@opengeni/core 0.21.10 → 0.28.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 (132) hide show
  1. package/dist/access/index.d.ts +1 -1
  2. package/dist/application/new-session-drafts.d.ts +1 -1
  3. package/dist/application/session-commands.d.ts +2 -2
  4. package/dist/billing/limits.d.ts +1 -1
  5. package/dist/canonical-human-identities.d.ts +12 -0
  6. package/dist/canonical-human-identities.js +23 -0
  7. package/dist/canonical-human-identities.js.map +1 -0
  8. package/dist/chunk-6WKPWE5S.js +2380 -0
  9. package/dist/chunk-6WKPWE5S.js.map +1 -0
  10. package/dist/chunk-IBOEYG6N.js +34 -0
  11. package/dist/chunk-IBOEYG6N.js.map +1 -0
  12. package/dist/chunk-JJU6I5XD.js +2713 -0
  13. package/dist/chunk-JJU6I5XD.js.map +1 -0
  14. package/dist/chunk-NYPMQ7NO.js +2270 -0
  15. package/dist/chunk-NYPMQ7NO.js.map +1 -0
  16. package/dist/dependencies.d.ts +30 -6
  17. package/dist/domain/capabilities.d.ts +28 -3
  18. package/dist/domain/company-profile-durable-learning-adapter.d.ts +39 -0
  19. package/dist/domain/conversation-integrations.d.ts +225 -0
  20. package/dist/domain/durable-learning-slack-publication.d.ts +72 -0
  21. package/dist/domain/editable-artifacts/agent-application.d.ts +192 -0
  22. package/dist/domain/editable-artifacts/durable-export-postgres.d.ts +4 -0
  23. package/dist/domain/editable-artifacts/durable-export.d.ts +212 -0
  24. package/dist/domain/editable-artifacts/errors.d.ts +47 -0
  25. package/dist/domain/editable-artifacts/hash.d.ts +11 -0
  26. package/dist/domain/editable-artifacts/in-memory.d.ts +99 -0
  27. package/dist/domain/editable-artifacts/index.d.ts +14 -0
  28. package/dist/domain/editable-artifacts/ports.d.ts +341 -0
  29. package/dist/domain/editable-artifacts/postgres-adapters.d.ts +13 -0
  30. package/dist/domain/editable-artifacts/service.d.ts +105 -0
  31. package/dist/domain/editable-artifacts/snapshot-compaction.d.ts +44 -0
  32. package/dist/domain/editable-artifacts/snapshot-verifier-genesis.d.ts +50 -0
  33. package/dist/domain/editable-artifacts/snapshot-verifier-materialization.d.ts +21 -0
  34. package/dist/domain/editable-artifacts/snapshot-verifier.d.ts +118 -0
  35. package/dist/domain/editable-artifacts/types.d.ts +410 -0
  36. package/dist/domain/fiken.d.ts +35 -0
  37. package/dist/domain/memory-slack-delivery.d.ts +19 -0
  38. package/dist/domain/packs.d.ts +29 -1
  39. package/dist/domain/personal-connection-delegations.d.ts +9 -1
  40. package/dist/domain/scheduled-tasks.d.ts +2 -2
  41. package/dist/domain/session-tool-policy.d.ts +2 -2
  42. package/dist/domain/sessions.d.ts +24 -8
  43. package/dist/domain/skill-imports.d.ts +32 -0
  44. package/dist/domain/slack-publication-secret-safety.d.ts +8 -0
  45. package/dist/domain/timeline-annotations.d.ts +5 -0
  46. package/dist/domain/video-generation-capabilities.d.ts +10 -0
  47. package/dist/domain/video-generation.d.ts +47 -0
  48. package/dist/editable-artifact-live/application.d.ts +69 -0
  49. package/dist/editable-artifact-live/errors.d.ts +1 -0
  50. package/dist/editable-artifact-live/index.d.ts +8 -0
  51. package/dist/editable-artifact-live/outbox-dispatcher.d.ts +162 -0
  52. package/dist/editable-artifact-live/ports.d.ts +100 -0
  53. package/dist/editable-artifact-live/server.d.ts +71 -0
  54. package/dist/editable-artifact-live/ticket.d.ts +40 -0
  55. package/dist/editable-artifact-live/types.d.ts +213 -0
  56. package/dist/editable-artifact-live/wire.d.ts +34 -0
  57. package/dist/editable-artifact-live.d.ts +2 -0
  58. package/dist/editable-artifact-live.js +58 -0
  59. package/dist/editable-artifact-live.js.map +1 -0
  60. package/dist/editable-artifacts.d.ts +2 -0
  61. package/dist/editable-artifacts.js +179 -0
  62. package/dist/editable-artifacts.js.map +1 -0
  63. package/dist/index.d.ts +37 -26
  64. package/dist/index.js +4145 -959
  65. package/dist/index.js.map +1 -1
  66. package/dist/managed-session.d.ts +6 -2
  67. package/dist/rigs/index.d.ts +1 -1
  68. package/dist/rigs/provider-images.d.ts +31 -0
  69. package/dist/sandbox/fleet.d.ts +8 -5
  70. package/dist/sandbox/routing.d.ts +1 -0
  71. package/dist/session-authorization.d.ts +4 -2
  72. package/dist/transcription.d.ts +5 -0
  73. package/dist/workflow-wake-contract.d.ts +7 -0
  74. package/package.json +22 -10
  75. package/src/access/index.ts +14 -2
  76. package/src/application/new-session-drafts.ts +2 -0
  77. package/src/application/session-commands.ts +188 -107
  78. package/src/canonical-human-identities.ts +27 -0
  79. package/src/dependencies.ts +34 -2
  80. package/src/domain/capabilities.ts +729 -408
  81. package/src/domain/company-profile-durable-learning-adapter.ts +221 -0
  82. package/src/domain/conversation-integrations.ts +1238 -0
  83. package/src/domain/durable-learning-slack-publication.ts +202 -0
  84. package/src/domain/editable-artifacts/agent-application.ts +687 -0
  85. package/src/domain/editable-artifacts/durable-export-postgres.ts +139 -0
  86. package/src/domain/editable-artifacts/durable-export.ts +734 -0
  87. package/src/domain/editable-artifacts/errors.ts +115 -0
  88. package/src/domain/editable-artifacts/hash.ts +131 -0
  89. package/src/domain/editable-artifacts/in-memory.ts +1662 -0
  90. package/src/domain/editable-artifacts/index.ts +14 -0
  91. package/src/domain/editable-artifacts/ports.ts +462 -0
  92. package/src/domain/editable-artifacts/postgres-adapters.ts +49 -0
  93. package/src/domain/editable-artifacts/service.ts +2402 -0
  94. package/src/domain/editable-artifacts/snapshot-compaction.ts +246 -0
  95. package/src/domain/editable-artifacts/snapshot-verifier-genesis.ts +235 -0
  96. package/src/domain/editable-artifacts/snapshot-verifier-materialization.ts +74 -0
  97. package/src/domain/editable-artifacts/snapshot-verifier.ts +687 -0
  98. package/src/domain/editable-artifacts/types.ts +835 -0
  99. package/src/domain/fiken.ts +88 -0
  100. package/src/domain/insights.ts +163 -50
  101. package/src/domain/memory-slack-delivery.ts +204 -0
  102. package/src/domain/memory-slack-publication.ts +5 -2
  103. package/src/domain/packs.ts +266 -5
  104. package/src/domain/personal-connection-delegations.ts +97 -6
  105. package/src/domain/scheduled-tasks.ts +171 -29
  106. package/src/domain/session-tool-policy.ts +8 -2
  107. package/src/domain/sessions.ts +395 -148
  108. package/src/domain/skill-imports.ts +350 -0
  109. package/src/domain/slack-publication-secret-safety.ts +42 -0
  110. package/src/domain/timeline-annotations.ts +204 -0
  111. package/src/domain/video-generation-capabilities.ts +104 -0
  112. package/src/domain/video-generation.ts +249 -0
  113. package/src/editable-artifact-live/application.ts +182 -0
  114. package/src/editable-artifact-live/errors.ts +4 -0
  115. package/src/editable-artifact-live/index.ts +8 -0
  116. package/src/editable-artifact-live/outbox-dispatcher.ts +916 -0
  117. package/src/editable-artifact-live/ports.ts +139 -0
  118. package/src/editable-artifact-live/server.ts +1707 -0
  119. package/src/editable-artifact-live/ticket.ts +217 -0
  120. package/src/editable-artifact-live/types.ts +286 -0
  121. package/src/editable-artifact-live/wire.ts +95 -0
  122. package/src/editable-artifact-live.ts +2 -0
  123. package/src/editable-artifacts.ts +2 -0
  124. package/src/index.ts +15 -0
  125. package/src/managed-session.ts +19 -2
  126. package/src/rigs/index.ts +26 -19
  127. package/src/rigs/provider-images.ts +110 -0
  128. package/src/sandbox/fleet.ts +72 -66
  129. package/src/sandbox/routing.ts +6 -3
  130. package/src/session-authorization.ts +187 -52
  131. package/src/transcription.ts +5 -0
  132. package/src/workflow-wake-contract.ts +8 -0
