robotrock 1.1.0 → 1.3.1

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 (71) hide show
  1. package/README.md +2 -2
  2. package/dist/agent-admin.d.ts +82 -0
  3. package/dist/agent-admin.js +938 -0
  4. package/dist/agent-admin.js.map +1 -0
  5. package/dist/ai/index.d.ts +6 -5
  6. package/dist/ai/index.js +407 -188
  7. package/dist/ai/index.js.map +1 -1
  8. package/dist/ai/trigger.d.ts +4 -3
  9. package/dist/ai/trigger.js +407 -188
  10. package/dist/ai/trigger.js.map +1 -1
  11. package/dist/ai/workflow.d.ts +4 -3
  12. package/dist/ai/workflow.js +404 -185
  13. package/dist/ai/workflow.js.map +1 -1
  14. package/dist/auth-headers-qL-ZeEtd.d.ts +13 -0
  15. package/dist/{client-XTnFHGFE.d.ts → client-YO9Y1rkH.d.ts} +29 -17
  16. package/dist/eve/agent/index.d.ts +11 -35
  17. package/dist/eve/agent/index.js +678 -146
  18. package/dist/eve/agent/index.js.map +1 -1
  19. package/dist/eve/index.d.ts +5 -2
  20. package/dist/eve/index.js +195 -2
  21. package/dist/eve/index.js.map +1 -1
  22. package/dist/eve/tools/admin/assign-tasks.d.ts +39 -0
  23. package/dist/eve/tools/admin/assign-tasks.js +1060 -0
  24. package/dist/eve/tools/admin/assign-tasks.js.map +1 -0
  25. package/dist/eve/tools/admin/manage-groups.d.ts +53 -0
  26. package/dist/eve/tools/admin/manage-groups.js +1218 -0
  27. package/dist/eve/tools/admin/manage-groups.js.map +1 -0
  28. package/dist/eve/tools/admin/manage-team-members.d.ts +45 -0
  29. package/dist/eve/tools/admin/manage-team-members.js +1160 -0
  30. package/dist/eve/tools/admin/manage-team-members.js.map +1 -0
  31. package/dist/eve/tools/admin/query-tasks.d.ts +71 -0
  32. package/dist/eve/tools/admin/query-tasks.js +1161 -0
  33. package/dist/eve/tools/admin/query-tasks.js.map +1 -0
  34. package/dist/eve/tools/catalog/search-products.d.ts +57 -0
  35. package/dist/eve/tools/catalog/search-products.js +94 -0
  36. package/dist/eve/tools/catalog/search-products.js.map +1 -0
  37. package/dist/eve/tools/identity/index.d.ts +2 -0
  38. package/dist/eve/tools/identity/index.js +117 -27
  39. package/dist/eve/tools/identity/index.js.map +1 -1
  40. package/dist/eve/tools/identity/my-access.d.ts +6 -46
  41. package/dist/eve/tools/identity/my-access.js +91 -10
  42. package/dist/eve/tools/identity/my-access.js.map +1 -1
  43. package/dist/eve/tools/identity/whoami.d.ts +7 -8
  44. package/dist/eve/tools/identity/whoami.js +33 -17
  45. package/dist/eve/tools/identity/whoami.js.map +1 -1
  46. package/dist/eve/tools/inbox/create-task.d.ts +5 -4
  47. package/dist/eve/tools/inbox/create-task.js +365 -137
  48. package/dist/eve/tools/inbox/create-task.js.map +1 -1
  49. package/dist/eve/tools/inbox/index.d.ts +1 -0
  50. package/dist/eve/tools/inbox/index.js +365 -137
  51. package/dist/eve/tools/inbox/index.js.map +1 -1
  52. package/dist/eve/tools/index.d.ts +7 -0
  53. package/dist/eve/tools/index.js +1362 -168
  54. package/dist/eve/tools/index.js.map +1 -1
  55. package/dist/{index-BL9qKHA8.d.ts → index-DoQN48Bm.d.ts} +61 -2
  56. package/dist/index.d.ts +6 -3
  57. package/dist/index.js +325 -119
  58. package/dist/index.js.map +1 -1
  59. package/dist/schemas/index.d.ts +6 -1
  60. package/dist/schemas/index.js +177 -48
  61. package/dist/schemas/index.js.map +1 -1
  62. package/dist/{tool-approval-bridge-C4bTm8vu.d.ts → tool-approval-bridge-aMA79Z1B.d.ts} +1 -1
  63. package/dist/tool-reply-guidance-C3qrT1In.d.ts +25 -0
  64. package/dist/trigger/index.d.ts +2 -1
  65. package/dist/trigger/index.js +310 -108
  66. package/dist/trigger/index.js.map +1 -1
  67. package/dist/{trigger-Dn0DFiyU.d.ts → trigger-CXrbKVCL.d.ts} +2 -2
  68. package/dist/workflow/index.d.ts +2 -1
  69. package/dist/workflow/index.js +310 -108
  70. package/dist/workflow/index.js.map +1 -1
  71. package/package.json +30 -6
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/eve/tools/identity/whoami.ts","../../../../src/eve/agent/attributes.ts","../../../../src/eve/agent/tenant.ts","../../../../src/eve/tools/identity/my-access.ts"],"sourcesContent":["import { defineTool } from \"eve/tools\";\nimport { z } from \"zod\";\nimport { tryResolveTenantCaller } from \"../../agent/tenant.js\";\n\nexport const WHOAMI_TOOL_NAME = \"whoami\";\n\nexport const whoamiInputSchema = z.object({});\n\nexport function defineWhoamiTool() {\n return defineTool({\n description:\n \"Return the authenticated RobotRock user, tenant, role, and group memberships for the current chat session.\",\n inputSchema: whoamiInputSchema,\n async execute(_input, ctx) {\n const caller = tryResolveTenantCaller(ctx);\n if (!caller) {\n return {\n authenticated: false as const,\n message:\n \"No RobotRock user is attached to this session. Dashboard chat supplies user context via the Eve proxy.\",\n };\n }\n\n return {\n authenticated: true as const,\n userId: caller.userId,\n name: caller.name,\n email: caller.email,\n tenantSlug: caller.tenantSlug,\n role: caller.role,\n isAdmin: caller.isAdmin,\n groups: caller.groups.map((slug) => ({ slug })),\n ...(caller.workosUserId ? { workosUserId: caller.workosUserId } : {}),\n sessionId: ctx.session.id,\n };\n },\n });\n}\n\nexport const whoamiTool = defineWhoamiTool();\n","export function readStringAttribute(\n attributes: Readonly<Record<string, string | readonly string[]>> | undefined,\n key: string\n): string | undefined {\n const value = attributes?.[key];\n if (typeof value === \"string\" && value.length > 0) {\n return value;\n }\n if (Array.isArray(value) && typeof value[0] === \"string\" && value[0].length > 0) {\n return value[0];\n }\n return undefined;\n}\n\nexport function readStringArrayAttribute(\n attributes: Readonly<Record<string, string | readonly string[]>> | undefined,\n key: string\n): string[] {\n const value = attributes?.[key];\n if (typeof value === \"string\" && value.length > 0) {\n return [value];\n }\n if (Array.isArray(value)) {\n return value.filter(\n (entry): entry is string => typeof entry === \"string\" && entry.length > 0\n );\n }\n return [];\n}\n\nexport function parseTenantRole(\n value: string | undefined\n): \"admin\" | \"member\" | null {\n if (value === \"admin\" || value === \"member\") {\n return value;\n }\n return null;\n}\n","import type { SessionContext } from \"eve/context\";\nimport {\n parseTenantRole,\n readStringArrayAttribute,\n readStringAttribute,\n} from \"./attributes.js\";\n\nexport type TenantRole = \"admin\" | \"member\";\n\nexport type TenantCaller = {\n userId: string;\n email: string;\n name: string;\n tenantSlug: string;\n connectionId?: string;\n role: TenantRole;\n isAdmin: boolean;\n groups: string[];\n workosUserId?: string;\n};\n\n/** Resolve the authenticated RobotRock dashboard user for the current session. */\nexport function tryResolveTenantCaller(ctx: SessionContext): TenantCaller | null {\n const caller = ctx.session.auth.initiator ?? ctx.session.auth.current;\n if (caller?.principalType !== \"user\") {\n return null;\n }\n\n const email = readStringAttribute(caller.attributes, \"email\");\n const name = readStringAttribute(caller.attributes, \"name\");\n const tenantSlug =\n readStringAttribute(caller.attributes, \"tenantSlug\") ??\n readStringAttribute(caller.attributes, \"tenantId\");\n const role = parseTenantRole(readStringAttribute(caller.attributes, \"role\"));\n if (!email || !tenantSlug || !caller.principalId || !role) {\n return null;\n }\n\n const workosUserId = readStringAttribute(caller.attributes, \"workosUserId\");\n const connectionId = readStringAttribute(caller.attributes, \"connectionId\");\n const groups = readStringArrayAttribute(caller.attributes, \"groups\");\n\n return {\n userId: caller.principalId,\n email,\n name: name ?? email.split(\"@\")[0] ?? email,\n tenantSlug,\n ...(connectionId ? { connectionId } : {}),\n role,\n isAdmin: role === \"admin\",\n groups,\n ...(workosUserId ? { workosUserId } : {}),\n };\n}\n\n/** Like {@link tryResolveTenantCaller} but throws when the session has no user. */\nexport function requireTenantCaller(ctx: SessionContext): TenantCaller {\n const caller = tryResolveTenantCaller(ctx);\n if (!caller) {\n throw new Error(\"An authenticated RobotRock tenant user is required.\");\n }\n return caller;\n}\n\nexport function isAdminCaller(ctx: SessionContext): boolean {\n return tryResolveTenantCaller(ctx)?.isAdmin === true;\n}\n\n/** Require an authenticated tenant admin for the current session. */\nexport function requireAdminCaller(ctx: SessionContext): TenantCaller {\n const caller = requireTenantCaller(ctx);\n if (!caller.isAdmin) {\n throw new Error(\"Tenant admin access is required.\");\n }\n return caller;\n}\n","import { defineTool } from \"eve/tools\";\nimport { z } from \"zod\";\nimport { tryResolveTenantCaller } from \"../../agent/tenant.js\";\n\n/** Eve tool slug — must match the agent tool filename `get_my_access.ts`. */\nexport const MY_ACCESS_TOOL_NAME = \"get_my_access\";\n\nexport const myAccessInputSchema = z.object({});\n\nfunction tenantCapabilities(isAdmin: boolean) {\n return {\n manageSettings: isAdmin,\n manageBilling: isAdmin,\n manageTeam: isAdmin,\n manageIntegrations: isAdmin,\n };\n}\n\nexport function defineMyAccessTool() {\n return defineTool({\n description:\n \"Check the authenticated user's tenant role, group memberships, and admin capabilities in RobotRock.\",\n inputSchema: myAccessInputSchema,\n async execute(_input, ctx) {\n const caller = tryResolveTenantCaller(ctx);\n if (!caller) {\n return {\n authenticated: false as const,\n message:\n \"No RobotRock user is attached to this session. Dashboard chat supplies user context via the Eve proxy.\",\n };\n }\n\n return {\n authenticated: true as const,\n tenantRole: caller.role,\n isTenantAdmin: caller.isAdmin,\n groupSlugs: caller.groups,\n capabilities: tenantCapabilities(caller.isAdmin),\n email: caller.email,\n tenantSlug: caller.tenantSlug,\n };\n },\n });\n}\n\nexport const myAccessTool = defineMyAccessTool();\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,SAAS;;;ACDX,SAAS,oBACd,YACA,KACoB;AACpB,QAAM,QAAQ,aAAa,GAAG;AAC9B,MAAI,OAAO,UAAU,YAAY,MAAM,SAAS,GAAG;AACjD,WAAO;AAAA,EACT;AACA,MAAI,MAAM,QAAQ,KAAK,KAAK,OAAO,MAAM,CAAC,MAAM,YAAY,MAAM,CAAC,EAAE,SAAS,GAAG;AAC/E,WAAO,MAAM,CAAC;AAAA,EAChB;AACA,SAAO;AACT;AAEO,SAAS,yBACd,YACA,KACU;AACV,QAAM,QAAQ,aAAa,GAAG;AAC9B,MAAI,OAAO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AAAA,QACnB,eAAe,OAAO;AAAA,QACtB,YAAY,OAAO;AAAA,QACnB,cAAc,mBAAmB,OAAO,OAAO;AAAA,QAC/C,OAAO,OAAO;AAAA,QACd,YAAY,OAAO;AAAA,MACrB;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEO,IAAM,eAAe,mBAAmB;","names":["defineTool","z","z","defineTool"]}
1
+ {"version":3,"sources":["../../../../src/eve/tools/identity/whoami.ts","../../../../src/eve/agent/attributes.ts","../../../../src/eve/agent/tenant.ts","../../../../src/eve/tool-reply-guidance.ts","../../../../src/eve/tools/identity/my-access.ts","../../../../src/eve/tool-result-display.ts","../../../../src/eve/tool-display-format.ts","../../../../src/eve/tools/identity/format-my-access.ts"],"sourcesContent":["import { defineTool } from \"eve/tools\";\nimport { z } from \"zod\";\nimport { tryResolveTenantCaller } from \"../../agent/tenant.js\";\nimport {\n WHOAMI_REPLY_GUIDANCE,\n withReplyGuidance,\n} from \"../../tool-reply-guidance.js\";\n\nexport const WHOAMI_TOOL_NAME = \"whoami\";\n\nexport const whoamiInputSchema = z.object({});\n\nexport function defineWhoamiTool() {\n return defineTool({\n description:\n \"Return the authenticated RobotRock user, tenant, role, and group memberships for the current chat session. \" +\n \"The dashboard renders a profile card — do not repeat name, email, workspace, role, or groups in your reply; only add context not shown in the card.\",\n inputSchema: whoamiInputSchema,\n async execute(_input, ctx) {\n const caller = tryResolveTenantCaller(ctx);\n if (!caller) {\n return withReplyGuidance(\n {\n authenticated: false as const,\n message:\n \"No RobotRock user is attached to this session. Dashboard chat supplies user context via the Eve proxy.\",\n },\n \"Explain that no user is attached to this session. Do not invent identity details.\"\n );\n }\n\n return withReplyGuidance(\n {\n authenticated: true as const,\n userId: caller.userId,\n name: caller.name,\n email: caller.email,\n tenantSlug: caller.tenantSlug,\n role: caller.role,\n isAdmin: caller.isAdmin,\n groups: caller.groups.map((slug) => ({ slug })),\n ...(caller.workosUserId ? { workosUserId: caller.workosUserId } : {}),\n sessionId: ctx.session.id,\n },\n WHOAMI_REPLY_GUIDANCE\n );\n },\n });\n}\n\nexport const whoamiTool = defineWhoamiTool();\n","export function readStringAttribute(\n attributes: Readonly<Record<string, string | readonly string[]>> | undefined,\n key: string\n): string | undefined {\n const value = attributes?.[key];\n if (typeof value === \"string\" && value.length > 0) {\n return value;\n }\n if (Array.isArray(value) && typeof value[0] === \"string\" && value[0].length > 0) {\n return value[0];\n }\n return undefined;\n}\n\nexport function readStringArrayAttribute(\n attributes: Readonly<Record<string, string | readonly string[]>> | undefined,\n key: string\n): string[] {\n const value = attributes?.[key];\n if (typeof value === \"string\" && value.length > 0) {\n return [value];\n }\n if (Array.isArray(value)) {\n return value.filter(\n (entry): entry is string => typeof entry === \"string\" && entry.length > 0\n );\n }\n return [];\n}\n\nexport function parseTenantRole(\n value: string | undefined\n): \"admin\" | \"member\" | null {\n if (value === \"admin\" || value === \"member\") {\n return value;\n }\n return null;\n}\n","import type { SessionContext } from \"eve/context\";\nimport {\n parseTenantRole,\n readStringArrayAttribute,\n readStringAttribute,\n} from \"./attributes.js\";\n\nexport type TenantRole = \"admin\" | \"member\";\n\nexport type TenantCaller = {\n userId: string;\n email: string;\n name: string;\n tenantSlug: string;\n connectionId?: string;\n role: TenantRole;\n isAdmin: boolean;\n groups: string[];\n workosUserId?: string;\n};\n\n/** Resolve the authenticated RobotRock dashboard user for the current session. */\nexport function tryResolveTenantCaller(ctx: SessionContext): TenantCaller | null {\n const caller = ctx.session.auth.initiator ?? ctx.session.auth.current;\n if (caller?.principalType !== \"user\") {\n return null;\n }\n\n const email = readStringAttribute(caller.attributes, \"email\");\n const name = readStringAttribute(caller.attributes, \"name\");\n const tenantSlug =\n readStringAttribute(caller.attributes, \"tenantSlug\") ??\n readStringAttribute(caller.attributes, \"tenantId\");\n const role = parseTenantRole(readStringAttribute(caller.attributes, \"role\"));\n if (!email || !tenantSlug || !caller.principalId || !role) {\n return null;\n }\n\n const workosUserId = readStringAttribute(caller.attributes, \"workosUserId\");\n const connectionId = readStringAttribute(caller.attributes, \"connectionId\");\n const groups = readStringArrayAttribute(caller.attributes, \"groups\");\n\n return {\n userId: caller.principalId,\n email,\n name: name ?? email.split(\"@\")[0] ?? email,\n tenantSlug,\n ...(connectionId ? { connectionId } : {}),\n role,\n isAdmin: role === \"admin\",\n groups,\n ...(workosUserId ? { workosUserId } : {}),\n };\n}\n\n/** Like {@link tryResolveTenantCaller} but throws when the session has no user. */\nexport function requireTenantCaller(ctx: SessionContext): TenantCaller {\n const caller = tryResolveTenantCaller(ctx);\n if (!caller) {\n throw new Error(\"An authenticated RobotRock tenant user is required.\");\n }\n return caller;\n}\n\nexport function isAdminCaller(ctx: SessionContext): boolean {\n return tryResolveTenantCaller(ctx)?.isAdmin === true;\n}\n\n/** Require an authenticated tenant admin for the current session. */\nexport function requireAdminCaller(ctx: SessionContext): TenantCaller {\n const caller = requireTenantCaller(ctx);\n if (!caller.isAdmin) {\n throw new Error(\"Tenant admin access is required.\");\n }\n return caller;\n}\n","/** Field name agents read; dashboard widgets must ignore when rendering. */\nexport const TOOL_REPLY_GUIDANCE_FIELD = \"replyGuidance\" as const;\n\nexport const WHOAMI_REPLY_GUIDANCE =\n \"The dashboard shows a profile card with name, email, workspace, role, and groups. Do not restate those in your reply. Only add context not in the card (e.g. permissions, refund approval rules, missing group membership).\";\n\nexport const MY_ACCESS_REPLY_GUIDANCE =\n \"Access details may render in chat UI. Do not restate role, groups, or admin capabilities if already visible. Only explain what the user can or cannot do for their question (e.g. finance group required for refunds ≥ $10,000). When access.tenantAdmin is false and the user needs manageTeam, manageGroups, or query-tasks capabilities, explain briefly then call ask_question to offer sending an admin request to tenant admins — do not tell them to find an admin manually without offering delegation first.\";\n\nexport const CREATE_INBOX_TASK_REPLY_GUIDANCE =\n \"A task card shows title, assignee, and inbox status in chat. Do not restate task ID, assignee, or delegation details from the card. Only mention next steps or answer the user's question.\";\n\nexport const SEARCH_PRODUCTS_REPLY_GUIDANCE =\n \"Product results render as a list card in chat. Do not restate product names, prices, or SKUs. Only add context not in the list (e.g. no matches, recommendations).\";\n\nexport const MANAGE_TEAM_MEMBERS_LIST_REPLY_GUIDANCE =\n \"Team members render as a list card in chat. Do not restate names, emails, or roles from the list. Only add context not shown (e.g. duplicates, next admin actions).\";\n\nexport const MANAGE_TEAM_MEMBERS_DETAIL_REPLY_GUIDANCE =\n \"Team member details render in chat UI. Do not restate name, email, or role from the card. Only add next steps or policy context.\";\n\nexport const MANAGE_GROUPS_LIST_REPLY_GUIDANCE =\n \"Groups render as a list card in chat. Do not restate group names, slugs, or descriptions from the list. Use slug (not internal id) for get, update, delete, and membership actions. Only add context not shown.\";\n\nexport const MANAGE_GROUPS_DETAIL_REPLY_GUIDANCE =\n \"Group details render in chat UI. Do not restate fields already visible in the card. Only add next steps.\";\n\nexport const QUERY_TASKS_LIST_REPLY_GUIDANCE =\n \"Tasks render as a list card in chat. Do not restate task names, ids, or statuses from the list. Only add context not shown (e.g. filters applied, recommended next action).\";\n\nexport const QUERY_TASKS_DETAIL_REPLY_GUIDANCE =\n \"Task details render in chat UI. Do not restate fields already visible in the card. Only add analysis or next steps.\";\n\nexport const ASSIGN_TASKS_REPLY_GUIDANCE =\n \"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.\";\n\nexport const REFUND_CHARGE_REPLY_GUIDANCE =\n \"Refund details render in chat UI. Do not restate charge id, amount, or status from the card. Only add policy context or next steps.\";\n\nexport const DEPLOY_RELEASE_REPLY_GUIDANCE =\n \"Deploy details render in chat UI. Do not restate service, version, or environment from the card. Only add rollout context or next steps.\";\n\nexport const GET_WEATHER_REPLY_GUIDANCE =\n \"Weather details render in chat UI. Do not restate city, condition, or temperature from the card. Only add conversational context if needed.\";\n\nexport const ADMIN_MUTATION_REPLY_GUIDANCE =\n \"The action result renders in chat UI. Do not restate fields already visible in the card. Confirm outcome briefly or add next steps only.\";\n\nexport type ToolResultWithReplyGuidance<T extends Record<string, unknown>> = T & {\n replyGuidance: string;\n};\n\n/** Attach model-facing narration hints to a tool execute result. */\nexport function withReplyGuidance<T extends Record<string, unknown>>(\n result: T,\n guidance: string\n): ToolResultWithReplyGuidance<T> {\n return {\n ...result,\n [TOOL_REPLY_GUIDANCE_FIELD]: guidance,\n };\n}\n\n/** Remove agent-only fields before showing raw JSON in the dashboard. */\nexport function stripAgentOnlyToolFields(output: unknown): unknown {\n if (typeof output !== \"object\" || output === null || Array.isArray(output)) {\n return output;\n }\n\n const record = { ...(output as Record<string, unknown>) };\n delete record[TOOL_REPLY_GUIDANCE_FIELD];\n return record;\n}\n","import { defineTool } from \"eve/tools\";\nimport { z } from \"zod\";\nimport { tryResolveTenantCaller } from \"../../agent/tenant.js\";\nimport {\n MY_ACCESS_REPLY_GUIDANCE,\n withReplyGuidance,\n} from \"../../tool-reply-guidance.js\";\nimport { formatMyAccessResult } from \"./format-my-access.js\";\n\n/** Eve tool slug — must match the agent tool filename `get_my_access.ts`. */\nexport const MY_ACCESS_TOOL_NAME = \"get_my_access\";\n\nexport const myAccessInputSchema = z.object({});\n\nfunction tenantCapabilities(isAdmin: boolean) {\n return {\n manageSettings: isAdmin,\n manageBilling: isAdmin,\n manageTeam: isAdmin,\n manageIntegrations: isAdmin,\n };\n}\n\nexport function defineMyAccessTool() {\n return defineTool({\n description:\n \"Check the authenticated user's tenant role, group memberships, and admin capabilities in RobotRock. \" +\n \"Results render as an access card in chat — do not restate role, groups, or capabilities in your reply.\",\n inputSchema: myAccessInputSchema,\n async execute(_input, ctx) {\n const caller = tryResolveTenantCaller(ctx);\n if (!caller) {\n return withReplyGuidance(\n {\n authenticated: false as const,\n message:\n \"No RobotRock user is attached to this session. Dashboard chat supplies user context via the Eve proxy.\",\n },\n \"Explain that no user is attached to this session. Do not invent access details.\"\n );\n }\n\n return formatMyAccessResult({\n tenantSlug: caller.tenantSlug,\n tenantRole: caller.role,\n isTenantAdmin: caller.isAdmin,\n groupSlugs: caller.groups,\n capabilities: tenantCapabilities(caller.isAdmin),\n email: caller.email,\n });\n },\n });\n}\n\nexport const myAccessTool = defineMyAccessTool();\n","import type {\n ToolDisplayEnvelope,\n ToolDisplayMetadata,\n UiSchema,\n} from \"@robotrock/core/schemas\";\n\nexport type ToolDisplayResultOptions = {\n widget?: string;\n title?: string;\n description?: string;\n ui?: Record<string, UiSchema>;\n};\n\n/**\n * Wrap tool execute output with optional dashboard display hints.\n * Agents return plain JSON by default; use this when schema-driven widgets help.\n */\nexport function toolDisplayResult<T extends Record<string, unknown>>(\n data: T,\n options?: ToolDisplayResultOptions\n): ToolDisplayEnvelope<T> {\n const display: ToolDisplayMetadata | undefined =\n options?.widget || options?.title || options?.description\n ? {\n ...(options.widget ? { widget: options.widget } : {}),\n ...(options.title ? { title: options.title } : {}),\n ...(options.description ? { description: options.description } : {}),\n }\n : undefined;\n\n return {\n ...(display ? { display } : {}),\n data,\n ...(options?.ui ? { ui: options.ui } : {}),\n };\n}\n","import type { UiSchema } from \"@robotrock/core/schemas\";\nimport { toolDisplayResult } from \"./tool-result-display.js\";\nimport { withReplyGuidance } from \"./tool-reply-guidance.js\";\n\nexport type FormatToolObjectResultOptions = {\n title?: string;\n description?: string;\n ui?: Record<string, UiSchema>;\n replyGuidance: string;\n};\n\nexport type FormatToolListResultOptions = {\n title: string;\n itemUi?: UiSchema;\n /** Composite widget for each row (uses list layout instead of table). */\n itemWidget?: string;\n replyGuidance: string;\n};\n\n/** Wrap a flat object for schema-driven chat rendering. */\nexport function formatToolObjectResult(\n data: Record<string, unknown>,\n options: FormatToolObjectResultOptions\n) {\n return withReplyGuidance(\n toolDisplayResult(data, {\n title: options.title,\n description: options.description,\n ui: options.ui,\n }),\n options.replyGuidance\n );\n}\n\n/** Wrap an array field as a list widget inside a display envelope. */\nexport function formatToolListResult(\n listKey: string,\n items: Record<string, unknown>[],\n options: FormatToolListResultOptions\n) {\n const listFieldUi = options.itemWidget\n ? {\n \"ui:widget\": \"list\" as const,\n items: {\n \"ui:widget\": options.itemWidget,\n ...(options.itemUi ?? {}),\n },\n }\n : {\n \"ui:widget\": \"table\" as const,\n ...(options.itemUi ? { items: options.itemUi } : {}),\n };\n\n return formatToolObjectResult(\n { [listKey]: items },\n {\n title: options.title,\n ui: {\n [listKey]: listFieldUi,\n },\n replyGuidance: options.replyGuidance,\n }\n );\n}\n\nexport function isAgentAdminErrorResult(\n result: unknown\n): result is { ok: false; message: string } {\n return (\n typeof result === \"object\" &&\n result !== null &&\n (result as { ok?: unknown }).ok === false &&\n typeof (result as { message?: unknown }).message === \"string\"\n );\n}\n","import { formatToolObjectResult } from \"../../tool-display-format.js\";\nimport { MY_ACCESS_REPLY_GUIDANCE } from \"../../tool-reply-guidance.js\";\n\ntype MyAccessResultInput = {\n tenantSlug: string;\n tenantRole?: string;\n isTenantAdmin: boolean;\n groupSlugs: string[];\n capabilities: {\n manageSettings: boolean;\n manageBilling: boolean;\n manageTeam: boolean;\n manageIntegrations: boolean;\n };\n email?: string;\n};\n\nconst ACCESS_FIELD_UI = {\n workspace: { \"ui:title\": \"Workspace\" },\n role: { \"ui:title\": \"Role\" },\n tenantAdmin: { \"ui:title\": \"Tenant admin\", \"ui:widget\": \"boolean\" },\n groups: { \"ui:title\": \"Groups\" },\n manageSettings: { \"ui:title\": \"Manage settings\", \"ui:widget\": \"boolean\" },\n manageBilling: { \"ui:title\": \"Manage billing\", \"ui:widget\": \"boolean\" },\n manageTeam: { \"ui:title\": \"Manage team\", \"ui:widget\": \"boolean\" },\n manageIntegrations: {\n \"ui:title\": \"Manage integrations\",\n \"ui:widget\": \"boolean\",\n },\n email: { \"ui:title\": \"Email\" },\n} as const;\n\nexport function formatMyAccessResult(input: MyAccessResultInput) {\n return formatToolObjectResult(\n {\n access: {\n workspace: input.tenantSlug,\n role: input.tenantRole ?? \"member\",\n tenantAdmin: input.isTenantAdmin,\n groups: input.groupSlugs.join(\", \") || \"—\",\n manageSettings: input.capabilities.manageSettings,\n manageBilling: input.capabilities.manageBilling,\n manageTeam: input.capabilities.manageTeam,\n manageIntegrations: input.capabilities.manageIntegrations,\n ...(input.email ? { email: input.email } : {}),\n },\n },\n {\n ui: {\n access: {\n \"ui:widget\": \"access\",\n \"ui:title\": \"Your access\",\n items: ACCESS_FIELD_UI,\n },\n },\n replyGuidance: MY_ACCESS_REPLY_GUIDANCE,\n }\n );\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,SAAS;;;ACDX,SAAS,oBACd,YACA,KACoB;AACpB,QAAM,QAAQ,aAAa,GAAG;AAC9B,MAAI,OAAO,UAAU,YAAY,MAAM,SAAS,GAAG;AACjD,WAAO;AAAA,EACT;AACA,MAAI,MAAM,QAAQ,KAAK,KAAK,OAAO,MAAM,CAAC,MAAM,YAAY,MAAM,CAAC,EAAE,SAAS,GAAG;AAC/E,WAAO,MAAM,CAAC;AAAA,EAChB;AACA,SAAO;AACT;AAEO,SAAS,yBACd,YACA,KACU;AACV,QAAM,QAAQ,aAAa,GAAG;AAC9B,MAAI,OAAO,UAAU,YAAY,MAAM,SAAS,GAAG;AACjD,WAAO,CAAC,KAAK;AAAA,EACf;AACA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM;AAAA,MACX,CAAC,UAA2B,OAAO,UAAU,YAAY,MAAM,SAAS;AAAA,IAC1E;AAAA,EACF;AACA,SAAO,CAAC;AACV;AAEO,SAAS,gBACd,OAC2B;AAC3B,MAAI,UAAU,WAAW,UAAU,UAAU;AAC3C,WAAO;AAAA,EACT;AACA,SAAO;AACT;;;ACfO,SAAS,uBAAuB,KAA0C;AAC/E,QAAM,SAAS,IAAI,QAAQ,KAAK,aAAa,IAAI,QAAQ,KAAK;AAC9D,MAAI,QAAQ,kBAAkB,QAAQ;AACpC,WAAO;AAAA,EACT;AAEA,QAAM,QAAQ,oBAAoB,OAAO,YAAY,OAAO;AAC5D,QAAM,OAAO,oBAAoB,OAAO,YAAY,MAAM;AAC1D,QAAM,aACJ,oBAAoB,OAAO,YAAY,YAAY,KACnD,oBAAoB,OAAO,YAAY,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J;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAEA,aAAO,qBAAqB;AAAA,QAC1B,YAAY,OAAO;AAAA,QACnB,YAAY,OAAO;AAAA,QACnB,eAAe,OAAO;AAAA,QACtB,YAAY,OAAO;AAAA,QACnB,cAAc,mBAAmB,OAAO,OAAO;AAAA,QAC/C,OAAO,OAAO;AAAA,MAChB,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;AAEO,IAAM,eAAe,mBAAmB;","names":["defineTool","z","z","defineTool"]}
@@ -1,58 +1,18 @@
1
1
  import * as eve_tools from 'eve/tools';
2
- import { T as TenantRole } from '../../../tenant-5YKDrdC-.js';
2
+ import * as _robotrock_core from '@robotrock/core';
3
+ import { T as ToolResultWithReplyGuidance } from '../../../tool-reply-guidance-C3qrT1In.js';
3
4
  import { z } from 'zod';
4
- import 'eve/context';
5
5
 
6
6
  /** Eve tool slug — must match the agent tool filename `get_my_access.ts`. */
7
7
  declare const MY_ACCESS_TOOL_NAME = "get_my_access";
8
8
  declare const myAccessInputSchema: z.ZodObject<{}, z.core.$strip>;
9
- declare function defineMyAccessTool(): eve_tools.ToolDefinition<Record<string, never>, {
9
+ declare function defineMyAccessTool(): eve_tools.ToolDefinition<Record<string, never>, ToolResultWithReplyGuidance<{
10
10
  authenticated: false;
11
11
  message: string;
12
- tenantRole?: undefined;
13
- isTenantAdmin?: undefined;
14
- groupSlugs?: undefined;
15
- capabilities?: undefined;
16
- email?: undefined;
17
- tenantSlug?: undefined;
18
- } | {
19
- authenticated: true;
20
- tenantRole: TenantRole;
21
- isTenantAdmin: boolean;
22
- groupSlugs: string[];
23
- capabilities: {
24
- manageSettings: boolean;
25
- manageBilling: boolean;
26
- manageTeam: boolean;
27
- manageIntegrations: boolean;
28
- };
29
- email: string;
30
- tenantSlug: string;
31
- message?: undefined;
32
- }>;
33
- declare const myAccessTool: eve_tools.ToolDefinition<Record<string, never>, {
12
+ }> | ToolResultWithReplyGuidance<_robotrock_core.ToolDisplayEnvelope<Record<string, unknown>>>>;
13
+ declare const myAccessTool: eve_tools.ToolDefinition<Record<string, never>, ToolResultWithReplyGuidance<{
34
14
  authenticated: false;
35
15
  message: string;
36
- tenantRole?: undefined;
37
- isTenantAdmin?: undefined;
38
- groupSlugs?: undefined;
39
- capabilities?: undefined;
40
- email?: undefined;
41
- tenantSlug?: undefined;
42
- } | {
43
- authenticated: true;
44
- tenantRole: TenantRole;
45
- isTenantAdmin: boolean;
46
- groupSlugs: string[];
47
- capabilities: {
48
- manageSettings: boolean;
49
- manageBilling: boolean;
50
- manageTeam: boolean;
51
- manageIntegrations: boolean;
52
- };
53
- email: string;
54
- tenantSlug: string;
55
- message?: undefined;
56
- }>;
16
+ }> | ToolResultWithReplyGuidance<_robotrock_core.ToolDisplayEnvelope<Record<string, unknown>>>>;
57
17
 
58
18
  export { MY_ACCESS_TOOL_NAME, defineMyAccessTool, myAccessInputSchema, myAccessTool };
@@ -61,6 +61,85 @@ function tryResolveTenantCaller(ctx) {
61
61
  };
62
62
  }
