super-dsh 0.1.6 → 0.1.10

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 (248) hide show
  1. package/README.md +25 -3
  2. package/agent-agy/cordis.patch.yml +7 -4
  3. package/agent-agy/dist/agent.d.ts +12 -11
  4. package/agent-agy/dist/agy-auth-gateway.d.ts +124 -0
  5. package/agent-agy/dist/agy-auth-gateway.js +233 -0
  6. package/agent-agy/dist/agy-auth.d.ts +153 -0
  7. package/agent-agy/dist/agy-auth.js +179 -0
  8. package/agent-agy/dist/agy-cli-client.d.ts +39 -9
  9. package/agent-agy/dist/agy-cli-client.js +82 -18
  10. package/agent-agy/dist/agy-store.d.ts +8 -0
  11. package/agent-agy/dist/index.d.ts +46 -16
  12. package/agent-agy/dist/index.js +82 -56
  13. package/agent-agy/dist/models.d.ts +70 -0
  14. package/agent-agy/dist/models.js +102 -3
  15. package/agent-agy/package.json +7 -5
  16. package/agent-agy-sdk/cordis.patch.yml +58 -0
  17. package/agent-agy-sdk/dist/adapter.d.ts +15 -0
  18. package/agent-agy-sdk/dist/adapter.js +42 -0
  19. package/agent-agy-sdk/dist/agent-preset-agy.d.ts +27 -0
  20. package/agent-agy-sdk/dist/agent-preset-agy.js +32 -0
  21. package/agent-agy-sdk/dist/agent.d.ts +138 -0
  22. package/agent-agy-sdk/dist/agent.js +494 -0
  23. package/{agent-agy → agent-agy-sdk}/dist/agy-client.d.ts +26 -6
  24. package/{agent-agy → agent-agy-sdk}/dist/agy-client.js +43 -25
  25. package/agent-agy-sdk/dist/agy-sessions.d.ts +25 -0
  26. package/agent-agy-sdk/dist/agy-sessions.js +107 -0
  27. package/agent-agy-sdk/dist/agy-store.d.ts +39 -0
  28. package/agent-agy-sdk/dist/agy-store.js +83 -0
  29. package/agent-agy-sdk/dist/inbox.d.ts +26 -0
  30. package/agent-agy-sdk/dist/inbox.js +53 -0
  31. package/agent-agy-sdk/dist/index.d.ts +93 -0
  32. package/agent-agy-sdk/dist/index.js +476 -0
  33. package/agent-agy-sdk/dist/models.d.ts +41 -0
  34. package/agent-agy-sdk/dist/models.js +74 -0
  35. package/agent-agy-sdk/dist/sdk-venv.d.ts +76 -0
  36. package/agent-agy-sdk/dist/sdk-venv.js +173 -0
  37. package/agent-agy-sdk/dist/world-plugin.d.ts +10 -0
  38. package/agent-agy-sdk/dist/world-plugin.js +82 -0
  39. package/agent-agy-sdk/package.json +64 -0
  40. package/agent-codex/README.md +141 -36
  41. package/agent-codex/cordis.patch.yml +14 -10
  42. package/agent-codex/dist/adapter.js +64 -28
  43. package/agent-codex/dist/agent.js +255 -81
  44. package/agent-codex/dist/app-server-approvals.js +165 -0
  45. package/agent-codex/dist/app-server-client.js +723 -0
  46. package/agent-codex/dist/app-server-events.js +432 -0
  47. package/agent-codex/dist/app-server-protocol.js +95 -0
  48. package/agent-codex/dist/app-server-wire.js +299 -0
  49. package/agent-codex/dist/codex-launch.js +78 -0
  50. package/agent-codex/dist/codex-native-config.js +392 -0
  51. package/agent-codex/dist/codex-provider-gateway.js +402 -0
  52. package/agent-codex/dist/codex-providers.js +376 -0
  53. package/agent-codex/dist/codex-route.js +86 -0
  54. package/agent-codex/dist/index.js +256 -115
  55. package/agent-codex/dist/permission.js +75 -1
  56. package/agent-codex/package.json +1 -2
  57. package/agent-codex-sdk/README.md +79 -0
  58. package/agent-codex-sdk/cordis.patch.yml +81 -0
  59. package/agent-codex-sdk/dist/adapter.js +91 -0
  60. package/agent-codex-sdk/dist/agent-preset-codex.js +32 -0
  61. package/agent-codex-sdk/dist/agent.js +1085 -0
  62. package/agent-codex-sdk/dist/codex-native-config.js +392 -0
  63. package/agent-codex-sdk/dist/codex-provider-gateway.js +402 -0
  64. package/agent-codex-sdk/dist/codex-providers.js +376 -0
  65. package/agent-codex-sdk/dist/codex-route.js +86 -0
  66. package/{agent-codex/dist/codex-client.js → agent-codex-sdk/dist/codex-sdk-client.js} +253 -32
  67. package/agent-codex-sdk/dist/codex-sdk-launch.js +92 -0
  68. package/agent-codex-sdk/dist/codex-store.js +180 -0
  69. package/agent-codex-sdk/dist/inbox.js +53 -0
  70. package/agent-codex-sdk/dist/index.js +739 -0
  71. package/agent-codex-sdk/dist/permission.js +71 -0
  72. package/agent-codex-sdk/dist/sdk-runtime.js +307 -0
  73. package/agent-codex-sdk/dist/session-map.js +167 -0
  74. package/agent-codex-sdk/dist/world-plugin.js +93 -0
  75. package/agent-codex-sdk/package.json +79 -0
  76. package/agent-codex-sdk/scripts/fetch-sdk-runtime.mjs +57 -0
  77. package/agent-omp/README.md +72 -55
  78. package/agent-omp/dist/agent.js +36 -11
  79. package/agent-omp/dist/index.js +92 -52
  80. package/agent-omp/dist/lazy-rpc.js +11 -4
  81. package/agent-omp/dist/omp-cli.js +114 -97
  82. package/agent-omp/dist/omp-store.js +12 -4
  83. package/agent-omp/dist/permission.js +70 -5
  84. package/agent-omp/dist/rpc-client.js +409 -0
  85. package/agent-omp/dist/world-plugin.js +36 -3
  86. package/agent-omp/package.json +2 -6
  87. package/agent-omp-sdk/README.md +103 -0
  88. package/agent-omp-sdk/cordis.patch.yml +108 -0
  89. package/agent-omp-sdk/dist/adapter.d.ts +21 -0
  90. package/agent-omp-sdk/dist/adapter.js +36 -0
  91. package/agent-omp-sdk/dist/agent-preset-omp.d.ts +31 -0
  92. package/agent-omp-sdk/dist/agent-preset-omp.js +32 -0
  93. package/agent-omp-sdk/dist/agent.d.ts +64 -0
  94. package/agent-omp-sdk/dist/agent.js +1178 -0
  95. package/agent-omp-sdk/dist/discovery.d.ts +57 -0
  96. package/agent-omp-sdk/dist/discovery.js +116 -0
  97. package/agent-omp-sdk/dist/inbox.d.ts +28 -0
  98. package/agent-omp-sdk/dist/inbox.js +53 -0
  99. package/agent-omp-sdk/dist/index.d.ts +60 -0
  100. package/agent-omp-sdk/dist/index.js +632 -0
  101. package/agent-omp-sdk/dist/knobs.d.ts +34 -0
  102. package/agent-omp-sdk/dist/knobs.js +50 -0
  103. package/agent-omp-sdk/dist/lazy-rpc.d.ts +98 -0
  104. package/agent-omp-sdk/dist/lazy-rpc.js +178 -0
  105. package/agent-omp-sdk/dist/mobile/zoom-guard.d.ts +187 -0
  106. package/agent-omp-sdk/dist/mobile/zoom-guard.js +294 -0
  107. package/agent-omp-sdk/dist/mobile-boot.d.ts +49 -0
  108. package/agent-omp-sdk/dist/mobile-boot.js +38 -0
  109. package/agent-omp-sdk/dist/models.d.ts +39 -0
  110. package/agent-omp-sdk/dist/models.js +299 -0
  111. package/agent-omp-sdk/dist/omp-cli.d.ts +67 -0
  112. package/agent-omp-sdk/dist/omp-cli.js +164 -0
  113. package/agent-omp-sdk/dist/omp-disk-discovery.d.ts +27 -0
  114. package/agent-omp-sdk/dist/omp-disk-discovery.js +178 -0
  115. package/agent-omp-sdk/dist/omp-executable.d.ts +2 -0
  116. package/agent-omp-sdk/dist/omp-executable.js +30 -0
  117. package/agent-omp-sdk/dist/omp-store.d.ts +134 -0
  118. package/agent-omp-sdk/dist/omp-store.js +526 -0
  119. package/agent-omp-sdk/dist/pairing.d.ts +7 -0
  120. package/agent-omp-sdk/dist/pairing.js +45 -0
  121. package/agent-omp-sdk/dist/permission.d.ts +138 -0
  122. package/agent-omp-sdk/dist/permission.js +161 -0
  123. package/agent-omp-sdk/dist/protocol.d.ts +189 -0
  124. package/agent-omp-sdk/dist/rpc-types.d.ts +77 -0
  125. package/agent-omp-sdk/dist/rpc-types.js +1 -0
  126. package/agent-omp-sdk/dist/sdk-client.d.ts +160 -0
  127. package/{agent-omp → agent-omp-sdk}/dist/sdk-client.js +108 -56
  128. package/agent-omp-sdk/dist/sdk-runtime.d.ts +211 -0
  129. package/agent-omp-sdk/dist/sdk-runtime.js +418 -0
  130. package/agent-omp-sdk/dist/sidecar-client.d.ts +87 -0
  131. package/agent-omp-sdk/dist/sidecar-client.js +197 -0
  132. package/agent-omp-sdk/dist/store/adapter.d.ts +17 -0
  133. package/agent-omp-sdk/dist/store/adapter.js +47 -0
  134. package/agent-omp-sdk/dist/store/db.d.ts +70 -0
  135. package/agent-omp-sdk/dist/store/db.js +210 -0
  136. package/agent-omp-sdk/dist/store/index.d.ts +23 -0
  137. package/agent-omp-sdk/dist/store/index.js +59 -0
  138. package/agent-omp-sdk/dist/store/reconcile.d.ts +15 -0
  139. package/agent-omp-sdk/dist/store/reconcile.js +51 -0
  140. package/agent-omp-sdk/dist/store/schema.d.ts +8 -0
  141. package/agent-omp-sdk/dist/store/schema.js +40 -0
  142. package/agent-omp-sdk/dist/transport.d.ts +49 -0
  143. package/agent-omp-sdk/dist/transport.js +35 -0
  144. package/agent-omp-sdk/dist/world-home.d.ts +4 -0
  145. package/agent-omp-sdk/dist/world-home.js +23 -0
  146. package/agent-omp-sdk/dist/world-plugin.d.ts +10 -0
  147. package/agent-omp-sdk/dist/world-plugin.js +137 -0
  148. package/agent-omp-sdk/package.json +87 -0
  149. package/client/index.js +1794 -287
  150. package/cordis.patch.yml +80 -0
  151. package/package.json +23 -8
  152. package/superd-hub/dist/a2a-delivery.d.ts +189 -0
  153. package/superd-hub/dist/a2a-delivery.js +240 -0
  154. package/superd-hub/dist/a2a-host.d.ts +76 -0
  155. package/superd-hub/dist/a2a-host.js +145 -0
  156. package/superd-hub/dist/a2a-ingest.d.ts +31 -0
  157. package/superd-hub/dist/a2a-ingest.js +636 -0
  158. package/superd-hub/dist/a2a-log.d.ts +17 -0
  159. package/superd-hub/dist/a2a-log.js +42 -0
  160. package/superd-hub/dist/a2a-row.d.ts +65 -0
  161. package/superd-hub/dist/a2a-row.js +162 -0
  162. package/superd-hub/dist/a2a-service.d.ts +357 -0
  163. package/superd-hub/dist/a2a-service.js +980 -0
  164. package/superd-hub/dist/a2a-wire.d.ts +220 -0
  165. package/superd-hub/dist/a2a-wire.js +305 -0
  166. package/superd-hub/dist/agent-ids.d.ts +10 -0
  167. package/superd-hub/dist/agent-ids.js +68 -0
  168. package/superd-hub/dist/agent-roster.d.ts +29 -18
  169. package/superd-hub/dist/agent-roster.js +54 -15
  170. package/superd-hub/dist/agent-status.d.ts +119 -0
  171. package/superd-hub/dist/agent-status.js +386 -0
  172. package/superd-hub/dist/client/agent-settings.d.ts +156 -0
  173. package/superd-hub/dist/client/agent-settings.js +229 -0
  174. package/superd-hub/dist/client/mesh-api.d.ts +134 -0
  175. package/superd-hub/dist/client/mesh-api.js +219 -0
  176. package/superd-hub/dist/client/mesh-groups.d.ts +63 -0
  177. package/superd-hub/dist/client/mesh-groups.js +66 -0
  178. package/superd-hub/dist/client/roster.d.ts +48 -0
  179. package/superd-hub/dist/client/roster.js +102 -0
  180. package/superd-hub/dist/client/runtime-settings-api.d.ts +76 -0
  181. package/superd-hub/dist/client/runtime-settings-api.js +137 -0
  182. package/superd-hub/dist/client/switch.d.ts +165 -0
  183. package/superd-hub/dist/client/switch.js +295 -0
  184. package/superd-hub/dist/exec-pty-channel.d.ts +58 -0
  185. package/superd-hub/dist/exec-pty-channel.js +162 -0
  186. package/superd-hub/dist/exec-pty-framing.d.ts +32 -0
  187. package/superd-hub/dist/exec-pty-framing.js +81 -0
  188. package/superd-hub/dist/exec-pty-rpc.d.ts +21 -0
  189. package/superd-hub/dist/exec-pty-rpc.js +128 -0
  190. package/superd-hub/dist/exec-pty-session.d.ts +76 -0
  191. package/superd-hub/dist/exec-pty-session.js +234 -0
  192. package/superd-hub/dist/exec.d.ts +56 -0
  193. package/superd-hub/dist/exec.js +225 -0
  194. package/superd-hub/dist/gateway.d.ts +39 -2
  195. package/superd-hub/dist/gateway.js +62 -3
  196. package/superd-hub/dist/hub-tool.d.ts +174 -0
  197. package/superd-hub/dist/hub-tool.js +464 -0
  198. package/superd-hub/dist/index.d.ts +15 -1
  199. package/superd-hub/dist/index.js +16 -0
  200. package/superd-hub/dist/machines.d.ts +45 -0
  201. package/superd-hub/dist/machines.js +125 -0
  202. package/superd-hub/dist/mesh-federate.d.ts +138 -0
  203. package/superd-hub/dist/mesh-federate.js +223 -0
  204. package/superd-hub/dist/mesh-gateway.d.ts +67 -0
  205. package/superd-hub/dist/mesh-gateway.js +408 -0
  206. package/superd-hub/dist/mesh-link.d.ts +274 -0
  207. package/superd-hub/dist/mesh-link.js +441 -0
  208. package/superd-hub/dist/mesh-rpc.d.ts +123 -0
  209. package/superd-hub/dist/mesh-rpc.js +250 -0
  210. package/superd-hub/dist/mux-client.d.ts +71 -0
  211. package/superd-hub/dist/mux-client.js +281 -0
  212. package/superd-hub/dist/pack-version.d.ts +2 -0
  213. package/superd-hub/dist/pack-version.js +30 -0
  214. package/superd-hub/dist/roster.d.ts +6 -0
  215. package/superd-hub/dist/rpc.d.ts +18 -2
  216. package/superd-hub/dist/rpc.js +34 -4
  217. package/superd-hub/dist/spawn-world.js +3 -1
  218. package/superd-hub/dist/switch-core.d.ts +62 -25
  219. package/superd-hub/dist/switch-core.js +53 -30
  220. package/superd-hub/dist/system-head.d.ts +22 -12
  221. package/superd-hub/dist/system-head.js +100 -84
  222. package/superd-hub/dist/wire-endpoints.d.ts +264 -0
  223. package/superd-hub/dist/wire-endpoints.js +180 -0
  224. package/superd-hub/lib/client/index.js +1794 -287
  225. package/superd-hub/package.json +11 -2
  226. package/agent-agy/dist/agent-preset-projection.d.ts +0 -31
  227. package/agent-agy/dist/agent-preset-projection.js +0 -33
  228. package/agent-claude/dist/agent-preset-projection.js +0 -30
  229. package/agent-codex/dist/agent-preset-projection.js +0 -37
  230. package/agent-codex/dist/app-home.js +0 -65
  231. package/agent-codex/dist/models.js +0 -152
  232. package/agent-codex/dist/spike.js +0 -46
  233. package/agent-hermes/dist/agent-preset-projection.js +0 -34
  234. package/agent-omp/dist/agent-preset-projection.js +0 -36
  235. package/agent-omp/dist/app-home.js +0 -86
  236. package/agent-omp/dist/sidecar-client.js +0 -195
  237. package/agent-pi/dist/agent-preset-projection.js +0 -29
  238. package/superd-hub/dist/client-shim.d.ts +0 -28
  239. package/superd-hub/dist/client-shim.js +0 -251
  240. package/superd-hub/dist/index-pass.d.ts +0 -22
  241. package/superd-hub/dist/index-pass.js +0 -47
  242. package/superd-hub/dist/labels.d.ts +0 -45
  243. package/superd-hub/dist/labels.js +0 -83
  244. /package/{agent-agy → agent-agy-sdk}/bridge/agy_bridge.py +0 -0
  245. /package/{agent-agy → agent-agy-sdk}/bridge/gemini_openai_server.mjs +0 -0
  246. /package/{agent-codex/dist/codex-events.js → agent-codex-sdk/dist/codex-sdk-events.js} +0 -0
  247. /package/{agent-omp → agent-omp-sdk}/dist/protocol.js +0 -0
  248. /package/{agent-omp → agent-omp-sdk}/sidecar/main.ts +0 -0
