@okrlinkhub/agent-factory 2.0.3 → 3.0.1

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.
Files changed (38) hide show
  1. package/README.md +102 -0
  2. package/dist/client/index.d.ts +53 -21
  3. package/dist/client/index.d.ts.map +1 -1
  4. package/dist/client/index.js +74 -3
  5. package/dist/client/index.js.map +1 -1
  6. package/dist/component/_generated/api.d.ts +2 -0
  7. package/dist/component/_generated/api.d.ts.map +1 -1
  8. package/dist/component/_generated/api.js.map +1 -1
  9. package/dist/component/_generated/component.d.ts +119 -2
  10. package/dist/component/_generated/component.d.ts.map +1 -1
  11. package/dist/component/identity.d.ts +6 -6
  12. package/dist/component/lib.d.ts +2 -1
  13. package/dist/component/lib.d.ts.map +1 -1
  14. package/dist/component/lib.js +2 -1
  15. package/dist/component/lib.js.map +1 -1
  16. package/dist/component/messageTemplates.d.ts +37 -0
  17. package/dist/component/messageTemplates.d.ts.map +1 -0
  18. package/dist/component/messageTemplates.js +177 -0
  19. package/dist/component/messageTemplates.js.map +1 -0
  20. package/dist/component/pushing.d.ts +37 -37
  21. package/dist/component/queue.d.ts +113 -90
  22. package/dist/component/queue.d.ts.map +1 -1
  23. package/dist/component/queue.js +122 -47
  24. package/dist/component/queue.js.map +1 -1
  25. package/dist/component/scheduler.d.ts +23 -23
  26. package/dist/component/schema.d.ts +86 -44
  27. package/dist/component/schema.d.ts.map +1 -1
  28. package/dist/component/schema.js +19 -1
  29. package/dist/component/schema.js.map +1 -1
  30. package/package.json +1 -1
  31. package/src/client/index.ts +76 -3
  32. package/src/component/_generated/api.ts +2 -0
  33. package/src/component/_generated/component.ts +159 -2
  34. package/src/component/lib.test.ts +125 -0
  35. package/src/component/lib.ts +8 -0
  36. package/src/component/messageTemplates.ts +205 -0
  37. package/src/component/queue.ts +165 -49
  38. package/src/component/schema.ts +22 -1
package/README.md CHANGED
@@ -614,6 +614,7 @@ Fork this repository to maintain your own image with your custom skills/assets.
614
614
 
615
615
  For `globalSkills` managed by this component, the recommended runtime pattern is different:
616
616
  - store the source of truth in component tables `globalSkills`, `globalSkillVersions`, `globalSkillReleases`
617
+ - treat each skill as a mini filesystem bundle (`files[]`), not as a single `sourceJs` blob
617
618
  - expose them through `getWorkerGlobalSkillsManifest`
618
619
  - let the worker image materialize them into `OPENCLAW_SKILLS_DIR` during prestart, before the OpenClaw gateway boots
619
620
 
@@ -622,6 +623,107 @@ The manifest now carries an explicit on-disk layout contract for OpenClaw worksp
622
623
  - `skillDirName`
623
624
  - `files[]` with `path`, `content`, `sha256`
624
625
 
