robotrock 1.3.1 → 1.3.3

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 (59) hide show
  1. package/dist/agent-admin.d.ts +2 -1
  2. package/dist/agent-admin.js +44 -0
  3. package/dist/agent-admin.js.map +1 -1
  4. package/dist/ai/index.d.ts +6 -6
  5. package/dist/ai/index.js +34 -2
  6. package/dist/ai/index.js.map +1 -1
  7. package/dist/ai/trigger.d.ts +4 -4
  8. package/dist/ai/trigger.js +34 -2
  9. package/dist/ai/trigger.js.map +1 -1
  10. package/dist/ai/workflow.d.ts +4 -4
  11. package/dist/ai/workflow.js +34 -2
  12. package/dist/ai/workflow.js.map +1 -1
  13. package/dist/{auth-headers-qL-ZeEtd.d.ts → chat-correlation-BsHD-tOQ.d.ts} +6 -1
  14. package/dist/{client-YO9Y1rkH.d.ts → client-CZ5eWH5v.d.ts} +6 -1
  15. package/dist/eve/agent/index.d.ts +69 -6
  16. package/dist/eve/agent/index.js +165 -238
  17. package/dist/eve/agent/index.js.map +1 -1
  18. package/dist/eve/index.d.ts +3 -3
  19. package/dist/eve/index.js +1 -26
  20. package/dist/eve/index.js.map +1 -1
  21. package/dist/eve/tools/admin/assign-tasks.js +44 -0
  22. package/dist/eve/tools/admin/assign-tasks.js.map +1 -1
  23. package/dist/eve/tools/admin/manage-groups.js +44 -0
  24. package/dist/eve/tools/admin/manage-groups.js.map +1 -1
  25. package/dist/eve/tools/admin/manage-team-members.js +44 -0
  26. package/dist/eve/tools/admin/manage-team-members.js.map +1 -1
  27. package/dist/eve/tools/admin/query-tasks.js +44 -0
  28. package/dist/eve/tools/admin/query-tasks.js.map +1 -1
  29. package/dist/eve/tools/identity/index.d.ts +1 -1
  30. package/dist/eve/tools/identity/index.js +2 -0
  31. package/dist/eve/tools/identity/index.js.map +1 -1
  32. package/dist/eve/tools/identity/my-access.js +2 -0
  33. package/dist/eve/tools/identity/my-access.js.map +1 -1
  34. package/dist/eve/tools/identity/whoami.d.ts +1 -1
  35. package/dist/eve/tools/identity/whoami.js +2 -0
  36. package/dist/eve/tools/identity/whoami.js.map +1 -1
  37. package/dist/eve/tools/inbox/create-task.d.ts +1 -1
  38. package/dist/eve/tools/inbox/create-task.js +56 -31
  39. package/dist/eve/tools/inbox/create-task.js.map +1 -1
  40. package/dist/eve/tools/inbox/index.d.ts +1 -1
  41. package/dist/eve/tools/inbox/index.js +56 -31
  42. package/dist/eve/tools/inbox/index.js.map +1 -1
  43. package/dist/eve/tools/index.d.ts +1 -1
  44. package/dist/eve/tools/index.js +68 -31
  45. package/dist/eve/tools/index.js.map +1 -1
  46. package/dist/{index-DoQN48Bm.d.ts → index-DePyAbTI.d.ts} +6 -3
  47. package/dist/index.d.ts +4 -4
  48. package/dist/index.js +26 -2
  49. package/dist/index.js.map +1 -1
  50. package/dist/{tenant-5YKDrdC-.d.ts → tenant-DmN0MMyC.d.ts} +1 -0
  51. package/dist/{tool-approval-bridge-aMA79Z1B.d.ts → tool-approval-bridge-DnGaRES4.d.ts} +1 -1
  52. package/dist/trigger/index.d.ts +2 -2
  53. package/dist/trigger/index.js +26 -2
  54. package/dist/trigger/index.js.map +1 -1
  55. package/dist/{trigger-CXrbKVCL.d.ts → trigger--qTIK0s6.d.ts} +2 -2
  56. package/dist/workflow/index.d.ts +2 -2
  57. package/dist/workflow/index.js +26 -2
  58. package/dist/workflow/index.js.map +1 -1
  59. package/package.json +1 -1
