@opengeni/api-router 0.16.5 → 0.20.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.
@@ -0,0 +1,371 @@
1
+ import type { Settings } from "@opengeni/config";
2
+ import type { CodexRealtimeWebrtcRequest, CodexRealtimeWebrtcResponse } from "@opengeni/contracts";
3
+ import {
4
+ CODEX_CLIENT_VERSION,
5
+ CodexRealtimeError,
6
+ CodexReloginRequired,
7
+ createCodexRealtimeCall,
8
+ selectCodexCredentialId,
9
+ type CodexAuthHeaders,
10
+ type CodexFetch,
11
+ type CodexRealtimeInitialItem,
12
+ type CodexRealtimeCallInput,
13
+ } from "@opengeni/codex";
14
+ import {
15
+ buildCodexTokenResolver,
16
+ getActiveSessionHistoryItems,
17
+ getCodexCredentialStatus,
18
+ getSessionRealtimeContinuityEntries,
19
+ getSessionCodexState,
20
+ listCodexAccountStatuses,
21
+ type Database,
22
+ } from "@opengeni/db";
23
+ import { projectSessionRealtimeInitialItems } from "./session-realtime-context";
24
+
25
+ export type CodexRealtimeBrokerFailureReason =
26
+ | "subscription_disabled"
27
+ | "credential_unavailable"
28
+ | "reconnect_required"
29
+ | "invalid_request"
30
+ | "incompatible"
31
+ | "entitlement_denied"
32
+ | "rate_limited"
33
+ | "provider_error"
34
+ | "invalid_provider_response"
35
+ | "network_error"
36
+ | "timeout"
37
+ | "cancelled";
38
+
39
+ export class CodexRealtimeBrokerError extends Error {
40
+ constructor(
41
+ readonly reason: CodexRealtimeBrokerFailureReason,
42
+ message: string,
43
+ readonly providerStatus: number | null = null,
44
+ ) {
45
+ super(message);
46
+ this.name = "CodexRealtimeBrokerError";
47
+ }
48
+ }
49
+
50
+ type CodexTokenResolver = {
51
+ getToken(): Promise<Omit<CodexAuthHeaders, "clientVersion">>;
52
+ refresh(): Promise<Omit<CodexAuthHeaders, "clientVersion">>;
53
+ };
54
+
55
+ export type CodexRealtimeBrokerDependencies = {
56
+ enabled: boolean;
57
+ loadSelection(): Promise<{
58
+ pinnedCredentialId: string | null;
59
+ activeCredentialId: string | null;
60
+ connectedCredentialIds: ReadonlySet<string>;
61
+ }>;
62
+ loadInitialItems(): Promise<CodexRealtimeInitialItem[]>;
63
+ tokenResolver(credentialId: string): CodexTokenResolver;
64
+ createCall(
65
+ auth: CodexAuthHeaders,
66
+ input: CodexRealtimeCallInput,
67
+ options: { signal?: AbortSignal | undefined },
68
+ ): Promise<CodexRealtimeProviderAnswer>;
69
+ };
70
+
71
+ export type CodexRealtimeProviderAnswer = Pick<
72
+ CodexRealtimeWebrtcResponse,
73
+ "sdp" | "version" | "model"
74
+ >;
75
+
76
+ export type CodexRealtimeBrokerInput = {
77
+ sessionId: string;
78
+ request: Pick<CodexRealtimeWebrtcRequest, "sdp" | "version" | "instructions" | "voice">;
79
+ signal?: AbortSignal | undefined;
80
+ };
81
+
82
+ export const OPENGENI_REALTIME_BASE_INSTRUCTIONS = `## Identity, tone, and role
83
+
84
+ You are the realtime conversational interface for the current session.
85
+
86
+ Be concise, clear, and efficient. Keep responses tight and useful, with no fluff. Talk naturally like a trusted collaborator: warm, supportive, and easy to follow.
87
+
88
+ ## Interface and operating model
89
+
90
+ The backend handles execution and produces durable output and artifacts. You are the conversational surface of the same system.
91
+
92
+ Treat the system as one unified assistant. Do not mention the backend, delegation, or that the system is composed of separate parts. Present execution work and results as work done by you.
93
+
94
+ Pass execution work to the backend. Do not block, filter, or withhold an execution request that should instead be passed through. Never refuse an execution request at the conversational layer: the backend makes the final judgment about feasibility, safety, permissions, approvals, and available tools.
95
+
96
+ Treat backend outputs as authoritative. Do not override, contradict, embellish, or invent them.
97
+
98
+ Use conversation to support execution: clarify briefly when necessary, acknowledge meaningful progress, answer succinctly, and make the next step clear. Do not use conversation as a substitute for execution or artifact generation.
99
+
100
+ ## Session context
101
+
102
+ The initial conversation items are authoritative context from the current session. Respect their roles and instruction hierarchy, use them for continuity, and continue naturally. Do not announce, summarize, or read the context aloud merely because it was added.
103
+
104
+ Live context wrapped in <session_user_message> is an authoritative user message already routed to the current session. A status of queued_for_execution means it is waiting behind existing work; accepted_for_execution means it is next with no existing work ahead; accepted_for_steering means it was given priority as a change of direction, while any prior work may still be yielding. Incorporate it immediately as conversation context, but never delegate it again or treat the wrapper metadata as user-authored text.
105
+
106
+ Live context wrapped in <session_human_input_request> means current work is paused for the user's answer. Preserve the exact question meaning and options. Ask one question at a time when useful. The user may answer in the visible form or answer conversationally. If the user answers conversationally, create exactly one delegation containing the relevant question and the user's answer so the session agent can continue with complete context. If the user changes direction instead, delegate the new direction normally. Do not claim work resumed until session context confirms it.
107
+
108
+ Live context wrapped in <session_human_input_response> is the authoritative outcome of that pending question. An answered or skipped response came through the structured session UI and is already routed; incorporate it, never delegate it again, and acknowledge briefly only if useful. An expired or cancelled response means the question is no longer active.
109
+
110
+ Live session updates may describe work that started before this realtime conversation, work sent directly by the user, or work delegated during an earlier realtime connection. Treat those updates as part of this same session even when they have no current delegation identity.
111
+
112
+ ## Backend use
113
+
114
+ For actions or tasks, always use the backend. If it is unclear whether backend use would help, use it.
115
+
116
+ Respond directly only when the request is clearly self-contained and backend use would not meaningfully help.
117
+
118
+ Do not claim that you cannot perform an action or lack access to tools, session state, workspace state, files, code, terminals, deployments, connected services, or other execution capabilities. Pass the request to the backend and let it determine what is available.
119
+
120
+ Ask a clarifying question only when needed to avoid a materially harmful mistake or when essential information cannot reasonably be inferred. Otherwise, make a reasonable assumption and use the backend.
121
+
122
+ Give the backend a complete standalone task containing the user's requested outcome, constraints, and all relevant context already established in the conversation. Do not make the user repeat information you already have.
123
+
124
+ Create only one delegation for one execution request. Do not submit duplicates while waiting. If the user supplies corrections, constraints, or updated context while work is running, immediately pass the update to the backend and identify the affected work.
125
+
126
+ ## Progress and completion
127
+
128
+ Backend messages may be intermediate progress or final output. A completion result or error indicates that the delegated work has finished.
129
+
130
+ Do not claim success, completion, or a changed state until authoritative backend output confirms it. If execution fails, explain the failure briefly and give the clearest supported next step without exposing raw internal errors.
131
+
132
+ Use at most one short spoken acknowledgement before work that may take noticeable time. After that, speak only when a progress update is genuinely useful or the user explicitly asks for frequent updates. Do not fill waiting time with repeated reassurance.
133
+
134
+ ## Presenting results
135
+
136
+ Treat backend output and artifacts as the authoritative execution record. Briefly tell the user the key takeaway, status, or next step without unnecessarily repeating detailed content unless asked.
137
+
138
+ Do not read out or recreate tables, diffs, plots, code blocks, structured data, or other heavily formatted content by default. Present detailed backend content only when the user explicitly asks. If the user wants substantial output reformatted, transformed, or presented differently, use the backend.
139
+
140
+ ## Task-level user preferences
141
+
142
+ Treat instructions about update frequency, verbosity, pacing, detail level, and presentation style as active task-level preferences. Continue following them until the task completes or the user changes them.
143
+
144
+ ## Voice behavior
145
+
146
+ Keep direct answers to one or two short sentences by default. Ask one clarification question at a time. Give tool or execution results as the outcome first, followed only by the next useful action.
147
+
148
+ Only act on audio you understand with sufficient confidence. If speech is unclear, incomplete, ambiguous, or likely background conversation, ask for a brief clarification instead of guessing, reasoning from missing words, or using the backend.
149
+
150
+ ## Communication style
151
+
152
+ When the user makes a clear request, proceed directly. Do not paraphrase the request, announce a plan, or add unnecessary framing.
153
+
154
+ Avoid repetitive confirmation, filler, re-acknowledgement, and obvious play-by-play. By default, share progress only when it is brief, grounded, and genuinely useful.`;
155
+
156
+ const REALTIME_INSTRUCTIONS_MAX_BYTES = 32_768;
157
+
158
+ export function openGeniRealtimeInstructions(additional?: string): string {
159
+ const trimmed = additional?.trim();
160
+ if (!trimmed) return OPENGENI_REALTIME_BASE_INSTRUCTIONS;
161
+ const heading =
162
+ "\n\n## Additional realtime guidance\nFollow the guidance below for this conversation unless it conflicts with the operating, delegation, safety, permission, or context-handling rules above.\n";
163
+ const prefix = `${OPENGENI_REALTIME_BASE_INSTRUCTIONS}${heading}`;
164
+ const remaining = REALTIME_INSTRUCTIONS_MAX_BYTES - Buffer.byteLength(prefix, "utf8");
165
+ return `${prefix}${takeUtf8Head(trimmed, Math.max(0, remaining))}`;
166
+ }
167
+
168
+ function takeUtf8Head(value: string, maximumBytes: number): string {
169
+ if (Buffer.byteLength(value, "utf8") <= maximumBytes) return value;
170
+ const bytes = Buffer.from(value, "utf8");
171
+ let end = maximumBytes;
172
+ while (end > 0 && (bytes[end]! & 0xc0) === 0x80) end -= 1;
173
+ return bytes.subarray(0, end).toString("utf8");
174
+ }
175
+
176
+ /**
177
+ * Credential-bound server broker. Selection is identical to a turn (pin then
178
+ * workspace active), and only a provider 401 permits one forced refresh/retry.
179
+ */
180
+ export async function brokerSessionCodexRealtime(
181
+ deps: CodexRealtimeBrokerDependencies,
182
+ input: CodexRealtimeBrokerInput,
183
+ ): Promise<CodexRealtimeProviderAnswer> {
184
+ if (!deps.enabled) {
185
+ throw new CodexRealtimeBrokerError(
186
+ "subscription_disabled",
187
+ "Connected Codex subscription realtime is disabled",
188
+ );
189
+ }
190
+ const selection = await deps.loadSelection();
191
+ const credentialId = selectCodexCredentialId({
192
+ sessionPinnedCredentialId: selection.pinnedCredentialId,
193
+ activeCredentialId: selection.activeCredentialId,
194
+ connectedIds: selection.connectedCredentialIds,
195
+ });
196
+ if (!credentialId) {
197
+ throw new CodexRealtimeBrokerError(
198
+ "credential_unavailable",
199
+ "No connected Codex subscription is available for this session",
200
+ );
201
+ }
202
+
203
+ // This comes from active session_history_items after lifecycle owner proof;
204
+ // it is not accepted from the browser request and is replayed identically on
205
+ // the one authentication-only retry below.
206
+ const initialItems = await deps.loadInitialItems();
207
+
208
+ const resolver = deps.tokenResolver(credentialId);
209
+ let token: Omit<CodexAuthHeaders, "clientVersion">;
210
+ try {
211
+ token = await resolver.getToken();
212
+ } catch (error) {
213
+ throw credentialError(error);
214
+ }
215
+ const callInput: CodexRealtimeCallInput = {
216
+ ...input.request,
217
+ sessionId: input.sessionId,
218
+ initialItems,
219
+ instructions: openGeniRealtimeInstructions(input.request.instructions),
220
+ };
221
+ try {
222
+ return await deps.createCall({ ...token, clientVersion: CODEX_CLIENT_VERSION }, callInput, {
223
+ signal: input.signal,
224
+ });
225
+ } catch (error) {
226
+ if (!(error instanceof CodexRealtimeError) || error.code !== "authentication") {
227
+ throw brokerProviderError(error);
228
+ }
229
+ }
230
+
231
+ // A provider 401 is the only replay-safe credential lifecycle exception: the
232
+ // call was rejected before authentication, so force exactly one refresh and
233
+ // repeat the same SDP request once. No other provider outcome is retried.
234
+ try {
235
+ token = await resolver.refresh();
236
+ } catch (error) {
237
+ throw credentialError(error);
238
+ }
239
+ try {
240
+ return await deps.createCall({ ...token, clientVersion: CODEX_CLIENT_VERSION }, callInput, {
241
+ signal: input.signal,
242
+ });
243
+ } catch (error) {
244
+ if (error instanceof CodexRealtimeError && error.code === "authentication") {
245
+ throw new CodexRealtimeBrokerError(
246
+ "reconnect_required",
247
+ "Codex subscription must be reconnected for realtime",
248
+ error.providerStatus,
249
+ );
250
+ }
251
+ throw brokerProviderError(error);
252
+ }
253
+ }
254
+
255
+ /** Bind the pure broker to OpenGeni's encrypted DB credential lifecycle. */
256
+ export function buildSessionCodexRealtimeBroker(
257
+ db: Database,
258
+ settings: Settings,
259
+ workspaceId: string,
260
+ sessionId: string,
261
+ fetchImpl: CodexFetch = fetch,
262
+ ): (input: Omit<CodexRealtimeBrokerInput, "sessionId">) => Promise<CodexRealtimeProviderAnswer> {
263
+ return async (input) =>
264
+ await brokerSessionCodexRealtime(
265
+ {
266
+ enabled: settings.codexSubscriptionEnabled,
267
+ loadSelection: async () => {
268
+ const [sessionState, status, accounts] = await Promise.all([
269
+ getSessionCodexState(db, workspaceId, sessionId),
270
+ getCodexCredentialStatus(db, workspaceId),
271
+ listCodexAccountStatuses(db, workspaceId),
272
+ ]);
273
+ if (!sessionState) {
274
+ throw new CodexRealtimeBrokerError(
275
+ "credential_unavailable",
276
+ "Session is unavailable for Codex realtime",
277
+ );
278
+ }
279
+ return {
280
+ pinnedCredentialId: sessionState.pinnedCredentialId,
281
+ activeCredentialId: status?.credentialId ?? null,
282
+ connectedCredentialIds: new Set(
283
+ accounts
284
+ .filter((account) => account.status === "active")
285
+ .map((account) => account.id),
286
+ ),
287
+ };
288
+ },
289
+ loadInitialItems: async () => {
290
+ const [history, continuity] = await Promise.all([
291
+ getActiveSessionHistoryItems(db, workspaceId, sessionId),
292
+ getSessionRealtimeContinuityEntries(db, workspaceId, sessionId),
293
+ ]);
294
+ return projectSessionRealtimeInitialItems(history, continuity);
295
+ },
296
+ tokenResolver: (credentialId) =>
297
+ buildCodexTokenResolver(db, settings, workspaceId, credentialId),
298
+ createCall: async (auth, callInput, options) =>
299
+ await createCodexRealtimeCall(auth, callInput, fetchImpl, options),
300
+ },
301
+ { ...input, sessionId },
302
+ );
303
+ }
304
+
305
+ function credentialError(error: unknown): CodexRealtimeBrokerError {
306
+ if (error instanceof CodexReloginRequired) {
307
+ return new CodexRealtimeBrokerError(
308
+ "reconnect_required",
309
+ "Codex subscription must be reconnected for realtime",
310
+ );
311
+ }
312
+ return new CodexRealtimeBrokerError(
313
+ "credential_unavailable",
314
+ "Codex subscription credential is unavailable",
315
+ );
316
+ }
317
+
318
+ function brokerProviderError(error: unknown): CodexRealtimeBrokerError {
319
+ if (!(error instanceof CodexRealtimeError)) {
320
+ return new CodexRealtimeBrokerError("network_error", "Codex realtime provider request failed");
321
+ }
322
+ const reason: CodexRealtimeBrokerFailureReason =
323
+ error.code === "invalid_request"
324
+ ? "invalid_request"
325
+ : error.code === "incompatible"
326
+ ? "incompatible"
327
+ : error.code === "authentication"
328
+ ? "reconnect_required"
329
+ : error.code === "entitlement"
330
+ ? "entitlement_denied"
331
+ : error.code === "rate_limited"
332
+ ? "rate_limited"
333
+ : error.code === "invalid_response"
334
+ ? "invalid_provider_response"
335
+ : error.code === "timeout"
336
+ ? "timeout"
337
+ : error.code === "cancelled"
338
+ ? "cancelled"
339
+ : error.code === "network"
340
+ ? "network_error"
341
+ : "provider_error";
342
+ return new CodexRealtimeBrokerError(reason, safeBrokerMessage(reason), error.providerStatus);
343
+ }
344
+
345
+ function safeBrokerMessage(reason: CodexRealtimeBrokerFailureReason): string {
346
+ switch (reason) {
347
+ case "invalid_request":
348
+ return "Codex realtime request is invalid";
349
+ case "incompatible":
350
+ return "Connected Codex subscription is not compatible with realtime V3";
351
+ case "reconnect_required":
352
+ return "Codex subscription must be reconnected for realtime";
353
+ case "entitlement_denied":
354
+ return "Connected Codex subscription does not include realtime access";
355
+ case "rate_limited":
356
+ return "Codex realtime is rate limited";
357
+ case "invalid_provider_response":
358
+ return "Codex realtime returned an incompatible response";
359
+ case "timeout":
360
+ return "Codex realtime negotiation timed out";
361
+ case "cancelled":
362
+ return "Codex realtime negotiation was cancelled";
363
+ case "network_error":
364
+ case "provider_error":
365
+ return "Codex realtime provider request failed";
366
+ case "subscription_disabled":
367
+ return "Connected Codex subscription realtime is disabled";
368
+ case "credential_unavailable":
369
+ return "No connected Codex subscription is available for this session";
370
+ }
371
+ }
@@ -0,0 +1,143 @@
1
+ import {
2
+ VERCEL_AI_GATEWAY_AI_SDK_BASE_URL,
3
+ VERCEL_AI_GATEWAY_BASE_URL,
4
+ resolveAiGatewayRealtimeModel,
5
+ type Settings,
6
+ } from "@opengeni/config";
7
+ import type { GatewayRealtimeInitialItem, SessionRealtimeModel } from "@opengeni/contracts";
8
+ import {
9
+ getActiveSessionHistoryItems,
10
+ getSessionRealtimeContinuityEntries,
11
+ loadWorkspaceVercelAiGatewayApiKey,
12
+ type Database,
13
+ } from "@opengeni/db";
14
+
15
+ import { openGeniRealtimeInstructions } from "./codex-realtime";
16
+ import { projectSessionRealtimeInitialItems } from "./session-realtime-context";
17
+
18
+ export class GatewayRealtimeBrokerError extends Error {
19
+ constructor(
20
+ readonly code:
21
+ | "model_unavailable"
22
+ | "credential_unavailable"
23
+ | "provider_error"
24
+ | "invalid_provider_response",
25
+ message: string,
26
+ readonly providerStatus: number | null = null,
27
+ ) {
28
+ super(message);
29
+ this.name = "GatewayRealtimeBrokerError";
30
+ }
31
+ }
32
+
33
+ export type GatewayRealtimeConnectionSecret = {
34
+ token: string;
35
+ url: string;
36
+ upstreamModelId: string;
37
+ expiresAt: number | null;
38
+ initialItems: GatewayRealtimeInitialItem[];
39
+ instructions: string;
40
+ };
41
+
42
+ export async function createGatewayRealtimeConnectionSecret(input: {
43
+ db: Database;
44
+ settings: Settings;
45
+ workspaceId: string;
46
+ sessionId: string;
47
+ model: SessionRealtimeModel;
48
+ fetchImpl?: typeof fetch;
49
+ }): Promise<GatewayRealtimeConnectionSecret> {
50
+ const resolved = resolveAiGatewayRealtimeModel(input.model);
51
+ if (!resolved) {
52
+ throw new GatewayRealtimeBrokerError(
53
+ "model_unavailable",
54
+ "The selected model is not an AI Gateway realtime model",
55
+ );
56
+ }
57
+ const apiKey =
58
+ resolved.source === "managed"
59
+ ? input.settings.vercelAiGatewayApiKey
60
+ : await loadWorkspaceVercelAiGatewayApiKey(input.db, input.settings, input.workspaceId);
61
+ if (!apiKey) {
62
+ throw new GatewayRealtimeBrokerError(
63
+ "credential_unavailable",
64
+ resolved.source === "managed"
65
+ ? "OpenGeni Gateway voice is not configured"
66
+ : "The workspace AI Gateway connection is unavailable",
67
+ );
68
+ }
69
+
70
+ const [history, continuity, minted] = await Promise.all([
71
+ getActiveSessionHistoryItems(input.db, input.workspaceId, input.sessionId),
72
+ getSessionRealtimeContinuityEntries(input.db, input.workspaceId, input.sessionId),
73
+ mintGatewayClientSecret({
74
+ apiKey,
75
+ upstreamModelId: resolved.upstreamModelId,
76
+ fetchImpl: input.fetchImpl ?? fetch,
77
+ }),
78
+ ]);
79
+ return {
80
+ ...minted,
81
+ upstreamModelId: resolved.upstreamModelId,
82
+ initialItems: projectSessionRealtimeInitialItems(history, continuity),
83
+ instructions: openGeniRealtimeInstructions(),
84
+ };
85
+ }
86
+
87
+ async function mintGatewayClientSecret(input: {
88
+ apiKey: string;
89
+ upstreamModelId: string;
90
+ fetchImpl: typeof fetch;
91
+ }): Promise<{ token: string; url: string; expiresAt: number | null }> {
92
+ const mintUrl = new URL("/v1/realtime/client-secrets", VERCEL_AI_GATEWAY_BASE_URL);
93
+ let response: Response;
94
+ try {
95
+ response = await input.fetchImpl(mintUrl, {
96
+ method: "POST",
97
+ headers: {
98
+ authorization: `Bearer ${input.apiKey}`,
99
+ "content-type": "application/json",
100
+ "ai-gateway-auth-method": "api-key",
101
+ "ai-gateway-protocol-version": "0.0.1",
102
+ },
103
+ body: JSON.stringify({ model: input.upstreamModelId, expiresIn: 120 }),
104
+ });
105
+ } catch {
106
+ throw new GatewayRealtimeBrokerError(
107
+ "provider_error",
108
+ "AI Gateway realtime token request failed",
109
+ );
110
+ }
111
+ if (!response.ok) {
112
+ throw new GatewayRealtimeBrokerError(
113
+ response.status === 401 || response.status === 403
114
+ ? "credential_unavailable"
115
+ : "provider_error",
116
+ response.status === 401 || response.status === 403
117
+ ? "AI Gateway credentials were rejected"
118
+ : "AI Gateway realtime token request failed",
119
+ response.status,
120
+ );
121
+ }
122
+ const body = (await response.json().catch(() => null)) as Record<string, unknown> | null;
123
+ const token = body?.token;
124
+ const expiresAt = body?.expiresAt;
125
+ if (
126
+ typeof token !== "string" ||
127
+ token.length === 0 ||
128
+ (expiresAt !== undefined && expiresAt !== null && typeof expiresAt !== "number")
129
+ ) {
130
+ throw new GatewayRealtimeBrokerError(
131
+ "invalid_provider_response",
132
+ "AI Gateway returned an invalid realtime token",
133
+ response.status,
134
+ );
135
+ }
136
+ const url = new URL(`${VERCEL_AI_GATEWAY_AI_SDK_BASE_URL.replace(/^http/, "ws")}/realtime-model`);
137
+ url.searchParams.set("ai-model-id", input.upstreamModelId);
138
+ return {
139
+ token,
140
+ url: url.toString(),
141
+ expiresAt: typeof expiresAt === "number" ? expiresAt : null,
142
+ };
143
+ }
package/src/index.ts CHANGED
@@ -231,12 +231,13 @@ export async function createTemporalWorkflowClient(
231
231
  },
232
232
  };
233
233
  const documentIndexer: DocumentIndexClient = {
234
- indexDocument: async ({ accountId, workspaceId, documentId }) => {
234
+ indexDocument: async (input) => {
235
+ const { documentId } = input;
235
236
  const workflowId = `document-index-${documentId}-${crypto.randomUUID()}`;
236
237
  await temporal.workflow.start("documentIndexWorkflow", {
237
238
  taskQueue: settings.temporalTaskQueue,
238
239
  workflowId,
239
- args: [{ accountId, workspaceId, documentId }],
240
+ args: [input],
240
241
  });
241
242
  },
242
243
  };