@opencode/util 0.0.0-dev-572 → 0.0.0-dev-575
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.
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import { FileSystem, Path } from "effect";
|
|
1
|
+
import { FileSystem, Layer, Path } from "effect";
|
|
2
2
|
import { HttpClient } from "effect/http";
|
|
3
3
|
export declare const filesystem: import("./layer-node.js").Provider<FileSystem.FileSystem, never, import("./layer-node.js").Tag<"global">>;
|
|
4
4
|
export declare const path: import("./layer-node.js").Provider<Path.Path, never, import("./layer-node.js").Tag<"global">>;
|
|
5
|
+
export type Fetch = (input: Request | string | URL, init?: RequestInit) => Promise<Response>;
|
|
6
|
+
/**
|
|
7
|
+
* The fetch behind `httpClient`, AI SDK providers and remote MCP servers: `fetch` when given, so an embedder can route requests through
|
|
8
|
+
* e.g. a Service Binding, otherwise the `FetchHttpClient.Fetch` in scope when the graph is built.
|
|
9
|
+
*/
|
|
10
|
+
export declare const fetchLayer: (fetch?: Fetch) => Layer.Layer<never, never, never>;
|
|
11
|
+
export declare const httpFetch: import("./layer-node.js").Provider<never, never, import("./layer-node.js").Tag<"global">>;
|
|
5
12
|
export declare const httpClient: import("./layer-node.js").Provider<HttpClient.HttpClient, never, import("./layer-node.js").Tag<"global">>;
|
|
6
13
|
export * as LayerNodePlatform from "./app-node-platform.js";
|
|
@@ -2,10 +2,28 @@
|
|
|
2
2
|
// ioredis, and node:sqlite, which runtimes such as workerd cannot load.
|
|
3
3
|
import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem";
|
|
4
4
|
import * as NodePath from "@effect/platform-node/NodePath";
|
|
5
|
-
import { FileSystem, Path } from "effect";
|
|
5
|
+
import { Effect, FileSystem, Layer, Path } from "effect";
|
|
6
6
|
import { FetchHttpClient, HttpClient } from "effect/http";
|
|
7
7
|
import { makeGlobalNode } from "./app-node.js";
|
|
8
8
|
export const filesystem = makeGlobalNode({ service: FileSystem.FileSystem, layer: NodeFileSystem.layer, deps: [] });
|
|
9
9
|
export const path = makeGlobalNode({ service: Path.Path, layer: NodePath.layer, deps: [] });
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The fetch behind `httpClient`, AI SDK providers and remote MCP servers: `fetch` when given, so an embedder can route requests through
|
|
12
|
+
* e.g. a Service Binding, otherwise the `FetchHttpClient.Fetch` in scope when the graph is built.
|
|
13
|
+
*/
|
|
14
|
+
export const fetchLayer = (fetch) => Layer.effect(FetchHttpClient.Fetch, Effect.gen(function* () {
|
|
15
|
+
// Bun's `typeof fetch` adds `preconnect`, which nothing here calls.
|
|
16
|
+
return fetch ? fetch : yield* FetchHttpClient.Fetch;
|
|
17
|
+
}));
|
|
18
|
+
export const httpFetch = makeGlobalNode({ service: FetchHttpClient.Fetch, layer: fetchLayer(), deps: [] });
|
|
19
|
+
// Provided per request, so a caller's context can't swap `httpFetch` for another fetch.
|
|
20
|
+
export const httpClient = makeGlobalNode({
|
|
21
|
+
service: HttpClient.HttpClient,
|
|
22
|
+
layer: Layer.effect(HttpClient.HttpClient, Effect.gen(function* () {
|
|
23
|
+
const fetch = yield* FetchHttpClient.Fetch;
|
|
24
|
+
const client = yield* HttpClient.HttpClient.pipe(Effect.provide(FetchHttpClient.layer));
|
|
25
|
+
return HttpClient.transformResponse(client, Effect.provideService(FetchHttpClient.Fetch, fetch));
|
|
26
|
+
})),
|
|
27
|
+
deps: [httpFetch],
|
|
28
|
+
});
|
|
11
29
|
export * as LayerNodePlatform from "./app-node-platform.js";
|