@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/schemas.d.ts CHANGED
@@ -1,211 +1,109 @@
1
1
  import { z } from "zod";
2
- export declare const artifactTypeSchema: z.ZodEnum<["html-inline", "html-ref"]>;
3
- export declare const artifactSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
2
+ export declare const artifactTypeSchema: z.ZodEnum<{
3
+ "html-inline": "html-inline";
4
+ "html-ref": "html-ref";
5
+ }>;
6
+ export declare const artifactSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
4
7
  type: z.ZodLiteral<"html-inline">;
5
8
  source: z.ZodString;
6
- }, "strip", z.ZodTypeAny, {
7
- type: "html-inline";
8
- source: string;
9
- }, {
10
- type: "html-inline";
11
- source: string;
12
- }>, z.ZodObject<{
9
+ }, z.core.$strip>, z.ZodObject<{
13
10
  type: z.ZodLiteral<"html-ref">;
14
11
  source: z.ZodString;
15
- }, "strip", z.ZodTypeAny, {
16
- type: "html-ref";
17
- source: string;
18
- }, {
19
- type: "html-ref";
20
- source: string;
21
- }>]>;
12
+ }, z.core.$strip>], "type">;
22
13
  export declare const callbackSchema: z.ZodObject<{
23
14
  url: z.ZodString;
24
- events: z.ZodArray<z.ZodString, "many">;
15
+ events: z.ZodArray<z.ZodString>;
25
16
  secret: z.ZodString;
26
- }, "strip", z.ZodTypeAny, {
27
- url: string;
28
- events: string[];
29
- secret: string;
30
- }, {
31
- url: string;
32
- events: string[];
33
- secret: string;
34
- }>;
17
+ }, z.core.$strip>;
35
18
  export declare const createSessionSchema: z.ZodObject<{
36
- artifact: z.ZodEffects<z.ZodUnion<[z.ZodObject<{
19
+ template: z.ZodUnion<readonly [z.ZodObject<{
37
20
  id: z.ZodString;
38
21
  version: z.ZodOptional<z.ZodNumber>;
39
- }, "strip", z.ZodTypeAny, {
40
- id: string;
41
- version?: number | undefined;
42
- }, {
43
- id: string;
44
- version?: number | undefined;
45
- }>, z.ZodObject<{
22
+ }, z.core.$strip>, z.ZodObject<{
46
23
  source: z.ZodString;
47
- type: z.ZodEnum<["html-inline", "html-ref"]>;
24
+ type: z.ZodEnum<{
25
+ "html-inline": "html-inline";
26
+ "html-ref": "html-ref";
27
+ }>;
48
28
  event_schema: z.ZodOptional<z.ZodUnknown>;
49
- }, "strip", z.ZodTypeAny, {
50
- type: "html-inline" | "html-ref";
51
- source: string;
52
- event_schema?: unknown;
53
- }, {
54
- type: "html-inline" | "html-ref";
55
- source: string;
56
- event_schema?: unknown;
57
- }>]>, {
58
- type: "html-inline" | "html-ref";
59
- source: string;
60
- event_schema?: unknown;
61
- } | {
62
- id: string;
63
- version?: number | undefined;
64
- }, {
65
- type: "html-inline" | "html-ref";
66
- source: string;
67
- event_schema?: unknown;
68
- } | {
69
- id: string;
70
- version?: number | undefined;
71
- }>;
29
+ input_schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
30
+ }, z.core.$strip>]>;
72
31
  input_data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
73
32
  participants: z.ZodOptional<z.ZodObject<{
74
33
  humans: z.ZodNumber;
75
- }, "strip", z.ZodTypeAny, {
76
- humans: number;
77
- }, {
78
- humans: number;
79
- }>>;
34
+ }, z.core.$strip>>;
80
35
  ttl: z.ZodOptional<z.ZodNumber>;
