@krak-stack/registry 0.1.11 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -2
- package/dist/components/ui/app-brand.d.ts +18 -13
- package/dist/components/ui/app-brand.js +48 -15
- package/dist/components/ui/code-block.js +10 -6
- package/dist/components/ui/copy-button.d.ts +1 -1
- package/dist/components/ui/copy-button.js +1 -1
- package/dist/components/ui/data-table.d.ts +1 -1
- package/dist/components/ui/data-table.js +21 -20
- package/dist/components/ui/effect-form.js +7 -6
- package/dist/components/ui/file-picker.js +2 -1
- package/dist/components/ui/form.js +17 -15
- package/dist/components/ui/google-map.d.ts +6 -10
- package/dist/components/ui/google-map.js +19 -14
- package/dist/components/ui/locale-switcher.js +7 -1
- package/dist/components/ui/sidebar-layout.js +19 -21
- package/dist/components/ui/theme-switcher.js +1 -1
- package/dist/lib/docs-core.js +165 -109
- package/dist/lib/documentation-toolkit.d.ts +140 -0
- package/dist/lib/{docs-ai.js → documentation-toolkit.js} +54 -63
- package/dist/lib/httpapi-cli.d.ts +6 -6
- package/dist/lib/httpapi-cli.js +75 -48
- package/dist/lib/httpapi-client.d.ts +8 -2
- package/dist/lib/httpapi-client.js +21 -9
- package/dist/lib/httpapi-helpers.d.ts +15 -21
- package/dist/lib/httpapi-helpers.js +38 -26
- package/dist/lib/httpapi-mcp.js +73 -50
- package/dist/lib/httpapi-toolkit.d.ts +20 -0
- package/dist/lib/{httpapi-ai.js → httpapi-toolkit.js} +123 -100
- package/dist/lib/seo.js +29 -17
- package/dist/lib/webfetch-toolkit.d.ts +45 -0
- package/dist/lib/webfetch-toolkit.js +276 -0
- package/dist/oxlint/anti-slop/index.js +1592 -0
- package/dist/services/agent/client/atom.d.ts +7 -7
- package/dist/services/agent/client/index.js +55 -54
- package/dist/services/agent/index.d.ts +71 -71
- package/dist/services/agent/index.js +38 -19
- package/dist/services/notification/channels/index.d.ts +11 -9
- package/dist/services/notification/channels/ses/index.d.ts +6 -6
- package/dist/services/notification/channels/ses/index.js +15 -11
- package/dist/services/notification/client/index.js +3 -2
- package/dist/services/notification/client/notification-menu.d.ts +9 -9
- package/dist/services/notification/index.d.ts +7 -6
- package/dist/services/notification/persistence/drizzle.js +214 -0
- package/dist/services/notification/persistence/index.js +227 -0
- package/dist/services/notification/persistence/schema.js +118 -0
- package/dist/services/notification/public.js +3 -2
- package/dist/services/s3/index.d.ts +2 -16
- package/dist/services/s3/index.js +12 -9
- package/package.json +33 -7
- package/dist/lib/docs-ai.d.ts +0 -142
- package/dist/lib/httpapi-ai.d.ts +0 -54
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Effect, Stream } from "effect";
|
|
1
|
+
import { Effect, Option, Stream } from "effect";
|
|
2
2
|
import { Atom, Reactivity } from "effect/unstable/reactivity";
|
|
3
3
|
import type { AgentErrorCode, AgentEvent, AgentReference, AgentRequest } from "../schema.js";
|
|
4
4
|
export type AgentToolStatus = "running" | "approval-required" | "approved" | "denied" | "completed" | "failed";
|
|
@@ -37,9 +37,9 @@ export type AgentState<Resource = never> = {
|
|
|
37
37
|
};
|
|
38
38
|
export declare const initialAgentState: AgentState<never>;
|
|
39
39
|
export declare const reduceAgentEvent: <Resource>(state: AgentState<Resource>, event: AgentEvent) => AgentState<Resource>;
|
|
40
|
-
export type AgentAtomsConfig<Resource> = {
|
|
41
|
-
readonly stream: (get: Atom.FnContext, request: AgentRequest<Resource>) => Effect.Effect<Stream.Stream<AgentEvent,
|
|
42
|
-
readonly errorCode?: (error:
|
|
40
|
+
export type AgentAtomsConfig<Resource, Failure = ErrorOptions["cause"]> = {
|
|
41
|
+
readonly stream: (get: Atom.FnContext, request: AgentRequest<Resource>) => Effect.Effect<Stream.Stream<AgentEvent, Failure, Reactivity.Reactivity>, Failure>;
|
|
42
|
+
readonly errorCode?: (error: Failure) => AgentErrorCode;
|
|
43
43
|
readonly reactivityKeys?: ReadonlyArray<unknown>;
|
|
44
44
|
readonly runtime?: Atom.AtomRuntime<never>;
|
|
45
45
|
};
|
|
@@ -48,9 +48,9 @@ export type AgentSubmitInput<Resource> = {
|
|
|
48
48
|
readonly context?: AgentConversationContext<Resource>;
|
|
49
49
|
readonly scope: string;
|
|
50
50
|
};
|
|
51
|
-
export declare const makeAgentAtoms: <Resource>({ errorCode, reactivityKeys, runtime, stream, }: AgentAtomsConfig<Resource>) => {
|
|
52
|
-
readonly removeContext: Atom.Writable<
|
|
53
|
-
readonly reset: Atom.Writable<
|
|
51
|
+
export declare const makeAgentAtoms: <Resource, Failure = unknown>({ errorCode, reactivityKeys, runtime, stream, }: AgentAtomsConfig<Resource, Failure>) => {
|
|
52
|
+
readonly removeContext: Atom.Writable<Option.Option<void>, string>;
|
|
53
|
+
readonly reset: Atom.Writable<Option.Option<void>, string>;
|
|
54
54
|
readonly state: (arg: string) => Atom.Writable<AgentState<Resource>, AgentState<Resource>>;
|
|
55
55
|
readonly submit: Atom.AtomResultFn<AgentSubmitInput<Resource>, void, never>;
|
|
56
56
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// ../../src/services/agent/client/atom.ts
|
|
2
|
-
import { Effect, Layer, Stream } from "effect";
|
|
2
|
+
import { Effect, Layer, Option, Schema, Stream } from "effect";
|
|
3
3
|
import { Atom } from "effect/unstable/reactivity";
|
|
4
4
|
var initialAgentState = {
|
|
5
5
|
context: undefined,
|
|
@@ -64,12 +64,15 @@ var reduceAgentEvent = (state, event) => {
|
|
|
64
64
|
return state;
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
+
var AgentError = Schema.Struct({
|
|
68
|
+
code: Schema.Literals(["stream-failed", "unavailable"])
|
|
69
|
+
}).annotate({ identifier: "AgentError" });
|
|
67
70
|
var defaultErrorCode = (error) => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
const failure = Schema.decodeUnknownOption(AgentError)(error);
|
|
72
|
+
if (Option.isNone(failure))
|
|
73
|
+
return "unavailable";
|
|
74
|
+
if (failure.value.code === "stream-failed")
|
|
75
|
+
return "stream-failed";
|
|
73
76
|
return "unavailable";
|
|
74
77
|
};
|
|
75
78
|
var makeAgentAtoms = ({
|
|
@@ -628,8 +631,9 @@ function InputGroupAddon({
|
|
|
628
631
|
"data-align": align,
|
|
629
632
|
className: cn(inputGroupAddonVariants({ align }), className),
|
|
630
633
|
onClick: (event) => {
|
|
631
|
-
if (event.target.closest("button"))
|
|
634
|
+
if (event.target instanceof HTMLElement && event.target.closest("button")) {
|
|
632
635
|
return;
|
|
636
|
+
}
|
|
633
637
|
event.currentTarget.parentElement?.querySelector("input")?.focus();
|
|
634
638
|
},
|
|
635
639
|
...props
|
|
@@ -1346,7 +1350,7 @@ function isCustomStrategy(strategy2) {
|
|
|
1346
1350
|
}
|
|
1347
1351
|
|
|
1348
1352
|
// ../../src/services/agent/schema.ts
|
|
1349
|
-
import { Schema } from "effect";
|
|
1353
|
+
import { Schema as Schema2 } from "effect";
|
|
1350
1354
|
import {
|
|
1351
1355
|
HttpApiEndpoint,
|
|
1352
1356
|
HttpApiError,
|
|
@@ -1354,63 +1358,63 @@ import {
|
|
|
1354
1358
|
HttpApiSchema,
|
|
1355
1359
|
OpenApi
|
|
1356
1360
|
} from "effect/unstable/httpapi";
|
|
1357
|
-
var AgentMessageText =
|
|
1361
|
+
var AgentMessageText = Schema2.String.check(Schema2.isLengthBetween(1, 4000)).annotate({
|
|
1358
1362
|
identifier: "AgentMessageText",
|
|
1359
1363
|
title: "Agent message",
|
|
1360
1364
|
description: "A user message sent to the agent."
|
|
1361
1365
|
});
|
|
1362
|
-
var AgentReferenceLabel =
|
|
1366
|
+
var AgentReferenceLabel = Schema2.String.check(Schema2.isLengthBetween(1, 500));
|
|
1363
1367
|
var AGENT_REFERENCE_LIMIT = 20;
|
|
1364
|
-
var AgentToolMetadata =
|
|
1365
|
-
title:
|
|
1366
|
-
description:
|
|
1367
|
-
destructive:
|
|
1368
|
+
var AgentToolMetadata = Schema2.Struct({
|
|
1369
|
+
title: Schema2.optional(Schema2.String),
|
|
1370
|
+
description: Schema2.optional(Schema2.String),
|
|
1371
|
+
destructive: Schema2.Boolean
|
|
1368
1372
|
}).annotate({ identifier: "AgentToolMetadata" });
|
|
1369
|
-
var AgentEvent =
|
|
1370
|
-
|
|
1371
|
-
type:
|
|
1372
|
-
messageId:
|
|
1373
|
+
var AgentEvent = Schema2.Union([
|
|
1374
|
+
Schema2.Struct({
|
|
1375
|
+
type: Schema2.Literal("message-start"),
|
|
1376
|
+
messageId: Schema2.String
|
|
1373
1377
|
}),
|
|
1374
|
-
|
|
1375
|
-
type:
|
|
1376
|
-
messageId:
|
|
1377
|
-
delta:
|
|
1378
|
+
Schema2.Struct({
|
|
1379
|
+
type: Schema2.Literal("text-delta"),
|
|
1380
|
+
messageId: Schema2.String,
|
|
1381
|
+
delta: Schema2.String
|
|
1378
1382
|
}),
|
|
1379
|
-
|
|
1380
|
-
type:
|
|
1381
|
-
messageId:
|
|
1382
|
-
toolCallId:
|
|
1383
|
-
name:
|
|
1384
|
-
input:
|
|
1383
|
+
Schema2.Struct({
|
|
1384
|
+
type: Schema2.Literal("tool-call"),
|
|
1385
|
+
messageId: Schema2.String,
|
|
1386
|
+
toolCallId: Schema2.String,
|
|
1387
|
+
name: Schema2.String,
|
|
1388
|
+
input: Schema2.Unknown,
|
|
1385
1389
|
metadata: AgentToolMetadata
|
|
1386
1390
|
}),
|
|
1387
|
-
|
|
1388
|
-
type:
|
|
1389
|
-
toolCallId:
|
|
1390
|
-
name:
|
|
1391
|
-
isFailure:
|
|
1391
|
+
Schema2.Struct({
|
|
1392
|
+
type: Schema2.Literal("tool-result"),
|
|
1393
|
+
toolCallId: Schema2.String,
|
|
1394
|
+
name: Schema2.String,
|
|
1395
|
+
isFailure: Schema2.Boolean
|
|
1392
1396
|
}),
|
|
1393
|
-
|
|
1394
|
-
type:
|
|
1395
|
-
approvalId:
|
|
1396
|
-
toolCallId:
|
|
1397
|
+
Schema2.Struct({
|
|
1398
|
+
type: Schema2.Literal("approval-required"),
|
|
1399
|
+
approvalId: Schema2.String,
|
|
1400
|
+
toolCallId: Schema2.String
|
|
1397
1401
|
}),
|
|
1398
|
-
|
|
1399
|
-
type:
|
|
1400
|
-
value:
|
|
1402
|
+
Schema2.Struct({
|
|
1403
|
+
type: Schema2.Literal("history"),
|
|
1404
|
+
value: Schema2.String
|
|
1401
1405
|
}),
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
type:
|
|
1405
|
-
code:
|
|
1406
|
+
Schema2.Struct({ type: Schema2.Literal("finish") }),
|
|
1407
|
+
Schema2.Struct({
|
|
1408
|
+
type: Schema2.Literal("error"),
|
|
1409
|
+
code: Schema2.Literals(["unavailable", "invalid-request", "stream-failed"])
|
|
1406
1410
|
})
|
|
1407
1411
|
]).annotate({
|
|
1408
1412
|
identifier: "AgentEvent",
|
|
1409
1413
|
title: "Agent stream event",
|
|
1410
1414
|
description: "An event emitted by the agent endpoint."
|
|
1411
1415
|
});
|
|
1412
|
-
var AgentStreamError =
|
|
1413
|
-
code:
|
|
1416
|
+
var AgentStreamError = Schema2.Struct({
|
|
1417
|
+
code: Schema2.Literals(["unavailable", "stream-failed"])
|
|
1414
1418
|
}).annotate({
|
|
1415
1419
|
identifier: "AgentStreamError",
|
|
1416
1420
|
title: "Agent stream error",
|
|
@@ -1891,16 +1895,13 @@ function AgentWidget({
|
|
|
1891
1895
|
setInput("");
|
|
1892
1896
|
setReferences([]);
|
|
1893
1897
|
setReferencePickerOpen(false);
|
|
1894
|
-
|
|
1898
|
+
const messageReferences = references.length > 0 ? references.map(({ label, resource }) => ({ label, resource })) : undefined;
|
|
1899
|
+
const action = {
|
|
1895
1900
|
type: "message",
|
|
1896
1901
|
text,
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
resource
|
|
1901
|
-
}))
|
|
1902
|
-
} : {}
|
|
1903
|
-
});
|
|
1902
|
+
references: messageReferences
|
|
1903
|
+
};
|
|
1904
|
+
onSubmit(action);
|
|
1904
1905
|
};
|
|
1905
1906
|
const respondToApproval = (tool, approved) => {
|
|
1906
1907
|
if (!tool.approvalId || state.pending)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context, Effect, Layer, Stream } from "effect";
|
|
1
|
+
import { Context, Effect, Layer, Schema, Stream } from "effect";
|
|
2
2
|
import { LanguageModel, Tool, Toolkit } from "effect/unstable/ai";
|
|
3
3
|
import type { AgentAction } from "./schema.js";
|
|
4
4
|
export type AgentStreamOptions<Tools extends Record<string, Tool.Any>> = {
|
|
@@ -13,41 +13,41 @@ declare const AgentHistoryError_base: new <A extends Record<string, any> = {}>(a
|
|
|
13
13
|
declare class AgentHistoryError extends AgentHistoryError_base {
|
|
14
14
|
}
|
|
15
15
|
declare const AgentService_base: Context.ServiceClass<AgentService, "AgentService", {
|
|
16
|
-
stream: <Tools extends Record<string, Tool.Any>>(args_0: AgentStreamOptions<Tools>) => Effect.Effect<Stream.Stream<
|
|
17
|
-
readonly type:
|
|
18
|
-
readonly messageId:
|
|
19
|
-
}, "Type"> |
|
|
20
|
-
readonly type:
|
|
21
|
-
readonly messageId:
|
|
22
|
-
readonly delta:
|
|
23
|
-
}, "Type"> |
|
|
24
|
-
readonly type:
|
|
25
|
-
readonly messageId:
|
|
26
|
-
readonly toolCallId:
|
|
27
|
-
readonly name:
|
|
28
|
-
readonly input:
|
|
29
|
-
readonly metadata:
|
|
30
|
-
readonly title:
|
|
31
|
-
readonly description:
|
|
32
|
-
readonly destructive:
|
|
16
|
+
stream: <Tools extends Record<string, Tool.Any>>(args_0: AgentStreamOptions<Tools>) => Effect.Effect<Stream.Stream<Schema.Struct.ReadonlySide<{
|
|
17
|
+
readonly type: Schema.Literal<"message-start">;
|
|
18
|
+
readonly messageId: Schema.String;
|
|
19
|
+
}, "Type"> | Schema.Struct.ReadonlySide<{
|
|
20
|
+
readonly type: Schema.Literal<"text-delta">;
|
|
21
|
+
readonly messageId: Schema.String;
|
|
22
|
+
readonly delta: Schema.String;
|
|
23
|
+
}, "Type"> | Schema.Struct.ReadonlySide<{
|
|
24
|
+
readonly type: Schema.Literal<"tool-call">;
|
|
25
|
+
readonly messageId: Schema.String;
|
|
26
|
+
readonly toolCallId: Schema.String;
|
|
27
|
+
readonly name: Schema.String;
|
|
28
|
+
readonly input: Schema.Unknown;
|
|
29
|
+
readonly metadata: Schema.Struct<{
|
|
30
|
+
readonly title: Schema.optional<Schema.String>;
|
|
31
|
+
readonly description: Schema.optional<Schema.String>;
|
|
32
|
+
readonly destructive: Schema.Boolean;
|
|
33
33
|
}>;
|
|
34
|
-
}, "Type"> |
|
|
35
|
-
readonly type:
|
|
36
|
-
readonly toolCallId:
|
|
37
|
-
readonly name:
|
|
38
|
-
readonly isFailure:
|
|
39
|
-
}, "Type"> |
|
|
40
|
-
readonly type:
|
|
41
|
-
readonly approvalId:
|
|
42
|
-
readonly toolCallId:
|
|
43
|
-
}, "Type"> |
|
|
44
|
-
readonly type:
|
|
45
|
-
readonly value:
|
|
46
|
-
}, "Type"> |
|
|
47
|
-
readonly type:
|
|
48
|
-
}, "Type"> |
|
|
49
|
-
readonly type:
|
|
50
|
-
readonly code:
|
|
34
|
+
}, "Type"> | Schema.Struct.ReadonlySide<{
|
|
35
|
+
readonly type: Schema.Literal<"tool-result">;
|
|
36
|
+
readonly toolCallId: Schema.String;
|
|
37
|
+
readonly name: Schema.String;
|
|
38
|
+
readonly isFailure: Schema.Boolean;
|
|
39
|
+
}, "Type"> | Schema.Struct.ReadonlySide<{
|
|
40
|
+
readonly type: Schema.Literal<"approval-required">;
|
|
41
|
+
readonly approvalId: Schema.String;
|
|
42
|
+
readonly toolCallId: Schema.String;
|
|
43
|
+
}, "Type"> | Schema.Struct.ReadonlySide<{
|
|
44
|
+
readonly type: Schema.Literal<"history">;
|
|
45
|
+
readonly value: Schema.String;
|
|
46
|
+
}, "Type"> | Schema.Struct.ReadonlySide<{
|
|
47
|
+
readonly type: Schema.Literal<"finish">;
|
|
48
|
+
}, "Type"> | Schema.Struct.ReadonlySide<{
|
|
49
|
+
readonly type: Schema.Literal<"error">;
|
|
50
|
+
readonly code: Schema.Literals<readonly ["unavailable", "invalid-request", "stream-failed"]>;
|
|
51
51
|
}, "Type"> | {
|
|
52
52
|
type: "history";
|
|
53
53
|
value: string;
|
|
@@ -56,44 +56,44 @@ declare const AgentService_base: Context.ServiceClass<AgentService, "AgentServic
|
|
|
56
56
|
code: "stream-failed";
|
|
57
57
|
} | {
|
|
58
58
|
type: "finish";
|
|
59
|
-
}, never, Exclude<Tool.HandlerServices<Tools[keyof Tools]>, LanguageModel.LanguageModel> | Exclude<Tool.ResultDecodingServices<Tools[keyof Tools]>, LanguageModel.LanguageModel>>, AgentHistoryError |
|
|
59
|
+
}, never, Exclude<Tool.HandlerServices<Tools[keyof Tools]>, LanguageModel.LanguageModel> | Exclude<Tool.ResultDecodingServices<Tools[keyof Tools]>, LanguageModel.LanguageModel>>, AgentHistoryError | Schema.SchemaError, LanguageModel.LanguageModel>;
|
|
60
60
|
}> & {
|
|
61
61
|
readonly make: Effect.Effect<{
|
|
62
|
-
stream: <Tools extends Record<string, Tool.Any>>(args_0: AgentStreamOptions<Tools>) => Effect.Effect<Stream.Stream<
|
|
63
|
-
readonly type:
|
|
64
|
-
readonly messageId:
|
|
65
|
-
}, "Type"> |
|
|
66
|
-
readonly type:
|
|
67
|
-
readonly messageId:
|
|
68
|
-
readonly delta:
|
|
69
|
-
}, "Type"> |
|
|
70
|
-
readonly type:
|
|
71
|
-
readonly messageId:
|
|
72
|
-
readonly toolCallId:
|
|
73
|
-
readonly name:
|
|
74
|
-
readonly input:
|
|
75
|
-
readonly metadata:
|
|
76
|
-
readonly title:
|
|
77
|
-
readonly description:
|
|
78
|
-
readonly destructive:
|
|
62
|
+
stream: <Tools extends Record<string, Tool.Any>>(args_0: AgentStreamOptions<Tools>) => Effect.Effect<Stream.Stream<Schema.Struct.ReadonlySide<{
|
|
63
|
+
readonly type: Schema.Literal<"message-start">;
|
|
64
|
+
readonly messageId: Schema.String;
|
|
65
|
+
}, "Type"> | Schema.Struct.ReadonlySide<{
|
|
66
|
+
readonly type: Schema.Literal<"text-delta">;
|
|
67
|
+
readonly messageId: Schema.String;
|
|
68
|
+
readonly delta: Schema.String;
|
|
69
|
+
}, "Type"> | Schema.Struct.ReadonlySide<{
|
|
70
|
+
readonly type: Schema.Literal<"tool-call">;
|
|
71
|
+
readonly messageId: Schema.String;
|
|
72
|
+
readonly toolCallId: Schema.String;
|
|
73
|
+
readonly name: Schema.String;
|
|
74
|
+
readonly input: Schema.Unknown;
|
|
75
|
+
readonly metadata: Schema.Struct<{
|
|
76
|
+
readonly title: Schema.optional<Schema.String>;
|
|
77
|
+
readonly description: Schema.optional<Schema.String>;
|
|
78
|
+
readonly destructive: Schema.Boolean;
|
|
79
79
|
}>;
|
|
80
|
-
}, "Type"> |
|
|
81
|
-
readonly type:
|
|
82
|
-
readonly toolCallId:
|
|
83
|
-
readonly name:
|
|
84
|
-
readonly isFailure:
|
|
85
|
-
}, "Type"> |
|
|
86
|
-
readonly type:
|
|
87
|
-
readonly approvalId:
|
|
88
|
-
readonly toolCallId:
|
|
89
|
-
}, "Type"> |
|
|
90
|
-
readonly type:
|
|
91
|
-
readonly value:
|
|
92
|
-
}, "Type"> |
|
|
93
|
-
readonly type:
|
|
94
|
-
}, "Type"> |
|
|
95
|
-
readonly type:
|
|
96
|
-
readonly code:
|
|
80
|
+
}, "Type"> | Schema.Struct.ReadonlySide<{
|
|
81
|
+
readonly type: Schema.Literal<"tool-result">;
|
|
82
|
+
readonly toolCallId: Schema.String;
|
|
83
|
+
readonly name: Schema.String;
|
|
84
|
+
readonly isFailure: Schema.Boolean;
|
|
85
|
+
}, "Type"> | Schema.Struct.ReadonlySide<{
|
|
86
|
+
readonly type: Schema.Literal<"approval-required">;
|
|
87
|
+
readonly approvalId: Schema.String;
|
|
88
|
+
readonly toolCallId: Schema.String;
|
|
89
|
+
}, "Type"> | Schema.Struct.ReadonlySide<{
|
|
90
|
+
readonly type: Schema.Literal<"history">;
|
|
91
|
+
readonly value: Schema.String;
|
|
92
|
+
}, "Type"> | Schema.Struct.ReadonlySide<{
|
|
93
|
+
readonly type: Schema.Literal<"finish">;
|
|
94
|
+
}, "Type"> | Schema.Struct.ReadonlySide<{
|
|
95
|
+
readonly type: Schema.Literal<"error">;
|
|
96
|
+
readonly code: Schema.Literals<readonly ["unavailable", "invalid-request", "stream-failed"]>;
|
|
97
97
|
}, "Type"> | {
|
|
98
98
|
type: "history";
|
|
99
99
|
value: string;
|
|
@@ -102,7 +102,7 @@ declare const AgentService_base: Context.ServiceClass<AgentService, "AgentServic
|
|
|
102
102
|
code: "stream-failed";
|
|
103
103
|
} | {
|
|
104
104
|
type: "finish";
|
|
105
|
-
}, never, Exclude<Tool.HandlerServices<Tools[keyof Tools]>, LanguageModel.LanguageModel> | Exclude<Tool.ResultDecodingServices<Tools[keyof Tools]>, LanguageModel.LanguageModel>>, AgentHistoryError |
|
|
105
|
+
}, never, Exclude<Tool.HandlerServices<Tools[keyof Tools]>, LanguageModel.LanguageModel> | Exclude<Tool.ResultDecodingServices<Tools[keyof Tools]>, LanguageModel.LanguageModel>>, AgentHistoryError | Schema.SchemaError, LanguageModel.LanguageModel>;
|
|
106
106
|
}, never, never>;
|
|
107
107
|
};
|
|
108
108
|
export declare class AgentService extends AgentService_base {
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
// ../../src/services/agent/index.ts
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Context,
|
|
4
|
+
Data,
|
|
5
|
+
Effect,
|
|
6
|
+
Layer,
|
|
7
|
+
Option,
|
|
8
|
+
Ref,
|
|
9
|
+
Schema,
|
|
10
|
+
Stream
|
|
11
|
+
} from "effect";
|
|
3
12
|
import {
|
|
4
13
|
Chat,
|
|
5
14
|
LanguageModel,
|
|
@@ -9,23 +18,30 @@ import {
|
|
|
9
18
|
|
|
10
19
|
class AgentHistoryError extends Data.TaggedError("AgentHistoryError") {
|
|
11
20
|
}
|
|
21
|
+
var AgentStreamErrorDetails = Schema.Struct({
|
|
22
|
+
message: Schema.optional(Schema.String),
|
|
23
|
+
reason: Schema.optional(Schema.String),
|
|
24
|
+
status: Schema.optional(Schema.Number),
|
|
25
|
+
_tag: Schema.optional(Schema.String)
|
|
26
|
+
}).annotate({ identifier: "AgentStreamErrorDetails" });
|
|
27
|
+
var decodeAgentStreamErrorDetails = Schema.decodeUnknownOption(AgentStreamErrorDetails);
|
|
12
28
|
|
|
13
29
|
class AgentService extends Context.Service()("AgentService", {
|
|
14
30
|
make: Effect.gen(function* () {
|
|
15
31
|
const streamErrorDetails = (error) => {
|
|
16
|
-
|
|
32
|
+
const details = Option.getOrUndefined(decodeAgentStreamErrorDetails(error));
|
|
33
|
+
if (!details)
|
|
17
34
|
return { error: String(error) };
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
35
|
+
const result = {};
|
|
36
|
+
if (details.message)
|
|
37
|
+
result.message = details.message;
|
|
38
|
+
if (details.reason)
|
|
39
|
+
result.reason = details.reason;
|
|
40
|
+
if (details.status !== undefined)
|
|
41
|
+
result.status = details.status;
|
|
42
|
+
if (details._tag)
|
|
43
|
+
result.tag = details._tag;
|
|
44
|
+
return result;
|
|
29
45
|
};
|
|
30
46
|
const eventsForPart = ({
|
|
31
47
|
messageId,
|
|
@@ -45,11 +61,14 @@ class AgentService extends Context.Service()("AgentService", {
|
|
|
45
61
|
toolCallId: part.id,
|
|
46
62
|
name: part.name,
|
|
47
63
|
input: part.params,
|
|
48
|
-
metadata: {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
64
|
+
metadata: (() => {
|
|
65
|
+
const metadata = {
|
|
66
|
+
destructive: tool ? Context.get(tool.annotations, Tool.Destructive) : false,
|
|
67
|
+
title,
|
|
68
|
+
description: tool?.description
|
|
69
|
+
};
|
|
70
|
+
return metadata;
|
|
71
|
+
})()
|
|
53
72
|
}
|
|
54
73
|
];
|
|
55
74
|
}
|
|
@@ -120,7 +139,7 @@ class AgentService extends Context.Service()("AgentService", {
|
|
|
120
139
|
const resolvedToolCallIds = new Set;
|
|
121
140
|
for (const message of history.content) {
|
|
122
141
|
for (const part of message.content) {
|
|
123
|
-
if (
|
|
142
|
+
if (Schema.is(Schema.String)(part))
|
|
124
143
|
continue;
|
|
125
144
|
if (part.type === "tool-approval-request" && part.approvalId === action.approvalId) {
|
|
126
145
|
pendingToolCallId = part.toolCallId;
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import { Context, Effect, Layer } from "effect";
|
|
2
|
+
import type { Json } from "effect/Schema";
|
|
2
3
|
import { NotificationSendError } from "../schema.js";
|
|
3
4
|
export interface NotificationChannels {
|
|
4
5
|
}
|
|
5
|
-
export type NotificationMessage = keyof NotificationChannels extends never ? Record<string,
|
|
6
|
+
export type NotificationMessage<FallbackPayload = Json> = keyof NotificationChannels extends never ? Record<string, FallbackPayload> : Partial<{
|
|
6
7
|
readonly [Key in keyof NotificationChannels]: NotificationChannels[Key];
|
|
7
8
|
}>;
|
|
8
|
-
export interface
|
|
9
|
+
export interface NotificationChannel<Key extends string = string, Payload = Json> {
|
|
9
10
|
readonly key: Key;
|
|
10
|
-
readonly send: (payload:
|
|
11
|
+
readonly send: (payload: Payload, message: NotificationMessage) => Effect.Effect<void, NotificationSendError>;
|
|
11
12
|
readonly payload?: Payload;
|
|
12
13
|
}
|
|
13
|
-
export interface
|
|
14
|
-
readonly channels: ReadonlyArray<
|
|
14
|
+
export interface NotificationChannelRegistryService {
|
|
15
|
+
readonly channels: ReadonlyArray<NotificationChannel>;
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
+
/** @deprecated Use the domain-owned names without the Shape suffix. */
|
|
18
|
+
export { type NotificationChannel as NotificationChannelShape, type NotificationChannelRegistryService as NotificationChannelRegistryShape, };
|
|
19
|
+
declare const NotificationChannelRegistry_base: Context.ServiceClass<NotificationChannelRegistry, "NotificationChannelRegistry", NotificationChannelRegistryService>;
|
|
17
20
|
export declare class NotificationChannelRegistry extends NotificationChannelRegistry_base {
|
|
18
|
-
static readonly make: (...channels: ReadonlyArray<
|
|
19
|
-
static readonly layer: (channels: ReadonlyArray<
|
|
21
|
+
static readonly make: (...channels: ReadonlyArray<NotificationChannel>) => NotificationChannelRegistryService;
|
|
22
|
+
static readonly layer: (channels: ReadonlyArray<NotificationChannel>) => Layer.Layer<NotificationChannelRegistry, never, never>;
|
|
20
23
|
static readonly emptyLayer: Layer.Layer<NotificationChannelRegistry, never, never>;
|
|
21
24
|
}
|
|
22
|
-
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Config, Context, Effect, Layer, Redacted } from "effect";
|
|
2
|
-
import { type
|
|
2
|
+
import { type NotificationChannel } from "..";
|
|
3
3
|
import { SesEmailNotification } from "./schema.js";
|
|
4
4
|
declare module ".." {
|
|
5
5
|
interface NotificationChannels {
|
|
@@ -14,17 +14,17 @@ interface SesIdentity {
|
|
|
14
14
|
readonly region: string;
|
|
15
15
|
readonly from: string | undefined;
|
|
16
16
|
}
|
|
17
|
-
interface
|
|
17
|
+
interface SesNotificationConfigService {
|
|
18
18
|
readonly identity: SesIdentity;
|
|
19
19
|
readonly accessKey: SesAccessKey;
|
|
20
20
|
}
|
|
21
|
-
declare const SesNotificationConfig_base: Context.ServiceClass<SesNotificationConfig, "SesNotificationConfig",
|
|
22
|
-
readonly make: Effect.Effect<
|
|
21
|
+
declare const SesNotificationConfig_base: Context.ServiceClass<SesNotificationConfig, "SesNotificationConfig", SesNotificationConfigService> & {
|
|
22
|
+
readonly make: Effect.Effect<SesNotificationConfigService, Config.ConfigError, never>;
|
|
23
23
|
};
|
|
24
24
|
export declare class SesNotificationConfig extends SesNotificationConfig_base {
|
|
25
25
|
static readonly layer: Layer.Layer<SesNotificationConfig, Config.ConfigError, never>;
|
|
26
26
|
}
|
|
27
|
-
declare const SesNotificationChannel_base: Context.ServiceClass<SesNotificationChannel, "SesNotificationChannel",
|
|
27
|
+
declare const SesNotificationChannel_base: Context.ServiceClass<SesNotificationChannel, "SesNotificationChannel", NotificationChannel<"email", {
|
|
28
28
|
readonly from?: string | undefined;
|
|
29
29
|
readonly to: string | readonly [string, ...string[]];
|
|
30
30
|
readonly cc?: readonly string[] | undefined;
|
|
@@ -34,7 +34,7 @@ declare const SesNotificationChannel_base: Context.ServiceClass<SesNotificationC
|
|
|
34
34
|
readonly text?: string | undefined;
|
|
35
35
|
readonly html?: string | undefined;
|
|
36
36
|
}>> & {
|
|
37
|
-
readonly make: Effect.Effect<
|
|
37
|
+
readonly make: Effect.Effect<NotificationChannel<"email", {
|
|
38
38
|
readonly from?: string | undefined;
|
|
39
39
|
readonly to: string | readonly [string, ...string[]];
|
|
40
40
|
readonly cc?: readonly string[] | undefined;
|
|
@@ -106,7 +106,7 @@ class SesNotificationChannel extends Context.Service()("SesNotificationChannel",
|
|
|
106
106
|
FromEmailAddress: from,
|
|
107
107
|
Destination: buildDestination(email),
|
|
108
108
|
Content: { Simple: emailMessage },
|
|
109
|
-
|
|
109
|
+
ReplyToAddresses: email.replyTo?.length ? Array.from(email.replyTo) : undefined
|
|
110
110
|
})),
|
|
111
111
|
catch: (error) => notificationSendError("Failed to send SES email", error)
|
|
112
112
|
});
|
|
@@ -119,7 +119,7 @@ class SesNotificationChannel extends Context.Service()("SesNotificationChannel",
|
|
|
119
119
|
var notificationSendError = (message, error) => new NotificationSendError({
|
|
120
120
|
channel: "email",
|
|
121
121
|
message,
|
|
122
|
-
|
|
122
|
+
error
|
|
123
123
|
});
|
|
124
124
|
var decodeEmail = (payload) => Schema3.decodeUnknownEffect(SesEmailNotification)(payload).pipe(Effect.mapError((error) => notificationSendError("Invalid SES email notification payload", error)));
|
|
125
125
|
var requireBody = (email) => {
|
|
@@ -127,18 +127,22 @@ var requireBody = (email) => {
|
|
|
127
127
|
if (!html && !text) {
|
|
128
128
|
return Effect.fail(notificationSendError("SES email notification requires text or html"));
|
|
129
129
|
}
|
|
130
|
-
const body = {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
const body = {};
|
|
131
|
+
if (text)
|
|
132
|
+
body.Text = { Data: text, Charset: "UTF-8" };
|
|
133
|
+
if (html)
|
|
134
|
+
body.Html = { Data: html, Charset: "UTF-8" };
|
|
134
135
|
return Effect.succeed(body);
|
|
135
136
|
};
|
|
136
137
|
var recipients = (to) => Array.isArray(to) ? Array.from(to) : [to];
|
|
137
|
-
var buildDestination = (email) =>
|
|
138
|
-
ToAddresses: recipients(email.to)
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
var buildDestination = (email) => {
|
|
139
|
+
const destination = { ToAddresses: recipients(email.to) };
|
|
140
|
+
if (email.cc?.length)
|
|
141
|
+
destination.CcAddresses = Array.from(email.cc);
|
|
142
|
+
if (email.bcc?.length)
|
|
143
|
+
destination.BccAddresses = Array.from(email.bcc);
|
|
144
|
+
return destination;
|
|
145
|
+
};
|
|
142
146
|
export {
|
|
143
147
|
SesNotificationConfig,
|
|
144
148
|
SesNotificationChannel
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
TriangleAlert
|
|
9
9
|
} from "lucide-react";
|
|
10
10
|
import { useState } from "react";
|
|
11
|
+
import { Schema } from "effect";
|
|
11
12
|
|
|
12
13
|
// ../../src/components/ui/badge.tsx
|
|
13
14
|
import { mergeProps } from "@base-ui/react/merge-props";
|
|
@@ -974,7 +975,7 @@ function NotificationListItem({
|
|
|
974
975
|
onNavigate(notification);
|
|
975
976
|
return;
|
|
976
977
|
}
|
|
977
|
-
if (notification.href &&
|
|
978
|
+
if (notification.href && globalThis.window) {
|
|
978
979
|
window.location.assign(notification.href);
|
|
979
980
|
}
|
|
980
981
|
};
|
|
@@ -1112,7 +1113,7 @@ var formatNotificationDate = (value, locale) => {
|
|
|
1112
1113
|
timeStyle: "short"
|
|
1113
1114
|
}).format(date);
|
|
1114
1115
|
};
|
|
1115
|
-
var notificationTitle = (notification) =>
|
|
1116
|
+
var notificationTitle = (notification) => Schema.is(Schema.String)(notification.title) ? notification.title : defaultMessages.en.notifications;
|
|
1116
1117
|
export {
|
|
1117
1118
|
notificationMenuMessages,
|
|
1118
1119
|
NotificationMenuTrigger,
|