@opengeni/api-router 2.3.2-canary.2 → 2.5.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.
Files changed (44) hide show
  1. package/dist/app.js +1 -1
  2. package/dist/auth/managed-auth-attempt-context.d.ts +4 -0
  3. package/dist/auth/managed-auth-session-adapter.d.ts +4 -0
  4. package/dist/{chunk-IBV7Z6F4.js → chunk-QESX7HDK.js} +3645 -470
  5. package/dist/chunk-QESX7HDK.js.map +1 -0
  6. package/dist/fatal-process-boundary.d.ts +25 -0
  7. package/dist/http/sse.d.ts +2 -0
  8. package/dist/index.d.ts +5 -1
  9. package/dist/index.js +168 -6
  10. package/dist/index.js.map +1 -1
  11. package/dist/integrations/slack-interactions.d.ts +1 -1
  12. package/dist/mcp/receipts.d.ts +9 -0
  13. package/dist/mcp/server.d.ts +33 -0
  14. package/dist/organization-recovery-notifications.d.ts +41 -0
  15. package/dist/routes/managed-auth-session-sets.d.ts +19 -0
  16. package/dist/routes/organization-recovery.d.ts +19 -0
  17. package/dist/routes/sessions.d.ts +17 -5
  18. package/dist/routes/workspaces.d.ts +1 -0
  19. package/dist/work-discovery-observability.d.ts +33 -0
  20. package/package.json +18 -18
  21. package/src/app.ts +133 -1
  22. package/src/auth/managed-auth-attempt-context.ts +24 -0
  23. package/src/auth/managed-auth-session-adapter.ts +205 -0
  24. package/src/auth/managed-auth.ts +52 -2
  25. package/src/fatal-process-boundary.ts +231 -0
  26. package/src/http/sse.ts +7 -0
  27. package/src/index.ts +25 -5
  28. package/src/integrations/slack-interactions.ts +30 -17
  29. package/src/mcp/receipts.ts +34 -0
  30. package/src/mcp/server.ts +349 -68
  31. package/src/organization-recovery-notifications.ts +103 -0
  32. package/src/routes/canonical-human-identities.ts +29 -14
  33. package/src/routes/codex.ts +5 -1
  34. package/src/routes/environments.ts +23 -0
  35. package/src/routes/interaction-resources.ts +3 -0
  36. package/src/routes/managed-auth-session-sets.ts +994 -0
  37. package/src/routes/managed-onboarding.ts +2 -0
  38. package/src/routes/organization-memberships.ts +2 -0
  39. package/src/routes/organization-recovery.ts +325 -0
  40. package/src/routes/sessions.ts +401 -120
  41. package/src/routes/supergrok.ts +5 -1
  42. package/src/routes/workspaces.ts +23 -1
  43. package/src/work-discovery-observability.ts +121 -0
  44. package/dist/chunk-IBV7Z6F4.js.map +0 -1
@@ -3203,13 +3203,15 @@ async function continueSlackSession(
3203
3203
  respondedBy: grant.subjectId,
3204
3204
  clientEventId: `slack:${entry.providerEventId}`,
3205
3205
  });
3206
- if (accepted.action === "accepted") {
3207
- await publishDurableSessionEvents(
3208
- deps.bus,
3209
- grant.workspaceId,
3210
- interaction.sessionId,
3211
- accepted.events,
3212
- );
3206
+ if (accepted.action === "accepted" || accepted.action === "completed") {
3207
+ if (accepted.events.length > 0) {
3208
+ await publishDurableSessionEvents(
3209
+ deps.bus,
3210
+ grant.workspaceId,
3211
+ interaction.sessionId,
3212
+ accepted.events,
3213
+ );
3214
+ }
3213
3215
  if (accepted.workflowWakeRevision !== null) {
3214
3216
  await deps.workflowClient.signalApprovalDecision({
3215
3217
  accountId: grant.accountId,
@@ -3220,7 +3222,8 @@ async function continueSlackSession(
3220
3222
  workflowWakeRevision: accepted.workflowWakeRevision,
3221
3223
  });
3222
3224
  }
3223
- return;
3225
+ const committedOutcome = accepted.request.response?.outcome;
3226
+ if (committedOutcome === "answered" || committedOutcome === "skipped") return;
3224
3227
  }
3225
3228
  }
3226
3229
  }