81
36
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
82
37
  callback: z.ZodOptional<z.ZodObject<{
83
38
  url: z.ZodString;
84
- events: z.ZodArray<z.ZodString, "many">;
39
+ events: z.ZodArray<z.ZodString>;
85
40
  secret: z.ZodString;
86
- }, "strip", z.ZodTypeAny, {
87
- url: string;
88
- events: string[];
89
- secret: string;
90
- }, {
91
- url: string;
92
- events: string[];
93
- secret: string;
94
- }>>;
95
- }, "strip", z.ZodTypeAny, {
96
- artifact: {
97
- type: "html-inline" | "html-ref";
98
- source: string;
99
- event_schema?: unknown;
100
- } | {
101
- id: string;
102
- version?: number | undefined;
103
- };
104
- input_data?: Record<string, unknown> | undefined;
105
- participants?: {
106
- humans: number;
107
- } | undefined;
108
- ttl?: number | undefined;
109
- metadata?: Record<string, unknown> | undefined;
110
- callback?: {
111
- url: string;
112
- events: string[];
113
- secret: string;
114
- } | undefined;
115
- }, {
116
- artifact: {
117
- type: "html-inline" | "html-ref";
118
- source: string;
119
- event_schema?: unknown;
120
- } | {
121
- id: string;
122
- version?: number | undefined;
123
- };
124
- input_data?: Record<string, unknown> | undefined;
125
- participants?: {
126
- humans: number;
127
- } | undefined;
128
- ttl?: number | undefined;
129
- metadata?: Record<string, unknown> | undefined;
130
- callback?: {
131
- url: string;
132
- events: string[];
133
- secret: string;
134
- } | undefined;
135
- }>;
41
+ }, z.core.$strip>>;
42
+ title: z.ZodOptional<z.ZodString>;
43
+ context_key: z.ZodOptional<z.ZodString>;
44
+ }, z.core.$strip>;
136
45
  export declare const createArtifactSchema: z.ZodObject<{
137
46
  name: z.ZodString;
138
47
  slug: z.ZodOptional<z.ZodString>;
139
48
  description: z.ZodOptional<z.ZodString>;
140
- tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
49
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
141
50
  source: z.ZodString;
142
- type: z.ZodEnum<["html-inline", "html-ref"]>;
51
+ type: z.ZodEnum<{
52
+ "html-inline": "html-inline";
53
+ "html-ref": "html-ref";
54
+ }>;
143
55
  event_schema: z.ZodOptional<z.ZodUnknown>;
144
56
  input_schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
145
- }, "strip", z.ZodTypeAny, {
146
- type: "html-inline" | "html-ref";
147
- source: string;
148
- name: string;
149
- event_schema?: unknown;
150
- slug?: string | undefined;
151
- description?: string | undefined;
152
- tags?: string[] | undefined;
153
- input_schema?: Record<string, unknown> | undefined;
154
- }, {
155
- type: "html-inline" | "html-ref";
156
- source: string;
157
- name: string;
158
- event_schema?: unknown;
159
- slug?: string | undefined;
160
- description?: string | undefined;
161
- tags?: string[] | undefined;
162
- input_schema?: Record<string, unknown> | undefined;
163
- }>;
57
+ }, z.core.$strip>;
164
58
  export declare const createArtifactVersionSchema: z.ZodObject<{
165
59
  source: z.ZodString;
166
- type: z.ZodEnum<["html-inline", "html-ref"]>;
60
+ type: z.ZodEnum<{
61
+ "html-inline": "html-inline";
62
+ "html-ref": "html-ref";
63
+ }>;
167
64
  event_schema: z.ZodOptional<z.ZodUnknown>;
168
65
  input_schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
169
- }, "strip", z.ZodTypeAny, {
170
- type: "html-inline" | "html-ref";
171
- source: string;
172
- event_schema?: unknown;
173
- input_schema?: Record<string, unknown> | undefined;
174
- }, {
175
- type: "html-inline" | "html-ref";
176
- source: string;
177
- event_schema?: unknown;
178
- input_schema?: Record<string, unknown> | undefined;
179
- }>;
66
+ }, z.core.$strip>;
180
67
  export declare const patchArtifactMetadataSchema: z.ZodObject<{
181
68
  name: z.ZodOptional<z.ZodString>;
182
69
  slug: z.ZodOptional<z.ZodString>;
183
70
  description: z.ZodOptional<z.ZodString>;
184
- tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
185
- }, "strip", z.ZodTypeAny, {
186
- name?: string | undefined;
187
- slug?: string | undefined;
188
- description?: string | undefined;
189
- tags?: string[] | undefined;
190
- }, {
191
- name?: string | undefined;
192
- slug?: string | undefined;
193
- description?: string | undefined;
194
- tags?: string[] | undefined;
71
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
72
+ }, z.core.$strip>;
73
+ export declare const feedbackTypeSchema: z.ZodEnum<{
74
+ bug: "bug";
75
+ feature: "feature";
76
+ note: "note";
195
77
  }>;
