@opengeni/worker-bundle 1.0.1 → 2.0.0-canary.35625901699001

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 (125) hide show
  1. package/dist/activities/agent-turn/agent-build.d.ts +1 -0
  2. package/dist/activities/agent-turn/codex.d.ts +1 -1
  3. package/dist/activities/agent-turn/compaction-prep.d.ts +1 -5
  4. package/dist/activities/agent-turn/errors.d.ts +31 -5
  5. package/dist/activities/agent-turn/finalization-monitor.d.ts +17 -0
  6. package/dist/activities/agent-turn/finalization.d.ts +1 -1
  7. package/dist/activities/agent-turn/governance-model.d.ts +0 -2
  8. package/dist/activities/agent-turn/quiescence.d.ts +1 -0
  9. package/dist/activities/agent-turn/recovery-warning.d.ts +8 -0
  10. package/dist/activities/agent-turn/run-credentials.d.ts +0 -1
  11. package/dist/activities/agent-turn/sandbox-establish.d.ts +1 -1
  12. package/dist/activities/agent-turn/sandbox-route.d.ts +0 -20
  13. package/dist/activities/agent-turn/sandbox-runtime.d.ts +1 -1
  14. package/dist/activities/agent-turn/skill-remove.d.ts +14 -0
  15. package/dist/activities/agent-turn/skill-search.d.ts +1 -1
  16. package/dist/activities/agent-turn/stream-attempt.d.ts +1 -0
  17. package/dist/activities/agent-turn/tool-environment.d.ts +34 -4
  18. package/dist/activities/agent-turn/turn-context.d.ts +2 -0
  19. package/dist/activities/agent-turn/turn-sandbox-access.d.ts +3 -0
  20. package/dist/activities/codemode-dispatcher.d.ts +3 -1
  21. package/dist/activities/codex-capacity.d.ts +6 -1
  22. package/dist/activities/codex-rotation.d.ts +1 -1
  23. package/dist/activities/context-compaction.d.ts +7 -1
  24. package/dist/activities/mcp-account-routes.d.ts +22 -0
  25. package/dist/activities/mcp-credentials.d.ts +12 -13
  26. package/dist/activities/mcp-operation-authority.d.ts +0 -5
  27. package/dist/activities/rig-verification.d.ts +2 -3
  28. package/dist/activities/sandbox-images.d.ts +1 -1
  29. package/dist/activities/sandbox-lease.d.ts +4 -3
  30. package/dist/activities/session-state.d.ts +57 -2
  31. package/dist/activities/types.d.ts +12 -3
  32. package/dist/{activities-control-HMFGSKC5.js → activities-control-BOLIY3H4.js} +366 -187
  33. package/dist/activities-control-BOLIY3H4.js.map +1 -0
  34. package/dist/activities-control.d.ts +110 -2
  35. package/dist/{activities-turn-AP67JADS.js → activities-turn-UCFKWOAA.js} +797 -476
  36. package/dist/activities-turn-UCFKWOAA.js.map +1 -0
  37. package/dist/activities.d.ts +110 -2
  38. package/dist/artifact-materializer-entry.js +5 -2
  39. package/dist/artifact-materializer-entry.js.map +1 -1
  40. package/dist/artifact-outbox-entry.js +2 -2
  41. package/dist/artifact-outbox-entry.js.map +1 -1
  42. package/dist/{chunk-A4XQWVZK.js → chunk-I7HKKMUJ.js} +77 -1
  43. package/dist/chunk-I7HKKMUJ.js.map +1 -0
  44. package/dist/{chunk-CYITU5UH.js → chunk-TVEE2UUC.js} +275 -146
  45. package/dist/chunk-TVEE2UUC.js.map +1 -0
  46. package/dist/editable-artifact-materializer-service.d.ts +2 -2
  47. package/dist/editable-artifact-outbox-service.d.ts +2 -2
  48. package/dist/index.d.ts +55 -1
  49. package/dist/index.js +4 -3
  50. package/dist/index.js.map +1 -1
  51. package/dist/observability-metrics.d.ts +11 -3
  52. package/dist/retained-process-diagnostics.d.ts +4 -0
  53. package/dist/sandbox-resume.d.ts +2 -12
  54. package/dist/sandbox-routing.d.ts +5 -3
  55. package/dist/sandbox-snapshot-diagnostics.d.ts +20 -0
  56. package/dist/warm-capture-holder.d.ts +3 -0
  57. package/dist/workflow-bundle.js +51 -11
  58. package/package.json +19 -19
  59. package/src/activities/agent-turn/agent-build.ts +47 -6
  60. package/src/activities/agent-turn/claim.ts +12 -0
  61. package/src/activities/agent-turn/codex-capacity.ts +26 -4
  62. package/src/activities/agent-turn/codex.ts +6 -2
  63. package/src/activities/agent-turn/compaction-prep.ts +53 -72
  64. package/src/activities/agent-turn/errors.ts +98 -10
  65. package/src/activities/agent-turn/failure-settlement.ts +49 -28
  66. package/src/activities/agent-turn/finalization-monitor.ts +121 -0
  67. package/src/activities/agent-turn/finalization.ts +79 -21
  68. package/src/activities/agent-turn/governance-model.ts +15 -19
  69. package/src/activities/agent-turn/history.ts +24 -10
  70. package/src/activities/agent-turn/quiescence.ts +3 -0
  71. package/src/activities/agent-turn/recovery-warning.ts +18 -0
  72. package/src/activities/agent-turn/run-credentials.ts +3 -7
  73. package/src/activities/agent-turn/run.ts +69 -52
  74. package/src/activities/agent-turn/sandbox-establish.ts +10 -2
  75. package/src/activities/agent-turn/sandbox-route.ts +0 -20
  76. package/src/activities/agent-turn/sandbox-runtime.ts +40 -7
  77. package/src/activities/agent-turn/skill-remove.ts +46 -0
  78. package/src/activities/agent-turn/skill-save.ts +1 -1
  79. package/src/activities/agent-turn/skill-search.ts +1 -1
  80. package/src/activities/agent-turn/skill-selection.ts +2 -0
  81. package/src/activities/agent-turn/skill-tools.ts +10 -5
  82. package/src/activities/agent-turn/stream-attempt.ts +52 -16
  83. package/src/activities/agent-turn/tool-environment.ts +49 -29
  84. package/src/activities/agent-turn/turn-context.ts +3 -0
  85. package/src/activities/agent-turn/turn-sandbox-access.ts +7 -1
  86. package/src/activities/capabilities.ts +17 -2
  87. package/src/activities/codemode-dispatcher.ts +6 -0
  88. package/src/activities/codex-capacity.ts +38 -9
  89. package/src/activities/codex-rotation.ts +18 -5
  90. package/src/activities/context-compaction.ts +26 -4
  91. package/src/activities/goals.ts +1 -0
  92. package/src/activities/google-drive-publication.ts +1 -3
  93. package/src/activities/mcp-account-routes.ts +139 -0
  94. package/src/activities/mcp-credentials.ts +83 -194
  95. package/src/activities/mcp-operation-authority.ts +16 -41
  96. package/src/activities/parent-wake.ts +8 -0
  97. package/src/activities/rig-verification.ts +38 -37
  98. package/src/activities/run-input.ts +25 -16
  99. package/src/activities/sandbox-images.ts +0 -1
  100. package/src/activities/sandbox-lease.ts +177 -44
  101. package/src/activities/scheduled-tasks.ts +118 -93
  102. package/src/activities/session-state.ts +83 -3
  103. package/src/activities/types.ts +18 -2
  104. package/src/activities/workflow-wake.ts +2 -17
  105. package/src/editable-artifact-materializer-service.ts +7 -3
  106. package/src/editable-artifact-outbox-service.ts +4 -4
  107. package/src/github-rest-mcp.ts +0 -1
  108. package/src/index.ts +2 -1
  109. package/src/observability-metrics.ts +105 -2
  110. package/src/personal-github-git-credentials.ts +0 -1
  111. package/src/pr-review-credentials.ts +0 -2
  112. package/src/retained-process-diagnostics.ts +50 -0
  113. package/src/sandbox-resume.ts +58 -73
  114. package/src/sandbox-routing.ts +44 -19
  115. package/src/sandbox-snapshot-diagnostics.ts +112 -0
  116. package/src/warm-capture-holder.ts +15 -0
  117. package/src/workflows/session.ts +64 -2
  118. package/dist/activities/agent-turn/knowledge-sources.d.ts +0 -20
  119. package/dist/activities/packs.d.ts +0 -55
  120. package/dist/activities-control-HMFGSKC5.js.map +0 -1
  121. package/dist/activities-turn-AP67JADS.js.map +0 -1
  122. package/dist/chunk-A4XQWVZK.js.map +0 -1
  123. package/dist/chunk-CYITU5UH.js.map +0 -1
  124. package/src/activities/agent-turn/knowledge-sources.ts +0 -86
  125. package/src/activities/packs.ts +0 -166
