@opencode-ai/client 0.0.0-next-14971 → 0.0.0-next-14974

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.
@@ -63,7 +63,8 @@ export const Info = Schema.Struct({
63
63
  password: Schema.optional(Schema.String),
64
64
  });
65
65
  const decode = Schema.decodeUnknownEffect(Schema.fromJsonString(Info));
66
- const decodeHealth = Schema.decodeUnknownEffect(Schema.Struct({ healthy: Schema.Literal(true), version: Schema.String, pid: Schema.Int }));
66
+ const decodeHealth = Schema.decodeUnknownOption(Schema.Struct({ healthy: Schema.Literal(true), version: Schema.String, pid: Schema.Int }));
67
+ const decodeLegacyHealth = Schema.decodeUnknownOption(Schema.Struct({ healthy: Schema.Literal(true) }));
67
68
  // A missing or corrupt file means no valid info; callers treat both
68
69
  // the same (the registering server self-evicts, clients rediscover).
69
70
  const read = Effect.fnUntraced(function* (file) {
@@ -73,7 +74,7 @@ const read = Effect.fnUntraced(function* (file) {
73
74
  return undefined;
74
75
  return yield* decode(text.value).pipe(Effect.option, Effect.map(Option.getOrUndefined));
75
76
  });
76
- const probe = Effect.fnUntraced(function* (info, version) {
77
+ const probe = Effect.fnUntraced(function* (info, version, allowLegacy = false) {
77
78
  const headers = info.password === undefined ? undefined : auth(info.password);
78
79
  const response = yield* Effect.tryPromise(() => fetch(new URL("/api/health", info.url), {
79
80
  headers,
@@ -81,12 +82,20 @@ const probe = Effect.fnUntraced(function* (info, version) {
81
82
  })).pipe(Effect.option, Effect.map(Option.getOrUndefined));
82
83
  if (response === undefined || !response.ok)
83
84
  return undefined;
84
- const health = yield* Effect.tryPromise(() => response.json()).pipe(Effect.flatMap(decodeHealth), Effect.option, Effect.map(Option.getOrUndefined));
85
- if (health?.pid !== info.pid)
86
- return undefined;
87
- if (info.version !== undefined && health.version !== info.version)
88
- return undefined;
89
- if (version !== undefined && health.version !== version)
85
+ const body = yield* Effect.tryPromise(() => response.json()).pipe(Effect.option, Effect.map(Option.getOrUndefined));
86
+ const health = decodeHealth(body);
87
+ if (Option.isSome(health)) {
88
+ if (health.value.pid !== info.pid)
89
+ return undefined;
90
+ if (info.version !== undefined && health.value.version !== info.version)
91
+ return undefined;
92
+ if (version !== undefined && health.value.version !== version)
93
+ return undefined;
94
+ return { info, transport: { url: info.url, headers } };
95
+ }
96
+ if (!allowLegacy ||
97
+ Option.isNone(decodeLegacyHealth(body)) ||
98
+ (typeof body === "object" && body !== null && ("version" in body || "pid" in body)))
90
99
  return undefined;
91
100
  return { info, transport: { url: info.url, headers } };
92
101
  });
@@ -96,7 +105,7 @@ const find = Effect.fnUntraced(function* (options) {
96
105
  const info = yield* read(options.file);
97
106
  if (info === undefined)
98
107
  return undefined;
99
- return yield* probe(info);
108
+ return yield* probe(info, undefined, true);
100
109
  });
101
110
  // 50ms cadence bounded at ~5s, shared by stop escalation and start readiness.
102
111
  const poll = Schedule.spaced("50 millis").pipe(Schedule.both(Schedule.recurs(100)));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@opencode-ai/client",
4
- "version": "0.0.0-next-14971",
4
+ "version": "0.0.0-next-14974",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -41,8 +41,8 @@
41
41
  "typecheck": "tsgo --noEmit"
42
42
  },
43
43
  "dependencies": {
44
- "@opencode-ai/schema": "0.0.0-next-14971",
45
- "@opencode-ai/protocol": "0.0.0-next-14971"
44
+ "@opencode-ai/schema": "0.0.0-next-14974",
45
+ "@opencode-ai/protocol": "0.0.0-next-14974"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "effect": "4.0.0-beta.83"
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "devDependencies": {
56
56
  "@effect/platform-node": "4.0.0-beta.83",
57
- "@opencode-ai/httpapi-codegen": "0.0.0-next-14971",
57
+ "@opencode-ai/httpapi-codegen": "0.0.0-next-14974",
58
58
  "@tsconfig/bun": "1.0.9",
59
59
  "@types/bun": "1.3.13",
60
60
  "@typescript/native-preview": "7.0.0-dev.20251207.1",