@opendray/sdk 2.6.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.
- package/LICENSE +201 -0
- package/README.md +62 -0
- package/dist/index.cjs +317 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +209 -0
- package/dist/index.d.ts +209 -0
- package/dist/index.js +287 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may choose to offer, and charge a
|
|
167
|
+
fee for, acceptance of support, warranty, indemnity, or other
|
|
168
|
+
liability obligations and/or rights consistent with this License.
|
|
169
|
+
However, in accepting such obligations, You may act only on Your
|
|
170
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
171
|
+
other Contributor, and only if You agree to indemnify, defend,
|
|
172
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
173
|
+
or claims asserted against, such Contributor by reason of your
|
|
174
|
+
accepting any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Linivek
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
200
|
+
implied. See the License for the specific language governing permissions
|
|
201
|
+
and limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @opendray/sdk
|
|
2
|
+
|
|
3
|
+
TypeScript / JavaScript client for the [opendray](https://opendray.dev)
|
|
4
|
+
gateway: REST + WebSocket access to sessions, providers, channels,
|
|
5
|
+
integrations, and the event stream.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @opendray/sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Works in Node 18+, Deno, Bun, and the browser. On Node <22 you'll need
|
|
14
|
+
to provide a `WebSocket` implementation (e.g. `ws`) to the WS helpers.
|
|
15
|
+
|
|
16
|
+
## Quick start
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { Client, subscribeEvents } from "@opendray/sdk";
|
|
20
|
+
|
|
21
|
+
const client = new Client({
|
|
22
|
+
baseUrl: "https://opendray.example.com",
|
|
23
|
+
token: process.env.OPENDRAY_TOKEN!, // admin token OR `odk_live_…` integration key
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// REST
|
|
27
|
+
const sessions = await client.listSessions();
|
|
28
|
+
const session = await client.createSession({ provider: "claude", cwd: "/tmp" });
|
|
29
|
+
await client.sendInput(session.id, { data: "ls -la\n" });
|
|
30
|
+
|
|
31
|
+
// WebSocket events
|
|
32
|
+
for await (const frame of subscribeEvents(client, { topics: ["session.*"] })) {
|
|
33
|
+
console.log(frame.topic, frame.data);
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## API surface
|
|
38
|
+
|
|
39
|
+
| Group | Methods |
|
|
40
|
+
| ---------------- | ------- |
|
|
41
|
+
| Integrations | `registerIntegration`, `listIntegrations`, `getIntegration`, `updateIntegration`, `deleteIntegration`, `rotateIntegrationKey` (admin only) |
|
|
42
|
+
| Sessions | `createSession`, `listSessions`, `getSession`, `deleteSession`, `sendInput`, `resizeSession`, `getSessionBuffer` |
|
|
43
|
+
| Providers | `listProviders`, `setProviderConfig` |
|
|
44
|
+
| Channels | `listChannels` |
|
|
45
|
+
| Event stream | `subscribeEvents(client, { topics })` — async iterable, auto-reconnect |
|
|
46
|
+
| Session stream | `streamSession(client, id, { onOutput, onEnded })` — bidirectional terminal WS |
|
|
47
|
+
|
|
48
|
+
Errors thrown by REST calls are `OpendrayError` instances with `status` and `body`.
|
|
49
|
+
|
|
50
|
+
See the [integration guide](https://github.com/Opendray/opendray/blob/main/docs/integration-guide.md)
|
|
51
|
+
for the full surface this SDK wraps.
|
|
52
|
+
|
|
53
|
+
## Versioning
|
|
54
|
+
|
|
55
|
+
This SDK ships in lockstep with the gateway: `@opendray/sdk@X.Y.Z`
|
|
56
|
+
matches gateway `vX.Y.Z`. If the wire types haven't changed between
|
|
57
|
+
two adjacent gateway releases, the SDK still gets a patch bump for
|
|
58
|
+
consistency.
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
Apache-2.0
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
Client: () => Client,
|
|
24
|
+
OpendrayError: () => OpendrayError,
|
|
25
|
+
streamSession: () => streamSession,
|
|
26
|
+
subscribeEvents: () => subscribeEvents
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
|
+
|
|
30
|
+
// src/client.ts
|
|
31
|
+
var OpendrayError = class extends Error {
|
|
32
|
+
status;
|
|
33
|
+
body;
|
|
34
|
+
constructor(status, body, message) {
|
|
35
|
+
super(message);
|
|
36
|
+
this.name = "OpendrayError";
|
|
37
|
+
this.status = status;
|
|
38
|
+
this.body = body;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var Client = class {
|
|
42
|
+
baseUrl;
|
|
43
|
+
token;
|
|
44
|
+
fetchImpl;
|
|
45
|
+
timeoutMs;
|
|
46
|
+
constructor(opts) {
|
|
47
|
+
if (!opts.baseUrl) throw new Error("Client: baseUrl is required");
|
|
48
|
+
if (!opts.token) throw new Error("Client: token is required");
|
|
49
|
+
let trimmed = opts.baseUrl;
|
|
50
|
+
while (trimmed.endsWith("/")) trimmed = trimmed.slice(0, -1);
|
|
51
|
+
this.baseUrl = trimmed;
|
|
52
|
+
this.token = opts.token;
|
|
53
|
+
this.fetchImpl = opts.fetch ?? globalThis.fetch;
|
|
54
|
+
if (!this.fetchImpl) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
"Client: no fetch available \u2014 pass `fetch` in options on platforms older than Node 18."
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
this.timeoutMs = opts.timeoutMs ?? 3e4;
|
|
60
|
+
}
|
|
61
|
+
// ── low level ──────────────────────────────────────────────────────
|
|
62
|
+
async request(method, path, body) {
|
|
63
|
+
const url = `${this.baseUrl}/api/v1${path}`;
|
|
64
|
+
const headers = {
|
|
65
|
+
Authorization: `Bearer ${this.token}`,
|
|
66
|
+
Accept: "application/json"
|
|
67
|
+
};
|
|
68
|
+
let payload;
|
|
69
|
+
if (body !== void 0) {
|
|
70
|
+
headers["Content-Type"] = "application/json";
|
|
71
|
+
payload = JSON.stringify(body);
|
|
72
|
+
}
|
|
73
|
+
const ctrl = this.timeoutMs > 0 ? new AbortController() : null;
|
|
74
|
+
const timer = ctrl ? setTimeout(() => ctrl.abort(new Error("request timed out")), this.timeoutMs) : null;
|
|
75
|
+
const init = { method, headers };
|
|
76
|
+
if (payload !== void 0) init.body = payload;
|
|
77
|
+
if (ctrl) init.signal = ctrl.signal;
|
|
78
|
+
try {
|
|
79
|
+
const res = await this.fetchImpl(url, init);
|
|
80
|
+
const text = await res.text();
|
|
81
|
+
let parsed = void 0;
|
|
82
|
+
if (text.length > 0) {
|
|
83
|
+
try {
|
|
84
|
+
parsed = JSON.parse(text);
|
|
85
|
+
} catch {
|
|
86
|
+
parsed = text;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (!res.ok) {
|
|
90
|
+
const msg = (parsed && typeof parsed === "object" && "error" in parsed ? String(parsed.error) : void 0) ?? `${method} ${path} -> ${res.status}`;
|
|
91
|
+
throw new OpendrayError(res.status, parsed, msg);
|
|
92
|
+
}
|
|
93
|
+
return parsed;
|
|
94
|
+
} finally {
|
|
95
|
+
if (timer) clearTimeout(timer);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// ── integrations (admin-only) ──────────────────────────────────────
|
|
99
|
+
registerIntegration(input) {
|
|
100
|
+
return this.request("POST", "/integrations", input);
|
|
101
|
+
}
|
|
102
|
+
listIntegrations() {
|
|
103
|
+
return this.request("GET", "/integrations");
|
|
104
|
+
}
|
|
105
|
+
getIntegration(id) {
|
|
106
|
+
return this.request("GET", `/integrations/${encodeURIComponent(id)}`);
|
|
107
|
+
}
|
|
108
|
+
updateIntegration(id, patch) {
|
|
109
|
+
return this.request("PATCH", `/integrations/${encodeURIComponent(id)}`, patch);
|
|
110
|
+
}
|
|
111
|
+
deleteIntegration(id) {
|
|
112
|
+
return this.request("DELETE", `/integrations/${encodeURIComponent(id)}`);
|
|
113
|
+
}
|
|
114
|
+
rotateIntegrationKey(id) {
|
|
115
|
+
return this.request("POST", `/integrations/${encodeURIComponent(id)}/rotate-key`);
|
|
116
|
+
}
|
|
117
|
+
// ── sessions (dual-auth) ───────────────────────────────────────────
|
|
118
|
+
createSession(input) {
|
|
119
|
+
return this.request("POST", "/sessions", input);
|
|
120
|
+
}
|
|
121
|
+
listSessions() {
|
|
122
|
+
return this.request("GET", "/sessions");
|
|
123
|
+
}
|
|
124
|
+
getSession(id) {
|
|
125
|
+
return this.request("GET", `/sessions/${encodeURIComponent(id)}`);
|
|
126
|
+
}
|
|
127
|
+
deleteSession(id) {
|
|
128
|
+
return this.request("DELETE", `/sessions/${encodeURIComponent(id)}`);
|
|
129
|
+
}
|
|
130
|
+
sendInput(id, input) {
|
|
131
|
+
return this.request("POST", `/sessions/${encodeURIComponent(id)}/input`, input);
|
|
132
|
+
}
|
|
133
|
+
resizeSession(id, size) {
|
|
134
|
+
return this.request("POST", `/sessions/${encodeURIComponent(id)}/resize`, size);
|
|
135
|
+
}
|
|
136
|
+
getSessionBuffer(id) {
|
|
137
|
+
return this.request("GET", `/sessions/${encodeURIComponent(id)}/buffer`);
|
|
138
|
+
}
|
|
139
|
+
// ── providers / channels (dual-auth) ───────────────────────────────
|
|
140
|
+
listProviders() {
|
|
141
|
+
return this.request("GET", "/providers");
|
|
142
|
+
}
|
|
143
|
+
setProviderConfig(id, config) {
|
|
144
|
+
return this.request(
|
|
145
|
+
"PATCH",
|
|
146
|
+
`/providers/${encodeURIComponent(id)}/config`,
|
|
147
|
+
config
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
listChannels() {
|
|
151
|
+
return this.request("GET", "/channels");
|
|
152
|
+
}
|
|
153
|
+
// ── ws helpers (URLs only — open via subscribeEvents / streamSession) ─
|
|
154
|
+
/**
|
|
155
|
+
* Compose the WS URL for the events stream. Used by `subscribeEvents`,
|
|
156
|
+
* exposed publicly for callers that want to manage the socket lifecycle
|
|
157
|
+
* themselves.
|
|
158
|
+
*/
|
|
159
|
+
eventsUrl(topics) {
|
|
160
|
+
const u = new URL(`${this.baseUrl}/api/v1/integrations/_events`);
|
|
161
|
+
u.protocol = u.protocol === "https:" ? "wss:" : "ws:";
|
|
162
|
+
u.searchParams.set("token", this.token);
|
|
163
|
+
if (topics.length > 0) u.searchParams.set("topics", topics.join(","));
|
|
164
|
+
return u.toString();
|
|
165
|
+
}
|
|
166
|
+
sessionStreamUrl(id) {
|
|
167
|
+
const u = new URL(
|
|
168
|
+
`${this.baseUrl}/api/v1/sessions/${encodeURIComponent(id)}/stream`
|
|
169
|
+
);
|
|
170
|
+
u.protocol = u.protocol === "https:" ? "wss:" : "ws:";
|
|
171
|
+
u.searchParams.set("token", this.token);
|
|
172
|
+
return u.toString();
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// src/events.ts
|
|
177
|
+
async function* subscribeEvents(client, opts) {
|
|
178
|
+
const WS = opts.WebSocket ?? globalThis.WebSocket;
|
|
179
|
+
if (!WS) {
|
|
180
|
+
throw new Error(
|
|
181
|
+
"subscribeEvents: no WebSocket available. On Node <22 import 'ws' and pass it via `WebSocket`."
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
const url = client.eventsUrl(opts.topics);
|
|
185
|
+
const reconnect = opts.reconnect ?? true;
|
|
186
|
+
const baseDelay = opts.reconnectBaseMs ?? 1e3;
|
|
187
|
+
let attempt = 0;
|
|
188
|
+
while (true) {
|
|
189
|
+
if (opts.signal?.aborted) return;
|
|
190
|
+
const queue = [];
|
|
191
|
+
let resolve = null;
|
|
192
|
+
let closed = false;
|
|
193
|
+
let closeReason = null;
|
|
194
|
+
const ws = new WS(url);
|
|
195
|
+
ws.addEventListener("message", (ev) => {
|
|
196
|
+
try {
|
|
197
|
+
const frame = JSON.parse(String(ev.data));
|
|
198
|
+
queue.push(frame);
|
|
199
|
+
if (resolve) {
|
|
200
|
+
const r = resolve;
|
|
201
|
+
resolve = null;
|
|
202
|
+
r();
|
|
203
|
+
}
|
|
204
|
+
} catch (err) {
|
|
205
|
+
closeReason = err instanceof Error ? err : new Error(String(err));
|
|
206
|
+
try {
|
|
207
|
+
ws.close();
|
|
208
|
+
} catch {
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
ws.addEventListener("close", () => {
|
|
213
|
+
closed = true;
|
|
214
|
+
if (resolve) {
|
|
215
|
+
const r = resolve;
|
|
216
|
+
resolve = null;
|
|
217
|
+
r();
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
ws.addEventListener("error", (ev) => {
|
|
221
|
+
closeReason = new Error(`websocket error: ${ev.message ?? "unknown"}`);
|
|
222
|
+
});
|
|
223
|
+
const onAbort = () => {
|
|
224
|
+
try {
|
|
225
|
+
ws.close();
|
|
226
|
+
} catch {
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
opts.signal?.addEventListener("abort", onAbort, { once: true });
|
|
230
|
+
try {
|
|
231
|
+
while (!closed) {
|
|
232
|
+
while (queue.length > 0) {
|
|
233
|
+
const frame = queue.shift();
|
|
234
|
+
yield frame;
|
|
235
|
+
attempt = 0;
|
|
236
|
+
}
|
|
237
|
+
if (closed) break;
|
|
238
|
+
await new Promise((r) => {
|
|
239
|
+
resolve = r;
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
} finally {
|
|
243
|
+
opts.signal?.removeEventListener("abort", onAbort);
|
|
244
|
+
try {
|
|
245
|
+
ws.close();
|
|
246
|
+
} catch {
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (opts.signal?.aborted) return;
|
|
250
|
+
if (closeReason) throw closeReason;
|
|
251
|
+
if (!reconnect) return;
|
|
252
|
+
attempt += 1;
|
|
253
|
+
const delay = Math.min(3e4, baseDelay * 2 ** (attempt - 1));
|
|
254
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// src/session.ts
|
|
259
|
+
function streamSession(client, sessionId, opts = {}) {
|
|
260
|
+
const WS = opts.WebSocket ?? globalThis.WebSocket;
|
|
261
|
+
if (!WS) {
|
|
262
|
+
throw new Error(
|
|
263
|
+
"streamSession: no WebSocket available. On Node <22 import 'ws' and pass it via `WebSocket`."
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
const ws = new WS(client.sessionStreamUrl(sessionId));
|
|
267
|
+
let resolveClosed;
|
|
268
|
+
const closed = new Promise((r) => {
|
|
269
|
+
resolveClosed = r;
|
|
270
|
+
});
|
|
271
|
+
ws.addEventListener("message", (ev) => {
|
|
272
|
+
let frame;
|
|
273
|
+
try {
|
|
274
|
+
frame = JSON.parse(String(ev.data));
|
|
275
|
+
} catch {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
if (frame.kind === "output" && typeof frame.data === "string") {
|
|
279
|
+
opts.onOutput?.(frame.data);
|
|
280
|
+
} else if (frame.kind === "ended") {
|
|
281
|
+
opts.onEnded?.({ exitCode: frame.exit_code, reason: frame.reason });
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
ws.addEventListener("close", () => {
|
|
285
|
+
resolveClosed();
|
|
286
|
+
});
|
|
287
|
+
const onAbort = () => {
|
|
288
|
+
try {
|
|
289
|
+
ws.close();
|
|
290
|
+
} catch {
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
opts.signal?.addEventListener("abort", onAbort, { once: true });
|
|
294
|
+
return {
|
|
295
|
+
send(data) {
|
|
296
|
+
if (ws.readyState !== WS.OPEN) {
|
|
297
|
+
throw new Error("streamSession: socket not open");
|
|
298
|
+
}
|
|
299
|
+
ws.send(JSON.stringify({ kind: "input", data }));
|
|
300
|
+
},
|
|
301
|
+
close() {
|
|
302
|
+
try {
|
|
303
|
+
ws.close();
|
|
304
|
+
} catch {
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
closed
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
311
|
+
0 && (module.exports = {
|
|
312
|
+
Client,
|
|
313
|
+
OpendrayError,
|
|
314
|
+
streamSession,
|
|
315
|
+
subscribeEvents
|
|
316
|
+
});
|
|
317
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/events.ts","../src/session.ts"],"sourcesContent":["export { Client, OpendrayError } from \"./client.js\";\nexport type { ClientOptions } from \"./client.js\";\n\nexport { subscribeEvents } from \"./events.js\";\nexport type { SubscribeOptions } from \"./events.js\";\n\nexport { streamSession } from \"./session.js\";\nexport type { SessionStreamHandle, SessionStreamOptions } from \"./session.js\";\n\nexport type {\n Channel,\n EventFrame,\n Integration,\n IntegrationCreated,\n IntegrationRegistration,\n IntegrationScope,\n IntegrationUpdate,\n Iso8601,\n Provider,\n Session,\n SessionBuffer,\n SessionCreateRequest,\n SessionEndedData,\n SessionIdleData,\n SessionInputRequest,\n SessionOutputData,\n SessionResizeRequest,\n SessionState,\n} from \"./types.js\";\n","import type {\n Channel,\n Integration,\n IntegrationCreated,\n IntegrationRegistration,\n IntegrationUpdate,\n Provider,\n Session,\n SessionBuffer,\n SessionCreateRequest,\n SessionInputRequest,\n SessionResizeRequest,\n} from \"./types.js\";\n\nexport interface ClientOptions {\n /** Base URL of the gateway, e.g. `https://opendray.example.com`. */\n baseUrl: string;\n /** Admin bearer token or integration API key (`odk_live_…`). */\n token: string;\n /** Optional custom fetch (e.g. for proxying or instrumentation). */\n fetch?: typeof fetch;\n /** Default request timeout in ms. 30s if omitted. 0 disables. */\n timeoutMs?: number;\n}\n\nexport class OpendrayError extends Error {\n readonly status: number;\n readonly body: unknown;\n constructor(status: number, body: unknown, message: string) {\n super(message);\n this.name = \"OpendrayError\";\n this.status = status;\n this.body = body;\n }\n}\n\nexport class Client {\n readonly baseUrl: string;\n readonly token: string;\n private readonly fetchImpl: typeof fetch;\n private readonly timeoutMs: number;\n\n constructor(opts: ClientOptions) {\n if (!opts.baseUrl) throw new Error(\"Client: baseUrl is required\");\n if (!opts.token) throw new Error(\"Client: token is required\");\n let trimmed = opts.baseUrl;\n while (trimmed.endsWith(\"/\")) trimmed = trimmed.slice(0, -1);\n this.baseUrl = trimmed;\n this.token = opts.token;\n this.fetchImpl = opts.fetch ?? globalThis.fetch;\n if (!this.fetchImpl) {\n throw new Error(\n \"Client: no fetch available — pass `fetch` in options on platforms older than Node 18.\",\n );\n }\n this.timeoutMs = opts.timeoutMs ?? 30_000;\n }\n\n // ── low level ──────────────────────────────────────────────────────\n\n private async request<T>(\n method: string,\n path: string,\n body?: unknown,\n ): Promise<T> {\n const url = `${this.baseUrl}/api/v1${path}`;\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.token}`,\n Accept: \"application/json\",\n };\n let payload: BodyInit | undefined;\n if (body !== undefined) {\n headers[\"Content-Type\"] = \"application/json\";\n payload = JSON.stringify(body);\n }\n\n const ctrl = this.timeoutMs > 0 ? new AbortController() : null;\n const timer = ctrl\n ? setTimeout(() => ctrl.abort(new Error(\"request timed out\")), this.timeoutMs)\n : null;\n\n const init: RequestInit = { method, headers };\n if (payload !== undefined) init.body = payload;\n if (ctrl) init.signal = ctrl.signal;\n\n try {\n const res = await this.fetchImpl(url, init);\n const text = await res.text();\n let parsed: unknown = undefined;\n if (text.length > 0) {\n try {\n parsed = JSON.parse(text);\n } catch {\n parsed = text;\n }\n }\n if (!res.ok) {\n const msg =\n (parsed && typeof parsed === \"object\" && \"error\" in parsed\n ? String((parsed as { error: unknown }).error)\n : undefined) ?? `${method} ${path} -> ${res.status}`;\n throw new OpendrayError(res.status, parsed, msg);\n }\n return parsed as T;\n } finally {\n if (timer) clearTimeout(timer);\n }\n }\n\n // ── integrations (admin-only) ──────────────────────────────────────\n\n registerIntegration(input: IntegrationRegistration): Promise<IntegrationCreated> {\n return this.request(\"POST\", \"/integrations\", input);\n }\n\n listIntegrations(): Promise<Integration[]> {\n return this.request(\"GET\", \"/integrations\");\n }\n\n getIntegration(id: string): Promise<Integration> {\n return this.request(\"GET\", `/integrations/${encodeURIComponent(id)}`);\n }\n\n updateIntegration(id: string, patch: IntegrationUpdate): Promise<Integration> {\n return this.request(\"PATCH\", `/integrations/${encodeURIComponent(id)}`, patch);\n }\n\n deleteIntegration(id: string): Promise<void> {\n return this.request(\"DELETE\", `/integrations/${encodeURIComponent(id)}`);\n }\n\n rotateIntegrationKey(id: string): Promise<IntegrationCreated> {\n return this.request(\"POST\", `/integrations/${encodeURIComponent(id)}/rotate-key`);\n }\n\n // ── sessions (dual-auth) ───────────────────────────────────────────\n\n createSession(input: SessionCreateRequest): Promise<Session> {\n return this.request(\"POST\", \"/sessions\", input);\n }\n\n listSessions(): Promise<Session[]> {\n return this.request(\"GET\", \"/sessions\");\n }\n\n getSession(id: string): Promise<Session> {\n return this.request(\"GET\", `/sessions/${encodeURIComponent(id)}`);\n }\n\n deleteSession(id: string): Promise<void> {\n return this.request(\"DELETE\", `/sessions/${encodeURIComponent(id)}`);\n }\n\n sendInput(id: string, input: SessionInputRequest): Promise<void> {\n return this.request(\"POST\", `/sessions/${encodeURIComponent(id)}/input`, input);\n }\n\n resizeSession(id: string, size: SessionResizeRequest): Promise<void> {\n return this.request(\"POST\", `/sessions/${encodeURIComponent(id)}/resize`, size);\n }\n\n getSessionBuffer(id: string): Promise<SessionBuffer> {\n return this.request(\"GET\", `/sessions/${encodeURIComponent(id)}/buffer`);\n }\n\n // ── providers / channels (dual-auth) ───────────────────────────────\n\n listProviders(): Promise<Provider[]> {\n return this.request(\"GET\", \"/providers\");\n }\n\n setProviderConfig(id: string, config: Record<string, unknown>): Promise<Provider> {\n return this.request(\n \"PATCH\",\n `/providers/${encodeURIComponent(id)}/config`,\n config,\n );\n }\n\n listChannels(): Promise<Channel[]> {\n return this.request(\"GET\", \"/channels\");\n }\n\n // ── ws helpers (URLs only — open via subscribeEvents / streamSession) ─\n\n /**\n * Compose the WS URL for the events stream. Used by `subscribeEvents`,\n * exposed publicly for callers that want to manage the socket lifecycle\n * themselves.\n */\n eventsUrl(topics: string[]): string {\n const u = new URL(`${this.baseUrl}/api/v1/integrations/_events`);\n u.protocol = u.protocol === \"https:\" ? \"wss:\" : \"ws:\";\n u.searchParams.set(\"token\", this.token);\n if (topics.length > 0) u.searchParams.set(\"topics\", topics.join(\",\"));\n return u.toString();\n }\n\n sessionStreamUrl(id: string): string {\n const u = new URL(\n `${this.baseUrl}/api/v1/sessions/${encodeURIComponent(id)}/stream`,\n );\n u.protocol = u.protocol === \"https:\" ? \"wss:\" : \"ws:\";\n u.searchParams.set(\"token\", this.token);\n return u.toString();\n }\n}\n","import type { Client } from \"./client.js\";\nimport type { EventFrame } from \"./types.js\";\n\nexport interface SubscribeOptions {\n /** Topic patterns. Use `session.*` for prefix wildcards. */\n topics: string[];\n /** AbortSignal closes the socket and ends the iterator. */\n signal?: AbortSignal;\n /**\n * Custom WebSocket implementation. Defaults to globalThis.WebSocket.\n * On Node <22 you'll need to pass `ws`'s default export.\n */\n WebSocket?: typeof globalThis.WebSocket;\n /** Reconnect on unexpected close. Defaults to true. */\n reconnect?: boolean;\n /** Initial backoff in ms (doubles up to 30s). Defaults to 1000. */\n reconnectBaseMs?: number;\n}\n\n/**\n * Returns an async iterable that yields one EventFrame per server message.\n * Reconnects automatically on transient drops; an AbortSignal ends the\n * stream cleanly.\n *\n * ```ts\n * for await (const frame of subscribeEvents(client, { topics: [\"session.*\"] })) {\n * console.log(frame.topic, frame.data);\n * }\n * ```\n */\nexport async function* subscribeEvents<T = unknown>(\n client: Client,\n opts: SubscribeOptions,\n): AsyncGenerator<EventFrame<T>, void, void> {\n const WS = opts.WebSocket ?? globalThis.WebSocket;\n if (!WS) {\n throw new Error(\n \"subscribeEvents: no WebSocket available. On Node <22 import 'ws' and pass it via `WebSocket`.\",\n );\n }\n\n const url = client.eventsUrl(opts.topics);\n const reconnect = opts.reconnect ?? true;\n const baseDelay = opts.reconnectBaseMs ?? 1000;\n let attempt = 0;\n\n while (true) {\n if (opts.signal?.aborted) return;\n const queue: EventFrame<T>[] = [];\n let resolve: (() => void) | null = null;\n let closed = false;\n let closeReason: Error | null = null;\n\n const ws = new WS(url);\n ws.addEventListener(\"message\", (ev: MessageEvent) => {\n try {\n const frame = JSON.parse(String(ev.data)) as EventFrame<T>;\n queue.push(frame);\n if (resolve) {\n const r = resolve;\n resolve = null;\n r();\n }\n } catch (err) {\n closeReason = err instanceof Error ? err : new Error(String(err));\n try {\n ws.close();\n } catch {\n /* ignore */\n }\n }\n });\n ws.addEventListener(\"close\", () => {\n closed = true;\n if (resolve) {\n const r = resolve;\n resolve = null;\n r();\n }\n });\n ws.addEventListener(\"error\", (ev: Event) => {\n closeReason = new Error(`websocket error: ${(ev as ErrorEvent).message ?? \"unknown\"}`);\n });\n\n const onAbort = () => {\n try {\n ws.close();\n } catch {\n /* ignore */\n }\n };\n opts.signal?.addEventListener(\"abort\", onAbort, { once: true });\n\n try {\n while (!closed) {\n while (queue.length > 0) {\n const frame = queue.shift()!;\n yield frame;\n attempt = 0; // reset backoff on successful delivery\n }\n if (closed) break;\n await new Promise<void>((r) => {\n resolve = r;\n });\n }\n } finally {\n opts.signal?.removeEventListener(\"abort\", onAbort);\n try {\n ws.close();\n } catch {\n /* ignore */\n }\n }\n\n if (opts.signal?.aborted) return;\n if (closeReason) throw closeReason;\n if (!reconnect) return;\n\n attempt += 1;\n const delay = Math.min(30_000, baseDelay * 2 ** (attempt - 1));\n await new Promise((r) => setTimeout(r, delay));\n }\n}\n","import type { Client } from \"./client.js\";\n\nexport interface SessionStreamHandle {\n /** Send raw bytes to the session's PTY stdin. */\n send(data: string): void;\n /** Close the stream. */\n close(): void;\n /** Resolves when the socket closes (cleanly or with an error). */\n readonly closed: Promise<void>;\n}\n\nexport interface SessionStreamOptions {\n /** Called with each chunk of terminal output. */\n onOutput?: (data: string) => void;\n /** Called when the server reports the session has ended. */\n onEnded?: (info: { exitCode?: number | undefined; reason?: string | undefined }) => void;\n /** AbortSignal closes the socket. */\n signal?: AbortSignal;\n /**\n * Custom WebSocket implementation. Defaults to globalThis.WebSocket.\n * On Node <22 pass `ws`'s default export.\n */\n WebSocket?: typeof globalThis.WebSocket;\n}\n\n/**\n * Open a bidirectional terminal stream against the given session.\n *\n * The wire format is gateway-specific JSON frames:\n * { kind: \"output\", data: \"<chunk>\" } (server → client)\n * { kind: \"ended\", exit_code?, reason? } (server → client)\n * { kind: \"input\", data: \"<chunk>\" } (client → server)\n *\n * The returned handle exposes `send()` and `close()`, and a `closed`\n * promise that resolves when the socket finishes.\n */\nexport function streamSession(\n client: Client,\n sessionId: string,\n opts: SessionStreamOptions = {},\n): SessionStreamHandle {\n const WS = opts.WebSocket ?? globalThis.WebSocket;\n if (!WS) {\n throw new Error(\n \"streamSession: no WebSocket available. On Node <22 import 'ws' and pass it via `WebSocket`.\",\n );\n }\n\n const ws = new WS(client.sessionStreamUrl(sessionId));\n let resolveClosed!: () => void;\n const closed = new Promise<void>((r) => {\n resolveClosed = r;\n });\n\n ws.addEventListener(\"message\", (ev: MessageEvent) => {\n let frame: { kind?: string; data?: string; exit_code?: number; reason?: string };\n try {\n frame = JSON.parse(String(ev.data));\n } catch {\n return;\n }\n if (frame.kind === \"output\" && typeof frame.data === \"string\") {\n opts.onOutput?.(frame.data);\n } else if (frame.kind === \"ended\") {\n opts.onEnded?.({ exitCode: frame.exit_code, reason: frame.reason });\n }\n });\n ws.addEventListener(\"close\", () => {\n resolveClosed();\n });\n\n const onAbort = () => {\n try {\n ws.close();\n } catch {\n /* ignore */\n }\n };\n opts.signal?.addEventListener(\"abort\", onAbort, { once: true });\n\n return {\n send(data: string) {\n if (ws.readyState !== WS.OPEN) {\n throw new Error(\"streamSession: socket not open\");\n }\n ws.send(JSON.stringify({ kind: \"input\", data }));\n },\n close() {\n try {\n ws.close();\n } catch {\n /* ignore */\n }\n },\n closed,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACyBO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAC9B;AAAA,EACA;AAAA,EACT,YAAY,QAAgB,MAAe,SAAiB;AAC1D,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,SAAN,MAAa;AAAA,EACT;AAAA,EACA;AAAA,EACQ;AAAA,EACA;AAAA,EAEjB,YAAY,MAAqB;AAC/B,QAAI,CAAC,KAAK,QAAS,OAAM,IAAI,MAAM,6BAA6B;AAChE,QAAI,CAAC,KAAK,MAAO,OAAM,IAAI,MAAM,2BAA2B;AAC5D,QAAI,UAAU,KAAK;AACnB,WAAO,QAAQ,SAAS,GAAG,EAAG,WAAU,QAAQ,MAAM,GAAG,EAAE;AAC3D,SAAK,UAAU;AACf,SAAK,QAAQ,KAA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