@opengeni/core 3.0.1 → 3.1.2
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 +4 -4
- package/dist/access/index.d.ts +131 -7
- package/dist/access/service-initiator.d.ts +3 -0
- package/dist/application/archived-session-imports.d.ts +6 -0
- package/dist/application/composer-submit.d.ts +1 -1
- package/dist/application/connect-operation.d.ts +6 -0
- package/dist/application/external-workspace-members.d.ts +13 -1
- package/dist/application/modal-native-live-declaration-join.d.ts +37 -0
- package/dist/application/modal-native-original-configuration.d.ts +79 -0
- package/dist/application/modal-native-worker-host-transport.d.ts +297 -0
- package/dist/application/new-session-drafts.d.ts +29 -2
- package/dist/application/organization-privacy.d.ts +57 -0
- package/dist/application/prepared-mcp-connection.d.ts +31 -0
- package/dist/application/sandbox-recovery.d.ts +58 -0
- package/dist/application/session-commands.d.ts +3 -0
- package/dist/application/session-tenancy.d.ts +13 -4
- package/dist/billing/agent-run-admission.d.ts +21 -0
- package/dist/billing/limits.d.ts +27 -1
- package/dist/billing/model-call-admission.d.ts +34 -0
- package/dist/billing/model-usage-settlement.d.ts +112 -0
- package/dist/canonical-human-identities.js +1 -1
- package/dist/{chunk-VCZFFEPB.js → chunk-7T2SZ7BI.js} +16 -2
- package/dist/chunk-7T2SZ7BI.js.map +1 -0
- package/dist/{chunk-ZYCNLYGH.js → chunk-OMJFIIWK.js} +178 -12
- package/dist/chunk-OMJFIIWK.js.map +1 -0
- package/dist/{chunk-H7X52RI2.js → chunk-QI2M2B2K.js} +83 -8
- package/dist/chunk-QI2M2B2K.js.map +1 -0
- package/dist/{chunk-OF65T3PM.js → chunk-TTWTXQB2.js} +94 -6
- package/dist/chunk-TTWTXQB2.js.map +1 -0
- package/dist/codex-model-availability.d.ts +55 -0
- package/dist/default-session-model.d.ts +192 -0
- package/dist/dependencies.d.ts +41 -7
- 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 +8 -1
- package/dist/domain/capabilities.d.ts +112 -8
- package/dist/domain/connection-account-selection-error.d.ts +8 -0
- package/dist/domain/connector-tool-permissions.d.ts +62 -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 +3 -1
- package/dist/domain/editable-artifacts/types.d.ts +1 -1
- package/dist/domain/encryption-key.d.ts +12 -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 +21 -3
- package/dist/domain/knowledge-files.d.ts +1 -1
- 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 -76
- package/dist/domain/mcp-account-bindings.d.ts +17 -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/personal-connection-delegations.d.ts +73 -12
- package/dist/domain/pr-review.d.ts +121 -6
- package/dist/domain/realtime-voice-billing.d.ts +103 -0
- package/dist/domain/resources.d.ts +17 -1
- package/dist/domain/scheduled-task-access.d.ts +265 -0
- package/dist/domain/scheduled-task-account-audit.d.ts +27 -0
- package/dist/domain/scheduled-task-audience.d.ts +70 -0
- package/dist/domain/scheduled-tasks.d.ts +61 -18
- package/dist/domain/session-connection-accounts.d.ts +53 -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 +102 -4
- package/dist/domain/sessions.d.ts +179 -15
- package/dist/domain/site-audience.d.ts +52 -0
- package/dist/domain/skills.d.ts +29 -1
- package/dist/domain/slack-bot.d.ts +46 -1
- package/dist/domain/slack-publication-secret-safety.d.ts +1 -1
- package/dist/domain/vaults/index.d.ts +7 -0
- package/dist/domain/vaults/mapping.d.ts +25 -0
- package/dist/domain/vaults/provider-registry.d.ts +72 -0
- package/dist/domain/vaults/provider-sync.d.ts +176 -0
- package/dist/domain/vaults/provider-writes.d.ts +57 -0
- package/dist/domain/vaults/secret-resolver.d.ts +34 -0
- package/dist/domain/vaults/types.d.ts +24 -0
- package/dist/domain/vaults/vault-service.d.ts +35 -0
- package/dist/domain/voice-input-billing.d.ts +77 -0
- package/dist/domain/web-search-billing.d.ts +51 -0
- package/dist/domain/workspace-credits.d.ts +7 -0
- package/dist/editable-artifact-live/application.d.ts +2 -1
- package/dist/editable-artifact-live/server.d.ts +5 -1
- package/dist/editable-artifact-live/ticket.d.ts +2 -1
- package/dist/editable-artifact-live/types.d.ts +9 -0
- package/dist/editable-artifact-live.js +2 -2
- package/dist/editable-artifacts.js +10 -2
- package/dist/goal-admission.d.ts +627 -0
- package/dist/host-session-usage-limit.d.ts +15 -0
- package/dist/index.d.ts +43 -8
- package/dist/index.js +22682 -11743
- package/dist/index.js.map +1 -1
- package/dist/managed-session.d.ts +110 -7
- package/dist/model-call.d.ts +58 -0
- package/dist/model-catalog.d.ts +29 -3
- package/dist/model-provider-credentials.d.ts +43 -0
- package/dist/product-usage-metrics.d.ts +30 -0
- package/dist/rigs/index.d.ts +1 -13
- package/dist/sandbox/fleet.d.ts +58 -4
- package/dist/sandbox/routing.d.ts +42 -2
- package/dist/sandbox/runtime-settings.d.ts +27 -17
- package/dist/session-authorization.d.ts +10 -0
- package/dist/session-usage-limit-metrics.d.ts +60 -0
- package/dist/session-usage-limits.d.ts +89 -0
- package/dist/site-agent-clamp.d.ts +71 -0
- package/dist/site-session-origin.d.ts +39 -2
- package/dist/transcription.d.ts +120 -3
- package/dist/turn-surface.d.ts +20 -0
- package/dist/user-presence.d.ts +32 -0
- package/dist/workflow-wake-contract.d.ts +13 -1
- package/package.json +15 -22
- package/src/access/index.ts +961 -38
- package/src/access/service-initiator.ts +50 -0
- package/src/application/api-integration-servers.ts +9 -0
- package/src/application/archived-session-imports.ts +161 -0
- package/src/application/composer-submit.ts +3 -2
- package/src/application/connect-authority.ts +3 -3
- package/src/application/connect-operation.ts +37 -3
- package/src/application/external-continuation.ts +20 -3
- package/src/application/external-link-work-admission.ts +3 -0
- package/src/application/external-workspace-members.ts +51 -3
- package/src/application/modal-native-live-declaration-join.ts +196 -0
- package/src/application/modal-native-original-configuration.ts +261 -0
- package/src/application/modal-native-worker-host-transport.ts +263 -0
- package/src/application/new-session-drafts.ts +172 -55
- package/src/application/organization-privacy.ts +161 -0
- package/src/application/prepared-mcp-connection.ts +133 -0
- package/src/application/sandbox-recovery.ts +78 -0
- package/src/application/session-commands.ts +73 -1
- package/src/application/session-mcp-credential-rotation.ts +61 -18
- package/src/application/session-tenancy.ts +262 -44
- package/src/application/user-resource-grants.ts +1 -29
- package/src/billing/agent-run-admission.ts +117 -0
- package/src/billing/limits.ts +138 -14
- package/src/billing/model-call-admission.ts +118 -0
- package/src/billing/model-usage-settlement.ts +472 -0
- package/src/codex-model-availability.ts +264 -0
- package/src/default-session-model.ts +692 -0
- package/src/dependencies.ts +48 -6
- package/src/developer-setup-credential-ceiling.ts +60 -0
- package/src/domain/agent-config-resolution.ts +148 -0
- package/src/domain/automations.ts +76 -2
- package/src/domain/capabilities.ts +830 -181
- package/src/domain/connection-account-selection-error.ts +19 -0
- package/src/domain/connector-tool-permissions.ts +572 -0
- package/src/domain/direct-model-provider.ts +62 -0
- package/src/domain/editable-artifacts/agent-application.ts +44 -6
- 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 +20 -0
- package/src/domain/editable-artifacts/types.ts +1 -1
- package/src/domain/encryption-key.ts +26 -0
- package/src/domain/file-owner.ts +16 -1
- package/src/domain/github-action-policies.ts +1 -1
- package/src/domain/github-skill-source.ts +3 -1
- package/src/domain/insights-timing.ts +95 -0
- package/src/domain/insights-usage.ts +67 -0
- package/src/domain/insights.ts +167 -43
- package/src/domain/knowledge-files.ts +10 -3
- package/src/domain/knowledge-messages.ts +1 -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 +617 -5
- package/src/domain/knowledge-search.ts +240 -23
- package/src/domain/mcp-account-bindings.ts +169 -0
- package/src/domain/mcp-account-routes.ts +152 -0
- package/src/domain/native-mcp-connection-admission.ts +14 -0
- package/src/domain/organization-integration-catalog.ts +88 -0
- package/src/domain/personal-connection-delegations.ts +399 -257
- package/src/domain/pr-review.ts +24 -8
- package/src/domain/realtime-voice-billing.ts +425 -0
- package/src/domain/resources.ts +50 -4
- package/src/domain/scheduled-task-access.ts +1089 -0
- package/src/domain/scheduled-task-account-audit.ts +90 -0
- package/src/domain/scheduled-task-audience.ts +249 -0
- package/src/domain/scheduled-tasks.ts +1313 -374
- package/src/domain/session-connection-accounts.ts +239 -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 +60 -0
- package/src/domain/session-tool-policy.ts +489 -14
- package/src/domain/sessions.ts +2254 -717
- package/src/domain/site-audience.ts +130 -0
- package/src/domain/skills.ts +9 -0
- package/src/domain/slack-bot.ts +141 -4
- package/src/domain/slack-publication-secret-safety.ts +1 -1
- package/src/domain/vaults/index.ts +19 -0
- package/src/domain/vaults/mapping.ts +190 -0
- package/src/domain/vaults/provider-registry.ts +201 -0
- package/src/domain/vaults/provider-sync.ts +531 -0
- package/src/domain/vaults/provider-writes.ts +288 -0
- package/src/domain/vaults/secret-resolver.ts +464 -0
- package/src/domain/vaults/types.ts +26 -0
- package/src/domain/vaults/vault-service.ts +1316 -0
- package/src/domain/voice-input-billing.ts +330 -0
- package/src/domain/web-search-billing.ts +169 -0
- package/src/domain/workspace-credits.ts +13 -0
- package/src/editable-artifact-live/application.ts +8 -1
- package/src/editable-artifact-live/server.ts +154 -6
- package/src/editable-artifact-live/ticket.ts +86 -1
- package/src/editable-artifact-live/types.ts +10 -0
- package/src/goal-admission.ts +220 -0
- package/src/host-session-usage-limit.ts +25 -0
- package/src/index.ts +75 -11
- package/src/managed-session.ts +137 -6
- package/src/model-call.ts +79 -0
- package/src/model-catalog.ts +345 -91
- package/src/model-provider-credentials.ts +394 -0
- package/src/product-usage-metrics.ts +101 -0
- package/src/rigs/index.ts +23 -111
- package/src/sandbox/fleet.ts +253 -28
- package/src/sandbox/routing.ts +204 -43
- package/src/sandbox/runtime-settings.ts +159 -85
- package/src/session-authorization.ts +172 -23
- package/src/session-usage-limit-metrics.ts +95 -0
- package/src/session-usage-limits.ts +415 -0
- package/src/site-agent-clamp.ts +226 -0
- package/src/site-session-origin.ts +84 -5
- package/src/transcription.ts +123 -4
- package/src/turn-surface.ts +47 -0
- package/src/user-presence.ts +134 -0
- package/src/workflow-wake-contract.ts +14 -1
- package/dist/application/host-mcp-owner.d.ts +0 -6
- package/dist/application/host-mcp-resolvers.d.ts +0 -13
- package/dist/chunk-5WZYFL45.js +0 -266
- package/dist/chunk-5WZYFL45.js.map +0 -1
- package/dist/chunk-H7X52RI2.js.map +0 -1
- package/dist/chunk-OF65T3PM.js.map +0 -1
- package/dist/chunk-VCZFFEPB.js.map +0 -1
- package/dist/chunk-ZYCNLYGH.js.map +0 -1
- package/dist/domain/connection-authority.d.ts +0 -97
- package/dist/domain/connection-authority.js +0 -169
- package/dist/domain/connection-authority.js.map +0 -1
- package/dist/domain/environments.d.ts +0 -33
- package/dist/domain/host-mcp-authority-source-admission.d.ts +0 -10
- package/dist/domain/host-mcp-task-admission.d.ts +0 -18
- package/dist/domain/packs.d.ts +0 -59
- package/dist/domain/product-integration-pack.d.ts +0 -44
- package/dist/domain/product-integration-skill.gen.d.ts +0 -5
- package/dist/remote-mcp-credentials.d.ts +0 -23
- package/dist/remote-mcp-credentials.js +0 -11
- package/dist/remote-mcp-credentials.js.map +0 -1
- package/src/application/host-mcp-owner.ts +0 -41
- package/src/application/host-mcp-resolvers.ts +0 -84
- package/src/domain/connection-authority.ts +0 -329
- package/src/domain/environments.ts +0 -120
- package/src/domain/host-mcp-authority-source-admission.ts +0 -25
- package/src/domain/host-mcp-task-admission.ts +0 -121
- package/src/domain/packs.ts +0 -699
- package/src/domain/product-integration-pack.ts +0 -42
- package/src/domain/product-integration-skill.gen.ts +0 -52
- package/src/remote-mcp-credentials.ts +0 -361
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
editableArtifactStateHash,
|
|
15
15
|
editableArtifactTransactionId,
|
|
16
16
|
validateEditableArtifactActor
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-7T2SZ7BI.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";
|
|
@@ -94,7 +94,8 @@ var EditableArtifactApplication = class {
|
|
|
94
94
|
artifactId: artifact.id,
|
|
95
95
|
modality: artifact.modality,
|
|
96
96
|
actor: input.actor,
|
|
97
|
-
allowEdit: input.allowEdit
|
|
97
|
+
allowEdit: input.allowEdit,
|
|
98
|
+
...input.sourceSessionAuthority ? { sourceSessionAuthority: input.sourceSessionAuthority } : {}
|
|
98
99
|
});
|
|
99
100
|
}
|
|
100
101
|
openLive(input) {
|
|
@@ -748,6 +749,12 @@ import {
|
|
|
748
749
|
import { decodeCommittedTransactionSummary } from "@opengeni/contracts/editable-artifact-committed-transaction";
|
|
749
750
|
import { decodeEditableArtifactSerializedCommit } from "@opengeni/contracts/editable-artifact-serialized-commit";
|
|
750
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
|
+
|
|
751
758
|
// src/editable-artifact-live/types.ts
|
|
752
759
|
import { EDITABLE_ARTIFACT_LIVE_WIRE_VERSION } from "@opengeni/contracts/editable-artifact-live";
|
|
753
760
|
var EDITABLE_ARTIFACT_LIVE_PROTOCOL_VERSION = EDITABLE_ARTIFACT_LIVE_WIRE_VERSION;
|
|
@@ -756,6 +763,14 @@ var EDITABLE_ARTIFACT_LIVE_PROTOCOL_VERSION = EDITABLE_ARTIFACT_LIVE_WIRE_VERSIO
|
|
|
756
763
|
var DEFAULT_TTL_MS = 3e4;
|
|
757
764
|
var MAX_TTL_MS = 6e4;
|
|
758
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();
|
|
759
774
|
var EditableArtifactLiveTicketAuthority = class {
|
|
760
775
|
constructor(dependencies) {
|
|
761
776
|
this.dependencies = dependencies;
|
|
@@ -788,7 +803,19 @@ var EditableArtifactLiveTicketAuthority = class {
|
|
|
788
803
|
"Editable artifact read permission denied"
|
|
789
804
|
);
|
|
790
805
|
}
|
|
791
|
-
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;
|
|
792
819
|
assertToken(token);
|
|
793
820
|
const tokenDigest = await this.dependencies.tokens.digestOpaqueToken(token);
|
|
794
821
|
assertDigest(tokenDigest);
|
|
@@ -831,6 +858,10 @@ var EditableArtifactLiveTicketAuthority = class {
|
|
|
831
858
|
);
|
|
832
859
|
}
|
|
833
860
|
validateTicketRecord(record);
|
|
861
|
+
const sourceSessionAuthority = decodeSourceSessionAuthority(input.token);
|
|
862
|
+
if (sourceSessionAuthority) {
|
|
863
|
+
assertSourceSessionAuthority(sourceSessionAuthority, record.scope, record.actor);
|
|
864
|
+
}
|
|
834
865
|
if (Date.parse(record.expiresAt) <= this.dependencies.clock.now().getTime()) {
|
|
835
866
|
throw new EditableArtifactLiveError("ticket_expired", "Live ticket has expired", {
|
|
836
867
|
retryable: true
|
|
@@ -848,7 +879,8 @@ var EditableArtifactLiveTicketAuthority = class {
|
|
|
848
879
|
return Object.freeze({
|
|
849
880
|
...record,
|
|
850
881
|
scope: editableArtifactScope(record.scope),
|
|
851
|
-
actor: Object.freeze({ ...record.actor })
|
|
882
|
+
actor: Object.freeze({ ...record.actor }),
|
|
883
|
+
...sourceSessionAuthority ? { sourceSessionAuthority } : {}
|
|
852
884
|
});
|
|
853
885
|
}
|
|
854
886
|
};
|
|
@@ -890,6 +922,34 @@ function validateTicketRecord(record) {
|
|
|
890
922
|
assertIsoTimestamp(record.issuedAt, "ticket issuedAt");
|
|
891
923
|
assertIsoTimestamp(record.expiresAt, "ticket expiresAt");
|
|
892
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
|
+
}
|
|
893
953
|
function assertModality(value) {
|
|
894
954
|
if (value !== "document" && value !== "spreadsheet" && value !== "presentation") {
|
|
895
955
|
throw new TypeError("ticket modality is invalid");
|
|
@@ -908,6 +968,7 @@ function assertDigest(value) {
|
|
|
908
968
|
|
|
909
969
|
// src/editable-artifact-live/server.ts
|
|
910
970
|
var textEncoder2 = new TextEncoder();
|
|
971
|
+
var SOURCE_SESSION_LIVE_LEASE_MS = 15e3;
|
|
911
972
|
var strictDecoder = new TextDecoder("utf-8", { fatal: true });
|
|
912
973
|
var DEFAULT_MAX_CLIENT_FRAME_BYTES = 5 * 1024 * 1024 + 64 * 1024;
|
|
913
974
|
var DEFAULT_MAX_OUTBOUND_FRAME_BYTES = 8 * 1024 * 1024 + 64 * 1024;
|
|
@@ -960,7 +1021,8 @@ var EditableArtifactLiveServer = class {
|
|
|
960
1021
|
streamEpoch,
|
|
961
1022
|
resume: input.resume,
|
|
962
1023
|
sink: input.sink,
|
|
963
|
-
...input.signal === void 0 ? {} : { parentSignal: input.signal }
|
|
1024
|
+
...input.signal === void 0 ? {} : { parentSignal: input.signal },
|
|
1025
|
+
...input.authorizeSourceSession ? { authorizeSourceSession: input.authorizeSourceSession } : {}
|
|
964
1026
|
});
|
|
965
1027
|
await session.start();
|
|
966
1028
|
return session;
|
|
@@ -974,6 +1036,8 @@ var EditableArtifactLiveSessionImpl = class {
|
|
|
974
1036
|
dependencies;
|
|
975
1037
|
options;
|
|
976
1038
|
ticket;
|
|
1039
|
+
authorizeSourceSession;
|
|
1040
|
+
sourceSessionLeaseExpiresAt;
|
|
977
1041
|
resume;
|
|
978
1042
|
sink;
|
|
979
1043
|
abort = new AbortController();
|
|
@@ -1006,6 +1070,8 @@ var EditableArtifactLiveSessionImpl = class {
|
|
|
1006
1070
|
this.dependencies = input.dependencies;
|
|
1007
1071
|
this.options = input.options;
|
|
1008
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;
|
|
1009
1075
|
this.artifactId = input.ticket.artifactId;
|
|
1010
1076
|
this.modality = input.ticket.modality;
|
|
1011
1077
|
this.streamEpoch = input.streamEpoch;
|
|
@@ -1026,6 +1092,11 @@ var EditableArtifactLiveSessionImpl = class {
|
|
|
1026
1092
|
async start() {
|
|
1027
1093
|
try {
|
|
1028
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
|
+
}
|
|
1029
1100
|
this.authorizationRevision = await this.requireRead();
|
|
1030
1101
|
this.assertOpen();
|
|
1031
1102
|
const releaseHints = await this.dependencies.hints.subscribe({
|
|
@@ -1249,6 +1320,7 @@ var EditableArtifactLiveSessionImpl = class {
|
|
|
1249
1320
|
this.resolveClosed(close);
|
|
1250
1321
|
}
|
|
1251
1322
|
assertOpen() {
|
|
1323
|
+
this.assertSourceSessionLease();
|
|
1252
1324
|
if (this.closedValue) {
|
|
1253
1325
|
throw new EditableArtifactLiveError("closed", "Live session is closed");
|
|
1254
1326
|
}
|
|
@@ -1597,6 +1669,20 @@ var EditableArtifactLiveSessionImpl = class {
|
|
|
1597
1669
|
scope: this.ticket.scope,
|
|
1598
1670
|
artifactId: this.artifactId,
|
|
1599
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
|
+
} : {},
|
|
1600
1686
|
request: {
|
|
1601
1687
|
intentBytes: frame.intentBytes.slice(),
|
|
1602
1688
|
requestHash: frame.requestHash
|
|
@@ -1687,17 +1773,66 @@ var EditableArtifactLiveSessionImpl = class {
|
|
|
1687
1773
|
return decision.revision;
|
|
1688
1774
|
}
|
|
1689
1775
|
async checkPermission(permission) {
|
|
1690
|
-
const decision = await this.
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
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
|
+
});
|
|
1695
1789
|
});
|
|
1696
1790
|
if (permission === "edit" && !this.ticket.allowEdit) {
|
|
1697
1791
|
return Object.freeze({ ...decision, allowed: false });
|
|
1698
1792
|
}
|
|
1699
1793
|
return decision;
|
|
1700
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
|
+
}
|
|
1701
1836
|
async sendBarrier() {
|
|
1702
1837
|
if (!this.sentStateHash)
|
|
1703
1838
|
throw new EditableArtifactLiveError("durable_gap", "Bootstrap has no state boundary");
|
|
@@ -1712,6 +1847,7 @@ var EditableArtifactLiveSessionImpl = class {
|
|
|
1712
1847
|
}
|
|
1713
1848
|
async send(frame) {
|
|
1714
1849
|
if (this.closedValue) return;
|
|
1850
|
+
this.assertSourceSessionLease();
|
|
1715
1851
|
const bytes = estimateFrameBytes(frame);
|
|
1716
1852
|
if (bytes > this.options.maxOutboundFrameBytes) {
|
|
1717
1853
|
throw new EditableArtifactLiveError(
|
|
@@ -1769,9 +1905,18 @@ var EditableArtifactLiveSessionImpl = class {
|
|
|
1769
1905
|
)
|
|
1770
1906
|
);
|
|
1771
1907
|
while (!this.abort.signal.aborted) {
|
|
1772
|
-
|
|
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);
|
|
1773
1914
|
if (this.abort.signal.aborted || this.closedValue) return;
|
|
1774
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
|
+
}
|
|
1775
1920
|
if (this.oldestInFlightAt !== 0 && now - this.oldestInFlightAt >= this.options.ackTimeoutMs) {
|
|
1776
1921
|
await this.enqueue(() => this.requireResync("slow_client", this.targetHead));
|
|
1777
1922
|
return;
|
|
@@ -1805,6 +1950,27 @@ var EditableArtifactLiveSessionImpl = class {
|
|
|
1805
1950
|
await this.close("transport_error");
|
|
1806
1951
|
}
|
|
1807
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
|
+
}
|
|
1808
1974
|
function decodeClientFrame(bytes, artifactId, streamEpoch, protocolVersion) {
|
|
1809
1975
|
let value;
|
|
1810
1976
|
try {
|
|
@@ -2269,4 +2435,4 @@ export {
|
|
|
2269
2435
|
encodeEditableArtifactLiveMutationWireFrame,
|
|
2270
2436
|
encodeEditableArtifactLiveServerWireFrame
|
|
2271
2437
|
};
|
|
2272
|
-
//# sourceMappingURL=chunk-
|
|
2438
|
+
//# sourceMappingURL=chunk-OMJFIIWK.js.map
|