@flue/sdk 0.3.5 → 0.3.7
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 +33 -3
- package/dist/{agent-BB4lwAd5.mjs → agent-BTB0809P.mjs} +1 -1
- package/dist/client.d.mts +3 -3
- package/dist/client.mjs +33 -12
- package/dist/cloudflare/index.d.mts +2 -2
- package/dist/cloudflare/index.mjs +5 -3
- package/dist/{command-helpers-DdAfbnom.d.mts → command-helpers-5DpOaRIB.d.mts} +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +199 -92
- package/dist/internal.d.mts +265 -4
- package/dist/internal.mjs +438 -6
- package/dist/{mcp-DOgMtp8y.mjs → mcp-B13ZPduG.mjs} +4 -3
- package/dist/{mcp-BVF-sOBZ.d.mts → mcp-CKMPhMDe.d.mts} +1 -1
- package/dist/node/index.d.mts +2 -2
- package/dist/sandbox.d.mts +2 -1
- package/dist/sandbox.mjs +31 -5
- package/dist/{session-DukL3zwF.mjs → session-CNOAfV45.mjs} +14 -8
- package/dist/{types-T8pE1xIS.d.mts → types-CKcp6T-y.d.mts} +64 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
# Flue
|
|
6
6
|
|
|
7
|
-
Flue is **The
|
|
7
|
+
Flue is **The Agent Harness Framework.** If you know how to use Claude Code (or OpenCode, Codex, Gemini, etc)... then you already know the basics of how to build agents with Flue.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Flue is a TypeScript framework for building the next generation of agents, designed around a built-in **agent harness**. It's like Claude Code, but 100% headless and programmable. There's no baked-in assumption like requiring a human operator to function. No TUI. No GUI. Just TypeScript.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
But using Flue feels like using Claude Code. The agents you build act autonomously to solve problems and complete tasks. They require very little code to run — most of the "logic" lives in Markdown: skills, context, and `AGENTS.md`.
|
|
12
|
+
|
|
13
|
+
Flue isn't another AI SDK. It's a proper runtime-agnostic framework — think Astro or Next.js, but for agents. Write once, build, and deploy your agents anywhere (Node.js, Cloudflare, GitHub Actions, GitLab CI/CD, etc).
|
|
12
14
|
|
|
13
15
|
## Packages
|
|
14
16
|
|
|
@@ -287,6 +289,34 @@ await session.prompt('Review the latest changes.'); // uses reviewer
|
|
|
287
289
|
await session.task('Research related issues.', { role: 'researcher' }); // uses researcher
|
|
288
290
|
```
|
|
289
291
|
|
|
292
|
+
### Provider Settings
|
|
293
|
+
|
|
294
|
+
Use `providers` when model traffic needs provider-specific runtime settings,
|
|
295
|
+
such as an enterprise API gateway, provider-compatible proxy, custom endpoint,
|
|
296
|
+
or gateway-specific credentials. This is common for managed credentials, audit
|
|
297
|
+
logging, traffic routing, or self-hosted OpenAI-compatible providers.
|
|
298
|
+
|
|
299
|
+
Configure these settings in `init()` instead of mutating global model state. They
|
|
300
|
+
are runtime-scoped to that agent and apply to every model it resolves, including
|
|
301
|
+
agent defaults, role-level models, per-call model selections, tasks, and context
|
|
302
|
+
compaction.
|
|
303
|
+
|
|
304
|
+
```ts
|
|
305
|
+
const agent = await init({
|
|
306
|
+
model: 'anthropic/claude-sonnet-4-6',
|
|
307
|
+
providers: {
|
|
308
|
+
anthropic: {
|
|
309
|
+
baseUrl: env.ANTHROPIC_BASE_URL,
|
|
310
|
+
headers: {
|
|
311
|
+
'X-Custom-Auth': env.GATEWAY_KEY,
|
|
312
|
+
},
|
|
313
|
+
// Use this when the proxy expects a synthetic or gateway-specific key.
|
|
314
|
+
apiKey: 'dummy',
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
});
|
|
318
|
+
```
|
|
319
|
+
|
|
290
320
|
### Custom Virtual Sandboxes
|
|
291
321
|
|
|
292
322
|
For most agents, use the built-in virtual sandbox or `sandbox: 'local'`. If you need to customize just-bash directly, pass a Bash factory. The factory must return a fresh Bash-like runtime each time; share the filesystem object in the closure to persist files across sessions and prompts.
|
|
@@ -287,7 +287,7 @@ function createBashTool(env) {
|
|
|
287
287
|
}),
|
|
288
288
|
async execute(_toolCallId, params, signal) {
|
|
289
289
|
throwIfAborted(signal);
|
|
290
|
-
return formatBashResult(await env.exec(params.command), params.command);
|
|
290
|
+
return formatBashResult(await env.exec(params.command, { timeout: params.timeout }), params.command);
|
|
291
291
|
}
|
|
292
292
|
};
|
|
293
293
|
}
|
package/dist/client.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { i as connectMcpServer, n as McpServerOptions, r as McpTransport, t as McpServerConnection } from "./mcp-
|
|
1
|
+
import { A as ShellResult, D as SessionOptions, E as SessionEnv, F as ToolParameters, M as SkillOptions, N as TaskOptions, O as SessionStore, P as ToolDef, S as ProvidersConfig, T as SessionData, _ as FlueSessions, a as BashLike, b as PromptResponse, d as FileStat, f as FlueAgent, g as FlueSession, h as FlueEventCallback, i as BashFactory, k as ShellOptions, l as Command, m as FlueEvent, p as FlueContext, r as AgentInit, t as AgentConfig, v as ModelConfig, w as SandboxFactory, x as ProviderSettings, y as PromptOptions } from "./types-CKcp6T-y.mjs";
|
|
2
|
+
import { i as connectMcpServer, n as McpServerOptions, r as McpTransport, t as McpServerConnection } from "./mcp-CKMPhMDe.mjs";
|
|
3
3
|
import { Type } from "@mariozechner/pi-ai";
|
|
4
4
|
|
|
5
5
|
//#region src/client.d.ts
|
|
@@ -23,4 +23,4 @@ interface FlueContextInternal extends FlueContext {
|
|
|
23
23
|
}
|
|
24
24
|
declare function createFlueContext(config: FlueContextConfig): FlueContextInternal;
|
|
25
25
|
//#endregion
|
|
26
|
-
export { type AgentInit, type BashFactory, type BashLike, type Command, type FileStat, type FlueAgent, type FlueContext, FlueContextConfig, FlueContextInternal, type FlueEvent, type FlueEventCallback, type FlueSession, type FlueSessions, type McpServerConnection, type McpServerOptions, type McpTransport, type PromptOptions, type PromptResponse, type SandboxFactory, type SessionData, type SessionEnv, type SessionOptions, type SessionStore, type ShellOptions, type ShellResult, type SkillOptions, type TaskOptions, type ToolDef, type ToolParameters, Type, connectMcpServer, createFlueContext };
|
|
26
|
+
export { type AgentInit, type BashFactory, type BashLike, type Command, type FileStat, type FlueAgent, type FlueContext, FlueContextConfig, FlueContextInternal, type FlueEvent, type FlueEventCallback, type FlueSession, type FlueSessions, type McpServerConnection, type McpServerOptions, type McpTransport, type ModelConfig, type PromptOptions, type PromptResponse, type ProviderSettings, type ProvidersConfig, type SandboxFactory, type SessionData, type SessionEnv, type SessionOptions, type SessionStore, type ShellOptions, type ShellResult, type SkillOptions, type TaskOptions, type ToolDef, type ToolParameters, Type, connectMcpServer, createFlueContext };
|
package/dist/client.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { r as discoverSessionContext } from "./agent-
|
|
2
|
-
import { a as assertRoleExists } from "./session-
|
|
1
|
+
import { r as discoverSessionContext } from "./agent-BTB0809P.mjs";
|
|
2
|
+
import { a as assertRoleExists } from "./session-CNOAfV45.mjs";
|
|
3
3
|
import { bashFactoryToSessionEnv, createCwdSessionEnv } from "./sandbox.mjs";
|
|
4
|
-
import { n as AgentClient, t as connectMcpServer } from "./mcp-
|
|
4
|
+
import { n as AgentClient, t as connectMcpServer } from "./mcp-B13ZPduG.mjs";
|
|
5
5
|
import { Type } from "@mariozechner/pi-ai";
|
|
6
6
|
|
|
7
7
|
//#region src/client.ts
|
|
@@ -19,24 +19,28 @@ function createFlueContext(config) {
|
|
|
19
19
|
return config.env;
|
|
20
20
|
},
|
|
21
21
|
async init(options) {
|
|
22
|
-
|
|
22
|
+
if (!options || !("model" in options)) throw new Error("[flue] init() requires a model. Pass { model: \"provider/model-id\" } or { model: false }.");
|
|
23
|
+
if (options.model !== false && typeof options.model !== "string") throw new Error("[flue] init({ model }) must be a model string or false.");
|
|
24
|
+
const id = options.id ?? config.id;
|
|
23
25
|
if (initializedAgentIds.has(id)) throw new Error(`[flue] init() has already been called for agent "${id}" in this request.`);
|
|
24
26
|
initializedAgentIds.add(id);
|
|
25
27
|
try {
|
|
26
|
-
assertRoleExists(config.agentConfig.roles, options
|
|
27
|
-
const sandbox = options
|
|
28
|
-
const baseEnv = await resolveSessionEnv(id, sandbox, config, options
|
|
29
|
-
const env = options
|
|
30
|
-
const store = options
|
|
28
|
+
assertRoleExists(config.agentConfig.roles, options.role);
|
|
29
|
+
const sandbox = options.sandbox;
|
|
30
|
+
const baseEnv = await resolveSessionEnv(id, sandbox, config, options.cwd);
|
|
31
|
+
const env = options.cwd ? createCwdSessionEnv(baseEnv, options.cwd) : baseEnv;
|
|
32
|
+
const store = options.persist ?? config.defaultStore;
|
|
31
33
|
const localContext = await discoverSessionContext(env);
|
|
32
|
-
const
|
|
34
|
+
const providers = mergeProvidersConfig(config.agentConfig.providers, options.providers);
|
|
35
|
+
const agentModel = config.agentConfig.resolveModel(options.model, providers);
|
|
33
36
|
return new AgentClient(id, {
|
|
34
37
|
...config.agentConfig,
|
|
35
38
|
systemPrompt: localContext.systemPrompt,
|
|
36
39
|
skills: localContext.skills,
|
|
37
40
|
model: agentModel,
|
|
38
|
-
role: options
|
|
39
|
-
|
|
41
|
+
role: options.role ?? config.agentConfig.role,
|
|
42
|
+
providers
|
|
43
|
+
}, env, store, currentEventCallback, options.commands, options.tools);
|
|
40
44
|
} catch (error) {
|
|
41
45
|
initializedAgentIds.delete(id);
|
|
42
46
|
throw error;
|
|
@@ -73,6 +77,23 @@ async function resolveSessionEnv(id, sandbox, config, cwd) {
|
|
|
73
77
|
});
|
|
74
78
|
throw new Error("[flue] Invalid sandbox option passed to init().");
|
|
75
79
|
}
|
|
80
|
+
function mergeProvidersConfig(base, settings) {
|
|
81
|
+
if (!base) return settings;
|
|
82
|
+
if (!settings) return base;
|
|
83
|
+
const merged = { ...base };
|
|
84
|
+
for (const [provider, config] of Object.entries(settings)) {
|
|
85
|
+
const previous = merged[provider];
|
|
86
|
+
merged[provider] = {
|
|
87
|
+
...previous,
|
|
88
|
+
...config,
|
|
89
|
+
headers: previous?.headers || config.headers ? {
|
|
90
|
+
...previous?.headers ?? {},
|
|
91
|
+
...config.headers ?? {}
|
|
92
|
+
} : void 0
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return merged;
|
|
96
|
+
}
|
|
76
97
|
|
|
77
98
|
//#endregion
|
|
78
99
|
export { Type, connectMcpServer, createFlueContext };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as CommandExecutor } from "../command-helpers-
|
|
1
|
+
import { E as SessionEnv, O as SessionStore, l as Command } from "../types-CKcp6T-y.mjs";
|
|
2
|
+
import { t as CommandExecutor } from "../command-helpers-5DpOaRIB.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/cloudflare/virtual-sandbox.d.ts
|
|
5
5
|
interface VirtualSandboxOptions {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../agent-
|
|
2
|
-
import "../session-
|
|
1
|
+
import "../agent-BTB0809P.mjs";
|
|
2
|
+
import "../session-CNOAfV45.mjs";
|
|
3
3
|
import { createSandboxSessionEnv } from "../sandbox.mjs";
|
|
4
4
|
import { t as normalizeExecutor } from "../command-helpers-hTZKWK13.mjs";
|
|
5
5
|
import { Workspace, WorkspaceFileSystem } from "@cloudflare/shell";
|
|
@@ -195,9 +195,11 @@ async function cfSandboxToSessionEnv(sandbox, cwd = "/workspace") {
|
|
|
195
195
|
} else await sandbox.deleteFile(path);
|
|
196
196
|
},
|
|
197
197
|
async exec(command, execOpts) {
|
|
198
|
+
const timeoutMs = typeof execOpts?.timeout === "number" ? execOpts.timeout * 1e3 : void 0;
|
|
198
199
|
const result = await sandbox.exec(command, {
|
|
199
200
|
cwd: execOpts?.cwd,
|
|
200
|
-
env: execOpts?.env
|
|
201
|
+
env: execOpts?.env,
|
|
202
|
+
timeout: timeoutMs
|
|
201
203
|
});
|
|
202
204
|
return {
|
|
203
205
|
stdout: result.stdout ?? "",
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as ShellResult, C as Role, D as SessionOptions, E as SessionEnv, F as ToolParameters, M as SkillOptions, N as TaskOptions, O as SessionStore, P as ToolDef, T as SessionData, _ as FlueSessions, a as BashLike, b as PromptResponse, c as BuildPlugin, d as FileStat, f as FlueAgent, g as FlueSession, h as FlueEventCallback, i as BashFactory, j as Skill, k as ShellOptions, l as Command, m as FlueEvent, n as AgentInfo, o as BuildContext, p as FlueContext, r as AgentInit, s as BuildOptions, t as AgentConfig, u as CommandDef, v as ModelConfig, w as SandboxFactory, y as PromptOptions } from "./types-CKcp6T-y.mjs";
|
|
2
2
|
import { AgentTool, AgentToolResult } from "@mariozechner/pi-agent-core";
|
|
3
3
|
|
|
4
4
|
//#region src/build.d.ts
|
|
@@ -113,4 +113,4 @@ interface CreateToolsOptions {
|
|
|
113
113
|
}
|
|
114
114
|
declare function createTools(env: SessionEnv, options?: CreateToolsOptions): AgentTool<any>[];
|
|
115
115
|
//#endregion
|
|
116
|
-
export { type AgentConfig, type AgentInfo, type AgentInit, BUILTIN_TOOL_NAMES, type BashFactory, type BashLike, type BuildContext, type BuildOptions, type BuildPlugin, type Command, type CommandDef, DEFAULT_DEV_PORT, type DevOptions, type FileStat, type FlueAgent, type FlueContext, type FlueEvent, type FlueEventCallback, type FlueSession, type FlueSessions, type PromptOptions, type PromptResponse, type Role, type SandboxFactory, type SessionData, type SessionEnv, type SessionOptions, type SessionStore, type ShellOptions, type ShellResult, type Skill, type SkillOptions, type TaskOptions, type ToolDef, type ToolParameters, build, createTools, dev, parseEnvFiles, resolveEnvFiles, resolveWorkspaceFromCwd };
|
|
116
|
+
export { type AgentConfig, type AgentInfo, type AgentInit, BUILTIN_TOOL_NAMES, type BashFactory, type BashLike, type BuildContext, type BuildOptions, type BuildPlugin, type Command, type CommandDef, DEFAULT_DEV_PORT, type DevOptions, type FileStat, type FlueAgent, type FlueContext, type FlueEvent, type FlueEventCallback, type FlueSession, type FlueSessions, type ModelConfig, type PromptOptions, type PromptResponse, type Role, type SandboxFactory, type SessionData, type SessionEnv, type SessionOptions, type SessionStore, type ShellOptions, type ShellResult, type Skill, type SkillOptions, type TaskOptions, type ToolDef, type ToolParameters, build, createTools, dev, parseEnvFiles, resolveEnvFiles, resolveWorkspaceFromCwd };
|