@@ -0,0 +1,299 @@
1
+ /**
2
+ * OMP model catalog for the Dash model selector.
3
+ *
4
+ * The browser model selector is a pure RPC round-trip through the apiproxy:
5
+ * `session.models` reads `ctx.llm.listProviders/listModels/resolveModelInfo`,
6
+ * so the OMP provider registers an `LlmAdapter` whose catalog is OMP's real
7
+ * AVAILABLE model set. This module owns the source of that catalog.
8
+ *
9
+ * Source: `omp models --json` (first-party CLI, `omp-cli.ts`) — OMP's own
10
+ * credential-resolved availability verdict. The documented selectability
11
+ * rule (provider not in `disabledProviders` and keyless or with a
12
+ * resolvable credential) runs through a 7-level credential precedence that
13
+ * includes OAuth/login keys stored in agent.db — a state NO config file
14
+ * reveals, which is why the catalog must come from OMP itself.
15
+ *
16
+ * The authoritative RPC `get_available_models` would serve the same set but
17
+ * exceeds the 1 MiB transport frame limit for this install; the CLI returns
18
+ * the compact form (~50 models / 5 providers, 15 KB, ~1.7s). The on-disk
19
+ * `models.db` ∪ `models.yml` pair remains ONLY as the subprocess-failure
20
+ * fallback (registry-cache noise included) — never the primary.
21
+ */
22
+ import { readFileSync } from "node:fs";
23
+ import { join } from "node:path";
24
+ import { DatabaseSync } from "node:sqlite";
25
+ import { ompAvailableModels, ompAvailableModelsSync, ompModelRolesSync } from "./omp-cli.js";
26
+ import { OMP_NATIVE_HOME } from "./knobs.js";
27
+ import { readOmpModelRolesFromConfig } from "./omp-store.js";
28
+ import { ReasoningEffortId } from "@deepseek-ai/dsh-llm";
29
+ const OMP_AGENT_DIR = join(OMP_NATIVE_HOME, "agent");
30
+ /**
31
+ * Providers named by config.yml `modelRoles` lead the selector: they are the
32
+ * roles the operator actually wired (the TUI default-model semantics).
33
+ */
34
+ let cached = null;
35
+ /**
36
+ * Read the AVAILABLE OMP model catalog, memoized. First call prefers the CLI
37
+ * (`omp models --json`, synchronous — the boot route list must be known
38
+ * before `registerAdapter` returns); a CLI failure falls back to the on-disk
39
+ * registry cache with a stderr note. Later refreshes go through
40
+ * `refreshOmpModelsCli` (async, per reconcile tick).
41
+ */
42
+ export function loadOmpModels() {
43
+ if (cached === null) {
44
+ const cli = ompAvailableModelsSync();
45
+ if (cli !== undefined) {
46
+ cached = cli.map((model) => normalizeModel(model)).filter((model) => model !== null);
47
+ }
48
+ else {
49
+ process.stderr.write("[omp-provider] omp models --json unavailable; falling back to the on-disk model cache\n");
50
+ cached = mergeModels(loadModelsDb(), loadModelsYml());
51
+ }
52
+ }
53
+ return cached;
54
+ }
55
+ /**
56
+ * Re-run the CLI catalog and swap the memo on success.
57
+ * @returns whether the refresh produced a fresh catalog.
58
+ */
59
+ export async function refreshOmpModelsCli() {
60
+ const cli = await ompAvailableModels();
61
+ if (cli === undefined)
62
+ return false;
63
+ cached = cli.map((model) => normalizeModel(model)).filter((model) => model !== null);
64
+ return true;
65
+ }
66
+ /** The distinct provider ids across the catalog, modelRoles roles first. */
67
+ export function ompProviderIds(models = loadOmpModels()) {
68
+ const seen = new Set();
69
+ for (const model of models)
70
+ seen.add(model.provider);
71
+ const ordered = [];
72
+ // Providers the operator wired into modelRoles lead the selector (TUI
73
+ // semantics: the roles actually in use); everything else follows
74
+ // alphabetically. Roles come from config.yml ON DISK — never a sidecar
75
+ // warm (sidecar-decoupling); the memo is only a fallback for a sidecar
76
+ // that is already live.
77
+ const roles = readOmpModelRolesFromConfig() ?? ompModelRolesSync();
78
+ for (const selector of Object.values(roles ?? {})) {
79
+ const slash = selector.indexOf("/");
80
+ const provider = slash > 0 ? selector.slice(0, slash) : "";
81
+ if (provider !== "" && seen.has(provider) && !ordered.includes(provider))
82
+ ordered.push(provider);
83
+ }
84
+ for (const provider of [...seen].sort((a, b) => a.localeCompare(b))) {
85
+ if (!ordered.includes(provider))
86
+ ordered.push(provider);
87
+ }
88
+ return ordered;
89
+ }
90
+ /** Human-readable provider name for `LlmProviderInfo.name`. */
91
+ export function providerDisplayName(provider) {
92
+ const titles = { zai: "Z.AI", xai: "xAI", openrouter: "OpenRouter" };
93
+ return titles[provider] ?? (provider.charAt(0).toUpperCase() + provider.slice(1));
94
+ }
95
+ /** Merge the registry cache under the user overlay (later models win per provider+id). */
96
+ function mergeModels(cache, overlay) {
97
+ if (overlay.length === 0)
98
+ return cache;
99
+ const byKey = new Map();
100
+ for (const model of cache)
101
+ byKey.set(model.provider + "/" + model.id, model);
102
+ for (const model of overlay)
103
+ byKey.set(model.provider + "/" + model.id, model);
104
+ return [...byKey.values()];
105
+ }
106
+ /**
107
+ * Read `~/.omp/agent/models.db` (`model_cache.models` JSON column). This is
108
+ * the on-disk form of the registry `get_available_models` serves. Read-only
109
+ * and tolerant of a missing/empty file (OMP may not have refreshed it yet).
110
+ */
111
+ function loadModelsDb() {
112
+ const out = [];
113
+ try {
114
+ const db = new DatabaseSync(join(OMP_AGENT_DIR, "models.db"), { readOnly: true });
115
+ try {
116
+ const rows = db.prepare("SELECT models FROM model_cache").all();
117
+ for (const row of rows) {
118
+ try {
119
+ const models = JSON.parse(row.models);
120
+ if (!Array.isArray(models))
121
+ continue;
122
+ for (const model of models) {
123
+ const parsed = normalizeModel(model);
124
+ if (parsed !== null)
125
+ out.push(parsed);
126
+ }
127
+ }
128
+ catch {
129
+ // one malformed provider row must not sink the whole catalog
130
+ }
131
+ }
132
+ }
133
+ finally {
134
+ db.close();
135
+ }
136
+ }
137
+ catch {
138
+ // absent db / schema drift → fall through to the overlay alone
139
+ }
140
+ return out;
141
+ }
142
+ /**
143
+ * Parse `~/.omp/agent/models.yml` — a `providers: <id>: { models: [ ... ] }`
144
+ * overlay OMP writes. A focused indentation scan is enough for this fixed
145
+ * shape and avoids pulling `js-yaml` into the provider's dependency surface.
146
+ * Any parse failure degrades to an empty overlay.
147
+ */
148
+ function loadModelsYml() {
149
+ const out = [];
150
+ let text;
151
+ try {
152
+ text = readFileSync(join(OMP_AGENT_DIR, "models.yml"), "utf8");
153
+ }
154
+ catch {
155
+ return out;
156
+ }
157
+ let provider = "";
158
+ let inModels = false;
159
+ let model = null;
160
+ const push = () => {
161
+ if (model !== null) {
162
+ const parsed = normalizeModel({ ...model, provider });
163
+ if (parsed !== null)
164
+ out.push(parsed);
165
+ model = null;
166
+ }
167
+ };
168
+ for (const raw of text.split("\n")) {
169
+ const line = raw.replace(/\r$/, "");
170
+ if (line.trim() === "" || line.trimStart().startsWith("#"))
171
+ continue;
172
+ const indent = line.length - line.trimStart().length;
173
+ const trimmed = line.trim();
174
+ if (indent === 0) {
175
+ if (trimmed === "providers:") {
176
+ provider = "";
177
+ inModels = false;
178
+ model = null;
179
+ }
180
+ else {
181
+ provider = "";
182
+ inModels = false;
183
+ model = null;
184
+ }
185
+ continue;
186
+ }
187
+ if (indent === 2 && trimmed.endsWith(":")) {
188
+ push();
189
+ provider = trimmed.slice(0, -1).trim();
190
+ inModels = false;
191
+ continue;
192
+ }
193
+ if (indent === 4 && trimmed === "models:") {
194
+ inModels = true;
195
+ continue;
196
+ }
197
+ if (inModels && indent >= 6 && trimmed.startsWith("- ")) {
198
+ push();
199
+ model = {};
200
+ const entry = trimmed.slice(2).trim();
201
+ const colon = entry.indexOf(":");
202
+ if (colon > 0)
203
+ model[entry.slice(0, colon).trim()] = entry.slice(colon + 1).trim();
204
+ continue;
205
+ }
206
+ if (inModels && model !== null && indent >= 8) {
207
+ const colon = trimmed.indexOf(":");
208
+ if (colon > 0) {
209
+ const key = trimmed.slice(0, colon).trim();
210
+ model[key] = trimmed.slice(colon + 1).trim();
211
+ }
212
+ continue;
213
+ }
214
+ // Any other shape is outside the models list we care about.
215
+ }
216
+ push();
217
+ return out;
218
+ }
219
+ /** Coerce one raw model record into an {@link OmpModel}, or null when unusable. */
220
+ function normalizeModel(raw) {
221
+ if (raw === null || typeof raw !== "object")
222
+ return null;
223
+ const record = raw;
224
+ const id = typeof record.id === "string" ? record.id : "";
225
+ const provider = typeof record.provider === "string" ? record.provider : "";
226
+ const name = typeof record.name === "string" && record.name !== "" ? record.name : id;
227
+ if (id === "" || provider === "" || name === "")
228
+ return null;
229
+ const thinking = normalizeThinking(record.thinking);
230
+ return {
231
+ id,
232
+ provider,
233
+ name,
234
+ ...(typeof record.api === "string" ? { api: record.api } : {}),
235
+ ...(typeof record.baseUrl === "string" ? { baseUrl: record.baseUrl } : {}),
236
+ ...(typeof record.reasoning === "boolean" ? { reasoning: record.reasoning } : {}),
237
+ ...(Array.isArray(record.input) ? { input: record.input.filter((m) => typeof m === "string") } : {}),
238
+ ...(typeof record.contextWindow === "number" ? { contextWindow: record.contextWindow } : {}),
239
+ ...(typeof record.maxTokens === "number" ? { maxTokens: record.maxTokens } : {}),
240
+ ...(thinking === undefined ? {} : { thinking }),
241
+ };
242
+ }
243
+ /** Map OMP's declared input modalities to the harness vocabulary. */
244
+ function inputModalities(model) {
245
+ if (model.input === undefined)
246
+ return undefined;
247
+ const modalities = model.input.filter((m) => m === "text" || m === "image");
248
+ return modalities.length === 0 ? undefined : modalities;
249
+ }
250
+ /** Extract OMP's `thinking` sub-object, checking each field at the boundary. */
251
+ function normalizeThinking(raw) {
252
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw))
253
+ return undefined;
254
+ const t = raw;
255
+ return {
256
+ ...(typeof t.mode === "string" ? { mode: t.mode } : {}),
257
+ ...(Array.isArray(t.efforts) ? { efforts: t.efforts.filter((e) => typeof e === "string") } : {}),
258
+ ...(typeof t.defaultLevel === "string" ? { defaultLevel: t.defaultLevel } : {}),
259
+ };
260
+ }
261
+ /** Map OMP `thinking.efforts` into the adapter reasoning-effort vocabulary. */
262
+ function reasoningInfo(model) {
263
+ const efforts = model.thinking?.efforts ?? [];
264
+ if (efforts.length === 0)
265
+ return undefined;
266
+ const ids = new Set();
267
+ const mapped = efforts
268
+ .filter((effort) => effort !== "" && !ids.has(effort) && (ids.add(effort), true))
269
+ .map((effort) => ({ id: ReasoningEffortId(effort), name: effort }));
270
+ if (mapped.length === 0)
271
+ return undefined;
272
+ const defaultEffort = model.thinking?.defaultLevel;
273
+ return {
274
+ efforts: mapped,
275
+ ...(defaultEffort !== undefined && ids.has(defaultEffort) ? { defaultEffort: ReasoningEffortId(defaultEffort) } : {}),
276
+ };
277
+ }
278
+ /** One catalog row: {@link LlmModelInfo} for `listModels`. */
279
+ export function toModelInfo(model) {
280
+ return {
281
+ provider: model.provider,
282
+ id: model.id,
283
+ name: model.name,
284
+ ...(inputModalities(model) === undefined ? {} : { inputModalities: inputModalities(model) }),
285
+ };
286
+ }
287
+ /** One exact-model resolution: {@link LlmResolvedModelInfo} for `resolveModel`. */
288
+ export function toResolvedModelInfo(model) {
289
+ const info = toModelInfo(model);
290
+ const contextWindow = typeof model.contextWindow === "number" && model.contextWindow > 0 ? model.contextWindow : undefined;
291
+ const defaultMaxTokens = typeof model.maxTokens === "number" && model.maxTokens > 0 ? model.maxTokens : undefined;
292
+ const reasoning = reasoningInfo(model);
293
+ return {
294
+ ...info,
295
+ ...(contextWindow === undefined ? {} : { context: { contextWindow } }),
296
+ ...(defaultMaxTokens === undefined ? {} : { defaultMaxTokens }),
297
+ ...(reasoning === undefined ? {} : { reasoning }),
298
+ };
299
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * OMP CLI subprocess data plane — the model catalog and the `modelRoles` map
3
+ * are read from (and written through) the operator's own `omp` binary, the
4
+ * first-party entries the bridge uses instead of parsing OMP's files or
5
+ * hitting frame-limited RPC:
6
+ *
7
+ * - `omp models --json` → the credential-resolved AVAILABLE model catalog
8
+ * (documented selectability rule: provider not in `disabledProviders` and
9
+ * keyless or with a resolvable credential — 7-level precedence, including
10
+ * OAuth/login keys stored in agent.db that no config file reveals).
11
+ * - `omp config get modelRoles --json` → the role→"provider/model[:effort]"
12
+ * map, including the persisted `default` selector (TUI semantics: the
13
+ * default model IS config state, surviving sessions).
14
+ * - `omp config set modelRoles --json <obj>` → whole-object roundtrip write
15
+ * (dotted keys are rejected; the entire modelRoles object is the unit).
16
+ *
17
+ * All calls run with cwd = `OMP_HOME` (omp writes its own state db next to
18
+ * the agent dir) and inherit the daemon environment. The binary is resolved
19
+ * per call ({@link resolveOmpExecutable}), so `$OMP_EXECUTABLE` and PATH
20
+ * changes take effect without a reload.
21
+ *
22
+ * Fail-soft: a missing, broken or unresponsive `omp` yields `undefined`
23
+ * (reads) or `false` (write) — the provider never fails to boot because the
24
+ * CLI is down.
25
+ *
26
+ * @module agent-omp/omp-cli
27
+ */
28
+ /** One raw model record as OMP's catalog describes it. */
29
+ export interface OmpCliModel {
30
+ provider: string;
31
+ id: string;
32
+ [key: string]: unknown;
33
+ }
34
+ /** role → "provider/model[:effort]" selectors, from the live config. */
35
+ export interface OmpModelRoles {
36
+ [role: string]: string;
37
+ }
38
+ /**
39
+ * Synchronous `omp models --json` — the boot-time variant (the adapter's
40
+ * provider route list must be known before `registerAdapter` returns).
41
+ * Blocks up to the timeout; prefer the async variant everywhere else.
42
+ */
43
+ export declare function ompAvailableModelsSync(): OmpCliModel[] | undefined;
44
+ /**
45
+ * `omp models --json` — the AVAILABLE model catalog (credential-resolved,
46
+ * `disabledProviders`-aware). `undefined` when the CLI fails; callers fall
47
+ * back to the on-disk sources.
48
+ */
49
+ export declare function ompAvailableModels(): Promise<OmpCliModel[] | undefined>;
50
+ /**
51
+ * Synchronous `omp config get modelRoles --json` — boot-time variant of
52
+ * {@link ompModelRoles}.
53
+ */
54
+ export declare function ompModelRolesSync(): OmpModelRoles | undefined;
55
+ /**
56
+ * `omp config get modelRoles --json` — the current modelRoles object, read
57
+ * fresh on every call (the OMP TUI may have rewritten config.yml). `undefined`
58
+ * when unset or the CLI fails.
59
+ */
60
+ export declare function ompModelRoles(): Promise<OmpModelRoles | undefined>;
61
+ /**
62
+ * `omp config set modelRoles --json <obj>` — the TUI-grade default-model
63
+ * write: OMP persists `modelRoles.default` itself, so every new session
64
+ * (TUI or Web) inherits the selection. Whole-object roundtrip: dotted keys
65
+ * are rejected by the CLI. `false` on any failure (fail-soft).
66
+ */
67
+ export declare function ompSetModelRoles(roles: OmpModelRoles): Promise<boolean>;
@@ -0,0 +1,164 @@
1
+ /**
2
+ * OMP CLI subprocess data plane — the model catalog and the `modelRoles` map
3
+ * are read from (and written through) the operator's own `omp` binary, the
4
+ * first-party entries the bridge uses instead of parsing OMP's files or
5
+ * hitting frame-limited RPC:
6
+ *
7
+ * - `omp models --json` → the credential-resolved AVAILABLE model catalog
8
+ * (documented selectability rule: provider not in `disabledProviders` and
9
+ * keyless or with a resolvable credential — 7-level precedence, including
10
+ * OAuth/login keys stored in agent.db that no config file reveals).
11
+ * - `omp config get modelRoles --json` → the role→"provider/model[:effort]"
12
+ * map, including the persisted `default` selector (TUI semantics: the
13
+ * default model IS config state, surviving sessions).
14
+ * - `omp config set modelRoles --json <obj>` → whole-object roundtrip write
15
+ * (dotted keys are rejected; the entire modelRoles object is the unit).
16
+ *
17
+ * All calls run with cwd = `OMP_HOME` (omp writes its own state db next to
18
+ * the agent dir) and inherit the daemon environment. The binary is resolved
19
+ * per call ({@link resolveOmpExecutable}), so `$OMP_EXECUTABLE` and PATH
20
+ * changes take effect without a reload.
21
+ *
22
+ * Fail-soft: a missing, broken or unresponsive `omp` yields `undefined`
23
+ * (reads) or `false` (write) — the provider never fails to boot because the
24
+ * CLI is down.
25
+ *
26
+ * @module agent-omp/omp-cli
27
+ */
28
+ import { execFile, execFileSync } from "node:child_process";
29
+ import { promisify } from "node:util";
30
+ import { OMP_HOME } from "./knobs.js";
31
+ import { resolveOmpExecutable } from "./omp-executable.js";
32
+ const execFileAsync = promisify(execFile);
33
+ const TIMEOUT_MS = 15_000;
34
+ const MAX_BUFFER = 64 * 1024 * 1024;
35
+ // ---------------------------------------------------------------------------
36
+ // Subprocess plumbing (fail-soft: any failure → undefined/false)
37
+ // ---------------------------------------------------------------------------
38
+ /** One `omp <args>` invocation parsed as JSON; undefined on any failure. */
39
+ async function ompCliJson(args) {
40
+ try {
41
+ const { stdout } = await execFileAsync(resolveOmpExecutable(), args, {
42
+ cwd: OMP_HOME,
43
+ timeout: TIMEOUT_MS,
44
+ maxBuffer: MAX_BUFFER,
45
+ });
46
+ return JSON.parse(stdout);
47
+ }
48
+ catch {
49
+ return undefined;
50
+ }
51
+ }
52
+ /** Synchronous variant of {@link ompCliJson} — the boot-time path. */
53
+ function ompCliJsonSync(args) {
54
+ try {
55
+ const stdout = execFileSync(resolveOmpExecutable(), args, {
56
+ cwd: OMP_HOME,
57
+ timeout: TIMEOUT_MS,
58
+ encoding: "utf8",
59
+ maxBuffer: MAX_BUFFER,
60
+ });
61
+ return JSON.parse(stdout);
62
+ }
63
+ catch {
64
+ return undefined;
65
+ }
66
+ }
67
+ /** Validate an `omp models --json` payload; undefined when empty or invalid. */
68
+ function parseModels(json) {
69
+ if (json === null || typeof json !== "object")
70
+ return undefined;
71
+ const models = json.models;
72
+ if (!Array.isArray(models))
73
+ return undefined;
74
+ const out = [];
75
+ for (const model of models) {
76
+ if (model !== null && typeof model === "object" && typeof model.provider === "string") {
77
+ out.push(model);
78
+ }
79
+ }
80
+ return out.length > 0 ? out : undefined;
81
+ }
82
+ /**
83
+ * Validate a `modelRoles` payload; undefined when unset, empty or invalid.
84
+ *
85
+ * `omp config get <key> --json` prints `{key, value, type, description}`, but
86
+ * the bare value map appears in older builds, so both shapes are accepted. A
87
+ * wrapped payload for a different key is rejected rather than misread as a
88
+ * role map.
89
+ */
90
+ function parseModelRoles(json) {
91
+ if (json === null || typeof json !== "object" || Array.isArray(json))
92
+ return undefined;
93
+ const record = json;
94
+ let value = record;
95
+ if ("key" in record || "value" in record) {
96
+ if (typeof record.key === "string" && record.key !== "modelRoles")
97
+ return undefined;
98
+ value = record.value;
99
+ }
100
+ if (value === null || typeof value !== "object" || Array.isArray(value))
101
+ return undefined;
102
+ const out = {};
103
+ for (const [role, selector] of Object.entries(value)) {
104
+ if (typeof selector === "string" && selector !== "")
105
+ out[role] = selector;
106
+ }
107
+ return Object.keys(out).length > 0 ? out : undefined;
108
+ }
109
+ // ---------------------------------------------------------------------------
110
+ // Model catalog
111
+ // ---------------------------------------------------------------------------
112
+ /**
113
+ * Synchronous `omp models --json` — the boot-time variant (the adapter's
114
+ * provider route list must be known before `registerAdapter` returns).
115
+ * Blocks up to the timeout; prefer the async variant everywhere else.
116
+ */
117
+ export function ompAvailableModelsSync() {
118
+ return parseModels(ompCliJsonSync(["models", "--json"]));
119
+ }
120
+ /**
121
+ * `omp models --json` — the AVAILABLE model catalog (credential-resolved,
122
+ * `disabledProviders`-aware). `undefined` when the CLI fails; callers fall
123
+ * back to the on-disk sources.
124
+ */
125
+ export async function ompAvailableModels() {
126
+ return parseModels(await ompCliJson(["models", "--json"]));
127
+ }
128
+ // ---------------------------------------------------------------------------
129
+ // modelRoles
130
+ // ---------------------------------------------------------------------------
131
+ /**
132
+ * Synchronous `omp config get modelRoles --json` — boot-time variant of
133
+ * {@link ompModelRoles}.
134
+ */
135
+ export function ompModelRolesSync() {
136
+ return parseModelRoles(ompCliJsonSync(["config", "get", "modelRoles", "--json"]));
137
+ }
138
+ /**
139
+ * `omp config get modelRoles --json` — the current modelRoles object, read
140
+ * fresh on every call (the OMP TUI may have rewritten config.yml). `undefined`
141
+ * when unset or the CLI fails.
142
+ */
143
+ export async function ompModelRoles() {
144
+ return parseModelRoles(await ompCliJson(["config", "get", "modelRoles", "--json"]));
145
+ }
146
+ /**
147
+ * `omp config set modelRoles --json <obj>` — the TUI-grade default-model
148
+ * write: OMP persists `modelRoles.default` itself, so every new session
149
+ * (TUI or Web) inherits the selection. Whole-object roundtrip: dotted keys
150
+ * are rejected by the CLI. `false` on any failure (fail-soft).
151
+ */
152
+ export async function ompSetModelRoles(roles) {
153
+ try {
154
+ await execFileAsync(resolveOmpExecutable(), ["config", "set", "modelRoles", "--json", JSON.stringify(roles)], {
155
+ cwd: OMP_HOME,
156
+ timeout: TIMEOUT_MS,
157
+ maxBuffer: MAX_BUFFER,
158
+ });
159
+ return true;
160
+ }
161
+ catch {
162
+ return false;
163
+ }
164
+ }
@@ -0,0 +1,27 @@
1
+ /** One file-based slash command, shape-compatible with the old sidecar frame. */
2
+ export interface OmpDiskSlashCommand {
3
+ name: string;
4
+ description: string;
5
+ content: string;
6
+ source: string;
7
+ filePath: string;
8
+ }
9
+ /** One discovered skill, shape-compatible with the old sidecar frame. */
10
+ export interface OmpDiskSkill {
11
+ name: string;
12
+ description: string;
13
+ filePath: string;
14
+ baseDir: string;
15
+ source: string;
16
+ }
17
+ /**
18
+ * Read every file-based slash command from the discovery roots.
19
+ * Deterministic output: deduped by name (scan order, first wins), then sorted.
20
+ */
21
+ export declare function readSlashCommands(cwd?: string): OmpDiskSlashCommand[];
22
+ /**
23
+ * Read every discovered skill from the discovery roots: the Agent Skills
24
+ * standard `<root>/<name>/SKILL.md` layout, plus a lenient flat `<root>/*.md`.
25
+ * Deterministic output: deduped by name (scan order, first wins), then sorted.
26
+ */
27
+ export declare function readSkills(cwd?: string): OmpDiskSkill[];