showrunner-agent-staging 0.3.1-staging.1538 → 0.3.2-staging.1540
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 +3 -3
- package/dist/src/adapter.js +1 -1
- package/dist/src/adapters/acp/acp-adapter.js +6 -1
- package/dist/src/adapters/acp/acp-mcp-stdio.d.ts +1 -0
- package/dist/src/adapters/acp/acp-mcp-stdio.js +45 -0
- package/dist/src/adapters/acp/acp-permission-mapper.js +15 -0
- package/dist/src/adapters/acp/acp-runtime.d.ts +5 -1
- package/dist/src/adapters/acp/acp-runtime.js +2 -2
- package/dist/src/adapters/acp/acp-tool-bridge.d.ts +5 -0
- package/dist/src/adapters/acp/acp-tool-bridge.js +97 -0
- package/dist/src/agent-tools.d.ts +2 -2
- package/dist/src/agent-tools.js +1 -1
- package/package.json +2 -1
- package/test/adapters/acp/fake-acp-agent.mjs +36 -2
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ The connector credential is issued by Showrunner pairing and stored by `FileConn
|
|
|
50
50
|
- Codex launches `codex app-server` over stdio. Authentication comes from the locally installed Codex process and its normal OpenAI credential configuration. App-server endpoints are limited to stdio, Unix sockets, or loopback unless an embedding application explicitly opts out. See the current [Codex app-server documentation](https://learn.chatgpt.com/docs/app-server).
|
|
51
51
|
Consent-only MCP forms (such as Computer Use access) appear as one-time Showrunner approvals. Forms that require field values and URL authorization flows are cancelled because the approval card cannot collect their responses.
|
|
52
52
|
- Claude is transparently re-hosted with `@anthropic-ai/claude-agent-sdk` through the user's installed Claude Code binary and its existing sign-in. Executable discovery is defined by `findClaudeCodeExecutable` in `src/adapters/claude/claude-adapter.ts`.
|
|
53
|
-
- ACP agents use their CLI's configured credentials. ACP
|
|
53
|
+
- ACP agents use their CLI's configured credentials. ACP receives the same Showrunner tools as Codex and Claude through an invocation-scoped stdio MCP bridge. New and resumed sessions get a fresh authenticated loopback endpoint; calls use the connector's existing grants and owner approval flow. Providers that identify a Showrunner call with a fully qualified structured tool name defer authorization to the bridge. Providers that omit that identity still require their host approval and may show an additional approval before the bridge checks the call. The endpoint closes when the invocation ends. Native image ingestion remains unavailable; download_file provides file access.
|
|
54
54
|
- Custom adapters own their provider credential loading. Keep secrets outside the repository and do not put them in Showrunner messages, adapter state, command errors, or structured log fields.
|
|
55
55
|
|
|
56
56
|
Run each connector under a dedicated OS account/container with access only to its intended working directory, network destinations, and provider credentials. Do not share a home directory or cloud credential chain with unrelated workloads. Disable unused MCP servers and prefer read-only scopes.
|
|
@@ -98,8 +98,8 @@ The transfer timeout in `ExternalAgentClient.uploadFile` reserves finalization h
|
|
|
98
98
|
|
|
99
99
|
Recording requires an app environment and a working host recording tool; the connector doesn't
|
|
100
100
|
supply a desktop or fabricate a recording. If capture is unavailable, the agent reports the blocker.
|
|
101
|
-
|
|
102
|
-
`AdapterClient.uploadFile` transport
|
|
101
|
+
ACP mounts these tools through its MCP bridge; custom SDK adapters can use the same
|
|
102
|
+
`AdapterClient.uploadFile` transport directly.
|
|
103
103
|
|
|
104
104
|
This follows Slack's [file upload sequence](https://docs.slack.dev/messaging/working-with-files/):
|
|
105
105
|
reserve, transfer bytes, finalize, then share a durable file reference. For the intended user
|
package/dist/src/adapter.js
CHANGED
|
@@ -20,7 +20,7 @@ const urlPattern = /https?:\/\/[^\s"'<>]+/gi;
|
|
|
20
20
|
const absolutePathPattern = /\B\/(?:[\w.-]+\/)+[\w.-]*\b/g;
|
|
21
21
|
const providerErrorDetailLimit = 300;
|
|
22
22
|
export const adapterMediaCapabilities = {
|
|
23
|
-
acp: { image: "unsupported", voice: "
|
|
23
|
+
acp: { image: "unsupported", voice: "transcript", video: "unsupported", files: "download" },
|
|
24
24
|
claude: { image: "native", voice: "transcript", video: "unsupported", files: "download" },
|
|
25
25
|
codex: { image: "native", voice: "transcript", video: "unsupported", files: "download" },
|
|
26
26
|
custom: { image: "unsupported", voice: "unsupported", video: "unsupported", files: "unsupported" },
|
|
@@ -3,6 +3,7 @@ import { prepareProviderInput, withMediaFallbacks } from "../../media-input.js";
|
|
|
3
3
|
import { deliverAdapterOutput, describeIncomingPieces, describeVocabulary } from "../../output-vocabulary.js";
|
|
4
4
|
import { handleAcpPermission, mergeToolCall, } from "./acp-permission-mapper.js";
|
|
5
5
|
import { AcpStdioRuntime, } from "./acp-runtime.js";
|
|
6
|
+
import { startAcpToolBridge } from "./acp-tool-bridge.js";
|
|
6
7
|
export class AcpAdapter {
|
|
7
8
|
kind = "acp";
|
|
8
9
|
version = "0.1.0";
|
|
@@ -34,6 +35,7 @@ export class AcpAdapter {
|
|
|
34
35
|
return { status: "aborted" };
|
|
35
36
|
}
|
|
36
37
|
const runtime = this.#runtime ?? new AcpStdioRuntime({ config: this.#config, cwd: this.#cwd });
|
|
38
|
+
let bridge;
|
|
37
39
|
let sessionId;
|
|
38
40
|
let cancelRequested = false;
|
|
39
41
|
let cancellation;
|
|
@@ -45,11 +47,12 @@ export class AcpAdapter {
|
|
|
45
47
|
};
|
|
46
48
|
try {
|
|
47
49
|
const initialized = await runtime.initialize();
|
|
50
|
+
bridge = await startAcpToolBridge(context, this.#cwd, signal, `agent "${this.#config.id}"`);
|
|
48
51
|
this.#negotiatedCapabilities = structuredClone(initialized.agentCapabilities ?? {});
|
|
49
52
|
const supportsLoadSession = this.#negotiatedCapabilities.loadSession === true;
|
|
50
53
|
const createsFreshSession = context.externalSessionId === null || !supportsLoadSession;
|
|
51
54
|
if (createsFreshSession) {
|
|
52
|
-
const session = await runtime.newSession({ cwd: this.#cwd });
|
|
55
|
+
const session = await runtime.newSession({ cwd: this.#cwd, mcpServers: [bridge.descriptor] });
|
|
53
56
|
sessionId = session.sessionId;
|
|
54
57
|
}
|
|
55
58
|
else {
|
|
@@ -60,6 +63,7 @@ export class AcpAdapter {
|
|
|
60
63
|
await runtime.loadSession({
|
|
61
64
|
sessionId,
|
|
62
65
|
cwd: this.#cwd,
|
|
66
|
+
mcpServers: [bridge.descriptor],
|
|
63
67
|
});
|
|
64
68
|
}
|
|
65
69
|
if (signal.aborted) {
|
|
@@ -137,6 +141,7 @@ export class AcpAdapter {
|
|
|
137
141
|
}
|
|
138
142
|
finally {
|
|
139
143
|
signal.removeEventListener("abort", cancel);
|
|
144
|
+
await bridge?.close();
|
|
140
145
|
await cancellation;
|
|
141
146
|
if (this.#runtime === undefined) {
|
|
142
147
|
await runtime.close?.().catch(() => undefined);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
|
+
import { request as httpRequest } from "node:http";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { CallToolRequestSchema, CallToolResultSchema, ListToolsRequestSchema, ListToolsResultSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
+
const url = new URL(process.env.SHOWRUNNER_TOOL_BRIDGE_URL ?? "");
|
|
6
|
+
const token = process.env.SHOWRUNNER_TOOL_BRIDGE_TOKEN;
|
|
7
|
+
if (url.protocol !== "http:" || url.hostname !== "127.0.0.1" || !token) {
|
|
8
|
+
throw new Error("Missing local Showrunner tool bridge.");
|
|
9
|
+
}
|
|
10
|
+
const lifetime = new AbortController();
|
|
11
|
+
process.stdin.once("end", () => lifetime.abort());
|
|
12
|
+
const server = new Server({ name: "showrunner", version: "1.0.0" }, { capabilities: { tools: {} } });
|
|
13
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ListToolsResultSchema.parse(await request("/tools")));
|
|
14
|
+
server.setRequestHandler(CallToolRequestSchema, async (input, extra) => CallToolResultSchema.parse(await request("/call", input.params, extra.signal)));
|
|
15
|
+
await server.connect(new StdioServerTransport());
|
|
16
|
+
function request(path, body, signal) {
|
|
17
|
+
// node:http has no implicit response-header timeout while an owner considers an approval.
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
const outgoing = httpRequest(new URL(path, url), {
|
|
20
|
+
method: body === undefined ? "GET" : "POST",
|
|
21
|
+
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
|
|
22
|
+
signal: AbortSignal.any([lifetime.signal, AbortSignal.timeout(3_600_000), ...(signal ? [signal] : [])]),
|
|
23
|
+
}, response => {
|
|
24
|
+
if (response.statusCode !== 200) {
|
|
25
|
+
response.resume();
|
|
26
|
+
reject(new Error("Showrunner tool bridge request failed."));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
response.setEncoding("utf8");
|
|
30
|
+
let content = "";
|
|
31
|
+
response.on("data", chunk => { content += chunk; });
|
|
32
|
+
response.once("error", reject);
|
|
33
|
+
response.once("end", () => {
|
|
34
|
+
try {
|
|
35
|
+
resolve(JSON.parse(content));
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
reject(new Error("Invalid Showrunner tool bridge response."));
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
outgoing.once("error", reject);
|
|
43
|
+
outgoing.end(body === undefined ? undefined : JSON.stringify(body));
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { requestHostToolApproval, sanitizeApprovalText } from "../../adapter.js";
|
|
2
|
+
import { agentToolName } from "../../agent-tools.js";
|
|
2
3
|
import { defaultAcpToolKindMap } from "./acp-config.js";
|
|
3
4
|
export async function handleAcpPermission(event, runtime, context, signal, toolCalls, config, workspaceRoot) {
|
|
4
5
|
const toolCallId = event.correlatedToolCallId;
|
|
@@ -8,6 +9,20 @@ export async function handleAcpPermission(event, runtime, context, signal, toolC
|
|
|
8
9
|
}
|
|
9
10
|
const pending = toolCalls.get(toolCallId);
|
|
10
11
|
const toolCall = mergeToolCall(pending, event.request.toolCall);
|
|
12
|
+
const name = toolCall.name;
|
|
13
|
+
const qualified = name?.startsWith("mcp__showrunner__")
|
|
14
|
+
? name.slice("mcp__showrunner__".length)
|
|
15
|
+
: name?.startsWith("mcp_showrunner_") ? name.slice("mcp_showrunner_".length) : undefined;
|
|
16
|
+
// Only a structured tool name identifies the bridge. Titles and call ids are display/correlation
|
|
17
|
+
// fields and must not turn a host permission into an implicitly allowed Showrunner call.
|
|
18
|
+
if (qualified !== undefined && agentToolName(qualified) !== undefined &&
|
|
19
|
+
(toolCall.kind === undefined || toolCall.kind === "other")) {
|
|
20
|
+
const option = signal.aborted ? undefined : permissionOption(event.request.options, true, true);
|
|
21
|
+
await runtime.respondPermission(event.requestId, toolCallId, option === undefined
|
|
22
|
+
? { outcome: { outcome: "cancelled" } }
|
|
23
|
+
: { outcome: { outcome: "selected", optionId: option.optionId } });
|
|
24
|
+
return option !== undefined;
|
|
25
|
+
}
|
|
11
26
|
const hostRequest = hostRequestFor(toolCall, config, workspaceRoot);
|
|
12
27
|
const approval = await requestHostToolApproval(context, hostRequest, {
|
|
13
28
|
title: safeText(`Allow ACP agent to use ${hostRequest.toolName}?`, 120),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type InitializeResponse, type NewSessionResponse, type PromptResponse, type RequestPermissionRequest, type RequestPermissionResponse, type SessionNotification } from "@agentclientprotocol/sdk";
|
|
1
|
+
import { type InitializeResponse, type McpServer, type NewSessionResponse, type PromptResponse, type RequestPermissionRequest, type RequestPermissionResponse, type SessionNotification } from "@agentclientprotocol/sdk";
|
|
2
2
|
import type { AcpAgentConfig } from "./acp-config.js";
|
|
3
3
|
export type AcpRuntimeEvent = {
|
|
4
4
|
type: "session.update";
|
|
@@ -18,10 +18,12 @@ export interface AcpRuntime {
|
|
|
18
18
|
initialize(): Promise<InitializeResponse>;
|
|
19
19
|
newSession(input: {
|
|
20
20
|
cwd: string;
|
|
21
|
+
mcpServers: McpServer[];
|
|
21
22
|
}): Promise<NewSessionResponse>;
|
|
22
23
|
loadSession(input: {
|
|
23
24
|
sessionId: string;
|
|
24
25
|
cwd: string;
|
|
26
|
+
mcpServers: McpServer[];
|
|
25
27
|
}): Promise<void>;
|
|
26
28
|
prompt(input: {
|
|
27
29
|
sessionId: string;
|
|
@@ -40,10 +42,12 @@ export declare class AcpStdioRuntime implements AcpRuntime {
|
|
|
40
42
|
initialize(): Promise<InitializeResponse>;
|
|
41
43
|
newSession(input: {
|
|
42
44
|
cwd: string;
|
|
45
|
+
mcpServers: McpServer[];
|
|
43
46
|
}): Promise<NewSessionResponse>;
|
|
44
47
|
loadSession(input: {
|
|
45
48
|
sessionId: string;
|
|
46
49
|
cwd: string;
|
|
50
|
+
mcpServers: McpServer[];
|
|
47
51
|
}): Promise<void>;
|
|
48
52
|
prompt(input: {
|
|
49
53
|
sessionId: string;
|
|
@@ -28,14 +28,14 @@ export class AcpStdioRuntime {
|
|
|
28
28
|
newSession(input) {
|
|
29
29
|
return this.#connect().newSession({
|
|
30
30
|
cwd: input.cwd,
|
|
31
|
-
mcpServers:
|
|
31
|
+
mcpServers: input.mcpServers,
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
async loadSession(input) {
|
|
35
35
|
await this.#connect().loadSession({
|
|
36
36
|
sessionId: input.sessionId,
|
|
37
37
|
cwd: input.cwd,
|
|
38
|
-
mcpServers:
|
|
38
|
+
mcpServers: input.mcpServers,
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
async *prompt(input, _signal) {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AgentInvocationContext } from "../../adapter.js";
|
|
2
|
+
export declare function startAcpToolBridge(context: AgentInvocationContext, cwd: string, signal: AbortSignal, agentName: string): Promise<{
|
|
3
|
+
descriptor: import("@agentclientprotocol/sdk").McpServerStdio;
|
|
4
|
+
close(): Promise<void>;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { createServer } from "node:http";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { agentToolDefinitions, agentToolName, authorizeAgentTool, executeAgentTool } from "../../agent-tools.js";
|
|
6
|
+
const callSchema = z.object({ name: z.string(), arguments: z.record(z.string(), z.unknown()).default({}) });
|
|
7
|
+
const maxRequestBytes = 1024 * 1024;
|
|
8
|
+
// ACP launches an MCP subprocess. Only this invocation's authenticated loopback endpoint can
|
|
9
|
+
// turn its calls into Showrunner actions; connector credentials never leave the parent process.
|
|
10
|
+
export async function startAcpToolBridge(context, cwd, signal, agentName) {
|
|
11
|
+
const token = randomBytes(32).toString("hex");
|
|
12
|
+
const lifetime = new AbortController();
|
|
13
|
+
const active = AbortSignal.any([signal, lifetime.signal]);
|
|
14
|
+
const server = createServer((request, response) => {
|
|
15
|
+
handle(request, response).catch(() => {
|
|
16
|
+
if (!response.headersSent)
|
|
17
|
+
response.writeHead(500);
|
|
18
|
+
response.end();
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
server.requestTimeout = 30_000;
|
|
22
|
+
server.headersTimeout = 10_000;
|
|
23
|
+
await new Promise((resolve, reject) => {
|
|
24
|
+
server.once("error", reject);
|
|
25
|
+
server.listen(0, "127.0.0.1", resolve);
|
|
26
|
+
});
|
|
27
|
+
const address = server.address();
|
|
28
|
+
if (address === null || typeof address === "string")
|
|
29
|
+
throw new Error("ACP tool bridge failed to listen.");
|
|
30
|
+
const url = `http://127.0.0.1:${address.port}`;
|
|
31
|
+
const source = import.meta.url.endsWith(".ts");
|
|
32
|
+
const descriptor = {
|
|
33
|
+
name: "showrunner",
|
|
34
|
+
command: process.execPath,
|
|
35
|
+
args: [
|
|
36
|
+
...(source ? ["--import", fileURLToPath(import.meta.resolve("tsx"))] : []),
|
|
37
|
+
fileURLToPath(new URL(`./acp-mcp-stdio.${source ? "ts" : "js"}`, import.meta.url)),
|
|
38
|
+
],
|
|
39
|
+
env: [
|
|
40
|
+
{ name: "SHOWRUNNER_TOOL_BRIDGE_URL", value: url },
|
|
41
|
+
{ name: "SHOWRUNNER_TOOL_BRIDGE_TOKEN", value: token },
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
async function handle(request, response) {
|
|
45
|
+
const disconnected = new AbortController();
|
|
46
|
+
response.once("close", () => {
|
|
47
|
+
if (!response.writableFinished)
|
|
48
|
+
disconnected.abort();
|
|
49
|
+
});
|
|
50
|
+
const callSignal = AbortSignal.any([active, disconnected.signal]);
|
|
51
|
+
response.setHeader("Connection", "close");
|
|
52
|
+
if (active.aborted || request.headers.authorization !== `Bearer ${token}` || request.headers.origin !== undefined) {
|
|
53
|
+
response.writeHead(403).end();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (request.method === "GET" && request.url === "/tools") {
|
|
57
|
+
response.setHeader("Content-Type", "application/json");
|
|
58
|
+
response.end(JSON.stringify({ tools: agentToolDefinitions }));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (request.method !== "POST" || request.url !== "/call") {
|
|
62
|
+
response.writeHead(404).end();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const chunks = [];
|
|
66
|
+
let size = 0;
|
|
67
|
+
for await (const chunk of request) {
|
|
68
|
+
const bytes = Buffer.from(chunk);
|
|
69
|
+
size += bytes.length;
|
|
70
|
+
if (size > maxRequestBytes) {
|
|
71
|
+
response.writeHead(413).end();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
chunks.push(bytes);
|
|
75
|
+
}
|
|
76
|
+
const input = callSchema.safeParse(JSON.parse(Buffer.concat(chunks).toString("utf8")));
|
|
77
|
+
const name = input.success ? agentToolName(input.data.name) : undefined;
|
|
78
|
+
if (!input.success || name === undefined) {
|
|
79
|
+
response.writeHead(400).end();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const allowed = await authorizeAgentTool(context, agentName, name, input.data.arguments, callSignal);
|
|
83
|
+
const result = allowed && !callSignal.aborted
|
|
84
|
+
? await executeAgentTool(context, name, input.data.arguments, cwd, callSignal)
|
|
85
|
+
: { success: false, text: JSON.stringify({ error: "not_authorized" }) };
|
|
86
|
+
response.setHeader("Content-Type", "application/json");
|
|
87
|
+
response.end(JSON.stringify({ content: [{ type: "text", text: result.text }], isError: !result.success }));
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
descriptor,
|
|
91
|
+
async close() {
|
|
92
|
+
lifetime.abort();
|
|
93
|
+
server.closeAllConnections();
|
|
94
|
+
await new Promise((resolve, reject) => server.close((error) => error ? reject(error) : resolve()));
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { AgentInvocationContext, HostToolCapability } from "./adapter.js";
|
|
3
3
|
/**
|
|
4
|
-
* Every Showrunner limb an external agent can reach, mounted
|
|
4
|
+
* Every Showrunner limb an external agent can reach, mounted by the provider adapters.
|
|
5
5
|
* Order matters only for prompt readability: expression first, then reading.
|
|
6
6
|
*/
|
|
7
7
|
export declare const agentToolSchemas: {
|
|
@@ -413,7 +413,7 @@ export declare const agentToolDefinitions: {
|
|
|
413
413
|
export declare function agentToolName(value: string): AgentToolName | undefined;
|
|
414
414
|
export declare function agentToolDescription(name: AgentToolName): string;
|
|
415
415
|
export declare function capabilityForAgentTool(name: AgentToolName): HostToolCapability;
|
|
416
|
-
export declare function authorizeAgentTool(context: AgentInvocationContext, provider:
|
|
416
|
+
export declare function authorizeAgentTool(context: AgentInvocationContext, provider: string, name: AgentToolName, input: Record<string, unknown>, signal?: AbortSignal): Promise<boolean>;
|
|
417
417
|
export declare function executeAgentTool(context: AgentInvocationContext, name: AgentToolName, untrusted: unknown, workspaceRoot?: string, signal?: AbortSignal, downloadDirectory?: string): Promise<{
|
|
418
418
|
success: boolean;
|
|
419
419
|
text: string;
|
package/dist/src/agent-tools.js
CHANGED
|
@@ -6,7 +6,7 @@ import { capabilityForFileTool, executeFileTool, fileToolDescription, fileToolEf
|
|
|
6
6
|
import { capabilityForNoteTool, executeNoteTool, noteToolDescription, noteToolEffect, noteToolNames, noteToolSchemas, } from "./note-tools.js";
|
|
7
7
|
import { capabilityForTodoTool, executeTodoTool, todoToolDescription, todoToolEffect, todoToolNames, todoToolSchemas, } from "./todo-tools.js";
|
|
8
8
|
/**
|
|
9
|
-
* Every Showrunner limb an external agent can reach, mounted
|
|
9
|
+
* Every Showrunner limb an external agent can reach, mounted by the provider adapters.
|
|
10
10
|
* Order matters only for prompt readability: expression first, then reading.
|
|
11
11
|
*/
|
|
12
12
|
export const agentToolSchemas = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "showrunner-agent-staging",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2-staging.1540",
|
|
4
4
|
"description": "Provider-neutral connector SDK for Showrunner agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"@agentclientprotocol/sdk": "^1.3.0",
|
|
26
26
|
"@anthropic-ai/claude-agent-sdk": "^0.3.217",
|
|
27
27
|
"@microsoft/signalr": "^9.0.0",
|
|
28
|
+
"@modelcontextprotocol/sdk": "^1.31.0",
|
|
28
29
|
"@showrunner/agent-contracts": "file:../shared/agent-contracts",
|
|
29
30
|
"env-paths": "^3.0.0",
|
|
30
31
|
"sharp": "^0.34.5",
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
3
|
+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
2
4
|
import * as acp from "@agentclientprotocol/sdk";
|
|
3
5
|
import { appendFileSync } from "node:fs";
|
|
4
6
|
import { Readable, Writable } from "node:stream";
|
|
@@ -36,13 +38,13 @@ async function initialize() {
|
|
|
36
38
|
|
|
37
39
|
async function newSession(params) {
|
|
38
40
|
const sessionId = `reference-session-${++nextSession}`;
|
|
39
|
-
sessions.set(sessionId, { cancel: null });
|
|
41
|
+
sessions.set(sessionId, { cancel: null, mcpServers: params.mcpServers });
|
|
40
42
|
trace("session/new", { sessionId, cwd: params.cwd });
|
|
41
43
|
return { sessionId };
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
async function loadSession(params) {
|
|
45
|
-
sessions.set(params.sessionId, { cancel: null });
|
|
47
|
+
sessions.set(params.sessionId, { cancel: null, mcpServers: params.mcpServers });
|
|
46
48
|
trace("session/load", { sessionId: params.sessionId, cwd: params.cwd });
|
|
47
49
|
return {};
|
|
48
50
|
}
|
|
@@ -62,6 +64,38 @@ async function prompt(params, client) {
|
|
|
62
64
|
hasVocabulary: text.includes("## Showrunner output format"),
|
|
63
65
|
});
|
|
64
66
|
|
|
67
|
+
if (scenario === "showrunner-tools") {
|
|
68
|
+
const descriptor = session.mcpServers.find(server => server.name === "showrunner");
|
|
69
|
+
if (!descriptor) throw new Error("Showrunner MCP server was not supplied");
|
|
70
|
+
const mcp = new Client({ name: "fake-acp-agent", version: "1.0.0" });
|
|
71
|
+
try {
|
|
72
|
+
await mcp.connect(new StdioClientTransport({
|
|
73
|
+
...descriptor,
|
|
74
|
+
env: Object.fromEntries(descriptor.env.map(({ name, value }) => [name, value])),
|
|
75
|
+
}));
|
|
76
|
+
const tools = await mcp.listTools();
|
|
77
|
+
trace("showrunner/tools", { names: tools.tools.map(tool => tool.name) });
|
|
78
|
+
for (const name of ["read_thread", "create_task"]) {
|
|
79
|
+
const permission = await client.requestPermission({
|
|
80
|
+
sessionId: params.sessionId,
|
|
81
|
+
toolCall: { toolCallId: `bridge-${name}`, name: `mcp__showrunner__${name}`,
|
|
82
|
+
title: name, kind: "other", status: "pending" },
|
|
83
|
+
options: permissionOptions(),
|
|
84
|
+
});
|
|
85
|
+
if (permission.outcome.outcome !== "selected" || permission.outcome.optionId !== "allow-once") {
|
|
86
|
+
throw new Error("Showrunner bridge permission was not allowed once");
|
|
87
|
+
}
|
|
88
|
+
const result = await mcp.callTool({ name, arguments: name === "read_thread"
|
|
89
|
+
? {} : { pieces: [{ type: "text", text: "Follow up" }] } });
|
|
90
|
+
if (name === "read_thread" && result.isError) throw new Error("Showrunner read failed");
|
|
91
|
+
}
|
|
92
|
+
await message(client, params.sessionId, "Read the conversation using Showrunner tools");
|
|
93
|
+
} finally {
|
|
94
|
+
await mcp.close();
|
|
95
|
+
}
|
|
96
|
+
return promptResponse("end_turn");
|
|
97
|
+
}
|
|
98
|
+
|
|
65
99
|
if (scenario === "abort") {
|
|
66
100
|
await new Promise((resolve) => {
|
|
67
101
|
session.cancel = resolve;
|