@sixb/core 0.1.0 → 0.1.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.
Files changed (214) hide show
  1. package/README.md +24 -4
  2. package/dist/actions/index.js +17 -17
  3. package/dist/actions/worker.js +7 -7
  4. package/dist/actions/worker.js.map +1 -1
  5. package/dist/agents/adapters.d.ts.map +1 -1
  6. package/dist/agents/builders.d.ts +8 -1
  7. package/dist/agents/builders.d.ts.map +1 -1
  8. package/dist/agents/context.js +2 -2
  9. package/dist/agents/errors.d.ts +15 -0
  10. package/dist/agents/errors.d.ts.map +1 -1
  11. package/dist/agents/index.d.ts +4 -4
  12. package/dist/agents/index.d.ts.map +1 -1
  13. package/dist/agents/index.js +30 -11
  14. package/dist/agents/index.js.map +1 -1
  15. package/dist/agents/tool-definition.d.ts +9 -0
  16. package/dist/agents/tool-definition.d.ts.map +1 -0
  17. package/dist/agents/types.d.ts +64 -0
  18. package/dist/agents/types.d.ts.map +1 -1
  19. package/dist/agents/validation.d.ts +14 -1
  20. package/dist/agents/validation.d.ts.map +1 -1
  21. package/dist/auth/index.js +4 -4
  22. package/dist/authorization/index.js +3 -3
  23. package/dist/blob-storage/browser.js +3 -2
  24. package/dist/blob-storage/browser.js.map +1 -1
  25. package/dist/blob-storage/index.js +4 -3
  26. package/dist/blob-storage/index.js.map +1 -1
  27. package/dist/blob-storage/validation.d.ts.map +1 -1
  28. package/dist/bootstrap/index.js +25 -25
  29. package/dist/broker/index.js +2 -2
  30. package/dist/{chunk-590dejbp.js → chunk-4hwxq5e6.js} +1 -1
  31. package/dist/{chunk-wj01s5hr.js → chunk-4tvj3ate.js} +1 -1
  32. package/dist/{chunk-tsk2bxs3.js → chunk-53s4asfm.js} +13 -13
  33. package/dist/{chunk-tsk2bxs3.js.map → chunk-53s4asfm.js.map} +3 -3
  34. package/dist/{chunk-8r8cw2xw.js → chunk-63te770v.js} +40 -5
  35. package/dist/{chunk-8r8cw2xw.js.map → chunk-63te770v.js.map} +3 -3
  36. package/dist/{chunk-vj723r3p.js → chunk-6rzdtvn5.js} +1 -1
  37. package/dist/{chunk-5yny9z0e.js → chunk-6zrpewy4.js} +1 -1
  38. package/dist/{chunk-nvamz5dv.js → chunk-86459jn0.js} +294 -22
  39. package/dist/chunk-86459jn0.js.map +22 -0
  40. package/dist/{chunk-p6r5g77m.js → chunk-8kv2sez0.js} +1 -1
  41. package/dist/{chunk-k41ajtz7.js → chunk-9k3hgv8h.js} +1 -1
  42. package/dist/{chunk-jdwx7vzs.js → chunk-avppcgt6.js} +7 -7
  43. package/dist/{chunk-jdwx7vzs.js.map → chunk-avppcgt6.js.map} +1 -1
  44. package/dist/{chunk-2gpr6jsz.js → chunk-b1bqvhpe.js} +2 -2
  45. package/dist/{chunk-pv1yad91.js → chunk-b5dp7gaf.js} +17 -90
  46. package/dist/{chunk-pv1yad91.js.map → chunk-b5dp7gaf.js.map} +5 -6
  47. package/dist/{chunk-1vffvydj.js → chunk-be9vm29v.js} +6 -6
  48. package/dist/chunk-be9vm29v.js.map +10 -0
  49. package/dist/{chunk-wxhdnwh4.js → chunk-bh8bwma3.js} +1 -1
  50. package/dist/{chunk-0psb6kdw.js → chunk-btcsywk4.js} +12 -16
  51. package/dist/{chunk-0psb6kdw.js.map → chunk-btcsywk4.js.map} +3 -3
  52. package/dist/{chunk-0fygrz37.js → chunk-exrfbt2d.js} +1 -1
  53. package/dist/{chunk-c3zd880g.js → chunk-f6kyyeef.js} +2 -2
  54. package/dist/{chunk-q4qzq0ea.js → chunk-hb9xcx9c.js} +3 -3
  55. package/dist/{chunk-4pycxcj3.js → chunk-hz8m927w.js} +6 -9
  56. package/dist/{chunk-4pycxcj3.js.map → chunk-hz8m927w.js.map} +3 -3
  57. package/dist/{chunk-btpe64e4.js → chunk-m9w0artv.js} +1 -1
  58. package/dist/{chunk-45tw90k7.js → chunk-md9jbrm9.js} +1 -1
  59. package/dist/{chunk-dhmj53mx.js → chunk-nbywkytr.js} +3 -3
  60. package/dist/{chunk-t358gywy.js → chunk-p7vj8xgb.js} +8 -8
  61. package/dist/{chunk-2s6sydsh.js → chunk-qzyemcj7.js} +294 -4
  62. package/dist/chunk-qzyemcj7.js.map +13 -0
  63. package/dist/{chunk-r65yscvk.js → chunk-r82k4z7z.js} +131 -13
  64. package/dist/chunk-r82k4z7z.js.map +13 -0
  65. package/dist/{chunk-aebzcsxr.js → chunk-raq0x6bd.js} +11 -9
  66. package/dist/{chunk-aebzcsxr.js.map → chunk-raq0x6bd.js.map} +4 -4
  67. package/dist/{chunk-hsv43v58.js → chunk-rgzed50y.js} +77 -22
  68. package/dist/chunk-rgzed50y.js.map +22 -0
  69. package/dist/{chunk-yvef9xwc.js → chunk-rjqm6ksg.js} +7 -7
  70. package/dist/{chunk-f2b5e2gf.js → chunk-sb0shdvv.js} +18 -3
  71. package/dist/{chunk-f2b5e2gf.js.map → chunk-sb0shdvv.js.map} +3 -3
  72. package/dist/{chunk-dcgrzj1t.js → chunk-xt6qx9sh.js} +1 -1
  73. package/dist/{chunk-mx84y05q.js → chunk-y2ygpd0m.js} +2 -2
  74. package/dist/{chunk-yxss87qa.js → chunk-yn947ck3.js} +1 -1
  75. package/dist/datasets/builders.d.ts +18 -5
  76. package/dist/datasets/builders.d.ts.map +1 -1
  77. package/dist/datasets/changes.d.ts +18 -0
  78. package/dist/datasets/changes.d.ts.map +1 -0
  79. package/dist/datasets/index.d.ts +3 -1
  80. package/dist/datasets/index.d.ts.map +1 -1
  81. package/dist/datasets/types.d.ts +2 -0
  82. package/dist/datasets/types.d.ts.map +1 -1
  83. package/dist/datasets/validation.d.ts.map +1 -1
  84. package/dist/events/index.js +2 -2
  85. package/dist/http/api-routes.d.ts.map +1 -1
  86. package/dist/http/index.js +1 -1
  87. package/dist/index.d.ts +6 -6
  88. package/dist/index.d.ts.map +1 -1
  89. package/dist/index.js +64 -58
  90. package/dist/index.js.map +1 -1
  91. package/dist/json.d.ts +8 -1
  92. package/dist/json.d.ts.map +1 -1
  93. package/dist/lake-storage/definition-updates.d.ts.map +1 -1
  94. package/dist/lake-storage/in-memory.d.ts +15 -1
  95. package/dist/lake-storage/in-memory.d.ts.map +1 -1
  96. package/dist/lake-storage/index.d.ts +3 -1
  97. package/dist/lake-storage/index.d.ts.map +1 -1
  98. package/dist/lake-storage/index.js +15 -7
  99. package/dist/lake-storage/index.js.map +1 -1
  100. package/dist/lake-storage/merge-validation.d.ts +10 -0
  101. package/dist/lake-storage/merge-validation.d.ts.map +1 -0
  102. package/dist/lake-storage/merge.d.ts +32 -0
  103. package/dist/lake-storage/merge.d.ts.map +1 -0
  104. package/dist/lake-storage/types.d.ts +3 -1
  105. package/dist/lake-storage/types.d.ts.map +1 -1
  106. package/dist/logging/index.js +3 -3
  107. package/dist/logging/types.js +2 -2
  108. package/dist/materialization/index.js +2 -2
  109. package/dist/materializer/index.js +15 -15
  110. package/dist/materializer/index.js.map +1 -1
  111. package/dist/objects/index.js +17 -17
  112. package/dist/objects/query/index.js +8 -8
  113. package/dist/ontology/index.js +5 -5
  114. package/dist/ontology/internal.js +7 -6
  115. package/dist/ontology/internal.js.map +3 -3
  116. package/dist/ontology/validation/normalize.d.ts.map +1 -1
  117. package/dist/projections/internal.js +4 -4
  118. package/dist/runtime/sixb.d.ts.map +1 -1
  119. package/dist/storage/index.d.ts +1 -1
  120. package/dist/storage/index.d.ts.map +1 -1
  121. package/dist/storage/index.js +16 -16
  122. package/dist/storage/index.js.map +1 -1
  123. package/dist/storage/ontology/provider.js +4 -4
  124. package/dist/storage/sync-runs/index.d.ts +1 -1
  125. package/dist/storage/sync-runs/index.d.ts.map +1 -1
  126. package/dist/storage/sync-runs/types.d.ts +7 -3
  127. package/dist/storage/sync-runs/types.d.ts.map +1 -1
  128. package/dist/storage/types.d.ts +1 -1
  129. package/dist/storage/types.d.ts.map +1 -1
  130. package/dist/storage/workflow-runs/in-memory.d.ts.map +1 -1
  131. package/dist/storage/workflow-runs/types.d.ts +2 -0
  132. package/dist/storage/workflow-runs/types.d.ts.map +1 -1
  133. package/dist/syncs/builders.d.ts +11 -3
  134. package/dist/syncs/builders.d.ts.map +1 -1
  135. package/dist/syncs/index.d.ts +1 -1
  136. package/dist/syncs/index.d.ts.map +1 -1
  137. package/dist/syncs/types.d.ts +24 -19
  138. package/dist/syncs/types.d.ts.map +1 -1
  139. package/dist/syncs/validation.d.ts +14 -0
  140. package/dist/syncs/validation.d.ts.map +1 -0
  141. package/dist/testing/index.d.ts +1 -0
  142. package/dist/testing/index.d.ts.map +1 -1
  143. package/dist/testing/index.js +837 -583
  144. package/dist/testing/index.js.map +5 -4
  145. package/dist/testing/lake-merge-storage-contract.d.ts +7 -0
  146. package/dist/testing/lake-merge-storage-contract.d.ts.map +1 -0
  147. package/dist/testing/lake-storage-contract.d.ts.map +1 -1
  148. package/dist/workflows/index.js +23 -23
  149. package/package.json +1 -1
  150. package/src/agents/adapters.ts +1 -9
  151. package/src/agents/builders.ts +53 -3
  152. package/src/agents/errors.ts +22 -0
  153. package/src/agents/index.ts +22 -2
  154. package/src/agents/prompt.ts +2 -2
  155. package/src/agents/tool-definition.ts +93 -0
  156. package/src/agents/types.ts +101 -0
  157. package/src/agents/validation.ts +287 -3
  158. package/src/blob-storage/validation.ts +2 -10
  159. package/src/datasets/builders.ts +49 -5
  160. package/src/datasets/changes.ts +13 -0
  161. package/src/datasets/index.ts +3 -0
  162. package/src/datasets/types.ts +5 -0
  163. package/src/datasets/validation.ts +53 -11
  164. package/src/http/api-routes.ts +39 -4
  165. package/src/index.ts +18 -1
  166. package/src/json.ts +11 -4
  167. package/src/lake-storage/definition-updates.ts +21 -0
  168. package/src/lake-storage/in-memory.ts +284 -2
  169. package/src/lake-storage/index.ts +14 -0
  170. package/src/lake-storage/merge-validation.ts +117 -0
  171. package/src/lake-storage/merge.ts +35 -0
  172. package/src/lake-storage/types.ts +3 -1
  173. package/src/ontology/json-schema.ts +2 -1
  174. package/src/ontology/validation/normalize.ts +9 -15
  175. package/src/runtime/sixb.ts +16 -1
  176. package/src/storage/index.ts +1 -0
  177. package/src/storage/sync-runs/in-memory.ts +2 -2
  178. package/src/storage/sync-runs/index.ts +1 -0
  179. package/src/storage/sync-runs/types.ts +9 -4
  180. package/src/storage/types.ts +1 -0
  181. package/src/storage/workflow-runs/in-memory.ts +2 -0
  182. package/src/storage/workflow-runs/types.ts +2 -0
  183. package/src/syncs/builders.ts +31 -13
  184. package/src/syncs/index.ts +1 -0
  185. package/src/syncs/types.ts +44 -18
  186. package/src/syncs/validation.ts +77 -0
  187. package/src/testing/index.ts +4 -0
  188. package/src/testing/lake-merge-storage-contract.ts +302 -0
  189. package/src/testing/lake-storage-contract.ts +23 -0
  190. package/src/workflows/snapshot.ts +1 -10
  191. package/dist/chunk-1vffvydj.js.map +0 -10
  192. package/dist/chunk-2s6sydsh.js.map +0 -12
  193. package/dist/chunk-hsv43v58.js.map +0 -21
  194. package/dist/chunk-nvamz5dv.js.map +0 -21
  195. package/dist/chunk-r65yscvk.js.map +0 -11
  196. /package/dist/{chunk-590dejbp.js.map → chunk-4hwxq5e6.js.map} +0 -0
  197. /package/dist/{chunk-wj01s5hr.js.map → chunk-4tvj3ate.js.map} +0 -0
  198. /package/dist/{chunk-vj723r3p.js.map → chunk-6rzdtvn5.js.map} +0 -0
  199. /package/dist/{chunk-5yny9z0e.js.map → chunk-6zrpewy4.js.map} +0 -0
  200. /package/dist/{chunk-p6r5g77m.js.map → chunk-8kv2sez0.js.map} +0 -0
  201. /package/dist/{chunk-k41ajtz7.js.map → chunk-9k3hgv8h.js.map} +0 -0
  202. /package/dist/{chunk-2gpr6jsz.js.map → chunk-b1bqvhpe.js.map} +0 -0
  203. /package/dist/{chunk-wxhdnwh4.js.map → chunk-bh8bwma3.js.map} +0 -0
  204. /package/dist/{chunk-0fygrz37.js.map → chunk-exrfbt2d.js.map} +0 -0
  205. /package/dist/{chunk-c3zd880g.js.map → chunk-f6kyyeef.js.map} +0 -0
  206. /package/dist/{chunk-q4qzq0ea.js.map → chunk-hb9xcx9c.js.map} +0 -0
  207. /package/dist/{chunk-btpe64e4.js.map → chunk-m9w0artv.js.map} +0 -0
  208. /package/dist/{chunk-45tw90k7.js.map → chunk-md9jbrm9.js.map} +0 -0
  209. /package/dist/{chunk-dhmj53mx.js.map → chunk-nbywkytr.js.map} +0 -0
  210. /package/dist/{chunk-t358gywy.js.map → chunk-p7vj8xgb.js.map} +0 -0
  211. /package/dist/{chunk-yvef9xwc.js.map → chunk-rjqm6ksg.js.map} +0 -0
  212. /package/dist/{chunk-dcgrzj1t.js.map → chunk-xt6qx9sh.js.map} +0 -0
  213. /package/dist/{chunk-mx84y05q.js.map → chunk-y2ygpd0m.js.map} +0 -0
  214. /package/dist/{chunk-yxss87qa.js.map → chunk-yn947ck3.js.map} +0 -0
@@ -5,17 +5,17 @@ import {
5
5
  import {
6
6
  createObjectSet,
7
7
  exports_service
8
- } from "./chunk-t358gywy.js";
8
+ } from "./chunk-p7vj8xgb.js";
9
9
  import {
10
10
  createOntologyMutationRuntime,
11
11
  registerOntologyMutationRuntime
12
12
  } from "./chunk-v5c085yp.js";
