robotrock 1.0.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.
- package/dist/ai/index.d.ts +5 -5
- package/dist/ai/index.js +285 -47
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/trigger.d.ts +3 -3
- package/dist/ai/trigger.js +285 -47
- package/dist/ai/trigger.js.map +1 -1
- package/dist/ai/workflow.d.ts +3 -3
- package/dist/ai/workflow.js +285 -47
- package/dist/ai/workflow.js.map +1 -1
- package/dist/{client-CzVmjXpz.d.ts → client-XTnFHGFE.d.ts} +34 -5
- package/dist/eve/agent/index.d.ts +188 -0
- package/dist/eve/agent/index.js +2322 -0
- package/dist/eve/agent/index.js.map +1 -0
- package/dist/eve/index.d.ts +5 -0
- package/dist/eve/index.js +446 -0
- package/dist/eve/index.js.map +1 -0
- package/dist/eve/tools/identity/index.d.ts +6 -0
- package/dist/eve/tools/identity/index.js +144 -0
- package/dist/eve/tools/identity/index.js.map +1 -0
- package/dist/eve/tools/identity/my-access.d.ts +58 -0
- package/dist/eve/tools/identity/my-access.js +106 -0
- package/dist/eve/tools/identity/my-access.js.map +1 -0
- package/dist/eve/tools/identity/whoami.d.ts +45 -0
- package/dist/eve/tools/identity/whoami.js +101 -0
- package/dist/eve/tools/identity/whoami.js.map +1 -0
- package/dist/eve/tools/inbox/create-task.d.ts +113 -0
- package/dist/eve/tools/inbox/create-task.js +1557 -0
- package/dist/eve/tools/inbox/create-task.js.map +1 -0
- package/dist/eve/tools/inbox/index.d.ts +5 -0
- package/dist/eve/tools/inbox/index.js +1557 -0
- package/dist/eve/tools/inbox/index.js.map +1 -0
- package/dist/eve/tools/index.d.ts +17 -0
- package/dist/eve/tools/index.js +1654 -0
- package/dist/eve/tools/index.js.map +1 -0
- package/dist/index-BL9qKHA8.d.ts +141 -0
- package/dist/index.d.ts +5 -44
- package/dist/index.js +541 -42
- package/dist/index.js.map +1 -1
- package/dist/schemas/index.js +75 -12
- 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-C4bTm8vu.d.ts} +1 -1
- package/dist/trigger/index.d.ts +1 -1
- package/dist/trigger/index.js +256 -42
- package/dist/trigger/index.js.map +1 -1
- package/dist/{trigger-BCKBbAV7.d.ts → trigger-Dn0DFiyU.d.ts} +2 -2
- package/dist/workflow/index.d.ts +1 -1
- package/dist/workflow/index.js +256 -42
- package/dist/workflow/index.js.map +1 -1
- package/package.json +44 -7
|
@@ -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-
|
|
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-
|
|
3
|
+
import { R as RobotRock, S as SendToHumanActionInput } from './client-XTnFHGFE.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-C4bTm8vu.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* AI SDK tool with fixed approve/decline actions; blocks until a human decides.
|
package/dist/workflow/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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-
|
|
3
|
+
import { S as SendToHumanActionInput, a as SendToHumanInput } from '../client-XTnFHGFE.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';
|
package/dist/workflow/index.js
CHANGED
|
@@ -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,13 +417,22 @@ 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
|
assignTo: assignToSchema.optional(),
|
|
@@ -411,16 +443,47 @@ var createAgentChatBodySchema = z.object({
|
|
|
411
443
|
}).refine((data) => Boolean(data.agentIdentifier || data.parentChatId), {
|
|
412
444
|
message: "Provide either agentIdentifier or parentChatId"
|
|
413
445
|
});
|
|
414
|
-
var
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
446
|
+
var agentChatAuditInputBodySchema = z.object({
|
|
447
|
+
eveSessionId: z.string().min(1),
|
|
448
|
+
userId: z.string().min(1),
|
|
449
|
+
actionId: z.string().min(1),
|
|
450
|
+
actionTitle: z.string().optional(),
|
|
451
|
+
prompt: z.string().optional(),
|
|
452
|
+
data: z.record(z.string(), z.unknown()).optional(),
|
|
453
|
+
idempotencyKey: z.string().optional(),
|
|
454
|
+
/** Eve input request id — used to merge staged HITL metadata. */
|
|
455
|
+
requestId: z.string().optional(),
|
|
456
|
+
/** Eve tool call id — fallback lookup for staged HITL metadata. */
|
|
457
|
+
toolCallId: z.string().optional()
|
|
458
|
+
});
|
|
459
|
+
var eveHitlStagedOptionSchema = z.object({
|
|
460
|
+
id: z.string(),
|
|
461
|
+
label: z.string()
|
|
462
|
+
});
|
|
463
|
+
var agentChatStageHitlBodySchema = z.object({
|
|
464
|
+
eveSessionId: z.string().min(1),
|
|
465
|
+
requests: z.array(
|
|
466
|
+
z.object({
|
|
467
|
+
requestId: z.string().min(1),
|
|
468
|
+
toolCallId: z.string().min(1),
|
|
469
|
+
toolName: z.string().min(1),
|
|
470
|
+
prompt: z.string().min(1),
|
|
471
|
+
display: z.enum(["confirmation", "select", "text"]).optional(),
|
|
472
|
+
allowFreeform: z.boolean().optional(),
|
|
473
|
+
options: z.array(eveHitlStagedOptionSchema).optional(),
|
|
474
|
+
toolInput: z.record(z.string(), z.unknown()).optional()
|
|
475
|
+
})
|
|
476
|
+
)
|
|
477
|
+
});
|
|
478
|
+
var agentChatLinkTaskBodySchema = z.object({
|
|
479
|
+
eveSessionId: z.string().min(1),
|
|
480
|
+
publicTaskId: z.string().min(1),
|
|
481
|
+
toolCallId: z.string().min(1)
|
|
419
482
|
});
|
|
420
483
|
|
|
421
484
|
// src/schemas/index.ts
|
|
422
|
-
var
|
|
423
|
-
message:
|
|
485
|
+
var handlerUrlSchema2 = z2.string().refine((url) => isAllowedHandlerUrl(url), {
|
|
486
|
+
message: HANDLER_URL_ERROR
|
|
424
487
|
});
|
|
425
488
|
var jsonSchema7Schema2 = z2.custom(
|
|
426
489
|
(val) => typeof val === "object" && val !== null,
|
|
@@ -431,7 +494,7 @@ var uiSchemaSchema2 = z2.custom((val) => typeof val === "object" && val !== null
|
|
|
431
494
|
});
|
|
432
495
|
var webhookHandlerSchema2 = z2.object({
|
|
433
496
|
type: z2.literal("webhook"),
|
|
434
|
-
url:
|
|
497
|
+
url: handlerUrlSchema2,
|
|
435
498
|
headers: z2.record(z2.string(), z2.string())
|
|
436
499
|
});
|
|
437
500
|
var triggerHandlerSchema2 = webhookHandlerSchema2.extend({
|
|
@@ -608,8 +671,13 @@ async function parseResponseBody(response) {
|
|
|
608
671
|
}
|
|
609
672
|
function getErrorMessage(data, fallback) {
|
|
610
673
|
if (data && typeof data === "object" && !Array.isArray(data)) {
|
|
611
|
-
const
|
|
674
|
+
const record = data;
|
|
675
|
+
const maybeMessage = record.message;
|
|
676
|
+
const maybeHint = record.hint;
|
|
612
677
|
if (typeof maybeMessage === "string" && maybeMessage.trim()) {
|
|
678
|
+
if (typeof maybeHint === "string" && maybeHint.trim()) {
|
|
679
|
+
return `${maybeMessage.trim()} ${maybeHint.trim()}`;
|
|
680
|
+
}
|
|
613
681
|
return maybeMessage;
|
|
614
682
|
}
|
|
615
683
|
}
|
|
@@ -645,7 +713,26 @@ import { z as z3 } from "zod";
|
|
|
645
713
|
|
|
646
714
|
// ../core/src/app-url.ts
|
|
647
715
|
var PRODUCTION_APP_URL = "https://app.robotrock.io";
|
|
716
|
+
var PRODUCTION_API_URL = "https://api.robotrock.io/v1";
|
|
717
|
+
var DEV_API_URL = "http://localhost:4001/v1";
|
|
648
718
|
var APP_SIGNUP_URL = `${PRODUCTION_APP_URL}/sign-up`;
|
|
719
|
+
function normalizeRobotRockApiBaseUrl(baseUrl) {
|
|
720
|
+
const trimmed = baseUrl.trim().replace(/\/+$/, "");
|
|
721
|
+
if (trimmed.endsWith("/v1")) {
|
|
722
|
+
return trimmed;
|
|
723
|
+
}
|
|
724
|
+
return `${trimmed}/v1`;
|
|
725
|
+
}
|
|
726
|
+
function getRobotRockApiBaseUrl() {
|
|
727
|
+
const explicit = process.env.ROBOTROCK_BASE_URL?.trim() || process.env.ROBOTROCK_API_URL?.trim();
|
|
728
|
+
if (explicit) {
|
|
729
|
+
return normalizeRobotRockApiBaseUrl(explicit);
|
|
730
|
+
}
|
|
731
|
+
if (process.env.NODE_ENV === "production") {
|
|
732
|
+
return PRODUCTION_API_URL;
|
|
733
|
+
}
|
|
734
|
+
return DEV_API_URL;
|
|
735
|
+
}
|
|
649
736
|
|
|
650
737
|
// ../core/src/attribution/index.ts
|
|
651
738
|
var ATTRIBUTION_COOKIE_MAX_AGE = 60 * 60 * 24 * 90;
|
|
@@ -661,11 +748,40 @@ var attributionSchema = z3.object({
|
|
|
661
748
|
capturedAt: z3.number()
|
|
662
749
|
});
|
|
663
750
|
|
|
751
|
+
// src/auth-headers.ts
|
|
752
|
+
function buildRobotRockAuthHeaders(auth) {
|
|
753
|
+
if (auth.kind === "apiKey") {
|
|
754
|
+
return {
|
|
755
|
+
"X-Api-Key": auth.apiKey
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
return {
|
|
759
|
+
Authorization: `Bearer ${auth.token}`,
|
|
760
|
+
"X-RobotRock-Tenant-Slug": auth.tenantSlug,
|
|
761
|
+
"X-RobotRock-Connection-Id": auth.connectionId
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
function resolveRobotRockAuthConfig(overrides) {
|
|
765
|
+
if (overrides?.agentService) {
|
|
766
|
+
return {
|
|
767
|
+
kind: "agentService",
|
|
768
|
+
...overrides.agentService
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
const apiKey = overrides?.apiKey ?? process.env.ROBOTROCK_API_KEY;
|
|
772
|
+
if (!apiKey) {
|
|
773
|
+
throw new Error(
|
|
774
|
+
"RobotRock auth is required. Set ROBOTROCK_API_KEY, ROBOTROCK_AGENT_SERVICE_TOKEN with tenant context, or pass auth when creating the client."
|
|
775
|
+
);
|
|
776
|
+
}
|
|
777
|
+
return { kind: "apiKey", apiKey };
|
|
778
|
+
}
|
|
779
|
+
|
|
664
780
|
// src/chats.ts
|
|
665
781
|
function createChatsApi(config) {
|
|
666
782
|
const headers = () => ({
|
|
667
783
|
"Content-Type": "application/json",
|
|
668
|
-
|
|
784
|
+
...buildRobotRockAuthHeaders(config.auth)
|
|
669
785
|
});
|
|
670
786
|
return {
|
|
671
787
|
async create(input) {
|
|
@@ -718,6 +834,97 @@ function createChatsApi(config) {
|
|
|
718
834
|
data
|
|
719
835
|
);
|
|
720
836
|
}
|
|
837
|
+
},
|
|
838
|
+
async stageHitlRequests(input) {
|
|
839
|
+
const validation = agentChatStageHitlBodySchema.safeParse(input);
|
|
840
|
+
if (!validation.success) {
|
|
841
|
+
throw new RobotRockError(
|
|
842
|
+
`Invalid stage HITL input: ${validation.error.issues[0]?.message}`,
|
|
843
|
+
400,
|
|
844
|
+
validation.error.issues
|
|
845
|
+
);
|
|
846
|
+
}
|
|
847
|
+
const response = await fetch(`${config.baseUrl}/agent-chats/stage-hitl`, {
|
|
848
|
+
method: "POST",
|
|
849
|
+
headers: headers(),
|
|
850
|
+
body: JSON.stringify(validation.data)
|
|
851
|
+
});
|
|
852
|
+
if (!response.ok) {
|
|
853
|
+
const data = await parseResponseBody(response);
|
|
854
|
+
throw new RobotRockError(
|
|
855
|
+
getErrorMessage(data, "Failed to stage chat HITL requests"),
|
|
856
|
+
response.status,
|
|
857
|
+
data
|
|
858
|
+
);
|
|
859
|
+
}
|
|
860
|
+
},
|
|
861
|
+
async getStagedHitlRequests(eveSessionId) {
|
|
862
|
+
const trimmed = eveSessionId.trim();
|
|
863
|
+
if (!trimmed) {
|
|
864
|
+
throw new RobotRockError("eveSessionId is required", 400);
|
|
865
|
+
}
|
|
866
|
+
const url = new URL(`${config.baseUrl}/agent-chats/staged-hitl`);
|
|
867
|
+
url.searchParams.set("eveSessionId", trimmed);
|
|
868
|
+
const response = await fetch(url.toString(), {
|
|
869
|
+
method: "GET",
|
|
870
|
+
headers: headers()
|
|
871
|
+
});
|
|
872
|
+
const data = await parseResponseBody(response);
|
|
873
|
+
if (!response.ok) {
|
|
874
|
+
throw new RobotRockError(
|
|
875
|
+
getErrorMessage(data, "Failed to fetch staged chat HITL requests"),
|
|
876
|
+
response.status,
|
|
877
|
+
data
|
|
878
|
+
);
|
|
879
|
+
}
|
|
880
|
+
const requests = data.requests;
|
|
881
|
+
return Array.isArray(requests) ? requests : [];
|
|
882
|
+
},
|
|
883
|
+
async logInputSubmission(input) {
|
|
884
|
+
const validation = agentChatAuditInputBodySchema.safeParse(input);
|
|
885
|
+
if (!validation.success) {
|
|
886
|
+
throw new RobotRockError(
|
|
887
|
+
`Invalid audit input: ${validation.error.issues[0]?.message}`,
|
|
888
|
+
400,
|
|
889
|
+
validation.error.issues
|
|
890
|
+
);
|
|
891
|
+
}
|
|
892
|
+
const response = await fetch(`${config.baseUrl}/agent-chats/audit-input`, {
|
|
893
|
+
method: "POST",
|
|
894
|
+
headers: headers(),
|
|
895
|
+
body: JSON.stringify(validation.data)
|
|
896
|
+
});
|
|
897
|
+
if (!response.ok) {
|
|
898
|
+
const data = await parseResponseBody(response);
|
|
899
|
+
throw new RobotRockError(
|
|
900
|
+
getErrorMessage(data, "Failed to log chat input submission"),
|
|
901
|
+
response.status,
|
|
902
|
+
data
|
|
903
|
+
);
|
|
904
|
+
}
|
|
905
|
+
},
|
|
906
|
+
async linkTask(input) {
|
|
907
|
+
const validation = agentChatLinkTaskBodySchema.safeParse(input);
|
|
908
|
+
if (!validation.success) {
|
|
909
|
+
throw new RobotRockError(
|
|
910
|
+
`Invalid link task input: ${validation.error.issues[0]?.message}`,
|
|
911
|
+
400,
|
|
912
|
+
validation.error.issues
|
|
913
|
+
);
|
|
914
|
+
}
|
|
915
|
+
const response = await fetch(`${config.baseUrl}/agent-chats/link-task`, {
|
|
916
|
+
method: "POST",
|
|
917
|
+
headers: headers(),
|
|
918
|
+
body: JSON.stringify(validation.data)
|
|
919
|
+
});
|
|
920
|
+
if (!response.ok) {
|
|
921
|
+
const data = await parseResponseBody(response);
|
|
922
|
+
throw new RobotRockError(
|
|
923
|
+
getErrorMessage(data, "Failed to link inbox task to chat"),
|
|
924
|
+
response.status,
|
|
925
|
+
data
|
|
926
|
+
);
|
|
927
|
+
}
|
|
721
928
|
}
|
|
722
929
|
};
|
|
723
930
|
}
|
|
@@ -760,7 +967,7 @@ function serializeValidUntil(value) {
|
|
|
760
967
|
throw new RobotRockError("Invalid validUntil: expected a Date or parseable date string", 400);
|
|
761
968
|
}
|
|
762
969
|
var RobotRock = class {
|
|
763
|
-
|
|
970
|
+
auth;
|
|
764
971
|
baseUrl;
|
|
765
972
|
app;
|
|
766
973
|
agentVersion;
|
|
@@ -778,14 +985,17 @@ var RobotRock = class {
|
|
|
778
985
|
);
|
|
779
986
|
}
|
|
780
987
|
const apiKey = config.apiKey ?? process.env.ROBOTROCK_API_KEY;
|
|
781
|
-
|
|
988
|
+
const agentService = config.agentService;
|
|
989
|
+
if (apiKey && agentService) {
|
|
782
990
|
throw new Error(
|
|
783
|
-
"RobotRock
|
|
991
|
+
"RobotRock client cannot configure both apiKey and agentService."
|
|
784
992
|
);
|
|
785
993
|
}
|
|
786
|
-
this.
|
|
787
|
-
|
|
788
|
-
|
|
994
|
+
this.auth = resolveRobotRockAuthConfig({
|
|
995
|
+
...apiKey ? { apiKey } : {},
|
|
996
|
+
...agentService ? { agentService } : {}
|
|
997
|
+
});
|
|
998
|
+
this.baseUrl = config.baseUrl ?? getRobotRockApiBaseUrl();
|
|
789
999
|
this.app = config.app;
|
|
790
1000
|
this.agentVersion = config.version ?? resolveAgentVersionFromEnv();
|
|
791
1001
|
this.contextVersion = config.advanced?.contextVersion ?? TASK_CONTEXT_FORMAT_VERSION2;
|
|
@@ -799,10 +1009,17 @@ var RobotRock = class {
|
|
|
799
1009
|
};
|
|
800
1010
|
this.chats = createChatsApi({
|
|
801
1011
|
baseUrl: this.baseUrl,
|
|
802
|
-
|
|
1012
|
+
auth: this.auth,
|
|
803
1013
|
app: this.app
|
|
804
1014
|
});
|
|
805
1015
|
}
|
|
1016
|
+
authHeaders(extra) {
|
|
1017
|
+
return {
|
|
1018
|
+
"Content-Type": "application/json",
|
|
1019
|
+
...buildRobotRockAuthHeaders(this.auth),
|
|
1020
|
+
...extra
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
806
1023
|
async createTaskRequest(task) {
|
|
807
1024
|
const normalizedTask = normalizeSendToHumanInput(task, {
|
|
808
1025
|
webhook: this.webhook,
|
|
@@ -827,13 +1044,9 @@ var RobotRock = class {
|
|
|
827
1044
|
validation.error.issues
|
|
828
1045
|
);
|
|
829
1046
|
}
|
|
830
|
-
const headers =
|
|
831
|
-
"
|
|
832
|
-
|
|
833
|
-
};
|
|
834
|
-
if (task.idempotencyKey) {
|
|
835
|
-
headers["Idempotency-Key"] = task.idempotencyKey;
|
|
836
|
-
}
|
|
1047
|
+
const headers = this.authHeaders(
|
|
1048
|
+
task.idempotencyKey ? { "Idempotency-Key": task.idempotencyKey } : void 0
|
|
1049
|
+
);
|
|
837
1050
|
const response = await fetch(`${this.baseUrl}/`, {
|
|
838
1051
|
method: "POST",
|
|
839
1052
|
headers,
|
|
@@ -926,9 +1139,7 @@ var RobotRock = class {
|
|
|
926
1139
|
async getTaskById(taskId) {
|
|
927
1140
|
const response = await fetch(`${this.baseUrl}/tasks/${taskId}`, {
|
|
928
1141
|
method: "GET",
|
|
929
|
-
headers:
|
|
930
|
-
"X-Api-Key": this.apiKey
|
|
931
|
-
}
|
|
1142
|
+
headers: this.authHeaders()
|
|
932
1143
|
});
|
|
933
1144
|
if (response.status === 404) {
|
|
934
1145
|
return null;
|
|
@@ -963,10 +1174,7 @@ var RobotRock = class {
|
|
|
963
1174
|
`${this.baseUrl}/threads/${encodeURIComponent(threadId)}/updates`,
|
|
964
1175
|
{
|
|
965
1176
|
method: "POST",
|
|
966
|
-
headers:
|
|
967
|
-
"Content-Type": "application/json",
|
|
968
|
-
"X-Api-Key": this.apiKey
|
|
969
|
-
},
|
|
1177
|
+
headers: this.authHeaders(),
|
|
970
1178
|
body: JSON.stringify(validation.data)
|
|
971
1179
|
}
|
|
972
1180
|
);
|
|
@@ -983,9 +1191,7 @@ var RobotRock = class {
|
|
|
983
1191
|
async cancelTaskRequest(taskId) {
|
|
984
1192
|
const response = await fetch(`${this.baseUrl}/tasks/${taskId}/cancel`, {
|
|
985
1193
|
method: "POST",
|
|
986
|
-
headers:
|
|
987
|
-
"X-Api-Key": this.apiKey
|
|
988
|
-
}
|
|
1194
|
+
headers: this.authHeaders()
|
|
989
1195
|
});
|
|
990
1196
|
if (!response.ok) {
|
|
991
1197
|
const data = await parseResponseBody(response);
|
|
@@ -1041,16 +1247,24 @@ function normalizeSendToHumanInput(task, clientDefaults) {
|
|
|
1041
1247
|
}
|
|
1042
1248
|
|
|
1043
1249
|
// src/env.ts
|
|
1044
|
-
var DEFAULT_BASE_URL = "https://api.robotrock.io/v1";
|
|
1045
1250
|
function resolveRobotRockConfig(overrides) {
|
|
1251
|
+
const agentService = overrides?.agentService;
|
|
1046
1252
|
const apiKey = overrides?.apiKey ?? process.env.ROBOTROCK_API_KEY;
|
|
1047
|
-
if (
|
|
1253
|
+
if (agentService && apiKey) {
|
|
1048
1254
|
throw new Error(
|
|
1049
|
-
"RobotRock
|
|
1255
|
+
"RobotRock client cannot configure both apiKey and agentService."
|
|
1050
1256
|
);
|
|
1051
1257
|
}
|
|
1052
|
-
const baseUrl = overrides?.baseUrl ??
|
|
1258
|
+
const baseUrl = overrides?.baseUrl ?? getRobotRockApiBaseUrl();
|
|
1053
1259
|
const app = overrides?.app ?? process.env.ROBOTROCK_APP;
|
|
1260
|
+
if (agentService) {
|
|
1261
|
+
return app ? { agentService, baseUrl, app } : { agentService, baseUrl };
|
|
1262
|
+
}
|
|
1263
|
+
if (!apiKey) {
|
|
1264
|
+
throw new Error(
|
|
1265
|
+
"RobotRock API key is required. Set ROBOTROCK_API_KEY or pass agentService when creating the client."
|
|
1266
|
+
);
|
|
1267
|
+
}
|
|
1054
1268
|
return app ? { apiKey, baseUrl, app } : { apiKey, baseUrl };
|
|
1055
1269
|
}
|
|
1056
1270
|
|