@wiro-ai/wiro-mcp 1.9.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/README.md +101 -41
  2. package/dist/index.js +7 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/instructions.js +5 -5
  5. package/dist/instructions.js.map +1 -1
  6. package/dist/playbooks.d.ts.map +1 -1
  7. package/dist/playbooks.js +125 -98
  8. package/dist/playbooks.js.map +1 -1
  9. package/dist/prompts.js +7 -7
  10. package/dist/prompts.js.map +1 -1
  11. package/dist/tools/answer-agent-approval.d.ts +4 -0
  12. package/dist/tools/answer-agent-approval.d.ts.map +1 -0
  13. package/dist/tools/answer-agent-approval.js +354 -0
  14. package/dist/tools/answer-agent-approval.js.map +1 -0
  15. package/dist/tools/apply-agent-skills.d.ts.map +1 -1
  16. package/dist/tools/apply-agent-skills.js +81 -30
  17. package/dist/tools/apply-agent-skills.js.map +1 -1
  18. package/dist/tools/bind-agent-project.d.ts.map +1 -1
  19. package/dist/tools/bind-agent-project.js +29 -28
  20. package/dist/tools/bind-agent-project.js.map +1 -1
  21. package/dist/tools/cancel-agent-message.js +1 -1
  22. package/dist/tools/cancel-agent-message.js.map +1 -1
  23. package/dist/tools/check-model-access.d.ts.map +1 -1
  24. package/dist/tools/check-model-access.js +22 -15
  25. package/dist/tools/check-model-access.js.map +1 -1
  26. package/dist/tools/connect-agent-connector.d.ts +4 -0
  27. package/dist/tools/connect-agent-connector.d.ts.map +1 -0
  28. package/dist/tools/connect-agent-connector.js +634 -0
  29. package/dist/tools/connect-agent-connector.js.map +1 -0
  30. package/dist/tools/control-agent.d.ts.map +1 -1
  31. package/dist/tools/control-agent.js +30 -31
  32. package/dist/tools/control-agent.js.map +1 -1
  33. package/dist/tools/delete-agent.d.ts.map +1 -1
  34. package/dist/tools/delete-agent.js +12 -5
  35. package/dist/tools/delete-agent.js.map +1 -1
  36. package/dist/tools/deploy-agent.d.ts.map +1 -1
  37. package/dist/tools/deploy-agent.js +96 -44
  38. package/dist/tools/deploy-agent.js.map +1 -1
  39. package/dist/tools/disconnect-agent-connector.d.ts +4 -0
  40. package/dist/tools/disconnect-agent-connector.d.ts.map +1 -0
  41. package/dist/tools/disconnect-agent-connector.js +184 -0
  42. package/dist/tools/disconnect-agent-connector.js.map +1 -0
  43. package/dist/tools/get-account.d.ts.map +1 -1
  44. package/dist/tools/get-account.js +24 -8
  45. package/dist/tools/get-account.js.map +1 -1
  46. package/dist/tools/get-agent-activity.d.ts.map +1 -1
  47. package/dist/tools/get-agent-activity.js +285 -138
  48. package/dist/tools/get-agent-activity.js.map +1 -1
  49. package/dist/tools/get-agent-connector-permissions.d.ts +145 -0
  50. package/dist/tools/get-agent-connector-permissions.d.ts.map +1 -0
  51. package/dist/tools/get-agent-connector-permissions.js +194 -0
  52. package/dist/tools/get-agent-connector-permissions.js.map +1 -0
  53. package/dist/tools/get-agent-conversation.d.ts.map +1 -1
  54. package/dist/tools/get-agent-conversation.js +41 -11
  55. package/dist/tools/get-agent-conversation.js.map +1 -1
  56. package/dist/tools/get-agent-message.d.ts.map +1 -1
  57. package/dist/tools/get-agent-message.js +13 -5
  58. package/dist/tools/get-agent-message.js.map +1 -1
  59. package/dist/tools/get-agent-template.d.ts.map +1 -1
  60. package/dist/tools/get-agent-template.js +13 -15
  61. package/dist/tools/get-agent-template.js.map +1 -1
  62. package/dist/tools/get-controls.d.ts.map +1 -1
  63. package/dist/tools/get-controls.js +7 -4
  64. package/dist/tools/get-controls.js.map +1 -1
  65. package/dist/tools/get-my-agent.d.ts.map +1 -1
  66. package/dist/tools/get-my-agent.js +38 -5
  67. package/dist/tools/get-my-agent.js.map +1 -1
  68. package/dist/tools/get-task-price.d.ts.map +1 -1
  69. package/dist/tools/get-task-price.js +4 -4
  70. package/dist/tools/get-task-price.js.map +1 -1
  71. package/dist/tools/get-task.d.ts.map +1 -1
  72. package/dist/tools/get-task.js +4 -4
  73. package/dist/tools/get-task.js.map +1 -1
  74. package/dist/tools/index.d.ts +8 -3
  75. package/dist/tools/index.d.ts.map +1 -1
  76. package/dist/tools/index.js +17 -6
  77. package/dist/tools/index.js.map +1 -1
  78. package/dist/tools/kill-task.js +1 -1
  79. package/dist/tools/kill-task.js.map +1 -1
  80. package/dist/tools/list-agent-connectors.d.ts +4 -0
  81. package/dist/tools/list-agent-connectors.d.ts.map +1 -0
  82. package/dist/tools/list-agent-connectors.js +325 -0
  83. package/dist/tools/list-agent-connectors.js.map +1 -0
  84. package/dist/tools/list-agent-skills.d.ts.map +1 -1
  85. package/dist/tools/list-agent-skills.js +59 -40
  86. package/dist/tools/list-agent-skills.js.map +1 -1
  87. package/dist/tools/list-agent-templates.d.ts.map +1 -1
  88. package/dist/tools/list-agent-templates.js +7 -5
  89. package/dist/tools/list-agent-templates.js.map +1 -1
  90. package/dist/tools/list-my-agents.d.ts.map +1 -1
  91. package/dist/tools/list-my-agents.js +7 -3
  92. package/dist/tools/list-my-agents.js.map +1 -1
  93. package/dist/tools/list-projects.d.ts.map +1 -1
  94. package/dist/tools/list-projects.js +7 -4
  95. package/dist/tools/list-projects.js.map +1 -1
  96. package/dist/tools/list-studio-results.d.ts.map +1 -1
  97. package/dist/tools/list-studio-results.js +3 -2
  98. package/dist/tools/list-studio-results.js.map +1 -1
  99. package/dist/tools/list-tasks.d.ts.map +1 -1
  100. package/dist/tools/list-tasks.js +6 -3
  101. package/dist/tools/list-tasks.js.map +1 -1
  102. package/dist/tools/manage-agent-billing.d.ts.map +1 -1
  103. package/dist/tools/manage-agent-billing.js +216 -359
  104. package/dist/tools/manage-agent-billing.js.map +1 -1
  105. package/dist/tools/manage-agent-custom-skill.d.ts.map +1 -1
  106. package/dist/tools/manage-agent-custom-skill.js +77 -30
  107. package/dist/tools/manage-agent-custom-skill.js.map +1 -1
  108. package/dist/tools/manage-model-access.d.ts.map +1 -1
  109. package/dist/tools/manage-model-access.js +51 -20
  110. package/dist/tools/manage-model-access.js.map +1 -1
  111. package/dist/tools/manage-spend-limit.d.ts.map +1 -1
  112. package/dist/tools/manage-spend-limit.js +25 -19
  113. package/dist/tools/manage-spend-limit.js.map +1 -1
  114. package/dist/tools/run-model.d.ts.map +1 -1
  115. package/dist/tools/run-model.js +9 -8
  116. package/dist/tools/run-model.js.map +1 -1
  117. package/dist/tools/schemas.d.ts +11 -0
  118. package/dist/tools/schemas.d.ts.map +1 -1
  119. package/dist/tools/schemas.js +19 -1
  120. package/dist/tools/schemas.js.map +1 -1
  121. package/dist/tools/send-agent-message.d.ts.map +1 -1
  122. package/dist/tools/send-agent-message.js +53 -23
  123. package/dist/tools/send-agent-message.js.map +1 -1
  124. package/dist/tools/set-agent-connector-accounts.d.ts +4 -0
  125. package/dist/tools/set-agent-connector-accounts.d.ts.map +1 -0
  126. package/dist/tools/set-agent-connector-accounts.js +263 -0
  127. package/dist/tools/set-agent-connector-accounts.js.map +1 -0
  128. package/dist/tools/set-agent-connector-permissions.d.ts +4 -0
  129. package/dist/tools/set-agent-connector-permissions.d.ts.map +1 -0
  130. package/dist/tools/set-agent-connector-permissions.js +280 -0
  131. package/dist/tools/set-agent-connector-permissions.js.map +1 -0
  132. package/dist/tools/set-agent-credentials.d.ts.map +1 -1
  133. package/dist/tools/set-agent-credentials.js +52 -169
  134. package/dist/tools/set-agent-credentials.js.map +1 -1
  135. package/dist/tools/update-agent.d.ts.map +1 -1
  136. package/dist/tools/update-agent.js +39 -18
  137. package/dist/tools/update-agent.js.map +1 -1
  138. package/dist/tools/wait-for-task.d.ts.map +1 -1
  139. package/dist/tools/wait-for-task.js +4 -4
  140. package/dist/tools/wait-for-task.js.map +1 -1
  141. package/dist/tools/wait-for-workflow-run.d.ts.map +1 -1
  142. package/dist/tools/wait-for-workflow-run.js +6 -3
  143. package/dist/tools/wait-for-workflow-run.js.map +1 -1
  144. package/dist/utils/agent-approvals.d.ts +328 -0
  145. package/dist/utils/agent-approvals.d.ts.map +1 -0
  146. package/dist/utils/agent-approvals.js +620 -0
  147. package/dist/utils/agent-approvals.js.map +1 -0
  148. package/dist/utils/agent-catalog.d.ts +15 -25
  149. package/dist/utils/agent-catalog.d.ts.map +1 -1
  150. package/dist/utils/agent-catalog.js +27 -36
  151. package/dist/utils/agent-catalog.js.map +1 -1
  152. package/dist/utils/agent-config.d.ts +87 -292
  153. package/dist/utils/agent-config.d.ts.map +1 -1
  154. package/dist/utils/agent-config.js +150 -787
  155. package/dist/utils/agent-config.js.map +1 -1
  156. package/dist/utils/agent-connectors.d.ts +197 -0
  157. package/dist/utils/agent-connectors.d.ts.map +1 -0
  158. package/dist/utils/agent-connectors.js +415 -0
  159. package/dist/utils/agent-connectors.js.map +1 -0
  160. package/dist/utils/agent-message.d.ts +112 -4
  161. package/dist/utils/agent-message.d.ts.map +1 -1
  162. package/dist/utils/agent-message.js +105 -15
  163. package/dist/utils/agent-message.js.map +1 -1
  164. package/dist/utils/agent-setup.d.ts +19 -14
  165. package/dist/utils/agent-setup.d.ts.map +1 -1
  166. package/dist/utils/agent-setup.js +171 -106
  167. package/dist/utils/agent-setup.js.map +1 -1
  168. package/dist/utils/agent-targets.d.ts +7 -1
  169. package/dist/utils/agent-targets.d.ts.map +1 -1
  170. package/dist/utils/agent-targets.js +78 -23
  171. package/dist/utils/agent-targets.js.map +1 -1
  172. package/dist/utils/agent-turns.d.ts +260 -7
  173. package/dist/utils/agent-turns.d.ts.map +1 -1
  174. package/dist/utils/agent-turns.js +265 -74
  175. package/dist/utils/agent-turns.js.map +1 -1
  176. package/dist/utils/api.d.ts +26 -0
  177. package/dist/utils/api.d.ts.map +1 -1
  178. package/dist/utils/api.js +29 -0
  179. package/dist/utils/api.js.map +1 -1
  180. package/dist/utils/connector-permissions.d.ts +184 -0
  181. package/dist/utils/connector-permissions.d.ts.map +1 -0
  182. package/dist/utils/connector-permissions.js +439 -0
  183. package/dist/utils/connector-permissions.js.map +1 -0
  184. package/dist/utils/controls.d.ts +71 -11
  185. package/dist/utils/controls.d.ts.map +1 -1
  186. package/dist/utils/controls.js +124 -30
  187. package/dist/utils/controls.js.map +1 -1
  188. package/dist/utils/format.d.ts +10 -0
  189. package/dist/utils/format.d.ts.map +1 -1
  190. package/dist/utils/format.js +42 -3
  191. package/dist/utils/format.js.map +1 -1
  192. package/dist/utils/quoted-text.d.ts +2 -0
  193. package/dist/utils/quoted-text.d.ts.map +1 -1
  194. package/dist/utils/quoted-text.js +5 -0
  195. package/dist/utils/quoted-text.js.map +1 -1
  196. package/dist/utils/structured.d.ts +3 -0
  197. package/dist/utils/structured.d.ts.map +1 -1
  198. package/dist/utils/structured.js +7 -2
  199. package/dist/utils/structured.js.map +1 -1
  200. package/dist/utils/studio-runs.d.ts.map +1 -1
  201. package/dist/utils/studio-runs.js +6 -4
  202. package/dist/utils/studio-runs.js.map +1 -1
  203. package/dist/utils/user-agent.d.ts +271 -100
  204. package/dist/utils/user-agent.d.ts.map +1 -1
  205. package/dist/utils/user-agent.js +434 -159
  206. package/dist/utils/user-agent.js.map +1 -1
  207. package/dist/utils/wiro-project.d.ts +25 -0
  208. package/dist/utils/wiro-project.d.ts.map +1 -1
  209. package/dist/utils/wiro-project.js +76 -2
  210. package/dist/utils/wiro-project.js.map +1 -1
  211. package/dist/utils/workspace.d.ts +3 -1
  212. package/dist/utils/workspace.d.ts.map +1 -1
  213. package/dist/utils/workspace.js +2 -1
  214. package/dist/utils/workspace.js.map +1 -1
  215. package/package.json +1 -1
  216. package/dist/tools/connect-agent-oauth.d.ts +0 -4
  217. package/dist/tools/connect-agent-oauth.d.ts.map +0 -1
  218. package/dist/tools/connect-agent-oauth.js +0 -778
  219. package/dist/tools/connect-agent-oauth.js.map +0 -1
  220. package/dist/tools/disconnect-agent-oauth.d.ts +0 -4
  221. package/dist/tools/disconnect-agent-oauth.d.ts.map +0 -1
  222. package/dist/tools/disconnect-agent-oauth.js +0 -138
  223. package/dist/tools/disconnect-agent-oauth.js.map +0 -1