@@ -0,0 +1,221 @@
1
+ import {
2
+ CompanyProfileLearningSubjectKind,
3
+ CompanyProfileLearningWrite,
4
+ type CompanyProfileMutationResponse,
5
+ } from "@opengeni/contracts";
6
+ import {
7
+ type CompanyProfileLearningWriteResult,
8
+ type Database,
9
+ rollbackCompanyProfileLearning,
10
+ writeCompanyProfileLearning,
11
+ } from "@opengeni/db";
12
+
13
+ export type CompanyProfileDurableLearningResource = {
14
+ surface: "company_profile";
15
+ id: string;
16
+ version: string | null;
17
+ status: string;
18
+ };
19
+
20
+ export type CompanyProfileDurableLearningWriteResult = {
21
+ outcome: "applied" | "proposed";
22
+ resource: CompanyProfileDurableLearningResource;
23
+ effectiveBoundary: "next_accepted_attempt";
24
+ rollback: {
25
+ supported: boolean;
26
+ targetAttemptId: null;
27
+ token: string | null;
28
+ };
29
+ };
30
+
31
+ export type CompanyProfileDurableLearningRollbackResult = {
32
+ resource: CompanyProfileDurableLearningResource;
33
+ effectiveBoundary: "next_accepted_attempt";
34
+ };
35
+
36
+ /**
37
+ * Structural match for canonical durable-learning router's DurableLearningAuthorityAdapter. The router
38
+ * package owns its complete request/decision types; accepting unknown here
39
+ * keeps this adapter assignable without copying or competing with that router.
40
+ */
41
+ export type CompanyProfileDurableLearningAuthorityAdapter = {
42
+ write: (input: unknown) => Promise<CompanyProfileDurableLearningWriteResult>;
43
+ rollback: (input: unknown) => Promise<CompanyProfileDurableLearningRollbackResult>;
44
+ };
45
+
46
+ export type CompanyProfileDurableLearningAdapterOptions = {
47
+ db: Database;
48
+ authority?: {
49
+ write: typeof writeCompanyProfileLearning;
50
+ rollback: typeof rollbackCompanyProfileLearning;
51
+ };
52
+ };
53
+
54
+ function record(value: unknown, name: string): Record<string, unknown> {
55
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
56
+ throw new Error(`${name} must be an object`);
57
+ }
58
+ return value as Record<string, unknown>;
59
+ }
60
+
61
+ function requiredString(value: unknown, name: string): string {
62
+ if (typeof value !== "string" || value.length === 0) {
63
+ throw new Error(`${name} must be a non-empty string`);
64
+ }
65
+ return value;
66
+ }
67
+
68
+ function nullableString(value: unknown, name: string): string | null {
69
+ if (value === null) return null;
70
+ return requiredString(value, name);
71
+ }
72
+
73
+ function actorKind(value: unknown): "human" | "agent" | "service" {
74
+ if (value === "human" || value === "agent" || value === "service") return value;
75
+ throw new Error("durable-learning attempt actor kind is invalid");
76
+ }
77
+
78
+ function parseAttempt(value: unknown) {
79
+ const attempt = record(value, "durable-learning attempt");
80
+ const actor = record(attempt.actor, "durable-learning actor");
81
+ return {
82
+ id: requiredString(attempt.id, "durable-learning attempt id"),
83
+ accountId: requiredString(attempt.accountId, "durable-learning account id"),
84
+ workspaceId: requiredString(attempt.workspaceId, "durable-learning workspace id"),
85
+ actor: {
86
+ kind: actorKind(actor.kind),
87
+ subjectId: requiredString(actor.subjectId, "durable-learning actor subject"),
88
+ },
89
+ };
90
+ }
91
+
92
+ function parseWriteInput(value: unknown) {
93
+ const input = record(value, "company-profile durable-learning write");
94
+ const attempt = parseAttempt(input.attempt);
95
+ const request = record(input.request, "durable-learning write request");
96
+ const decision = record(input.decision, "durable-learning route decision");
97
+ const scope = record(decision.scope, "durable-learning resolved scope");
98
+ const subject = record(request.subject, "durable-learning subject");
99
+ if (
100
+ request.operation !== "write" ||
101
+ request.attemptId !== attempt.id ||
102
+ request.targetSurface !== "company_profile" ||
103
+ decision.disposition !== "route" ||
104
+ decision.destination !== "company_profile" ||
105
+ scope.kind !== "organization" ||
106
+ (decision.authority !== "active" && decision.authority !== "proposal")
107
+ ) {
108
+ throw new Error(
109
+ "The company-profile adapter accepts only matching routed active or proposal organization company_profile writes",
110
+ );
111
+ }
112
+ return CompanyProfileLearningWrite.parse({
113
+ operationId: attempt.id,
114
+ accountId: attempt.accountId,
115
+ workspaceId: attempt.workspaceId,
116
+ actorSubjectId: attempt.actor.subjectId,
117
+ actorKind: attempt.actor.kind,
118
+ authority: decision.authority,
119
+ subject: {
120
+ kind: CompanyProfileLearningSubjectKind.parse(subject.kind),
121
+ content: requiredString(subject.content, "durable-learning subject content"),
122
+ stableKey: nullableString(subject.stableKey, "durable-learning subject stable key"),
123
+ },
124
+ sourceId: `durable-learning-attempt:${attempt.id}`,
125
+ });
126
+ }
127
+
128
+ function parseRollbackInput(value: unknown) {
129
+ const input = record(value, "company-profile durable-learning rollback");
130
+ const attempt = parseAttempt(input.attempt);
131
+ const targetAttempt = parseAttempt(input.targetAttempt);
132
+ const targetReceipt = record(input.targetReceipt, "durable-learning target receipt");
133
+ const targetResource = record(
134
+ targetReceipt.resource,
135
+ "durable-learning target company-profile resource",
136
+ );
137
+ const receiptRollback = record(
138
+ targetReceipt.rollback,
139
+ "durable-learning target rollback receipt",
140
+ );
141
+ const rollbackToken = requiredString(input.rollbackToken, "company-profile rollback token");
142
+ if (
143
+ targetReceipt.attemptId !== targetAttempt.id ||
144
+ targetResource.surface !== "company_profile" ||
145
+ receiptRollback.supported !== true ||
146
+ receiptRollback.token !== rollbackToken
147
+ ) {
148
+ throw new Error("The company-profile adapter cannot roll back another authority surface");
149
+ }
150
+ return {
151
+ attempt,
152
+ rollbackToken,
153
+ reason: requiredString(input.reason, "company-profile rollback reason"),
154
+ };
155
+ }
156
+
157
+ function writeResource(
158
+ result: CompanyProfileLearningWriteResult,
159
+ ): CompanyProfileDurableLearningResource {
160
+ return {
161
+ surface: "company_profile",
162
+ id: result.revision.id,
163
+ version: String(result.revision.revision),
164
+ status: result.outcome === "applied" ? "active" : "proposal",
165
+ };
166
+ }
167
+
168
+ function rollbackResource(
169
+ result: CompanyProfileMutationResponse,
170
+ ): CompanyProfileDurableLearningResource {
171
+ if (!result.event) throw new Error("Company-profile rollback returned no activation event");
172
+ return {
173
+ surface: "company_profile",
174
+ id: result.head?.revisionId ?? result.event.oldRevision?.id ?? result.event.id,
175
+ version: String(result.event.activationVersion),
176
+ status: result.head ? "active" : "inactive",
177
+ };
178
+ }
179
+
180
+ /** Install this under `authorities.company_profile` in the canonical durable-learning router ports. */
181
+ export function createCompanyProfileDurableLearningAdapter(
182
+ options: CompanyProfileDurableLearningAdapterOptions,
183
+ ): CompanyProfileDurableLearningAuthorityAdapter {
184
+ const authority = options.authority ?? {
185
+ write: writeCompanyProfileLearning,
186
+ rollback: rollbackCompanyProfileLearning,
187
+ };
188
+ return {
189
+ async write(rawInput) {
190
+ const input = parseWriteInput(rawInput);
191
+ const result = await authority.write(options.db, input);
192
+ return {
193
+ outcome: result.outcome,
194
+ resource: writeResource(result),
195
+ effectiveBoundary: result.effectiveBoundary,
196
+ rollback: {
197
+ supported: result.rollbackToken !== null,
198
+ targetAttemptId: null,
199
+ token: result.rollbackToken,
200
+ },
201
+ };
202
+ },
203
+
204
+ async rollback(rawInput) {
205
+ const input = parseRollbackInput(rawInput);
206
+ const result = await authority.rollback(options.db, {
207
+ operationId: input.attempt.id,
208
+ accountId: input.attempt.accountId,
209
+ workspaceId: input.attempt.workspaceId,
210
+ actorSubjectId: input.attempt.actor.subjectId,
211
+ actorKind: input.attempt.actor.kind,
212
+ token: input.rollbackToken,
213
+ reason: input.reason,
214
+ });
215
+ return {
216
+ resource: rollbackResource(result),
217
+ effectiveBoundary: "next_accepted_attempt",
218
+ };
219
+ },
220
+ };
221
+ }