@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
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Settings } from "@opengeni/config";
|
|
2
|
+
import type { ControlActivityServices } from "./types.js";
|
|
3
|
+
export type AgentRunAdmissionDenial = "insufficient_credits" | "monthly_model_cost_limit" | "monthly_agent_run_limit";
|
|
4
|
+
/** One worker-side admission boundary for service-authored agent runs. */
|
|
5
|
+
export declare function agentRunAdmissionDenial(services: Pick<ControlActivityServices, "db" | "entitlements"> & {
|
|
6
|
+
settings: Settings;
|
|
7
|
+
}, input: {
|
|
8
|
+
accountId: string;
|
|
9
|
+
workspaceId: string;
|
|
10
|
+
model: string;
|
|
11
|
+
requestedAgentRuns: number;
|
|
12
|
+
}): Promise<AgentRunAdmissionDenial | null>;
|
|
@@ -35,6 +35,7 @@ export declare function shouldPublishToolAuthNeededForTurn(payload: Pick<ToolAut
|
|
|
35
35
|
export declare function turnExecutionPolicyBillingIdentity(policy: TurnExecutionPolicyV1): {
|
|
36
36
|
externallyBilled: boolean;
|
|
37
37
|
codexSubscription: boolean;
|
|
38
|
+
xaiSubscription: boolean;
|
|
38
39
|
};
|
|
39
40
|
export declare function legacyTurnExecutionPolicyInput(turn: Pick<SessionTurn, "source" | "model" | "reasoningEffort" | "latencyMode">): Parameters<typeof resolveTurnExecutionPolicyV1>[1];
|
|
40
41
|
/** A retryable provider fault recovers the accepted turn itself. Goal state is
|
|
@@ -91,6 +92,8 @@ export declare function filterUnmaterializedSandboxFileDownloads(downloads: Sand
|
|
|
91
92
|
export declare function codexWorkspaceMetricKey(workspaceId: string): string;
|
|
92
93
|
/** Stable public request identity across partial resumes and activity retries. */
|
|
93
94
|
export declare function stableHumanInputRequestId(sessionId: string, turnId: string, toolCallId: string): string;
|
|
95
|
+
export declare function stableInteractionInterventionId(sessionId: string, turnId: string, toolCallId: string): string;
|
|
96
|
+
export declare function stableInteractionInterventionOperationId(sessionId: string, turnId: string, toolCallId: string): string;
|
|
94
97
|
/**
|
|
95
98
|
* True when this activity attempt was cancelled because its hosting worker is
|
|
96
99
|
* shutting down gracefully (SIGTERM during a deploy), as opposed to a
|
|
@@ -506,6 +509,8 @@ export declare function managedSandboxOwnershipForTurn(machinePrimary: boolean,
|
|
|
506
509
|
holderId: TurnSandboxLeaseHolderId;
|
|
507
510
|
sandboxGroupId: string;
|
|
508
511
|
} | null;
|
|
512
|
+
/** A sandboxless home still establishes an explicitly attached Connected Machine. */
|
|
513
|
+
export declare function shouldEstablishSandboxForTurn(sandboxOwnershipEnabled: boolean, homeBackend: Settings["sandboxBackend"], machinePrimary: boolean): boolean;
|
|
509
514
|
/**
|
|
510
515
|
* Classify a persisted active-sandbox pointer for TURN-START RECONCILE (issue #341
|
|
511
516
|
* invariant B). Returns the typed reason to RESET the pointer to the session HOME,
|
|
@@ -680,6 +685,16 @@ export declare function hostedWebSearchForTurn(resolvedModel: {
|
|
|
680
685
|
hostedWebSearch: boolean;
|
|
681
686
|
};
|
|
682
687
|
} | null, deploymentWebSearchEnabled: boolean): boolean;
|
|
688
|
+
/**
|
|
689
|
+
* Image generation is an optional connected-account capability. A delegated
|
|
690
|
+
* subscription may still authorize the text model without carrying the local
|
|
691
|
+
* credential identity required for paid image operations; that must narrow the
|
|
692
|
+
* tool catalog, not reject an otherwise valid turn.
|
|
693
|
+
*/
|
|
694
|
+
export declare function connectedSubscriptionImageGenerationAuthority<T>(credentialContext: T | null | undefined, credentialId: string | null | undefined): {
|
|
695
|
+
credentialContext: T;
|
|
696
|
+
credentialId: string;
|
|
697
|
+
} | null;
|
|
683
698
|
/** Direct OpenAI hosted image IDs are reusable only by the exact API credential. */
|
|
684
699
|
export declare function openAiHostedImageProviderBindingForTurn(settings: Pick<Settings, "openaiProvider" | "openaiApiKey" | "openaiBaseUrl">, resolvedModel: {
|
|
685
700
|
provider: {
|
|
@@ -793,6 +808,16 @@ type OpStreamFinalizer = {
|
|
|
793
808
|
export declare function finalizeDurableTurnOpStreams(sessions: readonly unknown[], fallback: OpStreamFinalizer | null): Promise<void>;
|
|
794
809
|
export declare function createRunAgentTurnActivity(services: () => Promise<ActivityServices>): (input: RunAgentTurnInput) => Promise<RunAgentTurnResult>;
|
|
795
810
|
export declare function isTransientProviderError(error: unknown): boolean;
|
|
811
|
+
export type XaiCredentialFailure = {
|
|
812
|
+
kind: "auth" | "forbidden" | "rate_limit";
|
|
813
|
+
cooldownMs: number | null;
|
|
814
|
+
};
|
|
815
|
+
/**
|
|
816
|
+
* Only definitive SuperGrok account refusals may move the same logical turn to
|
|
817
|
+
* another credential. The marked transport response proves inference was
|
|
818
|
+
* rejected before a stream began; refresh relogin is equally definitive.
|
|
819
|
+
*/
|
|
820
|
+
export declare function classifyXaiCredentialFailure(error: unknown): XaiCredentialFailure | null;
|
|
796
821
|
export declare function agentRunFailurePayload(error: unknown, options?: {
|
|
797
822
|
isCodexTurn?: boolean;
|
|
798
823
|
}): {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { claimBrowserStateArtifactCleanup, claimBrowserStateUploadCleanup, completeBrowserStateArtifactCleanup, completeBrowserStateUploadCleanup, type BrowserStateArtifactCleanupClaim, type BrowserStateUploadCleanupClaim } from "@opengeni/db";
|
|
2
|
+
import type { ObjectStorage } from "@opengeni/storage";
|
|
3
|
+
import type { ControlActivityServices } from "./types.js";
|
|
4
|
+
export declare const BROWSER_STATE_ARTIFACT_CLAIM_TIMEOUT_MS: number;
|
|
5
|
+
export declare const BROWSER_STATE_ARTIFACT_CLEANUP_BATCH_SIZE = 100;
|
|
6
|
+
export type MaintainBrowserStateArtifactsResult = {
|
|
7
|
+
claimed: number;
|
|
8
|
+
deleted: number;
|
|
9
|
+
retryable: number;
|
|
10
|
+
};
|
|
11
|
+
export type BrowserStateArtifactMaintenanceOptions = {
|
|
12
|
+
claimTimeoutMs?: number;
|
|
13
|
+
batchSize?: number;
|
|
14
|
+
claimArtifacts?: typeof claimBrowserStateArtifactCleanup;
|
|
15
|
+
completeArtifact?: typeof completeBrowserStateArtifactCleanup;
|
|
16
|
+
claimUploads?: typeof claimBrowserStateUploadCleanup;
|
|
17
|
+
completeUpload?: typeof completeBrowserStateUploadCleanup;
|
|
18
|
+
/** Failure-injection seam; production uses the configured provider delete. */
|
|
19
|
+
deleteObject?: (storage: ObjectStorage, key: string) => Promise<void>;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Reap retired encrypted private browser checkpoints. Provider deletion happens
|
|
23
|
+
* before terminal settlement; a crash or provider failure leaves the durable
|
|
24
|
+
* claim reclaimable and an already-deleted provider key is safe to retry.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createBrowserStateArtifactMaintenanceActivities(services: () => Promise<ControlActivityServices>, options?: BrowserStateArtifactMaintenanceOptions): {
|
|
27
|
+
maintainBrowserStateArtifacts: () => Promise<MaintainBrowserStateArtifactsResult>;
|
|
28
|
+
};
|
|
29
|
+
export type { BrowserStateArtifactCleanupClaim, BrowserStateUploadCleanupClaim };
|
|
@@ -16,4 +16,10 @@ export declare function settingsWithSessionMcpServers(settings: Settings, server
|
|
|
16
16
|
export declare function settingsWithCodexCredential(db: Database, workspaceId: string, settings: Settings, activeOverride?: boolean): Promise<Settings>;
|
|
17
17
|
/** Pure: append the synthetic codex-subscription provider, idempotently. */
|
|
18
18
|
export declare function withCodexProvider(settings: Settings): Settings;
|
|
19
|
+
/**
|
|
20
|
+
* Pure: append the synthetic SuperGrok/xAI subscription provider,
|
|
21
|
+
* idempotently. The overlay is catalogue metadata only; the exact account,
|
|
22
|
+
* authority snapshot, and bearer remain frozen later at turn admission.
|
|
23
|
+
*/
|
|
24
|
+
export declare function withXaiSubscriptionProvider(settings: Settings): Settings;
|
|
19
25
|
export declare function settingsWithWorkspaceGatewayCredential(db: Database, workspaceId: string, settings: Settings): Promise<Settings>;
|
|
@@ -21,6 +21,7 @@ export declare function signalPendingCodexCapacityWakeTargets(services: CodexCap
|
|
|
21
21
|
export declare function codexCapacityDecision(context: CodexCapacitySelectionContext, settings: Settings): ReturnType<Parameters<typeof reconcileCodexCapacityWaitDb>[2]>;
|
|
22
22
|
export declare function createCodexCapacityActivities(services: () => Promise<ControlActivityServices>): {
|
|
23
23
|
getCodexCapacityWait: (input: GetCodexCapacityWaitInput) => Promise<{
|
|
24
|
+
provider?: "xai";
|
|
24
25
|
waiterId: string;
|
|
25
26
|
generation: number;
|
|
26
27
|
nextCheckAt: string;
|
|
@@ -61,7 +61,13 @@ type RunGitCredentialOptions = {
|
|
|
61
61
|
export declare function loadWorkspaceEnvironmentForRunWithCredentials(db: Database, settings: Settings, scope: ConnectionScope, environmentId: string | null, sandboxSecrets?: ConnectionCredentialsPort["sandboxSecrets"]): Promise<WorkspaceEnvironmentForRun | null>;
|
|
62
62
|
export declare function sandboxEnvironmentForRun(settings: Settings, resources: ResourceRef[], workspaceEnvironment?: Record<string, string>, options?: RunGitCredentialOptions & {
|
|
63
63
|
skipGitHubToken?: boolean;
|
|
64
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Codemode credential delivery for this attempt. Managed sandboxes receive
|
|
66
|
+
* stable URL/file pointers in their manifest and the bearer through the
|
|
67
|
+
* lifecycle file writer. Connected Machines receive no manifest pointers;
|
|
68
|
+
* the worker injects the minted bearer only into exact exec requests.
|
|
69
|
+
*/
|
|
70
|
+
codemodeDelivery?: "managed_file" | "transient_exec" | "none";
|
|
65
71
|
deferGitHubToken?: boolean;
|
|
66
72
|
codemodeAuthority?: SandboxCodemodeAuthority;
|
|
67
73
|
}): Promise<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CapabilityPack, type PackInstallation } from "@opengeni/contracts";
|
|
2
2
|
import { type Database } from "@opengeni/db";
|
|
3
|
-
import { type
|
|
3
|
+
import { type InstalledSkillActivation, type PackSkillActivation } from "@opengeni/runtime";
|
|
4
4
|
export { resolveRigProviderImageSelection, rigProviderImageSourceImage, settingsWithPackSandboxImage, settingsWithRigImage, settingsWithRigProviderImage, } from "./sandbox-images.js";
|
|
5
5
|
/**
|
|
6
6
|
* Legacy pack-scoped runtime compatibility. V2 Pack installations own ordinary
|
|
@@ -9,11 +9,10 @@ export { resolveRigProviderImageSelection, rigProviderImageSourceImage, settings
|
|
|
9
9
|
export type WorkspacePackRuntime = {
|
|
10
10
|
sandboxImage: string | null;
|
|
11
11
|
sandboxProviderImages: CapabilityPack["sandboxProviderImages"] | null;
|
|
12
|
-
|
|
12
|
+
skillActivations: PackSkillActivation[];
|
|
13
13
|
};
|
|
14
|
-
export type
|
|
15
|
-
|
|
16
|
-
skillLibrarySelections: EffectiveSkillSelection[];
|
|
14
|
+
export type WorkspaceInstalledSkillRuntime = {
|
|
15
|
+
activations: InstalledSkillActivation[];
|
|
17
16
|
};
|
|
18
17
|
/**
|
|
19
18
|
* Resolves only pre-V2 active Pack installations. A frozen manifest/digest is
|
|
@@ -25,12 +24,11 @@ export type WorkspaceSkillLibraryRuntime = {
|
|
|
25
24
|
export declare function resolveWorkspacePackRuntime(db: Database, workspaceId: string): Promise<WorkspacePackRuntime>;
|
|
26
25
|
export declare function packInstallationUsesLegacyRuntime(installation: Pick<PackInstallation, "manifestSnapshot" | "manifestDigest">): boolean;
|
|
27
26
|
/**
|
|
28
|
-
* Resolves active immutable
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* the pinned artifact hash before any content is materialized.
|
|
27
|
+
* Resolves every active immutable Skill through the normalized Plugin/Skill-
|
|
28
|
+
* Facet ledger. The data layer has already filtered ineffective owner edges;
|
|
29
|
+
* this boundary independently verifies exact files before runtime activation.
|
|
32
30
|
*/
|
|
33
|
-
export declare function
|
|
31
|
+
export declare function resolveWorkspaceInstalledSkillRuntime(db: Database, workspaceId: string): Promise<WorkspaceInstalledSkillRuntime>;
|
|
34
32
|
/**
|
|
35
33
|
* Pure pre-V2 compatibility rule for enabled Pack manifests. At most one
|
|
36
34
|
* legacy Pack may declare a sandbox image, and legacy Skill names must be
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { settleSessionAttemptInterruptions, applySessionTurnSettlement, requestSessionTurnRecovery, recoverSessionDispatch, reconcileSessionAttemptQuiescence, peekSessionWork as peekSessionWorkDb, countQueuedTurns, getSessionAttemptActivityRef, getSessionEvent, getSessionTurnForAttempt, expireSessionHumanInputRequest, markSessionAttemptQuiesced, requireSession, settleSessionIdleWithParentOutbox } from "@opengeni/db";
|
|
1
|
+
import { settleSessionAttemptInterruptions, applySessionTurnSettlement, requestSessionTurnRecovery, recoverSessionDispatch, reconcileSessionAttemptQuiescence, peekSessionWork as peekSessionWorkDb, countQueuedTurns, getSessionAttemptActivityRef, getSessionEvent, getSessionTurnForAttempt, expireSessionInteractionIntervention as expireSessionInteractionInterventionDb, expireSessionHumanInputRequest, markSessionAttemptQuiesced, requireSession, settleSessionIdleWithParentOutbox } from "@opengeni/db";
|
|
2
2
|
import { publishDurableSessionEvents } from "@opengeni/events";
|
|
3
3
|
import { deliverFailedChildTurnToParent, notifyParentOfChildIdle } from "./parent-wake.js";
|
|
4
4
|
import { recordTurnsQueuedGauge } from "../observability-metrics.js";
|
|
5
|
-
import type { ControlActivityServices, ExpireSessionHumanInputInput, ExpireSessionHumanInputResult, PeekSessionWorkInput, FailSessionAttemptInput, SettleSessionInterruptionsInput, MarkSessionIdleInput, PersistSessionAttemptQuiescenceInput, ReconcileSessionAttemptQuiescenceInput, ReconcileSessionAttemptQuiescenceResult, RecoverDispatchInput, RecoverDispatchResult, RecoverEscapedMcpTimeoutInput, RecoverEscapedMcpTimeoutResult } from "./types.js";
|
|
5
|
+
import type { ControlActivityServices, ExpireSessionHumanInputInput, ExpireSessionHumanInputResult, ExpireSessionInteractionInterventionInput, ExpireSessionInteractionInterventionResult, PeekSessionWorkInput, FailSessionAttemptInput, SettleSessionInterruptionsInput, MarkSessionIdleInput, PersistSessionAttemptQuiescenceInput, ReconcileSessionAttemptQuiescenceInput, ReconcileSessionAttemptQuiescenceResult, RecoverDispatchInput, RecoverDispatchResult, RecoverEscapedMcpTimeoutInput, RecoverEscapedMcpTimeoutResult } from "./types.js";
|
|
6
6
|
export type SessionStateActivityOverrides = Partial<{
|
|
7
7
|
settleSessionAttemptInterruptions: typeof settleSessionAttemptInterruptions;
|
|
8
8
|
applySessionTurnSettlement: typeof applySessionTurnSettlement;
|
|
@@ -15,6 +15,7 @@ export type SessionStateActivityOverrides = Partial<{
|
|
|
15
15
|
getSessionEvent: typeof getSessionEvent;
|
|
16
16
|
getSessionTurnForAttempt: typeof getSessionTurnForAttempt;
|
|
17
17
|
expireSessionHumanInputRequest: typeof expireSessionHumanInputRequest;
|
|
18
|
+
expireSessionInteractionIntervention: typeof expireSessionInteractionInterventionDb;
|
|
18
19
|
requireSession: typeof requireSession;
|
|
19
20
|
settleSessionIdleWithParentOutbox: typeof settleSessionIdleWithParentOutbox;
|
|
20
21
|
markSessionAttemptQuiesced: typeof markSessionAttemptQuiesced;
|
|
@@ -35,5 +36,6 @@ export declare function createSessionStateActivities(services: () => Promise<Con
|
|
|
35
36
|
recoverEscapedMcpTimeout: (input: RecoverEscapedMcpTimeoutInput) => Promise<RecoverEscapedMcpTimeoutResult>;
|
|
36
37
|
peekSessionWork: (input: PeekSessionWorkInput) => Promise<import("@opengeni/db").SessionWorkPeek>;
|
|
37
38
|
expireSessionHumanInput: (input: ExpireSessionHumanInputInput) => Promise<ExpireSessionHumanInputResult>;
|
|
39
|
+
expireSessionInteractionIntervention: (input: ExpireSessionInteractionInterventionInput) => Promise<ExpireSessionInteractionInterventionResult>;
|
|
38
40
|
markSessionIdle: (input: MarkSessionIdleInput) => Promise<void>;
|
|
39
41
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { assertWorkspaceModelPolicyAllows, createAndStartSessionWithOutcome, recordWorkspaceUsage } from "@opengeni/core";
|
|
2
|
+
import { claimSiteAuthMaintenance, confirmSiteAuthMaintenanceSessionInTransaction, deferSiteAuthMaintenance } from "@opengeni/db";
|
|
3
|
+
import { agentRunAdmissionDenial } from "./agent-run-admission.js";
|
|
4
|
+
import type { ControlActivityServices } from "./types.js";
|
|
5
|
+
export declare const SITE_AUTH_MAINTENANCE_CLAIM_TIMEOUT_MS: number;
|
|
6
|
+
export declare const SITE_AUTH_MAINTENANCE_BATCH_SIZE = 16;
|
|
7
|
+
export type MaintainSiteAuthConnectionsResult = {
|
|
8
|
+
claimed: number;
|
|
9
|
+
started: number;
|
|
10
|
+
deferred: number;
|
|
11
|
+
};
|
|
12
|
+
export type SiteAuthMaintenanceOptions = {
|
|
13
|
+
claimTimeoutMs?: number;
|
|
14
|
+
batchSize?: number;
|
|
15
|
+
claim?: typeof claimSiteAuthMaintenance;
|
|
16
|
+
confirm?: typeof confirmSiteAuthMaintenanceSessionInTransaction;
|
|
17
|
+
defer?: typeof deferSiteAuthMaintenance;
|
|
18
|
+
createSession?: typeof createAndStartSessionWithOutcome;
|
|
19
|
+
admit?: typeof agentRunAdmissionDenial;
|
|
20
|
+
recordUsage?: typeof recordWorkspaceUsage;
|
|
21
|
+
assertModelPolicy?: typeof assertWorkspaceModelPolicyAllows;
|
|
22
|
+
};
|
|
23
|
+
/** Dispatch bounded, auditable agent sessions for due authentication checks.
|
|
24
|
+
* A hidden claim id/session id pair makes every crash point replayable. */
|
|
25
|
+
export declare function createSiteAuthMaintenanceActivities(services: () => Promise<ControlActivityServices>, options?: SiteAuthMaintenanceOptions): {
|
|
26
|
+
maintainSiteAuthConnections: () => Promise<MaintainSiteAuthConnectionsResult>;
|
|
27
|
+
};
|
|
@@ -87,11 +87,16 @@ export type ActivityServices = ControlActivityServices & TurnActivityServices &
|
|
|
87
87
|
documentServices: DocumentServices;
|
|
88
88
|
};
|
|
89
89
|
export type CodexCapacityWaitRef = {
|
|
90
|
+
/** Absent only for Temporal histories written before provider-tagged waits. */
|
|
91
|
+
provider?: "codex" | "xai";
|
|
90
92
|
waiterId: string;
|
|
91
93
|
generation: number;
|
|
92
94
|
nextCheckAt: string;
|
|
93
95
|
wakeRevision: number;
|
|
94
96
|
};
|
|
97
|
+
export type XaiCapacityWaitRef = CodexCapacityWaitRef & {
|
|
98
|
+
provider: "xai";
|
|
99
|
+
};
|
|
95
100
|
export type GetCodexCapacityWaitInput = {
|
|
96
101
|
workspaceId: string;
|
|
97
102
|
sessionId: string;
|
|
@@ -103,6 +108,8 @@ export type ReconcileCodexCapacityWaitInput = {
|
|
|
103
108
|
waiterId: string;
|
|
104
109
|
generation: number;
|
|
105
110
|
cause: "timer" | "signal" | "queue" | "recovery";
|
|
111
|
+
/** Absent only for Codex waits and pre-provider-tagged workflow histories. */
|
|
112
|
+
provider?: "codex" | "xai";
|
|
106
113
|
};
|
|
107
114
|
export type ReconcileCodexCapacityWaitResult = ({
|
|
108
115
|
action: "waiting";
|
|
@@ -214,6 +221,15 @@ export type ExpireSessionHumanInputInput = {
|
|
|
214
221
|
export type ExpireSessionHumanInputResult = {
|
|
215
222
|
action: "expired" | "stale" | "not_found";
|
|
216
223
|
};
|
|
224
|
+
export type ExpireSessionInteractionInterventionInput = {
|
|
225
|
+
accountId: string;
|
|
226
|
+
workspaceId: string;
|
|
227
|
+
sessionId: string;
|
|
228
|
+
interventionId: string;
|
|
229
|
+
};
|
|
230
|
+
export type ExpireSessionInteractionInterventionResult = {
|
|
231
|
+
action: "expired" | "stale" | "not_found";
|
|
232
|
+
};
|
|
217
233
|
export type MarkSessionIdleInput = {
|
|
218
234
|
workspaceId: string;
|
|
219
235
|
sessionId: string;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { VideoGenerationAcceptedReceipt, type GenerateVideoToolInput, type VideoGenerationCapabilities, type VideoGenerationPolicy } from "@opengeni/contracts";
|
|
2
|
-
import { type Database } from "@opengeni/db";
|
|
1
|
+
import { VideoGenerationAcceptedReceipt, type GenerateVideoToolInput, type VideoGenerationCapabilities, type VideoGenerationPolicy, type XaiProviderAccountAuthoritySnapshotV1 } from "@opengeni/contracts";
|
|
2
|
+
import { type Database, type XaiCredentialForRun } from "@opengeni/db";
|
|
3
3
|
import { type Settings } from "@opengeni/config";
|
|
4
4
|
import type { ObjectStorage } from "@opengeni/storage";
|
|
5
5
|
import { type SandboxCommandRunner } from "./video-reference-staging.js";
|
|
6
6
|
export type VideoGenerationCredentialLease = Readonly<{
|
|
7
|
-
fundingSource: "opengeni_credits" | "workspace_gateway";
|
|
7
|
+
fundingSource: "opengeni_credits" | "workspace_gateway" | "supergrok_subscription";
|
|
8
8
|
connectionId: string | null;
|
|
9
9
|
version: number;
|
|
10
10
|
credentialEncrypted: string;
|
|
11
|
-
apiKey: string;
|
|
12
11
|
}>;
|
|
13
12
|
export type AcceptedVideoGeneration = Readonly<{
|
|
14
13
|
receipt: ReturnType<typeof VideoGenerationAcceptedReceipt.parse>;
|
|
@@ -20,6 +19,12 @@ export declare function videoCapabilitiesForTurn(input: {
|
|
|
20
19
|
credential: VideoGenerationCredentialLease;
|
|
21
20
|
}): VideoGenerationCapabilities;
|
|
22
21
|
export declare function managedVideoGenerationCredentialLease(settings: Settings): VideoGenerationCredentialLease | null;
|
|
22
|
+
export declare function xaiVideoGenerationCredentialLease(input: {
|
|
23
|
+
settings: Settings;
|
|
24
|
+
credential: XaiCredentialForRun;
|
|
25
|
+
subjectId: string;
|
|
26
|
+
authoritySnapshot: XaiProviderAccountAuthoritySnapshotV1;
|
|
27
|
+
}): VideoGenerationCredentialLease;
|
|
23
28
|
export declare function admitVideoGenerationRequest(input: {
|
|
24
29
|
db: Database;
|
|
25
30
|
storage: ObjectStorage;
|
|
@@ -1,7 +1,24 @@
|
|
|
1
|
+
import type { XaiProviderAccountAuthoritySnapshotV1 } from "@opengeni/contracts";
|
|
2
|
+
export type VideoGenerationProviderCredential = Readonly<{
|
|
3
|
+
kind: "api-key";
|
|
4
|
+
apiKey: string;
|
|
5
|
+
}> | Readonly<{
|
|
6
|
+
kind: "xai-subscription";
|
|
7
|
+
accessToken: string;
|
|
8
|
+
refreshToken: string;
|
|
9
|
+
userId: string;
|
|
10
|
+
credentialId: string;
|
|
11
|
+
subjectId: string;
|
|
12
|
+
authoritySnapshot: XaiProviderAccountAuthoritySnapshotV1;
|
|
13
|
+
}>;
|
|
1
14
|
/** One frozen, provider-neutral credential envelope for every video funding route. */
|
|
2
15
|
export declare function encryptVideoGenerationApiKey(key: Uint8Array, apiKey: string): string;
|
|
16
|
+
export declare function encryptVideoGenerationXaiCredential(key: Uint8Array, credential: Omit<Extract<VideoGenerationProviderCredential, {
|
|
17
|
+
kind: "xai-subscription";
|
|
18
|
+
}>, "kind">): string;
|
|
3
19
|
/**
|
|
4
20
|
* Decrypt without ever attaching parser/decryption errors: JSON parser errors
|
|
5
21
|
* may quote plaintext and must not enter Temporal failure payloads or logs.
|
|
6
22
|
*/
|
|
23
|
+
export declare function decryptVideoGenerationCredential(key: Uint8Array, stored: string): VideoGenerationProviderCredential;
|
|
7
24
|
export declare function decryptVideoGenerationApiKey(key: Uint8Array, stored: string): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type GenerateVideoToolInput } from "@opengeni/contracts";
|
|
1
|
+
import { type GenerateVideoToolInput, type VideoGenerationRejectedCode } from "@opengeni/contracts";
|
|
2
2
|
import type { SealedVideoReference, SealedVideoReferenceRole } from "@opengeni/core";
|
|
3
3
|
import type { ObjectStorage } from "@opengeni/storage";
|
|
4
4
|
export type SandboxCommandRunner = (input: {
|
|
@@ -18,6 +18,12 @@ export type InspectedSandboxVideoReference = Readonly<{
|
|
|
18
18
|
sizeBytes: number;
|
|
19
19
|
sha256: string;
|
|
20
20
|
}>;
|
|
21
|
+
export type VideoReferenceInputErrorCode = VideoGenerationRejectedCode;
|
|
22
|
+
/** A deterministic, pre-admission tool-input error. No video operation exists yet. */
|
|
23
|
+
export declare class VideoReferenceInputError extends Error {
|
|
24
|
+
readonly code: VideoReferenceInputErrorCode;
|
|
25
|
+
constructor(code: VideoReferenceInputErrorCode, message: string);
|
|
26
|
+
}
|
|
21
27
|
export declare function videoReferencePaths(request: GenerateVideoToolInput): Array<{
|
|
22
28
|
role: SealedVideoReferenceRole;
|
|
23
29
|
path: string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Settings } from "@opengeni/config";
|
|
2
|
+
import { type Database } from "@opengeni/db";
|
|
3
|
+
import type { XaiProviderAccountAuthoritySnapshotV1 } from "@opengeni/contracts";
|
|
4
|
+
import { type XaiFetch, type XaiSubscriptionRequestContext } from "@opengeni/xai-subscription";
|
|
5
|
+
export type XaiTurnRequestAuthorization = {
|
|
6
|
+
context: XaiSubscriptionRequestContext;
|
|
7
|
+
credentialId: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function buildXaiTurnRequestAuthorization(input: {
|
|
10
|
+
db: Database;
|
|
11
|
+
settings: Settings;
|
|
12
|
+
accountId: string;
|
|
13
|
+
workspaceId: string;
|
|
14
|
+
subjectId: string;
|
|
15
|
+
sessionId: string;
|
|
16
|
+
turnId: string;
|
|
17
|
+
credentialId: string;
|
|
18
|
+
authoritySnapshot: XaiProviderAccountAuthoritySnapshotV1;
|
|
19
|
+
fetch?: XaiFetch;
|
|
20
|
+
hostedSearch?: XaiSubscriptionRequestContext["hostedSearch"];
|
|
21
|
+
onFinalContextUsage?: XaiSubscriptionRequestContext["onFinalContextUsage"];
|
|
22
|
+
nextRequestId?: XaiSubscriptionRequestContext["nextRequestId"];
|
|
23
|
+
}): Promise<XaiTurnRequestAuthorization>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { generateXaiSubscriptionImage, type XaiSubscriptionRequestContext } from "@opengeni/xai-subscription";
|
|
2
|
+
import type { Database } from "@opengeni/db";
|
|
3
|
+
import type { ObjectStorage } from "@opengeni/storage";
|
|
4
|
+
import type { GeneratedImageReceipt } from "./generated-images.js";
|
|
5
|
+
import { executeImageGenerationOperation } from "./image-generation-operation.js";
|
|
6
|
+
import type { ResolvedImageGenerationReference } from "./image-generation-references.js";
|
|
7
|
+
export type XaiImageGenerationPorts = {
|
|
8
|
+
execute: typeof executeImageGenerationOperation;
|
|
9
|
+
generate: typeof generateXaiSubscriptionImage;
|
|
10
|
+
};
|
|
11
|
+
/** Execute xAI's standalone subscription image path under the durable paid-operation fence. */
|
|
12
|
+
export declare function executeXaiSubscriptionImageGeneration(input: {
|
|
13
|
+
db: Database;
|
|
14
|
+
objectStorage: ObjectStorage | null;
|
|
15
|
+
accountId: string;
|
|
16
|
+
workspaceId: string;
|
|
17
|
+
sessionId: string;
|
|
18
|
+
turnId: string;
|
|
19
|
+
attemptId: string;
|
|
20
|
+
toolCallId: string;
|
|
21
|
+
prompt: string;
|
|
22
|
+
references?: readonly ResolvedImageGenerationReference[];
|
|
23
|
+
credentialId: string;
|
|
24
|
+
xaiContext: Pick<XaiSubscriptionRequestContext, "getToken" | "refresh">;
|
|
25
|
+
abortSignal?: AbortSignal;
|
|
26
|
+
}, ports?: XaiImageGenerationPorts): Promise<GeneratedImageReceipt>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CanonicalVideoGenerationRequest } from "@opengeni/core";
|
|
2
|
+
import { type XaiFetch, type XaiSubscriptionRequestContext, type XaiVideoStatus } from "@opengeni/xai-subscription";
|
|
3
|
+
import type { GatewayVideoReferenceGrant } from "./gateway-video-generation.js";
|
|
4
|
+
export declare function buildXaiVideoStartBody(request: CanonicalVideoGenerationRequest, referenceGrants: readonly GatewayVideoReferenceGrant[]): Record<string, unknown>;
|
|
5
|
+
export declare function startXaiVideoGeneration(input: {
|
|
6
|
+
body: Record<string, unknown>;
|
|
7
|
+
sessionId: string | null;
|
|
8
|
+
auth: Pick<XaiSubscriptionRequestContext, "getToken" | "refresh">;
|
|
9
|
+
fetch?: XaiFetch;
|
|
10
|
+
}): Promise<{
|
|
11
|
+
providerJobId: string;
|
|
12
|
+
}>;
|
|
13
|
+
export declare function getXaiVideoGenerationStatus(input: {
|
|
14
|
+
providerJobId: string;
|
|
15
|
+
sessionId: string | null;
|
|
16
|
+
auth: Pick<XaiSubscriptionRequestContext, "getToken" | "refresh">;
|
|
17
|
+
fetch?: XaiFetch;
|
|
18
|
+
}): Promise<XaiVideoStatus>;
|