robotrock 1.0.0 → 1.3.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.
Files changed (71) hide show
  1. package/dist/agent-admin.d.ts +82 -0
  2. package/dist/agent-admin.js +938 -0
  3. package/dist/agent-admin.js.map +1 -0
  4. package/dist/ai/index.d.ts +6 -5
  5. package/dist/ai/index.js +682 -225
  6. package/dist/ai/index.js.map +1 -1
  7. package/dist/ai/trigger.d.ts +4 -3
  8. package/dist/ai/trigger.js +682 -225
  9. package/dist/ai/trigger.js.map +1 -1
  10. package/dist/ai/workflow.d.ts +4 -3
  11. package/dist/ai/workflow.js +679 -222
  12. package/dist/ai/workflow.js.map +1 -1
  13. package/dist/auth-headers-qL-ZeEtd.d.ts +13 -0
  14. package/dist/{client-CzVmjXpz.d.ts → client-YO9Y1rkH.d.ts} +51 -10
  15. package/dist/eve/agent/index.d.ts +164 -0
  16. package/dist/eve/agent/index.js +2854 -0
  17. package/dist/eve/agent/index.js.map +1 -0
  18. package/dist/eve/index.d.ts +8 -0
  19. package/dist/eve/index.js +639 -0
  20. package/dist/eve/index.js.map +1 -0
  21. package/dist/eve/tools/admin/assign-tasks.d.ts +39 -0
  22. package/dist/eve/tools/admin/assign-tasks.js +1060 -0
  23. package/dist/eve/tools/admin/assign-tasks.js.map +1 -0
  24. package/dist/eve/tools/admin/manage-groups.d.ts +53 -0
  25. package/dist/eve/tools/admin/manage-groups.js +1218 -0
  26. package/dist/eve/tools/admin/manage-groups.js.map +1 -0
  27. package/dist/eve/tools/admin/manage-team-members.d.ts +45 -0
  28. package/dist/eve/tools/admin/manage-team-members.js +1160 -0
  29. package/dist/eve/tools/admin/manage-team-members.js.map +1 -0
  30. package/dist/eve/tools/admin/query-tasks.d.ts +71 -0
  31. package/dist/eve/tools/admin/query-tasks.js +1161 -0
  32. package/dist/eve/tools/admin/query-tasks.js.map +1 -0
  33. package/dist/eve/tools/catalog/search-products.d.ts +57 -0
  34. package/dist/eve/tools/catalog/search-products.js +94 -0
  35. package/dist/eve/tools/catalog/search-products.js.map +1 -0
  36. package/dist/eve/tools/identity/index.d.ts +8 -0
  37. package/dist/eve/tools/identity/index.js +234 -0
  38. package/dist/eve/tools/identity/index.js.map +1 -0
  39. package/dist/eve/tools/identity/my-access.d.ts +18 -0
  40. package/dist/eve/tools/identity/my-access.js +187 -0
  41. package/dist/eve/tools/identity/my-access.js.map +1 -0
  42. package/dist/eve/tools/identity/whoami.d.ts +44 -0
  43. package/dist/eve/tools/identity/whoami.js +117 -0
  44. package/dist/eve/tools/identity/whoami.js.map +1 -0
  45. package/dist/eve/tools/inbox/create-task.d.ts +114 -0
  46. package/dist/eve/tools/inbox/create-task.js +1785 -0
  47. package/dist/eve/tools/inbox/create-task.js.map +1 -0
  48. package/dist/eve/tools/inbox/index.d.ts +6 -0
  49. package/dist/eve/tools/inbox/index.js +1785 -0
  50. package/dist/eve/tools/inbox/index.js.map +1 -0
  51. package/dist/eve/tools/index.d.ts +24 -0
  52. package/dist/eve/tools/index.js +2848 -0
  53. package/dist/eve/tools/index.js.map +1 -0
  54. package/dist/index-DoQN48Bm.d.ts +200 -0
  55. package/dist/index.d.ts +8 -44
  56. package/dist/index.js +842 -137
  57. package/dist/index.js.map +1 -1
  58. package/dist/schemas/index.d.ts +6 -1
  59. package/dist/schemas/index.js +251 -59
  60. package/dist/schemas/index.js.map +1 -1
  61. package/dist/tenant-5YKDrdC-.d.ts +23 -0
  62. package/dist/{tool-approval-bridge-DbwUEBHv.d.ts → tool-approval-bridge-aMA79Z1B.d.ts} +1 -1
  63. package/dist/tool-reply-guidance-C3qrT1In.d.ts +25 -0
  64. package/dist/trigger/index.d.ts +2 -1
  65. package/dist/trigger/index.js +543 -127
  66. package/dist/trigger/index.js.map +1 -1
  67. package/dist/{trigger-BCKBbAV7.d.ts → trigger-CXrbKVCL.d.ts} +2 -2
  68. package/dist/workflow/index.d.ts +2 -1
  69. package/dist/workflow/index.js +543 -127
  70. package/dist/workflow/index.js.map +1 -1
  71. package/package.json +69 -8
@@ -196,7 +196,7 @@ function finishRobotRockHumanWaitOtel(session, handled, outcome) {
196
196
  }
197
197
 
198
198
  // src/schemas/index.ts
199
- import { z as z2 } from "zod";
199
+ import { z as z4 } from "zod";
200
200
 
201
201
  // ../core/src/utils/safe-url.ts
