@opengeni/worker-bundle 2.2.0-canary.36844267522001 → 2.2.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 (40) hide show
  1. package/dist/activities/agent-run-admission.d.ts +1 -3
  2. package/dist/activities/agent-turn/admission.d.ts +3 -24
  3. package/dist/activities/agent-turn/claude-usage-observer.d.ts +1 -13
  4. package/dist/activities/agent-turn/run-credentials.d.ts +0 -2
  5. package/dist/activities/agent-turn/stream-attempt.d.ts +0 -1
  6. package/dist/activities/agent-turn/turn-context.d.ts +0 -1
  7. package/dist/activities/goals.d.ts +0 -8
  8. package/dist/activities/run-credentials.d.ts +2 -4
  9. package/dist/activities/types.d.ts +1 -1
  10. package/dist/{activities-control-KQ5OK2GD.js → activities-control-MHNA3CYV.js} +66 -28
  11. package/dist/activities-control-MHNA3CYV.js.map +1 -0
  12. package/dist/{activities-turn-LSRAUGEK.js → activities-turn-FQ5OO2WW.js} +195 -459
  13. package/dist/activities-turn-FQ5OO2WW.js.map +1 -0
  14. package/dist/{chunk-WADNTBZZ.js → chunk-RZAAGRFQ.js} +64 -109
  15. package/dist/chunk-RZAAGRFQ.js.map +1 -0
  16. package/dist/index.js +1 -1
  17. package/dist/workflow-bundle.js +1 -1
  18. package/package.json +20 -20
  19. package/src/activities/agent-run-admission.ts +1 -17
  20. package/src/activities/agent-turn/admission.ts +1 -64
  21. package/src/activities/agent-turn/claim.ts +14 -56
  22. package/src/activities/agent-turn/claude-usage-observer.ts +1 -33
  23. package/src/activities/agent-turn/failure-settlement.ts +0 -5
  24. package/src/activities/agent-turn/run-credentials.ts +3 -15
  25. package/src/activities/agent-turn/run.ts +3 -32
  26. package/src/activities/agent-turn/stream-attempt.ts +32 -58
  27. package/src/activities/agent-turn/tool-environment.ts +20 -13
  28. package/src/activities/agent-turn/turn-context.ts +0 -1
  29. package/src/activities/capabilities.ts +14 -52
  30. package/src/activities/goals.ts +78 -36
  31. package/src/activities/knowledge-indexing.ts +0 -29
  32. package/src/activities/run-credentials.ts +16 -22
  33. package/src/activities/scheduled-tasks.ts +0 -1
  34. package/src/activities/types.ts +0 -1
  35. package/src/activities/workspace-credential-provider.ts +0 -12
  36. package/dist/activities/agent-turn/model-call-admission.d.ts +0 -15
  37. package/dist/activities-control-KQ5OK2GD.js.map +0 -1
  38. package/dist/activities-turn-LSRAUGEK.js.map +0 -1
  39. package/dist/chunk-WADNTBZZ.js.map +0 -1
  40. package/src/activities/agent-turn/model-call-admission.ts +0 -94
@@ -68,10 +68,8 @@ import {
68
68
  buildApiIntegrationMcpServers,
69
69
  resolveCatalogSettings,
70
70
  resolveWorkspaceModelSelection,
71
- loadWorkspaceCodexModelAvailability,
72
71
  withFrozenPersonalConnectionDelegations,
73
- resolveTurnToolPolicy,
74
- scheduledTurnMcpServerIds,
72
+ resolveSessionToolPolicy,
75
73
  hasPermission,
76
74
  } from "@opengeni/core";
77
75
  import { loadWorkspaceEnvironmentForRunWithCredentials } from "../environment";
@@ -225,20 +223,32 @@ export async function prepareTurnToolPolicy(deps: PrepareTurnToolPolicyDeps) {
225
223
  // sessions follow the current configured MCP set,
226
224
  // while explicit, inherited-fixed, and legacy sessions remain narrowed
227
225
  // to their stored materialized allow-list.
228
- const resolvedToolPolicy = resolveTurnToolPolicy({
226
+ const scheduledEffectiveMcpServerIds = (() => {
227
+ const value =
228
+ turn.metadata && typeof turn.metadata === "object" && !Array.isArray(turn.metadata)
229
+ ? (turn.metadata as Record<string, unknown>).scheduledEffectiveMcpServerIds
230
+ : null;
231
+ return Array.isArray(value) && value.every((id) => typeof id === "string")
232
+ ? [...new Set(value)].sort()
233
+ : null;
234
+ })();
235
+ const currentMcpServerIds = new Set(runSettings.mcpServers.map((server) => server.id));
236
+ const resolvedToolPolicy = resolveSessionToolPolicy({
229
237
  toolPolicy: session.toolPolicy,
230
- session,
231
- turn,
232
- availableMcpServerIds: runSettings.mcpServers.map((server) => server.id),
238
+ sessionTools: scheduledEffectiveMcpServerIds ? turn.tools : session.tools,
239
+ availableMcpServerIds: scheduledEffectiveMcpServerIds
240
+ ? scheduledEffectiveMcpServerIds.filter((id) => currentMcpServerIds.has(id))
241
+ : [...currentMcpServerIds],
233
242
  defaultMcpServerIds:
234
- scheduledTurnMcpServerIds(turn) === null && session.toolPolicy.mode === "workspace_default"
243
+ scheduledEffectiveMcpServerIds ??
244
+ (session.toolPolicy.mode === "workspace_default"
235
245
  ? await workspaceSessionToolPolicyDefaultServerIds(
236
246
  db,
237
247
  input.workspaceId,
238
248
  capabilitySettings,
239
249
  fileAuthoritySubjectId ?? undefined,
240
250
  )
241
- : [],
251
+ : []),
242
252
  });
243
253
  const mcpAvailabilityNote = unavailableMcpOperationalContext({
244
254
  droppedIds: resolvedToolPolicy.effectivePolicy.droppedIds,
@@ -898,7 +908,6 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
898
908
  organizationGatewayCustomModels,
899
909
  organizationOpenRouterConnectionActive,
900
910
  organizationOpenRouterCustomModels,
901
- codexModelAvailability,
902
911
  ] = await Promise.all([
903
912
  getWorkspaceConnectionModelRestrictions(
904
913
  db,
@@ -944,11 +953,9 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
944
953
  workspaceId: input.workspaceId,
945
954
  providerKind: "openrouter",
946
955
  }),
947
- loadWorkspaceCodexModelAvailability(db, currentSettings, input.workspaceId),
948
956
  ]);
949
957
  return {
950
958
  selections: resolveWorkspaceModelSelection({
951
- observations: codexModelAvailability,
952
959
  connectionModelRestrictions,
953
960
  settings: currentSettings,
954
961
  policy,
@@ -1103,7 +1110,7 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
1103
1110
  sessionAttachedRemoteMcpTargets: selectedSessionRemoteMcpTargets(
1104
1111
  githubRestMcp.settings,
1105
1112
  session.mcpServers ?? [],
1106
- githubRestMcp.tools,
1113
+ turn.tools ?? [],
1107
1114
  localMcpServers,
1108
1115
  ),
1109
1116
  ...(deps.runMcpCredentials ? { runMcpCredentials: deps.runMcpCredentials } : {}),
@@ -48,7 +48,6 @@ export type TurnSettleFn = (input: {
48
48
  sessionStatus: SessionStatus;
49
49
  activeTurnId: string | null;
50
50
  suppressGoalContinuation?: boolean;
51
- allowanceGoalPause?: ApplySessionTurnSettlementInput["allowanceGoalPause"];
52
51
  consumeRequestedCompactionFailure?: boolean;
53
52
  runState?: ApplySessionTurnSettlementInput["runState"];
54
53
  }) => Promise<boolean>;
@@ -40,8 +40,6 @@ import {
40
40
  listWorkspaceProviderCustomModels,
41
41
  getWorkspaceProviderCustomModelForExecution,
42
42
  loadWorkspaceProviderApiKey,
43
- loadClaudeSubscriptionUsageCredential,
44
- assertModelConnectionAllowsTurn,
45
43
  type Database,
46
44
  type SessionMcpServerForRun,
47
45
  } from "@opengeni/db";
@@ -305,30 +303,12 @@ export async function settingsWithOrganizationProviderCredentials(
305
303
  if (kind === "claude_subscription" && !settings.claudeSubscriptionEnabled) continue;
306
304
  const models = await buildModels(kind, claudeProviderId(kind) + "/");
307
305
  result = withClaudeConnectionCatalog(result, { [kind]: { models } });
308
- const binding =
309
- kind === "claude_subscription"
310
- ? await loadClaudeSubscriptionUsageCredential(db, settings, {
311
- accountId,
312
- workspaceId,
313
- scope: "organization",
314
- })
315
- : null;
316
- const credential =
317
- kind === "claude_subscription"
318
- ? binding?.serializedCredential
319
- : await loadOrganizationModelProviderApiKey(db, settings, {
320
- accountId,
321
- workspaceId,
322
- providerKind: kind,
323
- });
324
- if (credential)
325
- result = withClaudeConnectionCredential(
326
- result,
327
- kind,
328
- credential,
329
- "organization",
330
- binding ?? undefined,
331
- );
306
+ const credential = await loadOrganizationModelProviderApiKey(db, settings, {
307
+ accountId,
308
+ workspaceId,
309
+ providerKind: kind,
310
+ });
311
+ if (credential) result = withClaudeConnectionCredential(result, kind, credential);
332
312
  const workspaceModels = await listWorkspaceProviderCustomModels(db, {
333
313
  accountId,
334
314
  workspaceId,
@@ -353,33 +333,15 @@ export async function settingsWithOrganizationProviderCredentials(
353
333
  { [kind]: { models: workspaceModels } },
354
334
  "workspace",
355
335
  );
356
- const workspaceBinding =
357
- kind === "claude_subscription"
358
- ? await loadClaudeSubscriptionUsageCredential(db, settings, {
359
- accountId,
360
- workspaceId,
361
- scope: "workspace",
362
- })
363
- : null;
364
- if (workspaceBinding && workspaceModelId)
365
- await assertModelConnectionAllowsTurn(db, {
366
- workspaceId,
367
- subjectId: "worker:model-access",
368
- modelId: workspaceModelId,
369
- workspaceProviderConnectionId: workspaceBinding.connectionId,
370
- });
371
- const workspaceCredential =
372
- kind === "claude_subscription"
373
- ? workspaceBinding?.serializedCredential
374
- : await loadWorkspaceProviderApiKey(db, settings, workspaceId, kind, workspaceModelId);
336
+ const workspaceCredential = await loadWorkspaceProviderApiKey(
337
+ db,
338
+ settings,
339
+ workspaceId,
340
+ kind,
341
+ workspaceModelId,
342
+ );
375
343
  if (workspaceCredential)
376
- result = withClaudeConnectionCredential(
377
- result,
378
- kind,
379
- workspaceCredential,
380
- "workspace",
381
- workspaceBinding ?? undefined,
382
- );
344
+ result = withClaudeConnectionCredential(result, kind, workspaceCredential, "workspace");
383
345
  }
384
346
  return result;
385
347
  }
@@ -19,10 +19,14 @@ import {
19
19
  import { isCodexBilledModel } from "@opengeni/codex";
20
20
  import {
21
21
  enqueueSessionWorkflowWakeIfRunnable,
22
+ getBillingBalance,
22
23
  getWorkspaceModelPolicy,
23
24
  getSessionGoal,
25
+ isCodexBilledTurn,
24
26
  materializeGoalContinuation,
25
27
  requireSession,
28
+ sumUsageQuantity,
29
+ type Database,
26
30
  } from "@opengeni/db";
27
31
  import type {
28
32
  ControlActivityServices,
@@ -34,7 +38,6 @@ import {
34
38
  resolveCatalogSettings,
35
39
  resolveWorkspaceCatalogSettings,
36
40
  } from "@opengeni/core";
37
- import { agentRunAdmissionDenial } from "./agent-run-admission";
38
41
 
39
42
  export function createGoalActivities(services: () => Promise<ControlActivityServices>) {
40
43
  async function enqueueGoalRetryWake(input: MaybeContinueGoalInput): Promise<void> {
@@ -106,6 +109,30 @@ export function createGoalActivities(services: () => Promise<ControlActivityServ
106
109
  ) {
107
110
  modelPolicyBlocked = `session is locked to Codex remote compaction v2; model "${continuationModel}" is not a Codex subscription model`;
108
111
  }
112
+ // A codex-model goal continuation is paid by the user's ChatGPT/Codex plan,
113
+ // so it must not be budget-paused for zero OpenGeni credits. This file uses
114
+ // BASE settings (no codex overlay); the predicate does its own credential read.
115
+ const isCodexRun = await isCodexBilledTurn({
116
+ db,
117
+ settings,
118
+ workspaceId: input.workspaceId,
119
+ model: continuationModel,
120
+ });
121
+ const fundedWithoutCredits = goalContinuationFundedWithoutCredits(
122
+ settings,
123
+ continuationModel,
124
+ isCodexRun,
125
+ );
126
+ // Budget exhaustion pauses the goal visibly instead of failing the
127
+ // session. Computed up front and applied inside the locked decision so a
128
+ // limits pause never consumes continuation budget.
129
+ const budgetBlocked = await goalRunBudgetBlocked(
130
+ settings,
131
+ db,
132
+ input.accountId,
133
+ input.workspaceId,
134
+ fundedWithoutCredits,
135
+ );
109
136
  const turnExecutionPolicy = resolveTurnExecutionPolicyV1(settings, {
110
137
  modelId: continuationModel,
111
138
  requestedModelId: null,
@@ -130,25 +157,7 @@ export function createGoalActivities(services: () => Promise<ControlActivityServ
130
157
  // A model-policy block takes precedence: it is deterministic (a budget
131
158
  // pause can clear on its own; a policy pause needs a model/policy change)
132
159
  // and rides the same visible-pause channel.
133
- admission: async (tx, causalTurn) => {
134
- const budgetBlocked = modelPolicyBlocked
135
- ? null
136
- : await goalRunBudgetBlocked(
137
- { ...service, settings, db: tx },
138
- {
139
- accountId: input.accountId,
140
- workspaceId: input.workspaceId,
141
- model: continuationModel,
142
- initiatingHumanSubjectId: causalTurn?.initiatingHumanSubjectId ?? null,
143
- },
144
- );
145
- return {
146
- budgetBlocked: modelPolicyBlocked ?? budgetBlocked?.message ?? null,
147
- budgetPausedReason: modelPolicyBlocked
148
- ? "limits"
149
- : (budgetBlocked?.pausedReason ?? "limits"),
150
- };
151
- },
160
+ budgetBlocked: modelPolicyBlocked ?? budgetBlocked,
152
161
  policy: {
153
162
  model: continuationModel,
154
163
  reasoningEffort: continuationReasoningEffort,
@@ -327,22 +336,55 @@ export function withFirstPartyTools(settings: Settings, tools: ToolRef[]): ToolR
327
336
  }
328
337
 
329
338
  /**
330
- * Goals share scheduled admission and pause visibly without synthesizing work.
339
+ * Non-throwing variant of the scheduled-run admission check: returns a human
340
+ * readable reason when balance or monthly caps block another agent run.
331
341
  */
332
- export async function goalRunBudgetBlocked(
333
- services: Parameters<typeof agentRunAdmissionDenial>[0],
334
- input: Omit<Parameters<typeof agentRunAdmissionDenial>[1], "requestedAgentRuns">,
335
- ): Promise<{ pausedReason: "limits" | "allowance"; message: string } | null> {
336
- const denial = await agentRunAdmissionDenial(services, { ...input, requestedAgentRuns: 1 });
337
- if (denial === null) return null;
338
- if (denial === "allowance_exhausted") {
339
- return { pausedReason: "allowance", message: "OpenGeni usage allowance exhausted" };
342
+ async function goalRunBudgetBlocked(
343
+ settings: Settings,
344
+ db: Database,
345
+ accountId: string,
346
+ workspaceId: string,
347
+ fundedWithoutCredits: boolean,
348
+ ): Promise<string | null> {
349
+ // Free, subscription, and workspace-funded continuations skip OpenGeni's
350
+ // credit-balance gate and monthly model-cost cap. The agent-run COUNT cap
351
+ // below is a volume quota (not a credit/cost gate) and remains enforced.
352
+ if (
353
+ !fundedWithoutCredits &&
354
+ (settings.billingMode === "stripe" || settings.usageLimitsMode === "managed")
355
+ ) {
356
+ const balance = await getBillingBalance(db, accountId);
357
+ if (balance.balanceMicros <= 0) {
358
+ return "insufficient OpenGeni credits";
359
+ }
340
360
  }
341
- const limits = configuredStaticUsageLimits(services.settings);
342
- const messages = {
343
- insufficient_credits: "insufficient OpenGeni credits",
344
- monthly_model_cost_limit: `monthly model cost limit reached (${limits.maxMonthlyCostMicrosPerAccount} micros)`,
345
- monthly_agent_run_limit: `monthly agent run limit reached (${limits.maxMonthlyAgentRunsPerWorkspace})`,
346
- };
347
- return { pausedReason: "limits", message: messages[denial] };
361
+ if (settings.usageLimitsMode === "static" || settings.usageLimitsMode === "managed") {
362
+ const limits = configuredStaticUsageLimits(settings);
363
+ if (!fundedWithoutCredits && limits.maxMonthlyCostMicrosPerAccount) {
364
+ const used = await sumUsageQuantity(db, {
365
+ accountId,
366
+ eventType: "model.cost",
367
+ since: startOfUtcMonth(),
368
+ });
369
+ if (used >= limits.maxMonthlyCostMicrosPerAccount) {
370
+ return `monthly model cost limit reached (${limits.maxMonthlyCostMicrosPerAccount} micros)`;
371
+ }
372
+ }
373
+ if (limits.maxMonthlyAgentRunsPerWorkspace) {
374
+ const used = await sumUsageQuantity(db, {
375
+ workspaceId,
376
+ eventType: "agent_run.created",
377
+ since: startOfUtcMonth(),
378
+ });
379
+ if (used + 1 > limits.maxMonthlyAgentRunsPerWorkspace) {
380
+ return `monthly agent run limit reached (${limits.maxMonthlyAgentRunsPerWorkspace})`;
381
+ }
382
+ }
383
+ }
384
+ return null;
385
+ }
386
+
387
+ function startOfUtcMonth(): Date {
388
+ const now = new Date();
389
+ return new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1));
348
390
  }
@@ -4,10 +4,8 @@ import {
4
4
  applyCreditDebitAfterUse,
5
5
  appendKnowledgeIndexChunks,
6
6
  claimKnowledgeIndexJobs,
7
- checkWorkspaceAllowance,
8
7
  completeKnowledgeIndexJob,
9
8
  continueKnowledgeIndexJob,
10
- creditDebitAttributionMetadata,
11
9
  deferKnowledgeIndexJob,
12
10
  freezeKnowledgeIndexBillingMode,
13
11
  getBillingBalance,
@@ -200,16 +198,6 @@ export function createKnowledgeIndexingActivities(
200
198
  return;
201
199
  }
202
200
  const paid = frozenPolicy.mode === "credits";
203
- if (paid && claim.billingAttribution.kind === "unknown") {
204
- // Unknown legacy/source-preparation causality is not service.
205
- // Keep the checkpoint without making an uncountable paid call.
206
- observability.warn("Paid Knowledge indexing awaits initiating attribution", {
207
- errorCode: "knowledge_index_attribution_unavailable",
208
- });
209
- await deferKnowledgeIndexJob(lockedDb, claim);
210
- result.deferred++;
211
- return;
212
- }
213
201
  if (paid && current.nextIndex === 0) {
214
202
  const balance = await getBillingBalance(lockedDb, claim.accountId);
215
203
  if (balance.balanceMicros <= 0) {
@@ -218,22 +206,6 @@ export function createKnowledgeIndexingActivities(
218
206
  return;
219
207
  }
220
208
  }
221
- if (paid) {
222
- const refusal = await checkWorkspaceAllowance(lockedDb, {
223
- accountId: claim.accountId,
224
- workspaceId: current.billingWorkspaceId,
225
- subjectId:
226
- claim.billingAttribution.kind === "turn" ||
227
- claim.billingAttribution.kind === "human"
228
- ? claim.billingAttribution.initiatingHumanSubjectId
229
- : null,
230
- });
231
- if (refusal) {
232
- await deferKnowledgeIndexJob(lockedDb, claim);
233
- result.deferred++;
234
- return;
235
- }
236
- }
237
209
  if (settings.usageLimitsMode === "static" || settings.usageLimitsMode === "managed") {
238
210
  const limit =
239
211
  configuredStaticUsageLimits(settings).maxDocumentIndexedChunksPerWorkspace;
@@ -337,7 +309,6 @@ export function createKnowledgeIndexingActivities(
337
309
  sourceId: claim.revisionId,
338
310
  idempotencyKey: `knowledge.embedding:${claim.revisionId}:${claim.generation}:${current.nextIndex}`,
339
311
  metadata: {
340
- ...creditDebitAttributionMetadata(claim.billingAttribution),
341
312
  model: claim.model,
342
313
  bytes,
343
314
  chunks: chunks.length,
@@ -5,7 +5,6 @@ import type {
5
5
  RunCredentialsRequest,
6
6
  Session,
7
7
  SessionTurn,
8
- ToolRef,
9
8
  } from "@opengeni/contracts";
10
9
  import type { Settings } from "@opengeni/config";
11
10
  import { getSessionRootId, type Database } from "@opengeni/db";
@@ -31,8 +30,6 @@ export type RunCredentialResolutionContext = {
31
30
  initiatingHumanSubjectId?: string | null;
32
31
  /** Installed in-process API routes must never enter a product callback. */
33
32
  localMcpServerIds?: readonly string[];
34
- /** Exact execution selection, resolved once at the turn policy boundary. */
35
- effectiveTools: readonly ToolRef[];
36
33
  };
37
34
 
38
35
  export type BoundRunCredentialResolver = {
@@ -45,7 +42,7 @@ export type BoundRunCredentialResolver = {
45
42
  export function buildRunCredentialsRequest(
46
43
  input: Omit<
47
44
  RunCredentialResolutionContext,
48
- "db" | "connectionCredentials" | "settings" | "initiatingHumanSubjectId" | "effectiveTools"
45
+ "db" | "connectionCredentials" | "settings" | "initiatingHumanSubjectId"
49
46
  > & {
50
47
  rootSessionId: string;
51
48
  purpose: "provision" | "renewal";
@@ -128,7 +125,7 @@ export async function bindRunCredentialResolver(
128
125
  mcpServers: selectedSessionRemoteMcpTargets(
129
126
  input.settings,
130
127
  input.session.mcpServers ?? [],
131
- input.effectiveTools,
128
+ input.turn.tools ?? [],
132
129
  (input.localMcpServerIds ?? []).map((id) => ({ id })),
133
130
  ),
134
131
  },
@@ -149,25 +146,22 @@ export async function bindRunCredentialResolver(
149
146
  workspaceId: input.workspaceId,
150
147
  sessionId: input.session.id,
151
148
  };
152
- // A renewable resolver belongs to one admitted turn, even if its caller
153
- // subsequently replaces or mutates an in-memory session/turn projection.
154
- const frozenRequest = structuredClone(
155
- buildRunCredentialsRequest({
156
- accountId: input.accountId,
157
- workspaceId: input.workspaceId,
158
- session: input.session,
159
- turn: input.turn,
160
- attemptId: input.attemptId,
161
- effectiveSandboxBackend: input.effectiveSandboxBackend,
162
- variableSet: input.variableSet,
163
- rootSessionId,
164
- purpose: "provision",
165
- forceRefresh: false,
166
- }),
167
- );
168
149
  return {
169
150
  resolve: async ({ purpose, forceRefresh }) => {
170
- const resolution = await resolver({ ...frozenRequest, purpose, forceRefresh });
151
+ const resolution = await resolver(
152
+ buildRunCredentialsRequest({
153
+ accountId: input.accountId,
154
+ workspaceId: input.workspaceId,
155
+ session: input.session,
156
+ turn: input.turn,
157
+ attemptId: input.attemptId,
158
+ effectiveSandboxBackend: input.effectiveSandboxBackend,
159
+ variableSet: input.variableSet,
160
+ rootSessionId,
161
+ purpose,
162
+ forceRefresh,
163
+ }),
164
+ );
171
165
  return normalizeRunCredentialsResolution(resolution, scope);
172
166
  },
173
167
  };
@@ -917,7 +917,6 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
917
917
  workspaceId: task.workspaceId,
918
918
  model: targetSessionExecution?.model ?? model,
919
919
  requestedAgentRuns: input.agentRunUsageIdempotencyKey ? 0 : 1,
920
- initiatingHumanSubjectId: causalHumanSubjectId,
921
920
  },
922
921
  );
923
922
  if (admissionDenial) {
@@ -458,7 +458,6 @@ export type DispatchScheduledTaskRunResult =
458
458
  refusal?: import("@opengeni/contracts").ScheduledTaskAdmissionRefusal;
459
459
  reason:
460
460
  | "insufficient_credits"
461
- | "allowance_exhausted"
462
461
  | "monthly_model_cost_limit"
463
462
  | "monthly_agent_run_limit"
464
463
  | "malformed_manual_trigger"
@@ -78,8 +78,6 @@ export function credentialProviderRequestBody(
78
78
  mcpServers: [],
79
79
  },
80
80
  ): CredentialProviderRequest {
81
- const via = input.initiatorContext.via;
82
- const latestHop = Array.isArray(via) ? via.at(-1) : null;
83
81
  return {
84
82
  type: "credentials.request",
85
83
  lane: selection.lane,
@@ -94,16 +92,6 @@ export function credentialProviderRequestBody(
94
92
  turnId: input.turnId,
95
93
  attemptId: input.attemptId,
96
94
  initiator: { kind: input.initiator.kind, subjectId: input.initiator.subjectId },
97
- initiatorContext: {
98
- kind:
99
- latestHop?.kind === "agent"
100
- ? "agent"
101
- : input.initiator.kind === "subject"
102
- ? "human"
103
- : "service",
104
- initiator: input.initiator,
105
- context: input.initiatorContext,
106
- },
107
95
  initiatingHumanSubjectId,
108
96
  initiatingHuman,
109
97
  sandboxBackend: input.effectiveSandboxBackend,
@@ -1,15 +0,0 @@
1
- import type { StreamEvent } from "@openai/agents";
2
- /** SDK producer/consumer rendezvous. Usage stays on the sole consumer writer. */
3
- export declare function createModelCallAdmission(input: {
4
- signal: AbortSignal;
5
- admit: () => Promise<void>;
6
- }): {
7
- beforeModelRequest: () => Promise<void>;
8
- onModelResponse: (event: StreamEvent) => Promise<void>;
9
- settle: (event: {
10
- type: string;
11
- data?: unknown;
12
- }) => void;
13
- fail: (error: unknown) => void;
14
- close: () => void;
15
- };