robotrock 0.9.0 → 1.0.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.
@@ -1,7 +1,7 @@
1
1
  import { Tool } from 'ai';
2
2
  import { z } from 'zod';
3
- import { R as RobotRock, S as SendToHumanActionInput } from './client-Cy7YLxms.js';
4
- import { A as ApproveByHumanToolDurableOptions, a as ApproveByHumanToolOptions, y as approveByHumanInputSchema, H as HumanToolResult, e as CreateSendToHumanToolDurableOptions, C as CreateSendToHumanToolOptions, G as sendToHumanToolInputSchema, f as CreateSendUpdateToolDurableOptions, c as CreateSendUpdateToolOptions, J as sendUpdateToolInputSchema, w as SendUpdateToolResult, g as RobotRockAiContext } from './tool-approval-bridge-G765kMJR.js';
3
+ import { R as RobotRock, S as SendToHumanActionInput } from './client-CzVmjXpz.js';
4
+ import { A as ApproveByHumanToolDurableOptions, a as ApproveByHumanToolOptions, N as approveByHumanInputSchema, H as HumanToolResult, i as CreateSendToHumanToolDurableOptions, C as CreateSendToHumanToolOptions, a7 as sendToHumanToolInputSchema, j as CreateSendUpdateToolDurableOptions, c as CreateSendUpdateToolOptions, a9 as sendUpdateToolInputSchema, L as SendUpdateToolResult, e as RequestActionInputToolOptions, a4 as requestActionInputToolInputSchema, E as RequestActionInputToolOutput, g as ReportStatusToolOptions, a2 as reportStatusToolInputSchema, B as ReportStatusToolOutput, k as RobotRockAiContext } from './tool-approval-bridge-DbwUEBHv.js';
5
5
 
6
6
  /**
7
7
  * AI SDK tool with fixed approve/decline actions; blocks until a human decides.
@@ -39,6 +39,55 @@ declare function createSendToHumanTool<A extends readonly SendToHumanActionInput
39
39
  */
40
40
  declare function createSendUpdateTool(clientOrOptions: RobotRock | CreateSendUpdateToolDurableOptions, maybeOptions?: CreateSendUpdateToolOptions): Tool<z.infer<typeof sendUpdateToolInputSchema>, SendUpdateToolResult>;
41
41
 
