@relayfx/sdk 0.2.13 → 0.2.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/dist/ai.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./index-kghdnamr.js";
2
+ import"./index-qg0hy7s1.js";
3
3
  import {
4
4
  AiError,
5
5
  Chat,
@@ -34,7 +34,7 @@ import {
34
34
  exports_tool_executor,
35
35
  exports_tool_output,
36
36
  exports_turn_policy
37
- } from "./index-3e4cs8s6.js";
37
+ } from "./index-9q3yh32k.js";
38
38
 
39
39
  // src/ai.ts
40
40
  var relayAiPackage = "@relayfx/sdk/ai";
@@ -0,0 +1,69 @@
1
+ // @bun
2
+ import {
3
+ ConfigFailure,
4
+ DatabaseDialect,
5
+ MigratorError,
6
+ RuntimeConfigurationError,
7
+ RuntimeMigrationError,
8
+ SqlFailure,
9
+ exports_runtime_database
10
+ } from "./index-gb7d1wfm.js";
11
+
12
+ // src/migration-errors.ts
13
+ import { Cause, Effect } from "effect";
14
+ var retain = (value, cause) => {
15
+ Object.defineProperty(value, "originalCause", { value: cause, enumerable: false });
16
+ return value;
17
+ };
18
+ var migrationFailure = (dialect, phase, cause) => retain(new RuntimeMigrationError({
19
+ dialect,
20
+ phase,
21
+ nextAction: phase === "apply" ? "retry" : "inspect-schema",
22
+ cause: retain(phase === "apply" ? new MigratorError({ reason: `packaged ${dialect} migration failed` }) : new SqlFailure({ category: "statement", operation: "verify", retryable: false }), cause)
23
+ }), cause);
24
+ var normalizeMigrationCause = (effect, dialect, phase) => effect.pipe(Effect.catchCause((cause) => Cause.hasInterrupts(cause) ? Effect.failCause(cause) : Effect.fail(migrationFailure(dialect, phase, cause))));
25
+
26
+ // src/runtime-database-adapter.ts
27
+ import { Cause as Cause2, Effect as Effect2, Layer } from "effect";
28
+ import { SqlClient } from "effect/unstable/sql/SqlClient";
29
+ var configurationFailure = (cause) => {
30
+ const configFailure = new ConfigFailure({ reason: "database client layer acquisition failed" });
31
+ Object.defineProperty(configFailure, "originalCause", { value: cause, enumerable: false });
32
+ return new RuntimeConfigurationError({
33
+ setting: "databaseLayer",
34
+ nextAction: "provide-setting",
35
+ cause: configFailure
36
+ });
37
+ };
38
+ var normalizeClientLayer = (clientLayer) => clientLayer.pipe(Layer.catchCause((cause) => {
39
+ if (Cause2.hasInterrupts(cause)) {
40
+ return Layer.unwrap(Effect2.failCause(Cause2.map(cause, configurationFailure)));
41
+ }
42
+ return Layer.unwrap(Effect2.fail(configurationFailure(Cause2.squash(cause))));
43
+ }));
44
+ var runtimeDatabaseLayer = (options) => {
45
+ const normalizedClientLayer = normalizeClientLayer(options.clientLayer);
46
+ const databaseLayer = Layer.effect(exports_runtime_database.Service, Effect2.gen(function* () {
47
+ const sql = yield* SqlClient;
48
+ const database = options.dialect === "sqlite" ? exports_runtime_database.Service.of({
49
+ dialect: "sqlite",
50
+ databaseIdentity: options.databaseIdentity,
51
+ ownership: "runtime-exclusive",
52
+ schemaHead: options.schemaHead,
53
+ notification: "in-process",
54
+ acquireSchema: options.schema.pipe(Effect2.provideService(SqlClient, sql))
55
+ }) : exports_runtime_database.Service.of({
56
+ dialect: options.dialect,
57
+ databaseIdentity: options.databaseIdentity,
58
+ ownership: "shared-multi-node",
59
+ schemaHead: options.schemaHead,
60
+ notification: options.dialect === "pg" ? "pg-listen-notify" : "polling",
61
+ verifySchema: options.schema.pipe(Effect2.provideService(SqlClient, sql))
62
+ });
63
+ return database;
64
+ })).pipe(Layer.provide(normalizedClientLayer));
65
+ const layer = Layer.merge(normalizedClientLayer, databaseLayer);
66
+ return Object.assign(layer, { [DatabaseDialect]: options.dialect });
67
+ };
68
+
69
+ export { normalizeMigrationCause, normalizeClientLayer, runtimeDatabaseLayer };