@@ -0,0 +1,439 @@
1
+ import { z } from 'zod';
2
+ import { asString, isPlainObject, requireApiSuccess, truncate, unixToIso } from './api.js';
3
+ // Connector permissions: what a connected Connector's actions may do without asking. Wiro sorts each action into a
4
+ // group by what it does (Read-only, Create and send, Change and delete) and gives each one a value in two columns:
5
+ // Chat, when someone is talking to the agent (the Wiro web chat, a message sent with an API key or from this server,
6
+ // an authorized Telegram, Slack or Discord chat), and Autopilot, its scheduled tasks and the work before and after a
7
+ // voice call. Any other work the agent does on its own (sub-agents, work in the background) takes the stricter of
8
+ // the two for each action, so an action runs there without asking only where both columns allow it.
9
+ // Allow runs the action, Ask waits for a person to approve it in the chat (an approval card), and Block never runs
10
+ // it; an action blocked in both columns is not shown to the agent at all. A group's value holds for each of its
11
+ // actions, and an action can have a setting of its own. By default Read-only runs, and Create and send and Change and
12
+ // delete ask first in Chat and run in Autopilot. These are the words the Wiro dashboard uses; the keys the API takes
13
+ // are read, create and change, chat and autopilot, allow, ask and block.
14
+ export const PERMISSION_CATEGORIES = ['read', 'create', 'change'];
15
+ export const PERMISSION_COLUMNS = ['chat', 'autopilot'];
16
+ export const PERMISSION_VALUES = ['allow', 'ask', 'block'];
17
+ /** The defaults of each group, the same on every connector unless Wiro sets an action's own default. */
18
+ export const CATEGORY_DEFAULTS = {
19
+ read: { chat: 'allow', autopilot: 'allow' },
20
+ create: { chat: 'ask', autopilot: 'allow' },
21
+ change: { chat: 'ask', autopilot: 'allow' },
22
+ };
23
+ export const CATEGORY_TITLES = {
24
+ read: 'Read-only',
25
+ create: 'Create and send',
26
+ change: 'Change and delete',
27
+ };
28
+ export const CATEGORY_TEXTS = {
29
+ read: 'Looks things up and changes nothing.',
30
+ create: 'Creates or sends something new, such as a post, a message or an email.',
31
+ change: 'Changes or deletes what is already there.',
32
+ };
33
+ export const COLUMN_TITLES = { chat: 'Chat', autopilot: 'Autopilot' };
34
+ export const VALUE_TITLES = { allow: 'Allow', ask: 'Ask', block: 'Block' };
35
+ /** The two columns and the three values, said the same way by every tool that shows or sets them. */
36
+ export const PERMISSIONS_EXPLAINED = 'Chat is when someone is talking to the agent: the Wiro web chat, a message sent '
37
+ + 'with an API key or from this server, or an authorized Telegram, Slack or Discord chat. Autopilot is its scheduled '
38
+ + 'tasks and the work before and after a voice call; any other work it does on its own, such as sub-agents and work '
39
+ + 'in the background, takes the stricter of Chat and Autopilot for each action. Allow runs an action, Ask waits for a '
40
+ + 'person to approve it in the chat, and Block never runs it; an action blocked in both is not shown to the agent at '
41
+ + 'all.';
42
+ /** The defaults, in words. */
43
+ export const PERMISSION_DEFAULTS_TEXT = 'By default, read-only actions run, and Create and send and Change and delete '
44
+ + 'ask first in Chat and run in Autopilot.';
45
+ /** What the permissions of the Wiro AI Models connector cover, and what they do not. */
46
+ export const WIRO_SCOPE_NOTE = 'These permissions cover the actions of the Wiro AI Models connector. Skills that run '
47
+ + 'models with the agent\'s own Wiro project, such as video creation, follow its Spend Limits and Model Access instead.';
48
+ const TOOL_NAME = /^[A-Za-z0-9_.-]{1,128}$/;
49
+ const MAX_DESCRIPTION = 200;
50
+ const MAX_TITLE = 120;
51
+ export const permissionValueSchema = z.enum(PERMISSION_VALUES);
52
+ const columnValueSchema = z.object({
53
+ value: permissionValueSchema.nullable()
54
+ .describe('The value every action of the group has in this column; null when they differ (mixed).'),
55
+ mixed: z.boolean(),
56
+ });
57
+ export const permissionCategorySchema = z.object({
58
+ key: z.enum(PERMISSION_CATEGORIES),
59
+ title: z.string(),
60
+ description: z.string(),
61
+ actions: z.number().int().nonnegative(),
62
+ chat: columnValueSchema,
63
+ autopilot: columnValueSchema,
64
+ chosen: z.object({ chat: permissionValueSchema.optional(), autopilot: permissionValueSchema.optional() })
65
+ .describe('The group\'s own setting in each column, where one was chosen; a column left out follows the default.'),
66
+ });
67
+ export const permissionActionSchema = z.object({
68
+ name: z.string().describe('The action\'s tool name at the connector, the key tools takes.'),
69
+ title: z.string(),
70
+ description: z.string().optional(),
71
+ category: z.enum(PERMISSION_CATEGORIES),
72
+ chat: permissionValueSchema,
73
+ autopilot: permissionValueSchema,
74
+ own: z.object({ chat: z.boolean(), autopilot: z.boolean() })
75
+ .describe('Whether the action has a setting of its own in each column, instead of its group\'s. null in tools removes it.'),
76
+ defaults: z.object({ chat: permissionValueSchema, autopilot: permissionValueSchema })
77
+ .describe('What each column falls back to without a setting of its group or its own: Wiro\'s default for this action, else its group\'s.'),
78
+ hidden: z.boolean().describe('Blocked in Chat and Autopilot, so the agent does not see it.'),
79
+ listed: z.boolean()
80
+ .describe('false: the connector has not listed this action yet; it shows because it has a setting of its own or a Wiro default.'),
81
+ });
82
+ function value(raw) {
83
+ const text = asString(raw);
84
+ return PERMISSION_VALUES.includes(text ?? '') ? text : undefined;
85
+ }
86
+ function category(raw) {
87
+ const text = asString(raw);
88
+ return PERMISSION_CATEGORIES.includes(text ?? '') ? text : undefined;
89
+ }
90
+ function cellSource(raw) {
91
+ const text = asString(raw);
92
+ return text === 'tool' || text === 'category' || text === 'catalog' || text === 'default' || text === 'unknown' ? text : 'default';
93
+ }
94
+ function line(raw, max) {
95
+ const text = asString(raw)?.replace(/\s+/g, ' ').trim();
96
+ return text ? truncate(text, max) : undefined;
97
+ }
98
+ function toAction(raw) {
99
+ const name = asString(raw.name)?.trim();
100
+ const group = category(raw.category);
101
+ const chat = value(raw.chat);
102
+ const autopilot = value(raw.autopilot);
103
+ if (!name || !TOOL_NAME.test(name) || !group || !chat || !autopilot)
104
+ return undefined;
105
+ const sources = isPlainObject(raw.source) ? raw.source : {};
106
+ const defaults = isPlainObject(raw.defaults) ? raw.defaults : {};
107
+ const source = { chat: cellSource(sources.chat), autopilot: cellSource(sources.autopilot) };
108
+ const description = line(raw.description, MAX_DESCRIPTION);
109
+ return {
110
+ name,
111
+ title: line(raw.title, MAX_TITLE) ?? name,
112
+ ...(description ? { description } : {}),
113
+ category: group,
114
+ chat,
115
+ autopilot,
116
+ own: { chat: source.chat === 'tool', autopilot: source.autopilot === 'tool' },
117
+ defaults: {
118
+ chat: value(defaults.chat) ?? CATEGORY_DEFAULTS[group].chat,
119
+ autopilot: value(defaults.autopilot) ?? CATEGORY_DEFAULTS[group].autopilot,
120
+ },
121
+ hidden: chat === 'block' && autopilot === 'block',
122
+ listed: raw.cached !== false,
123
+ source,
124
+ };
125
+ }
126
+ function toColumnValue(raw, fallback) {
127
+ if (!isPlainObject(raw))
128
+ return { value: fallback, mixed: false };
129
+ if (raw.mixed === true)
130
+ return { value: null, mixed: true };
131
+ return { value: value(raw.value) ?? fallback, mixed: false };
132
+ }
133
+ /** ConnectorPermissions' view of one connection: its groups, its actions and what an action not listed yet does. */
134
+ export function toPermissionView(raw) {
135
+ const body = isPlainObject(raw) ? raw : {};
136
+ const actions = (Array.isArray(body.tools) ? body.tools : []).filter(isPlainObject).map(toAction)
137
+ .filter((action) => action !== undefined);
138
+ const rows = (Array.isArray(body.categories) ? body.categories : []).filter(isPlainObject);
139
+ const categories = PERMISSION_CATEGORIES.map((key) => {
140
+ const row = rows.find(item => item.key === key) ?? {};
141
+ const chosenRow = isPlainObject(row.chosen) ? row.chosen : {};
142
+ const chosen = {};
143
+ for (const column of PERMISSION_COLUMNS) {
144
+ const picked = value(chosenRow[column]);
145
+ if (picked)
146
+ chosen[column] = picked;
147
+ }
148
+ const count = typeof row.tools === 'number' && Number.isFinite(row.tools)
149
+ ? Math.max(0, Math.trunc(row.tools))
150
+ : actions.filter(action => action.category === key).length;
151
+ return {
152
+ key,
153
+ title: CATEGORY_TITLES[key],
154
+ description: CATEGORY_TEXTS[key],
155
+ actions: count,
156
+ chat: toColumnValue(row.chat, chosen.chat ?? CATEGORY_DEFAULTS[key].chat),
157
+ autopilot: toColumnValue(row.autopilot, chosen.autopilot ?? CATEGORY_DEFAULTS[key].autopilot),
158
+ chosen,
159
+ };
160
+ });
161
+ const unknown = isPlainObject(body.unknown) ? body.unknown : {};
162
+ const updatedAt = unixToIso(body.updatedat);
163
+ return {
164
+ categories,
165
+ actions,
166
+ unlisted: {
167
+ chat: value(unknown.chat) ?? CATEGORY_DEFAULTS.change.chat,
168
+ autopilot: value(unknown.autopilot) ?? CATEGORY_DEFAULTS.change.autopilot,
169
+ },
170
+ ...(updatedAt ? { updatedAt } : {}),
171
+ };
172
+ }
173
+ /** An action as the tools return it: without where each value came from. */
174
+ export function publicAction(action) {
175
+ const { source: _source, ...rest } = action;
176
+ return rest;
177
+ }
178
+ /** One connection's permissions and the approval cards waiting for it. Only an agent admin can read them. */
179
+ export async function readConnectorPermissions(client, agentGuid, slug, signal) {
180
+ const body = requireApiSuccess(await client.post('/UserAgent/ConnectorPermissions', { useragentguid: agentGuid, slug }, signal), 'The connector\'s permissions could not be read.');
181
+ const connector = isPlainObject(body.connector) ? body.connector : {};
182
+ const status = asString(connector.catalogstatus);
183
+ return {
184
+ connector: {
185
+ slug: asString(connector.slug) ?? slug,
186
+ title: line(connector.title, MAX_TITLE) ?? slug,
187
+ actionsListed: connector.toolscached === true,
188
+ ...(status === 'active' || status === 'hidden' || status === 'retired' ? { catalogStatus: status } : {}),
189
+ },
190
+ view: toPermissionView(body.permissions),
191
+ waiting: (Array.isArray(body.pending) ? body.pending : []).filter(isPlainObject),
192
+ };
193
+ }
194
+ /** What the connection holds now, as far as the view shows it: each group's own setting and each action's own one. */
195
+ function storedState(view) {
196
+ const categories = {};
197
+ for (const row of view.categories) {
198
+ if (Object.keys(row.chosen).length > 0)
199
+ categories[row.key] = { ...row.chosen };
200
+ }
201
+ const tools = {};
202
+ for (const action of view.actions) {
203
+ const cells = {};
204
+ for (const column of PERMISSION_COLUMNS)
205
+ if (action.own[column])
206
+ cells[column] = action[column];
207
+ if (Object.keys(cells).length > 0)
208
+ tools[action.name] = cells;
209
+ }
210
+ return { categories, tools };
211
+ }
212
+ /**
213
+ * The state after a change, applied the way Wiro applies it: reset first (no group or action setting is left), then
214
+ * the groups (setting a group's column also clears that column from the own settings of its actions), then the
215
+ * actions (null removes an own setting).
216
+ */
217
+ function applyChanges(view, before, changes) {
218
+ const categories = changes.reset ? {} : structuredClone(before.categories);
219
+ const tools = changes.reset ? {} : structuredClone(before.tools);
220
+ // An action the connector has not listed counts as Change and delete.
221
+ const groupOf = new Map(view.actions.filter(action => action.listed).map(action => [action.name, action.category]));
222
+ for (const key of PERMISSION_CATEGORIES) {
223
+ const cells = changes.categories?.[key];
224
+ if (!cells)
225
+ continue;
226
+ const entry = { ...(categories[key] ?? {}) };
227
+ for (const column of PERMISSION_COLUMNS) {
228
+ if (!(column in cells))
229
+ continue;
230
+ const next = cells[column];
231
+ if (next === null || next === undefined)
232
+ delete entry[column];
233
+ else
234
+ entry[column] = next;
235
+ for (const name of Object.keys(tools)) {
236
+ if ((groupOf.get(name) ?? 'change') !== key)
237
+ continue;
238
+ delete tools[name][column];
239
+ if (Object.keys(tools[name]).length === 0)
240
+ delete tools[name];
241
+ }
242
+ }
243
+ if (Object.keys(entry).length > 0)
244
+ categories[key] = entry;
245
+ else
246
+ delete categories[key];
247
+ }
248
+ for (const [name, cells] of Object.entries(changes.tools ?? {})) {
249
+ const entry = { ...(tools[name] ?? {}) };
250
+ for (const column of PERMISSION_COLUMNS) {
251
+ if (!(column in cells))
252
+ continue;
253
+ const next = cells[column];
254
+ if (next === null || next === undefined)
255
+ delete entry[column];
256
+ else
257
+ entry[column] = next;
258
+ }
259
+ if (Object.keys(entry).length > 0)
260
+ tools[name] = entry;
261
+ else
262
+ delete tools[name];
263
+ }
264
+ return { categories, tools };
265
+ }
266
+ function unlistedValue(state, column) {
267
+ return state.categories.change?.[column] ?? CATEGORY_DEFAULTS.change[column];
268
+ }
269
+ /**
270
+ * What an action the connector has not listed reads in one column without a setting of its own: Wiro's own default
271
+ * for it when it has one, else Change and delete's value. The view tells a value that came from Wiro's default, and a
272
+ * default that differs from Change and delete's default, but not a default equal to Change and delete's default from
273
+ * none. So the value is certain when that default equals Change and delete's value under the state, and is one of the
274
+ * two when they differ: Change and delete's value, or the default.
275
+ */
276
+ function catalogDefault(action, state, column) {
277
+ if (action.source[column] === 'catalog')
278
+ return { to: action[column] };
279
+ const unlisted = unlistedValue(state, column);
280
+ if (action.source[column] === 'unknown')
281
+ return { to: unlisted };
282
+ const fallback = action.defaults[column];
283
+ if (fallback !== CATEGORY_DEFAULTS.change[column] || fallback === unlisted)
284
+ return { to: fallback };
285
+ return { to: unlisted, or: fallback };
286
+ }
287
+ /** An action's value in a column under a state: its own setting, else its group's, else its default. */
288
+ function effectiveValue(action, state, column) {
289
+ const own = state.tools[action.name]?.[column];
290
+ if (own)
291
+ return { to: own };
292
+ if (action.listed)
293
+ return { to: state.categories[action.category]?.[column] ?? action.defaults[column] };
294
+ return catalogDefault(action, state, column);
295
+ }
296
+ /** Whether an outcome of a move turns Ask into Allow or leaves the value as it is. */
297
+ function asksToAllow(from, to) {
298
+ return to === from || (from === 'ask' && to === 'allow');
299
+ }
300
+ /** What a change does, worked out from the view the way Wiro decides it. */
301
+ export function planChanges(view, changes) {
302
+ const before = storedState(view);
303
+ const after = applyChanges(view, before, changes);
304
+ const moves = [];
305
+ const hides = [];
306
+ const shows = [];
307
+ for (const action of view.actions) {
308
+ const values = PERMISSION_COLUMNS.map(column => [column, action[column], effectiveValue(action, after, column)]);
309
+ for (const [column, from, outcome] of values) {
310
+ if (from === outcome.to && (outcome.or === undefined || from === outcome.or))
311
+ continue;
312
+ moves.push({
313
+ action: action.title,
314
+ name: action.name,
315
+ column,
316
+ from,
317
+ to: outcome.to,
318
+ ...(outcome.or !== undefined ? { or: outcome.or } : {}),
319
+ });
320
+ }
321
+ // Where a value is one of two, an action counts as hidden only when both outcomes hide it, and as shown again
322
+ // only when neither does.
323
+ const hiddenTo = values.every(([, , outcome]) => outcome.to === 'block');
324
+ const hiddenOr = values.every(([, , outcome]) => (outcome.or ?? outcome.to) === 'block');
325
+ if (hiddenTo && hiddenOr && !action.hidden)
326
+ hides.push(action.title);
327
+ if (!hiddenTo && !hiddenOr && action.hidden)
328
+ shows.push(action.title);
329
+ }
330
+ for (const column of PERMISSION_COLUMNS) {
331
+ const to = unlistedValue(after, column);
332
+ if (view.unlisted[column] !== to)
333
+ moves.push({ action: null, column, from: view.unlisted[column], to });
334
+ }
335
+ return {
336
+ moves,
337
+ stored: stableJson(before) !== stableJson(after),
338
+ // Each outcome of each move turns Ask into Allow or leaves the value as it is.
339
+ askToAllowOnly: moves.every(move => asksToAllow(move.from, move.to) && (move.or === undefined || asksToAllow(move.from, move.or))),
340
+ hides,
341
+ shows,
342
+ };
343
+ }
344
+ function stableJson(value) {
345
+ if (Array.isArray(value))
346
+ return `[${value.map(stableJson).join(',')}]`;
347
+ if (isPlainObject(value)) {
348
+ return `{${Object.keys(value).sort().map(key => `${JSON.stringify(key)}:${stableJson(value[key])}`).join(',')}}`;
349
+ }
350
+ return JSON.stringify(value) ?? 'null';
351
+ }
352
+ /** What the view holds, for a change summary's id: a confirm goes ahead only while it is the same. */
353
+ export function permissionStateDigest(view) {
354
+ return stableJson({ state: storedState(view), updatedAt: view.updatedAt ?? null });
355
+ }
356
+ /** A change request with only what it sets, in a stable order, as the summary id binds it. */
357
+ export function normalizedChanges(changes) {
358
+ const out = {};
359
+ if (changes.reset === true)
360
+ out.reset = true;
361
+ const categories = {};
362
+ for (const key of PERMISSION_CATEGORIES) {
363
+ const cells = changes.categories?.[key];
364
+ if (cells && Object.keys(cells).length > 0)
365
+ categories[key] = cells;
366
+ }
367
+ if (Object.keys(categories).length > 0)
368
+ out.categories = categories;
369
+ const names = Object.keys(changes.tools ?? {}).filter(name => Object.keys(changes.tools?.[name] ?? {}).length > 0).sort();
370
+ if (names.length > 0)
371
+ out.tools = Object.fromEntries(names.map(name => [name, changes.tools[name]]));
372
+ return out;
373
+ }
374
+ /** A value in words: "Allow". */
375
+ export function valueTitle(valueKey) {
376
+ return valueKey ? VALUE_TITLES[valueKey] : 'Mixed';
377
+ }
378
+ /** One requested cell in words: "Chat Allow", or "Chat back to the group's setting". */
379
+ function requestedCell(column, next, ofAction) {
380
+ if (next === null || next === undefined) {
381
+ return `${COLUMN_TITLES[column]} back to ${ofAction ? 'its group\'s setting' : 'its default'}`;
382
+ }
383
+ return `${COLUMN_TITLES[column]} ${VALUE_TITLES[next]}`;
384
+ }
385
+ /** The request in words, one line each, as a change summary lists it. titles names actions by their titles. */
386
+ export function requestLines(changes, titles) {
387
+ const lines = [];
388
+ if (changes.reset)
389
+ lines.push('- Reset: every group and action goes back to its default first.');
390
+ for (const key of PERMISSION_CATEGORIES) {
391
+ const cells = changes.categories?.[key];
392
+ if (!cells)
393
+ continue;
394
+ const parts = PERMISSION_COLUMNS.filter(column => column in cells).map(column => requestedCell(column, cells[column], false));
395
+ if (parts.length > 0) {
396
+ lines.push(`- ${CATEGORY_TITLES[key]} (group): ${parts.join(', ')}. Its actions' own settings in ${parts.length === 1 ? 'this column are' : 'these columns are'} cleared.`);
397
+ }
398
+ }
399
+ for (const [name, cells] of Object.entries(changes.tools ?? {})) {
400
+ const parts = PERMISSION_COLUMNS.filter(column => column in cells).map(column => requestedCell(column, cells[column], true));
401
+ if (parts.length > 0)
402
+ lines.push(`- ${titles.get(name) ?? name} (\`${name}\`): ${parts.join(', ')}.`);
403
+ }
404
+ return lines;
405
+ }
406
+ /**
407
+ * What changes for the agent, grouped by column and by the move, one line each. A move that can end at one of two
408
+ * values gets a line of its own that names both.
409
+ */
410
+ export function moveLines(moves, limit = 12) {
411
+ const groups = new Map();
412
+ const eitherWay = [];
413
+ for (const move of moves) {
414
+ if (move.or !== undefined) {
415
+ eitherWay.push(move);
416
+ continue;
417
+ }
418
+ const key = `${move.column}:${move.from}:${move.to}`;
419
+ groups.set(key, [...(groups.get(key) ?? []), move]);
420
+ }
421
+ const lines = [...groups.values()].map((group) => {
422
+ const first = group[0];
423
+ const named = group.filter(move => move.action !== null).map(move => move.action);
424
+ const unlisted = group.some(move => move.action === null);
425
+ const shown = named.slice(0, limit);
426
+ const more = named.length - shown.length;
427
+ const who = [
428
+ ...(shown.length > 0 ? [`${named.length === 1 ? '1 action' : `${named.length} actions`} (${shown.join(', ')}${more > 0 ? `, and ${more} more` : ''})`] : []),
429
+ ...(unlisted ? ['actions not listed yet'] : []),
430
+ ].join(' and ');
431
+ return `- ${COLUMN_TITLES[first.column]}: ${VALUE_TITLES[first.from]} to ${VALUE_TITLES[first.to]} for ${who}.`;
432
+ });
433
+ for (const move of eitherWay) {
434
+ lines.push(`- ${move.action ?? 'An action'} (not listed yet), ${COLUMN_TITLES[move.column]}: ${VALUE_TITLES[move.from]} `
435
+ + `to ${VALUE_TITLES[move.to]}, or ${VALUE_TITLES[move.or]} if Wiro sets a default for it; the save's answer says which.`);
436
+ }
437
+ return lines;
438
+ }
439
+ //# sourceMappingURL=connector-permissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connector-permissions.js","sourceRoot":"","sources":["../../src/utils/connector-permissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,iBAAiB,EAAE,QAAQ,EAAE,SAAS,EAAoB,MAAM,UAAU,CAAC;AAE7G,mHAAmH;AACnH,mHAAmH;AACnH,qHAAqH;AACrH,qHAAqH;AACrH,kHAAkH;AAClH,oGAAoG;AACpG,mHAAmH;AACnH,gHAAgH;AAChH,sHAAsH;AACtH,qHAAqH;AACrH,yEAAyE;AAEzE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAC;AAG3E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,WAAW,CAAU,CAAC;AAGjE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAU,CAAC;AAKpE,wGAAwG;AACxG,MAAM,CAAC,MAAM,iBAAiB,GAA0E;IACtG,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE;IAC3C,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE;IAC3C,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AI,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5J,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAChD,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAChB,OAAO,KAAK,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,GAAG,GAAG,CAAC;IAClH,CAAC,CAAC,CAAC;IACH,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;QAC7B,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,IAAI,WAAW,sBAAsB,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;cACrH,MAAM,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,YAAY,CAAC,IAAI,CAAC,EAAG,CAAC,+DAA+D,CAAC,CAAC;IAChI,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -2,7 +2,7 @@ import { z } from 'zod';
2
2
  import { type WiroClient } from '../client.js';
