@flue/client 0.0.24 → 0.0.26

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 CHANGED
@@ -14,14 +14,15 @@ pnpm install @flue/client
14
14
 
15
15
  ```ts
16
16
  // .flue/workflows/issue-triage.ts
17
- import type { Flue } from '@flue/client';
17
+ import type { FlueClient } from '@flue/client';
18
18
 
19
- export default async function triage(flue: Flue) {
20
- const { issueNumber } = flue.args as { issueNumber: number };
21
- const issue = await flue.shell(`gh issue view ${issueNumber} --json title,body`);
22
- const result = await flue.skill('triage/diagnose.md', { args: { issueNumber } });
19
+ export default async function triage(flue: FlueClient, args: { issueNumber: number }) {
20
+ const issue = await flue.shell(`gh issue view ${args.issueNumber} --json title,body`);
21
+ const result = await flue.skill('triage/diagnose.md', {
22
+ args: { issueNumber: args.issueNumber },
23
+ });
23
24
  const comment = await flue.prompt(`Summarize the triage for: ${issue.stdout}`);
24
- await flue.shell(`gh issue comment ${issueNumber} --body-file -`, { stdin: comment });
25
+ await flue.shell(`gh issue comment ${args.issueNumber} --body-file -`, { stdin: comment });
25
26
  }
26
27
  ```
27
28
 
@@ -29,11 +30,10 @@ export default async function triage(flue: Flue) {
29
30
 
30
31
  ### `flue.shell(command, options?)`
31
32
 
32
- Run a shell command. Returns `{ stdout, stderr, exitCode }`.
33
+ Run a shell command in the target environment. Returns `{ stdout, stderr, exitCode }`.
33
34
 
34
35
  ```ts
35
36
  const result = await flue.shell('pnpm test');
36
- const result = await flue.shell('gh issue view 123', { env: { GH_TOKEN: '...' } });
37
37
  const result = await flue.shell('cat -', { stdin: 'hello' });
38
38
  ```
39
39
 
@@ -78,14 +78,13 @@ Flue ships with built-in presets for popular services. Every proxy supports an a
78
78
  ```ts
79
79
  import { anthropic, github } from '@flue/client/proxies';
80
80
 
81
- export const proxies = [
82
- anthropic(),
83
- github({
84
- token: process.env.GH_TOKEN!,
81
+ export const proxies = {
82
+ anthropic: anthropic(),
83
+ github: github({
85
84
  policy: {
86
85
  base: 'allow-read',
87
86
  allow: [{ method: 'POST', path: '/repos/withastro/astro/issues/*/comments', limit: 1 }],
88
87
  },
89
88
  }),
90
- ];
89
+ };
91
90
  ```
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() {}
@@ -79,7 +79,10 @@ function github(opts) {
79
79
  },
80
80
  policy: resolvedPolicy,
81
81
  socket: true,
82
- env: { GH_TOKEN: "proxy-placeholder" },
82
+ env: {
83
+ GH_TOKEN: "proxy-placeholder",
84
+ GH_HOST: "github.com"
85
+ },
83
86
  setup: ["gh config set http_unix_socket {{socketPath}} 2>/dev/null || true"],
84
87
  instructions: ["The `gh` CLI is pre-configured with authentication.", "For GitHub API calls, prefer `gh api` over raw `curl`."].join(" "),
85
88
  denyResponse
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flue/client",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {