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
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { R as RobotRock, a as SendToHumanInput, S as SendToHumanActionInput, n as SendUpdateInput } from './client-XTnFHGFE.js';
2
+ import { R as RobotRock, a as SendToHumanInput, S as SendToHumanActionInput, o as SendUpdateInput } from './client-YO9Y1rkH.js';
3
3
  import { DiscriminatedApprovalResult, ThreadUpdate } from './schemas/index.js';
4
4
  import { ToolApprovalResponse } from 'ai';
5
5
 
@@ -0,0 +1,25 @@
1
+ /** Field name agents read; dashboard widgets must ignore when rendering. */
2
+ declare const TOOL_REPLY_GUIDANCE_FIELD: "replyGuidance";
3
+ declare const WHOAMI_REPLY_GUIDANCE = "The dashboard shows a profile card with name, email, workspace, role, and groups. Do not restate those in your reply. Only add context not in the card (e.g. permissions, refund approval rules, missing group membership).";
4
+ declare const MY_ACCESS_REPLY_GUIDANCE = "Access details may render in chat UI. Do not restate role, groups, or admin capabilities if already visible. Only explain what the user can or cannot do for their question (e.g. finance group required for refunds \u2265 $10,000). When access.tenantAdmin is false and the user needs manageTeam, manageGroups, or query-tasks capabilities, explain briefly then call ask_question to offer sending an admin request to tenant admins \u2014 do not tell them to find an admin manually without offering delegation first.";
5
+ declare const CREATE_INBOX_TASK_REPLY_GUIDANCE = "A task card shows title, assignee, and inbox status in chat. Do not restate task ID, assignee, or delegation details from the card. Only mention next steps or answer the user's question.";
6
+ declare const SEARCH_PRODUCTS_REPLY_GUIDANCE = "Product results render as a list card in chat. Do not restate product names, prices, or SKUs. Only add context not in the list (e.g. no matches, recommendations).";
7
+ declare const MANAGE_TEAM_MEMBERS_LIST_REPLY_GUIDANCE = "Team members render as a list card in chat. Do not restate names, emails, or roles from the list. Only add context not shown (e.g. duplicates, next admin actions).";
8
+ declare const MANAGE_TEAM_MEMBERS_DETAIL_REPLY_GUIDANCE = "Team member details render in chat UI. Do not restate name, email, or role from the card. Only add next steps or policy context.";
9
+ declare const MANAGE_GROUPS_LIST_REPLY_GUIDANCE = "Groups render as a list card in chat. Do not restate group names, slugs, or descriptions from the list. Use slug (not internal id) for get, update, delete, and membership actions. Only add context not shown.";
10
+ declare const MANAGE_GROUPS_DETAIL_REPLY_GUIDANCE = "Group details render in chat UI. Do not restate fields already visible in the card. Only add next steps.";
11
+ declare const QUERY_TASKS_LIST_REPLY_GUIDANCE = "Tasks render as a list card in chat. Do not restate task names, ids, or statuses from the list. Only add context not shown (e.g. filters applied, recommended next action).";
12
+ declare const QUERY_TASKS_DETAIL_REPLY_GUIDANCE = "Task details render in chat UI. Do not restate fields already visible in the card. Only add analysis or next steps.";
13
+ declare const REFUND_CHARGE_REPLY_GUIDANCE = "Refund details render in chat UI. Do not restate charge id, amount, or status from the card. Only add policy context or next steps.";
14
+ declare const DEPLOY_RELEASE_REPLY_GUIDANCE = "Deploy details render in chat UI. Do not restate service, version, or environment from the card. Only add rollout context or next steps.";
15
+ declare const GET_WEATHER_REPLY_GUIDANCE = "Weather details render in chat UI. Do not restate city, condition, or temperature from the card. Only add conversational context if needed.";
16
+ declare const ADMIN_MUTATION_REPLY_GUIDANCE = "The action result renders in chat UI. Do not restate fields already visible in the card. Confirm outcome briefly or add next steps only.";
17
+ type ToolResultWithReplyGuidance<T extends Record<string, unknown>> = T & {
18
+ replyGuidance: string;
19
+ };
20
+ /** Attach model-facing narration hints to a tool execute result. */
21
+ declare function withReplyGuidance<T extends Record<string, unknown>>(result: T, guidance: string): ToolResultWithReplyGuidance<T>;
22
+ /** Remove agent-only fields before showing raw JSON in the dashboard. */
23
+ declare function stripAgentOnlyToolFields(output: unknown): unknown;
24
+
25
+ export { ADMIN_MUTATION_REPLY_GUIDANCE as A, CREATE_INBOX_TASK_REPLY_GUIDANCE as C, DEPLOY_RELEASE_REPLY_GUIDANCE as D, GET_WEATHER_REPLY_GUIDANCE as G, MANAGE_GROUPS_DETAIL_REPLY_GUIDANCE as M, QUERY_TASKS_DETAIL_REPLY_GUIDANCE as Q, REFUND_CHARGE_REPLY_GUIDANCE as R, SEARCH_PRODUCTS_REPLY_GUIDANCE as S, type ToolResultWithReplyGuidance as T, WHOAMI_REPLY_GUIDANCE as W, MANAGE_GROUPS_LIST_REPLY_GUIDANCE as a, MANAGE_TEAM_MEMBERS_DETAIL_REPLY_GUIDANCE as b, MANAGE_TEAM_MEMBERS_LIST_REPLY_GUIDANCE as c, MY_ACCESS_REPLY_GUIDANCE as d, QUERY_TASKS_LIST_REPLY_GUIDANCE as e, TOOL_REPLY_GUIDANCE_FIELD as f, stripAgentOnlyToolFields as s, withReplyGuidance as w };
@@ -1,11 +1,12 @@
1
1
  import * as _trigger_dev_sdk from '@trigger.dev/sdk';