63
63
 
64
+ // src/eve/tool-reply-guidance.ts
65
+ var TOOL_REPLY_GUIDANCE_FIELD = "replyGuidance";
66
+ var MY_ACCESS_REPLY_GUIDANCE = "Access details may render in chat UI. Do not restate role, groups, or admin capabilities if already visible. Only explain what the user can or cannot do for their question (e.g. finance group required for refunds \u2265 $10,000). When access.tenantAdmin is false and the user needs manageTeam, manageGroups, or query-tasks capabilities, explain briefly then call ask_question to offer sending an admin request to tenant admins \u2014 do not tell them to find an admin manually without offering delegation first.";
67
+ function withReplyGuidance(result, guidance) {
68
+ return {
69
+ ...result,
70
+ [TOOL_REPLY_GUIDANCE_FIELD]: guidance
71
+ };
72
+ }
73
+
74
+ // src/eve/tool-result-display.ts
75
+ function toolDisplayResult(data, options) {
76
+ const display = options?.widget || options?.title || options?.description ? {
77
+ ...options.widget ? { widget: options.widget } : {},
78
+ ...options.title ? { title: options.title } : {},
79
+ ...options.description ? { description: options.description } : {}
80
+ } : void 0;
81
+ return {
82
+ ...display ? { display } : {},
83
+ data,
84
+ ...options?.ui ? { ui: options.ui } : {}
85
+ };
86
+ }
87
+
88
+ // src/eve/tool-display-format.ts
89
+ function formatToolObjectResult(data, options) {
90
+ return withReplyGuidance(
91
+ toolDisplayResult(data, {
92
+ title: options.title,
93
+ description: options.description,
94
+ ui: options.ui
95
+ }),
96
+ options.replyGuidance
97
+ );
98
+ }
99
+
100
+ // src/eve/tools/identity/format-my-access.ts
101
+ var ACCESS_FIELD_UI = {
102
+ workspace: { "ui:title": "Workspace" },
103
+ role: { "ui:title": "Role" },
104
+ tenantAdmin: { "ui:title": "Tenant admin", "ui:widget": "boolean" },
105
+ groups: { "ui:title": "Groups" },
106
+ manageSettings: { "ui:title": "Manage settings", "ui:widget": "boolean" },
107
+ manageBilling: { "ui:title": "Manage billing", "ui:widget": "boolean" },
108
+ manageTeam: { "ui:title": "Manage team", "ui:widget": "boolean" },
109
+ manageIntegrations: {
110
+ "ui:title": "Manage integrations",
111
+ "ui:widget": "boolean"
112
+ },
113
+ email: { "ui:title": "Email" }
114
+ };
115
+ function formatMyAccessResult(input) {
116
+ return formatToolObjectResult(
117
+ {
118
+ access: {
119
+ workspace: input.tenantSlug,
120
+ role: input.tenantRole ?? "member",
121
+ tenantAdmin: input.isTenantAdmin,
122
+ groups: input.groupSlugs.join(", ") || "\u2014",
123
+ manageSettings: input.capabilities.manageSettings,
124
+ manageBilling: input.capabilities.manageBilling,
125
+ manageTeam: input.capabilities.manageTeam,
126
+ manageIntegrations: input.capabilities.manageIntegrations,
127
+ ...input.email ? { email: input.email } : {}
128
+ }
129
+ },
130
+ {
131
+ ui: {
132
+ access: {
133
+ "ui:widget": "access",
134
+ "ui:title": "Your access",
135
+ items: ACCESS_FIELD_UI
136
+ }
137
+ },
138
+ replyGuidance: MY_ACCESS_REPLY_GUIDANCE
139
+ }
140
+ );
141
+ }
142
+
64
143
  // src/eve/tools/identity/my-access.ts
