@paneui/core 0.0.5 → 0.0.7
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/dist/client.d.ts +242 -36
- package/dist/client.js +330 -40
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/schemas.d.ts +69 -171
- package/dist/schemas.js +61 -23
- package/dist/stream.d.ts +4 -4
- package/dist/stream.js +3 -3
- package/dist/types.d.ts +96 -31
- package/package.json +4 -4
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TemplateRecord, TemplateSummary, TemplateType, TemplateVersion, CreateArtifactResponse, CreateSessionRequest, CreateSessionResponse, EventsPage, FeedbackPage, FeedbackSubmission, FeedbackType, KeyInfo, MintParticipantResponse, PaneEvent, ParticipantsList, SurfaceState, SurfacesPage, TasteInfo } from "./types.js";
|
|
2
|
+
import type { ListSessionsQuery } from "./schemas.js";
|
|
2
3
|
export interface ClientOptions {
|
|
3
4
|
/** Relay base URL, e.g. https://pane.example.com. Trailing slash is trimmed. */
|
|
4
5
|
url: string;
|
|
@@ -23,7 +24,7 @@ export interface RelayResponse {
|
|
|
23
24
|
data: unknown;
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
|
-
* Request body for POST /v1/
|
|
27
|
+
* Request body for POST /v1/templates — create a named, reusable template plus
|
|
27
28
|
* its v1 content. Mirrors `createArtifactSchema` from ./schemas.js.
|
|
28
29
|
*/
|
|
29
30
|
export interface CreateArtifactRequest {
|
|
@@ -32,22 +33,22 @@ export interface CreateArtifactRequest {
|
|
|
32
33
|
description?: string;
|
|
33
34
|
tags?: string[];
|
|
34
35
|
source: string;
|
|
35
|
-
type:
|
|
36
|
+
type: TemplateType;
|
|
36
37
|
event_schema?: unknown;
|
|
37
38
|
input_schema?: Record<string, unknown>;
|
|
38
39
|
}
|
|
39
40
|
/**
|
|
40
|
-
* Request body for POST /v1/
|
|
41
|
+
* Request body for POST /v1/templates/:id/versions — append a new immutable
|
|
41
42
|
* version (content only). Mirrors `createArtifactVersionSchema`.
|
|
42
43
|
*/
|
|
43
44
|
export interface CreateArtifactVersionRequest {
|
|
44
45
|
source: string;
|
|
45
|
-
type:
|
|
46
|
+
type: TemplateType;
|
|
46
47
|
event_schema?: unknown;
|
|
47
48
|
input_schema?: Record<string, unknown>;
|
|
48
49
|
}
|
|
49
50
|
/**
|
|
50
|
-
* Request body for PATCH /v1/
|
|
51
|
+
* Request body for PATCH /v1/templates/:id — head metadata only (never
|
|
51
52
|
* content). Mirrors `patchArtifactMetadataSchema`.
|
|
52
53
|
*/
|
|
53
54
|
export interface PatchArtifactMetadataRequest {
|
|
@@ -97,21 +98,21 @@ export declare class PaneClient {
|
|
|
97
98
|
private asObject;
|
|
98
99
|
/** Throw a PaneApiError from a failed RelayResponse. */
|
|
99
100
|
private fail;
|
|
100
|
-
/** POST /v1/
|
|
101
|
+
/** POST /v1/surfaces — create a surface. */
|
|
101
102
|
createSession(req: CreateSessionRequest): Promise<CreateSessionResponse>;
|
|
102
|
-
/** GET /v1/
|
|
103
|
-
getSession(
|
|
103
|
+
/** GET /v1/surfaces/:id — non-blocking surface metadata. */
|
|
104
|
+
getSession(surfaceId: string): Promise<SurfaceState>;
|
|
104
105
|
/**
|
|
105
|
-
* GET /v1/
|
|
106
|
+
* GET /v1/surfaces/:id/events — fetch the event log.
|
|
106
107
|
* `since` is an opaque cursor; `waitSeconds` enables the relay long-poll
|
|
107
108
|
* (0 = non-blocking, capped at 30 by the relay).
|
|
108
109
|
*/
|
|
109
|
-
getEvents(
|
|
110
|
+
getEvents(surfaceId: string, opts?: {
|
|
110
111
|
since?: string | null;
|
|
111
112
|
waitSeconds?: number;
|
|
112
113
|
}): Promise<EventsPage>;
|
|
113
|
-
/** POST /v1/
|
|
114
|
-
sendEvent(
|
|
114
|
+
/** POST /v1/surfaces/:id/events — append an agent event. */
|
|
115
|
+
sendEvent(surfaceId: string, ev: {
|
|
115
116
|
type: string;
|
|
116
117
|
data: unknown;
|
|
117
118
|
causationId?: string;
|
|
@@ -121,37 +122,37 @@ export declare class PaneClient {
|
|
|
121
122
|
deduped: boolean;
|
|
122
123
|
}>;
|
|
123
124
|
/**
|
|
124
|
-
* POST /v1/
|
|
125
|
-
* Returns the new `
|
|
125
|
+
* POST /v1/templates — create a named, reusable template and its v1 content.
|
|
126
|
+
* Returns the new `template_id` and `version` (1).
|
|
126
127
|
*/
|
|
127
128
|
createArtifact(req: CreateArtifactRequest): Promise<CreateArtifactResponse>;
|
|
128
129
|
/**
|
|
129
|
-
* POST /v1/
|
|
130
|
-
* existing
|
|
130
|
+
* POST /v1/templates/:id/versions — append a new immutable version to an
|
|
131
|
+
* existing template. `idOrSlug` accepts the template id or its slug.
|
|
131
132
|
* Returns the new `version` number.
|
|
132
133
|
*/
|
|
133
134
|
createArtifactVersion(idOrSlug: string, req: CreateArtifactVersionRequest): Promise<CreateArtifactResponse>;
|
|
134
135
|
/**
|
|
135
|
-
* PATCH /v1/
|
|
136
|
+
* PATCH /v1/templates/:id — update head metadata (name / slug / description /
|
|
136
137
|
* tags); never the content. Returns the updated lean summary.
|
|
137
138
|
*/
|
|
138
|
-
updateArtifact(idOrSlug: string, metadata: PatchArtifactMetadataRequest): Promise<
|
|
139
|
+
updateArtifact(idOrSlug: string, metadata: PatchArtifactMetadataRequest): Promise<TemplateSummary>;
|
|
139
140
|
/**
|
|
140
|
-
* GET /v1/
|
|
141
|
-
* response is lean (no `source`
|
|
142
|
-
* to list every named
|
|
141
|
+
* GET /v1/templates?q=... — search/list the agent's named templates. The
|
|
142
|
+
* response is lean (no `source` attachment), ranked by `last_used_at`. Omit `query`
|
|
143
|
+
* to list every named template.
|
|
143
144
|
*/
|
|
144
|
-
searchArtifacts(query?: string): Promise<
|
|
145
|
+
searchArtifacts(query?: string): Promise<TemplateSummary[]>;
|
|
145
146
|
/**
|
|
146
|
-
* GET /v1/
|
|
147
|
-
* list). `idOrSlug` accepts the
|
|
147
|
+
* GET /v1/templates/:id — fetch a full template (head metadata + version
|
|
148
|
+
* list). `idOrSlug` accepts the template id or its slug.
|
|
148
149
|
*/
|
|
149
|
-
getArtifact(idOrSlug: string): Promise<
|
|
150
|
+
getArtifact(idOrSlug: string): Promise<TemplateRecord>;
|
|
150
151
|
/**
|
|
151
|
-
* GET /v1/
|
|
152
|
+
* GET /v1/templates/:id/versions/:version — fetch one version's full
|
|
152
153
|
* content (HTML, event schema, input schema).
|
|
153
154
|
*/
|
|
154
|
-
getArtifactVersion(idOrSlug: string, version: number): Promise<
|
|
155
|
+
getArtifactVersion(idOrSlug: string, version: number): Promise<TemplateVersion>;
|
|
155
156
|
/**
|
|
156
157
|
* GET /v1/keys — the calling agent's own key info. The relay scopes this to
|
|
157
158
|
* the authenticated agent: it returns one key (the caller's), not a list.
|
|
@@ -164,15 +165,27 @@ export declare class PaneClient {
|
|
|
164
165
|
*/
|
|
165
166
|
revokeKey(id: string): Promise<void>;
|
|
166
167
|
/**
|
|
167
|
-
*
|
|
168
|
+
* POST /v1/agents/claim — bind this agent to a human via a one-shot
|
|
169
|
+
* claim code the human generated in their settings UI. After a
|
|
170
|
+
* successful claim the agent's existing API key continues to work,
|
|
171
|
+
* but the agent (and its surfaces/templates) now belong to the
|
|
172
|
+
* claiming human. One-way operation — there is no unclaim in v1.
|
|
173
|
+
*/
|
|
174
|
+
claimAgent(code: string): Promise<{
|
|
175
|
+
ok: true;
|
|
176
|
+
owner_human_id: string;
|
|
177
|
+
claimed_at: string;
|
|
178
|
+
}>;
|
|
179
|
+
/**
|
|
180
|
+
* GET /v1/taste — the calling agent's freeform "taste notes" markdown attachment:
|
|
168
181
|
* presentation preferences the agent has picked up from human feedback over
|
|
169
182
|
* time. Returns `{ taste: null, updated_at: null, bytes: 0 }` when the
|
|
170
|
-
* agent has never written notes. Read this before generating an
|
|
183
|
+
* agent has never written notes. Read this before generating an template so
|
|
171
184
|
* the agent applies prior feedback.
|
|
172
185
|
*/
|
|
173
186
|
getTaste(): Promise<TasteInfo>;
|
|
174
187
|
/**
|
|
175
|
-
* PUT /v1/taste — whole-
|
|
188
|
+
* PUT /v1/taste — whole-attachment replace of the calling agent's taste notes.
|
|
176
189
|
* Empty/whitespace-only values are rejected by the relay; callers asking to
|
|
177
190
|
* clear must use {@link clearTaste}. The relay caps the payload at the
|
|
178
191
|
* server's `MAX_TASTE_BYTES` (utf8 bytes).
|
|
@@ -192,7 +205,7 @@ export declare class PaneClient {
|
|
|
192
205
|
submitFeedback(req: {
|
|
193
206
|
type: FeedbackType;
|
|
194
207
|
message: string;
|
|
195
|
-
|
|
208
|
+
surfaceId?: string;
|
|
196
209
|
}): Promise<FeedbackSubmission>;
|
|
197
210
|
/**
|
|
198
211
|
* GET /v1/feedback — the calling agent's own submissions, newest first.
|
|
@@ -203,16 +216,209 @@ export declare class PaneClient {
|
|
|
203
216
|
before?: string;
|
|
204
217
|
}): Promise<FeedbackPage>;
|
|
205
218
|
/**
|
|
206
|
-
*
|
|
207
|
-
*
|
|
219
|
+
* GET /v1/surfaces — list the calling agent's surfaces. Default filter is
|
|
220
|
+
* `status=open` (effective status — respects expiresAt). Response items
|
|
221
|
+
* carry NO secrets: no participant token plaintext, no callback URL, no
|
|
222
|
+
* metadata or input_data. Use `participant_id` from the list as the handle
|
|
223
|
+
* for {@link revokeParticipant}; use {@link mintParticipant} to issue a
|
|
224
|
+
* fresh URL when the original was lost.
|
|
225
|
+
*/
|
|
226
|
+
listSessions(opts?: ListSessionsQuery): Promise<SurfacesPage>;
|
|
227
|
+
/**
|
|
228
|
+
* GET /v1/surfaces/:id/participants — list every participant on one
|
|
229
|
+
* surface (active and revoked). Bounded by MAX_PARTICIPANTS_PER_SESSION
|
|
230
|
+
* on the relay, so the full list is returned with no pagination.
|
|
231
|
+
* Use this to find the `participant_id` you need to pass to
|
|
232
|
+
* {@link revokeParticipant}, or to audit revoked rows.
|
|
233
|
+
*/
|
|
234
|
+
listParticipants(surfaceId: string): Promise<ParticipantsList>;
|
|
235
|
+
/**
|
|
236
|
+
* POST /v1/surfaces/:id/participants — mint a fresh participant URL for an
|
|
237
|
+
* existing surface. The one-shot recovery primitive when the original URL
|
|
238
|
+
* was dropped: the surface keeps its event log, template pin, and created_at.
|
|
239
|
+
* v1 supports `kind: "human"` only.
|
|
240
|
+
*
|
|
241
|
+
* The plaintext token is returned EXACTLY ONCE in the response — the relay
|
|
242
|
+
* stores only the hash. Save the response (e.g. pipe to a JSONL log) before
|
|
243
|
+
* delivering the URL to the human.
|
|
244
|
+
*/
|
|
245
|
+
mintParticipant(surfaceId: string, opts?: {
|
|
246
|
+
kind?: "human";
|
|
247
|
+
}): Promise<MintParticipantResponse>;
|
|
248
|
+
/**
|
|
249
|
+
* DELETE /v1/surfaces/:id/participants/:participant_id — revoke a single
|
|
250
|
+
* participant URL. The surface's other participants (and the agent's own
|
|
251
|
+
* WebSocket) are untouched. Idempotent: revoking an unknown or already-
|
|
252
|
+
* revoked participant returns 204. The agent participant cannot be revoked
|
|
253
|
+
* via this endpoint — use {@link deleteSession} instead.
|
|
254
|
+
*
|
|
255
|
+
* Existing WebSocket connections held under the revoked token are NOT
|
|
256
|
+
* actively kicked in v1; new HTTP and WS connections are refused.
|
|
257
|
+
*/
|
|
258
|
+
revokeParticipant(surfaceId: string, participantId: string): Promise<void>;
|
|
259
|
+
/**
|
|
260
|
+
* DELETE /v1/surfaces/:id — close/delete a surface. Idempotent on the relay
|
|
261
|
+
* side (an already-closed surface still returns 204 with no body).
|
|
208
262
|
*/
|
|
209
263
|
deleteSession(id: string): Promise<void>;
|
|
210
264
|
/**
|
|
211
|
-
* DELETE /v1/
|
|
265
|
+
* DELETE /v1/templates/:id — remove an template and (server-side) all its
|
|
212
266
|
* versions. Strict cascade: the relay refuses with 409 conflict if any
|
|
213
|
-
*
|
|
267
|
+
* surface in any state still references one of the template's versions —
|
|
214
268
|
* surface that as a typed PaneApiError so the CLI can render a hint
|
|
215
269
|
* instead of swallowing it.
|
|
216
270
|
*/
|
|
217
271
|
deleteArtifact(idOrSlug: string): Promise<void>;
|
|
272
|
+
/**
|
|
273
|
+
* Upload a attachment to the relay. Returns a `AttachmentRef` that can be referenced
|
|
274
|
+
* in event payloads (the relay's `format: pane-attachment-id` schema vocab
|
|
275
|
+
* validates the id) or in `pane create --input-data`.
|
|
276
|
+
*
|
|
277
|
+
* Scope defaults to "agent" (reusable across the agent's surfaces). For
|
|
278
|
+
* `scope: "surface"` pass `surfaceId`; for `scope: "template"` pass
|
|
279
|
+
* `templateId`. The agent must own the referenced surface / template;
|
|
280
|
+
* cross-tenant attempts return attachment_not_found.
|
|
281
|
+
*
|
|
282
|
+
* MIME is inferred from `mime` if supplied; otherwise the relay sniffs
|
|
283
|
+
* leading bytes and may reject with mime_mismatch / mime_disallowed.
|
|
284
|
+
*
|
|
285
|
+
* Backed by the relay's multipart `POST /v1/attachments` (the fallback path).
|
|
286
|
+
* For large uploads (>1 MB on hosted Azure) call `presignBlob()` +
|
|
287
|
+
* `confirmBlob()` instead — those use SAS direct-to-storage and don't
|
|
288
|
+
* stream bytes through the relay.
|
|
289
|
+
*/
|
|
290
|
+
uploadBlob(file: Blob | Buffer | Uint8Array, opts?: UploadBlobOptions): Promise<AttachmentRef>;
|
|
291
|
+
/** GET /v1/attachments/:id — download bytes as an ArrayBuffer. */
|
|
292
|
+
downloadBlob(attachmentId: string): Promise<ArrayBuffer>;
|
|
293
|
+
/**
|
|
294
|
+
* GET a attachment's metadata only — useful before downloading large attachments, or
|
|
295
|
+
* for `pane attachment show <id>` which doesn't want the bytes. Returns the full
|
|
296
|
+
* AttachmentRef (the same shape POST /v1/attachments returns): id, scope, mime, size,
|
|
297
|
+
* sha256, filename, width, height, status, scope FKs, timestamps.
|
|
298
|
+
*
|
|
299
|
+
* Backed by GET /v1/attachments/:id/metadata which serves the JSON AttachmentRef
|
|
300
|
+
* without streaming the bytes — cheap on the relay and avoids the
|
|
301
|
+
* encrypt-at-rest decrypt cost when only the metadata is needed.
|
|
302
|
+
*/
|
|
303
|
+
getBlob(attachmentId: string): Promise<AttachmentRef>;
|
|
304
|
+
/** DELETE /v1/attachments/:id — soft-delete (idempotent). */
|
|
305
|
+
deleteBlob(attachmentId: string): Promise<{
|
|
306
|
+
deleted: true;
|
|
307
|
+
}>;
|
|
308
|
+
/**
|
|
309
|
+
* Mint a `/b/<token>` capability URL for `attachmentId`. Default TTL is set by
|
|
310
|
+
* the relay (24h agent, surface-TTL surface, 30d template). `once: true`
|
|
311
|
+
* tokens self-delete on first GET.
|
|
312
|
+
*/
|
|
313
|
+
mintBlobToken(attachmentId: string, opts?: {
|
|
314
|
+
ttlSeconds?: number;
|
|
315
|
+
once?: boolean;
|
|
316
|
+
}): Promise<AttachmentTokenMintResponse>;
|
|
317
|
+
/** Revoke a previously-minted token. Idempotent. */
|
|
318
|
+
revokeBlobToken(attachmentId: string, tokenId: string): Promise<{
|
|
319
|
+
token_id: string;
|
|
320
|
+
revoked: true;
|
|
321
|
+
}>;
|
|
322
|
+
/**
|
|
323
|
+
* GET /v1/attachments — list YOUR agent's non-deleted attachments (newest first).
|
|
324
|
+
* Paginated via opaque cursor: when `next_cursor` is non-null, pass it
|
|
325
|
+
* back as `cursor` on the next call.
|
|
326
|
+
*/
|
|
327
|
+
listBlobs(opts?: ListBlobsOptions): Promise<{
|
|
328
|
+
items: AttachmentRef[];
|
|
329
|
+
next_cursor: string | null;
|
|
330
|
+
}>;
|
|
331
|
+
/**
|
|
332
|
+
* GET /v1/attachments/:id/tokens — enumerate the capability tokens minted
|
|
333
|
+
* against one attachment, including revoked rows (for audit). The plaintext
|
|
334
|
+
* token is NEVER returned — it isn't stored, only its sha256 is.
|
|
335
|
+
*/
|
|
336
|
+
listBlobTokens(attachmentId: string): Promise<AttachmentTokenListResponse>;
|
|
337
|
+
/**
|
|
338
|
+
* Issue a presigned PUT URL for direct-to-storage upload. Returns the
|
|
339
|
+
* upload URL + the attachment_id (already reserved in the relay's DB with
|
|
340
|
+
* status=pending) + expiry. After PUTting the bytes to the URL, call
|
|
341
|
+
* `confirmBlob(attachment_id)` to finalise.
|
|
342
|
+
*
|
|
343
|
+
* Filesystem backend returns 501 not_implemented — use uploadBlob()
|
|
344
|
+
* (multipart fallback) instead. Azure backend returns a SAS URL.
|
|
345
|
+
*/
|
|
346
|
+
presignBlob(opts: PresignBlobOptions): Promise<{
|
|
347
|
+
attachment_id: string;
|
|
348
|
+
upload_url: string;
|
|
349
|
+
expires_at: string;
|
|
350
|
+
}>;
|
|
351
|
+
/** Finalise a presigned upload — relay HEADs the bytes, verifies, flips ready. */
|
|
352
|
+
confirmBlob(attachmentId: string): Promise<AttachmentRef>;
|
|
353
|
+
}
|
|
354
|
+
/** Per-attachment metadata as returned by `POST /v1/attachments` and friends. */
|
|
355
|
+
export interface AttachmentRef {
|
|
356
|
+
attachment_id: string;
|
|
357
|
+
scope: "agent" | "surface" | "template";
|
|
358
|
+
mime: string;
|
|
359
|
+
size: number;
|
|
360
|
+
sha256: string;
|
|
361
|
+
url?: string;
|
|
362
|
+
width?: number | null;
|
|
363
|
+
height?: number | null;
|
|
364
|
+
filename?: string | null;
|
|
365
|
+
status?: string;
|
|
366
|
+
surface_id?: string | null;
|
|
367
|
+
template_id?: string | null;
|
|
368
|
+
created_at?: string;
|
|
369
|
+
confirmed_at?: string | null;
|
|
370
|
+
deleted_at?: string | null;
|
|
371
|
+
}
|
|
372
|
+
export interface UploadBlobOptions {
|
|
373
|
+
scope?: "agent" | "surface" | "template";
|
|
374
|
+
surfaceId?: string;
|
|
375
|
+
templateId?: string;
|
|
376
|
+
/** Declared Content-Type. Defaults to `application/octet-stream`. The
|
|
377
|
+
* relay sniffs leading bytes and may reject with `mime_mismatch`. */
|
|
378
|
+
mime?: string;
|
|
379
|
+
/** Optional display name (the relay records it for UX; never a path component). */
|
|
380
|
+
filename?: string;
|
|
381
|
+
}
|
|
382
|
+
export interface PresignBlobOptions {
|
|
383
|
+
mime: string;
|
|
384
|
+
size: number;
|
|
385
|
+
sha256: string;
|
|
386
|
+
scope?: "agent" | "surface" | "template";
|
|
387
|
+
surfaceId?: string;
|
|
388
|
+
templateId?: string;
|
|
389
|
+
filename?: string;
|
|
390
|
+
}
|
|
391
|
+
export interface AttachmentTokenMintResponse {
|
|
392
|
+
token_id: string;
|
|
393
|
+
token: string;
|
|
394
|
+
token_prefix: string;
|
|
395
|
+
url: string;
|
|
396
|
+
expires_at: string;
|
|
397
|
+
once: boolean;
|
|
398
|
+
}
|
|
399
|
+
/** Options for `listBlobs()` — opaque cursor + page-size knob. */
|
|
400
|
+
export interface ListBlobsOptions {
|
|
401
|
+
/** Opaque pagination cursor from a prior `next_cursor`. */
|
|
402
|
+
cursor?: string;
|
|
403
|
+
/** Page size; relay clamps to 1..100. Defaults to the relay default (50). */
|
|
404
|
+
limit?: number;
|
|
405
|
+
}
|
|
406
|
+
/** One row in the response from `listBlobTokens()`. */
|
|
407
|
+
export interface AttachmentTokenAuditEntry {
|
|
408
|
+
token_id: string;
|
|
409
|
+
token_prefix: string;
|
|
410
|
+
expires_at: string;
|
|
411
|
+
once: boolean;
|
|
412
|
+
created_at: string;
|
|
413
|
+
last_used_at: string | null;
|
|
414
|
+
use_count: number;
|
|
415
|
+
/** Non-null when the token has been revoked. Expired-but-unrevoked rows
|
|
416
|
+
* carry `revoked_at: null` and an `expires_at` in the past — both are
|
|
417
|
+
* useful for audit. */
|
|
418
|
+
revoked_at: string | null;
|
|
419
|
+
}
|
|
420
|
+
/** Shape returned by `listBlobTokens()`. */
|
|
421
|
+
export interface AttachmentTokenListResponse {
|
|
422
|
+
attachment_id: string;
|
|
423
|
+
items: AttachmentTokenAuditEntry[];
|
|
218
424
|
}
|