@opengeni/core 0.28.0 → 1.0.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.
- package/README.md +1 -1
- package/dist/access/external-actor-authority.d.ts +47 -0
- package/dist/access/index.d.ts +182 -3
- package/dist/access/service-initiator.d.ts +3 -0
- package/dist/application/api-integration-servers.d.ts +20 -0
- package/dist/application/archived-session-imports.d.ts +6 -0
- package/dist/application/composer-submit.d.ts +24 -0
- package/dist/application/connect-authority.d.ts +13 -0
- package/dist/application/connect-operation.d.ts +31 -0
- package/dist/application/external-continuation.d.ts +15 -0
- package/dist/application/external-identity-lifecycle.d.ts +20 -0
- package/dist/application/external-link-work-admission.d.ts +12 -0
- package/dist/application/external-workspace-members.d.ts +34 -0
- package/dist/application/modal-native-worker-host-transport.d.ts +297 -0
- package/dist/application/new-session-drafts.d.ts +39 -2
- package/dist/application/sandbox-recovery.d.ts +58 -0
- package/dist/application/session-commands.d.ts +26 -13
- package/dist/application/session-mcp-credential-rotation.d.ts +29 -0
- package/dist/application/session-tenancy.d.ts +19 -0
- package/dist/application/user-resource-grants.d.ts +20 -0
- package/dist/billing/limits.d.ts +11 -0
- package/dist/canonical-human-identities.d.ts +7 -2
- package/dist/canonical-human-identities.js +17 -4
- package/dist/canonical-human-identities.js.map +1 -1
- package/dist/{chunk-6WKPWE5S.js → chunk-2MKMRGSY.js} +108 -24
- package/dist/chunk-2MKMRGSY.js.map +1 -0
- package/dist/{chunk-NYPMQ7NO.js → chunk-GVO3N37G.js} +205 -37
- package/dist/chunk-GVO3N37G.js.map +1 -0
- package/dist/{chunk-JJU6I5XD.js → chunk-LCQXNR62.js} +36 -10
- package/dist/chunk-LCQXNR62.js.map +1 -0
- package/dist/chunk-MM6N7CTO.js +387 -0
- package/dist/chunk-MM6N7CTO.js.map +1 -0
- package/dist/chunk-QO5GVFFO.js +235 -0
- package/dist/chunk-QO5GVFFO.js.map +1 -0
- package/dist/codex-model-availability.d.ts +14 -0
- package/dist/default-session-model.d.ts +139 -0
- package/dist/dependencies.d.ts +87 -4
- package/dist/developer-setup-credential-ceiling.d.ts +10 -0
- package/dist/domain/agent-config-resolution.d.ts +49 -0
- package/dist/domain/automations.d.ts +58 -0
- package/dist/domain/capabilities.d.ts +22 -4
- package/dist/domain/company-profile-agent-admin.d.ts +25 -0
- package/dist/domain/connection-account-selection-error.d.ts +8 -0
- package/dist/domain/connector-tool-permissions.d.ts +36 -0
- package/dist/domain/direct-model-provider.d.ts +3 -0
- package/dist/domain/editable-artifacts/agent-application.d.ts +10 -1
- package/dist/domain/editable-artifacts/durable-export.d.ts +22 -1
- package/dist/domain/editable-artifacts/ports.d.ts +10 -0
- package/dist/domain/editable-artifacts/service.d.ts +4 -3
- package/dist/domain/environments.d.ts +5 -9
- package/dist/domain/external-creation-attribution.d.ts +6 -0
- package/dist/domain/file-owner.d.ts +8 -0
- package/dist/domain/github-action-policies.d.ts +36 -0
- package/dist/domain/github-repository-bindings.d.ts +117 -0
- package/dist/domain/github-skill-source.d.ts +5 -0
- package/dist/domain/governed-learning-slack-publication.d.ts +45 -0
- package/dist/domain/insights-timing.d.ts +16 -0
- package/dist/domain/insights-usage.d.ts +27 -0
- package/dist/domain/insights.d.ts +28 -1
- package/dist/domain/knowledge-files.d.ts +20 -0
- package/dist/domain/knowledge-messages.d.ts +39 -0
- package/dist/domain/knowledge-messages.test.d.ts +1 -0
- package/dist/domain/knowledge-preparation.d.ts +10 -0
- package/dist/domain/knowledge-preparation.test.d.ts +1 -0
- package/dist/domain/knowledge-search.d.ts +15 -0
- package/dist/domain/knowledge-search.test.d.ts +1 -0
- package/dist/domain/knowledge.d.ts +9 -0
- package/dist/domain/mcp-account-bindings.d.ts +19 -0
- package/dist/domain/mcp-account-routes.d.ts +21 -0
- package/dist/domain/native-mcp-connection-admission.d.ts +3 -0
- package/dist/domain/organization-integration-catalog.d.ts +15 -0
- package/dist/domain/organization-membership-lifecycle.d.ts +1 -0
- package/dist/domain/personal-connection-delegations.d.ts +87 -4
- package/dist/domain/pr-review.d.ts +249 -0
- package/dist/domain/resources.d.ts +24 -3
- package/dist/domain/scheduled-task-access.d.ts +247 -0
- package/dist/domain/scheduled-tasks.d.ts +103 -6
- package/dist/domain/session-connection-accounts.d.ts +16 -0
- package/dist/domain/session-file-access.d.ts +4 -0
- package/dist/domain/session-native-connection-replacement.d.ts +14 -0
- package/dist/domain/session-start-timing.d.ts +7 -0
- package/dist/domain/session-tool-policy.d.ts +93 -4
- package/dist/domain/sessions.d.ts +275 -28
- package/dist/domain/skill-imports.d.ts +1 -0
- package/dist/domain/skill-search.d.ts +30 -0
- package/dist/domain/skills.d.ts +117 -0
- package/dist/domain/slack-bot.d.ts +46 -1
- package/dist/domain/workspace-members.d.ts +8 -1
- package/dist/editable-artifact-live/application.d.ts +12 -3
- package/dist/editable-artifact-live/ports.d.ts +0 -1
- package/dist/editable-artifact-live/server.d.ts +5 -2
- package/dist/editable-artifact-live/ticket.d.ts +2 -2
- package/dist/editable-artifact-live/types.d.ts +14 -2
- package/dist/editable-artifact-live.js +2 -2
- package/dist/editable-artifacts.js +10 -4
- package/dist/index.d.ts +49 -3
- package/dist/index.js +18826 -6847
- package/dist/index.js.map +1 -1
- package/dist/managed-auth-session-sets.d.ts +131 -0
- package/dist/managed-auth-session-sets.js +51 -0
- package/dist/managed-auth-session-sets.js.map +1 -0
- package/dist/managed-session.d.ts +98 -11
- package/dist/model-catalog.d.ts +117 -0
- package/dist/product-usage-metrics.d.ts +30 -0
- package/dist/rigs/index.d.ts +22 -5
- package/dist/rigs/provider-images.d.ts +1 -1
- package/dist/sandbox/fleet.d.ts +59 -10
- package/dist/sandbox/routing.d.ts +22 -2
- package/dist/sandbox/runtime-settings.d.ts +56 -0
- package/dist/session-authorization.d.ts +38 -1
- package/dist/site-session-origin.d.ts +9 -0
- package/dist/transcription.d.ts +12 -1
- package/dist/turn-surface.d.ts +18 -0
- package/dist/user-presence.d.ts +32 -0
- package/package.json +18 -11
- package/src/access/external-actor-authority.ts +94 -0
- package/src/access/index.ts +1386 -44
- package/src/access/service-initiator.ts +50 -0
- package/src/application/api-integration-servers.ts +215 -0
- package/src/application/archived-session-imports.ts +161 -0
- package/src/application/composer-submit.ts +77 -0
- package/src/application/connect-authority.ts +77 -0
- package/src/application/connect-operation.ts +80 -0
- package/src/application/external-continuation.ts +129 -0
- package/src/application/external-identity-lifecycle.ts +48 -0
- package/src/application/external-link-work-admission.ts +90 -0
- package/src/application/external-workspace-members.ts +232 -0
- package/src/application/modal-native-worker-host-transport.ts +263 -0
- package/src/application/new-session-drafts.ts +222 -29
- package/src/application/sandbox-recovery.ts +78 -0
- package/src/application/session-commands.ts +430 -73
- package/src/application/session-mcp-credential-rotation.ts +217 -0
- package/src/application/session-tenancy.ts +445 -0
- package/src/application/user-resource-grants.ts +154 -0
- package/src/billing/limits.ts +103 -24
- package/src/canonical-human-identities.ts +22 -3
- package/src/codex-model-availability.ts +136 -0
- package/src/default-session-model.ts +656 -0
- package/src/dependencies.ts +97 -5
- package/src/developer-setup-credential-ceiling.ts +60 -0
- package/src/domain/agent-config-resolution.ts +148 -0
- package/src/domain/automations.ts +270 -0
- package/src/domain/capabilities.ts +244 -151
- package/src/domain/company-profile-agent-admin.ts +56 -0
- package/src/domain/connection-account-selection-error.ts +19 -0
- package/src/domain/connector-tool-permissions.ts +371 -0
- package/src/domain/direct-model-provider.ts +62 -0
- package/src/domain/editable-artifacts/agent-application.ts +61 -15
- package/src/domain/editable-artifacts/durable-export.ts +100 -5
- package/src/domain/editable-artifacts/in-memory.ts +6 -0
- package/src/domain/editable-artifacts/ports.ts +11 -0
- package/src/domain/editable-artifacts/service.ts +32 -1
- package/src/domain/editable-artifacts/snapshot-compaction.ts +9 -5
- package/src/domain/editable-artifacts/snapshot-verifier-genesis.ts +10 -8
- package/src/domain/editable-artifacts/snapshot-verifier.ts +10 -3
- package/src/domain/environments.ts +25 -45
- package/src/domain/external-creation-attribution.ts +22 -0
- package/src/domain/file-owner.ts +67 -0
- package/src/domain/github-action-policies.ts +169 -0
- package/src/domain/github-repository-bindings.ts +295 -0
- package/src/domain/github-skill-source.ts +233 -0
- package/src/domain/governed-learning-slack-publication.ts +157 -0
- package/src/domain/insights-timing.ts +95 -0
- package/src/domain/insights-usage.ts +67 -0
- package/src/domain/insights.ts +270 -169
- package/src/domain/knowledge-files.ts +46 -0
- package/src/domain/knowledge-messages.test.ts +91 -0
- package/src/domain/knowledge-messages.ts +106 -0
- package/src/domain/knowledge-preparation.test.ts +276 -0
- package/src/domain/knowledge-preparation.ts +147 -0
- package/src/domain/knowledge-search.test.ts +561 -0
- package/src/domain/knowledge-search.ts +256 -0
- package/src/domain/knowledge.ts +133 -0
- package/src/domain/mcp-account-bindings.ts +171 -0
- package/src/domain/mcp-account-routes.ts +121 -0
- package/src/domain/native-mcp-connection-admission.ts +14 -0
- package/src/domain/organization-integration-catalog.ts +88 -0
- package/src/domain/organization-membership-lifecycle.ts +10 -0
- package/src/domain/personal-connection-delegations.ts +758 -115
- package/src/domain/pr-review.ts +687 -0
- package/src/domain/resources.ts +182 -25
- package/src/domain/scheduled-task-access.ts +1052 -0
- package/src/domain/scheduled-tasks.ts +1952 -215
- package/src/domain/session-connection-accounts.ts +67 -0
- package/src/domain/session-file-access.ts +47 -0
- package/src/domain/session-native-connection-replacement.ts +64 -0
- package/src/domain/session-start-timing.ts +55 -0
- package/src/domain/session-tool-policy.ts +443 -19
- package/src/domain/sessions.ts +3417 -619
- package/src/domain/skill-imports.ts +137 -17
- package/src/domain/skill-search.ts +221 -0
- package/src/domain/skills.ts +104 -0
- package/src/domain/slack-bot.ts +128 -3
- package/src/domain/workspace-members.ts +34 -2
- package/src/editable-artifact-live/application.ts +29 -4
- package/src/editable-artifact-live/ports.ts +0 -1
- package/src/editable-artifact-live/server.ts +167 -13
- package/src/editable-artifact-live/ticket.ts +87 -6
- package/src/editable-artifact-live/types.ts +16 -2
- package/src/editable-artifact-live/wire.ts +0 -10
- package/src/index.ts +69 -4
- package/src/managed-auth-session-sets.ts +371 -0
- package/src/managed-session.ts +520 -2
- package/src/model-catalog.ts +873 -0
- package/src/product-usage-metrics.ts +101 -0
- package/src/rigs/index.ts +179 -63
- package/src/rigs/provider-images.ts +2 -3
- package/src/sandbox/fleet.ts +471 -59
- package/src/sandbox/routing.ts +160 -33
- package/src/sandbox/runtime-settings.ts +281 -0
- package/src/session-authorization.ts +262 -78
- package/src/site-session-origin.ts +22 -0
- package/src/transcription.ts +13 -1
- package/src/turn-surface.ts +45 -0
- package/src/user-presence.ts +134 -0
- package/dist/chunk-6WKPWE5S.js.map +0 -1
- package/dist/chunk-IBOEYG6N.js +0 -34
- package/dist/chunk-IBOEYG6N.js.map +0 -1
- package/dist/chunk-JJU6I5XD.js.map +0 -1
- package/dist/chunk-NYPMQ7NO.js.map +0 -1
- package/dist/domain/durable-learning-slack-publication.d.ts +0 -72
- package/dist/domain/packs.d.ts +0 -55
- package/src/domain/durable-learning-slack-publication.ts +0 -202
- package/src/domain/packs.ts +0 -556
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
editableArtifactStateHash,
|
|
15
15
|
editableArtifactTransactionId,
|
|
16
16
|
validateEditableArtifactActor
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-LCQXNR62.js";
|
|
18
18
|
|
|
19
19
|
// src/editable-artifact-live/application.ts
|
|
20
20
|
import { EDITABLE_ARTIFACT_KERNEL_VERSION_MAX_BYTES } from "@opengeni/contracts/editable-artifacts";
|
|
@@ -75,16 +75,27 @@ var EditableArtifactApplication = class {
|
|
|
75
75
|
const artifact = await this.readArtifact(input);
|
|
76
76
|
await this.dependencies.compatibility.assertCompatible({
|
|
77
77
|
artifact,
|
|
78
|
-
|
|
78
|
+
modality: input.modality,
|
|
79
|
+
liveProtocolVersion: positiveInteger(input.liveProtocolVersion, "liveProtocolVersion"),
|
|
79
80
|
kernelVersion: boundedVersion(input.kernelVersion, "kernelVersion"),
|
|
80
|
-
modelSchemaVersion: positiveInteger(input.modelSchemaVersion, "modelSchemaVersion")
|
|
81
|
+
modelSchemaVersion: positiveInteger(input.modelSchemaVersion, "modelSchemaVersion"),
|
|
82
|
+
snapshotVersion: positiveInteger(input.snapshotVersion, "snapshotVersion"),
|
|
83
|
+
commandProtocolVersion: positiveInteger(
|
|
84
|
+
input.commandProtocolVersion,
|
|
85
|
+
"commandProtocolVersion"
|
|
86
|
+
),
|
|
87
|
+
committedTransactionProtocolVersion: positiveInteger(
|
|
88
|
+
input.committedTransactionProtocolVersion,
|
|
89
|
+
"committedTransactionProtocolVersion"
|
|
90
|
+
)
|
|
81
91
|
});
|
|
82
92
|
return await this.dependencies.live.mintTicket({
|
|
83
93
|
scope: artifact.scope,
|
|
84
94
|
artifactId: artifact.id,
|
|
85
95
|
modality: artifact.modality,
|
|
86
96
|
actor: input.actor,
|
|
87
|
-
allowEdit: input.allowEdit
|
|
97
|
+
allowEdit: input.allowEdit,
|
|
98
|
+
...input.sourceSessionAuthority ? { sourceSessionAuthority: input.sourceSessionAuthority } : {}
|
|
88
99
|
});
|
|
89
100
|
}
|
|
90
101
|
openLive(input) {
|
|
@@ -738,13 +749,28 @@ import {
|
|
|
738
749
|
import { decodeCommittedTransactionSummary } from "@opengeni/contracts/editable-artifact-committed-transaction";
|
|
739
750
|
import { decodeEditableArtifactSerializedCommit } from "@opengeni/contracts/editable-artifact-serialized-commit";
|
|
740
751
|
|
|
752
|
+
// src/editable-artifact-live/ticket.ts
|
|
753
|
+
import { AccessGrant } from "@opengeni/contracts";
|
|
754
|
+
import { ExternalActorContinuation } from "@opengeni/contracts/external-identities";
|
|
755
|
+
import { z } from "zod";
|
|
756
|
+
import { deflateRawSync, inflateRawSync } from "zlib";
|
|
757
|
+
|
|
741
758
|
// src/editable-artifact-live/types.ts
|
|
742
|
-
|
|
759
|
+
import { EDITABLE_ARTIFACT_LIVE_WIRE_VERSION } from "@opengeni/contracts/editable-artifact-live";
|
|
760
|
+
var EDITABLE_ARTIFACT_LIVE_PROTOCOL_VERSION = EDITABLE_ARTIFACT_LIVE_WIRE_VERSION;
|
|
743
761
|
|
|
744
762
|
// src/editable-artifact-live/ticket.ts
|
|
745
763
|
var DEFAULT_TTL_MS = 3e4;
|
|
746
764
|
var MAX_TTL_MS = 6e4;
|
|
747
765
|
var MAX_TOKEN_BYTES = 4096;
|
|
766
|
+
var SOURCE_AUTHORITY_MARKER = ".ogs1.";
|
|
767
|
+
var COMPRESSED_SOURCE_AUTHORITY_MARKER = ".ogs2.";
|
|
768
|
+
var MAX_SOURCE_AUTHORITY_BYTES = 16 * 1024;
|
|
769
|
+
var SourceSessionAuthority = z.object({
|
|
770
|
+
sessionId: z.string().uuid(),
|
|
771
|
+
grant: AccessGrant,
|
|
772
|
+
externalContinuation: ExternalActorContinuation.optional()
|
|
773
|
+
}).strict();
|
|
748
774
|
var EditableArtifactLiveTicketAuthority = class {
|
|
749
775
|
constructor(dependencies) {
|
|
750
776
|
this.dependencies = dependencies;
|
|
@@ -752,10 +778,7 @@ var EditableArtifactLiveTicketAuthority = class {
|
|
|
752
778
|
if (!Number.isSafeInteger(this.ttlMs) || this.ttlMs < 1e3 || this.ttlMs > MAX_TTL_MS) {
|
|
753
779
|
throw new TypeError(`ticket ttl must be 1000-${MAX_TTL_MS} milliseconds`);
|
|
754
780
|
}
|
|
755
|
-
this.protocolVersion =
|
|
756
|
-
if (!Number.isSafeInteger(this.protocolVersion) || this.protocolVersion < 1) {
|
|
757
|
-
throw new TypeError("protocol version must be a positive safe integer");
|
|
758
|
-
}
|
|
781
|
+
this.protocolVersion = EDITABLE_ARTIFACT_LIVE_PROTOCOL_VERSION;
|
|
759
782
|
}
|
|
760
783
|
ttlMs;
|
|
761
784
|
protocolVersion;
|
|
@@ -780,7 +803,19 @@ var EditableArtifactLiveTicketAuthority = class {
|
|
|
780
803
|
"Editable artifact read permission denied"
|
|
781
804
|
);
|
|
782
805
|
}
|
|
783
|
-
const
|
|
806
|
+
const sourceSessionAuthority = input.sourceSessionAuthority ? SourceSessionAuthority.parse(input.sourceSessionAuthority) : void 0;
|
|
807
|
+
if (sourceSessionAuthority) {
|
|
808
|
+
assertSourceSessionAuthority(sourceSessionAuthority, scope, actor);
|
|
809
|
+
}
|
|
810
|
+
const sourceBytes = sourceSessionAuthority ? Buffer.from(JSON.stringify(sourceSessionAuthority)) : null;
|
|
811
|
+
if (sourceBytes && sourceBytes.byteLength > MAX_SOURCE_AUTHORITY_BYTES) {
|
|
812
|
+
throw new EditableArtifactLiveError(
|
|
813
|
+
"invalid_ticket",
|
|
814
|
+
"Live ticket source authority is too large"
|
|
815
|
+
);
|
|
816
|
+
}
|
|
817
|
+
const nonce = this.dependencies.tokens.randomOpaqueToken();
|
|
818
|
+
const token = sourceBytes ? `${nonce}${COMPRESSED_SOURCE_AUTHORITY_MARKER}${deflateRawSync(sourceBytes).toString("base64url")}` : nonce;
|
|
784
819
|
assertToken(token);
|
|
785
820
|
const tokenDigest = await this.dependencies.tokens.digestOpaqueToken(token);
|
|
786
821
|
assertDigest(tokenDigest);
|
|
@@ -823,6 +858,10 @@ var EditableArtifactLiveTicketAuthority = class {
|
|
|
823
858
|
);
|
|
824
859
|
}
|
|
825
860
|
validateTicketRecord(record);
|
|
861
|
+
const sourceSessionAuthority = decodeSourceSessionAuthority(input.token);
|
|
862
|
+
if (sourceSessionAuthority) {
|
|
863
|
+
assertSourceSessionAuthority(sourceSessionAuthority, record.scope, record.actor);
|
|
864
|
+
}
|
|
826
865
|
if (Date.parse(record.expiresAt) <= this.dependencies.clock.now().getTime()) {
|
|
827
866
|
throw new EditableArtifactLiveError("ticket_expired", "Live ticket has expired", {
|
|
828
867
|
retryable: true
|
|
@@ -840,7 +879,8 @@ var EditableArtifactLiveTicketAuthority = class {
|
|
|
840
879
|
return Object.freeze({
|
|
841
880
|
...record,
|
|
842
881
|
scope: editableArtifactScope(record.scope),
|
|
843
|
-
actor: Object.freeze({ ...record.actor })
|
|
882
|
+
actor: Object.freeze({ ...record.actor }),
|
|
883
|
+
...sourceSessionAuthority ? { sourceSessionAuthority } : {}
|
|
844
884
|
});
|
|
845
885
|
}
|
|
846
886
|
};
|
|
@@ -882,6 +922,34 @@ function validateTicketRecord(record) {
|
|
|
882
922
|
assertIsoTimestamp(record.issuedAt, "ticket issuedAt");
|
|
883
923
|
assertIsoTimestamp(record.expiresAt, "ticket expiresAt");
|
|
884
924
|
}
|
|
925
|
+
function decodeSourceSessionAuthority(token) {
|
|
926
|
+
const compressed = token.includes(COMPRESSED_SOURCE_AUTHORITY_MARKER);
|
|
927
|
+
const marker = compressed ? COMPRESSED_SOURCE_AUTHORITY_MARKER : SOURCE_AUTHORITY_MARKER;
|
|
928
|
+
const separator = token.lastIndexOf(marker);
|
|
929
|
+
if (separator === -1) return void 0;
|
|
930
|
+
try {
|
|
931
|
+
return SourceSessionAuthority.parse(
|
|
932
|
+
JSON.parse(
|
|
933
|
+
(compressed ? inflateRawSync(Buffer.from(token.slice(separator + marker.length), "base64url"), {
|
|
934
|
+
maxOutputLength: MAX_SOURCE_AUTHORITY_BYTES
|
|
935
|
+
}) : Buffer.from(token.slice(separator + marker.length), "base64url")).toString("utf8")
|
|
936
|
+
)
|
|
937
|
+
);
|
|
938
|
+
} catch {
|
|
939
|
+
throw new EditableArtifactLiveError(
|
|
940
|
+
"invalid_ticket",
|
|
941
|
+
"Live ticket source authority is invalid"
|
|
942
|
+
);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
function assertSourceSessionAuthority(authority, scope, actor) {
|
|
946
|
+
if (authority.grant.accountId !== scope.accountId || authority.grant.workspaceId !== scope.workspaceId || authority.grant.subjectId !== actor.subjectId) {
|
|
947
|
+
throw new EditableArtifactLiveError(
|
|
948
|
+
"invalid_ticket",
|
|
949
|
+
"Live ticket source scope does not match"
|
|
950
|
+
);
|
|
951
|
+
}
|
|
952
|
+
}
|
|
885
953
|
function assertModality(value) {
|
|
886
954
|
if (value !== "document" && value !== "spreadsheet" && value !== "presentation") {
|
|
887
955
|
throw new TypeError("ticket modality is invalid");
|
|
@@ -900,6 +968,7 @@ function assertDigest(value) {
|
|
|
900
968
|
|
|
901
969
|
// src/editable-artifact-live/server.ts
|
|
902
970
|
var textEncoder2 = new TextEncoder();
|
|
971
|
+
var SOURCE_SESSION_LIVE_LEASE_MS = 15e3;
|
|
903
972
|
var strictDecoder = new TextDecoder("utf-8", { fatal: true });
|
|
904
973
|
var DEFAULT_MAX_CLIENT_FRAME_BYTES = 5 * 1024 * 1024 + 64 * 1024;
|
|
905
974
|
var DEFAULT_MAX_OUTBOUND_FRAME_BYTES = 8 * 1024 * 1024 + 64 * 1024;
|
|
@@ -927,7 +996,6 @@ var EditableArtifactLiveServer = class {
|
|
|
927
996
|
tickets: dependencies.tickets,
|
|
928
997
|
tokens: dependencies.tokens,
|
|
929
998
|
clock: dependencies.clock,
|
|
930
|
-
protocolVersion: this.options.protocolVersion,
|
|
931
999
|
...this.options.ticketTtlMs === void 0 ? {} : { ttlMs: this.options.ticketTtlMs }
|
|
932
1000
|
});
|
|
933
1001
|
}
|
|
@@ -953,7 +1021,8 @@ var EditableArtifactLiveServer = class {
|
|
|
953
1021
|
streamEpoch,
|
|
954
1022
|
resume: input.resume,
|
|
955
1023
|
sink: input.sink,
|
|
956
|
-
...input.signal === void 0 ? {} : { parentSignal: input.signal }
|
|
1024
|
+
...input.signal === void 0 ? {} : { parentSignal: input.signal },
|
|
1025
|
+
...input.authorizeSourceSession ? { authorizeSourceSession: input.authorizeSourceSession } : {}
|
|
957
1026
|
});
|
|
958
1027
|
await session.start();
|
|
959
1028
|
return session;
|
|
@@ -967,6 +1036,8 @@ var EditableArtifactLiveSessionImpl = class {
|
|
|
967
1036
|
dependencies;
|
|
968
1037
|
options;
|
|
969
1038
|
ticket;
|
|
1039
|
+
authorizeSourceSession;
|
|
1040
|
+
sourceSessionLeaseExpiresAt;
|
|
970
1041
|
resume;
|
|
971
1042
|
sink;
|
|
972
1043
|
abort = new AbortController();
|
|
@@ -999,6 +1070,8 @@ var EditableArtifactLiveSessionImpl = class {
|
|
|
999
1070
|
this.dependencies = input.dependencies;
|
|
1000
1071
|
this.options = input.options;
|
|
1001
1072
|
this.ticket = input.ticket;
|
|
1073
|
+
this.authorizeSourceSession = input.authorizeSourceSession;
|
|
1074
|
+
this.sourceSessionLeaseExpiresAt = input.ticket.sourceSessionAuthority ? Date.parse(input.ticket.issuedAt) + SOURCE_SESSION_LIVE_LEASE_MS : null;
|
|
1002
1075
|
this.artifactId = input.ticket.artifactId;
|
|
1003
1076
|
this.modality = input.ticket.modality;
|
|
1004
1077
|
this.streamEpoch = input.streamEpoch;
|
|
@@ -1019,6 +1092,11 @@ var EditableArtifactLiveSessionImpl = class {
|
|
|
1019
1092
|
async start() {
|
|
1020
1093
|
try {
|
|
1021
1094
|
this.assertOpen();
|
|
1095
|
+
if (this.sourceSessionLeaseExpiresAt !== null) {
|
|
1096
|
+
void this.runSourceSessionLease().catch((error) => {
|
|
1097
|
+
if (!this.abort.signal.aborted) void this.fail(error);
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1022
1100
|
this.authorizationRevision = await this.requireRead();
|
|
1023
1101
|
this.assertOpen();
|
|
1024
1102
|
const releaseHints = await this.dependencies.hints.subscribe({
|
|
@@ -1057,8 +1135,7 @@ var EditableArtifactLiveSessionImpl = class {
|
|
|
1057
1135
|
const bootstrap = await this.dependencies.read.readBootstrap({
|
|
1058
1136
|
scope: this.ticket.scope,
|
|
1059
1137
|
artifactId: this.artifactId,
|
|
1060
|
-
resume: this.resume
|
|
1061
|
-
protocolVersion: this.options.protocolVersion
|
|
1138
|
+
resume: this.resume
|
|
1062
1139
|
});
|
|
1063
1140
|
this.assertOpen();
|
|
1064
1141
|
validateBootstrap(bootstrap, this.artifactId, this.modality, this.resume, this.options);
|
|
@@ -1243,6 +1320,7 @@ var EditableArtifactLiveSessionImpl = class {
|
|
|
1243
1320
|
this.resolveClosed(close);
|
|
1244
1321
|
}
|
|
1245
1322
|
assertOpen() {
|
|
1323
|
+
this.assertSourceSessionLease();
|
|
1246
1324
|
if (this.closedValue) {
|
|
1247
1325
|
throw new EditableArtifactLiveError("closed", "Live session is closed");
|
|
1248
1326
|
}
|
|
@@ -1397,7 +1475,13 @@ var EditableArtifactLiveSessionImpl = class {
|
|
|
1397
1475
|
bytes
|
|
1398
1476
|
};
|
|
1399
1477
|
await this.send(
|
|
1400
|
-
snapshot.modality === "spreadsheet" ? {
|
|
1478
|
+
snapshot.modality === "spreadsheet" ? {
|
|
1479
|
+
...common,
|
|
1480
|
+
modality: snapshot.modality,
|
|
1481
|
+
causalFrontier,
|
|
1482
|
+
operationProtocolVersion: snapshot.operationProtocolVersion,
|
|
1483
|
+
snapshotVersion: snapshot.snapshotVersion
|
|
1484
|
+
} : {
|
|
1401
1485
|
...common,
|
|
1402
1486
|
modality: snapshot.modality,
|
|
1403
1487
|
nativeRevision: snapshot.nativeRevision
|
|
@@ -1585,6 +1669,20 @@ var EditableArtifactLiveSessionImpl = class {
|
|
|
1585
1669
|
scope: this.ticket.scope,
|
|
1586
1670
|
artifactId: this.artifactId,
|
|
1587
1671
|
actor: this.ticket.actor,
|
|
1672
|
+
...this.ticket.sourceSessionAuthority ? {
|
|
1673
|
+
authorizeCommit: async (transaction2) => {
|
|
1674
|
+
this.assertOpen();
|
|
1675
|
+
if (!this.authorizeSourceSession || !await this.withBoundedAuthorization(
|
|
1676
|
+
(signal) => this.authorizeSourceSession(this.ticket, "edit", transaction2, signal)
|
|
1677
|
+
)) {
|
|
1678
|
+
throw new EditableArtifactLiveError(
|
|
1679
|
+
"permission_changed",
|
|
1680
|
+
"Editable artifact source session permission changed"
|
|
1681
|
+
);
|
|
1682
|
+
}
|
|
1683
|
+
this.assertOpen();
|
|
1684
|
+
}
|
|
1685
|
+
} : {},
|
|
1588
1686
|
request: {
|
|
1589
1687
|
intentBytes: frame.intentBytes.slice(),
|
|
1590
1688
|
requestHash: frame.requestHash
|
|
@@ -1675,17 +1773,66 @@ var EditableArtifactLiveSessionImpl = class {
|
|
|
1675
1773
|
return decision.revision;
|
|
1676
1774
|
}
|
|
1677
1775
|
async checkPermission(permission) {
|
|
1678
|
-
const decision = await this.
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1776
|
+
const decision = await this.withBoundedAuthorization(async (signal) => {
|
|
1777
|
+
if (this.ticket.sourceSessionAuthority) {
|
|
1778
|
+
if (!this.authorizeSourceSession || !await this.authorizeSourceSession(this.ticket, permission, void 0, signal)) {
|
|
1779
|
+
return Object.freeze({ allowed: false, revision: this.authorizationRevision });
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
signal.throwIfAborted();
|
|
1783
|
+
return await this.dependencies.authorization.authorize({
|
|
1784
|
+
scope: this.ticket.scope,
|
|
1785
|
+
artifactId: this.artifactId,
|
|
1786
|
+
actor: this.ticket.actor,
|
|
1787
|
+
permission
|
|
1788
|
+
});
|
|
1683
1789
|
});
|
|
1684
1790
|
if (permission === "edit" && !this.ticket.allowEdit) {
|
|
1685
1791
|
return Object.freeze({ ...decision, allowed: false });
|
|
1686
1792
|
}
|
|
1687
1793
|
return decision;
|
|
1688
1794
|
}
|
|
1795
|
+
async withBoundedAuthorization(operation) {
|
|
1796
|
+
this.assertSourceSessionLease();
|
|
1797
|
+
const timeout = new AbortController();
|
|
1798
|
+
const signal = AbortSignal.any([this.abort.signal, timeout.signal]);
|
|
1799
|
+
if (this.sourceSessionLeaseExpiresAt !== null) {
|
|
1800
|
+
const budget = this.sourceSessionLeaseExpiresAt - this.dependencies.clock.now().getTime();
|
|
1801
|
+
void this.dependencies.scheduler.sleep(budget, signal).then(
|
|
1802
|
+
() => timeout.abort(
|
|
1803
|
+
new EditableArtifactLiveError("ticket_expired", "Live authorization lease expired", {
|
|
1804
|
+
retryable: true
|
|
1805
|
+
})
|
|
1806
|
+
),
|
|
1807
|
+
() => void 0
|
|
1808
|
+
);
|
|
1809
|
+
}
|
|
1810
|
+
try {
|
|
1811
|
+
const result = await awaitLiveAuthorization(operation(signal), signal);
|
|
1812
|
+
this.assertOpen();
|
|
1813
|
+
return result;
|
|
1814
|
+
} finally {
|
|
1815
|
+
timeout.abort();
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
async runSourceSessionLease() {
|
|
1819
|
+
while (!this.abort.signal.aborted && this.sourceSessionLeaseExpiresAt !== null) {
|
|
1820
|
+
const remaining = this.sourceSessionLeaseExpiresAt - this.dependencies.clock.now().getTime();
|
|
1821
|
+
if (remaining <= 0) {
|
|
1822
|
+
await this.close("ticket_expired");
|
|
1823
|
+
return;
|
|
1824
|
+
}
|
|
1825
|
+
await this.dependencies.scheduler.sleep(remaining, this.abort.signal);
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
assertSourceSessionLease() {
|
|
1829
|
+
if (this.sourceSessionLeaseExpiresAt !== null && this.dependencies.clock.now().getTime() >= this.sourceSessionLeaseExpiresAt) {
|
|
1830
|
+
void this.close("ticket_expired");
|
|
1831
|
+
throw new EditableArtifactLiveError("ticket_expired", "Source session lease expired", {
|
|
1832
|
+
retryable: true
|
|
1833
|
+
});
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1689
1836
|
async sendBarrier() {
|
|
1690
1837
|
if (!this.sentStateHash)
|
|
1691
1838
|
throw new EditableArtifactLiveError("durable_gap", "Bootstrap has no state boundary");
|
|
@@ -1700,6 +1847,7 @@ var EditableArtifactLiveSessionImpl = class {
|
|
|
1700
1847
|
}
|
|
1701
1848
|
async send(frame) {
|
|
1702
1849
|
if (this.closedValue) return;
|
|
1850
|
+
this.assertSourceSessionLease();
|
|
1703
1851
|
const bytes = estimateFrameBytes(frame);
|
|
1704
1852
|
if (bytes > this.options.maxOutboundFrameBytes) {
|
|
1705
1853
|
throw new EditableArtifactLiveError(
|
|
@@ -1757,9 +1905,18 @@ var EditableArtifactLiveSessionImpl = class {
|
|
|
1757
1905
|
)
|
|
1758
1906
|
);
|
|
1759
1907
|
while (!this.abort.signal.aborted) {
|
|
1760
|
-
|
|
1908
|
+
const leaseRemaining = this.sourceSessionLeaseExpiresAt === null ? tick : this.sourceSessionLeaseExpiresAt - this.dependencies.clock.now().getTime();
|
|
1909
|
+
if (leaseRemaining <= 0) {
|
|
1910
|
+
await this.close("ticket_expired");
|
|
1911
|
+
return;
|
|
1912
|
+
}
|
|
1913
|
+
await this.dependencies.scheduler.sleep(Math.min(tick, leaseRemaining), this.abort.signal);
|
|
1761
1914
|
if (this.abort.signal.aborted || this.closedValue) return;
|
|
1762
1915
|
const now = this.dependencies.clock.now().getTime();
|
|
1916
|
+
if (this.sourceSessionLeaseExpiresAt !== null && now >= this.sourceSessionLeaseExpiresAt) {
|
|
1917
|
+
await this.close("ticket_expired");
|
|
1918
|
+
return;
|
|
1919
|
+
}
|
|
1763
1920
|
if (this.oldestInFlightAt !== 0 && now - this.oldestInFlightAt >= this.options.ackTimeoutMs) {
|
|
1764
1921
|
await this.enqueue(() => this.requireResync("slow_client", this.targetHead));
|
|
1765
1922
|
return;
|
|
@@ -1793,6 +1950,27 @@ var EditableArtifactLiveSessionImpl = class {
|
|
|
1793
1950
|
await this.close("transport_error");
|
|
1794
1951
|
}
|
|
1795
1952
|
};
|
|
1953
|
+
function awaitLiveAuthorization(operation, signal) {
|
|
1954
|
+
return new Promise((resolve, reject) => {
|
|
1955
|
+
const abort = () => {
|
|
1956
|
+
signal.removeEventListener("abort", abort);
|
|
1957
|
+
reject(signal.reason);
|
|
1958
|
+
};
|
|
1959
|
+
operation.then(
|
|
1960
|
+
(value) => {
|
|
1961
|
+
signal.removeEventListener("abort", abort);
|
|
1962
|
+
if (signal.aborted) reject(signal.reason);
|
|
1963
|
+
else resolve(value);
|
|
1964
|
+
},
|
|
1965
|
+
(error) => {
|
|
1966
|
+
signal.removeEventListener("abort", abort);
|
|
1967
|
+
reject(error);
|
|
1968
|
+
}
|
|
1969
|
+
);
|
|
1970
|
+
if (signal.aborted) abort();
|
|
1971
|
+
else signal.addEventListener("abort", abort, { once: true });
|
|
1972
|
+
});
|
|
1973
|
+
}
|
|
1796
1974
|
function decodeClientFrame(bytes, artifactId, streamEpoch, protocolVersion) {
|
|
1797
1975
|
let value;
|
|
1798
1976
|
try {
|
|
@@ -1871,7 +2049,7 @@ function validateAppliedFrame(frame, artifactId, streamEpoch, protocolVersion) {
|
|
|
1871
2049
|
});
|
|
1872
2050
|
}
|
|
1873
2051
|
function validateResume(resume, durableModality) {
|
|
1874
|
-
const resumeModality = resume.modality
|
|
2052
|
+
const resumeModality = resume.modality;
|
|
1875
2053
|
if (resumeModality !== durableModality) {
|
|
1876
2054
|
throw new EditableArtifactLiveError(
|
|
1877
2055
|
"invalid_frame",
|
|
@@ -2123,7 +2301,7 @@ function boundedString(value, label, maxBytes) {
|
|
|
2123
2301
|
}
|
|
2124
2302
|
function normalizeOptions2(options) {
|
|
2125
2303
|
const normalized = {
|
|
2126
|
-
protocolVersion:
|
|
2304
|
+
protocolVersion: EDITABLE_ARTIFACT_LIVE_PROTOCOL_VERSION,
|
|
2127
2305
|
maxClientFrameBytes: options.maxClientFrameBytes ?? DEFAULT_MAX_CLIENT_FRAME_BYTES,
|
|
2128
2306
|
maxOutboundFrameBytes: options.maxOutboundFrameBytes ?? DEFAULT_MAX_OUTBOUND_FRAME_BYTES,
|
|
2129
2307
|
maxSnapshotBytes: options.maxSnapshotBytes ?? DEFAULT_MAX_SNAPSHOT_BYTES,
|
|
@@ -2204,7 +2382,7 @@ var SystemEditableArtifactLiveScheduler = class {
|
|
|
2204
2382
|
|
|
2205
2383
|
// src/editable-artifact-live/wire.ts
|
|
2206
2384
|
import {
|
|
2207
|
-
EDITABLE_ARTIFACT_LIVE_WIRE_VERSION,
|
|
2385
|
+
EDITABLE_ARTIFACT_LIVE_WIRE_VERSION as EDITABLE_ARTIFACT_LIVE_WIRE_VERSION2,
|
|
2208
2386
|
decodeEditableArtifactLiveClientWireFrame as decodeContractClientFrame,
|
|
2209
2387
|
decodeEditableArtifactLiveServerWireFrame,
|
|
2210
2388
|
encodeEditableArtifactLiveAppliedWireFrame as encodeContractAppliedFrame,
|
|
@@ -2226,16 +2404,6 @@ function encodeEditableArtifactLiveMutationWireFrame(frame) {
|
|
|
2226
2404
|
return encodeContractMutationFrame(frame);
|
|
2227
2405
|
}
|
|
2228
2406
|
function encodeEditableArtifactLiveServerWireFrame(frame) {
|
|
2229
|
-
if (frame.type === "transaction" && frame.transaction.modality === "spreadsheet") {
|
|
2230
|
-
const { operationProtocolVersion, modality: _modality, ...transaction } = frame.transaction;
|
|
2231
|
-
return encodeContractServerFrame({
|
|
2232
|
-
...frame,
|
|
2233
|
-
transaction: {
|
|
2234
|
-
...transaction,
|
|
2235
|
-
protocolVersion: operationProtocolVersion
|
|
2236
|
-
}
|
|
2237
|
-
});
|
|
2238
|
-
}
|
|
2239
2407
|
return encodeContractServerFrame(frame);
|
|
2240
2408
|
}
|
|
2241
2409
|
|
|
@@ -2258,7 +2426,7 @@ export {
|
|
|
2258
2426
|
EditableArtifactLiveServer,
|
|
2259
2427
|
SystemEditableArtifactLiveClock,
|
|
2260
2428
|
SystemEditableArtifactLiveScheduler,
|
|
2261
|
-
EDITABLE_ARTIFACT_LIVE_WIRE_VERSION,
|
|
2429
|
+
EDITABLE_ARTIFACT_LIVE_WIRE_VERSION2 as EDITABLE_ARTIFACT_LIVE_WIRE_VERSION,
|
|
2262
2430
|
decodeEditableArtifactLiveServerWireFrame,
|
|
2263
2431
|
inspectEditableArtifactLiveWireEnvelope,
|
|
2264
2432
|
decodeEditableArtifactLiveClientWireFrame,
|
|
@@ -2267,4 +2435,4 @@ export {
|
|
|
2267
2435
|
encodeEditableArtifactLiveMutationWireFrame,
|
|
2268
2436
|
encodeEditableArtifactLiveServerWireFrame
|
|
2269
2437
|
};
|
|
2270
|
-
//# sourceMappingURL=chunk-
|
|
2438
|
+
//# sourceMappingURL=chunk-GVO3N37G.js.map
|