@openwop/openwop 1.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.
- package/LICENSE +201 -0
- package/README.md +149 -0
- package/dist/client.d.ts +72 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +178 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/run-helpers.d.ts +126 -0
- package/dist/run-helpers.d.ts.map +1 -0
- package/dist/run-helpers.js +182 -0
- package/dist/run-helpers.js.map +1 -0
- package/dist/sse.d.ts +35 -0
- package/dist/sse.d.ts.map +1 -0
- package/dist/sse.js +137 -0
- package/dist/sse.js.map +1 -0
- package/dist/types.d.ts +171 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +57 -0
- package/dist/types.js.map +1 -0
- package/package.json +41 -0
- package/src/client.ts +277 -0
- package/src/index.ts +57 -0
- package/src/run-helpers.ts +235 -0
- package/src/sse.ts +167 -0
- package/src/types.ts +224 -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 Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
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 David Tufts and openwop contributors
|
|
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,149 @@
|
|
|
1
|
+
# `@openwop/openwop` — TypeScript SDK for the Multi-Agent Workflow Orchestration Protocol
|
|
2
|
+
|
|
3
|
+
**openwop is an open, wire-level protocol for multi-agent workflow orchestration** — a single contract for runs in which LLM agents, deterministic tools, sub-workflows, and human reviewers collaborate, with durable suspend / resume, replay, version negotiation, and observability owned by the protocol itself. This package is the reference TypeScript client: typed methods for every spec'd REST endpoint plus an async-iterable SSE consumer, zero runtime deps.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @openwop/openwop
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
> **Spec:** [github.com/openwop/openwop](https://github.com/openwop/openwop) · **Status:** FINAL v1 (2026-04-27) · **Mirrors:** [`api/openapi.yaml`](https://github.com/openwop/openwop/blob/main/api/openapi.yaml)
|
|
10
|
+
|
|
11
|
+
The SDK is hand-authored rather than codegen'd from OpenAPI for two reasons:
|
|
12
|
+
|
|
13
|
+
1. **Idiomatic shape.** OpenAPI codegen produces verbose accessors (`api.runs.runs_create()`, etc.) that are nicer if hand-curated. A v1 reference SDK should set the API style other ecosystems (Python, Go) follow.
|
|
14
|
+
2. **Stays close to the spec.** Each method maps 1:1 to a documented endpoint, and types come from the spec's JSON Schemas (referenced via the OpenAPI doc), not from a generator's intermediate representation.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Quickstart
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { OpenwopClient } from '@openwop/openwop';
|
|
22
|
+
|
|
23
|
+
const client = new OpenwopClient({
|
|
24
|
+
baseUrl: 'https://api.example.com',
|
|
25
|
+
apiKey: 'hk_test_abc123',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Discovery
|
|
29
|
+
const caps = await client.discovery.capabilities();
|
|
30
|
+
console.log(caps.protocolVersion, caps.limits);
|
|
31
|
+
|
|
32
|
+
// Workflows
|
|
33
|
+
const wf = await client.workflows.get('my-workflow-id');
|
|
34
|
+
|
|
35
|
+
// Run lifecycle
|
|
36
|
+
const { runId } = await client.runs.create({
|
|
37
|
+
workflowId: 'my-workflow-id',
|
|
38
|
+
inputs: { foo: 'bar' },
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Poll (or use SSE — see below)
|
|
42
|
+
let snap = await client.runs.get(runId);
|
|
43
|
+
while (snap.status !== 'completed' && snap.status !== 'failed') {
|
|
44
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
45
|
+
snap = await client.runs.get(runId);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Cancel mid-flight
|
|
49
|
+
await client.runs.cancel(runId, { reason: 'user request' });
|
|
50
|
+
|
|
51
|
+
// HITL approval (run-scoped)
|
|
52
|
+
await client.interrupts.resolveByRun(runId, 'gate', { resumeValue: { action: 'accept' } });
|
|
53
|
+
|
|
54
|
+
// Replay / fork
|
|
55
|
+
const fork = await client.runs.fork(runId, { fromSeq: 5, mode: 'branch' });
|
|
56
|
+
|
|
57
|
+
// SSE stream
|
|
58
|
+
for await (const event of client.runs.events(runId, { streamMode: 'updates' })) {
|
|
59
|
+
console.log(event.type, event.payload);
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Quickstart (Node)
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
cd sdk/typescript
|
|
69
|
+
npm install # installs @openwop/openwop deps locally (NOT in parent monorepo)
|
|
70
|
+
npx tsc --noEmit # typecheck the SDK source
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## What's Covered In v1.0
|
|
76
|
+
|
|
77
|
+
| Endpoint | SDK method |
|
|
78
|
+
|---|---|
|
|
79
|
+
| `GET /.well-known/openwop` | `client.discovery.capabilities()` |
|
|
80
|
+
| `GET /v1/openapi.json` | `client.discovery.openapi()` |
|
|
81
|
+
| `GET /v1/workflows/{id}` | `client.workflows.get(id)` |
|
|
82
|
+
| `POST /v1/runs` | `client.runs.create(body, opts?)` |
|
|
83
|
+
| `GET /v1/runs/{id}` | `client.runs.get(id)` |
|
|
84
|
+
| `GET /v1/runs/{id}/events` (SSE) | `client.runs.events(id, opts?)` (async iterable) |
|
|
85
|
+
| `GET /v1/runs/{id}/events/poll` | `client.runs.pollEvents(id, opts?)` |
|
|
86
|
+
| `POST /v1/runs/{id}/cancel` | `client.runs.cancel(id, body?)` |
|
|
87
|
+
| `POST /v1/runs/{id}:fork` | `client.runs.fork(id, body)` |
|
|
88
|
+
| `POST /v1/runs/{id}/interrupts/{nodeId}` | `client.interrupts.resolveByRun(id, nodeId, body)` |
|
|
89
|
+
| `GET /v1/interrupts/{token}` | `client.interrupts.inspectByToken(token)` |
|
|
90
|
+
| `POST /v1/interrupts/{token}` | `client.interrupts.resolveByToken(token, body)` |
|
|
91
|
+
|
|
92
|
+
**Idempotency-Key** is supported via the `idempotencyKey` option on every mutation method.
|
|
93
|
+
|
|
94
|
+
**Typed `RunConfigurable`** — `client.runs.create(...).configurable` is now a typed surface with reserved keys (`recursionLimit`, `model`, `temperature`, `maxTokens`, `promptOverrides`) plus pass-through for impl extensions.
|
|
95
|
+
|
|
96
|
+
## Error Handling
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import { HTTP_ERROR_CODES, isHttpErrorCode, WopError } from '@openwop/openwop';
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
await client.runs.create({ workflowId: 'my-workflow-id' });
|
|
103
|
+
} catch (err) {
|
|
104
|
+
if (err instanceof WopError && isHttpErrorCode(err.envelope?.error)) {
|
|
105
|
+
console.error(err.envelope.error, err.envelope.details);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
`HTTP_ERROR_CODES` is the canonical REST/MCP error-envelope vocabulary (`unauthenticated`, `validation_error`, `run_already_active`, etc.). Contextual fields live under `ErrorEnvelope.details`; for example retry hints are `details.retryAfter`, not a top-level response field. `RUN_ERROR_CODES` is separate and applies to `RunSnapshot.error.code` after a run itself fails.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Not In The v1.0 SDK
|
|
115
|
+
|
|
116
|
+
| Feature | Why |
|
|
117
|
+
|---|---|
|
|
118
|
+
| Webhook subscription helpers | v1 specifies webhook delivery, but the SDK keeps endpoint coverage focused on the run lifecycle and conformance-critical surfaces. |
|
|
119
|
+
| Hosted registry publishing helpers | Node-pack registry publishing needs operator-specific credentials and policy; use direct HTTP until a dedicated package workflow is warranted. |
|
|
120
|
+
| Auto-retry with exponential backoff | Retry policy is application-specific. The SDK exposes structured errors so callers can implement their own retry envelope. |
|
|
121
|
+
| Separate browser entrypoint (`@openwop/openwop/browser`) | The default ESM build uses standard `fetch`/`ReadableStream` primitives and can be bundled by modern tools; a dedicated browser subpath can ship later without changing the v1 surface. |
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Layout
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
sdk/typescript/
|
|
129
|
+
README.md — this file
|
|
130
|
+
package.json — @openwop/openwop package manifest
|
|
131
|
+
tsconfig.json — strict TS, ESM
|
|
132
|
+
src/
|
|
133
|
+
index.ts — public surface (OpenwopClient + types)
|
|
134
|
+
client.ts — OpenwopClient class (auth, request helper)
|
|
135
|
+
types.ts — request/response types mirrored from the OpenAPI spec
|
|
136
|
+
sse.ts — async-iterable SSE consumer
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Versioning
|
|
142
|
+
|
|
143
|
+
This SDK tracks OpenWOP v1. SDK majors match the protocol major; v1.x SDK releases remain forward-compatible with the v1 wire contract. Mismatch behavior is forward-compat tolerant — see `../../version-negotiation.md`. Breaking spec changes will increment the SDK major.
|
|
144
|
+
|
|
145
|
+
## References
|
|
146
|
+
|
|
147
|
+
- Spec corpus: `../../README.md`
|
|
148
|
+
- OpenAPI: `../../api/openapi.yaml` (the SDK mirrors this surface)
|
|
149
|
+
- AsyncAPI: `../../api/asyncapi.yaml` (the SSE consumer follows these channels)
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenwopClient — typed HTTP client for the openwop REST surface.
|
|
3
|
+
*
|
|
4
|
+
* Hand-authored. Each method maps 1:1 to a documented endpoint in
|
|
5
|
+
* ../../api/openapi.yaml. Request/response types live in ./types.ts.
|
|
6
|
+
*
|
|
7
|
+
* Auth: a single bearer-style API key, supplied at construction. See
|
|
8
|
+
* ../../auth.md for credential format.
|
|
9
|
+
*/
|
|
10
|
+
import { type EventsStreamOptions } from './sse.js';
|
|
11
|
+
import { type Capabilities, type CancelRunRequest, type CancelRunResponse, type CreateRunRequest, type CreateRunResponse, type ForkRunRequest, type ForkRunResponse, type InterruptByTokenInspection, type PollEventsResponse, type ResolveInterruptByTokenResponse, type ResolveInterruptRequest, type ResolveInterruptResponse, type RunEventDoc, type RunSnapshot } from './types.js';
|
|
12
|
+
export interface OpenwopClientOptions {
|
|
13
|
+
/** Base URL of the openwop server, e.g., `https://api.example.com`. Trailing slash optional. */
|
|
14
|
+
readonly baseUrl: string;
|
|
15
|
+
/** API key (bearer-style). See auth.md. */
|
|
16
|
+
readonly apiKey: string;
|
|
17
|
+
/** Optional fetch implementation override (test injection). Defaults to global `fetch`. */
|
|
18
|
+
readonly fetch?: typeof fetch;
|
|
19
|
+
/** Default `Accept-Language` to send. Optional. */
|
|
20
|
+
readonly acceptLanguage?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface MutationOptions {
|
|
23
|
+
/** RFC-spec'd Idempotency-Key for at-most-once mutation semantics. */
|
|
24
|
+
readonly idempotencyKey?: string;
|
|
25
|
+
/** Optional X-Dedup hint for cross-host claim coordination on POST /v1/runs. */
|
|
26
|
+
readonly dedup?: 'enforce';
|
|
27
|
+
}
|
|
28
|
+
export declare class OpenwopClient {
|
|
29
|
+
#private;
|
|
30
|
+
constructor(opts: OpenwopClientOptions);
|
|
31
|
+
readonly discovery: {
|
|
32
|
+
capabilities: () => Promise<Capabilities>;
|
|
33
|
+
openapi: () => Promise<unknown>;
|
|
34
|
+
};
|
|
35
|
+
readonly workflows: {
|
|
36
|
+
get: (workflowId: string) => Promise<unknown>;
|
|
37
|
+
};
|
|
38
|
+
readonly runs: {
|
|
39
|
+
create: (body: CreateRunRequest, opts?: MutationOptions) => Promise<CreateRunResponse>;
|
|
40
|
+
get: (runId: string) => Promise<RunSnapshot>;
|
|
41
|
+
cancel: (runId: string, body?: CancelRunRequest, opts?: MutationOptions) => Promise<CancelRunResponse>;
|
|
42
|
+
fork: (runId: string, body: ForkRunRequest, opts?: MutationOptions) => Promise<ForkRunResponse>;
|
|
43
|
+
pollEvents: (runId: string, params?: {
|
|
44
|
+
lastSequence?: number;
|
|
45
|
+
timeoutSeconds?: number;
|
|
46
|
+
}) => Promise<PollEventsResponse>;
|
|
47
|
+
/**
|
|
48
|
+
* Async-iterable SSE consumer. The connection auto-closes when the
|
|
49
|
+
* server closes the stream (terminal run event); break out of the
|
|
50
|
+
* loop or call `signal.abort()` to terminate early.
|
|
51
|
+
*/
|
|
52
|
+
events: (runId: string, opts?: EventsStreamOptions) => AsyncGenerator<RunEventDoc, void, void>;
|
|
53
|
+
};
|
|
54
|
+
readonly interrupts: {
|
|
55
|
+
resolveByRun: (runId: string, nodeId: string, body: ResolveInterruptRequest, opts?: MutationOptions) => Promise<ResolveInterruptResponse>;
|
|
56
|
+
/**
|
|
57
|
+
* Inspect an interrupt via signed token — useful for showing the
|
|
58
|
+
* interrupt's `kind`, `data`, and `resumeSchema` to a downstream
|
|
59
|
+
* UI before the user resolves. Token is the auth, no API key
|
|
60
|
+
* required (signed-token endpoints intentionally bypass bearer
|
|
61
|
+
* auth so external systems can resolve without openwop credentials).
|
|
62
|
+
*/
|
|
63
|
+
inspectByToken: (token: string) => Promise<InterruptByTokenInspection>;
|
|
64
|
+
/**
|
|
65
|
+
* Resolve an interrupt via signed token — used by external
|
|
66
|
+
* systems (calendar webhooks, payment confirmations) that the
|
|
67
|
+
* engine handed a callback URL at suspension time.
|
|
68
|
+
*/
|
|
69
|
+
resolveByToken: (token: string, body: ResolveInterruptRequest, opts?: MutationOptions) => Promise<ResolveInterruptByTokenResponse>;
|
|
70
|
+
};
|
|
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gBAAgB,SAAQ,eAAe,KAAQ,OAAO,CAAC,iBAAiB,CAAC;qBAQ3E,MAAM,KAAG,OAAO,CAAC,WAAW,CAAC;wBAOjC,MAAM,SACP,gBAAgB,SAChB,eAAe,KACpB,OAAO,CAAC,iBAAiB,CAAC;sBASpB,MAAM,QACP,cAAc,SACd,eAAe,KACpB,OAAO,CAAC,eAAe,CAAC;4BASlB,MAAM,WACL;YAAE,YAAY,CAAC,EAAE,MAAM,CAAC;YAAC,cAAc,CAAC,EAAE,MAAM,CAAA;SAAE,KACzD,OAAO,CAAC,kBAAkB,CAAC;QAe9B;;;;WAIG;wBACa,MAAM,SAAQ,mBAAmB,KAAQ,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC;MAEhG;IAGF,QAAQ,CAAC,UAAU;8BAER,MAAM,UACL,MAAM,QACR,uBAAuB,SACvB,eAAe,KACpB,OAAO,CAAC,wBAAwB,CAAC;QAQpC;;;;;;WAMG;gCACqB,MAAM,KAAG,OAAO,CAAC,0BAA0B,CAAC;QASpE;;;;WAIG;gCAEM,MAAM,QACP,uBAAuB,SACvB,eAAe,KACpB,OAAO,CAAC,+BAA+B,CAAC;MAU3C;CAsEH"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenwopClient — typed HTTP client for the openwop REST surface.
|
|
3
|
+
*
|
|
4
|
+
* Hand-authored. Each method maps 1:1 to a documented endpoint in
|
|
5
|
+
* ../../api/openapi.yaml. Request/response types live in ./types.ts.
|
|
6
|
+
*
|
|
7
|
+
* Auth: a single bearer-style API key, supplied at construction. See
|
|
8
|
+
* ../../auth.md for credential format.
|
|
9
|
+
*/
|
|
10
|
+
import { streamEvents } from './sse.js';
|
|
11
|
+
import { WopError, } from './types.js';
|
|
12
|
+
export class OpenwopClient {
|
|
13
|
+
#baseUrl;
|
|
14
|
+
#apiKey;
|
|
15
|
+
#fetch;
|
|
16
|
+
#acceptLanguage;
|
|
17
|
+
constructor(opts) {
|
|
18
|
+
if (!opts.baseUrl)
|
|
19
|
+
throw new TypeError('OpenwopClient: baseUrl is required');
|
|
20
|
+
if (!opts.apiKey)
|
|
21
|
+
throw new TypeError('OpenwopClient: apiKey is required');
|
|
22
|
+
this.#baseUrl = opts.baseUrl.replace(/\/$/, '');
|
|
23
|
+
this.#apiKey = opts.apiKey;
|
|
24
|
+
this.#fetch = opts.fetch ?? fetch;
|
|
25
|
+
this.#acceptLanguage = opts.acceptLanguage;
|
|
26
|
+
}
|
|
27
|
+
// ── Discovery ────────────────────────────────────────────────────────
|
|
28
|
+
discovery = {
|
|
29
|
+
capabilities: () => this.#request({ method: 'GET', path: '/.well-known/openwop' }, false),
|
|
30
|
+
openapi: () => this.#request({ method: 'GET', path: '/v1/openapi.json' }, false),
|
|
31
|
+
};
|
|
32
|
+
// ── Workflows ────────────────────────────────────────────────────────
|
|
33
|
+
workflows = {
|
|
34
|
+
get: (workflowId) => this.#request({
|
|
35
|
+
method: 'GET',
|
|
36
|
+
path: `/v1/workflows/${encodeURIComponent(workflowId)}`,
|
|
37
|
+
}),
|
|
38
|
+
};
|
|
39
|
+
// ── Runs ─────────────────────────────────────────────────────────────
|
|
40
|
+
runs = {
|
|
41
|
+
create: (body, opts = {}) => this.#request({
|
|
42
|
+
method: 'POST',
|
|
43
|
+
path: '/v1/runs',
|
|
44
|
+
body,
|
|
45
|
+
headers: this.#mutationHeaders(opts),
|
|
46
|
+
}),
|
|
47
|
+
get: (runId) => this.#request({
|
|
48
|
+
method: 'GET',
|
|
49
|
+
path: `/v1/runs/${encodeURIComponent(runId)}`,
|
|
50
|
+
}),
|
|
51
|
+
cancel: (runId, body = {}, opts = {}) => this.#request({
|
|
52
|
+
method: 'POST',
|
|
53
|
+
path: `/v1/runs/${encodeURIComponent(runId)}/cancel`,
|
|
54
|
+
body,
|
|
55
|
+
headers: this.#mutationHeaders(opts),
|
|
56
|
+
}),
|
|
57
|
+
fork: (runId, body, opts = {}) => this.#request({
|
|
58
|
+
method: 'POST',
|
|
59
|
+
path: `/v1/runs/${encodeURIComponent(runId)}:fork`,
|
|
60
|
+
body,
|
|
61
|
+
headers: this.#mutationHeaders(opts),
|
|
62
|
+
}),
|
|
63
|
+
pollEvents: (runId, params = {}) => {
|
|
64
|
+
const search = new URLSearchParams();
|
|
65
|
+
if (params.lastSequence !== undefined) {
|
|
66
|
+
search.set('lastSequence', String(params.lastSequence));
|
|
67
|
+
}
|
|
68
|
+
if (params.timeoutSeconds !== undefined) {
|
|
69
|
+
search.set('timeout', String(params.timeoutSeconds));
|
|
70
|
+
}
|
|
71
|
+
const qs = search.toString();
|
|
72
|
+
return this.#request({
|
|
73
|
+
method: 'GET',
|
|
74
|
+
path: `/v1/runs/${encodeURIComponent(runId)}/events/poll${qs ? `?${qs}` : ''}`,
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
/**
|
|
78
|
+
* Async-iterable SSE consumer. The connection auto-closes when the
|
|
79
|
+
* server closes the stream (terminal run event); break out of the
|
|
80
|
+
* loop or call `signal.abort()` to terminate early.
|
|
81
|
+
*/
|
|
82
|
+
events: (runId, opts = {}) => streamEvents({ baseUrl: this.#baseUrl, apiKey: this.#apiKey }, runId, opts),
|
|
83
|
+
};
|
|
84
|
+
// ── HITL interrupts (run-scoped + signed-token) ──────────────────────
|
|
85
|
+
interrupts = {
|
|
86
|
+
resolveByRun: (runId, nodeId, body, opts = {}) => this.#request({
|
|
87
|
+
method: 'POST',
|
|
88
|
+
path: `/v1/runs/${encodeURIComponent(runId)}/interrupts/${encodeURIComponent(nodeId)}`,
|
|
89
|
+
body,
|
|
90
|
+
headers: this.#mutationHeaders(opts),
|
|
91
|
+
}),
|
|
92
|
+
/**
|
|
93
|
+
* Inspect an interrupt via signed token — useful for showing the
|
|
94
|
+
* interrupt's `kind`, `data`, and `resumeSchema` to a downstream
|
|
95
|
+
* UI before the user resolves. Token is the auth, no API key
|
|
96
|
+
* required (signed-token endpoints intentionally bypass bearer
|
|
97
|
+
* auth so external systems can resolve without openwop credentials).
|
|
98
|
+
*/
|
|
99
|
+
inspectByToken: (token) => this.#request({
|
|
100
|
+
method: 'GET',
|
|
101
|
+
path: `/v1/interrupts/${encodeURIComponent(token)}`,
|
|
102
|
+
}, false),
|
|
103
|
+
/**
|
|
104
|
+
* Resolve an interrupt via signed token — used by external
|
|
105
|
+
* systems (calendar webhooks, payment confirmations) that the
|
|
106
|
+
* engine handed a callback URL at suspension time.
|
|
107
|
+
*/
|
|
108
|
+
resolveByToken: (token, body, opts = {}) => this.#request({
|
|
109
|
+
method: 'POST',
|
|
110
|
+
path: `/v1/interrupts/${encodeURIComponent(token)}`,
|
|
111
|
+
body,
|
|
112
|
+
headers: this.#mutationHeaders(opts),
|
|
113
|
+
}, false),
|
|
114
|
+
};
|
|
115
|
+
// ── Internals ────────────────────────────────────────────────────────
|
|
116
|
+
#mutationHeaders(opts) {
|
|
117
|
+
const h = {};
|
|
118
|
+
if (opts.idempotencyKey)
|
|
119
|
+
h['Idempotency-Key'] = opts.idempotencyKey;
|
|
120
|
+
if (opts.dedup)
|
|
121
|
+
h['X-Dedup'] = opts.dedup;
|
|
122
|
+
return h;
|
|
123
|
+
}
|
|
124
|
+
async #request(opts, authenticated = true) {
|
|
125
|
+
const url = `${this.#baseUrl}${opts.path}`;
|
|
126
|
+
const headers = {
|
|
127
|
+
Accept: 'application/json',
|
|
128
|
+
...(opts.headers ?? {}),
|
|
129
|
+
};
|
|
130
|
+
if (opts.body !== undefined && headers['Content-Type'] === undefined) {
|
|
131
|
+
headers['Content-Type'] = 'application/json';
|
|
132
|
+
}
|
|
133
|
+
if (authenticated) {
|
|
134
|
+
headers.Authorization = `Bearer ${this.#apiKey}`;
|
|
135
|
+
}
|
|
136
|
+
if (this.#acceptLanguage) {
|
|
137
|
+
headers['Accept-Language'] = this.#acceptLanguage;
|
|
138
|
+
}
|
|
139
|
+
const init = { method: opts.method, headers };
|
|
140
|
+
if (opts.body !== undefined) {
|
|
141
|
+
init.body = JSON.stringify(opts.body);
|
|
142
|
+
}
|
|
143
|
+
if (opts.signal) {
|
|
144
|
+
init.signal = opts.signal;
|
|
145
|
+
}
|
|
146
|
+
const res = await this.#fetch(url, init);
|
|
147
|
+
const text = await res.text();
|
|
148
|
+
// Capture traceparent for error reporting per observability.md
|
|
149
|
+
// §Trace context propagation. Header name is case-insensitive per
|
|
150
|
+
// RFC 9110; fetch normalizes to lowercase but be defensive.
|
|
151
|
+
const traceparent = res.headers.get('traceparent') ?? res.headers.get('Traceparent') ?? undefined;
|
|
152
|
+
if (!res.ok) {
|
|
153
|
+
let env;
|
|
154
|
+
try {
|
|
155
|
+
const parsed = text.length > 0 ? JSON.parse(text) : undefined;
|
|
156
|
+
if (parsed && typeof parsed === 'object' && 'error' in parsed && 'message' in parsed) {
|
|
157
|
+
env = parsed;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
// not JSON; leave envelope undefined
|
|
162
|
+
}
|
|
163
|
+
throw new WopError(res.status, text, env, traceparent);
|
|
164
|
+
}
|
|
165
|
+
if (text.length === 0)
|
|
166
|
+
return undefined;
|
|
167
|
+
try {
|
|
168
|
+
return JSON.parse(text);
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
throw new WopError(res.status, text, {
|
|
172
|
+
error: 'invalid_json',
|
|
173
|
+
message: 'Server returned non-JSON body for a 2xx response',
|
|
174
|
+
}, traceparent);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAA4B,MAAM,UAAU,CAAC;AAClE,OAAO,EACL,QAAQ,GAgBT,MAAM,YAAY,CAAC;AA4BpB,MAAM,OAAO,aAAa;IACf,QAAQ,CAAS;IACj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I,QAAQ,CAChB,GAAG,CAAC,MAAM,EACV,IAAI,EACJ;gBACE,KAAK,EAAE,cAAc;gBACrB,OAAO,EAAE,kDAAkD;aAC5D,EACD,WAAW,CACZ,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @openwop/openwop — TypeScript reference SDK for OpenWOP-compliant servers.
|
|
3
|
+
*
|
|
4
|
+
* Public surface:
|
|
5
|
+
* - OpenwopClient (auth + endpoint methods)
|
|
6
|
+
* - WopError (typed error wrapping ErrorEnvelope)
|
|
7
|
+
* - All request/response types mirroring the OpenAPI spec
|
|
8
|
+
* - streamEvents helper for advanced SSE use cases
|
|
9
|
+
*
|
|
10
|
+
* See README.md for usage examples.
|
|
11
|
+
*/
|
|
12
|
+
export { OpenwopClient } from './client.js';
|
|
13
|
+
export type { OpenwopClientOptions, MutationOptions } from './client.js';
|
|
14
|
+
export { WopError } from './types.js';
|
|
15
|
+
export type { Capabilities, CancelRunRequest, CancelRunResponse, CreateRunRequest, CreateRunResponse, ErrorEnvelope, ForkRunRequest, ForkRunResponse, InterruptByTokenInspection, PollEventsResponse, ResolveInterruptByTokenResponse, ResolveInterruptRequest, ResolveInterruptResponse, RunConfigurable, RunEventDoc, RunSnapshot, RunStatus, StreamMode, } from './types.js';
|
|
16
|
+
export { streamEvents } from './sse.js';
|
|
17
|
+
export type { EventsStreamContext, EventsStreamOptions } from './sse.js';
|
|
18
|
+
export { ACTIVE_RUN_STATUSES, TERMINAL_RUN_STATUSES, isTerminalRunStatus, HTTP_ERROR_CODES, isHttpErrorCode, RUN_ERROR_CODES, isRunErrorCode, } from './run-helpers.js';
|
|
19
|
+
export type { ActiveRunStatus, TerminalRunStatus, HttpErrorCode, RunErrorCode, RunError, } from './run-helpers.js';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,eAAe,EACf,0BAA0B,EAC1B,kBAAkB,EAClB,+BAA+B,EAC/B,uBAAuB,EACvB,wBAAwB,EACxB,eAAe,EACf,WAAW,EACX,WAAW,EACX,SAAS,EACT,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAKzE,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,QAAQ,GACT,MAAM,kBAAkB,CAAC"}
|