robotrock 1.0.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-admin.d.ts +82 -0
- package/dist/agent-admin.js +938 -0
- package/dist/agent-admin.js.map +1 -0
- package/dist/ai/index.d.ts +6 -5
- package/dist/ai/index.js +682 -225
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/trigger.d.ts +4 -3
- package/dist/ai/trigger.js +682 -225
- package/dist/ai/trigger.js.map +1 -1
- package/dist/ai/workflow.d.ts +4 -3
- package/dist/ai/workflow.js +679 -222
- package/dist/ai/workflow.js.map +1 -1
- package/dist/auth-headers-qL-ZeEtd.d.ts +13 -0
- package/dist/{client-CzVmjXpz.d.ts → client-YO9Y1rkH.d.ts} +51 -10
- package/dist/eve/agent/index.d.ts +164 -0
- package/dist/eve/agent/index.js +2854 -0
- package/dist/eve/agent/index.js.map +1 -0
- package/dist/eve/index.d.ts +8 -0
- package/dist/eve/index.js +639 -0
- package/dist/eve/index.js.map +1 -0
- package/dist/eve/tools/admin/assign-tasks.d.ts +39 -0
- package/dist/eve/tools/admin/assign-tasks.js +1060 -0
- package/dist/eve/tools/admin/assign-tasks.js.map +1 -0
- package/dist/eve/tools/admin/manage-groups.d.ts +53 -0
- package/dist/eve/tools/admin/manage-groups.js +1218 -0
- package/dist/eve/tools/admin/manage-groups.js.map +1 -0
- package/dist/eve/tools/admin/manage-team-members.d.ts +45 -0
- package/dist/eve/tools/admin/manage-team-members.js +1160 -0
- package/dist/eve/tools/admin/manage-team-members.js.map +1 -0
- package/dist/eve/tools/admin/query-tasks.d.ts +71 -0
- package/dist/eve/tools/admin/query-tasks.js +1161 -0
- package/dist/eve/tools/admin/query-tasks.js.map +1 -0
- package/dist/eve/tools/catalog/search-products.d.ts +57 -0
- package/dist/eve/tools/catalog/search-products.js +94 -0
- package/dist/eve/tools/catalog/search-products.js.map +1 -0
- package/dist/eve/tools/identity/index.d.ts +8 -0
- package/dist/eve/tools/identity/index.js +234 -0
- package/dist/eve/tools/identity/index.js.map +1 -0
- package/dist/eve/tools/identity/my-access.d.ts +18 -0
- package/dist/eve/tools/identity/my-access.js +187 -0
- package/dist/eve/tools/identity/my-access.js.map +1 -0
- package/dist/eve/tools/identity/whoami.d.ts +44 -0
- package/dist/eve/tools/identity/whoami.js +117 -0
- package/dist/eve/tools/identity/whoami.js.map +1 -0
- package/dist/eve/tools/inbox/create-task.d.ts +114 -0
- package/dist/eve/tools/inbox/create-task.js +1785 -0
- package/dist/eve/tools/inbox/create-task.js.map +1 -0
- package/dist/eve/tools/inbox/index.d.ts +6 -0
- package/dist/eve/tools/inbox/index.js +1785 -0
- package/dist/eve/tools/inbox/index.js.map +1 -0
- package/dist/eve/tools/index.d.ts +24 -0
- package/dist/eve/tools/index.js +2848 -0
- package/dist/eve/tools/index.js.map +1 -0
- package/dist/index-DoQN48Bm.d.ts +200 -0
- package/dist/index.d.ts +8 -44
- package/dist/index.js +842 -137
- package/dist/index.js.map +1 -1
- package/dist/schemas/index.d.ts +6 -1
- package/dist/schemas/index.js +251 -59
- package/dist/schemas/index.js.map +1 -1
- package/dist/tenant-5YKDrdC-.d.ts +23 -0
- package/dist/{tool-approval-bridge-DbwUEBHv.d.ts → tool-approval-bridge-aMA79Z1B.d.ts} +1 -1
- package/dist/tool-reply-guidance-C3qrT1In.d.ts +25 -0
- package/dist/trigger/index.d.ts +2 -1
- package/dist/trigger/index.js +543 -127
- package/dist/trigger/index.js.map +1 -1
- package/dist/{trigger-BCKBbAV7.d.ts → trigger-CXrbKVCL.d.ts} +2 -2
- package/dist/workflow/index.d.ts +2 -1
- package/dist/workflow/index.js +543 -127
- package/dist/workflow/index.js.map +1 -1
- package/package.json +69 -8
package/dist/workflow/index.js
CHANGED
|
@@ -48,7 +48,7 @@ var __callDispose = (stack, error, hasError) => {
|
|
|
48
48
|
import { createWebhook, sleep as sleep2 } from "workflow";
|
|
49
49
|
|
|
50
50
|
// src/schemas/index.ts
|
|
51
|
-
import { z as
|
|
51
|
+
import { z as z4 } from "zod";
|
|
52
52
|
|
|
53
53
|
// ../core/src/utils/safe-url.ts
|
|
54
54
|
var BLOCKED_HOSTNAMES = /* @__PURE__ */ new Set([
|
|
@@ -157,6 +157,25 @@ function isBlockedHostname(hostname) {
|
|
|
157
157
|
}
|
|
158
158
|
return isBlockedIpv4(host) || isBlockedIpv6(host);
|
|
159
159
|
}
|
|
160
|
+
function isLoopbackHandlerUrl(urlString) {
|
|
161
|
+
let url;
|
|
162
|
+
try {
|
|
163
|
+
url = new URL(urlString);
|
|
164
|
+
} catch {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
if (url.username || url.password) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
const host = url.hostname.toLowerCase();
|
|
174
|
+
return host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "[::1]" || host.endsWith(".localhost");
|
|
175
|
+
}
|
|
176
|
+
function isAllowedHandlerUrl(urlString) {
|
|
177
|
+
return isPublicHttpUrl(urlString) || isLoopbackHandlerUrl(urlString);
|
|
178
|
+
}
|
|
160
179
|
function isPublicHttpUrl(urlString) {
|
|
161
180
|
let url;
|
|
162
181
|
try {
|
|
@@ -173,6 +192,7 @@ function isPublicHttpUrl(urlString) {
|
|
|
173
192
|
return !isBlockedHostname(url.hostname);
|
|
174
193
|
}
|
|
175
194
|
var PUBLIC_HTTP_URL_ERROR = "URL must be a public http:// or https:// address";
|
|
195
|
+
var HANDLER_URL_ERROR = "Handler URL must be a public or loopback http:// or https:// address";
|
|
176
196
|
|
|
177
197
|
// ../core/src/schemas/task.ts
|
|
178
198
|
import { z } from "zod";
|
|
@@ -234,6 +254,9 @@ function validateContextPublicUrls(context2) {
|
|
|
234
254
|
var safeUrlSchema = z.string().refine((url) => isPublicHttpUrl(url), {
|
|
235
255
|
message: PUBLIC_HTTP_URL_ERROR
|
|
236
256
|
});
|
|
257
|
+
var handlerUrlSchema = z.string().refine((url) => isAllowedHandlerUrl(url), {
|
|
258
|
+
message: HANDLER_URL_ERROR
|
|
259
|
+
});
|
|
237
260
|
var jsonSchema7Schema = z.custom(
|
|
238
261
|
(val) => typeof val === "object" && val !== null,
|
|
239
262
|
{ message: "Must be a valid JSON Schema object" }
|
|
@@ -243,7 +266,7 @@ var uiSchemaSchema = z.custom((val) => typeof val === "object" && val !== null,
|
|
|
243
266
|
});
|
|
244
267
|
var webhookHandlerSchema = z.object({
|
|
245
268
|
type: z.literal("webhook"),
|
|
246
|
-
url:
|
|
269
|
+
url: handlerUrlSchema,
|
|
247
270
|
headers: z.record(z.string(), z.string())
|
|
248
271
|
});
|
|
249
272
|
var triggerHandlerSchema = webhookHandlerSchema.extend({
|
|
@@ -394,86 +417,253 @@ var agentChatSeedMessageSchema = z.object({
|
|
|
394
417
|
action: agentChatSeedActionSchema
|
|
395
418
|
}).optional()
|
|
396
419
|
});
|
|
420
|
+
var eveAgentChatTransportSchema = z.object({
|
|
421
|
+
kind: z.literal("eve"),
|
|
422
|
+
chatId: z.string().min(1),
|
|
423
|
+
baseUrl: z.string().url(),
|
|
424
|
+
sessionId: z.string().optional(),
|
|
425
|
+
continuationToken: z.string().optional(),
|
|
426
|
+
streamIndex: z.number().int().nonnegative().optional(),
|
|
427
|
+
isStreaming: z.boolean().optional()
|
|
428
|
+
});
|
|
397
429
|
var createAgentChatBodySchema = z.object({
|
|
398
|
-
/**
|
|
430
|
+
/** Agent id (eve agent name). Required unless `parentChatId` is set. */
|
|
399
431
|
agentIdentifier: z.string().min(1).optional(),
|
|
400
432
|
/** Inherit tenant/connection/agent from an existing chat (agent-spawned chats). */
|
|
401
433
|
parentChatId: z.string().min(1).optional(),
|
|
402
|
-
/** Convex
|
|
403
|
-
|
|
434
|
+
/** Convex tenantEveConnections id; resolved from the tenant when omitted. */
|
|
435
|
+
eveConnectionId: z.string().min(1).optional(),
|
|
404
436
|
/** Source application id; groups the chat under an inbox section. */
|
|
405
437
|
app: z.string().min(1).optional(),
|
|
406
|
-
|
|
438
|
+
/** Email of the user who owns the chat. Required unless `parentChatId` is set. */
|
|
439
|
+
ownerEmail: z.string().email().optional(),
|
|
407
440
|
title: z.string().min(1),
|
|
408
441
|
messages: z.array(agentChatSeedMessageSchema).default([]),
|
|
409
442
|
/** Provenance label stored on the session ("cron" | "agent" | ...). */
|
|
410
443
|
source: z.string().min(1).optional()
|
|
411
444
|
}).refine((data) => Boolean(data.agentIdentifier || data.parentChatId), {
|
|
412
445
|
message: "Provide either agentIdentifier or parentChatId"
|
|
446
|
+
}).refine((data) => Boolean(data.ownerEmail || data.parentChatId), {
|
|
447
|
+
message: "Provide ownerEmail unless parentChatId is set"
|
|
413
448
|
});
|
|
414
|
-
var
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
449
|
+
var agentChatAuditToolBodySchema = z.object({
|
|
450
|
+
eveSessionId: z.string().min(1),
|
|
451
|
+
userId: z.string().min(1),
|
|
452
|
+
toolCallId: z.string().min(1),
|
|
453
|
+
toolName: z.string().min(1),
|
|
454
|
+
input: z.record(z.string(), z.unknown()).default({}),
|
|
455
|
+
success: z.boolean(),
|
|
456
|
+
status: z.enum(["completed", "failed", "rejected"]),
|
|
457
|
+
error: z.string().optional(),
|
|
458
|
+
idempotencyKey: z.string().optional()
|
|
459
|
+
});
|
|
460
|
+
var agentChatAuditInputBodySchema = z.object({
|
|
461
|
+
eveSessionId: z.string().min(1),
|
|
462
|
+
userId: z.string().min(1),
|
|
463
|
+
actionId: z.string().min(1),
|
|
464
|
+
actionTitle: z.string().optional(),
|
|
465
|
+
prompt: z.string().optional(),
|
|
466
|
+
data: z.record(z.string(), z.unknown()).optional(),
|
|
467
|
+
idempotencyKey: z.string().optional(),
|
|
468
|
+
/** Eve input request id — used to merge staged HITL metadata. */
|
|
469
|
+
requestId: z.string().optional(),
|
|
470
|
+
/** Eve tool call id — fallback lookup for staged HITL metadata. */
|
|
471
|
+
toolCallId: z.string().optional()
|
|
472
|
+
});
|
|
473
|
+
var eveHitlStagedOptionSchema = z.object({
|
|
474
|
+
id: z.string(),
|
|
475
|
+
label: z.string()
|
|
476
|
+
});
|
|
477
|
+
var agentChatStageHitlBodySchema = z.object({
|
|
478
|
+
eveSessionId: z.string().min(1),
|
|
479
|
+
requests: z.array(
|
|
480
|
+
z.object({
|
|
481
|
+
requestId: z.string().min(1),
|
|
482
|
+
toolCallId: z.string().min(1),
|
|
483
|
+
toolName: z.string().min(1),
|
|
484
|
+
prompt: z.string().min(1),
|
|
485
|
+
display: z.enum(["confirmation", "select", "text"]).optional(),
|
|
486
|
+
allowFreeform: z.boolean().optional(),
|
|
487
|
+
options: z.array(eveHitlStagedOptionSchema).optional(),
|
|
488
|
+
toolInput: z.record(z.string(), z.unknown()).optional()
|
|
489
|
+
})
|
|
490
|
+
)
|
|
491
|
+
});
|
|
492
|
+
var agentChatLinkTaskBodySchema = z.object({
|
|
493
|
+
eveSessionId: z.string().min(1),
|
|
494
|
+
publicTaskId: z.string().min(1),
|
|
495
|
+
toolCallId: z.string().min(1)
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
// ../core/src/schemas/tool-result-display.ts
|
|
499
|
+
import { z as z2 } from "zod";
|
|
500
|
+
var toolDisplayMetadataSchema = z2.object({
|
|
501
|
+
widget: z2.string().optional(),
|
|
502
|
+
title: z2.string().optional(),
|
|
503
|
+
description: z2.string().optional()
|
|
504
|
+
});
|
|
505
|
+
var toolDisplayEnvelopeSchema = z2.object({
|
|
506
|
+
display: toolDisplayMetadataSchema.optional(),
|
|
507
|
+
data: z2.record(z2.string(), z2.unknown()),
|
|
508
|
+
ui: z2.record(
|
|
509
|
+
z2.string(),
|
|
510
|
+
z2.object({
|
|
511
|
+
"ui:widget": z2.string().optional(),
|
|
512
|
+
"ui:title": z2.string().optional(),
|
|
513
|
+
"ui:description": z2.string().optional(),
|
|
514
|
+
"ui:options": z2.record(z2.string(), z2.unknown()).optional()
|
|
515
|
+
}).passthrough()
|
|
516
|
+
).optional()
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
// ../core/src/schemas/agent-admin.ts
|
|
520
|
+
import { z as z3 } from "zod";
|
|
521
|
+
var tenantRoleSchema = z3.enum(["admin", "member"]);
|
|
522
|
+
var agentAdminUserSchema = z3.object({
|
|
523
|
+
id: z3.string(),
|
|
524
|
+
email: z3.string().email(),
|
|
525
|
+
name: z3.string()
|
|
526
|
+
});
|
|
527
|
+
var agentAdminMemberSchema = z3.object({
|
|
528
|
+
userId: z3.string(),
|
|
529
|
+
role: z3.string(),
|
|
530
|
+
membershipKind: z3.enum(["team", "assignee"]),
|
|
531
|
+
hasLoggedIn: z3.boolean(),
|
|
532
|
+
user: agentAdminUserSchema
|
|
533
|
+
});
|
|
534
|
+
var agentAdminGroupSchema = z3.object({
|
|
535
|
+
id: z3.string(),
|
|
536
|
+
name: z3.string(),
|
|
537
|
+
slug: z3.string(),
|
|
538
|
+
description: z3.string().nullable(),
|
|
539
|
+
memberCount: z3.number().optional()
|
|
540
|
+
});
|
|
541
|
+
var agentAdminGroupDetailSchema = agentAdminGroupSchema.extend({
|
|
542
|
+
members: z3.array(
|
|
543
|
+
z3.object({
|
|
544
|
+
userId: z3.string(),
|
|
545
|
+
user: agentAdminUserSchema
|
|
546
|
+
})
|
|
547
|
+
)
|
|
548
|
+
});
|
|
549
|
+
var agentAdminTaskSummarySchema = z3.object({
|
|
550
|
+
id: z3.string(),
|
|
551
|
+
convexId: z3.string(),
|
|
552
|
+
status: z3.string(),
|
|
553
|
+
type: z3.string().nullable(),
|
|
554
|
+
name: z3.string().nullable(),
|
|
555
|
+
description: z3.string().nullable(),
|
|
556
|
+
validUntil: z3.number(),
|
|
557
|
+
createdAt: z3.number(),
|
|
558
|
+
threadPriority: z3.string().nullable(),
|
|
559
|
+
handledByUserId: z3.string().nullable()
|
|
560
|
+
});
|
|
561
|
+
var inviteMemberBodySchema = z3.object({
|
|
562
|
+
email: z3.string().email(),
|
|
563
|
+
role: tenantRoleSchema.optional()
|
|
564
|
+
});
|
|
565
|
+
var updateMemberRoleBodySchema = z3.object({
|
|
566
|
+
role: tenantRoleSchema
|
|
567
|
+
});
|
|
568
|
+
var createGroupBodySchema = z3.object({
|
|
569
|
+
name: z3.string().min(1),
|
|
570
|
+
description: z3.string().optional()
|
|
571
|
+
});
|
|
572
|
+
var updateGroupBodySchema = z3.object({
|
|
573
|
+
name: z3.string().min(1).optional(),
|
|
574
|
+
description: z3.string().optional()
|
|
575
|
+
});
|
|
576
|
+
var addGroupMemberBodySchema = z3.object({
|
|
577
|
+
userId: z3.string().min(1).describe("Convex user id or member email.")
|
|
578
|
+
});
|
|
579
|
+
var listTasksQuerySchema = z3.object({
|
|
580
|
+
statusFilter: z3.enum(["all", "open", "handled", "expired"]).optional(),
|
|
581
|
+
typeFilter: z3.string().optional(),
|
|
582
|
+
appFilter: z3.string().optional(),
|
|
583
|
+
sortField: z3.enum(["type", "date", "status", "validUntil"]).optional(),
|
|
584
|
+
sortDirection: z3.enum(["asc", "desc"]).optional(),
|
|
585
|
+
limit: z3.coerce.number().int().positive().max(100).optional(),
|
|
586
|
+
cursor: z3.string().optional()
|
|
587
|
+
});
|
|
588
|
+
var searchTasksQuerySchema = z3.object({
|
|
589
|
+
q: z3.string().min(1),
|
|
590
|
+
limit: z3.coerce.number().int().positive().max(100).optional()
|
|
591
|
+
});
|
|
592
|
+
var assignTasksResultSchema = z3.object({
|
|
593
|
+
taskId: z3.string(),
|
|
594
|
+
success: z3.boolean(),
|
|
595
|
+
message: z3.string().optional(),
|
|
596
|
+
name: z3.string().nullable().optional(),
|
|
597
|
+
description: z3.string().nullable().optional(),
|
|
598
|
+
type: z3.string().nullable().optional()
|
|
599
|
+
});
|
|
600
|
+
var assignTasksResponseSchema = z3.object({
|
|
601
|
+
results: z3.array(assignTasksResultSchema)
|
|
602
|
+
});
|
|
603
|
+
var assignTasksBodySchema = z3.object({
|
|
604
|
+
taskIds: z3.array(z3.string().min(1)).min(1).max(100),
|
|
605
|
+
assignTo: assignToSchema.refine(
|
|
606
|
+
(value) => (value.users?.length ?? 0) > 0 || (value.groups?.length ?? 0) > 0,
|
|
607
|
+
{ message: "assignTo needs at least one user email or group slug." }
|
|
608
|
+
)
|
|
419
609
|
});
|
|
420
610
|
|
|
421
611
|
// src/schemas/index.ts
|
|
422
|
-
var
|
|
423
|
-
message:
|
|
612
|
+
var handlerUrlSchema2 = z4.string().refine((url) => isAllowedHandlerUrl(url), {
|
|
613
|
+
message: HANDLER_URL_ERROR
|
|
424
614
|
});
|
|
425
|
-
var jsonSchema7Schema2 =
|
|
615
|
+
var jsonSchema7Schema2 = z4.custom(
|
|
426
616
|
(val) => typeof val === "object" && val !== null,
|
|
427
617
|
{ message: "Must be a valid JSON Schema object" }
|
|
428
618
|
);
|
|
429
|
-
var uiSchemaSchema2 =
|
|
619
|
+
var uiSchemaSchema2 = z4.custom((val) => typeof val === "object" && val !== null, {
|
|
430
620
|
message: "Must be a valid UiSchema object"
|
|
431
621
|
});
|
|
432
|
-
var webhookHandlerSchema2 =
|
|
433
|
-
type:
|
|
434
|
-
url:
|
|
435
|
-
headers:
|
|
622
|
+
var webhookHandlerSchema2 = z4.object({
|
|
623
|
+
type: z4.literal("webhook"),
|
|
624
|
+
url: handlerUrlSchema2,
|
|
625
|
+
headers: z4.record(z4.string(), z4.string())
|
|
436
626
|
});
|
|
437
627
|
var triggerHandlerSchema2 = webhookHandlerSchema2.extend({
|
|
438
|
-
type:
|
|
439
|
-
tokenId:
|
|
628
|
+
type: z4.literal("trigger"),
|
|
629
|
+
tokenId: z4.string().min(1)
|
|
440
630
|
});
|
|
441
|
-
var handlerSchema2 =
|
|
442
|
-
var taskActionInputSchema2 =
|
|
443
|
-
id:
|
|
444
|
-
title:
|
|
445
|
-
description:
|
|
631
|
+
var handlerSchema2 = z4.discriminatedUnion("type", [webhookHandlerSchema2, triggerHandlerSchema2]);
|
|
632
|
+
var taskActionInputSchema2 = z4.object({
|
|
633
|
+
id: z4.string().min(1),
|
|
634
|
+
title: z4.string().min(1),
|
|
635
|
+
description: z4.string().optional(),
|
|
446
636
|
schema: jsonSchema7Schema2.optional(),
|
|
447
637
|
ui: uiSchemaSchema2.optional(),
|
|
448
|
-
data:
|
|
638
|
+
data: z4.record(z4.string(), z4.unknown()).optional()
|
|
449
639
|
});
|
|
450
640
|
var taskActionSchema2 = taskActionInputSchema2.extend({
|
|
451
|
-
handlers:
|
|
641
|
+
handlers: z4.array(handlerSchema2).min(1).optional()
|
|
452
642
|
});
|
|
453
|
-
var uiFieldSchemaSchema2 =
|
|
454
|
-
"ui:widget":
|
|
455
|
-
"ui:title":
|
|
456
|
-
"ui:description":
|
|
457
|
-
"ui:options":
|
|
458
|
-
items:
|
|
643
|
+
var uiFieldSchemaSchema2 = z4.object({
|
|
644
|
+
"ui:widget": z4.string().optional(),
|
|
645
|
+
"ui:title": z4.string().optional(),
|
|
646
|
+
"ui:description": z4.string().optional(),
|
|
647
|
+
"ui:options": z4.record(z4.string(), z4.unknown()).optional(),
|
|
648
|
+
items: z4.lazy(() => z4.record(z4.string(), uiFieldSchemaSchema2)).optional()
|
|
459
649
|
}).passthrough();
|
|
460
|
-
var contextUiSchema2 =
|
|
461
|
-
var contextDataSchema2 =
|
|
462
|
-
data:
|
|
650
|
+
var contextUiSchema2 = z4.record(z4.string(), uiFieldSchemaSchema2).optional();
|
|
651
|
+
var contextDataSchema2 = z4.object({
|
|
652
|
+
data: z4.record(z4.string(), z4.unknown()),
|
|
463
653
|
ui: contextUiSchema2
|
|
464
654
|
}).optional();
|
|
465
655
|
var TASK_CONTEXT_FORMAT_VERSION2 = 2;
|
|
466
|
-
var taskContextObjectBaseSchema2 =
|
|
467
|
-
app:
|
|
468
|
-
type:
|
|
469
|
-
name:
|
|
470
|
-
description:
|
|
471
|
-
validUntil:
|
|
656
|
+
var taskContextObjectBaseSchema2 = z4.object({
|
|
657
|
+
app: z4.string().min(1).optional(),
|
|
658
|
+
type: z4.string().min(1),
|
|
659
|
+
name: z4.string().min(1),
|
|
660
|
+
description: z4.string().optional(),
|
|
661
|
+
validUntil: z4.string().optional(),
|
|
472
662
|
context: contextDataSchema2,
|
|
473
|
-
contextVersion:
|
|
663
|
+
contextVersion: z4.literal(2).optional(),
|
|
474
664
|
/** @deprecated Use `contextVersion`. Accepted on ingest only. */
|
|
475
|
-
version:
|
|
476
|
-
actions:
|
|
665
|
+
version: z4.literal(2).optional(),
|
|
666
|
+
actions: z4.array(taskActionSchema2).min(1, "At least one action is required")
|
|
477
667
|
});
|
|
478
668
|
function normalizeTaskContextVersion2(data) {
|
|
479
669
|
const { version: legacyVersion, contextVersion, ...rest } = data;
|
|
@@ -489,7 +679,7 @@ function refineContextPublicUrls2(data, ctx) {
|
|
|
489
679
|
const error = validateContextPublicUrls(data.context);
|
|
490
680
|
if (error) {
|
|
491
681
|
ctx.addIssue({
|
|
492
|
-
code:
|
|
682
|
+
code: z4.ZodIssueCode.custom,
|
|
493
683
|
message: error,
|
|
494
684
|
path: ["context"]
|
|
495
685
|
});
|
|
@@ -498,9 +688,9 @@ function refineContextPublicUrls2(data, ctx) {
|
|
|
498
688
|
var taskContextSchema2 = taskContextObjectSchema2.superRefine(
|
|
499
689
|
refineContextPublicUrls2
|
|
500
690
|
);
|
|
501
|
-
var assignToSchema2 =
|
|
502
|
-
users:
|
|
503
|
-
groups:
|
|
691
|
+
var assignToSchema2 = z4.object({
|
|
692
|
+
users: z4.array(z4.string().email()).optional(),
|
|
693
|
+
groups: z4.array(z4.string().min(1)).optional()
|
|
504
694
|
}).refine(
|
|
505
695
|
(data) => {
|
|
506
696
|
const groups = data.groups ?? [];
|
|
@@ -511,7 +701,7 @@ var assignToSchema2 = z2.object({
|
|
|
511
701
|
},
|
|
512
702
|
{ message: 'Cannot combine "all" with other group slugs' }
|
|
513
703
|
);
|
|
514
|
-
var threadUpdateMessageSchema2 =
|
|
704
|
+
var threadUpdateMessageSchema2 = z4.string().min(1).max(500);
|
|
515
705
|
var threadUpdateStatuses2 = [
|
|
516
706
|
"info",
|
|
517
707
|
"queued",
|
|
@@ -521,15 +711,15 @@ var threadUpdateStatuses2 = [
|
|
|
521
711
|
"failed",
|
|
522
712
|
"cancelled"
|
|
523
713
|
];
|
|
524
|
-
var threadUpdateStatusSchema2 =
|
|
525
|
-
var threadUpdateInputSchema2 =
|
|
714
|
+
var threadUpdateStatusSchema2 = z4.enum(threadUpdateStatuses2);
|
|
715
|
+
var threadUpdateInputSchema2 = z4.object({
|
|
526
716
|
message: threadUpdateMessageSchema2,
|
|
527
717
|
status: threadUpdateStatusSchema2.optional()
|
|
528
718
|
});
|
|
529
719
|
var taskPriorities2 = ["low", "normal", "high", "urgent"];
|
|
530
|
-
var taskPrioritySchema2 =
|
|
531
|
-
var agentTelemetrySchema2 =
|
|
532
|
-
version:
|
|
720
|
+
var taskPrioritySchema2 = z4.enum(taskPriorities2);
|
|
721
|
+
var agentTelemetrySchema2 = z4.object({
|
|
722
|
+
version: z4.string().min(1)
|
|
533
723
|
});
|
|
534
724
|
var createTaskBodySchema2 = taskContextObjectBaseSchema2.extend({
|
|
535
725
|
assignTo: assignToSchema2.optional(),
|
|
@@ -537,7 +727,7 @@ var createTaskBodySchema2 = taskContextObjectBaseSchema2.extend({
|
|
|
537
727
|
* Groups related tasks together. When omitted, the server generates one and
|
|
538
728
|
* returns it so the caller can reuse it on later tasks in the same thread.
|
|
539
729
|
*/
|
|
540
|
-
threadId:
|
|
730
|
+
threadId: z4.string().min(1).optional(),
|
|
541
731
|
/**
|
|
542
732
|
* Optional thread priority. When set, applies to the whole thread and
|
|
543
733
|
* overwrites any previous priority. Omit on later tasks to leave unchanged.
|
|
@@ -552,6 +742,65 @@ var createTaskBodySchema2 = taskContextObjectBaseSchema2.extend({
|
|
|
552
742
|
}).transform(normalizeTaskContextVersion2).superRefine(refineContextPublicUrls2);
|
|
553
743
|
var threadUpdateBodySchema = threadUpdateInputSchema2;
|
|
554
744
|
|
|
745
|
+
// ../core/src/handler-retry.ts
|
|
746
|
+
var HANDLER_RETRY_DELAYS_MS = [
|
|
747
|
+
6e4,
|
|
748
|
+
// 1m
|
|
749
|
+
3e5,
|
|
750
|
+
// 5m
|
|
751
|
+
18e5,
|
|
752
|
+
// 30m
|
|
753
|
+
36e5,
|
|
754
|
+
// 1h
|
|
755
|
+
216e5,
|
|
756
|
+
// 6h
|
|
757
|
+
864e5,
|
|
758
|
+
// 24h
|
|
759
|
+
1728e5
|
|
760
|
+
// 48h
|
|
761
|
+
];
|
|
762
|
+
var HANDLER_MAX_ATTEMPTS = HANDLER_RETRY_DELAYS_MS.length + 1;
|
|
763
|
+
|
|
764
|
+
// ../core/src/attribution/index.ts
|
|
765
|
+
import { z as z5 } from "zod";
|
|
766
|
+
|
|
767
|
+
// ../core/src/app-url.ts
|
|
768
|
+
var PRODUCTION_APP_URL = "https://app.robotrock.io";
|
|
769
|
+
var PRODUCTION_API_URL = "https://api.robotrock.io/v1";
|
|
770
|
+
var DEV_API_URL = "http://localhost:4001/v1";
|
|
771
|
+
var APP_SIGNUP_URL = `${PRODUCTION_APP_URL}/sign-up`;
|
|
772
|
+
function normalizeRobotRockApiBaseUrl(baseUrl) {
|
|
773
|
+
const trimmed = baseUrl.trim().replace(/\/+$/, "");
|
|
774
|
+
if (trimmed.endsWith("/v1")) {
|
|
775
|
+
return trimmed;
|
|
776
|
+
}
|
|
777
|
+
return `${trimmed}/v1`;
|
|
778
|
+
}
|
|
779
|
+
function getRobotRockApiBaseUrl() {
|
|
780
|
+
const explicit = process.env.ROBOTROCK_BASE_URL?.trim() || process.env.ROBOTROCK_API_URL?.trim();
|
|
781
|
+
if (explicit) {
|
|
782
|
+
return normalizeRobotRockApiBaseUrl(explicit);
|
|
783
|
+
}
|
|
784
|
+
if (process.env.NODE_ENV === "production") {
|
|
785
|
+
return PRODUCTION_API_URL;
|
|
786
|
+
}
|
|
787
|
+
return DEV_API_URL;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
// ../core/src/attribution/index.ts
|
|
791
|
+
var ATTRIBUTION_COOKIE_MAX_AGE = 60 * 60 * 24 * 90;
|
|
792
|
+
var attributionSchema = z5.object({
|
|
793
|
+
utmSource: z5.string().optional(),
|
|
794
|
+
utmMedium: z5.string().optional(),
|
|
795
|
+
utmCampaign: z5.string().optional(),
|
|
796
|
+
utmContent: z5.string().optional(),
|
|
797
|
+
utmTerm: z5.string().optional(),
|
|
798
|
+
gclid: z5.string().optional(),
|
|
799
|
+
landingUrl: z5.string().optional(),
|
|
800
|
+
referrer: z5.string().optional(),
|
|
801
|
+
capturedAt: z5.number()
|
|
802
|
+
});
|
|
803
|
+
|
|
555
804
|
// src/approval-result.ts
|
|
556
805
|
var TaskTimeoutError = class extends Error {
|
|
557
806
|
constructor(message) {
|
|
@@ -608,8 +857,13 @@ async function parseResponseBody(response) {
|
|
|
608
857
|
}
|
|
609
858
|
function getErrorMessage(data, fallback) {
|
|
610
859
|
if (data && typeof data === "object" && !Array.isArray(data)) {
|
|
611
|
-
const
|
|
860
|
+
const record = data;
|
|
861
|
+
const maybeMessage = record.message;
|
|
862
|
+
const maybeHint = record.hint;
|
|
612
863
|
if (typeof maybeMessage === "string" && maybeMessage.trim()) {
|
|
864
|
+
if (typeof maybeHint === "string" && maybeHint.trim()) {
|
|
865
|
+
return `${maybeMessage.trim()} ${maybeHint.trim()}`;
|
|
866
|
+
}
|
|
613
867
|
return maybeMessage;
|
|
614
868
|
}
|
|
615
869
|
}
|
|
@@ -621,51 +875,49 @@ function getErrorMessage(data, fallback) {
|
|
|
621
875
|
return fallback;
|
|
622
876
|
}
|
|
623
877
|
|
|
624
|
-
//
|
|
625
|
-
var
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
capturedAt: z3.number()
|
|
662
|
-
});
|
|
878
|
+
// src/auth-headers.ts
|
|
879
|
+
var ROBOTROCK_ACTING_USER_ID_HEADER = "x-robotrock-acting-user-id";
|
|
880
|
+
function buildRobotRockAuthHeaders(auth) {
|
|
881
|
+
if (auth.kind === "apiKey") {
|
|
882
|
+
const headers2 = {
|
|
883
|
+
"X-Api-Key": auth.apiKey
|
|
884
|
+
};
|
|
885
|
+
if (auth.actingUserId?.trim()) {
|
|
886
|
+
headers2[ROBOTROCK_ACTING_USER_ID_HEADER] = auth.actingUserId.trim();
|
|
887
|
+
}
|
|
888
|
+
return headers2;
|
|
889
|
+
}
|
|
890
|
+
const headers = {
|
|
891
|
+
Authorization: `Bearer ${auth.token}`,
|
|
892
|
+
"X-RobotRock-Tenant-Slug": auth.tenantSlug,
|
|
893
|
+
"X-RobotRock-Connection-Id": auth.connectionId
|
|
894
|
+
};
|
|
895
|
+
if (auth.actingUserId?.trim()) {
|
|
896
|
+
headers[ROBOTROCK_ACTING_USER_ID_HEADER] = auth.actingUserId.trim();
|
|
897
|
+
}
|
|
898
|
+
return headers;
|
|
899
|
+
}
|
|
900
|
+
function resolveRobotRockAuthConfig(overrides) {
|
|
901
|
+
if (overrides?.agentService) {
|
|
902
|
+
return {
|
|
903
|
+
kind: "agentService",
|
|
904
|
+
...overrides.agentService
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
const apiKey = overrides?.apiKey ?? process.env.ROBOTROCK_API_KEY;
|
|
908
|
+
if (!apiKey) {
|
|
909
|
+
throw new Error(
|
|
910
|
+
"RobotRock auth is required. Set ROBOTROCK_API_KEY, ROBOTROCK_AGENT_SERVICE_TOKEN with tenant context, or pass auth when creating the client."
|
|
911
|
+
);
|
|
912
|
+
}
|
|
913
|
+
return { kind: "apiKey", apiKey };
|
|
914
|
+
}
|
|
663
915
|
|
|
664
916
|
// src/chats.ts
|
|
665
917
|
function createChatsApi(config) {
|
|
666
918
|
const headers = () => ({
|
|
667
919
|
"Content-Type": "application/json",
|
|
668
|
-
|
|
920
|
+
...buildRobotRockAuthHeaders(config.auth)
|
|
669
921
|
});
|
|
670
922
|
return {
|
|
671
923
|
async create(input) {
|
|
@@ -718,6 +970,120 @@ function createChatsApi(config) {
|
|
|
718
970
|
data
|
|
719
971
|
);
|
|
720
972
|
}
|
|
973
|
+
},
|
|
974
|
+
async stageHitlRequests(input) {
|
|
975
|
+
const validation = agentChatStageHitlBodySchema.safeParse(input);
|
|
976
|
+
if (!validation.success) {
|
|
977
|
+
throw new RobotRockError(
|
|
978
|
+
`Invalid stage HITL input: ${validation.error.issues[0]?.message}`,
|
|
979
|
+
400,
|
|
980
|
+
validation.error.issues
|
|
981
|
+
);
|
|
982
|
+
}
|
|
983
|
+
const response = await fetch(`${config.baseUrl}/agent-chats/stage-hitl`, {
|
|
984
|
+
method: "POST",
|
|
985
|
+
headers: headers(),
|
|
986
|
+
body: JSON.stringify(validation.data)
|
|
987
|
+
});
|
|
988
|
+
if (!response.ok) {
|
|
989
|
+
const data = await parseResponseBody(response);
|
|
990
|
+
throw new RobotRockError(
|
|
991
|
+
getErrorMessage(data, "Failed to stage chat HITL requests"),
|
|
992
|
+
response.status,
|
|
993
|
+
data
|
|
994
|
+
);
|
|
995
|
+
}
|
|
996
|
+
},
|
|
997
|
+
async getStagedHitlRequests(eveSessionId) {
|
|
998
|
+
const trimmed = eveSessionId.trim();
|
|
999
|
+
if (!trimmed) {
|
|
1000
|
+
throw new RobotRockError("eveSessionId is required", 400);
|
|
1001
|
+
}
|
|
1002
|
+
const url = new URL(`${config.baseUrl}/agent-chats/staged-hitl`);
|
|
1003
|
+
url.searchParams.set("eveSessionId", trimmed);
|
|
1004
|
+
const response = await fetch(url.toString(), {
|
|
1005
|
+
method: "GET",
|
|
1006
|
+
headers: headers()
|
|
1007
|
+
});
|
|
1008
|
+
const data = await parseResponseBody(response);
|
|
1009
|
+
if (!response.ok) {
|
|
1010
|
+
throw new RobotRockError(
|
|
1011
|
+
getErrorMessage(data, "Failed to fetch staged chat HITL requests"),
|
|
1012
|
+
response.status,
|
|
1013
|
+
data
|
|
1014
|
+
);
|
|
1015
|
+
}
|
|
1016
|
+
const requests = data.requests;
|
|
1017
|
+
return Array.isArray(requests) ? requests : [];
|
|
1018
|
+
},
|
|
1019
|
+
async logInputSubmission(input) {
|
|
1020
|
+
const validation = agentChatAuditInputBodySchema.safeParse(input);
|
|
1021
|
+
if (!validation.success) {
|
|
1022
|
+
throw new RobotRockError(
|
|
1023
|
+
`Invalid audit input: ${validation.error.issues[0]?.message}`,
|
|
1024
|
+
400,
|
|
1025
|
+
validation.error.issues
|
|
1026
|
+
);
|
|
1027
|
+
}
|
|
1028
|
+
const response = await fetch(`${config.baseUrl}/agent-chats/audit-input`, {
|
|
1029
|
+
method: "POST",
|
|
1030
|
+
headers: headers(),
|
|
1031
|
+
body: JSON.stringify(validation.data)
|
|
1032
|
+
});
|
|
1033
|
+
if (!response.ok) {
|
|
1034
|
+
const data = await parseResponseBody(response);
|
|
1035
|
+
throw new RobotRockError(
|
|
1036
|
+
getErrorMessage(data, "Failed to log chat input submission"),
|
|
1037
|
+
response.status,
|
|
1038
|
+
data
|
|
1039
|
+
);
|
|
1040
|
+
}
|
|
1041
|
+
},
|
|
1042
|
+
async logToolExecution(input) {
|
|
1043
|
+
const validation = agentChatAuditToolBodySchema.safeParse(input);
|
|
1044
|
+
if (!validation.success) {
|
|
1045
|
+
throw new RobotRockError(
|
|
1046
|
+
`Invalid audit tool input: ${validation.error.issues[0]?.message}`,
|
|
1047
|
+
400,
|
|
1048
|
+
validation.error.issues
|
|
1049
|
+
);
|
|
1050
|
+
}
|
|
1051
|
+
const response = await fetch(`${config.baseUrl}/agent-chats/audit-tool`, {
|
|
1052
|
+
method: "POST",
|
|
1053
|
+
headers: headers(),
|
|
1054
|
+
body: JSON.stringify(validation.data)
|
|
1055
|
+
});
|
|
1056
|
+
if (!response.ok) {
|
|
1057
|
+
const data = await parseResponseBody(response);
|
|
1058
|
+
throw new RobotRockError(
|
|
1059
|
+
getErrorMessage(data, "Failed to log chat tool execution"),
|
|
1060
|
+
response.status,
|
|
1061
|
+
data
|
|
1062
|
+
);
|
|
1063
|
+
}
|
|
1064
|
+
},
|
|
1065
|
+
async linkTask(input) {
|
|
1066
|
+
const validation = agentChatLinkTaskBodySchema.safeParse(input);
|
|
1067
|
+
if (!validation.success) {
|
|
1068
|
+
throw new RobotRockError(
|
|
1069
|
+
`Invalid link task input: ${validation.error.issues[0]?.message}`,
|
|
1070
|
+
400,
|
|
1071
|
+
validation.error.issues
|
|
1072
|
+
);
|
|
1073
|
+
}
|
|
1074
|
+
const response = await fetch(`${config.baseUrl}/agent-chats/link-task`, {
|
|
1075
|
+
method: "POST",
|
|
1076
|
+
headers: headers(),
|
|
1077
|
+
body: JSON.stringify(validation.data)
|
|
1078
|
+
});
|
|
1079
|
+
if (!response.ok) {
|
|
1080
|
+
const data = await parseResponseBody(response);
|
|
1081
|
+
throw new RobotRockError(
|
|
1082
|
+
getErrorMessage(data, "Failed to link inbox task to chat"),
|
|
1083
|
+
response.status,
|
|
1084
|
+
data
|
|
1085
|
+
);
|
|
1086
|
+
}
|
|
721
1087
|
}
|
|
722
1088
|
};
|
|
723
1089
|
}
|
|
@@ -760,7 +1126,7 @@ function serializeValidUntil(value) {
|
|
|
760
1126
|
throw new RobotRockError("Invalid validUntil: expected a Date or parseable date string", 400);
|
|
761
1127
|
}
|
|
762
1128
|
var RobotRock = class {
|
|
763
|
-
|
|
1129
|
+
auth;
|
|
764
1130
|
baseUrl;
|
|
765
1131
|
app;
|
|
766
1132
|
agentVersion;
|
|
@@ -778,14 +1144,17 @@ var RobotRock = class {
|
|
|
778
1144
|
);
|
|
779
1145
|
}
|
|
780
1146
|
const apiKey = config.apiKey ?? process.env.ROBOTROCK_API_KEY;
|
|
781
|
-
|
|
1147
|
+
const agentService = config.agentService;
|
|
1148
|
+
if (apiKey && agentService) {
|
|
782
1149
|
throw new Error(
|
|
783
|
-
"RobotRock
|
|
1150
|
+
"RobotRock client cannot configure both apiKey and agentService."
|
|
784
1151
|
);
|
|
785
1152
|
}
|
|
786
|
-
this.
|
|
787
|
-
|
|
788
|
-
|
|
1153
|
+
this.auth = resolveRobotRockAuthConfig({
|
|
1154
|
+
...apiKey ? { apiKey } : {},
|
|
1155
|
+
...agentService ? { agentService } : {}
|
|
1156
|
+
});
|
|
1157
|
+
this.baseUrl = config.baseUrl ?? getRobotRockApiBaseUrl();
|
|
789
1158
|
this.app = config.app;
|
|
790
1159
|
this.agentVersion = config.version ?? resolveAgentVersionFromEnv();
|
|
791
1160
|
this.contextVersion = config.advanced?.contextVersion ?? TASK_CONTEXT_FORMAT_VERSION2;
|
|
@@ -795,14 +1164,23 @@ var RobotRock = class {
|
|
|
795
1164
|
create: (task) => this.createTaskRequest(task),
|
|
796
1165
|
get: (taskId) => this.getTaskById(taskId),
|
|
797
1166
|
cancel: (taskId) => this.cancelTaskRequest(taskId),
|
|
798
|
-
sendUpdate: (input) => this.sendThreadUpdate(input)
|
|
1167
|
+
sendUpdate: (input) => this.sendThreadUpdate(input),
|
|
1168
|
+
list: (input) => this.listTasksRequest(input),
|
|
1169
|
+
search: (input) => this.searchTasksRequest(input)
|
|
799
1170
|
};
|
|
800
1171
|
this.chats = createChatsApi({
|
|
801
1172
|
baseUrl: this.baseUrl,
|
|
802
|
-
|
|
1173
|
+
auth: this.auth,
|
|
803
1174
|
app: this.app
|
|
804
1175
|
});
|
|
805
1176
|
}
|
|
1177
|
+
authHeaders(extra) {
|
|
1178
|
+
return {
|
|
1179
|
+
"Content-Type": "application/json",
|
|
1180
|
+
...buildRobotRockAuthHeaders(this.auth),
|
|
1181
|
+
...extra
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
806
1184
|
async createTaskRequest(task) {
|
|
807
1185
|
const normalizedTask = normalizeSendToHumanInput(task, {
|
|
808
1186
|
webhook: this.webhook,
|
|
@@ -827,13 +1205,9 @@ var RobotRock = class {
|
|
|
827
1205
|
validation.error.issues
|
|
828
1206
|
);
|
|
829
1207
|
}
|
|
830
|
-
const headers =
|
|
831
|
-
"
|
|
832
|
-
|
|
833
|
-
};
|
|
834
|
-
if (task.idempotencyKey) {
|
|
835
|
-
headers["Idempotency-Key"] = task.idempotencyKey;
|
|
836
|
-
}
|
|
1208
|
+
const headers = this.authHeaders(
|
|
1209
|
+
task.idempotencyKey ? { "Idempotency-Key": task.idempotencyKey } : void 0
|
|
1210
|
+
);
|
|
837
1211
|
const response = await fetch(`${this.baseUrl}/`, {
|
|
838
1212
|
method: "POST",
|
|
839
1213
|
headers,
|
|
@@ -926,9 +1300,7 @@ var RobotRock = class {
|
|
|
926
1300
|
async getTaskById(taskId) {
|
|
927
1301
|
const response = await fetch(`${this.baseUrl}/tasks/${taskId}`, {
|
|
928
1302
|
method: "GET",
|
|
929
|
-
headers:
|
|
930
|
-
"X-Api-Key": this.apiKey
|
|
931
|
-
}
|
|
1303
|
+
headers: this.authHeaders()
|
|
932
1304
|
});
|
|
933
1305
|
if (response.status === 404) {
|
|
934
1306
|
return null;
|
|
@@ -963,10 +1335,7 @@ var RobotRock = class {
|
|
|
963
1335
|
`${this.baseUrl}/threads/${encodeURIComponent(threadId)}/updates`,
|
|
964
1336
|
{
|
|
965
1337
|
method: "POST",
|
|
966
|
-
headers:
|
|
967
|
-
"Content-Type": "application/json",
|
|
968
|
-
"X-Api-Key": this.apiKey
|
|
969
|
-
},
|
|
1338
|
+
headers: this.authHeaders(),
|
|
970
1339
|
body: JSON.stringify(validation.data)
|
|
971
1340
|
}
|
|
972
1341
|
);
|
|
@@ -983,9 +1352,7 @@ var RobotRock = class {
|
|
|
983
1352
|
async cancelTaskRequest(taskId) {
|
|
984
1353
|
const response = await fetch(`${this.baseUrl}/tasks/${taskId}/cancel`, {
|
|
985
1354
|
method: "POST",
|
|
986
|
-
headers:
|
|
987
|
-
"X-Api-Key": this.apiKey
|
|
988
|
-
}
|
|
1355
|
+
headers: this.authHeaders()
|
|
989
1356
|
});
|
|
990
1357
|
if (!response.ok) {
|
|
991
1358
|
const data = await parseResponseBody(response);
|
|
@@ -996,6 +1363,47 @@ var RobotRock = class {
|
|
|
996
1363
|
);
|
|
997
1364
|
}
|
|
998
1365
|
}
|
|
1366
|
+
async listTasksRequest(input) {
|
|
1367
|
+
const params = new URLSearchParams();
|
|
1368
|
+
for (const [key, value] of Object.entries(input ?? {})) {
|
|
1369
|
+
if (value !== void 0 && value !== "") {
|
|
1370
|
+
params.set(key, String(value));
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
const suffix = params.size > 0 ? `?${params.toString()}` : "";
|
|
1374
|
+
const response = await fetch(`${this.baseUrl}/tasks${suffix}`, {
|
|
1375
|
+
method: "GET",
|
|
1376
|
+
headers: this.authHeaders()
|
|
1377
|
+
});
|
|
1378
|
+
const data = await parseResponseBody(response);
|
|
1379
|
+
if (!response.ok) {
|
|
1380
|
+
throw new RobotRockError(
|
|
1381
|
+
getErrorMessage(data, "Failed to list tasks"),
|
|
1382
|
+
response.status,
|
|
1383
|
+
data
|
|
1384
|
+
);
|
|
1385
|
+
}
|
|
1386
|
+
return data;
|
|
1387
|
+
}
|
|
1388
|
+
async searchTasksRequest(input) {
|
|
1389
|
+
const params = new URLSearchParams({ q: input.q });
|
|
1390
|
+
if (input.limit !== void 0) {
|
|
1391
|
+
params.set("limit", String(input.limit));
|
|
1392
|
+
}
|
|
1393
|
+
const response = await fetch(`${this.baseUrl}/tasks/search?${params.toString()}`, {
|
|
1394
|
+
method: "GET",
|
|
1395
|
+
headers: this.authHeaders()
|
|
1396
|
+
});
|
|
1397
|
+
const data = await parseResponseBody(response);
|
|
1398
|
+
if (!response.ok) {
|
|
1399
|
+
throw new RobotRockError(
|
|
1400
|
+
getErrorMessage(data, "Failed to search tasks"),
|
|
1401
|
+
response.status,
|
|
1402
|
+
data
|
|
1403
|
+
);
|
|
1404
|
+
}
|
|
1405
|
+
return data;
|
|
1406
|
+
}
|
|
999
1407
|
};
|
|
1000
1408
|
function createClient(config) {
|
|
1001
1409
|
return new RobotRock(config);
|
|
@@ -1041,16 +1449,24 @@ function normalizeSendToHumanInput(task, clientDefaults) {
|
|
|
1041
1449
|
}
|
|
1042
1450
|
|
|
1043
1451
|
// src/env.ts
|
|
1044
|
-
var DEFAULT_BASE_URL = "https://api.robotrock.io/v1";
|
|
1045
1452
|
function resolveRobotRockConfig(overrides) {
|
|
1453
|
+
const agentService = overrides?.agentService;
|
|
1046
1454
|
const apiKey = overrides?.apiKey ?? process.env.ROBOTROCK_API_KEY;
|
|
1047
|
-
if (
|
|
1455
|
+
if (agentService && apiKey) {
|
|
1048
1456
|
throw new Error(
|
|
1049
|
-
"RobotRock
|
|
1457
|
+
"RobotRock client cannot configure both apiKey and agentService."
|
|
1050
1458
|
);
|
|
1051
1459
|
}
|
|
1052
|
-
const baseUrl = overrides?.baseUrl ??
|
|
1460
|
+
const baseUrl = overrides?.baseUrl ?? getRobotRockApiBaseUrl();
|
|
1053
1461
|
const app = overrides?.app ?? process.env.ROBOTROCK_APP;
|
|
1462
|
+
if (agentService) {
|
|
1463
|
+
return app ? { agentService, baseUrl, app } : { agentService, baseUrl };
|
|
1464
|
+
}
|
|
1465
|
+
if (!apiKey) {
|
|
1466
|
+
throw new Error(
|
|
1467
|
+
"RobotRock API key is required. Set ROBOTROCK_API_KEY or pass agentService when creating the client."
|
|
1468
|
+
);
|
|
1469
|
+
}
|
|
1054
1470
|
return app ? { apiKey, baseUrl, app } : { apiKey, baseUrl };
|
|
1055
1471
|
}
|
|
1056
1472
|
|