robotrock 1.1.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 (70) 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 +407 -188
  6. package/dist/ai/index.js.map +1 -1
  7. package/dist/ai/trigger.d.ts +4 -3
  8. package/dist/ai/trigger.js +407 -188
  9. package/dist/ai/trigger.js.map +1 -1
  10. package/dist/ai/workflow.d.ts +4 -3
  11. package/dist/ai/workflow.js +404 -185
  12. package/dist/ai/workflow.js.map +1 -1
  13. package/dist/auth-headers-qL-ZeEtd.d.ts +13 -0
  14. package/dist/{client-XTnFHGFE.d.ts → client-YO9Y1rkH.d.ts} +29 -17
  15. package/dist/eve/agent/index.d.ts +11 -35
  16. package/dist/eve/agent/index.js +678 -146
  17. package/dist/eve/agent/index.js.map +1 -1
  18. package/dist/eve/index.d.ts +5 -2
  19. package/dist/eve/index.js +195 -2
  20. package/dist/eve/index.js.map +1 -1
  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 +2 -0
  37. package/dist/eve/tools/identity/index.js +117 -27
  38. package/dist/eve/tools/identity/index.js.map +1 -1
  39. package/dist/eve/tools/identity/my-access.d.ts +6 -46
  40. package/dist/eve/tools/identity/my-access.js +91 -10
  41. package/dist/eve/tools/identity/my-access.js.map +1 -1
  42. package/dist/eve/tools/identity/whoami.d.ts +7 -8
  43. package/dist/eve/tools/identity/whoami.js +33 -17
  44. package/dist/eve/tools/identity/whoami.js.map +1 -1
  45. package/dist/eve/tools/inbox/create-task.d.ts +5 -4
  46. package/dist/eve/tools/inbox/create-task.js +365 -137
  47. package/dist/eve/tools/inbox/create-task.js.map +1 -1
  48. package/dist/eve/tools/inbox/index.d.ts +1 -0
  49. package/dist/eve/tools/inbox/index.js +365 -137
  50. package/dist/eve/tools/inbox/index.js.map +1 -1
  51. package/dist/eve/tools/index.d.ts +7 -0
  52. package/dist/eve/tools/index.js +1362 -168
  53. package/dist/eve/tools/index.js.map +1 -1
  54. package/dist/{index-BL9qKHA8.d.ts → index-DoQN48Bm.d.ts} +61 -2
  55. package/dist/index.d.ts +6 -3
  56. package/dist/index.js +325 -119
  57. package/dist/index.js.map +1 -1
  58. package/dist/schemas/index.d.ts +6 -1
  59. package/dist/schemas/index.js +177 -48
  60. package/dist/schemas/index.js.map +1 -1
  61. package/dist/{tool-approval-bridge-C4bTm8vu.d.ts → tool-approval-bridge-aMA79Z1B.d.ts} +1 -1
  62. package/dist/tool-reply-guidance-C3qrT1In.d.ts +25 -0
  63. package/dist/trigger/index.d.ts +2 -1
  64. package/dist/trigger/index.js +310 -108
  65. package/dist/trigger/index.js.map +1 -1
  66. package/dist/{trigger-Dn0DFiyU.d.ts → trigger-CXrbKVCL.d.ts} +2 -2
  67. package/dist/workflow/index.d.ts +2 -1
  68. package/dist/workflow/index.js +310 -108
  69. package/dist/workflow/index.js.map +1 -1
  70. package/package.json +28 -4
package/dist/ai/index.js CHANGED
@@ -329,7 +329,7 @@ function refineContextPublicUrls(data, ctx) {
329
329
  });
330
330
  }
331
331
  }
