@opengeni/api-router 6.36.1-canary.45090389523001 → 6.37.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/dist/app.js +1 -1
- package/dist/{chunk-6JSLE7AS.js → chunk-GAWTCUEH.js} +113 -28
- package/dist/{chunk-6JSLE7AS.js.map → chunk-GAWTCUEH.js.map} +1 -1
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/sandbox/operation-inventory.d.ts +7 -8
- package/dist/secret-answers.d.ts +9 -3
- package/dist/site-tool-data.d.ts +11 -0
- package/package.json +27 -28
- package/src/app-sync/service.ts +43 -19
- package/src/routes/sessions.ts +18 -9
- package/src/sandbox/auth-callout.ts +3 -0
- package/src/sandbox/operation-inventory.ts +15 -12
- package/src/secret-answers.ts +46 -1
- package/src/site-data/operations.ts +22 -3
- package/src/site-sql/service.ts +8 -1
- package/src/site-tool-data.ts +48 -3
package/dist/app.js
CHANGED
|
@@ -2901,7 +2901,7 @@ function ipv6Groups(address) {
|
|
|
2901
2901
|
|
|
2902
2902
|
// src/workspace-tool-gateway.ts
|
|
2903
2903
|
import {
|
|
2904
|
-
isVerifiedDelegatedHumanAuthorization as
|
|
2904
|
+
isVerifiedDelegatedHumanAuthorization as isVerifiedDelegatedHumanAuthorization3,
|
|
2905
2905
|
knowledgeContextForGateway,
|
|
2906
2906
|
outsideAgentReach as outsideAgentReach3,
|
|
2907
2907
|
serviceConnectionCredentialReferences
|
|
@@ -16337,6 +16337,8 @@ import {
|
|
|
16337
16337
|
getWorkspaceGrant,
|
|
16338
16338
|
listSiteToolDataSources,
|
|
16339
16339
|
markSiteToolData,
|
|
16340
|
+
resetSiteToolData,
|
|
16341
|
+
SITE_TOOL_DATA_RESET_GRACE_MS,
|
|
16340
16342
|
SiteDataError,
|
|
16341
16343
|
siteToolDataTarget,
|
|
16342
16344
|
subjectHasLiveWorkspaceAuthorityInScope,
|
|
@@ -16387,15 +16389,32 @@ function sourceOfSyncAction(raw) {
|
|
|
16387
16389
|
};
|
|
16388
16390
|
}
|
|
16389
16391
|
async function siteToolDataSources(deps, scope, siteId4) {
|
|
16390
|
-
const { marks, sharedSyncActions } = await listSiteToolDataSources(
|
|
16392
|
+
const { marks, sharedSyncActions, resets } = await listSiteToolDataSources(
|
|
16393
|
+
deps.db,
|
|
16394
|
+
scope,
|
|
16395
|
+
siteId4
|
|
16396
|
+
);
|
|
16391
16397
|
return [
|
|
16392
16398
|
...marks,
|
|
16393
|
-
...sharedSyncActions.flatMap((action2) => {
|
|
16399
|
+
...sharedSyncActions.flatMap(({ action: action2, deletedAt }) => {
|
|
16394
16400
|
const source = sourceOfSyncAction(action2);
|
|
16395
|
-
|
|
16401
|
+
if (!source) return [];
|
|
16402
|
+
const reset = resets.get(source.target);
|
|
16403
|
+
if (deletedAt && reset && reset.getTime() - SITE_TOOL_DATA_RESET_GRACE_MS >= deletedAt.getTime())
|
|
16404
|
+
return [];
|
|
16405
|
+
return [source];
|
|
16396
16406
|
})
|
|
16397
16407
|
];
|
|
16398
16408
|
}
|
|
16409
|
+
async function resetToolData(deps, scope, siteId4, target) {
|
|
16410
|
+
await resetSiteToolData(deps.db, scope, siteId4, target);
|
|
16411
|
+
}
|
|
16412
|
+
async function keepSyncToolDataMarked(deps, scope, siteId4, action2) {
|
|
16413
|
+
if (!action2 || typeof action2 !== "object" || action2.mode !== "shared")
|
|
16414
|
+
return;
|
|
16415
|
+
const source = sourceOfSyncAction(action2);
|
|
16416
|
+
if (source) await markSiteToolData(deps.db, scope, siteId4, [source]);
|
|
16417
|
+
}
|
|
16399
16418
|
async function markToolData(deps, scope, siteId4, sources) {
|
|
16400
16419
|
await markSiteToolData(deps.db, scope, siteId4, sources);
|
|
16401
16420
|
}
|
|
@@ -17948,12 +17967,24 @@ async function defineSiteDataCollection(deps, grant, siteId4, name, definition)
|
|
|
17948
17967
|
async function deleteSiteDataCollection(deps, grant, siteId4, name) {
|
|
17949
17968
|
const access = await resolveSiteDataAccess(deps, grant, siteId4, { management: true });
|
|
17950
17969
|
await consume(access, "write", 1);
|
|
17951
|
-
|
|
17970
|
+
const deleted = await access.store.deleteCollection(access.caller, name);
|
|
17971
|
+
await resetCollectionToolData(deps, access, name);
|
|
17972
|
+
return deleted;
|
|
17952
17973
|
}
|
|
17953
17974
|
async function resetSiteDataCollection(deps, grant, siteId4, name) {
|
|
17954
17975
|
const access = await resolveSiteDataAccess(deps, grant, siteId4, { management: true });
|
|
17955
17976
|
await consume(access, "write", 1);
|
|
17956
|
-
|
|
17977
|
+
const reset = await access.store.resetCollection(access.caller, name);
|
|
17978
|
+
await resetCollectionToolData(deps, access, name);
|
|
17979
|
+
return reset;
|
|
17980
|
+
}
|
|
17981
|
+
async function resetCollectionToolData(deps, access, name) {
|
|
17982
|
+
await resetToolData(
|
|
17983
|
+
deps,
|
|
17984
|
+
{ accountId: access.caller.accountId, workspaceId: access.caller.workspaceId },
|
|
17985
|
+
access.site.id,
|
|
17986
|
+
siteToolDataTarget("collection", name)
|
|
17987
|
+
);
|
|
17957
17988
|
}
|
|
17958
17989
|
async function requireCollectionReader(deps, access, collection) {
|
|
17959
17990
|
await requireToolDataReader(deps, {
|
|
@@ -19314,6 +19345,7 @@ async function resetSiteSql(deps, authority, siteId4, request) {
|
|
|
19314
19345
|
await markSiteSqlRebuilt(tx, resolved.scope, usage.databaseBytes);
|
|
19315
19346
|
return rebuilt;
|
|
19316
19347
|
});
|
|
19348
|
+
await resetToolData(deps, resolved.scope, resolved.scope.siteId, siteToolDataTarget("sql"));
|
|
19317
19349
|
return { applied, droppedSchema: drop };
|
|
19318
19350
|
} finally {
|
|
19319
19351
|
await meter(deps, resolved, usage, { countTowardCaps: false });
|
|
@@ -20645,22 +20677,24 @@ async function runForPerson(deps, callTool, task, action2, subjectId, context, c
|
|
|
20645
20677
|
);
|
|
20646
20678
|
const writer = await syncWriter(deps, grant, task, action2, context);
|
|
20647
20679
|
const identity2 = await toolForPerson(deps, grant, action2, chosenAccount);
|
|
20680
|
+
let markTarget = async () => {
|
|
20681
|
+
};
|
|
20648
20682
|
if (action2.mode === "shared") {
|
|
20649
20683
|
const inventory = await readInventory(deps, grant).catch(() => null);
|
|
20650
20684
|
const account = inventory?.accounts.find((item) => item.serverId === identity2.serverId);
|
|
20651
|
-
|
|
20685
|
+
const source = {
|
|
20686
|
+
target: action2.target ? siteToolDataTarget("sql") : siteToolDataTarget("collection", action2.collection),
|
|
20687
|
+
connector: account?.canonicalServerId ?? connectorToolOf(action2).serverId,
|
|
20688
|
+
route: identity2.serverId,
|
|
20689
|
+
shared: account?.shared === true
|
|
20690
|
+
};
|
|
20691
|
+
markTarget = () => markToolData(
|
|
20652
20692
|
deps,
|
|
20653
20693
|
{ accountId: task.accountId, workspaceId: task.workspaceId },
|
|
20654
20694
|
action2.siteId,
|
|
20655
|
-
[
|
|
20656
|
-
{
|
|
20657
|
-
target: action2.target ? siteToolDataTarget("sql") : siteToolDataTarget("collection", action2.collection),
|
|
20658
|
-
connector: account?.canonicalServerId ?? connectorToolOf(action2).serverId,
|
|
20659
|
-
route: identity2.serverId,
|
|
20660
|
-
shared: account?.shared === true
|
|
20661
|
-
}
|
|
20662
|
-
]
|
|
20695
|
+
[source]
|
|
20663
20696
|
);
|
|
20697
|
+
await markTarget();
|
|
20664
20698
|
}
|
|
20665
20699
|
const limit = Math.min(action2.maxRecords ?? APP_SYNC_MAX_RECORDS, APP_SYNC_MAX_RUN_RECORDS);
|
|
20666
20700
|
const paging = action2.paging ?? null;
|
|
@@ -20693,6 +20727,7 @@ async function runForPerson(deps, callTool, task, action2, subjectId, context, c
|
|
|
20693
20727
|
seen.add(record17.key);
|
|
20694
20728
|
fresh += 1;
|
|
20695
20729
|
}
|
|
20730
|
+
await markTarget();
|
|
20696
20731
|
summary.written += await writer.write(extracted.records);
|
|
20697
20732
|
if (action2.removeMissing)
|
|
20698
20733
|
await recordAppSyncKeys(deps.db, {
|
|
@@ -21267,6 +21302,12 @@ async function updateAppSync(deps, grant, siteId4, syncId, input) {
|
|
|
21267
21302
|
action: nextAction,
|
|
21268
21303
|
events: patch.events
|
|
21269
21304
|
}) : null;
|
|
21305
|
+
await keepSyncToolDataMarked(
|
|
21306
|
+
deps,
|
|
21307
|
+
{ accountId: grant.accountId, workspaceId: grant.workspaceId },
|
|
21308
|
+
siteId4,
|
|
21309
|
+
action2
|
|
21310
|
+
);
|
|
21270
21311
|
const updated = await deps.db.transaction(async (tx) => {
|
|
21271
21312
|
const next = await updateScheduledTask(tx, grant.workspaceId, task.id, {
|
|
21272
21313
|
...patch.name !== void 0 ? { name: patch.name.trim() } : {},
|
|
@@ -21310,7 +21351,13 @@ function stableJson2(value) {
|
|
|
21310
21351
|
}
|
|
21311
21352
|
async function deleteAppSync(deps, grant, siteId4, syncId) {
|
|
21312
21353
|
const access = await managerAccess(deps, grant, siteId4);
|
|
21313
|
-
await requireSyncTask(deps, grant, siteId4, syncId);
|
|
21354
|
+
const { action: action2 } = await requireSyncTask(deps, grant, siteId4, syncId);
|
|
21355
|
+
await keepSyncToolDataMarked(
|
|
21356
|
+
deps,
|
|
21357
|
+
{ accountId: grant.accountId, workspaceId: grant.workspaceId },
|
|
21358
|
+
siteId4,
|
|
21359
|
+
action2
|
|
21360
|
+
);
|
|
21314
21361
|
await deleteScheduledTaskLifecycle({
|
|
21315
21362
|
db: deps.db,
|
|
21316
21363
|
workspaceId: grant.workspaceId,
|
|
@@ -36287,11 +36334,39 @@ import {
|
|
|
36287
36334
|
generatePassword,
|
|
36288
36335
|
VAULT_LIMITS
|
|
36289
36336
|
} from "@opengeni/contracts";
|
|
36337
|
+
import {
|
|
36338
|
+
isVerifiedDelegatedHumanAuthorization as isVerifiedDelegatedHumanAuthorization2
|
|
36339
|
+
} from "@opengeni/core";
|
|
36290
36340
|
import {
|
|
36291
36341
|
encryptEnvironmentValue as encryptEnvironmentValue6,
|
|
36342
|
+
listHumanInputSecretSaveTargets,
|
|
36292
36343
|
VaultError as VaultError2
|
|
36293
36344
|
} from "@opengeni/db";
|
|
36294
36345
|
import { looksLikeSshPrivateKey, sshPublicKeyFromPrivateKey } from "@opengeni/vaults";
|
|
36346
|
+
function isSignedInSecretAnswerer(authorization) {
|
|
36347
|
+
return authorization.canonicalManagedHumanSession || authorization.canonicalLocalHumanSession || isVerifiedDelegatedHumanAuthorization2(authorization);
|
|
36348
|
+
}
|
|
36349
|
+
async function projectSecretAnswerTargets(db, authorization, requests) {
|
|
36350
|
+
const signedIn = isSignedInSecretAnswerer(authorization);
|
|
36351
|
+
const context = humanSecretWriteContext(authorization.grant);
|
|
36352
|
+
const byTurn = /* @__PURE__ */ new Map();
|
|
36353
|
+
return await Promise.all(
|
|
36354
|
+
requests.map(async (request) => {
|
|
36355
|
+
if (request.status !== "pending" || !request.questions.some((question) => question.kind === "secret")) {
|
|
36356
|
+
return request;
|
|
36357
|
+
}
|
|
36358
|
+
let read = byTurn.get(request.turnId);
|
|
36359
|
+
if (!read) {
|
|
36360
|
+
read = listHumanInputSecretSaveTargets(db, context, request);
|
|
36361
|
+
byTurn.set(request.turnId, read);
|
|
36362
|
+
}
|
|
36363
|
+
return {
|
|
36364
|
+
...request,
|
|
36365
|
+
secretSaveTargets: (await read).filter((target) => target !== "user" || signedIn)
|
|
36366
|
+
};
|
|
36367
|
+
})
|
|
36368
|
+
);
|
|
36369
|
+
}
|
|
36295
36370
|
function encrypted(key3, plaintext) {
|
|
36296
36371
|
const valueSize = Buffer.byteLength(plaintext, "utf8");
|
|
36297
36372
|
if (valueSize > VAULT_LIMITS.textValueMaxBytes) {
|
|
@@ -99813,7 +99888,7 @@ function requireWorkspaceToolGatewayAuthorization(authorization) {
|
|
|
99813
99888
|
return grant;
|
|
99814
99889
|
}
|
|
99815
99890
|
requireWorkspaceToolGatewayGrant(grant);
|
|
99816
|
-
if (!authorization.canonicalManagedHumanSession && !authorization.canonicalLocalHumanSession && !
|
|
99891
|
+
if (!authorization.canonicalManagedHumanSession && !authorization.canonicalLocalHumanSession && !isVerifiedDelegatedHumanAuthorization3(authorization) && !externalActorContinuationForAuthorization5(authorization)) {
|
|
99817
99892
|
throw new HTTPException47(403, { message: "current-human tool access required" });
|
|
99818
99893
|
}
|
|
99819
99894
|
return grant;
|
|
@@ -108324,7 +108399,7 @@ import {
|
|
|
108324
108399
|
requireOrganizationAdministrationStamp,
|
|
108325
108400
|
requireAccessContext as requireAccessContext9,
|
|
108326
108401
|
requireCanonicalLocalAccountAdministrator as requireCanonicalLocalAccountAdministrator3,
|
|
108327
|
-
isVerifiedDelegatedHumanAuthorization as
|
|
108402
|
+
isVerifiedDelegatedHumanAuthorization as isVerifiedDelegatedHumanAuthorization4,
|
|
108328
108403
|
MissingPermissionRefusal as MissingPermissionRefusal7
|
|
108329
108404
|
} from "@opengeni/core";
|
|
108330
108405
|
import {
|
|
@@ -108751,7 +108826,7 @@ function requireOrganizationIntegrationAdmin(context, organizationId2, authoriza
|
|
|
108751
108826
|
} else {
|
|
108752
108827
|
if (!holdsOrganizationAdministration2(context, organizationId2))
|
|
108753
108828
|
throw new MissingPermissionRefusal7("account:admin");
|
|
108754
|
-
if (!authorization || !(authorization.canonicalManagedHumanSession || authorization.canonicalLocalHumanSession ||
|
|
108829
|
+
if (!authorization || !(authorization.canonicalManagedHumanSession || authorization.canonicalLocalHumanSession || isVerifiedDelegatedHumanAuthorization4(authorization)) || authorization.grant.accountId !== organizationId2 || authorization.authenticatedSubjectId !== context.subjectId || context.workspaceGrants.some((candidate) => candidate.metadata?.delegated === true)) {
|
|
108755
108830
|
throw new HTTPException67(403, { message: "Canonical organization administrator required" });
|
|
108756
108831
|
}
|
|
108757
108832
|
requireOrganizationAdministrationStamp(authorization);
|
|
@@ -109012,7 +109087,7 @@ import {
|
|
|
109012
109087
|
import {
|
|
109013
109088
|
hasIntegrationAdminPermission as hasIntegrationAdminPermission4,
|
|
109014
109089
|
hasPermission as hasPermission31,
|
|
109015
|
-
isVerifiedDelegatedHumanAuthorization as
|
|
109090
|
+
isVerifiedDelegatedHumanAuthorization as isVerifiedDelegatedHumanAuthorization5,
|
|
109016
109091
|
withSiteSessionOrigin as withSiteSessionOrigin3,
|
|
109017
109092
|
siteViewerForGrant as siteViewerForGrant11
|
|
109018
109093
|
} from "@opengeni/core";
|
|
@@ -109445,7 +109520,7 @@ var notAuthorized = () => new HTTPException69(403, { message: "site_tool_not_aut
|
|
|
109445
109520
|
function mayRememberForSite(authorization) {
|
|
109446
109521
|
if (isPublishedSiteToolAuthorization(authorization)) return false;
|
|
109447
109522
|
return Boolean(
|
|
109448
|
-
authorization.canonicalManagedHumanSession || authorization.canonicalLocalHumanSession ||
|
|
109523
|
+
authorization.canonicalManagedHumanSession || authorization.canonicalLocalHumanSession || isVerifiedDelegatedHumanAuthorization5(authorization)
|
|
109449
109524
|
);
|
|
109450
109525
|
}
|
|
109451
109526
|
async function siteTarget(deps, authorization, request, options, mode) {
|
|
@@ -111688,7 +111763,6 @@ import {
|
|
|
111688
111763
|
} from "@opengeni/db";
|
|
111689
111764
|
import {
|
|
111690
111765
|
currentSiteSessionOrigin as currentSiteSessionOrigin3,
|
|
111691
|
-
isVerifiedDelegatedHumanAuthorization as isVerifiedDelegatedHumanAuthorization5,
|
|
111692
111766
|
scheduledTaskViewerSubjectForGrant,
|
|
111693
111767
|
withSiteSessionOrigin as withSiteSessionOrigin5
|
|
111694
111768
|
} from "@opengeni/core";
|
|
@@ -118331,7 +118405,7 @@ function registerSessionRoutes(app, deps) {
|
|
|
118331
118405
|
})
|
|
118332
118406
|
} : {},
|
|
118333
118407
|
respondedBy: grant.subjectId,
|
|
118334
|
-
canonicalHumanSession:
|
|
118408
|
+
canonicalHumanSession: isSignedInSecretAnswerer(authorization),
|
|
118335
118409
|
// An agent or personal key acting as the person is not the person
|
|
118336
118410
|
// for a secret approval card.
|
|
118337
118411
|
personSignedIn: authorization.canonicalManagedHumanSession || authorization.canonicalLocalHumanSession,
|
|
@@ -118396,7 +118470,12 @@ function registerSessionRoutes(app, deps) {
|
|
|
118396
118470
|
});
|
|
118397
118471
|
app.get("/v1/workspaces/:workspaceId/sessions/:sessionId/human-input-requests", async (c) => {
|
|
118398
118472
|
const workspaceId = c.req.param("workspaceId");
|
|
118399
|
-
|
|
118473
|
+
const authorization = await requireAccessGrantAuthorization12(
|
|
118474
|
+
c,
|
|
118475
|
+
deps,
|
|
118476
|
+
workspaceId,
|
|
118477
|
+
"sessions:read"
|
|
118478
|
+
);
|
|
118400
118479
|
const sessionId = c.req.param("sessionId");
|
|
118401
118480
|
const observedSequence = await requireSessionSequence(db, workspaceId, sessionId);
|
|
118402
118481
|
const rawStatus = c.req.query("status");
|
|
@@ -118410,13 +118489,18 @@ function registerSessionRoutes(app, deps) {
|
|
|
118410
118489
|
...status2?.success ? { status: status2.data } : {}
|
|
118411
118490
|
});
|
|
118412
118491
|
c.header(SESSION_SEQUENCE_HEADER, String(observedSequence));
|
|
118413
|
-
return c.json({ requests });
|
|
118492
|
+
return c.json({ requests: await projectSecretAnswerTargets(db, authorization, requests) });
|
|
118414
118493
|
});
|
|
118415
118494
|
app.get(
|
|
118416
118495
|
"/v1/workspaces/:workspaceId/sessions/:sessionId/human-input-requests/:requestId",
|
|
118417
118496
|
async (c) => {
|
|
118418
118497
|
const workspaceId = c.req.param("workspaceId");
|
|
118419
|
-
|
|
118498
|
+
const authorization = await requireAccessGrantAuthorization12(
|
|
118499
|
+
c,
|
|
118500
|
+
deps,
|
|
118501
|
+
workspaceId,
|
|
118502
|
+
"sessions:read"
|
|
118503
|
+
);
|
|
118420
118504
|
const sessionId = c.req.param("sessionId");
|
|
118421
118505
|
const request = await getSessionHumanInputRequest2(
|
|
118422
118506
|
db,
|
|
@@ -118428,7 +118512,8 @@ function registerSessionRoutes(app, deps) {
|
|
|
118428
118512
|
throw new HTTPException73(404, {
|
|
118429
118513
|
message: "human-input request not found"
|
|
118430
118514
|
});
|
|
118431
|
-
|
|
118515
|
+
const [projected] = await projectSecretAnswerTargets(db, authorization, [request]);
|
|
118516
|
+
return c.json(projected);
|
|
118432
118517
|
}
|
|
118433
118518
|
);
|
|
118434
118519
|
function assertOwnershipEnabled() {
|
|
@@ -189651,4 +189736,4 @@ export {
|
|
|
189651
189736
|
withDefaultEnabledCapabilityMcpTools,
|
|
189652
189737
|
workflowIdForSession5 as workflowIdForSession
|
|
189653
189738
|
};
|
|
189654
|
-
//# sourceMappingURL=chunk-
|
|
189739
|
+
//# sourceMappingURL=chunk-GAWTCUEH.js.map
|