@martinloop/mcp 0.3.8 → 0.3.9
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 +148 -105
- package/dist/resources.js +148 -148
- package/dist/server.js +0 -0
- package/dist/tools/preflight.d.ts +0 -2
- package/dist/tools/preflight.js +2 -42
- package/dist/vendor/adapters/openai-compatible.js +6 -6
- package/dist/vendor/contracts/index.d.ts +0 -2
- package/dist/vendor/contracts/index.js +0 -2
- package/dist/vendor/core/index.d.ts +0 -2
- package/dist/vendor/core/index.js +0 -2
- package/package.json +86 -83
- package/server.json +21 -21
- package/LICENSE +0 -216
- package/dist/vendor/adapters/adapters/src/claude-cli.d.ts +0 -146
- package/dist/vendor/adapters/adapters/src/claude-cli.js +0 -1100
- package/dist/vendor/adapters/adapters/src/cli-bridge.d.ts +0 -103
- package/dist/vendor/adapters/adapters/src/cli-bridge.js +0 -569
- package/dist/vendor/adapters/adapters/src/codex-launcher.d.ts +0 -78
- package/dist/vendor/adapters/adapters/src/codex-launcher.js +0 -663
- package/dist/vendor/adapters/adapters/src/direct-provider.d.ts +0 -10
- package/dist/vendor/adapters/adapters/src/direct-provider.js +0 -40
- package/dist/vendor/adapters/adapters/src/index.d.ts +0 -8
- package/dist/vendor/adapters/adapters/src/index.js +0 -8
- package/dist/vendor/adapters/adapters/src/openai-compatible.d.ts +0 -62
- package/dist/vendor/adapters/adapters/src/openai-compatible.js +0 -306
- package/dist/vendor/adapters/adapters/src/runtime-support.d.ts +0 -17
- package/dist/vendor/adapters/adapters/src/runtime-support.js +0 -59
- package/dist/vendor/adapters/adapters/src/stub-agent-cli.d.ts +0 -8
- package/dist/vendor/adapters/adapters/src/stub-agent-cli.js +0 -40
- package/dist/vendor/adapters/adapters/src/stub-direct-provider.d.ts +0 -8
- package/dist/vendor/adapters/adapters/src/stub-direct-provider.js +0 -12
- package/dist/vendor/adapters/adapters/src/verifier-only.d.ts +0 -9
- package/dist/vendor/adapters/adapters/src/verifier-only.js +0 -63
- package/dist/vendor/adapters/contracts/src/context-graph.d.ts +0 -48
- package/dist/vendor/adapters/contracts/src/context-graph.js +0 -26
- package/dist/vendor/adapters/contracts/src/execution-policy.d.ts +0 -78
- package/dist/vendor/adapters/contracts/src/execution-policy.js +0 -43
- package/dist/vendor/adapters/contracts/src/governance.d.ts +0 -24
- package/dist/vendor/adapters/contracts/src/governance.js +0 -11
- package/dist/vendor/adapters/contracts/src/identity.d.ts +0 -29
- package/dist/vendor/adapters/contracts/src/identity.js +0 -30
- package/dist/vendor/adapters/contracts/src/index.d.ts +0 -412
- package/dist/vendor/adapters/contracts/src/index.js +0 -225
- package/dist/vendor/adapters/contracts/src/operator.d.ts +0 -19
- package/dist/vendor/adapters/contracts/src/operator.js +0 -11
- package/dist/vendor/adapters/contracts/src/trajectory.d.ts +0 -26
- package/dist/vendor/adapters/contracts/src/trajectory.js +0 -27
- package/dist/vendor/adapters/core/src/compiler.d.ts +0 -52
- package/dist/vendor/adapters/core/src/compiler.js +0 -52
- package/dist/vendor/adapters/core/src/context-graph.d.ts +0 -3
- package/dist/vendor/adapters/core/src/context-graph.js +0 -371
- package/dist/vendor/adapters/core/src/context-integrity.d.ts +0 -26
- package/dist/vendor/adapters/core/src/context-integrity.js +0 -80
- package/dist/vendor/adapters/core/src/grounding.d.ts +0 -38
- package/dist/vendor/adapters/core/src/grounding.js +0 -273
- package/dist/vendor/adapters/core/src/identity.d.ts +0 -20
- package/dist/vendor/adapters/core/src/identity.js +0 -86
- package/dist/vendor/adapters/core/src/index.d.ts +0 -186
- package/dist/vendor/adapters/core/src/index.js +0 -1495
- package/dist/vendor/adapters/core/src/leash.d.ts +0 -48
- package/dist/vendor/adapters/core/src/leash.js +0 -497
- package/dist/vendor/adapters/core/src/persistence/compiler.d.ts +0 -18
- package/dist/vendor/adapters/core/src/persistence/compiler.js +0 -34
- package/dist/vendor/adapters/core/src/persistence/index.d.ts +0 -10
- package/dist/vendor/adapters/core/src/persistence/index.js +0 -5
- package/dist/vendor/adapters/core/src/persistence/integrity.d.ts +0 -39
- package/dist/vendor/adapters/core/src/persistence/integrity.js +0 -252
- package/dist/vendor/adapters/core/src/persistence/ledger.d.ts +0 -23
- package/dist/vendor/adapters/core/src/persistence/ledger.js +0 -9
- package/dist/vendor/adapters/core/src/persistence/memory-store.d.ts +0 -63
- package/dist/vendor/adapters/core/src/persistence/memory-store.js +0 -115
- package/dist/vendor/adapters/core/src/persistence/runs-reader.d.ts +0 -66
- package/dist/vendor/adapters/core/src/persistence/runs-reader.js +0 -140
- package/dist/vendor/adapters/core/src/persistence/store.d.ts +0 -89
- package/dist/vendor/adapters/core/src/persistence/store.js +0 -125
- package/dist/vendor/adapters/core/src/persistence/trace-store.d.ts +0 -85
- package/dist/vendor/adapters/core/src/persistence/trace-store.js +0 -125
- package/dist/vendor/adapters/core/src/policy-compiler.d.ts +0 -2
- package/dist/vendor/adapters/core/src/policy-compiler.js +0 -195
- package/dist/vendor/adapters/core/src/policy.d.ts +0 -156
- package/dist/vendor/adapters/core/src/policy.js +0 -704
- package/dist/vendor/adapters/core/src/repo-analyzer.d.ts +0 -53
- package/dist/vendor/adapters/core/src/repo-analyzer.js +0 -263
- package/dist/vendor/adapters/core/src/rollback.d.ts +0 -15
- package/dist/vendor/adapters/core/src/rollback.js +0 -253
- package/dist/vendor/adapters/core/src/routing.d.ts +0 -82
- package/dist/vendor/adapters/core/src/routing.js +0 -336
- package/dist/vendor/adapters/core/src/test-integrity.d.ts +0 -64
- package/dist/vendor/adapters/core/src/test-integrity.js +0 -197
- package/dist/vendor/adapters/core/src/trajectory.d.ts +0 -18
- package/dist/vendor/adapters/core/src/trajectory.js +0 -295
- package/dist/vendor/contracts/delivery.d.ts +0 -47
- package/dist/vendor/contracts/delivery.js +0 -18
- package/dist/vendor/core/delivery/index.d.ts +0 -6
- package/dist/vendor/core/delivery/index.js +0 -4
- package/dist/vendor/core/delivery/message-client.d.ts +0 -18
- package/dist/vendor/core/delivery/message-client.js +0 -38
- package/dist/vendor/core/delivery/message-ledger.d.ts +0 -35
- package/dist/vendor/core/delivery/message-ledger.js +0 -97
- package/dist/vendor/core/delivery/message-schema.d.ts +0 -16
- package/dist/vendor/core/delivery/message-schema.js +0 -111
- package/dist/vendor/core/delivery/update-check.d.ts +0 -19
- package/dist/vendor/core/delivery/update-check.js +0 -107
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { ALLOWED_ACTION_TYPES, DELIVERY_MESSAGE_SCHEMA_VERSION, MESSAGE_SELECTION_RESPONSE_SCHEMA_VERSION, } from "../../contracts/index.js";
|
|
2
|
-
const MAX_RESPONSE_BYTES = 8_192;
|
|
3
|
-
const MAX_TITLE_LENGTH = 120;
|
|
4
|
-
const MAX_BODY_LENGTH = 500;
|
|
5
|
-
const MAX_ID_LENGTH = 128;
|
|
6
|
-
const ALLOWED_ACTION_SET = new Set(ALLOWED_ACTION_TYPES);
|
|
7
|
-
/**
|
|
8
|
-
* Parse and validate a raw response body from the message selection endpoint.
|
|
9
|
-
* Returns ok:false on any violation — caller must render nothing and log the error.
|
|
10
|
-
*/
|
|
11
|
-
export function parseMessageSelectionResponse(raw) {
|
|
12
|
-
if (Buffer.byteLength(raw, "utf8") > MAX_RESPONSE_BYTES) {
|
|
13
|
-
return { ok: false, error: "schema_response_too_large" };
|
|
14
|
-
}
|
|
15
|
-
let parsed;
|
|
16
|
-
try {
|
|
17
|
-
parsed = JSON.parse(raw);
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
return { ok: false, error: "schema_malformed" };
|
|
21
|
-
}
|
|
22
|
-
if (!isObject(parsed)) {
|
|
23
|
-
return { ok: false, error: "schema_malformed" };
|
|
24
|
-
}
|
|
25
|
-
if (parsed["schemaVersion"] !== MESSAGE_SELECTION_RESPONSE_SCHEMA_VERSION) {
|
|
26
|
-
return { ok: false, error: "schema_version_unknown", detail: String(parsed["schemaVersion"]) };
|
|
27
|
-
}
|
|
28
|
-
if (!("message" in parsed) || parsed["message"] === undefined || parsed["message"] === null) {
|
|
29
|
-
return { ok: true, message: undefined };
|
|
30
|
-
}
|
|
31
|
-
const result = validateMessage(parsed["message"]);
|
|
32
|
-
if (!result.ok)
|
|
33
|
-
return result;
|
|
34
|
-
return { ok: true, message: result.message };
|
|
35
|
-
}
|
|
36
|
-
function validateMessage(raw) {
|
|
37
|
-
if (!isObject(raw)) {
|
|
38
|
-
return { ok: false, error: "schema_malformed" };
|
|
39
|
-
}
|
|
40
|
-
if (raw["schemaVersion"] !== DELIVERY_MESSAGE_SCHEMA_VERSION) {
|
|
41
|
-
return { ok: false, error: "schema_version_unknown", detail: String(raw["schemaVersion"]) };
|
|
42
|
-
}
|
|
43
|
-
const id = raw["id"];
|
|
44
|
-
if (typeof id !== "string" || id.length === 0 || id.length > MAX_ID_LENGTH || !/^[\w\-.:]+$/.test(id)) {
|
|
45
|
-
return { ok: false, error: "schema_invalid_id" };
|
|
46
|
-
}
|
|
47
|
-
const kind = raw["kind"];
|
|
48
|
-
if (kind !== "update" && kind !== "feedback_request" && kind !== "milestone") {
|
|
49
|
-
return { ok: false, error: "schema_unknown_kind", detail: String(kind) };
|
|
50
|
-
}
|
|
51
|
-
const revision = raw["revision"];
|
|
52
|
-
if (typeof revision !== "number" || !Number.isInteger(revision) || revision < 0) {
|
|
53
|
-
return { ok: false, error: "schema_malformed", detail: "revision" };
|
|
54
|
-
}
|
|
55
|
-
const title = raw["title"];
|
|
56
|
-
if (typeof title !== "string" || title.length === 0 || title.length > MAX_TITLE_LENGTH) {
|
|
57
|
-
return { ok: false, error: "schema_text_too_long", detail: "title" };
|
|
58
|
-
}
|
|
59
|
-
const body = raw["body"];
|
|
60
|
-
if (typeof body !== "string" || body.length === 0 || body.length > MAX_BODY_LENGTH) {
|
|
61
|
-
return { ok: false, error: "schema_text_too_long", detail: "body" };
|
|
62
|
-
}
|
|
63
|
-
const action = raw["action"];
|
|
64
|
-
if (!isObject(action)) {
|
|
65
|
-
return { ok: false, error: "schema_malformed", detail: "action" };
|
|
66
|
-
}
|
|
67
|
-
const actionType = action["type"];
|
|
68
|
-
if (typeof actionType !== "string" || !ALLOWED_ACTION_SET.has(actionType)) {
|
|
69
|
-
return { ok: false, error: "schema_unknown_action_type", detail: String(actionType) };
|
|
70
|
-
}
|
|
71
|
-
if ("url" in action && action["url"] !== undefined) {
|
|
72
|
-
if (typeof action["url"] !== "string" || !action["url"].startsWith("https://")) {
|
|
73
|
-
return { ok: false, error: "schema_url_not_https" };
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
if ("targetVersion" in action && action["targetVersion"] !== undefined) {
|
|
77
|
-
if (typeof action["targetVersion"] !== "string") {
|
|
78
|
-
return { ok: false, error: "schema_malformed", detail: "targetVersion" };
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
const expiresAt = raw["expiresAt"];
|
|
82
|
-
if (typeof expiresAt !== "string" || isNaN(Date.parse(expiresAt))) {
|
|
83
|
-
return { ok: false, error: "schema_invalid_date", detail: "expiresAt" };
|
|
84
|
-
}
|
|
85
|
-
const cooldownHours = raw["cooldownHours"];
|
|
86
|
-
if (typeof cooldownHours !== "number" ||
|
|
87
|
-
!Number.isFinite(cooldownHours) ||
|
|
88
|
-
cooldownHours < 0 ||
|
|
89
|
-
cooldownHours > 8760) {
|
|
90
|
-
return { ok: false, error: "schema_invalid_cooldown" };
|
|
91
|
-
}
|
|
92
|
-
const message = {
|
|
93
|
-
schemaVersion: DELIVERY_MESSAGE_SCHEMA_VERSION,
|
|
94
|
-
id,
|
|
95
|
-
revision,
|
|
96
|
-
kind,
|
|
97
|
-
title,
|
|
98
|
-
body,
|
|
99
|
-
action: {
|
|
100
|
-
type: actionType,
|
|
101
|
-
...(action["url"] !== undefined ? { url: action["url"] } : {}),
|
|
102
|
-
...(action["targetVersion"] !== undefined ? { targetVersion: action["targetVersion"] } : {}),
|
|
103
|
-
},
|
|
104
|
-
expiresAt,
|
|
105
|
-
cooldownHours,
|
|
106
|
-
};
|
|
107
|
-
return { ok: true, message };
|
|
108
|
-
}
|
|
109
|
-
function isObject(v) {
|
|
110
|
-
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
111
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the installed version of the CLI package (`martin-loop`).
|
|
3
|
-
* Call site: CLI only. Never call from MCP.
|
|
4
|
-
*/
|
|
5
|
-
export declare function getCliInstalledVersion(): string | null;
|
|
6
|
-
/**
|
|
7
|
-
* Returns the installed version of the MCP package (`@martinloop/mcp`).
|
|
8
|
-
* Call site: MCP only. Never call from CLI.
|
|
9
|
-
*/
|
|
10
|
-
export declare function getMcpInstalledVersion(): string | null;
|
|
11
|
-
/**
|
|
12
|
-
* Compare two semver strings. Returns true when `available` is strictly
|
|
13
|
-
* newer than `current`.
|
|
14
|
-
*
|
|
15
|
-
* Prereleases are never surfaced as updates unless the user's current
|
|
16
|
-
* version is itself a prerelease (semver prerelease protection).
|
|
17
|
-
* Build metadata (+build) does not affect precedence.
|
|
18
|
-
*/
|
|
19
|
-
export declare function isNewerVersion(current: string, available: string): boolean;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
// CLI and MCP version checks are intentionally independent — they use different
|
|
3
|
-
// package names and must never share a constant or resolve function.
|
|
4
|
-
/**
|
|
5
|
-
* Returns the installed version of the CLI package (`martin-loop`).
|
|
6
|
-
* Call site: CLI only. Never call from MCP.
|
|
7
|
-
*/
|
|
8
|
-
export function getCliInstalledVersion() {
|
|
9
|
-
return resolvePackageVersion("martin-loop");
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Returns the installed version of the MCP package (`@martinloop/mcp`).
|
|
13
|
-
* Call site: MCP only. Never call from CLI.
|
|
14
|
-
*/
|
|
15
|
-
export function getMcpInstalledVersion() {
|
|
16
|
-
return resolvePackageVersion("@martinloop/mcp");
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Compare two semver strings. Returns true when `available` is strictly
|
|
20
|
-
* newer than `current`.
|
|
21
|
-
*
|
|
22
|
-
* Prereleases are never surfaced as updates unless the user's current
|
|
23
|
-
* version is itself a prerelease (semver prerelease protection).
|
|
24
|
-
* Build metadata (+build) does not affect precedence.
|
|
25
|
-
*/
|
|
26
|
-
export function isNewerVersion(current, available) {
|
|
27
|
-
const currentVersion = parseSemver(current);
|
|
28
|
-
const availableVersion = parseSemver(available);
|
|
29
|
-
if (!currentVersion || !availableVersion)
|
|
30
|
-
return false;
|
|
31
|
-
// Stable users must never be offered a prerelease.
|
|
32
|
-
if (currentVersion.prerelease.length === 0 &&
|
|
33
|
-
availableVersion.prerelease.length > 0) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
return compareSemver(availableVersion, currentVersion) > 0;
|
|
37
|
-
}
|
|
38
|
-
function resolvePackageVersion(name) {
|
|
39
|
-
try {
|
|
40
|
-
const require = createRequire(import.meta.url);
|
|
41
|
-
const pkg = require(`${name}/package.json`);
|
|
42
|
-
return typeof pkg.version === "string" ? pkg.version : null;
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function parseSemver(version) {
|
|
49
|
-
const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.exec(version);
|
|
50
|
-
if (!match)
|
|
51
|
-
return null;
|
|
52
|
-
const prerelease = [];
|
|
53
|
-
for (const identifier of match[4]?.split(".") ?? []) {
|
|
54
|
-
if (/^\d+$/.test(identifier)) {
|
|
55
|
-
// Leading zeros on numeric identifiers are invalid per SemVer spec.
|
|
56
|
-
if (identifier.length > 1 && identifier.startsWith("0"))
|
|
57
|
-
return null;
|
|
58
|
-
prerelease.push(Number(identifier));
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
prerelease.push(identifier);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return {
|
|
65
|
-
major: Number(match[1]),
|
|
66
|
-
minor: Number(match[2]),
|
|
67
|
-
patch: Number(match[3]),
|
|
68
|
-
prerelease,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Returns a positive number if left > right, negative if left < right, 0 if equal.
|
|
73
|
-
* Implements SemVer 2.0.0 precedence rules exactly.
|
|
74
|
-
*/
|
|
75
|
-
function compareSemver(left, right) {
|
|
76
|
-
for (const key of ["major", "minor", "patch"]) {
|
|
77
|
-
if (left[key] !== right[key])
|
|
78
|
-
return left[key] > right[key] ? 1 : -1;
|
|
79
|
-
}
|
|
80
|
-
// When base versions are equal: stable (no prerelease) > prerelease.
|
|
81
|
-
if (left.prerelease.length === 0 && right.prerelease.length === 0)
|
|
82
|
-
return 0;
|
|
83
|
-
if (left.prerelease.length === 0)
|
|
84
|
-
return 1;
|
|
85
|
-
if (right.prerelease.length === 0)
|
|
86
|
-
return -1;
|
|
87
|
-
// Both have prereleases — compare identifier by identifier.
|
|
88
|
-
const length = Math.max(left.prerelease.length, right.prerelease.length);
|
|
89
|
-
for (let index = 0; index < length; index++) {
|
|
90
|
-
const a = left.prerelease[index];
|
|
91
|
-
const b = right.prerelease[index];
|
|
92
|
-
if (a === undefined)
|
|
93
|
-
return -1; // fewer identifiers = lower precedence
|
|
94
|
-
if (b === undefined)
|
|
95
|
-
return 1;
|
|
96
|
-
if (a === b)
|
|
97
|
-
continue;
|
|
98
|
-
if (typeof a === "number" && typeof b === "number")
|
|
99
|
-
return a > b ? 1 : -1;
|
|
100
|
-
if (typeof a === "number")
|
|
101
|
-
return -1; // numeric < alphanumeric
|
|
102
|
-
if (typeof b === "number")
|
|
103
|
-
return 1;
|
|
104
|
-
return a > b ? 1 : -1; // both alphanumeric: lexicographic
|
|
105
|
-
}
|
|
106
|
-
return 0;
|
|
107
|
-
}
|