@opengeni/worker-bundle 0.22.1-canary.0 → 0.22.4-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/activities/agent-turn/agent-build.d.ts +1 -0
- package/dist/activities/agent-turn/sandbox-establish.d.ts +1 -0
- package/dist/activities/agent-turn/session-title.d.ts +24 -0
- package/dist/activities/agent-turn/tool-environment.d.ts +1 -0
- package/dist/activities/agent-turn/tool-policy.d.ts +2 -1
- package/dist/activities/incident-telemetry-authority.d.ts +1 -0
- package/dist/activities/parent-wake.d.ts +25 -2
- package/dist/activities/rig-verification.d.ts +22 -7
- package/dist/activities/scheduled-tasks.d.ts +49 -3
- package/dist/{activities-control-DKG22ONJ.js → activities-control-4XVBA3Q5.js} +168 -70
- package/dist/activities-control-4XVBA3Q5.js.map +1 -0
- package/dist/activities-control.d.ts +16 -12
- package/dist/{activities-turn-4IMC3MAA.js → activities-turn-J3CR27E6.js} +164 -44
- package/dist/activities-turn-J3CR27E6.js.map +1 -0
- package/dist/activities.d.ts +16 -12
- package/dist/{chunk-CE7TPKBS.js → chunk-FA35XBBC.js} +3 -3
- package/dist/{chunk-CE7TPKBS.js.map → chunk-FA35XBBC.js.map} +1 -1
- package/dist/{chunk-CNYGVRKF.js → chunk-XWQPS6GG.js} +76 -17
- package/dist/chunk-XWQPS6GG.js.map +1 -0
- package/dist/http.d.ts +1 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/package.json +17 -17
- package/src/activities/agent-turn/agent-build.ts +8 -6
- package/src/activities/agent-turn/governance-model.ts +13 -15
- package/src/activities/agent-turn/run.ts +3 -0
- package/src/activities/agent-turn/sandbox-establish.ts +6 -1
- package/src/activities/agent-turn/session-title.ts +106 -0
- package/src/activities/agent-turn/tool-environment.ts +68 -19
- package/src/activities/agent-turn/tool-policy.ts +5 -2
- package/src/activities/incident-telemetry-authority.ts +7 -0
- package/src/activities/parent-wake.ts +65 -1
- package/src/activities/rig-verification.ts +156 -47
- package/src/activities/scheduled-tasks.ts +38 -35
- package/src/activities/workflow-wake.ts +30 -9
- package/src/http.ts +2 -1
- package/src/index.ts +6 -1
- package/src/observability-metrics.ts +2 -2
- package/src/pr-review-credentials.ts +42 -14
- package/dist/activities-control-DKG22ONJ.js.map +0 -1
- package/dist/activities-turn-4IMC3MAA.js.map +0 -1
- package/dist/chunk-CNYGVRKF.js.map +0 -1
|
@@ -72,6 +72,7 @@ export type BuildTurnAgentDeps = {
|
|
|
72
72
|
executionGeneration: number;
|
|
73
73
|
initiator: Pick<ClaimTurnOk["turn"]["initiator"], "kind" | "subjectId">;
|
|
74
74
|
};
|
|
75
|
+
preparationIndependentToolNames: readonly string[];
|
|
75
76
|
videoGenerationAcceptancesByCallId: Map<string, {
|
|
76
77
|
operationId: string;
|
|
77
78
|
requestDigest: string;
|
|
@@ -25,6 +25,7 @@ export type SandboxRouteDeps = {
|
|
|
25
25
|
media: ReturnType<typeof createTurnMediaArtifacts>;
|
|
26
26
|
fileAuthoritySubjectId: ClaimTurnOk["fileAuthoritySubjectId"];
|
|
27
27
|
runSettings: GovernanceModelOk["runSettings"];
|
|
28
|
+
logicalSandboxSettings: GovernanceModelOk["logicalSandboxSettings"];
|
|
28
29
|
};
|
|
29
30
|
export type SandboxRouteOk = {
|
|
30
31
|
routingOn: boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AttemptToolDefinition } from "@opengeni/codemode";
|
|
2
|
+
import { type FirstPartyMcpToolName, type Permission, type ToolRef } from "@opengeni/contracts";
|
|
3
|
+
export declare const SESSION_TITLE_MODEL_TOOL_NAME = "opengeni__set_session_title";
|
|
4
|
+
export declare function shouldRequestMissingSessionTitle(input: {
|
|
5
|
+
title: string | null;
|
|
6
|
+
titleSource: "user" | "agent" | null;
|
|
7
|
+
firstPartyMcpTools: readonly FirstPartyMcpToolName[];
|
|
8
|
+
firstPartyMcpPermissions: readonly Permission[] | null;
|
|
9
|
+
}): boolean;
|
|
10
|
+
export declare function sessionTitleToolPlan(input: {
|
|
11
|
+
tools: readonly ToolRef[];
|
|
12
|
+
selectedFirstPartyMcpTools: readonly FirstPartyMcpToolName[];
|
|
13
|
+
shouldRequestTitle: boolean;
|
|
14
|
+
}): {
|
|
15
|
+
promoteTitleTool: boolean;
|
|
16
|
+
remoteFirstPartyMcpTools: FirstPartyMcpToolName[];
|
|
17
|
+
preparationIndependentToolNames: string[];
|
|
18
|
+
};
|
|
19
|
+
export declare function createSessionTitleAttemptToolDefinition(input: {
|
|
20
|
+
updateTitle: (title: string) => Promise<{
|
|
21
|
+
updated: boolean;
|
|
22
|
+
title: string | null;
|
|
23
|
+
}>;
|
|
24
|
+
}): AttemptToolDefinition;
|
|
@@ -137,6 +137,7 @@ export declare function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps)
|
|
|
137
137
|
};
|
|
138
138
|
};
|
|
139
139
|
postToolPreparationStartedAt: number;
|
|
140
|
+
preparationIndependentToolNames: string[];
|
|
140
141
|
}>;
|
|
141
142
|
export type PrepareTurnToolPolicyOk = Awaited<ReturnType<typeof prepareTurnToolPolicy>>;
|
|
142
143
|
export type PrepareTurnToolRuntimeOk = Awaited<ReturnType<typeof prepareTurnToolRuntime>>;
|
|
@@ -32,10 +32,11 @@ export declare function computerToolModeForTurn(resolvedModel: {
|
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
34
|
} | null): ComputerToolMode;
|
|
35
|
-
/** Gateway models do not advertise OpenAI's hosted
|
|
35
|
+
/** Chat wires and Gateway models do not advertise OpenAI's hosted sandbox tool types. */
|
|
36
36
|
export declare function structuredToolTransportForTurn(resolvedModel: {
|
|
37
37
|
provider: {
|
|
38
38
|
kind: RegistryProviderKind;
|
|
39
|
+
api: ModelProviderApi;
|
|
39
40
|
};
|
|
40
41
|
} | null): boolean;
|
|
41
42
|
/**
|
|
@@ -14,6 +14,7 @@ export declare function resolveIncidentTelemetryResponderMetadata(input: {
|
|
|
14
14
|
tools: ScheduledTaskRunAcceptedExecution["resolvedTools"];
|
|
15
15
|
firstPartyMcpTools: ScheduledTaskRunAcceptedExecution["resolvedFirstPartyMcpTools"];
|
|
16
16
|
firstPartyMcpPermissions: ScheduledTaskRunAcceptedExecution["resolvedFirstPartyMcpPermissions"] | null;
|
|
17
|
+
variableSetIds?: readonly string[];
|
|
17
18
|
variableSetId: string | null;
|
|
18
19
|
rigId: string | null;
|
|
19
20
|
rigVersionId: string | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Settings } from "@opengeni/config";
|
|
2
2
|
import type { Session, SessionGoal } from "@opengeni/contracts";
|
|
3
|
-
import { claimPendingSessionSystemUpdateOutbox, claimPendingSessionWorkflowWakes, type Database } from "@opengeni/db";
|
|
4
|
-
import type
|
|
3
|
+
import { claimPendingSessionSystemUpdateOutbox, claimPendingSessionWorkflowWakes, claimAutomaticSessionTitleFanout, markAutomaticSessionTitleFanoutDelivered, markAutomaticSessionTitleFanoutFailed, type Database } from "@opengeni/db";
|
|
4
|
+
import { type EventBus } from "@opengeni/events";
|
|
5
5
|
import type { ActivityServices, WakeSessionWorkflowSignal } from "./types.js";
|
|
6
6
|
export type NotifyServices = {
|
|
7
7
|
db: Database;
|
|
@@ -16,6 +16,11 @@ export type ReconcileParentSystemUpdateOverrides = Partial<{
|
|
|
16
16
|
export type ReconcileSessionWorkflowWakeOverrides = Partial<{
|
|
17
17
|
claimPendingSessionWorkflowWakes: typeof claimPendingSessionWorkflowWakes;
|
|
18
18
|
}>;
|
|
19
|
+
export type ReconcileAutomaticSessionTitleFanoutOverrides = Partial<{
|
|
20
|
+
claimAutomaticSessionTitleFanout: typeof claimAutomaticSessionTitleFanout;
|
|
21
|
+
markAutomaticSessionTitleFanoutDelivered: typeof markAutomaticSessionTitleFanoutDelivered;
|
|
22
|
+
markAutomaticSessionTitleFanoutFailed: typeof markAutomaticSessionTitleFanoutFailed;
|
|
23
|
+
}>;
|
|
19
24
|
/**
|
|
20
25
|
* Enrich and deliver the durable idle-boundary row committed by
|
|
21
26
|
* settleSessionIdleWithParentOutbox. Idle has no single owning turn, so its
|
|
@@ -52,6 +57,24 @@ export declare function reconcilePendingParentSystemUpdates(svc: NotifyServices,
|
|
|
52
57
|
delivered: number;
|
|
53
58
|
failed: number;
|
|
54
59
|
}>;
|
|
60
|
+
/**
|
|
61
|
+
* Publish migration-created safe title events through the configured session
|
|
62
|
+
* event bus. The outbox is durable and deployment-global; a crash after publish
|
|
63
|
+
* but before acknowledgement can duplicate a notification, which is safe
|
|
64
|
+
* because SSE consumers sequence-fence and gap-fill from the durable log.
|
|
65
|
+
*
|
|
66
|
+
* Managed NATS exposes the stronger bounded flush acknowledgement through
|
|
67
|
+
* publishConfirmed. Embedding buses predate that optional capability, so their
|
|
68
|
+
* required publish promise remains the delivery acknowledgement: resolve only
|
|
69
|
+
* after accepting the batch, and reject a real transport failure so the durable
|
|
70
|
+
* row stays retryable. Every supported bus also provides the mandatory paired
|
|
71
|
+
* recovery capability used by API SSE streams after subscriber reconnect.
|
|
72
|
+
*/
|
|
73
|
+
export declare function reconcileAutomaticSessionTitleFanout(svc: NotifyServices, limit?: number, overrides?: ReconcileAutomaticSessionTitleFanoutOverrides): Promise<{
|
|
74
|
+
claimed: number;
|
|
75
|
+
delivered: number;
|
|
76
|
+
failed: number;
|
|
77
|
+
}>;
|
|
55
78
|
export declare function reconcilePendingSessionWorkflowWakes(svc: NotifyServices, limit?: number, overrides?: ReconcileSessionWorkflowWakeOverrides): Promise<{
|
|
56
79
|
claimed: number;
|
|
57
80
|
delivered: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RigProviderImage } from "@opengeni/contracts";
|
|
1
|
+
import type { RigCheck, RigProviderImage } from "@opengeni/contracts";
|
|
2
2
|
import { type RigProviderImageDefinition } from "@opengeni/core";
|
|
3
3
|
import { acquireLease, commitWarmingToWarm, failWarmingToCold, markWarmLeaseInstanceLost, recordWarmingSandboxCreated, releaseLeaseHolder, touchLeaseHolder, type Database } from "@opengeni/db";
|
|
4
4
|
import { createTurnToolCancellationController, establishSandboxSessionFromEnvelope, serializeEstablishedSandboxEnvelope, tagModalSandbox, type EstablishedSandboxSession, type TurnSandboxCommandArgs, type TurnSandboxCommandSession } from "@opengeni/runtime/sandbox";
|
|
@@ -15,6 +15,19 @@ export type RigVerificationWorkflowInput = {
|
|
|
15
15
|
versionId: string;
|
|
16
16
|
changeId?: never;
|
|
17
17
|
};
|
|
18
|
+
type CommandResult = {
|
|
19
|
+
exitCode: number | null;
|
|
20
|
+
output: string;
|
|
21
|
+
};
|
|
22
|
+
export type RigPlatformCheckResult = CommandResult & RigCheck;
|
|
23
|
+
/**
|
|
24
|
+
* Platform-owned checks run after Rig setup and independently of user-declared
|
|
25
|
+
* checks. They prove that a Rig layered on the deployment image did not remove
|
|
26
|
+
* or replace the Browser, Terminal, or Computer/Desktop services. The commands
|
|
27
|
+
* start each enabled service on its canonical loopback port, wait for its own
|
|
28
|
+
* readiness contract, probe it, and tear it down before provider snapshotting.
|
|
29
|
+
*/
|
|
30
|
+
export declare function rigPlatformChecksForSettings(settings: ControlActivityServices["settings"]): RigCheck[];
|
|
18
31
|
export declare const RIG_VERIFICATION_OWNER_TTL_MS: number;
|
|
19
32
|
export declare const RIG_VERIFICATION_OWNERS_DISABLED_MESSAGE = "Rig verification lease ownership is disabled; refusing to create an unowned verifier sandbox";
|
|
20
33
|
export declare class RigVerificationActivityDeadlineError extends Error {
|
|
@@ -151,6 +164,12 @@ export declare function createRigVerificationActivities(services: () => Promise<
|
|
|
151
164
|
startedAt?: string | undefined;
|
|
152
165
|
finishedAt?: string | undefined;
|
|
153
166
|
log?: string | undefined;
|
|
167
|
+
platformCheckResults?: {
|
|
168
|
+
name: string;
|
|
169
|
+
command: string;
|
|
170
|
+
exitCode: number | null;
|
|
171
|
+
output?: string | undefined;
|
|
172
|
+
}[] | undefined;
|
|
154
173
|
checkResults?: {
|
|
155
174
|
name: string;
|
|
156
175
|
command: string;
|
|
@@ -168,12 +187,8 @@ export declare function createRigVerificationActivities(services: () => Promise<
|
|
|
168
187
|
}) => Promise<{
|
|
169
188
|
versionId: string;
|
|
170
189
|
passed: boolean;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
output: string;
|
|
174
|
-
name: string;
|
|
175
|
-
command: string;
|
|
176
|
-
}[];
|
|
190
|
+
platformCheckResults: RigPlatformCheckResult[];
|
|
191
|
+
checkResults: RigPlatformCheckResult[];
|
|
177
192
|
providerImage: {
|
|
178
193
|
backend: "blaxel" | "cloudflare" | "daytona" | "docker" | "e2b" | "local" | "modal" | "none" | "opensandbox" | "runloop" | "selfhosted" | "vercel";
|
|
179
194
|
provider: string;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { updateSessionTitleWithEvent } from "@opengeni/db";
|
|
1
2
|
import type { ControlActivityServices, DispatchScheduledTaskRunInput, DispatchScheduledTaskRunResult } from "./types.js";
|
|
3
|
+
import type { Database } from "@opengeni/db";
|
|
2
4
|
type ScheduledTemporalActivityIdentity = {
|
|
3
5
|
namespace: string;
|
|
4
6
|
workflowExecution?: {
|
|
@@ -12,9 +14,8 @@ export declare function scheduledTaskRunProducerKey(input: DispatchScheduledTask
|
|
|
12
14
|
* Display title for a session the scheduler generates for a task.
|
|
13
15
|
*
|
|
14
16
|
* A scheduled session's `initialMessage` is the task prompt, byte-identical for
|
|
15
|
-
* every run
|
|
16
|
-
*
|
|
17
|
-
* short human-chosen label that actually identifies it, so that is the title.
|
|
17
|
+
* every run. The task name is the short human-chosen label that actually
|
|
18
|
+
* identifies it, so that is the title.
|
|
18
19
|
*
|
|
19
20
|
* The title is the task name and NOTHING else. It deliberately does not name the
|
|
20
21
|
* run's fire instant, for two independent reasons:
|
|
@@ -45,6 +46,51 @@ export declare function scheduledTaskRunProducerKey(input: DispatchScheduledTask
|
|
|
45
46
|
* texts differ.
|
|
46
47
|
*/
|
|
47
48
|
export declare function scheduledTaskSessionTitle(taskName: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Title a session the scheduler generated, and emit the same `session.title_set`
|
|
51
|
+
* event every other title write in the product emits.
|
|
52
|
+
*
|
|
53
|
+
* This uses the same database operation as `@opengeni/core`
|
|
54
|
+
* `updateSessionTitle`: the clobber/CAS guarded row update and its identical
|
|
55
|
+
* `session.title_set` append commit together under the session event lock. A
|
|
56
|
+
* newer writer therefore cannot land between the authoritative row change and
|
|
57
|
+
* an older event. Without the event a live subscriber sees nothing:
|
|
58
|
+
* `packages/react/src/hooks/use-session.ts` patches an open session's title
|
|
59
|
+
* exclusively on `session.title_set`, so a bare row write leaves the viewer on
|
|
60
|
+
* the stale title until an unrelated refetch.
|
|
61
|
+
*
|
|
62
|
+
* The core wrapper itself is not called, because its only additional behavior is
|
|
63
|
+
* `requireSessionAuthorization(grant, ...)` - a check on an HTTP/MCP caller's
|
|
64
|
+
* grant. The scheduler has no such grant; it is naming a session it just created
|
|
65
|
+
* itself moments earlier. Satisfying that gate would mean fabricating a subject,
|
|
66
|
+
* and the gate would then answer for it: a session later transitioned to
|
|
67
|
+
* `user_private` denies any actor whose subject is not the owner
|
|
68
|
+
* (`packages/core/src/session-authorization.ts`), which would turn naming a
|
|
69
|
+
* session into a way to fail a dispatch. Authorization belongs to callers with
|
|
70
|
+
* grants; the durable write and its event are the part that is shared.
|
|
71
|
+
*
|
|
72
|
+
* Only the neutral create fallback is replaced. A keyed create replay can hand
|
|
73
|
+
* back a session that has already run, and recovery re-enters this path for a
|
|
74
|
+
* session the dead dispatch may already have titled; in both cases whatever the
|
|
75
|
+
* agent or a human chose is newer truth than this stamp. The fallback check is
|
|
76
|
+
* part of the UPDATE itself, not a stale session-object precheck, so a title
|
|
77
|
+
* committed between dispatch read and stamp cannot be overwritten.
|
|
78
|
+
*
|
|
79
|
+
* `source: "agent"` is deliberate, and is the only system-assigned value the
|
|
80
|
+
* schema offers (`Session.titleSource` is "user" | "agent" | null). The database
|
|
81
|
+
* clobber guard pins only a `user` title, so this title still lets the agent
|
|
82
|
+
* rename its own session through set_session_title, and a human rename still
|
|
83
|
+
* wins permanently. Writing "user" here would quietly make every scheduled
|
|
84
|
+
* session unrenameable by the agent that runs in it.
|
|
85
|
+
*
|
|
86
|
+
* Returns the appended events so the caller can route them through the same
|
|
87
|
+
* defer-or-publish path as every other event this dispatch produces.
|
|
88
|
+
*/
|
|
89
|
+
export declare function stampScheduledSessionTitle(db: Database, input: {
|
|
90
|
+
workspaceId: string;
|
|
91
|
+
sessionId: string;
|
|
92
|
+
taskName: string;
|
|
93
|
+
}): Promise<Awaited<ReturnType<typeof updateSessionTitleWithEvent>>["events"]>;
|
|
48
94
|
export declare function createScheduledTaskActivities(services: () => Promise<ControlActivityServices>): {
|
|
49
95
|
dispatchScheduledTaskRun: (input: DispatchScheduledTaskRunInput) => Promise<DispatchScheduledTaskRunResult>;
|
|
50
96
|
};
|
|
@@ -23,17 +23,16 @@ import {
|
|
|
23
23
|
notifyParentOfChildIdle,
|
|
24
24
|
providerRecoveryCountFromMetadata,
|
|
25
25
|
putVersion1TarArchiveOrInline,
|
|
26
|
+
reconcileAutomaticSessionTitleFanout,
|
|
26
27
|
reconcilePendingParentSystemUpdates,
|
|
27
28
|
reconcilePendingSessionWorkflowWakes,
|
|
28
29
|
resolveIncidentTelemetryResponderMetadata,
|
|
29
30
|
resolveWorkspacePackRuntime,
|
|
30
31
|
rigProviderImageSourceImage,
|
|
31
32
|
scheduledUserMessagePayload,
|
|
32
|
-
settingsWithPackSandboxImage,
|
|
33
|
-
settingsWithRigImage,
|
|
34
33
|
withFirstPartyTools,
|
|
35
34
|
workflowIdForSession
|
|
36
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-XWQPS6GG.js";
|
|
37
36
|
import {
|
|
38
37
|
inspectOpenSandboxKubernetesInventory,
|
|
39
38
|
recordCreditBalanceGauges,
|
|
@@ -52,7 +51,7 @@ import {
|
|
|
52
51
|
recordSandboxRotationBacklogGauges,
|
|
53
52
|
recordTurnsQueuedGauge,
|
|
54
53
|
runtimeMetricsHooksForObservability
|
|
55
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-FA35XBBC.js";
|
|
56
55
|
|
|
57
56
|
// src/activities/browser-state-artifact-reaper.ts
|
|
58
57
|
import {
|
|
@@ -3868,6 +3867,67 @@ async function runRigSetupHook(...args) {
|
|
|
3868
3867
|
const hook = await rigSetupHookPromise;
|
|
3869
3868
|
await hook(...args);
|
|
3870
3869
|
}
|
|
3870
|
+
function rigPlatformChecksForSettings(settings) {
|
|
3871
|
+
const backend = settings.sandboxBackend;
|
|
3872
|
+
if (!rigProviderImageSourceImage(settings, backend)) return [];
|
|
3873
|
+
const checks = [
|
|
3874
|
+
{
|
|
3875
|
+
name: "opengeni-platform-browser",
|
|
3876
|
+
command: [
|
|
3877
|
+
"set -eu",
|
|
3878
|
+
"test -x /usr/local/bin/opengeni-browserd",
|
|
3879
|
+
"test -x /usr/local/bin/opengeni-browserd-up",
|
|
3880
|
+
"test -x /usr/local/bin/opengeni-browserd-down",
|
|
3881
|
+
"test -r /etc/opengeni/browser-engine",
|
|
3882
|
+
'__og_browser_engine="$(head -n 1 /etc/opengeni/browser-engine)"',
|
|
3883
|
+
'test -n "$__og_browser_engine"',
|
|
3884
|
+
'test -x "$__og_browser_engine"',
|
|
3885
|
+
'__og_browser_token="$(mktemp)"',
|
|
3886
|
+
`trap 'opengeni-browserd-down >/dev/null 2>&1 || true; rm -f "$__og_browser_token"' EXIT`,
|
|
3887
|
+
`printf '%s\\n' 'rig-platform-check' > "$__og_browser_token"`,
|
|
3888
|
+
'chmod 0600 "$__og_browser_token"',
|
|
3889
|
+
'OPENGENI_BROWSERD_ADMIN_TOKEN_FILE="$__og_browser_token" OPENGENI_BROWSERD_PORT=7682 OPENGENI_BROWSERD_ALLOWED_ORIGINS= opengeni-browserd-up',
|
|
3890
|
+
"curl --noproxy '*' -fsS http://127.0.0.1:7682/healthz >/dev/null",
|
|
3891
|
+
"curl --noproxy '*' -fsS -H 'Authorization: Bearer rig-platform-check' http://127.0.0.1:7682/v1/browser-sessions >/dev/null"
|
|
3892
|
+
].join("\n")
|
|
3893
|
+
}
|
|
3894
|
+
];
|
|
3895
|
+
if (settings.sandboxTerminalEnabled) {
|
|
3896
|
+
checks.push({
|
|
3897
|
+
name: "opengeni-platform-terminal",
|
|
3898
|
+
command: [
|
|
3899
|
+
"set -eu",
|
|
3900
|
+
"test -x /usr/local/bin/opengeni-terminal-up",
|
|
3901
|
+
"test -x /usr/local/bin/opengeni-terminal-down",
|
|
3902
|
+
"command -v ttyd >/dev/null",
|
|
3903
|
+
"trap 'opengeni-terminal-down >/dev/null 2>&1 || true' EXIT",
|
|
3904
|
+
"TERMINAL_PORT=7681 opengeni-terminal-up",
|
|
3905
|
+
"curl --noproxy '*' -fsS http://127.0.0.1:7681/ >/dev/null"
|
|
3906
|
+
].join("\n")
|
|
3907
|
+
});
|
|
3908
|
+
}
|
|
3909
|
+
if (settings.sandboxDesktopEnabled) {
|
|
3910
|
+
checks.push({
|
|
3911
|
+
name: "opengeni-platform-computer-desktop",
|
|
3912
|
+
command: [
|
|
3913
|
+
"set -eu",
|
|
3914
|
+
"test -x /usr/local/bin/opengeni-desktop-up",
|
|
3915
|
+
"test -x /usr/local/bin/opengeni-desktop-down",
|
|
3916
|
+
"command -v Xvfb >/dev/null",
|
|
3917
|
+
"command -v x11vnc >/dev/null",
|
|
3918
|
+
"command -v websockify >/dev/null",
|
|
3919
|
+
"command -v scrot >/dev/null",
|
|
3920
|
+
"command -v xdotool >/dev/null",
|
|
3921
|
+
'__og_desktop_home="$(mktemp -d)"',
|
|
3922
|
+
`trap 'opengeni-desktop-down >/dev/null 2>&1 || true; rm -rf "$__og_desktop_home"' EXIT`,
|
|
3923
|
+
'HOME="$__og_desktop_home" STREAM_PORT=6080 DESKTOP_W=1280 DESKTOP_H=800 opengeni-desktop-up',
|
|
3924
|
+
"curl --noproxy '*' -fsS http://127.0.0.1:6080/vnc.html >/dev/null",
|
|
3925
|
+
"nc -z 127.0.0.1 5900"
|
|
3926
|
+
].join("\n")
|
|
3927
|
+
});
|
|
3928
|
+
}
|
|
3929
|
+
return checks;
|
|
3930
|
+
}
|
|
3871
3931
|
var RIG_VERIFICATION_CLEANUP_RESERVE_MAX_MS = 2 * 6e4;
|
|
3872
3932
|
var RIG_VERIFICATION_CLEANUP_OPERATION_MAX_MS = 6e4;
|
|
3873
3933
|
var RIG_VERIFICATION_HEARTBEAT_MAX_INTERVAL_MS = 1e4;
|
|
@@ -4346,6 +4406,17 @@ async function runCommand(session, command, timeoutMs, commandRunner) {
|
|
|
4346
4406
|
output: sandboxCommandOutput(result)
|
|
4347
4407
|
};
|
|
4348
4408
|
}
|
|
4409
|
+
async function runRigChecks(session, checks, timeoutMs, commandRunner) {
|
|
4410
|
+
const results = [];
|
|
4411
|
+
for (const check of checks) {
|
|
4412
|
+
results.push({
|
|
4413
|
+
name: check.name,
|
|
4414
|
+
command: check.command,
|
|
4415
|
+
...await runCommand(session, check.command, timeoutMs, commandRunner)
|
|
4416
|
+
});
|
|
4417
|
+
}
|
|
4418
|
+
return results;
|
|
4419
|
+
}
|
|
4349
4420
|
function setupAppendCommand(change) {
|
|
4350
4421
|
if (change.kind !== "setup_append") {
|
|
4351
4422
|
return null;
|
|
@@ -4355,12 +4426,12 @@ function setupAppendCommand(change) {
|
|
|
4355
4426
|
}
|
|
4356
4427
|
function candidateVersionForChange(baseVersion, change) {
|
|
4357
4428
|
if (change.kind !== "definition_edit") {
|
|
4358
|
-
return { ...baseVersion, providerImages: {} };
|
|
4429
|
+
return { ...baseVersion, image: null, providerImages: {} };
|
|
4359
4430
|
}
|
|
4360
4431
|
const payload = change.payload;
|
|
4361
4432
|
return {
|
|
4362
4433
|
...baseVersion,
|
|
4363
|
-
image:
|
|
4434
|
+
image: null,
|
|
4364
4435
|
setupScript: payload.setupScript === void 0 ? baseVersion.setupScript : payload.setupScript,
|
|
4365
4436
|
checks: Array.isArray(payload.checks) ? payload.checks : baseVersion.checks,
|
|
4366
4437
|
credentialHooks: Array.isArray(payload.credentialHooks) ? payload.credentialHooks : baseVersion.credentialHooks,
|
|
@@ -4373,7 +4444,6 @@ function providerImageDefinitionForChange(baseVersion, change, candidateVersion)
|
|
|
4373
4444
|
if (change.kind !== "setup_append") return candidateVersion;
|
|
4374
4445
|
const command = setupAppendCommand(change);
|
|
4375
4446
|
return {
|
|
4376
|
-
image: baseVersion.image,
|
|
4377
4447
|
setupScript: command ? appendRigSetupCommand(baseVersion.setupScript, command) : baseVersion.setupScript,
|
|
4378
4448
|
checks: baseVersion.checks,
|
|
4379
4449
|
credentialHooks: baseVersion.credentialHooks,
|
|
@@ -4429,6 +4499,19 @@ async function verifyRigProviderImageColdBoot(input, dependencies = defaultRigPr
|
|
|
4429
4499
|
if (markerResult.exitCode !== 0) {
|
|
4430
4500
|
throw new Error("built provider image is missing its exact rig-content marker");
|
|
4431
4501
|
}
|
|
4502
|
+
for (const check of rigPlatformChecksForSettings(input.settings)) {
|
|
4503
|
+
const result = await runCommand(
|
|
4504
|
+
established.session,
|
|
4505
|
+
check.command,
|
|
4506
|
+
input.settings.rigSetupTimeoutMs,
|
|
4507
|
+
runContext.commandRunner
|
|
4508
|
+
);
|
|
4509
|
+
if (result.exitCode !== 0) {
|
|
4510
|
+
throw new Error(
|
|
4511
|
+
`built provider image failed mandatory platform check ${JSON.stringify(check.name)}: ${result.output.slice(-2e3)}`
|
|
4512
|
+
);
|
|
4513
|
+
}
|
|
4514
|
+
}
|
|
4432
4515
|
for (const check of input.checks) {
|
|
4433
4516
|
const result = await runCommand(
|
|
4434
4517
|
established.session,
|
|
@@ -4674,14 +4757,9 @@ async function buildVerifiedRigProviderImage(input) {
|
|
|
4674
4757
|
}
|
|
4675
4758
|
}
|
|
4676
4759
|
function settingsForRigVerification(settings, packRuntime, rigImage) {
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
packRuntime.sandboxImage,
|
|
4681
|
-
packRuntime.sandboxProviderImages
|
|
4682
|
-
),
|
|
4683
|
-
rigImage
|
|
4684
|
-
);
|
|
4760
|
+
void packRuntime;
|
|
4761
|
+
void rigImage;
|
|
4762
|
+
return settings;
|
|
4685
4763
|
}
|
|
4686
4764
|
async function loadChangeTarget(db, workspaceId, changeId) {
|
|
4687
4765
|
const change = await getRigChange(db, workspaceId, changeId);
|
|
@@ -4833,22 +4911,21 @@ function createRigVerificationActivities(services) {
|
|
|
4833
4911
|
`Failed to seal rig provider image content marker: ${markerResult.output.slice(-2e3)}`
|
|
4834
4912
|
);
|
|
4835
4913
|
}
|
|
4836
|
-
const
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
}
|
|
4914
|
+
const platformCheckResults = await runRigChecks(
|
|
4915
|
+
established.session,
|
|
4916
|
+
rigPlatformChecksForSettings(runSettings),
|
|
4917
|
+
settings.rigSetupTimeoutMs,
|
|
4918
|
+
runContext.commandRunner
|
|
4919
|
+
);
|
|
4920
|
+
verification.platformCheckResults = platformCheckResults;
|
|
4921
|
+
const checkResults = await runRigChecks(
|
|
4922
|
+
established.session,
|
|
4923
|
+
candidateVersion.checks,
|
|
4924
|
+
settings.rigSetupTimeoutMs,
|
|
4925
|
+
runContext.commandRunner
|
|
4926
|
+
);
|
|
4850
4927
|
verification.checkResults = checkResults;
|
|
4851
|
-
const passed = checkResults.every((result) => result.exitCode === 0);
|
|
4928
|
+
const passed = platformCheckResults.every((result) => result.exitCode === 0) && checkResults.every((result) => result.exitCode === 0);
|
|
4852
4929
|
if (passed) {
|
|
4853
4930
|
verification.providerImage = await buildVerifiedRigProviderImage({
|
|
4854
4931
|
settings: runSettings,
|
|
@@ -4988,20 +5065,19 @@ function createRigVerificationActivities(services) {
|
|
|
4988
5065
|
`Failed to seal rig provider image content marker: ${markerResult.output.slice(-2e3)}`
|
|
4989
5066
|
);
|
|
4990
5067
|
}
|
|
4991
|
-
const
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
const passed = checkResults.every((result) => result.exitCode === 0);
|
|
5068
|
+
const platformCheckResults = await runRigChecks(
|
|
5069
|
+
established.session,
|
|
5070
|
+
rigPlatformChecksForSettings(runSettings),
|
|
5071
|
+
settings.rigSetupTimeoutMs,
|
|
5072
|
+
runContext.commandRunner
|
|
5073
|
+
);
|
|
5074
|
+
const checkResults = await runRigChecks(
|
|
5075
|
+
established.session,
|
|
5076
|
+
version.checks,
|
|
5077
|
+
settings.rigSetupTimeoutMs,
|
|
5078
|
+
runContext.commandRunner
|
|
5079
|
+
);
|
|
5080
|
+
const passed = platformCheckResults.every((result) => result.exitCode === 0) && checkResults.every((result) => result.exitCode === 0);
|
|
5005
5081
|
const providerImage = passed ? await buildVerifiedRigProviderImage({
|
|
5006
5082
|
settings: runSettings,
|
|
5007
5083
|
db,
|
|
@@ -5025,11 +5101,18 @@ function createRigVerificationActivities(services) {
|
|
|
5025
5101
|
startedAt,
|
|
5026
5102
|
finishedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5027
5103
|
passed,
|
|
5104
|
+
platformCheckResults,
|
|
5028
5105
|
checkResults,
|
|
5029
5106
|
providerImage
|
|
5030
5107
|
}
|
|
5031
5108
|
});
|
|
5032
|
-
return {
|
|
5109
|
+
return {
|
|
5110
|
+
versionId: version.id,
|
|
5111
|
+
passed,
|
|
5112
|
+
platformCheckResults,
|
|
5113
|
+
checkResults,
|
|
5114
|
+
providerImage
|
|
5115
|
+
};
|
|
5033
5116
|
}
|
|
5034
5117
|
);
|
|
5035
5118
|
} catch (error) {
|
|
@@ -7112,6 +7195,7 @@ async function terminateProviderBox(settings, lease, observability, persistArchi
|
|
|
7112
7195
|
|
|
7113
7196
|
// src/activities/scheduled-tasks.ts
|
|
7114
7197
|
import {
|
|
7198
|
+
AUTOMATIC_SESSION_TITLE_FALLBACK,
|
|
7115
7199
|
DEFAULT_FIRST_PARTY_MCP_PERMISSIONS,
|
|
7116
7200
|
OPENGENI_SLACK_BOT_CREDENTIAL_LABEL,
|
|
7117
7201
|
OPENGENI_SLACK_BOT_CREDENTIAL_ROLE,
|
|
@@ -7119,6 +7203,7 @@ import {
|
|
|
7119
7203
|
resolveWorkspaceCodexCompactionDefault,
|
|
7120
7204
|
SCHEDULED_TASK_OCCURRENCE_PAYLOAD_MAX_BYTES,
|
|
7121
7205
|
ScheduledTaskRunAcceptedExecution,
|
|
7206
|
+
normalizeAutomaticSessionTitle,
|
|
7122
7207
|
scheduledOccurrencePayloadUtf8Bytes,
|
|
7123
7208
|
stableJson
|
|
7124
7209
|
} from "@opengeni/contracts";
|
|
@@ -7130,7 +7215,6 @@ import {
|
|
|
7130
7215
|
scheduledSlackBotConnectionId
|
|
7131
7216
|
} from "@opengeni/core";
|
|
7132
7217
|
import {
|
|
7133
|
-
appendSessionEvents,
|
|
7134
7218
|
addSessionSystemUpdateWithSourceMutation,
|
|
7135
7219
|
bindScheduledTaskRunSessionInTransaction,
|
|
7136
7220
|
createScheduledTaskRun,
|
|
@@ -7166,7 +7250,7 @@ import {
|
|
|
7166
7250
|
settleScheduledTaskRunInTransaction,
|
|
7167
7251
|
SessionSpawnDeniedDbError,
|
|
7168
7252
|
updateScheduledTaskRun as updateScheduledTaskRun2,
|
|
7169
|
-
|
|
7253
|
+
updateSessionTitleWithEvent,
|
|
7170
7254
|
upsertScheduledSessionGoalForRun,
|
|
7171
7255
|
withSessionActivityRlsContext
|
|
7172
7256
|
} from "@opengeni/db";
|
|
@@ -7308,25 +7392,22 @@ function scheduledTaskRunProducerKey(input, suppliedActivityIdentity) {
|
|
|
7308
7392
|
workflowId: info.workflowExecution.workflowId
|
|
7309
7393
|
})}`;
|
|
7310
7394
|
}
|
|
7311
|
-
var SCHEDULED_SESSION_TITLE_MAX_LENGTH = 200;
|
|
7312
7395
|
function scheduledTaskSessionTitle(taskName) {
|
|
7313
|
-
|
|
7314
|
-
if (name.length <= SCHEDULED_SESSION_TITLE_MAX_LENGTH) return name;
|
|
7315
|
-
return `${name.slice(0, SCHEDULED_SESSION_TITLE_MAX_LENGTH - 1).trimEnd()}\u2026`;
|
|
7396
|
+
return normalizeAutomaticSessionTitle(taskName) ?? "Scheduled run";
|
|
7316
7397
|
}
|
|
7317
7398
|
async function stampScheduledSessionTitle(db, input) {
|
|
7318
|
-
if (input.session.title !== null) return [];
|
|
7319
7399
|
const title = scheduledTaskSessionTitle(input.taskName);
|
|
7320
|
-
const result = await
|
|
7400
|
+
const result = await updateSessionTitleWithEvent(db, {
|
|
7321
7401
|
workspaceId: input.workspaceId,
|
|
7322
|
-
sessionId: input.
|
|
7402
|
+
sessionId: input.sessionId,
|
|
7323
7403
|
title,
|
|
7324
|
-
source: "agent"
|
|
7404
|
+
source: "agent",
|
|
7405
|
+
expectedCurrent: {
|
|
7406
|
+
title: AUTOMATIC_SESSION_TITLE_FALLBACK,
|
|
7407
|
+
source: "agent"
|
|
7408
|
+
}
|
|
7325
7409
|
});
|
|
7326
|
-
|
|
7327
|
-
return await appendSessionEvents(db, input.workspaceId, input.session.id, [
|
|
7328
|
-
{ type: "session.title_set", payload: { title: result.title ?? title, source: "agent" } }
|
|
7329
|
-
]);
|
|
7410
|
+
return result.events;
|
|
7330
7411
|
}
|
|
7331
7412
|
function createScheduledTaskActivities(services) {
|
|
7332
7413
|
return {
|
|
@@ -7652,6 +7733,9 @@ function createScheduledTaskActivities(services) {
|
|
|
7652
7733
|
tools: targetSessionExecution.tools,
|
|
7653
7734
|
firstPartyMcpTools: targetSessionExecution.firstPartyMcpTools,
|
|
7654
7735
|
firstPartyMcpPermissions: targetSessionExecution.firstPartyMcpPermissions,
|
|
7736
|
+
variableSetIds: targetSessionExecution.variableSets.map(
|
|
7737
|
+
(variableSet) => variableSet.id
|
|
7738
|
+
),
|
|
7655
7739
|
variableSetId: targetSessionExecution.variableSetId,
|
|
7656
7740
|
rigId: targetSessionExecution.rigId,
|
|
7657
7741
|
rigVersionId: targetSessionExecution.rigVersionId,
|
|
@@ -8141,7 +8225,7 @@ function createScheduledTaskActivities(services) {
|
|
|
8141
8225
|
}
|
|
8142
8226
|
const titleEvents = await stampScheduledSessionTitle(dispatchDb, {
|
|
8143
8227
|
workspaceId: task.workspaceId,
|
|
8144
|
-
session,
|
|
8228
|
+
sessionId: session.id,
|
|
8145
8229
|
taskName: task.name
|
|
8146
8230
|
});
|
|
8147
8231
|
if (titleEvents.length > 0) {
|
|
@@ -8549,6 +8633,9 @@ async function prepareIncidentTelemetrySource(input) {
|
|
|
8549
8633
|
tools: input.acceptedExecution.targetSessionExecution.tools,
|
|
8550
8634
|
firstPartyMcpTools: input.acceptedExecution.targetSessionExecution.firstPartyMcpTools,
|
|
8551
8635
|
firstPartyMcpPermissions: input.acceptedExecution.targetSessionExecution.firstPartyMcpPermissions,
|
|
8636
|
+
variableSetIds: input.acceptedExecution.targetSessionExecution.variableSets.map(
|
|
8637
|
+
(variableSet) => variableSet.id
|
|
8638
|
+
),
|
|
8552
8639
|
variableSetId: input.acceptedExecution.targetSessionExecution.variableSetId,
|
|
8553
8640
|
rigId: input.acceptedExecution.targetSessionExecution.rigId,
|
|
8554
8641
|
rigVersionId: input.acceptedExecution.targetSessionExecution.rigVersionId,
|
|
@@ -8840,7 +8927,7 @@ async function recoverBoundScheduledTaskDispatch(input) {
|
|
|
8840
8927
|
}
|
|
8841
8928
|
const titleEvents = await stampScheduledSessionTitle(input.db, {
|
|
8842
8929
|
workspaceId: task.workspaceId,
|
|
8843
|
-
session,
|
|
8930
|
+
sessionId: session.id,
|
|
8844
8931
|
taskName: task.name
|
|
8845
8932
|
});
|
|
8846
8933
|
if (titleEvents.length > 0) {
|
|
@@ -9597,6 +9684,7 @@ async function refreshQueuedTurnsGauge(db, observability, countQueuedTurnsFn, re
|
|
|
9597
9684
|
// src/activities/workflow-wake.ts
|
|
9598
9685
|
var BATCH_SIZE = 1e3;
|
|
9599
9686
|
var MAX_DELIVERIES_PER_ACTIVITY = 1e4;
|
|
9687
|
+
var MAX_TITLE_FANOUT_PER_ACTIVITY = 1e3;
|
|
9600
9688
|
function createWorkflowWakeActivities(services) {
|
|
9601
9689
|
return {
|
|
9602
9690
|
async dispatchSessionWorkflowWakes() {
|
|
@@ -9604,22 +9692,32 @@ function createWorkflowWakeActivities(services) {
|
|
|
9604
9692
|
let claimed = 0;
|
|
9605
9693
|
let delivered = 0;
|
|
9606
9694
|
let failed = 0;
|
|
9695
|
+
let exhaustedBatchLimit = false;
|
|
9607
9696
|
for (; ; ) {
|
|
9608
9697
|
const remaining = MAX_DELIVERIES_PER_ACTIVITY - claimed;
|
|
9609
9698
|
if (remaining <= 0) {
|
|
9610
|
-
|
|
9699
|
+
exhaustedBatchLimit = true;
|
|
9700
|
+
break;
|
|
9611
9701
|
}
|
|
9612
|
-
const
|
|
9613
|
-
|
|
9614
|
-
Math.min(BATCH_SIZE, remaining)
|
|
9615
|
-
);
|
|
9702
|
+
const limit = Math.min(BATCH_SIZE, remaining);
|
|
9703
|
+
const batch = await reconcilePendingSessionWorkflowWakes(service, limit);
|
|
9616
9704
|
claimed += batch.claimed;
|
|
9617
9705
|
delivered += batch.delivered;
|
|
9618
9706
|
failed += batch.failed;
|
|
9619
|
-
if (batch.claimed <
|
|
9620
|
-
|
|
9621
|
-
|
|
9707
|
+
if (batch.claimed < limit) break;
|
|
9708
|
+
}
|
|
9709
|
+
const titleFanout = await reconcileAutomaticSessionTitleFanout(
|
|
9710
|
+
service,
|
|
9711
|
+
MAX_TITLE_FANOUT_PER_ACTIVITY
|
|
9712
|
+
);
|
|
9713
|
+
if (titleFanout.claimed > 0) {
|
|
9714
|
+
service.observability.info("automatic-title migration event fanout reconciled", {
|
|
9715
|
+
claimed: titleFanout.claimed,
|
|
9716
|
+
delivered: titleFanout.delivered,
|
|
9717
|
+
failed: titleFanout.failed
|
|
9718
|
+
});
|
|
9622
9719
|
}
|
|
9720
|
+
return { claimed, delivered, failed, exhaustedBatchLimit };
|
|
9623
9721
|
}
|
|
9624
9722
|
};
|
|
9625
9723
|
}
|
|
@@ -9662,4 +9760,4 @@ export {
|
|
|
9662
9760
|
createControlActivities,
|
|
9663
9761
|
createControlActivitiesFromServices
|
|
9664
9762
|
};
|
|
9665
|
-
//# sourceMappingURL=activities-control-
|
|
9763
|
+
//# sourceMappingURL=activities-control-4XVBA3Q5.js.map
|