@opencode/client 2.0.21 → 2.0.23

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.
Files changed (59) hide show
  1. package/dist/chunks/{contract-fnmdfwt6.js → service-version-02j88w0z.js} +14 -21
  2. package/dist/chunks/{contract-1tbj6z39.js → service-version-1y4a697q.js} +1 -1
  3. package/dist/chunks/{contract-tqcb80dw.js → service-version-21favj1f.js} +5 -5
  4. package/dist/chunks/{contract-txckps9j.js → service-version-6f43cgzz.js} +1 -0
  5. package/dist/chunks/{contract-x6wet7em.js → service-version-7yt87z36.js} +6 -3
  6. package/dist/chunks/{contract-h11j9btw.js → service-version-e5ea35j7.js} +1 -1
  7. package/dist/chunks/{contract-frbwqjmf.js → service-version-frbwqjmf.js} +1 -1
  8. package/dist/chunks/{contract-3heptsgt.js → service-version-gah0fg5v.js} +4 -4
  9. package/dist/chunks/{contract-c3yh8bjt.js → service-version-nyqggzs9.js} +62 -47
  10. package/dist/chunks/{contract-t1xa31vm.js → service-version-t1xa31vm.js} +1 -1
  11. package/dist/chunks/{contract-4tveyqeh.js → service-version-vt9jbch8.js} +4 -2
  12. package/dist/chunks/{contract-z6qdwcsf.js → service-version-z6qdwcsf.js} +2 -2
  13. package/dist/contract.js +1 -1
  14. package/dist/effect/api/api.d.ts +13 -0
  15. package/dist/effect/client.d.ts +94 -93
  16. package/dist/effect/client.js +8 -8
  17. package/dist/effect/generated/client-error.js +1 -1
  18. package/dist/effect/generated/client.d.ts +94 -93
  19. package/dist/effect/generated/client.js +3 -3
  20. package/dist/effect/generated/index.js +4 -4
  21. package/dist/effect/index.js +8 -8
  22. package/dist/effect/rpc.js +2 -2
  23. package/dist/effect/service.js +29 -17
  24. package/dist/promise/client.d.ts +1 -0
  25. package/dist/promise/client.js +7 -7
  26. package/dist/promise/generated/client-error.js +1 -1
  27. package/dist/promise/generated/client.d.ts +2 -1
  28. package/dist/promise/generated/client.js +2 -2
  29. package/dist/promise/generated/index.js +13 -9
  30. package/dist/promise/generated/types.d.ts +72 -3
  31. package/dist/promise/generated/types.js +6 -2
  32. package/dist/promise/index.js +15 -11
  33. package/dist/promise/rpc.js +2 -2
  34. package/dist/promise/service.js +29 -17
  35. package/dist/pty-handoff.d.ts +4 -1
  36. package/dist/pty-handoff.js +1 -1
  37. package/dist/rpc-runtime.js +1 -1
  38. package/dist/service-contender.js +1 -1
  39. package/dist/service-timing.js +1 -1
  40. package/dist/service-version.js +1 -1
  41. package/dist/service.js +1 -1
  42. package/dist/shared-events.js +1 -1
  43. package/dist/solid/connection.js +1 -1
  44. package/dist/solid/data.js +9 -9
  45. package/dist/solid/index.js +11 -11
  46. package/dist/solid/pty.js +1 -1
  47. package/package.json +4 -4
  48. /package/dist/chunks/{contract-6mptkzbc.js → service-version-6mptkzbc.js} +0 -0
  49. /package/dist/chunks/{contract-9rqn6x4v.js → service-version-9rqn6x4v.js} +0 -0
  50. /package/dist/chunks/{contract-gne7h7mq.js → service-version-gne7h7mq.js} +0 -0
  51. /package/dist/chunks/{contract-m2eywc8w.js → service-version-m2eywc8w.js} +0 -0
  52. /package/dist/chunks/{contract-nwcpakzx.js → service-version-nwcpakzx.js} +0 -0
  53. /package/dist/chunks/{contract-qav6mfdz.js → service-version-qav6mfdz.js} +0 -0
  54. /package/dist/chunks/{contract-sxt88q69.js → service-version-sxt88q69.js} +0 -0
  55. /package/dist/chunks/{contract-vmytr4q8.js → service-version-vmytr4q8.js} +0 -0
  56. /package/dist/chunks/{contract-vyas3vgt.js → service-version-vyas3vgt.js} +0 -0
  57. /package/dist/chunks/{contract-xgnj2w4v.js → service-version-xgnj2w4v.js} +0 -0
  58. /package/dist/chunks/{contract-y2etg5bs.js → service-version-y2etg5bs.js} +0 -0
  59. /package/dist/chunks/{contract-ydhz1zrh.js → service-version-ydhz1zrh.js} +0 -0
@@ -2,21 +2,21 @@ import {
2
2
  spawnServiceContender2,
3
3
  contenderFailure2,
4
4
  contenderFinished2
5
- } from "../chunks/contract-txckps9j.js";
5
+ } from "../chunks/service-version-6f43cgzz.js";
6
6
  import {
7
7
  defaultEnsureTiming2,
8
8
  ensureTiming2
9
- } from "../chunks/contract-xgnj2w4v.js";
9
+ } from "../chunks/service-version-xgnj2w4v.js";
10
10
  import {
11
11
  matchesVersion2
12
- } from "../chunks/contract-sxt88q69.js";
12
+ } from "../chunks/service-version-sxt88q69.js";
13
13
  import {
14
14
  prepare2,
15
15
  environment2,
16
16
  complete2,
17
17
  clear2
18
- } from "../chunks/contract-fnmdfwt6.js";
19
- import"../chunks/contract-qav6mfdz.js";
18
+ } from "../chunks/service-version-02j88w0z.js";
19
+ import"../chunks/service-version-qav6mfdz.js";
20
20
 
21
21
  // src/effect/service.ts
22
22
  import { Effect, FileSystem, Option, Schedule, Schema } from "effect";
