robotrock 1.1.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.
Files changed (70) hide show
  1. package/dist/agent-admin.d.ts +82 -0
  2. package/dist/agent-admin.js +938 -0
  3. package/dist/agent-admin.js.map +1 -0
  4. package/dist/ai/index.d.ts +6 -5
  5. package/dist/ai/index.js +407 -188
  6. package/dist/ai/index.js.map +1 -1
  7. package/dist/ai/trigger.d.ts +4 -3
  8. package/dist/ai/trigger.js +407 -188
  9. package/dist/ai/trigger.js.map +1 -1
  10. package/dist/ai/workflow.d.ts +4 -3
  11. package/dist/ai/workflow.js +404 -185
  12. package/dist/ai/workflow.js.map +1 -1
  13. package/dist/auth-headers-qL-ZeEtd.d.ts +13 -0
  14. package/dist/{client-XTnFHGFE.d.ts → client-YO9Y1rkH.d.ts} +29 -17
  15. package/dist/eve/agent/index.d.ts +11 -35
  16. package/dist/eve/agent/index.js +678 -146
  17. package/dist/eve/agent/index.js.map +1 -1
  18. package/dist/eve/index.d.ts +5 -2
  19. package/dist/eve/index.js +195 -2
  20. package/dist/eve/index.js.map +1 -1
  21. package/dist/eve/tools/admin/assign-tasks.d.ts +39 -0
  22. package/dist/eve/tools/admin/assign-tasks.js +1060 -0
  23. package/dist/eve/tools/admin/assign-tasks.js.map +1 -0
  24. package/dist/eve/tools/admin/manage-groups.d.ts +53 -0
  25. package/dist/eve/tools/admin/manage-groups.js +1218 -0
  26. package/dist/eve/tools/admin/manage-groups.js.map +1 -0
  27. package/dist/eve/tools/admin/manage-team-members.d.ts +45 -0
  28. package/dist/eve/tools/admin/manage-team-members.js +1160 -0
  29. package/dist/eve/tools/admin/manage-team-members.js.map +1 -0
  30. package/dist/eve/tools/admin/query-tasks.d.ts +71 -0
  31. package/dist/eve/tools/admin/query-tasks.js +1161 -0
  32. package/dist/eve/tools/admin/query-tasks.js.map +1 -0
  33. package/dist/eve/tools/catalog/search-products.d.ts +57 -0
  34. package/dist/eve/tools/catalog/search-products.js +94 -0
  35. package/dist/eve/tools/catalog/search-products.js.map +1 -0
  36. package/dist/eve/tools/identity/index.d.ts +2 -0
  37. package/dist/eve/tools/identity/index.js +117 -27
  38. package/dist/eve/tools/identity/index.js.map +1 -1
  39. package/dist/eve/tools/identity/my-access.d.ts +6 -46
  40. package/dist/eve/tools/identity/my-access.js +91 -10
  41. package/dist/eve/tools/identity/my-access.js.map +1 -1
  42. package/dist/eve/tools/identity/whoami.d.ts +7 -8
  43. package/dist/eve/tools/identity/whoami.js +33 -17
  44. package/dist/eve/tools/identity/whoami.js.map +1 -1
  45. package/dist/eve/tools/inbox/create-task.d.ts +5 -4
  46. package/dist/eve/tools/inbox/create-task.js +365 -137
  47. package/dist/eve/tools/inbox/create-task.js.map +1 -1
  48. package/dist/eve/tools/inbox/index.d.ts +1 -0
  49. package/dist/eve/tools/inbox/index.js +365 -137
  50. package/dist/eve/tools/inbox/index.js.map +1 -1
  51. package/dist/eve/tools/index.d.ts +7 -0
  52. package/dist/eve/tools/index.js +1362 -168
  53. package/dist/eve/tools/index.js.map +1 -1
  54. package/dist/{index-BL9qKHA8.d.ts → index-DoQN48Bm.d.ts} +61 -2
  55. package/dist/index.d.ts +6 -3
  56. package/dist/index.js +325 -119
  57. package/dist/index.js.map +1 -1
  58. package/dist/schemas/index.d.ts +6 -1
  59. package/dist/schemas/index.js +177 -48
  60. package/dist/schemas/index.js.map +1 -1
  61. package/dist/{tool-approval-bridge-C4bTm8vu.d.ts → tool-approval-bridge-aMA79Z1B.d.ts} +1 -1
  62. package/dist/tool-reply-guidance-C3qrT1In.d.ts +25 -0
  63. package/dist/trigger/index.d.ts +2 -1
  64. package/dist/trigger/index.js +310 -108
  65. package/dist/trigger/index.js.map +1 -1
  66. package/dist/{trigger-Dn0DFiyU.d.ts → trigger-CXrbKVCL.d.ts} +2 -2
  67. package/dist/workflow/index.d.ts +2 -1
  68. package/dist/workflow/index.js +310 -108
  69. package/dist/workflow/index.js.map +1 -1
  70. package/package.json +28 -4