3
3
  export declare const CONTROL_SCOPES: readonly ["account", "member", "project", "surface", "agent"];
4
4
  export type ControlScope = typeof CONTROL_SCOPES[number];
5
- export declare const SURFACES: readonly ["web", "api", "mcp", "llm-gateway", "extension", "agent"];
5
+ export declare const SURFACES: readonly ["web", "api", "mcp", "llm-gateway", "extension", "agent", "studio", "workflow-agent", "workflow"];
6
6
  export type Surface = typeof SURFACES[number];
7
7
  export declare const PERIODS: readonly ["month", "day"];
8
8
  export type Period = typeof PERIODS[number];
@@ -12,7 +12,11 @@ export type Access = 'allow' | 'block';
12
12
  export type CategoryLabels = Record<CategoryKey, string>;
13
13
  /** How Wiro names each way in, as its refusals do. */
14
14
  export declare const SURFACE_LABELS: Record<Surface, string>;
15
- /** What each way in covers. A local install of this server sends its calls with an API key, so it counts as api. */
15
+ /**
16
+ * What each way in covers. This server's command names itself to Wiro (x-wiro-client), so a local install counts as
17
+ * mcp, like the hosted server. Work that fits more than one counts on the first that matches: who does it (Studio,
18
+ * the Workflow Agent or a deployed agent), then a workflow run, then the client, then the API key or the dashboard.
19
+ */
16
20
  export declare const SURFACE_DESCRIPTIONS: Record<Surface, string>;