@@ -50,6 +50,7 @@ var ensure = Effect.fn("service.ensure")(function* (options = {}) {
50
50
  let announced = false;
51
51
  let lastSpawn = 0;
52
52
  let spawnDelay = timing.spawnDelay;
53
+ let failure;
53
54
  const announce = (reason, previousVersion) => Effect.sync(() => {
54
55
  if (announced)
55
56
  return;
@@ -82,6 +83,13 @@ var ensure = Effect.fn("service.ensure")(function* (options = {}) {
82
83
  yield* Effect.logWarning("Background service is unresponsive; recovery cannot preserve persistent terminals");
83
84
  yield* Effect.tryPromise(() => clear2(options.file ?? fallback()));
84
85
  yield* terminate(info, options, timing);
86
+ for (const item of contenders) {
87
+ if (item.child.pid === info.pid || contenderFinished2(item)) {
88
+ item.release();
89
+ contenders.delete(item);
90
+ }
91
+ }
92
+ failure = undefined;
85
93
  timeouts = undefined;
86
94
  lastSpawn = Date.now() - spawnDelay;
87
95
  }
@@ -89,7 +97,10 @@ var ensure = Effect.fn("service.ensure")(function* (options = {}) {
89
97
  timeouts = undefined;
90
98
  if (service2 !== undefined) {
91
99
  spawnDelay = timing.spawnDelay;
92
- const compatible = service2.compatible && matchesVersion2(service2.version, options);
100
+ const versionMatches = matchesVersion2(service2.version, options);
101
+ const compatible = service2.compatible && versionMatches;
102
+ if (!service2.compatible && versionMatches)
103
+ return yield* Effect.fail(new Error("Background service uses an incompatible health protocol. Update this client or explicitly restart the service."));
93
104
  if (compatible && service2.state === "ready") {
94
105
  yield* Effect.tryPromise(() => complete2(options.file ?? fallback(), service2.info));
95
106
  return Option.some(service2);
@@ -105,19 +116,26 @@ var ensure = Effect.fn("service.ensure")(function* (options = {}) {
105
116
  file: options.file,
106
117
  pty: service2.state === "ready" ? "handoff" : "clear"
107
118
  }).pipe(Effect.ignore);
119
+ for (const item of contenders) {
120
+ if (item.child.pid === service2.info.pid || contenderFinished2(item)) {
121
+ item.release();
122
+ contenders.delete(item);
123
+ }
124
+ }
125
+ failure = undefined;
108
126
  lastSpawn = 0;
109
127
  return Option.none();
110
128
  } else if (lastSpawn === 0 && info !== undefined)
111
129
  lastSpawn = Date.now();
112
130
  const finished = [...contenders].filter(contenderFinished2);
113
- const failure = finished.map(contenderFailure2).find((error) => error !== undefined);
131
+ failure ??= finished.map(contenderFailure2).find((error) => error !== undefined);
114
132
  if (finished.some((item) => item.child.exitCode === 0)) {
115
133
  spawnDelay = Math.min(spawnDelay * 2, timing.maxSpawnDelay);
116
134
  }
117
135
  finished.forEach((item) => contenders.delete(item));
118
136
  if (failure !== undefined && contenders.size === 0)
119
137
  return yield* Effect.fail(failure);
120
- if (contenders.size < 2 && Date.now() - lastSpawn >= spawnDelay) {
138
+ if (failure === undefined && contenders.size < 2 && Date.now() - lastSpawn >= spawnDelay) {
121
139
  yield* announce("missing");
122
140
  contenders.add(yield* spawnContender);
123
141
  lastSpawn = Date.now();
@@ -128,17 +146,14 @@ var ensure = Effect.fn("service.ensure")(function* (options = {}) {
128
146
  schedule: Schedule.spaced(timing.pollInterval).pipe(Schedule.upTo({ duration: timing.promiseTimeout }))
129
147
  }), Effect.ensuring(Effect.sync(() => contenders.forEach((contender) => contender.release()))));
130
148
  if (Option.isNone(found))
131
- return yield* Effect.fail(new Error("Timed out waiting for the background service to start"));
149
+ return yield* Effect.fail(failure ?? new Error("Timed out waiting for the background service to start"));
132
150
  return found.value.endpoint;
133
151
  });
134
152
  var stop = Effect.fn("service.stop")(function* (options = {}) {
135
153
  const info = yield* read(options.file);
136
- if (options.pty === "handoff" && info !== undefined)
137
- yield* Effect.tryPromise(() => prepare2(options.file ?? fallback(), info, defaultEnsureTiming2.requestTimeout));
138
- else
139
- yield* Effect.tryPromise(() => clear2(options.file ?? fallback()));
154
+ yield* Effect.tryPromise(() => options.pty === "handoff" && info !== undefined ? prepare2(options.file ?? fallback(), info, defaultEnsureTiming2.requestTimeout) : clear2(options.file ?? fallback())).pipe(Effect.catch((cause) => Effect.logWarning("Failed to prepare persistent terminals for replacement", cause)));
140
155
  if (info !== undefined)
141
- yield* terminate(info, options, defaultEnsureTiming2);
156
+ yield* terminate(info, options, ensureTiming2(options));
142
157
  });
143
158
  function fallback() {
144
159
  const state = process.env["XDG_STATE_HOME"] ?? join(homedir(), ".local", "state");
@@ -239,9 +254,6 @@ var terminate = Effect.fnUntraced(function* (info, options, timing) {
239
254
  yield* signal(info.pid, "SIGTERM");
240
255
  const done = yield* stopped(info.pid).pipe(Effect.retry(poll(timing)), Effect.option);
241
256
  if (Option.isNone(done)) {
242
- const latest = yield* read(options.file);
243
- if (latest === undefined || !same(latest, info))
244
- return;
245
257
  yield* signal(info.pid, "SIGKILL");
246
258
  yield* stopped(info.pid).pipe(Effect.retry(poll(timing)));
247
259
  }
@@ -219,6 +219,7 @@ export declare function make(options: ClientOptions): {
219
219
  refresh: (input: import("./index.js").WorktreeRefreshInput, requestOptions?: OpenCode.RequestOptions) => Promise<void>;
220
220
  };
221
221
  vcs: {
222
+ init: (input?: import("./index.js").VcsInitInput, requestOptions?: OpenCode.RequestOptions) => Promise<void>;
222
223
  get: (input?: import("./index.js").VcsGetInput, requestOptions?: OpenCode.RequestOptions) => Promise<import("./index.js").VcsGetOutput>;
223
224
  base: (input?: import("./index.js").VcsBaseInput, requestOptions?: OpenCode.RequestOptions) => Promise<import("./index.js").VcsBaseOutput>;
224
225
  status: (input?: import("./index.js").VcsStatusInput, requestOptions?: OpenCode.RequestOptions) => Promise<import("./index.js").VcsStatusOutput>;
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  make5,
3
3
  exports_client3
4
- } from "../chunks/contract-3heptsgt.js";
5
- import"../chunks/contract-1tbj6z39.js";
6
- import"../chunks/contract-vyas3vgt.js";
7
- import"../chunks/contract-4tveyqeh.js";
8
- import"../chunks/contract-c3yh8bjt.js";
9
- import"../chunks/contract-nwcpakzx.js";
10
- import"../chunks/contract-frbwqjmf.js";
4
+ } from "../chunks/service-version-gah0fg5v.js";
5
+ import"../chunks/service-version-vyas3vgt.js";
6
+ import"../chunks/service-version-nyqggzs9.js";
7
+ import"../chunks/service-version-nwcpakzx.js";
8
+ import"../chunks/service-version-1y4a697q.js";
9
+ import"../chunks/service-version-vt9jbch8.js";
10
+ import"../chunks/service-version-frbwqjmf.js";
11
11
  export {
12
12
  exports_client3 as OpenCode,
13
13
  make5 as make
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ClientError3
3
- } from "../../chunks/contract-nwcpakzx.js";
3
+ } from "../../chunks/service-version-nwcpakzx.js";
4
4
  export {
5
5
  ClientError3 as ClientError
6
6
  };
@@ -1,4 +1,4 @@
1
- import type { ServerConnectInput, LocationGetInput, AgentListInput, AgentListOutput, AgentGetInput, AgentGetOutput, PluginListInput, PluginListOutput, PluginCheckInput, PluginCheckOutput, PluginUpdateInput, SessionListInput, SessionStatsInput, SessionCreateInput, SessionImportInput, SessionExportInput, SessionGetInput, SessionRemoveInput, SessionForkInput, SessionSwitchAgentInput, SessionSwitchModelInput, SessionUpdateInput, SessionMoveInput, SessionPromptInput, SessionCommandInput, SessionSkillInput, SessionSyntheticInput, SessionShellInput, SessionCompactInput, SessionWaitInput, SessionRevertStageInput, SessionRevertClearInput, SessionRevertCommitInput, SessionContextInput, SessionDiffInput, SessionInboxListInput, SessionInboxCancelInput, SessionInboxUpdateInput, SessionInstructionsEntryListInput, SessionInstructionsEntryPutInput, SessionInstructionsEntryRemoveInput, SessionGenerateInput, SessionLogInput, SessionLogOutput, SessionInterruptInput, SessionBackgroundInput, SessionMessageGetInput, SessionFormListInput, SessionFormCreateInput, SessionFormGetInput, SessionFormReplyInput, SessionFormCancelInput, SessionEnvironmentInput, SessionViewInput, MessageListInput, ModelListInput, ModelListOutput, ModelDefaultInput, ModelDefaultOutput, GenerateTextInput, ProviderListInput, ProviderListOutput, ProviderGetInput, ProviderGetOutput, IntegrationListInput, IntegrationListOutput, IntegrationGetInput, IntegrationGetOutput, IntegrationWellknownAddInput, IntegrationConnectKeyInput, IntegrationOauthConnectInput, IntegrationOauthConnectOutput, IntegrationOauthStatusInput, IntegrationOauthStatusOutput, IntegrationOauthCompleteInput, IntegrationOauthCancelInput, IntegrationCommandConnectInput, IntegrationCommandConnectOutput, IntegrationCommandStatusInput, IntegrationCommandStatusOutput, IntegrationCommandCancelInput, McpListInput, McpListOutput, McpAddInput, McpRemoveInput, McpConnectInput, McpDisconnectInput, McpResourceCatalogInput, McpResourceCatalogOutput, CredentialCreateInput, CredentialUpdateInput, CredentialActivateInput, CredentialRemoveInput, ProjectListOutput, ProjectUpdateInput, FormListInput, FormListOutput, PermissionRequestListInput, PermissionRequestListOutput, PermissionSavedListInput, PermissionSavedRemoveInput, PermissionCreateInput, PermissionListInput, PermissionGetInput, PermissionReplyInput, FileReadInput, FileReadOutput, FileListInput, FileListOutput, FileFindInput, FileFindOutput, FileWriteInput, FileWriteOutput, CommandListInput, CommandListOutput, SkillListInput, SkillListOutput, RpcCallInput, EventSubscribeOutput, PtyListInput, PtyListOutput, PtyCreateInput, PtyCreateOutput, PtyGetInput, PtyGetOutput, PtyUpdateInput, PtyUpdateOutput, PtyRemoveInput, PtyConnectTokenInput, PtyConnectTokenOutput, ExperimentalPersistentPtyReadInput, ExperimentalPersistentPtyListInput, ExperimentalPersistentPtyCreateInput, ExperimentalPersistentPtyHandoffOutput, ExperimentalPersistentPtyGetInput, ExperimentalPersistentPtyUpdateInput, ExperimentalPersistentPtySnapshotInput, ExperimentalPersistentPtyRemoveInput, ExperimentalPersistentPtyConnectTokenInput, ShellListInput, ShellListOutput, ShellCreateInput, ShellCreateOutput, ShellGetInput, ShellGetOutput, ShellOutputInput, ShellOutputOutput, ShellRemoveInput, ReferenceListInput, ReferenceListOutput, WorktreeListInput, WorktreeCreateInput, WorktreeRemoveInput, WorktreeRefreshInput, VcsGetInput, VcsGetOutput, VcsBaseInput, VcsBaseOutput, VcsStatusInput, VcsStatusOutput, VcsBranchListInput, VcsBranchListOutput, VcsDiffInput, VcsDiffOutput, DebugLocationListOutput, DebugLocationEvictInput, MigrationV1StatusOutput, WebsearchProvidersInput, WebsearchProvidersOutput, WebsearchQueryInput, WebsearchQueryOutput, ConfigGetInput, ConfigGetOutput, ConfigShellsOutput, ConfigUpdateInput } from "./types.js";
1
+ import type { ServerConnectInput, LocationGetInput, AgentListInput, AgentListOutput, AgentGetInput, AgentGetOutput, PluginListInput, PluginListOutput, PluginCheckInput, PluginCheckOutput, PluginUpdateInput, SessionListInput, SessionStatsInput, SessionCreateInput, SessionImportInput, SessionExportInput, SessionGetInput, SessionRemoveInput, SessionForkInput, SessionSwitchAgentInput, SessionSwitchModelInput, SessionUpdateInput, SessionMoveInput, SessionPromptInput, SessionCommandInput, SessionSkillInput, SessionSyntheticInput, SessionShellInput, SessionCompactInput, SessionWaitInput, SessionRevertStageInput, SessionRevertClearInput, SessionRevertCommitInput, SessionContextInput, SessionDiffInput, SessionInboxListInput, SessionInboxCancelInput, SessionInboxUpdateInput, SessionInstructionsEntryListInput, SessionInstructionsEntryPutInput, SessionInstructionsEntryRemoveInput, SessionGenerateInput, SessionLogInput, SessionLogOutput, SessionInterruptInput, SessionBackgroundInput, SessionMessageGetInput, SessionFormListInput, SessionFormCreateInput, SessionFormGetInput, SessionFormReplyInput, SessionFormCancelInput, SessionEnvironmentInput, SessionViewInput, MessageListInput, ModelListInput, ModelListOutput, ModelDefaultInput, ModelDefaultOutput, GenerateTextInput, ProviderListInput, ProviderListOutput, ProviderGetInput, ProviderGetOutput, IntegrationListInput, IntegrationListOutput, IntegrationGetInput, IntegrationGetOutput, IntegrationWellknownAddInput, IntegrationConnectKeyInput, IntegrationOauthConnectInput, IntegrationOauthConnectOutput, IntegrationOauthStatusInput, IntegrationOauthStatusOutput, IntegrationOauthCompleteInput, IntegrationOauthCancelInput, IntegrationCommandConnectInput, IntegrationCommandConnectOutput, IntegrationCommandStatusInput, IntegrationCommandStatusOutput, IntegrationCommandCancelInput, McpListInput, McpListOutput, McpAddInput, McpRemoveInput, McpConnectInput, McpDisconnectInput, McpResourceCatalogInput, McpResourceCatalogOutput, CredentialCreateInput, CredentialUpdateInput, CredentialActivateInput, CredentialRemoveInput, ProjectListOutput, ProjectUpdateInput, FormListInput, FormListOutput, PermissionRequestListInput, PermissionRequestListOutput, PermissionSavedListInput, PermissionSavedRemoveInput, PermissionCreateInput, PermissionListInput, PermissionGetInput, PermissionReplyInput, FileReadInput, FileReadOutput, FileListInput, FileListOutput, FileFindInput, FileFindOutput, FileWriteInput, FileWriteOutput, CommandListInput, CommandListOutput, SkillListInput, SkillListOutput, RpcCallInput, EventSubscribeOutput, PtyListInput, PtyListOutput, PtyCreateInput, PtyCreateOutput, PtyGetInput, PtyGetOutput, PtyUpdateInput, PtyUpdateOutput, PtyRemoveInput, PtyConnectTokenInput, PtyConnectTokenOutput, ExperimentalPersistentPtyReadInput, ExperimentalPersistentPtyListInput, ExperimentalPersistentPtyCreateInput, ExperimentalPersistentPtyHandoffOutput, ExperimentalPersistentPtyGetInput, ExperimentalPersistentPtyUpdateInput, ExperimentalPersistentPtySnapshotInput, ExperimentalPersistentPtyRemoveInput, ExperimentalPersistentPtyConnectTokenInput, ShellListInput, ShellListOutput, ShellCreateInput, ShellCreateOutput, ShellGetInput, ShellGetOutput, ShellOutputInput, ShellOutputOutput, ShellRemoveInput, ReferenceListInput, ReferenceListOutput, WorktreeListInput, WorktreeCreateInput, WorktreeRemoveInput, WorktreeRefreshInput, VcsInitInput, VcsGetInput, VcsGetOutput, VcsBaseInput, VcsBaseOutput, VcsStatusInput, VcsStatusOutput, VcsBranchListInput, VcsBranchListOutput, VcsDiffInput, VcsDiffOutput, DebugLocationListOutput, DebugLocationEvictInput, MigrationV1StatusOutput, WebsearchProvidersInput, WebsearchProvidersOutput, WebsearchQueryInput, WebsearchQueryOutput, ConfigGetInput, ConfigGetOutput, ConfigShellsOutput, ConfigUpdateInput } from "./types.js";
2
2
  export interface ClientOptions {
3
3
  readonly baseUrl: string;
4
4
  readonly fetch?: typeof globalThis.fetch;
@@ -226,6 +226,7 @@ export declare function make(options: ClientOptions): {
226
226
  refresh: (input: WorktreeRefreshInput, requestOptions?: RequestOptions) => Promise<void>;
227
227
  };
228
228
  vcs: {
229
+ init: (input?: VcsInitInput, requestOptions?: RequestOptions) => Promise<void>;
229
230
  get: (input?: VcsGetInput, requestOptions?: RequestOptions) => Promise<VcsGetOutput>;
230
231
  base: (input?: VcsBaseInput, requestOptions?: RequestOptions) => Promise<VcsBaseOutput>;
231
232
  status: (input?: VcsStatusInput, requestOptions?: RequestOptions) => Promise<VcsStatusOutput>;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  make6
3
- } from "../../chunks/contract-c3yh8bjt.js";
4
- import"../../chunks/contract-nwcpakzx.js";
3
+ } from "../../chunks/service-version-nyqggzs9.js";
4
+ import"../../chunks/service-version-nwcpakzx.js";
5
5
  export {
6
6
  make6 as make
7
7
  };
@@ -1,7 +1,14 @@
1
- import"../../chunks/contract-vyas3vgt.js";
1
+ import"../../chunks/service-version-vyas3vgt.js";
2
+ import {
3
+ exports_client4
4
+ } from "../../chunks/service-version-nyqggzs9.js";
5
+ import {
6
+ ClientError3
7
+ } from "../../chunks/service-version-nwcpakzx.js";
2
8
  import {
3
9
  isInvalidRequestError2,
4
10
  isUnauthorizedError2,
11
+ isLocationNotFoundError2,
5
12
  isServiceUnavailableError2,
6
13
  isAgentNotFoundError2,
7
14
  isInvalidCursorError2,
@@ -30,14 +37,9 @@ import {
30
37
  isPtyNotFoundError2,
31
38
  isForbiddenError2,
32
39
  isShellNotFoundError2,
33
- isWorktreeError2
34
- } from "../../chunks/contract-4tveyqeh.js";
35
- import {
36
- exports_client4
37
- } from "../../chunks/contract-c3yh8bjt.js";
38
- import {
39
- ClientError3
40
- } from "../../chunks/contract-nwcpakzx.js";
40
+ isWorktreeError2,
41
+ isVcsInitNotSupportedError2
42
+ } from "../../chunks/service-version-vt9jbch8.js";
41
43
  export {
42
44
  ClientError3 as ClientError,
43
45
  exports_client4 as OpenCode,
@@ -56,6 +58,7 @@ export {
56
58
  isIntegrationNotFoundError2 as isIntegrationNotFoundError,
57
59
  isInvalidCursorError2 as isInvalidCursorError,
58
60
  isInvalidRequestError2 as isInvalidRequestError,
61
+ isLocationNotFoundError2 as isLocationNotFoundError,
59
62
  isMcpServerNotFoundError2 as isMcpServerNotFoundError,
60
63
  isMessageNotFoundError2 as isMessageNotFoundError,
61
64
  isPermissionNotFoundError2 as isPermissionNotFoundError,
@@ -71,5 +74,6 @@ export {
71
74
  isSkillNotFoundError2 as isSkillNotFoundError,
72
75
  isUnauthorizedError2 as isUnauthorizedError,
73
76
  isUnknownError2 as isUnknownError,
77
+ isVcsInitNotSupportedError2 as isVcsInitNotSupportedError,
74
78
  isWorktreeError2 as isWorktreeError
75
79
  };
@@ -8,6 +8,9 @@ export type ServerInfo = {
8
8
  paths: {
9
9
  tmp: string;
10
10
  };
11
+ capabilities?: {
12
+ persistentPty?: boolean | undefined;
13
+ } | undefined;
11
14
  };
12
15
  export type PairingCode = {
13
16
  code: string;
@@ -693,6 +696,11 @@ export type McpProtocol = "legacy" | "auto" | "2026-07-28";
693
696
  export type ConfigWorktree = {
694
697
  directory: string;
695
698
  };
699
+ export type ConfigModelCapabilities = {
700
+ tools?: boolean;
701
+ input?: Array<string>;
702
+ output?: Array<string>;
703
+ };
696
704
  export type ConfigShellOption = {
697
705
  path: string;
698
706
  name: string;
@@ -754,7 +762,8 @@ export type ConfigModelSettings = {
754
762
  };
755
763
  export type ProviderSettings = {
756
764
  timeout?: number | false;
757
- chunkTimeout?: number;
765
+ headerTimeout?: number | false;
766
+ chunkTimeout?: number | false;
758
767
  compaction?: ProviderCompaction;
759
768
  transport?: ProviderTransport;
760
769
  } & {
@@ -762,7 +771,8 @@ export type ProviderSettings = {
762
771
  };
763
772
  export type ConfigProviderSettings = {
764
773
  timeout?: number | false;
765
- chunkTimeout?: number;
774
+ headerTimeout?: number | false;
775
+ chunkTimeout?: number | false;
766
776
  compaction?: ProviderCompaction;
767
777
  transport?: ProviderTransport;
768
778
  } & {
@@ -3078,7 +3088,7 @@ export type ConfigEntry = {
3078
3088
  body?: {
3079
3089
  [x: string]: JsonValue;
3080
3090
  };
3081
- capabilities?: ModelCapabilities;
3091
+ capabilities?: ConfigModelCapabilities;
3082
3092
  variants?: Array<{
3083
3093
  id: string;
3084
3094
  settings?: ConfigModelSettings;
@@ -3358,6 +3368,14 @@ export type UnauthorizedError = {
3358
3368
  readonly message: string;
3359
3369
  };
3360
3370
  export declare const isUnauthorizedError: (value: unknown) => value is UnauthorizedError;
3371
+ export type LocationNotFoundError = {
3372
+ readonly _tag: "LocationNotFoundError";
3373
+ readonly location: {
3374
+ readonly directory: string;
3375
+ };
3376
+ readonly message: string;
3377
+ };
3378
+ export declare const isLocationNotFoundError: (value: unknown) => value is LocationNotFoundError;
3361
3379
  export type ServiceUnavailableError = {
3362
3380
  readonly _tag: "ServiceUnavailableError";
3363
3381
  readonly message: string;
@@ -3531,6 +3549,7 @@ export type ShellNotFoundError = {
3531
3549
  };
3532
3550
  export declare const isShellNotFoundError: (value: unknown) => value is ShellNotFoundError;
3533
3551
  export type WorktreeError = {
3552
+ readonly _tag: "WorktreeError";
3534
3553
  readonly name: "WorktreeError";
3535
3554
  readonly data: {
3536
3555
  readonly message: string;
@@ -3538,6 +3557,12 @@ export type WorktreeError = {
3538
3557
  };
3539
3558
  };
3540
3559
  export declare const isWorktreeError: (value: unknown) => value is WorktreeError;
3560
+ export type VcsInitNotSupportedError = {
3561
+ readonly _tag: "VcsInitNotSupportedError";
3562
+ readonly providerID: string;
3563
+ readonly message: string;
3564
+ };
3565
+ export declare const isVcsInitNotSupportedError: (value: unknown) => value is VcsInitNotSupportedError;
3541
3566
  export type ServerInfoOutput = ServerInfo;
3542
3567
  export type ServerPairOutput = PairingCode;
3543
3568
  export type ServerConnectInput = {
@@ -3742,6 +3767,7 @@ export type SessionStatsOutput = {
3742
3767
  export type SessionCreateInput = {
3743
3768
  readonly id?: {
3744
3769
  readonly id?: string | null;
3770
+ readonly parentID?: string | null;
3745
3771
  readonly title?: string | null;
3746
3772
  readonly agent?: string | null;
3747
3773
  readonly model?: {
@@ -3761,8 +3787,31 @@ export type SessionCreateInput = {
3761
3787
  readonly effect: "allow" | "deny" | "ask";
3762
3788
  }> | null;
3763
3789
  }["id"];
3790
+ readonly parentID?: {
3791
+ readonly id?: string | null;
3792
+ readonly parentID?: string | null;
3793
+ readonly title?: string | null;
3794
+ readonly agent?: string | null;
3795
+ readonly model?: {
3796
+ readonly id: string;
3797
+ readonly providerID: string;
3798
+ readonly variant?: string;
3799
+ } | null;
3800
+ readonly location?: {
3801
+ readonly directory: string;
3802
+ } | null;
3803
+ readonly metadata?: {
3804
+ readonly [x: string]: JsonValue;
3805
+ } | null;
3806
+ readonly permissions?: ReadonlyArray<{
3807
+ readonly action: string;
3808
+ readonly resource: string;
3809
+ readonly effect: "allow" | "deny" | "ask";
3810
+ }> | null;
3811
+ }["parentID"];
3764
3812
  readonly title?: {
3765
3813
  readonly id?: string | null;
3814
+ readonly parentID?: string | null;
3766
3815
  readonly title?: string | null;
3767
3816
  readonly agent?: string | null;
3768
3817
  readonly model?: {
@@ -3784,6 +3833,7 @@ export type SessionCreateInput = {
3784
3833
  }["title"];
3785
3834
  readonly agent?: {
3786
3835
  readonly id?: string | null;
3836
+ readonly parentID?: string | null;
3787
3837
  readonly title?: string | null;
3788
3838
  readonly agent?: string | null;
3789
3839
  readonly model?: {
@@ -3805,6 +3855,7 @@ export type SessionCreateInput = {
3805
3855
  }["agent"];
3806
3856
  readonly model?: {
3807
3857
  readonly id?: string | null;
3858
+ readonly parentID?: string | null;
3808
3859
  readonly title?: string | null;
3809
3860
  readonly agent?: string | null;
3810
3861
  readonly model?: {
@@ -3826,6 +3877,7 @@ export type SessionCreateInput = {
3826
3877
  }["model"];
3827
3878
  readonly location?: {
3828
3879
  readonly id?: string | null;
3880
+ readonly parentID?: string | null;
3829
3881
  readonly title?: string | null;
3830
3882
  readonly agent?: string | null;
3831
3883
  readonly model?: {
@@ -3847,6 +3899,7 @@ export type SessionCreateInput = {
3847
3899
  }["location"];
3848
3900
  readonly metadata?: {
3849
3901
  readonly id?: string | null;
3902
+ readonly parentID?: string | null;
3850
3903
  readonly title?: string | null;
3851
3904
  readonly agent?: string | null;
3852
3905
  readonly model?: {
@@ -3868,6 +3921,7 @@ export type SessionCreateInput = {
3868
3921
  }["metadata"];
3869
3922
  readonly permissions?: {
3870
3923
  readonly id?: string | null;
3924
+ readonly parentID?: string | null;
3871
3925
  readonly title?: string | null;
3872
3926
  readonly agent?: string | null;
3873
3927
  readonly model?: {
@@ -8541,6 +8595,21 @@ export type WorktreeRefreshInput = {
8541
8595
  }["projectID"];
8542
8596
  };
8543
8597
  export type WorktreeRefreshOutput = void;
8598
+ export type VcsInitInput = {
8599
+ readonly location?: {
8600
+ readonly location?: {
8601
+ readonly directory?: string | undefined;
8602
+ } | undefined;
8603
+ readonly provider?: string | undefined;
8604
+ }["location"];
8605
+ readonly provider?: {
8606
+ readonly location?: {
8607
+ readonly directory?: string | undefined;
8608
+ } | undefined;
8609
+ readonly provider?: string | undefined;
8610
+ }["provider"];
8611
+ };
8612
+ export type VcsInitOutput = void;
8544
8613
  export type VcsGetInput = {
8545
8614
  readonly location?: {
8546
8615
  readonly location?: {
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  isInvalidRequestError2,
3
3
  isUnauthorizedError2,
4
+ isLocationNotFoundError2,
4
5
  isServiceUnavailableError2,
5
6
  isAgentNotFoundError2,
6
7
  isInvalidCursorError2,
@@ -29,8 +30,9 @@ import {
29
30
  isPtyNotFoundError2,
30
31
  isForbiddenError2,
31
32
  isShellNotFoundError2,
32
- isWorktreeError2
33
- } from "../../chunks/contract-4tveyqeh.js";
33
+ isWorktreeError2,
34
+ isVcsInitNotSupportedError2
35
+ } from "../../chunks/service-version-vt9jbch8.js";
34
36
  export {
35
37
  isAgentNotFoundError2 as isAgentNotFoundError,
36
38
  isCommandExecutionError2 as isCommandExecutionError,
@@ -47,6 +49,7 @@ export {
47
49
  isIntegrationNotFoundError2 as isIntegrationNotFoundError,
48
50
  isInvalidCursorError2 as isInvalidCursorError,
49
51
  isInvalidRequestError2 as isInvalidRequestError,
52
+ isLocationNotFoundError2 as isLocationNotFoundError,
50
53
  isMcpServerNotFoundError2 as isMcpServerNotFoundError,
51
54
  isMessageNotFoundError2 as isMessageNotFoundError,
52
55
  isPermissionNotFoundError2 as isPermissionNotFoundError,
@@ -62,5 +65,6 @@ export {
62
65
  isSkillNotFoundError2 as isSkillNotFoundError,
63
66
  isUnauthorizedError2 as isUnauthorizedError,
64
67
  isUnknownError2 as isUnknownError,
68
+ isVcsInitNotSupportedError2 as isVcsInitNotSupportedError,
65
69
  isWorktreeError2 as isWorktreeError
66
70
  };
@@ -1,12 +1,17 @@
1
- import"../chunks/contract-m2eywc8w.js";
1
+ import"../chunks/service-version-m2eywc8w.js";
2
2
  import {
3
3
  exports_client3
4
- } from "../chunks/contract-3heptsgt.js";
5
- import"../chunks/contract-1tbj6z39.js";
6
- import"../chunks/contract-vyas3vgt.js";
4
+ } from "../chunks/service-version-gah0fg5v.js";
5
+ import"../chunks/service-version-vyas3vgt.js";
6
+ import"../chunks/service-version-nyqggzs9.js";
7
+ import {
8
+ ClientError3
9
+ } from "../chunks/service-version-nwcpakzx.js";
10
+ import"../chunks/service-version-1y4a697q.js";
7
11
  import {
8
12
  isInvalidRequestError2,
9
13
  isUnauthorizedError2,
14
+ isLocationNotFoundError2,
10
15
  isServiceUnavailableError2,
11
16
  isAgentNotFoundError2,
12
17
  isInvalidCursorError2,
@@ -35,13 +40,10 @@ import {
35
40
  isPtyNotFoundError2,
36
41
  isForbiddenError2,
37
42
  isShellNotFoundError2,
38
- isWorktreeError2
39
- } from "../chunks/contract-4tveyqeh.js";
40
- import"../chunks/contract-c3yh8bjt.js";
41
- import {
42
- ClientError3
43
- } from "../chunks/contract-nwcpakzx.js";
44
- import"../chunks/contract-frbwqjmf.js";
43
+ isWorktreeError2,
44
+ isVcsInitNotSupportedError2
45
+ } from "../chunks/service-version-vt9jbch8.js";
46
+ import"../chunks/service-version-frbwqjmf.js";
45
47
  export {
46
48
  ClientError3 as ClientError,
47
49
  exports_client3 as OpenCode,
@@ -60,6 +62,7 @@ export {
60
62
  isIntegrationNotFoundError2 as isIntegrationNotFoundError,
61
63
  isInvalidCursorError2 as isInvalidCursorError,
62
64
  isInvalidRequestError2 as isInvalidRequestError,
65
+ isLocationNotFoundError2 as isLocationNotFoundError,
63
66
  isMcpServerNotFoundError2 as isMcpServerNotFoundError,
64
67
  isMessageNotFoundError2 as isMessageNotFoundError,
65
68
  isPermissionNotFoundError2 as isPermissionNotFoundError,
@@ -75,5 +78,6 @@ export {
75
78
  isSkillNotFoundError2 as isSkillNotFoundError,
76
79
  isUnauthorizedError2 as isUnauthorizedError,
77
80
  isUnknownError2 as isUnknownError,
81
+ isVcsInitNotSupportedError2 as isVcsInitNotSupportedError,
78
82
  isWorktreeError2 as isWorktreeError
79
83
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  makeRpc2
3
- } from "../chunks/contract-1tbj6z39.js";
4
- import"../chunks/contract-4tveyqeh.js";
3
+ } from "../chunks/service-version-1y4a697q.js";
4
+ import"../chunks/service-version-vt9jbch8.js";
5
5
  export {
6
6
  makeRpc2 as makeRpc
7
7
  };
@@ -2,21 +2,21 @@ import {
2
2
  spawnServiceContender2,
3
3
  contenderFailure2,
4
4
  contenderFinished2
5
- } from "../chunks/contract-txckps9j.js";
5
+ } from "../chunks/service-version-6f43cgzz.js";
6
6
  import {
7
7
  defaultEnsureTiming2,
8
8
  ensureTiming2
9
- } from "../chunks/contract-xgnj2w4v.js";
9
+ } from "../chunks/service-version-xgnj2w4v.js";
10
10
  import {
11
11
  matchesVersion2
12
- } from "../chunks/contract-sxt88q69.js";
12
+ } from "../chunks/service-version-sxt88q69.js";
13
13
  import {
14
14
  prepare2,
15
15
  environment2,
16
16
  complete2,
17
17
  clear2
18
- } from "../chunks/contract-fnmdfwt6.js";
19
- import"../chunks/contract-qav6mfdz.js";
18
+ } from "../chunks/service-version-02j88w0z.js";
19
+ import"../chunks/service-version-qav6mfdz.js";
20
20
 
21
21
  // src/promise/service.ts
22
22
  import { readFile, rm } from "node:fs/promises";
@@ -40,6 +40,7 @@ async function ensure(options = {}) {
40
40
  let announced = false;
41
41
  let lastSpawn = 0;
42
42
  let spawnDelay = timing.spawnDelay;
43
+ let failure;
43
44
  const announce = (reason, previousVersion) => {
44
45
  if (announced)
45
46
  return;
@@ -59,7 +60,7 @@ async function ensure(options = {}) {
59
60
  try {
60
61
  while (true) {
61
62
  if (Date.now() >= deadline)
62
- throw new Error("Timed out waiting for the background service to start");
63
+ throw failure ?? new Error("Timed out waiting for the background service to start");
63
64
  const registration = await registered(options.file, timing.requestTimeout);
64
65
  if (registration.timedOut && registration.info !== undefined) {
65
66
  timeouts = {
@@ -71,6 +72,13 @@ async function ensure(options = {}) {
71
72
  console.warn("Background service is unresponsive; recovery cannot preserve persistent terminals");
72
73
  await clear2(options.file ?? fallback());
73
74
  await terminate(registration.info, options, timing);
75
+ for (const item of contenders) {
76
+ if (item.child.pid === registration.info.pid || contenderFinished2(item)) {
77
+ item.release();
78
+ contenders.delete(item);
79
+ }
80
+ }
81
+ failure = undefined;
74
82
  timeouts = undefined;
75
83
  lastSpawn = Date.now() - spawnDelay;
76
84
  }
@@ -79,7 +87,10 @@ async function ensure(options = {}) {
79
87
  if (registration.service !== undefined) {
80
88
  spawnDelay = timing.spawnDelay;
81
89
  const service2 = registration.service;
82
- const compatible = service2.compatible && matchesVersion2(service2.version, options);
90
+ const versionMatches = matchesVersion2(service2.version, options);
91
+ const compatible = service2.compatible && versionMatches;
92
+ if (!service2.compatible && versionMatches)
93
+ throw new Error("Background service uses an incompatible health protocol. Update this client or explicitly restart the service.");
83
94
  if (compatible && service2.state === "ready") {
84
95
  await complete2(options.file ?? fallback(), service2.info);
85
96
  return service2.endpoint;
@@ -96,20 +107,27 @@ async function ensure(options = {}) {
96
107
  }).catch(() => {
97
108
  return;
98
109
  });
110
+ for (const item of contenders) {
111
+ if (item.child.pid === service2.info.pid || contenderFinished2(item)) {
112
+ item.release();
113
+ contenders.delete(item);
114
+ }
115
+ }
116
+ failure = undefined;
99
117
  lastSpawn = 0;
100
118
  }
101
119
  } else {
102
120
  if (lastSpawn === 0 && registration.info !== undefined)
103
121
  lastSpawn = Date.now();
104
122
  const finished = [...contenders].filter(contenderFinished2);
105
- const failure = finished.map(contenderFailure2).find((error) => error !== undefined);
123
+ failure ??= finished.map(contenderFailure2).find((error) => error !== undefined);
106
124
  if (finished.some((item) => item.child.exitCode === 0)) {
107
125
  spawnDelay = Math.min(spawnDelay * 2, timing.maxSpawnDelay);
108
126
  }
109
127
  finished.forEach((item) => contenders.delete(item));
110
128
  if (failure !== undefined && contenders.size === 0)
111
129
  throw failure;
112
- if (contenders.size < 2 && Date.now() - lastSpawn >= spawnDelay) {
130
+ if (failure === undefined && contenders.size < 2 && Date.now() - lastSpawn >= spawnDelay) {
113
131
  announce("missing");
114
132
  contenders.add(await spawnContender());
115
133
  lastSpawn = Date.now();
@@ -123,12 +141,9 @@ async function ensure(options = {}) {
123
141
  }
124
142
  async function stop(options = {}) {
125
143
  const info = await read(options.file);
126
- if (options.pty === "handoff" && info !== undefined)
127
- await prepare2(options.file ?? fallback(), info, defaultEnsureTiming2.requestTimeout);
128
- else
129
- await clear2(options.file ?? fallback());
144
+ await (options.pty === "handoff" && info !== undefined ? prepare2(options.file ?? fallback(), info, defaultEnsureTiming2.requestTimeout) : clear2(options.file ?? fallback())).catch((cause) => console.warn("Failed to prepare persistent terminals for replacement", cause));
130
145
  if (info !== undefined)
131
- await terminate(info, options, defaultEnsureTiming2);
146
+ await terminate(info, options, ensureTiming2(options));
132
147
  }
133
148
  function fallback() {
134
149
  return join(process.env["XDG_STATE_HOME"] ?? join(homedir(), ".local", "state"), "opencode", "service.json");
@@ -241,9 +256,6 @@ async function terminate(info, options, timing) {
241
256
  return;
242
257
  signal(info.pid, "SIGTERM");
243
258
  if (!await waitUntilStopped(info.pid, timing)) {
244
- const latest = await read(options.file);
245
- if (latest === undefined || !same(latest, info))
246
- return;
247
259
  signal(info.pid, "SIGKILL");
248
260
  if (!await waitUntilStopped(info.pid, timing))
249
261
  throw new Error(`Server process ${info.pid} is still running`);
@@ -1,6 +1,9 @@
1
1
  export * as PtyHandoff from "./pty-handoff.js";
2
2
  import type { Info } from "./service.js";
3
- /** Publish the ticket before stopping its owner so every replacement contender can adopt it. */
3
+ /**
4
+ * Publish the ticket before stopping its owner so every replacement contender can adopt it.
5
+ * Never throws: terminals are best-effort, so any failure replaces the service without a handoff.
6
+ */
4
7
  export declare function prepare(file: string, info: Info, timeout: number): Promise<void>;
5
8
  export declare function environment(file: string, env?: Readonly<Record<string, string>>): Promise<{
6
9
  OPENCODE_PTY_HANDOFF: string | undefined;