@opengeni/worker-bundle 0.23.4-canary.0 → 0.24.2-canary.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-turn/admission.d.ts +7 -0
- package/dist/activities/agent-turn/model-usage.d.ts +5 -0
- package/dist/activities/agent-turn/quiescence.d.ts +2 -0
- package/dist/activities/agent-turn/run.d.ts +9 -0
- package/dist/activities/agent-turn/sandbox-runtime.d.ts +15 -0
- package/dist/activities/agent-turn/session-title.d.ts +21 -0
- package/dist/activities/agent-turn/stream-attempt.d.ts +4 -0
- package/dist/activities/agent-turn/tool-environment.d.ts +1 -0
- package/dist/activities/agent-turn/turn-context.d.ts +2 -1
- package/dist/activities/agent-turn.d.ts +1 -1
- package/dist/activities/capabilities.d.ts +1 -0
- package/dist/activities/context-compaction.d.ts +2 -0
- package/dist/{activities-control-SGU2WEVB.js → activities-control-ZWH7J4KZ.js} +102 -94
- package/dist/activities-control-ZWH7J4KZ.js.map +1 -0
- package/dist/{activities-turn-7EAQXW6Q.js → activities-turn-I4OPLQLS.js} +613 -284
- package/dist/activities-turn-I4OPLQLS.js.map +1 -0
- package/dist/{chunk-TJIPCHMP.js → chunk-65JEWP2Q.js} +105 -6
- package/dist/chunk-65JEWP2Q.js.map +1 -0
- package/dist/{chunk-GRFQTTSQ.js → chunk-GDCLDKSH.js} +7 -3
- package/dist/{chunk-GRFQTTSQ.js.map → chunk-GDCLDKSH.js.map} +1 -1
- package/dist/{chunk-S2QVRVJW.js → chunk-RQNH6CGR.js} +28 -41
- package/dist/chunk-RQNH6CGR.js.map +1 -0
- package/dist/index.js +16 -3
- package/dist/index.js.map +1 -1
- package/dist/observability-metrics.d.ts +33 -7
- package/dist/sandbox-reaper-timeout.d.ts +2 -2
- package/dist/sandbox-resume.d.ts +6 -1
- package/package.json +17 -17
- package/src/activities/agent-turn/admission.ts +19 -0
- package/src/activities/agent-turn/claim.ts +9 -1
- package/src/activities/agent-turn/compaction-prep.ts +6 -1
- package/src/activities/agent-turn/finalization.ts +31 -17
- package/src/activities/agent-turn/model-usage.ts +33 -4
- package/src/activities/agent-turn/quiescence.ts +11 -2
- package/src/activities/agent-turn/run.ts +74 -1
- package/src/activities/agent-turn/sandbox-runtime.ts +78 -81
- package/src/activities/agent-turn/session-title.ts +55 -2
- package/src/activities/agent-turn/stream-attempt.ts +258 -135
- package/src/activities/agent-turn/tool-environment.ts +41 -7
- package/src/activities/agent-turn/turn-context.ts +4 -2
- package/src/activities/agent-turn.ts +5 -1
- package/src/activities/api-integrations.ts +11 -1
- package/src/activities/capabilities.ts +57 -0
- package/src/activities/context-compaction.ts +3 -0
- package/src/activities/goals.ts +1 -0
- package/src/activities/mcp-credentials.ts +53 -0
- package/src/activities/rig-verification.ts +5 -3
- package/src/activities/scheduled-tasks.ts +111 -98
- package/src/index.ts +15 -0
- package/src/observability-metrics.ts +152 -14
- package/src/sandbox-reaper-timeout.ts +10 -4
- package/src/sandbox-resume.ts +58 -8
- package/dist/activities-control-SGU2WEVB.js.map +0 -1
- package/dist/activities-turn-7EAQXW6Q.js.map +0 -1
- package/dist/chunk-S2QVRVJW.js.map +0 -1
- package/dist/chunk-TJIPCHMP.js.map +0 -1
|
@@ -29,6 +29,13 @@ export declare function isDirectHumanTurnInitiation(turn: Pick<SessionTurn, "sou
|
|
|
29
29
|
* Slack explicitly. Other providers retain the existing generic behavior.
|
|
30
30
|
*/
|
|
31
31
|
export declare function shouldPublishToolAuthNeededForTurn(payload: Pick<ToolAuthNeededPayload, "providerDomain" | "toolName">, trigger: Pick<SessionEvent, "type" | "payload">, turn: Pick<SessionTurn, "source" | "initiator" | "initiatorContext">): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Keep host-owned auth events inert in browsers from before authoritySource
|
|
34
|
+
* existed. Those bundles treat unsupported_auth as unavailable and therefore
|
|
35
|
+
* do not invoke native OAuth; upgraded clients read hostReason and the
|
|
36
|
+
* host-minted authorizationUrl.
|
|
37
|
+
*/
|
|
38
|
+
export declare function rollingSafeToolAuthNeededPayload(payload: ToolAuthNeededPayload): ToolAuthNeededPayload;
|
|
32
39
|
export declare function turnExecutionPolicyBillingIdentity(policy: TurnExecutionPolicyV1): {
|
|
33
40
|
externallyBilled: boolean;
|
|
34
41
|
countsTowardTokenCap: boolean;
|
|
@@ -47,6 +47,7 @@ export type CompactionModelUsageEventState = {
|
|
|
47
47
|
};
|
|
48
48
|
export declare function createModelResponseEventState(claimedSourceKeys?: Set<string>): ModelResponseEventState;
|
|
49
49
|
export declare function createCompactionModelUsageEventState(claimedSourceKeys?: Set<string>): CompactionModelUsageEventState;
|
|
50
|
+
export declare const createSessionTitleModelUsageEventState: typeof createCompactionModelUsageEventState;
|
|
50
51
|
export declare function modelResponseContextSignal(state: ModelResponseEventState): {
|
|
51
52
|
revision: number;
|
|
52
53
|
totalTokens: number;
|
|
@@ -120,6 +121,7 @@ export declare function processModelResponseTerminalEvent(input: {
|
|
|
120
121
|
export declare function processCompactionModelUsageEvent(input: {
|
|
121
122
|
usage: ModelResponseUsage;
|
|
122
123
|
state: CompactionModelUsageEventState;
|
|
124
|
+
sourceKind?: "compaction" | "session-title";
|
|
123
125
|
dispatchId: string | null;
|
|
124
126
|
settings: Settings;
|
|
125
127
|
db: ActivityServices["db"];
|
|
@@ -151,6 +153,7 @@ export declare function processCompactionModelUsageEvent(input: {
|
|
|
151
153
|
sourceKey: string;
|
|
152
154
|
authoritative: boolean;
|
|
153
155
|
}>;
|
|
156
|
+
export declare function processSessionTitleModelUsageEvent(input: Omit<Parameters<typeof processCompactionModelUsageEvent>[0], "sourceKind">): ReturnType<typeof processCompactionModelUsageEvent>;
|
|
154
157
|
export declare function emitModelCallUsage(input: {
|
|
155
158
|
observability: ActivityServices["observability"];
|
|
156
159
|
publish: TurnEventPublisher | null;
|
|
@@ -186,6 +189,8 @@ export type ModelUsageBillingRecord = {
|
|
|
186
189
|
pricedCostMicros: number;
|
|
187
190
|
/** Hypothetical provider-rate USD micros; never an OpenGeni charge. */
|
|
188
191
|
estimatedProviderCostMicros: number | null;
|
|
192
|
+
/** Hypothetical OpenGeni credit price at the captured rate; never a debit. */
|
|
193
|
+
equivalentCreditCostMicros: number | null;
|
|
189
194
|
pricingSource: "configured_list_price" | "gateway_reported" | null;
|
|
190
195
|
normalizedUsage: ModelCallUsageNormalization;
|
|
191
196
|
upstreamProvider?: string;
|
|
@@ -9,6 +9,7 @@ import { type SessionEvent } from "@opengeni/contracts";
|
|
|
9
9
|
export declare function shouldRunTurnEndWorkspacePersistence(input: {
|
|
10
10
|
activityStatus: RunAgentTurnResult["status"] | "unknown";
|
|
11
11
|
cancellationRequested: boolean;
|
|
12
|
+
deadlineRotationRequested?: boolean;
|
|
12
13
|
}): boolean;
|
|
13
14
|
/**
|
|
14
15
|
* Periodic workspace snapshots protect work performed during a long-running
|
|
@@ -20,6 +21,7 @@ export declare function shouldStartPeriodicWorkspaceSnapshot(input: {
|
|
|
20
21
|
firstProviderRequestStarted: boolean;
|
|
21
22
|
snapshotInFlight: boolean;
|
|
22
23
|
turnEndCaptureInProgress: boolean;
|
|
24
|
+
deadlineRotationRequested: boolean;
|
|
23
25
|
}): boolean;
|
|
24
26
|
/**
|
|
25
27
|
* Temporal cancellation is delivery/transport state, never proof that the
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import { type CodexRequestContext } from "@opengeni/codex";
|
|
2
|
+
import { type XaiSubscriptionRequestContext } from "@opengeni/xai-subscription";
|
|
1
3
|
import type { TurnActivityServices as ActivityServices, RunAgentTurnInput, RunAgentTurnResult } from "../types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Retain subscription credential/account authority for the title sidecar
|
|
6
|
+
* without sharing main-stream recovery, startup, audit, or opaque-artifact
|
|
7
|
+
* callbacks. Title usage is returned by the runtime and metered separately.
|
|
8
|
+
*/
|
|
9
|
+
export declare function sessionTitleCodexRequestContext(context: CodexRequestContext, nextRequestId: () => string): CodexRequestContext;
|
|
10
|
+
export declare function sessionTitleXaiRequestContext(context: XaiSubscriptionRequestContext, nextRequestId: () => string): XaiSubscriptionRequestContext;
|
|
2
11
|
/** Lifecycle orchestrator: claim → capacity → governance → sandbox → tools → stream. */
|
|
3
12
|
export declare function createRunAgentTurnActivity(services: () => Promise<ActivityServices>): (input: RunAgentTurnInput) => Promise<RunAgentTurnResult>;
|
|
@@ -18,6 +18,21 @@ export type SandboxTurnRuntimeDeps = {
|
|
|
18
18
|
attempt: AttemptIdentityState;
|
|
19
19
|
};
|
|
20
20
|
export type SandboxTurnRuntime = ReturnType<typeof createSandboxTurnRuntime>;
|
|
21
|
+
/**
|
|
22
|
+
* Provider-deadline rotation is a preemption boundary, not a cooperative
|
|
23
|
+
* snapshot boundary. Snapshotting while this attempt still owns active tools
|
|
24
|
+
* can deadlock on its own unsettled mutation admission or on an earlier native
|
|
25
|
+
* capture. Abort first; the ordinary attempt finalizer then drains every writer
|
|
26
|
+
* and releases the holder, after which the zero-holder reaper owns the exact
|
|
27
|
+
* generation capture and same-request takeover protocol.
|
|
28
|
+
*/
|
|
29
|
+
export declare function preemptSandboxTurnForDeadlineRotation(input: {
|
|
30
|
+
controller: AbortController;
|
|
31
|
+
sandboxState: Pick<SandboxRuntimeState, "deadlineRotationRequested">;
|
|
32
|
+
sandboxGroupId: string;
|
|
33
|
+
leaseEpoch: number;
|
|
34
|
+
cancellationSignal?: AbortSignal;
|
|
35
|
+
}): boolean;
|
|
21
36
|
export declare function createSandboxTurnRuntime(deps: SandboxTurnRuntimeDeps): {
|
|
22
37
|
releaseLateSandbox: (sandbox: ResumedTurnSandbox) => Promise<void>;
|
|
23
38
|
requireResolvedSandboxForMutation: (message: string) => ResumedTurnSandbox;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AttemptToolDefinition } from "@opengeni/codemode";
|
|
2
|
+
import type { GeneratedSessionTitle } from "@opengeni/runtime";
|
|
2
3
|
import { type FirstPartyMcpToolName, type Permission, type ToolRef } from "@opengeni/contracts";
|
|
3
4
|
export declare const SESSION_TITLE_MODEL_TOOL_NAME = "opengeni__set_session_title";
|
|
4
5
|
export declare function shouldRequestMissingSessionTitle(input: {
|
|
@@ -11,11 +12,31 @@ export declare function sessionTitleToolPlan(input: {
|
|
|
11
12
|
tools: readonly ToolRef[];
|
|
12
13
|
selectedFirstPartyMcpTools: readonly FirstPartyMcpToolName[];
|
|
13
14
|
shouldRequestTitle: boolean;
|
|
15
|
+
parallelGenerationAvailable: boolean;
|
|
14
16
|
}): {
|
|
15
17
|
promoteTitleTool: boolean;
|
|
18
|
+
generateTitleInParallel: boolean;
|
|
16
19
|
remoteFirstPartyMcpTools: FirstPartyMcpToolName[];
|
|
17
20
|
preparationIndependentToolNames: string[];
|
|
18
21
|
};
|
|
22
|
+
export declare const PARALLEL_SESSION_TITLE_TIMEOUT_MS = 15000;
|
|
23
|
+
export type ParallelSessionTitleGeneration = {
|
|
24
|
+
finish: () => Promise<GeneratedSessionTitle | null>;
|
|
25
|
+
cancel: () => Promise<void>;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Start title inference immediately and keep it independent of the main agent
|
|
29
|
+
* stream. finish() waits for the already-running bounded request, so a quick
|
|
30
|
+
* main response does not discard a valid title merely because it completed
|
|
31
|
+
* first. cancel() aborts and joins exceptional/cancelled exits so no provider
|
|
32
|
+
* work escapes the owning runAgentTurn activity.
|
|
33
|
+
*/
|
|
34
|
+
export declare function startParallelSessionTitleGeneration(input: {
|
|
35
|
+
generate: (signal: AbortSignal) => Promise<GeneratedSessionTitle>;
|
|
36
|
+
signal?: AbortSignal;
|
|
37
|
+
timeoutMs?: number;
|
|
38
|
+
onError?: (error: unknown) => void;
|
|
39
|
+
}): ParallelSessionTitleGeneration;
|
|
19
40
|
export declare function createSessionTitleAttemptToolDefinition(input: {
|
|
20
41
|
updateTitle: (title: string) => Promise<{
|
|
21
42
|
updated: boolean;
|
|
@@ -23,6 +23,7 @@ export type TurnStreamAttemptDeps = {
|
|
|
23
23
|
input: RunAgentTurnInput;
|
|
24
24
|
settings: Settings;
|
|
25
25
|
db: ActivityServices["db"];
|
|
26
|
+
bus: ActivityServices["bus"];
|
|
26
27
|
runtime: ActivityServices["runtime"];
|
|
27
28
|
objectStorage: ActivityServices["objectStorage"];
|
|
28
29
|
observability: ActivityServices["observability"];
|
|
@@ -60,6 +61,7 @@ export type TurnStreamAttemptDeps = {
|
|
|
60
61
|
attachCodemodeTokenRenewal: (tokenSession?: CodemodeTokenWriterSession, initialExpiresAt?: Date, initialSandbox?: ResumedTurnSandbox) => Promise<void>;
|
|
61
62
|
attachRunCredentialRenewal: (credentialSession: RunCredentialCommandSession, initialMaterial: NormalizedRunCredentialMaterial | null, initialSandbox?: ResumedTurnSandbox) => Promise<void>;
|
|
62
63
|
withProviderRequestContext: <T>(fn: () => Promise<T>) => Promise<T>;
|
|
64
|
+
withSessionTitleProviderRequestContext: <T>(fn: () => Promise<T>) => Promise<T>;
|
|
63
65
|
publishCompactionLiveEvents: (events: SessionEvent[]) => Promise<void>;
|
|
64
66
|
publishCompactionOutcomeEvents: (events: SessionEvent[]) => Promise<void>;
|
|
65
67
|
recordCompanyBrainContributionReceiptOnce: () => void;
|
|
@@ -88,6 +90,8 @@ export type TurnStreamAttemptDeps = {
|
|
|
88
90
|
providerApi: HistoryProviderApi;
|
|
89
91
|
runSettings: Settings;
|
|
90
92
|
turnTools: ReturnType<typeof withFirstPartyTools>;
|
|
93
|
+
generateSessionTitleInParallel: boolean;
|
|
94
|
+
sessionTitlePrompt: string;
|
|
91
95
|
compactSummarizer: CompactionSummarizer;
|
|
92
96
|
settleDeferredSteerAfterCompaction: () => Promise<RunAgentTurnResult | null>;
|
|
93
97
|
compactionModelHistoryProjector: (items: Array<Record<string, unknown>>) => Promise<Array<Record<string, unknown>>>;
|
|
@@ -137,6 +137,7 @@ export declare function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps)
|
|
|
137
137
|
readonly subjectId: string;
|
|
138
138
|
};
|
|
139
139
|
};
|
|
140
|
+
generateSessionTitleInParallel: boolean;
|
|
140
141
|
postToolPreparationStartedAt: number;
|
|
141
142
|
preparationIndependentToolNames: string[];
|
|
142
143
|
}>;
|
|
@@ -69,7 +69,8 @@ export type SandboxRuntimeState = {
|
|
|
69
69
|
sandboxHolderId: TurnSandboxLeaseHolderId | null;
|
|
70
70
|
sandboxGroupId: string | null;
|
|
71
71
|
leaseHeartbeatTimer: ReturnType<typeof setInterval> | undefined;
|
|
72
|
-
|
|
72
|
+
rotationPreemptionInFlight: Promise<void> | null;
|
|
73
|
+
deadlineRotationRequested: boolean;
|
|
73
74
|
snapshotInFlight: Promise<void> | null;
|
|
74
75
|
firstProviderRequestStarted: boolean;
|
|
75
76
|
turnEndCaptureInProgress: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Public agent-turn surface. Implementation lives in `./agent-turn/*`. */
|
|
2
|
-
export { createRunAgentTurnActivity } from "./agent-turn/run.js";
|
|
2
|
+
export { createRunAgentTurnActivity, sessionTitleCodexRequestContext, sessionTitleXaiRequestContext, } from "./agent-turn/run.js";
|
|
3
3
|
export * from "./agent-turn/admission.js";
|
|
4
4
|
export * from "./agent-turn/codex.js";
|
|
5
5
|
export * from "./agent-turn/errors.js";
|
|
@@ -24,3 +24,4 @@ export declare function withCodexProvider(settings: Settings): Settings;
|
|
|
24
24
|
export declare function withXaiSubscriptionProvider(settings: Settings): Settings;
|
|
25
25
|
export declare function settingsWithWorkspaceGatewayCredential(db: Database, accountId: string, workspaceId: string, settings: Settings, retainedProductModelId?: string | null): Promise<Settings>;
|
|
26
26
|
export declare function settingsWithWorkspaceOpenRouterCredential(db: Database, accountId: string, workspaceId: string, settings: Settings, retainedProductModelId?: string | null): Promise<Settings>;
|
|
27
|
+
export declare function settingsWithOrganizationProviderCredentials(db: Database, accountId: string, workspaceId: string, settings: Settings, retainedProductModelId?: string | null): Promise<Settings>;
|
|
@@ -54,6 +54,8 @@ export declare function maybeCompactContext(db: Database, settings: Settings, sc
|
|
|
54
54
|
* append again — the event is already durable.
|
|
55
55
|
*/
|
|
56
56
|
publishLiveEvents?: (events: SessionEvent[]) => Promise<void>;
|
|
57
|
+
/** Observe the durable start immediately after its attempt-fenced commit. */
|
|
58
|
+
onCompactionStarted?: (trigger: "auto" | "operator" | "proactive" | "overflow") => void;
|
|
57
59
|
/** Materialize retained screenshot receipts only in the attempt-local model view. */
|
|
58
60
|
materializeHistory?: (items: CompactionItem[]) => Promise<CompactionItem[]>;
|
|
59
61
|
/** Turn-scoped attachment/modality view; canonical persisted rows stay untouched. */
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
SANDBOX_REAPER_CHILD_DISPATCH_LIMIT,
|
|
5
5
|
assertSandboxDrainInputTiming,
|
|
6
6
|
sandboxDrainTiming
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-GDCLDKSH.js";
|
|
8
8
|
import {
|
|
9
9
|
INCIDENT_TELEMETRY_AUTHORITY_FENCE_LINEAGE_KEY,
|
|
10
10
|
MAX_AUTOMATIC_PROVIDER_RECOVERIES,
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
scheduledUserMessagePayload,
|
|
33
33
|
withFirstPartyTools,
|
|
34
34
|
workflowIdForSession
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-RQNH6CGR.js";
|
|
36
36
|
import {
|
|
37
37
|
inspectOpenSandboxKubernetesInventory,
|
|
38
38
|
recordCreditBalanceGauges,
|
|
@@ -52,7 +52,7 @@ import {
|
|
|
52
52
|
recordTurnsQueuedGauge,
|
|
53
53
|
recordWorkerDeathRecoveryMetrics,
|
|
54
54
|
runtimeMetricsHooksForObservability
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-65JEWP2Q.js";
|
|
56
56
|
|
|
57
57
|
// src/activities/browser-state-artifact-reaper.ts
|
|
58
58
|
import {
|
|
@@ -3932,11 +3932,13 @@ function rigPlatformChecksForSettings(settings) {
|
|
|
3932
3932
|
'test -x "$__og_browser_engine"',
|
|
3933
3933
|
'__og_browser_token="$(mktemp)"',
|
|
3934
3934
|
`trap 'opengeni-browserd-down >/dev/null 2>&1 || true; rm -f "$__og_browser_token"' EXIT`,
|
|
3935
|
-
`
|
|
3935
|
+
`__og_browser_token_value="$(od -An -N32 -tx1 /dev/urandom | tr -d '[:space:]')"`,
|
|
3936
|
+
'test "${#__og_browser_token_value}" -eq 64',
|
|
3937
|
+
`printf '%s\\n' "$__og_browser_token_value" > "$__og_browser_token"`,
|
|
3936
3938
|
'chmod 0600 "$__og_browser_token"',
|
|
3937
3939
|
'OPENGENI_BROWSERD_ADMIN_TOKEN_FILE="$__og_browser_token" OPENGENI_BROWSERD_PORT=7682 OPENGENI_BROWSERD_ALLOWED_ORIGINS= opengeni-browserd-up',
|
|
3938
3940
|
"curl --noproxy '*' -fsS http://127.0.0.1:7682/healthz >/dev/null",
|
|
3939
|
-
|
|
3941
|
+
`curl --noproxy '*' -fsS -H "Authorization: Bearer $__og_browser_token_value" http://127.0.0.1:7682/v1/browser-sessions >/dev/null`
|
|
3940
3942
|
].join("\n")
|
|
3941
3943
|
}
|
|
3942
3944
|
];
|
|
@@ -3963,7 +3965,7 @@ function rigPlatformChecksForSettings(settings) {
|
|
|
3963
3965
|
"test -x /usr/local/bin/opengeni-desktop-down",
|
|
3964
3966
|
"command -v Xvfb >/dev/null",
|
|
3965
3967
|
"command -v x11vnc >/dev/null",
|
|
3966
|
-
"
|
|
3968
|
+
"test -x /opt/noVNC/utils/novnc_proxy",
|
|
3967
3969
|
"command -v scrot >/dev/null",
|
|
3968
3970
|
"command -v xdotool >/dev/null",
|
|
3969
3971
|
'__og_desktop_home="$(mktemp -d)"',
|
|
@@ -7286,6 +7288,7 @@ import {
|
|
|
7286
7288
|
resolveWorkspaceCatalogSettings as resolveWorkspaceCatalogSettings2,
|
|
7287
7289
|
resolveSessionToolPolicy,
|
|
7288
7290
|
workspaceCustomModelReference,
|
|
7291
|
+
lockActiveCustomModelForAdmission,
|
|
7289
7292
|
scheduledSlackBotConnectionId,
|
|
7290
7293
|
swapActiveSandbox
|
|
7291
7294
|
} from "@opengeni/core";
|
|
@@ -7315,8 +7318,6 @@ import {
|
|
|
7315
7318
|
getVariableSet,
|
|
7316
7319
|
isCodexBilledModel,
|
|
7317
7320
|
initializeSessionStartAtomically,
|
|
7318
|
-
lockActiveWorkspaceGatewayCustomModelForAdmission,
|
|
7319
|
-
lockActiveWorkspaceOpenRouterCustomModelForAdmission,
|
|
7320
7321
|
materializeScheduledTaskReusableSessionFromRun,
|
|
7321
7322
|
listEnabledMcpCapabilityServerIds,
|
|
7322
7323
|
listInstalledApiIntegrationServerIdsForDelegations,
|
|
@@ -7928,14 +7929,10 @@ function createScheduledTaskActivities(services) {
|
|
|
7928
7929
|
const acceptedLatencyMode = targetSessionExecution?.latencyMode ?? "standard";
|
|
7929
7930
|
const acceptedCustomModel = generatedTarget ? workspaceCustomModelReference(settings, acceptedModel) : null;
|
|
7930
7931
|
const beforeFreshAgentRunCommit = acceptedCustomModel ? async (tx) => {
|
|
7931
|
-
const active =
|
|
7932
|
+
const active = await lockActiveCustomModelForAdmission(tx, {
|
|
7932
7933
|
accountId: task.accountId,
|
|
7933
7934
|
workspaceId: task.workspaceId,
|
|
7934
|
-
|
|
7935
|
-
}) : await lockActiveWorkspaceGatewayCustomModelForAdmission(tx, {
|
|
7936
|
-
accountId: task.accountId,
|
|
7937
|
-
workspaceId: task.workspaceId,
|
|
7938
|
-
upstreamModelId: acceptedCustomModel.upstreamModelId
|
|
7935
|
+
reference: acceptedCustomModel
|
|
7939
7936
|
});
|
|
7940
7937
|
if (!active) {
|
|
7941
7938
|
throw new ScheduledRunTerminalAuthorityError(
|
|
@@ -8433,15 +8430,16 @@ function createScheduledTaskActivities(services) {
|
|
|
8433
8430
|
xaiProviderAccountAuthoritySnapshot: taskXaiProviderAccountAuthoritySnapshot,
|
|
8434
8431
|
scheduledTaskRunId: run.id
|
|
8435
8432
|
},
|
|
8436
|
-
async (tx, wakeEventId) => {
|
|
8433
|
+
async (tx, wakeEventId, _updateId, rejectionReason) => {
|
|
8437
8434
|
if (!wakeEventId) {
|
|
8435
|
+
const error = scheduledSessionRejectionError(rejectionReason);
|
|
8438
8436
|
await settleScheduledTaskRunInTransaction(tx, {
|
|
8439
8437
|
workspaceId: task.workspaceId,
|
|
8440
8438
|
runId: scheduledRun.id,
|
|
8441
8439
|
sessionId: session.id,
|
|
8442
8440
|
triggerEventId: null,
|
|
8443
8441
|
status: "skipped",
|
|
8444
|
-
error
|
|
8442
|
+
error
|
|
8445
8443
|
});
|
|
8446
8444
|
return;
|
|
8447
8445
|
}
|
|
@@ -8453,23 +8451,27 @@ function createScheduledTaskActivities(services) {
|
|
|
8453
8451
|
status: "dispatched"
|
|
8454
8452
|
});
|
|
8455
8453
|
},
|
|
8456
|
-
|
|
8457
|
-
|
|
8458
|
-
|
|
8459
|
-
|
|
8460
|
-
|
|
8461
|
-
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
|
|
8466
|
-
|
|
8454
|
+
{
|
|
8455
|
+
requireIdleSession: task.overlapPolicy === "skip" && !sessionCreated,
|
|
8456
|
+
...incidentPreflightRequired ? {
|
|
8457
|
+
prepareSource: async (tx, sessionId) => await prepareIncidentTelemetrySource({
|
|
8458
|
+
tx,
|
|
8459
|
+
settings,
|
|
8460
|
+
taskId: task.id,
|
|
8461
|
+
workspaceId: task.workspaceId,
|
|
8462
|
+
sessionId,
|
|
8463
|
+
alertOccurrenceLabels: structuredAlertOccurrence?.labels ?? null,
|
|
8464
|
+
acceptedExecution
|
|
8465
|
+
})
|
|
8466
|
+
} : {}
|
|
8467
|
+
}
|
|
8467
8468
|
);
|
|
8468
|
-
if (scheduledUpdate.reason === "session_cancelled") {
|
|
8469
|
+
if (scheduledUpdate.reason === "session_cancelled" || scheduledUpdate.reason === "session_not_idle") {
|
|
8470
|
+
const error = scheduledSessionRejectionError(scheduledUpdate.reason);
|
|
8469
8471
|
return {
|
|
8470
8472
|
kind: "blocked",
|
|
8471
8473
|
result: { action: "blocked", reason: "scheduled_run_terminal" },
|
|
8472
|
-
run: { ...run, status: "skipped", error
|
|
8474
|
+
run: { ...run, status: "skipped", error }
|
|
8473
8475
|
};
|
|
8474
8476
|
}
|
|
8475
8477
|
if (scheduledUpdate.added && scheduledUpdate.events.length > 0) {
|
|
@@ -8508,26 +8510,6 @@ function createScheduledTaskActivities(services) {
|
|
|
8508
8510
|
});
|
|
8509
8511
|
assertReusableSessionRevivable(session.status);
|
|
8510
8512
|
assertReusableSessionBindingMatches(session, task);
|
|
8511
|
-
const goalEvents = task.runMode === "reusable_session" && goalSpec && run.status === "queued" ? await upsertScheduledSessionGoalForRun(dispatchDb, {
|
|
8512
|
-
accountId: task.accountId,
|
|
8513
|
-
workspaceId: task.workspaceId,
|
|
8514
|
-
sessionId: session.id,
|
|
8515
|
-
runId: run.id,
|
|
8516
|
-
text: goalSpec.text,
|
|
8517
|
-
successCriteria: goalSpec.successCriteria ?? null,
|
|
8518
|
-
maxAutoContinuations: goalSpec.maxAutoContinuations ?? null,
|
|
8519
|
-
...goalSpec.mutationPolicy ? { mutationPolicy: goalSpec.mutationPolicy } : {}
|
|
8520
|
-
}) : [];
|
|
8521
|
-
if (goalEvents.length > 0) {
|
|
8522
|
-
if (deferPublications) {
|
|
8523
|
-
deferredEvents.push({
|
|
8524
|
-
sessionId: session.id,
|
|
8525
|
-
events: goalEvents
|
|
8526
|
-
});
|
|
8527
|
-
} else {
|
|
8528
|
-
await publishDurableSessionEvents(bus, task.workspaceId, session.id, goalEvents);
|
|
8529
|
-
}
|
|
8530
|
-
}
|
|
8531
8513
|
const bundled = await addSessionSystemUpdateWithSourceMutation(
|
|
8532
8514
|
dispatchDb,
|
|
8533
8515
|
{
|
|
@@ -8557,15 +8539,16 @@ function createScheduledTaskActivities(services) {
|
|
|
8557
8539
|
xaiProviderAccountAuthoritySnapshot: taskXaiProviderAccountAuthoritySnapshot,
|
|
8558
8540
|
scheduledTaskRunId: run.id
|
|
8559
8541
|
},
|
|
8560
|
-
async (tx, wakeEventId) => {
|
|
8542
|
+
async (tx, wakeEventId, _updateId, rejectionReason) => {
|
|
8561
8543
|
if (!wakeEventId) {
|
|
8544
|
+
const error = scheduledSessionRejectionError(rejectionReason);
|
|
8562
8545
|
await settleScheduledTaskRunInTransaction(tx, {
|
|
8563
8546
|
workspaceId: task.workspaceId,
|
|
8564
8547
|
runId: scheduledRun.id,
|
|
8565
8548
|
sessionId: session.id,
|
|
8566
8549
|
triggerEventId: null,
|
|
8567
8550
|
status: "skipped",
|
|
8568
|
-
error
|
|
8551
|
+
error
|
|
8569
8552
|
});
|
|
8570
8553
|
return;
|
|
8571
8554
|
}
|
|
@@ -8577,23 +8560,41 @@ function createScheduledTaskActivities(services) {
|
|
|
8577
8560
|
status: "dispatched"
|
|
8578
8561
|
});
|
|
8579
8562
|
},
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
|
|
8584
|
-
|
|
8585
|
-
|
|
8586
|
-
|
|
8587
|
-
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8563
|
+
{
|
|
8564
|
+
requireIdleSession: task.overlapPolicy === "skip",
|
|
8565
|
+
prepareSource: async (tx, sessionId) => {
|
|
8566
|
+
const goalEvents = task.runMode === "reusable_session" && goalSpec && run.status === "queued" ? await upsertScheduledSessionGoalForRun(tx, {
|
|
8567
|
+
accountId: task.accountId,
|
|
8568
|
+
workspaceId: task.workspaceId,
|
|
8569
|
+
sessionId,
|
|
8570
|
+
runId: run.id,
|
|
8571
|
+
text: goalSpec.text,
|
|
8572
|
+
successCriteria: goalSpec.successCriteria ?? null,
|
|
8573
|
+
maxAutoContinuations: goalSpec.maxAutoContinuations ?? null,
|
|
8574
|
+
...goalSpec.mutationPolicy ? { mutationPolicy: goalSpec.mutationPolicy } : {}
|
|
8575
|
+
}) : [];
|
|
8576
|
+
const incidentSource = incidentPreflightRequired ? await prepareIncidentTelemetrySource({
|
|
8577
|
+
tx,
|
|
8578
|
+
settings,
|
|
8579
|
+
taskId: task.id,
|
|
8580
|
+
workspaceId: task.workspaceId,
|
|
8581
|
+
sessionId,
|
|
8582
|
+
alertOccurrenceLabels: structuredAlertOccurrence?.labels ?? null,
|
|
8583
|
+
acceptedExecution
|
|
8584
|
+
}) : void 0;
|
|
8585
|
+
return {
|
|
8586
|
+
...incidentSource ?? {},
|
|
8587
|
+
...goalEvents.length > 0 ? { events: goalEvents } : {}
|
|
8588
|
+
};
|
|
8589
|
+
}
|
|
8590
|
+
}
|
|
8591
8591
|
);
|
|
8592
|
-
if (bundled.reason === "session_cancelled") {
|
|
8592
|
+
if (bundled.reason === "session_cancelled" || bundled.reason === "session_not_idle") {
|
|
8593
|
+
const error = scheduledSessionRejectionError(bundled.reason);
|
|
8593
8594
|
return {
|
|
8594
8595
|
kind: "blocked",
|
|
8595
8596
|
result: { action: "blocked", reason: "scheduled_run_terminal" },
|
|
8596
|
-
run: { ...run, status: "skipped", error
|
|
8597
|
+
run: { ...run, status: "skipped", error }
|
|
8597
8598
|
};
|
|
8598
8599
|
}
|
|
8599
8600
|
if (bundled.added && bundled.events.length > 0) {
|
|
@@ -8785,6 +8786,9 @@ function scheduledRunTerminalResult(error) {
|
|
|
8785
8786
|
}
|
|
8786
8787
|
return { action: "blocked", reason: "scheduled_run_terminal" };
|
|
8787
8788
|
}
|
|
8789
|
+
function scheduledSessionRejectionError(rejectionReason) {
|
|
8790
|
+
return rejectionReason === "session_not_idle" ? "scheduled_session_not_idle" : "session_cancelled";
|
|
8791
|
+
}
|
|
8788
8792
|
async function prepareIncidentTelemetrySource(input) {
|
|
8789
8793
|
const session = await requireSession(input.tx, input.workspaceId, input.sessionId);
|
|
8790
8794
|
const { task, personalConnectionDelegations } = input.acceptedExecution ? {
|
|
@@ -9172,21 +9176,6 @@ async function recoverBoundScheduledTaskDispatch(input) {
|
|
|
9172
9176
|
await publishDurableSessionEvents(input.bus, task.workspaceId, session.id, titleEvents);
|
|
9173
9177
|
}
|
|
9174
9178
|
}
|
|
9175
|
-
if (!generatedSession && task.runMode === "reusable_session" && task.agentConfig.goal) {
|
|
9176
|
-
const goalEvents = await upsertScheduledSessionGoalForRun(input.db, {
|
|
9177
|
-
accountId: task.accountId,
|
|
9178
|
-
workspaceId: task.workspaceId,
|
|
9179
|
-
sessionId: session.id,
|
|
9180
|
-
runId: input.run.id,
|
|
9181
|
-
text: task.agentConfig.goal.text,
|
|
9182
|
-
successCriteria: task.agentConfig.goal.successCriteria ?? null,
|
|
9183
|
-
maxAutoContinuations: task.agentConfig.goal.maxAutoContinuations ?? null,
|
|
9184
|
-
...task.agentConfig.goal.mutationPolicy ? { mutationPolicy: task.agentConfig.goal.mutationPolicy } : {}
|
|
9185
|
-
});
|
|
9186
|
-
if (goalEvents.length > 0) {
|
|
9187
|
-
await publishDurableSessionEvents(input.bus, task.workspaceId, session.id, goalEvents);
|
|
9188
|
-
}
|
|
9189
|
-
}
|
|
9190
9179
|
const scheduledUpdate = await addSessionSystemUpdateWithSourceMutation(
|
|
9191
9180
|
input.db,
|
|
9192
9181
|
{
|
|
@@ -9218,15 +9207,16 @@ async function recoverBoundScheduledTaskDispatch(input) {
|
|
|
9218
9207
|
xaiProviderAccountAuthoritySnapshot: input.acceptedExecution.xaiProviderAccountAuthoritySnapshot,
|
|
9219
9208
|
scheduledTaskRunId: input.run.id
|
|
9220
9209
|
},
|
|
9221
|
-
async (tx, wakeEventId) => {
|
|
9210
|
+
async (tx, wakeEventId, _updateId, rejectionReason) => {
|
|
9222
9211
|
if (!wakeEventId) {
|
|
9212
|
+
const error = scheduledSessionRejectionError(rejectionReason);
|
|
9223
9213
|
await settleScheduledTaskRunInTransaction(tx, {
|
|
9224
9214
|
workspaceId: task.workspaceId,
|
|
9225
9215
|
runId: input.run.id,
|
|
9226
9216
|
sessionId: session.id,
|
|
9227
9217
|
triggerEventId: null,
|
|
9228
9218
|
status: "skipped",
|
|
9229
|
-
error
|
|
9219
|
+
error
|
|
9230
9220
|
});
|
|
9231
9221
|
return;
|
|
9232
9222
|
}
|
|
@@ -9238,19 +9228,37 @@ async function recoverBoundScheduledTaskDispatch(input) {
|
|
|
9238
9228
|
status: "dispatched"
|
|
9239
9229
|
});
|
|
9240
9230
|
},
|
|
9241
|
-
|
|
9242
|
-
|
|
9243
|
-
|
|
9244
|
-
|
|
9245
|
-
|
|
9246
|
-
|
|
9247
|
-
|
|
9248
|
-
|
|
9249
|
-
|
|
9250
|
-
|
|
9251
|
-
|
|
9231
|
+
{
|
|
9232
|
+
requireIdleSession: task.overlapPolicy === "skip" && !generatedSession,
|
|
9233
|
+
prepareSource: async (tx, sessionId) => {
|
|
9234
|
+
const goal = task.agentConfig.goal;
|
|
9235
|
+
const goalEvents = !generatedSession && task.runMode === "reusable_session" && goal ? await upsertScheduledSessionGoalForRun(tx, {
|
|
9236
|
+
accountId: task.accountId,
|
|
9237
|
+
workspaceId: task.workspaceId,
|
|
9238
|
+
sessionId,
|
|
9239
|
+
runId: input.run.id,
|
|
9240
|
+
text: goal.text,
|
|
9241
|
+
successCriteria: goal.successCriteria ?? null,
|
|
9242
|
+
maxAutoContinuations: goal.maxAutoContinuations ?? null,
|
|
9243
|
+
...goal.mutationPolicy ? { mutationPolicy: goal.mutationPolicy } : {}
|
|
9244
|
+
}) : [];
|
|
9245
|
+
const incidentSource = input.acceptedExecution.incidentPreflightRequired ? await prepareIncidentTelemetrySource({
|
|
9246
|
+
tx,
|
|
9247
|
+
settings: input.settings,
|
|
9248
|
+
taskId: task.id,
|
|
9249
|
+
workspaceId: task.workspaceId,
|
|
9250
|
+
sessionId,
|
|
9251
|
+
alertOccurrenceLabels: input.acceptedExecution.alertOccurrenceLabels,
|
|
9252
|
+
acceptedExecution: input.acceptedExecution
|
|
9253
|
+
}) : void 0;
|
|
9254
|
+
return {
|
|
9255
|
+
...incidentSource ?? {},
|
|
9256
|
+
...goalEvents.length > 0 ? { events: goalEvents } : {}
|
|
9257
|
+
};
|
|
9258
|
+
}
|
|
9259
|
+
}
|
|
9252
9260
|
);
|
|
9253
|
-
if (scheduledUpdate.reason === "session_cancelled") {
|
|
9261
|
+
if (scheduledUpdate.reason === "session_cancelled" || scheduledUpdate.reason === "session_not_idle") {
|
|
9254
9262
|
return { action: "blocked", reason: "scheduled_run_terminal" };
|
|
9255
9263
|
}
|
|
9256
9264
|
if (scheduledUpdate.added && scheduledUpdate.events.length > 0) {
|
|
@@ -10046,4 +10054,4 @@ export {
|
|
|
10046
10054
|
createControlActivities,
|
|
10047
10055
|
createControlActivitiesFromServices
|
|
10048
10056
|
};
|
|
10049
|
-
//# sourceMappingURL=activities-control-
|
|
10057
|
+
//# sourceMappingURL=activities-control-ZWH7J4KZ.js.map
|