2
2
  import { R as RobotRockPlatformOtelFields } from '../otel-platform-DzHyHkGk.js';
3
3
  export { a as RobotRockHandlerWebhookPayload } from '../otel-platform-DzHyHkGk.js';
4
- import { S as SendToHumanActionInput, a as SendToHumanInput } from '../client-XTnFHGFE.js';
4
+ import { S as SendToHumanActionInput, a as SendToHumanInput } from '../client-YO9Y1rkH.js';
5
5
  export { ApprovalResult, DiscriminatedApprovalResult, TaskContextInput, TaskResult } from '../schemas/index.js';
6
6
  import '@opentelemetry/api';
7
7
  import '@robotrock/core';
8
8
  import 'zod';
9
+ import '../auth-headers-qL-ZeEtd.js';
9
10
 
10
11
  type SendToHumanPayload<A extends readonly SendToHumanActionInput[] = readonly SendToHumanActionInput[]> = SendToHumanInput<A> & RobotRockPlatformOtelFields & {
11
12
  /** Inbox app bucket. Overrides `ROBOTROCK_APP` when set. */
@@ -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([
@@ -583,13 +583,27 @@ var createAgentChatBodySchema = z.object({
583
583
  eveConnectionId: z.string().min(1).optional(),
584
584
  /** Source application id; groups the chat under an inbox section. */
585
585
  app: z.string().min(1).optional(),
586
- assignTo: assignToSchema.optional(),
586
+ /** Email of the user who owns the chat. Required unless `parentChatId` is set. */
587
+ ownerEmail: z.string().email().optional(),
587
588
  title: z.string().min(1),
588
589
  messages: z.array(agentChatSeedMessageSchema).default([]),
589
590
  /** Provenance label stored on the session ("cron" | "agent" | ...). */
590
591
  source: z.string().min(1).optional()
591
592
  }).refine((data) => Boolean(data.agentIdentifier || data.parentChatId), {
592
593
  message: "Provide either agentIdentifier or parentChatId"
594
+ }).refine((data) => Boolean(data.ownerEmail || data.parentChatId), {
595
+ message: "Provide ownerEmail unless parentChatId is set"
596
+ });
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()
593
607
  });
594
608
  var agentChatAuditInputBodySchema = z.object({
595
609
  eveSessionId: z.string().min(1),
@@ -629,62 +643,175 @@ var agentChatLinkTaskBodySchema = z.object({
629
643
  toolCallId: z.string().min(1)
630
644
  });
631
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
+ )
757
+ });
758
+
632
759
  // src/schemas/index.ts
