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
package/dist/ai/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { C as CloseChatToolDurableOptions, a as CloseChatToolOptions, c as closeChatToolInputSchema, b as CloseChatToolResult } from '../trigger-
|
|
2
|
-
export { d as CLOSE_CHAT_TOOL_NAME, e as CloseChatToolInput, f as CreateRobotRockAiToolsOptions, R as RobotRockAiTools, g as approveByHumanTool, h as createRobotRockAiTools, i as createSendToHumanTool, j as createSendUpdateTool, r as reportStatusTool, k as requestActionInputTool } from '../trigger-
|
|
1
|
+
import { C as CloseChatToolDurableOptions, a as CloseChatToolOptions, c as closeChatToolInputSchema, b as CloseChatToolResult } from '../trigger-Dn0DFiyU.js';
|
|
2
|
+
export { d as CLOSE_CHAT_TOOL_NAME, e as CloseChatToolInput, f as CreateRobotRockAiToolsOptions, R as RobotRockAiTools, g as approveByHumanTool, h as createRobotRockAiTools, i as createSendToHumanTool, j as createSendUpdateTool, r as reportStatusTool, k as requestActionInputTool } from '../trigger-Dn0DFiyU.js';
|
|
3
3
|
import { Tool } from 'ai';
|
|
4
4
|
import { z } from 'zod';
|
|
5
|
-
import { R as RobotRock, a as SendToHumanInput } from '../client-
|
|
6
|
-
import { u as RobotRockToolCallInfo, F as FormatToolApprovalTaskOptions, H as HumanToolResult } from '../tool-approval-bridge-
|
|
7
|
-
export { v as APPROVE_BY_HUMAN_ACTIONS, A as ApproveByHumanToolDurableOptions, a as ApproveByHumanToolOptions, i as CreateSendToHumanToolDurableOptions, C as CreateSendToHumanToolOptions, j as CreateSendUpdateToolDurableOptions, c as CreateSendUpdateToolOptions, w as REPORT_STATUS_TOOL_NAME, x as REQUEST_ACTION_INPUT_TOOL_NAME, y as ReportStatusPhase, z as ReportStatusToolInput, g as ReportStatusToolOptions, B as ReportStatusToolOutput, D as RequestActionInputToolInput, e as RequestActionInputToolOptions, E as RequestActionInputToolOutput, G as ResolveToolApprovalsOptions, k as RobotRockAiContext, l as RobotRockAiMode, m as RobotRockAiPollingContext, n as RobotRockAiTriggerContext, R as RobotRockAiWorkflowContext, I as RobotRockToolApprovalConfig, J as RobotRockToolApprovalDecision, K as RunWithRobotRockApprovalsOptions, L as SendUpdateToolResult, T as ToolApprovalRequestPart, o as applyRobotRockToolApprovalToTools, M as approveByHumanForAi, N as approveByHumanInputSchema, O as buildReportStatusToolDefinition, P as buildRequestActionInputToolDefinition, Q as closeChatForAi, U as collectApprovalRequests, V as createRobotRockAiTriggerContext, p as createRobotRockAiWorkflowContext, q as createRobotRockNeedsApproval, r as createRobotRockToolApproval, W as defaultRequestActionInputActionId, X as executeReportStatusTool, Y as isReportStatusToolPart, Z as isRequestActionInputToolPart, _ as normalizeReportStatusToolInput, $ as normalizeRequestActionInputToolInput, a0 as normalizeRobotRockAiContext, a1 as reportStatusPhaseSchema, a2 as reportStatusToolInputSchema, a3 as reportStatusToolOutputSchema, a4 as requestActionInputToolInputSchema, a5 as requestActionInputToolOutputSchema, s as resolveToolApprovalsViaRobotRock, t as runWithRobotRockApprovals, a6 as sendToHumanForAi, a7 as sendToHumanToolInputSchema, a8 as sendUpdateForAi, a9 as sendUpdateToolInputSchema } from '../tool-approval-bridge-
|
|
5
|
+
import { R as RobotRock, a as SendToHumanInput } from '../client-XTnFHGFE.js';
|
|
6
|
+
import { u as RobotRockToolCallInfo, F as FormatToolApprovalTaskOptions, H as HumanToolResult } from '../tool-approval-bridge-C4bTm8vu.js';
|
|
7
|
+
export { v as APPROVE_BY_HUMAN_ACTIONS, A as ApproveByHumanToolDurableOptions, a as ApproveByHumanToolOptions, i as CreateSendToHumanToolDurableOptions, C as CreateSendToHumanToolOptions, j as CreateSendUpdateToolDurableOptions, c as CreateSendUpdateToolOptions, w as REPORT_STATUS_TOOL_NAME, x as REQUEST_ACTION_INPUT_TOOL_NAME, y as ReportStatusPhase, z as ReportStatusToolInput, g as ReportStatusToolOptions, B as ReportStatusToolOutput, D as RequestActionInputToolInput, e as RequestActionInputToolOptions, E as RequestActionInputToolOutput, G as ResolveToolApprovalsOptions, k as RobotRockAiContext, l as RobotRockAiMode, m as RobotRockAiPollingContext, n as RobotRockAiTriggerContext, R as RobotRockAiWorkflowContext, I as RobotRockToolApprovalConfig, J as RobotRockToolApprovalDecision, K as RunWithRobotRockApprovalsOptions, L as SendUpdateToolResult, T as ToolApprovalRequestPart, o as applyRobotRockToolApprovalToTools, M as approveByHumanForAi, N as approveByHumanInputSchema, O as buildReportStatusToolDefinition, P as buildRequestActionInputToolDefinition, Q as closeChatForAi, U as collectApprovalRequests, V as createRobotRockAiTriggerContext, p as createRobotRockAiWorkflowContext, q as createRobotRockNeedsApproval, r as createRobotRockToolApproval, W as defaultRequestActionInputActionId, X as executeReportStatusTool, Y as isReportStatusToolPart, Z as isRequestActionInputToolPart, _ as normalizeReportStatusToolInput, $ as normalizeRequestActionInputToolInput, a0 as normalizeRobotRockAiContext, a1 as reportStatusPhaseSchema, a2 as reportStatusToolInputSchema, a3 as reportStatusToolOutputSchema, a4 as requestActionInputToolInputSchema, a5 as requestActionInputToolOutputSchema, s as resolveToolApprovalsViaRobotRock, t as runWithRobotRockApprovals, a6 as sendToHumanForAi, a7 as sendToHumanToolInputSchema, a8 as sendUpdateForAi, a9 as sendUpdateToolInputSchema } from '../tool-approval-bridge-C4bTm8vu.js';
|
|
8
8
|
import { DiscriminatedApprovalResult } from '../schemas/index.js';
|
|
9
9
|
import '@robotrock/core';
|
|
10
10
|
|
package/dist/ai/index.js
CHANGED
|
@@ -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, taskActionInputSchema, taskActionSchema, uiFieldSchemaSchema, contextUiSchema, contextDataSchema, TASK_CONTEXT_FORMAT_VERSION, taskContextObjectBaseSchema, taskContextObjectSchema, taskContextSchema, assignToSchema, threadUpdateMessageSchema, threadUpdateStatuses, threadUpdateStatusSchema, threadUpdateInputSchema, taskPriorities, taskPrioritySchema, agentTelemetrySchema, createTaskBodySchema, agentChatSeedActionSchema, agentChatSeedMessageSchema, createAgentChatBodySchema,
|
|
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:
|
|
353
|
+
url: handlerUrlSchema,
|
|
323
354
|
headers: z.record(z.string(), z.string())
|
|
324
355
|
});
|
|
325
356
|
triggerHandlerSchema = webhookHandlerSchema.extend({
|
|
@@ -453,13 +484,22 @@ var init_task = __esm({
|
|
|
453
484
|
action: agentChatSeedActionSchema
|
|
454
485
|
}).optional()
|
|
455
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
|
+
});
|
|
456
496
|
createAgentChatBodySchema = z.object({
|
|
457
|
-
/**
|
|
497
|
+
/** Agent id (eve agent name). Required unless `parentChatId` is set. */
|
|
458
498
|
agentIdentifier: z.string().min(1).optional(),
|
|
459
499
|
/** Inherit tenant/connection/agent from an existing chat (agent-spawned chats). */
|
|
460
500
|
parentChatId: z.string().min(1).optional(),
|
|
461
|
-
/** Convex
|
|
462
|
-
|
|
501
|
+
/** Convex tenantEveConnections id; resolved from the tenant when omitted. */
|
|
502
|
+
eveConnectionId: z.string().min(1).optional(),
|
|
463
503
|
/** Source application id; groups the chat under an inbox section. */
|
|
464
504
|
app: z.string().min(1).optional(),
|
|
465
505
|
assignTo: assignToSchema.optional(),
|
|
@@ -470,11 +510,42 @@ var init_task = __esm({
|
|
|
470
510
|
}).refine((data) => Boolean(data.agentIdentifier || data.parentChatId), {
|
|
471
511
|
message: "Provide either agentIdentifier or parentChatId"
|
|
472
512
|
});
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
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)
|
|
478
549
|
});
|
|
479
550
|
}
|
|
480
551
|
});
|
|
@@ -515,14 +586,14 @@ function refineContextPublicUrls2(data, ctx) {
|
|
|
515
586
|
});
|
|
516
587
|
}
|
|
517
588
|
}
|
|
518
|
-
var
|
|
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;
|
|
519
590
|
var init_schemas2 = __esm({
|
|
520
591
|
"src/schemas/index.ts"() {
|
|
521
592
|
"use strict";
|
|
522
593
|
init_utils();
|
|
523
594
|
init_schemas();
|
|
524
|
-
|
|
525
|
-
message:
|
|
595
|
+
handlerUrlSchema2 = z2.string().refine((url) => isAllowedHandlerUrl(url), {
|
|
596
|
+
message: HANDLER_URL_ERROR
|
|
526
597
|
});
|
|
527
598
|
jsonSchema7Schema2 = z2.custom(
|
|
528
599
|
(val) => typeof val === "object" && val !== null,
|
|
@@ -533,7 +604,7 @@ var init_schemas2 = __esm({
|
|
|
533
604
|
});
|
|
534
605
|
webhookHandlerSchema2 = z2.object({
|
|
535
606
|
type: z2.literal("webhook"),
|
|
536
|
-
url:
|
|
607
|
+
url: handlerUrlSchema2,
|
|
537
608
|
headers: z2.record(z2.string(), z2.string())
|
|
538
609
|
});
|
|
539
610
|
triggerHandlerSchema2 = webhookHandlerSchema2.extend({
|
|
@@ -693,8 +764,13 @@ async function parseResponseBody(response) {
|
|
|
693
764
|
}
|
|
694
765
|
function getErrorMessage(data, fallback) {
|
|
695
766
|
if (data && typeof data === "object" && !Array.isArray(data)) {
|
|
696
|
-
const
|
|
767
|
+
const record = data;
|
|
768
|
+
const maybeMessage = record.message;
|
|
769
|
+
const maybeHint = record.hint;
|
|
697
770
|
if (typeof maybeMessage === "string" && maybeMessage.trim()) {
|
|
771
|
+
if (typeof maybeHint === "string" && maybeHint.trim()) {
|
|
772
|
+
return `${maybeMessage.trim()} ${maybeHint.trim()}`;
|
|
773
|
+
}
|
|
698
774
|
return maybeMessage;
|
|
699
775
|
}
|
|
700
776
|
}
|
|
@@ -790,11 +866,30 @@ var init_welcome_task = __esm({
|
|
|
790
866
|
});
|
|
791
867
|
|
|
792
868
|
// ../core/src/app-url.ts
|
|
793
|
-
|
|
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;
|
|
794
887
|
var init_app_url = __esm({
|
|
795
888
|
"../core/src/app-url.ts"() {
|
|
796
889
|
"use strict";
|
|
797
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";
|
|
798
893
|
APP_SIGNUP_URL = `${PRODUCTION_APP_URL}/sign-up`;
|
|
799
894
|
}
|
|
800
895
|
});
|
|
@@ -822,6 +917,13 @@ var init_attribution = __esm({
|
|
|
822
917
|
}
|
|
823
918
|
});
|
|
824
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
|
+
|
|
825
927
|
// ../core/src/index.ts
|
|
826
928
|
var init_src = __esm({
|
|
827
929
|
"../core/src/index.ts"() {
|
|
@@ -835,6 +937,41 @@ var init_src = __esm({
|
|
|
835
937
|
init_welcome_task();
|
|
836
938
|
init_attribution();
|
|
837
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";
|
|
838
975
|
}
|
|
839
976
|
});
|
|
840
977
|
|
|
@@ -842,7 +979,7 @@ var init_src = __esm({
|
|
|
842
979
|
function createChatsApi(config) {
|
|
843
980
|
const headers = () => ({
|
|
844
981
|
"Content-Type": "application/json",
|
|
845
|
-
|
|
982
|
+
...buildRobotRockAuthHeaders(config.auth)
|
|
846
983
|
});
|
|
847
984
|
return {
|
|
848
985
|
async create(input) {
|
|
@@ -895,6 +1032,97 @@ function createChatsApi(config) {
|
|
|
895
1032
|
data
|
|
896
1033
|
);
|
|
897
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
|
+
}
|
|
898
1126
|
}
|
|
899
1127
|
};
|
|
900
1128
|
}
|
|
@@ -903,6 +1131,7 @@ var init_chats = __esm({
|
|
|
903
1131
|
"use strict";
|
|
904
1132
|
init_src();
|
|
905
1133
|
init_http();
|
|
1134
|
+
init_auth_headers();
|
|
906
1135
|
}
|
|
907
1136
|
});
|
|
908
1137
|
|
|
@@ -990,12 +1219,14 @@ var init_client = __esm({
|
|
|
990
1219
|
init_schemas2();
|
|
991
1220
|
init_approval_result();
|
|
992
1221
|
init_http();
|
|
1222
|
+
init_src();
|
|
993
1223
|
init_chats();
|
|
1224
|
+
init_auth_headers();
|
|
994
1225
|
init_http();
|
|
995
1226
|
DEFAULT_POLL_INTERVAL_MS = 2e3;
|
|
996
1227
|
DEFAULT_TIMEOUT_MS = 24 * 60 * 60 * 1e3;
|
|
997
1228
|
RobotRock = class {
|
|
998
|
-
|
|
1229
|
+
auth;
|
|
999
1230
|
baseUrl;
|
|
1000
1231
|
app;
|
|
1001
1232
|
agentVersion;
|
|
@@ -1013,14 +1244,17 @@ var init_client = __esm({
|
|
|
1013
1244
|
);
|
|
1014
1245
|
}
|
|
1015
1246
|
const apiKey = config.apiKey ?? process.env.ROBOTROCK_API_KEY;
|
|
1016
|
-
|
|
1247
|
+
const agentService = config.agentService;
|
|
1248
|
+
if (apiKey && agentService) {
|
|
1017
1249
|
throw new Error(
|
|
1018
|
-
"RobotRock
|
|
1250
|
+
"RobotRock client cannot configure both apiKey and agentService."
|
|
1019
1251
|
);
|
|
1020
1252
|
}
|
|
1021
|
-
this.
|
|
1022
|
-
|
|
1023
|
-
|
|
1253
|
+
this.auth = resolveRobotRockAuthConfig({
|
|
1254
|
+
...apiKey ? { apiKey } : {},
|
|
1255
|
+
...agentService ? { agentService } : {}
|
|
1256
|
+
});
|
|
1257
|
+
this.baseUrl = config.baseUrl ?? getRobotRockApiBaseUrl();
|
|
1024
1258
|
this.app = config.app;
|
|
1025
1259
|
this.agentVersion = config.version ?? resolveAgentVersionFromEnv();
|
|
1026
1260
|
this.contextVersion = config.advanced?.contextVersion ?? TASK_CONTEXT_FORMAT_VERSION2;
|
|
@@ -1034,10 +1268,17 @@ var init_client = __esm({
|
|
|
1034
1268
|
};
|
|
1035
1269
|
this.chats = createChatsApi({
|
|
1036
1270
|
baseUrl: this.baseUrl,
|
|
1037
|
-
|
|
1271
|
+
auth: this.auth,
|
|
1038
1272
|
app: this.app
|
|
1039
1273
|
});
|
|
1040
1274
|
}
|
|
1275
|
+
authHeaders(extra) {
|
|
1276
|
+
return {
|
|
1277
|
+
"Content-Type": "application/json",
|
|
1278
|
+
...buildRobotRockAuthHeaders(this.auth),
|
|
1279
|
+
...extra
|
|
1280
|
+
};
|
|
1281
|
+
}
|
|
1041
1282
|
async createTaskRequest(task2) {
|
|
1042
1283
|
const normalizedTask = normalizeSendToHumanInput(task2, {
|
|
1043
1284
|
webhook: this.webhook,
|
|
@@ -1062,13 +1303,9 @@ var init_client = __esm({
|
|
|
1062
1303
|
validation.error.issues
|
|
1063
1304
|
);
|
|
1064
1305
|
}
|
|
1065
|
-
const headers =
|
|
1066
|
-
"
|
|
1067
|
-
|
|
1068
|
-
};
|
|
1069
|
-
if (task2.idempotencyKey) {
|
|
1070
|
-
headers["Idempotency-Key"] = task2.idempotencyKey;
|
|
1071
|
-
}
|
|
1306
|
+
const headers = this.authHeaders(
|
|
1307
|
+
task2.idempotencyKey ? { "Idempotency-Key": task2.idempotencyKey } : void 0
|
|
1308
|
+
);
|
|
1072
1309
|
const response = await fetch(`${this.baseUrl}/`, {
|
|
1073
1310
|
method: "POST",
|
|
1074
1311
|
headers,
|
|
@@ -1161,9 +1398,7 @@ var init_client = __esm({
|
|
|
1161
1398
|
async getTaskById(taskId) {
|
|
1162
1399
|
const response = await fetch(`${this.baseUrl}/tasks/${taskId}`, {
|
|
1163
1400
|
method: "GET",
|
|
1164
|
-
headers:
|
|
1165
|
-
"X-Api-Key": this.apiKey
|
|
1166
|
-
}
|
|
1401
|
+
headers: this.authHeaders()
|
|
1167
1402
|
});
|
|
1168
1403
|
if (response.status === 404) {
|
|
1169
1404
|
return null;
|
|
@@ -1198,10 +1433,7 @@ var init_client = __esm({
|
|
|
1198
1433
|
`${this.baseUrl}/threads/${encodeURIComponent(threadId)}/updates`,
|
|
1199
1434
|
{
|
|
1200
1435
|
method: "POST",
|
|
1201
|
-
headers:
|
|
1202
|
-
"Content-Type": "application/json",
|
|
1203
|
-
"X-Api-Key": this.apiKey
|
|
1204
|
-
},
|
|
1436
|
+
headers: this.authHeaders(),
|
|
1205
1437
|
body: JSON.stringify(validation.data)
|
|
1206
1438
|
}
|
|
1207
1439
|
);
|
|
@@ -1218,9 +1450,7 @@ var init_client = __esm({
|
|
|
1218
1450
|
async cancelTaskRequest(taskId) {
|
|
1219
1451
|
const response = await fetch(`${this.baseUrl}/tasks/${taskId}/cancel`, {
|
|
1220
1452
|
method: "POST",
|
|
1221
|
-
headers:
|
|
1222
|
-
"X-Api-Key": this.apiKey
|
|
1223
|
-
}
|
|
1453
|
+
headers: this.authHeaders()
|
|
1224
1454
|
});
|
|
1225
1455
|
if (!response.ok) {
|
|
1226
1456
|
const data = await parseResponseBody(response);
|
|
@@ -1237,22 +1467,30 @@ var init_client = __esm({
|
|
|
1237
1467
|
|
|
1238
1468
|
// src/env.ts
|
|
1239
1469
|
function resolveRobotRockConfig(overrides) {
|
|
1470
|
+
const agentService = overrides?.agentService;
|
|
1240
1471
|
const apiKey = overrides?.apiKey ?? process.env.ROBOTROCK_API_KEY;
|
|
1241
|
-
if (
|
|
1472
|
+
if (agentService && apiKey) {
|
|
1242
1473
|
throw new Error(
|
|
1243
|
-
"RobotRock
|
|
1474
|
+
"RobotRock client cannot configure both apiKey and agentService."
|
|
1244
1475
|
);
|
|
1245
1476
|
}
|
|
1246
|
-
const baseUrl = overrides?.baseUrl ??
|
|
1477
|
+
const baseUrl = overrides?.baseUrl ?? getRobotRockApiBaseUrl();
|
|
1247
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
|
+
}
|
|
1248
1487
|
return app ? { apiKey, baseUrl, app } : { apiKey, baseUrl };
|
|
1249
1488
|
}
|
|
1250
|
-
var DEFAULT_BASE_URL;
|
|
1251
1489
|
var init_env = __esm({
|
|
1252
1490
|
"src/env.ts"() {
|
|
1253
1491
|
"use strict";
|
|
1254
1492
|
init_client();
|
|
1255
|
-
|
|
1493
|
+
init_src();
|
|
1256
1494
|
}
|
|
1257
1495
|
});
|
|
1258
1496
|
|