@opengeni/worker-bundle 0.16.29 → 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 +110 -19
- package/dist/activities/api-integrations.d.ts +21 -0
- package/dist/activities/browser-state-artifact-reaper.d.ts +29 -0
- package/dist/activities/capabilities.d.ts +6 -0
- package/dist/activities/codemode-dispatcher.d.ts +35 -0
- package/dist/activities/codemode-token-renewal.d.ts +23 -0
- package/dist/activities/codex-capacity.d.ts +6 -5
- package/dist/activities/codex-image-generation.d.ts +21 -0
- package/dist/activities/context-compaction.d.ts +1 -0
- package/dist/activities/documents.d.ts +3 -2
- package/dist/activities/environment.d.ts +17 -8
- package/dist/activities/expiring-material-renewal.d.ts +1 -1
- package/dist/activities/file-upload-reaper.d.ts +7 -2
- package/dist/activities/gateway-image-generation.d.ts +39 -0
- package/dist/activities/gateway-video-generation.d.ts +53 -0
- package/dist/activities/generated-images.d.ts +112 -0
- package/dist/activities/git-credential-renewal.d.ts +1 -1
- package/dist/activities/goals.d.ts +2 -2
- package/dist/activities/google-drive-changes.d.ts +99 -0
- package/dist/activities/image-generation-operation.d.ts +74 -0
- package/dist/activities/image-generation-references.d.ts +25 -0
- package/dist/activities/knowledge-source-sync-driver.d.ts +23 -0
- package/dist/activities/knowledge-source-sync.d.ts +75 -0
- package/dist/activities/packs.d.ts +21 -36
- package/dist/activities/parent-wake.d.ts +1 -1
- package/dist/activities/retained-screenshot-reaper.d.ts +2 -2
- package/dist/activities/retained-screenshots.d.ts +36 -0
- package/dist/activities/rig-verification.d.ts +82 -5
- package/dist/activities/run-credential-renewal.d.ts +1 -1
- package/dist/activities/run-input.d.ts +3 -1
- package/dist/activities/sandbox-images.d.ts +14 -0
- package/dist/activities/sandbox-lease.d.ts +47 -9
- package/dist/activities/scheduled-tasks.d.ts +2 -2
- package/dist/activities/session-state.d.ts +7 -5
- package/dist/activities/site-auth-maintenance.d.ts +27 -0
- package/dist/activities/streaming.d.ts +1 -1
- package/dist/activities/types.d.ts +87 -5
- package/dist/activities/video-generation-admission.d.ts +43 -0
- package/dist/activities/video-generation-credential.d.ts +24 -0
- package/dist/activities/video-generation-reconciliation.d.ts +13 -0
- package/dist/activities/video-media-validation.d.ts +34 -0
- package/dist/activities/video-output-retention.d.ts +36 -0
- package/dist/activities/video-reference-staging.d.ts +55 -0
- package/dist/activities/workflow-wake.d.ts +2 -2
- package/dist/activities/workspace-capture.d.ts +10 -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-XURE4VKN.js +7221 -0
- package/dist/activities-control-XURE4VKN.js.map +1 -0
- package/dist/activities-control.d.ts +297 -0
- package/dist/activities-turn-6EBXGGLS.js +16036 -0
- package/dist/activities-turn-6EBXGGLS.js.map +1 -0
- package/dist/activities-turn.d.ts +17 -0
- package/dist/activities.d.ts +138 -150
- package/dist/activity-services.d.ts +10 -0
- package/dist/artifact-materializer-entry.d.ts +6 -0
- package/dist/artifact-materializer-entry.js +2662 -0
- package/dist/artifact-materializer-entry.js.map +1 -0
- package/dist/artifact-outbox-entry.d.ts +2 -0
- package/dist/artifact-outbox-entry.js +681 -0
- package/dist/artifact-outbox-entry.js.map +1 -0
- package/dist/chunk-5GRJIP5H.js +3092 -0
- package/dist/chunk-5GRJIP5H.js.map +1 -0
- package/dist/chunk-GRFQTTSQ.js +448 -0
- package/dist/chunk-GRFQTTSQ.js.map +1 -0
- package/dist/chunk-TYNPCG4U.js +906 -0
- package/dist/chunk-TYNPCG4U.js.map +1 -0
- package/dist/concurrency.d.ts +108 -5
- package/dist/editable-artifact-hint-broker.d.ts +49 -0
- package/dist/editable-artifact-materializer-launcher.d.ts +49 -0
- package/dist/editable-artifact-materializer-service.d.ts +108 -0
- package/dist/editable-artifact-materializer-storage.d.ts +12 -0
- package/dist/editable-artifact-materializer-subprocess.d.ts +50 -0
- package/dist/editable-artifact-materializer.d.ts +262 -0
- package/dist/editable-artifact-outbox-dispatcher.d.ts +44 -0
- package/dist/editable-artifact-outbox-service.d.ts +70 -0
- package/dist/host-export.d.ts +1 -1
- package/dist/index.d.ts +189 -10
- package/dist/index.js +715 -17380
- package/dist/index.js.map +1 -1
- package/dist/memory-pressure-guard.d.ts +57 -0
- package/dist/model-checkpoint-memory-collector.d.ts +23 -0
- package/dist/model-context-contributions.d.ts +40 -0
- package/dist/observability-metrics.d.ts +53 -1
- package/dist/sandbox-reaper-contract.d.ts +40 -0
- package/dist/sandbox-reaper-timeout.d.ts +14 -0
- package/dist/sandbox-resume.d.ts +34 -7
- package/dist/sandbox-routing.d.ts +6 -0
- package/dist/worker-service-lifecycle.d.ts +6 -2
- package/dist/workflow-bundle.js +1094 -370
- package/dist/workflows/activities.d.ts +8 -2
- package/dist/workflows/document-index.d.ts +1 -1
- package/dist/workflows/knowledge-source-sync.d.ts +13 -0
- package/dist/workflows/rig-verification.d.ts +1 -1
- package/dist/workflows/sandbox-reaper.d.ts +8 -0
- package/dist/workflows/scheduled-tasks.d.ts +1 -1
- package/dist/workflows/session.d.ts +2 -2
- package/dist/workflows/site-auth-maintenance.d.ts +2 -0
- package/dist/workflows/video-generation.d.ts +10 -0
- package/dist/workflows/workflow-wake.d.ts +1 -1
- package/dist/workflows.d.ts +10 -7
- package/package.json +35 -15
- package/src/activities/agent-run-admission.ts +76 -0
- package/src/activities/agent-turn.ts +2600 -340
- package/src/activities/api-integrations.ts +138 -0
- package/src/activities/browser-state-artifact-reaper.ts +120 -0
- package/src/activities/capabilities.ts +10 -0
- package/src/activities/codemode-dispatcher.ts +335 -0
- package/src/activities/codemode-token-renewal.ts +64 -0
- package/src/activities/codex-capacity.ts +54 -7
- package/src/activities/codex-image-generation.ts +56 -0
- package/src/activities/context-compaction.ts +38 -3
- package/src/activities/documents.ts +14 -4
- package/src/activities/environment.ts +54 -45
- package/src/activities/expiring-material-renewal.ts +1 -1
- package/src/activities/file-upload-reaper.ts +34 -3
- package/src/activities/gateway-image-generation.ts +146 -0
- package/src/activities/gateway-video-generation.ts +298 -0
- package/src/activities/generated-images.ts +860 -0
- package/src/activities/goals.ts +8 -3
- package/src/activities/google-drive-changes.ts +454 -0
- package/src/activities/image-generation-operation.ts +333 -0
- package/src/activities/image-generation-references.ts +118 -0
- package/src/activities/knowledge-source-sync-driver.ts +27 -0
- package/src/activities/knowledge-source-sync.ts +2840 -0
- package/src/activities/mcp-credentials.ts +1 -0
- package/src/activities/packs.ts +75 -152
- package/src/activities/parent-wake.ts +13 -1
- package/src/activities/retained-screenshot-reaper.ts +2 -2
- package/src/activities/retained-screenshots.ts +453 -28
- package/src/activities/rig-verification.ts +554 -43
- package/src/activities/run-input.ts +22 -6
- package/src/activities/sandbox-images.ts +167 -0
- package/src/activities/sandbox-lease.ts +1065 -483
- package/src/activities/scheduled-tasks.ts +104 -74
- package/src/activities/session-state.ts +22 -4
- package/src/activities/site-auth-maintenance.ts +269 -0
- package/src/activities/streaming.ts +42 -3
- package/src/activities/types.ts +104 -5
- package/src/activities/video-generation-admission.ts +303 -0
- package/src/activities/video-generation-credential.ts +112 -0
- package/src/activities/video-generation-reconciliation.ts +771 -0
- package/src/activities/video-media-validation.ts +332 -0
- package/src/activities/video-output-retention.ts +314 -0
- package/src/activities/video-reference-staging.ts +350 -0
- package/src/activities/workflow-wake.ts +2 -2
- package/src/activities/workspace-capture.ts +44 -10
- 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 +58 -0
- package/src/activities-turn.ts +40 -0
- package/src/activities.ts +53 -124
- package/src/activity-services.ts +62 -0
- package/src/artifact-materializer-entry.ts +35 -0
- package/src/artifact-outbox-entry.ts +29 -0
- package/src/concurrency.ts +484 -6
- package/src/editable-artifact-hint-broker.ts +235 -0
- package/src/editable-artifact-materializer-launcher.ts +515 -0
- package/src/editable-artifact-materializer-service.ts +787 -0
- package/src/editable-artifact-materializer-storage.ts +413 -0
- package/src/editable-artifact-materializer-subprocess.ts +956 -0
- package/src/editable-artifact-materializer.ts +1289 -0
- package/src/editable-artifact-outbox-dispatcher.ts +244 -0
- package/src/editable-artifact-outbox-service.ts +438 -0
- package/src/index.ts +328 -72
- package/src/memory-pressure-guard.ts +489 -0
- package/src/model-checkpoint-memory-collector.ts +123 -0
- package/src/model-context-contributions.ts +159 -0
- package/src/observability-metrics.ts +297 -13
- package/src/sandbox-reaper-contract.ts +73 -0
- package/src/sandbox-reaper-timeout.ts +79 -0
- package/src/sandbox-resume.ts +294 -153
- package/src/sandbox-routing.ts +32 -24
- package/src/worker-service-lifecycle.ts +80 -14
- package/src/workflows/activities.ts +31 -0
- package/src/workflows/file-upload-reaper.ts +9 -1
- package/src/workflows/knowledge-source-sync.ts +83 -0
- package/src/workflows/sandbox-reaper.ts +183 -21
- package/src/workflows/scheduled-tasks.ts +42 -6
- package/src/workflows/session.ts +20 -6
- package/src/workflows/site-auth-maintenance.ts +14 -0
- package/src/workflows/video-generation.ts +36 -0
- package/src/workflows.ts +18 -1
- package/dist/activities/toolspace-token-renewal.d.ts +0 -23
- package/src/activities/toolspace-token-renewal.ts +0 -64
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createGraphqlMcpServer,
|
|
3
|
+
createOpenApiMcpServer,
|
|
4
|
+
createPinnedIntegrationTransport,
|
|
5
|
+
type IntegrationCredentialResolver,
|
|
6
|
+
type IntegrationInvocationAuthority,
|
|
7
|
+
} from "@opengeni/capabilities";
|
|
8
|
+
import type { Settings } from "@opengeni/config";
|
|
9
|
+
import type { ToolAuthNeededPayload } from "@opengeni/contracts";
|
|
10
|
+
import type {
|
|
11
|
+
ApiIntegrationRuntime,
|
|
12
|
+
ResolveConnectionCredentialInput,
|
|
13
|
+
ResolveConnectionCredentialResult,
|
|
14
|
+
} from "@opengeni/db";
|
|
15
|
+
import type { LocalMcpServerRegistration } from "@opengeni/runtime";
|
|
16
|
+
import type { FetchLike } from "@opengeni/network";
|
|
17
|
+
|
|
18
|
+
export type BuildApiIntegrationServersInput = {
|
|
19
|
+
settings: Settings;
|
|
20
|
+
integrations: readonly ApiIntegrationRuntime[];
|
|
21
|
+
authority: Omit<IntegrationInvocationAuthority, "connectionRef">;
|
|
22
|
+
resolveCredential: (
|
|
23
|
+
input: ResolveConnectionCredentialInput,
|
|
24
|
+
) => Promise<ResolveConnectionCredentialResult>;
|
|
25
|
+
onAuthNeeded?: (payload: ToolAuthNeededPayload) => Promise<void> | void;
|
|
26
|
+
fetchImpl?: FetchLike;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Compile active persisted API facets into ordinary in-process MCP servers for
|
|
31
|
+
* one exact attempt. Connection resolution remains request-time, destination-
|
|
32
|
+
* bound, personal-delegation-fenced, and refreshable through the same worker
|
|
33
|
+
* resolver used by remote MCP servers.
|
|
34
|
+
*/
|
|
35
|
+
export function buildApiIntegrationServersForTurn(
|
|
36
|
+
input: BuildApiIntegrationServersInput,
|
|
37
|
+
): LocalMcpServerRegistration[] {
|
|
38
|
+
const transport = createPinnedIntegrationTransport({
|
|
39
|
+
network: input.settings,
|
|
40
|
+
...(input.fetchImpl ? { fetchImpl: input.fetchImpl } : {}),
|
|
41
|
+
});
|
|
42
|
+
return input.integrations.map((integration) => {
|
|
43
|
+
const authority: IntegrationInvocationAuthority = {
|
|
44
|
+
...input.authority,
|
|
45
|
+
...(integration.connectionRef?.connectionId
|
|
46
|
+
? { connectionRef: integration.connectionRef.connectionId }
|
|
47
|
+
: {}),
|
|
48
|
+
};
|
|
49
|
+
const credentialResolver = integration.connectionRef
|
|
50
|
+
? integrationCredentialResolver(input, integration)
|
|
51
|
+
: undefined;
|
|
52
|
+
const server =
|
|
53
|
+
integration.revision.protocol === "openapi"
|
|
54
|
+
? createOpenApiMcpServer({
|
|
55
|
+
revision: integration.revision,
|
|
56
|
+
transport,
|
|
57
|
+
authority,
|
|
58
|
+
...(credentialResolver ? { credentialResolver } : {}),
|
|
59
|
+
})
|
|
60
|
+
: createGraphqlMcpServer({
|
|
61
|
+
revision: integration.revision,
|
|
62
|
+
endpoint: integration.baseUrl,
|
|
63
|
+
transport,
|
|
64
|
+
authority,
|
|
65
|
+
...(credentialResolver ? { credentialResolver } : {}),
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
id: integration.serverId,
|
|
69
|
+
server,
|
|
70
|
+
...(integration.connectionRef?.connectionId
|
|
71
|
+
? { resolvedConnectionId: integration.connectionRef.connectionId }
|
|
72
|
+
: {}),
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function integrationCredentialResolver(
|
|
78
|
+
input: BuildApiIntegrationServersInput,
|
|
79
|
+
integration: ApiIntegrationRuntime,
|
|
80
|
+
): IntegrationCredentialResolver {
|
|
81
|
+
const connectionRef = integration.connectionRef;
|
|
82
|
+
if (!connectionRef) throw new Error("Integration credential resolver requires a connection");
|
|
83
|
+
return {
|
|
84
|
+
resolve: async (request) => {
|
|
85
|
+
const result = await input.resolveCredential({
|
|
86
|
+
workspaceId: input.authority.workspaceId,
|
|
87
|
+
serverId: integration.serverId,
|
|
88
|
+
toolName: request.operationKey,
|
|
89
|
+
connectionRef,
|
|
90
|
+
destinationUrl: request.destinationUrl,
|
|
91
|
+
credentialTarget: "http_api",
|
|
92
|
+
forceRefresh: request.forceRefresh === true,
|
|
93
|
+
});
|
|
94
|
+
if (result.status === "auth_needed") {
|
|
95
|
+
await publishAuthNeeded(input, integration.serverId, request.operationKey, result);
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
const destination = new URL(request.destinationUrl);
|
|
99
|
+
return {
|
|
100
|
+
audience: { origin: destination.origin, pathPrefix: "/" },
|
|
101
|
+
placements:
|
|
102
|
+
result.placements ??
|
|
103
|
+
Object.entries(result.headers).map(([name, value]) => ({
|
|
104
|
+
carrier: "header" as const,
|
|
105
|
+
name,
|
|
106
|
+
value,
|
|
107
|
+
})),
|
|
108
|
+
...(result.expiresAt ? { expiresAt: result.expiresAt.toISOString() } : {}),
|
|
109
|
+
...(connectionRef.scopes ? { scope: [...connectionRef.scopes] } : {}),
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async function publishAuthNeeded(
|
|
116
|
+
input: BuildApiIntegrationServersInput,
|
|
117
|
+
serverId: string,
|
|
118
|
+
toolName: string,
|
|
119
|
+
result: Extract<ResolveConnectionCredentialResult, { status: "auth_needed" }>,
|
|
120
|
+
): Promise<void> {
|
|
121
|
+
try {
|
|
122
|
+
await input.onAuthNeeded?.({
|
|
123
|
+
serverId,
|
|
124
|
+
toolName,
|
|
125
|
+
providerDomain: result.providerDomain,
|
|
126
|
+
...(result.provider ? { provider: result.provider } : {}),
|
|
127
|
+
reason: result.reason,
|
|
128
|
+
...(result.connectionId ? { connectionId: result.connectionId } : {}),
|
|
129
|
+
...(result.scopes ? { scopes: result.scopes } : {}),
|
|
130
|
+
...(result.resource ? { resource: result.resource } : {}),
|
|
131
|
+
...(result.selectedResources ? { selectedResources: result.selectedResources } : {}),
|
|
132
|
+
...(result.authorizationUrl ? { authorizationUrl: result.authorizationUrl } : {}),
|
|
133
|
+
});
|
|
134
|
+
} catch {
|
|
135
|
+
// Authentication notices are advisory UI/audit signals. The local tool
|
|
136
|
+
// still returns the fixed connection-required result when publication fails.
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import {
|
|
2
|
+
claimBrowserStateArtifactCleanup,
|
|
3
|
+
claimBrowserStateUploadCleanup,
|
|
4
|
+
completeBrowserStateArtifactCleanup,
|
|
5
|
+
completeBrowserStateUploadCleanup,
|
|
6
|
+
type BrowserStateArtifactCleanupClaim,
|
|
7
|
+
type BrowserStateUploadCleanupClaim,
|
|
8
|
+
} from "@opengeni/db";
|
|
9
|
+
import type { ObjectStorage } from "@opengeni/storage";
|
|
10
|
+
import type { ControlActivityServices } from "./types";
|
|
11
|
+
|
|
12
|
+
export const BROWSER_STATE_ARTIFACT_CLAIM_TIMEOUT_MS = 10 * 60 * 1_000;
|
|
13
|
+
export const BROWSER_STATE_ARTIFACT_CLEANUP_BATCH_SIZE = 100;
|
|
14
|
+
|
|
15
|
+
const SAFE_PROVIDER_ERROR_CODES = new Set([
|
|
16
|
+
"aborted",
|
|
17
|
+
"conflict",
|
|
18
|
+
"network",
|
|
19
|
+
"not_found",
|
|
20
|
+
"permission_denied",
|
|
21
|
+
"provider",
|
|
22
|
+
"timeout",
|
|
23
|
+
"unavailable",
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
export type MaintainBrowserStateArtifactsResult = {
|
|
27
|
+
claimed: number;
|
|
28
|
+
deleted: number;
|
|
29
|
+
retryable: number;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type BrowserStateArtifactMaintenanceOptions = {
|
|
33
|
+
claimTimeoutMs?: number;
|
|
34
|
+
batchSize?: number;
|
|
35
|
+
claimArtifacts?: typeof claimBrowserStateArtifactCleanup;
|
|
36
|
+
completeArtifact?: typeof completeBrowserStateArtifactCleanup;
|
|
37
|
+
claimUploads?: typeof claimBrowserStateUploadCleanup;
|
|
38
|
+
completeUpload?: typeof completeBrowserStateUploadCleanup;
|
|
39
|
+
/** Failure-injection seam; production uses the configured provider delete. */
|
|
40
|
+
deleteObject?: (storage: ObjectStorage, key: string) => Promise<void>;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Reap retired encrypted private browser checkpoints. Provider deletion happens
|
|
45
|
+
* before terminal settlement; a crash or provider failure leaves the durable
|
|
46
|
+
* claim reclaimable and an already-deleted provider key is safe to retry.
|
|
47
|
+
*/
|
|
48
|
+
export function createBrowserStateArtifactMaintenanceActivities(
|
|
49
|
+
services: () => Promise<ControlActivityServices>,
|
|
50
|
+
options: BrowserStateArtifactMaintenanceOptions = {},
|
|
51
|
+
) {
|
|
52
|
+
const claimTimeoutMs = options.claimTimeoutMs ?? BROWSER_STATE_ARTIFACT_CLAIM_TIMEOUT_MS;
|
|
53
|
+
const batchSize = options.batchSize ?? BROWSER_STATE_ARTIFACT_CLEANUP_BATCH_SIZE;
|
|
54
|
+
const claimArtifacts = options.claimArtifacts ?? claimBrowserStateArtifactCleanup;
|
|
55
|
+
const completeArtifact = options.completeArtifact ?? completeBrowserStateArtifactCleanup;
|
|
56
|
+
const claimUploads = options.claimUploads ?? claimBrowserStateUploadCleanup;
|
|
57
|
+
const completeUpload = options.completeUpload ?? completeBrowserStateUploadCleanup;
|
|
58
|
+
const deleteObject = options.deleteObject ?? ((storage, key) => storage.deleteObject(key));
|
|
59
|
+
|
|
60
|
+
async function maintainBrowserStateArtifacts(): Promise<MaintainBrowserStateArtifactsResult> {
|
|
61
|
+
const { db, objectStorage, observability } = await services();
|
|
62
|
+
if (!objectStorage) return { claimed: 0, deleted: 0, retryable: 0 };
|
|
63
|
+
|
|
64
|
+
const [artifactClaims, uploadClaims] = await Promise.all([
|
|
65
|
+
claimArtifacts(db, { claimTimeoutMs, limit: batchSize }),
|
|
66
|
+
claimUploads(db, { claimTimeoutMs, limit: batchSize }),
|
|
67
|
+
]);
|
|
68
|
+
const result: MaintainBrowserStateArtifactsResult = {
|
|
69
|
+
claimed: artifactClaims.length + uploadClaims.length,
|
|
70
|
+
deleted: 0,
|
|
71
|
+
retryable: 0,
|
|
72
|
+
};
|
|
73
|
+
for (const cleanup of artifactClaims) {
|
|
74
|
+
try {
|
|
75
|
+
await deleteObject(objectStorage, cleanup.objectKey);
|
|
76
|
+
if (!(await completeArtifact(db, cleanup))) {
|
|
77
|
+
throw new Error("browser state artifact cleanup claim was superseded");
|
|
78
|
+
}
|
|
79
|
+
result.deleted += 1;
|
|
80
|
+
} catch (error) {
|
|
81
|
+
result.retryable += 1;
|
|
82
|
+
observability.warn("browser state artifact cleanup failed; claim remains reclaimable", {
|
|
83
|
+
workspaceId: cleanup.workspaceId,
|
|
84
|
+
artifactId: cleanup.artifactId,
|
|
85
|
+
errorCategory: cleanupErrorCategory(error),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
for (const cleanup of uploadClaims) {
|
|
90
|
+
try {
|
|
91
|
+
await deleteObject(objectStorage, cleanup.objectKey);
|
|
92
|
+
if (!(await completeUpload(db, cleanup))) {
|
|
93
|
+
throw new Error("browser state upload cleanup claim was superseded");
|
|
94
|
+
}
|
|
95
|
+
result.deleted += 1;
|
|
96
|
+
} catch (error) {
|
|
97
|
+
result.retryable += 1;
|
|
98
|
+
observability.warn("browser state upload cleanup failed; claim remains reclaimable", {
|
|
99
|
+
workspaceId: cleanup.workspaceId,
|
|
100
|
+
uploadId: cleanup.uploadId,
|
|
101
|
+
errorCategory: cleanupErrorCategory(error),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (result.claimed > 0) {
|
|
106
|
+
observability.info("browser state artifact maintenance swept", result);
|
|
107
|
+
}
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return { maintainBrowserStateArtifacts };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function cleanupErrorCategory(error: unknown): string {
|
|
115
|
+
if (!error || typeof error !== "object") return "unknown";
|
|
116
|
+
const code = (error as { code?: unknown }).code;
|
|
117
|
+
return typeof code === "string" && SAFE_PROVIDER_ERROR_CODES.has(code) ? code : "unknown";
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export type { BrowserStateArtifactCleanupClaim, BrowserStateUploadCleanupClaim };
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
withCodexCatalogProvider,
|
|
5
5
|
withWorkspaceGatewayCatalogProvider,
|
|
6
6
|
withWorkspaceGatewayCredential,
|
|
7
|
+
withXaiSubscriptionCatalogProvider,
|
|
7
8
|
} from "@opengeni/config";
|
|
8
9
|
import { settingsWithEnabledCapabilityMcpServers } from "@opengeni/core";
|
|
9
10
|
import {
|
|
@@ -114,6 +115,15 @@ export function withCodexProvider(settings: Settings): Settings {
|
|
|
114
115
|
return withCodexCatalogProvider(settings);
|
|
115
116
|
}
|
|
116
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Pure: append the synthetic SuperGrok/xAI subscription provider,
|
|
120
|
+
* idempotently. The overlay is catalogue metadata only; the exact account,
|
|
121
|
+
* authority snapshot, and bearer remain frozen later at turn admission.
|
|
122
|
+
*/
|
|
123
|
+
export function withXaiSubscriptionProvider(settings: Settings): Settings {
|
|
124
|
+
return withXaiSubscriptionCatalogProvider(settings);
|
|
125
|
+
}
|
|
126
|
+
|
|
117
127
|
export async function settingsWithWorkspaceGatewayCredential(
|
|
118
128
|
db: Database,
|
|
119
129
|
workspaceId: string,
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import {
|
|
3
|
+
AttemptToolApprovalRequiredError,
|
|
4
|
+
AttemptToolCatalogStaleError,
|
|
5
|
+
AttemptToolNotFoundError,
|
|
6
|
+
codemodeDispatchSubject,
|
|
7
|
+
decodeCodemodeDispatchRequest,
|
|
8
|
+
encodeCodemodeDispatchAck,
|
|
9
|
+
type AttemptToolEnvironment,
|
|
10
|
+
} from "@opengeni/codemode";
|
|
11
|
+
import {
|
|
12
|
+
CODEMODE_CLAIM_HEARTBEAT_MS,
|
|
13
|
+
CODEMODE_MAX_CONCURRENT_CALLS_PER_ATTEMPT,
|
|
14
|
+
type CodemodeOperation,
|
|
15
|
+
} from "@opengeni/contracts";
|
|
16
|
+
import {
|
|
17
|
+
cancelQueuedCodemodeOperationsForAttempt,
|
|
18
|
+
claimCodemodeOperation,
|
|
19
|
+
failCodemodeOperation,
|
|
20
|
+
markCodemodeOperationExecutionStarted,
|
|
21
|
+
renewCodemodeOperationClaim,
|
|
22
|
+
settleCodemodeOperationWithOutput,
|
|
23
|
+
type Database,
|
|
24
|
+
} from "@opengeni/db";
|
|
25
|
+
import {
|
|
26
|
+
appendAndPublishTurnEventsFenced,
|
|
27
|
+
publishDurableSessionEvents,
|
|
28
|
+
type EventBus,
|
|
29
|
+
} from "@opengeni/events";
|
|
30
|
+
|
|
31
|
+
export type CodemodeDispatcherScope = {
|
|
32
|
+
accountId: string;
|
|
33
|
+
workspaceId: string;
|
|
34
|
+
sessionId: string;
|
|
35
|
+
turnId: string;
|
|
36
|
+
attemptId: string;
|
|
37
|
+
executionGeneration: number;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Owns the only Codemode execution edge for one exact attempt. NATS carries a
|
|
42
|
+
* wake-up only; the durable row is claimed before any side effect and the call
|
|
43
|
+
* is executed by the same AttemptToolEnvironment already bound to model MCP.
|
|
44
|
+
*/
|
|
45
|
+
export class CodemodeAttemptDispatcher {
|
|
46
|
+
private readonly stopController = new AbortController();
|
|
47
|
+
private readonly inFlight = new Map<string, Promise<void>>();
|
|
48
|
+
private pendingClaims = 0;
|
|
49
|
+
private unsubscribe: (() => void) | null = null;
|
|
50
|
+
private closing = false;
|
|
51
|
+
|
|
52
|
+
constructor(
|
|
53
|
+
private readonly db: Database,
|
|
54
|
+
private readonly bus: EventBus,
|
|
55
|
+
private readonly environment: AttemptToolEnvironment,
|
|
56
|
+
private readonly scope: CodemodeDispatcherScope,
|
|
57
|
+
private readonly turnSignal?: AbortSignal,
|
|
58
|
+
private readonly maxConcurrentCalls = CODEMODE_MAX_CONCURRENT_CALLS_PER_ATTEMPT,
|
|
59
|
+
) {
|
|
60
|
+
if (
|
|
61
|
+
environment.catalog.accountId !== scope.accountId ||
|
|
62
|
+
environment.catalog.workspaceId !== scope.workspaceId ||
|
|
63
|
+
environment.catalog.sessionId !== scope.sessionId ||
|
|
64
|
+
environment.catalog.turnId !== scope.turnId ||
|
|
65
|
+
environment.catalog.attemptId !== scope.attemptId ||
|
|
66
|
+
environment.catalog.executionGeneration !== scope.executionGeneration
|
|
67
|
+
) {
|
|
68
|
+
throw new Error("Codemode dispatcher scope does not match its tool environment");
|
|
69
|
+
}
|
|
70
|
+
if (!Number.isSafeInteger(maxConcurrentCalls) || maxConcurrentCalls < 1) {
|
|
71
|
+
throw new Error("Codemode dispatcher concurrency must be a positive safe integer");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
start(): void {
|
|
76
|
+
if (this.unsubscribe || this.closing)
|
|
77
|
+
throw new Error("Codemode dispatcher cannot be restarted");
|
|
78
|
+
this.unsubscribe = this.bus.subscribeRequests(
|
|
79
|
+
codemodeDispatchSubject(this.scope.workspaceId, this.scope.attemptId),
|
|
80
|
+
async (payload) => {
|
|
81
|
+
const request = decodeCodemodeDispatchRequest(payload);
|
|
82
|
+
if (request.catalogDigest !== this.environment.catalog.digest || this.closing) {
|
|
83
|
+
return encodeCodemodeDispatchAck({
|
|
84
|
+
version: 1,
|
|
85
|
+
operationId: request.operationId,
|
|
86
|
+
status: "rejected",
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
if (
|
|
90
|
+
!this.inFlight.has(request.operationId) &&
|
|
91
|
+
this.inFlight.size + this.pendingClaims >= this.maxConcurrentCalls
|
|
92
|
+
) {
|
|
93
|
+
return encodeCodemodeDispatchAck({
|
|
94
|
+
version: 1,
|
|
95
|
+
operationId: request.operationId,
|
|
96
|
+
status: "unavailable",
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
this.pendingClaims += 1;
|
|
100
|
+
try {
|
|
101
|
+
const claim = await claimCodemodeOperation(this.db, {
|
|
102
|
+
...this.scope,
|
|
103
|
+
catalogDigest: request.catalogDigest,
|
|
104
|
+
operationId: request.operationId,
|
|
105
|
+
claimId: randomUUID(),
|
|
106
|
+
});
|
|
107
|
+
if (claim.status === "claimed") {
|
|
108
|
+
const execution = this.execute(claim.operation, claim.claimId).finally(() => {
|
|
109
|
+
this.inFlight.delete(request.operationId);
|
|
110
|
+
});
|
|
111
|
+
this.inFlight.set(request.operationId, execution);
|
|
112
|
+
return encodeCodemodeDispatchAck({
|
|
113
|
+
version: 1,
|
|
114
|
+
operationId: request.operationId,
|
|
115
|
+
status: "accepted",
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return encodeCodemodeDispatchAck({
|
|
119
|
+
version: 1,
|
|
120
|
+
operationId: request.operationId,
|
|
121
|
+
status: claim.status,
|
|
122
|
+
});
|
|
123
|
+
} finally {
|
|
124
|
+
this.pendingClaims -= 1;
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async close(reason = "Execution attempt ended"): Promise<void> {
|
|
131
|
+
if (this.closing) {
|
|
132
|
+
await Promise.allSettled([...this.inFlight.values()]);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
this.closing = true;
|
|
136
|
+
this.unsubscribe?.();
|
|
137
|
+
this.unsubscribe = null;
|
|
138
|
+
this.stopController.abort(reason);
|
|
139
|
+
await cancelQueuedCodemodeOperationsForAttempt(this.db, {
|
|
140
|
+
accountId: this.scope.accountId,
|
|
141
|
+
workspaceId: this.scope.workspaceId,
|
|
142
|
+
attemptId: this.scope.attemptId,
|
|
143
|
+
reason,
|
|
144
|
+
});
|
|
145
|
+
await Promise.allSettled([...this.inFlight.values()]);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
private async execute(operation: CodemodeOperation, claimId: string): Promise<void> {
|
|
149
|
+
const entry = this.environment.catalog.entries.find(
|
|
150
|
+
(candidate) =>
|
|
151
|
+
candidate.identity.serverId === operation.identity.serverId &&
|
|
152
|
+
candidate.identity.toolName === operation.identity.toolName,
|
|
153
|
+
);
|
|
154
|
+
if (!entry) {
|
|
155
|
+
await this.failBeforeExecution(
|
|
156
|
+
operation.operationId,
|
|
157
|
+
claimId,
|
|
158
|
+
"tool_not_found",
|
|
159
|
+
"Tool left the active catalog",
|
|
160
|
+
);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const signal = combinedSignal(this.stopController.signal, this.turnSignal);
|
|
164
|
+
if (signal.aborted) {
|
|
165
|
+
await this.failBeforeExecution(
|
|
166
|
+
operation.operationId,
|
|
167
|
+
claimId,
|
|
168
|
+
"attempt_cancelled",
|
|
169
|
+
"Execution attempt ended before the Codemode call started",
|
|
170
|
+
);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const created = await appendAndPublishTurnEventsFenced(
|
|
174
|
+
this.db,
|
|
175
|
+
this.bus,
|
|
176
|
+
this.scope.workspaceId,
|
|
177
|
+
this.scope.sessionId,
|
|
178
|
+
this.scope.turnId,
|
|
179
|
+
this.scope.executionGeneration,
|
|
180
|
+
this.scope.attemptId,
|
|
181
|
+
[
|
|
182
|
+
{
|
|
183
|
+
type: "agent.toolCall.created",
|
|
184
|
+
turnId: this.scope.turnId,
|
|
185
|
+
turnGeneration: this.scope.executionGeneration,
|
|
186
|
+
turnAttemptId: this.scope.attemptId,
|
|
187
|
+
producerId: operation.caller.subjectId,
|
|
188
|
+
payload: {
|
|
189
|
+
id: operation.operationId,
|
|
190
|
+
name: entry.modelName,
|
|
191
|
+
arguments: operation.arguments,
|
|
192
|
+
origin: "codemode",
|
|
193
|
+
subjectId: operation.caller.subjectId,
|
|
194
|
+
raw: {
|
|
195
|
+
type: "codemode_call",
|
|
196
|
+
serverId: operation.identity.serverId,
|
|
197
|
+
toolName: operation.identity.toolName,
|
|
198
|
+
catalogDigest: operation.catalogDigest,
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
).catch(() => ({ accepted: false }));
|
|
204
|
+
if (!created.accepted) {
|
|
205
|
+
await this.failBeforeExecution(
|
|
206
|
+
operation.operationId,
|
|
207
|
+
claimId,
|
|
208
|
+
"attempt_fence_closed",
|
|
209
|
+
"Execution attempt ended before the Codemode call started",
|
|
210
|
+
);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (signal.aborted) {
|
|
214
|
+
await this.settleWithOutput(operation, claimId, {
|
|
215
|
+
state: "failed",
|
|
216
|
+
errorCode: "attempt_cancelled",
|
|
217
|
+
errorMessage: "Execution attempt ended before the Codemode call started",
|
|
218
|
+
});
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const claimAuthority = {
|
|
223
|
+
accountId: this.scope.accountId,
|
|
224
|
+
workspaceId: this.scope.workspaceId,
|
|
225
|
+
attemptId: this.scope.attemptId,
|
|
226
|
+
operationId: operation.operationId,
|
|
227
|
+
claimId,
|
|
228
|
+
};
|
|
229
|
+
const crossedExecutionBoundary = await markCodemodeOperationExecutionStarted(
|
|
230
|
+
this.db,
|
|
231
|
+
claimAuthority,
|
|
232
|
+
);
|
|
233
|
+
if (!crossedExecutionBoundary) return;
|
|
234
|
+
const heartbeat = setInterval(() => {
|
|
235
|
+
void renewCodemodeOperationClaim(this.db, claimAuthority).catch(() => undefined);
|
|
236
|
+
}, CODEMODE_CLAIM_HEARTBEAT_MS);
|
|
237
|
+
heartbeat.unref?.();
|
|
238
|
+
try {
|
|
239
|
+
const result = await this.environment.call(
|
|
240
|
+
{
|
|
241
|
+
operationId: operation.operationId,
|
|
242
|
+
catalogDigest: operation.catalogDigest,
|
|
243
|
+
identity: operation.identity,
|
|
244
|
+
arguments: operation.arguments,
|
|
245
|
+
caller: operation.caller,
|
|
246
|
+
},
|
|
247
|
+
{ signal },
|
|
248
|
+
);
|
|
249
|
+
await this.settleWithOutput(operation, claimId, { state: "completed", result });
|
|
250
|
+
} catch (error) {
|
|
251
|
+
const knownPreExecution =
|
|
252
|
+
error instanceof AttemptToolApprovalRequiredError ||
|
|
253
|
+
error instanceof AttemptToolCatalogStaleError ||
|
|
254
|
+
error instanceof AttemptToolNotFoundError;
|
|
255
|
+
await this.settleWithOutput(operation, claimId, {
|
|
256
|
+
state: knownPreExecution ? "failed" : "outcome_unknown",
|
|
257
|
+
errorCode: errorCode(error, signal),
|
|
258
|
+
errorMessage: !knownPreExecution
|
|
259
|
+
? "Tool execution ended without a durable result. Its side-effect outcome is unknown; inspect actual state before retrying."
|
|
260
|
+
: safeErrorMessage(error),
|
|
261
|
+
});
|
|
262
|
+
} finally {
|
|
263
|
+
clearInterval(heartbeat);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
private async settleWithOutput(
|
|
268
|
+
operation: CodemodeOperation,
|
|
269
|
+
claimId: string,
|
|
270
|
+
settlement:
|
|
271
|
+
| { state: "completed"; result: NonNullable<CodemodeOperation["result"]> }
|
|
272
|
+
| {
|
|
273
|
+
state: "failed" | "outcome_unknown";
|
|
274
|
+
errorCode: string;
|
|
275
|
+
errorMessage: string;
|
|
276
|
+
},
|
|
277
|
+
): Promise<void> {
|
|
278
|
+
const result = await settleCodemodeOperationWithOutput(this.db, {
|
|
279
|
+
...this.scope,
|
|
280
|
+
operationId: operation.operationId,
|
|
281
|
+
claimId,
|
|
282
|
+
producerId: operation.caller.subjectId,
|
|
283
|
+
settlement,
|
|
284
|
+
});
|
|
285
|
+
if (!result.committed || result.events.length === 0) return;
|
|
286
|
+
await publishDurableSessionEvents(
|
|
287
|
+
this.bus,
|
|
288
|
+
this.scope.workspaceId,
|
|
289
|
+
this.scope.sessionId,
|
|
290
|
+
result.events,
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
private async failBeforeExecution(
|
|
295
|
+
operationId: string,
|
|
296
|
+
claimId: string,
|
|
297
|
+
failureCode: string,
|
|
298
|
+
failureMessage: string,
|
|
299
|
+
): Promise<void> {
|
|
300
|
+
await failCodemodeOperation(this.db, {
|
|
301
|
+
accountId: this.scope.accountId,
|
|
302
|
+
workspaceId: this.scope.workspaceId,
|
|
303
|
+
attemptId: this.scope.attemptId,
|
|
304
|
+
operationId,
|
|
305
|
+
claimId,
|
|
306
|
+
state: "failed",
|
|
307
|
+
errorCode: failureCode,
|
|
308
|
+
errorMessage: failureMessage,
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function combinedSignal(primary: AbortSignal, secondary?: AbortSignal): AbortSignal {
|
|
314
|
+
return secondary ? AbortSignal.any([primary, secondary]) : primary;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function errorCode(error: unknown, signal: AbortSignal): string {
|
|
318
|
+
if (signal.aborted) return "attempt_cancelled_during_execution";
|
|
319
|
+
if (typeof error === "object" && error !== null && "code" in error) {
|
|
320
|
+
const code = (error as { code?: unknown }).code;
|
|
321
|
+
if (typeof code === "string" && /^[a-z0-9_]{1,128}$/u.test(code)) return code;
|
|
322
|
+
}
|
|
323
|
+
return "tool_outcome_unknown";
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function safeErrorMessage(error: unknown): string {
|
|
327
|
+
if (
|
|
328
|
+
error instanceof AttemptToolApprovalRequiredError ||
|
|
329
|
+
error instanceof AttemptToolCatalogStaleError ||
|
|
330
|
+
error instanceof AttemptToolNotFoundError
|
|
331
|
+
) {
|
|
332
|
+
return error.message;
|
|
333
|
+
}
|
|
334
|
+
return "Codemode call failed before tool execution";
|
|
335
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
startExpiringMaterialRenewalLoop,
|
|
3
|
+
type ExpiringMaterialRenewalController,
|
|
4
|
+
} from "./expiring-material-renewal";
|
|
5
|
+
import type { MintedSandboxCodemodeToken } from "./environment";
|
|
6
|
+
|
|
7
|
+
export const CODEMODE_TOKEN_DEFAULT_REFRESH_MS = 30 * 60_000;
|
|
8
|
+
export const CODEMODE_TOKEN_EXPIRY_LEAD_MS = 5 * 60_000;
|
|
9
|
+
export const CODEMODE_TOKEN_MIN_REFRESH_MS = 5_000;
|
|
10
|
+
export const CODEMODE_TOKEN_MAX_RETRY_MS = 5 * 60_000;
|
|
11
|
+
|
|
12
|
+
export type CodemodeTokenRenewalController = ExpiringMaterialRenewalController;
|
|
13
|
+
|
|
14
|
+
export type CodemodeTokenRenewalOptions = {
|
|
15
|
+
initialExpiresAt: Date;
|
|
16
|
+
mint: () => Promise<MintedSandboxCodemodeToken | undefined>;
|
|
17
|
+
write: (material: MintedSandboxCodemodeToken) => Promise<void>;
|
|
18
|
+
now?: () => number;
|
|
19
|
+
schedule?: (callback: () => void, delayMs: number) => unknown;
|
|
20
|
+
clearSchedule?: (timer: unknown) => void;
|
|
21
|
+
onSuccess?: (result: { nextDelayMs: number }) => void;
|
|
22
|
+
onFailure?: (failure: {
|
|
23
|
+
retryDelayMs: number;
|
|
24
|
+
errorClass: "CodemodeTokenRenewalOperationError";
|
|
25
|
+
}) => void;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
class CodemodeTokenRenewalError extends Error {
|
|
29
|
+
override readonly name = "CodemodeTokenRenewalError";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function startCodemodeTokenRenewalLoop(
|
|
33
|
+
options: CodemodeTokenRenewalOptions,
|
|
34
|
+
): CodemodeTokenRenewalController {
|
|
35
|
+
return startExpiringMaterialRenewalLoop<
|
|
36
|
+
MintedSandboxCodemodeToken,
|
|
37
|
+
"CodemodeTokenRenewalOperationError"
|
|
38
|
+
>({
|
|
39
|
+
initialExpiresAt: options.initialExpiresAt,
|
|
40
|
+
resolve: async () => {
|
|
41
|
+
const minted = await options.mint();
|
|
42
|
+
if (!minted) {
|
|
43
|
+
throw new CodemodeTokenRenewalError("Codemode token mint is no longer available");
|
|
44
|
+
}
|
|
45
|
+
return minted;
|
|
46
|
+
},
|
|
47
|
+
write: options.write,
|
|
48
|
+
expiresAt: (material) => material.expiresAt,
|
|
49
|
+
publicErrorClass: "CodemodeTokenRenewalOperationError",
|
|
50
|
+
policy: {
|
|
51
|
+
defaultRefreshMs: CODEMODE_TOKEN_DEFAULT_REFRESH_MS,
|
|
52
|
+
expiryLeadMs: CODEMODE_TOKEN_EXPIRY_LEAD_MS,
|
|
53
|
+
minRefreshMs: CODEMODE_TOKEN_MIN_REFRESH_MS,
|
|
54
|
+
maxRetryMs: CODEMODE_TOKEN_MAX_RETRY_MS,
|
|
55
|
+
},
|
|
56
|
+
...(options.now ? { now: options.now } : {}),
|
|
57
|
+
...(options.schedule ? { schedule: options.schedule } : {}),
|
|
58
|
+
...(options.clearSchedule ? { clearSchedule: options.clearSchedule } : {}),
|
|
59
|
+
...(options.onSuccess
|
|
60
|
+
? { onSuccess: ({ nextDelayMs }) => options.onSuccess?.({ nextDelayMs }) }
|
|
61
|
+
: {}),
|
|
62
|
+
...(options.onFailure ? { onFailure: options.onFailure } : {}),
|
|
63
|
+
});
|
|
64
|
+
}
|