@opengeni/worker-bundle 0.23.4 → 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 +17 -2
- package/dist/activities/agent-turn/claim.d.ts +1 -0
- package/dist/activities/agent-turn/codex.d.ts +2 -2
- package/dist/activities/agent-turn/list-models.d.ts +16 -0
- package/dist/activities/agent-turn/model-usage.d.ts +15 -1
- 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 +2 -0
- package/dist/activities/agent-turn/tool-policy.d.ts +36 -5
- package/dist/activities/agent-turn/turn-context.d.ts +4 -1
- package/dist/activities/agent-turn.d.ts +1 -1
- package/dist/activities/automations.d.ts +1 -0
- package/dist/activities/capabilities.d.ts +3 -1
- package/dist/activities/context-compaction.d.ts +2 -0
- package/dist/activities/goals.d.ts +11 -0
- package/dist/activities/image-generation-references.d.ts +2 -1
- package/dist/activities/scheduled-tasks.d.ts +1 -0
- package/dist/activities/types.d.ts +8 -0
- package/dist/{activities-control-52W5IDWM.js → activities-control-ZWH7J4KZ.js} +297 -180
- package/dist/activities-control-ZWH7J4KZ.js.map +1 -0
- package/dist/activities-control.d.ts +2 -0
- package/dist/{activities-turn-A2G2KLSY.js → activities-turn-I4OPLQLS.js} +898 -333
- package/dist/activities-turn-I4OPLQLS.js.map +1 -0
- package/dist/activities.d.ts +2 -0
- package/dist/{chunk-GFNXVZVQ.js → chunk-65JEWP2Q.js} +107 -7
- 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-IPVMCAW5.js → chunk-RQNH6CGR.js} +111 -62
- package/dist/chunk-RQNH6CGR.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +43 -7
- package/dist/index.js.map +1 -1
- package/dist/observability-metrics.d.ts +34 -7
- package/dist/sandbox-reaper-timeout.d.ts +2 -2
- package/dist/sandbox-resume.d.ts +6 -1
- package/dist/workflow-bundle.js +26 -3
- package/dist/workflows/activities.d.ts +5 -0
- package/dist/workflows/automations.d.ts +5 -0
- package/package.json +17 -17
- package/src/activities/agent-run-admission.ts +7 -1
- package/src/activities/agent-turn/admission.ts +47 -6
- package/src/activities/agent-turn/claim.ts +33 -5
- package/src/activities/agent-turn/codex.ts +2 -2
- package/src/activities/agent-turn/compaction-prep.ts +8 -1
- package/src/activities/agent-turn/finalization.ts +31 -17
- package/src/activities/agent-turn/list-models.ts +101 -0
- package/src/activities/agent-turn/model-usage.ts +120 -45
- package/src/activities/agent-turn/quiescence.ts +11 -2
- package/src/activities/agent-turn/run.ts +80 -4
- 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 +266 -135
- package/src/activities/agent-turn/tool-environment.ts +102 -7
- package/src/activities/agent-turn/tool-policy.ts +58 -5
- package/src/activities/agent-turn/turn-context.ts +8 -2
- package/src/activities/agent-turn.ts +5 -1
- package/src/activities/api-integrations.ts +11 -1
- package/src/activities/automations.ts +122 -67
- package/src/activities/capabilities.ts +129 -2
- package/src/activities/context-compaction.ts +3 -0
- package/src/activities/goals.ts +108 -31
- package/src/activities/image-generation-references.ts +9 -9
- package/src/activities/mcp-credentials.ts +53 -0
- package/src/activities/rig-verification.ts +5 -3
- package/src/activities/scheduled-tasks.ts +217 -110
- package/src/activities/site-auth-maintenance.ts +12 -12
- package/src/activities/types.ts +6 -0
- package/src/activities.ts +1 -0
- package/src/activity-services.ts +4 -1
- package/src/github-rest-mcp.ts +2 -1
- package/src/index.ts +34 -4
- package/src/observability-metrics.ts +154 -14
- package/src/sandbox-reaper-timeout.ts +10 -4
- package/src/sandbox-resume.ts +58 -8
- package/src/workflows/activities.ts +15 -0
- package/src/workflows/automations.ts +21 -2
- package/dist/activities-control-52W5IDWM.js.map +0 -1
- package/dist/activities-turn-A2G2KLSY.js.map +0 -1
- package/dist/chunk-GFNXVZVQ.js.map +0 -1
- package/dist/chunk-IPVMCAW5.js.map +0 -1
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { resolveTurnExecutionPolicyV1, type Settings } from "@opengeni/config";
|
|
2
2
|
import type { TurnActivityServices as ActivityServices } from "../types.js";
|
|
3
|
-
import { type SessionEvent, type SessionTurn, type ToolAuthNeededPayload, type TurnExecutionPolicyV1 } from "@opengeni/contracts";
|
|
3
|
+
import { type SessionEvent, type SessionTurn, type ToolAuthNeededPayload, type TurnExecutionPolicyV1, type XaiProviderAccountAuthoritySnapshotV1 } from "@opengeni/contracts";
|
|
4
4
|
export declare class WorkspaceHumanInputDisabledError extends Error {
|
|
5
5
|
constructor(kind: "resume" | "interruption");
|
|
6
6
|
}
|
|
7
7
|
export declare function assertWorkspaceHumanInputAllowed(enabled: boolean, kind: "resume" | "interruption", attempted: boolean): void;
|
|
8
8
|
/** Broad personal lookup is allowed only for a direct human/API command. */
|
|
9
9
|
export declare function credentialSubjectIdForTurnInitiator(turn: Pick<SessionTurn, "source" | "initiator" | "initiatorContext">): string | undefined;
|
|
10
|
+
export declare function xaiCatalogReadinessAuthority(turn: {
|
|
11
|
+
initiatingHumanSubjectId: string | null;
|
|
12
|
+
xaiProviderAccountAuthoritySnapshot: XaiProviderAccountAuthoritySnapshotV1;
|
|
13
|
+
}, directCredentialSubjectId: string | undefined): {
|
|
14
|
+
subjectId: string;
|
|
15
|
+
authoritySnapshot: XaiProviderAccountAuthoritySnapshotV1;
|
|
16
|
+
} | null;
|
|
10
17
|
/**
|
|
11
18
|
* Direct authenticated-human work is the persisted human source with subject
|
|
12
19
|
* authority and no inherited agent or legacy provenance. Use this complete
|
|
@@ -22,8 +29,16 @@ export declare function isDirectHumanTurnInitiation(turn: Pick<SessionTurn, "sou
|
|
|
22
29
|
* Slack explicitly. Other providers retain the existing generic behavior.
|
|
23
30
|
*/
|
|
24
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;
|
|
25
39
|
export declare function turnExecutionPolicyBillingIdentity(policy: TurnExecutionPolicyV1): {
|
|
26
40
|
externallyBilled: boolean;
|
|
41
|
+
countsTowardTokenCap: boolean;
|
|
27
42
|
codexSubscription: boolean;
|
|
28
43
|
xaiSubscription: boolean;
|
|
29
44
|
};
|
|
@@ -49,4 +64,4 @@ export declare class BudgetExhaustedError extends Error {
|
|
|
49
64
|
readonly serializedRunState: string | null;
|
|
50
65
|
constructor(message: string, serializedRunState: string | null);
|
|
51
66
|
}
|
|
52
|
-
export declare function ensureRunAllowed(settings: Settings, db: ActivityServices["db"], accountId: string, workspaceId: string, isExternallyBilledTurn: boolean, entitlements?: ActivityServices["entitlements"]): Promise<void>;
|
|
67
|
+
export declare function ensureRunAllowed(settings: Settings, db: ActivityServices["db"], accountId: string, workspaceId: string, isExternallyBilledTurn: boolean, entitlements?: ActivityServices["entitlements"], chargesOpenGeniCredits?: boolean, countsTowardTokenCap?: boolean): Promise<void>;
|
|
@@ -10,6 +10,7 @@ import type { AttemptIdentityState, BillingState, ClaimedResult, EventingState,
|
|
|
10
10
|
export type ClaimTurnDeps = {
|
|
11
11
|
input: RunAgentTurnInput;
|
|
12
12
|
settings: Settings;
|
|
13
|
+
catalogSourceSettings: Settings;
|
|
13
14
|
db: ActivityServices["db"];
|
|
14
15
|
bus: ActivityServices["bus"];
|
|
15
16
|
runtime: ActivityServices["runtime"];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type CodexAccountStatus } from "@opengeni/db";
|
|
2
|
-
import { type
|
|
2
|
+
import { type ResolvedModelProvider, type Settings } from "@opengeni/config";
|
|
3
3
|
import type { TurnActivityServices as ActivityServices } from "../types.js";
|
|
4
4
|
export declare function codexWorkspaceMetricKey(workspaceId: string): string;
|
|
5
5
|
/** Stable public request identity across partial resumes and activity retries. */
|
|
6
6
|
export declare function acceptsPromptCacheKeyForTurn(resolvedModel: {
|
|
7
7
|
provider: {
|
|
8
|
-
kind:
|
|
8
|
+
kind: ResolvedModelProvider["kind"];
|
|
9
9
|
builtin?: boolean;
|
|
10
10
|
};
|
|
11
11
|
} | null): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AttemptToolDefinition } from "@opengeni/codemode";
|
|
2
|
+
import type { WorkspaceModelSelection } from "@opengeni/core";
|
|
3
|
+
export declare const LIST_MODELS_TOOL_NAME = "list_models";
|
|
4
|
+
export declare const LIST_MODELS_TOOL_DESCRIPTION = "List the models this workspace can select right now, in picker order, with deployment-defined cost and optional guidance. This does not switch the current session model; use an ID with session_create or the human model picker.";
|
|
5
|
+
export declare function renderListModels(input: {
|
|
6
|
+
currentModelId: string | null;
|
|
7
|
+
selections: readonly WorkspaceModelSelection[];
|
|
8
|
+
modelNotes: Readonly<Record<string, string>>;
|
|
9
|
+
}): string;
|
|
10
|
+
export declare function createListModelsAttemptToolDefinition(input: {
|
|
11
|
+
currentModelId: string | null;
|
|
12
|
+
load: () => Promise<{
|
|
13
|
+
selections: readonly WorkspaceModelSelection[];
|
|
14
|
+
modelNotes: Readonly<Record<string, string>>;
|
|
15
|
+
}>;
|
|
16
|
+
}): AttemptToolDefinition;
|
|
@@ -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;
|
|
@@ -89,6 +90,8 @@ export declare function processModelResponseTerminalEvent(input: {
|
|
|
89
90
|
latencyMode?: LatencyMode;
|
|
90
91
|
metricProvider: string;
|
|
91
92
|
externallyBilled: boolean;
|
|
93
|
+
chargesOpenGeniCredits?: boolean;
|
|
94
|
+
countsTowardTokenCap?: boolean;
|
|
92
95
|
servingCredentialId: string | null;
|
|
93
96
|
priorSessionCredentialId: string | null;
|
|
94
97
|
emittedSourceKeys: Set<string>;
|
|
@@ -118,6 +121,7 @@ export declare function processModelResponseTerminalEvent(input: {
|
|
|
118
121
|
export declare function processCompactionModelUsageEvent(input: {
|
|
119
122
|
usage: ModelResponseUsage;
|
|
120
123
|
state: CompactionModelUsageEventState;
|
|
124
|
+
sourceKind?: "compaction" | "session-title";
|
|
121
125
|
dispatchId: string | null;
|
|
122
126
|
settings: Settings;
|
|
123
127
|
db: ActivityServices["db"];
|
|
@@ -132,6 +136,8 @@ export declare function processCompactionModelUsageEvent(input: {
|
|
|
132
136
|
providerApi: ModelProviderApi;
|
|
133
137
|
model: string;
|
|
134
138
|
externallyBilled: boolean;
|
|
139
|
+
chargesOpenGeniCredits?: boolean;
|
|
140
|
+
countsTowardTokenCap?: boolean;
|
|
135
141
|
servingCredentialId: string | null;
|
|
136
142
|
priorSessionCredentialId: string | null;
|
|
137
143
|
emittedSourceKeys: Set<string>;
|
|
@@ -147,6 +153,7 @@ export declare function processCompactionModelUsageEvent(input: {
|
|
|
147
153
|
sourceKey: string;
|
|
148
154
|
authoritative: boolean;
|
|
149
155
|
}>;
|
|
156
|
+
export declare function processSessionTitleModelUsageEvent(input: Omit<Parameters<typeof processCompactionModelUsageEvent>[0], "sourceKind">): ReturnType<typeof processCompactionModelUsageEvent>;
|
|
150
157
|
export declare function emitModelCallUsage(input: {
|
|
151
158
|
observability: ActivityServices["observability"];
|
|
152
159
|
publish: TurnEventPublisher | null;
|
|
@@ -162,6 +169,10 @@ export declare function emitModelCallUsage(input: {
|
|
|
162
169
|
usage?: unknown | null;
|
|
163
170
|
} | null;
|
|
164
171
|
normalizedUsage?: ModelCallUsageNormalization;
|
|
172
|
+
/** Accepted billing authority persisted for Insights repair after a soft fact-write failure. */
|
|
173
|
+
billingPath?: ModelUsageBillingRecord["billingPath"];
|
|
174
|
+
/** Validated Gateway endpoint provider persisted for exact Insights repair. */
|
|
175
|
+
upstreamProvider?: string;
|
|
165
176
|
servingAccountHash?: string;
|
|
166
177
|
accountChangedFromPrevCall?: boolean;
|
|
167
178
|
emittedSourceKeys?: Set<string>;
|
|
@@ -178,6 +189,8 @@ export type ModelUsageBillingRecord = {
|
|
|
178
189
|
pricedCostMicros: number;
|
|
179
190
|
/** Hypothetical provider-rate USD micros; never an OpenGeni charge. */
|
|
180
191
|
estimatedProviderCostMicros: number | null;
|
|
192
|
+
/** Hypothetical OpenGeni credit price at the captured rate; never a debit. */
|
|
193
|
+
equivalentCreditCostMicros: number | null;
|
|
181
194
|
pricingSource: "configured_list_price" | "gateway_reported" | null;
|
|
182
195
|
normalizedUsage: ModelCallUsageNormalization;
|
|
183
196
|
upstreamProvider?: string;
|
|
@@ -190,7 +203,8 @@ export declare function recordModelUsageAndDebitCredits(settings: Settings, db:
|
|
|
190
203
|
turnAttemptId: string;
|
|
191
204
|
model: string;
|
|
192
205
|
externallyBilled: boolean;
|
|
193
|
-
|
|
206
|
+
chargesOpenGeniCredits?: boolean;
|
|
207
|
+
countsTowardTokenCap?: boolean;
|
|
194
208
|
gatewayBilling?: ModelResponseUsage["gatewayBilling"];
|
|
195
209
|
usage?: ModelUsageInput | ModelCallUsageInput | null;
|
|
196
210
|
normalizedUsage?: ModelCallUsageNormalization;
|
|
@@ -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>>>;
|
|
@@ -24,6 +24,7 @@ export type PrepareTurnToolPolicyDeps = {
|
|
|
24
24
|
};
|
|
25
25
|
export type PrepareTurnToolRuntimeDeps = {
|
|
26
26
|
input: RunAgentTurnInput;
|
|
27
|
+
catalogSourceSettings: Settings;
|
|
27
28
|
db: ActivityServices["db"];
|
|
28
29
|
bus: ActivityServices["bus"];
|
|
29
30
|
runtime: ActivityServices["runtime"];
|
|
@@ -136,6 +137,7 @@ export declare function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps)
|
|
|
136
137
|
readonly subjectId: string;
|
|
137
138
|
};
|
|
138
139
|
};
|
|
140
|
+
generateSessionTitleInParallel: boolean;
|
|
139
141
|
postToolPreparationStartedAt: number;
|
|
140
142
|
preparationIndependentToolNames: string[];
|
|
141
143
|
}>;
|
|
@@ -1,10 +1,41 @@
|
|
|
1
|
-
import { type LazyToolTransport } from "@opengeni/runtime";
|
|
2
|
-
import { type ModelProviderApi, type
|
|
1
|
+
import { type ComputerToolMode, type LazyToolTransport } from "@opengeni/runtime";
|
|
2
|
+
import { type ModelProviderApi, type ResolvedModelProvider, type Settings } from "@opengeni/config";
|
|
3
3
|
import { type ModelAttachmentInputPolicy } from "../run-input.js";
|
|
4
|
+
export declare function shouldStartOnTurnRecording(params: {
|
|
5
|
+
recordingEnabled: boolean;
|
|
6
|
+
desktopEnabled: boolean;
|
|
7
|
+
establishedBackendId: string;
|
|
8
|
+
effectiveBackend: Settings["sandboxBackend"] | undefined;
|
|
9
|
+
}): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Decide the EXPLICIT computer-use tool transport for THIS turn.
|
|
12
|
+
*
|
|
13
|
+
* Computer-use is ordinary `computer_*` function tools bound to the live
|
|
14
|
+
* desktop. The worker picks the mode from the resolved provider so the runtime
|
|
15
|
+
* never string-sniffs the model instance:
|
|
16
|
+
* • catalogue `inputModalities` must include `image`, or computer-use is off
|
|
17
|
+
* • Responses wires (Azure/OpenAI, Gateway, Codex, legacy client) →
|
|
18
|
+
* "function-image": screenshot results are structured `{type:'image'}`
|
|
19
|
+
* • Chat Completions → "disabled": tool results on that wire are text, so a
|
|
20
|
+
* screenshot would become a base64 string rather than an image the model sees
|
|
21
|
+
*
|
|
22
|
+
* Pure + exported so the mapping is unit-testable without a live turn.
|
|
23
|
+
*/
|
|
24
|
+
export declare function computerToolModeForTurn(resolvedModel: {
|
|
25
|
+
provider: {
|
|
26
|
+
kind: ResolvedModelProvider["kind"];
|
|
27
|
+
api: ModelProviderApi;
|
|
28
|
+
};
|
|
29
|
+
configured: {
|
|
30
|
+
capabilities: {
|
|
31
|
+
inputModalities: string[];
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
} | null): ComputerToolMode;
|
|
4
35
|
/** Chat wires and Gateway models do not advertise OpenAI's hosted sandbox tool types. */
|
|
5
36
|
export declare function structuredToolTransportForTurn(resolvedModel: {
|
|
6
37
|
provider: {
|
|
7
|
-
kind:
|
|
38
|
+
kind: ResolvedModelProvider["kind"];
|
|
8
39
|
api: ModelProviderApi;
|
|
9
40
|
};
|
|
10
41
|
} | null): boolean;
|
|
@@ -17,7 +48,7 @@ export declare function structuredToolTransportForTurn(resolvedModel: {
|
|
|
17
48
|
export declare function lazyToolTransportForTurn(resolvedModel: {
|
|
18
49
|
provider: {
|
|
19
50
|
id: string;
|
|
20
|
-
kind:
|
|
51
|
+
kind: ResolvedModelProvider["kind"];
|
|
21
52
|
api: ModelProviderApi;
|
|
22
53
|
wireProfile: "openai" | "azure-openai";
|
|
23
54
|
builtin: boolean;
|
|
@@ -60,7 +91,7 @@ export declare function connectedSubscriptionImageGenerationAuthority<T>(credent
|
|
|
60
91
|
export declare function openAiHostedImageProviderBindingForTurn(settings: Pick<Settings, "openaiProvider" | "openaiApiKey" | "openaiBaseUrl">, resolvedModel: {
|
|
61
92
|
provider: {
|
|
62
93
|
id: string;
|
|
63
|
-
kind:
|
|
94
|
+
kind: ResolvedModelProvider["kind"];
|
|
64
95
|
builtin: boolean;
|
|
65
96
|
baseUrl?: string | undefined;
|
|
66
97
|
};
|
|
@@ -46,6 +46,8 @@ export type BillingState = {
|
|
|
46
46
|
isCodexTurn: boolean;
|
|
47
47
|
isXaiTurn: boolean;
|
|
48
48
|
isExternallyBilledTurn: boolean;
|
|
49
|
+
chargesOpenGeniCredits: boolean;
|
|
50
|
+
countsTowardTokenCap: boolean;
|
|
49
51
|
};
|
|
50
52
|
export type SandboxRuntimeState = {
|
|
51
53
|
resolvedSandbox: ResumedTurnSandbox | null;
|
|
@@ -67,7 +69,8 @@ export type SandboxRuntimeState = {
|
|
|
67
69
|
sandboxHolderId: TurnSandboxLeaseHolderId | null;
|
|
68
70
|
sandboxGroupId: string | null;
|
|
69
71
|
leaseHeartbeatTimer: ReturnType<typeof setInterval> | undefined;
|
|
70
|
-
|
|
72
|
+
rotationPreemptionInFlight: Promise<void> | null;
|
|
73
|
+
deadlineRotationRequested: boolean;
|
|
71
74
|
snapshotInFlight: Promise<void> | null;
|
|
72
75
|
firstProviderRequestStarted: boolean;
|
|
73
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";
|
|
@@ -12,5 +12,6 @@ export type AutomationActivityOptions = {
|
|
|
12
12
|
recordUsage?: typeof recordWorkspaceUsage;
|
|
13
13
|
};
|
|
14
14
|
export declare function createAutomationActivities(services: () => Promise<ControlActivityServices>, options?: AutomationActivityOptions): {
|
|
15
|
+
settleAutomationRunFailure: (input: DispatchAutomationRunInput) => Promise<void>;
|
|
15
16
|
dispatchAutomationRun: (input: DispatchAutomationRunInput) => Promise<DispatchAutomationRunResult>;
|
|
16
17
|
};
|
|
@@ -22,4 +22,6 @@ export declare function withCodexProvider(settings: Settings): Settings;
|
|
|
22
22
|
* authority snapshot, and bearer remain frozen later at turn admission.
|
|
23
23
|
*/
|
|
24
24
|
export declare function withXaiSubscriptionProvider(settings: Settings): Settings;
|
|
25
|
-
export declare function settingsWithWorkspaceGatewayCredential(db: Database, workspaceId: string, settings: Settings): Promise<Settings>;
|
|
25
|
+
export declare function settingsWithWorkspaceGatewayCredential(db: Database, accountId: string, workspaceId: string, settings: Settings, retainedProductModelId?: string | null): Promise<Settings>;
|
|
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. */
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { type Settings } from "@opengeni/config";
|
|
2
2
|
import { type SessionGoal, type ToolRef } from "@opengeni/contracts";
|
|
3
|
+
import { getWorkspaceModelPolicy } from "@opengeni/db";
|
|
3
4
|
import type { ControlActivityServices, MaybeContinueGoalInput, MaybeContinueGoalResult } from "./types.js";
|
|
4
5
|
export declare function createGoalActivities(services: () => Promise<ControlActivityServices>): {
|
|
5
6
|
enqueueGoalRetryWake: (input: MaybeContinueGoalInput) => Promise<void>;
|
|
6
7
|
maybeContinueGoal: (input: MaybeContinueGoalInput) => Promise<MaybeContinueGoalResult>;
|
|
7
8
|
};
|
|
9
|
+
export declare function goalContinuationModelDecision(input: {
|
|
10
|
+
settings: Settings;
|
|
11
|
+
workspaceModelPolicy: Awaited<ReturnType<typeof getWorkspaceModelPolicy>>;
|
|
12
|
+
inheritedModel: string;
|
|
13
|
+
sessionModel: string;
|
|
14
|
+
}): {
|
|
15
|
+
model: string;
|
|
16
|
+
blocked: string | null;
|
|
17
|
+
};
|
|
18
|
+
export declare function goalContinuationFundedWithoutCredits(settings: Settings, model: string, codexBilled: boolean): boolean;
|
|
8
19
|
export declare function goalContinuationPrompt(_goal: SessionGoal, _autoContinuation: number, _cap: number | null, options?: {
|
|
9
20
|
goalWaitAvailable?: boolean;
|
|
10
21
|
humanInputRespondAvailable?: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ImageGenerationReference } from "@opengeni/contracts";
|
|
1
|
+
import { type ImageGenerationReference, type FileAsset } from "@opengeni/contracts";
|
|
2
2
|
import { type Database } from "@opengeni/db";
|
|
3
3
|
import type { ObjectStorage } from "@opengeni/storage";
|
|
4
4
|
import { type GeneratedImageMediaType } from "./generated-images.js";
|
|
@@ -57,3 +57,4 @@ export declare function resolveImageGenerationReferencesForTool(input: ResolveIm
|
|
|
57
57
|
* /workspace. Provider adapters receive only validated immutable bytes.
|
|
58
58
|
*/
|
|
59
59
|
export declare function resolveImageGenerationReferences(input: ResolveImageGenerationReferencesInput): Promise<ResolvedImageGenerationReference[]>;
|
|
60
|
+
export declare function readStoredImageReferenceFile(objectStorage: Pick<ObjectStorage, "getFileBytes">, file: FileAsset): Promise<Uint8Array>;
|
|
@@ -10,6 +10,7 @@ type ScheduledTemporalActivityIdentity = {
|
|
|
10
10
|
activityId: string;
|
|
11
11
|
};
|
|
12
12
|
export declare function scheduledTaskRunProducerKey(input: DispatchScheduledTaskRunInput, suppliedActivityIdentity?: ScheduledTemporalActivityIdentity): string;
|
|
13
|
+
export declare function scheduledTaskGeneratedSessionCreateIdempotencyKey(producerKey: string): string;
|
|
13
14
|
/**
|
|
14
15
|
* Display title for a session the scheduler generates for a task.
|
|
15
16
|
*
|
|
@@ -53,6 +53,11 @@ export type InspectSessionAttemptActivity = (input: {
|
|
|
53
53
|
* agent runtime and document parser so each process can load only its role. */
|
|
54
54
|
export type SharedActivityServices = {
|
|
55
55
|
settings: Settings;
|
|
56
|
+
/**
|
|
57
|
+
* Original environment/host settings retained across live database-catalog
|
|
58
|
+
* refreshes. Older embedded test hosts may omit it and fall back to settings.
|
|
59
|
+
*/
|
|
60
|
+
catalogSourceSettings?: Settings;
|
|
56
61
|
db: Database;
|
|
57
62
|
bus: EventBus;
|
|
58
63
|
objectStorage: ObjectStorage | null;
|
|
@@ -357,6 +362,9 @@ export type DispatchAutomationRunResult = {
|
|
|
357
362
|
} | {
|
|
358
363
|
action: "skipped";
|
|
359
364
|
reason: string;
|
|
365
|
+
} | {
|
|
366
|
+
action: "failed";
|
|
367
|
+
reason: string;
|
|
360
368
|
} | {
|
|
361
369
|
action: "not_found";
|
|
362
370
|
};
|