626
+ Breaking change in `3.0.0`:
627
+ - `sourceJs` has been removed from the global skill model
628
+ - existing legacy global skill rows must be deleted before moving to `3.0.0`
629
+ - existing legacy skills must be republished as full bundles
630
+
631
+ Bundle contract for `3.0.0`:
632
+ - required user files:
633
+ - `SKILL.md`
634
+ - `scripts/index.mjs` or `scripts/index.cjs` (must match `moduleFormat`)
635
+ - optional user files:
636
+ - any extra script or asset needed by the skill, for example `scripts/agent-bridge-cli.mjs`
637
+ - system-generated file:
638
+ - `.af-global-skill.json` must not be provided by clients; it is injected by `agent-factory` during materialization
639
+
640
+ Extract a `Bundle files JSON` payload from an existing OpenClaw skill directory:
641
+
642
+ Use this when you already have a correctly materialized skill inside an OpenClaw workspace and want to republish it as a `3.0.0` global skill bundle.
643
+
644
+ Important:
645
+ - run the command against the skill directory itself (for example `/path/to/workspace/skills/agent-bridge`)
646
+ - the command automatically excludes `.af-global-skill.json`
647
+ - hidden files other than `.af-global-skill.json` are excluded by default
648
+ - the output is the JSON array to paste into the `Bundle files JSON` field in the admin UI
649
+
650
+ ```sh
651
+ node - <<'EOF' "/absolute/path/to/workspace/skills/agent-bridge"
652
+ const fs = require('fs')
653
+ const path = require('path')
654
+
655
+ const skillDir = process.argv[2]
656
+ if (!skillDir) {
657
+ console.error('Usage: node extract-skill-bundle.mjs /absolute/path/to/skill-dir')
658
+ process.exit(1)
659
+ }
660
+
661
+ function walk(dir, baseDir) {
662
+ const entries = fs.readdirSync(dir, { withFileTypes: true })
663
+ const files = []
664
+
665
+ for (const entry of entries) {
666
+ if (entry.name === '.af-global-skill.json') continue
667
+ if (entry.name.startsWith('.')) continue
668
+
669
+ const absolutePath = path.join(dir, entry.name)
670
+ if (entry.isDirectory()) {
671
+ files.push(...walk(absolutePath, baseDir))
672
+ continue
673
+ }
674
+
675
+ const relativePath = path.relative(baseDir, absolutePath).replaceAll(path.sep, '/')
676
+ files.push({
677
+ path: relativePath,
678
+ content: fs.readFileSync(absolutePath, 'utf8'),
679
+ })
680
+ }
681
+
682
+ return files
683
+ }
684
+
685
+ const bundle = walk(skillDir, skillDir).sort((left, right) => left.path.localeCompare(right.path))
686
+ console.log(JSON.stringify(bundle, null, 2))
687
+ EOF
688
+ ```
689
+
690
+ Example:
691
+
692
+ ```sh
693
+ node - <<'EOF' "/Users/me/openclaw/workspace/skills/agent-bridge"
694
+ const fs = require('fs')
695
+ const path = require('path')
696
+
697
+ const skillDir = process.argv[2]
698
+
699
+ function walk(dir, baseDir) {
700
+ const entries = fs.readdirSync(dir, { withFileTypes: true })
701
+ const files = []
702
+ for (const entry of entries) {
703
+ if (entry.name === '.af-global-skill.json') continue
704
+ if (entry.name.startsWith('.')) continue
705
+ const absolutePath = path.join(dir, entry.name)
706
+ if (entry.isDirectory()) {
707
+ files.push(...walk(absolutePath, baseDir))
708
+ continue
709
+ }
710
+ files.push({
711
+ path: path.relative(baseDir, absolutePath).replaceAll(path.sep, '/'),
712
+ content: fs.readFileSync(absolutePath, 'utf8'),
713
+ })
714
+ }
715
+ return files
716
+ }
717
+
718
+ console.log(JSON.stringify(walk(skillDir, skillDir).sort((a, b) => a.path.localeCompare(b.path)), null, 2))
719
+ EOF
720
+ ```
721
+
722
+ The resulting JSON should contain files like:
723
+ - `SKILL.md`
724
+ - `scripts/index.mjs`
725
+ - any extra files such as `scripts/agent-bridge-cli.mjs`
726
+
625
727
  Recommended worker bootstrap order:
626
728
  1. restore snapshot into `/data`
627
729
  2. fetch `workerGlobalSkillsManifest`
