@opengeni/worker-bundle 2.2.1 → 2.3.0-canary.36935312914001
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/credential-restriction.d.ts +3 -0
- package/dist/activities/agent-turn/run-credentials.d.ts +2 -0
- package/dist/activities/scheduled-tasks.d.ts +4 -35
- package/dist/activities/types.d.ts +3 -0
- package/dist/activities/workspace-capture.d.ts +2 -0
- package/dist/{activities-control-55ECL47G.js → activities-control-RDA4E2DM.js} +102 -20
- package/dist/activities-control-RDA4E2DM.js.map +1 -0
- package/dist/{activities-turn-T7Y3BWYO.js → activities-turn-A7LDKRLD.js} +20 -7
- package/dist/activities-turn-A7LDKRLD.js.map +1 -0
- package/dist/{chunk-OWNLATJL.js → chunk-HXPW4HPN.js} +60 -24
- package/dist/chunk-HXPW4HPN.js.map +1 -0
- package/dist/{chunk-IJZU752L.js → chunk-YG27NEMX.js} +34 -1
- package/dist/chunk-YG27NEMX.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/observability-metrics.d.ts +16 -1
- package/dist/workflow-bundle.js +18 -12
- package/dist/workflows/scheduled-tasks.d.ts +4 -0
- package/package.json +21 -21
- package/src/activities/agent-turn/claim.ts +13 -1
- package/src/activities/agent-turn/credential-restriction.ts +14 -0
- package/src/activities/agent-turn/errors.ts +39 -13
- package/src/activities/agent-turn/run-credentials.ts +5 -0
- package/src/activities/agent-turn/run.ts +1 -0
- package/src/activities/agent-turn/tool-environment.ts +4 -0
- package/src/activities/automations.ts +23 -1
- package/src/activities/goals.ts +33 -8
- package/src/activities/sandbox-lease.ts +22 -0
- package/src/activities/scheduled-tasks.ts +89 -25
- package/src/activities/site-auth-maintenance.ts +1 -0
- package/src/activities/types.ts +3 -0
- package/src/activities/workspace-capture.ts +13 -2
- package/src/observability-metrics.ts +55 -1
- package/src/workflows/scheduled-tasks.ts +26 -13
- package/dist/activities-control-55ECL47G.js.map +0 -1
- package/dist/activities-turn-T7Y3BWYO.js.map +0 -1
- package/dist/chunk-IJZU752L.js.map +0 -1
- package/dist/chunk-OWNLATJL.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
observabilityEventBusOptions
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YG27NEMX.js";
|
|
4
4
|
|
|
5
5
|
// src/activity-services.ts
|
|
6
6
|
import {
|
|
@@ -1254,13 +1254,15 @@ import {
|
|
|
1254
1254
|
} from "@opengeni/config";
|
|
1255
1255
|
import {
|
|
1256
1256
|
evaluateWorkspaceModelPolicy,
|
|
1257
|
-
mergeToolRefs
|
|
1257
|
+
mergeToolRefs,
|
|
1258
|
+
readTurnExecutionPolicyV1 as readTurnExecutionPolicyV12
|
|
1258
1259
|
} from "@opengeni/contracts";
|
|
1259
1260
|
import { isCodexBilledModel } from "@opengeni/codex";
|
|
1260
1261
|
import {
|
|
1261
1262
|
enqueueSessionWorkflowWakeIfRunnable,
|
|
1262
1263
|
getWorkspaceModelPolicy,
|
|
1263
1264
|
getSessionGoal,
|
|
1265
|
+
getSessionTurn,
|
|
1264
1266
|
materializeGoalContinuation,
|
|
1265
1267
|
requireSession
|
|
1266
1268
|
} from "@opengeni/db";
|
|
@@ -1344,6 +1346,13 @@ function startOfUtcMonth() {
|
|
|
1344
1346
|
return new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1));
|
|
1345
1347
|
}
|
|
1346
1348
|
|
|
1349
|
+
// src/activities/agent-turn/credential-restriction.ts
|
|
1350
|
+
import { readTurnExecutionPolicyV1 } from "@opengeni/contracts";
|
|
1351
|
+
function turnCredentialRestriction(acceptedPolicy, initialSessionMetadata) {
|
|
1352
|
+
const initialPolicy = readTurnExecutionPolicyV1(initialSessionMetadata);
|
|
1353
|
+
return acceptedPolicy.credentialRestriction === "developer_setup" || initialPolicy.kind === "valid" && initialPolicy.policy.credentialRestriction === "developer_setup" ? "developer_setup" : void 0;
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1347
1356
|
// src/activities/goals.ts
|
|
1348
1357
|
function createGoalActivities(services) {
|
|
1349
1358
|
async function enqueueGoalRetryWake(input) {
|
|
@@ -1403,6 +1412,14 @@ function createGoalActivities(services) {
|
|
|
1403
1412
|
latencyMode: continuationLatencyMode,
|
|
1404
1413
|
latencyModeSource: "continuation"
|
|
1405
1414
|
});
|
|
1415
|
+
const continuationPolicy = {
|
|
1416
|
+
model: continuationModel,
|
|
1417
|
+
reasoningEffort: continuationReasoningEffort,
|
|
1418
|
+
latencyMode: continuationLatencyMode,
|
|
1419
|
+
...turnExecutionPolicy ? { turnExecutionPolicy } : {},
|
|
1420
|
+
tools: withFirstPartyTools(settings, session.tools),
|
|
1421
|
+
sandboxBackend: session.sandboxBackend
|
|
1422
|
+
};
|
|
1406
1423
|
const decision = await materializeGoalContinuation(db, {
|
|
1407
1424
|
accountId: input.accountId,
|
|
1408
1425
|
workspaceId: input.workspaceId,
|
|
@@ -1419,6 +1436,18 @@ function createGoalActivities(services) {
|
|
|
1419
1436
|
// pause can clear on its own; a policy pause needs a model/policy change)
|
|
1420
1437
|
// and rides the same visible-pause channel.
|
|
1421
1438
|
admission: async (tx, causalTurn) => {
|
|
1439
|
+
const sourceTurn = causalTurn ? await getSessionTurn(tx, input.workspaceId, causalTurn.id) : null;
|
|
1440
|
+
if (causalTurn && (!sourceTurn || sourceTurn.sessionId !== input.sessionId)) {
|
|
1441
|
+
throw new Error("Goal continuation source turn is unavailable");
|
|
1442
|
+
}
|
|
1443
|
+
const sourcePolicy = readTurnExecutionPolicyV12(sourceTurn?.metadata);
|
|
1444
|
+
if (turnExecutionPolicy) {
|
|
1445
|
+
const credentialRestriction = turnCredentialRestriction(
|
|
1446
|
+
sourcePolicy.kind === "valid" ? sourcePolicy.policy : turnExecutionPolicy,
|
|
1447
|
+
session.metadata
|
|
1448
|
+
);
|
|
1449
|
+
continuationPolicy.turnExecutionPolicy = credentialRestriction ? { ...turnExecutionPolicy, credentialRestriction } : turnExecutionPolicy;
|
|
1450
|
+
}
|
|
1422
1451
|
const budgetBlocked = modelPolicyBlocked ? null : await goalRunBudgetBlocked(
|
|
1423
1452
|
{ ...service, settings, db: tx },
|
|
1424
1453
|
{
|
|
@@ -1433,14 +1462,7 @@ function createGoalActivities(services) {
|
|
|
1433
1462
|
budgetPausedReason: modelPolicyBlocked ? "limits" : budgetBlocked?.pausedReason ?? "limits"
|
|
1434
1463
|
};
|
|
1435
1464
|
},
|
|
1436
|
-
policy:
|
|
1437
|
-
model: continuationModel,
|
|
1438
|
-
reasoningEffort: continuationReasoningEffort,
|
|
1439
|
-
latencyMode: continuationLatencyMode,
|
|
1440
|
-
...turnExecutionPolicy ? { turnExecutionPolicy } : {},
|
|
1441
|
-
tools: withFirstPartyTools(settings, session.tools),
|
|
1442
|
-
sandboxBackend: session.sandboxBackend
|
|
1443
|
-
},
|
|
1465
|
+
policy: continuationPolicy,
|
|
1444
1466
|
// Long-wait guidance is only given when `wait_for_input` is actually in this
|
|
1445
1467
|
// session's effective first-party selection (the same source the worker
|
|
1446
1468
|
// signs into the delegated token and the API uses to register tools), so
|
|
@@ -8923,6 +8945,8 @@ import {
|
|
|
8923
8945
|
ActiveSessionHistoryLimitExceededError,
|
|
8924
8946
|
ApprovalRunStateLimitExceededError,
|
|
8925
8947
|
nestedPostgresSqlState,
|
|
8948
|
+
databaseFailureCode,
|
|
8949
|
+
isRetryablePersistenceSqlState,
|
|
8926
8950
|
safeDatabaseErrorFacts,
|
|
8927
8951
|
isRetryableDatabaseTransportFailure,
|
|
8928
8952
|
isSessionEventPersistenceError,
|
|
@@ -9729,6 +9753,13 @@ function preClaimAdmissionFailure(error) {
|
|
|
9729
9753
|
}
|
|
9730
9754
|
function retryableDatabaseFailureCode(error) {
|
|
9731
9755
|
const persistenceFailure = isSessionEventPersistenceError(error) ? error : null;
|
|
9756
|
+
if (!persistenceFailure) {
|
|
9757
|
+
const driver = findPostgresDriverError(error);
|
|
9758
|
+
const driverSqlState = typeof driver?.code === "string" ? driver.code : null;
|
|
9759
|
+
if (isRetryablePersistenceSqlState(driverSqlState)) {
|
|
9760
|
+
return databaseFailureCode(driverSqlState);
|
|
9761
|
+
}
|
|
9762
|
+
}
|
|
9732
9763
|
const sqlState = persistenceFailure?.details.sqlState ?? null;
|
|
9733
9764
|
if (sqlState === null && isRetryableDatabaseTransportFailure(error)) {
|
|
9734
9765
|
return "db_failure";
|
|
@@ -10065,6 +10096,9 @@ function findPostgresDriverError(error) {
|
|
|
10065
10096
|
}
|
|
10066
10097
|
return null;
|
|
10067
10098
|
}
|
|
10099
|
+
function isRawDatabaseQueryError(error) {
|
|
10100
|
+
return error instanceof Error && "query" in error && typeof error.query === "string" && "params" in error && Array.isArray(error.params);
|
|
10101
|
+
}
|
|
10068
10102
|
function agentRunFailurePayload(error, options = {}) {
|
|
10069
10103
|
const failure = baseAgentRunFailurePayload(error, options);
|
|
10070
10104
|
const diagnostic = materializationVerificationDiagnostic(error);
|
|
@@ -10083,7 +10117,8 @@ function baseAgentRunFailurePayload(error, options = {}) {
|
|
|
10083
10117
|
return { error: error.message, code: "retained_attachment_transport_limit", retryable: false };
|
|
10084
10118
|
}
|
|
10085
10119
|
if (error instanceof MandatoryHistoryPersistenceError) {
|
|
10086
|
-
const
|
|
10120
|
+
const databaseFailure = isSessionEventPersistenceError(error.cause) || findPostgresDriverError(error.cause) !== null || isRawDatabaseQueryError(error.cause);
|
|
10121
|
+
const underlying = databaseFailure ? agentRunFailurePayload(error.cause, options) : {
|
|
10087
10122
|
error: error.cause instanceof Error ? error.cause.message : String(error.cause)
|
|
10088
10123
|
};
|
|
10089
10124
|
return {
|
|
@@ -10091,6 +10126,18 @@ function baseAgentRunFailurePayload(error, options = {}) {
|
|
|
10091
10126
|
historyPersistenceStage: error.stage
|
|
10092
10127
|
};
|
|
10093
10128
|
}
|
|
10129
|
+
const postgresDriverError = findPostgresDriverError(error);
|
|
10130
|
+
const rawOrmFailure = isRawDatabaseQueryError(error);
|
|
10131
|
+
if ((postgresDriverError || rawOrmFailure) && !isSessionEventPersistenceError(error)) {
|
|
10132
|
+
const database = safeDatabaseErrorFacts(postgresDriverError ?? error);
|
|
10133
|
+
const sqlState = postgresDriverError ? nestedPostgresSqlState(postgresDriverError) : null;
|
|
10134
|
+
return {
|
|
10135
|
+
error: "OpenGeni encountered a database error.",
|
|
10136
|
+
code: databaseFailureCode(sqlState),
|
|
10137
|
+
sqlState,
|
|
10138
|
+
...Object.keys(database).length > 0 ? { database } : {}
|
|
10139
|
+
};
|
|
10140
|
+
}
|
|
10094
10141
|
const safetyRefusalDiagnostic = providerSafetyRefusalDiagnostic(error);
|
|
10095
10142
|
if (safetyRefusalDiagnostic !== void 0) {
|
|
10096
10143
|
return {
|
|
@@ -10307,18 +10354,6 @@ function baseAgentRunFailurePayload(error, options = {}) {
|
|
|
10307
10354
|
}
|
|
10308
10355
|
return { error: message, code: "provider_unavailable", retryable: true };
|
|
10309
10356
|
}
|
|
10310
|
-
const postgresDriverError = findPostgresDriverError(error);
|
|
10311
|
-
if (postgresDriverError) {
|
|
10312
|
-
const database = safeDatabaseErrorFacts(postgresDriverError);
|
|
10313
|
-
const sqlState = nestedPostgresSqlState(postgresDriverError);
|
|
10314
|
-
if (sqlState !== null || Object.keys(database).length > 0) {
|
|
10315
|
-
return {
|
|
10316
|
-
error: message,
|
|
10317
|
-
sqlState,
|
|
10318
|
-
...Object.keys(database).length > 0 ? { database } : {}
|
|
10319
|
-
};
|
|
10320
|
-
}
|
|
10321
|
-
}
|
|
10322
10357
|
return { error: message };
|
|
10323
10358
|
}
|
|
10324
10359
|
var CODEX_ALLOWANCE_FALLBACK_MS = 5 * 60 * 6e4;
|
|
@@ -10436,6 +10471,7 @@ export {
|
|
|
10436
10471
|
createCodexCapacityActivities,
|
|
10437
10472
|
agentRunAdmissionDenial,
|
|
10438
10473
|
createDocumentActivities,
|
|
10474
|
+
turnCredentialRestriction,
|
|
10439
10475
|
createGoalActivities,
|
|
10440
10476
|
withFirstPartyTools,
|
|
10441
10477
|
createKnowledgeSourceSyncActivities,
|
|
@@ -10537,4 +10573,4 @@ export {
|
|
|
10537
10573
|
codexUsageLimitFailurePayload,
|
|
10538
10574
|
CODEX_USAGE_LIMIT_MAX_RESUME_MS
|
|
10539
10575
|
};
|
|
10540
|
-
//# sourceMappingURL=chunk-
|
|
10576
|
+
//# sourceMappingURL=chunk-HXPW4HPN.js.map
|