@palai/sdk 0.1.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 +65 -0
- package/LICENSE +201 -0
- package/README.md +160 -0
- package/dist/client.d.ts +94 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +296 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +40 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +143 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated/tools.d.ts +39 -0
- package/dist/generated/tools.d.ts.map +1 -0
- package/dist/generated/tools.js +44 -0
- package/dist/generated/tools.js.map +1 -0
- package/dist/generated/types.d.ts +341 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/generated/types.js +7 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/index.browser.d.ts +3 -0
- package/dist/index.browser.d.ts.map +1 -0
- package/dist/index.browser.js +6 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/orchestrator.d.ts +61 -0
- package/dist/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator.js +159 -0
- package/dist/orchestrator.js.map +1 -0
- package/dist/resources/agents.d.ts +67 -0
- package/dist/resources/agents.d.ts.map +1 -0
- package/dist/resources/agents.js +75 -0
- package/dist/resources/agents.js.map +1 -0
- package/dist/resources/approvals.d.ts +33 -0
- package/dist/resources/approvals.d.ts.map +1 -0
- package/dist/resources/approvals.js +33 -0
- package/dist/resources/approvals.js.map +1 -0
- package/dist/resources/artifacts.d.ts +36 -0
- package/dist/resources/artifacts.d.ts.map +1 -0
- package/dist/resources/artifacts.js +70 -0
- package/dist/resources/artifacts.js.map +1 -0
- package/dist/resources/model-routes.d.ts +70 -0
- package/dist/resources/model-routes.d.ts.map +1 -0
- package/dist/resources/model-routes.js +74 -0
- package/dist/resources/model-routes.js.map +1 -0
- package/dist/resources/reads.d.ts +49 -0
- package/dist/resources/reads.d.ts.map +1 -0
- package/dist/resources/reads.js +91 -0
- package/dist/resources/reads.js.map +1 -0
- package/dist/resources/responses.d.ts +70 -0
- package/dist/resources/responses.d.ts.map +1 -0
- package/dist/resources/responses.js +147 -0
- package/dist/resources/responses.js.map +1 -0
- package/dist/resources/secret-refs.d.ts +24 -0
- package/dist/resources/secret-refs.d.ts.map +1 -0
- package/dist/resources/secret-refs.js +33 -0
- package/dist/resources/secret-refs.js.map +1 -0
- package/dist/resources/sessions.d.ts +106 -0
- package/dist/resources/sessions.d.ts.map +1 -0
- package/dist/resources/sessions.js +161 -0
- package/dist/resources/sessions.js.map +1 -0
- package/dist/resources/shared.d.ts +31 -0
- package/dist/resources/shared.d.ts.map +1 -0
- package/dist/resources/shared.js +32 -0
- package/dist/resources/shared.js.map +1 -0
- package/dist/resources/skills.d.ts +40 -0
- package/dist/resources/skills.d.ts.map +1 -0
- package/dist/resources/skills.js +40 -0
- package/dist/resources/skills.js.map +1 -0
- package/dist/schema.d.ts +35 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +30 -0
- package/dist/schema.js.map +1 -0
- package/dist/server-only.d.ts +2 -0
- package/dist/server-only.d.ts.map +1 -0
- package/dist/server-only.js +22 -0
- package/dist/server-only.js.map +1 -0
- package/dist/stream.d.ts +38 -0
- package/dist/stream.d.ts.map +1 -0
- package/dist/stream.js +314 -0
- package/dist/stream.js.map +1 -0
- package/package.json +44 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Changelog — @palai/sdk (TypeScript)
|
|
2
|
+
|
|
3
|
+
All notable changes to the Palai TypeScript SDK. This SDK is part of the E16 three-language SDK
|
|
4
|
+
line; versions move together across TS / Python / Go (see `docs/operations/sdk-compatibility.md`).
|
|
5
|
+
|
|
6
|
+
## 0.1.0 — E16 SDK surface (unreleased)
|
|
7
|
+
|
|
8
|
+
Target API-Version: **2026-07-16**.
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Typed `/v1` client with resources: `responses`, `sessions`, `agents`, `artifacts`, `reads`,
|
|
12
|
+
`provisioning`, `secretRefs`, `modelRoutes` (list/get read-back landed with E16 T1).
|
|
13
|
+
- Resumable SSE streaming for `responses.stream()` (shares the `create()` wire request;
|
|
14
|
+
`Last-Event-ID` resume).
|
|
15
|
+
- Transport-level retry with a stable `Idempotency-Key` (single retry owner — no per-resource retry).
|
|
16
|
+
- RFC 9457 typed errors, including the 410 retention tombstone (`GoneError`, API-015).
|
|
17
|
+
- Forward-compatible decoding: unknown fields are preserved.
|
|
18
|
+
- `Page` (cursor) vs `ListView` (`object:"list"` admin) envelope decode (E16 T1 distinction).
|
|
19
|
+
|
|
20
|
+
### Conformance
|
|
21
|
+
Validated against the shared cross-language corpus (`tests/conformance/sdk/`) via
|
|
22
|
+
`TestCorpusTypeScriptRunnerEquality`: **request-encode, event-decode, error-map, unknown-field,
|
|
23
|
+
envelope-decode** (5 of 6 categories).
|
|
24
|
+
|
|
25
|
+
### Honest ceiling
|
|
26
|
+
- **No webhook signature verify.** This SDK keeps the E13 server-relay/browser stance; webhook
|
|
27
|
+
verification is a server-side concern. `signature-verify` is therefore **not** a supported cell
|
|
28
|
+
in the compatibility matrix (see the `—` for TS). Use the Python or Go SDK server-side for that.
|
|
29
|
+
- **Not published.** `npm publish` is deliberately out of scope; the package is built + checksummed
|
|
30
|
+
+ signed locally (`scripts/release/sdk-package.sh`). Public-registry publish is E18.
|
|
31
|
+
|
|
32
|
+
## Unreleased
|
|
33
|
+
|
|
34
|
+
### Legacy taraması — 2026-08-26, sıfır bulgu
|
|
35
|
+
|
|
36
|
+
Paket, Swift SDK koşusunun bir parçası olarak legacy kalıntısı için tarandı. **Hiçbir şey
|
|
37
|
+
kaldırılmadı, çünkü kaldırılacak bir şey bulunamadı.** Her satır kendi komutuyla:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
grep -rn '@deprecated' src/ → 0
|
|
41
|
+
grep -rnE 'callback[?]?:|completion[?]?:' src/ → 4 (hepsi yanlış pozitif)
|
|
42
|
+
grep -rn '\.then(' src/ → 1 (yanlış pozitif)
|
|
43
|
+
grep -rn 'require(' src/ → 0
|
|
44
|
+
grep -rnE ': any\b' src/ ; grep -rn 'as any' src/ → 0, 0
|
|
45
|
+
grep -rnE '@ts-(ignore|expect-error)' src/ → 0
|
|
46
|
+
grep -rnE '^\s*var ' src/ → 0
|
|
47
|
+
grep -rniE 'PalaiAdmin|fleet|provisioning' src/ → 3 (hepsi yorum)
|
|
48
|
+
hiçbir yerden import edilmeyen dosya → 0
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Üç eşleşmenin üçü de yanlış pozitif ve **silinmeleri kusur olurdu**:
|
|
52
|
+
- `callback` alanları `response-create` şemasının **tel alanı** (webhook callback config), bir
|
|
53
|
+
completion-handler API'si değil; ikisi zaten üretilmiş tiplerde.
|
|
54
|
+
- `stream.ts:177`'deki `.then(` bir start-promise'i memoize ediyor, callback stili değil.
|
|
55
|
+
- `PalaiAdmin`/`fleet`/`provisioning` eşleşmelerinin üçü de bu yüzeylerin pakette
|
|
56
|
+
**OLMADIĞINI açıklayan yorumlar** (`index.ts:39`), kalıntı değil.
|
|
57
|
+
|
|
58
|
+
87 export'un 15'i depo içinde tek referanslı; hepsi **yayımlanan paketin public sözleşmesi**
|
|
59
|
+
(hata sınıfları, param tipleri) ve çağıranları depo dışında. "Kimse kullanmıyor" diye silmek
|
|
60
|
+
tüketiciyi kırardı — CLAUDE.md Kural 1'in "sayı yanlış değildi, arama yanlıştı" kaydı.
|
|
61
|
+
|
|
62
|
+
Ağacın zaten temiz olmasının sebebi `docs/paltimate/2026-08-10-consumer-only-sdk`: admin
|
|
63
|
+
yüzeyi o iş sırasında paketten çıkarılmıştı.
|
|
64
|
+
|
|
65
|
+
Doğrulama: `pnpm run typecheck` temiz · `node --test test/*.test.ts` → 70/70.
|
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 reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and 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 Palgroup
|
|
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 implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# @palai/sdk
|
|
2
|
+
|
|
3
|
+
A thin, typed TypeScript client for the Palai control-plane HTTP API. It speaks the dated
|
|
4
|
+
`/v1` contract (the `API-Version` header rides every request), maps failures to typed
|
|
5
|
+
RFC 9457 problem errors, and retries idempotently.
|
|
6
|
+
|
|
7
|
+
## Server-only credential stance (why browser-direct tokens were dropped)
|
|
8
|
+
|
|
9
|
+
**The API key is server-side only. There is no browser-direct token, by design.**
|
|
10
|
+
|
|
11
|
+
Palai deliberately **dropped** the idea of issuing a short-lived, browser-scoped token that a
|
|
12
|
+
browser would use to call the control-plane directly. The correct and supported pattern is a
|
|
13
|
+
**server relay**: your server holds the API key, calls Palai with this SDK, and re-projects only
|
|
14
|
+
the curated fields your UI needs. The browser talks to *your* server route, never to Palai.
|
|
15
|
+
|
|
16
|
+
Why the relay is the right pattern (not a limitation):
|
|
17
|
+
|
|
18
|
+
- **The credential never reaches the client.** A browser-direct token is still a bearer
|
|
19
|
+
credential shipped to every visitor; a relay keeps the only credential on the server.
|
|
20
|
+
- **You control the projection.** The relay forwards curated canonical fields — never the raw
|
|
21
|
+
provider payload, never the key. See `examples/nextjs-sdk`.
|
|
22
|
+
- **No CORS / token-exchange surface to secure.** There is nothing browser-facing to scope,
|
|
23
|
+
rotate, or leak.
|
|
24
|
+
|
|
25
|
+
How the stance is **enforced**, not just documented:
|
|
26
|
+
|
|
27
|
+
1. **Two entrypoints.** The package `browser` export condition resolves to
|
|
28
|
+
`./src/index.browser.ts`, which exports the typed shapes and the RFC 9457 error surface —
|
|
29
|
+
**everything a browser needs to render a response or narrow an error** — and **no** API-key
|
|
30
|
+
client. The default (server) condition resolves to `./src/index.ts`, which exports the `Palai`
|
|
31
|
+
client and every resource.
|
|
32
|
+
2. **A runtime backstop.** The `Palai` client's module chain imports `./src/server-only.ts`,
|
|
33
|
+
which **throws** if it is ever evaluated in a browser (a `window`/`document` global is
|
|
34
|
+
present) — so a misconfigured bundler that ignores the export condition fails loud instead of
|
|
35
|
+
silently shipping the secret.
|
|
36
|
+
3. **Every new resource routes through that client.** Sessions, agents, artifacts, the read/LIST
|
|
37
|
+
surfaces and the tenant-configuration clients (secret-refs, model-routes) are all reachable
|
|
38
|
+
**only** from the server entrypoint. None is re-exported from the browser entrypoint. This is
|
|
39
|
+
the positive enforcement of the drop decision; the SDK test suite asserts the browser
|
|
40
|
+
entrypoint exposes no credentialed client.
|
|
41
|
+
|
|
42
|
+
In Next.js, layer the framework's own `server-only` package on top (as `examples/nextjs-sdk`
|
|
43
|
+
does) for a build-time error the moment a Client Component imports the credential path.
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
// server code only (route handler, server action, server component)
|
|
47
|
+
import { Palai } from "@palai/sdk";
|
|
48
|
+
const palai = new Palai({ apiKey: process.env.PALAI_API_KEY });
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
// browser code — types and error narrowing only, no client, no key
|
|
53
|
+
import { PalaiAPIError, type Response } from "@palai/sdk/browser";
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Resources
|
|
57
|
+
|
|
58
|
+
All resources hang off the server-only `Palai` client:
|
|
59
|
+
|
|
60
|
+
- `responses` — create / retrieve / cancel / **stream** (resumable SSE) / **list** (run history)
|
|
61
|
+
- `sessions` — create / retrieve / list, and `sessions.commands.steer` / `.interrupt`
|
|
62
|
+
(durable commands)
|
|
63
|
+
- `agents` — list / retrieve / listRevisions / publishRevision
|
|
64
|
+
- `artifacts` — retrieve (metadata) / **download** (authenticated byte stream + Content-Digest) /
|
|
65
|
+
listForResponse
|
|
66
|
+
- read/LIST surfaces — `repositoryBindings`, `tools` (+ `listSets`), `mcpConnections`, `triggers`,
|
|
67
|
+
all over the shared opaque, tenant-bound cursor (`after` + `limit`)
|
|
68
|
+
- tenant configuration — `secretRefs` (write-only value, metadata reads, rotate) and `modelRoutes`
|
|
69
|
+
(connections / routes / revisions / publish). **These are yours, not the operator's:** neither
|
|
70
|
+
route family is behind the plane's `system` gate, both are confined to your project by RLS, and
|
|
71
|
+
your project key reaches them. They were filed under "admin" here until 2026-08-11, which was one
|
|
72
|
+
loose word putting your own configuration in the same bag as platform administration.
|
|
73
|
+
- `Orchestrator` — the external-orchestrator kit: the §35.1 five-step contract
|
|
74
|
+
(`start` / `waitByPoll` / `waitByStream` / `sendMessage` / `cancel` / `reconcile` / `runActivity`),
|
|
75
|
+
keeping the external workflow id and Palai's canonical run id separate. See
|
|
76
|
+
[docs/orchestrator-kit.md](docs/orchestrator-kit.md) for who owns which timeout/retry (§35.2).
|
|
77
|
+
|
|
78
|
+
## What is not here
|
|
79
|
+
|
|
80
|
+
**The machine fleet and tenancy provisioning are not in this package.** Runner pools, enrolment
|
|
81
|
+
keys, enrolled machines, `projects` and `apiKeys` are operator surface: every one of those routes
|
|
82
|
+
demands a `system` or `provision` capability that a project key does not carry, so a method for one
|
|
83
|
+
could only ever hand you a `403` your key can never satisfy. Their contract is the `admin`-tagged
|
|
84
|
+
half of `protocols/openapi/openapi-3.2.yaml` — 24 operations across 19 paths, schema-backed — which
|
|
85
|
+
an operator generates a client from. If you run Palai yourself, that document and the web console
|
|
86
|
+
are your fleet surface.
|
|
87
|
+
|
|
88
|
+
**Their absence is not what keeps them safe, and you should not read it that way.** The boundary is
|
|
89
|
+
the server's capability gate — every fleet route is registered through `systemOnly`, and a test
|
|
90
|
+
derives its route list from the router rather than from a copied list, so a new route cannot miss
|
|
91
|
+
the gate quietly. `request()` below is public and generic: `palai.request("POST", "/v1/runner-pools",
|
|
92
|
+
…)` compiles today and is refused by the plane, not by this package. Nothing here is hidden for
|
|
93
|
+
security; it is absent because it is not yours to call.
|
|
94
|
+
|
|
95
|
+
Lists page with an opaque `after` cursor and a `limit`; the SDK passes the server's
|
|
96
|
+
`next_cursor` straight back — it never parses the cursor (it is tenant-bound and server-minted).
|
|
97
|
+
|
|
98
|
+
## Development
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
npm run typecheck # tsc, no emit
|
|
102
|
+
npm test # node --test (native, no framework)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## v2 surface
|
|
106
|
+
|
|
107
|
+
The same names and the same semantics as [`palai-swift`](../swift) — a caller moving between the
|
|
108
|
+
two should not have to learn a second vocabulary.
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
import { Palai } from "@palai/sdk";
|
|
112
|
+
import { s } from "@palai/sdk/schema";
|
|
113
|
+
|
|
114
|
+
const client = new Palai({ apiKey, baseURL });
|
|
115
|
+
|
|
116
|
+
// One prompt in, the model's text out.
|
|
117
|
+
const answer = await client.ask("Fransa'nın başkenti?", { model: "claude-opus-5", effort: "xhigh" });
|
|
118
|
+
|
|
119
|
+
// The full turn, finished. Waits on the event stream — it does not poll.
|
|
120
|
+
const response = await client.responses.run({ input: "özetle", effort: "high" });
|
|
121
|
+
|
|
122
|
+
// The journal, as it arrives.
|
|
123
|
+
const final = await client.responses.stream(request).finalResponse();
|
|
124
|
+
|
|
125
|
+
// A typed answer under a JSON-Schema contract.
|
|
126
|
+
const capital = await client.responses.parse<{ city: string }>("Türkiye'nin başkenti?", {
|
|
127
|
+
schema: s.object({ city: s.string }, ["city"]),
|
|
128
|
+
name: "capital",
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// What the agent actually did — WITH results.
|
|
132
|
+
const failed = (await client.responses.toolCalls(response.id)).filter((c) => c.succeeded === false);
|
|
133
|
+
|
|
134
|
+
// Models come through a connection; the engine has no flat model list.
|
|
135
|
+
for (const c of await client.modelConnections.list()) {
|
|
136
|
+
console.log(c.name, await client.modelConnections.models(c.id));
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### No Zod, and that is on purpose
|
|
141
|
+
|
|
142
|
+
`dependencies` is empty and stays empty. A schema library would be inherited by every consumer,
|
|
143
|
+
including ones already using a different validator. OpenAI solves the same problem with an optional
|
|
144
|
+
subpath (`openai/helpers/zod`) that only works if you installed zod; `s` is the zero-dependency half
|
|
145
|
+
of that idea. If you do use zod, `z.toJSONSchema(...)` produces exactly what `parse` wants.
|
|
146
|
+
|
|
147
|
+
The **server** is the only validator: an unrecognised `output.format` answers 400. A second
|
|
148
|
+
validator here would be a second definition of "invalid".
|
|
149
|
+
|
|
150
|
+
### `Effort` is an open set
|
|
151
|
+
|
|
152
|
+
`Effort` includes `(string & {})`, which keeps the named rungs in autocomplete while letting an
|
|
153
|
+
unknown one through. The ladder is not fixed — Anthropic's own rungs differ per model — and a closed
|
|
154
|
+
union would turn the server adding a rung into a compile error in every application using this SDK.
|
|
155
|
+
|
|
156
|
+
### `completed` is not success
|
|
157
|
+
|
|
158
|
+
`ToolCall.succeeded` reads `result.status`, never `state`. They disagree in practice: a live run
|
|
159
|
+
emitted `tool_call.completed.v1` while the tool-calls record carried `result.status: "error"`.
|
|
160
|
+
`succeeded` is `undefined` when the server has not said yet — unknown is not failure.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import "./server-only.ts";
|
|
2
|
+
import type { Response as PalaiResponse } from "./generated/types.ts";
|
|
3
|
+
import { type StreamTransport } from "./stream.ts";
|
|
4
|
+
import { Responses } from "./resources/responses.ts";
|
|
5
|
+
import { Sessions } from "./resources/sessions.ts";
|
|
6
|
+
import { Skills } from "./resources/skills.ts";
|
|
7
|
+
import type { CallOptions } from "./resources/shared.ts";
|
|
8
|
+
import { Agents, type DefineAgentParams, type PublishedAgent } from "./resources/agents.ts";
|
|
9
|
+
import { Approvals } from "./resources/approvals.ts";
|
|
10
|
+
import { Artifacts } from "./resources/artifacts.ts";
|
|
11
|
+
import { MCPConnections, ModelConnections, RepositoryBindings, Tools, Triggers } from "./resources/reads.ts";
|
|
12
|
+
import { SecretRefs } from "./resources/secret-refs.ts";
|
|
13
|
+
import { ModelRoutes } from "./resources/model-routes.ts";
|
|
14
|
+
import type { DownloadOptions } from "./resources/shared.ts";
|
|
15
|
+
export declare const APIVersion = "2026-07-16";
|
|
16
|
+
export interface PalaiOptions {
|
|
17
|
+
baseURL?: string;
|
|
18
|
+
apiKey?: string;
|
|
19
|
+
/** Reserved for multi-project keys; the server derives scope from the key today. */
|
|
20
|
+
project?: string;
|
|
21
|
+
/** Injectable for tests and custom transports; defaults to the global fetch. */
|
|
22
|
+
fetch?: typeof fetch;
|
|
23
|
+
/** Max retry attempts after the first try for a retryable failure. Default 2. */
|
|
24
|
+
maxRetries?: number;
|
|
25
|
+
/** Total deadline for a request including retries and backoff, ms. Default 60000. */
|
|
26
|
+
timeoutMs?: number;
|
|
27
|
+
backoffBaseMs?: number;
|
|
28
|
+
backoffMaxMs?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface RequestOptions {
|
|
31
|
+
body?: unknown;
|
|
32
|
+
/**
|
|
33
|
+
* bytes is a RAW body, for the one endpoint that takes an object rather than JSON
|
|
34
|
+
* (`POST /v1/artifacts`). It is mutually exclusive with `body` and wins when both are set, because a
|
|
35
|
+
* request that carried both would be one whose Content-Type contradicts its payload.
|
|
36
|
+
*/
|
|
37
|
+
bytes?: Uint8Array;
|
|
38
|
+
idempotencyKey?: string;
|
|
39
|
+
signal?: AbortSignal | undefined;
|
|
40
|
+
maxRetries?: number;
|
|
41
|
+
timeoutMs?: number;
|
|
42
|
+
accept?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Whether a NETWORK-level failure (no HTTP status seen) may be safely re-sent. A torn connection
|
|
45
|
+
* can drop AFTER the server committed, so re-sending a non-idempotent mutation would double-apply
|
|
46
|
+
* it. Defaults to true for safe methods (GET/HEAD) and for any request carrying an Idempotency-Key;
|
|
47
|
+
* a body-idempotent op (a command's command_id) sets it explicitly. Non-idempotent creates leave it
|
|
48
|
+
* false, so they fail closed rather than double-provisioning (a 429/5xx *response* still retries —
|
|
49
|
+
* that is pre-commit-safe on the server).
|
|
50
|
+
*/
|
|
51
|
+
idempotent?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface ApiResult<T> {
|
|
54
|
+
status: number;
|
|
55
|
+
headers: Headers;
|
|
56
|
+
body: T;
|
|
57
|
+
}
|
|
58
|
+
export declare class Palai implements StreamTransport {
|
|
59
|
+
#private;
|
|
60
|
+
readonly baseURL: string;
|
|
61
|
+
readonly project: string | undefined;
|
|
62
|
+
readonly responses: Responses;
|
|
63
|
+
readonly modelConnections: ModelConnections;
|
|
64
|
+
readonly sessions: Sessions;
|
|
65
|
+
readonly agents: Agents;
|
|
66
|
+
readonly skills: Skills;
|
|
67
|
+
readonly approvals: Approvals;
|
|
68
|
+
readonly artifacts: Artifacts;
|
|
69
|
+
readonly repositoryBindings: RepositoryBindings;
|
|
70
|
+
readonly tools: Tools;
|
|
71
|
+
readonly mcpConnections: MCPConnections;
|
|
72
|
+
readonly triggers: Triggers;
|
|
73
|
+
readonly secretRefs: SecretRefs;
|
|
74
|
+
readonly modelRoutes: ModelRoutes;
|
|
75
|
+
constructor(options?: PalaiOptions);
|
|
76
|
+
request<T>(method: string, path: string, options?: RequestOptions): Promise<ApiResult<T>>;
|
|
77
|
+
openEventStream(sessionID: string, lastEventId: string | null, signal: AbortSignal | undefined): Promise<globalThis.Response>;
|
|
78
|
+
retrieveResponse(responseID: string): Promise<PalaiResponse>;
|
|
79
|
+
/**
|
|
80
|
+
* One prompt in, the model's text out.
|
|
81
|
+
*
|
|
82
|
+
* The whole vertical collapsed to a single call — create, wait, read — for the case where a
|
|
83
|
+
* caller wants an answer and nothing else. Everything it hides stays reachable: `responses.run`
|
|
84
|
+
* returns the full Response, `responses.stream` gives the journal.
|
|
85
|
+
*/
|
|
86
|
+
ask(prompt: string, options?: {
|
|
87
|
+
model?: string;
|
|
88
|
+
effort?: string;
|
|
89
|
+
deadlineMs?: number;
|
|
90
|
+
}): Promise<string>;
|
|
91
|
+
openDownload(path: string, options?: DownloadOptions): Promise<globalThis.Response>;
|
|
92
|
+
defineAgent(params: DefineAgentParams, options?: CallOptions): Promise<PublishedAgent>;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEtE,OAAO,EAA4B,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5F,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC7G,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE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