zidane 5.0.6 → 5.1.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.
- package/README.md +37 -1
- package/dist/{agent-JhicgLOV.d.ts → agent-B0vrSTQ9.d.ts} +162 -4
- package/dist/agent-B0vrSTQ9.d.ts.map +1 -0
- package/dist/chat.d.ts +526 -81
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +2 -2
- package/dist/contexts/docker.d.ts +7 -0
- package/dist/contexts/docker.d.ts.map +1 -0
- package/dist/{contexts-3Arvn7yR.js → contexts/docker.js} +2 -128
- package/dist/contexts/docker.js.map +1 -0
- package/dist/contexts-BwiHIr2w.js +129 -0
- package/dist/contexts-BwiHIr2w.js.map +1 -0
- package/dist/contexts.d.ts +3 -2
- package/dist/contexts.js +2 -2
- package/dist/index-CFxhms_B.d.ts +1303 -0
- package/dist/index-CFxhms_B.d.ts.map +1 -0
- package/dist/index-DYcymRtr.d.ts +26 -0
- package/dist/index-DYcymRtr.d.ts.map +1 -0
- package/dist/{index-t_W9i7Ql.d.ts → index-X6Q9PN_A.d.ts} +3 -3
- package/dist/{index-t_W9i7Ql.d.ts.map → index-X6Q9PN_A.d.ts.map} +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +10 -9
- package/dist/index.js.map +1 -1
- package/dist/login-B7b7NNJQ.js +1277 -0
- package/dist/login-B7b7NNJQ.js.map +1 -0
- package/dist/{mcp-Dw-fRPVk.js → mcp-BgwK6ySj.js} +184 -9
- package/dist/mcp-BgwK6ySj.js.map +1 -0
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +1 -1
- package/dist/{messages-xaYMMFlb.js → messages-BAFLvH_z.js} +1 -1
- package/dist/{messages-xaYMMFlb.js.map → messages-BAFLvH_z.js.map} +1 -1
- package/dist/{presets-BRFH2qsQ.js → presets-CI8_fyvX.js} +2 -2
- package/dist/{presets-BRFH2qsQ.js.map → presets-CI8_fyvX.js.map} +1 -1
- package/dist/presets.d.ts +2 -2
- package/dist/presets.js +1 -1
- package/dist/{providers-BCbdv99U.js → providers-C6-vhaVu.js} +2 -2
- package/dist/{providers-BCbdv99U.js.map → providers-C6-vhaVu.js.map} +1 -1
- package/dist/providers.d.ts +1 -1
- package/dist/providers.js +2 -2
- package/dist/session/sqlite.d.ts +1 -1
- package/dist/{session-791hhrFa.js → session-pS4Vt4dl.js} +1 -1
- package/dist/{session-791hhrFa.js.map → session-pS4Vt4dl.js.map} +1 -1
- package/dist/session.d.ts +1 -1
- package/dist/session.js +2 -2
- package/dist/skills.d.ts +2 -2
- package/dist/{stats-DZIsGqzu.js → stats-DvCtBRwK.js} +1 -1
- package/dist/{stats-DZIsGqzu.js.map → stats-DvCtBRwK.js.map} +1 -1
- package/dist/{theme-C3JHZ5y9.d.ts → tool-formatters-D7cN3T_W.d.ts} +932 -31
- package/dist/tool-formatters-D7cN3T_W.d.ts.map +1 -0
- package/dist/{tools-CLazLRb4.js → tools-d1yeA6xK.js} +399 -13
- package/dist/tools-d1yeA6xK.js.map +1 -0
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +1 -1
- package/dist/tui.d.ts +426 -68
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +3966 -878
- package/dist/tui.js.map +1 -1
- package/dist/{turn-operations-BfEh-GER.js → turn-operations-lsUMITng.js} +2550 -206
- package/dist/turn-operations-lsUMITng.js.map +1 -0
- package/dist/types-Bx_F8jet.js.map +1 -1
- package/dist/{index-CXVvqTQj.d.ts → types-OtrV6LJT.d.ts} +2 -27
- package/dist/types-OtrV6LJT.d.ts.map +1 -0
- package/dist/types.d.ts +4 -3
- package/dist/types.js +1 -1
- package/package.json +5 -1
- package/dist/agent-JhicgLOV.d.ts.map +0 -1
- package/dist/contexts-3Arvn7yR.js.map +0 -1
- package/dist/index-2yLUyTbc.d.ts +0 -430
- package/dist/index-2yLUyTbc.d.ts.map +0 -1
- package/dist/index-CXVvqTQj.d.ts.map +0 -1
- package/dist/mcp-Dw-fRPVk.js.map +0 -1
- package/dist/theme-C3JHZ5y9.d.ts.map +0 -1
- package/dist/tools-CLazLRb4.js.map +0 -1
- package/dist/turn-operations-BfEh-GER.js.map +0 -1
package/dist/chat.d.ts
CHANGED
|
@@ -1,10 +1,269 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Ot as SessionTurn, Rt as TurnUsage, T as SkillsConfig, W as Provider, x as SkillConfig } from "./agent-B0vrSTQ9.js";
|
|
2
|
+
import { K as McpCredentialEntry, q as McpCredentialStore } from "./index-CFxhms_B.js";
|
|
3
|
+
import { m as SourcedScanPath } from "./index-X6Q9PN_A.js";
|
|
4
|
+
import { $ as PlanRequest, $n as singleAgentRegistry, $t as DEFAULT_KEYBINDINGS, A as useSafeModeQueue, An as OUTPUT_RESERVE_TOKENS, At as isEditErrorResult, B as parseMcpsFile, Bn as openaiDescriptor, Bt as titleFromTurns, C as writeSessionExport, Cn as useCompletion, Ct as ResolvedConfig, D as SafeModeActions, Dn as detectAuth, Dt as createStateStore, E as RequestApproval, En as ProviderKey, Et as TuiState, F as DiscoveryError, Fn as effectiveContextWindow, Ft as loadState, G as InteractionRequest, Gn as AgentRegistry, Gt as EditPayload, H as AnswerValue, Hn as piIdOf, Ht as toolResultText, I as DiscoveryResult, In as getContextWindow, It as marginTopFor, J as InteractionsProvider, Jn as DEFAULT_AGENT_ID, Jt as Screen, K as InteractionResponse, Kn as BUILD_AGENT, Kt as Owner, L as buildMcpServers, Ln as getModelInfo, Lt as saveState, M as PromptSegmentRef, Mn as anthropicDescriptor, Mt as isVisible, N as splitPromptSegments, Nn as cerebrasDescriptor, Nt as lastContextSizeFromTurns, O as SafeModeProvider, On as BUILTIN_PROVIDERS, Ot as deriveSessionTitle, P as DiscoveredMcp, Pn as credKeyOf, Pt as listSessionMeta, Q as PlanPayload, Qn as resolveAgentId, Qt as ToolCallDisplay, R as defaultMcpsConfigPaths, Rn as modelSupportsReasoning, Rt as selectableTurnIds, S as resolveSessionExportTarget, Sn as mergeReferences, St as ProviderRegistry, T as ApprovalRequest, Tn as ProviderAuth, Tt as StateStoreApi, U as ConfirmQuestion, Un as AgentAccent, Ut as turnSelectionOwnership, V as ASK_USER_TOOL, Vn as openrouterDescriptor, Vt as toolCallPreview, W as CreateInteractionToolsOptions, Wn as AgentProfile, Wt as EditHunk, X as PendingInteractionEntry, Xn as PLAN_AGENT, Xt as Settings, Y as PRESENT_PLAN_TOOL, Yn as DEFAULT_PERSIST_EXCLUDE_TOOLS, Yt as SessionMeta, Z as PlanDecision, Zn as accentColor, Zt as StreamEvent, _ as resolveTheme, _n as CompletionReference, _t as useInteractionsQueue, a as formatToolCall, an as ParsedBinding, at as QuestionRequest, b as SessionExportTarget, bn as collectReferences, bt as useEnabledToggleSet, c as ChipColorMap, cn as matchesBinding, ct as SelectQuestion, d as SyntaxTokenStyle, dn as readKeybindings, dt as createInteractionTools, en as KEYBINDING_DEFS, et as PlanResponse, f as Theme, fn as stripJsonComments, ft as isInteractionTool, g as resolveChipColor, gn as CompletionProvider, gt as useInteractionsActions, h as ThemeSurfaces, hn as CompletionItem, ht as serializeInteractionResponse, i as displayNameFor, in as KeyBindings, it as QuestionPayload, j as PromptSegment, jn as ProviderDescriptor, jt as isTurnHighlighted, k as useSafeModeActions, kn as ModelInfo, kt as eventsFromTurns, l as DEFAULT_THEME, ln as mergeKeybindings, lt as TextQuestion, m as ThemeSelect, mn as CompletionContext, mt as pendingInteractionsFromTurns, n as ToolDisplayMeta, nn as KeyAction, nt as Question, o as BUILTIN_THEMES, on as ensureKeybindingsFile, ot as QuestionResponse, p as ThemeColors, pn as ActiveTrigger, pt as makeRequestInteraction, q as InteractionsActions, qn as BUILTIN_AGENTS, qt as Picked, r as ToolFormatLine, rn as KeyBindingDef, rt as QuestionChoice, s as ChipColor, sn as keybindingsPath, st as QuestionType, t as TOOL_DISPLAY, tn as KEYBINDING_DEF_BY_ACTION, tt as PlanStep, u as SyntaxStyles, un as parseBindingSpec, ut as buildResumedToolResultsTurn, v as SessionExportAnchor, vn as CompletionState, vt as EnabledAllowlistKey, w as ApprovalDecision, wn as AuthMethod, wt as resolveConfig, x as renderSession, xn as findActiveTrigger, xt as ChatOptions, y as SessionExportFormat, yn as applyInsert, yt as EnabledToggleSet, z as discoverProjectMcps, zn as modelsForDescriptor, zt as stripSpawnTokensLine } from "./tool-formatters-D7cN3T_W.js";
|
|
4
5
|
import { OAuthCredentials } from "@mariozechner/pi-ai/oauth";
|
|
5
6
|
import { Dispatch, ReactNode, SetStateAction } from "react";
|
|
6
7
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
7
|
-
|
|
8
|
+
//#region src/chat/agent-prompt.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Agent system-prompt fragments — composable doctrine for built-in profiles.
|
|
11
|
+
*
|
|
12
|
+
* Each `const` below is one self-contained section of a system prompt. They
|
|
13
|
+
* exist as exports so SDK consumers can pick and choose: build a custom
|
|
14
|
+
* profile by spreading them in {@link buildBuildSystem} order, drop a fragment
|
|
15
|
+
* for a stricter / looser agent, or compose with project-specific prose.
|
|
16
|
+
*
|
|
17
|
+
* The fragments are deliberately byte-stable across sessions — every doctrine
|
|
18
|
+
* piece reads the same on every turn so the system-prompt cache breakpoint
|
|
19
|
+
* (anthropic ephemeral, `src/providers/anthropic.ts:327`) keeps hitting cache.
|
|
20
|
+
* Runtime-derived content (cwd, date) lives in {@link envSection} and is
|
|
21
|
+
* computed at agent-build time, not per-turn — same anchor, same cache.
|
|
22
|
+
*
|
|
23
|
+
* The TUI overrides `agent.run({ system })` with the composed string at
|
|
24
|
+
* session activation so a moved cwd or rolled-over date refreshes the
|
|
25
|
+
* prefix; SDK consumers calling `createAgent({ system })` directly get the
|
|
26
|
+
* cwd-less variant from the preset and can wrap their own env section.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Lead line — short, version-stable, written in the same key as Claude Code's
|
|
30
|
+
* identity prefix (`constants/system.ts:10` in claude-code). Models trained
|
|
31
|
+
* on similar prefixes anchor faster; keep this immutable across releases.
|
|
32
|
+
*/
|
|
33
|
+
declare const IDENTITY_PREFIX = "You are zidane, a terminal-based coding agent that helps the user with software-engineering tasks.";
|
|
34
|
+
interface EnvSectionOptions {
|
|
35
|
+
/**
|
|
36
|
+
* The agent's actual working directory — what `process.cwd()` reports
|
|
37
|
+
* and what its tool calls resolve relative paths against. Distinct
|
|
38
|
+
* from {@link EnvSectionOptions.projectRoot}, which carries the
|
|
39
|
+
* project anchor when the user spawned from a subdirectory.
|
|
40
|
+
*/
|
|
41
|
+
cwd: string;
|
|
42
|
+
/**
|
|
43
|
+
* Project root (typically the git root). When set AND different from
|
|
44
|
+
* `cwd`, the rendered env block discloses both AND adds a path-
|
|
45
|
+
* convention note — file paths coming from the user's `@`-completion
|
|
46
|
+
* are project-root-relative, NOT cwd-relative, so the model needs to
|
|
47
|
+
* know there's a wider anchor to resolve them against. When omitted
|
|
48
|
+
* or equal to `cwd`, the block stays compact (no project-root line,
|
|
49
|
+
* no note) — same wording as before the subdirectory disclosure
|
|
50
|
+
* landed, so users running from a project's root see no extra text.
|
|
51
|
+
*/
|
|
52
|
+
projectRoot?: string;
|
|
53
|
+
/** ISO date (YYYY-MM-DD). Defaults to today. Pinned for tests. */
|
|
54
|
+
date?: string;
|
|
55
|
+
/** Platform string. Defaults to `process.platform`. Pinned for tests. */
|
|
56
|
+
platform?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Render the env anchor block. Plain text — XML tags only because models
|
|
60
|
+
* lean on them as structural cues, not because we parse them anywhere.
|
|
61
|
+
*
|
|
62
|
+
* Kept narrow on purpose: cwd / projectRoot / date / platform are the
|
|
63
|
+
* knobs the model can't infer from the conversation. Anything else
|
|
64
|
+
* (git branch, project name) belongs in CLAUDE.md / project-level
|
|
65
|
+
* prompts where the user opts in.
|
|
66
|
+
*
|
|
67
|
+
* Cache-stability: outputs are byte-stable per `(cwd, projectRoot,
|
|
68
|
+
* date, platform)` tuple. Repeated session activations against the
|
|
69
|
+
* same workspace produce the same prefix → provider's prompt cache
|
|
70
|
+
* hits across turns + across sessions in the same host process.
|
|
71
|
+
*/
|
|
72
|
+
declare function envSection(opts: EnvSectionOptions): string;
|
|
73
|
+
/**
|
|
74
|
+
* Software-engineering doctrine. Lifted in spirit from claude-code's
|
|
75
|
+
* `# Doing tasks` (`constants/prompts.ts:199-253`). Key levers:
|
|
76
|
+
*
|
|
77
|
+
* - Stick to scope — prevents speculative refactors that double output tokens.
|
|
78
|
+
* - No narration comments — prevents inflating diffs with `// Import the module` lines.
|
|
79
|
+
* - Verify before claiming done — prevents false-positive reports that force a follow-up turn.
|
|
80
|
+
*/
|
|
81
|
+
declare const DOING_TASKS_DOCTRINE = "# Doing tasks\n- Stick to the scope you were asked for. Don't add features, refactor unrelated code, or \"improve\" things beyond the request. A bug fix doesn't need surrounding cleanup; a small feature doesn't need extra configurability.\n- Don't add comments, docstrings, or type annotations to code you didn't change. Only comment where the WHY is non-obvious (hidden constraint, subtle invariant, workaround). Never narrate WHAT the code does \u2014 well-named identifiers already do that.\n- Trust internal code and framework guarantees. Validate at system boundaries (user input, external APIs), not everywhere. Skip backwards-compat shims unless asked.\n- Don't create helpers, utilities, or abstractions for one-time operations. Three similar lines beat a premature abstraction. The right amount of complexity is what the task actually requires.\n- Before reporting a task complete, verify it actually works: run the test, execute the script, check the output. Report outcomes faithfully \u2014 if tests fail, say so with the relevant output. Never claim \"all tests pass\" when output shows failures.\n- If you spot a bug adjacent to what was asked, or notice the request is based on a misconception, say so. You are a collaborator, not just an executor.";
|
|
82
|
+
/**
|
|
83
|
+
* zidane-specific token-economy doctrine. No claude-code analog — this is
|
|
84
|
+
* the prose half of the `behavior.{compactStrategy, elideStaleReads,
|
|
85
|
+
* toolDisclosure, toolOutputBudget}` defaults. The behavior flags do the
|
|
86
|
+
* heavy lifting at the wire level; this prompt nudges the model away from
|
|
87
|
+
* the access patterns that defeat them.
|
|
88
|
+
*/
|
|
89
|
+
declare const TOKEN_DISCIPLINE_DOCTRINE = "# Working efficiently\n- Read a file once. Re-reading the same file in the same session wastes context \u2014 the prior `read_file` result is still in your view (and stale reads after an edit are elided automatically).\n- Narrow before you read. `grep` / `glob` to locate, then `read_file` on the specific file. Don't open a 2000-line file when you only need one function.\n- Prefer `edit` / `multi_edit` over `write_file` for surgical changes \u2014 full overwrites are larger payloads and easier to get wrong.\n- Spawn a subagent (`spawn`) for self-contained research dives or codegen passes that don't need the parent's context. The child runs in its own context window \u2014 you only get its final report back.\n- Don't grep for things already shown to you, list directories you already saw, or re-execute commands whose output is still above. Tool budgets nudge against runaway exploration but the cheaper fix is to not start the loop.\n\nTool results may be elided, persisted, or replaced as the conversation grows: stale `read_file` outputs become short stubs after the file is edited, older tool results may be tail-compacted, and large outputs are written to disk and replaced inline with a `<persisted-output tool=\"\u2026\" bytes=\"\u2026\" path=\"\u2026\">` block carrying a 2 KiB head preview plus the filesystem path. Copy load-bearing data into your own response text before you'd need to recover it later \u2014 and when you see a `<persisted-output>` block whose preview isn't enough, call `read_file` on the persisted path to retrieve the full payload.";
|
|
90
|
+
/**
|
|
91
|
+
* User-facing communication style. Lifted from claude-code's
|
|
92
|
+
* `# Communicating with the user` + `# Tone and style` sections (~404-442).
|
|
93
|
+
* The "no colon before tool calls" rule matters because models often
|
|
94
|
+
* generate "Let me check this file:" right before a tool call that the
|
|
95
|
+
* user never sees rendered.
|
|
96
|
+
*/
|
|
97
|
+
declare const COMMUNICATION_DOCTRINE = "# Communicating with the user\n- You're writing for a person, not logging to a console. Tool calls and reasoning are not visible \u2014 only your text output is. Before your first tool call, briefly state what you're about to do.\n- Give short updates at load-bearing moments: root cause found, direction change, real progress. Skip play-by-play.\n- Write in flowing prose. Avoid excessive em dashes, fragments, symbols, or notation. Tables when they help, not by default.\n- Don't use a colon before tool calls. \"Let me read the file:\" + tool call reads as broken \u2014 write \"Let me read the file.\" with a period.\n- Reference code as `file:line` so the user can navigate (e.g. `src/agent.ts:1213`).\n- No emojis unless the user explicitly asks.";
|
|
98
|
+
/**
|
|
99
|
+
* Reversibility / blast-radius doctrine. Mirrors claude-code's `# Executing
|
|
100
|
+
* actions with care` (255-267). The TUI's safe-mode already gates risky
|
|
101
|
+
* tool calls behind explicit approval, but this prompt teaches the model
|
|
102
|
+
* to anticipate the gate rather than be surprised by it — and to ask
|
|
103
|
+
* before reaching for destructive shortcuts.
|
|
104
|
+
*/
|
|
105
|
+
declare const ACTIONS_WITH_CARE_DOCTRINE = "# Executing actions with care\nReversibility scales the required caution. Local edits, tests, and reads are free to take. Destructive or shared-state actions need explicit user confirmation \u2014 `rm -rf`, dropping tables, force-pushing, modifying CI, sending messages, posting to external services. A user approving an action once does NOT mean they approve it in all contexts.\n\nWhen you hit an obstacle, do not use destructive actions as a shortcut to make it go away. Measure twice, cut once.";
|
|
106
|
+
/**
|
|
107
|
+
* How to brief a subagent. Spawning a child agent is the highest-leverage
|
|
108
|
+
* token move in zidane — a 5k-token research dive becomes a 200-token
|
|
109
|
+
* summary in the parent's context. But shallow prompts produce shallow
|
|
110
|
+
* work, so the doctrine is mostly about quality of the briefing.
|
|
111
|
+
*
|
|
112
|
+
* Lifted from claude-code's `## Writing the prompt` tool-prompt
|
|
113
|
+
* (`tools/AgentTool/prompt.ts:99-113`).
|
|
114
|
+
*/
|
|
115
|
+
declare const SUBAGENT_GUIDANCE = "# When spawning subagents\nBrief the child agent like a smart colleague who just walked in \u2014 it has not seen this conversation and doesn't know what you've tried or why this matters.\n- Explain what you're trying to accomplish and why.\n- Describe what you've already learned or ruled out.\n- Give enough context that the child can make judgment calls, not just follow narrow steps.\n- For investigations, hand over the question. For lookups, hand over the exact command.\n- Never delegate understanding (\"based on your findings, fix the bug\"). Synthesize yourself \u2014 include file paths, line numbers, and the specific change you want.\n\nTerse command-style prompts produce shallow, generic work.";
|
|
116
|
+
/**
|
|
117
|
+
* Plan-mode framing. Replaces the previous one-liner with explicit phases
|
|
118
|
+
* (explore → propose → submit), drawing on claude-code's iterative-plan
|
|
119
|
+
* mode (`utils/messages.ts:3323-3383`). Always paired with the read-only
|
|
120
|
+
* tool set in {@link PLAN_AGENT}.
|
|
121
|
+
*/
|
|
122
|
+
declare const PLAN_MODE_DOCTRINE = "# Plan mode \u2014 read-only\nYou are in PLAN mode. You can read files, list directories, and search the codebase \u2014 but you CANNOT modify files, run shell commands, or spawn subagents. Use this mode to investigate, understand, and design a proposal.\n\n## Loop\n1. **Explore** \u2014 Read code. Look for existing functions, utilities, and patterns to reuse.\n2. **Ask** \u2014 When you hit an ambiguity only the user can resolve (requirements, preferences, tradeoffs), call `ask_user` with the full batch of questions.\n3. **Propose** \u2014 When the plan is ready, submit it via `present_plan` with a concrete title, the markdown body, and optional structured steps. The user approves, rejects, or asks for revisions.\n\n## Good plans\n- Cover what to change, which files to modify, what existing code to reuse (with file paths), and how to verify the change end-to-end.\n- Reference real symbols and line numbers from your exploration.\n- Surface only your recommended approach, not every alternative.\n\nThe user will switch to Build mode to execute an approved plan.";
|
|
123
|
+
/**
|
|
124
|
+
* How to use `present_plan` / `ask_user`. Kept short — the tool descriptions
|
|
125
|
+
* carry the schema details; this prompt covers the cross-cutting *when*.
|
|
126
|
+
*
|
|
127
|
+
* Previously lived inline in `src/chat/agents.ts` as `INTERACTION_GUIDANCE`.
|
|
128
|
+
* Moved here so a custom profile can pull it in independently.
|
|
129
|
+
*/
|
|
130
|
+
declare const INTERACTION_GUIDANCE = "# Interacting with the user\n- Call `present_plan` when you have a concrete proposal that materially changes the workspace and want explicit confirmation before executing.\n- Call `ask_user` when clarifying answers materially change the next steps. Batch related questions into one call \u2014 every call pauses the conversation.\n- Use both sparingly. Don't ask what you could find out by reading the code.";
|
|
131
|
+
interface BuildSystemOptions {
|
|
132
|
+
/** Actual working directory. Omitted ⇒ no env section is rendered. */
|
|
133
|
+
cwd?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Project root (typically the git root), when different from `cwd`.
|
|
136
|
+
* When the user spawned the agent from a subdirectory of a larger
|
|
137
|
+
* project, this enables the env block's two-line disclosure + path-
|
|
138
|
+
* resolution note (see {@link envSection}). Same-as-`cwd` or
|
|
139
|
+
* omitted ⇒ the env block stays compact.
|
|
140
|
+
*/
|
|
141
|
+
projectRoot?: string;
|
|
142
|
+
/** Override date for tests. */
|
|
143
|
+
date?: string;
|
|
144
|
+
/** Override platform for tests. */
|
|
145
|
+
platform?: string;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Compose the Build-mode system prompt.
|
|
149
|
+
*
|
|
150
|
+
* Order matters for cache stability: identity → env → doctrine → guidance.
|
|
151
|
+
* Env comes before doctrine so a cwd change rebuilds only the head of the
|
|
152
|
+
* prompt; the doctrine tail stays byte-identical across sessions and rides
|
|
153
|
+
* the cache.
|
|
154
|
+
*
|
|
155
|
+
* The fragments are joined with blank lines so the model sees clean section
|
|
156
|
+
* breaks. Don't reorder lightly — every reorder costs one cache miss across
|
|
157
|
+
* every active session.
|
|
158
|
+
*/
|
|
159
|
+
declare function buildBuildSystem(opts?: BuildSystemOptions): string;
|
|
160
|
+
/**
|
|
161
|
+
* Compose the Plan-mode system prompt. Subset of Build: drops the
|
|
162
|
+
* subagent + actions-with-care fragments (no shell, no spawn in plan
|
|
163
|
+
* mode) and uses `PLAN_MODE_DOCTRINE` instead of `DOING_TASKS_DOCTRINE`.
|
|
164
|
+
*/
|
|
165
|
+
declare function buildPlanSystem(opts?: BuildSystemOptions): string;
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/chat/auto-compact.d.ts
|
|
168
|
+
/**
|
|
169
|
+
* Auto-compaction trigger policy — decide whether the latest turn's usage
|
|
170
|
+
* has crossed the threshold that should fire `compactConversation` against
|
|
171
|
+
* the active session.
|
|
172
|
+
*
|
|
173
|
+
* Pure function, no I/O. Sits next to the chat-layer settings + providers
|
|
174
|
+
* so the same decision is reusable from a non-TUI host (a future GUI shell
|
|
175
|
+
* that wants to surface "Compact now" suggestions, a CI runner that wants
|
|
176
|
+
* to auto-compact between batches, …).
|
|
177
|
+
*
|
|
178
|
+
* Wire contract:
|
|
179
|
+
*
|
|
180
|
+
* - Inputs are the bits the TUI already tracks: latest `usage.input` (from
|
|
181
|
+
* `turn:after`), the model's raw context window (`getContextWindow`),
|
|
182
|
+
* and the user's settings (`autoCompact` + `autoCompactThreshold`).
|
|
183
|
+
* - Output is a discriminated outcome — `'fire'` when the trigger should
|
|
184
|
+
* run, `'skip'` with a reason otherwise. The reason is diagnostic only;
|
|
185
|
+
* callers don't branch on it but tests + debug logs need it.
|
|
186
|
+
*
|
|
187
|
+
* No state. Same inputs → same answer.
|
|
188
|
+
*/
|
|
189
|
+
/**
|
|
190
|
+
* Inputs to {@link shouldAutoCompact}.
|
|
191
|
+
*
|
|
192
|
+
* Kept as a struct so the call site reads as the predicate it is, and so
|
|
193
|
+
* future inputs (per-session opt-out, recent-compaction cooldown, …) land
|
|
194
|
+
* without re-threading every consumer.
|
|
195
|
+
*/
|
|
196
|
+
interface AutoCompactInput {
|
|
197
|
+
/** User's master toggle. `false` → trigger never fires. */
|
|
198
|
+
enabled: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Threshold expressed as a fraction of the effective context window
|
|
201
|
+
* (e.g. `0.8` = 80%). Values outside the open interval `(0, 1)` are
|
|
202
|
+
* rejected with `'invalid-threshold'` — `<= 0` is meaningless, and
|
|
203
|
+
* `>= 1` would schedule the trigger for "after we've already
|
|
204
|
+
* overflowed" which is too late to be useful.
|
|
205
|
+
*/
|
|
206
|
+
threshold: number;
|
|
207
|
+
/**
|
|
208
|
+
* Latest input-token count from the last `turn:after`. Must be a
|
|
209
|
+
* non-negative finite number; `NaN` / `±Infinity` / negative values
|
|
210
|
+
* are treated as "no usable signal" and the trigger skips
|
|
211
|
+
* conservatively (we'd rather defer compaction than fire on garbage).
|
|
212
|
+
*/
|
|
213
|
+
inputTokens: number;
|
|
214
|
+
/**
|
|
215
|
+
* Model's raw context window from `getContextWindow(descriptor, model)`.
|
|
216
|
+
* `null` for unknown / custom models — the trigger skips since we can't
|
|
217
|
+
* compute a ratio.
|
|
218
|
+
*/
|
|
219
|
+
rawContextWindow: number | null;
|
|
220
|
+
/**
|
|
221
|
+
* Whether a compaction is already in flight for this session. The TUI
|
|
222
|
+
* tracks this with a ref + Promise; passing it through the predicate
|
|
223
|
+
* lets the test suite assert "doesn't double-fire" without spinning up
|
|
224
|
+
* the agent loop.
|
|
225
|
+
*/
|
|
226
|
+
alreadyCompacting?: boolean;
|
|
227
|
+
}
|
|
228
|
+
type AutoCompactDecision = {
|
|
229
|
+
kind: 'fire';
|
|
230
|
+
usedFraction: number;
|
|
231
|
+
effectiveWindow: number;
|
|
232
|
+
} | {
|
|
233
|
+
kind: 'skip';
|
|
234
|
+
reason: 'disabled' | 'unknown-window' | 'invalid-threshold' | 'invalid-input-tokens' | 'under-threshold' | 'already-compacting';
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* Decide whether auto-compaction should fire for the latest turn.
|
|
238
|
+
*
|
|
239
|
+
* Order of checks is deliberate: cheapest / most common skips first
|
|
240
|
+
* (`disabled` is one boolean read; `unknown-window` is the predictable
|
|
241
|
+
* miss for custom models), invariant violations next, then the actual
|
|
242
|
+
* threshold math. `already-compacting` runs last so the diagnostic
|
|
243
|
+
* surfaces correctly when the predicate is called inside an existing
|
|
244
|
+
* compaction window.
|
|
245
|
+
*/
|
|
246
|
+
declare function shouldAutoCompact(input: AutoCompactInput): AutoCompactDecision;
|
|
247
|
+
//#endregion
|
|
248
|
+
//#region src/chat/browser.d.ts
|
|
249
|
+
/**
|
|
250
|
+
* Best-effort cross-platform browser open.
|
|
251
|
+
*
|
|
252
|
+
* macOS uses `open`, Linux uses `xdg-open`, Windows uses `start`. Failures
|
|
253
|
+
* are swallowed — both callers (AI-provider OAuth + MCP-server OAuth) show
|
|
254
|
+
* the URL on-screen for manual click anyway, and the underlying flows have
|
|
255
|
+
* their own progress/cancel paths.
|
|
256
|
+
*
|
|
257
|
+
* Uses `spawn` (not `exec`) so the URL is passed as an argv element rather
|
|
258
|
+
* than interpolated into a shell command — URLs containing `&`, `?`, `"`,
|
|
259
|
+
* or other shell metacharacters don't need quoting.
|
|
260
|
+
*
|
|
261
|
+
* Detached + unref so the spawned helper outlives the parent: the user
|
|
262
|
+
* can finish authorizing in the browser even if the TUI is later
|
|
263
|
+
* suspended (Ctrl-Z) or killed.
|
|
264
|
+
*/
|
|
265
|
+
declare function tryOpenBrowser(url: string): void;
|
|
266
|
+
//#endregion
|
|
8
267
|
//#region src/chat/files-discovery.d.ts
|
|
9
268
|
/**
|
|
10
269
|
* Project file discovery for the `@`-prefixed files completion provider.
|
|
@@ -167,6 +426,41 @@ declare function removeProviderCredential(dataDir: string, descriptor: ProviderD
|
|
|
167
426
|
*/
|
|
168
427
|
declare function applyApiKeyEnv(dataDir: string, registry: Readonly<Record<string, ProviderDescriptor>>): void;
|
|
169
428
|
//#endregion
|
|
429
|
+
//#region src/chat/edit-diff.d.ts
|
|
430
|
+
declare function extractEditPayload(name: string, input: Record<string, unknown>, priorContent?: string): EditPayload | undefined;
|
|
431
|
+
type DiffOp = 'context' | 'add' | 'remove';
|
|
432
|
+
interface DiffLine {
|
|
433
|
+
op: DiffOp;
|
|
434
|
+
text: string;
|
|
435
|
+
}
|
|
436
|
+
declare function computeLineDiff(oldString: string, newString: string): DiffLine[];
|
|
437
|
+
/**
|
|
438
|
+
* Split a string into lines preserving empty lines but dropping the
|
|
439
|
+
* implicit trailing `""` produced by a final `\n`. Exported only for
|
|
440
|
+
* its tests — callers should use `computeLineDiff`.
|
|
441
|
+
*/
|
|
442
|
+
declare function splitLines(s: string): string[];
|
|
443
|
+
interface InlineSegment {
|
|
444
|
+
text: string;
|
|
445
|
+
changed: boolean;
|
|
446
|
+
}
|
|
447
|
+
interface InlineDiff {
|
|
448
|
+
oldSegments: InlineSegment[];
|
|
449
|
+
newSegments: InlineSegment[];
|
|
450
|
+
}
|
|
451
|
+
declare function computeInlineDiff(oldLine: string, newLine: string): InlineDiff;
|
|
452
|
+
/**
|
|
453
|
+
* Tokenize on word / non-word boundaries. Each run of `\w+` is one
|
|
454
|
+
* token; each run of `\W+` (whitespace, punctuation) is another. This
|
|
455
|
+
* gives the right granularity for renames (`oldName` → `newName`) and
|
|
456
|
+
* for symbol swaps (`+ → -`) without exploding into per-char segments.
|
|
457
|
+
*
|
|
458
|
+
* Exported only for its tests.
|
|
459
|
+
*/
|
|
460
|
+
declare function tokenize(s: string): string[];
|
|
461
|
+
declare function buildUnifiedDiff(payload: EditPayload): string;
|
|
462
|
+
declare function filetypeFromPath(path: string): string | undefined;
|
|
463
|
+
//#endregion
|
|
170
464
|
//#region src/chat/format.d.ts
|
|
171
465
|
/** Compact token formatter — 12_415 → "12.4k", 1_234_567 → "1.23M". */
|
|
172
466
|
declare function fmtTokens(n: number): string;
|
|
@@ -174,6 +468,21 @@ declare function fmtTokens(n: number): string;
|
|
|
174
468
|
declare function ageString(ts: number, now?: number): string;
|
|
175
469
|
/** Six-char short form of a session id for headers and lists. */
|
|
176
470
|
declare function shortId(id: string): string;
|
|
471
|
+
/**
|
|
472
|
+
* Compact an absolute path for display: replace the user's `$HOME`
|
|
473
|
+
* prefix with `~` (so `/Users/yael/Code/zidane` → `~/Code/zidane`),
|
|
474
|
+
* and optionally left-truncate with an ellipsis when the result
|
|
475
|
+
* still exceeds `maxWidth` (so the path's *tail* — the part the user
|
|
476
|
+
* recognizes — stays visible: `…/zidane` rather than `/Users/yaeluil…`).
|
|
477
|
+
*
|
|
478
|
+
* `maxWidth` is the maximum *display width* in cells. Omit to skip
|
|
479
|
+
* truncation. Paths outside `$HOME` are returned verbatim modulo
|
|
480
|
+
* truncation. The ellipsis (`…`) counts as one cell.
|
|
481
|
+
*
|
|
482
|
+
* `home` overrides `os.homedir()` for tests; production callers leave
|
|
483
|
+
* it undefined and pay the cheap one-syscall lookup per call.
|
|
484
|
+
*/
|
|
485
|
+
declare function compactPath(path: string, maxWidth?: number, home?: string): string;
|
|
177
486
|
//#endregion
|
|
178
487
|
//#region src/chat/generate-title.d.ts
|
|
179
488
|
interface GenerateSessionTitleOptions {
|
|
@@ -220,6 +529,137 @@ declare function generateSessionTitle({
|
|
|
220
529
|
*/
|
|
221
530
|
declare function cleanTitle(raw: string): string;
|
|
222
531
|
//#endregion
|
|
532
|
+
//#region src/chat/mcp-auth-state.d.ts
|
|
533
|
+
/**
|
|
534
|
+
* Per-server MCP OAuth status tracking, decoupled from the renderer.
|
|
535
|
+
*
|
|
536
|
+
* The TUI keeps a `Record<serverName, McpAuthStatus>` so it can render a
|
|
537
|
+
* "needs-auth" / "authorizing" / "error" badge in the MCP picker. The
|
|
538
|
+
* status map is driven entirely by hooks fired from the agent's MCP
|
|
539
|
+
* bootstrap + the interactive `loginMcpServer` flow — the reducer below
|
|
540
|
+
* is pure, makes no FS or network calls, and is shared between the live
|
|
541
|
+
* TUI store and the test harness.
|
|
542
|
+
*
|
|
543
|
+
* Status lifecycle:
|
|
544
|
+
*
|
|
545
|
+
* idle ──mcp:connect──▶ authed
|
|
546
|
+
* (bootstrap succeeded with stored tokens)
|
|
547
|
+
*
|
|
548
|
+
* idle ──mcp:auth:required──▶ needs-auth
|
|
549
|
+
* (bootstrap saw no/invalid tokens)
|
|
550
|
+
*
|
|
551
|
+
* needs-auth ──login()──▶ authorizing ──mcp:auth:url──▶ authorizing(url)
|
|
552
|
+
* ──mcp:auth:success──▶ authed
|
|
553
|
+
* ──mcp:auth:error──▶ error
|
|
554
|
+
*
|
|
555
|
+
* any ──logout──▶ idle
|
|
556
|
+
*
|
|
557
|
+
* Multiple servers progress through the lifecycle independently; the map
|
|
558
|
+
* is keyed by `McpServerConfig.name`.
|
|
559
|
+
*/
|
|
560
|
+
type McpAuthStatus = {
|
|
561
|
+
kind: 'idle';
|
|
562
|
+
} | {
|
|
563
|
+
kind: 'needs-auth';
|
|
564
|
+
reason: 'no-tokens' | 'auto-promoted';
|
|
565
|
+
} | {
|
|
566
|
+
kind: 'authorizing';
|
|
567
|
+
url?: string;
|
|
568
|
+
} | {
|
|
569
|
+
kind: 'authed';
|
|
570
|
+
} | {
|
|
571
|
+
kind: 'error';
|
|
572
|
+
error: string;
|
|
573
|
+
};
|
|
574
|
+
/**
|
|
575
|
+
* Map of server name → status. `idle` is the implicit default for any
|
|
576
|
+
* server NOT present in the map, so the renderer treats `undefined` as
|
|
577
|
+
* `{ kind: 'idle' }` and the map can stay sparse.
|
|
578
|
+
*/
|
|
579
|
+
type McpAuthStateMap = Readonly<Record<string, McpAuthStatus>>;
|
|
580
|
+
/**
|
|
581
|
+
* Events the reducer accepts. Names mirror the agent hooks 1:1 plus two
|
|
582
|
+
* UI-only verbs (`login:start` / `login:cancel`) so the renderer can
|
|
583
|
+
* optimistically flip a row to `authorizing` before the SDK has emitted
|
|
584
|
+
* `mcp:auth:url` — useful when the loopback callback is slow to bind.
|
|
585
|
+
*/
|
|
586
|
+
type McpAuthEvent = {
|
|
587
|
+
type: 'auth-required';
|
|
588
|
+
name: string;
|
|
589
|
+
reason: 'no-tokens' | 'auto-promoted';
|
|
590
|
+
} | {
|
|
591
|
+
type: 'auth-url';
|
|
592
|
+
name: string;
|
|
593
|
+
url: string;
|
|
594
|
+
} | {
|
|
595
|
+
type: 'auth-success';
|
|
596
|
+
name: string;
|
|
597
|
+
} | {
|
|
598
|
+
type: 'auth-error';
|
|
599
|
+
name: string;
|
|
600
|
+
error: string;
|
|
601
|
+
} | {
|
|
602
|
+
type: 'connected';
|
|
603
|
+
name: string;
|
|
604
|
+
} | {
|
|
605
|
+
type: 'login:start';
|
|
606
|
+
name: string;
|
|
607
|
+
} | {
|
|
608
|
+
type: 'login:cancel';
|
|
609
|
+
name: string;
|
|
610
|
+
} | {
|
|
611
|
+
type: 'logout';
|
|
612
|
+
name: string;
|
|
613
|
+
} | {
|
|
614
|
+
type: 'reset';
|
|
615
|
+
name: string;
|
|
616
|
+
};
|
|
617
|
+
/**
|
|
618
|
+
* Apply one event to the state map. Pure, immutable — returns a new map
|
|
619
|
+
* with only the affected key reassigned.
|
|
620
|
+
*
|
|
621
|
+
* State transitions are simple "last write wins"; we don't gate (e.g.) a
|
|
622
|
+
* `login:start` from overriding `authorizing` because the loop layer
|
|
623
|
+
* never doubles those up — interactive login is serialized in the TUI.
|
|
624
|
+
*/
|
|
625
|
+
declare function reduceMcpAuth(state: McpAuthStateMap, event: McpAuthEvent): McpAuthStateMap;
|
|
626
|
+
/** Convenience getter — treats `undefined` as `idle`. */
|
|
627
|
+
declare function getMcpAuthStatus(state: McpAuthStateMap, name: string): McpAuthStatus;
|
|
628
|
+
//#endregion
|
|
629
|
+
//#region src/chat/mcp-auth-context.d.ts
|
|
630
|
+
/**
|
|
631
|
+
* Mount once near the top of the React tree (above `ModalRoot`). Children
|
|
632
|
+
* use `useMcpAuthState()` to read and `useMcpAuthDispatch()` to fire events.
|
|
633
|
+
*/
|
|
634
|
+
declare function McpAuthProvider({
|
|
635
|
+
children
|
|
636
|
+
}: {
|
|
637
|
+
children: ReactNode;
|
|
638
|
+
}): _$react_jsx_runtime0.JSX.Element;
|
|
639
|
+
declare function useMcpAuthState(): McpAuthStateMap;
|
|
640
|
+
declare function useMcpAuthDispatch(): (event: McpAuthEvent) => void;
|
|
641
|
+
//#endregion
|
|
642
|
+
//#region src/chat/mcp-credentials.d.ts
|
|
643
|
+
declare function mcpCredentialsPath(dataDir: string): string;
|
|
644
|
+
/**
|
|
645
|
+
* Build a file-backed `McpCredentialStore`. All per-server reads / writes
|
|
646
|
+
* funnel through the single `mcp-credentials.json` file — this keeps
|
|
647
|
+
* concurrent flows for different servers from clobbering each other since
|
|
648
|
+
* each save reads-modifies-writes the full file atomically.
|
|
649
|
+
*
|
|
650
|
+
* Two flows for the same server name CAN race (last write wins). MCP OAuth
|
|
651
|
+
* flows are user-driven and serial in practice (one login modal at a time),
|
|
652
|
+
* so this is acceptable; a per-server file split + cross-process lock would
|
|
653
|
+
* be required to handle a multi-process scenario.
|
|
654
|
+
*/
|
|
655
|
+
declare function createFileMcpCredentialStore(dataDir: string): McpCredentialStore;
|
|
656
|
+
/**
|
|
657
|
+
* Convenience patches for individual sub-fields. The provider class uses
|
|
658
|
+
* these so a `saveTokens` call doesn't have to round-trip `clientInformation`
|
|
659
|
+
* + `discoveryState` it never touched.
|
|
660
|
+
*/
|
|
661
|
+
declare function patchMcpCredential(store: McpCredentialStore, name: string, patch: Partial<McpCredentialEntry>): void;
|
|
662
|
+
//#endregion
|
|
223
663
|
//#region src/chat/model-catalog.d.ts
|
|
224
664
|
/** A model entry as displayed in the cross-provider picker. */
|
|
225
665
|
interface CatalogEntry {
|
|
@@ -298,6 +738,77 @@ interface OAuthFlowOptions {
|
|
|
298
738
|
*/
|
|
299
739
|
declare function runOAuthLogin(descriptor: ProviderDescriptor, options: OAuthFlowOptions): Promise<OAuthCredentials>;
|
|
300
740
|
//#endregion
|
|
741
|
+
//#region src/chat/project-root.d.ts
|
|
742
|
+
/**
|
|
743
|
+
* Git root detection — walks parents from `cwd` looking for a `.git`
|
|
744
|
+
* entry, returning the absolute path of the repo root or `null` when
|
|
745
|
+
* the search reaches the filesystem root.
|
|
746
|
+
*
|
|
747
|
+
* Why parent-walk over `git rev-parse --show-toplevel`:
|
|
748
|
+
*
|
|
749
|
+
* - Zero dependencies (no shell-out, no git binary requirement,
|
|
750
|
+
* works even when `git` is missing from `PATH`).
|
|
751
|
+
* - Pure-sync, deterministic, easy to test against tmp dirs.
|
|
752
|
+
* - Equally fast in practice — most lookups are a single `existsSync`.
|
|
753
|
+
*
|
|
754
|
+
* Recognizes `.git` as either:
|
|
755
|
+
*
|
|
756
|
+
* - A directory (standard repo layout).
|
|
757
|
+
* - A file containing `gitdir: …` (worktrees + submodules).
|
|
758
|
+
*
|
|
759
|
+
* Bare repos (no working tree) are intentionally NOT detected here —
|
|
760
|
+
* the TUI's data dir contract is "project working tree", and a bare
|
|
761
|
+
* repo has no working files to scope sessions against.
|
|
762
|
+
*/
|
|
763
|
+
/**
|
|
764
|
+
* Walk parents of `cwd` looking for a `.git` entry. Returns the
|
|
765
|
+
* absolute path of the directory containing `.git`, or `null` when no
|
|
766
|
+
* git repo is found above `cwd`.
|
|
767
|
+
*
|
|
768
|
+
* Stops at the filesystem root (`/`) — no infinite loop on `dirname`'s
|
|
769
|
+
* idempotent root case (`dirname('/')` returns `/`).
|
|
770
|
+
*/
|
|
771
|
+
declare function findGitRoot(cwd?: string): string | null;
|
|
772
|
+
//#endregion
|
|
773
|
+
//#region src/chat/project-user-paths.d.ts
|
|
774
|
+
/**
|
|
775
|
+
* Shared search-path builder for project + user config discovery.
|
|
776
|
+
*
|
|
777
|
+
* Both Skills (`skills/<name>/SKILL.md`) and MCP servers (`mcps.json`)
|
|
778
|
+
* follow the same first-found-wins order:
|
|
779
|
+
*
|
|
780
|
+
* 1. `{project-root}/.agents/<sub>` — project, agnostic convention
|
|
781
|
+
* 2. `{project-root}/.{prefix}/<sub>` — project, zidane (`.zidane` default)
|
|
782
|
+
* 3. `~/.agents/<sub>` — user, agnostic
|
|
783
|
+
* 4. `~/.{prefix}/<sub>` — user, zidane
|
|
784
|
+
*
|
|
785
|
+
* `{project-root}` is the git root walked up from `cwd` when present,
|
|
786
|
+
* else `cwd` itself. This pairs with the project-scoped session
|
|
787
|
+
* storage (`resolveStoragePaths`) so all three project-aware surfaces
|
|
788
|
+
* — sessions, mcps, skills — anchor at the same `.{prefix}/`.
|
|
789
|
+
*
|
|
790
|
+
* Centralizing the pattern keeps the four paths in one place — a third
|
|
791
|
+
* discovery surface (hooks, rules, …) gets the same convention for free
|
|
792
|
+
* and stays in lock-step on a prefix bump.
|
|
793
|
+
*/
|
|
794
|
+
/** A discovered path tagged with whether it lives in the project or the user dir. */
|
|
795
|
+
interface ProjectUserPath {
|
|
796
|
+
path: string;
|
|
797
|
+
source: 'project' | 'user';
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Resolve the four search paths for a given subdirectory (`skills`,
|
|
801
|
+
* `mcps.json`, …). Returns absolute paths regardless of whether they
|
|
802
|
+
* exist — the caller chooses to `existsSync`-filter or feed straight
|
|
803
|
+
* into a tolerant discovery routine.
|
|
804
|
+
*/
|
|
805
|
+
declare function projectUserPaths(opts: {
|
|
806
|
+
/** Subdirectory or filename relative to each search root. E.g. `'skills'`, `'mcps.json'`. */subPath: string; /** Discovery cwd. Default: `process.cwd()`. */
|
|
807
|
+
cwd?: string; /** User home directory. Default: `os.homedir()`. */
|
|
808
|
+
home?: string; /** Storage prefix. Leading dot tolerated. Default: `'.zidane'`. */
|
|
809
|
+
prefix?: string;
|
|
810
|
+
}): ProjectUserPath[];
|
|
811
|
+
//#endregion
|
|
301
812
|
//#region src/chat/safe-mode.d.ts
|
|
302
813
|
/**
|
|
303
814
|
* Safe-mode storage + matching for the TUI.
|
|
@@ -339,8 +850,16 @@ declare function addToSafelist(dataDir: string, projectDir: string, entry: strin
|
|
|
339
850
|
/** Read the safelist for one project. Returns `[]` for unknown projects. */
|
|
340
851
|
declare function getSafelist(dataDir: string, projectDir: string): readonly string[];
|
|
341
852
|
/**
|
|
342
|
-
* Tools that always pass without prompting
|
|
343
|
-
*
|
|
853
|
+
* Tools that always pass without prompting. Two categories:
|
|
854
|
+
*
|
|
855
|
+
* - **Pure reads** (`read_file`, `list_files`, `glob`, `grep`) — no
|
|
856
|
+
* side effects on disk or the model's own state.
|
|
857
|
+
* - **Interaction tools** (`ask_user`, `present_plan`) — the call
|
|
858
|
+
* itself surfaces a TUI picker the user has to answer, so prompting
|
|
859
|
+
* for approval first would mean "approve this prompt before you see
|
|
860
|
+
* the prompt": redundant + breaks the flow. The picker IS the gate.
|
|
861
|
+
*
|
|
862
|
+
* Users who want to gate any of these must disable safe-mode entirely
|
|
344
863
|
* (or fork this list in their own embedding).
|
|
345
864
|
*/
|
|
346
865
|
declare const IMPLICITLY_SAFE_TOOLS: readonly string[];
|
|
@@ -374,80 +893,6 @@ declare function isOnSafelist(entries: readonly string[], tool: string, input: R
|
|
|
374
893
|
*/
|
|
375
894
|
declare function suggestSafelistEntry(tool: string, input: Record<string, unknown>): string;
|
|
376
895
|
//#endregion
|
|
377
|
-
//#region src/chat/session-export.d.ts
|
|
378
|
-
/** File format supported by the exporter. */
|
|
379
|
-
type SessionExportFormat = 'markdown' | 'json';
|
|
380
|
-
/**
|
|
381
|
-
* Anchor for the resolved destination directory:
|
|
382
|
-
* - `project` — the nearest enclosing git repository (`<repoRoot>/.{prefix}/sessions`)
|
|
383
|
-
* - `home` — fallback when no repo was found (`~/.{prefix}/sessions`)
|
|
384
|
-
*/
|
|
385
|
-
type SessionExportAnchor = 'project' | 'home';
|
|
386
|
-
/** Resolved file destination for a session export. */
|
|
387
|
-
interface SessionExportTarget {
|
|
388
|
-
/** Absolute directory holding the file. May not exist yet — `writeSessionExport` creates it on demand. */
|
|
389
|
-
dir: string;
|
|
390
|
-
/** Absolute path of the file (`dir/{id}.{ext}`). */
|
|
391
|
-
filepath: string;
|
|
392
|
-
/** Where the destination was anchored. */
|
|
393
|
-
anchor: SessionExportAnchor;
|
|
394
|
-
}
|
|
395
|
-
/** Options shared by every resolve / write entry-point. */
|
|
396
|
-
interface ResolveOptions {
|
|
397
|
-
/** Discovery cwd. Defaults to `process.cwd()`. */
|
|
398
|
-
cwd?: string;
|
|
399
|
-
/** User home directory. Defaults to `os.homedir()`. */
|
|
400
|
-
home?: string;
|
|
401
|
-
/**
|
|
402
|
-
* Storage prefix. Leading dot tolerated (`zidane` and `.zidane` are
|
|
403
|
-
* equivalent). Defaults to `'.zidane'`.
|
|
404
|
-
*/
|
|
405
|
-
prefix?: string;
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* Resolve the export target for a session id + format. Pure: no fs
|
|
409
|
-
* write happens here, the caller decides whether to `existsSync` the
|
|
410
|
-
* directory or hand the path to `writeSessionExport`.
|
|
411
|
-
*
|
|
412
|
-
* Anchor selection walks upward from `cwd` looking for a `.git` entry;
|
|
413
|
-
* the first hit anchors to that repo's root (`project`). When the walk
|
|
414
|
-
* exits without finding `.git`, the destination anchors to `home`.
|
|
415
|
-
*
|
|
416
|
-
* @throws RangeError when `sessionId` would resolve to an empty / `..`
|
|
417
|
-
* filename — defensive guard against malicious or buggy callers
|
|
418
|
-
* crossing into a sibling directory via the id.
|
|
419
|
-
*/
|
|
420
|
-
declare function resolveSessionExportTarget(opts: {
|
|
421
|
-
sessionId: string;
|
|
422
|
-
format: SessionExportFormat;
|
|
423
|
-
} & ResolveOptions): SessionExportTarget;
|
|
424
|
-
/**
|
|
425
|
-
* Render a session into a string in the requested format.
|
|
426
|
-
*
|
|
427
|
-
* `markdown` produces a human-readable transcript: a YAML-free header
|
|
428
|
-
* block with the title and a one-line `id · created · turns` summary,
|
|
429
|
-
* a stats section (turns / runs / tokens / cost / status), then a
|
|
430
|
-
* `## Conversation` block where each turn renders as `### N. role ·
|
|
431
|
-
* run_X · ISO-date` with text, thinking, tool calls, and tool results
|
|
432
|
-
* formatted as appropriate fenced blocks. Useful for sharing a session
|
|
433
|
-
* with a teammate or pasting into an issue tracker.
|
|
434
|
-
*
|
|
435
|
-
* `json` returns a 2-space-indented, deterministic dump of the full
|
|
436
|
-
* `SessionData` blob. Useful for re-importing into the store or for
|
|
437
|
-
* post-hoc analysis tooling.
|
|
438
|
-
*/
|
|
439
|
-
declare function renderSession(session: SessionData, format: SessionExportFormat): string;
|
|
440
|
-
/**
|
|
441
|
-
* Render `session` and write the resulting bytes to disk. Returns the
|
|
442
|
-
* resolved target so the caller can show the user where the file
|
|
443
|
-
* landed. The parent directory is created on demand (`recursive: true`)
|
|
444
|
-
* — first-time exports don't need any pre-flight setup.
|
|
445
|
-
*/
|
|
446
|
-
declare function writeSessionExport(opts: {
|
|
447
|
-
session: SessionData;
|
|
448
|
-
format: SessionExportFormat;
|
|
449
|
-
} & ResolveOptions): Promise<SessionExportTarget>;
|
|
450
|
-
//#endregion
|
|
451
896
|
//#region src/chat/settings-context.d.ts
|
|
452
897
|
declare const DEFAULT_SETTINGS: Settings;
|
|
453
898
|
interface SettingsContextValue {
|
|
@@ -688,5 +1133,5 @@ declare function countNeighbors(turnIds: readonly string[], turnId: string): {
|
|
|
688
1133
|
after: number;
|
|
689
1134
|
} | null;
|
|
690
1135
|
//#endregion
|
|
691
|
-
export { type ActiveTrigger, type AgentAccent, type AgentProfile, type AgentRegistry, type ApiKeyCredential, type ApprovalDecision, type ApprovalRequest, type AuthMethod, BUILD_AGENT, BUILTIN_AGENTS, BUILTIN_PROVIDERS, BUILTIN_THEMES, type BooleanSettingKey, CATPPUCCIN_FRAPPE, CATPPUCCIN_LATTE, CATPPUCCIN_MACCHIATO, CATPPUCCIN_MOCHA, type CatalogEntry, type ChatOptions, type ChipColor, type ChipColorMap, type CompletionContext, type CompletionItem, type CompletionProvider, type CompletionReference, type CompletionState, ConfigProvider, type CredentialsFile, DEFAULT_AGENT_ID, DEFAULT_SETTINGS, DEFAULT_THEME, type DiscoveredMcp, type EnabledAllowlistKey, type EnabledToggleSet, FILES_TRIGGER, type FileEntry, type GenerateSessionTitleOptions, IMPLICITLY_SAFE_TOOLS, type ListProjectFilesOptions, type ModelInfo, type OAuthCredential, type OAuthFlowOptions, type Owner, PLAN_AGENT, type Picked, type ProjectEntry, type ProjectsFile, type PromptSegment, type PromptSegmentRef, type ProviderAuth, type ProviderCredential, type ProviderDescriptor, type ProviderKey, type ProviderRegistry, type RequestApproval, type ResolvedConfig, SETTINGS_CHOICES, SETTINGS_TOGGLES, SKILLS_TRIGGER, type SafeModeActions, SafeModeProvider, type Screen, type SessionExportAnchor, type SessionExportFormat, type SessionExportTarget, type SessionMeta, type Settings, type SettingsChoice, SettingsProvider, type SettingsToggle, type StateStoreApi, type StreamBuffer, type StreamEvent, type StreamSource, type SyntaxStyles, type SyntaxTokenStyle, type Theme, type ThemeColors, ThemeProvider, type ThemeSelect, type ThemeSurfaces, type TuiState, VAPORWAVE_THEME, addToSafelist, ageString, anthropicDescriptor, applyApiKeyEnv, applyInsert, buildMcpServers, buildModelCatalog, buildSkillsConfig, cerebrasDescriptor, cleanTitle, collectReferences, countNeighbors, createFilesCompletionProvider, createSkillsCompletionProvider, createStateStore, credKeyOf, credentialsPath, defaultMcpsConfigPaths, defaultSkillScanPaths, deleteTurnSafely, deriveSessionTitle, detectAuth, discoverProjectMcps, discoverProjectSkills, eventsFromTurns, filterModelCatalog, finalizeStreamingMarkdown, finalizeStreamingMarkdownForOwner, findActiveTrigger, fmtTokens, generateSessionTitle, getContextWindow, getModelInfo, getSafelist, indexOfEntry, isOnSafelist, lastContextSizeFromTurns, listProjectFiles, listSessionMeta, loadState, matchesSafelistEntry, mergeReferences, modelSupportsReasoning, modelsForDescriptor, openaiDescriptor, openrouterDescriptor, parseMcpsFile, piIdOf, projectsFilePath, readCredentials, readProjects, readProviderCredential, removeProviderCredential, renderSession, resolveAgentId, resolveChipColor, resolveConfig, resolveSessionExportTarget, resolveTheme, runOAuthLogin, saveState, selectableTurnIds, setProviderCredential, shortId, singleAgentRegistry, splitPromptSegments, stripSpawnTokensLine, suggestSafelistEntry, supportsOAuth, titleFromTurns, toolCallPreview, toolResultText, truncateTurnsAt, turnAsText, turnContextSize, uniqueFilesFromReferences, uniqueSkillNamesFromReferences, useColors, useCompletion, useConfig, useEnabledToggleSet, useSafeModeActions, useSafeModeQueue, useSelectStyle, useSettings, useStreamBuffer, useSurfaces, useSyntaxStyles, useTheme, writeCredentials, writeProjects, writeSessionExport };
|
|
1136
|
+
export { ACTIONS_WITH_CARE_DOCTRINE, ASK_USER_TOOL, type ActiveTrigger, type AgentAccent, type AgentProfile, type AgentRegistry, type AnswerValue, type ApiKeyCredential, type ApprovalDecision, type ApprovalRequest, type AuthMethod, type AutoCompactDecision, type AutoCompactInput, BUILD_AGENT, BUILTIN_AGENTS, BUILTIN_PROVIDERS, BUILTIN_THEMES, type BooleanSettingKey, type BuildSystemOptions, CATPPUCCIN_FRAPPE, CATPPUCCIN_LATTE, CATPPUCCIN_MACCHIATO, CATPPUCCIN_MOCHA, COMMUNICATION_DOCTRINE, type CatalogEntry, type ChatOptions, type ChipColor, type ChipColorMap, type CompletionContext, type CompletionItem, type CompletionProvider, type CompletionReference, type CompletionState, ConfigProvider, type ConfirmQuestion, type CreateInteractionToolsOptions, type CredentialsFile, DEFAULT_AGENT_ID, DEFAULT_KEYBINDINGS, DEFAULT_PERSIST_EXCLUDE_TOOLS, DEFAULT_SETTINGS, DEFAULT_THEME, DOING_TASKS_DOCTRINE, type DiffLine, type DiffOp, type DiscoveredMcp, type DiscoveryError, type DiscoveryResult, type EditHunk, type EditPayload, type EnabledAllowlistKey, type EnabledToggleSet, type EnvSectionOptions, FILES_TRIGGER, type FileEntry, type GenerateSessionTitleOptions, IDENTITY_PREFIX, IMPLICITLY_SAFE_TOOLS, INTERACTION_GUIDANCE, type InlineDiff, type InlineSegment, type InteractionRequest, type InteractionResponse, type InteractionsActions, InteractionsProvider, KEYBINDING_DEFS, KEYBINDING_DEF_BY_ACTION, type KeyAction, type KeyBindingDef, type KeyBindings, type ListProjectFilesOptions, type McpAuthEvent, McpAuthProvider, type McpAuthStateMap, type McpAuthStatus, type ModelInfo, type OAuthCredential, type OAuthFlowOptions, OUTPUT_RESERVE_TOKENS, type Owner, PLAN_AGENT, PLAN_MODE_DOCTRINE, PRESENT_PLAN_TOOL, type ParsedBinding, type PendingInteractionEntry, type Picked, type PlanDecision, type PlanPayload, type PlanRequest, type PlanResponse, type PlanStep, type ProjectEntry, type ProjectUserPath, type ProjectsFile, type PromptSegment, type PromptSegmentRef, type ProviderAuth, type ProviderCredential, type ProviderDescriptor, type ProviderKey, type ProviderRegistry, type Question, type QuestionChoice, type QuestionPayload, type QuestionRequest, type QuestionResponse, type QuestionType, type RequestApproval, type ResolvedConfig, SETTINGS_CHOICES, SETTINGS_TOGGLES, SKILLS_TRIGGER, SUBAGENT_GUIDANCE, type SafeModeActions, SafeModeProvider, type Screen, type SelectQuestion, type SessionExportAnchor, type SessionExportFormat, type SessionExportTarget, type SessionMeta, type Settings, type SettingsChoice, SettingsProvider, type SettingsToggle, type StateStoreApi, type StreamBuffer, type StreamEvent, type StreamSource, type SyntaxStyles, type SyntaxTokenStyle, TOKEN_DISCIPLINE_DOCTRINE, TOOL_DISPLAY, type TextQuestion, type Theme, type ThemeColors, ThemeProvider, type ThemeSelect, type ThemeSurfaces, type ToolCallDisplay, type ToolDisplayMeta, type ToolFormatLine, type TuiState, VAPORWAVE_THEME, accentColor, addToSafelist, ageString, anthropicDescriptor, applyApiKeyEnv, applyInsert, buildBuildSystem, buildMcpServers, buildModelCatalog, buildPlanSystem, buildResumedToolResultsTurn, buildSkillsConfig, buildUnifiedDiff, cerebrasDescriptor, cleanTitle, collectReferences, compactPath, computeInlineDiff, computeLineDiff, countNeighbors, createFileMcpCredentialStore, createFilesCompletionProvider, createInteractionTools, createSkillsCompletionProvider, createStateStore, credKeyOf, credentialsPath, defaultMcpsConfigPaths, defaultSkillScanPaths, deleteTurnSafely, deriveSessionTitle, detectAuth, discoverProjectMcps, discoverProjectSkills, displayNameFor, effectiveContextWindow, ensureKeybindingsFile, envSection, eventsFromTurns, extractEditPayload, filetypeFromPath, filterModelCatalog, finalizeStreamingMarkdown, finalizeStreamingMarkdownForOwner, findActiveTrigger, findGitRoot, fmtTokens, formatToolCall, generateSessionTitle, getContextWindow, getMcpAuthStatus, getModelInfo, getSafelist, indexOfEntry, isEditErrorResult, isInteractionTool, isOnSafelist, isTurnHighlighted, isVisible, keybindingsPath, lastContextSizeFromTurns, listProjectFiles, listSessionMeta, loadState, makeRequestInteraction, marginTopFor, matchesBinding, matchesSafelistEntry, mcpCredentialsPath, mergeKeybindings, mergeReferences, modelSupportsReasoning, modelsForDescriptor, openaiDescriptor, openrouterDescriptor, parseBindingSpec, parseMcpsFile, patchMcpCredential, pendingInteractionsFromTurns, piIdOf, projectUserPaths, projectsFilePath, readCredentials, readKeybindings, readProjects, readProviderCredential, reduceMcpAuth, removeProviderCredential, renderSession, resolveAgentId, resolveChipColor, resolveConfig, resolveSessionExportTarget, resolveTheme, runOAuthLogin, saveState, selectableTurnIds, serializeInteractionResponse, setProviderCredential, shortId, shouldAutoCompact, singleAgentRegistry, splitLines, splitPromptSegments, stripJsonComments, stripSpawnTokensLine, suggestSafelistEntry, supportsOAuth, titleFromTurns, tokenize, toolCallPreview, toolResultText, truncateTurnsAt, tryOpenBrowser, turnAsText, turnContextSize, turnSelectionOwnership, uniqueFilesFromReferences, uniqueSkillNamesFromReferences, useColors, useCompletion, useConfig, useEnabledToggleSet, useInteractionsActions, useInteractionsQueue, useMcpAuthDispatch, useMcpAuthState, useSafeModeActions, useSafeModeQueue, useSelectStyle, useSettings, useStreamBuffer, useSurfaces, useSyntaxStyles, useTheme, writeCredentials, writeProjects, writeSessionExport };
|
|
692
1137
|
//# sourceMappingURL=chat.d.ts.map
|