@krak-stack/registry 0.10.14 → 0.10.15
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 +7 -0
- package/dist/components/support-dialog.js +215 -173
- package/dist/components/ui/dialog.d.ts +8 -4
- package/dist/components/ui/map-menu.js +23 -11
- package/dist/components/ui/search-menu.js +16 -14
- package/dist/lib/docs.integrations.server.js +1 -0
- package/dist/lib/docs.js +16 -14
- package/dist/lib/docs.server.js +1 -0
- package/dist/lib/documentation-toolkit.js +1 -0
- package/dist/services/agent/client/index.js +21 -23
- package/dist/services/clamav/index.d.ts +31 -0
- package/dist/services/clamav/index.js +124 -0
- package/dist/services/events/client/tracking-notice.js +34 -18
- package/dist/services/speech/api.js +18 -0
- package/dist/services/speech/index.js +37 -11
- package/dist/services/speech/schema.d.ts +25 -0
- package/dist/services/speech/schema.js +20 -0
- package/dist/services/webhooks/client/delivery-table.js +15 -13
- package/package.json +5 -1
package/dist/lib/docs.js
CHANGED
|
@@ -457,6 +457,7 @@ import { SearchIcon } from "lucide-react";
|
|
|
457
457
|
|
|
458
458
|
// ../../src/components/ui/dialog.tsx
|
|
459
459
|
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
|
|
460
|
+
import { cn as cn2 } from "cn";
|
|
460
461
|
import { XIcon } from "lucide-react";
|
|
461
462
|
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
462
463
|
function Dialog({ ...props }) {
|
|
@@ -477,13 +478,14 @@ function DialogOverlay({
|
|
|
477
478
|
}) {
|
|
478
479
|
return /* @__PURE__ */ jsx7(DialogPrimitive.Backdrop, {
|
|
479
480
|
"data-slot": "dialog-overlay",
|
|
480
|
-
className:
|
|
481
|
+
className: cn2("data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs", className),
|
|
481
482
|
...props
|
|
482
483
|
});
|
|
483
484
|
}
|
|
484
485
|
function DialogContent({
|
|
485
486
|
className,
|
|
486
487
|
children,
|
|
488
|
+
showCloseButton = true,
|
|
487
489
|
...props
|
|
488
490
|
}) {
|
|
489
491
|
return /* @__PURE__ */ jsxs4(DialogPortal, {
|
|
@@ -491,16 +493,19 @@ function DialogContent({
|
|
|
491
493
|
/* @__PURE__ */ jsx7(DialogOverlay, {}),
|
|
492
494
|
/* @__PURE__ */ jsxs4(DialogPrimitive.Popup, {
|
|
493
495
|
"data-slot": "dialog-content",
|
|
494
|
-
className:
|
|
496
|
+
className: cn2("bg-popover text-popover-foreground ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl p-6 text-sm ring-1 duration-100 outline-none sm:max-w-md", className),
|
|
495
497
|
...props,
|
|
496
498
|
children: [
|
|
497
499
|
children,
|
|
498
|
-
/* @__PURE__ */ jsxs4(DialogPrimitive.Close, {
|
|
499
|
-
|
|
500
|
+
showCloseButton && /* @__PURE__ */ jsxs4(DialogPrimitive.Close, {
|
|
501
|
+
"data-slot": "dialog-close",
|
|
502
|
+
render: /* @__PURE__ */ jsx7(Button, {
|
|
503
|
+
variant: "ghost",
|
|
504
|
+
className: "absolute top-4 right-4",
|
|
505
|
+
size: "icon-sm"
|
|
506
|
+
}),
|
|
500
507
|
children: [
|
|
501
|
-
/* @__PURE__ */ jsx7(XIcon, {
|
|
502
|
-
className: "size-4"
|
|
503
|
-
}),
|
|
508
|
+
/* @__PURE__ */ jsx7(XIcon, {}),
|
|
504
509
|
/* @__PURE__ */ jsx7("span", {
|
|
505
510
|
className: "sr-only",
|
|
506
511
|
children: "Close"
|
|
@@ -515,17 +520,14 @@ function DialogContent({
|
|
|
515
520
|
function DialogHeader({ className, ...props }) {
|
|
516
521
|
return /* @__PURE__ */ jsx7("div", {
|
|
517
522
|
"data-slot": "dialog-header",
|
|
518
|
-
className:
|
|
523
|
+
className: cn2("flex flex-col gap-2", className),
|
|
519
524
|
...props
|
|
520
525
|
});
|
|
521
526
|
}
|
|
522
|
-
function DialogTitle({
|
|
523
|
-
className,
|
|
524
|
-
...props
|
|
525
|
-
}) {
|
|
527
|
+
function DialogTitle({ className, ...props }) {
|
|
526
528
|
return /* @__PURE__ */ jsx7(DialogPrimitive.Title, {
|
|
527
529
|
"data-slot": "dialog-title",
|
|
528
|
-
className:
|
|
530
|
+
className: cn2("leading-none font-medium", className),
|
|
529
531
|
...props
|
|
530
532
|
});
|
|
531
533
|
}
|
|
@@ -535,7 +537,7 @@ function DialogDescription({
|
|
|
535
537
|
}) {
|
|
536
538
|
return /* @__PURE__ */ jsx7(DialogPrimitive.Description, {
|
|
537
539
|
"data-slot": "dialog-description",
|
|
538
|
-
className:
|
|
540
|
+
className: cn2("text-muted-foreground *:[a]:hover:text-foreground text-sm *:[a]:underline *:[a]:underline-offset-3", className),
|
|
539
541
|
...props
|
|
540
542
|
});
|
|
541
543
|
}
|
package/dist/lib/docs.server.js
CHANGED
|
@@ -111,6 +111,7 @@ import { SearchIcon } from "lucide-react";
|
|
|
111
111
|
|
|
112
112
|
// ../../src/components/ui/dialog.tsx
|
|
113
113
|
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
|
|
114
|
+
import { cn as cn2 } from "cn";
|
|
114
115
|
import { XIcon } from "lucide-react";
|
|
115
116
|
|
|
116
117
|
// ../../src/components/ui/search-menu.tsx
|
|
@@ -111,6 +111,7 @@ import { SearchIcon } from "lucide-react";
|
|
|
111
111
|
|
|
112
112
|
// ../../src/components/ui/dialog.tsx
|
|
113
113
|
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
|
|
114
|
+
import { cn as cn2 } from "cn";
|
|
114
115
|
import { XIcon } from "lucide-react";
|
|
115
116
|
|
|
116
117
|
// ../../src/components/ui/search-menu.tsx
|
|
@@ -678,6 +678,7 @@ import { SearchIcon } from "lucide-react";
|
|
|
678
678
|
|
|
679
679
|
// ../../src/components/ui/dialog.tsx
|
|
680
680
|
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
|
|
681
|
+
import { cn as cn2 } from "cn";
|
|
681
682
|
import { XIcon } from "lucide-react";
|
|
682
683
|
import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
683
684
|
function Dialog({ ...props }) {
|
|
@@ -707,17 +708,14 @@ function DialogClose({ ...props }) {
|
|
|
707
708
|
function DialogHeader({ className, ...props }) {
|
|
708
709
|
return /* @__PURE__ */ jsx8("div", {
|
|
709
710
|
"data-slot": "dialog-header",
|
|
710
|
-
className:
|
|
711
|
+
className: cn2("flex flex-col gap-2", className),
|
|
711
712
|
...props
|
|
712
713
|
});
|
|
713
714
|
}
|
|
714
|
-
function DialogTitle({
|
|
715
|
-
className,
|
|
716
|
-
...props
|
|
717
|
-
}) {
|
|
715
|
+
function DialogTitle({ className, ...props }) {
|
|
718
716
|
return /* @__PURE__ */ jsx8(DialogPrimitive.Title, {
|
|
719
717
|
"data-slot": "dialog-title",
|
|
720
|
-
className:
|
|
718
|
+
className: cn2("leading-none font-medium", className),
|
|
721
719
|
...props
|
|
722
720
|
});
|
|
723
721
|
}
|
|
@@ -927,7 +925,7 @@ function InputGroupTextarea({
|
|
|
927
925
|
import { mergeProps as mergeProps4 } from "@base-ui/react/merge-props";
|
|
928
926
|
import { useRender as useRender4 } from "@base-ui/react/use-render";
|
|
929
927
|
import { cva as cva8 } from "class-variance-authority";
|
|
930
|
-
import { cn as
|
|
928
|
+
import { cn as cn3 } from "cn";
|
|
931
929
|
|
|
932
930
|
// ../../src/components/ui/separator.tsx
|
|
933
931
|
import { Separator as SeparatorPrimitive } from "@base-ui/react/separator";
|
|
@@ -962,7 +960,7 @@ function Item({
|
|
|
962
960
|
return useRender4({
|
|
963
961
|
defaultTagName: "div",
|
|
964
962
|
props: mergeProps4({
|
|
965
|
-
className:
|
|
963
|
+
className: cn3(itemVariants({ variant, size, className }))
|
|
966
964
|
}, props),
|
|
967
965
|
render,
|
|
968
966
|
state: {
|
|
@@ -992,42 +990,42 @@ function ItemMedia({
|
|
|
992
990
|
return /* @__PURE__ */ jsx13("div", {
|
|
993
991
|
"data-slot": "item-media",
|
|
994
992
|
"data-variant": variant,
|
|
995
|
-
className:
|
|
993
|
+
className: cn3(itemMediaVariants({ variant, className })),
|
|
996
994
|
...props
|
|
997
995
|
});
|
|
998
996
|
}
|
|
999
997
|
function ItemContent({ className, ...props }) {
|
|
1000
998
|
return /* @__PURE__ */ jsx13("div", {
|
|
1001
999
|
"data-slot": "item-content",
|
|
1002
|
-
className:
|
|
1000
|
+
className: cn3("flex flex-1 flex-col gap-1 group-data-[size=xs]/item:gap-0 [&+[data-slot=item-content]]:flex-none", className),
|
|
1003
1001
|
...props
|
|
1004
1002
|
});
|
|
1005
1003
|
}
|
|
1006
1004
|
function ItemTitle({ className, ...props }) {
|
|
1007
1005
|
return /* @__PURE__ */ jsx13("div", {
|
|
1008
1006
|
"data-slot": "item-title",
|
|
1009
|
-
className:
|
|
1007
|
+
className: cn3("line-clamp-1 flex w-fit items-center gap-2 text-sm leading-snug font-medium underline-offset-4", className),
|
|
1010
1008
|
...props
|
|
1011
1009
|
});
|
|
1012
1010
|
}
|
|
1013
1011
|
function ItemDescription({ className, ...props }) {
|
|
1014
1012
|
return /* @__PURE__ */ jsx13("p", {
|
|
1015
1013
|
"data-slot": "item-description",
|
|
1016
|
-
className:
|
|
1014
|
+
className: cn3("line-clamp-2 text-left text-sm leading-normal font-normal text-muted-foreground group-data-[size=xs]/item:text-xs [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary", className),
|
|
1017
1015
|
...props
|
|
1018
1016
|
});
|
|
1019
1017
|
}
|
|
1020
1018
|
function ItemActions({ className, ...props }) {
|
|
1021
1019
|
return /* @__PURE__ */ jsx13("div", {
|
|
1022
1020
|
"data-slot": "item-actions",
|
|
1023
|
-
className:
|
|
1021
|
+
className: cn3("flex items-center gap-2", className),
|
|
1024
1022
|
...props
|
|
1025
1023
|
});
|
|
1026
1024
|
}
|
|
1027
1025
|
function ItemFooter({ className, ...props }) {
|
|
1028
1026
|
return /* @__PURE__ */ jsx13("div", {
|
|
1029
1027
|
"data-slot": "item-footer",
|
|
1030
|
-
className:
|
|
1028
|
+
className: cn3("flex basis-full items-center justify-between gap-2", className),
|
|
1031
1029
|
...props
|
|
1032
1030
|
});
|
|
1033
1031
|
}
|
|
@@ -1183,7 +1181,7 @@ function PopoverContent({
|
|
|
1183
1181
|
}
|
|
1184
1182
|
|
|
1185
1183
|
// ../../src/components/ui/trace.tsx
|
|
1186
|
-
import { cn as
|
|
1184
|
+
import { cn as cn4 } from "cn";
|
|
1187
1185
|
|
|
1188
1186
|
// ../../src/components/ui/collapsible.tsx
|
|
1189
1187
|
import { Collapsible as CollapsiblePrimitive } from "@base-ui/react/collapsible";
|
|
@@ -1213,7 +1211,7 @@ import { jsx as jsx18, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
|
1213
1211
|
function Trace({ className, ...props }) {
|
|
1214
1212
|
return /* @__PURE__ */ jsx18("div", {
|
|
1215
1213
|
"data-slot": "trace",
|
|
1216
|
-
className:
|
|
1214
|
+
className: cn4("flex w-full min-w-0 flex-col gap-2 *:has-[>[data-slot=trace-line]]:flex *:has-[>[data-slot=trace-line]]:w-fit *:has-[>[data-slot=trace-line]]:max-w-full *:has-[>[data-slot=trace-line]]:min-w-0 *:has-[>[data-slot=trace-line]]:rounded-md *:has-[>[data-slot=trace-line]]:text-left *:has-[>[data-slot=trace-line]]:outline-none *:has-[>[data-slot=trace-line]]:focus-visible:ring-3 *:has-[>[data-slot=trace-line]]:focus-visible:ring-ring/50", className),
|
|
1217
1215
|
...props
|
|
1218
1216
|
});
|
|
1219
1217
|
}
|
|
@@ -1225,7 +1223,7 @@ function TraceLine({
|
|
|
1225
1223
|
return /* @__PURE__ */ jsx18("span", {
|
|
1226
1224
|
"data-slot": "trace-line",
|
|
1227
1225
|
"data-status": status,
|
|
1228
|
-
className:
|
|
1226
|
+
className: cn4("flex w-fit max-w-full min-w-0 items-center gap-2 text-sm text-muted-foreground transition-colors in-[a,button]:cursor-pointer in-[a:hover,button:hover]:text-foreground data-[status=error]:text-destructive data-[status=error]:in-[a:hover,button:hover]:text-destructive data-[status=pending]:opacity-60 data-[status=running]:*:data-[slot=trace-title]:shimmer", className),
|
|
1229
1227
|
...props
|
|
1230
1228
|
});
|
|
1231
1229
|
}
|
|
@@ -1233,14 +1231,14 @@ function TraceIcon({ className, ...props }) {
|
|
|
1233
1231
|
return /* @__PURE__ */ jsx18("span", {
|
|
1234
1232
|
"data-slot": "trace-icon",
|
|
1235
1233
|
"aria-hidden": "true",
|
|
1236
|
-
className:
|
|
1234
|
+
className: cn4("flex size-4 shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [[data-slot=trace-title]~&]:-ml-1", className),
|
|
1237
1235
|
...props
|
|
1238
1236
|
});
|
|
1239
1237
|
}
|
|
1240
1238
|
function TraceTitle({ className, ...props }) {
|
|
1241
1239
|
return /* @__PURE__ */ jsx18("span", {
|
|
1242
1240
|
"data-slot": "trace-title",
|
|
1243
|
-
className:
|
|
1241
|
+
className: cn4("min-w-0 truncate motion-reduce:shimmer-none", className),
|
|
1244
1242
|
...props
|
|
1245
1243
|
});
|
|
1246
1244
|
}
|
|
@@ -1250,7 +1248,7 @@ function TraceDescription({
|
|
|
1250
1248
|
}) {
|
|
1251
1249
|
return /* @__PURE__ */ jsx18("span", {
|
|
1252
1250
|
"data-slot": "trace-description",
|
|
1253
|
-
className:
|
|
1251
|
+
className: cn4("shrink-0 text-muted-foreground/70 tabular-nums", className),
|
|
1254
1252
|
...props
|
|
1255
1253
|
});
|
|
1256
1254
|
}
|
|
@@ -1260,7 +1258,7 @@ function TraceCollapsible({
|
|
|
1260
1258
|
}) {
|
|
1261
1259
|
return /* @__PURE__ */ jsx18(Collapsible, {
|
|
1262
1260
|
"data-slot": "trace-collapsible",
|
|
1263
|
-
className:
|
|
1261
|
+
className: cn4("flex w-full min-w-0 flex-col", className),
|
|
1264
1262
|
...props
|
|
1265
1263
|
});
|
|
1266
1264
|
}
|
|
@@ -1271,7 +1269,7 @@ function TraceCollapsibleTrigger({
|
|
|
1271
1269
|
}) {
|
|
1272
1270
|
return /* @__PURE__ */ jsxs6(CollapsibleTrigger, {
|
|
1273
1271
|
"data-slot": "trace-collapsible-trigger",
|
|
1274
|
-
className:
|
|
1272
|
+
className: cn4("group/trace-collapsible-trigger flex w-fit max-w-full min-w-0 cursor-pointer items-center gap-1 rounded-md text-left text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 has-[[data-status=error]]:text-destructive", className),
|
|
1275
1273
|
...props,
|
|
1276
1274
|
children: [
|
|
1277
1275
|
children,
|
|
@@ -1293,7 +1291,7 @@ function TraceCollapsibleContent({
|
|
|
1293
1291
|
...props,
|
|
1294
1292
|
children: /* @__PURE__ */ jsx18("div", {
|
|
1295
1293
|
"data-slot": "trace-collapsible-content-inner",
|
|
1296
|
-
className:
|
|
1294
|
+
className: cn4("mt-2 mb-1 ml-[calc(--spacing(2)-1px)] min-w-0 border-l pr-1 pl-4 leading-relaxed wrap-break-word text-muted-foreground", className),
|
|
1297
1295
|
children
|
|
1298
1296
|
})
|
|
1299
1297
|
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Config, Context, Effect, Layer, Schema } from "effect";
|
|
2
|
+
export type ClamAVVerdict = {
|
|
3
|
+
readonly _tag: "Clean";
|
|
4
|
+
} | {
|
|
5
|
+
readonly _tag: "Detected";
|
|
6
|
+
readonly signature: string;
|
|
7
|
+
} | {
|
|
8
|
+
readonly _tag: "Unscannable";
|
|
9
|
+
};
|
|
10
|
+
declare const ClamAVError_base: Schema.Class<ClamAVError, Schema.TaggedStruct<"ClamAVError", {
|
|
11
|
+
readonly reason: Schema.Literals<readonly ["Unavailable", "Timeout", "InvalidReply", "ScanFailed"]>;
|
|
12
|
+
}>, import("effect/Cause").YieldableError>;
|
|
13
|
+
export declare class ClamAVError extends ClamAVError_base {
|
|
14
|
+
}
|
|
15
|
+
type Endpoint = {
|
|
16
|
+
readonly host: string;
|
|
17
|
+
readonly port: number;
|
|
18
|
+
};
|
|
19
|
+
declare const ClamAV_base: Context.ServiceClass<ClamAV, "krak-stack/ClamAV", {
|
|
20
|
+
readonly scan: (input: {
|
|
21
|
+
readonly bytes: Uint8Array;
|
|
22
|
+
}) => Effect.Effect<ClamAVVerdict, ClamAVError>;
|
|
23
|
+
readonly ping: () => Effect.Effect<void, ClamAVError>;
|
|
24
|
+
}>;
|
|
25
|
+
export declare class ClamAV extends ClamAV_base {
|
|
26
|
+
static readonly layerWith: (endpoint: Endpoint) => Layer.Layer<ClamAV, never, never>;
|
|
27
|
+
static readonly layer: Layer.Layer<ClamAV, Config.ConfigError, never>;
|
|
28
|
+
static readonly layerTest: (service: ClamAV["Service"]) => Layer.Layer<ClamAV, never, never>;
|
|
29
|
+
private static readonly make;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// ../../src/services/clamav/index.ts
|
|
2
|
+
import { createConnection } from "node:net";
|
|
3
|
+
import { Config, Context, Effect, Layer, Schema, Semaphore } from "effect";
|
|
4
|
+
|
|
5
|
+
class ClamAVError extends Schema.TaggedError()("ClamAVError", {
|
|
6
|
+
reason: Schema.Literals([
|
|
7
|
+
"Unavailable",
|
|
8
|
+
"Timeout",
|
|
9
|
+
"InvalidReply",
|
|
10
|
+
"ScanFailed"
|
|
11
|
+
])
|
|
12
|
+
}) {
|
|
13
|
+
}
|
|
14
|
+
var maxBytes = 100 * 1024 * 1024;
|
|
15
|
+
var request = (endpoint, bytes) => Effect.tryPromise({
|
|
16
|
+
try: (signal) => new Promise((resolve, reject) => {
|
|
17
|
+
const socket = createConnection({ ...endpoint, signal });
|
|
18
|
+
let reply = Buffer.alloc(0);
|
|
19
|
+
let sent = bytes === undefined;
|
|
20
|
+
const fail = (reason) => {
|
|
21
|
+
reject(new ClamAVError({ reason }));
|
|
22
|
+
socket.destroy();
|
|
23
|
+
};
|
|
24
|
+
socket.on("error", () => fail("Unavailable"));
|
|
25
|
+
socket.on("close", () => {
|
|
26
|
+
const end = reply.indexOf(0);
|
|
27
|
+
if (end < 0)
|
|
28
|
+
return fail(reply.length ? "InvalidReply" : "Unavailable");
|
|
29
|
+
if (end !== reply.length - 1)
|
|
30
|
+
return fail("InvalidReply");
|
|
31
|
+
const line = reply.toString("utf8", 0, end);
|
|
32
|
+
if (!sent && line === "stream: OK")
|
|
33
|
+
return fail("InvalidReply");
|
|
34
|
+
resolve(line);
|
|
35
|
+
});
|
|
36
|
+
socket.on("data", (part) => {
|
|
37
|
+
if (reply.length + part.length > 4096)
|
|
38
|
+
return fail("InvalidReply");
|
|
39
|
+
reply = Buffer.concat([reply, part]);
|
|
40
|
+
});
|
|
41
|
+
socket.once("connect", () => {
|
|
42
|
+
if (!bytes) {
|
|
43
|
+
socket.write("zPING\x00");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
let offset = 0;
|
|
47
|
+
const send = () => {
|
|
48
|
+
if (socket.destroyed)
|
|
49
|
+
return;
|
|
50
|
+
if (offset === bytes.length) {
|
|
51
|
+
sent = true;
|
|
52
|
+
socket.write(Buffer.alloc(4));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const size = Math.min(64 * 1024, bytes.length - offset);
|
|
56
|
+
const frame = Buffer.allocUnsafe(4 + size);
|
|
57
|
+
frame.writeUInt32BE(size);
|
|
58
|
+
frame.set(bytes.subarray(offset, offset + size), 4);
|
|
59
|
+
offset += size;
|
|
60
|
+
socket.write(frame, (error) => {
|
|
61
|
+
if (error)
|
|
62
|
+
fail("Unavailable");
|
|
63
|
+
else
|
|
64
|
+
send();
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
socket.write("zINSTREAM\x00", (error) => {
|
|
68
|
+
if (error)
|
|
69
|
+
fail("Unavailable");
|
|
70
|
+
else
|
|
71
|
+
send();
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}),
|
|
75
|
+
catch: (error) => error instanceof ClamAVError ? error : new ClamAVError({ reason: "Unavailable" })
|
|
76
|
+
}).pipe(Effect.timeoutOrElse({
|
|
77
|
+
duration: "60 seconds",
|
|
78
|
+
orElse: () => Effect.fail(new ClamAVError({ reason: "Timeout" }))
|
|
79
|
+
}));
|
|
80
|
+
|
|
81
|
+
class ClamAV extends Context.Service()("krak-stack/ClamAV") {
|
|
82
|
+
static layerWith = (endpoint) => Layer.effect(this, ClamAV.make(endpoint));
|
|
83
|
+
static layer = Layer.effect(this, Effect.gen(function* () {
|
|
84
|
+
const host = yield* Config.schema(Schema.NonEmptyString, "CLAMAV_HOST");
|
|
85
|
+
const port = yield* Config.Port("CLAMAV_PORT").pipe(Config.withDefault(3310));
|
|
86
|
+
return yield* ClamAV.make({ host, port });
|
|
87
|
+
}));
|
|
88
|
+
static layerTest = (service) => Layer.succeed(this, service);
|
|
89
|
+
static make = (endpoint) => Effect.gen(function* () {
|
|
90
|
+
const semaphore = yield* Semaphore.make(2);
|
|
91
|
+
const scan = Effect.fn("ClamAV.scan")(function* ({
|
|
92
|
+
bytes
|
|
93
|
+
}) {
|
|
94
|
+
if (bytes.length === 0 || bytes.length > maxBytes)
|
|
95
|
+
return { _tag: "Unscannable" };
|
|
96
|
+
const line = yield* semaphore.withPermit(request(endpoint, bytes));
|
|
97
|
+
if (line === "stream: OK")
|
|
98
|
+
return { _tag: "Clean" };
|
|
99
|
+
if (/^INSTREAM size limit exceeded\.? ERROR$/.test(line))
|
|
100
|
+
return { _tag: "Unscannable" };
|
|
101
|
+
const match = /^stream: ([^\r\n]+) FOUND$/.exec(line);
|
|
102
|
+
if (match) {
|
|
103
|
+
const signature = match[1];
|
|
104
|
+
if (/^Heuristics\.(Limits\.Exceeded|Encrypted)(?:\.|$)/.test(signature)) {
|
|
105
|
+
return { _tag: "Unscannable" };
|
|
106
|
+
}
|
|
107
|
+
return { _tag: "Detected", signature };
|
|
108
|
+
}
|
|
109
|
+
return yield* new ClamAVError({
|
|
110
|
+
reason: line.endsWith(" ERROR") ? "ScanFailed" : "InvalidReply"
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
const ping = Effect.fn("ClamAV.ping")(function* () {
|
|
114
|
+
if ((yield* request(endpoint)) !== "PONG") {
|
|
115
|
+
return yield* new ClamAVError({ reason: "InvalidReply" });
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
return { scan, ping };
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
export {
|
|
122
|
+
ClamAV,
|
|
123
|
+
ClamAVError
|
|
124
|
+
};
|
|
@@ -57,6 +57,7 @@ import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
|
|
|
57
57
|
|
|
58
58
|
// ../../src/components/ui/dialog.tsx
|
|
59
59
|
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
|
|
60
|
+
import { cn as cn2 } from "cn";
|
|
60
61
|
import { XIcon } from "lucide-react";
|
|
61
62
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
62
63
|
function Dialog({ ...props }) {
|
|
@@ -77,13 +78,14 @@ function DialogOverlay({
|
|
|
77
78
|
}) {
|
|
78
79
|
return /* @__PURE__ */ jsx2(DialogPrimitive.Backdrop, {
|
|
79
80
|
"data-slot": "dialog-overlay",
|
|
80
|
-
className:
|
|
81
|
+
className: cn2("data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs", className),
|
|
81
82
|
...props
|
|
82
83
|
});
|
|
83
84
|
}
|
|
84
85
|
function DialogContent({
|
|
85
86
|
className,
|
|
86
87
|
children,
|
|
88
|
+
showCloseButton = true,
|
|
87
89
|
...props
|
|
88
90
|
}) {
|
|
89
91
|
return /* @__PURE__ */ jsxs(DialogPortal, {
|
|
@@ -91,16 +93,19 @@ function DialogContent({
|
|
|
91
93
|
/* @__PURE__ */ jsx2(DialogOverlay, {}),
|
|
92
94
|
/* @__PURE__ */ jsxs(DialogPrimitive.Popup, {
|
|
93
95
|
"data-slot": "dialog-content",
|
|
94
|
-
className:
|
|
96
|
+
className: cn2("bg-popover text-popover-foreground ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl p-6 text-sm ring-1 duration-100 outline-none sm:max-w-md", className),
|
|
95
97
|
...props,
|
|
96
98
|
children: [
|
|
97
99
|
children,
|
|
98
|
-
/* @__PURE__ */ jsxs(DialogPrimitive.Close, {
|
|
99
|
-
|
|
100
|
+
showCloseButton && /* @__PURE__ */ jsxs(DialogPrimitive.Close, {
|
|
101
|
+
"data-slot": "dialog-close",
|
|
102
|
+
render: /* @__PURE__ */ jsx2(Button, {
|
|
103
|
+
variant: "ghost",
|
|
104
|
+
className: "absolute top-4 right-4",
|
|
105
|
+
size: "icon-sm"
|
|
106
|
+
}),
|
|
100
107
|
children: [
|
|
101
|
-
/* @__PURE__ */ jsx2(XIcon, {
|
|
102
|
-
className: "size-4"
|
|
103
|
-
}),
|
|
108
|
+
/* @__PURE__ */ jsx2(XIcon, {}),
|
|
104
109
|
/* @__PURE__ */ jsx2("span", {
|
|
105
110
|
className: "sr-only",
|
|
106
111
|
children: "Close"
|
|
@@ -115,24 +120,35 @@ function DialogContent({
|
|
|
115
120
|
function DialogHeader({ className, ...props }) {
|
|
116
121
|
return /* @__PURE__ */ jsx2("div", {
|
|
117
122
|
"data-slot": "dialog-header",
|
|
118
|
-
className:
|
|
119
|
-
...props
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
function DialogFooter({ className, ...props }) {
|
|
123
|
-
return /* @__PURE__ */ jsx2("div", {
|
|
124
|
-
"data-slot": "dialog-footer",
|
|
125
|
-
className: cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className),
|
|
123
|
+
className: cn2("flex flex-col gap-2", className),
|
|
126
124
|
...props
|
|
127
125
|
});
|
|
128
126
|
}
|
|
129
|
-
function
|
|
127
|
+
function DialogFooter({
|
|
130
128
|
className,
|
|
129
|
+
showCloseButton = false,
|
|
130
|
+
children,
|
|
131
131
|
...props
|
|
132
132
|
}) {
|
|
133
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
134
|
+
"data-slot": "dialog-footer",
|
|
135
|
+
className: cn2("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className),
|
|
136
|
+
...props,
|
|
137
|
+
children: [
|
|
138
|
+
children,
|
|
139
|
+
showCloseButton && /* @__PURE__ */ jsx2(DialogPrimitive.Close, {
|
|
140
|
+
render: /* @__PURE__ */ jsx2(Button, {
|
|
141
|
+
variant: "outline"
|
|
142
|
+
}),
|
|
143
|
+
children: "Close"
|
|
144
|
+
})
|
|
145
|
+
]
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function DialogTitle({ className, ...props }) {
|
|
133
149
|
return /* @__PURE__ */ jsx2(DialogPrimitive.Title, {
|
|
134
150
|
"data-slot": "dialog-title",
|
|
135
|
-
className:
|
|
151
|
+
className: cn2("leading-none font-medium", className),
|
|
136
152
|
...props
|
|
137
153
|
});
|
|
138
154
|
}
|
|
@@ -142,7 +158,7 @@ function DialogDescription({
|
|
|
142
158
|
}) {
|
|
143
159
|
return /* @__PURE__ */ jsx2(DialogPrimitive.Description, {
|
|
144
160
|
"data-slot": "dialog-description",
|
|
145
|
-
className:
|
|
161
|
+
className: cn2("text-muted-foreground *:[a]:hover:text-foreground text-sm *:[a]:underline *:[a]:underline-offset-3", className),
|
|
146
162
|
...props
|
|
147
163
|
});
|
|
148
164
|
}
|
|
@@ -36,6 +36,24 @@ var SynthesizeSpeech = Schema.Struct({
|
|
|
36
36
|
text: Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(4000), Schema.isPattern(/\S/)),
|
|
37
37
|
language: Schema.Literals(["en", "fr", "es", "zh", "ja", "ko"])
|
|
38
38
|
}).annotate({ identifier: "SynthesizeSpeech" });
|
|
39
|
+
var ElevenLabsSpeechRequest = Schema.Struct({
|
|
40
|
+
model: Schema.Literal("elevenlabs/eleven-flash-v2-5"),
|
|
41
|
+
input: Schema.Struct({
|
|
42
|
+
text: SynthesizeSpeech.fields.text,
|
|
43
|
+
language_code: SynthesizeSpeech.fields.language,
|
|
44
|
+
voice_id: Schema.NonEmptyString,
|
|
45
|
+
output_format: Schema.Literal("mp3_44100_128")
|
|
46
|
+
})
|
|
47
|
+
}).annotate({ identifier: "GatewayElevenLabsSpeechRequest" });
|
|
48
|
+
var GatewayAudioUrl = Schema.URLFromString.check(Schema.makeFilter((url) => url.protocol === "https:" && !url.port && !url.username && !url.password && (url.hostname.endsWith(".r2.cloudflarestorage.com") || url.hostname.endsWith(".r2.dev") || url.hostname === "examples.aig.cloudflare.com") || "Expected an HTTPS Cloudflare audio URL")).annotate({ identifier: "GatewayAudioUrl" });
|
|
49
|
+
var CompletedSpeech = Schema.Struct({
|
|
50
|
+
state: Schema.Literal("Completed"),
|
|
51
|
+
result: Schema.Struct({ audio: GatewayAudioUrl })
|
|
52
|
+
});
|
|
53
|
+
var GatewaySpeechResponse = Schema.Union([
|
|
54
|
+
Schema.Struct({ success: Schema.Literal(true), result: CompletedSpeech }),
|
|
55
|
+
CompletedSpeech
|
|
56
|
+
]).annotate({ identifier: "GatewaySpeechResponse" });
|
|
39
57
|
var MeloRequest = Schema.Struct({
|
|
40
58
|
prompt: SynthesizeSpeech.fields.text,
|
|
41
59
|
lang: SynthesizeSpeech.fields.language
|
|
@@ -41,6 +41,24 @@ var SynthesizeSpeech = Schema.Struct({
|
|
|
41
41
|
text: Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(4000), Schema.isPattern(/\S/)),
|
|
42
42
|
language: Schema.Literals(["en", "fr", "es", "zh", "ja", "ko"])
|
|
43
43
|
}).annotate({ identifier: "SynthesizeSpeech" });
|
|
44
|
+
var ElevenLabsSpeechRequest = Schema.Struct({
|
|
45
|
+
model: Schema.Literal("elevenlabs/eleven-flash-v2-5"),
|
|
46
|
+
input: Schema.Struct({
|
|
47
|
+
text: SynthesizeSpeech.fields.text,
|
|
48
|
+
language_code: SynthesizeSpeech.fields.language,
|
|
49
|
+
voice_id: Schema.NonEmptyString,
|
|
50
|
+
output_format: Schema.Literal("mp3_44100_128")
|
|
51
|
+
})
|
|
52
|
+
}).annotate({ identifier: "GatewayElevenLabsSpeechRequest" });
|
|
53
|
+
var GatewayAudioUrl = Schema.URLFromString.check(Schema.makeFilter((url) => url.protocol === "https:" && !url.port && !url.username && !url.password && (url.hostname.endsWith(".r2.cloudflarestorage.com") || url.hostname.endsWith(".r2.dev") || url.hostname === "examples.aig.cloudflare.com") || "Expected an HTTPS Cloudflare audio URL")).annotate({ identifier: "GatewayAudioUrl" });
|
|
54
|
+
var CompletedSpeech = Schema.Struct({
|
|
55
|
+
state: Schema.Literal("Completed"),
|
|
56
|
+
result: Schema.Struct({ audio: GatewayAudioUrl })
|
|
57
|
+
});
|
|
58
|
+
var GatewaySpeechResponse = Schema.Union([
|
|
59
|
+
Schema.Struct({ success: Schema.Literal(true), result: CompletedSpeech }),
|
|
60
|
+
CompletedSpeech
|
|
61
|
+
]).annotate({ identifier: "GatewaySpeechResponse" });
|
|
44
62
|
var MeloRequest = Schema.Struct({
|
|
45
63
|
prompt: SynthesizeSpeech.fields.text,
|
|
46
64
|
lang: SynthesizeSpeech.fields.language
|
|
@@ -82,25 +100,33 @@ class Speech extends Context.Service()("@krak-stack/registry/speech/Speech", {
|
|
|
82
100
|
const payload = yield* Schema2.decodeEffect(SynthesizeSpeech)(input);
|
|
83
101
|
const url = yield* Schema2.decodeEffect(Schema2.URLFromString)(options.baseUrl);
|
|
84
102
|
const path = yield* Schema2.decodeEffect(Schema2.String.check(Schema2.isPattern(/^\/.*accounts\/[^/]+\/ai\/(v1|run)\/?$/)))(url.pathname);
|
|
85
|
-
url.pathname = path.replace(/\/(v1|run)\/?$/, "/run
|
|
103
|
+
url.pathname = path.replace(/\/(v1|run)\/?$/, "/run");
|
|
86
104
|
url.search = "";
|
|
87
105
|
url.hash = "";
|
|
88
106
|
const request = yield* HttpClientRequest.post(url.toString()).pipe(HttpClientRequest.bearerToken(options.apiKey), HttpClientRequest.setHeaders({
|
|
89
107
|
"cf-aig-gateway-id": options.gatewayId,
|
|
90
108
|
"cf-aig-skip-cache": "true",
|
|
91
|
-
"cf-aig-collect-log": "false"
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
109
|
+
"cf-aig-collect-log": "false"
|
|
110
|
+
}), HttpClientRequest.schemaBodyJson(ElevenLabsSpeechRequest)({
|
|
111
|
+
model: "elevenlabs/eleven-flash-v2-5",
|
|
112
|
+
input: {
|
|
113
|
+
text: payload.text,
|
|
114
|
+
language_code: payload.language,
|
|
115
|
+
voice_id: "JBFqnCBsd6RMkjVDRZzb",
|
|
116
|
+
output_format: "mp3_44100_128"
|
|
117
|
+
}
|
|
96
118
|
}));
|
|
97
119
|
const response = yield* http.execute(request);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
120
|
+
const body = yield* HttpClientResponse.schemaBodyJson(GatewaySpeechResponse)(response);
|
|
121
|
+
const { result } = "success" in body ? body.result : body;
|
|
122
|
+
const audio = yield* http.get(result.audio).pipe(Effect.provideService(FetchHttpClient.RequestInit, {
|
|
123
|
+
credentials: "omit",
|
|
124
|
+
redirect: "error"
|
|
125
|
+
}), Effect.provideService(HttpClient.TracerDisabledWhen, () => true));
|
|
126
|
+
if (audio.headers["content-type"]?.split(";")[0]?.trim() !== "audio/mpeg") {
|
|
127
|
+
return yield* new SpeechUnavailable({});
|
|
101
128
|
}
|
|
102
|
-
|
|
103
|
-
return body.result.audio;
|
|
129
|
+
return yield* Schema2.decodeEffect(Schema2.Uint8Array.check(Schema2.isMinLength(1)))(new Uint8Array(yield* audio.arrayBuffer));
|
|
104
130
|
}, Effect.timeout("60 seconds"), Effect.mapError(() => new SpeechUnavailable({})));
|
|
105
131
|
return { transcribe, synthesize };
|
|
106
132
|
})
|