17
21
  /** Wiro's limit on one rule: it can name at most this many models. */
18
22
  export declare const MAX_RULE_MODELS = 500;
@@ -39,6 +43,25 @@ export interface Caller {
39
43
  /** In a team, the user id of the person this connection acts as: the creator of its key's project. */
40
44
  memberUuid?: string;
41
45
  }
46
+ /** Who changed a limit or a rule last, as Wiro names them. */
47
+ export interface ChangedBy {
48
+ useruuid: string;
49
+ /** Their name or e-mail, or "the organization owner"; absent for someone who is no longer in the team. */
50
+ name?: string;
51
+ }
52
+ export declare const changedBySchema: z.ZodObject<{
53
+ useruuid: z.ZodString;
54
+ name: z.ZodOptional<z.ZodString>;
55
+ }, z.core.$strip>;
56
+ /**
57
+ * "last changed by `Jane Doe` on November 18, 2026 at 14:02 UTC", or undefined when Wiro did not say who. A name
58
+ * people wrote stays in a code span; Wiro's own label for the organization's owner reads as words.
59
+ */
60
+ export declare function changedByText(row: {
61
+ updatedBy?: ChangedBy;
62
+ updatedAt?: number;
63
+ createdAt?: number;
64
+ }, kind: ControlsWorkspace['kind'], caller: Caller | undefined): string | undefined;
42
65
  /** Who may change controls, for a sentence after a refusal or in a read. */