@@ -24,9 +24,9 @@ export declare function exposeApi(component: ComponentApi, options: {
24
24
  providerConfig: {
25
25
  appName: string;
26
26
  kind: "fly" | "runpod" | "ecs";
27
- region: string;
28
27
  organizationSlug: string;
29
28
  image: string;
29
+ region: string;
30
30
  volumeName: string;
31
31
  volumePath: string;
32
32
  volumeSizeGb: number;
@@ -39,14 +39,36 @@ export declare function exposeApi(component: ComponentApi, options: {
39
39
  telegramAttachmentRetentionMs?: number | undefined;
40
40
  };
41
41
  }, Promise<null>>;
42
+ createMessageTemplate: import("convex/server").RegisteredMutation<"public", {
43
+ enabled?: boolean | undefined;
44
+ actorUserId: string;
45
+ tags: string[];
46
+ text: string;
47
+ title: string;
48
+ }, Promise<any>>;
49
+ updateMessageTemplate: import("convex/server").RegisteredMutation<"public", {
50
+ enabled?: boolean | undefined;
51
+ tags?: string[] | undefined;
52
+ text?: string | undefined;
53
+ title?: string | undefined;
54
+ actorUserId: string;
55
+ templateId: string;
56
+ }, Promise<any>>;
57
+ deleteMessageTemplate: import("convex/server").RegisteredMutation<"public", {
58
+ templateId: string;
59
+ }, Promise<any>>;
60
+ listMessageTemplatesByCompany: import("convex/server").RegisteredQuery<"public", {
61
+ includeDisabled?: boolean | undefined;
62
+ limit?: number | undefined;
63
+ }, Promise<any>>;
42
64
  enqueue: import("convex/server").RegisteredMutation<"public", {
43
65
  metadata?: Record<string, string> | undefined;
44
66
  providerConfig?: {
45
67
  appName: string;
46
68
  kind: "fly" | "runpod" | "ecs";
47
- region: string;
48
69
  organizationSlug: string;
49
70
  image: string;
71
+ region: string;
50
72
  volumeName: string;
51
73
  volumePath: string;
52
74
  volumeSizeGb: number;
@@ -56,8 +78,8 @@ export declare function exposeApi(component: ComponentApi, options: {
56
78
  sizeBytes?: number | undefined;
57
79
  fileName?: string | undefined;
58
80
  mimeType?: string | undefined;
59
- storageId: string;
60
81
  status: "expired" | "ready";
82
+ storageId: string;
61
83
  kind: "photo" | "video" | "audio" | "voice" | "document";
62
84
  telegramFileId: string;
63
85
  expiresAt: number;
@@ -217,8 +239,8 @@ export declare function exposeApi(component: ComponentApi, options: {
217
239
  sizeBytes: number;
218
240
  }, Promise<any>>;
219
241
  workerFailSnapshotUpload: import("convex/server").RegisteredMutation<"public", {
220
- workerId: string;
221
242
  error: string;
243
+ workerId: string;
222
244
  snapshotId: string;
223
245
  }, Promise<any>>;
224
246
  workerLatestSnapshotForRestore: import("convex/server").RegisteredQuery<"public", {
@@ -243,17 +265,21 @@ export declare function exposeApi(component: ComponentApi, options: {
243
265
  releaseChannel?: "stable" | "canary" | undefined;
244
266
  version: string;
245
267
  slug: string;
246
- sourceJs: string;
268
+ files: {
269
+ content: string;
270
+ sha256: string;
271
+ path: string;
272
+ }[];
247
273
  }, Promise<any>>;
248
274
  globalSkillsList: import("convex/server").RegisteredQuery<"public", {
275
+ status?: "active" | "disabled" | undefined;
249
276
  limit?: number | undefined;
250
277
  releaseChannel?: "stable" | "canary" | undefined;
251
- status?: "active" | "disabled" | undefined;
252
278
  }, Promise<any>>;
253
279
  globalSkillsSetStatus: import("convex/server").RegisteredMutation<"public", {
254
280
  actor?: string | undefined;
255
- slug: string;
256
281
  status: "active" | "disabled";
282
+ slug: string;
257
283
  }, Promise<any>>;
258
284
  globalSkillsDelete: import("convex/server").RegisteredMutation<"public", {
259
285
  slug: string;
@@ -479,11 +505,11 @@ export declare function exposeApi(component: ComponentApi, options: {
479
505
  }, Promise<any>>;
480
506
  createPushTemplate: import("convex/server").RegisteredMutation<"public", {
481
507
  enabled?: boolean | undefined;
482
- companyId: string;
483
- periodicity: "manual" | "daily" | "weekly" | "monthly";
508
+ actorUserId: string;
484
509
  text: string;
485
510
  title: string;
486
- actorUserId: string;
511
+ companyId: string;
512
+ periodicity: "manual" | "daily" | "weekly" | "monthly";
487
513
  suggestedTimes: ({
488
514
  kind: "daily";
489
515
  time: string;
@@ -500,9 +526,9 @@ export declare function exposeApi(component: ComponentApi, options: {
500
526
  }, Promise<any>>;
501
527
  updatePushTemplate: import("convex/server").RegisteredMutation<"public", {
502
528
  enabled?: boolean | undefined;
503
- periodicity?: "manual" | "daily" | "weekly" | "monthly" | undefined;
504
529
  text?: string | undefined;
505
530
  title?: string | undefined;
531
+ periodicity?: "manual" | "daily" | "weekly" | "monthly" | undefined;
506
532
  suggestedTimes?: ({
507
533
  kind: "daily";
508
534
  time: string;
@@ -515,8 +541,8 @@ export declare function exposeApi(component: ComponentApi, options: {
515
541
  time: string;
516
542
  dayOfMonth: number | "last";
517
543
  })[] | undefined;
518
- templateId: string;
519
544
  actorUserId: string;
545
+ templateId: string;
520
546
  }, Promise<any>>;
521
547
  deletePushTemplate: import("convex/server").RegisteredMutation<"public", {
522
548
  templateId: string;
@@ -549,6 +575,8 @@ export declare function exposeApi(component: ComponentApi, options: {
549
575
  createPushJobCustom: import("convex/server").RegisteredMutation<"public", {
550
576
  enabled?: boolean | undefined;
551
577
  consumerUserId: string;
578
+ text: string;
579
+ title: string;
552
580
  companyId: string;
553
581
  periodicity: "manual" | "daily" | "weekly" | "monthly";
554
582
  schedule: {
@@ -565,12 +593,12 @@ export declare function exposeApi(component: ComponentApi, options: {
565
593
  time: string;
566
594
  dayOfMonth: number | "last";
567
595
  };
568
- text: string;
569
596
  timezone: string;
570
- title: string;
571
597
  }, Promise<any>>;
572
598
  updatePushJob: import("convex/server").RegisteredMutation<"public", {
573
599
  enabled?: boolean | undefined;
600
+ text?: string | undefined;
601
+ title?: string | undefined;
574
602
  periodicity?: "manual" | "daily" | "weekly" | "monthly" | undefined;
575
603
  schedule?: {
576
604
  kind: "manual";
@@ -586,9 +614,7 @@ export declare function exposeApi(component: ComponentApi, options: {
586
614
  time: string;
587
615
  dayOfMonth: number | "last";
588
616
  } | undefined;
589
- text?: string | undefined;
590
617
  timezone?: string | undefined;
591
- title?: string | undefined;
592
618
  jobId: string;
593
619
  }, Promise<any>>;
594
620
  deletePushJob: import("convex/server").RegisteredMutation<"public", {
@@ -623,6 +649,12 @@ export declare function exposeApi(component: ComponentApi, options: {
623
649
  consumerUserId: string;
624
650
  content: string;
625
651
  }, Promise<any>>;
652
+ sendMessageTemplateToUserAgent: import("convex/server").RegisteredMutation<"public", {
653
+ metadata?: Record<string, string> | undefined;
654
+ agentKey: string;
655
+ consumerUserId: string;
656
+ templateId: string;
657
+ }, Promise<any>>;
626
658
  listSnapshotsForConversation: import("convex/server").RegisteredQuery<"public", {
627
659
  limit?: number | undefined;
628
660
  conversationId: string;
@@ -670,6 +702,8 @@ export declare function exposeApi(component: ComponentApi, options: {
670
702
  enabled?: boolean | undefined;
671
703
  agentKey: string;
672
704
  consumerUserId: string;
705
+ text: string;
706
+ title: string;
673
707
  companyId: string;
674
708
  periodicity: "manual" | "daily" | "weekly" | "monthly";
675
709
  schedule: {
@@ -686,12 +720,12 @@ export declare function exposeApi(component: ComponentApi, options: {
686
720
  time: string;
687
721
  dayOfMonth: number | "last";
688
722
  };
689
- text: string;
690
723
  timezone: string;
691
- title: string;
692
724
  }, Promise<any>>;
693
725
  updatePushJobForAgent: import("convex/server").RegisteredMutation<"public", {
694
726
  enabled?: boolean | undefined;
727
+ text?: string | undefined;
728
+ title?: string | undefined;
695
729
  periodicity?: "manual" | "daily" | "weekly" | "monthly" | undefined;
696
730
  schedule?: {
697
731
  kind: "manual";
@@ -707,9 +741,7 @@ export declare function exposeApi(component: ComponentApi, options: {
707
741
  time: string;
708
742
  dayOfMonth: number | "last";
709
743
  } | undefined;
710
- text?: string | undefined;
711
744
  timezone?: string | undefined;
712
- title?: string | undefined;
713
745
  agentKey: string;
714
746
  consumerUserId: string;
715
747
  jobId: string;
@@ -741,9 +773,9 @@ export declare function exposeApi(component: ComponentApi, options: {
741
773
  limit?: number | undefined;
742
774
  }, Promise<any>>;
743
775
  sendBroadcastToAllActiveAgents: import("convex/server").RegisteredMutation<"public", {
744
- companyId: string;
745
776
  text: string;
746
777
  title: string;
778
+ companyId: string;
747
779
  requestedBy: string;
748
780
  }, Promise<any>>;
749
781
  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,CAAC;AAqEhC,OAAO,EACL,6BAA6B,EAC7B,qBAAqB,EACrB,gBAAgB,EAChB,0BAA0B,EAC1B,0BAA0B,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,GACjC,MAAM,aAAa,CAAC;AAErB,wBAAgB,SAAS,CACvB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE;IACP,IAAI,EAAE,CACJ,GAAG,EAAE;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,EACnB,SAAS,EACL;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAChB;QACE,IAAI,EAAE,OAAO,CAAC;QACd,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,KACF,OAAO,CAAC,MAAM,CAAC,CAAC;IACrB,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAyzC2poB,CAAC;2BAAmC,CAAC;;wBAAiE,CAAC;;wBAAwG,CAAC;yBAAiC,CAAC;;;;;6BAAyK,CAAC;;oBAA+D,CAAC;;;yBAAqH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAA45N,CAAC;2BAAmC,CAAC;;wBAAiE,CAAC;;wBAAwG,CAAC;yBAAiC,C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mentRetentionMs: v.optional(v.number()),
45
45
  });
46
+ const messageTemplateValidator = v.object({
47
+ title: v.string(),
48
+ text: v.string(),
49
+ tags: v.array(v.string()),
50
+ enabled: v.optional(v.boolean()),
51
+ actorUserId: v.string(),
52
+ });
53
+ const globalSkillManifestFileValidator = v.object({
54
+ path: v.string(),
55
+ content: v.string(),
56
+ sha256: v.string(),
57
+ });
46
58
  export { bridgeFunctionKeyFromToolName, executeBridgeFunction, isBridgeToolName, maybeExecuteBridgeToolCall, resolveBridgeRuntimeConfig, } from "./bridge.js";
47
59
  export function exposeApi(component, options) {
48
60
  return {
@@ -87,6 +99,46 @@ export function exposeApi(component, options) {
87
99
  return null;
88
100
  },
89
101
  }),
102
+ createMessageTemplate: mutationGeneric({
103
+ args: messageTemplateValidator,
104
+ handler: async (ctx, args) => {
105
+ await options.auth(ctx, { type: "write" });
106
+ return await ctx.runMutation(component.lib.createMessageTemplate, args);
107
+ },
108
+ }),
109
+ updateMessageTemplate: mutationGeneric({
110
+ args: {
111
+ templateId: v.string(),
112
+ title: v.optional(v.string()),
113
+ text: v.optional(v.string()),
114
+ tags: v.optional(v.array(v.string())),
115
+ enabled: v.optional(v.boolean()),
116
+ actorUserId: v.string(),
117
+ },
118
+ handler: async (ctx, args) => {
119
+ await options.auth(ctx, { type: "write" });
120
+ return await ctx.runMutation(component.lib.updateMessageTemplate, args);
121
+ },
122
+ }),
123
+ deleteMessageTemplate: mutationGeneric({
124
+ args: {
125
+ templateId: v.string(),
126
+ },
127
+ handler: async (ctx, args) => {
128
+ await options.auth(ctx, { type: "write" });
129
+ return await ctx.runMutation(component.lib.deleteMessageTemplate, args);
130
+ },
131
+ }),
132
+ listMessageTemplatesByCompany: queryGeneric({
133
+ args: {
134
+ includeDisabled: v.optional(v.boolean()),
135
+ limit: v.optional(v.number()),
136
+ },
137
+ handler: async (ctx, args) => {
138
+ await options.auth(ctx, { type: "read" });
139
+ return await ctx.runQuery(component.lib.listMessageTemplatesByCompany, args);
140
+ },
141
+ }),
90
142
  enqueue: mutationGeneric({
91
143
  args: {
92
144
  conversationId: v.string(),
@@ -315,7 +367,7 @@ export function exposeApi(component, options) {
315
367
  displayName: v.optional(v.string()),
316
368
  description: v.optional(v.string()),
317
369
  version: v.string(),
318
- sourceJs: v.string(),
370
+ files: v.array(globalSkillManifestFileValidator),
319
371
  entryPoint: v.optional(v.string()),
320
372
  moduleFormat: v.optional(v.union(v.literal("esm"), v.literal("cjs"))),
321
373
  releaseChannel: v.optional(v.union(v.literal("stable"), v.literal("canary"))),
@@ -852,6 +904,24 @@ export function exposeApi(component, options) {
852
904
  });
853
905
  },
854
906
  }),
907
+ sendMessageTemplateToUserAgent: mutationGeneric({
908
+ args: {
909
+ consumerUserId: v.string(),
910
+ agentKey: v.string(),
911
+ templateId: v.string(),
912
+ metadata: v.optional(v.record(v.string(), v.string())),
913
+ },
914
+ handler: async (ctx, args) => {
915
+ await options.auth(ctx, {
916
+ type: "write",
917
+ agentKey: args.agentKey,
918
+ });
919
+ return await ctx.runMutation(component.lib.sendMessageTemplateToUserAgent, {
920
+ ...args,
921
+ providerConfig: options.providerConfig,
922
+ });
923
+ },
924
+ }),
855
925
  listSnapshotsForConversation: queryGeneric({
856
926
  args: {
857
927
  conversationId: v.string(),
@@ -1151,7 +1221,8 @@ export function registerRoutes(http, component, { pathPrefix = "/agent-factory",
1151
1221
  if (attachmentCandidates.length > 0) {
1152
1222
  metadata.telegramMediaType = Array.from(new Set(attachmentCandidates.map((attachment) => attachment.kind))).join("+");
1153
1223
  for (const attachment of attachmentCandidates) {
1154
- const metadataKey = `telegram${attachment.kind[0].toUpperCase()}${attachment.kind.slice(1)}FileId`;
1224
+ const [firstLetter = ""] = attachment.kind;
1225
+ const metadataKey = `telegram${firstLetter.toUpperCase()}${attachment.kind.slice(1)}FileId`;
1155
1226
  metadata[metadataKey] = attachment.telegramFileId;
1156
1227
  }
1157
1228
  }
@@ -1184,7 +1255,7 @@ export function registerRoutes(http, component, { pathPrefix = "/agent-factory",
1184
1255
  }
1185
1256
  function parseStartCommandCode(messageText) {
1186
1257
  const match = messageText.match(/^\/start(?:@\w+)?\s+([A-Za-z0-9_-]{4,128})\s*$/);
1187
- return match ? match[1] : null;
1258
+ return match?.[1] ?? null;
1188
1259
  }
1189
1260
  function collectTelegramAttachmentCandidates(message) {
1190
1261
  const attachments = [];