@okrlinkhub/agent-factory 1.0.10 → 2.0.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/README.md CHANGED
@@ -67,6 +67,39 @@ crons.interval(
67
67
  export default crons;
68
68
  ```
69
69
 
70
+ ## Upgrade to 2.0.0
71
+
72
+ Version `2.0.0` introduces a **conversation identity breaking change**.
73
+
74
+ What changed:
75
+ - `conversationId` is now required for worker snapshot upload and restore APIs.
76
+ - `dataSnapshots.conversationId` is now mandatory in persisted storage.
77
+ - Snapshot restore no longer falls back to the latest archive for `workspaceId + agentKey`.
78
+ - User-agent flows now use a stable conversation identity scoped to `consumerUserId + agentKey`.
79
+ - Telegram pairing no longer changes the conversation lineage used for chat history and snapshots.
80
+
81
+ Important warnings:
82
+ - This release is intentionally **not backward compatible** with legacy snapshots created without `conversationId`.
83
+ - Existing non-prod agents, snapshots, bindings, and conversations created with the old model should be deleted before rollout.
84
+ - If a worker runtime or consumer app still calls snapshot APIs without `conversationId`, the call will now fail at validation time.
85
+ - If your integration assumed conversation IDs like `telegram:<chatId>` or `user:<consumerUserId>` for user-agent flows, you must update it to treat `conversationId` as an opaque stable identifier.
86
+ - If you have custom dashboards, scripts, or admin tools that query snapshots only by `agentKey`, they must be updated to scope by `workspaceId + agentKey + conversationId`.
87
+
88
+ Quick upgrade checklist:
89
+ 1. Delete legacy non-production agents, snapshots, conversations, and identity bindings created before this release.
90
+ 2. Upgrade the package to `2.0.0`.
91
+ 3. Regenerate Convex bindings in the consumer app.
92
+ 4. Redeploy all worker runtimes and make sure they always pass `conversationId` to snapshot upload/restore APIs.
93
+ 5. Update any custom integrations that assumed user-agent conversation IDs were derived from Telegram chat IDs.
94
+ 6. Verify that snapshot restore returns data only for the exact `workspaceId + agentKey + conversationId` tuple.
95
+ 7. Smoke-test one manual user-agent flow, one Telegram-paired flow, and one worker snapshot restore flow before wider rollout.
96
+
97
+ Recommended release notes to communicate to consumers:
98
+ - treat this as a major upgrade, not a safe drop-in patch;
99
+ - start from a clean non-prod environment;
100
+ - roll out workers and consumer app together;
101
+ - do not reuse legacy archives generated before `conversationId` became mandatory.
102
+
70
103
  ## Usage
71
104
 
72
105
  ### User-facing agent APIs
@@ -103,6 +136,10 @@ Core APIs added for this pattern:
103
136
  - `listSnapshotsForUserAgent`
104
137
  - `getLatestSnapshotForUserAgent`
105
138
 
139
+ For user-agent flows, the component now treats `conversationId` as a stable identity scoped to
140
+ `consumerUserId + agentKey`, so Telegram pairing changes do not move the chat to a different
141
+ conversation history or snapshot lineage.
142
+
106
143
  Minimal consumer example:
107
144
 
108
145
  ```ts
@@ -215,6 +252,10 @@ After enqueue, a **queue processor runtime** must process the queue by calling:
215
252
  - `components.agentFactory.lib.heartbeat`
216
253
  - `components.agentFactory.lib.complete` or `components.agentFactory.lib.fail`
217
254
 
255
+ When workers create or restore filesystem snapshots, `conversationId` must always be passed
256
+ explicitly alongside `workspaceId` and `agentKey`; the component no longer supports snapshot
257
+ fallbacks that select the latest archive for an agent without matching the conversation.
258
+
218
259
  Worker autoscaling reconcile now follows a hybrid model:
219
260
  - `enqueue` schedules an immediate async reconcile trigger (`runAfter(0, ...)`)
220
261
  - a periodic cron fallback is still recommended to recover from missed triggers
@@ -293,9 +334,17 @@ If you use `exposeApi(...)`, the worker contract is available directly on the co
293
334
  - `workerComplete`
294
335
  - `workerFail`
295
336
 
296
- ### Native integration with `agent-bridge` (no consumer glue code)
337
+ ### `agent-bridge`: config and secrets for OpenClaw workers
338
+
339
+ `agent-factory` does **not** execute `agent-bridge` tools.
297
340
 
298
- `agent-factory` now exposes a native contract for bridge execution. You only configure profile + secrets in the component.
341
+ Its role stops at:
342
+ - storing bridge settings on the agent profile
343
+ - resolving bridge secrets from the component secret store
344
+ - exposing `bridgeRuntimeConfig` in hydration
345
+ - forwarding bridge-related env vars to spawned OpenClaw workers
346
+
347
+ Tool execution belongs to the OpenClaw worker runtime / worker image, not to `agent-factory`.
299
348
 
300
349
  1) Configure an agent profile with bridge settings:
