@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,145 +0,0 @@
1
- /**
2
- * lmprice <-> lmctl integration (approved design v2, section 1) -- the pure
3
- * model-catalog layer: provider adapters + catalog resolution over an
4
- * ALREADY-LOADED dataset snapshot (loading/refresh stays in pricing.ts).
5
- *
6
- * Identity vs billing route (design review correction #2): the same
7
- * normalized model id can have divergent priced offers across sources
8
- * (DeepSeek direct vs gateway rows differ ~2x; `:batch` variants share slugs
9
- * but price differently). Rows are therefore grouped by adapter-normalized
10
- * identity into ONE CatalogModel whose `offers` keep every source-qualified
11
- * row; route preference (first-party > litellm > openrouter > manual) picks
12
- * the winning row, never a reconciled average.
13
- *
14
- * Resolution order in resolveModel() (design section 1, exact):
15
- * 1. aliases.json exact hit (also probing `<provider>/<declared>`, since
16
- * the table keys are harness-qualified) -- evidence states honored:
17
- * established/asserted follow standard_slug -> standards[] ->
18
- * catalog_record_id pin; `unresolved` or a null standard_slug is
19
- * TERMINAL (`kimi-code/k3` must never fall through to guessing).
20
- * 2. Adapter path: normalize(declared) -> candidate ids -> match rows via
21
- * candidate fields (source_model_id, every path suffix of it -- which
22
- * covers LiteLLM route prefixes and the last `/`-segment -- and
23
- * gateway_id where present; lowercased).
24
- * 3. Miss -> `unknown`.
25
- */
26
- import type { PriceRecord } from "./pricing.js";
27
- export type ResolutionState = {
28
- kind: "priced";
29
- model: CatalogModel;
30
- } | {
31
- kind: "known-unpriced";
32
- id: string;
33
- } | {
34
- kind: "estimated";
35
- model: CatalogModel;
36
- } | {
37
- kind: "unresolved";
38
- alias: string;
39
- } | {
40
- kind: "unknown";
41
- declared: string;
42
- } | {
43
- kind: "wrong-provider";
44
- declared: string;
45
- otherProviders: string[];
46
- } | {
47
- kind: "no-catalog";
48
- };
49
- export interface CatalogModel {
50
- id: string;
51
- normalizedId: string;
52
- offers: PriceOffer[];
53
- contextWindow?: number;
54
- }
55
- export interface PriceOffer {
56
- route: string;
57
- source: string;
58
- sourceModelId: string;
59
- provider: string | null;
60
- pricing: PriceRecord["pricing"];
61
- estimated: boolean;
62
- }
63
- /**
64
- * The dataset record shape the catalog layer reads. Structurally compatible
65
- * with pricing.ts's PriceRecord (the extra fields are optional so a slimmed
66
- * record still satisfies this), but grounded in lmprice's real published
67
- * schema (record_id / provider / mode / gateway_id / context_window).
68
- */
69
- export interface CatalogRecord {
70
- record_id?: string | null;
71
- source: string;
72
- source_model_id: string;
73
- provider?: string | null;
74
- mode?: string | null;
75
- gateway_id?: string | null;
76
- pricing: PriceRecord["pricing"];
77
- context_window?: {
78
- input_tokens?: number | null;
79
- } | null;
80
- }
81
- export interface CatalogDataLike {
82
- records: CatalogRecord[];
83
- }
84
- export type AliasEvidence = "established" | "asserted" | "unresolved";
85
- export interface AliasStandard {
86
- standard_slug: string;
87
- display_name?: string | null;
88
- vendor?: string | null;
89
- catalog_record_id: string | null;
90
- note?: string | null;
91
- }
92
- export interface AliasEntry {
93
- alias: string;
94
- standard_slug: string | null;
95
- evidence: AliasEvidence;
96
- source_url?: string | null;
97
- note?: string | null;
98
- }
99
- export interface AliasTable {
100
- schema_version: number;
101
- standards: AliasStandard[];
102
- aliases: AliasEntry[];
103
- }
104
- /**
105
- * Design section 1 sketches `matchRow(record)`; the implemented signature
106
- * takes the normalized candidate ids as a second argument because matching
107
- * is candidates-vs-row-candidate-fields, not a bare regex on the raw id
108
- * (review correction #3).
109
- */
110
- export interface ProviderAdapter {
111
- matchRow(record: CatalogRecord, candidates: readonly string[]): boolean;
112
- normalize(declared: string): string[];
113
- isChatModel(record: CatalogRecord): boolean;
114
- /** Family + capability membership WITHOUT a candidate check (catalog stats). */
115
- coversRecord(record: CatalogRecord): boolean;
116
- }
117
- /**
118
- * Providers WITHOUT adapters are skipped (`no-catalog`): copilot, opencode,
119
- * pi, dsh, lmplayer. dsh/opencode models can still resolve via the aliases
120
- * table, which is consulted BEFORE the adapter check.
121
- */
122
- export declare const PROVIDER_ADAPTERS: Record<string, ProviderAdapter>;
123
- /**
124
- * Resolve one declared model string for one provider against a loaded
125
- * catalog snapshot + alias table. Pure; never throws; no I/O.
126
- */
127
- export declare function resolveModel(provider: string, declared: string, data: CatalogDataLike | null, aliases: AliasTable | null): ResolutionState;
128
- export interface OfferResolution {
129
- state: ResolutionState;
130
- /** The offer to price at when the state is priced/estimated, else null. */
131
- offer: PriceOffer | null;
132
- /**
133
- * How the offer was selected: the alias table's catalog_record_id pin
134
- * when resolution came through aliases, route preference
135
- * (first-party > litellm > openrouter > manual, first with rates) otherwise.
136
- */
137
- provenance: "alias-pin" | "route-preference" | null;
138
- }
139
- export declare function resolveOfferForCost(provider: string, declared: string, data: CatalogDataLike | null, aliases: AliasTable | null): OfferResolution;
140
- /**
141
- * Count of distinct model identities a provider's adapter covers in this
142
- * catalog -- the "(N known)" in lint/seed's unknown-model warning. `null`
143
- * when the provider has no adapter.
144
- */
145
- export declare function catalogKnownModelCount(data: CatalogDataLike, provider: string): number | null;
@@ -1,4 +0,0 @@
1
- import { type CatalogDataLike } from './model-catalog.js';
2
- export declare function isAggregatorProvider(provider: string): boolean;
3
- export declare function catalogModelSuggestions(provider: string, catalog: CatalogDataLike): string[];
4
- export declare function loadModelSuggestions(provider: string): Promise<string[]>;
@@ -1 +0,0 @@
1
- export declare function getOneShotTimeoutMs(env?: NodeJS.ProcessEnv): number;
@@ -1,62 +0,0 @@
1
- /**
2
- * Opencode `.opencode/opencode.json` permission writer.
3
- *
4
- * **YOLO contract via config** (`permission: "allow"`).
5
- *
6
- * Opencode's ACP mode does NOT accept the `--dangerously-skip-permissions`
7
- * argv flag (it's `run`-subcommand-only — empirically verified, see commit
8
- * log around the opencode06 incident). The only way to satisfy lmctl's
9
- * YOLO contract for opencode is via the `permission` key in
10
- * opencode.json. Per the opencode schema:
11
- * - shorthand `"allow"` → `{ "*": "allow" }` (all tools)
12
- * - object form → per-tool decisions
13
- * We use the shorthand.
14
- *
15
- * lmctl does NOT inject a provider/model catalog here — models resolve
16
- * from opencode's own default catalog (models.dev + provider auth) and
17
- * the user's `~/.config/opencode/opencode.json`. We write only
18
- * `permission: "allow"`.
19
- */
20
- import type { MemberConfig } from "./config/team-config.js";
21
- import type { McpExecutableWarningOptions } from "../mcp/path-warning.js";
22
- export declare const OPENCODE_LMCTL_MCP_TIMEOUT_MS = 86400000;
23
- export declare function buildOpencodeMcpEntry(): Record<string, unknown>;
24
- /**
25
- * Predicate: is this `permission` value "effectively allow everything"?
26
- *
27
- * Two equivalent shapes per opencode's schema satisfy lmctl's YOLO
28
- * contract:
29
- * - the shorthand string `"allow"`
30
- * - the object form `{ "*": "allow" }` (single wildcard-allow entry)
31
- *
32
- * Anything else (`"ask"`, `"deny"`, multi-entry objects with mixed
33
- * rules, etc.) is a USER OVERRIDE we respect but warn about — turns
34
- * may hang waiting on permission prompts opencode would otherwise
35
- * auto-approve.
36
- */
37
- export declare function isEffectivelyAllowAll(permission: unknown): boolean;
38
- export interface OpencodeYoloOverrideFsOps {
39
- existsSync(path: string): boolean;
40
- readFileSync(path: string, encoding: BufferEncoding): string;
41
- }
42
- export declare function opencodeYoloOverrideWarnings(members: MemberConfig[], baseDir: string, fsOps?: OpencodeYoloOverrideFsOps): string[];
43
- /**
44
- * Install or upgrade `<targetDir>/.opencode/opencode.json`.
45
- *
46
- * What we write:
47
- * - `permission: "allow"` — the YOLO contract for opencode.
48
- *
49
- * Merge semantics:
50
- * - If the file is missing, write a fresh one with
51
- * `{ permission: "allow" }`.
52
- * - If the file exists, only fill in `permission` when absent;
53
- * a user-supplied permission value is PRESERVED (user override
54
- * wins). Existing user MCP entries are preserved untouched. When
55
- * the user-set value is not effectively allow-all, emit a structured
56
- * `opencode_yolo_override` warning via errorLog so the operator
57
- * knows YOLO isn't in effect.
58
- *
59
- * Returns true iff the file was written, false if already up-to-date
60
- * or skipped due to malformed JSON.
61
- */
62
- export declare function installOpencodeConfig(targetDir: string, _options?: McpExecutableWarningOptions): boolean;
@@ -1,40 +0,0 @@
1
- import type { SessionProvider, SessionSummary, SessionDetail } from "./types.js";
2
- type OpenCodeCompatibleProviderName = "opencode" | "lmplayer";
3
- interface OpenCodeProviderOptions {
4
- dbPath?: string;
5
- providerName?: OpenCodeCompatibleProviderName;
6
- startCommand?: string;
7
- /** Read-only connection `PRAGMA busy_timeout` in ms. Default 5000; lower
8
- * for tests that need to observe the retry-then-give-up path quickly. */
9
- busyTimeoutMs?: number;
10
- }
11
- export declare class OpenCodeProvider implements SessionProvider {
12
- readonly name: OpenCodeCompatibleProviderName;
13
- private readonly startCommand;
14
- private readonly dbPaths;
15
- private readonly busyTimeoutMs;
16
- constructor(opts?: OpenCodeProviderOptions);
17
- private existingDbPaths;
18
- private openDb;
19
- discoverSessions(): Promise<SessionSummary[]>;
20
- loadSession(sessionId: string): Promise<SessionDetail | null>;
21
- private buildSessionDetail;
22
- private extractText;
23
- resolveSessionPath(sessionId: string): Promise<string | null>;
24
- deleteSession(sessionId: string): Promise<boolean>;
25
- private findSessionRow;
26
- }
27
- /**
28
- * Bundle-identity probe (batch bundle mode): does the opencode session store
29
- * hold a session with EXACTLY this id, and which directory does it belong
30
- * to? opencode's `session/load` response does not echo the sessionId
31
- * (verified on the wire, 2026-09-25), so the bundle driver verifies the
32
- * resume target here instead. Read-only, with the same busy_timeout
33
- * rationale as OpenCodeProvider.openDb.
34
- */
35
- export declare function opencodeSessionStoreEntry(sessionId: string, opts?: {
36
- dbPath?: string;
37
- }): {
38
- directory: string;
39
- } | null;
40
- export {};
@@ -1,71 +0,0 @@
1
- export interface AcpResult {
2
- result: string;
3
- sessionId: string;
4
- durationMs: number;
5
- stopReason: string;
6
- exitCode: number | null;
7
- /** Human-readable strings when this turn's provider silently dropped a
8
- * declared model=/effort= (task #232) -- e.g. a `session/set_config_option`
9
- * rejection the turn proceeded past anyway. Omitted when nothing was
10
- * dropped. */
11
- warnings?: string[];
12
- /** See AcpOutputProcessorResult.sawActivity. */
13
- sawActivity: boolean;
14
- }
15
- export interface AcpOutputProcessorResult {
16
- result: string;
17
- sessionId: string;
18
- stopReason: string;
19
- /** Whether THIS turn saw any real agent activity (message/thought text,
20
- * a tool call or its result, a plan) -- as opposed to pure session
21
- * bookkeeping (session_info_update, current_mode_update,
22
- * config_option_update, available_commands_update, usage_update,
23
- * user_message_chunk) or nothing at all. See ACP_MEANINGFUL_UPDATE_KINDS. */
24
- sawActivity: boolean;
25
- }
26
- export interface AcpOutputProcessor {
27
- setSessionId(sessionId: string): void;
28
- beginTurn(): void;
29
- completeTurn(promptResponse: Record<string, unknown>): AcpOutputProcessorResult;
30
- /**
31
- * Abandon the in-flight turn WITHOUT recording a result (bundle
32
- * cancellation): stops collecting, discards the partial text, and leaves
33
- * `gotResult` untouched so a late-arriving prompt response cannot be
34
- * mistaken for a completed turn. The next `beginTurn()` starts clean.
35
- */
36
- cancelTurn(): void;
37
- processMessage(message: Record<string, unknown>): boolean;
38
- finalize(): AcpOutputProcessorResult | null;
39
- }
40
- export declare function isolateGeminiLatestAgentMessage(text: string): string;
41
- export declare function acpSessionIdFromResponse(response: Record<string, unknown>, fallback?: string): string;
42
- export declare function acpStopReasonFromResponse(response: Record<string, unknown>): string;
43
- /**
44
- * `sessionUpdate` kinds that represent real agent work, grounded in actual
45
- * production ACP traffic (checked against a full day's ~/.lmctl/debug-*.log,
46
- * 2026-09-29) plus the ACP spec's own "plan" kind (Zed and friends). Every
47
- * OTHER kind seen in that traffic -- session_info_update, current_mode_
48
- * update, config_option_update, available_commands_update, usage_update,
49
- * user_message_chunk (an echo of the user's OWN input, not agent work) -- is
50
- * pure session bookkeeping, and any future/unrecognized kind is treated the
51
- * same conservative way: NOT activity. This is a whitelist, not a blacklist,
52
- * on purpose -- the failure mode of missing a real silent-failure turn is
53
- * bad, but the failure mode of flagging a legitimate turn as broken is
54
- * worse (it would fire fleet-wide, for every provider, on every genuinely
55
- * empty-but-fine turn), so activity only counts when there is positive
56
- * evidence of it.
57
- */
58
- export declare const ACP_MEANINGFUL_UPDATE_KINDS: Set<string>;
59
- export declare function createAcpOutputProcessor(opts?: {
60
- tool?: string;
61
- onDelta?: (text: string) => void;
62
- /**
63
- * Result-text isolation for providers that replay prior turns (gemini's
64
- * latest-agent-message isolation). Supplied by the provider's ACP
65
- * profile (transports/acp-profiles/); when absent, falls back to the
66
- * historical `tool === "gemini"` keying so direct callers that pass
67
- * only a tool name keep their behavior.
68
- */
69
- isolateResult?: (text: string) => string;
70
- }): AcpOutputProcessor;
71
- export declare function supportsAcp(tool: string): boolean;
@@ -1,60 +0,0 @@
1
- export type CodexPermissionMode = "plan" | "yolo";
2
- export declare function codexSandboxForPermissionMode(mode: CodexPermissionMode): string;
3
- export declare function buildCodexThreadStartParams(opts: {
4
- cwd: string;
5
- permissionMode?: CodexPermissionMode;
6
- model?: string;
7
- }): Record<string, unknown>;
8
- export declare function buildCodexThreadResumeParams(opts: {
9
- threadId: string;
10
- permissionMode?: CodexPermissionMode;
11
- model?: string;
12
- }): Record<string, unknown>;
13
- export interface CodexInitializePayload extends Record<string, unknown> {
14
- clientInfo: {
15
- name: string;
16
- title: string;
17
- version: string;
18
- };
19
- capabilities: {
20
- experimentalApi: boolean;
21
- };
22
- }
23
- export declare function buildInitializePayload(version?: string): CodexInitializePayload;
24
- export type AgentMessagePhase = "commentary" | "final_answer";
25
- export interface AgentMessageItemState {
26
- phase: AgentMessagePhase | undefined;
27
- buffer: string;
28
- }
29
- export interface CodexAgentAccumulatorState {
30
- agentItems: Map<string, AgentMessageItemState>;
31
- resultText: string;
32
- }
33
- export interface CodexItemMismatchInfo {
34
- itemId: string;
35
- threadId?: string;
36
- turnId?: string;
37
- expectedFromItemText: string;
38
- gotFromBuffer: string;
39
- }
40
- export declare function createCodexAgentAccumulator(): CodexAgentAccumulatorState;
41
- export declare function processCodexAgentNotification(notification: Record<string, unknown>, state: CodexAgentAccumulatorState, onDelta?: (text: string) => void, onItemMismatch?: (info: CodexItemMismatchInfo) => void): boolean;
42
- export declare function flushCodexAgentAccumulator(state: CodexAgentAccumulatorState): void;
43
- export type CodexErrorDisposition = {
44
- willRetry: true;
45
- } | {
46
- willRetry: false;
47
- turnError: Error;
48
- };
49
- export declare function classifyCodexErrorDisposition(notification: Record<string, unknown>): CodexErrorDisposition;
50
- export interface CodexTurnState {
51
- pendingCodexError: Error | null;
52
- }
53
- export declare function createCodexTurnState(): CodexTurnState;
54
- export declare function recordCodexErrorNotification(notification: Record<string, unknown>, state: CodexTurnState): CodexErrorDisposition;
55
- export declare function resolveCodexTurnCompletion(notification: Record<string, unknown>, state: CodexTurnState): {
56
- shouldReject: true;
57
- turnError: Error;
58
- } | {
59
- shouldReject: false;
60
- };
@@ -1,57 +0,0 @@
1
- export interface StreamJsonResult {
2
- result: string;
3
- sessionId: string;
4
- durationMs: number;
5
- numTurns: number;
6
- exitCode: number | null;
7
- /** Set only by the result-grace-timeout fallback in transports/stream-json.ts
8
- * (BUG-claude-cli-stalls-after-end-turn.md): the model finished responding
9
- * but the CLI never emitted its own closing `result` event. Same convention
10
- * as TurnResult.warnings -- informational, does not change the outcome. */
11
- warnings?: string[];
12
- }
13
- export interface StreamJsonProcessor {
14
- processLine(line: string): void;
15
- sawResult(): boolean;
16
- finalize(): {
17
- result: string;
18
- sessionId: string;
19
- durationMs: number;
20
- numTurns: number;
21
- /**
22
- * True when the aggregated turn produced NO usable text and at least
23
- * one `result` event reported `is_error: true` — see
24
- * AggregatedResultEvents.isError below for why this must not be
25
- * conflated with "the model genuinely returned nothing."
26
- */
27
- isError: boolean;
28
- errorMessage?: string;
29
- } | null;
30
- }
31
- export interface AggregatedResultEvents {
32
- resultTexts: string[];
33
- durationMs: number;
34
- numTurns: number;
35
- sessionId: string;
36
- /**
37
- * A `result` event can report `is_error: true` with NO `result` field at
38
- * all (confirmed live, 2026-09-16, against a real `claude` CLI resuming
39
- * an evicted/unresolvable session id: subtype "error_during_execution",
40
- * no "result" key, the actual message only in an `errors: string[]`
41
- * array). Without this flag that shape reads as a genuine empty
42
- * response — "status: ok, content: (empty)" — indistinguishable from a
43
- * model that legitimately said nothing, when the two need completely
44
- * different remedies (a member refresh vs. investigating the prompt).
45
- * `errorMessage` is the joined `errors` array, or a subtype-based
46
- * fallback when `errors` is absent.
47
- */
48
- isError: boolean;
49
- errorMessage?: string;
50
- }
51
- export declare function joinResultTurns(texts: string[]): string;
52
- export declare function createStreamJsonProcessor(opts?: {
53
- onEvent?: (event: Record<string, unknown>) => void;
54
- onText?: (text: string) => void;
55
- }): StreamJsonProcessor;
56
- export declare function aggregateResultEvents(events: Array<Record<string, unknown>>): AggregatedResultEvents;
57
- export declare function supportsStreamJson(tool: string): boolean;
@@ -1,155 +0,0 @@
1
- /**
2
- * Passive (read-only, bounded, certified) reader for Antigravity CLI (`agy`)
3
- * sessions.
4
- *
5
- * `agy` lives under `~/.gemini/antigravity-cli` but is NOT Gemini CLI — the
6
- * shared parent directory is a naming coincidence, and nothing in this reader is
7
- * shared with a Gemini/ACP path.
8
- *
9
- * ## The two candidate sources, and why only one is used
10
- *
11
- * 1. `conversations/<session>.db` — SQLite. Tables: `trajectory_meta`, `steps`,
12
- * `gen_metadata`, `executor_metadata`, `parent_references`,
13
- * `trajectory_metadata_blob`, `battle_mode_infos`. **Every payload column is
14
- * an opaque protobuf blob** (`google3/third_party/jetski/cortex_pb`), not
15
- * JSON. One `gen_metadata` row == one model generation.
16
- * 2. `brain/<session>/.system_generated/logs/transcript_full.jsonl` (and the
17
- * older compact `transcript.jsonl`) — readable JSONL.
18
- *
19
- * A census of every local transcript (141 files, 13 801 records) shows the JSONL
20
- * carries ONLY: `step_index`, `source`, `type`, `status`, `created_at`,
21
- * `content`, `tool_calls`, `thinking`, `exit_code`, `error`, `error_code`.
22
- * There is **no token field, no model field and no per-response id anywhere in
23
- * it**, so it cannot supply a `response_id` and cannot be the response source.
24
- * It is therefore not read here at all; see the owner report for why joining it
25
- * back to a generation is a separate, larger piece of work.
26
- *
27
- * ## What IS certified from the database
28
- *
29
- * Read with a schema-less protobuf wire walker (field numbers only — no
30
- * generated stubs, nothing evaluated), cross-checked across 4 sessions and 2
31
- * model families:
32
- *
33
- * - `gen_metadata.data` field 1 is the generation's chat-model metadata message.
34
- * - Inside it, field 20 is a repeated `{1:key, 2:value}` string map. It contains
35
- * `request_id` (`<trajectory_id>-<n>`), which is unique per generation and is
36
- * used as `response_id`. It also contains `trajectory_id`, `last_step_index`,
37
- * `model_enum`, `last_execution_id` and `used_claude`/`used_non_gemini_model`
38
- * flags. Cross-checked: the top-level field-4 UUID is NOT per-generation (it
39
- * repeats across rows) and is deliberately not used as an id.
40
- * - Field 19 is the response model name string (`gemini-3.8-flash`,
41
- * `gemini-pro-default` locally).
42
- * - `last_step_index` indexes the `steps` table, whose `step_payload` field 5
43
- * sub-field 1 is a `google.protobuf.Timestamp`. That join gives a real
44
- * per-generation timestamp and is verified monotonic against generation order.
45
- *
46
- * ## What is NOT certified: tokens
47
- *
48
- * ## Tokens — RESOLVED via the installed client's own embedded schema
49
- *
50
- * Field 4 of the chat-model metadata was long treated as an unnamed counter
51
- * block because no `.proto` was available and the standard `UsageMetadata`
52
- * interpretation was directly ruled out (its assumed field 3 was smaller than
53
- * its assumed field 2 — impossible for total-vs-candidates under that guess).
54
- * That block is NOT a guess anymore: the installed `agy` binary is a Go build
55
- * of `google.golang.org/protobuf`, which embeds each compiled `.proto` file's
56
- * real `FileDescriptorProto` bytes for reflection. Locating the descriptor's
57
- * self-declared name field (`third_party/jetski/cortex_pb/cortex.proto`,
58
- * tag `0x0a` immediately preceding it — distinguishing it from the many
59
- * `0x1a` dependency-reference copies of the same string elsewhere in the
60
- * binary) and parsing the schema-less-walked byte range with the real
61
- * `google.protobuf` library recovers the ACTUAL message: field 4 is
62
- * `exa.codeium_common_pb.ModelUsageStats`, not a generic `UsageMetadata`.
63
- * Its real fields (confirmed against 6,662 real local rows, independently
64
- * re-derived and cross-checked by a second reviewer against the raw binary):
65
- * 2 input_tokens, 3 output_tokens, 4 cache_write_tokens (never observed
66
- * non-null locally — genuinely rare/unused, not unread), 5 cache_read_tokens
67
- * (absent on some rows — no cache yet), 9 thinking_output_tokens,
68
- * 10 response_output_tokens, 1 model (enum; the string alias is already
69
- * separately captured from field 19 above), 7/11/12 assorted opaque id
70
- * strings (message_id/response_id/provider_assigned_message_id — these,
71
- * not a "bot id"/"session id", are what the pre-schema walk was seeing).
72
- * `response_output_tokens + thinking_output_tokens === output_tokens` EXACTLY
73
- * on all 6,662/6,662 rows carrying both — proof (not inference) that
74
- * `output_tokens` is the total and `thinking_output_tokens` is its reasoning
75
- * subset. `cache_write_tokens`'s relationship (if any) to `input_uncached` is
76
- * deliberately left unasserted — see `agyUsage`'s own doc comment below; a
77
- * shared field name across providers is not evidence of shared semantics.
78
- * `input_tokens` is used directly as `input_uncached`, never subtracted from:
79
- * real rows show `input_tokens < cache_read_tokens` (e.g. 3280 vs 12145),
80
- * which is only possible if the two are independent additive counts, not an
81
- * inclusive total/subset pair — ruling out subtraction the same way the
82
- * original block-level guess was ruled out (an impossible relation under the
83
- * wrong model). Missing/invalid buckets stay NULL per-field (never a guessed
84
- * 0) — `cache_write_tokens` in particular is null on every locally observed
85
- * row precisely because it has genuinely never been populated here, not
86
- * because it is unread.
87
- *
88
- * `files_read` / `files_written` / `external_io` are NULL (unknown), not `[]`:
89
- * tool calls live in `steps.step_payload`, a different opaque message, and in
90
- * the un-joinable transcript. NULL correctly forces `read_bytes`/`write_bytes`
91
- * to NULL rather than presenting "no tools observed" as "no I/O occurred".
92
- */
93
- import type { ReadLimits, Snapshot, Source, SourceState } from "../passive-session-reader.js";
94
- import { type TokenValues } from "./shared.js";
95
- export declare const AGY_PROVIDER = "agy";
96
- export declare const AGY_EXTRACTION_REVISION_TAG = "agy-tokens-v1";
97
- /**
98
- * `steps.step_payload` → ISO timestamp, via field 5 (step metadata) sub-field 1
99
- * (`google.protobuf.Timestamp` {1:seconds, 2:nanos}). Returns null when the
100
- * shape is absent — never a fabricated or file-mtime-derived time.
101
- */
102
- export declare function agyStepTimestamp(stepPayload: Buffer): string | null;
103
- /** One generation extracted from a `gen_metadata` row. */
104
- export interface AgyGeneration {
105
- /** Native `request_id` — `<trajectory_id>-<n>`, unique per generation. */
106
- requestId: string;
107
- model: string | null;
108
- /** `steps.idx` this generation ended on; the timestamp join key. */
109
- lastStepIndex: number | null;
110
- tokens: TokenValues;
111
- thinkingOutputTokens: number | null;
112
- }
113
- /**
114
- * Extract the certified facts from one `gen_metadata.data` blob. Returns null
115
- * when the row carries no `request_id` — without a native id the generation
116
- * cannot be addressed, and inventing one is forbidden.
117
- */
118
- export declare function parseAgyGeneration(data: Buffer): AgyGeneration | null;
119
- export interface AgyPassiveReaderOptions {
120
- /** Defaults to `$HOME/.gemini/antigravity-cli/conversations`. */
121
- agyConversationsDir?: string;
122
- }
123
- export declare class AgyPassiveReader {
124
- private readonly conversationsDir;
125
- private readonly sqliteBusyTimeoutMs;
126
- constructor(options?: AgyPassiveReaderOptions & {
127
- sqliteBusyTimeoutMs?: number;
128
- });
129
- /**
130
- * Enumerate up to `cap` `<conversationsDir>/<session>.db` files ordered by real
131
- * path. A flat listing, so there is no traversal budget to exhaust; `truncated`
132
- * is always false and is returned only to match the other readers' shape.
133
- *
134
- * `.db-wal` / `.db-shm` companions are excluded by the exact `.db` suffix test:
135
- * they are not sources, and treating one as a session would mint a bogus id.
136
- */
137
- discover(limits: ReadLimits, cap: number, afterPath?: string | null): Promise<{
138
- sources: Source[];
139
- truncated: boolean;
140
- }>;
141
- /**
142
- * Open the conversation database read-only, after proving the path is a real,
143
- * non-symlink file inside the configured conversations directory AND that its
144
- * basename is the claimed session id.
145
- *
146
- * Returns null (→ `unavailable`) rather than throwing when the file is not a
147
- * usable SQLite database. A live session's `-wal`/`-shm` companions are read
148
- * through by SQLite itself; a read-only open that cannot reach them fails
149
- * closed here instead of returning a half-visible snapshot.
150
- */
151
- private open;
152
- inspect(source: Source, limits: ReadLimits): Promise<SourceState>;
153
- read(source: Source, revision: string, limits: ReadLimits): Promise<Snapshot>;
154
- }
155
- export declare function createAgyPassiveReader(options?: AgyPassiveReaderOptions): AgyPassiveReader;