@@ -1,47 +1,46 @@
1
1
  import type { Settings } from "@opengeni/config";
2
- import type { ConnectionCredentialsPort } from "@opengeni/contracts";
3
- import type { HostMcpAcceptedAuthority } from "@opengeni/contracts/host-mcp-bindings";
2
+ import { stableJson } from "@opengeni/contracts";
4
3
  import {
5
4
  buildConnectionTokenResolver,
6
- buildHostConnectionTokenResolver,
7
- getSessionTurnForAttempt,
8
- authorizeDirectHostMcpUse,
9
- resolveAcceptedHostMcpBinding,
10
5
  resolveAcceptedConnectionUse,
11
- sessionTenancyProductActivated,
12
6
  type Database,
13
7
  type ResolveConnectionCredentialInput,
14
8
  type ResolveConnectionCredentialResult,
15
9
  type SessionTurnForExecution,
16
10
  } from "@opengeni/db";
17
- import { recordTenancyCompatibilityLaneUse, type Observability } from "@opengeni/observability";
18
11
  import { mcpOperationAuthorityDigest } from "./mcp-operation-authority";
19
12
 
20
- const OPENGENI_CONNECTION_ID_PATTERN =
21
- /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;
22
-
23
- export function connectionTokenResolverForTurn(input: {
13
+ type TurnConnectionInput = {
24
14
  db: Database;
25
15
  settings: Settings;
26
- connectionCredentials?: ConnectionCredentialsPort | null;
27
16
  accountId: string;
28
17
  workspaceId: string;
29
18
  sessionId: string;
30
- rootSessionId: string;
31
19
  attemptId: string;
32
20
  turn: SessionTurnForExecution;
21
+ /** Policy identities before account expansion; never used to select credentials. */
22
+ canonicalMcpServerIds?: readonly string[];
33
23
  authorizeAcceptedUse?: typeof resolveAcceptedConnectionUse;
34
- /** Test seam; production always reads the canonical active-attempt projection. */
35
- getHostTurnForAttempt?: typeof getSessionTurnForAttempt;
36
- /** Test seam for the activation fence on pre-snapshot workspace refs. */
37
- isSessionTenancyProductActivated?: typeof sessionTenancyProductActivated;
38
- /** Optional; used only for content-free compatibility-lane counters. */
39
- observability?: Observability | null | undefined;
40
- }): (request: ResolveConnectionCredentialInput) => Promise<ResolveConnectionCredentialResult> {
41
- const hostResolver = input.connectionCredentials?.mcpCredentials;
42
- const readHostTurn = input.getHostTurnForAttempt ?? getSessionTurnForAttempt;
43
- const hostDb = input.db;
44
- const nativeResolver = buildConnectionTokenResolver(input.db, input.settings);
24
+ };
25
+
26
+ type CredentialResolver = (
27
+ request: ResolveConnectionCredentialInput,
28
+ ) => Promise<ResolveConnectionCredentialResult>;
29
+
30
+ export function connectionTokenResolverForTurn(input: TurnConnectionInput): CredentialResolver {
31
+ return bindNativeConnectionCredentialsToTurn(
32
+ input,
33
+ buildConnectionTokenResolver(input.db, input.settings),
34
+ );
35
+ }
36
+
37
+ /** Bind the ordinary credential resolver to one immutable accepted turn.
38
+ * Credential acquisition and refresh stay inside the native connection engine;
39
+ * this layer adds the exact execution context and physical-request checks. */
40
+ export function bindNativeConnectionCredentialsToTurn(
41
+ input: TurnConnectionInput,
42
+ nativeResolver: CredentialResolver,
43
+ ): CredentialResolver {
45
44
  const recoveryEnabled = (serverId: string) =>
46
45
  input.settings.mcpServers.some(
47
46
  (server) =>
@@ -50,84 +49,14 @@ export function connectionTokenResolverForTurn(input: {
50
49
  server.operationRecovery !== undefined &&
51
50
  Object.keys(server.operationRecovery ?? {}).length > 0,
52
51
  );
53
- const configuredResolver = hostResolver
54
- ? async (
55
- credentialRequest: ResolveConnectionCredentialInput,
56
- ): Promise<ResolveConnectionCredentialResult> => {
57
- let authorizedSnapshot: HostMcpAcceptedAuthority | undefined;
58
- const wantsDigest = recoveryEnabled(credentialRequest.serverId);
59
- const resolver = buildHostConnectionTokenResolver(hostResolver, {
60
- accountId: input.accountId,
61
- workspaceId: input.workspaceId,
62
- sessionId: input.sessionId,
63
- rootSessionId: input.rootSessionId,
64
- turnId: input.turn.id,
65
- attemptId: input.attemptId,
66
- executionGeneration: input.turn.executionGeneration,
67
- initiator: input.turn.initiator,
68
- initiatorContext: input.turn.initiatorContext,
69
- surface: "model",
70
- resolveAcceptedBinding: (request) => resolveAcceptedHostMcpBinding(hostDb, request),
71
- // Only immutable captured direct-turn authority is currently supported.
72
- // Direct, scheduled and exact causal/child snapshots are validated;
73
- // no authority follows merely from a binding or creator identity.
74
- authorizeDurableBinding: (request) =>
75
- authorizeDirectHostMcpUse(
76
- hostDb,
77
- request,
78
- wantsDigest
79
- ? (snapshot) => {
80
- authorizedSnapshot = snapshot;
81
- }
82
- : undefined,
83
- ),
84
- authorizeExecution: async (request) => {
85
- // Native UUID references already pass the accepted-use boundary below.
86
- // Legacy opaque host IDs retain their compatibility path, but not a
87
- // right to execute after their accepted attempt has stopped.
88
- if (
89
- request.connectionRef.authoritySource !== "host" &&
90
- (!request.connectionRef.connectionId ||
91
- OPENGENI_CONNECTION_ID_PATTERN.test(request.connectionRef.connectionId))
92
- )
93
- return true;
94
- if (!request.attemptId) return false;
95
- const current = await readHostTurn(
96
- hostDb,
97
- request.workspaceId,
98
- request.sessionId,
99
- request.attemptId,
100
- );
101
- return (
102
- current !== null &&
103
- current.id === request.turnId &&
104
- current.executionGeneration === request.executionGeneration
105
- );
106
- },
107
- });
108
- const result = await resolver(credentialRequest);
109
- return result.status === "ok" && authorizedSnapshot
110
- ? {
111
- ...result,
112
- operationAuthorityDigest: mcpOperationAuthorityDigest(credentialRequest, {
113
- host: authorizedSnapshot,
114
- }),
115
- }
116
- : result;
117
- }
118
- : nativeResolver;
119
- const baseResolver = (request: ResolveConnectionCredentialInput) =>
120
- input.connectionCredentials?.mcpAuthoritySource === "host" &&
121
- request.connectionRef.authoritySource !== "host"
122
- ? nativeResolver(request)
123
- : configuredResolver(request);
52
+ const canonicalMcpServerIds = new Set(
53
+ input.canonicalMcpServerIds ??
54
+ input.settings.mcpServers.filter((server) => server.connectionRef).map((server) => server.id),
55
+ );
124
56
  return async (request) => {
125
- // Host-owned refs carry explicit provenance because their opaque ids may
126
- // themselves be valid UUIDs. They never enter OpenGeni's native connection
127
- // authority or PostgreSQL UUID lookup; the bound host authorizes the exact
128
- // immutable turn context on every credential request.
57
+ // Superseded host references must never fall through to native lookup,
58
+ // even when their opaque identifier happens to be a valid native UUID.
129
59
  if (request.connectionRef.authoritySource === "host") {
130
- if (hostResolver) return await baseResolver(request);
131
60
  return {
132
61
  status: "auth_needed",
133
62
  reason: "unsupported_auth",
@@ -144,34 +73,31 @@ export function connectionTokenResolverForTurn(input: {
144
73
  : {}),
145
74
  };
146
75
  }
147
- // Before explicit provenance existed, the public embedding contract let a
148
- // bound host use any non-UUID opaque id. Preserve those frozen/stored refs
149
- // during upgrades while keeping every UUID-shaped omission on OpenGeni's
150
- // native accepted-use authority. New host refs must carry authoritySource
151
- // so UUID-shaped host ids are unambiguous.
76
+ const accountBindings = input.turn.mcpAccountBindings ?? [];
77
+ const accountBinding = accountBindings.find((binding) => binding.serverId === request.serverId);
78
+ // Canonical policy identity cannot be invoked as a credential fallback once
79
+ // this turn selected explicit account routes for that connector.
152
80
  if (
153
- hostResolver &&
154
- input.connectionCredentials?.mcpAuthoritySource !== "host" &&
155
- request.connectionRef.connectionId &&
156
- !OPENGENI_CONNECTION_ID_PATTERN.test(request.connectionRef.connectionId)
81
+ (input.turn.mcpAccountBindings != null &&
82
+ !accountBinding &&
83
+ canonicalMcpServerIds.has(request.serverId)) ||
84
+ (!accountBinding &&
85
+ accountBindings.some((binding) => binding.canonicalServerId === request.serverId)) ||
86
+ (accountBinding &&
87
+ (request.connectionRef.connectionId !== accountBinding.connectionId ||
88
+ request.connectionRef.providerDomain !== accountBinding.providerDomain ||
89
+ request.connectionRef.kind !== accountBinding.kind ||
90
+ request.connectionRef.subjectScope !== accountBinding.subjectScope ||
91
+ stableJson(request.connectionRef) !== stableJson(accountBinding.connectionRef) ||
92
+ (accountBinding.subjectScope === "subject" &&
93
+ request.subjectId !== accountBinding.ownerSubjectId)))
157
94
  ) {
158
- try {
159
- return await baseResolver(request);
160
- } catch {
161
- return {
162
- status: "auth_needed",
163
- reason: "refresh_failed",
164
- providerDomain: request.connectionRef.providerDomain,
165
- authoritySource: "host",
166
- ...(request.connectionRef.provider ? { provider: request.connectionRef.provider } : {}),
167
- connectionId: request.connectionRef.connectionId,
168
- ...(request.connectionRef.scopes ? { scopes: request.connectionRef.scopes } : {}),
169
- ...(request.connectionRef.resource ? { resource: request.connectionRef.resource } : {}),
170
- ...(request.connectionRef.selectedResources
171
- ? { selectedResources: request.connectionRef.selectedResources }
172
- : {}),
173
- };
174
- }
95
+ return {
96
+ status: "auth_needed",
97
+ reason: "personal_authority_unavailable",
98
+ providerDomain: request.connectionRef.providerDomain,
99
+ ...(request.connectionRef.provider ? { provider: request.connectionRef.provider } : {}),
100
+ };
175
101
  }
176
102
  const acceptedDelegation = input.turn.personalConnectionDelegations.find(
177
103
  (delegation) =>
@@ -191,9 +117,7 @@ export function connectionTokenResolverForTurn(input: {
191
117
  const subjectScope: "subject" | "workspace" =
192
118
  request.connectionRef.subjectScope === "subject" ? "subject" : "workspace";
193
119
  // Every subject-scoped request must match an exact connection frozen on the
194
- // accepted turn. This also hard-fences pre-cutover common-user turns that
195
- // lack a userDelegation: the DB resolver denies those rows because only a
196
- // true legacy_user connection is eligible for bounded compatibility.
120
+ // accepted turn. The database then checks its immutable sender snapshot.
197
121
  if (
198
122
  subjectScope === "subject" &&
199
123
  (!acceptedDelegation || !request.connectionRef.connectionId)
@@ -205,31 +129,15 @@ export function connectionTokenResolverForTurn(input: {
205
129
  ...(request.connectionRef.provider ? { provider: request.connectionRef.provider } : {}),
206
130
  };
207
131
  }
208
- // Workspace-scope requests now run through the same accepted-use authority
209
- // (migration 0279): the exact workspace-owned connection is revalidated
210
- // inside the canonical lifecycle fences and every use leaves an idempotent
211
- // audit fact. A ref with no connection id is the bounded pre-snapshot
212
- // legacy path - it cannot be authorized by exact identity, so it keeps the
213
- // unprivileged resolution the old short-circuit used.
132
+ // Workspace connections also need an exact identity for accepted-use
133
+ // validation and attribution. Never rediscover a credential by domain here.
214
134
  if (subjectScope === "workspace" && !request.connectionRef.connectionId) {
215
- if (
216
- await (input.isSessionTenancyProductActivated ?? sessionTenancyProductActivated)(
217
- input.db,
218
- input.workspaceId,
219
- )
220
- ) {
221
- return {
222
- status: "auth_needed",
223
- reason: "missing_connection",
224
- providerDomain: request.connectionRef.providerDomain,
225
- ...(request.connectionRef.provider ? { provider: request.connectionRef.provider } : {}),
226
- };
227
- }
228
- // This lane writes no `connection_use_audit_facts` row, so this counter is
229
- // the only evidence it was taken. Lane name only - never the server,
230
- // provider domain, connection, or subject.
231
- recordTenancyCompatibilityLaneUse(input.observability, "connection_pre_snapshot_ref");
232
- return await baseResolver(request);
135
+ return {
136
+ status: "auth_needed",
137
+ reason: "missing_connection",
138
+ providerDomain: request.connectionRef.providerDomain,
139
+ ...(request.connectionRef.provider ? { provider: request.connectionRef.provider } : {}),
140
+ };
233
141
  }
234
142
  const credentialUseContext = {
235
143
  accountId: input.accountId,
@@ -299,50 +207,31 @@ export function connectionTokenResolverForTurn(input: {
299
207
  },
300
208
  };
301
209
  };
302
- // One place records the `legacy_user` lane for both resolution paths: the
303
- // scope comes back on the resolver result when the DB resolver authorized
304
- // internally, and on the resolution itself when the host resolver did.
305
- const recordAuthorizedScope = (scope: "workspace" | "user" | "legacy_user" | undefined) => {
306
- if (scope === "legacy_user") {
307
- recordTenancyCompatibilityLaneUse(input.observability, "connection_legacy_user");
308
- }
309
- };
310
- if (!hostResolver) {
311
- const result = await baseResolver({
312
- ...request,
313
- connectionUseContext: credentialUseContext,
314
- });
315
- if (result.status === "ok") recordAuthorizedScope(result.connectionUseAttribution?.scope);
316
- return withProviderRequestAuthorization(result);
317
- }
318
- const authorization = await authorize(credentialUseContext);
319
- if (authorization.status === "denied") {
210
+ const { subjectId: requestSubjectId, ...requestWithoutSubject } = request;
211
+ const result = await nativeResolver({
212
+ ...requestWithoutSubject,
213
+ ...(accountBinding?.connectionAuthorityGeneration !== undefined
214
+ ? { expectedAuthorityGeneration: accountBinding.connectionAuthorityGeneration }
215
+ : {}),
216
+ // Workspace authority has no personal owner, even when the turn has a
217
+ // causal human. Do not pass that human as credential ownership context.
218
+ ...(accountBinding?.subjectScope !== "workspace" && requestSubjectId !== undefined
219
+ ? { subjectId: requestSubjectId }
220
+ : {}),
221
+ connectionUseContext: credentialUseContext,
222
+ });
223
+ if (
224
+ accountBinding &&
225
+ result.status === "ok" &&
226
+ result.connectionId !== accountBinding.connectionId
227
+ ) {
320
228
  return {
321
229
  status: "auth_needed",
322
- reason:
323
- request.connectionRef.subjectScope === "subject"
324
- ? "personal_authority_unavailable"
325
- : "missing_connection",
326
- providerDomain: request.connectionRef.providerDomain,
327
- ...(request.connectionRef.provider ? { provider: request.connectionRef.provider } : {}),
230
+ reason: "personal_authority_unavailable",
231
+ providerDomain: accountBinding.providerDomain,
328
232
  };
329
233
  }
330
- recordAuthorizedScope(authorization.attribution.scope);
331
- const result = await baseResolver({
332
- ...request,
333
- connectionUseContext: credentialUseContext,
334
- connectionUseAuthority: authorization.attribution,
335
- connectionRef: {
336
- ...request.connectionRef,
337
- connectionId: authorization.attribution.connectionId,
338
- kind: authorization.connectionKind,
339
- subjectScope: authorization.attribution.scope === "workspace" ? "workspace" : "subject",
340
- },
341
- ...(authorization.attribution.ownerSubjectId
342
- ? { subjectId: authorization.attribution.ownerSubjectId }
343
- : {}),
344
- });
345
- return withProviderRequestAuthorization(result, authorization.attribution);
234
+ return withProviderRequestAuthorization(result);
346
235
  };
347
236
  }
348
237
 
@@ -1,23 +1,18 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { stableJson } from "@opengeni/contracts";
3
3
  import type { ConnectionUseAttribution } from "@opengeni/contracts/connection-authority";
4
- import type { HostMcpAcceptedAuthority } from "@opengeni/contracts/host-mcp-bindings";
5
4
  import type { ResolveConnectionCredentialInput } from "@opengeni/db";
6
5
 
7
6
  /** Metadata only. Callers must obtain authority from a current live fence.
8
7
  * This equality key is never authorization and never replaces physical-use checks. */
9
8
  export function mcpOperationAuthorityDigest(
10
9
  request: ResolveConnectionCredentialInput,
11
- authority:
12
- | {
13
- native: ConnectionUseAttribution;
14
- host?: never;
15
- principal?: { kind: string; subjectId?: string };
16
- }
17
- | { host: HostMcpAcceptedAuthority; native?: never },
10
+ authority: {
11
+ native: ConnectionUseAttribution;
12
+ principal?: { kind: string; subjectId?: string };
13
+ },
18
14
  ): string {
19
15
  const n = authority.native;
20
- const h = authority.host;
21
16
  const ref = request.connectionRef;
22
17
  const metadata = {
23
18
  version: 1,
@@ -31,7 +26,6 @@ export function mcpOperationAuthorityDigest(
31
26
  providerDomain: ref.providerDomain,
32
27
  kind: ref.kind,
33
28
  subjectScope: ref.subjectScope,
34
- hostBinding: ref.hostBinding,
35
29
  scopes: ref.scopes ? [...ref.scopes].sort() : undefined,
36
30
  resource: ref.resource,
37
31
  selectedResources: ref.selectedResources
@@ -40,37 +34,18 @@ export function mcpOperationAuthorityDigest(
40
34
  )
41
35
  : undefined,
42
36
  },
43
- native: n
44
- ? {
45
- organizationId: n.organizationId,
46
- workspaceId: n.workspaceId,
47
- sessionId: n.sessionId,
48
- connectionId: n.connectionId,
49
- connectionGeneration: n.connectionGeneration,
50
- scope: n.scope,
51
- ownerSubjectId: n.ownerSubjectId,
52
- authorityId: n.authorityId,
53
- grantId: n.grantId,
54
- principal: "principal" in authority ? authority.principal : undefined,
55
- }
56
- : undefined,
57
- host: h
58
- ? {
59
- accountId: h.accountId,
60
- workspaceId: h.workspaceId,
61
- targetSessionId: h.targetSessionId,
62
- targetSessionVisibility: h.targetSessionVisibility,
63
- targetSessionAuthorityEpoch: h.targetSessionAuthorityEpoch,
64
- ownerSubjectId: h.ownerSubjectId,
65
- ownerOrganizationMembershipId: h.ownerOrganizationMembershipId,
66
- ownerMembershipAuthorizationRevision: h.ownerMembershipAuthorizationRevision,
67
- bindingId: h.bindingId,
68
- bindingGeneration: h.bindingGeneration,
69
- definition: h.definition,
70
- delegationId: h.delegationId,
71
- delegationGeneration: h.delegationGeneration,
72
- }
73
- : undefined,
37
+ native: {
38
+ organizationId: n.organizationId,
39
+ workspaceId: n.workspaceId,
40
+ sessionId: n.sessionId,
41
+ connectionId: n.connectionId,
42
+ connectionGeneration: n.connectionGeneration,
43
+ scope: n.scope,
44
+ ownerSubjectId: n.ownerSubjectId,
45
+ authorityId: n.authorityId,
46
+ grantId: n.grantId,
47
+ principal: authority.principal,
48
+ },
74
49
  };
75
50
  return createHash("sha256").update(stableJson(metadata)).digest("hex");
76
51
  }
@@ -4,6 +4,7 @@ import {
4
4
  getSession,
5
5
  getSessionGoal,
6
6
  getSessionParentPersonalConnectionDelegations,
7
+ getSessionParentMcpAccountBindings,
7
8
  getSessionParentXaiProviderAccountAuthority,
8
9
  addSessionSystemUpdateWithSourceMutation,
9
10
  claimPendingSessionSystemUpdateOutbox,
@@ -75,6 +76,11 @@ export async function notifyParentOfChildIdle(
75
76
  workspaceId,
76
77
  childSessionId,
77
78
  );
79
+ const mcpAccountBindings = await getSessionParentMcpAccountBindings(
80
+ svc.db,
81
+ workspaceId,
82
+ childSessionId,
83
+ );
78
84
  const xaiAuthority = await getSessionParentXaiProviderAccountAuthority(
79
85
  svc.db,
80
86
  workspaceId,
@@ -97,6 +103,7 @@ export async function notifyParentOfChildIdle(
97
103
  ...(xaiAuthority.subjectId ? { xaiAuthoritySubjectId: xaiAuthority.subjectId } : {}),
98
104
  },
99
105
  personalConnectionDelegations,
106
+ mcpAccountBindings,
100
107
  xaiProviderAccountAuthoritySnapshot: xaiAuthority.snapshot,
101
108
  });
102
109
  if (outbox.status === "delivered") {
@@ -214,6 +221,7 @@ async function deliverParentSystemUpdateOutbox(
214
221
  summary: outbox.summary,
215
222
  lineage: outbox.lineage,
216
223
  personalConnectionDelegations: outbox.personalConnectionDelegations,
224
+ mcpAccountBindings: outbox.mcpAccountBindings,
217
225
  xaiProviderAccountAuthoritySnapshot: outbox.xaiProviderAccountAuthoritySnapshot,
218
226
  },
219
227
  async (tx) => {