196
- export declare const feedbackTypeSchema: z.ZodEnum<["bug", "feature", "note"]>;
197
78
  export declare const submitFeedbackSchema: z.ZodObject<{
198
- type: z.ZodEnum<["bug", "feature", "note"]>;
199
- message: z.ZodPipeline<z.ZodEffects<z.ZodString, string, string>, z.ZodString>;
200
- session_id: z.ZodOptional<z.ZodString>;
201
- }, "strip", z.ZodTypeAny, {
202
- type: "bug" | "feature" | "note";
203
- message: string;
204
- session_id?: string | undefined;
205
- }, {
206
- type: "bug" | "feature" | "note";
207
- message: string;
208
- session_id?: string | undefined;
209
- }>;
79
+ type: z.ZodEnum<{
80
+ bug: "bug";
81
+ feature: "feature";
82
+ note: "note";
83
+ }>;
84
+ message: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
85
+ surface_id: z.ZodOptional<z.ZodString>;
86
+ }, z.core.$strip>;
210
87
  /** @deprecated use `CreateSessionRequest` from ./types.js (same type). */
211
88
  export type CreateSessionInput = z.infer<typeof createSessionSchema>;
89
+ export declare const listSessionsStatusSchema: z.ZodEnum<{
90
+ open: "open";
91
+ closed: "closed";
92
+ all: "all";
93
+ }>;
94
+ export type ListSessionsStatus = z.infer<typeof listSessionsStatusSchema>;
95
+ export declare const listSessionsQuerySchema: z.ZodObject<{
96
+ status: z.ZodOptional<z.ZodEnum<{
97
+ open: "open";
98
+ closed: "closed";
99
+ all: "all";
100
+ }>>;
101
+ limit: z.ZodOptional<z.ZodNumber>;
102
+ cursor: z.ZodOptional<z.ZodString>;
103
+ template_id: z.ZodOptional<z.ZodString>;
104
+ }, z.core.$strip>;
105
+ export type ListSessionsQuery = z.infer<typeof listSessionsQuerySchema>;
106
+ export declare const mintParticipantSchema: z.ZodObject<{
107
+ kind: z.ZodLiteral<"human">;
108
+ }, z.core.$strip>;
109
+ export type MintParticipantInput = z.infer<typeof mintParticipantSchema>;
package/dist/schemas.js CHANGED
@@ -1,12 +1,12 @@
1
1
  // Zod schemas for the Pane relay request shapes. These let callers (the CLI,
2
- // other clients) validate user-supplied input — e.g. an inline JSON artifact
2
+ // other clients) validate user-supplied input — e.g. an inline JSON template
3
3
  // or callback config — before it hits the relay, producing clear errors.
4
4
  import { z } from "zod";
5
- // The artifact `type` discriminant. `html-inline` carries raw HTML in `source`;
5
+ // The template `type` discriminant. `html-inline` carries raw HTML in `source`;
6
6
  // `html-ref` carries a URL. The relay rejects `html-ref` in this release.
7
7
  export const artifactTypeSchema = z.enum(["html-inline", "html-ref"]);
8
8
  // Discriminated on `type`: both require a non-empty `source`. Kept for callers