@@ -3502,19 +3505,21 @@ async function executeSlackAction(
3502
3505
  respondedBy: grant.subjectId,
3503
3506
  clientEventId: `slack-action:${handle.id}`,
3504
3507
  });
3505
- if (accepted.action !== "accepted") {
3508
+ if (accepted.action === "not_found" || accepted.action === "conflict") {
3506
3509
  return {
3507
3510
  result: "stale",
3508
3511
  stale: true,
3509
3512
  text: `${mention}This question is no longer pending.`,
3510
3513
  };
3511
3514
  }
3512
- await publishDurableSessionEvents(
3513
- deps.bus,
3514
- grant.workspaceId,
3515
- handle.sessionId,
3516
- accepted.events,
3517
- );
3515
+ if (accepted.events.length > 0) {
3516
+ await publishDurableSessionEvents(
3517
+ deps.bus,
3518
+ grant.workspaceId,
3519
+ handle.sessionId,
3520
+ accepted.events,
3521
+ );
3522
+ }
3518
3523
  if (accepted.workflowWakeRevision !== null) {
3519
3524
  await deps.workflowClient.signalApprovalDecision({
3520
3525
  accountId: grant.accountId,
@@ -3525,9 +3530,17 @@ async function executeSlackAction(
3525
3530
  workflowWakeRevision: accepted.workflowWakeRevision,
3526
3531
  });
3527
3532
  }
3533
+ const committedOutcome = accepted.request.response?.outcome ?? response.outcome;
3534
+ if (committedOutcome !== "answered" && committedOutcome !== "skipped") {
3535
+ return {
3536
+ result: "stale",
3537
+ stale: true,
3538
+ text: `${mention}This question is already ${committedOutcome}.`,
3539
+ };
3540
+ }
3528
3541
  return {
3529
- result: response.outcome === "skipped" ? "skipped" : "answered",
3530
- text: `${mention}${response.outcome === "skipped" ? "Skipped the question" : "Answer submitted"}. OpenGeni will continue.`,
3542
+ result: committedOutcome === "skipped" ? "skipped" : "answered",
3543
+ text: `${mention}${committedOutcome === "skipped" ? "Skipped the question" : "Answer submitted"}. OpenGeni will continue.`,
3531
3544
  };
3532
3545
  }
3533
3546
  if (handle.actionKind === "session_pause" || handle.actionKind === "session_resume") {
@@ -26,6 +26,40 @@ export function mcpMutationReceipt(input: McpMutationReceiptInput): McpMutationR
26
26
  });
27
27
  }
28
28
 
29
+ export function sessionControlMutationReceipt(input: {
30
+ operation: "session_pause" | "session_resume";
31
+ sessionId: string;
32
+ state: string;
33
+ receiptId: string;
34
+ timestamp: string;
35
+ outcome: "changed" | "unchanged" | "replayed";
36
+ interruptionCount: number;
37
+ }): McpMutationReceiptType {
38
+ return mcpMutationReceipt({
39
+ operation: input.operation,
40
+ committed: true,
41
+ outcome:
42
+ input.outcome === "changed"
43
+ ? "updated"
44
+ : input.outcome === "unchanged"
45
+ ? "unchanged"
46
+ : "replayed",
47
+ changed: input.outcome === "changed",
48
+ resource: {
49
+ type: "session",
50
+ id: input.sessionId,
51
+ state: input.state,
52
+ },
53
+ relatedResources: [{ type: "session_command_receipt", id: input.receiptId }],
54
+ timestamp: input.timestamp,
55
+ idempotency: {
56
+ status: input.outcome === "replayed" ? "replayed" : "applied",
57
+ },
58
+ facts: { interruptionCount: input.interruptionCount },
59
+ nextAction: { tool: "session_get", arguments: { sessionId: input.sessionId } },
60
+ });
61
+ }
62
+
29
63
  export type SessionCreateReceiptResult = {
30
64
  session: {
31
65
  id: string;