@heyditto/cli 3.21.1 → 3.22.1

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.
@@ -0,0 +1,127 @@
1
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
+ import type { Command, Option } from "commander";
3
+ import { type InferenceEndpoint } from "./api.js";
4
+ import { type McpCatalog, type McpCatalogServer } from "./agents/claude-mcp.js";
5
+ export interface ResolvedMcpEndpoint {
6
+ endpoint: InferenceEndpoint;
7
+ baseUrl: string;
8
+ }
9
+ /**
10
+ * Resolves the active inference endpoint for MCP catalog commands (`mcp-config`
11
+ * and `tools`). Precedence matches `heyditto claude` / `mcp-config`:
12
+ * 1. explicit `--endpoint <slug|name|id>`
13
+ * 2. explicit `--profile <name>` / `DITTO_PROFILE`
14
+ * 3. repository `.ditto` default endpoint profile
15
+ * 4. active profile / saved default endpoint
16
+ * 5. sole endpoint when the account has exactly one
17
+ */
18
+ export declare function resolveMcpEndpoint(options?: {
19
+ endpoint?: string;
20
+ cwd?: string;
21
+ }): Promise<ResolvedMcpEndpoint>;
22
+ /**
23
+ * Resolves the MCP session id: explicit `--session`, `T3CODE_THREAD_ID`, active
24
+ * CLI session (`DITTO_SESSION_ID` or `heyditto session new`), or a fresh id.
25
+ */
26
+ export declare function resolveToolsSessionId(explicit?: string): Promise<string>;
27
+ /** Replaces any occurrence of a secret token before text reaches stdout or stderr. */
28
+ export declare function sanitizeSecret(text: string, secret: string): string;
29
+ /** Strips query string and fragment from a URL so presigned signatures are never printed. */
30
+ export declare function redactUrl(rawUrl: string): string;
31
+ /**
32
+ * Mints a one-hour ephemeral key on `endpoint`, passes it to `fn`, and always
33
+ * revokes the key in `finally` (and on SIGINT/SIGTERM). Never prints the key.
34
+ */
35
+ export declare function withEphemeralMcpKey<T>(endpoint: InferenceEndpoint, sessionId: string, fn: (apiKey: string) => Promise<T>): Promise<T>;
36
+ export interface ResolvedCatalogServer {
37
+ server: McpCatalogServer;
38
+ /** Harness-facing server name: "ditto" or "ditto-<source>". */
39
+ displayName: string;
40
+ /** Raw catalog alias: "ditto", "googledrive", "gmail", etc. */
41
+ alias: string;
42
+ }
43
+ /**
44
+ * Resolves a user-supplied server name against the endpoint's MCP catalog.
45
+ * Accepts canonical names (`ditto-googledrive`), short aliases (`googledrive`),
46
+ * and separator variants (`google-drive`, `google_drive`).
47
+ */
48
+ export declare function resolveCatalogServer(catalog: McpCatalog, wanted: string): ResolvedCatalogServer;
49
+ /** Opens a Streamable HTTP MCP client session against one catalog server. */
50
+ export declare function connectCatalogServer(server: McpCatalogServer, baseUrl: string, apiKey: string, sessionId: string): Promise<Client>;
51
+ export interface McpListedTool {
52
+ name: string;
53
+ title?: string;
54
+ description?: string;
55
+ inputSchema?: Record<string, unknown>;
56
+ annotations?: Record<string, unknown>;
57
+ }
58
+ /** Fetches all tools from an MCP server, following `nextCursor` pagination. */
59
+ export declare function listAllServerTools(client: Client): Promise<McpListedTool[]>;
60
+ /**
61
+ * Parses a single `--arg key=value` value: JSON booleans, null, strict finite
62
+ * numbers, quoted strings, arrays and objects parse as JSON; everything else
63
+ * stays a plain string.
64
+ */
65
+ export declare function parseArgValue(raw: string): unknown;
66
+ export interface ToolCallInputOptions {
67
+ json?: string;
68
+ stdin?: boolean;
69
+ arg?: string[];
70
+ rawArg?: string[];
71
+ }
72
+ export declare function parseToolCallArgs(positionalInput: string | undefined, options: ToolCallInputOptions): Promise<Record<string, unknown>>;
73
+ export type DownloadTarget = {
74
+ kind: "url";
75
+ url: string;
76
+ filename?: string;
77
+ mimeType?: string;
78
+ } | {
79
+ kind: "base64";
80
+ data: string;
81
+ filename?: string;
82
+ mimeType?: string;
83
+ };
84
+ /**
85
+ * Extracts a downloadable file payload (presigned URL or embedded binary blob)
86
+ * from an MCP `CallToolResult`.
87
+ */
88
+ export declare function extractDownloadTarget(result: unknown): DownloadTarget | undefined;
89
+ /** Sanitizes a remote filename so it can never escape a destination directory. */
90
+ export declare function sanitizeFilename(raw: string | undefined): string;
91
+ export interface DownloadResult {
92
+ downloaded: true;
93
+ path: string;
94
+ filename: string;
95
+ bytes: number;
96
+ contentType?: string;
97
+ sha256: string;
98
+ }
99
+ /**
100
+ * Streams a `DownloadTarget` to disk without sending Ditto auth headers to
101
+ * presigned URLs and without returning or logging any presigned URL.
102
+ */
103
+ export declare function downloadToolPayload(target: DownloadTarget, destArg: string, options?: {
104
+ fetchImpl?: typeof fetch;
105
+ timeoutMs?: number;
106
+ }): Promise<DownloadResult>;
107
+ interface ToolsBaseOptions {
108
+ endpoint?: string;
109
+ session?: string;
110
+ output?: string;
111
+ json?: boolean;
112
+ }
113
+ export declare function cmdToolsServers(options: ToolsBaseOptions): Promise<void>;
114
+ export declare function cmdToolsList(serverArg: string | undefined, options: ToolsBaseOptions & {
115
+ search?: string;
116
+ }): Promise<void>;
117
+ export declare function cmdToolsDescribe(serverArg: string, toolArg: string, options: ToolsBaseOptions): Promise<void>;
118
+ export interface ToolsCallOptions extends ToolCallInputOptions {
119
+ endpoint?: string;
120
+ session?: string;
121
+ output?: string;
122
+ timeout?: string;
123
+ download?: string;
124
+ }
125
+ export declare function cmdToolsCall(serverArg: string, toolArg: string, positionalInput: string | undefined, options: ToolsCallOptions): Promise<void>;
126
+ export declare function registerToolsCommands(program: Command, addExamples: (c: Command, ex: string) => Command, outputOption: () => Option): void;
127
+ export {};