301
350
 
@@ -346,32 +395,8 @@ skills (`APP_BASE_URL_MAP_JSON`).
346
395
 
347
396
  Hydration includes `bridgeRuntimeConfig` for the worker loop.
348
397
 
349
- 3) In worker runtime use built-in helpers from this package:
350
-
351
- ```ts
352
- import {
353
- maybeExecuteBridgeToolCall,
354
- resolveBridgeRuntimeConfig,
355
- } from "@okrlinkhub/agent-factory";
356
-
357
- const resolved = resolveBridgeRuntimeConfig(hydration.bridgeRuntimeConfig);
358
- if (resolved.ok) {
359
- // Optional proactive resolution check
360
- }
361
-
362
- const toolResult = await maybeExecuteBridgeToolCall({
363
- toolName: pendingToolCall.toolName,
364
- toolArgs,
365
- hydratedConfig: hydration.bridgeRuntimeConfig,
366
- userToken: maybeUserJwtOrNull,
367
- });
368
- ```
369
-
370
- `maybeExecuteBridgeToolCall` handles:
371
- - `bridge.<functionKey>` mapping to `POST /agent/execute`
372
- - strict headers (`X-Agent-Service-Id`, `X-Agent-Service-Key`, `X-Agent-App`)
373
- - retry for `429` and `5xx`
374
- - deterministic response object to map back into conversation/tool messages
398
+ Do **not** treat `agent-factory` as the place where `bridge.<functionKey>` tool calls are executed.
399
+ If your OpenClaw agents use `agent-bridge`, that execution flow must live in the worker runtime itself.
375
400
 
376
401
  Fallback env (worker-side only, used when hydration misses values):
377
402
  - `OPENCLAW_AGENT_BRIDGE_BASE_URL` or `AGENT_BRIDGE_BASE_URL`
@@ -381,7 +406,7 @@ Fallback env (worker-side only, used when hydration misses values):
381
406
 
382
407
  ### Required Fly.io / component secrets for agent-bridge
383
408
 
384
- When `agent-factory` is connected to `agent-bridge`, every spawned worker must receive these three environment variables for bridge execution and user linking to work correctly:
409
+ When `agent-factory` is used together with `agent-bridge`, spawned workers may need these environment variables available in their runtime:
385
410
 
386
411
  | Env var | Component secret ref | Purpose |
387
412
  |---------|----------------------|---------|
@@ -389,7 +414,7 @@ When `agent-factory` is connected to `agent-bridge`, every spawned worker must r
389
414
  | `OPENCLAW_SERVICE_KEY` | `agent-bridge.serviceKey` | Service key for bridge auth |
390
415
  | `OPENCLAW_LINKING_SHARED_SECRET` | `agent-bridge.linkingSharedSecret` | Shared secret for `execute-on-behalf` user linking |
391
416
 
392
- The scheduler forwards these from the component secret store into each machine's env at spawn time. If any is missing, the worker may fail bridge calls (e.g. `403 delegation_denied` when linking is required).
417
+ The scheduler forwards these from the component secret store into each machine's env at spawn time. These values prepare the worker runtime for bridge usage; they do not implement bridge tool execution inside `agent-factory`.
393
418
 
