robotrock 0.9.0 → 1.1.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 (52) hide show
  1. package/dist/ai/index.d.ts +18 -7
  2. package/dist/ai/index.js +852 -115
  3. package/dist/ai/index.js.map +1 -1
  4. package/dist/ai/trigger.d.ts +4 -3
  5. package/dist/ai/trigger.js +810 -115
  6. package/dist/ai/trigger.js.map +1 -1
  7. package/dist/ai/workflow.d.ts +15 -4
  8. package/dist/ai/workflow.js +729 -115
  9. package/dist/ai/workflow.js.map +1 -1
  10. package/dist/client-XTnFHGFE.d.ts +248 -0
  11. package/dist/eve/agent/index.d.ts +188 -0
  12. package/dist/eve/agent/index.js +2322 -0
  13. package/dist/eve/agent/index.js.map +1 -0
  14. package/dist/eve/index.d.ts +5 -0
  15. package/dist/eve/index.js +446 -0
  16. package/dist/eve/index.js.map +1 -0
  17. package/dist/eve/tools/identity/index.d.ts +6 -0
  18. package/dist/eve/tools/identity/index.js +144 -0
  19. package/dist/eve/tools/identity/index.js.map +1 -0
  20. package/dist/eve/tools/identity/my-access.d.ts +58 -0
  21. package/dist/eve/tools/identity/my-access.js +106 -0
  22. package/dist/eve/tools/identity/my-access.js.map +1 -0
  23. package/dist/eve/tools/identity/whoami.d.ts +45 -0
  24. package/dist/eve/tools/identity/whoami.js +101 -0
  25. package/dist/eve/tools/identity/whoami.js.map +1 -0
  26. package/dist/eve/tools/inbox/create-task.d.ts +113 -0
  27. package/dist/eve/tools/inbox/create-task.js +1557 -0
  28. package/dist/eve/tools/inbox/create-task.js.map +1 -0
  29. package/dist/eve/tools/inbox/index.d.ts +5 -0
  30. package/dist/eve/tools/inbox/index.js +1557 -0
  31. package/dist/eve/tools/inbox/index.js.map +1 -0
  32. package/dist/eve/tools/index.d.ts +17 -0
  33. package/dist/eve/tools/index.js +1654 -0
  34. package/dist/eve/tools/index.js.map +1 -0
  35. package/dist/index-BL9qKHA8.d.ts +141 -0
  36. package/dist/index.d.ts +12 -44
  37. package/dist/index.js +793 -97
  38. package/dist/index.js.map +1 -1
  39. package/dist/schemas/index.d.ts +11 -1
  40. package/dist/schemas/index.js +126 -8
  41. package/dist/schemas/index.js.map +1 -1
  42. package/dist/tenant-5YKDrdC-.d.ts +23 -0
  43. package/dist/{tool-approval-bridge-G765kMJR.d.ts → tool-approval-bridge-C4bTm8vu.d.ts} +93 -2
  44. package/dist/trigger/index.d.ts +2 -1
  45. package/dist/trigger/index.js +495 -87
  46. package/dist/trigger/index.js.map +1 -1
  47. package/dist/{trigger-D0shjqk0.d.ts → trigger-Dn0DFiyU.d.ts} +64 -3
  48. package/dist/workflow/index.d.ts +2 -1
  49. package/dist/workflow/index.js +496 -88
  50. package/dist/workflow/index.js.map +1 -1
  51. package/package.json +44 -7
  52. package/dist/client-Cy7YLxms.d.ts +0 -145
@@ -75,6 +75,13 @@ var init_convex_sanitize = __esm({
75
75
  }
76
76
  });
77
77
 
78
+ // ../core/src/utils/deployment-secret-encryption.ts
79
+ var init_deployment_secret_encryption = __esm({
80
+ "../core/src/utils/deployment-secret-encryption.ts"() {
81
+ "use strict";
82
+ }
83
+ });
84
+
78
85
  // ../core/src/utils/safe-url.ts
79
86
  function normalizeHostname(hostname) {
80
87
  return hostname.toLowerCase().replace(/^\[|\]$/g, "");
@@ -177,6 +184,25 @@ function isBlockedHostname(hostname) {
177
184
  }
178
185
  return isBlockedIpv4(host) || isBlockedIpv6(host);
179
186
  }
187
+ function isLoopbackHandlerUrl(urlString) {
188
+ let url;
189
+ try {
190
+ url = new URL(urlString);
191
+ } catch {
192
+ return false;
193
+ }
194
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
195
+ return false;
196
+ }
197
+ if (url.username || url.password) {
198
+ return false;
199
+ }
200
+ const host = url.hostname.toLowerCase();
201
+ return host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "[::1]" || host.endsWith(".localhost");
202
+ }
203
+ function isAllowedHandlerUrl(urlString) {
204
+ return isPublicHttpUrl(urlString) || isLoopbackHandlerUrl(urlString);
205
+ }
180
206
  function isPublicHttpUrl(urlString) {
181
207
  let url;
182
208
  try {
@@ -192,7 +218,7 @@ function isPublicHttpUrl(urlString) {
192
218
  }
193
219
  return !isBlockedHostname(url.hostname);
194
220
  }
195
- var BLOCKED_HOSTNAMES, PUBLIC_HTTP_URL_ERROR;
221
+ var BLOCKED_HOSTNAMES, PUBLIC_HTTP_URL_ERROR, HANDLER_URL_ERROR;
196
222
  var init_safe_url = __esm({
197
223
  "../core/src/utils/safe-url.ts"() {
198
224
  "use strict";
@@ -202,6 +228,7 @@ var init_safe_url = __esm({
202
228
  "metadata.goog"
203
229
  ]);
204
230
  PUBLIC_HTTP_URL_ERROR = "URL must be a public http:// or https:// address";
231
+ HANDLER_URL_ERROR = "Handler URL must be a public or loopback http:// or https:// address";
205
232
  }
206
233
  });
207
234
 
@@ -218,6 +245,7 @@ var init_utils = __esm({
218
245
  "use strict";
219
246
  init_cn();
220
247
  init_convex_sanitize();
248
+ init_deployment_secret_encryption();
221
249
  init_safe_url();
222
250
  init_task_app();
223
251
  }
@@ -301,7 +329,7 @@ function refineContextPublicUrls(data, ctx) {
301
329
  });
302
330
  }
303
331
  }