633
- var handlerUrlSchema2 = z2.string().refine((url) => isAllowedHandlerUrl(url), {
760
+ var handlerUrlSchema2 = z4.string().refine((url) => isAllowedHandlerUrl(url), {
634
761
  message: HANDLER_URL_ERROR
635
762
  });
636
- var jsonSchema7Schema2 = z2.custom(
763
+ var jsonSchema7Schema2 = z4.custom(
637
764
  (val) => typeof val === "object" && val !== null,
638
765
  { message: "Must be a valid JSON Schema object" }
639
766
  );
640
- var uiSchemaSchema2 = z2.custom((val) => typeof val === "object" && val !== null, {
767
+ var uiSchemaSchema2 = z4.custom((val) => typeof val === "object" && val !== null, {
641
768
  message: "Must be a valid UiSchema object"
642
769
  });
643
- var webhookHandlerSchema2 = z2.object({
644
- type: z2.literal("webhook"),
770
+ var webhookHandlerSchema2 = z4.object({
771
+ type: z4.literal("webhook"),
645
772
  url: handlerUrlSchema2,
646
- headers: z2.record(z2.string(), z2.string())
773
+ headers: z4.record(z4.string(), z4.string())
647
774
  });
648
775
  var triggerHandlerSchema2 = webhookHandlerSchema2.extend({
649
- type: z2.literal("trigger"),
650
- tokenId: z2.string().min(1)
776
+ type: z4.literal("trigger"),
777
+ tokenId: z4.string().min(1)
651
778
  });
652
- var handlerSchema2 = z2.discriminatedUnion("type", [webhookHandlerSchema2, triggerHandlerSchema2]);
653
- var taskActionInputSchema2 = z2.object({
654
- id: z2.string().min(1),
655
- title: z2.string().min(1),
656
- 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(),
657
784
  schema: jsonSchema7Schema2.optional(),
658
785
  ui: uiSchemaSchema2.optional(),
659
- data: z2.record(z2.string(), z2.unknown()).optional()
786
+ data: z4.record(z4.string(), z4.unknown()).optional()
660
787
  });
661
788
  var taskActionSchema2 = taskActionInputSchema2.extend({
662
- handlers: z2.array(handlerSchema2).min(1).optional()
789
+ handlers: z4.array(handlerSchema2).min(1).optional()
663
790
  });
664
- var uiFieldSchemaSchema2 = z2.object({
665
- "ui:widget": z2.string().optional(),
666
- "ui:title": z2.string().optional(),
667
- "ui:description": z2.string().optional(),
668
- "ui:options": z2.record(z2.string(), z2.unknown()).optional(),
669
- 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()
670
797
  }).passthrough();
671
- var contextUiSchema2 = z2.record(z2.string(), uiFieldSchemaSchema2).optional();
672
- var contextDataSchema2 = z2.object({
673
- 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()),
674
801
  ui: contextUiSchema2
675
802
  }).optional();
676
803
  var TASK_CONTEXT_FORMAT_VERSION2 = 2;
677
- var taskContextObjectBaseSchema2 = z2.object({
678
- app: z2.string().min(1).optional(),
679
- type: z2.string().min(1),
680
- name: z2.string().min(1),
681
- description: z2.string().optional(),
682
- 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(),
683
810
  context: contextDataSchema2,
684
- contextVersion: z2.literal(2).optional(),
811
+ contextVersion: z4.literal(2).optional(),
685
812
  /** @deprecated Use `contextVersion`. Accepted on ingest only. */
686
- version: z2.literal(2).optional(),
687
- 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")
688
815
  });
689
816
  function normalizeTaskContextVersion2(data) {
690
817
  const { version: legacyVersion, contextVersion, ...rest } = data;
@@ -700,7 +827,7 @@ function refineContextPublicUrls2(data, ctx) {
700
827
  const error = validateContextPublicUrls(data.context);
701
828
  if (error) {
702
829
  ctx.addIssue({
703
- code: z2.ZodIssueCode.custom,
830
+ code: z4.ZodIssueCode.custom,
704
831
  message: error,
705
832
  path: ["context"]
706
833
  });
@@ -709,9 +836,9 @@ function refineContextPublicUrls2(data, ctx) {
709
836
  var taskContextSchema2 = taskContextObjectSchema2.superRefine(
710
837
  refineContextPublicUrls2
711
838
  );
712
- var assignToSchema2 = z2.object({
713
- users: z2.array(z2.string().email()).optional(),
714
- 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()
715
842
  }).refine(
716
843
  (data) => {
717
844
  const groups = data.groups ?? [];
@@ -722,7 +849,7 @@ var assignToSchema2 = z2.object({
722
849
  },
723
850
  { message: 'Cannot combine "all" with other group slugs' }
724
851
  );
725
- var threadUpdateMessageSchema2 = z2.string().min(1).max(500);
852
+ var threadUpdateMessageSchema2 = z4.string().min(1).max(500);
726
853
  var threadUpdateStatuses2 = [
727
854
  "info",
728
855
  "queued",
@@ -732,15 +859,15 @@ var threadUpdateStatuses2 = [
732
859
  "failed",
733
860
  "cancelled"
734
861
  ];
735
- var threadUpdateStatusSchema2 = z2.enum(threadUpdateStatuses2);
736
- var threadUpdateInputSchema2 = z2.object({
862
+ var threadUpdateStatusSchema2 = z4.enum(threadUpdateStatuses2);
863
+ var threadUpdateInputSchema2 = z4.object({
737
864
  message: threadUpdateMessageSchema2,
738
865
  status: threadUpdateStatusSchema2.optional()
739
866
  });
740
867
  var taskPriorities2 = ["low", "normal", "high", "urgent"];
741
- var taskPrioritySchema2 = z2.enum(taskPriorities2);
742
- var agentTelemetrySchema2 = z2.object({
743
- version: z2.string().min(1)
868
+ var taskPrioritySchema2 = z4.enum(taskPriorities2);
869
+ var agentTelemetrySchema2 = z4.object({
870
+ version: z4.string().min(1)
744
871
  });
745
872
  var createTaskBodySchema2 = taskContextObjectBaseSchema2.extend({
746
873
  assignTo: assignToSchema2.optional(),
@@ -748,7 +875,7 @@ var createTaskBodySchema2 = taskContextObjectBaseSchema2.extend({
748
875
  * Groups related tasks together. When omitted, the server generates one and
749
876
  * returns it so the caller can reuse it on later tasks in the same thread.
750
877
  */
751
- threadId: z2.string().min(1).optional(),
878
+ threadId: z4.string().min(1).optional(),
752
879
  /**
753
880
  * Optional thread priority. When set, applies to the whole thread and
754
881
  * overwrites any previous priority. Omit on later tasks to leave unchanged.
@@ -763,6 +890,65 @@ var createTaskBodySchema2 = taskContextObjectBaseSchema2.extend({
763
890
  }).transform(normalizeTaskContextVersion2).superRefine(refineContextPublicUrls2);
764
891
  var threadUpdateBodySchema = threadUpdateInputSchema2;
765
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
+
766
952
  // src/approval-result.ts
767
953
  var TaskTimeoutError = class extends Error {
768
954
  constructor(message) {
@@ -837,77 +1023,27 @@ function getErrorMessage(data, fallback) {
837
1023
  return fallback;
838
1024
  }
839
1025
 
840
- // ../core/src/handler-retry.ts
841
- var HANDLER_RETRY_DELAYS_MS = [
842
- 6e4,
843
- // 1m
844
- 3e5,
845
- // 5m
846
- 18e5,
847
- // 30m
848
- 36e5,
849
- // 1h
850
- 216e5,
851
- // 6h
852
- 864e5,
853
- // 24h
854
- 1728e5
855
- // 48h
856
- ];
857
- var HANDLER_MAX_ATTEMPTS = HANDLER_RETRY_DELAYS_MS.length + 1;
858
-
859
- // ../core/src/attribution/index.ts
860
- import { z as z3 } from "zod";
861
-
862
- // ../core/src/app-url.ts
863
- var PRODUCTION_APP_URL = "https://app.robotrock.io";
864
- var PRODUCTION_API_URL = "https://api.robotrock.io/v1";
865
- var DEV_API_URL = "http://localhost:4001/v1";
866
- var APP_SIGNUP_URL = `${PRODUCTION_APP_URL}/sign-up`;
867
- function normalizeRobotRockApiBaseUrl(baseUrl) {
868
- const trimmed = baseUrl.trim().replace(/\/+$/, "");
869
- if (trimmed.endsWith("/v1")) {
870
- return trimmed;
871
- }
872
- return `${trimmed}/v1`;
873
- }
874
- function getRobotRockApiBaseUrl() {
875
- const explicit = process.env.ROBOTROCK_BASE_URL?.trim() || process.env.ROBOTROCK_API_URL?.trim();
876
- if (explicit) {
877
- return normalizeRobotRockApiBaseUrl(explicit);
878
- }
879
- if (process.env.NODE_ENV === "production") {
880
- return PRODUCTION_API_URL;
881
- }
882
- return DEV_API_URL;
883
- }
884
-
885
- // ../core/src/attribution/index.ts
886
- var ATTRIBUTION_COOKIE_MAX_AGE = 60 * 60 * 24 * 90;
887
- var attributionSchema = z3.object({
888
- utmSource: z3.string().optional(),
889
- utmMedium: z3.string().optional(),
890
- utmCampaign: z3.string().optional(),
891
- utmContent: z3.string().optional(),
892
- utmTerm: z3.string().optional(),
893
- gclid: z3.string().optional(),
894
- landingUrl: z3.string().optional(),
895
- referrer: z3.string().optional(),
896
- capturedAt: z3.number()
897
- });
898
-
899
1026
  // src/auth-headers.ts
1027
+ var ROBOTROCK_ACTING_USER_ID_HEADER = "x-robotrock-acting-user-id";
900
1028
  function buildRobotRockAuthHeaders(auth) {
901
1029
  if (auth.kind === "apiKey") {
902
- return {
1030
+ const headers2 = {
903
1031
  "X-Api-Key": auth.apiKey
904
1032
  };
1033
+ if (auth.actingUserId?.trim()) {
1034
+ headers2[ROBOTROCK_ACTING_USER_ID_HEADER] = auth.actingUserId.trim();
1035
+ }
1036
+ return headers2;
905
1037
  }
906
- return {
1038
+ const headers = {
907
1039
  Authorization: `Bearer ${auth.token}`,
908
1040
  "X-RobotRock-Tenant-Slug": auth.tenantSlug,
909
1041
  "X-RobotRock-Connection-Id": auth.connectionId
910
1042
  };
1043
+ if (auth.actingUserId?.trim()) {
1044
+ headers[ROBOTROCK_ACTING_USER_ID_HEADER] = auth.actingUserId.trim();
1045
+ }
1046
+ return headers;
911
1047
  }
912
1048
  function resolveRobotRockAuthConfig(overrides) {
913
1049
  if (overrides?.agentService) {
@@ -1051,6 +1187,29 @@ function createChatsApi(config) {
1051
1187
  );
1052
1188
  }
1053
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
+ },
1054
1213
  async linkTask(input) {
1055
1214
  const validation = agentChatLinkTaskBodySchema.safeParse(input);
1056
1215
  if (!validation.success) {
@@ -1153,7 +1312,9 @@ var RobotRock = class {
1153
1312
  create: (task2) => this.createTaskRequest(task2),
1154
1313
  get: (taskId) => this.getTaskById(taskId),
1155
1314
  cancel: (taskId) => this.cancelTaskRequest(taskId),
1156
- sendUpdate: (input) => this.sendThreadUpdate(input)
1315
+ sendUpdate: (input) => this.sendThreadUpdate(input),
1316
+ list: (input) => this.listTasksRequest(input),
1317
+ search: (input) => this.searchTasksRequest(input)
1157
1318
  };
1158
1319
  this.chats = createChatsApi({
1159
1320
  baseUrl: this.baseUrl,
@@ -1350,6 +1511,47 @@ var RobotRock = class {
1350
1511
  );
1351
1512
  }
1352
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
+ }
1353
1555
  };
1354
1556
  function createClient(config) {
1355
1557
  return new RobotRock(config);