mcp-feedback 0.0.0-stage → 0.1.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 +88 -2
- package/dist/cli.d.ts +11 -0
- package/dist/cli.js +249 -0
- package/dist/cli.js.map +1 -0
- package/dist/conformance-cases.d.ts +31 -0
- package/dist/conformance-cases.js +131 -0
- package/dist/conformance-cases.js.map +1 -0
- package/dist/identity.d.ts +29 -0
- package/dist/identity.js +21 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/reader.d.ts +21 -0
- package/dist/reader.js +59 -0
- package/dist/reader.js.map +1 -0
- package/dist/register.d.ts +49 -0
- package/dist/register.js +173 -0
- package/dist/register.js.map +1 -0
- package/dist/store.d.ts +27 -0
- package/dist/store.js +46 -0
- package/dist/store.js.map +1 -0
- package/dist/stores/memory.d.ts +3 -0
- package/dist/stores/memory.js +57 -0
- package/dist/stores/memory.js.map +1 -0
- package/dist/stores/postgres.d.ts +14 -0
- package/dist/stores/postgres.js +25 -0
- package/dist/stores/postgres.js.map +1 -0
- package/dist/stores/sql.d.ts +16 -0
- package/dist/stores/sql.js +217 -0
- package/dist/stores/sql.js.map +1 -0
- package/dist/stores/sqlite.d.ts +8 -0
- package/dist/stores/sqlite.js +36 -0
- package/dist/stores/sqlite.js.map +1 -0
- package/dist/testing.d.ts +8 -0
- package/dist/testing.js +65 -0
- package/dist/testing.js.map +1 -0
- package/dist/tools.d.ts +169 -0
- package/dist/tools.js +142 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +92 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/package.json +76 -4
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// SQL shared by the SQLite and Postgres stores. Statements are written with
|
|
2
|
+
// `?` placeholders; the Postgres store renumbers them to `$n`.
|
|
3
|
+
import { decodeCursor, encodeCursor, toolNamesOf } from "../store.js";
|
|
4
|
+
export const DEFAULT_TABLE = "mcp_feedback";
|
|
5
|
+
export function checkTableName(table) {
|
|
6
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]{0,62}$/.test(table))
|
|
7
|
+
throw new Error(`Invalid feedback table name: ${table}`);
|
|
8
|
+
return table;
|
|
9
|
+
}
|
|
10
|
+
const COLUMNS = [
|
|
11
|
+
"id",
|
|
12
|
+
"schema_version",
|
|
13
|
+
"created_at",
|
|
14
|
+
"updated_at",
|
|
15
|
+
"kind",
|
|
16
|
+
"title",
|
|
17
|
+
"body",
|
|
18
|
+
"severity",
|
|
19
|
+
"status",
|
|
20
|
+
"tags",
|
|
21
|
+
"tool_names",
|
|
22
|
+
"context",
|
|
23
|
+
"subject",
|
|
24
|
+
"client_id",
|
|
25
|
+
"session_id",
|
|
26
|
+
"token_fingerprint",
|
|
27
|
+
"scopes",
|
|
28
|
+
"client_name",
|
|
29
|
+
"client_version",
|
|
30
|
+
"user_agent",
|
|
31
|
+
"server_name",
|
|
32
|
+
"server_version",
|
|
33
|
+
"triage_note",
|
|
34
|
+
"triaged_by",
|
|
35
|
+
];
|
|
36
|
+
const JSON_COLUMNS = new Set(["tags", "tool_names", "context", "scopes"]);
|
|
37
|
+
/** DDL matching spec/sql/*.sql. */
|
|
38
|
+
export function schemaStatements(dialect, table) {
|
|
39
|
+
const json = dialect === "postgres" ? "JSONB" : "TEXT";
|
|
40
|
+
return [
|
|
41
|
+
`CREATE TABLE IF NOT EXISTS ${table} (
|
|
42
|
+
id TEXT PRIMARY KEY,
|
|
43
|
+
schema_version INTEGER NOT NULL,
|
|
44
|
+
created_at TEXT NOT NULL,
|
|
45
|
+
updated_at TEXT NOT NULL,
|
|
46
|
+
kind TEXT NOT NULL,
|
|
47
|
+
title TEXT NOT NULL,
|
|
48
|
+
body TEXT NOT NULL,
|
|
49
|
+
severity TEXT NOT NULL,
|
|
50
|
+
status TEXT NOT NULL,
|
|
51
|
+
tags ${json} NOT NULL,
|
|
52
|
+
tool_names ${json} NOT NULL,
|
|
53
|
+
context ${json} NOT NULL,
|
|
54
|
+
subject TEXT,
|
|
55
|
+
client_id TEXT,
|
|
56
|
+
session_id TEXT,
|
|
57
|
+
token_fingerprint TEXT,
|
|
58
|
+
scopes ${json} NOT NULL,
|
|
59
|
+
client_name TEXT,
|
|
60
|
+
client_version TEXT,
|
|
61
|
+
user_agent TEXT,
|
|
62
|
+
server_name TEXT,
|
|
63
|
+
server_version TEXT,
|
|
64
|
+
triage_note TEXT,
|
|
65
|
+
triaged_by TEXT
|
|
66
|
+
)`,
|
|
67
|
+
`CREATE INDEX IF NOT EXISTS ${table}_created_idx ON ${table} (created_at DESC, id DESC)`,
|
|
68
|
+
`CREATE INDEX IF NOT EXISTS ${table}_status_idx ON ${table} (status)`,
|
|
69
|
+
`CREATE INDEX IF NOT EXISTS ${table}_kind_idx ON ${table} (kind)`,
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
function toRow(record) {
|
|
73
|
+
return {
|
|
74
|
+
id: record.id,
|
|
75
|
+
schema_version: record.schema_version,
|
|
76
|
+
created_at: record.created_at,
|
|
77
|
+
updated_at: record.updated_at,
|
|
78
|
+
kind: record.kind,
|
|
79
|
+
title: record.title,
|
|
80
|
+
body: record.body,
|
|
81
|
+
severity: record.severity,
|
|
82
|
+
status: record.status,
|
|
83
|
+
tags: JSON.stringify(record.tags),
|
|
84
|
+
tool_names: JSON.stringify(toolNamesOf(record)),
|
|
85
|
+
context: JSON.stringify(record.context),
|
|
86
|
+
subject: record.identity.subject,
|
|
87
|
+
client_id: record.identity.client_id,
|
|
88
|
+
session_id: record.identity.session_id,
|
|
89
|
+
token_fingerprint: record.identity.token_fingerprint,
|
|
90
|
+
scopes: JSON.stringify(record.identity.scopes),
|
|
91
|
+
client_name: record.identity.client_name,
|
|
92
|
+
client_version: record.identity.client_version,
|
|
93
|
+
user_agent: record.identity.user_agent,
|
|
94
|
+
server_name: record.server.name,
|
|
95
|
+
server_version: record.server.version,
|
|
96
|
+
triage_note: record.triage_note,
|
|
97
|
+
triaged_by: record.triaged_by,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
// SQLite returns JSON columns as text, Postgres as parsed values.
|
|
101
|
+
const parsed = (value) => (typeof value === "string" ? JSON.parse(value) : value);
|
|
102
|
+
const text = (value) => (value == null ? null : String(value));
|
|
103
|
+
function fromRow(row) {
|
|
104
|
+
return {
|
|
105
|
+
schema_version: Number(row.schema_version),
|
|
106
|
+
id: String(row.id),
|
|
107
|
+
created_at: String(row.created_at),
|
|
108
|
+
kind: row.kind,
|
|
109
|
+
title: String(row.title),
|
|
110
|
+
body: String(row.body),
|
|
111
|
+
severity: row.severity,
|
|
112
|
+
tags: parsed(row.tags),
|
|
113
|
+
context: parsed(row.context),
|
|
114
|
+
identity: {
|
|
115
|
+
subject: text(row.subject),
|
|
116
|
+
client_id: text(row.client_id),
|
|
117
|
+
session_id: text(row.session_id),
|
|
118
|
+
token_fingerprint: text(row.token_fingerprint),
|
|
119
|
+
scopes: parsed(row.scopes),
|
|
120
|
+
client_name: text(row.client_name),
|
|
121
|
+
client_version: text(row.client_version),
|
|
122
|
+
user_agent: text(row.user_agent),
|
|
123
|
+
},
|
|
124
|
+
server: { name: text(row.server_name), version: text(row.server_version) },
|
|
125
|
+
status: row.status,
|
|
126
|
+
triage_note: text(row.triage_note),
|
|
127
|
+
triaged_by: text(row.triaged_by),
|
|
128
|
+
updated_at: String(row.updated_at),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function where(dialect, filter) {
|
|
132
|
+
const clauses = [];
|
|
133
|
+
const params = [];
|
|
134
|
+
const add = (clause, ...values) => {
|
|
135
|
+
clauses.push(clause);
|
|
136
|
+
params.push(...values);
|
|
137
|
+
};
|
|
138
|
+
const contains = (column, value) => dialect === "postgres"
|
|
139
|
+
? add(`f.${column} @> ?::jsonb`, JSON.stringify([value]))
|
|
140
|
+
: add(`EXISTS (SELECT 1 FROM json_each(f.${column}) WHERE value = ?)`, value);
|
|
141
|
+
if (filter.kind !== undefined)
|
|
142
|
+
add("f.kind = ?", filter.kind);
|
|
143
|
+
if (filter.status !== undefined)
|
|
144
|
+
add("f.status = ?", filter.status);
|
|
145
|
+
if (filter.severity !== undefined)
|
|
146
|
+
add("f.severity = ?", filter.severity);
|
|
147
|
+
if (filter.subject !== undefined)
|
|
148
|
+
add("f.subject = ?", filter.subject);
|
|
149
|
+
if (filter.tool !== undefined)
|
|
150
|
+
contains("tool_names", filter.tool);
|
|
151
|
+
if (filter.tag !== undefined)
|
|
152
|
+
contains("tags", filter.tag);
|
|
153
|
+
if (filter.since !== undefined)
|
|
154
|
+
add("f.created_at >= ?", filter.since);
|
|
155
|
+
if (filter.until !== undefined)
|
|
156
|
+
add("f.created_at < ?", filter.until);
|
|
157
|
+
return { clauses, params };
|
|
158
|
+
}
|
|
159
|
+
const whereSql = (clauses) => (clauses.length ? ` WHERE ${clauses.join(" AND ")}` : "");
|
|
160
|
+
export function sqlOperations(dialect, table, run) {
|
|
161
|
+
const placeholder = (column) => (dialect === "postgres" && JSON_COLUMNS.has(column) ? "?::jsonb" : "?");
|
|
162
|
+
const get = async (id) => {
|
|
163
|
+
const [row] = await run(`SELECT * FROM ${table} f WHERE f.id = ?`, [id]);
|
|
164
|
+
return row ? fromRow(row) : null;
|
|
165
|
+
};
|
|
166
|
+
return {
|
|
167
|
+
async insert(record) {
|
|
168
|
+
const row = toRow(record);
|
|
169
|
+
await run(`INSERT INTO ${table} (${COLUMNS.join(", ")}) VALUES (${COLUMNS.map(placeholder).join(", ")})`, COLUMNS.map((column) => row[column]));
|
|
170
|
+
},
|
|
171
|
+
get,
|
|
172
|
+
async list(query) {
|
|
173
|
+
const { clauses, params } = where(dialect, query);
|
|
174
|
+
if (query.cursor) {
|
|
175
|
+
const after = decodeCursor(query.cursor);
|
|
176
|
+
clauses.push("(f.created_at < ? OR (f.created_at = ? AND f.id < ?))");
|
|
177
|
+
params.push(after.created_at, after.created_at, after.id);
|
|
178
|
+
}
|
|
179
|
+
const rows = await run(`SELECT * FROM ${table} f${whereSql(clauses)} ORDER BY f.created_at DESC, f.id DESC LIMIT ?`, [...params, query.limit + 1]);
|
|
180
|
+
const items = rows.slice(0, query.limit).map(fromRow);
|
|
181
|
+
const last = items[items.length - 1];
|
|
182
|
+
return { items, next_cursor: rows.length > query.limit && last ? encodeCursor(last) : null };
|
|
183
|
+
},
|
|
184
|
+
async updateTriage(id, patch) {
|
|
185
|
+
const sets = ["triaged_by = ?", "updated_at = ?"];
|
|
186
|
+
const params = [patch.triaged_by, patch.updated_at];
|
|
187
|
+
if (patch.status !== undefined) {
|
|
188
|
+
sets.push("status = ?");
|
|
189
|
+
params.push(patch.status);
|
|
190
|
+
}
|
|
191
|
+
if (patch.triage_note !== undefined) {
|
|
192
|
+
sets.push("triage_note = ?");
|
|
193
|
+
params.push(patch.triage_note);
|
|
194
|
+
}
|
|
195
|
+
await run(`UPDATE ${table} SET ${sets.join(", ")} WHERE id = ?`, [...params, id]);
|
|
196
|
+
return get(id);
|
|
197
|
+
},
|
|
198
|
+
async stats(filter) {
|
|
199
|
+
const { clauses, params } = where(dialect, filter);
|
|
200
|
+
const filterSql = whereSql(clauses);
|
|
201
|
+
const counts = async (sql) => Object.fromEntries((await run(sql, params)).map((row) => [String(row.k), Number(row.c)]));
|
|
202
|
+
const grouped = (column) => counts(`SELECT f.${column} AS k, COUNT(*) AS c FROM ${table} f${filterSql} GROUP BY f.${column}`);
|
|
203
|
+
const each = dialect === "postgres"
|
|
204
|
+
? "CROSS JOIN LATERAL jsonb_array_elements_text(f.tool_names) AS j(value)"
|
|
205
|
+
: ", json_each(f.tool_names) AS j";
|
|
206
|
+
const [total] = await run(`SELECT COUNT(*) AS c FROM ${table} f${filterSql}`, params);
|
|
207
|
+
return {
|
|
208
|
+
total: Number(total?.c ?? 0),
|
|
209
|
+
by_kind: await grouped("kind"),
|
|
210
|
+
by_status: await grouped("status"),
|
|
211
|
+
by_severity: await grouped("severity"),
|
|
212
|
+
by_tool: await counts(`SELECT j.value AS k, COUNT(*) AS c FROM ${table} f ${each}${filterSql} GROUP BY j.value`),
|
|
213
|
+
};
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=sql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql.js","sourceRoot":"","sources":["../../src/stores/sql.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,+DAA+D;AAE/D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAgBtE,MAAM,CAAC,MAAM,aAAa,GAAG,cAAc,CAAC;AAE5C,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,IAAI,CAAC,+BAA+B,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,KAAK,EAAE,CAAC,CAAC;IAC3G,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,OAAO,GAAG;IACd,IAAI;IACJ,gBAAgB;IAChB,YAAY;IACZ,YAAY;IACZ,MAAM;IACN,OAAO;IACP,MAAM;IACN,UAAU;IACV,QAAQ;IACR,MAAM;IACN,YAAY;IACZ,SAAS;IACT,SAAS;IACT,WAAW;IACX,YAAY;IACZ,mBAAmB;IACnB,QAAQ;IACR,aAAa;IACb,gBAAgB;IAChB,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,aAAa;IACb,YAAY;CACJ,CAAC;AAEX,MAAM,YAAY,GAAG,IAAI,GAAG,CAAS,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AAElF,mCAAmC;AACnC,MAAM,UAAU,gBAAgB,CAAC,OAAgB,EAAE,KAAa;IAC9D,MAAM,IAAI,GAAG,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC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|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FeedbackStore } from "../store.js";
|
|
2
|
+
export interface SqliteStoreOptions {
|
|
3
|
+
/** Database file. Defaults to `./mcp-feedback.db`; use `:memory:` for a throwaway store. */
|
|
4
|
+
path?: string;
|
|
5
|
+
table?: string;
|
|
6
|
+
}
|
|
7
|
+
/** Default store: a standalone SQLite file, using Node's built-in `node:sqlite`. */
|
|
8
|
+
export declare function sqliteStore(options?: SqliteStoreOptions): FeedbackStore;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DatabaseSync } from "node:sqlite";
|
|
2
|
+
import { DEFAULT_TABLE, checkTableName, schemaStatements, sqlOperations } from "./sql.js";
|
|
3
|
+
/** Default store: a standalone SQLite file, using Node's built-in `node:sqlite`. */
|
|
4
|
+
export function sqliteStore(options = {}) {
|
|
5
|
+
const path = options.path ?? "./mcp-feedback.db";
|
|
6
|
+
const table = checkTableName(options.table ?? DEFAULT_TABLE);
|
|
7
|
+
let db;
|
|
8
|
+
// Opened on first use so importing a server module never touches the disk.
|
|
9
|
+
const open = () => {
|
|
10
|
+
if (!db) {
|
|
11
|
+
const opened = new DatabaseSync(path);
|
|
12
|
+
opened.exec("PRAGMA busy_timeout = 5000");
|
|
13
|
+
if (path !== ":memory:")
|
|
14
|
+
opened.exec("PRAGMA journal_mode = WAL");
|
|
15
|
+
for (const statement of schemaStatements("sqlite", table))
|
|
16
|
+
opened.exec(statement);
|
|
17
|
+
db = opened;
|
|
18
|
+
}
|
|
19
|
+
return db;
|
|
20
|
+
};
|
|
21
|
+
const operations = sqlOperations("sqlite", table, async (sql, params) => {
|
|
22
|
+
const statement = open().prepare(sql);
|
|
23
|
+
if (/^\s*SELECT/i.test(sql))
|
|
24
|
+
return statement.all(...params);
|
|
25
|
+
statement.run(...params);
|
|
26
|
+
return [];
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
...operations,
|
|
30
|
+
async close() {
|
|
31
|
+
db?.close();
|
|
32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AI,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC;YAAE,OAAO,SAAS,CAAC,GAAG,CAAC,GAAI,MAA0B,CAAU,CAAC;QAC3F,SAAS,CAAC,GAAG,CAAC,GAAI,MAA0B,CAAC,CAAC;QAC9C,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,UAAU;QACb,KAAK,CAAC,KAAK;YACT,EAAE,EAAE,KAAK,EAAE,CAAC;YACZ,EAAE,GAAG,SAAS,CAAC;QACjB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { conformanceCases, conformanceRecords, type StoreCase } from "./conformance-cases.js";
|
|
2
|
+
import type { FeedbackStore } from "./store.js";
|
|
3
|
+
export { conformanceCases, conformanceRecords, type StoreCase };
|
|
4
|
+
/**
|
|
5
|
+
* Checks a store against the contract in spec/store-contract.md. Pass a store
|
|
6
|
+
* that is empty; the suite seeds it. Rejects with the first failing case.
|
|
7
|
+
*/
|
|
8
|
+
export declare function runStoreConformance(store: FeedbackStore): Promise<void>;
|
package/dist/testing.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { conformanceCases, conformanceRecords } from "./conformance-cases.js";
|
|
3
|
+
export { conformanceCases, conformanceRecords };
|
|
4
|
+
async function runCase(store, testCase) {
|
|
5
|
+
switch (testCase.op) {
|
|
6
|
+
case "list": {
|
|
7
|
+
const pages = [];
|
|
8
|
+
let cursor;
|
|
9
|
+
do {
|
|
10
|
+
const page = await store.list({ ...testCase.filter, limit: testCase.limit, cursor });
|
|
11
|
+
pages.push(page.items.map((item) => item.id));
|
|
12
|
+
cursor = page.next_cursor ?? undefined;
|
|
13
|
+
assert.ok(pages.length <= testCase.expect_pages.length, "store returned more pages than expected");
|
|
14
|
+
} while (cursor);
|
|
15
|
+
assert.deepEqual(pages, testCase.expect_pages);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
case "get": {
|
|
19
|
+
const expected = conformanceRecords.find((record) => record.id === testCase.id) ?? null;
|
|
20
|
+
assert.equal(expected !== null, testCase.expect_found);
|
|
21
|
+
assert.deepEqual(await store.get(testCase.id), expected);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
case "stats":
|
|
25
|
+
assert.deepEqual(await store.stats(testCase.filter), testCase.expect);
|
|
26
|
+
return;
|
|
27
|
+
case "insert_duplicate": {
|
|
28
|
+
const existing = conformanceRecords.find((record) => record.id === testCase.id);
|
|
29
|
+
await assert.rejects(store.insert(existing), "inserting an existing id must reject");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
case "update_triage": {
|
|
33
|
+
const updated = await store.updateTriage(testCase.id, testCase.patch);
|
|
34
|
+
if (testCase.expect === null) {
|
|
35
|
+
assert.equal(updated, null);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
assert.ok(updated, "updateTriage must resolve the updated record");
|
|
39
|
+
const reread = await store.get(testCase.id);
|
|
40
|
+
assert.deepEqual(reread, updated);
|
|
41
|
+
for (const [key, value] of Object.entries(testCase.expect)) {
|
|
42
|
+
assert.deepEqual(updated[key], value, key);
|
|
43
|
+
}
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Checks a store against the contract in spec/store-contract.md. Pass a store
|
|
50
|
+
* that is empty; the suite seeds it. Rejects with the first failing case.
|
|
51
|
+
*/
|
|
52
|
+
export async function runStoreConformance(store) {
|
|
53
|
+
// Seed out of order so a store cannot pass by returning insertion order.
|
|
54
|
+
for (const index of [3, 0, 5, 2, 1, 4])
|
|
55
|
+
await store.insert(structuredClone(conformanceRecords[index]));
|
|
56
|
+
for (const testCase of conformanceCases) {
|
|
57
|
+
try {
|
|
58
|
+
await runCase(store, testCase);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
throw new Error(`Store conformance failed: ${testCase.name}`, { cause: error });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAkB,MAAM,wBAAwB,CAAC;AAG9F,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAkB,CAAC;AAEhE,KAAK,UAAU,OAAO,CAAC,KAAoB,EAAE,QAAmB;IAC9D,QAAQ,QAAQ,CAAC,EAAE,EAAE,CAAC;QACpB,KAAK,MAAM,CAAC,CAAC,CAAC;YACZ,MAAM,KAAK,GAAe,EAAE,CAAC;YAC7B,IAAI,MAA0B,CAAC;YAC/B,GAAG,CAAC;gBACF,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;gBACrF,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC9C,MAAM,GAAG,IAAI,CAAC,WAAW,IAAI,SAAS,CAAC;gBACvC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,IAAI,QAAQ,CAAC,YAAY,CAAC,MAAM,EAAE,yCAAyC,CAAC,CAAC;YACrG,CAAC,QAAQ,MAAM,EAAE;YACjB,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;YAC/C,OAAO;QACT,CAAC;QACD,KAAK,KAAK,CAAC,CAAC,CAAC;YACX,MAAM,QAAQ,GAAG,kBAAkB,CAA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C,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAClC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC3D,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,GAA2B,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;YACrE,CAAC;YACD,OAAO;QACT,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,KAAoB;IAC5D,yEAAyE;IACzE,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAAE,MAAM,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,kBAAkB,CAAC,KAAK,CAAE,CAAC,CAAC,CAAC;IACxG,KAAK,MAAM,QAAQ,IAAI,gBAAgB,EAAE,CAAC;QACxC,IAAI,CAAC;YACH,MAAM,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACjC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,6BAA6B,QAAQ,CAAC,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QAClF,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const submitFeedbackShape: {
|
|
3
|
+
kind: z.ZodEnum<["bug", "tool_failure", "feature_request", "friction", "praise", "other"]>;
|
|
4
|
+
title: z.ZodString;
|
|
5
|
+
body: z.ZodString;
|
|
6
|
+
severity: z.ZodOptional<z.ZodEnum<["blocker", "major", "minor", "none"]>>;
|
|
7
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
8
|
+
context: z.ZodOptional<z.ZodObject<{
|
|
9
|
+
goal: z.ZodOptional<z.ZodString>;
|
|
10
|
+
expected: z.ZodOptional<z.ZodString>;
|
|
11
|
+
actual: z.ZodOptional<z.ZodString>;
|
|
12
|
+
workaround: z.ZodOptional<z.ZodString>;
|
|
13
|
+
suggestion: z.ZodOptional<z.ZodString>;
|
|
14
|
+
tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
15
|
+
name: z.ZodString;
|
|
16
|
+
arguments_summary: z.ZodOptional<z.ZodString>;
|
|
17
|
+
error: z.ZodOptional<z.ZodString>;
|
|
18
|
+
is_error: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
name: string;
|
|
21
|
+
arguments_summary?: string | undefined;
|
|
22
|
+
error?: string | undefined;
|
|
23
|
+
is_error?: boolean | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
name: string;
|
|
26
|
+
arguments_summary?: string | undefined;
|
|
27
|
+
error?: string | undefined;
|
|
28
|
+
is_error?: boolean | undefined;
|
|
29
|
+
}>, "many">>;
|
|
30
|
+
repro_steps: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
31
|
+
excerpt: z.ZodOptional<z.ZodString>;
|
|
32
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
goal?: string | undefined;
|
|
35
|
+
expected?: string | undefined;
|
|
36
|
+
actual?: string | undefined;
|
|
37
|
+
workaround?: string | undefined;
|
|
38
|
+
suggestion?: string | undefined;
|
|
39
|
+
tool_calls?: {
|
|
40
|
+
name: string;
|
|
41
|
+
arguments_summary?: string | undefined;
|
|
42
|
+
error?: string | undefined;
|
|
43
|
+
is_error?: boolean | undefined;
|
|
44
|
+
}[] | undefined;
|
|
45
|
+
repro_steps?: string[] | undefined;
|
|
46
|
+
excerpt?: string | undefined;
|
|
47
|
+
metadata?: Record<string, unknown> | undefined;
|
|
48
|
+
}, {
|
|
49
|
+
goal?: string | undefined;
|
|
50
|
+
expected?: string | undefined;
|
|
51
|
+
actual?: string | undefined;
|
|
52
|
+
workaround?: string | undefined;
|
|
53
|
+
suggestion?: string | undefined;
|
|
54
|
+
tool_calls?: {
|
|
55
|
+
name: string;
|
|
56
|
+
arguments_summary?: string | undefined;
|
|
57
|
+
error?: string | undefined;
|
|
58
|
+
is_error?: boolean | undefined;
|
|
59
|
+
}[] | undefined;
|
|
60
|
+
repro_steps?: string[] | undefined;
|
|
61
|
+
excerpt?: string | undefined;
|
|
62
|
+
metadata?: Record<string, unknown> | undefined;
|
|
63
|
+
}>>;
|
|
64
|
+
};
|
|
65
|
+
export declare const listFeedbackShape: {
|
|
66
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
67
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
68
|
+
kind: z.ZodOptional<z.ZodEnum<["bug", "tool_failure", "feature_request", "friction", "praise", "other"]>>;
|
|
69
|
+
status: z.ZodOptional<z.ZodEnum<["new", "triaged", "resolved", "dismissed"]>>;
|
|
70
|
+
severity: z.ZodOptional<z.ZodEnum<["blocker", "major", "minor", "none"]>>;
|
|
71
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
72
|
+
tool: z.ZodOptional<z.ZodString>;
|
|
73
|
+
tag: z.ZodOptional<z.ZodString>;
|
|
74
|
+
since: z.ZodOptional<z.ZodString>;
|
|
75
|
+
until: z.ZodOptional<z.ZodString>;
|
|
76
|
+
};
|
|
77
|
+
export declare const getFeedbackShape: {
|
|
78
|
+
id: z.ZodString;
|
|
79
|
+
};
|
|
80
|
+
export declare const updateFeedbackTriageShape: {
|
|
81
|
+
ids: z.ZodArray<z.ZodString, "many">;
|
|
82
|
+
status: z.ZodOptional<z.ZodEnum<["new", "triaged", "resolved", "dismissed"]>>;
|
|
83
|
+
note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
84
|
+
};
|
|
85
|
+
export declare const feedbackStatsShape: {
|
|
86
|
+
kind: z.ZodOptional<z.ZodEnum<["bug", "tool_failure", "feature_request", "friction", "praise", "other"]>>;
|
|
87
|
+
status: z.ZodOptional<z.ZodEnum<["new", "triaged", "resolved", "dismissed"]>>;
|
|
88
|
+
severity: z.ZodOptional<z.ZodEnum<["blocker", "major", "minor", "none"]>>;
|
|
89
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
90
|
+
tool: z.ZodOptional<z.ZodString>;
|
|
91
|
+
tag: z.ZodOptional<z.ZodString>;
|
|
92
|
+
since: z.ZodOptional<z.ZodString>;
|
|
93
|
+
until: z.ZodOptional<z.ZodString>;
|
|
94
|
+
};
|
|
95
|
+
export declare const synthesizeFeedbackArgsShape: {
|
|
96
|
+
since: z.ZodOptional<z.ZodString>;
|
|
97
|
+
focus: z.ZodOptional<z.ZodString>;
|
|
98
|
+
};
|
|
99
|
+
export declare const SUBMIT_TOOL: {
|
|
100
|
+
readonly name: "submit_feedback";
|
|
101
|
+
readonly title: "Submit feedback";
|
|
102
|
+
readonly description: string;
|
|
103
|
+
readonly annotations: {
|
|
104
|
+
readonly readOnlyHint: false;
|
|
105
|
+
readonly destructiveHint: false;
|
|
106
|
+
readonly idempotentHint: false;
|
|
107
|
+
readonly openWorldHint: false;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
export declare const READER_TOOLS: {
|
|
111
|
+
readonly list: {
|
|
112
|
+
readonly name: "list_feedback";
|
|
113
|
+
readonly title: "List feedback";
|
|
114
|
+
readonly description: "List submitted feedback, newest first, with optional filters. Returns full records and a next_cursor when more remain.";
|
|
115
|
+
readonly annotations: {
|
|
116
|
+
readonly readOnlyHint: true;
|
|
117
|
+
readonly openWorldHint: false;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
readonly get: {
|
|
121
|
+
readonly name: "get_feedback";
|
|
122
|
+
readonly title: "Get feedback";
|
|
123
|
+
readonly description: "Fetch one feedback record by id.";
|
|
124
|
+
readonly annotations: {
|
|
125
|
+
readonly readOnlyHint: true;
|
|
126
|
+
readonly openWorldHint: false;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
readonly triage: {
|
|
130
|
+
readonly name: "update_feedback_triage";
|
|
131
|
+
readonly title: "Update feedback triage";
|
|
132
|
+
readonly description: string;
|
|
133
|
+
readonly annotations: {
|
|
134
|
+
readonly readOnlyHint: false;
|
|
135
|
+
readonly destructiveHint: false;
|
|
136
|
+
readonly idempotentHint: true;
|
|
137
|
+
readonly openWorldHint: false;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
readonly stats: {
|
|
141
|
+
readonly name: "feedback_stats";
|
|
142
|
+
readonly title: "Feedback statistics";
|
|
143
|
+
readonly description: "Count feedback by kind, status, severity and tool, with the same filters as list_feedback.";
|
|
144
|
+
readonly annotations: {
|
|
145
|
+
readonly readOnlyHint: true;
|
|
146
|
+
readonly openWorldHint: false;
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
export declare const SYNTHESIZE_PROMPT: {
|
|
151
|
+
readonly name: "synthesize_feedback";
|
|
152
|
+
readonly title: "Synthesize feedback";
|
|
153
|
+
readonly description: "Read the submitted feedback and produce a prioritised summary of themes for the server's maintainers.";
|
|
154
|
+
};
|
|
155
|
+
export declare function synthesizePromptText(prefix: string, args: {
|
|
156
|
+
since?: string;
|
|
157
|
+
focus?: string;
|
|
158
|
+
}): string;
|
|
159
|
+
/** Text a host can append to its server `instructions` so agents know when to file feedback. */
|
|
160
|
+
export declare const feedbackInstructions: string;
|
|
161
|
+
/** `{ name, description }` entries for hosts that publish a tool catalog. */
|
|
162
|
+
export declare const feedbackToolCatalog: {
|
|
163
|
+
name: "submit_feedback";
|
|
164
|
+
description: string;
|
|
165
|
+
}[];
|
|
166
|
+
export declare const feedbackReaderToolCatalog: {
|
|
167
|
+
name: "list_feedback" | "get_feedback" | "update_feedback_triage" | "feedback_stats";
|
|
168
|
+
description: string;
|
|
169
|
+
}[];
|