@opengeni/core 1.0.1 → 2.1.0-canary.0

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 (99) hide show
  1. package/dist/access/index.d.ts +37 -0
  2. package/dist/application/new-session-drafts.d.ts +8 -1
  3. package/dist/application/session-commands.d.ts +18 -11
  4. package/dist/application/session-tenancy.d.ts +18 -0
  5. package/dist/application/user-resource-grants.d.ts +20 -0
  6. package/dist/{chunk-6WKPWE5S.js → chunk-H7X52RI2.js} +27 -18
  7. package/dist/chunk-H7X52RI2.js.map +1 -0
  8. package/dist/{chunk-JJU6I5XD.js → chunk-VCZFFEPB.js} +21 -9
  9. package/dist/chunk-VCZFFEPB.js.map +1 -0
  10. package/dist/{chunk-NYPMQ7NO.js → chunk-ZYCNLYGH.js} +29 -27
  11. package/dist/chunk-ZYCNLYGH.js.map +1 -0
  12. package/dist/dependencies.d.ts +12 -1
  13. package/dist/domain/automations.d.ts +51 -0
  14. package/dist/domain/company-brain-governed-writes.d.ts +70 -0
  15. package/dist/domain/company-profile-agent-admin.d.ts +24 -0
  16. package/dist/domain/connection-authority.d.ts +97 -0
  17. package/dist/domain/connection-authority.js +169 -0
  18. package/dist/domain/connection-authority.js.map +1 -0
  19. package/dist/domain/editable-artifacts/service.d.ts +1 -2
  20. package/dist/domain/environments.d.ts +1 -1
  21. package/dist/domain/github-repository-bindings.d.ts +117 -0
  22. package/dist/domain/governed-learning-activation.d.ts +16 -0
  23. package/dist/domain/governed-learning-evaluator.d.ts +6 -0
  24. package/dist/domain/governed-learning-slack-publication.d.ts +45 -0
  25. package/dist/domain/memory-slack-delivery.d.ts +1 -4
  26. package/dist/domain/organization-membership-lifecycle.d.ts +1 -0
  27. package/dist/domain/packs.d.ts +5 -1
  28. package/dist/domain/personal-connection-delegations.d.ts +34 -2
  29. package/dist/domain/pr-review.d.ts +149 -0
  30. package/dist/domain/remember.d.ts +69 -0
  31. package/dist/domain/resources.d.ts +22 -1
  32. package/dist/domain/scheduled-tasks.d.ts +43 -2
  33. package/dist/domain/session-tool-policy.d.ts +1 -1
  34. package/dist/domain/sessions.d.ts +40 -6
  35. package/dist/editable-artifact-live/application.d.ts +10 -2
  36. package/dist/editable-artifact-live/ports.d.ts +0 -1
  37. package/dist/editable-artifact-live/server.d.ts +0 -1
  38. package/dist/editable-artifact-live/ticket.d.ts +0 -1
  39. package/dist/editable-artifact-live/types.d.ts +5 -2
  40. package/dist/editable-artifact-live.js +2 -2
  41. package/dist/editable-artifacts.js +2 -4
  42. package/dist/index.d.ts +13 -1
  43. package/dist/index.js +4827 -1164
  44. package/dist/index.js.map +1 -1
  45. package/dist/rigs/index.d.ts +22 -5
  46. package/dist/sandbox/fleet.d.ts +34 -6
  47. package/dist/sandbox/routing.d.ts +15 -1
  48. package/dist/sandbox/runtime-settings.d.ts +39 -0
  49. package/package.json +16 -11
  50. package/src/access/index.ts +151 -31
  51. package/src/application/new-session-drafts.ts +24 -2
  52. package/src/application/session-commands.ts +305 -71
  53. package/src/application/session-tenancy.ts +321 -0
  54. package/src/application/user-resource-grants.ts +140 -0
  55. package/src/billing/limits.ts +25 -15
  56. package/src/dependencies.ts +12 -1
  57. package/src/domain/automations.ts +196 -0
  58. package/src/domain/capabilities.ts +7 -1
  59. package/src/domain/company-brain-governed-writes.ts +330 -0
  60. package/src/domain/company-profile-agent-admin.ts +55 -0
  61. package/src/domain/connection-authority.ts +329 -0
  62. package/src/domain/editable-artifacts/agent-application.ts +17 -9
  63. package/src/domain/editable-artifacts/service.ts +12 -1
  64. package/src/domain/editable-artifacts/snapshot-compaction.ts +9 -5
  65. package/src/domain/editable-artifacts/snapshot-verifier-genesis.ts +10 -8
  66. package/src/domain/editable-artifacts/snapshot-verifier.ts +10 -3
  67. package/src/domain/environments.ts +16 -3
  68. package/src/domain/github-repository-bindings.ts +295 -0
  69. package/src/domain/governed-learning-activation.ts +44 -0
  70. package/src/domain/governed-learning-evaluator.ts +49 -0
  71. package/src/domain/governed-learning-slack-publication.ts +157 -0
  72. package/src/domain/insights.ts +9 -0
  73. package/src/domain/memory-slack-delivery.ts +0 -30
  74. package/src/domain/organization-membership-lifecycle.ts +9 -0
  75. package/src/domain/packs.ts +106 -3
  76. package/src/domain/personal-connection-delegations.ts +532 -51
  77. package/src/domain/pr-review.ts +671 -0
  78. package/src/domain/remember.ts +549 -0
  79. package/src/domain/resources.ts +131 -4
  80. package/src/domain/scheduled-tasks.ts +497 -76
  81. package/src/domain/session-tool-policy.ts +12 -9
  82. package/src/domain/sessions.ts +613 -166
  83. package/src/editable-artifact-live/application.ts +21 -3
  84. package/src/editable-artifact-live/ports.ts +0 -1
  85. package/src/editable-artifact-live/server.ts +13 -7
  86. package/src/editable-artifact-live/ticket.ts +1 -5
  87. package/src/editable-artifact-live/types.ts +6 -2
  88. package/src/editable-artifact-live/wire.ts +0 -10
  89. package/src/index.ts +13 -1
  90. package/src/rigs/index.ts +165 -48
  91. package/src/sandbox/fleet.ts +376 -30
  92. package/src/sandbox/routing.ts +91 -29
  93. package/src/sandbox/runtime-settings.ts +274 -0
  94. package/src/session-authorization.ts +17 -49
  95. package/dist/chunk-6WKPWE5S.js.map +0 -1
  96. package/dist/chunk-JJU6I5XD.js.map +0 -1
  97. package/dist/chunk-NYPMQ7NO.js.map +0 -1
  98. package/dist/domain/durable-learning-slack-publication.d.ts +0 -72
  99. package/src/domain/durable-learning-slack-publication.ts +0 -202
