llmist 17.3.0 → 17.5.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/README.md +21 -0
- package/dist/chunk-HM7PUGPA.js +2252 -0
- package/dist/chunk-HM7PUGPA.js.map +1 -0
- package/dist/index.cjs +1416 -331
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +448 -13
- package/dist/index.d.ts +448 -13
- package/dist/index.js +486 -1678
- package/dist/index.js.map +1 -1
- package/dist/runtime-GKQ6QIQP.js +187 -0
- package/dist/runtime-GKQ6QIQP.js.map +1 -0
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -3,10 +3,119 @@ import { ZodType, ZodTypeAny } from 'zod';
|
|
|
3
3
|
export { z } from 'zod';
|
|
4
4
|
import { Logger, ILogObj } from 'tslog';
|
|
5
5
|
export { ILogObj, Logger } from 'tslog';
|
|
6
|
+
import { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
|
|
6
7
|
import { MessageCreateParamsStreaming, MessageStreamEvent } from '@anthropic-ai/sdk/resources/messages';
|
|
7
8
|
import OpenAI from 'openai';
|
|
8
9
|
import { ChatCompletionMessageParam, ChatCompletionContentPart, ChatCompletionChunk } from 'openai/resources/chat/completions';
|
|
9
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Public types for the MCP integration.
|
|
13
|
+
*
|
|
14
|
+
* @module mcp/types
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* User-supplied spec describing an MCP server to consume.
|
|
18
|
+
*/
|
|
19
|
+
type McpServerSpec = StdioMcpServerSpec | HttpMcpServerSpec;
|
|
20
|
+
interface StdioMcpServerSpec {
|
|
21
|
+
/** Stable server name used for namespacing tools and surfacing in logs. */
|
|
22
|
+
name: string;
|
|
23
|
+
/** Stdio transport — server is spawned as a child process. */
|
|
24
|
+
transport: "stdio";
|
|
25
|
+
/** Executable to spawn. The basename is checked against the allowlist unless trust=true. */
|
|
26
|
+
command: string;
|
|
27
|
+
/** Arguments to pass to the executable. */
|
|
28
|
+
args?: string[];
|
|
29
|
+
/** Optional environment overrides for the spawned child process. */
|
|
30
|
+
env?: Record<string, string>;
|
|
31
|
+
/** Skip the allowlist check for this server. Default false. */
|
|
32
|
+
trust?: boolean;
|
|
33
|
+
/** Per-call timeout in milliseconds for tools/call. Default: no timeout. */
|
|
34
|
+
timeoutMs?: number;
|
|
35
|
+
}
|
|
36
|
+
interface HttpMcpServerSpec {
|
|
37
|
+
/** Stable server name. */
|
|
38
|
+
name: string;
|
|
39
|
+
/** Streamable HTTP transport (the modern, non-deprecated remote transport). */
|
|
40
|
+
transport: "http";
|
|
41
|
+
/** Server URL (must include scheme — http:// or https://). */
|
|
42
|
+
url: string;
|
|
43
|
+
/** Optional fixed headers (e.g. Authorization, X-API-Key). */
|
|
44
|
+
headers?: Record<string, string>;
|
|
45
|
+
/** Per-call timeout in milliseconds for tools/call. Default: no timeout. */
|
|
46
|
+
timeoutMs?: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Minimal subset of an MCP tool descriptor that this integration cares about.
|
|
50
|
+
*/
|
|
51
|
+
interface McpToolDescriptor {
|
|
52
|
+
name: string;
|
|
53
|
+
description?: string;
|
|
54
|
+
inputSchema?: unknown;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Canonical MCP content block shape used by the SDK.
|
|
58
|
+
*
|
|
59
|
+
* The SDK uses larger union types; this is the subset the adapter handles.
|
|
60
|
+
*/
|
|
61
|
+
type McpContentBlock = {
|
|
62
|
+
type: "text";
|
|
63
|
+
text: string;
|
|
64
|
+
} | {
|
|
65
|
+
type: "image";
|
|
66
|
+
data: string;
|
|
67
|
+
mimeType: string;
|
|
68
|
+
} | {
|
|
69
|
+
type: "audio";
|
|
70
|
+
data: string;
|
|
71
|
+
mimeType: string;
|
|
72
|
+
} | {
|
|
73
|
+
type: string;
|
|
74
|
+
[k: string]: unknown;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Result shape returned from a tools/call.
|
|
78
|
+
*/
|
|
79
|
+
interface McpToolResult {
|
|
80
|
+
content: McpContentBlock[];
|
|
81
|
+
isError?: boolean;
|
|
82
|
+
}
|
|
83
|
+
interface McpPromptArgument {
|
|
84
|
+
name: string;
|
|
85
|
+
description?: string;
|
|
86
|
+
required?: boolean;
|
|
87
|
+
}
|
|
88
|
+
interface McpPromptDescriptor {
|
|
89
|
+
name: string;
|
|
90
|
+
description?: string;
|
|
91
|
+
arguments?: McpPromptArgument[];
|
|
92
|
+
}
|
|
93
|
+
interface McpPromptMessage {
|
|
94
|
+
role: "user" | "assistant";
|
|
95
|
+
content: McpContentBlock;
|
|
96
|
+
}
|
|
97
|
+
interface McpPromptResult {
|
|
98
|
+
description?: string;
|
|
99
|
+
messages: McpPromptMessage[];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Server capabilities advertised on initialize. Only the fields used by plan 1
|
|
103
|
+
* are typed; richer capabilities arrive in plan 2.
|
|
104
|
+
*/
|
|
105
|
+
interface McpServerCapabilities {
|
|
106
|
+
tools?: {
|
|
107
|
+
listChanged?: boolean;
|
|
108
|
+
};
|
|
109
|
+
prompts?: {
|
|
110
|
+
listChanged?: boolean;
|
|
111
|
+
};
|
|
112
|
+
resources?: {
|
|
113
|
+
listChanged?: boolean;
|
|
114
|
+
subscribe?: boolean;
|
|
115
|
+
};
|
|
116
|
+
[k: string]: unknown;
|
|
117
|
+
}
|
|
118
|
+
|
|
10
119
|
/**
|
|
11
120
|
* Types and interfaces for multimodal input content.
|
|
12
121
|
*
|
|
@@ -5056,10 +5165,6 @@ declare function collectEvents(agentGenerator: AsyncGenerator<StreamEvent>, coll
|
|
|
5056
5165
|
*/
|
|
5057
5166
|
declare function collectText(agentGenerator: AsyncGenerator<StreamEvent>): Promise<string>;
|
|
5058
5167
|
|
|
5059
|
-
/**
|
|
5060
|
-
* Fluent builder for creating agents with delightful DX.
|
|
5061
|
-
*/
|
|
5062
|
-
|
|
5063
5168
|
/**
|
|
5064
5169
|
* Fluent builder for creating agents.
|
|
5065
5170
|
*
|
|
@@ -5073,6 +5178,7 @@ declare class AgentBuilder {
|
|
|
5073
5178
|
private subagents;
|
|
5074
5179
|
private policies;
|
|
5075
5180
|
private skills;
|
|
5181
|
+
private mcp;
|
|
5076
5182
|
constructor(client?: LLMist);
|
|
5077
5183
|
/** Set the model to use. Supports aliases like "sonnet", "flash". */
|
|
5078
5184
|
withModel(model: string): this;
|
|
@@ -5092,6 +5198,40 @@ declare class AgentBuilder {
|
|
|
5092
5198
|
withPromptTemplateConfig(config: PromptTemplateConfig): this;
|
|
5093
5199
|
/** Add gadgets (classes or instances). */
|
|
5094
5200
|
withGadgets(...gadgets: GadgetOrClass[]): this;
|
|
5201
|
+
/**
|
|
5202
|
+
* Attach a Model Context Protocol (MCP) server.
|
|
5203
|
+
*
|
|
5204
|
+
* The agent connects to the server lazily at the start of `run()`,
|
|
5205
|
+
* discovers its tools, and registers them as native gadgets so the LLM
|
|
5206
|
+
* can call them through the standard streaming block format.
|
|
5207
|
+
*
|
|
5208
|
+
* Calling this multiple times accumulates servers. Tools across servers
|
|
5209
|
+
* are merged into a single registry; in plan 1, conflicting tool names
|
|
5210
|
+
* raise a registration warning. Plan 2 introduces deterministic
|
|
5211
|
+
* `<server>__<tool>` prefixing for collisions.
|
|
5212
|
+
*
|
|
5213
|
+
* STDIO commands are gated by an allowlist (see allowlist.ts) — pass
|
|
5214
|
+
* `trust: true` on the spec to opt in for non-allowlisted binaries.
|
|
5215
|
+
*
|
|
5216
|
+
* Zero-overhead invariant: if you never call this method, the MCP
|
|
5217
|
+
* runtime module is never loaded. Agents without MCP pay nothing.
|
|
5218
|
+
*
|
|
5219
|
+
* @example
|
|
5220
|
+
* ```typescript
|
|
5221
|
+
* const agent = LLMist.createAgent()
|
|
5222
|
+
* .withModel("sonnet")
|
|
5223
|
+
* .withMcpServer({
|
|
5224
|
+
* name: "filesystem",
|
|
5225
|
+
* transport: "stdio",
|
|
5226
|
+
* command: "npx",
|
|
5227
|
+
* args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
|
|
5228
|
+
* })
|
|
5229
|
+
* .ask("list files in /tmp");
|
|
5230
|
+
* ```
|
|
5231
|
+
*/
|
|
5232
|
+
withMcpServer(spec: McpServerSpec): this;
|
|
5233
|
+
/** Inspect the configured MCP server specs. Useful for tests. */
|
|
5234
|
+
getMcpServerSpecs(): readonly McpServerSpec[];
|
|
5095
5235
|
/** Add conversation history messages. */
|
|
5096
5236
|
withHistory(messages: HistoryMessage[]): this;
|
|
5097
5237
|
/** Add a single message to the conversation history. */
|
|
@@ -5912,13 +6052,6 @@ interface OutputLimitConfig {
|
|
|
5912
6052
|
limitPercent?: number;
|
|
5913
6053
|
}
|
|
5914
6054
|
|
|
5915
|
-
/**
|
|
5916
|
-
* Agent: Lean orchestrator using the clean hooks architecture.
|
|
5917
|
-
*
|
|
5918
|
-
* The Agent delegates ALL stream processing and hook coordination to StreamProcessor,
|
|
5919
|
-
* making it a simple loop orchestrator with clear responsibilities.
|
|
5920
|
-
*/
|
|
5921
|
-
|
|
5922
6055
|
/**
|
|
5923
6056
|
* Configuration for the execution tree context (shared tree model with subagents).
|
|
5924
6057
|
*/
|
|
@@ -6052,6 +6185,18 @@ interface AgentOptions {
|
|
|
6052
6185
|
* settings instead of creating its own.
|
|
6053
6186
|
*/
|
|
6054
6187
|
sharedRetryConfig?: ResolvedRetryConfig;
|
|
6188
|
+
/**
|
|
6189
|
+
* MCP server specs to attach to the agent.
|
|
6190
|
+
*
|
|
6191
|
+
* When non-empty, the agent connects to each server lazily at the start of
|
|
6192
|
+
* `run()`, lists their tools, wraps them as native gadgets, and registers
|
|
6193
|
+
* them on the registry alongside any explicitly-provided gadgets. The
|
|
6194
|
+
* lifecycle teardown happens in the agent's `finally` block.
|
|
6195
|
+
*
|
|
6196
|
+
* When empty or omitted, the MCP module is never imported — agents that
|
|
6197
|
+
* don't use MCP pay zero overhead at load time.
|
|
6198
|
+
*/
|
|
6199
|
+
mcpSpecs?: McpServerSpec[];
|
|
6055
6200
|
}
|
|
6056
6201
|
/**
|
|
6057
6202
|
* Agent: Lean orchestrator that delegates to StreamProcessor.
|
|
@@ -6097,6 +6242,9 @@ declare class Agent {
|
|
|
6097
6242
|
private readonly parentNodeId;
|
|
6098
6243
|
private readonly streamProcessorFactory;
|
|
6099
6244
|
private readonly llmCallLifecycle;
|
|
6245
|
+
private readonly mcpSpecs;
|
|
6246
|
+
private mcpLifecycle;
|
|
6247
|
+
private readonly mcpDiscoveredPrompts;
|
|
6100
6248
|
/**
|
|
6101
6249
|
* Creates a new Agent instance.
|
|
6102
6250
|
* @internal This constructor is private. Use LLMist.createAgent() or AgentBuilder instead.
|
|
@@ -7486,7 +7634,7 @@ interface ConversationManagerOptions {
|
|
|
7486
7634
|
* Manages conversation history by building on top of base messages (system prompt, gadget instructions).
|
|
7487
7635
|
*/
|
|
7488
7636
|
declare class ConversationManager implements IConversationManager {
|
|
7489
|
-
private
|
|
7637
|
+
private baseMessages;
|
|
7490
7638
|
private readonly initialMessages;
|
|
7491
7639
|
private historyBuilder;
|
|
7492
7640
|
private readonly startPrefix?;
|
|
@@ -7499,6 +7647,14 @@ declare class ConversationManager implements IConversationManager {
|
|
|
7499
7647
|
getMessages(): LLMMessage[];
|
|
7500
7648
|
getHistoryMessages(): LLMMessage[];
|
|
7501
7649
|
getBaseMessages(): LLMMessage[];
|
|
7650
|
+
/**
|
|
7651
|
+
* Replace the base (system + gadget catalog) messages.
|
|
7652
|
+
*
|
|
7653
|
+
* Used when async setup (e.g. MCP server connect-and-list) discovers
|
|
7654
|
+
* additional gadgets after the agent was constructed. Conversation history
|
|
7655
|
+
* is preserved; only the leading system block is swapped.
|
|
7656
|
+
*/
|
|
7657
|
+
replaceBaseMessages(newBase: LLMMessage[]): void;
|
|
7502
7658
|
replaceHistory(newHistory: LLMMessage[]): void;
|
|
7503
7659
|
getConversationHistory(): LLMMessage[];
|
|
7504
7660
|
}
|
|
@@ -8623,6 +8779,285 @@ declare class GadgetCallParser {
|
|
|
8623
8779
|
reset(): void;
|
|
8624
8780
|
}
|
|
8625
8781
|
|
|
8782
|
+
/**
|
|
8783
|
+
* Default-safe allowlist for MCP STDIO server commands.
|
|
8784
|
+
*
|
|
8785
|
+
* Mitigates the CVE-2026-30623 family of stdio-spawn RCE vulnerabilities. The
|
|
8786
|
+
* gate refuses to spawn any executable whose basename is not in the allowlist
|
|
8787
|
+
* unless the spec is marked `trust: true` (library) / `trust = true` (TOML)
|
|
8788
|
+
* / `--mcp-trust <name>` (CLI). It also rejects whole-string commands that
|
|
8789
|
+
* embed args or shell metacharacters — callers must pass arguments as a
|
|
8790
|
+
* separate array.
|
|
8791
|
+
*
|
|
8792
|
+
* @module mcp/allowlist
|
|
8793
|
+
*/
|
|
8794
|
+
/**
|
|
8795
|
+
* Default allowlist of MCP stdio server runtimes that are safe to spawn
|
|
8796
|
+
* without explicit user opt-in. Add entries to this list only when the
|
|
8797
|
+
* basename is universally a runtime, not a tool that takes arbitrary code
|
|
8798
|
+
* (e.g. don't add `bash` or `sh`).
|
|
8799
|
+
*/
|
|
8800
|
+
declare const DEFAULT_MCP_COMMAND_ALLOWLIST: ReadonlySet<string>;
|
|
8801
|
+
/**
|
|
8802
|
+
* Throws McpUntrustedCommandError if `command` is not safe to spawn under
|
|
8803
|
+
* the allowlist policy.
|
|
8804
|
+
*/
|
|
8805
|
+
declare function assertCommandAllowed(command: string, trusted: boolean, customAllowlist?: ReadonlySet<string>): void;
|
|
8806
|
+
|
|
8807
|
+
/**
|
|
8808
|
+
* Wraps the official MCP SDK's stdio Client into a small, llmist-flavored
|
|
8809
|
+
* surface. Encapsulates the SDK so the rest of llmist depends on the typed
|
|
8810
|
+
* shapes in `./types.ts` rather than vendor types.
|
|
8811
|
+
*
|
|
8812
|
+
* Lazy-imports the SDK so agents that don't use MCP pay zero overhead at
|
|
8813
|
+
* load time.
|
|
8814
|
+
*
|
|
8815
|
+
* @module mcp/client
|
|
8816
|
+
*/
|
|
8817
|
+
|
|
8818
|
+
interface McpClientOptions {
|
|
8819
|
+
/**
|
|
8820
|
+
* Inject a pre-built transport for testing. When omitted, the client
|
|
8821
|
+
* builds a stdio transport from the spec at connect() time.
|
|
8822
|
+
*/
|
|
8823
|
+
transport?: Transport;
|
|
8824
|
+
/**
|
|
8825
|
+
* Override the client identity sent during initialize.
|
|
8826
|
+
*/
|
|
8827
|
+
clientInfo?: {
|
|
8828
|
+
name: string;
|
|
8829
|
+
version: string;
|
|
8830
|
+
};
|
|
8831
|
+
}
|
|
8832
|
+
declare class McpClient {
|
|
8833
|
+
readonly spec: McpServerSpec;
|
|
8834
|
+
private sdkClient;
|
|
8835
|
+
private spawnedPid;
|
|
8836
|
+
private closed;
|
|
8837
|
+
private readonly injectedTransport?;
|
|
8838
|
+
private readonly clientInfo;
|
|
8839
|
+
constructor(spec: McpServerSpec, opts?: McpClientOptions);
|
|
8840
|
+
get serverName(): string;
|
|
8841
|
+
get pid(): number | null;
|
|
8842
|
+
get serverCapabilities(): McpServerCapabilities | null;
|
|
8843
|
+
connect(): Promise<void>;
|
|
8844
|
+
listTools(): Promise<McpToolDescriptor[]>;
|
|
8845
|
+
callTool(name: string, args: unknown): Promise<McpToolResult>;
|
|
8846
|
+
listPrompts(): Promise<McpPromptDescriptor[]>;
|
|
8847
|
+
getPrompt(name: string, args?: Record<string, unknown>): Promise<McpPromptResult>;
|
|
8848
|
+
close(): Promise<void>;
|
|
8849
|
+
private requireClient;
|
|
8850
|
+
private withTimeout;
|
|
8851
|
+
}
|
|
8852
|
+
|
|
8853
|
+
/**
|
|
8854
|
+
* Typed errors raised by the MCP integration.
|
|
8855
|
+
*
|
|
8856
|
+
* These wrap underlying SDK and transport errors so the rest of llmist can
|
|
8857
|
+
* react to MCP failures with stable, narrow types instead of catching the
|
|
8858
|
+
* SDK's internal error classes.
|
|
8859
|
+
*
|
|
8860
|
+
* @module mcp/errors
|
|
8861
|
+
*/
|
|
8862
|
+
declare class McpError extends Error {
|
|
8863
|
+
readonly serverName?: string;
|
|
8864
|
+
constructor(message: string, serverName?: string);
|
|
8865
|
+
}
|
|
8866
|
+
declare class McpUntrustedCommandError extends McpError {
|
|
8867
|
+
readonly command: string;
|
|
8868
|
+
constructor(command: string, serverName?: string);
|
|
8869
|
+
}
|
|
8870
|
+
declare class McpConnectError extends McpError {
|
|
8871
|
+
readonly cause?: unknown;
|
|
8872
|
+
constructor(message: string, opts?: {
|
|
8873
|
+
serverName?: string;
|
|
8874
|
+
cause?: unknown;
|
|
8875
|
+
});
|
|
8876
|
+
}
|
|
8877
|
+
declare class McpToolCallError extends McpError {
|
|
8878
|
+
readonly toolName: string;
|
|
8879
|
+
readonly cause?: unknown;
|
|
8880
|
+
constructor(toolName: string, message: string, opts?: {
|
|
8881
|
+
serverName?: string;
|
|
8882
|
+
cause?: unknown;
|
|
8883
|
+
});
|
|
8884
|
+
}
|
|
8885
|
+
declare class JsonSchemaConversionError extends Error {
|
|
8886
|
+
readonly schemaFragment: unknown;
|
|
8887
|
+
readonly reason: string;
|
|
8888
|
+
constructor(reason: string, schemaFragment: unknown);
|
|
8889
|
+
}
|
|
8890
|
+
|
|
8891
|
+
/**
|
|
8892
|
+
* Convert native llmist gadgets into MCP tool descriptors and run them on
|
|
8893
|
+
* behalf of an MCP server. The inverse of `tool-adapter.ts` (which converts
|
|
8894
|
+
* MCP tools into native gadgets).
|
|
8895
|
+
*
|
|
8896
|
+
* @module mcp/gadget-exporter
|
|
8897
|
+
*/
|
|
8898
|
+
|
|
8899
|
+
/** Convert a native gadget into an MCP tool descriptor. */
|
|
8900
|
+
declare function gadgetToMcpTool(gadget: AbstractGadget): McpToolDescriptor;
|
|
8901
|
+
/**
|
|
8902
|
+
* Convert a gadget's execute() return value into MCP content blocks.
|
|
8903
|
+
*
|
|
8904
|
+
* Shapes handled:
|
|
8905
|
+
* - string → single `text` block
|
|
8906
|
+
* - { result, media[] } → `text` block + per-media block
|
|
8907
|
+
* - other (object) → JSON-stringified `text` block
|
|
8908
|
+
*/
|
|
8909
|
+
declare function gadgetResultToMcpContent(ret: GadgetExecuteReturn): McpContentBlock[];
|
|
8910
|
+
/**
|
|
8911
|
+
* Validate params and run the gadget, converting both the success and error
|
|
8912
|
+
* paths into MCP tool result shapes.
|
|
8913
|
+
*
|
|
8914
|
+
* Used by the McpServer's `tools/call` handler.
|
|
8915
|
+
*/
|
|
8916
|
+
declare function runGadgetForMcp(gadget: AbstractGadget, rawParams: unknown): Promise<McpToolResult>;
|
|
8917
|
+
|
|
8918
|
+
/**
|
|
8919
|
+
* Minimal JSON Schema → Zod converter for MCP tool input schemas.
|
|
8920
|
+
*
|
|
8921
|
+
* MCP tool descriptors expose `inputSchema` as JSON Schema (typically a
|
|
8922
|
+
* subset of draft-2020-12 with `type`, `properties`, `required`, `items`,
|
|
8923
|
+
* `enum`, `default`, `description`, `nullable`). This converter handles
|
|
8924
|
+
* exactly that subset — anything richer ($ref, allOf, format-only schemas,
|
|
8925
|
+
* non-primitive oneOf composition) throws so we surface the gap rather than
|
|
8926
|
+
* silently coercing a wrong schema.
|
|
8927
|
+
*
|
|
8928
|
+
* @module mcp/json-schema-to-zod
|
|
8929
|
+
*/
|
|
8930
|
+
|
|
8931
|
+
interface JSONSchemaLike {
|
|
8932
|
+
type?: string | string[];
|
|
8933
|
+
description?: string;
|
|
8934
|
+
default?: unknown;
|
|
8935
|
+
enum?: unknown[];
|
|
8936
|
+
nullable?: boolean;
|
|
8937
|
+
properties?: Record<string, JSONSchemaLike>;
|
|
8938
|
+
required?: string[];
|
|
8939
|
+
items?: JSONSchemaLike | JSONSchemaLike[];
|
|
8940
|
+
oneOf?: JSONSchemaLike[];
|
|
8941
|
+
anyOf?: JSONSchemaLike[];
|
|
8942
|
+
allOf?: JSONSchemaLike[];
|
|
8943
|
+
$ref?: string;
|
|
8944
|
+
[k: string]: unknown;
|
|
8945
|
+
}
|
|
8946
|
+
/**
|
|
8947
|
+
* Convert a JSON Schema fragment into a Zod schema.
|
|
8948
|
+
*
|
|
8949
|
+
* Throws JsonSchemaConversionError on features that have no clean Zod analog
|
|
8950
|
+
* in the MCP subset.
|
|
8951
|
+
*/
|
|
8952
|
+
declare function jsonSchemaToZod(schema: JSONSchemaLike | undefined): ZodTypeAny;
|
|
8953
|
+
|
|
8954
|
+
/**
|
|
8955
|
+
* Tracks spawned MCP clients for an agent run and closes them all on
|
|
8956
|
+
* teardown. Plan 1 ships the basics: register, closeAll, idempotent. Signal
|
|
8957
|
+
* handling and graceful shutdown windows are added in plan 2.
|
|
8958
|
+
*
|
|
8959
|
+
* @module mcp/lifecycle
|
|
8960
|
+
*/
|
|
8961
|
+
|
|
8962
|
+
declare class McpLifecycle {
|
|
8963
|
+
private clients;
|
|
8964
|
+
private closing;
|
|
8965
|
+
private signalHandlersInstalled;
|
|
8966
|
+
private sigtermHandler;
|
|
8967
|
+
private sigintHandler;
|
|
8968
|
+
get size(): number;
|
|
8969
|
+
register(client: McpClient): void;
|
|
8970
|
+
/**
|
|
8971
|
+
* Attach SIGTERM/SIGINT handlers that close every registered client when
|
|
8972
|
+
* the parent process is asked to exit. Idempotent (double install is a
|
|
8973
|
+
* no-op) and removable via `removeSignalHandlers()`.
|
|
8974
|
+
*/
|
|
8975
|
+
installSignalHandlers(): void;
|
|
8976
|
+
removeSignalHandlers(): void;
|
|
8977
|
+
/**
|
|
8978
|
+
* Close every registered client in parallel. Errors from individual close()
|
|
8979
|
+
* calls are swallowed (logged via console.warn) — a teardown path must not
|
|
8980
|
+
* throw because that would mask the original reason the agent is shutting
|
|
8981
|
+
* down. Idempotent: concurrent calls all return the same in-flight promise.
|
|
8982
|
+
*/
|
|
8983
|
+
closeAll(): Promise<void>;
|
|
8984
|
+
}
|
|
8985
|
+
|
|
8986
|
+
/**
|
|
8987
|
+
* Wrap the MCP SDK's Server class with llmist semantics: register native
|
|
8988
|
+
* gadgets as MCP tools and (optionally) llmist skills as MCP prompts.
|
|
8989
|
+
*
|
|
8990
|
+
* Lazy-imports the SDK so callers that don't expose anything pay no cost.
|
|
8991
|
+
*
|
|
8992
|
+
* @module mcp/server
|
|
8993
|
+
*/
|
|
8994
|
+
|
|
8995
|
+
interface CreateMcpServerOptions {
|
|
8996
|
+
gadgets: GadgetRegistry;
|
|
8997
|
+
skills?: SkillRegistry;
|
|
8998
|
+
/** Override the protocol version advertised. Defaults to 2025-06-18. */
|
|
8999
|
+
protocolVersion?: string;
|
|
9000
|
+
/** Server identity sent on initialize. */
|
|
9001
|
+
serverInfo?: {
|
|
9002
|
+
name: string;
|
|
9003
|
+
version: string;
|
|
9004
|
+
};
|
|
9005
|
+
}
|
|
9006
|
+
interface McpServerHandle {
|
|
9007
|
+
/** Connect the server to a Transport (stdio, in-memory test transport, etc.). */
|
|
9008
|
+
connect(transport: Transport): Promise<void>;
|
|
9009
|
+
/** Close the underlying server cleanly. Idempotent. */
|
|
9010
|
+
stop(): Promise<void>;
|
|
9011
|
+
/** True between connect() and stop(). */
|
|
9012
|
+
readonly running: boolean;
|
|
9013
|
+
}
|
|
9014
|
+
declare function createMcpServer(opts: CreateMcpServerOptions): McpServerHandle;
|
|
9015
|
+
|
|
9016
|
+
/**
|
|
9017
|
+
* Convert native llmist Skills into MCP prompt descriptors and render them
|
|
9018
|
+
* on behalf of an MCP server.
|
|
9019
|
+
*
|
|
9020
|
+
* Plan 3 maps:
|
|
9021
|
+
* - Skill metadata.name → prompt name
|
|
9022
|
+
* - Skill metadata.description → prompt description
|
|
9023
|
+
* - argumentHint (when present) → a single optional `arguments` parameter
|
|
9024
|
+
* (the existing skill-substitution machinery handles `$ARGUMENTS`, `$0`,
|
|
9025
|
+
* `$1`, etc., from a single string)
|
|
9026
|
+
* - Skill body, after argument substitution, becomes a single user-role
|
|
9027
|
+
* text message in the prompt response
|
|
9028
|
+
*
|
|
9029
|
+
* @module mcp/skill-exporter
|
|
9030
|
+
*/
|
|
9031
|
+
|
|
9032
|
+
declare function skillToMcpPrompt(skill: Skill): McpPromptDescriptor;
|
|
9033
|
+
/**
|
|
9034
|
+
* Render a skill's body as a single MCP prompt message after argument
|
|
9035
|
+
* substitution.
|
|
9036
|
+
*
|
|
9037
|
+
* `args.arguments` is a string interpreted by the existing skill activation
|
|
9038
|
+
* pipeline ($ARGUMENTS, $0, $1, ...). We don't try to map MCP's per-argument
|
|
9039
|
+
* named parameters into the existing positional substitution model — the
|
|
9040
|
+
* skill author already chose the substitution shape.
|
|
9041
|
+
*/
|
|
9042
|
+
declare function renderSkillForMcpPrompt(skill: Skill, args: Record<string, unknown>): Promise<McpPromptResult>;
|
|
9043
|
+
|
|
9044
|
+
/**
|
|
9045
|
+
* Wraps an MCP tool descriptor as a native llmist gadget so the existing
|
|
9046
|
+
* gadget executor consumes it without any awareness of MCP.
|
|
9047
|
+
*
|
|
9048
|
+
* @module mcp/tool-adapter
|
|
9049
|
+
*/
|
|
9050
|
+
|
|
9051
|
+
interface McpToolAdapterOptions {
|
|
9052
|
+
/** Prefix prepended to the gadget name. Used for multi-server name conflict resolution (plan 2). */
|
|
9053
|
+
prefix?: string;
|
|
9054
|
+
}
|
|
9055
|
+
/**
|
|
9056
|
+
* Convert an MCP tool descriptor into a native gadget that delegates to the
|
|
9057
|
+
* supplied MCP client.
|
|
9058
|
+
*/
|
|
9059
|
+
declare function mcpToolToGadget(tool: McpToolDescriptor, client: McpClient, opts?: McpToolAdapterOptions): AbstractGadget;
|
|
9060
|
+
|
|
8626
9061
|
/**
|
|
8627
9062
|
* Character-to-token ratio for fallback token estimation.
|
|
8628
9063
|
*
|
|
@@ -10617,4 +11052,4 @@ declare const timing: {
|
|
|
10617
11052
|
*/
|
|
10618
11053
|
declare function getHostExports(ctx: ExecutionContext): HostExports;
|
|
10619
11054
|
|
|
10620
|
-
export { AbortException, AbstractGadget, type AddGadgetParams, type AddLLMCallParams, type AfterGadgetExecutionAction, type AfterGadgetExecutionControllerContext, type AfterLLMCallAction, type AfterLLMCallControllerContext, type AfterLLMErrorAction, Agent, AgentBuilder, type AgentHooks, type AgentOptions, AnthropicMessagesProvider, type AudioContentPart, type AudioMimeType, type AudioSource, type BaseExecutionEvent, BaseSessionManager, type BeforeGadgetExecutionAction, type BeforeLLMCallAction, type BeforeSkillActivationAction, BudgetPricingUnavailableError, type CachingConfig, type CachingScope, type ChunkInterceptorContext, type CompactionConfig, type CompactionContext, type CompactionEvent, CompactionManager, type CompactionResult, type CompactionStats, type CompactionStrategy, type CompleteGadgetParams, type CompleteLLMCallParams, type ContentPart, type Controllers, ConversationManager, type CostEstimate, type CostReportingLLMist, type CreateGadgetConfig, DEFAULT_COMPACTION_CONFIG, DEFAULT_HINTS, DEFAULT_PROMPTS, DEFAULT_RATE_LIMIT_CONFIG, DEFAULT_RETRY_CONFIG, DEFAULT_SUMMARIZATION_PROMPT, type EventHandlers, type ExecutionContext, type ExecutionEvent, type ExecutionEventType, type ExecutionNode, type ExecutionNodeType, ExecutionTree, FALLBACK_CHARS_PER_TOKEN, type FileLoggingOptions, type FileLoggingState, type FileWrittenInfo, type FormatLLMErrorContext, GADGET_ARG_PREFIX, GADGET_END_PREFIX, GADGET_START_PREFIX, Gadget, type GadgetCallEvent, GadgetCallParser, type GadgetClass, type GadgetCompleteEvent, type GadgetConfig, type GadgetErrorEvent, type GadgetEvent, type GadgetExample, type GadgetExecuteResult, type GadgetExecuteResultWithMedia, type GadgetExecuteReturn, type GadgetExecutionControllerContext, type GadgetExecutionMode, type GadgetExecutionResult, GadgetExecutor, type GadgetExecutorOptions, type GadgetFactoryExports, type GadgetMediaOutput, type GadgetNode, type GadgetOrClass, GadgetOutputStore, type GadgetParameterInterceptorContext, GadgetRegistry, type GadgetResultInterceptorContext, type GadgetSkippedEvent, type GadgetStartEvent, type GadgetState, GeminiGenerativeProvider, type HintContext, type HintTemplate, type HintsConfig, type HistoryMessage, HookPresets, type HostExports, HuggingFaceProvider, type HumanInputRequiredEvent, HumanInputRequiredException, HybridStrategy, type IConversationManager, type ISessionManager, type ImageBase64Source, type ImageContentPart, type ImageGenerationOptions, type ImageGenerationResult, type ImageMimeType, type ImageModelSpec, type ImageSource, type ImageUrlSource, type Interceptors, type IterationHintOptions, type LLMCallCompleteEvent, type LLMCallControllerContext, type LLMCallErrorEvent, type LLMCallNode, type LLMCallStartEvent, type LLMCallStreamEvent, type LLMErrorControllerContext, type LLMEvent, type LLMGenerationOptions, type LLMMessage, LLMMessageBuilder, type LLMResponseEndEvent, type LLMStream, type LLMStreamChunk, LLMist, type LLMistOptions, type LLMistPackageManifest, LOAD_SKILL_GADGET_NAME, type LoggerOptions, type LoggingOptions, MODEL_ALIASES, type MediaKind, type MediaMetadata, MediaStore, type MessageContent, type MessageInterceptorContext, type MessageRole, type MessageTurn, type ModelDescriptor, type ModelFeatures, ModelIdentifierParser, type ModelLimits, type ModelPricing, ModelRegistry, type ModelSpec, type NodeId, type ObserveChunkContext, type ObserveCompactionContext, type ObserveGadgetCompleteContext, type ObserveGadgetStartContext, type ObserveLLMCallContext, type ObserveLLMCompleteContext, type ObserveLLMErrorContext, type ObserveRateLimitThrottleContext, type ObserveRetryAttemptContext, type ObserveSkillActivatedContext, type Observers, OpenAIChatProvider, type OpenAICompatibleConfig, OpenAICompatibleProvider, type OpenRouterConfig, OpenRouterProvider, type OpenRouterRouting, type OutputLimitConfig, type ParallelGadgetHintOptions, type ParsedGadgetCall, type ParsedSkill, type PrefixConfig, type PresetDefinition, type PromptContext, type PromptTemplate, type PromptTemplateConfig, type ProviderAdapter, type ProviderIdentifier, type RateLimitConfig, type RateLimitStats, RateLimitTracker, type ReasoningConfig, type ReasoningEffort, type ResolveValueOptions, type ResolvedCompactionConfig, type ResolvedRateLimitConfig, type ResolvedRetryConfig, type RetryConfig, type RetryOptions, type SessionManifestEntry, SimpleSessionManager, Skill, type SkillActivation, type SkillActivationControllerContext, type SkillActivationOptions, type SkillInstructionInterceptorContext, type SkillMetadata, SkillRegistry, type SkillResource, type SkillSource, SlidingWindowStrategy, type SpeechGenerationOptions, type SpeechGenerationResult, type SpeechModelSpec, type StoredMedia, type StoredOutput, type StreamCompleteEvent, type StreamEvent, type StreamProcessingResult, StreamProcessor, type StreamProcessorOptions, type SubagentConfig, type SubagentConfigMap, type SubagentContext, type SubagentManifestEntry, type SubagentOptions, SummarizationStrategy, TaskCompletionSignal, type TextContentPart, type TextEvent, type TextGenerationOptions, type TextOnlyAction, type TextOnlyContext, type TextOnlyCustomHandler, type TextOnlyGadgetConfig, type TextOnlyHandler, type TextOnlyStrategy, type ThinkingChunk, type ThinkingEvent, TimeoutException, type TokenUsage, type TrailingMessage, type TrailingMessageContext, type CompactionEvent$1 as TreeCompactionEvent, type TreeConfig, type GadgetSkippedEvent$1 as TreeGadgetSkippedEvent, type TriggeredLimitInfo, type ValidationIssue, type ValidationResult, type VisionAnalyzeOptions, type VisionAnalyzeResult, audioFromBase64, audioFromBuffer, collectEvents, collectText, complete, createAnthropicProviderFromEnv, createFileLoggingState, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createHuggingFaceProviderFromEnv, createLoadSkillGadget, createLogger, createMediaOutput, createOpenAIProviderFromEnv, createOpenRouterProviderFromEnv, createSubagent, defaultLogger, detectAudioMimeType, detectImageMimeType, discoverProviderAdapters, discoverSkills, extractMessageText, extractRetryAfterMs, filterByDepth, filterByParent, filterRootEvents, format, formatBytes, formatCallNumber, formatDate, formatDuration, formatLLMError, formatLlmRequest, gadgetError, gadgetSuccess, getErrorMessage, getHostExports, getModelId, getPresetGadgets, getProvider, getSubagent, groupByParent, hasHostExports, hasPreset, hasProviderPrefix, hasSubagents, humanDelay, imageFromBase64, imageFromBuffer, imageFromUrl, isAbortError, isAudioPart, isDataUrl, isGadgetEvent, isImagePart, isLLMEvent, isLikelyContextOverflow, isRetryableError, isRootEvent, isSubagentEvent, isTextPart, iterationProgressHint, listPresets, listSubagents, loadSkillsFromDirectory, normalizeMessageContent, parallelGadgetHint, parseDataUrl, parseFrontmatter, parseManifest, parseMetadata, parseRetryAfterHeader, parseSkillContent, parseSkillFile, randomDelay, resetFileLoggingState, resolveConfig, resolveHintTemplate, resolveInstructions, resolveModel, resolvePromptTemplate, resolveRateLimitConfig, resolveRetryConfig, resolveRulesTemplate, resolveSubagentModel, resolveSubagentTimeout, resolveValue, resultWithAudio, resultWithFile, resultWithImage, resultWithImages, resultWithMedia, runWithHandlers, scanResources, schemaToJSONSchema, stream, stripProviderPrefix, substituteArguments, substituteVariables, text, timing, toBase64, truncate, validateAndApplyDefaults, validateGadgetParams, validateGadgetSchema, validateMetadata, withErrorHandling, withRetry, withTimeout };
|
|
11055
|
+
export { AbortException, AbstractGadget, type AddGadgetParams, type AddLLMCallParams, type AfterGadgetExecutionAction, type AfterGadgetExecutionControllerContext, type AfterLLMCallAction, type AfterLLMCallControllerContext, type AfterLLMErrorAction, Agent, AgentBuilder, type AgentHooks, type AgentOptions, AnthropicMessagesProvider, type AudioContentPart, type AudioMimeType, type AudioSource, type BaseExecutionEvent, BaseSessionManager, type BeforeGadgetExecutionAction, type BeforeLLMCallAction, type BeforeSkillActivationAction, BudgetPricingUnavailableError, type CachingConfig, type CachingScope, type ChunkInterceptorContext, type CompactionConfig, type CompactionContext, type CompactionEvent, CompactionManager, type CompactionResult, type CompactionStats, type CompactionStrategy, type CompleteGadgetParams, type CompleteLLMCallParams, type ContentPart, type Controllers, ConversationManager, type CostEstimate, type CostReportingLLMist, type CreateGadgetConfig, type CreateMcpServerOptions, DEFAULT_COMPACTION_CONFIG, DEFAULT_HINTS, DEFAULT_MCP_COMMAND_ALLOWLIST, DEFAULT_PROMPTS, DEFAULT_RATE_LIMIT_CONFIG, DEFAULT_RETRY_CONFIG, DEFAULT_SUMMARIZATION_PROMPT, type EventHandlers, type ExecutionContext, type ExecutionEvent, type ExecutionEventType, type ExecutionNode, type ExecutionNodeType, ExecutionTree, FALLBACK_CHARS_PER_TOKEN, type FileLoggingOptions, type FileLoggingState, type FileWrittenInfo, type FormatLLMErrorContext, GADGET_ARG_PREFIX, GADGET_END_PREFIX, GADGET_START_PREFIX, Gadget, type GadgetCallEvent, GadgetCallParser, type GadgetClass, type GadgetCompleteEvent, type GadgetConfig, type GadgetErrorEvent, type GadgetEvent, type GadgetExample, type GadgetExecuteResult, type GadgetExecuteResultWithMedia, type GadgetExecuteReturn, type GadgetExecutionControllerContext, type GadgetExecutionMode, type GadgetExecutionResult, GadgetExecutor, type GadgetExecutorOptions, type GadgetFactoryExports, type GadgetMediaOutput, type GadgetNode, type GadgetOrClass, GadgetOutputStore, type GadgetParameterInterceptorContext, GadgetRegistry, type GadgetResultInterceptorContext, type GadgetSkippedEvent, type GadgetStartEvent, type GadgetState, GeminiGenerativeProvider, type HintContext, type HintTemplate, type HintsConfig, type HistoryMessage, HookPresets, type HostExports, type HttpMcpServerSpec, HuggingFaceProvider, type HumanInputRequiredEvent, HumanInputRequiredException, HybridStrategy, type IConversationManager, type ISessionManager, type ImageBase64Source, type ImageContentPart, type ImageGenerationOptions, type ImageGenerationResult, type ImageMimeType, type ImageModelSpec, type ImageSource, type ImageUrlSource, type Interceptors, type IterationHintOptions, type JSONSchemaLike, JsonSchemaConversionError, type LLMCallCompleteEvent, type LLMCallControllerContext, type LLMCallErrorEvent, type LLMCallNode, type LLMCallStartEvent, type LLMCallStreamEvent, type LLMErrorControllerContext, type LLMEvent, type LLMGenerationOptions, type LLMMessage, LLMMessageBuilder, type LLMResponseEndEvent, type LLMStream, type LLMStreamChunk, LLMist, type LLMistOptions, type LLMistPackageManifest, LOAD_SKILL_GADGET_NAME, type LoggerOptions, type LoggingOptions, MODEL_ALIASES, McpClient, type McpClientOptions, McpConnectError, type McpContentBlock, McpError, McpLifecycle, type McpServerCapabilities, type McpServerHandle, type McpServerSpec, type McpToolAdapterOptions, McpToolCallError, type McpToolDescriptor, type McpToolResult, McpUntrustedCommandError, type MediaKind, type MediaMetadata, MediaStore, type MessageContent, type MessageInterceptorContext, type MessageRole, type MessageTurn, type ModelDescriptor, type ModelFeatures, ModelIdentifierParser, type ModelLimits, type ModelPricing, ModelRegistry, type ModelSpec, type NodeId, type ObserveChunkContext, type ObserveCompactionContext, type ObserveGadgetCompleteContext, type ObserveGadgetStartContext, type ObserveLLMCallContext, type ObserveLLMCompleteContext, type ObserveLLMErrorContext, type ObserveRateLimitThrottleContext, type ObserveRetryAttemptContext, type ObserveSkillActivatedContext, type Observers, OpenAIChatProvider, type OpenAICompatibleConfig, OpenAICompatibleProvider, type OpenRouterConfig, OpenRouterProvider, type OpenRouterRouting, type OutputLimitConfig, type ParallelGadgetHintOptions, type ParsedGadgetCall, type ParsedSkill, type PrefixConfig, type PresetDefinition, type PromptContext, type PromptTemplate, type PromptTemplateConfig, type ProviderAdapter, type ProviderIdentifier, type RateLimitConfig, type RateLimitStats, RateLimitTracker, type ReasoningConfig, type ReasoningEffort, type ResolveValueOptions, type ResolvedCompactionConfig, type ResolvedRateLimitConfig, type ResolvedRetryConfig, type RetryConfig, type RetryOptions, type SessionManifestEntry, SimpleSessionManager, Skill, type SkillActivation, type SkillActivationControllerContext, type SkillActivationOptions, type SkillInstructionInterceptorContext, type SkillMetadata, SkillRegistry, type SkillResource, type SkillSource, SlidingWindowStrategy, type SpeechGenerationOptions, type SpeechGenerationResult, type SpeechModelSpec, type StdioMcpServerSpec, type StoredMedia, type StoredOutput, type StreamCompleteEvent, type StreamEvent, type StreamProcessingResult, StreamProcessor, type StreamProcessorOptions, type SubagentConfig, type SubagentConfigMap, type SubagentContext, type SubagentManifestEntry, type SubagentOptions, SummarizationStrategy, TaskCompletionSignal, type TextContentPart, type TextEvent, type TextGenerationOptions, type TextOnlyAction, type TextOnlyContext, type TextOnlyCustomHandler, type TextOnlyGadgetConfig, type TextOnlyHandler, type TextOnlyStrategy, type ThinkingChunk, type ThinkingEvent, TimeoutException, type TokenUsage, type TrailingMessage, type TrailingMessageContext, type CompactionEvent$1 as TreeCompactionEvent, type TreeConfig, type GadgetSkippedEvent$1 as TreeGadgetSkippedEvent, type TriggeredLimitInfo, type ValidationIssue, type ValidationResult, type VisionAnalyzeOptions, type VisionAnalyzeResult, assertCommandAllowed, audioFromBase64, audioFromBuffer, collectEvents, collectText, complete, createAnthropicProviderFromEnv, createFileLoggingState, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createHuggingFaceProviderFromEnv, createLoadSkillGadget, createLogger, createMcpServer, createMediaOutput, createOpenAIProviderFromEnv, createOpenRouterProviderFromEnv, createSubagent, defaultLogger, detectAudioMimeType, detectImageMimeType, discoverProviderAdapters, discoverSkills, extractMessageText, extractRetryAfterMs, filterByDepth, filterByParent, filterRootEvents, format, formatBytes, formatCallNumber, formatDate, formatDuration, formatLLMError, formatLlmRequest, gadgetError, gadgetResultToMcpContent, gadgetSuccess, gadgetToMcpTool, getErrorMessage, getHostExports, getModelId, getPresetGadgets, getProvider, getSubagent, groupByParent, hasHostExports, hasPreset, hasProviderPrefix, hasSubagents, humanDelay, imageFromBase64, imageFromBuffer, imageFromUrl, isAbortError, isAudioPart, isDataUrl, isGadgetEvent, isImagePart, isLLMEvent, isLikelyContextOverflow, isRetryableError, isRootEvent, isSubagentEvent, isTextPart, iterationProgressHint, jsonSchemaToZod, listPresets, listSubagents, loadSkillsFromDirectory, mcpToolToGadget, normalizeMessageContent, parallelGadgetHint, parseDataUrl, parseFrontmatter, parseManifest, parseMetadata, parseRetryAfterHeader, parseSkillContent, parseSkillFile, randomDelay, renderSkillForMcpPrompt, resetFileLoggingState, resolveConfig, resolveHintTemplate, resolveInstructions, resolveModel, resolvePromptTemplate, resolveRateLimitConfig, resolveRetryConfig, resolveRulesTemplate, resolveSubagentModel, resolveSubagentTimeout, resolveValue, resultWithAudio, resultWithFile, resultWithImage, resultWithImages, resultWithMedia, runGadgetForMcp, runWithHandlers, scanResources, schemaToJSONSchema, skillToMcpPrompt, stream, stripProviderPrefix, substituteArguments, substituteVariables, text, timing, toBase64, truncate, validateAndApplyDefaults, validateGadgetParams, validateGadgetSchema, validateMetadata, withErrorHandling, withRetry, withTimeout };
|