@opengeni/worker-bundle 4.2.1-canary.39593846423001 → 4.3.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.
- package/dist/activities/agent-turn/code-search.d.ts +19 -14
- package/dist/activities/agent-turn/decision-model.d.ts +11 -0
- package/dist/activities/agent-turn/provider-dispatch-barrier.d.ts +32 -4
- package/dist/activities/agent-turn/tool-discovery.d.ts +21 -0
- package/dist/activities/model-call-fact-reconciler.d.ts +2 -1
- package/dist/{activities-control-KP6WCM3S.js → activities-control-7ZHF4LES.js} +108 -44
- package/dist/activities-control-7ZHF4LES.js.map +1 -0
- package/dist/{activities-turn-7ESD3YJB.js → activities-turn-7VX4IWPO.js} +193 -67
- package/dist/activities-turn-7VX4IWPO.js.map +1 -0
- package/dist/artifact-materializer-entry.js +0 -0
- package/dist/artifact-outbox-entry.js +0 -0
- package/dist/{chunk-3LJG6QJL.js → chunk-5KOLEDGM.js} +27 -3
- package/dist/chunk-5KOLEDGM.js.map +1 -0
- package/dist/{chunk-6AZ2MKJC.js → chunk-AICMJ5A2.js} +10 -10
- package/dist/{chunk-6AZ2MKJC.js.map → chunk-AICMJ5A2.js.map} +1 -1
- package/dist/{chunk-L5XPJLGD.js → chunk-WGFH4MZV.js} +2 -2
- package/dist/index.js +3 -3
- package/dist/observability-metrics.d.ts +4 -4
- package/dist/{sandbox-lease-Y5UB6B2S.js → sandbox-lease-G4H72KAK.js} +3 -3
- package/dist/workflow-bundle.js +1 -1
- package/package.json +27 -26
- package/src/activities/agent-turn/agent-build.ts +23 -3
- package/src/activities/agent-turn/code-search.ts +86 -58
- package/src/activities/agent-turn/decision-model.ts +43 -0
- package/src/activities/agent-turn/file-resources.ts +8 -11
- package/src/activities/agent-turn/provider-dispatch-barrier.ts +54 -3
- package/src/activities/agent-turn/run.ts +13 -1
- package/src/activities/agent-turn/tool-discovery.ts +78 -0
- package/src/activities/agent-turn/tool-environment.ts +20 -15
- package/src/activities/model-call-fact-reconciler.ts +109 -38
- package/src/activities/session-title-route.ts +3 -1
- package/src/observability-metrics.ts +14 -14
- package/dist/activities-control-KP6WCM3S.js.map +0 -1
- package/dist/activities-turn-7ESD3YJB.js.map +0 -1
- package/dist/chunk-3LJG6QJL.js.map +0 -1
- /package/dist/{chunk-L5XPJLGD.js.map → chunk-WGFH4MZV.js.map} +0 -0
- /package/dist/{sandbox-lease-Y5UB6B2S.js.map → sandbox-lease-G4H72KAK.js.map} +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ActiveRouteDispatchBoundary,
|
|
2
3
|
CLAUDE_CORE_WAIT_BINDING,
|
|
3
4
|
CODEX_CORE_WAIT_BINDING,
|
|
4
5
|
FIRST_PARTY_MCP_SETUP_UNAVAILABLE_CODE,
|
|
@@ -112,7 +113,7 @@ import {
|
|
|
112
113
|
wakeSubscriptionCoreWaitersAndDeliver,
|
|
113
114
|
withFirstPartyTools,
|
|
114
115
|
withModelRoutePresentation
|
|
115
|
-
} from "./chunk-
|
|
116
|
+
} from "./chunk-5KOLEDGM.js";
|
|
116
117
|
import "./chunk-K225DMA7.js";
|
|
117
118
|
import {
|
|
118
119
|
agentBackgroundCommandDeps,
|
|
@@ -164,7 +165,7 @@ import {
|
|
|
164
165
|
runtimeMetricsHooksForObservability,
|
|
165
166
|
sandboxAutomaticRecoveryOutcome,
|
|
166
167
|
turnLifecycleMetricsFor
|
|
167
|
-
} from "./chunk-
|
|
168
|
+
} from "./chunk-AICMJ5A2.js";
|
|
168
169
|
import {
|
|
169
170
|
deliverChildRequiresActionToParent,
|
|
170
171
|
deliverFailedChildTurnToParent
|
|
@@ -1269,11 +1270,11 @@ function requiresSignedFileResourceDownloads(settings, activeSandboxBackend = se
|
|
|
1269
1270
|
if (activeSandboxBackend === "none") {
|
|
1270
1271
|
return false;
|
|
1271
1272
|
}
|
|
1272
|
-
|
|
1273
|
+
const bucketMount = CAPABILITY_DESCRIPTORS[activeSandboxBackend].bucketMount;
|
|
1274
|
+
if (bucketMount === "none") {
|
|
1273
1275
|
return true;
|
|
1274
1276
|
}
|
|
1275
|
-
|
|
1276
|
-
return activeSandboxBackend === "docker" && settings.objectStorageBackend === "s3-compatible" || settings.objectStorageBackend === "aws-s3" || settings.objectStorageBackend === "gcs" || nativeBucketMount && settings.objectStorageBackend === "azure-blob";
|
|
1277
|
+
return activeSandboxBackend === "docker" && settings.objectStorageBackend === "s3-compatible" || settings.objectStorageBackend === "aws-s3" || settings.objectStorageBackend === "gcs" || bucketMount === "native" && settings.objectStorageBackend === "azure-blob";
|
|
1277
1278
|
}
|
|
1278
1279
|
function objectStorageForSandboxDownloads(settings, objectStorage, activeSandboxBackend = settings.sandboxBackend) {
|
|
1279
1280
|
if (activeSandboxBackend === "selfhosted") {
|
|
@@ -26148,7 +26149,9 @@ var providerKinds = {
|
|
|
26148
26149
|
"opper-workspace": "opper",
|
|
26149
26150
|
"opper-organization": "opper",
|
|
26150
26151
|
"anthropic-workspace": "anthropic",
|
|
26151
|
-
"anthropic-organization": "anthropic"
|
|
26152
|
+
"anthropic-organization": "anthropic",
|
|
26153
|
+
"direct-openai-organization": "openai",
|
|
26154
|
+
"direct-azure-organization": "azure_openai"
|
|
26152
26155
|
};
|
|
26153
26156
|
async function sessionTitleApiConnectionId(input) {
|
|
26154
26157
|
const { db, settings, provider, workspaceId, accountId } = input;
|
|
@@ -26167,7 +26170,7 @@ async function sessionTitleApiConnectionId(input) {
|
|
|
26167
26170
|
}
|
|
26168
26171
|
const kind = providerKinds[provider.kind];
|
|
26169
26172
|
if (provider.credentialSource.kind === "workspace_connection") {
|
|
26170
|
-
if (!kind)
|
|
26173
|
+
if (!kind || kind === "openai" || kind === "azure_openai")
|
|
26171
26174
|
throw new SessionTitleRouteUnavailableError("Title workspace provider is unsupported");
|
|
26172
26175
|
const metadata = await getWorkspaceProviderApiKeyConnectionMetadata(db, workspaceId, kind);
|
|
26173
26176
|
const spec = workspaceProviderApiKeyConnectionSpec(kind);
|
|
@@ -36064,7 +36067,8 @@ function createRefreshCredentialsAttemptToolDefinition(input) {
|
|
|
36064
36067
|
}
|
|
36065
36068
|
|
|
36066
36069
|
// src/activities/agent-turn/code-search.ts
|
|
36067
|
-
import {
|
|
36070
|
+
import { decisionModelConfiguration as decisionModelConfiguration2 } from "@opengeni/config";
|
|
36071
|
+
import { DecisionUnavailableError, DecisionRequestError } from "@opengeni/decisions";
|
|
36068
36072
|
import {
|
|
36069
36073
|
CODE_SEARCH_TOOL_DESCRIPTION,
|
|
36070
36074
|
CODE_SEARCH_TOOL_NAME,
|
|
@@ -36072,9 +36076,6 @@ import {
|
|
|
36072
36076
|
CodeSearchRipgrepMissingError,
|
|
36073
36077
|
CodeSearchWorkspaceError,
|
|
36074
36078
|
JevCircuitBreaker,
|
|
36075
|
-
JevClient,
|
|
36076
|
-
JevRequestError,
|
|
36077
|
-
JevUnavailableError,
|
|
36078
36079
|
codeSearchInputSchema,
|
|
36079
36080
|
parseCodeSearchArguments,
|
|
36080
36081
|
renderCodeSearchError,
|
|
@@ -36087,6 +36088,35 @@ import {
|
|
|
36087
36088
|
ChannelAValidationError,
|
|
36088
36089
|
isWindowsConnectedMachinePath
|
|
36089
36090
|
} from "@opengeni/runtime/sandbox";
|
|
36091
|
+
|
|
36092
|
+
// src/activities/agent-turn/decision-model.ts
|
|
36093
|
+
import {
|
|
36094
|
+
decisionModelConfiguration
|
|
36095
|
+
} from "@opengeni/config";
|
|
36096
|
+
import { createHttpDecisionModel } from "@opengeni/decisions";
|
|
36097
|
+
import { createJevDecisionModel, JevClient } from "@opengeni/jev";
|
|
36098
|
+
function configuredDecisionModel(settings, options = {}) {
|
|
36099
|
+
const config2 = decisionModelConfiguration(settings, options.allowLegacyCodeSearch);
|
|
36100
|
+
if (!config2) return void 0;
|
|
36101
|
+
const model = config2.provider === "jev" ? createJevDecisionModel(
|
|
36102
|
+
new JevClient({
|
|
36103
|
+
apiKey: config2.apiKey,
|
|
36104
|
+
model: config2.model,
|
|
36105
|
+
...config2.baseUrl ? { baseUrl: config2.baseUrl } : {},
|
|
36106
|
+
...settings.jevRequestTimeoutMs !== void 0 ? { timeoutMs: settings.jevRequestTimeoutMs } : {},
|
|
36107
|
+
...options.fetch ? { fetch: options.fetch } : {}
|
|
36108
|
+
})
|
|
36109
|
+
) : createHttpDecisionModel({
|
|
36110
|
+
provider: config2.provider,
|
|
36111
|
+
model: config2.model,
|
|
36112
|
+
apiKey: config2.apiKey,
|
|
36113
|
+
...config2.baseUrl ? { endpoint: `${config2.baseUrl.replace(/\/$/, "")}/decisions` } : {},
|
|
36114
|
+
...options.fetch ? { fetch: options.fetch } : {}
|
|
36115
|
+
});
|
|
36116
|
+
return { id: `${config2.provider}/${config2.model}`, model };
|
|
36117
|
+
}
|
|
36118
|
+
|
|
36119
|
+
// src/activities/agent-turn/code-search.ts
|
|
36090
36120
|
var codeSearchCircuitBreaker = new JevCircuitBreaker();
|
|
36091
36121
|
var CODE_SEARCH_RIPGREP_MAX_BYTES = 32 * 1024 * 1024;
|
|
36092
36122
|
function codeSearchWorkspaceFromChannel(channel) {
|
|
@@ -36126,13 +36156,18 @@ function textResult(text, isError) {
|
|
|
36126
36156
|
}
|
|
36127
36157
|
function createCodeSearchAttemptToolDefinition(input) {
|
|
36128
36158
|
const breaker = input.breaker ?? codeSearchCircuitBreaker;
|
|
36129
|
-
const
|
|
36130
|
-
|
|
36131
|
-
|
|
36132
|
-
|
|
36133
|
-
|
|
36134
|
-
|
|
36135
|
-
|
|
36159
|
+
const configured = configuredDecisionModel(
|
|
36160
|
+
{
|
|
36161
|
+
...input.settings,
|
|
36162
|
+
...input.apiKey ? { jevApiKey: input.apiKey } : {}
|
|
36163
|
+
},
|
|
36164
|
+
{
|
|
36165
|
+
allowLegacyCodeSearch: true,
|
|
36166
|
+
...input.fetch ? { fetch: input.fetch } : {}
|
|
36167
|
+
}
|
|
36168
|
+
);
|
|
36169
|
+
if (!configured)
|
|
36170
|
+
throw new DecisionUnavailableError("Code search needs a configured decision model");
|
|
36136
36171
|
return {
|
|
36137
36172
|
identity: { serverId: "opengeni", toolName: CODE_SEARCH_TOOL_NAME },
|
|
36138
36173
|
modelName: CODE_SEARCH_TOOL_NAME,
|
|
@@ -36152,8 +36187,11 @@ function createCodeSearchAttemptToolDefinition(input) {
|
|
|
36152
36187
|
execute: async (args, context) => {
|
|
36153
36188
|
const startedAt = performance.now();
|
|
36154
36189
|
let outcome = "failed";
|
|
36155
|
-
let
|
|
36156
|
-
let
|
|
36190
|
+
let decisionRequests = 0;
|
|
36191
|
+
let decisionCostUsd = 0;
|
|
36192
|
+
let decisionInputTokens = 0;
|
|
36193
|
+
let decisionModel = null, decisionProvider = null;
|
|
36194
|
+
const costSources = /* @__PURE__ */ new Set();
|
|
36157
36195
|
let lease = null;
|
|
36158
36196
|
try {
|
|
36159
36197
|
const request = parseCodeSearchArguments(args);
|
|
@@ -36162,7 +36200,9 @@ function createCodeSearchAttemptToolDefinition(input) {
|
|
|
36162
36200
|
outcome = "breaker_open";
|
|
36163
36201
|
return textResult(
|
|
36164
36202
|
renderCodeSearchError(
|
|
36165
|
-
new
|
|
36203
|
+
new DecisionUnavailableError(
|
|
36204
|
+
"The decision model is not responding; calls are paused for a few minutes"
|
|
36205
|
+
)
|
|
36166
36206
|
),
|
|
36167
36207
|
true
|
|
36168
36208
|
);
|
|
@@ -36171,33 +36211,27 @@ function createCodeSearchAttemptToolDefinition(input) {
|
|
|
36171
36211
|
const result = await runCodeSearch({
|
|
36172
36212
|
...request,
|
|
36173
36213
|
workspace,
|
|
36174
|
-
|
|
36214
|
+
decisionModel: configured.model,
|
|
36215
|
+
onDecisionUsage: (usage) => {
|
|
36216
|
+
decisionRequests += usage.requests;
|
|
36217
|
+
decisionInputTokens = decisionInputTokens === null || usage.inputTokens === null ? null : decisionInputTokens + usage.inputTokens;
|
|
36218
|
+
decisionCostUsd = decisionCostUsd === null || usage.costUsd === null ? null : decisionCostUsd + usage.costUsd;
|
|
36219
|
+
decisionModel = usage.model;
|
|
36220
|
+
decisionProvider = usage.provider;
|
|
36221
|
+
costSources.add(usage.costSource);
|
|
36222
|
+
},
|
|
36175
36223
|
...context.signal ? { signal: context.signal } : {}
|
|
36176
36224
|
});
|
|
36177
36225
|
const held = lease;
|
|
36178
36226
|
lease = null;
|
|
36179
|
-
if (result.statusCheckError instanceof
|
|
36227
|
+
if (result.statusCheckError instanceof DecisionUnavailableError) {
|
|
36180
36228
|
breaker.recordFailure(result.statusCheckError, Date.now(), held);
|
|
36181
|
-
} else if (result.stats.
|
|
36229
|
+
} else if (result.stats.decision.requests > 0) {
|
|
36182
36230
|
breaker.recordSuccess(held);
|
|
36183
36231
|
} else {
|
|
36184
36232
|
breaker.release(held);
|
|
36185
36233
|
}
|
|
36186
36234
|
outcome = "completed";
|
|
36187
|
-
jevRequests = result.stats.jev.requests;
|
|
36188
|
-
jevCostUsd = result.stats.jev.costUsd;
|
|
36189
|
-
if (input.recordUsage && jevRequests > 0) {
|
|
36190
|
-
await input.recordUsage({
|
|
36191
|
-
operationId: context.operationId,
|
|
36192
|
-
jevRequests,
|
|
36193
|
-
jevInputTokens: result.stats.jev.inputTokens,
|
|
36194
|
-
jevCostUsd
|
|
36195
|
-
}).catch((error51) => {
|
|
36196
|
-
input.observability.warn("code_search usage record failed", {
|
|
36197
|
-
error: error51 instanceof Error ? error51.message : String(error51)
|
|
36198
|
-
});
|
|
36199
|
-
});
|
|
36200
|
-
}
|
|
36201
36235
|
return textResult(result.text, false);
|
|
36202
36236
|
} catch (error51) {
|
|
36203
36237
|
if (context.signal?.aborted) {
|
|
@@ -36208,15 +36242,15 @@ function createCodeSearchAttemptToolDefinition(input) {
|
|
|
36208
36242
|
outcome = "invalid_arguments";
|
|
36209
36243
|
return textResult(error51.message, true);
|
|
36210
36244
|
}
|
|
36211
|
-
if (error51 instanceof
|
|
36245
|
+
if (error51 instanceof DecisionUnavailableError) {
|
|
36212
36246
|
const held = lease;
|
|
36213
36247
|
lease = null;
|
|
36214
36248
|
breaker.recordFailure(error51, Date.now(), held);
|
|
36215
|
-
outcome = "
|
|
36249
|
+
outcome = "decision_unavailable";
|
|
36216
36250
|
return textResult(renderCodeSearchError(error51), true);
|
|
36217
36251
|
}
|
|
36218
|
-
if (error51 instanceof
|
|
36219
|
-
outcome = "
|
|
36252
|
+
if (error51 instanceof DecisionRequestError) {
|
|
36253
|
+
outcome = "decision_rejected";
|
|
36220
36254
|
return textResult(renderCodeSearchError(error51), true);
|
|
36221
36255
|
}
|
|
36222
36256
|
if (error51 instanceof CodeSearchWorkspaceError) {
|
|
@@ -36233,27 +36267,41 @@ function createCodeSearchAttemptToolDefinition(input) {
|
|
|
36233
36267
|
throw error51;
|
|
36234
36268
|
} finally {
|
|
36235
36269
|
if (lease) breaker.release(lease);
|
|
36270
|
+
if (input.recordUsage && decisionRequests > 0) {
|
|
36271
|
+
await input.recordUsage({
|
|
36272
|
+
operationId: context.operationId,
|
|
36273
|
+
decisionRequests,
|
|
36274
|
+
decisionInputTokens,
|
|
36275
|
+
decisionCostUsd,
|
|
36276
|
+
model: decisionModel,
|
|
36277
|
+
provider: decisionProvider,
|
|
36278
|
+
costSources: [...costSources]
|
|
36279
|
+
}).catch((error51) => {
|
|
36280
|
+
input.observability.warn("code_search usage record failed", {
|
|
36281
|
+
error: error51 instanceof Error ? error51.message : String(error51)
|
|
36282
|
+
});
|
|
36283
|
+
});
|
|
36284
|
+
}
|
|
36236
36285
|
recordCodeSearchCall(input.observability, {
|
|
36237
36286
|
outcome,
|
|
36238
36287
|
durationSeconds: (performance.now() - startedAt) / 1e3,
|
|
36239
|
-
|
|
36240
|
-
|
|
36288
|
+
decisionRequests,
|
|
36289
|
+
decisionCostUsd
|
|
36241
36290
|
});
|
|
36242
36291
|
}
|
|
36243
36292
|
}
|
|
36244
36293
|
};
|
|
36245
36294
|
}
|
|
36246
36295
|
function codeSearchToolDefinitions(input) {
|
|
36247
|
-
const
|
|
36296
|
+
const config2 = decisionModelConfiguration2(input.settings, true);
|
|
36248
36297
|
const breaker = input.breaker ?? codeSearchCircuitBreaker;
|
|
36249
|
-
if (!input.enabled || !
|
|
36298
|
+
if (!input.enabled || !config2 || input.backend === "none") return [];
|
|
36250
36299
|
if (input.machineWorkspaceRoot && isWindowsConnectedMachinePath(input.machineWorkspaceRoot)) {
|
|
36251
36300
|
return [];
|
|
36252
36301
|
}
|
|
36253
36302
|
return [
|
|
36254
36303
|
createCodeSearchAttemptToolDefinition({
|
|
36255
36304
|
settings: input.settings,
|
|
36256
|
-
apiKey,
|
|
36257
36305
|
workspace: input.workspace,
|
|
36258
36306
|
observability: input.observability,
|
|
36259
36307
|
...input.recordUsage ? { recordUsage: input.recordUsage } : {},
|
|
@@ -38255,7 +38303,7 @@ async function prepareTurnToolRuntime(deps) {
|
|
|
38255
38303
|
backend: activeSandboxBackend ?? groupBoxBackend,
|
|
38256
38304
|
machineWorkspaceRoot: sandboxState.machinePrimarySession?.workspaceRoot ?? null,
|
|
38257
38305
|
observability,
|
|
38258
|
-
//
|
|
38306
|
+
// The deployment's decision-model account pays whatever model billing the
|
|
38259
38307
|
// workspace uses; record them per workspace so the cost stays visible.
|
|
38260
38308
|
recordUsage: async (usage) => {
|
|
38261
38309
|
const shared = {
|
|
@@ -38267,20 +38315,23 @@ async function prepareTurnToolRuntime(deps) {
|
|
|
38267
38315
|
turnId: turn.id,
|
|
38268
38316
|
turnAttemptId: input.attemptId
|
|
38269
38317
|
};
|
|
38270
|
-
|
|
38271
|
-
|
|
38272
|
-
|
|
38273
|
-
|
|
38274
|
-
|
|
38275
|
-
|
|
38276
|
-
|
|
38277
|
-
|
|
38278
|
-
|
|
38279
|
-
|
|
38280
|
-
|
|
38281
|
-
|
|
38282
|
-
|
|
38283
|
-
|
|
38318
|
+
if (usage.decisionInputTokens !== null)
|
|
38319
|
+
await recordUsageEvent3(db, {
|
|
38320
|
+
...shared,
|
|
38321
|
+
eventType: "code_search.decision_input_tokens",
|
|
38322
|
+
quantity: usage.decisionInputTokens,
|
|
38323
|
+
unit: "tokens",
|
|
38324
|
+
idempotencyKey: `usage:code_search.decision_input_tokens:${input.attemptId}:${usage.operationId}`
|
|
38325
|
+
});
|
|
38326
|
+
const costEvent = usage.costSources.includes("estimate") ? "decision_estimated_cost" : "decision_cost";
|
|
38327
|
+
if (usage.decisionCostUsd !== null)
|
|
38328
|
+
await recordUsageEvent3(db, {
|
|
38329
|
+
...shared,
|
|
38330
|
+
eventType: `code_search.${costEvent}`,
|
|
38331
|
+
quantity: Math.round(usage.decisionCostUsd * 1e6),
|
|
38332
|
+
unit: "usd_micros",
|
|
38333
|
+
idempotencyKey: `usage:code_search.${costEvent}:${input.attemptId}:${usage.operationId}`
|
|
38334
|
+
});
|
|
38284
38335
|
},
|
|
38285
38336
|
workspace: async () => {
|
|
38286
38337
|
throwIfWorkerShuttingDown();
|
|
@@ -40490,6 +40541,59 @@ import { SandboxChannelAService as SandboxChannelAService4 } from "@opengeni/run
|
|
|
40490
40541
|
import { sandboxRunAs as sandboxRunAs5 } from "@opengeni/runtime";
|
|
40491
40542
|
import { VideoGenerationRejectedResult, resolveAgentToolFamilies as resolveAgentToolFamilies2 } from "@opengeni/contracts";
|
|
40492
40543
|
|
|
40544
|
+
// src/activities/agent-turn/tool-discovery.ts
|
|
40545
|
+
import { recordUsageEvent as recordUsageEvent4 } from "@opengeni/db";
|
|
40546
|
+
function configuredToolDecisionModel(input) {
|
|
40547
|
+
const route = configuredDecisionModel(input.settings, input.fetch ? { fetch: input.fetch } : {});
|
|
40548
|
+
if (!route) {
|
|
40549
|
+
if (input.settings.decisionModelProvider || input.settings.decisionModelId || input.settings.decisionModelApiKey || input.settings.decisionModelBaseUrl)
|
|
40550
|
+
input.onUnavailable();
|
|
40551
|
+
return void 0;
|
|
40552
|
+
}
|
|
40553
|
+
return {
|
|
40554
|
+
async decide(state, questions, options = {}) {
|
|
40555
|
+
const requestId = crypto.randomUUID();
|
|
40556
|
+
return await runAuxiliaryProviderDispatch(
|
|
40557
|
+
() => route.model.decide(state, questions, {
|
|
40558
|
+
...options,
|
|
40559
|
+
onUsage: async (usage) => {
|
|
40560
|
+
await input.recordUsage(route.id, usage, requestId);
|
|
40561
|
+
await options.onUsage?.(usage);
|
|
40562
|
+
}
|
|
40563
|
+
})
|
|
40564
|
+
);
|
|
40565
|
+
}
|
|
40566
|
+
};
|
|
40567
|
+
}
|
|
40568
|
+
async function recordToolDecisionUsage(input) {
|
|
40569
|
+
const entries = [
|
|
40570
|
+
["input_tokens", input.usage.inputTokens, "tokens"],
|
|
40571
|
+
["output_tokens", input.usage.outputTokens, "tokens"],
|
|
40572
|
+
[
|
|
40573
|
+
input.usage.costSource === "estimate" ? "estimated_provider_cost" : "provider_cost",
|
|
40574
|
+
input.usage.costUsd === null ? null : Math.round(input.usage.costUsd * 1e6),
|
|
40575
|
+
"usd_micros"
|
|
40576
|
+
]
|
|
40577
|
+
];
|
|
40578
|
+
const identity = input.usage.requestId ?? input.requestId;
|
|
40579
|
+
for (const [category, quantity, unit] of entries) {
|
|
40580
|
+
if (quantity === null) continue;
|
|
40581
|
+
await recordUsageEvent4(input.db, {
|
|
40582
|
+
accountId: input.accountId,
|
|
40583
|
+
workspaceId: input.workspaceId,
|
|
40584
|
+
sessionId: input.sessionId,
|
|
40585
|
+
turnId: input.turnId,
|
|
40586
|
+
turnAttemptId: input.turnAttemptId,
|
|
40587
|
+
sourceResourceType: "tool_discovery",
|
|
40588
|
+
sourceResourceId: `${input.modelId}:${identity}`,
|
|
40589
|
+
eventType: `tool_discovery.${category}`,
|
|
40590
|
+
quantity,
|
|
40591
|
+
unit,
|
|
40592
|
+
idempotencyKey: `usage:tool_discovery:${category}:${input.turnAttemptId}:${identity}`
|
|
40593
|
+
});
|
|
40594
|
+
}
|
|
40595
|
+
}
|
|
40596
|
+
|
|
40493
40597
|
// src/activities/agent-turn/video-reference-sandbox.ts
|
|
40494
40598
|
async function resolveVideoReferenceSandboxAccess(request, sandboxState, sdkOwnedSandboxSession) {
|
|
40495
40599
|
if (videoReferencePaths(request).length === 0) return null;
|
|
@@ -41029,9 +41133,9 @@ async function buildTurnAgent(deps) {
|
|
|
41029
41133
|
connectorActionPolicy,
|
|
41030
41134
|
attemptConnectorActionBindings,
|
|
41031
41135
|
...approvedToolCallId ? { approvedToolCallId } : {},
|
|
41032
|
-
//
|
|
41033
|
-
//
|
|
41034
|
-
//
|
|
41136
|
+
// Legacy connector metadata remains available to non-progressive paths.
|
|
41137
|
+
// Progressive discovery reads the authorized pool, never a changing
|
|
41138
|
+
// source directory in its first-request control schemas.
|
|
41035
41139
|
codexConnectorNamespaces: preparedTools.codexConnectorNamespaces,
|
|
41036
41140
|
// Resolved-model routing + gating (legacy defaults when null). The model
|
|
41037
41141
|
// is passed as the model *string* (agent.model = runSettings.openaiModel),
|
|
@@ -41051,6 +41155,23 @@ async function buildTurnAgent(deps) {
|
|
|
41051
41155
|
...imageGenerationOption,
|
|
41052
41156
|
...videoGenerationOption,
|
|
41053
41157
|
lazyToolTransport,
|
|
41158
|
+
toolSearchDecisionModel: configuredToolDecisionModel({
|
|
41159
|
+
settings: runSettings,
|
|
41160
|
+
onUnavailable: () => observability.warn(
|
|
41161
|
+
"Configured decision model is unavailable; using lexical tool discovery"
|
|
41162
|
+
),
|
|
41163
|
+
recordUsage: (modelId, usage, requestId) => recordToolDecisionUsage({
|
|
41164
|
+
db,
|
|
41165
|
+
accountId: input.accountId,
|
|
41166
|
+
workspaceId: input.workspaceId,
|
|
41167
|
+
sessionId: input.sessionId,
|
|
41168
|
+
turnId: turn.id,
|
|
41169
|
+
turnAttemptId: input.attemptId,
|
|
41170
|
+
modelId,
|
|
41171
|
+
usage,
|
|
41172
|
+
requestId
|
|
41173
|
+
})
|
|
41174
|
+
}),
|
|
41054
41175
|
...eventing.toolPreparationReady ? {
|
|
41055
41176
|
toolPreparationReady: eventing.toolPreparationReady,
|
|
41056
41177
|
...eventing.preparedTools?.startDeferredPreparation ? { startToolPreparation: eventing.preparedTools.startDeferredPreparation } : {}
|
|
@@ -41389,13 +41510,18 @@ function createRunAgentTurnActivity(services) {
|
|
|
41389
41510
|
providerRecoveryCount: attempt.providerRecoveryCount,
|
|
41390
41511
|
recoveryStartedAt: attempt.providerRecoveryStartedAt
|
|
41391
41512
|
});
|
|
41513
|
+
const activeRoute = new ActiveRouteDispatchBoundary({
|
|
41514
|
+
session: () => sandboxState.resolvedSandbox?.established.session,
|
|
41515
|
+
isRouteTransition: (error51) => sandboxRouteTransitionCode(error51) !== null
|
|
41516
|
+
});
|
|
41392
41517
|
const checkpointBeforeProviderDispatch = async () => {
|
|
41393
41518
|
assertRecoveryWindow();
|
|
41394
41519
|
await awaitModelCallAdmission();
|
|
41395
41520
|
await checkpointHistoryBeforeProviderDispatch(historySink, {
|
|
41396
41521
|
effectiveSandboxBackend: eventing.modelRunSettings.sandboxBackend,
|
|
41397
41522
|
routingEnabled: routingEnabled(settings),
|
|
41398
|
-
readActiveSandbox: () => readActiveSandbox3(db, input.workspaceId, input.sessionId)
|
|
41523
|
+
readActiveSandbox: () => readActiveSandbox3(db, input.workspaceId, input.sessionId),
|
|
41524
|
+
activeRoute
|
|
41399
41525
|
});
|
|
41400
41526
|
assertRecoveryWindow();
|
|
41401
41527
|
};
|
|
@@ -44085,4 +44211,4 @@ export {
|
|
|
44085
44211
|
createTurnActivities,
|
|
44086
44212
|
createTurnActivitiesFromServices
|
|
44087
44213
|
};
|
|
44088
|
-
//# sourceMappingURL=activities-turn-
|
|
44214
|
+
//# sourceMappingURL=activities-turn-7VX4IWPO.js.map
|