43
66
  export declare function whoCanChange(kind: ControlsWorkspace['kind']): string;
44
67
  /** The whole wallet's name, by the kind of workspace. */
@@ -59,6 +82,7 @@ export interface LimitRow {
59
82
  resetsAt?: number;
60
83
  createdAt?: number;
61
84
  updatedAt?: number;
85
+ updatedBy?: ChangedBy;
62
86
  }
63
87
  /** A limit row of SpendLimit/List, /Preview or /Set, rebuilt from an allowlist. */
64
88
  export declare function toLimitRow(row: Record<string, unknown>): LimitRow | null;
@@ -146,6 +170,10 @@ export declare const limitViewSchema: z.ZodObject<{
146
170
  periodStart: z.ZodOptional<z.ZodString>;
147
171
  resetsAt: z.ZodOptional<z.ZodString>;
148
172
  updatedAt: z.ZodOptional<z.ZodNumber>;
173
+ updatedBy: z.ZodOptional<z.ZodObject<{
174
+ useruuid: z.ZodString;
175
+ name: z.ZodOptional<z.ZodString>;
176
+ }, z.core.$strip>>;
149
177
  }, z.core.$strip>;
150
178
  export type LimitView = z.infer<typeof limitViewSchema>;
151
179
  export declare function limitView(row: LimitRow, caller: Caller | undefined): LimitView;
