verdo-mcp 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/definitions.d.ts +424 -0
- package/dist/definitions.js +288 -0
- package/dist/index.js +1 -1
- package/dist/tools.d.ts +10 -112
- package/dist/tools.js +56 -184
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,7 +36,9 @@ link with the team and makes the call there.
|
|
|
36
36
|
| `create_decision` | Propose a decision with a title, options, method and deadline. Nobody is invited or notified; the deadline starts counting at creation |
|
|
37
37
|
| `check_decision` | Check the status, the vote count per option, the owner and the outcome |
|
|
38
38
|
| `list_decisions` | List or search decisions in the workspace |
|
|
39
|
-
| `
|
|
39
|
+
| `get_close_summary` | Read-only: returns who makes the call, the dashboard link and the tally, so the agent can ask that person to decide |
|
|
40
|
+
| `search_decisions` | Read-only: past decided decisions whose title matches, newest first. Records, not consent |
|
|
41
|
+
| `get_precedent` | Read-only: one past decision's record (outcome, owner, votes per option, rationale if approved for sharing). A historical record, not consent or authorization to repeat it |
|
|
40
42
|
|
|
41
43
|
Removed in 1.1.0: `close_decision` and `add_participants`, and the
|
|
42
44
|
`participants` input on `create_decision`.
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
export declare const METHODS: readonly ["single_choice", "ranked_choice", "approval", "dot"];
|
|
2
|
+
export declare const AUTHORITY_MODES: readonly ["majority", "consensus"];
|
|
3
|
+
export declare const DEFAULT_DEADLINE_HOURS = 48;
|
|
4
|
+
export declare const MAX_DEADLINE_HOURS = 720;
|
|
5
|
+
export declare const MAX_TITLE_LENGTH = 140;
|
|
6
|
+
export declare const MIN_OPTIONS = 2;
|
|
7
|
+
export declare const MAX_OPTIONS = 10;
|
|
8
|
+
export declare const REMOVED_TOOLS: Record<string, string>;
|
|
9
|
+
export interface ProposedArgs {
|
|
10
|
+
title: string;
|
|
11
|
+
options: string[];
|
|
12
|
+
method?: string;
|
|
13
|
+
deadline_hours?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare function proposedText(id: string, url: string, args: ProposedArgs): string;
|
|
16
|
+
export declare function formatDecision(d: Record<string, unknown>): string;
|
|
17
|
+
export declare function listText(decisions: Record<string, unknown>[], query?: string): string;
|
|
18
|
+
export declare const PRECEDENT_NOTE = "Past records for reference. Not consent or authorization.";
|
|
19
|
+
export declare const SEARCH_LIMIT_DEFAULT = 10;
|
|
20
|
+
export declare const SEARCH_LIMIT_MAX = 50;
|
|
21
|
+
/** One past decided decision, as lib/precedent.ts returns it. */
|
|
22
|
+
export interface PrecedentItem {
|
|
23
|
+
id: string;
|
|
24
|
+
title: string;
|
|
25
|
+
status: string;
|
|
26
|
+
winner: string | null;
|
|
27
|
+
created_at?: string;
|
|
28
|
+
settled_at: string | null;
|
|
29
|
+
owner_name: string | null;
|
|
30
|
+
rationale?: string | null;
|
|
31
|
+
authority_mode?: string | null;
|
|
32
|
+
execution_authorized: false;
|
|
33
|
+
}
|
|
34
|
+
/** The section create_decision appends when there are past decisions with a similar title. */
|
|
35
|
+
export declare function precedentSection(items: readonly PrecedentItem[]): string;
|
|
36
|
+
export declare function searchText(items: readonly PrecedentItem[], query: string): string;
|
|
37
|
+
export interface PrecedentDetail extends PrecedentItem {
|
|
38
|
+
vote_counts: {
|
|
39
|
+
option: string;
|
|
40
|
+
votes: number;
|
|
41
|
+
}[];
|
|
42
|
+
related: {
|
|
43
|
+
id: string;
|
|
44
|
+
title: string;
|
|
45
|
+
status: string;
|
|
46
|
+
settled_at: string | null;
|
|
47
|
+
}[];
|
|
48
|
+
}
|
|
49
|
+
export declare function precedentText(d: PrecedentDetail): string;
|
|
50
|
+
export declare function closeSummaryText(d: Record<string, unknown>): string;
|
|
51
|
+
export declare function unknownToolText(name: string): string;
|
|
52
|
+
export interface ToolDefinitionOptions {
|
|
53
|
+
/** Per-tool `_meta`, e.g. the remote server's OAuth securitySchemes for ChatGPT. */
|
|
54
|
+
meta?: Record<string, unknown>;
|
|
55
|
+
}
|
|
56
|
+
export declare function toolDefinitions(opts?: ToolDefinitionOptions): ({
|
|
57
|
+
_meta: Record<string, unknown>;
|
|
58
|
+
name: string;
|
|
59
|
+
description: string;
|
|
60
|
+
annotations: {
|
|
61
|
+
title: string;
|
|
62
|
+
readOnlyHint: boolean;
|
|
63
|
+
destructiveHint: boolean;
|
|
64
|
+
idempotentHint: boolean;
|
|
65
|
+
openWorldHint: boolean;
|
|
66
|
+
};
|
|
67
|
+
inputSchema: {
|
|
68
|
+
type: "object";
|
|
69
|
+
required: string[];
|
|
70
|
+
properties: {
|
|
71
|
+
title: {
|
|
72
|
+
type: string;
|
|
73
|
+
maxLength: number;
|
|
74
|
+
description: string;
|
|
75
|
+
};
|
|
76
|
+
options: {
|
|
77
|
+
type: string;
|
|
78
|
+
minItems: number;
|
|
79
|
+
maxItems: number;
|
|
80
|
+
items: {
|
|
81
|
+
type: string;
|
|
82
|
+
};
|
|
83
|
+
description: string;
|
|
84
|
+
};
|
|
85
|
+
method: {
|
|
86
|
+
type: string;
|
|
87
|
+
enum: ("single_choice" | "ranked_choice" | "approval" | "dot")[];
|
|
88
|
+
description: string;
|
|
89
|
+
};
|
|
90
|
+
deadline_hours: {
|
|
91
|
+
type: string;
|
|
92
|
+
minimum: number;
|
|
93
|
+
maximum: number;
|
|
94
|
+
description: string;
|
|
95
|
+
};
|
|
96
|
+
authority_mode: {
|
|
97
|
+
type: string;
|
|
98
|
+
enum: ("majority" | "consensus")[];
|
|
99
|
+
description: string;
|
|
100
|
+
};
|
|
101
|
+
anonymous: {
|
|
102
|
+
type: string;
|
|
103
|
+
description: string;
|
|
104
|
+
};
|
|
105
|
+
id?: undefined;
|
|
106
|
+
query?: undefined;
|
|
107
|
+
limit?: undefined;
|
|
108
|
+
decision_id?: undefined;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
} | {
|
|
112
|
+
_meta?: undefined;
|
|
113
|
+
name: string;
|
|
114
|
+
description: string;
|
|
115
|
+
annotations: {
|
|
116
|
+
title: string;
|
|
117
|
+
readOnlyHint: boolean;
|
|
118
|
+
destructiveHint: boolean;
|
|
119
|
+
idempotentHint: boolean;
|
|
120
|
+
openWorldHint: boolean;
|
|
121
|
+
};
|
|
122
|
+
inputSchema: {
|
|
123
|
+
type: "object";
|
|
124
|
+
required: string[];
|
|
125
|
+
properties: {
|
|
126
|
+
title: {
|
|
127
|
+
type: string;
|
|
128
|
+
maxLength: number;
|
|
129
|
+
description: string;
|
|
130
|
+
};
|
|
131
|
+
options: {
|
|
132
|
+
type: string;
|
|
133
|
+
minItems: number;
|
|
134
|
+
maxItems: number;
|
|
135
|
+
items: {
|
|
136
|
+
type: string;
|
|
137
|
+
};
|
|
138
|
+
description: string;
|
|
139
|
+
};
|
|
140
|
+
method: {
|
|
141
|
+
type: string;
|
|
142
|
+
enum: ("single_choice" | "ranked_choice" | "approval" | "dot")[];
|
|
143
|
+
description: string;
|
|
144
|
+
};
|
|
145
|
+
deadline_hours: {
|
|
146
|
+
type: string;
|
|
147
|
+
minimum: number;
|
|
148
|
+
maximum: number;
|
|
149
|
+
description: string;
|
|
150
|
+
};
|
|
151
|
+
authority_mode: {
|
|
152
|
+
type: string;
|
|
153
|
+
enum: ("majority" | "consensus")[];
|
|
154
|
+
description: string;
|
|
155
|
+
};
|
|
156
|
+
anonymous: {
|
|
157
|
+
type: string;
|
|
158
|
+
description: string;
|
|
159
|
+
};
|
|
160
|
+
id?: undefined;
|
|
161
|
+
query?: undefined;
|
|
162
|
+
limit?: undefined;
|
|
163
|
+
decision_id?: undefined;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
} | {
|
|
167
|
+
_meta: Record<string, unknown>;
|
|
168
|
+
name: string;
|
|
169
|
+
description: string;
|
|
170
|
+
annotations: {
|
|
171
|
+
title: string;
|
|
172
|
+
readOnlyHint: boolean;
|
|
173
|
+
destructiveHint: boolean;
|
|
174
|
+
idempotentHint: boolean;
|
|
175
|
+
openWorldHint: boolean;
|
|
176
|
+
};
|
|
177
|
+
inputSchema: {
|
|
178
|
+
type: "object";
|
|
179
|
+
required: string[];
|
|
180
|
+
properties: {
|
|
181
|
+
id: {
|
|
182
|
+
type: string;
|
|
183
|
+
format: string;
|
|
184
|
+
description: string;
|
|
185
|
+
};
|
|
186
|
+
title?: undefined;
|
|
187
|
+
options?: undefined;
|
|
188
|
+
method?: undefined;
|
|
189
|
+
deadline_hours?: undefined;
|
|
190
|
+
authority_mode?: undefined;
|
|
191
|
+
anonymous?: undefined;
|
|
192
|
+
query?: undefined;
|
|
193
|
+
limit?: undefined;
|
|
194
|
+
decision_id?: undefined;
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
} | {
|
|
198
|
+
_meta?: undefined;
|
|
199
|
+
name: string;
|
|
200
|
+
description: string;
|
|
201
|
+
annotations: {
|
|
202
|
+
title: string;
|
|
203
|
+
readOnlyHint: boolean;
|
|
204
|
+
destructiveHint: boolean;
|
|
205
|
+
idempotentHint: boolean;
|
|
206
|
+
openWorldHint: boolean;
|
|
207
|
+
};
|
|
208
|
+
inputSchema: {
|
|
209
|
+
type: "object";
|
|
210
|
+
required: string[];
|
|
211
|
+
properties: {
|
|
212
|
+
id: {
|
|
213
|
+
type: string;
|
|
214
|
+
format: string;
|
|
215
|
+
description: string;
|
|
216
|
+
};
|
|
217
|
+
title?: undefined;
|
|
218
|
+
options?: undefined;
|
|
219
|
+
method?: undefined;
|
|
220
|
+
deadline_hours?: undefined;
|
|
221
|
+
authority_mode?: undefined;
|
|
222
|
+
anonymous?: undefined;
|
|
223
|
+
query?: undefined;
|
|
224
|
+
limit?: undefined;
|
|
225
|
+
decision_id?: undefined;
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
} | {
|
|
229
|
+
_meta: Record<string, unknown>;
|
|
230
|
+
name: string;
|
|
231
|
+
description: string;
|
|
232
|
+
annotations: {
|
|
233
|
+
title: string;
|
|
234
|
+
readOnlyHint: boolean;
|
|
235
|
+
destructiveHint: boolean;
|
|
236
|
+
idempotentHint: boolean;
|
|
237
|
+
openWorldHint: boolean;
|
|
238
|
+
};
|
|
239
|
+
inputSchema: {
|
|
240
|
+
type: "object";
|
|
241
|
+
properties: {
|
|
242
|
+
query: {
|
|
243
|
+
type: string;
|
|
244
|
+
description: string;
|
|
245
|
+
maxLength?: undefined;
|
|
246
|
+
};
|
|
247
|
+
title?: undefined;
|
|
248
|
+
options?: undefined;
|
|
249
|
+
method?: undefined;
|
|
250
|
+
deadline_hours?: undefined;
|
|
251
|
+
authority_mode?: undefined;
|
|
252
|
+
anonymous?: undefined;
|
|
253
|
+
id?: undefined;
|
|
254
|
+
limit?: undefined;
|
|
255
|
+
decision_id?: undefined;
|
|
256
|
+
};
|
|
257
|
+
required?: undefined;
|
|
258
|
+
};
|
|
259
|
+
} | {
|
|
260
|
+
_meta?: undefined;
|
|
261
|
+
name: string;
|
|
262
|
+
description: string;
|
|
263
|
+
annotations: {
|
|
264
|
+
title: string;
|
|
265
|
+
readOnlyHint: boolean;
|
|
266
|
+
destructiveHint: boolean;
|
|
267
|
+
idempotentHint: boolean;
|
|
268
|
+
openWorldHint: boolean;
|
|
269
|
+
};
|
|
270
|
+
inputSchema: {
|
|
271
|
+
type: "object";
|
|
272
|
+
properties: {
|
|
273
|
+
query: {
|
|
274
|
+
type: string;
|
|
275
|
+
description: string;
|
|
276
|
+
maxLength?: undefined;
|
|
277
|
+
};
|
|
278
|
+
title?: undefined;
|
|
279
|
+
options?: undefined;
|
|
280
|
+
method?: undefined;
|
|
281
|
+
deadline_hours?: undefined;
|
|
282
|
+
authority_mode?: undefined;
|
|
283
|
+
anonymous?: undefined;
|
|
284
|
+
id?: undefined;
|
|
285
|
+
limit?: undefined;
|
|
286
|
+
decision_id?: undefined;
|
|
287
|
+
};
|
|
288
|
+
required?: undefined;
|
|
289
|
+
};
|
|
290
|
+
} | {
|
|
291
|
+
_meta: Record<string, unknown>;
|
|
292
|
+
name: string;
|
|
293
|
+
description: string;
|
|
294
|
+
annotations: {
|
|
295
|
+
title: string;
|
|
296
|
+
readOnlyHint: boolean;
|
|
297
|
+
destructiveHint: boolean;
|
|
298
|
+
idempotentHint: boolean;
|
|
299
|
+
openWorldHint: boolean;
|
|
300
|
+
};
|
|
301
|
+
inputSchema: {
|
|
302
|
+
type: "object";
|
|
303
|
+
required: string[];
|
|
304
|
+
properties: {
|
|
305
|
+
query: {
|
|
306
|
+
type: string;
|
|
307
|
+
maxLength: number;
|
|
308
|
+
description: string;
|
|
309
|
+
};
|
|
310
|
+
limit: {
|
|
311
|
+
type: string;
|
|
312
|
+
minimum: number;
|
|
313
|
+
maximum: number;
|
|
314
|
+
description: string;
|
|
315
|
+
};
|
|
316
|
+
title?: undefined;
|
|
317
|
+
options?: undefined;
|
|
318
|
+
method?: undefined;
|
|
319
|
+
deadline_hours?: undefined;
|
|
320
|
+
authority_mode?: undefined;
|
|
321
|
+
anonymous?: undefined;
|
|
322
|
+
id?: undefined;
|
|
323
|
+
decision_id?: undefined;
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
} | {
|
|
327
|
+
_meta?: undefined;
|
|
328
|
+
name: string;
|
|
329
|
+
description: string;
|
|
330
|
+
annotations: {
|
|
331
|
+
title: string;
|
|
332
|
+
readOnlyHint: boolean;
|
|
333
|
+
destructiveHint: boolean;
|
|
334
|
+
idempotentHint: boolean;
|
|
335
|
+
openWorldHint: boolean;
|
|
336
|
+
};
|
|
337
|
+
inputSchema: {
|
|
338
|
+
type: "object";
|
|
339
|
+
required: string[];
|
|
340
|
+
properties: {
|
|
341
|
+
query: {
|
|
342
|
+
type: string;
|
|
343
|
+
maxLength: number;
|
|
344
|
+
description: string;
|
|
345
|
+
};
|
|
346
|
+
limit: {
|
|
347
|
+
type: string;
|
|
348
|
+
minimum: number;
|
|
349
|
+
maximum: number;
|
|
350
|
+
description: string;
|
|
351
|
+
};
|
|
352
|
+
title?: undefined;
|
|
353
|
+
options?: undefined;
|
|
354
|
+
method?: undefined;
|
|
355
|
+
deadline_hours?: undefined;
|
|
356
|
+
authority_mode?: undefined;
|
|
357
|
+
anonymous?: undefined;
|
|
358
|
+
id?: undefined;
|
|
359
|
+
decision_id?: undefined;
|
|
360
|
+
};
|
|
361
|
+
};
|
|
362
|
+
} | {
|
|
363
|
+
_meta: Record<string, unknown>;
|
|
364
|
+
name: string;
|
|
365
|
+
description: string;
|
|
366
|
+
annotations: {
|
|
367
|
+
title: string;
|
|
368
|
+
readOnlyHint: boolean;
|
|
369
|
+
destructiveHint: boolean;
|
|
370
|
+
idempotentHint: boolean;
|
|
371
|
+
openWorldHint: boolean;
|
|
372
|
+
};
|
|
373
|
+
inputSchema: {
|
|
374
|
+
type: "object";
|
|
375
|
+
required: string[];
|
|
376
|
+
properties: {
|
|
377
|
+
decision_id: {
|
|
378
|
+
type: string;
|
|
379
|
+
format: string;
|
|
380
|
+
description: string;
|
|
381
|
+
};
|
|
382
|
+
title?: undefined;
|
|
383
|
+
options?: undefined;
|
|
384
|
+
method?: undefined;
|
|
385
|
+
deadline_hours?: undefined;
|
|
386
|
+
authority_mode?: undefined;
|
|
387
|
+
anonymous?: undefined;
|
|
388
|
+
id?: undefined;
|
|
389
|
+
query?: undefined;
|
|
390
|
+
limit?: undefined;
|
|
391
|
+
};
|
|
392
|
+
};
|
|
393
|
+
} | {
|
|
394
|
+
_meta?: undefined;
|
|
395
|
+
name: string;
|
|
396
|
+
description: string;
|
|
397
|
+
annotations: {
|
|
398
|
+
title: string;
|
|
399
|
+
readOnlyHint: boolean;
|
|
400
|
+
destructiveHint: boolean;
|
|
401
|
+
idempotentHint: boolean;
|
|
402
|
+
openWorldHint: boolean;
|
|
403
|
+
};
|
|
404
|
+
inputSchema: {
|
|
405
|
+
type: "object";
|
|
406
|
+
required: string[];
|
|
407
|
+
properties: {
|
|
408
|
+
decision_id: {
|
|
409
|
+
type: string;
|
|
410
|
+
format: string;
|
|
411
|
+
description: string;
|
|
412
|
+
};
|
|
413
|
+
title?: undefined;
|
|
414
|
+
options?: undefined;
|
|
415
|
+
method?: undefined;
|
|
416
|
+
deadline_hours?: undefined;
|
|
417
|
+
authority_mode?: undefined;
|
|
418
|
+
anonymous?: undefined;
|
|
419
|
+
id?: undefined;
|
|
420
|
+
query?: undefined;
|
|
421
|
+
limit?: undefined;
|
|
422
|
+
};
|
|
423
|
+
};
|
|
424
|
+
})[];
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
// Verdo MCP tool definitions and the text every tool returns, shared by both transports:
|
|
2
|
+
// the stdio server in this package (src/tools.ts, over the REST API) and the remote
|
|
3
|
+
// server at verdo.ink/api/mcp (in-process). Pure: no fetch, no environment, no imports,
|
|
4
|
+
// so the remote server can import it without pulling in the stdio runtime.
|
|
5
|
+
//
|
|
6
|
+
// Guardrail: the agent proposes, a person decides. No tool invites, notifies, settles,
|
|
7
|
+
// closes or cancels. create_decision is the only write, and it sends no participants;
|
|
8
|
+
// get_close_summary only reads and points the agent at a person.
|
|
9
|
+
// Values the API accepts (DB checks in migrations 0041 and 0042). Owner and approver
|
|
10
|
+
// modes need a named person, which this API cannot set, so they are not offered.
|
|
11
|
+
export const METHODS = ["single_choice", "ranked_choice", "approval", "dot"];
|
|
12
|
+
export const AUTHORITY_MODES = ["majority", "consensus"];
|
|
13
|
+
export const DEFAULT_DEADLINE_HOURS = 48;
|
|
14
|
+
export const MAX_DEADLINE_HOURS = 720;
|
|
15
|
+
export const MAX_TITLE_LENGTH = 140;
|
|
16
|
+
export const MIN_OPTIONS = 2;
|
|
17
|
+
export const MAX_OPTIONS = 10;
|
|
18
|
+
export const REMOVED_TOOLS = {
|
|
19
|
+
close_decision: "close_decision was removed in 1.1.0: agents cannot close decisions. Use get_close_summary to find out who makes the call.",
|
|
20
|
+
add_participants: "add_participants was removed in 1.1.0: agents cannot invite people. Send the dashboard link to the decision's owner; they share the voter link.",
|
|
21
|
+
request_close: "request_close was renamed get_close_summary: the same read-only tool. Use get_close_summary.",
|
|
22
|
+
};
|
|
23
|
+
export function proposedText(id, url, args) {
|
|
24
|
+
return [
|
|
25
|
+
`Decision proposed.`,
|
|
26
|
+
``,
|
|
27
|
+
`ID: ${id}`,
|
|
28
|
+
`Dashboard: ${url}`,
|
|
29
|
+
`Title: ${args.title}`,
|
|
30
|
+
`Options: ${args.options.join(", ")}`,
|
|
31
|
+
`Method: ${args.method ?? "single_choice"}`,
|
|
32
|
+
`Deadline: ${args.deadline_hours ?? DEFAULT_DEADLINE_HOURS} hours from now`,
|
|
33
|
+
``,
|
|
34
|
+
`Nobody has been invited or notified. Send the dashboard link to the person who owns this decision: they share the voter link with the team and make the call.`,
|
|
35
|
+
`Use check_decision with id "${id}" to see progress.`,
|
|
36
|
+
].join("\n");
|
|
37
|
+
}
|
|
38
|
+
// Fields follow the API's DecisionPayload (packages/integrations-zapier/src/events/types.ts).
|
|
39
|
+
export function formatDecision(d) {
|
|
40
|
+
const lines = [`Decision: ${d.title}`, `Status: ${d.status}`, `Method: ${d.method}`, `ID: ${d.decision_id ?? d.id}`];
|
|
41
|
+
if (d.outcome)
|
|
42
|
+
lines.push(`Outcome: ${d.outcome}`);
|
|
43
|
+
if (d.decided_at)
|
|
44
|
+
lines.push(`Decided at: ${d.decided_at}`);
|
|
45
|
+
const owner = d.owner;
|
|
46
|
+
if (owner?.name || owner?.email)
|
|
47
|
+
lines.push(`Owner: ${owner.name ?? owner.email}`);
|
|
48
|
+
// Record lite (Prompt 62): present only when approved for external sharing.
|
|
49
|
+
if (typeof d.rationale === "string" && d.rationale)
|
|
50
|
+
lines.push(`Rationale: ${d.rationale}`);
|
|
51
|
+
const breakdown = d.vote_breakdown;
|
|
52
|
+
if (breakdown?.length) {
|
|
53
|
+
lines.push(``, `Options:`);
|
|
54
|
+
for (const o of breakdown) {
|
|
55
|
+
lines.push(` - ${o.option} (${o.votes} vote${o.votes === 1 ? "" : "s"})`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (d.url)
|
|
59
|
+
lines.push(``, `Dashboard: ${d.url}`);
|
|
60
|
+
return lines.join("\n");
|
|
61
|
+
}
|
|
62
|
+
export function listText(decisions, query) {
|
|
63
|
+
if (decisions.length === 0) {
|
|
64
|
+
return query ? `No decisions found matching "${query}".` : "No decisions in this workspace.";
|
|
65
|
+
}
|
|
66
|
+
const lines = [`${decisions.length} decision${decisions.length === 1 ? "" : "s"} found:`, ``];
|
|
67
|
+
for (const d of decisions)
|
|
68
|
+
lines.push(`- [${d.status}] ${d.title} (id: ${d.id})`);
|
|
69
|
+
return lines.join("\n");
|
|
70
|
+
}
|
|
71
|
+
// ---- Precedent (Prompt 64, I-4 + I-5): past records, never consent ----
|
|
72
|
+
export const PRECEDENT_NOTE = "Past records for reference. Not consent or authorization.";
|
|
73
|
+
export const SEARCH_LIMIT_DEFAULT = 10;
|
|
74
|
+
export const SEARCH_LIMIT_MAX = 50;
|
|
75
|
+
const day = (iso) => (iso ? String(iso).slice(0, 10) : "date unknown");
|
|
76
|
+
function precedentLine(p) {
|
|
77
|
+
const bits = [p.winner ? `outcome: ${p.winner}` : null, `decided ${day(p.settled_at)}`, p.owner_name ? `owner: ${p.owner_name}` : null];
|
|
78
|
+
return `- [${p.status}] ${p.title} (id: ${p.id}): ${bits.filter(Boolean).join(", ")}`;
|
|
79
|
+
}
|
|
80
|
+
/** The section create_decision appends when there are past decisions with a similar title. */
|
|
81
|
+
export function precedentSection(items) {
|
|
82
|
+
if (items.length === 0)
|
|
83
|
+
return "";
|
|
84
|
+
return ["", "", `Previously decided (${PRECEDENT_NOTE}):`, ...items.map(precedentLine)].join("\n");
|
|
85
|
+
}
|
|
86
|
+
export function searchText(items, query) {
|
|
87
|
+
if (items.length === 0)
|
|
88
|
+
return `No past decided decisions found matching "${query}". ${PRECEDENT_NOTE}`;
|
|
89
|
+
return [
|
|
90
|
+
`${items.length} past decision${items.length === 1 ? "" : "s"} matching "${query}" (newest first):`,
|
|
91
|
+
``,
|
|
92
|
+
...items.map(precedentLine),
|
|
93
|
+
``,
|
|
94
|
+
`${PRECEDENT_NOTE} execution_authorized: false.`,
|
|
95
|
+
].join("\n");
|
|
96
|
+
}
|
|
97
|
+
export function precedentText(d) {
|
|
98
|
+
const lines = [`Past decision: ${d.title}`, `Status: ${d.status}`, `ID: ${d.id}`];
|
|
99
|
+
if (d.winner)
|
|
100
|
+
lines.push(`Outcome: ${d.winner}`);
|
|
101
|
+
lines.push(`Decided: ${day(d.settled_at)}`);
|
|
102
|
+
if (d.owner_name)
|
|
103
|
+
lines.push(`Owner: ${d.owner_name}`);
|
|
104
|
+
if (d.authority_mode)
|
|
105
|
+
lines.push(`How it was decided: ${d.authority_mode}`);
|
|
106
|
+
// Only a rationale approved for external sharing is ever returned.
|
|
107
|
+
if (d.rationale)
|
|
108
|
+
lines.push(`Rationale: ${d.rationale}`);
|
|
109
|
+
if (d.vote_counts.length) {
|
|
110
|
+
lines.push(``, `Votes per option:`);
|
|
111
|
+
for (const o of d.vote_counts)
|
|
112
|
+
lines.push(` - ${o.option} (${o.votes} vote${o.votes === 1 ? "" : "s"})`);
|
|
113
|
+
}
|
|
114
|
+
if (d.related.length) {
|
|
115
|
+
lines.push(``, `Related decisions on the same question:`);
|
|
116
|
+
for (const r of d.related)
|
|
117
|
+
lines.push(` - [${r.status}] ${r.title} (id: ${r.id}), decided ${day(r.settled_at)}`);
|
|
118
|
+
}
|
|
119
|
+
lines.push(``, `This is a historical record, not consent or authorization to repeat the decision. execution_authorized: false.`);
|
|
120
|
+
return lines.join("\n");
|
|
121
|
+
}
|
|
122
|
+
export function closeSummaryText(d) {
|
|
123
|
+
if (d.status !== "active") {
|
|
124
|
+
return `This decision is no longer open (status: ${d.status}). Nothing to close.\n\n${formatDecision(d)}`;
|
|
125
|
+
}
|
|
126
|
+
const owner = d.owner;
|
|
127
|
+
const who = owner?.name || owner?.email
|
|
128
|
+
? [owner.name, owner.email ? `<${owner.email}>` : null].filter(Boolean).join(" ")
|
|
129
|
+
: "the person who owns this decision in Verdo (no owner is named on it)";
|
|
130
|
+
return [
|
|
131
|
+
`Agents cannot close Verdo decisions. A person makes the call.`,
|
|
132
|
+
``,
|
|
133
|
+
`Ask ${who} to open ${d.url} and close it there.`,
|
|
134
|
+
`Share the current tally below so they can decide.`,
|
|
135
|
+
``,
|
|
136
|
+
formatDecision(d),
|
|
137
|
+
].join("\n");
|
|
138
|
+
}
|
|
139
|
+
export function unknownToolText(name) {
|
|
140
|
+
const tools = toolDefinitions().map((t) => t.name).join(", ");
|
|
141
|
+
return `${REMOVED_TOOLS[name] ?? `Unknown tool: ${name}.`} Available tools: ${tools}.`;
|
|
142
|
+
}
|
|
143
|
+
export function toolDefinitions(opts = {}) {
|
|
144
|
+
const meta = opts.meta ? { _meta: opts.meta } : {};
|
|
145
|
+
return [
|
|
146
|
+
{
|
|
147
|
+
name: "create_decision",
|
|
148
|
+
description: "Propose a team decision in the user's Verdo workspace. The agent proposes; a person decides. Nobody is invited or notified: the decision opens in the workspace's dashboard, where its owner shares the voter link and makes the call. The deadline starts counting when it is created. Returns the decision ID and the dashboard link to send to that person, and up to 3 previously decided decisions with a similar title: past records for reference, not consent or authorization.",
|
|
149
|
+
annotations: {
|
|
150
|
+
title: "Propose Decision",
|
|
151
|
+
readOnlyHint: false,
|
|
152
|
+
destructiveHint: false,
|
|
153
|
+
idempotentHint: false,
|
|
154
|
+
openWorldHint: false,
|
|
155
|
+
},
|
|
156
|
+
inputSchema: {
|
|
157
|
+
type: "object",
|
|
158
|
+
required: ["title", "options"],
|
|
159
|
+
properties: {
|
|
160
|
+
title: { type: "string", maxLength: MAX_TITLE_LENGTH, description: "The decision question (max 140 characters)" },
|
|
161
|
+
options: {
|
|
162
|
+
type: "array",
|
|
163
|
+
minItems: MIN_OPTIONS,
|
|
164
|
+
maxItems: MAX_OPTIONS,
|
|
165
|
+
items: { type: "string" },
|
|
166
|
+
description: "2-10 options to vote on",
|
|
167
|
+
},
|
|
168
|
+
method: {
|
|
169
|
+
type: "string",
|
|
170
|
+
enum: [...METHODS],
|
|
171
|
+
description: "Voting method. Default: single_choice",
|
|
172
|
+
},
|
|
173
|
+
deadline_hours: {
|
|
174
|
+
type: "integer",
|
|
175
|
+
minimum: 1,
|
|
176
|
+
maximum: MAX_DEADLINE_HOURS,
|
|
177
|
+
description: "Hours until the decision closes. Default 48, max 720 (30 days).",
|
|
178
|
+
},
|
|
179
|
+
authority_mode: {
|
|
180
|
+
type: "string",
|
|
181
|
+
enum: [...AUTHORITY_MODES],
|
|
182
|
+
description: "How the result is reached: majority (most votes) or consensus (everyone agrees). Default: majority. Owner and approver modes need a named person and are set up in Verdo, not here.",
|
|
183
|
+
},
|
|
184
|
+
anonymous: {
|
|
185
|
+
type: "boolean",
|
|
186
|
+
description: "Whether votes are anonymous. Default: false",
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
...meta,
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: "check_decision",
|
|
194
|
+
description: "Check the status, votes and outcome of a Verdo decision. Returns the status, the vote count per option, the owner if one is named, the outcome once a person has decided, and the dashboard link.",
|
|
195
|
+
annotations: {
|
|
196
|
+
title: "Check Decision",
|
|
197
|
+
readOnlyHint: true,
|
|
198
|
+
destructiveHint: false,
|
|
199
|
+
idempotentHint: true,
|
|
200
|
+
openWorldHint: false,
|
|
201
|
+
},
|
|
202
|
+
inputSchema: {
|
|
203
|
+
type: "object",
|
|
204
|
+
required: ["id"],
|
|
205
|
+
properties: {
|
|
206
|
+
id: { type: "string", format: "uuid", description: "The decision ID from create_decision" },
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
...meta,
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
name: "list_decisions",
|
|
213
|
+
description: "List or search decisions in the workspace. Returns up to 25 decisions with their status and title. Use the query parameter to search by title.",
|
|
214
|
+
annotations: {
|
|
215
|
+
title: "List Decisions",
|
|
216
|
+
readOnlyHint: true,
|
|
217
|
+
destructiveHint: false,
|
|
218
|
+
idempotentHint: true,
|
|
219
|
+
openWorldHint: false,
|
|
220
|
+
},
|
|
221
|
+
inputSchema: {
|
|
222
|
+
type: "object",
|
|
223
|
+
properties: {
|
|
224
|
+
query: { type: "string", description: "Search term to filter decisions by title (optional)" },
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
...meta,
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
name: "search_decisions",
|
|
231
|
+
description: "Search past decided decisions in this workspace by words in their title, newest first. Returns each decision's ID, title, status, outcome, decision date and owner. Results are records, not consent: a past decision never authorizes repeating it, and a new decision still needs the team.",
|
|
232
|
+
annotations: {
|
|
233
|
+
title: "Search Past Decisions",
|
|
234
|
+
readOnlyHint: true,
|
|
235
|
+
destructiveHint: false,
|
|
236
|
+
idempotentHint: true,
|
|
237
|
+
openWorldHint: false,
|
|
238
|
+
},
|
|
239
|
+
inputSchema: {
|
|
240
|
+
type: "object",
|
|
241
|
+
required: ["query"],
|
|
242
|
+
properties: {
|
|
243
|
+
query: { type: "string", maxLength: 140, description: "Words to look for in past decision titles" },
|
|
244
|
+
limit: { type: "integer", minimum: 1, maximum: SEARCH_LIMIT_MAX, description: `How many to return. Default ${SEARCH_LIMIT_DEFAULT}, max ${SEARCH_LIMIT_MAX}.` },
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
...meta,
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
name: "get_precedent",
|
|
251
|
+
description: "Retrieve a past decision record: its outcome, date, owner, how it was decided, the vote count per option, the rationale if it was approved for sharing, and related decisions on the same question. This is a historical record, not consent or authorization to repeat the decision.",
|
|
252
|
+
annotations: {
|
|
253
|
+
title: "Get Past Decision Record",
|
|
254
|
+
readOnlyHint: true,
|
|
255
|
+
destructiveHint: false,
|
|
256
|
+
idempotentHint: true,
|
|
257
|
+
openWorldHint: false,
|
|
258
|
+
},
|
|
259
|
+
inputSchema: {
|
|
260
|
+
type: "object",
|
|
261
|
+
required: ["decision_id"],
|
|
262
|
+
properties: {
|
|
263
|
+
decision_id: { type: "string", format: "uuid", description: "A decided decision's ID, from search_decisions" },
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
...meta,
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
name: "get_close_summary",
|
|
270
|
+
description: "Returns the owner, dashboard link and current tally for a decision, so you can ask the owner to close it. Read-only — changes nothing.",
|
|
271
|
+
annotations: {
|
|
272
|
+
title: "Get Close Summary",
|
|
273
|
+
readOnlyHint: true,
|
|
274
|
+
destructiveHint: false,
|
|
275
|
+
idempotentHint: true,
|
|
276
|
+
openWorldHint: false,
|
|
277
|
+
},
|
|
278
|
+
inputSchema: {
|
|
279
|
+
type: "object",
|
|
280
|
+
required: ["id"],
|
|
281
|
+
properties: {
|
|
282
|
+
id: { type: "string", format: "uuid", description: "The decision ID" },
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
...meta,
|
|
286
|
+
},
|
|
287
|
+
];
|
|
288
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -29,7 +29,7 @@ const keyStore = {
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
};
|
|
32
|
-
const server = new Server({ name: "verdo-team-decisions", version: "1.
|
|
32
|
+
const server = new Server({ name: "verdo-team-decisions", version: "1.2.0" }, { capabilities: { tools: {} } });
|
|
33
33
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
34
34
|
tools: toolDefinitions(),
|
|
35
35
|
}));
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { AUTHORITY_MODES, METHODS, toolDefinitions } from "./definitions.js";
|
|
2
|
+
export { AUTHORITY_MODES, METHODS, toolDefinitions };
|
|
1
3
|
export type ApiKeyStore = {
|
|
2
4
|
get(): Promise<string | null>;
|
|
3
5
|
};
|
|
@@ -8,8 +10,6 @@ type Text = {
|
|
|
8
10
|
}[];
|
|
9
11
|
isError?: boolean;
|
|
10
12
|
};
|
|
11
|
-
export declare const METHODS: readonly ["single_choice", "ranked_choice", "approval", "dot"];
|
|
12
|
-
export declare const AUTHORITY_MODES: readonly ["majority", "consensus"];
|
|
13
13
|
export declare function createDecision(args: {
|
|
14
14
|
title: string;
|
|
15
15
|
options: string[];
|
|
@@ -18,122 +18,20 @@ export declare function createDecision(args: {
|
|
|
18
18
|
authority_mode?: string;
|
|
19
19
|
anonymous?: boolean;
|
|
20
20
|
}, store: ApiKeyStore): Promise<Text>;
|
|
21
|
+
export declare function searchDecisions(args: {
|
|
22
|
+
query: string;
|
|
23
|
+
limit?: number;
|
|
24
|
+
}, store: ApiKeyStore): Promise<Text>;
|
|
25
|
+
export declare function getPrecedent(args: {
|
|
26
|
+
decision_id: string;
|
|
27
|
+
}, store: ApiKeyStore): Promise<Text>;
|
|
21
28
|
export declare function checkDecision(args: {
|
|
22
29
|
id: string;
|
|
23
30
|
}, store: ApiKeyStore): Promise<Text>;
|
|
24
31
|
export declare function listDecisions(args: {
|
|
25
32
|
query?: string;
|
|
26
33
|
}, store: ApiKeyStore): Promise<Text>;
|
|
27
|
-
export declare function
|
|
34
|
+
export declare function getCloseSummary(args: {
|
|
28
35
|
id: string;
|
|
29
36
|
}, store: ApiKeyStore): Promise<Text>;
|
|
30
37
|
export declare function callTool(name: string, a: Record<string, unknown>, store: ApiKeyStore): Promise<Text>;
|
|
31
|
-
export declare function toolDefinitions(): ({
|
|
32
|
-
name: string;
|
|
33
|
-
description: string;
|
|
34
|
-
annotations: {
|
|
35
|
-
title: string;
|
|
36
|
-
readOnlyHint: boolean;
|
|
37
|
-
destructiveHint: boolean;
|
|
38
|
-
idempotentHint: boolean;
|
|
39
|
-
openWorldHint: boolean;
|
|
40
|
-
};
|
|
41
|
-
inputSchema: {
|
|
42
|
-
type: "object";
|
|
43
|
-
required: string[];
|
|
44
|
-
properties: {
|
|
45
|
-
title: {
|
|
46
|
-
type: string;
|
|
47
|
-
maxLength: number;
|
|
48
|
-
description: string;
|
|
49
|
-
};
|
|
50
|
-
options: {
|
|
51
|
-
type: string;
|
|
52
|
-
minItems: number;
|
|
53
|
-
maxItems: number;
|
|
54
|
-
items: {
|
|
55
|
-
type: string;
|
|
56
|
-
};
|
|
57
|
-
description: string;
|
|
58
|
-
};
|
|
59
|
-
method: {
|
|
60
|
-
type: string;
|
|
61
|
-
enum: ("single_choice" | "ranked_choice" | "approval" | "dot")[];
|
|
62
|
-
description: string;
|
|
63
|
-
};
|
|
64
|
-
deadline_hours: {
|
|
65
|
-
type: string;
|
|
66
|
-
minimum: number;
|
|
67
|
-
maximum: number;
|
|
68
|
-
description: string;
|
|
69
|
-
};
|
|
70
|
-
authority_mode: {
|
|
71
|
-
type: string;
|
|
72
|
-
enum: ("majority" | "consensus")[];
|
|
73
|
-
description: string;
|
|
74
|
-
};
|
|
75
|
-
anonymous: {
|
|
76
|
-
type: string;
|
|
77
|
-
description: string;
|
|
78
|
-
};
|
|
79
|
-
id?: undefined;
|
|
80
|
-
query?: undefined;
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
} | {
|
|
84
|
-
name: string;
|
|
85
|
-
description: string;
|
|
86
|
-
annotations: {
|
|
87
|
-
title: string;
|
|
88
|
-
readOnlyHint: boolean;
|
|
89
|
-
destructiveHint: boolean;
|
|
90
|
-
idempotentHint: boolean;
|
|
91
|
-
openWorldHint: boolean;
|
|
92
|
-
};
|
|
93
|
-
inputSchema: {
|
|
94
|
-
type: "object";
|
|
95
|
-
required: string[];
|
|
96
|
-
properties: {
|
|
97
|
-
id: {
|
|
98
|
-
type: string;
|
|
99
|
-
format: string;
|
|
100
|
-
description: string;
|
|
101
|
-
};
|
|
102
|
-
title?: undefined;
|
|
103
|
-
options?: undefined;
|
|
104
|
-
method?: undefined;
|
|
105
|
-
deadline_hours?: undefined;
|
|
106
|
-
authority_mode?: undefined;
|
|
107
|
-
anonymous?: undefined;
|
|
108
|
-
query?: undefined;
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
} | {
|
|
112
|
-
name: string;
|
|
113
|
-
description: string;
|
|
114
|
-
annotations: {
|
|
115
|
-
title: string;
|
|
116
|
-
readOnlyHint: boolean;
|
|
117
|
-
destructiveHint: boolean;
|
|
118
|
-
idempotentHint: boolean;
|
|
119
|
-
openWorldHint: boolean;
|
|
120
|
-
};
|
|
121
|
-
inputSchema: {
|
|
122
|
-
type: "object";
|
|
123
|
-
properties: {
|
|
124
|
-
query: {
|
|
125
|
-
type: string;
|
|
126
|
-
description: string;
|
|
127
|
-
};
|
|
128
|
-
title?: undefined;
|
|
129
|
-
options?: undefined;
|
|
130
|
-
method?: undefined;
|
|
131
|
-
deadline_hours?: undefined;
|
|
132
|
-
authority_mode?: undefined;
|
|
133
|
-
anonymous?: undefined;
|
|
134
|
-
id?: undefined;
|
|
135
|
-
};
|
|
136
|
-
required?: undefined;
|
|
137
|
-
};
|
|
138
|
-
})[];
|
|
139
|
-
export {};
|
package/dist/tools.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
// Verdo MCP tools — wraps the Zapier REST API (apps/verdo-web/app/api/zapier/*)
|
|
2
2
|
// with agent-friendly descriptions and error messages that help agents self-remedy.
|
|
3
|
+
// The definitions and the text each tool returns live in definitions.ts, shared with
|
|
4
|
+
// the remote server at verdo.ink/api/mcp.
|
|
3
5
|
//
|
|
4
6
|
// Guardrail: the agent proposes, a person decides. No tool here invites, notifies,
|
|
5
7
|
// settles, closes or cancels. create_decision is the only write, and it sends no
|
|
6
|
-
// participants;
|
|
8
|
+
// participants; get_close_summary only reads and points the agent at a person.
|
|
9
|
+
import { AUTHORITY_MODES, DEFAULT_DEADLINE_HOURS, METHODS, formatDecision, listText, proposedText, closeSummaryText, toolDefinitions, unknownToolText, precedentSection, precedentText, searchText, } from "./definitions.js";
|
|
10
|
+
export { AUTHORITY_MODES, METHODS, toolDefinitions };
|
|
7
11
|
const VERDO_API = process.env.VERDO_API_URL ?? "https://verdo.ink/api";
|
|
8
12
|
const text = (t, isError = false) => ({
|
|
9
13
|
content: [{ type: "text", text: t }],
|
|
@@ -39,10 +43,6 @@ function agentError(action, status, data) {
|
|
|
39
43
|
return text(`Could not ${action}: ${enriched}${retry}`, true);
|
|
40
44
|
}
|
|
41
45
|
// ---- Tool implementations ----
|
|
42
|
-
// Values the API accepts (DB checks in migrations 0041 and 0042). Owner and approver
|
|
43
|
-
// modes need a named person, which this API cannot set, so they are not offered.
|
|
44
|
-
export const METHODS = ["single_choice", "ranked_choice", "approval", "dot"];
|
|
45
|
-
export const AUTHORITY_MODES = ["majority", "consensus"];
|
|
46
46
|
export async function createDecision(args, store) {
|
|
47
47
|
const apiKey = await store.get();
|
|
48
48
|
if (!apiKey)
|
|
@@ -54,27 +54,52 @@ export async function createDecision(args, store) {
|
|
|
54
54
|
title: args.title,
|
|
55
55
|
options: args.options,
|
|
56
56
|
method: args.method ?? "single_choice",
|
|
57
|
-
deadline_hours: args.deadline_hours ??
|
|
57
|
+
deadline_hours: args.deadline_hours ?? DEFAULT_DEADLINE_HOURS,
|
|
58
58
|
authority_mode: args.authority_mode ?? "majority",
|
|
59
59
|
anonymous: args.anonymous ?? false,
|
|
60
60
|
}),
|
|
61
61
|
});
|
|
62
62
|
if (!ok)
|
|
63
63
|
return agentError("create the decision", status, data);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
64
|
+
// Prompt 64: up to 3 previously decided decisions with a similar title (reference only;
|
|
65
|
+
// a failed lookup never fails the create).
|
|
66
|
+
let precedent = [];
|
|
67
|
+
try {
|
|
68
|
+
const found = await verdoFetch(`/zapier/decisions/precedent?query=${encodeURIComponent(args.title)}&limit=4`, apiKey);
|
|
69
|
+
if (found.ok)
|
|
70
|
+
precedent = (found.data.decisions ?? []).filter((p) => p.id !== String(data.id)).slice(0, 3);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
precedent = [];
|
|
74
|
+
}
|
|
75
|
+
return text(proposedText(String(data.id), String(data.url), args) + precedentSection(precedent));
|
|
76
|
+
}
|
|
77
|
+
// Read-only. Past decided decisions, newest first: records, never consent.
|
|
78
|
+
export async function searchDecisions(args, store) {
|
|
79
|
+
const apiKey = await store.get();
|
|
80
|
+
if (!apiKey)
|
|
81
|
+
return noKeyError();
|
|
82
|
+
const query = args.query.trim();
|
|
83
|
+
if (!query)
|
|
84
|
+
return text("Could not search decisions: query is required (words to look for in past decision titles).", true);
|
|
85
|
+
const qs = `?query=${encodeURIComponent(query)}${args.limit !== undefined ? `&limit=${encodeURIComponent(String(args.limit))}` : ""}`;
|
|
86
|
+
const { ok, status, data } = await verdoFetch(`/zapier/decisions/precedent${qs}`, apiKey);
|
|
87
|
+
if (!ok)
|
|
88
|
+
return agentError("search decisions", status, data);
|
|
89
|
+
return text(searchText((data.decisions ?? []), query));
|
|
90
|
+
}
|
|
91
|
+
// Read-only. One past decision's record: a historical record, not consent.
|
|
92
|
+
export async function getPrecedent(args, store) {
|
|
93
|
+
const apiKey = await store.get();
|
|
94
|
+
if (!apiKey)
|
|
95
|
+
return noKeyError();
|
|
96
|
+
const { ok, status, data } = await verdoFetch(`/zapier/decisions/${encodeURIComponent(args.decision_id)}/precedent`, apiKey);
|
|
97
|
+
if (!ok)
|
|
98
|
+
return agentError("read the past decision", status, data);
|
|
99
|
+
const d = data.precedent;
|
|
100
|
+
if (!d)
|
|
101
|
+
return text("Past decision data not available.", true);
|
|
102
|
+
return text(precedentText(d));
|
|
78
103
|
}
|
|
79
104
|
export async function checkDecision(args, store) {
|
|
80
105
|
const apiKey = await store.get();
|
|
@@ -96,19 +121,11 @@ export async function listDecisions(args, store) {
|
|
|
96
121
|
const { ok, status, data } = await verdoFetch(`/zapier/decisions/search${qs}`, apiKey);
|
|
97
122
|
if (!ok)
|
|
98
123
|
return agentError("list decisions", status, data);
|
|
99
|
-
|
|
100
|
-
if (decisions.length === 0) {
|
|
101
|
-
return text(args.query ? `No decisions found matching "${args.query}".` : "No decisions in this workspace.");
|
|
102
|
-
}
|
|
103
|
-
const lines = [`${decisions.length} decision${decisions.length === 1 ? "" : "s"} found:`, ``];
|
|
104
|
-
for (const d of decisions) {
|
|
105
|
-
lines.push(`- [${d.status}] ${d.title} (id: ${d.id})`);
|
|
106
|
-
}
|
|
107
|
-
return text(lines.join("\n"));
|
|
124
|
+
return text(listText((data.decisions ?? []), args.query));
|
|
108
125
|
}
|
|
109
126
|
// Read-only. An agent never closes a decision: this tells it who makes the call and
|
|
110
127
|
// where. It only GETs the decision; no mutating route is called.
|
|
111
|
-
export async function
|
|
128
|
+
export async function getCloseSummary(args, store) {
|
|
112
129
|
const apiKey = await store.get();
|
|
113
130
|
if (!apiKey)
|
|
114
131
|
return noKeyError();
|
|
@@ -118,27 +135,9 @@ export async function requestClose(args, store) {
|
|
|
118
135
|
const d = data.decision;
|
|
119
136
|
if (!d)
|
|
120
137
|
return text("Decision data not available.", true);
|
|
121
|
-
|
|
122
|
-
return text(`This decision is no longer open (status: ${d.status}). Nothing to close.\n\n${formatDecision(d)}`);
|
|
123
|
-
}
|
|
124
|
-
const owner = d.owner;
|
|
125
|
-
const who = owner?.name || owner?.email
|
|
126
|
-
? [owner.name, owner.email ? `<${owner.email}>` : null].filter(Boolean).join(" ")
|
|
127
|
-
: "the person who owns this decision in Verdo (no owner is named on it)";
|
|
128
|
-
return text([
|
|
129
|
-
`Agents cannot close Verdo decisions. A person makes the call.`,
|
|
130
|
-
``,
|
|
131
|
-
`Ask ${who} to open ${d.url} and close it there.`,
|
|
132
|
-
`Share the current tally below so they can decide.`,
|
|
133
|
-
``,
|
|
134
|
-
formatDecision(d),
|
|
135
|
-
].join("\n"));
|
|
138
|
+
return text(closeSummaryText(d));
|
|
136
139
|
}
|
|
137
140
|
// ---- Dispatch ----
|
|
138
|
-
const REMOVED_TOOLS = {
|
|
139
|
-
close_decision: "close_decision was removed in 1.1.0: agents cannot close decisions. Use request_close to find out who makes the call.",
|
|
140
|
-
add_participants: "add_participants was removed in 1.1.0: agents cannot invite people. Send the dashboard link to the decision's owner; they share the voter link.",
|
|
141
|
-
};
|
|
142
141
|
export async function callTool(name, a, store) {
|
|
143
142
|
switch (name) {
|
|
144
143
|
case "create_decision":
|
|
@@ -154,41 +153,17 @@ export async function callTool(name, a, store) {
|
|
|
154
153
|
return checkDecision({ id: String(a.id ?? "") }, store);
|
|
155
154
|
case "list_decisions":
|
|
156
155
|
return listDecisions({ query: a.query }, store);
|
|
157
|
-
case "
|
|
158
|
-
return
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
156
|
+
case "get_close_summary":
|
|
157
|
+
return getCloseSummary({ id: String(a.id ?? "") }, store);
|
|
158
|
+
case "search_decisions":
|
|
159
|
+
return searchDecisions({ query: String(a.query ?? ""), limit: a.limit }, store);
|
|
160
|
+
case "get_precedent":
|
|
161
|
+
return getPrecedent({ decision_id: String(a.decision_id ?? "") }, store);
|
|
162
|
+
default:
|
|
163
|
+
return text(unknownToolText(name), true);
|
|
163
164
|
}
|
|
164
165
|
}
|
|
165
166
|
// ---- Helpers ----
|
|
166
|
-
// Fields follow the API's DecisionPayload (packages/integrations-zapier/src/events/types.ts).
|
|
167
|
-
function formatDecision(d) {
|
|
168
|
-
const lines = [
|
|
169
|
-
`Decision: ${d.title}`,
|
|
170
|
-
`Status: ${d.status}`,
|
|
171
|
-
`Method: ${d.method}`,
|
|
172
|
-
`ID: ${d.decision_id ?? d.id}`,
|
|
173
|
-
];
|
|
174
|
-
if (d.outcome)
|
|
175
|
-
lines.push(`Outcome: ${d.outcome}`);
|
|
176
|
-
if (d.decided_at)
|
|
177
|
-
lines.push(`Decided at: ${d.decided_at}`);
|
|
178
|
-
const owner = d.owner;
|
|
179
|
-
if (owner?.name || owner?.email)
|
|
180
|
-
lines.push(`Owner: ${owner.name ?? owner.email}`);
|
|
181
|
-
const breakdown = d.vote_breakdown;
|
|
182
|
-
if (breakdown?.length) {
|
|
183
|
-
lines.push(``, `Options:`);
|
|
184
|
-
for (const o of breakdown) {
|
|
185
|
-
lines.push(` - ${o.option} (${o.votes} vote${o.votes === 1 ? "" : "s"})`);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
if (d.url)
|
|
189
|
-
lines.push(``, `Dashboard: ${d.url}`);
|
|
190
|
-
return lines.join("\n");
|
|
191
|
-
}
|
|
192
167
|
function noKeyError() {
|
|
193
168
|
return text([
|
|
194
169
|
"No Verdo API key found.",
|
|
@@ -198,106 +173,3 @@ function noKeyError() {
|
|
|
198
173
|
"To get a key: verdo.ink/dashboard/settings > API Keys > Create (the key is shown once).",
|
|
199
174
|
].join("\n"), true);
|
|
200
175
|
}
|
|
201
|
-
// ---- Tool definitions ----
|
|
202
|
-
export function toolDefinitions() {
|
|
203
|
-
return [
|
|
204
|
-
{
|
|
205
|
-
name: "create_decision",
|
|
206
|
-
description: "Propose a team decision in the user's Verdo workspace. The agent proposes; a person decides. Nobody is invited or notified: the decision opens in the workspace's dashboard, where its owner shares the voter link and makes the call. The deadline starts counting when it is created. Returns the decision ID and the dashboard link to send to that person.",
|
|
207
|
-
annotations: {
|
|
208
|
-
title: "Propose Decision",
|
|
209
|
-
readOnlyHint: false,
|
|
210
|
-
destructiveHint: false,
|
|
211
|
-
idempotentHint: false,
|
|
212
|
-
openWorldHint: false,
|
|
213
|
-
},
|
|
214
|
-
inputSchema: {
|
|
215
|
-
type: "object",
|
|
216
|
-
required: ["title", "options"],
|
|
217
|
-
properties: {
|
|
218
|
-
title: { type: "string", maxLength: 140, description: "The decision question (max 140 characters)" },
|
|
219
|
-
options: {
|
|
220
|
-
type: "array",
|
|
221
|
-
minItems: 2,
|
|
222
|
-
maxItems: 10,
|
|
223
|
-
items: { type: "string" },
|
|
224
|
-
description: "2-10 options to vote on",
|
|
225
|
-
},
|
|
226
|
-
method: {
|
|
227
|
-
type: "string",
|
|
228
|
-
enum: [...METHODS],
|
|
229
|
-
description: "Voting method. Default: single_choice",
|
|
230
|
-
},
|
|
231
|
-
deadline_hours: {
|
|
232
|
-
type: "integer",
|
|
233
|
-
minimum: 1,
|
|
234
|
-
maximum: 720,
|
|
235
|
-
description: "Hours until the decision closes. Default 48, max 720 (30 days).",
|
|
236
|
-
},
|
|
237
|
-
authority_mode: {
|
|
238
|
-
type: "string",
|
|
239
|
-
enum: [...AUTHORITY_MODES],
|
|
240
|
-
description: "How the result is reached: majority (most votes) or consensus (everyone agrees). Default: majority. Owner and approver modes need a named person and are set up in Verdo, not here.",
|
|
241
|
-
},
|
|
242
|
-
anonymous: {
|
|
243
|
-
type: "boolean",
|
|
244
|
-
description: "Whether votes are anonymous. Default: false",
|
|
245
|
-
},
|
|
246
|
-
},
|
|
247
|
-
},
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
name: "check_decision",
|
|
251
|
-
description: "Check the status, votes and outcome of a Verdo decision. Returns the status, the vote count per option, the owner if one is named, the outcome once a person has decided, and the dashboard link.",
|
|
252
|
-
annotations: {
|
|
253
|
-
title: "Check Decision",
|
|
254
|
-
readOnlyHint: true,
|
|
255
|
-
destructiveHint: false,
|
|
256
|
-
idempotentHint: true,
|
|
257
|
-
openWorldHint: false,
|
|
258
|
-
},
|
|
259
|
-
inputSchema: {
|
|
260
|
-
type: "object",
|
|
261
|
-
required: ["id"],
|
|
262
|
-
properties: {
|
|
263
|
-
id: { type: "string", format: "uuid", description: "The decision ID from create_decision" },
|
|
264
|
-
},
|
|
265
|
-
},
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
name: "list_decisions",
|
|
269
|
-
description: "List or search decisions in the workspace. Returns up to 25 decisions with their status and title. Use the query parameter to search by title.",
|
|
270
|
-
annotations: {
|
|
271
|
-
title: "List Decisions",
|
|
272
|
-
readOnlyHint: true,
|
|
273
|
-
destructiveHint: false,
|
|
274
|
-
idempotentHint: true,
|
|
275
|
-
openWorldHint: false,
|
|
276
|
-
},
|
|
277
|
-
inputSchema: {
|
|
278
|
-
type: "object",
|
|
279
|
-
properties: {
|
|
280
|
-
query: { type: "string", description: "Search term to filter decisions by title (optional)" },
|
|
281
|
-
},
|
|
282
|
-
},
|
|
283
|
-
},
|
|
284
|
-
{
|
|
285
|
-
name: "request_close",
|
|
286
|
-
description: "Use when the user wants a Verdo decision closed or settled. Agents cannot close decisions; a person makes the call. Returns who owns the decision, its dashboard link and the current tally, so you can ask that person to decide. Changes nothing.",
|
|
287
|
-
annotations: {
|
|
288
|
-
title: "Request Close",
|
|
289
|
-
readOnlyHint: true,
|
|
290
|
-
destructiveHint: false,
|
|
291
|
-
idempotentHint: true,
|
|
292
|
-
openWorldHint: false,
|
|
293
|
-
},
|
|
294
|
-
inputSchema: {
|
|
295
|
-
type: "object",
|
|
296
|
-
required: ["id"],
|
|
297
|
-
properties: {
|
|
298
|
-
id: { type: "string", format: "uuid", description: "The decision ID" },
|
|
299
|
-
},
|
|
300
|
-
},
|
|
301
|
-
},
|
|
302
|
-
];
|
|
303
|
-
}
|