@lmctl-ai/lmctl 0.2.38 → 0.2.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/README.md +16 -0
  2. package/bin/lmbee +2 -0
  3. package/bin/lmscript +3 -0
  4. package/build-info.json +1 -0
  5. package/dist/cli/index.js +485 -460
  6. package/dist/cli/schema.sql +0 -169
  7. package/dist/cli/script.js +246 -246
  8. package/dist/lmbee.js +960 -0
  9. package/dist/lmscript.js +388 -0
  10. package/dist/public/app.js +379 -0
  11. package/dist/public/index.html +78 -0
  12. package/dist/public/styles.css +160 -0
  13. package/dist/schema.sql +455 -0
  14. package/dist/vendor-webui/index.html +18 -0
  15. package/dist/vendor-webui/local.js +231 -0
  16. package/dist/vendor-webui/styles.css +1852 -0
  17. package/package.json +11 -7
  18. package/dist/cli/batch.d.ts +0 -2
  19. package/dist/cli/busy-evidence.d.ts +0 -27
  20. package/dist/cli/chat-cycle.d.ts +0 -59
  21. package/dist/cli/chat-exec.d.ts +0 -91
  22. package/dist/cli/chat-policy.d.ts +0 -22
  23. package/dist/cli/chat.d.ts +0 -14
  24. package/dist/cli/code-resolver.d.ts +0 -8
  25. package/dist/cli/common.d.ts +0 -57
  26. package/dist/cli/context.d.ts +0 -12
  27. package/dist/cli/cost.d.ts +0 -2
  28. package/dist/cli/export.d.ts +0 -2
  29. package/dist/cli/hello.d.ts +0 -10
  30. package/dist/cli/index.d.ts +0 -3
  31. package/dist/cli/infra.d.ts +0 -78
  32. package/dist/cli/init.d.ts +0 -8
  33. package/dist/cli/intent-input.d.ts +0 -16
  34. package/dist/cli/intent-match.d.ts +0 -30
  35. package/dist/cli/intent-sessions.d.ts +0 -24
  36. package/dist/cli/intent-team.d.ts +0 -25
  37. package/dist/cli/intent.d.ts +0 -22
  38. package/dist/cli/ls.d.ts +0 -2
  39. package/dist/cli/mailbox-cli.d.ts +0 -6
  40. package/dist/cli/managed.d.ts +0 -62
  41. package/dist/cli/mcp-install.d.ts +0 -23
  42. package/dist/cli/mcp.d.ts +0 -2
  43. package/dist/cli/model.d.ts +0 -21
  44. package/dist/cli/paths.d.ts +0 -50
  45. package/dist/cli/plan-wizard.d.ts +0 -42
  46. package/dist/cli/plan.d.ts +0 -20
  47. package/dist/cli/queue-delivery.d.ts +0 -122
  48. package/dist/cli/quickrun.d.ts +0 -14
  49. package/dist/cli/ratelimit.d.ts +0 -2
  50. package/dist/cli/remote-fetch.d.ts +0 -7
  51. package/dist/cli/run-queries.d.ts +0 -82
  52. package/dist/cli/running.d.ts +0 -5
  53. package/dist/cli/save-script.d.ts +0 -41
  54. package/dist/cli/script.d.ts +0 -6
  55. package/dist/cli/seed-flight.d.ts +0 -2
  56. package/dist/cli/self-identity.d.ts +0 -25
  57. package/dist/cli/session-idle.d.ts +0 -118
  58. package/dist/cli/status.d.ts +0 -22
  59. package/dist/cli/tail.d.ts +0 -18
  60. package/dist/cli/target-resolver.d.ts +0 -139
  61. package/dist/cli/team-status.d.ts +0 -91
  62. package/dist/cli/teamfile-compat.d.ts +0 -116
  63. package/dist/cli/teamfile-store.d.ts +0 -18
  64. package/dist/cli/teamfile-template.d.ts +0 -47
  65. package/dist/cli/template-env.d.ts +0 -25
  66. package/dist/cli/terminal-lock.d.ts +0 -25
  67. package/dist/cli/terminal.d.ts +0 -23
  68. package/dist/cli/time-filter.d.ts +0 -10
  69. package/dist/cli/update-notifier.d.ts +0 -11
  70. package/dist/cli/version-util.d.ts +0 -23
  71. package/dist/config/seed_templates.d.ts +0 -1
  72. package/dist/db/backfill-event-log.d.ts +0 -26
  73. package/dist/db/delegation.d.ts +0 -37
  74. package/dist/db/escalation_vocab.d.ts +0 -45
  75. package/dist/db/event-log.d.ts +0 -40
  76. package/dist/db/index.d.ts +0 -1213
  77. package/dist/db/inflight-acquire.d.ts +0 -70
  78. package/dist/db/invocation-event-projections.d.ts +0 -65
  79. package/dist/db/ledger-identity.test.d.ts +0 -1
  80. package/dist/db/live-event-projections.d.ts +0 -92
  81. package/dist/db/migrate.d.ts +0 -51
  82. package/dist/db/open-readonly.d.ts +0 -2
  83. package/dist/db/process-liveness.d.ts +0 -37
  84. package/dist/db/sqlite.d.ts +0 -53
  85. package/dist/db/sqlite.test.d.ts +0 -1
  86. package/dist/db/terminal-lock.d.ts +0 -14
  87. package/dist/db/tracked-invocation-reconcile.d.ts +0 -52
  88. package/dist/db/tracked-invocation.d.ts +0 -116
  89. package/dist/mcp/dispatch.d.ts +0 -45
  90. package/dist/mcp/mediation.d.ts +0 -128
  91. package/dist/mcp/path-warning.d.ts +0 -7
  92. package/dist/mcp/server.d.ts +0 -63
  93. package/dist/mcp/tools.d.ts +0 -24
  94. package/dist/providers/adapter.d.ts +0 -271
  95. package/dist/providers/adapters/agy-adapter.d.ts +0 -18
  96. package/dist/providers/adapters/claude-adapter.d.ts +0 -20
  97. package/dist/providers/adapters/codex-adapter.d.ts +0 -22
  98. package/dist/providers/adapters/copilot-adapter.d.ts +0 -16
  99. package/dist/providers/adapters/dsh-adapter.d.ts +0 -89
  100. package/dist/providers/adapters/gemini-adapter.d.ts +0 -44
  101. package/dist/providers/adapters/hermes-adapter.d.ts +0 -71
  102. package/dist/providers/adapters/index.d.ts +0 -35
  103. package/dist/providers/adapters/kimi-adapter.d.ts +0 -16
  104. package/dist/providers/adapters/lmplayer-adapter.d.ts +0 -14
  105. package/dist/providers/adapters/opencode-adapter.d.ts +0 -11
  106. package/dist/providers/adapters/pi-adapter.d.ts +0 -17
  107. package/dist/providers/adapters/print-turn.d.ts +0 -29
  108. package/dist/providers/adapters/qwen-adapter.d.ts +0 -11
  109. package/dist/providers/agy.d.ts +0 -32
  110. package/dist/providers/base-adapter.d.ts +0 -110
  111. package/dist/providers/base.d.ts +0 -12
  112. package/dist/providers/binary-check.d.ts +0 -102
  113. package/dist/providers/bundle.d.ts +0 -124
  114. package/dist/providers/claude-mock.d.ts +0 -90
  115. package/dist/providers/claude.d.ts +0 -21
  116. package/dist/providers/codex-config.d.ts +0 -15
  117. package/dist/providers/codex.d.ts +0 -25
  118. package/dist/providers/config/init-config.d.ts +0 -59
  119. package/dist/providers/config/init-edit.d.ts +0 -3
  120. package/dist/providers/config/init-file.d.ts +0 -20
  121. package/dist/providers/config/init-write.d.ts +0 -2
  122. package/dist/providers/config/model-selection-lint.d.ts +0 -70
  123. package/dist/providers/config/team-config.d.ts +0 -184
  124. package/dist/providers/config/types.d.ts +0 -146
  125. package/dist/providers/config/user-config.d.ts +0 -88
  126. package/dist/providers/copilot.d.ts +0 -21
  127. package/dist/providers/debug.d.ts +0 -128
  128. package/dist/providers/dsh-sidecar.d.ts +0 -65
  129. package/dist/providers/dsh-zstd.d.ts +0 -27
  130. package/dist/providers/dsh.d.ts +0 -37
  131. package/dist/providers/frontmatter.d.ts +0 -46
  132. package/dist/providers/gemini-session-reader.d.ts +0 -151
  133. package/dist/providers/gemini.d.ts +0 -39
  134. package/dist/providers/hermes.d.ts +0 -90
  135. package/dist/providers/index.d.ts +0 -423
  136. package/dist/providers/kimi.d.ts +0 -37
  137. package/dist/providers/model-catalog.d.ts +0 -145
  138. package/dist/providers/model-suggestions.d.ts +0 -4
  139. package/dist/providers/one-shot-timeout.d.ts +0 -1
  140. package/dist/providers/opencode-config.d.ts +0 -62
  141. package/dist/providers/opencode.d.ts +0 -40
  142. package/dist/providers/parsers/acp.d.ts +0 -71
  143. package/dist/providers/parsers/codex-app-server.d.ts +0 -60
  144. package/dist/providers/parsers/stream-json.d.ts +0 -57
  145. package/dist/providers/passive-readers/agy.d.ts +0 -155
  146. package/dist/providers/passive-readers/copilot.d.ts +0 -173
  147. package/dist/providers/passive-readers/dsh.d.ts +0 -34
  148. package/dist/providers/passive-readers/kimi.d.ts +0 -44
  149. package/dist/providers/passive-readers/opencode.d.ts +0 -89
  150. package/dist/providers/passive-readers/qwen.d.ts +0 -151
  151. package/dist/providers/passive-readers/shared.d.ts +0 -138
  152. package/dist/providers/passive-session-reader.d.ts +0 -188
  153. package/dist/providers/path-utils.d.ts +0 -1
  154. package/dist/providers/pi.d.ts +0 -32
  155. package/dist/providers/pricing.d.ts +0 -107
  156. package/dist/providers/qwen.d.ts +0 -22
  157. package/dist/providers/ratelimit/agy.d.ts +0 -22
  158. package/dist/providers/ratelimit/claude-auth.d.ts +0 -13
  159. package/dist/providers/ratelimit/claude.d.ts +0 -6
  160. package/dist/providers/ratelimit/codex.d.ts +0 -7
  161. package/dist/providers/ratelimit/kimi-auth.d.ts +0 -15
  162. package/dist/providers/ratelimit/kimi.d.ts +0 -6
  163. package/dist/providers/ratelimit/schema.d.ts +0 -28
  164. package/dist/providers/ratelimit-readings.d.ts +0 -19
  165. package/dist/providers/registry.d.ts +0 -31
  166. package/dist/providers/resume.d.ts +0 -43
  167. package/dist/providers/seed-instruction.d.ts +0 -3
  168. package/dist/providers/self-session-env.d.ts +0 -21
  169. package/dist/providers/session-limit.d.ts +0 -9
  170. package/dist/providers/strip-ansi.d.ts +0 -5
  171. package/dist/providers/transport-errors.d.ts +0 -94
  172. package/dist/providers/transport-lifecycle.d.ts +0 -63
  173. package/dist/providers/transport-wrappers.d.ts +0 -110
  174. package/dist/providers/transports/acp-profiles/config-option-step.d.ts +0 -24
  175. package/dist/providers/transports/acp-profiles/copilot.d.ts +0 -12
  176. package/dist/providers/transports/acp-profiles/gemini.d.ts +0 -22
  177. package/dist/providers/transports/acp-profiles/hermes.d.ts +0 -27
  178. package/dist/providers/transports/acp-profiles/index.d.ts +0 -19
  179. package/dist/providers/transports/acp-profiles/kimi.d.ts +0 -24
  180. package/dist/providers/transports/acp-profiles/opencode.d.ts +0 -26
  181. package/dist/providers/transports/acp-profiles/types.d.ts +0 -258
  182. package/dist/providers/transports/acp-rpc.d.ts +0 -18
  183. package/dist/providers/transports/acp.d.ts +0 -217
  184. package/dist/providers/transports/codex-app-server.d.ts +0 -190
  185. package/dist/providers/transports/hold-open.d.ts +0 -120
  186. package/dist/providers/transports/manager.d.ts +0 -21
  187. package/dist/providers/transports/stream-json.d.ts +0 -162
  188. package/dist/providers/transports/types.d.ts +0 -56
  189. package/dist/providers/types.d.ts +0 -154
  190. package/dist/providers/yolo-contract.d.ts +0 -131
  191. package/dist/script/adapter.d.ts +0 -107
  192. package/dist/script/batch-script.d.ts +0 -7
  193. package/dist/script/index.d.ts +0 -3
  194. package/dist/script/init-environment.d.ts +0 -8
  195. package/dist/script/lmbee-module.d.ts +0 -2
  196. package/dist/script/lmscript.d.ts +0 -647
  197. package/dist/shared/policy.d.ts +0 -74
  198. package/dist/shared-lib/db.d.ts +0 -25
  199. package/dist/shared-lib/passive-session-reader.d.ts +0 -2
  200. package/dist/shared-lib/provider-parse.d.ts +0 -6
  201. package/dist/templates/basedir.d.ts +0 -52
  202. package/dist/uri/lmctl_uri.d.ts +0 -38
