super-dsh 0.1.6 → 0.1.10-e

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 (260) 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-claude/dist/adapter.js +106 -31
  41. package/agent-claude/dist/agent.js +154 -17
  42. package/agent-claude/dist/claude-client.js +84 -43
  43. package/agent-claude/dist/claude-launch.js +101 -0
  44. package/agent-claude/dist/claude-native-config.js +169 -0
  45. package/agent-claude/dist/claude-provider-gateway.js +340 -0
  46. package/agent-claude/dist/claude-providers.js +391 -0
  47. package/agent-claude/dist/claude-route.js +152 -0
  48. package/agent-claude/dist/index.js +214 -37
  49. package/agent-claude/dist/models.js +14 -0
  50. package/agent-claude/dist/sdk-runtime.js +320 -0
  51. package/agent-claude/package.json +6 -4
  52. package/agent-codex/README.md +141 -36
  53. package/agent-codex/cordis.patch.yml +14 -10
  54. package/agent-codex/dist/adapter.js +64 -28
  55. package/agent-codex/dist/agent.js +255 -81
  56. package/agent-codex/dist/app-server-approvals.js +165 -0
  57. package/agent-codex/dist/app-server-client.js +723 -0
  58. package/agent-codex/dist/app-server-events.js +432 -0
  59. package/agent-codex/dist/app-server-protocol.js +95 -0
  60. package/agent-codex/dist/app-server-wire.js +299 -0
  61. package/agent-codex/dist/codex-launch.js +78 -0
  62. package/agent-codex/dist/codex-native-config.js +392 -0
  63. package/agent-codex/dist/codex-provider-gateway.js +402 -0
  64. package/agent-codex/dist/codex-providers.js +376 -0
  65. package/agent-codex/dist/codex-route.js +86 -0
  66. package/agent-codex/dist/index.js +256 -115
  67. package/agent-codex/dist/permission.js +75 -1
  68. package/agent-codex/package.json +1 -2
  69. package/agent-codex-sdk/README.md +79 -0
  70. package/agent-codex-sdk/cordis.patch.yml +81 -0
  71. package/agent-codex-sdk/dist/adapter.js +91 -0
  72. package/agent-codex-sdk/dist/agent-preset-codex.js +32 -0
  73. package/agent-codex-sdk/dist/agent.js +1085 -0
  74. package/agent-codex-sdk/dist/codex-native-config.js +392 -0
  75. package/agent-codex-sdk/dist/codex-provider-gateway.js +402 -0
  76. package/agent-codex-sdk/dist/codex-providers.js +376 -0
  77. package/agent-codex-sdk/dist/codex-route.js +86 -0
  78. package/{agent-codex/dist/codex-client.js → agent-codex-sdk/dist/codex-sdk-client.js} +253 -32
  79. package/agent-codex-sdk/dist/codex-sdk-launch.js +92 -0
  80. package/agent-codex-sdk/dist/codex-store.js +180 -0
  81. package/agent-codex-sdk/dist/inbox.js +53 -0
  82. package/agent-codex-sdk/dist/index.js +739 -0
  83. package/agent-codex-sdk/dist/permission.js +71 -0
  84. package/agent-codex-sdk/dist/sdk-runtime.js +307 -0
  85. package/agent-codex-sdk/dist/session-map.js +167 -0
  86. package/agent-codex-sdk/dist/world-plugin.js +93 -0
  87. package/agent-codex-sdk/package.json +79 -0
  88. package/agent-codex-sdk/scripts/fetch-sdk-runtime.mjs +57 -0
  89. package/agent-omp/README.md +72 -55
  90. package/agent-omp/dist/agent.js +36 -11
  91. package/agent-omp/dist/index.js +92 -52
  92. package/agent-omp/dist/lazy-rpc.js +11 -4
  93. package/agent-omp/dist/omp-cli.js +114 -97
  94. package/agent-omp/dist/omp-store.js +12 -4
  95. package/agent-omp/dist/permission.js +70 -5
  96. package/agent-omp/dist/rpc-client.js +409 -0
  97. package/agent-omp/dist/world-plugin.js +36 -3
  98. package/agent-omp/package.json +2 -6
  99. package/agent-omp-sdk/README.md +103 -0
  100. package/agent-omp-sdk/cordis.patch.yml +108 -0
  101. package/agent-omp-sdk/dist/adapter.d.ts +21 -0
  102. package/agent-omp-sdk/dist/adapter.js +36 -0
  103. package/agent-omp-sdk/dist/agent-preset-omp.d.ts +31 -0
  104. package/agent-omp-sdk/dist/agent-preset-omp.js +32 -0
  105. package/agent-omp-sdk/dist/agent.d.ts +64 -0
  106. package/agent-omp-sdk/dist/agent.js +1178 -0
  107. package/agent-omp-sdk/dist/discovery.d.ts +57 -0
  108. package/agent-omp-sdk/dist/discovery.js +116 -0
  109. package/agent-omp-sdk/dist/inbox.d.ts +28 -0
  110. package/agent-omp-sdk/dist/inbox.js +53 -0
  111. package/agent-omp-sdk/dist/index.d.ts +60 -0
  112. package/agent-omp-sdk/dist/index.js +632 -0
  113. package/agent-omp-sdk/dist/knobs.d.ts +34 -0
  114. package/agent-omp-sdk/dist/knobs.js +50 -0
  115. package/agent-omp-sdk/dist/lazy-rpc.d.ts +98 -0
  116. package/agent-omp-sdk/dist/lazy-rpc.js +178 -0
  117. package/agent-omp-sdk/dist/mobile/zoom-guard.d.ts +187 -0
  118. package/agent-omp-sdk/dist/mobile/zoom-guard.js +294 -0
  119. package/agent-omp-sdk/dist/mobile-boot.d.ts +49 -0
  120. package/agent-omp-sdk/dist/mobile-boot.js +38 -0
  121. package/agent-omp-sdk/dist/models.d.ts +39 -0
  122. package/agent-omp-sdk/dist/models.js +299 -0
  123. package/agent-omp-sdk/dist/omp-cli.d.ts +67 -0
  124. package/agent-omp-sdk/dist/omp-cli.js +164 -0
  125. package/agent-omp-sdk/dist/omp-disk-discovery.d.ts +27 -0
  126. package/agent-omp-sdk/dist/omp-disk-discovery.js +178 -0
  127. package/agent-omp-sdk/dist/omp-executable.d.ts +2 -0
  128. package/agent-omp-sdk/dist/omp-executable.js +30 -0
  129. package/agent-omp-sdk/dist/omp-store.d.ts +134 -0
  130. package/agent-omp-sdk/dist/omp-store.js +526 -0
  131. package/agent-omp-sdk/dist/pairing.d.ts +7 -0
  132. package/agent-omp-sdk/dist/pairing.js +45 -0
  133. package/agent-omp-sdk/dist/permission.d.ts +138 -0
  134. package/agent-omp-sdk/dist/permission.js +161 -0
  135. package/agent-omp-sdk/dist/protocol.d.ts +189 -0
  136. package/agent-omp-sdk/dist/rpc-types.d.ts +77 -0
  137. package/agent-omp-sdk/dist/rpc-types.js +1 -0
  138. package/agent-omp-sdk/dist/sdk-client.d.ts +160 -0
  139. package/{agent-omp → agent-omp-sdk}/dist/sdk-client.js +108 -56
  140. package/agent-omp-sdk/dist/sdk-runtime.d.ts +211 -0
  141. package/agent-omp-sdk/dist/sdk-runtime.js +418 -0
  142. package/agent-omp-sdk/dist/sidecar-client.d.ts +87 -0
  143. package/agent-omp-sdk/dist/sidecar-client.js +197 -0
  144. package/agent-omp-sdk/dist/store/adapter.d.ts +17 -0
  145. package/agent-omp-sdk/dist/store/adapter.js +47 -0
  146. package/agent-omp-sdk/dist/store/db.d.ts +70 -0
  147. package/agent-omp-sdk/dist/store/db.js +210 -0
  148. package/agent-omp-sdk/dist/store/index.d.ts +23 -0
  149. package/agent-omp-sdk/dist/store/index.js +59 -0
  150. package/agent-omp-sdk/dist/store/reconcile.d.ts +15 -0
  151. package/agent-omp-sdk/dist/store/reconcile.js +51 -0
  152. package/agent-omp-sdk/dist/store/schema.d.ts +8 -0
  153. package/agent-omp-sdk/dist/store/schema.js +40 -0
  154. package/agent-omp-sdk/dist/transport.d.ts +49 -0
  155. package/agent-omp-sdk/dist/transport.js +35 -0
  156. package/agent-omp-sdk/dist/world-home.d.ts +4 -0
  157. package/agent-omp-sdk/dist/world-home.js +23 -0
  158. package/agent-omp-sdk/dist/world-plugin.d.ts +10 -0
  159. package/agent-omp-sdk/dist/world-plugin.js +137 -0
  160. package/agent-omp-sdk/package.json +87 -0
  161. package/client/index.js +1883 -287
  162. package/cordis.patch.yml +80 -0
  163. package/package.json +23 -9
  164. package/superd-hub/dist/a2a-delivery.d.ts +189 -0
  165. package/superd-hub/dist/a2a-delivery.js +240 -0
  166. package/superd-hub/dist/a2a-host.d.ts +76 -0
  167. package/superd-hub/dist/a2a-host.js +145 -0
  168. package/superd-hub/dist/a2a-ingest.d.ts +31 -0
  169. package/superd-hub/dist/a2a-ingest.js +636 -0
  170. package/superd-hub/dist/a2a-log.d.ts +17 -0
  171. package/superd-hub/dist/a2a-log.js +42 -0
  172. package/superd-hub/dist/a2a-row.d.ts +65 -0
  173. package/superd-hub/dist/a2a-row.js +162 -0
  174. package/superd-hub/dist/a2a-service.d.ts +357 -0
  175. package/superd-hub/dist/a2a-service.js +980 -0
  176. package/superd-hub/dist/a2a-wire.d.ts +220 -0
  177. package/superd-hub/dist/a2a-wire.js +305 -0
  178. package/superd-hub/dist/agent-ids.d.ts +10 -0
  179. package/superd-hub/dist/agent-ids.js +68 -0
  180. package/superd-hub/dist/agent-roster.d.ts +29 -18
  181. package/superd-hub/dist/agent-roster.js +54 -15
  182. package/superd-hub/dist/agent-status.d.ts +119 -0
  183. package/superd-hub/dist/agent-status.js +386 -0
  184. package/superd-hub/dist/client/agent-settings.d.ts +210 -0
  185. package/superd-hub/dist/client/agent-settings.js +300 -0
  186. package/superd-hub/dist/client/mesh-api.d.ts +134 -0
  187. package/superd-hub/dist/client/mesh-api.js +219 -0
  188. package/superd-hub/dist/client/mesh-groups.d.ts +63 -0
  189. package/superd-hub/dist/client/mesh-groups.js +66 -0
  190. package/superd-hub/dist/client/roster.d.ts +48 -0
  191. package/superd-hub/dist/client/roster.js +102 -0
  192. package/superd-hub/dist/client/runtime-settings-api.d.ts +76 -0
  193. package/superd-hub/dist/client/runtime-settings-api.js +137 -0
  194. package/superd-hub/dist/client/switch.d.ts +165 -0
  195. package/superd-hub/dist/client/switch.js +295 -0
  196. package/superd-hub/dist/exec-pty-channel.d.ts +58 -0
  197. package/superd-hub/dist/exec-pty-channel.js +162 -0
  198. package/superd-hub/dist/exec-pty-framing.d.ts +32 -0
  199. package/superd-hub/dist/exec-pty-framing.js +81 -0
  200. package/superd-hub/dist/exec-pty-rpc.d.ts +21 -0
  201. package/superd-hub/dist/exec-pty-rpc.js +128 -0
  202. package/superd-hub/dist/exec-pty-session.d.ts +76 -0
  203. package/superd-hub/dist/exec-pty-session.js +234 -0
  204. package/superd-hub/dist/exec.d.ts +56 -0
  205. package/superd-hub/dist/exec.js +225 -0
  206. package/superd-hub/dist/gateway.d.ts +39 -2
  207. package/superd-hub/dist/gateway.js +62 -3
  208. package/superd-hub/dist/hub-tool.d.ts +174 -0
  209. package/superd-hub/dist/hub-tool.js +464 -0
  210. package/superd-hub/dist/index.d.ts +15 -1
  211. package/superd-hub/dist/index.js +16 -0
  212. package/superd-hub/dist/machines.d.ts +45 -0
  213. package/superd-hub/dist/machines.js +125 -0
  214. package/superd-hub/dist/mesh-federate.d.ts +138 -0
  215. package/superd-hub/dist/mesh-federate.js +223 -0
  216. package/superd-hub/dist/mesh-gateway.d.ts +67 -0
  217. package/superd-hub/dist/mesh-gateway.js +408 -0
  218. package/superd-hub/dist/mesh-link.d.ts +274 -0
  219. package/superd-hub/dist/mesh-link.js +441 -0
  220. package/superd-hub/dist/mesh-rpc.d.ts +123 -0
  221. package/superd-hub/dist/mesh-rpc.js +250 -0
  222. package/superd-hub/dist/mux-client.d.ts +71 -0
  223. package/superd-hub/dist/mux-client.js +281 -0
  224. package/superd-hub/dist/pack-version.d.ts +2 -0
  225. package/superd-hub/dist/pack-version.js +30 -0
  226. package/superd-hub/dist/roster.d.ts +6 -0
  227. package/superd-hub/dist/rpc.d.ts +18 -2
  228. package/superd-hub/dist/rpc.js +34 -4
  229. package/superd-hub/dist/spawn-world.js +3 -1
  230. package/superd-hub/dist/switch-core.d.ts +62 -25
  231. package/superd-hub/dist/switch-core.js +53 -30
  232. package/superd-hub/dist/system-head.d.ts +22 -12
  233. package/superd-hub/dist/system-head.js +100 -84
  234. package/superd-hub/dist/wire-endpoints.d.ts +264 -0
  235. package/superd-hub/dist/wire-endpoints.js +180 -0
  236. package/superd-hub/lib/client/index.js +1883 -287
  237. package/superd-hub/package.json +11 -2
  238. package/agent-agy/dist/agent-preset-projection.d.ts +0 -31
  239. package/agent-agy/dist/agent-preset-projection.js +0 -33
  240. package/agent-claude/dist/agent-preset-projection.js +0 -30
  241. package/agent-codex/dist/agent-preset-projection.js +0 -37
  242. package/agent-codex/dist/app-home.js +0 -65
  243. package/agent-codex/dist/models.js +0 -152
  244. package/agent-codex/dist/spike.js +0 -46
  245. package/agent-hermes/dist/agent-preset-projection.js +0 -34
  246. package/agent-omp/dist/agent-preset-projection.js +0 -36
  247. package/agent-omp/dist/app-home.js +0 -86
  248. package/agent-omp/dist/sidecar-client.js +0 -195
  249. package/agent-pi/dist/agent-preset-projection.js +0 -29
  250. package/superd-hub/dist/client-shim.d.ts +0 -28
  251. package/superd-hub/dist/client-shim.js +0 -251
  252. package/superd-hub/dist/index-pass.d.ts +0 -22
  253. package/superd-hub/dist/index-pass.js +0 -47
  254. package/superd-hub/dist/labels.d.ts +0 -45
  255. package/superd-hub/dist/labels.js +0 -83
  256. /package/{agent-agy → agent-agy-sdk}/bridge/agy_bridge.py +0 -0
  257. /package/{agent-agy → agent-agy-sdk}/bridge/gemini_openai_server.mjs +0 -0
  258. /package/{agent-codex/dist/codex-events.js → agent-codex-sdk/dist/codex-sdk-events.js} +0 -0
  259. /package/{agent-omp → agent-omp-sdk}/dist/protocol.js +0 -0
  260. /package/{agent-omp → agent-omp-sdk}/sidecar/main.ts +0 -0
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Host-side disk readers for OMP slash commands and skills.
3
+ *
4
+ * Replaces the sidecar round-trips (`slashCommands.list` / `skills.list`) that
5
+ * used to spawn the whole bun/OMP core just to walk a few directories. The
6
+ * upstream discovery (pi-coding-agent src/discovery/*) is a 10+ provider
7
+ * capability web we deliberately do NOT port; v1 scans the practical roots:
8
+ *
9
+ * commands: <OMP_NATIVE_HOME>/agent/commands/*.md (native user)
10
+ * <cwd>/.omp/commands/*.md (native project)
11
+ * ~/.claude/commands/*.md (claude user)
12
+ * <cwd>/.claude/commands/*.md (claude project)
13
+ * skills: the same four roots' `skills/` sibling, each entry either
14
+ * `<root>/<name>/SKILL.md` (Agent Skills standard) or a lenient
15
+ * flat `<root>/*.md`.
16
+ *
17
+ * Known divergences from the SDK path (accepted, see plan §3): no embedded
18
+ * bundled commands, no codex/opencode/cursor/gemini providers, no capability
19
+ * semantics (at-imports, managed skills, extensionRoots reload). Dedupe order
20
+ * is scan order with FIRST occurrence winning: omp user → claude user →
21
+ * omp project → claude project. All readers are fail-soft: missing roots or
22
+ * unreadable files are skipped, never thrown.
23
+ *
24
+ * @module agent-omp/omp-disk-discovery
25
+ */
26
+ import { existsSync, readdirSync, readFileSync } from "node:fs";
27
+ import { homedir } from "node:os";
28
+ import { join } from "node:path";
29
+ import { resolveOmpNativeHome } from "./knobs.js";
30
+ function discoveryRoots(cwd, kind) {
31
+ const home = homedir();
32
+ const roots = [
33
+ { base: resolveOmpNativeHome(), subdir: join("agent", kind), label: `omp:user` },
34
+ { base: home, subdir: join(".claude", kind), label: `claude:user` },
35
+ ];
36
+ if (cwd !== undefined && cwd !== "") {
37
+ roots.push({ base: cwd, subdir: join(".omp", kind), label: `omp:project` }, { base: cwd, subdir: join(".claude", kind), label: `claude:project` });
38
+ }
39
+ return roots;
40
+ }
41
+ /**
42
+ * Split an optional YAML-ish frontmatter from a markdown body and derive the
43
+ * display description the way the SDK's parseCommandTemplate does: the
44
+ * frontmatter `description` when present, else the first non-empty body line
45
+ * trimmed to 60 chars. Unknown keys are ignored; a malformed block degrades to
46
+ * "whole file is body".
47
+ */
48
+ function parseMarkdownTemplate(raw) {
49
+ const text = raw.replace(/\r\n/g, "\n");
50
+ if (!text.startsWith("---\n")) {
51
+ return { description: fallbackDescription(text), content: text };
52
+ }
53
+ const end = text.indexOf("\n---", 4);
54
+ if (end === -1) {
55
+ return { description: fallbackDescription(text), content: text };
56
+ }
57
+ const frontmatter = text.slice(4, end);
58
+ const bodyStart = text.indexOf("\n", end + 1);
59
+ const body = bodyStart === -1 ? "" : text.slice(bodyStart + 1).replace(/^\n+/, "");
60
+ let description;
61
+ for (const line of frontmatter.split("\n")) {
62
+ const match = /^(description|argument-hint):\s*(.*)$/.exec(line);
63
+ if (match !== null && match[2] !== "") {
64
+ description = match[2].trim().replace(/^["']|["']$/g, "");
65
+ break;
66
+ }
67
+ }
68
+ return { description: description ?? fallbackDescription(body), content: body };
69
+ }
70
+ function fallbackDescription(body) {
71
+ const line = body.split("\n").find((candidate) => candidate.trim() !== "") ?? "";
72
+ return line.trim().slice(0, 60);
73
+ }
74
+ function listMarkdownFiles(dir) {
75
+ try {
76
+ return readdirSync(dir, { withFileTypes: true })
77
+ .filter((entry) => entry.isFile() && entry.name.toLowerCase().endsWith(".md"))
78
+ .map((entry) => entry.name)
79
+ .sort();
80
+ }
81
+ catch {
82
+ return [];
83
+ }
84
+ }
85
+ function readFileSoft(path) {
86
+ try {
87
+ return readFileSync(path, "utf8");
88
+ }
89
+ catch {
90
+ return undefined;
91
+ }
92
+ }
93
+ /**
94
+ * Read every file-based slash command from the discovery roots.
95
+ * Deterministic output: deduped by name (scan order, first wins), then sorted.
96
+ */
97
+ export function readSlashCommands(cwd) {
98
+ const byName = new Map();
99
+ for (const root of discoveryRoots(cwd, "commands")) {
100
+ const dir = join(root.base, root.subdir);
101
+ for (const file of listMarkdownFiles(dir)) {
102
+ const name = file.replace(/\.md$/i, "");
103
+ if (name === "" || byName.has(name))
104
+ continue;
105
+ const raw = readFileSoft(join(dir, file));
106
+ if (raw === undefined)
107
+ continue;
108
+ const parsed = parseMarkdownTemplate(raw);
109
+ byName.set(name, {
110
+ name,
111
+ description: parsed.description,
112
+ content: parsed.content,
113
+ source: root.label,
114
+ filePath: join(dir, file),
115
+ });
116
+ }
117
+ }
118
+ return [...byName.values()].sort((left, right) => left.name.localeCompare(right.name));
119
+ }
120
+ function readSkillFile(path, label) {
121
+ const raw = readFileSoft(path);
122
+ if (raw === undefined)
123
+ return undefined;
124
+ const parsed = parseMarkdownTemplate(raw);
125
+ // Frontmatter `name:` may rename the skill; default to the directory/file name.
126
+ let name = "";
127
+ const frontmatterName = /^---\n[\s\S]*?^name:\s*(\S+)/m.exec(raw);
128
+ if (frontmatterName !== null)
129
+ name = frontmatterName[1];
130
+ if (name === "") {
131
+ const base = path.split("/").pop() ?? "";
132
+ name = base.toLowerCase() === "skill.md" ? (path.split("/").at(-2) ?? base) : base.replace(/\.md$/i, "");
133
+ }
134
+ return {
135
+ name,
136
+ description: parsed.description,
137
+ filePath: path,
138
+ baseDir: path.slice(0, path.lastIndexOf("/")) || path,
139
+ source: label,
140
+ };
141
+ }
142
+ /**
143
+ * Read every discovered skill from the discovery roots: the Agent Skills
144
+ * standard `<root>/<name>/SKILL.md` layout, plus a lenient flat `<root>/*.md`.
145
+ * Deterministic output: deduped by name (scan order, first wins), then sorted.
146
+ */
147
+ export function readSkills(cwd) {
148
+ const byName = new Map();
149
+ for (const root of discoveryRoots(cwd, "skills")) {
150
+ const dir = join(root.base, root.subdir);
151
+ if (!existsSync(dir))
152
+ continue;
153
+ let entries = [];
154
+ try {
155
+ entries = readdirSync(dir, { withFileTypes: true }).map((entry) => ({
156
+ name: entry.name,
157
+ isDirectory: entry.isDirectory(),
158
+ }));
159
+ }
160
+ catch {
161
+ continue;
162
+ }
163
+ for (const entry of entries) {
164
+ const path = entry.isDirectory
165
+ ? join(dir, entry.name, "SKILL.md")
166
+ : join(dir, entry.name);
167
+ if (!entry.isDirectory && !entry.name.toLowerCase().endsWith(".md"))
168
+ continue;
169
+ if (entry.isDirectory && byName.has(entry.name))
170
+ continue;
171
+ const skill = readSkillFile(path, root.label);
172
+ if (skill === undefined || byName.has(skill.name))
173
+ continue;
174
+ byName.set(skill.name, skill);
175
+ }
176
+ }
177
+ return [...byName.values()].sort((left, right) => left.name.localeCompare(right.name));
178
+ }
@@ -0,0 +1,2 @@
1
+ /** `$OMP_EXECUTABLE` wins; else PATH, else the common native-installer spots. */
2
+ export declare function resolveOmpExecutable(): string;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Locate the operator's `omp` binary — the ONE resolution order the adapter's
3
+ * data plane (`omp-cli.ts`) uses.
4
+ *
5
+ * The SDK line does NOT need this to run its sessions (those live in the
6
+ * fetched bun sidecar), but the model catalog and the `modelRoles` bridge are
7
+ * read through the operator's own binary so the two OMP faces agree on config.
8
+ *
9
+ * Ported verbatim from the RPC line (`@pgmi-builds/agent-omp`, rpc-client.ts):
10
+ * a local copy keeps this package standalone — the task ruling is a complete
11
+ * standalone copy, not a shared-code sibling.
12
+ */
13
+ import { existsSync } from "node:fs";
14
+ import { homedir } from "node:os";
15
+ import { join } from "node:path";
16
+ /** `$OMP_EXECUTABLE` wins; else PATH, else the common native-installer spots. */
17
+ export function resolveOmpExecutable() {
18
+ const configured = process.env.OMP_EXECUTABLE?.trim();
19
+ if (configured !== undefined && configured !== "")
20
+ return configured;
21
+ for (const dir of (process.env.PATH ?? "").split(":").filter(Boolean)) {
22
+ if (existsSync(join(dir, "omp")))
23
+ return "omp";
24
+ }
25
+ for (const candidate of [join(homedir(), ".local/bin/omp"), "/usr/local/bin/omp"]) {
26
+ if (existsSync(candidate))
27
+ return candidate;
28
+ }
29
+ return "omp";
30
+ }
@@ -0,0 +1,134 @@
1
+ import type { OmpMessage } from "./rpc-types.js";
2
+ /** One OMP-native session discovered by {@link scanOmpSessions}. */
3
+ export interface OmpNativeSession {
4
+ /** OMP's session id (the `session` header record's `id`). */
5
+ readonly ompSessionId: string;
6
+ /** Absolute path to the OMP session file (the transcript of record). */
7
+ readonly ompSessionFile: string;
8
+ /** Working directory recorded in the session header, if any. */
9
+ readonly cwd?: string;
10
+ /** Creation epoch ms (session header `timestamp`, filename fallback). */
11
+ readonly createdAt: number;
12
+ /** Display title: the title record, else the first user message, else absent. */
13
+ readonly title?: string;
14
+ /** Transcript byte size (reconcile change detection). */
15
+ readonly size: number;
16
+ /** Transcript mtime, epoch ms (reconcile change detection + default sort). */
17
+ readonly mtimeMs: number;
18
+ /** Opaque change token (stat-derived), for persistence snapshot revisions. */
19
+ readonly revision: string;
20
+ }
21
+ /** Root of OMP's native session store. */
22
+ export declare const OMP_SESSIONS_ROOT: string;
23
+ /** One OMP `model_change` entry from a session transcript. */
24
+ export interface OmpModelChange {
25
+ /** `provider/model` selector string. */
26
+ readonly model: string;
27
+ /** The role this change records (absent on the initial restore). */
28
+ readonly role?: string;
29
+ }
30
+ /** The two record families cold replay needs from one transcript read. */
31
+ export interface OmpTranscript {
32
+ messages: OmpMessage[];
33
+ modelChanges: OmpModelChange[];
34
+ }
35
+ /**
36
+ * Read one OMP session transcript in a single pass, extracting both the
37
+ * `message` records and the `model_change` records.
38
+ */
39
+ export declare function readOmpTranscript(path: string): OmpTranscript;
40
+ /**
41
+ * Legacy fallback: the last assistant message that names a provider/model
42
+ * pair. Used only for transcripts without any `model_change` record; newer
43
+ * sessions derive their resume model from {@link lastRestorableModel}.
44
+ */
45
+ export declare function lastModelCall(messages: OmpMessage[]): {
46
+ provider: string;
47
+ model: string;
48
+ } | undefined;
49
+ /** Split a `provider/model[:variant]` selector into provider/model, dropping the variant suffix. */
50
+ export declare function parseSelector(selector: string | undefined): {
51
+ provider: string;
52
+ model: string;
53
+ } | undefined;
54
+ /**
55
+ * The model OMP restores on `--resume`: the last non-fallback `model_change`.
56
+ * Mirrors OMP's `getRestorableSessionModels` (`session-context.ts`): a
57
+ * fallback switch is recorded under `role:"fallback"` (EPHEMERAL) and never
58
+ * restores — the last such switch falls back to the role's primary.
59
+ */
60
+ export declare function lastRestorableModel(modelChanges: OmpModelChange[]): {
61
+ provider: string;
62
+ model: string;
63
+ } | undefined;
64
+ /**
65
+ * Read the whole `modelRoles` map (role → "provider/model[:effort]") from
66
+ * OMP's config.yml. Returns undefined when the block is absent/empty or the
67
+ * file is unreadable. A deliberately minimal YAML scan — the bridge has no
68
+ * YAML dependency; one indent level of `key: value` lines inside the block.
69
+ */
70
+ export declare function readOmpModelRolesFromConfig(): Record<string, string> | undefined;
71
+ /**
72
+ * Read the configured default role model (`modelRoles.default`) from OMP's
73
+ * config.yml. Returns the provider/model pair (variant suffix dropped), or
74
+ * undefined when unset or unreadable. Delegates to the whole-map reader.
75
+ */
76
+ export declare function readOmpDefaultModelFromConfig(): {
77
+ provider: string;
78
+ model: string;
79
+ } | undefined;
80
+ /**
81
+ * Derive the working directory a session ran in from its location in OMP's
82
+ * store: the parent directory name is the cwd with every "/" flattened to
83
+ * "-" (leading "/" → leading "-"). Literal dashes in path segments are
84
+ * ambiguous, so segments are re-joined greedily longest-first against the
85
+ * filesystem and the candidate is accepted only as an existing directory
86
+ * (realpath'd). This is the trusted resume cwd — the omp-sessions.json
87
+ * mapping's verbatim `cwd` is user-writable and never consulted.
88
+ */
89
+ export declare function cwdFromSessionFile(path: string): string | undefined;
90
+ /** Read one session file's header id (the `session` record's `id`), no full scan. */
91
+ export declare function sessionHeaderId(path: string): string | undefined;
92
+ /**
93
+
94
+ /**
95
+ * Scan OMP's native store (PURE DISK — sidecar-free). Returns sessions keyed
96
+ * by OMP session id; files without a parsable `session` header record are
97
+ * skipped (corrupt/foreign).
98
+ *
99
+ * The FILE LIST always comes from a fresh directory walk; per-session metadata
100
+ * (id/cwd/title/createdAt) comes from the self-written {@link scanHead},
101
+ * memoized by size+mtime in `entryCache`. The old SDK `sessions.listAll` fast
102
+ * path is GONE (sidecar-decoupling): the only consumer left is pairing.ts's
103
+ * store-absent fallback (unit tests).
104
+ */
105
+ export declare function scanOmpSessions(): Map<string, OmpNativeSession>;
106
+ /**
107
+ * One /proc pass over every foreign process's write-mode file descriptors,
108
+ * returning `canonical path → first foreign writer pid`. Shared by every
109
+ * session in one tick so the daemon never re-scans /proc per file.
110
+ *
111
+ * OMP has no session-level exclusivity: neither the TUI nor `--mode rpc`
112
+ * locks its transcript, so two live writers interleave appends silently
113
+ * (verified: a TUI `omp` and a bridge `omp --mode rpc --resume` coexisted on
114
+ * one file with plain `w` descriptors and no advisory locks). The intended
115
+ * enforcement is to refuse resuming a transcript another process already writes
116
+ * (the TUI case), closing the split-brain at the only layer that can see it —
117
+ * but see {@link foreignWriterPid}: that hold is NOT wired in this round.
118
+ * Own descendants (a just-torn-down bridge child whose fds linger) are
119
+ * exempt to keep teardown races from wedging re-resume.
120
+ */
121
+ export declare function scanForeignWriters(): Map<string, number>;
122
+ /**
123
+ * Pid of a FOREIGN process holding `file` open for writing, if any.
124
+ * Convenience wrapper over {@link scanForeignWriters} for the single-file
125
+ * resume gate.
126
+ *
127
+ * UNWIRED (2026-10-03): this helper has no caller — the `resume` path never
128
+ * invokes it, so nothing currently refuses a transcript another process (the
129
+ * TUI) is writing. Spec §3.4 of `docs/specs/omp-rpc-transport/spec.md`
130
+ * registers that accepted exposure and the planned follow-up: a fail-loud
131
+ * `foreignWriterPid(<sessionFile>)` check wired into `resume`, to be decided
132
+ * by the operator. Helper kept exported for that follow-up.
133
+ */
134
+ export declare function foreignWriterPid(file: string): number | undefined;