agent-canvas 0.9.0-dev.11 → 0.9.0-dev.12

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.
@@ -0,0 +1,56 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Structured answers a reviewer gives on a shared canvas: the wire shape the
4
+ * shared page sends with its feedback and the share worker validates. Kept
5
+ * apart from share-client.ts so the worker can import it without the
6
+ * encryption helpers.
7
+ */
8
+ export declare const MAX_SHARED_RESPONSES = 500;
9
+ export declare const MAX_SHARED_RESPONSE_TEXT = 10000;
10
+ /** A reviewer's answer to an input component (Choice, MultiChoice, UserInput, RangeInput) on the shared page. */
11
+ export declare const sharedResponseSchema: z.ZodObject<{
12
+ id: z.ZodString;
13
+ type: z.ZodEnum<["select", "radio", "checkbox", "text", "range"]>;
14
+ label: z.ZodString;
15
+ value: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodNumber, z.ZodNull]>;
16
+ note: z.ZodOptional<z.ZodString>;
17
+ }, "strip", z.ZodTypeAny, {
18
+ value: string | number | string[] | null;
19
+ type: "text" | "select" | "checkbox" | "radio" | "range";
20
+ id: string;
21
+ label: string;
22
+ note?: string | undefined;
23
+ }, {
24
+ value: string | number | string[] | null;
25
+ type: "text" | "select" | "checkbox" | "radio" | "range";
26
+ id: string;
27
+ label: string;
28
+ note?: string | undefined;
29
+ }>;
30
+ export type SharedResponse = z.infer<typeof sharedResponseSchema>;
31
+ export declare const sharedResponsesSchema: z.ZodArray<z.ZodObject<{
32
+ id: z.ZodString;
33
+ type: z.ZodEnum<["select", "radio", "checkbox", "text", "range"]>;
34
+ label: z.ZodString;
35
+ value: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodNumber, z.ZodNull]>;
36
+ note: z.ZodOptional<z.ZodString>;
37
+ }, "strip", z.ZodTypeAny, {
38
+ value: string | number | string[] | null;
39
+ type: "text" | "select" | "checkbox" | "radio" | "range";
40
+ id: string;
41
+ label: string;
42
+ note?: string | undefined;
43
+ }, {
44
+ value: string | number | string[] | null;
45
+ type: "text" | "select" | "checkbox" | "radio" | "range";
46
+ id: string;
47
+ label: string;
48
+ note?: string | undefined;
49
+ }>, "many">;
50
+ /**
51
+ * The answered inputs of a draft, as the shared page sends them. A response
52
+ * that does not fit the wire shape (an unknown type, a label over 1000
53
+ * characters, no `value` key even with a note), or has neither a value nor a
54
+ * note, is left out.
55
+ */
56
+ export declare function answeredResponses(responses: readonly unknown[]): SharedResponse[];
@@ -1,5 +1,6 @@
1
1
  import type { SessionManager, ShareEntry } from '@fabrika/canvas-kernel/server';
2
- import { type EncryptionMeta } from '../client/shareCrypto';
2
+ import { type SharePayload, type ShareResponse } from './share-client';
3
+ export { encryptSharePayload, type SharePayload, type ShareResponse } from './share-client';
3
4
  /**
4
5
  * Canvas sharing: packages a specific revision into a self-contained
5
6
  * snapshot and POSTs it to the configured cloud endpoint (CF Worker).
@@ -24,31 +25,6 @@ import { type EncryptionMeta } from '../client/shareCrypto';
24
25
  * formats, and the browser detects which one to use based on the URL
25
26
  * fragment.
26
27
  */
