@opengeni/api-router 6.6.1-canary.41657852324001 → 6.7.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 CHANGED
@@ -29,7 +29,7 @@ import {
29
29
  withDefaultEnabledCapabilityMcpTools,
30
30
  workflowIdForSession,
31
31
  workspaceActorContextExempt
32
- } from "./chunk-D5MIYVYV.js";
32
+ } from "./chunk-WXI5VFFM.js";
33
33
  import "./chunk-OGQDXVXY.js";
34
34
  export {
35
35
  API_MAX_REQUEST_BODY_BYTES,
@@ -22,6 +22,7 @@ import {
22
22
  isDatabaseConnectionLoss,
23
23
  SessionUsageLimitUnavailableError,
24
24
  nestedPostgresSqlState,
25
+ SessionApprovalForbiddenError,
25
26
  WorkspaceControlBusyError,
26
27
  WorkspaceContentFlowRefusedError
27
28
  } from "@opengeni/db";
@@ -57,6 +58,19 @@ function missingPermissionHttpError(error) {
57
58
  details: error.details
58
59
  });
59
60
  }
61
+ function approvalForbiddenHttpError(error) {
62
+ if (!(error instanceof SessionApprovalForbiddenError)) return null;
63
+ return new ApiHttpError(403, {
64
+ code: "forbidden",
65
+ message: error.message,
66
+ retryable: false,
67
+ outcomeUnknown: false,
68
+ details: {
69
+ code: error.code,
70
+ ...error.owner.label ? { accountOwnerLabel: error.owner.label } : {}
71
+ }
72
+ });
73
+ }
60
74
  function scheduledTaskTargetAccessHttpError(error) {
61
75
  if (!(error instanceof HTTPException) || error.status !== 409) return null;
62
76
  const result2 = ScheduledTaskTargetAccessChange.safeParse(error.cause);
@@ -34774,6 +34788,7 @@ import {
34774
34788
  acceptSessionHumanInputResponse,
34775
34789
  acceptSessionApprovalDecision,
34776
34790
  SessionApprovalAnswerError,
34791
+ SessionApprovalForbiddenError as SessionApprovalForbiddenError2,
34777
34792
  approveSlackUserLinkAccessRequest,
34778
34793
  advanceSlackInteractionDelivery,
34779
34794
  bindSlackInteractionSession,
@@ -34790,6 +34805,7 @@ import {
34790
34805
  enqueueSlackAppHomeRefresh,
34791
34806
  enqueueSlackInteractionInbox as enqueueSlackInteractionInbox2,
34792
34807
  getConnectionMetadata as getConnectionMetadata7,
34808
+ getToolActionAccountOwner,
34793
34809
  getToolActionReview,
34794
34810
  getOrCreateSlackInteraction,
34795
34811
  getLatestSessionModelForSubject,
@@ -41977,6 +41993,12 @@ async function executeSlackAction(deps, grant, interaction, handle) {
41977
41993
  clientEventId: `slack-action:${handle.id}`
41978
41994
  });
41979
41995
  } catch (error) {
41996
+ if (error instanceof SessionApprovalForbiddenError2) {
41997
+ return {
41998
+ result: "forbidden",
41999
+ text: `${mention}${error.message} ${openSessionText(deps, interaction.workspaceId, handle.sessionId)}`
42000
+ };
42001
+ }
41980
42002
  if (!(error instanceof SessionApprovalAnswerError)) throw error;
41981
42003
  return {
41982
42004
  result: "needs_answer",
@@ -42406,13 +42428,29 @@ async function slackApprovalCard(deps, interaction, event, mention, requesterAut
42406
42428
  const reviewById = new Map(
42407
42429
  reviews.flatMap((review) => review ? [[review.id, review]] : [])
42408
42430
  );
42431
+ const owners = await Promise.all(
42432
+ approvals.map(
42433
+ (approval) => getToolActionAccountOwner(deps.db, {
42434
+ accountId: interaction.accountId,
42435
+ workspaceId: interaction.workspaceId,
42436
+ sessionId: interaction.sessionId,
42437
+ approvalId: approval.id
42438
+ })
42439
+ )
42440
+ );
42441
+ const otherOwnerById = new Map(
42442
+ approvals.flatMap((approval, index) => {
42443
+ const owner2 = owners[index];
42444
+ return owner2 && owner2.subjectId !== interaction.owningSubjectId ? [[approval.id, owner2]] : [];
42445
+ })
42446
+ );
42409
42447
  const actionable = approvals.filter((approval) => {
42410
42448
  if (approval.question) return true;
42411
42449
  const review = reviewById.get(approval.id);
42412
42450
  return review && slackToolReviewCanDecide(review);
42413
42451
  });
42414
42452
  const specs = actionable.flatMap((approval) => [
42415
- ...approval.question && !slackServerQuestion(approval.question).answerableInSlack ? [] : [
42453
+ ...approval.question && !slackServerQuestion(approval.question).answerableInSlack || otherOwnerById.has(approval.id) ? [] : [
42416
42454
  {
42417
42455
  actionKind: "approval_approve",
42418
42456
  actionKey: approval.question ? `approval:${approval.id}:approve:${approval.question.round}` : `approval:${approval.id}:approve`,
@@ -42446,6 +42484,8 @@ async function slackApprovalCard(deps, interaction, event, mention, requesterAut
42446
42484
  }
42447
42485
  const question = slackServerQuestion(approval.question);
42448
42486
  blocks.push(question.block);
42487
+ const questionOwner = otherOwnerById.get(approval.id);
42488
+ if (questionOwner) blocks.push(slackAccountOwnerNote(questionOwner.label));
42449
42489
  if (!question.answerableInSlack && link) {
42450
42490
  blocks.push({
42451
42491
  type: "section",
@@ -42481,6 +42521,23 @@ async function slackApprovalCard(deps, interaction, event, mention, requesterAut
42481
42521
  }
42482
42522
  if (!review) continue;
42483
42523
  blocks.push(...slackToolReviewBlocks(review, privateAudience));
42524
+ const owner2 = otherOwnerById.get(approval.id);
42525
+ if (owner2 && reject) {
42526
+ blocks.push(slackAccountOwnerNote(owner2.label));
42527
+ blocks.push({
42528
+ type: "actions",
42529
+ block_id: `opengeni_approval_${event.sequence}_${blocks.length}`,
42530
+ elements: [
42531
+ {
42532
+ type: "button",
42533
+ action_id: SLACK_ACTION_ID_BY_KIND.approval_reject,
42534
+ value: reject.id,
42535
+ text: { type: "plain_text", text: "Decline", emoji: true }
42536
+ }
42537
+ ]
42538
+ });
42539
+ continue;
42540
+ }
42484
42541
  if (approve && reject) {
42485
42542
  blocks.push({
42486
42543
  type: "actions",
@@ -42515,6 +42572,16 @@ async function slackApprovalCard(deps, interaction, event, mention, requesterAut
42515
42572
  operationId
42516
42573
  };
42517
42574
  }
42575
+ function slackAccountOwnerNote(label) {
42576
+ const who = label ? escapeSlackMrkdwn(label) : "the person whose own account this runs on";
42577
+ return {
42578
+ type: "section",
42579
+ text: {
42580
+ type: "mrkdwn",
42581
+ text: `Only ${who} can approve this, because it runs on their own account. You can decline it.`
42582
+ }
42583
+ };
42584
+ }
42518
42585
  async function slackSharedResultPublicationBlocks(deps, interaction, event, requesterAuthorized, messageOperationId) {
42519
42586
  if (!safePayloadText(event.payload, "output").trim()) return [];
42520
42587
  if (!requesterAuthorized || !interaction.sessionId || !interaction.initiatingSlackUserId) {
@@ -79242,7 +79309,7 @@ var PolicyMcpServer = class extends McpServer3 {
79242
79309
  if (!memory) return dispatch();
79243
79310
  return withSecretValueMasking(memory, async () => {
79244
79311
  try {
79245
- return memory.mask(await dispatch(), "first_party_result");
79312
+ return memory.maskData(await dispatch(), "first_party_result");
79246
79313
  } catch (error) {
79247
79314
  throw maskSecretValuesInError(error, memory);
79248
79315
  }
@@ -98735,7 +98802,7 @@ function registerSessionRoutes(app, deps) {
98735
98802
  sessionId: c.req.param("sessionId"),
98736
98803
  approvalId: c.req.param("approvalId")
98737
98804
  };
98738
- const review = await getToolActionReview2(db, input);
98805
+ const review = await getToolActionReview2(db, { ...input, viewerSubjectId: grant.subjectId });
98739
98806
  if (!review) throw new HTTPException68(404, { message: "Review not found" });
98740
98807
  c.header("Cache-Control", "private, no-store");
98741
98808
  return c.json(review);
@@ -101534,6 +101601,8 @@ function registerSessionRoutes(app, deps) {
101534
101601
  if (error instanceof SessionApprovalAnswerError2) {
101535
101602
  throw new HTTPException68(422, { message: error.message });
101536
101603
  }
101604
+ const forbidden = approvalForbiddenHttpError(error);
101605
+ if (forbidden) throw forbidden;
101537
101606
  throw error;
101538
101607
  }
101539
101608
  if (accepted.action === "conflict") {
@@ -132356,6 +132425,8 @@ function interactionResourceRouteError(error) {
132356
132425
  if (error instanceof InteractionResourceNotFoundError2 || error instanceof BrowserSessionNotFoundError2 || error instanceof ComputerSessionNotFoundError2) {
132357
132426
  return new HTTPException112(404, { message: error.message, cause: error });
132358
132427
  }
132428
+ const forbidden = approvalForbiddenHttpError(error);
132429
+ if (forbidden) return forbidden;
132359
132430
  if (error instanceof InteractionResourceConflictError2 || error instanceof InteractionResourceStateError3) {
132360
132431
  return new HTTPException112(409, { message: error.message, cause: error });
132361
132432
  }
@@ -157274,4 +157345,4 @@ export {
157274
157345
  withDefaultEnabledCapabilityMcpTools,
157275
157346
  workflowIdForSession4 as workflowIdForSession
157276
157347
  };
157277
- //# sourceMappingURL=chunk-D5MIYVYV.js.map
157348
+ //# sourceMappingURL=chunk-WXI5VFFM.js.map