@krak-stack/registry 0.1.55 → 0.1.57
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 +25 -0
- package/dist/components/ui/data-table.d.ts +85 -2
- package/dist/components/ui/data-table.js +1385 -608
- package/dist/components/ui/error-component.js +1 -1
- package/dist/lib/docs.js +2 -1
- package/dist/lib/query.d.ts +216 -0
- package/dist/lib/query.js +50 -2
- package/dist/services/agent/client/index.js +3 -1
- package/dist/services/agent/index.d.ts +2 -2
- package/dist/services/agent/index.js +3 -1
- package/dist/services/events/browser.js +55 -5
- package/dist/services/events/client/audit-log-table.js +1399 -626
- package/dist/services/events/client/tracking-notice.js +2 -1
- package/dist/services/events/index.d.ts +57 -9
- package/dist/services/events/index.js +62 -16
- package/dist/services/events/schema.d.ts +189 -0
- package/dist/services/events/schema.js +46 -1
- package/dist/services/opentelemetry/web-vitals.js +1 -0
- package/package.json +4 -4
package/dist/lib/docs.js
CHANGED
|
@@ -2184,7 +2184,8 @@ var DocsLayout = ({
|
|
|
2184
2184
|
items: section.pages.map((item) => {
|
|
2185
2185
|
const navItem = {
|
|
2186
2186
|
label: () => item.title,
|
|
2187
|
-
href: item.path
|
|
2187
|
+
href: item.path,
|
|
2188
|
+
exact: true
|
|
2188
2189
|
};
|
|
2189
2190
|
const ItemIcon = iconFor(docs.icons, item.icon);
|
|
2190
2191
|
if (ItemIcon)
|
package/dist/lib/query.d.ts
CHANGED
|
@@ -28,6 +28,80 @@ export declare const SortParams: Schema.declare<readonly {
|
|
|
28
28
|
readonly id: string;
|
|
29
29
|
readonly direction: "asc" | "desc";
|
|
30
30
|
}[]>;
|
|
31
|
+
export declare const TextFilterOperator: Schema.Literals<readonly ["contains", "equals", "startsWith", "endsWith"]>;
|
|
32
|
+
export declare const ColumnFilter: Schema.Union<readonly [Schema.Struct<{
|
|
33
|
+
readonly id: Schema.NonEmptyString;
|
|
34
|
+
readonly kind: Schema.Literal<"text">;
|
|
35
|
+
readonly operator: Schema.Literals<readonly ["contains", "equals", "startsWith", "endsWith"]>;
|
|
36
|
+
readonly value: Schema.NonEmptyString;
|
|
37
|
+
}>, Schema.Struct<{
|
|
38
|
+
readonly id: Schema.NonEmptyString;
|
|
39
|
+
readonly kind: Schema.Literal<"number">;
|
|
40
|
+
readonly min: Schema.optional<Schema.Finite>;
|
|
41
|
+
readonly max: Schema.optional<Schema.Finite>;
|
|
42
|
+
}>, Schema.Struct<{
|
|
43
|
+
readonly id: Schema.NonEmptyString;
|
|
44
|
+
readonly kind: Schema.Literal<"date">;
|
|
45
|
+
readonly from: Schema.optional<Schema.String>;
|
|
46
|
+
readonly to: Schema.optional<Schema.String>;
|
|
47
|
+
}>, Schema.Struct<{
|
|
48
|
+
readonly id: Schema.NonEmptyString;
|
|
49
|
+
readonly kind: Schema.Literal<"boolean">;
|
|
50
|
+
readonly value: Schema.Boolean;
|
|
51
|
+
}>, Schema.Struct<{
|
|
52
|
+
readonly id: Schema.NonEmptyString;
|
|
53
|
+
readonly kind: Schema.Literal<"values">;
|
|
54
|
+
readonly values: Schema.NonEmptyArray<Schema.String>;
|
|
55
|
+
}>]>;
|
|
56
|
+
export type ColumnFilter = typeof ColumnFilter.Type;
|
|
57
|
+
/** Structured in router/JSON state; schema-validated JSON in HTTP query strings. */
|
|
58
|
+
export declare const ColumnFilters: Schema.declare<readonly ({
|
|
59
|
+
readonly id: string;
|
|
60
|
+
readonly kind: "number";
|
|
61
|
+
readonly min?: number | undefined;
|
|
62
|
+
readonly max?: number | undefined;
|
|
63
|
+
} | {
|
|
64
|
+
readonly id: string;
|
|
65
|
+
readonly kind: "date";
|
|
66
|
+
readonly from?: string | undefined;
|
|
67
|
+
readonly to?: string | undefined;
|
|
68
|
+
} | {
|
|
69
|
+
readonly id: string;
|
|
70
|
+
readonly kind: "text";
|
|
71
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
72
|
+
readonly value: string;
|
|
73
|
+
} | {
|
|
74
|
+
readonly id: string;
|
|
75
|
+
readonly kind: "boolean";
|
|
76
|
+
readonly value: boolean;
|
|
77
|
+
} | {
|
|
78
|
+
readonly id: string;
|
|
79
|
+
readonly kind: "values";
|
|
80
|
+
readonly values: readonly [string, ...string[]];
|
|
81
|
+
})[], readonly ({
|
|
82
|
+
readonly id: string;
|
|
83
|
+
readonly kind: "number";
|
|
84
|
+
readonly min?: number | undefined;
|
|
85
|
+
readonly max?: number | undefined;
|
|
86
|
+
} | {
|
|
87
|
+
readonly id: string;
|
|
88
|
+
readonly kind: "date";
|
|
89
|
+
readonly from?: string | undefined;
|
|
90
|
+
readonly to?: string | undefined;
|
|
91
|
+
} | {
|
|
92
|
+
readonly id: string;
|
|
93
|
+
readonly kind: "text";
|
|
94
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
95
|
+
readonly value: string;
|
|
96
|
+
} | {
|
|
97
|
+
readonly id: string;
|
|
98
|
+
readonly kind: "boolean";
|
|
99
|
+
readonly value: boolean;
|
|
100
|
+
} | {
|
|
101
|
+
readonly id: string;
|
|
102
|
+
readonly kind: "values";
|
|
103
|
+
readonly values: readonly [string, ...string[]];
|
|
104
|
+
})[]>;
|
|
31
105
|
export declare const Query: Schema.Struct<{
|
|
32
106
|
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
33
107
|
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
@@ -39,6 +113,53 @@ export declare const Query: Schema.Struct<{
|
|
|
39
113
|
readonly id: string;
|
|
40
114
|
readonly direction: "asc" | "desc";
|
|
41
115
|
}[]>>;
|
|
116
|
+
readonly filters: Schema.optional<Schema.declare<readonly ({
|
|
117
|
+
readonly id: string;
|
|
118
|
+
readonly kind: "number";
|
|
119
|
+
readonly min?: number | undefined;
|
|
120
|
+
readonly max?: number | undefined;
|
|
121
|
+
} | {
|
|
122
|
+
readonly id: string;
|
|
123
|
+
readonly kind: "date";
|
|
124
|
+
readonly from?: string | undefined;
|
|
125
|
+
readonly to?: string | undefined;
|
|
126
|
+
} | {
|
|
127
|
+
readonly id: string;
|
|
128
|
+
readonly kind: "text";
|
|
129
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
130
|
+
readonly value: string;
|
|
131
|
+
} | {
|
|
132
|
+
readonly id: string;
|
|
133
|
+
readonly kind: "boolean";
|
|
134
|
+
readonly value: boolean;
|
|
135
|
+
} | {
|
|
136
|
+
readonly id: string;
|
|
137
|
+
readonly kind: "values";
|
|
138
|
+
readonly values: readonly [string, ...string[]];
|
|
139
|
+
})[], readonly ({
|
|
140
|
+
readonly id: string;
|
|
141
|
+
readonly kind: "number";
|
|
142
|
+
readonly min?: number | undefined;
|
|
143
|
+
readonly max?: number | undefined;
|
|
144
|
+
} | {
|
|
145
|
+
readonly id: string;
|
|
146
|
+
readonly kind: "date";
|
|
147
|
+
readonly from?: string | undefined;
|
|
148
|
+
readonly to?: string | undefined;
|
|
149
|
+
} | {
|
|
150
|
+
readonly id: string;
|
|
151
|
+
readonly kind: "text";
|
|
152
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
153
|
+
readonly value: string;
|
|
154
|
+
} | {
|
|
155
|
+
readonly id: string;
|
|
156
|
+
readonly kind: "boolean";
|
|
157
|
+
readonly value: boolean;
|
|
158
|
+
} | {
|
|
159
|
+
readonly id: string;
|
|
160
|
+
readonly kind: "values";
|
|
161
|
+
readonly values: readonly [string, ...string[]];
|
|
162
|
+
})[]>>;
|
|
42
163
|
}>;
|
|
43
164
|
export type QueryType = typeof Query.Type;
|
|
44
165
|
export type QueryEncoded = typeof Query.Encoded;
|
|
@@ -50,6 +171,30 @@ export declare const QueryStandard: import("effect/StandardSchema").StandardSche
|
|
|
50
171
|
readonly id: string;
|
|
51
172
|
readonly direction: "asc" | "desc";
|
|
52
173
|
}[] | undefined;
|
|
174
|
+
readonly filters?: readonly ({
|
|
175
|
+
readonly id: string;
|
|
176
|
+
readonly kind: "number";
|
|
177
|
+
readonly min?: number | undefined;
|
|
178
|
+
readonly max?: number | undefined;
|
|
179
|
+
} | {
|
|
180
|
+
readonly id: string;
|
|
181
|
+
readonly kind: "date";
|
|
182
|
+
readonly from?: string | undefined;
|
|
183
|
+
readonly to?: string | undefined;
|
|
184
|
+
} | {
|
|
185
|
+
readonly id: string;
|
|
186
|
+
readonly kind: "text";
|
|
187
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
188
|
+
readonly value: string;
|
|
189
|
+
} | {
|
|
190
|
+
readonly id: string;
|
|
191
|
+
readonly kind: "boolean";
|
|
192
|
+
readonly value: boolean;
|
|
193
|
+
} | {
|
|
194
|
+
readonly id: string;
|
|
195
|
+
readonly kind: "values";
|
|
196
|
+
readonly values: readonly [string, ...string[]];
|
|
197
|
+
})[] | undefined;
|
|
53
198
|
}, {
|
|
54
199
|
readonly page: number;
|
|
55
200
|
readonly pageSize: number;
|
|
@@ -58,6 +203,30 @@ export declare const QueryStandard: import("effect/StandardSchema").StandardSche
|
|
|
58
203
|
readonly id: string;
|
|
59
204
|
readonly direction: "asc" | "desc";
|
|
60
205
|
}[] | undefined;
|
|
206
|
+
readonly filters?: readonly ({
|
|
207
|
+
readonly id: string;
|
|
208
|
+
readonly kind: "number";
|
|
209
|
+
readonly min?: number | undefined;
|
|
210
|
+
readonly max?: number | undefined;
|
|
211
|
+
} | {
|
|
212
|
+
readonly id: string;
|
|
213
|
+
readonly kind: "date";
|
|
214
|
+
readonly from?: string | undefined;
|
|
215
|
+
readonly to?: string | undefined;
|
|
216
|
+
} | {
|
|
217
|
+
readonly id: string;
|
|
218
|
+
readonly kind: "text";
|
|
219
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
220
|
+
readonly value: string;
|
|
221
|
+
} | {
|
|
222
|
+
readonly id: string;
|
|
223
|
+
readonly kind: "boolean";
|
|
224
|
+
readonly value: boolean;
|
|
225
|
+
} | {
|
|
226
|
+
readonly id: string;
|
|
227
|
+
readonly kind: "values";
|
|
228
|
+
readonly values: readonly [string, ...string[]];
|
|
229
|
+
})[] | undefined;
|
|
61
230
|
}> & Schema.Struct<{
|
|
62
231
|
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
63
232
|
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
@@ -69,6 +238,53 @@ export declare const QueryStandard: import("effect/StandardSchema").StandardSche
|
|
|
69
238
|
readonly id: string;
|
|
70
239
|
readonly direction: "asc" | "desc";
|
|
71
240
|
}[]>>;
|
|
241
|
+
readonly filters: Schema.optional<Schema.declare<readonly ({
|
|
242
|
+
readonly id: string;
|
|
243
|
+
readonly kind: "number";
|
|
244
|
+
readonly min?: number | undefined;
|
|
245
|
+
readonly max?: number | undefined;
|
|
246
|
+
} | {
|
|
247
|
+
readonly id: string;
|
|
248
|
+
readonly kind: "date";
|
|
249
|
+
readonly from?: string | undefined;
|
|
250
|
+
readonly to?: string | undefined;
|
|
251
|
+
} | {
|
|
252
|
+
readonly id: string;
|
|
253
|
+
readonly kind: "text";
|
|
254
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
255
|
+
readonly value: string;
|
|
256
|
+
} | {
|
|
257
|
+
readonly id: string;
|
|
258
|
+
readonly kind: "boolean";
|
|
259
|
+
readonly value: boolean;
|
|
260
|
+
} | {
|
|
261
|
+
readonly id: string;
|
|
262
|
+
readonly kind: "values";
|
|
263
|
+
readonly values: readonly [string, ...string[]];
|
|
264
|
+
})[], readonly ({
|
|
265
|
+
readonly id: string;
|
|
266
|
+
readonly kind: "number";
|
|
267
|
+
readonly min?: number | undefined;
|
|
268
|
+
readonly max?: number | undefined;
|
|
269
|
+
} | {
|
|
270
|
+
readonly id: string;
|
|
271
|
+
readonly kind: "date";
|
|
272
|
+
readonly from?: string | undefined;
|
|
273
|
+
readonly to?: string | undefined;
|
|
274
|
+
} | {
|
|
275
|
+
readonly id: string;
|
|
276
|
+
readonly kind: "text";
|
|
277
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
278
|
+
readonly value: string;
|
|
279
|
+
} | {
|
|
280
|
+
readonly id: string;
|
|
281
|
+
readonly kind: "boolean";
|
|
282
|
+
readonly value: boolean;
|
|
283
|
+
} | {
|
|
284
|
+
readonly id: string;
|
|
285
|
+
readonly kind: "values";
|
|
286
|
+
readonly values: readonly [string, ...string[]];
|
|
287
|
+
})[]>>;
|
|
72
288
|
}>;
|
|
73
289
|
export declare const PaginationMeta: Schema.Struct<{
|
|
74
290
|
readonly page: Schema.Int;
|
package/dist/lib/query.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// ../../src/lib/query.ts
|
|
2
2
|
import {
|
|
3
|
+
DateTime,
|
|
3
4
|
Effect,
|
|
4
5
|
Option,
|
|
5
6
|
Schema,
|
|
@@ -80,6 +81,49 @@ var SortParams = Schema.declare(Schema.is(SortParamsArray), {
|
|
|
80
81
|
toCodec: () => Schema.link()(SortParamsArray, SchemaTransformation.passthrough()),
|
|
81
82
|
toCodecStringTree: () => Schema.link()(SortParamsFromString, SchemaTransformation.passthrough())
|
|
82
83
|
});
|
|
84
|
+
var TextFilterOperator = Schema.Literals([
|
|
85
|
+
"contains",
|
|
86
|
+
"equals",
|
|
87
|
+
"startsWith",
|
|
88
|
+
"endsWith"
|
|
89
|
+
]).annotate({ identifier: "TextFilterOperator" });
|
|
90
|
+
var FilterCalendarDate = Schema.String.check(Schema.isPattern(/^\d{4}-\d{2}-\d{2}$/), Schema.makeFilter((value) => Option.exists(DateTime.make(value), (date) => DateTime.formatIsoDateUtc(date) === value))).annotate({ identifier: "FilterCalendarDate" });
|
|
91
|
+
var ColumnFilter = Schema.Union([
|
|
92
|
+
Schema.Struct({
|
|
93
|
+
id: Schema.NonEmptyString,
|
|
94
|
+
kind: Schema.Literal("text"),
|
|
95
|
+
operator: TextFilterOperator,
|
|
96
|
+
value: Schema.NonEmptyString
|
|
97
|
+
}),
|
|
98
|
+
Schema.Struct({
|
|
99
|
+
id: Schema.NonEmptyString,
|
|
100
|
+
kind: Schema.Literal("number"),
|
|
101
|
+
min: Schema.optional(Schema.Finite),
|
|
102
|
+
max: Schema.optional(Schema.Finite)
|
|
103
|
+
}).check(Schema.makeFilter((range) => (range.min !== undefined || range.max !== undefined) && (range.min === undefined || range.max === undefined || range.min <= range.max))),
|
|
104
|
+
Schema.Struct({
|
|
105
|
+
id: Schema.NonEmptyString,
|
|
106
|
+
kind: Schema.Literal("date"),
|
|
107
|
+
from: Schema.optional(FilterCalendarDate),
|
|
108
|
+
to: Schema.optional(FilterCalendarDate)
|
|
109
|
+
}).check(Schema.makeFilter((range) => (range.from !== undefined || range.to !== undefined) && (range.from === undefined || range.to === undefined || range.from <= range.to))),
|
|
110
|
+
Schema.Struct({
|
|
111
|
+
id: Schema.NonEmptyString,
|
|
112
|
+
kind: Schema.Literal("boolean"),
|
|
113
|
+
value: Schema.Boolean
|
|
114
|
+
}),
|
|
115
|
+
Schema.Struct({
|
|
116
|
+
id: Schema.NonEmptyString,
|
|
117
|
+
kind: Schema.Literal("values"),
|
|
118
|
+
values: Schema.NonEmptyArray(Schema.String)
|
|
119
|
+
})
|
|
120
|
+
]).annotate({ identifier: "ColumnFilter" });
|
|
121
|
+
var ColumnFiltersArray = Schema.Array(ColumnFilter);
|
|
122
|
+
var ColumnFilters = Schema.declare(Schema.is(ColumnFiltersArray), {
|
|
123
|
+
identifier: "ColumnFilters",
|
|
124
|
+
toCodec: () => Schema.link()(ColumnFiltersArray, SchemaTransformation.passthrough()),
|
|
125
|
+
toCodecStringTree: () => Schema.link()(Schema.fromJsonString(ColumnFiltersArray), SchemaTransformation.passthrough())
|
|
126
|
+
});
|
|
83
127
|
var Query = Schema.Struct({
|
|
84
128
|
page: Schema.optional(Schema.Union([Schema.Number, Schema.NumberFromString]).check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0))).pipe(Schema.decodeTo(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)), {
|
|
85
129
|
decode: SchemaGetter.withDefault(Effect.succeed(0)),
|
|
@@ -90,7 +134,8 @@ var Query = Schema.Struct({
|
|
|
90
134
|
encode: SchemaGetter.transformOptional(Option.filter((pageSize) => pageSize !== 20))
|
|
91
135
|
})),
|
|
92
136
|
globalFilter: Schema.optional(Schema.String),
|
|
93
|
-
sort: Schema.optional(SortParams)
|
|
137
|
+
sort: Schema.optional(SortParams),
|
|
138
|
+
filters: Schema.optional(ColumnFilters)
|
|
94
139
|
}).annotate({
|
|
95
140
|
identifier: "Query",
|
|
96
141
|
title: "Query",
|
|
@@ -124,6 +169,8 @@ var PaginatedResponse = (items) => Schema.Struct({
|
|
|
124
169
|
meta: PaginationMeta
|
|
125
170
|
});
|
|
126
171
|
export {
|
|
172
|
+
ColumnFilter,
|
|
173
|
+
ColumnFilters,
|
|
127
174
|
PaginatedResponse,
|
|
128
175
|
PaginationMeta,
|
|
129
176
|
Query,
|
|
@@ -132,5 +179,6 @@ export {
|
|
|
132
179
|
SortParam,
|
|
133
180
|
SortParamFromString,
|
|
134
181
|
SortParams,
|
|
135
|
-
SortParamsFromString
|
|
182
|
+
SortParamsFromString,
|
|
183
|
+
TextFilterOperator
|
|
136
184
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// ../../src/services/agent/client/atom.ts
|
|
2
|
+
import { SecureRandom } from "effect/crypto";
|
|
2
3
|
import { Effect, Layer, Option, Schema, Stream } from "effect";
|
|
3
4
|
import { Atom } from "effect/reactivity";
|
|
5
|
+
var random = Effect.runSync(SecureRandom.SecureRandom.pipe(Effect.provide(SecureRandom.layerWebCrypto)));
|
|
4
6
|
var initialAgentState = {
|
|
5
7
|
context: undefined,
|
|
6
8
|
contextLocked: false,
|
|
@@ -103,7 +105,7 @@ var makeAgentAtoms = ({
|
|
|
103
105
|
const messages = submitAction.type === "message" ? [
|
|
104
106
|
...current.messages,
|
|
105
107
|
{
|
|
106
|
-
id:
|
|
108
|
+
id: Effect.runSync(random.uuidV7()),
|
|
107
109
|
role: "user",
|
|
108
110
|
text: submitAction.text,
|
|
109
111
|
tools: []
|
|
@@ -66,7 +66,7 @@ declare const AgentService_base: Context.ServiceClass<AgentService, "AgentServic
|
|
|
66
66
|
code: "stream-failed";
|
|
67
67
|
} | {
|
|
68
68
|
type: "finish";
|
|
69
|
-
}, never, Exclude<Tool.
|
|
69
|
+
}, never, Exclude<Tool.Requirements<Tools[keyof Tools]>, LanguageModel.LanguageModel> | Exclude<Tool.ResultDecodingServices<Tools[keyof Tools]>, LanguageModel.LanguageModel> | Exclude<Tool.SchemaServices<Tools[keyof Tools]>, LanguageModel.LanguageModel>>, AgentHistoryError | Schema.SchemaError, LanguageModel.LanguageModel>;
|
|
70
70
|
}> & {
|
|
71
71
|
readonly make: Effect.Effect<{
|
|
72
72
|
stream: <Tools extends Record<string, Tool.Any>>(args_0: AgentStreamOptions<Tools>) => Effect.Effect<Stream.Stream<{
|
|
@@ -122,7 +122,7 @@ declare const AgentService_base: Context.ServiceClass<AgentService, "AgentServic
|
|
|
122
122
|
code: "stream-failed";
|
|
123
123
|
} | {
|
|
124
124
|
type: "finish";
|
|
125
|
-
}, never, Exclude<Tool.
|
|
125
|
+
}, never, Exclude<Tool.Requirements<Tools[keyof Tools]>, LanguageModel.LanguageModel> | Exclude<Tool.ResultDecodingServices<Tools[keyof Tools]>, LanguageModel.LanguageModel> | Exclude<Tool.SchemaServices<Tools[keyof Tools]>, LanguageModel.LanguageModel>>, AgentHistoryError | Schema.SchemaError, LanguageModel.LanguageModel>;
|
|
126
126
|
}, never, never>;
|
|
127
127
|
};
|
|
128
128
|
export declare class AgentService extends AgentService_base {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// ../../src/services/agent/index.ts
|
|
2
|
+
import { SecureRandom } from "effect/crypto";
|
|
2
3
|
import {
|
|
3
4
|
Context,
|
|
4
5
|
Data,
|
|
@@ -98,6 +99,7 @@ var decodeAgentStreamErrorDetails = Schema.decodeUnknownOption(AgentStreamErrorD
|
|
|
98
99
|
|
|
99
100
|
class AgentService extends Context.Service()("AgentService", {
|
|
100
101
|
make: Effect.gen(function* () {
|
|
102
|
+
const random = yield* SecureRandom.SecureRandom.pipe(Effect.provide(SecureRandom.layerWebCrypto));
|
|
101
103
|
const streamErrorDetails = (error) => {
|
|
102
104
|
const details = Option.getOrUndefined(decodeAgentStreamErrorDetails(error));
|
|
103
105
|
if (!details)
|
|
@@ -238,7 +240,7 @@ class AgentService extends Context.Service()("AgentService", {
|
|
|
238
240
|
});
|
|
239
241
|
const stream = Effect.fn("AgentService.stream")(function* ({ action, history, systemPrompt, toolkit }) {
|
|
240
242
|
const model = yield* LanguageModel.LanguageModel;
|
|
241
|
-
const messageId =
|
|
243
|
+
const messageId = yield* random.uuidV7();
|
|
242
244
|
const conversation = history ? yield* Chat.fromJson(history) : yield* Chat.fromPrompt([{ role: "system", content: systemPrompt }]);
|
|
243
245
|
yield* Ref.update(conversation.history, Prompt.setSystem(systemPrompt));
|
|
244
246
|
if (action.type === "approval") {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// ../../src/services/events/browser.ts
|
|
2
|
+
import { SecureRandom as SecureRandom2 } from "effect/crypto";
|
|
3
|
+
|
|
1
4
|
// ../../src/services/opentelemetry/events.ts
|
|
2
5
|
import {
|
|
3
6
|
Clock,
|
|
@@ -144,6 +147,7 @@ var event = Effect.fnUntraced(function* (name, properties, options) {
|
|
|
144
147
|
import { Context as Context2, Effect as Effect5, FiberSet, Layer as Layer2, Option as Option5, Schema as Schema6 } from "effect";
|
|
145
148
|
|
|
146
149
|
// ../../src/services/opentelemetry/consent.ts
|
|
150
|
+
import { SecureRandom } from "effect/crypto";
|
|
147
151
|
import { Effect as Effect2, Option as Option2, Schema as Schema3 } from "effect";
|
|
148
152
|
var ANALYTICS_CONSENT_COOKIE = "krakstack_analytics_consent";
|
|
149
153
|
var ANALYTICS_NOTICE_VERSION = "1";
|
|
@@ -197,7 +201,7 @@ var saveAnalyticsPreference = (choice) => {
|
|
|
197
201
|
const issuedAt = Date.now();
|
|
198
202
|
const value = Schema3.encodeSync(codec)({
|
|
199
203
|
choice,
|
|
200
|
-
revision:
|
|
204
|
+
revision: Effect2.runSync(SecureRandom.SecureRandom.use((random) => random.uuidV7()).pipe(Effect2.provide(SecureRandom.layerWebCrypto))),
|
|
201
205
|
version: ANALYTICS_NOTICE_VERSION,
|
|
202
206
|
issuedAt,
|
|
203
207
|
expiresAt: issuedAt + lifetime
|
|
@@ -231,6 +235,7 @@ import { Effect as Effect4, Option as Option4, Schema as Schema5 } from "effect"
|
|
|
231
235
|
|
|
232
236
|
// ../../src/lib/query.ts
|
|
233
237
|
import {
|
|
238
|
+
DateTime as DateTime2,
|
|
234
239
|
Effect as Effect3,
|
|
235
240
|
Option as Option3,
|
|
236
241
|
Schema as Schema4,
|
|
@@ -311,6 +316,49 @@ var SortParams = Schema4.declare(Schema4.is(SortParamsArray), {
|
|
|
311
316
|
toCodec: () => Schema4.link()(SortParamsArray, SchemaTransformation.passthrough()),
|
|
312
317
|
toCodecStringTree: () => Schema4.link()(SortParamsFromString, SchemaTransformation.passthrough())
|
|
313
318
|
});
|
|
319
|
+
var TextFilterOperator = Schema4.Literals([
|
|
320
|
+
"contains",
|
|
321
|
+
"equals",
|
|
322
|
+
"startsWith",
|
|
323
|
+
"endsWith"
|
|
324
|
+
]).annotate({ identifier: "TextFilterOperator" });
|
|
325
|
+
var FilterCalendarDate = Schema4.String.check(Schema4.isPattern(/^\d{4}-\d{2}-\d{2}$/), Schema4.makeFilter((value) => Option3.exists(DateTime2.make(value), (date) => DateTime2.formatIsoDateUtc(date) === value))).annotate({ identifier: "FilterCalendarDate" });
|
|
326
|
+
var ColumnFilter = Schema4.Union([
|
|
327
|
+
Schema4.Struct({
|
|
328
|
+
id: Schema4.NonEmptyString,
|
|
329
|
+
kind: Schema4.Literal("text"),
|
|
330
|
+
operator: TextFilterOperator,
|
|
331
|
+
value: Schema4.NonEmptyString
|
|
332
|
+
}),
|
|
333
|
+
Schema4.Struct({
|
|
334
|
+
id: Schema4.NonEmptyString,
|
|
335
|
+
kind: Schema4.Literal("number"),
|
|
336
|
+
min: Schema4.optional(Schema4.Finite),
|
|
337
|
+
max: Schema4.optional(Schema4.Finite)
|
|
338
|
+
}).check(Schema4.makeFilter((range) => (range.min !== undefined || range.max !== undefined) && (range.min === undefined || range.max === undefined || range.min <= range.max))),
|
|
339
|
+
Schema4.Struct({
|
|
340
|
+
id: Schema4.NonEmptyString,
|
|
341
|
+
kind: Schema4.Literal("date"),
|
|
342
|
+
from: Schema4.optional(FilterCalendarDate),
|
|
343
|
+
to: Schema4.optional(FilterCalendarDate)
|
|
344
|
+
}).check(Schema4.makeFilter((range) => (range.from !== undefined || range.to !== undefined) && (range.from === undefined || range.to === undefined || range.from <= range.to))),
|
|
345
|
+
Schema4.Struct({
|
|
346
|
+
id: Schema4.NonEmptyString,
|
|
347
|
+
kind: Schema4.Literal("boolean"),
|
|
348
|
+
value: Schema4.Boolean
|
|
349
|
+
}),
|
|
350
|
+
Schema4.Struct({
|
|
351
|
+
id: Schema4.NonEmptyString,
|
|
352
|
+
kind: Schema4.Literal("values"),
|
|
353
|
+
values: Schema4.NonEmptyArray(Schema4.String)
|
|
354
|
+
})
|
|
355
|
+
]).annotate({ identifier: "ColumnFilter" });
|
|
356
|
+
var ColumnFiltersArray = Schema4.Array(ColumnFilter);
|
|
357
|
+
var ColumnFilters = Schema4.declare(Schema4.is(ColumnFiltersArray), {
|
|
358
|
+
identifier: "ColumnFilters",
|
|
359
|
+
toCodec: () => Schema4.link()(ColumnFiltersArray, SchemaTransformation.passthrough()),
|
|
360
|
+
toCodecStringTree: () => Schema4.link()(Schema4.fromJsonString(ColumnFiltersArray), SchemaTransformation.passthrough())
|
|
361
|
+
});
|
|
314
362
|
var Query = Schema4.Struct({
|
|
315
363
|
page: Schema4.optional(Schema4.Union([Schema4.Number, Schema4.NumberFromString]).check(Schema4.isInt(), Schema4.isGreaterThanOrEqualTo(0))).pipe(Schema4.decodeTo(Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0)), {
|
|
316
364
|
decode: SchemaGetter.withDefault(Effect3.succeed(0)),
|
|
@@ -321,7 +369,8 @@ var Query = Schema4.Struct({
|
|
|
321
369
|
encode: SchemaGetter.transformOptional(Option3.filter((pageSize) => pageSize !== 20))
|
|
322
370
|
})),
|
|
323
371
|
globalFilter: Schema4.optional(Schema4.String),
|
|
324
|
-
sort: Schema4.optional(SortParams)
|
|
372
|
+
sort: Schema4.optional(SortParams),
|
|
373
|
+
filters: Schema4.optional(ColumnFilters)
|
|
325
374
|
}).annotate({
|
|
326
375
|
identifier: "Query",
|
|
327
376
|
title: "Query",
|
|
@@ -637,20 +686,21 @@ class BrowserEvents {
|
|
|
637
686
|
locale,
|
|
638
687
|
sanitizePath
|
|
639
688
|
} = {}) => {
|
|
689
|
+
const random = Effect5.runSync(SecureRandom2.SecureRandom.pipe(Effect5.provide(SecureRandom2.layerWebCrypto)));
|
|
640
690
|
const allowed = () => enabled && (!respectDoNotTrack || !browserPrivacyEnabled()) && (!requireConsent || analyticsAllowed());
|
|
641
691
|
let previousPath;
|
|
642
|
-
let pageViewId =
|
|
692
|
+
let pageViewId = Effect5.runSync(random.uuidV7());
|
|
643
693
|
const context = (name, properties) => {
|
|
644
694
|
const explicitPath = Schema6.decodeUnknownOption(Schema6.String)(properties?.["url.path"]);
|
|
645
695
|
const path = Option5.getOrElse(explicitPath, () => location.pathname);
|
|
646
696
|
if (location.pathname !== previousPath || name === "browser.page_view") {
|
|
647
697
|
previousPath = location.pathname;
|
|
648
|
-
pageViewId =
|
|
698
|
+
pageViewId = Effect5.runSync(random.uuidV7());
|
|
649
699
|
}
|
|
650
700
|
const attributes = {
|
|
651
701
|
"app.event.schema.version": "1",
|
|
652
702
|
"analytics.page_view.id": pageViewId,
|
|
653
|
-
"log.record.uid":
|
|
703
|
+
"log.record.uid": Effect5.runSync(random.uuidV7()),
|
|
654
704
|
"url.path": sanitizePath?.(path) ?? path,
|
|
655
705
|
"browser.language": navigator.language.slice(0, 256)
|
|
656
706
|
};
|