libfx 0.0.13-dev.1472.g2c7a4f83f06f → 0.0.13-dev.1510.ga878d4900a6a
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 +60 -23
- package/browser.js +1 -1
- package/durable/local.mjs +55 -55
- package/durable/vercel.mjs +64 -64
- package/durable/world.mjs +1 -1
- package/durable.js +504 -104
- package/fx-core.wasm +0 -0
- package/fx-harness.js +20 -4
- package/fx-sdk.js +92 -36
- package/fx-term.wasm +0 -0
- package/libfx.darwin-arm64.node +0 -0
- package/libfx.darwin-x64.node +0 -0
- package/libfx.linux-arm64.node +0 -0
- package/libfx.linux-x64.node +0 -0
- package/mcp.js +3 -0
- package/node.cjs +446 -125
- package/node.js +22 -6
- package/package.json +1 -1
- package/types/browser.d.ts +5 -1
- package/types/durable-vercel.d.ts +8 -2
- package/types/durable-world.d.ts +16 -0
- package/types/libfx.d.cts +62 -8
- package/types/mcp.d.ts +3 -2
- package/types/node.d.cts +6 -1
- package/types/skills-node.d.ts +3 -3
- package/types/skills.d.ts +4 -3
package/node.js
CHANGED
|
@@ -8,7 +8,7 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
8
8
|
import { CoreOutput } from "./core-output.js";
|
|
9
9
|
import { loadModule, withModuleFailure } from "./wasm-module.js";
|
|
10
10
|
import { fetchCleanupAction, cleanupTimeoutMs, cleanupByteLimit } from "./fetch-cleanup.js";
|
|
11
|
-
import { createDurableAgentFactory, memory } from "./durable.js";
|
|
11
|
+
import { createDurableAgentFactory, memory, wakeHandler } from "./durable.js";
|
|
12
12
|
import { fxHarness } from "./fx-harness.js";
|
|
13
13
|
import {
|
|
14
14
|
createFxEngine as createWasmAgent,
|
|
@@ -24,8 +24,8 @@ import {
|
|
|
24
24
|
xtermAdapter,
|
|
25
25
|
} from "./fx-sdk.js";
|
|
26
26
|
|
|
27
|
-
export { createMemoryPersistence, encodeXtermKeyEvent, FxFencedError, FxJournalVersionError, fxSdkApiVersion, listModels, memory, supportsJspi, xtermAdapter };
|
|
28
|
-
export const libfxApiVersion =
|
|
27
|
+
export { createMemoryPersistence, encodeXtermKeyEvent, FxFencedError, FxJournalVersionError, fxSdkApiVersion, listModels, memory, supportsJspi, wakeHandler, xtermAdapter };
|
|
28
|
+
export const libfxApiVersion = 3;
|
|
29
29
|
const nativeCoreApiVersion = 4;
|
|
30
30
|
|
|
31
31
|
const fetchOperationStale = 0;
|
|
@@ -676,14 +676,30 @@ export async function createFxEngine(options = {}) {
|
|
|
676
676
|
// on Vercel, otherwise files in the temporary directory. Each is its own
|
|
677
677
|
// module, loaded only here: a bundler copies the file the URL names and
|
|
678
678
|
// leaves the import itself to Node.
|
|
679
|
-
|
|
679
|
+
// Agents created without a durability share one for each place sessions
|
|
680
|
+
// live, as agents passed one durability do, so they can send each other's
|
|
681
|
+
// prompts on.
|
|
682
|
+
const environments = new Map();
|
|
683
|
+
function environmentDurability() {
|
|
684
|
+
const dir = process.env.VERCEL ? null : process.env.FX_SESSIONS_DIR || resolve(tmpdir(), "libfx", "sessions");
|
|
685
|
+
const key = dir ?? "vercel";
|
|
686
|
+
if (!environments.has(key)) {
|
|
687
|
+
environments.set(key, chooseEnvironmentDurability(dir).catch((error) => {
|
|
688
|
+
environments.delete(key);
|
|
689
|
+
throw error;
|
|
690
|
+
}));
|
|
691
|
+
}
|
|
692
|
+
return environments.get(key);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
async function chooseEnvironmentDurability(dir) {
|
|
680
696
|
const load = (asset) => import(/* webpackIgnore: true */ /* turbopackIgnore: true */ (asset.protocol === "" ? bundledAssetUrl(asset) : asset).href);
|
|
681
|
-
if (
|
|
697
|
+
if (dir === null) {
|
|
682
698
|
const { vercel } = await load(new URL("./durable/vercel.mjs", import.meta.url));
|
|
683
699
|
return vercel();
|
|
684
700
|
}
|
|
685
701
|
const { local } = await load(new URL("./durable/local.mjs", import.meta.url));
|
|
686
|
-
return local({ dir
|
|
702
|
+
return local({ dir });
|
|
687
703
|
}
|
|
688
704
|
|
|
689
705
|
/**
|
package/package.json
CHANGED
package/types/browser.d.ts
CHANGED
|
@@ -26,7 +26,11 @@ export type {
|
|
|
26
26
|
FxAccepted,
|
|
27
27
|
FxAgent,
|
|
28
28
|
FxAgentEvent,
|
|
29
|
+
FxAgentHostTool,
|
|
30
|
+
FxAgentKeyedTool,
|
|
29
31
|
FxAgentOptions,
|
|
32
|
+
FxAgentTool,
|
|
33
|
+
FxAgentTools,
|
|
30
34
|
FxApiKeyCredentials,
|
|
31
35
|
FxBrowserBackendOptions,
|
|
32
36
|
FxBytes,
|
|
@@ -130,4 +134,4 @@ export declare function createFxEngine(options: FxBrowserEngineOptions): Promise
|
|
|
130
134
|
export declare function createFxTerminal(options: FxBrowserTerminalOptions): Promise<FxTerminal>;
|
|
131
135
|
|
|
132
136
|
/** The version of the libfx agent API. */
|
|
133
|
-
export declare const libfxApiVersion:
|
|
137
|
+
export declare const libfxApiVersion: 3;
|
|
@@ -8,9 +8,15 @@ export type { Durability } from "./libfx.cjs";
|
|
|
8
8
|
export interface VercelOptions {
|
|
9
9
|
/** How long before the function's deadline each delivery stops. Default 30000. */
|
|
10
10
|
reserveMs?: number;
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Renew a lease of this length in the session's log while a turn runs, every third of it, so a function that stopped
|
|
13
|
+
* frees its session this long after its last renewal. Without it, nothing is renewed: a function holds its session
|
|
14
|
+
* for as long as Vercel Queues keeps the turn's message for it, and a function that died frees its session when the
|
|
15
|
+
* queue delivers that message again, about a second after its process exits, or once the queue's hold on it runs
|
|
16
|
+
* out. At least 1000.
|
|
17
|
+
*/
|
|
12
18
|
leaseMs?: number;
|
|
13
19
|
}
|
|
14
20
|
|
|
15
|
-
/** Keeps sessions in Vercel's World.
|
|
21
|
+
/** Keeps sessions in Vercel's World. A function holds its session while Vercel Queues keeps its message for it, and the next delivery of that message continues a turn whose function died. */
|
|
16
22
|
export declare function vercel(options?: VercelOptions): Durability;
|
package/types/durable-world.d.ts
CHANGED
|
@@ -45,6 +45,22 @@ export type WorldOptions = {
|
|
|
45
45
|
queueDurable?: boolean;
|
|
46
46
|
/** How often a waiting worker reads the session again. Default 1000. */
|
|
47
47
|
pollMs?: number;
|
|
48
|
+
/**
|
|
49
|
+
* The queue keeps a message from every other delivery while one handles it, and delivers it again once that
|
|
50
|
+
* delivery's process is gone, as Vercel Queues does. Without liveness, a worker then holds its session for as long as
|
|
51
|
+
* its delivery runs, up to its deadline, and renews nothing: the next delivery of the same message takes the session
|
|
52
|
+
* over. The World must pass each handler call the queue's `messageId` and delivery `attempt`. A worker with no
|
|
53
|
+
* deadline renews its lease all the same. Default false.
|
|
54
|
+
*/
|
|
55
|
+
queueLeases?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* With `queueLeases`: a prompt runs in the request that took it when no worker holds the session, and the queue keeps
|
|
58
|
+
* the prompt as a backstop it delivers only after that request's deadline. The request's lease names the backstop, so
|
|
59
|
+
* if the request died, the backstop takes the session over. Default true with `queueLeases`.
|
|
60
|
+
*/
|
|
61
|
+
runInRequest?: boolean;
|
|
62
|
+
/** Keeps the request alive until `work`, a turn it runs after its response, settles, such as Vercel's `waitUntil` or Next's `after()`. */
|
|
63
|
+
waitUntil?(work: Promise<void>): void;
|
|
48
64
|
/** Without liveness, how long a lease lasts after its worker took or last renewed it; renewed every third of that. At least 1000. Default 15000. */
|
|
49
65
|
leaseMs?: number;
|
|
50
66
|
/** Each delivery stops `reserveMs` before `maxDurationMs`, or before the World's `getRuntimeDeadline()`. No limit by default. */
|
package/types/libfx.d.cts
CHANGED
|
@@ -170,13 +170,19 @@ export interface FxHostTool<Input = any> {
|
|
|
170
170
|
inputSchema: FxJsonSchema;
|
|
171
171
|
/** Runs one call. A string is sent as is, an `FxToolResult` as rich content, and any other value as JSON text. */
|
|
172
172
|
execute: (input: Input, context: FxToolContext) => unknown;
|
|
173
|
-
/** Running a call twice is safe, so a call cut off by a crash runs again. */
|
|
173
|
+
/** Running a call twice is safe, so a call cut off by a crash runs again. Default `false`. */
|
|
174
174
|
idempotent?: boolean;
|
|
175
|
-
/** Calls must not overlap others: one starts after every earlier call in the response finishes. */
|
|
175
|
+
/** Calls must not overlap others: one starts after every earlier call in the response finishes. Defaults to `!idempotent`. */
|
|
176
176
|
writes?: boolean;
|
|
177
177
|
providerExecuted?: false;
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
+
/** A tool the JavaScript host runs for `createFxAgent()`, which must say whether a call is safe to run twice. */
|
|
181
|
+
export interface FxAgentHostTool<Input = any> extends FxHostTool<Input> {
|
|
182
|
+
/** `true` when running a call twice is harmless, `false` when it is not. Required. */
|
|
183
|
+
idempotent: boolean;
|
|
184
|
+
}
|
|
185
|
+
|
|
180
186
|
/** A tool the provider runs, such as Gateway web search. `web_search` is currently the supported name. */
|
|
181
187
|
export interface FxProviderTool {
|
|
182
188
|
name: "web_search";
|
|
@@ -195,6 +201,17 @@ export type FxKeyedTool =
|
|
|
195
201
|
/** At most 64 tools: an array of descriptors, or an object keyed by tool name. */
|
|
196
202
|
export type FxTools = readonly FxTool[] | { readonly [name: string]: FxKeyedTool };
|
|
197
203
|
|
|
204
|
+
/** A tool descriptor for `createFxAgent()`. */
|
|
205
|
+
export type FxAgentTool = FxAgentHostTool | FxProviderTool;
|
|
206
|
+
|
|
207
|
+
/** A `createFxAgent()` tool descriptor in an object keyed by tool name. */
|
|
208
|
+
export type FxAgentKeyedTool =
|
|
209
|
+
| (Omit<FxAgentHostTool, "name"> & { name?: string })
|
|
210
|
+
| (Omit<FxProviderTool, "name"> & { name?: "web_search" });
|
|
211
|
+
|
|
212
|
+
/** At most 64 `createFxAgent()` tools: an array of descriptors, or an object keyed by tool name. */
|
|
213
|
+
export type FxAgentTools = readonly FxAgentTool[] | { readonly [name: string]: FxAgentKeyedTool };
|
|
214
|
+
|
|
198
215
|
// ---------------------------------------------------------------------------
|
|
199
216
|
// Turn events and results
|
|
200
217
|
|
|
@@ -275,6 +292,8 @@ export type FxEngineEvent = FxEventBase & (
|
|
|
275
292
|
export type FxSessionEvent = FxEventBase & (
|
|
276
293
|
| { type: "session.error"; sessionId: string; error: FxErrorSummary }
|
|
277
294
|
| { type: "session.fenced"; sessionId: string; epoch: number }
|
|
295
|
+
/** A message for a session of the agent `agent` reached this one, which sent it on. */
|
|
296
|
+
| { type: "session.forwarded"; sessionId: string; agent: string }
|
|
278
297
|
/** `cutoffs`: the times in a row the deadline cut off the same step, this one included. */
|
|
279
298
|
| { type: "session.deadline"; sessionId: string; epoch: number; cutoffs: number }
|
|
280
299
|
| { type: "ui.error"; sessionId: string; error: string }
|
|
@@ -341,16 +360,31 @@ export interface JournalRecord {
|
|
|
341
360
|
export interface PersistenceLoadResult {
|
|
342
361
|
checkpoint?: { data: FxBytes; through: string };
|
|
343
362
|
journal?: Iterable<{ cursor: string; data: FxBytes }> | AsyncIterable<{ cursor: string; data: FxBytes }>;
|
|
363
|
+
/** The cursor the next `append()` names as `expected`, for a store whose log holds entries of its own after the last record. Defaults to the last record's cursor, or the checkpoint's `through`. */
|
|
364
|
+
head?: string | null;
|
|
344
365
|
}
|
|
345
366
|
|
|
367
|
+
/** What one record tells a store that set `marks: true` about turns: a turn started, ended or yielded, or an input was accepted. Other marks may appear; a store keeps or ignores them. */
|
|
368
|
+
export type FxJournalMark =
|
|
369
|
+
| { start: string }
|
|
370
|
+
| { end: true }
|
|
371
|
+
| { yield: true }
|
|
372
|
+
| { accepted: string }
|
|
373
|
+
| { step: string };
|
|
374
|
+
|
|
346
375
|
/** A store for one session's records and checkpoints. libfx writes opaque bytes; the store never parses them. */
|
|
347
376
|
export interface Persistence {
|
|
348
377
|
/** Called once by `createFxEngine()`. Resolve to `{}` for a session with nothing stored. */
|
|
349
378
|
load(): Promise<PersistenceLoadResult>;
|
|
350
|
-
/**
|
|
351
|
-
|
|
379
|
+
/**
|
|
380
|
+
* Stores one record and resolves to its cursor. Reject with an `FxFencedError` when `expected` is not the last stored record's cursor.
|
|
381
|
+
* `barrier` is true when libfx waits for the record before it goes on, such as before a tool call with effects. A store may resolve a record with `barrier: false` before it is durable, if it keeps records in order and resolves one with `barrier: true` only once it and every record before it are durable.
|
|
382
|
+
*/
|
|
383
|
+
append(input: { expected: string | null; idempotencyKey: string; data: Uint8Array; barrier: boolean; marks?: FxJournalMark[] }): Promise<{ cursor: string }>;
|
|
352
384
|
/** Stores a checkpoint covering the records through `through`. */
|
|
353
385
|
saveCheckpoint?(input: { through: string; data: Uint8Array }): Promise<void>;
|
|
386
|
+
/** Set to receive each record's `marks`, for a store that tracks turns and accepted inputs without reading records. */
|
|
387
|
+
marks?: boolean;
|
|
354
388
|
}
|
|
355
389
|
|
|
356
390
|
/** The persistence store `createMemoryPersistence()` returns. */
|
|
@@ -370,7 +404,7 @@ export declare class FxFencedError extends Error {
|
|
|
370
404
|
code: "FX_FENCED";
|
|
371
405
|
}
|
|
372
406
|
|
|
373
|
-
/** The journal was written by a newer libfx than this one. Its `code` is `FX_JOURNAL_VERSION`. */
|
|
407
|
+
/** The journal, or the `checkpoint` option, was written by a newer libfx than this one. Its `code` is `FX_JOURNAL_VERSION`. */
|
|
374
408
|
export declare class FxJournalVersionError extends Error {
|
|
375
409
|
constructor(message?: string);
|
|
376
410
|
name: "FxJournalVersionError";
|
|
@@ -393,12 +427,16 @@ export interface FxEnginePromptOptions {
|
|
|
393
427
|
/** The turn's id, so a retried prompt continues or answers the same turn. 1 to 128 letters, digits, `.`, `_`, or `-`. */
|
|
394
428
|
turnId?: string;
|
|
395
429
|
onAmbiguous?: FxOnAmbiguous;
|
|
430
|
+
/** With `persistence`: a time, in milliseconds since the epoch, after which the turn stops before its next model request with the stop reason `yielded`. The journal keeps it open, and the next `resume()` continues it without telling the model it was interrupted. */
|
|
431
|
+
yieldAt?: number;
|
|
396
432
|
}
|
|
397
433
|
|
|
398
434
|
/** Options for an engine's `resume()`. */
|
|
399
435
|
export interface FxResumeOptions {
|
|
400
436
|
signal?: AbortSignal;
|
|
401
437
|
onAmbiguous?: FxOnAmbiguous;
|
|
438
|
+
/** As `FxEnginePromptOptions.yieldAt`. */
|
|
439
|
+
yieldAt?: number;
|
|
402
440
|
}
|
|
403
441
|
|
|
404
442
|
/** How an engine turn ended. */
|
|
@@ -570,13 +608,21 @@ export declare function memory(options?: MemoryOptions): Durability;
|
|
|
570
608
|
// Durable agents
|
|
571
609
|
|
|
572
610
|
/** Options for `createFxAgent()`. */
|
|
573
|
-
export type FxAgentOptions = FxSharedOptions<FxAgentEvent> & FxModelChoice & (FxGatewayProvider | FxCodexProvider | FxGrokProvider | FxCustomProvider) & {
|
|
611
|
+
export type FxAgentOptions = Omit<FxSharedOptions<FxAgentEvent>, "tools"> & FxModelChoice & (FxGatewayProvider | FxCodexProvider | FxGrokProvider | FxCustomProvider) & {
|
|
612
|
+
/** Every host tool sets `idempotent`. */
|
|
613
|
+
tools?: FxAgentTools;
|
|
574
614
|
/** The AI Gateway credential. Without it, libfx uses `AI_GATEWAY_API_KEY`, then on Vercel the deployment's OIDC token. */
|
|
575
615
|
apiKey?: string | undefined;
|
|
576
616
|
/** Where sessions live. Without it, libfx picks one from the environment. */
|
|
577
617
|
durability?: Durability | undefined;
|
|
578
618
|
/** Checkpoint bytes the agent's new sessions start from. */
|
|
579
619
|
checkpoint?: FxBytes;
|
|
620
|
+
/**
|
|
621
|
+
* The agent's name, 1 to 64 letters, digits, `.`, `_` or `-`, starting with a letter or digit. Default `"default"`.
|
|
622
|
+
* A session's turns run only on agents with the name of the agent that created it, so an app can have several
|
|
623
|
+
* durable agents. Agents with the same name are copies of one agent and share its sessions' turns.
|
|
624
|
+
*/
|
|
625
|
+
name?: string;
|
|
580
626
|
};
|
|
581
627
|
|
|
582
628
|
/** Options for `agent.session()`. Each applies to the turns this session object starts. */
|
|
@@ -626,7 +672,7 @@ export interface FxIdleResult {
|
|
|
626
672
|
/** A turn event as a durable session delivers it, with the lease epoch of the worker that wrote it. */
|
|
627
673
|
export type FxSessionTurnEvent = FxTurnEvent & { epoch?: number };
|
|
628
674
|
|
|
629
|
-
/** A view of one durable turn. Dropping it cancels nothing; call `session.cancel()` to stop the turn. */
|
|
675
|
+
/** A view of one durable turn. It reads the session stream only once its events, `readable` or `result` are used. Dropping it cancels nothing; call `session.cancel()` to stop the turn. */
|
|
630
676
|
export interface FxTurnView<Result> {
|
|
631
677
|
/** Resolves once the prompt is stored, or at once for a prompt whose signal had already aborted. */
|
|
632
678
|
readonly accepted: Promise<FxAccepted>;
|
|
@@ -691,6 +737,8 @@ export interface FxSession {
|
|
|
691
737
|
|
|
692
738
|
/** An agent: the configuration its sessions run under. Create one per server and open a session per conversation. */
|
|
693
739
|
export interface FxAgent {
|
|
740
|
+
/** The agent's name, `"default"` unless `createFxAgent()` gave one. */
|
|
741
|
+
readonly name: string;
|
|
694
742
|
/** Opens the session `id`, or starts a new one without it. Any other value, `null` included, throws. */
|
|
695
743
|
session(id?: string, options?: FxSessionOptions): FxSession;
|
|
696
744
|
/** An id for a new session, before its first prompt. */
|
|
@@ -701,12 +749,18 @@ export interface FxAgent {
|
|
|
701
749
|
prompt(input: FxSessionPromptInput, options?: FxPromptOptions): FxTurn;
|
|
702
750
|
/** The history of the session `agent.prompt()` uses, as opaque bytes. */
|
|
703
751
|
checkpoint(): Promise<Uint8Array>;
|
|
704
|
-
/** The request handler a deployment mounts for queue deliveries. */
|
|
752
|
+
/** The request handler a deployment mounts for queue deliveries; it delivers to whichever agent in the process a message names. */
|
|
705
753
|
wakeHandler(): (request: Request) => Promise<Response>;
|
|
706
754
|
/** Waits for the turns this process is running, then lets their sessions go. */
|
|
707
755
|
close(): Promise<void>;
|
|
708
756
|
}
|
|
709
757
|
|
|
758
|
+
/**
|
|
759
|
+
* The request handler a deployment mounts for queue deliveries, for every durable agent in the process: each
|
|
760
|
+
* delivery goes to the agent its message names. One route and one queue trigger serve any number of agents.
|
|
761
|
+
*/
|
|
762
|
+
export declare function wakeHandler(): (request: Request) => Promise<Response>;
|
|
763
|
+
|
|
710
764
|
// ---------------------------------------------------------------------------
|
|
711
765
|
// Backend diagnostics (Node.js)
|
|
712
766
|
|
package/types/mcp.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// `libfx/mcp` (mcp.js): tools and instructions from a host-owned MCP client.
|
|
2
|
-
import type {
|
|
2
|
+
import type { FxAgentHostTool } from "./libfx.cjs";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The parts of an MCP client the adapter calls, with the MCP TypeScript SDK
|
|
@@ -30,7 +30,8 @@ export interface McpAdapterOptions {
|
|
|
30
30
|
|
|
31
31
|
/** What `createMcpAdapter()` resolves to. Pass `tools` and `instructions` to the agent. */
|
|
32
32
|
export interface McpAdapter {
|
|
33
|
-
|
|
33
|
+
/** Each tool has `idempotent: false`; set it to `true` on a tool known to be safe to run twice. */
|
|
34
|
+
tools: FxAgentHostTool[];
|
|
34
35
|
instructions: string;
|
|
35
36
|
/** Closes the client once. */
|
|
36
37
|
close(): Promise<void>;
|
package/types/node.d.cts
CHANGED
|
@@ -21,6 +21,7 @@ export {
|
|
|
21
21
|
listModels,
|
|
22
22
|
memory,
|
|
23
23
|
supportsJspi,
|
|
24
|
+
wakeHandler,
|
|
24
25
|
xtermAdapter,
|
|
25
26
|
} from "./libfx.cjs";
|
|
26
27
|
|
|
@@ -29,7 +30,11 @@ export type {
|
|
|
29
30
|
FxAccepted,
|
|
30
31
|
FxAgent,
|
|
31
32
|
FxAgentEvent,
|
|
33
|
+
FxAgentHostTool,
|
|
34
|
+
FxAgentKeyedTool,
|
|
32
35
|
FxAgentOptions,
|
|
36
|
+
FxAgentTool,
|
|
37
|
+
FxAgentTools,
|
|
33
38
|
FxApiKeyCredentials,
|
|
34
39
|
FxBackendAttempt,
|
|
35
40
|
FxBackendChoice,
|
|
@@ -148,4 +153,4 @@ export declare function createFxTerminal(options: FxNodeTerminalOptions): Promis
|
|
|
148
153
|
export declare function getBackendInfo(options?: FxBackendInfoOptions): Promise<FxBackendInfo>;
|
|
149
154
|
|
|
150
155
|
/** The version of the libfx agent API. */
|
|
151
|
-
export declare const libfxApiVersion:
|
|
156
|
+
export declare const libfxApiVersion: 3;
|
package/types/skills-node.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// `libfx/skills/node` (skills-node.js): loads a `SKILL.md` explicitly in
|
|
2
2
|
// Node.js or Bun.
|
|
3
|
-
import type {
|
|
3
|
+
import type { FxAgentTool } from "./libfx.cjs";
|
|
4
4
|
import type { SkillRecord, SkillResource } from "./skills.js";
|
|
5
5
|
|
|
6
6
|
export { createSkillsAdapter } from "./skills.js";
|
|
@@ -11,14 +11,14 @@ export interface LoadSkillFileOptions {
|
|
|
11
11
|
/** Replaces `fs.promises.readFile`. */
|
|
12
12
|
readFile?: (path: string, encoding: "utf8") => string | Promise<string>;
|
|
13
13
|
resources?: readonly SkillResource[];
|
|
14
|
-
tools?: readonly
|
|
14
|
+
tools?: readonly FxAgentTool[];
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/** A skill read from a `SKILL.md`: its frontmatter `name` and `description`, and its body as instructions. */
|
|
18
18
|
export interface LoadedSkill extends SkillRecord {
|
|
19
19
|
description: string;
|
|
20
20
|
resources: readonly SkillResource[];
|
|
21
|
-
tools: readonly
|
|
21
|
+
tools: readonly FxAgentTool[];
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/** Reads one `SKILL.md`. Without a frontmatter `name`, the file name is the skill's name. */
|
package/types/skills.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// `libfx/skills` (skills.js): instructions and tools from already-loaded
|
|
2
2
|
// skill records.
|
|
3
|
-
import type {
|
|
3
|
+
import type { FxAgentTool } from "./libfx.cjs";
|
|
4
4
|
|
|
5
5
|
/** A resource whose text joins its skill's instructions. */
|
|
6
6
|
export interface SkillResource {
|
|
@@ -14,13 +14,14 @@ export interface SkillRecord {
|
|
|
14
14
|
instructions: string;
|
|
15
15
|
description?: string;
|
|
16
16
|
resources?: readonly SkillResource[];
|
|
17
|
-
|
|
17
|
+
/** Each host tool sets `idempotent`, as `createFxAgent()` requires. */
|
|
18
|
+
tools?: readonly FxAgentTool[];
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
/** What `createSkillsAdapter()` returns: spread it into the agent options. */
|
|
21
22
|
export interface SkillsAdapter {
|
|
22
23
|
instructions: string;
|
|
23
|
-
tools:
|
|
24
|
+
tools: FxAgentTool[];
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
/** Turns up to 64 skill records into instructions and tools. */
|