@opengeni/api-router 0.30.0 → 0.30.3
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/app.js +1 -1
- package/dist/{chunk-2PQMSRCB.js → chunk-WCXHI3FF.js} +227 -66
- package/dist/chunk-WCXHI3FF.js.map +1 -0
- package/dist/editable-artifact-office-import.d.ts +7 -4
- package/dist/index.js +39 -5
- package/dist/index.js.map +1 -1
- package/dist/integrations/google-drive.d.ts +1 -0
- package/dist/integrations/slack-interactions.d.ts +6 -1
- package/dist/routes/browser-sessions.d.ts +13 -2
- package/dist/routes/files.d.ts +4 -0
- package/package.json +14 -14
- package/src/app.ts +7 -4
- package/src/editable-artifact-office-import.ts +49 -6
- package/src/integrations/google-drive.ts +115 -9
- package/src/integrations/slack-interactions.ts +9 -6
- package/src/mcp/files.ts +7 -2
- package/src/routes/browser-sessions.ts +59 -19
- package/src/routes/connections.ts +1 -0
- package/src/routes/files.ts +80 -16
- package/src/routes/sessions.ts +2 -2
- package/dist/chunk-2PQMSRCB.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { prepareArtifactOfficeImport } from "@opengeni/artifact-tool/office-import";
|
|
2
|
-
import { type EditableArtifactOfficeImportPort } from "@opengeni/core/editable-artifacts";
|
|
3
|
-
import {
|
|
2
|
+
import { type EditableArtifactActor, type EditableArtifactOfficeImportPort, type EditableArtifactScope } from "@opengeni/core/editable-artifacts";
|
|
3
|
+
import { getFilesForSubject } from "@opengeni/db";
|
|
4
4
|
import { type BoundedImmutableObjectWritePort, type ObjectStorage } from "@opengeni/storage";
|
|
5
5
|
import type { Database } from "@opengeni/db";
|
|
6
6
|
import type { VerifiedNativeArtifactRuntimeBinding } from "./editable-artifact-native-kernel.js";
|
|
@@ -10,13 +10,16 @@ export type EditableArtifactOfficeImportAdapterDependencies = Readonly<{
|
|
|
10
10
|
runtime: VerifiedNativeArtifactRuntimeBinding;
|
|
11
11
|
sourceObjects: BoundedImmutableObjectWritePort;
|
|
12
12
|
snapshotObjects: BoundedImmutableObjectWritePort;
|
|
13
|
-
|
|
13
|
+
readFiles?: typeof getFilesForSubject;
|
|
14
|
+
resolveFileAuthoritySubjectId?: typeof editableArtifactFileAuthoritySubjectId;
|
|
14
15
|
prepareOffice?: typeof prepareArtifactOfficeImport;
|
|
15
16
|
}>;
|
|
16
17
|
/** Trusted import boundary from one ready workspace file into native sequence-zero state. */
|
|
17
18
|
export declare class EditableArtifactOfficeImportAdapter implements EditableArtifactOfficeImportPort {
|
|
18
19
|
private readonly dependencies;
|
|
19
|
-
private readonly
|
|
20
|
+
private readonly readFiles;
|
|
21
|
+
private readonly resolveFileAuthoritySubjectId;
|
|
20
22
|
constructor(dependencies: EditableArtifactOfficeImportAdapterDependencies);
|
|
21
23
|
prepare(input: Parameters<EditableArtifactOfficeImportPort["prepare"]>[0]): ReturnType<EditableArtifactOfficeImportPort["prepare"]>;
|
|
22
24
|
}
|
|
25
|
+
export declare function editableArtifactFileAuthoritySubjectId(db: Database, scope: EditableArtifactScope, actor: EditableArtifactActor): Promise<string | null>;
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
createOpenGeniSlackBotInteractionClient,
|
|
5
5
|
startSlackInteractionPump,
|
|
6
6
|
startTemporalScheduleCleanupPump
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-WCXHI3FF.js";
|
|
8
8
|
|
|
9
9
|
// src/index.ts
|
|
10
10
|
import {
|
|
@@ -1578,7 +1578,8 @@ import {
|
|
|
1578
1578
|
editableArtifactStateHash as editableArtifactStateHash2,
|
|
1579
1579
|
EditableArtifactOfficeImportError
|
|
1580
1580
|
} from "@opengeni/core/editable-artifacts";
|
|
1581
|
-
import {
|
|
1581
|
+
import { requireLiveAgentAttemptAuthorization } from "@opengeni/core";
|
|
1582
|
+
import { getFilesForSubject } from "@opengeni/db";
|
|
1582
1583
|
import {
|
|
1583
1584
|
MAX_BOUNDED_OBJECT_CHUNK_BYTES
|
|
1584
1585
|
} from "@opengeni/storage";
|
|
@@ -1586,12 +1587,24 @@ var SNAPSHOT_MIME = "application/vnd.opengeni.editable-artifact-snapshot";
|
|
|
1586
1587
|
var EditableArtifactOfficeImportAdapter = class {
|
|
1587
1588
|
constructor(dependencies) {
|
|
1588
1589
|
this.dependencies = dependencies;
|
|
1589
|
-
this.
|
|
1590
|
+
this.readFiles = dependencies.readFiles ?? getFilesForSubject;
|
|
1591
|
+
this.resolveFileAuthoritySubjectId = dependencies.resolveFileAuthoritySubjectId ?? editableArtifactFileAuthoritySubjectId;
|
|
1590
1592
|
}
|
|
1591
|
-
|
|
1593
|
+
readFiles;
|
|
1594
|
+
resolveFileAuthoritySubjectId;
|
|
1592
1595
|
async prepare(input) {
|
|
1593
1596
|
throwIfAborted2(input.signal);
|
|
1594
|
-
const
|
|
1597
|
+
const subjectId = await this.resolveFileAuthoritySubjectId(
|
|
1598
|
+
this.dependencies.db,
|
|
1599
|
+
input.scope,
|
|
1600
|
+
input.actor
|
|
1601
|
+
);
|
|
1602
|
+
const [file] = await this.readFiles(this.dependencies.db, {
|
|
1603
|
+
accountId: input.scope.accountId,
|
|
1604
|
+
workspaceId: input.scope.workspaceId,
|
|
1605
|
+
subjectId,
|
|
1606
|
+
fileIds: [input.fileId]
|
|
1607
|
+
});
|
|
1595
1608
|
if (!file || file.status !== "ready") {
|
|
1596
1609
|
throw new EditableArtifactOfficeImportError("invalid_source");
|
|
1597
1610
|
}
|
|
@@ -1722,6 +1735,27 @@ async function readVerifiedWorkspaceFile(storage, file, signal) {
|
|
|
1722
1735
|
}
|
|
1723
1736
|
return bytes;
|
|
1724
1737
|
}
|
|
1738
|
+
async function editableArtifactFileAuthoritySubjectId(db, scope, actor) {
|
|
1739
|
+
if (actor.kind !== "agent") return actor.subjectId;
|
|
1740
|
+
const authorization = await requireLiveAgentAttemptAuthorization(
|
|
1741
|
+
db,
|
|
1742
|
+
{
|
|
1743
|
+
accountId: scope.accountId,
|
|
1744
|
+
workspaceId: scope.workspaceId,
|
|
1745
|
+
subjectId: actor.subjectId,
|
|
1746
|
+
permissions: [],
|
|
1747
|
+
principalKind: "agent_attempt",
|
|
1748
|
+
metadata: {
|
|
1749
|
+
sessionId: actor.sessionId,
|
|
1750
|
+
turnId: actor.turnId,
|
|
1751
|
+
attemptId: actor.attemptId,
|
|
1752
|
+
executionGeneration: actor.generation
|
|
1753
|
+
}
|
|
1754
|
+
},
|
|
1755
|
+
actor.sessionId
|
|
1756
|
+
);
|
|
1757
|
+
return authorization.initiatingHumanSubjectId;
|
|
1758
|
+
}
|
|
1725
1759
|
async function* byteChunks(bytes) {
|
|
1726
1760
|
for (let offset = 0; offset < bytes.byteLength; offset += MAX_BOUNDED_OBJECT_CHUNK_BYTES) {
|
|
1727
1761
|
yield bytes.subarray(offset, offset + MAX_BOUNDED_OBJECT_CHUNK_BYTES);
|