@lmctl-ai/lmctl 0.2.37 → 0.2.39

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 (199) hide show
  1. package/README.md +16 -0
  2. package/THIRD_PARTY_NOTICES.md +35 -0
  3. package/bin/lmbee +2 -0
  4. package/bin/lmscript +3 -0
  5. package/build-info.json +1 -0
  6. package/dist/cli/index.js +569 -494
  7. package/dist/cli/schema.sql +0 -169
  8. package/dist/cli/script.js +273 -266
  9. package/dist/lmbee.js +960 -0
  10. package/dist/lmscript.js +388 -0
  11. package/dist/public/app.js +379 -0
  12. package/dist/public/index.html +78 -0
  13. package/dist/public/styles.css +160 -0
  14. package/dist/schema.sql +455 -0
  15. package/dist/vendor-webui/index.html +18 -0
  16. package/dist/vendor-webui/local.js +231 -0
  17. package/dist/vendor-webui/styles.css +1852 -0
  18. package/package.json +12 -7
  19. package/dist/cli/batch.d.ts +0 -2
  20. package/dist/cli/busy-evidence.d.ts +0 -27
  21. package/dist/cli/chat-cycle.d.ts +0 -59
  22. package/dist/cli/chat-exec.d.ts +0 -91
  23. package/dist/cli/chat-policy.d.ts +0 -22
  24. package/dist/cli/chat.d.ts +0 -14
  25. package/dist/cli/code-resolver.d.ts +0 -8
  26. package/dist/cli/common.d.ts +0 -57
  27. package/dist/cli/context.d.ts +0 -12
  28. package/dist/cli/cost.d.ts +0 -2
  29. package/dist/cli/export.d.ts +0 -2
  30. package/dist/cli/hello.d.ts +0 -10
  31. package/dist/cli/index.d.ts +0 -3
  32. package/dist/cli/infra.d.ts +0 -78
  33. package/dist/cli/init.d.ts +0 -21
  34. package/dist/cli/intent-input.d.ts +0 -16
  35. package/dist/cli/intent-match.d.ts +0 -30
  36. package/dist/cli/intent-sessions.d.ts +0 -24
  37. package/dist/cli/intent-team.d.ts +0 -25
  38. package/dist/cli/intent.d.ts +0 -22
  39. package/dist/cli/ls.d.ts +0 -2
  40. package/dist/cli/mailbox-cli.d.ts +0 -6
  41. package/dist/cli/managed.d.ts +0 -62
  42. package/dist/cli/mcp-install.d.ts +0 -23
  43. package/dist/cli/mcp.d.ts +0 -2
  44. package/dist/cli/model.d.ts +0 -21
  45. package/dist/cli/paths.d.ts +0 -50
  46. package/dist/cli/plan-wizard.d.ts +0 -42
  47. package/dist/cli/plan.d.ts +0 -20
  48. package/dist/cli/queue-delivery.d.ts +0 -122
  49. package/dist/cli/quickrun.d.ts +0 -14
  50. package/dist/cli/ratelimit.d.ts +0 -2
  51. package/dist/cli/remote-fetch.d.ts +0 -7
  52. package/dist/cli/run-queries.d.ts +0 -82
  53. package/dist/cli/running.d.ts +0 -5
  54. package/dist/cli/save-script.d.ts +0 -41
  55. package/dist/cli/script.d.ts +0 -6
  56. package/dist/cli/seed-flight.d.ts +0 -2
  57. package/dist/cli/self-identity.d.ts +0 -25
  58. package/dist/cli/session-idle.d.ts +0 -118
  59. package/dist/cli/status.d.ts +0 -22
  60. package/dist/cli/tail.d.ts +0 -18
  61. package/dist/cli/target-resolver.d.ts +0 -139
  62. package/dist/cli/team-status.d.ts +0 -91
  63. package/dist/cli/teamfile-compat.d.ts +0 -116
  64. package/dist/cli/teamfile-store.d.ts +0 -18
  65. package/dist/cli/teamfile-template.d.ts +0 -47
  66. package/dist/cli/template-env.d.ts +0 -25
  67. package/dist/cli/terminal-lock.d.ts +0 -25
  68. package/dist/cli/terminal.d.ts +0 -23
  69. package/dist/cli/time-filter.d.ts +0 -10
  70. package/dist/cli/update-notifier.d.ts +0 -11
  71. package/dist/cli/version-util.d.ts +0 -23
  72. package/dist/config/seed_templates.d.ts +0 -1
  73. package/dist/db/backfill-event-log.d.ts +0 -26
  74. package/dist/db/delegation.d.ts +0 -37
  75. package/dist/db/escalation_vocab.d.ts +0 -45
  76. package/dist/db/event-log.d.ts +0 -40
  77. package/dist/db/index.d.ts +0 -1213
  78. package/dist/db/inflight-acquire.d.ts +0 -70
  79. package/dist/db/invocation-event-projections.d.ts +0 -65
  80. package/dist/db/ledger-identity.test.d.ts +0 -1
  81. package/dist/db/live-event-projections.d.ts +0 -92
  82. package/dist/db/migrate.d.ts +0 -51
  83. package/dist/db/open-readonly.d.ts +0 -2
  84. package/dist/db/process-liveness.d.ts +0 -37
  85. package/dist/db/sqlite.d.ts +0 -53
  86. package/dist/db/sqlite.test.d.ts +0 -1
  87. package/dist/db/terminal-lock.d.ts +0 -14
  88. package/dist/db/tracked-invocation-reconcile.d.ts +0 -52
  89. package/dist/db/tracked-invocation.d.ts +0 -116
  90. package/dist/mcp/dispatch.d.ts +0 -45
  91. package/dist/mcp/mediation.d.ts +0 -128
  92. package/dist/mcp/path-warning.d.ts +0 -7
  93. package/dist/mcp/server.d.ts +0 -63
  94. package/dist/mcp/tools.d.ts +0 -24
  95. package/dist/providers/adapter.d.ts +0 -271
  96. package/dist/providers/adapters/agy-adapter.d.ts +0 -18
  97. package/dist/providers/adapters/claude-adapter.d.ts +0 -20
  98. package/dist/providers/adapters/codex-adapter.d.ts +0 -22
  99. package/dist/providers/adapters/copilot-adapter.d.ts +0 -16
  100. package/dist/providers/adapters/dsh-adapter.d.ts +0 -89
  101. package/dist/providers/adapters/gemini-adapter.d.ts +0 -44
  102. package/dist/providers/adapters/hermes-adapter.d.ts +0 -71
  103. package/dist/providers/adapters/index.d.ts +0 -35
  104. package/dist/providers/adapters/kimi-adapter.d.ts +0 -16
  105. package/dist/providers/adapters/lmplayer-adapter.d.ts +0 -14
  106. package/dist/providers/adapters/opencode-adapter.d.ts +0 -11
  107. package/dist/providers/adapters/pi-adapter.d.ts +0 -17
  108. package/dist/providers/adapters/print-turn.d.ts +0 -29
  109. package/dist/providers/adapters/qwen-adapter.d.ts +0 -11
  110. package/dist/providers/agy.d.ts +0 -32
  111. package/dist/providers/base-adapter.d.ts +0 -110
  112. package/dist/providers/base.d.ts +0 -12
  113. package/dist/providers/binary-check.d.ts +0 -102
  114. package/dist/providers/bundle.d.ts +0 -124
  115. package/dist/providers/claude-mock.d.ts +0 -90
  116. package/dist/providers/claude.d.ts +0 -21
  117. package/dist/providers/codex-config.d.ts +0 -15
  118. package/dist/providers/codex.d.ts +0 -25
  119. package/dist/providers/config/init-config.d.ts +0 -43
  120. package/dist/providers/config/model-selection-lint.d.ts +0 -70
  121. package/dist/providers/config/team-config.d.ts +0 -184
  122. package/dist/providers/config/types.d.ts +0 -146
  123. package/dist/providers/config/user-config.d.ts +0 -88
  124. package/dist/providers/copilot.d.ts +0 -21
  125. package/dist/providers/debug.d.ts +0 -128
  126. package/dist/providers/dsh-sidecar.d.ts +0 -65
  127. package/dist/providers/dsh-zstd.d.ts +0 -27
  128. package/dist/providers/dsh.d.ts +0 -37
  129. package/dist/providers/frontmatter.d.ts +0 -46
  130. package/dist/providers/gemini-session-reader.d.ts +0 -151
  131. package/dist/providers/gemini.d.ts +0 -39
  132. package/dist/providers/hermes.d.ts +0 -90
  133. package/dist/providers/index.d.ts +0 -423
  134. package/dist/providers/kimi.d.ts +0 -37
  135. package/dist/providers/model-catalog.d.ts +0 -145
  136. package/dist/providers/model-suggestions.d.ts +0 -4
  137. package/dist/providers/one-shot-timeout.d.ts +0 -1
  138. package/dist/providers/opencode-config.d.ts +0 -62
  139. package/dist/providers/opencode.d.ts +0 -40
  140. package/dist/providers/parsers/acp.d.ts +0 -71
  141. package/dist/providers/parsers/codex-app-server.d.ts +0 -60
  142. package/dist/providers/parsers/stream-json.d.ts +0 -57
  143. package/dist/providers/passive-readers/agy.d.ts +0 -155
  144. package/dist/providers/passive-readers/copilot.d.ts +0 -173
  145. package/dist/providers/passive-readers/dsh.d.ts +0 -34
  146. package/dist/providers/passive-readers/kimi.d.ts +0 -44
  147. package/dist/providers/passive-readers/opencode.d.ts +0 -89
  148. package/dist/providers/passive-readers/qwen.d.ts +0 -151
  149. package/dist/providers/passive-readers/shared.d.ts +0 -138
  150. package/dist/providers/passive-session-reader.d.ts +0 -188
  151. package/dist/providers/path-utils.d.ts +0 -1
  152. package/dist/providers/pi.d.ts +0 -32
  153. package/dist/providers/pricing.d.ts +0 -107
  154. package/dist/providers/qwen.d.ts +0 -22
  155. package/dist/providers/ratelimit/agy.d.ts +0 -22
  156. package/dist/providers/ratelimit/claude-auth.d.ts +0 -13
  157. package/dist/providers/ratelimit/claude.d.ts +0 -6
  158. package/dist/providers/ratelimit/codex.d.ts +0 -7
  159. package/dist/providers/ratelimit/kimi-auth.d.ts +0 -15
  160. package/dist/providers/ratelimit/kimi.d.ts +0 -6
  161. package/dist/providers/ratelimit/schema.d.ts +0 -28
  162. package/dist/providers/ratelimit-readings.d.ts +0 -19
  163. package/dist/providers/registry.d.ts +0 -31
  164. package/dist/providers/resume.d.ts +0 -43
  165. package/dist/providers/seed-instruction.d.ts +0 -3
  166. package/dist/providers/self-session-env.d.ts +0 -21
  167. package/dist/providers/session-limit.d.ts +0 -9
  168. package/dist/providers/strip-ansi.d.ts +0 -5
  169. package/dist/providers/transport-errors.d.ts +0 -94
  170. package/dist/providers/transport-lifecycle.d.ts +0 -63
  171. package/dist/providers/transport-wrappers.d.ts +0 -110
  172. package/dist/providers/transports/acp-profiles/config-option-step.d.ts +0 -24
  173. package/dist/providers/transports/acp-profiles/copilot.d.ts +0 -12
  174. package/dist/providers/transports/acp-profiles/gemini.d.ts +0 -22
  175. package/dist/providers/transports/acp-profiles/hermes.d.ts +0 -27
  176. package/dist/providers/transports/acp-profiles/index.d.ts +0 -19
  177. package/dist/providers/transports/acp-profiles/kimi.d.ts +0 -24
  178. package/dist/providers/transports/acp-profiles/opencode.d.ts +0 -26
  179. package/dist/providers/transports/acp-profiles/types.d.ts +0 -258
  180. package/dist/providers/transports/acp-rpc.d.ts +0 -18
  181. package/dist/providers/transports/acp.d.ts +0 -217
  182. package/dist/providers/transports/codex-app-server.d.ts +0 -190
  183. package/dist/providers/transports/hold-open.d.ts +0 -120
  184. package/dist/providers/transports/manager.d.ts +0 -21
  185. package/dist/providers/transports/stream-json.d.ts +0 -162
  186. package/dist/providers/transports/types.d.ts +0 -56
  187. package/dist/providers/types.d.ts +0 -154
  188. package/dist/providers/yolo-contract.d.ts +0 -131
  189. package/dist/script/adapter.d.ts +0 -104
  190. package/dist/script/batch-script.d.ts +0 -7
  191. package/dist/script/index.d.ts +0 -3
  192. package/dist/script/lmbee-module.d.ts +0 -2
  193. package/dist/script/lmscript.d.ts +0 -616
  194. package/dist/shared/policy.d.ts +0 -74
  195. package/dist/shared-lib/db.d.ts +0 -25
  196. package/dist/shared-lib/passive-session-reader.d.ts +0 -2
  197. package/dist/shared-lib/provider-parse.d.ts +0 -6
  198. package/dist/templates/basedir.d.ts +0 -52
  199. package/dist/uri/lmctl_uri.d.ts +0 -38
