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,138 @@
1
+ import type { Context } from "@deepseek-ai/cordis";
2
+ import type { Session, SessionEvent } from "@deepseek-ai/dsh-session";
3
+ /** The Dash preset table (mirrors the base bundle's permission plugin config). */
4
+ declare const PRESETS: {
5
+ readonly "danger-full-access": {
6
+ readonly sandbox: "danger-full-access";
7
+ readonly approval: "never";
8
+ readonly ompMode: "yolo";
9
+ };
10
+ readonly "workspace-write": {
11
+ readonly sandbox: "workspace-write";
12
+ readonly approval: "ask";
13
+ readonly ompMode: "write";
14
+ };
15
+ readonly "read-only": {
16
+ readonly sandbox: "read-only";
17
+ readonly approval: "ask";
18
+ readonly ompMode: "always-ask";
19
+ };
20
+ };
21
+ /**
22
+ * The two permission event keys this module reads/synthesizes that the
23
+ * locally-resolved dsh-session build does not know (upstream declares them
24
+ * in dsh-permission-presets / dsh-sandbox-policy, whose types this project
25
+ * does not reference). Mirrored verbatim so `SessionEvent` narrows.
26
+ */
27
+ declare module "@deepseek-ai/dsh-session/types" {
28
+ interface SessionEventMap {
29
+ "permission/preset": {
30
+ preset: string;
31
+ };
32
+ "sandbox/mode": {
33
+ mode: "read-only" | "workspace-write" | "danger-full-access";
34
+ source?: "delegation";
35
+ };
36
+ }
37
+ }
38
+ type PresetName = keyof typeof PRESETS;
39
+ /** Narrow an untrusted value to a known preset name. */
40
+ export declare function isPresetName(raw: unknown): raw is PresetName;
41
+ /**
42
+ * `OMP_APPROVAL_MODE` when it names a mode OMP implements, else undefined.
43
+ * An invalid value is IGNORED (the preset mapping applies) — the old
44
+ * fall-back-to-`write` behavior silently downgraded from OMP's native yolo.
45
+ */
46
+ export declare function envApprovalMode(): string | undefined;
47
+ /** Map a preset onto OMP's `--approval-mode` flag value; no preset → yolo. */
48
+ export declare function ompApprovalMode(preset: string | undefined): string;
49
+ /**
50
+ * The default preset for FUTURE sessions, as the permission service
51
+ * resolves it (settings-backed; the profile patch pins the base default).
52
+ * Undefined when the service is absent or its getter fails — callers fall
53
+ * back to OMP's native default.
54
+ */
55
+ export declare function defaultPermissionPreset(ctx: Context): string | undefined;
56
+ /** The session's effective preset: the last `permission/preset` event. */
57
+ export declare function presetFromEvents(events: readonly SessionEvent[]): string | undefined;
58
+ /**
59
+ * Resolve a spawn's `--approval-mode` (and the preset to record for it) from
60
+ * the session's OWN log, evaluated at the moment the child materializes.
61
+ *
62
+ * Order of authority: the last valid `permission/preset` (= the user's pick in
63
+ * the new chat, or the draft's `pinInitialPermission` stamp) → `fallbackPreset`
64
+ * (the composition default for a create, the bridge-index row for a resume of a
65
+ * log that predates the event) → OMP's native default (`yolo`). An
66
+ * `OMP_APPROVAL_MODE` env override (headless runs) still wins over all of them.
67
+ *
68
+ * @param events - the live session's events (never a stale create-time read).
69
+ * @param fallbackPreset - used only when the log carries no valid preset.
70
+ * @param envMode - `envApprovalMode()`; undefined when unset or invalid.
71
+ * @returns the launch flag value plus the preset that produced it.
72
+ */
73
+ export declare function resolveSpawnPermission(events: readonly SessionEvent[], fallbackPreset: string | undefined, envMode: string | undefined): {
74
+ approvalMode: string;
75
+ preset: string | undefined;
76
+ };
77
+ /**
78
+ * The write slice of `ctx.permissionPresets` the `/permission` command mirrors:
79
+ * `names`/`current` for the settled answers, `set` for the durable write (the
80
+ * same public call the webhook plugin uses to pin a session's initial preset —
81
+ * it appends `permission/preset` + the knob events and touches no live agent).
82
+ */
83
+ export interface PermissionPresetsWriteSlice {
84
+ readonly names: readonly string[];
85
+ current(session: Session): string;
86
+ set(session: Session, name: string): void;
87
+ }
88
+ /** One `/permission` outcome, shaped exactly as `dsh-commands` expects. */
89
+ export interface PermissionCommandOutcome {
90
+ kind: "success" | "error";
91
+ text: string;
92
+ }
93
+ /**
94
+ * What the adapter's `/permission` shadow must do: `apply` writes the preset to
95
+ * the session (the caller then returns `result`), `settled` returns it as-is.
96
+ */
97
+ export type OmpPermissionDecision = {
98
+ action: "apply";
99
+ preset: string;
100
+ result: PermissionCommandOutcome;
101
+ } | {
102
+ action: "settled";
103
+ result: PermissionCommandOutcome;
104
+ };
105
+ /**
106
+ * Decide a `/permission` invocation for one OMP session.
107
+ *
108
+ * A permission pick can only become real at the child's launch, so the shadow
109
+ * accepts it exactly while no child exists (the new-chat draft, or a resumed
110
+ * session before its first prompt) and refuses it afterwards — appending a
111
+ * preset the running `omp` cannot honor would make the UI lie about the
112
+ * session's effective policy.
113
+ *
114
+ * @param input.rawInput - the preset name as typed (may be empty or padded).
115
+ * @param input.spawned - whether THIS session's `omp --mode rpc` child exists.
116
+ * @param input.names - the host's advertised preset names.
117
+ * @param input.current - the session's current preset (for the bare command).
118
+ * @returns the decision; the caller performs the write for `apply`.
119
+ */
120
+ export declare function ompPermissionCommand(input: {
121
+ rawInput: string;
122
+ spawned: boolean;
123
+ names: readonly string[];
124
+ current: string;
125
+ }): OmpPermissionDecision;
126
+ /**
127
+ * The three Dash events `pinInitialPermission` stamps for a fresh session,
128
+ * in its append order (preset, sandbox, approval). Cold replay prepends
129
+ * them so the UI shows the session's permission after wrapper restarts.
130
+ */
131
+ export declare function permissionEventsFor(preset: PresetName, time: number): SessionEvent[];
132
+ /**
133
+ * The bridge's legacy per-session artifact path (the migration reads this to
134
+ * import the old `dashSessionId` / `permissionPreset` once). Kept read-only;
135
+ * nothing writes it after the migration.
136
+ */
137
+ export declare function webuiArtifactPath(sessionFile: string): string;
138
+ export {};
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Dash permission preset ↔ OMP approval mode.
3
+ *
4
+ * OMP has no runtime approval control: `--approval-mode` is a launch flag, no
5
+ * RPC changes it mid-session. Dash's 3-way permission preset is therefore
6
+ * resolved ONCE, at the spawn of that session's `omp --mode rpc` child, and
7
+ * mapped explicitly:
8
+ *
9
+ * danger-full-access → `--approval-mode yolo` (OMP's own native default)
10
+ * workspace-write → `--approval-mode write`
11
+ * read-only → `--approval-mode always-ask`
12
+ * no explicit preset → yolo (native default)
13
+ *
14
+ * "At the spawn" is load-bearing, not incidental. The Dash session is prepared
15
+ * (and `pinInitialPermission`-stamped) only AFTER the transport wrapper exists,
16
+ * and the new-chat permission pick arrives as a later `permission/preset` — the
17
+ * child materializes on the first prompt, so the launch flag must be read from
18
+ * the session at THAT moment, never frozen at create. See
19
+ * {@link resolveSpawnPermission}.
20
+ *
21
+ * `OMP_APPROVAL_MODE` (a valid mode) overrides the mapping — headless test
22
+ * runs pin the flag without composing a preset default.
23
+ *
24
+ * The preset is a Dash-side session fact OMP never records. It lives in the
25
+ * dsh session log (`permission/preset`, the event `/permission` writes) and is
26
+ * mirrored into the centralized index (`sessions.permission_preset`) at first
27
+ * spawn; the index row is only a fallback for logs predating the event.
28
+ */
29
+ import { dirname, join } from "node:path";
30
+ /** The approval modes OMP actually implements (unknown modes degrade to yolo). */
31
+ const APPROVAL_MODES = ["write", "always-ask", "yolo"];
32
+ /** The Dash preset table (mirrors the base bundle's permission plugin config). */
33
+ const PRESETS = {
34
+ "danger-full-access": { sandbox: "danger-full-access", approval: "never", ompMode: "yolo" },
35
+ "workspace-write": { sandbox: "workspace-write", approval: "ask", ompMode: "write" },
36
+ "read-only": { sandbox: "read-only", approval: "ask", ompMode: "always-ask" },
37
+ };
38
+ /** Narrow an untrusted value to a known preset name. */
39
+ export function isPresetName(raw) {
40
+ return typeof raw === "string" && Object.hasOwn(PRESETS, raw);
41
+ }
42
+ /**
43
+ * `OMP_APPROVAL_MODE` when it names a mode OMP implements, else undefined.
44
+ * An invalid value is IGNORED (the preset mapping applies) — the old
45
+ * fall-back-to-`write` behavior silently downgraded from OMP's native yolo.
46
+ */
47
+ export function envApprovalMode() {
48
+ const raw = process.env.OMP_APPROVAL_MODE;
49
+ return raw !== undefined && APPROVAL_MODES.includes(raw) ? raw : undefined;
50
+ }
51
+ /** Map a preset onto OMP's `--approval-mode` flag value; no preset → yolo. */
52
+ export function ompApprovalMode(preset) {
53
+ return isPresetName(preset) ? PRESETS[preset].ompMode : "yolo";
54
+ }
55
+ /**
56
+ * The default preset for FUTURE sessions, as the permission service
57
+ * resolves it (settings-backed; the profile patch pins the base default).
58
+ * Undefined when the service is absent or its getter fails — callers fall
59
+ * back to OMP's native default.
60
+ */
61
+ export function defaultPermissionPreset(ctx) {
62
+ const service = ctx.get("permissionPresets");
63
+ if (service === undefined)
64
+ return undefined;
65
+ try {
66
+ const preset = service.defaultPreset;
67
+ return isPresetName(preset) ? preset : undefined;
68
+ }
69
+ catch {
70
+ return undefined;
71
+ }
72
+ }
73
+ /** The session's effective preset: the last `permission/preset` event. */
74
+ export function presetFromEvents(events) {
75
+ for (let index = events.length - 1; index >= 0; index -= 1) {
76
+ const event = events[index];
77
+ if (event.type === "permission/preset" && isPresetName(event.data?.preset))
78
+ return event.data.preset;
79
+ }
80
+ return undefined;
81
+ }
82
+ /**
83
+ * Resolve a spawn's `--approval-mode` (and the preset to record for it) from
84
+ * the session's OWN log, evaluated at the moment the child materializes.
85
+ *
86
+ * Order of authority: the last valid `permission/preset` (= the user's pick in
87
+ * the new chat, or the draft's `pinInitialPermission` stamp) → `fallbackPreset`
88
+ * (the composition default for a create, the bridge-index row for a resume of a
89
+ * log that predates the event) → OMP's native default (`yolo`). An
90
+ * `OMP_APPROVAL_MODE` env override (headless runs) still wins over all of them.
91
+ *
92
+ * @param events - the live session's events (never a stale create-time read).
93
+ * @param fallbackPreset - used only when the log carries no valid preset.
94
+ * @param envMode - `envApprovalMode()`; undefined when unset or invalid.
95
+ * @returns the launch flag value plus the preset that produced it.
96
+ */
97
+ export function resolveSpawnPermission(events, fallbackPreset, envMode) {
98
+ const preset = presetFromEvents(events) ?? (isPresetName(fallbackPreset) ? fallbackPreset : undefined);
99
+ return { approvalMode: envMode ?? ompApprovalMode(preset), preset };
100
+ }
101
+ /**
102
+ * Decide a `/permission` invocation for one OMP session.
103
+ *
104
+ * A permission pick can only become real at the child's launch, so the shadow
105
+ * accepts it exactly while no child exists (the new-chat draft, or a resumed
106
+ * session before its first prompt) and refuses it afterwards — appending a
107
+ * preset the running `omp` cannot honor would make the UI lie about the
108
+ * session's effective policy.
109
+ *
110
+ * @param input.rawInput - the preset name as typed (may be empty or padded).
111
+ * @param input.spawned - whether THIS session's `omp --mode rpc` child exists.
112
+ * @param input.names - the host's advertised preset names.
113
+ * @param input.current - the session's current preset (for the bare command).
114
+ * @returns the decision; the caller performs the write for `apply`.
115
+ */
116
+ export function ompPermissionCommand(input) {
117
+ const available = input.names.join(", ");
118
+ const name = input.rawInput.trim();
119
+ if (name === "") {
120
+ return {
121
+ action: "settled",
122
+ result: { kind: "success", text: `current preset ${input.current} (available: ${available})` },
123
+ };
124
+ }
125
+ if (!input.names.includes(name)) {
126
+ return { action: "settled", result: { kind: "error", text: `unknown preset "${name}" (available: ${available})` } };
127
+ }
128
+ if (input.spawned) {
129
+ return {
130
+ action: "settled",
131
+ result: {
132
+ kind: "error",
133
+ text: `the OMP session is already running with a fixed approval policy: pick "${name}" in a new chat, before the first prompt`,
134
+ },
135
+ };
136
+ }
137
+ return { action: "apply", preset: name, result: { kind: "success", text: `preset ${name}` } };
138
+ }
139
+ /**
140
+ * The three Dash events `pinInitialPermission` stamps for a fresh session,
141
+ * in its append order (preset, sandbox, approval). Cold replay prepends
142
+ * them so the UI shows the session's permission after wrapper restarts.
143
+ */
144
+ export function permissionEventsFor(preset, time) {
145
+ const spec = PRESETS[preset];
146
+ return [
147
+ { type: "permission/preset", time, data: { preset } },
148
+ { type: "sandbox/mode", time, data: { mode: spec.sandbox } },
149
+ { type: "approval/policy", time, data: { policy: spec.approval } },
150
+ ];
151
+ }
152
+ /**
153
+ * The bridge's legacy per-session artifact path (the migration reads this to
154
+ * import the old `dashSessionId` / `permissionPreset` once). Kept read-only;
155
+ * nothing writes it after the migration.
156
+ */
157
+ export function webuiArtifactPath(sessionFile) {
158
+ const base = sessionFile.split("/").pop() ?? sessionFile;
159
+ const stem = base.endsWith(".jsonl") ? base.slice(0, -".jsonl".length) : base;
160
+ return join(dirname(sessionFile), stem, "webui.json");
161
+ }
@@ -0,0 +1,189 @@
1
+ /**
2
+ * agent-omp sidecar protocol (v0).
3
+ *
4
+ * Transport: JSON lines over stdio of the bun sidecar process.
5
+ * - Node → sidecar: request frame { id, method, params }
6
+ * - sidecar → Node: response frame { id, ok: true, result } | { id, ok: false, error }
7
+ * - sidecar → Node: event frame { event: "<channel>", sessionId?, payload }
8
+ * - Node → sidecar: notification { method, params } (no id, no response — e.g. session.prompt cancel is out of band via abort)
9
+ *
10
+ * Handshake: on start the sidecar pushes { event: "ready", payload: { protocol: 0, sdk: <version> } }.
11
+ * Every request gets exactly one response, in any order (correlate by id).
12
+ */
13
+ export declare const PROTOCOL_VERSION = 0;
14
+ export interface RequestFrame {
15
+ id: number;
16
+ method: string;
17
+ params?: unknown;
18
+ }
19
+ export interface NotificationFrame {
20
+ method: string;
21
+ params?: unknown;
22
+ }
23
+ export type ResponseFrame = {
24
+ id: number;
25
+ ok: true;
26
+ result: unknown;
27
+ } | {
28
+ id: number;
29
+ ok: false;
30
+ error: string;
31
+ };
32
+ export interface EventFrame {
33
+ event: string;
34
+ sessionId?: string;
35
+ payload: unknown;
36
+ }
37
+ export declare namespace methods {
38
+ interface PingParams {
39
+ }
40
+ interface PingResult {
41
+ pong: true;
42
+ sdk: string;
43
+ bun: string;
44
+ }
45
+ interface ModelsListParams {
46
+ refresh?: boolean;
47
+ }
48
+ interface ModelsListResult {
49
+ models: Array<{
50
+ provider: string;
51
+ id: string;
52
+ name?: string;
53
+ api?: string;
54
+ baseUrl?: string;
55
+ reasoning?: boolean;
56
+ input?: string[];
57
+ contextWindow?: number;
58
+ maxTokens?: number;
59
+ thinking?: {
60
+ mode?: string;
61
+ efforts?: string[];
62
+ defaultLevel?: string;
63
+ };
64
+ }>;
65
+ providers: string[];
66
+ }
67
+ interface SettingsGetParams {
68
+ key?: string;
69
+ }
70
+ interface SettingsGetResult {
71
+ value: unknown;
72
+ }
73
+ /** modelRoles: role → "provider/model[:effort]" selector map. */
74
+ interface SettingsModelRolesGetParams {
75
+ }
76
+ interface SettingsModelRolesGetResult {
77
+ modelRoles: Record<string, string>;
78
+ }
79
+ interface SettingsModelRolesSetParams {
80
+ modelRoles: Record<string, string>;
81
+ }
82
+ interface SettingsModelRolesSetResult {
83
+ ok: boolean;
84
+ }
85
+ interface SessionCreateParams {
86
+ /** in-memory by default; "file" = SessionManager.create(cwd) */
87
+ persistence?: "memory" | "file";
88
+ cwd?: string;
89
+ /** provider/model selector, resolved the same way the CLI does */
90
+ model?: string;
91
+ systemPrompt?: string;
92
+ appendSystemPrompt?: string;
93
+ }
94
+ interface SessionCreateResult {
95
+ sessionId: string;
96
+ sessionFile?: string;
97
+ model?: string;
98
+ }
99
+ interface SessionDisposeParams {
100
+ sessionId: string;
101
+ }
102
+ interface SessionDisposeResult {
103
+ disposed: true;
104
+ }
105
+ interface SessionInfoParams {
106
+ sessionId: string;
107
+ }
108
+ interface SessionInfoResult {
109
+ sessionId: string;
110
+ sessionFile?: string;
111
+ model?: string;
112
+ thinkingLevel?: string;
113
+ isStreaming: boolean;
114
+ messageCount: number;
115
+ /** rendered system prompt (lazy — may be short until first turn) */
116
+ systemPromptBytes: number;
117
+ }
118
+ interface SessionPromptParams {
119
+ sessionId: string;
120
+ text: string;
121
+ streamingBehavior?: "steer" | "followUp";
122
+ }
123
+ interface SessionPromptResult {
124
+ accepted: boolean;
125
+ }
126
+ interface SessionSteerParams {
127
+ sessionId: string;
128
+ text: string;
129
+ }
130
+ interface SessionFollowUpParams {
131
+ sessionId: string;
132
+ text: string;
133
+ }
134
+ interface SessionAbortParams {
135
+ sessionId: string;
136
+ }
137
+ /** A5 — session store index */
138
+ interface SessionsListParams {
139
+ cwd?: string;
140
+ all?: boolean;
141
+ }
142
+ interface SessionsListResult {
143
+ sessions: Array<{
144
+ id: string;
145
+ file: string;
146
+ title?: string;
147
+ timestamp?: string;
148
+ }>;
149
+ }
150
+ /** S-lane — rendered base system prompt (live handle + cold file). */
151
+ interface SessionSystemPromptResult {
152
+ systemPrompt: string;
153
+ }
154
+ interface SessionSystemPromptForFileParams {
155
+ file: string;
156
+ }
157
+ /** A6 — full-library native session index (one `SessionManager.listAll` over every cwd group). */
158
+ interface SessionsListAllParams {
159
+ }
160
+ interface SessionsListAllResult {
161
+ sessions: Array<{
162
+ id: string;
163
+ file: string;
164
+ cwd?: string;
165
+ title?: string;
166
+ /** first user-message text (title fallback source). */
167
+ firstMessage?: string;
168
+ /** epoch ms (session header timestamp). */
169
+ createdAt?: number;
170
+ /** epoch ms (transcript mtime, ms precision). */
171
+ mtimeMs?: number;
172
+ /** transcript byte size. */
173
+ size?: number;
174
+ }>;
175
+ }
176
+ /** A6 — read-only transcript extraction for one session file (resume/replay). */
177
+ interface SessionsMessagesReadOnlyParams {
178
+ file: string;
179
+ }
180
+ interface SessionsMessagesReadOnlyResult {
181
+ messages: unknown[];
182
+ modelChanges: Array<{
183
+ model: string;
184
+ role?: string;
185
+ }>;
186
+ }
187
+ }
188
+ /** event channels forwarded from AgentSession.subscribe */
189
+ export type SessionEventChannel = "session:event";
@@ -0,0 +1,77 @@
1
+ /**
2
+ * OMP wire-shape types, shared verbatim with the RPC line
3
+ * (apps/omp-web/src/rpc.ts) so both clients speak identical payload shapes.
4
+ */
5
+ /** A `response` record (command acknowledgement). */
6
+ export interface RpcResponse {
7
+ id?: string;
8
+ type: "response";
9
+ command: string;
10
+ success: boolean;
11
+ data?: unknown;
12
+ error?: string;
13
+ }
14
+ /** Any event record streamed from OMP. */
15
+ export interface RpcEvent {
16
+ type: string;
17
+ [key: string]: unknown;
18
+ }
19
+ /** One content block inside an OMP `AgentMessage`. */
20
+ export interface OmpContentBlock {
21
+ type: string;
22
+ [key: string]: unknown;
23
+ }
24
+ /** An OMP `AgentMessage` (user | assistant | toolResult). */
25
+ export interface OmpMessage {
26
+ role: "user" | "assistant" | "toolResult";
27
+ content?: OmpContentBlock[];
28
+ [key: string]: unknown;
29
+ }
30
+ /** The `assistantMessageEvent` delta carried by a `message_update` event. */
31
+ export interface OmpAssistantMessageEvent {
32
+ type: string;
33
+ contentIndex?: number;
34
+ delta?: string;
35
+ content?: string;
36
+ partial?: unknown;
37
+ toolCall?: unknown;
38
+ }
39
+ /** The `get_state` response payload. */
40
+ export interface OmpState {
41
+ isStreaming: boolean;
42
+ sessionId?: string;
43
+ sessionFile?: string;
44
+ /** The currently selected model (`get_state` returns the full model record). */
45
+ model?: {
46
+ id: string;
47
+ provider: string;
48
+ name?: string;
49
+ [key: string]: unknown;
50
+ };
51
+ [key: string]: unknown;
52
+ }
53
+ /** The `get_session_stats` response payload (live sessions only). */
54
+ export interface OmpSessionStats {
55
+ tokens?: {
56
+ input?: number;
57
+ output?: number;
58
+ cacheRead?: number;
59
+ cacheWrite?: number;
60
+ };
61
+ contextUsage?: number;
62
+ cost?: unknown;
63
+ [key: string]: unknown;
64
+ }
65
+ /**
66
+ * An OMP `extension_ui_request` record. Approval cards surface as
67
+ * `method: "select"` with `options: ["Approve", "Deny"]`; the client answers
68
+ * with an `extension_ui_response` echoing the request `id` and a `value`.
69
+ */
70
+ export interface RpcExtensionUiRequest {
71
+ type: "extension_ui_request";
72
+ id: string;
73
+ method: string;
74
+ title?: string;
75
+ options?: string[];
76
+ [key: string]: unknown;
77
+ }
@@ -0,0 +1 @@
1
+ export {};