@@ -171,8 +199,9 @@ export interface RuleRow {
171
199
  models: RuleModelEntry[];
172
200
  createdAt?: number;
173
201
  updatedAt?: number;
202
+ updatedBy?: ChangedBy;
174
203
  }
175
- /** A rule row of ModelAccess/List, /Preview or /Set, rebuilt from an allowlist. */
204
+ /** A rule row of ModelAccess/List, /Preview, /Set or /Check, rebuilt from an allowlist. */
176
205
  export declare function toRuleRow(row: Record<string, unknown>): RuleRow | null;
177
206
  /** The category labels a ModelAccess/List answer gives, over the built-in ones. */
178
207
  export declare function toCategoryLabels(value: unknown): CategoryLabels;
@@ -242,11 +271,36 @@ export declare const ruleViewSchema: z.ZodObject<{
242
271
  }, z.core.$strip>>;
243
272
  summary: z.ZodString;
244
273
  updatedAt: z.ZodOptional<z.ZodNumber>;
274
+ updatedBy: z.ZodOptional<z.ZodObject<{
275
+ useruuid: z.ZodString;
276
+ name: z.ZodOptional<z.ZodString>;
277
+ }, z.core.$strip>>;
245
278
  }, z.core.$strip>;
246
279
  export type RuleView = z.infer<typeof ruleViewSchema>;
