@opencode-ai/util 0.0.0-next-17189 → 0.0.0-next-17194
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/npm-config.js
CHANGED
|
@@ -5,11 +5,12 @@ import Config from "@npmcli/config";
|
|
|
5
5
|
// @ts-expect-error npm does not publish types for this internal config API.
|
|
6
6
|
import { definitions, flatten, nerfDarts, shorthands } from "@npmcli/config/lib/definitions/index.js";
|
|
7
7
|
import { Effect } from "effect";
|
|
8
|
-
const npmPath = fileURLToPath(new URL("..", import.meta.url));
|
|
9
8
|
export const load = (dir) => Effect.tryPromise({
|
|
10
9
|
try: async () => {
|
|
11
10
|
const config = new Config({
|
|
12
|
-
|
|
11
|
+
// Resolved per call: on workerd import.meta.url is undefined and building
|
|
12
|
+
// this URL at module scope fails startup validation; npm config never runs there.
|
|
13
|
+
npmPath: fileURLToPath(new URL("..", import.meta.url)),
|
|
13
14
|
cwd: dir,
|
|
14
15
|
env: { ...process.env },
|
|
15
16
|
argv: [process.execPath, process.execPath, "--prefix", dir],
|
|
@@ -2,7 +2,7 @@ import { Effect, FileSystem, Formatter, Logger } from "effect";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { Global } from "../global.js";
|
|
4
4
|
import { runID } from "./shared.js";
|
|
5
|
-
function formatter(id = runID) {
|
|
5
|
+
function formatter(id = runID()) {
|
|
6
6
|
return Logger.map(Logger.formatStructured, (output) => {
|
|
7
7
|
const messages = Array.isArray(output.message) ? output.message : [output.message];
|
|
8
8
|
return [
|
|
@@ -45,7 +45,7 @@ export function file(local = true, channel = "local") {
|
|
|
45
45
|
return path.join(Global.Path.log, "opencode.log");
|
|
46
46
|
return path.join(Global.Path.log, `opencode-${channel.replace(/[^a-zA-Z0-9._-]/g, "-")}.log`);
|
|
47
47
|
}
|
|
48
|
-
export function fileLogger(target = file(), id = runID) {
|
|
48
|
+
export function fileLogger(target = file(), id = runID()) {
|
|
49
49
|
// Do not set batchWindow to 0; it causes high idle CPU usage.
|
|
50
50
|
return Effect.gen(function* () {
|
|
51
51
|
const fs = yield* FileSystem.FileSystem;
|
|
@@ -34,8 +34,8 @@ export function resource(app = { client: "opencode", version: "unknown", channel
|
|
|
34
34
|
...resourceAttributes(),
|
|
35
35
|
"deployment.environment.name": app.channel,
|
|
36
36
|
"opencode.client": app.client,
|
|
37
|
-
"opencode.run": runID,
|
|
38
|
-
"service.instance.id": runID,
|
|
37
|
+
"opencode.run": runID(),
|
|
38
|
+
"service.instance.id": runID(),
|
|
39
39
|
},
|
|
40
40
|
};
|
|
41
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare function runID(): string;
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// Lazy: workerd forbids generating random values in global scope, so the id
|
|
2
|
+
// materializes on first call (inside a handler) and stays stable afterwards.
|
|
3
|
+
let generated;
|
|
4
|
+
export function runID() {
|
|
5
|
+
generated ??= crypto.randomUUID().slice(0, 8);
|
|
6
|
+
return generated;
|
|
7
|
+
}
|
package/dist/observability.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * as Observability from "./observability.js";
|
|
2
|
-
import
|
|
2
|
+
import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem";
|
|
3
3
|
import { LayerNode } from "./effect/layer-node.js";
|
|
4
4
|
import { Effect, Layer, Logger, References, Schema } from "effect";
|
|
5
5
|
import { FetchHttpClient } from "effect/unstable/http";
|
|
@@ -28,4 +28,10 @@ export function layer(options = {
|
|
|
28
28
|
return Layer.merge(logs, yield* Otlp.tracingLayer(options, app));
|
|
29
29
|
})).pipe(Layer.catchCause(() => local));
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
// Layer.suspend: constructing the loggers eagerly at module scope performs
|
|
32
|
+
// I/O (file logger, run id) that workerd forbids in global scope.
|
|
33
|
+
export const node = LayerNode.make({
|
|
34
|
+
name: "observability",
|
|
35
|
+
layer: Layer.suspend(() => layer()),
|
|
36
|
+
deps: [],
|
|
37
|
+
});
|