304
- var safeUrlSchema, jsonSchema7Schema, uiSchemaSchema, webhookHandlerSchema, triggerHandlerSchema, handlerSchema, taskActionSchema, uiFieldSchemaSchema, contextUiSchema, contextDataSchema, TASK_CONTEXT_FORMAT_VERSION, taskContextObjectBaseSchema, taskContextObjectSchema, taskContextSchema, assignToSchema, threadUpdateMessageSchema, threadUpdateStatuses, threadUpdateStatusSchema, threadUpdateInputSchema, taskPriorities, taskPrioritySchema, agentTelemetrySchema, createTaskBodySchema;
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;
305
333
  var init_task = __esm({
306
334
  "../core/src/schemas/task.ts"() {
307
335
  "use strict";
@@ -310,6 +338,9 @@ var init_task = __esm({
310
338
  safeUrlSchema = z.string().refine((url) => isPublicHttpUrl(url), {
311
339
  message: PUBLIC_HTTP_URL_ERROR
312
340
  });
341
+ handlerUrlSchema = z.string().refine((url) => isAllowedHandlerUrl(url), {
342
+ message: HANDLER_URL_ERROR
343
+ });
313
344
  jsonSchema7Schema = z.custom(
314
345
  (val) => typeof val === "object" && val !== null,
315
346
  { message: "Must be a valid JSON Schema object" }
@@ -319,7 +350,7 @@ var init_task = __esm({
319
350
  });
320
351
  webhookHandlerSchema = z.object({
321
352
  type: z.literal("webhook"),
322
- url: safeUrlSchema,
353
+ url: handlerUrlSchema,
323
354
  headers: z.record(z.string(), z.string())
324
355
  });
325
356
  triggerHandlerSchema = webhookHandlerSchema.extend({
@@ -327,13 +358,15 @@ var init_task = __esm({
327
358
  tokenId: z.string().min(1)
328
359
  });
329
360
  handlerSchema = z.discriminatedUnion("type", [webhookHandlerSchema, triggerHandlerSchema]);
330
- taskActionSchema = z.object({
361
+ taskActionInputSchema = z.object({
331
362
  id: z.string().min(1),
332
363
  title: z.string().min(1),
333
364
  description: z.string().optional(),
334
365
  schema: jsonSchema7Schema.optional(),
335
366
  ui: uiSchemaSchema.optional(),
336
- data: z.record(z.string(), z.unknown()).optional(),
367
+ data: z.record(z.string(), z.unknown()).optional()
368
+ });
369
+ taskActionSchema = taskActionInputSchema.extend({
337
370
  // Optional handlers for this action - if present, must have at least 1
338
371
  handlers: z.array(handlerSchema).min(1).optional()
339
372
  });
@@ -424,6 +457,96 @@ var init_task = __esm({
424
457
  /** Agent release version — not shown in inbox UI. */
425
458
  agent: agentTelemetrySchema.optional()
426
459
  }).transform(normalizeTaskContextVersion).superRefine(refineContextPublicUrls);
460
+ agentChatSeedActionSchema = z.object({
461
+ /** Stable action id echoed back on submit; auto-derived from title when omitted. */
462
+ id: z.string().min(1).optional(),
463
+ title: z.string().min(1),
464
+ description: z.string().optional(),
465
+ /** JSON Schema object for the form fields. */
466
+ schema: z.record(z.string(), z.unknown()).optional(),
467
+ /** RJSF ui schema overrides (ui:widget, ui:enumNames, etc.). */
468
+ ui: z.record(z.string(), z.unknown()).optional(),
469
+ /** Optional default field values. */
470
+ data: z.record(z.string(), z.unknown()).optional()
471
+ });
472
+ agentChatSeedMessageSchema = z.object({
473
+ role: z.enum(["user", "assistant"]),
474
+ text: z.string().min(1),
475
+ /** Optional display-name override for the message sender. */
476
+ senderName: z.string().min(1).optional(),
477
+ /**
478
+ * Optional structured input request rendered as a styled RobotRock action
479
+ * widget below the message text. Use this instead of asking the user to reply
480
+ * in plain text so the request is always a proper action form.
481
+ */
482
+ requestActionInput: z.object({
483
+ prompt: z.string().optional(),
484
+ action: agentChatSeedActionSchema
485
+ }).optional()
486
+ });
487
+ eveAgentChatTransportSchema = z.object({
488
+ kind: z.literal("eve"),
489
+ chatId: z.string().min(1),
490
+ baseUrl: z.string().url(),
491
+ sessionId: z.string().optional(),
492
+ continuationToken: z.string().optional(),
493
+ streamIndex: z.number().int().nonnegative().optional(),
494
+ isStreaming: z.boolean().optional()
495
+ });
496
+ createAgentChatBodySchema = z.object({
497
+ /** Agent id (eve agent name). Required unless `parentChatId` is set. */
498
+ agentIdentifier: z.string().min(1).optional(),
499
+ /** Inherit tenant/connection/agent from an existing chat (agent-spawned chats). */
500
+ parentChatId: z.string().min(1).optional(),
501
+ /** Convex tenantEveConnections id; resolved from the tenant when omitted. */
502
+ eveConnectionId: z.string().min(1).optional(),
503
+ /** Source application id; groups the chat under an inbox section. */
504
+ app: z.string().min(1).optional(),
505
+ assignTo: assignToSchema.optional(),
506
+ title: z.string().min(1),
507
+ messages: z.array(agentChatSeedMessageSchema).default([]),
508
+ /** Provenance label stored on the session ("cron" | "agent" | ...). */
509
+ source: z.string().min(1).optional()
510
+ }).refine((data) => Boolean(data.agentIdentifier || data.parentChatId), {
511
+ message: "Provide either agentIdentifier or parentChatId"
512
+ });
513
+ agentChatAuditInputBodySchema = z.object({
514
+ eveSessionId: z.string().min(1),
515
+ userId: z.string().min(1),
516
+ actionId: z.string().min(1),
517
+ actionTitle: z.string().optional(),
518
+ prompt: z.string().optional(),
519
+ data: z.record(z.string(), z.unknown()).optional(),
520
+ idempotencyKey: z.string().optional(),
521
+ /** Eve input request id — used to merge staged HITL metadata. */
522
+ requestId: z.string().optional(),
523
+ /** Eve tool call id — fallback lookup for staged HITL metadata. */
524
+ toolCallId: z.string().optional()
525
+ });
526
+ eveHitlStagedOptionSchema = z.object({
527
+ id: z.string(),
528
+ label: z.string()
529
+ });
530
+ agentChatStageHitlBodySchema = z.object({
531
+ eveSessionId: z.string().min(1),
532
+ requests: z.array(
533
+ z.object({
534
+ requestId: z.string().min(1),
535
+ toolCallId: z.string().min(1),
536
+ toolName: z.string().min(1),
537
+ prompt: z.string().min(1),
538
+ display: z.enum(["confirmation", "select", "text"]).optional(),
539
+ allowFreeform: z.boolean().optional(),
540
+ options: z.array(eveHitlStagedOptionSchema).optional(),
541
+ toolInput: z.record(z.string(), z.unknown()).optional()
542
+ })
543
+ )
544
+ });
545
+ agentChatLinkTaskBodySchema = z.object({
546
+ eveSessionId: z.string().min(1),
547
+ publicTaskId: z.string().min(1),
548
+ toolCallId: z.string().min(1)
549
+ });
427
550
  }
428
551
  });
429
552
 
@@ -463,14 +586,14 @@ function refineContextPublicUrls2(data, ctx) {
463
586
  });
464
587
  }
465
588
  }
466
- var safeUrlSchema2, jsonSchema7Schema2, uiSchemaSchema2, webhookHandlerSchema2, triggerHandlerSchema2, handlerSchema2, taskActionSchema2, uiFieldSchemaSchema2, contextUiSchema2, contextDataSchema2, TASK_CONTEXT_FORMAT_VERSION2, taskContextObjectBaseSchema2, taskContextObjectSchema2, taskContextSchema2, assignToSchema2, threadUpdateMessageSchema2, threadUpdateStatuses2, threadUpdateStatusSchema2, threadUpdateInputSchema2, taskPriorities2, taskPrioritySchema2, agentTelemetrySchema2, createTaskBodySchema2, threadUpdateBodySchema;
589
+ var handlerUrlSchema2, jsonSchema7Schema2, uiSchemaSchema2, webhookHandlerSchema2, triggerHandlerSchema2, handlerSchema2, taskActionInputSchema2, taskActionSchema2, uiFieldSchemaSchema2, contextUiSchema2, contextDataSchema2, TASK_CONTEXT_FORMAT_VERSION2, taskContextObjectBaseSchema2, taskContextObjectSchema2, taskContextSchema2, assignToSchema2, threadUpdateMessageSchema2, threadUpdateStatuses2, threadUpdateStatusSchema2, threadUpdateInputSchema2, taskPriorities2, taskPrioritySchema2, agentTelemetrySchema2, createTaskBodySchema2, threadUpdateBodySchema;
467
590
  var init_schemas2 = __esm({
468
591
  "src/schemas/index.ts"() {
469
592
  "use strict";
470
593
  init_utils();
471
594
  init_schemas();
472
- safeUrlSchema2 = z2.string().refine((url) => isPublicHttpUrl(url), {
473
- message: PUBLIC_HTTP_URL_ERROR
595
+ handlerUrlSchema2 = z2.string().refine((url) => isAllowedHandlerUrl(url), {
596
+ message: HANDLER_URL_ERROR
474
597
  });
475
598
  jsonSchema7Schema2 = z2.custom(
476
599
  (val) => typeof val === "object" && val !== null,
@@ -481,7 +604,7 @@ var init_schemas2 = __esm({
481
604
  });
482
605
  webhookHandlerSchema2 = z2.object({
483
606
  type: z2.literal("webhook"),
484
- url: safeUrlSchema2,
607
+ url: handlerUrlSchema2,
485
608
  headers: z2.record(z2.string(), z2.string())
486
609
  });
487
610
  triggerHandlerSchema2 = webhookHandlerSchema2.extend({
@@ -489,13 +612,15 @@ var init_schemas2 = __esm({
489
612
  tokenId: z2.string().min(1)
490
613
  });
491
614
  handlerSchema2 = z2.discriminatedUnion("type", [webhookHandlerSchema2, triggerHandlerSchema2]);
492
- taskActionSchema2 = z2.object({
615
+ taskActionInputSchema2 = z2.object({
493
616
  id: z2.string().min(1),
494
617
  title: z2.string().min(1),
495
618
  description: z2.string().optional(),
496
619
  schema: jsonSchema7Schema2.optional(),
497
620
  ui: uiSchemaSchema2.optional(),
498
- data: z2.record(z2.string(), z2.unknown()).optional(),
621
+ data: z2.record(z2.string(), z2.unknown()).optional()
622
+ });
623
+ taskActionSchema2 = taskActionInputSchema2.extend({
499
624
  handlers: z2.array(handlerSchema2).min(1).optional()
500
625
  });
501
626
  uiFieldSchemaSchema2 = z2.object({
@@ -618,6 +743,398 @@ var init_approval_result = __esm({
618
743
  }
619
744
  });
620
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
+ // ../core/src/types/task.ts
800
+ var init_task2 = __esm({
801
+ "../core/src/types/task.ts"() {
802
+ "use strict";
803
+ }
804
+ });
805
+
806
+ // ../core/src/types/json-schema-infer.ts
807
+ var init_json_schema_infer = __esm({
808
+ "../core/src/types/json-schema-infer.ts"() {
809
+ "use strict";
810
+ }
811
+ });
812
+
813
+ // ../core/src/types/index.ts
814
+ var init_types = __esm({
815
+ "../core/src/types/index.ts"() {
816
+ "use strict";
817
+ init_task2();
818
+ init_json_schema_infer();
819
+ }
820
+ });
821
+
822
+ // ../core/src/plans/index.ts
823
+ var init_plans = __esm({
824
+ "../core/src/plans/index.ts"() {
825
+ "use strict";
826
+ }
827
+ });
828
+
829
+ // ../core/src/handler-retry.ts
830
+ var HANDLER_RETRY_DELAYS_MS, HANDLER_MAX_ATTEMPTS;
831
+ var init_handler_retry = __esm({
832
+ "../core/src/handler-retry.ts"() {
833
+ "use strict";
834
+ HANDLER_RETRY_DELAYS_MS = [
835
+ 6e4,
836
+ // 1m
837
+ 3e5,
838
+ // 5m
839
+ 18e5,
840
+ // 30m
841
+ 36e5,
842
+ // 1h
843
+ 216e5,
844
+ // 6h
845
+ 864e5,
846
+ // 24h
847
+ 1728e5
848
+ // 48h
849
+ ];
850
+ HANDLER_MAX_ATTEMPTS = HANDLER_RETRY_DELAYS_MS.length + 1;
851
+ }
852
+ });
853
+
854
+ // ../core/src/legal.ts
855
+ var init_legal = __esm({
856
+ "../core/src/legal.ts"() {
857
+ "use strict";
858
+ }
859
+ });
860
+
861
+ // ../core/src/welcome-task.ts
862
+ var init_welcome_task = __esm({
863
+ "../core/src/welcome-task.ts"() {
864
+ "use strict";
865
+ }
866
+ });
867
+
868
+ // ../core/src/app-url.ts
869
+ function normalizeRobotRockApiBaseUrl(baseUrl) {
870
+ const trimmed = baseUrl.trim().replace(/\/+$/, "");
871
+ if (trimmed.endsWith("/v1")) {
872
+ return trimmed;
873
+ }
874
+ return `${trimmed}/v1`;
875
+ }
876
+ function getRobotRockApiBaseUrl() {
877
+ const explicit = process.env.ROBOTROCK_BASE_URL?.trim() || process.env.ROBOTROCK_API_URL?.trim();
878
+ if (explicit) {
879
+ return normalizeRobotRockApiBaseUrl(explicit);
880
+ }
881
+ if (process.env.NODE_ENV === "production") {
882
+ return PRODUCTION_API_URL;
883
+ }
884
+ return DEV_API_URL;
885
+ }
886
+ var PRODUCTION_APP_URL, PRODUCTION_API_URL, DEV_API_URL, APP_SIGNUP_URL;
887
+ var init_app_url = __esm({
888
+ "../core/src/app-url.ts"() {
889
+ "use strict";
890
+ PRODUCTION_APP_URL = "https://app.robotrock.io";
891
+ PRODUCTION_API_URL = "https://api.robotrock.io/v1";
892
+ DEV_API_URL = "http://localhost:4001/v1";
893
+ APP_SIGNUP_URL = `${PRODUCTION_APP_URL}/sign-up`;
894
+ }
895
+ });
896
+
897
+ // ../core/src/attribution/index.ts
898
+ import { z as z3 } from "zod";
899
+ var ATTRIBUTION_COOKIE_MAX_AGE, attributionSchema;
900
+ var init_attribution = __esm({
901
+ "../core/src/attribution/index.ts"() {
902
+ "use strict";
903
+ init_app_url();
904
+ init_app_url();
905
+ 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()
916
+ });
917
+ }
918
+ });
919
+
920
+ // ../core/src/agent-service-auth.ts
921
+ var init_agent_service_auth = __esm({
922
+ "../core/src/agent-service-auth.ts"() {
923
+ "use strict";
924
+ }
925
+ });
926
+
927
+ // ../core/src/index.ts
928
+ var init_src = __esm({
929
+ "../core/src/index.ts"() {
930
+ "use strict";
931
+ init_schemas();
932
+ init_types();
933
+ init_utils();
934
+ init_plans();
935
+ init_handler_retry();
936
+ init_legal();
937
+ init_welcome_task();
938
+ init_attribution();
939
+ init_app_url();
940
+ init_agent_service_auth();
941
+ }
942
+ });
943
+
944
+ // src/auth-headers.ts
945
+ function buildRobotRockAuthHeaders(auth) {
946
+ if (auth.kind === "apiKey") {
947
+ return {
948
+ "X-Api-Key": auth.apiKey
949
+ };
950
+ }
951
+ return {
952
+ Authorization: `Bearer ${auth.token}`,
953
+ "X-RobotRock-Tenant-Slug": auth.tenantSlug,
954
+ "X-RobotRock-Connection-Id": auth.connectionId
955
+ };
956
+ }
957
+ function resolveRobotRockAuthConfig(overrides) {
958
+ if (overrides?.agentService) {
959
+ return {
960
+ kind: "agentService",
961
+ ...overrides.agentService
962
+ };
963
+ }
964
+ const apiKey = overrides?.apiKey ?? process.env.ROBOTROCK_API_KEY;
965
+ if (!apiKey) {
966
+ throw new Error(
967
+ "RobotRock auth is required. Set ROBOTROCK_API_KEY, ROBOTROCK_AGENT_SERVICE_TOKEN with tenant context, or pass auth when creating the client."
968
+ );
969
+ }
970
+ return { kind: "apiKey", apiKey };
971
+ }
972
+ var init_auth_headers = __esm({
973
+ "src/auth-headers.ts"() {
974
+ "use strict";
975
+ }
976
+ });
977
+
978
+ // src/chats.ts
979
+ function createChatsApi(config) {
980
+ const headers = () => ({
981
+ "Content-Type": "application/json",
982
+ ...buildRobotRockAuthHeaders(config.auth)
983
+ });
984
+ return {
985
+ async create(input) {
986
+ const bodyPayload = {
987
+ ...input,
988
+ app: input.app ?? config.app,
989
+ messages: input.messages ?? []
990
+ };
991
+ const validation = createAgentChatBodySchema.safeParse(bodyPayload);
992
+ if (!validation.success) {
993
+ throw new RobotRockError(
994
+ `Invalid chat: ${validation.error.issues[0]?.message}`,
995
+ 400,
996
+ validation.error.issues
997
+ );
998
+ }
999
+ const response = await fetch(`${config.baseUrl}/agent-chats`, {
1000
+ method: "POST",
1001
+ headers: headers(),
1002
+ body: JSON.stringify(validation.data)
1003
+ });
1004
+ const data = await parseResponseBody(response);
1005
+ if (!response.ok) {
1006
+ throw new RobotRockError(
1007
+ getErrorMessage(data, "Failed to create chat"),
1008
+ response.status,
1009
+ data
1010
+ );
1011
+ }
1012
+ const result = data;
1013
+ return { tenantSlug: result.tenantSlug, chats: result.chats };
1014
+ },
1015
+ async close(chatId, options) {
1016
+ if (!chatId) {
1017
+ throw new RobotRockError("chatId is required to close a chat", 400);
1018
+ }
1019
+ const response = await fetch(
1020
+ `${config.baseUrl}/agent-chats/${encodeURIComponent(chatId)}/close`,
1021
+ {
1022
+ method: "POST",
1023
+ headers: headers(),
1024
+ body: JSON.stringify({ reason: options?.reason })
1025
+ }
1026
+ );
1027
+ if (!response.ok) {
1028
+ const data = await parseResponseBody(response);
1029
+ throw new RobotRockError(
1030
+ getErrorMessage(data, "Failed to close chat"),
1031
+ response.status,
1032
+ data
1033
+ );
1034
+ }
1035
+ },
1036
+ async stageHitlRequests(input) {
1037
+ const validation = agentChatStageHitlBodySchema.safeParse(input);
1038
+ if (!validation.success) {
1039
+ throw new RobotRockError(
1040
+ `Invalid stage HITL input: ${validation.error.issues[0]?.message}`,
1041
+ 400,
1042
+ validation.error.issues
1043
+ );
1044
+ }
1045
+ const response = await fetch(`${config.baseUrl}/agent-chats/stage-hitl`, {
1046
+ method: "POST",
1047
+ headers: headers(),
1048
+ body: JSON.stringify(validation.data)
1049
+ });
1050
+ if (!response.ok) {
1051
+ const data = await parseResponseBody(response);
1052
+ throw new RobotRockError(
1053
+ getErrorMessage(data, "Failed to stage chat HITL requests"),
1054
+ response.status,
1055
+ data
1056
+ );
1057
+ }
1058
+ },
1059
+ async getStagedHitlRequests(eveSessionId) {
1060
+ const trimmed = eveSessionId.trim();
1061
+ if (!trimmed) {
1062
+ throw new RobotRockError("eveSessionId is required", 400);
1063
+ }
1064
+ const url = new URL(`${config.baseUrl}/agent-chats/staged-hitl`);
1065
+ url.searchParams.set("eveSessionId", trimmed);
1066
+ const response = await fetch(url.toString(), {
1067
+ method: "GET",
1068
+ headers: headers()
1069
+ });
1070
+ const data = await parseResponseBody(response);
1071
+ if (!response.ok) {
1072
+ throw new RobotRockError(
1073
+ getErrorMessage(data, "Failed to fetch staged chat HITL requests"),
1074
+ response.status,
1075
+ data
1076
+ );
1077
+ }
1078
+ const requests = data.requests;
1079
+ return Array.isArray(requests) ? requests : [];
1080
+ },
1081
+ async logInputSubmission(input) {
1082
+ const validation = agentChatAuditInputBodySchema.safeParse(input);
1083
+ if (!validation.success) {
1084
+ throw new RobotRockError(
1085
+ `Invalid audit input: ${validation.error.issues[0]?.message}`,
1086
+ 400,
1087
+ validation.error.issues
1088
+ );
1089
+ }
1090
+ const response = await fetch(`${config.baseUrl}/agent-chats/audit-input`, {
1091
+ method: "POST",
1092
+ headers: headers(),
1093
+ body: JSON.stringify(validation.data)
1094
+ });
1095
+ if (!response.ok) {
1096
+ const data = await parseResponseBody(response);
1097
+ throw new RobotRockError(
1098
+ getErrorMessage(data, "Failed to log chat input submission"),
1099
+ response.status,
1100
+ data
1101
+ );
1102
+ }
1103
+ },
1104
+ async linkTask(input) {
1105
+ const validation = agentChatLinkTaskBodySchema.safeParse(input);
1106
+ if (!validation.success) {
1107
+ throw new RobotRockError(
1108
+ `Invalid link task input: ${validation.error.issues[0]?.message}`,
1109
+ 400,
1110
+ validation.error.issues
1111
+ );
1112
+ }
1113
+ const response = await fetch(`${config.baseUrl}/agent-chats/link-task`, {
1114
+ method: "POST",
1115
+ headers: headers(),
1116
+ body: JSON.stringify(validation.data)
1117
+ });
1118
+ if (!response.ok) {
1119
+ const data = await parseResponseBody(response);
1120
+ throw new RobotRockError(
1121
+ getErrorMessage(data, "Failed to link inbox task to chat"),
1122
+ response.status,
1123
+ data
1124
+ );
1125
+ }
1126
+ }
1127
+ };
1128
+ }
1129
+ var init_chats = __esm({
1130
+ "src/chats.ts"() {
1131
+ "use strict";
1132
+ init_src();
1133
+ init_http();
1134
+ init_auth_headers();
1135
+ }
1136
+ });
1137
+
621
1138
  // src/client.ts
622
1139
  function sleep(ms) {
623
1140
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -695,62 +1212,31 @@ function normalizeSendToHumanInput(task2, clientDefaults) {
695
1212
  actions: normalizedActions
696
1213
  };
697
1214
  }
698
- async function parseResponseBody(response) {
699
- const contentType = response.headers.get("content-type") ?? "";
700
- const bodyText = await response.text();
701
- if (!bodyText) {
702
- return null;
703
- }
704
- if (contentType.toLowerCase().includes("application/json")) {
705
- try {
706
- return JSON.parse(bodyText);
707
- } catch {
708
- }
709
- }
710
- try {
711
- return JSON.parse(bodyText);
712
- } catch {
713
- return bodyText;
714
- }
715
- }
716
- function getErrorMessage(data, fallback) {
717
- if (data && typeof data === "object" && !Array.isArray(data)) {
718
- const maybeMessage = data.message;
719
- if (typeof maybeMessage === "string" && maybeMessage.trim()) {
720
- return maybeMessage;
721
- }
722
- }
723
- if (typeof data === "string" && data.trim()) {
724
- const compact = data.replace(/\s+/g, " ").trim();
725
- const snippet = compact.length > 180 ? `${compact.slice(0, 180)}...` : compact;
726
- return `${fallback}. Server returned non-JSON response: ${snippet}`;
727
- }
728
- return fallback;
729
- }
730
- var DEFAULT_POLL_INTERVAL_MS, DEFAULT_TIMEOUT_MS, RobotRockError, RobotRock;
1215
+ var DEFAULT_POLL_INTERVAL_MS, DEFAULT_TIMEOUT_MS, RobotRock;
731
1216
  var init_client = __esm({
732
1217
  "src/client.ts"() {
733
1218
  "use strict";
734
1219
  init_schemas2();
735
1220
  init_approval_result();
1221
+ init_http();
1222
+ init_src();
1223
+ init_chats();
1224
+ init_auth_headers();
1225
+ init_http();
736
1226
  DEFAULT_POLL_INTERVAL_MS = 2e3;
737
1227
  DEFAULT_TIMEOUT_MS = 24 * 60 * 60 * 1e3;
738
- RobotRockError = class extends Error {
739
- constructor(message, statusCode, response) {
740
- super(message);
741
- this.statusCode = statusCode;
742
- this.response = response;
743
- this.name = "RobotRockError";
744
- }
745
- };
746
1228
  RobotRock = class {
747
- apiKey;
1229
+ auth;
748
1230
  baseUrl;
749
1231
  app;
750
1232
  agentVersion;
751
1233
  contextVersion;
752
1234
  webhook;
753
1235
  polling;
1236
+ /** Task CRUD: `create`, `get`, `cancel`, `sendUpdate`. */
1237
+ tasks;
1238
+ /** Chat CRUD: `create`, `close`. */
1239
+ chats;
754
1240
  constructor(config) {
755
1241
  if (config.webhook && config.polling) {
756
1242
  throw new Error(
@@ -758,24 +1244,42 @@ var init_client = __esm({
758
1244
  );
759
1245
  }
760
1246
  const apiKey = config.apiKey ?? process.env.ROBOTROCK_API_KEY;
761
- if (!apiKey) {
1247
+ const agentService = config.agentService;
1248
+ if (apiKey && agentService) {
762
1249
  throw new Error(
763
- "RobotRock API key is required. Set ROBOTROCK_API_KEY or pass apiKey when creating the client."
1250
+ "RobotRock client cannot configure both apiKey and agentService."
764
1251
  );
765
1252
  }
766
- this.apiKey = apiKey;
767
- const rawBase = config.baseUrl ?? "https://api.robotrock.io/v1";
768
- this.baseUrl = rawBase.replace(/\/+$/, "");
1253
+ this.auth = resolveRobotRockAuthConfig({
1254
+ ...apiKey ? { apiKey } : {},
1255
+ ...agentService ? { agentService } : {}
1256
+ });
1257
+ this.baseUrl = config.baseUrl ?? getRobotRockApiBaseUrl();
769
1258
  this.app = config.app;
770
1259
  this.agentVersion = config.version ?? resolveAgentVersionFromEnv();
771
1260
  this.contextVersion = config.advanced?.contextVersion ?? TASK_CONTEXT_FORMAT_VERSION2;
772
1261
  this.webhook = config.webhook;
773
1262
  this.polling = config.polling ?? {};
1263
+ this.tasks = {
1264
+ create: (task2) => this.createTaskRequest(task2),
1265
+ get: (taskId) => this.getTaskById(taskId),
1266
+ cancel: (taskId) => this.cancelTaskRequest(taskId),
1267
+ sendUpdate: (input) => this.sendThreadUpdate(input)
1268
+ };
1269
+ this.chats = createChatsApi({
1270
+ baseUrl: this.baseUrl,
1271
+ auth: this.auth,
1272
+ app: this.app
1273
+ });
774
1274
  }
775
- /**
776
- * Create a task via POST /v1 without waiting for a human response.
777
- */
778
- async createTask(task2) {
1275
+ authHeaders(extra) {
1276
+ return {
1277
+ "Content-Type": "application/json",
1278
+ ...buildRobotRockAuthHeaders(this.auth),
1279
+ ...extra
1280
+ };
1281
+ }
1282
+ async createTaskRequest(task2) {
779
1283
  const normalizedTask = normalizeSendToHumanInput(task2, {
780
1284
  webhook: this.webhook,
781
1285
  app: this.app,
@@ -799,13 +1303,9 @@ var init_client = __esm({
799
1303
  validation.error.issues
800
1304
  );
801
1305
  }
802
- const headers = {
803
- "Content-Type": "application/json",
804
- "X-Api-Key": this.apiKey
805
- };
806
- if (task2.idempotencyKey) {
807
- headers["Idempotency-Key"] = task2.idempotencyKey;
808
- }
1306
+ const headers = this.authHeaders(
1307
+ task2.idempotencyKey ? { "Idempotency-Key": task2.idempotencyKey } : void 0
1308
+ );
809
1309
  const response = await fetch(`${this.baseUrl}/`, {
810
1310
  method: "POST",
811
1311
  headers,
@@ -828,7 +1328,7 @@ var init_client = __esm({
828
1328
  contextVersion: this.contextVersion,
829
1329
  agentVersion: this.agentVersion
830
1330
  });
831
- const createdTaskTask = await this.createTask(task2);
1331
+ const createdTaskTask = await this.createTaskRequest(task2);
832
1332
  const hasHandlers = normalizedTask.actions.some(
833
1333
  (action) => Array.isArray(action.handlers) && action.handlers.length > 0
834
1334
  );
@@ -845,7 +1345,7 @@ var init_client = __esm({
845
1345
  const deadline = validUntilMs !== void 0 ? Math.min(pollingDeadline, validUntilMs) : pollingDeadline;
846
1346
  const taskId = createdTaskTask.taskId;
847
1347
  while (Date.now() < deadline) {
848
- const existing = await this.getTask(taskId);
1348
+ const existing = await this.getTaskById(taskId);
849
1349
  if (existing?.status === "handled" && existing.handled) {
850
1350
  return {
851
1351
  mode: "handled",
@@ -867,15 +1367,38 @@ var init_client = __esm({
867
1367
  }
868
1368
  throw new TaskTimeoutError(`No human response within ${timeoutMs}ms`);
869
1369
  }
1370
+ /**
1371
+ * Create a task via POST /v1 without waiting for a human response.
1372
+ * @deprecated Use `client.tasks.create()` instead.
1373
+ */
1374
+ async createTask(task2) {
1375
+ return this.tasks.create(task2);
1376
+ }
870
1377
  /**
871
1378
  * Get a task by public task id (returned as `task.taskId` from {@link sendToHuman}).
1379
+ * @deprecated Use `client.tasks.get()` instead.
872
1380
  */
873
1381
  async getTask(taskId) {
1382
+ return this.tasks.get(taskId);
1383
+ }
1384
+ /**
1385
+ * Log a status update against a thread.
1386
+ * @deprecated Use `client.tasks.sendUpdate()` instead.
1387
+ */
1388
+ async sendUpdate(input) {
1389
+ return this.tasks.sendUpdate(input);
1390
+ }
1391
+ /**
1392
+ * Cancel a task by public task id.
1393
+ * @deprecated Use `client.tasks.cancel()` instead.
1394
+ */
1395
+ async cancelTask(taskId) {
1396
+ return this.tasks.cancel(taskId);
1397
+ }
1398
+ async getTaskById(taskId) {
874
1399
  const response = await fetch(`${this.baseUrl}/tasks/${taskId}`, {
875
1400
  method: "GET",
876
- headers: {
877
- "X-Api-Key": this.apiKey
878
- }
1401
+ headers: this.authHeaders()
879
1402
  });
880
1403
  if (response.status === 404) {
881
1404
  return null;
@@ -890,11 +1413,11 @@ var init_client = __esm({
890
1413
  }
891
1414
  return data;
892
1415
  }
893
- /**
894
- * Log a status update against a thread. The update shows in the inbox status
895
- * bar and thread update log for every task in the thread.
896
- */
897
- async sendUpdate({ threadId, message, status }) {
1416
+ async sendThreadUpdate({
1417
+ threadId,
1418
+ message,
1419
+ status
1420
+ }) {
898
1421
  if (!threadId) {
899
1422
  throw new RobotRockError("threadId is required to send an update", 400);
900
1423
  }
@@ -910,10 +1433,7 @@ var init_client = __esm({
910
1433
  `${this.baseUrl}/threads/${encodeURIComponent(threadId)}/updates`,
911
1434
  {
912
1435
  method: "POST",
913
- headers: {
914
- "Content-Type": "application/json",
915
- "X-Api-Key": this.apiKey
916
- },
1436
+ headers: this.authHeaders(),
917
1437
  body: JSON.stringify(validation.data)
918
1438
  }
919
1439
  );
@@ -927,12 +1447,10 @@ var init_client = __esm({
927
1447
  }
928
1448
  return data.update;
929
1449
  }
930
- async cancelTask(taskId) {
1450
+ async cancelTaskRequest(taskId) {
931
1451
  const response = await fetch(`${this.baseUrl}/tasks/${taskId}/cancel`, {
932
1452
  method: "POST",
933
- headers: {
934
- "X-Api-Key": this.apiKey
935
- }
1453
+ headers: this.authHeaders()
936
1454
  });
937
1455
  if (!response.ok) {
938
1456
  const data = await parseResponseBody(response);
@@ -949,22 +1467,30 @@ var init_client = __esm({
949
1467
 
950
1468
  // src/env.ts
951
1469
  function resolveRobotRockConfig(overrides) {
1470
+ const agentService = overrides?.agentService;
952
1471
  const apiKey = overrides?.apiKey ?? process.env.ROBOTROCK_API_KEY;
953
- if (!apiKey) {
1472
+ if (agentService && apiKey) {
954
1473
  throw new Error(
955
- "RobotRock API key is required. Set ROBOTROCK_API_KEY or pass apiKey when creating the client."
1474
+ "RobotRock client cannot configure both apiKey and agentService."
956
1475
  );
957
1476
  }
958
- const baseUrl = overrides?.baseUrl ?? process.env.ROBOTROCK_BASE_URL ?? process.env.ROBOTROCK_API_URL ?? DEFAULT_BASE_URL;
1477
+ const baseUrl = overrides?.baseUrl ?? getRobotRockApiBaseUrl();
959
1478
  const app = overrides?.app ?? process.env.ROBOTROCK_APP;
1479
+ if (agentService) {
1480
+ return app ? { agentService, baseUrl, app } : { agentService, baseUrl };
1481
+ }
1482
+ if (!apiKey) {
1483
+ throw new Error(
1484
+ "RobotRock API key is required. Set ROBOTROCK_API_KEY or pass agentService when creating the client."
1485
+ );
1486
+ }
960
1487
  return app ? { apiKey, baseUrl, app } : { apiKey, baseUrl };
961
1488
  }
962
- var DEFAULT_BASE_URL;
963
1489
  var init_env = __esm({
964
1490
  "src/env.ts"() {
965
1491
  "use strict";
966
1492
  init_client();
967
- DEFAULT_BASE_URL = "https://api.robotrock.io/v1";
1493
+ init_src();
968
1494
  }
969
1495
  });
970
1496
 
@@ -1470,7 +1996,7 @@ async function sendRobotRockUpdate(payload) {
1470
1996
  ...baseConfig.version ? { version: baseConfig.version } : {},
1471
1997
  ...baseConfig.advanced ? { advanced: baseConfig.advanced } : {}
1472
1998
  });
1473
- return client.sendUpdate(update);
1999
+ return client.tasks.sendUpdate(update);
1474
2000
  }
1475
2001
  async function sendUpdateInWorkflow(payload) {
1476
2002
  return sendRobotRockUpdate(payload);
@@ -1493,7 +2019,7 @@ var init_workflow = __esm({
1493
2019
  });
1494
2020
 
1495
2021
  // src/ai/approve-by-human-tool-core.ts
1496
- import { z as z3 } from "zod";
2022
+ import { z as z4 } from "zod";
1497
2023
 
1498
2024
  // src/ai/context.ts
1499
2025
  init_client();
@@ -1569,9 +2095,9 @@ async function sendUpdateForAi(context2, payload) {
1569
2095
  const client = createClient(
1570
2096
  resolveRobotRockConfig(context2.app ? { app: context2.app } : void 0)
1571
2097
  );
1572
- return client.sendUpdate(payload);
2098
+ return client.tasks.sendUpdate(payload);
1573
2099
  }
1574
- return context2.client.sendUpdate(payload);
2100
+ return context2.client.tasks.sendUpdate(payload);
1575
2101
  }
1576
2102
  async function approveByHumanForAi(context2, payload) {
1577
2103
  if (context2.mode === "trigger") {
@@ -1630,11 +2156,11 @@ function toHumanToolResult(result) {
1630
2156
  }
1631
2157
 
1632
2158
  // src/ai/approve-by-human-tool-core.ts
1633
- var approveByHumanInputSchema = z3.object({
1634
- type: z3.string().optional().describe("Task type slug; defaults to ai-approval"),
1635
- name: z3.string().describe("Short title for the approval request"),
1636
- description: z3.string().describe("What needs approval and the consequences of approving or declining"),
1637
- contextSummary: z3.string().optional().describe("Optional markdown summary shown to the reviewer")
2159
+ var approveByHumanInputSchema = z4.object({
2160
+ type: z4.string().optional().describe("Task type slug; defaults to ai-approval"),
2161
+ name: z4.string().describe("Short title for the approval request"),
2162
+ description: z4.string().describe("What needs approval and the consequences of approving or declining"),
2163
+ contextSummary: z4.string().optional().describe("Optional markdown summary shown to the reviewer")
1638
2164
  });
1639
2165
  function resolveApproveByHumanToolConfig(clientOrContext, maybeOptions = {}) {
1640
2166
  const isDurable = typeof clientOrContext === "object" && clientOrContext !== null && "mode" in clientOrContext && (clientOrContext.mode === "trigger" || clientOrContext.mode === "workflow");
@@ -1676,16 +2202,16 @@ function buildApproveByHumanToolDefinition(clientOrContext, maybeOptions = {}) {
1676
2202
 
1677
2203
  // src/ai/create-send-to-human-tool-core.ts
1678
2204
  init_schemas2();
1679
- import { z as z4 } from "zod";
1680
- var sendToHumanToolInputSchema = z4.object({
1681
- type: z4.string().describe("Task type slug shown in the RobotRock inbox"),
1682
- name: z4.string().describe("Short title for the human reviewer"),
1683
- description: z4.string().optional().describe("What you need from the human and why you cannot proceed alone"),
1684
- context: z4.object({
1685
- data: z4.record(z4.string(), z4.unknown()).optional(),
1686
- ui: z4.record(z4.string(), z4.unknown()).optional()
2205
+ import { z as z5 } from "zod";
2206
+ var sendToHumanToolInputSchema = z5.object({
2207
+ type: z5.string().describe("Task type slug shown in the RobotRock inbox"),
2208
+ name: z5.string().describe("Short title for the human reviewer"),
2209
+ description: z5.string().optional().describe("What you need from the human and why you cannot proceed alone"),
2210
+ context: z5.object({
2211
+ data: z5.record(z5.string(), z5.unknown()).optional(),
2212
+ ui: z5.record(z5.string(), z5.unknown()).optional()
1687
2213
  }).optional().describe("Optional structured context for the inbox UI"),
1688
- validUntil: z4.string().datetime().optional().describe("Optional ISO deadline for the task"),
2214
+ validUntil: z5.string().datetime().optional().describe("Optional ISO deadline for the task"),
1689
2215
  assignTo: assignToSchema2.optional().describe(
1690
2216
  "Assign to tenant member emails and/or group slugs; narrows who sees the task in the inbox"
1691
2217
  )
@@ -1731,12 +2257,12 @@ function buildSendToHumanToolDefinition(clientOrOptions, maybeOptions) {
1731
2257
  // src/ai/create-send-update-tool-core.ts
1732
2258
  init_schemas2();
1733
2259
  init_client();
1734
- import { z as z5 } from "zod";
1735
- var sendUpdateToolInputSchema = z5.object({
1736
- threadId: z5.string().optional().describe(
2260
+ import { z as z6 } from "zod";
2261
+ var sendUpdateToolInputSchema = z6.object({
2262
+ threadId: z6.string().optional().describe(
1737
2263
  "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."
1738
2264
  ),
1739
- message: z5.string().describe("Short progress update (1-2 sentences) shown in the inbox status bar"),
2265
+ message: z6.string().describe("Short progress update (1-2 sentences) shown in the inbox status bar"),
1740
2266
  status: threadUpdateStatusSchema2.optional().describe(
1741
2267
  "Lifecycle status driving the status-bar icon/color: info, queued, running, waiting, succeeded, failed, cancelled"
1742
2268
  )
@@ -1787,6 +2313,84 @@ function buildSendUpdateToolDefinition(clientOrOptions, maybeOptions = {}) {
1787
2313
  };
1788
2314
  }
1789
2315
 
2316
+ // src/ai/request-action-input-tool-core.ts
2317
+ import { z as z7 } from "zod";
2318
+ var requestActionInputActionSchema = z7.object({
2319
+ id: z7.string().min(1).optional().describe(
2320
+ "Stable action identifier echoed in tool output (e.g. pick-blog-topic). Strongly recommended \u2014 auto-derived from title when omitted."
2321
+ ),
2322
+ title: z7.string().min(1),
2323
+ description: z7.string().optional(),
2324
+ schema: z7.record(z7.string(), z7.unknown()).optional().describe("JSON Schema object for the human feedback form"),
2325
+ ui: z7.record(z7.string(), z7.unknown()).optional().describe(
2326
+ 'RJSF ui schema overrides (ui:widget, ui:enumNames, etc.). Use ui:widget "radio" for 2\u20136 discrete choices rendered as tappable cards.'
2327
+ ),
2328
+ data: z7.record(z7.string(), z7.unknown()).optional().describe("Optional default form field values")
2329
+ });
2330
+ var requestActionInputToolOutputSchema = z7.object({
2331
+ actionId: z7.string().min(1),
2332
+ data: z7.record(z7.string(), z7.unknown())
2333
+ });
2334
+ var requestActionInputToolInputSchema = z7.object({
2335
+ prompt: z7.string().optional().describe("Optional heading shown above the action widget in chat"),
2336
+ action: requestActionInputActionSchema.describe(
2337
+ "Action widget config: JSON Schema form fields and optional RJSF ui overrides (same shape as RobotRock inbox actions)"
2338
+ )
2339
+ });
2340
+ function buildRequestActionInputToolDefinition(options = {}) {
2341
+ const description = options.description ?? `Ask the user for structured input via a RobotRock action widget in chat. Always set action.id (e.g. "pick-blog-topic") and action.title. Provide action.schema and optional action.ui using the same JSON Schema and RJSF ui shape as inbox action widgets. Put every field you need in a single call \u2014 never invoke this tool more than once per turn. For 2\u20136 discrete options, use a string enum with ui:widget "radio" and ui:enumNames \u2014 never markdown bullet lists. After the tool returns, act on the user's data immediately; do not ask them to confirm choices they already submitted.`;
2342
+ return {
2343
+ description,
2344
+ inputSchema: requestActionInputToolInputSchema,
2345
+ outputSchema: requestActionInputToolOutputSchema
2346
+ };
2347
+ }
2348
+
2349
+ // src/ai/report-status-tool-core.ts
2350
+ import { z as z8 } from "zod";
2351
+ var reportStatusPhaseSchema = z8.enum([
2352
+ "info",
2353
+ "running",
2354
+ "waiting",
2355
+ "succeeded",
2356
+ "failed"
2357
+ ]);
2358
+ var reportStatusToolInputSchema = z8.object({
2359
+ message: z8.string().min(1).describe(
2360
+ "Short progress update shown in chat (1-2 sentences). Use while researching, drafting, or waiting on external work."
2361
+ ),
2362
+ phase: reportStatusPhaseSchema.optional().describe(
2363
+ "Lifecycle phase for the status marker. Defaults to running. Use succeeded or failed when a step finishes."
2364
+ )
2365
+ });
2366
+ var reportStatusToolOutputSchema = z8.object({
2367
+ message: z8.string().min(1),
2368
+ phase: reportStatusPhaseSchema
2369
+ });
2370
+ function normalizeReportStatusToolInput(input) {
2371
+ const parsed = reportStatusToolInputSchema.parse(input);
2372
+ return {
2373
+ message: parsed.message.trim(),
2374
+ phase: parsed.phase
2375
+ };
2376
+ }
2377
+ async function executeReportStatusTool(input) {
2378
+ const normalized = normalizeReportStatusToolInput(input);
2379
+ return {
2380
+ message: normalized.message,
2381
+ phase: normalized.phase ?? "running"
2382
+ };
2383
+ }
2384
+ function buildReportStatusToolDefinition(options = {}) {
2385
+ const description = options.description ?? 'Post a short progress update to the chat UI while you work. Call this before and during long steps (research, drafting, tool runs) so the user sees what is happening. Use phase "running" while in progress, "succeeded" or "failed" when a step completes, and "waiting" when blocked on external input.';
2386
+ return {
2387
+ description,
2388
+ inputSchema: reportStatusToolInputSchema,
2389
+ outputSchema: reportStatusToolOutputSchema,
2390
+ execute: executeReportStatusTool
2391
+ };
2392
+ }
2393
+
1790
2394
  // src/ai/workflow-tools.ts
1791
2395
  function approveByHumanTool(clientOrContext, maybeOptions = {}) {
1792
2396
  return buildApproveByHumanToolDefinition(clientOrContext, maybeOptions);
@@ -1797,6 +2401,12 @@ function createSendToHumanTool(clientOrOptions, maybeOptions) {
1797
2401
  function createSendUpdateTool(clientOrOptions, maybeOptions = {}) {
1798
2402
  return buildSendUpdateToolDefinition(clientOrOptions, maybeOptions);
1799
2403
  }
2404
+ function requestActionInputTool(options = {}) {
2405
+ return buildRequestActionInputToolDefinition(options);
2406
+ }
2407
+ function reportStatusTool(options = {}) {
2408
+ return buildReportStatusToolDefinition(options);
2409
+ }
1800
2410
  function createRobotRockAiTools(options = {}) {
1801
2411
  const context2 = { mode: "workflow", app: options.app };
1802
2412
  return {
@@ -1811,7 +2421,9 @@ function createRobotRockAiTools(options = {}) {
1811
2421
  ...context2,
1812
2422
  ...options.threadId ? { threadId: options.threadId } : {},
1813
2423
  ...toolOptions
1814
- })
2424
+ }),
2425
+ requestActionInput: (toolOptions = {}) => buildRequestActionInputToolDefinition(toolOptions),
2426
+ reportStatus: (toolOptions = {}) => buildReportStatusToolDefinition(toolOptions)
1815
2427
  };
1816
2428
  }
1817
2429
 
@@ -2075,6 +2687,8 @@ export {
2075
2687
  createRobotRockToolApproval,
2076
2688
  createSendToHumanTool,
2077
2689
  createSendUpdateTool,
2690
+ reportStatusTool,
2691
+ requestActionInputTool,
2078
2692
  resolveToolApprovalsViaRobotRock,
2079
2693
  runWithRobotRockApprovals
2080
2694
  };