@relayfx/sdk 0.3.1 → 0.3.3
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 +67 -37
- package/dist/http-server.js +22 -0
- package/dist/index-25gwk9tj.js +3423 -0
- package/dist/{index-3sv8mmz5.js → index-49fm2rdv.js} +23 -30
- package/dist/{index-c2skef55.js → index-8pa5e2yn.js} +16521 -18783
- package/dist/index-cphmds30.js +2852 -0
- package/dist/index-nb39b5ae.js +17 -0
- package/dist/index.js +315 -844
- package/dist/mysql.js +18 -18
- package/dist/postgres.js +724 -24
- package/dist/sqlite.js +57 -168
- package/dist/types/ai/index.d.ts +2 -1
- package/dist/types/ai/language-model/language-model-registration.d.ts +9 -6
- package/dist/types/relay/adapter-outbox.d.ts +1 -1
- package/dist/types/relay/ai.d.ts +34 -2
- package/dist/types/relay/child-fan-out-admission.d.ts +5 -0
- package/dist/types/relay/child-fan-out-host.d.ts +73 -0
- package/dist/types/relay/client-public.d.ts +481 -0
- package/dist/types/relay/client.d.ts +1 -478
- package/dist/types/relay/database-identity.d.ts +4 -0
- package/dist/types/relay/http-server.d.ts +95 -0
- package/dist/types/relay/index.d.ts +37 -14
- package/dist/types/relay/internal-client.d.ts +22 -0
- package/dist/types/relay/language-model-registration.d.ts +13 -0
- package/dist/types/relay/mysql.d.ts +6 -7
- package/dist/types/relay/operation.d.ts +4 -4
- package/dist/types/relay/postgres.d.ts +10 -7
- package/dist/types/relay/runtime-acquisition-error.d.ts +61 -0
- package/dist/types/relay/runtime-database-adapter.d.ts +8 -5
- package/dist/types/relay/runtime-database-owner.d.ts +13 -0
- package/dist/types/relay/runtime-database-public.d.ts +10 -0
- package/dist/types/relay/runtime.d.ts +77 -72
- package/dist/types/relay/sqlite-runtime.d.ts +5 -18
- package/dist/types/relay/sqlite.d.ts +4 -31
- package/dist/types/relay/state-version-conflict.d.ts +12 -0
- package/dist/types/relay/tool-runtime.d.ts +44 -0
- package/dist/types/relay/tool-worker.d.ts +2 -2
- package/dist/types/relay/workflow-definition-host.d.ts +32 -0
- package/dist/types/runtime/agent/agent-loop-error.d.ts +21 -0
- package/dist/types/runtime/agent/agent-loop-service.d.ts +6 -16
- package/dist/types/runtime/agent/prompt-assembler-service.d.ts +3 -3
- package/dist/types/runtime/cluster/execution-entity.d.ts +3 -3
- package/dist/types/runtime/execution/execution-service.d.ts +3 -0
- package/dist/types/runtime/index.d.ts +1 -0
- package/dist/types/runtime/model/language-model-service.d.ts +5 -12
- package/dist/types/runtime/model/model-hub.d.ts +27 -0
- package/dist/types/runtime/presence/presence-contract.d.ts +24 -0
- package/dist/types/runtime/presence/presence-service.d.ts +6 -24
- package/dist/types/runtime/runner/runner-runtime-service.d.ts +29 -13
- package/dist/types/runtime/session/session-store-service.d.ts +4 -1
- package/dist/types/runtime/tool/tool-runtime-contract.d.ts +121 -0
- package/dist/types/runtime/tool/tool-runtime-service.d.ts +6 -120
- package/dist/types/runtime/workflow/execution-workflow.d.ts +22 -24
- package/dist/types/schema/agent-schema.d.ts +4 -1
- package/dist/types/schema/execution-schema.d.ts +13 -2
- package/dist/types/schema/index.d.ts +1 -0
- package/dist/types/schema/pagination-schema.d.ts +17 -0
- package/dist/types/schema/shared-schema.d.ts +4 -0
- package/dist/types/store-sql/schema/relay-schema.d.ts +12 -12
- package/dist/types/store-sql/session/session-repository.d.ts +54 -11
- package/package.json +17 -14
- package/dist/index-9k4k3wq1.js +0 -2860
- package/dist/index-d3dme13d.js +0 -141
- package/dist/types/relay/database.d.ts +0 -16
package/dist/index.js
CHANGED
|
@@ -1,68 +1,49 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
DatabaseIdentity,
|
|
4
|
+
exports_artifact_store_service,
|
|
5
|
+
exports_blob_store_service,
|
|
6
|
+
exports_child_fan_out_host,
|
|
7
|
+
exports_embedding_model_service,
|
|
8
|
+
exports_language_model_service,
|
|
9
|
+
exports_model_hub,
|
|
10
|
+
exports_prompt_assembler_service,
|
|
10
11
|
exports_runtime,
|
|
12
|
+
exports_schema_registry_service,
|
|
13
|
+
exports_tool_runtime,
|
|
14
|
+
exports_workflow_definition_host,
|
|
11
15
|
makeDatabaseIdentity
|
|
12
|
-
} from "./index-
|
|
16
|
+
} from "./index-8pa5e2yn.js";
|
|
13
17
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
dialect,
|
|
19
|
-
encodeJson,
|
|
20
|
-
exports_activity_version_registry,
|
|
21
|
-
exports_address_book_service,
|
|
22
|
-
exports_address_resolution_service,
|
|
18
|
+
exports_model_registry
|
|
19
|
+
} from "./index-25gwk9tj.js";
|
|
20
|
+
import {
|
|
21
|
+
Service,
|
|
23
22
|
exports_address_schema,
|
|
24
|
-
exports_agent_loop_service,
|
|
25
|
-
exports_agent_registry_service,
|
|
26
23
|
exports_agent_schema,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
exports_child_run_service,
|
|
24
|
+
exports_child_orchestration_schema,
|
|
25
|
+
exports_client_public,
|
|
26
|
+
exports_command,
|
|
31
27
|
exports_content_schema,
|
|
32
|
-
exports_definition_runtime,
|
|
33
|
-
exports_embedding_model_service,
|
|
34
28
|
exports_entity_schema,
|
|
35
29
|
exports_envelope_schema,
|
|
36
|
-
exports_envelope_service,
|
|
37
|
-
exports_event_log_service,
|
|
38
|
-
exports_execution_entity,
|
|
39
30
|
exports_execution_schema,
|
|
40
|
-
exports_execution_service,
|
|
41
|
-
exports_execution_workflow,
|
|
42
31
|
exports_ids_schema,
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
exports_inbox_schema,
|
|
33
|
+
exports_operation,
|
|
34
|
+
exports_pagination_schema,
|
|
45
35
|
exports_presence_schema,
|
|
46
|
-
exports_presence_service,
|
|
47
|
-
exports_presence_tool,
|
|
48
|
-
exports_prompt_assembler_service,
|
|
49
|
-
exports_runner_runtime_service,
|
|
50
36
|
exports_schedule_schema,
|
|
51
|
-
exports_scheduler_service,
|
|
52
|
-
exports_schema_registry_service,
|
|
53
37
|
exports_shared_schema,
|
|
54
|
-
exports_skill_definition_repository,
|
|
55
|
-
exports_skill_registry_service,
|
|
56
38
|
exports_skill_schema,
|
|
57
|
-
|
|
39
|
+
exports_state_schema,
|
|
58
40
|
exports_tool_schema,
|
|
59
41
|
exports_wait_schema,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
} from "./index-c2skef55.js";
|
|
42
|
+
exports_workflow_schema
|
|
43
|
+
} from "./index-cphmds30.js";
|
|
44
|
+
import {
|
|
45
|
+
__export
|
|
46
|
+
} from "./index-nb39b5ae.js";
|
|
66
47
|
|
|
67
48
|
// src/adapter-outbox.ts
|
|
68
49
|
var exports_adapter_outbox = {};
|
|
@@ -112,778 +93,26 @@ var submitInbound = Effect.fn("AdapterOutbox.submitInbound.call")(function* (inp
|
|
|
112
93
|
const service = yield* Service2;
|
|
113
94
|
return yield* service.submitInbound(input);
|
|
114
95
|
});
|
|
115
|
-
// src/database.ts
|
|
116
|
-
var exports_database = {};
|
|
117
|
-
__export(exports_database, {
|
|
118
|
-
testLayer: () => testLayer3,
|
|
119
|
-
pgTypeParsers: () => pgTypeParsers2,
|
|
120
|
-
layerFromPgClient: () => layerFromPgClient2,
|
|
121
|
-
dialect: () => dialect2,
|
|
122
|
-
check: () => check2,
|
|
123
|
-
Service: () => Service4,
|
|
124
|
-
PgClientLive: () => PgClientLive2,
|
|
125
|
-
Dialect: () => Dialect2
|
|
126
|
-
});
|
|
127
|
-
// ../store-sql/src/database/database-service.ts
|
|
128
|
-
var exports_database_service = {};
|
|
129
|
-
__export(exports_database_service, {
|
|
130
|
-
timestampParam: () => timestampParam,
|
|
131
|
-
testLayer: () => testLayer2,
|
|
132
|
-
pgTypeParsers: () => pgTypeParsers,
|
|
133
|
-
layerFromPgClient: () => layerFromPgClient,
|
|
134
|
-
layer: () => layer2,
|
|
135
|
-
fromPgDate: () => fromDbTimestamp,
|
|
136
|
-
fromNullablePgDate: () => fromNullableDbTimestamp,
|
|
137
|
-
fromNullableDbTimestamp: () => fromNullableDbTimestamp,
|
|
138
|
-
fromDbTimestamp: () => fromDbTimestamp,
|
|
139
|
-
encodeJson: () => encodeJson,
|
|
140
|
-
dialect: () => dialect,
|
|
141
|
-
decodeJson: () => decodeJson,
|
|
142
|
-
decodeBool: () => decodeBool,
|
|
143
|
-
check: () => check,
|
|
144
|
-
Service: () => Service3,
|
|
145
|
-
PgClientLive: () => PgClientLive,
|
|
146
|
-
Dialect: () => Dialect
|
|
147
|
-
});
|
|
148
|
-
import { layerConfig as PgClientLayerConfig } from "@effect/sql-pg/PgClient";
|
|
149
|
-
import { makeWithDefaults } from "drizzle-orm/effect-postgres";
|
|
150
|
-
import { sql } from "drizzle-orm";
|
|
151
|
-
import { Config, Context as Context2, Effect as Effect2, Layer as Layer2, Redacted } from "effect";
|
|
152
|
-
import { types } from "pg";
|
|
153
96
|
|
|
154
|
-
class Service3 extends Context2.Service()("@relayfx/store-sql/database/database-service/Service") {
|
|
155
|
-
}
|
|
156
|
-
var pgTypeParsers = {
|
|
157
|
-
getTypeParser: (typeId, format) => {
|
|
158
|
-
if ([1184, 1114, 1082, 1186, 1231, 1115, 1185, 1187, 1182].includes(typeId)) {
|
|
159
|
-
return (value) => value;
|
|
160
|
-
}
|
|
161
|
-
return types.getTypeParser(typeId, format);
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
var PgClientLive = PgClientLayerConfig({
|
|
165
|
-
url: Config.redacted("DATABASE_URL").pipe(Config.withDefault(Redacted.make("postgres://relay:relay@localhost:5545/relay"))),
|
|
166
|
-
maxConnections: Config.int("RELAY_SQL_MAX_CONNECTIONS").pipe(Config.withDefault(8)),
|
|
167
|
-
applicationName: Config.string("RELAY_SQL_APPLICATION_NAME").pipe(Config.withDefault("relay")),
|
|
168
|
-
types: Config.succeed(pgTypeParsers)
|
|
169
|
-
});
|
|
170
|
-
var layerFromPgClient = Layer2.effect(Service3, makeWithDefaults());
|
|
171
|
-
var layer2 = layerFromPgClient.pipe(Layer2.provide(PgClientLive));
|
|
172
|
-
var testLayer2 = (db) => Layer2.succeed(Service3, db);
|
|
173
|
-
var check = Effect2.fn("Database.check")(function* () {
|
|
174
|
-
const db = yield* Service3;
|
|
175
|
-
yield* db.execute(sql`select 1 as ok`).pipe(Effect2.asVoid);
|
|
176
|
-
});
|
|
177
|
-
// ../store-sql/src/schema/relay-schema.ts
|
|
178
|
-
var exports_relay_schema = {};
|
|
179
|
-
__export(exports_relay_schema, {
|
|
180
|
-
relayWorkspaceSnapshots: () => relayWorkspaceSnapshots,
|
|
181
|
-
relayWorkspaceLeases: () => relayWorkspaceLeases,
|
|
182
|
-
relayWorkflowRuns: () => relayWorkflowRuns,
|
|
183
|
-
relayWorkflowOperationStates: () => relayWorkflowOperationStates,
|
|
184
|
-
relayWorkflowLifecycleEvents: () => relayWorkflowLifecycleEvents,
|
|
185
|
-
relayWorkflowDefinitionRevisions: () => relayWorkflowDefinitionRevisions,
|
|
186
|
-
relayWaits: () => relayWaits,
|
|
187
|
-
relayTopicSubscriptions: () => relayTopicSubscriptions,
|
|
188
|
-
relayToolResults: () => relayToolResults,
|
|
189
|
-
relayToolCalls: () => relayToolCalls,
|
|
190
|
-
relayToolAttempts: () => relayToolAttempts,
|
|
191
|
-
relaySteeringMessages: () => relaySteeringMessages,
|
|
192
|
-
relaySteeringDrains: () => relaySteeringDrains,
|
|
193
|
-
relaySkillDefinitions: () => relaySkillDefinitions,
|
|
194
|
-
relaySkillDefinitionRevisions: () => relaySkillDefinitionRevisions,
|
|
195
|
-
relaySessions: () => relaySessions,
|
|
196
|
-
relaySessionEntries: () => relaySessionEntries,
|
|
197
|
-
relaySchedules: () => relaySchedules,
|
|
198
|
-
relayRouteAttempts: () => relayRouteAttempts,
|
|
199
|
-
relayPresence: () => relayPresence,
|
|
200
|
-
relayPermissionRules: () => relayPermissionRules,
|
|
201
|
-
relayMemoryRecords: () => relayMemoryRecords,
|
|
202
|
-
relayInboxMessages: () => relayInboxMessages,
|
|
203
|
-
relayInboxDrains: () => relayInboxDrains,
|
|
204
|
-
relayIdempotencyKeys: () => relayIdempotencyKeys,
|
|
205
|
-
relayExecutions: () => relayExecutions,
|
|
206
|
-
relayExecutionStateOps: () => relayExecutionStateOps,
|
|
207
|
-
relayExecutionState: () => relayExecutionState,
|
|
208
|
-
relayExecutionSkillPins: () => relayExecutionSkillPins,
|
|
209
|
-
relayExecutionEvents: () => relayExecutionEvents,
|
|
210
|
-
relayExecutionContextEpochs: () => relayExecutionContextEpochs,
|
|
211
|
-
relayEnvelopes: () => relayEnvelopes,
|
|
212
|
-
relayEnvelopeReady: () => relayEnvelopeReady,
|
|
213
|
-
relayEntityKinds: () => relayEntityKinds,
|
|
214
|
-
relayEntityInstances: () => relayEntityInstances,
|
|
215
|
-
relayChildFanOuts: () => relayChildFanOuts,
|
|
216
|
-
relayChildFanOutMembers: () => relayChildFanOutMembers,
|
|
217
|
-
relayChildExecutions: () => relayChildExecutions,
|
|
218
|
-
relayAgentDefinitions: () => relayAgentDefinitions,
|
|
219
|
-
relayAgentDefinitionRevisions: () => relayAgentDefinitionRevisions,
|
|
220
|
-
relayAgentCompactions: () => relayAgentCompactions,
|
|
221
|
-
relayAgentChats: () => relayAgentChats,
|
|
222
|
-
relayAddressBookEntries: () => relayAddressBookEntries
|
|
223
|
-
});
|
|
224
|
-
import {
|
|
225
|
-
boolean,
|
|
226
|
-
doublePrecision,
|
|
227
|
-
index,
|
|
228
|
-
integer,
|
|
229
|
-
jsonb,
|
|
230
|
-
pgTable,
|
|
231
|
-
primaryKey,
|
|
232
|
-
text,
|
|
233
|
-
timestamp,
|
|
234
|
-
uniqueIndex
|
|
235
|
-
} from "drizzle-orm/pg-core";
|
|
236
|
-
import { sql as sql2 } from "drizzle-orm";
|
|
237
|
-
var tenantId = () => text("tenant_id").$type().notNull().default(exports_ids_schema.SystemTenantId);
|
|
238
|
-
var relayWorkflowDefinitionRevisions = pgTable("relay_workflow_definition_revisions", {
|
|
239
|
-
tenantId: tenantId(),
|
|
240
|
-
workflowDefinitionId: text("workflow_definition_id").$type().notNull(),
|
|
241
|
-
revision: integer("revision").$type().notNull(),
|
|
242
|
-
digest: text("digest").$type().notNull(),
|
|
243
|
-
definitionJson: jsonb("definition_json").$type().notNull(),
|
|
244
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
245
|
-
}, (table) => [
|
|
246
|
-
primaryKey({ columns: [table.tenantId, table.workflowDefinitionId, table.revision] }),
|
|
247
|
-
uniqueIndex("uq_relay_workflow_definition_digest").on(table.tenantId, table.workflowDefinitionId, table.digest)
|
|
248
|
-
]);
|
|
249
|
-
var relayWorkflowRuns = pgTable("relay_workflow_runs", {
|
|
250
|
-
tenantId: tenantId(),
|
|
251
|
-
executionId: text("execution_id").$type().notNull(),
|
|
252
|
-
workflowDefinitionId: text("workflow_definition_id").$type().notNull(),
|
|
253
|
-
workflowDefinitionRevision: integer("workflow_definition_revision").$type().notNull(),
|
|
254
|
-
workflowDefinitionDigest: text("workflow_definition_digest").$type().notNull(),
|
|
255
|
-
status: text("status").$type().notNull(),
|
|
256
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
257
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
258
|
-
}, (table) => [primaryKey({ columns: [table.tenantId, table.executionId] })]);
|
|
259
|
-
var relayWorkflowOperationStates = pgTable("relay_workflow_operation_states", {
|
|
260
|
-
tenantId: tenantId(),
|
|
261
|
-
executionId: text("execution_id").$type().notNull(),
|
|
262
|
-
operationId: text("operation_id").$type().notNull(),
|
|
263
|
-
status: text("status").notNull(),
|
|
264
|
-
fanOutId: text("fan_out_id"),
|
|
265
|
-
decision: boolean("decision"),
|
|
266
|
-
outputJson: jsonb("output_json"),
|
|
267
|
-
attempt: integer("attempt"),
|
|
268
|
-
backoffUntil: timestamp("backoff_until", { withTimezone: true }),
|
|
269
|
-
compensationOperationId: text("compensation_operation_id"),
|
|
270
|
-
startedAt: timestamp("started_at", { withTimezone: true }),
|
|
271
|
-
completedAt: timestamp("completed_at", { withTimezone: true }),
|
|
272
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
273
|
-
}, (table) => [primaryKey({ columns: [table.tenantId, table.executionId, table.operationId] })]);
|
|
274
|
-
var relayWorkflowLifecycleEvents = pgTable("relay_workflow_lifecycle_events", {
|
|
275
|
-
tenantId: tenantId(),
|
|
276
|
-
executionId: text("execution_id").$type().notNull(),
|
|
277
|
-
sequence: integer("sequence").notNull(),
|
|
278
|
-
eventType: text("event_type").notNull(),
|
|
279
|
-
operationId: text("operation_id"),
|
|
280
|
-
dataJson: jsonb("data_json"),
|
|
281
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull()
|
|
282
|
-
}, (table) => [primaryKey({ columns: [table.tenantId, table.executionId, table.sequence] })]);
|
|
283
|
-
var relayEntityKinds = pgTable("relay_entity_kinds", {
|
|
284
|
-
tenantId: tenantId(),
|
|
285
|
-
kind: text("kind").$type().notNull(),
|
|
286
|
-
agentId: text("agent_id").$type().notNull(),
|
|
287
|
-
inboxPolicyJson: jsonb("inbox_policy_json").$type(),
|
|
288
|
-
stateEnabled: integer("state_enabled").$type(),
|
|
289
|
-
continueAsNewAfterTurns: integer("continue_as_new_after_turns"),
|
|
290
|
-
metadataJson: jsonb("metadata_json").$type().notNull().default({}),
|
|
291
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
292
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
293
|
-
}, (table) => [primaryKey({ columns: [table.tenantId, table.kind], name: "pk_relay_entity_kinds" })]);
|
|
294
|
-
var relayEntityInstances = pgTable("relay_entity_instances", {
|
|
295
|
-
tenantId: tenantId(),
|
|
296
|
-
kind: text("kind").$type().notNull(),
|
|
297
|
-
key: text("key").$type().notNull(),
|
|
298
|
-
addressId: text("address_id").$type().notNull(),
|
|
299
|
-
executionId: text("execution_id").$type().notNull(),
|
|
300
|
-
generation: integer("generation").notNull(),
|
|
301
|
-
status: text("status").$type().notNull(),
|
|
302
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
303
|
-
destroyedAt: timestamp("destroyed_at", { withTimezone: true })
|
|
304
|
-
}, (table) => [
|
|
305
|
-
primaryKey({ columns: [table.tenantId, table.kind, table.key], name: "pk_relay_entity_instances" }),
|
|
306
|
-
index("idx_relay_entity_instances_kind_status").on(table.tenantId, table.kind, table.status)
|
|
307
|
-
]);
|
|
308
|
-
var relayAddressBookEntries = pgTable("relay_address_book_entries", {
|
|
309
|
-
tenantId: tenantId(),
|
|
310
|
-
id: text("id").$type().notNull(),
|
|
311
|
-
addressId: text("address_id").$type().notNull(),
|
|
312
|
-
routeKind: text("route_kind").notNull(),
|
|
313
|
-
routeKey: text("route_key").notNull(),
|
|
314
|
-
metadataJson: jsonb("metadata_json").$type().notNull().default({}),
|
|
315
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
316
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
317
|
-
}, (table) => [
|
|
318
|
-
primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_address_book_entries" }),
|
|
319
|
-
uniqueIndex("uq_relay_address_book_address").on(table.tenantId, table.addressId)
|
|
320
|
-
]);
|
|
321
|
-
var relayAgentDefinitions = pgTable("relay_agent_definitions", {
|
|
322
|
-
tenantId: tenantId(),
|
|
323
|
-
id: text("id").$type().notNull(),
|
|
324
|
-
name: text("name").notNull(),
|
|
325
|
-
currentRevision: integer("current_revision").$type().notNull(),
|
|
326
|
-
definitionJson: jsonb("definition_json").$type().notNull(),
|
|
327
|
-
toolInputSchemaDigestsJson: jsonb("tool_input_schema_digests_json").$type().notNull().default({}),
|
|
328
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
329
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
330
|
-
}, (table) => [
|
|
331
|
-
primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_agent_definitions" }),
|
|
332
|
-
index("idx_relay_agent_definitions_name").on(table.tenantId, table.name)
|
|
333
|
-
]);
|
|
334
|
-
var relayAgentDefinitionRevisions = pgTable("relay_agent_revisions", {
|
|
335
|
-
tenantId: tenantId(),
|
|
336
|
-
agentId: text("agent_id").$type().notNull(),
|
|
337
|
-
revision: integer("revision").$type().notNull(),
|
|
338
|
-
name: text("name").notNull(),
|
|
339
|
-
definitionJson: jsonb("definition_json").$type().notNull(),
|
|
340
|
-
toolInputSchemaDigestsJson: jsonb("tool_input_schema_digests_json").$type().notNull().default({}),
|
|
341
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
342
|
-
}, (table) => [
|
|
343
|
-
primaryKey({
|
|
344
|
-
columns: [table.tenantId, table.agentId, table.revision],
|
|
345
|
-
name: "pk_relay_agent_revisions"
|
|
346
|
-
}),
|
|
347
|
-
index("idx_relay_agent_revisions_definition").on(table.tenantId, table.agentId, table.revision)
|
|
348
|
-
]);
|
|
349
|
-
var relaySkillDefinitions = pgTable("relay_skill_definitions", {
|
|
350
|
-
tenantId: tenantId(),
|
|
351
|
-
id: text("id").$type().notNull(),
|
|
352
|
-
name: text("name").notNull(),
|
|
353
|
-
currentRevision: integer("current_revision").$type().notNull(),
|
|
354
|
-
definitionJson: jsonb("definition_json").$type().notNull(),
|
|
355
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
356
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
357
|
-
}, (table) => [
|
|
358
|
-
primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_skill_definitions" }),
|
|
359
|
-
index("idx_relay_skill_definitions_name").on(table.tenantId, table.name)
|
|
360
|
-
]);
|
|
361
|
-
var relaySkillDefinitionRevisions = pgTable("relay_skill_definition_revisions", {
|
|
362
|
-
tenantId: tenantId(),
|
|
363
|
-
skillDefinitionId: text("skill_definition_id").notNull().$type(),
|
|
364
|
-
revision: integer("revision").notNull().$type(),
|
|
365
|
-
name: text("name").notNull(),
|
|
366
|
-
definitionJson: jsonb("definition_json").$type().notNull(),
|
|
367
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
368
|
-
}, (table) => [
|
|
369
|
-
primaryKey({
|
|
370
|
-
columns: [table.tenantId, table.skillDefinitionId, table.revision],
|
|
371
|
-
name: "pk_relay_skill_definition_revisions"
|
|
372
|
-
}),
|
|
373
|
-
index("idx_relay_skill_definition_revisions_definition").on(table.tenantId, table.skillDefinitionId, table.revision)
|
|
374
|
-
]);
|
|
375
|
-
var relayExecutionSkillPins = pgTable("relay_execution_skill_pins", {
|
|
376
|
-
tenantId: tenantId(),
|
|
377
|
-
executionId: text("execution_id").notNull().$type(),
|
|
378
|
-
skillDefinitionId: text("skill_definition_id").notNull().$type(),
|
|
379
|
-
skillDefinitionRevision: integer("skill_definition_revision").notNull().$type(),
|
|
380
|
-
skillDefinitionSnapshotJson: jsonb("skill_definition_snapshot_json").$type().notNull(),
|
|
381
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
382
|
-
}, (table) => [
|
|
383
|
-
primaryKey({
|
|
384
|
-
columns: [table.tenantId, table.executionId, table.skillDefinitionId],
|
|
385
|
-
name: "pk_relay_execution_skill_pins"
|
|
386
|
-
}),
|
|
387
|
-
index("idx_relay_execution_skill_pins_execution").on(table.tenantId, table.executionId)
|
|
388
|
-
]);
|
|
389
|
-
var relayAgentChats = pgTable("relay_agent_chats", {
|
|
390
|
-
tenantId: tenantId(),
|
|
391
|
-
executionId: text("execution_id").$type().notNull(),
|
|
392
|
-
exportJson: jsonb("export_json").notNull(),
|
|
393
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
394
|
-
}, (table) => [primaryKey({ columns: [table.tenantId, table.executionId], name: "pk_relay_agent_chats" })]);
|
|
395
|
-
var relayExecutionState = pgTable("relay_execution_state", {
|
|
396
|
-
tenantId: tenantId(),
|
|
397
|
-
executionId: text("execution_id").$type().notNull(),
|
|
398
|
-
key: text("state_key").notNull(),
|
|
399
|
-
valueJson: jsonb("value_json").$type().notNull(),
|
|
400
|
-
version: integer("version").notNull(),
|
|
401
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
402
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
403
|
-
}, (table) => [
|
|
404
|
-
primaryKey({ columns: [table.tenantId, table.executionId, table.key], name: "pk_relay_execution_state" })
|
|
405
|
-
]);
|
|
406
|
-
var relayExecutionStateOps = pgTable("relay_execution_state_ops", {
|
|
407
|
-
tenantId: tenantId(),
|
|
408
|
-
executionId: text("execution_id").$type().notNull(),
|
|
409
|
-
idempotencyKey: text("idempotency_key").notNull(),
|
|
410
|
-
key: text("state_key").notNull(),
|
|
411
|
-
version: integer("version").notNull(),
|
|
412
|
-
op: text("op").notNull(),
|
|
413
|
-
resultPresent: boolean("result_present").notNull(),
|
|
414
|
-
resultValueJson: jsonb("result_value_json").$type(),
|
|
415
|
-
resultCreatedAt: timestamp("result_created_at", { withTimezone: true }),
|
|
416
|
-
resultUpdatedAt: timestamp("result_updated_at", { withTimezone: true }),
|
|
417
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull()
|
|
418
|
-
}, (table) => [
|
|
419
|
-
primaryKey({
|
|
420
|
-
columns: [table.tenantId, table.executionId, table.idempotencyKey],
|
|
421
|
-
name: "pk_relay_execution_state_ops"
|
|
422
|
-
}),
|
|
423
|
-
index("idx_relay_execution_state_ops_version").on(table.tenantId, table.executionId, table.key, table.version)
|
|
424
|
-
]);
|
|
425
|
-
var relayAgentCompactions = pgTable("relay_agent_compactions", {
|
|
426
|
-
tenantId: tenantId(),
|
|
427
|
-
executionId: text("execution_id").notNull().$type(),
|
|
428
|
-
checkpointId: text("checkpoint_id").notNull(),
|
|
429
|
-
summary: text("summary").notNull(),
|
|
430
|
-
firstKeptEntryId: text("first_kept_entry_id").$type().notNull(),
|
|
431
|
-
turn: integer("turn").notNull(),
|
|
432
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
433
|
-
}, (table) => [
|
|
434
|
-
primaryKey({
|
|
435
|
-
columns: [table.tenantId, table.executionId, table.checkpointId],
|
|
436
|
-
name: "pk_relay_agent_compactions"
|
|
437
|
-
}),
|
|
438
|
-
index("idx_relay_agent_compactions_execution_turn").on(table.tenantId, table.executionId, table.turn)
|
|
439
|
-
]);
|
|
440
|
-
var relayMemoryRecords = pgTable("relay_memory_records", {
|
|
441
|
-
tenantId: tenantId(),
|
|
442
|
-
id: text("id").notNull(),
|
|
443
|
-
agent: text("agent").notNull(),
|
|
444
|
-
subject: text("subject").$type().notNull(),
|
|
445
|
-
embedding: doublePrecision("embedding").array().notNull(),
|
|
446
|
-
partsJson: jsonb("parts_json").$type().notNull(),
|
|
447
|
-
metadataJson: jsonb("metadata_json").$type().notNull().default({}),
|
|
448
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
449
|
-
}, (table) => [
|
|
450
|
-
primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_memory_records" }),
|
|
451
|
-
index("idx_relay_memory_records_agent_subject").on(table.tenantId, table.agent, table.subject)
|
|
452
|
-
]);
|
|
453
|
-
var relayPermissionRules = pgTable("relay_permission_rules", {
|
|
454
|
-
tenantId: tenantId(),
|
|
455
|
-
agent: text("agent").notNull(),
|
|
456
|
-
scope: text("scope").notNull(),
|
|
457
|
-
pattern: text("pattern").notNull(),
|
|
458
|
-
ruleJson: jsonb("rule_json").$type().notNull(),
|
|
459
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
460
|
-
}, (table) => [
|
|
461
|
-
primaryKey({
|
|
462
|
-
columns: [table.tenantId, table.agent, table.scope, table.pattern],
|
|
463
|
-
name: "pk_relay_permission_rules"
|
|
464
|
-
}),
|
|
465
|
-
index("idx_relay_permission_rules_agent_scope").on(table.tenantId, table.agent, table.scope)
|
|
466
|
-
]);
|
|
467
|
-
var relaySteeringMessages = pgTable("relay_steering_messages", {
|
|
468
|
-
tenantId: tenantId(),
|
|
469
|
-
executionId: text("execution_id").notNull(),
|
|
470
|
-
kind: text("kind").notNull(),
|
|
471
|
-
sequence: integer("sequence").notNull(),
|
|
472
|
-
contentJson: jsonb("content_json").$type().notNull(),
|
|
473
|
-
drainId: text("drain_id"),
|
|
474
|
-
consumedAt: timestamp("consumed_at", { withTimezone: true }),
|
|
475
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
476
|
-
}, (table) => [
|
|
477
|
-
primaryKey({
|
|
478
|
-
columns: [table.tenantId, table.executionId, table.kind, table.sequence],
|
|
479
|
-
name: "pk_relay_steering_messages"
|
|
480
|
-
}),
|
|
481
|
-
index("idx_relay_steering_messages_unconsumed").on(table.tenantId, table.executionId, table.kind, table.consumedAt, table.sequence),
|
|
482
|
-
index("idx_relay_steering_messages_drain").on(table.tenantId, table.executionId, table.kind, table.drainId, table.sequence)
|
|
483
|
-
]);
|
|
484
|
-
var relaySteeringDrains = pgTable("relay_steering_drains", {
|
|
485
|
-
tenantId: tenantId(),
|
|
486
|
-
executionId: text("execution_id").notNull(),
|
|
487
|
-
kind: text("kind").notNull(),
|
|
488
|
-
drainId: text("drain_id").notNull(),
|
|
489
|
-
messageSequencesJson: jsonb("message_sequences_json").$type().notNull().default([]),
|
|
490
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
491
|
-
}, (table) => [
|
|
492
|
-
primaryKey({
|
|
493
|
-
columns: [table.tenantId, table.executionId, table.kind, table.drainId],
|
|
494
|
-
name: "pk_relay_steering_drains"
|
|
495
|
-
})
|
|
496
|
-
]);
|
|
497
|
-
var relayInboxMessages = pgTable("relay_inbox_messages", {
|
|
498
|
-
tenantId: tenantId(),
|
|
499
|
-
executionId: text("execution_id").$type().notNull(),
|
|
500
|
-
sequence: integer("sequence").notNull(),
|
|
501
|
-
fromAddressId: text("from_address_id").$type().notNull(),
|
|
502
|
-
envelopeId: text("envelope_id").$type(),
|
|
503
|
-
contentJson: jsonb("content_json").$type().notNull(),
|
|
504
|
-
replyWaitId: text("reply_wait_id").$type(),
|
|
505
|
-
correlationKey: text("correlation_key"),
|
|
506
|
-
idempotencyKey: text("idempotency_key"),
|
|
507
|
-
drainId: text("drain_id"),
|
|
508
|
-
consumedAt: timestamp("consumed_at", { withTimezone: true }),
|
|
509
|
-
metadataJson: jsonb("metadata_json").$type(),
|
|
510
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
511
|
-
}, (table) => [
|
|
512
|
-
primaryKey({ columns: [table.tenantId, table.executionId, table.sequence], name: "pk_relay_inbox_messages" }),
|
|
513
|
-
uniqueIndex("uq_relay_inbox_messages_idempotency").on(table.tenantId, table.executionId, table.idempotencyKey),
|
|
514
|
-
index("idx_relay_inbox_messages_unconsumed").on(table.tenantId, table.executionId, table.consumedAt, table.sequence),
|
|
515
|
-
index("idx_relay_inbox_messages_drain").on(table.tenantId, table.executionId, table.drainId, table.sequence)
|
|
516
|
-
]);
|
|
517
|
-
var relayInboxDrains = pgTable("relay_inbox_drains", {
|
|
518
|
-
tenantId: tenantId(),
|
|
519
|
-
executionId: text("execution_id").$type().notNull(),
|
|
520
|
-
drainId: text("drain_id").notNull(),
|
|
521
|
-
messageSequencesJson: jsonb("message_sequences_json").$type().notNull().default([]),
|
|
522
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
523
|
-
}, (table) => [
|
|
524
|
-
primaryKey({ columns: [table.tenantId, table.executionId, table.drainId], name: "pk_relay_inbox_drains" })
|
|
525
|
-
]);
|
|
526
|
-
var relayTopicSubscriptions = pgTable("relay_topic_subscriptions", {
|
|
527
|
-
tenantId: tenantId(),
|
|
528
|
-
topicAddressId: text("topic_address_id").$type().notNull(),
|
|
529
|
-
subscriberExecutionId: text("subscriber_execution_id").$type().notNull(),
|
|
530
|
-
metadataJson: jsonb("metadata_json").$type(),
|
|
531
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
532
|
-
}, (table) => [
|
|
533
|
-
primaryKey({
|
|
534
|
-
columns: [table.tenantId, table.topicAddressId, table.subscriberExecutionId],
|
|
535
|
-
name: "pk_relay_topic_subscriptions"
|
|
536
|
-
}),
|
|
537
|
-
index("idx_relay_topic_subscriptions_subscriber").on(table.tenantId, table.subscriberExecutionId)
|
|
538
|
-
]);
|
|
539
|
-
var relaySessions = pgTable("relay_sessions", {
|
|
540
|
-
tenantId: tenantId(),
|
|
541
|
-
id: text("id").$type().notNull(),
|
|
542
|
-
rootAddressId: text("root_address_id").$type().notNull(),
|
|
543
|
-
leafEntryId: text("leaf_entry_id").$type(),
|
|
544
|
-
metadataJson: jsonb("metadata_json").$type().notNull().default({}),
|
|
545
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
546
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
547
|
-
}, (table) => [
|
|
548
|
-
primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_sessions" }),
|
|
549
|
-
index("idx_relay_sessions_updated_id").on(table.tenantId, table.updatedAt, table.id),
|
|
550
|
-
index("idx_relay_sessions_root_updated_id").on(table.tenantId, table.rootAddressId, table.updatedAt, table.id)
|
|
551
|
-
]);
|
|
552
|
-
var relaySessionEntries = pgTable("relay_session_entries", {
|
|
553
|
-
tenantId: tenantId(),
|
|
554
|
-
id: text("id").$type().notNull(),
|
|
555
|
-
sessionId: text("session_id").$type().notNull(),
|
|
556
|
-
parentId: text("parent_id").$type(),
|
|
557
|
-
tag: text("tag").notNull(),
|
|
558
|
-
payloadJson: jsonb("payload_json").notNull(),
|
|
559
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
560
|
-
}, (table) => [
|
|
561
|
-
primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_session_entries" }),
|
|
562
|
-
index("idx_relay_session_entries_session_created").on(table.tenantId, table.sessionId, table.createdAt, table.id),
|
|
563
|
-
index("idx_relay_session_entries_session_parent").on(table.tenantId, table.sessionId, table.parentId)
|
|
564
|
-
]);
|
|
565
|
-
var relayExecutionContextEpochs = pgTable("relay_execution_context_epochs", {
|
|
566
|
-
tenantId: tenantId(),
|
|
567
|
-
executionId: text("execution_id").$type().notNull(),
|
|
568
|
-
baseline: text("baseline").notNull(),
|
|
569
|
-
dynamicSourceIdsJson: jsonb("dynamic_source_ids_json").$type().notNull().default([]),
|
|
570
|
-
openedAt: timestamp("opened_at", { withTimezone: true }).notNull().defaultNow()
|
|
571
|
-
}, (table) => [primaryKey({ columns: [table.tenantId, table.executionId], name: "pk_relay_execution_context_epochs" })]);
|
|
572
|
-
var relayExecutions = pgTable("relay_executions", {
|
|
573
|
-
tenantId: tenantId(),
|
|
574
|
-
id: text("id").$type().notNull(),
|
|
575
|
-
rootAddressId: text("root_address_id").$type().notNull(),
|
|
576
|
-
sessionId: text("session_id").$type(),
|
|
577
|
-
status: text("status").$type().notNull(),
|
|
578
|
-
agentId: text("agent_id").$type(),
|
|
579
|
-
agentRevision: integer("agent_revision").$type(),
|
|
580
|
-
agentSnapshotJson: jsonb("agent_snapshot_json").$type(),
|
|
581
|
-
agentToolInputSchemaDigestsJson: jsonb("agent_tool_input_schema_digests_json").$type().notNull().default({}),
|
|
582
|
-
metadataJson: jsonb("metadata_json").$type().notNull().default({}),
|
|
583
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
584
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
585
|
-
}, (table) => [
|
|
586
|
-
primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_executions" }),
|
|
587
|
-
index("idx_relay_executions_root_status").on(table.tenantId, table.rootAddressId, table.status),
|
|
588
|
-
index("idx_relay_executions_session_updated_id").on(table.tenantId, table.sessionId, table.updatedAt, table.id),
|
|
589
|
-
index("idx_relay_executions_updated_id").on(table.tenantId, table.updatedAt, table.id),
|
|
590
|
-
index("idx_relay_executions_root_status_updated_id").on(table.tenantId, table.rootAddressId, table.status, table.updatedAt, table.id)
|
|
591
|
-
]);
|
|
592
|
-
var relayChildExecutions = pgTable("relay_child_executions", {
|
|
593
|
-
tenantId: tenantId(),
|
|
594
|
-
id: text("id").$type().notNull(),
|
|
595
|
-
executionId: text("execution_id").$type().notNull(),
|
|
596
|
-
addressId: text("address_id").$type().notNull(),
|
|
597
|
-
status: text("status").$type().notNull(),
|
|
598
|
-
metadataJson: jsonb("metadata_json").$type().notNull().default({}),
|
|
599
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
600
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
601
|
-
}, (table) => [
|
|
602
|
-
primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_child_executions" }),
|
|
603
|
-
index("idx_relay_child_executions_parent").on(table.tenantId, table.executionId)
|
|
604
|
-
]);
|
|
605
|
-
var relayChildFanOuts = pgTable("relay_child_fan_outs", {
|
|
606
|
-
tenantId: tenantId(),
|
|
607
|
-
id: text("id").$type().notNull(),
|
|
608
|
-
parentExecutionId: text("parent_execution_id").$type().notNull(),
|
|
609
|
-
definitionJson: jsonb("definition_json").$type().notNull(),
|
|
610
|
-
state: text("state").$type().notNull().default("joining"),
|
|
611
|
-
satisfiedAt: timestamp("satisfied_at", { withTimezone: true }),
|
|
612
|
-
failedAt: timestamp("failed_at", { withTimezone: true }),
|
|
613
|
-
cancelledAt: timestamp("cancelled_at", { withTimezone: true }),
|
|
614
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
615
|
-
}, (table) => [
|
|
616
|
-
primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_child_fan_outs" }),
|
|
617
|
-
index("idx_relay_child_fan_outs_parent").on(table.tenantId, table.parentExecutionId)
|
|
618
|
-
]);
|
|
619
|
-
var relayChildFanOutMembers = pgTable("relay_child_fan_out_members", {
|
|
620
|
-
tenantId: tenantId(),
|
|
621
|
-
fanOutId: text("fan_out_id").$type().notNull(),
|
|
622
|
-
childExecutionId: text("child_execution_id").$type().notNull(),
|
|
623
|
-
ordinal: integer("ordinal").notNull(),
|
|
624
|
-
state: text("state").$type().notNull().default("queued"),
|
|
625
|
-
outputJson: jsonb("output_json").$type(),
|
|
626
|
-
error: text("error"),
|
|
627
|
-
completedAt: timestamp("completed_at", { withTimezone: true })
|
|
628
|
-
}, (table) => [
|
|
629
|
-
primaryKey({
|
|
630
|
-
columns: [table.tenantId, table.fanOutId, table.childExecutionId],
|
|
631
|
-
name: "pk_relay_child_fan_out_members"
|
|
632
|
-
}),
|
|
633
|
-
uniqueIndex("uq_relay_child_fan_out_member_ordinal").on(table.tenantId, table.fanOutId, table.ordinal)
|
|
634
|
-
]);
|
|
635
|
-
var relayEnvelopes = pgTable("relay_envelopes", {
|
|
636
|
-
tenantId: tenantId(),
|
|
637
|
-
id: text("id").$type().notNull(),
|
|
638
|
-
executionId: text("execution_id").$type().notNull(),
|
|
639
|
-
fromAddressId: text("from_address_id").$type().notNull(),
|
|
640
|
-
toAddressId: text("to_address_id").$type().notNull(),
|
|
641
|
-
contentJson: jsonb("content_json").$type().notNull(),
|
|
642
|
-
waitJson: jsonb("wait_json").$type(),
|
|
643
|
-
correlationKey: text("correlation_key"),
|
|
644
|
-
metadataJson: jsonb("metadata_json").$type().notNull().default({}),
|
|
645
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
646
|
-
}, (table) => [
|
|
647
|
-
primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_envelopes" }),
|
|
648
|
-
index("idx_relay_envelopes_execution").on(table.tenantId, table.executionId, table.createdAt),
|
|
649
|
-
index("idx_relay_envelopes_to_address").on(table.tenantId, table.toAddressId, table.createdAt)
|
|
650
|
-
]);
|
|
651
|
-
var relayWaits = pgTable("relay_waits", {
|
|
652
|
-
tenantId: tenantId(),
|
|
653
|
-
id: text("id").$type().notNull(),
|
|
654
|
-
executionId: text("execution_id").$type().notNull(),
|
|
655
|
-
envelopeId: text("envelope_id").$type(),
|
|
656
|
-
mode: text("mode").$type().notNull(),
|
|
657
|
-
correlationKey: text("correlation_key"),
|
|
658
|
-
state: text("state").notNull().default("open"),
|
|
659
|
-
metadataJson: jsonb("metadata_json").$type().notNull().default({}),
|
|
660
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
661
|
-
resolvedAt: timestamp("resolved_at", { withTimezone: true })
|
|
662
|
-
}, (table) => [
|
|
663
|
-
primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_waits" }),
|
|
664
|
-
index("idx_relay_waits_execution_state").on(table.tenantId, table.executionId, table.state)
|
|
665
|
-
]);
|
|
666
|
-
var relayWorkspaceLeases = pgTable("relay_workspace_leases", {
|
|
667
|
-
tenantId: tenantId(),
|
|
668
|
-
id: text("id").$type().notNull(),
|
|
669
|
-
executionId: text("execution_id").$type().notNull(),
|
|
670
|
-
providerKey: text("provider_key").$type().notNull(),
|
|
671
|
-
sandboxRef: text("sandbox_ref").$type(),
|
|
672
|
-
latestSnapshotRef: text("latest_snapshot_ref").$type(),
|
|
673
|
-
status: text("status").$type().notNull(),
|
|
674
|
-
resumeStrategy: text("resume_strategy").$type().notNull(),
|
|
675
|
-
region: text("region"),
|
|
676
|
-
requestJson: jsonb("request_json").$type(),
|
|
677
|
-
metadataJson: jsonb("metadata_json").$type().notNull().default({}),
|
|
678
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
679
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
680
|
-
}, (table) => [
|
|
681
|
-
primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_workspace_leases" }),
|
|
682
|
-
uniqueIndex("uq_relay_workspace_leases_active_execution").on(table.tenantId, table.executionId).where(sql2`${table.status} not in ('released', 'failed')`),
|
|
683
|
-
index("idx_relay_workspace_leases_execution").on(table.tenantId, table.executionId),
|
|
684
|
-
index("idx_relay_workspace_leases_status_updated").on(table.tenantId, table.status, table.updatedAt)
|
|
685
|
-
]);
|
|
686
|
-
var relayWorkspaceSnapshots = pgTable("relay_workspace_snapshots", {
|
|
687
|
-
tenantId: tenantId(),
|
|
688
|
-
id: text("id").$type().notNull(),
|
|
689
|
-
leaseId: text("lease_id").$type().notNull(),
|
|
690
|
-
executionId: text("execution_id").$type().notNull(),
|
|
691
|
-
reason: text("reason").$type().notNull(),
|
|
692
|
-
snapshotRef: text("snapshot_ref").$type().notNull(),
|
|
693
|
-
metadataJson: jsonb("metadata_json").$type().notNull().default({}),
|
|
694
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
695
|
-
}, (table) => [
|
|
696
|
-
primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_workspace_snapshots" }),
|
|
697
|
-
index("idx_relay_workspace_snapshots_lease").on(table.tenantId, table.leaseId, table.createdAt),
|
|
698
|
-
index("idx_relay_workspace_snapshots_execution").on(table.tenantId, table.executionId, table.createdAt)
|
|
699
|
-
]);
|
|
700
|
-
var relayEnvelopeReady = pgTable("relay_envelope_ready", {
|
|
701
|
-
tenantId: tenantId(),
|
|
702
|
-
id: text("id").$type().notNull(),
|
|
703
|
-
envelopeId: text("envelope_id").$type().notNull(),
|
|
704
|
-
routeType: text("route_type").notNull(),
|
|
705
|
-
routeKey: text("route_key").notNull(),
|
|
706
|
-
state: text("state").notNull().default("ready"),
|
|
707
|
-
availableAt: timestamp("available_at", { withTimezone: true }).notNull().defaultNow(),
|
|
708
|
-
attempt: integer("attempt").notNull().default(0),
|
|
709
|
-
claimOwner: text("claim_owner"),
|
|
710
|
-
claimExpiresAt: timestamp("claim_expires_at", { withTimezone: true }),
|
|
711
|
-
lastError: text("last_error"),
|
|
712
|
-
idempotencyKey: text("idempotency_key"),
|
|
713
|
-
metadataJson: jsonb("metadata_json").$type().notNull().default({}),
|
|
714
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
715
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
716
|
-
claimedAt: timestamp("claimed_at", { withTimezone: true }),
|
|
717
|
-
acknowledgedAt: timestamp("acknowledged_at", { withTimezone: true })
|
|
718
|
-
}, (table) => [
|
|
719
|
-
primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_envelope_ready" }),
|
|
720
|
-
index("idx_relay_envelope_ready_state_available").on(table.tenantId, table.state, table.availableAt),
|
|
721
|
-
index("idx_relay_envelope_ready_claim_expires").on(table.tenantId, table.claimExpiresAt),
|
|
722
|
-
uniqueIndex("uq_relay_envelope_ready_idempotency").on(table.tenantId, table.idempotencyKey)
|
|
723
|
-
]);
|
|
724
|
-
var relaySchedules = pgTable("relay_schedules", {
|
|
725
|
-
tenantId: tenantId(),
|
|
726
|
-
id: text("id").$type().notNull(),
|
|
727
|
-
kind: text("kind").notNull(),
|
|
728
|
-
targetKind: text("target_kind").notNull(),
|
|
729
|
-
addressId: text("address_id").$type(),
|
|
730
|
-
waitId: text("wait_id").$type(),
|
|
731
|
-
cronExpr: text("cron_expr"),
|
|
732
|
-
inputJson: jsonb("input_json").$type(),
|
|
733
|
-
state: text("state").notNull().default("active"),
|
|
734
|
-
nextRunAt: timestamp("next_run_at", { withTimezone: true }).notNull(),
|
|
735
|
-
attempt: integer("attempt").notNull().default(0),
|
|
736
|
-
claimOwner: text("claim_owner"),
|
|
737
|
-
claimExpiresAt: timestamp("claim_expires_at", { withTimezone: true }),
|
|
738
|
-
lastError: text("last_error"),
|
|
739
|
-
idempotencyKey: text("idempotency_key"),
|
|
740
|
-
metadataJson: jsonb("metadata_json").$type().notNull().default({}),
|
|
741
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
742
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
743
|
-
}, (table) => [
|
|
744
|
-
primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_schedules" }),
|
|
745
|
-
index("idx_relay_schedules_state_next_run").on(table.tenantId, table.state, table.nextRunAt),
|
|
746
|
-
index("idx_relay_schedules_claim_expires").on(table.tenantId, table.claimExpiresAt),
|
|
747
|
-
index("idx_relay_schedules_wait").on(table.tenantId, table.waitId),
|
|
748
|
-
uniqueIndex("uq_relay_schedules_idempotency").on(table.tenantId, table.idempotencyKey)
|
|
749
|
-
]);
|
|
750
|
-
var relayExecutionEvents = pgTable("relay_execution_events", {
|
|
751
|
-
tenantId: tenantId(),
|
|
752
|
-
id: text("id").$type().notNull(),
|
|
753
|
-
executionId: text("execution_id").$type().notNull(),
|
|
754
|
-
childExecutionId: text("child_execution_id").$type(),
|
|
755
|
-
type: text("type").notNull(),
|
|
756
|
-
sequence: integer("sequence").notNull(),
|
|
757
|
-
cursor: text("cursor").notNull(),
|
|
758
|
-
contentJson: jsonb("content_json").$type(),
|
|
759
|
-
dataJson: jsonb("data_json").$type().notNull().default({}),
|
|
760
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
761
|
-
}, (table) => [
|
|
762
|
-
primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_execution_events" }),
|
|
763
|
-
index("idx_relay_execution_events_execution").on(table.tenantId, table.executionId, table.createdAt),
|
|
764
|
-
uniqueIndex("uq_relay_execution_events_sequence").on(table.tenantId, table.executionId, table.sequence),
|
|
765
|
-
uniqueIndex("uq_relay_execution_events_cursor").on(table.tenantId, table.cursor)
|
|
766
|
-
]);
|
|
767
|
-
var relayPresence = pgTable("relay_presence", {
|
|
768
|
-
tenantId: tenantId(),
|
|
769
|
-
id: text("id").notNull(),
|
|
770
|
-
scopeKind: text("scope_kind").$type().notNull(),
|
|
771
|
-
scopeId: text("scope_id").notNull(),
|
|
772
|
-
metadataJson: jsonb("metadata_json").$type().notNull().default({}),
|
|
773
|
-
connectedAt: timestamp("connected_at", { withTimezone: true }).notNull().defaultNow(),
|
|
774
|
-
expiresAt: timestamp("expires_at", { withTimezone: true }).notNull()
|
|
775
|
-
}, (table) => [
|
|
776
|
-
primaryKey({ columns: [table.tenantId, table.id, table.scopeKind, table.scopeId], name: "pk_relay_presence" }),
|
|
777
|
-
index("idx_relay_presence_scope_expires").on(table.tenantId, table.scopeKind, table.scopeId, table.expiresAt)
|
|
778
|
-
]);
|
|
779
|
-
var relayToolCalls = pgTable("relay_tool_calls", {
|
|
780
|
-
tenantId: tenantId(),
|
|
781
|
-
id: text("id").$type().notNull(),
|
|
782
|
-
executionId: text("execution_id").$type().notNull(),
|
|
783
|
-
name: text("name").notNull(),
|
|
784
|
-
inputJson: jsonb("input_json").notNull(),
|
|
785
|
-
definitionJson: jsonb("definition_json").$type(),
|
|
786
|
-
placementKind: text("placement_kind").$type().notNull().default("local"),
|
|
787
|
-
placementKey: text("placement_key"),
|
|
788
|
-
state: text("state").$type().notNull().default("requested"),
|
|
789
|
-
waitId: text("wait_id").$type(),
|
|
790
|
-
idempotencyKey: text("idempotency_key").notNull(),
|
|
791
|
-
availableAt: timestamp("available_at", { withTimezone: true }).notNull().defaultNow(),
|
|
792
|
-
activeAttemptId: text("active_attempt_id").$type(),
|
|
793
|
-
claimOwner: text("claim_owner"),
|
|
794
|
-
claimedAt: timestamp("claimed_at", { withTimezone: true }),
|
|
795
|
-
claimExpiresAt: timestamp("claim_expires_at", { withTimezone: true }),
|
|
796
|
-
externalOutcomeJson: jsonb("external_outcome_json").$type(),
|
|
797
|
-
externalOutcomeAt: timestamp("external_outcome_at", { withTimezone: true }),
|
|
798
|
-
metadataJson: jsonb("metadata_json").$type().notNull().default({}),
|
|
799
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
800
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
801
|
-
}, (table) => [
|
|
802
|
-
primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_tool_calls" }),
|
|
803
|
-
index("idx_relay_tool_calls_execution").on(table.tenantId, table.executionId, table.createdAt),
|
|
804
|
-
index("idx_relay_tool_calls_remote_claim").on(table.tenantId, table.placementKind, table.placementKey, table.state, table.availableAt, table.createdAt, table.id),
|
|
805
|
-
index("idx_relay_tool_calls_stale_claim").on(table.tenantId, table.state, table.claimExpiresAt),
|
|
806
|
-
index("idx_relay_tool_calls_client_pending").on(table.tenantId, table.placementKind, table.state, table.createdAt, table.id)
|
|
807
|
-
]);
|
|
808
|
-
var relayToolAttempts = pgTable("relay_tool_attempts", {
|
|
809
|
-
tenantId: tenantId(),
|
|
810
|
-
id: text("id").$type().notNull(),
|
|
811
|
-
toolCallId: text("tool_call_id").$type().notNull(),
|
|
812
|
-
attemptNumber: integer("attempt_number").notNull(),
|
|
813
|
-
state: text("state").$type().notNull(),
|
|
814
|
-
workerId: text("worker_id"),
|
|
815
|
-
claimExpiresAt: timestamp("claim_expires_at", { withTimezone: true }),
|
|
816
|
-
error: text("error"),
|
|
817
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
818
|
-
completedAt: timestamp("completed_at", { withTimezone: true })
|
|
819
|
-
}, (table) => [
|
|
820
|
-
primaryKey({ columns: [table.tenantId, table.toolCallId, table.id], name: "pk_relay_tool_attempts" }),
|
|
821
|
-
uniqueIndex("uq_relay_tool_attempts_number").on(table.tenantId, table.toolCallId, table.attemptNumber),
|
|
822
|
-
index("idx_relay_tool_attempts_call").on(table.tenantId, table.toolCallId, table.attemptNumber)
|
|
823
|
-
]);
|
|
824
|
-
var relayToolResults = pgTable("relay_tool_results", {
|
|
825
|
-
tenantId: tenantId(),
|
|
826
|
-
toolCallId: text("tool_call_id").$type().notNull(),
|
|
827
|
-
outputJson: jsonb("output_json").notNull(),
|
|
828
|
-
error: text("error"),
|
|
829
|
-
metadataJson: jsonb("metadata_json").$type().notNull().default({}),
|
|
830
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
831
|
-
}, (table) => [primaryKey({ columns: [table.tenantId, table.toolCallId], name: "pk_relay_tool_results" })]);
|
|
832
|
-
var relayRouteAttempts = pgTable("relay_route_attempts", {
|
|
833
|
-
tenantId: tenantId(),
|
|
834
|
-
id: text("id").notNull(),
|
|
835
|
-
envelopeReadyId: text("envelope_ready_id").$type().notNull(),
|
|
836
|
-
routeKey: text("route_key").notNull(),
|
|
837
|
-
state: text("state").notNull(),
|
|
838
|
-
detail: text("detail"),
|
|
839
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
840
|
-
}, (table) => [
|
|
841
|
-
primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_route_attempts" }),
|
|
842
|
-
index("idx_relay_route_attempts_ready").on(table.tenantId, table.envelopeReadyId, table.createdAt)
|
|
843
|
-
]);
|
|
844
|
-
var relayIdempotencyKeys = pgTable("relay_idempotency_keys", {
|
|
845
|
-
tenantId: tenantId(),
|
|
846
|
-
id: text("id").notNull(),
|
|
847
|
-
scope: text("scope").notNull(),
|
|
848
|
-
operation: text("operation").notNull(),
|
|
849
|
-
key: text("key").notNull(),
|
|
850
|
-
resultJson: jsonb("result_json").$type(),
|
|
851
|
-
metadataJson: jsonb("metadata_json").$type().notNull().default({}),
|
|
852
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
853
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
854
|
-
expiresAt: timestamp("expires_at", { withTimezone: true })
|
|
855
|
-
}, (table) => [
|
|
856
|
-
primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_idempotency_keys" }),
|
|
857
|
-
uniqueIndex("uq_relay_idempotency_scope_operation_key").on(table.tenantId, table.scope, table.operation, table.key)
|
|
858
|
-
]);
|
|
859
|
-
// src/database.ts
|
|
860
|
-
var Service4 = exports_database_service.Service;
|
|
861
|
-
var PgClientLive2 = exports_database_service.PgClientLive;
|
|
862
|
-
var layerFromPgClient2 = exports_database_service.layerFromPgClient;
|
|
863
|
-
var testLayer3 = exports_database_service.testLayer;
|
|
864
|
-
var check2 = exports_database_service.check;
|
|
865
|
-
var pgTypeParsers2 = exports_database_service.pgTypeParsers;
|
|
866
|
-
var Dialect2 = exports_database_service.Dialect;
|
|
867
|
-
var dialect2 = exports_database_service.dialect;
|
|
868
97
|
// src/tool-worker.ts
|
|
869
98
|
var exports_tool_worker = {};
|
|
870
99
|
__export(exports_tool_worker, {
|
|
871
100
|
runOnce: () => runOnce,
|
|
872
101
|
run: () => run
|
|
873
102
|
});
|
|
874
|
-
import { Clock, Duration, Effect as
|
|
103
|
+
import { Clock, Duration, Effect as Effect2 } from "effect";
|
|
875
104
|
var failureMessage = (error) => error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
876
105
|
var handlerOutcome = (options, lease) => {
|
|
877
106
|
const handler = Object.hasOwn(options.handlers, lease.call.name) ? options.handlers[lease.call.name] : undefined;
|
|
878
107
|
if (typeof handler !== "function") {
|
|
879
|
-
return
|
|
108
|
+
return Effect2.succeed({ kind: "failure", message: `No remote handler registered for ${lease.call.name}` });
|
|
880
109
|
}
|
|
881
|
-
return handler(lease.call.input, { lease, idempotencyKey: lease.idempotency_key }).pipe(
|
|
110
|
+
return handler(lease.call.input, { lease, idempotencyKey: lease.idempotency_key }).pipe(Effect2.match({
|
|
882
111
|
onFailure: (error) => ({ kind: "failure", message: failureMessage(error) }),
|
|
883
112
|
onSuccess: (output) => ({ kind: "success", output })
|
|
884
113
|
}));
|
|
885
114
|
};
|
|
886
|
-
var runOnce =
|
|
115
|
+
var runOnce = Effect2.fn("ToolWorker.runOnce")(function* (options) {
|
|
887
116
|
const client = yield* Service;
|
|
888
117
|
const now = yield* Clock.currentTimeMillis;
|
|
889
118
|
const leaseMillis = Duration.toMillis(Duration.fromInputUnsafe(options.leaseDuration));
|
|
@@ -906,65 +135,307 @@ var runOnce = Effect3.fn("ToolWorker.runOnce")(function* (options) {
|
|
|
906
135
|
});
|
|
907
136
|
return true;
|
|
908
137
|
});
|
|
909
|
-
var run =
|
|
138
|
+
var run = Effect2.fn("ToolWorker.run")(function* (options) {
|
|
910
139
|
const pollInterval = Duration.fromInputUnsafe(options.pollInterval ?? "1 second");
|
|
911
|
-
return yield* runOnce(options).pipe(
|
|
140
|
+
return yield* runOnce(options).pipe(Effect2.flatMap((worked) => worked ? Effect2.void : Effect2.sleep(pollInterval)), Effect2.forever);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// src/language-model-registration.ts
|
|
144
|
+
var exports_language_model_registration = {};
|
|
145
|
+
__export(exports_language_model_registration, {
|
|
146
|
+
withOpenRouterFetch: () => withOpenRouterFetch,
|
|
147
|
+
withOpenRouter: () => withOpenRouter,
|
|
148
|
+
withOpenAiOrDeterministicFetch: () => withOpenAiOrDeterministicFetch,
|
|
149
|
+
withOpenAiOrDeterministic: () => withOpenAiOrDeterministic,
|
|
150
|
+
withOpenAiFetch: () => withOpenAiFetch,
|
|
151
|
+
withOpenAiCompatibleFetch: () => withOpenAiCompatibleFetch,
|
|
152
|
+
withOpenAiCompatible: () => withOpenAiCompatible,
|
|
153
|
+
withOpenAiAccountFetch: () => withOpenAiAccountFetch,
|
|
154
|
+
withOpenAiAccount: () => withOpenAiAccount,
|
|
155
|
+
withOpenAi: () => withOpenAi,
|
|
156
|
+
withDeterministic: () => withDeterministic,
|
|
157
|
+
withAnthropicFetch: () => withAnthropicFetch,
|
|
158
|
+
withAnthropic: () => withAnthropic,
|
|
159
|
+
openRouterClientLayerConfig: () => openRouterClientLayerConfig,
|
|
160
|
+
openRouter: () => openRouter,
|
|
161
|
+
openAiCompatibleClientLayerConfig: () => openAiCompatibleClientLayerConfig,
|
|
162
|
+
openAiCompatible: () => openAiCompatible,
|
|
163
|
+
openAiClientLayerConfig: () => openAiClientLayerConfig,
|
|
164
|
+
openAiAccount: () => openAiAccount,
|
|
165
|
+
openAi: () => openAi,
|
|
166
|
+
deterministicModel: () => deterministicModel2,
|
|
167
|
+
anthropicClientLayerConfig: () => anthropicClientLayerConfig,
|
|
168
|
+
anthropic: () => anthropic,
|
|
169
|
+
OpenAiAccountCredentialError: () => OpenAiAccountCredentialError
|
|
912
170
|
});
|
|
913
171
|
|
|
172
|
+
// ../../node_modules/.bun/@batonfx+providers@0.6.1/node_modules/@batonfx/providers/dist/deterministic.js
|
|
173
|
+
import { OpenAiClient as OpenAiClient2 } from "@effect/ai-openai";
|
|
174
|
+
import { Config as Config2, Effect as Effect4, Layer as Layer3, Option, Stream as Stream2 } from "effect";
|
|
175
|
+
import { LanguageModel, Response } from "effect/unstable/ai";
|
|
176
|
+
import { FetchHttpClient as FetchHttpClient2 } from "effect/unstable/http";
|
|
177
|
+
|
|
178
|
+
// ../../node_modules/.bun/@batonfx+providers@0.6.1/node_modules/@batonfx/providers/dist/openai.js
|
|
179
|
+
import { OpenAiClient, OpenAiLanguageModel } from "@effect/ai-openai";
|
|
180
|
+
import { Config, Effect as Effect3, Layer as Layer2, Redacted, Schema, Stream } from "effect";
|
|
181
|
+
import { AiError } from "effect/unstable/ai";
|
|
182
|
+
import { FetchHttpClient, Headers, HttpClient, HttpClientError, HttpClientRequest } from "effect/unstable/http";
|
|
183
|
+
var openAiAccountApiUrl = "https://chatgpt.com/backend-api/codex";
|
|
184
|
+
var openAiAccountResponsesUrl = `${openAiAccountApiUrl}/responses`;
|
|
185
|
+
var openAiAccountIdHeader = "ChatGPT-Account-ID";
|
|
186
|
+
var contextOverflowCodes = new Set(["context_length_exceeded", "context_window_exceeded", "input_too_long"]);
|
|
187
|
+
var classifyFailure = (error) => {
|
|
188
|
+
if (!AiError.isAiError(error))
|
|
189
|
+
return "other";
|
|
190
|
+
const reason = error.reason;
|
|
191
|
+
if (reason._tag !== "InvalidRequestError" && reason._tag !== "UnknownError")
|
|
192
|
+
return "other";
|
|
193
|
+
const metadata = reason.metadata.openai;
|
|
194
|
+
if (metadata !== null && metadata !== undefined) {
|
|
195
|
+
if (metadata.errorCode !== null && contextOverflowCodes.has(metadata.errorCode) || metadata.errorType !== null && contextOverflowCodes.has(metadata.errorType)) {
|
|
196
|
+
return "context-overflow";
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return reason._tag === "InvalidRequestError" && /maximum context length|context length exceeded|input exceeds (?:the )?context window/i.test(reason.description ?? "") ? "context-overflow" : "other";
|
|
200
|
+
};
|
|
201
|
+
var openAi = (input) => exports_model_registry.registrationFromLayer({
|
|
202
|
+
provider: "openai",
|
|
203
|
+
model: input.model,
|
|
204
|
+
layer: OpenAiLanguageModel.layer({
|
|
205
|
+
model: input.model,
|
|
206
|
+
...input.config === undefined ? {} : { config: input.config }
|
|
207
|
+
}),
|
|
208
|
+
classifyFailure,
|
|
209
|
+
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
210
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
211
|
+
});
|
|
212
|
+
var openAiClientLayerConfig = OpenAiClient.layerConfig;
|
|
213
|
+
var withOpenAi = (options) => exports_model_registry.layerFromRegistrationEffects([openAi(options)]).pipe(Layer2.provide(OpenAiClient.layerConfig({ ...options.clientConfig, apiKey: options.apiKey })));
|
|
214
|
+
var withOpenAiFetch = (options) => withOpenAi(options).pipe(Layer2.provide(FetchHttpClient.layer));
|
|
215
|
+
|
|
216
|
+
class OpenAiAccountCredentialError extends Schema.TaggedErrorClass()("@batonfx/providers/OpenAiAccountCredentialError", {
|
|
217
|
+
operation: Schema.Literals(["acquire", "refreshRejected"])
|
|
218
|
+
}) {
|
|
219
|
+
}
|
|
220
|
+
var credentialFailure = (request, error) => new HttpClientError.HttpClientError({
|
|
221
|
+
reason: new HttpClientError.TransportError({
|
|
222
|
+
request,
|
|
223
|
+
cause: error,
|
|
224
|
+
description: `OpenAI account credential ${error.operation} failed`
|
|
225
|
+
})
|
|
226
|
+
});
|
|
227
|
+
var withCredential = (request, credential) => {
|
|
228
|
+
const body = request.body;
|
|
229
|
+
const streaming = body._tag === "Uint8Array" && body.contentType === "application/json" && new TextDecoder().decode(body.body).includes('"stream":true');
|
|
230
|
+
return request.pipe(HttpClientRequest.setUrl(openAiAccountResponsesUrl), HttpClientRequest.bearerToken(credential.accessToken), HttpClientRequest.setHeader(openAiAccountIdHeader, credential.accountId), HttpClientRequest.accept(streaming ? "text/event-stream" : "application/json"));
|
|
231
|
+
};
|
|
232
|
+
var executeWithCredential = (client, request, credential) => client.postprocess(Effect3.succeed(withCredential(request, credential))).pipe(Effect3.provideService(FetchHttpClient.RequestInit, { redirect: "error" }), Effect3.updateService(Headers.CurrentRedactedNames, (names) => [...names, openAiAccountIdHeader]));
|
|
233
|
+
var accountClientTransform = (credentials) => (client) => HttpClient.transform(client, (_, request) => credentials.acquire.pipe(Effect3.mapError((error) => credentialFailure(request, error)), Effect3.flatMap((credential) => executeWithCredential(client, request, credential).pipe(Effect3.catchIf((error) => error.reason._tag === "StatusCodeError" && error.reason.response.status === 401, (error) => {
|
|
234
|
+
if (error.reason._tag !== "StatusCodeError")
|
|
235
|
+
return Effect3.fail(error);
|
|
236
|
+
return Stream.runDrain(error.reason.response.stream).pipe(Effect3.ignore, Effect3.andThen(credentials.refreshRejected(credential.generation)), Effect3.mapError((credentialError) => credentialFailure(request, credentialError)), Effect3.flatMap((refreshed) => executeWithCredential(client, request, refreshed)));
|
|
237
|
+
})))));
|
|
238
|
+
var withAccountHeaderRedaction = (effect) => effect.pipe(Effect3.updateService(Headers.CurrentRedactedNames, (names) => [...names, openAiAccountIdHeader]));
|
|
239
|
+
var withoutOpenAiSocket = (effect) => effect.pipe(Effect3.provideService(OpenAiClient.OpenAiSocket, null));
|
|
240
|
+
var openAiAccountClientLayer = (credentials) => Layer2.effect(OpenAiClient.OpenAiClient, OpenAiClient.make({
|
|
241
|
+
apiUrl: openAiAccountApiUrl,
|
|
242
|
+
transformClient: accountClientTransform(credentials)
|
|
243
|
+
}).pipe(Effect3.map((client) => OpenAiClient.OpenAiClient.of({
|
|
244
|
+
client: client.client,
|
|
245
|
+
createResponse: (options) => withAccountHeaderRedaction(client.createResponse(options)),
|
|
246
|
+
createResponseStream: (options) => client.createResponseStream(options).pipe(withoutOpenAiSocket, withAccountHeaderRedaction, Effect3.map(([response, stream]) => [
|
|
247
|
+
response,
|
|
248
|
+
stream.pipe(Stream.updateService(Headers.CurrentRedactedNames, (names) => [...names, openAiAccountIdHeader]))
|
|
249
|
+
])),
|
|
250
|
+
createEmbedding: (options) => withAccountHeaderRedaction(client.createEmbedding(options))
|
|
251
|
+
}))));
|
|
252
|
+
var openAiAccount = (input) => exports_model_registry.registrationFromLayer({
|
|
253
|
+
provider: "openai",
|
|
254
|
+
model: input.model,
|
|
255
|
+
layer: OpenAiLanguageModel.layer({
|
|
256
|
+
model: input.model,
|
|
257
|
+
...input.config === undefined ? {} : { config: input.config }
|
|
258
|
+
}).pipe(Layer2.provide(openAiAccountClientLayer(input.credentials))),
|
|
259
|
+
classifyFailure,
|
|
260
|
+
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
261
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
262
|
+
});
|
|
263
|
+
var withOpenAiAccount = (input) => exports_model_registry.layerFromRegistrationEffects([openAiAccount(input)]);
|
|
264
|
+
var withOpenAiAccountFetch = (input) => withOpenAiAccount(input).pipe(Layer2.provide(FetchHttpClient.layer));
|
|
265
|
+
|
|
266
|
+
// ../../node_modules/.bun/@batonfx+providers@0.6.1/node_modules/@batonfx/providers/dist/deterministic.js
|
|
267
|
+
var deterministicModelLayer = Layer3.effect(LanguageModel.LanguageModel, LanguageModel.make({
|
|
268
|
+
generateText: () => Effect4.succeed([{ type: "text", text: "deterministic response" }]),
|
|
269
|
+
streamText: () => Stream2.make(Response.makePart("text-delta", { id: "text", delta: "deterministic response" }))
|
|
270
|
+
}));
|
|
271
|
+
var deterministicModel = (input = {}) => exports_model_registry.registrationFromLayer({
|
|
272
|
+
provider: input.provider ?? "deterministic",
|
|
273
|
+
model: input.model ?? "deterministic",
|
|
274
|
+
layer: deterministicModelLayer,
|
|
275
|
+
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
276
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
277
|
+
});
|
|
278
|
+
var withDeterministic = (input = {}) => exports_model_registry.layerFromRegistrationEffects([deterministicModel(input)]);
|
|
279
|
+
var withOpenAiOrDeterministic = (options) => Layer3.unwrap(Effect4.gen(function* () {
|
|
280
|
+
const deterministic = yield* deterministicModel({
|
|
281
|
+
provider: options.fallbackProvider ?? "deterministic",
|
|
282
|
+
model: options.fallbackModel
|
|
283
|
+
});
|
|
284
|
+
const configuredApiKey = yield* Config2.option(options.apiKey);
|
|
285
|
+
const openAiRegistration = yield* Option.match(configuredApiKey, {
|
|
286
|
+
onNone: () => Effect4.succeedNone,
|
|
287
|
+
onSome: (apiKey) => Layer3.build(OpenAiClient2.layerConfig({
|
|
288
|
+
...options.clientConfig,
|
|
289
|
+
apiKey: Config2.succeed(apiKey)
|
|
290
|
+
})).pipe(Effect4.flatMap((context) => openAi(options).pipe(Effect4.provide(context))), Effect4.asSome)
|
|
291
|
+
});
|
|
292
|
+
return exports_model_registry.layer([
|
|
293
|
+
deterministic,
|
|
294
|
+
...Option.isSome(openAiRegistration) ? [openAiRegistration.value] : []
|
|
295
|
+
]);
|
|
296
|
+
}));
|
|
297
|
+
var withOpenAiOrDeterministicFetch = (options) => withOpenAiOrDeterministic(options).pipe(Layer3.provide(FetchHttpClient2.layer));
|
|
298
|
+
|
|
299
|
+
// ../../node_modules/.bun/@batonfx+providers@0.6.1/node_modules/@batonfx/providers/dist/anthropic.js
|
|
300
|
+
import { AnthropicClient, AnthropicLanguageModel } from "@effect/ai-anthropic";
|
|
301
|
+
import { Config as Config3, Layer as Layer4, Redacted as Redacted2 } from "effect";
|
|
302
|
+
import { AiError as AiError2 } from "effect/unstable/ai";
|
|
303
|
+
import { FetchHttpClient as FetchHttpClient3 } from "effect/unstable/http";
|
|
304
|
+
var classifyFailure2 = (error) => {
|
|
305
|
+
if (!AiError2.isAiError(error) || error.reason._tag !== "InvalidRequestError")
|
|
306
|
+
return "other";
|
|
307
|
+
const metadata = error.reason.metadata.anthropic;
|
|
308
|
+
return metadata?.errorType === "invalid_request_error" && /\bprompt is too long\b/i.test(error.reason.description ?? "") ? "context-overflow" : "other";
|
|
309
|
+
};
|
|
310
|
+
var anthropic = (input) => exports_model_registry.registrationFromLayer({
|
|
311
|
+
provider: "anthropic",
|
|
312
|
+
model: input.model,
|
|
313
|
+
layer: AnthropicLanguageModel.layer({
|
|
314
|
+
model: input.model,
|
|
315
|
+
...input.config === undefined ? {} : { config: input.config }
|
|
316
|
+
}),
|
|
317
|
+
classifyFailure: classifyFailure2,
|
|
318
|
+
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
319
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
320
|
+
});
|
|
321
|
+
var anthropicClientLayerConfig = AnthropicClient.layerConfig;
|
|
322
|
+
var withAnthropic = (options) => exports_model_registry.layerFromRegistrationEffects([anthropic(options)]).pipe(Layer4.provide(AnthropicClient.layerConfig({ ...options.clientConfig, apiKey: options.apiKey })));
|
|
323
|
+
var withAnthropicFetch = (options) => withAnthropic(options).pipe(Layer4.provide(FetchHttpClient3.layer));
|
|
324
|
+
// ../../node_modules/.bun/@batonfx+providers@0.6.1/node_modules/@batonfx/providers/dist/openai-compat.js
|
|
325
|
+
import { OpenAiClient as OpenAiClient3, OpenAiLanguageModel as OpenAiLanguageModel2 } from "@effect/ai-openai-compat";
|
|
326
|
+
import { Config as Config4, Layer as Layer5, Redacted as Redacted3 } from "effect";
|
|
327
|
+
import { FetchHttpClient as FetchHttpClient4 } from "effect/unstable/http";
|
|
328
|
+
var openAiCompatible = (input) => exports_model_registry.registrationFromLayer({
|
|
329
|
+
provider: input.provider ?? "openai-compatible",
|
|
330
|
+
model: input.model,
|
|
331
|
+
layer: OpenAiLanguageModel2.layer({
|
|
332
|
+
model: input.model,
|
|
333
|
+
...input.config === undefined ? {} : { config: input.config }
|
|
334
|
+
}),
|
|
335
|
+
...input.classifyFailure === undefined ? {} : { classifyFailure: input.classifyFailure },
|
|
336
|
+
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
337
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
338
|
+
});
|
|
339
|
+
var openAiCompatibleClientLayerConfig = OpenAiClient3.layerConfig;
|
|
340
|
+
var clientLayerConfig = (options) => OpenAiClient3.layerConfig({
|
|
341
|
+
...options.clientConfig,
|
|
342
|
+
...options.apiKey === undefined ? {} : { apiKey: options.apiKey },
|
|
343
|
+
...options.baseUrl === undefined ? {} : { apiUrl: Config4.succeed(options.baseUrl) }
|
|
344
|
+
});
|
|
345
|
+
var withOpenAiCompatible = (options) => exports_model_registry.layerFromRegistrationEffects([openAiCompatible(options)]).pipe(Layer5.provide(clientLayerConfig(options)));
|
|
346
|
+
var withOpenAiCompatibleFetch = (options) => withOpenAiCompatible(options).pipe(Layer5.provide(FetchHttpClient4.layer));
|
|
347
|
+
// ../../node_modules/.bun/@batonfx+providers@0.6.1/node_modules/@batonfx/providers/dist/openrouter.js
|
|
348
|
+
import { OpenRouterClient, OpenRouterLanguageModel } from "@effect/ai-openrouter";
|
|
349
|
+
import { Config as Config5, Layer as Layer6, Redacted as Redacted4 } from "effect";
|
|
350
|
+
import { AiError as AiError3 } from "effect/unstable/ai";
|
|
351
|
+
import { FetchHttpClient as FetchHttpClient5 } from "effect/unstable/http";
|
|
352
|
+
var contextOverflowCodes2 = new Set(["context_length_exceeded", "context_window_exceeded", "input_too_long"]);
|
|
353
|
+
var classifyFailure3 = (error) => {
|
|
354
|
+
if (!AiError3.isAiError(error))
|
|
355
|
+
return "other";
|
|
356
|
+
const reason = error.reason;
|
|
357
|
+
if (reason._tag !== "InvalidRequestError" && reason._tag !== "UnknownError")
|
|
358
|
+
return "other";
|
|
359
|
+
const metadata = reason.metadata.openrouter;
|
|
360
|
+
if (metadata !== null && metadata !== undefined) {
|
|
361
|
+
if (typeof metadata.errorCode === "string" && contextOverflowCodes2.has(metadata.errorCode) || metadata.errorType !== null && contextOverflowCodes2.has(metadata.errorType)) {
|
|
362
|
+
return "context-overflow";
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return reason._tag === "InvalidRequestError" && /maximum context length|context length exceeded|input exceeds (?:the )?context window|prompt is too long/i.test(reason.description ?? "") ? "context-overflow" : "other";
|
|
366
|
+
};
|
|
367
|
+
var openRouter = (input) => exports_model_registry.registrationFromLayer({
|
|
368
|
+
provider: "openrouter",
|
|
369
|
+
model: input.model,
|
|
370
|
+
layer: OpenRouterLanguageModel.layer({
|
|
371
|
+
model: input.model,
|
|
372
|
+
...input.config === undefined ? {} : { config: input.config }
|
|
373
|
+
}),
|
|
374
|
+
classifyFailure: classifyFailure3,
|
|
375
|
+
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
376
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
377
|
+
});
|
|
378
|
+
var openRouterClientLayerConfig = OpenRouterClient.layerConfig;
|
|
379
|
+
var withOpenRouter = (options) => exports_model_registry.layerFromRegistrationEffects([openRouter(options)]).pipe(Layer6.provide(OpenRouterClient.layerConfig({ ...options.clientConfig, apiKey: options.apiKey })));
|
|
380
|
+
var withOpenRouterFetch = (options) => withOpenRouter(options).pipe(Layer6.provide(FetchHttpClient5.layer));
|
|
381
|
+
|
|
382
|
+
// src/language-model-registration.ts
|
|
383
|
+
var deterministicModel2 = (input) => deterministicModel(input);
|
|
384
|
+
|
|
914
385
|
// src/index.ts
|
|
915
|
-
var
|
|
386
|
+
var AdapterOutbox = exports_adapter_outbox;
|
|
387
|
+
var Client = exports_client_public;
|
|
388
|
+
var ChildFanOutHost = exports_child_fan_out_host;
|
|
389
|
+
var Command = exports_command;
|
|
390
|
+
var Operation = exports_operation;
|
|
391
|
+
var ToolWorker = exports_tool_worker;
|
|
392
|
+
var Runtime = exports_runtime;
|
|
393
|
+
var WorkflowDefinitionHost = exports_workflow_definition_host;
|
|
394
|
+
var ArtifactStore = exports_artifact_store_service;
|
|
395
|
+
var BlobStore = exports_blob_store_service;
|
|
396
|
+
var EmbeddingModelService = exports_embedding_model_service;
|
|
397
|
+
var LanguageModelService = exports_language_model_service;
|
|
398
|
+
var ModelHub = exports_model_hub;
|
|
399
|
+
var PromptAssembler = exports_prompt_assembler_service;
|
|
400
|
+
var SchemaRegistry = exports_schema_registry_service;
|
|
401
|
+
var ToolRuntime = exports_tool_runtime;
|
|
402
|
+
var LanguageModelRegistration = exports_language_model_registration;
|
|
916
403
|
export {
|
|
917
|
-
relayPackage,
|
|
918
404
|
makeDatabaseIdentity,
|
|
919
|
-
|
|
405
|
+
WorkflowDefinitionHost,
|
|
920
406
|
exports_workflow_schema as Workflow,
|
|
921
407
|
exports_wait_schema as Waits,
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
exports_tool_runtime_service as ToolRuntime,
|
|
408
|
+
ToolWorker,
|
|
409
|
+
ToolRuntime,
|
|
925
410
|
exports_tool_schema as Tool,
|
|
926
|
-
|
|
927
|
-
exports_skill_definition_repository as SkillDefinitionRepository,
|
|
411
|
+
exports_state_schema as State,
|
|
928
412
|
exports_skill_schema as Skill,
|
|
929
413
|
exports_shared_schema as Shared,
|
|
930
|
-
|
|
931
|
-
exports_scheduler_service as SchedulerService,
|
|
414
|
+
SchemaRegistry,
|
|
932
415
|
exports_schedule_schema as Schedule,
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
exports_relay_schema as RelaySchema,
|
|
936
|
-
exports_prompt_assembler_service as PromptAssembler,
|
|
937
|
-
exports_presence_tool as PresenceTool,
|
|
938
|
-
exports_presence_service as PresenceService,
|
|
416
|
+
Runtime,
|
|
417
|
+
PromptAssembler,
|
|
939
418
|
exports_presence_schema as Presence,
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
419
|
+
exports_pagination_schema as Pagination,
|
|
420
|
+
Operation,
|
|
421
|
+
ModelHub,
|
|
422
|
+
LanguageModelService,
|
|
423
|
+
LanguageModelRegistration,
|
|
424
|
+
exports_inbox_schema as Inbox,
|
|
944
425
|
exports_ids_schema as Ids,
|
|
945
|
-
exports_execution_workflow as ExecutionWorkflow,
|
|
946
|
-
exports_execution_service as ExecutionService,
|
|
947
|
-
exports_execution_entity as ExecutionEntity,
|
|
948
426
|
exports_execution_schema as Execution,
|
|
949
|
-
exports_event_log_service as EventLog,
|
|
950
|
-
exports_envelope_service as EnvelopeService,
|
|
951
427
|
exports_envelope_schema as Envelope,
|
|
952
428
|
exports_entity_schema as Entity,
|
|
953
|
-
|
|
954
|
-
|
|
429
|
+
EmbeddingModelService,
|
|
430
|
+
DatabaseIdentity,
|
|
955
431
|
exports_content_schema as Content,
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
exports_agent_registry_service as AgentRegistry,
|
|
963
|
-
exports_agent_loop_service as AgentLoop,
|
|
432
|
+
Command,
|
|
433
|
+
Client,
|
|
434
|
+
exports_child_orchestration_schema as ChildOrchestration,
|
|
435
|
+
ChildFanOutHost,
|
|
436
|
+
BlobStore,
|
|
437
|
+
ArtifactStore,
|
|
964
438
|
exports_agent_schema as Agent,
|
|
965
|
-
exports_address_resolution_service as AddressResolution,
|
|
966
|
-
exports_address_book_service as AddressBook,
|
|
967
439
|
exports_address_schema as Address,
|
|
968
|
-
|
|
969
|
-
exports_activity_version_registry as ActivityVersionRegistry
|
|
440
|
+
AdapterOutbox
|
|
970
441
|
};
|