@opengeni/worker-bundle 2.0.0 → 2.0.1

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.
@@ -13,6 +13,7 @@ import type { loadWorkspaceEnvironmentForRunWithCredentials, sandboxEnvironmentF
13
13
  import type { AttemptIdentityState, EventingState, ProviderTurnState, SandboxRuntimeState } from "./turn-context.js";
14
14
  export type BuildTurnAgentDeps = {
15
15
  skillCatalog: NonNullable<BuildAgentOptions["skillCatalog"]>;
16
+ mcpServers: Settings["mcpServers"];
16
17
  input: RunAgentTurnInput;
17
18
  db: ActivityServices["db"];
18
19
  runtime: ActivityServices["runtime"];
@@ -125,6 +125,40 @@ export declare function prepareTurnToolPolicy(deps: PrepareTurnToolPolicyDeps):
125
125
  export declare function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps): Promise<{
126
126
  attemptConnectorActionBindings: AttemptConnectorActionBinding[];
127
127
  connectorActionPolicy: ConnectorActionPolicyHooks;
128
+ mcpServers: {
129
+ id: string;
130
+ name?: string | undefined;
131
+ url: string;
132
+ allowedTools?: string[] | undefined;
133
+ timeoutMs?: number | undefined;
134
+ cacheToolsList: boolean;
135
+ requireApproval?: boolean | string[] | undefined;
136
+ headers?: Record<string, string> | undefined;
137
+ connectionRef?: {
138
+ connectionId?: string | undefined;
139
+ accountSelection?: "all_eligible" | undefined;
140
+ authoritySource?: "host" | undefined;
141
+ hostBinding?: {
142
+ bindingId: string;
143
+ generation: number;
144
+ } | {
145
+ selection: "accepted_turn";
146
+ } | undefined;
147
+ provider?: string | undefined;
148
+ providerDomain: string;
149
+ kind?: "api_key" | "app_install" | "delegated" | "oauth2" | undefined;
150
+ scopes?: string[] | undefined;
151
+ resource?: string | undefined;
152
+ selectedResources?: {
153
+ id: string;
154
+ kind: "repository";
155
+ }[] | undefined;
156
+ subjectScope?: "subject" | "workspace" | undefined;
157
+ } | undefined;
158
+ operationRecovery?: Record<string, {
159
+ observerTool: string;
160
+ }> | undefined;
161
+ }[];
128
162
  generateSessionTitleInParallel: boolean;
129
163
  postToolPreparationStartedAt: number;
130
164
  preparationIndependentToolNames: string[];
@@ -1,4 +1,5 @@
1
1
  import { type AttemptToolEnvironment } from "@opengeni/codemode";
2
+ import { type ToolDisplayMetadata } from "@opengeni/contracts";
2
3
  import { type Database } from "@opengeni/db";
3
4
  import { type EventBus } from "@opengeni/events";
4
5
  export type CodemodeDispatcherScope = {
@@ -25,6 +26,7 @@ export declare class CodemodeAttemptDispatcher {
25
26
  private readonly scope;
26
27
  private readonly turnSignal?;
27
28
  private readonly maxConcurrentCalls;
29
+ private readonly toolDisplayMetadata?;
28
30
  private readonly stopController;
29
31
  private readonly inFlight;
30
32
  private pendingClaims;
@@ -32,7 +34,7 @@ export declare class CodemodeAttemptDispatcher {
32
34
  private closing;
33
35
  private readonly claimLeaseMs;
34
36
  private readonly claimHeartbeatMs;
35
- constructor(db: Database, bus: EventBus, environment: AttemptToolEnvironment, scope: CodemodeDispatcherScope, turnSignal?: AbortSignal | undefined, maxConcurrentCalls?: number, timings?: CodemodeDispatcherTimings);
37
+ constructor(db: Database, bus: EventBus, environment: AttemptToolEnvironment, scope: CodemodeDispatcherScope, turnSignal?: AbortSignal | undefined, maxConcurrentCalls?: number, timings?: CodemodeDispatcherTimings, toolDisplayMetadata?: ((modelName: string) => ToolDisplayMetadata | undefined) | undefined);
36
38
  start(): void;
37
39
  close(reason?: string): Promise<void>;
38
40
  private execute;
@@ -33,7 +33,7 @@ import {
33
33
  warnDrainSnapshotFailure,
34
34
  withFirstPartyTools,
35
35
  workflowIdForSession
36
- } from "./chunk-TVEE2UUC.js";
36
+ } from "./chunk-M3NVMF2V.js";
37
37
  import {
38
38
  inspectOpenSandboxKubernetesInventory,
39
39
  recordCreditBalanceGauges,
@@ -7498,4 +7498,4 @@ export {
7498
7498
  createControlActivities,
7499
7499
  createControlActivitiesFromServices
7500
7500
  };
7501
- //# sourceMappingURL=activities-control-BOLIY3H4.js.map
7501
+ //# sourceMappingURL=activities-control-QA6OLRQY.js.map
@@ -86,7 +86,7 @@ import {
86
86
  withFirstPartyTools,
87
87
  wrapLazyTurnBoxWithRouting,
88
88
  wrapTurnBoxWithRouting
89
- } from "./chunk-TVEE2UUC.js";
89
+ } from "./chunk-M3NVMF2V.js";
90
90
  import {
91
91
  StreamTimingMetrics,
92
92
  makeMachineOpObserver,
@@ -6994,6 +6994,7 @@ import { publishDurableSessionEvents as publishDurableSessionEvents3 } from "@op
6994
6994
  import {
6995
6995
  normalizeModelCallUsage as normalizeModelCallUsage2,
6996
6996
  normalizeSdkEvent,
6997
+ withMcpToolDisplayMetadata,
6997
6998
  extractOpenSuffixFromRunState,
6998
6999
  assertOpenSuffixResumable,
6999
7000
  interruptionKindForCallItem,
@@ -8824,6 +8825,11 @@ async function runTurnStreamAttempt(deps) {
8824
8825
  } : {}
8825
8826
  );
8826
8827
  for (const event of normalized) {
8828
+ if (event.type === "agent.toolCall.created")
8829
+ event.payload = withMcpToolDisplayMetadata(
8830
+ eventing.preparedTools?.mcpServers ?? [],
8831
+ event.payload
8832
+ );
8827
8833
  streamTiming.onEvent(event.type);
8828
8834
  await eventing.batcher.push(event);
8829
8835
  }
@@ -9113,7 +9119,14 @@ async function runTurnStreamAttempt(deps) {
9113
9119
  ...approvals.length > 0 ? [
9114
9120
  {
9115
9121
  type: "session.requiresAction",
9116
- payload: { approvals }
9122
+ payload: {
9123
+ approvals: approvals.map(
9124
+ (approval) => withMcpToolDisplayMetadata(
9125
+ eventing.preparedTools?.mcpServers ?? [],
9126
+ approval
9127
+ )
9128
+ )
9129
+ }
9117
9130
  }
9118
9131
  ] : [],
9119
9132
  {
@@ -9407,6 +9420,7 @@ import { appendAndPublishTurnEventsFenced as appendAndPublishTurnEventsFenced2,
9407
9420
  import { linkCurrentSpanToAdmission, turnExecutionTelemetryKey } from "@opengeni/observability";
9408
9421
  import {
9409
9422
  assertTurnExecutionPolicyMatchesConfigV1,
9423
+ settingsForAcceptedSubscriptionTurn,
9410
9424
  resolveTurnExecutionPolicyV1 as resolveTurnExecutionPolicyV12
9411
9425
  } from "@opengeni/config";
9412
9426
 
@@ -9730,7 +9744,7 @@ async function claimTurnAttempt(deps) {
9730
9744
  gatewaySettings,
9731
9745
  claimedPolicy.kind === "valid" ? claimedPolicy.policy.productModelId : turn.model
9732
9746
  );
9733
- const capabilitySettings = await settingsWithOrganizationProviderCredentials(
9747
+ let capabilitySettings = await settingsWithOrganizationProviderCredentials(
9734
9748
  db,
9735
9749
  input.accountId,
9736
9750
  input.workspaceId,
@@ -9738,7 +9752,6 @@ async function claimTurnAttempt(deps) {
9738
9752
  claimedPolicy.kind === "valid" ? claimedPolicy.policy.productModelId : turn.model
9739
9753
  );
9740
9754
  const codexAppsCredentialId = capabilitySettings.codexConnectedAppsEnabled ? await resolveCodexAppsCredentialIdForRun(db, input.workspaceId) : null;
9741
- runtime.configure(capabilitySettings);
9742
9755
  const policyForAbsent = claimedPolicy.kind === "valid" ? claimedPolicy.policy : resolveTurnExecutionPolicyV12(capabilitySettings, legacyTurnExecutionPolicyInput(turn));
9743
9756
  const installedPolicy = await installOrReadTurnExecutionPolicyForAttempt(db, {
9744
9757
  accountId: input.accountId,
@@ -9752,6 +9765,16 @@ async function claimTurnAttempt(deps) {
9752
9765
  if (!installedPolicy.accepted) {
9753
9766
  throw new TurnAttemptFencedError(`turn execution policy was fenced: ${installedPolicy.reason}`);
9754
9767
  }
9768
+ capabilitySettings = settingsForAcceptedSubscriptionTurn(
9769
+ capabilitySettings,
9770
+ installedPolicy.policy,
9771
+ {
9772
+ modelId: turn.model,
9773
+ reasoningEffort: turn.reasoningEffort,
9774
+ latencyMode: turn.latencyMode
9775
+ }
9776
+ );
9777
+ runtime.configure(capabilitySettings);
9755
9778
  const verifiedExecutionPolicy = assertTurnExecutionPolicyMatchesConfigV1(
9756
9779
  capabilitySettings,
9757
9780
  installedPolicy.policy,
@@ -14684,7 +14707,8 @@ import {
14684
14707
  } from "@opengeni/db";
14685
14708
  import { publishDurableSessionEvents as publishDurableSessionEvents9 } from "@opengeni/events";
14686
14709
  import {
14687
- createFirstPartyInteractionAttemptToolDefinitions
14710
+ createFirstPartyInteractionAttemptToolDefinitions,
14711
+ mcpToolDisplayMetadata
14688
14712
  } from "@opengeni/runtime";
14689
14713
 
14690
14714
  // src/activities/google-drive-publication.ts
@@ -30932,13 +30956,14 @@ import {
30932
30956
  publishDurableSessionEvents as publishDurableSessionEvents8
30933
30957
  } from "@opengeni/events";
30934
30958
  var CodemodeAttemptDispatcher = class {
30935
- constructor(db, bus, environment, scope, turnSignal, maxConcurrentCalls = CODEMODE_MAX_CONCURRENT_CALLS_PER_ATTEMPT, timings = {}) {
30959
+ constructor(db, bus, environment, scope, turnSignal, maxConcurrentCalls = CODEMODE_MAX_CONCURRENT_CALLS_PER_ATTEMPT, timings = {}, toolDisplayMetadata) {
30936
30960
  this.db = db;
30937
30961
  this.bus = bus;
30938
30962
  this.environment = environment;
30939
30963
  this.scope = scope;
30940
30964
  this.turnSignal = turnSignal;
30941
30965
  this.maxConcurrentCalls = maxConcurrentCalls;
30966
+ this.toolDisplayMetadata = toolDisplayMetadata;
30942
30967
  if (environment.catalog.accountId !== scope.accountId || environment.catalog.workspaceId !== scope.workspaceId || environment.catalog.sessionId !== scope.sessionId || environment.catalog.turnId !== scope.turnId || environment.catalog.attemptId !== scope.attemptId || environment.catalog.executionGeneration !== scope.executionGeneration) {
30943
30968
  throw new Error("Codemode dispatcher scope does not match its tool environment");
30944
30969
  }
@@ -31196,6 +31221,10 @@ var CodemodeAttemptDispatcher = class {
31196
31221
  payload: {
31197
31222
  id: operation.operationId,
31198
31223
  name: entry.modelName,
31224
+ display: this.toolDisplayMetadata?.(entry.modelName) ?? {
31225
+ toolName: entry.identity.toolName,
31226
+ ...entry.title ? { title: entry.title } : {}
31227
+ },
31199
31228
  arguments: operation.arguments,
31200
31229
  origin: "codemode",
31201
31230
  subjectId: operation.caller.subjectId,
@@ -32957,7 +32986,10 @@ async function prepareTurnToolRuntime(deps) {
32957
32986
  attemptId: input.attemptId,
32958
32987
  executionGeneration: attempt.executionGeneration
32959
32988
  },
32960
- cancellationSignal
32989
+ cancellationSignal,
32990
+ void 0,
32991
+ {},
32992
+ (name) => mcpToolDisplayMetadata(tools.mcpServers, name)
32961
32993
  );
32962
32994
  eventing.codemodeDispatcher.start();
32963
32995
  };
@@ -32973,6 +33005,7 @@ async function prepareTurnToolRuntime(deps) {
32973
33005
  return {
32974
33006
  attemptConnectorActionBindings,
32975
33007
  connectorActionPolicy,
33008
+ mcpServers: runSettings.mcpServers,
32976
33009
  generateSessionTitleInParallel: titleToolPlan.generateTitleInParallel,
32977
33010
  postToolPreparationStartedAt,
32978
33011
  preparationIndependentToolNames: [
@@ -34348,6 +34381,7 @@ async function resolveVideoReferenceSandboxAccess(request, sandboxState, sdkOwne
34348
34381
  // src/activities/agent-turn/agent-build.ts
34349
34382
  async function buildTurnAgent(deps) {
34350
34383
  const {
34384
+ mcpServers,
34351
34385
  input,
34352
34386
  db,
34353
34387
  runtime,
@@ -34765,7 +34799,7 @@ async function buildTurnAgent(deps) {
34765
34799
  const agentConstructionStartedAt = performance.now();
34766
34800
  let agentConstructionOutcome = "completed";
34767
34801
  try {
34768
- return runtime.buildAgent(eventing.modelRunSettings, runtimeResources, {
34802
+ return runtime.buildAgent({ ...eventing.modelRunSettings, mcpServers }, runtimeResources, {
34769
34803
  ...linkedToolAuthority ? {
34770
34804
  authorizeAttemptExecution: async () => {
34771
34805
  const current = await getSessionTurnForAttempt2(
@@ -35942,6 +35976,7 @@ These are publication receipts for the human's earlier answer. Do not call the r
35942
35976
  } = toolRuntime;
35943
35977
  const builtAgent = await buildTurnAgent({
35944
35978
  skillCatalog: toolRuntime.skillCatalog,
35979
+ mcpServers: toolRuntime.mcpServers,
35945
35980
  input,
35946
35981
  db,
35947
35982
  runtime,
@@ -37498,4 +37533,4 @@ export {
37498
37533
  createTurnActivities,
37499
37534
  createTurnActivitiesFromServices
37500
37535
  };
37501
- //# sourceMappingURL=activities-turn-2B3WMHBB.js.map
37536
+ //# sourceMappingURL=activities-turn-YVVKCGAK.js.map