@nyte-ai/plugin 0.0.0-stage → 0.0.18

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.
Files changed (134) hide show
  1. package/LICENSE +21 -0
  2. package/THIRD-PARTY-NOTICES.md +800 -0
  3. package/dist/chunks/billing-0y7dfkp2.js +146 -0
  4. package/dist/chunks/billing-2v3g7rd9.js +190 -0
  5. package/dist/chunks/billing-3j77ss7y.js +86 -0
  6. package/dist/chunks/billing-3scqmkzb.js +559 -0
  7. package/dist/chunks/billing-6z2kgtyt.js +51 -0
  8. package/dist/chunks/billing-8rjk35gr.js +444 -0
  9. package/dist/chunks/billing-9mfedmsh.js +373 -0
  10. package/dist/chunks/billing-9nn3yp18.js +176 -0
  11. package/dist/chunks/billing-9qc0eqh4.js +174 -0
  12. package/dist/chunks/billing-a9vqn66p.js +351 -0
  13. package/dist/chunks/billing-bv5zr32b.js +369 -0
  14. package/dist/chunks/billing-cy1rg619.js +302 -0
  15. package/dist/chunks/billing-ejx2hv52.js +323 -0
  16. package/dist/chunks/billing-h13r0byk.js +80 -0
  17. package/dist/chunks/billing-j643d12p.js +197 -0
  18. package/dist/chunks/billing-k2p1t25n.js +109 -0
  19. package/dist/chunks/billing-kn3d30b4.js +276 -0
  20. package/dist/chunks/billing-mvc33pv6.js +36 -0
  21. package/dist/chunks/billing-s4rrspsk.js +7 -0
  22. package/dist/chunks/billing-svrhh5a5.js +307 -0
  23. package/dist/chunks/billing-sxc70w72.js +161 -0
  24. package/dist/chunks/billing-t1qrxe16.js +41 -0
  25. package/dist/chunks/billing-tzr3cebf.js +20 -0
  26. package/dist/chunks/billing-wmcbg6fw.js +52 -0
  27. package/dist/chunks/billing-wmkxkypm.js +527 -0
  28. package/dist/chunks/billing-ye3wk5r3.js +205 -0
  29. package/dist/chunks/billing-zfpm2rt0.js +29 -0
  30. package/dist/examples/claude-code/LICENSE +21 -0
  31. package/dist/examples/claude-code/billing.d.ts +7 -0
  32. package/dist/examples/claude-code/billing.js +11 -0
  33. package/dist/examples/claude-code/claude-cli.d.ts +35 -0
  34. package/dist/examples/claude-code/claude-cli.js +15 -0
  35. package/dist/examples/claude-code/env.d.ts +1 -0
  36. package/dist/examples/claude-code/env.js +6 -0
  37. package/dist/examples/claude-code/index.d.ts +24 -0
  38. package/dist/examples/claude-code/index.js +149 -0
  39. package/dist/examples/claude-code/inert-mcp.d.ts +1 -0
  40. package/dist/examples/claude-code/inert-mcp.js +6 -0
  41. package/dist/examples/claude-code/model-catalog.d.ts +27 -0
  42. package/dist/examples/claude-code/model-catalog.js +12 -0
  43. package/dist/examples/claude-code/process.d.ts +22 -0
  44. package/dist/examples/claude-code/process.js +25 -0
  45. package/dist/examples/claude-code/replay.d.ts +4 -0
  46. package/dist/examples/claude-code/replay.js +11 -0
  47. package/dist/examples/claude-code/stream.d.ts +3 -0
  48. package/dist/examples/claude-code/stream.js +16 -0
  49. package/dist/examples/claude-code/transcript.d.ts +83 -0
  50. package/dist/examples/claude-code/transcript.js +23 -0
  51. package/dist/examples/claude-code/turn-relay.d.ts +48 -0
  52. package/dist/examples/claude-code/turn-relay.js +9 -0
  53. package/dist/examples/claude-code/wire.d.ts +372 -0
  54. package/dist/examples/claude-code/wire.js +18 -0
  55. package/dist/src/acp/connection.d.ts +24 -0
  56. package/dist/src/acp/connection.js +8 -0
  57. package/dist/src/acp/index.d.ts +54 -0
  58. package/dist/src/acp/index.js +1004 -0
  59. package/dist/src/acp/registry.d.ts +18 -0
  60. package/dist/src/acp/registry.js +8 -0
  61. package/dist/src/acp/thread.d.ts +46 -0
  62. package/dist/src/acp/thread.js +7 -0
  63. package/dist/src/acp/transcript.d.ts +8 -0
  64. package/dist/src/acp/transcript.js +11 -0
  65. package/dist/src/acp/translate.d.ts +33 -0
  66. package/dist/src/acp/translate.js +20 -0
  67. package/dist/src/approvals/approvals.d.ts +189 -0
  68. package/dist/src/approvals/approvals.js +143 -0
  69. package/dist/src/approvals/schema.d.ts +169 -0
  70. package/dist/src/approvals/schema.js +18 -0
  71. package/dist/src/bash-description.d.ts +30 -0
  72. package/dist/src/bash-description.js +18 -0
  73. package/dist/src/browser-tools.d.ts +25 -0
  74. package/dist/src/browser-tools.js +246 -0
  75. package/dist/src/canvas/canvas-compile.d.ts +48 -0
  76. package/dist/src/canvas/canvas-compile.js +8 -0
  77. package/dist/src/canvas/canvas-libraries.d.ts +32 -0
  78. package/dist/src/canvas/canvas-libraries.js +6 -0
  79. package/dist/src/canvas/canvas-preview.d.ts +107 -0
  80. package/dist/src/canvas/canvas-preview.js +12 -0
  81. package/dist/src/canvas/canvas-protocol.d.ts +184 -0
  82. package/dist/src/canvas/canvas-protocol.js +75 -0
  83. package/dist/src/canvas/canvas.d.ts +50 -0
  84. package/dist/src/canvas/canvas.js +221 -0
  85. package/dist/src/canvas/schema.d.ts +47 -0
  86. package/dist/src/canvas/schema.js +8 -0
  87. package/dist/src/claude-code-sdk/index.d.ts +35 -0
  88. package/dist/src/claude-code-sdk/index.js +368 -0
  89. package/dist/src/claude-code-sdk/session.d.ts +48 -0
  90. package/dist/src/claude-code-sdk/session.js +7 -0
  91. package/dist/src/claude-code-sdk/transcript.d.ts +19 -0
  92. package/dist/src/claude-code-sdk/transcript.js +15 -0
  93. package/dist/src/claude-code-sdk/translate.d.ts +18 -0
  94. package/dist/src/claude-code-sdk/translate.js +20 -0
  95. package/dist/src/client/mount.d.ts +44 -0
  96. package/dist/src/client/mount.js +252 -0
  97. package/dist/src/client/notifications.d.ts +35 -0
  98. package/dist/src/client/notifications.js +26 -0
  99. package/dist/src/client/presentation.d.ts +336 -0
  100. package/dist/src/client/presentation.js +373 -0
  101. package/dist/src/client/transcript-tui.d.ts +23 -0
  102. package/dist/src/client/transcript-tui.js +20 -0
  103. package/dist/src/client/transcript.d.ts +23 -0
  104. package/dist/src/client/transcript.js +51 -0
  105. package/dist/src/client.d.ts +53 -0
  106. package/dist/src/client.js +22 -0
  107. package/dist/src/codemode-runtime.d.ts +11 -0
  108. package/dist/src/codemode-runtime.js +10 -0
  109. package/dist/src/codemode-worker.d.ts +1 -0
  110. package/dist/src/codemode-worker.js +2 -0
  111. package/dist/src/codemode.d.ts +21 -0
  112. package/dist/src/codemode.js +170 -0
  113. package/dist/src/core.d.ts +43 -0
  114. package/dist/src/core.js +11 -0
  115. package/dist/src/openai-astra-context.d.ts +23 -0
  116. package/dist/src/openai-astra-context.js +14 -0
  117. package/dist/src/openai-compaction.d.ts +15 -0
  118. package/dist/src/openai-compaction.js +55 -0
  119. package/dist/src/question/client/questions-tui.d.ts +9 -0
  120. package/dist/src/question/client/questions-tui.js +19 -0
  121. package/dist/src/question/client/questions.d.ts +9 -0
  122. package/dist/src/question/client/questions.js +160 -0
  123. package/dist/src/question/question.d.ts +63 -0
  124. package/dist/src/question/question.js +9 -0
  125. package/dist/src/question/schema.d.ts +101 -0
  126. package/dist/src/question/schema.js +14 -0
  127. package/dist/src/rename.d.ts +78 -0
  128. package/dist/src/rename.js +78 -0
  129. package/dist/src/telemetry.d.ts +36 -0
  130. package/dist/src/telemetry.js +84 -0
  131. package/dist/src/web-search.d.ts +78 -0
  132. package/dist/src/web-search.js +219 -0
  133. package/package.json +190 -3
  134. package/README.md +0 -3