@@ -10,7 +10,7 @@ export { ASSIGN_TASKS_TOOL_NAME, assignTasksInputSchema, assignTasksTool, define
10
10
  import 'eve/tools';
11
11
  import '../../tool-reply-guidance-C3qrT1In.js';
12
12
  import 'zod';
13
- import '../../tenant-5YKDrdC-.js';
13
+ import '../../tenant-DmN0MMyC.js';
14
14
  import 'eve/context';
15
15
  import '@robotrock/core';
16
16
 
@@ -868,11 +868,42 @@ function resolveRobotRockAuthConfig(overrides) {
868
868
  return { kind: "apiKey", apiKey };
869
869
  }
870
870
 
871
+ // src/chat-correlation.ts
872
+ var ROBOTROCK_CHAT_ID_HEADER = "x-robotrock-chat-id";
873
+ var ROBOTROCK_EVE_SESSION_ID_HEADER = "x-robotrock-eve-session-id";
874
+ function resolveChatCorrelationFromEnv() {
875
+ const chatId = process.env.ROBOTROCK_CHAT_ID?.trim();
876
+ const eveSessionId = process.env.ROBOTROCK_EVE_SESSION_ID?.trim();
877
+ if (!chatId && !eveSessionId) {
878
+ return void 0;
879
+ }
880
+ return {
881
+ ...chatId ? { chatId } : {},
882
+ ...eveSessionId ? { eveSessionId } : {}
883
+ };
884
+ }
885
+ function buildChatCorrelationHeaders(correlation) {
886
+ if (!correlation) {
887
+ return {};
888
+ }
889
+ const headers = {};
890
+ const chatId = correlation.chatId?.trim();
891
+ const eveSessionId = correlation.eveSessionId?.trim();
892
+ if (chatId) {
893
+ headers[ROBOTROCK_CHAT_ID_HEADER] = chatId;
894
+ }
895
+ if (eveSessionId) {
896
+ headers[ROBOTROCK_EVE_SESSION_ID_HEADER] = eveSessionId;
897
+ }
898
+ return headers;
899
+ }
900
+
871
901
  // src/chats.ts
872
902
  function createChatsApi(config) {
873
903
  const headers = () => ({
874
904
  "Content-Type": "application/json",
875
- ...buildRobotRockAuthHeaders(config.auth)
905
+ ...buildRobotRockAuthHeaders(config.auth),
906
+ ...buildChatCorrelationHeaders(config.chatCorrelation)
876
907
  });
877
908
  return {
878
909
  async create(input) {
@@ -1082,6 +1113,7 @@ function serializeValidUntil(value) {
1082
1113
  }
1083
1114
  var RobotRock = class {
1084
1115
  auth;
1116
+ chatCorrelation;
1085
1117
  baseUrl;
1086
1118
  app;
1087
1119
  agentVersion;
@@ -1109,6 +1141,7 @@ var RobotRock = class {
1109
1141
  ...apiKey ? { apiKey } : {},
1110
1142
  ...agentService ? { agentService } : {}
1111
1143
  });
1144
+ this.chatCorrelation = config.chatCorrelation;
1112
1145
  this.baseUrl = config.baseUrl ?? getRobotRockApiBaseUrl();
1113
1146
  this.app = config.app;
1114
1147
  this.agentVersion = config.version ?? resolveAgentVersionFromEnv();
@@ -1126,13 +1159,15 @@ var RobotRock = class {
1126
1159
  this.chats = createChatsApi({
1127
1160
  baseUrl: this.baseUrl,
1128
1161
  auth: this.auth,
1129
- app: this.app
1162
+ app: this.app,
1163
+ chatCorrelation: this.chatCorrelation
1130
1164
  });
1131
1165
  }
1132
1166
  authHeaders(extra) {
1133
1167
  return {
1134
1168
  "Content-Type": "application/json",
1135
1169
  ...buildRobotRockAuthHeaders(this.auth),
1170
+ ...buildChatCorrelationHeaders(this.chatCorrelation),
1136
1171
  ...extra
1137
1172
  };
1138
1173
  }
@@ -1403,28 +1438,6 @@ function normalizeSendToHumanInput(task, clientDefaults) {
1403
1438
  };
1404
1439
  }
1405
1440
 
1406
- // src/env.ts
1407
- function resolveRobotRockConfig(overrides) {
1408
- const agentService = overrides?.agentService;
1409
- const apiKey = overrides?.apiKey ?? process.env.ROBOTROCK_API_KEY;
1410
- if (agentService && apiKey) {
1411
- throw new Error(
1412
- "RobotRock client cannot configure both apiKey and agentService."
1413
- );
1414
- }
1415
- const baseUrl = overrides?.baseUrl ?? getRobotRockApiBaseUrl();
1416
- const app = overrides?.app ?? process.env.ROBOTROCK_APP;
1417
- if (agentService) {
1418
- return app ? { agentService, baseUrl, app } : { agentService, baseUrl };
1419
- }
1420
- if (!apiKey) {
1421
- throw new Error(
1422
- "RobotRock API key is required. Set ROBOTROCK_API_KEY or pass agentService when creating the client."
1423
- );
1424
- }
1425
- return app ? { apiKey, baseUrl, app } : { apiKey, baseUrl };
1426
- }
1427
-
1428
1441
  // src/eve/agent/attributes.ts
1429
1442
  function readStringAttribute(attributes, key) {
1430
1443
  const value = attributes?.[key];
@@ -1470,6 +1483,7 @@ function tryResolveTenantCaller(ctx) {
1470
1483
  }
1471
1484
  const workosUserId = readStringAttribute(caller.attributes, "workosUserId");
1472
1485
  const connectionId = readStringAttribute(caller.attributes, "connectionId");
1486
+ const chatId = readStringAttribute(caller.attributes, "chatId");
1473
1487
  const groups = readStringArrayAttribute(caller.attributes, "groups");
1474
1488
  return {
1475
1489
  userId: caller.principalId,
@@ -1477,6 +1491,7 @@ function tryResolveTenantCaller(ctx) {
1477
1491
  name: name ?? email.split("@")[0] ?? email,
1478
1492
  tenantSlug,
1479
1493
  ...connectionId ? { connectionId } : {},
1494
+ ...chatId ? { chatId } : {},
1480
1495
  role,
1481
1496
  isAdmin: role === "admin",
1482
1497
  groups,
@@ -1500,27 +1515,37 @@ function requireAdminCaller(ctx) {
1500
1515
 
1501
1516
  // src/eve/agent/client-from-session.ts
1502
1517
  var warnedMissingAuth = false;
1518
+ function resolveBoundChatCorrelation(ctx) {
1519
+ const caller = tryResolveTenantCaller(ctx);
1520
+ return {
1521
+ eveSessionId: ctx.session.id,
1522
+ ...caller?.chatId ? { chatId: caller.chatId } : {},
1523
+ ...resolveChatCorrelationFromEnv()
1524
+ };
1525
+ }
1503
1526
  function tryCreateBoundRobotRockClient(ctx) {
1504
1527
  const caller = tryResolveTenantCaller(ctx);
1505
1528
  const serviceToken = process.env.ROBOTROCK_AGENT_SERVICE_TOKEN?.trim();
1529
+ const chatCorrelation = resolveBoundChatCorrelation(ctx);
1506
1530
  if (caller?.connectionId && serviceToken) {
1507
1531
  return createClient({
1508
1532
  baseUrl: process.env.ROBOTROCK_BASE_URL?.trim(),
1533
+ chatCorrelation,
1509
1534
  agentService: {
1510
1535
  token: serviceToken,
1511
1536
  tenantSlug: caller.tenantSlug,
1512
- connectionId: caller.connectionId
1537
+ connectionId: caller.connectionId,
1538
+ actingUserId: caller.userId
1513
1539
  }
1514
1540
  });
1515
1541
  }
1516
1542
  const apiKey = process.env.ROBOTROCK_API_KEY?.trim();
1517
1543
  if (apiKey) {
1518
- return createClient(
1519
- resolveRobotRockConfig({
1520
- apiKey,
1521
- baseUrl: process.env.ROBOTROCK_BASE_URL?.trim()
1522
- })
1523
- );
1544
+ return createClient({
1545
+ apiKey,
1546
+ baseUrl: process.env.ROBOTROCK_BASE_URL?.trim(),
1547
+ chatCorrelation
1548
+ });
1524
1549
  }
1525
1550
  if (!warnedMissingAuth) {
1526
1551
  warnedMissingAuth = true;
@@ -2043,6 +2068,7 @@ async function agentAdminFetch(config, path, init) {
2043
2068
  headers: {
2044
2069
  "Content-Type": "application/json",
2045
2070
  ...buildRobotRockAuthHeaders(config.auth),
2071
+ ...buildChatCorrelationHeaders(config.chatCorrelation),
2046
2072
  ...init?.headers ?? {}
2047
2073
  }
2048
2074
  });
@@ -2152,13 +2178,23 @@ function createAgentAdminApi(config) {
2152
2178
  }
2153
2179
  };
2154
2180
  }
2181
+ function resolveBoundChatCorrelation2(ctx) {
2182
+ const caller = tryResolveTenantCaller(ctx);
2183
+ return {
2184
+ eveSessionId: ctx.session.id,
2185
+ ...caller?.chatId ? { chatId: caller.chatId } : {},
2186
+ ...resolveChatCorrelationFromEnv()
2187
+ };
2188
+ }
2155
2189
  function createBoundAgentAdminClient(ctx) {
2156
2190
  const caller = requireTenantCaller(ctx);
2157
2191
  const baseUrl = process.env.ROBOTROCK_BASE_URL?.trim();
2158
2192
  const serviceToken = process.env.ROBOTROCK_AGENT_SERVICE_TOKEN?.trim();
2193
+ const chatCorrelation = resolveBoundChatCorrelation2(ctx);
2159
2194
  if (caller.connectionId && serviceToken) {
2160
2195
  return createAgentAdminApi({
2161
2196
  baseUrl,
2197
+ chatCorrelation,
2162
2198
  auth: resolveRobotRockAuthConfig({
2163
2199
  agentService: {
2164
2200
  token: serviceToken,
@@ -2173,6 +2209,7 @@ function createBoundAgentAdminClient(ctx) {
2173
2209
  if (apiKey) {
2174
2210
  return createAgentAdminApi({
2175
2211
  baseUrl,
2212
+ chatCorrelation,
2176
2213
  auth: {
2177
2214
  kind: "apiKey",
2178
2215
  apiKey,