robotrock 1.0.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.
- package/dist/agent-admin.d.ts +82 -0
- package/dist/agent-admin.js +938 -0
- package/dist/agent-admin.js.map +1 -0
- package/dist/ai/index.d.ts +6 -5
- package/dist/ai/index.js +682 -225
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/trigger.d.ts +4 -3
- package/dist/ai/trigger.js +682 -225
- package/dist/ai/trigger.js.map +1 -1
- package/dist/ai/workflow.d.ts +4 -3
- package/dist/ai/workflow.js +679 -222
- package/dist/ai/workflow.js.map +1 -1
- package/dist/auth-headers-qL-ZeEtd.d.ts +13 -0
- package/dist/{client-CzVmjXpz.d.ts → client-YO9Y1rkH.d.ts} +51 -10
- package/dist/eve/agent/index.d.ts +164 -0
- package/dist/eve/agent/index.js +2854 -0
- package/dist/eve/agent/index.js.map +1 -0
- package/dist/eve/index.d.ts +8 -0
- package/dist/eve/index.js +639 -0
- package/dist/eve/index.js.map +1 -0
- package/dist/eve/tools/admin/assign-tasks.d.ts +39 -0
- package/dist/eve/tools/admin/assign-tasks.js +1060 -0
- package/dist/eve/tools/admin/assign-tasks.js.map +1 -0
- package/dist/eve/tools/admin/manage-groups.d.ts +53 -0
- package/dist/eve/tools/admin/manage-groups.js +1218 -0
- package/dist/eve/tools/admin/manage-groups.js.map +1 -0
- package/dist/eve/tools/admin/manage-team-members.d.ts +45 -0
- package/dist/eve/tools/admin/manage-team-members.js +1160 -0
- package/dist/eve/tools/admin/manage-team-members.js.map +1 -0
- package/dist/eve/tools/admin/query-tasks.d.ts +71 -0
- package/dist/eve/tools/admin/query-tasks.js +1161 -0
- package/dist/eve/tools/admin/query-tasks.js.map +1 -0
- package/dist/eve/tools/catalog/search-products.d.ts +57 -0
- package/dist/eve/tools/catalog/search-products.js +94 -0
- package/dist/eve/tools/catalog/search-products.js.map +1 -0
- package/dist/eve/tools/identity/index.d.ts +8 -0
- package/dist/eve/tools/identity/index.js +234 -0
- package/dist/eve/tools/identity/index.js.map +1 -0
- package/dist/eve/tools/identity/my-access.d.ts +18 -0
- package/dist/eve/tools/identity/my-access.js +187 -0
- package/dist/eve/tools/identity/my-access.js.map +1 -0
- package/dist/eve/tools/identity/whoami.d.ts +44 -0
- package/dist/eve/tools/identity/whoami.js +117 -0
- package/dist/eve/tools/identity/whoami.js.map +1 -0
- package/dist/eve/tools/inbox/create-task.d.ts +114 -0
- package/dist/eve/tools/inbox/create-task.js +1785 -0
- package/dist/eve/tools/inbox/create-task.js.map +1 -0
- package/dist/eve/tools/inbox/index.d.ts +6 -0
- package/dist/eve/tools/inbox/index.js +1785 -0
- package/dist/eve/tools/inbox/index.js.map +1 -0
- package/dist/eve/tools/index.d.ts +24 -0
- package/dist/eve/tools/index.js +2848 -0
- package/dist/eve/tools/index.js.map +1 -0
- package/dist/index-DoQN48Bm.d.ts +200 -0
- package/dist/index.d.ts +8 -44
- package/dist/index.js +842 -137
- package/dist/index.js.map +1 -1
- package/dist/schemas/index.d.ts +6 -1
- package/dist/schemas/index.js +251 -59
- package/dist/schemas/index.js.map +1 -1
- package/dist/tenant-5YKDrdC-.d.ts +23 -0
- package/dist/{tool-approval-bridge-DbwUEBHv.d.ts → tool-approval-bridge-aMA79Z1B.d.ts} +1 -1
- package/dist/tool-reply-guidance-C3qrT1In.d.ts +25 -0
- package/dist/trigger/index.d.ts +2 -1
- package/dist/trigger/index.js +543 -127
- package/dist/trigger/index.js.map +1 -1
- package/dist/{trigger-BCKBbAV7.d.ts → trigger-CXrbKVCL.d.ts} +2 -2
- package/dist/workflow/index.d.ts +2 -1
- package/dist/workflow/index.js +543 -127
- package/dist/workflow/index.js.map +1 -1
- package/package.json +69 -8
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
// src/eve/tools/identity/whoami.ts
|
|
2
|
+
import { defineTool } from "eve/tools";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
// src/eve/agent/attributes.ts
|
|
6
|
+
function readStringAttribute(attributes, key) {
|
|
7
|
+
const value = attributes?.[key];
|
|
8
|
+
if (typeof value === "string" && value.length > 0) {
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
if (Array.isArray(value) && typeof value[0] === "string" && value[0].length > 0) {
|
|
12
|
+
return value[0];
|
|
13
|
+
}
|
|
14
|
+
return void 0;
|
|
15
|
+
}
|
|
16
|
+
function readStringArrayAttribute(attributes, key) {
|
|
17
|
+
const value = attributes?.[key];
|
|
18
|
+
if (typeof value === "string" && value.length > 0) {
|
|
19
|
+
return [value];
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(value)) {
|
|
22
|
+
return value.filter(
|
|
23
|
+
(entry) => typeof entry === "string" && entry.length > 0
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
function parseTenantRole(value) {
|
|
29
|
+
if (value === "admin" || value === "member") {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// src/eve/agent/tenant.ts
|
|
36
|
+
function tryResolveTenantCaller(ctx) {
|
|
37
|
+
const caller = ctx.session.auth.initiator ?? ctx.session.auth.current;
|
|
38
|
+
if (caller?.principalType !== "user") {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const email = readStringAttribute(caller.attributes, "email");
|
|
42
|
+
const name = readStringAttribute(caller.attributes, "name");
|
|
43
|
+
const tenantSlug = readStringAttribute(caller.attributes, "tenantSlug") ?? readStringAttribute(caller.attributes, "tenantId");
|
|
44
|
+
const role = parseTenantRole(readStringAttribute(caller.attributes, "role"));
|
|
45
|
+
if (!email || !tenantSlug || !caller.principalId || !role) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const workosUserId = readStringAttribute(caller.attributes, "workosUserId");
|
|
49
|
+
const connectionId = readStringAttribute(caller.attributes, "connectionId");
|
|
50
|
+
const groups = readStringArrayAttribute(caller.attributes, "groups");
|
|
51
|
+
return {
|
|
52
|
+
userId: caller.principalId,
|
|
53
|
+
email,
|
|
54
|
+
name: name ?? email.split("@")[0] ?? email,
|
|
55
|
+
tenantSlug,
|
|
56
|
+
...connectionId ? { connectionId } : {},
|
|
57
|
+
role,
|
|
58
|
+
isAdmin: role === "admin",
|
|
59
|
+
groups,
|
|
60
|
+
...workosUserId ? { workosUserId } : {}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
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
|
+
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.";
|
|
68
|
+
function withReplyGuidance(result, guidance) {
|
|
69
|
+
return {
|
|
70
|
+
...result,
|
|
71
|
+
[TOOL_REPLY_GUIDANCE_FIELD]: guidance
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// src/eve/tools/identity/whoami.ts
|
|
76
|
+
var WHOAMI_TOOL_NAME = "whoami";
|
|
77
|
+
var whoamiInputSchema = z.object({});
|
|
78
|
+
function defineWhoamiTool() {
|
|
79
|
+
return defineTool({
|
|
80
|
+
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.",
|
|
81
|
+
inputSchema: whoamiInputSchema,
|
|
82
|
+
async execute(_input, ctx) {
|
|
83
|
+
const caller = tryResolveTenantCaller(ctx);
|
|
84
|
+
if (!caller) {
|
|
85
|
+
return withReplyGuidance(
|
|
86
|
+
{
|
|
87
|
+
authenticated: false,
|
|
88
|
+
message: "No RobotRock user is attached to this session. Dashboard chat supplies user context via the Eve proxy."
|
|
89
|
+
},
|
|
90
|
+
"Explain that no user is attached to this session. Do not invent identity details."
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
return withReplyGuidance(
|
|
94
|
+
{
|
|
95
|
+
authenticated: true,
|
|
96
|
+
userId: caller.userId,
|
|
97
|
+
name: caller.name,
|
|
98
|
+
email: caller.email,
|
|
99
|
+
tenantSlug: caller.tenantSlug,
|
|
100
|
+
role: caller.role,
|
|
101
|
+
isAdmin: caller.isAdmin,
|
|
102
|
+
groups: caller.groups.map((slug) => ({ slug })),
|
|
103
|
+
...caller.workosUserId ? { workosUserId: caller.workosUserId } : {},
|
|
104
|
+
sessionId: ctx.session.id
|
|
105
|
+
},
|
|
106
|
+
WHOAMI_REPLY_GUIDANCE
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
var whoamiTool = defineWhoamiTool();
|
|
112
|
+
|
|
113
|
+
// src/eve/tools/identity/my-access.ts
|
|
114
|
+
import { defineTool as defineTool2 } from "eve/tools";
|
|
115
|
+
import { z as z2 } from "zod";
|
|
116
|
+
|
|
117
|
+
// src/eve/tool-result-display.ts
|
|
118
|
+
function toolDisplayResult(data, options) {
|
|
119
|
+
const display = options?.widget || options?.title || options?.description ? {
|
|
120
|
+
...options.widget ? { widget: options.widget } : {},
|
|
121
|
+
...options.title ? { title: options.title } : {},
|
|
122
|
+
...options.description ? { description: options.description } : {}
|
|
123
|
+
} : void 0;
|
|
124
|
+
return {
|
|
125
|
+
...display ? { display } : {},
|
|
126
|
+
data,
|
|
127
|
+
...options?.ui ? { ui: options.ui } : {}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// src/eve/tool-display-format.ts
|
|
132
|
+
function formatToolObjectResult(data, options) {
|
|
133
|
+
return withReplyGuidance(
|
|
134
|
+
toolDisplayResult(data, {
|
|
135
|
+
title: options.title,
|
|
136
|
+
description: options.description,
|
|
137
|
+
ui: options.ui
|
|
138
|
+
}),
|
|
139
|
+
options.replyGuidance
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// src/eve/tools/identity/format-my-access.ts
|
|
144
|
+
var ACCESS_FIELD_UI = {
|
|
145
|
+
workspace: { "ui:title": "Workspace" },
|
|
146
|
+
role: { "ui:title": "Role" },
|
|
147
|
+
tenantAdmin: { "ui:title": "Tenant admin", "ui:widget": "boolean" },
|
|
148
|
+
groups: { "ui:title": "Groups" },
|
|
149
|
+
manageSettings: { "ui:title": "Manage settings", "ui:widget": "boolean" },
|
|
150
|
+
manageBilling: { "ui:title": "Manage billing", "ui:widget": "boolean" },
|
|
151
|
+
manageTeam: { "ui:title": "Manage team", "ui:widget": "boolean" },
|
|
152
|
+
manageIntegrations: {
|
|
153
|
+
"ui:title": "Manage integrations",
|
|
154
|
+
"ui:widget": "boolean"
|
|
155
|
+
},
|
|
156
|
+
email: { "ui:title": "Email" }
|
|
157
|
+
};
|
|
158
|
+
function formatMyAccessResult(input) {
|
|
159
|
+
return formatToolObjectResult(
|
|
160
|
+
{
|
|
161
|
+
access: {
|
|
162
|
+
workspace: input.tenantSlug,
|
|
163
|
+
role: input.tenantRole ?? "member",
|
|
164
|
+
tenantAdmin: input.isTenantAdmin,
|
|
165
|
+
groups: input.groupSlugs.join(", ") || "\u2014",
|
|
166
|
+
manageSettings: input.capabilities.manageSettings,
|
|
167
|
+
manageBilling: input.capabilities.manageBilling,
|
|
168
|
+
manageTeam: input.capabilities.manageTeam,
|
|
169
|
+
manageIntegrations: input.capabilities.manageIntegrations,
|
|
170
|
+
...input.email ? { email: input.email } : {}
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
ui: {
|
|
175
|
+
access: {
|
|
176
|
+
"ui:widget": "access",
|
|
177
|
+
"ui:title": "Your access",
|
|
178
|
+
items: ACCESS_FIELD_UI
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
replyGuidance: MY_ACCESS_REPLY_GUIDANCE
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// src/eve/tools/identity/my-access.ts
|
|
187
|
+
var MY_ACCESS_TOOL_NAME = "get_my_access";
|
|
188
|
+
var myAccessInputSchema = z2.object({});
|
|
189
|
+
function tenantCapabilities(isAdmin) {
|
|
190
|
+
return {
|
|
191
|
+
manageSettings: isAdmin,
|
|
192
|
+
manageBilling: isAdmin,
|
|
193
|
+
manageTeam: isAdmin,
|
|
194
|
+
manageIntegrations: isAdmin
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function defineMyAccessTool() {
|
|
198
|
+
return defineTool2({
|
|
199
|
+
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.",
|
|
200
|
+
inputSchema: myAccessInputSchema,
|
|
201
|
+
async execute(_input, ctx) {
|
|
202
|
+
const caller = tryResolveTenantCaller(ctx);
|
|
203
|
+
if (!caller) {
|
|
204
|
+
return withReplyGuidance(
|
|
205
|
+
{
|
|
206
|
+
authenticated: false,
|
|
207
|
+
message: "No RobotRock user is attached to this session. Dashboard chat supplies user context via the Eve proxy."
|
|
208
|
+
},
|
|
209
|
+
"Explain that no user is attached to this session. Do not invent access details."
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
return formatMyAccessResult({
|
|
213
|
+
tenantSlug: caller.tenantSlug,
|
|
214
|
+
tenantRole: caller.role,
|
|
215
|
+
isTenantAdmin: caller.isAdmin,
|
|
216
|
+
groupSlugs: caller.groups,
|
|
217
|
+
capabilities: tenantCapabilities(caller.isAdmin),
|
|
218
|
+
email: caller.email
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
var myAccessTool = defineMyAccessTool();
|
|
224
|
+
export {
|
|
225
|
+
MY_ACCESS_TOOL_NAME,
|
|
226
|
+
WHOAMI_TOOL_NAME,
|
|
227
|
+
defineMyAccessTool,
|
|
228
|
+
defineWhoamiTool,
|
|
229
|
+
myAccessInputSchema,
|
|
230
|
+
myAccessTool,
|
|
231
|
+
whoamiInputSchema,
|
|
232
|
+
whoamiTool
|
|
233
|
+
};
|
|
234
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,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aACE;AAAA,IAEF,aAAa;AAAA,IACb,MAAM,QAAQ,QAAQ,KAAK;AACzB,YAAM,SAAS,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":["defineTool","z","z","defineTool"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as eve_tools from 'eve/tools';
|
|
2
|
+
import * as _robotrock_core from '@robotrock/core';
|
|
3
|
+
import { T as ToolResultWithReplyGuidance } from '../../../tool-reply-guidance-C3qrT1In.js';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
|
|
6
|
+
/** Eve tool slug — must match the agent tool filename `get_my_access.ts`. */
|
|
7
|
+
declare const MY_ACCESS_TOOL_NAME = "get_my_access";
|
|
8
|
+
declare const myAccessInputSchema: z.ZodObject<{}, z.core.$strip>;
|
|
9
|
+
declare function defineMyAccessTool(): eve_tools.ToolDefinition<Record<string, never>, ToolResultWithReplyGuidance<{
|
|
10
|
+
authenticated: false;
|
|
11
|
+
message: string;
|
|
12
|
+
}> | ToolResultWithReplyGuidance<_robotrock_core.ToolDisplayEnvelope<Record<string, unknown>>>>;
|
|
13
|
+
declare const myAccessTool: eve_tools.ToolDefinition<Record<string, never>, ToolResultWithReplyGuidance<{
|
|
14
|
+
authenticated: false;
|
|
15
|
+
message: string;
|
|
16
|
+
}> | ToolResultWithReplyGuidance<_robotrock_core.ToolDisplayEnvelope<Record<string, unknown>>>>;
|
|
17
|
+
|
|
18
|
+
export { MY_ACCESS_TOOL_NAME, defineMyAccessTool, myAccessInputSchema, myAccessTool };
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
// src/eve/tools/identity/my-access.ts
|
|
2
|
+
import { defineTool } from "eve/tools";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
// src/eve/agent/attributes.ts
|
|
6
|
+
function readStringAttribute(attributes, key) {
|
|
7
|
+
const value = attributes?.[key];
|
|
8
|
+
if (typeof value === "string" && value.length > 0) {
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
if (Array.isArray(value) && typeof value[0] === "string" && value[0].length > 0) {
|
|
12
|
+
return value[0];
|
|
13
|
+
}
|
|
14
|
+
return void 0;
|
|
15
|
+
}
|
|
16
|
+
function readStringArrayAttribute(attributes, key) {
|
|
17
|
+
const value = attributes?.[key];
|
|
18
|
+
if (typeof value === "string" && value.length > 0) {
|
|
19
|
+
return [value];
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(value)) {
|
|
22
|
+
return value.filter(
|
|
23
|
+
(entry) => typeof entry === "string" && entry.length > 0
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
function parseTenantRole(value) {
|
|
29
|
+
if (value === "admin" || value === "member") {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// src/eve/agent/tenant.ts
|
|
36
|
+
function tryResolveTenantCaller(ctx) {
|
|
37
|
+
const caller = ctx.session.auth.initiator ?? ctx.session.auth.current;
|
|
38
|
+
if (caller?.principalType !== "user") {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const email = readStringAttribute(caller.attributes, "email");
|
|
42
|
+
const name = readStringAttribute(caller.attributes, "name");
|
|
43
|
+
const tenantSlug = readStringAttribute(caller.attributes, "tenantSlug") ?? readStringAttribute(caller.attributes, "tenantId");
|
|
44
|
+
const role = parseTenantRole(readStringAttribute(caller.attributes, "role"));
|
|
45
|
+
if (!email || !tenantSlug || !caller.principalId || !role) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const workosUserId = readStringAttribute(caller.attributes, "workosUserId");
|
|
49
|
+
const connectionId = readStringAttribute(caller.attributes, "connectionId");
|
|
50
|
+
const groups = readStringArrayAttribute(caller.attributes, "groups");
|
|
51
|
+
return {
|
|
52
|
+
userId: caller.principalId,
|
|
53
|
+
email,
|
|
54
|
+
name: name ?? email.split("@")[0] ?? email,
|
|
55
|
+
tenantSlug,
|
|
56
|
+
...connectionId ? { connectionId } : {},
|
|
57
|
+
role,
|
|
58
|
+
isAdmin: role === "admin",
|
|
59
|
+
groups,
|
|
60
|
+
...workosUserId ? { workosUserId } : {}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
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
|
+
|
|
143
|
+
// src/eve/tools/identity/my-access.ts
|
|
144
|
+
var MY_ACCESS_TOOL_NAME = "get_my_access";
|
|
145
|
+
var myAccessInputSchema = z.object({});
|
|
146
|
+
function tenantCapabilities(isAdmin) {
|
|
147
|
+
return {
|
|
148
|
+
manageSettings: isAdmin,
|
|
149
|
+
manageBilling: isAdmin,
|
|
150
|
+
manageTeam: isAdmin,
|
|
151
|
+
manageIntegrations: isAdmin
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function defineMyAccessTool() {
|
|
155
|
+
return defineTool({
|
|
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.",
|
|
157
|
+
inputSchema: myAccessInputSchema,
|
|
158
|
+
async execute(_input, ctx) {
|
|
159
|
+
const caller = tryResolveTenantCaller(ctx);
|
|
160
|
+
if (!caller) {
|
|
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
|
+
);
|
|
168
|
+
}
|
|
169
|
+
return formatMyAccessResult({
|
|
170
|
+
tenantSlug: caller.tenantSlug,
|
|
171
|
+
tenantRole: caller.role,
|
|
172
|
+
isTenantAdmin: caller.isAdmin,
|
|
173
|
+
groupSlugs: caller.groups,
|
|
174
|
+
capabilities: tenantCapabilities(caller.isAdmin),
|
|
175
|
+
email: caller.email
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
var myAccessTool = defineMyAccessTool();
|
|
181
|
+
export {
|
|
182
|
+
MY_ACCESS_TOOL_NAME,
|
|
183
|
+
defineMyAccessTool,
|
|
184
|
+
myAccessInputSchema,
|
|
185
|
+
myAccessTool
|
|
186
|
+
};
|
|
187
|
+
//# sourceMappingURL=my-access.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,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,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AAM,eAAe,mBAAmB;","names":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as eve_tools from 'eve/tools';
|
|
2
|
+
import { T as TenantRole } from '../../../tenant-5YKDrdC-.js';
|
|
3
|
+
import { T as ToolResultWithReplyGuidance } from '../../../tool-reply-guidance-C3qrT1In.js';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import 'eve/context';
|
|
6
|
+
|
|
7
|
+
declare const WHOAMI_TOOL_NAME = "whoami";
|
|
8
|
+
declare const whoamiInputSchema: z.ZodObject<{}, z.core.$strip>;
|
|
9
|
+
declare function defineWhoamiTool(): eve_tools.ToolDefinition<Record<string, never>, ToolResultWithReplyGuidance<{
|
|
10
|
+
authenticated: false;
|
|
11
|
+
message: string;
|
|
12
|
+
}> | ToolResultWithReplyGuidance<{
|
|
13
|
+
sessionId: string;
|
|
14
|
+
workosUserId?: string | undefined;
|
|
15
|
+
authenticated: true;
|
|
16
|
+
userId: string;
|
|
17
|
+
name: string;
|
|
18
|
+
email: string;
|
|
19
|
+
tenantSlug: string;
|
|
20
|
+
role: TenantRole;
|
|
21
|
+
isAdmin: boolean;
|
|
22
|
+
groups: {
|
|
23
|
+
slug: string;
|
|
24
|
+
}[];
|
|
25
|
+
}>>;
|
|
26
|
+
declare const whoamiTool: eve_tools.ToolDefinition<Record<string, never>, ToolResultWithReplyGuidance<{
|
|
27
|
+
authenticated: false;
|
|
28
|
+
message: string;
|
|
29
|
+
}> | ToolResultWithReplyGuidance<{
|
|
30
|
+
sessionId: string;
|
|
31
|
+
workosUserId?: string | undefined;
|
|
32
|
+
authenticated: true;
|
|
33
|
+
userId: string;
|
|
34
|
+
name: string;
|
|
35
|
+
email: string;
|
|
36
|
+
tenantSlug: string;
|
|
37
|
+
role: TenantRole;
|
|
38
|
+
isAdmin: boolean;
|
|
39
|
+
groups: {
|
|
40
|
+
slug: string;
|
|
41
|
+
}[];
|
|
42
|
+
}>>;
|
|
43
|
+
|
|
44
|
+
export { WHOAMI_TOOL_NAME, defineWhoamiTool, whoamiInputSchema, whoamiTool };
|