@@ -0,0 +1,1060 @@
1
+ // ../core/src/schemas/task.ts
2
+ import { z } from "zod";
3
+
4
+ // ../core/src/utils/safe-url.ts
5
+ var BLOCKED_HOSTNAMES = /* @__PURE__ */ new Set([
6
+ "localhost",
7
+ "metadata.google.internal",
8
+ "metadata.goog"
9
+ ]);
10
+ function normalizeHostname(hostname) {
11
+ return hostname.toLowerCase().replace(/^\[|\]$/g, "");
12
+ }
13
+ function isBlockedIpv4(host) {
14
+ const match = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(host);
15
+ if (!match) {
16
+ return false;
17
+ }
18
+ const octets = match.slice(1, 5).map((part) => Number(part));
19
+ if (octets.some((octet) => Number.isNaN(octet) || octet < 0 || octet > 255)) {
20
+ return true;
21
+ }
22
+ const [a, b, _c, _d] = octets;
23
+ if (a === void 0 || b === void 0) {
24
+ return true;
25
+ }
26
+ if (a === 127 || a === 0) return true;
27
+ if (a === 10) return true;
28
+ if (a === 169 && b === 254) return true;
29
+ if (a === 192 && b === 168) return true;
30
+ if (a === 172 && b >= 16 && b <= 31) return true;
31
+ if (a === 100 && b >= 64 && b <= 127) return true;
32
+ return false;
33
+ }
34
+ function ipv4FromNumericHost(host) {
35
+ if (/^\d+$/.test(host)) {
36
+ const num = Number(host);
37
+ if (!Number.isFinite(num) || num < 0 || num > 4294967295) {
38
+ return null;
39
+ }
40
+ const a = num >>> 24 & 255;
41
+ const b = num >>> 16 & 255;
42
+ const c = num >>> 8 & 255;
43
+ const d = num & 255;
44
+ return `${a}.${b}.${c}.${d}`;
45
+ }
46
+ const hexMatch = /^0x([0-9a-f]{1,8})$/i.exec(host);
47
+ if (hexMatch) {
48
+ const num = Number.parseInt(hexMatch[1], 16);
49
+ if (!Number.isFinite(num) || num < 0 || num > 4294967295) {
50
+ return null;
51
+ }
52
+ const a = num >>> 24 & 255;
53
+ const b = num >>> 16 & 255;
54
+ const c = num >>> 8 & 255;
55
+ const d = num & 255;
56
+ return `${a}.${b}.${c}.${d}`;
57
+ }
58
+ return null;
59
+ }
60
+ function isBlockedIpv4Mapped(host) {
61
+ const mappedDotted = /^::ffff:(\d{1,3}(?:\.\d{1,3}){3})$/i.exec(host);
62
+ if (mappedDotted) {
63
+ return isBlockedIpv4(mappedDotted[1]);
64
+ }
65
+ const mappedHex = /^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i.exec(host);
66
+ if (mappedHex) {
67
+ const high = Number.parseInt(mappedHex[1], 16);
68
+ const low = Number.parseInt(mappedHex[2], 16);
69
+ if (Number.isFinite(high) && Number.isFinite(low)) {
70
+ const a = high >> 8 & 255;
71
+ const b = high & 255;
72
+ const c = low >> 8 & 255;
73
+ const d = low & 255;
74
+ return isBlockedIpv4(`${a}.${b}.${c}.${d}`);
75
+ }
76
+ }
77
+ return false;
78
+ }
79
+ function isBlockedIpv6(host) {
80
+ if (host === "::1" || host === "0:0:0:0:0:0:0:1") {
81
+ return true;
82
+ }
83
+ if (host.startsWith("fc") || host.startsWith("fd")) {
84
+ return true;
85
+ }
86
+ if (host.startsWith("fe80:")) {
87
+ return true;
88
+ }
89
+ if (isBlockedIpv4Mapped(host)) {
90
+ return true;
91
+ }
92
+ return false;
93
+ }
94
+ function isBlockedHostname(hostname) {
95
+ const host = normalizeHostname(hostname);
96
+ if (!host) {
97
+ return true;
98
+ }
99
+ if (BLOCKED_HOSTNAMES.has(host)) {
100
+ return true;
101
+ }
102
+ if (host.endsWith(".localhost") || host.endsWith(".local")) {
103
+ return true;
104
+ }
105
+ const numericIpv4 = ipv4FromNumericHost(host);
106
+ if (numericIpv4 && isBlockedIpv4(numericIpv4)) {
107
+ return true;
108
+ }
109
+ return isBlockedIpv4(host) || isBlockedIpv6(host);
110
+ }
111
+ function isLoopbackHandlerUrl(urlString) {
112
+ let url;
113
+ try {
114
+ url = new URL(urlString);
115
+ } catch {
116
+ return false;
117
+ }
118
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
119
+ return false;
120
+ }
121
+ if (url.username || url.password) {
122
+ return false;
123
+ }
124
+ const host = url.hostname.toLowerCase();
125
+ return host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "[::1]" || host.endsWith(".localhost");
126
+ }
127
+ function isAllowedHandlerUrl(urlString) {
128
+ return isPublicHttpUrl(urlString) || isLoopbackHandlerUrl(urlString);
129
+ }
130
+ function isPublicHttpUrl(urlString) {
131
+ let url;
132
+ try {
133
+ url = new URL(urlString);
134
+ } catch {
135
+ return false;
136
+ }
137
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
138
+ return false;
139
+ }
140
+ if (url.username || url.password) {
141
+ return false;
142
+ }
143
+ return !isBlockedHostname(url.hostname);
144
+ }
145
+ var PUBLIC_HTTP_URL_ERROR = "URL must be a public http:// or https:// address";
146
+ var HANDLER_URL_ERROR = "Handler URL must be a public or loopback http:// or https:// address";
147
+
148
+ // ../core/src/schemas/context-urls.ts
149
+ function resolveLinkUrl(value) {
150
+ return value.startsWith("http://") || value.startsWith("https://") ? value : `https://${value}`;
151
+ }
152
+ function widgetType(ui, field) {
153
+ const fieldUi = ui?.[field];
154
+ if (typeof fieldUi !== "object" || fieldUi === null) {
155
+ return void 0;
156
+ }
157
+ const widget = fieldUi["ui:widget"];
158
+ return typeof widget === "string" ? widget : void 0;
159
+ }
160
+ function validateUrlValue(value, widget) {
161
+ if (widget === "image" || widget === "link") {
162
+ if (typeof value !== "string") {
163
+ return PUBLIC_HTTP_URL_ERROR;
164
+ }
165
+ const url = widget === "link" ? resolveLinkUrl(value) : value;
166
+ if (!isPublicHttpUrl(url)) {
167
+ return PUBLIC_HTTP_URL_ERROR;
168
+ }
169
+ return null;
170
+ }
171
+ if (widget === "attachments" && Array.isArray(value)) {
172
+ for (const item of value) {
173
+ if (typeof item !== "object" || item === null) {
174
+ continue;
175
+ }
176
+ const url = item.url;
177
+ if (typeof url === "string" && !isPublicHttpUrl(resolveLinkUrl(url))) {
178
+ return PUBLIC_HTTP_URL_ERROR;
179
+ }
180
+ }
181
+ }
182
+ return null;
183
+ }
184
+ function validateContextPublicUrls(context) {
185
+ if (!context?.data) {
186
+ return null;
187
+ }
188
+ for (const [field, value] of Object.entries(context.data)) {
189
+ const widget = widgetType(context.ui, field);
190
+ if (!widget) {
191
+ continue;
192
+ }
193
+ const error = validateUrlValue(value, widget);
194
+ if (error) {
195
+ return `context.data.${field}: ${error}`;
196
+ }
197
+ }
198
+ return null;
199
+ }
200
+
201
+ // ../core/src/schemas/task.ts
202
+ var safeUrlSchema = z.string().refine((url) => isPublicHttpUrl(url), {
203
+ message: PUBLIC_HTTP_URL_ERROR
204
+ });
205
+ var handlerUrlSchema = z.string().refine((url) => isAllowedHandlerUrl(url), {
206
+ message: HANDLER_URL_ERROR
207
+ });
208
+ var jsonSchema7Schema = z.custom(
209
+ (val) => typeof val === "object" && val !== null,
210
+ { message: "Must be a valid JSON Schema object" }
211
+ );
212
+ var uiSchemaSchema = z.custom((val) => typeof val === "object" && val !== null, {
213
+ message: "Must be a valid UiSchema object"
214
+ });
215
+ var webhookHandlerSchema = z.object({
216
+ type: z.literal("webhook"),
217
+ url: handlerUrlSchema,
218
+ headers: z.record(z.string(), z.string())
219
+ });
220
+ var triggerHandlerSchema = webhookHandlerSchema.extend({
221
+ type: z.literal("trigger"),
222
+ tokenId: z.string().min(1)
223
+ });
224
+ var handlerSchema = z.discriminatedUnion("type", [webhookHandlerSchema, triggerHandlerSchema]);
225
+ var taskActionInputSchema = z.object({
226
+ id: z.string().min(1),
227
+ title: z.string().min(1),
228
+ description: z.string().optional(),
229
+ schema: jsonSchema7Schema.optional(),
230
+ ui: uiSchemaSchema.optional(),
231
+ data: z.record(z.string(), z.unknown()).optional()
232
+ });
233
+ var taskActionSchema = taskActionInputSchema.extend({
234
+ // Optional handlers for this action - if present, must have at least 1
235
+ handlers: z.array(handlerSchema).min(1).optional()
236
+ });
237
+ var uiFieldSchemaSchema = z.object({
238
+ "ui:widget": z.string().optional(),
239
+ "ui:title": z.string().optional(),
240
+ "ui:description": z.string().optional(),
241
+ "ui:options": z.record(z.string(), z.unknown()).optional(),
242
+ items: z.lazy(() => z.record(z.string(), uiFieldSchemaSchema)).optional()
243
+ }).passthrough();
244
+ var contextUiSchema = z.record(z.string(), uiFieldSchemaSchema).optional();
245
+ var contextDataSchema = z.object({
246
+ data: z.record(z.string(), z.unknown()),
247
+ ui: contextUiSchema
248
+ }).optional();
249
+ var TASK_CONTEXT_FORMAT_VERSION = 2;
250
+ var taskContextObjectBaseSchema = z.object({
251
+ /** Source application id; omitted tasks are grouped in the default inbox. */
252
+ app: z.string().min(1).optional(),
253
+ type: z.string().min(1),
254
+ name: z.string().min(1),
255
+ description: z.string().optional(),
256
+ validUntil: z.string().optional(),
257
+ context: contextDataSchema,
258
+ /** Task context wire format version. @default 2 */
259
+ contextVersion: z.literal(2).optional(),
260
+ /** @deprecated Use `contextVersion`. Accepted on ingest only. */
261
+ version: z.literal(2).optional(),
262
+ actions: z.array(taskActionSchema).min(1, "At least one action is required")
263
+ });
264
+ function normalizeTaskContextVersion(data) {
265
+ const { version: legacyVersion, contextVersion, ...rest } = data;
266
+ return {
267
+ ...rest,
268
+ contextVersion: contextVersion ?? legacyVersion ?? TASK_CONTEXT_FORMAT_VERSION
269
+ };
270
+ }
271
+ var taskContextObjectSchema = taskContextObjectBaseSchema.transform(
272
+ normalizeTaskContextVersion
273
+ );
274
+ function refineContextPublicUrls(data, ctx) {
275
+ const error = validateContextPublicUrls(data.context);
276
+ if (error) {
277
+ ctx.addIssue({
278
+ code: z.ZodIssueCode.custom,
279
+ message: error,
280
+ path: ["context"]
281
+ });
282
+ }
283
+ }
284
+ var taskContextSchema = taskContextObjectSchema.superRefine(
285
+ refineContextPublicUrls
286
+ );
287
+ var assignToSchema = z.object({
288
+ users: z.array(z.string().email()).optional(),
289
+ groups: z.array(z.string().min(1)).optional()
290
+ }).refine(
291
+ (data) => {
292
+ const groups = data.groups ?? [];
293
+ if (groups.includes("all") && groups.length > 1) {
294
+ return false;
295
+ }
296
+ return true;
297
+ },
298
+ { message: 'Cannot combine "all" with other group slugs' }
299
+ );
300
+ var threadUpdateMessageSchema = z.string().min(1).max(500);
301
+ var threadUpdateStatuses = [
302
+ "info",
303
+ "queued",
304
+ "running",
305
+ "waiting",
306
+ "succeeded",
307
+ "failed",
308
+ "cancelled"
309
+ ];
310
+ var threadUpdateStatusSchema = z.enum(threadUpdateStatuses);
311
+ var threadUpdateInputSchema = z.object({
312
+ message: threadUpdateMessageSchema,
313
+ status: threadUpdateStatusSchema.optional()
314
+ });
315
+ var taskPriorities = ["low", "normal", "high", "urgent"];
316
+ var taskPrioritySchema = z.enum(taskPriorities);
317
+ var agentTelemetrySchema = z.object({
318
+ /** Agent or app version (semver, git SHA, deploy tag — caller-defined). */
319
+ version: z.string().min(1)
320
+ });
321
+ var createTaskBodySchema = taskContextObjectBaseSchema.extend({
322
+ assignTo: assignToSchema.optional(),
323
+ /**
324
+ * Groups related tasks together. When omitted, the server generates one and
325
+ * returns it so the caller can reuse it on later tasks in the same thread.
326
+ */
327
+ threadId: z.string().min(1).optional(),
328
+ /**
329
+ * Optional thread priority. When set, applies to the whole thread and
330
+ * overwrites any previous priority. Omit on later tasks to leave unchanged.
331
+ */
332
+ priority: taskPrioritySchema.optional(),
333
+ /**
334
+ * Optional initial status update logged against the task's thread. Shows in
335
+ * the inbox status bar and the thread update log.
336
+ */
337
+ update: threadUpdateInputSchema.optional(),
338
+ /** Agent release version — not shown in inbox UI. */
339
+ agent: agentTelemetrySchema.optional()
340
+ }).transform(normalizeTaskContextVersion).superRefine(refineContextPublicUrls);
341
+ var agentChatSeedActionSchema = z.object({
342
+ /** Stable action id echoed back on submit; auto-derived from title when omitted. */
343
+ id: z.string().min(1).optional(),
344
+ title: z.string().min(1),
345
+ description: z.string().optional(),
346
+ /** JSON Schema object for the form fields. */
347
+ schema: z.record(z.string(), z.unknown()).optional(),
348
+ /** RJSF ui schema overrides (ui:widget, ui:enumNames, etc.). */
349
+ ui: z.record(z.string(), z.unknown()).optional(),
350
+ /** Optional default field values. */
351
+ data: z.record(z.string(), z.unknown()).optional()
352
+ });
353
+ var agentChatSeedMessageSchema = z.object({
354
+ role: z.enum(["user", "assistant"]),
355
+ text: z.string().min(1),
356
+ /** Optional display-name override for the message sender. */
357
+ senderName: z.string().min(1).optional(),
358
+ /**
359
+ * Optional structured input request rendered as a styled RobotRock action
360
+ * widget below the message text. Use this instead of asking the user to reply
361
+ * in plain text so the request is always a proper action form.
362
+ */
363
+ requestActionInput: z.object({
364
+ prompt: z.string().optional(),
365
+ action: agentChatSeedActionSchema
366
+ }).optional()
367
+ });
368
+ var eveAgentChatTransportSchema = z.object({
369
+ kind: z.literal("eve"),
370
+ chatId: z.string().min(1),
371
+ baseUrl: z.string().url(),
372
+ sessionId: z.string().optional(),
373
+ continuationToken: z.string().optional(),
374
+ streamIndex: z.number().int().nonnegative().optional(),
375
+ isStreaming: z.boolean().optional()
376
+ });
377
+ var createAgentChatBodySchema = z.object({
378
+ /** Agent id (eve agent name). Required unless `parentChatId` is set. */
379
+ agentIdentifier: z.string().min(1).optional(),
380
+ /** Inherit tenant/connection/agent from an existing chat (agent-spawned chats). */
381
+ parentChatId: z.string().min(1).optional(),
382
+ /** Convex tenantEveConnections id; resolved from the tenant when omitted. */
383
+ eveConnectionId: z.string().min(1).optional(),
384
+ /** Source application id; groups the chat under an inbox section. */
385
+ app: z.string().min(1).optional(),
386
+ /** Email of the user who owns the chat. Required unless `parentChatId` is set. */
387
+ ownerEmail: z.string().email().optional(),
388
+ title: z.string().min(1),
389
+ messages: z.array(agentChatSeedMessageSchema).default([]),
390
+ /** Provenance label stored on the session ("cron" | "agent" | ...). */
391
+ source: z.string().min(1).optional()
392
+ }).refine((data) => Boolean(data.agentIdentifier || data.parentChatId), {
393
+ message: "Provide either agentIdentifier or parentChatId"
394
+ }).refine((data) => Boolean(data.ownerEmail || data.parentChatId), {
395
+ message: "Provide ownerEmail unless parentChatId is set"
396
+ });
397
+ var agentChatAuditToolBodySchema = z.object({
398
+ eveSessionId: z.string().min(1),
399
+ userId: z.string().min(1),
400
+ toolCallId: z.string().min(1),
401
+ toolName: z.string().min(1),
402
+ input: z.record(z.string(), z.unknown()).default({}),
403
+ success: z.boolean(),
404
+ status: z.enum(["completed", "failed", "rejected"]),
405
+ error: z.string().optional(),
406
+ idempotencyKey: z.string().optional()
407
+ });
408
+ var agentChatAuditInputBodySchema = z.object({
409
+ eveSessionId: z.string().min(1),
410
+ userId: z.string().min(1),
411
+ actionId: z.string().min(1),
412
+ actionTitle: z.string().optional(),
413
+ prompt: z.string().optional(),
414
+ data: z.record(z.string(), z.unknown()).optional(),
415
+ idempotencyKey: z.string().optional(),
416
+ /** Eve input request id — used to merge staged HITL metadata. */
417
+ requestId: z.string().optional(),
418
+ /** Eve tool call id — fallback lookup for staged HITL metadata. */
419
+ toolCallId: z.string().optional()
420
+ });
421
+ var eveHitlStagedOptionSchema = z.object({
422
+ id: z.string(),
423
+ label: z.string()
424
+ });
425
+ var agentChatStageHitlBodySchema = z.object({
426
+ eveSessionId: z.string().min(1),
427
+ requests: z.array(
428
+ z.object({
429
+ requestId: z.string().min(1),
430
+ toolCallId: z.string().min(1),
431
+ toolName: z.string().min(1),
432
+ prompt: z.string().min(1),
433
+ display: z.enum(["confirmation", "select", "text"]).optional(),
434
+ allowFreeform: z.boolean().optional(),
435
+ options: z.array(eveHitlStagedOptionSchema).optional(),
436
+ toolInput: z.record(z.string(), z.unknown()).optional()
437
+ })
438
+ )
439
+ });
440
+ var agentChatLinkTaskBodySchema = z.object({
441
+ eveSessionId: z.string().min(1),
442
+ publicTaskId: z.string().min(1),
443
+ toolCallId: z.string().min(1)
444
+ });
445
+
446
+ // ../core/src/schemas/tool-result-display.ts
447
+ import { z as z2 } from "zod";
448
+ var toolDisplayMetadataSchema = z2.object({
449
+ widget: z2.string().optional(),
450
+ title: z2.string().optional(),
451
+ description: z2.string().optional()
452
+ });
453
+ var toolDisplayEnvelopeSchema = z2.object({
454
+ display: toolDisplayMetadataSchema.optional(),
455
+ data: z2.record(z2.string(), z2.unknown()),
456
+ ui: z2.record(
457
+ z2.string(),
458
+ z2.object({
459
+ "ui:widget": z2.string().optional(),
460
+ "ui:title": z2.string().optional(),
461
+ "ui:description": z2.string().optional(),
462
+ "ui:options": z2.record(z2.string(), z2.unknown()).optional()
463
+ }).passthrough()
464
+ ).optional()
465
+ });
466
+
467
+ // ../core/src/schemas/agent-admin.ts
468
+ import { z as z3 } from "zod";
469
+ var tenantRoleSchema = z3.enum(["admin", "member"]);
470
+ var agentAdminUserSchema = z3.object({
471
+ id: z3.string(),
472
+ email: z3.string().email(),
473
+ name: z3.string()
474
+ });
475
+ var agentAdminMemberSchema = z3.object({
476
+ userId: z3.string(),
477
+ role: z3.string(),
478
+ membershipKind: z3.enum(["team", "assignee"]),
479
+ hasLoggedIn: z3.boolean(),
480
+ user: agentAdminUserSchema
481
+ });
482
+ var agentAdminGroupSchema = z3.object({
483
+ id: z3.string(),
484
+ name: z3.string(),
485
+ slug: z3.string(),
486
+ description: z3.string().nullable(),
487
+ memberCount: z3.number().optional()
488
+ });
489
+ var agentAdminGroupDetailSchema = agentAdminGroupSchema.extend({
490
+ members: z3.array(
491
+ z3.object({
492
+ userId: z3.string(),
493
+ user: agentAdminUserSchema
494
+ })
495
+ )
496
+ });
497
+ var agentAdminTaskSummarySchema = z3.object({
498
+ id: z3.string(),
499
+ convexId: z3.string(),
500
+ status: z3.string(),
501
+ type: z3.string().nullable(),
502
+ name: z3.string().nullable(),
503
+ description: z3.string().nullable(),
504
+ validUntil: z3.number(),
505
+ createdAt: z3.number(),
506
+ threadPriority: z3.string().nullable(),
507
+ handledByUserId: z3.string().nullable()
508
+ });
509
+ var inviteMemberBodySchema = z3.object({
510
+ email: z3.string().email(),
511
+ role: tenantRoleSchema.optional()
512
+ });
513
+ var updateMemberRoleBodySchema = z3.object({
514
+ role: tenantRoleSchema
515
+ });
516
+ var createGroupBodySchema = z3.object({
517
+ name: z3.string().min(1),
518
+ description: z3.string().optional()
519
+ });
520
+ var updateGroupBodySchema = z3.object({
521
+ name: z3.string().min(1).optional(),
522
+ description: z3.string().optional()
523
+ });
524
+ var addGroupMemberBodySchema = z3.object({
525
+ userId: z3.string().min(1).describe("Convex user id or member email.")
526
+ });
527
+ var listTasksQuerySchema = z3.object({
528
+ statusFilter: z3.enum(["all", "open", "handled", "expired"]).optional(),
529
+ typeFilter: z3.string().optional(),
530
+ appFilter: z3.string().optional(),
531
+ sortField: z3.enum(["type", "date", "status", "validUntil"]).optional(),
532
+ sortDirection: z3.enum(["asc", "desc"]).optional(),
533
+ limit: z3.coerce.number().int().positive().max(100).optional(),
534
+ cursor: z3.string().optional()
535
+ });
536
+ var searchTasksQuerySchema = z3.object({
537
+ q: z3.string().min(1),
538
+ limit: z3.coerce.number().int().positive().max(100).optional()
539
+ });
540
+ var assignTasksResultSchema = z3.object({
541
+ taskId: z3.string(),
542
+ success: z3.boolean(),
543
+ message: z3.string().optional(),
544
+ name: z3.string().nullable().optional(),
545
+ description: z3.string().nullable().optional(),
546
+ type: z3.string().nullable().optional()
547
+ });
548
+ var assignTasksResponseSchema = z3.object({
549
+ results: z3.array(assignTasksResultSchema)
550
+ });
551
+ var assignTasksBodySchema = z3.object({
552
+ taskIds: z3.array(z3.string().min(1)).min(1).max(100),
553
+ assignTo: assignToSchema.refine(
554
+ (value) => (value.users?.length ?? 0) > 0 || (value.groups?.length ?? 0) > 0,
555
+ { message: "assignTo needs at least one user email or group slug." }
556
+ )
557
+ });
558
+
559
+ // src/eve/tools/admin/assign-tasks.ts
560
+ import { defineTool } from "eve/tools";
561
+ import { z as z5 } from "zod";
562
+
563
+ // ../core/src/handler-retry.ts
564
+ var HANDLER_RETRY_DELAYS_MS = [
565
+ 6e4,
566
+ // 1m
567
+ 3e5,
568
+ // 5m
569
+ 18e5,
570
+ // 30m
571
+ 36e5,
572
+ // 1h
573
+ 216e5,
574
+ // 6h
575
+ 864e5,
576
+ // 24h
577
+ 1728e5
578
+ // 48h
579
+ ];
580
+ var HANDLER_MAX_ATTEMPTS = HANDLER_RETRY_DELAYS_MS.length + 1;
581
+
582
+ // ../core/src/attribution/index.ts
583
+ import { z as z4 } from "zod";
584
+
585
+ // ../core/src/app-url.ts
586
+ var PRODUCTION_APP_URL = "https://app.robotrock.io";
587
+ var PRODUCTION_API_URL = "https://api.robotrock.io/v1";
588
+ var DEV_API_URL = "http://localhost:4001/v1";
589
+ var APP_SIGNUP_URL = `${PRODUCTION_APP_URL}/sign-up`;
590
+ function normalizeRobotRockApiBaseUrl(baseUrl) {
591
+ const trimmed = baseUrl.trim().replace(/\/+$/, "");
592
+ if (trimmed.endsWith("/v1")) {
593
+ return trimmed;
594
+ }
595
+ return `${trimmed}/v1`;
596
+ }
597
+ function getRobotRockApiBaseUrl() {
598
+ const explicit = process.env.ROBOTROCK_BASE_URL?.trim() || process.env.ROBOTROCK_API_URL?.trim();
599
+ if (explicit) {
600
+ return normalizeRobotRockApiBaseUrl(explicit);
601
+ }
602
+ if (process.env.NODE_ENV === "production") {
603
+ return PRODUCTION_API_URL;
604
+ }
605
+ return DEV_API_URL;
606
+ }
607
+
608
+ // ../core/src/attribution/index.ts
609
+ var ATTRIBUTION_COOKIE_MAX_AGE = 60 * 60 * 24 * 90;
610
+ var attributionSchema = z4.object({
611
+ utmSource: z4.string().optional(),
612
+ utmMedium: z4.string().optional(),
613
+ utmCampaign: z4.string().optional(),
614
+ utmContent: z4.string().optional(),
615
+ utmTerm: z4.string().optional(),
616
+ gclid: z4.string().optional(),
617
+ landingUrl: z4.string().optional(),
618
+ referrer: z4.string().optional(),
619
+ capturedAt: z4.number()
620
+ });
621
+
622
+ // src/auth-headers.ts
623
+ var ROBOTROCK_ACTING_USER_ID_HEADER = "x-robotrock-acting-user-id";
624
+ function buildRobotRockAuthHeaders(auth) {
625
+ if (auth.kind === "apiKey") {
626
+ const headers2 = {
627
+ "X-Api-Key": auth.apiKey
628
+ };
629
+ if (auth.actingUserId?.trim()) {
630
+ headers2[ROBOTROCK_ACTING_USER_ID_HEADER] = auth.actingUserId.trim();
631
+ }
632
+ return headers2;
633
+ }
634
+ const headers = {
635
+ Authorization: `Bearer ${auth.token}`,
636
+ "X-RobotRock-Tenant-Slug": auth.tenantSlug,
637
+ "X-RobotRock-Connection-Id": auth.connectionId
638
+ };
639
+ if (auth.actingUserId?.trim()) {
640
+ headers[ROBOTROCK_ACTING_USER_ID_HEADER] = auth.actingUserId.trim();
641
+ }
642
+ return headers;
643
+ }
644
+ function resolveRobotRockAuthConfig(overrides) {
645
+ if (overrides?.agentService) {
646
+ return {
647
+ kind: "agentService",
648
+ ...overrides.agentService
649
+ };
650
+ }
651
+ const apiKey = overrides?.apiKey ?? process.env.ROBOTROCK_API_KEY;
652
+ if (!apiKey) {
653
+ throw new Error(
654
+ "RobotRock auth is required. Set ROBOTROCK_API_KEY, ROBOTROCK_AGENT_SERVICE_TOKEN with tenant context, or pass auth when creating the client."
655
+ );
656
+ }
657
+ return { kind: "apiKey", apiKey };
658
+ }
659
+
660
+ // src/http.ts
661
+ var RobotRockError = class extends Error {
662
+ constructor(message, statusCode, response) {
663
+ super(message);
664
+ this.statusCode = statusCode;
665
+ this.response = response;
666
+ this.name = "RobotRockError";
667
+ }
668
+ };
669
+ async function parseResponseBody(response) {
670
+ const contentType = response.headers.get("content-type") ?? "";
671
+ const bodyText = await response.text();
672
+ if (!bodyText) {
673
+ return null;
674
+ }
675
+ if (contentType.toLowerCase().includes("application/json")) {
676
+ try {
677
+ return JSON.parse(bodyText);
678
+ } catch {
679
+ }
680
+ }
681
+ try {
682
+ return JSON.parse(bodyText);
683
+ } catch {
684
+ return bodyText;
685
+ }
686
+ }
687
+ function getErrorMessage(data, fallback) {
688
+ if (data && typeof data === "object" && !Array.isArray(data)) {
689
+ const record = data;
690
+ const maybeMessage = record.message;
691
+ const maybeHint = record.hint;
692
+ if (typeof maybeMessage === "string" && maybeMessage.trim()) {
693
+ if (typeof maybeHint === "string" && maybeHint.trim()) {
694
+ return `${maybeMessage.trim()} ${maybeHint.trim()}`;
695
+ }
696
+ return maybeMessage;
697
+ }
698
+ }
699
+ if (typeof data === "string" && data.trim()) {
700
+ const compact = data.replace(/\s+/g, " ").trim();
701
+ const snippet = compact.length > 180 ? `${compact.slice(0, 180)}...` : compact;
702
+ return `${fallback}. Server returned non-JSON response: ${snippet}`;
703
+ }
704
+ return fallback;
705
+ }
706
+
707
+ // src/eve/agent/attributes.ts
708
+ function readStringAttribute(attributes, key) {
709
+ const value = attributes?.[key];
710
+ if (typeof value === "string" && value.length > 0) {
711
+ return value;
712
+ }
713
+ if (Array.isArray(value) && typeof value[0] === "string" && value[0].length > 0) {
714
+ return value[0];
715
+ }
716
+ return void 0;
717
+ }
718
+ function readStringArrayAttribute(attributes, key) {
719
+ const value = attributes?.[key];
720
+ if (typeof value === "string" && value.length > 0) {
721
+ return [value];
722
+ }
723
+ if (Array.isArray(value)) {
724
+ return value.filter(
725
+ (entry) => typeof entry === "string" && entry.length > 0
726
+ );
727
+ }
728
+ return [];
729
+ }
730
+ function parseTenantRole(value) {
731
+ if (value === "admin" || value === "member") {
732
+ return value;
733
+ }
734
+ return null;
735
+ }
736
+
737
+ // src/eve/agent/tenant.ts
738
+ function tryResolveTenantCaller(ctx) {
739
+ const caller = ctx.session.auth.initiator ?? ctx.session.auth.current;
740
+ if (caller?.principalType !== "user") {
741
+ return null;
742
+ }
743
+ const email = readStringAttribute(caller.attributes, "email");
744
+ const name = readStringAttribute(caller.attributes, "name");
745
+ const tenantSlug = readStringAttribute(caller.attributes, "tenantSlug") ?? readStringAttribute(caller.attributes, "tenantId");
746
+ const role = parseTenantRole(readStringAttribute(caller.attributes, "role"));
747
+ if (!email || !tenantSlug || !caller.principalId || !role) {
748
+ return null;
749
+ }
750
+ const workosUserId = readStringAttribute(caller.attributes, "workosUserId");
751
+ const connectionId = readStringAttribute(caller.attributes, "connectionId");
752
+ const groups = readStringArrayAttribute(caller.attributes, "groups");
753
+ return {
754
+ userId: caller.principalId,
755
+ email,
756
+ name: name ?? email.split("@")[0] ?? email,
757
+ tenantSlug,
758
+ ...connectionId ? { connectionId } : {},
759
+ role,
760
+ isAdmin: role === "admin",
761
+ groups,
762
+ ...workosUserId ? { workosUserId } : {}
763
+ };
764
+ }
765
+ function requireTenantCaller(ctx) {
766
+ const caller = tryResolveTenantCaller(ctx);
767
+ if (!caller) {
768
+ throw new Error("An authenticated RobotRock tenant user is required.");
769
+ }
770
+ return caller;
771
+ }
772
+
773
+ // src/agent-admin.ts
774
+ async function agentAdminFetch(config, path, init) {
775
+ const baseUrl = (config.baseUrl?.trim() || getRobotRockApiBaseUrl()).replace(
776
+ /\/+$/,
777
+ ""
778
+ );
779
+ const url = `${baseUrl}/agent-admin${path}`;
780
+ const response = await fetch(url, {
781
+ ...init,
782
+ headers: {
783
+ "Content-Type": "application/json",
784
+ ...buildRobotRockAuthHeaders(config.auth),
785
+ ...init?.headers ?? {}
786
+ }
787
+ });
788
+ const data = await parseResponseBody(response);
789
+ if (!response.ok) {
790
+ throw new RobotRockError(
791
+ getErrorMessage(data, `Agent admin request failed (${response.status})`),
792
+ response.status,
793
+ data
794
+ );
795
+ }
796
+ return data;
797
+ }
798
+ function createAgentAdminApi(config) {
799
+ return {
800
+ members: {
801
+ list: () => agentAdminFetch(config, "/members"),
802
+ get: (memberRef) => agentAdminFetch(config, `/members/${encodeURIComponent(memberRef)}`),
803
+ invite: (body) => agentAdminFetch(config, "/members", {
804
+ method: "POST",
805
+ body: JSON.stringify(body)
806
+ }),
807
+ updateRole: (memberRef, role) => agentAdminFetch(
808
+ config,
809
+ `/members/${encodeURIComponent(memberRef)}/role`,
810
+ {
811
+ method: "PATCH",
812
+ body: JSON.stringify({ role })
813
+ }
814
+ ),
815
+ remove: (memberId) => agentAdminFetch(
816
+ config,
817
+ `/members/${encodeURIComponent(memberId)}`,
818
+ {
819
+ method: "DELETE"
820
+ }
821
+ )
822
+ },
823
+ groups: {
824
+ list: () => agentAdminFetch(config, "/groups"),
825
+ get: (groupId) => agentAdminFetch(
826
+ config,
827
+ `/groups/${encodeURIComponent(groupId)}`
828
+ ),
829
+ create: (body) => agentAdminFetch(config, "/groups", {
830
+ method: "POST",
831
+ body: JSON.stringify(body)
832
+ }),
833
+ update: (groupId, body) => agentAdminFetch(
834
+ config,
835
+ `/groups/${encodeURIComponent(groupId)}`,
836
+ {
837
+ method: "PATCH",
838
+ body: JSON.stringify(body)
839
+ }
840
+ ),
841
+ delete: (groupId) => agentAdminFetch(
842
+ config,
843
+ `/groups/${encodeURIComponent(groupId)}`,
844
+ {
845
+ method: "DELETE"
846
+ }
847
+ ),
848
+ addMember: (groupRef, memberRef) => agentAdminFetch(
849
+ config,
850
+ `/groups/${encodeURIComponent(groupRef)}/members`,
851
+ {
852
+ method: "POST",
853
+ body: JSON.stringify({ userId: memberRef })
854
+ }
855
+ ),
856
+ removeMember: (groupRef, memberRef) => agentAdminFetch(
857
+ config,
858
+ `/groups/${encodeURIComponent(groupRef)}/members/${encodeURIComponent(memberRef)}`,
859
+ { method: "DELETE" }
860
+ )
861
+ },
862
+ tasks: {
863
+ list: (query) => {
864
+ const params = new URLSearchParams();
865
+ for (const [key, value] of Object.entries(query ?? {})) {
866
+ if (value !== void 0 && value !== "") {
867
+ params.set(key, String(value));
868
+ }
869
+ }
870
+ const suffix = params.size > 0 ? `?${params.toString()}` : "";
871
+ return agentAdminFetch(
872
+ config,
873
+ `/tasks${suffix}`
874
+ );
875
+ },
876
+ search: (q, limit) => {
877
+ const params = new URLSearchParams({ q });
878
+ if (limit !== void 0) {
879
+ params.set("limit", String(limit));
880
+ }
881
+ return agentAdminFetch(
882
+ config,
883
+ `/tasks/search?${params.toString()}`
884
+ );
885
+ },
886
+ get: (taskId) => agentAdminFetch(config, `/tasks/${taskId}`),
887
+ assign: (body) => agentAdminFetch(config, "/tasks/assign", {
888
+ method: "POST",
889
+ body: JSON.stringify(body)
890
+ })
891
+ }
892
+ };
893
+ }
894
+ function createBoundAgentAdminClient(ctx) {
895
+ const caller = requireTenantCaller(ctx);
896
+ const baseUrl = process.env.ROBOTROCK_BASE_URL?.trim();
897
+ const serviceToken = process.env.ROBOTROCK_AGENT_SERVICE_TOKEN?.trim();
898
+ if (caller.connectionId && serviceToken) {
899
+ return createAgentAdminApi({
900
+ baseUrl,
901
+ auth: resolveRobotRockAuthConfig({
902
+ agentService: {
903
+ token: serviceToken,
904
+ tenantSlug: caller.tenantSlug,
905
+ connectionId: caller.connectionId,
906
+ actingUserId: caller.userId
907
+ }
908
+ })
909
+ });
910
+ }
911
+ const apiKey = process.env.ROBOTROCK_API_KEY?.trim();
912
+ if (apiKey) {
913
+ return createAgentAdminApi({
914
+ baseUrl,
915
+ auth: {
916
+ kind: "apiKey",
917
+ apiKey,
918
+ actingUserId: caller.userId
919
+ }
920
+ });
921
+ }
922
+ throw new Error(
923
+ "Agent admin auth is unset. Set ROBOTROCK_AGENT_SERVICE_TOKEN for hosted multi-tenant agents, or ROBOTROCK_API_KEY for self-hosted and localhost deployments."
924
+ );
925
+ }
926
+
927
+ // src/eve/tool-result-display.ts
928
+ function toolDisplayResult(data, options) {
929
+ const display = options?.widget || options?.title || options?.description ? {
930
+ ...options.widget ? { widget: options.widget } : {},
931
+ ...options.title ? { title: options.title } : {},
932
+ ...options.description ? { description: options.description } : {}
933
+ } : void 0;
934
+ return {
935
+ ...display ? { display } : {},
936
+ data,
937
+ ...options?.ui ? { ui: options.ui } : {}
938
+ };
939
+ }
940
+
941
+ // src/eve/tool-reply-guidance.ts
942
+ var TOOL_REPLY_GUIDANCE_FIELD = "replyGuidance";
943
+ var ASSIGN_TASKS_REPLY_GUIDANCE = "Reassignment results render in chat UI. Do not restate task ids or assignee emails from the card. Only mention failures, partial success, or next steps.";
944
+ function withReplyGuidance(result, guidance) {
945
+ return {
946
+ ...result,
947
+ [TOOL_REPLY_GUIDANCE_FIELD]: guidance
948
+ };
949
+ }
950
+
951
+ // src/eve/tool-display-format.ts
952
+ function formatToolObjectResult(data, options) {
953
+ return withReplyGuidance(
954
+ toolDisplayResult(data, {
955
+ title: options.title,
956
+ description: options.description,
957
+ ui: options.ui
958
+ }),
959
+ options.replyGuidance
960
+ );
961
+ }
962
+ function formatToolListResult(listKey, items, options) {
963
+ const listFieldUi = options.itemWidget ? {
964
+ "ui:widget": "list",
965
+ items: {
966
+ "ui:widget": options.itemWidget,
967
+ ...options.itemUi ?? {}
968
+ }
969
+ } : {
970
+ "ui:widget": "table",
971
+ ...options.itemUi ? { items: options.itemUi } : {}
972
+ };
973
+ return formatToolObjectResult(
974
+ { [listKey]: items },
975
+ {
976
+ title: options.title,
977
+ ui: {
978
+ [listKey]: listFieldUi
979
+ },
980
+ replyGuidance: options.replyGuidance
981
+ }
982
+ );
983
+ }
984
+
985
+ // src/eve/tools/admin/format-tasks-list.ts
986
+ function resolveTaskCardLabel(task) {
987
+ return task.name?.trim() || task.description?.trim() || task.type?.trim() || task.id?.trim() || "Untitled task";
988
+ }
989
+ function formatAssignTasksResult(results, _assignTo) {
990
+ const succeeded = results.filter((row) => row.success).length;
991
+ const title = succeeded === results.length ? `${succeeded === 1 ? "1 task" : `${succeeded} tasks`} reassigned` : `${succeeded}/${results.length} tasks reassigned`;
992
+ return formatToolListResult(
993
+ "results",
994
+ results.map((row) => ({
995
+ id: row.taskId,
996
+ name: resolveTaskCardLabel({
997
+ name: row.name,
998
+ description: row.description,
999
+ type: row.type,
1000
+ id: row.taskId
1001
+ }),
1002
+ type: row.type ?? null,
1003
+ description: row.description ?? null,
1004
+ status: row.success ? "reassigned" : "failed"
1005
+ })),
1006
+ {
1007
+ title,
1008
+ itemWidget: "tenantTask",
1009
+ replyGuidance: ASSIGN_TASKS_REPLY_GUIDANCE
1010
+ }
1011
+ );
1012
+ }
1013
+
1014
+ // src/eve/tools/admin/assign-tasks.ts
1015
+ var ASSIGN_TASKS_TOOL_NAME = "assign_tasks";
1016
+ var assignTasksInputSchema = z5.object({
1017
+ taskIds: z5.array(z5.string().min(1)).min(1).max(100).describe(
1018
+ "Public task ids or Convex tasks table ids to reassign. Use query_tasks search/get to resolve ids first."
1019
+ ),
1020
+ assignTo: assignToSchema.refine(
1021
+ (value) => (value.users?.length ?? 0) > 0 || (value.groups?.length ?? 0) > 0,
1022
+ { message: "assignTo needs at least one user email or group slug." }
1023
+ ).describe(
1024
+ 'New assignees \u2014 user emails and/or group slugs (e.g. "finance", virtual "admins").'
1025
+ )
1026
+ });
1027
+ function defineAssignTasksTool() {
1028
+ return defineTool({
1029
+ description: "Reassign existing inbox tasks to users or groups. Requires access to each task (tenant admins can reassign any task; others only tasks they can see). Use query_tasks to find task ids when needed. Results render as chat UI \u2014 do not restate task ids or assignees in your reply.",
1030
+ inputSchema: assignTasksInputSchema,
1031
+ async execute(input, ctx) {
1032
+ const api = createBoundAgentAdminClient(ctx);
1033
+ try {
1034
+ const result = await api.tasks.assign({
1035
+ taskIds: input.taskIds,
1036
+ assignTo: input.assignTo
1037
+ });
1038
+ return formatAssignTasksResult(result.results, input.assignTo);
1039
+ } catch (error) {
1040
+ if (error instanceof RobotRockError) {
1041
+ return {
1042
+ ok: false,
1043
+ status: error.statusCode,
1044
+ message: error.message,
1045
+ response: error.response
1046
+ };
1047
+ }
1048
+ throw error;
1049
+ }
1050
+ }
1051
+ });
1052
+ }
1053
+ var assignTasksTool = defineAssignTasksTool();
1054
+ export {
1055
+ ASSIGN_TASKS_TOOL_NAME,
1056
+ assignTasksInputSchema,
1057
+ assignTasksTool,
1058
+ defineAssignTasksTool
1059
+ };
1060
+ //# sourceMappingURL=assign-tasks.js.map