@opengeni/worker-bundle 0.17.2 → 0.20.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-run-admission.d.ts +12 -0
- package/dist/activities/agent-turn.d.ts +49 -1
- 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/run-input.d.ts +8 -0
- package/dist/activities/session-state.d.ts +7 -3
- package/dist/activities/site-auth-maintenance.d.ts +27 -0
- package/dist/activities/types.d.ts +43 -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-SMKF2OBE.js} +438 -55
- package/dist/activities-control-SMKF2OBE.js.map +1 -0
- package/dist/activities-control.d.ts +10 -2
- package/dist/{activities-turn-K4CEDEGJ.js → activities-turn-IDS3WEHA.js} +6704 -4847
- package/dist/activities-turn-IDS3WEHA.js.map +1 -0
- package/dist/activities.d.ts +11 -3
- package/dist/{chunk-E3RI3I33.js → chunk-N5TJIFCE.js} +156 -10
- package/dist/chunk-N5TJIFCE.js.map +1 -0
- package/dist/{chunk-KKCRGAGZ.js → chunk-P6Z2SLAA.js} +99 -98
- package/dist/chunk-P6Z2SLAA.js.map +1 -0
- package/dist/index.d.ts +14 -1
- 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 +57 -1
- package/dist/sandbox-routing.d.ts +4 -0
- package/dist/workflow-bundle.js +232 -18
- package/dist/workflows/activities.d.ts +1 -1
- package/dist/workflows/session.d.ts +17 -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 +2777 -1241
- 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/run-input.ts +137 -45
- package/src/activities/scheduled-tasks.ts +30 -73
- package/src/activities/session-state.ts +87 -5
- package/src/activities/site-auth-maintenance.ts +269 -0
- package/src/activities/types.ts +44 -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 +7 -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 +282 -12
- 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 +219 -14
- 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
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as activities from "../activities.js";
|
|
2
|
-
import { type EscapedMcpTimeoutRecoveryDetail } from "../activities/types.js";
|
|
2
|
+
import { type EscapedMcpTimeoutRecoveryDetail, type PreClaimFailureDisposition } from "../activities/types.js";
|
|
3
3
|
/**
|
|
4
4
|
* How long the continuation loop must hold before re-admitting the next turn. 0 ⇒ no
|
|
5
5
|
* hold (re-dispatch immediately — a rotation candidate is ready, or no idle delay was
|
|
@@ -21,6 +21,20 @@ export declare function continuationHoldMs(result: {
|
|
|
21
21
|
* signal-version and interruption paths in `sessionWorkflow`.
|
|
22
22
|
*/
|
|
23
23
|
export declare function deferredResultMayContinue(entryWakeups: number, currentWakeups: number): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Bound repeated failures that happen before an attempt row exists. The
|
|
26
|
+
* activity mirrors this deterministic delay into the durable wake outbox, so
|
|
27
|
+
* a live workflow and a replacement workflow observe the same retry floor.
|
|
28
|
+
*/
|
|
29
|
+
export declare function unclaimedAttemptRetryDelayMs(consecutiveFailures: number): number;
|
|
30
|
+
export type SessionWakeCounters = {
|
|
31
|
+
wakeups: number;
|
|
32
|
+
interruptionWakeups: number;
|
|
33
|
+
approvalWakeups: number;
|
|
34
|
+
capacityWakeups: number;
|
|
35
|
+
};
|
|
36
|
+
/** Any signal that can make the failed admission runnable interrupts backoff. */
|
|
37
|
+
export declare function unclaimedAttemptWakeChanged(baseline: SessionWakeCounters, current: SessionWakeCounters): boolean;
|
|
24
38
|
/** Deterministic Temporal timer delay for a persisted structured-input deadline. */
|
|
25
39
|
export declare function humanInputDeadlineWaitMs(expiresAt: string, nowMs?: number): number;
|
|
26
40
|
/**
|
|
@@ -31,6 +45,8 @@ export declare function humanInputDeadlineWaitMs(expiresAt: string, nowMs?: numb
|
|
|
31
45
|
* with immutable turn identity in payload-converted details.
|
|
32
46
|
*/
|
|
33
47
|
export declare function escapedMcpTimeoutRecoveryDetail(error: unknown): EscapedMcpTimeoutRecoveryDetail | null;
|
|
48
|
+
/** Read only the upgraded turn worker's explicit pre-claim wire contract. */
|
|
49
|
+
export declare function preClaimFailureDisposition(error: unknown): PreClaimFailureDisposition | undefined;
|
|
34
50
|
/**
|
|
35
51
|
* Classify only the exact turn-fence cancellation protocol used to arbitrate a
|
|
36
52
|
* database control commit that reaches the activity just before its Temporal
|
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.1",
|
|
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.2",
|
|
60
|
+
"@opengeni/codex": "^0.2.17",
|
|
61
|
+
"@opengeni/config": "^0.16.2",
|
|
62
|
+
"@opengeni/contracts": "^0.50.0",
|
|
63
|
+
"@opengeni/core": "^0.28.1",
|
|
64
|
+
"@opengeni/db": "^0.36.1",
|
|
65
|
+
"@opengeni/documents": "^0.5.39",
|
|
66
|
+
"@opengeni/events": "^0.3.110",
|
|
67
|
+
"@opengeni/github": "^0.4.57",
|
|
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.1",
|
|
71
|
+
"@opengeni/storage": "^0.2.94",
|
|
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
|
+
}
|