@opengeni/worker-bundle 1.0.2 → 1.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.
- package/dist/activities/agent-run-admission.d.ts +1 -14
- package/dist/activities/agent-turn/admission.d.ts +3 -2
- package/dist/activities/agent-turn/compaction-prep.d.ts +1 -0
- package/dist/activities/agent-turn/errors.d.ts +3 -0
- package/dist/activities/agent-turn/finalization-monitor.d.ts +6 -1
- package/dist/activities/agent-turn/model-usage.d.ts +10 -0
- package/dist/activities/agent-turn/provider-recovery-metrics.d.ts +18 -0
- package/dist/activities/agent-turn/turn-context.d.ts +5 -0
- package/dist/activities/goals.d.ts +1 -17
- package/dist/activities/types.d.ts +1 -1
- package/dist/{activities-control-BNPTRTOE.js → activities-control-QSDPXLLD.js} +26 -10
- package/dist/activities-control-QSDPXLLD.js.map +1 -0
- package/dist/{activities-turn-5LGZOSVU.js → activities-turn-BMY3CDKL.js} +191 -35
- package/dist/activities-turn-BMY3CDKL.js.map +1 -0
- package/dist/{chunk-LJX7Z2KP.js → chunk-JKMG5ZHH.js} +55 -167
- package/dist/chunk-JKMG5ZHH.js.map +1 -0
- package/dist/{chunk-3ZTRWDMN.js → chunk-XONQEVAD.js} +1 -1
- package/dist/chunk-XONQEVAD.js.map +1 -0
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/observability-metrics.d.ts +1 -1
- package/dist/workflow-bundle.js +1 -1
- package/package.json +21 -21
- package/src/activities/agent-run-admission.ts +1 -98
- package/src/activities/agent-turn/admission.ts +11 -5
- package/src/activities/agent-turn/claim.ts +12 -0
- package/src/activities/agent-turn/compaction-prep.ts +35 -1
- package/src/activities/agent-turn/errors.ts +51 -19
- package/src/activities/agent-turn/failure-settlement.ts +31 -1
- package/src/activities/agent-turn/finalization-monitor.ts +14 -1
- package/src/activities/agent-turn/finalization.ts +5 -0
- package/src/activities/agent-turn/model-usage.ts +38 -0
- package/src/activities/agent-turn/provider-recovery-metrics.ts +64 -0
- package/src/activities/agent-turn/run.ts +1 -0
- package/src/activities/agent-turn/stream-attempt.ts +32 -16
- package/src/activities/agent-turn/tool-environment.ts +9 -2
- package/src/activities/agent-turn/turn-context.ts +4 -0
- package/src/activities/goals.ts +17 -113
- package/src/activities/knowledge-indexing.ts +2 -2
- package/src/activities/scheduled-tasks.ts +18 -3
- package/src/activities/types.ts +1 -0
- package/src/index.ts +0 -2
- package/src/observability-metrics.ts +1 -0
- package/dist/activities-control-BNPTRTOE.js.map +0 -1
- package/dist/activities-turn-5LGZOSVU.js.map +0 -1
- package/dist/chunk-3ZTRWDMN.js.map +0 -1
- package/dist/chunk-LJX7Z2KP.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
observabilityEventBusOptions
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XONQEVAD.js";
|
|
4
4
|
|
|
5
5
|
// src/activity-services.ts
|
|
6
6
|
import {
|
|
@@ -1235,109 +1235,25 @@ function createDocumentActivities(services, resolveDocumentServices) {
|
|
|
1235
1235
|
// src/activities/goals.ts
|
|
1236
1236
|
import {
|
|
1237
1237
|
allowedFirstPartyMcpToolsForSession,
|
|
1238
|
-
|
|
1239
|
-
isModelAvailableForNewSelection,
|
|
1240
|
-
policyProviderIdForModel,
|
|
1241
|
-
resolveModelProvider,
|
|
1242
|
-
resolveTurnExecutionPolicyV1,
|
|
1243
|
-
withCodexCatalogProvider,
|
|
1244
|
-
withXaiSubscriptionCatalogProvider,
|
|
1245
|
-
WORKSPACE_GATEWAY_MODEL_ID_PREFIX,
|
|
1246
|
-
WORKSPACE_OPENROUTER_MODEL_ID_PREFIX
|
|
1238
|
+
resolveTurnExecutionPolicyV1
|
|
1247
1239
|
} from "@opengeni/config";
|
|
1248
1240
|
import {
|
|
1249
|
-
evaluateWorkspaceModelPolicy,
|
|
1250
1241
|
mergeToolRefs,
|
|
1251
1242
|
readTurnExecutionPolicyV1 as readTurnExecutionPolicyV12
|
|
1252
1243
|
} from "@opengeni/contracts";
|
|
1253
|
-
import { isCodexBilledModel } from "@opengeni/codex";
|
|
1254
1244
|
import {
|
|
1255
1245
|
enqueueSessionWorkflowWakeIfRunnable,
|
|
1256
|
-
getWorkspaceModelPolicy,
|
|
1257
1246
|
getSessionGoal,
|
|
1258
1247
|
getSessionTurn,
|
|
1259
1248
|
materializeGoalContinuation,
|
|
1260
1249
|
requireSession
|
|
1261
1250
|
} from "@opengeni/db";
|
|
1262
1251
|
import {
|
|
1263
|
-
modelFundingForAdmission
|
|
1264
|
-
|
|
1265
|
-
|
|
1252
|
+
modelFundingForAdmission,
|
|
1253
|
+
goalRunBudgetBlocked,
|
|
1254
|
+
resolveGoalModelAdmission
|
|
1266
1255
|
} from "@opengeni/core";
|
|
1267
|
-
|
|
1268
|
-
// src/activities/agent-run-admission.ts
|
|
1269
|
-
import { configuredStaticUsageLimits } from "@opengeni/config";
|
|
1270
|
-
import { modelFundingForAdmission } from "@opengeni/core";
|
|
1271
|
-
import {
|
|
1272
|
-
checkWorkspaceAllowance,
|
|
1273
|
-
getBillingBalance,
|
|
1274
|
-
isCodexBilledTurn,
|
|
1275
|
-
sumUsageQuantity
|
|
1276
|
-
} from "@opengeni/db";
|
|
1277
|
-
async function agentRunAdmissionDenial(services, input) {
|
|
1278
|
-
const codexBilled = await isCodexBilledTurn({
|
|
1279
|
-
db: services.db,
|
|
1280
|
-
settings: services.settings,
|
|
1281
|
-
workspaceId: input.workspaceId,
|
|
1282
|
-
model: input.model
|
|
1283
|
-
});
|
|
1284
|
-
const externallyBilled = modelFundingForAdmission(
|
|
1285
|
-
services.settings,
|
|
1286
|
-
input.model,
|
|
1287
|
-
codexBilled
|
|
1288
|
-
).fundedWithoutCredits;
|
|
1289
|
-
if (!externallyBilled && (services.settings.billingMode === "stripe" || services.settings.usageLimitsMode === "managed")) {
|
|
1290
|
-
if (services.entitlements) {
|
|
1291
|
-
const decision = await services.entitlements.admitRun({
|
|
1292
|
-
accountId: input.accountId,
|
|
1293
|
-
workspaceId: input.workspaceId,
|
|
1294
|
-
action: "agent_run:create",
|
|
1295
|
-
quantity: input.requestedAgentRuns
|
|
1296
|
-
});
|
|
1297
|
-
if (!decision.allowed) return "insufficient_credits";
|
|
1298
|
-
} else {
|
|
1299
|
-
const balance = await getBillingBalance(services.db, input.accountId);
|
|
1300
|
-
if (balance.balanceMicros <= 0) return "insufficient_credits";
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
1303
|
-
if (!externallyBilled) {
|
|
1304
|
-
const refusal = await checkWorkspaceAllowance(services.db, {
|
|
1305
|
-
accountId: input.accountId,
|
|
1306
|
-
workspaceId: input.workspaceId,
|
|
1307
|
-
subjectId: input.initiatingHumanSubjectId ?? null
|
|
1308
|
-
});
|
|
1309
|
-
if (refusal) return refusal.code;
|
|
1310
|
-
}
|
|
1311
|
-
if (services.settings.usageLimitsMode !== "static" && services.settings.usageLimitsMode !== "managed") {
|
|
1312
|
-
return null;
|
|
1313
|
-
}
|
|
1314
|
-
const limits = configuredStaticUsageLimits(services.settings);
|
|
1315
|
-
if (!externallyBilled && limits.maxMonthlyCostMicrosPerAccount) {
|
|
1316
|
-
const used = await sumUsageQuantity(services.db, {
|
|
1317
|
-
accountId: input.accountId,
|
|
1318
|
-
eventType: "model.cost",
|
|
1319
|
-
since: startOfUtcMonth()
|
|
1320
|
-
});
|
|
1321
|
-
if (used >= limits.maxMonthlyCostMicrosPerAccount) {
|
|
1322
|
-
return "monthly_model_cost_limit";
|
|
1323
|
-
}
|
|
1324
|
-
}
|
|
1325
|
-
if (limits.maxMonthlyAgentRunsPerWorkspace) {
|
|
1326
|
-
const used = await sumUsageQuantity(services.db, {
|
|
1327
|
-
workspaceId: input.workspaceId,
|
|
1328
|
-
eventType: "agent_run.created",
|
|
1329
|
-
since: startOfUtcMonth()
|
|
1330
|
-
});
|
|
1331
|
-
if (used + input.requestedAgentRuns > limits.maxMonthlyAgentRunsPerWorkspace) {
|
|
1332
|
-
return "monthly_agent_run_limit";
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1335
|
-
return null;
|
|
1336
|
-
}
|
|
1337
|
-
function startOfUtcMonth() {
|
|
1338
|
-
const now = /* @__PURE__ */ new Date();
|
|
1339
|
-
return new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1));
|
|
1340
|
-
}
|
|
1256
|
+
import { goalContinuationModelDecision, goalRunBudgetBlocked as goalRunBudgetBlocked2 } from "@opengeni/core";
|
|
1341
1257
|
|
|
1342
1258
|
// src/activities/agent-turn/credential-restriction.ts
|
|
1343
1259
|
import { readTurnExecutionPolicyV1 } from "@opengeni/contracts";
|
|
@@ -1373,29 +1289,18 @@ function createGoalActivities(services) {
|
|
|
1373
1289
|
if (session.status === "failed" || session.status === "cancelled") {
|
|
1374
1290
|
return { action: "none" };
|
|
1375
1291
|
}
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1292
|
+
const modelDecision = await resolveGoalModelAdmission(db, catalogSourceSettings, {
|
|
1293
|
+
accountId: input.accountId,
|
|
1294
|
+
workspaceId: input.workspaceId,
|
|
1295
|
+
model: session.model,
|
|
1296
|
+
codexCompactionMode: session.codexCompactionMode,
|
|
1297
|
+
latencyMode: session.latencyMode
|
|
1298
|
+
});
|
|
1299
|
+
const settings = modelDecision.settings;
|
|
1300
|
+
const continuationModel = modelDecision.model;
|
|
1379
1301
|
const continuationReasoningEffort = session.reasoningEffort;
|
|
1380
1302
|
const continuationLatencyMode = session.latencyMode;
|
|
1381
|
-
const
|
|
1382
|
-
if (inheritedContinuationModel.startsWith(WORKSPACE_GATEWAY_MODEL_ID_PREFIX) || inheritedContinuationModel.startsWith(WORKSPACE_OPENROUTER_MODEL_ID_PREFIX) || session.model.startsWith(WORKSPACE_GATEWAY_MODEL_ID_PREFIX) || session.model.startsWith(WORKSPACE_OPENROUTER_MODEL_ID_PREFIX)) {
|
|
1383
|
-
settings = (await resolveWorkspaceCatalogSettings(db, catalogSourceSettings, {
|
|
1384
|
-
accountId: input.accountId,
|
|
1385
|
-
workspaceId: input.workspaceId,
|
|
1386
|
-
retainedProductModelIds: [inheritedContinuationModel, session.model]
|
|
1387
|
-
})).settings;
|
|
1388
|
-
}
|
|
1389
|
-
const modelDecision = goalContinuationModelDecision({
|
|
1390
|
-
settings,
|
|
1391
|
-
workspaceModelPolicy,
|
|
1392
|
-
inheritedModel: inheritedContinuationModel
|
|
1393
|
-
});
|
|
1394
|
-
continuationModel = modelDecision.model;
|
|
1395
|
-
let modelPolicyBlocked = modelDecision.blocked;
|
|
1396
|
-
if (!modelPolicyBlocked && session.codexCompactionMode === "remote_v2" && !isCodexBilledModel(continuationModel)) {
|
|
1397
|
-
modelPolicyBlocked = `session is locked to Codex remote compaction v2; model "${continuationModel}" is not a Codex subscription model`;
|
|
1398
|
-
}
|
|
1303
|
+
const modelPolicyBlocked = modelDecision.blocked;
|
|
1399
1304
|
const turnExecutionPolicy = modelPolicyBlocked ? void 0 : resolveTurnExecutionPolicyV1(settings, {
|
|
1400
1305
|
modelId: continuationModel,
|
|
1401
1306
|
requestedModelId: null,
|
|
@@ -1450,9 +1355,10 @@ function createGoalActivities(services) {
|
|
|
1450
1355
|
initiatingHumanSubjectId: causalTurn?.initiatingHumanSubjectId ?? null
|
|
1451
1356
|
}
|
|
1452
1357
|
);
|
|
1358
|
+
const pausedReason = modelPolicyBlocked ? modelDecision.pausedReason : budgetBlocked?.pausedReason;
|
|
1453
1359
|
return {
|
|
1454
1360
|
budgetBlocked: modelPolicyBlocked ?? budgetBlocked?.message ?? null,
|
|
1455
|
-
|
|
1361
|
+
...pausedReason ? { budgetPausedReason: pausedReason } : {}
|
|
1456
1362
|
};
|
|
1457
1363
|
},
|
|
1458
1364
|
policy: continuationPolicy,
|
|
@@ -1483,34 +1389,6 @@ function createGoalActivities(services) {
|
|
|
1483
1389
|
maybeContinueGoal
|
|
1484
1390
|
};
|
|
1485
1391
|
}
|
|
1486
|
-
function goalContinuationModelDecision(input) {
|
|
1487
|
-
const catalogSettings = input.settings.supergrokSubscriptionEnabled ? withXaiSubscriptionCatalogProvider(
|
|
1488
|
-
input.settings.codexSubscriptionEnabled ? withCodexCatalogProvider(input.settings) : input.settings
|
|
1489
|
-
) : input.settings.codexSubscriptionEnabled ? withCodexCatalogProvider(input.settings) : input.settings;
|
|
1490
|
-
const policyBlocks = (modelId) => input.workspaceModelPolicy !== null && !evaluateWorkspaceModelPolicy(input.workspaceModelPolicy, {
|
|
1491
|
-
providerId: policyProviderIdForModel(catalogSettings, modelId),
|
|
1492
|
-
modelId
|
|
1493
|
-
}).allowed;
|
|
1494
|
-
if (!resolveModelProvider(catalogSettings, input.inheritedModel)) {
|
|
1495
|
-
return {
|
|
1496
|
-
model: input.inheritedModel,
|
|
1497
|
-
blocked: `model "${input.inheritedModel}" is no longer in the deployment or workspace catalog; choose an available model before resuming the goal`
|
|
1498
|
-
};
|
|
1499
|
-
}
|
|
1500
|
-
if (!isModelAvailableForNewSelection(catalogSettings, input.inheritedModel)) {
|
|
1501
|
-
return {
|
|
1502
|
-
model: input.inheritedModel,
|
|
1503
|
-
blocked: `model "${input.inheritedModel}" is retired from new selection; choose an available model before resuming the goal`
|
|
1504
|
-
};
|
|
1505
|
-
}
|
|
1506
|
-
if (!policyBlocks(input.inheritedModel)) {
|
|
1507
|
-
return { model: input.inheritedModel, blocked: null };
|
|
1508
|
-
}
|
|
1509
|
-
return {
|
|
1510
|
-
model: input.inheritedModel,
|
|
1511
|
-
blocked: `workspace model policy blocks model "${input.inheritedModel}"; pick an allowed model or change the workspace model policy`
|
|
1512
|
-
};
|
|
1513
|
-
}
|
|
1514
1392
|
function goalContinuationPrompt(_goal, _autoContinuation, _cap, options = {}) {
|
|
1515
1393
|
const waitingGuidance = options.inputWaitAvailable ? [
|
|
1516
1394
|
"Waiting on child sessions, background commands, or external events:",
|
|
@@ -1587,20 +1465,6 @@ function withFirstPartyTools(settings, tools) {
|
|
|
1587
1465
|
}
|
|
1588
1466
|
return mergeToolRefs(tools, [{ kind: "mcp", id: "opengeni" }]);
|
|
1589
1467
|
}
|
|
1590
|
-
async function goalRunBudgetBlocked(services, input) {
|
|
1591
|
-
const denial = await agentRunAdmissionDenial(services, { ...input, requestedAgentRuns: 1 });
|
|
1592
|
-
if (denial === null) return null;
|
|
1593
|
-
if (denial === "allowance_exhausted") {
|
|
1594
|
-
return { pausedReason: "allowance", message: "Opengeni usage allowance exhausted" };
|
|
1595
|
-
}
|
|
1596
|
-
const limits = configuredStaticUsageLimits2(services.settings);
|
|
1597
|
-
const messages = {
|
|
1598
|
-
insufficient_credits: "insufficient Opengeni credits",
|
|
1599
|
-
monthly_model_cost_limit: `monthly model cost limit reached (${limits.maxMonthlyCostMicrosPerAccount} micros)`,
|
|
1600
|
-
monthly_agent_run_limit: `monthly agent run limit reached (${limits.maxMonthlyAgentRunsPerWorkspace})`
|
|
1601
|
-
};
|
|
1602
|
-
return { pausedReason: "limits", message: messages[denial] };
|
|
1603
|
-
}
|
|
1604
1468
|
|
|
1605
1469
|
// src/activities/knowledge-source-sync.ts
|
|
1606
1470
|
import {
|
|
@@ -9222,6 +9086,7 @@ import {
|
|
|
9222
9086
|
safeDatabaseErrorFacts,
|
|
9223
9087
|
isRetryableDatabaseTransportFailure,
|
|
9224
9088
|
isSessionEventPersistenceError,
|
|
9089
|
+
DatabaseTransactionError,
|
|
9225
9090
|
SandboxLeaseTransitionError as SandboxLeaseTransitionError3
|
|
9226
9091
|
} from "@opengeni/db";
|
|
9227
9092
|
import {
|
|
@@ -9903,6 +9768,10 @@ var PROVIDER_BACKPRESSURE_DELAY_MS = 6e4;
|
|
|
9903
9768
|
var PROVIDER_CONNECTIVITY_BACKOFF_MS = [2e3, 5e3, 15e3, 3e4, 6e4];
|
|
9904
9769
|
var MAX_AUTOMATIC_PROVIDER_RECOVERIES = PROVIDER_CONNECTIVITY_BACKOFF_MS.length;
|
|
9905
9770
|
var PROVIDER_RATE_LIMIT_BACKOFF_MS = [1e4, 2e4, 4e4, 6e4, 12e4];
|
|
9771
|
+
function providerRecoveryJitterMs(delayMs, sample) {
|
|
9772
|
+
const bounded = Number.isFinite(sample) ? Math.max(0, Math.min(sample, 1)) : 0;
|
|
9773
|
+
return Math.floor(Math.min(5e3, delayMs * 0.2) * bounded);
|
|
9774
|
+
}
|
|
9906
9775
|
var POST_COMPACTION_CONTINUATION_EMPTY_CODE = "post_compaction_continuation_empty";
|
|
9907
9776
|
var PostCompactionContinuationEmptyError = class extends Error {
|
|
9908
9777
|
code = POST_COMPACTION_CONTINUATION_EMPTY_CODE;
|
|
@@ -9935,7 +9804,7 @@ function providerRecoveryResult(input) {
|
|
|
9935
9804
|
) : PROVIDER_BACKPRESSURE_DELAY_MS;
|
|
9936
9805
|
return {
|
|
9937
9806
|
status: "recovering",
|
|
9938
|
-
continueDelayMs
|
|
9807
|
+
continueDelayMs: continueDelayMs + (input.failureCode === "provider_rate_limited" || input.failureCode === "provider_unavailable" || input.failureCode === "upstream_connectivity_unavailable" ? providerRecoveryJitterMs(continueDelayMs, input.jitterSample ?? 0) : 0)
|
|
9939
9808
|
};
|
|
9940
9809
|
}
|
|
9941
9810
|
function providerRecoveryExhaustedFailure(failure, recovery) {
|
|
@@ -10064,6 +9933,11 @@ function retryableDatabaseFailureCode(error, requireDatabaseProvenance = false)
|
|
|
10064
9933
|
const boundaries = /* @__PURE__ */ new Set();
|
|
10065
9934
|
const ownDatabaseNodes = /* @__PURE__ */ new Set();
|
|
10066
9935
|
const codes = /* @__PURE__ */ new Set();
|
|
9936
|
+
const ownChildren = (node) => node instanceof DatabaseTransactionError ? (
|
|
9937
|
+
// Callback failures retained beside a failed rollback supply vetoes,
|
|
9938
|
+
// never driver provenance for a provider's connection-looking error.
|
|
9939
|
+
[...graph.get(node)].filter((child) => child === node.cause)
|
|
9940
|
+
) : [...graph.get(node)];
|
|
10067
9941
|
for (const node of graph.keys()) {
|
|
10068
9942
|
if (isRoutingMutationOutcomeUnknownError(node)) return null;
|
|
10069
9943
|
const record = node;
|
|
@@ -10072,12 +9946,12 @@ function retryableDatabaseFailureCode(error, requireDatabaseProvenance = false)
|
|
|
10072
9946
|
const sqlState = isSessionEventPersistenceError(node) ? node.details.sqlState : record.name === "PostgresError" && typeof record.code === "string" ? record.code : null;
|
|
10073
9947
|
if (requireDatabaseProvenance ? isRunningTurnDatabaseConnectionSqlState(sqlState) : isDatabaseConnectionSqlState(sqlState))
|
|
10074
9948
|
transports.add(node);
|
|
10075
|
-
if (node instanceof DrizzleQueryError || isSessionEventPersistenceError(node)) {
|
|
9949
|
+
if (node instanceof DrizzleQueryError || node instanceof DatabaseTransactionError || isSessionEventPersistenceError(node)) {
|
|
10076
9950
|
const queue = [node];
|
|
10077
9951
|
for (const source of queue) {
|
|
10078
9952
|
if (ownDatabaseNodes.has(source)) continue;
|
|
10079
9953
|
ownDatabaseNodes.add(source);
|
|
10080
|
-
queue.push(...
|
|
9954
|
+
queue.push(...ownChildren(source));
|
|
10081
9955
|
}
|
|
10082
9956
|
}
|
|
10083
9957
|
}
|
|
@@ -10088,13 +9962,13 @@ function retryableDatabaseFailureCode(error, requireDatabaseProvenance = false)
|
|
|
10088
9962
|
if (seen.has(node)) continue;
|
|
10089
9963
|
seen.add(node);
|
|
10090
9964
|
if (transports.has(node)) return true;
|
|
10091
|
-
queue.push(...
|
|
9965
|
+
queue.push(...ownChildren(node));
|
|
10092
9966
|
}
|
|
10093
9967
|
return false;
|
|
10094
9968
|
};
|
|
10095
9969
|
for (const node of graph.keys()) {
|
|
10096
9970
|
const record = node;
|
|
10097
|
-
if (node instanceof DrizzleQueryError) {
|
|
9971
|
+
if (node instanceof DrizzleQueryError || node instanceof DatabaseTransactionError) {
|
|
10098
9972
|
boundaries.add(node);
|
|
10099
9973
|
if (hasOwnTransport(node)) codes.add("db_failure");
|
|
10100
9974
|
}
|
|
@@ -10118,6 +9992,12 @@ function retryableDatabaseFailureCode(error, requireDatabaseProvenance = false)
|
|
|
10118
9992
|
}
|
|
10119
9993
|
}
|
|
10120
9994
|
var RUNNING_TURN_DATABASE_TRANSPORT_CODES = /* @__PURE__ */ new Set([
|
|
9995
|
+
// postgres.js reports these for a physically lost connection, including
|
|
9996
|
+
// transaction cleanup after its socket has already closed. Own-client
|
|
9997
|
+
// provenance and the unknown-outcome veto remain mandatory above.
|
|
9998
|
+
"CONNECTION_CLOSED",
|
|
9999
|
+
"CONNECTION_DESTROYED",
|
|
10000
|
+
"CONNECTION_ENDED",
|
|
10121
10001
|
"ECONNREFUSED",
|
|
10122
10002
|
"ECONNRESET",
|
|
10123
10003
|
"CONNECT_TIMEOUT"
|
|
@@ -10402,14 +10282,25 @@ function providerSafetyRefusalDiagnostic(error) {
|
|
|
10402
10282
|
function isProviderSafetyRefusal(error) {
|
|
10403
10283
|
return providerSafetyRefusalDiagnostic(error) !== void 0;
|
|
10404
10284
|
}
|
|
10285
|
+
function providerHttpStatus(error) {
|
|
10286
|
+
let current = error;
|
|
10287
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10288
|
+
for (let depth = 0; depth < 6 && current && typeof current === "object"; depth += 1) {
|
|
10289
|
+
if (seen.has(current)) break;
|
|
10290
|
+
seen.add(current);
|
|
10291
|
+
const value = current;
|
|
10292
|
+
const status = Number(value.status ?? value.statusCode);
|
|
10293
|
+
if (Number.isInteger(status) && status >= 100 && status < 600) return status;
|
|
10294
|
+
current = value.cause;
|
|
10295
|
+
}
|
|
10296
|
+
return void 0;
|
|
10297
|
+
}
|
|
10405
10298
|
function isTransientProviderError(error) {
|
|
10406
10299
|
if (error instanceof ResponsesStreamingTerminalError) {
|
|
10407
10300
|
return error.category === "unavailable";
|
|
10408
10301
|
}
|
|
10409
10302
|
if (isProviderSafetyRefusal(error)) return false;
|
|
10410
|
-
const status =
|
|
10411
|
-
error.status ?? error.statusCode
|
|
10412
|
-
) : void 0;
|
|
10303
|
+
const status = providerHttpStatus(error);
|
|
10413
10304
|
if (status !== void 0 && Number.isFinite(status)) {
|
|
10414
10305
|
return status >= 500 && status < 600;
|
|
10415
10306
|
}
|
|
@@ -10592,9 +10483,7 @@ function baseAgentRunFailurePayload(error, options = {}) {
|
|
|
10592
10483
|
};
|
|
10593
10484
|
}
|
|
10594
10485
|
const message = error instanceof Error ? error.message : String(error);
|
|
10595
|
-
const status =
|
|
10596
|
-
error.status ?? error.statusCode
|
|
10597
|
-
) : void 0;
|
|
10486
|
+
const status = providerHttpStatus(error);
|
|
10598
10487
|
const code = typeof error === "object" && error !== null && "code" in error ? String(error.code) : void 0;
|
|
10599
10488
|
if (error instanceof ActiveSessionHistoryLimitExceededError) {
|
|
10600
10489
|
return {
|
|
@@ -10928,7 +10817,6 @@ export {
|
|
|
10928
10817
|
signalPendingCodexCapacityWakeTargets,
|
|
10929
10818
|
armAndReconcileCodexCapacityWait,
|
|
10930
10819
|
createCodexCapacityActivities,
|
|
10931
|
-
agentRunAdmissionDenial,
|
|
10932
10820
|
createDocumentActivities,
|
|
10933
10821
|
turnCredentialRestriction,
|
|
10934
10822
|
createGoalActivities,
|
|
@@ -11037,4 +10925,4 @@ export {
|
|
|
11037
10925
|
CODEX_USAGE_LIMIT_MAX_RESUME_MS,
|
|
11038
10926
|
classifyClaudeCredentialFailure
|
|
11039
10927
|
};
|
|
11040
|
-
//# sourceMappingURL=chunk-
|
|
10928
|
+
//# sourceMappingURL=chunk-JKMG5ZHH.js.map
|