332
- var safeUrlSchema, handlerUrlSchema, jsonSchema7Schema, uiSchemaSchema, webhookHandlerSchema, triggerHandlerSchema, handlerSchema, taskActionInputSchema, taskActionSchema, uiFieldSchemaSchema, contextUiSchema, contextDataSchema, TASK_CONTEXT_FORMAT_VERSION, taskContextObjectBaseSchema, taskContextObjectSchema, taskContextSchema, assignToSchema, threadUpdateMessageSchema, threadUpdateStatuses, threadUpdateStatusSchema, threadUpdateInputSchema, taskPriorities, taskPrioritySchema, agentTelemetrySchema, createTaskBodySchema, agentChatSeedActionSchema, agentChatSeedMessageSchema, eveAgentChatTransportSchema, createAgentChatBodySchema, agentChatAuditInputBodySchema, eveHitlStagedOptionSchema, agentChatStageHitlBodySchema, agentChatLinkTaskBodySchema;
332
+ var safeUrlSchema, handlerUrlSchema, jsonSchema7Schema, uiSchemaSchema, webhookHandlerSchema, triggerHandlerSchema, handlerSchema, taskActionInputSchema, taskActionSchema, uiFieldSchemaSchema, contextUiSchema, contextDataSchema, TASK_CONTEXT_FORMAT_VERSION, taskContextObjectBaseSchema, taskContextObjectSchema, taskContextSchema, assignToSchema, threadUpdateMessageSchema, threadUpdateStatuses, threadUpdateStatusSchema, threadUpdateInputSchema, taskPriorities, taskPrioritySchema, agentTelemetrySchema, createTaskBodySchema, agentChatSeedActionSchema, agentChatSeedMessageSchema, eveAgentChatTransportSchema, createAgentChatBodySchema, agentChatAuditToolBodySchema, agentChatAuditInputBodySchema, eveHitlStagedOptionSchema, agentChatStageHitlBodySchema, agentChatLinkTaskBodySchema;
333
333
  var init_task = __esm({
334
334
  "../core/src/schemas/task.ts"() {
335
335
  "use strict";
@@ -502,13 +502,27 @@ var init_task = __esm({
502
502
  eveConnectionId: z.string().min(1).optional(),
503
503
  /** Source application id; groups the chat under an inbox section. */
504
504
  app: z.string().min(1).optional(),
505
- assignTo: assignToSchema.optional(),
505
+ /** Email of the user who owns the chat. Required unless `parentChatId` is set. */
506
+ ownerEmail: z.string().email().optional(),
506
507
  title: z.string().min(1),
507
508
  messages: z.array(agentChatSeedMessageSchema).default([]),
508
509
  /** Provenance label stored on the session ("cron" | "agent" | ...). */
509
510
  source: z.string().min(1).optional()
510
511
  }).refine((data) => Boolean(data.agentIdentifier || data.parentChatId), {
511
512
  message: "Provide either agentIdentifier or parentChatId"
513
+ }).refine((data) => Boolean(data.ownerEmail || data.parentChatId), {
514
+ message: "Provide ownerEmail unless parentChatId is set"
515
+ });
516
+ agentChatAuditToolBodySchema = z.object({
517
+ eveSessionId: z.string().min(1),
518
+ userId: z.string().min(1),
519
+ toolCallId: z.string().min(1),
520
+ toolName: z.string().min(1),
521
+ input: z.record(z.string(), z.unknown()).default({}),
522
+ success: z.boolean(),
523
+ status: z.enum(["completed", "failed", "rejected"]),
524
+ error: z.string().optional(),
525
+ idempotencyKey: z.string().optional()
512
526
  });
513
527
  agentChatAuditInputBodySchema = z.object({
514
528
  eveSessionId: z.string().min(1),
@@ -557,6 +571,132 @@ var init_json_schema = __esm({
557
571
  }
558
572
  });
559
573
 
574
+ // ../core/src/schemas/tool-result-display.ts
575
+ import { z as z2 } from "zod";
576
+ var toolDisplayMetadataSchema, toolDisplayEnvelopeSchema;
577
+ var init_tool_result_display = __esm({
578
+ "../core/src/schemas/tool-result-display.ts"() {
579
+ "use strict";
580
+ toolDisplayMetadataSchema = z2.object({
581
+ widget: z2.string().optional(),
582
+ title: z2.string().optional(),
583
+ description: z2.string().optional()
584
+ });
585
+ toolDisplayEnvelopeSchema = z2.object({
586
+ display: toolDisplayMetadataSchema.optional(),
587
+ data: z2.record(z2.string(), z2.unknown()),
588
+ ui: z2.record(
589
+ z2.string(),
590
+ z2.object({
591
+ "ui:widget": z2.string().optional(),
592
+ "ui:title": z2.string().optional(),
593
+ "ui:description": z2.string().optional(),
594
+ "ui:options": z2.record(z2.string(), z2.unknown()).optional()
595
+ }).passthrough()
596
+ ).optional()
597
+ });
598
+ }
599
+ });
600
+
601
+ // ../core/src/schemas/agent-admin.ts
602
+ import { z as z3 } from "zod";
603
+ var tenantRoleSchema, agentAdminUserSchema, agentAdminMemberSchema, agentAdminGroupSchema, agentAdminGroupDetailSchema, agentAdminTaskSummarySchema, inviteMemberBodySchema, updateMemberRoleBodySchema, createGroupBodySchema, updateGroupBodySchema, addGroupMemberBodySchema, listTasksQuerySchema, searchTasksQuerySchema, assignTasksResultSchema, assignTasksResponseSchema, assignTasksBodySchema;
604
+ var init_agent_admin = __esm({
605
+ "../core/src/schemas/agent-admin.ts"() {
606
+ "use strict";
607
+ init_task();
608
+ tenantRoleSchema = z3.enum(["admin", "member"]);
609
+ agentAdminUserSchema = z3.object({
610
+ id: z3.string(),
611
+ email: z3.string().email(),
612
+ name: z3.string()
613
+ });
614
+ agentAdminMemberSchema = z3.object({
615
+ userId: z3.string(),
616
+ role: z3.string(),
617
+ membershipKind: z3.enum(["team", "assignee"]),
618
+ hasLoggedIn: z3.boolean(),
619
+ user: agentAdminUserSchema
620
+ });
621
+ agentAdminGroupSchema = z3.object({
622
+ id: z3.string(),
623
+ name: z3.string(),
624
+ slug: z3.string(),
625
+ description: z3.string().nullable(),
626
+ memberCount: z3.number().optional()
627
+ });
628
+ agentAdminGroupDetailSchema = agentAdminGroupSchema.extend({
629
+ members: z3.array(
630
+ z3.object({
631
+ userId: z3.string(),
632
+ user: agentAdminUserSchema
633
+ })
634
+ )
635
+ });
636
+ agentAdminTaskSummarySchema = z3.object({
637
+ id: z3.string(),
638
+ convexId: z3.string(),
639
+ status: z3.string(),
640
+ type: z3.string().nullable(),
641
+ name: z3.string().nullable(),
642
+ description: z3.string().nullable(),
643
+ validUntil: z3.number(),
644
+ createdAt: z3.number(),
645
+ threadPriority: z3.string().nullable(),
646
+ handledByUserId: z3.string().nullable()
647
+ });
648
+ inviteMemberBodySchema = z3.object({
649
+ email: z3.string().email(),
650
+ role: tenantRoleSchema.optional()
651
+ });
652
+ updateMemberRoleBodySchema = z3.object({
653
+ role: tenantRoleSchema
654
+ });
655
+ createGroupBodySchema = z3.object({
656
+ name: z3.string().min(1),
657
+ description: z3.string().optional()
658
+ });
659
+ updateGroupBodySchema = z3.object({
660
+ name: z3.string().min(1).optional(),
661
+ description: z3.string().optional()
662
+ });
663
+ addGroupMemberBodySchema = z3.object({
664
+ userId: z3.string().min(1).describe("Convex user id or member email.")
665
+ });
666
+ listTasksQuerySchema = z3.object({
667
+ statusFilter: z3.enum(["all", "open", "handled", "expired"]).optional(),
668
+ typeFilter: z3.string().optional(),
669
+ appFilter: z3.string().optional(),
670
+ sortField: z3.enum(["type", "date", "status", "validUntil"]).optional(),
671
+ sortDirection: z3.enum(["asc", "desc"]).optional(),
672
+ limit: z3.coerce.number().int().positive().max(100).optional(),
673
+ cursor: z3.string().optional()
674
+ });
675
+ searchTasksQuerySchema = z3.object({
676
+ q: z3.string().min(1),
677
+ limit: z3.coerce.number().int().positive().max(100).optional()
678
+ });
679
+ assignTasksResultSchema = z3.object({
680
+ taskId: z3.string(),
681
+ success: z3.boolean(),
682
+ message: z3.string().optional(),
683
+ name: z3.string().nullable().optional(),
684
+ description: z3.string().nullable().optional(),
685
+ type: z3.string().nullable().optional()
686
+ });
687
+ assignTasksResponseSchema = z3.object({
688
+ results: z3.array(assignTasksResultSchema)
689
+ });
690
+ assignTasksBodySchema = z3.object({
691
+ taskIds: z3.array(z3.string().min(1)).min(1).max(100),
692
+ assignTo: assignToSchema.refine(
693
+ (value) => (value.users?.length ?? 0) > 0 || (value.groups?.length ?? 0) > 0,
694
+ { message: "assignTo needs at least one user email or group slug." }
695
+ )
696
+ });
697
+ }
698
+ });
699
+
560
700
  // ../core/src/schemas/index.ts
561
701
  var init_schemas = __esm({
562
702
  "../core/src/schemas/index.ts"() {
@@ -564,11 +704,13 @@ var init_schemas = __esm({
564
704
  init_task();
565
705
  init_json_schema();
566
706
  init_context_urls();
707
+ init_tool_result_display();
708
+ init_agent_admin();
567
709
  }
568
710
  });
569
711
 
570
712
  // src/schemas/index.ts
571
- import { z as z2 } from "zod";
713
+ import { z as z4 } from "zod";
572
714
  function normalizeTaskContextVersion2(data) {
573
715
  const { version: legacyVersion, contextVersion, ...rest } = data;
574
716
  return {
@@ -580,7 +722,7 @@ function refineContextPublicUrls2(data, ctx) {
580
722
  const error = validateContextPublicUrls(data.context);
581
723
  if (error) {
582
724
  ctx.addIssue({
583
- code: z2.ZodIssueCode.custom,
725
+ code: z4.ZodIssueCode.custom,
584
726
  message: error,
585
727
  path: ["context"]
586
728
  });
@@ -592,61 +734,61 @@ var init_schemas2 = __esm({
592
734
  "use strict";
593
735
  init_utils();
594
736
  init_schemas();
595
- handlerUrlSchema2 = z2.string().refine((url) => isAllowedHandlerUrl(url), {
737
+ handlerUrlSchema2 = z4.string().refine((url) => isAllowedHandlerUrl(url), {
596
738
  message: HANDLER_URL_ERROR
597
739
  });
598
- jsonSchema7Schema2 = z2.custom(
740
+ jsonSchema7Schema2 = z4.custom(
599
741
  (val) => typeof val === "object" && val !== null,
600
742
  { message: "Must be a valid JSON Schema object" }
601
743
  );
602
- uiSchemaSchema2 = z2.custom((val) => typeof val === "object" && val !== null, {
744
+ uiSchemaSchema2 = z4.custom((val) => typeof val === "object" && val !== null, {
603
745
  message: "Must be a valid UiSchema object"
604
746
  });
605
- webhookHandlerSchema2 = z2.object({
606
- type: z2.literal("webhook"),
747
+ webhookHandlerSchema2 = z4.object({
748
+ type: z4.literal("webhook"),
607
749
  url: handlerUrlSchema2,
608
- headers: z2.record(z2.string(), z2.string())
750
+ headers: z4.record(z4.string(), z4.string())
609
751
  });
610
752
  triggerHandlerSchema2 = webhookHandlerSchema2.extend({
611
- type: z2.literal("trigger"),
612
- tokenId: z2.string().min(1)
753
+ type: z4.literal("trigger"),
754
+ tokenId: z4.string().min(1)
613
755
  });
614
- handlerSchema2 = z2.discriminatedUnion("type", [webhookHandlerSchema2, triggerHandlerSchema2]);
615
- taskActionInputSchema2 = z2.object({
616
- id: z2.string().min(1),
617
- title: z2.string().min(1),
618
- description: z2.string().optional(),
756
+ handlerSchema2 = z4.discriminatedUnion("type", [webhookHandlerSchema2, triggerHandlerSchema2]);
757
+ taskActionInputSchema2 = z4.object({
758
+ id: z4.string().min(1),
759
+ title: z4.string().min(1),
760
+ description: z4.string().optional(),
619
761
  schema: jsonSchema7Schema2.optional(),
620
762
  ui: uiSchemaSchema2.optional(),
621
- data: z2.record(z2.string(), z2.unknown()).optional()
763
+ data: z4.record(z4.string(), z4.unknown()).optional()
622
764
  });
623
765
  taskActionSchema2 = taskActionInputSchema2.extend({
624
- handlers: z2.array(handlerSchema2).min(1).optional()
766
+ handlers: z4.array(handlerSchema2).min(1).optional()
625
767
  });
626
- uiFieldSchemaSchema2 = z2.object({
627
- "ui:widget": z2.string().optional(),
628
- "ui:title": z2.string().optional(),
629
- "ui:description": z2.string().optional(),
630
- "ui:options": z2.record(z2.string(), z2.unknown()).optional(),
631
- items: z2.lazy(() => z2.record(z2.string(), uiFieldSchemaSchema2)).optional()
768
+ uiFieldSchemaSchema2 = z4.object({
769
+ "ui:widget": z4.string().optional(),
770
+ "ui:title": z4.string().optional(),
771
+ "ui:description": z4.string().optional(),
772
+ "ui:options": z4.record(z4.string(), z4.unknown()).optional(),
773
+ items: z4.lazy(() => z4.record(z4.string(), uiFieldSchemaSchema2)).optional()
632
774
  }).passthrough();
633
- contextUiSchema2 = z2.record(z2.string(), uiFieldSchemaSchema2).optional();
634
- contextDataSchema2 = z2.object({
635
- data: z2.record(z2.string(), z2.unknown()),
775
+ contextUiSchema2 = z4.record(z4.string(), uiFieldSchemaSchema2).optional();
776
+ contextDataSchema2 = z4.object({
777
+ data: z4.record(z4.string(), z4.unknown()),
636
778
  ui: contextUiSchema2
637
779
  }).optional();
638
780
  TASK_CONTEXT_FORMAT_VERSION2 = 2;
639
- taskContextObjectBaseSchema2 = z2.object({
640
- app: z2.string().min(1).optional(),
641
- type: z2.string().min(1),
642
- name: z2.string().min(1),
643
- description: z2.string().optional(),
644
- validUntil: z2.string().optional(),
781
+ taskContextObjectBaseSchema2 = z4.object({
782
+ app: z4.string().min(1).optional(),
783
+ type: z4.string().min(1),
784
+ name: z4.string().min(1),
785
+ description: z4.string().optional(),
786
+ validUntil: z4.string().optional(),
645
787
  context: contextDataSchema2,
646
- contextVersion: z2.literal(2).optional(),
788
+ contextVersion: z4.literal(2).optional(),
647
789
  /** @deprecated Use `contextVersion`. Accepted on ingest only. */
648
- version: z2.literal(2).optional(),
649
- actions: z2.array(taskActionSchema2).min(1, "At least one action is required")
790
+ version: z4.literal(2).optional(),
791
+ actions: z4.array(taskActionSchema2).min(1, "At least one action is required")
650
792
  });
651
793
  taskContextObjectSchema2 = taskContextObjectBaseSchema2.transform(
652
794
  normalizeTaskContextVersion2
@@ -654,9 +796,9 @@ var init_schemas2 = __esm({
654
796
  taskContextSchema2 = taskContextObjectSchema2.superRefine(
655
797
  refineContextPublicUrls2
656
798
  );
657
- assignToSchema2 = z2.object({
658
- users: z2.array(z2.string().email()).optional(),
659
- groups: z2.array(z2.string().min(1)).optional()
799
+ assignToSchema2 = z4.object({
800
+ users: z4.array(z4.string().email()).optional(),
801
+ groups: z4.array(z4.string().min(1)).optional()
660
802
  }).refine(
661
803
  (data) => {
662
804
  const groups = data.groups ?? [];
@@ -667,7 +809,7 @@ var init_schemas2 = __esm({
667
809
  },
668
810
  { message: 'Cannot combine "all" with other group slugs' }
669
811
  );
670
- threadUpdateMessageSchema2 = z2.string().min(1).max(500);
812
+ threadUpdateMessageSchema2 = z4.string().min(1).max(500);
671
813
  threadUpdateStatuses2 = [
672
814
  "info",
673
815
  "queued",
@@ -677,15 +819,15 @@ var init_schemas2 = __esm({
677
819
  "failed",
678
820
  "cancelled"
679
821
  ];
680
- threadUpdateStatusSchema2 = z2.enum(threadUpdateStatuses2);
681
- threadUpdateInputSchema2 = z2.object({
822
+ threadUpdateStatusSchema2 = z4.enum(threadUpdateStatuses2);
823
+ threadUpdateInputSchema2 = z4.object({
682
824
  message: threadUpdateMessageSchema2,
683
825
  status: threadUpdateStatusSchema2.optional()
684
826
  });
685
827
  taskPriorities2 = ["low", "normal", "high", "urgent"];
686
- taskPrioritySchema2 = z2.enum(taskPriorities2);
687
- agentTelemetrySchema2 = z2.object({
688
- version: z2.string().min(1)
828
+ taskPrioritySchema2 = z4.enum(taskPriorities2);
829
+ agentTelemetrySchema2 = z4.object({
830
+ version: z4.string().min(1)
689
831
  });
690
832
  createTaskBodySchema2 = taskContextObjectBaseSchema2.extend({
691
833
  assignTo: assignToSchema2.optional(),
@@ -693,7 +835,7 @@ var init_schemas2 = __esm({
693
835
  * Groups related tasks together. When omitted, the server generates one and
694
836
  * returns it so the caller can reuse it on later tasks in the same thread.
695
837
  */
696
- threadId: z2.string().min(1).optional(),
838
+ threadId: z4.string().min(1).optional(),
697
839
  /**
698
840
  * Optional thread priority. When set, applies to the whole thread and
699
841
  * overwrites any previous priority. Omit on later tasks to leave unchanged.
@@ -710,92 +852,6 @@ var init_schemas2 = __esm({
710
852
  }
711
853
  });
712
854
 
713
- // src/approval-result.ts
714
- function toDiscriminatedApprovalResult(actions, task2) {
715
- void actions;
716
- if (!task2.handled) {
717
- throw new Error("Task has no handled result");
718
- }
719
- return {
720
- actionId: task2.handled.action.id,
721
- data: task2.handled.action.data,
722
- handledBy: task2.handled.handledBy,
723
- handledAt: new Date(task2.handledAt ?? Date.now()),
724
- taskId: task2.id
725
- };
726
- }
727
- var TaskTimeoutError, TaskExpiredError;
728
- var init_approval_result = __esm({
729
- "src/approval-result.ts"() {
730
- "use strict";
731
- TaskTimeoutError = class extends Error {
732
- constructor(message) {
733
- super(message);
734
- this.name = "TaskTimeoutError";
735
- }
736
- };
737
- TaskExpiredError = class extends Error {
738
- constructor(message) {
739
- super(message);
740
- this.name = "TaskExpiredError";
741
- }
742
- };
743
- }
744
- });
745
-
746
- // src/http.ts
747
- async function parseResponseBody(response) {
748
- const contentType = response.headers.get("content-type") ?? "";
749
- const bodyText = await response.text();
750
- if (!bodyText) {
751
- return null;
752
- }
753
- if (contentType.toLowerCase().includes("application/json")) {
754
- try {
755
- return JSON.parse(bodyText);
756
- } catch {
757
- }
758
- }
759
- try {
760
- return JSON.parse(bodyText);
761
- } catch {
762
- return bodyText;
763
- }
764
- }
765
- function getErrorMessage(data, fallback) {
766
- if (data && typeof data === "object" && !Array.isArray(data)) {
767
- const record = data;
768
- const maybeMessage = record.message;
769
- const maybeHint = record.hint;
770
- if (typeof maybeMessage === "string" && maybeMessage.trim()) {
771
- if (typeof maybeHint === "string" && maybeHint.trim()) {
772
- return `${maybeMessage.trim()} ${maybeHint.trim()}`;
773
- }
774
- return maybeMessage;
775
- }
776
- }
777
- if (typeof data === "string" && data.trim()) {
778
- const compact = data.replace(/\s+/g, " ").trim();
779
- const snippet = compact.length > 180 ? `${compact.slice(0, 180)}...` : compact;
780
- return `${fallback}. Server returned non-JSON response: ${snippet}`;
781
- }
782
- return fallback;
783
- }
784
- var RobotRockError;
785
- var init_http = __esm({
786
- "src/http.ts"() {
787
- "use strict";
788
- RobotRockError = class extends Error {
789
- constructor(message, statusCode, response) {
790
- super(message);
791
- this.statusCode = statusCode;
792
- this.response = response;
793
- this.name = "RobotRockError";
794
- }
795
- };
796
- }
797
- });
798
-
799
855
  // ../core/src/types/task.ts
800
856
  var init_task2 = __esm({
801
857
  "../core/src/types/task.ts"() {
@@ -895,7 +951,7 @@ var init_app_url = __esm({
895
951
  });
896
952
 
897
953
  // ../core/src/attribution/index.ts
898
- import { z as z3 } from "zod";
954
+ import { z as z5 } from "zod";
899
955
  var ATTRIBUTION_COOKIE_MAX_AGE, attributionSchema;
900
956
  var init_attribution = __esm({
901
957
  "../core/src/attribution/index.ts"() {
@@ -903,16 +959,16 @@ var init_attribution = __esm({
903
959
  init_app_url();
904
960
  init_app_url();
905
961
  ATTRIBUTION_COOKIE_MAX_AGE = 60 * 60 * 24 * 90;
906
- attributionSchema = z3.object({
907
- utmSource: z3.string().optional(),
908
- utmMedium: z3.string().optional(),
909
- utmCampaign: z3.string().optional(),
910
- utmContent: z3.string().optional(),
911
- utmTerm: z3.string().optional(),
912
- gclid: z3.string().optional(),
913
- landingUrl: z3.string().optional(),
914
- referrer: z3.string().optional(),
915
- capturedAt: z3.number()
962
+ attributionSchema = z5.object({
963
+ utmSource: z5.string().optional(),
964
+ utmMedium: z5.string().optional(),
965
+ utmCampaign: z5.string().optional(),
966
+ utmContent: z5.string().optional(),
967
+ utmTerm: z5.string().optional(),
968
+ gclid: z5.string().optional(),
969
+ landingUrl: z5.string().optional(),
970
+ referrer: z5.string().optional(),
971
+ capturedAt: z5.number()
916
972
  });
917
973
  }
918
974
  });
@@ -941,18 +997,112 @@ var init_src = __esm({
941
997
  }
942
998
  });
943
999
 
1000
+ // src/approval-result.ts
1001
+ function toDiscriminatedApprovalResult(actions, task2) {
1002
+ void actions;
1003
+ if (!task2.handled) {
1004
+ throw new Error("Task has no handled result");
1005
+ }
1006
+ return {
1007
+ actionId: task2.handled.action.id,
1008
+ data: task2.handled.action.data,
1009
+ handledBy: task2.handled.handledBy,
1010
+ handledAt: new Date(task2.handledAt ?? Date.now()),
1011
+ taskId: task2.id
1012
+ };
1013
+ }
1014
+ var TaskTimeoutError, TaskExpiredError;
1015
+ var init_approval_result = __esm({
1016
+ "src/approval-result.ts"() {
1017
+ "use strict";
1018
+ TaskTimeoutError = class extends Error {
1019
+ constructor(message) {
1020
+ super(message);
1021
+ this.name = "TaskTimeoutError";
1022
+ }
1023
+ };
1024
+ TaskExpiredError = class extends Error {
1025
+ constructor(message) {
1026
+ super(message);
1027
+ this.name = "TaskExpiredError";
1028
+ }
1029
+ };
1030
+ }
1031
+ });
1032
+
1033
+ // src/http.ts
1034
+ async function parseResponseBody(response) {
1035
+ const contentType = response.headers.get("content-type") ?? "";
1036
+ const bodyText = await response.text();
1037
+ if (!bodyText) {
1038
+ return null;
1039
+ }
1040
+ if (contentType.toLowerCase().includes("application/json")) {
1041
+ try {
1042
+ return JSON.parse(bodyText);
1043
+ } catch {
1044
+ }
1045
+ }
1046
+ try {
1047
+ return JSON.parse(bodyText);
1048
+ } catch {
1049
+ return bodyText;
1050
+ }
1051
+ }
1052
+ function getErrorMessage(data, fallback) {
1053
+ if (data && typeof data === "object" && !Array.isArray(data)) {
1054
+ const record = data;
1055
+ const maybeMessage = record.message;
1056
+ const maybeHint = record.hint;
1057
+ if (typeof maybeMessage === "string" && maybeMessage.trim()) {
1058
+ if (typeof maybeHint === "string" && maybeHint.trim()) {
1059
+ return `${maybeMessage.trim()} ${maybeHint.trim()}`;
1060
+ }
1061
+ return maybeMessage;
1062
+ }
1063
+ }
1064
+ if (typeof data === "string" && data.trim()) {
1065
+ const compact = data.replace(/\s+/g, " ").trim();
1066
+ const snippet = compact.length > 180 ? `${compact.slice(0, 180)}...` : compact;
1067
+ return `${fallback}. Server returned non-JSON response: ${snippet}`;
1068
+ }
1069
+ return fallback;
1070
+ }
1071
+ var RobotRockError;
1072
+ var init_http = __esm({
1073
+ "src/http.ts"() {
1074
+ "use strict";
1075
+ RobotRockError = class extends Error {
1076
+ constructor(message, statusCode, response) {
1077
+ super(message);
1078
+ this.statusCode = statusCode;
1079
+ this.response = response;
1080
+ this.name = "RobotRockError";
1081
+ }
1082
+ };
1083
+ }
1084
+ });
1085
+
944
1086
  // src/auth-headers.ts
945
1087
  function buildRobotRockAuthHeaders(auth) {
946
1088
  if (auth.kind === "apiKey") {
947
- return {
1089
+ const headers2 = {
948
1090
  "X-Api-Key": auth.apiKey
949
1091
  };
1092
+ if (auth.actingUserId?.trim()) {
1093
+ headers2[ROBOTROCK_ACTING_USER_ID_HEADER] = auth.actingUserId.trim();
1094
+ }
1095
+ return headers2;
950
1096
  }
951
- return {
1097
+ const headers = {
952
1098
  Authorization: `Bearer ${auth.token}`,
953
1099
  "X-RobotRock-Tenant-Slug": auth.tenantSlug,
954
1100
  "X-RobotRock-Connection-Id": auth.connectionId
955
1101
  };
1102
+ if (auth.actingUserId?.trim()) {
1103
+ headers[ROBOTROCK_ACTING_USER_ID_HEADER] = auth.actingUserId.trim();
1104
+ }
1105
+ return headers;
956
1106
  }
957
1107
  function resolveRobotRockAuthConfig(overrides) {
958
1108
  if (overrides?.agentService) {
@@ -969,9 +1119,11 @@ function resolveRobotRockAuthConfig(overrides) {
969
1119
  }
970
1120
  return { kind: "apiKey", apiKey };
971
1121
  }
1122
+ var ROBOTROCK_ACTING_USER_ID_HEADER;
972
1123
  var init_auth_headers = __esm({
973
1124
  "src/auth-headers.ts"() {
974
1125
  "use strict";
1126
+ ROBOTROCK_ACTING_USER_ID_HEADER = "x-robotrock-acting-user-id";
975
1127
  }
976
1128
  });
977
1129
 
@@ -1101,6 +1253,29 @@ function createChatsApi(config) {
1101
1253
  );
1102
1254
  }
1103
1255
  },
1256
+ async logToolExecution(input) {
1257
+ const validation = agentChatAuditToolBodySchema.safeParse(input);
1258
+ if (!validation.success) {
1259
+ throw new RobotRockError(
1260
+ `Invalid audit tool input: ${validation.error.issues[0]?.message}`,
1261
+ 400,
1262
+ validation.error.issues
1263
+ );
1264
+ }
1265
+ const response = await fetch(`${config.baseUrl}/agent-chats/audit-tool`, {
1266
+ method: "POST",
1267
+ headers: headers(),
1268
+ body: JSON.stringify(validation.data)
1269
+ });
1270
+ if (!response.ok) {
1271
+ const data = await parseResponseBody(response);
1272
+ throw new RobotRockError(
1273
+ getErrorMessage(data, "Failed to log chat tool execution"),
1274
+ response.status,
1275
+ data
1276
+ );
1277
+ }
1278
+ },
1104
1279
  async linkTask(input) {
1105
1280
  const validation = agentChatLinkTaskBodySchema.safeParse(input);
1106
1281
  if (!validation.success) {
@@ -1217,6 +1392,7 @@ var init_client = __esm({
1217
1392
  "src/client.ts"() {
1218
1393
  "use strict";
1219
1394
  init_schemas2();
1395
+ init_src();
1220
1396
  init_approval_result();
1221
1397
  init_http();
1222
1398
  init_src();
@@ -1264,7 +1440,9 @@ var init_client = __esm({
1264
1440
  create: (task2) => this.createTaskRequest(task2),
1265
1441
  get: (taskId) => this.getTaskById(taskId),
1266
1442
  cancel: (taskId) => this.cancelTaskRequest(taskId),
1267
- sendUpdate: (input) => this.sendThreadUpdate(input)
1443
+ sendUpdate: (input) => this.sendThreadUpdate(input),
1444
+ list: (input) => this.listTasksRequest(input),
1445
+ search: (input) => this.searchTasksRequest(input)
1268
1446
  };
1269
1447
  this.chats = createChatsApi({
1270
1448
  baseUrl: this.baseUrl,
@@ -1461,6 +1639,47 @@ var init_client = __esm({
1461
1639
  );
1462
1640
  }
1463
1641
  }
1642
+ async listTasksRequest(input) {
1643
+ const params = new URLSearchParams();
1644
+ for (const [key, value] of Object.entries(input ?? {})) {
1645
+ if (value !== void 0 && value !== "") {
1646
+ params.set(key, String(value));
1647
+ }
1648
+ }
1649
+ const suffix = params.size > 0 ? `?${params.toString()}` : "";
1650
+ const response = await fetch(`${this.baseUrl}/tasks${suffix}`, {
1651
+ method: "GET",
1652
+ headers: this.authHeaders()
1653
+ });
1654
+ const data = await parseResponseBody(response);
1655
+ if (!response.ok) {
1656
+ throw new RobotRockError(
1657
+ getErrorMessage(data, "Failed to list tasks"),
1658
+ response.status,
1659
+ data
1660
+ );
1661
+ }
1662
+ return data;
1663
+ }
1664
+ async searchTasksRequest(input) {
1665
+ const params = new URLSearchParams({ q: input.q });
1666
+ if (input.limit !== void 0) {
1667
+ params.set("limit", String(input.limit));
1668
+ }
1669
+ const response = await fetch(`${this.baseUrl}/tasks/search?${params.toString()}`, {
1670
+ method: "GET",
1671
+ headers: this.authHeaders()
1672
+ });
1673
+ const data = await parseResponseBody(response);
1674
+ if (!response.ok) {
1675
+ throw new RobotRockError(
1676
+ getErrorMessage(data, "Failed to search tasks"),
1677
+ response.status,
1678
+ data
1679
+ );
1680
+ }
1681
+ return data;
1682
+ }
1464
1683
  };
1465
1684
  }
1466
1685
  });
@@ -2022,7 +2241,7 @@ var init_workflow = __esm({
2022
2241
  import { tool } from "ai";
2023
2242
 
2024
2243
  // src/ai/approve-by-human-tool-core.ts
2025
- import { z as z4 } from "zod";
2244
+ import { z as z6 } from "zod";
2026
2245
 
2027
2246
  // src/ai/context.ts
2028
2247
  init_client();
@@ -2176,11 +2395,11 @@ var APPROVE_BY_HUMAN_ACTIONS4 = [
2176
2395
  { id: "approve", title: "Approve" },
2177
2396
  { id: "decline", title: "Decline" }
2178
2397
  ];
2179
- var approveByHumanInputSchema = z4.object({
2180
- type: z4.string().optional().describe("Task type slug; defaults to ai-approval"),
2181
- name: z4.string().describe("Short title for the approval request"),
2182
- description: z4.string().describe("What needs approval and the consequences of approving or declining"),
2183
- contextSummary: z4.string().optional().describe("Optional markdown summary shown to the reviewer")
2398
+ var approveByHumanInputSchema = z6.object({
2399
+ type: z6.string().optional().describe("Task type slug; defaults to ai-approval"),
2400
+ name: z6.string().describe("Short title for the approval request"),
2401
+ description: z6.string().describe("What needs approval and the consequences of approving or declining"),
2402
+ contextSummary: z6.string().optional().describe("Optional markdown summary shown to the reviewer")
2184
2403
  });
2185
2404
  function resolveApproveByHumanToolConfig(clientOrContext, maybeOptions = {}) {
2186
2405
  const isDurable = typeof clientOrContext === "object" && clientOrContext !== null && "mode" in clientOrContext && (clientOrContext.mode === "trigger" || clientOrContext.mode === "workflow");
@@ -2230,16 +2449,16 @@ import { tool as tool2 } from "ai";
2230
2449
 
2231
2450
  // src/ai/create-send-to-human-tool-core.ts
2232
2451
  init_schemas2();
2233
- import { z as z5 } from "zod";
2234
- var sendToHumanToolInputSchema = z5.object({
2235
- type: z5.string().describe("Task type slug shown in the RobotRock inbox"),
2236
- name: z5.string().describe("Short title for the human reviewer"),
2237
- description: z5.string().optional().describe("What you need from the human and why you cannot proceed alone"),
2238
- context: z5.object({
2239
- data: z5.record(z5.string(), z5.unknown()).optional(),
2240
- ui: z5.record(z5.string(), z5.unknown()).optional()
2452
+ import { z as z7 } from "zod";
2453
+ var sendToHumanToolInputSchema = z7.object({
2454
+ type: z7.string().describe("Task type slug shown in the RobotRock inbox"),
2455
+ name: z7.string().describe("Short title for the human reviewer"),
2456
+ description: z7.string().optional().describe("What you need from the human and why you cannot proceed alone"),
2457
+ context: z7.object({
2458
+ data: z7.record(z7.string(), z7.unknown()).optional(),
2459
+ ui: z7.record(z7.string(), z7.unknown()).optional()
2241
2460
  }).optional().describe("Optional structured context for the inbox UI"),
2242
- validUntil: z5.string().datetime().optional().describe("Optional ISO deadline for the task"),
2461
+ validUntil: z7.string().datetime().optional().describe("Optional ISO deadline for the task"),
2243
2462
  assignTo: assignToSchema2.optional().describe(
2244
2463
  "Assign to tenant member emails and/or group slugs; narrows who sees the task in the inbox"
2245
2464
  )
@@ -2293,12 +2512,12 @@ import { tool as tool3 } from "ai";
2293
2512
  // src/ai/create-send-update-tool-core.ts
2294
2513
  init_schemas2();
2295
2514
  init_client();
2296
- import { z as z6 } from "zod";
2297
- var sendUpdateToolInputSchema = z6.object({
2298
- threadId: z6.string().optional().describe(
2515
+ import { z as z8 } from "zod";
2516
+ var sendUpdateToolInputSchema = z8.object({
2517
+ threadId: z8.string().optional().describe(
2299
2518
  "Thread to post the update to. Use the `threadId` returned by a prior send-to-human task. Omit only when a session threadId is configured on the tool."
2300
2519
  ),
2301
- message: z6.string().describe("Short progress update (1-2 sentences) shown in the inbox status bar"),
2520
+ message: z8.string().describe("Short progress update (1-2 sentences) shown in the inbox status bar"),
2302
2521
  status: threadUpdateStatusSchema2.optional().describe(
2303
2522
  "Lifecycle status driving the status-bar icon/color: info, queued, running, waiting, succeeded, failed, cancelled"
2304
2523
  )
@@ -2358,23 +2577,23 @@ function createSendUpdateTool(clientOrOptions, maybeOptions = {}) {
2358
2577
  import { tool as tool4 } from "ai";
2359
2578
 
2360
2579
  // src/ai/request-action-input-tool-core.ts
2361
- import { z as z7 } from "zod";
2580
+ import { z as z9 } from "zod";
2362
2581
  var REQUEST_ACTION_INPUT_TOOL_NAME = "requestActionInput";
2363
2582
  function defaultRequestActionInputActionId(title) {
2364
2583
  const slug = title.trim().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
2365
2584
  return slug.length > 0 ? slug : "submit";
2366
2585
  }
2367
- var requestActionInputActionSchema = z7.object({
2368
- id: z7.string().min(1).optional().describe(
2586
+ var requestActionInputActionSchema = z9.object({
2587
+ id: z9.string().min(1).optional().describe(
2369
2588
  "Stable action identifier echoed in tool output (e.g. pick-blog-topic). Strongly recommended \u2014 auto-derived from title when omitted."
2370
2589
  ),
2371
- title: z7.string().min(1),
2372
- description: z7.string().optional(),
2373
- schema: z7.record(z7.string(), z7.unknown()).optional().describe("JSON Schema object for the human feedback form"),
2374
- ui: z7.record(z7.string(), z7.unknown()).optional().describe(
2590
+ title: z9.string().min(1),
2591
+ description: z9.string().optional(),
2592
+ schema: z9.record(z9.string(), z9.unknown()).optional().describe("JSON Schema object for the human feedback form"),
2593
+ ui: z9.record(z9.string(), z9.unknown()).optional().describe(
2375
2594
  'RJSF ui schema overrides (ui:widget, ui:enumNames, etc.). Use ui:widget "radio" for 2\u20136 discrete choices rendered as tappable cards.'
2376
2595
  ),
2377
- data: z7.record(z7.string(), z7.unknown()).optional().describe("Optional default form field values")
2596
+ data: z9.record(z9.string(), z9.unknown()).optional().describe("Optional default form field values")
2378
2597
  });
2379
2598
  function normalizeRequestActionInputToolInput(input) {
2380
2599
  const parsed = requestActionInputToolInputSchema.parse(input);
@@ -2386,12 +2605,12 @@ function normalizeRequestActionInputToolInput(input) {
2386
2605
  }
2387
2606
  };
2388
2607
  }
2389
- var requestActionInputToolOutputSchema = z7.object({
2390
- actionId: z7.string().min(1),
2391
- data: z7.record(z7.string(), z7.unknown())
2608
+ var requestActionInputToolOutputSchema = z9.object({
2609
+ actionId: z9.string().min(1),
2610
+ data: z9.record(z9.string(), z9.unknown())
2392
2611
  });
2393
- var requestActionInputToolInputSchema = z7.object({
2394
- prompt: z7.string().optional().describe("Optional heading shown above the action widget in chat"),
2612
+ var requestActionInputToolInputSchema = z9.object({
2613
+ prompt: z9.string().optional().describe("Optional heading shown above the action widget in chat"),
2395
2614
  action: requestActionInputActionSchema.describe(
2396
2615
  "Action widget config: JSON Schema form fields and optional RJSF ui overrides (same shape as RobotRock inbox actions)"
2397
2616
  )
@@ -2418,25 +2637,25 @@ function requestActionInputTool(options = {}) {
2418
2637
  import { tool as tool5 } from "ai";
2419
2638
 
2420
2639
  // src/ai/report-status-tool-core.ts
2421
- import { z as z8 } from "zod";
2640
+ import { z as z10 } from "zod";
2422
2641
  var REPORT_STATUS_TOOL_NAME = "reportStatus";
2423
- var reportStatusPhaseSchema = z8.enum([
2642
+ var reportStatusPhaseSchema = z10.enum([
2424
2643
  "info",
2425
2644
  "running",
2426
2645
  "waiting",
2427
2646
  "succeeded",
2428
2647
  "failed"
2429
2648
  ]);
2430
- var reportStatusToolInputSchema = z8.object({
2431
- message: z8.string().min(1).describe(
2649
+ var reportStatusToolInputSchema = z10.object({
2650
+ message: z10.string().min(1).describe(
2432
2651
  "Short progress update shown in chat (1-2 sentences). Use while researching, drafting, or waiting on external work."
2433
2652
  ),
2434
2653
  phase: reportStatusPhaseSchema.optional().describe(
2435
2654
  "Lifecycle phase for the status marker. Defaults to running. Use succeeded or failed when a step finishes."
2436
2655
  )
2437
2656
  });
2438
- var reportStatusToolOutputSchema = z8.object({
2439
- message: z8.string().min(1),
2657
+ var reportStatusToolOutputSchema = z10.object({
2658
+ message: z10.string().min(1),
2440
2659
  phase: reportStatusPhaseSchema
2441
2660
  });
2442
2661
  function normalizeReportStatusToolInput(input) {
@@ -2475,10 +2694,10 @@ function reportStatusTool(options = {}) {
2475
2694
  import { tool as tool6 } from "ai";
2476
2695
 
2477
2696
  // src/ai/close-chat-tool-core.ts
2478
- import { z as z9 } from "zod";
2697
+ import { z as z11 } from "zod";
2479
2698
  var CLOSE_CHAT_TOOL_NAME = "closeChat";
2480
- var closeChatToolInputSchema = z9.object({
2481
- reason: z9.string().optional().describe(
2699
+ var closeChatToolInputSchema = z11.object({
2700
+ reason: z11.string().optional().describe(
2482
2701
  "Short reason the conversation is being closed (recorded on the audit trail)."
2483
2702
  )
2484
2703
  });