9
- // that want to validate a bare artifact (no event schema attached).
9
+ // that want to validate a bare template (no event schema attached).
10
10
  export const artifactSchema = z.discriminatedUnion("type", [
11
11
  z.object({ type: z.literal("html-inline"), source: z.string().min(1) }),
12
12
  z.object({ type: z.literal("html-ref"), source: z.string().min(1) }),
@@ -16,24 +16,32 @@ export const callbackSchema = z.object({
16
16
  events: z.array(z.string().min(1)).min(1),
17
17
  secret: z.string().min(8),
18
18
  });
19
- // The inline artifact form for POST /v1/sessions — carries the event schema
20
- // INSIDE the artifact object (one-off, no registered artifact). The relay
21
- // transparently creates an anonymous artifact behind it.
19
+ // The inline template form for POST /v1/surfaces — carries the event schema
20
+ // INSIDE the template object (one-off, no registered template). The relay
21
+ // transparently creates an anonymous template behind it.
22
22
  const inlineArtifactSchema = z.object({
23
23
  source: z.string().min(1),
24
24
  type: artifactTypeSchema,
25
25
  // Optional: omit for a view-only one-off (a report/dashboard the human only
26
- // views — the session then accepts no page/agent events).
26
+ // views — the surface then accepts no page/agent events).
27
27
  event_schema: z.unknown().optional(),
28
+ // Optional: when present, the surface's `input_data` is validated against
29
+ // this JSON Schema before the surface row is created — and any attachment refs
30
+ // declared at `format: pane-attachment-id` sites become reachable from the page
31
+ // via `window.pane.downloadBlob()`. Without this, attachment refs in
32
+ // `input_data` are silently unreachable for inline surfaces (the
33
+ // participant attachment-download bridge walks input_data against the template
34
+ // version's inputSchema; no schema means no walkable sites). See #208.
35
+ input_schema: z.record(z.string(), z.unknown()).optional(),
28
36
  });
29
- // The reference form for POST /v1/sessions — instances an existing named
30
- // artifact. `id` accepts the artifact id or its slug; `version` is optional
31
- // and defaults to the artifact's latest version.
37
+ // The reference form for POST /v1/surfaces — instances an existing named
38
+ // template. `id` accepts the template id or its slug; `version` is optional
39
+ // and defaults to the template's latest version.
32
40
  const refArtifactSchema = z.object({
33
41
  id: z.string().min(1),
34
42
  version: z.number().int().positive().optional(),
35
43
  });
36
- // The session-create `artifact` field: exactly one of the two forms. A union
44
+ // The surface-create `template` field: exactly one of the two forms. A union
37
45
  // (not a discriminated union — the two forms share no discriminant key) with a
38
46
  // refine enforcing exactly-one-of `id` / `source`.
39
47
  const sessionArtifactSchema = z
@@ -43,17 +51,31 @@ const sessionArtifactSchema = z
43
51
  const hasSource = "source" in a && a.source !== undefined;
44
52
  return hasId !== hasSource;
45
53
  }, {
46
- message: "artifact must carry exactly one of `id` (reference an existing artifact) or `source` (inline a one-off artifact)",
54
+ message: "template must carry exactly one of `id` (reference an existing template) or `source` (inline a one-off template)",
47
55
  });
48
56
  export const createSessionSchema = z.object({
49
- artifact: sessionArtifactSchema,
50
- input_data: z.record(z.unknown()).optional(),
57
+ template: sessionArtifactSchema,
58
+ input_data: z.record(z.string(), z.unknown()).optional(),
51
59
  participants: z.object({ humans: z.number().int().positive() }).optional(),
52
60
  ttl: z.number().int().positive().optional(),
53
- metadata: z.record(z.unknown()).optional(),
61
+ metadata: z.record(z.string(), z.unknown()).optional(),
54
62
  callback: callbackSchema.optional(),
63
+ // Tab title for the human's browser. Optional on the wire because the relay
64
+ // also accepts the implicit fallback (an Template.name on the reference
65
+ // form). The relay enforces "required-or-fallback" + length/control-char
66
+ // rules — Zod only confirms it's a string here.
67
+ title: z.string().optional(),
68
+ // Phase G — natural-key dedup. When set, the relay collapses repeated
69
+ // creates with the same (template, owner, context_key) into one surface
70
+ // row. NULL = ad-hoc, no dedup. See HUMAN-SIDE-PROPOSAL.md §7.1.
71
+ context_key: z
72
+ .string()
73
+ .min(1)
74
+ .max(256)
75
+ .regex(/^[A-Za-z0-9_:.-]+$/, "context_key must be a short identifier")
76
+ .optional(),
55
77
  });
