@opencode/client 0.0.0-reserved → 2.0.0

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 (62) hide show
  1. package/README.md +24 -2
  2. package/dist/contract.d.ts +1 -0
  3. package/dist/contract.js +1 -0
  4. package/dist/effect/api/api.d.ts +2698 -0
  5. package/dist/effect/api/api.js +0 -0
  6. package/dist/effect/api.d.ts +8 -0
  7. package/dist/effect/api.js +0 -0
  8. package/dist/effect/client.d.ts +2464 -0
  9. package/dist/effect/client.js +29 -0
  10. package/dist/effect/generated/client-error.d.ts +7 -0
  11. package/dist/effect/generated/client-error.js +5 -0
  12. package/dist/effect/generated/client.d.ts +2463 -0
  13. package/dist/effect/generated/client.js +603 -0
  14. package/dist/effect/generated/index.d.ts +2 -0
  15. package/dist/effect/generated/index.js +2 -0
  16. package/dist/effect/index.d.ts +35 -0
  17. package/dist/effect/index.js +30 -0
  18. package/dist/effect/rpc.d.ts +20 -0
  19. package/dist/effect/rpc.js +49 -0
  20. package/dist/effect/service.d.ts +78 -0
  21. package/dist/effect/service.js +259 -0
  22. package/dist/promise/api.d.ts +24 -0
  23. package/dist/promise/api.js +0 -0
  24. package/dist/promise/client.d.ts +257 -0
  25. package/dist/promise/client.js +13 -0
  26. package/dist/promise/generated/client-error.d.ts +6 -0
  27. package/dist/promise/generated/client-error.js +8 -0
  28. package/dist/promise/generated/client.d.ts +264 -0
  29. package/dist/promise/generated/client.js +1426 -0
  30. package/dist/promise/generated/index.d.ts +3 -0
  31. package/dist/promise/generated/index.js +3 -0
  32. package/dist/promise/generated/types.d.ts +8777 -0
  33. package/dist/promise/generated/types.js +30 -0
  34. package/dist/promise/index.d.ts +6 -0
  35. package/dist/promise/index.js +2 -0
  36. package/dist/promise/rpc.d.ts +32 -0
  37. package/dist/promise/rpc.js +86 -0
  38. package/dist/promise/service.d.ts +26 -0
  39. package/dist/promise/service.js +247 -0
  40. package/dist/pty-handoff.d.ts +9 -0
  41. package/dist/pty-handoff.js +121 -0
  42. package/dist/rpc-runtime.d.ts +21 -0
  43. package/dist/rpc-runtime.js +32 -0
  44. package/dist/service-contender.d.ts +11 -0
  45. package/dist/service-contender.js +56 -0
  46. package/dist/service-timing.d.ts +13 -0
  47. package/dist/service-timing.js +19 -0
  48. package/dist/service-version.d.ts +2 -0
  49. package/dist/service-version.js +9 -0
  50. package/dist/service.d.ts +52 -0
  51. package/dist/service.js +0 -0
  52. package/dist/shared-events.d.ts +11 -0
  53. package/dist/shared-events.js +137 -0
  54. package/dist/solid/connection.d.ts +37 -0
  55. package/dist/solid/connection.js +246 -0
  56. package/dist/solid/data.d.ts +201 -0
  57. package/dist/solid/data.js +1731 -0
  58. package/dist/solid/index.d.ts +3 -0
  59. package/dist/solid/index.js +3 -0
  60. package/dist/solid/pty.d.ts +22 -0
  61. package/dist/solid/pty.js +43 -0
  62. package/package.json +76 -6
@@ -0,0 +1,3 @@
1
+ export * from "./data";
2
+ export * from "./connection";
3
+ export * from "./pty";
@@ -0,0 +1,3 @@
1
+ export * from "./data";
2
+ export * from "./connection";
3
+ export * from "./pty";
@@ -0,0 +1,22 @@
1
+ import type { ExperimentalPersistentPtyConnectTokenInput, OpenCodeClient, PtyConnectTokenInput } from "../promise";
2
+ export type PtyClientOptions = {
3
+ readonly url: string;
4
+ readonly openSocket?: (url: URL) => WebSocket;
5
+ };
6
+ export type PtyConnectInput = {
7
+ readonly ptyID: PtyConnectTokenInput["ptyID"];
8
+ readonly location?: PtyConnectTokenInput["location"];
9
+ readonly cursor?: number;
10
+ };
11
+ export type PersistentPtyConnectInput = {
12
+ readonly ptyID: ExperimentalPersistentPtyConnectTokenInput["ptyID"];
13
+ readonly cursor: number;
14
+ readonly attachmentID: string;
15
+ readonly takeover?: boolean;
16
+ };
17
+ export declare function createPtyClient(api: OpenCodeClient, options: PtyClientOptions): {
18
+ connect(input: PtyConnectInput): Promise<WebSocket>;
19
+ };
20
+ export declare function createPersistentPtyClient(api: OpenCodeClient, options: PtyClientOptions): {
21
+ connect(input: PersistentPtyConnectInput): Promise<WebSocket>;
22
+ };
@@ -0,0 +1,43 @@
1
+ export function createPtyClient(api, options) {
2
+ return {
3
+ async connect(input) {
4
+ const result = await api.pty.connect.token({
5
+ ptyID: input.ptyID,
6
+ location: input.location,
7
+ "x-opencode-ticket": "1",
8
+ });
9
+ const url = new URL(`/api/pty/${encodeURIComponent(input.ptyID)}/connect`, options.url);
10
+ if (input.location?.directory)
11
+ url.searchParams.set("location[directory]", input.location.directory);
12
+ if (input.location?.workspace)
13
+ url.searchParams.set("location[workspace]", input.location.workspace);
14
+ if (input.cursor !== undefined)
15
+ url.searchParams.set("cursor", String(input.cursor));
16
+ url.searchParams.set("ticket", result.data.ticket);
17
+ url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
18
+ const socket = options.openSocket?.(url) ?? new WebSocket(url);
19
+ socket.binaryType = "arraybuffer";
20
+ return socket;
21
+ },
22
+ };
23
+ }
24
+ export function createPersistentPtyClient(api, options) {
25
+ return {
26
+ async connect(input) {
27
+ const token = await api.experimental.persistentPty.connectToken({
28
+ ptyID: input.ptyID,
29
+ "x-opencode-ticket": "1",
30
+ });
31
+ const url = new URL(`/api/experimental/persistent-pty/${encodeURIComponent(input.ptyID)}/connect`, options.url);
32
+ url.searchParams.set("ticket", token.ticket);
33
+ url.searchParams.set("cursor", String(input.cursor));
34
+ url.searchParams.set("attachment_id", input.attachmentID);
35
+ url.searchParams.set("takeover", String(input.takeover ?? false));
36
+ url.searchParams.set("input_protocol", "1");
37
+ url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
38
+ const socket = options.openSocket?.(url) ?? new WebSocket(url);
39
+ socket.binaryType = "arraybuffer";
40
+ return socket;
41
+ },
42
+ };
43
+ }
package/package.json CHANGED
@@ -1,15 +1,85 @@
1
1
  {
2
+ "$schema": "https://json.schemastore.org/package.json",
2
3
  "name": "@opencode/client",
3
- "version": "0.0.0-reserved",
4
- "description": "OpenCode package bootstrap — not a functional release",
4
+ "version": "2.0.0",
5
+ "type": "module",
5
6
  "license": "MIT",
6
7
  "repository": {
7
8
  "type": "git",
8
- "url": "git+https://github.com/anomalyco/opencode.git"
9
+ "url": "git+https://github.com/anomalyco/opencode.git",
10
+ "directory": "packages/client"
9
11
  },
10
12
  "publishConfig": {
11
- "registry": "https://registry.npmjs.org",
12
- "access": "public",
13
- "tag": "reserved"
13
+ "access": "public"
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "exports": {
19
+ ".": {
20
+ "import": "./dist/promise/index.js",
21
+ "types": "./dist/promise/index.d.ts"
22
+ },
23
+ "./promise": {
24
+ "import": "./dist/promise/index.js",
25
+ "types": "./dist/promise/index.d.ts"
26
+ },
27
+ "./promise/api": {
28
+ "import": "./dist/promise/api.js",
29
+ "types": "./dist/promise/api.d.ts"
30
+ },
31
+ "./service": {
32
+ "import": "./dist/promise/service.js",
33
+ "types": "./dist/promise/service.d.ts"
34
+ },
35
+ "./solid": {
36
+ "import": "./dist/solid/index.js",
37
+ "types": "./dist/solid/index.d.ts"
38
+ },
39
+ "./effect": {
40
+ "import": "./dist/effect/index.js",
41
+ "types": "./dist/effect/index.d.ts"
42
+ },
43
+ "./effect/api": {
44
+ "import": "./dist/effect/api.js",
45
+ "types": "./dist/effect/api.d.ts"
46
+ },
47
+ "./effect/service": {
48
+ "import": "./dist/effect/service.js",
49
+ "types": "./dist/effect/service.d.ts"
50
+ }
51
+ },
52
+ "scripts": {
53
+ "build": "bun run script/build-package.ts",
54
+ "generate": "bun run script/build.ts",
55
+ "check:generated": "bun run generate && git diff --exit-code -- src/promise/generated src/effect/generated src/effect/api",
56
+ "test": "bun test --timeout 5000",
57
+ "typecheck": "tsgo --noEmit"
58
+ },
59
+ "dependencies": {
60
+ "@opencode/schema": "2.0.0",
61
+ "@opencode/protocol": "2.0.0"
62
+ },
63
+ "peerDependencies": {
64
+ "effect": "4.0.0-rc.112",
65
+ "solid-js": ">=1.9.0"
66
+ },
67
+ "peerDependenciesMeta": {
68
+ "effect": {
69
+ "optional": true
70
+ },
71
+ "solid-js": {
72
+ "optional": true
73
+ }
74
+ },
75
+ "devDependencies": {
76
+ "@effect/platform-node": "4.0.0-rc.112",
77
+ "@opencode/httpapi-codegen": "2.0.0",
78
+ "@tsconfig/bun": "1.0.9",
79
+ "@types/bun": "1.4.0",
80
+ "@typescript/native-preview": "7.0.0-dev.20251207.1",
81
+ "effect": "4.0.0-rc.112",
82
+ "solid-js": "1.9.15",
83
+ "zod": "4.1.8"
14
84
  }
15
85
  }