agent-canvas 0.9.0-dev.13 → 0.9.0-dev.14
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/README.md +28 -0
- package/bin/agent-canvas.ts +8 -1
- package/bin/lib/cli-auth.ts +31 -0
- package/bin/lib/commands/daemon.ts +2 -1
- package/bin/lib/commands/exec.ts +5 -4
- package/bin/lib/commands/fetch.ts +4 -4
- package/bin/lib/commands/push.ts +3 -2
- package/bin/lib/commands/reply.ts +45 -0
- package/bin/lib/commands/review.ts +4 -2
- package/bin/lib/commands/watch.ts +100 -5
- package/bin/lib/helpers.ts +121 -43
- package/bin/lib/instructions/component-download.md +28 -0
- package/bin/lib/instructions/component-filedrop.md +50 -0
- package/bin/lib/instructions/overview.md +41 -1
- package/bin/lib/instructions/template-dashboard.md +177 -0
- package/bin/lib/instructions/template-slides.md +196 -0
- package/bin/lib/instructions/theming.md +25 -0
- package/daemon/client/App.tsx +17 -5
- package/daemon/client/clientApi.ts +64 -5
- package/daemon/client/components/Download.tsx +28 -0
- package/daemon/client/components/FileDrop.tsx +164 -0
- package/daemon/client/components/index.ts +3 -1
- package/daemon/client/threadStore.ts +70 -0
- package/daemon/dist/client.css +1 -1
- package/daemon/dist/client.js +57 -56
- package/daemon/dist/components.js +52 -49
- package/daemon/src/admission.ts +102 -0
- package/daemon/src/assets.ts +16 -0
- package/daemon/src/components.ts +6 -1
- package/daemon/src/handlers/api.ts +7 -4
- package/daemon/src/handlers/assets.ts +126 -0
- package/daemon/src/handlers/files.ts +124 -19
- package/daemon/src/handlers/static.ts +65 -1
- package/daemon/src/handlers/theme.ts +150 -0
- package/daemon/src/handlers/threads.ts +93 -0
- package/daemon/src/review/server.ts +1 -1
- package/daemon/src/server.ts +81 -47
- package/daemon/src/threads.ts +132 -0
- package/package.json +4 -4
- package/skills/canvas/SKILL.md +5 -0
- package/types/bin/lib/cli-auth.d.ts +9 -0
- package/types/bin/lib/commands/reply.d.ts +2 -0
- package/types/bin/lib/commands/watch.d.ts +3 -1
- package/types/bin/lib/helpers.d.ts +102 -0
- package/types/daemon/client/clientApi.d.ts +14 -1
- package/types/daemon/client/components/Download.d.ts +9 -0
- package/types/daemon/client/components/FileDrop.d.ts +12 -0
- package/types/daemon/client/components/index.d.ts +2 -0
- package/types/daemon/client/threadStore.d.ts +15 -0
- package/types/daemon/src/admission.d.ts +24 -0
- package/types/daemon/src/assets.d.ts +23 -0
- package/types/daemon/src/components.d.ts +3 -1
- package/types/daemon/src/handlers/assets.d.ts +14 -0
- package/types/daemon/src/handlers/files.d.ts +8 -2
- package/types/daemon/src/handlers/static.d.ts +16 -0
- package/types/daemon/src/handlers/theme.d.ts +18 -0
- package/types/daemon/src/handlers/threads.d.ts +19 -0
- package/types/daemon/src/review/model.d.ts +24 -24
- package/types/daemon/src/review/remote.d.ts +8 -8
- package/types/daemon/src/review/server.d.ts +2 -0
- package/types/daemon/src/threads.d.ts +109 -0
|
@@ -1,13 +1,115 @@
|
|
|
1
1
|
import { type WaiterSocket } from '@fabrika/daemon-kit';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
export declare function getSessionId(session?: string): string;
|
|
3
4
|
export declare function consumeFeedback(sessionId: string): Promise<string | null>;
|
|
5
|
+
/** The thread replies the user sent since the last claim, as markdown; each is handed over once. */
|
|
6
|
+
export declare function claimThreadReplies(sessionId: string): Promise<string | null>;
|
|
7
|
+
/** What the user sent and the agent has not read yet: a submit first, then thread replies. */
|
|
8
|
+
export declare function pendingInput(sessionId: string): Promise<string | null>;
|
|
4
9
|
export declare function openBrowser(url: string): void;
|
|
5
10
|
interface FeedbackWaitOptions {
|
|
6
11
|
createSocket?: (url: string) => WaiterSocket;
|
|
12
|
+
/** Reads input the socket only announces (a thread reply) or that arrived while it was reconnecting. */
|
|
13
|
+
probe?: () => Promise<string | null>;
|
|
7
14
|
timeoutMs?: number;
|
|
8
15
|
reconnectAttempts?: number;
|
|
9
16
|
reconnectDelayMs?: number;
|
|
10
17
|
}
|
|
18
|
+
declare const canvasRenderErrorSchema: z.ZodObject<{
|
|
19
|
+
revision: z.ZodNumber;
|
|
20
|
+
filename: z.ZodString;
|
|
21
|
+
message: z.ZodString;
|
|
22
|
+
stack: z.ZodOptional<z.ZodString>;
|
|
23
|
+
componentStack: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
message: string;
|
|
26
|
+
revision: number;
|
|
27
|
+
filename: string;
|
|
28
|
+
stack?: string | undefined;
|
|
29
|
+
componentStack?: string | undefined;
|
|
30
|
+
}, {
|
|
31
|
+
message: string;
|
|
32
|
+
revision: number;
|
|
33
|
+
filename: string;
|
|
34
|
+
stack?: string | undefined;
|
|
35
|
+
componentStack?: string | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
type CanvasRenderError = z.infer<typeof canvasRenderErrorSchema>;
|
|
38
|
+
/** What the daemon sends a waiting CLI. */
|
|
39
|
+
declare const waitFrameSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
40
|
+
type: z.ZodLiteral<"submit">;
|
|
41
|
+
feedback: z.ZodString;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
type: "submit";
|
|
44
|
+
feedback: string;
|
|
45
|
+
}, {
|
|
46
|
+
type: "submit";
|
|
47
|
+
feedback: string;
|
|
48
|
+
}>, z.ZodObject<{
|
|
49
|
+
type: z.ZodLiteral<"render-error">;
|
|
50
|
+
error: z.ZodObject<{
|
|
51
|
+
revision: z.ZodNumber;
|
|
52
|
+
filename: z.ZodString;
|
|
53
|
+
message: z.ZodString;
|
|
54
|
+
stack: z.ZodOptional<z.ZodString>;
|
|
55
|
+
componentStack: z.ZodOptional<z.ZodString>;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
message: string;
|
|
58
|
+
revision: number;
|
|
59
|
+
filename: string;
|
|
60
|
+
stack?: string | undefined;
|
|
61
|
+
componentStack?: string | undefined;
|
|
62
|
+
}, {
|
|
63
|
+
message: string;
|
|
64
|
+
revision: number;
|
|
65
|
+
filename: string;
|
|
66
|
+
stack?: string | undefined;
|
|
67
|
+
componentStack?: string | undefined;
|
|
68
|
+
}>;
|
|
69
|
+
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
error: {
|
|
71
|
+
message: string;
|
|
72
|
+
revision: number;
|
|
73
|
+
filename: string;
|
|
74
|
+
stack?: string | undefined;
|
|
75
|
+
componentStack?: string | undefined;
|
|
76
|
+
};
|
|
77
|
+
type: "render-error";
|
|
78
|
+
}, {
|
|
79
|
+
error: {
|
|
80
|
+
message: string;
|
|
81
|
+
revision: number;
|
|
82
|
+
filename: string;
|
|
83
|
+
stack?: string | undefined;
|
|
84
|
+
componentStack?: string | undefined;
|
|
85
|
+
};
|
|
86
|
+
type: "render-error";
|
|
87
|
+
}>, z.ZodObject<{
|
|
88
|
+
type: z.ZodLiteral<"thread-queued">;
|
|
89
|
+
}, "strip", z.ZodTypeAny, {
|
|
90
|
+
type: "thread-queued";
|
|
91
|
+
}, {
|
|
92
|
+
type: "thread-queued";
|
|
93
|
+
}>, z.ZodObject<{
|
|
94
|
+
type: z.ZodLiteral<"remote-feedback-arrived">;
|
|
95
|
+
revision: z.ZodNumber;
|
|
96
|
+
count: z.ZodNumber;
|
|
97
|
+
reviewers: z.ZodArray<z.ZodString, "many">;
|
|
98
|
+
}, "strip", z.ZodTypeAny, {
|
|
99
|
+
type: "remote-feedback-arrived";
|
|
100
|
+
revision: number;
|
|
101
|
+
count: number;
|
|
102
|
+
reviewers: string[];
|
|
103
|
+
}, {
|
|
104
|
+
type: "remote-feedback-arrived";
|
|
105
|
+
revision: number;
|
|
106
|
+
count: number;
|
|
107
|
+
reviewers: string[];
|
|
108
|
+
}>]>;
|
|
109
|
+
export type WaitFrame = z.infer<typeof waitFrameSchema>;
|
|
110
|
+
/** A frame the CLI understands, or null for anything else (a keepalive, a newer daemon's frame). */
|
|
111
|
+
export declare function parseWaitFrame(frame: unknown): WaitFrame | null;
|
|
112
|
+
export declare function formatCanvasRenderError(error: CanvasRenderError): string;
|
|
11
113
|
export declare function waitForFeedback(sessionId: string, options?: FeedbackWaitOptions): Promise<string>;
|
|
12
114
|
export declare function readLine(): Promise<string>;
|
|
13
115
|
export {};
|
|
@@ -21,9 +21,11 @@
|
|
|
21
21
|
* work in cleartext.
|
|
22
22
|
*/
|
|
23
23
|
import type { CanvasHost } from '@fabrika/canvas-kernel/client';
|
|
24
|
+
import { type StoredAsset } from '../src/assets';
|
|
24
25
|
import type { SharedResponse } from '../src/share-responses';
|
|
25
26
|
import { type SessionMeta } from './apiSchemas';
|
|
26
27
|
import { type EncryptionMeta } from './shareCrypto';
|
|
28
|
+
import { type LocalThreadStore } from './threadStore';
|
|
27
29
|
declare global {
|
|
28
30
|
interface Window {
|
|
29
31
|
__CANVAS_SHARE__?: {
|
|
@@ -57,6 +59,16 @@ export declare function metaUrl(): string;
|
|
|
57
59
|
export declare function canvasJsUrl(filename: string, revision?: number): string;
|
|
58
60
|
/** Upload endpoint for annotation images. */
|
|
59
61
|
export declare function uploadUrl(): string;
|
|
62
|
+
export type { StoredAsset };
|
|
63
|
+
/** The files the user dropped on one `FileDrop` field of this session. */
|
|
64
|
+
export declare function listLocalAssets(fieldId: string): Promise<StoredAsset[]>;
|
|
65
|
+
export declare function uploadLocalAsset(fieldId: string, file: File): Promise<StoredAsset>;
|
|
66
|
+
export declare function deleteLocalAsset(fieldId: string, assetId: string): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Applies the project's `.agent-canvas/theme.css`, as the daemon rebuilt it, after the base theme. A theme the daemon
|
|
69
|
+
* refuses leaves the base theme and a console warning that says why.
|
|
70
|
+
*/
|
|
71
|
+
export declare function applyProjectTheme(): Promise<void>;
|
|
60
72
|
/** Return only readiness metadata. The secret value is never sent back to the browser. */
|
|
61
73
|
export declare function getLocalSecretStatus(fieldId: string): Promise<boolean>;
|
|
62
74
|
/** Deposit a secret into the daemon's in-memory vault. */
|
|
@@ -114,10 +126,11 @@ export declare function submitSharedFeedback(payload: SharedFeedbackPayload): Pr
|
|
|
114
126
|
export declare const FS_AVAILABLE: boolean;
|
|
115
127
|
/** Is live WebSocket session updates available? */
|
|
116
128
|
export declare const WS_AVAILABLE: boolean;
|
|
129
|
+
/** The session's threads; a shared canvas has none, its reviewers' feedback goes through the author. */
|
|
130
|
+
export declare const threadStore: LocalThreadStore | null;
|
|
117
131
|
/**
|
|
118
132
|
* What the kernel's annotation surface needs from this host. agent-canvas
|
|
119
133
|
* serves canvases in two modes, so these cannot use the kernel's local-only
|
|
120
134
|
* defaults: shared canvases come from the worker (and may be encrypted).
|
|
121
135
|
*/
|
|
122
136
|
export declare const canvasHost: CanvasHost;
|
|
123
|
-
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface DownloadProps {
|
|
2
|
+
/** A file you produced, as an absolute path or one relative to the project root. Write it as a string literal. */
|
|
3
|
+
path: string;
|
|
4
|
+
/** The link text; the file name by default. */
|
|
5
|
+
label?: string;
|
|
6
|
+
}
|
|
7
|
+
/** A file the agent hands the user. The daemon serves only a path a canvas of the session names as a literal. */
|
|
8
|
+
export declare function Download({ path, label }: DownloadProps): import("react").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface FileDropProps {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
/** File types the picker offers, as in `<input accept>`. A hint for the picker, not a check. */
|
|
5
|
+
accept?: string;
|
|
6
|
+
/** Largest file accepted, in bytes. */
|
|
7
|
+
maxBytes?: number;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** Files the user hands the agent. The daemon keeps them with the session; the feedback names their paths. */
|
|
11
|
+
export declare function FileDrop({ id, label, accept, maxBytes, required }: FileDropProps): import("react").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CanvasThreads } from '@fabrika/canvas-kernel/client';
|
|
2
|
+
import { type CanvasThread } from '../src/threads';
|
|
3
|
+
export interface LocalThreadStore extends CanvasThreads {
|
|
4
|
+
/** Reads the session's threads, e.g. after the socket (re)connects. */
|
|
5
|
+
load: () => Promise<void>;
|
|
6
|
+
/** A `threads` frame's payload from the session socket. */
|
|
7
|
+
receive: (threads: unknown) => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The newer copy of each thread, in the current order. Responses and socket frames can arrive out of order (a POST's
|
|
11
|
+
* response after the frame for the agent's claim), and threads are never deleted, so none is dropped.
|
|
12
|
+
*/
|
|
13
|
+
export declare function mergeThreads(current: readonly CanvasThread[], incoming: readonly CanvasThread[]): readonly CanvasThread[];
|
|
14
|
+
/** The local daemon's threads for one session, kept current by its socket. */
|
|
15
|
+
export declare function createThreadStore(sessionId: string): LocalThreadStore;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** The header the CLI sends its capability in; the daemon writes the capability to `CLI_AUTH_FILE`. */
|
|
2
|
+
export declare const CLI_TOKEN_HEADER = "X-Agent-Canvas-CLI-Token";
|
|
3
|
+
/**
|
|
4
|
+
* The query parameter a CLI WebSocket upgrade carries the capability in. Bun's client sends headers on an upgrade, but
|
|
5
|
+
* the CLI is typed against the DOM `WebSocket`, whose constructor takes none.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CLI_TOKEN_QUERY = "cli_token";
|
|
8
|
+
export interface AdmissionOptions {
|
|
9
|
+
port: number;
|
|
10
|
+
cliAuthToken: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function hasCliToken(req: Request, cliAuthToken: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Admission for every request the daemon receives, before any route or WebSocket upgrade:
|
|
15
|
+
* - the Host must name the daemon on loopback, which refuses DNS-rebound pages;
|
|
16
|
+
* - a request that changes state, and every WebSocket upgrade, must come from the daemon's own UI or from a client that
|
|
17
|
+
* sends no `Origin` (the CLI); browsers send `Origin` on such requests, so a cross-site page is refused whatever the
|
|
18
|
+
* content type;
|
|
19
|
+
* - every API request and upgrade a browser sends must be same-origin (`Sec-Fetch-Site`), reads included;
|
|
20
|
+
* - CLI routes require the CLI capability.
|
|
21
|
+
*
|
|
22
|
+
* Returns the refusal, or null when the request is admitted.
|
|
23
|
+
*/
|
|
24
|
+
export declare function admitRequest(req: Request, url: URL, options: AdmissionOptions): Response | null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Shared by the daemon's asset routes and `<FileDrop>`; this module stays free of Node APIs so the client can load it. */
|
|
3
|
+
/** The daemon's per-file limit; a canvas may set a lower one. */
|
|
4
|
+
export declare const MAX_ASSET_BYTES: number;
|
|
5
|
+
export declare const ASSET_FIELD_ID_RE: RegExp;
|
|
6
|
+
export declare const storedAssetSchema: z.ZodObject<{
|
|
7
|
+
/** The stored file's name: a time-ordered random prefix and the sanitised original name. */
|
|
8
|
+
id: z.ZodString;
|
|
9
|
+
name: z.ZodString;
|
|
10
|
+
path: z.ZodString;
|
|
11
|
+
size: z.ZodNumber;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
size: number;
|
|
14
|
+
name: string;
|
|
15
|
+
path: string;
|
|
16
|
+
id: string;
|
|
17
|
+
}, {
|
|
18
|
+
size: number;
|
|
19
|
+
name: string;
|
|
20
|
+
path: string;
|
|
21
|
+
id: string;
|
|
22
|
+
}>;
|
|
23
|
+
export type StoredAsset = z.infer<typeof storedAssetSchema>;
|
|
@@ -6,5 +6,7 @@
|
|
|
6
6
|
* through `#canvas/components`. A name here with no matching export renders as
|
|
7
7
|
* undefined.
|
|
8
8
|
*/
|
|
9
|
-
import type { CanvasComponents } from '@fabrika/canvas-kernel/server';
|
|
9
|
+
import type { CanvasComponents, FileReferenceProp } from '@fabrika/canvas-kernel/server';
|
|
10
10
|
export declare const HOST_COMPONENTS: CanvasComponents;
|
|
11
|
+
/** Host component props that name a local file, beside the kernel's; the file routes serve what they name. */
|
|
12
|
+
export declare const HOST_FILE_REFERENCE_PROPS: readonly FileReferenceProp[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SessionManager } from '@fabrika/canvas-kernel/server';
|
|
2
|
+
import { type Route } from '@fabrika/daemon-kit';
|
|
3
|
+
import { MAX_ASSET_BYTES } from '../assets';
|
|
4
|
+
/**
|
|
5
|
+
* Files the user hands the agent through `<FileDrop>`: `sessions/<id>/assets/<field>/<uuid>-<name>`. The feedback
|
|
6
|
+
* names their absolute paths and the agent reads them with its own tools. Nothing here serves a file back, so an
|
|
7
|
+
* upload is never rendered as a page or a script. Files are kept until the session directory is removed.
|
|
8
|
+
*/
|
|
9
|
+
export { MAX_ASSET_BYTES };
|
|
10
|
+
export declare const MAX_SESSION_ASSET_BYTES: number;
|
|
11
|
+
export declare const MAX_SESSION_ASSETS = 100;
|
|
12
|
+
/** The original name as a file name that is safe on every platform, needs no URL encoding and is never a path. */
|
|
13
|
+
export declare function safeAssetName(name: string): string;
|
|
14
|
+
export declare function createAssetHandlers(sessionManager: SessionManager): Route[];
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type SessionManager } from '@fabrika/canvas-kernel/server';
|
|
2
2
|
import { type Route } from '@fabrika/daemon-kit';
|
|
3
|
-
export
|
|
3
|
+
export interface FileHandlerOptions {
|
|
4
|
+
/** Directories whose contents the file routes never return: the daemon's own state. */
|
|
5
|
+
deniedRoots: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
/** `attachment` with an ASCII fallback name and the exact one in RFC 5987 form. */
|
|
8
|
+
export declare function attachmentDisposition(name: string): string;
|
|
9
|
+
export declare function createFileHandlers(sessionManager: SessionManager, options: FileHandlerOptions): Route[];
|
|
@@ -1,2 +1,18 @@
|
|
|
1
1
|
import type { Route } from '@fabrika/daemon-kit';
|
|
2
|
+
/**
|
|
3
|
+
* The canvas page's policy, derived from the page: scripts from the daemon, its inline scripts by hash, its external ones
|
|
4
|
+
* by URL, and connections only to the daemon. Images, fonts, styles, media and navigation can still carry data out.
|
|
5
|
+
*/
|
|
6
|
+
export declare function sessionPageCsp(html: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Every other response is a document in the daemon's origin when opened in a frame or window. Without a policy of its
|
|
9
|
+
* own it would let canvas JavaScript script it past the page's `connect-src`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const INERT_DOCUMENT_CSP = "default-src 'none'; frame-ancestors 'none'; sandbox";
|
|
12
|
+
export declare function withDefaultCsp(response: Response): Response;
|
|
13
|
+
/** The daemon's `Bun.serve` error options, shared with the test that holds them to an inert answer. */
|
|
14
|
+
export declare const serveErrorOptions: {
|
|
15
|
+
development: false;
|
|
16
|
+
error: (error: Error) => Response;
|
|
17
|
+
};
|
|
2
18
|
export declare function createStaticHandlers(): Route[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SessionManager } from '@fabrika/canvas-kernel/server';
|
|
2
|
+
import { type Route } from '@fabrika/daemon-kit';
|
|
3
|
+
/**
|
|
4
|
+
* A project's brand for its canvases: `<projectRoot>/.agent-canvas/theme.css`, served after the base theme. Only
|
|
5
|
+
* `--color-*` and `--font-*` custom properties on `:root` or a `[data-theme]` mode are accepted, and the daemon serves
|
|
6
|
+
* its own rebuild of them, never the file's text, so a theme cannot load a URL, import a stylesheet or style the page.
|
|
7
|
+
*/
|
|
8
|
+
export declare const PROJECT_THEME_PATH: string;
|
|
9
|
+
export type ThemeResult = {
|
|
10
|
+
ok: true;
|
|
11
|
+
css: string;
|
|
12
|
+
} | {
|
|
13
|
+
ok: false;
|
|
14
|
+
error: string;
|
|
15
|
+
};
|
|
16
|
+
/** The project theme as the daemon serves it, or why it is refused. A refused theme is not served at all. */
|
|
17
|
+
export declare function parseProjectTheme(source: string): ThemeResult;
|
|
18
|
+
export declare function createThemeHandlers(sessionManager: SessionManager): Route[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type Route } from '@fabrika/daemon-kit';
|
|
2
|
+
import { type CanvasThreadStore } from '../threads';
|
|
3
|
+
export interface ThreadRoutesContext {
|
|
4
|
+
store: CanvasThreadStore;
|
|
5
|
+
/** Sends the session's threads to its browsers. */
|
|
6
|
+
broadcast: (sessionId: string, frame: {
|
|
7
|
+
type: 'threads';
|
|
8
|
+
threads: unknown;
|
|
9
|
+
}) => void;
|
|
10
|
+
/** Tells the session's waiting CLI that the user answered a thread. */
|
|
11
|
+
notifyWaiters: (sessionId: string, frame: {
|
|
12
|
+
type: 'thread-queued';
|
|
13
|
+
}) => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Threads on submitted annotations. `reply` and `claim` are the CLI's (admission requires its capability); the
|
|
17
|
+
* browser lists threads, answers them and resolves them.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createThreadHandlers(ctx: ThreadRoutesContext): Route[];
|
|
@@ -129,8 +129,8 @@ export declare const reviewAnchorSchema: z.ZodObject<{
|
|
|
129
129
|
colorScheme: "light" | "dark";
|
|
130
130
|
} | undefined;
|
|
131
131
|
name?: string | undefined;
|
|
132
|
-
role?: string | undefined;
|
|
133
132
|
text?: string | undefined;
|
|
133
|
+
role?: string | undefined;
|
|
134
134
|
components?: string[] | undefined;
|
|
135
135
|
sources?: {
|
|
136
136
|
label: string;
|
|
@@ -159,8 +159,8 @@ export declare const reviewAnchorSchema: z.ZodObject<{
|
|
|
159
159
|
colorScheme: "light" | "dark";
|
|
160
160
|
} | undefined;
|
|
161
161
|
name?: string | undefined;
|
|
162
|
-
role?: string | undefined;
|
|
163
162
|
text?: string | undefined;
|
|
163
|
+
role?: string | undefined;
|
|
164
164
|
components?: string[] | undefined;
|
|
165
165
|
sources?: {
|
|
166
166
|
label: string;
|
|
@@ -304,8 +304,8 @@ export declare const reviewThreadSchema: z.ZodObject<{
|
|
|
304
304
|
colorScheme: "light" | "dark";
|
|
305
305
|
} | undefined;
|
|
306
306
|
name?: string | undefined;
|
|
307
|
-
role?: string | undefined;
|
|
308
307
|
text?: string | undefined;
|
|
308
|
+
role?: string | undefined;
|
|
309
309
|
components?: string[] | undefined;
|
|
310
310
|
sources?: {
|
|
311
311
|
label: string;
|
|
@@ -334,8 +334,8 @@ export declare const reviewThreadSchema: z.ZodObject<{
|
|
|
334
334
|
colorScheme: "light" | "dark";
|
|
335
335
|
} | undefined;
|
|
336
336
|
name?: string | undefined;
|
|
337
|
-
role?: string | undefined;
|
|
338
337
|
text?: string | undefined;
|
|
338
|
+
role?: string | undefined;
|
|
339
339
|
components?: string[] | undefined;
|
|
340
340
|
sources?: {
|
|
341
341
|
label: string;
|
|
@@ -387,8 +387,8 @@ export declare const reviewThreadSchema: z.ZodObject<{
|
|
|
387
387
|
colorScheme: "light" | "dark";
|
|
388
388
|
} | undefined;
|
|
389
389
|
name?: string | undefined;
|
|
390
|
-
role?: string | undefined;
|
|
391
390
|
text?: string | undefined;
|
|
391
|
+
role?: string | undefined;
|
|
392
392
|
components?: string[] | undefined;
|
|
393
393
|
sources?: {
|
|
394
394
|
label: string;
|
|
@@ -406,8 +406,8 @@ export declare const reviewThreadSchema: z.ZodObject<{
|
|
|
406
406
|
} | undefined;
|
|
407
407
|
};
|
|
408
408
|
id: string;
|
|
409
|
+
state: "open" | "resolved" | "queued" | "working";
|
|
409
410
|
createdAt: string;
|
|
410
|
-
state: "open" | "queued" | "working" | "resolved";
|
|
411
411
|
comments: {
|
|
412
412
|
id: string;
|
|
413
413
|
author: "user" | "agent";
|
|
@@ -430,8 +430,8 @@ export declare const reviewThreadSchema: z.ZodObject<{
|
|
|
430
430
|
colorScheme: "light" | "dark";
|
|
431
431
|
} | undefined;
|
|
432
432
|
name?: string | undefined;
|
|
433
|
-
role?: string | undefined;
|
|
434
433
|
text?: string | undefined;
|
|
434
|
+
role?: string | undefined;
|
|
435
435
|
components?: string[] | undefined;
|
|
436
436
|
sources?: {
|
|
437
437
|
label: string;
|
|
@@ -449,8 +449,8 @@ export declare const reviewThreadSchema: z.ZodObject<{
|
|
|
449
449
|
} | undefined;
|
|
450
450
|
};
|
|
451
451
|
id: string;
|
|
452
|
+
state: "open" | "resolved" | "queued" | "working";
|
|
452
453
|
createdAt: string;
|
|
453
|
-
state: "open" | "queued" | "working" | "resolved";
|
|
454
454
|
comments: {
|
|
455
455
|
id: string;
|
|
456
456
|
author: "user" | "agent";
|
|
@@ -561,8 +561,8 @@ export declare const reviewThreadsFileSchema: z.ZodObject<{
|
|
|
561
561
|
colorScheme: "light" | "dark";
|
|
562
562
|
} | undefined;
|
|
563
563
|
name?: string | undefined;
|
|
564
|
-
role?: string | undefined;
|
|
565
564
|
text?: string | undefined;
|
|
565
|
+
role?: string | undefined;
|
|
566
566
|
components?: string[] | undefined;
|
|
567
567
|
sources?: {
|
|
568
568
|
label: string;
|
|
@@ -591,8 +591,8 @@ export declare const reviewThreadsFileSchema: z.ZodObject<{
|
|
|
591
591
|
colorScheme: "light" | "dark";
|
|
592
592
|
} | undefined;
|
|
593
593
|
name?: string | undefined;
|
|
594
|
-
role?: string | undefined;
|
|
595
594
|
text?: string | undefined;
|
|
595
|
+
role?: string | undefined;
|
|
596
596
|
components?: string[] | undefined;
|
|
597
597
|
sources?: {
|
|
598
598
|
label: string;
|
|
@@ -644,8 +644,8 @@ export declare const reviewThreadsFileSchema: z.ZodObject<{
|
|
|
644
644
|
colorScheme: "light" | "dark";
|
|
645
645
|
} | undefined;
|
|
646
646
|
name?: string | undefined;
|
|
647
|
-
role?: string | undefined;
|
|
648
647
|
text?: string | undefined;
|
|
648
|
+
role?: string | undefined;
|
|
649
649
|
components?: string[] | undefined;
|
|
650
650
|
sources?: {
|
|
651
651
|
label: string;
|
|
@@ -663,8 +663,8 @@ export declare const reviewThreadsFileSchema: z.ZodObject<{
|
|
|
663
663
|
} | undefined;
|
|
664
664
|
};
|
|
665
665
|
id: string;
|
|
666
|
+
state: "open" | "resolved" | "queued" | "working";
|
|
666
667
|
createdAt: string;
|
|
667
|
-
state: "open" | "queued" | "working" | "resolved";
|
|
668
668
|
comments: {
|
|
669
669
|
id: string;
|
|
670
670
|
author: "user" | "agent";
|
|
@@ -687,8 +687,8 @@ export declare const reviewThreadsFileSchema: z.ZodObject<{
|
|
|
687
687
|
colorScheme: "light" | "dark";
|
|
688
688
|
} | undefined;
|
|
689
689
|
name?: string | undefined;
|
|
690
|
-
role?: string | undefined;
|
|
691
690
|
text?: string | undefined;
|
|
691
|
+
role?: string | undefined;
|
|
692
692
|
components?: string[] | undefined;
|
|
693
693
|
sources?: {
|
|
694
694
|
label: string;
|
|
@@ -706,8 +706,8 @@ export declare const reviewThreadsFileSchema: z.ZodObject<{
|
|
|
706
706
|
} | undefined;
|
|
707
707
|
};
|
|
708
708
|
id: string;
|
|
709
|
+
state: "open" | "resolved" | "queued" | "working";
|
|
709
710
|
createdAt: string;
|
|
710
|
-
state: "open" | "queued" | "working" | "resolved";
|
|
711
711
|
comments: {
|
|
712
712
|
id: string;
|
|
713
713
|
author: "user" | "agent";
|
|
@@ -732,8 +732,8 @@ export declare const reviewThreadsFileSchema: z.ZodObject<{
|
|
|
732
732
|
colorScheme: "light" | "dark";
|
|
733
733
|
} | undefined;
|
|
734
734
|
name?: string | undefined;
|
|
735
|
-
role?: string | undefined;
|
|
736
735
|
text?: string | undefined;
|
|
736
|
+
role?: string | undefined;
|
|
737
737
|
components?: string[] | undefined;
|
|
738
738
|
sources?: {
|
|
739
739
|
label: string;
|
|
@@ -751,8 +751,8 @@ export declare const reviewThreadsFileSchema: z.ZodObject<{
|
|
|
751
751
|
} | undefined;
|
|
752
752
|
};
|
|
753
753
|
id: string;
|
|
754
|
+
state: "open" | "resolved" | "queued" | "working";
|
|
754
755
|
createdAt: string;
|
|
755
|
-
state: "open" | "queued" | "working" | "resolved";
|
|
756
756
|
comments: {
|
|
757
757
|
id: string;
|
|
758
758
|
author: "user" | "agent";
|
|
@@ -777,8 +777,8 @@ export declare const reviewThreadsFileSchema: z.ZodObject<{
|
|
|
777
777
|
colorScheme: "light" | "dark";
|
|
778
778
|
} | undefined;
|
|
779
779
|
name?: string | undefined;
|
|
780
|
-
role?: string | undefined;
|
|
781
780
|
text?: string | undefined;
|
|
781
|
+
role?: string | undefined;
|
|
782
782
|
components?: string[] | undefined;
|
|
783
783
|
sources?: {
|
|
784
784
|
label: string;
|
|
@@ -796,8 +796,8 @@ export declare const reviewThreadsFileSchema: z.ZodObject<{
|
|
|
796
796
|
} | undefined;
|
|
797
797
|
};
|
|
798
798
|
id: string;
|
|
799
|
+
state: "open" | "resolved" | "queued" | "working";
|
|
799
800
|
createdAt: string;
|
|
800
|
-
state: "open" | "queued" | "working" | "resolved";
|
|
801
801
|
comments: {
|
|
802
802
|
id: string;
|
|
803
803
|
author: "user" | "agent";
|
|
@@ -908,8 +908,8 @@ export declare const createThreadBodySchema: z.ZodObject<{
|
|
|
908
908
|
colorScheme: "light" | "dark";
|
|
909
909
|
} | undefined;
|
|
910
910
|
name?: string | undefined;
|
|
911
|
-
role?: string | undefined;
|
|
912
911
|
text?: string | undefined;
|
|
912
|
+
role?: string | undefined;
|
|
913
913
|
components?: string[] | undefined;
|
|
914
914
|
sources?: {
|
|
915
915
|
label: string;
|
|
@@ -938,8 +938,8 @@ export declare const createThreadBodySchema: z.ZodObject<{
|
|
|
938
938
|
colorScheme: "light" | "dark";
|
|
939
939
|
} | undefined;
|
|
940
940
|
name?: string | undefined;
|
|
941
|
-
role?: string | undefined;
|
|
942
941
|
text?: string | undefined;
|
|
942
|
+
role?: string | undefined;
|
|
943
943
|
components?: string[] | undefined;
|
|
944
944
|
sources?: {
|
|
945
945
|
label: string;
|
|
@@ -973,8 +973,8 @@ export declare const createThreadBodySchema: z.ZodObject<{
|
|
|
973
973
|
colorScheme: "light" | "dark";
|
|
974
974
|
} | undefined;
|
|
975
975
|
name?: string | undefined;
|
|
976
|
-
role?: string | undefined;
|
|
977
976
|
text?: string | undefined;
|
|
977
|
+
role?: string | undefined;
|
|
978
978
|
components?: string[] | undefined;
|
|
979
979
|
sources?: {
|
|
980
980
|
label: string;
|
|
@@ -1008,8 +1008,8 @@ export declare const createThreadBodySchema: z.ZodObject<{
|
|
|
1008
1008
|
colorScheme: "light" | "dark";
|
|
1009
1009
|
} | undefined;
|
|
1010
1010
|
name?: string | undefined;
|
|
1011
|
-
role?: string | undefined;
|
|
1012
1011
|
text?: string | undefined;
|
|
1012
|
+
role?: string | undefined;
|
|
1013
1013
|
components?: string[] | undefined;
|
|
1014
1014
|
sources?: {
|
|
1015
1015
|
label: string;
|
|
@@ -1044,11 +1044,11 @@ export declare const agentReplyBodySchema: z.ZodObject<{
|
|
|
1044
1044
|
body: z.ZodString;
|
|
1045
1045
|
resolve: z.ZodBoolean;
|
|
1046
1046
|
}, "strip", z.ZodTypeAny, {
|
|
1047
|
-
body: string;
|
|
1048
1047
|
resolve: boolean;
|
|
1049
|
-
}, {
|
|
1050
1048
|
body: string;
|
|
1049
|
+
}, {
|
|
1051
1050
|
resolve: boolean;
|
|
1051
|
+
body: string;
|
|
1052
1052
|
}>;
|
|
1053
1053
|
/** The CLI's request to open an application for review through the daemon's proxy. */
|
|
1054
1054
|
export declare const openProxyBodySchema: z.ZodObject<{
|
|
@@ -62,8 +62,8 @@ export declare const sealedThreadSchema: z.ZodObject<{
|
|
|
62
62
|
}, "strip", z.ZodTypeAny, {
|
|
63
63
|
anchor: string;
|
|
64
64
|
id: string;
|
|
65
|
+
state: "open" | "resolved" | "queued" | "working";
|
|
65
66
|
createdAt: string;
|
|
66
|
-
state: "open" | "queued" | "working" | "resolved";
|
|
67
67
|
comments: {
|
|
68
68
|
id: string;
|
|
69
69
|
author: "user" | "agent";
|
|
@@ -75,8 +75,8 @@ export declare const sealedThreadSchema: z.ZodObject<{
|
|
|
75
75
|
}, {
|
|
76
76
|
anchor: string;
|
|
77
77
|
id: string;
|
|
78
|
+
state: "open" | "resolved" | "queued" | "working";
|
|
78
79
|
createdAt: string;
|
|
79
|
-
state: "open" | "queued" | "working" | "resolved";
|
|
80
80
|
comments: {
|
|
81
81
|
id: string;
|
|
82
82
|
author: "user" | "agent";
|
|
@@ -116,8 +116,8 @@ export declare const sealedThreadsSchema: z.ZodObject<{
|
|
|
116
116
|
}, "strip", z.ZodTypeAny, {
|
|
117
117
|
anchor: string;
|
|
118
118
|
id: string;
|
|
119
|
+
state: "open" | "resolved" | "queued" | "working";
|
|
119
120
|
createdAt: string;
|
|
120
|
-
state: "open" | "queued" | "working" | "resolved";
|
|
121
121
|
comments: {
|
|
122
122
|
id: string;
|
|
123
123
|
author: "user" | "agent";
|
|
@@ -129,8 +129,8 @@ export declare const sealedThreadsSchema: z.ZodObject<{
|
|
|
129
129
|
}, {
|
|
130
130
|
anchor: string;
|
|
131
131
|
id: string;
|
|
132
|
+
state: "open" | "resolved" | "queued" | "working";
|
|
132
133
|
createdAt: string;
|
|
133
|
-
state: "open" | "queued" | "working" | "resolved";
|
|
134
134
|
comments: {
|
|
135
135
|
id: string;
|
|
136
136
|
author: "user" | "agent";
|
|
@@ -144,8 +144,8 @@ export declare const sealedThreadsSchema: z.ZodObject<{
|
|
|
144
144
|
threads: {
|
|
145
145
|
anchor: string;
|
|
146
146
|
id: string;
|
|
147
|
+
state: "open" | "resolved" | "queued" | "working";
|
|
147
148
|
createdAt: string;
|
|
148
|
-
state: "open" | "queued" | "working" | "resolved";
|
|
149
149
|
comments: {
|
|
150
150
|
id: string;
|
|
151
151
|
author: "user" | "agent";
|
|
@@ -159,8 +159,8 @@ export declare const sealedThreadsSchema: z.ZodObject<{
|
|
|
159
159
|
threads: {
|
|
160
160
|
anchor: string;
|
|
161
161
|
id: string;
|
|
162
|
+
state: "open" | "resolved" | "queued" | "working";
|
|
162
163
|
createdAt: string;
|
|
163
|
-
state: "open" | "queued" | "working" | "resolved";
|
|
164
164
|
comments: {
|
|
165
165
|
id: string;
|
|
166
166
|
author: "user" | "agent";
|
|
@@ -219,11 +219,11 @@ export declare const sealedAgentReplyBodySchema: z.ZodObject<{
|
|
|
219
219
|
body: z.ZodString;
|
|
220
220
|
resolve: z.ZodBoolean;
|
|
221
221
|
}, "strip", z.ZodTypeAny, {
|
|
222
|
-
body: string;
|
|
223
222
|
resolve: boolean;
|
|
224
|
-
}, {
|
|
225
223
|
body: string;
|
|
224
|
+
}, {
|
|
226
225
|
resolve: boolean;
|
|
226
|
+
body: string;
|
|
227
227
|
}>;
|
|
228
228
|
export declare const sealedScreenshotSchema: z.ZodObject<{
|
|
229
229
|
screenshot: z.ZodString;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ChannelSocket } from '@fabrika/daemon-kit';
|
|
2
|
+
import type { z } from 'zod';
|
|
2
3
|
import type { ReviewProxies } from './proxy';
|
|
3
4
|
import type { ReviewStore } from './store';
|
|
4
5
|
export interface ReviewSocketData {
|
|
@@ -9,6 +10,7 @@ export interface ReviewSocketData {
|
|
|
9
10
|
export interface ReviewSocket extends ChannelSocket {
|
|
10
11
|
data: ReviewSocketData;
|
|
11
12
|
}
|
|
13
|
+
export declare function parseBody<T extends z.ZodTypeAny>(req: Request, schema: T): Promise<z.infer<T>>;
|
|
12
14
|
/** Review mode: threads a person leaves on a running application through the injected widget, and their delivery to the agent. */
|
|
13
15
|
export declare function createReviewServer(store: ReviewStore, proxies: ReviewProxies): {
|
|
14
16
|
channel: import("@fabrika/daemon-kit").NotificationChannel<ReviewSocket>;
|