56
- // POST /v1/artifacts — create a named, reusable artifact plus its v1 content.
78
+ // POST /v1/templates — create a named, reusable template plus its v1 content.
57
79
  export const createArtifactSchema = z.object({
58
80
  name: z.string().min(1),
59
81
  slug: z.string().min(1).optional(),
@@ -61,19 +83,19 @@ export const createArtifactSchema = z.object({
61
83
  tags: z.array(z.string().min(1)).optional(),
62
84
  source: z.string().min(1),
63
85
  type: artifactTypeSchema,
64
- // Optional: omit for a view-only artifact (no event vocabulary).
86
+ // Optional: omit for a view-only template (no event vocabulary).
65
87
  event_schema: z.unknown().optional(),
66
- input_schema: z.record(z.unknown()).optional(),
88
+ input_schema: z.record(z.string(), z.unknown()).optional(),
67
89
  });
68
- // POST /v1/artifacts/:id/versions — append a new version (content only).
90
+ // POST /v1/templates/:id/versions — append a new version (content only).
69
91
  export const createArtifactVersionSchema = z.object({
70
92
  source: z.string().min(1),
71
93
  type: artifactTypeSchema,
72
- // Optional: omit for a view-only artifact (no event vocabulary).
94
+ // Optional: omit for a view-only template (no event vocabulary).
73
95
  event_schema: z.unknown().optional(),
74
- input_schema: z.record(z.unknown()).optional(),
96
+ input_schema: z.record(z.string(), z.unknown()).optional(),
75
97
  });
76
- // PATCH /v1/artifacts/:id — update head metadata only (never content).
98
+ // PATCH /v1/templates/:id — update head metadata only (never content).
77
99
  export const patchArtifactMetadataSchema = z.object({
78
100
  name: z.string().min(1).optional(),
79
101
  slug: z.string().min(1).optional(),
@@ -90,5 +112,21 @@ export const submitFeedbackSchema = z.object({
90
112
  .string()
91
113
  .transform((s) => s.trim())
92
114
  .pipe(z.string().min(1).max(4000)),
93
- session_id: z.string().min(1).optional(),
115
+ surface_id: z.string().min(1).optional(),
116
+ });
117
+ // GET /v1/surfaces — list the calling agent's surfaces. The relay also
118
+ // re-parses these on its side (defence in depth); this schema is for the CLI
119
+ // to fail fast with a clear error before a round trip.
120
+ export const listSessionsStatusSchema = z.enum(["open", "closed", "all"]);
121
+ export const listSessionsQuerySchema = z.object({
122
+ status: listSessionsStatusSchema.optional(),
123
+ limit: z.number().int().positive().max(200).optional(),
124
+ cursor: z.string().min(1).optional(),
125
+ template_id: z.string().min(1).optional(),
126
+ });
127
+ // POST /v1/surfaces/:id/participants — mint a fresh participant URL for an
128
+ // existing surface. v1 supports human participants only (the agent token is
129
+ // minted at surface-create and cannot be re-minted via this endpoint).
130
+ export const mintParticipantSchema = z.object({
131
+ kind: z.literal("human"),
94
132
  });
package/dist/stream.d.ts CHANGED
@@ -3,8 +3,8 @@ import type { PaneEvent } from "./types.js";
3
3
  export interface OpenStreamOptions {
4
4
  /** WebSocket base URL, e.g. wss://pane.example.com (no trailing slash). */
5
5
  wsBaseUrl: string;
6
- /** Session id. */
7
- sessionId: string;
6
+ /** Surface id. */
7
+ surfaceId: string;
8
8
  /** Agent (or participant) bearer token. */
9
9
  token: string;
10
10
  /** Opaque cursor: replay only events strictly after this id. */
@@ -32,7 +32,7 @@ export interface StreamHandlers {
32
32
  }
33
33
  /** A live handle to an open stream. */
34
34
  export interface StreamHandle {
35
- /** Send an event frame into the session. */
35
+ /** Send an event frame into the surface. */
36
36
  send(frame: {
37
37
  type: string;
38
38
  data?: unknown;
@@ -45,7 +45,7 @@ export interface StreamHandle {
45
45
  readonly socket: WebSocket;
46
46
  }
47
47
  /**
48
- * Open a WebSocket stream to a Pane session. Replays on connect, then streams
48
+ * Open a WebSocket stream to a Pane surface. Replays on connect, then streams
49
49
  * live. Returns a handle for sending frames and closing.
50
50
  */
51
51
  export declare function openStream(opts: OpenStreamOptions, handlers: StreamHandlers): StreamHandle;
package/dist/stream.js CHANGED
@@ -1,4 +1,4 @@
1
- // WebSocket client for WS /v1/sessions/:id/stream.
1
+ // WebSocket client for WS /v1/surfaces/:id/stream.
2
2
  //
3
3
  // The relay protocol (see the relay's src/ws/handler.ts):
4
4
  // - on connect, the relay replays every event since `?since=` (or from the
@@ -16,12 +16,12 @@
16
16
  import { WebSocket } from "ws";
17
17
  import { MAX_FRAME_SNIPPET_LENGTH } from "./limits.js";
18
18
  /**
19
- * Open a WebSocket stream to a Pane session. Replays on connect, then streams
19
+ * Open a WebSocket stream to a Pane surface. Replays on connect, then streams
20
20
  * live. Returns a handle for sending frames and closing.
21
21
  */
22
22
  export function openStream(opts, handlers) {
23
23
  const base = opts.wsBaseUrl.replace(/\/$/, "");
24
- const u = new URL(`${base}/v1/sessions/${encodeURIComponent(opts.sessionId)}/stream`);
24
+ const u = new URL(`${base}/v1/surfaces/${encodeURIComponent(opts.surfaceId)}/stream`);
25
25
  if (opts.since != null && opts.since !== "") {
26
26
  u.searchParams.set("since", opts.since);
27
27
  }