202
202
  var BLOCKED_HOSTNAMES = /* @__PURE__ */ new Set([
@@ -305,6 +305,25 @@ function isBlockedHostname(hostname) {
305
305
  }
306
306
  return isBlockedIpv4(host) || isBlockedIpv6(host);
307
307
  }
308
+ function isLoopbackHandlerUrl(urlString) {
309
+ let url;
310
+ try {
311
+ url = new URL(urlString);
312
+ } catch {
313
+ return false;
314
+ }
315
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
316
+ return false;
317
+ }
318
+ if (url.username || url.password) {
319
+ return false;
320
+ }
321
+ const host = url.hostname.toLowerCase();
322
+ return host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "[::1]" || host.endsWith(".localhost");
323
+ }
324
+ function isAllowedHandlerUrl(urlString) {
325
+ return isPublicHttpUrl(urlString) || isLoopbackHandlerUrl(urlString);
326
+ }
308
327
  function isPublicHttpUrl(urlString) {
309
328
  let url;
310
329
  try {
@@ -321,6 +340,7 @@ function isPublicHttpUrl(urlString) {
321
340
  return !isBlockedHostname(url.hostname);
322
341
  }
323
342
  var PUBLIC_HTTP_URL_ERROR = "URL must be a public http:// or https:// address";
343
+ var HANDLER_URL_ERROR = "Handler URL must be a public or loopback http:// or https:// address";
324
344
 
325
345
  // ../core/src/schemas/task.ts
326
346
  import { z } from "zod";
@@ -382,6 +402,9 @@ function validateContextPublicUrls(context2) {
382
402
  var safeUrlSchema = z.string().refine((url) => isPublicHttpUrl(url), {
383
403
  message: PUBLIC_HTTP_URL_ERROR
384
404
  });
405
+ var handlerUrlSchema = z.string().refine((url) => isAllowedHandlerUrl(url), {
406
+ message: HANDLER_URL_ERROR
407
+ });
385
408
  var jsonSchema7Schema = z.custom(
386
409
  (val) => typeof val === "object" && val !== null,
387
410
  { message: "Must be a valid JSON Schema object" }
@@ -391,7 +414,7 @@ var uiSchemaSchema = z.custom((val) => typeof val === "object" && val !== null,
391
414
  });
392
415
  var webhookHandlerSchema = z.object({
393
416
  type: z.literal("webhook"),
394
- url: safeUrlSchema,
417
+ url: handlerUrlSchema,
395
418
  headers: z.record(z.string(), z.string())
396
419
  });
397
420
  var triggerHandlerSchema = webhookHandlerSchema.extend({
@@ -542,86 +565,253 @@ var agentChatSeedMessageSchema = z.object({
542
565
  action: agentChatSeedActionSchema
543
566
  }).optional()
544
567
  });
568
+ var eveAgentChatTransportSchema = z.object({
569
+ kind: z.literal("eve"),
570
+ chatId: z.string().min(1),
571
+ baseUrl: z.string().url(),
572
+ sessionId: z.string().optional(),
573
+ continuationToken: z.string().optional(),
574
+ streamIndex: z.number().int().nonnegative().optional(),
575
+ isStreaming: z.boolean().optional()
576
+ });
545
577
  var createAgentChatBodySchema = z.object({
546
- /** Trigger chat agent id (task slug). Required unless `parentChatId` is set. */
578
+ /** Agent id (eve agent name). Required unless `parentChatId` is set. */
547
579
  agentIdentifier: z.string().min(1).optional(),
548
580
  /** Inherit tenant/connection/agent from an existing chat (agent-spawned chats). */
549
581
  parentChatId: z.string().min(1).optional(),
550
- /** Convex tenantTriggerConnections id; resolved from the tenant when omitted. */
551
- connectionId: z.string().min(1).optional(),
582
+ /** Convex tenantEveConnections id; resolved from the tenant when omitted. */
583
+ eveConnectionId: z.string().min(1).optional(),
552
584
  /** Source application id; groups the chat under an inbox section. */
553
585
  app: z.string().min(1).optional(),
554
- assignTo: assignToSchema.optional(),
586
+ /** Email of the user who owns the chat. Required unless `parentChatId` is set. */
587
+ ownerEmail: z.string().email().optional(),
555
588
  title: z.string().min(1),
556
589
  messages: z.array(agentChatSeedMessageSchema).default([]),
557
590
  /** Provenance label stored on the session ("cron" | "agent" | ...). */
558
591
  source: z.string().min(1).optional()
559
592
  }).refine((data) => Boolean(data.agentIdentifier || data.parentChatId), {
560
593
  message: "Provide either agentIdentifier or parentChatId"
594
+ }).refine((data) => Boolean(data.ownerEmail || data.parentChatId), {
595
+ message: "Provide ownerEmail unless parentChatId is set"
561
596
  });
562
- var agentChatTransportBodySchema = z.object({
563
- chatId: z.string().min(1),
564
- publicAccessToken: z.string().min(1),
565
- lastEventId: z.string().optional(),
566
- isStreaming: z.boolean().optional()
597
+ var agentChatAuditToolBodySchema = z.object({
598
+ eveSessionId: z.string().min(1),
599
+ userId: z.string().min(1),
600
+ toolCallId: z.string().min(1),
601
+ toolName: z.string().min(1),
602
+ input: z.record(z.string(), z.unknown()).default({}),
603
+ success: z.boolean(),
604
+ status: z.enum(["completed", "failed", "rejected"]),
605
+ error: z.string().optional(),
606
+ idempotencyKey: z.string().optional()
607
+ });
608
+ var agentChatAuditInputBodySchema = z.object({
609
+ eveSessionId: z.string().min(1),
610
+ userId: z.string().min(1),
611
+ actionId: z.string().min(1),
612
+ actionTitle: z.string().optional(),
613
+ prompt: z.string().optional(),
614
+ data: z.record(z.string(), z.unknown()).optional(),
615
+ idempotencyKey: z.string().optional(),
616
+ /** Eve input request id — used to merge staged HITL metadata. */
617
+ requestId: z.string().optional(),
618
+ /** Eve tool call id — fallback lookup for staged HITL metadata. */
619
+ toolCallId: z.string().optional()
620
+ });
621
+ var eveHitlStagedOptionSchema = z.object({
622
+ id: z.string(),
623
+ label: z.string()
624
+ });
625
+ var agentChatStageHitlBodySchema = z.object({
626
+ eveSessionId: z.string().min(1),
627
+ requests: z.array(
628
+ z.object({
629
+ requestId: z.string().min(1),
630
+ toolCallId: z.string().min(1),
631
+ toolName: z.string().min(1),
632
+ prompt: z.string().min(1),
633
+ display: z.enum(["confirmation", "select", "text"]).optional(),
634
+ allowFreeform: z.boolean().optional(),
635
+ options: z.array(eveHitlStagedOptionSchema).optional(),
636
+ toolInput: z.record(z.string(), z.unknown()).optional()
637
+ })
638
+ )
639
+ });
640
+ var agentChatLinkTaskBodySchema = z.object({
641
+ eveSessionId: z.string().min(1),
642
+ publicTaskId: z.string().min(1),
643
+ toolCallId: z.string().min(1)
644
+ });
645
+
646
+ // ../core/src/schemas/tool-result-display.ts
647
+ import { z as z2 } from "zod";
648
+ var toolDisplayMetadataSchema = z2.object({
649
+ widget: z2.string().optional(),
650
+ title: z2.string().optional(),
651
+ description: z2.string().optional()
652
+ });
653
+ var toolDisplayEnvelopeSchema = z2.object({
654
+ display: toolDisplayMetadataSchema.optional(),
655
+ data: z2.record(z2.string(), z2.unknown()),
656
+ ui: z2.record(
657
+ z2.string(),
658
+ z2.object({
659
+ "ui:widget": z2.string().optional(),
660
+ "ui:title": z2.string().optional(),
661
+ "ui:description": z2.string().optional(),
662
+ "ui:options": z2.record(z2.string(), z2.unknown()).optional()
663
+ }).passthrough()
664
+ ).optional()
665
+ });
666
+
667
+ // ../core/src/schemas/agent-admin.ts
668
+ import { z as z3 } from "zod";
669
+ var tenantRoleSchema = z3.enum(["admin", "member"]);
670
+ var agentAdminUserSchema = z3.object({
671
+ id: z3.string(),
672
+ email: z3.string().email(),
673
+ name: z3.string()
674
+ });
675
+ var agentAdminMemberSchema = z3.object({
676
+ userId: z3.string(),
677
+ role: z3.string(),
678
+ membershipKind: z3.enum(["team", "assignee"]),
679
+ hasLoggedIn: z3.boolean(),
680
+ user: agentAdminUserSchema
681
+ });
682
+ var agentAdminGroupSchema = z3.object({
683
+ id: z3.string(),
684
+ name: z3.string(),
685
+ slug: z3.string(),
686
+ description: z3.string().nullable(),
687
+ memberCount: z3.number().optional()
688
+ });
689
+ var agentAdminGroupDetailSchema = agentAdminGroupSchema.extend({
690
+ members: z3.array(
691
+ z3.object({
692
+ userId: z3.string(),
693
+ user: agentAdminUserSchema
694
+ })
695
+ )
696
+ });
697
+ var agentAdminTaskSummarySchema = z3.object({
698
+ id: z3.string(),
699
+ convexId: z3.string(),
700
+ status: z3.string(),
701
+ type: z3.string().nullable(),
702
+ name: z3.string().nullable(),
703
+ description: z3.string().nullable(),
704
+ validUntil: z3.number(),
705
+ createdAt: z3.number(),
706
+ threadPriority: z3.string().nullable(),
707
+ handledByUserId: z3.string().nullable()
708
+ });
709
+ var inviteMemberBodySchema = z3.object({
710
+ email: z3.string().email(),
711
+ role: tenantRoleSchema.optional()
712
+ });
713
+ var updateMemberRoleBodySchema = z3.object({
714
+ role: tenantRoleSchema
715
+ });
716
+ var createGroupBodySchema = z3.object({
717
+ name: z3.string().min(1),
718
+ description: z3.string().optional()
719
+ });
720
+ var updateGroupBodySchema = z3.object({
721
+ name: z3.string().min(1).optional(),
722
+ description: z3.string().optional()
723
+ });
724
+ var addGroupMemberBodySchema = z3.object({
725
+ userId: z3.string().min(1).describe("Convex user id or member email.")
726
+ });
727
+ var listTasksQuerySchema = z3.object({
728
+ statusFilter: z3.enum(["all", "open", "handled", "expired"]).optional(),
729
+ typeFilter: z3.string().optional(),
730
+ appFilter: z3.string().optional(),
731
+ sortField: z3.enum(["type", "date", "status", "validUntil"]).optional(),
732
+ sortDirection: z3.enum(["asc", "desc"]).optional(),
733
+ limit: z3.coerce.number().int().positive().max(100).optional(),
734
+ cursor: z3.string().optional()
735
+ });
736
+ var searchTasksQuerySchema = z3.object({
737
+ q: z3.string().min(1),
738
+ limit: z3.coerce.number().int().positive().max(100).optional()
739
+ });
740
+ var assignTasksResultSchema = z3.object({
741
+ taskId: z3.string(),
742
+ success: z3.boolean(),
743
+ message: z3.string().optional(),
744
+ name: z3.string().nullable().optional(),
745
+ description: z3.string().nullable().optional(),
746
+ type: z3.string().nullable().optional()
747
+ });
748
+ var assignTasksResponseSchema = z3.object({
749
+ results: z3.array(assignTasksResultSchema)
750
+ });
751
+ var assignTasksBodySchema = z3.object({
752
+ taskIds: z3.array(z3.string().min(1)).min(1).max(100),
753
+ assignTo: assignToSchema.refine(
754
+ (value) => (value.users?.length ?? 0) > 0 || (value.groups?.length ?? 0) > 0,
755
+ { message: "assignTo needs at least one user email or group slug." }
756
+ )
567
757
  });
568
758
 
569
759
  // src/schemas/index.ts
570
- var safeUrlSchema2 = z2.string().refine((url) => isPublicHttpUrl(url), {
571
- message: PUBLIC_HTTP_URL_ERROR
760
+ var handlerUrlSchema2 = z4.string().refine((url) => isAllowedHandlerUrl(url), {
761
+ message: HANDLER_URL_ERROR
572
762
  });
573
- var jsonSchema7Schema2 = z2.custom(
763
+ var jsonSchema7Schema2 = z4.custom(
574
764
  (val) => typeof val === "object" && val !== null,
575
765
  { message: "Must be a valid JSON Schema object" }
576
766
  );
577
- var uiSchemaSchema2 = z2.custom((val) => typeof val === "object" && val !== null, {
767
+ var uiSchemaSchema2 = z4.custom((val) => typeof val === "object" && val !== null, {
578
768
  message: "Must be a valid UiSchema object"
579
769
  });
580
- var webhookHandlerSchema2 = z2.object({
581
- type: z2.literal("webhook"),
582
- url: safeUrlSchema2,
583
- headers: z2.record(z2.string(), z2.string())
770
+ var webhookHandlerSchema2 = z4.object({
771
+ type: z4.literal("webhook"),
772
+ url: handlerUrlSchema2,
773
+ headers: z4.record(z4.string(), z4.string())
584
774
  });
585
775
  var triggerHandlerSchema2 = webhookHandlerSchema2.extend({
586
- type: z2.literal("trigger"),
587
- tokenId: z2.string().min(1)
776
+ type: z4.literal("trigger"),
777
+ tokenId: z4.string().min(1)
588
778
  });
589
- var handlerSchema2 = z2.discriminatedUnion("type", [webhookHandlerSchema2, triggerHandlerSchema2]);
590
- var taskActionInputSchema2 = z2.object({
591
- id: z2.string().min(1),
592
- title: z2.string().min(1),
593
- description: z2.string().optional(),
779
+ var handlerSchema2 = z4.discriminatedUnion("type", [webhookHandlerSchema2, triggerHandlerSchema2]);
780
+ var taskActionInputSchema2 = z4.object({
781
+ id: z4.string().min(1),
782
+ title: z4.string().min(1),
783
+ description: z4.string().optional(),
594
784
  schema: jsonSchema7Schema2.optional(),
595
785
  ui: uiSchemaSchema2.optional(),
596
- data: z2.record(z2.string(), z2.unknown()).optional()
786
+ data: z4.record(z4.string(), z4.unknown()).optional()
597
787
  });
598
788
  var taskActionSchema2 = taskActionInputSchema2.extend({
599
- handlers: z2.array(handlerSchema2).min(1).optional()
789
+ handlers: z4.array(handlerSchema2).min(1).optional()
600
790
  });
601
- var uiFieldSchemaSchema2 = z2.object({
602
- "ui:widget": z2.string().optional(),
603
- "ui:title": z2.string().optional(),
604
- "ui:description": z2.string().optional(),
605
- "ui:options": z2.record(z2.string(), z2.unknown()).optional(),
606
- items: z2.lazy(() => z2.record(z2.string(), uiFieldSchemaSchema2)).optional()
791
+ var uiFieldSchemaSchema2 = z4.object({
792
+ "ui:widget": z4.string().optional(),
793
+ "ui:title": z4.string().optional(),
794
+ "ui:description": z4.string().optional(),
795
+ "ui:options": z4.record(z4.string(), z4.unknown()).optional(),
796
+ items: z4.lazy(() => z4.record(z4.string(), uiFieldSchemaSchema2)).optional()
607
797
  }).passthrough();
608
- var contextUiSchema2 = z2.record(z2.string(), uiFieldSchemaSchema2).optional();
609
- var contextDataSchema2 = z2.object({
610
- data: z2.record(z2.string(), z2.unknown()),
798
+ var contextUiSchema2 = z4.record(z4.string(), uiFieldSchemaSchema2).optional();
799
+ var contextDataSchema2 = z4.object({
800
+ data: z4.record(z4.string(), z4.unknown()),
611
801
  ui: contextUiSchema2
612
802
  }).optional();
613
803
  var TASK_CONTEXT_FORMAT_VERSION2 = 2;
614
- var taskContextObjectBaseSchema2 = z2.object({
615
- app: z2.string().min(1).optional(),
616
- type: z2.string().min(1),
617
- name: z2.string().min(1),
618
- description: z2.string().optional(),
619
- validUntil: z2.string().optional(),
804
+ var taskContextObjectBaseSchema2 = z4.object({
805
+ app: z4.string().min(1).optional(),
806
+ type: z4.string().min(1),
807
+ name: z4.string().min(1),
808
+ description: z4.string().optional(),
809
+ validUntil: z4.string().optional(),
620
810
  context: contextDataSchema2,
621
- contextVersion: z2.literal(2).optional(),
811
+ contextVersion: z4.literal(2).optional(),
622
812
  /** @deprecated Use `contextVersion`. Accepted on ingest only. */
623
- version: z2.literal(2).optional(),
624
- actions: z2.array(taskActionSchema2).min(1, "At least one action is required")
813
+ version: z4.literal(2).optional(),
814
+ actions: z4.array(taskActionSchema2).min(1, "At least one action is required")
625
815
  });
626
816
  function normalizeTaskContextVersion2(data) {
627
817
  const { version: legacyVersion, contextVersion, ...rest } = data;
@@ -637,7 +827,7 @@ function refineContextPublicUrls2(data, ctx) {
637
827
  const error = validateContextPublicUrls(data.context);
638
828
  if (error) {
639
829
  ctx.addIssue({
640
- code: z2.ZodIssueCode.custom,
830
+ code: z4.ZodIssueCode.custom,
641
831
  message: error,
642
832
  path: ["context"]
643
833
  });
@@ -646,9 +836,9 @@ function refineContextPublicUrls2(data, ctx) {
646
836
  var taskContextSchema2 = taskContextObjectSchema2.superRefine(
647
837
  refineContextPublicUrls2
648
838
  );
649
- var assignToSchema2 = z2.object({
650
- users: z2.array(z2.string().email()).optional(),
651
- groups: z2.array(z2.string().min(1)).optional()
839
+ var assignToSchema2 = z4.object({
840
+ users: z4.array(z4.string().email()).optional(),
841
+ groups: z4.array(z4.string().min(1)).optional()
652
842
  }).refine(
653
843
  (data) => {
654
844
  const groups = data.groups ?? [];
@@ -659,7 +849,7 @@ var assignToSchema2 = z2.object({
659
849
  },
660
850
  { message: 'Cannot combine "all" with other group slugs' }
661
851
  );
662
- var threadUpdateMessageSchema2 = z2.string().min(1).max(500);
852
+ var threadUpdateMessageSchema2 = z4.string().min(1).max(500);
663
853
  var threadUpdateStatuses2 = [
664
854
  "info",
665
855
  "queued",
@@ -669,15 +859,15 @@ var threadUpdateStatuses2 = [
669
859
  "failed",
670
860
  "cancelled"
671
861
  ];
672
- var threadUpdateStatusSchema2 = z2.enum(threadUpdateStatuses2);
673
- var threadUpdateInputSchema2 = z2.object({
862
+ var threadUpdateStatusSchema2 = z4.enum(threadUpdateStatuses2);
863
+ var threadUpdateInputSchema2 = z4.object({
674
864
  message: threadUpdateMessageSchema2,
675
865
  status: threadUpdateStatusSchema2.optional()
676
866
  });
677
867
  var taskPriorities2 = ["low", "normal", "high", "urgent"];
678
- var taskPrioritySchema2 = z2.enum(taskPriorities2);
679
- var agentTelemetrySchema2 = z2.object({
680
- version: z2.string().min(1)
868
+ var taskPrioritySchema2 = z4.enum(taskPriorities2);
869
+ var agentTelemetrySchema2 = z4.object({
870
+ version: z4.string().min(1)
681
871
  });
682
872
  var createTaskBodySchema2 = taskContextObjectBaseSchema2.extend({
683
873
  assignTo: assignToSchema2.optional(),
@@ -685,7 +875,7 @@ var createTaskBodySchema2 = taskContextObjectBaseSchema2.extend({
685
875
  * Groups related tasks together. When omitted, the server generates one and
686
876
  * returns it so the caller can reuse it on later tasks in the same thread.
687
877
  */
688
- threadId: z2.string().min(1).optional(),
878
+ threadId: z4.string().min(1).optional(),
689
879
  /**
690
880
  * Optional thread priority. When set, applies to the whole thread and
691
881
  * overwrites any previous priority. Omit on later tasks to leave unchanged.
@@ -700,6 +890,65 @@ var createTaskBodySchema2 = taskContextObjectBaseSchema2.extend({
700
890
  }).transform(normalizeTaskContextVersion2).superRefine(refineContextPublicUrls2);
701
891
  var threadUpdateBodySchema = threadUpdateInputSchema2;
702
892
 
893
+ // ../core/src/handler-retry.ts
894
+ var HANDLER_RETRY_DELAYS_MS = [
895
+ 6e4,
896
+ // 1m
897
+ 3e5,
898
+ // 5m
899
+ 18e5,
900
+ // 30m
901
+ 36e5,
902
+ // 1h
903
+ 216e5,
904
+ // 6h
905
+ 864e5,
906
+ // 24h
907
+ 1728e5
908
+ // 48h
909
+ ];
910
+ var HANDLER_MAX_ATTEMPTS = HANDLER_RETRY_DELAYS_MS.length + 1;
911
+
912
+ // ../core/src/attribution/index.ts
913
+ import { z as z5 } from "zod";
914
+
915
+ // ../core/src/app-url.ts
916
+ var PRODUCTION_APP_URL = "https://app.robotrock.io";
917
+ var PRODUCTION_API_URL = "https://api.robotrock.io/v1";
918
+ var DEV_API_URL = "http://localhost:4001/v1";
919
+ var APP_SIGNUP_URL = `${PRODUCTION_APP_URL}/sign-up`;
920
+ function normalizeRobotRockApiBaseUrl(baseUrl) {
921
+ const trimmed = baseUrl.trim().replace(/\/+$/, "");
922
+ if (trimmed.endsWith("/v1")) {
923
+ return trimmed;
924
+ }
925
+ return `${trimmed}/v1`;
926
+ }
927
+ function getRobotRockApiBaseUrl() {
928
+ const explicit = process.env.ROBOTROCK_BASE_URL?.trim() || process.env.ROBOTROCK_API_URL?.trim();
929
+ if (explicit) {
930
+ return normalizeRobotRockApiBaseUrl(explicit);
931
+ }
932
+ if (process.env.NODE_ENV === "production") {
933
+ return PRODUCTION_API_URL;
934
+ }
935
+ return DEV_API_URL;
936
+ }
937
+
938
+ // ../core/src/attribution/index.ts
939
+ var ATTRIBUTION_COOKIE_MAX_AGE = 60 * 60 * 24 * 90;
940
+ var attributionSchema = z5.object({
941
+ utmSource: z5.string().optional(),
942
+ utmMedium: z5.string().optional(),
943
+ utmCampaign: z5.string().optional(),
944
+ utmContent: z5.string().optional(),
945
+ utmTerm: z5.string().optional(),
946
+ gclid: z5.string().optional(),
947
+ landingUrl: z5.string().optional(),
948
+ referrer: z5.string().optional(),
949
+ capturedAt: z5.number()
950
+ });
951
+
703
952
  // src/approval-result.ts
704
953
  var TaskTimeoutError = class extends Error {
705
954
  constructor(message) {
@@ -756,8 +1005,13 @@ async function parseResponseBody(response) {
756
1005
  }
757
1006
  function getErrorMessage(data, fallback) {
758
1007
  if (data && typeof data === "object" && !Array.isArray(data)) {
759
- const maybeMessage = data.message;
1008
+ const record = data;
1009
+ const maybeMessage = record.message;
1010
+ const maybeHint = record.hint;
760
1011
  if (typeof maybeMessage === "string" && maybeMessage.trim()) {
1012
+ if (typeof maybeHint === "string" && maybeHint.trim()) {
1013
+ return `${maybeMessage.trim()} ${maybeHint.trim()}`;
1014
+ }
761
1015
  return maybeMessage;
762
1016
  }
763
1017
  }
@@ -769,51 +1023,49 @@ function getErrorMessage(data, fallback) {
769
1023
  return fallback;
770
1024
  }
771
1025
 
772
- // ../core/src/handler-retry.ts
773
- var HANDLER_RETRY_DELAYS_MS = [
774
- 6e4,
775
- // 1m
776
- 3e5,
777
- // 5m
778
- 18e5,
779
- // 30m
780
- 36e5,
781
- // 1h
782
- 216e5,
783
- // 6h
784
- 864e5,
785
- // 24h
786
- 1728e5
787
- // 48h
788
- ];
789
- var HANDLER_MAX_ATTEMPTS = HANDLER_RETRY_DELAYS_MS.length + 1;
790
-
791
- // ../core/src/attribution/index.ts
792
- import { z as z3 } from "zod";
793
-
794
- // ../core/src/app-url.ts
795
- var PRODUCTION_APP_URL = "https://app.robotrock.io";
796
- var APP_SIGNUP_URL = `${PRODUCTION_APP_URL}/sign-up`;
797
-
798
- // ../core/src/attribution/index.ts
799
- var ATTRIBUTION_COOKIE_MAX_AGE = 60 * 60 * 24 * 90;
800
- var attributionSchema = z3.object({
801
- utmSource: z3.string().optional(),
802
- utmMedium: z3.string().optional(),
803
- utmCampaign: z3.string().optional(),
804
- utmContent: z3.string().optional(),
805
- utmTerm: z3.string().optional(),
806
- gclid: z3.string().optional(),
807
- landingUrl: z3.string().optional(),
808
- referrer: z3.string().optional(),
809
- capturedAt: z3.number()
810
- });
1026
+ // src/auth-headers.ts
1027
+ var ROBOTROCK_ACTING_USER_ID_HEADER = "x-robotrock-acting-user-id";
1028
+ function buildRobotRockAuthHeaders(auth) {
1029
+ if (auth.kind === "apiKey") {
1030
+ const headers2 = {
1031
+ "X-Api-Key": auth.apiKey
1032
+ };
1033
+ if (auth.actingUserId?.trim()) {
1034
+ headers2[ROBOTROCK_ACTING_USER_ID_HEADER] = auth.actingUserId.trim();
1035
+ }
1036
+ return headers2;
1037
+ }
1038
+ const headers = {
1039
+ Authorization: `Bearer ${auth.token}`,
1040
+ "X-RobotRock-Tenant-Slug": auth.tenantSlug,
1041
+ "X-RobotRock-Connection-Id": auth.connectionId
1042
+ };
1043
+ if (auth.actingUserId?.trim()) {
1044
+ headers[ROBOTROCK_ACTING_USER_ID_HEADER] = auth.actingUserId.trim();
1045
+ }
1046
+ return headers;
1047
+ }
1048
+ function resolveRobotRockAuthConfig(overrides) {
1049
+ if (overrides?.agentService) {
1050
+ return {
1051
+ kind: "agentService",
1052
+ ...overrides.agentService
1053
+ };
1054
+ }
1055
+ const apiKey = overrides?.apiKey ?? process.env.ROBOTROCK_API_KEY;
1056
+ if (!apiKey) {
1057
+ throw new Error(
1058
+ "RobotRock auth is required. Set ROBOTROCK_API_KEY, ROBOTROCK_AGENT_SERVICE_TOKEN with tenant context, or pass auth when creating the client."
1059
+ );
1060
+ }
1061
+ return { kind: "apiKey", apiKey };
1062
+ }
811
1063
 
812
1064
  // src/chats.ts
813
1065
  function createChatsApi(config) {
814
1066
  const headers = () => ({
815
1067
  "Content-Type": "application/json",
816
- "X-Api-Key": config.apiKey
1068
+ ...buildRobotRockAuthHeaders(config.auth)
817
1069
  });
818
1070
  return {
819
1071
  async create(input) {
@@ -866,6 +1118,120 @@ function createChatsApi(config) {
866
1118
  data
867
1119
  );
868
1120
  }
1121
+ },
1122
+ async stageHitlRequests(input) {
1123
+ const validation = agentChatStageHitlBodySchema.safeParse(input);
1124
+ if (!validation.success) {
1125
+ throw new RobotRockError(
1126
+ `Invalid stage HITL input: ${validation.error.issues[0]?.message}`,
1127
+ 400,
1128
+ validation.error.issues
1129
+ );
1130
+ }
1131
+ const response = await fetch(`${config.baseUrl}/agent-chats/stage-hitl`, {
1132
+ method: "POST",
1133
+ headers: headers(),
1134
+ body: JSON.stringify(validation.data)
1135
+ });
1136
+ if (!response.ok) {
1137
+ const data = await parseResponseBody(response);
1138
+ throw new RobotRockError(
1139
+ getErrorMessage(data, "Failed to stage chat HITL requests"),
1140
+ response.status,
1141
+ data
1142
+ );
1143
+ }
1144
+ },
1145
+ async getStagedHitlRequests(eveSessionId) {
1146
+ const trimmed = eveSessionId.trim();
1147
+ if (!trimmed) {
1148
+ throw new RobotRockError("eveSessionId is required", 400);
1149
+ }
1150
+ const url = new URL(`${config.baseUrl}/agent-chats/staged-hitl`);
1151
+ url.searchParams.set("eveSessionId", trimmed);
1152
+ const response = await fetch(url.toString(), {
1153
+ method: "GET",
1154
+ headers: headers()
1155
+ });
1156
+ const data = await parseResponseBody(response);
1157
+ if (!response.ok) {
1158
+ throw new RobotRockError(
1159
+ getErrorMessage(data, "Failed to fetch staged chat HITL requests"),
1160
+ response.status,
1161
+ data
1162
+ );
1163
+ }
1164
+ const requests = data.requests;
1165
+ return Array.isArray(requests) ? requests : [];
1166
+ },
1167
+ async logInputSubmission(input) {
1168
+ const validation = agentChatAuditInputBodySchema.safeParse(input);
1169
+ if (!validation.success) {
1170
+ throw new RobotRockError(
1171
+ `Invalid audit input: ${validation.error.issues[0]?.message}`,
1172
+ 400,
1173
+ validation.error.issues
1174
+ );
1175
+ }
1176
+ const response = await fetch(`${config.baseUrl}/agent-chats/audit-input`, {
1177
+ method: "POST",
1178
+ headers: headers(),
1179
+ body: JSON.stringify(validation.data)
1180
+ });
1181
+ if (!response.ok) {
1182
+ const data = await parseResponseBody(response);
1183
+ throw new RobotRockError(
1184
+ getErrorMessage(data, "Failed to log chat input submission"),
1185
+ response.status,
1186
+ data
1187
+ );
1188
+ }
1189
+ },
1190
+ async logToolExecution(input) {
1191
+ const validation = agentChatAuditToolBodySchema.safeParse(input);
1192
+ if (!validation.success) {
1193
+ throw new RobotRockError(
1194
+ `Invalid audit tool input: ${validation.error.issues[0]?.message}`,
1195
+ 400,
1196
+ validation.error.issues
1197
+ );
1198
+ }
1199
+ const response = await fetch(`${config.baseUrl}/agent-chats/audit-tool`, {
1200
+ method: "POST",
1201
+ headers: headers(),
1202
+ body: JSON.stringify(validation.data)
1203
+ });
1204
+ if (!response.ok) {
1205
+ const data = await parseResponseBody(response);
1206
+ throw new RobotRockError(
1207
+ getErrorMessage(data, "Failed to log chat tool execution"),
1208
+ response.status,
1209
+ data
1210
+ );
1211
+ }
1212
+ },
1213
+ async linkTask(input) {
1214
+ const validation = agentChatLinkTaskBodySchema.safeParse(input);
1215
+ if (!validation.success) {
1216
+ throw new RobotRockError(
1217
+ `Invalid link task input: ${validation.error.issues[0]?.message}`,
1218
+ 400,
1219
+ validation.error.issues
1220
+ );
1221
+ }
1222
+ const response = await fetch(`${config.baseUrl}/agent-chats/link-task`, {
1223
+ method: "POST",
1224
+ headers: headers(),
1225
+ body: JSON.stringify(validation.data)
1226
+ });
1227
+ if (!response.ok) {
1228
+ const data = await parseResponseBody(response);
1229
+ throw new RobotRockError(
1230
+ getErrorMessage(data, "Failed to link inbox task to chat"),
1231
+ response.status,
1232
+ data
1233
+ );
1234
+ }
869
1235
  }
870
1236
  };
871
1237
  }
@@ -908,7 +1274,7 @@ function serializeValidUntil(value) {
908
1274
  throw new RobotRockError("Invalid validUntil: expected a Date or parseable date string", 400);
909
1275
  }
910
1276
  var RobotRock = class {
911
- apiKey;
1277
+ auth;
912
1278
  baseUrl;
913
1279
  app;
914
1280
  agentVersion;
@@ -926,14 +1292,17 @@ var RobotRock = class {
926
1292
  );
927
1293
  }
928
1294
  const apiKey = config.apiKey ?? process.env.ROBOTROCK_API_KEY;
929
- if (!apiKey) {
1295
+ const agentService = config.agentService;
1296
+ if (apiKey && agentService) {
930
1297
  throw new Error(
931
- "RobotRock API key is required. Set ROBOTROCK_API_KEY or pass apiKey when creating the client."
1298
+ "RobotRock client cannot configure both apiKey and agentService."
932
1299
  );
933
1300
  }
934
- this.apiKey = apiKey;
935
- const rawBase = config.baseUrl ?? "https://api.robotrock.io/v1";
936
- this.baseUrl = rawBase.replace(/\/+$/, "");
1301
+ this.auth = resolveRobotRockAuthConfig({
1302
+ ...apiKey ? { apiKey } : {},
1303
+ ...agentService ? { agentService } : {}
1304
+ });
1305
+ this.baseUrl = config.baseUrl ?? getRobotRockApiBaseUrl();
937
1306
  this.app = config.app;
938
1307
  this.agentVersion = config.version ?? resolveAgentVersionFromEnv();
939
1308
  this.contextVersion = config.advanced?.contextVersion ?? TASK_CONTEXT_FORMAT_VERSION2;
@@ -943,14 +1312,23 @@ var RobotRock = class {
943
1312
  create: (task2) => this.createTaskRequest(task2),
944
1313
  get: (taskId) => this.getTaskById(taskId),
945
1314
  cancel: (taskId) => this.cancelTaskRequest(taskId),
946
- sendUpdate: (input) => this.sendThreadUpdate(input)
1315
+ sendUpdate: (input) => this.sendThreadUpdate(input),
1316
+ list: (input) => this.listTasksRequest(input),
1317
+ search: (input) => this.searchTasksRequest(input)
947
1318
  };
948
1319
  this.chats = createChatsApi({
949
1320
  baseUrl: this.baseUrl,
950
- apiKey: this.apiKey,
1321
+ auth: this.auth,
951
1322
  app: this.app
952
1323
  });
953
1324
  }
1325
+ authHeaders(extra) {
1326
+ return {
1327
+ "Content-Type": "application/json",
1328
+ ...buildRobotRockAuthHeaders(this.auth),
1329
+ ...extra
1330
+ };
1331
+ }
954
1332
  async createTaskRequest(task2) {
955
1333
  const normalizedTask = normalizeSendToHumanInput(task2, {
956
1334
  webhook: this.webhook,
@@ -975,13 +1353,9 @@ var RobotRock = class {
975
1353
  validation.error.issues
976
1354
  );
977
1355
  }
978
- const headers = {
979
- "Content-Type": "application/json",
980
- "X-Api-Key": this.apiKey
981
- };
982
- if (task2.idempotencyKey) {
983
- headers["Idempotency-Key"] = task2.idempotencyKey;
984
- }
1356
+ const headers = this.authHeaders(
1357
+ task2.idempotencyKey ? { "Idempotency-Key": task2.idempotencyKey } : void 0
1358
+ );
985
1359
  const response = await fetch(`${this.baseUrl}/`, {
986
1360
  method: "POST",
987
1361
  headers,
@@ -1074,9 +1448,7 @@ var RobotRock = class {
1074
1448
  async getTaskById(taskId) {
1075
1449
  const response = await fetch(`${this.baseUrl}/tasks/${taskId}`, {
1076
1450
  method: "GET",
1077
- headers: {
1078
- "X-Api-Key": this.apiKey
1079
- }
1451
+ headers: this.authHeaders()
1080
1452
  });
1081
1453
  if (response.status === 404) {
1082
1454
  return null;
@@ -1111,10 +1483,7 @@ var RobotRock = class {
1111
1483
  `${this.baseUrl}/threads/${encodeURIComponent(threadId)}/updates`,
1112
1484
  {
1113
1485
  method: "POST",
1114
- headers: {
1115
- "Content-Type": "application/json",
1116
- "X-Api-Key": this.apiKey
1117
- },
1486
+ headers: this.authHeaders(),
1118
1487
  body: JSON.stringify(validation.data)
1119
1488
  }
1120
1489
  );
@@ -1131,9 +1500,7 @@ var RobotRock = class {
1131
1500
  async cancelTaskRequest(taskId) {
1132
1501
  const response = await fetch(`${this.baseUrl}/tasks/${taskId}/cancel`, {
1133
1502
  method: "POST",
1134
- headers: {
1135
- "X-Api-Key": this.apiKey
1136
- }
1503
+ headers: this.authHeaders()
1137
1504
  });
1138
1505
  if (!response.ok) {
1139
1506
  const data = await parseResponseBody(response);
@@ -1144,6 +1511,47 @@ var RobotRock = class {
1144
1511
  );
1145
1512
  }
1146
1513
  }
1514
+ async listTasksRequest(input) {
1515
+ const params = new URLSearchParams();
1516
+ for (const [key, value] of Object.entries(input ?? {})) {
1517
+ if (value !== void 0 && value !== "") {
1518
+ params.set(key, String(value));
1519
+ }
1520
+ }
1521
+ const suffix = params.size > 0 ? `?${params.toString()}` : "";
1522
+ const response = await fetch(`${this.baseUrl}/tasks${suffix}`, {
1523
+ method: "GET",
1524
+ headers: this.authHeaders()
1525
+ });
1526
+ const data = await parseResponseBody(response);
1527
+ if (!response.ok) {
1528
+ throw new RobotRockError(
1529
+ getErrorMessage(data, "Failed to list tasks"),
1530
+ response.status,
1531
+ data
1532
+ );
1533
+ }
1534
+ return data;
1535
+ }
1536
+ async searchTasksRequest(input) {
1537
+ const params = new URLSearchParams({ q: input.q });
1538
+ if (input.limit !== void 0) {
1539
+ params.set("limit", String(input.limit));
1540
+ }
1541
+ const response = await fetch(`${this.baseUrl}/tasks/search?${params.toString()}`, {
1542
+ method: "GET",
1543
+ headers: this.authHeaders()
1544
+ });
1545
+ const data = await parseResponseBody(response);
1546
+ if (!response.ok) {
1547
+ throw new RobotRockError(
1548
+ getErrorMessage(data, "Failed to search tasks"),
1549
+ response.status,
1550
+ data
1551
+ );
1552
+ }
1553
+ return data;
1554
+ }
1147
1555
  };
1148
1556
  function createClient(config) {
1149
1557
  return new RobotRock(config);
@@ -1189,16 +1597,24 @@ function normalizeSendToHumanInput(task2, clientDefaults) {
1189
1597
  }
1190
1598
 
1191
1599
  // src/env.ts
1192
- var DEFAULT_BASE_URL = "https://api.robotrock.io/v1";
1193
1600
  function resolveRobotRockConfig(overrides) {
1601
+ const agentService = overrides?.agentService;
1194
1602
  const apiKey = overrides?.apiKey ?? process.env.ROBOTROCK_API_KEY;
1195
- if (!apiKey) {
1603
+ if (agentService && apiKey) {
1196
1604
  throw new Error(
1197
- "RobotRock API key is required. Set ROBOTROCK_API_KEY or pass apiKey when creating the client."
1605
+ "RobotRock client cannot configure both apiKey and agentService."
1198
1606
  );
1199
1607
  }
1200
- const baseUrl = overrides?.baseUrl ?? process.env.ROBOTROCK_BASE_URL ?? process.env.ROBOTROCK_API_URL ?? DEFAULT_BASE_URL;
1608
+ const baseUrl = overrides?.baseUrl ?? getRobotRockApiBaseUrl();
1201
1609
  const app = overrides?.app ?? process.env.ROBOTROCK_APP;
1610
+ if (agentService) {
1611
+ return app ? { agentService, baseUrl, app } : { agentService, baseUrl };
1612
+ }
1613
+ if (!apiKey) {
1614
+ throw new Error(
1615
+ "RobotRock API key is required. Set ROBOTROCK_API_KEY or pass agentService when creating the client."
1616
+ );
1617
+ }
1202
1618
  return app ? { apiKey, baseUrl, app } : { apiKey, baseUrl };
1203
1619
  }
1204
1620