@agent-change-requests/client 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +122 -2
- package/dist/acceptance.d.ts +12 -0
- package/dist/acceptance.js +55 -0
- package/dist/acceptance.js.map +1 -0
- package/dist/changes.d.ts +96 -0
- package/dist/changes.js +192 -0
- package/dist/changes.js.map +1 -0
- package/dist/client.d.ts +205 -0
- package/dist/client.js +521 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/ledger.d.ts +39 -0
- package/dist/ledger.js +43 -0
- package/dist/ledger.js.map +1 -0
- package/dist/redact.d.ts +47 -0
- package/dist/redact.js +127 -0
- package/dist/redact.js.map +1 -0
- package/dist/types.d.ts +126 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +46 -4
package/dist/client.js
ADDED
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client support for the Agent Change Requests extension, on top of Client from
|
|
3
|
+
* @modelcontextprotocol/sdk.
|
|
4
|
+
*
|
|
5
|
+
* - Advertises the extension, only with consent and never from an ephemeral session.
|
|
6
|
+
* - Gives the model one submission tool whose description the client writes.
|
|
7
|
+
* - Redacts every model-written field, applies a daily cap, and skips gaps it already filed.
|
|
8
|
+
* - Reads the inbox when a response carries an update count, and records what shipped.
|
|
9
|
+
* - Re-runs its own acceptance tests and confirms the result.
|
|
10
|
+
*/
|
|
11
|
+
import { randomUUID } from "node:crypto";
|
|
12
|
+
import { ResultSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
13
|
+
import { runAcceptanceTest } from "./acceptance.js";
|
|
14
|
+
import { CHANGES_NOTICE_LINE } from "./changes.js";
|
|
15
|
+
import { MemoryLedger } from "./ledger.js";
|
|
16
|
+
import { redactSubmission } from "./redact.js";
|
|
17
|
+
import { TERMINAL_STATUSES, } from "./types.js";
|
|
18
|
+
export const CLIENT_CAPABILITIES_META_KEY = "io.modelcontextprotocol/clientCapabilities";
|
|
19
|
+
/** The text line servers add while updates wait. Matches any wording that carries the count. */
|
|
20
|
+
const NOTICE_LINE = /\b(\d+) of your change requests (?:has|have) an update\b/;
|
|
21
|
+
/** The server's default inbox tool (SEP section 7 example). */
|
|
22
|
+
const DEFAULT_INBOX_TOOL = "change_requests_list";
|
|
23
|
+
/** The fixed line a client adds from the _meta count. It carries no request content. */
|
|
24
|
+
export function updateNoticeLine(count, inboxTool) {
|
|
25
|
+
const verb = count === 1 ? "has" : "have";
|
|
26
|
+
return `${count} of your change requests ${verb} an update. Call ${inboxTool} to see them.`;
|
|
27
|
+
}
|
|
28
|
+
/** The server's default changes tool (SEP section 12 example). */
|
|
29
|
+
const DEFAULT_CHANGES_TOOL = "whats_new";
|
|
30
|
+
/** The fixed changes line a client adds from the _meta count. It carries no change content. */
|
|
31
|
+
export function changesNoticeLine(count, changesTool) {
|
|
32
|
+
const noun = count === 1 ? "change" : "changes";
|
|
33
|
+
return `${count} ${noun} may affect your use of this server. Call ${changesTool} to see them.`;
|
|
34
|
+
}
|
|
35
|
+
function isTextMatching(c, pattern) {
|
|
36
|
+
const text = c.text;
|
|
37
|
+
return c.type === "text" && typeof text === "string" && pattern.test(text);
|
|
38
|
+
}
|
|
39
|
+
function isUpdateBlock(c) {
|
|
40
|
+
return isTextMatching(c, NOTICE_LINE);
|
|
41
|
+
}
|
|
42
|
+
function isChangesBlock(c) {
|
|
43
|
+
return isTextMatching(c, CHANGES_NOTICE_LINE);
|
|
44
|
+
}
|
|
45
|
+
/** Either notice line: the update line (section 7) or the changes line (section 12). */
|
|
46
|
+
function isNoticeBlock(c) {
|
|
47
|
+
return isUpdateBlock(c) || isChangesBlock(c);
|
|
48
|
+
}
|
|
49
|
+
function textBlocks(content) {
|
|
50
|
+
return content
|
|
51
|
+
.filter((c) => c.type === "text" && typeof c.text === "string")
|
|
52
|
+
.map((c) => ({ type: "text", text: c.text }));
|
|
53
|
+
}
|
|
54
|
+
/** The capabilities to pass to new Client(): the extension is advertised only when allowed. */
|
|
55
|
+
export function changeRequestsCapabilities(extensionId, consent, base = {}) {
|
|
56
|
+
if (!allowed(consent))
|
|
57
|
+
return base;
|
|
58
|
+
const extensions = { ...(base.extensions ?? {}), [extensionId]: {} };
|
|
59
|
+
return { ...base, extensions };
|
|
60
|
+
}
|
|
61
|
+
function allowed(consent) {
|
|
62
|
+
if (consent.ephemeral)
|
|
63
|
+
return false;
|
|
64
|
+
return typeof consent.consent === "function" ? consent.consent() === true : consent.consent === true;
|
|
65
|
+
}
|
|
66
|
+
function utcDay(date) {
|
|
67
|
+
return date.toISOString().slice(0, 10);
|
|
68
|
+
}
|
|
69
|
+
function sameTarget(a, b) {
|
|
70
|
+
if (!a || !b)
|
|
71
|
+
return false;
|
|
72
|
+
return a.type === b.type && (a.name ?? "") === (b.name ?? "") && (a.component ?? "") === (b.component ?? "");
|
|
73
|
+
}
|
|
74
|
+
export class ChangeRequestsClient {
|
|
75
|
+
extensionId;
|
|
76
|
+
client;
|
|
77
|
+
options;
|
|
78
|
+
ledger;
|
|
79
|
+
now;
|
|
80
|
+
serverToolNames = null;
|
|
81
|
+
constructor(client, options) {
|
|
82
|
+
this.client = client;
|
|
83
|
+
this.options = options;
|
|
84
|
+
this.extensionId = options.extensionId;
|
|
85
|
+
this.ledger = options.ledger ?? new MemoryLedger();
|
|
86
|
+
this.now = options.now ?? (() => new Date());
|
|
87
|
+
}
|
|
88
|
+
/** The server's settings for the extension, or null when it does not advertise it. */
|
|
89
|
+
settings() {
|
|
90
|
+
const extensions = this.client.getServerCapabilities()?.extensions;
|
|
91
|
+
const settings = extensions?.[this.extensionId];
|
|
92
|
+
return settings && Array.isArray(settings.kinds) ? settings : null;
|
|
93
|
+
}
|
|
94
|
+
/** Consent given, not ephemeral, and the server supports the extension. */
|
|
95
|
+
enabled() {
|
|
96
|
+
return allowed(this.options) && this.settings() !== null;
|
|
97
|
+
}
|
|
98
|
+
// ---- The model-facing tool ----------------------------------------------
|
|
99
|
+
/** The one submission tool to show the model. Its description is the client's, not the server's. */
|
|
100
|
+
submissionTool() {
|
|
101
|
+
const settings = this.settings();
|
|
102
|
+
const server = this.options.serverName ?? "this server";
|
|
103
|
+
const kinds = settings?.kinds ?? ["bug", "friction", "missing_capability", "feature_request"];
|
|
104
|
+
const properties = {
|
|
105
|
+
kind: { type: "string", enum: kinds, description: "bug: it is broken. friction: it works but costs extra work. missing_capability: it cannot be done. feature_request: a new idea." },
|
|
106
|
+
title: { type: "string", maxLength: 120, description: "One line." },
|
|
107
|
+
description: { type: "string", maxLength: 4000, description: "What is broken or missing and what would have helped. Plain text." },
|
|
108
|
+
target: {
|
|
109
|
+
type: "object",
|
|
110
|
+
properties: { type: { type: "string", enum: ["tool", "resource", "prompt", "server"] }, name: { type: "string" } },
|
|
111
|
+
required: ["type"],
|
|
112
|
+
description: `Which of ${server}'s tools, resources, or prompts this is about.`,
|
|
113
|
+
},
|
|
114
|
+
context: {
|
|
115
|
+
type: "object",
|
|
116
|
+
properties: {
|
|
117
|
+
goal: { type: "string", description: "What you were trying to get done, in general terms." },
|
|
118
|
+
workaround: { type: "string", description: "What you did instead." },
|
|
119
|
+
cause: { type: "string", maxLength: 500, description: "Your guess at why the gap exists. It is read as a guess." },
|
|
120
|
+
attempts: { type: "array", maxItems: 5, items: { type: "object" }, description: "Up to 5 calls you tried and what happened. Made-up example values only." },
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
failureMode: { type: "string", description: "capability_missing, interface_cost, data_gap, discoverability, scope_not_honored, or silent_failure." },
|
|
124
|
+
impact: {
|
|
125
|
+
type: "object",
|
|
126
|
+
properties: {
|
|
127
|
+
blocked: { type: "boolean" },
|
|
128
|
+
frequency: { type: "string", enum: ["once", "recurring"] },
|
|
129
|
+
severity: { type: "string", enum: ["low", "medium", "high"] },
|
|
130
|
+
detectability: { type: "string", enum: ["immediate", "eventual", "hidden"] },
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
if (settings?.acceptanceTests) {
|
|
135
|
+
properties.acceptanceTests = {
|
|
136
|
+
type: "array",
|
|
137
|
+
maxItems: 10,
|
|
138
|
+
description: "The exact call you wanted and the result you expected. Made-up example values only.",
|
|
139
|
+
items: {
|
|
140
|
+
type: "object",
|
|
141
|
+
properties: {
|
|
142
|
+
description: { type: "string" },
|
|
143
|
+
call: {
|
|
144
|
+
type: "object",
|
|
145
|
+
properties: { method: { type: "string", enum: ["tools/call", "resources/read", "prompts/get"] }, params: { type: "object" } },
|
|
146
|
+
required: ["method"],
|
|
147
|
+
},
|
|
148
|
+
expect: {
|
|
149
|
+
type: "object",
|
|
150
|
+
properties: {
|
|
151
|
+
isError: { type: "boolean" },
|
|
152
|
+
structuredContentSchema: { type: "object" },
|
|
153
|
+
textContains: { type: "array", items: { type: "string" }, maxItems: 5 },
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
required: ["call"],
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
name: this.options.toolName ?? "file_change_request",
|
|
163
|
+
description: [
|
|
164
|
+
`Tell ${server}'s maintainers about a gap you hit in its tools, and get an answer when it is fixed.`,
|
|
165
|
+
"Use it only when the gap blocked your task, has come up more than once, or the user asked. Do not file one-off edge cases you worked around cheaply.",
|
|
166
|
+
settings?.acceptanceTests ? "Include an acceptance test: the call you wanted and the result you expected." : "",
|
|
167
|
+
"Write in general terms. Never include credentials, personal data, the user's words, file contents, file paths, or anything about other servers. Use made-up example values.",
|
|
168
|
+
]
|
|
169
|
+
.filter(Boolean)
|
|
170
|
+
.join(" "),
|
|
171
|
+
inputSchema: { type: "object", properties, required: ["kind", "title", "description"] },
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/** Runs the submission tool for the model and returns a tool result for it. */
|
|
175
|
+
async callSubmissionTool(args) {
|
|
176
|
+
const text = (t, isError = false) => ({ content: [{ type: "text", text: t }], ...(isError ? { isError } : {}) });
|
|
177
|
+
try {
|
|
178
|
+
const outcome = await this.submit(args);
|
|
179
|
+
if (outcome.submitted) {
|
|
180
|
+
return text(`Filed as ${outcome.result.requestId} (${outcome.result.status}). You will hear back through the inbox when it changes.`);
|
|
181
|
+
}
|
|
182
|
+
switch (outcome.reason) {
|
|
183
|
+
case "already_filed":
|
|
184
|
+
return text(`You already filed this gap as ${outcome.requestId}, which is ${outcome.status}. Keep your workaround for now.`);
|
|
185
|
+
case "daily_cap":
|
|
186
|
+
return text("The daily limit for change requests to this server is reached. Tell the user instead.", true);
|
|
187
|
+
case "cancelled":
|
|
188
|
+
return text("The user did not send this request.", true);
|
|
189
|
+
case "kind_unsupported":
|
|
190
|
+
return text("This server does not accept that kind of request.", true);
|
|
191
|
+
default:
|
|
192
|
+
return text("Change requests are not turned on for this server.", true);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
return text(`The server refused the request: ${error instanceof Error ? error.message : "unknown error"}`, true);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
// ---- Protocol methods ---------------------------------------------------
|
|
200
|
+
/**
|
|
201
|
+
* Submits a request after the client-side checks: consent, kind, daily cap,
|
|
202
|
+
* not already filed for the same target, redaction, and review.
|
|
203
|
+
*/
|
|
204
|
+
async submit(input) {
|
|
205
|
+
if (!this.enabled())
|
|
206
|
+
return { submitted: false, reason: "not_enabled" };
|
|
207
|
+
const settings = this.settings();
|
|
208
|
+
if (!settings.kinds.includes(input.kind))
|
|
209
|
+
return { submitted: false, reason: "kind_unsupported" };
|
|
210
|
+
const data = this.ledger.load();
|
|
211
|
+
const day = utcDay(this.now());
|
|
212
|
+
const cap = this.options.dailyCap ?? 5;
|
|
213
|
+
if (cap > 0 && (data.submissions[day] ?? 0) >= cap)
|
|
214
|
+
return { submitted: false, reason: "daily_cap" };
|
|
215
|
+
if (input.target) {
|
|
216
|
+
const open = await this.findOpen(input.target, data);
|
|
217
|
+
if (open)
|
|
218
|
+
return { submitted: false, reason: "already_filed", requestId: open.requestId, status: open.status };
|
|
219
|
+
}
|
|
220
|
+
const { acceptanceTests, idempotencyKey, ...rest } = input;
|
|
221
|
+
const draft = { ...rest };
|
|
222
|
+
if (acceptanceTests && settings.acceptanceTests)
|
|
223
|
+
draft.acceptanceTests = acceptanceTests;
|
|
224
|
+
let { params, findings } = redactSubmission(draft, this.options.redaction);
|
|
225
|
+
if (this.options.review && (this.options.reviewAll || findings.length > 0)) {
|
|
226
|
+
const verdict = await this.options.review(params, findings);
|
|
227
|
+
if (verdict === false)
|
|
228
|
+
return { submitted: false, reason: "cancelled" };
|
|
229
|
+
if (verdict !== true)
|
|
230
|
+
({ params, findings } = redactSubmission(verdict, this.options.redaction));
|
|
231
|
+
}
|
|
232
|
+
params.idempotencyKey = idempotencyKey ?? randomUUID();
|
|
233
|
+
const result = (await this.call("changeRequests/submit", params));
|
|
234
|
+
const at = this.now().toISOString();
|
|
235
|
+
const fresh = this.ledger.load();
|
|
236
|
+
fresh.submissions[day] = (fresh.submissions[day] ?? 0) + 1;
|
|
237
|
+
const entry = { requestId: result.requestId, title: params.title, status: result.status, submittedAt: at, updatedAt: at };
|
|
238
|
+
if (params.target)
|
|
239
|
+
entry.target = params.target;
|
|
240
|
+
// Keep the tests as sent, so the client re-runs exactly what the server stored.
|
|
241
|
+
if (params.acceptanceTests)
|
|
242
|
+
entry.acceptanceTests = params.acceptanceTests;
|
|
243
|
+
// Anonymous submissions: the ticket is the only way back to the request (SEP section 3).
|
|
244
|
+
if (typeof result.ticket === "string")
|
|
245
|
+
entry.ticket = result.ticket;
|
|
246
|
+
if (input.context?.workaround)
|
|
247
|
+
entry.workaround = input.context.workaround;
|
|
248
|
+
fresh.requests[result.requestId] = entry;
|
|
249
|
+
this.ledger.save(fresh);
|
|
250
|
+
return { submitted: true, result, findings };
|
|
251
|
+
}
|
|
252
|
+
/** Reads one request. Passes the ledger's ticket for a request filed anonymously. */
|
|
253
|
+
async get(requestId) {
|
|
254
|
+
const ticket = this.ledger.load().requests[requestId]?.ticket;
|
|
255
|
+
const params = ticket ? { requestId, ticket } : { requestId };
|
|
256
|
+
const status = (await this.call("changeRequests/get", params));
|
|
257
|
+
this.remember([status]);
|
|
258
|
+
return status;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* For requests filed anonymously, which have no inbox: reads each open one by its
|
|
262
|
+
* ticket and returns what changed, like checkInbox(). Shipped requests with an obsolete
|
|
263
|
+
* workaround are marked in the ledger and passed to onShipped.
|
|
264
|
+
*/
|
|
265
|
+
async checkTickets() {
|
|
266
|
+
const before = this.ledger.load();
|
|
267
|
+
const updated = [];
|
|
268
|
+
for (const entry of Object.values(before.requests)) {
|
|
269
|
+
if (!entry.ticket || TERMINAL_STATUSES.includes(entry.status))
|
|
270
|
+
continue;
|
|
271
|
+
const status = await this.get(entry.requestId);
|
|
272
|
+
if (status.status !== entry.status || status.updatedAt !== entry.updatedAt)
|
|
273
|
+
updated.push(status);
|
|
274
|
+
}
|
|
275
|
+
const shipped = updated.filter((s) => s.status === "shipped" && s.resolution?.workaroundObsolete === true);
|
|
276
|
+
const after = this.ledger.load();
|
|
277
|
+
for (const status of shipped) {
|
|
278
|
+
const entry = after.requests[status.requestId];
|
|
279
|
+
if (entry)
|
|
280
|
+
await this.options.onShipped?.(status, entry);
|
|
281
|
+
}
|
|
282
|
+
return { updated, shipped };
|
|
283
|
+
}
|
|
284
|
+
async list(query = {}) {
|
|
285
|
+
const page = (await this.call("changeRequests/list", query));
|
|
286
|
+
this.remember(page.requests);
|
|
287
|
+
return page;
|
|
288
|
+
}
|
|
289
|
+
async withdraw(requestId) {
|
|
290
|
+
const status = (await this.call("changeRequests/withdraw", { requestId }));
|
|
291
|
+
this.remember([status]);
|
|
292
|
+
return status;
|
|
293
|
+
}
|
|
294
|
+
async confirm(params) {
|
|
295
|
+
const status = (await this.call("changeRequests/confirm", params));
|
|
296
|
+
const data = this.ledger.load();
|
|
297
|
+
const entry = data.requests[params.requestId];
|
|
298
|
+
if (entry) {
|
|
299
|
+
entry.confirmed = params.outcome;
|
|
300
|
+
this.ledger.save(data);
|
|
301
|
+
}
|
|
302
|
+
return status;
|
|
303
|
+
}
|
|
304
|
+
// ---- Inbox and confirmation ----------------------------------------------
|
|
305
|
+
/**
|
|
306
|
+
* Looks at any result from this server. When it announces updates and the client may
|
|
307
|
+
* act on them, reads the inbox. When the client must not act (no consent, ephemeral),
|
|
308
|
+
* removes the notice line so the model never sees it (SEP section 9). Also returns the
|
|
309
|
+
* notice line and the content to show the model, as modelContent() does.
|
|
310
|
+
*/
|
|
311
|
+
async inspect(result) {
|
|
312
|
+
const updates = this.announced(result);
|
|
313
|
+
// Work out the line before reading the inbox: reading it clears the server's count.
|
|
314
|
+
const notice = await this.noticeLine(result);
|
|
315
|
+
const changesNotice = await this.changesNoticeLine(result);
|
|
316
|
+
const modelContent = this.render(result, [notice, changesNotice]);
|
|
317
|
+
if (!allowed(this.options)) {
|
|
318
|
+
const content = Array.isArray(result.content) ? result.content : [];
|
|
319
|
+
return {
|
|
320
|
+
updates: 0,
|
|
321
|
+
changes: 0,
|
|
322
|
+
result: { ...result, content: content.filter((c) => !isNoticeBlock(c)) },
|
|
323
|
+
notice,
|
|
324
|
+
changesNotice,
|
|
325
|
+
modelContent,
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
const changes = this.announcedChanges(result);
|
|
329
|
+
if (updates > 0 && this.enabled()) {
|
|
330
|
+
return { updates, changes, result, inbox: await this.checkInbox(), notice, changesNotice, modelContent };
|
|
331
|
+
}
|
|
332
|
+
return { updates, changes, result, notice, changesNotice, modelContent };
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* The update notice line the model should see for this result, or null (SEP section 7).
|
|
336
|
+
* Null when the client must withhold the notice (no consent, ephemeral: section 9) or no
|
|
337
|
+
* update is announced. Reuses the server's own line when the text carries one. Otherwise
|
|
338
|
+
* builds the fixed line from the _meta count, naming inboxToolName, or the server's
|
|
339
|
+
* change_requests_list when the server lists it. The line never carries request content.
|
|
340
|
+
*/
|
|
341
|
+
async noticeLine(result) {
|
|
342
|
+
if (!allowed(this.options))
|
|
343
|
+
return null;
|
|
344
|
+
const content = Array.isArray(result.content) ? result.content : [];
|
|
345
|
+
const serverLine = content.find(isUpdateBlock);
|
|
346
|
+
if (serverLine)
|
|
347
|
+
return serverLine.text;
|
|
348
|
+
const count = this.announced(result);
|
|
349
|
+
if (count <= 0)
|
|
350
|
+
return null;
|
|
351
|
+
const tool = this.options.inboxToolName ?? ((await this.serverHasTool(DEFAULT_INBOX_TOOL)) ? DEFAULT_INBOX_TOOL : null);
|
|
352
|
+
return tool ? updateNoticeLine(count, tool) : null;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* What a host should show the model for a tool result. A host that shows the model a
|
|
356
|
+
* tool's structuredContent in place of its text drops the server's notice line, so the
|
|
357
|
+
* duty to carry it falls on the client (SEP section 7). This returns the structured
|
|
358
|
+
* content as JSON text followed by the notice line, or, for a result without structured
|
|
359
|
+
* content, its text with the notice line removed when the client must withhold it.
|
|
360
|
+
*/
|
|
361
|
+
async modelContent(result) {
|
|
362
|
+
return this.render(result, [await this.noticeLine(result), await this.changesNoticeLine(result)]);
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* The changes line the model should see for this result, or null (SEP section 12). It
|
|
366
|
+
* follows the rules for the update line: withheld without consent or in an ephemeral
|
|
367
|
+
* session, the server's own line when present, otherwise built from _meta.changes
|
|
368
|
+
* naming whatsNewToolName or the server's whats_new when the server lists it.
|
|
369
|
+
*/
|
|
370
|
+
async changesNoticeLine(result) {
|
|
371
|
+
if (!allowed(this.options))
|
|
372
|
+
return null;
|
|
373
|
+
const content = Array.isArray(result.content) ? result.content : [];
|
|
374
|
+
const serverLine = content.find(isChangesBlock);
|
|
375
|
+
if (serverLine)
|
|
376
|
+
return serverLine.text;
|
|
377
|
+
const count = this.announcedChanges(result);
|
|
378
|
+
if (count <= 0)
|
|
379
|
+
return null;
|
|
380
|
+
const tool = this.options.whatsNewToolName ?? ((await this.serverHasTool(DEFAULT_CHANGES_TOOL)) ? DEFAULT_CHANGES_TOOL : null);
|
|
381
|
+
return tool ? changesNoticeLine(count, tool) : null;
|
|
382
|
+
}
|
|
383
|
+
render(result, notices) {
|
|
384
|
+
const content = Array.isArray(result.content) ? result.content : [];
|
|
385
|
+
const lines = notices.filter((n) => Boolean(n)).map((text) => ({ type: "text", text }));
|
|
386
|
+
if (result.structuredContent !== undefined && result.structuredContent !== null) {
|
|
387
|
+
return [{ type: "text", text: JSON.stringify(result.structuredContent) }, ...lines];
|
|
388
|
+
}
|
|
389
|
+
return [...textBlocks(content.filter((c) => !isNoticeBlock(c))), ...lines];
|
|
390
|
+
}
|
|
391
|
+
/** The unread changes count a result announces, from _meta or else from the text line. */
|
|
392
|
+
announcedChanges(result) {
|
|
393
|
+
const fromMeta = result._meta?.[this.extensionId]?.changes;
|
|
394
|
+
if (typeof fromMeta === "number" && fromMeta > 0)
|
|
395
|
+
return fromMeta;
|
|
396
|
+
const content = Array.isArray(result.content) ? result.content : [];
|
|
397
|
+
const line = content.find(isChangesBlock);
|
|
398
|
+
const match = line ? CHANGES_NOTICE_LINE.exec(line.text) : null;
|
|
399
|
+
return match ? Number(match[1]) : 0;
|
|
400
|
+
}
|
|
401
|
+
/** The update count a result announces, from _meta or else from the text line. */
|
|
402
|
+
announced(result) {
|
|
403
|
+
const fromMeta = result._meta?.[this.extensionId]?.updates;
|
|
404
|
+
if (typeof fromMeta === "number" && fromMeta > 0)
|
|
405
|
+
return fromMeta;
|
|
406
|
+
const content = Array.isArray(result.content) ? result.content : [];
|
|
407
|
+
const line = content.find(isUpdateBlock);
|
|
408
|
+
const match = line ? NOTICE_LINE.exec(line.text) : null;
|
|
409
|
+
return match ? Number(match[1]) : 0;
|
|
410
|
+
}
|
|
411
|
+
async serverHasTool(name) {
|
|
412
|
+
if (!this.client.getServerCapabilities()?.tools)
|
|
413
|
+
return false;
|
|
414
|
+
this.serverToolNames ??= (async () => {
|
|
415
|
+
const names = new Set();
|
|
416
|
+
let cursor;
|
|
417
|
+
do {
|
|
418
|
+
const page = await this.client.listTools(cursor ? { cursor } : {});
|
|
419
|
+
for (const tool of page.tools)
|
|
420
|
+
names.add(tool.name);
|
|
421
|
+
cursor = page.nextCursor;
|
|
422
|
+
} while (cursor);
|
|
423
|
+
return names;
|
|
424
|
+
})().catch(() => {
|
|
425
|
+
this.serverToolNames = null;
|
|
426
|
+
return new Set();
|
|
427
|
+
});
|
|
428
|
+
return (await this.serverToolNames).has(name);
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Reads the inbox and returns what changed since the client last looked. Shipped
|
|
432
|
+
* requests with an obsolete workaround are marked in the ledger and passed to onShipped.
|
|
433
|
+
*/
|
|
434
|
+
async checkInbox() {
|
|
435
|
+
const before = this.ledger.load();
|
|
436
|
+
const updated = [];
|
|
437
|
+
let cursor;
|
|
438
|
+
do {
|
|
439
|
+
const page = await this.list(cursor ? { cursor } : {});
|
|
440
|
+
for (const status of page.requests) {
|
|
441
|
+
const known = before.requests[status.requestId];
|
|
442
|
+
if (!known || known.status !== status.status || known.updatedAt !== status.updatedAt)
|
|
443
|
+
updated.push(status);
|
|
444
|
+
}
|
|
445
|
+
cursor = page.nextCursor;
|
|
446
|
+
} while (cursor);
|
|
447
|
+
const shipped = updated.filter((s) => s.status === "shipped" && s.resolution?.workaroundObsolete === true);
|
|
448
|
+
const after = this.ledger.load();
|
|
449
|
+
for (const status of shipped) {
|
|
450
|
+
const entry = after.requests[status.requestId];
|
|
451
|
+
if (!entry || before.requests[status.requestId]?.workaroundObsolete)
|
|
452
|
+
continue;
|
|
453
|
+
await this.options.onShipped?.(status, entry);
|
|
454
|
+
}
|
|
455
|
+
return { updated, shipped };
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Re-runs the acceptance tests this client sent with a shipped request, under its own
|
|
459
|
+
* authorization, and confirms with the per-test outcomes.
|
|
460
|
+
*/
|
|
461
|
+
async retestAndConfirm(requestId, note) {
|
|
462
|
+
const entry = this.ledger.load().requests[requestId];
|
|
463
|
+
const tests = entry?.acceptanceTests ?? [];
|
|
464
|
+
if (tests.length === 0)
|
|
465
|
+
throw new Error("No acceptance tests recorded for this request. Call confirm() with your own outcome.");
|
|
466
|
+
const runs = [];
|
|
467
|
+
for (const test of tests)
|
|
468
|
+
runs.push(await runAcceptanceTest(this.client, test));
|
|
469
|
+
const outcome = runs.every((r) => r.outcome === "pass") ? "pass" : "fail";
|
|
470
|
+
const reasons = runs.flatMap((r, i) => r.reasons.map((reason) => `test ${i}: ${reason}`));
|
|
471
|
+
const params = { requestId, outcome, tests: runs.map((r, index) => ({ index, outcome: r.outcome })) };
|
|
472
|
+
const text = note ?? (reasons.length ? reasons.join("; ") : undefined);
|
|
473
|
+
if (text)
|
|
474
|
+
params.note = text.slice(0, 1000);
|
|
475
|
+
return { outcome, status: await this.confirm(params) };
|
|
476
|
+
}
|
|
477
|
+
/** What the ledger knows, for showing the user or a later session. */
|
|
478
|
+
entries() {
|
|
479
|
+
return Object.values(this.ledger.load().requests);
|
|
480
|
+
}
|
|
481
|
+
// ---- Helpers --------------------------------------------------------------
|
|
482
|
+
async call(method, params) {
|
|
483
|
+
if (!this.enabled())
|
|
484
|
+
throw new Error("Change requests are not enabled for this server.");
|
|
485
|
+
const withMeta = { ...params, _meta: { [CLIENT_CAPABILITIES_META_KEY]: { extensions: { [this.extensionId]: {} } } } };
|
|
486
|
+
return (await this.client.request({ method, params: withMeta }, ResultSchema));
|
|
487
|
+
}
|
|
488
|
+
/** An open request of this client's for the same target, checked against the server. */
|
|
489
|
+
async findOpen(target, data) {
|
|
490
|
+
const isOpen = (s) => !TERMINAL_STATUSES.includes(s);
|
|
491
|
+
const candidates = Object.values(data.requests).filter((e) => sameTarget(target, e.target) && isOpen(e.status));
|
|
492
|
+
for (const candidate of candidates) {
|
|
493
|
+
try {
|
|
494
|
+
const status = await this.get(candidate.requestId);
|
|
495
|
+
if (isOpen(status.status))
|
|
496
|
+
return status;
|
|
497
|
+
}
|
|
498
|
+
catch {
|
|
499
|
+
// Gone from the server: not a reason to skip filing.
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
return null;
|
|
503
|
+
}
|
|
504
|
+
remember(statuses) {
|
|
505
|
+
const data = this.ledger.load();
|
|
506
|
+
let changed = false;
|
|
507
|
+
for (const status of statuses) {
|
|
508
|
+
const entry = data.requests[status.requestId];
|
|
509
|
+
if (!entry)
|
|
510
|
+
continue;
|
|
511
|
+
entry.status = status.status;
|
|
512
|
+
entry.updatedAt = status.updatedAt;
|
|
513
|
+
if (status.status === "shipped" && status.resolution?.workaroundObsolete)
|
|
514
|
+
entry.workaroundObsolete = true;
|
|
515
|
+
changed = true;
|
|
516
|
+
}
|
|
517
|
+
if (changed)
|
|
518
|
+
this.ledger.save(data);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,YAAY,EAAkD,MAAM,aAAa,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAA6C,MAAM,aAAa,CAAC;AAC1F,OAAO,EACL,iBAAiB,GAOlB,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,4BAA4B,GAAG,4CAA4C,CAAC;AAiFzF,gGAAgG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,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;YAC7B,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;YACnC,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,UAAU,EAAE,kBAAkB;gBAAE,KAAK,CAAC,kBAAkB,GAAG,IAAI,CAAC;YAC1G,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;QACD,IAAI,OAAO;YAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export { ChangeRequestsClient, changeRequestsCapabilities, CLIENT_CAPABILITIES_META_KEY, updateNoticeLine, changesNoticeLine, type ChangeRequestsClientOptions, type ConsentOptions, type InboxCheck, type Inspection, type SubmitOutcome, type ToolResultLike, } from "./client.js";
|
|
3
|
+
export { runAcceptanceTest, type TestRun } from "./acceptance.js";
|
|
4
|
+
export { DEFAULT_RULES, Redactor, redactSubmission, type RedactOptions, type RedactionFinding, type RedactionRule } from "./redact.js";
|
|
5
|
+
export { FileLedger, MemoryLedger, type Ledger, type LedgerData, type LedgerEntry } from "./ledger.js";
|
|
6
|
+
export { ChangesFeed, FileChangesLedger, MemoryChangesLedger, CHANGES_NOTICE_LINE, changesCount, isNotable, type ChangesCheck, type ChangesFeedOptions, type ChangesLedger, type ChangesLedgerData, } from "./changes.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export { ChangeRequestsClient, changeRequestsCapabilities, CLIENT_CAPABILITIES_META_KEY, updateNoticeLine, changesNoticeLine, } from "./client.js";
|
|
3
|
+
export { runAcceptanceTest } from "./acceptance.js";
|
|
4
|
+
export { DEFAULT_RULES, Redactor, redactSubmission } from "./redact.js";
|
|
5
|
+
export { FileLedger, MemoryLedger } from "./ledger.js";
|
|
6
|
+
export { ChangesFeed, FileChangesLedger, MemoryChangesLedger, CHANGES_NOTICE_LINE, changesCount, isNotable, } from "./changes.js";
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,4BAA4B,EAC5B,gBAAgB,EAChB,iBAAiB,GAOlB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAgB,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,gBAAgB,EAAiE,MAAM,aAAa,CAAC;AACvI,OAAO,EAAE,UAAU,EAAE,YAAY,EAAkD,MAAM,aAAa,CAAC;AACvG,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,SAAS,GAKV,MAAM,cAAc,CAAC"}
|
package/dist/ledger.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AcceptanceTest, Status, Target } from "./types.js";
|
|
2
|
+
export interface LedgerEntry {
|
|
3
|
+
requestId: string;
|
|
4
|
+
title: string;
|
|
5
|
+
target?: Target;
|
|
6
|
+
acceptanceTests?: AcceptanceTest[];
|
|
7
|
+
/** The workaround this client uses until the request ships. */
|
|
8
|
+
workaround?: string;
|
|
9
|
+
status: Status;
|
|
10
|
+
submittedAt: string;
|
|
11
|
+
updatedAt: string;
|
|
12
|
+
/** Set when the server says the change shipped and the workaround is no longer needed. */
|
|
13
|
+
workaroundObsolete?: boolean;
|
|
14
|
+
/** For a request filed without a signed-in principal: the ticket that reads it. A credential; never shown to the model. */
|
|
15
|
+
ticket?: string;
|
|
16
|
+
/** The client's own verdict, once it has re-run its tests. */
|
|
17
|
+
confirmed?: "pass" | "fail";
|
|
18
|
+
}
|
|
19
|
+
export interface LedgerData {
|
|
20
|
+
requests: Record<string, LedgerEntry>;
|
|
21
|
+
/** Submissions per UTC day, for the client-side cap. */
|
|
22
|
+
submissions: Record<string, number>;
|
|
23
|
+
}
|
|
24
|
+
export interface Ledger {
|
|
25
|
+
load(): LedgerData;
|
|
26
|
+
save(data: LedgerData): void;
|
|
27
|
+
}
|
|
28
|
+
export declare class MemoryLedger implements Ledger {
|
|
29
|
+
private data;
|
|
30
|
+
load(): LedgerData;
|
|
31
|
+
save(data: LedgerData): void;
|
|
32
|
+
}
|
|
33
|
+
/** A ledger in one JSON file per server, for clients whose sessions come and go. */
|
|
34
|
+
export declare class FileLedger implements Ledger {
|
|
35
|
+
private readonly path;
|
|
36
|
+
constructor(path: string);
|
|
37
|
+
load(): LedgerData;
|
|
38
|
+
save(data: LedgerData): void;
|
|
39
|
+
}
|