@opengeni/db 0.28.1 → 0.31.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/attached-browser-devices.d.ts +42 -0
- package/dist/attempt-tool-catalogs.d.ts +16 -0
- package/dist/browser-auth.d.ts +91 -0
- package/dist/browser-identities.d.ts +128 -0
- package/dist/browser-sessions.d.ts +272 -0
- package/dist/browser-state-artifacts.d.ts +17 -0
- package/dist/capability-components.d.ts +37 -0
- package/dist/capability-integrations.d.ts +192 -0
- package/dist/chunk-F5FT7BEZ.js +3535 -0
- package/dist/chunk-F5FT7BEZ.js.map +1 -0
- package/dist/chunk-ISI2TIUG.js +639 -0
- package/dist/chunk-ISI2TIUG.js.map +1 -0
- package/dist/chunk-MWDVXQOL.js +11639 -0
- package/dist/chunk-MWDVXQOL.js.map +1 -0
- package/dist/chunk-NBE6CHRI.js +955 -0
- package/dist/chunk-NBE6CHRI.js.map +1 -0
- package/dist/{chunk-DBS5HPEW.js → chunk-YHZXQ7HP.js} +760 -11
- package/dist/chunk-YHZXQ7HP.js.map +1 -0
- package/dist/codemode-operations.d.ts +117 -0
- package/dist/codex-token-resolver.d.ts +2 -2
- package/dist/company-profile-schema.d.ts +798 -0
- package/dist/company-profile.d.ts +268 -0
- package/dist/computer-sessions.d.ts +109 -0
- package/dist/connection-token-resolver.d.ts +9 -4
- package/dist/database.d.ts +52 -3
- package/dist/editable-artifact-durable-export.d.ts +153 -0
- package/dist/editable-artifact-durable-export.js +788 -0
- package/dist/editable-artifact-durable-export.js.map +1 -0
- package/dist/editable-artifact-materialization.d.ts +123 -0
- package/dist/editable-artifacts-schema.d.ts +4152 -0
- package/dist/editable-artifacts.d.ts +610 -0
- package/dist/editable-artifacts.js +26 -0
- package/dist/editable-artifacts.js.map +1 -0
- package/dist/environment-crypto.d.ts +8 -4
- package/dist/generated-images.d.ts +139 -0
- package/dist/index.d.ts +958 -126
- package/dist/index.js +31204 -12172
- package/dist/index.js.map +1 -1
- package/dist/insights.d.ts +51 -4
- package/dist/integration-bindings.d.ts +70 -0
- package/dist/integration-features.d.ts +99 -0
- package/dist/interaction-revisions.d.ts +3 -0
- package/dist/interaction-schema.d.ts +5372 -0
- package/dist/knowledge-source-sync-schema.d.ts +1679 -0
- package/dist/knowledge-source-sync.d.ts +274 -0
- package/dist/lossless-columns.d.ts +58 -0
- package/dist/lossless-json.d.ts +39 -0
- package/dist/memory-domain.d.ts +3 -6
- package/dist/memory-governance.d.ts +2 -2
- package/dist/memory-slack-delivery.d.ts +101 -0
- package/dist/new-session-drafts.d.ts +2 -2
- package/dist/pack-components.d.ts +76 -0
- package/dist/pack-installations.d.ts +86 -0
- package/dist/persistence-errors.d.ts +7 -14
- package/dist/plugin-packages.d.ts +126 -0
- package/dist/preference-registry.d.ts +1 -1
- package/dist/provision-roles.d.ts +9 -1
- package/dist/provision-roles.js +1 -1
- package/dist/runtime-posture.d.ts +18 -6
- package/dist/schema.d.ts +19122 -8731
- package/dist/schema.js +173 -1
- package/dist/scoped-knowledge.d.ts +97 -1
- package/dist/session-control.d.ts +4 -4
- package/dist/session-queue-commands.d.ts +19 -11
- package/dist/session-realtime-context.d.ts +2 -2
- package/dist/session-realtime-ledger.d.ts +4 -4
- package/dist/session-realtime-mirror.d.ts +2 -2
- package/dist/session-realtime-state.d.ts +1 -1
- package/dist/session-realtime-terminal.d.ts +8 -1
- package/dist/session-realtime.d.ts +7 -7
- package/dist/session-tool-call-settlement.d.ts +1 -1
- package/dist/slack-user-link-access.d.ts +54 -0
- package/dist/transcription-recordings-schema.d.ts +44 -6
- package/dist/transcription-recordings.d.ts +3 -3
- package/dist/turn-initiator.d.ts +2 -2
- package/dist/video-generation.d.ts +216 -0
- package/dist/video-generation.js +66 -0
- package/dist/video-generation.js.map +1 -0
- package/dist/workspace-artifacts.d.ts +1 -1
- package/dist/workspace-instruction-policies.d.ts +1 -1
- package/dist/workspace-learning-policy-schema.d.ts +932 -0
- package/dist/workspace-learning-policy.d.ts +161 -0
- package/drizzle/0065_enrollment_credential_generation.sql +10 -0
- package/drizzle/0140_retained_screenshot_artifacts.sql +192 -0
- package/drizzle/0176_lossless_canonical_json.sql +975 -0
- package/drizzle/0177_session_events_workspace_turn_type_index.sql +5 -0
- package/drizzle/0178_permissioned_secret_reads.sql +14 -0
- package/drizzle/0179_slack_private_shortcut_delivery_gate.sql +85 -0
- package/drizzle/0180_retained_screenshot_lifecycle_fences.sql +273 -0
- package/drizzle/0181_connected_machine_removal.sql +52 -0
- package/drizzle/0182_connected_machine_remove_session_default.sql +77 -0
- package/drizzle/0183_model_call_provider_cost_estimates.sql +39 -0
- package/drizzle/0184_sandbox_drain_teardown_fence.sql +682 -0
- package/drizzle/0185_temporal_schedule_cleanup_outbox.sql +168 -0
- package/drizzle/0186_sandbox_capture_provider_contract.sql +400 -0
- package/drizzle/0187_generated_image_artifacts.sql +173 -0
- package/drizzle/0188_image_generation_retention_failure.sql +25 -0
- package/drizzle/0189_retained_session_image_formats.sql +13 -0
- package/drizzle/0190_timeline_annotations.sql +31 -0
- package/drizzle/0191_editable_artifact_engine.sql +3853 -0
- package/drizzle/0192_editable_artifact_live_tickets.sql +338 -0
- package/drizzle/0193_editable_artifact_authorization.sql +190 -0
- package/drizzle/0194_editable_artifact_durable_exports.sql +160 -0
- package/drizzle/0195_editable_artifact_import_authorization.sql +203 -0
- package/drizzle/0196_rig_provider_images.sql +152 -0
- package/drizzle/0197_knowledge_source_sync_schedules.sql +523 -0
- package/drizzle/0198_memory_slack_publication_delivery.sql +393 -0
- package/drizzle/0199_workspace_learning_policy.sql +980 -0
- package/drizzle/0201_company_profile_authority.sql +849 -0
- package/drizzle/0202_document_index_checkpoints.sql +85 -0
- package/drizzle/0203_durable_video_generation.sql +353 -0
- package/drizzle/0204_video_generation_funding.sql +44 -0
- package/drizzle/0205_attempt_tool_catalogs.sql +230 -0
- package/drizzle/0206_browser_sessions.sql +646 -0
- package/drizzle/0207_browser_identities.sql +379 -0
- package/drizzle/0208_attached_browser_devices.sql +165 -0
- package/drizzle/0209_computer_sessions.sql +575 -0
- package/drizzle/0210_browser_auth_network_interventions.sql +441 -0
- package/drizzle/0211_editable_artifact_session_links.sql +58 -0
- package/drizzle/0212_slack_installation_bindings.sql +348 -0
- package/drizzle/0213_slack_user_link_access_requests.sql +177 -0
- package/drizzle/0214_session_activity_commit_gate.sql +262 -0
- package/drizzle/0215_capabilities_platform.sql +980 -0
- package/drizzle/0216_pack_component_ownership.sql +235 -0
- package/drizzle/0217_capability_definition_delete_authority.sql +32 -0
- package/package.json +18 -5
- package/src/attached-browser-devices.ts +371 -0
- package/src/attempt-tool-catalogs.ts +131 -0
- package/src/browser-auth.ts +1896 -0
- package/src/browser-identities.ts +1168 -0
- package/src/browser-sessions.ts +2005 -0
- package/src/browser-state-artifacts.ts +59 -0
- package/src/capability-components.ts +166 -0
- package/src/capability-integrations.ts +1663 -0
- package/src/codemode-operations.ts +674 -0
- package/src/company-profile-schema.ts +143 -0
- package/src/company-profile.ts +968 -0
- package/src/computer-sessions.ts +1130 -0
- package/src/connection-token-resolver.ts +270 -25
- package/src/database.ts +434 -24
- package/src/editable-artifact-durable-export.ts +1201 -0
- package/src/editable-artifact-materialization.ts +893 -0
- package/src/editable-artifacts-schema.ts +879 -0
- package/src/editable-artifacts.ts +5404 -0
- package/src/environment-crypto.ts +22 -9
- package/src/generated-images.ts +740 -0
- package/src/index.ts +10117 -2730
- package/src/insights.ts +160 -13
- package/src/integration-bindings.ts +455 -0
- package/src/integration-features.ts +859 -0
- package/src/interaction-revisions.ts +40 -0
- package/src/interaction-schema.ts +1303 -0
- package/src/knowledge-source-sync-schema.ts +192 -0
- package/src/knowledge-source-sync.ts +1922 -0
- package/src/lossless-columns.ts +35 -0
- package/src/lossless-json.ts +322 -0
- package/src/memory-domain.ts +5 -44
- package/src/memory-slack-delivery.ts +801 -0
- package/src/pack-components.ts +954 -0
- package/src/pack-installations.ts +929 -0
- package/src/persistence-errors.ts +26 -34
- package/src/plugin-packages.ts +1186 -0
- package/src/provision-roles.ts +302 -1
- package/src/runtime-posture-cli.ts +9 -0
- package/src/runtime-posture.ts +514 -5
- package/src/schema.ts +5177 -2957
- package/src/scoped-knowledge-schema.ts +1 -1
- package/src/scoped-knowledge.ts +655 -3
- package/src/session-control.ts +133 -81
- package/src/session-queue-commands.ts +511 -247
- package/src/session-realtime-context.ts +20 -7
- package/src/session-realtime-ledger.ts +32 -10
- package/src/session-realtime-mirror.ts +4 -2
- package/src/session-realtime-terminal.ts +89 -21
- package/src/session-realtime.ts +10 -9
- package/src/session-tool-call-settlement.ts +38 -15
- package/src/slack-user-link-access.ts +702 -0
- package/src/transcription-recordings-schema.ts +5 -2
- package/src/transcription-recordings.ts +70 -40
- package/src/video-generation.ts +1452 -0
- package/src/workspace-learning-policy-schema.ts +139 -0
- package/src/workspace-learning-policy.ts +595 -0
- package/dist/chunk-DBS5HPEW.js.map +0 -1
- package/dist/chunk-HT5T62CC.js +0 -6803
- package/dist/chunk-HT5T62CC.js.map +0 -1
- package/dist/event-payload-sanitizer.d.ts +0 -32
- package/src/event-payload-sanitizer.ts +0 -377
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BrowserRevisionMaterialization,
|
|
3
|
+
type BrowserRevisionMaterialization as BrowserRevisionMaterializationValue,
|
|
4
|
+
} from "@opengeni/contracts";
|
|
5
|
+
import type * as schema from "./schema";
|
|
6
|
+
|
|
7
|
+
type BrowserStateArtifactRow = typeof schema.browserStateArtifacts.$inferSelect;
|
|
8
|
+
|
|
9
|
+
const SHA256_PATTERN = /^[0-9a-f]{64}$/u;
|
|
10
|
+
const OBJECT_KEY_SEGMENT_PATTERN = /^[A-Za-z0-9._=-]+$/u;
|
|
11
|
+
|
|
12
|
+
export type BrowserStateArtifactCommitInput = {
|
|
13
|
+
kind: BrowserStateArtifactRow["kind"];
|
|
14
|
+
format: string;
|
|
15
|
+
artifactDigest: string;
|
|
16
|
+
contentDigest: string;
|
|
17
|
+
manifestDigest: string;
|
|
18
|
+
objectKey: string;
|
|
19
|
+
encryptedDataKey: string;
|
|
20
|
+
sizeBytes: number;
|
|
21
|
+
materialization: BrowserRevisionMaterializationValue;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/** Validate storage authority before it can become durable state. */
|
|
25
|
+
export function validateBrowserStateArtifactCommitInput(
|
|
26
|
+
workspaceId: string,
|
|
27
|
+
value: BrowserStateArtifactCommitInput,
|
|
28
|
+
): BrowserStateArtifactCommitInput {
|
|
29
|
+
const prefix = `workspaces/${workspaceId}/browser-state/`;
|
|
30
|
+
const objectKeySuffix = value.objectKey.slice(prefix.length);
|
|
31
|
+
if (
|
|
32
|
+
!SHA256_PATTERN.test(value.artifactDigest) ||
|
|
33
|
+
!SHA256_PATTERN.test(value.contentDigest) ||
|
|
34
|
+
!SHA256_PATTERN.test(value.manifestDigest) ||
|
|
35
|
+
!value.objectKey.startsWith(prefix) ||
|
|
36
|
+
objectKeySuffix.length < 1 ||
|
|
37
|
+
objectKeySuffix
|
|
38
|
+
.split("/")
|
|
39
|
+
.some(
|
|
40
|
+
(segment) =>
|
|
41
|
+
!OBJECT_KEY_SEGMENT_PATTERN.test(segment) || segment === "." || segment === "..",
|
|
42
|
+
) ||
|
|
43
|
+
Buffer.byteLength(value.objectKey) > 2_048 ||
|
|
44
|
+
value.format.trim() !== value.format ||
|
|
45
|
+
Buffer.byteLength(value.format) < 1 ||
|
|
46
|
+
Buffer.byteLength(value.format) > 512 ||
|
|
47
|
+
Buffer.byteLength(value.encryptedDataKey) < 16 ||
|
|
48
|
+
Buffer.byteLength(value.encryptedDataKey) > 8_192 ||
|
|
49
|
+
!Number.isSafeInteger(value.sizeBytes) ||
|
|
50
|
+
value.sizeBytes < 1
|
|
51
|
+
) {
|
|
52
|
+
throw new Error("Browser state artifact metadata is invalid");
|
|
53
|
+
}
|
|
54
|
+
const materialization = BrowserRevisionMaterialization.parse(value.materialization);
|
|
55
|
+
if (value.kind === "provider_snapshot" && materialization.portability !== "provider_bound") {
|
|
56
|
+
throw new Error("Provider snapshots must declare their provider binding");
|
|
57
|
+
}
|
|
58
|
+
return { ...value, materialization };
|
|
59
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { and, eq, inArray, sql, type SQLWrapper } from "drizzle-orm";
|
|
2
|
+
|
|
3
|
+
import type { Database } from "./database";
|
|
4
|
+
import * as schema from "./schema";
|
|
5
|
+
|
|
6
|
+
export type CapabilityComponentOwnerIdentity = {
|
|
7
|
+
kind: "direct" | "plugin" | "pack" | "migration";
|
|
8
|
+
id: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export class CapabilityComponentVersionConflictError extends Error {
|
|
12
|
+
readonly name = "CapabilityComponentVersionConflictError";
|
|
13
|
+
|
|
14
|
+
constructor(readonly pluginKey: string) {
|
|
15
|
+
super("Capability component version is pinned by another owner");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* An owner row is runtime-effective only while its lifecycle-owning Plugin or
|
|
21
|
+
* v2 Pack installation is active. Direct, migration, and legacy textual Pack
|
|
22
|
+
* ownership is intrinsic so the rolling migration does not hide pre-v2 shared
|
|
23
|
+
* components before those Packs are reinstalled into the normalized ledger.
|
|
24
|
+
*/
|
|
25
|
+
export function effectiveCapabilityOwnerSql(
|
|
26
|
+
ownerKind: SQLWrapper,
|
|
27
|
+
ownerId: SQLWrapper,
|
|
28
|
+
): ReturnType<typeof sql> {
|
|
29
|
+
return sql`(
|
|
30
|
+
${ownerKind} not in ('plugin', 'pack')
|
|
31
|
+
or (
|
|
32
|
+
${ownerKind} = 'plugin'
|
|
33
|
+
and exists (
|
|
34
|
+
select 1 from ${schema.capabilityPluginInstallations} owning_plugin
|
|
35
|
+
where owning_plugin.id::text = ${ownerId}
|
|
36
|
+
and owning_plugin.status = 'active'
|
|
37
|
+
)
|
|
38
|
+
)
|
|
39
|
+
or (
|
|
40
|
+
${ownerKind} = 'pack'
|
|
41
|
+
and (
|
|
42
|
+
${ownerId} !~ '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$'
|
|
43
|
+
or exists (
|
|
44
|
+
select 1 from ${schema.packInstallations} owning_pack
|
|
45
|
+
where owning_pack.id::text = ${ownerId}
|
|
46
|
+
and owning_pack.status = 'active'
|
|
47
|
+
)
|
|
48
|
+
)
|
|
49
|
+
)
|
|
50
|
+
)`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Serialize one workspace-local component identity across direct, Plugin, and Pack installers. */
|
|
54
|
+
export async function lockCapabilityComponentIdentity(
|
|
55
|
+
db: Database,
|
|
56
|
+
workspaceId: string,
|
|
57
|
+
pluginKey: string,
|
|
58
|
+
): Promise<void> {
|
|
59
|
+
await db.execute(
|
|
60
|
+
sql`select pg_advisory_xact_lock(hashtextextended(${`capability-component:${workspaceId}:${pluginKey}`}, 0))`,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* A child installation selects exactly one immutable Plugin version. Changing
|
|
66
|
+
* that version is safe only when every retained facet owner is the caller.
|
|
67
|
+
*/
|
|
68
|
+
export async function assertCapabilityComponentVersionCanChange(
|
|
69
|
+
db: Database,
|
|
70
|
+
input: {
|
|
71
|
+
workspaceId: string;
|
|
72
|
+
pluginKey: string;
|
|
73
|
+
pluginInstallationId: string;
|
|
74
|
+
owner: CapabilityComponentOwnerIdentity;
|
|
75
|
+
},
|
|
76
|
+
): Promise<void> {
|
|
77
|
+
const owners = await db
|
|
78
|
+
.select({
|
|
79
|
+
kind: schema.capabilityComponentOwners.ownerKind,
|
|
80
|
+
id: schema.capabilityComponentOwners.ownerId,
|
|
81
|
+
})
|
|
82
|
+
.from(schema.capabilityComponentOwners)
|
|
83
|
+
.innerJoin(
|
|
84
|
+
schema.capabilityFacetInstallations,
|
|
85
|
+
eq(
|
|
86
|
+
schema.capabilityFacetInstallations.id,
|
|
87
|
+
schema.capabilityComponentOwners.facetInstallationId,
|
|
88
|
+
),
|
|
89
|
+
)
|
|
90
|
+
.where(
|
|
91
|
+
and(
|
|
92
|
+
eq(schema.capabilityComponentOwners.workspaceId, input.workspaceId),
|
|
93
|
+
eq(schema.capabilityFacetInstallations.pluginInstallationId, input.pluginInstallationId),
|
|
94
|
+
effectiveCapabilityOwnerSql(
|
|
95
|
+
schema.capabilityComponentOwners.ownerKind,
|
|
96
|
+
schema.capabilityComponentOwners.ownerId,
|
|
97
|
+
),
|
|
98
|
+
),
|
|
99
|
+
);
|
|
100
|
+
if (owners.some((owner) => owner.kind !== input.owner.kind || owner.id !== input.owner.id)) {
|
|
101
|
+
throw new CapabilityComponentVersionConflictError(input.pluginKey);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Delete physically ownerless facet installations and disable now-empty child
|
|
107
|
+
* components. Inactive lifecycle owners still preserve storage: a Pack may
|
|
108
|
+
* have claimed a component while its installation is pending or repairing,
|
|
109
|
+
* even though that owner is intentionally hidden from runtime reads.
|
|
110
|
+
*/
|
|
111
|
+
export async function cleanupOrphanedCapabilityComponents(
|
|
112
|
+
db: Database,
|
|
113
|
+
workspaceId: string,
|
|
114
|
+
facetInstallationIds: string[],
|
|
115
|
+
): Promise<void> {
|
|
116
|
+
const uniqueIds = [...new Set(facetInstallationIds)];
|
|
117
|
+
if (uniqueIds.length === 0) return;
|
|
118
|
+
const orphanRows = await db
|
|
119
|
+
.select({
|
|
120
|
+
facetInstallationId: schema.capabilityFacetInstallations.id,
|
|
121
|
+
pluginInstallationId: schema.capabilityFacetInstallations.pluginInstallationId,
|
|
122
|
+
})
|
|
123
|
+
.from(schema.capabilityFacetInstallations)
|
|
124
|
+
.where(
|
|
125
|
+
and(
|
|
126
|
+
inArray(schema.capabilityFacetInstallations.id, uniqueIds),
|
|
127
|
+
sql`not exists (
|
|
128
|
+
select 1 from ${schema.capabilityComponentOwners} owner
|
|
129
|
+
where owner.facet_installation_id = ${schema.capabilityFacetInstallations.id}
|
|
130
|
+
)`,
|
|
131
|
+
),
|
|
132
|
+
);
|
|
133
|
+
if (orphanRows.length === 0) return;
|
|
134
|
+
await db.delete(schema.capabilityFacetInstallations).where(
|
|
135
|
+
inArray(
|
|
136
|
+
schema.capabilityFacetInstallations.id,
|
|
137
|
+
orphanRows.map((row) => row.facetInstallationId),
|
|
138
|
+
),
|
|
139
|
+
);
|
|
140
|
+
const childInstallations = [...new Set(orphanRows.map((row) => row.pluginInstallationId))];
|
|
141
|
+
for (const childInstallationId of childInstallations) {
|
|
142
|
+
const [remaining] = await db
|
|
143
|
+
.select({ id: schema.capabilityFacetInstallations.id })
|
|
144
|
+
.from(schema.capabilityFacetInstallations)
|
|
145
|
+
.where(eq(schema.capabilityFacetInstallations.pluginInstallationId, childInstallationId))
|
|
146
|
+
.limit(1);
|
|
147
|
+
if (remaining) continue;
|
|
148
|
+
await db
|
|
149
|
+
.update(schema.capabilityPluginInstallations)
|
|
150
|
+
.set({
|
|
151
|
+
status: "disabled",
|
|
152
|
+
version: sql`${schema.capabilityPluginInstallations.version} + 1`,
|
|
153
|
+
updatedAt: new Date(),
|
|
154
|
+
})
|
|
155
|
+
.where(eq(schema.capabilityPluginInstallations.id, childInstallationId));
|
|
156
|
+
await db
|
|
157
|
+
.update(schema.capabilityInstallations)
|
|
158
|
+
.set({ status: "disabled", updatedAt: new Date() })
|
|
159
|
+
.where(
|
|
160
|
+
and(
|
|
161
|
+
eq(schema.capabilityInstallations.workspaceId, workspaceId),
|
|
162
|
+
sql`${schema.capabilityInstallations.metadata} ->> 'pluginInstallationId' = ${childInstallationId}`,
|
|
163
|
+
),
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
}
|