@relayfx/sdk 0.7.9 → 0.7.11
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 +1 -1
- package/dist/http-server.js +1 -1
- package/dist/{index-0gd9t134.js → index-d1je4njg.js} +4089 -3765
- package/dist/{index-72hhs3mp.js → index-d5563j6w.js} +46 -46
- package/dist/{index-nb078xsy.js → index-j8k41y47.js} +26 -4
- package/dist/{index-qjad95s5.js → index-skcp0xvt.js} +1 -1
- package/dist/index.js +11 -11
- package/dist/migrations/20260723190000_transactional_event_head/migration.sql +22 -0
- package/dist/migrations/20260724010000_execution_event_archive_manifests/migration.sql +66 -0
- package/dist/migrations/20260724120000_execution_event_identity_directory/migration.sql +15 -0
- package/dist/migrations/20260724230000_idempotent_steering/migration.sql +7 -0
- package/dist/migrations/mysql/0015_transactional_event_head.sql +32 -0
- package/dist/migrations/mysql/0016_execution_event_archive_manifests.sql +65 -0
- package/dist/migrations/mysql/0017_execution_event_identity_directory.sql +20 -0
- package/dist/migrations/mysql/0018_idempotent_steering.sql +7 -0
- package/dist/migrations/pg/20260723190000_transactional_event_head/migration.sql +22 -0
- package/dist/migrations/pg/20260724010000_execution_event_archive_manifests/migration.sql +66 -0
- package/dist/migrations/pg/20260724120000_execution_event_identity_directory/migration.sql +15 -0
- package/dist/migrations/pg/20260724230000_idempotent_steering/migration.sql +7 -0
- package/dist/migrations/sqlite/0015_transactional_event_head.sql +22 -0
- package/dist/migrations/sqlite/0016_execution_event_archive_manifests.sql +45 -0
- package/dist/migrations/sqlite/0017_execution_event_identity_directory.sql +13 -0
- package/dist/migrations/sqlite/0018_idempotent_steering.sql +5 -0
- package/dist/mysql.js +50 -9
- package/dist/postgres.js +136 -14
- package/dist/sqlite.js +116 -5
- package/dist/types/relay/client-public-executions.d.ts +1 -1
- package/dist/types/relay/client-public.d.ts +2 -2
- package/dist/types/relay/http-server.d.ts +2 -2
- package/dist/types/relay/mysql-migrations.d.ts +1 -1
- package/dist/types/relay/operation.d.ts +9 -0
- package/dist/types/relay/sqlite-migrations.d.ts +21 -1
- package/dist/types/runtime/agent/agent-loop-events.d.ts +10 -9
- package/dist/types/runtime/agent/agent-loop-service.d.ts +1 -0
- package/dist/types/runtime/agent/emission-ordinal-allocator.d.ts +7 -0
- package/dist/types/runtime/agent/relay-permissions.d.ts +4 -7
- package/dist/types/runtime/agent/relay-steering.d.ts +5 -5
- package/dist/types/runtime/agent/relay-tool-executor.d.ts +3 -2
- package/dist/types/runtime/envelope/envelope-service.d.ts +2 -1
- package/dist/types/runtime/execution/event-log-service.d.ts +5 -4
- package/dist/types/runtime/execution/execution-service.d.ts +1 -1
- package/dist/types/runtime/inbox/inbox-service.d.ts +6 -6
- package/dist/types/runtime/schedule/scheduler-service.d.ts +3 -4
- package/dist/types/runtime/state/execution-state-service.d.ts +2 -2
- package/dist/types/runtime/tool/tool-runtime-contract.d.ts +2 -0
- package/dist/types/runtime/tool/tool-runtime-identifiers.d.ts +6 -0
- package/dist/types/runtime/wait/wait-service.d.ts +5 -5
- package/dist/types/runtime/workflow/execution-workflow.d.ts +2 -3
- package/dist/types/runtime/workspace/workspace-planner-service.d.ts +2 -0
- package/dist/types/schema/workflow-schema.d.ts +1 -0
- package/dist/types/store-sql/execution/archive-compression.d.ts +11 -0
- package/dist/types/store-sql/execution/event-history-file-system.d.ts +7 -0
- package/dist/types/store-sql/execution/event-history-store.d.ts +93 -0
- package/dist/types/store-sql/execution/execution-event-archive-codec.d.ts +69 -0
- package/dist/types/store-sql/execution/execution-event-archive-repository-memory.d.ts +28 -0
- package/dist/types/store-sql/execution/execution-event-archive-repository-sql.d.ts +19 -0
- package/dist/types/store-sql/execution/execution-event-archive-repository.d.ts +175 -0
- package/dist/types/store-sql/execution/execution-event-head-memory.d.ts +13 -0
- package/dist/types/store-sql/execution/execution-event-head.d.ts +40 -0
- package/dist/types/store-sql/execution/execution-event-identity-directory.d.ts +26 -0
- package/dist/types/store-sql/execution/execution-event-repository-archive-aware.d.ts +7 -0
- package/dist/types/store-sql/execution/execution-event-repository-memory.d.ts +6 -1
- package/dist/types/store-sql/execution/execution-event-repository.d.ts +6 -4
- package/dist/types/store-sql/inbox/inbox-repository.d.ts +6 -2
- package/dist/types/store-sql/schema/communication-schema.d.ts +15 -0
- package/dist/types/store-sql/schema/execution-schema.d.ts +583 -0
- package/dist/types/store-sql/schema/relay-schema.d.ts +1 -1
- package/dist/types/store-sql/state/execution-state-repository.d.ts +2 -1
- package/dist/types/store-sql/steering/steering-model.d.ts +60 -0
- package/dist/types/store-sql/steering/steering-repository.d.ts +5 -50
- package/package.json +5 -5
- package/dist/types/relay/client-event-sequence.d.ts +0 -3
- package/dist/types/runtime/agent/sequence-allocator.d.ts +0 -9
package/dist/postgres.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
database,
|
|
4
4
|
normalizeMigrationCause
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-skcp0xvt.js";
|
|
6
6
|
import {
|
|
7
7
|
Dialect,
|
|
8
8
|
RuntimeMigrationError,
|
|
@@ -14,11 +14,11 @@ import {
|
|
|
14
14
|
fromDbTimestamp,
|
|
15
15
|
fromNullableDbTimestamp,
|
|
16
16
|
timestampParam
|
|
17
|
-
} from "./index-
|
|
18
|
-
import"./index-
|
|
17
|
+
} from "./index-d1je4njg.js";
|
|
18
|
+
import"./index-d5563j6w.js";
|
|
19
19
|
import {
|
|
20
20
|
exports_ids_schema
|
|
21
|
-
} from "./index-
|
|
21
|
+
} from "./index-j8k41y47.js";
|
|
22
22
|
import {
|
|
23
23
|
__export
|
|
24
24
|
} from "./index-nb39b5ae.js";
|
|
@@ -294,7 +294,21 @@ var relayPermissionRules = pgTable4("relay_permission_rules", {
|
|
|
294
294
|
index2("idx_relay_permission_rules_agent_scope").on(table.tenantId, table.agent, table.scope)
|
|
295
295
|
]);
|
|
296
296
|
// ../store-sql/src/schema/execution-schema.ts
|
|
297
|
-
import {
|
|
297
|
+
import {
|
|
298
|
+
bigint,
|
|
299
|
+
boolean as boolean2,
|
|
300
|
+
check as check2,
|
|
301
|
+
foreignKey,
|
|
302
|
+
index as index3,
|
|
303
|
+
integer as integer4,
|
|
304
|
+
jsonb as jsonb5,
|
|
305
|
+
pgTable as pgTable5,
|
|
306
|
+
primaryKey as primaryKey5,
|
|
307
|
+
text as text6,
|
|
308
|
+
timestamp as timestamp5,
|
|
309
|
+
uniqueIndex as uniqueIndex3
|
|
310
|
+
} from "drizzle-orm/pg-core";
|
|
311
|
+
import { sql as sql2 } from "drizzle-orm";
|
|
298
312
|
var relayExecutionState = pgTable5("relay_execution_state", {
|
|
299
313
|
tenantId: tenantId(),
|
|
300
314
|
executionId: text6("execution_id").$type().notNull(),
|
|
@@ -395,6 +409,96 @@ var relayChildFanOutMembers = pgTable5("relay_child_fan_out_members", {
|
|
|
395
409
|
}),
|
|
396
410
|
uniqueIndex3("uq_relay_child_fan_out_member_ordinal").on(table.tenantId, table.fanOutId, table.ordinal)
|
|
397
411
|
]);
|
|
412
|
+
var relayExecutionEventHeads = pgTable5("relay_execution_event_heads", {
|
|
413
|
+
tenantId: tenantId(),
|
|
414
|
+
executionId: text6("execution_id").$type().notNull(),
|
|
415
|
+
nextSequence: integer4("next_sequence").notNull().default(0),
|
|
416
|
+
maxSequence: integer4("max_sequence"),
|
|
417
|
+
eventCount: integer4("event_count").notNull().default(0),
|
|
418
|
+
usageTokens: bigint("usage_tokens", { mode: "number" }).notNull().default(0),
|
|
419
|
+
archivedThrough: integer4("archived_through"),
|
|
420
|
+
archiveGeneration: integer4("archive_generation")
|
|
421
|
+
}, (table) => [
|
|
422
|
+
primaryKey5({ columns: [table.tenantId, table.executionId], name: "pk_relay_execution_event_heads" }),
|
|
423
|
+
check2("ck_relay_execution_event_heads_archive_pointer", sql2`(${table.archivedThrough} IS NULL) = (${table.archiveGeneration} IS NULL)`)
|
|
424
|
+
]);
|
|
425
|
+
var relayExecutionEventArchiveManifests = pgTable5("relay_execution_event_archive_manifests", {
|
|
426
|
+
tenantId: tenantId(),
|
|
427
|
+
executionId: text6("execution_id").$type().notNull(),
|
|
428
|
+
generation: integer4("generation").notNull(),
|
|
429
|
+
archivedThrough: integer4("archived_through").notNull(),
|
|
430
|
+
eventCount: integer4("event_count").notNull(),
|
|
431
|
+
maxSequence: integer4("max_sequence").notNull(),
|
|
432
|
+
usageTokens: bigint("usage_tokens", { mode: "number" }).notNull(),
|
|
433
|
+
schemaVersion: integer4("schema_version").notNull()
|
|
434
|
+
}, (table) => [
|
|
435
|
+
primaryKey5({
|
|
436
|
+
columns: [table.tenantId, table.executionId, table.generation],
|
|
437
|
+
name: "pk_relay_execution_event_archive_manifests"
|
|
438
|
+
}),
|
|
439
|
+
foreignKey({
|
|
440
|
+
columns: [table.tenantId, table.executionId],
|
|
441
|
+
foreignColumns: [relayExecutions.tenantId, relayExecutions.id],
|
|
442
|
+
name: "fk_relay_execution_event_archive_manifests_execution"
|
|
443
|
+
}),
|
|
444
|
+
check2("ck_relay_execution_event_archive_manifests_generation", sql2`${table.generation} > 0`),
|
|
445
|
+
check2("ck_relay_execution_event_archive_manifests_frontier", sql2`${table.archivedThrough} >= 0`),
|
|
446
|
+
check2("ck_relay_execution_event_archive_manifests_count", sql2`${table.eventCount} > 0`),
|
|
447
|
+
check2("ck_relay_execution_event_archive_manifests_max", sql2`${table.maxSequence} = ${table.archivedThrough}`),
|
|
448
|
+
check2("ck_relay_execution_event_archive_manifests_gaps", sql2`${table.eventCount} <= ${table.archivedThrough} + 1`),
|
|
449
|
+
check2("ck_relay_execution_event_archive_manifests_usage", sql2`${table.usageTokens} >= 0`),
|
|
450
|
+
check2("ck_relay_execution_event_archive_manifests_schema", sql2`${table.schemaVersion} = 1`)
|
|
451
|
+
]);
|
|
452
|
+
var relayExecutionEventArchiveBlocks = pgTable5("relay_execution_event_archive_blocks", {
|
|
453
|
+
tenantId: tenantId(),
|
|
454
|
+
executionId: text6("execution_id").$type().notNull(),
|
|
455
|
+
generation: integer4("generation").notNull(),
|
|
456
|
+
blockIndex: integer4("block_index").notNull(),
|
|
457
|
+
firstSequence: integer4("first_sequence").notNull(),
|
|
458
|
+
lastSequence: integer4("last_sequence").notNull(),
|
|
459
|
+
eventCount: integer4("event_count").notNull(),
|
|
460
|
+
objectKey: text6("object_key").notNull(),
|
|
461
|
+
objectChecksum: text6("object_checksum").notNull(),
|
|
462
|
+
objectSize: integer4("object_size").notNull(),
|
|
463
|
+
codecVersion: integer4("codec_version").notNull(),
|
|
464
|
+
encoding: text6("encoding").notNull(),
|
|
465
|
+
compression: text6("compression").notNull(),
|
|
466
|
+
payloadChecksum: text6("payload_checksum").notNull(),
|
|
467
|
+
storedPayloadBytes: integer4("stored_payload_bytes").notNull(),
|
|
468
|
+
uncompressedBytes: integer4("uncompressed_bytes").notNull()
|
|
469
|
+
}, (table) => [
|
|
470
|
+
primaryKey5({
|
|
471
|
+
columns: [table.tenantId, table.executionId, table.generation, table.blockIndex],
|
|
472
|
+
name: "pk_relay_execution_event_archive_blocks"
|
|
473
|
+
}),
|
|
474
|
+
foreignKey({
|
|
475
|
+
columns: [table.tenantId, table.executionId, table.generation],
|
|
476
|
+
foreignColumns: [
|
|
477
|
+
relayExecutionEventArchiveManifests.tenantId,
|
|
478
|
+
relayExecutionEventArchiveManifests.executionId,
|
|
479
|
+
relayExecutionEventArchiveManifests.generation
|
|
480
|
+
],
|
|
481
|
+
name: "fk_relay_execution_event_archive_blocks_manifest"
|
|
482
|
+
}),
|
|
483
|
+
uniqueIndex3("uq_relay_execution_event_archive_blocks_first").on(table.tenantId, table.executionId, table.generation, table.firstSequence),
|
|
484
|
+
check2("ck_relay_execution_event_archive_blocks_index", sql2`${table.blockIndex} >= 0`),
|
|
485
|
+
check2("ck_relay_execution_event_archive_blocks_first", sql2`${table.firstSequence} >= 0`),
|
|
486
|
+
check2("ck_relay_execution_event_archive_blocks_bounds", sql2`${table.lastSequence} >= ${table.firstSequence}`),
|
|
487
|
+
check2("ck_relay_execution_event_archive_blocks_count", sql2`${table.eventCount} > 0`),
|
|
488
|
+
check2("ck_relay_execution_event_archive_blocks_count_limit", sql2`${table.eventCount} <= 4096`),
|
|
489
|
+
check2("ck_relay_execution_event_archive_blocks_gaps", sql2`${table.eventCount} <= ${table.lastSequence} - ${table.firstSequence} + 1`),
|
|
490
|
+
check2("ck_relay_execution_event_archive_blocks_object_size", sql2`${table.objectSize} > 0 AND ${table.objectSize} <= 16777216`),
|
|
491
|
+
check2("ck_relay_execution_event_archive_blocks_stored_payload_size", sql2`${table.storedPayloadBytes} > 0 AND ${table.storedPayloadBytes} <= 15728640`),
|
|
492
|
+
check2("ck_relay_execution_event_archive_blocks_uncompressed_size", sql2`${table.uncompressedBytes} > 0 AND ${table.uncompressedBytes} <= 15728640`),
|
|
493
|
+
check2("ck_relay_execution_event_archive_blocks_stored_size", sql2`${table.storedPayloadBytes} < ${table.objectSize}`),
|
|
494
|
+
check2("ck_relay_execution_event_archive_blocks_expansion", sql2`${table.storedPayloadBytes} <= ${table.uncompressedBytes}`),
|
|
495
|
+
check2("ck_relay_execution_event_archive_blocks_codec", sql2`${table.codecVersion} IN (1, 2)`),
|
|
496
|
+
check2("ck_relay_execution_event_archive_blocks_encoding", sql2`${table.encoding} = 'json'`),
|
|
497
|
+
check2("ck_relay_execution_event_archive_blocks_compression", sql2`(${table.codecVersion} = 1 AND ${table.compression} = 'none' AND ${table.storedPayloadBytes} = ${table.uncompressedBytes}) OR (${table.codecVersion} = 2 AND ${table.compression} = 'gzip')`),
|
|
498
|
+
check2("ck_relay_execution_event_archive_blocks_object_key", sql2`length(${table.objectKey}) <= 80`),
|
|
499
|
+
check2("ck_relay_execution_event_archive_blocks_checksum", sql2`length(${table.objectChecksum}) = 64`),
|
|
500
|
+
check2("ck_relay_execution_event_archive_blocks_payload_checksum", sql2`length(${table.payloadChecksum}) = 64`)
|
|
501
|
+
]);
|
|
398
502
|
var relayExecutionEvents = pgTable5("relay_execution_events", {
|
|
399
503
|
tenantId: tenantId(),
|
|
400
504
|
id: text6("id").$type().notNull(),
|
|
@@ -412,11 +516,23 @@ var relayExecutionEvents = pgTable5("relay_execution_events", {
|
|
|
412
516
|
uniqueIndex3("uq_relay_execution_events_sequence").on(table.tenantId, table.executionId, table.sequence),
|
|
413
517
|
uniqueIndex3("uq_relay_execution_events_cursor").on(table.tenantId, table.cursor)
|
|
414
518
|
]);
|
|
519
|
+
var relayExecutionEventIdentityDirectory = pgTable5("relay_execution_event_identity_directory", {
|
|
520
|
+
tenantId: tenantId(),
|
|
521
|
+
cursor: text6("cursor").notNull(),
|
|
522
|
+
eventId: text6("event_id").$type().notNull(),
|
|
523
|
+
executionId: text6("execution_id").$type().notNull(),
|
|
524
|
+
sequence: integer4("sequence").notNull()
|
|
525
|
+
}, (table) => [
|
|
526
|
+
primaryKey5({ columns: [table.tenantId, table.cursor], name: "pk_relay_execution_event_identity_directory" }),
|
|
527
|
+
uniqueIndex3("uq_relay_execution_event_identity_directory_event").on(table.tenantId, table.eventId),
|
|
528
|
+
uniqueIndex3("uq_relay_execution_event_identity_directory_sequence").on(table.tenantId, table.executionId, table.sequence)
|
|
529
|
+
]);
|
|
415
530
|
// ../store-sql/src/schema/communication-schema.ts
|
|
416
531
|
import { index as index4, integer as integer5, jsonb as jsonb6, pgTable as pgTable6, primaryKey as primaryKey6, text as text7, timestamp as timestamp6, uniqueIndex as uniqueIndex4 } from "drizzle-orm/pg-core";
|
|
417
532
|
var relaySteeringMessages = pgTable6("relay_steering_messages", {
|
|
418
533
|
tenantId: tenantId(),
|
|
419
534
|
executionId: text7("execution_id").notNull(),
|
|
535
|
+
idempotencyKey: text7("idempotency_key").notNull(),
|
|
420
536
|
kind: text7("kind").notNull(),
|
|
421
537
|
sequence: integer5("sequence").notNull(),
|
|
422
538
|
contentJson: jsonb6("content_json").$type().notNull(),
|
|
@@ -428,6 +544,7 @@ var relaySteeringMessages = pgTable6("relay_steering_messages", {
|
|
|
428
544
|
columns: [table.tenantId, table.executionId, table.kind, table.sequence],
|
|
429
545
|
name: "pk_relay_steering_messages"
|
|
430
546
|
}),
|
|
547
|
+
uniqueIndex4("uq_relay_steering_messages_idempotency").on(table.tenantId, table.executionId, table.idempotencyKey),
|
|
431
548
|
index4("idx_relay_steering_messages_unconsumed").on(table.tenantId, table.executionId, table.kind, table.consumedAt, table.sequence),
|
|
432
549
|
index4("idx_relay_steering_messages_drain").on(table.tenantId, table.executionId, table.kind, table.drainId, table.sequence)
|
|
433
550
|
]);
|
|
@@ -487,14 +604,14 @@ var relayTopicSubscriptions = pgTable6("relay_topic_subscriptions", {
|
|
|
487
604
|
index4("idx_relay_topic_subscriptions_subscriber").on(table.tenantId, table.subscriberExecutionId)
|
|
488
605
|
]);
|
|
489
606
|
// ../store-sql/src/schema/session-schema.ts
|
|
490
|
-
import { bigint, boolean as boolean3, index as index5, jsonb as jsonb7, pgTable as pgTable7, primaryKey as primaryKey7, text as text8, timestamp as timestamp7 } from "drizzle-orm/pg-core";
|
|
607
|
+
import { bigint as bigint2, boolean as boolean3, index as index5, jsonb as jsonb7, pgTable as pgTable7, primaryKey as primaryKey7, text as text8, timestamp as timestamp7 } from "drizzle-orm/pg-core";
|
|
491
608
|
var relaySessions = pgTable7("relay_sessions", {
|
|
492
609
|
tenantId: tenantId(),
|
|
493
610
|
id: text8("id").$type().notNull(),
|
|
494
611
|
rootAddressId: text8("root_address_id").$type().notNull(),
|
|
495
612
|
leafEntryId: text8("leaf_entry_id").$type(),
|
|
496
613
|
ownerExecutionId: text8("owner_execution_id").$type(),
|
|
497
|
-
ownerEpoch:
|
|
614
|
+
ownerEpoch: bigint2("owner_epoch", { mode: "number" }).notNull().default(0),
|
|
498
615
|
ownerReleased: boolean3("owner_released").notNull().default(true),
|
|
499
616
|
metadataJson: jsonb7("metadata_json").$type().notNull().default({}),
|
|
500
617
|
createdAt: timestamp7("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
@@ -588,7 +705,7 @@ var relayRouteAttempts = pgTable8("relay_route_attempts", {
|
|
|
588
705
|
]);
|
|
589
706
|
// ../store-sql/src/schema/workspace-schema.ts
|
|
590
707
|
import { index as index7, jsonb as jsonb9, pgTable as pgTable9, primaryKey as primaryKey9, text as text10, timestamp as timestamp9, uniqueIndex as uniqueIndex6 } from "drizzle-orm/pg-core";
|
|
591
|
-
import { sql as
|
|
708
|
+
import { sql as sql3 } from "drizzle-orm";
|
|
592
709
|
var relayWorkspaceLeases = pgTable9("relay_workspace_leases", {
|
|
593
710
|
tenantId: tenantId(),
|
|
594
711
|
id: text10("id").$type().notNull(),
|
|
@@ -605,7 +722,7 @@ var relayWorkspaceLeases = pgTable9("relay_workspace_leases", {
|
|
|
605
722
|
updatedAt: timestamp9("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
606
723
|
}, (table) => [
|
|
607
724
|
primaryKey9({ columns: [table.tenantId, table.id], name: "pk_relay_workspace_leases" }),
|
|
608
|
-
uniqueIndex6("uq_relay_workspace_leases_active_execution").on(table.tenantId, table.executionId).where(
|
|
725
|
+
uniqueIndex6("uq_relay_workspace_leases_active_execution").on(table.tenantId, table.executionId).where(sql3`${table.status} not in ('released', 'failed')`),
|
|
609
726
|
index7("idx_relay_workspace_leases_execution").on(table.tenantId, table.executionId),
|
|
610
727
|
index7("idx_relay_workspace_leases_status_updated").on(table.tenantId, table.status, table.updatedAt)
|
|
611
728
|
]);
|
|
@@ -748,7 +865,8 @@ var relayIdempotencyKeys = pgTable13("relay_idempotency_keys", {
|
|
|
748
865
|
uniqueIndex9("uq_relay_idempotency_scope_operation_key").on(table.tenantId, table.scope, table.operation, table.key)
|
|
749
866
|
]);
|
|
750
867
|
// src/postgres.ts
|
|
751
|
-
var
|
|
868
|
+
var priorSchemaHead = "20260724120000_execution_event_identity_directory";
|
|
869
|
+
var schemaHead = "20260724230000_idempotent_steering";
|
|
752
870
|
var migrationNames = [
|
|
753
871
|
"20260701002839_sour_cerebro",
|
|
754
872
|
"20260701041134_acoustic_hulk",
|
|
@@ -778,13 +896,17 @@ var migrationNames = [
|
|
|
778
896
|
"20260718140000_execution_scoped_tool_calls",
|
|
779
897
|
"20260719120000_rename_entity_to_resident",
|
|
780
898
|
"20260721120000_steering_delivered",
|
|
899
|
+
"20260721170000_session_writer_ownership",
|
|
900
|
+
"20260723190000_transactional_event_head",
|
|
901
|
+
"20260724010000_execution_event_archive_manifests",
|
|
902
|
+
priorSchemaHead,
|
|
781
903
|
schemaHead
|
|
782
904
|
];
|
|
783
905
|
var migrationsFolderUrl = import.meta.url.endsWith("/src/postgres.ts") ? new URL("../../../migrations/pg", import.meta.url) : new URL("./migrations/pg", import.meta.url);
|
|
784
906
|
var migrationsFolder = fileURLToPath(migrationsFolderUrl);
|
|
785
907
|
var verifySchema = Effect2.gen(function* () {
|
|
786
|
-
const
|
|
787
|
-
const rows = yield*
|
|
908
|
+
const sql4 = yield* SqlClient;
|
|
909
|
+
const rows = yield* sql4`SELECT name FROM drizzle.__drizzle_migrations ORDER BY id`;
|
|
788
910
|
const actual = rows.map((row) => row.name).join(",");
|
|
789
911
|
const expected = migrationNames.join(",");
|
|
790
912
|
if (actual !== expected) {
|
|
@@ -797,8 +919,8 @@ var verifySchema = Effect2.gen(function* () {
|
|
|
797
919
|
}
|
|
798
920
|
}).pipe((effect) => normalizeMigrationCause(effect, "pg", "verify"));
|
|
799
921
|
var runMigrations = normalizeMigrationCause(Effect2.gen(function* () {
|
|
800
|
-
const
|
|
801
|
-
const pg =
|
|
922
|
+
const sql4 = yield* SqlClient;
|
|
923
|
+
const pg = sql4;
|
|
802
924
|
const database2 = yield* makeWithDefaults2().pipe(Effect2.provideService(PgClient2, pg));
|
|
803
925
|
yield* runDrizzleMigrator(database2, { migrationsFolder });
|
|
804
926
|
}), "pg", "apply");
|
package/dist/sqlite.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
database,
|
|
4
4
|
normalizeMigrationCause
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-skcp0xvt.js";
|
|
6
6
|
import {
|
|
7
7
|
DatabaseAlreadyOwned,
|
|
8
8
|
RuntimeConfigurationError,
|
|
@@ -12,9 +12,9 @@ import {
|
|
|
12
12
|
make,
|
|
13
13
|
makeDatabaseIdentity,
|
|
14
14
|
runtimeLayer
|
|
15
|
-
} from "./index-
|
|
16
|
-
import"./index-
|
|
17
|
-
import"./index-
|
|
15
|
+
} from "./index-d1je4njg.js";
|
|
16
|
+
import"./index-d5563j6w.js";
|
|
17
|
+
import"./index-j8k41y47.js";
|
|
18
18
|
import"./index-nb39b5ae.js";
|
|
19
19
|
|
|
20
20
|
// src/sqlite-runtime.ts
|
|
@@ -682,6 +682,103 @@ ALTER TABLE "relay_sessions" ADD COLUMN "owner_epoch" INTEGER NOT NULL DEFAULT 0
|
|
|
682
682
|
ALTER TABLE "relay_sessions" ADD COLUMN "owner_released" INTEGER NOT NULL DEFAULT 1;
|
|
683
683
|
`;
|
|
684
684
|
|
|
685
|
+
// ../../migrations/sqlite/0015_transactional_event_head.sql
|
|
686
|
+
var _0015_transactional_event_head_default = `CREATE TABLE "relay_execution_event_heads" (
|
|
687
|
+
"tenant_id" TEXT NOT NULL DEFAULT 'system',
|
|
688
|
+
"execution_id" TEXT NOT NULL,
|
|
689
|
+
"next_sequence" INTEGER NOT NULL DEFAULT 0,
|
|
690
|
+
"max_sequence" INTEGER,
|
|
691
|
+
"event_count" INTEGER NOT NULL DEFAULT 0,
|
|
692
|
+
"usage_tokens" INTEGER NOT NULL DEFAULT 0,
|
|
693
|
+
CONSTRAINT "pk_relay_execution_event_heads" PRIMARY KEY ("tenant_id", "execution_id")
|
|
694
|
+
);
|
|
695
|
+
--> statement-breakpoint
|
|
696
|
+
INSERT INTO "relay_execution_event_heads" ("tenant_id", "execution_id", "next_sequence", "max_sequence", "event_count", "usage_tokens")
|
|
697
|
+
SELECT execution."tenant_id", execution."id", COALESCE(MAX(event."sequence") + 1, 0), MAX(event."sequence"), COUNT(event."id"),
|
|
698
|
+
COALESCE(SUM(CASE WHEN event."type" = 'model.usage.reported' AND json_valid(event."data_json") THEN
|
|
699
|
+
CASE WHEN json_type(event."data_json", '$.input_tokens') IN ('integer', 'real')
|
|
700
|
+
THEN CAST(json_extract(event."data_json", '$.input_tokens') AS INTEGER) ELSE 0 END +
|
|
701
|
+
CASE WHEN json_type(event."data_json", '$.output_tokens') IN ('integer', 'real')
|
|
702
|
+
THEN CAST(json_extract(event."data_json", '$.output_tokens') AS INTEGER) ELSE 0 END
|
|
703
|
+
ELSE 0 END), 0)
|
|
704
|
+
FROM "relay_executions" execution
|
|
705
|
+
LEFT JOIN "relay_execution_events" event
|
|
706
|
+
ON event."tenant_id" = execution."tenant_id" AND event."execution_id" = execution."id"
|
|
707
|
+
GROUP BY execution."tenant_id", execution."id";
|
|
708
|
+
`;
|
|
709
|
+
|
|
710
|
+
// ../../migrations/sqlite/0016_execution_event_archive_manifests.sql
|
|
711
|
+
var _0016_execution_event_archive_manifests_default = `ALTER TABLE "relay_execution_event_heads" ADD COLUMN "archived_through" INTEGER;
|
|
712
|
+
--> statement-breakpoint
|
|
713
|
+
ALTER TABLE "relay_execution_event_heads" ADD COLUMN "archive_generation" INTEGER;
|
|
714
|
+
--> statement-breakpoint
|
|
715
|
+
CREATE TABLE "relay_execution_event_archive_manifests" (
|
|
716
|
+
"tenant_id" TEXT NOT NULL DEFAULT 'system',
|
|
717
|
+
"execution_id" TEXT NOT NULL,
|
|
718
|
+
"generation" INTEGER NOT NULL CHECK ("generation" > 0),
|
|
719
|
+
"archived_through" INTEGER NOT NULL CHECK ("archived_through" >= 0),
|
|
720
|
+
"event_count" INTEGER NOT NULL CHECK ("event_count" > 0),
|
|
721
|
+
"max_sequence" INTEGER NOT NULL,
|
|
722
|
+
"usage_tokens" INTEGER NOT NULL CHECK ("usage_tokens" >= 0),
|
|
723
|
+
"schema_version" INTEGER NOT NULL CHECK ("schema_version" = 1),
|
|
724
|
+
CONSTRAINT "pk_relay_execution_event_archive_manifests" PRIMARY KEY ("tenant_id", "execution_id", "generation"),
|
|
725
|
+
CONSTRAINT "fk_relay_execution_event_archive_manifests_execution" FOREIGN KEY ("tenant_id", "execution_id") REFERENCES "relay_executions" ("tenant_id", "id"),
|
|
726
|
+
CONSTRAINT "ck_relay_execution_event_archive_manifests_max" CHECK ("max_sequence" = "archived_through"),
|
|
727
|
+
CONSTRAINT "ck_relay_execution_event_archive_manifests_gaps" CHECK ("event_count" <= "archived_through" + 1)
|
|
728
|
+
);
|
|
729
|
+
--> statement-breakpoint
|
|
730
|
+
CREATE TABLE "relay_execution_event_archive_blocks" (
|
|
731
|
+
"tenant_id" TEXT NOT NULL DEFAULT 'system',
|
|
732
|
+
"execution_id" TEXT NOT NULL,
|
|
733
|
+
"generation" INTEGER NOT NULL,
|
|
734
|
+
"block_index" INTEGER NOT NULL CHECK ("block_index" >= 0),
|
|
735
|
+
"first_sequence" INTEGER NOT NULL CHECK ("first_sequence" >= 0),
|
|
736
|
+
"last_sequence" INTEGER NOT NULL,
|
|
737
|
+
"event_count" INTEGER NOT NULL CHECK ("event_count" > 0 AND "event_count" <= 4096),
|
|
738
|
+
"object_key" TEXT NOT NULL CHECK (length("object_key") <= 80),
|
|
739
|
+
"object_checksum" TEXT NOT NULL CHECK (length("object_checksum") = 64),
|
|
740
|
+
"object_size" INTEGER NOT NULL CHECK ("object_size" > 0 AND "object_size" <= 16777216),
|
|
741
|
+
"codec_version" INTEGER NOT NULL CHECK ("codec_version" IN (1, 2)),
|
|
742
|
+
"encoding" TEXT NOT NULL CHECK ("encoding" = 'json'),
|
|
743
|
+
"compression" TEXT NOT NULL,
|
|
744
|
+
"payload_checksum" TEXT NOT NULL CHECK (length("payload_checksum") = 64),
|
|
745
|
+
"stored_payload_bytes" INTEGER NOT NULL CHECK ("stored_payload_bytes" > 0 AND "stored_payload_bytes" <= 15728640),
|
|
746
|
+
"uncompressed_bytes" INTEGER NOT NULL CHECK ("uncompressed_bytes" > 0 AND "uncompressed_bytes" <= 15728640),
|
|
747
|
+
CONSTRAINT "pk_relay_execution_event_archive_blocks" PRIMARY KEY ("tenant_id", "execution_id", "generation", "block_index"),
|
|
748
|
+
CONSTRAINT "fk_relay_execution_event_archive_blocks_manifest" FOREIGN KEY ("tenant_id", "execution_id", "generation") REFERENCES "relay_execution_event_archive_manifests" ("tenant_id", "execution_id", "generation"),
|
|
749
|
+
CONSTRAINT "ck_relay_execution_event_archive_blocks_bounds" CHECK ("last_sequence" >= "first_sequence"),
|
|
750
|
+
CONSTRAINT "ck_relay_execution_event_archive_blocks_gaps" CHECK ("event_count" <= "last_sequence" - "first_sequence" + 1),
|
|
751
|
+
CONSTRAINT "ck_relay_execution_event_archive_blocks_stored_size" CHECK ("stored_payload_bytes" < "object_size"),
|
|
752
|
+
CONSTRAINT "ck_relay_execution_event_archive_blocks_expansion" CHECK ("stored_payload_bytes" <= "uncompressed_bytes"),
|
|
753
|
+
CONSTRAINT "ck_relay_execution_event_archive_blocks_compression" CHECK (("codec_version" = 1 AND "compression" = 'none' AND "stored_payload_bytes" = "uncompressed_bytes") OR ("codec_version" = 2 AND "compression" = 'gzip')),
|
|
754
|
+
CONSTRAINT "uq_relay_execution_event_archive_blocks_first" UNIQUE ("tenant_id", "execution_id", "generation", "first_sequence")
|
|
755
|
+
);
|
|
756
|
+
`;
|
|
757
|
+
|
|
758
|
+
// ../../migrations/sqlite/0017_execution_event_identity_directory.sql
|
|
759
|
+
var _0017_execution_event_identity_directory_default = `CREATE TABLE "relay_execution_event_identity_directory" (
|
|
760
|
+
"tenant_id" text NOT NULL,
|
|
761
|
+
"cursor" text NOT NULL,
|
|
762
|
+
"event_id" text NOT NULL,
|
|
763
|
+
"execution_id" text NOT NULL,
|
|
764
|
+
"sequence" integer NOT NULL,
|
|
765
|
+
CONSTRAINT "pk_relay_execution_event_identity_directory" PRIMARY KEY("tenant_id", "cursor"),
|
|
766
|
+
CONSTRAINT "uq_relay_execution_event_identity_directory_event" UNIQUE("tenant_id", "event_id"),
|
|
767
|
+
CONSTRAINT "uq_relay_execution_event_identity_directory_sequence" UNIQUE("tenant_id", "execution_id", "sequence")
|
|
768
|
+
);
|
|
769
|
+
--> statement-breakpoint
|
|
770
|
+
INSERT INTO "relay_execution_event_identity_directory" ("tenant_id", "cursor", "event_id", "execution_id", "sequence")
|
|
771
|
+
SELECT "tenant_id", "cursor", "id", "execution_id", "sequence" FROM "relay_execution_events";
|
|
772
|
+
`;
|
|
773
|
+
|
|
774
|
+
// ../../migrations/sqlite/0018_idempotent_steering.sql
|
|
775
|
+
var _0018_idempotent_steering_default = `ALTER TABLE "relay_steering_messages" ADD COLUMN "idempotency_key" text NOT NULL DEFAULT '';
|
|
776
|
+
--> statement-breakpoint
|
|
777
|
+
UPDATE "relay_steering_messages" SET "idempotency_key" = 'relay:legacy:' || "kind" || ':' || CAST("sequence" AS text);
|
|
778
|
+
--> statement-breakpoint
|
|
779
|
+
CREATE UNIQUE INDEX "uq_relay_steering_messages_idempotency" ON "relay_steering_messages" ("tenant_id", "execution_id", "idempotency_key");
|
|
780
|
+
`;
|
|
781
|
+
|
|
685
782
|
// src/sqlite-migrations.ts
|
|
686
783
|
import { Effect } from "effect";
|
|
687
784
|
import { SqlClient } from "effect/unstable/sql/SqlClient";
|
|
@@ -706,7 +803,21 @@ var migrations = [
|
|
|
706
803
|
{ id: 11, name: "execution_scoped_tool_calls", file: "0011_execution_scoped_tool_calls.sql", source: _0011_execution_scoped_tool_calls_default },
|
|
707
804
|
{ id: 12, name: "rename_entity_to_resident", file: "0012_rename_entity_to_resident.sql", source: _0012_rename_entity_to_resident_default },
|
|
708
805
|
{ id: 13, name: "steering_delivered", file: "0013_steering_delivered.sql", source: _0013_steering_delivered_default },
|
|
709
|
-
{ id: 14, name: "session_writer_ownership", file: "0014_session_writer_ownership.sql", source: _0014_session_writer_ownership_default }
|
|
806
|
+
{ id: 14, name: "session_writer_ownership", file: "0014_session_writer_ownership.sql", source: _0014_session_writer_ownership_default },
|
|
807
|
+
{ id: 15, name: "transactional_event_head", file: "0015_transactional_event_head.sql", source: _0015_transactional_event_head_default },
|
|
808
|
+
{
|
|
809
|
+
id: 16,
|
|
810
|
+
name: "execution_event_archive_manifests",
|
|
811
|
+
file: "0016_execution_event_archive_manifests.sql",
|
|
812
|
+
source: _0016_execution_event_archive_manifests_default
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
id: 17,
|
|
816
|
+
name: "execution_event_identity_directory",
|
|
817
|
+
file: "0017_execution_event_identity_directory.sql",
|
|
818
|
+
source: _0017_execution_event_identity_directory_default
|
|
819
|
+
},
|
|
820
|
+
{ id: 18, name: "idempotent_steering", file: "0018_idempotent_steering.sql", source: _0018_idempotent_steering_default }
|
|
710
821
|
];
|
|
711
822
|
var loader = Effect.succeed(migrations.map(({ id, name, source }) => [id, name, Effect.succeed(execute(source))]));
|
|
712
823
|
|
|
@@ -7,7 +7,7 @@ export declare const startExecution: (input: StartExecutionInput) => Effect.Effe
|
|
|
7
7
|
export declare const startExecutionByAddress: (input: StartExecutionByAddressInput) => Effect.Effect<import("./operation").StartExecutionResult, ClientError | import("./client-public").ResidentNamespaceReserved, Service>;
|
|
8
8
|
export declare const startExecutionByAgentDefinition: (input: StartExecutionByAgentDefinitionInput) => Effect.Effect<import("./operation").StartExecutionResult, ClientError | import("./client-public").ResidentNamespaceReserved, Service>;
|
|
9
9
|
export declare const cancelExecution: (input: CancelExecutionInput) => Effect.Effect<import("./operation").CancelExecutionAccepted, ClientError, Service>;
|
|
10
|
-
export declare const steer: (input: SteerInput) => Effect.Effect<import("./operation").SteerAccepted, ClientError, Service>;
|
|
10
|
+
export declare const steer: (input: SteerInput) => Effect.Effect<import("./operation").SteerAccepted, ClientError | import("./operation").SteeringIdempotencyConflict, Service>;
|
|
11
11
|
export declare const getExecution: (id: Ids.ExecutionId) => Effect.Effect<Execution.Execution | undefined, ClientError, Service>;
|
|
12
12
|
export declare const listExecutions: (input: ListExecutionsInput) => Effect.Effect<import("./operation").ListExecutionsResult, ClientError, Service>;
|
|
13
13
|
export declare const listSessions: (input: ListSessionsInput) => Effect.Effect<import("./operation").ListSessionsResult, ClientError, Service>;
|
|
@@ -4,7 +4,7 @@ import type { Agent as BatonAgent } from "@batonfx/core";
|
|
|
4
4
|
import { Address, Agent, ChildOrchestration, Content, Resident, Envelope, Execution, Ids, Inbox, Presence, Shared, Skill, State, Tool, Workflow } from "../schema/index";
|
|
5
5
|
import { Context, Effect, Schema, Stream } from "effect";
|
|
6
6
|
import type { Tool as BatonTool } from "effect/unstable/ai";
|
|
7
|
-
import type { AckEnvelopeReadyInput, CancelExecutionAccepted, CancelExecutionInput, CancelScheduleInput, CancelScheduleResult, ClaimEnvelopeReadyInput, CreateScheduleInput, CreateScheduleResult, EnvelopeReadyAcked, EnvelopeReadyLease, EnvelopeReadyReleased, ExecutionInspection, ExecutionListChange, GetSessionInput, GetSessionResult, GetResidentStateInput, PutResidentStateInput, DeleteResidentStateInput, ListResidentStateInput, SpawnResidentInput, GetResidentInput, DestroyResidentInput, ListResidentsInput, ListExecutionsInput, ListExecutionsResult, ListInboxMessagesInput, ListTopicSubscriptionsInput, PublishTopicInput, SubscribeTopicInput, TopicPublishAccepted, TopicSubscription, UnsubscribeTopicInput, ListPendingApprovalsInput, SessionStreamItem, StreamSessionInput, WatchExecutionsInput, ListRunnersResult, ListSchedulesInput, ListSchedulesResult, ListSessionsInput, ListSessionsResult, ListWaitsInput, PendingToolApprovalList, PendingToolCallList, ListPendingToolCallsInput, FulfillToolCallInput, ClaimToolWorkInput, CompleteToolWorkInput, ReleaseToolWorkInput, ListToolAttemptsInput, ToolAttemptList, ToolOutcomeAccepted, ToolWorkLease, ToolWorkReleased, ReleaseEnvelopeReadyInput, PageExecutionEventsInput, PageExecutionEventsResult, ReplayExecutionInput, ReplayExecutionResult, ResolvePermissionInput, ResolveToolApprovalInput, RouteExecutionResult, StartExecutionInput, StartExecutionResult, SpawnChildRunInput, CancelChildFanOutInput, CancelChildFanOutResult, CreateChildFanOutInput, InspectChildFanOutInput, InspectChildFanOutResult, SteerAccepted, SteerInput, StreamExecutionInput, SubmitInboundEnvelopeAccepted, SubmitInboundEnvelopeInput, WaitView, WakeAccepted, WakeInput } from "./operation";
|
|
7
|
+
import type { AckEnvelopeReadyInput, CancelExecutionAccepted, CancelExecutionInput, CancelScheduleInput, CancelScheduleResult, ClaimEnvelopeReadyInput, CreateScheduleInput, CreateScheduleResult, EnvelopeReadyAcked, EnvelopeReadyLease, EnvelopeReadyReleased, ExecutionInspection, ExecutionListChange, GetSessionInput, GetSessionResult, GetResidentStateInput, PutResidentStateInput, DeleteResidentStateInput, ListResidentStateInput, SpawnResidentInput, GetResidentInput, DestroyResidentInput, ListResidentsInput, ListExecutionsInput, ListExecutionsResult, ListInboxMessagesInput, ListTopicSubscriptionsInput, PublishTopicInput, SubscribeTopicInput, TopicPublishAccepted, TopicSubscription, UnsubscribeTopicInput, ListPendingApprovalsInput, SessionStreamItem, StreamSessionInput, WatchExecutionsInput, ListRunnersResult, ListSchedulesInput, ListSchedulesResult, ListSessionsInput, ListSessionsResult, ListWaitsInput, PendingToolApprovalList, PendingToolCallList, ListPendingToolCallsInput, FulfillToolCallInput, ClaimToolWorkInput, CompleteToolWorkInput, ReleaseToolWorkInput, ListToolAttemptsInput, ToolAttemptList, ToolOutcomeAccepted, ToolWorkLease, ToolWorkReleased, ReleaseEnvelopeReadyInput, PageExecutionEventsInput, PageExecutionEventsResult, ReplayExecutionInput, ReplayExecutionResult, ResolvePermissionInput, ResolveToolApprovalInput, RouteExecutionResult, StartExecutionInput, StartExecutionResult, SpawnChildRunInput, CancelChildFanOutInput, CancelChildFanOutResult, CreateChildFanOutInput, InspectChildFanOutInput, InspectChildFanOutResult, SteerAccepted, SteerInput, SteeringIdempotencyConflict, StreamExecutionInput, SubmitInboundEnvelopeAccepted, SubmitInboundEnvelopeInput, WaitView, WakeAccepted, WakeInput } from "./operation";
|
|
8
8
|
import { EventLogCursorNotFound } from "./operation";
|
|
9
9
|
export { EventLogCursorNotFound } from "./operation";
|
|
10
10
|
import { AwaitWaitInput, WaitOutcome } from "./operation";
|
|
@@ -130,7 +130,7 @@ export interface FlatInterface {
|
|
|
130
130
|
readonly startExecutionByAddress: (input: StartExecutionByAddressInput) => Effect.Effect<StartExecutionResult, ResidentNamespaceReserved | ClientError>;
|
|
131
131
|
readonly startExecutionByAgentDefinition: (input: StartExecutionByAgentDefinitionInput) => Effect.Effect<StartExecutionResult, ResidentNamespaceReserved | ClientError>;
|
|
132
132
|
readonly cancelExecution: (input: CancelExecutionInput) => Effect.Effect<CancelExecutionAccepted, ClientError>;
|
|
133
|
-
readonly steer: (input: SteerInput) => Effect.Effect<SteerAccepted, ClientError>;
|
|
133
|
+
readonly steer: (input: SteerInput) => Effect.Effect<SteerAccepted, ClientError | SteeringIdempotencyConflict>;
|
|
134
134
|
readonly getExecution: (id: Ids.ExecutionId) => Effect.Effect<Execution.Execution | undefined, ClientError>;
|
|
135
135
|
readonly inspectExecution: (executionId: Ids.ExecutionId) => Effect.Effect<ExecutionInspection, ExecutionNotFound | ClientError>;
|
|
136
136
|
readonly listExecutions: (input: ListExecutionsInput) => Effect.Effect<ListExecutionsResult, ClientError>;
|
|
@@ -3,7 +3,7 @@ export { StateVersionConflict } from "./state-version-conflict";
|
|
|
3
3
|
import type { StateVersionConflict } from "./state-version-conflict";
|
|
4
4
|
import { Context } from "effect";
|
|
5
5
|
import type { Effect, Scope, Stream } from "effect";
|
|
6
|
-
import type { CancelExecutionAccepted, CancelExecutionInput, ClaimToolWorkInput, CompleteToolWorkInput, DeleteResidentStateInput, DestroyResidentInput, ExecutionInspection, ExecutionListChange, FulfillToolCallInput, GetResidentInput, GetResidentStateInput, ListResidentsInput, ListExecutionsInput, ListExecutionsResult, ListInboxMessagesInput, ListPendingToolCallsInput, ListResidentStateInput, ListToolAttemptsInput, ListWaitsInput, PendingToolCallList, PutResidentStateInput, ReleaseToolWorkInput, ResolvePermissionInput, SessionStreamItem, SpawnResidentInput, SpawnChildRunInput, StartExecutionResult, SteerAccepted, SteerInput, StreamExecutionInput, StreamSessionInput, ToolAttemptList, ToolOutcomeAccepted, ToolWorkLease, ToolWorkReleased, WaitView, WakeAccepted, WakeInput, WatchExecutionsInput } from "./operation";
|
|
6
|
+
import type { CancelExecutionAccepted, CancelExecutionInput, ClaimToolWorkInput, CompleteToolWorkInput, DeleteResidentStateInput, DestroyResidentInput, ExecutionInspection, ExecutionListChange, FulfillToolCallInput, GetResidentInput, GetResidentStateInput, ListResidentsInput, ListExecutionsInput, ListExecutionsResult, ListInboxMessagesInput, ListPendingToolCallsInput, ListResidentStateInput, ListToolAttemptsInput, ListWaitsInput, PendingToolCallList, PutResidentStateInput, ReleaseToolWorkInput, ResolvePermissionInput, SessionStreamItem, SpawnResidentInput, SpawnChildRunInput, StartExecutionResult, SteerAccepted, SteerInput, SteeringIdempotencyConflict, StreamExecutionInput, StreamSessionInput, ToolAttemptList, ToolOutcomeAccepted, ToolWorkLease, ToolWorkReleased, WaitView, WakeAccepted, WakeInput, WatchExecutionsInput } from "./operation";
|
|
7
7
|
export interface ClientError {
|
|
8
8
|
readonly _tag: "ClientError";
|
|
9
9
|
readonly message: string;
|
|
@@ -49,7 +49,7 @@ export interface ClientInterface {
|
|
|
49
49
|
readonly executions: {
|
|
50
50
|
readonly startByAddress: (input: StartExecutionByAddressInput) => Effect.Effect<StartExecutionResult, ResidentNamespaceReserved | ClientError>;
|
|
51
51
|
readonly cancel: (input: CancelExecutionInput) => Effect.Effect<CancelExecutionAccepted, ClientError>;
|
|
52
|
-
readonly steer: (input: SteerInput) => Effect.Effect<SteerAccepted, ClientError>;
|
|
52
|
+
readonly steer: (input: SteerInput) => Effect.Effect<SteerAccepted, ClientError | SteeringIdempotencyConflict>;
|
|
53
53
|
readonly get: (id: Ids.ExecutionId) => Effect.Effect<Execution.Execution | undefined, ClientError>;
|
|
54
54
|
readonly inspect: (executionId: Ids.ExecutionId) => Effect.Effect<ExecutionInspection, ExecutionNotFound | ClientError>;
|
|
55
55
|
readonly list: (input: ListExecutionsInput) => Effect.Effect<ListExecutionsResult, ClientError>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const migrations: readonly [readonly [1, "baseline", string], readonly [2, "durable_tool_placement", string], readonly [3, "durable_inbox", string], readonly [4, "execution_state", string], readonly [5, "durable_entities", string], readonly [6, "ephemeral_presence", string], readonly [7, "topic_subscriptions", string], readonly [8, "child_fan_out", string], readonly [9, "workflow_definitions", string], readonly [10, "workflow_runtime", string], readonly [11, "execution_scoped_tool_calls", string], readonly [12, "rename_entity_to_resident", string], readonly [13, "steering_delivered", string], readonly [14, "session_writer_ownership", string]];
|
|
1
|
+
export declare const migrations: readonly [readonly [1, "baseline", string], readonly [2, "durable_tool_placement", string], readonly [3, "durable_inbox", string], readonly [4, "execution_state", string], readonly [5, "durable_entities", string], readonly [6, "ephemeral_presence", string], readonly [7, "topic_subscriptions", string], readonly [8, "child_fan_out", string], readonly [9, "workflow_definitions", string], readonly [10, "workflow_runtime", string], readonly [11, "execution_scoped_tool_calls", string], readonly [12, "rename_entity_to_resident", string], readonly [13, "steering_delivered", string], readonly [14, "session_writer_ownership", string], readonly [15, "transactional_event_head", string], readonly [16, "execution_event_archive_manifests", string], readonly [17, "execution_event_identity_directory", string], readonly [18, "idempotent_steering", string]];
|
|
@@ -454,6 +454,7 @@ export declare const SteerInput: Schema.Struct<{
|
|
|
454
454
|
readonly execution_id: Schema.brand<Schema.String, "Relay.ExecutionId"> & {
|
|
455
455
|
make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.ExecutionId">;
|
|
456
456
|
};
|
|
457
|
+
readonly idempotency_key: Schema.String;
|
|
457
458
|
readonly kind: Schema.Literals<readonly ["steering", "follow_up"]>;
|
|
458
459
|
readonly content: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
459
460
|
readonly type: Schema.Literal<"text">;
|
|
@@ -508,6 +509,14 @@ export declare const SteerInput: Schema.Struct<{
|
|
|
508
509
|
}>;
|
|
509
510
|
export interface SteerInput extends Schema.Schema.Type<typeof SteerInput> {
|
|
510
511
|
}
|
|
512
|
+
declare const SteeringIdempotencyConflict_base: Schema.Class<SteeringIdempotencyConflict, Schema.TaggedStruct<"SteeringIdempotencyConflict", {
|
|
513
|
+
readonly execution_id: Schema.brand<Schema.String, "Relay.ExecutionId"> & {
|
|
514
|
+
make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.ExecutionId">;
|
|
515
|
+
};
|
|
516
|
+
readonly idempotency_key: Schema.String;
|
|
517
|
+
}>, import("effect/Cause").YieldableError>;
|
|
518
|
+
export declare class SteeringIdempotencyConflict extends SteeringIdempotencyConflict_base {
|
|
519
|
+
}
|
|
511
520
|
export declare const SteerAccepted: Schema.Struct<{
|
|
512
521
|
readonly execution_id: Schema.brand<Schema.String, "Relay.ExecutionId"> & {
|
|
513
522
|
make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.ExecutionId">;
|
|
@@ -70,5 +70,25 @@ export declare const migrations: readonly [{
|
|
|
70
70
|
readonly name: "session_writer_ownership";
|
|
71
71
|
readonly file: "0014_session_writer_ownership.sql";
|
|
72
72
|
readonly source: string;
|
|
73
|
+
}, {
|
|
74
|
+
readonly id: 15;
|
|
75
|
+
readonly name: "transactional_event_head";
|
|
76
|
+
readonly file: "0015_transactional_event_head.sql";
|
|
77
|
+
readonly source: string;
|
|
78
|
+
}, {
|
|
79
|
+
readonly id: 16;
|
|
80
|
+
readonly name: "execution_event_archive_manifests";
|
|
81
|
+
readonly file: "0016_execution_event_archive_manifests.sql";
|
|
82
|
+
readonly source: string;
|
|
83
|
+
}, {
|
|
84
|
+
readonly id: 17;
|
|
85
|
+
readonly name: "execution_event_identity_directory";
|
|
86
|
+
readonly file: "0017_execution_event_identity_directory.sql";
|
|
87
|
+
readonly source: string;
|
|
88
|
+
}, {
|
|
89
|
+
readonly id: 18;
|
|
90
|
+
readonly name: "idempotent_steering";
|
|
91
|
+
readonly file: "0018_idempotent_steering.sql";
|
|
92
|
+
readonly source: string;
|
|
73
93
|
}];
|
|
74
|
-
export declare const loader: Effect.Effect<(readonly [1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14, "baseline" | "child_fan_out" | "durable_entities" | "durable_inbox" | "durable_tool_placement" | "ephemeral_presence" | "execution_scoped_tool_calls" | "execution_state" | "rename_entity_to_resident" | "session_writer_ownership" | "steering_delivered" | "topic_subscriptions" | "workflow_definitions" | "workflow_runtime", Effect.Effect<Effect.Effect<void, import("effect/unstable/sql/SqlError").SqlError, SqlClient>, never, never>])[], never, never>;
|
|
94
|
+
export declare const loader: Effect.Effect<(readonly [1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18, "baseline" | "child_fan_out" | "durable_entities" | "durable_inbox" | "durable_tool_placement" | "ephemeral_presence" | "execution_event_archive_manifests" | "execution_event_identity_directory" | "execution_scoped_tool_calls" | "execution_state" | "idempotent_steering" | "rename_entity_to_resident" | "session_writer_ownership" | "steering_delivered" | "topic_subscriptions" | "transactional_event_head" | "workflow_definitions" | "workflow_runtime", Effect.Effect<Effect.Effect<void, import("effect/unstable/sql/SqlError").SqlError, SqlClient>, never, never>])[], never, never>;
|
|
@@ -2,20 +2,21 @@ import type { AgentEvent, ModelTelemetry } from "@batonfx/core";
|
|
|
2
2
|
import { Content, Execution, Shared, Tool } from "../../schema/index";
|
|
3
3
|
import type { Response } from "effect/unstable/ai";
|
|
4
4
|
import type { RunInput } from "./agent-loop-service";
|
|
5
|
+
type ExecutionEventDraft = Omit<Execution.ExecutionEvent, "sequence">;
|
|
5
6
|
declare const legacyTelemetryCursor: (input: RunInput, event: ModelTelemetry.Event) => string;
|
|
6
7
|
declare const legacyUsageCursor: (input: RunInput, event: ModelTelemetry.ModelAttemptCompleted) => string;
|
|
7
|
-
declare const telemetryEvent: (input: RunInput, sessionId: string, event: ModelTelemetry.Event,
|
|
8
|
-
declare const inputPreparedEvent: (input: RunInput, definitions: ReadonlyArray<Tool.Definition>) =>
|
|
9
|
-
declare const usageReportedEvent: (input: RunInput, sessionId: string, event: ModelTelemetry.ModelAttemptCompleted,
|
|
10
|
-
declare const budgetExceededEvent: (input: RunInput, tokensUsed: number, tokenBudget: number
|
|
11
|
-
declare const outputDeltaEvent: (input: RunInput, modelPart: AgentEvent.ModelPart, part: Response.TextDeltaPart, deltaIndex: number, createdAt: number) =>
|
|
12
|
-
declare const reasoningDeltaEvent: (input: RunInput, modelPart: AgentEvent.ModelPart, part: Response.ReasoningPart | Response.ReasoningDeltaPart, deltaIndex: number, createdAt: number) =>
|
|
13
|
-
declare const toolCallDeltaEvent: (input: RunInput, modelPart: AgentEvent.ModelPart, part: Response.ToolParamsDeltaPart, toolCallName: string | undefined,
|
|
14
|
-
declare const outputCompletedEvent: (input: RunInput, content: ReadonlyArray<Content.Part>, outputText: string,
|
|
8
|
+
declare const telemetryEvent: (input: RunInput, sessionId: string, event: ModelTelemetry.Event, createdAt: number) => ExecutionEventDraft;
|
|
9
|
+
declare const inputPreparedEvent: (input: RunInput, definitions: ReadonlyArray<Tool.Definition>) => ExecutionEventDraft;
|
|
10
|
+
declare const usageReportedEvent: (input: RunInput, sessionId: string, event: ModelTelemetry.ModelAttemptCompleted, createdAt: number) => ExecutionEventDraft;
|
|
11
|
+
declare const budgetExceededEvent: (input: RunInput, tokensUsed: number, tokenBudget: number) => ExecutionEventDraft;
|
|
12
|
+
declare const outputDeltaEvent: (input: RunInput, modelPart: AgentEvent.ModelPart, part: Response.TextDeltaPart, deltaIndex: number, createdAt: number) => ExecutionEventDraft;
|
|
13
|
+
declare const reasoningDeltaEvent: (input: RunInput, modelPart: AgentEvent.ModelPart, part: Response.ReasoningPart | Response.ReasoningDeltaPart, deltaIndex: number, createdAt: number) => ExecutionEventDraft;
|
|
14
|
+
declare const toolCallDeltaEvent: (input: RunInput, modelPart: AgentEvent.ModelPart, part: Response.ToolParamsDeltaPart, toolCallName: string | undefined, deltaIndex: number, createdAt: number) => ExecutionEventDraft;
|
|
15
|
+
declare const outputCompletedEvent: (input: RunInput, content: ReadonlyArray<Content.Part>, outputText: string, structuredOutput?: Shared.JsonValue, structuredIdentity?: {
|
|
15
16
|
readonly modelCallId: string;
|
|
16
17
|
readonly modelAttemptId: string;
|
|
17
18
|
readonly attempt: number;
|
|
18
|
-
}) =>
|
|
19
|
+
}) => ExecutionEventDraft;
|
|
19
20
|
declare const completedContent: (outputText: string) => ReadonlyArray<Content.Part>;
|
|
20
21
|
declare const modelOutputMetadata: (event: Execution.ExecutionEvent) => Shared.Metadata;
|
|
21
22
|
export declare const AgentLoopEvents: {
|
|
@@ -32,6 +32,7 @@ export declare class AgentLoopWaitRequested extends AgentLoopWaitRequested_base
|
|
|
32
32
|
}
|
|
33
33
|
export interface RunInput {
|
|
34
34
|
readonly executionId: Ids.ExecutionId;
|
|
35
|
+
readonly operationId: string;
|
|
35
36
|
readonly origin?: Execution.ExecutionOrigin;
|
|
36
37
|
readonly sessionId?: Ids.SessionId;
|
|
37
38
|
readonly agent: Agent.Definition;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
/** Invocation-local deterministic emission ordinals. These are never durable event sequences. */
|
|
3
|
+
export interface EmissionOrdinalAllocator {
|
|
4
|
+
readonly allocate: (count: number) => Effect.Effect<number>;
|
|
5
|
+
readonly current: Effect.Effect<number>;
|
|
6
|
+
}
|
|
7
|
+
export declare const make: Effect.Effect<EmissionOrdinalAllocator>;
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import { Approvals, Permissions } from "@batonfx/core";
|
|
2
2
|
import { Agent, Execution, Ids } from "../../schema/index";
|
|
3
3
|
import { PermissionRuleRepository } from "../../store-sql/portable";
|
|
4
|
-
import {
|
|
4
|
+
import { Layer } from "effect";
|
|
5
5
|
import type { Interface as EventLogInterface } from "../execution/event-log-service";
|
|
6
6
|
import type { Interface as WaitServiceInterface } from "../wait/wait-service";
|
|
7
|
-
export interface SequenceAllocator {
|
|
8
|
-
readonly allocate: (count: number) => Effect.Effect<Execution.ExecutionEventSequence>;
|
|
9
|
-
readonly current: Effect.Effect<Execution.ExecutionEventSequence>;
|
|
10
|
-
readonly resetTo: (sequence: Execution.ExecutionEventSequence) => Effect.Effect<void>;
|
|
11
|
-
}
|
|
12
7
|
export interface Config {
|
|
13
8
|
readonly ruleset: Agent.PermissionRuleset;
|
|
14
9
|
readonly repository: PermissionRuleRepository.Interface;
|
|
15
10
|
readonly waits: WaitServiceInterface;
|
|
16
11
|
readonly eventLog: EventLogInterface;
|
|
17
|
-
readonly allocator: SequenceAllocator;
|
|
18
12
|
readonly executionId: Ids.ExecutionId;
|
|
13
|
+
readonly operationId: string;
|
|
14
|
+
readonly resumedPermissionWaitId?: Ids.WaitId;
|
|
15
|
+
readonly resumedPermissionToolCallId?: string;
|
|
19
16
|
readonly agentName: string;
|
|
20
17
|
readonly scope: string;
|
|
21
18
|
readonly startedAt: number;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Steering } from "@batonfx/core";
|
|
2
|
-
import {
|
|
2
|
+
import { Ids } from "../../schema/index";
|
|
3
3
|
import { SteeringRepository } from "../../store-sql/portable";
|
|
4
4
|
import { Effect, Layer } from "effect";
|
|
5
5
|
import type { Interface } from "../execution/event-log-service";
|
|
6
|
-
export interface
|
|
7
|
-
readonly allocate: (count: number) => Effect.Effect<
|
|
6
|
+
export interface EmissionOrdinalAllocator {
|
|
7
|
+
readonly allocate: (count: number) => Effect.Effect<number>;
|
|
8
8
|
}
|
|
9
9
|
export interface Config {
|
|
10
10
|
readonly repository: SteeringRepository.Interface;
|
|
11
11
|
readonly eventLog: Interface;
|
|
12
|
-
readonly allocator:
|
|
12
|
+
readonly allocator: EmissionOrdinalAllocator;
|
|
13
13
|
readonly executionId: Ids.ExecutionId;
|
|
14
|
+
readonly operationId: string;
|
|
14
15
|
readonly startedAt: number;
|
|
15
|
-
readonly eventSequence: Execution.ExecutionEventSequence;
|
|
16
16
|
}
|
|
17
17
|
export declare const layer: (config: Config) => Layer.Layer<Steering.Steering>;
|