27
- export interface SharePayload {
28
- version: 1;
29
- /** Present iff payload fields below are ciphertext rather than plaintext. */
30
- encryption?: EncryptionMeta;
31
- origin: {
32
- sessionId: string;
33
- revision: number;
34
- label?: string;
35
- createdAt: string;
36
- };
37
- canvasFiles: Array<{
38
- filename: string;
39
- compiledJs: string;
40
- sourceJsx?: string;
41
- }>;
42
- runtime: {
43
- componentsVersion: string;
44
- };
45
- }
46
- export interface ShareResponse {
47
- shareId: string;
48
- url: string;
49
- ownerToken?: string;
50
- expiresAt?: string;
51
- }
52
28
  export interface ShareConfig {
53
29
  /** Base URL of the share worker, e.g. `https://canvas-share.example.workers.dev` */
54
30
  endpoint: string;
@@ -67,22 +43,7 @@ export declare function loadShareConfig(version: string): ShareConfig | null;
67
43
  * original JSX source for "view source" functionality on the shared canvas.
68
44
  */
69
45
  export declare function buildSharePayload(sessionManager: SessionManager, sessionId: string, revision: number, componentsVersion: string): SharePayload;
70
- /**
71
- * Encrypt a plaintext SharePayload in-place semantics, returning a new
72
- * payload whose secret fields are ciphertext + the `encryption` marker.
73
- * Fields kept plaintext (and why):
74
- * - `version`, `runtime.componentsVersion`: routing
75
- * - `origin.revision`, `origin.createdAt`: indexing/display
76
- * - `canvasFiles[].filename`: used as the route key by the worker
77
- * Everything else (sessionId, label, compiledJs, sourceJsx) is encrypted.
78
- */
79
- export declare function encryptSharePayload(payload: SharePayload, key: CryptoKey): Promise<SharePayload>;
80
- /**
81
- * POST the payload to the CF Worker. Returns the `shareId` + public URL
82
- * assigned by the worker. Throws on any HTTP error — the caller is expected
83
- * to surface the failure to the client (dialog) so the user can retry or
84
- * fix their config.
85
- */
46
+ /** POST the payload to the configured worker (see share-client.ts). */
86
47
  export declare function pushShareToWorker(payload: SharePayload, config: ShareConfig): Promise<ShareResponse>;
87
48
  /**
88
49
  * High-level: build payload, optionally encrypt it, push to worker, record
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Annotation image uploads, shared by the local daemon and the canvas-share worker: which images an upload may carry
3
+ * and how a stored upload is served. Runtime-neutral (Bun and workerd).
4
+ */
5
+ /** Raster formats only: an SVG or any other active document would run script on the serving origin. */
6
+ declare const UPLOAD_IMAGE_TYPES: {
7
+ readonly 'image/png': "png";
8
+ readonly 'image/jpeg': "jpg";
9
+ readonly 'image/gif': "gif";
10
+ readonly 'image/webp': "webp";
11
+ };
12
+ export type UploadImageType = keyof typeof UPLOAD_IMAGE_TYPES;
13
+ export interface UploadImage {
14
+ type: UploadImageType;
15
+ extension: (typeof UPLOAD_IMAGE_TYPES)[UploadImageType];
16
+ }
17
+ export declare const UPLOAD_IMAGE_REFUSED = "Only PNG, JPEG, GIF and WebP images are accepted";
18
+ /**
19
+ * The image an upload carries, or null when its content is not an accepted raster format. The content's signature
20
+ * alone decides: a declared type means different things per runtime (Bun derives it from the file name).
21
+ */
22
+ export declare function parseUploadImage(bytes: Uint8Array): UploadImage | null;
23
+ /** The accepted type a stored upload's file extension names. */
24
+ export declare function uploadImageTypeOfExtension(extension: string): UploadImageType | undefined;
25
+ /**
26
+ * Response headers for a stored upload. Every upload is served inert (no sniffing, no script, sandboxed), which also
27
+ * covers files stored before the type allowlist; a type outside the allowlist is served as a download.
28
+ */
29
+ export declare function uploadServeHeaders(storedType: string | undefined): Record<string, string>;
30
+ export {};