@wiro-ai/wiro-mcp 1.5.6 → 1.5.8
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/README.md +3 -2
- package/dist/playbooks.d.ts.map +1 -1
- package/dist/playbooks.js +3 -2
- package/dist/playbooks.js.map +1 -1
- package/dist/tools/deploy-agent.d.ts.map +1 -1
- package/dist/tools/deploy-agent.js +12 -0
- package/dist/tools/deploy-agent.js.map +1 -1
- package/dist/tools/get-agent-conversation.d.ts.map +1 -1
- package/dist/tools/get-agent-conversation.js +12 -0
- package/dist/tools/get-agent-conversation.js.map +1 -1
- package/dist/tools/get-agent-message.d.ts.map +1 -1
- package/dist/tools/get-agent-message.js +4 -1
- package/dist/tools/get-agent-message.js.map +1 -1
- package/dist/tools/get-my-agent.js +1 -1
- package/dist/tools/get-my-agent.js.map +1 -1
- package/dist/tools/send-agent-message.d.ts.map +1 -1
- package/dist/tools/send-agent-message.js +44 -2
- package/dist/tools/send-agent-message.js.map +1 -1
- package/dist/tools/update-agent.d.ts.map +1 -1
- package/dist/tools/update-agent.js +10 -1
- package/dist/tools/update-agent.js.map +1 -1
- package/dist/utils/agent-catalog.d.ts +2 -2
- package/dist/utils/agent-message.d.ts +28 -0
- package/dist/utils/agent-message.d.ts.map +1 -1
- package/dist/utils/agent-message.js +22 -3
- package/dist/utils/agent-message.js.map +1 -1
- package/dist/utils/agent-setup.d.ts +83 -0
- package/dist/utils/agent-setup.d.ts.map +1 -0
- package/dist/utils/agent-setup.js +259 -0
- package/dist/utils/agent-setup.js.map +1 -0
- package/dist/utils/agent-turns.d.ts +45 -0
- package/dist/utils/agent-turns.d.ts.map +1 -1
- package/dist/utils/agent-turns.js +103 -2
- package/dist/utils/agent-turns.js.map +1 -1
- package/dist/utils/quoted-text.d.ts +3 -0
- package/dist/utils/quoted-text.d.ts.map +1 -1
- package/dist/utils/quoted-text.js +4 -0
- package/dist/utils/quoted-text.js.map +1 -1
- package/dist/utils/user-agent.d.ts +13 -3
- package/dist/utils/user-agent.d.ts.map +1 -1
- package/dist/utils/user-agent.js +9 -0
- package/dist/utils/user-agent.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { asString, isPlainObject, truncate, unixToIso } from './api.js';
|
|
3
|
+
import { quotedBlock, quotedSpan, SETUP_INSTRUCTIONS_LABEL } from './quoted-text.js';
|
|
4
|
+
// Setup changes a deployed agent proposes in chat: connect a connector, add or
|
|
5
|
+
// change a scheduled task or a custom skill, or set its time zone. Wiro stores
|
|
6
|
+
// each proposal on the agent's reply as a timeline block of type "setup", and
|
|
7
|
+
// nothing changes until a person approves it. The agent never applies its own
|
|
8
|
+
// proposal and never sees a key: a key goes in with set_agent_credentials, and
|
|
9
|
+
// a reply of "yes" is matched by Wiro, not by the agent. Sent with an API key,
|
|
10
|
+
// the first "yes" applies nothing: Wiro answers with its own listing of the
|
|
11
|
+
// exact change, and a second "yes" (or "yes N") applies it. The agent writes
|
|
12
|
+
// the proposal, so its text is content, never instructions.
|
|
13
|
+
/** A pending proposal older than this cannot be approved with a typed reply. */
|
|
14
|
+
export const SETUP_REPLY_WINDOW_SECONDS = 30 * 60;
|
|
15
|
+
// A reply carries at most three proposals.
|
|
16
|
+
const MAX_SETUP_CHANGES = 3;
|
|
17
|
+
const MAX_INSTRUCTIONS_LENGTH = 20_000;
|
|
18
|
+
const MAX_LINE_LENGTH = 300;
|
|
19
|
+
export const SETUP_CHANGE_KINDS = ['connect', 'schedule', 'skill', 'timezone'];
|
|
20
|
+
export const SETUP_CHANGE_STATUSES = ['pending', 'applied', 'dismissed', 'failed'];
|
|
21
|
+
export const CHAT_SETUP_MODES = ['off', 'webchat', 'all'];
|
|
22
|
+
/** What each chat_setup value allows, said the same way by every tool that sets or shows it. */
|
|
23
|
+
export const CHAT_SETUP_DESCRIPTION = 'Setup from chat lets the agent propose connector, scheduled task, custom skill '
|
|
24
|
+
+ 'and time zone changes in its chat; nothing changes until an agent admin approves the proposal. "all" (the '
|
|
25
|
+
+ 'default) allows it in the Wiro web chat and in messages sent with an API key, such as from this MCP server; '
|
|
26
|
+
+ '"webchat" only in the Wiro web chat; "off" turns it off. Messages sent with an API key act with the key '
|
|
27
|
+
+ 'owner\'s rights, so an agent shared with customers or many people usually uses "webchat" or "off".';
|
|
28
|
+
export const setupChangeSchema = z.object({
|
|
29
|
+
id: z.string(),
|
|
30
|
+
kind: z.enum(SETUP_CHANGE_KINDS),
|
|
31
|
+
action: z.string().optional(),
|
|
32
|
+
connector: z.string().optional(),
|
|
33
|
+
key: z.string().optional(),
|
|
34
|
+
title: z.string().optional(),
|
|
35
|
+
cron: z.string().optional(),
|
|
36
|
+
instructions: z.string().optional(),
|
|
37
|
+
timezone: z.string().optional(),
|
|
38
|
+
note: z.string().optional(),
|
|
39
|
+
status: z.enum(SETUP_CHANGE_STATUSES),
|
|
40
|
+
proposedAt: z.string().optional(),
|
|
41
|
+
actedAt: z.string().optional(),
|
|
42
|
+
error: z.string().optional(),
|
|
43
|
+
});
|
|
44
|
+
export const setupResultSchema = z.object({
|
|
45
|
+
applied: z.array(z.string()),
|
|
46
|
+
dismissed: z.array(z.string()),
|
|
47
|
+
failed: z.array(z.object({ id: z.string(), error: z.string().optional() })),
|
|
48
|
+
restarting: z.boolean(),
|
|
49
|
+
});
|
|
50
|
+
function shortLine(value) {
|
|
51
|
+
const text = asString(value)?.replace(/\s+/g, ' ').trim();
|
|
52
|
+
return text ? truncate(text, MAX_LINE_LENGTH) : undefined;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The public part of one stored proposal, or undefined for a shape this
|
|
56
|
+
* version does not know. Who proposed or approved it is left out.
|
|
57
|
+
*/
|
|
58
|
+
export function toSetupChange(value) {
|
|
59
|
+
if (!isPlainObject(value))
|
|
60
|
+
return undefined;
|
|
61
|
+
const id = asString(value.id);
|
|
62
|
+
const kind = asString(value.kind);
|
|
63
|
+
if (!id || !SETUP_CHANGE_KINDS.includes(kind ?? ''))
|
|
64
|
+
return undefined;
|
|
65
|
+
const rawStatus = asString(value.status);
|
|
66
|
+
// A card stored before outcomes were recorded has no status: it is pending.
|
|
67
|
+
const status = rawStatus === undefined
|
|
68
|
+
? 'pending'
|
|
69
|
+
: SETUP_CHANGE_STATUSES.includes(rawStatus) ? rawStatus : undefined;
|
|
70
|
+
if (!status)
|
|
71
|
+
return undefined;
|
|
72
|
+
const instructions = asString(value.instructions);
|
|
73
|
+
const fields = {
|
|
74
|
+
action: shortLine(value.action),
|
|
75
|
+
connector: shortLine(value.connector),
|
|
76
|
+
key: shortLine(value.key),
|
|
77
|
+
title: shortLine(value.title),
|
|
78
|
+
cron: shortLine(value.cron),
|
|
79
|
+
instructions: instructions?.trim() ? truncate(instructions, MAX_INSTRUCTIONS_LENGTH) : undefined,
|
|
80
|
+
timezone: shortLine(value.timezone),
|
|
81
|
+
note: shortLine(value.note),
|
|
82
|
+
proposedAt: unixToIso(value.createdat),
|
|
83
|
+
actedAt: unixToIso(value.actedat),
|
|
84
|
+
error: status === 'failed' ? shortLine(value.error) : undefined,
|
|
85
|
+
};
|
|
86
|
+
return {
|
|
87
|
+
id,
|
|
88
|
+
kind: kind,
|
|
89
|
+
status,
|
|
90
|
+
...Object.fromEntries(Object.entries(fields).filter(([, field]) => field !== undefined)),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** The proposals in a list of timeline blocks that are already in order, each once. */
|
|
94
|
+
export function setupChangesFromBlocks(blocks) {
|
|
95
|
+
const changes = [];
|
|
96
|
+
for (const block of blocks) {
|
|
97
|
+
if (block.type !== 'setup')
|
|
98
|
+
continue;
|
|
99
|
+
const change = toSetupChange(block.setup);
|
|
100
|
+
// A live block and its stored copy can both be listed; the later one is the newer state.
|
|
101
|
+
const index = change ? changes.findIndex(item => item.id === change.id) : -1;
|
|
102
|
+
if (change && index >= 0)
|
|
103
|
+
changes[index] = change;
|
|
104
|
+
else if (change && changes.length < MAX_SETUP_CHANGES)
|
|
105
|
+
changes.push(change);
|
|
106
|
+
}
|
|
107
|
+
return changes;
|
|
108
|
+
}
|
|
109
|
+
/** Send's own report of a reply Wiro handled as an answer to a setup proposal. */
|
|
110
|
+
export function toSetupResult(value) {
|
|
111
|
+
if (!isPlainObject(value))
|
|
112
|
+
return undefined;
|
|
113
|
+
const ids = (list) => (Array.isArray(list)
|
|
114
|
+
? list.map(item => asString(item)).filter((item) => Boolean(item))
|
|
115
|
+
: []);
|
|
116
|
+
const failed = Array.isArray(value.failed)
|
|
117
|
+
? value.failed.filter(isPlainObject).flatMap((item) => {
|
|
118
|
+
const id = asString(item.id);
|
|
119
|
+
const error = shortLine(item.error);
|
|
120
|
+
return id ? [{ id, ...(error ? { error } : {}) }] : [];
|
|
121
|
+
})
|
|
122
|
+
: [];
|
|
123
|
+
return {
|
|
124
|
+
applied: ids(value.applied),
|
|
125
|
+
dismissed: ids(value.dismissed),
|
|
126
|
+
failed,
|
|
127
|
+
restarting: value.restarting === true,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/** Whether Wiro's answer applied, turned down or failed anything, or restarts the agent. */
|
|
131
|
+
export function setupResultActed(result) {
|
|
132
|
+
return result.applied.length > 0 || result.dismissed.length > 0 || result.failed.length > 0 || result.restarting;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* How many proposals Wiro's answer lists, read from the stored answer. A
|
|
136
|
+
* typed approval sent with an API key, or one that could mean several
|
|
137
|
+
* proposals, applies nothing at first: Wiro answers with the exact changes
|
|
138
|
+
* instead, and only a later "yes" (or "yes N") applies one of them. 0 for any
|
|
139
|
+
* other row.
|
|
140
|
+
*/
|
|
141
|
+
export function listedSetupCount(row) {
|
|
142
|
+
const metadata = isPlainObject(row.metadata) ? row.metadata : undefined;
|
|
143
|
+
if (asString(metadata?.type) !== 'setup_result' || !Array.isArray(metadata?.listed))
|
|
144
|
+
return 0;
|
|
145
|
+
return Math.min(metadata.listed.filter(id => asString(id)).length, MAX_SETUP_CHANGES);
|
|
146
|
+
}
|
|
147
|
+
/** What to do with Wiro's listing, said the same way by the note and the Next line. */
|
|
148
|
+
export const SETUP_LISTING_RULE = 'Show the listing to the user, and send "yes" (or "yes N" for change N) again '
|
|
149
|
+
+ 'only after the user agrees to exactly that change. Never send yes on your own.';
|
|
150
|
+
/** Whether a pending proposal can still be approved with a typed reply. */
|
|
151
|
+
export function isApprovableByReply(change, nowMs = Date.now()) {
|
|
152
|
+
if (change.status !== 'pending')
|
|
153
|
+
return false;
|
|
154
|
+
const proposed = change.proposedAt ? Date.parse(change.proposedAt) : NaN;
|
|
155
|
+
// Without a time the server decides; it refuses a proposal that is too old.
|
|
156
|
+
return Number.isNaN(proposed) || nowMs - proposed < SETUP_REPLY_WINDOW_SECONDS * 1000;
|
|
157
|
+
}
|
|
158
|
+
const SCHEDULE_VERBS = {
|
|
159
|
+
create: 'Create the scheduled task',
|
|
160
|
+
update: 'Change the scheduled task',
|
|
161
|
+
pause: 'Pause the scheduled task',
|
|
162
|
+
resume: 'Resume the scheduled task',
|
|
163
|
+
delete: 'Delete the scheduled task',
|
|
164
|
+
};
|
|
165
|
+
const SKILL_VERBS = {
|
|
166
|
+
create: 'Add the custom skill',
|
|
167
|
+
update: 'Change the custom skill',
|
|
168
|
+
disable: 'Turn off the custom skill',
|
|
169
|
+
enable: 'Turn on the custom skill',
|
|
170
|
+
};
|
|
171
|
+
/** One line that names the change, such as "Create the scheduled task `cs-cron-weekly-report`". */
|
|
172
|
+
export function setupChangeHeadline(change) {
|
|
173
|
+
switch (change.kind) {
|
|
174
|
+
case 'connect':
|
|
175
|
+
return `Connect ${quotedSpan(change.connector ?? '')}`;
|
|
176
|
+
case 'schedule':
|
|
177
|
+
return `${SCHEDULE_VERBS[change.action ?? ''] ?? 'Change the scheduled task'} ${quotedSpan(change.key ?? '')}`;
|
|
178
|
+
case 'skill':
|
|
179
|
+
return `${SKILL_VERBS[change.action ?? ''] ?? 'Change the custom skill'} ${quotedSpan(change.key ?? '')}`;
|
|
180
|
+
default:
|
|
181
|
+
return `Set the agent's time zone to ${quotedSpan(change.timezone ?? '')}`;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function pendingChangeLines(change, index, nowMs) {
|
|
185
|
+
const lines = [`#### Proposed change ${index + 1}: ${setupChangeHeadline(change)}`, ''];
|
|
186
|
+
if (change.title)
|
|
187
|
+
lines.push(`- Title: ${quotedSpan(change.title)}`);
|
|
188
|
+
if (change.cron) {
|
|
189
|
+
lines.push(`- Schedule: ${quotedSpan(change.cron)} (cron: minute, hour, day of month, month, weekday; in the `
|
|
190
|
+
+ 'agent\'s time zone)');
|
|
191
|
+
}
|
|
192
|
+
if (change.kind === 'connect') {
|
|
193
|
+
lines.push('- The user provides the key or sign-in for it. A key is saved with set_agent_credentials, never sent '
|
|
194
|
+
+ 'in a chat message.');
|
|
195
|
+
}
|
|
196
|
+
if (change.note)
|
|
197
|
+
lines.push(`- Note from the agent: ${quotedSpan(change.note)}`);
|
|
198
|
+
if (change.proposedAt)
|
|
199
|
+
lines.push(`- Proposed at: ${change.proposedAt}`);
|
|
200
|
+
if (!isApprovableByReply(change, nowMs)) {
|
|
201
|
+
lines.push(`- Older than ${SETUP_REPLY_WINDOW_SECONDS / 60} minutes, so a reply can no longer approve it. The user `
|
|
202
|
+
+ 'can still apply it in the agent\'s chat on wiro.ai, or ask the agent again.');
|
|
203
|
+
}
|
|
204
|
+
if (change.instructions)
|
|
205
|
+
lines.push('', ...quotedBlock(SETUP_INSTRUCTIONS_LABEL, change.instructions));
|
|
206
|
+
return lines;
|
|
207
|
+
}
|
|
208
|
+
function settledChangeLine(change) {
|
|
209
|
+
const when = change.actedAt ? ` (${change.actedAt})` : '';
|
|
210
|
+
switch (change.status) {
|
|
211
|
+
case 'applied':
|
|
212
|
+
return `- Applied: ${setupChangeHeadline(change)}${when}`;
|
|
213
|
+
case 'dismissed':
|
|
214
|
+
return `- Dismissed: ${setupChangeHeadline(change)}${when}`;
|
|
215
|
+
default:
|
|
216
|
+
return `- Not applied: ${setupChangeHeadline(change)}${when}${change.error ? `. Reason: ${quotedSpan(change.error)}` : ''}`;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/** The text for a reply's proposals: each pending one in full, each settled one as one status line. */
|
|
220
|
+
export function formatSetupChanges(changes, nowMs = Date.now()) {
|
|
221
|
+
if (changes.length === 0)
|
|
222
|
+
return [];
|
|
223
|
+
const lines = ['', '### Setup changes proposed in this reply', ''];
|
|
224
|
+
const settled = changes.filter(change => change.status !== 'pending');
|
|
225
|
+
changes.filter(change => change.status === 'pending').forEach((change, index) => {
|
|
226
|
+
if (index > 0)
|
|
227
|
+
lines.push('');
|
|
228
|
+
lines.push(...pendingChangeLines(change, index, nowMs));
|
|
229
|
+
});
|
|
230
|
+
if (settled.length > 0) {
|
|
231
|
+
if (settled.length < changes.length)
|
|
232
|
+
lines.push('');
|
|
233
|
+
lines.push(...settled.map(settledChangeLine));
|
|
234
|
+
}
|
|
235
|
+
return lines;
|
|
236
|
+
}
|
|
237
|
+
/** One line per proposal, for a conversation listing. */
|
|
238
|
+
export function setupChangeSummaryLines(changes) {
|
|
239
|
+
return changes.map(change => (change.status === 'pending'
|
|
240
|
+
? `- Proposed setup change (pending): ${setupChangeHeadline(change)}. get_agent_message with this message id shows it in full.`
|
|
241
|
+
: settledChangeLine(change)));
|
|
242
|
+
}
|
|
243
|
+
/** A chat_setup value from an agent row, or undefined when the row does not say. */
|
|
244
|
+
export function readChatSetupMode(value) {
|
|
245
|
+
const mode = asString(value);
|
|
246
|
+
return CHAT_SETUP_MODES.includes(mode ?? '') ? mode : undefined;
|
|
247
|
+
}
|
|
248
|
+
/** How get_my_agent names a chat_setup value. */
|
|
249
|
+
export function chatSetupLabel(mode) {
|
|
250
|
+
switch (mode) {
|
|
251
|
+
case 'off':
|
|
252
|
+
return 'off';
|
|
253
|
+
case 'webchat':
|
|
254
|
+
return 'Wiro web chat only (`webchat`)';
|
|
255
|
+
default:
|
|
256
|
+
return 'Wiro web chat and API messages (`all`)';
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=agent-setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-setup.js","sourceRoot":"","sources":["../../src/utils/agent-setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAErF,+EAA+E;AAC/E,+EAA+E;AAC/E,8EAA8E;AAC9E,8EAA8E;AAC9E,+EAA+E;AAC/E,+EAA+E;AAC/E,4EAA4E;AAC5E,6EAA6E;AAC7E,4DAA4D;AAE5D,gFAAgF;AAChF,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,GAAG,EAAE,CAAC;AAClD,2CAA2C;AAC3C,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,uBAAuB,GAAG,MAAM,CAAC;AACvC,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,CAAU,CAAC;AACxF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAU,CAAC;AAE5F,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAU,CAAC;AAGnE,gGAAgG;AAChG,MAAM,CAAC,MAAM,sBAAsB,GAAG,iFAAiF;MACnH,4GAA4G;MAC5G,8GAA8G;MAC9G,0GAA0G;MAC1G,oGAAoG,CAAC;AAEzG,MAAM,CAAC,MAAM,iBAAiB,GA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BAAkB,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IACH,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,IAAI,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM;YAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpD,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,uBAAuB,CAAC,OAA+B;IACrE,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,KAAK,SAAS;QACvD,CAAC,CAAC,sCAAsC,mBAAmB,CAAC,MAAM,CAAC,4DAA4D;QAC/H,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAClC,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAQ,gBAAsC,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAqB,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1G,CAAC;AAED,iDAAiD;AACjD,MAAM,UAAU,cAAc,CAAC,IAAmB;IAChD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,KAAK;YACR,OAAO,KAAK,CAAC;QACf,KAAK,SAAS;YACZ,OAAO,gCAAgC,CAAC;QAC1C;YACE,OAAO,wCAAwC,CAAC;IACpD,CAAC;AACH,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { type WiroClient } from '../client.js';
|
|
|
3
3
|
import type { NextAction } from './structured.js';
|
|
4
4
|
import { type AgentMessage } from './agent-message.js';
|
|
5
5
|
import { type AgentTarget } from './agent-targets.js';
|
|
6
|
+
import { type SetupResult } from './agent-setup.js';
|
|
6
7
|
import { type MediaItem } from './media.js';
|
|
7
8
|
import { type ToolCallContext } from './poll.js';
|
|
8
9
|
import { type StudioRun } from './studio-runs.js';
|
|
@@ -28,6 +29,7 @@ export declare const agentTurnOutputSchema: {
|
|
|
28
29
|
}>;
|
|
29
30
|
status: z.ZodString;
|
|
30
31
|
kind: z.ZodOptional<z.ZodEnum<{
|
|
32
|
+
setup_result: "setup_result";
|
|
31
33
|
user_turn: "user_turn";
|
|
32
34
|
agent_message: "agent_message";
|
|
33
35
|
model_change: "model_change";
|
|
@@ -41,6 +43,33 @@ export declare const agentTurnOutputSchema: {
|
|
|
41
43
|
name: z.ZodString;
|
|
42
44
|
status: z.ZodOptional<z.ZodString>;
|
|
43
45
|
}, z.core.$strip>>;
|
|
46
|
+
setupChanges: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
47
|
+
id: z.ZodString;
|
|
48
|
+
kind: z.ZodEnum<{
|
|
49
|
+
connect: "connect";
|
|
50
|
+
schedule: "schedule";
|
|
51
|
+
skill: "skill";
|
|
52
|
+
timezone: "timezone";
|
|
53
|
+
}>;
|
|
54
|
+
action: z.ZodOptional<z.ZodString>;
|
|
55
|
+
connector: z.ZodOptional<z.ZodString>;
|
|
56
|
+
key: z.ZodOptional<z.ZodString>;
|
|
57
|
+
title: z.ZodOptional<z.ZodString>;
|
|
58
|
+
cron: z.ZodOptional<z.ZodString>;
|
|
59
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
60
|
+
timezone: z.ZodOptional<z.ZodString>;
|
|
61
|
+
note: z.ZodOptional<z.ZodString>;
|
|
62
|
+
status: z.ZodEnum<{
|
|
63
|
+
failed: "failed";
|
|
64
|
+
pending: "pending";
|
|
65
|
+
applied: "applied";
|
|
66
|
+
dismissed: "dismissed";
|
|
67
|
+
}>;
|
|
68
|
+
proposedAt: z.ZodOptional<z.ZodString>;
|
|
69
|
+
actedAt: z.ZodOptional<z.ZodString>;
|
|
70
|
+
error: z.ZodOptional<z.ZodString>;
|
|
71
|
+
}, z.core.$strip>>>;
|
|
72
|
+
listedSetupChanges: z.ZodOptional<z.ZodNumber>;
|
|
44
73
|
attachments: z.ZodArray<z.ZodObject<{
|
|
45
74
|
url: z.ZodString;
|
|
46
75
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -119,6 +148,15 @@ export declare const agentTurnOutputSchema: {
|
|
|
119
148
|
instruction: z.ZodString;
|
|
120
149
|
error: z.ZodOptional<z.ZodString>;
|
|
121
150
|
}, z.core.$strip>>;
|
|
151
|
+
setupResult: z.ZodOptional<z.ZodObject<{
|
|
152
|
+
applied: z.ZodArray<z.ZodString>;
|
|
153
|
+
dismissed: z.ZodArray<z.ZodString>;
|
|
154
|
+
failed: z.ZodArray<z.ZodObject<{
|
|
155
|
+
id: z.ZodString;
|
|
156
|
+
error: z.ZodOptional<z.ZodString>;
|
|
157
|
+
}, z.core.$strip>>;
|
|
158
|
+
restarting: z.ZodBoolean;
|
|
159
|
+
}, z.core.$strip>>;
|
|
122
160
|
notes: z.ZodArray<z.ZodString>;
|
|
123
161
|
nextAction: z.ZodOptional<z.ZodObject<{
|
|
124
162
|
tool: z.ZodString;
|
|
@@ -146,6 +184,7 @@ export interface AgentTurnResult {
|
|
|
146
184
|
attachedWorkflow?: AttachedWorkflow;
|
|
147
185
|
workflows?: WorkflowArtifactSummary[];
|
|
148
186
|
workflowList?: WorkflowListResult;
|
|
187
|
+
setupResult?: SetupResult;
|
|
149
188
|
notes: string[];
|
|
150
189
|
nextAction?: NextAction;
|
|
151
190
|
}
|
|
@@ -172,6 +211,12 @@ export interface CollectTurnOptions {
|
|
|
172
211
|
toModel?: string;
|
|
173
212
|
};
|
|
174
213
|
attachedWorkflow?: AttachedWorkflow;
|
|
214
|
+
/**
|
|
215
|
+
* Set by send when Wiro answered the message itself (a reply to a setup
|
|
216
|
+
* proposal): the finished row built from Send's answer, so nothing is read.
|
|
217
|
+
*/
|
|
218
|
+
handledRow?: Record<string, unknown>;
|
|
219
|
+
setupResult?: SetupResult;
|
|
175
220
|
}
|
|
176
221
|
export declare function notFoundMessage(target: AgentTarget): string;
|
|
177
222
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-turns.d.ts","sourceRoot":"","sources":["../../src/utils/agent-turns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AASlD,OAAO,EAWL,KAAK,YAAY,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAML,KAAK,WAAW,EACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAsD,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAChG,OAAO,
|
|
1
|
+
{"version":3,"file":"agent-turns.d.ts","sourceRoot":"","sources":["../../src/utils/agent-turns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AASlD,OAAO,EAWL,KAAK,YAAY,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAML,KAAK,WAAW,EACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAOL,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAsD,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAChG,OAAO,EAAoE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAGnH,OAAO,EAKL,KAAK,SAAS,EAEf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGL,sBAAsB,E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AM,EAAE,OAAO,CAAC,EAC5B,eAAe,EAAE,OAAO,GACvB,gBAAgB,CAyBlB;AAkOD,wBAAsB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC,CAgNvF;AAoJD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,EAAE,CAYnE;AAED,2EAA2E;AAC3E,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,4CAEvE;AAuBD,wBAAgB,UAAU,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,GAAG,MAAM,CA2D/E"}
|
|
@@ -4,8 +4,9 @@ import { nextActionSchema } from '../tools/schemas.js';
|
|
|
4
4
|
import { ApiResultError, asString, isPlainObject, toNumber, truncate, unixToIso, } from './api.js';
|
|
5
5
|
import { agentMessageSchema, extractMediaUrls, extractReply, formatAgentMessage, isEarlyNotFound, isTerminalMessageStatus, isVoiceCallRow, messageKind, messageState, toAgentMessage, } from './agent-message.js';
|
|
6
6
|
import { BARE_UNAVAILABLE_PATTERN, agentRequestBody, callAgent, isBackgroundHandOff, readAgentMessage, } from './agent-targets.js';
|
|
7
|
+
import { SETUP_LISTING_RULE, SETUP_REPLY_WINDOW_SECONDS, formatSetupChanges, isApprovableByReply, setupResultActed, setupResultSchema, } from './agent-setup.js';
|
|
7
8
|
import { createMediaContent, guessMimeType, isWiroHostedUrl } from './media.js';
|
|
8
|
-
import { defaultInterval, pollUntil, reportProgress } from './poll.js';
|
|
9
|
+
import { DEFAULT_WAIT_SECONDS, defaultInterval, pollUntil, reportProgress } from './poll.js';
|
|
9
10
|
import { AGENT_REPLY_LABEL, jsonSpan, quotedBlock, quotedSpan, quotedSubItem } from './quoted-text.js';
|
|
10
11
|
import { formatCredits, readAgentDetail } from './user-agent.js';
|
|
11
12
|
import { STUDIO_RUNS_MAX, formatStudioRun, readStudioRunPage, studioRunSchema, } from './studio-runs.js';
|
|
@@ -65,6 +66,9 @@ export const agentTurnOutputSchema = {
|
|
|
65
66
|
attachedWorkflow: attachedWorkflowSchema.optional(),
|
|
66
67
|
workflows: z.array(workflowArtifactSummarySchema).optional(),
|
|
67
68
|
workflowList: workflowListResultSchema.optional(),
|
|
69
|
+
setupResult: setupResultSchema.optional()
|
|
70
|
+
.describe('Set when Wiro handled this message itself as the user\'s answer to a setup change the agent proposed: '
|
|
71
|
+
+ 'the ids of the proposals it applied, dismissed or could not apply, and whether the agent restarts.'),
|
|
68
72
|
notes: z.array(z.string()),
|
|
69
73
|
nextAction: nextActionSchema.optional(),
|
|
70
74
|
};
|
|
@@ -371,7 +375,11 @@ export async function collectTurn(options) {
|
|
|
371
375
|
let done = false;
|
|
372
376
|
let readFailure = options.readFailure;
|
|
373
377
|
let invisible = false;
|
|
374
|
-
if (
|
|
378
|
+
if (options.handledRow) {
|
|
379
|
+
row = options.handledRow;
|
|
380
|
+
done = true;
|
|
381
|
+
}
|
|
382
|
+
else if (!options.skipRead && readFailure === undefined) {
|
|
375
383
|
let lastError;
|
|
376
384
|
try {
|
|
377
385
|
const poll = await pollUntil({
|
|
@@ -438,6 +446,7 @@ export async function collectTurn(options) {
|
|
|
438
446
|
notes,
|
|
439
447
|
...(options.modelChange ? { modelChange: options.modelChange } : {}),
|
|
440
448
|
...(options.attachedWorkflow ? { attachedWorkflow: options.attachedWorkflow } : {}),
|
|
449
|
+
...(options.setupResult ? { setupResult: options.setupResult } : {}),
|
|
441
450
|
};
|
|
442
451
|
const continueArguments = {
|
|
443
452
|
agent: target.agent,
|
|
@@ -482,6 +491,23 @@ export async function collectTurn(options) {
|
|
|
482
491
|
const voiceCall = result.message.kind === 'voice_call';
|
|
483
492
|
if (voiceCall)
|
|
484
493
|
notes.push('This is a voice call record. Caller details and transcripts are not returned.');
|
|
494
|
+
if (result.message.kind === 'setup_result') {
|
|
495
|
+
notes.push('Wiro answered this message itself as the user\'s answer to a setup change the agent proposed, so the '
|
|
496
|
+
+ 'agent took no turn and no credits were used.');
|
|
497
|
+
if (result.message.listedSetupChanges) {
|
|
498
|
+
notes.push('Nothing is applied yet. A "yes" sent with an API key, such as from this server, first gets Wiro\'s '
|
|
499
|
+
+ `own listing of the exact change, written from the stored proposal. ${SETUP_LISTING_RULE}`);
|
|
500
|
+
}
|
|
501
|
+
else if (result.setupResult && !setupResultActed(result.setupResult)) {
|
|
502
|
+
// Send's answer alone does not say whether it is a listing; the stored row does, when it can be read.
|
|
503
|
+
notes.push('Nothing was applied. If Wiro\'s answer lists a setup change, show it to the user, and send "yes" '
|
|
504
|
+
+ '(or "yes N" for change N) again only after the user agrees to exactly that change. Never send yes on '
|
|
505
|
+
+ 'your own.');
|
|
506
|
+
}
|
|
507
|
+
if (result.setupResult?.restarting) {
|
|
508
|
+
notes.push('The agent restarts to load the change. Send the next message once it is running again, in about a minute.');
|
|
509
|
+
}
|
|
510
|
+
}
|
|
485
511
|
if (target.kind !== 'deployed') {
|
|
486
512
|
const credits = toNumber(row.tokencost);
|
|
487
513
|
result.llmCostUsd = credits === null ? null : Math.round(credits * 100) / 10_000;
|
|
@@ -612,6 +638,9 @@ function chooseNextAction(target, result, continueArguments, state, afterSend) {
|
|
|
612
638
|
+ 'message again.',
|
|
613
639
|
};
|
|
614
640
|
}
|
|
641
|
+
const setup = setupNextAction(target, result);
|
|
642
|
+
if (setup)
|
|
643
|
+
return setup;
|
|
615
644
|
if (result.background) {
|
|
616
645
|
if (target.kind === 'studio') {
|
|
617
646
|
if (!state.awaitingBackgroundRuns)
|
|
@@ -633,6 +662,69 @@ function chooseNextAction(target, result, continueArguments, state, afterSend) {
|
|
|
633
662
|
}
|
|
634
663
|
return undefined;
|
|
635
664
|
}
|
|
665
|
+
/**
|
|
666
|
+
* The step after a deployed agent's reply that proposes setup changes, after
|
|
667
|
+
* Wiro listed them, or after Wiro applied one. A change is applied only when the
|
|
668
|
+
* user approves it: their "yes" as the next message, which Wiro matches itself,
|
|
669
|
+
* or a key saved with set_agent_credentials. Sent with an API key, the first
|
|
670
|
+
* "yes" only gets Wiro's listing of the exact change; the next "yes" (or
|
|
671
|
+
* "yes N") applies it. A key never goes in a chat message.
|
|
672
|
+
*/
|
|
673
|
+
function setupNextAction(target, result) {
|
|
674
|
+
const guid = target.agentGuid;
|
|
675
|
+
if (target.kind !== 'deployed' || !guid || result.message.state !== 'completed')
|
|
676
|
+
return undefined;
|
|
677
|
+
if (result.setupResult?.restarting) {
|
|
678
|
+
return {
|
|
679
|
+
tool: 'get_my_agent',
|
|
680
|
+
arguments: { agent_guid: guid, wait_seconds: DEFAULT_WAIT_SECONDS },
|
|
681
|
+
reason: 'The agent restarts to load the change. Wait until it is running again before the next message.',
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
const listed = result.message.listedSetupChanges ?? 0;
|
|
685
|
+
if (listed > 0) {
|
|
686
|
+
// The proposals behind a listing expire with the window, counted from before the listing.
|
|
687
|
+
const listedAt = result.message.createdAt ? Date.parse(result.message.createdAt) : NaN;
|
|
688
|
+
if (!Number.isNaN(listedAt) && Date.now() - listedAt >= SETUP_REPLY_WINDOW_SECONDS * 1000)
|
|
689
|
+
return undefined;
|
|
690
|
+
const several = listed > 1
|
|
691
|
+
? ' One change per message: "yes" and its number from the listing. Replace the 1 with the number of the change '
|
|
692
|
+
+ 'the user agreed to.'
|
|
693
|
+
: '';
|
|
694
|
+
return {
|
|
695
|
+
tool: 'send_agent_message',
|
|
696
|
+
arguments: { agent: target.agent, session: result.session, message: listed === 1 ? 'yes' : 'yes 1' },
|
|
697
|
+
reason: `Wiro listed the exact setup change${listed === 1 ? '' : 's'} the agent proposed; nothing is applied `
|
|
698
|
+
+ `yet. ${SETUP_LISTING_RULE}${several}`,
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
const open = (result.message.setupChanges ?? []).filter(change => isApprovableByReply(change));
|
|
702
|
+
if (open.length === 0)
|
|
703
|
+
return undefined;
|
|
704
|
+
const key = open.some(change => change.kind === 'connect')
|
|
705
|
+
? ' For a key, use set_agent_credentials instead of a chat message.'
|
|
706
|
+
: '';
|
|
707
|
+
if (open.some(change => change.kind !== 'connect')) {
|
|
708
|
+
return {
|
|
709
|
+
tool: 'send_agent_message',
|
|
710
|
+
arguments: { agent: target.agent, session: result.session, message: 'yes' },
|
|
711
|
+
reason: 'The agent proposes a setup change. Show it to the user and ask; never send yes on your own. If they '
|
|
712
|
+
+ 'approve, send their reply (yes) with send_agent_message: Wiro answers it, not the agent. Sent with an API '
|
|
713
|
+
+ 'key, the first yes applies nothing and gets Wiro\'s own listing of the exact change; show that listing and '
|
|
714
|
+
+ 'send yes (or "yes N") again only after the user agrees to exactly that change.'
|
|
715
|
+
+ `${key} A reply approves only the changes on the latest reply of this session, for `
|
|
716
|
+
+ `${SETUP_REPLY_WINDOW_SECONDS / 60} minutes, and only when the agent's chat_setup `
|
|
717
|
+
+ 'is "all"; otherwise the user applies them in the agent\'s chat on wiro.ai.',
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
const connector = open.find(change => change.kind === 'connect')?.connector;
|
|
721
|
+
return {
|
|
722
|
+
tool: 'set_agent_credentials',
|
|
723
|
+
arguments: { agent_guid: guid, ...(connector ? { credential: connector } : {}) },
|
|
724
|
+
reason: 'The agent asks for a key or sign-in. This call only lists the connector\'s fields: ask the user for the '
|
|
725
|
+
+ 'value and save it with set_agent_credentials, never in a chat message.',
|
|
726
|
+
};
|
|
727
|
+
}
|
|
636
728
|
// ─── Text ───────────────────────────────────────────────────────────
|
|
637
729
|
/**
|
|
638
730
|
* Files to present once the turn is over: every model run output, and the
|
|
@@ -663,6 +755,13 @@ function heading(target, result) {
|
|
|
663
755
|
return '## Message not visible yet';
|
|
664
756
|
if (!result.done)
|
|
665
757
|
return `## ${target.name} is still working`;
|
|
758
|
+
if (result.message.listedSetupChanges) {
|
|
759
|
+
return result.message.listedSetupChanges === 1
|
|
760
|
+
? '## Wiro listed the proposed setup change'
|
|
761
|
+
: '## Wiro listed the proposed setup changes';
|
|
762
|
+
}
|
|
763
|
+
if (result.message.kind === 'setup_result')
|
|
764
|
+
return '## Wiro answered the setup reply';
|
|
666
765
|
switch (result.message.state) {
|
|
667
766
|
case 'completed':
|
|
668
767
|
return `## ${target.name} replied`;
|
|
@@ -695,6 +794,8 @@ export function formatTurn(target, result) {
|
|
|
695
794
|
if (result.partialReply) {
|
|
696
795
|
lines.push('', '### Partial reply', '', ...quotedBlock(AGENT_REPLY_LABEL, result.partialReply));
|
|
697
796
|
}
|
|
797
|
+
if (result.message.setupChanges)
|
|
798
|
+
lines.push(...formatSetupChanges(result.message.setupChanges));
|
|
698
799
|
if (result.modelRuns && result.modelRuns.length > 0) {
|
|
699
800
|
lines.push('', '### Model runs started by this turn', '');
|
|
700
801
|
for (const run of result.modelRuns)
|