@krak-stack/registry 0.1.55 → 0.1.56
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 +13 -0
- package/dist/components/ui/error-component.js +1 -1
- package/dist/lib/docs.js +2 -1
- 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 +9 -4
- package/dist/services/events/client/tracking-notice.js +2 -1
- package/dist/services/events/index.d.ts +9 -9
- package/dist/services/events/index.js +9 -8
- package/dist/services/opentelemetry/web-vitals.js +1 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @krak-stack/registry
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Merge the error component's homepage link classes with `cn` so its outline border is visible instead of being overridden by the base transparent border.
|
|
8
|
+
|
|
9
|
+
## 0.1.56
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Upgrade to Effect 4.1.0 and use Effect crypto services for UUIDv7 entity IDs, hashing, and secure capability generation. Preserve existing deterministic fingerprints and random upload capability tokens.
|
|
14
|
+
- d3000ed: Use exact matching for documentation sidebar links so Introduction is only highlighted on its own page.
|
|
15
|
+
|
|
3
16
|
## 0.1.55
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
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)
|
|
@@ -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
|
|
@@ -637,20 +641,21 @@ class BrowserEvents {
|
|
|
637
641
|
locale,
|
|
638
642
|
sanitizePath
|
|
639
643
|
} = {}) => {
|
|
644
|
+
const random = Effect5.runSync(SecureRandom2.SecureRandom.pipe(Effect5.provide(SecureRandom2.layerWebCrypto)));
|
|
640
645
|
const allowed = () => enabled && (!respectDoNotTrack || !browserPrivacyEnabled()) && (!requireConsent || analyticsAllowed());
|
|
641
646
|
let previousPath;
|
|
642
|
-
let pageViewId =
|
|
647
|
+
let pageViewId = Effect5.runSync(random.uuidV7());
|
|
643
648
|
const context = (name, properties) => {
|
|
644
649
|
const explicitPath = Schema6.decodeUnknownOption(Schema6.String)(properties?.["url.path"]);
|
|
645
650
|
const path = Option5.getOrElse(explicitPath, () => location.pathname);
|
|
646
651
|
if (location.pathname !== previousPath || name === "browser.page_view") {
|
|
647
652
|
previousPath = location.pathname;
|
|
648
|
-
pageViewId =
|
|
653
|
+
pageViewId = Effect5.runSync(random.uuidV7());
|
|
649
654
|
}
|
|
650
655
|
const attributes = {
|
|
651
656
|
"app.event.schema.version": "1",
|
|
652
657
|
"analytics.page_view.id": pageViewId,
|
|
653
|
-
"log.record.uid":
|
|
658
|
+
"log.record.uid": Effect5.runSync(random.uuidV7()),
|
|
654
659
|
"url.path": sanitizePath?.(path) ?? path,
|
|
655
660
|
"browser.language": navigator.language.slice(0, 256)
|
|
656
661
|
};
|
|
@@ -148,6 +148,7 @@ function DialogDescription({
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
// ../../src/services/opentelemetry/consent.ts
|
|
151
|
+
import { SecureRandom } from "effect/crypto";
|
|
151
152
|
import { Effect, Option, Schema as Schema2 } from "effect";
|
|
152
153
|
|
|
153
154
|
// ../../src/services/opentelemetry/schema.ts
|
|
@@ -247,7 +248,7 @@ var saveAnalyticsPreference = (choice) => {
|
|
|
247
248
|
const issuedAt = Date.now();
|
|
248
249
|
const value = Schema2.encodeSync(codec)({
|
|
249
250
|
choice,
|
|
250
|
-
revision:
|
|
251
|
+
revision: Effect.runSync(SecureRandom.SecureRandom.use((random) => random.uuidV7()).pipe(Effect.provide(SecureRandom.layerWebCrypto))),
|
|
251
252
|
version: ANALYTICS_NOTICE_VERSION,
|
|
252
253
|
issuedAt,
|
|
253
254
|
expiresAt: issuedAt + lifetime
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Config, Context,
|
|
1
|
+
import { Config, Context, DateTime, Effect, Layer, Redacted, Schema } from "effect";
|
|
2
2
|
import { HttpServerRequest } from "effect/http";
|
|
3
3
|
import { OtlpLogsProcessor, OtlpProcessingError } from "../opentelemetry/processor.js";
|
|
4
4
|
import { Otlp } from "../opentelemetry/index.js";
|
|
@@ -32,7 +32,7 @@ export declare const dailyVisitorId: (input: {
|
|
|
32
32
|
readonly userAgent: string;
|
|
33
33
|
readonly day: string;
|
|
34
34
|
readonly secret: Redacted.Redacted<string>;
|
|
35
|
-
}) => Effect.Effect<string,
|
|
35
|
+
}) => Effect.Effect<string, never, never>;
|
|
36
36
|
declare const Events_base: Context.ServiceClass<Events, "krakstack/events/Events", {
|
|
37
37
|
process: (body: Uint8Array<ArrayBufferLike>) => Effect.Effect<{
|
|
38
38
|
body: Uint8Array<ArrayBufferLike>;
|
|
@@ -70,7 +70,7 @@ declare const Events_base: Context.ServiceClass<Events, "krakstack/events/Events
|
|
|
70
70
|
}) => Effect.Effect<{
|
|
71
71
|
eventId: string;
|
|
72
72
|
inserted: boolean;
|
|
73
|
-
}, EventConflictError | EventsPersistenceError |
|
|
73
|
+
}, EventConflictError | EventsPersistenceError | Schema.SchemaError, never>;
|
|
74
74
|
list: (input: {
|
|
75
75
|
readonly page?: string | number | undefined;
|
|
76
76
|
readonly pageSize?: string | number | undefined;
|
|
@@ -160,7 +160,7 @@ declare const Events_base: Context.ServiceClass<Events, "krakstack/events/Events
|
|
|
160
160
|
}) => Effect.Effect<{
|
|
161
161
|
eventId: string;
|
|
162
162
|
inserted: boolean;
|
|
163
|
-
}, EventConflictError | EventsPersistenceError |
|
|
163
|
+
}, EventConflictError | EventsPersistenceError | Schema.SchemaError, never>;
|
|
164
164
|
list: (input: {
|
|
165
165
|
readonly page?: string | number | undefined;
|
|
166
166
|
readonly pageSize?: string | number | undefined;
|
|
@@ -212,14 +212,14 @@ declare const Events_base: Context.ServiceClass<Events, "krakstack/events/Events
|
|
|
212
212
|
pageCount: number;
|
|
213
213
|
};
|
|
214
214
|
}, EventsPersistenceError | import("effect/Cause").NoSuchElementError | Schema.SchemaError | import("effect/sql/SqlError").SqlError, never>;
|
|
215
|
-
}, EventsConfigurationError,
|
|
215
|
+
}, EventsConfigurationError, Otlp | OtlpEvents>;
|
|
216
216
|
};
|
|
217
217
|
export declare class Events extends Events_base {
|
|
218
218
|
/** Missing options resolve from APP_SECRET, VITE_SITE_URL and Otlp. */
|
|
219
|
-
static readonly baseLayerWith: (options?: Partial<EventsOptions>) => Layer.Layer<Events, Config.ConfigError | EventsConfigurationError,
|
|
220
|
-
static readonly baseLayer: Layer.Layer<Events, Config.ConfigError | EventsConfigurationError,
|
|
219
|
+
static readonly baseLayerWith: (options?: Partial<EventsOptions>) => Layer.Layer<Events, Config.ConfigError | EventsConfigurationError, Otlp | OtlpEvents>;
|
|
220
|
+
static readonly baseLayer: Layer.Layer<Events, Config.ConfigError | EventsConfigurationError, Otlp | OtlpEvents>;
|
|
221
221
|
/** An injected PostgreSQL/SQLite SqlClient enables persistence and the initial migration. */
|
|
222
|
-
static readonly layerWith: (options?: Partial<EventsOptions>) => Layer.Layer<Events, Config.ConfigError | EventsConfigurationError | import("effect/sql/Migrator").MigrationError | import("effect/sql/SqlError").SqlError,
|
|
223
|
-
static readonly layer: Layer.Layer<Events, Config.ConfigError | EventsConfigurationError | import("effect/sql/Migrator").MigrationError | import("effect/sql/SqlError").SqlError,
|
|
222
|
+
static readonly layerWith: (options?: Partial<EventsOptions>) => Layer.Layer<Events, Config.ConfigError | EventsConfigurationError | import("effect/sql/Migrator").MigrationError | import("effect/sql/SqlError").SqlError, Otlp | OtlpEvents>;
|
|
223
|
+
static readonly layer: Layer.Layer<Events, Config.ConfigError | EventsConfigurationError | import("effect/sql/Migrator").MigrationError | import("effect/sql/SqlError").SqlError, Otlp | OtlpEvents>;
|
|
224
224
|
static readonly ingestionLayer: Layer.Layer<OtlpLogsProcessor, never, Events>;
|
|
225
225
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import {
|
|
3
3
|
Config as Config2,
|
|
4
4
|
Context as Context4,
|
|
5
|
-
Crypto,
|
|
6
5
|
DateTime as DateTime2,
|
|
7
6
|
Effect as Effect8,
|
|
8
7
|
Layer as Layer3,
|
|
@@ -12,6 +11,7 @@ import {
|
|
|
12
11
|
References as References2,
|
|
13
12
|
Schema as Schema9
|
|
14
13
|
} from "effect";
|
|
14
|
+
import { Digest, SecureRandom as SecureRandom2 } from "effect/crypto";
|
|
15
15
|
import { HttpServerRequest } from "effect/http";
|
|
16
16
|
import { SqlClient as SqlClient2, SqlSchema } from "effect/sql";
|
|
17
17
|
import { Hex } from "effect/encoding";
|
|
@@ -576,6 +576,7 @@ var migrateEvents = Migrator.make({})({
|
|
|
576
576
|
});
|
|
577
577
|
|
|
578
578
|
// ../../src/services/opentelemetry/consent.ts
|
|
579
|
+
import { SecureRandom } from "effect/crypto";
|
|
579
580
|
import { Effect as Effect7, Option as Option5, Schema as Schema8 } from "effect";
|
|
580
581
|
var ANALYTICS_CONSENT_COOKIE = "krakstack_analytics_consent";
|
|
581
582
|
var ANALYTICS_NOTICE_VERSION = "1";
|
|
@@ -656,15 +657,15 @@ var eventContent = (record, source, compareTimestamp = source === "browser") =>
|
|
|
656
657
|
].includes(key) || key === "user.id" || key === "organization.id").sort((a, b) => a.key.localeCompare(b.key))
|
|
657
658
|
});
|
|
658
659
|
var dailyVisitorId = Effect8.fnUntraced(function* (input) {
|
|
659
|
-
const
|
|
660
|
+
const digestService = yield* Digest.Digest.pipe(Effect8.provide(Digest.layerWebCrypto));
|
|
660
661
|
const encoder = new TextEncoder;
|
|
661
|
-
const salt = yield*
|
|
662
|
+
const salt = yield* digestService.digest(Digest.sha256, encoder.encode(JSON.stringify([
|
|
662
663
|
"analytics.visitor.salt.v2",
|
|
663
664
|
Redacted.value(input.secret),
|
|
664
665
|
input.serviceName,
|
|
665
666
|
input.day
|
|
666
667
|
])));
|
|
667
|
-
const digest = yield*
|
|
668
|
+
const digest = yield* digestService.digest(Digest.sha256, encoder.encode(JSON.stringify([
|
|
668
669
|
"analytics.visitor.v2",
|
|
669
670
|
input.serviceName,
|
|
670
671
|
input.day,
|
|
@@ -677,7 +678,7 @@ var dailyVisitorId = Effect8.fnUntraced(function* (input) {
|
|
|
677
678
|
|
|
678
679
|
class Events extends Context4.Service()("krakstack/events/Events", {
|
|
679
680
|
make: (options) => Effect8.gen(function* () {
|
|
680
|
-
const
|
|
681
|
+
const random = yield* SecureRandom2.SecureRandom.pipe(Effect8.provide(SecureRandom2.layerWebCrypto));
|
|
681
682
|
const telemetry = yield* Otlp;
|
|
682
683
|
const exporter = yield* OtlpEvents;
|
|
683
684
|
const resource = options.serviceName ? yield* OtlpResource3.fromConfig({ serviceName: options.serviceName }) : yield* telemetry.resource;
|
|
@@ -776,12 +777,12 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
776
777
|
ip: location2.ip,
|
|
777
778
|
userAgent,
|
|
778
779
|
day: DateTime2.formatIsoDate(now)
|
|
779
|
-
})
|
|
780
|
+
}) : undefined;
|
|
780
781
|
let sessionId;
|
|
781
782
|
if (visitorId && storage) {
|
|
782
783
|
yield* storage.lockVisitor(visitorId);
|
|
783
784
|
const latest = yield* storage.latestSession({ visitorId });
|
|
784
|
-
sessionId = Option6.isSome(latest) && latest.value.received_at > DateTime2.toEpochMillis(now) - SESSION_TIMEOUT_MS ? latest.value.session_id : yield*
|
|
785
|
+
sessionId = Option6.isSome(latest) && latest.value.received_at > DateTime2.toEpochMillis(now) - SESSION_TIMEOUT_MS ? latest.value.session_id : yield* random.uuidV7();
|
|
785
786
|
}
|
|
786
787
|
const identity = {};
|
|
787
788
|
if (visitorId)
|
|
@@ -797,7 +798,7 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
797
798
|
});
|
|
798
799
|
const track = Effect8.fn("Events.track")(function* (input) {
|
|
799
800
|
const event = yield* Schema9.decodeUnknownEffect(TrackEvent)(input);
|
|
800
|
-
const eventId = event.eventId ?? (yield*
|
|
801
|
+
const eventId = event.eventId ?? (yield* random.uuidV7());
|
|
801
802
|
const category = event.category ?? "analytics";
|
|
802
803
|
const receivedAt = yield* DateTime2.now;
|
|
803
804
|
const now = DateTime2.toEpochMillis(receivedAt);
|
|
@@ -145,6 +145,7 @@ var event = Effect.fnUntraced(function* (name, properties, options) {
|
|
|
145
145
|
});
|
|
146
146
|
|
|
147
147
|
// ../../src/services/opentelemetry/consent.ts
|
|
148
|
+
import { SecureRandom } from "effect/crypto";
|
|
148
149
|
import { Effect as Effect2, Option as Option2, Schema as Schema3 } from "effect";
|
|
149
150
|
var ANALYTICS_CONSENT_COOKIE = "krakstack_analytics_consent";
|
|
150
151
|
var ANALYTICS_NOTICE_VERSION = "1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krak-stack/registry",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.56",
|
|
4
4
|
"description": "Tree-shakable KrakStack components and Effect services.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -271,8 +271,8 @@
|
|
|
271
271
|
"peerDependencies": {
|
|
272
272
|
"@aws-sdk/client-sesv2": "^3.1068.0",
|
|
273
273
|
"@base-ui/react": "^1.5.0",
|
|
274
|
-
"@effect/atom-react": "^4.
|
|
275
|
-
"@effect/platform-browser": "^4.
|
|
274
|
+
"@effect/atom-react": "^4.1.0",
|
|
275
|
+
"@effect/platform-browser": "^4.1.0",
|
|
276
276
|
"@iconify/react": "^6.0.2",
|
|
277
277
|
"@inlang/paraglide-js": "^2.19.0",
|
|
278
278
|
"@lucas-barake/effect-form": "1.1.0",
|
|
@@ -286,7 +286,7 @@
|
|
|
286
286
|
"cmdk": "^1.1.1",
|
|
287
287
|
"cn": "^0.3.0",
|
|
288
288
|
"drizzle-orm": "^1.0.0-rc.4-5d5b77c",
|
|
289
|
-
"effect": "^4.
|
|
289
|
+
"effect": "^4.1.0",
|
|
290
290
|
"lucide-react": "^1.18.0",
|
|
291
291
|
"react": "^19.2.0",
|
|
292
292
|
"react-dom": "^19.2.0"
|