65
144
  var MY_ACCESS_TOOL_NAME = "get_my_access";
66
145
  var myAccessInputSchema = z.object({});
@@ -74,25 +153,27 @@ function tenantCapabilities(isAdmin) {
74
153
  }
75
154
  function defineMyAccessTool() {
76
155
  return defineTool({
77
- description: "Check the authenticated user's tenant role, group memberships, and admin capabilities in RobotRock.",
156
+ description: "Check the authenticated user's tenant role, group memberships, and admin capabilities in RobotRock. Results render as an access card in chat \u2014 do not restate role, groups, or capabilities in your reply.",
78
157
  inputSchema: myAccessInputSchema,
79
158
  async execute(_input, ctx) {
80
159
  const caller = tryResolveTenantCaller(ctx);
81
160
  if (!caller) {
82
- return {
83
- authenticated: false,
84
- message: "No RobotRock user is attached to this session. Dashboard chat supplies user context via the Eve proxy."
85
- };
161
+ return withReplyGuidance(
162
+ {
163
+ authenticated: false,
164
+ message: "No RobotRock user is attached to this session. Dashboard chat supplies user context via the Eve proxy."
165
+ },
166
+ "Explain that no user is attached to this session. Do not invent access details."
167
+ );
86
168
  }
87
- return {
88
- authenticated: true,
169
+ return formatMyAccessResult({
170
+ tenantSlug: caller.tenantSlug,
89
171
  tenantRole: caller.role,
90
172
  isTenantAdmin: caller.isAdmin,
91
173
  groupSlugs: caller.groups,
92
174
  capabilities: tenantCapabilities(caller.isAdmin),
93
- email: caller.email,
94
- tenantSlug: caller.tenantSlug
95
- };
175
+ email: caller.email
176
+ });
96
177
  }
97
178
  });
98
179
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/eve/tools/identity/my-access.ts","../../../../src/eve/agent/attributes.ts","../../../../src/eve/agent/tenant.ts"],"sourcesContent":["import { defineTool } from \"eve/tools\";\nimport { z } from \"zod\";\nimport { tryResolveTenantCaller } from \"../../agent/tenant.js\";\n\n/** Eve tool slug — must match the agent tool filename `get_my_access.ts`. */\nexport const MY_ACCESS_TOOL_NAME = \"get_my_access\";\n\nexport const myAccessInputSchema = z.object({});\n\nfunction tenantCapabilities(isAdmin: boolean) {\n return {\n manageSettings: isAdmin,\n manageBilling: isAdmin,\n manageTeam: isAdmin,\n manageIntegrations: isAdmin,\n };\n}\n\nexport function defineMyAccessTool() {\n return defineTool({\n description:\n \"Check the authenticated user's tenant role, group memberships, and admin capabilities in RobotRock.\",\n inputSchema: myAccessInputSchema,\n async execute(_input, ctx) {\n const caller = tryResolveTenantCaller(ctx);\n if (!caller) {\n return {\n authenticated: false as const,\n message:\n \"No RobotRock user is attached to this session. Dashboard chat supplies user context via the Eve proxy.\",\n };\n }\n\n return {\n authenticated: true as const,\n tenantRole: caller.role,\n isTenantAdmin: caller.isAdmin,\n groupSlugs: caller.groups,\n capabilities: tenantCapabilities(caller.isAdmin),\n email: caller.email,\n tenantSlug: caller.tenantSlug,\n };\n },\n });\n}\n\nexport const myAccessTool = defineMyAccessTool();\n","export function readStringAttribute(\n attributes: Readonly<Record<string, string | readonly string[]>> | undefined,\n key: string\n): string | undefined {\n const value = attributes?.[key];\n if (typeof value === \"string\" && value.length > 0) {\n return value;\n }\n if (Array.isArray(value) && typeof value[0] === \"string\" && value[0].length > 0) {\n return value[0];\n }\n return undefined;\n}\n\nexport function readStringArrayAttribute(\n attributes: Readonly<Record<string, string | readonly string[]>> | undefined,\n key: string\n): string[] {\n const value = attributes?.[key];\n if (typeof value === \"string\" && value.length > 0) {\n return [value];\n }\n if (Array.isArray(value)) {\n return value.filter(\n (entry): entry is string => typeof entry === \"string\" && entry.length > 0\n );\n }\n return [];\n}\n\nexport function parseTenantRole(\n value: string | undefined\n): \"admin\" | \"member\" | null {\n if (value === \"admin\" || value === \"member\") {\n return value;\n }\n return null;\n}\n","import type { SessionContext } from \"eve/context\";\nimport {\n parseTenantRole,\n readStringArrayAttribute,\n readStringAttribute,\n} from \"./attributes.js\";\n\nexport type TenantRole = \"admin\" | \"member\";\n\nexport type TenantCaller = {\n userId: string;\n email: string;\n name: string;\n tenantSlug: string;\n connectionId?: string;\n role: TenantRole;\n isAdmin: boolean;\n groups: string[];\n workosUserId?: string;\n};\n\n/** Resolve the authenticated RobotRock dashboard user for the current session. */\nexport function tryResolveTenantCaller(ctx: SessionContext): TenantCaller | null {\n const caller = ctx.session.auth.initiator ?? ctx.session.auth.current;\n if (caller?.principalType !== \"user\") {\n return null;\n }\n\n const email = readStringAttribute(caller.attributes, \"email\");\n const name = readStringAttribute(caller.attributes, \"name\");\n const tenantSlug =\n readStringAttribute(caller.attributes, \"tenantSlug\") ??\n readStringAttribute(caller.attributes, \"tenantId\");\n const role = parseTenantRole(readStringAttribute(caller.attributes, \"role\"));\n if (!email || !tenantSlug || !caller.principalId || !role) {\n return null;\n }\n\n const workosUserId = readStringAttribute(caller.attributes, \"workosUserId\");\n const connectionId = readStringAttribute(caller.attributes, \"connectionId\");\n const groups = readStringArrayAttribute(caller.attributes, \"groups\");\n\n return {\n userId: caller.principalId,\n email,\n name: name ?? email.split(\"@\")[0] ?? email,\n tenantSlug,\n ...(connectionId ? { connectionId } : {}),\n role,\n isAdmin: role === \"admin\",\n groups,\n ...(workosUserId ? { workosUserId } : {}),\n };\n}\n\n/** Like {@link tryResolveTenantCaller} but throws when the session has no user. */\nexport function requireTenantCaller(ctx: SessionContext): TenantCaller {\n const caller = tryResolveTenantCaller(ctx);\n if (!caller) {\n throw new Error(\"An authenticated RobotRock tenant user is required.\");\n }\n return caller;\n}\n\nexport function isAdminCaller(ctx: SessionContext): boolean {\n return tryResolveTenantCaller(ctx)?.isAdmin === true;\n}\n\n/** Require an authenticated tenant admin for the current session. */\nexport function requireAdminCaller(ctx: SessionContext): TenantCaller {\n const caller = requireTenantCaller(ctx);\n if (!caller.isAdmin) {\n throw new Error(\"Tenant admin access is required.\");\n }\n return caller;\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,SAAS;;;ACDX,SAAS,oBACd,YACA,KACoB;AACpB,QAAM,QAAQ,aAAa,GAAG;AAC9B,MAAI,OAAO,UAAU,YAAY,MAAM,SAAS,GAAG;AACjD,WAAO;AAAA,EACT;AACA,MAAI,MAAM,QAAQ,KAAK,KAAK,OAAO,MAAM,CAAC,MAAM,YAAY,MAAM,CAAC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a,IAAI,CAAC;AAAA,IACvC;AAAA,IACA,SAAS,SAAS;AAAA,IAClB;AAAA,IACA,GAAI,eAAe,EAAE,aAAa,IAAI,CAAC;AAAA,EACzC;AACF;;;AFhDO,IAAM,sBAAsB;AAE5B,IAAM,sBAAsB,EAAE,OAAO,CAAC,CAAC;AAE9C,SAAS,mBAAmB,SAAkB;AAC5C,SAAO;AAAA,IACL,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,YAAY;AAAA,IACZ,oBAAoB;AAAA,EACtB;AACF;AAEO,SAAS,qBAAqB;AACnC,SAAO,WAAW;AAAA,IAChB,aACE;AAAA,IACF,aAAa;AAAA,IACb,MAAM,QAAQ,QAAQ,KAAK;AACzB,YAAM,SAAS,uBAAuB,GAAG;AACzC,UAAI,CAAC,QAAQ;AACX,eAAO;AAAA,UACL,eAAe;AAAA,UACf,SACE;AAAA,QACJ;AAAA,MACF;AAEA,aAAO;AAAA,QACL,eAAe;AAAA,QACf,YAAY,OAAO;AAAA,QACnB,eAAe,OAAO;AAAA,QACtB,YAAY,OAAO;AAAA,QACnB,cAAc,mBAAmB,OAAO,OAAO;AAAA,QAC/C,OAAO,OAAO;AAAA,QACd,YAAY,OAAO;AAAA,MACrB;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEO,IAAM,eAAe,mBAAmB;","names":[]}
1
+ {"version":3,"sources":["../../../../src/eve/tools/identity/my-access.ts","../../../../src/eve/agent/attributes.ts","../../../../src/eve/agent/tenant.ts","../../../../src/eve/tool-reply-guidance.ts","../../../../src/eve/tool-result-display.ts","../../../../src/eve/tool-display-format.ts","../../../../src/eve/tools/identity/format-my-access.ts"],"sourcesContent":["import { defineTool } from \"eve/tools\";\nimport { z } from \"zod\";\nimport { tryResolveTenantCaller } from \"../../agent/tenant.js\";\nimport {\n MY_ACCESS_REPLY_GUIDANCE,\n withReplyGuidance,\n} from \"../../tool-reply-guidance.js\";\nimport { formatMyAccessResult } from \"./format-my-access.js\";\n\n/** Eve tool slug — must match the agent tool filename `get_my_access.ts`. */\nexport const MY_ACCESS_TOOL_NAME = \"get_my_access\";\n\nexport const myAccessInputSchema = z.object({});\n\nfunction tenantCapabilities(isAdmin: boolean) {\n return {\n manageSettings: isAdmin,\n manageBilling: isAdmin,\n manageTeam: isAdmin,\n manageIntegrations: isAdmin,\n };\n}\n\nexport function defineMyAccessTool() {\n return defineTool({\n description:\n \"Check the authenticated user's tenant role, group memberships, and admin capabilities in RobotRock. \" +\n \"Results render as an access card in chat — do not restate role, groups, or capabilities in your reply.\",\n inputSchema: myAccessInputSchema,\n async execute(_input, ctx) {\n const caller = tryResolveTenantCaller(ctx);\n if (!caller) {\n return withReplyGuidance(\n {\n authenticated: false as const,\n message:\n \"No RobotRock user is attached to this session. Dashboard chat supplies user context via the Eve proxy.\",\n },\n \"Explain that no user is attached to this session. Do not invent access details.\"\n );\n }\n\n return formatMyAccessResult({\n tenantSlug: caller.tenantSlug,\n tenantRole: caller.role,\n isTenantAdmin: caller.isAdmin,\n groupSlugs: caller.groups,\n capabilities: tenantCapabilities(caller.isAdmin),\n email: caller.email,\n });\n },\n });\n}\n\nexport const myAccessTool = defineMyAccessTool();\n","export function readStringAttribute(\n attributes: Readonly<Record<string, string | readonly string[]>> | undefined,\n key: string\n): string | undefined {\n const value = attributes?.[key];\n if (typeof value === \"string\" && value.length > 0) {\n return value;\n }\n if (Array.isArray(value) && typeof value[0] === \"string\" && value[0].length > 0) {\n return value[0];\n }\n return undefined;\n}\n\nexport function readStringArrayAttribute(\n attributes: Readonly<Record<string, string | readonly string[]>> | undefined,\n key: string\n): string[] {\n const value = attributes?.[key];\n if (typeof value === \"string\" && value.length > 0) {\n return [value];\n }\n if (Array.isArray(value)) {\n return value.filter(\n (entry): entry is string => typeof entry === \"string\" && entry.length > 0\n );\n }\n return [];\n}\n\nexport function parseTenantRole(\n value: string | undefined\n): \"admin\" | \"member\" | null {\n if (value === \"admin\" || value === \"member\") {\n return value;\n }\n return null;\n}\n","import type { SessionContext } from \"eve/context\";\nimport {\n parseTenantRole,\n readStringArrayAttribute,\n readStringAttribute,\n} from \"./attributes.js\";\n\nexport type TenantRole = \"admin\" | \"member\";\n\nexport type TenantCaller = {\n userId: string;\n email: string;\n name: string;\n tenantSlug: string;\n connectionId?: string;\n role: TenantRole;\n isAdmin: boolean;\n groups: string[];\n workosUserId?: string;\n};\n\n/** Resolve the authenticated RobotRock dashboard user for the current session. */\nexport function tryResolveTenantCaller(ctx: SessionContext): TenantCaller | null {\n const caller = ctx.session.auth.initiator ?? ctx.session.auth.current;\n if (caller?.principalType !== \"user\") {\n return null;\n }\n\n const email = readStringAttribute(caller.attributes, \"email\");\n const name = readStringAttribute(caller.attributes, \"name\");\n const tenantSlug =\n readStringAttribute(caller.attributes, \"tenantSlug\") ??\n readStringAttribute(caller.attributes, \"tenantId\");\n const role = parseTenantRole(readStringAttribute(caller.attributes, \"role\"));\n if (!email || !tenantSlug || !caller.principalId || !role) {\n return null;\n }\n\n const workosUserId = readStringAttribute(caller.attributes, \"workosUserId\");\n const connectionId = readStringAttribute(caller.attributes, \"connectionId\");\n const groups = readStringArrayAttribute(caller.attributes, \"groups\");\n\n return {\n userId: caller.principalId,\n email,\n name: name ?? email.split(\"@\")[0] ?? email,\n tenantSlug,\n ...(connectionId ? { connectionId } : {}),\n role,\n isAdmin: role === \"admin\",\n groups,\n ...(workosUserId ? { workosUserId } : {}),\n };\n}\n\n/** Like {@link tryResolveTenantCaller} but throws when the session has no user. */\nexport function requireTenantCaller(ctx: SessionContext): TenantCaller {\n const caller = tryResolveTenantCaller(ctx);\n if (!caller) {\n throw new Error(\"An authenticated RobotRock tenant user is required.\");\n }\n return caller;\n}\n\nexport function isAdminCaller(ctx: SessionContext): boolean {\n return tryResolveTenantCaller(ctx)?.isAdmin === true;\n}\n\n/** Require an authenticated tenant admin for the current session. */\nexport function requireAdminCaller(ctx: SessionContext): TenantCaller {\n const caller = requireTenantCaller(ctx);\n if (!caller.isAdmin) {\n throw new Error(\"Tenant admin access is required.\");\n }\n return caller;\n}\n","/** Field name agents read; dashboard widgets must ignore when rendering. */\nexport const TOOL_REPLY_GUIDANCE_FIELD = \"replyGuidance\" as const;\n\nexport const WHOAMI_REPLY_GUIDANCE =\n \"The dashboard shows a profile card with name, email, workspace, role, and groups. Do not restate those in your reply. Only add context not in the card (e.g. permissions, refund approval rules, missing group membership).\";\n\nexport const MY_ACCESS_REPLY_GUIDANCE =\n \"Access details may render in chat UI. Do not restate role, groups, or admin capabilities if already visible. Only explain what the user can or cannot do for their question (e.g. finance group required for refunds ≥ $10,000). When access.tenantAdmin is false and the user needs manageTeam, manageGroups, or query-tasks capabilities, explain briefly then call ask_question to offer sending an admin request to tenant admins — do not tell them to find an admin manually without offering delegation first.\";\n\nexport const CREATE_INBOX_TASK_REPLY_GUIDANCE =\n \"A task card shows title, assignee, and inbox status in chat. Do not restate task ID, assignee, or delegation details from the card. Only mention next steps or answer the user's question.\";\n\nexport const SEARCH_PRODUCTS_REPLY_GUIDANCE =\n \"Product results render as a list card in chat. Do not restate product names, prices, or SKUs. Only add context not in the list (e.g. no matches, recommendations).\";\n\nexport const MANAGE_TEAM_MEMBERS_LIST_REPLY_GUIDANCE =\n \"Team members render as a list card in chat. Do not restate names, emails, or roles from the list. Only add context not shown (e.g. duplicates, next admin actions).\";\n\nexport const MANAGE_TEAM_MEMBERS_DETAIL_REPLY_GUIDANCE =\n \"Team member details render in chat UI. Do not restate name, email, or role from the card. Only add next steps or policy context.\";\n\nexport const MANAGE_GROUPS_LIST_REPLY_GUIDANCE =\n \"Groups render as a list card in chat. Do not restate group names, slugs, or descriptions from the list. Use slug (not internal id) for get, update, delete, and membership actions. Only add context not shown.\";\n\nexport const MANAGE_GROUPS_DETAIL_REPLY_GUIDANCE =\n \"Group details render in chat UI. Do not restate fields already visible in the card. Only add next steps.\";\n\nexport const QUERY_TASKS_LIST_REPLY_GUIDANCE =\n \"Tasks render as a list card in chat. Do not restate task names, ids, or statuses from the list. Only add context not shown (e.g. filters applied, recommended next action).\";\n\nexport const QUERY_TASKS_DETAIL_REPLY_GUIDANCE =\n \"Task details render in chat UI. Do not restate fields already visible in the card. Only add analysis or next steps.\";\n\nexport const ASSIGN_TASKS_REPLY_GUIDANCE =\n \"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.\";\n\nexport const REFUND_CHARGE_REPLY_GUIDANCE =\n \"Refund details render in chat UI. Do not restate charge id, amount, or status from the card. Only add policy context or next steps.\";\n\nexport const DEPLOY_RELEASE_REPLY_GUIDANCE =\n \"Deploy details render in chat UI. Do not restate service, version, or environment from the card. Only add rollout context or next steps.\";\n\nexport const GET_WEATHER_REPLY_GUIDANCE =\n \"Weather details render in chat UI. Do not restate city, condition, or temperature from the card. Only add conversational context if needed.\";\n\nexport const ADMIN_MUTATION_REPLY_GUIDANCE =\n \"The action result renders in chat UI. Do not restate fields already visible in the card. Confirm outcome briefly or add next steps only.\";\n\nexport type ToolResultWithReplyGuidance<T extends Record<string, unknown>> = T & {\n replyGuidance: string;\n};\n\n/** Attach model-facing narration hints to a tool execute result. */\nexport function withReplyGuidance<T extends Record<string, unknown>>(\n result: T,\n guidance: string\n): ToolResultWithReplyGuidance<T> {\n return {\n ...result,\n [TOOL_REPLY_GUIDANCE_FIELD]: guidance,\n };\n}\n\n/** Remove agent-only fields before showing raw JSON in the dashboard. */\nexport function stripAgentOnlyToolFields(output: unknown): unknown {\n if (typeof output !== \"object\" || output === null || Array.isArray(output)) {\n return output;\n }\n\n const record = { ...(output as Record<string, unknown>) };\n delete record[TOOL_REPLY_GUIDANCE_FIELD];\n return record;\n}\n","import type {\n ToolDisplayEnvelope,\n ToolDisplayMetadata,\n UiSchema,\n} from \"@robotrock/core/schemas\";\n\nexport type ToolDisplayResultOptions = {\n widget?: string;\n title?: string;\n description?: string;\n ui?: Record<string, UiSchema>;\n};\n\n/**\n * Wrap tool execute output with optional dashboard display hints.\n * Agents return plain JSON by default; use this when schema-driven widgets help.\n */\nexport function toolDisplayResult<T extends Record<string, unknown>>(\n data: T,\n options?: ToolDisplayResultOptions\n): ToolDisplayEnvelope<T> {\n const display: ToolDisplayMetadata | undefined =\n options?.widget || options?.title || options?.description\n ? {\n ...(options.widget ? { widget: options.widget } : {}),\n ...(options.title ? { title: options.title } : {}),\n ...(options.description ? { description: options.description } : {}),\n }\n : undefined;\n\n return {\n ...(display ? { display } : {}),\n data,\n ...(options?.ui ? { ui: options.ui } : {}),\n };\n}\n","import type { UiSchema } from \"@robotrock/core/schemas\";\nimport { toolDisplayResult } from \"./tool-result-display.js\";\nimport { withReplyGuidance } from \"./tool-reply-guidance.js\";\n\nexport type FormatToolObjectResultOptions = {\n title?: string;\n description?: string;\n ui?: Record<string, UiSchema>;\n replyGuidance: string;\n};\n\nexport type FormatToolListResultOptions = {\n title: string;\n itemUi?: UiSchema;\n /** Composite widget for each row (uses list layout instead of table). */\n itemWidget?: string;\n replyGuidance: string;\n};\n\n/** Wrap a flat object for schema-driven chat rendering. */\nexport function formatToolObjectResult(\n data: Record<string, unknown>,\n options: FormatToolObjectResultOptions\n) {\n return withReplyGuidance(\n toolDisplayResult(data, {\n title: options.title,\n description: options.description,\n ui: options.ui,\n }),\n options.replyGuidance\n );\n}\n\n/** Wrap an array field as a list widget inside a display envelope. */\nexport function formatToolListResult(\n listKey: string,\n items: Record<string, unknown>[],\n options: FormatToolListResultOptions\n) {\n const listFieldUi = options.itemWidget\n ? {\n \"ui:widget\": \"list\" as const,\n items: {\n \"ui:widget\": options.itemWidget,\n ...(options.itemUi ?? {}),\n },\n }\n : {\n \"ui:widget\": \"table\" as const,\n ...(options.itemUi ? { items: options.itemUi } : {}),\n };\n\n return formatToolObjectResult(\n { [listKey]: items },\n {\n title: options.title,\n ui: {\n [listKey]: listFieldUi,\n },\n replyGuidance: options.replyGuidance,\n }\n );\n}\n\nexport function isAgentAdminErrorResult(\n result: unknown\n): result is { ok: false; message: string } {\n return (\n typeof result === \"object\" &&\n result !== null &&\n (result as { ok?: unknown }).ok === false &&\n typeof (result as { message?: unknown }).message === \"string\"\n );\n}\n","import { formatToolObjectResult } from \"../../tool-display-format.js\";\nimport { MY_ACCESS_REPLY_GUIDANCE } from \"../../tool-reply-guidance.js\";\n\ntype MyAccessResultInput = {\n tenantSlug: string;\n tenantRole?: string;\n isTenantAdmin: boolean;\n groupSlugs: string[];\n capabilities: {\n manageSettings: boolean;\n manageBilling: boolean;\n manageTeam: boolean;\n manageIntegrations: boolean;\n };\n email?: string;\n};\n\nconst ACCESS_FIELD_UI = {\n workspace: { \"ui:title\": \"Workspace\" },\n role: { \"ui:title\": \"Role\" },\n tenantAdmin: { \"ui:title\": \"Tenant admin\", \"ui:widget\": \"boolean\" },\n groups: { \"ui:title\": \"Groups\" },\n manageSettings: { \"ui:title\": \"Manage settings\", \"ui:widget\": \"boolean\" },\n manageBilling: { \"ui:title\": \"Manage billing\", \"ui:widget\": \"boolean\" },\n manageTeam: { \"ui:title\": \"Manage team\", \"ui:widget\": \"boolean\" },\n manageIntegrations: {\n \"ui:title\": \"Manage integrations\",\n \"ui:widget\": \"boolean\",\n },\n email: { \"ui:title\": \"Email\" },\n} as const;\n\nexport function formatMyAccessResult(input: MyAccessResultInput) {\n return formatToolObjectResult(\n {\n access: {\n workspace: input.tenantSlug,\n role: input.tenantRole ?? \"member\",\n tenantAdmin: input.isTenantAdmin,\n groups: input.groupSlugs.join(\", \") || \"—\",\n manageSettings: input.capabilities.manageSettings,\n manageBilling: input.capabilities.manageBilling,\n manageTeam: input.capabilities.manageTeam,\n manageIntegrations: input.capabilities.manageIntegrations,\n ...(input.email ? { email: input.email } : {}),\n },\n },\n {\n ui: {\n access: {\n \"ui:widget\": \"access\",\n \"ui:title\": \"Your access\",\n items: ACCESS_FIELD_UI,\n },\n },\n replyGuidance: MY_ACCESS_REPLY_GUIDANCE,\n }\n );\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,SAAS;;;ACDX,SAAS,oBACd,YACA,KACoB;AACpB,QAAM,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uBAAuB,GAAG;AACzC,UAAI,CAAC,QAAQ;AACX,eAAO;AAAA,UACL;AAAA,YACE,eAAe;AAAA,YACf,SACE;AAAA,UACJ;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAEA,aAAO,qBAAqB;AAAA,QAC1B,YAAY,OAAO;AAAA,QACnB,YAAY,OAAO;AAAA,QACnB,eAAe,OAAO;AAAA,QACtB,YAAY,OAAO;AAAA,QACnB,cAAc,mBAAmB,OAAO,OAAO;AAAA,QAC/C,OAAO,OAAO;AAAA,MAChB,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;AAEO,IAAM,eAAe,mBAAmB;","names":[]}
@@ -1,14 +1,15 @@
1
1
  import * as eve_tools from 'eve/tools';
2
2
  import { T as TenantRole } from '../../../tenant-5YKDrdC-.js';
3
+ import { T as ToolResultWithReplyGuidance } from '../../../tool-reply-guidance-C3qrT1In.js';
3
4
  import { z } from 'zod';
4
5
  import 'eve/context';
5
6
 
6
7
  declare const WHOAMI_TOOL_NAME = "whoami";
7
8
  declare const whoamiInputSchema: z.ZodObject<{}, z.core.$strip>;
8
- declare function defineWhoamiTool(): eve_tools.ToolDefinition<Record<string, never>, {
9
+ declare function defineWhoamiTool(): eve_tools.ToolDefinition<Record<string, never>, ToolResultWithReplyGuidance<{
9
10
  authenticated: false;
10
11
  message: string;
11
- } | {
12
+ }> | ToolResultWithReplyGuidance<{
12
13
  sessionId: string;
13
14
  workosUserId?: string | undefined;
14
15
  authenticated: true;
@@ -21,12 +22,11 @@ declare function defineWhoamiTool(): eve_tools.ToolDefinition<Record<string, nev
21
22
  groups: {
22
23
  slug: string;
23
24
  }[];
24
- message?: undefined;
25
- }>;
26
- declare const whoamiTool: eve_tools.ToolDefinition<Record<string, never>, {
25
+ }>>;
26
+ declare const whoamiTool: eve_tools.ToolDefinition<Record<string, never>, ToolResultWithReplyGuidance<{
27
27
  authenticated: false;
28
28
  message: string;
29
- } | {
29
+ }> | ToolResultWithReplyGuidance<{
30
30
  sessionId: string;
31
31
  workosUserId?: string | undefined;
32
32
  authenticated: true;
@@ -39,7 +39,6 @@ declare const whoamiTool: eve_tools.ToolDefinition<Record<string, never>, {
39
39
  groups: {
40
40
  slug: string;
41
41
  }[];
42
- message?: undefined;
43
- }>;
42
+ }>>;
44
43
 
45
44
  export { WHOAMI_TOOL_NAME, defineWhoamiTool, whoamiInputSchema, whoamiTool };
@@ -61,33 +61,49 @@ function tryResolveTenantCaller(ctx) {
61
61
  };
62
62
  }
63
63
 
64
+ // src/eve/tool-reply-guidance.ts
65
+ var TOOL_REPLY_GUIDANCE_FIELD = "replyGuidance";
66
+ var WHOAMI_REPLY_GUIDANCE = "The dashboard shows a profile card with name, email, workspace, role, and groups. Do not restate those in your reply. Only add context not in the card (e.g. permissions, refund approval rules, missing group membership).";
67
+ function withReplyGuidance(result, guidance) {
68
+ return {
69
+ ...result,
70
+ [TOOL_REPLY_GUIDANCE_FIELD]: guidance
71
+ };
72
+ }
73
+
64
74
  // src/eve/tools/identity/whoami.ts
65
75
  var WHOAMI_TOOL_NAME = "whoami";
66
76
  var whoamiInputSchema = z.object({});
67
77
  function defineWhoamiTool() {
68
78
  return defineTool({
69
- description: "Return the authenticated RobotRock user, tenant, role, and group memberships for the current chat session.",
79
+ description: "Return the authenticated RobotRock user, tenant, role, and group memberships for the current chat session. The dashboard renders a profile card \u2014 do not repeat name, email, workspace, role, or groups in your reply; only add context not shown in the card.",
70
80
  inputSchema: whoamiInputSchema,
71
81
  async execute(_input, ctx) {
72
82
  const caller = tryResolveTenantCaller(ctx);
73
83
  if (!caller) {
74
- return {
75
- authenticated: false,
76
- message: "No RobotRock user is attached to this session. Dashboard chat supplies user context via the Eve proxy."
77
- };
84
+ return withReplyGuidance(
85
+ {
86
+ authenticated: false,
87
+ message: "No RobotRock user is attached to this session. Dashboard chat supplies user context via the Eve proxy."
88
+ },
89
+ "Explain that no user is attached to this session. Do not invent identity details."
90
+ );
78
91
  }
79
- return {
80
- authenticated: true,
81
- userId: caller.userId,
82
- name: caller.name,
83
- email: caller.email,
84
- tenantSlug: caller.tenantSlug,
85
- role: caller.role,
86
- isAdmin: caller.isAdmin,
87
- groups: caller.groups.map((slug) => ({ slug })),
88
- ...caller.workosUserId ? { workosUserId: caller.workosUserId } : {},
89
- sessionId: ctx.session.id
90
- };
92
+ return withReplyGuidance(
93
+ {
94
+ authenticated: true,
95
+ userId: caller.userId,
96
+ name: caller.name,
97
+ email: caller.email,
98
+ tenantSlug: caller.tenantSlug,
99
+ role: caller.role,
100
+ isAdmin: caller.isAdmin,
101
+ groups: caller.groups.map((slug) => ({ slug })),
102
+ ...caller.workosUserId ? { workosUserId: caller.workosUserId } : {},
103
+ sessionId: ctx.session.id
104
+ },
105
+ WHOAMI_REPLY_GUIDANCE
106
+ );
91
107
  }
92
108
  });
93
109
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/eve/tools/identity/whoami.ts","../../../../src/eve/agent/attributes.ts","../../../../src/eve/agent/tenant.ts"],"sourcesContent":["import { defineTool } from \"eve/tools\";\nimport { z } from \"zod\";\nimport { tryResolveTenantCaller } from \"../../agent/tenant.js\";\n\nexport const WHOAMI_TOOL_NAME = \"whoami\";\n\nexport const whoamiInputSchema = z.object({});\n\nexport function defineWhoamiTool() {\n return defineTool({\n description:\n \"Return the authenticated RobotRock user, tenant, role, and group memberships for the current chat session.\",\n inputSchema: whoamiInputSchema,\n async execute(_input, ctx) {\n const caller = tryResolveTenantCaller(ctx);\n if (!caller) {\n return {\n authenticated: false as const,\n message:\n \"No RobotRock user is attached to this session. Dashboard chat supplies user context via the Eve proxy.\",\n };\n }\n\n return {\n authenticated: true as const,\n userId: caller.userId,\n name: caller.name,\n email: caller.email,\n tenantSlug: caller.tenantSlug,\n role: caller.role,\n isAdmin: caller.isAdmin,\n groups: caller.groups.map((slug) => ({ slug })),\n ...(caller.workosUserId ? { workosUserId: caller.workosUserId } : {}),\n sessionId: ctx.session.id,\n };\n },\n });\n}\n\nexport const whoamiTool = defineWhoamiTool();\n","export function readStringAttribute(\n attributes: Readonly<Record<string, string | readonly string[]>> | undefined,\n key: string\n): string | undefined {\n const value = attributes?.[key];\n if (typeof value === \"string\" && value.length > 0) {\n return value;\n }\n if (Array.isArray(value) && typeof value[0] === \"string\" && value[0].length > 0) {\n return value[0];\n }\n return undefined;\n}\n\nexport function readStringArrayAttribute(\n attributes: Readonly<Record<string, string | readonly string[]>> | undefined,\n key: string\n): string[] {\n const value = attributes?.[key];\n if (typeof value === \"string\" && value.length > 0) {\n return [value];\n }\n if (Array.isArray(value)) {\n return value.filter(\n (entry): entry is string => typeof entry === \"string\" && entry.length > 0\n );\n }\n return [];\n}\n\nexport function parseTenantRole(\n value: string | undefined\n): \"admin\" | \"member\" | null {\n if (value === \"admin\" || value === \"member\") {\n return value;\n }\n return null;\n}\n","import type { SessionContext } from \"eve/context\";\nimport {\n parseTenantRole,\n readStringArrayAttribute,\n readStringAttribute,\n} from \"./attributes.js\";\n\nexport type TenantRole = \"admin\" | \"member\";\n\nexport type TenantCaller = {\n userId: string;\n email: string;\n name: string;\n tenantSlug: string;\n connectionId?: string;\n role: TenantRole;\n isAdmin: boolean;\n groups: string[];\n workosUserId?: string;\n};\n\n/** Resolve the authenticated RobotRock dashboard user for the current session. */\nexport function tryResolveTenantCaller(ctx: SessionContext): TenantCaller | null {\n const caller = ctx.session.auth.initiator ?? ctx.session.auth.current;\n if (caller?.principalType !== \"user\") {\n return null;\n }\n\n const email = readStringAttribute(caller.attributes, \"email\");\n const name = readStringAttribute(caller.attributes, \"name\");\n const tenantSlug =\n readStringAttribute(caller.attributes, \"tenantSlug\") ??\n readStringAttribute(caller.attributes, \"tenantId\");\n const role = parseTenantRole(readStringAttribute(caller.attributes, \"role\"));\n if (!email || !tenantSlug || !caller.principalId || !role) {\n return null;\n }\n\n const workosUserId = readStringAttribute(caller.attributes, \"workosUserId\");\n const connectionId = readStringAttribute(caller.attributes, \"connectionId\");\n const groups = readStringArrayAttribute(caller.attributes, \"groups\");\n\n return {\n userId: caller.principalId,\n email,\n name: name ?? email.split(\"@\")[0] ?? email,\n tenantSlug,\n ...(connectionId ? { connectionId } : {}),\n role,\n isAdmin: role === \"admin\",\n groups,\n ...(workosUserId ? { workosUserId } : {}),\n };\n}\n\n/** Like {@link tryResolveTenantCaller} but throws when the session has no user. */\nexport function requireTenantCaller(ctx: SessionContext): TenantCaller {\n const caller = tryResolveTenantCaller(ctx);\n if (!caller) {\n throw new Error(\"An authenticated RobotRock tenant user is required.\");\n }\n return caller;\n}\n\nexport function isAdminCaller(ctx: SessionContext): boolean {\n return tryResolveTenantCaller(ctx)?.isAdmin === true;\n}\n\n/** Require an authenticated tenant admin for the current session. */\nexport function requireAdminCaller(ctx: SessionContext): TenantCaller {\n const caller = requireTenantCaller(ctx);\n if (!caller.isAdmin) {\n throw new Error(\"Tenant admin access is required.\");\n }\n return caller;\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,SAAS;;;ACDX,SAAS,oBACd,YACA,KACoB;AACpB,QAAM,QAAQ,aAAa,GAAG;AAC9B,MAAI,OAAO,UAAU,YAAY,MAAM,SAAS,GAAG;AACjD,WAAO;AAAA,EACT;AACA,MAAI,MAAM,QAAQ,KAAK,KAAK,OAAO,MAAM,CAAC,MAAM,YAAY,MAAM,CAAC,EAAE,SAAS,GAAG;AAC/E,WAAO,MAAM,CAAC;AAAA,EAChB;AACA,SAAO;AACT;AAEO,SAAS,yBACd,YACA,KACU;AACV,QAAM,QAAQ,aAAa,GAAG;AAC9B,MAAI,OAAO,UAAU,YAAY,MAAM,SAAS,GAAG;AACjD,WAAO,CAAC,KAAK;AAAA,EACf;AACA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM;AAAA,MACX,CAAC,UAA2B,OAAO,UAAU,YAAY,MAAM,SAAS;AAAA,IAC1E;AAAA,EACF;AACA,SAAO,CAAC;AACV;AAEO,SAAS,gBACd,OAC2B;AAC3B,MAAI,UAAU,WAAW,UAAU,UA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;AAEA,aAAO;AAAA,QACL,eAAe;AAAA,QACf,QAAQ,OAAO;AAAA,QACf,MAAM,OAAO;AAAA,QACb,OAAO,OAAO;AAAA,QACd,YAAY,OAAO;AAAA,QACnB,MAAM,OAAO;AAAA,QACb,SAAS,OAAO;AAAA,QAChB,QAAQ,OAAO,OAAO,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE;AAAA,QAC9C,GAAI,OAAO,eAAe,EAAE,cAAc,OAAO,aAAa,IAAI,CAAC;AAAA,QACnE,WAAW,IAAI,QAAQ;AAAA,MACzB;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEO,IAAM,aAAa,iBAAiB;","names":[]}
1
+ {"version":3,"sources":["../../../../src/eve/tools/identity/whoami.ts","../../../../src/eve/agent/attributes.ts","../../../../src/eve/agent/tenant.ts","../../../../src/eve/tool-reply-guidance.ts"],"sourcesContent":["import { defineTool } from \"eve/tools\";\nimport { z } from \"zod\";\nimport { tryResolveTenantCaller } from \"../../agent/tenant.js\";\nimport {\n WHOAMI_REPLY_GUIDANCE,\n withReplyGuidance,\n} from \"../../tool-reply-guidance.js\";\n\nexport const WHOAMI_TOOL_NAME = \"whoami\";\n\nexport const whoamiInputSchema = z.object({});\n\nexport function defineWhoamiTool() {\n return defineTool({\n description:\n \"Return the authenticated RobotRock user, tenant, role, and group memberships for the current chat session. \" +\n \"The dashboard renders a profile card — do not repeat name, email, workspace, role, or groups in your reply; only add context not shown in the card.\",\n inputSchema: whoamiInputSchema,\n async execute(_input, ctx) {\n const caller = tryResolveTenantCaller(ctx);\n if (!caller) {\n return withReplyGuidance(\n {\n authenticated: false as const,\n message:\n \"No RobotRock user is attached to this session. Dashboard chat supplies user context via the Eve proxy.\",\n },\n \"Explain that no user is attached to this session. Do not invent identity details.\"\n );\n }\n\n return withReplyGuidance(\n {\n authenticated: true as const,\n userId: caller.userId,\n name: caller.name,\n email: caller.email,\n tenantSlug: caller.tenantSlug,\n role: caller.role,\n isAdmin: caller.isAdmin,\n groups: caller.groups.map((slug) => ({ slug })),\n ...(caller.workosUserId ? { workosUserId: caller.workosUserId } : {}),\n sessionId: ctx.session.id,\n },\n WHOAMI_REPLY_GUIDANCE\n );\n },\n });\n}\n\nexport const whoamiTool = defineWhoamiTool();\n","export function readStringAttribute(\n attributes: Readonly<Record<string, string | readonly string[]>> | undefined,\n key: string\n): string | undefined {\n const value = attributes?.[key];\n if (typeof value === \"string\" && value.length > 0) {\n return value;\n }\n if (Array.isArray(value) && typeof value[0] === \"string\" && value[0].length > 0) {\n return value[0];\n }\n return undefined;\n}\n\nexport function readStringArrayAttribute(\n attributes: Readonly<Record<string, string | readonly string[]>> | undefined,\n key: string\n): string[] {\n const value = attributes?.[key];\n if (typeof value === \"string\" && value.length > 0) {\n return [value];\n }\n if (Array.isArray(value)) {\n return value.filter(\n (entry): entry is string => typeof entry === \"string\" && entry.length > 0\n );\n }\n return [];\n}\n\nexport function parseTenantRole(\n value: string | undefined\n): \"admin\" | \"member\" | null {\n if (value === \"admin\" || value === \"member\") {\n return value;\n }\n return null;\n}\n","import type { SessionContext } from \"eve/context\";\nimport {\n parseTenantRole,\n readStringArrayAttribute,\n readStringAttribute,\n} from \"./attributes.js\";\n\nexport type TenantRole = \"admin\" | \"member\";\n\nexport type TenantCaller = {\n userId: string;\n email: string;\n name: string;\n tenantSlug: string;\n connectionId?: string;\n role: TenantRole;\n isAdmin: boolean;\n groups: string[];\n workosUserId?: string;\n};\n\n/** Resolve the authenticated RobotRock dashboard user for the current session. */\nexport function tryResolveTenantCaller(ctx: SessionContext): TenantCaller | null {\n const caller = ctx.session.auth.initiator ?? ctx.session.auth.current;\n if (caller?.principalType !== \"user\") {\n return null;\n }\n\n const email = readStringAttribute(caller.attributes, \"email\");\n const name = readStringAttribute(caller.attributes, \"name\");\n const tenantSlug =\n readStringAttribute(caller.attributes, \"tenantSlug\") ??\n readStringAttribute(caller.attributes, \"tenantId\");\n const role = parseTenantRole(readStringAttribute(caller.attributes, \"role\"));\n if (!email || !tenantSlug || !caller.principalId || !role) {\n return null;\n }\n\n const workosUserId = readStringAttribute(caller.attributes, \"workosUserId\");\n const connectionId = readStringAttribute(caller.attributes, \"connectionId\");\n const groups = readStringArrayAttribute(caller.attributes, \"groups\");\n\n return {\n userId: caller.principalId,\n email,\n name: name ?? email.split(\"@\")[0] ?? email,\n tenantSlug,\n ...(connectionId ? { connectionId } : {}),\n role,\n isAdmin: role === \"admin\",\n groups,\n ...(workosUserId ? { workosUserId } : {}),\n };\n}\n\n/** Like {@link tryResolveTenantCaller} but throws when the session has no user. */\nexport function requireTenantCaller(ctx: SessionContext): TenantCaller {\n const caller = tryResolveTenantCaller(ctx);\n if (!caller) {\n throw new Error(\"An authenticated RobotRock tenant user is required.\");\n }\n return caller;\n}\n\nexport function isAdminCaller(ctx: SessionContext): boolean {\n return tryResolveTenantCaller(ctx)?.isAdmin === true;\n}\n\n/** Require an authenticated tenant admin for the current session. */\nexport function requireAdminCaller(ctx: SessionContext): TenantCaller {\n const caller = requireTenantCaller(ctx);\n if (!caller.isAdmin) {\n throw new Error(\"Tenant admin access is required.\");\n }\n return caller;\n}\n","/** Field name agents read; dashboard widgets must ignore when rendering. */\nexport const TOOL_REPLY_GUIDANCE_FIELD = \"replyGuidance\" as const;\n\nexport const WHOAMI_REPLY_GUIDANCE =\n \"The dashboard shows a profile card with name, email, workspace, role, and groups. Do not restate those in your reply. Only add context not in the card (e.g. permissions, refund approval rules, missing group membership).\";\n\nexport const MY_ACCESS_REPLY_GUIDANCE =\n \"Access details may render in chat UI. Do not restate role, groups, or admin capabilities if already visible. Only explain what the user can or cannot do for their question (e.g. finance group required for refunds ≥ $10,000). When access.tenantAdmin is false and the user needs manageTeam, manageGroups, or query-tasks capabilities, explain briefly then call ask_question to offer sending an admin request to tenant admins — do not tell them to find an admin manually without offering delegation first.\";\n\nexport const CREATE_INBOX_TASK_REPLY_GUIDANCE =\n \"A task card shows title, assignee, and inbox status in chat. Do not restate task ID, assignee, or delegation details from the card. Only mention next steps or answer the user's question.\";\n\nexport const SEARCH_PRODUCTS_REPLY_GUIDANCE =\n \"Product results render as a list card in chat. Do not restate product names, prices, or SKUs. Only add context not in the list (e.g. no matches, recommendations).\";\n\nexport const MANAGE_TEAM_MEMBERS_LIST_REPLY_GUIDANCE =\n \"Team members render as a list card in chat. Do not restate names, emails, or roles from the list. Only add context not shown (e.g. duplicates, next admin actions).\";\n\nexport const MANAGE_TEAM_MEMBERS_DETAIL_REPLY_GUIDANCE =\n \"Team member details render in chat UI. Do not restate name, email, or role from the card. Only add next steps or policy context.\";\n\nexport const MANAGE_GROUPS_LIST_REPLY_GUIDANCE =\n \"Groups render as a list card in chat. Do not restate group names, slugs, or descriptions from the list. Use slug (not internal id) for get, update, delete, and membership actions. Only add context not shown.\";\n\nexport const MANAGE_GROUPS_DETAIL_REPLY_GUIDANCE =\n \"Group details render in chat UI. Do not restate fields already visible in the card. Only add next steps.\";\n\nexport const QUERY_TASKS_LIST_REPLY_GUIDANCE =\n \"Tasks render as a list card in chat. Do not restate task names, ids, or statuses from the list. Only add context not shown (e.g. filters applied, recommended next action).\";\n\nexport const QUERY_TASKS_DETAIL_REPLY_GUIDANCE =\n \"Task details render in chat UI. Do not restate fields already visible in the card. Only add analysis or next steps.\";\n\nexport const ASSIGN_TASKS_REPLY_GUIDANCE =\n \"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.\";\n\nexport const REFUND_CHARGE_REPLY_GUIDANCE =\n \"Refund details render in chat UI. Do not restate charge id, amount, or status from the card. Only add policy context or next steps.\";\n\nexport const DEPLOY_RELEASE_REPLY_GUIDANCE =\n \"Deploy details render in chat UI. Do not restate service, version, or environment from the card. Only add rollout context or next steps.\";\n\nexport const GET_WEATHER_REPLY_GUIDANCE =\n \"Weather details render in chat UI. Do not restate city, condition, or temperature from the card. Only add conversational context if needed.\";\n\nexport const ADMIN_MUTATION_REPLY_GUIDANCE =\n \"The action result renders in chat UI. Do not restate fields already visible in the card. Confirm outcome briefly or add next steps only.\";\n\nexport type ToolResultWithReplyGuidance<T extends Record<string, unknown>> = T & {\n replyGuidance: string;\n};\n\n/** Attach model-facing narration hints to a tool execute result. */\nexport function withReplyGuidance<T extends Record<string, unknown>>(\n result: T,\n guidance: string\n): ToolResultWithReplyGuidance<T> {\n return {\n ...result,\n [TOOL_REPLY_GUIDANCE_FIELD]: guidance,\n };\n}\n\n/** Remove agent-only fields before showing raw JSON in the dashboard. */\nexport function stripAgentOnlyToolFields(output: unknown): unknown {\n if (typeof output !== \"object\" || output === null || Array.isArray(output)) {\n return output;\n }\n\n const record = { ...(output as Record<string, unknown>) };\n delete record[TOOL_REPLY_GUIDANCE_FIELD];\n return record;\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,SAAS;;;ACDX,SAAS,oBACd,YACA,KACoB;AACpB,QAAM,QAAQ,aAAa,GAAG;AAC9B,MAAI,OAAO,UAAU,YAAY,MAAM,SAAS,GAAG;AACjD,WAAO;AAAA,EACT;AACA,MAAI,MAAM,QAAQ,KAAK,KAAK,OAAO,MAAM,CAAC,MAAM,YAAY,MAAM,CAAC,EAAE,SAAS,GAAG;AAC/E,WAAO,MAAM,CAAC;AAAA,EAChB;AACA,SAAO;AACT;AAEO,SAAS,yBACd,YACA,KACU;AACV,QAAM,QAAQ,aAAa,GAAG;AAC9B,MAAI,OAAO,UAAU,YAAY,MAAM,SAAS,GAAG;AACjD,WAAO,CAAC,KAAK;AAAA,EACf;AACA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM;AAAA,MACX,CAAC,UAA2B,OAAO,UAAU,YAAY,MAAM,SAAS;AAAA,IAC1E;AAAA,EACF;AACA,SAAO,CAAC;AACV;AAEO,SAAS,gBACd,OAC2B;AAC3B,MAAI,UAAU,WAAW,UAAU,UAAU;AAC3C,WAAO;AAAA,EACT;AACA,SAAO;AACT;;;ACfO,SAAS,uBAAuB,KAA0C;AAC/E,QAAM,SAAS,IAAI,QAAQ,K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;AAAA,YACE,eAAe;AAAA,YACf,SACE;AAAA,UACJ;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAEA,aAAO;AAAA,QACL;AAAA,UACE,eAAe;AAAA,UACf,QAAQ,OAAO;AAAA,UACf,MAAM,OAAO;AAAA,UACb,OAAO,OAAO;AAAA,UACd,YAAY,OAAO;AAAA,UACnB,MAAM,OAAO;AAAA,UACb,SAAS,OAAO;AAAA,UAChB,QAAQ,OAAO,OAAO,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE;AAAA,UAC9C,GAAI,OAAO,eAAe,EAAE,cAAc,OAAO,aAAa,IAAI,CAAC;AAAA,UACnE,WAAW,IAAI,QAAQ;AAAA,QACzB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEO,IAAM,aAAa,iBAAiB;","names":[]}
@@ -1,4 +1,5 @@
1
1
  import * as eve_tools from 'eve/tools';
2
+ import { T as ToolResultWithReplyGuidance } from '../../../tool-reply-guidance-C3qrT1In.js';
2
3
  import { z } from 'zod';
3
4
  import { a as TenantCaller } from '../../../tenant-5YKDrdC-.js';
4
5
  import 'eve/context';
@@ -58,7 +59,7 @@ declare function defineCreateInboxTaskTool(options?: DefineCreateInboxTaskToolOp
58
59
  priority?: "low" | "normal" | "high" | "urgent" | undefined;
59
60
  updateMessage?: string | undefined;
60
61
  delegationReason?: string | undefined;
61
- }, {
62
+ }, ToolResultWithReplyGuidance<{
62
63
  name: string;
63
64
  assignedTo: {
64
65
  users?: string[] | undefined;
@@ -72,7 +73,7 @@ declare function defineCreateInboxTaskTool(options?: DefineCreateInboxTaskToolOp
72
73
  status: "pending" | "open";
73
74
  validUntil: string;
74
75
  submittedAt: string;
75
- }>;
76
+ }>>;
76
77
  declare const createInboxTaskTool: eve_tools.ToolDefinition<{
77
78
  type: string;
78
79
  name: string;
@@ -94,7 +95,7 @@ declare const createInboxTaskTool: eve_tools.ToolDefinition<{
94
95
  priority?: "low" | "normal" | "high" | "urgent" | undefined;
95
96
  updateMessage?: string | undefined;
96
97
  delegationReason?: string | undefined;
97
- }, {
98
+ }, ToolResultWithReplyGuidance<{
98
99
  name: string;
99
100
  assignedTo: {
100
101
  users?: string[] | undefined;
@@ -108,6 +109,6 @@ declare const createInboxTaskTool: eve_tools.ToolDefinition<{
108
109
  status: "pending" | "open";
109
110
  validUntil: string;
110
111
  submittedAt: string;
111
- }>;
112
+ }>>;
112
113
 
113
114
  export { CREATE_INBOX_TASK_TOOL_NAME, type CreateInboxTaskToolInput, type DefineCreateInboxTaskToolOptions, createInboxTaskInputSchema, createInboxTaskTool, defineCreateInboxTaskTool };