@flue/client 0.0.24 → 0.0.25

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/dist/index.d.mts CHANGED
@@ -86,22 +86,10 @@ interface FlueClientOptions {
86
86
  providerID: string;
87
87
  modelID: string;
88
88
  };
89
- /**
90
- * Custom fetch implementation for reaching the OpenCode server.
91
- * Use this when the OpenCode server is not reachable via global fetch
92
- * (e.g. from a Cloudflare Worker, route through sandbox.containerFetch).
93
- *
94
- * When omitted, the SDK's default fetch (globalThis.fetch) is used.
95
- */
96
- fetch?: (request: Request) => Promise<Response>;
97
- /**
98
- * Custom shell implementation for executing commands.
99
- * Use this when child_process is not available (e.g. Cloudflare Workers)
100
- * and commands should be routed through sandbox.exec() instead.
101
- *
102
- * When omitted, commands run via Node.js child_process.exec.
103
- */
104
- shell?: (command: string, options?: ShellOptions) => Promise<ShellResult>;
89
+ /** Fetch implementation for reaching the OpenCode server. */
90
+ fetch: (request: Request) => Promise<Response>;
91
+ /** Shell implementation for executing commands in the target environment. */
92
+ shell: (command: string, options?: ShellOptions) => Promise<ShellResult>;
105
93
  }
106
94
  interface SkillOptions<S extends v.GenericSchema | undefined = undefined> {
107
95
  /** Key-value args serialized into the prompt. */
@@ -145,7 +133,7 @@ declare class FlueClient {
145
133
  private readonly proxyInstructions;
146
134
  private readonly model?;
147
135
  private readonly client;
148
- private readonly shellFn?;
136
+ private readonly shellFn;
149
137
  constructor(options: FlueClientOptions);
150
138
  /** Run a named skill with a result schema. */
151
139
  skill<S extends v.GenericSchema>(name: string, options: SkillOptions<S> & {
package/dist/index.mjs CHANGED
@@ -1,6 +1,5 @@
1
1
  import { createOpencodeClient } from "@opencode-ai/sdk";
2
2
  import { toJsonSchema } from "@valibot/to-json-schema";
3
- import { exec } from "node:child_process";
4
3
  import * as v from "valibot";
5
4
 
6
5
  //#region src/errors.ts
@@ -225,43 +224,6 @@ function buildSkillPrompt(name, args, schema, proxyInstructions) {
225
224
  return parts.join("\n");
226
225
  }
227
226
 
228
- //#endregion
229
- //#region src/shell.ts
230
- async function runShell(command, options) {
231
- console.log("[flue] shell: running", {
232
- command,
233
- cwd: options?.cwd,
234
- env: options?.env ? Object.keys(options.env) : void 0,
235
- stdin: options?.stdin ? `${options.stdin.length} chars` : void 0,
236
- timeout: options?.timeout
237
- });
238
- return new Promise((resolve) => {
239
- const child = exec(command, {
240
- cwd: options?.cwd,
241
- env: options?.env ?? process.env,
242
- timeout: options?.timeout
243
- }, (error, stdout, stderr) => {
244
- const rawCode = error && typeof error.code === "number" ? error.code : 0;
245
- const result = {
246
- stdout: stdout ?? "",
247
- stderr: stderr ?? "",
248
- exitCode: error ? rawCode || 1 : 0
249
- };
250
- console.log("[flue] shell: completed", {
251
- command,
252
- exitCode: result.exitCode,
253
- stdout: result.stdout.length > 200 ? `${result.stdout.slice(0, 200)}... (${result.stdout.length} chars)` : result.stdout,
254
- stderr: result.stderr.length > 200 ? `${result.stderr.slice(0, 200)}... (${result.stderr.length} chars)` : result.stderr
255
- });
256
- resolve(result);
257
- });
258
- if (options?.stdin) {
259
- child.stdin?.write(options.stdin);
260
- child.stdin?.end();
261
- }
262
- });
263
- }
264
-
265
227
  //#endregion
266
228
  //#region src/result.ts
267
229
  /**
@@ -492,7 +454,7 @@ var FlueClient = class {
492
454
  this.client = createOpencodeClient({
493
455
  baseUrl: options.opencodeUrl ?? "http://localhost:48765",
494
456
  directory: this.workdir,
495
- ...options.fetch ? { fetch: options.fetch } : {}
457
+ fetch: options.fetch
496
458
  });
497
459
  }
498
460
  async skill(name, options) {
@@ -520,12 +482,10 @@ var FlueClient = class {
520
482
  }
521
483
  /** Execute a shell command with scoped environment variables. */
522
484
  async shell(command, options) {
523
- const mergedOptions = {
485
+ return this.shellFn(command, {
524
486
  ...options,
525
487
  cwd: options?.cwd ?? this.workdir
526
- };
527
- if (this.shellFn) return this.shellFn(command, mergedOptions);
528
- return runShell(command, mergedOptions);
488
+ });
529
489
  }
530
490
  /** Close the OpenCode client connection. */
531
491
  async close() {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flue/client",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {