@opengeni/worker-bundle 0.15.1 → 0.16.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.
@@ -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 TurnCodexAccount } from "./run-input";
10
+ import { type ModelAttachmentInputPolicy, type TurnCodexAccount } 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";
@@ -592,6 +592,11 @@ export declare function computerToolModeForTurn(resolvedModel: {
592
592
  kind: RegistryProviderKind;
593
593
  api: ModelProviderApi;
594
594
  };
595
+ configured: {
596
+ capabilities: {
597
+ inputModalities: string[];
598
+ };
599
+ };
595
600
  } | null): ComputerToolMode;
596
601
  /** Gateway models do not advertise OpenAI's hosted apply_patch/view_image tool types. */
597
602
  export declare function structuredToolTransportForTurn(resolvedModel: {
@@ -611,18 +616,26 @@ export declare function hostedWebSearchForTurn(resolvedModel: {
611
616
  hostedWebSearch: boolean;
612
617
  };
613
618
  } | null, deploymentWebSearchEnabled: boolean): boolean;
614
- /**
615
- * Decide whether this turn's provider accepts typed file/image content in a
616
- * user message. The legacy built-in client and registry Responses clients use
617
- * the Agents SDK Responses converter, which supports `input_image` and
618
- * `input_file`. Chat-completions providers retain the sandbox-path projection
619
- * until that transport declares and proves an equivalent capability.
620
- */
621
- export declare function modelAcceptsTypedAttachmentContentForTurn(resolvedModel: {
619
+ /** Exact model-catalog modality gate; null preserves the legacy built-in path. */
620
+ export declare function modelSupportsImageInputForTurn(resolvedModel: {
621
+ configured: {
622
+ capabilities?: {
623
+ inputModalities: string[];
624
+ };
625
+ };
626
+ } | null): boolean;
627
+ /** Image and file input are independent catalogue capabilities. */
628
+ export declare function modelAttachmentInputPolicyForTurn(resolvedModel: {
622
629
  provider: {
623
630
  api: ModelProviderApi;
624
631
  };
625
- } | null): boolean;
632
+ configured: {
633
+ capabilities?: {
634
+ inputModalities: string[];
635
+ inputFileMediaTypes?: string[];
636
+ };
637
+ };
638
+ } | null): ModelAttachmentInputPolicy;
626
639
  export type TurnSandboxProvisioner<T> = {
627
640
  get(): Promise<T>;
628
641
  hasStarted(): boolean;
@@ -755,6 +768,7 @@ export type ModelUsageBillingRecord = {
755
768
  /** Same quantity written to usage_events.model.cost when present; else 0. */
756
769
  pricedCostMicros: number;
757
770
  normalizedUsage: ModelCallUsageNormalization;
771
+ upstreamProvider?: string;
758
772
  };
759
773
  export declare function recordModelUsageAndDebitCredits(settings: Settings, db: ActivityServices["db"], input: {
760
774
  accountId: string;
@@ -764,6 +778,8 @@ export declare function recordModelUsageAndDebitCredits(settings: Settings, db:
764
778
  turnAttemptId: string;
765
779
  model: string;
766
780
  externallyBilled: boolean;
781
+ gatewayManaged?: boolean;
782
+ gatewayBilling?: ModelResponseUsage["gatewayBilling"];
767
783
  usage?: ModelUsageInput | ModelCallUsageInput | null;
768
784
  normalizedUsage?: ModelCallUsageNormalization;
769
785
  sourceKey: string;
@@ -785,4 +801,5 @@ export declare function recordAuthoritativeModelCallFact(input: {
785
801
  model: string;
786
802
  billing: ModelUsageBillingRecord;
787
803
  }): Promise<void>;
804
+ export declare function requiresSignedFileResourceDownloads(settings: Settings, activeSandboxBackend?: Settings["sandboxBackend"]): boolean;
788
805
  export {};
@@ -58,6 +58,8 @@ export declare function maybeCompactContext(db: Database, settings: Settings, sc
58
58
  * append again — the event is already durable.
59
59
  */
60
60
  publishLiveEvents?: (events: SessionEvent[]) => Promise<void>;
61
+ /** Turn-scoped attachment/modality view; canonical persisted rows stay untouched. */
62
+ projectModelInput?: (items: CompactionItem[]) => Promise<CompactionItem[]>;
61
63
  }): Promise<MaybeCompactResult>;
62
64
  /**
63
65
  * After `compaction.started`, record a visible skip so the timeline cannot
@@ -19,6 +19,9 @@ export declare function createDocumentActivities(services: () => Promise<Activit
19
19
  sourceUpdatedAt: string | null;
20
20
  sourceVersion: string | null;
21
21
  aclTags: string[];
22
+ authorityKind: "organization" | "personal" | "workspace";
23
+ authorityWorkspaceId: string | null;
24
+ authoritySubjectId: string | null;
22
25
  visibility: "private" | "workspace";
23
26
  createdBy: string | null;
24
27
  agentAccess: boolean;
@@ -1,4 +1,4 @@
1
- import type { FileAsset, ResourceRef } from "@opengeni/contracts";
1
+ import { FileResourceRef, type FileAsset, type ResourceRef } from "@opengeni/contracts";
2
2
  import { getSessionEvent, type Database } from "@opengeni/db";
3
3
  import { type OpenGeniRuntime } from "@opengeni/runtime";
4
4
  /**
@@ -84,7 +84,7 @@ export type TurnInputOptions = {
84
84
  recovering?: boolean;
85
85
  unavailableSandboxFilesNote?: string;
86
86
  runCredentialsNote?: string;
87
- readFileBytesForModel?: (file: FileAsset) => Promise<Uint8Array>;
87
+ projectModelHistory?: ModelHistoryAttachmentProjector;
88
88
  };
89
89
  export declare const MAX_INLINE_MODEL_ATTACHMENT_BYTES: number;
90
90
  export type ModelAttachmentContent = {
@@ -94,13 +94,19 @@ export type ModelAttachmentContent = {
94
94
  contentType: string;
95
95
  dataUrl: string;
96
96
  };
97
+ export type ModelHistoryAttachmentProjector = (items: Array<Record<string, unknown>>) => Promise<Array<Record<string, unknown>>>;
98
+ export type ModelAttachmentInputPolicy = {
99
+ supportsImageInput: boolean;
100
+ inputFileMediaTypes: readonly string[];
101
+ };
97
102
  export declare function modelAttachmentContentForFiles(files: FileAsset[], readFileBytes: (file: FileAsset) => Promise<Uint8Array>): Promise<ModelAttachmentContent[]>;
98
103
  /**
99
- * Enrich the current turn's durable user boundary for this model attempt only.
100
- * The item count stays unchanged, so the turn reconciler still treats the
101
- * enriched row as the already-persisted prefix and never writes inline bytes to
102
- * session_history_items. Recovery rebuilds the same projection from the trigger.
104
+ * Build one turn-scoped durable-attachment projector. Metadata is batch-loaded
105
+ * and file bytes are memoized, so compaction/retry can reuse the same work and
106
+ * the SDK's repeated tool loop never touches storage or rescans old history.
103
107
  */
104
- export declare function withCurrentUserAttachmentContent(historyItems: Array<Record<string, unknown>>, attachments: ModelAttachmentContent[]): Array<Record<string, unknown>>;
108
+ export declare function createModelHistoryAttachmentProjector(db: Database, workspaceId: string, policy: ModelAttachmentInputPolicy, readFileBytes?: (file: FileAsset) => Promise<Uint8Array>): ModelHistoryAttachmentProjector;
109
+ /** Add current trigger refs only when older/local history predates durable stamping. */
110
+ export declare function withCurrentUserAttachmentRefs(historyItems: Array<Record<string, unknown>>, refs: FileResourceRef[]): Array<Record<string, unknown>>;
105
111
  export declare function turnInput(db: Database, runtime: OpenGeniRuntime, agent: any, trigger: Awaited<ReturnType<typeof getSessionEvent>>, current: TurnCodexAccount | undefined, options: TurnInputOptions): Promise<PreparedTurnInput>;
106
112
  export declare function userMessageTextWithAttachments(db: Database, workspaceId: string, text: string, resources: ResourceRef[]): Promise<string>;
@@ -1,5 +1,5 @@
1
1
  import type { Settings } from "@opengeni/config";
2
- import type { ConnectionCredentialsPort, EntitlementsPort, ScheduledTaskTriggerType, TurnInitiator } from "@opengeni/contracts";
2
+ import type { ConnectionCredentialsPort, DocumentAuthorityKind, EntitlementsPort, ScheduledTaskTriggerType, TurnInitiator } from "@opengeni/contracts";
3
3
  import type { Database } from "@opengeni/db";
4
4
  import type { DocumentServices } from "@opengeni/documents";
5
5
  import type { EventBus } from "@opengeni/events";
@@ -219,11 +219,22 @@ export type DispatchScheduledTaskRunResult = {
219
219
  workflowId: string;
220
220
  workflowWakeRevision: number | null;
221
221
  };
222
- export type IndexDocumentInput = {
222
+ type DocumentIndexIdentity = {
223
223
  accountId: string;
224
224
  workspaceId: string;
225
225
  documentId: string;
226
226
  };
227
+ type CurrentDocumentIndexAuthority = {
228
+ authorityKind: DocumentAuthorityKind;
229
+ authorityWorkspaceId: string | null;
230
+ authoritySubjectId: string | null;
231
+ };
232
+ type HistoricalDocumentIndexAuthority = {
233
+ authorityKind?: never;
234
+ authorityWorkspaceId?: never;
235
+ authoritySubjectId?: never;
236
+ };
237
+ export type IndexDocumentInput = DocumentIndexIdentity & (CurrentDocumentIndexAuthority | HistoricalDocumentIndexAuthority);
227
238
  type ClaimedRunAgentTurnResult = {
228
239
  status: "idle" | "requires_action" | "failed" | "cancelled" | "recovering" | "waiting_capacity";
229
240
  turnId: string;
@@ -29,6 +29,9 @@ export declare function createControlActivities(dependencies?: ActivityDependenc
29
29
  sourceUpdatedAt: string | null;
30
30
  sourceVersion: string | null;
31
31
  aclTags: string[];
32
+ authorityKind: "organization" | "personal" | "workspace";
33
+ authorityWorkspaceId: string | null;
34
+ authoritySubjectId: string | null;
32
35
  visibility: "private" | "workspace";
33
36
  createdBy: string | null;
34
37
  agentAccess: boolean;
@@ -135,6 +138,9 @@ export declare function createActivityTestHarness(dependencies?: ActivityDepende
135
138
  sourceUpdatedAt: string | null;
136
139
  sourceVersion: string | null;
137
140
  aclTags: string[];
141
+ authorityKind: "organization" | "personal" | "workspace";
142
+ authorityWorkspaceId: string | null;
143
+ authoritySubjectId: string | null;
138
144
  visibility: "private" | "workspace";
139
145
  createdBy: string | null;
140
146
  agentAccess: boolean;
@@ -229,6 +235,9 @@ export declare const indexDocument: (input: import("./activities").IndexDocument
229
235
  sourceUpdatedAt: string | null;
230
236
  sourceVersion: string | null;
231
237
  aclTags: string[];
238
+ authorityKind: "organization" | "personal" | "workspace";
239
+ authorityWorkspaceId: string | null;
240
+ authoritySubjectId: string | null;
232
241
  visibility: "private" | "workspace";
233
242
  createdBy: string | null;
234
243
  agentAccess: boolean;