@opengeni/worker-bundle 0.16.14 → 0.16.21
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 +33 -52
- package/dist/activities/codex-rotation.d.ts +5 -9
- package/dist/activities/context-compaction.d.ts +0 -4
- package/dist/activities/file-upload-reaper.d.ts +6 -0
- package/dist/activities/run-input.d.ts +16 -73
- package/dist/index.js +350 -278
- package/dist/index.js.map +1 -1
- package/dist/workflow-bundle.js +44 -28
- package/package.json +12 -12
- package/src/activities/agent-turn.ts +242 -257
- package/src/activities/codex-capacity.ts +0 -1
- package/src/activities/codex-rotation.ts +10 -83
- package/src/activities/context-compaction.ts +2 -14
- package/src/activities/file-upload-reaper.ts +108 -7
- package/src/activities/run-input.ts +90 -150
- package/src/activities/sandbox-lease.ts +5 -2
- package/src/sandbox-routing.ts +5 -2
- package/src/workflows/session.ts +55 -32
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AppendEventInput, type ActiveSandboxPointer, type SandboxRecord } from "@opengeni/db";
|
|
2
|
-
import { modelResponseServiceTierFromSdkEvent,
|
|
2
|
+
import { modelResponseServiceTierFromSdkEvent, modelTerminalResponseFromSdkEvent, type SandboxFileDownload, type ComputerToolMode, type ModelResponseUsage, type ModelCallUsageInput, type ModelCallUsageNormalization, type RunAgentStreamOptions, type TurnToolCancellationFence, type BackendUnresolvableCode } 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";
|
|
@@ -7,7 +7,7 @@ import { type GitCredentialRenewalController } from "./git-credential-renewal";
|
|
|
7
7
|
import { type RunCredentialRenewalController } from "./run-credential-renewal";
|
|
8
8
|
import { type ToolspaceTokenRenewalController } from "./toolspace-token-renewal";
|
|
9
9
|
import { type SecretForRedaction } from "./redaction";
|
|
10
|
-
import { type ModelAttachmentInputPolicy
|
|
10
|
+
import { type ModelAttachmentInputPolicy } from "./run-input";
|
|
11
11
|
import type { ActivityServices, EscapedMcpTimeoutRecoveryDetail, RunAgentTurnInput, RunAgentTurnResult, SessionAttemptQuiescenceProof } from "./types";
|
|
12
12
|
import { type TurnSandboxLeaseHolderId } from "../sandbox-resume";
|
|
13
13
|
import { type LatencyMode, type SessionEvent, type SessionEventType, type SessionTurn, type ToolAuthNeededPayload, type TurnExecutionPolicyV1 } from "@opengeni/contracts";
|
|
@@ -271,19 +271,21 @@ type TurnEventPublisher = (events: Array<Omit<AppendEventInput, "producerId" | "
|
|
|
271
271
|
events: SessionEvent[];
|
|
272
272
|
accepted: boolean;
|
|
273
273
|
}>;
|
|
274
|
-
export type
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
274
|
+
export type ModelResponseEventState = {
|
|
275
|
+
responseCount: number;
|
|
276
|
+
contextSignal: {
|
|
277
|
+
revision: number;
|
|
278
|
+
totalTokens: number;
|
|
279
|
+
} | null;
|
|
278
280
|
claimedSourceKeys: Set<string>;
|
|
279
281
|
};
|
|
280
282
|
export type CompactionModelUsageEventState = {
|
|
281
283
|
usageCount: number;
|
|
282
284
|
claimedSourceKeys: Set<string>;
|
|
283
285
|
};
|
|
284
|
-
export declare function
|
|
286
|
+
export declare function createModelResponseEventState(claimedSourceKeys?: Set<string>): ModelResponseEventState;
|
|
285
287
|
export declare function createCompactionModelUsageEventState(claimedSourceKeys?: Set<string>): CompactionModelUsageEventState;
|
|
286
|
-
export declare function
|
|
288
|
+
export declare function modelResponseContextSignal(state: ModelResponseEventState): {
|
|
287
289
|
revision: number;
|
|
288
290
|
totalTokens: number;
|
|
289
291
|
} | null;
|
|
@@ -295,19 +297,20 @@ export declare function assertModelResponseLatencyMode(input: {
|
|
|
295
297
|
providerId?: string;
|
|
296
298
|
}): void;
|
|
297
299
|
/**
|
|
298
|
-
* Process one SDK
|
|
300
|
+
* Process one SDK terminal-response event through the production authority path.
|
|
299
301
|
*
|
|
300
302
|
* The pinned Responses SDK mirrors one provider terminal response as both a
|
|
301
303
|
* normalized `response_done` and a raw `model/response.completed` event. Claim
|
|
302
|
-
* the stable response/source key before lease renewal or any
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
304
|
+
* the stable response/source key before lease renewal or any side effect, and
|
|
305
|
+
* use that one positional ordinal for both response identity and same-run
|
|
306
|
+
* context binding. A response without usage still clears attempt-owned token
|
|
307
|
+
* state. When usage exists, the durable `agent.model.usage` source-key fence
|
|
308
|
+
* remains the cross-restart authority: a replay may retry the idempotent billing
|
|
309
|
+
* write, but it cannot advance metrics, context, or attempt-owned signals.
|
|
310
|
+
*/
|
|
311
|
+
export declare function processModelResponseTerminalEvent(input: {
|
|
312
|
+
event: Parameters<typeof modelTerminalResponseFromSdkEvent>[0];
|
|
313
|
+
state: ModelResponseEventState;
|
|
311
314
|
dispatchId: string | null;
|
|
312
315
|
settings: Settings;
|
|
313
316
|
db: ActivityServices["db"];
|
|
@@ -330,9 +333,9 @@ export declare function processModelResponseUsageEvent(input: {
|
|
|
330
333
|
renewLease: () => Promise<void>;
|
|
331
334
|
leaseLost: () => boolean;
|
|
332
335
|
leaseLostMessage: string;
|
|
333
|
-
setLastInputTokens: (tokens: number) => Promise<void>;
|
|
336
|
+
setLastInputTokens: (tokens: number | null) => Promise<void>;
|
|
334
337
|
}): Promise<{
|
|
335
|
-
status: "
|
|
338
|
+
status: "not_response";
|
|
336
339
|
} | {
|
|
337
340
|
status: "duplicate";
|
|
338
341
|
sourceKey: string;
|
|
@@ -340,6 +343,7 @@ export declare function processModelResponseUsageEvent(input: {
|
|
|
340
343
|
status: "processed";
|
|
341
344
|
sourceKey: string;
|
|
342
345
|
authoritative: boolean;
|
|
346
|
+
usageReported: boolean;
|
|
343
347
|
}>;
|
|
344
348
|
/**
|
|
345
349
|
* Apply the same source-key authority ordering to the compaction summarizer's
|
|
@@ -412,40 +416,17 @@ export declare function historyRowsToAppend(rawHistory: Array<Record<string, unk
|
|
|
412
416
|
nextWatermark: number;
|
|
413
417
|
nextPosition: number;
|
|
414
418
|
};
|
|
419
|
+
/** Select only opaque rows that participated in the provider's rejected wire request. */
|
|
420
|
+
export declare function selectRejectedProviderArtifactHistoryIds(activeHistory: ReadonlyArray<{
|
|
421
|
+
id: string;
|
|
422
|
+
item: Record<string, unknown>;
|
|
423
|
+
providerArtifactInvalidatedAt: Date | null;
|
|
424
|
+
}>, candidates: {
|
|
425
|
+
knownHistoryItemIds: readonly string[];
|
|
426
|
+
historyItemIds: readonly string[];
|
|
427
|
+
}, wireFingerprints: readonly string[]): string[];
|
|
415
428
|
/** Literal final per-call boundary for replayed and current-turn model input. */
|
|
416
429
|
export declare function secretRedactionModelInputFilter(redactValue: (value: unknown) => unknown): NonNullable<RunAgentStreamOptions["callModelInputFilter"]>;
|
|
417
|
-
/**
|
|
418
|
-
* Seed the turn-end reconcile watermark (`persistedHistoryCount`) from EXACTLY the
|
|
419
|
-
* view `state.history` was seeded from, so the model-input length and the watermark
|
|
420
|
-
* can NEVER disagree. The watermark is the slice index the reconcile cuts the
|
|
421
|
-
* (re-sanitized) `state.history` at to find this turn's genuinely-new items, so it
|
|
422
|
-
* must equal the length of `state.history`'s already-persisted leading prefix.
|
|
423
|
-
*
|
|
424
|
-
* The cross-account reasoning strip drops foreign reasoning items, so the prefix
|
|
425
|
-
* length is PATH-DEPENDENT, captured by `modelHistoryFromItems`:
|
|
426
|
-
*
|
|
427
|
-
* - items read path (`modelHistoryFromItems === true`) — `state.history` was seeded
|
|
428
|
-
* from the cross-account-STRIPPED active items (foreign reasoning DROPPED), so it
|
|
429
|
-
* starts K shorter than the raw active-row count. Seed from the SAME strip
|
|
430
|
-
* (HOLE D); seeding from the un-stripped count would slice K genuinely-new items
|
|
431
|
-
* off the reconcile and silently lose them (incl. the user's switch-turn message).
|
|
432
|
-
*
|
|
433
|
-
* - approval RunState path (`modelHistoryFromItems === false`) — `state.history` was seeded
|
|
434
|
-
* from the blob, where foreign reasoning is NEUTRALIZED-IN-PLACE (the item is
|
|
435
|
-
* KEPT, only its id/encrypted_content go — see resumeRunStateForCodexAccount), so
|
|
436
|
-
* the blob's history length still COUNTS those items. Applying the strip here
|
|
437
|
-
* under-counts by K and the reconcile re-appends K already-persisted items at
|
|
438
|
-
* fresh positions — HOLE E. So the blob path must NOT strip: count the raw
|
|
439
|
-
* sanitized active length, which mirrors the blob's completed prefix.
|
|
440
|
-
*
|
|
441
|
-
* On a same-account / non-codex turn the strip is a no-op, so both branches reduce
|
|
442
|
-
* to the same raw sanitized count (byte-identical to the pre-strip behaviour).
|
|
443
|
-
* Pure; exported for unit testing the D/E seed invariant.
|
|
444
|
-
*/
|
|
445
|
-
export declare function reconcileSeedCount(activeSeedRows: ReadonlyArray<{
|
|
446
|
-
item: Record<string, unknown>;
|
|
447
|
-
producerCodexCredentialId: string | null;
|
|
448
|
-
}>, modelHistoryFromItems: boolean, current: TurnCodexAccount): number;
|
|
449
430
|
/**
|
|
450
431
|
* Resolve the EFFECTIVE/active compute backend a turn should gate
|
|
451
432
|
* filesystem-touching agent lifecycle hooks on (today: the repository clone).
|
|
@@ -43,7 +43,6 @@ export type RotationDecision = {
|
|
|
43
43
|
kind: "active";
|
|
44
44
|
credentialId: string;
|
|
45
45
|
moved: boolean;
|
|
46
|
-
droppedConnectors?: string[];
|
|
47
46
|
} | {
|
|
48
47
|
kind: "allCapped";
|
|
49
48
|
earliestResetAt: Date;
|
|
@@ -68,10 +67,10 @@ export declare const DEFAULT_RESET_COOLDOWN_MS = 60000;
|
|
|
68
67
|
/** Cached provider usage becomes unavailable only at actual exhaustion. */
|
|
69
68
|
export declare const CODEX_USAGE_EXHAUSTED_PCT = 100;
|
|
70
69
|
/**
|
|
71
|
-
* Healthy for an already-
|
|
70
|
+
* Healthy for an already-leased/in-flight turn = connected/usable (status
|
|
72
71
|
* "active", excludes needs_relogin/error), not cooling, and not exhausted in
|
|
73
72
|
* either provider window. Allocator eligibility is
|
|
74
|
-
* deliberately separate so disabling NEW work cannot break
|
|
73
|
+
* deliberately separate so disabling NEW work cannot break an existing live lease.
|
|
75
74
|
*/
|
|
76
75
|
export declare function isCodexCredentialHealthy(acct: CodexRotationAccount, now: Date): boolean;
|
|
77
76
|
/** New automatic allocation requires both health and explicit allocator eligibility. */
|
|
@@ -181,8 +180,8 @@ export declare const REACTIVE_PERSISTENCE_FAULT_FLOOR_MS = 5000;
|
|
|
181
180
|
* Circuit-breaker slack (Finding 1b) added to the connected-account count to bound
|
|
182
181
|
* consecutive reactive failovers. Each legitimate failover cools one account, so
|
|
183
182
|
* after at most N failovers every account is capped and the reactive path takes the
|
|
184
|
-
* all-capped idle instead; the +margin absorbs benign re-ranks
|
|
185
|
-
*
|
|
183
|
+
* all-capped idle instead; the +margin absorbs benign capacity re-ranks without
|
|
184
|
+
* tripping the breaker in normal use.
|
|
186
185
|
*/
|
|
187
186
|
export declare const REACTIVE_ROTATION_MARGIN = 2;
|
|
188
187
|
/**
|
|
@@ -229,7 +228,6 @@ export declare function chooseRotationActive(args: {
|
|
|
229
228
|
priorCredentialId: string | null;
|
|
230
229
|
accounts: CodexRotationAccount[];
|
|
231
230
|
now: Date;
|
|
232
|
-
usedConnectors?: string[];
|
|
233
231
|
}): RotationDecision;
|
|
234
232
|
/**
|
|
235
233
|
* Exact pre-0053 selector used while the lease cutover is off.
|
|
@@ -239,7 +237,7 @@ export declare function chooseRotationActive(args: {
|
|
|
239
237
|
* the same until BOTH the deployment flag and workspace cutover are enabled;
|
|
240
238
|
* otherwise a rolling fleet would run two allocators at once. When the active
|
|
241
239
|
* pointer is no longer eligible, zeroing the additive metadata delegates to the
|
|
242
|
-
* same capacity
|
|
240
|
+
* same capacity ranking that the old selector used.
|
|
243
241
|
*/
|
|
244
242
|
export declare function chooseLegacyRotationActive(args: Parameters<typeof chooseRotationActive>[0]): RotationDecision;
|
|
245
243
|
/**
|
|
@@ -255,7 +253,5 @@ export declare function selectCodexCredentialLeaseForTurn(args: {
|
|
|
255
253
|
sessionPinnedCredentialId: string | null;
|
|
256
254
|
sessionPinSource: CodexPinSource | null;
|
|
257
255
|
sessionLastCredentialId: string | null;
|
|
258
|
-
/** Same-turn checkpoint/frozen account; temporary disable cannot move it. */
|
|
259
|
-
continuationCredentialId?: string | null;
|
|
260
256
|
now: Date;
|
|
261
257
|
}): CodexTurnLeaseSelection;
|
|
@@ -2,7 +2,6 @@ import { type Database } from "@opengeni/db";
|
|
|
2
2
|
import { type CompactionItem } from "@opengeni/runtime";
|
|
3
3
|
import { type Settings } from "@opengeni/config";
|
|
4
4
|
import type { SessionEvent } from "@opengeni/contracts";
|
|
5
|
-
import { type TurnCodexAccount } from "./run-input";
|
|
6
5
|
export type MaybeCompactResult = {
|
|
7
6
|
compacted: false;
|
|
8
7
|
reason: string;
|
|
@@ -43,15 +42,12 @@ export declare function maybeCompactContext(db: Database, settings: Settings, sc
|
|
|
43
42
|
force?: boolean;
|
|
44
43
|
clearRequestedCompaction?: boolean;
|
|
45
44
|
trigger?: "auto" | "operator" | "proactive" | "overflow";
|
|
46
|
-
codexAccount?: TurnCodexAccount;
|
|
47
45
|
/** Frozen session mode; remote_v2 selects the Codex opaque path. */
|
|
48
46
|
codexCompactionMode?: "remote_v2" | "portable";
|
|
49
47
|
/** True when this turn's resolved provider is codex-subscription. */
|
|
50
48
|
isCodexSubscriptionTurn?: boolean;
|
|
51
49
|
/** Injected remote requester; required for the remote_v2 branch. */
|
|
52
50
|
requestRemoteCompactionV2?: RemoteCompactionV2Requester;
|
|
53
|
-
/** Tag persisted history with the Codex credential that produced it. */
|
|
54
|
-
producerCodexCredentialId?: string | null;
|
|
55
51
|
/**
|
|
56
52
|
* Live fanout for the attempt-fenced `compaction.started` event so the
|
|
57
53
|
* timeline can show progress before the provider call returns. Must never
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { claimDueTranscriptionRecordingObjectCleanup, claimExpiredFileUploadCleanup, completeDueTranscriptionRecordingObjectCleanup, completeExpiredFileUploadCleanup, purgeExpiredTranscriptionRecordings } from "@opengeni/db";
|
|
1
2
|
import type { ObjectStorage } from "@opengeni/storage";
|
|
2
3
|
import type { ActivityServices } from "./types";
|
|
3
4
|
export declare const FILE_UPLOAD_CLEANUP_GRACE_MS: number;
|
|
@@ -14,6 +15,11 @@ export type FileUploadReaperActivityOptions = {
|
|
|
14
15
|
batchSize?: number;
|
|
15
16
|
/** Failure-injection seam; production uses the configured provider delete. */
|
|
16
17
|
deleteObject?: (storage: ObjectStorage, key: string) => Promise<void>;
|
|
18
|
+
claimFileUploads?: typeof claimExpiredFileUploadCleanup;
|
|
19
|
+
completeFileUpload?: typeof completeExpiredFileUploadCleanup;
|
|
20
|
+
claimTranscriptionObjects?: typeof claimDueTranscriptionRecordingObjectCleanup;
|
|
21
|
+
completeTranscriptionObject?: typeof completeDueTranscriptionRecordingObjectCleanup;
|
|
22
|
+
purgeTranscriptionRecordings?: typeof purgeExpiredTranscriptionRecordings;
|
|
17
23
|
};
|
|
18
24
|
/**
|
|
19
25
|
* Build the provider-neutral expired direct-upload reaper. Claims are durable
|
|
@@ -1,89 +1,32 @@
|
|
|
1
1
|
import { FileResourceRef, type FileAsset, type ResourceRef } from "@opengeni/contracts";
|
|
2
2
|
import { getSessionEvent, type Database } from "@opengeni/db";
|
|
3
|
-
import { type OpenGeniRuntime } from "@opengeni/runtime";
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
* cross-account turn never replays another account's encrypted reasoning. The
|
|
7
|
-
* single rule across all paths: DROP any reasoning item whose producing codex
|
|
8
|
-
* account differs from `currentCodexCredentialId`.
|
|
9
|
-
*
|
|
10
|
-
* `currentCodexCredentialId` is the resolved codex credential id on a codex turn,
|
|
11
|
-
* or NULL on a non-codex turn (the "account" of the built-in Azure/OpenAI path).
|
|
12
|
-
* NULL is a real value in the comparison, not a "skip" sentinel: a non-codex turn
|
|
13
|
-
* (current = null) still drops codex-produced reasoning (producer != null) so a
|
|
14
|
-
* foreign encrypted blob never reaches the Azure/built-in Responses call. A
|
|
15
|
-
* session with no codex history (every producer == null == current) is a no-op.
|
|
16
|
-
*/
|
|
17
|
-
export type TurnCodexAccount = {
|
|
18
|
-
currentCodexCredentialId: string | null;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Apply the cross-account reasoning strip to a set of stored history rows. Pure +
|
|
22
|
-
* non-mutating. The single rule: a row whose producing codex account EQUALS the
|
|
23
|
-
* turn's current account replays verbatim (by reference); a row produced by a
|
|
24
|
-
* DIFFERENT account is treated by item type —
|
|
25
|
-
*
|
|
26
|
-
* - `reasoning` → DROPPED WHOLE (id + blob filtered out of the history). The
|
|
27
|
-
* foreign `rs_…` id is validated by the Responses backend, which rejects a
|
|
28
|
-
* reasoning item that has a foreign id and no encrypted_content (store:false),
|
|
29
|
-
* so blanking only the blob is not enough — the whole item must go.
|
|
30
|
-
* - `compaction` → kept, with only its account-bound `encrypted_content` blob
|
|
31
|
-
* stripped (its summary is real conversation content that must survive).
|
|
32
|
-
* - everything else (messages, tool calls, tool outputs) → kept verbatim by
|
|
33
|
-
* reference; message and tool content are never account-bound, never touched.
|
|
34
|
-
*
|
|
35
|
-
* Mismatch covers a foreign codex account, the non-codex/Azure producer (null on
|
|
36
|
-
* a codex turn), and legacy untagged rows (null): all are stripped, which is
|
|
37
|
-
* defensive and harmless (at most one turn of lost chain-of-thought continuity,
|
|
38
|
-
* never any content). No-op (rows by reference) when every producer equals the
|
|
39
|
-
* current account — a single-account workspace, an unchanged-account turn, or a
|
|
40
|
-
* non-codex turn over a history with no codex-produced reasoning.
|
|
41
|
-
*/
|
|
42
|
-
export declare function applyCodexHistoryStrip(rows: ReadonlyArray<{
|
|
3
|
+
import { type HistoryProviderApi, type OpenGeniRuntime } from "@opengeni/runtime";
|
|
4
|
+
/** Project only artifacts explicitly rejected by the provider out of its next view. */
|
|
5
|
+
export declare function projectRejectedProviderArtifacts(rows: ReadonlyArray<{
|
|
43
6
|
item: Record<string, unknown>;
|
|
44
|
-
producerCodexCredentialId: string | null;
|
|
45
7
|
providerArtifactInvalidatedAt?: Date | null;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
|
|
49
|
-
* the same cross-account rule as the canonical history-items path. The blob
|
|
50
|
-
* carries no per-item producer tag, so we
|
|
51
|
-
* compare the codex account that FROZE the state to the resuming turn's account:
|
|
52
|
-
* when they differ, neutralize every reasoning item's account-bound identity
|
|
53
|
-
* (encrypted_content + provider id) in the blob; when they match (including
|
|
54
|
-
* null == null for non-codex / single-account) the blob replays byte-for-byte
|
|
55
|
-
* (same string reference). This closes the gap where a frozen A-minted RunState
|
|
56
|
-
* was replayed verbatim into a turn that switched to account B (or to a non-codex
|
|
57
|
-
* turn), 400ing the resume.
|
|
58
|
-
*/
|
|
59
|
-
export declare function resumeRunStateForCodexAccount(state: {
|
|
8
|
+
}>): Array<Record<string, unknown>>;
|
|
9
|
+
/** Build the attempt-local RunState view after an explicit provider rejection. */
|
|
10
|
+
export declare function resumeRunState(state: {
|
|
60
11
|
serializedRunState: string;
|
|
61
|
-
frozenCodexCredentialId: string | null;
|
|
62
12
|
providerArtifactInvalidatedAt?: Date | null;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* A prepared turn input plus the watermark-seed discriminator the reconcile pass
|
|
66
|
-
* needs (HOLE E). `modelHistoryFromItems` is TRUE iff `state.history` was seeded
|
|
67
|
-
* from the cross-account-STRIPPED active history items (the items read path) — so
|
|
68
|
-
* the turn-end reconcile must seed `persistedHistoryCount` from the SAME strip
|
|
69
|
-
* (HOLE D). It is FALSE only when `state.history` was seeded from the approval
|
|
70
|
-
* RunState: there
|
|
71
|
-
* foreign reasoning is NEUTRALIZED-IN-PLACE by {@link resumeRunStateForCodexAccount}
|
|
72
|
-
* (the item is KEPT, only its id/encrypted_content go), so the blob's history
|
|
73
|
-
* length still COUNTS those items. Seeding the watermark with the strip on that
|
|
74
|
-
* path under-counts by K and the reconcile re-appends K already-persisted items at
|
|
75
|
-
* fresh positions — that is HOLE E. The watermark must therefore NOT strip on the
|
|
76
|
-
* blob path (count the raw sanitized active length, matching the blob).
|
|
77
|
-
*/
|
|
13
|
+
}): string;
|
|
14
|
+
/** Prepared input and its exact durable-history prefix length for reconciliation. */
|
|
78
15
|
export type PreparedTurnInput = {
|
|
79
16
|
input: Awaited<ReturnType<OpenGeniRuntime["prepareInput"]>>;
|
|
80
|
-
|
|
17
|
+
persistedHistoryCount: number;
|
|
18
|
+
providerArtifactCandidates: {
|
|
19
|
+
knownHistoryItemIds: string[];
|
|
20
|
+
historyItemIds: string[];
|
|
21
|
+
runStateId?: string;
|
|
22
|
+
};
|
|
81
23
|
};
|
|
82
24
|
export type TurnInputOptions = {
|
|
83
25
|
turnId: string;
|
|
84
26
|
recovering?: boolean;
|
|
85
27
|
unavailableSandboxFilesNote?: string;
|
|
86
28
|
runCredentialsNote?: string;
|
|
29
|
+
providerApi: HistoryProviderApi;
|
|
87
30
|
projectModelHistory?: ModelHistoryAttachmentProjector;
|
|
88
31
|
};
|
|
89
32
|
export declare const MAX_INLINE_MODEL_ATTACHMENT_BYTES: number;
|
|
@@ -108,5 +51,5 @@ export declare function modelAttachmentContentForFiles(files: FileAsset[], readF
|
|
|
108
51
|
export declare function createModelHistoryAttachmentProjector(db: Database, workspaceId: string, policy: ModelAttachmentInputPolicy, readFileBytes?: (file: FileAsset) => Promise<Uint8Array>): ModelHistoryAttachmentProjector;
|
|
109
52
|
/** Add current trigger refs only when older/local history predates durable stamping. */
|
|
110
53
|
export declare function withCurrentUserAttachmentRefs(historyItems: Array<Record<string, unknown>>, refs: FileResourceRef[]): Array<Record<string, unknown>>;
|
|
111
|
-
export declare function turnInput(db: Database, runtime: OpenGeniRuntime, agent: any, trigger: Awaited<ReturnType<typeof getSessionEvent>>,
|
|
54
|
+
export declare function turnInput(db: Database, runtime: OpenGeniRuntime, agent: any, trigger: Awaited<ReturnType<typeof getSessionEvent>>, options: TurnInputOptions): Promise<PreparedTurnInput>;
|
|
112
55
|
export declare function userMessageTextWithAttachments(db: Database, workspaceId: string, text: string, resources: ResourceRef[]): Promise<string>;
|