@@ -1,188 +0,0 @@
1
- import type { CopilotSessionUsage } from "./passive-readers/copilot.js";
2
- export interface Source {
3
- provider: string;
4
- sessionid: string;
5
- source_id: string;
6
- }
7
- export interface ReadLimits {
8
- signal: AbortSignal;
9
- maxBytes: number;
10
- maxRows: number;
11
- }
12
- export type SourceState = {
13
- status: "ready";
14
- revision: string;
15
- } | {
16
- status: "partial" | "unsupported" | "unavailable";
17
- };
18
- /** A non-file external-I/O contributor for a response (phase 3 / bx2). File
19
- * reads/writes stay in files_read/files_written and are NEVER duplicated here.
20
- * An `unattributed` entry is a coverage marker (bytes=null, basis="unknown")
21
- * that forces its whole direction's aggregate to NULL. */
22
- export interface ExternalIoEntry {
23
- direction: "read" | "write";
24
- kind: "prompt" | "web" | "other" | "unattributed";
25
- /** Native admission/call id for dedup; never a content body. */
26
- id: string | null;
27
- /** Bounded metadata ref (web URL sans credentials/query/fragment); null for
28
- * prompt/unattributed; never a raw command/query/prompt body. */
29
- ref: string | null;
30
- bytes: number | null;
31
- basis: "input_text" | "normalized_content" | "certified_counter" | "unknown";
32
- }
33
- /** Closed whitelist of native pricing/fidelity facts for an eventual lmprice
34
- * join (note 387). Counts only — no rates, service tier/speed, credentials, or
35
- * account info. `reasoning_output_tokens` is a subset of `tokens.output`; the
36
- * cache-write TTL counts cannot exceed `tokens.input_cache_write`. */
37
- export interface PricingFacts {
38
- cache_write_5m_tokens?: number | null;
39
- cache_write_1h_tokens?: number | null;
40
- reasoning_output_tokens?: number | null;
41
- web_search_requests?: number | null;
42
- web_fetch_requests?: number | null;
43
- }
44
- export interface NativeResponseMetadata {
45
- response_id: string;
46
- timestamp: string | null;
47
- model: string | null;
48
- tokens: {
49
- input_uncached: number | null;
50
- input_cached: number | null;
51
- input_cache_write: number | null;
52
- output: number | null;
53
- };
54
- files_read: Array<{
55
- path: string;
56
- bytes: number | null;
57
- }> | null;
58
- files_written: Array<{
59
- path: string;
60
- bytes: number | null;
61
- }> | null;
62
- read_bytes?: number | null;
63
- write_bytes?: number | null;
64
- external_io?: ExternalIoEntry[] | null;
65
- model_provider?: string | null;
66
- pricing_facts?: PricingFacts | null;
67
- }
68
- export interface Discovery {
69
- sources: Source[];
70
- complete: boolean;
71
- cursor: string | null;
72
- }
73
- export type Snapshot = {
74
- status: "complete";
75
- source: Source;
76
- revision: string;
77
- checkpoint: string | null;
78
- responses: NativeResponseMetadata[];
79
- /** Native session-scoped usage snapshots (currently: copilot's
80
- * `session.shutdown` records) — surfaced BESIDE responses, never
81
- * distributed into them, never a synthetic response. `undefined`/absent
82
- * for providers with no such native concept; `null` for a provider that
83
- * has the concept but this session has none yet (e.g. still live);
84
- * present-and-non-empty only when real native snapshots exist. Every
85
- * relevant native snapshot is retained (never "last wins") since a
86
- * provider's own scope semantics may not cover the whole session. */
87
- session_usage?: CopilotSessionUsage[] | null;
88
- /** Explicit, additive coverage marker: `responses` above are real,
89
- * identified, fully-valid rows — never fabricated or clamped-to-zero —
90
- * but a KNOWN native-format gap means some other, uncapturable activity
91
- * in this same source could not be attributed to a response (e.g. a
92
- * Codex source mixing legacy `event_msg`/`token_count` telemetry
93
- * alongside modern `token_usage_record`s: the old-format usage is
94
- * conservatively treated as an unresolved gap whenever it co-occurs with
95
- * captured rows — matching raw token counts is NOT proof of native
96
- * identity, since distinct requests can share identical small integer
97
- * counts, so a numeric match never clears this marker). Absent ⇒ legacy
98
- * full-coverage semantics (nothing else exists to omit) —
99
- * NEVER default a missing marker to "partial" or vice versa. A caller
100
- * MUST reject any value other than "partial" here rather than guess a
101
- * new meaning for an unrecognized marker. This is a coverage flag only:
102
- * it never changes the validity of `responses`, and a caller retains
103
- * and journals those rows while simply never advancing its incremental
104
- * revision/retention watermark past a snapshot carrying this flag. */
105
- capture_status?: "partial";
106
- } | {
107
- status: "partial" | "unsupported" | "unavailable";
108
- };
109
- /**
110
- * Effective discovery-coverage certification (lmbi backfill-reader-contract.md).
111
- * This is an explicit certification of what this reader instance actually
112
- * covers, NOT a list inferred from rows already returned — a caller must be
113
- * able to tell "no adapter for this provider" apart from "adapter exists, its
114
- * store is genuinely empty."
115
- */
116
- export interface PassiveSessionReaderCapabilities {
117
- /** All configured native account roots, no team/task/session filter. */
118
- scope: "account";
119
- /** Changes when extraction semantics OR effective declared root
120
- * configuration change, so a caller knows to start a safe new traversal
121
- * rather than trust a stale cursor/cache against new coverage. */
122
- revision: string;
123
- /** Providers this instance can discover/inspect/read at all (certified,
124
- * even where token metering itself is only partial — see `metering`). */
125
- providers: string[];
126
- /** Per-provider metering completeness. Informational only — never an
127
- * admission gate; an unlisted provider makes no metering claim either way. */
128
- metering: Record<string, "per_response" | "partial" | "unavailable" | "session_only">;
129
- }
130
- export interface PassiveSessionReader {
131
- discover(limits: ReadLimits & {
132
- maxSources: number;
133
- after?: string;
134
- }): Promise<Discovery>;
135
- inspect(source: Source, limits: ReadLimits): Promise<SourceState>;
136
- read(source: Source, revision: string, limits: ReadLimits): Promise<Snapshot>;
137
- capabilities(): PassiveSessionReaderCapabilities;
138
- }
139
- export interface PassiveSessionReaderOptions {
140
- claudeProjectsDir?: string;
141
- codexSessionDirs?: string[];
142
- lmplayerDbPaths?: string[];
143
- /** Overrides agy's default `$HOME/.gemini/antigravity-cli/conversations`. */
144
- agyConversationsDir?: string;
145
- /** Overrides dsh's default `~/.dsh/sessions` (or `$DSH_HOME/sessions`). */
146
- dshHome?: string;
147
- /** Overrides qwen's default live+backup project roots. */
148
- qwenProjectsDirs?: string[];
149
- /** Overrides opencode's default store paths (does NOT read `OPENCODE_DB`). */
150
- opencodeDbPaths?: string[];
151
- /** Overrides copilot's default `$HOME/.copilot/session-state`. */
152
- copilotSessionStateDir?: string;
153
- /** Overrides kimi's default `$KIMI_CODE_HOME`/`~/.kimi-code`. */
154
- kimiHome?: string;
155
- sqliteBusyTimeoutMs?: number;
156
- /** Directory-traversal visit budget for discovery (see
157
- * MAX_DISCOVERY_TRAVERSAL_VISITS). Overridable mainly so tests can exercise
158
- * the truncation path without a pathological tree. */
159
- maxDiscoveryTraversalVisits?: number;
160
- }
161
- export declare class NativePassiveSessionReader implements PassiveSessionReader {
162
- private readonly claudeProjectsDir;
163
- private readonly codexSessionDirs;
164
- private readonly lmplayerDbPaths;
165
- private readonly sqliteBusyTimeoutMs;
166
- private readonly maxDiscoveryTraversalVisits;
167
- private readonly agyReader;
168
- private readonly dshReader;
169
- private readonly qwenReader;
170
- private readonly opencodeReader;
171
- private readonly copilotReader;
172
- private readonly kimiReader;
173
- constructor(options?: PassiveSessionReaderOptions);
174
- capabilities(): PassiveSessionReaderCapabilities;
175
- discover(limits: ReadLimits & {
176
- maxSources: number;
177
- after?: string;
178
- }): Promise<Discovery>;
179
- inspect(source: Source, limits: ReadLimits): Promise<SourceState>;
180
- read(source: Source, revision: string, limits: ReadLimits): Promise<Snapshot>;
181
- private discoverProvider;
182
- private jsonlSourceMatches;
183
- private openLmplayer;
184
- private discoverLmplayer;
185
- private inspectLmplayer;
186
- private readLmplayer;
187
- }
188
- export declare function createPassiveSessionReader(options?: PassiveSessionReaderOptions): PassiveSessionReader;
@@ -1 +0,0 @@
1
- export declare function canonicalPath(path: string): string;
@@ -1,32 +0,0 @@
1
- /**
2
- * pi coding agent session provider.
3
- *
4
- * pi stores sessions as JSONL files under
5
- * ~/.pi/agent/sessions/--<encoded-cwd>--/<timestamp>_<session-id>.jsonl
6
- * where <encoded-cwd> is the cwd with the leading separator stripped and
7
- * "/", "\\", ":" replaced by "-". The first line is a session header
8
- * ({"type":"session","id":...,"cwd":...}); subsequent lines are tree-linked
9
- * entries (message / model_change / compaction / ...). File format:
10
- * packages/coding-agent/docs/session-format.md in the pi repo.
11
- */
12
- import type { SessionDetail, SessionProvider, SessionSummary } from "./types.js";
13
- interface PiProviderOptions {
14
- piDir?: string;
15
- }
16
- export declare class PiProvider implements SessionProvider {
17
- name: "pi";
18
- private baseDir;
19
- constructor(opts?: PiProviderOptions);
20
- getWatchPaths(): {
21
- directory: string;
22
- filePattern: RegExp;
23
- }[];
24
- discoverSessions(): Promise<SessionSummary[]>;
25
- private listSessionFiles;
26
- private readHeader;
27
- private extractSummary;
28
- loadSession(sessionId: string): Promise<SessionDetail | null>;
29
- resolveSessionPath(sessionId: string): Promise<string | null>;
30
- deleteSession(sessionId: string): Promise<boolean>;
31
- }
32
- export {};
@@ -1,107 +0,0 @@
1
- import type { AliasTable } from "./model-catalog.js";
2
- export declare const PRICE_DATA_URL = "https://lmctl.com/dataset/model_list.json";
3
- export declare const PRICE_ALIASES_URL = "https://lmctl.com/dataset/aliases.json";
4
- export type PriceDataSource = "network" | "cache" | "bundled" | "pinned" | "unavailable";
5
- export interface PriceRecord {
6
- source: string;
7
- source_model_id: string;
8
- provider?: string | null;
9
- mode?: string | null;
10
- record_id?: string | null;
11
- gateway_id?: string | null;
12
- context_window?: {
13
- input_tokens?: number | null;
14
- } | null;
15
- pricing: {
16
- input_per_1m_tokens: number | null;
17
- output_per_1m_tokens: number | null;
18
- input_cache_read_per_1m_tokens: number | null;
19
- };
20
- }
21
- export interface PriceCatalog {
22
- schema_version: number;
23
- generated_at: string;
24
- records: PriceRecord[];
25
- }
26
- export interface PriceDataResult {
27
- catalog: PriceCatalog | null;
28
- source: PriceDataSource;
29
- generatedAt: string | null;
30
- }
31
- export interface CatalogSnapshot {
32
- catalog: PriceCatalog | null;
33
- aliases: AliasTable | null;
34
- source: PriceDataSource;
35
- generatedAt: string | null;
36
- }
37
- export declare function isValidCatalog(payload: unknown): payload is PriceCatalog;
38
- export declare function isValidAliases(payload: unknown): payload is AliasTable;
39
- export interface LoadCatalogOptions {
40
- fetchImpl?: typeof fetch;
41
- cacheDir?: string;
42
- /** Override for the bundled model_list path; `null` disables that fallback. */
43
- bundledPath?: string | null;
44
- /** Override for the bundled aliases path; `null` disables that fallback. */
45
- bundledAliasesPath?: string | null;
46
- /** Override for LMCTL_PRICE_DATA; `null` forces unpinned. */
47
- pinDir?: string | null;
48
- /** Test seam for the TTL gate (defaults to Date.now()). */
49
- now?: number;
50
- /** Test seam overriding LMCTL_PRICE_TTL (ms). */
51
- ttlMs?: number;
52
- }
53
- /** Dataset generated_at of the most recently loaded snapshot, for --debug surfaces. */
54
- export declare function datasetGeneratedAt(): string | null;
55
- /** Test seam: drop the memoized no-argument snapshot (process-level memo). */
56
- export declare function _resetCatalogSnapshotMemoForTests(): void;
57
- /**
58
- * The one snapshot loader for the lmprice integration. Never throws. One
59
- * snapshot load per process invocation: the no-argument call (the normal
60
- * command path) is memoized module-wide, so lint/seed/cost members never
61
- * trigger per-member re-downloads; calls with explicit options (tests,
62
- * seams) always execute.
63
- */
64
- export declare function loadCatalogSnapshot(opts?: LoadCatalogOptions): Promise<CatalogSnapshot>;
65
- /**
66
- * The one function `lmctl cost`'s Phase 1 callers use. Never throws, never
67
- * blocks longer than `VERSION_CHECK_TIMEOUT_MS` for the "is there anything
68
- * new" check regardless of network state (per resource, outside the TTL) --
69
- * a HEAD request specifically so a slow/large BODY download can never blow
70
- * that budget. Thin wrapper over loadCatalogSnapshot: the model-list half
71
- * of the snapshot with the same result shape as before the two-resource
72
- * extension.
73
- */
74
- export declare function loadPriceData(opts?: LoadCatalogOptions): Promise<PriceDataResult>;
75
- /**
76
- * Records are source-specific and NOT reconciled across sources (lmprice's
77
- * own documented behavior) -- the same model can appear many times (bare id,
78
- * `vendor/id`, `region/vendor/id`, ...) with the litellm and openrouter
79
- * sources potentially disagreeing. `records` is already sorted by
80
- * (source, provider, source_model_id) -- "litellm" sorts before "openrouter"
81
- * -- so preferring the first exact-bare-id match, then the first
82
- * suffix (`/<modelId>`) match, is a deterministic, if arbitrary, tie-break
83
- * rather than an average/reconciliation across disagreeing sources.
84
- *
85
- * Superseded for provider-aware resolution by model-catalog.ts's
86
- * resolveModel(); kept for `lmctl cost` Phase 1 compatibility.
87
- */
88
- export declare function findModelPrice(catalog: PriceCatalog, modelId: string): PriceRecord["pricing"] | null;
89
- /**
90
- * Phase 1 cost model (approved design): the session's existing AGGREGATE
91
- * token totals x one model's rate -- not a true per-model breakdown (see
92
- * `runCost`'s `approximate` flag for when a session touched more than one
93
- * model; that's a separate, later sub-task). `cachedInput` is priced at the
94
- * cache-READ rate only -- lmprice's `input_cache_write_per_1m_tokens` isn't
95
- * consumed here because lctl-src's own token accounting
96
- * (`totalCachedInputTokens`) has never distinguished cache-write from
97
- * cache-read tokens; conflating them into the (usually cheaper) read rate
98
- * would UNDERSTATE cost for a cache-write-heavy session, but overstating via
99
- * the (usually pricier) write rate for every cache hit is worse on average.
100
- * Returns `null` when any needed price is missing -- never a partial/guessed
101
- * number.
102
- */
103
- export declare function computeCostUsd(tokens: {
104
- input: number;
105
- output: number;
106
- cachedInput: number;
107
- }, pricing: PriceRecord["pricing"] | null): number | null;
@@ -1,22 +0,0 @@
1
- /**
2
- * Qwen Code session provider.
3
- *
4
- * Qwen Code is a Claude Code fork — same JSONL session format in ~/.qwen/.
5
- * This provider reuses the Claude provider logic with Qwen-specific paths.
6
- */
7
- import type { SessionProvider, SessionSummary, SessionDetail } from "./types.js";
8
- interface QwenProviderOptions {
9
- qwenDir?: string;
10
- }
11
- export declare class QwenProvider implements SessionProvider {
12
- name: "qwen";
13
- private baseDir;
14
- constructor(opts?: QwenProviderOptions);
15
- discoverSessions(): Promise<SessionSummary[]>;
16
- private extractSummary;
17
- loadSession(sessionId: string): Promise<SessionDetail | null>;
18
- private loadFromFile;
19
- resolveSessionPath(sessionId: string): Promise<string | null>;
20
- deleteSession(sessionId: string): Promise<boolean>;
21
- }
22
- export {};
@@ -1,22 +0,0 @@
1
- import { type QuotaDiagnostics } from './schema.js';
2
- type CommandResult = {
3
- status: number | null;
4
- stdout?: string;
5
- error?: NodeJS.ErrnoException;
6
- };
7
- type CommandRunner = (timeoutMs: number, env: NodeJS.ProcessEnv) => CommandResult;
8
- type HttpResult = {
9
- status: number;
10
- body: string;
11
- };
12
- type HttpRunner = (url: string, headers: Record<string, string>, timeoutMs: number) => Promise<HttpResult>;
13
- /** Test seam; production callers should use readAgy. */
14
- export declare function _setAgyDepsForTests(deps: {
15
- command?: CommandRunner;
16
- http?: HttpRunner;
17
- } | null): void;
18
- export declare function readAgy(options: {
19
- timeoutSeconds: number;
20
- env: NodeJS.ProcessEnv;
21
- } & QuotaDiagnostics): Promise<Record<string, unknown>>;
22
- export {};
@@ -1,13 +0,0 @@
1
- export declare const CLAUDE_EXPIRY_BUFFER_MS = 300000;
2
- type OAuth = Record<string, unknown>;
3
- export interface ClaudeCredentials {
4
- oauth?: OAuth;
5
- path?: string;
6
- error?: string;
7
- }
8
- export declare function claudeCredentialPath(env: NodeJS.ProcessEnv): string;
9
- export declare function loadClaudeCredentials(env: NodeJS.ProcessEnv): ClaudeCredentials;
10
- export declare function claudeTokenExpiresSoon(oauth: OAuth): boolean;
11
- /** Refresh only file-owned OAuth credentials. Never print tokens or response bodies. */
12
- export declare function refreshClaudeCredentials(loaded: ClaudeCredentials, signal: AbortSignal): Promise<OAuth>;
13
- export {};
@@ -1,6 +0,0 @@
1
- import { type QuotaDiagnostics } from './schema.js';
2
- export interface ClaudeReadOptions extends QuotaDiagnostics {
3
- timeoutSeconds: number;
4
- env: NodeJS.ProcessEnv;
5
- }
6
- export declare function readClaude({ timeoutSeconds, env, debug, onRawResponse }: ClaudeReadOptions): Promise<Record<string, unknown>>;
@@ -1,7 +0,0 @@
1
- import { type QuotaDiagnostics } from './schema.js';
2
- type JsonObject = Record<string, unknown>;
3
- export declare function readCodex(options: {
4
- timeoutSeconds: number;
5
- env: NodeJS.ProcessEnv;
6
- } & QuotaDiagnostics): Promise<JsonObject>;
7
- export {};
@@ -1,15 +0,0 @@
1
- type Token = Record<string, unknown> & {
2
- access_token: string;
3
- };
4
- export interface KimiAccount {
5
- home: string;
6
- path: string;
7
- lockTarget: string;
8
- baseUrl: string;
9
- oauthHost: string;
10
- token: Token;
11
- }
12
- export declare function loadKimiAccount(env: NodeJS.ProcessEnv): KimiAccount;
13
- export declare function kimiTokenExpiresSoon(token: Token): boolean;
14
- export declare function refreshKimiAccount(account: KimiAccount, signal: AbortSignal): Promise<Token>;
15
- export {};
@@ -1,6 +0,0 @@
1
- import { type QuotaDiagnostics } from './schema.js';
2
- export interface KimiReadOptions extends QuotaDiagnostics {
3
- timeoutSeconds: number;
4
- env: NodeJS.ProcessEnv;
5
- }
6
- export declare function readKimi({ timeoutSeconds, env, debug, onRawResponse }: KimiReadOptions): Promise<Record<string, unknown>>;
@@ -1,28 +0,0 @@
1
- /** Wire format shared by the in-process subscription quota readers. */
2
- export declare const SCHEMA_URL = "https://lmctl.com/schemas/lmratelimit-v1.json";
3
- export declare function clampFraction(value: unknown): number | null;
4
- export declare function toFraction(value: unknown, scale: 'fraction' | 'percent'): number | null;
5
- export declare function isoFromEpoch(value: unknown): string | null;
6
- export declare function epochFromIso(value: unknown): number | null;
7
- export declare function windowTypeFromMinutes(value: unknown): string;
8
- export declare function windowTypeFromLabel(value: unknown): string;
9
- export declare function windowSuffix(type: string): string;
10
- export declare function redact(value: unknown, secrets?: Iterable<string | null | undefined>): string;
11
- export declare function makeBucket(fields: Record<string, unknown>): Record<string, unknown>;
12
- export declare function makeReading(provider: string, status: string, fields?: Record<string, unknown>): Record<string, unknown>;
13
- export declare function errorReading(provider: string, status: string, reason: string, detail?: unknown, source?: string, secrets?: Iterable<string | null | undefined>, retryAfterSeconds?: number | null): Record<string, unknown>;
14
- export declare function parseRetryAfter(headers: Headers): number | null;
15
- /** Quota responses only; never use for credentials or OAuth refresh bodies. */
16
- export type RawQuotaDebug = (message: string) => void;
17
- export interface RawQuotaResponse {
18
- source: string;
19
- http_status?: number;
20
- text: string;
21
- }
22
- export interface QuotaDiagnostics {
23
- debug?: RawQuotaDebug;
24
- onRawResponse?: (response: RawQuotaResponse) => void;
25
- }
26
- export declare function captureQuota(options: QuotaDiagnostics, source: string, text: string, secrets?: Iterable<unknown>, httpStatus?: number): void;
27
- /** Preserve a provider's own error explanation instead of replacing it with a generic status. */
28
- export declare function withQuotaError(reading: Record<string, unknown>, raw: string, secrets?: Iterable<string | null | undefined>): Record<string, unknown>;
@@ -1,19 +0,0 @@
1
- export declare const VALID_RATELIMIT_TARGETS: readonly ["all", "codex", "agy", "claude", "kimi"];
2
- export interface RatelimitReadingsOptions {
3
- providers?: string[];
4
- targets?: string[];
5
- timeoutSeconds?: number;
6
- env?: NodeJS.ProcessEnv;
7
- progress?: (message: string) => void;
8
- debug?: (message: string) => void;
9
- includeRaw?: boolean;
10
- }
11
- export type RatelimitReadingsResult = {
12
- status: 'ok';
13
- readings: Record<string, unknown>[];
14
- } | {
15
- status: 'error';
16
- error: string;
17
- readings: [];
18
- };
19
- export declare function queryRatelimitReadings(options?: RatelimitReadingsOptions): Promise<RatelimitReadingsResult>;
@@ -1,31 +0,0 @@
1
- import type { SessionProvider, SessionSummary, SessionDetail, ProviderName, WatchTarget } from "./types.js";
2
- import type { ProviderAdapter } from "./adapter.js";
3
- export type { ProviderAdapter };
4
- export declare class ProviderRegistry {
5
- private providers;
6
- private adapters;
7
- register(provider: SessionProvider): void;
8
- listAll(filter?: {
9
- provider?: ProviderName;
10
- workspace?: string;
11
- limit?: number;
12
- from?: Date;
13
- to?: Date;
14
- }): Promise<SessionSummary[]>;
15
- getSession(sessionId: string, provider?: ProviderName): Promise<SessionDetail | null>;
16
- resolveSession(sessionId: string, provider?: ProviderName): Promise<{
17
- provider: SessionProvider;
18
- filePath: string;
19
- } | null>;
20
- resolveSessions(sessionId: string, provider?: ProviderName): Promise<Array<{
21
- provider: SessionProvider;
22
- filePath: string;
23
- }>>;
24
- getWatchTargets(): WatchTarget[];
25
- deleteSession(sessionId: string, provider?: ProviderName): Promise<boolean>;
26
- registerAdapter(adapter: ProviderAdapter): void;
27
- getAdapter(name: ProviderName): ProviderAdapter | undefined;
28
- getAllAdapters(): ProviderAdapter[];
29
- }
30
- export declare function createRegistry(...providers: SessionProvider[]): ProviderRegistry;
31
- export declare function createAdapterRegistry(adapters: ProviderAdapter[]): ProviderRegistry;
@@ -1,43 +0,0 @@
1
- import type { ProviderName, SessionDetail } from './types.js';
2
- export interface ResumeModelIgnored {
3
- provider: string;
4
- model: string;
5
- reason: string;
6
- }
7
- /**
8
- * Defensive sessionid format guard for the step-in spawn (design §2.4 /
9
- * §10.B B3). Provider-minted ids are UUID-/slug-class; anything else is
10
- * refused before any spawn (no shell, no injection surface).
11
- */
12
- export declare const SESSIONID_RE: RegExp;
13
- export declare function isResumableProvider(p: string): p is ProviderName;
14
- /** Test-only: drop the cached registry between cases. */
15
- export declare function _resetResumeRegistryForTests(): void;
16
- /**
17
- * The native resume incantation as an argv array (argv[0] is the PROVIDER
18
- * binary — never lmctl). Returns null if `provider` has no registered
19
- * adapter / resumable template. Tokenizes the native `resumeTemplate`
20
- * (no quoted args in any template) and appends the YOLO suffix.
21
- */
22
- export declare function resumeIncantationArgv(provider: string, sessionId: string, opts?: {
23
- isLead?: boolean;
24
- model?: string;
25
- onModelIgnored?: (ignored: ResumeModelIgnored) => void;
26
- }): string[] | null;
27
- /** Display form of {@link resumeIncantationArgv} (seed-print + >200K UX). */
28
- export declare function resumeIncantationString(provider: string, sessionId: string, opts?: {
29
- model?: string;
30
- }): string | null;
31
- /**
32
- * Provider-agnostic session read (no provider round-trip, no `tokens`):
33
- * the native per-provider session reader the registry already owns.
34
- */
35
- export declare function loadSessionDetail(sessionId: string, provider: ProviderName): Promise<SessionDetail | null>;
36
- /**
37
- * P2 — bare-sessionid auto-detect: ask the registry which provider(s)
38
- * a sessionid resolves to. Returns matching provider names (0/1/N).
39
- * Callers map 0 ⇒ not-found, 1 ⇒ use that provider, N ⇒ ambiguous (ask
40
- * the user to pass `--provider`). Thin wrapper over the existing
41
- * `registry().resolveSessions` — no new coupling.
42
- */
43
- export declare function findSessionProviders(sessionId: string): Promise<ProviderName[]>;
@@ -1,3 +0,0 @@
1
- export declare const SEED_ACK = "ACK: waiting for explicit lmctl task.";
2
- export declare const SEED_INITIAL_PROMPT: string;
3
- export declare const MANUAL_SEED_POST_LAUNCH_NOTE = "send this exact lmctl seed instruction: \"lmctl seed initial connection only. Create or pin this provider session, then stop. Do not inspect files, run commands, infer a task, delegate, or edit. Reply exactly: ACK: waiting for explicit lmctl task.\"";
@@ -1,21 +0,0 @@
1
- export declare const LMCTL_SELF_SESSIONID = "LMCTL_SELF_SESSIONID";
2
- export declare const LMCTL_LAUNCH_SOURCE = "LMCTL_LAUNCH_SOURCE";
3
- export type LmctlLaunchSource = 'chat' | 'terminal' | 'unknown';
4
- /**
5
- * A shell/profile can export `CLAUDE_CODE_EXECPATH` pointing at a binary
6
- * for the WRONG platform (a real incident: a WSL environment inherited a
7
- * Windows `claude.exe` from a cross-platform npm install). The `claude`
8
- * CLI itself trusts this override unconditionally and re-execs into it,
9
- * so a bad value there breaks every claude-provider spawn with a generic
10
- * "native binary not installed" error that reads as a global install
11
- * problem rather than one bad env var. lmctl can't fix the CLI's own
12
- * re-exec logic, but it fully controls the env it hands the child, so it
13
- * strips an override that's clearly wrong for the current platform
14
- * (non-Windows + `.exe`, or a path that doesn't exist) before spawning —
15
- * the child then falls back to its own default binary discovery instead
16
- * of blindly trusting a broken pointer.
17
- */
18
- export declare function sanitizeClaudeExecPathEnv(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
19
- export declare function withProviderCwdEnv(env: NodeJS.ProcessEnv | undefined, cwd: string): NodeJS.ProcessEnv;
20
- export declare function withSelfSessionEnv(env: NodeJS.ProcessEnv | undefined, sessionId: string | undefined): NodeJS.ProcessEnv | undefined;
21
- export declare function withProviderSpawnEnv(env: NodeJS.ProcessEnv | undefined, cwd: string, sessionId: string | undefined, launchSource?: LmctlLaunchSource): NodeJS.ProcessEnv;
@@ -1,9 +0,0 @@
1
- import type { ConversationMessage } from './types.js';
2
- export interface SessionLimitState {
3
- state: 'LIMITED';
4
- resets_at: string | null;
5
- reset_time: string;
6
- timezone: string | null;
7
- detected_at: string;
8
- }
9
- export declare function detectSessionLimit(messages: ConversationMessage[]): SessionLimitState | null;
@@ -1,5 +0,0 @@
1
- /** Strips ANSI/VT100 escape sequences (color codes, etc.) so provider error
2
- * text captured from a child process's stderr reads as plain text instead
3
- * of literal escape-code noise wherever it's surfaced (a captured log, a
4
- * terminal that doesn't render them, JSON output). */
5
- export declare function stripAnsiCodes(text: string): string;