@opengeni/core 0.21.10 → 0.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access/index.d.ts +1 -1
- package/dist/application/new-session-drafts.d.ts +1 -1
- package/dist/application/session-commands.d.ts +2 -2
- package/dist/billing/limits.d.ts +1 -1
- package/dist/chunk-6WKPWE5S.js +2380 -0
- package/dist/chunk-6WKPWE5S.js.map +1 -0
- package/dist/chunk-JJU6I5XD.js +2713 -0
- package/dist/chunk-JJU6I5XD.js.map +1 -0
- package/dist/chunk-NYPMQ7NO.js +2270 -0
- package/dist/chunk-NYPMQ7NO.js.map +1 -0
- package/dist/dependencies.d.ts +26 -6
- package/dist/domain/capabilities.d.ts +28 -3
- package/dist/domain/company-profile-durable-learning-adapter.d.ts +39 -0
- package/dist/domain/durable-learning-slack-publication.d.ts +72 -0
- package/dist/domain/editable-artifacts/agent-application.d.ts +192 -0
- package/dist/domain/editable-artifacts/durable-export-postgres.d.ts +4 -0
- package/dist/domain/editable-artifacts/durable-export.d.ts +212 -0
- package/dist/domain/editable-artifacts/errors.d.ts +47 -0
- package/dist/domain/editable-artifacts/hash.d.ts +11 -0
- package/dist/domain/editable-artifacts/in-memory.d.ts +99 -0
- package/dist/domain/editable-artifacts/index.d.ts +14 -0
- package/dist/domain/editable-artifacts/ports.d.ts +341 -0
- package/dist/domain/editable-artifacts/postgres-adapters.d.ts +13 -0
- package/dist/domain/editable-artifacts/service.d.ts +105 -0
- package/dist/domain/editable-artifacts/snapshot-compaction.d.ts +44 -0
- package/dist/domain/editable-artifacts/snapshot-verifier-genesis.d.ts +50 -0
- package/dist/domain/editable-artifacts/snapshot-verifier-materialization.d.ts +21 -0
- package/dist/domain/editable-artifacts/snapshot-verifier.d.ts +118 -0
- package/dist/domain/editable-artifacts/types.d.ts +410 -0
- package/dist/domain/memory-slack-delivery.d.ts +19 -0
- package/dist/domain/packs.d.ts +29 -1
- package/dist/domain/personal-connection-delegations.d.ts +9 -1
- package/dist/domain/scheduled-tasks.d.ts +2 -2
- package/dist/domain/session-tool-policy.d.ts +2 -2
- package/dist/domain/sessions.d.ts +14 -6
- package/dist/domain/skill-imports.d.ts +32 -0
- package/dist/domain/slack-publication-secret-safety.d.ts +8 -0
- package/dist/domain/timeline-annotations.d.ts +5 -0
- package/dist/domain/video-generation-capabilities.d.ts +9 -0
- package/dist/domain/video-generation.d.ts +47 -0
- package/dist/editable-artifact-live/application.d.ts +69 -0
- package/dist/editable-artifact-live/errors.d.ts +1 -0
- package/dist/editable-artifact-live/index.d.ts +8 -0
- package/dist/editable-artifact-live/outbox-dispatcher.d.ts +162 -0
- package/dist/editable-artifact-live/ports.d.ts +100 -0
- package/dist/editable-artifact-live/server.d.ts +71 -0
- package/dist/editable-artifact-live/ticket.d.ts +40 -0
- package/dist/editable-artifact-live/types.d.ts +213 -0
- package/dist/editable-artifact-live/wire.d.ts +34 -0
- package/dist/editable-artifact-live.d.ts +2 -0
- package/dist/editable-artifact-live.js +58 -0
- package/dist/editable-artifact-live.js.map +1 -0
- package/dist/editable-artifacts.d.ts +2 -0
- package/dist/editable-artifacts.js +179 -0
- package/dist/editable-artifacts.js.map +1 -0
- package/dist/index.d.ts +35 -26
- package/dist/index.js +2792 -609
- package/dist/index.js.map +1 -1
- package/dist/managed-session.d.ts +1 -1
- package/dist/rigs/index.d.ts +1 -1
- package/dist/rigs/provider-images.d.ts +31 -0
- package/dist/sandbox/routing.d.ts +1 -0
- package/dist/session-authorization.d.ts +1 -1
- package/dist/workflow-wake-contract.d.ts +7 -0
- package/package.json +18 -10
- package/src/application/new-session-drafts.ts +2 -0
- package/src/application/session-commands.ts +188 -107
- package/src/dependencies.ts +30 -2
- package/src/domain/capabilities.ts +604 -220
- package/src/domain/company-profile-durable-learning-adapter.ts +221 -0
- package/src/domain/durable-learning-slack-publication.ts +202 -0
- package/src/domain/editable-artifacts/agent-application.ts +687 -0
- package/src/domain/editable-artifacts/durable-export-postgres.ts +139 -0
- package/src/domain/editable-artifacts/durable-export.ts +734 -0
- package/src/domain/editable-artifacts/errors.ts +115 -0
- package/src/domain/editable-artifacts/hash.ts +131 -0
- package/src/domain/editable-artifacts/in-memory.ts +1662 -0
- package/src/domain/editable-artifacts/index.ts +14 -0
- package/src/domain/editable-artifacts/ports.ts +462 -0
- package/src/domain/editable-artifacts/postgres-adapters.ts +49 -0
- package/src/domain/editable-artifacts/service.ts +2402 -0
- package/src/domain/editable-artifacts/snapshot-compaction.ts +246 -0
- package/src/domain/editable-artifacts/snapshot-verifier-genesis.ts +235 -0
- package/src/domain/editable-artifacts/snapshot-verifier-materialization.ts +74 -0
- package/src/domain/editable-artifacts/snapshot-verifier.ts +687 -0
- package/src/domain/editable-artifacts/types.ts +835 -0
- package/src/domain/insights.ts +136 -33
- package/src/domain/memory-slack-delivery.ts +204 -0
- package/src/domain/memory-slack-publication.ts +5 -2
- package/src/domain/packs.ts +266 -5
- package/src/domain/personal-connection-delegations.ts +97 -6
- package/src/domain/scheduled-tasks.ts +155 -29
- package/src/domain/session-tool-policy.ts +8 -2
- package/src/domain/sessions.ts +274 -131
- package/src/domain/skill-imports.ts +350 -0
- package/src/domain/slack-publication-secret-safety.ts +42 -0
- package/src/domain/timeline-annotations.ts +204 -0
- package/src/domain/video-generation-capabilities.ts +69 -0
- package/src/domain/video-generation.ts +249 -0
- package/src/editable-artifact-live/application.ts +182 -0
- package/src/editable-artifact-live/errors.ts +4 -0
- package/src/editable-artifact-live/index.ts +8 -0
- package/src/editable-artifact-live/outbox-dispatcher.ts +916 -0
- package/src/editable-artifact-live/ports.ts +139 -0
- package/src/editable-artifact-live/server.ts +1707 -0
- package/src/editable-artifact-live/ticket.ts +217 -0
- package/src/editable-artifact-live/types.ts +286 -0
- package/src/editable-artifact-live/wire.ts +95 -0
- package/src/editable-artifact-live.ts +2 -0
- package/src/editable-artifacts.ts +2 -0
- package/src/index.ts +13 -0
- package/src/rigs/index.ts +26 -19
- package/src/rigs/provider-images.ts +110 -0
- package/src/sandbox/routing.ts +6 -3
- package/src/session-authorization.ts +3 -0
- package/src/workflow-wake-contract.ts +8 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import type { EditableArtifactAuthorizationPort } from "../domain/editable-artifacts/ports";
|
|
2
|
+
import {
|
|
3
|
+
assertIsoTimestamp,
|
|
4
|
+
editableArtifactId,
|
|
5
|
+
editableArtifactScope,
|
|
6
|
+
validateEditableArtifactActor,
|
|
7
|
+
type EditableArtifactActor,
|
|
8
|
+
type EditableArtifactId,
|
|
9
|
+
type EditableArtifactModality,
|
|
10
|
+
type EditableArtifactScope,
|
|
11
|
+
} from "../domain/editable-artifacts/types";
|
|
12
|
+
import { EditableArtifactLiveError } from "./errors";
|
|
13
|
+
import type {
|
|
14
|
+
EditableArtifactLiveClockPort,
|
|
15
|
+
EditableArtifactLiveTicketStorePort,
|
|
16
|
+
EditableArtifactLiveTokenPort,
|
|
17
|
+
} from "./ports";
|
|
18
|
+
import {
|
|
19
|
+
EDITABLE_ARTIFACT_LIVE_PROTOCOL_VERSION,
|
|
20
|
+
type EditableArtifactLiveTicket,
|
|
21
|
+
type EditableArtifactLiveTicketRecord,
|
|
22
|
+
} from "./types";
|
|
23
|
+
|
|
24
|
+
const DEFAULT_TTL_MS = 30_000;
|
|
25
|
+
const MAX_TTL_MS = 60_000;
|
|
26
|
+
const MAX_TOKEN_BYTES = 4_096;
|
|
27
|
+
|
|
28
|
+
export type EditableArtifactLiveTicketAuthorityDependencies = Readonly<{
|
|
29
|
+
authorization: EditableArtifactAuthorizationPort;
|
|
30
|
+
tickets: EditableArtifactLiveTicketStorePort;
|
|
31
|
+
tokens: EditableArtifactLiveTokenPort;
|
|
32
|
+
clock: EditableArtifactLiveClockPort;
|
|
33
|
+
ttlMs?: number;
|
|
34
|
+
protocolVersion?: number;
|
|
35
|
+
}>;
|
|
36
|
+
|
|
37
|
+
export class EditableArtifactLiveTicketAuthority {
|
|
38
|
+
private readonly ttlMs: number;
|
|
39
|
+
private readonly protocolVersion: number;
|
|
40
|
+
|
|
41
|
+
constructor(private readonly dependencies: EditableArtifactLiveTicketAuthorityDependencies) {
|
|
42
|
+
this.ttlMs = dependencies.ttlMs ?? DEFAULT_TTL_MS;
|
|
43
|
+
if (!Number.isSafeInteger(this.ttlMs) || this.ttlMs < 1_000 || this.ttlMs > MAX_TTL_MS) {
|
|
44
|
+
throw new TypeError(`ticket ttl must be 1000-${MAX_TTL_MS} milliseconds`);
|
|
45
|
+
}
|
|
46
|
+
this.protocolVersion = dependencies.protocolVersion ?? EDITABLE_ARTIFACT_LIVE_PROTOCOL_VERSION;
|
|
47
|
+
if (!Number.isSafeInteger(this.protocolVersion) || this.protocolVersion < 1) {
|
|
48
|
+
throw new TypeError("protocol version must be a positive safe integer");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async mint(
|
|
53
|
+
input: Readonly<{
|
|
54
|
+
scope: EditableArtifactScope;
|
|
55
|
+
artifactId: EditableArtifactId;
|
|
56
|
+
modality: EditableArtifactModality;
|
|
57
|
+
actor: EditableArtifactActor;
|
|
58
|
+
allowEdit: boolean;
|
|
59
|
+
}>,
|
|
60
|
+
): Promise<EditableArtifactLiveTicket> {
|
|
61
|
+
const scope = editableArtifactScope(input.scope);
|
|
62
|
+
const artifactId = editableArtifactId(input.artifactId);
|
|
63
|
+
const modality = assertModality(input.modality);
|
|
64
|
+
validateEditableArtifactActor(input.actor);
|
|
65
|
+
if (typeof input.allowEdit !== "boolean") {
|
|
66
|
+
throw new TypeError("ticket allowEdit must be boolean");
|
|
67
|
+
}
|
|
68
|
+
const actor = Object.freeze({ ...input.actor }) as EditableArtifactActor;
|
|
69
|
+
const decision = await this.dependencies.authorization.authorize({
|
|
70
|
+
scope,
|
|
71
|
+
artifactId,
|
|
72
|
+
actor,
|
|
73
|
+
permission: "read",
|
|
74
|
+
});
|
|
75
|
+
if (!decision.allowed) {
|
|
76
|
+
throw new EditableArtifactLiveError(
|
|
77
|
+
"permission_changed",
|
|
78
|
+
"Editable artifact read permission denied",
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
const token = this.dependencies.tokens.randomOpaqueToken();
|
|
82
|
+
assertToken(token);
|
|
83
|
+
const tokenDigest = await this.dependencies.tokens.digestOpaqueToken(token);
|
|
84
|
+
assertDigest(tokenDigest);
|
|
85
|
+
const issuedAtDate = this.dependencies.clock.now();
|
|
86
|
+
if (!Number.isFinite(issuedAtDate.getTime()))
|
|
87
|
+
throw new TypeError("clock returned an invalid date");
|
|
88
|
+
const issuedAt = issuedAtDate.toISOString();
|
|
89
|
+
const expiresAt = new Date(issuedAtDate.getTime() + this.ttlMs).toISOString();
|
|
90
|
+
const record: EditableArtifactLiveTicketRecord = Object.freeze({
|
|
91
|
+
tokenDigest,
|
|
92
|
+
scope,
|
|
93
|
+
artifactId,
|
|
94
|
+
modality,
|
|
95
|
+
actor,
|
|
96
|
+
allowEdit: input.allowEdit,
|
|
97
|
+
protocolVersion: this.protocolVersion,
|
|
98
|
+
issuedAt,
|
|
99
|
+
expiresAt,
|
|
100
|
+
});
|
|
101
|
+
await this.dependencies.tickets.put(record);
|
|
102
|
+
return Object.freeze({
|
|
103
|
+
artifactId,
|
|
104
|
+
modality,
|
|
105
|
+
replicaId: actor.replicaId,
|
|
106
|
+
token,
|
|
107
|
+
expiresAt,
|
|
108
|
+
protocolVersion: this.protocolVersion,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async consume(
|
|
113
|
+
input: Readonly<{
|
|
114
|
+
token: string;
|
|
115
|
+
artifactId: EditableArtifactId;
|
|
116
|
+
protocolVersion: number;
|
|
117
|
+
}>,
|
|
118
|
+
): Promise<EditableArtifactLiveTicketRecord> {
|
|
119
|
+
assertToken(input.token);
|
|
120
|
+
const artifactId = editableArtifactId(input.artifactId);
|
|
121
|
+
const digest = await this.dependencies.tokens.digestOpaqueToken(input.token);
|
|
122
|
+
assertDigest(digest);
|
|
123
|
+
const record = await this.dependencies.tickets.consume(digest);
|
|
124
|
+
if (!record) {
|
|
125
|
+
throw new EditableArtifactLiveError(
|
|
126
|
+
"ticket_replayed",
|
|
127
|
+
"Live ticket is invalid or was already consumed",
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
validateTicketRecord(record);
|
|
131
|
+
if (Date.parse(record.expiresAt) <= this.dependencies.clock.now().getTime()) {
|
|
132
|
+
throw new EditableArtifactLiveError("ticket_expired", "Live ticket has expired", {
|
|
133
|
+
retryable: true,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
if (record.artifactId !== artifactId) {
|
|
137
|
+
throw new EditableArtifactLiveError("invalid_ticket", "Live ticket scope does not match");
|
|
138
|
+
}
|
|
139
|
+
if (
|
|
140
|
+
record.protocolVersion !== input.protocolVersion ||
|
|
141
|
+
input.protocolVersion !== this.protocolVersion
|
|
142
|
+
) {
|
|
143
|
+
throw new EditableArtifactLiveError(
|
|
144
|
+
"protocol_mismatch",
|
|
145
|
+
"Editable artifact live protocol is unsupported",
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
return Object.freeze({
|
|
149
|
+
...record,
|
|
150
|
+
scope: editableArtifactScope(record.scope),
|
|
151
|
+
actor: Object.freeze({ ...record.actor }) as EditableArtifactActor,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Single-process test/dev store. Production must inject a shared atomic CAS store. */
|
|
157
|
+
export class InMemoryEditableArtifactLiveTicketStore implements EditableArtifactLiveTicketStorePort {
|
|
158
|
+
private readonly records = new Map<string, EditableArtifactLiveTicketRecord>();
|
|
159
|
+
|
|
160
|
+
async put(record: EditableArtifactLiveTicketRecord): Promise<void> {
|
|
161
|
+
if (this.records.has(record.tokenDigest)) throw new Error("Live ticket digest collision");
|
|
162
|
+
this.records.set(record.tokenDigest, record);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async consume(tokenDigest: string): Promise<EditableArtifactLiveTicketRecord | null> {
|
|
166
|
+
const record = this.records.get(tokenDigest) ?? null;
|
|
167
|
+
if (record) this.records.delete(tokenDigest);
|
|
168
|
+
return record;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export class WebCryptoEditableArtifactLiveTokens implements EditableArtifactLiveTokenPort {
|
|
173
|
+
randomOpaqueToken(): string {
|
|
174
|
+
const bytes = crypto.getRandomValues(new Uint8Array(32));
|
|
175
|
+
let binary = "";
|
|
176
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
177
|
+
return btoa(binary).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/u, "");
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
async digestOpaqueToken(token: string): Promise<string> {
|
|
181
|
+
const digest = new Uint8Array(
|
|
182
|
+
await crypto.subtle.digest("SHA-256", new TextEncoder().encode(token)),
|
|
183
|
+
);
|
|
184
|
+
return `sha256:${[...digest].map((byte) => byte.toString(16).padStart(2, "0")).join("")}`;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function validateTicketRecord(record: EditableArtifactLiveTicketRecord): void {
|
|
189
|
+
assertDigest(record.tokenDigest);
|
|
190
|
+
editableArtifactScope(record.scope);
|
|
191
|
+
editableArtifactId(record.artifactId);
|
|
192
|
+
assertModality(record.modality);
|
|
193
|
+
validateEditableArtifactActor(record.actor);
|
|
194
|
+
if (typeof record.allowEdit !== "boolean") {
|
|
195
|
+
throw new TypeError("ticket allowEdit is invalid");
|
|
196
|
+
}
|
|
197
|
+
assertIsoTimestamp(record.issuedAt, "ticket issuedAt");
|
|
198
|
+
assertIsoTimestamp(record.expiresAt, "ticket expiresAt");
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function assertModality(value: EditableArtifactModality): EditableArtifactModality {
|
|
202
|
+
if (value !== "document" && value !== "spreadsheet" && value !== "presentation") {
|
|
203
|
+
throw new TypeError("ticket modality is invalid");
|
|
204
|
+
}
|
|
205
|
+
return value;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function assertToken(token: string): void {
|
|
209
|
+
const bytes = new TextEncoder().encode(token).byteLength;
|
|
210
|
+
if (bytes < 32 || bytes > MAX_TOKEN_BYTES || !/^[A-Za-z0-9._~-]+$/u.test(token)) {
|
|
211
|
+
throw new EditableArtifactLiveError("invalid_ticket", "Live ticket is malformed");
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function assertDigest(value: string): void {
|
|
216
|
+
if (!/^sha256:[0-9a-f]{64}$/u.test(value)) throw new TypeError("ticket digest is malformed");
|
|
217
|
+
}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
EditableArtifactActor,
|
|
3
|
+
EditableArtifactCausalFrontier,
|
|
4
|
+
EditableArtifactClientTransactionId,
|
|
5
|
+
EditableArtifactContentHash,
|
|
6
|
+
EditableArtifactId,
|
|
7
|
+
EditableArtifactModality,
|
|
8
|
+
EditableArtifactRequestHash,
|
|
9
|
+
EditableArtifactScope,
|
|
10
|
+
EditableArtifactStateHash,
|
|
11
|
+
EditableArtifactTransactionId,
|
|
12
|
+
} from "../domain/editable-artifacts/types";
|
|
13
|
+
|
|
14
|
+
export const EDITABLE_ARTIFACT_LIVE_PROTOCOL_VERSION = 1;
|
|
15
|
+
|
|
16
|
+
export type EditableArtifactLiveTicket = Readonly<{
|
|
17
|
+
artifactId: EditableArtifactId;
|
|
18
|
+
modality: EditableArtifactModality;
|
|
19
|
+
replicaId: string;
|
|
20
|
+
token: string;
|
|
21
|
+
expiresAt: string;
|
|
22
|
+
protocolVersion: number;
|
|
23
|
+
}>;
|
|
24
|
+
|
|
25
|
+
/** Stored under a digest of the opaque token and atomically consumed once. */
|
|
26
|
+
export type EditableArtifactLiveTicketRecord = Readonly<{
|
|
27
|
+
tokenDigest: string;
|
|
28
|
+
scope: EditableArtifactScope;
|
|
29
|
+
artifactId: EditableArtifactId;
|
|
30
|
+
modality: EditableArtifactModality;
|
|
31
|
+
actor: EditableArtifactActor;
|
|
32
|
+
/** Delegated ceiling captured by the authenticated ticket-minting request. */
|
|
33
|
+
allowEdit: boolean;
|
|
34
|
+
protocolVersion: number;
|
|
35
|
+
issuedAt: string;
|
|
36
|
+
expiresAt: string;
|
|
37
|
+
}>;
|
|
38
|
+
|
|
39
|
+
type EditableArtifactLiveSnapshotCommon = Readonly<{
|
|
40
|
+
artifactId: EditableArtifactId;
|
|
41
|
+
sequence: number;
|
|
42
|
+
stateHash: EditableArtifactStateHash;
|
|
43
|
+
digest: EditableArtifactContentHash;
|
|
44
|
+
kernelVersion: string;
|
|
45
|
+
modelSchemaVersion: number;
|
|
46
|
+
bytes: Uint8Array;
|
|
47
|
+
}>;
|
|
48
|
+
|
|
49
|
+
export type EditableArtifactLiveSnapshot =
|
|
50
|
+
| (EditableArtifactLiveSnapshotCommon &
|
|
51
|
+
Readonly<{
|
|
52
|
+
modality: "spreadsheet";
|
|
53
|
+
causalFrontier: EditableArtifactCausalFrontier;
|
|
54
|
+
operationProtocolVersion: number;
|
|
55
|
+
}>)
|
|
56
|
+
| (EditableArtifactLiveSnapshotCommon &
|
|
57
|
+
Readonly<{
|
|
58
|
+
modality: "document" | "presentation";
|
|
59
|
+
nativeRevision: number;
|
|
60
|
+
}>);
|
|
61
|
+
|
|
62
|
+
type EditableArtifactLiveCommittedTransactionCommon = Readonly<{
|
|
63
|
+
artifactId: EditableArtifactId;
|
|
64
|
+
transactionId: EditableArtifactTransactionId;
|
|
65
|
+
requestHash: EditableArtifactRequestHash;
|
|
66
|
+
startSequence: number;
|
|
67
|
+
endSequence: number;
|
|
68
|
+
priorStateHash: EditableArtifactStateHash;
|
|
69
|
+
stateHash: EditableArtifactStateHash;
|
|
70
|
+
committedTransactionBytes: Uint8Array;
|
|
71
|
+
}>;
|
|
72
|
+
|
|
73
|
+
export type EditableArtifactLiveCommittedTransaction =
|
|
74
|
+
| (EditableArtifactLiveCommittedTransactionCommon &
|
|
75
|
+
Readonly<{
|
|
76
|
+
modality: "spreadsheet";
|
|
77
|
+
causalFrontier: EditableArtifactCausalFrontier;
|
|
78
|
+
operationProtocolVersion: number;
|
|
79
|
+
}>)
|
|
80
|
+
| (EditableArtifactLiveCommittedTransactionCommon &
|
|
81
|
+
Readonly<{
|
|
82
|
+
modality: "document" | "presentation";
|
|
83
|
+
priorNativeRevision: number;
|
|
84
|
+
nativeRevision: number;
|
|
85
|
+
commitProtocolVersion: number;
|
|
86
|
+
}>);
|
|
87
|
+
|
|
88
|
+
type EditableArtifactLiveHeadCommon = Readonly<{
|
|
89
|
+
headSequence: number;
|
|
90
|
+
stateHash: EditableArtifactStateHash;
|
|
91
|
+
minimumReplaySequence: number;
|
|
92
|
+
}>;
|
|
93
|
+
|
|
94
|
+
export type EditableArtifactLiveHead =
|
|
95
|
+
| (EditableArtifactLiveHeadCommon &
|
|
96
|
+
Readonly<{
|
|
97
|
+
modality: "spreadsheet";
|
|
98
|
+
causalFrontier: EditableArtifactCausalFrontier;
|
|
99
|
+
}>)
|
|
100
|
+
| (EditableArtifactLiveHeadCommon &
|
|
101
|
+
Readonly<{
|
|
102
|
+
modality: "document" | "presentation";
|
|
103
|
+
nativeRevision: number;
|
|
104
|
+
}>);
|
|
105
|
+
|
|
106
|
+
export type EditableArtifactLiveBootstrap = EditableArtifactLiveHead &
|
|
107
|
+
Readonly<{
|
|
108
|
+
resumeAccepted: boolean;
|
|
109
|
+
resumeSequence: number;
|
|
110
|
+
resumeStateHash: EditableArtifactStateHash;
|
|
111
|
+
snapshot: EditableArtifactLiveSnapshot | null;
|
|
112
|
+
}>;
|
|
113
|
+
|
|
114
|
+
type EditableArtifactLiveResumeCommon = Readonly<{
|
|
115
|
+
localCursor: number | null;
|
|
116
|
+
localStateHash: EditableArtifactStateHash | null;
|
|
117
|
+
requireSnapshot: boolean;
|
|
118
|
+
}>;
|
|
119
|
+
|
|
120
|
+
export type EditableArtifactLiveResume =
|
|
121
|
+
| (EditableArtifactLiveResumeCommon &
|
|
122
|
+
Readonly<{
|
|
123
|
+
modality?: "spreadsheet";
|
|
124
|
+
localCausalFrontier: EditableArtifactCausalFrontier;
|
|
125
|
+
}>)
|
|
126
|
+
| (EditableArtifactLiveResumeCommon &
|
|
127
|
+
Readonly<{
|
|
128
|
+
modality: "document" | "presentation";
|
|
129
|
+
localNativeRevision: number | null;
|
|
130
|
+
}>);
|
|
131
|
+
|
|
132
|
+
export type EditableArtifactLiveServerFrame =
|
|
133
|
+
| Readonly<{
|
|
134
|
+
type: "open";
|
|
135
|
+
protocolVersion: number;
|
|
136
|
+
artifactId: EditableArtifactId;
|
|
137
|
+
streamEpoch: string;
|
|
138
|
+
modality: EditableArtifactModality;
|
|
139
|
+
writable: boolean;
|
|
140
|
+
headSequence: number;
|
|
141
|
+
minimumReplaySequence: number;
|
|
142
|
+
maxClientFrameBytes: number;
|
|
143
|
+
maxCommandBytes: number;
|
|
144
|
+
maxIntentBytes: number;
|
|
145
|
+
maxCommittedTransactionBytes: number;
|
|
146
|
+
maxSnapshotBytes: number;
|
|
147
|
+
maxInFlightTransactions: number;
|
|
148
|
+
maxInFlightBytes: number;
|
|
149
|
+
}>
|
|
150
|
+
| (Readonly<{
|
|
151
|
+
type: "snapshot";
|
|
152
|
+
protocolVersion: number;
|
|
153
|
+
artifactId: EditableArtifactId;
|
|
154
|
+
streamEpoch: string;
|
|
155
|
+
sequence: number;
|
|
156
|
+
stateHash: EditableArtifactStateHash;
|
|
157
|
+
digest: EditableArtifactContentHash;
|
|
158
|
+
kernelVersion: string;
|
|
159
|
+
modelSchemaVersion: number;
|
|
160
|
+
offset: number;
|
|
161
|
+
totalBytes: number;
|
|
162
|
+
final: boolean;
|
|
163
|
+
bytes: Uint8Array;
|
|
164
|
+
}> &
|
|
165
|
+
(
|
|
166
|
+
| Readonly<{
|
|
167
|
+
modality: "spreadsheet";
|
|
168
|
+
causalFrontier: EditableArtifactCausalFrontier;
|
|
169
|
+
}>
|
|
170
|
+
| Readonly<{
|
|
171
|
+
modality: "document" | "presentation";
|
|
172
|
+
nativeRevision: number;
|
|
173
|
+
}>
|
|
174
|
+
))
|
|
175
|
+
| Readonly<{
|
|
176
|
+
type: "transaction";
|
|
177
|
+
protocolVersion: number;
|
|
178
|
+
artifactId: EditableArtifactId;
|
|
179
|
+
streamEpoch: string;
|
|
180
|
+
transaction: EditableArtifactLiveCommittedTransaction;
|
|
181
|
+
}>
|
|
182
|
+
| Readonly<{
|
|
183
|
+
type: "barrier";
|
|
184
|
+
protocolVersion: number;
|
|
185
|
+
artifactId: EditableArtifactId;
|
|
186
|
+
streamEpoch: string;
|
|
187
|
+
sequence: number;
|
|
188
|
+
stateHash: EditableArtifactStateHash;
|
|
189
|
+
}>
|
|
190
|
+
| Readonly<{
|
|
191
|
+
type: "watermark";
|
|
192
|
+
protocolVersion: number;
|
|
193
|
+
artifactId: EditableArtifactId;
|
|
194
|
+
streamEpoch: string;
|
|
195
|
+
headSequence: number;
|
|
196
|
+
}>
|
|
197
|
+
| Readonly<{
|
|
198
|
+
type: "resyncRequired";
|
|
199
|
+
protocolVersion: number;
|
|
200
|
+
artifactId: EditableArtifactId;
|
|
201
|
+
streamEpoch: string;
|
|
202
|
+
reason: "retention_gap" | "durable_gap" | "invalid_ack" | "slow_client" | "oversized_frame";
|
|
203
|
+
headSequence: number;
|
|
204
|
+
}>
|
|
205
|
+
| Readonly<{
|
|
206
|
+
type: "applied";
|
|
207
|
+
protocolVersion: number;
|
|
208
|
+
artifactId: EditableArtifactId;
|
|
209
|
+
streamEpoch: string;
|
|
210
|
+
sequence: number;
|
|
211
|
+
stateHash: EditableArtifactStateHash;
|
|
212
|
+
}>
|
|
213
|
+
| Readonly<{
|
|
214
|
+
type: "authorizationChanged";
|
|
215
|
+
protocolVersion: number;
|
|
216
|
+
artifactId: EditableArtifactId;
|
|
217
|
+
streamEpoch: string;
|
|
218
|
+
writable: boolean;
|
|
219
|
+
}>
|
|
220
|
+
| Readonly<{
|
|
221
|
+
type: "mutationAccepted";
|
|
222
|
+
protocolVersion: number;
|
|
223
|
+
artifactId: EditableArtifactId;
|
|
224
|
+
streamEpoch: string;
|
|
225
|
+
requestHash: EditableArtifactRequestHash;
|
|
226
|
+
clientTransactionId: EditableArtifactClientTransactionId;
|
|
227
|
+
transactionId: EditableArtifactTransactionId;
|
|
228
|
+
startSequence: number;
|
|
229
|
+
endSequence: number;
|
|
230
|
+
stateHash: EditableArtifactStateHash;
|
|
231
|
+
}>
|
|
232
|
+
| Readonly<{
|
|
233
|
+
type: "mutationRejected";
|
|
234
|
+
protocolVersion: number;
|
|
235
|
+
artifactId: EditableArtifactId;
|
|
236
|
+
streamEpoch: string;
|
|
237
|
+
requestHash: EditableArtifactRequestHash;
|
|
238
|
+
code: "invalid_request" | "forbidden" | "conflict" | "unsupported" | "unavailable";
|
|
239
|
+
retryable: boolean;
|
|
240
|
+
}>;
|
|
241
|
+
|
|
242
|
+
export type EditableArtifactLiveAppliedClientFrame = Readonly<{
|
|
243
|
+
type: "applied";
|
|
244
|
+
protocolVersion: number;
|
|
245
|
+
artifactId: EditableArtifactId;
|
|
246
|
+
streamEpoch: string;
|
|
247
|
+
sequence: number;
|
|
248
|
+
stateHash: EditableArtifactStateHash;
|
|
249
|
+
}>;
|
|
250
|
+
|
|
251
|
+
export type EditableArtifactLiveMutationClientFrame = Readonly<{
|
|
252
|
+
protocolVersion: number;
|
|
253
|
+
artifactId: EditableArtifactId;
|
|
254
|
+
streamEpoch: string;
|
|
255
|
+
requestHash: EditableArtifactRequestHash;
|
|
256
|
+
intentBytes: Uint8Array;
|
|
257
|
+
}>;
|
|
258
|
+
|
|
259
|
+
export type EditableArtifactLiveClientFrame = EditableArtifactLiveAppliedClientFrame;
|
|
260
|
+
|
|
261
|
+
export type EditableArtifactLiveCloseReason =
|
|
262
|
+
| "closed"
|
|
263
|
+
| "ticket_expired"
|
|
264
|
+
| "ticket_replayed"
|
|
265
|
+
| "protocol_mismatch"
|
|
266
|
+
| "permission_changed"
|
|
267
|
+
| "invalid_frame"
|
|
268
|
+
| "oversized_frame"
|
|
269
|
+
| "stale_epoch"
|
|
270
|
+
| "invalid_ack"
|
|
271
|
+
| "retention_gap"
|
|
272
|
+
| "durable_gap"
|
|
273
|
+
| "slow_client"
|
|
274
|
+
| "transport_error";
|
|
275
|
+
|
|
276
|
+
export type EditableArtifactLiveClose = Readonly<{
|
|
277
|
+
reason: EditableArtifactLiveCloseReason;
|
|
278
|
+
retryable: boolean;
|
|
279
|
+
requiresSnapshot: boolean;
|
|
280
|
+
}>;
|
|
281
|
+
|
|
282
|
+
export type EditableArtifactLiveMutationReceipt = Readonly<{
|
|
283
|
+
clientTransactionId: EditableArtifactClientTransactionId;
|
|
284
|
+
requestHash: EditableArtifactRequestHash;
|
|
285
|
+
transaction: EditableArtifactLiveCommittedTransaction;
|
|
286
|
+
}>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EDITABLE_ARTIFACT_LIVE_WIRE_VERSION,
|
|
3
|
+
decodeEditableArtifactLiveClientWireFrame as decodeContractClientFrame,
|
|
4
|
+
decodeEditableArtifactLiveServerWireFrame,
|
|
5
|
+
encodeEditableArtifactLiveAppliedWireFrame as encodeContractAppliedFrame,
|
|
6
|
+
encodeEditableArtifactLiveMutationWireFrame as encodeContractMutationFrame,
|
|
7
|
+
encodeEditableArtifactLiveOpenWireFrame as encodeContractOpenFrame,
|
|
8
|
+
encodeEditableArtifactLiveServerWireFrame as encodeContractServerFrame,
|
|
9
|
+
inspectEditableArtifactLiveWireEnvelope,
|
|
10
|
+
type EditableArtifactLiveAppliedWireFrame as ContractAppliedWireFrame,
|
|
11
|
+
type EditableArtifactLiveMutationWireFrame as ContractMutationWireFrame,
|
|
12
|
+
type EditableArtifactLiveOpenWireFrame as ContractOpenWireFrame,
|
|
13
|
+
type EditableArtifactLiveServerFrame as ContractServerFrame,
|
|
14
|
+
} from "@opengeni/contracts/editable-artifact-live";
|
|
15
|
+
import type {
|
|
16
|
+
EditableArtifactId,
|
|
17
|
+
EditableArtifactRequestHash,
|
|
18
|
+
EditableArtifactStateHash,
|
|
19
|
+
} from "../domain/editable-artifacts/types";
|
|
20
|
+
import type { EditableArtifactLiveResume, EditableArtifactLiveServerFrame } from "./types";
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
EDITABLE_ARTIFACT_LIVE_WIRE_VERSION,
|
|
24
|
+
decodeEditableArtifactLiveServerWireFrame,
|
|
25
|
+
inspectEditableArtifactLiveWireEnvelope,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** Branded core view over the contracts-owned wire type. Runtime validation is contracts-only. */
|
|
29
|
+
export type EditableArtifactLiveOpenWireFrame = Readonly<{
|
|
30
|
+
type: "open";
|
|
31
|
+
protocolVersion: number;
|
|
32
|
+
artifactId: EditableArtifactId;
|
|
33
|
+
token: string;
|
|
34
|
+
resume: EditableArtifactLiveResume;
|
|
35
|
+
}>;
|
|
36
|
+
export type EditableArtifactLiveAppliedWireFrame = Readonly<{
|
|
37
|
+
type: "applied";
|
|
38
|
+
protocolVersion: number;
|
|
39
|
+
artifactId: EditableArtifactId;
|
|
40
|
+
streamEpoch: string;
|
|
41
|
+
sequence: number;
|
|
42
|
+
stateHash: EditableArtifactStateHash;
|
|
43
|
+
}>;
|
|
44
|
+
export type EditableArtifactLiveMutationWireFrame = Readonly<{
|
|
45
|
+
type: "mutation";
|
|
46
|
+
protocolVersion: number;
|
|
47
|
+
artifactId: EditableArtifactId;
|
|
48
|
+
streamEpoch: string;
|
|
49
|
+
requestHash: EditableArtifactRequestHash;
|
|
50
|
+
intentBytes: Uint8Array;
|
|
51
|
+
}>;
|
|
52
|
+
export type EditableArtifactLiveClientWireFrame =
|
|
53
|
+
| EditableArtifactLiveOpenWireFrame
|
|
54
|
+
| EditableArtifactLiveAppliedWireFrame
|
|
55
|
+
| EditableArtifactLiveMutationWireFrame;
|
|
56
|
+
|
|
57
|
+
export function decodeEditableArtifactLiveClientWireFrame(
|
|
58
|
+
bytes: Uint8Array,
|
|
59
|
+
): EditableArtifactLiveClientWireFrame {
|
|
60
|
+
return decodeContractClientFrame(bytes) as unknown as EditableArtifactLiveClientWireFrame;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function encodeEditableArtifactLiveOpenWireFrame(
|
|
64
|
+
frame: EditableArtifactLiveOpenWireFrame,
|
|
65
|
+
): Uint8Array {
|
|
66
|
+
return encodeContractOpenFrame(frame as unknown as ContractOpenWireFrame);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function encodeEditableArtifactLiveAppliedWireFrame(
|
|
70
|
+
frame: EditableArtifactLiveAppliedWireFrame,
|
|
71
|
+
): Uint8Array {
|
|
72
|
+
return encodeContractAppliedFrame(frame as unknown as ContractAppliedWireFrame);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function encodeEditableArtifactLiveMutationWireFrame(
|
|
76
|
+
frame: EditableArtifactLiveMutationWireFrame,
|
|
77
|
+
): Uint8Array {
|
|
78
|
+
return encodeContractMutationFrame(frame as unknown as ContractMutationWireFrame);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function encodeEditableArtifactLiveServerWireFrame(
|
|
82
|
+
frame: EditableArtifactLiveServerFrame,
|
|
83
|
+
): Uint8Array {
|
|
84
|
+
if (frame.type === "transaction" && frame.transaction.modality === "spreadsheet") {
|
|
85
|
+
const { operationProtocolVersion, modality: _modality, ...transaction } = frame.transaction;
|
|
86
|
+
return encodeContractServerFrame({
|
|
87
|
+
...frame,
|
|
88
|
+
transaction: {
|
|
89
|
+
...transaction,
|
|
90
|
+
protocolVersion: operationProtocolVersion,
|
|
91
|
+
},
|
|
92
|
+
} as unknown as ContractServerFrame);
|
|
93
|
+
}
|
|
94
|
+
return encodeContractServerFrame(frame as unknown as ContractServerFrame);
|
|
95
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -55,6 +55,7 @@ export * from "./billing/limits";
|
|
|
55
55
|
// postUserMessageTurn, createAndStartSession, capability/pack/environment/
|
|
56
56
|
// scheduled-task/workspace-member logic, …).
|
|
57
57
|
export * from "./domain/capabilities";
|
|
58
|
+
export * from "./domain/skill-imports";
|
|
58
59
|
export * from "./domain/environments";
|
|
59
60
|
export * from "./rigs";
|
|
60
61
|
export * from "./domain/packs";
|
|
@@ -65,7 +66,19 @@ export * from "./domain/scheduled-tasks";
|
|
|
65
66
|
export * from "./domain/sessions";
|
|
66
67
|
export * from "./domain/insights";
|
|
67
68
|
export * from "./domain/memory-slack-publication";
|
|
69
|
+
export * from "./domain/memory-slack-delivery";
|
|
70
|
+
export * from "./domain/durable-learning-slack-publication";
|
|
71
|
+
export * from "./domain/slack-publication-secret-safety";
|
|
72
|
+
export * from "./domain/company-profile-durable-learning-adapter";
|
|
68
73
|
export * from "./domain/slack-bot";
|
|
69
74
|
export * from "./domain/workspace-members";
|
|
75
|
+
export * from "./domain/video-generation";
|
|
76
|
+
export * from "./domain/video-generation-capabilities";
|
|
70
77
|
export * from "./application/new-session-drafts";
|
|
71
78
|
export * from "./application/session-commands";
|
|
79
|
+
|
|
80
|
+
// Durable editable-artifact live broker, ticket, ports, and projection types.
|
|
81
|
+
export * from "./editable-artifact-live";
|
|
82
|
+
|
|
83
|
+
// Transport-neutral editable-artifact domain service, ports, and contracts.
|
|
84
|
+
export * from "./editable-artifacts";
|