@convilyn/sdk 0.2.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/CHANGELOG.md +137 -0
- package/LICENSE +201 -0
- package/README.md +282 -0
- package/dist/chunk-UJHZKIP6.js +1650 -0
- package/dist/chunk-UJHZKIP6.js.map +1 -0
- package/dist/cli.cjs +2667 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.js +1019 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +1678 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +893 -0
- package/dist/index.d.ts +893 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/package.json +78 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@convilyn/sdk` are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/); this package adheres to
|
|
5
|
+
[Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.2.0] — 2026-07-09
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- **`goals.start({ llmConfigId })` / `goals.run({ llmConfigId })`** — optionally
|
|
14
|
+
pin a goal run to one of your stored BYO-LLM provider configs (created in the
|
|
15
|
+
console) so it runs on your own provider/key. Omit it to use your account
|
|
16
|
+
default. Serialised as `llmConfigId`; honoured only when BYO-LLM is enabled for
|
|
17
|
+
your account, otherwise the run uses the platform provider (parity with the
|
|
18
|
+
Python `convilyn` SDK).
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- **Default base URL corrected to `https://api.convilyn.corenovus.com`**
|
|
23
|
+
(was the non-serving `api.convilyn.com`), matching the Python consumer SDK.
|
|
24
|
+
Zero-config clients now reach the live API.
|
|
25
|
+
- **`goals.events()` failure now points at `wait()` polling.** The platform
|
|
26
|
+
does not accept `ck_` keys on the WebSocket event stream in v1, so a connect
|
|
27
|
+
failure's `WebSocketError` message and the method docstring now spell out
|
|
28
|
+
that WebSocket streaming is polling-only for now (use `wait()`), mirroring
|
|
29
|
+
the Go consumer SDK's guidance.
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
|
|
33
|
+
- **README licence corrected to Apache-2.0** (it claimed MIT; the shipped
|
|
34
|
+
`LICENSE` file, `package.json`, and the Python SDKs are all Apache-2.0).
|
|
35
|
+
`publishConfig.access: public` is now pinned in `package.json` so a manual
|
|
36
|
+
publish of this scoped package cannot accidentally target restricted access.
|
|
37
|
+
- **`convilyn doctor` no longer fails on runtimes without a global
|
|
38
|
+
`WebSocket`** (Node 18/20 — it is global only from Node 22). The capability
|
|
39
|
+
is optional: only `goals.events()` streaming needs it, and `goals.wait()`
|
|
40
|
+
polling covers the same ground, so the check now reports an advisory WARN
|
|
41
|
+
instead of failing the whole diagnostic with exit 1.
|
|
42
|
+
- **`goals.start` reshapes seeded `slots` to `slotAnswers` on the create wire.**
|
|
43
|
+
The create endpoint (`CreateGoalJobRequest`) keys pre-seeded answers as
|
|
44
|
+
`slotAnswers: [{slotId, value}]`; the SDK sent the raw `{slotId: value}` dict
|
|
45
|
+
under `slots`, which the backend silently dropped — a seeded slot answer never
|
|
46
|
+
reached the job. `start({ slots })` now maps to the `slotAnswers` list (public
|
|
47
|
+
`slots` param unchanged). Mirrors the same fix in the Python SDK (`slots` →
|
|
48
|
+
`slotAnswers`).
|
|
49
|
+
- **`convert.create` sends the snake_case `processor_type` discriminator.**
|
|
50
|
+
The conversion `JobRequest` discriminated union keys on `processor_type` per
|
|
51
|
+
the contract (`processorType` is only the *response* field name); the prior
|
|
52
|
+
camelCase request key was rejected by the backend with HTTP 400
|
|
53
|
+
`union_tag_not_found`, breaking every conversion. Conversions now succeed
|
|
54
|
+
against the current backend. Mirrors the same fix in the Python SDK.
|
|
55
|
+
|
|
56
|
+
### Removed
|
|
57
|
+
|
|
58
|
+
- **BREAKING: `GoalJob.workflowId`** — the backend's `GoalJobResponse` never
|
|
59
|
+
echoes `workflowId` (the *request* accepts it; the response does not), so the
|
|
60
|
+
property was always `null` at runtime. Removed pre-first-publish, so no
|
|
61
|
+
released consumer is affected. `goals.start({ workflowId })` /
|
|
62
|
+
`run({ workflowId })` and the `Workflow` / `WorkflowSummary` types are
|
|
63
|
+
unchanged. `GoalJob` is now conformance-mapped, so any future field the wire
|
|
64
|
+
doesn't speak fails CI instead of shipping silently.
|
|
65
|
+
|
|
66
|
+
### Security
|
|
67
|
+
|
|
68
|
+
- **https-only external presign URLs.** `externalGet` / `externalPut` now
|
|
69
|
+
refuse any backend-supplied URL whose scheme is not `https` (downgrade /
|
|
70
|
+
`file://` / unparseable → throw before any fetch), mirroring the Python
|
|
71
|
+
`_require_https` guard (internal `requireHttps`; not part of the public
|
|
72
|
+
barrel).
|
|
73
|
+
- **Symlink refusal on `convert.downloadTo`.** Writing *through* a
|
|
74
|
+
pre-existing symlink target now throws; overwriting a regular file is
|
|
75
|
+
unchanged (parity with the Python `download_to` guard).
|
|
76
|
+
|
|
77
|
+
## [0.1.0] — 2026-06-27
|
|
78
|
+
|
|
79
|
+
### Added
|
|
80
|
+
|
|
81
|
+
- Initial scaffold of the TypeScript consumer SDK (port of the Python
|
|
82
|
+
`convilyn` SDK).
|
|
83
|
+
- Core transport seams: `AuthStrategy` + `ApiKey` + `resolveAuth`
|
|
84
|
+
(`CONVILYN_API_KEY`), `RetryPolicy` + `ExponentialBackoffRetry` + `NoRetry`,
|
|
85
|
+
and the `HttpClient` (fetch-based, retry loop + auto `Idempotency-Key` on
|
|
86
|
+
mutating verbs + typed error decoding + presigned-URL helpers).
|
|
87
|
+
- The full typed-error hierarchy (`ConvilynError` → `AuthError` / `APIError` →
|
|
88
|
+
`RateLimitError` / `PlanRequiredError` / `QuotaExceededError` / `S3UploadError`
|
|
89
|
+
/ `RetryExhaustedError`; `JobFailedError` / `JobTimeoutError` /
|
|
90
|
+
`GoalJobFailedError` / `GoalJobTimeoutError` / `WebSocketError`).
|
|
91
|
+
- The wire/domain type interfaces (`File`, `ConvertJob`, `GoalJob`, `GoalEvent`,
|
|
92
|
+
`Workflow*`, `CostEstimate`, …).
|
|
93
|
+
- The `files` resource (`upload`: presign → upload PUT → confirm; path or raw
|
|
94
|
+
bytes, MIME auto-detection) and the `convert` resource (`create` / `retrieve` /
|
|
95
|
+
`wait` / `createAndWait` / `downloadUrl` / `downloadTo`, with poll-backoff and
|
|
96
|
+
`JobFailedError` / `JobTimeoutError`).
|
|
97
|
+
- The `Convilyn` client exposing all five resources: `files`, `convert`,
|
|
98
|
+
`goals`, `workflows`, `account`.
|
|
99
|
+
- The `goals` resource (agentic workflow runs): `start` / `retrieve` / `wait`
|
|
100
|
+
(terminal + HITL stop) / `run` / `fillSlot` / `fillSlots` / `confirm` /
|
|
101
|
+
`cancel` / `retry`, plus `events()` — an `AsyncIterableIterator<GoalEvent>`
|
|
102
|
+
over a WebSocket, with the `WSTransport` DIP seam, `GoalJobFailedError` /
|
|
103
|
+
`GoalJobTimeoutError`, and strict envelope validation.
|
|
104
|
+
- The `workflows` resource (`search` / `get` / `fork` / `publish` / `patch` /
|
|
105
|
+
`like`) and the `account` resource (`getQuota` / `getPlan` / `usageHistory`).
|
|
106
|
+
Cost-preview amounts are exposed in **credits** (the µU wire is converted at
|
|
107
|
+
10,000 µU = 1 credit).
|
|
108
|
+
- The `convilyn` CLI (commander) — `convert`, `goals` (start/status/events/
|
|
109
|
+
fill-slot/confirm/cancel/retry), `account` (plan/quota), `api` (gh-style
|
|
110
|
+
escape hatch), and `doctor`. `--json` for machine output, `--dry-run` where
|
|
111
|
+
applicable, and pinned exit codes (0 ok / 1 usage / 2 api / 3 job-failed /
|
|
112
|
+
130 sigint) via the `OutputRenderer` seam.
|
|
113
|
+
- Release tooling: the npm publish workflow (provenance via OIDC, tag-gated),
|
|
114
|
+
the shared SDK black-box blacklist lint extended over the TS surface, npm
|
|
115
|
+
Dependabot tracking, and packaging guards (version↔CHANGELOG lockstep +
|
|
116
|
+
public-surface importability).
|
|
117
|
+
- Opt-in auto-throttle: `AutoThrottleConfig` + the `autoThrottle` client option
|
|
118
|
+
sleep + re-issue on a 402 `QUOTA_EXCEEDED` envelope (waiting for the quota
|
|
119
|
+
window, distinct from the transient-failure retry policy), and a
|
|
120
|
+
`X-Quota-State: soft_limit` signal is surfaced via `process.emitWarning`
|
|
121
|
+
(parity with the Python SDK's throttle module).
|
|
122
|
+
- Consumer/Author key boundary: only the `ck_` consumer key is accepted. An
|
|
123
|
+
Author-SDK / deploy token now raises a guiding `AuthError` instead of
|
|
124
|
+
producing an opaque 401; unknown prefixes are still accepted for
|
|
125
|
+
forward-compat.
|
|
126
|
+
|
|
127
|
+
### Changed
|
|
128
|
+
|
|
129
|
+
- The public resilience + transport contracts (`RetryPolicy` /
|
|
130
|
+
`ExponentialBackoffRetry` / `NoRetry`, and the `WSTransport` seam) now live in
|
|
131
|
+
public modules (`src/retry.ts`, `src/transport.ts`) — no published contract is
|
|
132
|
+
re-exported from `internal/`. A strengthened packaging guard pins the exact
|
|
133
|
+
public runtime surface, scans for internal/Author-token leaks, and asserts the
|
|
134
|
+
`package.json` `exports` map exposes only the root entry.
|
|
135
|
+
- Rewrote the README into a complete guide (auth, all five resources, error
|
|
136
|
+
handling, retry/timeout/auto-throttle, WebSocket events, CLI) with a "Public
|
|
137
|
+
API & Stability" section codifying the SemVer surface.
|
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 accept (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 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 CoreNovus 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
|
|
201
|
+
permissions and limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/CoreNovus/convilyn-js/main/docs/assets/corenovus-community-banner.png" alt="CoreNovus Community — Connected AI Workflows" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# @convilyn/sdk
|
|
6
|
+
|
|
7
|
+
[](https://github.com/CoreNovus/convilyn-js/actions/workflows/ci.yml)
|
|
8
|
+
|
|
9
|
+
Official Convilyn client SDK for TypeScript / JavaScript — file conversion,
|
|
10
|
+
agentic goal workflows, and a community library for reusable AI workflows. A
|
|
11
|
+
faithful port of the Python `convilyn` SDK: same wire contract, idiomatic async
|
|
12
|
+
TypeScript surface. Ships ESM + CJS + type declarations, with a `convilyn` CLI.
|
|
13
|
+
|
|
14
|
+
Convilyn helps people turn repeated AI-assisted work into workflows that can be
|
|
15
|
+
run again, shared, and improved. It is part of the CoreNovus vision for
|
|
16
|
+
practical AI workflows across cloud services, local machines, AI PCs, edge
|
|
17
|
+
devices, and future IoT environments.
|
|
18
|
+
|
|
19
|
+
> **Public mirror** of Convilyn's monorepo (the source of truth). Contributions
|
|
20
|
+
> are welcome and land in the shipped package — see
|
|
21
|
+
> **[CONTRIBUTING.md](CONTRIBUTING.md)** (fork → PR → upstreamed, authorship
|
|
22
|
+
> preserved).
|
|
23
|
+
|
|
24
|
+
## What is Convilyn?
|
|
25
|
+
|
|
26
|
+
Convilyn is an open source SDK for building with free file conversion tools and
|
|
27
|
+
practical AI workflow capabilities. Its main value is helping people use the
|
|
28
|
+
computing resources they already have — local machines, AI PCs, and edge
|
|
29
|
+
devices — to run practical AI workflows without depending entirely on paid
|
|
30
|
+
cloud services.
|
|
31
|
+
|
|
32
|
+
## Who is this for?
|
|
33
|
+
|
|
34
|
+
- Developers building reusable AI workflow components
|
|
35
|
+
- People working with file conversion and automation
|
|
36
|
+
- Builders experimenting with local-first AI workflows
|
|
37
|
+
- Communities that want open, practical AI tooling
|
|
38
|
+
- Contributors who want to help make AI workflows easier to use and share
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm install @convilyn/sdk # or: pnpm add @convilyn/sdk / yarn add @convilyn/sdk
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Requires **Node 18+** (uses the global `fetch`) or any modern browser bundler. The
|
|
47
|
+
only runtime dependency is `commander` (for the CLI).
|
|
48
|
+
|
|
49
|
+
## Authentication
|
|
50
|
+
|
|
51
|
+
The SDK authenticates with a **consumer API key** — it starts with `ck_`. Mint one
|
|
52
|
+
in the Convilyn web app under **Settings → API**.
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
import { Convilyn } from '@convilyn/sdk'
|
|
56
|
+
|
|
57
|
+
// Explicit:
|
|
58
|
+
const client = new Convilyn({ apiKey: 'ck_…' }) // pragma: allowlist secret
|
|
59
|
+
|
|
60
|
+
// Or omit it and the SDK reads the CONVILYN_API_KEY environment variable:
|
|
61
|
+
const client = new Convilyn()
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
> `ck_` is the **only** consumer key. `cvl_` / `cvi_` are *Author SDK* / deploy
|
|
65
|
+
> tokens (for publishing workflows and tools) — passing one here throws an
|
|
66
|
+
> `AuthError` pointing you to the right key.
|
|
67
|
+
|
|
68
|
+
## Quickstart
|
|
69
|
+
|
|
70
|
+
Convert a local document to PDF:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { Convilyn } from '@convilyn/sdk'
|
|
74
|
+
|
|
75
|
+
const client = new Convilyn({ apiKey: process.env.CONVILYN_API_KEY })
|
|
76
|
+
|
|
77
|
+
const file = await client.files.upload({ path: 'report.docx' })
|
|
78
|
+
const job = await client.convert.createAndWait({ file, targetFormat: 'pdf' })
|
|
79
|
+
await client.convert.downloadTo(job, { to: 'report.pdf' })
|
|
80
|
+
|
|
81
|
+
await client.close()
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Run an agentic goal workflow and wait for the result:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
const result = await client.goals.run({
|
|
88
|
+
workflowId: 'wf_grade_sheet',
|
|
89
|
+
files: [file.fileId],
|
|
90
|
+
})
|
|
91
|
+
console.log(result.status) // 'completed' | 'partial' | 'failed' | 'slots_pending' | …
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Resources
|
|
95
|
+
|
|
96
|
+
The client exposes five resources: `files`, `convert`, `goals`, `workflows`,
|
|
97
|
+
`account`.
|
|
98
|
+
|
|
99
|
+
### `files` — upload
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
const fromPath = await client.files.upload({ path: 'a.pdf' }) // Node
|
|
103
|
+
const fromBytes = await client.files.upload({ content: bytes, filename: 'a.pdf' }) // browser-safe
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### `convert` — document conversion
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
const job = await client.convert.create({ file, targetFormat: 'pdf' })
|
|
110
|
+
const done = await client.convert.wait(job.jobId) // poll to terminal
|
|
111
|
+
const url = await client.convert.downloadUrl(done) // presigned URL
|
|
112
|
+
await client.convert.downloadTo(done, { to: 'out.pdf' }) // Node: stream to disk
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`createAndWait` is the `create` + `wait` shortcut. A `failed` job throws
|
|
116
|
+
`JobFailedError`; an elapsed deadline throws `JobTimeoutError`.
|
|
117
|
+
|
|
118
|
+
### `goals` — agentic goal workflows
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
const job = await client.goals.start({ goalText: 'Summarise this', files: [file.fileId] })
|
|
122
|
+
const state = await client.goals.wait(job.jobSpecId) // stops at terminal OR a HITL slot
|
|
123
|
+
|
|
124
|
+
if (state.status === 'slots_pending') {
|
|
125
|
+
await client.goals.fillSlot(state.jobSpecId, { slotId: state.pendingSlots[0]!.slotId, value: 'A1' })
|
|
126
|
+
await client.goals.confirm(state.jobSpecId)
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Other methods: `retrieve`, `run` (`start` + `wait`), `fillSlots`, `cancel`,
|
|
131
|
+
`retry`, and `events()` (see [WebSocket events](#websocket-events) below).
|
|
132
|
+
|
|
133
|
+
### `workflows` — community marketplace
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
const page = await client.workflows.search({ tag: 'finance', sort: 'popular' })
|
|
137
|
+
const wf = await client.workflows.get(page.items[0]!.workflowId)
|
|
138
|
+
const mine = await client.workflows.fork({ sourceSpecId: wf.specId, name: 'My copy' }) // Pro
|
|
139
|
+
await client.workflows.publish(mine.workflowId, { itemVersion: mine.itemVersion }) // Pro
|
|
140
|
+
await client.workflows.like(wf.workflowId)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### `account` — plan, cost preview & usage (read-only)
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
const plan = await client.account.getPlan() // { tier: 'free' | 'pro' }
|
|
147
|
+
const estimate = await client.account.getQuota({ tools: ['pdf-mcp:extract_text'] })
|
|
148
|
+
console.log(estimate.estimatedCredits, estimate.quotaCheck.state)
|
|
149
|
+
const history = await client.account.usageHistory({ since: new Date('2026-06-01') })
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Money is always expressed in **credits** (1 credit = $0.01) — never internal
|
|
153
|
+
micro-units.
|
|
154
|
+
|
|
155
|
+
## Error handling
|
|
156
|
+
|
|
157
|
+
Every SDK failure is a subclass of `ConvilynError`; branch on `code` / `statusCode`
|
|
158
|
+
for typed handling.
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
import { ConvilynError, QuotaExceededError, RateLimitError, PlanRequiredError } from '@convilyn/sdk'
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
await client.goals.run({ goalText: '…', files: [file.fileId] })
|
|
165
|
+
} catch (err) {
|
|
166
|
+
if (err instanceof QuotaExceededError) {
|
|
167
|
+
console.error(`Need ${err.costCredits} credits, have ${err.balanceCredits}. Top up: ${err.topUpUrl}`)
|
|
168
|
+
} else if (err instanceof PlanRequiredError) {
|
|
169
|
+
console.error(`Upgrade required: ${err.upgradeUrl}`)
|
|
170
|
+
} else if (err instanceof RateLimitError) {
|
|
171
|
+
console.error('Rate limited — back off and retry.')
|
|
172
|
+
} else if (err instanceof ConvilynError) {
|
|
173
|
+
console.error('SDK error:', err.message)
|
|
174
|
+
} else {
|
|
175
|
+
throw err
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
The hierarchy: `ConvilynError` → `AuthError`, `APIError` (→ `RateLimitError`,
|
|
181
|
+
`PlanRequiredError`, `QuotaExceededError`, `S3UploadError`, `RetryExhaustedError`),
|
|
182
|
+
`JobFailedError`, `JobTimeoutError`, `GoalJobFailedError`, `GoalJobTimeoutError`,
|
|
183
|
+
`WebSocketError`.
|
|
184
|
+
|
|
185
|
+
## Retry, timeout & auto-throttle
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
import { Convilyn, ExponentialBackoffRetry, NoRetry, AutoThrottleConfig } from '@convilyn/sdk'
|
|
189
|
+
|
|
190
|
+
const client = new Convilyn({
|
|
191
|
+
timeout: 30, // per-request, in seconds
|
|
192
|
+
maxRetries: 5, // cap (0 = no retries); or pass a full policy:
|
|
193
|
+
retryPolicy: new ExponentialBackoffRetry({ maxAttempts: 5, baseDelay: 0.2, maxDelay: 30 }),
|
|
194
|
+
autoThrottle: true, // sleep+retry on a 402 quota error
|
|
195
|
+
})
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
- **`retryPolicy` / `maxRetries`** handle *transient* transport failures
|
|
199
|
+
(408 / 429 / 5xx) with capped exponential backoff + jitter, honouring
|
|
200
|
+
`Retry-After`. Pass `new NoRetry()` to fail fast.
|
|
201
|
+
- **`autoThrottle`** is a distinct, opt-in shim for the **402 `QUOTA_EXCEEDED`**
|
|
202
|
+
envelope, where the remedy is *waiting for the quota window* rather than
|
|
203
|
+
retrying faster. `true` enables the defaults (1 retry, 60 s cap); pass
|
|
204
|
+
`new AutoThrottleConfig({ maxRetries: 2, maxSleep: 120, fallbackSleep: 5 })` to
|
|
205
|
+
tune. A soft-limit signal (`X-Quota-State: soft_limit`) is surfaced via Node's
|
|
206
|
+
`process.emitWarning` whether or not auto-throttle is enabled.
|
|
207
|
+
|
|
208
|
+
## WebSocket events
|
|
209
|
+
|
|
210
|
+
`goals.events()` streams live execution events as an async iterator:
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
for await (const event of client.goals.events(job.jobSpecId)) {
|
|
214
|
+
console.log(event.type, event.data) // 'tool_started' | 'progress' | 'completed' | …
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
> **Known v1 limitation:** the platform does not yet accept `ck_` keys for the
|
|
219
|
+
> WebSocket event stream. Until that lands, prefer polling with `goals.wait()`
|
|
220
|
+
> (which uses standard HTTP auth and works today); `events()` is wired and ready
|
|
221
|
+
> for when consumer-key streaming ships. There is no auto-reconnect — the
|
|
222
|
+
> backend does not replay missed events, so a silent reconnect would hide gaps.
|
|
223
|
+
|
|
224
|
+
## CLI
|
|
225
|
+
|
|
226
|
+
The package installs a `convilyn` binary:
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
export CONVILYN_API_KEY=ck_…
|
|
230
|
+
convilyn doctor --ping # environment + backend connectivity
|
|
231
|
+
convilyn convert a.docx --to pdf -o a.pdf
|
|
232
|
+
convilyn goals start --goal-text "Summarise" --files f_123
|
|
233
|
+
convilyn goals status <jobSpecId> --watch
|
|
234
|
+
convilyn goals events <jobSpecId>
|
|
235
|
+
convilyn account plan
|
|
236
|
+
convilyn account quota --tool pdf-mcp:extract_text
|
|
237
|
+
convilyn api GET /api/v1/health # gh-style escape hatch
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
`--json` emits machine-readable output. Exit codes are pinned: `0` ok, `1` usage,
|
|
241
|
+
`2` API error, `3` job failed, `130` interrupted.
|
|
242
|
+
|
|
243
|
+
## Configuration reference
|
|
244
|
+
|
|
245
|
+
| Constructor option | Env var | Default |
|
|
246
|
+
|---|---|---|
|
|
247
|
+
| `apiKey` | `CONVILYN_API_KEY` | — (required) |
|
|
248
|
+
| `baseUrl` | `CONVILYN_BASE_URL` (CLI only) | `https://api.convilyn.corenovus.com` |
|
|
249
|
+
| `wsUrl` | `CONVILYN_WS_URL` | — |
|
|
250
|
+
| `timeout` (seconds) | — | `30` |
|
|
251
|
+
| `maxRetries` / `retryPolicy` | — | 5-attempt backoff |
|
|
252
|
+
| `autoThrottle` | — | disabled |
|
|
253
|
+
| `disableIdempotency` | — | `false` |
|
|
254
|
+
|
|
255
|
+
## Public API & Stability
|
|
256
|
+
|
|
257
|
+
This package follows [Semantic Versioning](https://semver.org/). **The SemVer
|
|
258
|
+
contract is exactly the set of names exported from the package root** — the
|
|
259
|
+
`Convilyn` client and its resources, the error classes, the wire/response types,
|
|
260
|
+
the retry policies + `AutoThrottleConfig`, the `WSTransport` seam, and `VERSION`:
|
|
261
|
+
|
|
262
|
+
```ts
|
|
263
|
+
import { Convilyn, QuotaExceededError, ExponentialBackoffRetry, AutoThrottleConfig } from '@convilyn/sdk'
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Anything **not** exported here — the HTTP transport, the auth strategy, parsers,
|
|
267
|
+
the concrete WebSocket adapter — is internal and may change in any release. The
|
|
268
|
+
`package.json` `exports` map blocks deep imports of those paths, and a packaging
|
|
269
|
+
test pins the public surface so it cannot grow by accident. While the package is
|
|
270
|
+
pre-1.0 (`0.x`), minor versions may still contain breaking changes; once it
|
|
271
|
+
reaches `1.0.0`, breaking changes will only land in major versions.
|
|
272
|
+
|
|
273
|
+
### Relationship to the Python SDK
|
|
274
|
+
|
|
275
|
+
The public surface mirrors the Python SDK's `__all__`. Two intentional,
|
|
276
|
+
idiomatic differences: there is a single promise-based `Convilyn` (JavaScript has
|
|
277
|
+
no sync/async split, so there is no separate `AsyncConvilyn`), and the version
|
|
278
|
+
constant is `VERSION` (vs Python's `__version__`).
|
|
279
|
+
|
|
280
|
+
## License
|
|
281
|
+
|
|
282
|
+
Apache-2.0 — see [LICENSE](./LICENSE).
|