@opengeni/worker-bundle 0.20.0 → 0.20.3
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.d.ts +25 -2
- package/dist/activities/google-drive-publication.d.ts +53 -0
- package/dist/activities/image-generation-references.d.ts +2 -0
- package/dist/activities/knowledge-source-sync-driver.d.ts +21 -0
- package/dist/activities/knowledge-source-sync.d.ts +29 -1
- package/dist/activities/run-input.d.ts +20 -2
- package/dist/activities/session-state.d.ts +5 -3
- package/dist/activities/types.d.ts +27 -0
- package/dist/{activities-control-XURE4VKN.js → activities-control-BJSDRSIP.js} +369 -20
- package/dist/activities-control-BJSDRSIP.js.map +1 -0
- package/dist/activities-control.d.ts +2 -2
- package/dist/{activities-turn-6EBXGGLS.js → activities-turn-J5YO7XXX.js} +2281 -1074
- package/dist/activities-turn-J5YO7XXX.js.map +1 -0
- package/dist/activities.d.ts +3 -3
- package/dist/{chunk-TYNPCG4U.js → chunk-N5TJIFCE.js} +69 -1
- package/dist/chunk-N5TJIFCE.js.map +1 -0
- package/dist/{chunk-5GRJIP5H.js → chunk-P6Z2SLAA.js} +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/observability-metrics.d.ts +37 -0
- package/dist/workflow-bundle.js +174 -4
- package/dist/workflows/session.d.ts +17 -1
- package/package.json +13 -13
- package/src/activities/agent-turn.ts +1801 -1175
- package/src/activities/documents.ts +6 -4
- package/src/activities/google-drive-publication.ts +840 -0
- package/src/activities/image-generation-references.ts +11 -2
- package/src/activities/knowledge-source-sync-driver.ts +23 -0
- package/src/activities/knowledge-source-sync.ts +384 -9
- package/src/activities/run-input.ts +175 -51
- package/src/activities/session-state.ts +69 -5
- package/src/activities/types.ts +27 -0
- package/src/activities.ts +2 -0
- package/src/observability-metrics.ts +184 -3
- package/src/workflows/session.ts +199 -8
- package/dist/activities-control-XURE4VKN.js.map +0 -1
- package/dist/activities-turn-6EBXGGLS.js.map +0 -1
- package/dist/chunk-TYNPCG4U.js.map +0 -1
- /package/dist/{chunk-5GRJIP5H.js.map → chunk-P6Z2SLAA.js.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AppendEventInput, type ActiveSandboxPointer, type SandboxRecord, type SessionAttemptQuiescenceCommit } from "@opengeni/db";
|
|
2
|
-
import { modelResponseServiceTierFromSdkEvent, modelTerminalResponseFromSdkEvent, type SandboxFileDownload, type ComputerToolMode, type ModelResponseUsage, type ModelCallUsageInput, type ModelCallUsageNormalization, type TurnToolCancellationFence, type BackendUnresolvableCode, type LazyToolTransport } from "@opengeni/runtime";
|
|
2
|
+
import { modelResponseServiceTierFromSdkEvent, modelTerminalResponseFromSdkEvent, type SandboxFileDownload, type SandboxFileDownloadFailure, type ComputerToolMode, type ModelResponseUsage, type ModelCallUsageInput, type ModelCallUsageNormalization, type TurnToolCancellationFence, type BackendUnresolvableCode, type LazyToolTransport } from "@opengeni/runtime";
|
|
3
3
|
import { resolveTurnExecutionPolicyV1, type ModelUsageInput, type ModelProviderApi, type RegistryProviderKind, type Settings } from "@opengeni/config";
|
|
4
4
|
import { ApplicationFailure, CancelledFailure } from "@temporalio/activity";
|
|
5
5
|
import type { CodexAccountStatus } from "@opengeni/db";
|
|
@@ -9,6 +9,7 @@ import { type CodemodeTokenRenewalController } from "./codemode-token-renewal.js
|
|
|
9
9
|
import { type ModelAttachmentInputPolicy } from "./run-input.js";
|
|
10
10
|
import type { TurnActivityServices as ActivityServices, EscapedMcpTimeoutRecoveryDetail, RunAgentTurnInput, RunAgentTurnResult, SessionAttemptQuiescenceProof } from "./types.js";
|
|
11
11
|
import { type ResumedTurnSandbox, type TurnSandboxLeaseHolderId } from "../sandbox-resume.js";
|
|
12
|
+
import { type TurnSandboxEstablishReason } from "../observability-metrics.js";
|
|
12
13
|
import { type LatencyMode, type SessionEvent, type SessionEventType, type SessionTurn, type ToolAuthNeededPayload, type TurnExecutionPolicyV1 } from "@opengeni/contracts";
|
|
13
14
|
export declare const PROVIDER_BACKPRESSURE_DELAY_MS = 60000;
|
|
14
15
|
export declare class WorkspaceHumanInputDisabledError extends Error {
|
|
@@ -58,7 +59,7 @@ export declare function providerRetryAfterMs(error: unknown, nowMs?: number): nu
|
|
|
58
59
|
* this notice prevents a graceful runtime drop from becoming a silent source-
|
|
59
60
|
* of-truth substitution or a false claim that the disconnected system was read.
|
|
60
61
|
*/
|
|
61
|
-
export declare function
|
|
62
|
+
export declare function unavailableMcpOperationalContext(input: {
|
|
62
63
|
droppedIds: readonly string[];
|
|
63
64
|
droppedCount: number;
|
|
64
65
|
}): string | undefined;
|
|
@@ -75,6 +76,16 @@ export declare function escapedMcpTimeoutRecoveryFailure(input: {
|
|
|
75
76
|
modelRequestStarted: boolean;
|
|
76
77
|
detail: EscapedMcpTimeoutRecoveryDetail;
|
|
77
78
|
}): ApplicationFailure | null;
|
|
79
|
+
/**
|
|
80
|
+
* Convert the atomic claim transaction's failure into a small, stable
|
|
81
|
+
* Temporal wire contract. The original error remains in activity diagnostics,
|
|
82
|
+
* but SQL text, parameters, and arbitrary invariant messages never enter
|
|
83
|
+
* workflow history. Contention and operational database unavailability are
|
|
84
|
+
* safe to re-read after backoff because the claim transaction contains no
|
|
85
|
+
* model/tool effects; permanent database and state failures require terminal
|
|
86
|
+
* settlement.
|
|
87
|
+
*/
|
|
88
|
+
export declare function preClaimAdmissionFailure(error: unknown): ApplicationFailure;
|
|
78
89
|
/**
|
|
79
90
|
* Resolve which Codex account a turn runs on (multi-account P1): session-pin >
|
|
80
91
|
* workspace-active. No rotation in P1. The selected id must still be in the
|
|
@@ -88,6 +99,7 @@ export declare function selectCodexCredentialForTurn(args: {
|
|
|
88
99
|
connectedIds: Set<string>;
|
|
89
100
|
}): string | null;
|
|
90
101
|
export declare function filterUnmaterializedSandboxFileDownloads(downloads: SandboxFileDownload[], materializedFileIds: Set<string>): SandboxFileDownload[];
|
|
102
|
+
export declare function sandboxFileMaterializationOutcome(failures: readonly SandboxFileDownloadFailure[]): "completed" | "failed";
|
|
91
103
|
/** Fixed-length one-way tenant correlation for metrics/alerts; never a raw id. */
|
|
92
104
|
export declare function codexWorkspaceMetricKey(workspaceId: string): string;
|
|
93
105
|
/** Stable public request identity across partial resumes and activity retries. */
|
|
@@ -511,6 +523,17 @@ export declare function managedSandboxOwnershipForTurn(machinePrimary: boolean,
|
|
|
511
523
|
} | null;
|
|
512
524
|
/** A sandboxless home still establishes an explicitly attached Connected Machine. */
|
|
513
525
|
export declare function shouldEstablishSandboxForTurn(sandboxOwnershipEnabled: boolean, homeBackend: Settings["sandboxBackend"], machinePrimary: boolean): boolean;
|
|
526
|
+
export declare function sandboxEstablishPolicyDecision(input: {
|
|
527
|
+
lazyEnabled: boolean;
|
|
528
|
+
machinePrimary: boolean;
|
|
529
|
+
sandboxBackend: Settings["sandboxBackend"];
|
|
530
|
+
hasInitialRunCredentialMaterial: boolean;
|
|
531
|
+
generatedVideoFileCount: number;
|
|
532
|
+
hasSignedFileResources: boolean;
|
|
533
|
+
}): {
|
|
534
|
+
policy: "eager" | "on-demand";
|
|
535
|
+
reason: TurnSandboxEstablishReason;
|
|
536
|
+
};
|
|
514
537
|
/**
|
|
515
538
|
* Classify a persisted active-sandbox pointer for TURN-START RECONCILE (issue #341
|
|
516
539
|
* invariant B). Returns the typed reason to RESET the pointer to the session HOME,
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type AttemptToolDefinition } from "@opengeni/codemode";
|
|
2
|
+
import type { McpPersonalConnectionDelegation } from "@opengeni/contracts";
|
|
3
|
+
import { GOOGLE_DRIVE_FILE_SCOPE, GOOGLE_DRIVE_FULL_SCOPE, type GoogleDriveOutputDestination, type GoogleDrivePublicationReceipt as GoogleDrivePublicationReceiptValue, type GoogleDrivePublicationToolInput as GoogleDrivePublicationToolInputValue } from "@opengeni/contracts/google-drive";
|
|
4
|
+
import { beginConnectorActionExecution, completeConnectorActionExecution, getConnectionMetadata, getWorkspaceGrant, prepareConnectorActionApproval, requireFile, type ConnectorActionAttemptIdentity, type ConnectorActionInvocation, type Database, type ResolveConnectionCredentialInput, type ResolveConnectionCredentialResult } from "@opengeni/db";
|
|
5
|
+
import { readAuthorizedEditableArtifactMaterialization } from "@opengeni/db/editable-artifact-durable-export";
|
|
6
|
+
import { type FetchLike } from "@opengeni/network";
|
|
7
|
+
import type { ObjectStorage } from "@opengeni/storage";
|
|
8
|
+
export type GoogleDrivePublicationTarget = Readonly<{
|
|
9
|
+
ownerSubjectId: string;
|
|
10
|
+
connectionId: string;
|
|
11
|
+
destination: GoogleDriveOutputDestination;
|
|
12
|
+
credentialScope: typeof GOOGLE_DRIVE_FILE_SCOPE | typeof GOOGLE_DRIVE_FULL_SCOPE;
|
|
13
|
+
}>;
|
|
14
|
+
export type GoogleDrivePublicationPorts = {
|
|
15
|
+
getConnection: typeof getConnectionMetadata;
|
|
16
|
+
getMembership: typeof getWorkspaceGrant;
|
|
17
|
+
readMaterialization: typeof readAuthorizedEditableArtifactMaterialization;
|
|
18
|
+
requireFile: typeof requireFile;
|
|
19
|
+
prepare: typeof prepareConnectorActionApproval;
|
|
20
|
+
begin: typeof beginConnectorActionExecution;
|
|
21
|
+
complete: typeof completeConnectorActionExecution;
|
|
22
|
+
fetch: FetchLike;
|
|
23
|
+
};
|
|
24
|
+
export declare function resolveGoogleDrivePublicationTarget(db: Database, workspaceId: string, delegations: readonly McpPersonalConnectionDelegation[], ports?: Pick<GoogleDrivePublicationPorts, "getConnection" | "getMembership">): Promise<GoogleDrivePublicationTarget | null>;
|
|
25
|
+
export declare function googleDrivePublicationConnectorCall(target: GoogleDrivePublicationTarget, rawRequest: unknown, approvalId: string): ConnectorActionInvocation;
|
|
26
|
+
export declare function createGoogleDrivePublicationAttemptTool(input: {
|
|
27
|
+
db: Database;
|
|
28
|
+
objectStorage: ObjectStorage;
|
|
29
|
+
identity: ConnectorActionAttemptIdentity;
|
|
30
|
+
subjectId: string;
|
|
31
|
+
target: GoogleDrivePublicationTarget;
|
|
32
|
+
resolveCredential: (input: ResolveConnectionCredentialInput) => Promise<ResolveConnectionCredentialResult>;
|
|
33
|
+
signal?: AbortSignal;
|
|
34
|
+
ports?: GoogleDrivePublicationPorts;
|
|
35
|
+
}): AttemptToolDefinition;
|
|
36
|
+
export declare function authorizeGoogleDrivePublicationAttempt(input: {
|
|
37
|
+
db: Database;
|
|
38
|
+
identity: ConnectorActionAttemptIdentity;
|
|
39
|
+
target: GoogleDrivePublicationTarget;
|
|
40
|
+
approvalId: string;
|
|
41
|
+
arguments: unknown;
|
|
42
|
+
ports?: Pick<GoogleDrivePublicationPorts, "prepare">;
|
|
43
|
+
}): Promise<void>;
|
|
44
|
+
export declare function executeGoogleDrivePublication(input: {
|
|
45
|
+
db: Database;
|
|
46
|
+
objectStorage: ObjectStorage;
|
|
47
|
+
identity: ConnectorActionAttemptIdentity;
|
|
48
|
+
subjectId: string;
|
|
49
|
+
target: GoogleDrivePublicationTarget;
|
|
50
|
+
request: GoogleDrivePublicationToolInputValue;
|
|
51
|
+
resolveCredential: (input: ResolveConnectionCredentialInput) => Promise<ResolveConnectionCredentialResult>;
|
|
52
|
+
signal?: AbortSignal;
|
|
53
|
+
}, ports?: Pick<GoogleDrivePublicationPorts, "getConnection" | "readMaterialization" | "requireFile" | "fetch">): Promise<GoogleDrivePublicationReceiptValue>;
|
|
@@ -19,7 +19,9 @@ export type SandboxImageReferenceReader = (path: string, maxBytes: number) => Pr
|
|
|
19
19
|
export declare function resolveImageGenerationReferences(input: {
|
|
20
20
|
db: Database;
|
|
21
21
|
objectStorage: ObjectStorage;
|
|
22
|
+
accountId: string;
|
|
22
23
|
workspaceId: string;
|
|
24
|
+
subjectId: string | null;
|
|
23
25
|
references: readonly ImageGenerationReference[];
|
|
24
26
|
readSandboxFile?: SandboxImageReferenceReader;
|
|
25
27
|
}): Promise<ResolvedImageGenerationReference[]>;
|
|
@@ -10,6 +10,26 @@ export type KnowledgeSourceSyncDriverInventory<Entry, StopReason extends string>
|
|
|
10
10
|
elapsedMs: number;
|
|
11
11
|
hardLimitReached: boolean;
|
|
12
12
|
};
|
|
13
|
+
export type KnowledgeSourceSyncAclPrincipal = {
|
|
14
|
+
type: "user" | "group" | "domain" | "anyone";
|
|
15
|
+
permissionId?: string | null;
|
|
16
|
+
emailAddress?: string | null;
|
|
17
|
+
domain?: string | null;
|
|
18
|
+
role: "owner" | "organizer" | "fileOrganizer" | "writer" | "commenter" | "reader";
|
|
19
|
+
inherited?: boolean;
|
|
20
|
+
allowFileDiscovery?: boolean | null;
|
|
21
|
+
expirationTime?: string | null;
|
|
22
|
+
};
|
|
23
|
+
export type KnowledgeSourceSyncAclEvidence = {
|
|
24
|
+
eligibility: "eligible" | "denied";
|
|
25
|
+
providerRevision: string | null;
|
|
26
|
+
driveId: string | null;
|
|
27
|
+
aclRevision: string;
|
|
28
|
+
observedAt: string;
|
|
29
|
+
expiresAt: string;
|
|
30
|
+
providerRequests: number;
|
|
31
|
+
principals: KnowledgeSourceSyncAclPrincipal[];
|
|
32
|
+
};
|
|
13
33
|
/** Provider port for deterministic knowledge ingestion. Implementations own
|
|
14
34
|
* provider JSON and byte transfer; the shared activity owns authority,
|
|
15
35
|
* persistence, indexing obligations, telemetry, and checkpoint settlement. */
|
|
@@ -20,4 +40,5 @@ export type KnowledgeSourceSyncDriver<Entry, StopReason extends string> = {
|
|
|
20
40
|
inventory: (executionCheckpoint: Record<string, unknown> | null, providerCursor: Record<string, unknown> | null) => Promise<KnowledgeSourceSyncDriverInventory<Entry, StopReason>>;
|
|
21
41
|
fetchContent: (entry: Entry, maxBytes: number) => Promise<Uint8Array>;
|
|
22
42
|
citationLocator: (entry: Entry) => Record<string, unknown>;
|
|
43
|
+
readAcl?: (entry: Entry, maxProviderRequests: number) => Promise<KnowledgeSourceSyncAclEvidence>;
|
|
23
44
|
};
|
|
@@ -2,8 +2,23 @@ import { GoogleDriveConnectionMetadata, type GoogleDriveSelectedSource } from "@
|
|
|
2
2
|
import { type GoogleDriveInventoryEntry, type GoogleDriveInventoryPage, type GoogleDriveInventoryProviderItem, type GoogleDriveInventoryStopReason } from "@opengeni/documents/google-drive";
|
|
3
3
|
import { deauthorizeKnowledgeSourceRetrieval, settleKnowledgeSourceSyncLease, type Database, type KnowledgeSourceSyncObjectObservationResult, type KnowledgeSourceSyncObservationFloor } from "@opengeni/db";
|
|
4
4
|
import type { ControlActivityServices, RunKnowledgeSourceSyncBatchInput, RunKnowledgeSourceSyncBatchResult } from "./types.js";
|
|
5
|
-
import type { KnowledgeSourceSyncDriver } from "./knowledge-source-sync-driver.js";
|
|
5
|
+
import type { KnowledgeSourceSyncAclEvidence, KnowledgeSourceSyncDriver } from "./knowledge-source-sync-driver.js";
|
|
6
6
|
import { type GoogleDriveChangesPage } from "./google-drive-changes.js";
|
|
7
|
+
type GoogleDrivePermission = {
|
|
8
|
+
id: string;
|
|
9
|
+
type: "user" | "group" | "domain" | "anyone";
|
|
10
|
+
role: "owner" | "organizer" | "fileOrganizer" | "writer" | "commenter" | "reader";
|
|
11
|
+
emailAddress: string | null;
|
|
12
|
+
domain: string | null;
|
|
13
|
+
allowFileDiscovery: boolean | null;
|
|
14
|
+
expirationTime: string | null;
|
|
15
|
+
inherited: boolean;
|
|
16
|
+
};
|
|
17
|
+
type GoogleDrivePermissionsPage = {
|
|
18
|
+
permissions: GoogleDrivePermission[];
|
|
19
|
+
nextPageToken: string | null;
|
|
20
|
+
denied: boolean;
|
|
21
|
+
};
|
|
7
22
|
export declare function knowledgeSyncObservationPolicy(kind: "google_drive" | "atlassian"): {
|
|
8
23
|
revisionOrdering: "canonical_decimal";
|
|
9
24
|
filterWithDriveDurability: boolean;
|
|
@@ -36,6 +51,11 @@ export type GoogleDriveSyncProviderPort = {
|
|
|
36
51
|
pageToken: string | null;
|
|
37
52
|
pageSize: number;
|
|
38
53
|
}) => Promise<GoogleDriveInventoryPage>;
|
|
54
|
+
listPermissions?: (input: {
|
|
55
|
+
fileId: string;
|
|
56
|
+
pageToken: string | null;
|
|
57
|
+
pageSize: number;
|
|
58
|
+
}) => Promise<GoogleDrivePermissionsPage>;
|
|
39
59
|
};
|
|
40
60
|
export declare function googleDriveSyncDriver(input: {
|
|
41
61
|
actionProviderCoordinationKey: string;
|
|
@@ -64,6 +84,13 @@ export declare function shouldProcessGoogleDriveDurableObservation(input: {
|
|
|
64
84
|
aclGeneration: number;
|
|
65
85
|
}): boolean;
|
|
66
86
|
export declare function mergeGoogleDriveDurableObservationFloors(checkpoint: Record<string, unknown> | null, observations: KnowledgeSourceSyncObservationFloor[], maxItems: number): Record<string, unknown> | null;
|
|
87
|
+
export declare function collectGoogleDriveAclEvidence(input: {
|
|
88
|
+
entry: Pick<GoogleDriveInventoryEntry, "externalObjectId" | "externalVersionId" | "driveId">;
|
|
89
|
+
maxProviderRequests: number;
|
|
90
|
+
listPermissions: NonNullable<GoogleDriveSyncProviderPort["listPermissions"]>;
|
|
91
|
+
getFile?: GoogleDriveSyncProviderPort["getFile"];
|
|
92
|
+
now?: () => number;
|
|
93
|
+
}): Promise<KnowledgeSourceSyncAclEvidence>;
|
|
67
94
|
export declare function googleDriveSyncProviderAccessAllowed(input: {
|
|
68
95
|
connectionVersion: number;
|
|
69
96
|
resolvedConnectionVersion: number | undefined;
|
|
@@ -73,3 +100,4 @@ export declare function googleDriveSyncProviderAccessAllowed(input: {
|
|
|
73
100
|
}): boolean;
|
|
74
101
|
export declare function confluenceCursor(value: unknown): string | null;
|
|
75
102
|
export declare function adfToMarkdown(value: unknown): string;
|
|
103
|
+
export {};
|
|
@@ -23,15 +23,29 @@ export type PreparedTurnInput = {
|
|
|
23
23
|
};
|
|
24
24
|
export type TurnInputOptions = {
|
|
25
25
|
turnId: string;
|
|
26
|
+
/** Frozen initiating-human authority for every model-visible file read. */
|
|
27
|
+
fileAuthority: {
|
|
28
|
+
accountId: string;
|
|
29
|
+
subjectId: string | null;
|
|
30
|
+
};
|
|
26
31
|
recovering?: boolean;
|
|
27
32
|
unavailableSandboxFilesNote?: string;
|
|
28
33
|
runCredentialsNote?: string;
|
|
34
|
+
mcpAvailabilityNote?: string;
|
|
29
35
|
providerApi: HistoryProviderApi;
|
|
30
36
|
projectCanonicalHistory?: ModelHistoryAttachmentProjector;
|
|
31
37
|
materializeModelHistory?: ModelHistoryAttachmentProjector;
|
|
32
38
|
materializeSerializedRunState?: (serialized: string) => Promise<string>;
|
|
33
39
|
projectModelHistory?: ModelHistoryAttachmentProjector;
|
|
34
40
|
loadActiveHistory?: typeof getActiveSessionHistoryItemsPaged;
|
|
41
|
+
/** Bounded critical-path timings; telemetry failures never affect preparation. */
|
|
42
|
+
onPreparationPhase?: (measurement: HistoryPreparationPhaseMeasurement) => void;
|
|
43
|
+
};
|
|
44
|
+
export type HistoryPreparationPhase = "system_update_load" | "current_attachment_resolution" | "durable_history_load" | "sandbox_envelope_load" | "canonical_projection" | "provider_projection" | "attachment_ref_projection" | "screenshot_materialization" | "model_attachment_projection" | "runtime_input_assembly" | "artifact_candidate_scan";
|
|
45
|
+
export type HistoryPreparationPhaseMeasurement = {
|
|
46
|
+
phase: HistoryPreparationPhase;
|
|
47
|
+
outcome: "completed" | "failed";
|
|
48
|
+
durationSeconds: number;
|
|
35
49
|
};
|
|
36
50
|
export declare const MAX_INLINE_MODEL_ATTACHMENT_BYTES: number;
|
|
37
51
|
export type ModelAttachmentContent = {
|
|
@@ -52,8 +66,12 @@ export declare function modelAttachmentContentForFiles(files: FileAsset[], readF
|
|
|
52
66
|
* and file bytes are memoized, so compaction/retry can reuse the same work and
|
|
53
67
|
* the SDK's repeated tool loop never touches storage or rescans old history.
|
|
54
68
|
*/
|
|
55
|
-
export declare function createModelHistoryAttachmentProjector(db: Database,
|
|
69
|
+
export declare function createModelHistoryAttachmentProjector(db: Database, authority: {
|
|
70
|
+
accountId: string;
|
|
71
|
+
workspaceId: string;
|
|
72
|
+
subjectId: string | null;
|
|
73
|
+
}, policy: ModelAttachmentInputPolicy, readFileBytes?: (file: FileAsset) => Promise<Uint8Array>): ModelHistoryAttachmentProjector;
|
|
56
74
|
/** Add current trigger refs only when older/local history predates durable stamping. */
|
|
57
75
|
export declare function withCurrentUserAttachmentRefs(historyItems: Array<Record<string, unknown>>, refs: FileResourceRef[]): Array<Record<string, unknown>>;
|
|
58
76
|
export declare function turnInput(db: Database, runtime: OpenGeniRuntime, agent: any, trigger: Awaited<ReturnType<typeof getSessionEvent>>, options: TurnInputOptions): Promise<PreparedTurnInput>;
|
|
59
|
-
export declare function userMessageTextWithAttachments(db: Database, workspaceId: string, text: string, resources: ResourceRef[]): Promise<string>;
|
|
77
|
+
export declare function userMessageTextWithAttachments(db: Database, accountId: string, workspaceId: string, subjectId: string | null, text: string, resources: ResourceRef[]): Promise<string>;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { settleSessionAttemptInterruptions, applySessionTurnSettlement, requestSessionTurnRecovery, recoverSessionDispatch, reconcileSessionAttemptQuiescence, peekSessionWork as peekSessionWorkDb, countQueuedTurns, getSessionAttemptActivityRef, getSessionEvent, getSessionTurnForAttempt, expireSessionInteractionIntervention as expireSessionInteractionInterventionDb, expireSessionHumanInputRequest, markSessionAttemptQuiesced, requireSession, settleSessionIdleWithParentOutbox } from "@opengeni/db";
|
|
1
|
+
import { settleSessionAttemptInterruptions, applySessionTurnSettlement, enqueueSessionWorkflowWake, failSessionWorkBeforeAttemptClaim, requestSessionTurnRecovery, recoverSessionDispatch, reconcileSessionAttemptQuiescence, peekSessionWork as peekSessionWorkDb, countQueuedTurns, getSessionAttemptActivityRef, getSessionEvent, getSessionTurnForAttempt, expireSessionInteractionIntervention as expireSessionInteractionInterventionDb, expireSessionHumanInputRequest, markSessionAttemptQuiesced, requireSession, settleSessionIdleWithParentOutbox } from "@opengeni/db";
|
|
2
2
|
import { publishDurableSessionEvents } from "@opengeni/events";
|
|
3
3
|
import { deliverFailedChildTurnToParent, notifyParentOfChildIdle } from "./parent-wake.js";
|
|
4
4
|
import { recordTurnsQueuedGauge } from "../observability-metrics.js";
|
|
5
|
-
import type { ControlActivityServices, ExpireSessionHumanInputInput, ExpireSessionHumanInputResult, ExpireSessionInteractionInterventionInput, ExpireSessionInteractionInterventionResult, PeekSessionWorkInput, FailSessionAttemptInput, SettleSessionInterruptionsInput, MarkSessionIdleInput, PersistSessionAttemptQuiescenceInput, ReconcileSessionAttemptQuiescenceInput, ReconcileSessionAttemptQuiescenceResult, RecoverDispatchInput, RecoverDispatchResult, RecoverEscapedMcpTimeoutInput, RecoverEscapedMcpTimeoutResult } from "./types.js";
|
|
5
|
+
import type { ControlActivityServices, ExpireSessionHumanInputInput, ExpireSessionHumanInputResult, ExpireSessionInteractionInterventionInput, ExpireSessionInteractionInterventionResult, PeekSessionWorkInput, FailSessionAttemptInput, FailSessionAttemptResult, SettleSessionInterruptionsInput, MarkSessionIdleInput, PersistSessionAttemptQuiescenceInput, ReconcileSessionAttemptQuiescenceInput, ReconcileSessionAttemptQuiescenceResult, RecoverDispatchInput, RecoverDispatchResult, RecoverEscapedMcpTimeoutInput, RecoverEscapedMcpTimeoutResult } from "./types.js";
|
|
6
6
|
export type SessionStateActivityOverrides = Partial<{
|
|
7
7
|
settleSessionAttemptInterruptions: typeof settleSessionAttemptInterruptions;
|
|
8
8
|
applySessionTurnSettlement: typeof applySessionTurnSettlement;
|
|
9
|
+
enqueueSessionWorkflowWake: typeof enqueueSessionWorkflowWake;
|
|
10
|
+
failSessionWorkBeforeAttemptClaim: typeof failSessionWorkBeforeAttemptClaim;
|
|
9
11
|
requestSessionTurnRecovery: typeof requestSessionTurnRecovery;
|
|
10
12
|
recoverSessionDispatch: typeof recoverSessionDispatch;
|
|
11
13
|
reconcileSessionAttemptQuiescence: typeof reconcileSessionAttemptQuiescence;
|
|
@@ -26,7 +28,7 @@ export type SessionStateActivityOverrides = Partial<{
|
|
|
26
28
|
}>;
|
|
27
29
|
export declare const WORKER_DEATH_MAX_REDISPATCHES = 3;
|
|
28
30
|
export declare function createSessionStateActivities(services: () => Promise<ControlActivityServices>, overrides?: SessionStateActivityOverrides): {
|
|
29
|
-
failSessionAttempt: (input: FailSessionAttemptInput) => Promise<
|
|
31
|
+
failSessionAttempt: (input: FailSessionAttemptInput) => Promise<FailSessionAttemptResult>;
|
|
30
32
|
settleSessionInterruptions: (input: SettleSessionInterruptionsInput) => Promise<{
|
|
31
33
|
action: "paused" | "continue" | "stale";
|
|
32
34
|
}>;
|
|
@@ -170,8 +170,35 @@ export type FailSessionAttemptInput = {
|
|
|
170
170
|
workspaceId: string;
|
|
171
171
|
sessionId: string;
|
|
172
172
|
attemptId: string;
|
|
173
|
+
/** Added in v2; old Temporal histories derive the session's canonical id. */
|
|
174
|
+
workflowId?: string;
|
|
175
|
+
/** Added in v2; old Temporal histories use the bounded 60-second floor. */
|
|
176
|
+
retryDelayMs?: number;
|
|
177
|
+
/** Added in v3. Upgraded turn workers classify failures from the atomic
|
|
178
|
+
* admission transaction; omission is a rolling-deploy/legacy unknown and
|
|
179
|
+
* deliberately keeps the recoverable wake behavior. */
|
|
180
|
+
preClaimFailureDisposition?: PreClaimFailureDisposition;
|
|
181
|
+
/** The workflow admission trigger is required to re-evaluate the same
|
|
182
|
+
* durable admission branch before terminally settling a permanent failure. */
|
|
183
|
+
trigger?: RunAgentTurnInput["trigger"];
|
|
173
184
|
error?: string;
|
|
174
185
|
};
|
|
186
|
+
export type FailSessionAttemptResult = {
|
|
187
|
+
action: "failed";
|
|
188
|
+
} | {
|
|
189
|
+
action: "unclaimed";
|
|
190
|
+
} | {
|
|
191
|
+
action: "terminal";
|
|
192
|
+
} | {
|
|
193
|
+
action: "stale";
|
|
194
|
+
};
|
|
195
|
+
export type PreClaimFailureDisposition = "retryable" | "permanent";
|
|
196
|
+
export type PreClaimFailureDetail = {
|
|
197
|
+
disposition: PreClaimFailureDisposition;
|
|
198
|
+
code: "db_deadlock" | "db_serialization_failure" | "db_failure" | "claim_invariant";
|
|
199
|
+
};
|
|
200
|
+
export declare const PRE_CLAIM_FAILURE_TYPE = "OpenGeniPreClaimFailure";
|
|
201
|
+
export declare const PRE_CLAIM_FAILURE_MESSAGE = "Agent turn admission failed before attempt claim.";
|
|
175
202
|
export type RecoverDispatchInput = {
|
|
176
203
|
accountId: string;
|
|
177
204
|
workspaceId: string;
|