394
419
  Import all three into the component secret store:
395
420
 
@@ -22,8 +22,8 @@ export declare function exposeApi(component: ComponentApi, options: {
22
22
  getProviderRuntimeConfig: import("convex/server").RegisteredQuery<"public", {}, Promise<any>>;
23
23
  setProviderRuntimeConfig: import("convex/server").RegisteredMutation<"public", {
24
24
  providerConfig: {
25
- appName: string;
26
25
  kind: "fly" | "runpod" | "ecs";
26
+ appName: string;
27
27
  organizationSlug: string;
28
28
  image: string;
29
29
  region: string;
@@ -39,10 +39,9 @@ export declare function exposeApi(component: ComponentApi, options: {
39
39
  };
40
40
  }, Promise<null>>;
41
41
  enqueue: import("convex/server").RegisteredMutation<"public", {
42
- metadata?: Record<string, string> | undefined;
43
42
  providerConfig?: {
44
- appName: string;
45
43
  kind: "fly" | "runpod" | "ecs";
44
+ appName: string;
46
45
  organizationSlug: string;
47
46
  image: string;
48
47
  region: string;
@@ -50,11 +49,12 @@ export declare function exposeApi(component: ComponentApi, options: {
50
49
  volumePath: string;
51
50
  volumeSizeGb: number;
52
51
  } | undefined;
53
- priority?: number | undefined;
54
52
  externalMessageId?: string | undefined;
55
53
  rawUpdateJson?: string | undefined;
56
- agentKey: string;
54
+ metadata?: Record<string, string> | undefined;
55
+ priority?: number | undefined;
57
56
  conversationId: string;
57
+ agentKey: string;
58
58
  provider: string;
59
59
  providerUserId: string;
60
60
  messageText: string;
@@ -90,18 +90,18 @@ export declare function exposeApi(component: ComponentApi, options: {
90
90
  };
91
91
  } | null>>;
92
92
  workerHeartbeat: import("convex/server").RegisteredMutation<"public", {
93
- messageId: string;
94
93
  workerId: string;
94
+ messageId: string;
95
95
  leaseId: string;
96
96
  }, Promise<boolean>>;
97
97
  workerComplete: import("convex/server").RegisteredMutation<"public", {
98
- messageId: string;
99
98
  workerId: string;
99
+ messageId: string;
100
100
  leaseId: string;
101
101
  }, Promise<boolean>>;
102
102
  workerFail: import("convex/server").RegisteredMutation<"public", {
103
- messageId: string;
104
103
  workerId: string;
104
+ messageId: string;
105
105
  leaseId: string;
106
106
  errorMessage: string;
107
107
  }, Promise<{
@@ -110,8 +110,8 @@ export declare function exposeApi(component: ComponentApi, options: {
110
110
  requeued: boolean;
111
111
  }>>;
112
112
  workerHydrationBundle: import("convex/server").RegisteredQuery<"public", {
113
- workspaceId: string;
114
113
  messageId: string;
114
+ workspaceId: string;
115
115
  }, Promise<{
116
116
  agentKey: string;
117
117
  bridgeRuntimeConfig: null | {
@@ -147,8 +147,8 @@ export declare function exposeApi(component: ComponentApi, options: {
147
147
  telegramBotToken: null | string;
148
148
  } | null>>;
149
149
  workerGlobalSkillsManifest: import("convex/server").RegisteredQuery<"public", {
150
- workspaceId?: string | undefined;
151
150
  workerId?: string | undefined;
151
+ workspaceId?: string | undefined;
152
152
  releaseChannel?: "stable" | "canary" | undefined;
153
153
  }, Promise<any>>;
154
154
  workerConversationHasQueued: import("convex/server").RegisteredQuery<"public", {
@@ -159,8 +159,8 @@ export declare function exposeApi(component: ComponentApi, options: {
159
159
  conversationId: string;
160
160
  messages: {
161
161
  at?: number | undefined;
162
- content: string;
163
162
  role: "system" | "user" | "assistant" | "tool";
163
+ content: string;
164
164
  }[];
165
165
  }, Promise<{
166
166
  messageCount: number;
@@ -170,26 +170,26 @@ export declare function exposeApi(component: ComponentApi, options: {
170
170
  workerId: string;
171
171
  }, Promise<any>>;
172
172
  workerPrepareSnapshotUpload: import("convex/server").RegisteredMutation<"public", {
173
- conversationId?: string | undefined;
173
+ conversationId: string;
174
174
  agentKey: string;
175
- workspaceId: string;
176
175
  workerId: string;
177
- reason: "manual" | "drain" | "signal";
176
+ workspaceId: string;
177
+ reason: "drain" | "signal" | "manual";
178
178
  }, Promise<any>>;
179
179
  workerFinalizeSnapshotUpload: import("convex/server").RegisteredMutation<"public", {
180
180
  workerId: string;
181
- storageId: string;
182
181
  snapshotId: string;
182
+ storageId: string;
183
183
  sha256: string;
184
184
  sizeBytes: number;
185
185
  }, Promise<any>>;
186
186
  workerFailSnapshotUpload: import("convex/server").RegisteredMutation<"public", {
187
- error: string;
188
187
  workerId: string;
189
188
  snapshotId: string;
189
+ error: string;
190
190
  }, Promise<any>>;
191
191
  workerLatestSnapshotForRestore: import("convex/server").RegisteredQuery<"public", {
192
- conversationId?: string | undefined;
192
+ conversationId: string;
193
193
  agentKey: string;
194
194
  workspaceId: string;
195
195
  }, Promise<any>>;
@@ -202,25 +202,25 @@ export declare function exposeApi(component: ComponentApi, options: {
202
202
  messageId: string;
203
203
  }, Promise<any>>;
204
204
  globalSkillsDeploy: import("convex/server").RegisteredMutation<"public", {
205
- actor?: string | undefined;
206
- description?: string | undefined;
205
+ releaseChannel?: "stable" | "canary" | undefined;
207
206
  displayName?: string | undefined;
207
+ description?: string | undefined;
208
208
  entryPoint?: string | undefined;
209
209
  moduleFormat?: "esm" | "cjs" | undefined;
210
- releaseChannel?: "stable" | "canary" | undefined;
211
- version: string;
210
+ actor?: string | undefined;
212
211
  slug: string;
212
+ version: string;
213
213
  sourceJs: string;
214
214
  }, Promise<any>>;
215
215
  globalSkillsList: import("convex/server").RegisteredQuery<"public", {
216
+ releaseChannel?: "stable" | "canary" | undefined;
216
217
  status?: "active" | "disabled" | undefined;
217
218
  limit?: number | undefined;
218
- releaseChannel?: "stable" | "canary" | undefined;
219
219
  }, Promise<any>>;
220
220
  globalSkillsSetStatus: import("convex/server").RegisteredMutation<"public", {
221
221
  actor?: string | undefined;
222
- status: "active" | "disabled";
223
222
  slug: string;
223
+ status: "active" | "disabled";
224
224
  }, Promise<any>>;
225
225
  globalSkillsDelete: import("convex/server").RegisteredMutation<"public", {
226
226
  slug: string;
@@ -291,8 +291,8 @@ export declare function exposeApi(component: ComponentApi, options: {
291
291
  bindUserAgent: import("convex/server").RegisteredMutation<"public", {
292
292
  metadata?: Record<string, string> | undefined;
293
293
  source?: "manual" | "telegram_pairing" | "api" | undefined;
294
- telegramChatId?: string | undefined;
295
294
  telegramUserId?: string | undefined;
295
+ telegramChatId?: string | undefined;
296
296
  agentKey: string;
297
297
  consumerUserId: string;
298
298
  }, Promise<{
@@ -345,8 +345,8 @@ export declare function exposeApi(component: ComponentApi, options: {
345
345
  consumerUserId: string;
346
346
  }, Promise<any>>;
347
347
  resolveAgentForTelegram: import("convex/server").RegisteredQuery<"public", {
348
- telegramChatId?: string | undefined;
349
348
  telegramUserId?: string | undefined;
349
+ telegramChatId?: string | undefined;
350
350
  }, Promise<{
351
351
  agentKey: null | string;
352
352
  consumerUserId: null | string;
@@ -372,8 +372,8 @@ export declare function exposeApi(component: ComponentApi, options: {
372
372
  consumerUserId: string;
373
373
  }, Promise<any>>;
374
374
  consumePairingCode: import("convex/server").RegisteredMutation<"public", {
375
- telegramChatId: string;
376
375
  telegramUserId: string;
376
+ telegramChatId: string;
377
377
  code: string;
378
378
  }, Promise<{
379
379
  agentKey: string;
@@ -406,8 +406,8 @@ export declare function exposeApi(component: ComponentApi, options: {
406
406
  importTelegramTokenForAgent: import("convex/server").RegisteredMutation<"public", {
407
407
  metadata?: Record<string, string> | undefined;
408
408
  agentKey: string;
409
- consumerUserId: string;
410
409
  plaintextValue: string;
410
+ consumerUserId: string;
411
411
  }, Promise<any>>;
412
412
  getUserAgentOnboardingState: import("convex/server").RegisteredQuery<"public", {
413
413
  agentKey: string;
@@ -443,11 +443,11 @@ export declare function exposeApi(component: ComponentApi, options: {
443
443
  }, Promise<any>>;
444
444
  createPushTemplate: import("convex/server").RegisteredMutation<"public", {
445
445
  enabled?: boolean | undefined;
446
- companyId: string;
447
446
  periodicity: "manual" | "daily" | "weekly" | "monthly";
448
- text: string;
447
+ companyId: string;
448
+ templateKey: string;
449
449
  title: string;
450
- actorUserId: string;
450
+ text: string;
451
451
  suggestedTimes: ({
452
452
  kind: "daily";
453
453
  time: string;
@@ -460,13 +460,12 @@ export declare function exposeApi(component: ComponentApi, options: {
460
460
  time: string;
461
461
  dayOfMonth: number | "last";
462
462
  })[];
463
- templateKey: string;
463
+ actorUserId: string;
464
464
  }, Promise<any>>;
465
465
  updatePushTemplate: import("convex/server").RegisteredMutation<"public", {
466
- enabled?: boolean | undefined;
467
466
  periodicity?: "manual" | "daily" | "weekly" | "monthly" | undefined;
468
- text?: string | undefined;
469
467
  title?: string | undefined;
468
+ text?: string | undefined;
470
469
  suggestedTimes?: ({
471
470
  kind: "daily";
472
471
  time: string;
@@ -479,8 +478,9 @@ export declare function exposeApi(component: ComponentApi, options: {
479
478
  time: string;
480
479
  dayOfMonth: number | "last";
481
480
  })[] | undefined;
482
- templateId: string;
481
+ enabled?: boolean | undefined;
483
482
  actorUserId: string;
483
+ templateId: string;
484
484
  }, Promise<any>>;
485
485
  deletePushTemplate: import("convex/server").RegisteredMutation<"public", {
486
486
  templateId: string;
@@ -507,14 +507,17 @@ export declare function exposeApi(component: ComponentApi, options: {
507
507
  } | undefined;
508
508
  consumerUserId: string;
509
509
  companyId: string;
510
- timezone: string;
511
510
  templateId: string;
511
+ timezone: string;
512
512
  }, Promise<any>>;
513
513
  createPushJobCustom: import("convex/server").RegisteredMutation<"public", {
514
514
  enabled?: boolean | undefined;
515
515
  consumerUserId: string;
516
- companyId: string;
517
516
  periodicity: "manual" | "daily" | "weekly" | "monthly";
517
+ companyId: string;
518
+ title: string;
519
+ text: string;
520
+ timezone: string;
518
521
  schedule: {
519
522
  kind: "manual";
520
523
  } | {
@@ -529,13 +532,13 @@ export declare function exposeApi(component: ComponentApi, options: {
529
532
  time: string;
530
533
  dayOfMonth: number | "last";
531
534
  };
532
- text: string;
533
- timezone: string;
534
- title: string;
535
535
  }, Promise<any>>;
536
536
  updatePushJob: import("convex/server").RegisteredMutation<"public", {
537
- enabled?: boolean | undefined;
538
537
  periodicity?: "manual" | "daily" | "weekly" | "monthly" | undefined;
538
+ title?: string | undefined;
539
+ text?: string | undefined;
540
+ enabled?: boolean | undefined;
541
+ timezone?: string | undefined;
539
542
  schedule?: {
540
543
  kind: "manual";
541
544
  } | {
@@ -550,9 +553,6 @@ export declare function exposeApi(component: ComponentApi, options: {
550
553
  time: string;
551
554
  dayOfMonth: number | "last";
552
555
  } | undefined;
553
- text?: string | undefined;
554
- timezone?: string | undefined;
555
- title?: string | undefined;
556
556
  jobId: string;
557
557
  }, Promise<any>>;
558
558
  deletePushJob: import("convex/server").RegisteredMutation<"public", {
@@ -572,7 +572,7 @@ export declare function exposeApi(component: ComponentApi, options: {
572
572
  }, Promise<any>>;
573
573
  listQueueItemsForUserAgent: import("convex/server").RegisteredQuery<"public", {
574
574
  limit?: number | undefined;
575
- statuses?: ("failed" | "done" | "queued" | "processing" | "dead_letter")[] | undefined;
575
+ statuses?: ("queued" | "processing" | "done" | "failed" | "dead_letter")[] | undefined;
576
576
  agentKey: string;
577
577
  consumerUserId: string;
578
578
  }, Promise<any>>;
@@ -584,8 +584,8 @@ export declare function exposeApi(component: ComponentApi, options: {
584
584
  sendMessageToUserAgent: import("convex/server").RegisteredMutation<"public", {
585
585
  metadata?: Record<string, string> | undefined;
586
586
  agentKey: string;
587
- consumerUserId: string;
588
587
  content: string;
588
+ consumerUserId: string;
589
589
  }, Promise<any>>;
590
590
  listSnapshotsForConversation: import("convex/server").RegisteredQuery<"public", {
591
591
  limit?: number | undefined;
@@ -627,15 +627,18 @@ export declare function exposeApi(component: ComponentApi, options: {
627
627
  agentKey: string;
628
628
  consumerUserId: string;
629
629
  companyId: string;
630
- timezone: string;
631
630
  templateId: string;
631
+ timezone: string;
632
632
  }, Promise<any>>;
633
633
  createPushJobCustomForAgent: import("convex/server").RegisteredMutation<"public", {
634
634
  enabled?: boolean | undefined;
635
635
  agentKey: string;
636
636
  consumerUserId: string;
637
- companyId: string;
638
637
  periodicity: "manual" | "daily" | "weekly" | "monthly";
638
+ companyId: string;
639
+ title: string;
640
+ text: string;
641
+ timezone: string;
639
642
  schedule: {
640
643
  kind: "manual";
641
644
  } | {
@@ -650,13 +653,13 @@ export declare function exposeApi(component: ComponentApi, options: {
650
653
  time: string;
651
654
  dayOfMonth: number | "last";
652
655
  };
653
- text: string;
654
- timezone: string;
655
- title: string;
656
656
  }, Promise<any>>;
657
657
  updatePushJobForAgent: import("convex/server").RegisteredMutation<"public", {
658
- enabled?: boolean | undefined;
659
658
  periodicity?: "manual" | "daily" | "weekly" | "monthly" | undefined;
659
+ title?: string | undefined;
660
+ text?: string | undefined;
661
+ enabled?: boolean | undefined;
662
+ timezone?: string | undefined;
660
663
  schedule?: {
661
664
  kind: "manual";
662
665
  } | {
@@ -671,9 +674,6 @@ export declare function exposeApi(component: ComponentApi, options: {
671
674
  time: string;
672
675
  dayOfMonth: number | "last";
673
676
  } | undefined;
674
- text?: string | undefined;
675
- timezone?: string | undefined;
676
- title?: string | undefined;
677
677
  agentKey: string;
678
678
  consumerUserId: string;
679
679
  jobId: string;
@@ -706,8 +706,8 @@ export declare function exposeApi(component: ComponentApi, options: {
706
706
  }, Promise<any>>;
707
707
  sendBroadcastToAllActiveAgents: import("convex/server").RegisteredMutation<"public", {
708
708
  companyId: string;
709
- text: string;
710
709
  title: string;
710
+ text: string;
711
711
  requestedBy: string;
712
712
  }, Promise<any>>;
713
713
  listPushDispatchesByJob: import("convex/server").RegisteredQuery<"public", {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,wBAAwB,CA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AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,YAAY,EACvB,EACE,UAA6B,EAC7B,eAAe,EACf,0BAAiC,EACjC,gBAA4B,EAC5B,yBAAiC,EACjC,cAAc,GACf,GAAE;IACD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAC;IAC9C,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,cAAc,CAAC,EAAE,cAAc,CAAC;CAC5B,QAoLP"}
@@ -226,7 +226,7 @@ export function exposeApi(component, options) {
226
226
  workerId: v.string(),
227
227
  workspaceId: v.string(),
228
228
  agentKey: v.string(),
229
- conversationId: v.optional(v.string()),
229
+ conversationId: v.string(),
230
230
  reason: v.union(v.literal("drain"), v.literal("signal"), v.literal("manual")),
231
231
  },
232
232
  handler: async (ctx, args) => {
@@ -262,7 +262,7 @@ export function exposeApi(component, options) {
262
262
  args: {
263
263
  workspaceId: v.string(),
264
264
  agentKey: v.string(),
265
- conversationId: v.optional(v.string()),
265
+ conversationId: v.string(),
266
266
  },
267
267
  handler: async (ctx, args) => {
268
268
  await options.auth(ctx, { type: "read" });
@@ -1106,12 +1106,17 @@ export function registerRoutes(http, component, { pathPrefix = "/agent-factory",
1106
1106
  headers: { "Content-Type": "application/json" },
1107
1107
  });
1108
1108
  }
1109
- const mapped = resolveAgentKeyFromBinding
1109
+ const mappedRaw = resolveAgentKeyFromBinding
1110
1110
  ? await ctx.runQuery(component.lib.resolveAgentForTelegram, {
1111
1111
  telegramUserId,
1112
1112
  telegramChatId,
1113
1113
  })
1114
- : { consumerUserId: null, agentKey: null };
1114
+ : { consumerUserId: null, agentKey: null, conversationId: null };
1115
+ const mapped = {
1116
+ consumerUserId: mappedRaw.consumerUserId,
1117
+ agentKey: mappedRaw.agentKey,
1118
+ conversationId: "conversationId" in mappedRaw ? mappedRaw.conversationId : null,
1119
+ };
1115
1120
  const configuredAgentKey = resolveAgentKey ? resolveAgentKey(update) : null;
1116
1121
  const agentKey = configuredAgentKey ?? mapped.agentKey ?? fallbackAgentKey;
1117
1122
  if (!agentKey || (requireBindingForTelegram && !configuredAgentKey && !mapped.agentKey)) {
@@ -1167,7 +1172,7 @@ export function registerRoutes(http, component, { pathPrefix = "/agent-factory",
1167
1172
  metadata.telegramVideoFileId = message.video.file_id;
1168
1173
  }
1169
1174
  await ctx.runMutation(component.lib.enqueue, {
1170
- conversationId: `telegram:${telegramChatId}`,
1175
+ conversationId: mapped.conversationId ?? `telegram:${telegramChatId}`,
1171
1176
  agentKey,
1172
1177
  payload: {
1173
1178
  provider: "telegram",