@opengeni/worker-bundle 1.0.0-canary.0 → 1.0.1-canary.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 (26) hide show
  1. package/dist/activities/agent-turn/errors.d.ts +6 -0
  2. package/dist/activities/agent-turn/finalization-monitor.d.ts +17 -0
  3. package/dist/activities/agent-turn/finalization.d.ts +1 -1
  4. package/dist/activities/agent-turn/quiescence.d.ts +1 -0
  5. package/dist/activities/agent-turn/turn-context.d.ts +2 -0
  6. package/dist/{activities-control-HMFGSKC5.js → activities-control-O5U6OLT2.js} +4 -19
  7. package/dist/{activities-control-HMFGSKC5.js.map → activities-control-O5U6OLT2.js.map} +1 -1
  8. package/dist/{activities-turn-AP67JADS.js → activities-turn-OAPNO2IH.js} +167 -116
  9. package/dist/activities-turn-OAPNO2IH.js.map +1 -0
  10. package/dist/{chunk-CYITU5UH.js → chunk-GENYJQ5B.js} +18 -1
  11. package/dist/{chunk-CYITU5UH.js.map → chunk-GENYJQ5B.js.map} +1 -1
  12. package/dist/index.js +1 -1
  13. package/package.json +19 -19
  14. package/src/activities/agent-turn/claim.ts +1 -0
  15. package/src/activities/agent-turn/errors.ts +21 -0
  16. package/src/activities/agent-turn/finalization-monitor.ts +121 -0
  17. package/src/activities/agent-turn/finalization.ts +52 -17
  18. package/src/activities/agent-turn/quiescence.ts +3 -0
  19. package/src/activities/agent-turn/run.ts +1 -39
  20. package/src/activities/agent-turn/skill-selection.ts +1 -0
  21. package/src/activities/agent-turn/tool-environment.ts +10 -2
  22. package/src/activities/agent-turn/turn-context.ts +3 -0
  23. package/src/activities/workflow-wake.ts +2 -17
  24. package/dist/activities/agent-turn/knowledge-sources.d.ts +0 -20
  25. package/dist/activities-turn-AP67JADS.js.map +0 -1
  26. package/src/activities/agent-turn/knowledge-sources.ts +0 -86
