libfx 0.0.13 → 0.0.14-dev.1534.g6afa7c33dac5

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/types/mcp.d.ts ADDED
@@ -0,0 +1,41 @@
1
+ // `libfx/mcp` (mcp.js): tools and instructions from a host-owned MCP client.
2
+ import type { FxAgentHostTool } from "./libfx.cjs";
3
+
4
+ /**
5
+ * The parts of an MCP client the adapter calls, with the MCP TypeScript SDK
6
+ * v1 signatures. Transport, authentication, elicitation, and cleanup stay
7
+ * with the host.
8
+ */
9
+ export interface McpClient {
10
+ /** Resolves to the tools array or `{ tools, nextCursor? }`. */
11
+ listTools(params?: { cursor: string }): unknown;
12
+ /** Called with the tool's original name, the model's arguments, and the turn's `signal` in `options`. */
13
+ callTool(params: { name: string; arguments?: unknown }, resultSchema?: unknown, options?: { signal?: AbortSignal }): unknown;
14
+ /** Required when `resources` is given. */
15
+ readResource?(params: { uri: string }): unknown;
16
+ /** Required when `prompts` is given. */
17
+ getPrompt?(params: { name: string; arguments?: Record<string, string> }): unknown;
18
+ close?(): unknown;
19
+ }
20
+
21
+ /** Options for `createMcpAdapter()`. */
22
+ export interface McpAdapterOptions {
23
+ /** Prepended to each tool name: letters, digits, `_`, or `-`. */
24
+ prefix?: string;
25
+ /** Resource URIs whose text becomes instructions. */
26
+ resources?: readonly string[];
27
+ /** Prompts whose text becomes instructions: a name, or a `getPrompt()` request. */
28
+ prompts?: readonly (string | { name: string; arguments?: Record<string, string> })[];
29
+ }
30
+
31
+ /** What `createMcpAdapter()` resolves to. Pass `tools` and `instructions` to the agent. */
32
+ export interface McpAdapter {
33
+ /** Each tool has `idempotent: false`; set it to `true` on a tool known to be safe to run twice. */
34
+ tools: FxAgentHostTool[];
35
+ instructions: string;
36
+ /** Closes the client once. */
37
+ close(): Promise<void>;
38
+ }
39
+
40
+ /** Adapts a host-owned MCP client into agent tools and instructions. */
41
+ export declare function createMcpAdapter(client: McpClient, options?: McpAdapterOptions): Promise<McpAdapter>;
@@ -0,0 +1,158 @@
1
+ // `libfx` and `libfx/node` on Node.js, for `require` (node.cjs). The ESM entry,
2
+ // node.d.ts, re-exports this file: node.cjs is built from node.js.
3
+ import type {
4
+ FxAgent,
5
+ FxAgentOptions,
6
+ FxBackendInfo,
7
+ FxBackendInfoOptions,
8
+ FxEngine,
9
+ FxEngineOptions,
10
+ FxNodeBackendOptions,
11
+ FxTerminal,
12
+ FxTerminalOptions,
13
+ } from "./libfx.cjs";
14
+
15
+ export {
16
+ createMemoryPersistence,
17
+ encodeXtermKeyEvent,
18
+ FxFencedError,
19
+ FxJournalVersionError,
20
+ fxSdkApiVersion,
21
+ listModels,
22
+ memory,
23
+ supportsJspi,
24
+ wakeHandler,
25
+ xtermAdapter,
26
+ } from "./libfx.cjs";
27
+
28
+ export type {
29
+ Durability,
30
+ FxAccepted,
31
+ FxAgent,
32
+ FxAgentEvent,
33
+ FxAgentHostTool,
34
+ FxAgentKeyedTool,
35
+ FxAgentOptions,
36
+ FxAgentTool,
37
+ FxAgentTools,
38
+ FxApiKeyCredentials,
39
+ FxBackendAttempt,
40
+ FxBackendChoice,
41
+ FxBackendInfo,
42
+ FxBackendInfoOptions,
43
+ FxBackendReason,
44
+ FxBackendReasonCode,
45
+ FxBytes,
46
+ FxCheckpointMeta,
47
+ FxCodexProvider,
48
+ FxCustomProvider,
49
+ FxCustomProviderDefinition,
50
+ FxCustomProviderModel,
51
+ FxEffort,
52
+ FxEngine,
53
+ FxEngineEvent,
54
+ FxEngineOptions,
55
+ FxEnginePromptOptions,
56
+ FxEngineStorage,
57
+ FxEngineTurn,
58
+ FxEngineTurnResult,
59
+ FxErrorSummary,
60
+ FxFetch,
61
+ FxFollowUp,
62
+ FxGatewayProvider,
63
+ FxGrokProvider,
64
+ FxHostTool,
65
+ FxIdleResult,
66
+ FxImageBlock,
67
+ FxJsonSchema,
68
+ FxKeyedTool,
69
+ FxKeyEventLike,
70
+ FxListModelsOptions,
71
+ FxModelCatalogEntry,
72
+ FxModelChoice,
73
+ FxModelOptions,
74
+ FxNodeBackendOptions,
75
+ FxNodeWasmSource,
76
+ FxOnAmbiguous,
77
+ FxPromptBlock,
78
+ FxPromptInput,
79
+ FxPromptOptions,
80
+ FxProviderCredentials,
81
+ FxProviderTool,
82
+ FxResizedImage,
83
+ FxResourceBlock,
84
+ FxResumeOptions,
85
+ FxResumeTurn,
86
+ FxSession,
87
+ FxSessionEvent,
88
+ FxSessionImageBlock,
89
+ FxSessionOptions,
90
+ FxSessionPromptInput,
91
+ FxSessionTurnEvent,
92
+ FxSharedOptions,
93
+ FxSteer,
94
+ FxSteerOptions,
95
+ FxSteered,
96
+ FxSteeringInput,
97
+ FxStopReason,
98
+ FxStreamLine,
99
+ FxTerminal,
100
+ FxTerminalAdapter,
101
+ FxTerminalEvent,
102
+ FxTerminalOptions,
103
+ FxTextBlock,
104
+ FxTool,
105
+ FxToolContext,
106
+ FxToolImage,
107
+ FxToolResult,
108
+ FxTools,
109
+ FxTurn,
110
+ FxTurnEvent,
111
+ FxTurnResult,
112
+ FxTurnView,
113
+ FxUsage,
114
+ FxWasmModule,
115
+ FxWorkspace,
116
+ FxWorkspaceExecResult,
117
+ FxXtermLike,
118
+ JournalRecord,
119
+ JsonObject,
120
+ JsonValue,
121
+ MemoryOptions,
122
+ MemoryPersistence,
123
+ Persistence,
124
+ PersistenceLoadResult,
125
+ } from "./libfx.cjs";
126
+
127
+ /** Options for `createFxAgent()` on Node.js. */
128
+ export type FxNodeAgentOptions = FxAgentOptions & FxNodeBackendOptions;
129
+
130
+ /** Options for `createFxEngine()` on Node.js. */
131
+ export type FxNodeEngineOptions = FxEngineOptions & FxNodeBackendOptions;
132
+
133
+ /** Options for `createFxTerminal()` on Node.js. */
134
+ export type FxNodeTerminalOptions = FxTerminalOptions & FxNodeBackendOptions;
135
+
136
+ /**
137
+ * An agent whose sessions survive crashes, timeouts, and redeployments. It
138
+ * returns at once and does no I/O until a session runs a turn. Without
139
+ * `durability`, sessions live in Vercel's World on Vercel and in local files
140
+ * elsewhere.
141
+ */
142
+ export declare function createFxAgent(options?: FxNodeAgentOptions): FxAgent;
143
+
144
+ /**
145
+ * The kernel under `createFxAgent()`: one conversation, held in the memory of
146
+ * the process that runs it. `apiKey` is required, and it resolves once its
147
+ * backend has loaded.
148
+ */
149
+ export declare function createFxEngine(options: FxNodeEngineOptions): Promise<FxEngine>;
150
+
151
+ /** The interactive terminal harness. */
152
+ export declare function createFxTerminal(options: FxNodeTerminalOptions): Promise<FxTerminal>;
153
+
154
+ /** Inspects backend availability without creating an agent or terminal. */
155
+ export declare function getBackendInfo(options?: FxBackendInfoOptions): Promise<FxBackendInfo>;
156
+
157
+ /** The version of the libfx agent API. */
158
+ export declare const libfxApiVersion: 3;
@@ -0,0 +1,3 @@
1
+ // `libfx` and `libfx/node` on Node.js, for `import` (node.js). The CommonJS
2
+ // entry, node.cjs, is built from node.js, so both declare the same exports.
3
+ export * from "./node.cjs";
@@ -0,0 +1,25 @@
1
+ // `libfx/skills/node` (skills-node.js): loads a `SKILL.md` explicitly in
2
+ // Node.js or Bun.
3
+ import type { FxAgentTool } from "./libfx.cjs";
4
+ import type { SkillRecord, SkillResource } from "./skills.js";
5
+
6
+ export { createSkillsAdapter } from "./skills.js";
7
+ export type { SkillRecord, SkillResource, SkillsAdapter } from "./skills.js";
8
+
9
+ /** Options for `loadSkillFile()`. */
10
+ export interface LoadSkillFileOptions {
11
+ /** Replaces `fs.promises.readFile`. */
12
+ readFile?: (path: string, encoding: "utf8") => string | Promise<string>;
13
+ resources?: readonly SkillResource[];
14
+ tools?: readonly FxAgentTool[];
15
+ }
16
+
17
+ /** A skill read from a `SKILL.md`: its frontmatter `name` and `description`, and its body as instructions. */
18
+ export interface LoadedSkill extends SkillRecord {
19
+ description: string;
20
+ resources: readonly SkillResource[];
21
+ tools: readonly FxAgentTool[];
22
+ }
23
+
24
+ /** Reads one `SKILL.md`. Without a frontmatter `name`, the file name is the skill's name. */
25
+ export declare function loadSkillFile(path: string, options?: LoadSkillFileOptions): Promise<LoadedSkill>;
@@ -0,0 +1,28 @@
1
+ // `libfx/skills` (skills.js): instructions and tools from already-loaded
2
+ // skill records.
3
+ import type { FxAgentTool } from "./libfx.cjs";
4
+
5
+ /** A resource whose text joins its skill's instructions. */
6
+ export interface SkillResource {
7
+ uri: string;
8
+ text: string;
9
+ }
10
+
11
+ /** An already-loaded skill. */
12
+ export interface SkillRecord {
13
+ name: string;
14
+ instructions: string;
15
+ description?: string;
16
+ resources?: readonly SkillResource[];
17
+ /** Each host tool sets `idempotent`, as `createFxAgent()` requires. */
18
+ tools?: readonly FxAgentTool[];
19
+ }
20
+
21
+ /** What `createSkillsAdapter()` returns: spread it into the agent options. */
22
+ export interface SkillsAdapter {
23
+ instructions: string;
24
+ tools: FxAgentTool[];
25
+ }
26
+
27
+ /** Turns up to 64 skill records into instructions and tools. */
28
+ export declare function createSkillsAdapter(records: readonly SkillRecord[]): SkillsAdapter;
@@ -0,0 +1,99 @@
1
+ // `libfx/wasm` (fx-sdk.js): the WebAssembly SDK with no packaged asset paths,
2
+ // so every factory takes its `wasm` explicitly.
3
+ import type { FxEngine, FxEngineOptions, FxTerminal, FxTerminalOptions, FxWasmSource } from "./libfx.cjs";
4
+
5
+ export {
6
+ createMemoryPersistence,
7
+ encodeXtermKeyEvent,
8
+ FxFencedError,
9
+ FxJournalVersionError,
10
+ fxSdkApiVersion,
11
+ listModels,
12
+ supportsJspi,
13
+ xtermAdapter,
14
+ } from "./libfx.cjs";
15
+
16
+ export type {
17
+ FxApiKeyCredentials,
18
+ FxBytes,
19
+ FxCheckpointMeta,
20
+ FxCodexProvider,
21
+ FxCustomProvider,
22
+ FxCustomProviderDefinition,
23
+ FxCustomProviderModel,
24
+ FxEffort,
25
+ FxEngine,
26
+ FxEngineEvent,
27
+ FxEngineOptions,
28
+ FxEnginePromptOptions,
29
+ FxEngineStorage,
30
+ FxEngineTurn,
31
+ FxEngineTurnResult,
32
+ FxErrorSummary,
33
+ FxFetch,
34
+ FxFollowUp,
35
+ FxGatewayProvider,
36
+ FxGrokProvider,
37
+ FxHostTool,
38
+ FxImageBlock,
39
+ FxJsonSchema,
40
+ FxKeyedTool,
41
+ FxKeyEventLike,
42
+ FxListModelsOptions,
43
+ FxModelCatalogEntry,
44
+ FxModelChoice,
45
+ FxModelOptions,
46
+ FxOnAmbiguous,
47
+ FxPromptBlock,
48
+ FxPromptInput,
49
+ FxProviderCredentials,
50
+ FxProviderTool,
51
+ FxResizedImage,
52
+ FxResourceBlock,
53
+ FxResumeOptions,
54
+ FxSharedOptions,
55
+ FxSteer,
56
+ FxSteeringInput,
57
+ FxStopReason,
58
+ FxTerminal,
59
+ FxTerminalAdapter,
60
+ FxTerminalEvent,
61
+ FxTerminalOptions,
62
+ FxTextBlock,
63
+ FxTool,
64
+ FxToolContext,
65
+ FxToolImage,
66
+ FxToolResult,
67
+ FxTools,
68
+ FxTurnEvent,
69
+ FxUsage,
70
+ FxWasmModule,
71
+ FxWasmSource,
72
+ FxWorkspace,
73
+ FxWorkspaceExecResult,
74
+ FxXtermLike,
75
+ JournalRecord,
76
+ JsonObject,
77
+ JsonValue,
78
+ MemoryPersistence,
79
+ Persistence,
80
+ PersistenceLoadResult,
81
+ } from "./libfx.cjs";
82
+
83
+ /** Options for `createFxEngine()` from `libfx/wasm`. */
84
+ export type FxWasmEngineOptions = FxEngineOptions & {
85
+ /** The `fx-core.wasm` asset. */
86
+ wasm: FxWasmSource;
87
+ };
88
+
89
+ /** Options for `createFxTerminal()` from `libfx/wasm`. */
90
+ export type FxWasmTerminalOptions = FxTerminalOptions & {
91
+ /** The `fx-term.wasm` asset. */
92
+ wasm: FxWasmSource;
93
+ };
94
+
95
+ /** One session on one fx core, with no durability of its own. Requires JSPI. */
96
+ export declare function createFxEngine(options: FxWasmEngineOptions): Promise<FxEngine>;
97
+
98
+ /** The interactive terminal harness on WebAssembly. Requires JSPI. */
99
+ export declare function createFxTerminal(options: FxWasmTerminalOptions): Promise<FxTerminal>;