13
13
  import {
14
14
  registerProjectionRegistry
15
- } from "./chunk-590dejbp.js";
15
+ } from "./chunk-4hwxq5e6.js";
16
16
  import {
17
17
  LogsRuntime
18
- } from "./chunk-c3zd880g.js";
18
+ } from "./chunk-f6kyyeef.js";
19
19
  import {
20
20
  ConnectorError,
21
21
  ConnectorNotFoundError,
@@ -38,11 +38,11 @@ import {
38
38
  requestPipelineRun,
39
39
  requestSyncRun,
40
40
  validateRulesAtStartup
41
- } from "./chunk-pv1yad91.js";
41
+ } from "./chunk-b5dp7gaf.js";
42
42
  import {
43
43
  WorkflowsRuntime,
44
44
  validateWorkflowsAtStartup
45
- } from "./chunk-0psb6kdw.js";
45
+ } from "./chunk-btcsywk4.js";
46
46
  import {
47
47
  validateSchedulesAtStartup
48
48
  } from "./chunk-867jxh7c.js";
@@ -51,47 +51,48 @@ import {
51
51
  } from "./chunk-k6j72mtt.js";
52
52
  import {
53
53
  assertDatasetDefinition
54
- } from "./chunk-r65yscvk.js";
54
+ } from "./chunk-r82k4z7z.js";
55
55
  import {
56
56
  EventsRuntime,
57
57
  OntologyOutboxDispatcher
58
- } from "./chunk-yxss87qa.js";
58
+ } from "./chunk-yn947ck3.js";
59
59
  import {
60
60
  ActionRegistry,
61
61
  ActionsRuntime
62
- } from "./chunk-dhmj53mx.js";
62
+ } from "./chunk-nbywkytr.js";
63
63
  import {
64
64
  requestAction,
65
65
  requestActionAndWait
66
- } from "./chunk-jdwx7vzs.js";
66
+ } from "./chunk-avppcgt6.js";
67
67
  import {
68
68
  ProjectionRegistry,
69
69
  createOntologyMaterializer
70
- } from "./chunk-yvef9xwc.js";
70
+ } from "./chunk-rjqm6ksg.js";
71
71
  import {
72
72
  checkStorageSchema,
73
73
  isMigrationCapableStorage
74
- } from "./chunk-aebzcsxr.js";
75
- import {
76
- OntologyRegistry
77
- } from "./chunk-mx84y05q.js";
74
+ } from "./chunk-raq0x6bd.js";
78
75
  import {
79
76
  attachSixbErrorReporter,
80
77
  reportEventDeliveryFailure,
81
78
  shareSixbErrorReporter
82
79
  } from "./chunk-t72dvahb.js";
83
- import {
84
- assertObjectTypeRegistered
85
- } from "./chunk-tsk2bxs3.js";
86
80
  import {
87
81
  AgentsRuntime,
88
- validateAgentGroupReferences
89
- } from "./chunk-nvamz5dv.js";
82
+ validateAgentGroupReferences,
83
+ validateAgentToolsAtStartup
84
+ } from "./chunk-86459jn0.js";
85
+ import {
86
+ OntologyRegistry
87
+ } from "./chunk-y2ygpd0m.js";
88
+ import {
89
+ assertObjectTypeRegistered
90
+ } from "./chunk-53s4asfm.js";
90
91
  import {
91
92
  APPLICATION_IDS,
92
93
  AuthRuntime,
93
94
  validateSecurityDefinitionsAtStartup
94
- } from "./chunk-dcgrzj1t.js";
95
+ } from "./chunk-xt6qx9sh.js";
95
96
  import {
96
97
  AuthRuntimeError,
97
98
  isMagicLinkAuthStrategy,
@@ -102,7 +103,7 @@ import {
102
103
  canViewEvent,
103
104
  isAllowed,
104
105
  resolveRoleGrants
105
- } from "./chunk-0fygrz37.js";
106
+ } from "./chunk-exrfbt2d.js";
106
107
  // src/webhooks/errors.ts
