@botmanor/fe-sdk 2026.1205.3 → 2026.1205.5
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/guided-errors-CiQTVYn8.d.ts +386 -0
- package/dist/guided-errors-D5vT9owt.js +2383 -0
- package/dist/guided-errors.d.ts +9 -0
- package/dist/guided-errors.js +4 -0
- package/dist/index.d.ts +160 -6
- package/dist/index.js +1002 -108
- package/package.json +5 -1
|
@@ -0,0 +1,2383 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// src/guided/permissions.ts
|
|
3
|
+
/**
|
|
4
|
+
* Permissions the guided actions need (catalog section 1.5 and assumption 6).
|
|
5
|
+
* They mirror the `@rbac` pairs on the GraphQL fields each action calls; the
|
|
6
|
+
* client hides what the gateway would refuse, and the gateway stays the only
|
|
7
|
+
* enforcement point.
|
|
8
|
+
*/
|
|
9
|
+
const GUIDED_PERMISSIONS = {
|
|
10
|
+
STEWARD_READ: "botmanor-steward:read",
|
|
11
|
+
STEWARD_CREATE: "botmanor-steward:create",
|
|
12
|
+
STEWARD_UPDATE: "botmanor-steward:update",
|
|
13
|
+
STEWARD_EXECUTE: "botmanor-steward:execute",
|
|
14
|
+
STEWARD_MANAGE: "botmanor-steward:manage",
|
|
15
|
+
AGENT_READ: "botmanor-agent:read",
|
|
16
|
+
AGENT_CREATE: "botmanor-agent:create",
|
|
17
|
+
AGENT_UPDATE: "botmanor-agent:update",
|
|
18
|
+
AGENT_APPROVE: "botmanor-agent:approve",
|
|
19
|
+
LLM_UPDATE: "botmanor-llm:update",
|
|
20
|
+
POLICY_READ: "botmanor-policy:read",
|
|
21
|
+
SANDBOX_ADMIN: "sandbox:admin",
|
|
22
|
+
MACHINE_UPDATE: "agent:update",
|
|
23
|
+
RBAC_MANAGE: "rbac:manage"
|
|
24
|
+
};
|
|
25
|
+
/** Readable labels for `PERMISSION_DENIED` ("Ask a workspace admin for permission to …"). */
|
|
26
|
+
const PERMISSION_LABELS = {
|
|
27
|
+
"botmanor-steward:read": "read stewards",
|
|
28
|
+
"botmanor-steward:create": "create stewards",
|
|
29
|
+
"botmanor-steward:update": "change steward charters",
|
|
30
|
+
"botmanor-steward:execute": "run stewards",
|
|
31
|
+
"botmanor-steward:manage": "manage steward limits",
|
|
32
|
+
"botmanor-steward:delete": "delete stewards",
|
|
33
|
+
"botmanor-policy:read": "read BotManor policies",
|
|
34
|
+
"botmanor-agent:read": "read agents",
|
|
35
|
+
"botmanor-agent:create": "create agents",
|
|
36
|
+
"botmanor-agent:update": "publish agents",
|
|
37
|
+
"botmanor-agent:approve": "approve agents",
|
|
38
|
+
"botmanor-llm:update": "change model settings",
|
|
39
|
+
"agent:read": "see VibeControls machines",
|
|
40
|
+
"agent:update": "share VibeControls machines"
|
|
41
|
+
};
|
|
42
|
+
/** `guidedErrors.permissions.<resource>.<action>` for a `resource:action` permission. */
|
|
43
|
+
function permissionLabelKey(permission) {
|
|
44
|
+
const [resource = "", action = ""] = permission.split(":");
|
|
45
|
+
return `guidedErrors.permissions.${resource.replace(/-([a-z0-9])/g, (_m, c) => c.toUpperCase())}.${action}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/guided/copy.ts
|
|
49
|
+
function nav(id, label, target, extra = {}) {
|
|
50
|
+
return {
|
|
51
|
+
id,
|
|
52
|
+
kind: "navigate",
|
|
53
|
+
label,
|
|
54
|
+
target,
|
|
55
|
+
...extra
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function mut(id, label, mutation, extra = {}) {
|
|
59
|
+
return {
|
|
60
|
+
id,
|
|
61
|
+
kind: "mutation",
|
|
62
|
+
label,
|
|
63
|
+
mutation,
|
|
64
|
+
...extra
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function retry(id = "tryAgain", label = "Try again") {
|
|
68
|
+
return {
|
|
69
|
+
id,
|
|
70
|
+
kind: "retry",
|
|
71
|
+
label
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function ask(id, text) {
|
|
75
|
+
return {
|
|
76
|
+
id,
|
|
77
|
+
kind: "ask-admin",
|
|
78
|
+
label: text,
|
|
79
|
+
askAdmin: {
|
|
80
|
+
id,
|
|
81
|
+
text
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const UPGRADE = {
|
|
86
|
+
id: "upgradePlan",
|
|
87
|
+
kind: "upgrade",
|
|
88
|
+
label: "Upgrade plan",
|
|
89
|
+
target: "BILLING_PLANS"
|
|
90
|
+
};
|
|
91
|
+
const ASK_ADMIN = {
|
|
92
|
+
id: "askWorkspaceAdmin",
|
|
93
|
+
text: "Ask a workspace admin."
|
|
94
|
+
};
|
|
95
|
+
const ASK_OWNER = {
|
|
96
|
+
id: "askStewardOwner",
|
|
97
|
+
text: "Ask {{ownerName}} to make this change."
|
|
98
|
+
};
|
|
99
|
+
const ASK_AGENT_OWNER = {
|
|
100
|
+
id: "askAgentOwner",
|
|
101
|
+
text: "Ask the agent's owner or a workspace admin to publish the agent."
|
|
102
|
+
};
|
|
103
|
+
const ASK_MODEL_ADMIN = {
|
|
104
|
+
id: "askModelAdmin",
|
|
105
|
+
text: "Ask a workspace admin to add a model provider."
|
|
106
|
+
};
|
|
107
|
+
const ASK_MACHINE_OWNER = {
|
|
108
|
+
id: "askMachineOwner",
|
|
109
|
+
text: "Ask {{machineOwner}} to share the computer with this steward in VibeControls."
|
|
110
|
+
};
|
|
111
|
+
const OPEN_AGENT = nav("openAgent", "Open agent", "AGENT", { permission: GUIDED_PERMISSIONS.AGENT_READ });
|
|
112
|
+
const CREATE_STEWARD = nav("createSteward", "Create a new steward", "STEWARD_NEW", { permission: GUIDED_PERMISSIONS.STEWARD_CREATE });
|
|
113
|
+
const RUN_AGAIN = retry("runAgain", "Run again");
|
|
114
|
+
const CHANGE_MODEL = nav("changeModel", "Change model", "STEWARD_CHARTER", {
|
|
115
|
+
anchor: "model",
|
|
116
|
+
permission: GUIDED_PERMISSIONS.STEWARD_UPDATE,
|
|
117
|
+
ownerParam: "ownerActorId",
|
|
118
|
+
askAdmin: ASK_OWNER
|
|
119
|
+
});
|
|
120
|
+
const CHANGE_BUDGET = nav("changeBudget", "Change budget", "STEWARD_CHARTER", {
|
|
121
|
+
anchor: "budget",
|
|
122
|
+
permission: GUIDED_PERMISSIONS.STEWARD_UPDATE,
|
|
123
|
+
ownerParam: "ownerActorId",
|
|
124
|
+
askAdmin: ASK_OWNER
|
|
125
|
+
});
|
|
126
|
+
const USE_OWN_MACHINE = nav("useOwnMachine", "Use my own machine", "STEWARD_CHARTER", {
|
|
127
|
+
anchor: "own-machine-desk",
|
|
128
|
+
permission: GUIDED_PERMISSIONS.STEWARD_UPDATE,
|
|
129
|
+
ownerParam: "ownerActorId"
|
|
130
|
+
});
|
|
131
|
+
const MODEL_SETTINGS = nav("openModelSettings", "Open model settings", "MODEL_SETTINGS", {
|
|
132
|
+
permission: GUIDED_PERMISSIONS.LLM_UPDATE,
|
|
133
|
+
askAdmin: ASK_MODEL_ADMIN
|
|
134
|
+
});
|
|
135
|
+
const OPEN_VIBECONTROLS = nav("openVibecontrols", "Open VibeControls", "VIBECONTROLS", {
|
|
136
|
+
ownerParam: "machineOwnerActorId",
|
|
137
|
+
askAdmin: ASK_MACHINE_OWNER
|
|
138
|
+
});
|
|
139
|
+
const REFRESH = retry("refresh", "Refresh");
|
|
140
|
+
const PICK_ANOTHER_AGENT = {
|
|
141
|
+
id: "pickAnotherAgent",
|
|
142
|
+
kind: "none",
|
|
143
|
+
label: "Pick another agent"
|
|
144
|
+
};
|
|
145
|
+
const GUIDED_ENTRIES = {
|
|
146
|
+
agentNotActive: {
|
|
147
|
+
title: "This steward's agent isn't active.",
|
|
148
|
+
cause: "A steward works through its agent, and that agent isn't published or was paused.",
|
|
149
|
+
next: "Publish or resume the agent, then run the steward again.",
|
|
150
|
+
actions: [mut("publishAgentAndContinue", "Publish agent and continue", "PUBLISH_AGENT", {
|
|
151
|
+
permission: GUIDED_PERMISSIONS.AGENT_UPDATE,
|
|
152
|
+
askAdmin: ASK_AGENT_OWNER
|
|
153
|
+
}), OPEN_AGENT]
|
|
154
|
+
},
|
|
155
|
+
"agentNotActive.draftReady": {
|
|
156
|
+
title: "This steward's agent isn't published yet.",
|
|
157
|
+
cause: "A steward works through its agent, and that agent is still a draft. Drafts can't run.",
|
|
158
|
+
next: "Publish the agent. The steward will then activate.",
|
|
159
|
+
actions: [mut("publishAgentAndContinue", "Publish agent and continue", "PUBLISH_AGENT", {
|
|
160
|
+
permission: GUIDED_PERMISSIONS.AGENT_UPDATE,
|
|
161
|
+
askAdmin: ASK_AGENT_OWNER
|
|
162
|
+
}), OPEN_AGENT]
|
|
163
|
+
},
|
|
164
|
+
"agentNotActive.draftNoModel": {
|
|
165
|
+
title: "This steward's agent isn't published yet.",
|
|
166
|
+
cause: "The agent is still a draft and has no AI model chosen, so it can't be published yet.",
|
|
167
|
+
next: "Choose a model for the agent and publish it, then come back and activate this steward.",
|
|
168
|
+
actions: [nav("chooseModel", "Choose a model", "AGENT_EDIT", {
|
|
169
|
+
permission: GUIDED_PERMISSIONS.AGENT_UPDATE,
|
|
170
|
+
askAdmin: ASK_AGENT_OWNER
|
|
171
|
+
})]
|
|
172
|
+
},
|
|
173
|
+
"agentNotActive.draftNeedsApproval": {
|
|
174
|
+
title: "This steward's agent isn't published yet.",
|
|
175
|
+
cause: "This workspace has reviewers check agents before they go live, and this steward's agent hasn't been approved yet.",
|
|
176
|
+
next: "Request activation. When a reviewer approves it, activate the steward.",
|
|
177
|
+
actions: [mut("requestActivation", "Request activation", "REQUEST_AGENT_ACTIVATION", {
|
|
178
|
+
permission: GUIDED_PERMISSIONS.AGENT_UPDATE,
|
|
179
|
+
askAdmin: ASK_AGENT_OWNER
|
|
180
|
+
}), nav("seeApprovalRequests", "See approval requests", "AGENT_APPROVALS", { permission: GUIDED_PERMISSIONS.AGENT_READ })]
|
|
181
|
+
},
|
|
182
|
+
"agentNotActive.approvalPending": {
|
|
183
|
+
title: "The agent is waiting for a reviewer.",
|
|
184
|
+
cause: "This workspace has reviewers check agents before they go live, and a request is waiting.",
|
|
185
|
+
next: "You can activate the steward once a reviewer approves the agent.",
|
|
186
|
+
actions: [nav("viewRequest", "View request", "AGENT_APPROVALS", { permission: GUIDED_PERMISSIONS.AGENT_READ })]
|
|
187
|
+
},
|
|
188
|
+
"agentNotActive.paused": {
|
|
189
|
+
title: "This steward's agent is paused.",
|
|
190
|
+
cause: "The steward's agent is paused, so the steward can't run.",
|
|
191
|
+
next: "Resume the agent, then try again.",
|
|
192
|
+
actions: [mut("resumeAgentAndContinue", "Resume agent and continue", "PUBLISH_AGENT", {
|
|
193
|
+
permission: GUIDED_PERMISSIONS.AGENT_UPDATE,
|
|
194
|
+
askAdmin: {
|
|
195
|
+
id: "askAgentOwnerResume",
|
|
196
|
+
text: "Ask the agent's owner or a workspace admin to resume the agent."
|
|
197
|
+
}
|
|
198
|
+
}), OPEN_AGENT]
|
|
199
|
+
},
|
|
200
|
+
"agentNotActive.training": {
|
|
201
|
+
title: "This steward's agent is still training.",
|
|
202
|
+
cause: "The steward's agent is still training.",
|
|
203
|
+
next: "Wait until training finishes, then try again.",
|
|
204
|
+
actions: [retry(), nav("checkTraining", "Check training", "AGENT", { permission: GUIDED_PERMISSIONS.AGENT_READ })]
|
|
205
|
+
},
|
|
206
|
+
"agentNotActive.archived": {
|
|
207
|
+
title: "This steward's agent is no longer available.",
|
|
208
|
+
cause: "The agent was archived or deleted, so this steward can't run again.",
|
|
209
|
+
next: "Create a new steward on an active agent. This steward's history stays available.",
|
|
210
|
+
actions: [CREATE_STEWARD]
|
|
211
|
+
},
|
|
212
|
+
"stewardNotActive.draft": {
|
|
213
|
+
title: "This steward isn't active yet.",
|
|
214
|
+
cause: "Only an active steward can run.",
|
|
215
|
+
next: "Activate the steward, then run it.",
|
|
216
|
+
actions: [mut("activateAndRun", "Activate and run", "ACTIVATE_STEWARD", {
|
|
217
|
+
permission: GUIDED_PERMISSIONS.STEWARD_UPDATE,
|
|
218
|
+
askAdmin: ASK_OWNER
|
|
219
|
+
})]
|
|
220
|
+
},
|
|
221
|
+
"stewardNotActive.paused": {
|
|
222
|
+
title: "This steward is paused.",
|
|
223
|
+
cause: "Only an active steward can run.",
|
|
224
|
+
next: "Resume it to run it again.",
|
|
225
|
+
actions: [mut("resumeAndRun", "Resume and run", "ACTIVATE_STEWARD", {
|
|
226
|
+
permission: GUIDED_PERMISSIONS.STEWARD_UPDATE,
|
|
227
|
+
askAdmin: ASK_OWNER
|
|
228
|
+
})]
|
|
229
|
+
},
|
|
230
|
+
"stewardNotActive.stoppedBeforeStart": {
|
|
231
|
+
title: "This run didn't start.",
|
|
232
|
+
cause: "The steward was paused or archived after this run was queued.",
|
|
233
|
+
next: "Activate the steward, then run it again.",
|
|
234
|
+
actions: [mut("activateSteward", "Activate steward", "ACTIVATE_STEWARD", {
|
|
235
|
+
permission: GUIDED_PERMISSIONS.STEWARD_UPDATE,
|
|
236
|
+
askAdmin: ASK_OWNER
|
|
237
|
+
}), RUN_AGAIN]
|
|
238
|
+
},
|
|
239
|
+
stewardArchived: {
|
|
240
|
+
title: "This steward is archived.",
|
|
241
|
+
cause: "Archived stewards keep their history, but they can't be changed or run.",
|
|
242
|
+
next: "Create a new steward to carry on this work.",
|
|
243
|
+
actions: [CREATE_STEWARD]
|
|
244
|
+
},
|
|
245
|
+
stewardStatusChanged: {
|
|
246
|
+
title: "This steward changed while you were looking at it.",
|
|
247
|
+
cause: "Someone changed the steward's status in the meantime.",
|
|
248
|
+
next: "We've refreshed it. Choose the action again.",
|
|
249
|
+
actions: [REFRESH]
|
|
250
|
+
},
|
|
251
|
+
agentUnavailable: {
|
|
252
|
+
title: "The steward's agent couldn't be found.",
|
|
253
|
+
cause: "The agent was removed or changed after this run was queued.",
|
|
254
|
+
next: "Open the agent to check it. If it's gone, create a new steward.",
|
|
255
|
+
actions: [OPEN_AGENT, CREATE_STEWARD]
|
|
256
|
+
},
|
|
257
|
+
"stewardAgentNotUsable.training": {
|
|
258
|
+
title: "This agent can't become a steward yet.",
|
|
259
|
+
cause: "This agent is still training.",
|
|
260
|
+
next: "Choose it again once training finishes, or pick another agent.",
|
|
261
|
+
actions: [PICK_ANOTHER_AGENT]
|
|
262
|
+
},
|
|
263
|
+
"stewardAgentNotUsable.gone": {
|
|
264
|
+
title: "This agent can't become a steward.",
|
|
265
|
+
cause: "This agent was archived or removed, so it can't become a steward.",
|
|
266
|
+
next: "Pick another agent or create a new one.",
|
|
267
|
+
actions: [PICK_ANOTHER_AGENT, mut("createAgent", "Create a new agent", "CREATE_AGENT", { permission: GUIDED_PERMISSIONS.AGENT_CREATE })]
|
|
268
|
+
},
|
|
269
|
+
"agentAlreadySteward.live": {
|
|
270
|
+
title: "This agent already works as a steward.",
|
|
271
|
+
cause: "An agent can be one steward only.",
|
|
272
|
+
next: "Open that steward, or pick another agent.",
|
|
273
|
+
actions: [nav("openExistingSteward", "Open the existing steward", "STEWARD", { permission: GUIDED_PERMISSIONS.STEWARD_READ }), PICK_ANOTHER_AGENT]
|
|
274
|
+
},
|
|
275
|
+
"agentAlreadySteward.archived": {
|
|
276
|
+
title: "This agent was a steward before.",
|
|
277
|
+
cause: "This agent was a steward before, and that steward is archived. An agent can be one steward only.",
|
|
278
|
+
next: "Pick or create another agent.",
|
|
279
|
+
actions: [PICK_ANOTHER_AGENT]
|
|
280
|
+
},
|
|
281
|
+
"agentNeedsModel.missing": {
|
|
282
|
+
title: "The agent has no AI model yet.",
|
|
283
|
+
cause: "An agent needs an AI model before it can be published.",
|
|
284
|
+
next: "Choose a model, then publish it.",
|
|
285
|
+
actions: [nav("chooseModel", "Choose a model", "AGENT_EDIT", {
|
|
286
|
+
permission: GUIDED_PERMISSIONS.AGENT_UPDATE,
|
|
287
|
+
askAdmin: ASK_AGENT_OWNER
|
|
288
|
+
})]
|
|
289
|
+
},
|
|
290
|
+
"agentNeedsModel.unusable": {
|
|
291
|
+
title: "The agent's AI model can't be used.",
|
|
292
|
+
cause: "The agent's model, or its provider, was removed or turned off.",
|
|
293
|
+
next: "Choose another model, then publish it.",
|
|
294
|
+
actions: [nav("chooseModel", "Choose a model", "AGENT_EDIT", {
|
|
295
|
+
permission: GUIDED_PERMISSIONS.AGENT_UPDATE,
|
|
296
|
+
askAdmin: ASK_AGENT_OWNER
|
|
297
|
+
})]
|
|
298
|
+
},
|
|
299
|
+
"agentNeedsModel.noneInWorkspace": {
|
|
300
|
+
title: "This workspace has no AI models set up yet.",
|
|
301
|
+
cause: "An agent needs an AI model, and none is set up in this workspace.",
|
|
302
|
+
next: "A workspace admin needs to add a model provider first.",
|
|
303
|
+
actions: [nav("setUpModels", "Set up models", "MODEL_SETTINGS", {
|
|
304
|
+
permission: GUIDED_PERMISSIONS.LLM_UPDATE,
|
|
305
|
+
askAdmin: ASK_MODEL_ADMIN
|
|
306
|
+
})]
|
|
307
|
+
},
|
|
308
|
+
agentApprovalRequired: {
|
|
309
|
+
title: "A reviewer needs to approve this agent first.",
|
|
310
|
+
cause: "This workspace has reviewers check agents before they go live.",
|
|
311
|
+
next: "Request activation. You'll be able to continue once it's approved.",
|
|
312
|
+
actions: [mut("requestActivation", "Request activation", "REQUEST_AGENT_ACTIVATION", {
|
|
313
|
+
permission: GUIDED_PERMISSIONS.AGENT_UPDATE,
|
|
314
|
+
askAdmin: ASK_AGENT_OWNER
|
|
315
|
+
}), nav("seeApprovalRequests", "See approval requests", "AGENT_APPROVALS", { permission: GUIDED_PERMISSIONS.AGENT_READ })]
|
|
316
|
+
},
|
|
317
|
+
activationAlreadyPending: {
|
|
318
|
+
title: "An activation request is already waiting.",
|
|
319
|
+
cause: "This agent already has an activation request waiting for a reviewer.",
|
|
320
|
+
next: "Wait for the reviewer, or open the request.",
|
|
321
|
+
actions: [nav("viewRequest", "View request", "AGENT_APPROVALS", { permission: GUIDED_PERMISSIONS.AGENT_READ })]
|
|
322
|
+
},
|
|
323
|
+
activationSelfReview: {
|
|
324
|
+
title: "Another reviewer needs to approve this.",
|
|
325
|
+
cause: "You asked for this activation, so another reviewer needs to approve it.",
|
|
326
|
+
next: "Ask another reviewer to decide it.",
|
|
327
|
+
actions: [ask("askAnotherReviewer", "Ask another reviewer.")]
|
|
328
|
+
},
|
|
329
|
+
activationRequestStale: {
|
|
330
|
+
title: "The agent changed after activation was requested.",
|
|
331
|
+
cause: "The reviewer would see an older version of the agent.",
|
|
332
|
+
next: "Request activation again so the reviewer sees the current version.",
|
|
333
|
+
actions: [mut("requestAgain", "Request again", "REQUEST_AGENT_ACTIVATION", { permission: GUIDED_PERMISSIONS.AGENT_UPDATE })]
|
|
334
|
+
},
|
|
335
|
+
activationOnlyRequester: {
|
|
336
|
+
title: "Only the requester can cancel this.",
|
|
337
|
+
cause: "Only the person who asked for activation can cancel the request.",
|
|
338
|
+
next: "Ask them to cancel it if it's no longer needed.",
|
|
339
|
+
actions: []
|
|
340
|
+
},
|
|
341
|
+
activationRequestClosed: {
|
|
342
|
+
title: "This request is closed.",
|
|
343
|
+
cause: "This request was already decided or withdrawn.",
|
|
344
|
+
next: "Refresh to see the current requests.",
|
|
345
|
+
actions: [REFRESH]
|
|
346
|
+
},
|
|
347
|
+
activationAgentArchived: {
|
|
348
|
+
title: "This agent is archived.",
|
|
349
|
+
cause: "The agent was archived, so it can't be activated.",
|
|
350
|
+
next: "Use another agent instead.",
|
|
351
|
+
actions: []
|
|
352
|
+
},
|
|
353
|
+
stewardRunsUsedUp: {
|
|
354
|
+
title: "No steward runs left this month.",
|
|
355
|
+
cause: "This workspace's BotManor plan has used all its steward runs for this month.",
|
|
356
|
+
next: "Upgrade the plan to run now, or wait until runs reset on {{resetsAt}}.",
|
|
357
|
+
actions: [UPGRADE]
|
|
358
|
+
},
|
|
359
|
+
"stewardRunsUsedUp.noReset": {
|
|
360
|
+
title: "No steward runs left this month.",
|
|
361
|
+
cause: "This workspace's BotManor plan has used all its steward runs for this month.",
|
|
362
|
+
next: "Upgrade the plan to run now, or wait until runs reset next month.",
|
|
363
|
+
actions: [UPGRADE]
|
|
364
|
+
},
|
|
365
|
+
deskMinutesUsedUp: {
|
|
366
|
+
title: "No cloud desk minutes left this month.",
|
|
367
|
+
cause: "This steward works on a cloud desk, and the workspace's plan has used all its desk minutes.",
|
|
368
|
+
next: "Let the steward use your own computer instead, upgrade the plan, or wait until minutes reset on {{resetsAt}}.",
|
|
369
|
+
actions: [USE_OWN_MACHINE, UPGRADE]
|
|
370
|
+
},
|
|
371
|
+
"deskMinutesUsedUp.noReset": {
|
|
372
|
+
title: "No cloud desk minutes left this month.",
|
|
373
|
+
cause: "This steward works on a cloud desk, and the workspace's plan has used all its desk minutes.",
|
|
374
|
+
next: "Let the steward use your own computer instead, upgrade the plan, or wait until minutes reset next month.",
|
|
375
|
+
actions: [USE_OWN_MACHINE, UPGRADE]
|
|
376
|
+
},
|
|
377
|
+
deskMinutesNotInPlan: {
|
|
378
|
+
title: "Cloud desks aren't part of this plan.",
|
|
379
|
+
cause: "The workspace's current plan doesn't include cloud desk minutes.",
|
|
380
|
+
next: "Let the steward use your own computer, or upgrade to a plan with cloud desks.",
|
|
381
|
+
actions: [USE_OWN_MACHINE, UPGRADE]
|
|
382
|
+
},
|
|
383
|
+
aiCreditsUsedUp: {
|
|
384
|
+
title: "The plan's AI credits are used up.",
|
|
385
|
+
cause: "This steward uses an AI model paid through the BotManor plan, and this month's credits are used up.",
|
|
386
|
+
next: "Switch the steward to a model that uses your workspace's own provider key, or upgrade the plan.",
|
|
387
|
+
actions: [
|
|
388
|
+
CHANGE_MODEL,
|
|
389
|
+
UPGRADE,
|
|
390
|
+
RUN_AGAIN
|
|
391
|
+
]
|
|
392
|
+
},
|
|
393
|
+
"aiCreditsUsedUp.notInPlan": {
|
|
394
|
+
title: "The plan's AI credits are used up.",
|
|
395
|
+
cause: "This steward uses an AI model paid through the BotManor plan, and the plan doesn't include AI credits.",
|
|
396
|
+
next: "Switch the steward to a model that uses your workspace's own provider key, or upgrade the plan.",
|
|
397
|
+
actions: [
|
|
398
|
+
CHANGE_MODEL,
|
|
399
|
+
UPGRADE,
|
|
400
|
+
RUN_AGAIN
|
|
401
|
+
]
|
|
402
|
+
},
|
|
403
|
+
"stewardBudgetUsedUp.run": {
|
|
404
|
+
title: "The steward reached its own budget.",
|
|
405
|
+
cause: "The charter limits this steward to {{budgetCap}} {{budgetKeyLabel}} {{budgetLevelLabel}}, and this run reached it.",
|
|
406
|
+
next: "Raise the per-run budget, or ask for something smaller and run again.",
|
|
407
|
+
actions: [CHANGE_BUDGET, RUN_AGAIN]
|
|
408
|
+
},
|
|
409
|
+
"stewardBudgetUsedUp.day": {
|
|
410
|
+
title: "The steward reached its own budget.",
|
|
411
|
+
cause: "The charter limits this steward to {{budgetCap}} {{budgetKeyLabel}} {{budgetLevelLabel}}, and this run reached it.",
|
|
412
|
+
next: "It can run again tomorrow, or you can raise the daily budget.",
|
|
413
|
+
actions: [CHANGE_BUDGET, RUN_AGAIN]
|
|
414
|
+
},
|
|
415
|
+
"stewardBudgetUsedUp.total": {
|
|
416
|
+
title: "The steward reached its own budget.",
|
|
417
|
+
cause: "The charter limits this steward to {{budgetCap}} {{budgetKeyLabel}} {{budgetLevelLabel}}, and this run reached it.",
|
|
418
|
+
next: "Raise the total budget to keep using this steward.",
|
|
419
|
+
actions: [CHANGE_BUDGET, RUN_AGAIN]
|
|
420
|
+
},
|
|
421
|
+
stewardBudgetUsedUp: {
|
|
422
|
+
title: "The run stopped when a budget ran out.",
|
|
423
|
+
cause: "Either the steward's own budget in its charter or the plan's AI credits ran out during this run.",
|
|
424
|
+
next: "Check the steward's budget, or the plan's AI credits, then run again.",
|
|
425
|
+
actions: [
|
|
426
|
+
CHANGE_BUDGET,
|
|
427
|
+
UPGRADE,
|
|
428
|
+
RUN_AGAIN
|
|
429
|
+
]
|
|
430
|
+
},
|
|
431
|
+
stepLimitReached: {
|
|
432
|
+
title: "The run hit the step limit.",
|
|
433
|
+
cause: "The steward took {{maxSteps}} steps without finishing, which is the most a run can take when the charter sets no step budget.",
|
|
434
|
+
next: "Break the request into smaller parts, or set a step budget on the charter.",
|
|
435
|
+
actions: [nav("setStepBudget", "Set a step budget", "STEWARD_CHARTER", {
|
|
436
|
+
anchor: "budget",
|
|
437
|
+
permission: GUIDED_PERMISSIONS.STEWARD_UPDATE,
|
|
438
|
+
ownerParam: "ownerActorId",
|
|
439
|
+
askAdmin: ASK_OWNER
|
|
440
|
+
}), RUN_AGAIN]
|
|
441
|
+
},
|
|
442
|
+
"stepLimitReached.unknownCap": {
|
|
443
|
+
title: "The run hit the step limit.",
|
|
444
|
+
cause: "The steward took the most steps a run can take without finishing, because the charter sets no step budget.",
|
|
445
|
+
next: "Break the request into smaller parts, or set a step budget on the charter.",
|
|
446
|
+
actions: [nav("setStepBudget", "Set a step budget", "STEWARD_CHARTER", {
|
|
447
|
+
anchor: "budget",
|
|
448
|
+
permission: GUIDED_PERMISSIONS.STEWARD_UPDATE,
|
|
449
|
+
ownerParam: "ownerActorId",
|
|
450
|
+
askAdmin: ASK_OWNER
|
|
451
|
+
}), RUN_AGAIN]
|
|
452
|
+
},
|
|
453
|
+
planLimitReached: {
|
|
454
|
+
title: "This plan's limit is reached.",
|
|
455
|
+
cause: "The workspace's plan doesn't allow more of this right now.",
|
|
456
|
+
next: "Upgrade the plan, or free up something you no longer need.",
|
|
457
|
+
actions: [UPGRADE]
|
|
458
|
+
},
|
|
459
|
+
"planLimitReached.notInPlan": {
|
|
460
|
+
title: "This isn't part of the current plan.",
|
|
461
|
+
cause: "The workspace's current plan doesn't include this.",
|
|
462
|
+
next: "Upgrade to a plan that includes it.",
|
|
463
|
+
actions: [UPGRADE]
|
|
464
|
+
},
|
|
465
|
+
"modelNotSetUp.noCredentials": {
|
|
466
|
+
title: "The steward's AI model isn't set up.",
|
|
467
|
+
cause: "The steward's AI model has no working provider key in this workspace.",
|
|
468
|
+
next: "Add the provider key in model settings, or switch the steward to another model.",
|
|
469
|
+
actions: [CHANGE_MODEL, MODEL_SETTINGS]
|
|
470
|
+
},
|
|
471
|
+
"modelNotSetUp.notUsable": {
|
|
472
|
+
title: "The steward's AI model can't be used.",
|
|
473
|
+
cause: "The steward's AI model, or its provider, was removed or turned off.",
|
|
474
|
+
next: "Choose an active model for the steward.",
|
|
475
|
+
actions: [CHANGE_MODEL]
|
|
476
|
+
},
|
|
477
|
+
modelNotSetUp: {
|
|
478
|
+
title: "The steward's AI model isn't available.",
|
|
479
|
+
cause: "The steward couldn't use its AI model in this workspace.",
|
|
480
|
+
next: "Check the model in model settings, or switch the steward to another model.",
|
|
481
|
+
actions: [CHANGE_MODEL, MODEL_SETTINGS]
|
|
482
|
+
},
|
|
483
|
+
"modelNotSetUp.notAllowed": {
|
|
484
|
+
title: "The steward's AI model isn't allowed.",
|
|
485
|
+
cause: "A workspace policy doesn't allow this AI model.",
|
|
486
|
+
next: "Choose an allowed model for the steward.",
|
|
487
|
+
actions: [CHANGE_MODEL]
|
|
488
|
+
},
|
|
489
|
+
"modelNotSetUp.blockedByPolicy": {
|
|
490
|
+
title: "The data policy blocks this AI model.",
|
|
491
|
+
cause: "The workspace's data policy doesn't allow sending this steward's data to that model's provider or region.",
|
|
492
|
+
next: "Choose a model that meets the policy, or ask a workspace admin to review the policy.",
|
|
493
|
+
actions: [CHANGE_MODEL, nav("openPolicies", "Open policies", "POLICIES", {
|
|
494
|
+
permission: GUIDED_PERMISSIONS.POLICY_READ,
|
|
495
|
+
askAdmin: ASK_ADMIN
|
|
496
|
+
})]
|
|
497
|
+
},
|
|
498
|
+
"modelCallFailed.authFailed": {
|
|
499
|
+
title: "The AI provider rejected the key.",
|
|
500
|
+
cause: "The AI provider rejected the workspace's key for this model.",
|
|
501
|
+
next: "Update the key in model settings.",
|
|
502
|
+
actions: [MODEL_SETTINGS, RUN_AGAIN]
|
|
503
|
+
},
|
|
504
|
+
"modelCallFailed.rateLimited": {
|
|
505
|
+
title: "The AI provider is limiting requests.",
|
|
506
|
+
cause: "The AI provider is limiting requests, or its account is out of quota.",
|
|
507
|
+
next: "Wait a few minutes and run again. If it keeps happening, the provider account owner needs to raise the limit.",
|
|
508
|
+
actions: [RUN_AGAIN]
|
|
509
|
+
},
|
|
510
|
+
"modelCallFailed.temporary": {
|
|
511
|
+
title: "The AI provider didn't respond properly.",
|
|
512
|
+
cause: "The AI provider didn't respond properly. This is usually temporary.",
|
|
513
|
+
next: "Run the steward again.",
|
|
514
|
+
actions: [RUN_AGAIN]
|
|
515
|
+
},
|
|
516
|
+
"modelCallFailed.badRequest": {
|
|
517
|
+
title: "The AI provider refused the request.",
|
|
518
|
+
cause: "The AI provider refused the request this model received.",
|
|
519
|
+
next: "Try another model for this steward.",
|
|
520
|
+
actions: [CHANGE_MODEL]
|
|
521
|
+
},
|
|
522
|
+
"charterModelNotUsable.notFound": {
|
|
523
|
+
title: "That model can't be used.",
|
|
524
|
+
cause: "The model chosen for the {{modelRoleLabel}} role isn't active.",
|
|
525
|
+
next: "Choose an active model for the {{modelRoleLabel}} role.",
|
|
526
|
+
actions: []
|
|
527
|
+
},
|
|
528
|
+
"charterModelNotUsable.unpriced": {
|
|
529
|
+
title: "The reviewer model has no price.",
|
|
530
|
+
cause: "The reviewer model needs a price per million tokens so the steward can track its budget.",
|
|
531
|
+
next: "Set the model's price, or choose another reviewer model.",
|
|
532
|
+
actions: [nav("setModelPrices", "Set model prices", "MODEL_SETTINGS", {
|
|
533
|
+
permission: GUIDED_PERMISSIONS.LLM_UPDATE,
|
|
534
|
+
askAdmin: ASK_MODEL_ADMIN
|
|
535
|
+
})]
|
|
536
|
+
},
|
|
537
|
+
modelProviderTestFailed: {
|
|
538
|
+
title: "We couldn't reach the AI provider.",
|
|
539
|
+
cause: "We couldn't reach the AI provider with these settings.",
|
|
540
|
+
next: "Check the key and endpoint, then test again.",
|
|
541
|
+
actions: [retry("testAgain", "Test again")]
|
|
542
|
+
},
|
|
543
|
+
"toolFailed.connectionSignIn": {
|
|
544
|
+
title: "A connection needs signing in again.",
|
|
545
|
+
cause: "The {{toolLabel}} connection's sign-in stopped working.",
|
|
546
|
+
next: "Reconnect it, then run again.",
|
|
547
|
+
actions: [nav("reconnect", "Reconnect", "INTEGRATIONS", { askAdmin: {
|
|
548
|
+
id: "askConnectionOwner",
|
|
549
|
+
text: "Ask the connection's owner to reconnect it."
|
|
550
|
+
} }), RUN_AGAIN]
|
|
551
|
+
},
|
|
552
|
+
"toolFailed.connectionNoAccess": {
|
|
553
|
+
title: "The connection's account isn't allowed to do this.",
|
|
554
|
+
cause: "The connection is signed in, but its account isn't allowed to do this.",
|
|
555
|
+
next: "The connection's owner can widen its access or share a different connection.",
|
|
556
|
+
actions: [ask("askConnectionOwner", "Ask the connection's owner."), nav("openIntegrations", "Open integrations", "INTEGRATIONS")]
|
|
557
|
+
},
|
|
558
|
+
"toolFailed.toolNotAllowed": {
|
|
559
|
+
title: "The steward tried a tool it isn't allowed to use.",
|
|
560
|
+
cause: "The steward tried a tool its charter doesn't include.",
|
|
561
|
+
next: "Add the tool or its connection to the charter if the steward should use it.",
|
|
562
|
+
actions: [nav("editTools", "Edit tools", "STEWARD_CHARTER", {
|
|
563
|
+
anchor: "tools",
|
|
564
|
+
permission: GUIDED_PERMISSIONS.STEWARD_UPDATE,
|
|
565
|
+
ownerParam: "ownerActorId",
|
|
566
|
+
askAdmin: ASK_OWNER
|
|
567
|
+
})]
|
|
568
|
+
},
|
|
569
|
+
"toolFailed.targetMissing": {
|
|
570
|
+
title: "Something the steward needed wasn't found.",
|
|
571
|
+
cause: "The thing the steward was working on couldn't be found in {{toolLabel}}.",
|
|
572
|
+
next: "Check that it still exists, then run again.",
|
|
573
|
+
actions: [RUN_AGAIN]
|
|
574
|
+
},
|
|
575
|
+
"toolFailed.badRequest": {
|
|
576
|
+
title: "A tool didn't accept the steward's request.",
|
|
577
|
+
cause: "{{toolLabel}} didn't accept what the steward sent.",
|
|
578
|
+
next: "Rephrase the request with more detail and run again.",
|
|
579
|
+
actions: [RUN_AGAIN]
|
|
580
|
+
},
|
|
581
|
+
"toolFailed.temporary": {
|
|
582
|
+
title: "A tool was busy or unreachable.",
|
|
583
|
+
cause: "{{toolLabel}} was busy or unreachable. This is usually temporary.",
|
|
584
|
+
next: "Run the steward again.",
|
|
585
|
+
actions: [RUN_AGAIN]
|
|
586
|
+
},
|
|
587
|
+
actionResultUnknown: {
|
|
588
|
+
title: "We're not sure an action went through.",
|
|
589
|
+
cause: "The steward stopped while sending an action with {{toolLabel}}, and it didn't repeat it, to avoid doing it twice.",
|
|
590
|
+
next: "Check {{toolLabel}} to see whether it happened, then run again if needed.",
|
|
591
|
+
actions: [RUN_AGAIN]
|
|
592
|
+
},
|
|
593
|
+
"actionNotApproved.denied": {
|
|
594
|
+
title: "An approver declined an action.",
|
|
595
|
+
cause: "An approver declined this action, so the run stopped.",
|
|
596
|
+
next: "Change the request if needed, then run again.",
|
|
597
|
+
actions: [RUN_AGAIN]
|
|
598
|
+
},
|
|
599
|
+
"actionNotApproved.expired": {
|
|
600
|
+
title: "An approval request ran out of time.",
|
|
601
|
+
cause: "Nobody decided on the approval request in time, so the run stopped.",
|
|
602
|
+
next: "Run again and keep an eye on approvals, or add an approval rule for actions like this.",
|
|
603
|
+
actions: [RUN_AGAIN, nav("openApprovals", "Open approvals", "TOOL_APPROVALS", { permission: GUIDED_PERMISSIONS.POLICY_READ })]
|
|
604
|
+
},
|
|
605
|
+
"actionNotApproved.cancelled": {
|
|
606
|
+
title: "An approval request was withdrawn.",
|
|
607
|
+
cause: "The approval request was withdrawn, so the run stopped.",
|
|
608
|
+
next: "Run again if the work is still needed.",
|
|
609
|
+
actions: [RUN_AGAIN]
|
|
610
|
+
},
|
|
611
|
+
needsAPerson: {
|
|
612
|
+
title: "This run needs someone to approve an action.",
|
|
613
|
+
cause: "It started on its own (from a schedule, webhook or event) and reached a step, {{toolLabel}} on {{destination}}, that needs a person's approval.",
|
|
614
|
+
next: "Run it yourself so you can approve the step, or let the steward always do this when you next approve it.",
|
|
615
|
+
actions: [mut("runItNow", "Run it now", "RUN_STEWARD", {
|
|
616
|
+
permission: GUIDED_PERMISSIONS.STEWARD_EXECUTE,
|
|
617
|
+
ownerParam: "ownerActorId",
|
|
618
|
+
askAdmin: ASK_OWNER
|
|
619
|
+
}), nav("reviewAutonomy", "Review autonomy", "STEWARD_CHARTER", {
|
|
620
|
+
permission: GUIDED_PERMISSIONS.STEWARD_UPDATE,
|
|
621
|
+
ownerParam: "ownerActorId"
|
|
622
|
+
})]
|
|
623
|
+
},
|
|
624
|
+
approvalScopeNotAllowed: {
|
|
625
|
+
title: "This action can't be approved that broadly.",
|
|
626
|
+
cause: "This action can't be approved that broadly. {{specificReason}}",
|
|
627
|
+
next: "You can still approve it once or for this run.",
|
|
628
|
+
actions: [mut("approveOnce", "Approve once", "APPROVE_NARROWER")]
|
|
629
|
+
},
|
|
630
|
+
approvalPurposeRequired: {
|
|
631
|
+
title: "A reason is needed.",
|
|
632
|
+
cause: "This decision needs a short reason.",
|
|
633
|
+
next: "Fill in the reason, then decide again.",
|
|
634
|
+
actions: []
|
|
635
|
+
},
|
|
636
|
+
approvalOwnRequest: {
|
|
637
|
+
title: "Another approver needs to decide this.",
|
|
638
|
+
cause: "This action is on your behalf, so another approver needs to decide it.",
|
|
639
|
+
next: "Ask one of the other approvers.",
|
|
640
|
+
actions: [ask("askAnotherApprover", "Ask another approver.")]
|
|
641
|
+
},
|
|
642
|
+
approvalNotApprover: {
|
|
643
|
+
title: "You're not an approver for this action.",
|
|
644
|
+
cause: "You're not one of the approvers for this action.",
|
|
645
|
+
next: "Ask one of its approvers to decide it.",
|
|
646
|
+
actions: [ask("askAnApprover", "Ask one of the approvers.")]
|
|
647
|
+
},
|
|
648
|
+
approvalAlreadyDecided: {
|
|
649
|
+
title: "This was already decided.",
|
|
650
|
+
cause: "Someone already decided this, or it was withdrawn.",
|
|
651
|
+
next: "Refresh to see what's still waiting.",
|
|
652
|
+
actions: [REFRESH]
|
|
653
|
+
},
|
|
654
|
+
delegationRevoked: {
|
|
655
|
+
title: "Another agent's permission was withdrawn.",
|
|
656
|
+
cause: "This run was started by another agent, and that permission was withdrawn.",
|
|
657
|
+
next: "A workspace admin can review agent-to-agent permissions.",
|
|
658
|
+
actions: [nav("reviewA2a", "Review agent permissions", "A2A", {
|
|
659
|
+
permission: GUIDED_PERMISSIONS.POLICY_READ,
|
|
660
|
+
askAdmin: ASK_ADMIN
|
|
661
|
+
})]
|
|
662
|
+
},
|
|
663
|
+
"cloudDesk.poolFull": {
|
|
664
|
+
title: "All cloud desks are in use right now.",
|
|
665
|
+
cause: "All cloud desks are in use right now.",
|
|
666
|
+
next: "Try again in a few minutes, or let the steward use your own computer.",
|
|
667
|
+
actions: [retry(), USE_OWN_MACHINE]
|
|
668
|
+
},
|
|
669
|
+
"cloudDesk.checkUnavailable": {
|
|
670
|
+
title: "We couldn't check the plan's desk minutes.",
|
|
671
|
+
cause: "We couldn't check the plan's desk minutes just now.",
|
|
672
|
+
next: "Try again in a few minutes.",
|
|
673
|
+
actions: [retry()]
|
|
674
|
+
},
|
|
675
|
+
"cloudDesk.notConfigured": {
|
|
676
|
+
title: "Cloud desks aren't available here yet.",
|
|
677
|
+
cause: "Cloud desks aren't available here yet.",
|
|
678
|
+
next: "Let the steward use your own computer instead.",
|
|
679
|
+
actions: [USE_OWN_MACHINE]
|
|
680
|
+
},
|
|
681
|
+
"cloudDesk.startFailed": {
|
|
682
|
+
title: "The cloud desk didn't start.",
|
|
683
|
+
cause: "The cloud desk didn't start. This is usually temporary.",
|
|
684
|
+
next: "Run the steward again.",
|
|
685
|
+
actions: [RUN_AGAIN]
|
|
686
|
+
},
|
|
687
|
+
"cloudDeskLimit.workspace": {
|
|
688
|
+
title: "This workspace runs its maximum of sandboxes.",
|
|
689
|
+
cause: "This workspace already runs its maximum of {{limit}} sandboxes, so the desk can't start.",
|
|
690
|
+
next: "Stop a sandbox you no longer need.",
|
|
691
|
+
actions: [nav("manageSandboxes", "Manage sandboxes", "SANDBOX"), nav("changeLimits", "Change limits", "SANDBOX_ADMIN", { permission: GUIDED_PERMISSIONS.SANDBOX_ADMIN })]
|
|
692
|
+
},
|
|
693
|
+
"cloudDeskLimit.person": {
|
|
694
|
+
title: "The desk's owner runs their maximum of sandboxes.",
|
|
695
|
+
cause: "The desk's owner already runs their maximum of {{limit}} sandboxes.",
|
|
696
|
+
next: "They can stop one they no longer need.",
|
|
697
|
+
actions: [nav("manageSandboxes", "Manage sandboxes", "SANDBOX")]
|
|
698
|
+
},
|
|
699
|
+
"cloudDeskLimit.plan": {
|
|
700
|
+
title: "The plan's sandbox limit is reached.",
|
|
701
|
+
cause: "The plan allows {{limit}} sandboxes at a time.",
|
|
702
|
+
next: "Stop a sandbox you no longer need, or upgrade the plan.",
|
|
703
|
+
actions: [nav("manageSandboxes", "Manage sandboxes", "SANDBOX"), UPGRADE]
|
|
704
|
+
},
|
|
705
|
+
cloudDeskTemplateNotAllowed: {
|
|
706
|
+
title: "Desktop sandboxes aren't allowed here.",
|
|
707
|
+
cause: "This workspace's sandbox policy doesn't allow desktop sandboxes, so the steward can't get a cloud desk.",
|
|
708
|
+
next: "A workspace admin can allow desktop sandboxes, or the steward can use your own computer.",
|
|
709
|
+
actions: [nav("openSandboxPolicy", "Open sandbox policy", "SANDBOX_ADMIN", {
|
|
710
|
+
permission: GUIDED_PERMISSIONS.SANDBOX_ADMIN,
|
|
711
|
+
askAdmin: ASK_ADMIN
|
|
712
|
+
}), USE_OWN_MACHINE]
|
|
713
|
+
},
|
|
714
|
+
"ownMachineNotGranted.noGrant": {
|
|
715
|
+
title: "That computer isn't shared with this steward.",
|
|
716
|
+
cause: "That computer hasn't been shared with this steward yet.",
|
|
717
|
+
next: "The computer's owner can share it with this steward.",
|
|
718
|
+
actions: [mut("shareComputer", "Share this computer", "SHARE_MACHINE", {
|
|
719
|
+
permission: GUIDED_PERMISSIONS.MACHINE_UPDATE,
|
|
720
|
+
ownerParam: "machineOwnerActorId",
|
|
721
|
+
askAdmin: ASK_MACHINE_OWNER
|
|
722
|
+
}), OPEN_VIBECONTROLS]
|
|
723
|
+
},
|
|
724
|
+
"ownMachineNotGranted.scope": {
|
|
725
|
+
title: "That computer's sharing doesn't cover this.",
|
|
726
|
+
cause: "The computer is shared with this steward, but not for {{scopeLabel}}.",
|
|
727
|
+
next: "The computer's owner can update the sharing.",
|
|
728
|
+
actions: [mut("updateSharing", "Update sharing", "SHARE_MACHINE", {
|
|
729
|
+
permission: GUIDED_PERMISSIONS.MACHINE_UPDATE,
|
|
730
|
+
ownerParam: "machineOwnerActorId",
|
|
731
|
+
askAdmin: ASK_MACHINE_OWNER
|
|
732
|
+
}), OPEN_VIBECONTROLS]
|
|
733
|
+
},
|
|
734
|
+
"ownMachineNotGranted.app": {
|
|
735
|
+
title: "That app isn't allowed on the computer.",
|
|
736
|
+
cause: "The steward tried to use {{app}}, which isn't on the list of apps it may use on that computer.",
|
|
737
|
+
next: "The computer's owner can add the app to the sharing.",
|
|
738
|
+
actions: [mut("updateSharing", "Update sharing", "SHARE_MACHINE", {
|
|
739
|
+
permission: GUIDED_PERMISSIONS.MACHINE_UPDATE,
|
|
740
|
+
ownerParam: "machineOwnerActorId",
|
|
741
|
+
askAdmin: ASK_MACHINE_OWNER
|
|
742
|
+
}), OPEN_VIBECONTROLS]
|
|
743
|
+
},
|
|
744
|
+
"ownMachineOffline.offline": {
|
|
745
|
+
title: "The steward's computer isn't connected.",
|
|
746
|
+
cause: "The computer this steward uses isn't connected.",
|
|
747
|
+
next: "Open VibeControls on it and make sure it's online, then run again.",
|
|
748
|
+
actions: [OPEN_VIBECONTROLS, RUN_AGAIN]
|
|
749
|
+
},
|
|
750
|
+
"ownMachineOffline.paused": {
|
|
751
|
+
title: "Steward access is turned off on that computer.",
|
|
752
|
+
cause: "Steward access is turned off on that computer.",
|
|
753
|
+
next: "Turn it back on in VibeControls on that computer, then run again.",
|
|
754
|
+
actions: [OPEN_VIBECONTROLS, RUN_AGAIN]
|
|
755
|
+
},
|
|
756
|
+
"ownMachineOffline.slow": {
|
|
757
|
+
title: "The computer didn't answer in time.",
|
|
758
|
+
cause: "The computer didn't answer in time.",
|
|
759
|
+
next: "Run again in a moment.",
|
|
760
|
+
actions: [RUN_AGAIN]
|
|
761
|
+
},
|
|
762
|
+
"ownMachineOwnerOnly.steward": {
|
|
763
|
+
title: "Only the steward's owner can choose its computer.",
|
|
764
|
+
cause: "Only the steward's owner can choose its computer.",
|
|
765
|
+
next: "Ask the steward's owner to choose it.",
|
|
766
|
+
actions: [ask(ASK_OWNER.id, ASK_OWNER.text)]
|
|
767
|
+
},
|
|
768
|
+
"ownMachineOwnerOnly.machine": {
|
|
769
|
+
title: "Only the computer's owner can share it.",
|
|
770
|
+
cause: "Only the computer's owner can share it.",
|
|
771
|
+
next: "Ask the computer's owner to share it with this steward.",
|
|
772
|
+
actions: [ask(ASK_MACHINE_OWNER.id, ASK_MACHINE_OWNER.text)]
|
|
773
|
+
},
|
|
774
|
+
ownMachineNotUsable: {
|
|
775
|
+
title: "That computer can't be used.",
|
|
776
|
+
cause: "That computer can't be used.",
|
|
777
|
+
next: "Pick another one.",
|
|
778
|
+
actions: []
|
|
779
|
+
},
|
|
780
|
+
ownMachineInUse: {
|
|
781
|
+
title: "The steward is using its desk right now.",
|
|
782
|
+
cause: "The steward is using its desk right now.",
|
|
783
|
+
next: "Change it when the current run ends.",
|
|
784
|
+
actions: [retry()]
|
|
785
|
+
},
|
|
786
|
+
ownMachineTryAgain: {
|
|
787
|
+
title: "We couldn't confirm that just now.",
|
|
788
|
+
cause: "We couldn't confirm that just now.",
|
|
789
|
+
next: "Try again.",
|
|
790
|
+
actions: [retry()]
|
|
791
|
+
},
|
|
792
|
+
"ownMachineTryAgain.liveGrant": {
|
|
793
|
+
title: "This computer is already shared.",
|
|
794
|
+
cause: "This computer already has live sharing with this steward.",
|
|
795
|
+
next: "Revoke the current sharing first to change it.",
|
|
796
|
+
actions: [mut("revokeSharing", "Revoke sharing", "REVOKE_MACHINE_GRANT", {
|
|
797
|
+
permission: GUIDED_PERMISSIONS.MACHINE_UPDATE,
|
|
798
|
+
ownerParam: "machineOwnerActorId"
|
|
799
|
+
})]
|
|
800
|
+
},
|
|
801
|
+
"deskActionBlocked.site": {
|
|
802
|
+
title: "The desk isn't allowed to visit that site.",
|
|
803
|
+
cause: "The steward tried to open {{host}}, which its desk isn't allowed to visit.",
|
|
804
|
+
next: "Add the site to the charter if it should.",
|
|
805
|
+
actions: [nav("editDesk", "Edit desk settings", "STEWARD_CHARTER", {
|
|
806
|
+
anchor: "desk",
|
|
807
|
+
permission: GUIDED_PERMISSIONS.STEWARD_UPDATE,
|
|
808
|
+
ownerParam: "ownerActorId",
|
|
809
|
+
askAdmin: ASK_OWNER
|
|
810
|
+
})]
|
|
811
|
+
},
|
|
812
|
+
"deskActionBlocked.folder": {
|
|
813
|
+
title: "The steward stayed inside its folder.",
|
|
814
|
+
cause: "The steward tried to work outside the folder it's allowed to use.",
|
|
815
|
+
next: "Ask for work inside that folder, then run again.",
|
|
816
|
+
actions: []
|
|
817
|
+
},
|
|
818
|
+
"deskActionBlocked.shell": {
|
|
819
|
+
title: "The desk doesn't allow commands.",
|
|
820
|
+
cause: "The steward tried to run a command, which its desk doesn't allow.",
|
|
821
|
+
next: "Allow commands on the desk if the steward should run them.",
|
|
822
|
+
actions: [nav("editDesk", "Edit desk settings", "STEWARD_CHARTER", {
|
|
823
|
+
anchor: "desk",
|
|
824
|
+
permission: GUIDED_PERMISSIONS.STEWARD_UPDATE,
|
|
825
|
+
ownerParam: "ownerActorId",
|
|
826
|
+
askAdmin: ASK_OWNER
|
|
827
|
+
})]
|
|
828
|
+
},
|
|
829
|
+
"deskActionBlocked.unsupported": {
|
|
830
|
+
title: "That step can't be done on this desk.",
|
|
831
|
+
cause: "That kind of step can't be done on this desk.",
|
|
832
|
+
next: "Ask for the work another way, or use a different desk.",
|
|
833
|
+
actions: []
|
|
834
|
+
},
|
|
835
|
+
"deskActionBlocked.target": {
|
|
836
|
+
title: "The steward couldn't find what it was looking for.",
|
|
837
|
+
cause: "The steward couldn't find what it was looking for on screen.",
|
|
838
|
+
next: "Run the steward again.",
|
|
839
|
+
actions: [RUN_AGAIN]
|
|
840
|
+
},
|
|
841
|
+
deskSignInLost: {
|
|
842
|
+
title: "The desk lost a saved sign-in.",
|
|
843
|
+
cause: "The desk lost a saved sign-in, so the steward can't continue.",
|
|
844
|
+
next: "Take over the desk, sign in again, then hand it back.",
|
|
845
|
+
actions: [nav("openLiveDesk", "Open live desk", "STEWARD_RUN", {
|
|
846
|
+
permission: GUIDED_PERMISSIONS.STEWARD_UPDATE,
|
|
847
|
+
ownerParam: "ownerActorId"
|
|
848
|
+
})]
|
|
849
|
+
},
|
|
850
|
+
fieldInvalid: {
|
|
851
|
+
title: "Check this field.",
|
|
852
|
+
cause: "{{serverMessage}}",
|
|
853
|
+
next: "Correct the value, then save again.",
|
|
854
|
+
actions: []
|
|
855
|
+
},
|
|
856
|
+
staleEdit: {
|
|
857
|
+
title: "Someone saved a newer version.",
|
|
858
|
+
cause: "Someone saved a newer version while you were editing.",
|
|
859
|
+
next: "Reload to see their changes. Your edits are kept so you can apply them again.",
|
|
860
|
+
actions: [retry("reload", "Reload")]
|
|
861
|
+
},
|
|
862
|
+
ownerOnly: {
|
|
863
|
+
title: "Only the steward's owner can change this.",
|
|
864
|
+
cause: "Only {{ownerName}} can change this steward's {{areaLabel}}.",
|
|
865
|
+
next: "Ask {{ownerName}} to make the change.",
|
|
866
|
+
actions: [ask(ASK_OWNER.id, ASK_OWNER.text)]
|
|
867
|
+
},
|
|
868
|
+
"ownerOnly.charter": {
|
|
869
|
+
title: "Only the steward's owner can change this.",
|
|
870
|
+
cause: "Only {{ownerName}} or a workspace admin can change this steward's {{areaLabel}}.",
|
|
871
|
+
next: "Ask {{ownerName}} or a workspace admin to make the change.",
|
|
872
|
+
actions: [ask(ASK_OWNER.id, ASK_OWNER.text)]
|
|
873
|
+
},
|
|
874
|
+
workspaceLimitSetting: {
|
|
875
|
+
title: "A workspace limit applies here.",
|
|
876
|
+
cause: "A workspace admin limits {{controlLabel}} for all stewards.",
|
|
877
|
+
next: "Choose one of the allowed options: {{allowedLabels}}.",
|
|
878
|
+
actions: [nav("changeWorkspaceLimits", "Change workspace limits", "STEWARD_WORKSPACE_CONTROLS", {
|
|
879
|
+
permission: GUIDED_PERMISSIONS.STEWARD_MANAGE,
|
|
880
|
+
askAdmin: ASK_ADMIN
|
|
881
|
+
})]
|
|
882
|
+
},
|
|
883
|
+
"workspaceLimitSetting.noOptions": {
|
|
884
|
+
title: "A workspace limit applies here.",
|
|
885
|
+
cause: "A workspace admin limits {{controlLabel}} for all stewards.",
|
|
886
|
+
next: "Choose one of the options the form still offers.",
|
|
887
|
+
actions: [nav("changeWorkspaceLimits", "Change workspace limits", "STEWARD_WORKSPACE_CONTROLS", {
|
|
888
|
+
permission: GUIDED_PERMISSIONS.STEWARD_MANAGE,
|
|
889
|
+
askAdmin: ASK_ADMIN
|
|
890
|
+
})]
|
|
891
|
+
},
|
|
892
|
+
dutyLimitReached: {
|
|
893
|
+
title: "This steward has the most duties it can have.",
|
|
894
|
+
cause: "This steward has the most duties it can have ({{limit}}).",
|
|
895
|
+
next: "Archive one it no longer needs.",
|
|
896
|
+
actions: []
|
|
897
|
+
},
|
|
898
|
+
dutyArchived: {
|
|
899
|
+
title: "This duty is archived.",
|
|
900
|
+
cause: "This duty is archived and can't be changed.",
|
|
901
|
+
next: "Create a new duty if the work is still needed.",
|
|
902
|
+
actions: []
|
|
903
|
+
},
|
|
904
|
+
dutyWebhookTokenInvalid: {
|
|
905
|
+
title: "A webhook used an old or wrong token.",
|
|
906
|
+
cause: "A webhook call used an old or wrong token.",
|
|
907
|
+
next: "Rotate the token and update the sender.",
|
|
908
|
+
actions: [mut("rotateToken", "Rotate token", "ROTATE_DUTY_TOKEN", {
|
|
909
|
+
permission: GUIDED_PERMISSIONS.STEWARD_UPDATE,
|
|
910
|
+
ownerParam: "ownerActorId",
|
|
911
|
+
askAdmin: ASK_OWNER
|
|
912
|
+
})]
|
|
913
|
+
},
|
|
914
|
+
dutyScheduleNotSaved: {
|
|
915
|
+
title: "The schedule wasn't saved.",
|
|
916
|
+
cause: "The schedule wasn't saved with the scheduler.",
|
|
917
|
+
next: "Save again to retry.",
|
|
918
|
+
actions: [retry("saveAgain", "Save again")]
|
|
919
|
+
},
|
|
920
|
+
dutyNotAProposal: {
|
|
921
|
+
title: "This item changed.",
|
|
922
|
+
cause: "This item changed since the list loaded.",
|
|
923
|
+
next: "Refresh to see the current list.",
|
|
924
|
+
actions: [REFRESH]
|
|
925
|
+
},
|
|
926
|
+
dutyFireNotAllowed: {
|
|
927
|
+
title: "Only the steward's owner can start this duty.",
|
|
928
|
+
cause: "Only the steward's owner can start this duty by hand.",
|
|
929
|
+
next: "Ask the steward's owner to start it.",
|
|
930
|
+
actions: [ask(ASK_OWNER.id, ASK_OWNER.text)]
|
|
931
|
+
},
|
|
932
|
+
memoryKeyTaken: {
|
|
933
|
+
title: "That name is taken.",
|
|
934
|
+
cause: "A memory note with this name already exists.",
|
|
935
|
+
next: "Open that note, or choose another name.",
|
|
936
|
+
actions: [nav("openNote", "Open the note", "STEWARD_MEMORY", { permission: GUIDED_PERMISSIONS.STEWARD_READ })]
|
|
937
|
+
},
|
|
938
|
+
memoryLimitReached: {
|
|
939
|
+
title: "This steward's memory is full.",
|
|
940
|
+
cause: "This steward has the most memory notes it can keep.",
|
|
941
|
+
next: "Delete one it no longer needs.",
|
|
942
|
+
actions: []
|
|
943
|
+
},
|
|
944
|
+
memoryOutcomeNotReady: {
|
|
945
|
+
title: "This outcome can't be saved.",
|
|
946
|
+
cause: "Only a finished run's outcome can be saved, once.",
|
|
947
|
+
next: "Save the outcome of a finished run instead.",
|
|
948
|
+
actions: []
|
|
949
|
+
},
|
|
950
|
+
memoryNotFound: {
|
|
951
|
+
title: "This note was removed.",
|
|
952
|
+
cause: "This note was removed.",
|
|
953
|
+
next: "Refresh the list.",
|
|
954
|
+
actions: [REFRESH]
|
|
955
|
+
},
|
|
956
|
+
playbookNotActive: {
|
|
957
|
+
title: "This playbook can't be used now.",
|
|
958
|
+
cause: "This playbook is {{statusLabel}}, so it can't be used now.",
|
|
959
|
+
next: "Activate the playbook, then try again.",
|
|
960
|
+
actions: [mut("activatePlaybook", "Activate playbook", "ACTIVATE_PLAYBOOK", {
|
|
961
|
+
permission: GUIDED_PERMISSIONS.STEWARD_UPDATE,
|
|
962
|
+
ownerParam: "ownerActorId",
|
|
963
|
+
askAdmin: ASK_OWNER
|
|
964
|
+
})]
|
|
965
|
+
},
|
|
966
|
+
playbookNeedsRecording: {
|
|
967
|
+
title: "The saved steps can't be replayed.",
|
|
968
|
+
cause: "The saved steps can't be replayed ({{specificReason}}).",
|
|
969
|
+
next: "Record them again.",
|
|
970
|
+
actions: [nav("recordAgain", "Record again", "STEWARD_PLAYBOOKS", {
|
|
971
|
+
permission: GUIDED_PERMISSIONS.STEWARD_UPDATE,
|
|
972
|
+
ownerParam: "ownerActorId"
|
|
973
|
+
})]
|
|
974
|
+
},
|
|
975
|
+
"playbookNeedsRecording.credential": {
|
|
976
|
+
title: "The saved steps can't be replayed.",
|
|
977
|
+
cause: "Recordings can't contain passwords or keys.",
|
|
978
|
+
next: "Sign in before you start recording, then record them again.",
|
|
979
|
+
actions: [nav("recordAgain", "Record again", "STEWARD_PLAYBOOKS", {
|
|
980
|
+
permission: GUIDED_PERMISSIONS.STEWARD_UPDATE,
|
|
981
|
+
ownerParam: "ownerActorId"
|
|
982
|
+
})]
|
|
983
|
+
},
|
|
984
|
+
playbookLimitReached: {
|
|
985
|
+
title: "This steward has the most playbooks it can have.",
|
|
986
|
+
cause: "This steward has the most playbooks it can have.",
|
|
987
|
+
next: "Archive one it no longer needs.",
|
|
988
|
+
actions: []
|
|
989
|
+
},
|
|
990
|
+
playbookArchived: {
|
|
991
|
+
title: "This playbook is archived.",
|
|
992
|
+
cause: "This playbook is archived and can't be changed.",
|
|
993
|
+
next: "Create a new playbook if the work is still needed.",
|
|
994
|
+
actions: []
|
|
995
|
+
},
|
|
996
|
+
runAlreadyEnded: {
|
|
997
|
+
title: "This run already finished.",
|
|
998
|
+
cause: "This run already finished, so it can't be cancelled.",
|
|
999
|
+
next: "Refresh to see how it ended.",
|
|
1000
|
+
actions: [REFRESH]
|
|
1001
|
+
},
|
|
1002
|
+
permissionDenied: {
|
|
1003
|
+
title: "You don't have access to this yet.",
|
|
1004
|
+
cause: "Your role in this workspace doesn't allow this.",
|
|
1005
|
+
next: "Ask a workspace admin for permission to {{permissionLabel}}.",
|
|
1006
|
+
actions: [nav("manageRoles", "Manage roles", "RBAC", { permission: GUIDED_PERMISSIONS.RBAC_MANAGE })]
|
|
1007
|
+
},
|
|
1008
|
+
"permissionDenied.readOnlyCredential": {
|
|
1009
|
+
title: "This sign-in can only read.",
|
|
1010
|
+
cause: "The credential this page uses is allowed to read, not to make changes.",
|
|
1011
|
+
next: "Sign in with an account or key that may make changes, then try again.",
|
|
1012
|
+
actions: []
|
|
1013
|
+
},
|
|
1014
|
+
"permissionDenied.unknownPermission": {
|
|
1015
|
+
title: "You don't have access to this yet.",
|
|
1016
|
+
cause: "Your role in this workspace doesn't allow this.",
|
|
1017
|
+
next: "Ask a workspace admin for the permission you need.",
|
|
1018
|
+
actions: [nav("manageRoles", "Manage roles", "RBAC", { permission: GUIDED_PERMISSIONS.RBAC_MANAGE })]
|
|
1019
|
+
},
|
|
1020
|
+
permissionCheckUnavailable: {
|
|
1021
|
+
title: "We couldn't check your access.",
|
|
1022
|
+
cause: "We couldn't check your access just now.",
|
|
1023
|
+
next: "Try again in a moment.",
|
|
1024
|
+
actions: [retry()]
|
|
1025
|
+
},
|
|
1026
|
+
sessionEnded: {
|
|
1027
|
+
title: "Your session ended.",
|
|
1028
|
+
cause: "Your session ended.",
|
|
1029
|
+
next: "Sign in again to continue.",
|
|
1030
|
+
actions: []
|
|
1031
|
+
},
|
|
1032
|
+
workspaceRequired: {
|
|
1033
|
+
title: "Choose a workspace.",
|
|
1034
|
+
cause: "Stewards belong to a workspace.",
|
|
1035
|
+
next: "Choose a workspace to see its stewards.",
|
|
1036
|
+
actions: []
|
|
1037
|
+
},
|
|
1038
|
+
notFound: {
|
|
1039
|
+
title: "This wasn't found.",
|
|
1040
|
+
cause: "This steward (or run) doesn't exist, or it belongs to another workspace.",
|
|
1041
|
+
next: "Go back to the list of stewards.",
|
|
1042
|
+
actions: [nav("backToStewards", "Back to stewards", "STEWARD_LIST", { permission: GUIDED_PERMISSIONS.STEWARD_READ })]
|
|
1043
|
+
},
|
|
1044
|
+
serviceTrouble: {
|
|
1045
|
+
title: "Something went wrong on our side.",
|
|
1046
|
+
cause: "Something went wrong on our side.",
|
|
1047
|
+
next: "Try again in a moment.",
|
|
1048
|
+
actions: [retry()]
|
|
1049
|
+
},
|
|
1050
|
+
"serviceTrouble.withMessage": {
|
|
1051
|
+
title: "Something went wrong on our side.",
|
|
1052
|
+
cause: "{{serverMessage}}",
|
|
1053
|
+
next: "Try again in a moment.",
|
|
1054
|
+
actions: [retry()]
|
|
1055
|
+
},
|
|
1056
|
+
"cloudDesk.deskUnreachable": {
|
|
1057
|
+
title: "The steward's desk wasn't available.",
|
|
1058
|
+
cause: "The desk the steward works on couldn't be reached or started.",
|
|
1059
|
+
next: "Run the steward again. If it uses your own computer, make sure VibeControls is running on it.",
|
|
1060
|
+
actions: [RUN_AGAIN]
|
|
1061
|
+
},
|
|
1062
|
+
runFailed: {
|
|
1063
|
+
title: "This run didn't finish.",
|
|
1064
|
+
cause: "The steward stopped before finishing this run.",
|
|
1065
|
+
next: "Check the steps below, then run it again.",
|
|
1066
|
+
actions: [RUN_AGAIN]
|
|
1067
|
+
},
|
|
1068
|
+
"runFailed.unchecked": {
|
|
1069
|
+
title: "This run didn't finish.",
|
|
1070
|
+
cause: "The steward stopped after repeated failures.",
|
|
1071
|
+
next: "Check what the steward already did before you run it again, so nothing happens twice.",
|
|
1072
|
+
actions: []
|
|
1073
|
+
},
|
|
1074
|
+
unknown: {
|
|
1075
|
+
title: "That didn't work.",
|
|
1076
|
+
cause: "{{serverMessage}}",
|
|
1077
|
+
next: "Try again. If it keeps happening, copy the details for support.",
|
|
1078
|
+
actions: [retry()]
|
|
1079
|
+
}
|
|
1080
|
+
};
|
|
1081
|
+
/**
|
|
1082
|
+
* Run stop-reason and status labels (catalog section J), in place of raw
|
|
1083
|
+
* codes on run pages, headers, daybooks and notifications.
|
|
1084
|
+
*/
|
|
1085
|
+
const STOP_REASON_LABELS = {
|
|
1086
|
+
CANCELLED_BY_OWNER: "Cancelled",
|
|
1087
|
+
STEWARD_ARCHIVED: "Stopped because the steward was archived",
|
|
1088
|
+
PROPOSAL_DECLINED: "Proposal declined",
|
|
1089
|
+
BUDGET: "Paused: budget used up",
|
|
1090
|
+
STEP_CAP: "Stopped at the step limit",
|
|
1091
|
+
REPEATED_FAILURE: "Stopped after repeated failures",
|
|
1092
|
+
APPROVAL_DENIED: "Stopped: an approver declined an action",
|
|
1093
|
+
APPROVAL_EXPIRED: "Stopped: an approval ran out of time",
|
|
1094
|
+
APPROVAL_CANCELLED: "Stopped: an approval was withdrawn",
|
|
1095
|
+
UNATTENDED_NEEDS_PERSON: "Stopped: needs a person to approve",
|
|
1096
|
+
STEWARD_NOT_ACTIVE: "Didn't start: the steward wasn't active",
|
|
1097
|
+
AGENT_UNAVAILABLE: "Didn't start: the agent wasn't found",
|
|
1098
|
+
DELEGATION_REVOKED: "Stopped: permission was withdrawn",
|
|
1099
|
+
EFFECT_UNKNOWN: "Stopped: an action's result is unknown"
|
|
1100
|
+
};
|
|
1101
|
+
/** Readable labels for agent statuses inside sentences ("still a draft"). */
|
|
1102
|
+
const AGENT_STATUS_LABELS = {
|
|
1103
|
+
DRAFT: "still a draft",
|
|
1104
|
+
PAUSED: "paused",
|
|
1105
|
+
TRAINING: "still training",
|
|
1106
|
+
ARCHIVED: "archived",
|
|
1107
|
+
DELETED: "deleted",
|
|
1108
|
+
ACTIVE: "published"
|
|
1109
|
+
};
|
|
1110
|
+
/** Short agent status labels for pickers and headers ("Agent: draft"). */
|
|
1111
|
+
const AGENT_STATUS_SHORT_LABELS = {
|
|
1112
|
+
DRAFT: "Draft",
|
|
1113
|
+
ACTIVE: "Published",
|
|
1114
|
+
PAUSED: "Paused",
|
|
1115
|
+
TRAINING: "Training",
|
|
1116
|
+
ARCHIVED: "Archived",
|
|
1117
|
+
DELETED: "Deleted"
|
|
1118
|
+
};
|
|
1119
|
+
const BUDGET_KEY_LABELS = {
|
|
1120
|
+
CREDITS: "credits",
|
|
1121
|
+
AI_CREDITS: "AI credits",
|
|
1122
|
+
STEPS: "steps",
|
|
1123
|
+
DESK_MINUTES: "desk minutes",
|
|
1124
|
+
WALL_SECONDS: "seconds of run time"
|
|
1125
|
+
};
|
|
1126
|
+
const BUDGET_LEVEL_LABELS = {
|
|
1127
|
+
RUN: "per run",
|
|
1128
|
+
DAY: "per day",
|
|
1129
|
+
TOTAL: "in total"
|
|
1130
|
+
};
|
|
1131
|
+
const CONTROL_LABELS = {
|
|
1132
|
+
AUTONOMY: "autonomy",
|
|
1133
|
+
EGRESS_MODE: "which sites desks may visit",
|
|
1134
|
+
APPROVAL_SCOPE: "how broadly actions may be approved",
|
|
1135
|
+
EXTERNAL_MESSAGE: "messages to people outside the workspace"
|
|
1136
|
+
};
|
|
1137
|
+
const MODEL_ROLE_LABELS = {
|
|
1138
|
+
mainModelId: "main",
|
|
1139
|
+
reviewerModelId: "reviewer",
|
|
1140
|
+
visionModelId: "vision",
|
|
1141
|
+
MAIN: "main",
|
|
1142
|
+
REVIEWER: "reviewer",
|
|
1143
|
+
VISION: "vision"
|
|
1144
|
+
};
|
|
1145
|
+
const OWNER_AREA_LABELS = {
|
|
1146
|
+
charter: "charter",
|
|
1147
|
+
duties: "duties",
|
|
1148
|
+
memory: "memory",
|
|
1149
|
+
playbooks: "playbooks",
|
|
1150
|
+
approvalRules: "approval rules"
|
|
1151
|
+
};
|
|
1152
|
+
|
|
1153
|
+
// src/guided/extract.ts
|
|
1154
|
+
/**
|
|
1155
|
+
* Reads the code, message and extensions of any error a Stewards surface can
|
|
1156
|
+
* hold, without depending on the client that produced it:
|
|
1157
|
+
*
|
|
1158
|
+
* - the SDK's `StewardsRequestError` (`code`, `extensions`);
|
|
1159
|
+
* - Apollo Client 4 `CombinedGraphQLErrors` (`errors[]`) and Apollo 3
|
|
1160
|
+
* `ApolloError` (`graphQLErrors[]`): the first GraphQL error;
|
|
1161
|
+
* - Apollo Client 4 `ServerError` (`bodyText`, `statusCode`): the gateway's
|
|
1162
|
+
* HTTP 403 or 5xx answers carry a GraphQL body there;
|
|
1163
|
+
* - a bare GraphQL error object (`message`, `extensions`);
|
|
1164
|
+
* - any other `Error`: its message only.
|
|
1165
|
+
*/
|
|
1166
|
+
function extractGuidedSource(error) {
|
|
1167
|
+
if (error == null) return void 0;
|
|
1168
|
+
if (typeof error === "string") return { message: error };
|
|
1169
|
+
if (typeof error !== "object") return { message: String(error) };
|
|
1170
|
+
const record = error;
|
|
1171
|
+
const graphqlErrors = firstGraphqlError(record.errors ?? record.graphQLErrors);
|
|
1172
|
+
if (graphqlErrors) return graphqlErrors;
|
|
1173
|
+
const ownExtensions = asRecord(record.extensions);
|
|
1174
|
+
const ownCode = typeof record.code === "string" ? record.code : typeof ownExtensions?.code === "string" ? ownExtensions.code : void 0;
|
|
1175
|
+
if (ownCode || ownExtensions) return {
|
|
1176
|
+
...ownCode ? { code: ownCode } : {},
|
|
1177
|
+
...messageOf(record),
|
|
1178
|
+
...ownExtensions ? { extensions: ownExtensions } : {}
|
|
1179
|
+
};
|
|
1180
|
+
const fromBody = fromBodyText(record.bodyText, record.statusCode);
|
|
1181
|
+
if (fromBody) return fromBody;
|
|
1182
|
+
return messageOf(record);
|
|
1183
|
+
}
|
|
1184
|
+
function asRecord(value) {
|
|
1185
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
1186
|
+
}
|
|
1187
|
+
function messageOf(record) {
|
|
1188
|
+
return typeof record.message === "string" && record.message !== "" ? { message: record.message } : {};
|
|
1189
|
+
}
|
|
1190
|
+
function firstGraphqlError(value) {
|
|
1191
|
+
if (!Array.isArray(value) || value.length === 0) return void 0;
|
|
1192
|
+
const first = asRecord(value[0]);
|
|
1193
|
+
if (!first) return void 0;
|
|
1194
|
+
const extensions = asRecord(first.extensions);
|
|
1195
|
+
const code = typeof extensions?.code === "string" ? extensions.code : void 0;
|
|
1196
|
+
return {
|
|
1197
|
+
...code ? { code } : {},
|
|
1198
|
+
...messageOf(first),
|
|
1199
|
+
...extensions ? { extensions } : {}
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1202
|
+
function fromBodyText(bodyText, statusCode) {
|
|
1203
|
+
if (typeof bodyText !== "string" || bodyText.trim() === "") return void 0;
|
|
1204
|
+
let parsed;
|
|
1205
|
+
try {
|
|
1206
|
+
parsed = JSON.parse(bodyText);
|
|
1207
|
+
} catch {
|
|
1208
|
+
return statusSource(statusCode);
|
|
1209
|
+
}
|
|
1210
|
+
return firstGraphqlError(asRecord(parsed)?.errors) ?? statusSource(statusCode);
|
|
1211
|
+
}
|
|
1212
|
+
function statusSource(statusCode) {
|
|
1213
|
+
if (typeof statusCode !== "number") return void 0;
|
|
1214
|
+
if (statusCode === 401) return { code: "UNAUTHENTICATED" };
|
|
1215
|
+
if (statusCode === 403) return { code: "FORBIDDEN" };
|
|
1216
|
+
if (statusCode >= 500) return { code: "SERVICE_UNAVAILABLE" };
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
// src/guided/describe.ts
|
|
1220
|
+
/** A table entry the table itself holds: a key such as `constructor` never reads an inherited value. */
|
|
1221
|
+
function own(table, key) {
|
|
1222
|
+
return Object.prototype.hasOwnProperty.call(table, key) ? table[key] : void 0;
|
|
1223
|
+
}
|
|
1224
|
+
/** `AGENT_NOT_ACTIVE` → `agentNotActive`. */
|
|
1225
|
+
function reasonCamel(reason) {
|
|
1226
|
+
return reason.toLowerCase().replace(/_([a-z0-9])/g, (_m, c) => c.toUpperCase());
|
|
1227
|
+
}
|
|
1228
|
+
const KNOWN_REASONS = /* @__PURE__ */ new Set([
|
|
1229
|
+
"AGENT_NOT_ACTIVE",
|
|
1230
|
+
"STEWARD_NOT_ACTIVE",
|
|
1231
|
+
"STEWARD_ARCHIVED",
|
|
1232
|
+
"STEWARD_STATUS_CHANGED",
|
|
1233
|
+
"AGENT_UNAVAILABLE",
|
|
1234
|
+
"STEWARD_AGENT_NOT_USABLE",
|
|
1235
|
+
"AGENT_ALREADY_STEWARD",
|
|
1236
|
+
"AGENT_NEEDS_MODEL",
|
|
1237
|
+
"AGENT_APPROVAL_REQUIRED",
|
|
1238
|
+
"ACTIVATION_ALREADY_PENDING",
|
|
1239
|
+
"ACTIVATION_SELF_REVIEW",
|
|
1240
|
+
"ACTIVATION_REQUEST_STALE",
|
|
1241
|
+
"ACTIVATION_ONLY_REQUESTER",
|
|
1242
|
+
"ACTIVATION_REQUEST_CLOSED",
|
|
1243
|
+
"ACTIVATION_AGENT_ARCHIVED",
|
|
1244
|
+
"STEWARD_RUNS_USED_UP",
|
|
1245
|
+
"DESK_MINUTES_USED_UP",
|
|
1246
|
+
"DESK_MINUTES_NOT_IN_PLAN",
|
|
1247
|
+
"AI_CREDITS_USED_UP",
|
|
1248
|
+
"STEWARD_BUDGET_USED_UP",
|
|
1249
|
+
"STEP_LIMIT_REACHED",
|
|
1250
|
+
"PLAN_LIMIT_REACHED",
|
|
1251
|
+
"MODEL_NOT_SET_UP",
|
|
1252
|
+
"MODEL_CALL_FAILED",
|
|
1253
|
+
"CHARTER_MODEL_NOT_USABLE",
|
|
1254
|
+
"MODEL_PROVIDER_TEST_FAILED",
|
|
1255
|
+
"TOOL_FAILED",
|
|
1256
|
+
"ACTION_RESULT_UNKNOWN",
|
|
1257
|
+
"ACTION_NOT_APPROVED",
|
|
1258
|
+
"NEEDS_A_PERSON",
|
|
1259
|
+
"APPROVAL_SCOPE_NOT_ALLOWED",
|
|
1260
|
+
"APPROVAL_SCOPE_LOCKED",
|
|
1261
|
+
"APPROVAL_PURPOSE_REQUIRED",
|
|
1262
|
+
"APPROVAL_OWN_REQUEST",
|
|
1263
|
+
"APPROVAL_NOT_APPROVER",
|
|
1264
|
+
"APPROVAL_ALREADY_DECIDED",
|
|
1265
|
+
"DELEGATION_REVOKED",
|
|
1266
|
+
"CLOUD_DESK_BUSY_OR_UNAVAILABLE",
|
|
1267
|
+
"CLOUD_DESK_LIMIT_REACHED",
|
|
1268
|
+
"CLOUD_DESK_TEMPLATE_NOT_ALLOWED",
|
|
1269
|
+
"OWN_MACHINE_NOT_GRANTED",
|
|
1270
|
+
"OWN_MACHINE_OFFLINE",
|
|
1271
|
+
"OWN_MACHINE_OWNER_ONLY",
|
|
1272
|
+
"OWN_MACHINE_NOT_USABLE",
|
|
1273
|
+
"OWN_MACHINE_IN_USE",
|
|
1274
|
+
"OWN_MACHINE_TRY_AGAIN",
|
|
1275
|
+
"DESK_ACTION_BLOCKED",
|
|
1276
|
+
"DESK_SIGN_IN_LOST",
|
|
1277
|
+
"FIELD_INVALID",
|
|
1278
|
+
"STALE_EDIT",
|
|
1279
|
+
"OWNER_ONLY",
|
|
1280
|
+
"WORKSPACE_LIMIT_SETTING",
|
|
1281
|
+
"DUTY_LIMIT_REACHED",
|
|
1282
|
+
"DUTY_ARCHIVED",
|
|
1283
|
+
"DUTY_WEBHOOK_TOKEN_INVALID",
|
|
1284
|
+
"DUTY_SCHEDULE_NOT_SAVED",
|
|
1285
|
+
"DUTY_NOT_A_PROPOSAL",
|
|
1286
|
+
"DUTY_FIRE_NOT_ALLOWED",
|
|
1287
|
+
"MEMORY_KEY_TAKEN",
|
|
1288
|
+
"MEMORY_LIMIT_REACHED",
|
|
1289
|
+
"MEMORY_OUTCOME_NOT_READY",
|
|
1290
|
+
"MEMORY_NOT_FOUND",
|
|
1291
|
+
"PLAYBOOK_NOT_ACTIVE",
|
|
1292
|
+
"PLAYBOOK_NEEDS_RECORDING",
|
|
1293
|
+
"PLAYBOOK_LIMIT_REACHED",
|
|
1294
|
+
"PLAYBOOK_ARCHIVED",
|
|
1295
|
+
"RUN_ALREADY_ENDED",
|
|
1296
|
+
"PERMISSION_DENIED",
|
|
1297
|
+
"PERMISSION_CHECK_UNAVAILABLE",
|
|
1298
|
+
"SESSION_ENDED",
|
|
1299
|
+
"WORKSPACE_REQUIRED",
|
|
1300
|
+
"NOT_FOUND",
|
|
1301
|
+
"SERVICE_TROUBLE"
|
|
1302
|
+
]);
|
|
1303
|
+
/**
|
|
1304
|
+
* Server `i18nKey`s the catalog names, for services that do not send
|
|
1305
|
+
* `extensions.reason` yet. Keys are matched exactly; the `steward.errors.`
|
|
1306
|
+
* prefix is shared by the BotManor steward services.
|
|
1307
|
+
*/
|
|
1308
|
+
const I18N_KEY_HINTS = {
|
|
1309
|
+
"steward.errors.agentNotActive": "AGENT_NOT_ACTIVE",
|
|
1310
|
+
"steward.errors.notActive": "STEWARD_NOT_ACTIVE",
|
|
1311
|
+
"steward.errors.archived": "STEWARD_ARCHIVED",
|
|
1312
|
+
"steward.errors.ownMachineArchived": "STEWARD_ARCHIVED",
|
|
1313
|
+
"steward.errors.invalidStatusTransition": "STEWARD_STATUS_CHANGED",
|
|
1314
|
+
"agent.errors.notFound": ["STEWARD_AGENT_NOT_USABLE", "gone"],
|
|
1315
|
+
"steward.errors.agentNotUsable": "STEWARD_AGENT_NOT_USABLE",
|
|
1316
|
+
"steward.errors.alreadySteward": "AGENT_ALREADY_STEWARD",
|
|
1317
|
+
"agent.errors.activationNeedsModel": ["AGENT_NEEDS_MODEL", "missing"],
|
|
1318
|
+
"agent.errors.modelNotUsable": ["AGENT_NEEDS_MODEL", "unusable"],
|
|
1319
|
+
"agent.approval.errors.approvalRequired": "AGENT_APPROVAL_REQUIRED",
|
|
1320
|
+
"agent.approval.errors.alreadyPending": "ACTIVATION_ALREADY_PENDING",
|
|
1321
|
+
"agent.approval.errors.selfReviewNotAllowed": "ACTIVATION_SELF_REVIEW",
|
|
1322
|
+
"agent.approval.errors.requestStale": "ACTIVATION_REQUEST_STALE",
|
|
1323
|
+
"agent.approval.errors.onlyRequesterCanCancel": "ACTIVATION_ONLY_REQUESTER",
|
|
1324
|
+
"agent.approval.errors.notPending": "ACTIVATION_REQUEST_CLOSED",
|
|
1325
|
+
"agent.approval.errors.requestNotFound": "ACTIVATION_REQUEST_CLOSED",
|
|
1326
|
+
"agent.approval.errors.agentArchived": "ACTIVATION_AGENT_ARCHIVED",
|
|
1327
|
+
"agent.approval.errors.reasonRequired": "FIELD_INVALID",
|
|
1328
|
+
"agent.approval.errors.textTooLong": "FIELD_INVALID",
|
|
1329
|
+
"steward.errors.runQuotaExhausted": "STEWARD_RUNS_USED_UP",
|
|
1330
|
+
"steward.errors.deskMinutesExhausted": "DESK_MINUTES_USED_UP",
|
|
1331
|
+
"sandbox.errors.deskMinutesExhausted": "DESK_MINUTES_USED_UP",
|
|
1332
|
+
"steward.errors.deskMinutesNotInPlan": "DESK_MINUTES_NOT_IN_PLAN",
|
|
1333
|
+
"steward.errors.aiCreditsExhausted": "AI_CREDITS_USED_UP",
|
|
1334
|
+
"steward.errors.aiCreditsNotInPlan": ["AI_CREDITS_USED_UP", "notInPlan"],
|
|
1335
|
+
"steward.errors.modelNotFound": ["CHARTER_MODEL_NOT_USABLE", "notFound"],
|
|
1336
|
+
"steward.errors.reviewerModelUnpriced": ["CHARTER_MODEL_NOT_USABLE", "unpriced"],
|
|
1337
|
+
"steward.errors.ruleNotOwner": "APPROVAL_SCOPE_NOT_ALLOWED",
|
|
1338
|
+
"steward.errors.ruleTooBroad": "APPROVAL_SCOPE_NOT_ALLOWED",
|
|
1339
|
+
"steward.errors.ruleStandingDestructive": "APPROVAL_SCOPE_NOT_ALLOWED",
|
|
1340
|
+
"steward.errors.ruleFixedDefault": "APPROVAL_SCOPE_NOT_ALLOWED",
|
|
1341
|
+
"steward.errors.ruleNeedsDuty": "APPROVAL_SCOPE_NOT_ALLOWED",
|
|
1342
|
+
"toolApproval.errors.scopeNotAvailable": "APPROVAL_SCOPE_NOT_ALLOWED",
|
|
1343
|
+
"toolApproval.errors.scopeNotAllowed": "APPROVAL_SCOPE_NOT_ALLOWED",
|
|
1344
|
+
"steward.errors.rulePurposeRequired": "APPROVAL_PURPOSE_REQUIRED",
|
|
1345
|
+
"toolApproval.errors.reasonRequired": "APPROVAL_PURPOSE_REQUIRED",
|
|
1346
|
+
"toolApproval.errors.ownRequest": "APPROVAL_OWN_REQUEST",
|
|
1347
|
+
"toolApproval.errors.notApprover": "APPROVAL_NOT_APPROVER",
|
|
1348
|
+
"toolApproval.errors.notPending": "APPROVAL_ALREADY_DECIDED",
|
|
1349
|
+
"toolApproval.errors.notFound": "APPROVAL_ALREADY_DECIDED",
|
|
1350
|
+
"steward.errors.ruleNotFound": "APPROVAL_ALREADY_DECIDED",
|
|
1351
|
+
"steward.errors.ownMachineGrantRequired": ["OWN_MACHINE_NOT_GRANTED", "noGrant"],
|
|
1352
|
+
"steward.errors.ownMachineNotOwner": ["OWN_MACHINE_OWNER_ONLY", "steward"],
|
|
1353
|
+
"stewardGrant.errors.ownerOnly": ["OWN_MACHINE_OWNER_ONLY", "machine"],
|
|
1354
|
+
"steward.errors.ownMachineAgentInvalid": "OWN_MACHINE_NOT_USABLE",
|
|
1355
|
+
"steward.errors.ownMachineDeskInUse": "OWN_MACHINE_IN_USE",
|
|
1356
|
+
"steward.errors.ownMachineCheckUnavailable": "OWN_MACHINE_TRY_AGAIN",
|
|
1357
|
+
"steward.errors.ownMachineChangedConcurrently": "OWN_MACHINE_TRY_AGAIN",
|
|
1358
|
+
"steward.errors.charterVersionConflict": "STALE_EDIT",
|
|
1359
|
+
"steward.errors.memoryRevisionConflict": "STALE_EDIT",
|
|
1360
|
+
"steward.errors.playbookVersionConflict": "STALE_EDIT",
|
|
1361
|
+
"steward.errors.charterEditorNotAllowed": ["OWNER_ONLY", "charter"],
|
|
1362
|
+
"steward.errors.dutyEditorNotAllowed": ["OWNER_ONLY", "duties"],
|
|
1363
|
+
"steward.errors.memoryEditorNotAllowed": ["OWNER_ONLY", "memory"],
|
|
1364
|
+
"steward.errors.playbookEditorNotAllowed": ["OWNER_ONLY", "playbooks"],
|
|
1365
|
+
"steward.errors.autonomyLocked": ["WORKSPACE_LIMIT_SETTING", "AUTONOMY"],
|
|
1366
|
+
"steward.errors.egressModeLocked": ["WORKSPACE_LIMIT_SETTING", "EGRESS_MODE"],
|
|
1367
|
+
"steward.errors.invalidControl": "WORKSPACE_LIMIT_SETTING",
|
|
1368
|
+
"steward.errors.ruleScopeLocked": ["WORKSPACE_LIMIT_SETTING", "APPROVAL_SCOPE"],
|
|
1369
|
+
"steward.errors.ruleExternalMessageLocked": ["WORKSPACE_LIMIT_SETTING", "EXTERNAL_MESSAGE"],
|
|
1370
|
+
"steward.errors.tooManyDuties": "DUTY_LIMIT_REACHED",
|
|
1371
|
+
"steward.errors.dutyArchived": "DUTY_ARCHIVED",
|
|
1372
|
+
"steward.errors.dutyTokenInvalid": "DUTY_WEBHOOK_TOKEN_INVALID",
|
|
1373
|
+
"steward.errors.dutyHasNoToken": "DUTY_WEBHOOK_TOKEN_INVALID",
|
|
1374
|
+
"steward.errors.notAProposal": "DUTY_NOT_A_PROPOSAL",
|
|
1375
|
+
"steward.errors.dutyStewardMismatch": "DUTY_NOT_A_PROPOSAL",
|
|
1376
|
+
"steward.errors.dutyFireNotAllowed": "DUTY_FIRE_NOT_ALLOWED",
|
|
1377
|
+
"steward.errors.memoryKeyTaken": "MEMORY_KEY_TAKEN",
|
|
1378
|
+
"steward.errors.tooManyMemoryDocs": "MEMORY_LIMIT_REACHED",
|
|
1379
|
+
"steward.errors.memoryOutcomeNotCompleted": "MEMORY_OUTCOME_NOT_READY",
|
|
1380
|
+
"steward.errors.memoryOutcomeAlreadySaved": "MEMORY_OUTCOME_NOT_READY",
|
|
1381
|
+
"steward.errors.memoryNotFound": "MEMORY_NOT_FOUND",
|
|
1382
|
+
"steward.errors.memoryRevisionNotFound": "MEMORY_NOT_FOUND",
|
|
1383
|
+
"steward.errors.playbookNotUsable": "PLAYBOOK_NOT_ACTIVE",
|
|
1384
|
+
"steward.errors.playbookRecordingInvalid": "PLAYBOOK_NEEDS_RECORDING",
|
|
1385
|
+
"steward.errors.playbookRecordingUnusable": "PLAYBOOK_NEEDS_RECORDING",
|
|
1386
|
+
"steward.errors.runSavedStepsNotCompleted": "PLAYBOOK_NEEDS_RECORDING",
|
|
1387
|
+
"steward.errors.runSavedStepsDryRun": "PLAYBOOK_NEEDS_RECORDING",
|
|
1388
|
+
"steward.errors.runSavedStepsRangeInvalid": "PLAYBOOK_NEEDS_RECORDING",
|
|
1389
|
+
"steward.errors.tooManyPlaybooks": "PLAYBOOK_LIMIT_REACHED",
|
|
1390
|
+
"steward.errors.playbookArchived": "PLAYBOOK_ARCHIVED",
|
|
1391
|
+
"steward.errors.runNotCancellable": "RUN_ALREADY_ENDED",
|
|
1392
|
+
"rbac.errors.forbidden": "PERMISSION_DENIED",
|
|
1393
|
+
"common.errors.actorRequired": "SESSION_ENDED",
|
|
1394
|
+
"common.errors.workspaceRequired": "WORKSPACE_REQUIRED",
|
|
1395
|
+
"steward.errors.notFound": "NOT_FOUND",
|
|
1396
|
+
"steward.errors.runNotFound": "NOT_FOUND",
|
|
1397
|
+
"sandbox.errors.activeSandboxCapReached": ["CLOUD_DESK_LIMIT_REACHED", "plan"]
|
|
1398
|
+
};
|
|
1399
|
+
/** G1: field-validation keys whose server text is already plain and field-specific. */
|
|
1400
|
+
const FIELD_KEYS = /* @__PURE__ */ new Set([
|
|
1401
|
+
"charterTextRequired",
|
|
1402
|
+
"charterTextTooLong",
|
|
1403
|
+
"tooManyToolKeys",
|
|
1404
|
+
"invalidToolKey",
|
|
1405
|
+
"tooManyConnections",
|
|
1406
|
+
"invalidConnectionId",
|
|
1407
|
+
"invalidEgressHost",
|
|
1408
|
+
"tooManyEgressHosts",
|
|
1409
|
+
"invalidTimezone",
|
|
1410
|
+
"sameReviewerModel",
|
|
1411
|
+
"invalidBudget",
|
|
1412
|
+
"dutyTriggerInvalid",
|
|
1413
|
+
"dutyScheduleInvalid",
|
|
1414
|
+
"dutyNameRequired",
|
|
1415
|
+
"dutyPromptOrPlaybook",
|
|
1416
|
+
"dutyPayloadTooLarge",
|
|
1417
|
+
"proposalReasonTooLong",
|
|
1418
|
+
"memoryKeyInvalid",
|
|
1419
|
+
"memoryBodyTooLong",
|
|
1420
|
+
"memoryOutcomeEmpty",
|
|
1421
|
+
"memoryOutcomeTooLong",
|
|
1422
|
+
"playbookNameRequired",
|
|
1423
|
+
"playbookSkillMdTooLong",
|
|
1424
|
+
"playbookManifestInvalid",
|
|
1425
|
+
"playbookStatusInvalid",
|
|
1426
|
+
"promptRequired",
|
|
1427
|
+
"promptTooLong"
|
|
1428
|
+
]);
|
|
1429
|
+
/** Transport and GraphQL codes, for errors that carry neither a reason nor a known key. */
|
|
1430
|
+
const CODE_HINTS = {
|
|
1431
|
+
SANDBOX_DESKTOP_POOL_FULL: ["CLOUD_DESK_BUSY_OR_UNAVAILABLE", "poolFull"],
|
|
1432
|
+
SANDBOX_DESKTOP_QUOTA_UNAVAILABLE: ["CLOUD_DESK_BUSY_OR_UNAVAILABLE", "checkUnavailable"],
|
|
1433
|
+
SANDBOX_DESKTOP_NOT_CONFIGURED: ["CLOUD_DESK_BUSY_OR_UNAVAILABLE", "notConfigured"],
|
|
1434
|
+
SANDBOX_WORKSPACE_LIMIT_REACHED: ["CLOUD_DESK_LIMIT_REACHED", "workspace"],
|
|
1435
|
+
SANDBOX_USER_CONCURRENCY_LIMIT: ["CLOUD_DESK_LIMIT_REACHED", "person"],
|
|
1436
|
+
RESOURCE_CAP_EXCEEDED: ["CLOUD_DESK_LIMIT_REACHED", "plan"],
|
|
1437
|
+
SANDBOX_TEMPLATE_NOT_ALLOWED: "CLOUD_DESK_TEMPLATE_NOT_ALLOWED",
|
|
1438
|
+
STEWARD_GRANT_REQUIRED: ["OWN_MACHINE_NOT_GRANTED", "noGrant"],
|
|
1439
|
+
STEWARD_GRANT_SCOPE: ["OWN_MACHINE_NOT_GRANTED", "scope"],
|
|
1440
|
+
STEWARD_APP_NOT_ALLOWED: ["OWN_MACHINE_NOT_GRANTED", "app"],
|
|
1441
|
+
LLM_CONNECTION_FAILED: "MODEL_PROVIDER_TEST_FAILED",
|
|
1442
|
+
RBAC_SERVICE_UNAVAILABLE: "PERMISSION_CHECK_UNAVAILABLE",
|
|
1443
|
+
UNAUTHENTICATED: "SESSION_ENDED",
|
|
1444
|
+
UNAUTHORIZED: "PERMISSION_DENIED",
|
|
1445
|
+
GATEWAY_TIMEOUT: "SERVICE_TROUBLE",
|
|
1446
|
+
BAD_GATEWAY: "SERVICE_TROUBLE",
|
|
1447
|
+
SUBREQUEST_HTTP_ERROR: "SERVICE_TROUBLE",
|
|
1448
|
+
SERVICE_UNAVAILABLE: "SERVICE_TROUBLE",
|
|
1449
|
+
INTERNAL_SERVER_ERROR: "SERVICE_TROUBLE",
|
|
1450
|
+
NETWORK: "SERVICE_TROUBLE",
|
|
1451
|
+
BAD_RESPONSE: "SERVICE_TROUBLE"
|
|
1452
|
+
};
|
|
1453
|
+
const DESK_MINUTES_QUOTA = /desk[-_.]?minutes/i;
|
|
1454
|
+
const RUNS_QUOTA = /stewards\.runs$/i;
|
|
1455
|
+
function str(value) {
|
|
1456
|
+
return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
|
|
1457
|
+
}
|
|
1458
|
+
function num(value) {
|
|
1459
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
1460
|
+
}
|
|
1461
|
+
function bool(value) {
|
|
1462
|
+
return typeof value === "boolean" ? value : void 0;
|
|
1463
|
+
}
|
|
1464
|
+
/**
|
|
1465
|
+
* The agent status an older service only wrote into its message ("… it is
|
|
1466
|
+
* DRAFT."), used when neither `extensions.agentStatus` nor the surface's own
|
|
1467
|
+
* data says it.
|
|
1468
|
+
*/
|
|
1469
|
+
function statusFromMessage(message) {
|
|
1470
|
+
return (message?.match(/\b(DRAFT|PAUSED|TRAINING|ARCHIVED|DELETED)\b/))?.[1];
|
|
1471
|
+
}
|
|
1472
|
+
function stewardStatusFromMessage(message) {
|
|
1473
|
+
return (message?.match(/\b(DRAFT|PAUSED|ARCHIVED)\b/))?.[1];
|
|
1474
|
+
}
|
|
1475
|
+
function hintOf(hint) {
|
|
1476
|
+
return typeof hint === "string" ? { reason: hint } : {
|
|
1477
|
+
reason: hint[0],
|
|
1478
|
+
variant: hint[1]
|
|
1479
|
+
};
|
|
1480
|
+
}
|
|
1481
|
+
/** Which catalog entry an error belongs to: `reason`, then `i18nKey`, then `code`. */
|
|
1482
|
+
function classify(source) {
|
|
1483
|
+
const ext = source.extensions ?? {};
|
|
1484
|
+
const reason = str(ext.reason);
|
|
1485
|
+
const key = str(ext.i18nKey);
|
|
1486
|
+
if (reason && KNOWN_REASONS.has(reason)) {
|
|
1487
|
+
if (reason === "APPROVAL_SCOPE_LOCKED") return {
|
|
1488
|
+
reason: "WORKSPACE_LIMIT_SETTING",
|
|
1489
|
+
variant: "APPROVAL_SCOPE"
|
|
1490
|
+
};
|
|
1491
|
+
const keyed = key ? own(I18N_KEY_HINTS, key) : void 0;
|
|
1492
|
+
const hint = keyed ? hintOf(keyed) : void 0;
|
|
1493
|
+
return hint && hint.reason === reason && hint.variant ? {
|
|
1494
|
+
reason,
|
|
1495
|
+
variant: hint.variant
|
|
1496
|
+
} : { reason };
|
|
1497
|
+
}
|
|
1498
|
+
if (key) {
|
|
1499
|
+
const hint = own(I18N_KEY_HINTS, key);
|
|
1500
|
+
if (hint) return hintOf(hint);
|
|
1501
|
+
const leaf = key.split(".").pop() ?? "";
|
|
1502
|
+
if (FIELD_KEYS.has(leaf)) return { reason: "FIELD_INVALID" };
|
|
1503
|
+
}
|
|
1504
|
+
const code = source.code ?? str(ext.code);
|
|
1505
|
+
const quotaKey = str(ext.quotaKey) ?? str(ext.quotaName);
|
|
1506
|
+
if (code === "QUOTA_EXHAUSTED") {
|
|
1507
|
+
if (quotaKey && DESK_MINUTES_QUOTA.test(quotaKey)) return { reason: "DESK_MINUTES_USED_UP" };
|
|
1508
|
+
if (quotaKey && RUNS_QUOTA.test(quotaKey)) return { reason: "STEWARD_RUNS_USED_UP" };
|
|
1509
|
+
if (quotaKey && /sandbox/i.test(quotaKey)) return {
|
|
1510
|
+
reason: "CLOUD_DESK_LIMIT_REACHED",
|
|
1511
|
+
variant: "plan"
|
|
1512
|
+
};
|
|
1513
|
+
return { reason: "PLAN_LIMIT_REACHED" };
|
|
1514
|
+
}
|
|
1515
|
+
if (code === "QUOTA_NOT_PROVISIONED") {
|
|
1516
|
+
if (quotaKey && DESK_MINUTES_QUOTA.test(quotaKey)) return { reason: "DESK_MINUTES_NOT_IN_PLAN" };
|
|
1517
|
+
return {
|
|
1518
|
+
reason: "PLAN_LIMIT_REACHED",
|
|
1519
|
+
variant: "notInPlan"
|
|
1520
|
+
};
|
|
1521
|
+
}
|
|
1522
|
+
if (code === "FORBIDDEN" && ext.authFailure !== void 0) return { reason: "SESSION_ENDED" };
|
|
1523
|
+
if (code === "FORBIDDEN") return key && key !== "rbac.errors.forbidden" ? { reason: "UNKNOWN" } : { reason: "PERMISSION_DENIED" };
|
|
1524
|
+
if (code === "BAD_USER_INPUT" && !key) return { reason: "FIELD_INVALID" };
|
|
1525
|
+
if (code === "NOT_FOUND") return { reason: "NOT_FOUND" };
|
|
1526
|
+
const codeHint = code ? own(CODE_HINTS, code) : void 0;
|
|
1527
|
+
if (codeHint) return hintOf(codeHint);
|
|
1528
|
+
return { reason: "UNKNOWN" };
|
|
1529
|
+
}
|
|
1530
|
+
function formatResetDate(iso) {
|
|
1531
|
+
const date = new Date(iso);
|
|
1532
|
+
if (Number.isNaN(date.getTime())) return void 0;
|
|
1533
|
+
return date.toISOString().slice(0, 10);
|
|
1534
|
+
}
|
|
1535
|
+
/** Variant and parameters for one reason, from the extensions and the surface's context. */
|
|
1536
|
+
function refine(base, source, context) {
|
|
1537
|
+
const ext = source.extensions ?? {};
|
|
1538
|
+
const params = {};
|
|
1539
|
+
const put = (name, value) => {
|
|
1540
|
+
if (value !== void 0) params[name] = value;
|
|
1541
|
+
};
|
|
1542
|
+
put("stewardId", str(ext.stewardId) ?? context.stewardId);
|
|
1543
|
+
put("agentId", str(ext.agentId) ?? context.agent?.id);
|
|
1544
|
+
put("runId", context.runId);
|
|
1545
|
+
put("ownerActorId", str(ext.ownerActorId) ?? context.ownerActorId);
|
|
1546
|
+
put("existingStewardId", str(ext.existingStewardId));
|
|
1547
|
+
put("pendingActivationRequestId", str(ext.pendingActivationRequestId));
|
|
1548
|
+
put("machineId", str(ext.machineId));
|
|
1549
|
+
put("machineOwnerActorId", str(ext.machineOwnerActorId));
|
|
1550
|
+
put("dutyId", str(ext.dutyId));
|
|
1551
|
+
put("playbookId", str(ext.playbookId));
|
|
1552
|
+
put("connectionId", str(ext.connectionId));
|
|
1553
|
+
put("serverMessage", source.message);
|
|
1554
|
+
put("quotaKey", str(ext.quotaKey) ?? str(ext.quotaName));
|
|
1555
|
+
let { reason, variant } = base;
|
|
1556
|
+
switch (reason) {
|
|
1557
|
+
case "AGENT_NOT_ACTIVE": {
|
|
1558
|
+
const known = str(context.agent?.status);
|
|
1559
|
+
const status = str(ext.agentStatus) ?? statusFromMessage(source.message) ?? (known === "ACTIVE" ? void 0 : known);
|
|
1560
|
+
const hasModel = bool(ext.agentHasModel) ?? (context.agent && "llmModelId" in context.agent ? context.agent.llmModelId != null : void 0);
|
|
1561
|
+
if (status) put("statusLabel", AGENT_STATUS_LABELS[status] ?? status);
|
|
1562
|
+
if (status === "ARCHIVED" || status === "DELETED") variant = "archived";
|
|
1563
|
+
else if (status === "TRAINING") variant = "training";
|
|
1564
|
+
else if (str(ext.pendingActivationRequestId)) variant = "approvalPending";
|
|
1565
|
+
else if (bool(ext.activationApprovalRequired) === true) variant = "draftNeedsApproval";
|
|
1566
|
+
else if (status === "PAUSED") variant = "paused";
|
|
1567
|
+
else if (hasModel === false) variant = "draftNoModel";
|
|
1568
|
+
else variant = "draftReady";
|
|
1569
|
+
break;
|
|
1570
|
+
}
|
|
1571
|
+
case "AI_CREDITS_USED_UP":
|
|
1572
|
+
if (variant !== "notInPlan" && (source.code ?? str(ext.code)) === "QUOTA_NOT_PROVISIONED") variant = "notInPlan";
|
|
1573
|
+
put("quotaKey", str(ext.quotaKey));
|
|
1574
|
+
break;
|
|
1575
|
+
case "AGENT_APPROVAL_REQUIRED":
|
|
1576
|
+
if (str(ext.pendingActivationRequestId)) reason = "ACTIVATION_ALREADY_PENDING";
|
|
1577
|
+
break;
|
|
1578
|
+
case "STEWARD_NOT_ACTIVE": {
|
|
1579
|
+
const status = str(ext.stewardStatus) ?? context.stewardStatus ?? stewardStatusFromMessage(source.message);
|
|
1580
|
+
if (status === "ARCHIVED") {
|
|
1581
|
+
reason = "STEWARD_ARCHIVED";
|
|
1582
|
+
variant = void 0;
|
|
1583
|
+
} else variant = status === "PAUSED" ? "paused" : "draft";
|
|
1584
|
+
break;
|
|
1585
|
+
}
|
|
1586
|
+
case "STEWARD_STATUS_CHANGED":
|
|
1587
|
+
if ((str(ext.stewardStatus) ?? context.stewardStatus) === "ARCHIVED") reason = "STEWARD_ARCHIVED";
|
|
1588
|
+
break;
|
|
1589
|
+
case "STEWARD_AGENT_NOT_USABLE": {
|
|
1590
|
+
const status = str(ext.agentStatus) ?? statusFromMessage(source.message);
|
|
1591
|
+
variant = variant ?? (status === "TRAINING" ? "training" : "gone");
|
|
1592
|
+
break;
|
|
1593
|
+
}
|
|
1594
|
+
case "AGENT_ALREADY_STEWARD":
|
|
1595
|
+
variant = str(ext.existingStewardStatus) === "ARCHIVED" ? "archived" : "live";
|
|
1596
|
+
if (params.existingStewardId) params.stewardId = params.existingStewardId;
|
|
1597
|
+
break;
|
|
1598
|
+
case "AGENT_NEEDS_MODEL":
|
|
1599
|
+
if (bool(ext.workspaceHasModels) === false) variant = "noneInWorkspace";
|
|
1600
|
+
else if (!variant) variant = str(ext.modelId) ? "unusable" : "missing";
|
|
1601
|
+
break;
|
|
1602
|
+
case "STEWARD_RUNS_USED_UP":
|
|
1603
|
+
case "DESK_MINUTES_USED_UP": {
|
|
1604
|
+
const resets = str(ext.resetsAt);
|
|
1605
|
+
const date = resets ? formatResetDate(resets) : void 0;
|
|
1606
|
+
if (date) put("resetsAt", date);
|
|
1607
|
+
else variant = "noReset";
|
|
1608
|
+
put("limitLeft", num(ext.limitLeft));
|
|
1609
|
+
put("quotaKey", str(ext.quotaKey) ?? str(ext.quotaName));
|
|
1610
|
+
break;
|
|
1611
|
+
}
|
|
1612
|
+
case "CHARTER_MODEL_NOT_USABLE": {
|
|
1613
|
+
const role = str(ext.modelRole) ?? str(ext.field);
|
|
1614
|
+
put("modelRoleLabel", role ? MODEL_ROLE_LABELS[role] ?? role : "main");
|
|
1615
|
+
variant = variant ?? "notFound";
|
|
1616
|
+
break;
|
|
1617
|
+
}
|
|
1618
|
+
case "CLOUD_DESK_LIMIT_REACHED": {
|
|
1619
|
+
put("limit", num(ext.limit));
|
|
1620
|
+
const quotaKey = str(ext.quotaKey);
|
|
1621
|
+
if (!variant) variant = quotaKey && /sandbox/i.test(quotaKey) ? "plan" : "workspace";
|
|
1622
|
+
if (params.limit === void 0) params.limit = "its";
|
|
1623
|
+
break;
|
|
1624
|
+
}
|
|
1625
|
+
case "CLOUD_DESK_BUSY_OR_UNAVAILABLE":
|
|
1626
|
+
variant = variant ?? "startFailed";
|
|
1627
|
+
break;
|
|
1628
|
+
case "OWN_MACHINE_NOT_GRANTED":
|
|
1629
|
+
put("scopeLabel", str(ext.missingScope));
|
|
1630
|
+
put("app", str(ext.app));
|
|
1631
|
+
variant = variant ?? (str(ext.app) ? "app" : str(ext.missingScope) ? "scope" : "noGrant");
|
|
1632
|
+
if (variant === "scope" && params.scopeLabel === void 0) params.scopeLabel = "this kind of work";
|
|
1633
|
+
if (variant === "app" && params.app === void 0) params.app = "an app";
|
|
1634
|
+
break;
|
|
1635
|
+
case "OWN_MACHINE_OWNER_ONLY":
|
|
1636
|
+
variant = variant ?? "steward";
|
|
1637
|
+
break;
|
|
1638
|
+
case "OWNER_ONLY": {
|
|
1639
|
+
const area = variant ?? "charter";
|
|
1640
|
+
put("areaLabel", OWNER_AREA_LABELS[area] ?? area);
|
|
1641
|
+
variant = area === "charter" || bool(ext.adminCanEdit) === true ? "charter" : void 0;
|
|
1642
|
+
break;
|
|
1643
|
+
}
|
|
1644
|
+
case "WORKSPACE_LIMIT_SETTING": {
|
|
1645
|
+
const control = str(ext.control) ?? variant;
|
|
1646
|
+
put("controlLabel", control ? CONTROL_LABELS[control] ?? control : "this setting");
|
|
1647
|
+
const allowed = Array.isArray(ext.allowedValues) ? ext.allowedValues.filter((v) => typeof v === "string" && v !== "") : [];
|
|
1648
|
+
if (allowed.length > 0) put("allowedLabels", allowed.map((v) => v.toLowerCase().replace(/_/g, " ")).join(", "));
|
|
1649
|
+
variant = allowed.length > 0 ? void 0 : "noOptions";
|
|
1650
|
+
break;
|
|
1651
|
+
}
|
|
1652
|
+
case "DUTY_LIMIT_REACHED":
|
|
1653
|
+
put("limit", num(ext.limit) ?? "its maximum");
|
|
1654
|
+
break;
|
|
1655
|
+
case "PLAYBOOK_NOT_ACTIVE":
|
|
1656
|
+
put("statusLabel", "not active");
|
|
1657
|
+
break;
|
|
1658
|
+
case "PLAYBOOK_NEEDS_RECORDING":
|
|
1659
|
+
if (/CREDENTIAL_IN_RECORDING/.test(source.message ?? "")) variant = "credential";
|
|
1660
|
+
put("specificReason", source.message ?? "they're out of date");
|
|
1661
|
+
break;
|
|
1662
|
+
case "APPROVAL_SCOPE_NOT_ALLOWED":
|
|
1663
|
+
put("specificReason", source.message ?? "");
|
|
1664
|
+
break;
|
|
1665
|
+
case "PERMISSION_DENIED": {
|
|
1666
|
+
const permission = str(ext.requiredPermission) ?? (str(ext.reason) === "PERMISSION_DENIED" ? void 0 : str(ext.permission));
|
|
1667
|
+
if (permission?.startsWith("scope:")) variant = "readOnlyCredential";
|
|
1668
|
+
else if (permission) {
|
|
1669
|
+
put("permission", permission);
|
|
1670
|
+
put("permissionLabel", PERMISSION_LABELS[permission] ?? permission.replace(":", " "));
|
|
1671
|
+
} else variant = "unknownPermission";
|
|
1672
|
+
break;
|
|
1673
|
+
}
|
|
1674
|
+
case "SERVICE_TROUBLE":
|
|
1675
|
+
if (source.message && source.code !== "INTERNAL_SERVER_ERROR" && !/^unexpected error\.?$/i.test(source.message.trim())) variant = "withMessage";
|
|
1676
|
+
break;
|
|
1677
|
+
case "UNKNOWN":
|
|
1678
|
+
case "FIELD_INVALID": if (params.serverMessage === void 0) params.serverMessage = "The request couldn't be completed.";
|
|
1679
|
+
}
|
|
1680
|
+
return variant ? {
|
|
1681
|
+
reason,
|
|
1682
|
+
variant,
|
|
1683
|
+
params
|
|
1684
|
+
} : {
|
|
1685
|
+
reason,
|
|
1686
|
+
params
|
|
1687
|
+
};
|
|
1688
|
+
}
|
|
1689
|
+
/** Reasons whose i18n base key is not their camel-cased name (catalog F1, F2). */
|
|
1690
|
+
const I18N_BASES = {
|
|
1691
|
+
CLOUD_DESK_BUSY_OR_UNAVAILABLE: "cloudDesk",
|
|
1692
|
+
CLOUD_DESK_LIMIT_REACHED: "cloudDeskLimit"
|
|
1693
|
+
};
|
|
1694
|
+
/** The i18n base for a reason: `guidedErrors.<base>`. */
|
|
1695
|
+
function guidedI18nBase(reason) {
|
|
1696
|
+
return I18N_BASES[reason] ?? reasonCamel(reason);
|
|
1697
|
+
}
|
|
1698
|
+
/** The entry key for a reason and variant, falling back to the reason alone. */
|
|
1699
|
+
function entryKey(reason, variant) {
|
|
1700
|
+
const base = guidedI18nBase(reason);
|
|
1701
|
+
if (variant && own(GUIDED_ENTRIES, `${base}.${variant}`)) return `${base}.${variant}`;
|
|
1702
|
+
if (own(GUIDED_ENTRIES, base)) return base;
|
|
1703
|
+
return "unknown";
|
|
1704
|
+
}
|
|
1705
|
+
/** Builds the guidance for a resolved reason, variant and parameters. */
|
|
1706
|
+
function buildGuidedError(resolved, extra = {}) {
|
|
1707
|
+
const key = entryKey(resolved.reason, resolved.variant);
|
|
1708
|
+
const entry = own(GUIDED_ENTRIES, key) ?? GUIDED_ENTRIES.unknown;
|
|
1709
|
+
const reason = key === "unknown" ? "UNKNOWN" : resolved.reason;
|
|
1710
|
+
const variant = key.includes(".") ? key.split(".")[1] : void 0;
|
|
1711
|
+
return {
|
|
1712
|
+
reason,
|
|
1713
|
+
...variant ? { variant } : {},
|
|
1714
|
+
i18nKey: `guidedErrors.${key}`,
|
|
1715
|
+
title: entry?.title ?? "",
|
|
1716
|
+
cause: entry?.cause ?? "",
|
|
1717
|
+
next: entry?.next ?? "",
|
|
1718
|
+
actions: entry?.actions ?? [],
|
|
1719
|
+
params: resolved.params,
|
|
1720
|
+
...extra
|
|
1721
|
+
};
|
|
1722
|
+
}
|
|
1723
|
+
/**
|
|
1724
|
+
* The guidance for any error a Stewards surface holds: what happened, why,
|
|
1725
|
+
* what to do next, and the actions that fix it.
|
|
1726
|
+
*
|
|
1727
|
+
* Works against older services: the client branches on `extensions.reason`
|
|
1728
|
+
* first, then on `extensions.i18nKey`, then on `extensions.code`, and fills in
|
|
1729
|
+
* what the service does not send yet (the agent's status, its model) from
|
|
1730
|
+
* `context`, the data the surface already has.
|
|
1731
|
+
*/
|
|
1732
|
+
function describeGuidedError(error, context = {}) {
|
|
1733
|
+
const source = extractGuidedSource(error);
|
|
1734
|
+
if (!source) return void 0;
|
|
1735
|
+
const resolved = refine(classify(source), source, context);
|
|
1736
|
+
const ext = source.extensions ?? {};
|
|
1737
|
+
const traceId = str(ext.traceId) ?? str(ext.requestId);
|
|
1738
|
+
const retryAfter = num(ext.retryAfter);
|
|
1739
|
+
const field = str(ext.field);
|
|
1740
|
+
const code = source.code ?? str(ext.code);
|
|
1741
|
+
return buildGuidedError(resolved, {
|
|
1742
|
+
...code ? { code } : {},
|
|
1743
|
+
...source.message ? { serverMessage: source.message } : {},
|
|
1744
|
+
...traceId ? { traceId } : {},
|
|
1745
|
+
...retryAfter !== void 0 ? { retryAfterSeconds: retryAfter } : {},
|
|
1746
|
+
...field ? { field } : {}
|
|
1747
|
+
});
|
|
1748
|
+
}
|
|
1749
|
+
/** Number-and-label parameters for a budget stop (C5). */
|
|
1750
|
+
function budgetParams(budgetKey, budgetLevel, budgetCap) {
|
|
1751
|
+
const params = {};
|
|
1752
|
+
if (budgetKey) params.budgetKeyLabel = BUDGET_KEY_LABELS[budgetKey] ?? budgetKey.toLowerCase();
|
|
1753
|
+
if (budgetLevel) params.budgetLevelLabel = BUDGET_LEVEL_LABELS[budgetLevel] ?? budgetLevel.toLowerCase();
|
|
1754
|
+
if (budgetCap != null) params.budgetCap = budgetCap;
|
|
1755
|
+
return params;
|
|
1756
|
+
}
|
|
1757
|
+
/** Reasons whose only fix is to load the current state again (someone else acted first). */
|
|
1758
|
+
const REFRESH_REASONS = /* @__PURE__ */ new Set([
|
|
1759
|
+
"APPROVAL_ALREADY_DECIDED",
|
|
1760
|
+
"RUN_ALREADY_ENDED",
|
|
1761
|
+
"ACTIVATION_REQUEST_CLOSED",
|
|
1762
|
+
"DUTY_NOT_A_PROPOSAL",
|
|
1763
|
+
"MEMORY_NOT_FOUND",
|
|
1764
|
+
"STEWARD_STATUS_CHANGED"
|
|
1765
|
+
]);
|
|
1766
|
+
/**
|
|
1767
|
+
* Whether a failed write lost a race (the approval was already decided, the
|
|
1768
|
+
* run already ended): its "Refresh" reloads the data and never repeats the write.
|
|
1769
|
+
*/
|
|
1770
|
+
function isStaleStateError(error) {
|
|
1771
|
+
const guided = describeGuidedError(error);
|
|
1772
|
+
return !!guided && REFRESH_REASONS.has(guided.reason);
|
|
1773
|
+
}
|
|
1774
|
+
/** GraphQL codes a service returns only when it refused the request outright. */
|
|
1775
|
+
const REFUSAL_CODES = /* @__PURE__ */ new Set([
|
|
1776
|
+
"BAD_USER_INPUT",
|
|
1777
|
+
"FORBIDDEN",
|
|
1778
|
+
"UNAUTHORIZED",
|
|
1779
|
+
"QUOTA_EXHAUSTED",
|
|
1780
|
+
"QUOTA_NOT_PROVISIONED",
|
|
1781
|
+
"CONFLICT",
|
|
1782
|
+
"NOT_FOUND",
|
|
1783
|
+
"FAILED_PRECONDITION"
|
|
1784
|
+
]);
|
|
1785
|
+
/**
|
|
1786
|
+
* Whether a failed write was refused before it did anything, so submitting it
|
|
1787
|
+
* again (after its fix) cannot do the work twice. A lost answer (network,
|
|
1788
|
+
* gateway, unknown error) is not: the write may have happened.
|
|
1789
|
+
*/
|
|
1790
|
+
function isDefiniteRefusal(error) {
|
|
1791
|
+
const source = extractGuidedSource(error);
|
|
1792
|
+
const code = source?.code ?? (typeof source?.extensions?.code === "string" ? source.extensions.code : void 0);
|
|
1793
|
+
return !!code && REFUSAL_CODES.has(code);
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
// src/guided/targets.ts
|
|
1797
|
+
function enc(value) {
|
|
1798
|
+
return value ? encodeURIComponent(value) : void 0;
|
|
1799
|
+
}
|
|
1800
|
+
function withAnchor(path, anchor) {
|
|
1801
|
+
return anchor ? `${path}#${encodeURIComponent(anchor)}` : path;
|
|
1802
|
+
}
|
|
1803
|
+
/** BotManor's own address for a target, or `undefined` when an id it needs is missing. */
|
|
1804
|
+
function botmanorPath(target, params = {}) {
|
|
1805
|
+
const steward = enc(params.stewardId);
|
|
1806
|
+
const agent = enc(params.agentId);
|
|
1807
|
+
const run = enc(params.runId);
|
|
1808
|
+
switch (target) {
|
|
1809
|
+
case "STEWARD_LIST": return "/botmanor/stewards";
|
|
1810
|
+
case "STEWARD_NEW": return "/botmanor/stewards/new";
|
|
1811
|
+
case "STEWARD": return steward ? `/botmanor/stewards/${steward}` : void 0;
|
|
1812
|
+
case "STEWARD_CHARTER": return steward ? withAnchor(`/botmanor/stewards/${steward}/charter`, params.anchor) : void 0;
|
|
1813
|
+
case "STEWARD_DUTIES": return steward ? `/botmanor/stewards/${steward}/duties` : void 0;
|
|
1814
|
+
case "STEWARD_MEMORY": return steward ? `/botmanor/stewards/${steward}/memory` : void 0;
|
|
1815
|
+
case "STEWARD_PLAYBOOKS": return steward ? `/botmanor/stewards/${steward}/playbooks` : void 0;
|
|
1816
|
+
case "STEWARD_DAYBOOK": return steward ? `/botmanor/stewards/${steward}/daybook` : void 0;
|
|
1817
|
+
case "STEWARD_RUN": return run ? `/botmanor/stewards/runs/${run}` : void 0;
|
|
1818
|
+
case "TOOL_APPROVALS": return "/botmanor/approvals";
|
|
1819
|
+
case "AGENT": return agent ? `/botmanor/agents/${agent}` : void 0;
|
|
1820
|
+
case "AGENT_EDIT": return agent ? `/botmanor/agents/${agent}/edit` : void 0;
|
|
1821
|
+
case "AGENT_APPROVALS": return "/botmanor/agents/approvals";
|
|
1822
|
+
case "MODEL_SETTINGS": return "/botmanor/settings";
|
|
1823
|
+
case "POLICIES": return "/botmanor/policies";
|
|
1824
|
+
case "A2A": return "/botmanor/a2a";
|
|
1825
|
+
case "CONNECTIONS": return "/botmanor/mcp";
|
|
1826
|
+
case "INTEGRATIONS": return "/integrations";
|
|
1827
|
+
case "BILLING_PLANS": return "/billing/plans";
|
|
1828
|
+
case "RBAC": return "/rbac";
|
|
1829
|
+
case "SANDBOX": return "/sandbox";
|
|
1830
|
+
case "SANDBOX_ADMIN": return "/sandbox/admin";
|
|
1831
|
+
case "STEWARD_WORKSPACE_CONTROLS":
|
|
1832
|
+
case "VIBECONTROLS": return;
|
|
1833
|
+
default: return;
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
/** Targets whose page only BotManor has: every other shell links there. */
|
|
1837
|
+
const BOTMANOR_ONLY = /* @__PURE__ */ new Set([
|
|
1838
|
+
"STEWARD_DUTIES",
|
|
1839
|
+
"STEWARD_MEMORY",
|
|
1840
|
+
"STEWARD_PLAYBOOKS",
|
|
1841
|
+
"STEWARD_DAYBOOK",
|
|
1842
|
+
"AGENT",
|
|
1843
|
+
"AGENT_EDIT",
|
|
1844
|
+
"AGENT_APPROVALS",
|
|
1845
|
+
"MODEL_SETTINGS",
|
|
1846
|
+
"POLICIES",
|
|
1847
|
+
"A2A",
|
|
1848
|
+
"CONNECTIONS"
|
|
1849
|
+
]);
|
|
1850
|
+
/**
|
|
1851
|
+
* Where a target lives for the shell the surface runs in, or `undefined` when
|
|
1852
|
+
* it has no page (the action then becomes "ask an admin", or is dropped).
|
|
1853
|
+
*/
|
|
1854
|
+
function resolveGuidedLocation(target, params, shell) {
|
|
1855
|
+
if (target === "VIBECONTROLS") return {
|
|
1856
|
+
kind: "cross-shell",
|
|
1857
|
+
product: "vibecontrols",
|
|
1858
|
+
path: "/"
|
|
1859
|
+
};
|
|
1860
|
+
const inBotmanor = botmanorPath(target, params);
|
|
1861
|
+
if (shell.kind === "botmanor") return inBotmanor ? {
|
|
1862
|
+
kind: "route",
|
|
1863
|
+
path: inBotmanor
|
|
1864
|
+
} : void 0;
|
|
1865
|
+
const botmanorCharter = target === "STEWARD_CHARTER" && !!params.anchor;
|
|
1866
|
+
if (BOTMANOR_ONLY.has(target) || botmanorCharter) return inBotmanor ? {
|
|
1867
|
+
kind: "cross-shell",
|
|
1868
|
+
product: "botmanor",
|
|
1869
|
+
path: inBotmanor
|
|
1870
|
+
} : void 0;
|
|
1871
|
+
const base = (shell.stewardsBasePath ?? "/stewards").replace(/\/$/, "");
|
|
1872
|
+
const steward = enc(params.stewardId);
|
|
1873
|
+
const run = enc(params.runId);
|
|
1874
|
+
switch (target) {
|
|
1875
|
+
case "STEWARD_LIST": return {
|
|
1876
|
+
kind: "route",
|
|
1877
|
+
path: base
|
|
1878
|
+
};
|
|
1879
|
+
case "STEWARD_NEW": return {
|
|
1880
|
+
kind: "route",
|
|
1881
|
+
path: shell.stewardBuilderPath ?? `${base}/new`
|
|
1882
|
+
};
|
|
1883
|
+
case "STEWARD": return steward ? {
|
|
1884
|
+
kind: "route",
|
|
1885
|
+
path: `${base}/${steward}`
|
|
1886
|
+
} : void 0;
|
|
1887
|
+
case "STEWARD_CHARTER": return steward ? {
|
|
1888
|
+
kind: "route",
|
|
1889
|
+
path: withAnchor(`${base}/${steward}/charter`, params.anchor)
|
|
1890
|
+
} : void 0;
|
|
1891
|
+
case "STEWARD_RUN": return run ? {
|
|
1892
|
+
kind: "route",
|
|
1893
|
+
path: `${base}/runs/${run}`
|
|
1894
|
+
} : void 0;
|
|
1895
|
+
case "TOOL_APPROVALS": return {
|
|
1896
|
+
kind: "route",
|
|
1897
|
+
path: `${base}/approvals`
|
|
1898
|
+
};
|
|
1899
|
+
case "INTEGRATIONS": return shell.hasIntegrations === false ? {
|
|
1900
|
+
kind: "cross-shell",
|
|
1901
|
+
product: "workspaces",
|
|
1902
|
+
path: "/integrations"
|
|
1903
|
+
} : {
|
|
1904
|
+
kind: "route",
|
|
1905
|
+
path: "/integrations"
|
|
1906
|
+
};
|
|
1907
|
+
case "SANDBOX":
|
|
1908
|
+
case "SANDBOX_ADMIN": {
|
|
1909
|
+
const path = target === "SANDBOX" ? "/sandbox" : "/sandbox/admin";
|
|
1910
|
+
return shell.hasSandbox ? {
|
|
1911
|
+
kind: "route",
|
|
1912
|
+
path
|
|
1913
|
+
} : {
|
|
1914
|
+
kind: "cross-shell",
|
|
1915
|
+
product: "workspaces",
|
|
1916
|
+
path
|
|
1917
|
+
};
|
|
1918
|
+
}
|
|
1919
|
+
case "BILLING_PLANS": return {
|
|
1920
|
+
kind: "route",
|
|
1921
|
+
path: "/billing/plans"
|
|
1922
|
+
};
|
|
1923
|
+
case "RBAC": return {
|
|
1924
|
+
kind: "route",
|
|
1925
|
+
path: "/rbac"
|
|
1926
|
+
};
|
|
1927
|
+
case "STEWARD_WORKSPACE_CONTROLS": return;
|
|
1928
|
+
default: return;
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
/** BotManor's production app shell, the cross-shell fallback when a host gives no resolver. */
|
|
1932
|
+
const DEFAULT_BOTMANOR_APP_URL = "https://app.botmanor.com";
|
|
1933
|
+
/** An absolute URL for a cross-shell location, given the product's app URL. */
|
|
1934
|
+
function crossShellUrl(appUrl, path) {
|
|
1935
|
+
return `${appUrl.replace(/\/+$/, "")}${path.startsWith("/") ? path : `/${path}`}`;
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
// src/guided/plan.ts
|
|
1939
|
+
const PLACEHOLDER = /\{\{\s*([\w.-]+)\s*\}\}/g;
|
|
1940
|
+
/** Fills `{{name}}` placeholders; an unknown name is left as written. */
|
|
1941
|
+
function fillGuidedParams(text, params) {
|
|
1942
|
+
if (!params) return text;
|
|
1943
|
+
return text.replace(PLACEHOLDER, (match, name) => Object.prototype.hasOwnProperty.call(params, name) ? String(params[name]) : match);
|
|
1944
|
+
}
|
|
1945
|
+
/** English only: the catalog's own copy with its parameters filled. */
|
|
1946
|
+
const englishGuidedTranslate = (_key, fallback, params) => fillGuidedParams(fallback, params);
|
|
1947
|
+
/** Wraps a host translator so an unknown key reads as the English fallback. */
|
|
1948
|
+
function guidedTranslateFrom(t) {
|
|
1949
|
+
return (key, fallback, params) => {
|
|
1950
|
+
const translated = t ? t(key) : key;
|
|
1951
|
+
return fillGuidedParams(!translated || translated === key ? fallback : translated, params);
|
|
1952
|
+
};
|
|
1953
|
+
}
|
|
1954
|
+
/** Parameters every sentence can use, when the error does not name them. */
|
|
1955
|
+
const DEFAULT_PARAMS = {
|
|
1956
|
+
ownerName: "the steward's owner",
|
|
1957
|
+
machineOwner: "the computer's owner",
|
|
1958
|
+
toolLabel: "the tool",
|
|
1959
|
+
destination: "its destination",
|
|
1960
|
+
host: "a site",
|
|
1961
|
+
limit: "its",
|
|
1962
|
+
budgetCap: "its",
|
|
1963
|
+
budgetKeyLabel: "budget",
|
|
1964
|
+
budgetLevelLabel: "",
|
|
1965
|
+
maxSteps: "the most",
|
|
1966
|
+
statusLabel: "not active",
|
|
1967
|
+
areaLabel: "settings",
|
|
1968
|
+
controlLabel: "this setting",
|
|
1969
|
+
allowedLabels: "the options the form still offers",
|
|
1970
|
+
modelRoleLabel: "main",
|
|
1971
|
+
permissionLabel: "do this",
|
|
1972
|
+
specificReason: "",
|
|
1973
|
+
serverMessage: "The request couldn't be completed."
|
|
1974
|
+
};
|
|
1975
|
+
/** The guidance's parameters with defaults and any the host resolved (display names). */
|
|
1976
|
+
function guidedParams(guided, extra = {}) {
|
|
1977
|
+
const params = {
|
|
1978
|
+
...DEFAULT_PARAMS,
|
|
1979
|
+
...guided.params
|
|
1980
|
+
};
|
|
1981
|
+
for (const [name, value] of Object.entries(extra)) if (value !== void 0 && value !== "") params[name] = value;
|
|
1982
|
+
return params;
|
|
1983
|
+
}
|
|
1984
|
+
/** Title, cause and next step, translated (`<i18nKey>.title|cause|next`). */
|
|
1985
|
+
function guidedText(guided, t = englishGuidedTranslate, extra = {}) {
|
|
1986
|
+
const params = guidedParams(guided, extra);
|
|
1987
|
+
const tidy = (text) => text.replace(/\s+([.,])/g, "$1").replace(/\s{2,}/g, " ").trim();
|
|
1988
|
+
return {
|
|
1989
|
+
title: tidy(t(`${guided.i18nKey}.title`, guided.title, params)),
|
|
1990
|
+
cause: tidy(t(`${guided.i18nKey}.cause`, guided.cause, params)),
|
|
1991
|
+
next: tidy(t(`${guided.i18nKey}.next`, guided.next, params))
|
|
1992
|
+
};
|
|
1993
|
+
}
|
|
1994
|
+
function allowed(action, guided, env) {
|
|
1995
|
+
const ownerId = action.ownerParam ? guided.params[action.ownerParam] : void 0;
|
|
1996
|
+
const isOwner = ownerId !== void 0 && !!env.viewerActorId && String(ownerId) === env.viewerActorId;
|
|
1997
|
+
if (!action.permission) {
|
|
1998
|
+
if (!action.ownerParam) return true;
|
|
1999
|
+
if (ownerId === void 0 || !env.viewerActorId) return void 0;
|
|
2000
|
+
return isOwner;
|
|
2001
|
+
}
|
|
2002
|
+
const has = env.hasPermission?.(action.permission);
|
|
2003
|
+
if (has === false) return false;
|
|
2004
|
+
if (action.ownerParam && ownerId !== void 0 && env.viewerActorId && !isOwner) return has === true && action.ownerParam === "ownerActorId" ? true : false;
|
|
2005
|
+
return has;
|
|
2006
|
+
}
|
|
2007
|
+
/**
|
|
2008
|
+
* The actions to show for an error on this surface: permission-gated
|
|
2009
|
+
* (catalog section 1.5), limited to what the surface can run or reach, at
|
|
2010
|
+
* most two, with "who can fix it" text for the rest.
|
|
2011
|
+
*/
|
|
2012
|
+
function planGuidedActions(guided, env) {
|
|
2013
|
+
const t = env.t ?? englishGuidedTranslate;
|
|
2014
|
+
const params = guidedParams(guided, env.extraParams);
|
|
2015
|
+
const planned = [];
|
|
2016
|
+
const askAdmin = [];
|
|
2017
|
+
const label = (action) => t(`guidedErrors.actions.${action.id}`, action.label, params);
|
|
2018
|
+
const addAsk = (action) => {
|
|
2019
|
+
if (!action.askAdmin) return;
|
|
2020
|
+
const text = t(`guidedErrors.actions.${action.askAdmin.id}`, action.askAdmin.text, params);
|
|
2021
|
+
if (!askAdmin.includes(text)) askAdmin.push(text);
|
|
2022
|
+
};
|
|
2023
|
+
const locate = (action) => {
|
|
2024
|
+
if (!action.target) return void 0;
|
|
2025
|
+
const targetParams = {
|
|
2026
|
+
...params.stewardId !== void 0 ? { stewardId: String(params.stewardId) } : {},
|
|
2027
|
+
...params.agentId !== void 0 ? { agentId: String(params.agentId) } : {},
|
|
2028
|
+
...params.runId !== void 0 ? { runId: String(params.runId) } : {},
|
|
2029
|
+
...action.anchor ? { anchor: action.anchor } : {}
|
|
2030
|
+
};
|
|
2031
|
+
return env.locate ? env.locate(action.target, targetParams) : resolveGuidedLocation(action.target, targetParams, env.shell);
|
|
2032
|
+
};
|
|
2033
|
+
for (const action of guided.actions) {
|
|
2034
|
+
if (action.kind === "ask-admin") {
|
|
2035
|
+
addAsk(action);
|
|
2036
|
+
continue;
|
|
2037
|
+
}
|
|
2038
|
+
if (action.kind === "none") continue;
|
|
2039
|
+
if (action.kind === "retry") {
|
|
2040
|
+
if (env.canRetry) planned.push({
|
|
2041
|
+
action,
|
|
2042
|
+
label: label(action)
|
|
2043
|
+
});
|
|
2044
|
+
continue;
|
|
2045
|
+
}
|
|
2046
|
+
if (action.kind === "upgrade") {
|
|
2047
|
+
if (env.canUpgrade !== false) {
|
|
2048
|
+
const location = locate(action);
|
|
2049
|
+
planned.push({
|
|
2050
|
+
action,
|
|
2051
|
+
label: label(action),
|
|
2052
|
+
...location ? { location } : {}
|
|
2053
|
+
});
|
|
2054
|
+
}
|
|
2055
|
+
continue;
|
|
2056
|
+
}
|
|
2057
|
+
if (allowed(action, guided, env) === false) {
|
|
2058
|
+
addAsk(action);
|
|
2059
|
+
continue;
|
|
2060
|
+
}
|
|
2061
|
+
if (action.kind === "mutation") {
|
|
2062
|
+
if ((action.mutation === "PUBLISH_AGENT" || action.mutation === "REQUEST_AGENT_ACTIVATION" ? params.agentId : action.mutation === "ACTIVATE_STEWARD" || action.mutation === "RUN_STEWARD" ? params.stewardId : true) === void 0) continue;
|
|
2063
|
+
if (action.mutation && env.mutations?.has(action.mutation)) planned.push({
|
|
2064
|
+
action,
|
|
2065
|
+
label: label(action)
|
|
2066
|
+
});
|
|
2067
|
+
else if (action.mutation === "PUBLISH_AGENT" || action.mutation === "REQUEST_AGENT_ACTIVATION") {
|
|
2068
|
+
const fallback = {
|
|
2069
|
+
id: "openAgentToPublish",
|
|
2070
|
+
kind: "navigate",
|
|
2071
|
+
label: "Open agent to publish it",
|
|
2072
|
+
target: action.mutation === "PUBLISH_AGENT" ? "AGENT" : "AGENT_APPROVALS"
|
|
2073
|
+
};
|
|
2074
|
+
const location = locate(fallback);
|
|
2075
|
+
if (location) planned.push({
|
|
2076
|
+
action: fallback,
|
|
2077
|
+
label: label(fallback),
|
|
2078
|
+
location
|
|
2079
|
+
});
|
|
2080
|
+
}
|
|
2081
|
+
continue;
|
|
2082
|
+
}
|
|
2083
|
+
const location = locate(action);
|
|
2084
|
+
if (location) planned.push({
|
|
2085
|
+
action,
|
|
2086
|
+
label: label(action),
|
|
2087
|
+
location
|
|
2088
|
+
});
|
|
2089
|
+
else addAsk(action);
|
|
2090
|
+
}
|
|
2091
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2092
|
+
return {
|
|
2093
|
+
actions: planned.filter((p) => {
|
|
2094
|
+
const key = p.location ? locationKey(p.location) : `${p.action.kind}:${p.action.mutation ?? p.action.id}`;
|
|
2095
|
+
if (seen.has(key)) return false;
|
|
2096
|
+
seen.add(key);
|
|
2097
|
+
return true;
|
|
2098
|
+
}).slice(0, 2),
|
|
2099
|
+
askAdmin
|
|
2100
|
+
};
|
|
2101
|
+
}
|
|
2102
|
+
function locationKey(location) {
|
|
2103
|
+
return location.kind === "href" ? `href:${location.href}` : `${location.kind}:${location.path}`;
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2106
|
+
// src/guided/runFailure.ts
|
|
2107
|
+
/** Run statuses that end a run without it finishing its work. */
|
|
2108
|
+
const UNFINISHED = /* @__PURE__ */ new Set([
|
|
2109
|
+
"FAILED",
|
|
2110
|
+
"STOPPED",
|
|
2111
|
+
"PAUSED_BUDGET"
|
|
2112
|
+
]);
|
|
2113
|
+
/** Step codes (E1 `TOOL_FAILED`) → variant. */
|
|
2114
|
+
const TOOL_STEP_VARIANTS = {
|
|
2115
|
+
TOOL_AUTH_FAILED: "connectionSignIn",
|
|
2116
|
+
TOOL_PERMISSION_DENIED: "connectionNoAccess",
|
|
2117
|
+
TOOL_NOT_AVAILABLE: "toolNotAllowed",
|
|
2118
|
+
TOOL_NOT_FOUND: "targetMissing",
|
|
2119
|
+
TOOL_INVALID_ARGUMENTS: "badRequest",
|
|
2120
|
+
TOOL_REJECTED: "badRequest",
|
|
2121
|
+
TOOL_RATE_LIMITED: "temporary",
|
|
2122
|
+
TOOL_TIMEOUT: "temporary",
|
|
2123
|
+
TOOL_UNREACHABLE: "temporary",
|
|
2124
|
+
DESK_BUSY: "temporary"
|
|
2125
|
+
};
|
|
2126
|
+
/** Step codes (D2 `MODEL_CALL_FAILED`) → variant. */
|
|
2127
|
+
const MODEL_STEP_VARIANTS = {
|
|
2128
|
+
MODEL_AUTH_FAILED: "authFailed",
|
|
2129
|
+
MODEL_RATE_LIMITED: "rateLimited",
|
|
2130
|
+
MODEL_TIMEOUT: "temporary",
|
|
2131
|
+
MODEL_UNAVAILABLE: "temporary",
|
|
2132
|
+
MODEL_FAILED: "temporary",
|
|
2133
|
+
MODEL_BAD_REQUEST: "badRequest"
|
|
2134
|
+
};
|
|
2135
|
+
/** Step codes (D1 `MODEL_NOT_SET_UP`) → variant. */
|
|
2136
|
+
const MODEL_SETUP_VARIANTS = {
|
|
2137
|
+
MODEL_NO_CREDENTIALS: "noCredentials",
|
|
2138
|
+
MODEL_NOT_USABLE: "notUsable",
|
|
2139
|
+
LLM_PROVIDER_UNCONFIGURED: "noCredentials",
|
|
2140
|
+
MODEL_NOT_ALLOWED: "notAllowed",
|
|
2141
|
+
MODEL_BLOCKED_BY_POLICY: "blockedByPolicy"
|
|
2142
|
+
};
|
|
2143
|
+
/** Desk step codes (F1, F4, F5, F7, F8) → reason and variant. */
|
|
2144
|
+
const DESK_STEP_HINTS = {
|
|
2145
|
+
DESK_UNAVAILABLE: ["CLOUD_DESK_BUSY_OR_UNAVAILABLE", "startFailed"],
|
|
2146
|
+
STALE_FENCING_TOKEN: ["CLOUD_DESK_BUSY_OR_UNAVAILABLE", "startFailed"],
|
|
2147
|
+
LEASE_PREEMPTED: ["CLOUD_DESK_BUSY_OR_UNAVAILABLE", "startFailed"],
|
|
2148
|
+
UNEXPECTED_WINDOW: ["CLOUD_DESK_BUSY_OR_UNAVAILABLE", "startFailed"],
|
|
2149
|
+
SANDBOX_DESKTOP_POOL_FULL: ["CLOUD_DESK_BUSY_OR_UNAVAILABLE", "poolFull"],
|
|
2150
|
+
STEWARD_GRANT_REQUIRED: ["OWN_MACHINE_NOT_GRANTED", "noGrant"],
|
|
2151
|
+
STEWARD_GRANT_SCOPE: ["OWN_MACHINE_NOT_GRANTED", "scope"],
|
|
2152
|
+
STEWARD_APP_NOT_ALLOWED: ["OWN_MACHINE_NOT_GRANTED", "app"],
|
|
2153
|
+
DESK_OFFLINE: ["OWN_MACHINE_OFFLINE", "offline"],
|
|
2154
|
+
DESK_EXPIRED: ["OWN_MACHINE_OFFLINE", "offline"],
|
|
2155
|
+
KILL_SWITCH: ["OWN_MACHINE_OFFLINE", "paused"],
|
|
2156
|
+
LOCAL_CONSENT_OFF: ["OWN_MACHINE_OFFLINE", "paused"],
|
|
2157
|
+
CONSENT_REQUIRED: ["OWN_MACHINE_OFFLINE", "paused"],
|
|
2158
|
+
TOO_MANY_REQUESTS: ["OWN_MACHINE_OFFLINE", "slow"],
|
|
2159
|
+
URL_BLOCKED: ["DESK_ACTION_BLOCKED", "site"],
|
|
2160
|
+
ORIGIN_MISMATCH: ["DESK_ACTION_BLOCKED", "site"],
|
|
2161
|
+
OUTSIDE_WORKSPACE_FOLDER: ["DESK_ACTION_BLOCKED", "folder"],
|
|
2162
|
+
SHELL_NOT_ALLOWED: ["DESK_ACTION_BLOCKED", "shell"],
|
|
2163
|
+
UNSUPPORTED_ON_DESK: ["DESK_ACTION_BLOCKED", "unsupported"],
|
|
2164
|
+
TARGET_NOT_FOUND: ["DESK_ACTION_BLOCKED", "target"],
|
|
2165
|
+
DESK_SIGN_IN_LOST: ["DESK_SIGN_IN_LOST", void 0]
|
|
2166
|
+
};
|
|
2167
|
+
function classifyStep(stepCode) {
|
|
2168
|
+
const tool = TOOL_STEP_VARIANTS[stepCode];
|
|
2169
|
+
if (tool) return {
|
|
2170
|
+
reason: "TOOL_FAILED",
|
|
2171
|
+
variant: tool
|
|
2172
|
+
};
|
|
2173
|
+
if (stepCode === "TOOL_UNCONFIRMED") return { reason: "ACTION_RESULT_UNKNOWN" };
|
|
2174
|
+
const model = MODEL_STEP_VARIANTS[stepCode];
|
|
2175
|
+
if (model) return {
|
|
2176
|
+
reason: "MODEL_CALL_FAILED",
|
|
2177
|
+
variant: model
|
|
2178
|
+
};
|
|
2179
|
+
const setup = MODEL_SETUP_VARIANTS[stepCode];
|
|
2180
|
+
if (setup) return {
|
|
2181
|
+
reason: "MODEL_NOT_SET_UP",
|
|
2182
|
+
variant: setup
|
|
2183
|
+
};
|
|
2184
|
+
const desk = DESK_STEP_HINTS[stepCode];
|
|
2185
|
+
if (desk) return desk[1] ? {
|
|
2186
|
+
reason: desk[0],
|
|
2187
|
+
variant: desk[1]
|
|
2188
|
+
} : { reason: desk[0] };
|
|
2189
|
+
}
|
|
2190
|
+
function classifyFailure(failure, run) {
|
|
2191
|
+
const step = failure.stepCode ?? failedStepCodes(run).find((c) => classifyStep(c));
|
|
2192
|
+
switch (failure.code) {
|
|
2193
|
+
case "STEWARD_NOT_ACTIVE": return {
|
|
2194
|
+
reason: "STEWARD_NOT_ACTIVE",
|
|
2195
|
+
variant: "stoppedBeforeStart"
|
|
2196
|
+
};
|
|
2197
|
+
case "AGENT_NOT_ACTIVE": return { reason: "AGENT_NOT_ACTIVE" };
|
|
2198
|
+
case "AGENT_UNAVAILABLE": return { reason: "AGENT_UNAVAILABLE" };
|
|
2199
|
+
case "AI_CREDITS_EXHAUSTED": return step === "QUOTA_NOT_PROVISIONED" || step === "AI_CREDITS_NOT_IN_PLAN" ? {
|
|
2200
|
+
reason: "AI_CREDITS_USED_UP",
|
|
2201
|
+
variant: "notInPlan"
|
|
2202
|
+
} : { reason: "AI_CREDITS_USED_UP" };
|
|
2203
|
+
case "STEWARD_BUDGET": {
|
|
2204
|
+
const level = failure.budgetLevel?.toLowerCase();
|
|
2205
|
+
return level === "run" || level === "day" || level === "total" ? {
|
|
2206
|
+
reason: "STEWARD_BUDGET_USED_UP",
|
|
2207
|
+
variant: level
|
|
2208
|
+
} : { reason: "STEWARD_BUDGET_USED_UP" };
|
|
2209
|
+
}
|
|
2210
|
+
case "STEWARD_STEP_CAP": return failure.budgetCap != null ? { reason: "STEP_LIMIT_REACHED" } : {
|
|
2211
|
+
reason: "STEP_LIMIT_REACHED",
|
|
2212
|
+
variant: "unknownCap"
|
|
2213
|
+
};
|
|
2214
|
+
case "MODEL_UNAVAILABLE": return {
|
|
2215
|
+
reason: "MODEL_NOT_SET_UP",
|
|
2216
|
+
...step && MODEL_SETUP_VARIANTS[step] ? { variant: MODEL_SETUP_VARIANTS[step] } : {}
|
|
2217
|
+
};
|
|
2218
|
+
case "MODEL_FAILED": return {
|
|
2219
|
+
reason: "MODEL_CALL_FAILED",
|
|
2220
|
+
variant: (step && MODEL_STEP_VARIANTS[step]) ?? "temporary"
|
|
2221
|
+
};
|
|
2222
|
+
case "TOOL_FAILED": return (step ? classifyStep(step) : void 0) ?? {
|
|
2223
|
+
reason: "TOOL_FAILED",
|
|
2224
|
+
variant: "temporary"
|
|
2225
|
+
};
|
|
2226
|
+
case "EFFECT_UNKNOWN": return { reason: "ACTION_RESULT_UNKNOWN" };
|
|
2227
|
+
case "APPROVAL_DENIED": return {
|
|
2228
|
+
reason: "ACTION_NOT_APPROVED",
|
|
2229
|
+
variant: "denied"
|
|
2230
|
+
};
|
|
2231
|
+
case "APPROVAL_EXPIRED": return {
|
|
2232
|
+
reason: "ACTION_NOT_APPROVED",
|
|
2233
|
+
variant: "expired"
|
|
2234
|
+
};
|
|
2235
|
+
case "APPROVAL_CANCELLED": return {
|
|
2236
|
+
reason: "ACTION_NOT_APPROVED",
|
|
2237
|
+
variant: "cancelled"
|
|
2238
|
+
};
|
|
2239
|
+
case "UNATTENDED_NEEDS_PERSON": return { reason: "NEEDS_A_PERSON" };
|
|
2240
|
+
case "DELEGATION_REVOKED": return { reason: "DELEGATION_REVOKED" };
|
|
2241
|
+
case "RECORDING_INVALID":
|
|
2242
|
+
case "PLAYBOOK_UNAVAILABLE": return { reason: "PLAYBOOK_NEEDS_RECORDING" };
|
|
2243
|
+
default: return classifyStep(failure.code) ?? (step ? classifyStep(step) : void 0) ?? { reason: "RUN_FAILED" };
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
/**
|
|
2247
|
+
* A step reason as a code: `MODEL_AUTH_FAILED` as it is, and the
|
|
2248
|
+
* `<kind>:error:<code>` form older services store (`model:error:model_auth_failed`)
|
|
2249
|
+
* by its last part.
|
|
2250
|
+
*/
|
|
2251
|
+
function stepReasonCode(reason) {
|
|
2252
|
+
const code = (reason.split(":").pop()?.trim() ?? "").toUpperCase();
|
|
2253
|
+
return /^[A-Z][A-Z0-9_]{2,63}$/.test(code) ? code : void 0;
|
|
2254
|
+
}
|
|
2255
|
+
/** Step codes a failed step reported (its `verdictReasons`), latest step first. */
|
|
2256
|
+
function failedStepCodes(run) {
|
|
2257
|
+
const steps = run.steps ?? [];
|
|
2258
|
+
const codes = [];
|
|
2259
|
+
for (let i = steps.length - 1; i >= 0; i -= 1) {
|
|
2260
|
+
const step = steps[i];
|
|
2261
|
+
if (step?.verdict !== "FAILED") continue;
|
|
2262
|
+
for (const reason of step.verdictReasons ?? []) {
|
|
2263
|
+
const code = stepReasonCode(reason);
|
|
2264
|
+
if (code) codes.push(code);
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
return codes;
|
|
2268
|
+
}
|
|
2269
|
+
/** A failure that older services do not expose, read from the stop reason and the steps. */
|
|
2270
|
+
function classifyLegacy(run) {
|
|
2271
|
+
const stop = run.stopReason ?? void 0;
|
|
2272
|
+
if ((run.steps ?? []).some((step) => (step.verdictReasons ?? []).some((r) => r.startsWith("effect:unknown")))) return { reason: "ACTION_RESULT_UNKNOWN" };
|
|
2273
|
+
switch (stop) {
|
|
2274
|
+
case "BUDGET": return { reason: "STEWARD_BUDGET_USED_UP" };
|
|
2275
|
+
case "STEP_CAP": return {
|
|
2276
|
+
reason: "STEP_LIMIT_REACHED",
|
|
2277
|
+
variant: "unknownCap"
|
|
2278
|
+
};
|
|
2279
|
+
case "APPROVAL_DENIED": return {
|
|
2280
|
+
reason: "ACTION_NOT_APPROVED",
|
|
2281
|
+
variant: "denied"
|
|
2282
|
+
};
|
|
2283
|
+
case "APPROVAL_EXPIRED": return {
|
|
2284
|
+
reason: "ACTION_NOT_APPROVED",
|
|
2285
|
+
variant: "expired"
|
|
2286
|
+
};
|
|
2287
|
+
case "APPROVAL_CANCELLED": return {
|
|
2288
|
+
reason: "ACTION_NOT_APPROVED",
|
|
2289
|
+
variant: "cancelled"
|
|
2290
|
+
};
|
|
2291
|
+
case "UNATTENDED_NEEDS_PERSON": return { reason: "NEEDS_A_PERSON" };
|
|
2292
|
+
case "STEWARD_NOT_ACTIVE": return {
|
|
2293
|
+
reason: "STEWARD_NOT_ACTIVE",
|
|
2294
|
+
variant: "stoppedBeforeStart"
|
|
2295
|
+
};
|
|
2296
|
+
case "AGENT_UNAVAILABLE": return { reason: "AGENT_UNAVAILABLE" };
|
|
2297
|
+
case "DELEGATION_REVOKED": return { reason: "DELEGATION_REVOKED" };
|
|
2298
|
+
case "EFFECT_UNKNOWN": return { reason: "ACTION_RESULT_UNKNOWN" };
|
|
2299
|
+
case "CANCELLED_BY_OWNER":
|
|
2300
|
+
case "STEWARD_ARCHIVED":
|
|
2301
|
+
case "PROPOSAL_DECLINED": return;
|
|
2302
|
+
}
|
|
2303
|
+
const listed = run.steps?.length ?? 0;
|
|
2304
|
+
if (run.stepCount != null && run.stepCount > listed && (run.status === "FAILED" || stop === "REPEATED_FAILURE")) return {
|
|
2305
|
+
reason: "RUN_FAILED",
|
|
2306
|
+
variant: "unchecked"
|
|
2307
|
+
};
|
|
2308
|
+
for (const code of failedStepCodes(run)) {
|
|
2309
|
+
const hint = classifyStep(code);
|
|
2310
|
+
if (hint) return hint;
|
|
2311
|
+
}
|
|
2312
|
+
if (stop) {
|
|
2313
|
+
const hint = classifyStep(stop);
|
|
2314
|
+
if (hint) return hint;
|
|
2315
|
+
}
|
|
2316
|
+
if (run.status !== "FAILED" && stop !== "REPEATED_FAILURE") return void 0;
|
|
2317
|
+
return { reason: "RUN_FAILED" };
|
|
2318
|
+
}
|
|
2319
|
+
/**
|
|
2320
|
+
* The guidance for a run that ended without finishing (failed, stopped or
|
|
2321
|
+
* paused on budget), or `undefined` for a run that is fine or whose stop needs
|
|
2322
|
+
* no guidance (cancelled by its owner, say).
|
|
2323
|
+
*
|
|
2324
|
+
* Reads `run.failure` (catalog section 1.2) when the service exposes it, and
|
|
2325
|
+
* falls back to `stopReason` and the failed steps' codes on older services.
|
|
2326
|
+
*/
|
|
2327
|
+
function describeRunFailure(run) {
|
|
2328
|
+
if (!UNFINISHED.has(run.status)) return void 0;
|
|
2329
|
+
const failure = run.failure ?? void 0;
|
|
2330
|
+
let hint = failure ? classifyFailure(failure, run) : classifyLegacy(run);
|
|
2331
|
+
if (hint?.reason === "OWN_MACHINE_OFFLINE" && hint.variant === "offline") {
|
|
2332
|
+
if (run.deskKind === "CLOUD" || run.deskKind === "BROWSER") hint = {
|
|
2333
|
+
reason: "CLOUD_DESK_BUSY_OR_UNAVAILABLE",
|
|
2334
|
+
variant: "startFailed"
|
|
2335
|
+
};
|
|
2336
|
+
else if (!run.deskKind) hint = {
|
|
2337
|
+
reason: "CLOUD_DESK_BUSY_OR_UNAVAILABLE",
|
|
2338
|
+
variant: "deskUnreachable"
|
|
2339
|
+
};
|
|
2340
|
+
}
|
|
2341
|
+
if (!hint) return void 0;
|
|
2342
|
+
const params = {
|
|
2343
|
+
toolLabel: failure?.toolKey ?? lastToolKey(run) ?? "the tool",
|
|
2344
|
+
destination: "its destination",
|
|
2345
|
+
...budgetParams(failure?.budgetKey, failure?.budgetLevel, failure?.budgetCap)
|
|
2346
|
+
};
|
|
2347
|
+
if (run.id) params.runId = run.id;
|
|
2348
|
+
if (run.stewardId) params.stewardId = run.stewardId;
|
|
2349
|
+
if (failure?.agentId) params.agentId = failure.agentId;
|
|
2350
|
+
if (failure?.connectionId) params.connectionId = failure.connectionId;
|
|
2351
|
+
if (failure?.machineId) params.machineId = failure.machineId;
|
|
2352
|
+
if (failure?.message) params.serverMessage = failure.message;
|
|
2353
|
+
params.specificReason = failure?.message ?? "they're out of date";
|
|
2354
|
+
if (hint.reason === "STEWARD_BUDGET_USED_UP" && hint.variant && params.budgetCap === void 0) return buildGuidedError({
|
|
2355
|
+
reason: hint.reason,
|
|
2356
|
+
params
|
|
2357
|
+
});
|
|
2358
|
+
if (hint.reason === "STEP_LIMIT_REACHED" && failure?.budgetCap != null) params.maxSteps = failure.budgetCap;
|
|
2359
|
+
return buildGuidedError(hint.variant ? {
|
|
2360
|
+
reason: hint.reason,
|
|
2361
|
+
variant: hint.variant,
|
|
2362
|
+
params
|
|
2363
|
+
} : {
|
|
2364
|
+
reason: hint.reason,
|
|
2365
|
+
params
|
|
2366
|
+
}, failure?.message ? { serverMessage: failure.message } : {});
|
|
2367
|
+
}
|
|
2368
|
+
function lastToolKey(run) {
|
|
2369
|
+
const steps = run.steps ?? [];
|
|
2370
|
+
for (let i = steps.length - 1; i >= 0; i -= 1) {
|
|
2371
|
+
const key = steps[i]?.toolKey;
|
|
2372
|
+
if (key) return key;
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
/** A readable label for a run's stop reason (catalog section J), never the raw code. */
|
|
2376
|
+
function stopReasonLabel(stopReason) {
|
|
2377
|
+
if (!stopReason) return void 0;
|
|
2378
|
+
const known = STOP_REASON_LABELS[stopReason];
|
|
2379
|
+
if (known) return known;
|
|
2380
|
+
return `Stopped: ${stopReason.toLowerCase().replace(/_/g, " ")}`;
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
export { GUIDED_ENTRIES as C, permissionLabelKey as D, PERMISSION_LABELS as E, AGENT_STATUS_SHORT_LABELS as S, GUIDED_PERMISSIONS as T, isDefiniteRefusal as _, fillGuidedParams as a, extractGuidedSource as b, guidedTranslateFrom as c, botmanorPath as d, crossShellUrl as f, guidedI18nBase as g, describeGuidedError as h, englishGuidedTranslate as i, planGuidedActions as l, buildGuidedError as m, stepReasonCode as n, guidedParams as o, resolveGuidedLocation as p, stopReasonLabel as r, guidedText as s, describeRunFailure as t, DEFAULT_BOTMANOR_APP_URL as u, isStaleStateError as v, STOP_REASON_LABELS as w, AGENT_STATUS_LABELS as x, reasonCamel as y };
|