@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.
@@ -67,6 +67,7 @@ interface SessionEnv {
67
67
  exec(command: string, options?: {
68
68
  cwd?: string;
69
69
  env?: Record<string, string>;
70
+ timeout?: number;
70
71
  }): Promise<ShellResult>;
71
72
  /** Create an operation-scoped environment, usually backed by a fresh Bash runtime. */
72
73
  scope?(options?: {
@@ -101,6 +102,25 @@ interface CompactionConfig {
101
102
  /** Recent tokens to preserve (not summarized). Default: 20000 */
102
103
  keepRecentTokens?: number;
103
104
  }
105
+ interface ProviderSettings {
106
+ /**
107
+ * Provider endpoint used by built-in models. Useful for API gateways,
108
+ * LiteLLM-style proxies, or enterprise-managed provider endpoints.
109
+ */
110
+ baseUrl?: string;
111
+ /**
112
+ * Headers merged into the resolved model's provider-level headers. Values
113
+ * here override headers already defined by the built-in model.
114
+ */
115
+ headers?: Record<string, string>;
116
+ /**
117
+ * API key returned to the underlying agent runtime for this provider.
118
+ * Useful when the gateway requires a dummy key or when credentials should
119
+ * come from the agent's runtime env instead of process-global env vars.
120
+ */
121
+ apiKey?: string;
122
+ }
123
+ type ProvidersConfig = Record<string, ProviderSettings>;
104
124
  interface AgentConfig {
105
125
  /** Discovered at runtime from AGENTS.md + .agents/skills/ in the session's cwd. */
106
126
  systemPrompt: string;
@@ -108,27 +128,34 @@ interface AgentConfig {
108
128
  skills: Record<string, Skill>;
109
129
  roles: Record<string, Role>;
110
130
  /**
111
- * Agent-wide default model. Undefined by default — the user must set it via
112
- * `init({ model: "provider/model-id" })` or pass `{ model }` at each prompt/
113
- * skill/task call site. Calls with no model resolved throw clearly at runtime.
131
+ * Agent-wide default model. Undefined when the user explicitly passes
132
+ * `init({ model: false })`, so each model-using call must resolve one from a
133
+ * role or call-site override.
114
134
  */
115
135
  model: Model<any> | undefined;
116
136
  /** Agent-wide default role. Per-session and per-call roles override this. */
117
137
  role?: string;
118
- /** Resolve a "provider/modelId" string to a Model instance. Throws on invalid input. */
119
- resolveModel?: (modelString: string) => Model<any>;
138
+ /** Provider runtime settings applied when resolving models. */
139
+ providers?: ProvidersConfig;
140
+ /** Resolve model config to a Model instance. Throws on invalid model strings. */
141
+ resolveModel: (model: ModelConfig | undefined, providers?: ProvidersConfig) => Model<any> | undefined;
120
142
  compaction?: CompactionConfig;
121
143
  }
122
- /** Request context passed to agent handler functions. */
123
- interface FlueContext {
144
+ type ModelConfig = string | false;
145
+ /**
146
+ * Request context passed to agent handler functions. Pass type parameters
147
+ * to type `payload` and `env` (e.g. the `Env` interface generated by
148
+ * `wrangler types`). Compile-time only — no runtime validation of `payload`.
149
+ */
150
+ interface FlueContext<TPayload = any, TEnv = Record<string, any>> {
124
151
  readonly id: string;
125
- readonly payload: any;
152
+ readonly payload: TPayload;
126
153
  /** Platform env bindings (process.env on Node, Worker env on Cloudflare). */
127
- readonly env: Record<string, any>;
154
+ readonly env: TEnv;
128
155
  /** Initialize an agent runtime with sandbox + persistence. */
129
- init(options?: AgentInit): Promise<FlueAgent>;
156
+ init(options: AgentInit): Promise<FlueAgent>;
130
157
  }
131
- /** All fields are optional omitting gives platform defaults (empty sandbox, platform store, build-time model). */
158
+ /** Agent runtime options. A default model is required unless explicitly disabled with `model: false`. */
132
159
  interface AgentInit {
133
160
  /** Agent/sandbox scope id. Defaults to the route/context id. */
134
161
  id?: string;
@@ -144,16 +171,37 @@ interface AgentInit {
144
171
  /** Defaults to platform store (in-memory on Node, DO SQLite on Cloudflare). */
145
172
  persist?: SessionStore;
146
173
  /**
147
- * Override the default model for this agent. Applies to all prompt() and skill()
148
- * calls unless overridden at the call site.
174
+ * Default model for this agent. Applies to all prompt(), skill(), and task()
175
+ * calls unless overridden by a role or at the call site. Pass `false` to require every
176
+ * model-using call to resolve a model from a role or call-site override.
149
177
  *
150
178
  * Format: `'provider/modelId'` (e.g. `'anthropic/claude-opus-4-20250514'`).
151
179
  *
152
- * Precedence (highest wins): per-call `model` > role `model` > agent `model` > build-time default.
180
+ * Precedence (highest wins): per-call `model` > role `model` > agent `model`.
153
181
  */
154
- model?: string;
182
+ model: ModelConfig;
155
183
  /** Agent-wide default role. Overridden by session-level or per-call roles. */
156
184
  role?: string;
185
+ /**
186
+ * Provider runtime settings for every model used by this agent, including
187
+ * role-level and per-call model selections.
188
+ *
189
+ * Example:
190
+ *
191
+ * ```ts
192
+ * await init({
193
+ * model: 'anthropic/claude-sonnet-4-6',
194
+ * providers: {
195
+ * anthropic: {
196
+ * baseUrl: env.ANTHROPIC_BASE_URL,
197
+ * headers: { 'X-Custom-Auth': env.GATEWAY_KEY },
198
+ * apiKey: 'dummy',
199
+ * },
200
+ * },
201
+ * });
202
+ * ```
203
+ */
204
+ providers?: ProvidersConfig;
157
205
  /**
158
206
  * Agent-wide tools. Every prompt(), skill(), and task() call can use these.
159
207
  * Per-call tools are added on top and must not reuse the same names.
@@ -458,4 +506,4 @@ interface BuildOptions {
458
506
  plugin?: BuildPlugin;
459
507
  }
460
508
  //#endregion
461
- export { TaskOptions as A, SessionEnv as C, ShellResult as D, ShellOptions as E, ToolParameters as M, Skill as O, SessionData as S, SessionStore as T, FlueSessions as _, BashLike as a, Role as b, BuildPlugin as c, FileStat as d, FlueAgent as f, FlueSession as g, FlueEventCallback as h, BashFactory as i, ToolDef as j, SkillOptions as k, Command as l, FlueEvent as m, AgentInfo as n, BuildContext as o, FlueContext as p, AgentInit as r, BuildOptions as s, AgentConfig as t, CommandDef as u, PromptOptions as v, SessionOptions as w, SandboxFactory as x, PromptResponse as y };
509
+ export { ShellResult as A, Role as C, SessionOptions as D, SessionEnv as E, ToolParameters as F, SkillOptions as M, TaskOptions as N, SessionStore as O, ToolDef as P, ProvidersConfig as S, SessionData as T, FlueSessions as _, BashLike as a, PromptResponse as b, BuildPlugin as c, FileStat as d, FlueAgent as f, FlueSession as g, FlueEventCallback as h, BashFactory as i, Skill as j, ShellOptions as k, Command as l, FlueEvent as m, AgentInfo as n, BuildContext as o, FlueContext as p, AgentInit as r, BuildOptions as s, AgentConfig as t, CommandDef as u, ModelConfig as v, SandboxFactory as w, ProviderSettings as x, PromptOptions as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flue/sdk",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {