@inkeep/agents-core 0.10.2 → 0.11.1

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/index.cjs CHANGED
@@ -240,11 +240,7 @@ __export(schema_exports, {
240
240
  externalAgents: () => externalAgents,
241
241
  externalAgentsRelations: () => externalAgentsRelations,
242
242
  ledgerArtifacts: () => ledgerArtifacts,
243
- ledgerArtifactsContextIdIdx: () => ledgerArtifactsContextIdIdx,
244
243
  ledgerArtifactsRelations: () => ledgerArtifactsRelations,
245
- ledgerArtifactsTaskContextNameUnique: () => ledgerArtifactsTaskContextNameUnique,
246
- ledgerArtifactsTaskIdIdx: () => ledgerArtifactsTaskIdIdx,
247
- ledgerArtifactsToolCallIdIdx: () => ledgerArtifactsToolCallIdIdx,
248
244
  messages: () => messages,
249
245
  messagesRelations: () => messagesRelations,
250
246
  projects: () => projects,
@@ -256,29 +252,47 @@ __export(schema_exports, {
256
252
  tools: () => tools,
257
253
  toolsRelations: () => toolsRelations
258
254
  });
255
+ var tenantScoped = {
256
+ tenantId: sqliteCore.text("tenant_id").notNull(),
257
+ id: sqliteCore.text("id").notNull()
258
+ };
259
+ var projectScoped = {
260
+ ...tenantScoped,
261
+ projectId: sqliteCore.text("project_id").notNull()
262
+ };
263
+ var graphScoped = {
264
+ ...projectScoped,
265
+ graphId: sqliteCore.text("graph_id").notNull()
266
+ };
267
+ var agentScoped = {
268
+ ...graphScoped,
269
+ agentId: sqliteCore.text("agent_id").notNull()
270
+ };
271
+ var uiProperties = {
272
+ name: sqliteCore.text("name").notNull(),
273
+ description: sqliteCore.text("description").notNull()
274
+ };
275
+ var timestamps = {
276
+ createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
277
+ updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
278
+ };
259
279
  var projects = sqliteCore.sqliteTable(
260
280
  "projects",
261
281
  {
262
- tenantId: sqliteCore.text("tenant_id").notNull(),
263
- id: sqliteCore.text("id").notNull(),
264
- // This IS the project ID
265
- name: sqliteCore.text("name").notNull(),
266
- description: sqliteCore.text("description").notNull(),
282
+ ...tenantScoped,
283
+ ...uiProperties,
267
284
  // Project-level default model settings that can be inherited by graphs and agents
268
285
  models: sqliteCore.text("models", { mode: "json" }).$type(),
269
286
  // Project-level stopWhen configuration that can be inherited by graphs and agents
270
287
  stopWhen: sqliteCore.text("stop_when", { mode: "json" }).$type(),
271
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
272
- updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
288
+ ...timestamps
273
289
  },
274
290
  (table) => [sqliteCore.primaryKey({ columns: [table.tenantId, table.id] })]
275
291
  );
276
292
  var agentGraph = sqliteCore.sqliteTable(
277
293
  "agent_graph",
278
294
  {
279
- tenantId: sqliteCore.text("tenant_id").notNull(),
280
- projectId: sqliteCore.text("project_id").notNull(),
281
- id: sqliteCore.text("id").notNull(),
295
+ ...projectScoped,
282
296
  name: sqliteCore.text("name").notNull(),
283
297
  description: sqliteCore.text("description"),
284
298
  defaultAgentId: sqliteCore.text("default_agent_id"),
@@ -293,8 +307,7 @@ var agentGraph = sqliteCore.sqliteTable(
293
307
  graphPrompt: sqliteCore.text("graph_prompt"),
294
308
  // Graph-level stopWhen configuration that can be inherited by agents
295
309
  stopWhen: sqliteCore.text("stop_when", { mode: "json" }).$type(),
296
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
297
- updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
310
+ ...timestamps
298
311
  },
299
312
  (table) => [
300
313
  sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
@@ -308,19 +321,14 @@ var agentGraph = sqliteCore.sqliteTable(
308
321
  var contextConfigs = sqliteCore.sqliteTable(
309
322
  "context_configs",
310
323
  {
311
- tenantId: sqliteCore.text("tenant_id").notNull(),
312
- projectId: sqliteCore.text("project_id").notNull(),
313
- // Add graph level scoping
314
- id: sqliteCore.text("id").notNull(),
315
- name: sqliteCore.text("name").notNull(),
316
- description: sqliteCore.text("description").notNull(),
324
+ ...projectScoped,
325
+ ...uiProperties,
317
326
  // Developer-defined Zod schema for validating incoming request context
318
327
  requestContextSchema: sqliteCore.blob("request_context_schema", { mode: "json" }).$type(),
319
328
  // Stores serialized Zod schema
320
329
  // Object mapping template keys to fetch definitions that use request context data
321
330
  contextVariables: sqliteCore.blob("context_variables", { mode: "json" }).$type(),
322
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
323
- updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
331
+ ...timestamps
324
332
  },
325
333
  (table) => [
326
334
  sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
@@ -334,9 +342,7 @@ var contextConfigs = sqliteCore.sqliteTable(
334
342
  var contextCache = sqliteCore.sqliteTable(
335
343
  "context_cache",
336
344
  {
337
- tenantId: sqliteCore.text("tenant_id").notNull(),
338
- projectId: sqliteCore.text("project_id").notNull(),
339
- id: sqliteCore.text("id").notNull(),
345
+ ...projectScoped,
340
346
  // Always scoped to conversation for complete data isolation
341
347
  conversationId: sqliteCore.text("conversation_id").notNull(),
342
348
  // Reference to the context config and specific fetch definition
@@ -353,8 +359,7 @@ var contextCache = sqliteCore.sqliteTable(
353
359
  fetchSource: sqliteCore.text("fetch_source"),
354
360
  // URL or source identifier
355
361
  fetchDurationMs: sqliteCore.integer("fetch_duration_ms"),
356
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
357
- updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
362
+ ...timestamps
358
363
  },
359
364
  (table) => [
360
365
  sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
@@ -373,12 +378,8 @@ var contextCache = sqliteCore.sqliteTable(
373
378
  var agents = sqliteCore.sqliteTable(
374
379
  "agents",
375
380
  {
376
- tenantId: sqliteCore.text("tenant_id").notNull(),
377
- projectId: sqliteCore.text("project_id").notNull(),
378
- graphId: sqliteCore.text("graph_id").notNull(),
379
- id: sqliteCore.text("id").notNull(),
380
- name: sqliteCore.text("name").notNull(),
381
- description: sqliteCore.text("description").notNull(),
381
+ ...graphScoped,
382
+ ...uiProperties,
382
383
  prompt: sqliteCore.text("prompt").notNull(),
383
384
  conversationHistoryConfig: sqliteCore.text("conversation_history_config", {
384
385
  mode: "json"
@@ -386,8 +387,7 @@ var agents = sqliteCore.sqliteTable(
386
387
  models: sqliteCore.text("models", { mode: "json" }).$type(),
387
388
  // Agent-level stopWhen configuration (inherited from project)
388
389
  stopWhen: sqliteCore.text("stop_when", { mode: "json" }).$type(),
389
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
390
- updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
390
+ ...timestamps
391
391
  },
392
392
  (table) => [
393
393
  sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
@@ -401,10 +401,7 @@ var agents = sqliteCore.sqliteTable(
401
401
  var agentRelations = sqliteCore.sqliteTable(
402
402
  "agent_relations",
403
403
  {
404
- tenantId: sqliteCore.text("tenant_id").notNull(),
405
- projectId: sqliteCore.text("project_id").notNull(),
406
- graphId: sqliteCore.text("graph_id").notNull(),
407
- id: sqliteCore.text("id").notNull(),
404
+ ...graphScoped,
408
405
  sourceAgentId: sqliteCore.text("source_agent_id").notNull(),
409
406
  // For internal relationships
410
407
  targetAgentId: sqliteCore.text("target_agent_id"),
@@ -412,8 +409,7 @@ var agentRelations = sqliteCore.sqliteTable(
412
409
  externalAgentId: sqliteCore.text("external_agent_id"),
413
410
  relationType: sqliteCore.text("relation_type"),
414
411
  // 'transfer' | 'delegate'
415
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
416
- updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
412
+ ...timestamps
417
413
  },
418
414
  (table) => [
419
415
  sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
@@ -427,18 +423,13 @@ var agentRelations = sqliteCore.sqliteTable(
427
423
  var externalAgents = sqliteCore.sqliteTable(
428
424
  "external_agents",
429
425
  {
430
- tenantId: sqliteCore.text("tenant_id").notNull(),
431
- projectId: sqliteCore.text("project_id").notNull(),
432
- graphId: sqliteCore.text("graph_id").notNull(),
433
- id: sqliteCore.text("id").notNull(),
434
- name: sqliteCore.text("name").notNull(),
435
- description: sqliteCore.text("description").notNull(),
426
+ ...graphScoped,
427
+ ...uiProperties,
436
428
  baseUrl: sqliteCore.text("base_url").notNull(),
437
429
  // A2A endpoint URL
438
430
  credentialReferenceId: sqliteCore.text("credential_reference_id"),
439
431
  headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
440
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
441
- updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
432
+ ...timestamps
442
433
  },
443
434
  (table) => [
444
435
  sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
@@ -461,37 +452,30 @@ var externalAgents = sqliteCore.sqliteTable(
461
452
  var tasks = sqliteCore.sqliteTable(
462
453
  "tasks",
463
454
  {
464
- tenantId: sqliteCore.text("tenant_id").notNull(),
465
- projectId: sqliteCore.text("project_id").notNull(),
466
- id: sqliteCore.text("id").notNull(),
455
+ ...agentScoped,
467
456
  contextId: sqliteCore.text("context_id").notNull(),
468
457
  status: sqliteCore.text("status").notNull(),
469
458
  metadata: sqliteCore.blob("metadata", { mode: "json" }).$type(),
470
- agentId: sqliteCore.text("agent_id").notNull(),
471
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
472
- updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
459
+ ...timestamps
473
460
  },
474
461
  (table) => [
475
462
  sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
476
463
  sqliteCore.foreignKey({
477
- columns: [table.tenantId, table.projectId],
478
- foreignColumns: [projects.tenantId, projects.id],
479
- name: "tasks_project_fk"
464
+ columns: [table.tenantId, table.projectId, table.graphId, table.agentId],
465
+ foreignColumns: [agents.tenantId, agents.projectId, agents.graphId, agents.id],
466
+ name: "tasks_agent_fk"
480
467
  }).onDelete("cascade")
481
468
  ]
482
469
  );
483
470
  var taskRelations = sqliteCore.sqliteTable(
484
471
  "task_relations",
485
472
  {
486
- tenantId: sqliteCore.text("tenant_id").notNull(),
487
- projectId: sqliteCore.text("project_id").notNull(),
488
- id: sqliteCore.text("id").notNull(),
473
+ ...projectScoped,
489
474
  parentTaskId: sqliteCore.text("parent_task_id").notNull(),
490
475
  childTaskId: sqliteCore.text("child_task_id").notNull(),
491
476
  relationType: sqliteCore.text("relation_type").default("parent_child"),
492
477
  // Could be extended for other relation types
493
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
494
- updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
478
+ ...timestamps
495
479
  },
496
480
  (table) => [
497
481
  sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
@@ -505,14 +489,10 @@ var taskRelations = sqliteCore.sqliteTable(
505
489
  var dataComponents = sqliteCore.sqliteTable(
506
490
  "data_components",
507
491
  {
508
- tenantId: sqliteCore.text("tenant_id").notNull(),
509
- projectId: sqliteCore.text("project_id").notNull(),
510
- id: sqliteCore.text("id").notNull(),
511
- name: sqliteCore.text("name").notNull(),
512
- description: sqliteCore.text("description").notNull(),
492
+ ...projectScoped,
493
+ ...uiProperties,
513
494
  props: sqliteCore.blob("props", { mode: "json" }).$type(),
514
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
515
- updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
495
+ ...timestamps
516
496
  },
517
497
  (table) => [
518
498
  sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
@@ -526,11 +506,7 @@ var dataComponents = sqliteCore.sqliteTable(
526
506
  var agentDataComponents = sqliteCore.sqliteTable(
527
507
  "agent_data_components",
528
508
  {
529
- tenantId: sqliteCore.text("tenant_id").notNull(),
530
- projectId: sqliteCore.text("project_id").notNull(),
531
- graphId: sqliteCore.text("graph_id").notNull(),
532
- agentId: sqliteCore.text("agent_id").notNull(),
533
- id: sqliteCore.text("id").notNull(),
509
+ ...agentScoped,
534
510
  dataComponentId: sqliteCore.text("data_component_id").notNull(),
535
511
  createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
536
512
  },
@@ -553,15 +529,11 @@ var agentDataComponents = sqliteCore.sqliteTable(
553
529
  var artifactComponents = sqliteCore.sqliteTable(
554
530
  "artifact_components",
555
531
  {
556
- tenantId: sqliteCore.text("tenant_id").notNull(),
557
- projectId: sqliteCore.text("project_id").notNull(),
558
- id: sqliteCore.text("id").notNull(),
559
- name: sqliteCore.text("name").notNull(),
560
- description: sqliteCore.text("description").notNull(),
532
+ ...projectScoped,
533
+ ...uiProperties,
561
534
  summaryProps: sqliteCore.blob("summary_props", { mode: "json" }).$type(),
562
535
  fullProps: sqliteCore.blob("full_props", { mode: "json" }).$type(),
563
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
564
- updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
536
+ ...timestamps
565
537
  },
566
538
  (table) => [
567
539
  sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
@@ -575,11 +547,7 @@ var artifactComponents = sqliteCore.sqliteTable(
575
547
  var agentArtifactComponents = sqliteCore.sqliteTable(
576
548
  "agent_artifact_components",
577
549
  {
578
- tenantId: sqliteCore.text("tenant_id").notNull(),
579
- projectId: sqliteCore.text("project_id").notNull(),
580
- graphId: sqliteCore.text("graph_id").notNull(),
581
- agentId: sqliteCore.text("agent_id").notNull(),
582
- id: sqliteCore.text("id").notNull(),
550
+ ...agentScoped,
583
551
  artifactComponentId: sqliteCore.text("artifact_component_id").notNull(),
584
552
  createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
585
553
  },
@@ -608,9 +576,7 @@ var agentArtifactComponents = sqliteCore.sqliteTable(
608
576
  var tools = sqliteCore.sqliteTable(
609
577
  "tools",
610
578
  {
611
- tenantId: sqliteCore.text("tenant_id").notNull(),
612
- projectId: sqliteCore.text("project_id").notNull(),
613
- id: sqliteCore.text("id").notNull(),
579
+ ...projectScoped,
614
580
  name: sqliteCore.text("name").notNull(),
615
581
  // Enhanced MCP configuration
616
582
  config: sqliteCore.blob("config", { mode: "json" }).$type().notNull(),
@@ -621,8 +587,7 @@ var tools = sqliteCore.sqliteTable(
621
587
  // Server capabilities and status
622
588
  capabilities: sqliteCore.blob("capabilities", { mode: "json" }).$type(),
623
589
  lastError: sqliteCore.text("last_error"),
624
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
625
- updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
590
+ ...timestamps
626
591
  },
627
592
  (table) => [
628
593
  sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
@@ -636,16 +601,11 @@ var tools = sqliteCore.sqliteTable(
636
601
  var agentToolRelations = sqliteCore.sqliteTable(
637
602
  "agent_tool_relations",
638
603
  {
639
- tenantId: sqliteCore.text("tenant_id").notNull(),
640
- projectId: sqliteCore.text("project_id").notNull(),
641
- graphId: sqliteCore.text("graph_id").notNull(),
642
- agentId: sqliteCore.text("agent_id").notNull(),
643
- id: sqliteCore.text("id").notNull(),
604
+ ...agentScoped,
644
605
  toolId: sqliteCore.text("tool_id").notNull(),
645
606
  selectedTools: sqliteCore.blob("selected_tools", { mode: "json" }).$type(),
646
607
  headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
647
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
648
- updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
608
+ ...timestamps
649
609
  },
650
610
  (table) => [
651
611
  sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
@@ -666,16 +626,13 @@ var agentToolRelations = sqliteCore.sqliteTable(
666
626
  var conversations = sqliteCore.sqliteTable(
667
627
  "conversations",
668
628
  {
669
- tenantId: sqliteCore.text("tenant_id").notNull(),
670
- projectId: sqliteCore.text("project_id").notNull(),
671
- id: sqliteCore.text("id").notNull(),
629
+ ...projectScoped,
672
630
  userId: sqliteCore.text("user_id"),
673
631
  activeAgentId: sqliteCore.text("active_agent_id").notNull(),
674
632
  title: sqliteCore.text("title"),
675
633
  lastContextResolution: sqliteCore.text("last_context_resolution"),
676
634
  metadata: sqliteCore.blob("metadata", { mode: "json" }).$type(),
677
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
678
- updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
635
+ ...timestamps
679
636
  },
680
637
  (table) => [
681
638
  sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
@@ -689,9 +646,7 @@ var conversations = sqliteCore.sqliteTable(
689
646
  var messages = sqliteCore.sqliteTable(
690
647
  "messages",
691
648
  {
692
- tenantId: sqliteCore.text("tenant_id").notNull(),
693
- projectId: sqliteCore.text("project_id").notNull(),
694
- id: sqliteCore.text("id").notNull(),
649
+ ...projectScoped,
695
650
  conversationId: sqliteCore.text("conversation_id").notNull(),
696
651
  // Role mapping: user, agent, system (unified for both formats)
697
652
  role: sqliteCore.text("role").notNull(),
@@ -726,8 +681,7 @@ var messages = sqliteCore.sqliteTable(
726
681
  // A2A session identifier
727
682
  // Metadata for extensions
728
683
  metadata: sqliteCore.blob("metadata", { mode: "json" }).$type(),
729
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
730
- updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
684
+ ...timestamps
731
685
  },
732
686
  (table) => [
733
687
  sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
@@ -741,10 +695,7 @@ var messages = sqliteCore.sqliteTable(
741
695
  var ledgerArtifacts = sqliteCore.sqliteTable(
742
696
  "ledger_artifacts",
743
697
  {
744
- // Primary identifier (maps to `artifactId`)
745
- tenantId: sqliteCore.text("tenant_id").notNull(),
746
- projectId: sqliteCore.text("project_id").notNull(),
747
- id: sqliteCore.text("id").notNull(),
698
+ ...projectScoped,
748
699
  // Links
749
700
  taskId: sqliteCore.text("task_id").notNull(),
750
701
  toolCallId: sqliteCore.text("tool_call_id"),
@@ -762,9 +713,7 @@ var ledgerArtifacts = sqliteCore.sqliteTable(
762
713
  visibility: sqliteCore.text("visibility").default("context"),
763
714
  allowedAgents: sqliteCore.blob("allowed_agents", { mode: "json" }).$type(),
764
715
  derivedFrom: sqliteCore.text("derived_from"),
765
- // Timestamps
766
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
767
- updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
716
+ ...timestamps
768
717
  },
769
718
  (table) => [
770
719
  sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id, table.taskId] }),
@@ -772,16 +721,21 @@ var ledgerArtifacts = sqliteCore.sqliteTable(
772
721
  columns: [table.tenantId, table.projectId],
773
722
  foreignColumns: [projects.tenantId, projects.id],
774
723
  name: "ledger_artifacts_project_fk"
775
- }).onDelete("cascade")
724
+ }).onDelete("cascade"),
725
+ sqliteCore.index("ledger_artifacts_task_id_idx").on(table.taskId),
726
+ sqliteCore.index("ledger_artifacts_tool_call_id_idx").on(table.toolCallId),
727
+ sqliteCore.index("ledger_artifacts_context_id_idx").on(table.contextId),
728
+ sqliteCore.unique("ledger_artifacts_task_context_name_unique").on(
729
+ table.taskId,
730
+ table.contextId,
731
+ table.name
732
+ )
776
733
  ]
777
734
  );
778
735
  var apiKeys = sqliteCore.sqliteTable(
779
736
  "api_keys",
780
737
  {
781
- id: sqliteCore.text("id").primaryKey(),
782
- tenantId: sqliteCore.text("tenant_id").notNull(),
783
- projectId: sqliteCore.text("project_id").notNull(),
784
- graphId: sqliteCore.text("graph_id").notNull(),
738
+ ...graphScoped,
785
739
  publicId: sqliteCore.text("public_id").notNull().unique(),
786
740
  // Public ID for O(1) lookup (e.g., "abc123def456")
787
741
  keyHash: sqliteCore.text("key_hash").notNull(),
@@ -791,8 +745,7 @@ var apiKeys = sqliteCore.sqliteTable(
791
745
  name: sqliteCore.text("name"),
792
746
  lastUsedAt: sqliteCore.text("last_used_at"),
793
747
  expiresAt: sqliteCore.text("expires_at"),
794
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
795
- updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
748
+ ...timestamps
796
749
  },
797
750
  (t) => [
798
751
  sqliteCore.foreignKey({
@@ -813,16 +766,13 @@ var apiKeys = sqliteCore.sqliteTable(
813
766
  var credentialReferences = sqliteCore.sqliteTable(
814
767
  "credential_references",
815
768
  {
816
- tenantId: sqliteCore.text("tenant_id").notNull(),
817
- projectId: sqliteCore.text("project_id").notNull(),
818
- id: sqliteCore.text("id").notNull(),
769
+ ...projectScoped,
819
770
  type: sqliteCore.text("type").notNull(),
820
771
  // Implementation type: 'keychain', 'nango', 'memory', etc.
821
772
  credentialStoreId: sqliteCore.text("credential_store_id").notNull(),
822
773
  // Maps to framework.getCredentialStore(id)
823
774
  retrievalParams: sqliteCore.blob("retrieval_params", { mode: "json" }).$type(),
824
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
825
- updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
775
+ ...timestamps
826
776
  },
827
777
  (t) => [
828
778
  sqliteCore.primaryKey({ columns: [t.tenantId, t.projectId, t.id] }),
@@ -833,18 +783,6 @@ var credentialReferences = sqliteCore.sqliteTable(
833
783
  }).onDelete("cascade")
834
784
  ]
835
785
  );
836
- var ledgerArtifactsTaskIdIdx = sqliteCore.index("ledger_artifacts_task_id_idx").on(
837
- ledgerArtifacts.taskId
838
- );
839
- var ledgerArtifactsToolCallIdIdx = sqliteCore.index("ledger_artifacts_tool_call_id_idx").on(
840
- ledgerArtifacts.toolCallId
841
- );
842
- var ledgerArtifactsContextIdIdx = sqliteCore.index("ledger_artifacts_context_id_idx").on(
843
- ledgerArtifacts.contextId
844
- );
845
- var ledgerArtifactsTaskContextNameUnique = sqliteCore.unique(
846
- "ledger_artifacts_task_context_name_unique"
847
- ).on(ledgerArtifacts.taskId, ledgerArtifacts.contextId, ledgerArtifacts.name);
848
786
  var tasksRelations = drizzleOrm.relations(tasks, ({ one, many }) => ({
849
787
  // A task belongs to one project
850
788
  project: one(projects, {
@@ -870,37 +808,24 @@ var tasksRelations = drizzleOrm.relations(tasks, ({ one, many }) => ({
870
808
  ledgerArtifacts: many(ledgerArtifacts)
871
809
  }));
872
810
  var projectsRelations = drizzleOrm.relations(projects, ({ many }) => ({
873
- // A project can have many agents
874
811
  agents: many(agents),
875
- // A project can have many agent graphs
876
812
  agentGraphs: many(agentGraph),
877
- // A project can have many tools
878
813
  tools: many(tools),
879
- // A project can have many context configs
880
814
  contextConfigs: many(contextConfigs),
881
- // A project can have many external agents
882
815
  externalAgents: many(externalAgents),
883
- // A project can have many conversations
884
816
  conversations: many(conversations),
885
- // A project can have many tasks
886
817
  tasks: many(tasks),
887
- // A project can have many data components
888
818
  dataComponents: many(dataComponents),
889
- // A project can have many artifact components
890
819
  artifactComponents: many(artifactComponents),
891
- // A project can have many ledger artifacts
892
820
  ledgerArtifacts: many(ledgerArtifacts),
893
- // A project can have many credential references
894
821
  credentialReferences: many(credentialReferences)
895
822
  }));
896
823
  var taskRelationsRelations = drizzleOrm.relations(taskRelations, ({ one }) => ({
897
- // Each relation has one parent task
898
824
  parentTask: one(tasks, {
899
825
  fields: [taskRelations.parentTaskId],
900
826
  references: [tasks.id],
901
827
  relationName: "parentTask"
902
828
  }),
903
- // Each relation has one child task
904
829
  childTask: one(tasks, {
905
830
  fields: [taskRelations.childTaskId],
906
831
  references: [tasks.id],
@@ -908,107 +833,85 @@ var taskRelationsRelations = drizzleOrm.relations(taskRelations, ({ one }) => ({
908
833
  })
909
834
  }));
910
835
  var contextConfigsRelations = drizzleOrm.relations(contextConfigs, ({ many, one }) => ({
911
- // A context config belongs to one project
912
836
  project: one(projects, {
913
837
  fields: [contextConfigs.tenantId, contextConfigs.projectId],
914
838
  references: [projects.tenantId, projects.id]
915
839
  }),
916
- // A context config can be used by many agent graphs
917
840
  graphs: many(agentGraph),
918
- // A context config can have many cached entries
919
841
  cache: many(contextCache)
920
842
  }));
921
843
  var contextCacheRelations = drizzleOrm.relations(contextCache, ({ one }) => ({
922
- // Each cache entry belongs to one context config
923
844
  contextConfig: one(contextConfigs, {
924
845
  fields: [contextCache.contextConfigId],
925
846
  references: [contextConfigs.id]
926
847
  })
927
848
  }));
928
849
  var agentsRelations = drizzleOrm.relations(agents, ({ many, one }) => ({
929
- // A context config belongs to one project
930
850
  project: one(projects, {
931
851
  fields: [agents.tenantId, agents.projectId],
932
852
  references: [projects.tenantId, projects.id]
933
853
  }),
934
- // An agent can have many tasks
935
854
  tasks: many(tasks),
936
- // An agent can be the default agent for many graphs
937
855
  defaultForGraphs: many(agentGraph),
938
- // Agent relation tracking
939
856
  sourceRelations: many(agentRelations, {
940
857
  relationName: "sourceRelations"
941
858
  }),
942
859
  targetRelations: many(agentRelations, {
943
860
  relationName: "targetRelations"
944
861
  }),
945
- // Message tracking relations
946
862
  sentMessages: many(messages, {
947
863
  relationName: "sentMessages"
948
864
  }),
949
865
  receivedMessages: many(messages, {
950
866
  relationName: "receivedMessages"
951
867
  }),
952
- // Legacy message association (consider deprecating)
953
868
  associatedMessages: many(messages, {
954
869
  relationName: "associatedAgent"
955
870
  }),
956
871
  toolRelations: many(agentToolRelations),
957
- // Data component relations
958
872
  dataComponentRelations: many(agentDataComponents),
959
- // Artifact component relations
960
873
  artifactComponentRelations: many(agentArtifactComponents)
961
874
  }));
962
875
  var agentGraphRelations = drizzleOrm.relations(agentGraph, ({ one }) => ({
963
- // An agent graph belongs to one project
964
876
  project: one(projects, {
965
877
  fields: [agentGraph.tenantId, agentGraph.projectId],
966
878
  references: [projects.tenantId, projects.id]
967
879
  }),
968
- // An agent graph may have one default agent (optional)
969
880
  defaultAgent: one(agents, {
970
881
  fields: [agentGraph.defaultAgentId],
971
882
  references: [agents.id]
972
883
  }),
973
- // An agent graph can reference one context config
974
884
  contextConfig: one(contextConfigs, {
975
885
  fields: [agentGraph.contextConfigId],
976
886
  references: [contextConfigs.id]
977
887
  })
978
888
  }));
979
889
  var externalAgentsRelations = drizzleOrm.relations(externalAgents, ({ one, many }) => ({
980
- // An external agent belongs to one project
981
890
  project: one(projects, {
982
891
  fields: [externalAgents.tenantId, externalAgents.projectId],
983
892
  references: [projects.tenantId, projects.id]
984
893
  }),
985
- // An external agent can be referenced by many agent relations
986
894
  agentRelations: many(agentRelations),
987
- // An external agent may have one credential reference
988
895
  credentialReference: one(credentialReferences, {
989
896
  fields: [externalAgents.credentialReferenceId],
990
897
  references: [credentialReferences.id]
991
898
  })
992
899
  }));
993
900
  var apiKeysRelations = drizzleOrm.relations(apiKeys, ({ one }) => ({
994
- // An API key belongs to one project
995
901
  project: one(projects, {
996
902
  fields: [apiKeys.tenantId, apiKeys.projectId],
997
903
  references: [projects.tenantId, projects.id]
998
904
  }),
999
- // An API key belongs to one tenant and graph
1000
905
  graph: one(agentGraph, {
1001
906
  fields: [apiKeys.graphId],
1002
907
  references: [agentGraph.id]
1003
908
  })
1004
909
  }));
1005
910
  var agentToolRelationsRelations = drizzleOrm.relations(agentToolRelations, ({ one }) => ({
1006
- // An agent-tool relation belongs to one agent
1007
911
  agent: one(agents, {
1008
912
  fields: [agentToolRelations.agentId],
1009
913
  references: [agents.id]
1010
914
  }),
1011
- // An agent-tool relation belongs to one tool
1012
915
  tool: one(tools, {
1013
916
  fields: [agentToolRelations.toolId],
1014
917
  references: [tools.id]
@@ -1018,35 +921,28 @@ var credentialReferencesRelations = drizzleOrm.relations(credentialReferences, (
1018
921
  tools: many(tools)
1019
922
  }));
1020
923
  var toolsRelations = drizzleOrm.relations(tools, ({ one, many }) => ({
1021
- // A tool belongs to one project
1022
924
  project: one(projects, {
1023
925
  fields: [tools.tenantId, tools.projectId],
1024
926
  references: [projects.tenantId, projects.id]
1025
927
  }),
1026
- // A tool can be used by many agents through agent-tool relations
1027
928
  agentRelations: many(agentToolRelations),
1028
- // A tool may have one credential reference
1029
929
  credentialReference: one(credentialReferences, {
1030
930
  fields: [tools.credentialReferenceId],
1031
931
  references: [credentialReferences.id]
1032
932
  })
1033
933
  }));
1034
934
  var conversationsRelations = drizzleOrm.relations(conversations, ({ one, many }) => ({
1035
- // A conversation belongs to one project
1036
935
  project: one(projects, {
1037
936
  fields: [conversations.tenantId, conversations.projectId],
1038
937
  references: [projects.tenantId, projects.id]
1039
938
  }),
1040
- // A conversation has many messages
1041
939
  messages: many(messages),
1042
- // A conversation has one active agent
1043
940
  activeAgent: one(agents, {
1044
941
  fields: [conversations.activeAgentId],
1045
942
  references: [agents.id]
1046
943
  })
1047
944
  }));
1048
945
  var messagesRelations = drizzleOrm.relations(messages, ({ one, many }) => ({
1049
- // A message belongs to one conversation
1050
946
  conversation: one(conversations, {
1051
947
  fields: [messages.conversationId],
1052
948
  references: [conversations.id]
@@ -1057,114 +953,94 @@ var messagesRelations = drizzleOrm.relations(messages, ({ one, many }) => ({
1057
953
  references: [agents.id],
1058
954
  relationName: "associatedAgent"
1059
955
  }),
1060
- // Sender tracking relations
1061
956
  fromAgent: one(agents, {
1062
957
  fields: [messages.fromAgentId],
1063
958
  references: [agents.id],
1064
959
  relationName: "sentMessages"
1065
960
  }),
1066
- // Recipient tracking relations
1067
961
  toAgent: one(agents, {
1068
962
  fields: [messages.toAgentId],
1069
963
  references: [agents.id],
1070
964
  relationName: "receivedMessages"
1071
965
  }),
1072
- // External agent sender tracking relations
1073
966
  fromExternalAgent: one(externalAgents, {
1074
967
  fields: [messages.fromExternalAgentId],
1075
968
  references: [externalAgents.id],
1076
969
  relationName: "receivedExternalMessages"
1077
970
  }),
1078
- // External agent recipient tracking relations
1079
971
  toExternalAgent: one(externalAgents, {
1080
972
  fields: [messages.toExternalAgentId],
1081
973
  references: [externalAgents.id],
1082
974
  relationName: "sentExternalMessages"
1083
975
  }),
1084
- // A message may be associated with a task
1085
976
  task: one(tasks, {
1086
977
  fields: [messages.taskId],
1087
978
  references: [tasks.id]
1088
979
  }),
1089
- // A message may have a parent message (for threading)
1090
980
  parentMessage: one(messages, {
1091
981
  fields: [messages.parentMessageId],
1092
982
  references: [messages.id],
1093
983
  relationName: "parentChild"
1094
984
  }),
1095
- // A message may have child messages
1096
985
  childMessages: many(messages, {
1097
986
  relationName: "parentChild"
1098
987
  })
1099
988
  }));
1100
989
  var artifactComponentsRelations = drizzleOrm.relations(artifactComponents, ({ many }) => ({
1101
- // An artifact component can be associated with many agents
1102
990
  agentRelations: many(agentArtifactComponents)
1103
991
  }));
1104
992
  var agentArtifactComponentsRelations = drizzleOrm.relations(agentArtifactComponents, ({ one }) => ({
1105
- // An agent-artifact component relation belongs to one agent
1106
993
  agent: one(agents, {
1107
994
  fields: [agentArtifactComponents.agentId],
1108
995
  references: [agents.id]
1109
996
  }),
1110
- // An agent-artifact component relation belongs to one artifact component
1111
997
  artifactComponent: one(artifactComponents, {
1112
998
  fields: [agentArtifactComponents.artifactComponentId],
1113
999
  references: [artifactComponents.id]
1114
1000
  })
1115
1001
  }));
1116
1002
  var dataComponentsRelations = drizzleOrm.relations(dataComponents, ({ many, one }) => ({
1117
- // A data component belongs to one project
1118
1003
  project: one(projects, {
1119
1004
  fields: [dataComponents.tenantId, dataComponents.projectId],
1120
1005
  references: [projects.tenantId, projects.id]
1121
1006
  }),
1122
- // A data component can be associated with many agents
1123
1007
  agentRelations: many(agentDataComponents)
1124
1008
  }));
1125
1009
  var agentDataComponentsRelations = drizzleOrm.relations(agentDataComponents, ({ one }) => ({
1126
- // An agent-data component relation belongs to one agent
1127
1010
  agent: one(agents, {
1128
1011
  fields: [agentDataComponents.agentId],
1129
1012
  references: [agents.id]
1130
1013
  }),
1131
- // An agent-data component relation belongs to one data component
1132
1014
  dataComponent: one(dataComponents, {
1133
1015
  fields: [agentDataComponents.dataComponentId],
1134
1016
  references: [dataComponents.id]
1135
1017
  })
1136
1018
  }));
1137
1019
  var ledgerArtifactsRelations = drizzleOrm.relations(ledgerArtifacts, ({ one }) => ({
1138
- // A ledger artifact belongs to one project
1139
1020
  project: one(projects, {
1140
1021
  fields: [ledgerArtifacts.tenantId, ledgerArtifacts.projectId],
1141
1022
  references: [projects.tenantId, projects.id]
1142
1023
  }),
1143
- // A ledger artifact may be associated with one task
1144
1024
  task: one(tasks, {
1145
1025
  fields: [ledgerArtifacts.taskId],
1146
1026
  references: [tasks.id]
1147
1027
  })
1148
1028
  }));
1149
1029
  var agentRelationsRelations = drizzleOrm.relations(agentRelations, ({ one }) => ({
1150
- // An agent relation belongs to one graph
1151
1030
  graph: one(agentGraph, {
1152
1031
  fields: [agentRelations.graphId],
1153
1032
  references: [agentGraph.id]
1154
1033
  }),
1155
- // An agent relation has one source agent
1156
1034
  sourceAgent: one(agents, {
1157
1035
  fields: [agentRelations.sourceAgentId],
1158
1036
  references: [agents.id],
1159
1037
  relationName: "sourceRelations"
1160
1038
  }),
1161
- // An agent relation may have one target agent (for internal relations)
1162
1039
  targetAgent: one(agents, {
1163
1040
  fields: [agentRelations.targetAgentId],
1164
1041
  references: [agents.id],
1165
1042
  relationName: "targetRelations"
1166
1043
  }),
1167
- // An agent relation may have one external agent (for external relations)
1168
1044
  externalAgent: one(externalAgents, {
1169
1045
  fields: [agentRelations.externalAgentId],
1170
1046
  references: [externalAgents.id]
@@ -11212,11 +11088,7 @@ exports.isInternalAgent = isInternalAgent;
11212
11088
  exports.isValidHttpRequest = isValidHttpRequest;
11213
11089
  exports.isValidResourceId = isValidResourceId;
11214
11090
  exports.ledgerArtifacts = ledgerArtifacts;
11215
- exports.ledgerArtifactsContextIdIdx = ledgerArtifactsContextIdIdx;
11216
11091
  exports.ledgerArtifactsRelations = ledgerArtifactsRelations;
11217
- exports.ledgerArtifactsTaskContextNameUnique = ledgerArtifactsTaskContextNameUnique;
11218
- exports.ledgerArtifactsTaskIdIdx = ledgerArtifactsTaskIdIdx;
11219
- exports.ledgerArtifactsToolCallIdIdx = ledgerArtifactsToolCallIdIdx;
11220
11092
  exports.listAgentGraphs = listAgentGraphs;
11221
11093
  exports.listAgentGraphsPaginated = listAgentGraphsPaginated;
11222
11094
  exports.listAgentRelations = listAgentRelations;