247
280
  export declare function ruleView(rule: RuleRow, labels: CategoryLabels, caller: Caller | undefined): RuleView;
248
281
  /** One line of a rule list: at most ten models are named in the text. */
249
282
  export declare function ruleLine(rule: RuleRow, labels: CategoryLabels, kind: ControlsWorkspace['kind'], caller: Caller | undefined): string;
283
+ /** The model that transcribes the voice notes of an agent that chats on Gemini. It is an LLM & Chat model too. */
284
+ export declare const GEMINI_VOICE_MODEL = "google/gemini-3-flash";
285
+ /** What an agent's own rule gives its built-in voice. */
286
+ export interface AgentVoice {
287
+ /** Whether the agent chats on Gemini, so that GEMINI_VOICE_MODEL transcribes its voice notes. */
288
+ gemini: boolean;
289
+ /** Its voice notes: transcribed, or not. */
290
+ notes: Access;
291
+ /** Whether the rule's entry for GEMINI_VOICE_MODEL decides the voice notes (an agent that chats on Gemini). */
292
+ notesByName: boolean;
293
+ /** Its voice replies: spoken, or sent as text. */
294
+ replies: Access;
295
+ }
296
+ /**
297
+ * What an agent's own rule gives its built-in voice; null for no rule. Its voice models count as Audio & Speech, so the
298
+ * rule's Audio & Speech entry decides them, else what it gives every other model, and allowing LLM & Chat does not
299
+ * open them. An agent that chats on Gemini has its voice notes transcribed by GEMINI_VOICE_MODEL, which has to pass
300
+ * the rule both as an Audio & Speech model and as the LLM & Chat model it is: a rule entry that names it decides
301
+ * both, else Audio & Speech and LLM & Chat must both let it run.
302
+ */
303
+ export declare function agentVoice(rule: Pick<RuleRow, 'access' | 'categories' | 'models'> | null, chatModel: string | undefined): AgentVoice;
250
304
  export type Decision = 'allow' | 'block';