@@ -1,90 +0,0 @@
1
- /**
2
- * Hermes Agent ("hermes") session provider.
3
- *
4
- * Hermes persists every conversation in ONE SQLite store,
5
- * `<HERMES_HOME>/state.db` (default `~/.hermes`), whose `sessions` table
6
- * carries a `source` discriminator (`cli` / gateway platforms / `acp`).
7
- * The ACP server (`hermes acp`) writes `source='acp'` rows, and its own
8
- * resume path refuses anything else (`acp_adapter/session.py:341`:
9
- * `row.get("source") != "acp"` ⇒ no restore). This reader mirrors that
10
- * contract exactly: ACP-source rows only.
11
- *
12
- * Shape facts this reader depends on, each verified against a real store
13
- * and against `acp_adapter/session.py`:
14
- *
15
- * 1. An ACP session only becomes a row once it has history
16
- * (`_persist()` returns early on empty history), so a session that
17
- * was created but never prompted does not exist for discovery.
18
- * 2. Assistant rows keep tool calls in a JSON `tool_calls` column
19
- * (`[{id, call_id, function:{name, arguments}}]`) while results land
20
- * on separate `role='tool'` rows keyed by `tool_call_id`. Emitting
21
- * both keeps tool-call/result pairing intact for session inspection.
22
- * 3. A resume replays the `active = 1` set only
23
- * (`get_messages_as_conversation` defaults to `include_inactive=False`),
24
- * so the transcript here does too: compaction archives pre-summary
25
- * turns and a rewind flags taken-back rows `active = 0`, and neither
26
- * belongs in the conversation a resumed member sees.
27
- *
28
- * Schema contract: every column both queries name exists in Hermes's real
29
- * `SCHEMA_SQL` (`hermes_state_common.py`) — asserted against a store a real
30
- * `SessionDB` produced, not a hand-written fixture
31
- * (`tests/providers/hermes-real-schema.test.ts`).
32
- *
33
- * Token accounting: the `sessions` row carries aggregate counters only
34
- * (input/output/cache-read/cache-write/reasoning), which is the same
35
- * "partial" standard as codex/gemini/qwen.
36
- */
37
- import type { SessionProvider, SessionSummary, SessionDetail } from "./types.js";
38
- export interface HermesProviderOptions {
39
- /**
40
- * Explicit effective HERMES_HOME. Defaults to `$HERMES_HOME`, then
41
- * `~/.hermes`. A PROFILE is a different home (`<root>/profiles/<name>`
42
- * — see `hermes_constants.get_default_hermes_root`), so a caller
43
- * selecting a profile passes that profile's home path here; there is no
44
- * separate profile knob and `HERMES_PROFILE` is only the profile's
45
- * display NAME, never a path segment.
46
- */
47
- hermesHome?: string;
48
- /** Read-only connection `PRAGMA busy_timeout` in ms. Default 5000. */
49
- busyTimeoutMs?: number;
50
- /** Max sessions returned by discovery. Default 200. */
51
- discoverLimit?: number;
52
- }
53
- /**
54
- * Resolve HERMES_HOME the way `hermes_constants.get_hermes_home()` does:
55
- * an explicit override, then the `HERMES_HOME` env var, then the platform
56
- * default `~/.hermes`.
57
- */
58
- export declare function resolveHermesHome(opts?: {
59
- hermesHome?: string;
60
- }): string;
61
- /** `<HERMES_HOME>/state.db` — the one store every Hermes session lives in. */
62
- export declare function resolveHermesStateDbPath(opts?: HermesProviderOptions): string;
63
- export declare class HermesProvider implements SessionProvider {
64
- readonly name: "hermes";
65
- private readonly dbPath;
66
- private readonly busyTimeoutMs;
67
- private readonly discoverLimit;
68
- constructor(opts?: HermesProviderOptions);
69
- /** Exposed for diagnostics (`lmctl ls --provider hermes` shows nothing
70
- * when this path does not exist, which is the common first-run state). */
71
- get stateDbPath(): string;
72
- private openDb;
73
- private selectSessionRow;
74
- discoverSessions(): Promise<SessionSummary[]>;
75
- /**
76
- * Read the live (`active = 1`) transcript rows for a session.
77
- *
78
- * Same set a Hermes resume replays: `active = 0` rows are turns a rewind
79
- * took back, and the pre-compaction turns an archive flagged
80
- * `active = 0, compacted = 1` were replaced by the summary in the
81
- * conversation the member sees. A store old enough to predate the column
82
- * has no archived rows either, so the fallback is faithful, not lenient.
83
- */
84
- private activeMessageRows;
85
- /** Read only the preview endpoints, not every transcript body. */
86
- private previewTexts;
87
- loadSession(sessionId: string): Promise<SessionDetail | null>;
88
- resolveSessionPath(sessionId: string): Promise<string | null>;
89
- deleteSession(_sessionId: string): Promise<boolean>;
90
- }
@@ -1,423 +0,0 @@
1
- /**
2
- * Public API surface for the lmctl provider library.
3
- *
4
- * Phase A0.4 introduces this facade so A1's engine switch (gated by
5
- * `LMCTL_USE_LIBRARY_PROVIDER=1`) can `import { chat, seed,
6
- * listSessions, countTokens } from "../providers/index.js"` and rely on
7
- * a stable surface even as the internal file layout under
8
- * `src/providers/` evolves.
9
- *
10
- * The four exported functions are thin wrappers around the existing
11
- * adapter / registry plumbing copied in by A0.1. They do not introduce
12
- * new behavior; if `chat()` rejects, the rejection comes from the
13
- * underlying transport (claude / codex / gemini), not from this layer.
14
- *
15
- * @module providers
16
- */
17
- import type { ProgressEvent, TurnOptions } from "./adapter.js";
18
- import type { ProviderName, SessionSummary, SessionTokenUsage } from "./types.js";
19
- import { ProviderRegistry } from "./registry.js";
20
- import type { BundleSession, BundleSessionOpenOptions } from "./bundle.js";
21
- /**
22
- * Test-only escape hatch: drop the cached default registry. Calls to
23
- * `chat()` / `seed()` / `listSessions()` / `countTokens()` made without
24
- * an explicit `registry:` field will rebuild on next use.
25
- */
26
- export declare function _resetDefaultRegistryForTests(): void;
27
- /**
28
- * Options for a single chat turn against an existing native provider session.
29
- */
30
- export interface ChatOptions {
31
- /** Which provider drives the turn. */
32
- provider: ProviderName;
33
- /** Native session id to resume. */
34
- sessionId: string;
35
- /** Working directory the provider CLI runs in for this turn. */
36
- cwd: string;
37
- /** The user prompt sent on this turn. */
38
- prompt: string;
39
- /** Optional model override; format is provider-specific (e.g. `claude-sonnet-4-6`). */
40
- model?: string;
41
- /** Optional effort / variant override; used by OpenCode ACP. Kimi has no genuine per-turn effort override, so this is unsupported (and warned on) for kimi members. */
42
- effort?: string;
43
- /**
44
- * Idle timeout in ms. Default: 8 hours. `0` disables the timer; when
45
- * the timer fires the turn resolves with `status: "stalled"` rather
46
- * than killing the child — see the underlying `TurnResult` doc.
47
- */
48
- timeoutMs?: number;
49
- /** Abort signal for cancellation (caller rejects immediately on abort). */
50
- signal?: AbortSignal;
51
- /** Streaming delta callback — every text chunk the provider emits. */
52
- onDelta?: (text: string) => void;
53
- /** Classified progress events (tool_use / tool_result / thinking / …). */
54
- onProgress?: (event: ProgressEvent) => void;
55
- /** Environment overrides for the spawned provider process. */
56
- env?: NodeJS.ProcessEnv;
57
- /** Override the spawned provider binary path (troubleshooting dev builds). */
58
- progPath?: string;
59
- /**
60
- * Teamfile alias of the member being spawned.
61
- */
62
- alias?: string;
63
- /** Role-based Lead signal from teamfile resolution. */
64
- isLead?: boolean;
65
- /**
66
- * Defer end-of-turn shutdown while the session still has outstanding
67
- * dispatched work of its own. See `TurnOptions.holdOpen`.
68
- */
69
- holdOpen?: TurnOptions["holdOpen"];
70
- /**
71
- * Permission mode for the turn — `"yolo"` (default) or `"plan"`.
72
- * Plumbed straight through to the adapter's TurnOptions so the
73
- * transport rewrites argv / JSON-RPC params per the table in
74
- * `src/providers/yolo-contract.ts`. Default `"yolo"` preserves
75
- * the historical contract.
76
- */
77
- permissionMode?: import("./yolo-contract.js").PermissionMode;
78
- /**
79
- * Fail closed on resume: when `true`, a provider that cannot load the
80
- * requested `sessionId` MUST error instead of silently creating a NEW
81
- * session. Currently only meaningful for ACP-transport providers
82
- * (opencode/kimi/gemini/copilot) — that's the only transport that reads it
83
- * (see `acp.ts` `session/load` handling); every other provider silently
84
- * IGNORES it (it is a request for stricter behavior a provider MAY not
85
- * support, never an error). Omitted/`false` preserves the historical
86
- * fallback-with-warning behavior. Batch opts in so successive prompts keep
87
- * their conversation; ordinary chat preserves its existing behavior.
88
- * Other callers (e.g. a Hermes ACP adapter) may also opt in explicitly.
89
- *
90
- * Caveat: a member configured with a custom one-shot `agent=` command routes
91
- * through `runOneShotAgent`, which bypasses the ACP transport entirely — the
92
- * flag has no effect there (consistent with "a provider MAY not support it").
93
- */
94
- requireResume?: boolean;
95
- /**
96
- * Caller-held bundle session (batch bundle mode): when set, this
97
- * turn goes through the already-open provider process instead of
98
- * spawning a new one. Spawn-time options (model, effort, env, holdOpen)
99
- * were fixed at open. See src/providers/bundle.ts for the contract.
100
- */
101
- bundleSession?: import("./bundle.js").BundleSession;
102
- /**
103
- * Provider-adapter registry. If omitted, a default built from
104
- * `createAllAdapters()` is reused across calls. Pass an explicit
105
- * registry when you need custom provider home directories
106
- * (testing) or a non-default adapter set.
107
- */
108
- registry?: ProviderRegistry;
109
- }
110
- /**
111
- * Result of a single chat turn.
112
- *
113
- * `text` is the final assistant response (with multi-turn aggregation
114
- * applied for stream-json — see `joinResultTurns`). `status` is `"ok"`
115
- * on normal completion, or `"stalled"` when the idle timer fired (the
116
- * child remains alive; caller decides what to do).
117
- *
118
- * Per-turn token usage is NOT returned here — providers persist it to
119
- * their on-disk session files. Read it with `countTokens()` after.
120
- */
121
- export interface ChatResult {
122
- text: string;
123
- sessionId: string;
124
- durationMs: number;
125
- stopReason?: string;
126
- numTurns?: number;
127
- status?: "ok" | "stalled" | "empty";
128
- stalledAfterMs?: number;
129
- /** Human-readable strings when this turn's provider silently dropped a
130
- * declared model=/effort= (task #232). Omitted when nothing was dropped. */
131
- warnings?: string[];
132
- }
133
- /**
134
- * Run one chat turn against an existing native session.
135
- *
136
- * Delegates to `ProviderAdapter.sendTurn` for the named provider.
137
- *
138
- * @param opts - chat call options; see {@link ChatOptions}
139
- * @param opts.provider - which provider adapter drives the turn
140
- * (for example `"claude"`, `"codex"`, `"gemini"`, or `"agy"`)
141
- * @param opts.sessionId - native session id to resume
142
- * @param opts.cwd - working directory the provider CLI runs in
143
- * @param opts.prompt - user message sent on this turn
144
- * @param opts.model - optional provider-specific model override
145
- * @param opts.timeoutMs - idle timeout in ms (default 8h; 0 disables)
146
- * @param opts.signal - abort signal; on abort the caller rejects with
147
- * `Error("Aborted")` while the child gets a graceful-shutdown ladder
148
- * @param opts.onDelta - streaming text-chunk callback
149
- * @param opts.onProgress - classified ProgressEvent callback
150
- * @param opts.env - environment overrides for the spawned child
151
- * @param opts.progPath - override the spawned binary path (dev builds)
152
- * @param opts.alias - teamfile alias of the spawning member
153
- * (Lead-only flows gate on case-insensitive `"lead"`)
154
- * @param opts.registry - DI for the ProviderRegistry; omit to use the
155
- * lazily-built default
156
- * @returns A {@link ChatResult} with the assembled assistant text plus
157
- * session bookkeeping (durationMs, stopReason, numTurns, status).
158
- * @throws `Error` (plain) when `opts.provider` is not registered in
159
- * the supplied (or default) registry — message matches
160
- * `/not registered/`. {@link TransportConnectionError} if the
161
- * provider binary cannot be spawned (ENOENT).
162
- * {@link TransportProcessError} if it exits non-zero before a final
163
- * result event. {@link TransportJsonError} on malformed wire frames.
164
- * {@link TransportRpcError} on JSON-RPC errors from codex / gemini
165
- * app-server. `Error("Aborted")` (plain) on `opts.signal` abort.
166
- * @example
167
- * ```ts
168
- * import { chat } from "../providers/index.js";
169
- *
170
- * const result = await chat({
171
- * provider: "claude",
172
- * sessionId: "ses-abc",
173
- * cwd: "/repo",
174
- * prompt: "summarize the diff",
175
- * model: "claude-sonnet-4-6",
176
- * onDelta: (chunk) => process.stdout.write(chunk),
177
- * });
178
- * console.log(result.text);
179
- * ```
180
- */
181
- export declare function chat(opts: ChatOptions): Promise<ChatResult>;
182
- /**
183
- * Options for opening a bundle session — one provider process serving many
184
- * prompts (batch bundle mode). The lifecycle contract is in
185
- * `src/providers/bundle.ts`.
186
- */
187
- export interface OpenBundleSessionOptions extends BundleSessionOpenOptions {
188
- /** Which provider drives the bundle. */
189
- provider: ProviderName;
190
- /** Adapter registry override. See {@link ChatOptions.registry}. */
191
- registry?: ProviderRegistry;
192
- }
193
- /**
194
- * Providers whose adapter implements `openSession` — the bundle-SUPPORTED
195
- * set for this version (Landing C1: the ACP providers). Distinct from
196
- * `BUNDLE_CAPABLE_PROVIDERS` in bundle.ts, which is the by-design matrix
197
- * including the transports a follow-up landing will implement.
198
- */
199
- export declare function bundleSupportedProviders(registry?: ProviderRegistry): string[];
200
- /**
201
- * Open a bundle session for `opts.provider`. Throws when the provider's
202
- * adapter has no `openSession` (not bundle-supported in this version).
203
- */
204
- export declare function openBundleSession(opts: OpenBundleSessionOptions): Promise<BundleSession>;
205
- /**
206
- * Options for bootstrapping a new provider session.
207
- */
208
- export interface SeedOptions {
209
- /** Provider whose CLI will be spawned to create the session. */
210
- provider: ProviderName;
211
- /** Working directory where the session-bound subprocess will run. */
212
- cwd: string;
213
- /** Optional initial-turn model override. */
214
- model?: string;
215
- /** Optional initial-turn effort / variant override. */
216
- effort?: string;
217
- /** Optional initial seed prompt; defaults to the standard seed ACK prompt. */
218
- prompt?: string;
219
- /** Adapter registry override. See {@link ChatOptions.registry}. */
220
- registry?: ProviderRegistry;
221
- }
222
- /**
223
- * Result of `seed()`. On success, the on-disk session has been written
224
- * and is discoverable via `listSessions()`. On failure, `error` carries
225
- * the human-readable cause; the caller typically falls back to the
226
- * adapter's `manualSeedHint()`.
227
- *
228
- * A0.5 extension (added during A2.1): `sessionId` carries the native
229
- * session id of the freshly-created session when discovery can match
230
- * a single new entry against the pre-seed snapshot. Callers that need
231
- * the id (the engine's `seedMember` does) read it directly; older
232
- * callers that only checked `success` keep working unchanged.
233
- *
234
- * `sessionId` may be omitted (undefined) when:
235
- * - `success: false`
236
- * - discovery couldn't isolate a single new session (parallel seed
237
- * races; corrupt session file; provider that doesn't persist
238
- * immediately). Callers must defensively fall back to
239
- * `listSessions()` + their own diff logic in that case.
240
- */
241
- export interface SeedResult {
242
- success: boolean;
243
- error?: string;
244
- /** Non-fatal provider diagnostics that callers should surface to the operator. */
245
- warnings?: string[];
246
- /** Native session id of the freshly-created session. See doc above. */
247
- sessionId?: string;
248
- }
249
- /**
250
- * Bootstrap a new native session for the given provider in `cwd`.
251
- *
252
- * Delegates to `ProviderAdapter.seed`. The provider spawns its own
253
- * one-shot seed turn (via the SEED_INITIAL_PROMPT shared across
254
- * adapters) and the session file lands in the provider's home
255
- * directory. `listSessions()` will then find it.
256
- *
257
- * @param opts - seed call options; see {@link SeedOptions}
258
- * @param opts.provider - provider whose CLI is spawned
259
- * (for example `"claude"`, `"codex"`, `"gemini"`, or `"agy"`)
260
- * @param opts.cwd - working directory the session is bound to
261
- * @param opts.model - optional initial-turn model override
262
- * @param opts.registry - DI for the ProviderRegistry; omit to use the
263
- * lazily-built default
264
- * @returns {@link SeedResult} — `{success: true, sessionId?}` on
265
- * success (with the new session id when discovery can isolate one),
266
- * `{success: false, error}` on failure (error is human-readable
267
- * and surfaces the adapter / transport reason).
268
- * @throws `Error` (plain) when `opts.provider` is not registered in
269
- * the supplied (or default) registry — message matches
270
- * `/not registered/`. Otherwise the adapter swallows underlying
271
- * transport / spawn errors into `SeedResult.error` rather than
272
- * rejecting; an unexpected throw indicates a bug at this layer.
273
- * @example
274
- * ```ts
275
- * import { seed } from "../providers/index.js";
276
- *
277
- * const { success, error, sessionId } = await seed({
278
- * provider: "claude",
279
- * cwd: "/repo/teams/backend",
280
- * });
281
- * if (!success) throw new Error(`seed failed: ${error}`);
282
- * await persist(sessionId); // engine writes the new id to teamfile
283
- * ```
284
- */
285
- export declare function seed(opts: SeedOptions): Promise<SeedResult>;
286
- /**
287
- * Options for enumerating on-disk provider sessions.
288
- */
289
- export interface ListSessionsOptions {
290
- /** Restrict to one provider. Omit to list across all registered providers. */
291
- provider?: ProviderName;
292
- /** Filter by canonical workspace path (matches `SessionSummary.cwd`). */
293
- workspace?: string;
294
- /** Cap the result count after sorting by `modifiedAt` descending. */
295
- limit?: number;
296
- /** Only sessions modified at-or-after this date. */
297
- from?: Date;
298
- /** Only sessions modified at-or-before this date. */
299
- to?: Date;
300
- /** Adapter registry override. See {@link ChatOptions.registry}. */
301
- registry?: ProviderRegistry;
302
- }
303
- /**
304
- * Enumerate native provider sessions on disk.
305
- *
306
- * Walks the registered providers' session directories
307
- * (`~/.claude/projects/`, `~/.codex/sessions/`, `~/.gemini/tmp/.../chats/`, ...)
308
- * via the existing `ProviderRegistry.listAll` plumbing.
309
- *
310
- * @param opts - listing options; see {@link ListSessionsOptions}.
311
- * All fields are optional; omit `opts` entirely to list across every
312
- * registered provider with no filtering.
313
- * @param opts.provider - restrict to one provider; omit for all
314
- * @param opts.workspace - filter by canonical workspace path (matched
315
- * against `SessionSummary.cwd` via `canonicalPath`)
316
- * @param opts.limit - cap the result count after newest-first sort
317
- * @param opts.from - lower bound on `modifiedAt` (inclusive)
318
- * @param opts.to - upper bound on `modifiedAt` (inclusive)
319
- * @param opts.registry - DI for the ProviderRegistry; omit to use the
320
- * lazily-built default
321
- * @returns Array of {@link SessionSummary} entries, sorted newest-first.
322
- * @throws Adapter `discover()` calls catch and log most filesystem
323
- * errors internally (a corrupt session JSONL doesn't fail the whole
324
- * listing). Unexpected throws bubble up.
325
- * @example
326
- * ```ts
327
- * import { listSessions } from "../providers/index.js";
328
- *
329
- * const recent = await listSessions({
330
- * provider: "claude",
331
- * workspace: "/repo",
332
- * limit: 5,
333
- * });
334
- * for (const s of recent) console.log(s.sessionId, s.modifiedAt);
335
- * ```
336
- */
337
- export declare function listSessions(opts?: ListSessionsOptions): Promise<SessionSummary[]>;
338
- /** Delete one native session from a known provider. */
339
- export declare function deleteSession(provider: ProviderName, sessionId: string, registry?: ProviderRegistry): Promise<boolean>;
340
- /**
341
- * Options for `countTokens()`.
342
- */
343
- export interface CountTokensOptions {
344
- /** Session id to look up. */
345
- sessionId: string;
346
- /**
347
- * Restrict the lookup to one provider. If omitted, the registry
348
- * probes every provider in registration order and returns the first
349
- * match (same semantics as `lmctl info <sessionid>`).
350
- */
351
- provider?: ProviderName;
352
- /** Adapter registry override. See {@link ChatOptions.registry}. */
353
- registry?: ProviderRegistry;
354
- }
355
- /**
356
- * Aggregate token usage for a single session.
357
- *
358
- * `input`, `output`, etc. mirror `SessionSummary.total*Tokens` —
359
- * cumulative counts across every turn the session has produced. `total`
360
- * is the sum the provider reports (when available); when only the
361
- * per-bucket fields are populated, callers can compute `input +
362
- * cachedInput + cacheWriteInput + output + reasoningOutput`.
363
- */
364
- export interface TokenCount {
365
- /** Provider that owns the session. */
366
- provider: ProviderName;
367
- /** Echoed sessionId for round-trip identification. */
368
- sessionId: string;
369
- /** Cumulative uncached input tokens. */
370
- input: number;
371
- /** Cumulative cache-hit input tokens. */
372
- cachedInput: number;
373
- /** Cumulative cache-write input tokens (claude only today). */
374
- cacheWriteInput: number;
375
- /** Cumulative output tokens. */
376
- output: number;
377
- /** Cumulative reasoning (a.k.a. "thoughts") output tokens. */
378
- reasoningOutput: number;
379
- /**
380
- * Cumulative grand total = sum of the five per-bucket fields above.
381
- * This is NOT the last-turn total — see `lastTurn.totalTokens`.
382
- */
383
- total: number;
384
- /** Raw last-turn usage snapshot when the session file recorded it. */
385
- lastTurn?: SessionTokenUsage;
386
- }
387
- /**
388
- * Aggregate token usage for a single session.
389
- *
390
- * Loads the session via the registered adapter, then extracts the
391
- * `total*Tokens` fields the discovery / load pass already computed.
392
- * Returns zeros for any field the provider did not report — callers
393
- * MUST treat 0 as "not measured" rather than "free." `total` is the
394
- * SUM of the five per-bucket fields; for a last-turn snapshot read
395
- * `lastTurn.totalTokens` instead.
396
- *
397
- * @param opts - lookup options; see {@link CountTokensOptions}
398
- * @param opts.sessionId - native session id (UUID-like)
399
- * @param opts.provider - restrict to one provider; omit to probe every
400
- * registered provider in registration order
401
- * @param opts.registry - DI for the ProviderRegistry; omit to use the
402
- * lazily-built default
403
- * @returns {@link TokenCount} populated from the session's persisted
404
- * token buckets.
405
- * @throws `Error("session <sessionId> not found")` when no registered
406
- * provider can resolve the id (message matches `/not found/`).
407
- * @example
408
- * ```ts
409
- * import { countTokens } from "../providers/index.js";
410
- *
411
- * const usage = await countTokens({ sessionId: "ses-abc" });
412
- * console.log(`${usage.input} in / ${usage.output} out`);
413
- * ```
414
- */
415
- export declare function countTokens(opts: CountTokensOptions): Promise<TokenCount>;
416
- export type { ProviderAdapter } from "./adapter.js";
417
- export type { ProgressEvent, TurnOptions, TurnResult, } from "./adapter.js";
418
- export type { ProviderName, SessionSummary, SessionDetail, SessionTokenUsage, ConversationMessage, MessageRole, } from "./types.js";
419
- export { ProviderRegistry, createAdapterRegistry } from "./registry.js";
420
- export { createAllAdapters } from "./adapters/index.js";
421
- export type { BundleSession, BundleSessionOpenOptions, BundleTurnOptions, BundleTurnResult, } from "./bundle.js";
422
- export { BUNDLE_CAPABLE_PROVIDERS, BUNDLE_NEVER_CAPABLE_PROVIDERS, } from "./bundle.js";
423
- export { TransportError, TransportConnectionError, TransportProcessError, TransportJsonError, TransportRpcError, } from "./transport-errors.js";
@@ -1,37 +0,0 @@
1
- /**
2
- * Kimi Code session provider.
3
- *
4
- * Kimi persists an append-only session index plus one self-contained directory
5
- * per session:
6
- * $KIMI_CODE_HOME/session_index.jsonl
7
- * $KIMI_CODE_HOME/sessions/<workspace>/<session>/state.json
8
- * $KIMI_CODE_HOME/sessions/<workspace>/<session>/agents/main/wire.jsonl
9
- */
10
- import type { SessionDetail, SessionProvider, SessionSummary } from "./types.js";
11
- interface KimiProviderOptions {
12
- kimiHome?: string;
13
- }
14
- export declare class KimiProvider implements SessionProvider {
15
- name: "kimi";
16
- private readonly homeDir;
17
- private readonly sessionsDir;
18
- constructor(opts?: KimiProviderOptions);
19
- discoverSessions(): Promise<SessionSummary[]>;
20
- loadSession(sessionId: string): Promise<SessionDetail | null>;
21
- resolveSessionPath(sessionId: string): Promise<string | null>;
22
- deleteSession(sessionId: string): Promise<boolean>;
23
- getWatchPaths(): {
24
- directory: string;
25
- filePattern: RegExp;
26
- }[];
27
- private indexPath;
28
- private sessionFiles;
29
- private readIndex;
30
- private filesFor;
31
- private validSessionDir;
32
- private findSession;
33
- private readState;
34
- private summary;
35
- private parseWire;
36
- }
37
- export {};