@@ -0,0 +1,184 @@
1
+ /** The shell surface a compiled module was built against. Bump on any change to `KIT`, a kit component's props, the libraries or the global; a shell renders a canvas whose runtime is at most its own. Runtime 2 added `react-dom` and the libraries; the compiler stamps a canvas with 2 only when it imports one of them, so a runtime 1 shell still renders the rest. */
2
+ export declare const CANVAS_RUNTIME = 2;
3
+ /** The global the shell installs before importing a module: `{ runtime, react, jsxRuntime, reactDom, kit, library }`, where `library(specifier)` loads one of `LIBRARY_EXPORTS`' modules. */
4
+ export declare const CANVAS_GLOBAL = "__nyteCanvas";
5
+ /** The import specifier for the kit. */
6
+ export declare const KIT_SPECIFIER = "nyte/canvas";
7
+ /** The entry module's file name: the tool's `source`, which its other files are imported from. */
8
+ export declare const CANVAS_ENTRY = "main.tsx";
9
+ /** Bytes of TSX the tool accepts, across every file of one canvas. */
10
+ export declare const CANVAS_SOURCE_LIMIT = 65536;
11
+ /** Bytes of compiled module a part may hold. */
12
+ export declare const CANVAS_CODE_LIMIT = 196608;
13
+ /** The frame's height range in CSS pixels; a taller canvas scrolls inside. */
14
+ export declare const CANVAS_MIN_HEIGHT = 48;
15
+ export declare const CANVAS_MAX_HEIGHT = 2000;
16
+ /** The height hint range the tool accepts. */
17
+ export declare const CANVAS_MIN_HEIGHT_HINT = 80;
18
+ /** The frame height before a canvas reports its own, when the agent gave no hint. */
19
+ export declare const CANVAS_DEFAULT_HEIGHT = 80;
20
+ /** React 19's public surface a canvas may import, without `act`, `version` and the unstable or server-only names. */
21
+ export declare const REACT_EXPORTS: readonly ["Activity", "Children", "Component", "Fragment", "Profiler", "PureComponent", "StrictMode", "Suspense", "ViewTransition", "addTransitionType", "cache", "cloneElement", "createContext", "createElement", "createRef", "forwardRef", "isValidElement", "lazy", "memo", "startTransition", "use", "useActionState", "useCallback", "useContext", "useDebugValue", "useDeferredValue", "useEffect", "useEffectEvent", "useId", "useImperativeHandle", "useInsertionEffect", "useLayoutEffect", "useMemo", "useOptimistic", "useReducer", "useRef", "useState", "useSyncExternalStore", "useTransition"];
22
+ export declare const JSX_RUNTIME_EXPORTS: readonly ["Fragment", "jsx", "jsxs"];
23
+ /** The two `react-dom` names a canvas may import; the shell owns the root, so nothing that mounts one. */
24
+ export declare const REACT_DOM_EXPORTS: readonly ["createPortal", "flushSync"];
25
+ /** Every name each library exports, by its import specifier. */
26
+ export declare const LIBRARY_EXPORTS: Readonly<Record<string, readonly string[]>>;
27
+ /** Each library's pinned version, by its import specifier. */
28
+ export declare const LIBRARY_VERSIONS: Readonly<Record<string, string>>;
29
+ /**
30
+ * A source file's place in a compiled module: its name, the module line its
31
+ * first line sits on, and how many lines it has.
32
+ */
33
+ export type CanvasFileSpan = readonly [file: string, start: number, lines: number];
34
+ /** Returns the comment a compiled module opens with, naming where each source file sits in it. */
35
+ export declare function canvasFilesComment(spans: readonly CanvasFileSpan[]): string;
36
+ /** Returns `file:line` for the first frame of a stack that runs in a compiled module, which the shell loads from a blob URL, or undefined when no frame lands in a source file (the linker's own lines, a module without the files comment). Sucrase keeps lines, not columns, so a stack's column belongs to the compiled code and is left out. */
37
+ export declare function locateCanvasStack(code: string, stack: string): string | undefined;
38
+ /**
39
+ * The hues a series, a sparkline or a meter may name; charts without one take
40
+ * the first eight in this order. Neighbours stay apart under protan and deutan
41
+ * vision (OKLab ΔE ≥ 10 on the chart-series step), the first three stay apart
42
+ * pairwise, and yellow, the one hue under 3:1 on white, comes late.
43
+ */
44
+ export declare const TINTS: readonly ["blue", "pink", "orange", "teal", "red", "yellow", "purple", "green", "gray", "brown"];
45
+ /**
46
+ * The kit, name by name, each with the one-line signature the model reads.
47
+ * `packages/canvas` exports exactly these names, in a test; the compiler
48
+ * answers any other import of `nyte/canvas` with a positioned error.
49
+ */
50
+ export declare const KIT: {
51
+ readonly Stack: "{ direction?: \"row\" | \"column\" = \"column\", gap?: 0 | 1 | 2 | 3 | 4 | 6 = 2 (×4 px), align?: \"start\" | \"center\" | \"end\" | \"stretch\", justify?: \"start\" | \"center\" | \"end\" | \"between\", wrap?: boolean, children }: flex layout";
52
+ readonly Grid: "{ columns?: number | \"auto\" = \"auto\", minWidth?: number = 160 (px, with \"auto\"), gap?: 0 | 1 | 2 | 3 | 4 | 6 = 2, children }: equal columns";
53
+ readonly Divider: "{}: a hairline";
54
+ readonly Heading: "{ level?: 1 | 2 | 3 = 2, children }";
55
+ readonly Text: "{ size?: \"xs\" | \"sm\" | \"base\" | \"lg\", tone?: \"primary\" | \"secondary\" | \"tertiary\", weight?: \"normal\" | \"medium\" | \"semibold\", mono?: boolean, truncate?: boolean, align?: \"start\" | \"center\" | \"end\", children }";
56
+ readonly Code: "{ block?: boolean, children: string }: monospace, inline or a block";
57
+ readonly Stat: "{ label: string, value: ReactNode, detail?: ReactNode, tone?: \"neutral\" | \"success\" | \"warning\" | \"danger\" }: a labelled number";
58
+ readonly Badge: "{ tone?: \"neutral\" | \"info\" | \"success\" | \"warning\" | \"danger\", children }";
59
+ readonly Meter: "{ value: number, max?: number = 100, label?: string, tone?: \"primary\" | \"success\" | \"warning\" | \"danger\" = \"primary\" }: a thin filled bar with the value beside the label";
60
+ readonly Table: "{ columns: { key: string, label: ReactNode, align?: \"start\" | \"end\", width?: number | string }[], rows: Record<string, ReactNode>[], caption?: string }: rows are keyed by column key; a cell can hold a Sparkline or a Badge";
61
+ readonly Callout: "{ tone?: \"info\" | \"success\" | \"warning\" | \"danger\", title?: string, children }";
62
+ readonly Card: "{ title?: ReactNode, actions?: ReactNode, padding?: 0 | 2 | 3 | 4 = 4, children }: an elevated bordered surface";
63
+ readonly StackedBars: "{ label: string, series: { key: string, label: string, tint: Tint }[], buckets: { key: string, label: string, values: number[] }[], format: (value: number) => string, height?: number = 88, ticks?: number = 5 }: compact stacked bars without axes, a readout on pointer or arrow keys; the numbers live in the copy around it. Preferred beside a Stat or a heading figure";
64
+ readonly Sparkline: "{ values: number[], tint?: Tint, label?: string, width?: number = 72, height?: number = 20 }: a row's trend scaled to its own peak, for a Table cell beside the row's number";
65
+ readonly LineChart: "{ series: { id: string, data: { x: number | string, y: number }[], tint?: Tint }[], height?: number = 240, xFormat?: (x) => string, yFormat?: (y) => string, curve?: \"linear\" | \"monotone\" | \"step\", area?: boolean, legend?: boolean }: a full chart with axes and a readout";
66
+ readonly BarChart: "{ data: Record<string, number | string>[], keys: (string | { key: string, label?: string, tint?: Tint })[], indexBy: string, height?: number = 240, layout?: \"vertical\" | \"horizontal\", mode?: \"grouped\" | \"stacked\" = \"stacked\", valueFormat?: (value: number) => string, legend?: boolean }: a full chart with axes and a readout with the total";
67
+ readonly PieChart: "{ data: { id: string, value: number, label?: string, tint?: Tint }[], height?: number = 240, donut?: boolean, valueFormat?: (value: number) => string, legend?: boolean }";
68
+ readonly Button: "{ variant?: \"solid\" | \"outline\" | \"ghost\" | \"pill\" | \"chip\", size?: \"2xs\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\", tone?: \"neutral\" | \"primary\" | \"success\" | \"warning\" | \"danger\", loading?: boolean, disabled?: boolean, onClick, children }";
69
+ readonly Tabs: "Tabs.Root { value?, defaultValue?, onValueChange? } > Tabs.List { children: Tabs.Tab { value, children }[] } + Tabs.Panel { value, children }";
70
+ readonly Select: "Select { value?, defaultValue?, onValueChange? } > SelectTrigger { children: <SelectValue /> } + SelectContent { children: SelectItem[] }";
71
+ readonly SelectTrigger: "see Select";
72
+ readonly SelectValue: "see Select";
73
+ readonly SelectContent: "see Select";
74
+ readonly SelectItem: "{ value: string, children }";
75
+ readonly ToggleGroup: "{ value?: string[], defaultValue?: string[], onValueChange?: (value: string[]) => void, multiple?: boolean, children: Toggle[] }";
76
+ readonly Toggle: "{ value: string, size?: as Button, tone?: as Button, children }";
77
+ readonly Switch: "{ label: string, checked?, defaultChecked?, onCheckedChange?: (checked: boolean) => void, disabled? }";
78
+ readonly Checkbox: "{ checked?, defaultChecked?, indeterminate?, onCheckedChange?: (checked: boolean) => void, disabled? }";
79
+ readonly Slider: "Slider.Root { value?, defaultValue?, onValueChange?, min?, max?, step? } > Slider.Control > Slider.Track > Slider.Indicator + Slider.Thumb";
80
+ readonly Tooltip: "Tooltip > TooltipTrigger { render?: ReactElement, children } + TooltipContent { side?, children }";
81
+ readonly TooltipTrigger: "see Tooltip";
82
+ readonly TooltipContent: "see Tooltip";
83
+ readonly Collapsible: "Collapsible.Root { open?, defaultOpen?, onOpenChange? } > Collapsible.Trigger { children } + Collapsible.Panel { children }";
84
+ readonly Kbd: "{ keys: string[] }";
85
+ readonly Spinner: "{}";
86
+ readonly useColorScheme: "(): \"light\" | \"dark\"";
87
+ };
88
+ /** Every name `nyte/canvas` exports, in `KIT` order. */
89
+ export declare const KIT_EXPORTS: readonly string[];
90
+ /** The custom properties a client may hand the shell; anything else is dropped. */
91
+ export declare const CANVAS_VARIABLES: readonly ["--nyte-custom-hue", "--nyte-custom-chroma-scale", "--nyte-font-family-sans", "--nyte-font-family-mono", "--nyte-font-size-base", "--nyte-font-size-code", "--nyte-letter-spacing-lg", "--nyte-font-smoothing", "--nyte-moz-font-smoothing", "--nyte-reduce-transparency"];
92
+ export declare const CANVAS_PROTOCOL_VERSION = "2026-01-26";
93
+ /** What a client tells the shell about where it runs. */
94
+ export type CanvasHostContext = {
95
+ readonly theme: "light" | "dark";
96
+ readonly styles: {
97
+ readonly variables: Readonly<Record<string, string>>;
98
+ };
99
+ readonly displayMode: "inline";
100
+ readonly platform: "desktop" | "web" | "mobile";
101
+ readonly deviceCapabilities: {
102
+ readonly touch: boolean;
103
+ readonly hover: boolean;
104
+ };
105
+ };
106
+ /** A compiled canvas, as the part holds it and the shell receives it. */
107
+ export type CanvasModule = {
108
+ readonly runtime: number;
109
+ readonly code: string;
110
+ readonly title: string;
111
+ };
112
+ /** Who answers `ui/initialize`: a client, or `nyte-preview`, the harness a previewer runs in place of one. */
113
+ export type CanvasHostInfo = {
114
+ readonly name: "nyte-desktop" | "nyte-web" | "nyte-ios" | "nyte-preview";
115
+ readonly version: string;
116
+ };
117
+ export type JsonRpcId = string | number;
118
+ /** A message the shell sends its client. */
119
+ export type ShellMessage = {
120
+ readonly kind: "initialize";
121
+ readonly id: JsonRpcId;
122
+ readonly runtime: number;
123
+ } | {
124
+ readonly kind: "initialized";
125
+ } | {
126
+ readonly kind: "size";
127
+ readonly height: number;
128
+ }
129
+ /** `url` is an http(s) URL, or a reference with no scheme that the client resolves in its workspace. */
130
+ | {
131
+ readonly kind: "open-link";
132
+ readonly id: JsonRpcId;
133
+ readonly url: string;
134
+ } | {
135
+ readonly kind: "error";
136
+ readonly phase: "load" | "render";
137
+ readonly message: string;
138
+ readonly stack: string | null;
139
+ };
140
+ /** A message a client sends the shell. */
141
+ export type HostMessage = {
142
+ readonly kind: "initialize-result";
143
+ readonly id: JsonRpcId;
144
+ readonly hostInfo: CanvasHostInfo;
145
+ readonly hostContext: CanvasHostContext;
146
+ } | {
147
+ readonly kind: "render";
148
+ readonly module: CanvasModule;
149
+ } | {
150
+ readonly kind: "context-changed";
151
+ readonly context: Partial<CanvasHostContext>;
152
+ } | {
153
+ readonly kind: "open-link-result";
154
+ readonly id: JsonRpcId;
155
+ readonly isError: boolean;
156
+ };
157
+ type Json = null | boolean | number | string | readonly Json[] | {
158
+ readonly [key: string]: Json;
159
+ };
160
+ /** Returns the `ui/initialize` request the shell opens with. */
161
+ export declare function initializeRequest(id: JsonRpcId, runtime: number): Json;
162
+ export declare function initializedNotification(): Json;
163
+ export declare function sizeChangedNotification(height: number): Json;
164
+ export declare function openLinkRequest(id: JsonRpcId, url: string): Json;
165
+ /** Returns the error notification the shell sends when a module fails to load or render. */
166
+ export declare function errorNotification(error: {
167
+ readonly phase: "load" | "render";
168
+ readonly message: string;
169
+ readonly stack?: string;
170
+ }): Json;
171
+ /** Returns the answer to the shell's `ui/initialize`. */
172
+ export declare function initializeResult(id: JsonRpcId, hostInfo: CanvasHostInfo, hostContext: CanvasHostContext): Json;
173
+ export declare function renderNotification(module: CanvasModule): Json;
174
+ export declare function hostContextChangedNotification(context: Partial<CanvasHostContext>): Json;
175
+ export declare function openLinkResult(id: JsonRpcId, isError?: boolean): Json;
176
+ /** Returns the message a shell posted, or undefined for anything that is not one. */
177
+ export declare function readShellMessage(data: unknown): ShellMessage | undefined;
178
+ /** Returns the message a client posted into the shell, or undefined for anything that is not one. */
179
+ export declare function readHostMessage(data: unknown): HostMessage | undefined;
180
+ /** Returns the height a frame shows a canvas at, within the range. */
181
+ export declare function clampCanvasHeight(height: number): number;
182
+ /** Returns the variables the shell may apply: allowlisted names, values stripped of the characters that could end a declaration. */
183
+ export declare function sanitizeCanvasVariables(variables: Readonly<Record<string, string>>): Record<string, string>;
184
+ export {};
@@ -0,0 +1,75 @@
1
+ import {
2
+ CANVAS_RUNTIME2,
3
+ CANVAS_GLOBAL2,
4
+ KIT_SPECIFIER2,
5
+ CANVAS_ENTRY2,
6
+ CANVAS_SOURCE_LIMIT2,
7
+ CANVAS_CODE_LIMIT2,
8
+ CANVAS_MIN_HEIGHT2,
9
+ CANVAS_MAX_HEIGHT2,
10
+ CANVAS_MIN_HEIGHT_HINT2,
11
+ CANVAS_DEFAULT_HEIGHT2,
12
+ REACT_EXPORTS2,
13
+ JSX_RUNTIME_EXPORTS2,
14
+ REACT_DOM_EXPORTS2,
15
+ LIBRARY_EXPORTS2,
16
+ LIBRARY_VERSIONS2,
17
+ canvasFilesComment2,
18
+ locateCanvasStack2,
19
+ TINTS2,
20
+ KIT2,
21
+ KIT_EXPORTS2,
22
+ CANVAS_VARIABLES2,
23
+ CANVAS_PROTOCOL_VERSION2,
24
+ initializeRequest2,
25
+ initializedNotification2,
26
+ sizeChangedNotification2,
27
+ openLinkRequest2,
28
+ errorNotification2,
29
+ initializeResult2,
30
+ renderNotification2,
31
+ hostContextChangedNotification2,
32
+ openLinkResult2,
33
+ readShellMessage2,
34
+ readHostMessage2,
35
+ clampCanvasHeight2,
36
+ sanitizeCanvasVariables2
37
+ } from "../../chunks/billing-bv5zr32b.js";
38
+ import"../../chunks/billing-zfpm2rt0.js";
39
+ export {
40
+ CANVAS_CODE_LIMIT2 as CANVAS_CODE_LIMIT,
41
+ CANVAS_DEFAULT_HEIGHT2 as CANVAS_DEFAULT_HEIGHT,
42
+ CANVAS_ENTRY2 as CANVAS_ENTRY,
43
+ CANVAS_GLOBAL2 as CANVAS_GLOBAL,
44
+ CANVAS_MAX_HEIGHT2 as CANVAS_MAX_HEIGHT,
45
+ CANVAS_MIN_HEIGHT2 as CANVAS_MIN_HEIGHT,
46
+ CANVAS_MIN_HEIGHT_HINT2 as CANVAS_MIN_HEIGHT_HINT,
47
+ CANVAS_PROTOCOL_VERSION2 as CANVAS_PROTOCOL_VERSION,
48
+ CANVAS_RUNTIME2 as CANVAS_RUNTIME,
49
+ CANVAS_SOURCE_LIMIT2 as CANVAS_SOURCE_LIMIT,
50
+ CANVAS_VARIABLES2 as CANVAS_VARIABLES,
51
+ JSX_RUNTIME_EXPORTS2 as JSX_RUNTIME_EXPORTS,
52
+ KIT2 as KIT,
53
+ KIT_EXPORTS2 as KIT_EXPORTS,
54
+ KIT_SPECIFIER2 as KIT_SPECIFIER,
55
+ LIBRARY_EXPORTS2 as LIBRARY_EXPORTS,
56
+ LIBRARY_VERSIONS2 as LIBRARY_VERSIONS,
57
+ REACT_DOM_EXPORTS2 as REACT_DOM_EXPORTS,
58
+ REACT_EXPORTS2 as REACT_EXPORTS,
59
+ TINTS2 as TINTS,
60
+ canvasFilesComment2 as canvasFilesComment,
61
+ clampCanvasHeight2 as clampCanvasHeight,
62
+ errorNotification2 as errorNotification,
63
+ hostContextChangedNotification2 as hostContextChangedNotification,
64
+ initializeRequest2 as initializeRequest,
65
+ initializeResult2 as initializeResult,
66
+ initializedNotification2 as initializedNotification,
67
+ locateCanvasStack2 as locateCanvasStack,
68
+ openLinkRequest2 as openLinkRequest,
69
+ openLinkResult2 as openLinkResult,
70
+ readHostMessage2 as readHostMessage,
71
+ readShellMessage2 as readShellMessage,
72
+ renderNotification2 as renderNotification,
73
+ sanitizeCanvasVariables2 as sanitizeCanvasVariables,
74
+ sizeChangedNotification2 as sizeChangedNotification
75
+ };
@@ -0,0 +1,50 @@
1
+ import type { CanvasPreviewer } from "./canvas-preview.ts";
2
+ import type { Plugin } from "@nyte-ai/plugin/core";
3
+ export declare const canvas: import("@nyte-ai/core").PartDefinition<{
4
+ code: string;
5
+ runtime: number;
6
+ title: string;
7
+ error: string | null;
8
+ height: number | null;
9
+ }, {
10
+ replace: {
11
+ input: import("@nyte-ai/schema").Schema<{
12
+ code: string;
13
+ runtime: number;
14
+ title: string;
15
+ height: number | null;
16
+ }>;
17
+ };
18
+ report: {
19
+ input: import("@nyte-ai/schema").Schema<{
20
+ message: string;
21
+ }>;
22
+ };
23
+ }>;
24
+ /**
25
+ * What the model reads about the tool and the kit; the signatures come from
26
+ * `KIT`, so they cannot drift from what the compiler accepts.
27
+ *
28
+ * @category plugins
29
+ * @since 0.1.0
30
+ */
31
+ export declare const CANVAS_DESCRIPTION: string;
32
+ /**
33
+ * Returns the canvas plugin: the `canvas` part and `canvas_render`, which
34
+ * compiles in-process on any host, plus `canvas_preview` when the host
35
+ * passes a previewer, in which case `canvas_render` tells the model to
36
+ * preview first.
37
+ *
38
+ * @category plugins
39
+ * @since 0.1.0
40
+ */
41
+ export declare function canvasPlugin(preview?: CanvasPreviewer): Plugin;
42
+ /**
43
+ * The canvas plugin without a previewer, as a host that cannot render one
44
+ * loads it.
45
+ *
46
+ * @category plugins
47
+ * @since 0.1.0
48
+ */
49
+ declare const _default: Plugin;
50
+ export default _default;
@@ -0,0 +1,221 @@
1
+ import"../../chunks/billing-zfpm2rt0.js";
2
+ import {
3
+ KIT_SPECIFIER2,
4
+ CANVAS_ENTRY2,
5
+ CANVAS_SOURCE_LIMIT2,
6
+ CANVAS_MAX_HEIGHT2,
7
+ CANVAS_MIN_HEIGHT_HINT2,
8
+ REACT_DOM_EXPORTS2,
9
+ LIBRARY_VERSIONS2,
10
+ TINTS2,
11
+ KIT2
12
+ } from "../../chunks/billing-bv5zr32b.js";
13
+ import {
14
+ compileCanvas2
15
+ } from "../../chunks/billing-kn3d30b4.js";
16
+ import {
17
+ CANVAS_PREVIEW_WIDTHS2,
18
+ describeCanvasPreview2
19
+ } from "../../chunks/billing-sxc70w72.js";
20
+ import {
21
+ canvas2
22
+ } from "../../chunks/billing-mvc33pv6.js";
23
+
24
+ // src/canvas/canvas.ts
25
+ import { definePart, followedTrace, traced } from "@nyte-ai/core";
26
+ import { asId, standard } from "@nyte-ai/schema";
27
+ import { Type } from "typebox";
28
+ var handlers = {
29
+ async replace(input, context) {
30
+ const outcome = await context.part.update(() => ({ ...input, error: null }));
31
+ if (outcome.kind !== "updated")
32
+ throw new Error(`The canvas could not be replaced: ${outcome.kind}.`);
33
+ },
34
+ async report(input, context) {
35
+ const outcome = await context.part.update((current) => ({ ...current, error: input.message }));
36
+ if (outcome.kind !== "updated")
37
+ throw new Error(`The canvas error could not be reported: ${outcome.kind}.`);
38
+ }
39
+ };
40
+ var canvas = definePart({
41
+ ...canvas2,
42
+ onAction: (action, input, context) => handlers[action](input, context)
43
+ });
44
+ var source = Type.String({
45
+ maxLength: CANVAS_SOURCE_LIMIT2,
46
+ description: `${CANVAS_ENTRY2}: the TSX module whose default export is the component.`
47
+ });
48
+ var files = Type.Optional(Type.Record(Type.String(), Type.String({ maxLength: CANVAS_SOURCE_LIMIT2 }), {
49
+ description: `The canvas's other modules, keyed by path from ${CANVAS_ENTRY2}'s folder (\`chart.tsx\`, \`lib/scale.ts\`), which it imports as \`./chart\` or \`./lib/scale.ts\`.`
50
+ }));
51
+ var parameters = standard(Type.Object({
52
+ title: Type.String({ minLength: 1, maxLength: 120, description: "Shown above the canvas." }),
53
+ source,
54
+ files,
55
+ canvas: Type.Optional(Type.String({
56
+ description: "The id of a canvas to replace in place; omit to add a new one."
57
+ })),
58
+ height: Type.Optional(Type.Number({
59
+ minimum: CANVAS_MIN_HEIGHT_HINT2,
60
+ maximum: CANVAS_MAX_HEIGHT2,
61
+ description: "Initial frame height in px until the canvas reports its own."
62
+ }))
63
+ }));
64
+ var kitReference = Object.entries(KIT2).map(([name, signature]) => `- ${name} ${signature}`).join(`
65
+ `);
66
+ var CANVAS_DESCRIPTION = [
67
+ `Render a React canvas inline in the chat. \`source\` is ${CANVAS_ENTRY2}, a TSX module whose default export is a component; split a large canvas into \`files\` it imports by relative path. Every file counts toward one ${Math.round(CANVAS_SOURCE_LIMIT2 / 1024)} KB budget.`,
68
+ `Imports: \`react\`, \`react-dom\` (${REACT_DOM_EXPORTS2.map((name) => `\`${name}\``).join(" and ")} only), \`${KIT_SPECIFIER2}\`, the canvas's own files, and these libraries, each loaded only by a canvas that imports it: ${Object.entries(LIBRARY_VERSIONS2).map(([name, version]) => `\`${name}\` ${version}`).join(", ")}. \`three\` is the core module without its addons, so orbit a camera yourself. Nothing else resolves (no other npm packages, no URLs, no fetch). \`eval\` and \`new Function\` are unavailable at run time.`,
69
+ `The canvas runs sandboxed with no network, sized to its content (up to ${CANVAS_MAX_HEIGHT2} px, then it scrolls), on the chat's background with the user's theme applied through the kit.`,
70
+ "Use the kit for layout, text, data and charts; never hard-code colours, fonts or backgrounds. An `<a href>` to an http(s) URL opens in the user's browser, and one to a workspace path such as `src/app.ts:42` opens that file at that line; other schemes are refused. Pass `canvas` to replace an earlier canvas in place.",
71
+ "",
72
+ 'Charts: `StackedBars` and `Sparkline` are compact and axis-free, for a figure that sits beside its own number (a Stat, a Table row); use them first. `LineChart`, `BarChart` and `PieChart` are full charts with axes, gridlines and a readout, for a series that needs reading on its own: a line for change over time, bars to compare categories (`layout="horizontal"` when the labels are long), a pie only for up to five parts of one whole. All of them share one look and fit the width they get; give each series a `tint` only when a hue carries meaning (green for good, red for bad), or leave the order to the kit, which keeps neighbouring series apart for colour-blind readers.',
73
+ 'Keep a chart to one value axis and at most eight series; fold the rest into an "Other" series, and put measures on different scales in separate charts. Pass `yFormat` or `valueFormat` to carry units (`$`, `%`, `ms`); the axis, readout and pie legend all use it. An empty series or data array draws a "No data" box, so render the chart as it is rather than guarding it.',
74
+ `Tint = ${TINTS2.map((tint) => `"${tint}"`).join(" | ")}.`,
75
+ "",
76
+ `\`${KIT_SPECIFIER2}\` exports:`,
77
+ kitReference
78
+ ].join(`
79
+ `);
80
+ function describeErrors(errors) {
81
+ return errors.map((error) => {
82
+ if (error.file === null)
83
+ return error.text;
84
+ return error.line === null ? `${error.file}: ${error.text}` : `${error.file}:${error.line}:${error.column ?? 0} ${error.text}`;
85
+ }).join(`
86
+ `);
87
+ }
88
+ var encoder = new TextEncoder;
89
+ async function compile(args, invocation) {
90
+ const compiled = await traced("canvas.compile", followedTrace(invocation.session.id), {
91
+ bytes: [args.source, ...Object.values(args.files ?? {})].reduce((sum, text) => sum + encoder.encode(text).byteLength, 0),
92
+ files: Object.keys(args.files ?? {}).length
93
+ }, () => compileCanvas2(args.source, args.files));
94
+ if (compiled.kind === "failed")
95
+ throw new Error(`The canvas did not compile:
96
+ ${describeErrors(compiled.errors)}`);
97
+ return compiled;
98
+ }
99
+ var PREVIEW_FIRST = "Before rendering, call `canvas_preview` with the same `source` and `files`: it shows you the canvas and its errors, console and height without the user seeing it. Fix what it shows, then render once.";
100
+ function renderTool(previewing) {
101
+ return {
102
+ name: "canvas_render",
103
+ description: previewing ? `${PREVIEW_FIRST}
104
+
105
+ ${CANVAS_DESCRIPTION}` : CANVAS_DESCRIPTION,
106
+ parameters,
107
+ class: (args) => ({
108
+ kind: "custom",
109
+ label: args.canvas === undefined ? `Rendering ${args.title}` : `Updating ${args.title}`
110
+ }),
111
+ effects: "none",
112
+ approval: "never",
113
+ replay: "safe",
114
+ async execute(args, invocation) {
115
+ const compiled = await compile(args, invocation);
116
+ const next = {
117
+ runtime: compiled.runtime,
118
+ title: args.title,
119
+ code: compiled.code,
120
+ height: args.height ?? null
121
+ };
122
+ if (args.canvas === undefined) {
123
+ const part = await invocation.session.parts.create(canvas, {
124
+ state: { ...next, error: null },
125
+ placement: { kind: "transcript", role: "answer" }
126
+ });
127
+ return {
128
+ content: [{ kind: "text", text: `Rendered canvas ${part.id}: ${args.title}.` }],
129
+ parts: [part.id]
130
+ };
131
+ }
132
+ const outcome = await invocation.session.part(asId(args.canvas)).act("replace", next);
133
+ if (outcome.kind !== "ok")
134
+ throw new Error(`Canvas ${args.canvas} was not replaced: ${outcome.kind}.`);
135
+ return {
136
+ content: [{ kind: "text", text: `Replaced canvas ${args.canvas}: ${args.title}.` }],
137
+ parts: [asId(args.canvas)]
138
+ };
139
+ }
140
+ };
141
+ }
142
+ var previewParameters = standard(Type.Object({
143
+ source,
144
+ files,
145
+ theme: Type.Optional(Type.Union([Type.Literal("light"), Type.Literal("dark")], {
146
+ description: "The theme to preview in; default light."
147
+ }))
148
+ }));
149
+ var PREVIEW_TIMEOUT_MS = 45000;
150
+ async function previewWithin(preview, request, signal) {
151
+ signal.throwIfAborted();
152
+ const deadline = new AbortController;
153
+ const timer = setTimeout(() => deadline.abort(), PREVIEW_TIMEOUT_MS);
154
+ const stop = AbortSignal.any([signal, deadline.signal]);
155
+ const stopped = new Promise((resolve) => stop.addEventListener("abort", () => resolve("stopped"), { once: true }));
156
+ try {
157
+ const outcome = await Promise.race([preview(request, stop), stopped]);
158
+ if (outcome !== "stopped")
159
+ return outcome;
160
+ } finally {
161
+ clearTimeout(timer);
162
+ }
163
+ signal.throwIfAborted();
164
+ return {
165
+ kind: "unavailable",
166
+ reason: `The preview took longer than ${PREVIEW_TIMEOUT_MS / 1000} seconds.`
167
+ };
168
+ }
169
+ function previewTool(preview) {
170
+ return {
171
+ name: "canvas_preview",
172
+ description: `Render a canvas off-screen in the real canvas runtime and see it before the user does: a PNG at the chat column's width (${CANVAS_PREVIEW_WIDTHS2.chat} px), its height there and at a phone's width (${CANVAS_PREVIEW_WIDTHS2.phone} px), every load or render error with its file and line, and the canvas's console output. Takes the same \`source\` and \`files\` as canvas_render and compiles them the same way; nothing is added to the chat.`,
173
+ parameters: previewParameters,
174
+ class: () => ({ kind: "custom", label: "Previewing canvas" }),
175
+ effects: "none",
176
+ approval: "never",
177
+ replay: "safe",
178
+ async execute(args, invocation) {
179
+ const compiled = await compile(args, invocation);
180
+ const outcome = await previewWithin(preview, {
181
+ module: { runtime: compiled.runtime, code: compiled.code, title: "Preview" },
182
+ theme: args.theme ?? "light"
183
+ }, invocation.signal);
184
+ if (outcome.kind === "unavailable")
185
+ return {
186
+ content: [
187
+ {
188
+ kind: "text",
189
+ text: `No preview here: ${outcome.reason} Render with canvas_render; an error it hits comes back in the canvas next turn.`
190
+ }
191
+ ]
192
+ };
193
+ const { png } = outcome.report;
194
+ const blob = await invocation.env.files.upload(async function* () {
195
+ yield png;
196
+ }());
197
+ return {
198
+ content: [
199
+ { kind: "text", text: describeCanvasPreview2(outcome.report) },
200
+ { kind: "file", blob, mime: "image/png" }
201
+ ]
202
+ };
203
+ }
204
+ };
205
+ }
206
+ function canvasPlugin(preview) {
207
+ return {
208
+ id: "canvas",
209
+ contribute: {
210
+ parts: [canvas],
211
+ tools: preview === undefined ? [renderTool(false)] : [renderTool(true), previewTool(preview)]
212
+ }
213
+ };
214
+ }
215
+ var canvas_default = canvasPlugin();
216
+ export {
217
+ CANVAS_DESCRIPTION,
218
+ canvas,
219
+ canvasPlugin,
220
+ canvas_default as default
221
+ };
@@ -0,0 +1,47 @@
1
+ import type { Infer } from "@nyte-ai/schema";
2
+ declare const state: import("@nyte-ai/schema").Schema<{
3
+ code: string;
4
+ runtime: number;
5
+ title: string;
6
+ error: string | null;
7
+ height: number | null;
8
+ }>;
9
+ /**
10
+ * Returns a canvas part's state: the compiled module, the runtime it needs,
11
+ * its title, the agent's height hint and the last error a client reported.
12
+ *
13
+ * @category plugins
14
+ * @since 0.1.0
15
+ */
16
+ export type CanvasState = Infer<typeof state>;
17
+ /**
18
+ * A canvas part: a React module the agent wrote, compiled on the host and
19
+ * drawn by a client inside the sandboxed runtime shell. `replace` swaps the
20
+ * module in place; `report` records a load or render error a client saw,
21
+ * which the model reads in the fallback.
22
+ *
23
+ * @category plugins
24
+ * @since 0.1.0
25
+ */
26
+ export declare const canvas: import("@nyte-ai/core").PartDefinition<{
27
+ code: string;
28
+ runtime: number;
29
+ title: string;
30
+ error: string | null;
31
+ height: number | null;
32
+ }, {
33
+ replace: {
34
+ input: import("@nyte-ai/schema").Schema<{
35
+ code: string;
36
+ runtime: number;
37
+ title: string;
38
+ height: number | null;
39
+ }>;
40
+ };
41
+ report: {
42
+ input: import("@nyte-ai/schema").Schema<{
43
+ message: string;
44
+ }>;
45
+ };
46
+ }>;
47
+ export {};
@@ -0,0 +1,8 @@
1
+ import {
2
+ canvas2
3
+ } from "../../chunks/billing-mvc33pv6.js";
4
+ import"../../chunks/billing-bv5zr32b.js";
5
+ import"../../chunks/billing-zfpm2rt0.js";
6
+ export {
7
+ canvas2 as canvas
8
+ };
@@ -0,0 +1,35 @@
1
+ import type { Api, Provider } from "@nyte-ai/ai";
2
+ import type { SettingDefinition, ToolDefinition } from "@nyte-ai/core";
3
+ import type { StartQuery } from "./session.ts";
4
+ export declare const ultracodeSetting: SettingDefinition<boolean>;
5
+ export declare function claudeCodeSdk(start?: StartQuery): {
6
+ provider: Provider<Api>;
7
+ plugin: {
8
+ id: string;
9
+ contribute: {
10
+ tools: ToolDefinition<{
11
+ id: string;
12
+ name: string;
13
+ input: Record<string, unknown>;
14
+ }, unknown>[];
15
+ settings: SettingDefinition<boolean>[];
16
+ };
17
+ activate(api: {
18
+ readonly side: "core";
19
+ readonly sdk: import("@nyte-ai/core").Connection;
20
+ readonly contribute: import("@nyte-ai/core").Registries<"core">;
21
+ readonly storage: import("@nyte-ai/core").PluginStorage;
22
+ readonly signal: AbortSignal;
23
+ hook<N extends "session_activated" | "before_send" | "run_started" | "transform_transcript" | "before_compaction" | "before_request" | "before_tool" | "after_tool" | "after_request" | "run_ended">(name: N, entry: import("@nyte-ai/core").HookEntry<"core", N>): import("@nyte-ai/schema").Disposer;
24
+ report(issue: import("@nyte-ai/schema").ValidationIssue): void;
25
+ reload(): void;
26
+ } & {
27
+ readonly session: import("@nyte-ai/core").Session;
28
+ readonly env: import("@nyte-ai/core").ExecutionEnv;
29
+ wrapEnv(wrap: import("@nyte-ai/core").EnvironmentWrap): import("@nyte-ai/schema").Disposer;
30
+ readonly inputs: import("@nyte-ai/core").Resources;
31
+ request<T = string>(input: import("@nyte-ai/schema").ModelRequestInput<T>): Promise<import("@nyte-ai/schema").ModelRequestOutcome<T>>;
32
+ approve(call: import("@nyte-ai/core").RuntimeCall, signal: AbortSignal): Promise<import("@nyte-ai/core").RuntimeVerdict>;
33
+ }): void;
34
+ };
35
+ };