42
+ /**
43
+ * Client-side AI SDK tool that renders a RobotRock action widget in chat.
44
+ *
45
+ * Has no `execute` — the chat UI collects input and calls `addToolOutput`.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * tools: {
50
+ * requestActionInput: requestActionInputTool(),
51
+ * }
52
+ * ```
53
+ */
54
+ declare function requestActionInputTool(options?: RequestActionInputToolOptions): Tool<z.infer<typeof requestActionInputToolInputSchema>, RequestActionInputToolOutput>;
55
+
56
+ /**
57
+ * AI SDK tool that posts ephemeral progress updates to the agent chat UI.
58
+ *
59
+ * Fire-and-forget: executes immediately and renders as a status marker in chat.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * tools: {
64
+ * reportStatus: reportStatusTool(),
65
+ * }
66
+ * ```
67
+ */
68
+ declare function reportStatusTool(options?: ReportStatusToolOptions): Tool<z.infer<typeof reportStatusToolInputSchema>, ReportStatusToolOutput>;
69
+
70
+ declare const CLOSE_CHAT_TOOL_NAME = "closeChat";
71
+ declare const closeChatToolInputSchema: z.ZodObject<{
72
+ reason: z.ZodOptional<z.ZodString>;
73
+ }, z.core.$strip>;
74
+ type CloseChatToolInput = z.infer<typeof closeChatToolInputSchema>;
75
+ type CloseChatToolResult = {
76
+ closed: boolean;
77
+ chatId: string;
78
+ };
79
+ type CloseChatToolOptions = {
80
+ /**
81
+ * Public chatId of the chat the agent is running in. Required — the model
82
+ * does not supply it. The agent runtime passes its own chatId here.
83
+ */
84
+ chatId: string;
85
+ description?: string;
86
+ };
87
+ type CloseChatToolDurableOptions = CloseChatToolOptions & RobotRockAiContext & {
88
+ mode: "trigger" | "workflow";
89
+ };
90
+
42
91
  type CreateRobotRockAiToolsOptions = {
43
92
  /** @default "polling" when `client` is passed; `"trigger"` or `"workflow"` for durable waits. */
44
93
  mode?: "polling" | "trigger" | "workflow";
@@ -49,12 +98,24 @@ type CreateRobotRockAiToolsOptions = {
49
98
  * `sendUpdate` tool to auto-thread onto tasks made by the `sendToHuman` tool.
50
99
  */
51
100
  threadId?: string;
101
+ /**
102
+ * Public chatId of the chat the agent is running in. Enables the `closeChat`
103
+ * tool to close the current chat without the model supplying an id.
104
+ */
105
+ chatId?: string;
52
106
  };
53
107
  type RobotRockAiTools = {
54
108
  context: RobotRockAiContext;
55
109
  approveByHuman: (toolOptions?: ApproveByHumanToolOptions) => Tool<z.infer<typeof approveByHumanInputSchema>, HumanToolResult>;
56
110
  sendToHuman: <A extends readonly SendToHumanActionInput[]>(toolOptions: CreateSendToHumanToolOptions<A>) => Tool<z.infer<typeof sendToHumanToolInputSchema>, HumanToolResult>;
57
111
  sendUpdate: (toolOptions?: CreateSendUpdateToolOptions) => Tool<z.infer<typeof sendUpdateToolInputSchema>, SendUpdateToolResult>;
112
+ requestActionInput: (toolOptions?: RequestActionInputToolOptions) => Tool<z.infer<typeof requestActionInputToolInputSchema>, RequestActionInputToolOutput>;
113
+ reportStatus: (toolOptions?: ReportStatusToolOptions) => Tool<z.infer<typeof reportStatusToolInputSchema>, ReportStatusToolOutput>;
114
+ /**
115
+ * Close the current chat. Requires a `chatId` — from `createRobotRockAiTools`
116
+ * options or per-call `toolOptions`.
117
+ */
118
+ closeChat: (toolOptions?: CloseChatToolOptions) => Tool<z.infer<typeof closeChatToolInputSchema>, CloseChatToolResult>;
58
119
  };
59
120
  /**
60
121
  * Build AI SDK tools for a given RobotRock execution mode.
@@ -76,4 +137,4 @@ type RobotRockAiTools = {
76
137
  */
77
138
  declare function createRobotRockAiTools(options: CreateRobotRockAiToolsOptions): RobotRockAiTools;
78
139
 
79
- export { type CreateRobotRockAiToolsOptions as C, type RobotRockAiTools as R, approveByHumanTool as a, createSendToHumanTool as b, createRobotRockAiTools as c, createSendUpdateTool as d };
140
+ export { type CloseChatToolDurableOptions as C, type RobotRockAiTools as R, type CloseChatToolOptions as a, type CloseChatToolResult as b, closeChatToolInputSchema as c, CLOSE_CHAT_TOOL_NAME as d, type CloseChatToolInput as e, type CreateRobotRockAiToolsOptions as f, approveByHumanTool as g, createRobotRockAiTools as h, createSendToHumanTool as i, createSendUpdateTool as j, requestActionInputTool as k, reportStatusTool as r };
@@ -1,9 +1,10 @@
1
1
  import { ThreadUpdateStatus, DiscriminatedApprovalResult, ThreadUpdate } from '../schemas/index.js';
2
2
  export { ApprovalResult, TaskContextInput, TaskResult } from '../schemas/index.js';
3
- import { S as SendToHumanActionInput, a as SendToHumanInput } from '../client-Cy7YLxms.js';
3
+ import { S as SendToHumanActionInput, a as SendToHumanInput } from '../client-CzVmjXpz.js';
4
4
  import { R as RobotRockPlatformOtelFields } from '../otel-platform-DzHyHkGk.js';
5
5
  export { a as RobotRockHandlerWebhookPayload } from '../otel-platform-DzHyHkGk.js';
6
6
  import 'zod';
7
+ import '@robotrock/core';
7
8
  import '@opentelemetry/api';
8
9
 
9
10
  type SendToHumanWorkflowPayload<A extends readonly SendToHumanActionInput[] = readonly SendToHumanActionInput[]> = SendToHumanInput<A> & RobotRockPlatformOtelFields & {
@@ -251,13 +251,15 @@ var triggerHandlerSchema = webhookHandlerSchema.extend({
251
251
  tokenId: z.string().min(1)
252
252
  });
253
253
  var handlerSchema = z.discriminatedUnion("type", [webhookHandlerSchema, triggerHandlerSchema]);
254
- var taskActionSchema = z.object({
254
+ var taskActionInputSchema = z.object({
255
255
  id: z.string().min(1),
256
256
  title: z.string().min(1),
257
257
  description: z.string().optional(),
258
258
  schema: jsonSchema7Schema.optional(),
259
259
  ui: uiSchemaSchema.optional(),
260
- data: z.record(z.string(), z.unknown()).optional(),
260
+ data: z.record(z.string(), z.unknown()).optional()
261
+ });
262
+ var taskActionSchema = taskActionInputSchema.extend({
261
263
  // Optional handlers for this action - if present, must have at least 1
262
264
  handlers: z.array(handlerSchema).min(1).optional()
263
265
  });
@@ -365,6 +367,56 @@ var createTaskBodySchema = taskContextObjectBaseSchema.extend({
365
367
  /** Agent release version — not shown in inbox UI. */
366
368
  agent: agentTelemetrySchema.optional()
367
369
  }).transform(normalizeTaskContextVersion).superRefine(refineContextPublicUrls);
370
+ var agentChatSeedActionSchema = z.object({
371
+ /** Stable action id echoed back on submit; auto-derived from title when omitted. */
372
+ id: z.string().min(1).optional(),
373
+ title: z.string().min(1),
374
+ description: z.string().optional(),
375
+ /** JSON Schema object for the form fields. */
376
+ schema: z.record(z.string(), z.unknown()).optional(),
377
+ /** RJSF ui schema overrides (ui:widget, ui:enumNames, etc.). */
378
+ ui: z.record(z.string(), z.unknown()).optional(),
379
+ /** Optional default field values. */
380
+ data: z.record(z.string(), z.unknown()).optional()
381
+ });
382
+ var agentChatSeedMessageSchema = z.object({
383
+ role: z.enum(["user", "assistant"]),
384
+ text: z.string().min(1),
385
+ /** Optional display-name override for the message sender. */
386
+ senderName: z.string().min(1).optional(),
387
+ /**
388
+ * Optional structured input request rendered as a styled RobotRock action
389
+ * widget below the message text. Use this instead of asking the user to reply
390
+ * in plain text so the request is always a proper action form.
391
+ */
392
+ requestActionInput: z.object({
393
+ prompt: z.string().optional(),
394
+ action: agentChatSeedActionSchema
395
+ }).optional()
396
+ });
397
+ var createAgentChatBodySchema = z.object({
398
+ /** Trigger chat agent id (task slug). Required unless `parentChatId` is set. */
399
+ agentIdentifier: z.string().min(1).optional(),
400
+ /** Inherit tenant/connection/agent from an existing chat (agent-spawned chats). */
401
+ parentChatId: z.string().min(1).optional(),
402
+ /** Convex tenantTriggerConnections id; resolved from the tenant when omitted. */
403
+ connectionId: z.string().min(1).optional(),
404
+ /** Source application id; groups the chat under an inbox section. */
405
+ app: z.string().min(1).optional(),
406
+ assignTo: assignToSchema.optional(),
407
+ title: z.string().min(1),
408
+ messages: z.array(agentChatSeedMessageSchema).default([]),
409
+ /** Provenance label stored on the session ("cron" | "agent" | ...). */
410
+ source: z.string().min(1).optional()
411
+ }).refine((data) => Boolean(data.agentIdentifier || data.parentChatId), {
412
+ message: "Provide either agentIdentifier or parentChatId"
413
+ });
414
+ var agentChatTransportBodySchema = z.object({
415
+ chatId: z.string().min(1),
416
+ publicAccessToken: z.string().min(1),
417
+ lastEventId: z.string().optional(),
418
+ isStreaming: z.boolean().optional()
419
+ });
368
420
 
369
421
  // src/schemas/index.ts
370
422
  var safeUrlSchema2 = z2.string().refine((url) => isPublicHttpUrl(url), {
@@ -387,13 +439,15 @@ var triggerHandlerSchema2 = webhookHandlerSchema2.extend({
387
439
  tokenId: z2.string().min(1)
388
440
  });
389
441
  var handlerSchema2 = z2.discriminatedUnion("type", [webhookHandlerSchema2, triggerHandlerSchema2]);
390
- var taskActionSchema2 = z2.object({
442
+ var taskActionInputSchema2 = z2.object({
391
443
  id: z2.string().min(1),
392
444
  title: z2.string().min(1),
393
445
  description: z2.string().optional(),
394
446
  schema: jsonSchema7Schema2.optional(),
395
447
  ui: uiSchemaSchema2.optional(),
396
- data: z2.record(z2.string(), z2.unknown()).optional(),
448
+ data: z2.record(z2.string(), z2.unknown()).optional()
449
+ });
450
+ var taskActionSchema2 = taskActionInputSchema2.extend({
397
451
  handlers: z2.array(handlerSchema2).min(1).optional()
398
452
  });
399
453
  var uiFieldSchemaSchema2 = z2.object({
@@ -525,6 +579,149 @@ function toDiscriminatedApprovalResult(actions, task) {
525
579
  };
526
580
  }
527
581
 
582
+ // src/http.ts
583
+ var RobotRockError = class extends Error {
584
+ constructor(message, statusCode, response) {
585
+ super(message);
586
+ this.statusCode = statusCode;
587
+ this.response = response;
588
+ this.name = "RobotRockError";
589
+ }
590
+ };
591
+ async function parseResponseBody(response) {
592
+ const contentType = response.headers.get("content-type") ?? "";
593
+ const bodyText = await response.text();
594
+ if (!bodyText) {
595
+ return null;
596
+ }
597
+ if (contentType.toLowerCase().includes("application/json")) {
598
+ try {
599
+ return JSON.parse(bodyText);
600
+ } catch {
601
+ }
602
+ }
603
+ try {
604
+ return JSON.parse(bodyText);
605
+ } catch {
606
+ return bodyText;
607
+ }
608
+ }
609
+ function getErrorMessage(data, fallback) {
610
+ if (data && typeof data === "object" && !Array.isArray(data)) {
611
+ const maybeMessage = data.message;
612
+ if (typeof maybeMessage === "string" && maybeMessage.trim()) {
613
+ return maybeMessage;
614
+ }
615
+ }
616
+ if (typeof data === "string" && data.trim()) {
617
+ const compact = data.replace(/\s+/g, " ").trim();
618
+ const snippet = compact.length > 180 ? `${compact.slice(0, 180)}...` : compact;
619
+ return `${fallback}. Server returned non-JSON response: ${snippet}`;
620
+ }
621
+ return fallback;
622
+ }
623
+
624
+ // ../core/src/handler-retry.ts
625
+ var HANDLER_RETRY_DELAYS_MS = [
626
+ 6e4,
627
+ // 1m
628
+ 3e5,
629
+ // 5m
630
+ 18e5,
631
+ // 30m
632
+ 36e5,
633
+ // 1h
634
+ 216e5,
635
+ // 6h
636
+ 864e5,
637
+ // 24h
638
+ 1728e5
639
+ // 48h
640
+ ];
641
+ var HANDLER_MAX_ATTEMPTS = HANDLER_RETRY_DELAYS_MS.length + 1;
642
+
643
+ // ../core/src/attribution/index.ts
644
+ import { z as z3 } from "zod";
645
+
646
+ // ../core/src/app-url.ts
647
+ var PRODUCTION_APP_URL = "https://app.robotrock.io";
648
+ var APP_SIGNUP_URL = `${PRODUCTION_APP_URL}/sign-up`;
649
+
650
+ // ../core/src/attribution/index.ts
651
+ var ATTRIBUTION_COOKIE_MAX_AGE = 60 * 60 * 24 * 90;
652
+ var attributionSchema = z3.object({
653
+ utmSource: z3.string().optional(),
654
+ utmMedium: z3.string().optional(),
655
+ utmCampaign: z3.string().optional(),
656
+ utmContent: z3.string().optional(),
657
+ utmTerm: z3.string().optional(),
658
+ gclid: z3.string().optional(),
659
+ landingUrl: z3.string().optional(),
660
+ referrer: z3.string().optional(),
661
+ capturedAt: z3.number()
662
+ });
663
+
664
+ // src/chats.ts
665
+ function createChatsApi(config) {
666
+ const headers = () => ({
667
+ "Content-Type": "application/json",
668
+ "X-Api-Key": config.apiKey
669
+ });
670
+ return {
671
+ async create(input) {
672
+ const bodyPayload = {
673
+ ...input,
674
+ app: input.app ?? config.app,
675
+ messages: input.messages ?? []
676
+ };
677
+ const validation = createAgentChatBodySchema.safeParse(bodyPayload);
678
+ if (!validation.success) {
679
+ throw new RobotRockError(
680
+ `Invalid chat: ${validation.error.issues[0]?.message}`,
681
+ 400,
682
+ validation.error.issues
683
+ );
684
+ }
685
+ const response = await fetch(`${config.baseUrl}/agent-chats`, {
686
+ method: "POST",
687
+ headers: headers(),
688
+ body: JSON.stringify(validation.data)
689
+ });
690
+ const data = await parseResponseBody(response);
691
+ if (!response.ok) {
692
+ throw new RobotRockError(
693
+ getErrorMessage(data, "Failed to create chat"),
694
+ response.status,
695
+ data
696
+ );
697
+ }
698
+ const result = data;
699
+ return { tenantSlug: result.tenantSlug, chats: result.chats };
700
+ },
701
+ async close(chatId, options) {
702
+ if (!chatId) {
703
+ throw new RobotRockError("chatId is required to close a chat", 400);
704
+ }
705
+ const response = await fetch(
706
+ `${config.baseUrl}/agent-chats/${encodeURIComponent(chatId)}/close`,
707
+ {
708
+ method: "POST",
709
+ headers: headers(),
710
+ body: JSON.stringify({ reason: options?.reason })
711
+ }
712
+ );
713
+ if (!response.ok) {
714
+ const data = await parseResponseBody(response);
715
+ throw new RobotRockError(
716
+ getErrorMessage(data, "Failed to close chat"),
717
+ response.status,
718
+ data
719
+ );
720
+ }
721
+ }
722
+ };
723
+ }
724
+
528
725
  // src/client.ts
529
726
  var DEFAULT_POLL_INTERVAL_MS = 2e3;
530
727
  var DEFAULT_TIMEOUT_MS = 24 * 60 * 60 * 1e3;
@@ -562,14 +759,6 @@ function serializeValidUntil(value) {
562
759
  }
563
760
  throw new RobotRockError("Invalid validUntil: expected a Date or parseable date string", 400);
564
761
  }
565
- var RobotRockError = class extends Error {
566
- constructor(message, statusCode, response) {
567
- super(message);
568
- this.statusCode = statusCode;
569
- this.response = response;
570
- this.name = "RobotRockError";
571
- }
572
- };
573
762
  var RobotRock = class {
574
763
  apiKey;
575
764
  baseUrl;
@@ -578,6 +767,10 @@ var RobotRock = class {
578
767
  contextVersion;
579
768
  webhook;
580
769
  polling;
770
+ /** Task CRUD: `create`, `get`, `cancel`, `sendUpdate`. */
771
+ tasks;
772
+ /** Chat CRUD: `create`, `close`. */
773
+ chats;
581
774
  constructor(config) {
582
775
  if (config.webhook && config.polling) {
583
776
  throw new Error(
@@ -598,11 +791,19 @@ var RobotRock = class {
598
791
  this.contextVersion = config.advanced?.contextVersion ?? TASK_CONTEXT_FORMAT_VERSION2;
599
792
  this.webhook = config.webhook;
600
793
  this.polling = config.polling ?? {};
794
+ this.tasks = {
795
+ create: (task) => this.createTaskRequest(task),
796
+ get: (taskId) => this.getTaskById(taskId),
797
+ cancel: (taskId) => this.cancelTaskRequest(taskId),
798
+ sendUpdate: (input) => this.sendThreadUpdate(input)
799
+ };
800
+ this.chats = createChatsApi({
801
+ baseUrl: this.baseUrl,
802
+ apiKey: this.apiKey,
803
+ app: this.app
804
+ });
601
805
  }
602
- /**
603
- * Create a task via POST /v1 without waiting for a human response.
604
- */
605
- async createTask(task) {
806
+ async createTaskRequest(task) {
606
807
  const normalizedTask = normalizeSendToHumanInput(task, {
607
808
  webhook: this.webhook,
608
809
  app: this.app,
@@ -655,7 +856,7 @@ var RobotRock = class {
655
856
  contextVersion: this.contextVersion,
656
857
  agentVersion: this.agentVersion
657
858
  });
658
- const createdTaskTask = await this.createTask(task);
859
+ const createdTaskTask = await this.createTaskRequest(task);
659
860
  const hasHandlers = normalizedTask.actions.some(
660
861
  (action) => Array.isArray(action.handlers) && action.handlers.length > 0
661
862
  );
@@ -672,7 +873,7 @@ var RobotRock = class {
672
873
  const deadline = validUntilMs !== void 0 ? Math.min(pollingDeadline, validUntilMs) : pollingDeadline;
673
874
  const taskId = createdTaskTask.taskId;
674
875
  while (Date.now() < deadline) {
675
- const existing = await this.getTask(taskId);
876
+ const existing = await this.getTaskById(taskId);
676
877
  if (existing?.status === "handled" && existing.handled) {
677
878
  return {
678
879
  mode: "handled",
@@ -694,10 +895,35 @@ var RobotRock = class {
694
895
  }
695
896
  throw new TaskTimeoutError(`No human response within ${timeoutMs}ms`);
696
897
  }
898
+ /**
899
+ * Create a task via POST /v1 without waiting for a human response.
900
+ * @deprecated Use `client.tasks.create()` instead.
901
+ */
902
+ async createTask(task) {
903
+ return this.tasks.create(task);
904
+ }
697
905
  /**
698
906
  * Get a task by public task id (returned as `task.taskId` from {@link sendToHuman}).
907
+ * @deprecated Use `client.tasks.get()` instead.
699
908
  */
700
909
  async getTask(taskId) {
910
+ return this.tasks.get(taskId);
911
+ }
912
+ /**
913
+ * Log a status update against a thread.
914
+ * @deprecated Use `client.tasks.sendUpdate()` instead.
915
+ */
916
+ async sendUpdate(input) {
917
+ return this.tasks.sendUpdate(input);
918
+ }
919
+ /**
920
+ * Cancel a task by public task id.
921
+ * @deprecated Use `client.tasks.cancel()` instead.
922
+ */
923
+ async cancelTask(taskId) {
924
+ return this.tasks.cancel(taskId);
925
+ }
926
+ async getTaskById(taskId) {
701
927
  const response = await fetch(`${this.baseUrl}/tasks/${taskId}`, {
702
928
  method: "GET",
703
929
  headers: {
@@ -717,11 +943,11 @@ var RobotRock = class {
717
943
  }
718
944
  return data;
719
945
  }
720
- /**
721
- * Log a status update against a thread. The update shows in the inbox status
722
- * bar and thread update log for every task in the thread.
723
- */
724
- async sendUpdate({ threadId, message, status }) {
946
+ async sendThreadUpdate({
947
+ threadId,
948
+ message,
949
+ status
950
+ }) {
725
951
  if (!threadId) {
726
952
  throw new RobotRockError("threadId is required to send an update", 400);
727
953
  }
@@ -754,7 +980,7 @@ var RobotRock = class {
754
980
  }
755
981
  return data.update;
756
982
  }
757
- async cancelTask(taskId) {
983
+ async cancelTaskRequest(taskId) {
758
984
  const response = await fetch(`${this.baseUrl}/tasks/${taskId}/cancel`, {
759
985
  method: "POST",
760
986
  headers: {
@@ -813,38 +1039,6 @@ function normalizeSendToHumanInput(task, clientDefaults) {
813
1039
  actions: normalizedActions
814
1040
  };
815
1041
  }
816
- async function parseResponseBody(response) {
817
- const contentType = response.headers.get("content-type") ?? "";
818
- const bodyText = await response.text();
819
- if (!bodyText) {
820
- return null;
821
- }
822
- if (contentType.toLowerCase().includes("application/json")) {
823
- try {
824
- return JSON.parse(bodyText);
825
- } catch {
826
- }
827
- }
828
- try {
829
- return JSON.parse(bodyText);
830
- } catch {
831
- return bodyText;
832
- }
833
- }
834
- function getErrorMessage(data, fallback) {
835
- if (data && typeof data === "object" && !Array.isArray(data)) {
836
- const maybeMessage = data.message;
837
- if (typeof maybeMessage === "string" && maybeMessage.trim()) {
838
- return maybeMessage;
839
- }
840
- }
841
- if (typeof data === "string" && data.trim()) {
842
- const compact = data.replace(/\s+/g, " ").trim();
843
- const snippet = compact.length > 180 ? `${compact.slice(0, 180)}...` : compact;
844
- return `${fallback}. Server returned non-JSON response: ${snippet}`;
845
- }
846
- return fallback;
847
- }
848
1042
 
849
1043
  // src/env.ts
850
1044
  var DEFAULT_BASE_URL = "https://api.robotrock.io/v1";
@@ -1228,7 +1422,7 @@ async function sendRobotRockUpdate(payload) {
1228
1422
  ...baseConfig.version ? { version: baseConfig.version } : {},
1229
1423
  ...baseConfig.advanced ? { advanced: baseConfig.advanced } : {}
1230
1424
  });
1231
- return client.sendUpdate(update);
1425
+ return client.tasks.sendUpdate(update);
1232
1426
  }
1233
1427
  async function sendUpdateInWorkflow(payload) {
1234
1428
  return sendRobotRockUpdate(payload);