@krak-stack/registry 0.11.1 → 0.11.2
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/CHANGELOG.md +6 -0
- package/dist/components/agent/react.js +29 -183
- package/dist/components/animated-list/react.js +16 -168
- package/dist/components/animated-number/react.js +8 -162
- package/dist/components/async-action-button/react.js +10 -164
- package/dist/components/audit-log-table/react.js +59 -213
- package/dist/components/code-block/react.js +10 -164
- package/dist/components/copy-button/react.js +10 -164
- package/dist/components/copy-value/html.js +4 -4
- package/dist/components/copy-value/react.js +20 -172
- package/dist/components/danger-confirmation/react.js +13 -167
- package/dist/components/data-table/react.js +59 -213
- package/dist/components/editable-text/react.js +14 -168
- package/dist/components/email-composer/react.js +25 -174
- package/dist/components/email-editor/react.js +34 -186
- package/dist/components/error-component/react.js +15 -169
- package/dist/components/icon-input/react.js +7 -161
- package/dist/components/image-crop-editor/react.js +19 -173
- package/dist/components/markdown/react.js +10 -164
- package/dist/components/presence-transition/react.js +9 -163
- package/dist/components/registry-previews/component-example.js +10 -164
- package/dist/components/rich-text-editor/react.js +9 -161
- package/dist/components/search-menu/react.js +11 -165
- package/dist/components/sidebar-layout/react.js +3 -157
- package/dist/components/support/react.js +14 -168
- package/dist/components/timezone-input/react.js +9 -163
- package/dist/components/webhook-delivery-table/react.js +74 -226
- package/dist/lib/docs.integrations.server.js +16 -35
- package/dist/lib/docs.js +31 -183
- package/dist/lib/docs.server.js +16 -35
- package/dist/lib/documentation-toolkit.js +19 -38
- package/dist/lib/effect-ui-adapter/use-model.js +158 -0
- package/dist/services/agent/client/index.js +29 -183
- package/package.json +5 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// ../../src/lib/documentation-toolkit.ts
|
|
2
|
-
import { Effect as
|
|
2
|
+
import { Effect as Effect2, Schema as Schema9 } from "effect";
|
|
3
3
|
import { Tool, Toolkit } from "effect/ai";
|
|
4
4
|
|
|
5
5
|
// ../../src/lib/docs.tsx
|
|
@@ -10,8 +10,8 @@ import { Cookies as Cookies2 } from "effect/http";
|
|
|
10
10
|
import {
|
|
11
11
|
forwardRef,
|
|
12
12
|
useDeferredValue,
|
|
13
|
-
useEffect as
|
|
14
|
-
useState as
|
|
13
|
+
useEffect as useEffect3,
|
|
14
|
+
useState as useState4
|
|
15
15
|
} from "react";
|
|
16
16
|
|
|
17
17
|
// ../../src/lib/utils.ts
|
|
@@ -70,34 +70,13 @@ var buttonVariants = cva2("group/button inline-flex shrink-0 items-center justif
|
|
|
70
70
|
import { Check, Copy, TriangleAlert } from "lucide-react";
|
|
71
71
|
import { Redacted as Redacted2 } from "effect";
|
|
72
72
|
import { Component as Component2 } from "effect/ui";
|
|
73
|
-
import { useLayoutEffect
|
|
73
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
74
74
|
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider/react";
|
|
75
|
-
|
|
76
|
-
// ../../src/lib/effect-ui-adapter/use-model.ts
|
|
77
|
-
import { MessageLog as MessageLog2 } from "effect/ui";
|
|
78
|
-
import {
|
|
79
|
-
createContext,
|
|
80
|
-
useCallback,
|
|
81
|
-
useContext,
|
|
82
|
-
useEffect,
|
|
83
|
-
useLayoutEffect,
|
|
84
|
-
useRef,
|
|
85
|
-
useState,
|
|
86
|
-
useSyncExternalStore
|
|
87
|
-
} from "react";
|
|
88
|
-
|
|
89
|
-
// ../../src/lib/effect-ui-adapter/model-runtime.ts
|
|
90
|
-
import { MessageLog, Renderer, View } from "effect/ui";
|
|
91
|
-
import { BrowserHost, Html } from "effect/ui/html";
|
|
92
|
-
import { Cause, Effect, Fiber } from "effect";
|
|
93
|
-
|
|
94
|
-
// ../../src/lib/effect-ui-adapter/use-model.ts
|
|
95
|
-
"use client";
|
|
96
|
-
var ModelMessageLogContext = createContext(undefined);
|
|
75
|
+
import { useModel } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
97
76
|
|
|
98
77
|
// ../../src/components/copy-button/index.ts
|
|
99
|
-
import { Effect
|
|
100
|
-
import { Command, Component, UiSchema, View
|
|
78
|
+
import { Effect, Redacted, Schema as Schema2 } from "effect";
|
|
79
|
+
import { Command, Component, UiSchema, View } from "effect/ui";
|
|
101
80
|
|
|
102
81
|
// ../../src/components/copy-button/schema.ts
|
|
103
82
|
import { Schema } from "effect";
|
|
@@ -141,13 +120,13 @@ class WriteClipboard extends Command.Service()("copy-button/WriteClipboard", {
|
|
|
141
120
|
},
|
|
142
121
|
success: CopyButtonMessage
|
|
143
122
|
}) {
|
|
144
|
-
static layerFromWrite = (write) => WriteClipboard.toLayer(({ value }) =>
|
|
123
|
+
static layerFromWrite = (write) => WriteClipboard.toLayer(({ value }) => Effect.tryPromise(() => write(Redacted.value(value))).pipe(Effect.match({
|
|
145
124
|
onSuccess: () => CopyButtonMessage.Finished({ success: true }),
|
|
146
125
|
onFailure: () => CopyButtonMessage.Finished({ success: false })
|
|
147
126
|
})));
|
|
148
127
|
static browser = WriteClipboard.layerFromWrite((value) => navigator.clipboard.writeText(value));
|
|
149
128
|
}
|
|
150
|
-
var ResetClipboardFeedback = Command.make("copy-button/ResetFeedback", { args: { delay: Schema2.Number }, mode: "switch" }, ({ delay }) =>
|
|
129
|
+
var ResetClipboardFeedback = Command.make("copy-button/ResetFeedback", { args: { delay: Schema2.Number }, mode: "switch" }, ({ delay }) => Effect.sleep(Math.max(0, delay)).pipe(Effect.as(CopyButtonMessage.Reset())));
|
|
151
130
|
var copyButtonOptions = {
|
|
152
131
|
name: "CopyButton",
|
|
153
132
|
props: CopyButtonModelProps,
|
|
@@ -169,7 +148,7 @@ var copyButtonBehaviours = {
|
|
|
169
148
|
};
|
|
170
149
|
var CopyButtonModel = Definition.make({
|
|
171
150
|
...copyButtonBehaviours,
|
|
172
|
-
view: () =>
|
|
151
|
+
view: () => View.text("")
|
|
173
152
|
});
|
|
174
153
|
// ../../src/components/copy-button/react.tsx
|
|
175
154
|
"use client";
|
|
@@ -206,7 +185,7 @@ import { Collapsible as CollapsiblePrimitive } from "@base-ui/react/collapsible"
|
|
|
206
185
|
|
|
207
186
|
// ../../src/components/search-menu/react.tsx
|
|
208
187
|
import { SearchIcon as SearchIcon2, XIcon as XIcon2 } from "lucide-react";
|
|
209
|
-
import { useCallback
|
|
188
|
+
import { useCallback, useEffect, useRef as useRef2, useState as useState2 } from "react";
|
|
210
189
|
|
|
211
190
|
// ../../src/components/ui/command.tsx
|
|
212
191
|
import { Command as CommandPrimitive } from "cmdk";
|
|
@@ -219,7 +198,8 @@ import { XIcon } from "lucide-react";
|
|
|
219
198
|
|
|
220
199
|
// ../../src/components/search-menu/react.tsx
|
|
221
200
|
import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider/react";
|
|
222
|
-
import { Component as Component4, View as
|
|
201
|
+
import { Component as Component4, View as View2 } from "effect/ui";
|
|
202
|
+
import { useModel as useModel2 } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
223
203
|
|
|
224
204
|
// ../../src/components/search-menu/classes.ts
|
|
225
205
|
var searchMenuClasses = {
|
|
@@ -314,11 +294,12 @@ var searchMenuBehaviours = {
|
|
|
314
294
|
// ../../src/components/search-menu/react.tsx
|
|
315
295
|
var SearchModel = Component4.define(searchMenuOptions).make({
|
|
316
296
|
...searchMenuBehaviours,
|
|
317
|
-
view: () =>
|
|
297
|
+
view: () => View2.text("")
|
|
318
298
|
});
|
|
319
299
|
// ../../src/components/sidebar-layout/react.tsx
|
|
320
300
|
import { Link, Outlet } from "@tanstack/react-router";
|
|
321
|
-
import { Component as Component6, View as
|
|
301
|
+
import { Component as Component6, View as View3 } from "effect/ui";
|
|
302
|
+
import { useModel as useModel3 } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
322
303
|
|
|
323
304
|
// ../../src/components/ui/sidebar.tsx
|
|
324
305
|
import * as React2 from "react";
|
|
@@ -458,7 +439,7 @@ var sidebarLayoutBehaviours = {
|
|
|
458
439
|
// ../../src/components/sidebar-layout/react.tsx
|
|
459
440
|
var SidebarModel = Component6.define(sidebarLayoutOptions).make({
|
|
460
441
|
...sidebarLayoutBehaviours,
|
|
461
|
-
view: () =>
|
|
442
|
+
view: () => View3.text("")
|
|
462
443
|
});
|
|
463
444
|
// ../../src/lib/docs.tsx
|
|
464
445
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
@@ -604,7 +585,7 @@ var ReadDocumentation = Tool.make("readDocumentation", {
|
|
|
604
585
|
}).annotate({ identifier: "ReadDocumentationResult" })
|
|
605
586
|
}).annotate(Tool.Title, "Read documentation").annotate(Tool.Readonly, true).annotate(Tool.Destructive, false).annotate(Tool.Idempotent, true).annotate(Tool.OpenWorld, false);
|
|
606
587
|
var DocumentationToolkit = Toolkit.make(SearchDocumentation, ReadDocumentation);
|
|
607
|
-
var searchDocumentation =
|
|
588
|
+
var searchDocumentation = Effect2.fn("ChatDocumentation.search")(function* ({
|
|
608
589
|
docs,
|
|
609
590
|
locale,
|
|
610
591
|
query
|
|
@@ -616,7 +597,7 @@ var searchDocumentation = Effect3.fn("ChatDocumentation.search")(function* ({
|
|
|
616
597
|
heading: heading?.id
|
|
617
598
|
}));
|
|
618
599
|
});
|
|
619
|
-
var readDocumentation =
|
|
600
|
+
var readDocumentation = Effect2.fn("ChatDocumentation.read")(function* ({
|
|
620
601
|
locale,
|
|
621
602
|
paths,
|
|
622
603
|
docs
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// ../../src/lib/effect-ui-adapter/use-model.ts
|
|
2
|
+
import { MessageLog as MessageLog2 } from "effect/ui";
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
useCallback,
|
|
6
|
+
useContext,
|
|
7
|
+
useEffect,
|
|
8
|
+
useLayoutEffect,
|
|
9
|
+
useRef,
|
|
10
|
+
useState,
|
|
11
|
+
useSyncExternalStore
|
|
12
|
+
} from "react";
|
|
13
|
+
|
|
14
|
+
// ../../src/lib/effect-ui-adapter/model-runtime.ts
|
|
15
|
+
import { MessageLog, Renderer, View } from "effect/ui";
|
|
16
|
+
import { BrowserHost, Html } from "effect/ui/html";
|
|
17
|
+
import { Cause, Effect, Fiber } from "effect";
|
|
18
|
+
var node = () => ({ children: [] });
|
|
19
|
+
var modelHost = (commit) => {
|
|
20
|
+
const remove = (child) => {
|
|
21
|
+
if (!child.parent)
|
|
22
|
+
return;
|
|
23
|
+
child.parent.children.splice(child.parent.children.indexOf(child), 1);
|
|
24
|
+
delete child.parent;
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
createElement: node,
|
|
28
|
+
createText: node,
|
|
29
|
+
setText: () => {},
|
|
30
|
+
setAttr: () => {},
|
|
31
|
+
setProp: () => {},
|
|
32
|
+
setEvents: () => {},
|
|
33
|
+
insertBefore: (parent, child, before) => {
|
|
34
|
+
if (child === before)
|
|
35
|
+
return;
|
|
36
|
+
remove(child);
|
|
37
|
+
const index = before ? parent.children.indexOf(before) : parent.children.length;
|
|
38
|
+
parent.children.splice(index, 0, child);
|
|
39
|
+
child.parent = parent;
|
|
40
|
+
},
|
|
41
|
+
remove,
|
|
42
|
+
parentOf: (child) => child.parent,
|
|
43
|
+
nextOf: (child) => child.parent?.children[child.parent.children.indexOf(child) + 1],
|
|
44
|
+
elements: ["html"],
|
|
45
|
+
controlled: new Set,
|
|
46
|
+
runsMounts: false,
|
|
47
|
+
commit
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
var mountModel = (component, props, publishSnapshot, messageLog, onEmit) => {
|
|
51
|
+
let currentProps = props;
|
|
52
|
+
let root;
|
|
53
|
+
let active = true;
|
|
54
|
+
let failure;
|
|
55
|
+
const publish = () => {
|
|
56
|
+
if (!active)
|
|
57
|
+
return;
|
|
58
|
+
if (failure) {
|
|
59
|
+
publishSnapshot({ error: failure });
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const current = root?.model();
|
|
63
|
+
if (current !== undefined)
|
|
64
|
+
publishSnapshot({ model: current });
|
|
65
|
+
};
|
|
66
|
+
const fiber = Effect.runFork(Effect.scoped(Effect.gen(function* () {
|
|
67
|
+
const mounted = yield* Renderer.mount(component, Effect.succeed(props), node(), {
|
|
68
|
+
head: false,
|
|
69
|
+
onEmit,
|
|
70
|
+
fallback: ({ cause }) => {
|
|
71
|
+
failure = new Error("Effect UI root failed", {
|
|
72
|
+
cause: Cause.squash(cause)
|
|
73
|
+
});
|
|
74
|
+
return View.text("");
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
if (!active)
|
|
78
|
+
return;
|
|
79
|
+
root = mounted;
|
|
80
|
+
if (props !== currentProps)
|
|
81
|
+
mounted.setProps(currentProps);
|
|
82
|
+
publish();
|
|
83
|
+
return yield* Effect.never;
|
|
84
|
+
}).pipe(Effect.provide(Renderer.layer(modelHost(publish))), Effect.provideService(Html.Host, BrowserHost.htmlHost), Effect.provideService(MessageLog.MessageLog, messageLog))));
|
|
85
|
+
return {
|
|
86
|
+
send: (message) => {
|
|
87
|
+
root?.send(message);
|
|
88
|
+
publish();
|
|
89
|
+
},
|
|
90
|
+
setProps: (next) => {
|
|
91
|
+
currentProps = next;
|
|
92
|
+
root?.setProps(next);
|
|
93
|
+
},
|
|
94
|
+
dispose: () => {
|
|
95
|
+
active = false;
|
|
96
|
+
root = undefined;
|
|
97
|
+
Effect.runFork(Fiber.interrupt(fiber));
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// ../../src/lib/effect-ui-adapter/use-model.ts
|
|
103
|
+
"use client";
|
|
104
|
+
var ModelMessageLogContext = createContext(undefined);
|
|
105
|
+
var useModel = (component, props, options = {}) => {
|
|
106
|
+
const contextLog = useContext(ModelMessageLogContext);
|
|
107
|
+
const messageLog = options.messageLog ?? (contextLog === undefined ? MessageLog2.noop : contextLog);
|
|
108
|
+
const [store] = useState(() => {
|
|
109
|
+
const initial = { model: component.init(props).model };
|
|
110
|
+
let snapshot = initial;
|
|
111
|
+
const listeners = new Set;
|
|
112
|
+
return {
|
|
113
|
+
subscribe: (listener) => {
|
|
114
|
+
listeners.add(listener);
|
|
115
|
+
return () => {
|
|
116
|
+
listeners.delete(listener);
|
|
117
|
+
};
|
|
118
|
+
},
|
|
119
|
+
getSnapshot: () => snapshot,
|
|
120
|
+
getServerSnapshot: () => initial,
|
|
121
|
+
publish: (next) => {
|
|
122
|
+
if ("model" in snapshot && "model" in next && Object.is(snapshot.model, next.model))
|
|
123
|
+
return;
|
|
124
|
+
if ("error" in snapshot && "error" in next && snapshot.error === next.error)
|
|
125
|
+
return;
|
|
126
|
+
snapshot = next;
|
|
127
|
+
listeners.forEach((listener) => listener());
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);
|
|
132
|
+
const committed = useRef(props);
|
|
133
|
+
const onEmit = useRef(options.onEmit);
|
|
134
|
+
const runtime = useRef(undefined);
|
|
135
|
+
const send = useCallback((message) => runtime.current?.send(message), []);
|
|
136
|
+
useLayoutEffect(() => {
|
|
137
|
+
onEmit.current = options.onEmit;
|
|
138
|
+
committed.current = props;
|
|
139
|
+
runtime.current?.setProps(props);
|
|
140
|
+
}, [props, options.onEmit]);
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
if (messageLog === null)
|
|
143
|
+
return;
|
|
144
|
+
const mounted = mountModel(component, committed.current, store.publish, messageLog, (event) => onEmit.current?.(event));
|
|
145
|
+
runtime.current = mounted;
|
|
146
|
+
return () => {
|
|
147
|
+
runtime.current = undefined;
|
|
148
|
+
mounted.dispose();
|
|
149
|
+
};
|
|
150
|
+
}, [component, messageLog, store]);
|
|
151
|
+
if ("error" in snapshot)
|
|
152
|
+
throw snapshot.error;
|
|
153
|
+
return { model: snapshot.model, send };
|
|
154
|
+
};
|
|
155
|
+
export {
|
|
156
|
+
ModelMessageLogContext,
|
|
157
|
+
useModel
|
|
158
|
+
};
|
|
@@ -147,7 +147,7 @@ var makeAgentAtoms = ({
|
|
|
147
147
|
return { removeContext, reset, state, submit };
|
|
148
148
|
};
|
|
149
149
|
// ../../src/components/agent/react.tsx
|
|
150
|
-
import { useEffect
|
|
150
|
+
import { useEffect, useId, useRef as useRef2, useState as useState2 } from "react";
|
|
151
151
|
import { Dialog as DialogPrimitive2 } from "@base-ui/react/dialog";
|
|
152
152
|
import {
|
|
153
153
|
ArrowDownIcon as ArrowDownIcon2,
|
|
@@ -214,167 +214,13 @@ function Button({
|
|
|
214
214
|
import { Check, Copy, TriangleAlert } from "lucide-react";
|
|
215
215
|
import { Redacted as Redacted2 } from "effect";
|
|
216
216
|
import { Component as Component2 } from "effect/ui";
|
|
217
|
-
import { useLayoutEffect
|
|
217
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
218
218
|
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider/react";
|
|
219
|
-
|
|
220
|
-
// ../../src/lib/effect-ui-adapter/use-model.ts
|
|
221
|
-
import { MessageLog as MessageLog2 } from "effect/ui";
|
|
222
|
-
import {
|
|
223
|
-
createContext,
|
|
224
|
-
useCallback,
|
|
225
|
-
useContext,
|
|
226
|
-
useEffect,
|
|
227
|
-
useLayoutEffect,
|
|
228
|
-
useRef,
|
|
229
|
-
useState,
|
|
230
|
-
useSyncExternalStore
|
|
231
|
-
} from "react";
|
|
232
|
-
|
|
233
|
-
// ../../src/lib/effect-ui-adapter/model-runtime.ts
|
|
234
|
-
import { MessageLog, Renderer, View } from "effect/ui";
|
|
235
|
-
import { BrowserHost, Html } from "effect/ui/html";
|
|
236
|
-
import { Cause, Effect as Effect2, Fiber } from "effect";
|
|
237
|
-
var node = () => ({ children: [] });
|
|
238
|
-
var modelHost = (commit) => {
|
|
239
|
-
const remove = (child) => {
|
|
240
|
-
if (!child.parent)
|
|
241
|
-
return;
|
|
242
|
-
child.parent.children.splice(child.parent.children.indexOf(child), 1);
|
|
243
|
-
delete child.parent;
|
|
244
|
-
};
|
|
245
|
-
return {
|
|
246
|
-
createElement: node,
|
|
247
|
-
createText: node,
|
|
248
|
-
setText: () => {},
|
|
249
|
-
setAttr: () => {},
|
|
250
|
-
setProp: () => {},
|
|
251
|
-
setEvents: () => {},
|
|
252
|
-
insertBefore: (parent, child, before) => {
|
|
253
|
-
if (child === before)
|
|
254
|
-
return;
|
|
255
|
-
remove(child);
|
|
256
|
-
const index = before ? parent.children.indexOf(before) : parent.children.length;
|
|
257
|
-
parent.children.splice(index, 0, child);
|
|
258
|
-
child.parent = parent;
|
|
259
|
-
},
|
|
260
|
-
remove,
|
|
261
|
-
parentOf: (child) => child.parent,
|
|
262
|
-
nextOf: (child) => child.parent?.children[child.parent.children.indexOf(child) + 1],
|
|
263
|
-
elements: ["html"],
|
|
264
|
-
controlled: new Set,
|
|
265
|
-
runsMounts: false,
|
|
266
|
-
commit
|
|
267
|
-
};
|
|
268
|
-
};
|
|
269
|
-
var mountModel = (component, props, publishSnapshot, messageLog, onEmit) => {
|
|
270
|
-
let currentProps = props;
|
|
271
|
-
let root;
|
|
272
|
-
let active = true;
|
|
273
|
-
let failure;
|
|
274
|
-
const publish = () => {
|
|
275
|
-
if (!active)
|
|
276
|
-
return;
|
|
277
|
-
if (failure) {
|
|
278
|
-
publishSnapshot({ error: failure });
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
const current = root?.model();
|
|
282
|
-
if (current !== undefined)
|
|
283
|
-
publishSnapshot({ model: current });
|
|
284
|
-
};
|
|
285
|
-
const fiber = Effect2.runFork(Effect2.scoped(Effect2.gen(function* () {
|
|
286
|
-
const mounted = yield* Renderer.mount(component, Effect2.succeed(props), node(), {
|
|
287
|
-
head: false,
|
|
288
|
-
onEmit,
|
|
289
|
-
fallback: ({ cause }) => {
|
|
290
|
-
failure = new Error("Effect UI root failed", {
|
|
291
|
-
cause: Cause.squash(cause)
|
|
292
|
-
});
|
|
293
|
-
return View.text("");
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
if (!active)
|
|
297
|
-
return;
|
|
298
|
-
root = mounted;
|
|
299
|
-
if (props !== currentProps)
|
|
300
|
-
mounted.setProps(currentProps);
|
|
301
|
-
publish();
|
|
302
|
-
return yield* Effect2.never;
|
|
303
|
-
}).pipe(Effect2.provide(Renderer.layer(modelHost(publish))), Effect2.provideService(Html.Host, BrowserHost.htmlHost), Effect2.provideService(MessageLog.MessageLog, messageLog))));
|
|
304
|
-
return {
|
|
305
|
-
send: (message) => {
|
|
306
|
-
root?.send(message);
|
|
307
|
-
publish();
|
|
308
|
-
},
|
|
309
|
-
setProps: (next) => {
|
|
310
|
-
currentProps = next;
|
|
311
|
-
root?.setProps(next);
|
|
312
|
-
},
|
|
313
|
-
dispose: () => {
|
|
314
|
-
active = false;
|
|
315
|
-
root = undefined;
|
|
316
|
-
Effect2.runFork(Fiber.interrupt(fiber));
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
// ../../src/lib/effect-ui-adapter/use-model.ts
|
|
322
|
-
"use client";
|
|
323
|
-
var ModelMessageLogContext = createContext(undefined);
|
|
324
|
-
var useModel = (component, props, options = {}) => {
|
|
325
|
-
const contextLog = useContext(ModelMessageLogContext);
|
|
326
|
-
const messageLog = options.messageLog ?? (contextLog === undefined ? MessageLog2.noop : contextLog);
|
|
327
|
-
const [store] = useState(() => {
|
|
328
|
-
const initial = { model: component.init(props).model };
|
|
329
|
-
let snapshot = initial;
|
|
330
|
-
const listeners = new Set;
|
|
331
|
-
return {
|
|
332
|
-
subscribe: (listener) => {
|
|
333
|
-
listeners.add(listener);
|
|
334
|
-
return () => {
|
|
335
|
-
listeners.delete(listener);
|
|
336
|
-
};
|
|
337
|
-
},
|
|
338
|
-
getSnapshot: () => snapshot,
|
|
339
|
-
getServerSnapshot: () => initial,
|
|
340
|
-
publish: (next) => {
|
|
341
|
-
if ("model" in snapshot && "model" in next && Object.is(snapshot.model, next.model))
|
|
342
|
-
return;
|
|
343
|
-
if ("error" in snapshot && "error" in next && snapshot.error === next.error)
|
|
344
|
-
return;
|
|
345
|
-
snapshot = next;
|
|
346
|
-
listeners.forEach((listener) => listener());
|
|
347
|
-
}
|
|
348
|
-
};
|
|
349
|
-
});
|
|
350
|
-
const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);
|
|
351
|
-
const committed = useRef(props);
|
|
352
|
-
const onEmit = useRef(options.onEmit);
|
|
353
|
-
const runtime = useRef(undefined);
|
|
354
|
-
const send = useCallback((message) => runtime.current?.send(message), []);
|
|
355
|
-
useLayoutEffect(() => {
|
|
356
|
-
onEmit.current = options.onEmit;
|
|
357
|
-
committed.current = props;
|
|
358
|
-
runtime.current?.setProps(props);
|
|
359
|
-
}, [props, options.onEmit]);
|
|
360
|
-
useEffect(() => {
|
|
361
|
-
if (messageLog === null)
|
|
362
|
-
return;
|
|
363
|
-
const mounted = mountModel(component, committed.current, store.publish, messageLog, (event) => onEmit.current?.(event));
|
|
364
|
-
runtime.current = mounted;
|
|
365
|
-
return () => {
|
|
366
|
-
runtime.current = undefined;
|
|
367
|
-
mounted.dispose();
|
|
368
|
-
};
|
|
369
|
-
}, [component, messageLog, store]);
|
|
370
|
-
if ("error" in snapshot)
|
|
371
|
-
throw snapshot.error;
|
|
372
|
-
return { model: snapshot.model, send };
|
|
373
|
-
};
|
|
219
|
+
import { useModel } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
374
220
|
|
|
375
221
|
// ../../src/components/copy-button/index.ts
|
|
376
|
-
import { Effect as
|
|
377
|
-
import { Command, Component, UiSchema, View
|
|
222
|
+
import { Effect as Effect2, Redacted, Schema as Schema3 } from "effect";
|
|
223
|
+
import { Command, Component, UiSchema, View } from "effect/ui";
|
|
378
224
|
|
|
379
225
|
// ../../src/components/copy-button/schema.ts
|
|
380
226
|
import { Schema as Schema2 } from "effect";
|
|
@@ -429,13 +275,13 @@ class WriteClipboard extends Command.Service()("copy-button/WriteClipboard", {
|
|
|
429
275
|
},
|
|
430
276
|
success: CopyButtonMessage
|
|
431
277
|
}) {
|
|
432
|
-
static layerFromWrite = (write) => WriteClipboard.toLayer(({ value }) =>
|
|
278
|
+
static layerFromWrite = (write) => WriteClipboard.toLayer(({ value }) => Effect2.tryPromise(() => write(Redacted.value(value))).pipe(Effect2.match({
|
|
433
279
|
onSuccess: () => CopyButtonMessage.Finished({ success: true }),
|
|
434
280
|
onFailure: () => CopyButtonMessage.Finished({ success: false })
|
|
435
281
|
})));
|
|
436
282
|
static browser = WriteClipboard.layerFromWrite((value) => navigator.clipboard.writeText(value));
|
|
437
283
|
}
|
|
438
|
-
var ResetClipboardFeedback = Command.make("copy-button/ResetFeedback", { args: { delay: Schema3.Number }, mode: "switch" }, ({ delay }) =>
|
|
284
|
+
var ResetClipboardFeedback = Command.make("copy-button/ResetFeedback", { args: { delay: Schema3.Number }, mode: "switch" }, ({ delay }) => Effect2.sleep(Math.max(0, delay)).pipe(Effect2.as(CopyButtonMessage.Reset())));
|
|
439
285
|
var copyButtonOptions = {
|
|
440
286
|
name: "CopyButton",
|
|
441
287
|
props: CopyButtonModelProps,
|
|
@@ -457,7 +303,7 @@ var copyButtonBehaviours = {
|
|
|
457
303
|
};
|
|
458
304
|
var CopyButtonModel = Definition.make({
|
|
459
305
|
...copyButtonBehaviours,
|
|
460
|
-
view: () =>
|
|
306
|
+
view: () => View.text("")
|
|
461
307
|
});
|
|
462
308
|
var copyButtonStatus = (status, copy, description) => {
|
|
463
309
|
if (status === "idle")
|
|
@@ -485,19 +331,19 @@ function CopyButton({
|
|
|
485
331
|
}) {
|
|
486
332
|
const locale = useKrakstackLocale(localeOverride);
|
|
487
333
|
const labels = copyButtonMessages(locale, messages);
|
|
488
|
-
const callbacks =
|
|
334
|
+
const callbacks = useRef({
|
|
489
335
|
onCopied,
|
|
490
336
|
onCopyError,
|
|
491
337
|
failureLabel: labels.copyFailed
|
|
492
338
|
});
|
|
493
|
-
|
|
339
|
+
useLayoutEffect(() => {
|
|
494
340
|
callbacks.current = {
|
|
495
341
|
onCopied,
|
|
496
342
|
onCopyError,
|
|
497
343
|
failureLabel: labels.copyFailed
|
|
498
344
|
};
|
|
499
345
|
}, [onCopied, onCopyError, labels.copyFailed]);
|
|
500
|
-
const [component] =
|
|
346
|
+
const [component] = useState(() => CopyButtonModel.pipe(Component2.provide(WriteClipboard.layerFromWrite(async (text) => {
|
|
501
347
|
const { onCopied, onCopyError, failureLabel } = callbacks.current;
|
|
502
348
|
try {
|
|
503
349
|
await navigator.clipboard.writeText(text);
|
|
@@ -1669,7 +1515,7 @@ var AgentStreamError = Schema4.Struct({
|
|
|
1669
1515
|
import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider/react";
|
|
1670
1516
|
|
|
1671
1517
|
// ../../src/components/agent/index.ts
|
|
1672
|
-
import { Context, Effect as
|
|
1518
|
+
import { Context, Effect as Effect3, Layer as Layer2, Redacted as Redacted3, Schema as Schema6, Stream as Stream2 } from "effect";
|
|
1673
1519
|
import { AtomRegistry } from "effect/reactivity";
|
|
1674
1520
|
import { Command as Command3, Component as Component3, Subscription, UiSchema as UiSchema2 } from "effect/ui";
|
|
1675
1521
|
|
|
@@ -1732,7 +1578,7 @@ var AgentWidgetIntentSchema = Schema5.Union([
|
|
|
1732
1578
|
|
|
1733
1579
|
// ../../src/components/agent/index.ts
|
|
1734
1580
|
class ConversationHost extends Context.Service()("agent/ConversationHost") {
|
|
1735
|
-
static layer = (host) => Layer2.merge(Layer2.succeed(ConversationHost, host), DispatchIntent.toLayer(({ intent }) =>
|
|
1581
|
+
static layer = (host) => Layer2.merge(Layer2.succeed(ConversationHost, host), DispatchIntent.toLayer(({ intent }) => Effect3.suspend(() => host.dispatch(intent)).pipe(Effect3.match({
|
|
1736
1582
|
onSuccess: () => AgentWidgetMessage.Delivered({ success: true }),
|
|
1737
1583
|
onFailure: () => AgentWidgetMessage.Delivered({ success: false })
|
|
1738
1584
|
}))));
|
|
@@ -1877,7 +1723,7 @@ var agentWidgetBehaviours = {
|
|
|
1877
1723
|
maximized: false
|
|
1878
1724
|
}),
|
|
1879
1725
|
subscriptions: () => [
|
|
1880
|
-
Subscription.make("agent/conversation", Stream2.unwrap(
|
|
1726
|
+
Subscription.make("agent/conversation", Stream2.unwrap(Effect3.map(ConversationHost, (host) => host.snapshots.pipe(Stream2.map((snapshot) => AgentWidgetMessage.Received({
|
|
1881
1727
|
snapshot: Redacted3.make(snapshot)
|
|
1882
1728
|
})), Stream2.concat(Stream2.make(AgentWidgetMessage.Disconnected()))))))
|
|
1883
1729
|
],
|
|
@@ -2175,7 +2021,7 @@ function ToolActivityLog({
|
|
|
2175
2021
|
tools,
|
|
2176
2022
|
workedSeconds
|
|
2177
2023
|
}) {
|
|
2178
|
-
const [open, setOpen] =
|
|
2024
|
+
const [open, setOpen] = useState2();
|
|
2179
2025
|
const approvals = tools.filter((tool) => tool.status === "approval-required");
|
|
2180
2026
|
const activity = tools.filter((tool) => tool.status !== "approval-required");
|
|
2181
2027
|
const currentTool = activity.at(-1);
|
|
@@ -2252,12 +2098,12 @@ function AgentMessageRow({
|
|
|
2252
2098
|
pending
|
|
2253
2099
|
}) {
|
|
2254
2100
|
const isUser = message.role === "user";
|
|
2255
|
-
const activeStartedAt =
|
|
2256
|
-
const activeMilliseconds =
|
|
2257
|
-
const wasPending =
|
|
2258
|
-
const [workedSeconds, setWorkedSeconds] =
|
|
2101
|
+
const activeStartedAt = useRef2(undefined);
|
|
2102
|
+
const activeMilliseconds = useRef2(0);
|
|
2103
|
+
const wasPending = useRef2(pending);
|
|
2104
|
+
const [workedSeconds, setWorkedSeconds] = useState2();
|
|
2259
2105
|
const hasPendingApproval = message.tools.some((tool) => tool.status === "approval-required");
|
|
2260
|
-
|
|
2106
|
+
useEffect(() => {
|
|
2261
2107
|
const isWorking = pending && !hasPendingApproval;
|
|
2262
2108
|
if (isWorking) {
|
|
2263
2109
|
wasPending.current = true;
|
|
@@ -2342,15 +2188,15 @@ function AgentWidget({
|
|
|
2342
2188
|
const labels = agentWidgetMessages(locale, messageOverrides);
|
|
2343
2189
|
const referenceInputId = useId();
|
|
2344
2190
|
const referenceListId = `${referenceInputId}-list`;
|
|
2345
|
-
const [open, setOpen] =
|
|
2346
|
-
const [maximized, setMaximized] =
|
|
2347
|
-
const [referencePickerOpen, setReferencePickerOpen] =
|
|
2348
|
-
const [activeReferenceKey, setActiveReferenceKey] =
|
|
2349
|
-
const [activeReferenceSearch, setActiveReferenceSearch] =
|
|
2350
|
-
const [input, setInput] =
|
|
2351
|
-
const inputRef =
|
|
2352
|
-
const inputOverlayRef =
|
|
2353
|
-
const [references, setReferences] =
|
|
2191
|
+
const [open, setOpen] = useState2(false);
|
|
2192
|
+
const [maximized, setMaximized] = useState2(false);
|
|
2193
|
+
const [referencePickerOpen, setReferencePickerOpen] = useState2(false);
|
|
2194
|
+
const [activeReferenceKey, setActiveReferenceKey] = useState2("");
|
|
2195
|
+
const [activeReferenceSearch, setActiveReferenceSearch] = useState2();
|
|
2196
|
+
const [input, setInput] = useState2("");
|
|
2197
|
+
const inputRef = useRef2(null);
|
|
2198
|
+
const inputOverlayRef = useRef2(null);
|
|
2199
|
+
const [references, setReferences] = useState2([]);
|
|
2354
2200
|
const activeContext = state.contextLocked ? state.context ? {
|
|
2355
2201
|
...state.context,
|
|
2356
2202
|
icon: availableReferences.find(({ key }) => key === state.context?.key)?.icon
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krak-stack/registry",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.2",
|
|
4
4
|
"description": "Tree-shakable KrakStack components and Effect services.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
"types": "./dist/components/ui/select.d.ts",
|
|
22
22
|
"import": "./dist/components/ui/select.js"
|
|
23
23
|
},
|
|
24
|
+
"./effect-ui-adapter/react": {
|
|
25
|
+
"types": "./dist/lib/effect-ui-adapter/use-model.d.ts",
|
|
26
|
+
"import": "./dist/lib/effect-ui-adapter/use-model.js"
|
|
27
|
+
},
|
|
24
28
|
"./*/react": {
|
|
25
29
|
"types": "./dist/components/*/react.d.ts",
|
|
26
30
|
"import": "./dist/components/*/react.js"
|