@opengeni/worker-bundle 0.17.2 → 0.20.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 +12 -0
- package/dist/activities/agent-turn.d.ts +25 -0
- package/dist/activities/browser-state-artifact-reaper.d.ts +29 -0
- package/dist/activities/capabilities.d.ts +6 -0
- package/dist/activities/codex-capacity.d.ts +1 -0
- package/dist/activities/environment.d.ts +7 -1
- package/dist/activities/packs.d.ts +8 -10
- package/dist/activities/session-state.d.ts +4 -2
- package/dist/activities/site-auth-maintenance.d.ts +27 -0
- package/dist/activities/types.d.ts +16 -0
- package/dist/activities/video-generation-admission.d.ts +9 -4
- package/dist/activities/video-generation-credential.d.ts +17 -0
- package/dist/activities/video-reference-staging.d.ts +7 -1
- package/dist/activities/xai-auth.d.ts +23 -0
- package/dist/activities/xai-image-generation.d.ts +26 -0
- package/dist/activities/xai-video-generation.d.ts +18 -0
- package/dist/{activities-control-44KBWLSM.js → activities-control-XURE4VKN.js} +387 -51
- package/dist/activities-control-XURE4VKN.js.map +1 -0
- package/dist/activities-control.d.ts +8 -0
- package/dist/{activities-turn-K4CEDEGJ.js → activities-turn-6EBXGGLS.js} +5312 -3951
- package/dist/activities-turn-6EBXGGLS.js.map +1 -0
- package/dist/activities.d.ts +9 -1
- package/dist/{chunk-KKCRGAGZ.js → chunk-5GRJIP5H.js} +99 -98
- package/dist/chunk-5GRJIP5H.js.map +1 -0
- package/dist/{chunk-E3RI3I33.js → chunk-TYNPCG4U.js} +88 -10
- package/dist/chunk-TYNPCG4U.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +49 -2
- package/dist/index.js.map +1 -1
- package/dist/model-checkpoint-memory-collector.d.ts +1 -0
- package/dist/model-context-contributions.d.ts +40 -0
- package/dist/observability-metrics.d.ts +20 -1
- package/dist/sandbox-routing.d.ts +4 -0
- package/dist/workflow-bundle.js +59 -15
- package/dist/workflows/activities.d.ts +1 -1
- package/dist/workflows/site-auth-maintenance.d.ts +2 -0
- package/dist/workflows.d.ts +1 -0
- package/package.json +16 -15
- package/src/activities/agent-run-admission.ts +76 -0
- package/src/activities/agent-turn.ts +1178 -142
- package/src/activities/browser-state-artifact-reaper.ts +120 -0
- package/src/activities/capabilities.ts +10 -0
- package/src/activities/codex-capacity.ts +48 -1
- package/src/activities/environment.ts +14 -8
- package/src/activities/goals.ts +2 -1
- package/src/activities/packs.ts +45 -122
- package/src/activities/parent-wake.ts +13 -1
- package/src/activities/scheduled-tasks.ts +30 -73
- package/src/activities/session-state.ts +18 -0
- package/src/activities/site-auth-maintenance.ts +269 -0
- package/src/activities/types.ts +17 -0
- package/src/activities/video-generation-admission.ts +37 -4
- package/src/activities/video-generation-credential.ts +84 -6
- package/src/activities/video-generation-reconciliation.ts +212 -19
- package/src/activities/video-media-validation.ts +8 -2
- package/src/activities/video-reference-staging.ts +121 -34
- package/src/activities/xai-auth.ts +122 -0
- package/src/activities/xai-image-generation.ts +86 -0
- package/src/activities/xai-video-generation.ts +69 -0
- package/src/activities-control.ts +4 -0
- package/src/activities.ts +5 -0
- package/src/index.ts +51 -0
- package/src/model-checkpoint-memory-collector.ts +8 -1
- package/src/model-context-contributions.ts +159 -0
- package/src/observability-metrics.ts +98 -9
- package/src/sandbox-routing.ts +13 -0
- package/src/workflows/activities.ts +1 -0
- package/src/workflows/file-upload-reaper.ts +8 -2
- package/src/workflows/session.ts +20 -6
- package/src/workflows/site-auth-maintenance.ts +14 -0
- package/src/workflows.ts +1 -0
- package/dist/activities-control-44KBWLSM.js.map +0 -1
- package/dist/activities-turn-K4CEDEGJ.js.map +0 -1
- package/dist/chunk-E3RI3I33.js.map +0 -1
- package/dist/chunk-KKCRGAGZ.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as activities from "../activities.js";
|
|
2
|
-
type WorkflowControlActivities = Pick<typeof activities, "enqueueGoalRetryWake" | "expireSessionHumanInput" | "failSessionAttempt" | "getCodexCapacityWait" | "markSessionIdle" | "peekSessionWork" | "persistSessionAttemptQuiescence" | "reconcileSessionAttemptQuiescence" | "reconcileCodexCapacityWait" | "recoverDispatch" | "recoverEscapedMcpTimeout" | "settleSessionInterruptions">;
|
|
2
|
+
type WorkflowControlActivities = Pick<typeof activities, "enqueueGoalRetryWake" | "expireSessionHumanInput" | "expireSessionInteractionIntervention" | "failSessionAttempt" | "getCodexCapacityWait" | "markSessionIdle" | "peekSessionWork" | "persistSessionAttemptQuiescence" | "reconcileSessionAttemptQuiescence" | "reconcileCodexCapacityWait" | "recoverDispatch" | "recoverEscapedMcpTimeout" | "settleSessionInterruptions">;
|
|
3
3
|
/**
|
|
4
4
|
* Session/schedule workflow control activities are bounded, idempotent database
|
|
5
5
|
* and provider-metadata operations. They must not inherit the agent turn's
|
package/dist/workflows.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { scheduledTaskFireWorkflow, type ScheduledTaskFireWorkflowInput, } from
|
|
|
4
4
|
export { knowledgeSourceSyncWake, knowledgeSourceSyncWorkflow, knowledgeSourceSyncWorkflowId, type KnowledgeSourceSyncWorkflowInput, } from "./workflows/knowledge-source-sync.js";
|
|
5
5
|
export { sandboxDrainWorkflow, sandboxReaperMaintenanceWorkflow, sandboxReaperWorkflow, sandboxReaperWorkflowV2, } from "./workflows/sandbox-reaper.js";
|
|
6
6
|
export { fileUploadReaperWorkflow } from "./workflows/file-upload-reaper.js";
|
|
7
|
+
export { siteAuthMaintenanceWorkflow } from "./workflows/site-auth-maintenance.js";
|
|
7
8
|
export { videoGenerationWorkflow, videoGenerationWorkflowId, type VideoGenerationWorkflowInput, } from "./workflows/video-generation.js";
|
|
8
9
|
export { sessionWorkflowWakeDispatcherWorkflow } from "./workflows/workflow-wake.js";
|
|
9
10
|
export { rigVerificationWorkflow, type RigVerificationWorkflowInput, } from "./workflows/rig-verification.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeni/worker-bundle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "OpenGeni worker entry and reusable embedded lifecycle, shipped with a release-coherent pre-bundled Temporal workflow artifact.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -54,21 +54,22 @@
|
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@llamaindex/liteparse": "^1.5.3",
|
|
57
|
-
"@opengeni/agent-proto": "^0.
|
|
58
|
-
"@opengeni/capabilities": "^0.
|
|
59
|
-
"@opengeni/codemode": "^0.
|
|
60
|
-
"@opengeni/codex": "^0.2.
|
|
61
|
-
"@opengeni/config": "^0.
|
|
62
|
-
"@opengeni/contracts": "^0.
|
|
63
|
-
"@opengeni/core": "^0.
|
|
64
|
-
"@opengeni/db": "^0.
|
|
65
|
-
"@opengeni/documents": "^0.5.
|
|
66
|
-
"@opengeni/events": "^0.3.
|
|
67
|
-
"@opengeni/github": "^0.4.
|
|
57
|
+
"@opengeni/agent-proto": "^0.5.0",
|
|
58
|
+
"@opengeni/capabilities": "^0.2.0",
|
|
59
|
+
"@opengeni/codemode": "^0.4.1",
|
|
60
|
+
"@opengeni/codex": "^0.2.16",
|
|
61
|
+
"@opengeni/config": "^0.16.1",
|
|
62
|
+
"@opengeni/contracts": "^0.50.0",
|
|
63
|
+
"@opengeni/core": "^0.28.0",
|
|
64
|
+
"@opengeni/db": "^0.36.0",
|
|
65
|
+
"@opengeni/documents": "^0.5.38",
|
|
66
|
+
"@opengeni/events": "^0.3.109",
|
|
67
|
+
"@opengeni/github": "^0.4.56",
|
|
68
68
|
"@opengeni/network": "^0.2.2",
|
|
69
|
-
"@opengeni/observability": "^0.
|
|
70
|
-
"@opengeni/runtime": "^0.
|
|
71
|
-
"@opengeni/storage": "^0.2.
|
|
69
|
+
"@opengeni/observability": "^0.7.5",
|
|
70
|
+
"@opengeni/runtime": "^0.23.0",
|
|
71
|
+
"@opengeni/storage": "^0.2.93",
|
|
72
|
+
"@opengeni/xai-subscription": "^0.1.0",
|
|
72
73
|
"@temporalio/activity": "^1.17.0",
|
|
73
74
|
"@temporalio/client": "^1.17.0",
|
|
74
75
|
"@temporalio/worker": "^1.17.0",
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { configuredStaticUsageLimits, type Settings } from "@opengeni/config";
|
|
2
|
+
import { getBillingBalance, isCodexBilledTurn, sumUsageQuantity } from "@opengeni/db";
|
|
3
|
+
import type { ControlActivityServices } from "./types";
|
|
4
|
+
|
|
5
|
+
export type AgentRunAdmissionDenial =
|
|
6
|
+
| "insufficient_credits"
|
|
7
|
+
| "monthly_model_cost_limit"
|
|
8
|
+
| "monthly_agent_run_limit";
|
|
9
|
+
|
|
10
|
+
/** One worker-side admission boundary for service-authored agent runs. */
|
|
11
|
+
export async function agentRunAdmissionDenial(
|
|
12
|
+
services: Pick<ControlActivityServices, "db" | "entitlements"> & { settings: Settings },
|
|
13
|
+
input: {
|
|
14
|
+
accountId: string;
|
|
15
|
+
workspaceId: string;
|
|
16
|
+
model: string;
|
|
17
|
+
requestedAgentRuns: number;
|
|
18
|
+
},
|
|
19
|
+
): Promise<AgentRunAdmissionDenial | null> {
|
|
20
|
+
const externallyBilled = await isCodexBilledTurn({
|
|
21
|
+
db: services.db,
|
|
22
|
+
settings: services.settings,
|
|
23
|
+
workspaceId: input.workspaceId,
|
|
24
|
+
model: input.model,
|
|
25
|
+
});
|
|
26
|
+
if (
|
|
27
|
+
!externallyBilled &&
|
|
28
|
+
(services.settings.billingMode === "stripe" || services.settings.usageLimitsMode === "managed")
|
|
29
|
+
) {
|
|
30
|
+
if (services.entitlements) {
|
|
31
|
+
const decision = await services.entitlements.admitRun({
|
|
32
|
+
accountId: input.accountId,
|
|
33
|
+
workspaceId: input.workspaceId,
|
|
34
|
+
action: "agent_run:create",
|
|
35
|
+
quantity: input.requestedAgentRuns,
|
|
36
|
+
});
|
|
37
|
+
if (!decision.allowed) return "insufficient_credits";
|
|
38
|
+
} else {
|
|
39
|
+
const balance = await getBillingBalance(services.db, input.accountId);
|
|
40
|
+
if (balance.balanceMicros <= 0) return "insufficient_credits";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (
|
|
44
|
+
services.settings.usageLimitsMode !== "static" &&
|
|
45
|
+
services.settings.usageLimitsMode !== "managed"
|
|
46
|
+
) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const limits = configuredStaticUsageLimits(services.settings);
|
|
50
|
+
if (!externallyBilled && limits.maxMonthlyCostMicrosPerAccount) {
|
|
51
|
+
const used = await sumUsageQuantity(services.db, {
|
|
52
|
+
accountId: input.accountId,
|
|
53
|
+
eventType: "model.cost",
|
|
54
|
+
since: startOfUtcMonth(),
|
|
55
|
+
});
|
|
56
|
+
if (used >= limits.maxMonthlyCostMicrosPerAccount) {
|
|
57
|
+
return "monthly_model_cost_limit";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (limits.maxMonthlyAgentRunsPerWorkspace) {
|
|
61
|
+
const used = await sumUsageQuantity(services.db, {
|
|
62
|
+
workspaceId: input.workspaceId,
|
|
63
|
+
eventType: "agent_run.created",
|
|
64
|
+
since: startOfUtcMonth(),
|
|
65
|
+
});
|
|
66
|
+
if (used + input.requestedAgentRuns > limits.maxMonthlyAgentRunsPerWorkspace) {
|
|
67
|
+
return "monthly_agent_run_limit";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function startOfUtcMonth(): Date {
|
|
74
|
+
const now = new Date();
|
|
75
|
+
return new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1));
|
|
76
|
+
}
|