@buildaharness/aielia 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +832 -0
- package/dist/action-approval-service.d.ts +52 -0
- package/dist/action-snapshot.d.ts +173 -0
- package/dist/action-tools.d.ts +38 -0
- package/dist/agent-loop.d.ts +372 -0
- package/dist/answer-claim.d.ts +51 -0
- package/dist/ask-clarification-service.d.ts +70 -0
- package/dist/ask-mode-flag.d.ts +25 -0
- package/dist/ask-response-format.d.ts +8 -0
- package/dist/assistant-session.d.ts +267 -0
- package/dist/assistant-source.d.ts +14 -0
- package/dist/assistant-types.d.ts +158 -0
- package/dist/assistant.d.ts +419 -0
- package/dist/batch-list-detector.d.ts +15 -0
- package/dist/batch-research-fixtures.d.ts +50 -0
- package/dist/benchmark-injected-failure.d.ts +27 -0
- package/dist/claude-cli-llm-client.d.ts +139 -0
- package/dist/claude-cli-prompt.d.ts +86 -0
- package/dist/cli-config.d.ts +27 -0
- package/dist/cli-session-D0uLdT2A.js +7863 -0
- package/dist/cli-session-D0uLdT2A.js.map +1 -0
- package/dist/cli-session.d.ts +63 -0
- package/dist/cli.d.ts +65 -0
- package/dist/cli.js +1693 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +175 -0
- package/dist/contradiction-checker.d.ts +27 -0
- package/dist/debug-log.d.ts +16 -0
- package/dist/decomposition-classifier.d.ts +38 -0
- package/dist/doctor-checks.d.ts +8 -0
- package/dist/email-smtp.d.ts +19 -0
- package/dist/email.d.ts +60 -0
- package/dist/error-classifier.d.ts +13 -0
- package/dist/execution-mode.d.ts +85 -0
- package/dist/fact-extraction.d.ts +143 -0
- package/dist/failure-mode-matcher.d.ts +32 -0
- package/dist/file-tools-mcp-server.mjs +1027 -0
- package/dist/file-tools.d.ts +179 -0
- package/dist/first-run.d.ts +22 -0
- package/dist/harness-bridge.d.ts +103 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.js +212 -0
- package/dist/index.js.map +1 -0
- package/dist/ink-test-render.d.ts +24 -0
- package/dist/lexical/patterns/batch-list-markers.json +8 -0
- package/dist/lexical/patterns/batch-list-markers.json.d.ts +11 -0
- package/dist/lexical/patterns/coding-fact-markers.json +8 -0
- package/dist/lexical/patterns/coding-fact-markers.json.d.ts +11 -0
- package/dist/lexical/patterns/enumeration-markers.json +20 -0
- package/dist/lexical/patterns/enumeration-markers.json.d.ts +23 -0
- package/dist/lexical/patterns/fact-markers.json +16 -0
- package/dist/lexical/patterns/fact-markers.json.d.ts +19 -0
- package/dist/lexical/patterns/injection-patterns.json +20 -0
- package/dist/lexical/patterns/injection-patterns.json.d.ts +23 -0
- package/dist/lexical/patterns/plan-mode-markers.json +10 -0
- package/dist/lexical/patterns/plan-mode-markers.json.d.ts +13 -0
- package/dist/lexical/patterns/risk-patterns.json +122 -0
- package/dist/lexical/patterns/risk-patterns.json.d.ts +125 -0
- package/dist/lexical/patterns/task-cancel-markers.json +22 -0
- package/dist/lexical/patterns/task-cancel-markers.json.d.ts +25 -0
- package/dist/lexical/patterns/template-keywords.json +20 -0
- package/dist/lexical/patterns/template-keywords.json.d.ts +23 -0
- package/dist/lexical/patterns/tool-yield-markers.json +22 -0
- package/dist/lexical/patterns/tool-yield-markers.json.d.ts +25 -0
- package/dist/lexical/patterns.d.ts +64 -0
- package/dist/memory-service.d.ts +219 -0
- package/dist/model-pricing.d.ts +19 -0
- package/dist/network-containment.d.ts +21 -0
- package/dist/node-config-store.d.ts +29 -0
- package/dist/node-display-names.d.ts +26 -0
- package/dist/node-fs-backend.d.ts +8 -0
- package/dist/non-interactive-mode.d.ts +22 -0
- package/dist/one-loop-flag.d.ts +38 -0
- package/dist/plan-approval-service.d.ts +62 -0
- package/dist/plan-builder.d.ts +32 -0
- package/dist/plan-drafting-service.d.ts +87 -0
- package/dist/plan-drafting.d.ts +58 -0
- package/dist/plan-mode-flag.d.ts +34 -0
- package/dist/plan-service.d.ts +61 -0
- package/dist/plan-sketch-service.d.ts +24 -0
- package/dist/plan-sketch.d.ts +20 -0
- package/dist/plan-store.d.ts +232 -0
- package/dist/plan-templates/data/content_creation.json.d.ts +75 -0
- package/dist/plan-templates/data/decision_making.json.d.ts +66 -0
- package/dist/plan-templates/data/problem_solving.json.d.ts +75 -0
- package/dist/plan-templates/data/process_improvement.json.d.ts +57 -0
- package/dist/plan-templates/data/project_planning.json.d.ts +66 -0
- package/dist/plan-templates/data/research_analysis.json.d.ts +66 -0
- package/dist/plan-templates/data/trip_planning.json.d.ts +66 -0
- package/dist/plan-templates/index.d.ts +33 -0
- package/dist/plan-verification.d.ts +31 -0
- package/dist/reminder-tools.d.ts +13 -0
- package/dist/response-service.d.ts +73 -0
- package/dist/review-checker.d.ts +22 -0
- package/dist/risk-classifier.d.ts +7 -0
- package/dist/scripted-llm-client.d.ts +37 -0
- package/dist/semantic-criterion-coverage.d.ts +30 -0
- package/dist/shell-executor.d.ts +14 -0
- package/dist/shell-tools.d.ts +84 -0
- package/dist/spend-cap.d.ts +41 -0
- package/dist/spike.d.ts +1 -0
- package/dist/spike.js +18 -0
- package/dist/spike.js.map +1 -0
- package/dist/supervisor-decider.d.ts +3 -0
- package/dist/system-prompt.d.ts +8 -0
- package/dist/task-mapping.d.ts +42 -0
- package/dist/tool-control-plane.d.ts +67 -0
- package/dist/tool-policy.d.ts +45 -0
- package/dist/tool-step.d.ts +23 -0
- package/dist/tool-yield-classifier.d.ts +7 -0
- package/dist/trace-events.d.ts +126 -0
- package/dist/transcript-compaction.d.ts +13 -0
- package/dist/trust-tagging.d.ts +38 -0
- package/dist/tui-app-DxLPSGh2.js +481 -0
- package/dist/tui-app-DxLPSGh2.js.map +1 -0
- package/dist/tui-app.d.ts +125 -0
- package/dist/tui-input.d.ts +51 -0
- package/dist/tui-mode-flag.d.ts +36 -0
- package/dist/tui-output-capture.d.ts +30 -0
- package/dist/tui-spike.d.ts +1 -0
- package/dist/turn-intent-classifier.d.ts +96 -0
- package/dist/turn-interpreter.d.ts +71 -0
- package/dist/turn-policy.d.ts +45 -0
- package/dist/web-fetch-core.d.ts +65 -0
- package/dist/web-search-provider.d.ts +12 -0
- package/dist/web-tools.d.ts +26 -0
- package/package.json +69 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { ILLMClient, ChatMessage, ChatOptions, ToolDefinition, LLMStructuredResponse } from '@buildaharness/runtime';
|
|
2
|
+
export interface ClaudeCliLLMClientOptions {
|
|
3
|
+
/** Path to the claude binary. Defaults to CLAUDE_PATH env var, then 'claude' on PATH. */
|
|
4
|
+
claudePath?: string;
|
|
5
|
+
/**
|
|
6
|
+
* When set, callChatStructured wires in the file-tools MCP server (read_file/
|
|
7
|
+
* list_directory/write_file, scoped to workspaceRoot) via --mcp-config instead
|
|
8
|
+
* of throwing when tools are supplied. Absent by default — an ordinary chat
|
|
9
|
+
* turn through this backend stays fully tool-free, exactly as before.
|
|
10
|
+
*/
|
|
11
|
+
fileTools?: {
|
|
12
|
+
workspaceRoot: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* When set (and fileTools is also set — the MCP server only starts at all
|
|
16
|
+
* when fileTools is configured), also registers create_reminder/list_reminders
|
|
17
|
+
* on the same MCP server, backed by this file. Must point at the exact file a
|
|
18
|
+
* `FileSystemAdapter` (namespace "reminders") would use for the key
|
|
19
|
+
* "reminders" — see file-tools-mcp-server.mjs's doc comment — so this
|
|
20
|
+
* subprocess and the parent process's own ReminderStore share one reminder
|
|
21
|
+
* list instead of drifting into two disconnected ones. Absent by default —
|
|
22
|
+
* those two tools stay unregistered, same as before this option existed.
|
|
23
|
+
* fetch_url needs no such option: it's registered unconditionally whenever
|
|
24
|
+
* fileTools is set, since it has no shared-state dependency to configure.
|
|
25
|
+
*/
|
|
26
|
+
remindersFile?: string;
|
|
27
|
+
/**
|
|
28
|
+
* When set, also registers run_shell_command on the same MCP server (started
|
|
29
|
+
* whenever fileTools or shellTools is configured) — gated behind an env var
|
|
30
|
+
* the same way reminders are gated behind `remindersFile`. Bash itself is
|
|
31
|
+
* never added to --tools regardless of this setting — see the class doc
|
|
32
|
+
* comment. Kept as a separate option from fileTools so a caller can enable
|
|
33
|
+
* shell without file access or vice versa, even though `workspaceRoot` is
|
|
34
|
+
* typically the same value for both on this backend.
|
|
35
|
+
*/
|
|
36
|
+
shellTools?: {
|
|
37
|
+
workspaceRoot: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* When set, also registers `web_search` on the same MCP server (started
|
|
41
|
+
* whenever fileTools, shellTools, or webTools is configured), backed by the
|
|
42
|
+
* Brave Search API (the only backend — see web-search-provider.ts). Gated
|
|
43
|
+
* behind the `BRAVE_SEARCH_API_KEY` env var passed to the server, the same
|
|
44
|
+
* way shell is gated behind `ENABLE_SHELL_TOOLS`. `fetch_url` is registered
|
|
45
|
+
* independently whenever the server runs at all — this option only adds the
|
|
46
|
+
* search half.
|
|
47
|
+
*/
|
|
48
|
+
webTools?: {
|
|
49
|
+
braveApiKey?: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* When set, also registers send_email on the same MCP server (started whenever any of
|
|
53
|
+
* fileTools/shellTools/webTools/actionTools is configured), gated behind an env var the same
|
|
54
|
+
* way run_shell_command is. The MCP server only ever *stages* the message — the parent process
|
|
55
|
+
* delivers it, after approval, through its own configured SendEmail transport (email.ts /
|
|
56
|
+
* email-smtp.ts). Kept separate from fileTools so email can be enabled without file access.
|
|
57
|
+
*/
|
|
58
|
+
actionTools?: {
|
|
59
|
+
workspaceRoot: string;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Default model passed as `--model` to every `claude -p` call when the per-call
|
|
63
|
+
* `ChatOptions.model` doesn't already set one. The benchmark (Plan A1) uses this to pin every
|
|
64
|
+
* audit run to a stated model instead of silently inheriting the CLI default. `undefined` keeps
|
|
65
|
+
* the pre-A1 behaviour (no `--model` flag → CLI default).
|
|
66
|
+
*/
|
|
67
|
+
model?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* ILLMClient backed by a local `claude -p` subprocess instead of a hosted API key —
|
|
71
|
+
* runs PersonalAssistant against an already-authenticated Claude Code CLI session.
|
|
72
|
+
* Always passes --system-prompt (so the CLI's own default prompt/CLAUDE.md/skills
|
|
73
|
+
* never leak into an ordinary chat turn) and --tools "" (PersonalAssistant only
|
|
74
|
+
* ever calls callChatSync — there's nothing here that expects tool use). **Bash is
|
|
75
|
+
* never added to --tools, under any configuration** — run_shell_command instead goes
|
|
76
|
+
* through the same MCP server as the file tools, which only stages (never executes),
|
|
77
|
+
* exactly like write_file: once a built-in like Bash is active, Claude Code's own
|
|
78
|
+
* agentic loop would execute it autonomously within the single `claude -p` call, with
|
|
79
|
+
* no point at which our code sees the command before it runs.
|
|
80
|
+
*
|
|
81
|
+
* **onUsage's costUsd caveat:** token counts (`inputTokens`/`outputTokens`) are always real —
|
|
82
|
+
* they come straight from `claude --output-format json`'s `usage` field. `costUsd` comes from
|
|
83
|
+
* that same response's `total_cost_usd`, which reflects real API billing when the underlying
|
|
84
|
+
* `claude` session is authenticated with an API key, but may read `0` when it's authenticated
|
|
85
|
+
* against a Pro/Max subscription instead (no per-call dollar cost to report). A caller
|
|
86
|
+
* presenting this to a user (see personal-assistant's /cost) must not read a `0` here as "this
|
|
87
|
+
* turn was free" without that context.
|
|
88
|
+
*/
|
|
89
|
+
export declare class ClaudeCliLLMClient implements ILLMClient {
|
|
90
|
+
private readonly claudePath;
|
|
91
|
+
private readonly fileTools?;
|
|
92
|
+
private readonly remindersFile?;
|
|
93
|
+
private readonly shellTools?;
|
|
94
|
+
private readonly webTools?;
|
|
95
|
+
private readonly actionTools?;
|
|
96
|
+
private readonly model?;
|
|
97
|
+
/**
|
|
98
|
+
* The concrete model id the last `claude -p` call actually reported running against (read from
|
|
99
|
+
* the response's own `model` field, not the CLI alias). `undefined` until a call resolves one.
|
|
100
|
+
* Plan A1 records this into the benchmark report so a published table can name the model.
|
|
101
|
+
*/
|
|
102
|
+
resolvedModelId?: string;
|
|
103
|
+
constructor(options?: ClaudeCliLLMClientOptions);
|
|
104
|
+
callChat(messages: ChatMessage[], options?: ChatOptions): AsyncIterable<string>;
|
|
105
|
+
callChatSync(messages: ChatMessage[], options?: ChatOptions): Promise<string>;
|
|
106
|
+
/**
|
|
107
|
+
* When `tools` is non-empty and `fileTools`/`shellTools` was configured, wires the
|
|
108
|
+
* file-tools MCP server into a single `claude -p` call and lets Claude Code's own
|
|
109
|
+
* agentic loop call read_file/list_directory/write_file/fetch_url/create_reminder/
|
|
110
|
+
* list_reminders/run_shell_command autonomously — we don't get to intercept each
|
|
111
|
+
* call the way the proxy backend's manual tool loop does (see
|
|
112
|
+
* plans/personal_assistant_file_tools_plan.html, T6). fetch_url is always
|
|
113
|
+
* registered on that server; create_reminder/list_reminders only when
|
|
114
|
+
* `remindersFile` is set; run_shell_command only when `shellTools` is set;
|
|
115
|
+
* web_search only when `webTools` is set (Brave Search — see the `webTools`
|
|
116
|
+
* option). Three
|
|
117
|
+
* possible outcomes: a final text reply (no tool call this backend needs to
|
|
118
|
+
* surface), a write or shell command staged by the MCP server mid-call (surfaced
|
|
119
|
+
* as a synthetic `__staged_action` tool call so assistant.ts's tool loop treats it
|
|
120
|
+
* the same as a manually staged action without staging it a second time), or —
|
|
121
|
+
* for fetch_url/create_reminder/list_reminders — the tool's result text folded
|
|
122
|
+
* directly into Claude Code's own reply, since (unlike the proxy backend's
|
|
123
|
+
* `executeToolCall`) there's no outer loop here to intercept each call and
|
|
124
|
+
* re-apply trust-tagging itself; the MCP server tags fetch_url's result before
|
|
125
|
+
* Claude Code ever sees it instead (see file-tools-mcp-server.mjs).
|
|
126
|
+
*/
|
|
127
|
+
callChatStructured(messages: ChatMessage[], tools?: ToolDefinition[], options?: ChatOptions): Promise<LLMStructuredResponse>;
|
|
128
|
+
/** Diffs .pending-actions/ against the call's start time to detect a write or shell command the MCP server staged during this subprocess call. */
|
|
129
|
+
/**
|
|
130
|
+
* When the MCP server staged more than one action this call (e.g. "run X AND write Y" —
|
|
131
|
+
* see file-tools-mcp-server.mjs's stagePendingAction doc comment), every one of them lands
|
|
132
|
+
* in `.pending-actions/` with an mtime after `startTimeMs`, in `readdir`-arbitrary order —
|
|
133
|
+
* not necessarily staging order. Must return the *chain head* (earliest `stagedAt`)
|
|
134
|
+
* specifically, since resolvePendingAction (assistant.ts) walks `nextPendingActionId`
|
|
135
|
+
* forward from whichever record it's handed; returning a later link here would surface the
|
|
136
|
+
* chain out of order and orphan the earlier, still-unresolved action.
|
|
137
|
+
*/
|
|
138
|
+
private findPendingActionStagedSince;
|
|
139
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { ChatMessage, TokenUsage } from '@buildaharness/runtime';
|
|
2
|
+
import { PendingActionRecord } from './file-tools.js';
|
|
3
|
+
/**
|
|
4
|
+
* Synthetic tool name a claude-cli-backed ILLMClient uses to signal "an action was already
|
|
5
|
+
* staged by the file-tools MCP server during this call" — distinct from `write_file`/
|
|
6
|
+
* `run_shell_command` so assistant.ts's tool loop adopts the already-staged id instead of
|
|
7
|
+
* staging a second, redundant pending action. Shared across every backend that wires that
|
|
8
|
+
* MCP server into a `claude -p` call (claude-cli-llm-client.ts today; a Tauri desktop
|
|
9
|
+
* bridge tomorrow) so assistant.ts's `call.name === '__staged_action'` check has exactly
|
|
10
|
+
* one producer to stay in sync with.
|
|
11
|
+
*/
|
|
12
|
+
export declare const ALREADY_STAGED_ACTION_TOOL = "__staged_action";
|
|
13
|
+
/**
|
|
14
|
+
* Reduces a staged record down to the synthetic __staged_action tool call's input shape. Shared
|
|
15
|
+
* for the same reason ALREADY_STAGED_ACTION_TOOL above is. `kind: 'revert'` is never passed here
|
|
16
|
+
* — a revert is only ever staged directly (assistant.ts's stageUndoAction, driven by
|
|
17
|
+
* /undo-action), never proposed by the model through the claude-cli MCP server's staging path.
|
|
18
|
+
*/
|
|
19
|
+
export declare function stagedActionInput(record: PendingActionRecord): {
|
|
20
|
+
id: string;
|
|
21
|
+
kind: 'write' | 'shell' | 'email';
|
|
22
|
+
} & Record<string, unknown>;
|
|
23
|
+
/**
|
|
24
|
+
* Converts a ChatMessage[] transcript into the `--system-prompt`/trailing-prompt-argument
|
|
25
|
+
* pair a `claude -p` invocation expects. Pure and environment-agnostic (no node:child_process
|
|
26
|
+
* import) so it can be shared by every backend that shells out to the Claude CLI — today
|
|
27
|
+
* that's claude-cli-llm-client.ts (spawns `claude` directly via node:child_process, used by
|
|
28
|
+
* the CLI front end) and chat-ui's TauriClaudeCliLLMClient (invokes a Tauri Rust command that
|
|
29
|
+
* spawns `claude`, used by the desktop front end) — without the two drifting apart.
|
|
30
|
+
*
|
|
31
|
+
* Every call to `claude -p` is a fresh, stateless subprocess (`--no-session-persistence`) —
|
|
32
|
+
* there is no real prior turn from the underlying API's point of view, only whatever text we
|
|
33
|
+
* hand it in this one prompt argument. When there's more than one prior turn to carry, the
|
|
34
|
+
* history is explicitly framed as a labeled, delimited block ("verbatim conversation so far
|
|
35
|
+
* ... never doubt, deny, or second-guess it") clearly separated from the current message,
|
|
36
|
+
* rather than just interleaved as bare lines — found via live testing (conv150/conv166's
|
|
37
|
+
* re-probe) that a flat, unframed interleaving occasionally led the model to treat its own
|
|
38
|
+
* prior "Assistant:" line as fabricated/untrustworthy and explicitly disclaim it to the user,
|
|
39
|
+
* on perfectly ordinary turns, not just the synthetic decline-notice line that first surfaced
|
|
40
|
+
* this. A single-message call (the common case — most turns have no history yet) is left
|
|
41
|
+
* exactly as before: the bare content, no framing overhead.
|
|
42
|
+
*/
|
|
43
|
+
export declare function buildClaudePrompt(messages: ChatMessage[]): {
|
|
44
|
+
systemPrompt: string;
|
|
45
|
+
prompt: string;
|
|
46
|
+
};
|
|
47
|
+
export interface ParsedClaudeCliOutput {
|
|
48
|
+
reply: string;
|
|
49
|
+
/** Real usage/cost from Claude's own accounting — absent when stdout wasn't valid JSON (e.g. a plain-text error). See ClaudeCliLLMClient's doc comment for the Pro/Max-subscription caveat on costUsd. */
|
|
50
|
+
usage?: TokenUsage;
|
|
51
|
+
/** The concrete model id the CLI reported running against (`model` field of the result event), not the `--model` alias. Absent when the CLI didn't report one. */
|
|
52
|
+
model?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Parses `claude --output-format json`'s stdout into the reply text plus usage, falling back
|
|
56
|
+
* to just the raw stdout as the reply if it isn't valid JSON (e.g. the CLI printed a
|
|
57
|
+
* plain-text error before reaching --output-format handling). Shared for the same reason
|
|
58
|
+
* buildClaudePrompt above is.
|
|
59
|
+
*/
|
|
60
|
+
/**
|
|
61
|
+
* The claude-cli backend has no schema-constrained "structured output" mode of its own —
|
|
62
|
+
* callChatStructured's schema is only ever a system-prompt instruction ("Respond with JSON
|
|
63
|
+
* only, no prose") the model can, and routinely does, still wrap in a markdown code fence
|
|
64
|
+
* (```json ... ```). Every caller (classifyTurnIntent, checkForContradictions,
|
|
65
|
+
* reframeTaskDescriptionWithLLM, buildPlanFromTemplate, review-checker.ts, trust-tagging.ts,
|
|
66
|
+
* failure-mode-matcher.ts) does a
|
|
67
|
+
* bare `JSON.parse(response.content)` and falls back to its own "nothing structured" default on
|
|
68
|
+
* any parse failure — a fenced reply silently looked exactly like the model declining to
|
|
69
|
+
* decompose/flag/reframe anything, rather than a parsing bug. Only strips a fence that wraps the
|
|
70
|
+
* *entire* trimmed reply (leading and trailing) — never touches an ordinary conversational reply
|
|
71
|
+
* that legitimately contains a code block, since this is only ever applied to the
|
|
72
|
+
* structured-output path, not plain callChat/callChatSync results.
|
|
73
|
+
*/
|
|
74
|
+
export declare function stripJsonCodeFence(content: string): string;
|
|
75
|
+
/**
|
|
76
|
+
* The `claude` CLI (2.1.x) reports no top-level `model` on a `--output-format json`/`stream-json`
|
|
77
|
+
* result — only a `modelUsage` map, and it routinely has **two** entries: the model that actually
|
|
78
|
+
* ran the turn (per `--model`) plus a small internal Haiku call the CLI makes for its own
|
|
79
|
+
* bookkeeping. `Object.keys(modelUsage)[0]` was picking that auxiliary Haiku, which is why every
|
|
80
|
+
* audit report on disk says `claude-haiku-4-5-20251001` even though `--model=sonnet` was honoured.
|
|
81
|
+
*
|
|
82
|
+
* The primary turn always carries the full prompt + cached context, so it has by far the most
|
|
83
|
+
* input tokens — pick the entry with the largest `input + cacheRead + cacheCreation`.
|
|
84
|
+
*/
|
|
85
|
+
export declare function primaryModelFromUsage(modelUsage: Record<string, unknown> | undefined): string | undefined;
|
|
86
|
+
export declare function parseClaudeCliOutput(stdout: string): ParsedClaudeCliOutput;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AssistantConfig, CONFIG_KEYS } from './config.js';
|
|
2
|
+
/**
|
|
3
|
+
* Pure logic backing cli.ts's /config command family — split out so it's unit-testable in
|
|
4
|
+
* isolation, the same way error-classifier.ts and node-display-names.ts are split out of
|
|
5
|
+
* cli.ts for the same reason. cli.ts itself stays thin glue (readline dispatch, ConfigStore
|
|
6
|
+
* I/O, rebuilding the assistant) on top of these functions.
|
|
7
|
+
*/
|
|
8
|
+
export { CONFIG_KEYS };
|
|
9
|
+
/** Never printed in full by formatConfigValue — /config shows these masked regardless of value. */
|
|
10
|
+
export declare const SECRET_CONFIG_KEYS: ReadonlySet<keyof AssistantConfig>;
|
|
11
|
+
/** Which env var, if any, can pin a given key — shown next to a value in /config's listing when that var is set. */
|
|
12
|
+
export declare const ENV_VAR_FOR_CONFIG_KEY: Partial<Record<keyof AssistantConfig, string>>;
|
|
13
|
+
export declare function isConfigKey(key: string): key is keyof AssistantConfig;
|
|
14
|
+
/**
|
|
15
|
+
* Builds the `overrides` argument for resolveConfig() from process.env — only includes a key
|
|
16
|
+
* when its env var is actually set, so an absent env var can never shadow a persisted config
|
|
17
|
+
* value with a falsy default. Mirrors the exact env vars/parsing cli.ts read individually
|
|
18
|
+
* before this module existed (ASSISTANT_ENABLE_WEB/ASSISTANT_ENABLE_SHELL must be exactly "1").
|
|
19
|
+
*/
|
|
20
|
+
export declare function envOverridesFromProcessEnv(env: NodeJS.ProcessEnv): Partial<AssistantConfig>;
|
|
21
|
+
/** Thrown by parseConfigValue on a value that doesn't fit the target key's type — cli.ts reports .message and leaves the config unchanged. */
|
|
22
|
+
export declare class ConfigValueParseError extends Error {
|
|
23
|
+
}
|
|
24
|
+
/** Parses a raw `/config set <key> <value>` string into the type AssistantConfig[key] expects. */
|
|
25
|
+
export declare function parseConfigValue(key: keyof AssistantConfig, raw: string): unknown;
|
|
26
|
+
/** Renders /config's full listing as a single multi-line string — cli.ts just console.logs the result. */
|
|
27
|
+
export declare function formatConfigListing(config: AssistantConfig, overriddenKeys: ReadonlySet<keyof AssistantConfig>): string;
|