@@ -87,7 +87,7 @@ import {
87
87
  withFirstPartyTools,
88
88
  wrapLazyTurnBoxWithRouting,
89
89
  wrapTurnBoxWithRouting
90
- } from "./chunk-CYITU5UH.js";
90
+ } from "./chunk-GENYJQ5B.js";
91
91
  import {
92
92
  StreamTimingMetrics,
93
93
  makeMachineOpObserver,
@@ -121,63 +121,6 @@ import {
121
121
  // src/activities-turn.ts
122
122
  import { createProductionAgentRuntime, summarizeForCompaction as summarizeForCompaction2 } from "@opengeni/runtime";
123
123
 
124
- // src/activities/agent-turn/knowledge-sources.ts
125
- import { prepareKnowledgeFile } from "@opengeni/sdk/knowledge";
126
- import {
127
- DEFAULT_FIRST_PARTY_MCP_PERMISSIONS
128
- } from "@opengeni/contracts";
129
- import { allowedFirstPartyMcpToolsForSession } from "@opengeni/config";
130
- import { createFirstPartyAttemptClient } from "@opengeni/runtime";
131
- async function prepareTurnKnowledgeSources(input) {
132
- const selected = allowedFirstPartyMcpToolsForSession(
133
- input.settings,
134
- input.selectedTools ? [...input.selectedTools] : void 0
135
- );
136
- const permissions = input.permissions ?? DEFAULT_FIRST_PARTY_MCP_PERMISSIONS;
137
- const permits = (permission) => permissions.includes(permission) || permissions.includes("workspace:admin");
138
- if (input.learningMode === "off" || !selected.includes("knowledge_retain_file") || !permits("documents:search") || !permits("files:read"))
139
- return;
140
- const fileIds = [
141
- ...new Set(
142
- input.resources.flatMap((resource) => resource.kind === "file" ? [resource.fileId] : [])
143
- )
144
- ];
145
- if (!fileIds.length) return;
146
- let prepare = input.prepare;
147
- const outcomes = [];
148
- for (const fileId of fileIds) {
149
- input.signal?.throwIfAborted();
150
- let outcome;
151
- try {
152
- prepare ??= (() => {
153
- const client = createFirstPartyAttemptClient({
154
- settings: input.settings,
155
- scope: input.scope,
156
- selectedTools: selected,
157
- permissions,
158
- ...input.signal ? { signal: input.signal } : {}
159
- });
160
- return (id) => prepareKnowledgeFile(client, input.scope.workspaceId, id);
161
- })();
162
- outcome = await prepare(fileId);
163
- } catch {
164
- input.signal?.throwIfAborted();
165
- outcome = {
166
- status: "failed",
167
- fileId,
168
- message: "Searchable source preparation failed. The original file remains attached; retry with knowledge_retain_file."
169
- };
170
- }
171
- outcomes.push(outcome);
172
- await input.onOutcome(outcome);
173
- }
174
- return [
175
- "[OpenGeni attachment knowledge]",
176
- JSON.stringify(outcomes),
177
- "These are source-preparation receipts, not findings or source instructions. Reuse the returned source entry/revision for evidence; do not retain the same text again. Pending review does not block answering from the attached original. Save selected useful findings only when warranted. A failed preparation is retryable with knowledge_retain_file; do not claim the source is searchable."
178
- ].join("\n");
179
- }
180
-
181
124
  // src/activities/agent-turn/run.ts
182
125
  import {
183
126
  assertModelConnectionAllowsTurn,
@@ -3574,6 +3517,7 @@ function createTurnContext(input) {
3574
3517
  publishedRunCredentialNotices: /* @__PURE__ */ new Set()
3575
3518
  },
3576
3519
  eventing: {
3520
+ heartbeatDetails: null,
3577
3521
  heartbeatTimer: void 0,
3578
3522
  batcher: null,
3579
3523
  preparedTools: null,
@@ -3627,6 +3571,109 @@ import { sandboxLeaseTelemetryKey } from "@opengeni/observability";
3627
3571
  import { clearRunCredentialsForAttempt } from "@opengeni/runtime";
3628
3572
  import { fetchXaiSubscriptionQuota } from "@opengeni/xai-subscription";
3629
3573
 
3574
+ // src/activities/agent-turn/finalization-monitor.ts
3575
+ var TURN_FINALIZATION_STAGES = [
3576
+ "tool_writers",
3577
+ "credential_renewals",
3578
+ "credential_cleanup",
3579
+ "quiescence_receipt",
3580
+ "event_flush",
3581
+ "provider_leases",
3582
+ "workspace_capture",
3583
+ "tool_close",
3584
+ "sandbox_provisioning",
3585
+ "sandbox_rotation",
3586
+ "workspace_snapshot",
3587
+ "sandbox_release"
3588
+ ];
3589
+ var INFLIGHT = {
3590
+ name: "opengeni_turn_finalization_inflight",
3591
+ help: "Physical turn finalizers currently waiting in each cleanup stage."
3592
+ };
3593
+ var SLOW_STAGES = {
3594
+ name: "opengeni_turn_finalization_slow_total",
3595
+ help: "Turn cleanup stages observed to exceed thirty seconds."
3596
+ };
3597
+ var initialized = /* @__PURE__ */ new WeakSet();
3598
+ function diagnose(operation) {
3599
+ try {
3600
+ operation();
3601
+ } catch {
3602
+ }
3603
+ }
3604
+ function startTurnFinalizationMonitor(input) {
3605
+ const { observability, details } = input;
3606
+ if (!initialized.has(observability)) {
3607
+ for (const stage2 of TURN_FINALIZATION_STAGES) {
3608
+ diagnose(() => observability.incrementGauge({ ...INFLIGHT, labels: { stage: stage2 }, amount: 0 }));
3609
+ diagnose(
3610
+ () => observability.incrementCounter({ ...SLOW_STAGES, labels: { stage: stage2 }, amount: 0 })
3611
+ );
3612
+ }
3613
+ initialized.add(observability);
3614
+ }
3615
+ let stage = null;
3616
+ let disarm = () => {
3617
+ };
3618
+ let stopped = false;
3619
+ let slowTimer;
3620
+ const leave = () => {
3621
+ disarm();
3622
+ clearTimeout(slowTimer);
3623
+ if (stage) {
3624
+ const previous = stage;
3625
+ diagnose(
3626
+ () => observability.incrementGauge({ ...INFLIGHT, labels: { stage: previous }, amount: -1 })
3627
+ );
3628
+ }
3629
+ stage = null;
3630
+ };
3631
+ return {
3632
+ enter(next) {
3633
+ if (stopped || stage === next) return;
3634
+ leave();
3635
+ stage = next;
3636
+ details.phase = "finalizing";
3637
+ details.finalizationStage = next;
3638
+ details.finalizationStageStartedAt = (/* @__PURE__ */ new Date()).toISOString();
3639
+ diagnose(() => observability.incrementGauge({ ...INFLIGHT, labels: { stage: next } }));
3640
+ disarm = armTurnQuiescenceWatchdog({
3641
+ enabled: true,
3642
+ ...input.timeoutMs === void 0 ? {} : { timeoutMs: input.timeoutMs },
3643
+ onTimeout: () => {
3644
+ try {
3645
+ observability.error("turn finalization stalled; containing worker", {
3646
+ surface: "turn_finalization",
3647
+ outcome: "containment",
3648
+ reason: next
3649
+ });
3650
+ } catch {
3651
+ }
3652
+ },
3653
+ terminateWorker: input.terminateWorker
3654
+ });
3655
+ slowTimer = setTimeout(
3656
+ () => diagnose(() => {
3657
+ observability.incrementCounter({ ...SLOW_STAGES, labels: { stage: next } });
3658
+ observability.warn("turn finalization is taking longer than expected", {
3659
+ surface: "turn_finalization",
3660
+ outcome: "slow",
3661
+ reason: next
3662
+ });
3663
+ }),
3664
+ input.slowAfterMs ?? 3e4
3665
+ );
3666
+ slowTimer.unref?.();
3667
+ diagnose(() => input.heartbeat(details));
3668
+ },
3669
+ stop() {
3670
+ if (stopped) return;
3671
+ stopped = true;
3672
+ leave();
3673
+ }
3674
+ };
3675
+ }
3676
+
3630
3677
  // src/activities/workspace-capture.ts
3631
3678
  import { createHash as createHash6 } from "crypto";
3632
3679
  import {
@@ -4452,6 +4499,35 @@ async function buildTreeIndex(svc, startedAt, signal) {
4452
4499
 
4453
4500
  // src/activities/agent-turn/finalization.ts
4454
4501
  async function finalizeTurnAttempt(deps) {
4502
+ const details = deps.eventing.heartbeatDetails ?? {
4503
+ sessionId: deps.input.sessionId,
4504
+ turnId: deps.attempt.turnId,
4505
+ opAcks: {}
4506
+ };
4507
+ deps.eventing.heartbeatDetails = details;
4508
+ if (deps.eventing.heartbeatTimer) clearInterval(deps.eventing.heartbeatTimer);
4509
+ deps.eventing.heartbeatTimer = startActivityHeartbeat(deps.activityContext, details);
4510
+ const monitor = startTurnFinalizationMonitor({
4511
+ observability: deps.observability,
4512
+ details,
4513
+ heartbeat: (value) => {
4514
+ try {
4515
+ deps.activityContext?.heartbeat({ ...value, at: (/* @__PURE__ */ new Date()).toISOString() });
4516
+ } catch {
4517
+ }
4518
+ },
4519
+ terminateWorker: () => process.exit(1)
4520
+ });
4521
+ try {
4522
+ monitor.enter("tool_writers");
4523
+ await finalizeTurnAttemptSteps(deps, monitor);
4524
+ } finally {
4525
+ monitor.stop();
4526
+ if (deps.eventing.heartbeatTimer) clearInterval(deps.eventing.heartbeatTimer);
4527
+ deps.eventing.heartbeatTimer = void 0;
4528
+ }
4529
+ }
4530
+ async function finalizeTurnAttemptSteps(deps, monitor) {
4455
4531
  const {
4456
4532
  input,
4457
4533
  settings,
@@ -4492,17 +4568,6 @@ async function finalizeTurnAttempt(deps) {
4492
4568
  let finalizationError;
4493
4569
  let physicalToolQuiescenceConfirmed = !control.acknowledgeQuiescence;
4494
4570
  let quiescenceReceiptOrProofDurable = !control.acknowledgeQuiescence;
4495
- const disarmQuiescenceWatchdog = armTurnQuiescenceWatchdog({
4496
- enabled: control.acknowledgeQuiescence,
4497
- onTimeout: () => {
4498
- observability.error("turn quiescence drain exceeded hard containment deadline", {
4499
- "opengeni.session_id": input.sessionId,
4500
- "opengeni.turn_id": attempt.turnId ?? "",
4501
- "opengeni.attempt_id": input.attemptId
4502
- });
4503
- },
4504
- terminateWorker: () => process.exit(1)
4505
- });
4506
4571
  const finalizerSignal = turnFinalizerCancellationSignal(
4507
4572
  cancellationSignal,
4508
4573
  control.activityStatus
@@ -4539,12 +4604,14 @@ async function finalizeTurnAttempt(deps) {
4539
4604
  // and durably settled before workspace capture. Only receipt
4540
4605
  // publication remains conditional on acknowledgeQuiescence.
4541
4606
  toolCancellationFence,
4607
+ onStage: monitor.enter,
4542
4608
  cancellationReason: cancellationSignal?.reason ?? new Error("TURN_ATTEMPT_FINALIZED"),
4543
4609
  gitCredentialRenewals: gitRenewalsToStop,
4544
4610
  codemodeTokenRenewal: codemodeRenewalToStop,
4545
4611
  runCredentialRenewal: runRenewalToStop
4546
4612
  });
4547
4613
  if (credentialSessionToClear) {
4614
+ monitor.enter("credential_cleanup");
4548
4615
  const clearAttemptCredentials = async () => await clearRunCredentialsForAttempt(credentialSessionToClear, {
4549
4616
  sessionId: input.sessionId,
4550
4617
  attemptId: input.attemptId,
@@ -4574,6 +4641,7 @@ async function finalizeTurnAttempt(deps) {
4574
4641
  physicalToolQuiescenceConfirmed = true;
4575
4642
  }
4576
4643
  if (control.acknowledgeQuiescence && physicalToolQuiescenceConfirmed) {
4644
+ monitor.enter("quiescence_receipt");
4577
4645
  const proof = {
4578
4646
  accountId: input.accountId,
4579
4647
  workspaceId: input.workspaceId,
@@ -4614,6 +4682,7 @@ async function finalizeTurnAttempt(deps) {
4614
4682
  signalProof: signalSessionAttemptQuiesced,
4615
4683
  heartbeat: (deliveryAttempt, retryMs) => {
4616
4684
  activityContext?.heartbeat({
4685
+ ...eventing.heartbeatDetails,
4617
4686
  phase: "quiescence-proof-delivery",
4618
4687
  sessionId: input.sessionId,
4619
4688
  attemptId: input.attemptId,
@@ -4646,7 +4715,6 @@ async function finalizeTurnAttempt(deps) {
4646
4715
  }
4647
4716
  });
4648
4717
  quiescenceReceiptOrProofDurable = true;
4649
- disarmQuiescenceWatchdog();
4650
4718
  if (recoveryMode === "signal") {
4651
4719
  observability.info("agent turn quiescence proof handed to workflow recovery", {
4652
4720
  "opengeni.session_id": input.sessionId,
@@ -4656,6 +4724,7 @@ async function finalizeTurnAttempt(deps) {
4656
4724
  });
4657
4725
  }
4658
4726
  }
4727
+ monitor.enter("event_flush");
4659
4728
  const machineOpEvents = machineOpObserver.drainEvents();
4660
4729
  if (machineOpEvents.length > 0 && attempt.turnId && attempt.executionGeneration > 0) {
4661
4730
  await waitForTurnFinalizerStep(
@@ -4678,6 +4747,7 @@ async function finalizeTurnAttempt(deps) {
4678
4747
  finalizerSignal
4679
4748
  );
4680
4749
  }
4750
+ monitor.enter("provider_leases");
4681
4751
  if (providerTurn.effectiveCodexCredentialId) {
4682
4752
  if (providerTurn.latestCodexUsage) {
4683
4753
  const usageMutation = await waitForTurnFinalizerStep(
@@ -4760,6 +4830,7 @@ async function finalizeTurnAttempt(deps) {
4760
4830
  deadlineRotationRequested: sandboxState.deadlineRotationRequested
4761
4831
  });
4762
4832
  if (settings.workspaceCaptureEnabled && runTurnEndPersistence && attempt.turnId && sandboxState.resolvedSandbox && sandboxState.setupBoxSession && sandboxState.sandboxGroupId) {
4833
+ monitor.enter("workspace_capture");
4763
4834
  sandboxState.turnEndCaptureInProgress = true;
4764
4835
  const captureSandbox = sandboxState.resolvedSandbox;
4765
4836
  const captureSession = sandboxState.setupBoxSession;
@@ -4804,6 +4875,7 @@ async function finalizeTurnAttempt(deps) {
4804
4875
  }
4805
4876
  });
4806
4877
  }
4878
+ monitor.enter("tool_close");
4807
4879
  eventing.toolPreparationClosing = true;
4808
4880
  if (eventing.toolPreparationReady) {
4809
4881
  await waitForTurnFinalizerStep(
@@ -4824,9 +4896,7 @@ async function finalizeTurnAttempt(deps) {
4824
4896
  finalizerSignal
4825
4897
  );
4826
4898
  }
4827
- if (eventing.heartbeatTimer) {
4828
- clearInterval(eventing.heartbeatTimer);
4829
- }
4899
+ monitor.enter("sandbox_provisioning");
4830
4900
  if (sandboxState.turnSandboxProvisioner?.hasStarted()) {
4831
4901
  await waitForTurnFinalizerStep(
4832
4902
  sandboxState.turnSandboxProvisioner.waitForSettled(3e4),
@@ -4846,9 +4916,11 @@ async function finalizeTurnAttempt(deps) {
4846
4916
  if (sandboxState.leaseHeartbeatTimer) {
4847
4917
  stopLeaseHeartbeat();
4848
4918
  }
4919
+ monitor.enter("sandbox_rotation");
4849
4920
  if (sandboxState.rotationPreemptionInFlight) {
4850
4921
  await sandboxState.rotationPreemptionInFlight.catch(() => void 0);
4851
4922
  }
4923
+ monitor.enter("workspace_snapshot");
4852
4924
  await drainInFlightWarmSnapshot();
4853
4925
  if (sandboxState.resolvedSandbox) {
4854
4926
  const settledTurnId = attempt.turnId;
@@ -4887,10 +4959,13 @@ async function finalizeTurnAttempt(deps) {
4887
4959
  );
4888
4960
  } finally {
4889
4961
  stopLeaseHeartbeat();
4962
+ monitor.enter("sandbox_rotation");
4890
4963
  if (sandboxState.rotationPreemptionInFlight) {
4891
4964
  await sandboxState.rotationPreemptionInFlight.catch(() => void 0);
4892
4965
  }
4966
+ monitor.enter("workspace_snapshot");
4893
4967
  await drainInFlightWarmSnapshot();
4968
+ monitor.enter("sandbox_release");
4894
4969
  const sandboxReleaseTargets = new Set(sandboxState.lateSandboxesAwaitingWriterDrain);
4895
4970
  sandboxState.lateSandboxesAwaitingWriterDrain.clear();
4896
4971
  if (sandboxState.resolvedSandbox) {
@@ -7577,7 +7652,7 @@ import {
7577
7652
  import { hasPermission } from "@opengeni/core";
7578
7653
  import {
7579
7654
  AUTOMATIC_SESSION_TITLE_FALLBACK,
7580
- DEFAULT_FIRST_PARTY_MCP_PERMISSIONS as DEFAULT_FIRST_PARTY_MCP_PERMISSIONS2
7655
+ DEFAULT_FIRST_PARTY_MCP_PERMISSIONS
7581
7656
  } from "@opengeni/contracts";
7582
7657
  var SESSION_TITLE_MODEL_TOOL_NAME = "opengeni__set_session_title";
7583
7658
  var SESSION_TITLE_DESCRIPTION = "Set this session's display title to a concise 3-7 word topic label. Use a stable noun phrase about the actual task or subject, never a quote/prefix of a prompt, greeting, request boilerplate, URL, identifier, credential, token, or other sensitive value. Call once on a new session, then only when the topic materially changes. Never call it as routine setup after a continuation, resume, or interruption, or merely to reassert the same title. A human-set title cannot be replaced.";
@@ -7586,7 +7661,7 @@ function shouldRequestMissingSessionTitle(input) {
7586
7661
  const needsSemanticTitle = input.titleSource !== "user" && (!title || title === AUTOMATIC_SESSION_TITLE_FALLBACK);
7587
7662
  if (!needsSemanticTitle) return false;
7588
7663
  if (!input.firstPartyMcpTools.includes("set_session_title")) return false;
7589
- const permissions = input.firstPartyMcpPermissions ?? DEFAULT_FIRST_PARTY_MCP_PERMISSIONS2;
7664
+ const permissions = input.firstPartyMcpPermissions ?? DEFAULT_FIRST_PARTY_MCP_PERMISSIONS;
7590
7665
  return hasPermission([...permissions], "sessions:control");
7591
7666
  }
7592
7667
  function sessionTitleToolPlan(input) {
@@ -9647,6 +9722,7 @@ async function claimTurnAttempt(deps) {
9647
9722
  turnId: attempt.turnId,
9648
9723
  opAcks: {}
9649
9724
  };
9725
+ eventing.heartbeatDetails = heartbeatDetails;
9650
9726
  const opJournal = makeTurnOpJournal(activityContext, heartbeatDetails);
9651
9727
  eventing.heartbeatTimer = startActivityHeartbeat(activityContext, heartbeatDetails);
9652
9728
  let producerSeq = 0;
@@ -30686,7 +30762,7 @@ async function materializeConnectorAttachmentsInChannel(channel, request, option
30686
30762
  }
30687
30763
 
30688
30764
  // src/activities/agent-turn/tool-environment.ts
30689
- import { allowedFirstPartyMcpToolsForSession as allowedFirstPartyMcpToolsForSession2 } from "@opengeni/config";
30765
+ import { allowedFirstPartyMcpToolsForSession } from "@opengeni/config";
30690
30766
 
30691
30767
  // src/activities/codemode-dispatcher.ts
30692
30768
  import { randomUUID as randomUUID3 } from "crypto";
@@ -31080,7 +31156,7 @@ function safeErrorMessage(error51) {
31080
31156
  // src/activities/agent-turn/tool-environment.ts
31081
31157
  import { CODEX_CLIENT_VERSION } from "@opengeni/codex";
31082
31158
  import {
31083
- defaultSessionMcpServerIds,
31159
+ workspaceSessionToolPolicyDefaultServerIds,
31084
31160
  loadRigDefaultVariableSetEnvironment,
31085
31161
  mergeRigDefaultVariableSetEnvironment,
31086
31162
  buildApiIntegrationMcpServers,
@@ -31093,7 +31169,7 @@ import {
31093
31169
  import { SandboxChannelAService as SandboxChannelAService3 } from "@opengeni/runtime/sandbox";
31094
31170
  import { sandboxRunAs as sandboxRunAs4 } from "@opengeni/runtime";
31095
31171
  import {
31096
- DEFAULT_FIRST_PARTY_MCP_PERMISSIONS as DEFAULT_FIRST_PARTY_MCP_PERMISSIONS3
31172
+ DEFAULT_FIRST_PARTY_MCP_PERMISSIONS as DEFAULT_FIRST_PARTY_MCP_PERMISSIONS2
31097
31173
  } from "@opengeni/contracts";
31098
31174
 
31099
31175
  // src/activities/agent-turn/turn-sandbox-access.ts
@@ -31904,6 +31980,7 @@ function configuredBundledSkillNames(context) {
31904
31980
  const tools = new Set(context.firstPartyTools);
31905
31981
  const artifacts = () => tools.has("editable_artifact_list") && tools.has("editable_artifact_get");
31906
31982
  const definitions = [
31983
+ { name: "opengeni-help", include: () => true },
31907
31984
  { name: "opengeni-visualize", include: () => true },
31908
31985
  { name: "document-parsing", include: () => true },
31909
31986
  { name: "opengeni-skills", include: () => true },
@@ -31962,7 +32039,12 @@ async function prepareTurnToolPolicy(deps) {
31962
32039
  toolPolicy: session.toolPolicy,
31963
32040
  sessionTools: scheduledEffectiveMcpServerIds ? turn.tools : session.tools,
31964
32041
  availableMcpServerIds: scheduledEffectiveMcpServerIds ? scheduledEffectiveMcpServerIds.filter((id) => currentMcpServerIds.has(id)) : [...currentMcpServerIds],
31965
- defaultMcpServerIds: scheduledEffectiveMcpServerIds ?? defaultSessionMcpServerIds(capabilitySettings.mcpServers)
32042
+ defaultMcpServerIds: scheduledEffectiveMcpServerIds ?? (session.toolPolicy.mode === "workspace_default" ? await workspaceSessionToolPolicyDefaultServerIds(
32043
+ db,
32044
+ input.workspaceId,
32045
+ capabilitySettings,
32046
+ fileAuthoritySubjectId ?? void 0
32047
+ ) : [])
31966
32048
  });
31967
32049
  const mcpAvailabilityNote = unavailableMcpOperationalContext({
31968
32050
  droppedIds: resolvedToolPolicy.effectivePolicy.droppedIds,
@@ -32230,10 +32312,10 @@ async function prepareTurnToolRuntime(deps) {
32230
32312
  );
32231
32313
  if (linkedAuthority && !linkedAuthority.authorized)
32232
32314
  throw new Error("Native identity link was revoked");
32233
- const effectiveFirstPartyPermissions = linkedAuthority ? (session.firstPartyMcpPermissions ?? DEFAULT_FIRST_PARTY_MCP_PERMISSIONS3).filter(
32315
+ const effectiveFirstPartyPermissions = linkedAuthority ? (session.firstPartyMcpPermissions ?? DEFAULT_FIRST_PARTY_MCP_PERMISSIONS2).filter(
32234
32316
  (permission) => hasPermission2(linkedAuthority.permissions, permission)
32235
32317
  ) : session.firstPartyMcpPermissions;
32236
- const selectedFirstPartyMcpTools = allowedFirstPartyMcpToolsForSession2(
32318
+ const selectedFirstPartyMcpTools = allowedFirstPartyMcpToolsForSession(
32237
32319
  runSettings,
32238
32320
  session.firstPartyMcpTools
32239
32321
  );
@@ -32249,10 +32331,10 @@ async function prepareTurnToolRuntime(deps) {
32249
32331
  parallelGenerationAvailable: typeof runtime.generateSessionTitle === "function"
32250
32332
  });
32251
32333
  const googleDrivePublicationAllowed = selectedFirstPartyMcpTools.includes("editable_artifact_export") && selectedFirstPartyMcpTools.includes("editable_artifact_export_status") && hasPermission2(
32252
- [...effectiveFirstPartyPermissions ?? DEFAULT_FIRST_PARTY_MCP_PERMISSIONS3],
32334
+ [...effectiveFirstPartyPermissions ?? DEFAULT_FIRST_PARTY_MCP_PERMISSIONS2],
32253
32335
  "artifacts:read"
32254
32336
  ) && hasPermission2(
32255
- [...effectiveFirstPartyPermissions ?? DEFAULT_FIRST_PARTY_MCP_PERMISSIONS3],
32337
+ [...effectiveFirstPartyPermissions ?? DEFAULT_FIRST_PARTY_MCP_PERMISSIONS2],
32256
32338
  "artifacts:publish"
32257
32339
  );
32258
32340
  const googleDriveConnectorBindings = googleDrivePublicationTool && googleDrivePublicationTarget && googleDrivePublicationAllowed ? [
@@ -35408,38 +35490,7 @@ These are publication receipts for the human's earlier answer. Do not call the r
35408
35490
  cancellationSignal?.throwIfAborted();
35409
35491
  knowledgeRecoveryNote = "[OpenGeni confirmation recovery unavailable] Do not assume an earlier remember confirmation was published. Inspect the current Knowledge or instruction review.";
35410
35492
  }
35411
- const attachmentPreparationNote = await prepareTurnKnowledgeSources({
35412
- settings: runSettings,
35413
- scope: {
35414
- accountId: input.accountId,
35415
- workspaceId: input.workspaceId,
35416
- sessionId: input.sessionId,
35417
- turnId: turn.id,
35418
- attemptId: input.attemptId,
35419
- executionGeneration: attempt.executionGeneration
35420
- },
35421
- // Only attachments on this accepted turn are new source inputs.
35422
- // Session-level file receipts remain historical context and must
35423
- // never trigger metadata reads, downloads, or re-preparation.
35424
- resources: turn.resources,
35425
- selectedTools: session.firstPartyMcpTools,
35426
- permissions: session.firstPartyMcpPermissions,
35427
- learningMode: learning.effective.knowledge,
35428
- signal: cancellationSignal,
35429
- onOutcome: async (outcome) => {
35430
- if (outcome.status === "disabled") return;
35431
- await eventing.publish(
35432
- [
35433
- {
35434
- type: outcome.status === "failed" ? "knowledge.source.failed" : "knowledge.source.prepared",
35435
- payload: outcome
35436
- }
35437
- ],
35438
- true
35439
- );
35440
- }
35441
- });
35442
- const knowledgeSourcePreparationNote = [knowledgeRecoveryNote, attachmentPreparationNote].filter(Boolean).join("\n\n") || void 0;
35493
+ const knowledgeSourcePreparationNote = knowledgeRecoveryNote;
35443
35494
  const sandboxRoute = await resolveSandboxRoute({
35444
35495
  input,
35445
35496
  settings,
@@ -37202,4 +37253,4 @@ export {
37202
37253
  createTurnActivities,
37203
37254
  createTurnActivitiesFromServices
37204
37255
  };
37205
- //# sourceMappingURL=activities-turn-AP67JADS.js.map
37256
+ //# sourceMappingURL=activities-turn-OAPNO2IH.js.map