super-dsh 0.1.9 → 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.
- package/README.md +25 -3
- package/agent-agy/cordis.patch.yml +7 -4
- package/agent-agy/dist/agent.d.ts +12 -11
- package/agent-agy/dist/agy-auth-gateway.d.ts +124 -0
- package/agent-agy/dist/agy-auth-gateway.js +233 -0
- package/agent-agy/dist/agy-auth.d.ts +153 -0
- package/agent-agy/dist/agy-auth.js +179 -0
- package/agent-agy/dist/agy-cli-client.d.ts +39 -9
- package/agent-agy/dist/agy-cli-client.js +82 -18
- package/agent-agy/dist/agy-store.d.ts +8 -0
- package/agent-agy/dist/index.d.ts +46 -16
- package/agent-agy/dist/index.js +82 -56
- package/agent-agy/dist/models.d.ts +70 -0
- package/agent-agy/dist/models.js +102 -3
- package/agent-agy/package.json +7 -5
- package/agent-agy-sdk/cordis.patch.yml +58 -0
- package/agent-agy-sdk/dist/adapter.d.ts +15 -0
- package/agent-agy-sdk/dist/adapter.js +42 -0
- package/agent-agy-sdk/dist/agent-preset-agy.d.ts +27 -0
- package/agent-agy-sdk/dist/agent-preset-agy.js +32 -0
- package/agent-agy-sdk/dist/agent.d.ts +138 -0
- package/agent-agy-sdk/dist/agent.js +494 -0
- package/{agent-agy → agent-agy-sdk}/dist/agy-client.d.ts +26 -6
- package/{agent-agy → agent-agy-sdk}/dist/agy-client.js +43 -25
- package/agent-agy-sdk/dist/agy-sessions.d.ts +25 -0
- package/agent-agy-sdk/dist/agy-sessions.js +107 -0
- package/agent-agy-sdk/dist/agy-store.d.ts +39 -0
- package/agent-agy-sdk/dist/agy-store.js +83 -0
- package/agent-agy-sdk/dist/inbox.d.ts +26 -0
- package/agent-agy-sdk/dist/inbox.js +53 -0
- package/agent-agy-sdk/dist/index.d.ts +93 -0
- package/agent-agy-sdk/dist/index.js +476 -0
- package/agent-agy-sdk/dist/models.d.ts +41 -0
- package/agent-agy-sdk/dist/models.js +74 -0
- package/agent-agy-sdk/dist/sdk-venv.d.ts +76 -0
- package/agent-agy-sdk/dist/sdk-venv.js +173 -0
- package/agent-agy-sdk/dist/world-plugin.d.ts +10 -0
- package/agent-agy-sdk/dist/world-plugin.js +82 -0
- package/agent-agy-sdk/package.json +64 -0
- package/agent-codex/README.md +141 -36
- package/agent-codex/cordis.patch.yml +14 -10
- package/agent-codex/dist/adapter.js +64 -28
- package/agent-codex/dist/agent.js +255 -81
- package/agent-codex/dist/app-server-approvals.js +165 -0
- package/agent-codex/dist/app-server-client.js +723 -0
- package/agent-codex/dist/app-server-events.js +432 -0
- package/agent-codex/dist/app-server-protocol.js +95 -0
- package/agent-codex/dist/app-server-wire.js +299 -0
- package/agent-codex/dist/codex-launch.js +78 -0
- package/agent-codex/dist/codex-native-config.js +392 -0
- package/agent-codex/dist/codex-provider-gateway.js +402 -0
- package/agent-codex/dist/codex-providers.js +376 -0
- package/agent-codex/dist/codex-route.js +86 -0
- package/agent-codex/dist/index.js +256 -115
- package/agent-codex/dist/permission.js +75 -1
- package/agent-codex/package.json +1 -2
- package/agent-codex-sdk/README.md +79 -0
- package/agent-codex-sdk/cordis.patch.yml +81 -0
- package/agent-codex-sdk/dist/adapter.js +91 -0
- package/agent-codex-sdk/dist/agent-preset-codex.js +32 -0
- package/agent-codex-sdk/dist/agent.js +1085 -0
- package/agent-codex-sdk/dist/codex-native-config.js +392 -0
- package/agent-codex-sdk/dist/codex-provider-gateway.js +402 -0
- package/agent-codex-sdk/dist/codex-providers.js +376 -0
- package/agent-codex-sdk/dist/codex-route.js +86 -0
- package/{agent-codex/dist/codex-client.js → agent-codex-sdk/dist/codex-sdk-client.js} +253 -32
- package/agent-codex-sdk/dist/codex-sdk-launch.js +92 -0
- package/agent-codex-sdk/dist/codex-store.js +180 -0
- package/agent-codex-sdk/dist/inbox.js +53 -0
- package/agent-codex-sdk/dist/index.js +739 -0
- package/agent-codex-sdk/dist/permission.js +71 -0
- package/agent-codex-sdk/dist/sdk-runtime.js +307 -0
- package/agent-codex-sdk/dist/session-map.js +167 -0
- package/agent-codex-sdk/dist/world-plugin.js +93 -0
- package/agent-codex-sdk/package.json +79 -0
- package/agent-codex-sdk/scripts/fetch-sdk-runtime.mjs +57 -0
- package/agent-omp/README.md +72 -55
- package/agent-omp/dist/agent.js +36 -11
- package/agent-omp/dist/index.js +92 -52
- package/agent-omp/dist/lazy-rpc.js +11 -4
- package/agent-omp/dist/omp-cli.js +114 -97
- package/agent-omp/dist/omp-store.js +12 -4
- package/agent-omp/dist/permission.js +70 -5
- package/agent-omp/dist/rpc-client.js +409 -0
- package/agent-omp/dist/world-plugin.js +36 -3
- package/agent-omp/package.json +2 -6
- package/agent-omp-sdk/README.md +103 -0
- package/agent-omp-sdk/cordis.patch.yml +108 -0
- package/agent-omp-sdk/dist/adapter.d.ts +21 -0
- package/agent-omp-sdk/dist/adapter.js +36 -0
- package/agent-omp-sdk/dist/agent-preset-omp.d.ts +31 -0
- package/agent-omp-sdk/dist/agent-preset-omp.js +32 -0
- package/agent-omp-sdk/dist/agent.d.ts +64 -0
- package/agent-omp-sdk/dist/agent.js +1178 -0
- package/agent-omp-sdk/dist/discovery.d.ts +57 -0
- package/agent-omp-sdk/dist/discovery.js +116 -0
- package/agent-omp-sdk/dist/inbox.d.ts +28 -0
- package/agent-omp-sdk/dist/inbox.js +53 -0
- package/agent-omp-sdk/dist/index.d.ts +60 -0
- package/agent-omp-sdk/dist/index.js +632 -0
- package/agent-omp-sdk/dist/knobs.d.ts +34 -0
- package/agent-omp-sdk/dist/knobs.js +50 -0
- package/agent-omp-sdk/dist/lazy-rpc.d.ts +98 -0
- package/agent-omp-sdk/dist/lazy-rpc.js +178 -0
- package/agent-omp-sdk/dist/mobile/zoom-guard.d.ts +187 -0
- package/agent-omp-sdk/dist/mobile/zoom-guard.js +294 -0
- package/agent-omp-sdk/dist/mobile-boot.d.ts +49 -0
- package/agent-omp-sdk/dist/mobile-boot.js +38 -0
- package/agent-omp-sdk/dist/models.d.ts +39 -0
- package/agent-omp-sdk/dist/models.js +299 -0
- package/agent-omp-sdk/dist/omp-cli.d.ts +67 -0
- package/agent-omp-sdk/dist/omp-cli.js +164 -0
- package/agent-omp-sdk/dist/omp-disk-discovery.d.ts +27 -0
- package/agent-omp-sdk/dist/omp-disk-discovery.js +178 -0
- package/agent-omp-sdk/dist/omp-executable.d.ts +2 -0
- package/agent-omp-sdk/dist/omp-executable.js +30 -0
- package/agent-omp-sdk/dist/omp-store.d.ts +134 -0
- package/agent-omp-sdk/dist/omp-store.js +526 -0
- package/agent-omp-sdk/dist/pairing.d.ts +7 -0
- package/agent-omp-sdk/dist/pairing.js +45 -0
- package/agent-omp-sdk/dist/permission.d.ts +138 -0
- package/agent-omp-sdk/dist/permission.js +161 -0
- package/agent-omp-sdk/dist/protocol.d.ts +189 -0
- package/agent-omp-sdk/dist/rpc-types.d.ts +77 -0
- package/agent-omp-sdk/dist/rpc-types.js +1 -0
- package/agent-omp-sdk/dist/sdk-client.d.ts +160 -0
- package/{agent-omp → agent-omp-sdk}/dist/sdk-client.js +108 -56
- package/agent-omp-sdk/dist/sdk-runtime.d.ts +211 -0
- package/agent-omp-sdk/dist/sdk-runtime.js +418 -0
- package/agent-omp-sdk/dist/sidecar-client.d.ts +87 -0
- package/agent-omp-sdk/dist/sidecar-client.js +197 -0
- package/agent-omp-sdk/dist/store/adapter.d.ts +17 -0
- package/agent-omp-sdk/dist/store/adapter.js +47 -0
- package/agent-omp-sdk/dist/store/db.d.ts +70 -0
- package/agent-omp-sdk/dist/store/db.js +210 -0
- package/agent-omp-sdk/dist/store/index.d.ts +23 -0
- package/agent-omp-sdk/dist/store/index.js +59 -0
- package/agent-omp-sdk/dist/store/reconcile.d.ts +15 -0
- package/agent-omp-sdk/dist/store/reconcile.js +51 -0
- package/agent-omp-sdk/dist/store/schema.d.ts +8 -0
- package/agent-omp-sdk/dist/store/schema.js +40 -0
- package/agent-omp-sdk/dist/transport.d.ts +49 -0
- package/agent-omp-sdk/dist/transport.js +35 -0
- package/agent-omp-sdk/dist/world-home.d.ts +4 -0
- package/agent-omp-sdk/dist/world-home.js +23 -0
- package/agent-omp-sdk/dist/world-plugin.d.ts +10 -0
- package/agent-omp-sdk/dist/world-plugin.js +137 -0
- package/agent-omp-sdk/package.json +87 -0
- package/client/index.js +1115 -93
- package/cordis.patch.yml +64 -0
- package/package.json +17 -7
- package/superd-hub/dist/client/agent-settings.d.ts +156 -0
- package/superd-hub/dist/client/agent-settings.js +229 -0
- package/superd-hub/dist/client/roster.js +6 -0
- package/superd-hub/dist/client/runtime-settings-api.d.ts +76 -0
- package/superd-hub/dist/client/runtime-settings-api.js +137 -0
- package/superd-hub/dist/client/switch.d.ts +165 -0
- package/superd-hub/dist/client/switch.js +295 -0
- package/superd-hub/lib/client/index.js +1115 -93
- package/agent-codex/dist/models.js +0 -152
- package/agent-omp/dist/sidecar-client.js +0 -195
- /package/{agent-agy → agent-agy-sdk}/bridge/agy_bridge.py +0 -0
- /package/{agent-agy → agent-agy-sdk}/bridge/gemini_openai_server.mjs +0 -0
- /package/{agent-codex/dist/codex-events.js → agent-codex-sdk/dist/codex-sdk-events.js} +0 -0
- /package/{agent-omp → agent-omp-sdk}/dist/protocol.js +0 -0
- /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,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;
|