@otskit/mcp 0.2.1 → 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/README.md +106 -106
- package/package.json +49 -49
- package/dist/chunk-4ZDPWS7C.js +0 -123
- package/dist/chunk-OMNHFTJW.js +0 -265
- package/dist/chunk-YFSUDT24.js +0 -24
- package/dist/claude-QTEB3Z5V.js +0 -54
- package/dist/claude-code-THJIWEHG.js +0 -48
- package/dist/cli-D7G2H6UT.js +0 -98
- package/dist/codex-P7EDO5GY.js +0 -41
- package/dist/index.js +0 -77
- package/dist/install-BUSOMBB2.js +0 -37
- package/dist/install-claude-UKSS65BW.js +0 -44
- package/dist/remove-BGFQRDX3.js +0 -17
- package/dist/scheduler-MTE6OUSV.js +0 -27
- package/dist/server-IDRHOKL7.js +0 -221
- package/dist/status-M6A2RG7G.js +0 -17
- package/dist/watch-7NPUWR6I.js +0 -41
package/dist/chunk-OMNHFTJW.js
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getDataDir
|
|
3
|
-
} from "./chunk-4ZDPWS7C.js";
|
|
4
|
-
import {
|
|
5
|
-
writeAtomic
|
|
6
|
-
} from "./chunk-YFSUDT24.js";
|
|
7
|
-
|
|
8
|
-
// src/tools/create-timestamp.ts
|
|
9
|
-
import { mkdirSync } from "fs";
|
|
10
|
-
import { join } from "path";
|
|
11
|
-
import { randomUUID } from "crypto";
|
|
12
|
-
import { OpenTimestampsClient } from "@otskit/client";
|
|
13
|
-
|
|
14
|
-
// src/db/stamps.ts
|
|
15
|
-
function insertStamp(db, params) {
|
|
16
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
17
|
-
db.prepare(`
|
|
18
|
-
INSERT INTO stamps (id, hash, status, created_at, proof_path, archive_path, attempt_count, metadata)
|
|
19
|
-
VALUES (?, ?, 'pending', ?, ?, ?, 0, ?)
|
|
20
|
-
`).run(params.id, params.hash, now, params.proof_path, params.archive_path ?? null, params.metadata ?? null);
|
|
21
|
-
return getStamp(db, params.id);
|
|
22
|
-
}
|
|
23
|
-
function getStamp(db, id) {
|
|
24
|
-
return db.prepare("SELECT * FROM stamps WHERE id = ?").get(id) ?? null;
|
|
25
|
-
}
|
|
26
|
-
function updateStampStatus(db, id, params) {
|
|
27
|
-
const fields = [];
|
|
28
|
-
const values = [];
|
|
29
|
-
const add = (col, val) => {
|
|
30
|
-
fields.push(`${col} = ?`);
|
|
31
|
-
values.push(val);
|
|
32
|
-
};
|
|
33
|
-
if (params.status !== void 0) add("status", params.status);
|
|
34
|
-
if (params.bitcoin_block !== void 0) add("bitcoin_block", params.bitcoin_block);
|
|
35
|
-
if (params.bitcoin_time !== void 0) add("bitcoin_time", params.bitcoin_time);
|
|
36
|
-
if (params.confirmed_at !== void 0) add("confirmed_at", params.confirmed_at);
|
|
37
|
-
if (params.last_error !== void 0) add("last_error", params.last_error);
|
|
38
|
-
if (params.attempt_count !== void 0) add("attempt_count", params.attempt_count);
|
|
39
|
-
if (params.last_attempt_at !== void 0) add("last_attempt_at", params.last_attempt_at);
|
|
40
|
-
if (params.next_retry_at !== void 0) add("next_retry_at", params.next_retry_at);
|
|
41
|
-
if (fields.length === 0) return;
|
|
42
|
-
values.push(id);
|
|
43
|
-
db.prepare(`UPDATE stamps SET ${fields.join(", ")} WHERE id = ?`).run(...values);
|
|
44
|
-
}
|
|
45
|
-
function listStamps(db, params) {
|
|
46
|
-
const conds = [];
|
|
47
|
-
const vals = [];
|
|
48
|
-
if (params.status) {
|
|
49
|
-
conds.push("status = ?");
|
|
50
|
-
vals.push(params.status);
|
|
51
|
-
}
|
|
52
|
-
if (params.older_than_hours) {
|
|
53
|
-
const cutoff = new Date(Date.now() - params.older_than_hours * 36e5).toISOString();
|
|
54
|
-
conds.push("created_at < ?");
|
|
55
|
-
vals.push(cutoff);
|
|
56
|
-
}
|
|
57
|
-
if (params.due_now) {
|
|
58
|
-
conds.push("(next_retry_at IS NULL OR next_retry_at <= ?)");
|
|
59
|
-
vals.push((/* @__PURE__ */ new Date()).toISOString());
|
|
60
|
-
}
|
|
61
|
-
const where = conds.length ? `WHERE ${conds.join(" AND ")}` : "";
|
|
62
|
-
const total = db.prepare(`SELECT COUNT(*) as n FROM stamps ${where}`).get(...vals).n;
|
|
63
|
-
const items = db.prepare(
|
|
64
|
-
`SELECT * FROM stamps ${where} ORDER BY created_at DESC LIMIT ? OFFSET ?`
|
|
65
|
-
).all(...vals, params.limit, params.offset);
|
|
66
|
-
return { items, total };
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// src/db/operations-log.ts
|
|
70
|
-
function logOperation(db, params) {
|
|
71
|
-
db.prepare(`
|
|
72
|
-
INSERT INTO operations_log (stamp_id, action, result, error_msg, calendar_uri, response_time_ms, created_at)
|
|
73
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
74
|
-
`).run(
|
|
75
|
-
params.stamp_id,
|
|
76
|
-
params.action,
|
|
77
|
-
params.result,
|
|
78
|
-
params.error_msg ?? null,
|
|
79
|
-
params.calendar_uri ?? null,
|
|
80
|
-
params.response_time_ms ?? null,
|
|
81
|
-
(/* @__PURE__ */ new Date()).toISOString()
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// src/tools/create-timestamp.ts
|
|
86
|
-
var HEX64 = /^[0-9a-f]{64}$/i;
|
|
87
|
-
async function createTimestamp(input, db, config) {
|
|
88
|
-
if (!HEX64.test(input.hash)) {
|
|
89
|
-
return { error: "invalid_hash", details: "hash must be 64 hex characters (SHA-256)" };
|
|
90
|
-
}
|
|
91
|
-
const normalizedHash = input.hash.toLowerCase();
|
|
92
|
-
const client = new OpenTimestampsClient({
|
|
93
|
-
calendars: config.calendars,
|
|
94
|
-
resilience: { timeout: config.calendar_timeout_ms }
|
|
95
|
-
});
|
|
96
|
-
const t0 = Date.now();
|
|
97
|
-
let proofBuffer;
|
|
98
|
-
try {
|
|
99
|
-
proofBuffer = await client.stamp(normalizedHash);
|
|
100
|
-
} catch (e) {
|
|
101
|
-
return { error: "calendar_error", details: String(e) };
|
|
102
|
-
}
|
|
103
|
-
const responseTimeMs = Date.now() - t0;
|
|
104
|
-
const id = randomUUID();
|
|
105
|
-
const proofDir = join(getDataDir(), "proofs");
|
|
106
|
-
mkdirSync(proofDir, { recursive: true });
|
|
107
|
-
const proofPath = join(proofDir, `${id}.ots`);
|
|
108
|
-
try {
|
|
109
|
-
writeAtomic(proofPath, proofBuffer);
|
|
110
|
-
} catch (e) {
|
|
111
|
-
return { error: "storage_error", details: String(e) };
|
|
112
|
-
}
|
|
113
|
-
const record = insertStamp(db, { id, hash: normalizedHash, proof_path: proofPath });
|
|
114
|
-
logOperation(db, { stamp_id: id, action: "stamp", result: "success", response_time_ms: responseTimeMs });
|
|
115
|
-
return {
|
|
116
|
-
id: record.id,
|
|
117
|
-
hash: record.hash,
|
|
118
|
-
status: "pending",
|
|
119
|
-
calendars: config.calendars,
|
|
120
|
-
created_at: record.created_at,
|
|
121
|
-
proof_path: proofPath
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// src/tools/upgrade-timestamp.ts
|
|
126
|
-
import { readFileSync } from "fs";
|
|
127
|
-
import { OpenTimestampsClient as OpenTimestampsClient2, UpgradeError } from "@otskit/client";
|
|
128
|
-
import { DetachedTimestampFile, StreamDeserializationContext } from "@otskit/core";
|
|
129
|
-
function collectAttestations(ts) {
|
|
130
|
-
const atts = [...ts.attestations];
|
|
131
|
-
for (const branch of ts.branches) {
|
|
132
|
-
atts.push(...collectAttestations(branch.stamp));
|
|
133
|
-
}
|
|
134
|
-
return atts;
|
|
135
|
-
}
|
|
136
|
-
function checkBitcoinConfirmation(bytes) {
|
|
137
|
-
try {
|
|
138
|
-
const ctx = new StreamDeserializationContext(new Uint8Array(bytes));
|
|
139
|
-
const dtf = DetachedTimestampFile.deserialize(ctx);
|
|
140
|
-
const attestations = collectAttestations(dtf.timestamp);
|
|
141
|
-
const bitcoinAtts = attestations.filter((a) => a.kind === "bitcoin");
|
|
142
|
-
if (bitcoinAtts.length === 0) return { confirmed: false };
|
|
143
|
-
const block = Math.min(...bitcoinAtts.map((a) => a.height));
|
|
144
|
-
return { confirmed: true, block };
|
|
145
|
-
} catch {
|
|
146
|
-
return { confirmed: false };
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
function nextRetryAt(attemptCount) {
|
|
150
|
-
const base = Math.min(3e4 * Math.pow(2, attemptCount), 36e5);
|
|
151
|
-
const jitter = Math.random() * 0.2 * base;
|
|
152
|
-
return new Date(Date.now() + base + jitter).toISOString();
|
|
153
|
-
}
|
|
154
|
-
async function upgradeTimestamp(input, db, config) {
|
|
155
|
-
const record = getStamp(db, input.id);
|
|
156
|
-
if (!record) return { error: "not_found", details: `No stamp with id ${input.id}` };
|
|
157
|
-
if (!record.proof_path) return { error: "storage_error", details: "No proof_path on record" };
|
|
158
|
-
const proofBefore = readFileSync(record.proof_path);
|
|
159
|
-
const client = new OpenTimestampsClient2({
|
|
160
|
-
calendars: config.calendars,
|
|
161
|
-
resilience: { timeout: config.calendar_timeout_ms }
|
|
162
|
-
});
|
|
163
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
164
|
-
const newAttemptCount = record.attempt_count + 1;
|
|
165
|
-
const next = nextRetryAt(newAttemptCount);
|
|
166
|
-
let upgraded;
|
|
167
|
-
try {
|
|
168
|
-
upgraded = await client.upgrade(proofBefore);
|
|
169
|
-
} catch (e) {
|
|
170
|
-
if (e instanceof UpgradeError) {
|
|
171
|
-
updateStampStatus(db, input.id, { last_attempt_at: now, attempt_count: newAttemptCount, next_retry_at: next });
|
|
172
|
-
logOperation(db, { stamp_id: input.id, action: "upgrade", result: "pending" });
|
|
173
|
-
return { id: input.id, status: "pending", attempt_count: newAttemptCount, last_attempt_at: now, next_retry_at: next };
|
|
174
|
-
}
|
|
175
|
-
updateStampStatus(db, input.id, { last_attempt_at: now, attempt_count: newAttemptCount, last_error: String(e), next_retry_at: next });
|
|
176
|
-
logOperation(db, { stamp_id: input.id, action: "upgrade", result: "failed", error_msg: String(e) });
|
|
177
|
-
return { error: "calendar_error", details: String(e) };
|
|
178
|
-
}
|
|
179
|
-
writeAtomic(record.proof_path, upgraded);
|
|
180
|
-
const { confirmed, block } = checkBitcoinConfirmation(upgraded);
|
|
181
|
-
if (confirmed && block !== void 0) {
|
|
182
|
-
const bitcoinTime = now;
|
|
183
|
-
updateStampStatus(db, input.id, {
|
|
184
|
-
status: "confirmed",
|
|
185
|
-
bitcoin_block: block,
|
|
186
|
-
bitcoin_time: bitcoinTime,
|
|
187
|
-
confirmed_at: now,
|
|
188
|
-
last_attempt_at: now,
|
|
189
|
-
attempt_count: newAttemptCount
|
|
190
|
-
});
|
|
191
|
-
logOperation(db, { stamp_id: input.id, action: "upgrade", result: "success" });
|
|
192
|
-
return { id: input.id, status: "confirmed", bitcoin_block: block, bitcoin_time: bitcoinTime, proof_path: record.proof_path };
|
|
193
|
-
}
|
|
194
|
-
updateStampStatus(db, input.id, { last_attempt_at: now, attempt_count: newAttemptCount, next_retry_at: next });
|
|
195
|
-
logOperation(db, { stamp_id: input.id, action: "upgrade", result: "pending" });
|
|
196
|
-
return { id: input.id, status: "pending", attempt_count: newAttemptCount, last_attempt_at: now, next_retry_at: next };
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// src/tools/verify-timestamp.ts
|
|
200
|
-
import { readFileSync as readFileSync2 } from "fs";
|
|
201
|
-
import { OpenTimestampsClient as OpenTimestampsClient3 } from "@otskit/client";
|
|
202
|
-
async function verifyTimestamp(input, db, config) {
|
|
203
|
-
const record = getStamp(db, input.id);
|
|
204
|
-
if (!record) return { error: "not_found", details: `No stamp with id ${input.id}` };
|
|
205
|
-
if (!record.proof_path) return { error: "storage_error", details: "No proof_path on record" };
|
|
206
|
-
let proofBytes;
|
|
207
|
-
try {
|
|
208
|
-
proofBytes = readFileSync2(record.proof_path);
|
|
209
|
-
} catch (e) {
|
|
210
|
-
return { error: "storage_error", details: String(e) };
|
|
211
|
-
}
|
|
212
|
-
const client = new OpenTimestampsClient3({
|
|
213
|
-
calendars: config.calendars,
|
|
214
|
-
resilience: { timeout: config.calendar_timeout_ms }
|
|
215
|
-
});
|
|
216
|
-
let result;
|
|
217
|
-
try {
|
|
218
|
-
result = await client.verify(proofBytes, record.hash);
|
|
219
|
-
} catch (e) {
|
|
220
|
-
logOperation(db, { stamp_id: input.id, action: "verify", result: "failed", error_msg: String(e) });
|
|
221
|
-
return { status: "network_error", hash: record.hash, details: String(e) };
|
|
222
|
-
}
|
|
223
|
-
if (!result.valid) {
|
|
224
|
-
if (result.error?.includes("No Bitcoin attestation")) {
|
|
225
|
-
logOperation(db, { stamp_id: input.id, action: "verify", result: "pending" });
|
|
226
|
-
return { status: "pending", hash: record.hash, calendars: config.calendars };
|
|
227
|
-
}
|
|
228
|
-
if (result.error?.toLowerCase().includes("invalid") || result.error?.toLowerCase().includes("corrupt")) {
|
|
229
|
-
logOperation(db, { stamp_id: input.id, action: "verify", result: "failed", error_msg: result.error });
|
|
230
|
-
return { status: "invalid", hash: record.hash, reason: result.error ?? "unknown" };
|
|
231
|
-
}
|
|
232
|
-
logOperation(db, { stamp_id: input.id, action: "verify", result: "failed", error_msg: result.error });
|
|
233
|
-
return { status: "unknown", hash: record.hash };
|
|
234
|
-
}
|
|
235
|
-
logOperation(db, { stamp_id: input.id, action: "verify", result: "success" });
|
|
236
|
-
return {
|
|
237
|
-
status: "confirmed",
|
|
238
|
-
hash: record.hash,
|
|
239
|
-
bitcoin_block: result.blockHeight,
|
|
240
|
-
bitcoin_time: new Date(result.timestamp * 1e3).toISOString()
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// src/tools/list-pending.ts
|
|
245
|
-
function toPublic({ attempt_count: _, last_attempt_at: __, next_retry_at: ___, ...rest }) {
|
|
246
|
-
return rest;
|
|
247
|
-
}
|
|
248
|
-
function listPending(input, db, _config) {
|
|
249
|
-
const result = listStamps(db, {
|
|
250
|
-
status: input.status ?? "pending",
|
|
251
|
-
limit: Math.min(input.limit ?? 50, 200),
|
|
252
|
-
offset: input.offset ?? 0,
|
|
253
|
-
older_than_hours: input.older_than_hours,
|
|
254
|
-
due_now: input.due_now
|
|
255
|
-
});
|
|
256
|
-
return { items: result.items.map(toPublic), total: result.total };
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
export {
|
|
260
|
-
getStamp,
|
|
261
|
-
createTimestamp,
|
|
262
|
-
upgradeTimestamp,
|
|
263
|
-
verifyTimestamp,
|
|
264
|
-
listPending
|
|
265
|
-
};
|
package/dist/chunk-YFSUDT24.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// src/utils.ts
|
|
2
|
-
import { execFileSync } from "child_process";
|
|
3
|
-
import { writeFileSync, renameSync } from "fs";
|
|
4
|
-
function which(cmd) {
|
|
5
|
-
try {
|
|
6
|
-
const out = execFileSync(
|
|
7
|
-
process.platform === "win32" ? "where" : "which",
|
|
8
|
-
[cmd]
|
|
9
|
-
).toString().trim();
|
|
10
|
-
return out.split("\n")[0] ?? null;
|
|
11
|
-
} catch {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function writeAtomic(dest, data) {
|
|
16
|
-
const tmp = dest + ".tmp";
|
|
17
|
-
writeFileSync(tmp, data);
|
|
18
|
-
renameSync(tmp, dest);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export {
|
|
22
|
-
which,
|
|
23
|
-
writeAtomic
|
|
24
|
-
};
|
package/dist/claude-QTEB3Z5V.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// src/setup/claude.ts
|
|
2
|
-
import { readFileSync, writeFileSync, copyFileSync, mkdirSync, existsSync } from "fs";
|
|
3
|
-
import { join } from "path";
|
|
4
|
-
import { homedir } from "os";
|
|
5
|
-
function getConfigPath() {
|
|
6
|
-
if (process.platform === "win32") {
|
|
7
|
-
return join(process.env.APPDATA ?? "", "Claude", "claude_desktop_config.json");
|
|
8
|
-
} else if (process.platform === "darwin") {
|
|
9
|
-
return join(homedir(), "Library", "Application Support", "Claude", "claude_desktop_config.json");
|
|
10
|
-
} else {
|
|
11
|
-
return join(homedir(), ".config", "Claude", "claude_desktop_config.json");
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function setupClaude() {
|
|
15
|
-
const configPath = getConfigPath();
|
|
16
|
-
const configDir = join(configPath, "..");
|
|
17
|
-
if (!existsSync(configDir)) {
|
|
18
|
-
mkdirSync(configDir, { recursive: true });
|
|
19
|
-
}
|
|
20
|
-
let config = {};
|
|
21
|
-
if (existsSync(configPath)) {
|
|
22
|
-
try {
|
|
23
|
-
config = JSON.parse(readFileSync(configPath, "utf8"));
|
|
24
|
-
} catch {
|
|
25
|
-
process.stderr.write(` Aviso: no se pudo parsear la config existente, se crear\xE1 nueva.
|
|
26
|
-
`);
|
|
27
|
-
}
|
|
28
|
-
const existing = config.mcpServers ?? {};
|
|
29
|
-
if ("otskit" in existing) {
|
|
30
|
-
process.stdout.write(` ots-mcp ya est\xE1 configurado en ${configPath}
|
|
31
|
-
`);
|
|
32
|
-
process.stdout.write(` No se hizo ning\xFAn cambio.
|
|
33
|
-
`);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
const backupPath = configPath + ".bak";
|
|
37
|
-
copyFileSync(configPath, backupPath);
|
|
38
|
-
process.stdout.write(` Backup guardado en ${backupPath}
|
|
39
|
-
`);
|
|
40
|
-
}
|
|
41
|
-
const mcpServers = config.mcpServers ?? {};
|
|
42
|
-
mcpServers["otskit"] = { command: "npx", args: ["-y", "@otskit/mcp", "serve"] };
|
|
43
|
-
config.mcpServers = mcpServers;
|
|
44
|
-
writeFileSync(configPath, JSON.stringify(config, null, 2), "utf8");
|
|
45
|
-
process.stdout.write(`OTSkit MCP configurado para Claude Desktop
|
|
46
|
-
`);
|
|
47
|
-
process.stdout.write(` Config: ${configPath}
|
|
48
|
-
`);
|
|
49
|
-
process.stdout.write(` Reinicia Claude Desktop para aplicar los cambios.
|
|
50
|
-
`);
|
|
51
|
-
}
|
|
52
|
-
export {
|
|
53
|
-
setupClaude
|
|
54
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
// src/setup/claude-code.ts
|
|
2
|
-
import { readFileSync, writeFileSync, copyFileSync, mkdirSync, existsSync } from "fs";
|
|
3
|
-
import { join } from "path";
|
|
4
|
-
import { homedir } from "os";
|
|
5
|
-
function getConfigPath() {
|
|
6
|
-
return join(homedir(), ".claude.json");
|
|
7
|
-
}
|
|
8
|
-
function setupClaudeCode() {
|
|
9
|
-
const configPath = getConfigPath();
|
|
10
|
-
const configDir = join(configPath, "..");
|
|
11
|
-
if (!existsSync(configDir)) {
|
|
12
|
-
mkdirSync(configDir, { recursive: true });
|
|
13
|
-
}
|
|
14
|
-
let config = {};
|
|
15
|
-
if (existsSync(configPath)) {
|
|
16
|
-
try {
|
|
17
|
-
config = JSON.parse(readFileSync(configPath, "utf8"));
|
|
18
|
-
} catch {
|
|
19
|
-
process.stderr.write(` Aviso: no se pudo parsear la config existente, se crear\xE1 nueva.
|
|
20
|
-
`);
|
|
21
|
-
}
|
|
22
|
-
const existing = config.mcpServers ?? {};
|
|
23
|
-
if ("otskit" in existing) {
|
|
24
|
-
process.stdout.write(` ots-mcp ya est\xE1 configurado en ${configPath}
|
|
25
|
-
`);
|
|
26
|
-
process.stdout.write(` No se hizo ning\xFAn cambio.
|
|
27
|
-
`);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
const backupPath = configPath + ".bak";
|
|
31
|
-
copyFileSync(configPath, backupPath);
|
|
32
|
-
process.stdout.write(` Backup guardado en ${backupPath}
|
|
33
|
-
`);
|
|
34
|
-
}
|
|
35
|
-
const mcpServers = config.mcpServers ?? {};
|
|
36
|
-
mcpServers["otskit"] = { command: "npx", args: ["-y", "@otskit/mcp", "serve"] };
|
|
37
|
-
config.mcpServers = mcpServers;
|
|
38
|
-
writeFileSync(configPath, JSON.stringify(config, null, 2), "utf8");
|
|
39
|
-
process.stdout.write(`OTSkit MCP configurado para Claude Code CLI
|
|
40
|
-
`);
|
|
41
|
-
process.stdout.write(` Config: ${configPath}
|
|
42
|
-
`);
|
|
43
|
-
process.stdout.write(` Reinicia Claude Code para aplicar los cambios.
|
|
44
|
-
`);
|
|
45
|
-
}
|
|
46
|
-
export {
|
|
47
|
-
setupClaudeCode
|
|
48
|
-
};
|
package/dist/cli-D7G2H6UT.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createTimestamp,
|
|
3
|
-
listPending,
|
|
4
|
-
upgradeTimestamp,
|
|
5
|
-
verifyTimestamp
|
|
6
|
-
} from "./chunk-OMNHFTJW.js";
|
|
7
|
-
import {
|
|
8
|
-
backupDb,
|
|
9
|
-
getDb,
|
|
10
|
-
loadConfig
|
|
11
|
-
} from "./chunk-4ZDPWS7C.js";
|
|
12
|
-
import "./chunk-YFSUDT24.js";
|
|
13
|
-
|
|
14
|
-
// src/cli.ts
|
|
15
|
-
async function runCli(command, args) {
|
|
16
|
-
const config = loadConfig();
|
|
17
|
-
const db = getDb();
|
|
18
|
-
switch (command) {
|
|
19
|
-
case "stamp": {
|
|
20
|
-
const hash = args[0];
|
|
21
|
-
if (!hash) {
|
|
22
|
-
process.stderr.write("Usage: ots-mcp stamp <sha256-hash>\n");
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
const result = await createTimestamp({ hash }, db, config);
|
|
26
|
-
if ("error" in result) {
|
|
27
|
-
process.stderr.write(`Error: ${result.error} \u2014 ${result.details}
|
|
28
|
-
`);
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
31
|
-
process.stdout.write(JSON.stringify(result, null, 2) + "\n");
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
case "upgrade": {
|
|
35
|
-
const id = args[0];
|
|
36
|
-
if (!id) {
|
|
37
|
-
process.stderr.write("Usage: ots-mcp upgrade <id>\n");
|
|
38
|
-
process.exit(1);
|
|
39
|
-
}
|
|
40
|
-
const result = await upgradeTimestamp({ id }, db, config);
|
|
41
|
-
if ("error" in result) {
|
|
42
|
-
process.stderr.write(`Error: ${result.error} \u2014 ${result.details}
|
|
43
|
-
`);
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
process.stdout.write(JSON.stringify(result, null, 2) + "\n");
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
case "verify": {
|
|
50
|
-
const id = args[0];
|
|
51
|
-
if (!id) {
|
|
52
|
-
process.stderr.write("Usage: ots-mcp verify <id>\n");
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
const result = await verifyTimestamp({ id }, db, config);
|
|
56
|
-
if ("error" in result) {
|
|
57
|
-
process.stderr.write(`Error: ${result.error} \u2014 ${result.details}
|
|
58
|
-
`);
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
process.stdout.write(JSON.stringify(result, null, 2) + "\n");
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
case "list": {
|
|
65
|
-
const status = args[0] ?? "pending";
|
|
66
|
-
const result = listPending({ status }, db, config);
|
|
67
|
-
process.stdout.write(JSON.stringify(result, null, 2) + "\n");
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
case "check-pending": {
|
|
71
|
-
const { items } = listPending({ status: "pending", limit: 200, due_now: true }, db, config);
|
|
72
|
-
process.stderr.write(`Processing ${items.length} pending stamps...
|
|
73
|
-
`);
|
|
74
|
-
for (const record of items) {
|
|
75
|
-
const result = await upgradeTimestamp({ id: record.id }, db, config);
|
|
76
|
-
const statusStr = "status" in result ? result.status : `error:${result.error}`;
|
|
77
|
-
process.stderr.write(`${record.id.slice(0, 8)}: ${statusStr}
|
|
78
|
-
`);
|
|
79
|
-
}
|
|
80
|
-
process.exit(0);
|
|
81
|
-
}
|
|
82
|
-
case "backup": {
|
|
83
|
-
const dest = args[0] ?? `ots-mcp-backup-${Date.now()}.sqlite`;
|
|
84
|
-
backupDb(dest);
|
|
85
|
-
process.stdout.write(`Backup saved to ${dest}
|
|
86
|
-
`);
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
case "scheduler": {
|
|
90
|
-
const { runScheduler } = await import("./scheduler-MTE6OUSV.js");
|
|
91
|
-
await runScheduler(args);
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
export {
|
|
97
|
-
runCli
|
|
98
|
-
};
|
package/dist/codex-P7EDO5GY.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// src/setup/codex.ts
|
|
2
|
-
import { readFileSync, writeFileSync, copyFileSync, mkdirSync, existsSync } from "fs";
|
|
3
|
-
import { join } from "path";
|
|
4
|
-
import { homedir } from "os";
|
|
5
|
-
var BLOCK = `
|
|
6
|
-
[mcp_servers.ots-mcp]
|
|
7
|
-
command = "npx"
|
|
8
|
-
args = ["-y", "@otskit/mcp", "serve"]
|
|
9
|
-
`;
|
|
10
|
-
function setupCodex() {
|
|
11
|
-
const configPath = join(homedir(), ".codex", "config.toml");
|
|
12
|
-
const configDir = join(configPath, "..");
|
|
13
|
-
if (!existsSync(configDir)) {
|
|
14
|
-
mkdirSync(configDir, { recursive: true });
|
|
15
|
-
}
|
|
16
|
-
let content = "";
|
|
17
|
-
if (existsSync(configPath)) {
|
|
18
|
-
content = readFileSync(configPath, "utf8");
|
|
19
|
-
if (content.includes("[mcp_servers.ots-mcp]")) {
|
|
20
|
-
process.stdout.write(` ots-mcp ya est\xE1 configurado en ${configPath}
|
|
21
|
-
`);
|
|
22
|
-
process.stdout.write(` No se hizo ning\xFAn cambio.
|
|
23
|
-
`);
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const backupPath = configPath + ".bak";
|
|
27
|
-
copyFileSync(configPath, backupPath);
|
|
28
|
-
process.stdout.write(` Backup guardado en ${backupPath}
|
|
29
|
-
`);
|
|
30
|
-
}
|
|
31
|
-
writeFileSync(configPath, content.trimEnd() + "\n" + BLOCK, "utf8");
|
|
32
|
-
process.stdout.write(`OTSkit MCP configurado para Codex
|
|
33
|
-
`);
|
|
34
|
-
process.stdout.write(` Config: ${configPath}
|
|
35
|
-
`);
|
|
36
|
-
process.stdout.write(` Reinicia Codex para aplicar los cambios.
|
|
37
|
-
`);
|
|
38
|
-
}
|
|
39
|
-
export {
|
|
40
|
-
setupCodex
|
|
41
|
-
};
|
package/dist/index.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/index.ts
|
|
4
|
-
var [, , command, ...args] = process.argv;
|
|
5
|
-
if (!command || command === "--help" || command === "help") {
|
|
6
|
-
process.stderr.write(`Usage: ots-mcp <command>
|
|
7
|
-
Commands:
|
|
8
|
-
serve Start MCP server (stdio transport)
|
|
9
|
-
setup <target> Configure MCP for an agent (claude | claude-code | codex)
|
|
10
|
-
watch [interval] Watch pending stamps in real-time (default: 5 min)
|
|
11
|
-
stamp <hash> Stamp a SHA-256 hash
|
|
12
|
-
upgrade <id> Upgrade a pending stamp
|
|
13
|
-
verify <id> Verify a stamp
|
|
14
|
-
list [status] List stamps (default: pending)
|
|
15
|
-
check-pending Run pending upgrades (for scheduler)
|
|
16
|
-
backup [dest] Backup the SQLite database
|
|
17
|
-
scheduler Manage OS scheduler (install|remove|status)
|
|
18
|
-
`);
|
|
19
|
-
process.exit(command ? 0 : 1);
|
|
20
|
-
}
|
|
21
|
-
switch (command) {
|
|
22
|
-
case "serve": {
|
|
23
|
-
const { runServer } = await import("./server-IDRHOKL7.js");
|
|
24
|
-
await runServer();
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
case "setup": {
|
|
28
|
-
const target = args[0];
|
|
29
|
-
if (!target || target !== "claude" && target !== "claude-code" && target !== "codex") {
|
|
30
|
-
process.stderr.write(`Usage: ots-mcp setup <claude|claude-code|codex>
|
|
31
|
-
`);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
if (target === "claude") {
|
|
35
|
-
const { setupClaude } = await import("./claude-QTEB3Z5V.js");
|
|
36
|
-
setupClaude();
|
|
37
|
-
} else if (target === "claude-code") {
|
|
38
|
-
const { setupClaudeCode } = await import("./claude-code-THJIWEHG.js");
|
|
39
|
-
setupClaudeCode();
|
|
40
|
-
} else {
|
|
41
|
-
const { setupCodex } = await import("./codex-P7EDO5GY.js");
|
|
42
|
-
setupCodex();
|
|
43
|
-
}
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
case "install-claude": {
|
|
47
|
-
const { installClaude } = await import("./install-claude-UKSS65BW.js");
|
|
48
|
-
installClaude();
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
case "watch": {
|
|
52
|
-
const { watchPending } = await import("./watch-7NPUWR6I.js");
|
|
53
|
-
const parsed = args[0] ? parseInt(args[0], 10) : NaN;
|
|
54
|
-
const interval = isNaN(parsed) || parsed < 1 ? 5 : parsed;
|
|
55
|
-
if (args[0] && (isNaN(parsed) || parsed < 1))
|
|
56
|
-
process.stderr.write(`Argumento inv\xE1lido "${args[0]}", usando intervalo por defecto: 5 min
|
|
57
|
-
`);
|
|
58
|
-
await watchPending(interval);
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
case "stamp":
|
|
62
|
-
case "upgrade":
|
|
63
|
-
case "verify":
|
|
64
|
-
case "list":
|
|
65
|
-
case "check-pending":
|
|
66
|
-
case "backup":
|
|
67
|
-
case "scheduler": {
|
|
68
|
-
const { runCli } = await import("./cli-D7G2H6UT.js");
|
|
69
|
-
await runCli(command, args);
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
default: {
|
|
73
|
-
process.stderr.write(`Unknown command: ${command}. Run 'ots-mcp help' for usage.
|
|
74
|
-
`);
|
|
75
|
-
process.exit(1);
|
|
76
|
-
}
|
|
77
|
-
}
|
package/dist/install-BUSOMBB2.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
which
|
|
3
|
-
} from "./chunk-YFSUDT24.js";
|
|
4
|
-
|
|
5
|
-
// src/scheduler/install.ts
|
|
6
|
-
import { execFileSync } from "child_process";
|
|
7
|
-
import { writeFileSync } from "fs";
|
|
8
|
-
async function installScheduler(args) {
|
|
9
|
-
const intervalIdx = args.indexOf("--interval");
|
|
10
|
-
const interval = intervalIdx !== -1 ? parseInt(args[intervalIdx + 1] ?? "30") : 30;
|
|
11
|
-
const bin = which("ots-mcp") ?? process.argv[1];
|
|
12
|
-
if (process.platform === "win32") {
|
|
13
|
-
const xmlPath = `${process.env.TEMP}\\ots-mcp-task.xml`;
|
|
14
|
-
writeFileSync(xmlPath, `<?xml version="1.0"?>
|
|
15
|
-
<Task xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
|
16
|
-
<Triggers><TimeTrigger>
|
|
17
|
-
<Repetition><Interval>PT${interval}M</Interval><StopAtDurationEnd>false</StopAtDurationEnd></Repetition>
|
|
18
|
-
<StartBoundary>2020-01-01T00:00:00</StartBoundary><Enabled>true</Enabled>
|
|
19
|
-
</TimeTrigger></Triggers>
|
|
20
|
-
<Actions><Exec>
|
|
21
|
-
<Command>${bin}</Command>
|
|
22
|
-
<Arguments>check-pending</Arguments>
|
|
23
|
-
</Exec></Actions>
|
|
24
|
-
</Task>`);
|
|
25
|
-
execFileSync("schtasks", ["/create", "/tn", "ots-mcp-check-pending", "/xml", xmlPath, "/f"]);
|
|
26
|
-
process.stdout.write(`Scheduler installed: runs every ${interval} minutes
|
|
27
|
-
`);
|
|
28
|
-
} else {
|
|
29
|
-
process.stdout.write(`Add to crontab (run: crontab -e):
|
|
30
|
-
`);
|
|
31
|
-
process.stdout.write(`*/${interval} * * * * "${bin}" check-pending
|
|
32
|
-
`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export {
|
|
36
|
-
installScheduler
|
|
37
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// src/install-claude.ts
|
|
2
|
-
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
|
|
3
|
-
import { join } from "path";
|
|
4
|
-
function getConfigPath() {
|
|
5
|
-
if (process.platform === "win32") {
|
|
6
|
-
return join(process.env.APPDATA ?? "", "Claude", "claude_desktop_config.json");
|
|
7
|
-
} else if (process.platform === "darwin") {
|
|
8
|
-
return join(process.env.HOME ?? "", "Library", "Application Support", "Claude", "claude_desktop_config.json");
|
|
9
|
-
} else {
|
|
10
|
-
return join(process.env.HOME ?? "", ".config", "Claude", "claude_desktop_config.json");
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
function installClaude() {
|
|
14
|
-
const configPath = getConfigPath();
|
|
15
|
-
const configDir = join(configPath, "..");
|
|
16
|
-
if (!existsSync(configDir)) {
|
|
17
|
-
mkdirSync(configDir, { recursive: true });
|
|
18
|
-
}
|
|
19
|
-
let config = {};
|
|
20
|
-
if (existsSync(configPath)) {
|
|
21
|
-
try {
|
|
22
|
-
config = JSON.parse(readFileSync(configPath, "utf8"));
|
|
23
|
-
} catch {
|
|
24
|
-
process.stderr.write(`Warning: could not parse existing config, creating new one
|
|
25
|
-
`);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const mcpServers = config.mcpServers ?? {};
|
|
29
|
-
mcpServers["otskit"] = {
|
|
30
|
-
command: "npx",
|
|
31
|
-
args: ["-y", "@otskit/mcp", "serve"]
|
|
32
|
-
};
|
|
33
|
-
config.mcpServers = mcpServers;
|
|
34
|
-
writeFileSync(configPath, JSON.stringify(config, null, 2), "utf8");
|
|
35
|
-
process.stdout.write(`\u2713 OTSkit MCP installed in Claude Desktop
|
|
36
|
-
`);
|
|
37
|
-
process.stdout.write(` Config: ${configPath}
|
|
38
|
-
`);
|
|
39
|
-
process.stdout.write(` Restart Claude Desktop to apply changes.
|
|
40
|
-
`);
|
|
41
|
-
}
|
|
42
|
-
export {
|
|
43
|
-
installClaude
|
|
44
|
-
};
|