@@ -3,6 +3,18 @@ import { type AccountGrant, type AccessContext, type AccessGrant, type Permissio
3
3
  import { type Database } from "@opengeni/db";
4
4
  import type { Context } from "hono";
5
5
  import type { ManagedAuth } from "../managed-auth-type.js";
6
+ /**
7
+ * Opaque, request-local proof that the canonical access resolver authorized the
8
+ * exact account administrator named by the stamp. The random id is audit and
9
+ * replay provenance only; object identity is what prevents a caller from
10
+ * manufacturing this proof inside the API process.
11
+ */
12
+ export type AccountAdminAuthorizationStamp = Readonly<{
13
+ authorizationId: string;
14
+ accountId: string;
15
+ actorSubjectId: string;
16
+ permission: "account:admin";
17
+ }>;
6
18
  export type AccessDeps = {
7
19
  db: Database;
8
20
  settings: Settings;
@@ -10,13 +22,38 @@ export type AccessDeps = {
10
22
  };
11
23
  export declare function requireAccessContext(c: Context, deps: AccessDeps): Promise<AccessContext>;
12
24
  export declare function requireAccessGrant(c: Context, deps: AccessDeps, workspaceId: string, permission?: Permission): Promise<AccessGrant>;
25
+ /**
26
+ * Re-resolve the authenticated principal and its current grants without using
27
+ * the request-local access cache. Long-lived responses use this to ensure a
28
+ * membership suspension or revocation takes effect while the connection is
29
+ * still open.
30
+ */
31
+ export declare function requireFreshAccessGrant(c: Context, deps: AccessDeps, workspaceId: string, permission?: Permission): Promise<AccessGrant>;
13
32
  export type AccessGrantAuthorization = {
14
33
  grant: AccessGrant;
15
34
  accountGrant: AccountGrant | null;
16
35
  authenticatedSubjectId: string;
17
36
  contextIntegrity: boolean;
37
+ /**
38
+ * Did this request authenticate as the canonical managed-cookie (Better Auth)
39
+ * session that OWNS this grant's subject? The single input to the owner-only
40
+ * managed personal-workspace exception; see `isCanonicalManagedHumanSession`.
41
+ * False for every bearer, API-key, delegated, service, local, and configured
42
+ * principal, and for any future path that does not verify a cookie.
43
+ */
44
+ canonicalManagedHumanSession: boolean;
18
45
  };
19
46
  export declare function accessGrantAuthorizationFromContext(context: AccessContext, grant: AccessGrant): AccessGrantAuthorization;
47
+ /**
48
+ * Mint the capability passed to an account-admin database lifecycle.
49
+ *
50
+ * This deliberately accepts every canonical access mode (managed,
51
+ * local/configured, and signed delegation). Organization-membership rows are
52
+ * one possible source of account authority, not the definition of it. A plain
53
+ * object with matching fields is rejected because only values returned by the
54
+ * access resolver are present in `resolvedAccessGrantAuthorizations`.
55
+ */
56
+ export declare function requireAccountAdminAuthorizationStamp(authorization: AccessGrantAuthorization): AccountAdminAuthorizationStamp;
20
57
  export declare function requireAccessGrantAuthorization(c: Context, deps: AccessDeps, workspaceId: string, permission?: Permission): Promise<AccessGrantAuthorization>;
21
58
  export declare function requirePermission(grant: AccessGrant, permission: Permission): void;
22
59
  /**
@@ -10,5 +10,12 @@ export declare function getActorNewSessionDraft(deps: Pick<NewSessionDraftDepend
10
10
  * draft may represent incomplete options, while no invalid option can become a
11
11
  * session without passing that single canonical create boundary.
12
12
  */
13
- export declare function saveActorNewSessionDraft(deps: NewSessionDraftDependencies, grant: AccessGrant, workspaceId: string, rawInput: unknown): Promise<NewSessionDraftValue>;
13
+ export declare function saveActorNewSessionDraft(deps: NewSessionDraftDependencies, grant: AccessGrant, workspaceId: string, rawInput: unknown,
14
+ /**
15
+ * `AccessGrantAuthorization.canonicalManagedHumanSession` — did this request
16
+ * authenticate as the canonical managed cookie that owns `grant.subjectId`?
17
+ * Defaults to false so every caller that has not proven it fails closed onto
18
+ * the historical bare-membership fence.
19
+ */
20
+ canonicalManagedHumanSession?: boolean): Promise<NewSessionDraftValue>;
14
21
  export {};
@@ -31,12 +31,16 @@ type SessionAuthorizationCommandDeps = {
31
31
  db: Database;
32
32
  sessionAuthorization?: SessionAuthorizationPort | null;
33
33
  };
34
+ type SessionCommandPostCommitDeps = {
35
+ /** Historical name; now schedules replayable follow-up for every interactive session command. */
36
+ schedulePromptPostCommit?: ((task: () => Promise<void>) => void) | undefined;
37
+ };
34
38
  export declare function sendAgentSessionMessage(deps: {
35
39
  db: Database;
36
40
  bus: EventBus;
37
41
  workflowClient: Pick<SessionWorkflowClient, "wakeSessionWorkflow">;
38
42
  sessionAuthorization?: SessionAuthorizationPort | null;
39
- }, context: AgentSessionCommandContext, input: {
43
+ } & SessionCommandPostCommitDeps, context: AgentSessionCommandContext, input: {
40
44
  targetSessionId: string;
41
45
  text: string;
42
46
  idempotencyKey: string;
@@ -46,7 +50,7 @@ export declare function steerAgentSession(deps: {
46
50
  bus: EventBus;
47
51
  workflowClient: Pick<SessionWorkflowClient, "wakeSessionWorkflow">;
48
52
  sessionAuthorization?: SessionAuthorizationPort | null;
49
- }, context: AgentSessionCommandContext, input: {
53
+ } & SessionCommandPostCommitDeps, context: AgentSessionCommandContext, input: {
50
54
  targetSessionId: string;
51
55
  instruction: string;
52
56
  idempotencyKey: string;
@@ -54,9 +58,9 @@ export declare function steerAgentSession(deps: {
54
58
  export declare function controlAgentSessionWorkstream(deps: {
55
59
  db: Database;
56
60
  bus: EventBus;
57
- workflowClient: Pick<SessionWorkflowClient, "requestSessionWorkflowWakeDispatch">;
61
+ workflowClient: Pick<SessionWorkflowClient, "requestSessionWorkflowWakeDispatch" | "wakeSessionWorkflow">;
58
62
  sessionAuthorization?: SessionAuthorizationPort | null;
59
- }, context: AgentSessionCommandContext, input: {
63
+ } & SessionCommandPostCommitDeps, context: AgentSessionCommandContext, input: {
60
64
  targetSessionId: string;
61
65
  action: "pause" | "resume";
62
66
  idempotencyKey: string;
@@ -67,6 +71,7 @@ export declare function controlAgentSessionWorkstream(deps: {
67
71
  sessionControlEventId: string;
68
72
  workspaceControlEventId: string;
69
73
  interruptionCount: number;
74
+ backgroundCommandCount: number;
70
75
  wakeCount: number;
71
76
  cancelledSessionCount: number;
72
77
  cancelledTurnCount: number;
@@ -74,6 +79,7 @@ export declare function controlAgentSessionWorkstream(deps: {
74
79
  sessionId: string;
75
80
  eventIds: string[];
76
81
  }>;
82
+ workflowWake: import("@opengeni/db").SessionControlWorkflowWake | null;
77
83
  replay: boolean;
78
84
  authorization: ResolvedSessionAuthorization | null;
79
85
  }>;
@@ -81,28 +87,29 @@ export declare function moveHumanQueuePrompt(deps: {
81
87
  db: Database;
82
88
  bus: EventBus;
83
89
  sessionAuthorization?: SessionAuthorizationPort | null;
84
- }, context: HumanSessionCommandContext, turnId: string, input: MoveSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
90
+ } & SessionCommandPostCommitDeps, context: HumanSessionCommandContext, turnId: string, input: MoveSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
85
91
  export declare function deleteHumanQueuePrompt(deps: {
86
92
  db: Database;
87
93
  bus: EventBus;
88
94
  sessionAuthorization?: SessionAuthorizationPort | null;
89
- }, context: HumanSessionCommandContext, turnId: string, input: DeleteSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
95
+ } & SessionCommandPostCommitDeps, context: HumanSessionCommandContext, turnId: string, input: DeleteSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
90
96
  export declare function editHumanQueuePrompt(deps: {
91
97
  db: Database;
92
98
  bus: EventBus;
93
99
  sessionAuthorization?: SessionAuthorizationPort | null;
94
- }, context: HumanSessionCommandContext, turnId: string, input: EditSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
100
+ } & SessionCommandPostCommitDeps, context: HumanSessionCommandContext, turnId: string, input: EditSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
95
101
  export declare function steerHumanQueuePrompt(deps: {
96
102
  db: Database;
97
103
  bus: EventBus;
104
+ workflowClient: Pick<SessionWorkflowClient, "wakeSessionWorkflow">;
98
105
  sessionAuthorization?: SessionAuthorizationPort | null;
99
- }, context: HumanSessionCommandContext, turnId: string, input: SteerSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
106
+ } & SessionCommandPostCommitDeps, context: HumanSessionCommandContext, turnId: string, input: SteerSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
100
107
  export declare function controlHumanSessionWorkstreamWithOutcome(deps: {
101
108
  db: Database;
102
109
  bus: EventBus;
103
- workflowClient: Pick<SessionWorkflowClient, "requestSessionWorkflowWakeDispatch">;
110
+ workflowClient: Pick<SessionWorkflowClient, "requestSessionWorkflowWakeDispatch" | "wakeSessionWorkflow">;
104
111
  sessionAuthorization?: SessionAuthorizationPort | null;
105
- }, context: HumanSessionCommandContext, input: SessionControlRequest): Promise<{
112
+ } & SessionCommandPostCommitDeps, context: HumanSessionCommandContext, input: SessionControlRequest): Promise<{
106
113
  response: SessionControlResponse;
107
114
  replay: boolean;
108
115
  }>;
@@ -112,7 +119,7 @@ export declare function controlHumanWorkspace(deps: {
112
119
  db: Database;
113
120
  bus: EventBus;
114
121
  workflowClient: Pick<SessionWorkflowClient, "requestSessionWorkflowWakeDispatch">;
115
- }, context: Omit<HumanSessionCommandContext, "sessionId">, input: WorkspaceInferenceControlRequest): Promise<WorkspaceInferenceControlResponse>;
122
+ } & SessionCommandPostCommitDeps, context: Omit<HumanSessionCommandContext, "sessionId">, input: WorkspaceInferenceControlRequest): Promise<WorkspaceInferenceControlResponse>;
116
123
  export declare function getHumanComposerDraft(deps: SessionAuthorizationCommandDeps, context: HumanSessionCommandContext): Promise<ComposerDraft>;
117
124
  export declare function saveHumanComposerDraft(deps: SessionAuthorizationCommandDeps, context: HumanSessionCommandContext, input: SaveComposerDraftRequest): Promise<ComposerDraft>;
118
125
  export {};
@@ -0,0 +1,18 @@
1
+ import { ForkSessionResponse, SessionTenancyCreateCapabilities, UpdateSessionVisibilityResponse, type ForkSessionRequest, type SessionAuthorizationSurface, type UpdateSessionVisibilityRequest } from "@opengeni/contracts";
2
+ import { type AccessGrantAuthorization } from "../access/index.js";
3
+ import type { AppDependencies } from "../dependencies.js";
4
+ type SessionTenancyDependencies = Pick<AppDependencies, "db" | "bus" | "sessionAuthorization">;
5
+ export declare class SessionTenancyManagedHumanRequiredError extends Error {
6
+ readonly name = "SessionTenancyManagedHumanRequiredError";
7
+ constructor();
8
+ }
9
+ export declare class SessionTenancyPersistenceOutcomeUnknownError extends Error {
10
+ readonly name = "SessionTenancyPersistenceOutcomeUnknownError";
11
+ constructor(options?: ErrorOptions);
12
+ }
13
+ export declare function requireCanonicalManagedHuman(authorization: AccessGrantAuthorization, workspaceId: string): void;
14
+ export declare function getManagedHumanSessionCreateCapabilities(deps: Pick<SessionTenancyDependencies, "db">, authorization: AccessGrantAuthorization, workspaceId: string): Promise<SessionTenancyCreateCapabilities>;
15
+ export declare function requireManagedHumanPrivateSessionCreate(deps: Pick<SessionTenancyDependencies, "db">, authorization: AccessGrantAuthorization, workspaceId: string): Promise<void>;
16
+ export declare function updateManagedHumanSessionVisibility(deps: SessionTenancyDependencies, authorization: AccessGrantAuthorization, workspaceId: string, sessionId: string, request: UpdateSessionVisibilityRequest, authorizationSurface?: SessionAuthorizationSurface): Promise<UpdateSessionVisibilityResponse>;
17
+ export declare function forkManagedHumanSession(deps: SessionTenancyDependencies, authorization: AccessGrantAuthorization, workspaceId: string, sourceSessionId: string, request: ForkSessionRequest, authorizationSurface?: SessionAuthorizationSurface): Promise<ForkSessionResponse>;
18
+ export {};
@@ -0,0 +1,20 @@
1
+ import type { IssueUserResourceGrantRequest, SessionAuthorizationSurface, UserResourceKind } from "@opengeni/contracts";
2
+ import { type AccessGrantAuthorization } from "../access/index.js";
3
+ import type { AppDependencies } from "../dependencies.js";
4
+ type UserResourceGrantDependencies = Pick<AppDependencies, "db" | "sessionAuthorization">;
5
+ export declare function listManagedHumanUserResourceAuthorities(deps: Pick<UserResourceGrantDependencies, "db">, authorization: AccessGrantAuthorization, workspaceId: string, input: {
6
+ resourceKind: UserResourceKind;
7
+ cursor?: string | undefined;
8
+ limit: number;
9
+ }): Promise<{
10
+ authorities: import("@opengeni/db").UserResourceAuthoritySummary[];
11
+ nextCursor: string | null;
12
+ }>;
13
+ export declare function issueManagedHumanUserResourceGrant(deps: UserResourceGrantDependencies, authorization: AccessGrantAuthorization, workspaceId: string, authorityId: string, request: IssueUserResourceGrantRequest, authorizationSurface?: SessionAuthorizationSurface): Promise<import("@opengeni/db").UserResourceAuthorityGrant>;
14
+ export declare function revokeManagedHumanUserResourceGrant(deps: Pick<UserResourceGrantDependencies, "db">, authorization: AccessGrantAuthorization, workspaceId: string, grantId: string): Promise<{
15
+ grantId: string;
16
+ generation: number;
17
+ status: "revoked";
18
+ revokedAt: string;
19
+ }>;
20
+ export {};
@@ -25,7 +25,7 @@ import {
25
25
  editableArtifactSnapshotId,
26
26
  editableArtifactStateHash,
27
27
  validateEditableArtifactActor
28
- } from "./chunk-JJU6I5XD.js";
28
+ } from "./chunk-VCZFFEPB.js";
29
29
 
30
30
  // src/domain/editable-artifacts/durable-export.ts
31
31
  import { createHash } from "crypto";
@@ -423,15 +423,13 @@ function validateEditableArtifactMaterializationJob(job) {
423
423
 
424
424
  // src/domain/editable-artifacts/agent-application.ts
425
425
  import { createHash as createHash2 } from "crypto";
426
- import {
427
- COMMITTED_TRANSACTION_PROTOCOL_VERSION,
428
- EDITABLE_ARTIFACT_MODEL_SCHEMA_VERSION
429
- } from "@opengeni/contracts/editable-artifact-versions";
430
426
  import {
431
427
  DOCUMENT_ARTIFACT_COMMAND_VERSION,
428
+ EDITABLE_ARTIFACT_INTENT_PROTOCOL_VERSION,
432
429
  EDITABLE_ARTIFACT_INTENT_VERSION,
433
430
  PRESENTATION_ARTIFACT_COMMAND_VERSION,
434
431
  SPREADSHEET_ARTIFACT_COMMAND_VERSION,
432
+ currentEditableArtifactCompatibility,
435
433
  decodeEditableArtifactMutationIntent,
436
434
  decodeDocumentArtifactQueryResponse,
437
435
  decodePresentationArtifactQueryResponse,
@@ -586,8 +584,8 @@ var EditableArtifactAgentApplication = class {
586
584
  }
587
585
  const authored = hashEditableArtifactMutationIntent({
588
586
  envelopeVersion: EDITABLE_ARTIFACT_INTENT_VERSION,
589
- protocolVersion: COMMITTED_TRANSACTION_PROTOCOL_VERSION,
590
- modelSchemaVersion: EDITABLE_ARTIFACT_MODEL_SCHEMA_VERSION,
587
+ protocolVersion: EDITABLE_ARTIFACT_INTENT_PROTOCOL_VERSION,
588
+ modelSchemaVersion: currentEditableArtifactCompatibility(input.batch.modality).modelSchemaVersion,
591
589
  commandProtocolVersion: commandProtocolVersion(input.batch.modality),
592
590
  artifactId,
593
591
  clientTransactionId,
@@ -738,12 +736,21 @@ function agentContext(input) {
738
736
  }
739
737
  function encodeCommands(batch) {
740
738
  if (batch.modality === "spreadsheet") {
741
- return encodeSpreadsheetArtifactCommandBatch({ version: 1, commands: batch.commands });
739
+ return encodeSpreadsheetArtifactCommandBatch({
740
+ version: SPREADSHEET_ARTIFACT_COMMAND_VERSION,
741
+ commands: batch.commands
742
+ });
742
743
  }
743
744
  if (batch.modality === "document") {
744
- return encodeDocumentArtifactCommandBatch({ version: 1, commands: batch.commands });
745
+ return encodeDocumentArtifactCommandBatch({
746
+ version: DOCUMENT_ARTIFACT_COMMAND_VERSION,
747
+ commands: batch.commands
748
+ });
745
749
  }
746
- return encodePresentationArtifactCommandBatch({ version: 1, commands: batch.commands });
750
+ return encodePresentationArtifactCommandBatch({
751
+ version: PRESENTATION_ARTIFACT_COMMAND_VERSION,
752
+ commands: batch.commands
753
+ });
747
754
  }
748
755
  function encodeQuery(request) {
749
756
  if (request.modality === "spreadsheet") {
@@ -2072,6 +2079,8 @@ function editableArtifactLiveTicketStorePortFromPostgres(store) {
2072
2079
 
2073
2080
  // src/domain/editable-artifacts/snapshot-compaction.ts
2074
2081
  import { BoundedObjectWriteError } from "@opengeni/storage";
2082
+ import { EDITABLE_ARTIFACT_CODEC_REGISTRY } from "@opengeni/contracts/editable-artifacts";
2083
+ import { COMMITTED_TRANSACTION_PROTOCOL_VERSION } from "@opengeni/contracts/editable-artifact-committed-transaction";
2075
2084
  var SNAPSHOT_MIME_TYPE = "application/vnd.opengeni.editable-artifact-snapshot";
2076
2085
  var EditableArtifactCompactionPipeline = class {
2077
2086
  #dependencies;
@@ -2148,6 +2157,7 @@ function validateBasis(state, scope, artifactId) {
2148
2157
  }
2149
2158
  }
2150
2159
  function validateGenerated(value, state, scope, artifactId) {
2160
+ const currentCodec = EDITABLE_ARTIFACT_CODEC_REGISTRY[value.modality];
2151
2161
  if (value.scope.accountId !== scope.accountId || value.scope.workspaceId !== scope.workspaceId || value.artifactId !== artifactId || value.modality !== state.modality) {
2152
2162
  throw new EditableArtifactSnapshotVerificationError("identity_mismatch");
2153
2163
  }
@@ -2161,8 +2171,7 @@ function validateGenerated(value, state, scope, artifactId) {
2161
2171
  throw new EditableArtifactSnapshotVerificationError("limit_exceeded");
2162
2172
  }
2163
2173
  editableArtifactContentHash(value.canonicalContentHash);
2164
- const versions = value.modality === "spreadsheet" ? [value.modelSchemaVersion, value.operationProtocolVersion, value.crdtStateVersion] : [value.modelSchemaVersion];
2165
- if (versions.some((version) => !Number.isSafeInteger(version) || version <= 0)) {
2174
+ if (value.modelSchemaVersion !== currentCodec.modelSchemaVersion || value.modality === "spreadsheet" && (value.operationProtocolVersion !== COMMITTED_TRANSACTION_PROTOCOL_VERSION || value.crdtStateVersion !== currentCodec.snapshotVersion)) {
2166
2175
  throw new EditableArtifactSnapshotVerificationError("version_mismatch");
2167
2176
  }
2168
2177
  try {
@@ -2189,6 +2198,8 @@ function throwIfCancelled(signal) {
2189
2198
 
2190
2199
  // src/domain/editable-artifacts/snapshot-verifier-genesis.ts
2191
2200
  import { BoundedObjectWriteError as BoundedObjectWriteError2 } from "@opengeni/storage";
2201
+ import { EDITABLE_ARTIFACT_CODEC_REGISTRY as EDITABLE_ARTIFACT_CODEC_REGISTRY2 } from "@opengeni/contracts/editable-artifacts";
2202
+ import { COMMITTED_TRANSACTION_PROTOCOL_VERSION as COMMITTED_TRANSACTION_PROTOCOL_VERSION2 } from "@opengeni/contracts/editable-artifact-committed-transaction";
2192
2203
  var SNAPSHOT_MIME_TYPE2 = "application/vnd.opengeni.editable-artifact-snapshot";
2193
2204
  var EditableArtifactGenesisPipeline = class {
2194
2205
  #dependencies;
@@ -2265,6 +2276,7 @@ var EditableArtifactGenesisPipeline = class {
2265
2276
  }
2266
2277
  };
2267
2278
  function validateGeneratedGenesis(value, scope, artifactId, modality) {
2279
+ const currentCodec = EDITABLE_ARTIFACT_CODEC_REGISTRY2[value.modality];
2268
2280
  if (value.scope.accountId !== scope.accountId || value.scope.workspaceId !== scope.workspaceId || value.artifactId !== artifactId || value.modality !== modality) {
2269
2281
  throw new EditableArtifactSnapshotVerificationError("identity_mismatch");
2270
2282
  }
@@ -2276,11 +2288,8 @@ function validateGeneratedGenesis(value, scope, artifactId, modality) {
2276
2288
  }
2277
2289
  editableArtifactContentHash(value.canonicalContentHash);
2278
2290
  editableArtifactStateHash(value.stateHash);
2279
- const versions = value.modality === "spreadsheet" ? [value.modelSchemaVersion, value.operationProtocolVersion, value.crdtStateVersion] : [value.modelSchemaVersion];
2280
- for (const version of versions) {
2281
- if (!Number.isSafeInteger(version) || version <= 0) {
2282
- throw new EditableArtifactSnapshotVerificationError("version_mismatch");
2283
- }
2291
+ if (value.modelSchemaVersion !== currentCodec.modelSchemaVersion || value.modality === "spreadsheet" && (value.operationProtocolVersion !== COMMITTED_TRANSACTION_PROTOCOL_VERSION2 || value.crdtStateVersion !== currentCodec.snapshotVersion)) {
2292
+ throw new EditableArtifactSnapshotVerificationError("version_mismatch");
2284
2293
  }
2285
2294
  try {
2286
2295
  assertBoundedKernelVersion(value.kernelVersion);
@@ -2377,4 +2386,4 @@ export {
2377
2386
  EditableArtifactGenesisPipeline,
2378
2387
  editableArtifactMaterializationKey
2379
2388
  };
2380
- //# sourceMappingURL=chunk-6WKPWE5S.js.map
2389
+ //# sourceMappingURL=chunk-H7X52RI2.js.map