@cyfsh/adapters 0.0.0-stage → 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 CYF (Chat Yourself) Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,119 @@
1
+ import { type AgentEngineId } from "@cyfsh/protocol";
2
+ import type { AgentRuntimeAdapter, EngineLaunchSpec, RuntimeInjectedContext, RuntimeTurnRequest, RuntimeTurnResult } from "./types.js";
3
+ export interface RuntimeAdapterOptions {
4
+ /**
5
+ * Execution mode:
6
+ * - `"sandbox"` (default): deterministic local zero-API-key responder with full guard & approval simulation
7
+ * - `"live"`: invokes real local CLI binary with generated Fail-Closed hooks & strict MCP isolation
8
+ */
9
+ executionMode?: "sandbox" | "live";
10
+ /**
11
+ * Optional root directory where virtual/materialized guard artifacts live.
12
+ */
13
+ artifactsRootDir?: string;
14
+ /**
15
+ * Whether `buildLaunchSpec` should also write generated guard files to disk immediately.
16
+ */
17
+ materializeFilesOnBuild?: boolean;
18
+ /**
19
+ * OpenCode HTTP server base URL when driving `opencode serve`.
20
+ */
21
+ openCodeBaseUrl?: string;
22
+ /**
23
+ * Dsh profile selection (`acp` or `sdk`).
24
+ */
25
+ dshProfile?: "acp" | "sdk";
26
+ }
27
+ declare abstract class BaseEngineAdapter implements AgentRuntimeAdapter {
28
+ abstract readonly engine: AgentEngineId;
29
+ protected readonly options: RuntimeAdapterOptions;
30
+ protected readonly activeProcesses: Map<string, () => void>;
31
+ constructor(options?: RuntimeAdapterOptions);
32
+ abstract buildLaunchSpec(context: RuntimeInjectedContext): EngineLaunchSpec;
33
+ protected resolveArtifactsDir(context: RuntimeInjectedContext): string;
34
+ protected buildBaseEnv(context: RuntimeInjectedContext, guardScriptPath: string): Record<string, string>;
35
+ executeGuestTurn(request: RuntimeTurnRequest): Promise<RuntimeTurnResult>;
36
+ cancelActiveSession(shareId: string): Promise<void>;
37
+ }
38
+ /**
39
+ * 1. Anthropic Claude Code Adapter
40
+ * Uses `--input-format stream-json --output-format stream-json --strict-mcp-config`
41
+ * + managed `settings.json` with Fail-Closed `PreToolUse` / `UserPromptSubmit` hooks.
42
+ * Native `--resume <rawId> --fork-session` is ONLY attached in `MODE_C_FULL_FORK`.
43
+ */
44
+ export declare class ClaudeCodeAdapter extends BaseEngineAdapter {
45
+ readonly engine: "claude-code";
46
+ buildLaunchSpec(context: RuntimeInjectedContext): EngineLaunchSpec;
47
+ }
48
+ /**
49
+ * 2. OpenAI Codex Adapter (`codex app-server` JSON-RPC 2.0)
50
+ * - Mode A/B/D: `thread/start` with `ephemeral: true` + `sandbox: "read-only"`
51
+ * - Mode C: `thread/fork` (explicitly avoiding `-32600` single-writer lock on `thread/resume`)
52
+ * - Revocation: `turn/interrupt`
53
+ */
54
+ export declare class CodexAdapter extends BaseEngineAdapter {
55
+ readonly engine: "codex";
56
+ buildLaunchSpec(context: RuntimeInjectedContext): EngineLaunchSpec;
57
+ buildTurnStartRpc(threadId: string, prompt: string, requestId?: number): {
58
+ jsonrpc: "2.0";
59
+ id: number;
60
+ method: string;
61
+ params: {
62
+ threadId: string;
63
+ input: {
64
+ type: string;
65
+ text: string;
66
+ }[];
67
+ sandbox: string;
68
+ };
69
+ };
70
+ buildTurnInterruptRpc(threadId: string, turnId?: string, requestId?: number): {
71
+ jsonrpc: "2.0";
72
+ id: number;
73
+ method: string;
74
+ params: {
75
+ turnId?: string | undefined;
76
+ threadId: string;
77
+ };
78
+ };
79
+ }
80
+ /**
81
+ * 3. SST OpenCode Adapter (`opencode serve` REST/SSE + `opencode acp`)
82
+ * - Mode A/B/D: `POST /session` clean isolated session
83
+ * - Mode C: `POST /session/:id/fork`
84
+ * - ACP: `opencode acp` stdio with `session/request_permission` interception
85
+ */
86
+ export declare class OpenCodeAdapter extends BaseEngineAdapter {
87
+ readonly engine: "opencode";
88
+ buildLaunchSpec(context: RuntimeInjectedContext): EngineLaunchSpec;
89
+ }
90
+ /**
91
+ * 4. DeepSeek Harness Adapter (`dsh --profile acp|sdk --patch cyf-dsh-guard-patch.yaml`)
92
+ * Dynamically overlays a Cordis guard YAML patch stripping high-risk tools & private MCPs.
93
+ */
94
+ export declare class DshAdapter extends BaseEngineAdapter {
95
+ readonly engine: "dsh";
96
+ buildLaunchSpec(context: RuntimeInjectedContext): EngineLaunchSpec;
97
+ }
98
+ /**
99
+ * 5. Tencent Cloud CodeBuddy Adapter
100
+ * Builds `codebuddy --serve --strict-mcp-config --no-session-persistence`
101
+ * pure in-memory zero-footprint guest runtime specification.
102
+ */
103
+ export declare class CodeBuddyAdapter extends BaseEngineAdapter {
104
+ readonly engine: "codebuddy";
105
+ buildLaunchSpec(context: RuntimeInjectedContext): EngineLaunchSpec;
106
+ }
107
+ /**
108
+ * Registry holding all 5 first-wave runtime adapters.
109
+ */
110
+ export declare class RuntimeAdapterRegistry {
111
+ private readonly adapters;
112
+ constructor(options?: RuntimeAdapterOptions);
113
+ getAdapter(engine: AgentEngineId): AgentRuntimeAdapter;
114
+ listAdapters(): AgentRuntimeAdapter[];
115
+ cancelShareAcrossEngines(shareId: string): Promise<void>;
116
+ }
117
+ export declare function createRuntimeAdapterRegistry(options?: RuntimeAdapterOptions): RuntimeAdapterRegistry;
118
+ export {};
119
+ //# sourceMappingURL=adapters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../src/adapters.ts"],"names":[],"mappings":"AAGA,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAM3E,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,aAAa,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACnC;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,UAAU,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;CAC5B;AAED,uBAAe,iBAAkB,YAAW,mBAAmB;IAC7D,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IACxC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAC;IAClD,SAAS,CAAC,QAAQ,CAAC,eAAe,oBAAyB,IAAI,EAAI;gBAEvD,OAAO,GAAE,qBAA0B;IAI/C,QAAQ,CAAC,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,gBAAgB;IAE3E,SAAS,CAAC,mBAAmB,CAAC,OAAO,EAAE,sBAAsB,GAAG,MAAM;IAStE,SAAS,CAA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;;GAEG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6C;gBAE1D,OAAO,GAAE,qBAA0B;IAU/C,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,mBAAmB;IAItD,YAAY,IAAI,mBAAmB,EAAE;IAI/B,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAS/D;AAED,wBAAgB,4BAA4B,CAC1C,OAAO,GAAE,qBAA0B,GAClC,sBAAsB,CAExB"}
@@ -0,0 +1,492 @@
1
+ import { spawn } from "node:child_process";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { AGENT_ENGINE_CATALOG } from "@cyfsh/protocol";
5
+ import { buildGuardArtifactBundle } from "./guard-generator.js";
6
+ import { buildRuntimeSystemEnvelope, runSandboxResponder, } from "./sandbox-responder.js";
7
+ class BaseEngineAdapter {
8
+ options;
9
+ activeProcesses = new Map();
10
+ constructor(options = {}) {
11
+ this.options = options;
12
+ }
13
+ resolveArtifactsDir(context) {
14
+ if (context.guardArtifactsDir) {
15
+ return context.guardArtifactsDir;
16
+ }
17
+ const base = this.options.artifactsRootDir ?? path.join(os.tmpdir(), "cyf-guards");
18
+ return path.join(base, context.shareId);
19
+ }
20
+ buildBaseEnv(context, guardScriptPath) {
21
+ return {
22
+ CYF_GUEST_SHARE_ID: context.shareId,
23
+ CYF_CONTEXT_MODE: context.contextMode,
24
+ CYF_PERMISSION_TIER: context.permissionTier,
25
+ CYF_GUARD_SCRIPT: guardScriptPath,
26
+ CYF_STRICT_NO_PRIVATE_MCP: "1",
27
+ };
28
+ }
29
+ async executeGuestTurn(request) {
30
+ // Always run deterministic guard & grey-zone broker pre-check first (Defense in Depth Layer 1)
31
+ const sandboxResult = runSandboxResponder(request);
32
+ if (sandboxResult.blockedByGuard || sandboxResult.greyZoneEscalation) {
33
+ return sandboxResult;
34
+ }
35
+ const mode = this.options.executionMode ??
36
+ (process.env["CYF_RUNTIME_MODE"] === "live" ? "live" : "sandbox");
37
+ if (mode !== "live") {
38
+ return sandboxResult;
39
+ }
40
+ const spec = this.buildLaunchSpec({
41
+ ...request.context,
42
+ guardArtifactsDir: this.resolveArtifactsDir(request.context),
43
+ });
44
+ buildGuardArtifactBundle(this.resolveArtifactsDir(request.context), {
45
+ shareId: request.context.shareId,
46
+ workspacePath: request.context.workspacePath,
47
+ permissionTier: request.context.permissionTier,
48
+ writableGlobs: request.context.writableGlobs,
49
+ }, true);
50
+ return new Promise((resolve) => {
51
+ try {
52
+ const child = spawn(spec.binary, spec.args, {
53
+ cwd: spec.cwd,
54
+ env: { ...process.env, ...spec.env },
55
+ stdio: ["pipe", "pipe", "pipe"],
56
+ });
57
+ let stdout = "";
58
+ let stderr = "";
59
+ const killHandle = () => {
60
+ if (!child.killed) {
61
+ child.kill("SIGTERM");
62
+ }
63
+ };
64
+ this.activeProcesses.set(request.context.shareId, killHandle);
65
+ child.stdout.on("data", (chunk) => {
66
+ stdout += chunk.toString("utf8");
67
+ });
68
+ child.stderr.on("data", (chunk) => {
69
+ stderr += chunk.toString("utf8");
70
+ });
71
+ child.on("error", () => {
72
+ this.activeProcesses.delete(request.context.shareId);
73
+ resolve(sandboxResult);
74
+ });
75
+ child.on("close", (code) => {
76
+ this.activeProcesses.delete(request.context.shareId);
77
+ if (code === 2) {
78
+ resolve({
79
+ blockedByGuard: true,
80
+ guardInterception: {
81
+ ruleId: "SENSITIVE_FILE_ACCESS",
82
+ targetOrPattern: spec.binary,
83
+ reason: stderr.trim() || "Blocked by PreToolUse Fail-Closed Hook (Exit 2).",
84
+ },
85
+ thinkingTrace: `[Live CLI Exit 2] ${stderr.trim()}`,
86
+ replyContent: `[CYF Guard] 底层运行时守卫拦截了受限操作:${stderr.trim() || "Exit Code 2"}`,
87
+ });
88
+ return;
89
+ }
90
+ const trimmed = stdout.trim();
91
+ if (!trimmed) {
92
+ resolve(sandboxResult);
93
+ return;
94
+ }
95
+ resolve({
96
+ blockedByGuard: false,
97
+ thinkingTrace: `[Live ${spec.binary} Subprocess Completed (exit=${String(code)})]`,
98
+ replyContent: trimmed,
99
+ });
100
+ });
101
+ child.stdin.write(JSON.stringify({
102
+ type: "user",
103
+ message: { role: "user", content: request.prompt },
104
+ }) + "\n");
105
+ child.stdin.end();
106
+ }
107
+ catch {
108
+ resolve(sandboxResult);
109
+ }
110
+ });
111
+ }
112
+ async cancelActiveSession(shareId) {
113
+ const cancelFn = this.activeProcesses.get(shareId);
114
+ if (cancelFn) {
115
+ cancelFn();
116
+ this.activeProcesses.delete(shareId);
117
+ }
118
+ }
119
+ }
120
+ /**
121
+ * 1. Anthropic Claude Code Adapter
122
+ * Uses `--input-format stream-json --output-format stream-json --strict-mcp-config`
123
+ * + managed `settings.json` with Fail-Closed `PreToolUse` / `UserPromptSubmit` hooks.
124
+ * Native `--resume <rawId> --fork-session` is ONLY attached in `MODE_C_FULL_FORK`.
125
+ */
126
+ export class ClaudeCodeAdapter extends BaseEngineAdapter {
127
+ engine = "claude-code";
128
+ buildLaunchSpec(context) {
129
+ const artifactsDir = this.resolveArtifactsDir(context);
130
+ const bundle = buildGuardArtifactBundle(artifactsDir, {
131
+ shareId: context.shareId,
132
+ workspacePath: context.workspacePath,
133
+ permissionTier: context.permissionTier,
134
+ writableGlobs: context.writableGlobs,
135
+ }, this.options.materializeFilesOnBuild ?? false);
136
+ const systemPromptPayload = buildRuntimeSystemEnvelope(context);
137
+ const usesNativeFork = context.contextMode === "MODE_C_FULL_FORK";
138
+ const args = [
139
+ "-p",
140
+ "--input-format",
141
+ "stream-json",
142
+ "--output-format",
143
+ "stream-json",
144
+ "--strict-mcp-config",
145
+ "--mcp-config",
146
+ bundle.emptyMcpConfigPath,
147
+ "--settings",
148
+ bundle.claudeSettingsPath,
149
+ "--append-system-prompt",
150
+ systemPromptPayload,
151
+ ];
152
+ if (usesNativeFork) {
153
+ args.push("--resume", context.rawSessionId, "--fork-session");
154
+ }
155
+ return {
156
+ engine: this.engine,
157
+ protocolKind: AGENT_ENGINE_CATALOG[this.engine].protocolKind,
158
+ binary: AGENT_ENGINE_CATALOG[this.engine].cliBinary,
159
+ args,
160
+ cwd: context.workspacePath,
161
+ env: this.buildBaseEnv(context, bundle.guardScriptPath),
162
+ usesNativeFork,
163
+ strictMcpIsolated: true,
164
+ systemPromptPayload,
165
+ generatedFiles: bundle.files,
166
+ };
167
+ }
168
+ }
169
+ /**
170
+ * 2. OpenAI Codex Adapter (`codex app-server` JSON-RPC 2.0)
171
+ * - Mode A/B/D: `thread/start` with `ephemeral: true` + `sandbox: "read-only"`
172
+ * - Mode C: `thread/fork` (explicitly avoiding `-32600` single-writer lock on `thread/resume`)
173
+ * - Revocation: `turn/interrupt`
174
+ */
175
+ export class CodexAdapter extends BaseEngineAdapter {
176
+ engine = "codex";
177
+ buildLaunchSpec(context) {
178
+ const artifactsDir = this.resolveArtifactsDir(context);
179
+ const bundle = buildGuardArtifactBundle(artifactsDir, {
180
+ shareId: context.shareId,
181
+ workspacePath: context.workspacePath,
182
+ permissionTier: context.permissionTier,
183
+ writableGlobs: context.writableGlobs,
184
+ }, this.options.materializeFilesOnBuild ?? false);
185
+ const systemPromptPayload = buildRuntimeSystemEnvelope(context);
186
+ const usesNativeFork = context.contextMode === "MODE_C_FULL_FORK";
187
+ const approvalPolicy = context.ownerApprovalOnGreyZone ? "on-request" : "never";
188
+ const bootstrapRpc = usesNativeFork
189
+ ? {
190
+ jsonrpc: "2.0",
191
+ id: 1,
192
+ method: "thread/fork",
193
+ params: {
194
+ threadId: context.rawSessionId,
195
+ cwd: context.workspacePath,
196
+ ephemeral: true,
197
+ sandbox: "read-only",
198
+ approvalPolicy,
199
+ developerInstructions: systemPromptPayload,
200
+ },
201
+ }
202
+ : {
203
+ jsonrpc: "2.0",
204
+ id: 1,
205
+ method: "thread/start",
206
+ params: {
207
+ cwd: context.workspacePath,
208
+ ephemeral: true,
209
+ sandbox: "read-only",
210
+ approvalPolicy,
211
+ developerInstructions: systemPromptPayload,
212
+ },
213
+ };
214
+ const interruptRpc = {
215
+ jsonrpc: "2.0",
216
+ id: 99,
217
+ method: "turn/interrupt",
218
+ params: {
219
+ threadId: usesNativeFork ? `fork_${context.rawSessionId}` : `ephemeral_${context.shareId}`,
220
+ reason: "revoked_by_owner",
221
+ },
222
+ };
223
+ return {
224
+ engine: this.engine,
225
+ protocolKind: AGENT_ENGINE_CATALOG[this.engine].protocolKind,
226
+ binary: AGENT_ENGINE_CATALOG[this.engine].cliBinary,
227
+ args: ["app-server"],
228
+ cwd: context.workspacePath,
229
+ env: this.buildBaseEnv(context, bundle.guardScriptPath),
230
+ usesNativeFork,
231
+ strictMcpIsolated: true,
232
+ systemPromptPayload,
233
+ rpcBootstrapFrames: [bootstrapRpc],
234
+ rpcInterruptFrame: interruptRpc,
235
+ generatedFiles: bundle.files,
236
+ };
237
+ }
238
+ buildTurnStartRpc(threadId, prompt, requestId = 2) {
239
+ return {
240
+ jsonrpc: "2.0",
241
+ id: requestId,
242
+ method: "turn/start",
243
+ params: {
244
+ threadId,
245
+ input: [{ type: "text", text: prompt }],
246
+ sandbox: "read-only",
247
+ },
248
+ };
249
+ }
250
+ buildTurnInterruptRpc(threadId, turnId, requestId = 99) {
251
+ return {
252
+ jsonrpc: "2.0",
253
+ id: requestId,
254
+ method: "turn/interrupt",
255
+ params: {
256
+ threadId,
257
+ ...(turnId ? { turnId } : {}),
258
+ },
259
+ };
260
+ }
261
+ }
262
+ /**
263
+ * 3. SST OpenCode Adapter (`opencode serve` REST/SSE + `opencode acp`)
264
+ * - Mode A/B/D: `POST /session` clean isolated session
265
+ * - Mode C: `POST /session/:id/fork`
266
+ * - ACP: `opencode acp` stdio with `session/request_permission` interception
267
+ */
268
+ export class OpenCodeAdapter extends BaseEngineAdapter {
269
+ engine = "opencode";
270
+ buildLaunchSpec(context) {
271
+ const artifactsDir = this.resolveArtifactsDir(context);
272
+ const bundle = buildGuardArtifactBundle(artifactsDir, {
273
+ shareId: context.shareId,
274
+ workspacePath: context.workspacePath,
275
+ permissionTier: context.permissionTier,
276
+ writableGlobs: context.writableGlobs,
277
+ }, this.options.materializeFilesOnBuild ?? false);
278
+ const systemPromptPayload = buildRuntimeSystemEnvelope(context);
279
+ const usesNativeFork = context.contextMode === "MODE_C_FULL_FORK";
280
+ const baseUrl = this.options.openCodeBaseUrl ?? "http://127.0.0.1:4096";
281
+ const createOrForkEndpoint = usesNativeFork
282
+ ? {
283
+ method: "POST",
284
+ path: `/session/${encodeURIComponent(context.rawSessionId)}/fork`,
285
+ body: {
286
+ title: `[CYF Guest] ${context.topic}`,
287
+ permission: {
288
+ bash: context.ownerApprovalOnGreyZone ? "ask" : "deny",
289
+ edit: context.permissionTier === "TIER_2_WORKTREE_SANDBOX" ? "ask" : "deny",
290
+ webfetch: "deny",
291
+ },
292
+ },
293
+ description: "Fork existing OpenCode session into isolated guest shadow branch",
294
+ }
295
+ : {
296
+ method: "POST",
297
+ path: "/session",
298
+ body: {
299
+ title: `[CYF Guest] ${context.topic}`,
300
+ systemPrompt: systemPromptPayload,
301
+ permission: {
302
+ bash: context.ownerApprovalOnGreyZone ? "ask" : "deny",
303
+ edit: "deny",
304
+ webfetch: "deny",
305
+ },
306
+ },
307
+ description: "Create clean OpenCode session with sanitized capsule context",
308
+ };
309
+ return {
310
+ engine: this.engine,
311
+ protocolKind: AGENT_ENGINE_CATALOG[this.engine].protocolKind,
312
+ binary: AGENT_ENGINE_CATALOG[this.engine].cliBinary,
313
+ args: ["acp"],
314
+ cwd: context.workspacePath,
315
+ env: {
316
+ ...this.buildBaseEnv(context, bundle.guardScriptPath),
317
+ OPENCODE_SERVER_URL: baseUrl,
318
+ },
319
+ usesNativeFork,
320
+ strictMcpIsolated: true,
321
+ systemPromptPayload,
322
+ httpEndpoints: {
323
+ bootstrapSession: createOrForkEndpoint,
324
+ eventStream: {
325
+ method: "GET",
326
+ path: "/event",
327
+ description: "Subscribe to OpenCode SSE session events & tool permission requests",
328
+ },
329
+ abortSession: {
330
+ method: "POST",
331
+ path: `/session/${encodeURIComponent(context.shareId)}/abort`,
332
+ description: "Immediately cancel active OpenCode guest generation on revoke",
333
+ },
334
+ },
335
+ rpcBootstrapFrames: [
336
+ {
337
+ jsonrpc: "2.0",
338
+ id: 1,
339
+ method: "session/new",
340
+ params: {
341
+ cwd: context.workspacePath,
342
+ mcpServers: [],
343
+ systemPrompt: systemPromptPayload,
344
+ },
345
+ },
346
+ ],
347
+ rpcInterruptFrame: {
348
+ jsonrpc: "2.0",
349
+ id: 99,
350
+ method: "session/cancel",
351
+ params: { sessionId: context.shareId },
352
+ },
353
+ generatedFiles: bundle.files,
354
+ };
355
+ }
356
+ }
357
+ /**
358
+ * 4. DeepSeek Harness Adapter (`dsh --profile acp|sdk --patch cyf-dsh-guard-patch.yaml`)
359
+ * Dynamically overlays a Cordis guard YAML patch stripping high-risk tools & private MCPs.
360
+ */
361
+ export class DshAdapter extends BaseEngineAdapter {
362
+ engine = "dsh";
363
+ buildLaunchSpec(context) {
364
+ const artifactsDir = this.resolveArtifactsDir(context);
365
+ const bundle = buildGuardArtifactBundle(artifactsDir, {
366
+ shareId: context.shareId,
367
+ workspacePath: context.workspacePath,
368
+ permissionTier: context.permissionTier,
369
+ writableGlobs: context.writableGlobs,
370
+ }, this.options.materializeFilesOnBuild ?? false);
371
+ const systemPromptPayload = buildRuntimeSystemEnvelope(context);
372
+ const usesNativeFork = context.contextMode === "MODE_C_FULL_FORK";
373
+ const profile = this.options.dshProfile ?? "acp";
374
+ const args = [
375
+ "--profile",
376
+ profile,
377
+ "--patch",
378
+ bundle.dshPatchYamlPath,
379
+ ];
380
+ if (usesNativeFork) {
381
+ args.push("--fork", context.rawSessionId);
382
+ }
383
+ return {
384
+ engine: this.engine,
385
+ protocolKind: AGENT_ENGINE_CATALOG[this.engine].protocolKind,
386
+ binary: AGENT_ENGINE_CATALOG[this.engine].cliBinary,
387
+ args,
388
+ cwd: context.workspacePath,
389
+ env: this.buildBaseEnv(context, bundle.guardScriptPath),
390
+ usesNativeFork,
391
+ strictMcpIsolated: true,
392
+ systemPromptPayload,
393
+ rpcBootstrapFrames: [
394
+ {
395
+ jsonrpc: "2.0",
396
+ id: 1,
397
+ method: usesNativeFork ? "session/load" : "session/new",
398
+ params: {
399
+ ...(usesNativeFork ? { sessionId: context.rawSessionId, fork: true } : {}),
400
+ cwd: context.workspacePath,
401
+ mcpServers: [],
402
+ systemPrompt: systemPromptPayload,
403
+ },
404
+ },
405
+ ],
406
+ rpcInterruptFrame: {
407
+ jsonrpc: "2.0",
408
+ id: 99,
409
+ method: "session/cancel",
410
+ params: { sessionId: context.shareId },
411
+ },
412
+ generatedFiles: bundle.files,
413
+ };
414
+ }
415
+ }
416
+ /**
417
+ * 5. Tencent Cloud CodeBuddy Adapter
418
+ * Builds `codebuddy --serve --strict-mcp-config --no-session-persistence`
419
+ * pure in-memory zero-footprint guest runtime specification.
420
+ */
421
+ export class CodeBuddyAdapter extends BaseEngineAdapter {
422
+ engine = "codebuddy";
423
+ buildLaunchSpec(context) {
424
+ const artifactsDir = this.resolveArtifactsDir(context);
425
+ const bundle = buildGuardArtifactBundle(artifactsDir, {
426
+ shareId: context.shareId,
427
+ workspacePath: context.workspacePath,
428
+ permissionTier: context.permissionTier,
429
+ writableGlobs: context.writableGlobs,
430
+ }, this.options.materializeFilesOnBuild ?? false);
431
+ const systemPromptPayload = buildRuntimeSystemEnvelope(context);
432
+ const usesNativeFork = context.contextMode === "MODE_C_FULL_FORK";
433
+ const args = [
434
+ "--serve",
435
+ "--strict-mcp-config",
436
+ "--no-session-persistence",
437
+ "--mcp-config",
438
+ bundle.emptyMcpConfigPath,
439
+ "--settings",
440
+ bundle.claudeSettingsPath,
441
+ "--append-system-prompt",
442
+ systemPromptPayload,
443
+ ];
444
+ if (usesNativeFork) {
445
+ args.push("--resume", context.rawSessionId, "--fork-session");
446
+ }
447
+ return {
448
+ engine: this.engine,
449
+ protocolKind: AGENT_ENGINE_CATALOG[this.engine].protocolKind,
450
+ binary: AGENT_ENGINE_CATALOG[this.engine].cliBinary,
451
+ args,
452
+ cwd: context.workspacePath,
453
+ env: this.buildBaseEnv(context, bundle.guardScriptPath),
454
+ usesNativeFork,
455
+ strictMcpIsolated: true,
456
+ systemPromptPayload,
457
+ generatedFiles: bundle.files,
458
+ };
459
+ }
460
+ }
461
+ /**
462
+ * Registry holding all 5 first-wave runtime adapters.
463
+ */
464
+ export class RuntimeAdapterRegistry {
465
+ adapters;
466
+ constructor(options = {}) {
467
+ this.adapters = {
468
+ "claude-code": new ClaudeCodeAdapter(options),
469
+ codex: new CodexAdapter(options),
470
+ opencode: new OpenCodeAdapter(options),
471
+ dsh: new DshAdapter(options),
472
+ codebuddy: new CodeBuddyAdapter(options),
473
+ };
474
+ }
475
+ getAdapter(engine) {
476
+ return this.adapters[engine];
477
+ }
478
+ listAdapters() {
479
+ return Object.values(this.adapters);
480
+ }
481
+ async cancelShareAcrossEngines(shareId) {
482
+ await Promise.all(Object.values(this.adapters).map(async (adapter) => {
483
+ if (adapter.cancelActiveSession) {
484
+ await adapter.cancelActiveSession(shareId);
485
+ }
486
+ }));
487
+ }
488
+ }
489
+ export function createRuntimeAdapterRegistry(options = {}) {
490
+ return new RuntimeAdapterRegistry(options);
491
+ }
492
+ //# sourceMappingURL=adapters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapters.js","sourceRoot":"","sources":["../src/adapters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAsB,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAkChC,MAAe,iBAAiB;IAEX,OAAO,CAAwB;IAC/B,eAAe,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