107
108
  class WebhookValidationError extends Error {
108
109
  name = "WebhookValidationError";
@@ -699,6 +700,50 @@ function createRuntimeSecurityRegistry(input) {
699
700
  return new RuntimeSecurityRegistry(securityDefinitions.groupsById, securityDefinitions.rolesById, securityDefinitions.membershipPoliciesById, resolvedRoles);
700
701
  }
701
702
 
703
+ // src/syncs/validation.ts
704
+ function validateKeyedDatasetWriterTopology(input) {
705
+ for (const sync of input.syncs) {
706
+ const dataset = input.datasetsById.get(sync.target.dataset.id);
707
+ if (sync.config.mode === "merge" && dataset?.primaryKey === undefined) {
708
+ throw new SyncValidationError(`[Sixb] Merge sync '${sync.id}' targets dataset '${sync.target.dataset.id}', which must define a primaryKey.`);
709
+ }
710
+ }
711
+ const firstWriterByDataset = new Map;
712
+ for (const writer of datasetWriters(input.syncs, input.pipelines)) {
713
+ const dataset = input.datasetsById.get(writer.datasetId);
714
+ if (dataset?.primaryKey === undefined)
715
+ continue;
716
+ const first = firstWriterByDataset.get(writer.datasetId);
717
+ if (!first) {
718
+ firstWriterByDataset.set(writer.datasetId, writer);
719
+ continue;
720
+ }
721
+ throw new SyncValidationError(`[Sixb] Keyed dataset '${writer.datasetId}' has multiple registered writers: ${first.label} and ${writer.label}. V1 allows one writer per keyed dataset.`);
722
+ }
723
+ }
724
+ function validateMergeSyncProjectionSafety(input) {
725
+ const mergeSyncByDataset = new Map(input.syncs.filter((sync) => sync.config.mode === "merge").map((sync) => [sync.target.dataset.id, sync]));
726
+ for (const projection of input.telemetryProjections) {
727
+ const sync = mergeSyncByDataset.get(projection.datasetId);
728
+ if (!sync)
729
+ continue;
730
+ throw new SyncValidationError(`[Sixb] Telemetry projection '${projection.id}' cannot read merge-written dataset '${projection.datasetId}' from sync '${sync.id}'. V1 merge syncs support object and link replacement projections only.`);
731
+ }
732
+ }
733
+ function* datasetWriters(syncs, pipelines) {
734
+ for (const sync of syncs) {
735
+ yield { datasetId: sync.target.dataset.id, label: `sync '${sync.id}'` };
736
+ }
737
+ for (const pipeline of pipelines) {
738
+ for (const node of pipeline.graph.nodes) {
739
+ yield {
740
+ datasetId: node.step.output.id,
741
+ label: `pipeline '${pipeline.id}' step '${node.step.id}'`
742
+ };
743
+ }
744
+ }
745
+ }
746
+
702
747
  // src/runtime/scoped.ts
703
748
  function createScopedSixb(runtime, deps) {
704
749
  const canListAction = (action) => isAllowed(runtime.authorization, { kind: "action.apply", actionId: action.id }) && (action.binding.kind === "global" || isAllowed(runtime.authorization, {
@@ -921,6 +966,7 @@ class Sixb {
921
966
  this.actionRegistry = new ActionRegistry(options.actions ?? [], this.ontology);
922
967
  const registeredActionIds = new Set(this.actionRegistry.list().map((action) => action.id));
923
968
  const agents = options.agents ?? [];
969
+ validateAgentToolsAtStartup(agents);
924
970
  this.security = createRuntimeSecurityRegistry({
925
971
  groups: options.groups ?? [],
926
972
  roles: options.roles ?? [],
@@ -996,6 +1042,11 @@ class Sixb {
996
1042
  }
997
1043
  this.pipelinesById.set(pipeline.id, pipeline);
998
1044
  }
1045
+ validateKeyedDatasetWriterTopology({
1046
+ datasetsById: this.datasetsById,
1047
+ syncs: [...this.syncsById.values()],
1048
+ pipelines: [...this.pipelinesById.values()]
1049
+ });
999
1050
  validateRulesAtStartup(this.rules, this.ontology);
1000
1051
  for (const rule of this.rules) {
1001
1052
  this.rulesById.set(rule.id, rule);
@@ -1031,6 +1082,10 @@ class Sixb {
1031
1082
  ontology: this.ontology,
1032
1083
  datasetsById: this.datasetsById
1033
1084
  });
1085
+ validateMergeSyncProjectionSafety({
1086
+ syncs: [...this.syncsById.values()],
1087
+ telemetryProjections: this.projectionRegistry.listTelemetryProjections()
1088
+ });
1034
1089
  registerProjectionRegistry(this, this.projectionRegistry);
1035
1090
  const materializer = createOntologyMaterializer({
1036
1091
  projectId: this.projectId,
@@ -1387,4 +1442,4 @@ async function createSixb(options) {
1387
1442
  }
1388
1443
  export { WebhookValidationError, defineWebhook, webhookConnector, UnverifiedWebhookError, resolveWebhookVerification, warnUnverifiedWebhook, Sixb, createSixb };
1389
1444
 
1390
- //# debugId=1140B1FB403AF17D64756E2164756E21
1445
+ //# debugId=7B1968C15C65FC4364756E2164756E21
@@ -0,0 +1,22 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/webhooks/errors.ts", "../src/webhooks/builders.ts", "../src/webhooks/connector.ts", "../src/webhooks/registry.ts", "../src/webhooks/unverified.ts", "../src/runtime/create.ts", "../src/runtime/sixb.ts", "../src/connectors/runtime.ts", "../src/maintenance/ontology-maintenance.ts", "../src/security/runtime.ts", "../src/syncs/validation.ts", "../src/runtime/scoped.ts", "../src/runtime/storage-readiness.ts"],
4
+ "sourcesContent": [
5
+ "export class WebhookValidationError extends Error {\n readonly name = \"WebhookValidationError\"\n}\n",
6
+ "import { WebhookValidationError } from \"./errors\"\nimport type {\n WebhookBodyParser,\n WebhookBodySchema,\n WebhookDefinition,\n WebhookHandlerContext,\n WebhookHandlerResult,\n WebhookIdempotencyKeyResolver,\n WebhookVerifyContext,\n} from \"./types\"\n\ntype WebhookHandler<TBody, TClient> = (\n ctx: WebhookHandlerContext<TBody, TClient>\n) => Promise<WebhookHandlerResult> | WebhookHandlerResult\n\ntype WebhookVerifyHandler = (ctx: WebhookVerifyContext) => Promise<void> | void\n\ninterface WebhookDraft<TBody> {\n readonly id: string\n readonly method: \"POST\"\n readonly body: WebhookBodyParser<TBody>\n readonly verify?: WebhookVerifyHandler\n readonly idempotencyKey?: WebhookIdempotencyKeyResolver<TBody>\n}\n\n/** Define an inbound webhook owned by a connector adapter. */\nexport function defineWebhook(id: string): WebhookMethodBuilder {\n assertNonEmpty(id, \"Webhook id\")\n return new WebhookMethodBuilder(id)\n}\n\nexport class WebhookMethodBuilder<TClient = unknown> {\n constructor(private readonly id: string) {}\n\n post(): WebhookBodyBuilder<TClient> {\n return new WebhookBodyBuilder(this.id, \"POST\")\n }\n}\n\nexport class WebhookBodyBuilder<TClient = unknown> {\n constructor(\n private readonly id: string,\n private readonly method: \"POST\"\n ) {}\n\n /**\n * Decode JSON and keep the handler body as unknown.\n *\n * Prefer `.json(schema)` for provider payloads that have a known shape.\n */\n json(): WebhookBuilder<unknown, TClient>\n /** Decode JSON, validate or normalize it at runtime, and infer the handler body. */\n json<TBody>(schema: WebhookBodySchema<TBody>): WebhookBuilder<TBody, TClient>\n json<TBody>(schema?: WebhookBodySchema<TBody>): WebhookBuilder<TBody | unknown, TClient> {\n if (schema !== undefined && typeof schema.parse !== \"function\") {\n throw new WebhookValidationError(\"[Sixb] Webhook JSON schema must provide parse(value).\")\n }\n\n return new WebhookBuilder({\n id: this.id,\n method: this.method,\n body: {\n format: \"json\",\n parse(value: unknown) {\n return schema ? schema.parse(value) : value\n },\n },\n })\n }\n\n text(): WebhookBuilder<string, TClient> {\n return new WebhookBuilder({\n id: this.id,\n method: this.method,\n body: {\n format: \"text\",\n parse(value: unknown) {\n if (typeof value !== \"string\") {\n throw new Error(\"Expected webhook body to be text.\")\n }\n\n return value\n },\n },\n })\n }\n\n raw(): WebhookBuilder<Uint8Array, TClient> {\n return new WebhookBuilder({\n id: this.id,\n method: this.method,\n body: {\n format: \"raw\",\n parse(value: unknown) {\n if (!(value instanceof Uint8Array)) {\n throw new Error(\"Expected webhook body to be raw bytes.\")\n }\n\n return value\n },\n },\n })\n }\n}\n\nexport class WebhookBuilder<TBody, TClient = unknown> {\n constructor(private readonly draft: WebhookDraft<TBody>) {}\n\n verify(verify: WebhookVerifyHandler): WebhookBuilder<TBody, TClient> {\n if (typeof verify !== \"function\") {\n throw new WebhookValidationError(\"[Sixb] Webhook verify must be a function.\")\n }\n\n return new WebhookBuilder({\n ...this.draft,\n verify,\n })\n }\n\n idempotencyKey(resolver: WebhookIdempotencyKeyResolver<TBody>): WebhookBuilder<TBody, TClient> {\n if (typeof resolver !== \"function\") {\n throw new WebhookValidationError(\"[Sixb] Webhook idempotencyKey must be a function.\")\n }\n\n return new WebhookBuilder({\n ...this.draft,\n idempotencyKey: resolver,\n })\n }\n\n handle<TNextClient = TClient>(\n handle: WebhookHandler<TBody, TNextClient>\n ): WebhookDefinition<TBody, TNextClient> {\n if (typeof handle !== \"function\") {\n throw new WebhookValidationError(\"[Sixb] Webhook handle must be a function.\")\n }\n\n return {\n kind: \"webhook\",\n id: this.draft.id,\n method: this.draft.method,\n body: this.draft.body,\n idempotencyKey: this.draft.idempotencyKey,\n verify: this.draft.verify,\n handle,\n }\n }\n}\n\nfunction assertNonEmpty(value: string, field: string): void {\n if (!value.trim()) {\n throw new WebhookValidationError(`[Sixb] ${field} must not be empty.`)\n }\n}\n",
7
+ "import type { ConnectorAdapter } from \"../connectors/types\"\nimport type { WebhookDefinition } from \"./types\"\n\nexport interface WebhookConnectorClient {\n readonly kind: \"webhook\"\n}\n\n/** Connector adapter for inbound-only integrations that expose no outbound client. */\nexport function webhookConnector(options: {\n readonly webhooks: readonly WebhookDefinition<unknown, WebhookConnectorClient>[]\n}): ConnectorAdapter<\"webhook\", WebhookConnectorClient> {\n return {\n type: \"webhook\",\n webhooks: options.webhooks,\n connect() {\n return { kind: \"webhook\" }\n },\n }\n}\n",
8
+ "import type { ConnectorDefinition } from \"../connectors/types\"\nimport { WebhookValidationError } from \"./errors\"\nimport type { RegisteredWebhook, WebhookDefinition } from \"./types\"\n\nexport function registerWebhooks(connectors: readonly ConnectorDefinition[]): {\n readonly webhooks: readonly RegisteredWebhook[]\n} {\n const registered: RegisteredWebhook[] = []\n const routes = new Map<string, RegisteredWebhook>()\n\n for (const connector of connectors) {\n const webhooks = connector.adapter.webhooks ?? []\n if (!Array.isArray(webhooks)) {\n throw new WebhookValidationError(\n `[Sixb] Connector '${connector.id}' webhooks must be an array when provided.`\n )\n }\n\n const ids = new Set<string>()\n for (const webhook of webhooks) {\n assertValidWebhook(connector.id, webhook)\n\n if (ids.has(webhook.id)) {\n throw new WebhookValidationError(\n `[Sixb] Duplicate webhook id '${webhook.id}' for connector '${connector.id}'.`\n )\n }\n ids.add(webhook.id)\n\n const route = webhookRoute(connector.id, webhook.id)\n const duplicate = routes.get(route)\n if (duplicate) {\n throw new WebhookValidationError(\n `[Sixb] Duplicate webhook route '${route}' for connectors '${duplicate.connector.id}' and '${connector.id}'.`\n )\n }\n\n const registeredWebhook = {\n connector,\n webhook,\n route,\n } satisfies RegisteredWebhook\n\n routes.set(route, registeredWebhook)\n registered.push(registeredWebhook)\n }\n }\n\n return {\n webhooks: registered,\n }\n}\n\nexport function webhookRoute(connectorId: string, webhookId: string): string {\n return `/api/webhooks/${connectorId}/${webhookId}`\n}\n\nfunction assertValidWebhook(\n connectorId: string,\n webhook: unknown\n): asserts webhook is WebhookDefinition {\n if (!isRecord(webhook)) {\n throw new WebhookValidationError(`[Sixb] Connector '${connectorId}' has an invalid webhook.`)\n }\n\n if (webhook.kind !== \"webhook\") {\n throw new WebhookValidationError(\n `[Sixb] Connector '${connectorId}' webhook must be created with defineWebhook(...).`\n )\n }\n\n if (typeof webhook.id !== \"string\" || !webhook.id.trim()) {\n throw new WebhookValidationError(\n `[Sixb] Connector '${connectorId}' webhook id must not be empty.`\n )\n }\n\n if (webhook.method !== \"POST\") {\n throw new WebhookValidationError(\n `[Sixb] Webhook '${connectorId}/${webhook.id}' must use method POST.`\n )\n }\n\n if (!isRecord(webhook.body)) {\n throw new WebhookValidationError(\n `[Sixb] Webhook '${connectorId}/${webhook.id}' body is required.`\n )\n }\n\n if (\n webhook.body.format !== \"json\" &&\n webhook.body.format !== \"text\" &&\n webhook.body.format !== \"raw\"\n ) {\n throw new WebhookValidationError(\n `[Sixb] Webhook '${connectorId}/${webhook.id}' body format must be json, text, or raw.`\n )\n }\n\n if (typeof webhook.body.parse !== \"function\") {\n throw new WebhookValidationError(\n `[Sixb] Webhook '${connectorId}/${webhook.id}' body parser must provide parse(value).`\n )\n }\n\n if (webhook.verify !== undefined && typeof webhook.verify !== \"function\") {\n throw new WebhookValidationError(\n `[Sixb] Webhook '${connectorId}/${webhook.id}' verify must be a function.`\n )\n }\n\n if (webhook.idempotencyKey !== undefined && typeof webhook.idempotencyKey !== \"function\") {\n throw new WebhookValidationError(\n `[Sixb] Webhook '${connectorId}/${webhook.id}' idempotencyKey must be a function.`\n )\n }\n\n if (typeof webhook.handle !== \"function\") {\n throw new WebhookValidationError(\n `[Sixb] Webhook '${connectorId}/${webhook.id}' handle must be a function.`\n )\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n",
9
+ "/**\n * How a webhook is allowed to treat the credential its provider sends.\n *\n * A union, so no value carries neither branch. `resolveWebhookVerification` covers the path\n * where the credential arrives as `TCredential | undefined` from the environment, which no type\n * can narrow. Generic because a credential is not always a signing secret: PandaDoc resolves a\n * shared key, Pipedrive compares a username and password.\n */\nexport type WebhookVerification<TCredential = string> =\n | { readonly credential: TCredential; readonly allowUnverified?: never }\n | {\n readonly credential?: never\n /**\n * Accept deliveries this webhook cannot verify. Without a credential the route accepts\n * requests from anyone who can reach it, so it has to be asked for.\n */\n readonly allowUnverified: true\n }\n\n/**\n * How to name a webhook, and its options, in a message about its verification.\n *\n * The options are part of the subject because a connector has two entry points with different\n * names for the same thing: a message fixed to one sends half the callers to an option their\n * API does not have.\n */\nexport interface WebhookVerificationSubject {\n /** The connector, as it appears in its own message prefix — `SixbGitHub`, `SixbMercury`. */\n readonly connector: string\n /** What this webhook checks when a credential is configured, as a noun phrase. */\n readonly verifies: string\n /** The option carrying the credential, written as the caller would type it. */\n readonly credentialOption: string\n /** The option that accepts unverified deliveries, written as the caller would type it. */\n readonly allowOption: string\n}\n\nexport class UnverifiedWebhookError extends Error {\n readonly name = \"UnverifiedWebhookError\"\n}\n\n/**\n * Narrows a credential that may be absent into a {@link WebhookVerification}, or refuses.\n *\n * Returns the union so a caller spreads the result into the builder instead of deciding again.\n * Refusing is the point: a missing credential used to mean `.verify()` returned early and the\n * route accepted anything that reached it. Throwing here fails `createSixb()` instead, so the\n * API role never starts open.\n */\nexport function resolveWebhookVerification<TCredential>(\n subject: WebhookVerificationSubject,\n options: { readonly credential?: TCredential; readonly allowUnverified?: boolean }\n): WebhookVerification<TCredential> {\n if (options.credential) return { credential: options.credential }\n\n if (!options.allowUnverified) {\n throw new UnverifiedWebhookError(\n `[${subject.connector}] This webhook has no credential, so ${subject.verifies} cannot be ` +\n `checked and the route would accept unverified requests from anyone who can reach it. ` +\n `Set ${subject.credentialOption}, or pass ${subject.allowOption} to accept that.`\n )\n }\n\n return { allowUnverified: true }\n}\n\n/**\n * Announces a webhook whose author chose to accept unverified deliveries. Called where the\n * webhook is defined, not inside `verify()`: once per boot is a fact, once per request is noise.\n */\nexport function warnUnverifiedWebhook<TCredential>(\n subject: WebhookVerificationSubject,\n verification: WebhookVerification<TCredential>\n): void {\n if (verification.credential) return\n\n console.warn(\n `[${subject.connector}] ${subject.allowOption}, so ${subject.verifies} is not checked ` +\n `and this route accepts unverified requests from anyone who can reach it. ` +\n `Set ${subject.credentialOption} before exposing it.`\n )\n}\n",
10
+ "import { resolve } from \"node:path\"\nimport type { ActionDefinition } from \"../actions\"\nimport type { AgentDefinition } from \"../agents\"\nimport type { SixbAuthConfig } from \"../auth\"\nimport type { BlobStorage } from \"../blob-storage\"\nimport {\n discoverActions,\n discoverAgents,\n discoverConnectors,\n discoverDatasets,\n discoverGroups,\n discoverMembershipPolicies,\n discoverOntologySources,\n discoverPipelines,\n discoverProjections,\n discoverRoles,\n discoverRules,\n discoverSchedules,\n discoverSyncs,\n discoverWorkflows,\n} from \"../bootstrap\"\nimport type { Broker } from \"../broker\"\nimport type { ConnectorDefinition } from \"../connectors/types\"\nimport type { DatasetDefinition } from \"../datasets\"\nimport type { SixbErrorHandler } from \"../error-reporting/types\"\nimport type { LakeStorage } from \"../lake-storage\"\nimport type { LoggerProvider, ObservabilityOptions } from \"../logging\"\nimport type { OntologyMaintenanceOptions } from \"../maintenance\"\nimport type { PipelineDefinition } from \"../pipelines/types\"\nimport type { ProjectionDefinition } from \"../projections/types\"\nimport type { Queues } from \"../queues\"\nimport type { RuleDefinition } from \"../rules\"\nimport type { SandboxFactory } from \"../sandboxes\"\nimport type { ScheduleDefinition } from \"../schedules\"\nimport type { GroupDefinition, MembershipPolicyDefinition, RoleDefinition } from \"../security\"\nimport type { Storage } from \"../storage\"\nimport type { SyncDefinition } from \"../syncs\"\nimport type { WorkflowDefinition } from \"../workflows\"\nimport { RuntimeError } from \"./errors\"\nimport { Sixb } from \"./sixb\"\nimport type { OntologySource } from \"./types\"\n\nexport interface CreateSixbOptions {\n id?: string\n broker: Broker\n storage: Storage\n lakeStorage: LakeStorage\n blobStorage: BlobStorage\n queues: Queues\n sandboxes?: SandboxFactory\n /** Optional process-level output provider. Omit for broker-only logging. */\n logger?: LoggerProvider\n /** Broker capture controls, independent from the output provider. */\n observability?: ObservabilityOptions\n /** Observes runtime failures without changing their outcome. */\n onError?: SixbErrorHandler\n /** Recovery and retention settings. The runtime constructor never starts maintenance timers. */\n ontologyMaintenance?: OntologyMaintenanceOptions\n ontologies?: readonly OntologySource[]\n actions?: readonly ActionDefinition[]\n /** Agent definitions to register in addition to auto-discovered `agents/` exports. */\n agents?: readonly AgentDefinition[]\n datasets?: readonly DatasetDefinition[]\n /** Connector definitions to register in addition to auto-discovered `connectors/` exports. */\n connectors?: readonly ConnectorDefinition[]\n schedules?: readonly ScheduleDefinition[]\n syncs?: readonly SyncDefinition[]\n pipelines?: readonly PipelineDefinition[]\n projections?: readonly ProjectionDefinition[]\n rules?: readonly RuleDefinition[]\n workflows?: readonly WorkflowDefinition[]\n groups?: readonly GroupDefinition[]\n roles?: readonly RoleDefinition[]\n membershipPolicies?: readonly MembershipPolicyDefinition[]\n auth?: SixbAuthConfig\n projectRoot?: string\n}\n\n/**\n * Create a Sixb runtime using convention-based discovery.\n *\n * Sixb auto-discovers exported definitions from `ontology/`, `actions/`, `datasets/`,\n * `connectors/`, `syncs/`, `schedules/`, `pipelines/`, `projections/`,\n * `rules/`, `workflows/`, `agents/`, and `security/{groups,roles,policies}/`\n * relative to `projectRoot`.\n */\nexport async function createSixb(\n options: CreateSixbOptions\n): Promise<Sixb<readonly OntologySource[]>> {\n const projectRoot = resolve(options.projectRoot ?? process.cwd())\n\n const discovered = await discoverOntologySources(projectRoot)\n const allSources = [...(options.ontologies ?? []), ...discovered]\n\n if (allSources.length === 0) {\n throw new RuntimeError(\n \"No ontology found. Create an 'ontology/' folder or pass 'ontologies' to createSixb().\"\n )\n }\n\n const [\n actions,\n projections,\n schedules,\n syncs,\n connectors,\n pipelines,\n datasets,\n rules,\n workflows,\n groups,\n roles,\n membershipPolicies,\n agents,\n ] = await Promise.all([\n discoverActions(projectRoot),\n discoverProjections(projectRoot),\n discoverSchedules(projectRoot),\n discoverSyncs(projectRoot),\n discoverConnectors(projectRoot),\n discoverPipelines(projectRoot),\n discoverDatasets(projectRoot),\n discoverRules(projectRoot),\n discoverWorkflows(projectRoot),\n discoverGroups(projectRoot),\n discoverRoles(projectRoot),\n discoverMembershipPolicies(projectRoot),\n discoverAgents(projectRoot),\n ])\n\n // Explicit definitions come first so local setup can override ordering while duplicate ids are\n // still rejected by the Sixb constructor. Every family merges — `actions` and `projections` used to\n // *replace* discovery instead, silently and undocumented.\n return new Sixb<readonly OntologySource[]>({\n id: options.id,\n ontology: allSources,\n broker: options.broker,\n storage: options.storage,\n lakeStorage: options.lakeStorage,\n blobStorage: options.blobStorage,\n queues: options.queues,\n sandboxes: options.sandboxes,\n logger: options.logger,\n observability: options.observability,\n onError: options.onError,\n ontologyMaintenance: options.ontologyMaintenance,\n projectRoot,\n actions: [...(options.actions ?? []), ...actions],\n datasets: [...(options.datasets ?? []), ...datasets],\n connectors: [...(options.connectors ?? []), ...connectors],\n schedules: [...(options.schedules ?? []), ...schedules],\n syncs: [...(options.syncs ?? []), ...syncs],\n pipelines: [...(options.pipelines ?? []), ...pipelines],\n projections: [...(options.projections ?? []), ...projections],\n rules: [...(options.rules ?? []), ...rules],\n workflows: [...(options.workflows ?? []), ...workflows],\n groups: [...(options.groups ?? []), ...groups],\n roles: [...(options.roles ?? []), ...roles],\n membershipPolicies: [...(options.membershipPolicies ?? []), ...membershipPolicies],\n agents: [...(options.agents ?? []), ...agents],\n auth: options.auth,\n })\n}\n",
11
+ "/**\n * Sixb is the main runtime entry point.\n *\n * It provides a typed API (`objects(MyType)`) returning ObjectSet with full compile-time inference.\n * For direct runtime access (broker records, events, storage, queued work), use\n * `sixb.broker`, `sixb.events`, `sixb.storage`, and `sixb.queues`.\n */\n\nimport { resolve } from \"node:path\"\nimport { ActionRegistry, ActionsRuntime } from \"../actions\"\nimport type {\n RequestActionAndWaitInput,\n RequestActionInput,\n RequestActionResult,\n} from \"../actions/request\"\nimport {\n requestAction as requestRuntimeAction,\n requestActionAndWait as requestRuntimeActionAndWait,\n} from \"../actions/request\"\nimport type { ActionDefinition } from \"../actions/types\"\nimport type { AgentDefinition, RequestAgentRunInput, RequestAgentRunResult } from \"../agents\"\nimport { AgentsRuntime, validateAgentGroupReferences, validateAgentToolsAtStartup } from \"../agents\"\nimport {\n AuthRuntime,\n AuthRuntimeError,\n isMagicLinkAuthStrategy,\n isOidcAuthStrategy,\n type SixbAuthConfig,\n} from \"../auth\"\nimport type { AuthorizationContext } from \"../authorization\"\nimport type { BlobStorage } from \"../blob-storage\"\nimport type { Broker } from \"../broker\"\nimport { ConnectorRuntime } from \"../connectors/runtime\"\nimport type { ConnectorAdapter, ConnectorClient, ConnectorDefinition } from \"../connectors/types\"\nimport type { DatasetDefinition } from \"../datasets/types\"\nimport { assertDatasetDefinition } from \"../datasets/validation\"\nimport {\n attachSixbErrorReporter,\n reportEventDeliveryFailure,\n shareSixbErrorReporter,\n} from \"../error-reporting/capability\"\nimport type { SixbErrorHandler } from \"../error-reporting/types\"\nimport { type DomainEventLog, EventsRuntime, OntologyOutboxDispatcher } from \"../events\"\nimport type { LakeStorage } from \"../lake-storage\"\nimport { type LoggerProvider, LogsRuntime, type ObservabilityOptions } from \"../logging\"\nimport {\n OntologyMaintenance,\n type OntologyMaintenanceHandle,\n type OntologyMaintenanceOptions,\n type OntologyOperationalStatus,\n type SixbReadiness,\n} from \"../maintenance\"\nimport { createOntologyMaterializer } from \"../materializer\"\nimport { createObjectSet, objectService } from \"../objects\"\nimport {\n assertObjectTypeRegistered,\n type ObjectType,\n OntologyRegistry,\n type ValueType,\n} from \"../ontology\"\nimport type { ObjectTypeWithPropertyTokens } from \"../ontology/tokens\"\nimport { PipelineError } from \"../pipelines\"\nimport {\n type PipelineRunRequestResult,\n type RequestPipelineRunInput,\n requestPipelineRun,\n} from \"../pipelines/request\"\nimport type { PipelineDefinition } from \"../pipelines/types\"\nimport { registerProjectionRegistry } from \"../projections/internal\"\nimport { ProjectionRegistry } from \"../projections/registry\"\nimport type {\n LinkProjectionDefinition,\n ObjectProjectionDefinition,\n ProjectionDefinition,\n TelemetryProjectionDefinition,\n} from \"../projections/types\"\nimport type { Queues } from \"../queues\"\nimport type { RuleDefinition } from \"../rules\"\nimport { validateRulesAtStartup } from \"../rules\"\nimport type { SandboxFactory } from \"../sandboxes\"\nimport { SchedulerRuntime } from \"../scheduler\"\nimport type { ScheduleDefinition } from \"../schedules\"\nimport { validateSchedulesAtStartup } from \"../schedules\"\nimport type {\n GroupDefinition,\n MembershipPolicyDefinition,\n RoleDefinition,\n SecurityRegistry,\n} from \"../security\"\nimport { createRuntimeSecurityRegistry } from \"../security/runtime\"\nimport type { ActionRunRecord, ObjectRow, Storage } from \"../storage\"\nimport type { SyncDefinition } from \"../syncs\"\nimport { SyncValidationError } from \"../syncs\"\nimport {\n type RequestSyncRunInput,\n requestSyncRun,\n type SyncRunRequestResult,\n} from \"../syncs/request\"\nimport {\n validateKeyedDatasetWriterTopology,\n validateMergeSyncProjectionSafety,\n} from \"../syncs/validation\"\nimport type { RegisteredWebhook } from \"../webhooks\"\nimport { registerWebhooks, WebhookValidationError, webhookRoute } from \"../webhooks\"\nimport type {\n RequestWorkflowRunInput,\n WorkflowDefinition,\n WorkflowRunRequestResult,\n} from \"../workflows\"\nimport { validateWorkflowsAtStartup, WorkflowsRuntime } from \"../workflows\"\nimport { RuntimeError } from \"./errors\"\nimport {\n createOntologyMutationRuntime,\n registerOntologyMutationRuntime,\n} from \"./ontology-mutations\"\nimport { createScopedSixb, type ScopedSixb } from \"./scoped\"\nimport { StorageReadiness } from \"./storage-readiness\"\nimport type {\n BatchItemResult,\n ListResult,\n ObjectSet,\n OntologySource,\n RegisteredObjectType,\n RegisteredValueTypes,\n SixbInstance,\n SixbRuntimeContext,\n} from \"./types\"\n\nexport interface SixbOptions<TOntologySources extends readonly OntologySource[]> {\n id?: string\n ontology: TOntologySources\n broker: Broker\n storage: Storage\n lakeStorage: LakeStorage\n blobStorage: BlobStorage\n queues: Queues\n sandboxes?: SandboxFactory\n /** Optional process-level output provider. Omit for broker-only logging. */\n logger?: LoggerProvider\n /** Broker capture controls, independent from the output provider. */\n observability?: ObservabilityOptions\n /** Observes runtime failures without changing their outcome. */\n onError?: SixbErrorHandler\n /** Recovery and retention settings. The runtime constructor never starts maintenance timers. */\n ontologyMaintenance?: OntologyMaintenanceOptions\n projectRoot?: string\n actions?: readonly ActionDefinition[]\n datasets?: readonly DatasetDefinition[]\n /** Connector definitions registered with this runtime. */\n connectors?: readonly ConnectorDefinition[]\n schedules?: readonly ScheduleDefinition[]\n syncs?: readonly SyncDefinition[]\n pipelines?: readonly PipelineDefinition[]\n projections?: readonly ProjectionDefinition[]\n rules?: readonly RuleDefinition[]\n workflows?: readonly WorkflowDefinition[]\n agents?: readonly AgentDefinition[]\n groups?: readonly GroupDefinition[]\n roles?: readonly RoleDefinition[]\n membershipPolicies?: readonly MembershipPolicyDefinition[]\n auth?: SixbAuthConfig\n}\n\nexport class Sixb<TOntologySources extends readonly OntologySource[]>\n implements SixbInstance<TOntologySources>\n{\n readonly projectId: string\n private readonly ontologySources: TOntologySources\n private readonly datasetsById = new Map<string, DatasetDefinition>()\n private readonly schedulesById = new Map<string, ScheduleDefinition>()\n private readonly syncsById = new Map<string, SyncDefinition>()\n private readonly pipelinesById = new Map<string, PipelineDefinition>()\n private readonly rulesById = new Map<string, RuleDefinition>()\n private readonly connectorRuntime: ConnectorRuntime\n private readonly webhooksByRoute = new Map<string, RegisteredWebhook>()\n private readonly webhooks: readonly RegisteredWebhook[]\n private readonly runtimeContext: SixbRuntimeContext\n private readonly committedFacts: OntologyOutboxDispatcher\n private readonly eventsRuntime: EventsRuntime\n private readonly ontologyMaintenance: OntologyMaintenance\n private readonly storageReadiness: StorageReadiness\n private readonly projectionRegistry: ProjectionRegistry\n readonly ontology: OntologyRegistry\n readonly actionRegistry: ActionRegistry\n readonly actions: ActionsRuntime\n readonly workflows: WorkflowsRuntime\n readonly agents: AgentsRuntime\n readonly broker: Broker\n readonly events: DomainEventLog\n readonly logs: LogsRuntime\n readonly storage: Storage\n readonly lakeStorage: LakeStorage\n readonly blobStorage: BlobStorage\n readonly queues: Queues\n readonly sandboxes?: SandboxFactory\n readonly projectRoot: string\n readonly rules: readonly RuleDefinition[]\n readonly security: SecurityRegistry\n readonly auth: AuthRuntime\n private schedulerRuntime: SchedulerRuntime | null = null\n\n constructor(options: SixbOptions<TOntologySources>) {\n attachSixbErrorReporter(this, options.onError)\n this.projectId = options.id ?? \"default\"\n this.ontologySources = options.ontology\n this.broker = options.broker\n // `host: this` is how `events.emit()` reaches the reporter attached at the top of this constructor.\n this.eventsRuntime = new EventsRuntime({\n projectId: this.projectId,\n broker: this.broker,\n host: this,\n })\n this.events = this.eventsRuntime\n this.logs = new LogsRuntime({\n projectId: this.projectId,\n broker: this.broker,\n logger: options.logger,\n observability: options.observability?.logs,\n })\n this.storage = options.storage\n this.storageReadiness = new StorageReadiness(this.storage)\n this.lakeStorage = options.lakeStorage\n this.blobStorage = options.blobStorage\n this.queues = options.queues\n this.sandboxes = options.sandboxes\n this.projectRoot = resolve(options.projectRoot ?? process.cwd())\n this.rules = options.rules ?? []\n // Ontology and actions resolve first so every later registry (security,\n // rules, workflows, projections) can validate its references against them.\n this.ontology = new OntologyRegistry({ sources: this.ontologySources })\n this.actionRegistry = new ActionRegistry(options.actions ?? [], this.ontology)\n const registeredActionIds = new Set(this.actionRegistry.list().map((action) => action.id))\n const agents = options.agents ?? []\n validateAgentToolsAtStartup(agents)\n this.security = createRuntimeSecurityRegistry({\n groups: options.groups ?? [],\n roles: options.roles ?? [],\n membershipPolicies: options.membershipPolicies ?? [],\n objectTypeIds: new Set(this.ontology.getObjectTypesById().keys()),\n datasetIds: new Set((options.datasets ?? []).map((dataset) => dataset.id)),\n actionIds: registeredActionIds,\n workflowIds: new Set((options.workflows ?? []).map((workflow) => workflow.id)),\n syncIds: new Set((options.syncs ?? []).map((sync) => sync.id)),\n pipelineIds: new Set((options.pipelines ?? []).map((pipeline) => pipeline.id)),\n agentIds: new Set(agents.map((agent) => agent.id)),\n getSubTypes: (objectTypeId) => this.ontology.listSubTypes(objectTypeId),\n })\n this.auth = new AuthRuntime({\n projectId: this.projectId,\n storage: this.storage,\n security: this.security,\n config: options.auth,\n })\n validateAuthStrategySecurityReferences(this.auth.getStrategy(), this.security)\n this.connectorRuntime = new ConnectorRuntime(this.projectId, options.connectors ?? [])\n const connectors = this.connectorRuntime.list()\n assertWebhookDeliveryStorage(connectors, this.storage)\n this.webhooks = registerWebhooks(connectors).webhooks\n\n for (const registered of this.webhooks) {\n this.webhooksByRoute.set(registered.route, registered)\n }\n\n // Register datasets first so sync and pipeline definitions can be validated\n // against the runtime dataset registry during startup.\n for (const dataset of options.datasets ?? []) {\n assertDatasetDefinition(dataset, (message) => new RuntimeError(message))\n\n if (this.datasetsById.has(dataset.id)) {\n throw new RuntimeError(`Duplicate dataset id: ${dataset.id}`)\n }\n\n this.datasetsById.set(dataset.id, dataset)\n }\n\n for (const schedule of options.schedules ?? []) {\n if (this.schedulesById.has(schedule.id)) {\n throw new RuntimeError(`Duplicate schedule id: ${schedule.id}`)\n }\n this.schedulesById.set(schedule.id, schedule)\n }\n\n for (const sync of options.syncs ?? []) {\n if (this.syncsById.has(sync.id)) {\n throw new RuntimeError(`Duplicate sync id: ${sync.id}`)\n }\n\n const dataset = this.datasetsById.get(sync.target.dataset.id)\n if (!dataset) {\n throw new RuntimeError(\n `Sync '${sync.id}' targets unknown dataset '${sync.target.dataset.id}'. Add it to 'datasets' in createSixb() or export it from 'datasets/'.`\n )\n }\n\n this.syncsById.set(sync.id, sync)\n }\n\n for (const pipeline of options.pipelines ?? []) {\n if (this.pipelinesById.has(pipeline.id)) {\n throw new RuntimeError(`Duplicate pipeline id: ${pipeline.id}`)\n }\n\n if (pipeline.graph.nodes.length === 0) {\n throw new RuntimeError(`Pipeline '${pipeline.id}' must contain at least one step.`)\n }\n\n const stepIds = new Set<string>()\n for (const node of pipeline.graph.nodes) {\n const { step } = node\n if (stepIds.has(step.id)) {\n throw new RuntimeError(\n `Pipeline '${pipeline.id}' contains duplicate step id '${step.id}'.`\n )\n }\n stepIds.add(step.id)\n\n for (const [inputName, dataset] of Object.entries(step.inputs)) {\n if (!this.datasetsById.has(dataset.id)) {\n throw new RuntimeError(\n `Pipeline '${pipeline.id}' step '${step.id}' input '${inputName}' references unknown dataset '${dataset.id}'. Add it to 'datasets' in createSixb() or export it from 'datasets/'.`\n )\n }\n }\n\n if (!this.datasetsById.has(step.output.id)) {\n throw new RuntimeError(\n `Pipeline '${pipeline.id}' step '${step.id}' outputs unknown dataset '${step.output.id}'. Add it to 'datasets' in createSixb() or export it from 'datasets/'.`\n )\n }\n }\n\n this.pipelinesById.set(pipeline.id, pipeline)\n }\n\n validateKeyedDatasetWriterTopology({\n datasetsById: this.datasetsById,\n syncs: [...this.syncsById.values()],\n pipelines: [...this.pipelinesById.values()],\n })\n\n // Rules validate against the resolved ontology so inherited properties and\n // links are available before checking predicate references.\n validateRulesAtStartup(this.rules, this.ontology)\n for (const rule of this.rules) {\n this.rulesById.set(rule.id, rule)\n }\n\n validateSchedulesAtStartup([...this.schedulesById.values()], this.ontology, {\n registeredRuleIds: new Set(this.rulesById.keys()),\n registeredActionIds,\n registeredDatasetIds: new Set(this.datasetsById.keys()),\n registeredSyncIds: new Set(this.syncsById.keys()),\n registeredPipelineIds: new Set(this.pipelinesById.keys()),\n })\n for (const sync of this.syncsById.values()) {\n validateScheduleReferences(\"Sync\", sync.id, sync.triggers, this.schedulesById)\n }\n for (const pipeline of this.pipelinesById.values()) {\n validateScheduleReferences(\"Pipeline\", pipeline.id, pipeline.triggers, this.schedulesById)\n }\n\n const workflows = validateWorkflowsAtStartup({\n workflows: options.workflows ?? [],\n registeredSchedules: this.schedulesById,\n registeredActionIds,\n registeredAgentIds: new Set(agents.map((agent) => agent.id)),\n })\n\n const workflowIds = new Set<string>()\n for (const workflow of workflows) {\n if (workflowIds.has(workflow.id)) {\n throw new RuntimeError(`Duplicate workflow id: ${workflow.id}`)\n }\n workflowIds.add(workflow.id)\n }\n\n this.projectionRegistry = new ProjectionRegistry({\n projections: options.projections ?? [],\n ontology: this.ontology,\n datasetsById: this.datasetsById,\n })\n validateMergeSyncProjectionSafety({\n syncs: [...this.syncsById.values()],\n telemetryProjections: this.projectionRegistry.listTelemetryProjections(),\n })\n registerProjectionRegistry(this, this.projectionRegistry)\n\n const materializer = createOntologyMaterializer({\n projectId: this.projectId,\n ontology: this.ontology,\n projections: this.projectionRegistry,\n storage: this.storage,\n })\n this.committedFacts = new OntologyOutboxDispatcher({\n projectId: this.projectId,\n storage: this.storage,\n events: this.eventsRuntime,\n onDeliveryFailure: (error, failure) =>\n reportEventDeliveryFailure(this, error, {\n projectId: this.projectId,\n ...failure,\n }),\n })\n this.ontologyMaintenance = new OntologyMaintenance({\n projectId: this.projectId,\n storage: this.storage,\n dispatcher: this.committedFacts,\n options: options.ontologyMaintenance,\n })\n\n this.runtimeContext = {\n projectId: this.projectId,\n ontology: this.ontology,\n actionRegistry: this.actionRegistry,\n events: this.events,\n storage: this.storage,\n lakeStorage: this.lakeStorage,\n blobStorage: this.blobStorage,\n queues: this.queues,\n sandboxes: this.sandboxes,\n rules: this.rules,\n }\n registerProjectionRegistry(this.runtimeContext, this.projectionRegistry)\n const ontologyMutations = createOntologyMutationRuntime({\n materializer,\n notifyCommittedFacts: () => this.committedFacts.notify(),\n })\n registerOntologyMutationRuntime(this, ontologyMutations)\n registerOntologyMutationRuntime(this.runtimeContext, ontologyMutations)\n shareSixbErrorReporter(this, this.runtimeContext)\n this.actions = new ActionsRuntime(this.runtimeContext)\n this.workflows = new WorkflowsRuntime(this.runtimeContext, workflows)\n\n const agentIds = new Set<string>()\n for (const agent of agents) {\n if (agentIds.has(agent.id)) {\n throw new RuntimeError(`Duplicate agent id: ${agent.id}`)\n }\n agentIds.add(agent.id)\n }\n validateAgentGroupReferences(agents, this.security)\n this.agents = new AgentsRuntime(this.runtimeContext, agents)\n }\n\n get id(): string {\n return this.projectId\n }\n\n listObjectTypes(): readonly ObjectTypeWithPropertyTokens[] {\n return this.ontology.listObjectTypes()\n }\n\n getObjectTypeById(objectTypeId: string): ObjectTypeWithPropertyTokens | null {\n return this.ontology.getObjectTypeById(objectTypeId)\n }\n\n resolveObjectType(objectTypeId: string): ObjectTypeWithPropertyTokens {\n return this.ontology.resolveObjectType(objectTypeId)\n }\n\n getValueTypesById(): ReadonlyMap<string, ValueType> {\n return this.ontology.getValueTypesById()\n }\n\n listActions(): readonly ActionDefinition[] {\n return this.actionRegistry.list()\n }\n\n getActionById(actionId: string): ActionDefinition | null {\n return this.actionRegistry.getById(actionId)\n }\n\n listGlobalActions(): readonly ActionDefinition[] {\n return this.actionRegistry.getGlobalActions()\n }\n\n listActionsForType(objectType: ObjectType): readonly ActionDefinition[] {\n return this.actionRegistry.getActionsForType(objectType)\n }\n\n listDatasets(): readonly DatasetDefinition[] {\n return [...this.datasetsById.values()]\n }\n\n getDatasetById(datasetId: string): DatasetDefinition | null {\n return this.datasetsById.get(datasetId) ?? null\n }\n\n listSyncs(): readonly SyncDefinition[] {\n return [...this.syncsById.values()]\n }\n\n getSyncById(syncId: string): SyncDefinition | null {\n return this.syncsById.get(syncId) ?? null\n }\n\n listPipelines(): readonly PipelineDefinition[] {\n return [...this.pipelinesById.values()]\n }\n\n getPipelineById(pipelineId: string): PipelineDefinition | null {\n return this.pipelinesById.get(pipelineId) ?? null\n }\n\n // ── Starting work ─────────────────────────────────────────\n // Every verb is `request*` because everything here is queued, never run inline. `requestActionAndWait`\n // is the one that waits, and says so.\n\n requestAction(input: RequestActionInput): Promise<RequestActionResult> {\n return requestRuntimeAction(this.runtimeContext, input)\n }\n\n requestActionAndWait(input: RequestActionAndWaitInput): Promise<ActionRunRecord> {\n return requestRuntimeActionAndWait(this.runtimeContext, input)\n }\n\n requestWorkflowRun(input: RequestWorkflowRunInput): Promise<WorkflowRunRequestResult> {\n return this.workflows.requestById(input)\n }\n\n async requestSyncRun(input: RequestSyncRunInput): Promise<SyncRunRequestResult> {\n const sync = this.getSyncById(input.syncId)\n if (!sync) {\n throw new SyncValidationError(`[Sixb] Unknown sync '${input.syncId}'`)\n }\n return requestSyncRun(this.runtimeContext, sync, input)\n }\n\n async requestPipelineRun(input: RequestPipelineRunInput): Promise<PipelineRunRequestResult> {\n const pipeline = this.getPipelineById(input.pipelineId)\n if (!pipeline) {\n throw new PipelineError(`[Sixb] Unknown pipeline '${input.pipelineId}'`)\n }\n return requestPipelineRun(this.runtimeContext, pipeline, input)\n }\n\n requestAgentRun(input: RequestAgentRunInput): Promise<RequestAgentRunResult> {\n return this.agents.request(input)\n }\n\n listSchedules(): readonly ScheduleDefinition[] {\n return [...this.schedulesById.values()]\n }\n\n getScheduleById(scheduleId: string): ScheduleDefinition | null {\n return this.schedulesById.get(scheduleId) ?? null\n }\n\n listRules(): readonly RuleDefinition[] {\n return [...this.rulesById.values()]\n }\n\n getRuleById(ruleId: string): RuleDefinition | null {\n return this.rulesById.get(ruleId) ?? null\n }\n\n /** All connector definitions registered with this runtime. */\n listConnectors(): readonly ConnectorDefinition[] {\n return this.connectorRuntime.list()\n }\n\n /** Lookup a registered connector definition by id. */\n getConnectorById(connectorId: string): ConnectorDefinition | null {\n return this.connectorRuntime.getById(connectorId)\n }\n\n /** All webhook endpoints registered through connector adapters. */\n listWebhooks(): readonly RegisteredWebhook[] {\n return this.webhooks\n }\n\n /** Lookup a registered connector webhook by connector id and webhook id. */\n getWebhookById(connectorId: string, webhookId: string): RegisteredWebhook | null {\n return this.webhooksByRoute.get(webhookRoute(connectorId, webhookId)) ?? null\n }\n\n /**\n * Resolve a connector definition to a connected client.\n *\n * Connector definitions are inert. This method performs lazy connection and\n * reuses the same connected client for subsequent calls.\n */\n connector<TAdapter extends ConnectorAdapter>(\n definition: ConnectorDefinition<string, TAdapter>\n ): Promise<ConnectorClient<TAdapter>> {\n return this.connectorRuntime.connect(definition)\n }\n\n async startScheduler(): Promise<void> {\n if (this.schedulerRuntime || this.schedulesById.size === 0) return\n\n const runtime = new SchedulerRuntime({\n schedules: this.listSchedules(),\n events: this.eventsRuntime,\n })\n\n await runtime.start()\n this.schedulerRuntime = runtime\n }\n\n async stopScheduler(): Promise<void> {\n if (!this.schedulerRuntime) return\n\n const runtime = this.schedulerRuntime\n this.schedulerRuntime = null\n await runtime.stop()\n }\n\n /** Start the API-owned recovery and retention loop. Embedded runtimes opt in explicitly. */\n startOntologyMaintenance(): Promise<OntologyMaintenanceHandle> {\n this.storageReadiness.startSchemaValidation()\n return this.ontologyMaintenance.start()\n }\n\n getOntologyOperationalStatus(): OntologyOperationalStatus {\n return this.ontologyMaintenance.getOperationalStatus()\n }\n\n async checkReadiness(): Promise<SixbReadiness> {\n return this.storageReadiness.check()\n }\n\n /** Disconnect all currently connected connector clients. */\n async disconnectConnectors(): Promise<void> {\n await this.connectorRuntime.disconnectAll()\n }\n\n /** Flush and close the configured process logger provider. */\n async closeLogger(): Promise<void> {\n await this.logs.close()\n }\n\n /** Close the runtime broker provider if it owns external resources. */\n async closeBroker(): Promise<void> {\n await this.committedFacts.stop()\n await this.ontologyMaintenance.stop()\n await this.broker.close?.()\n }\n\n /**\n * Derive a principal-scoped SDK from this runtime.\n *\n * The scoped surface is default-deny: operations run only when covered by\n * the context's grants. This raw runtime stays privileged for trusted\n * system code (startup, syncs, projections, workers, webhooks, tests).\n */\n as(context: AuthorizationContext): ScopedSixb<TOntologySources> {\n return createScopedSixb<TOntologySources>(\n { ...this.runtimeContext, authorization: context },\n {\n datasets: {\n list: () => this.listDatasets(),\n getById: (datasetId) => this.getDatasetById(datasetId),\n },\n syncs: {\n list: () => this.listSyncs(),\n getById: (syncId) => this.getSyncById(syncId),\n },\n pipelines: {\n list: () => this.listPipelines(),\n getById: (pipelineId) => this.getPipelineById(pipelineId),\n },\n workflows: this.workflows,\n agents: this.agents,\n }\n )\n }\n\n objects<TObjectType extends RegisteredObjectType<TOntologySources>>(\n objectType: TObjectType\n ): ObjectSet<\n TObjectType,\n RegisteredValueTypes<TOntologySources>,\n RegisteredObjectType<TOntologySources>\n > {\n assertObjectTypeRegistered(this.ontology.getObjectTypesById(), objectType)\n\n return createObjectSet<\n TObjectType,\n RegisteredObjectType<TOntologySources>,\n RegisteredValueTypes<TOntologySources>\n >({ ...this.runtimeContext, objectType })\n }\n\n async upsertObject(\n objectTypeId: string,\n properties: Record<string, unknown>\n ): Promise<ObjectRow> {\n return objectService.upsertObject(this.runtimeContext, objectTypeId, properties)\n }\n\n async upsertObjectBatch(\n objectTypeId: string,\n items: readonly { properties: Record<string, unknown> }[]\n ): Promise<readonly BatchItemResult<ObjectRow>[]> {\n return objectService.upsertObjectBatch(this.runtimeContext, objectTypeId, items)\n }\n\n async upsertLinkBatch(\n items: readonly {\n objectTypeId: string\n sourceId: string\n linkId: string\n target: { targetTypeId: string; targetId: string; properties?: Record<string, unknown> }\n }[]\n ): Promise<readonly BatchItemResult<void>[]> {\n return objectService.upsertLinkBatch(this.runtimeContext, items)\n }\n\n async appendTelemetry(\n objectTypeId: string,\n items: readonly { id: string; properties: Record<string, unknown>; at?: Date }[]\n ): Promise<void> {\n await objectService.appendTelemetry(this.runtimeContext, objectTypeId, items)\n }\n\n async upsertLink(\n objectTypeId: string,\n sourceId: string,\n linkId: string,\n target: { targetTypeId: string; targetId: string; properties?: Record<string, unknown> }\n ): Promise<void> {\n await objectService.upsertLink(this.runtimeContext, objectTypeId, sourceId, linkId, target)\n }\n\n async removeLink(\n objectTypeId: string,\n sourceId: string,\n linkId: string,\n target: { targetTypeId: string; targetId: string }\n ): Promise<void> {\n await objectService.removeLink(this.runtimeContext, objectTypeId, sourceId, linkId, target)\n }\n\n getPrimaryPropertyId(objectTypeId: string): string {\n return this.ontology.getPrimaryPropertyId(objectTypeId)\n }\n\n listObjectProjections(): readonly ObjectProjectionDefinition[] {\n return this.projectionRegistry.listObjectProjections()\n }\n\n listLinkProjections(): readonly LinkProjectionDefinition[] {\n return this.projectionRegistry.listLinkProjections()\n }\n\n listTelemetryProjections(): readonly TelemetryProjectionDefinition[] {\n return this.projectionRegistry.listTelemetryProjections()\n }\n\n getProjectionById(projectionId: string): ProjectionDefinition | null {\n return this.projectionRegistry.getProjectionById(projectionId)\n }\n\n /**\n * Global list for cross-type queries (e.g., dashboards, search).\n * Use sixb.objects(Type).query().where(...).list() for type-safe property filtering.\n */\n async list(params: {\n objectTypeIds?: readonly string[]\n idPrefix?: string\n idSuffix?: string\n updatedAfter?: Date\n updatedBefore?: Date\n createdAfter?: Date\n createdBefore?: Date\n limit?: number\n offset?: number\n orderBy?: \"createdAt\" | \"updatedAt\" | \"primaryId\"\n order?: \"asc\" | \"desc\"\n }): Promise<ListResult<ObjectRow>> {\n return objectService.listObjects(this.runtimeContext, params)\n }\n\n listSubTypes(objectTypeId: string): string[] {\n return this.ontology.listSubTypes(objectTypeId)\n }\n\n isValidLinkTarget(expected: string | string[], actual: string): boolean {\n return this.ontology.isValidLinkTarget(expected, actual)\n }\n}\n\nfunction validateScheduleReferences(\n consumerKind: \"Sync\" | \"Pipeline\",\n consumerId: string,\n references: readonly { readonly scheduleId: string }[],\n schedulesById: ReadonlyMap<string, ScheduleDefinition>\n): void {\n for (const reference of references) {\n if (!schedulesById.has(reference.scheduleId)) {\n throw new RuntimeError(\n `${consumerKind} '${consumerId}' references unknown schedule '${reference.scheduleId}'. Add it to 'schedules' in createSixb() or export it from 'schedules/'.`\n )\n }\n }\n}\n\nfunction validateAuthStrategySecurityReferences(\n strategy: ReturnType<AuthRuntime[\"getStrategy\"]>,\n security: SecurityRegistry\n): void {\n if (!isMagicLinkAuthStrategy(strategy) && !isOidcAuthStrategy(strategy)) {\n return\n }\n\n for (const groupId of strategy.bootstrapGroupIds ?? []) {\n if (!security.getGroupById(groupId)) {\n throw new AuthRuntimeError(\n \"invalid_auth_config\",\n `[Sixb] Auth bootstrapGroups references unknown group '${groupId}'. Add it to 'security/groups/' or pass it to createSixb({ groups }).`\n )\n }\n }\n}\n\nfunction assertWebhookDeliveryStorage(\n connectors: readonly ConnectorDefinition[],\n storage: Storage\n): void {\n if (storage.webhookDeliveries !== undefined) {\n return\n }\n\n for (const connector of connectors) {\n const webhooks = connector.adapter.webhooks\n if (!Array.isArray(webhooks)) {\n continue\n }\n\n if (webhooks.some((webhook) => webhook.idempotencyKey !== undefined)) {\n throw new WebhookValidationError(\n \"[Sixb] Webhook idempotency requires storage.webhookDeliveries to be configured.\"\n )\n }\n }\n}\n",
12
+ "import { ConnectorError, ConnectorNotFoundError } from \"./errors\"\nimport type { ConnectorAdapter, ConnectorClient, ConnectorDefinition } from \"./types\"\n\ntype ConnectorConnectionState = {\n controller: AbortController\n clientPromise: Promise<unknown>\n}\n\nexport class ConnectorRuntime {\n private readonly definitionsById = new Map<string, ConnectorDefinition>()\n private readonly connectionStates = new Map<ConnectorDefinition, ConnectorConnectionState>()\n\n constructor(\n private readonly projectId: string,\n definitions: readonly ConnectorDefinition[]\n ) {\n for (const definition of definitions) {\n if (this.definitionsById.has(definition.id)) {\n throw new ConnectorError(`Duplicate connector id: ${definition.id}`)\n }\n\n this.definitionsById.set(definition.id, definition)\n }\n }\n\n list(): readonly ConnectorDefinition[] {\n return [...this.definitionsById.values()]\n }\n\n getById(id: string): ConnectorDefinition | null {\n return this.definitionsById.get(id) ?? null\n }\n\n async connect<TAdapter extends ConnectorAdapter>(\n definition: ConnectorDefinition<string, TAdapter>\n ): Promise<ConnectorClient<TAdapter>> {\n const registeredDefinition = this.definitionsById.get(definition.id)\n\n if (!registeredDefinition) {\n throw new ConnectorNotFoundError(definition.id)\n }\n\n if (registeredDefinition !== definition) {\n throw new ConnectorError(\n `Connector '${definition.id}' is not the registered definition instance.`\n )\n }\n\n let state = this.connectionStates.get(definition)\n if (!state) {\n const controller = new AbortController()\n const clientPromise = Promise.resolve(\n definition.adapter.connect({\n projectId: this.projectId,\n connectorId: definition.id,\n signal: controller.signal,\n })\n )\n\n state = { controller, clientPromise }\n this.connectionStates.set(definition, state)\n }\n\n try {\n return (await state.clientPromise) as ConnectorClient<TAdapter>\n } catch (error) {\n if (this.connectionStates.get(definition) === state) {\n this.connectionStates.delete(definition)\n }\n throw error\n }\n }\n\n async disconnectAll(): Promise<void> {\n const activeConnections = [...this.connectionStates.entries()]\n this.connectionStates.clear()\n\n for (const [definition, state] of activeConnections) {\n await this.disconnectState(definition, state)\n }\n }\n\n private async disconnectState(\n definition: ConnectorDefinition,\n state: ConnectorConnectionState\n ): Promise<void> {\n state.controller.abort()\n\n let client: unknown\n try {\n client = await state.clientPromise\n } catch {\n return\n }\n\n if (typeof definition.adapter.disconnect === \"function\") {\n await definition.adapter.disconnect(client as never)\n }\n }\n}\n",
13
+ "import type { OntologyOutboxDispatcher } from \"../events\"\nimport type { Storage } from \"../storage\"\nimport type {\n OntologyMaintenanceCleanupSnapshot,\n OntologyMaintenanceHandle,\n OntologyMaintenanceOptions,\n OntologyMaintenanceSnapshot,\n OntologyOperationalStatus,\n} from \"./types\"\n\nconst DEFAULT_INTERVAL_MS = 60_000\nconst DEFAULT_RETENTION_MS = 24 * 60 * 60_000\nconst DEFAULT_CLEANUP_LIMIT = 1_000\nconst DEFAULT_SHUTDOWN_TIMEOUT_MS = 30_000\nconst DEGRADED_ATTEMPT_THRESHOLD = 3\nconst DEGRADED_FAILURE_THRESHOLD = 2\n\ninterface OntologyMaintenanceDependencies {\n readonly projectId: string\n readonly storage: Storage\n readonly dispatcher: OntologyOutboxDispatcher\n readonly options?: OntologyMaintenanceOptions\n readonly now?: () => Date\n readonly onError?: (error: unknown) => void\n}\n\n/** API-owned catch-up, retention, and operational snapshot lifecycle. */\nexport class OntologyMaintenance {\n private readonly projectId: string\n private readonly storage: Storage\n private readonly dispatcher: OntologyOutboxDispatcher\n private readonly intervalMs: number\n private readonly publishedOutboxRetentionMs: number\n private readonly terminalSourceRetentionMs: number\n private readonly cleanupLimit: number\n private readonly shutdownTimeoutMs: number\n private readonly now: () => Date\n private readonly onError: (error: unknown) => void\n private readonly owners = new Set<symbol>()\n private timer: ReturnType<typeof setTimeout> | null = null\n private pass: Promise<void> | null = null\n private stopping: Promise<void> | null = null\n private snapshot: OntologyMaintenanceSnapshot\n\n constructor(dependencies: OntologyMaintenanceDependencies) {\n assertNonblank(dependencies.projectId, \"projectId\")\n const options = dependencies.options ?? {}\n this.projectId = dependencies.projectId\n this.storage = dependencies.storage\n this.dispatcher = dependencies.dispatcher\n this.intervalMs = positiveInteger(options.intervalMs ?? DEFAULT_INTERVAL_MS, \"intervalMs\")\n this.publishedOutboxRetentionMs = nonnegativeInteger(\n options.publishedOutboxRetentionMs ?? DEFAULT_RETENTION_MS,\n \"publishedOutboxRetentionMs\"\n )\n this.terminalSourceRetentionMs = nonnegativeInteger(\n options.terminalSourceRetentionMs ?? DEFAULT_RETENTION_MS,\n \"terminalSourceRetentionMs\"\n )\n this.cleanupLimit = positiveInteger(\n options.cleanupLimit ?? DEFAULT_CLEANUP_LIMIT,\n \"cleanupLimit\"\n )\n this.shutdownTimeoutMs = nonnegativeInteger(\n options.shutdownTimeoutMs ?? DEFAULT_SHUTDOWN_TIMEOUT_MS,\n \"shutdownTimeoutMs\"\n )\n this.now = dependencies.now ?? (() => new Date())\n this.onError =\n dependencies.onError ??\n ((error) => console.error(\"[Sixb] Ontology maintenance error:\", error))\n this.snapshot = emptySnapshot(this.intervalMs)\n }\n\n /** Acquires maintenance ownership and starts catch-up without blocking the host from listening. */\n async start(): Promise<OntologyMaintenanceHandle> {\n if (this.stopping) await this.stopping\n const owner = Symbol(\"ontology-maintenance-owner\")\n const startsHosting = this.owners.size === 0\n this.owners.add(owner)\n if (startsHosting) this.startHostedPass()\n\n let released = false\n return {\n stop: async () => {\n if (released) return\n released = true\n this.owners.delete(owner)\n if (this.owners.size === 0) await this.stopLoop()\n },\n }\n }\n\n /** Runs one coalesced pass. Exposed for deterministic hosting and tests. */\n runNow(): Promise<void> {\n this.pass ??= this.runPass().finally(() => {\n this.pass = null\n })\n return this.pass\n }\n\n /** Force-stops every owner; used during provider shutdown. */\n async stop(): Promise<void> {\n this.owners.clear()\n await this.stopLoop()\n }\n\n getSnapshot(): OntologyMaintenanceSnapshot {\n return structuredClone(this.snapshot)\n }\n\n getOperationalStatus(): OntologyOperationalStatus {\n const snapshot = this.getSnapshot()\n const lastActivityAt = latestTimestamp(snapshot.lastStartedAt, snapshot.lastCompletedAt)\n const overdue =\n lastActivityAt !== null &&\n this.now().getTime() - Date.parse(lastActivityAt) > this.intervalMs * 2\n const oldestPendingAt = snapshot.outbox?.oldestPendingAt ?? null\n const pendingTooLong =\n oldestPendingAt !== null &&\n this.now().getTime() - Date.parse(oldestPendingAt) > this.intervalMs * 2\n const repeatedlyFailing = (snapshot.outbox?.maxAttempts ?? 0) >= DEGRADED_ATTEMPT_THRESHOLD\n const degraded =\n snapshot.consecutiveFailures >= DEGRADED_FAILURE_THRESHOLD ||\n repeatedlyFailing ||\n pendingTooLong ||\n overdue\n return { status: degraded ? \"degraded\" : \"ok\", maintenance: snapshot }\n }\n\n private startHostedPass(): void {\n void this.runNow()\n .catch((error) => this.reportError(error))\n .finally(() => this.scheduleNextPass())\n }\n\n private async runPass(): Promise<void> {\n const started = this.now()\n this.snapshot = { ...this.snapshot, running: true, lastStartedAt: started.toISOString() }\n\n const failures: unknown[] = []\n await captureFailure(() => this.dispatcher.drain(), failures)\n const cleanup = await this.cleanupExpiredRows(started, failures)\n const { outbox, terminalSources } = await this.readOperationalSummaries(failures)\n this.completePass({ started, failures, cleanup, outbox, terminalSources })\n }\n\n private async cleanupExpiredRows(\n started: Date,\n failures: unknown[]\n ): Promise<OntologyMaintenanceCleanupSnapshot> {\n const publishedOutboxRowsDeleted = await captureFailure(\n () =>\n this.storage.ontology.outbox.purgePublished({\n projectId: this.projectId,\n publishedBefore: new Date(\n started.getTime() - this.publishedOutboxRetentionMs\n ).toISOString(),\n limit: this.cleanupLimit,\n }),\n failures,\n 0\n )\n const terminalSources = await captureFailure(\n () =>\n this.storage.ontology.sources.cleanupTerminal({\n projectId: this.projectId,\n terminalBefore: new Date(\n started.getTime() - this.terminalSourceRetentionMs\n ).toISOString(),\n limit: this.cleanupLimit,\n }),\n failures,\n { rowsDeleted: 0, materializationsDeleted: 0 }\n )\n\n return {\n publishedOutboxRowsDeleted,\n terminalSourceRowsDeleted: terminalSources.rowsDeleted,\n terminalSourceMaterializationsDeleted: terminalSources.materializationsDeleted,\n }\n }\n\n private async readOperationalSummaries(failures: unknown[]): Promise<{\n readonly outbox: OntologyMaintenanceSnapshot[\"outbox\"]\n readonly terminalSources: OntologyMaintenanceSnapshot[\"terminalSources\"]\n }> {\n const outbox = await captureFailure(\n () => this.storage.ontology.outbox.summarize({ projectId: this.projectId }),\n failures,\n this.snapshot.outbox\n )\n const terminalSummary = await captureFailure(\n () => this.storage.ontology.sources.summarizeTerminal({ projectId: this.projectId }),\n failures,\n this.snapshot.terminalSources\n )\n return { outbox, terminalSources: terminalSummary }\n }\n\n private completePass(input: {\n readonly started: Date\n readonly failures: readonly unknown[]\n readonly cleanup: OntologyMaintenanceCleanupSnapshot\n readonly outbox: OntologyMaintenanceSnapshot[\"outbox\"]\n readonly terminalSources: OntologyMaintenanceSnapshot[\"terminalSources\"]\n }): void {\n const completed = this.now()\n const failure =\n input.failures.length > 0\n ? new AggregateError(input.failures, \"Maintenance pass failed.\")\n : null\n this.snapshot = {\n running: false,\n intervalMs: this.intervalMs,\n lastStartedAt: input.started.toISOString(),\n lastCompletedAt: completed.toISOString(),\n lastDurationMs: Math.max(0, completed.getTime() - input.started.getTime()),\n consecutiveFailures: failure ? this.snapshot.consecutiveFailures + 1 : 0,\n lastError: failure ? errorMessage(failure) : null,\n outbox: input.outbox,\n terminalSources: input.terminalSources,\n cleanup: input.cleanup,\n }\n if (failure) this.reportError(failure)\n }\n\n private scheduleNextPass(): void {\n if (this.owners.size === 0 || this.timer !== null) return\n this.timer = setTimeout(() => {\n this.timer = null\n if (this.owners.size === 0) return\n void this.runNow()\n .catch((error) => this.reportError(error))\n .finally(() => this.scheduleNextPass())\n }, this.intervalMs)\n this.timer.unref?.()\n }\n\n private stopLoop(): Promise<void> {\n if (this.stopping) return this.stopping\n if (this.timer !== null) {\n clearTimeout(this.timer)\n this.timer = null\n }\n const activePass = this.pass ?? Promise.resolve()\n const stopping = settlesWithin(activePass, this.shutdownTimeoutMs).then((settled) => {\n if (!settled) {\n this.reportError(\n new Error(`[Sixb] Ontology maintenance did not stop within ${this.shutdownTimeoutMs}ms.`)\n )\n }\n })\n this.stopping = stopping.finally(() => {\n this.stopping = null\n })\n return this.stopping\n }\n\n private reportError(error: unknown): void {\n try {\n this.onError(error)\n } catch {\n // Maintenance failures stay observable without escaping into runtime lifecycle code.\n }\n }\n}\n\nfunction emptySnapshot(intervalMs: number): OntologyMaintenanceSnapshot {\n return {\n running: false,\n intervalMs,\n lastStartedAt: null,\n lastCompletedAt: null,\n lastDurationMs: null,\n consecutiveFailures: 0,\n lastError: null,\n outbox: null,\n terminalSources: null,\n cleanup: null,\n }\n}\n\nfunction positiveInteger(value: number, name: string): number {\n if (!Number.isSafeInteger(value) || value <= 0) {\n throw new Error(`[Sixb] Ontology maintenance ${name} must be a positive integer.`)\n }\n return value\n}\n\nfunction nonnegativeInteger(value: number, name: string): number {\n if (!Number.isSafeInteger(value) || value < 0) {\n throw new Error(`[Sixb] Ontology maintenance ${name} must be a nonnegative integer.`)\n }\n return value\n}\n\nfunction assertNonblank(value: string, name: string): void {\n if (value.trim().length === 0) {\n throw new Error(`[Sixb] Ontology maintenance ${name} must not be blank.`)\n }\n}\n\nfunction errorMessage(error: unknown): string {\n if (error instanceof AggregateError) {\n return [...error.errors].map(errorMessage).join(\" | \").slice(0, 2_000)\n }\n const message = error instanceof Error ? `${error.name}: ${error.message}` : String(error)\n return message.slice(0, 2_000)\n}\n\nfunction latestTimestamp(left: string | null, right: string | null): string | null {\n if (left === null) return right\n if (right === null) return left\n return Date.parse(left) >= Date.parse(right) ? left : right\n}\n\nasync function settlesWithin(promise: Promise<void>, timeoutMs: number): Promise<boolean> {\n let timer: ReturnType<typeof setTimeout> | undefined\n const timedOut = new Promise<false>((resolve) => {\n timer = setTimeout(() => resolve(false), timeoutMs)\n })\n const result = await Promise.race([\n promise.then(\n () => true as const,\n () => true as const\n ),\n timedOut,\n ])\n if (timer !== undefined) clearTimeout(timer)\n return result\n}\n\nasync function captureFailure(run: () => Promise<void>, failures: unknown[]): Promise<void>\nasync function captureFailure<T>(\n run: () => Promise<T>,\n failures: unknown[],\n fallback: T\n): Promise<T>\nasync function captureFailure<T>(\n run: () => Promise<T>,\n failures: unknown[],\n fallback?: T\n): Promise<T | undefined> {\n try {\n return await run()\n } catch (error) {\n failures.push(error)\n return fallback\n }\n}\n",
14
+ "import { type ResolvedRole, resolveRoleGrants } from \"../authorization\"\nimport { APPLICATION_IDS } from \"./applications\"\nimport type {\n GroupDefinition,\n MembershipPolicyDefinition,\n RoleDefinition,\n SecurityRegistry,\n} from \"./types\"\nimport { validateSecurityDefinitionsAtStartup } from \"./validation\"\n\nclass RuntimeSecurityRegistry implements SecurityRegistry {\n constructor(\n private readonly groupsById: ReadonlyMap<string, GroupDefinition>,\n private readonly rolesById: ReadonlyMap<string, RoleDefinition>,\n private readonly membershipPoliciesById: ReadonlyMap<string, MembershipPolicyDefinition>,\n private readonly resolvedRoles: readonly ResolvedRole[]\n ) {}\n\n listGroups(): readonly GroupDefinition[] {\n return [...this.groupsById.values()]\n }\n\n getGroupById(groupId: string): GroupDefinition | null {\n return this.groupsById.get(groupId) ?? null\n }\n\n listRoles(): readonly RoleDefinition[] {\n return [...this.rolesById.values()]\n }\n\n getRoleById(roleId: string): RoleDefinition | null {\n return this.rolesById.get(roleId) ?? null\n }\n\n listResolvedRoles(): readonly ResolvedRole[] {\n return this.resolvedRoles\n }\n\n listMembershipPolicies(): readonly MembershipPolicyDefinition[] {\n return [...this.membershipPoliciesById.values()]\n }\n\n getMembershipPolicyById(policyId: string): MembershipPolicyDefinition | null {\n return this.membershipPoliciesById.get(policyId) ?? null\n }\n}\n\nexport function createRuntimeSecurityRegistry(input: {\n readonly groups?: readonly GroupDefinition[]\n readonly roles?: readonly RoleDefinition[]\n readonly membershipPolicies?: readonly MembershipPolicyDefinition[]\n readonly applicationIds?: ReadonlySet<string>\n readonly objectTypeIds?: ReadonlySet<string>\n readonly datasetIds?: ReadonlySet<string>\n readonly actionIds?: ReadonlySet<string>\n readonly workflowIds?: ReadonlySet<string>\n readonly syncIds?: ReadonlySet<string>\n readonly pipelineIds?: ReadonlySet<string>\n readonly agentIds?: ReadonlySet<string>\n readonly getSubTypes?: (objectTypeId: string) => readonly string[]\n}): SecurityRegistry {\n const securityDefinitions = validateSecurityDefinitionsAtStartup({\n groups: input.groups ?? [],\n roles: input.roles ?? [],\n membershipPolicies: input.membershipPolicies ?? [],\n applicationIds: input.applicationIds ?? APPLICATION_IDS,\n objectTypeIds: input.objectTypeIds,\n datasetIds: input.datasetIds,\n actionIds: input.actionIds,\n workflowIds: input.workflowIds,\n syncIds: input.syncIds,\n pipelineIds: input.pipelineIds,\n agentIds: input.agentIds,\n observableIds: new Set([\"logs\"]),\n })\n\n const universe = {\n applicationIds: input.applicationIds ?? APPLICATION_IDS,\n objectTypeIds: input.objectTypeIds ?? new Set<string>(),\n datasetIds: input.datasetIds ?? new Set<string>(),\n actionIds: input.actionIds ?? new Set<string>(),\n workflowIds: input.workflowIds ?? new Set<string>(),\n syncIds: input.syncIds ?? new Set<string>(),\n pipelineIds: input.pipelineIds ?? new Set<string>(),\n agentIds: input.agentIds ?? new Set<string>(),\n observableIds: new Set([\"logs\"]),\n getSubTypes: input.getSubTypes ?? (() => []),\n }\n const resolvedRoles = securityDefinitions.roles.map((role) => ({\n id: role.id,\n grantedToGroupIds: role.grantedToGroupIds,\n grants: resolveRoleGrants(role, universe),\n }))\n\n return new RuntimeSecurityRegistry(\n securityDefinitions.groupsById,\n securityDefinitions.rolesById,\n securityDefinitions.membershipPoliciesById,\n resolvedRoles\n )\n}\n",
15
+ "import type { DatasetDefinition } from \"../datasets\"\nimport type { PipelineDefinition } from \"../pipelines\"\nimport type { TelemetryProjectionDefinition } from \"../projections\"\nimport { SyncValidationError } from \"./errors\"\nimport type { SyncDefinition } from \"./types\"\n\ninterface DatasetWriter {\n readonly datasetId: string\n readonly label: string\n}\n\nexport function validateKeyedDatasetWriterTopology(input: {\n readonly datasetsById: ReadonlyMap<string, DatasetDefinition>\n readonly syncs: readonly SyncDefinition[]\n readonly pipelines: readonly PipelineDefinition[]\n}): void {\n for (const sync of input.syncs) {\n const dataset = input.datasetsById.get(sync.target.dataset.id)\n if (sync.config.mode === \"merge\" && dataset?.primaryKey === undefined) {\n throw new SyncValidationError(\n `[Sixb] Merge sync '${sync.id}' targets dataset '${sync.target.dataset.id}', which must define a primaryKey.`\n )\n }\n }\n\n const firstWriterByDataset = new Map<string, DatasetWriter>()\n for (const writer of datasetWriters(input.syncs, input.pipelines)) {\n const dataset = input.datasetsById.get(writer.datasetId)\n if (dataset?.primaryKey === undefined) continue\n\n const first = firstWriterByDataset.get(writer.datasetId)\n if (!first) {\n firstWriterByDataset.set(writer.datasetId, writer)\n continue\n }\n\n throw new SyncValidationError(\n `[Sixb] Keyed dataset '${writer.datasetId}' has multiple registered writers: ${first.label} and ${writer.label}. V1 allows one writer per keyed dataset.`\n )\n }\n}\n\nexport function validateMergeSyncProjectionSafety(input: {\n readonly syncs: readonly SyncDefinition[]\n readonly telemetryProjections: readonly TelemetryProjectionDefinition[]\n}): void {\n const mergeSyncByDataset = new Map(\n input.syncs\n .filter((sync) => sync.config.mode === \"merge\")\n .map((sync) => [sync.target.dataset.id, sync] as const)\n )\n\n for (const projection of input.telemetryProjections) {\n const sync = mergeSyncByDataset.get(projection.datasetId)\n if (!sync) continue\n throw new SyncValidationError(\n `[Sixb] Telemetry projection '${projection.id}' cannot read merge-written dataset '${projection.datasetId}' from sync '${sync.id}'. V1 merge syncs support object and link replacement projections only.`\n )\n }\n}\n\nfunction* datasetWriters(\n syncs: readonly SyncDefinition[],\n pipelines: readonly PipelineDefinition[]\n): Iterable<DatasetWriter> {\n for (const sync of syncs) {\n yield { datasetId: sync.target.dataset.id, label: `sync '${sync.id}'` }\n }\n for (const pipeline of pipelines) {\n for (const node of pipeline.graph.nodes) {\n yield {\n datasetId: node.step.output.id,\n label: `pipeline '${pipeline.id}' step '${node.step.id}'`,\n }\n }\n }\n}\n",
16
+ "/**\n * Scoped SDK surface returned by `sixb.as(context)`.\n *\n * The scoped types are masks over the full SDK types — derived from the same\n * declarations, never copies — so signatures cannot drift and new surface area\n * stays hidden until its grants are enforceable end to end. The runtime values\n * are the same factories running over an authorization-carrying runtime\n * context; leaf asserts and query planning enforce the grants.\n */\n\nimport type {\n ActionDefinition,\n RequestActionAndWaitInput,\n RequestActionInput,\n RequestActionResult,\n} from \"../actions\"\nimport {\n requestAction as requestRuntimeAction,\n requestActionAndWait as requestRuntimeActionAndWait,\n} from \"../actions/request\"\nimport type {\n AgentDefinition,\n AgentsRuntime,\n RequestAgentRunInput,\n RequestAgentRunResult,\n ScopedListAgentThreadsInput,\n} from \"../agents\"\nimport {\n type AuthorizationContext,\n type AuthzRequest,\n assertAuthorized,\n canViewEvent,\n isAllowed,\n} from \"../authorization\"\nimport type { DatasetDefinition } from \"../datasets\"\nimport type { EventsReadInput, StoredDomainEvent } from \"../events\"\nimport { createObjectSet, objectService } from \"../objects\"\nimport type { ListObjectsParams } from \"../objects/service\"\nimport type { ValueType } from \"../ontology\"\nimport { assertObjectTypeRegistered } from \"../ontology\"\nimport type { ObjectTypeWithPropertyTokens } from \"../ontology/tokens\"\nimport type { PipelineDefinition } from \"../pipelines\"\nimport { PipelineError } from \"../pipelines\"\nimport {\n type PipelineRunRequestResult,\n type RequestPipelineRunInput,\n requestPipelineRun,\n} from \"../pipelines/request\"\nimport type { ObjectRow } from \"../storage\"\nimport type { ActionRunRecord } from \"../storage/action-runs\"\nimport type { AgentThreadRecord, ListAgentThreadsResult } from \"../storage/agents\"\nimport type { SyncDefinition } from \"../syncs\"\nimport { SyncValidationError } from \"../syncs\"\nimport {\n type RequestSyncRunInput,\n requestSyncRun,\n type SyncRunRequestResult,\n} from \"../syncs/request\"\nimport type {\n RequestWorkflowRunInput,\n WorkflowDefinition,\n WorkflowRunRequestResult,\n WorkflowsRuntime,\n} from \"../workflows\"\nimport type {\n ListResult,\n ObjectByIdHandle,\n ObjectSet,\n OntologySource,\n RegisteredObjectType,\n RegisteredValueTypes,\n SixbInstance,\n SixbRuntimeContext,\n} from \"./types\"\n\n// Scoped members are indexed accesses of the full SDK types rather than\n// `Pick`s: signatures stay single-sourced (no drift), while indexed access\n// stays lazy — mapped types would eagerly materialize every method's deep\n// query/telemetry conditionals and blow the instantiation depth limit.\nexport interface ScopedObjectByIdHandle<\n TObjectType extends ObjectTypeWithPropertyTokens,\n TValueTypes extends readonly ValueType[],\n> {\n get: ObjectByIdHandle<TObjectType, TValueTypes>[\"get\"]\n requestAction: ObjectByIdHandle<TObjectType, TValueTypes>[\"requestAction\"]\n requestActionAndWait: ObjectByIdHandle<TObjectType, TValueTypes>[\"requestActionAndWait\"]\n /** Requires `edit:object` on this type and `view:object` on the link target. */\n link: ObjectByIdHandle<TObjectType, TValueTypes>[\"link\"]\n /** Requires `edit:object` on this type and `view:object` on the link target. */\n unlink: ObjectByIdHandle<TObjectType, TValueTypes>[\"unlink\"]\n /** Requires `edit:object`. */\n delete: ObjectByIdHandle<TObjectType, TValueTypes>[\"delete\"]\n /** Requires `edit:object`. */\n restore: ObjectByIdHandle<TObjectType, TValueTypes>[\"restore\"]\n /** `append()` requires `append:telemetry`; `history()` requires `view:object`. */\n telemetry: ObjectByIdHandle<TObjectType, TValueTypes>[\"telemetry\"]\n // `listLinks` stays off this surface: its rows name target types that no read grant covers.\n}\n\nexport interface ScopedObjectSet<\n TObjectType extends ObjectTypeWithPropertyTokens,\n TValueTypes extends readonly ValueType[],\n TRegisteredObjectTypes extends ObjectTypeWithPropertyTokens = TObjectType,\n> {\n get: ObjectSet<TObjectType, TValueTypes, TRegisteredObjectTypes>[\"get\"]\n list: ObjectSet<TObjectType, TValueTypes, TRegisteredObjectTypes>[\"list\"]\n query: ObjectSet<TObjectType, TValueTypes, TRegisteredObjectTypes>[\"query\"]\n requestAction: ObjectSet<TObjectType, TValueTypes, TRegisteredObjectTypes>[\"requestAction\"]\n requestActionAndWait: ObjectSet<\n TObjectType,\n TValueTypes,\n TRegisteredObjectTypes\n >[\"requestActionAndWait\"]\n /** Requires `view:object` and `edit:object`. */\n upsert: ObjectSet<TObjectType, TValueTypes, TRegisteredObjectTypes>[\"upsert\"]\n /** Requires `edit:object` on this type and `view:object` on the link target. */\n upsertLink: ObjectSet<TObjectType, TValueTypes, TRegisteredObjectTypes>[\"upsertLink\"]\n /** Requires `edit:object` on this type and `view:object` on the link target. */\n removeLink: ObjectSet<TObjectType, TValueTypes, TRegisteredObjectTypes>[\"removeLink\"]\n /** Requires `append:telemetry` — and notably not `view:object`. */\n appendTelemetryBatch: ObjectSet<\n TObjectType,\n TValueTypes,\n TRegisteredObjectTypes\n >[\"appendTelemetryBatch\"]\n\n /** Bind read, write, and action operations to a specific object id. */\n byId(id: string): ScopedObjectByIdHandle<TObjectType, TValueTypes>\n}\n\n/**\n * Principal-scoped runtime surface.\n *\n * Exposes only operations whose grants are enforceable end to end (`can.view`, `can.edit`,\n * `can.append`, `can.apply`, `can.run`, `can.observe`). Infra handles, lifecycle, auth\n * administration, and `listLinks` stay on the privileged runtime.\n */\nexport interface ScopedSixb<TOntologySources extends readonly OntologySource[]> {\n /** The authorization context this SDK instance enforces. */\n readonly authorization: AuthorizationContext\n\n /** Type-safe ObjectSet narrowed to grant-enforceable operations. */\n objects<TObjectType extends RegisteredObjectType<TOntologySources>>(\n objectType: TObjectType\n ): ScopedObjectSet<\n TObjectType,\n RegisteredValueTypes<TOntologySources>,\n RegisteredObjectType<TOntologySources>\n >\n\n /** Cross-type listing narrowed to the principal's viewable object types. */\n list(params: ListObjectsParams): Promise<ListResult<ObjectRow>>\n\n /** Get an object by type id and primary id (server / dynamic contexts). */\n getObject(objectTypeId: string, primaryId: string): Promise<ObjectRow | null>\n\n /**\n * The primary property of a type the principal may view.\n *\n * Asserts before it looks the type up, which is the whole point of having it here: the privileged\n * lookup answers \"unknown type\" for an unregistered id and a primary property for a registered\n * one, so a caller that reaches it before any grant check can tell the two apart. Every other\n * ontology read is grant-filtered — `listObjectTypes` returns only viewable types — and this\n * matches them.\n */\n getPrimaryPropertyId: SixbInstance<TOntologySources>[\"getPrimaryPropertyId\"]\n\n // The string-based write entry points, indexed off the full runtime rather than restated, so the\n // surface that now carries authorization cannot drift from the one it delegates to.\n /** Upsert an object by type id. Requires `view:object` and `edit:object`. */\n upsertObject: SixbInstance<TOntologySources>[\"upsertObject\"]\n /** Batch upsert objects of one type. Requires `view:object` and `edit:object`. */\n upsertObjectBatch: SixbInstance<TOntologySources>[\"upsertObjectBatch\"]\n /** Create or update a link. Requires `edit:object` on the source, `view:object` on the target. */\n upsertLink: SixbInstance<TOntologySources>[\"upsertLink\"]\n /** Batch upsert links. Asserted for every item before anything commits. */\n upsertLinkBatch: SixbInstance<TOntologySources>[\"upsertLinkBatch\"]\n /** Remove a link. Requires `edit:object` on the source, `view:object` on the target. */\n removeLink: SixbInstance<TOntologySources>[\"removeLink\"]\n /** Append telemetry. Requires `append:telemetry` — and notably not `view:object`. */\n appendTelemetry: SixbInstance<TOntologySources>[\"appendTelemetry\"]\n\n /** Dataset definitions the principal may view. */\n listDatasets(): readonly DatasetDefinition[]\n\n /** Look up a viewable dataset definition; null hides ungranted datasets. */\n getDatasetById(datasetId: string): DatasetDefinition | null\n\n /** Action definitions the principal may apply. */\n listActions(): readonly ActionDefinition[]\n\n /** Look up an applicable action definition; null hides ungranted actions. */\n getActionById(actionId: string): ActionDefinition | null\n\n /** Request an action by id (server / dynamic contexts). Requires `can.apply`. */\n requestAction(input: RequestActionInput): Promise<RequestActionResult>\n\n /** Request an action by id and wait for the run to settle. Requires `can.apply`. */\n requestActionAndWait(input: RequestActionAndWaitInput): Promise<ActionRunRecord>\n\n /** Workflow definitions the principal may run. */\n listWorkflows(): readonly WorkflowDefinition[]\n\n /** Look up a runnable workflow definition; null hides workflows the principal cannot run. */\n getWorkflowById(workflowId: string): WorkflowDefinition | null\n\n /** Queue a workflow run. Requires `can.run`. */\n requestWorkflowRun(input: RequestWorkflowRunInput): Promise<WorkflowRunRequestResult>\n\n /** Sync definitions the principal may run. */\n listSyncs(): readonly SyncDefinition[]\n\n /** Look up a runnable sync definition; null hides syncs the principal cannot run. */\n getSyncById(syncId: string): SyncDefinition | null\n\n /** Queue a sync run. Requires `can.run`. */\n requestSyncRun(input: RequestSyncRunInput): Promise<SyncRunRequestResult>\n\n /** Pipeline definitions the principal may run. */\n listPipelines(): readonly PipelineDefinition[]\n\n /** Look up a runnable pipeline definition; null hides pipelines the principal cannot run. */\n getPipelineById(pipelineId: string): PipelineDefinition | null\n\n /** Queue a pipeline run. Requires `can.run`. */\n requestPipelineRun(input: RequestPipelineRunInput): Promise<PipelineRunRequestResult>\n\n /** Agent definitions the principal may run. */\n listAgents(): readonly AgentDefinition[]\n\n /** Look up a runnable agent definition; null hides agents the principal cannot run. */\n getAgentById(agentId: string): AgentDefinition | null\n\n /** Request an agent turn. Requires `can.run`. */\n requestAgentRun(input: RequestAgentRunInput): Promise<RequestAgentRunResult>\n\n /** List agent threads the principal owns and may run (owner + `run:agent` filtered). */\n listThreads(input?: ScopedListAgentThreadsInput): Promise<ListAgentThreadsResult>\n\n /** Read one agent thread the principal owns and may run; null hides inaccessible threads. */\n getThread(threadId: string): Promise<AgentThreadRecord | null>\n\n /** Read the domain events the principal is allowed to see (derived from grants). */\n readEvents(input?: EventsReadInput): Promise<readonly StoredDomainEvent[]>\n}\n\nexport function createScopedSixb<TOntologySources extends readonly OntologySource[]>(\n runtime: SixbRuntimeContext & { readonly authorization: AuthorizationContext },\n deps: {\n readonly datasets: {\n readonly list: () => readonly DatasetDefinition[]\n readonly getById: (datasetId: string) => DatasetDefinition | null\n }\n readonly syncs: {\n readonly list: () => readonly SyncDefinition[]\n readonly getById: (syncId: string) => SyncDefinition | null\n }\n readonly pipelines: {\n readonly list: () => readonly PipelineDefinition[]\n readonly getById: (pipelineId: string) => PipelineDefinition | null\n }\n readonly workflows: WorkflowsRuntime\n readonly agents: AgentsRuntime\n }\n): ScopedSixb<TOntologySources> {\n const canListAction = (action: ActionDefinition) =>\n isAllowed(runtime.authorization, { kind: \"action.apply\", actionId: action.id }) &&\n (action.binding.kind === \"global\" ||\n isAllowed(runtime.authorization, {\n kind: \"object.view\",\n objectTypeId: action.binding.objectType.id,\n }))\n\n // A scoped catalog narrows a definition source to what the principal may see.\n // The run/view grant doubles as catalog visibility: a definition the principal\n // cannot run/view is not worth surfacing, and hiding it also hides the\n // (possibly ungranted) resources its shape references.\n const scopedCatalog = <T extends { readonly id: string }>(\n source: { list(): readonly T[]; getById(id: string): T | null },\n toRequest: (id: string) => AuthzRequest\n ) => {\n const allowed = (id: string) => isAllowed(runtime.authorization, toRequest(id))\n return {\n list: () => source.list().filter((item) => allowed(item.id)),\n getById: (id: string) => {\n const item = source.getById(id)\n return item && allowed(id) ? item : null\n },\n }\n }\n\n const datasets = scopedCatalog(deps.datasets, (datasetId) => ({\n kind: \"dataset.view\",\n datasetId,\n }))\n const syncs = scopedCatalog(deps.syncs, (syncId) => ({ kind: \"sync.run\", syncId }))\n const pipelines = scopedCatalog(deps.pipelines, (pipelineId) => ({\n kind: \"pipeline.run\",\n pipelineId,\n }))\n const workflows = scopedCatalog(deps.workflows, (workflowId) => ({\n kind: \"workflow.run\",\n workflowId,\n }))\n const agents = scopedCatalog(deps.agents, (agentId) => ({ kind: \"agent.run\", agentId }))\n\n const scoped = {\n authorization: runtime.authorization,\n\n objects<TObjectType extends RegisteredObjectType<TOntologySources>>(objectType: TObjectType) {\n assertObjectTypeRegistered(runtime.ontology.getObjectTypesById(), objectType)\n\n return createObjectSet<\n TObjectType,\n RegisteredObjectType<TOntologySources>,\n RegisteredValueTypes<TOntologySources>\n >({ ...runtime, objectType })\n },\n\n list: (params: ListObjectsParams) => objectService.listObjects(runtime, params),\n\n getObject: async (objectTypeId: string, primaryId: string) => {\n assertAuthorized(runtime, { kind: \"object.view\", objectTypeId })\n return runtime.storage.objects.getByPrimaryId({\n projectId: runtime.projectId,\n objectTypeId,\n primaryId,\n })\n },\n\n getPrimaryPropertyId: (objectTypeId: string) => {\n assertAuthorized(runtime, { kind: \"object.view\", objectTypeId })\n return runtime.ontology.getPrimaryPropertyId(objectTypeId)\n },\n\n // Same delegation as the privileged runtime's own methods; the leaves assert the grants off\n // `runtime.authorization`, which is present here by construction.\n upsertObject: (objectTypeId: string, properties: Record<string, unknown>) =>\n objectService.upsertObject(runtime, objectTypeId, properties),\n\n upsertObjectBatch: (\n objectTypeId: string,\n items: readonly { properties: Record<string, unknown> }[]\n ) => objectService.upsertObjectBatch(runtime, objectTypeId, items),\n\n upsertLink: (\n objectTypeId: string,\n sourceId: string,\n linkId: string,\n target: { targetTypeId: string; targetId: string; properties?: Record<string, unknown> }\n ) => objectService.upsertLink(runtime, objectTypeId, sourceId, linkId, target),\n\n upsertLinkBatch: (\n items: readonly {\n objectTypeId: string\n sourceId: string\n linkId: string\n target: { targetTypeId: string; targetId: string; properties?: Record<string, unknown> }\n }[]\n ) => objectService.upsertLinkBatch(runtime, items),\n\n removeLink: (\n objectTypeId: string,\n sourceId: string,\n linkId: string,\n target: { targetTypeId: string; targetId: string }\n ) => objectService.removeLink(runtime, objectTypeId, sourceId, linkId, target),\n\n appendTelemetry: (\n objectTypeId: string,\n items: readonly { id: string; properties: Record<string, unknown>; at?: Date }[]\n ) => objectService.appendTelemetry(runtime, objectTypeId, items),\n\n listDatasets: datasets.list,\n getDatasetById: datasets.getById,\n\n listActions: () => runtime.actionRegistry.list().filter((action) => canListAction(action)),\n\n getActionById: (actionId: string) => {\n const action = runtime.actionRegistry.getById(actionId)\n return action && canListAction(action) ? action : null\n },\n\n requestAction: (input: RequestActionInput) => requestRuntimeAction(runtime, input),\n\n // Gated by the same `can.apply` assertion: `requestActionAndWait` requests through\n // `requestAction` and then only reads the run it just created.\n requestActionAndWait: (input: RequestActionAndWaitInput) =>\n requestRuntimeActionAndWait(runtime, input),\n\n listWorkflows: workflows.list,\n getWorkflowById: workflows.getById,\n\n requestWorkflowRun: (input: RequestWorkflowRunInput) =>\n deps.workflows.requestByIdAs(runtime, input),\n\n listSyncs: syncs.list,\n getSyncById: syncs.getById,\n requestSyncRun: async (input: RequestSyncRunInput) => {\n // Resolve against the full registry, not the grant-filtered one: an existing sync the caller\n // may not run has to report \"forbidden\", the same as `requestAction`. Only a genuinely unknown\n // id is \"unknown\". `requestSyncRun` asserts the grant.\n const sync = deps.syncs.getById(input.syncId)\n if (!sync) throw new SyncValidationError(`[Sixb] Unknown sync '${input.syncId}'`)\n return requestSyncRun(runtime, sync, input)\n },\n\n listPipelines: pipelines.list,\n getPipelineById: pipelines.getById,\n requestPipelineRun: async (input: RequestPipelineRunInput) => {\n const pipeline = deps.pipelines.getById(input.pipelineId)\n if (!pipeline) throw new PipelineError(`[Sixb] Unknown pipeline '${input.pipelineId}'`)\n return requestPipelineRun(runtime, pipeline, input)\n },\n\n listAgents: agents.list,\n getAgentById: agents.getById,\n requestAgentRun: (input: RequestAgentRunInput) => deps.agents.requestAs(runtime, input),\n listThreads: (input?: ScopedListAgentThreadsInput) => deps.agents.listThreadsAs(runtime, input),\n getThread: (threadId: string) => deps.agents.getThreadAs(runtime, threadId),\n\n // No standalone events grant: the stream is filtered to events whose\n // subject the principal may view/apply/run. `limit` applies before this\n // filter, so a page may return fewer events than requested — acceptable for\n // a best-effort recent log (storage-level filtering is the planned fix).\n readEvents: async (input?: EventsReadInput) => {\n const events = await runtime.events.read(input)\n return events.filter((event) => canViewEvent(runtime.authorization, event))\n },\n }\n\n // Boundary cast: checking the literal against ScopedSixb<TOntologySources>\n // triggers excessively deep ObjectSet instantiation (same constraint noted\n // on SixbInstance). The mask only hides members of the full SDK values.\n return scoped as unknown as ScopedSixb<TOntologySources>\n}\n",
17
+ "import type { SixbReadiness } from \"../maintenance\"\nimport { checkStorageSchema, isMigrationCapableStorage, type Storage } from \"../storage\"\n\nconst DEFAULT_SCHEMA_RETRY_DELAY_MS = 60_000\n\ntype SchemaReadiness =\n | { readonly status: \"unchecked\" | \"checking\" }\n | { readonly status: \"valid\" }\n | { readonly status: \"invalid\"; readonly reason: string; readonly retryAt: number }\n\ninterface StorageReadinessOptions {\n readonly schemaRetryDelayMs?: number\n readonly now?: () => Date\n}\n\n/** Caches the process schema invariant while keeping each readiness probe lock-free. */\nexport class StorageReadiness {\n private schema: SchemaReadiness\n private readonly schemaRetryDelayMs: number\n private readonly now: () => Date\n\n constructor(\n private readonly storage: Storage,\n options: StorageReadinessOptions = {}\n ) {\n this.schemaRetryDelayMs = positiveInteger(\n options.schemaRetryDelayMs ?? DEFAULT_SCHEMA_RETRY_DELAY_MS,\n \"schemaRetryDelayMs\"\n )\n this.now = options.now ?? (() => new Date())\n this.schema = isMigrationCapableStorage(storage) ? { status: \"unchecked\" } : { status: \"valid\" }\n }\n\n startSchemaValidation(): void {\n if (this.schema.status === \"checking\" || this.schema.status === \"valid\") return\n if (this.schema.status === \"invalid\" && this.now().getTime() < this.schema.retryAt) return\n this.schema = { status: \"checking\" }\n void this.validateSchema()\n }\n\n async check(): Promise<SixbReadiness> {\n try {\n await this.storage.ping()\n } catch {\n return {\n status: \"unready\",\n storage: { reachable: false, schemaValid: false },\n reason: \"Storage is unreachable.\",\n }\n }\n\n this.startSchemaValidation()\n if (this.schema.status === \"valid\") {\n return { status: \"ready\", storage: { reachable: true, schemaValid: true } }\n }\n\n return {\n status: \"unready\",\n storage: { reachable: true, schemaValid: false },\n reason:\n this.schema.status === \"invalid\"\n ? this.schema.reason\n : \"Storage schema validation is in progress.\",\n }\n }\n\n private async validateSchema(): Promise<void> {\n // Shared with `sixb check`, so the panel an author reads before deploying and the\n // `/ready` a load balancer polls after cannot disagree about what \"usable\" means.\n const result = await checkStorageSchema(this.storage)\n\n this.schema = result.ok\n ? { status: \"valid\" }\n : this.invalidSchema(result.reason ?? \"Storage schema is not usable.\")\n }\n\n private invalidSchema(reason: string): SchemaReadiness {\n return {\n status: \"invalid\",\n reason,\n retryAt: this.now().getTime() + this.schemaRetryDelayMs,\n }\n }\n}\n\nfunction positiveInteger(value: number, name: string): number {\n if (!Number.isSafeInteger(value) || value <= 0) {\n throw new Error(`[Sixb] Storage readiness ${name} must be a positive integer.`)\n }\n return value\n}\n"
18
+ ],
19
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,+BAA+B,MAAM;AAAA,EACvC,OAAO;AAClB;;;ACwBO,SAAS,aAAa,CAAC,IAAkC;AAAA,EAC9D,eAAe,IAAI,YAAY;AAAA,EAC/B,OAAO,IAAI,qBAAqB,EAAE;AAAA;AAAA;AAG7B,MAAM,qBAAwC;AAAA,EACtB;AAAA,EAA7B,WAAW,CAAkB,IAAY;AA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AAAA,IAChD,UAAU,CAAC,GAAI,QAAQ,YAAY,CAAC,GAAI,GAAG,QAAQ;AAAA,IACnD,YAAY,CAAC,GAAI,QAAQ,cAAc,CAAC,GAAI,GAAG,UAAU;AAAA,IACzD,WAAW,CAAC,GAAI,QAAQ,aAAa,CAAC,GAAI,GAAG,SAAS;AAAA,IACtD,OAAO,CAAC,GAAI,QAAQ,SAAS,CAAC,GAAI,GAAG,KAAK;AAAA,IAC1C,WAAW,CAAC,GAAI,QAAQ,aAAa,CAAC,GAAI,GAAG,SAAS;AAAA,IACtD,aAAa,CAAC,GAAI,QAAQ,eAAe,CAAC,GAAI,GAAG,WAAW;AAAA,IAC5D,OAAO,CAAC,GAAI,QAAQ,SAAS,CAAC,GAAI,GAAG,KAAK;AAAA,IAC1C,WAAW,CAAC,GAAI,QAAQ,aAAa,CAAC,GAAI,GAAG,SAAS;AAAA,IACtD,QAAQ,CAAC,GAAI,QAAQ,UAAU,CAAC,GAAI,GAAG,MAAM;AAAA,IAC7C,OAAO,CAAC,GAAI,QAAQ,SAAS,CAAC,GAAI,GAAG,KAAK;AAAA,IAC1C,oBAAoB,CAAC,GAAI,QAAQ,sBAAsB,CAAC,GAAI,GAAG,kBAAkB;AAAA,IACjF,QAAQ,CAAC,GAAI,QAAQ,UAAU,CAAC,GAAI,GAAG,MAAM;AAAA,IAC7C,MAAM,QAAQ;AAAA,EAChB,CAAC;AAAA;",
20
+ "debugId": "7B1968C15C65FC4364756E2164756E21",
21
+ "names": []
22
+ }
@@ -1,17 +1,17 @@
1
1
  // @bun
2
2
  import {
3
3
  isStorageSerializationFailure
4
- } from "./chunk-aebzcsxr.js";
4
+ } from "./chunk-raq0x6bd.js";
5
5
  import {
6
6
  materializationApplyPhase
7
- } from "./chunk-q4qzq0ea.js";
7
+ } from "./chunk-hb9xcx9c.js";
8
8
  import {
9
9
  createCommitId,
10
10
  createEventId,
11
11
  createRequestHash,
12
12
  materializationEventKindOrdinal,
13
13
  sha256Canonical
14
- } from "./chunk-wxhdnwh4.js";
14
+ } from "./chunk-bh8bwma3.js";
15
15
  import {
16
16
  assertPinnedDatasetWatermark
17
17
  } from "./chunk-9dzba0f2.js";
@@ -32,7 +32,7 @@ import {
32
32
  telemetryPointKey,
33
33
  telemetryPointSortKey,
34
34
  utf8JsonByteLength
35
- } from "./chunk-p6r5g77m.js";
35
+ } from "./chunk-8kv2sez0.js";
36
36
  import {
37
37
  MaterializationCancellationError,
38
38
  MaterializationConflictError,
@@ -48,18 +48,18 @@ import {
48
48
  validateObjectProperties,
49
49
  validatePropertyValue,
50
50
  validateTelemetryUnit
51
- } from "./chunk-tsk2bxs3.js";
51
+ } from "./chunk-53s4asfm.js";
52
52
  import {
53
53
  ProjectionValidationError,
54
54
  isProjectionDefinition,
55
55
  validateProjectionsAtStartup
56
- } from "./chunk-btpe64e4.js";
56
+ } from "./chunk-m9w0artv.js";
57
57
  import {
58
58
  assertJsonValue,
59
59
  cloneJsonValue,
60
60
  compareStrings,
61
61
  stableJsonStringify
62
- } from "./chunk-1vffvydj.js";
62
+ } from "./chunk-be9vm29v.js";
63
63
  // src/projections/revision.ts
64
64
  function computeOntologyRevision(ontology) {
65
65
  const referencedValueTypeIds = collectOntologyValueTypeDependencies(ontology);
@@ -3,7 +3,7 @@ import {
3
3
  cloneJsonValue,
4
4
  getInvalidJsonValueReason,
5
5
  stableJsonStringify
6
- } from "./chunk-1vffvydj.js";
6
+ } from "./chunk-be9vm29v.js";
7
7
 
8
8
  // src/agents/errors.ts
9
9
  class AgentDefinitionError extends Error {
@@ -14,6 +14,21 @@ class AgentMessageAdapterError extends Error {
14
14
  name = "AgentMessageAdapterError";
15
15
  }
16
16
 
17
+ class AgentToolPublicError extends Error {
18
+ name = "AgentToolPublicError";
19
+ }
20
+
21
+ class AgentToolResultValidationError extends Error {
22
+ toolName;
23
+ reason;
24
+ name = "AgentToolResultValidationError";
25
+ constructor(toolName, reason, options) {
26
+ super(`[Sixb] Agent tool '${toolName}' result must be a JSON value; ${reason}.`, options);
27
+ this.toolName = toolName;
28
+ this.reason = reason;
29
+ }
30
+ }
31
+
17
32
  class AgentRequestError extends Error {
18
33
  code;
19
34
  name = "AgentRequestError";
@@ -136,6 +151,6 @@ function invalidContext(message) {
136
151
  throw new AgentRequestError("invalid_context", `[Sixb] Invalid agent context: ${message}.`);
137
152
  }
138
153
 
139
- export { AgentDefinitionError, AgentMessageAdapterError, AgentRequestError, MAX_AGENT_CONTEXT_ENTRIES, MAX_AGENT_APP_STATE_ENTRY_BYTES, MAX_AGENT_APP_STATE_TOTAL_BYTES, agentContext, agentContextIdentity, agentContextFingerprint, normalizeAgentContextEntries };
154
+ export { AgentDefinitionError, AgentMessageAdapterError, AgentToolPublicError, AgentToolResultValidationError, AgentRequestError, MAX_AGENT_CONTEXT_ENTRIES, MAX_AGENT_APP_STATE_ENTRY_BYTES, MAX_AGENT_APP_STATE_TOTAL_BYTES, agentContext, agentContextIdentity, agentContextFingerprint, normalizeAgentContextEntries };
140
155
 
141
- //# debugId=2356DA13EB8987D664756E2164756E21
156
+ //# debugId=86564C87A0ED8E7F64756E2164756E21