@introspection-ai/recipes 0.48.0 → 0.50.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/dist/api/mcp.d.ts +1 -0
- package/dist/api/mcp.d.ts.map +1 -1
- package/dist/api/mcp.js +1 -0
- package/dist/api/mcp.js.map +1 -1
- package/dist/channels/tools.d.ts.map +1 -1
- package/dist/channels/tools.js +2 -17
- package/dist/channels/tools.js.map +1 -1
- package/dist/command-parameters.d.ts +10 -0
- package/dist/command-parameters.d.ts.map +1 -0
- package/dist/command-parameters.js +25 -0
- package/dist/command-parameters.js.map +1 -0
- package/dist/connector-tools.d.ts +1 -1
- package/dist/connector-tools.d.ts.map +1 -1
- package/dist/connector-tools.js +12 -1
- package/dist/connector-tools.js.map +1 -1
- package/dist/documents/module.js +1 -1
- package/dist/documents/module.js.map +1 -1
- package/dist/documents/profile.d.ts +1 -1
- package/dist/documents/profile.js +1 -1
- package/dist/extensions.d.ts +1 -1
- package/dist/extensions.d.ts.map +1 -1
- package/dist/extensions.js +23 -2
- package/dist/extensions.js.map +1 -1
- package/dist/introspection-open.d.ts +46 -0
- package/dist/introspection-open.d.ts.map +1 -0
- package/dist/introspection-open.js +278 -0
- package/dist/introspection-open.js.map +1 -0
- package/dist/mcp/index.d.ts +37 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +14 -4
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/pi-client.d.ts +97 -0
- package/dist/mcp/pi-client.d.ts.map +1 -0
- package/dist/mcp/pi-client.js +342 -0
- package/dist/mcp/pi-client.js.map +1 -0
- package/dist/mcp/policy.d.ts +2 -0
- package/dist/mcp/policy.d.ts.map +1 -1
- package/dist/mcp/policy.js +6 -0
- package/dist/mcp/policy.js.map +1 -1
- package/dist/mcp-chunks/{chunk-3M4OCQR5.js → chunk-PO2SOBEN.js} +1 -0
- package/dist/mcp-daemon.js +1 -1
- package/dist/mcp-run-worker.js +1 -1
- package/dist/open.d.ts +82 -0
- package/dist/open.d.ts.map +1 -0
- package/dist/open.js +152 -0
- package/dist/open.js.map +1 -0
- package/dist/pi-extension.d.ts.map +1 -1
- package/dist/pi-extension.js +99 -8
- package/dist/pi-extension.js.map +1 -1
- package/dist/productivity/content.d.ts +25 -0
- package/dist/productivity/content.d.ts.map +1 -0
- package/dist/productivity/content.js +94 -0
- package/dist/productivity/content.js.map +1 -0
- package/dist/productivity/handles.d.ts +72 -0
- package/dist/productivity/handles.d.ts.map +1 -0
- package/dist/productivity/handles.js +111 -0
- package/dist/productivity/handles.js.map +1 -0
- package/dist/productivity/http.d.ts +35 -0
- package/dist/productivity/http.d.ts.map +1 -0
- package/dist/productivity/http.js +216 -0
- package/dist/productivity/http.js.map +1 -0
- package/dist/productivity/index.d.ts +11 -0
- package/dist/productivity/index.d.ts.map +1 -0
- package/dist/productivity/index.js +7 -0
- package/dist/productivity/index.js.map +1 -0
- package/dist/productivity/module.d.ts +63 -0
- package/dist/productivity/module.d.ts.map +1 -0
- package/dist/productivity/module.js +121 -0
- package/dist/productivity/module.js.map +1 -0
- package/dist/productivity/paging.d.ts +32 -0
- package/dist/productivity/paging.d.ts.map +1 -0
- package/dist/productivity/paging.js +42 -0
- package/dist/productivity/paging.js.map +1 -0
- package/dist/productivity/tools.d.ts +40 -0
- package/dist/productivity/tools.d.ts.map +1 -0
- package/dist/productivity/tools.js +969 -0
- package/dist/productivity/tools.js.map +1 -0
- package/dist/productivity/types.d.ts +538 -0
- package/dist/productivity/types.d.ts.map +1 -0
- package/dist/productivity/types.js +119 -0
- package/dist/productivity/types.js.map +1 -0
- package/dist/recipe/agent.d.ts +6 -1
- package/dist/recipe/agent.d.ts.map +1 -1
- package/dist/recipe/agent.js +48 -7
- package/dist/recipe/agent.js.map +1 -1
- package/dist/recipe/companions.d.ts.map +1 -1
- package/dist/recipe/companions.js +5 -4
- package/dist/recipe/companions.js.map +1 -1
- package/dist/recipe/manifest.generated.d.ts +3 -1
- package/dist/recipe/manifest.generated.d.ts.map +1 -1
- package/dist/recipe/manifest.generated.js +4 -2
- package/dist/recipe/manifest.generated.js.map +1 -1
- package/dist/recipe/package.d.ts +12 -0
- package/dist/recipe/package.d.ts.map +1 -1
- package/dist/recipe/package.js +93 -0
- package/dist/recipe/package.js.map +1 -1
- package/dist/review.d.ts +1 -0
- package/dist/review.d.ts.map +1 -1
- package/dist/review.js +1 -0
- package/dist/review.js.map +1 -1
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +175 -15
- package/dist/session.js.map +1 -1
- package/dist/skill-progress.d.ts.map +1 -1
- package/dist/skill-progress.js +5 -1
- package/dist/skill-progress.js.map +1 -1
- package/dist/tool-search.d.ts +2 -2
- package/dist/tool-search.d.ts.map +1 -1
- package/dist/tool-search.js +4 -2
- package/dist/tool-search.js.map +1 -1
- package/docs/{index.md → README.md} +9 -3
- package/docs/{slack.md → channels/slack.md} +1 -1
- package/docs/{documents.md → documents/README.md} +4 -4
- package/docs/interactions.md +90 -31
- package/docs/mcp-configuration.md +76 -2
- package/docs/productivity/README.md +360 -0
- package/docs/productivity/google.md +226 -0
- package/docs/productivity/microsoft.md +143 -0
- package/docs/recipe-format.md +40 -16
- package/docs/recipe-judges.md +8 -4
- package/package.json +14 -8
- package/skills/README.md +12 -0
- package/skills/productivity/SKILL.md +76 -0
- /package/docs/{channels.md → channels/README.md} +0 -0
- /package/{documents → skills/documents}/SKILL.md +0 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { type ExtensionAPI, type ExtensionFactory, type McpServerConfig, type ToolDefinition, type ToolNamespace } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { RecipeAgentMcp } from "../recipe/agent.js";
|
|
3
|
+
import { type McpEndpointBinding, type McpSessionConfig, type McpSessionServer } from "./index.js";
|
|
4
|
+
/** Pi's MCP resource tools, which no Recipe declares. */
|
|
5
|
+
export declare const PI_MCP_RESOURCE_TOOL_NAMES: readonly ["list_mcp_resources", "list_mcp_resource_templates", "read_mcp_resource"];
|
|
6
|
+
/**
|
|
7
|
+
* The Pi tool name of an MCP tool under `mcp.mode: codemode`, the name a
|
|
8
|
+
* codemode script calls (`tools.<name>`) and `ctx.executeTool()` takes. It is
|
|
9
|
+
* Pi's own rule (`createMcpToolName`, which Pi does not export):
|
|
10
|
+
* `mcp__<server>__<tool>`, every character outside `[A-Za-z0-9_]` replaced by
|
|
11
|
+
* `_`, and a hash suffix past 64 characters. Pi also adds the suffix when two
|
|
12
|
+
* of a server's tools sanitize to one name, which this cannot know; match a
|
|
13
|
+
* registered tool to its server with {@link isPiMcpServerTool}, never by name.
|
|
14
|
+
*/
|
|
15
|
+
export declare function mcpToolName(serverId: string, toolName: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* A prefix of every Pi tool name of the server's tools, hashed or not: a
|
|
18
|
+
* hashed name keeps the first 55 characters of the sanitized full name, and
|
|
19
|
+
* the sanitized `mcp__<server>__` cut at 55 is a prefix of those. It can also
|
|
20
|
+
* prefix another server's tools (`a` and `a__b`, or two ids that agree on
|
|
21
|
+
* their first 48 characters), so it only narrows a name allowlist; it never
|
|
22
|
+
* says which server a tool is from.
|
|
23
|
+
*/
|
|
24
|
+
export declare function piMcpToolNamePrefix(serverId: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Whether Pi registered the tool for this MCP server. Pi gives every MCP tool
|
|
27
|
+
* the server's namespace, aliased by the server's name, and refuses a second
|
|
28
|
+
* server whose namespace would clash, so this is exact where a name prefix is
|
|
29
|
+
* not.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isPiMcpServerTool(tool: {
|
|
32
|
+
namespace?: ToolNamespace;
|
|
33
|
+
}, serverId: string): boolean;
|
|
34
|
+
/** Refuses `mcp.mode: codemode` on a Pi older than {@link PI_MCP_CODEMODE_MIN_VERSION}. */
|
|
35
|
+
export declare function assertPiSupportsMcpCodemode(version?: string): void;
|
|
36
|
+
export interface PiMcpServerRegistration {
|
|
37
|
+
id: string;
|
|
38
|
+
required: boolean;
|
|
39
|
+
/** The package marks the server's discovery deferrable (a bake may start without it). */
|
|
40
|
+
deferrableDiscovery: boolean;
|
|
41
|
+
/** The tools whose calls alone may reach the server (`behind`). */
|
|
42
|
+
behind?: readonly string[];
|
|
43
|
+
config: McpServerConfig;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Pi server configs for the servers this agent may use: the session's bound
|
|
47
|
+
* servers, their URLs and headers from the bindings, and the agent's policy as
|
|
48
|
+
* Pi exposures. Allowed tools are reachable from codemode scripts, `eager`
|
|
49
|
+
* ones are also declared to the model, and every other tool is hidden.
|
|
50
|
+
*/
|
|
51
|
+
export declare function piMcpServerRegistrations(options: {
|
|
52
|
+
session: McpSessionConfig;
|
|
53
|
+
bindings: readonly McpEndpointBinding[];
|
|
54
|
+
mcp: RecipeAgentMcp;
|
|
55
|
+
env: NodeJS.ProcessEnv;
|
|
56
|
+
}): PiMcpServerRegistration[];
|
|
57
|
+
/**
|
|
58
|
+
* Pi's MCP extension for a Recipe session: no `mcp.json` is read, no OAuth
|
|
59
|
+
* state is kept, and server logs go to `logPath`.
|
|
60
|
+
*/
|
|
61
|
+
export declare function createRecipeMcpClientExtension(logPath: string): ExtensionFactory;
|
|
62
|
+
/** Registers the servers with Pi's MCP support, keeping the API for `waitForPiMcpServers`. */
|
|
63
|
+
export declare function createPiMcpServersExtension(registrations: readonly PiMcpServerRegistration[], onRegistered?: (pi: ExtensionAPI) => void): ExtensionFactory;
|
|
64
|
+
/**
|
|
65
|
+
* Waits until each server has registered a tool, which Pi does once it has
|
|
66
|
+
* connected and listed them, and throws naming those that did not in time.
|
|
67
|
+
* Pi connects every server in the background when the session starts.
|
|
68
|
+
*/
|
|
69
|
+
export declare function waitForPiMcpServers(pi: Pick<ExtensionAPI, "getAllTools">, serverIds: readonly string[], env: NodeJS.ProcessEnv, signal?: AbortSignal): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* The server and tool a Pi MCP tool stands for, for telemetry: the server from
|
|
72
|
+
* the tool's namespace, the tool from Pi's `<server>/<tool>` label.
|
|
73
|
+
*/
|
|
74
|
+
export declare function piMcpToolOrigin(session: McpSessionConfig, tool: Pick<ToolDefinition, "label" | "namespace"> | undefined): {
|
|
75
|
+
serverId: string;
|
|
76
|
+
toolName: string;
|
|
77
|
+
binding?: McpSessionServer["binding"];
|
|
78
|
+
} | undefined;
|
|
79
|
+
type BehindServer = Pick<PiMcpServerRegistration, "id" | "behind">;
|
|
80
|
+
/** The server kept behind tools that a Pi tool belongs to, if any. */
|
|
81
|
+
export declare function serverBehindTools(servers: readonly BehindServer[], tool: {
|
|
82
|
+
namespace?: ToolNamespace;
|
|
83
|
+
} | undefined): BehindServer | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Keeps each server registered with `behind` behind its tools: a call to one
|
|
86
|
+
* of its tools is refused unless a tool named in `behind` issued it, directly
|
|
87
|
+
* or through calls nested inside that tool's call. The model, codemode scripts
|
|
88
|
+
* and every other tool are refused.
|
|
89
|
+
*/
|
|
90
|
+
export declare function createMcpBehindGuard(servers: () => readonly BehindServer[]): ExtensionFactory;
|
|
91
|
+
/**
|
|
92
|
+
* Drops the servers kept behind tools from Pi's `mcp_servers` prompt section,
|
|
93
|
+
* from a `before_agent_start` handler that runs after Pi's MCP extension's.
|
|
94
|
+
*/
|
|
95
|
+
export declare function hideServersBehindTools(sections: Record<string, string>, servers: readonly BehindServer[]): void;
|
|
96
|
+
export {};
|
|
97
|
+
//# sourceMappingURL=pi-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi-client.d.ts","sourceRoot":"","sources":["../../src/mcp/pi-client.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EAGrB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,aAAa,EAEnB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAA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ding-agent";
|
|
3
|
+
import { mcpSelectionAllowsTool } from "./policy.js";
|
|
4
|
+
import { explicitAllowedTools, interpolateEnv, mcpSessionAllowsTool, } from "./index.js";
|
|
5
|
+
const MCP_CONNECT_TIMEOUT_ENV = "PI_RECIPES_MCP_CONNECT_TIMEOUT_MS";
|
|
6
|
+
const DEFAULT_CONNECT_TIMEOUT_MS = 30_000;
|
|
7
|
+
const DEFAULT_CALL_TIMEOUT_MS = 120_000;
|
|
8
|
+
const CONNECT_POLL_MS = 50;
|
|
9
|
+
// Pi's limit for a tool name, which its MCP tool names are shortened to by
|
|
10
|
+
// keeping the start and adding `_` and this many hex digits of a hash.
|
|
11
|
+
const MAX_TOOL_NAME_LENGTH = 64;
|
|
12
|
+
const HASH_LENGTH = 8;
|
|
13
|
+
/** Pi's MCP resource tools, which no Recipe declares. */
|
|
14
|
+
export const PI_MCP_RESOURCE_TOOL_NAMES = [
|
|
15
|
+
"list_mcp_resources",
|
|
16
|
+
"list_mcp_resource_templates",
|
|
17
|
+
"read_mcp_resource",
|
|
18
|
+
];
|
|
19
|
+
/**
|
|
20
|
+
* The Pi tool name of an MCP tool under `mcp.mode: codemode`, the name a
|
|
21
|
+
* codemode script calls (`tools.<name>`) and `ctx.executeTool()` takes. It is
|
|
22
|
+
* Pi's own rule (`createMcpToolName`, which Pi does not export):
|
|
23
|
+
* `mcp__<server>__<tool>`, every character outside `[A-Za-z0-9_]` replaced by
|
|
24
|
+
* `_`, and a hash suffix past 64 characters. Pi also adds the suffix when two
|
|
25
|
+
* of a server's tools sanitize to one name, which this cannot know; match a
|
|
26
|
+
* registered tool to its server with {@link isPiMcpServerTool}, never by name.
|
|
27
|
+
*/
|
|
28
|
+
export function mcpToolName(serverId, toolName) {
|
|
29
|
+
const name = `mcp__${serverId}__${toolName}`.replace(/[^A-Za-z0-9_]/g, "_");
|
|
30
|
+
if (name.length <= MAX_TOOL_NAME_LENGTH)
|
|
31
|
+
return name;
|
|
32
|
+
const hash = createHash("sha256")
|
|
33
|
+
.update(`${serverId}\0${toolName}`)
|
|
34
|
+
.digest("hex")
|
|
35
|
+
.slice(0, HASH_LENGTH);
|
|
36
|
+
return `${name.slice(0, MAX_TOOL_NAME_LENGTH - HASH_LENGTH - 1)}_${hash}`;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A prefix of every Pi tool name of the server's tools, hashed or not: a
|
|
40
|
+
* hashed name keeps the first 55 characters of the sanitized full name, and
|
|
41
|
+
* the sanitized `mcp__<server>__` cut at 55 is a prefix of those. It can also
|
|
42
|
+
* prefix another server's tools (`a` and `a__b`, or two ids that agree on
|
|
43
|
+
* their first 48 characters), so it only narrows a name allowlist; it never
|
|
44
|
+
* says which server a tool is from.
|
|
45
|
+
*/
|
|
46
|
+
export function piMcpToolNamePrefix(serverId) {
|
|
47
|
+
return `mcp__${serverId}__`
|
|
48
|
+
.replace(/[^A-Za-z0-9_]/g, "_")
|
|
49
|
+
.slice(0, MAX_TOOL_NAME_LENGTH - HASH_LENGTH - 1);
|
|
50
|
+
}
|
|
51
|
+
/** Pi's namespace of a server's tools (`mcpNamespace`, which Pi does not export). */
|
|
52
|
+
function piMcpNamespace(serverId) {
|
|
53
|
+
return `mcp__${serverId.replace(/-/g, "_")}`;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Whether Pi registered the tool for this MCP server. Pi gives every MCP tool
|
|
57
|
+
* the server's namespace, aliased by the server's name, and refuses a second
|
|
58
|
+
* server whose namespace would clash, so this is exact where a name prefix is
|
|
59
|
+
* not.
|
|
60
|
+
*/
|
|
61
|
+
export function isPiMcpServerTool(tool, serverId) {
|
|
62
|
+
// `aliases` is typed from Pi 1.3.0; the peer floor is older.
|
|
63
|
+
const namespace = tool.namespace;
|
|
64
|
+
return (namespace?.name === piMcpNamespace(serverId) &&
|
|
65
|
+
(namespace.aliases?.includes(serverId) ?? false));
|
|
66
|
+
}
|
|
67
|
+
/** Pi added `reachesTools`, which codemode's readiness rests on, in 1.3.0. */
|
|
68
|
+
const PI_MCP_CODEMODE_MIN_VERSION = "1.3.0";
|
|
69
|
+
function versionParts(version) {
|
|
70
|
+
return version
|
|
71
|
+
.split(/[.+-]/)
|
|
72
|
+
.slice(0, 3)
|
|
73
|
+
.map((part) => Number(part) || 0);
|
|
74
|
+
}
|
|
75
|
+
/** Refuses `mcp.mode: codemode` on a Pi older than {@link PI_MCP_CODEMODE_MIN_VERSION}. */
|
|
76
|
+
export function assertPiSupportsMcpCodemode(version = VERSION) {
|
|
77
|
+
const have = versionParts(version);
|
|
78
|
+
const need = versionParts(PI_MCP_CODEMODE_MIN_VERSION);
|
|
79
|
+
const index = have.findIndex((part, i) => part !== need[i]);
|
|
80
|
+
if (index !== -1 && have[index] < need[index]) {
|
|
81
|
+
throw new Error(`mcp.mode codemode needs Pi ${PI_MCP_CODEMODE_MIN_VERSION} or newer, where a tool can wait for the MCP servers it reaches; this host runs Pi ${version}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function selectorsInclude(selectors, name) {
|
|
85
|
+
return (selectors?.some((selector) => selector === "*" || selector === name) ??
|
|
86
|
+
false);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The tools of a session server the current agent may call. A host-provisioned
|
|
90
|
+
* session may have been written for a broader agent, so the agent's own
|
|
91
|
+
* selection narrows it, as `mode: tools` does.
|
|
92
|
+
*/
|
|
93
|
+
function agentAllowedTools(server, mcp) {
|
|
94
|
+
const selection = mcp.servers[server.id] ?? {};
|
|
95
|
+
const allows = (name) => mcpSessionAllowsTool(server, name) &&
|
|
96
|
+
mcpSelectionAllowsTool(selection, name);
|
|
97
|
+
const agentIncludes = selection.include ?? [];
|
|
98
|
+
const candidates = explicitAllowedTools(server) ??
|
|
99
|
+
(agentIncludes.includes("*") ? undefined : agentIncludes);
|
|
100
|
+
return {
|
|
101
|
+
allows,
|
|
102
|
+
explicit: candidates && [...new Set(candidates)].filter(allows),
|
|
103
|
+
excludes: [
|
|
104
|
+
...(server.package_tools.exclude ?? []),
|
|
105
|
+
...server.agent_tools.flatMap((entry) => entry.exclude ?? []),
|
|
106
|
+
...(selection.exclude ?? []),
|
|
107
|
+
],
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function exposureConfig(server, mcp) {
|
|
111
|
+
const policy = mcp.servers[server.id];
|
|
112
|
+
// A server behind a tool is off the model's declarations and codemode's
|
|
113
|
+
// listings; only `ctx.executeTool` reaches a `deferred` tool.
|
|
114
|
+
const allowed = policy?.behind ? "deferred" : "codemode";
|
|
115
|
+
const eager = policy?.behind ? undefined : policy?.eager;
|
|
116
|
+
const exposureOf = (name) => selectorsInclude(eager, name) ? "direct" : allowed;
|
|
117
|
+
const { allows, explicit, excludes } = agentAllowedTools(server, mcp);
|
|
118
|
+
if (explicit) {
|
|
119
|
+
return {
|
|
120
|
+
exposure: allowed,
|
|
121
|
+
toolExposure: {
|
|
122
|
+
...Object.fromEntries(explicit.map((name) => [name, exposureOf(name)])),
|
|
123
|
+
"*": "hidden",
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
// Every tool is allowed but the excluded ones, which stay unreachable.
|
|
128
|
+
const excluded = excludes.filter((name) => !allows(name));
|
|
129
|
+
return {
|
|
130
|
+
exposure: eager?.includes("*") ? "direct" : allowed,
|
|
131
|
+
toolExposure: {
|
|
132
|
+
...Object.fromEntries((eager ?? [])
|
|
133
|
+
.filter((name) => name !== "*")
|
|
134
|
+
.map((name) => [name, "direct"])),
|
|
135
|
+
...Object.fromEntries(excluded.map((name) => [name, "hidden"])),
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function resolvedHeaders(binding, env) {
|
|
140
|
+
const entries = Object.entries(binding?.rawHeaders ?? {});
|
|
141
|
+
if (entries.length === 0)
|
|
142
|
+
return undefined;
|
|
143
|
+
return Object.fromEntries(entries.map(([name, raw]) => {
|
|
144
|
+
const value = interpolateEnv(raw, env);
|
|
145
|
+
// Pi runs a header value that starts with `!` as a shell command.
|
|
146
|
+
if (value.startsWith("!")) {
|
|
147
|
+
throw new Error(`MCP server '${binding.id}' header '${name}' starts with '!', which Pi would run as a command`);
|
|
148
|
+
}
|
|
149
|
+
return [name, value];
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
function callTimeoutSeconds(env) {
|
|
153
|
+
const raw = Number(env.PI_RECIPES_MCP_CALL_TIMEOUT_MS);
|
|
154
|
+
const ms = Number.isInteger(raw) && raw > 0 ? raw : DEFAULT_CALL_TIMEOUT_MS;
|
|
155
|
+
return Math.ceil(ms / 1000);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Pi server configs for the servers this agent may use: the session's bound
|
|
159
|
+
* servers, their URLs and headers from the bindings, and the agent's policy as
|
|
160
|
+
* Pi exposures. Allowed tools are reachable from codemode scripts, `eager`
|
|
161
|
+
* ones are also declared to the model, and every other tool is hidden.
|
|
162
|
+
*/
|
|
163
|
+
export function piMcpServerRegistrations(options) {
|
|
164
|
+
assertPiSupportsMcpCodemode();
|
|
165
|
+
const timeout = callTimeoutSeconds(options.env);
|
|
166
|
+
return options.session.servers
|
|
167
|
+
.filter((server) => Object.hasOwn(options.mcp.servers, server.id))
|
|
168
|
+
.map((server) => {
|
|
169
|
+
const binding = options.bindings.find((entry) => entry.id === server.id);
|
|
170
|
+
if (binding?.localOAuth) {
|
|
171
|
+
throw new Error(`MCP server '${server.id}' is bound with an OAuth flow, which Pi's MCP client (mcp.mode codemode, or a server behind a tool) does not support; bind it with a header`);
|
|
172
|
+
}
|
|
173
|
+
const headers = resolvedHeaders(binding, options.env);
|
|
174
|
+
const behind = options.mcp.servers[server.id]?.behind;
|
|
175
|
+
return {
|
|
176
|
+
id: server.id,
|
|
177
|
+
required: server.required === true,
|
|
178
|
+
deferrableDiscovery: server.discovery === "defer",
|
|
179
|
+
...(behind ? { behind } : {}),
|
|
180
|
+
config: {
|
|
181
|
+
url: server.base_url,
|
|
182
|
+
...(headers ? { headers } : {}),
|
|
183
|
+
timeout,
|
|
184
|
+
...exposureConfig(server, options.mcp),
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* OAuth state Pi's MCP extension would otherwise keep in `~/.pi/agent`. A
|
|
191
|
+
* Recipe session never signs in (credentials ride headers or the MCP edge), so
|
|
192
|
+
* nothing is stored and nothing is written.
|
|
193
|
+
*/
|
|
194
|
+
const noStoredCredentials = {
|
|
195
|
+
forServer: () => ({
|
|
196
|
+
load: () => undefined,
|
|
197
|
+
save: () => { },
|
|
198
|
+
withRefreshLock: (fn) => fn(),
|
|
199
|
+
}),
|
|
200
|
+
tokens: () => undefined,
|
|
201
|
+
remove: () => false,
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Pi's MCP extension for a Recipe session: no `mcp.json` is read, no OAuth
|
|
205
|
+
* state is kept, and server logs go to `logPath`.
|
|
206
|
+
*/
|
|
207
|
+
export function createRecipeMcpClientExtension(logPath) {
|
|
208
|
+
return createMcpExtension({
|
|
209
|
+
loadConfig: () => ({ servers: [], errors: [] }),
|
|
210
|
+
credentials: noStoredCredentials,
|
|
211
|
+
logPath,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
/** Registers the servers with Pi's MCP support, keeping the API for `waitForPiMcpServers`. */
|
|
215
|
+
export function createPiMcpServersExtension(registrations, onRegistered = () => { }) {
|
|
216
|
+
return (pi) => {
|
|
217
|
+
for (const registration of registrations) {
|
|
218
|
+
pi.registerMcpServer(registration.id, registration.config);
|
|
219
|
+
}
|
|
220
|
+
onRegistered(pi);
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
function connectTimeoutMs(env) {
|
|
224
|
+
const raw = Number(env[MCP_CONNECT_TIMEOUT_ENV]);
|
|
225
|
+
return Number.isInteger(raw) && raw > 0 ? raw : DEFAULT_CONNECT_TIMEOUT_MS;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Waits until each server has registered a tool, which Pi does once it has
|
|
229
|
+
* connected and listed them, and throws naming those that did not in time.
|
|
230
|
+
* Pi connects every server in the background when the session starts.
|
|
231
|
+
*/
|
|
232
|
+
export async function waitForPiMcpServers(pi, serverIds, env, signal) {
|
|
233
|
+
const deadline = Date.now() + connectTimeoutMs(env);
|
|
234
|
+
for (;;) {
|
|
235
|
+
const tools = pi.getAllTools();
|
|
236
|
+
const waiting = serverIds.filter((id) => !tools.some((tool) => isPiMcpServerTool(tool, id)));
|
|
237
|
+
if (waiting.length === 0)
|
|
238
|
+
return;
|
|
239
|
+
if (signal?.aborted)
|
|
240
|
+
throw new Error("MCP server connection was aborted");
|
|
241
|
+
if (Date.now() >= deadline) {
|
|
242
|
+
throw new Error(`Required MCP server(s) did not connect within ${connectTimeoutMs(env)} ms: ${waiting.join(", ")}`);
|
|
243
|
+
}
|
|
244
|
+
await new Promise((resolve) => setTimeout(resolve, CONNECT_POLL_MS));
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* The server and tool a Pi MCP tool stands for, for telemetry: the server from
|
|
249
|
+
* the tool's namespace, the tool from Pi's `<server>/<tool>` label.
|
|
250
|
+
*/
|
|
251
|
+
export function piMcpToolOrigin(session, tool) {
|
|
252
|
+
if (!tool)
|
|
253
|
+
return undefined;
|
|
254
|
+
const server = session.servers.find((entry) => isPiMcpServerTool(tool, entry.id));
|
|
255
|
+
const labelPrefix = `${server?.id}/`;
|
|
256
|
+
if (!server || !tool.label.startsWith(labelPrefix))
|
|
257
|
+
return undefined;
|
|
258
|
+
return {
|
|
259
|
+
serverId: server.id,
|
|
260
|
+
toolName: tool.label.slice(labelPrefix.length),
|
|
261
|
+
...(server.binding ? { binding: server.binding } : {}),
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
const MCP_SERVERS_SECTION = "mcp_servers";
|
|
265
|
+
/** The server kept behind tools that a Pi tool belongs to, if any. */
|
|
266
|
+
export function serverBehindTools(servers, tool) {
|
|
267
|
+
return tool
|
|
268
|
+
? servers.find((server) => server.behind && isPiMcpServerTool(tool, server.id))
|
|
269
|
+
: undefined;
|
|
270
|
+
}
|
|
271
|
+
/** Pi's `mcp_servers` prompt section without the servers kept behind tools. */
|
|
272
|
+
function sectionWithoutServersBehindTools(section, servers) {
|
|
273
|
+
// A listed server reads `- <namespace> (<how>)`.
|
|
274
|
+
const hidden = servers.map((server) => `- ${piMcpNamespace(server.id)} (`);
|
|
275
|
+
const [, ...lines] = section.split("\n");
|
|
276
|
+
const kept = lines.filter((line) => !hidden.some((prefix) => line.startsWith(prefix)));
|
|
277
|
+
if (!kept.some((line) => / \((codemode|tool_search)\)/.test(line))) {
|
|
278
|
+
return undefined;
|
|
279
|
+
}
|
|
280
|
+
// Pi's intro names how the listed servers are reached; rebuild it for those kept.
|
|
281
|
+
let intro = "MCP servers whose tools are not declared to you.";
|
|
282
|
+
if (kept.some((line) => line.includes(" (codemode)")))
|
|
283
|
+
intro += " Call the tools of `codemode` servers from codemode scripts.";
|
|
284
|
+
if (kept.some((line) => line.includes(" (tool_search)")))
|
|
285
|
+
intro += " Load the tools of `tool_search` servers with `tool_search`.";
|
|
286
|
+
return [intro, ...kept].join("\n");
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Keeps each server registered with `behind` behind its tools: a call to one
|
|
290
|
+
* of its tools is refused unless a tool named in `behind` issued it, directly
|
|
291
|
+
* or through calls nested inside that tool's call. The model, codemode scripts
|
|
292
|
+
* and every other tool are refused.
|
|
293
|
+
*/
|
|
294
|
+
export function createMcpBehindGuard(servers) {
|
|
295
|
+
return (pi) => {
|
|
296
|
+
const calls = new Map();
|
|
297
|
+
pi.on("tool_call", (event) => {
|
|
298
|
+
calls.set(event.toolCallId, {
|
|
299
|
+
toolName: event.toolName,
|
|
300
|
+
parentToolCallId: event.parentToolCallId,
|
|
301
|
+
});
|
|
302
|
+
const server = serverBehindTools(servers(), pi.getAllTools().find((tool) => tool.name === event.toolName));
|
|
303
|
+
if (!server?.behind)
|
|
304
|
+
return undefined;
|
|
305
|
+
const front = new Set(server.behind);
|
|
306
|
+
// An ancestor this guard never saw ends the walk: the call is refused.
|
|
307
|
+
for (let call = calls.get(event.parentToolCallId ?? ""); call; call = calls.get(call.parentToolCallId ?? "")) {
|
|
308
|
+
if (front.has(call.toolName))
|
|
309
|
+
return undefined;
|
|
310
|
+
}
|
|
311
|
+
const tools = server.behind.join(", ");
|
|
312
|
+
return {
|
|
313
|
+
block: true,
|
|
314
|
+
reason: `MCP server '${server.id}' is reachable only through the ${tools} tool${server.behind.length === 1 ? "" : "s"}; call ${server.behind[0]} instead.`,
|
|
315
|
+
};
|
|
316
|
+
});
|
|
317
|
+
pi.on("tool_result", (event) => {
|
|
318
|
+
calls.delete(event.toolCallId);
|
|
319
|
+
});
|
|
320
|
+
pi.on("agent_end", () => {
|
|
321
|
+
calls.clear();
|
|
322
|
+
});
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Drops the servers kept behind tools from Pi's `mcp_servers` prompt section,
|
|
327
|
+
* from a `before_agent_start` handler that runs after Pi's MCP extension's.
|
|
328
|
+
*/
|
|
329
|
+
export function hideServersBehindTools(sections, servers) {
|
|
330
|
+
const behind = servers.filter((server) => server.behind);
|
|
331
|
+
if (behind.length === 0)
|
|
332
|
+
return;
|
|
333
|
+
const section = sections[MCP_SERVERS_SECTION];
|
|
334
|
+
if (!section)
|
|
335
|
+
return;
|
|
336
|
+
const kept = sectionWithoutServersBehindTools(section, behind);
|
|
337
|
+
if (kept)
|
|
338
|
+
sections[MCP_SERVERS_SECTION] = kept;
|
|
339
|
+
else
|
|
340
|
+
delete sections[MCP_SERVERS_SECTION];
|
|
341
|
+
}
|
|
342
|
+
//# sourceMappingURL=pi-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi-client.js","sourceRoot":"","sources":["../../src/mcp/pi-client.ts"],"names":[],"mappings":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;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACpC,QAAgC,EAChC,OAAgC;IAEhC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACzD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAChC,MAAM,OAAO,GAAG,QAAQ,CAAC,mBAAmB,CAAC,CAAC;IAC9C,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,MAAM,IAAI,GAAG,gCAAgC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/D,IAAI,IAAI;QAAE,QAAQ,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAAC;;QAC1C,OAAO,QAAQ,CAAC,mBAAmB,CAAC,CAAC;AAC5C,CAAC"}
|
package/dist/mcp/policy.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export interface ScopedMcpToolSelection {
|
|
|
6
6
|
}
|
|
7
7
|
export declare function normalizeMcpServerId(value: string): string;
|
|
8
8
|
export declare function resolveAgentMcpSelections(mcp: RecipeAgentMcp | undefined): ScopedMcpToolSelection[];
|
|
9
|
+
/** The servers an agent keeps behind wrapper tools: server id to the tools in front of it. */
|
|
10
|
+
export declare function mcpServersBehindTools(mcp: RecipeAgentMcp | undefined): Map<string, readonly string[]>;
|
|
9
11
|
export declare function executableRecipeToolNames(tools: readonly string[]): string[];
|
|
10
12
|
export declare function mcpSelectionAllowsTool(selection: RecipeMcpToolSelection, toolName: string): boolean;
|
|
11
13
|
//# sourceMappingURL=policy.d.ts.map
|
package/dist/mcp/policy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/mcp/policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBA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 +12,12 @@ export function resolveAgentMcpSelections(mcp) {
|
|
|
12
12
|
tools: selection,
|
|
13
13
|
}));
|
|
14
14
|
}
|
|
15
|
+
/** The servers an agent keeps behind wrapper tools: server id to the tools in front of it. */
|
|
16
|
+
export function mcpServersBehindTools(mcp) {
|
|
17
|
+
return new Map(Object.entries(mcp?.servers ?? {}).flatMap(([serverId, selection]) => selection.behind
|
|
18
|
+
? [[normalizeMcpServerId(serverId), selection.behind]]
|
|
19
|
+
: []));
|
|
20
|
+
}
|
|
15
21
|
export function executableRecipeToolNames(tools) {
|
|
16
22
|
return [...tools];
|
|
17
23
|
}
|
package/dist/mcp/policy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/mcp/policy.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,MAAM,EAAE,GAAG,KAAK;SACb,IAAI,EAAE;SACN,WAAW,EAAE;SACb,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC;SAC7B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAC3B,OAAO,EAAE,IAAI,KAAK,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,GAA+B;IAE/B,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;QACxE,QAAQ,EAAE,oBAAoB,CAAC,QAAQ,CAAC;QACxC,KAAK,EAAE,SAAS;KACjB,CAAC,CAAC,CAAC;AACN,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,KAAwB;IAChE,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,SAAiC,EACjC,QAAgB;IAEhB,MAAM,QAAQ,GACZ,SAAS,CAAC,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SAAS,CAAC,EAAE,EAAE,CACnE,SAAS,CAAC,MAAM;QACd,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,MAAM,CAAU,CAAC;QAC/D,CAAC,CAAC,EAAE,CACP,CACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,KAAwB;IAChE,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,SAAiC,EACjC,QAAgB;IAEhB,MAAM,QAAQ,GACZ,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;QACnC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;QAChC,OAAO,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,QAAQ,CAAC;IACjD,CAAC,CAAC,IAAI,KAAK,CAAC;IACd,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5B,OAAO,CAAC,CAAC,SAAS,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,CACpC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,QAAQ,CAC3C,CAAC;AACJ,CAAC"}
|
|
@@ -12515,6 +12515,7 @@ var PI_KEYS = /* @__PURE__ */ new Set([
|
|
|
12515
12515
|
...RESOURCE_KEYS,
|
|
12516
12516
|
"channels",
|
|
12517
12517
|
"documents",
|
|
12518
|
+
"productivity",
|
|
12518
12519
|
"evals",
|
|
12519
12520
|
"mcp",
|
|
12520
12521
|
"runtime"
|
package/dist/mcp-daemon.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
installMcpCommandIoRouting,
|
|
13
13
|
mcpDaemonRequestContext,
|
|
14
14
|
serializeMcpDaemonEnvelope
|
|
15
|
-
} from "./mcp-chunks/chunk-
|
|
15
|
+
} from "./mcp-chunks/chunk-PO2SOBEN.js";
|
|
16
16
|
import "./mcp-chunks/chunk-S2F7DDP5.js";
|
|
17
17
|
import "./mcp-chunks/chunk-HNQSUT44.js";
|
|
18
18
|
import "./mcp-chunks/chunk-UFV6SVQG.js";
|
package/dist/mcp-run-worker.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createRequire as __createRequire } from "node:module"; const require =
|
|
|
2
2
|
import {
|
|
3
3
|
executeMcpCommand,
|
|
4
4
|
installMcpCommandIoRouting
|
|
5
|
-
} from "./mcp-chunks/chunk-
|
|
5
|
+
} from "./mcp-chunks/chunk-PO2SOBEN.js";
|
|
6
6
|
import "./mcp-chunks/chunk-S2F7DDP5.js";
|
|
7
7
|
import "./mcp-chunks/chunk-HNQSUT44.js";
|
|
8
8
|
import "./mcp-chunks/chunk-UFV6SVQG.js";
|
package/dist/open.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `introspection_open`, as every host shares it: the targets an agent can ask a
|
|
3
|
+
* person to open, the interrupt metadata a pause/resume host renders, and the
|
|
4
|
+
* answers a host resumes with. Imports nothing from Node, Pi or a renderer, so
|
|
5
|
+
* a browser host renders and answers with the same values the terminal uses;
|
|
6
|
+
* `./review.ts` re-exports it for that reason.
|
|
7
|
+
*/
|
|
8
|
+
export declare const INTROSPECTION_OPEN_TOOL_NAME = "introspection_open";
|
|
9
|
+
/** What the person is asked to open. The agent names a target, never a URL. */
|
|
10
|
+
export type IntrospectionOpenTarget =
|
|
11
|
+
/** A project-level install: `github`, `slack`. */
|
|
12
|
+
{
|
|
13
|
+
kind: "integration";
|
|
14
|
+
provider: string;
|
|
15
|
+
}
|
|
16
|
+
/** An admin adds the project's connector: its OAuth client. */
|
|
17
|
+
| {
|
|
18
|
+
kind: "connector";
|
|
19
|
+
provider: string;
|
|
20
|
+
}
|
|
21
|
+
/** The person's own account with a provider: `google_workspace`, `notion`. */
|
|
22
|
+
| {
|
|
23
|
+
kind: "connection";
|
|
24
|
+
provider: string;
|
|
25
|
+
}
|
|
26
|
+
/** An organization admin sets up sign-in: `google`, `entra`. */
|
|
27
|
+
| {
|
|
28
|
+
kind: "sso";
|
|
29
|
+
provider: string;
|
|
30
|
+
}
|
|
31
|
+
/** One of a Runtime's MCP bindings. */
|
|
32
|
+
| {
|
|
33
|
+
kind: "binding";
|
|
34
|
+
runtime: string;
|
|
35
|
+
name: string;
|
|
36
|
+
environment?: string;
|
|
37
|
+
}
|
|
38
|
+
/** A Runtime's page. */
|
|
39
|
+
| {
|
|
40
|
+
kind: "runtime";
|
|
41
|
+
runtime: string;
|
|
42
|
+
}
|
|
43
|
+
/** A task's chat. */
|
|
44
|
+
| {
|
|
45
|
+
kind: "task";
|
|
46
|
+
task: string;
|
|
47
|
+
}
|
|
48
|
+
/** A new repository the person creates on GitHub, registered once the App reaches it. */
|
|
49
|
+
| {
|
|
50
|
+
kind: "repository";
|
|
51
|
+
provider: "github";
|
|
52
|
+
name: string;
|
|
53
|
+
template?: string;
|
|
54
|
+
};
|
|
55
|
+
export type IntrospectionOpenTargetKind = IntrospectionOpenTarget["kind"];
|
|
56
|
+
export declare const INTROSPECTION_OPEN_TARGET_KINDS: readonly IntrospectionOpenTargetKind[];
|
|
57
|
+
/** The answers a host resumes an `introspection_open` interrupt with, as `payload.answer`. */
|
|
58
|
+
export declare const INTROSPECTION_OPEN_ANSWER: {
|
|
59
|
+
/** The person finished the connection. */
|
|
60
|
+
readonly connected: "connected";
|
|
61
|
+
/** The person came back from a page with nothing to connect (`runtime`, `task`). */
|
|
62
|
+
readonly returned: "returned";
|
|
63
|
+
};
|
|
64
|
+
/** `failed: <error>`, the answer for a flow the provider ended with an error. */
|
|
65
|
+
export declare function introspectionOpenFailed(error: string): string;
|
|
66
|
+
/** The answer for a target the person completed: `returned` for a page, `connected` otherwise. */
|
|
67
|
+
export declare function introspectionOpenDone(target: IntrospectionOpenTarget): string;
|
|
68
|
+
/**
|
|
69
|
+
* A target read back from untrusted input (a tool call's arguments, an
|
|
70
|
+
* interrupt's metadata), or null when it isn't one. Only the fields its kind
|
|
71
|
+
* names survive, trimmed.
|
|
72
|
+
*/
|
|
73
|
+
export declare function parseIntrospectionOpenTarget(value: unknown): IntrospectionOpenTarget | null;
|
|
74
|
+
/** The target an `introspection_open` interrupt carries, or null for any other interrupt. */
|
|
75
|
+
export declare function introspectionOpenTargetOf(interrupt: {
|
|
76
|
+
metadata?: unknown;
|
|
77
|
+
}): IntrospectionOpenTarget | null;
|
|
78
|
+
/** A provider id as a person reads it: `google_workspace` is "Google Workspace". */
|
|
79
|
+
export declare function providerName(provider: string): string;
|
|
80
|
+
/** The button a host shows for the target, e.g. "Connect GitHub" or "Open the runtime". */
|
|
81
|
+
export declare function introspectionOpenAction(target: IntrospectionOpenTarget): string;
|
|
82
|
+
//# sourceMappingURL=open.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../src/open.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,4BAA4B,uBAAuB,CAAC;AAEjE,+EAA+E;AAC/E,MAAM,MAAM,uBAAuB;AACjC,kDAAkD;AAChD;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE;AAC3C,+DAA+D;GAC7D;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE;AACzC,8EAA8E;GAC5E;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE;AAC1C,gEAAgE;GAC9D;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE;AACnC,uCAAuC;GACrC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE;AAC1E,wBAA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