251
305
  export type DecidedBy = 'model' | 'category' | 'default';
252
306
  /** How one rule decides a model for a run, as ModelAccess/Check explains it. */
@@ -344,28 +398,34 @@ export declare function resolveTarget(client: WiroClient, args: TargetArgs & {
344
398
  caller?: Caller;
345
399
  }, signal?: AbortSignal): Promise<ResolvedTarget>;
346
400
  export type ControlsPage = 'spend-limits' | 'model-access';
401
+ /** The workspace a Controls link opens in, where it is known. */
402
+ export type LinkedWorkspace = Pick<ControlsWorkspace, 'kind' | 'teamGuid'>;
403
+ /**
404
+ * A Controls page of the Wiro dashboard, in the workspace it is about: ?workspace=<team guid> for a team, or
405
+ * ?workspace=personal for a personal account, opens the page in that workspace whichever one the browser is on.
406
+ * The page's plain address when the workspace is not known.
407
+ */
408
+ export declare function controlsPageUrl(page: ControlsPage, workspace?: LinkedWorkspace): string;
347
409
  /** An older Wiro API has no change summary for controls, so no change goes through this server. */
348
- export declare function previewMissingText(page: ControlsPage): string;
410
+ export declare function previewMissingText(page: ControlsPage, workspace?: LinkedWorkspace): string;
349
411
  /** Wiro's refusal of a change, with what fixes it where that is known. */
350
412
  export declare function refusalText(message: string): string;
351
413
  /** Why a read for a change failed, as one sentence that says nothing changed. */
352
414
  export declare function readFailure(what: string, error: unknown): Error;
353
415
  /** Why a change summary could not be made. A route the API does not have means the change cannot be previewed. */
354
- export declare function previewFailure(error: unknown, page: ControlsPage): Error;
416
+ export declare function previewFailure(error: unknown, page: ControlsPage, workspace?: LinkedWorkspace): Error;
355
417
  /**
356
418
  * Why a change failed. A clean refusal changed nothing. Without a clear answer the change may have
357
419
  * gone through, so `unknownText` says how to find out.
358
420
  */
359
- export declare function changeFailure(error: unknown, page: ControlsPage, unknownText: string): Error;
421
+ export declare function changeFailure(error: unknown, page: ControlsPage, unknownText: string, workspace?: LinkedWorkspace): Error;
360
422
  /** The sentence for a connection that may read controls but not change them. */
361
- export declare function cannotChangeText(kind: ControlsWorkspace['kind'], what: 'spend limits' | 'Model Access rules', page: ControlsPage): string;
423
+ export declare function cannotChangeText(workspace: LinkedWorkspace, what: 'spend limits' | 'Model Access rules', page: ControlsPage): string;
362
424
  export declare const dashboardSchema: z.ZodObject<{
363
425
  spendLimits: z.ZodString;
364
426
  modelAccess: z.ZodString;
365
427
  }, z.core.$strip>;
366
- export declare const DASHBOARD: {
367
- spendLimits: string;
368
- modelAccess: string;
369
- };
428
+ /** The Controls pages of the Wiro dashboard, in the given workspace where it is known. */
429
+ export declare function dashboardOf(workspace?: LinkedWorkspace): z.infer<typeof dashboardSchema>;
370
430
  export {};
371
431
  //# sourceMappingURL=controls.d.ts.map