@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/dist/ledger.js ADDED
@@ -0,0 +1,43 @@
1
+ /**
2
+ * What the client remembers about its own requests, so a later session can find
3
+ * them (SEP sections 7 and 11): the acceptance tests it sent (the server never returns
4
+ * them), the workaround it is relying on, the last status it saw, and the daily count
5
+ * behind the submission cap. Nothing in it is sent to the server.
6
+ */
7
+ import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
8
+ import { dirname } from "node:path";
9
+ function empty() {
10
+ return { requests: {}, submissions: {} };
11
+ }
12
+ export class MemoryLedger {
13
+ data = empty();
14
+ load() {
15
+ return structuredClone(this.data);
16
+ }
17
+ save(data) {
18
+ this.data = structuredClone(data);
19
+ }
20
+ }
21
+ /** A ledger in one JSON file per server, for clients whose sessions come and go. */
22
+ export class FileLedger {
23
+ path;
24
+ constructor(path) {
25
+ this.path = path;
26
+ }
27
+ load() {
28
+ try {
29
+ const parsed = JSON.parse(readFileSync(this.path, "utf8"));
30
+ return { requests: parsed.requests ?? {}, submissions: parsed.submissions ?? {} };
31
+ }
32
+ catch {
33
+ return empty();
34
+ }
35
+ }
36
+ save(data) {
37
+ mkdirSync(dirname(this.path), { recursive: true });
38
+ const tmp = `${this.path}.tmp`;
39
+ writeFileSync(tmp, `${JSON.stringify(data, null, 2)}\n`);
40
+ renameSync(tmp, this.path);
41
+ }
42
+ }
43
+ //# sourceMappingURL=ledger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ledger.js","sourceRoot":"","sources":["../src/ledger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgCpC,SAAS,KAAK;IACZ,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;AAC3C,CAAC;AAED,MAAM,OAAO,YAAY;IACf,IAAI,GAAe,KAAK,EAAE,CAAC;IACnC,IAAI;QACF,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IACD,IAAI,CAAC,IAAgB;QACnB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;CACF;AAED,oFAAoF;AACpF,MAAM,OAAO,UAAU;IACQ;IAA7B,YAA6B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAE7C,IAAI;QACF,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAwB,CAAC;YAClF,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,EAAE,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,EAAE,EAAE,CAAC;QACpF,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,EAAE,CAAC;QACjB,CAAC;IACH,CAAC;IAED,IAAI,CAAC,IAAgB;QACnB,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,IAAI,MAAM,CAAC;QAC/B,aAAa,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QACzD,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The client's redaction pass (SEP section 9). A request carries text a model wrote,
3
+ * so before it leaves the user's environment every free-text field and every
4
+ * argument value goes through these rules.
5
+ *
6
+ * Redaction is a safety net, not a guarantee: patterns catch common secrets, contact
7
+ * details, and paths, and the app adds what only it knows (the user's name, workspace
8
+ * and database names, other servers' tool names). When a rule fires, a review hook
9
+ * can show the user the cleaned request before it is sent.
10
+ */
11
+ export interface RedactionRule {
12
+ name: string;
13
+ pattern: RegExp;
14
+ replacement: string;
15
+ }
16
+ export declare const DEFAULT_RULES: readonly RedactionRule[];
17
+ export interface RedactOptions {
18
+ /** Values only the app knows are sensitive: the user's name, workspace, project, or database names. */
19
+ sensitiveValues?: readonly string[];
20
+ /** Tool, resource, and prompt names of the other servers connected to this client (section 9). */
21
+ foreignNames?: readonly string[];
22
+ /** Replace the default rules. */
23
+ rules?: readonly RedactionRule[];
24
+ /** Rules added after the defaults. */
25
+ extraRules?: readonly RedactionRule[];
26
+ }
27
+ /** Where a rule fired. It never includes the value that was removed. */
28
+ export interface RedactionFinding {
29
+ path: string;
30
+ rule: string;
31
+ }
32
+ export declare class Redactor {
33
+ private readonly rules;
34
+ constructor(options?: RedactOptions);
35
+ /** Redacts one string and reports which rules fired. */
36
+ text(value: string, path?: string, findings?: RedactionFinding[]): string;
37
+ /** Redacts every string inside a JSON value, keys included. */
38
+ value(value: unknown, path: string, findings: RedactionFinding[]): unknown;
39
+ }
40
+ /**
41
+ * Redacts a changeRequests/submit params object. Fixed fields pass through, target.name
42
+ * is checked only against foreign names, and every other string is redacted.
43
+ */
44
+ export declare function redactSubmission<T extends Record<string, unknown>>(params: T, options?: RedactOptions): {
45
+ params: T;
46
+ findings: RedactionFinding[];
47
+ };
package/dist/redact.js ADDED
@@ -0,0 +1,127 @@
1
+ /**
2
+ * The client's redaction pass (SEP section 9). A request carries text a model wrote,
3
+ * so before it leaves the user's environment every free-text field and every
4
+ * argument value goes through these rules.
5
+ *
6
+ * Redaction is a safety net, not a guarantee: patterns catch common secrets, contact
7
+ * details, and paths, and the app adds what only it knows (the user's name, workspace
8
+ * and database names, other servers' tool names). When a rule fires, a review hook
9
+ * can show the user the cleaned request before it is sent.
10
+ */
11
+ export const DEFAULT_RULES = [
12
+ { name: "private_key", pattern: /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g, replacement: "<private-key>" },
13
+ { name: "jwt", pattern: /\beyJ[\w-]{8,}\.[\w-]{8,}\.[\w-]{8,}\b/g, replacement: "<token>" },
14
+ { name: "bearer", pattern: /\bBearer\s+[\w.~+/=-]{8,}/gi, replacement: "Bearer <token>" },
15
+ {
16
+ name: "api_key",
17
+ pattern: /\b(?:sk|pk|rk)[-_](?:live[-_]|test[-_])?[A-Za-z0-9_-]{16,}\b|\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}\b|\bgithub_pat_[A-Za-z0-9_]{20,}\b|\bAKIA[0-9A-Z]{16}\b|\bxox[abprs]-[A-Za-z0-9-]{10,}\b|\bAIza[0-9A-Za-z_-]{30,}\b/g,
18
+ replacement: "<secret>",
19
+ },
20
+ {
21
+ name: "assigned_secret",
22
+ pattern: /\b(api[_-]?key|access[_-]?token|auth[_-]?token|secret|password|passwd|pwd)(\s*[:=]\s*)("[^"]*"|'[^']*'|\S+)/gi,
23
+ replacement: "$1$2<secret>",
24
+ },
25
+ { name: "url_credentials", pattern: /\b([a-z][a-z0-9+.-]*:\/\/)[^\s/@:]+:[^\s/@]+@/gi, replacement: "$1<credentials>@" },
26
+ { name: "email", pattern: /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g, replacement: "<email>" },
27
+ { name: "phone", pattern: /(?<![\w-])(?:\+\d{1,3}[\s.-]?)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}(?![\w-])/g, replacement: "<phone>" },
28
+ { name: "ip_address", pattern: /\b(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)\b/g, replacement: "<ip>" },
29
+ { name: "windows_path", pattern: /\b[A-Za-z]:\\(?:[^\\\s:*?"<>|]+\\)*[^\\\s:*?"<>|]*/g, replacement: "<path>" },
30
+ { name: "file_path", pattern: /(?<![\w.:/-])(?:~|\.{1,2})?\/(?:[\w.@-]+\/)+[\w.@-]*/g, replacement: "<path>" },
31
+ { name: "long_token", pattern: /\b(?=[A-Za-z0-9_-]*\d)(?=[A-Za-z0-9_-]*[A-Za-z])[A-Za-z0-9_-]{40,}\b/g, replacement: "<token>" },
32
+ ];
33
+ function escapeRegExp(value) {
34
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
35
+ }
36
+ export class Redactor {
37
+ rules;
38
+ constructor(options = {}) {
39
+ this.rules = [...(options.rules ?? DEFAULT_RULES), ...(options.extraRules ?? [])];
40
+ const literal = (values, name, replacement) => {
41
+ const usable = (values ?? []).filter((v) => v.trim().length >= 2).sort((a, b) => b.length - a.length);
42
+ if (usable.length === 0)
43
+ return;
44
+ this.rules.unshift({
45
+ name,
46
+ pattern: new RegExp(`(?<![\\w])(?:${usable.map(escapeRegExp).join("|")})(?![\\w])`, "gi"),
47
+ replacement,
48
+ });
49
+ };
50
+ literal(options.foreignNames, "other_server", "<other-server>");
51
+ literal(options.sensitiveValues, "sensitive_value", "<redacted>");
52
+ }
53
+ /** Redacts one string and reports which rules fired. */
54
+ text(value, path = "", findings = []) {
55
+ let out = value;
56
+ for (const rule of this.rules) {
57
+ rule.pattern.lastIndex = 0;
58
+ if (!rule.pattern.test(out))
59
+ continue;
60
+ rule.pattern.lastIndex = 0;
61
+ out = out.replace(rule.pattern, rule.replacement);
62
+ findings.push({ path, rule: rule.name });
63
+ }
64
+ return out;
65
+ }
66
+ /** Redacts every string inside a JSON value, keys included. */
67
+ value(value, path, findings) {
68
+ if (typeof value === "string")
69
+ return this.text(value, path, findings);
70
+ if (Array.isArray(value))
71
+ return value.map((item, i) => this.value(item, `${path}[${i}]`, findings));
72
+ if (value && typeof value === "object") {
73
+ const out = {};
74
+ for (const [key, inner] of Object.entries(value)) {
75
+ out[this.text(key, `${path}{key}`, findings)] = this.value(inner, path ? `${path}.${key}` : key, findings);
76
+ }
77
+ return out;
78
+ }
79
+ return value;
80
+ }
81
+ }
82
+ /** Fields that hold fixed vocabulary, never model-written text. */
83
+ const FIXED_FIELDS = new Set(["kind", "idempotencyKey", "failureMode", "impact", "origin", "about"]);
84
+ /**
85
+ * Redacts a changeRequests/submit params object. Fixed fields pass through, target.name
86
+ * is checked only against foreign names, and every other string is redacted.
87
+ */
88
+ export function redactSubmission(params, options = {}) {
89
+ const redactor = new Redactor(options);
90
+ const findings = [];
91
+ const out = {};
92
+ for (const [key, value] of Object.entries(params)) {
93
+ if (FIXED_FIELDS.has(key)) {
94
+ out[key] = value;
95
+ }
96
+ else if (key === "target" && value && typeof value === "object") {
97
+ const target = { ...value };
98
+ if (typeof target.name === "string") {
99
+ target.name = new Redactor({ ...options, rules: [], extraRules: [] }).text(target.name, "target.name", findings);
100
+ }
101
+ if (typeof target.component === "string") {
102
+ target.component = new Redactor({ ...options, rules: [], extraRules: [] }).text(target.component, "target.component", findings);
103
+ }
104
+ out[key] = target;
105
+ }
106
+ else if (key === "acceptanceTests" && Array.isArray(value)) {
107
+ out[key] = value.map((test, i) => {
108
+ const { call, ...rest } = test;
109
+ const cleaned = redactor.value(rest, `acceptanceTests[${i}]`, findings);
110
+ if (call) {
111
+ cleaned.call = {
112
+ method: call.method,
113
+ ...(call.params !== undefined
114
+ ? { params: redactor.value(call.params, `acceptanceTests[${i}].call.params`, findings) }
115
+ : {}),
116
+ };
117
+ }
118
+ return cleaned;
119
+ });
120
+ }
121
+ else {
122
+ out[key] = redactor.value(value, key, findings);
123
+ }
124
+ }
125
+ return { params: out, findings };
126
+ }
127
+ //# sourceMappingURL=redact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redact.js","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH,MAAM,CAAC,MAAM,aAAa,GA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AAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,kBAAkB,EAAE,QAAQ,CAAC,CAAC;YAClI,CAAC;YACD,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;QACpB,CAAC;aAAM,IAAI,GAAG,KAAK,iBAAiB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7D,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;gBAC/B,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,IAAyD,CAAC;gBACpF,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,mBAAmB,CAAC,GAAG,EAAE,QAAQ,CAA4B,CAAC;gBACnG,IAAI,IAAI,EAAE,CAAC;oBACT,OAAO,CAAC,IAAI,GAAG;wBACb,MAAM,EAAE,IAAI,CAAC,MAAM;wBACnB,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS;4BAC3B,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,mBAAmB,CAAC,eAAe,EAAE,QAAQ,CAAC,EAAE;4BACxF,CAAC,CAAC,EAAE,CAAC;qBACR,CAAC;gBACJ,CAAC;gBACD,OAAO,OAAO,CAAC;YACjB,CAAC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,GAAQ,EAAE,QAAQ,EAAE,CAAC;AACxC,CAAC"}
@@ -0,0 +1,126 @@
1
+ /** Wire types from SEP-0000, as a client sees them. */
2
+ export type Kind = "bug" | "friction" | "missing_capability" | "feature_request";
3
+ export type Status = "received" | "needs_info" | "triaged" | "planned" | "building" | "shipped" | "declined" | "duplicate" | "withdrawn";
4
+ export declare const TERMINAL_STATUSES: readonly Status[];
5
+ export interface Target {
6
+ type: "tool" | "resource" | "prompt" | "server" | "extension";
7
+ /** The tool, resource, or prompt name, or for type extension the extension identifier. */
8
+ name?: string;
9
+ /** For type extension only: spec, server-sdk, or client-sdk for this extension. */
10
+ component?: string;
11
+ }
12
+ export interface AcceptanceTest {
13
+ description?: string;
14
+ call: {
15
+ method: "tools/call" | "resources/read" | "prompts/get";
16
+ params?: Record<string, unknown>;
17
+ };
18
+ expect?: {
19
+ isError?: boolean;
20
+ structuredContentSchema?: Record<string, unknown>;
21
+ textContains?: string[];
22
+ };
23
+ }
24
+ /** changeRequests/submit params. idempotencyKey is optional here: the client makes one. */
25
+ export interface SubmitParams {
26
+ kind: Kind;
27
+ title: string;
28
+ description: string;
29
+ target?: Target;
30
+ context?: {
31
+ goal?: string;
32
+ workaround?: string;
33
+ cause?: string;
34
+ attempts?: Record<string, unknown>[];
35
+ };
36
+ failureMode?: string;
37
+ impact?: {
38
+ blocked?: boolean;
39
+ frequency?: "once" | "recurring";
40
+ severity?: "low" | "medium" | "high";
41
+ detectability?: "immediate" | "eventual" | "hidden";
42
+ };
43
+ acceptanceTests?: AcceptanceTest[];
44
+ idempotencyKey?: string;
45
+ [key: string]: unknown;
46
+ }
47
+ export interface SubmitResult {
48
+ requestId: string;
49
+ status: Status;
50
+ duplicateOf: string | null;
51
+ demand: number;
52
+ ticket?: string;
53
+ }
54
+ export interface Resolution {
55
+ availability: "requester" | "all";
56
+ changed?: Target[];
57
+ changelogUri?: string;
58
+ workaroundObsolete?: boolean;
59
+ tests?: {
60
+ index: number;
61
+ outcome: "pass" | "fail" | "not_evaluated";
62
+ }[];
63
+ }
64
+ export interface StatusObject {
65
+ requestId: string;
66
+ status: Status;
67
+ updatedAt: string;
68
+ demand: number;
69
+ title?: string;
70
+ message?: string;
71
+ resolution?: Resolution;
72
+ duplicateOf?: string;
73
+ version?: string;
74
+ confirmation?: {
75
+ outcome: "pass" | "fail";
76
+ confirmedAt: string;
77
+ };
78
+ [key: string]: unknown;
79
+ }
80
+ /** The server settings object from SEP section 1. */
81
+ export interface ServerSettings {
82
+ kinds: Kind[];
83
+ acceptanceTests?: boolean;
84
+ events?: boolean;
85
+ anonymous?: boolean;
86
+ policyUri?: string;
87
+ changelogUri?: string;
88
+ changes?: boolean;
89
+ }
90
+ export interface ConfirmParams {
91
+ requestId: string;
92
+ outcome: "pass" | "fail";
93
+ tests?: {
94
+ index: number;
95
+ outcome: "pass" | "fail";
96
+ }[];
97
+ note?: string;
98
+ [key: string]: unknown;
99
+ }
100
+ /** One entry of the changes feed (SEP section 12). */
101
+ export interface ChangeEntry {
102
+ version: string;
103
+ publishedAt: string;
104
+ type: "added" | "changed" | "deprecated" | "removed" | "fixed";
105
+ breaking: boolean;
106
+ summary: string;
107
+ changed?: Target[];
108
+ changelogUri?: string;
109
+ removeAfter?: string;
110
+ /** The caller's own requests this change resolved. */
111
+ changeRequestIds?: string[];
112
+ [key: string]: unknown;
113
+ }
114
+ /** changeRequests/changes params. Pass sinceVersion or since, not both. */
115
+ export interface ChangesQuery {
116
+ sinceVersion?: string;
117
+ since?: string;
118
+ cursor?: string;
119
+ limit?: number;
120
+ }
121
+ /** changeRequests/changes result. */
122
+ export interface ChangesPage {
123
+ currentVersion: string;
124
+ changes: ChangeEntry[];
125
+ nextCursor?: string;
126
+ }
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ /** Wire types from SEP-0000, as a client sees them. */
2
+ export const TERMINAL_STATUSES = ["shipped", "declined", "duplicate", "withdrawn"];
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAevD,MAAM,CAAC,MAAM,iBAAiB,GAAsB,CAAC,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,48 @@
1
1
  {
2
2
  "name": "@agent-change-requests/client",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.3.0",
4
+ "description": "Client side of the Agent Change Requests extension for @modelcontextprotocol/sdk: consent, a model-facing submission tool, redaction, the inbox, and requester confirmation.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/MiamiMike-1/agent-change-requests.git",
9
+ "directory": "packages/client"
10
+ },
11
+ "homepage": "https://github.com/MiamiMike-1/agent-change-requests/tree/main/packages/client",
12
+ "type": "module",
13
+ "main": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "scripts": {
27
+ "build": "tsc -p tsconfig.build.json",
28
+ "typecheck": "tsc -p tsconfig.json --noEmit",
29
+ "test": "vitest run"
30
+ },
31
+ "peerDependencies": {
32
+ "@modelcontextprotocol/sdk": "^1.20.0"
33
+ },
34
+ "devDependencies": {
35
+ "@agent-change-requests/server": "*",
36
+ "@modelcontextprotocol/sdk": "^1.32.2",
37
+ "@types/node": "^22.0.0",
38
+ "typescript": "^5.6.0",
39
+ "vitest": "^3.2.0",
40
+ "zod": "^4.0.0"
41
+ },
42
+ "engines": {
43
+ "node": ">=20"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ }
48
+ }