@kl-c/matrixos 0.1.4 → 0.1.6
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/cli/architect.d.ts +16 -0
- package/dist/cli/index.js +284 -107
- package/dist/cli-node/index.js +284 -107
- package/dist/index.js +1433 -1198
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14123,6 +14123,41 @@ var init_storage = __esm(() => {
|
|
|
14123
14123
|
init_constants3();
|
|
14124
14124
|
});
|
|
14125
14125
|
|
|
14126
|
+
// node_modules/.bun/sqlite-vec@0.1.9/node_modules/sqlite-vec/index.cjs
|
|
14127
|
+
var require_sqlite_vec = __commonJS((exports, module) => {
|
|
14128
|
+
var { arch, platform: platform3 } = __require("process");
|
|
14129
|
+
var BASE_PACKAGE_NAME = "sqlite-vec";
|
|
14130
|
+
var ENTRYPOINT_BASE_NAME = "vec0";
|
|
14131
|
+
var supportedPlatforms = [["darwin", "x64"], ["linux", "x64"], ["darwin", "arm64"], ["win32", "x64"], ["linux", "arm64"]];
|
|
14132
|
+
var invalidPlatformErrorMessage = `Unsupported platform for ${BASE_PACKAGE_NAME}, on a ${platform3}-${arch} machine. Supported platforms are (${supportedPlatforms.map(([p, a]) => `${p}-${a}`).join(",")}). Consult the ${BASE_PACKAGE_NAME} NPM package README for details.`;
|
|
14133
|
+
function validPlatform(platform4, arch2) {
|
|
14134
|
+
return supportedPlatforms.find(([p, a]) => platform4 === p && arch2 === a) !== undefined;
|
|
14135
|
+
}
|
|
14136
|
+
function extensionSuffix(platform4) {
|
|
14137
|
+
if (platform4 === "win32")
|
|
14138
|
+
return "dll";
|
|
14139
|
+
if (platform4 === "darwin")
|
|
14140
|
+
return "dylib";
|
|
14141
|
+
return "so";
|
|
14142
|
+
}
|
|
14143
|
+
function platformPackageName(platform4, arch2) {
|
|
14144
|
+
const os7 = platform4 === "win32" ? "windows" : platform4;
|
|
14145
|
+
return `${BASE_PACKAGE_NAME}-${os7}-${arch2}`;
|
|
14146
|
+
}
|
|
14147
|
+
function getLoadablePath() {
|
|
14148
|
+
if (!validPlatform(platform3, arch)) {
|
|
14149
|
+
throw new Error(invalidPlatformErrorMessage);
|
|
14150
|
+
}
|
|
14151
|
+
const packageName = platformPackageName(platform3, arch);
|
|
14152
|
+
const loadablePath = __require.resolve(packageName + "/" + ENTRYPOINT_BASE_NAME + "." + extensionSuffix(platform3));
|
|
14153
|
+
return loadablePath;
|
|
14154
|
+
}
|
|
14155
|
+
function load(db) {
|
|
14156
|
+
db.loadExtension(getLoadablePath());
|
|
14157
|
+
}
|
|
14158
|
+
module.exports = { getLoadablePath, load };
|
|
14159
|
+
});
|
|
14160
|
+
|
|
14126
14161
|
// node_modules/.bun/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/code.js
|
|
14127
14162
|
var require_code = __commonJS((exports) => {
|
|
14128
14163
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -20981,12 +21016,12 @@ var init_paths3 = __esm(() => {
|
|
|
20981
21016
|
});
|
|
20982
21017
|
|
|
20983
21018
|
// packages/omo-opencode/src/features/team-mode/team-runtime/shutdown-helpers.ts
|
|
20984
|
-
import { randomUUID as
|
|
21019
|
+
import { randomUUID as randomUUID10 } from "crypto";
|
|
20985
21020
|
import { rm as rm5 } from "fs/promises";
|
|
20986
21021
|
function createShutdownMessage(from, to, kind, body) {
|
|
20987
21022
|
return {
|
|
20988
21023
|
version: 1,
|
|
20989
|
-
messageId:
|
|
21024
|
+
messageId: randomUUID10(),
|
|
20990
21025
|
from,
|
|
20991
21026
|
to,
|
|
20992
21027
|
kind,
|
|
@@ -21187,41 +21222,6 @@ var init_delete_team = __esm(() => {
|
|
|
21187
21222
|
ACTIVE_BACKGROUND_TASK_STATUSES3 = new Set(["pending", "running"]);
|
|
21188
21223
|
});
|
|
21189
21224
|
|
|
21190
|
-
// node_modules/.bun/sqlite-vec@0.1.9/node_modules/sqlite-vec/index.cjs
|
|
21191
|
-
var require_sqlite_vec = __commonJS((exports, module) => {
|
|
21192
|
-
var { arch, platform: platform3 } = __require("process");
|
|
21193
|
-
var BASE_PACKAGE_NAME = "sqlite-vec";
|
|
21194
|
-
var ENTRYPOINT_BASE_NAME = "vec0";
|
|
21195
|
-
var supportedPlatforms = [["darwin", "x64"], ["linux", "x64"], ["darwin", "arm64"], ["win32", "x64"], ["linux", "arm64"]];
|
|
21196
|
-
var invalidPlatformErrorMessage = `Unsupported platform for ${BASE_PACKAGE_NAME}, on a ${platform3}-${arch} machine. Supported platforms are (${supportedPlatforms.map(([p, a]) => `${p}-${a}`).join(",")}). Consult the ${BASE_PACKAGE_NAME} NPM package README for details.`;
|
|
21197
|
-
function validPlatform(platform4, arch2) {
|
|
21198
|
-
return supportedPlatforms.find(([p, a]) => platform4 === p && arch2 === a) !== undefined;
|
|
21199
|
-
}
|
|
21200
|
-
function extensionSuffix(platform4) {
|
|
21201
|
-
if (platform4 === "win32")
|
|
21202
|
-
return "dll";
|
|
21203
|
-
if (platform4 === "darwin")
|
|
21204
|
-
return "dylib";
|
|
21205
|
-
return "so";
|
|
21206
|
-
}
|
|
21207
|
-
function platformPackageName(platform4, arch2) {
|
|
21208
|
-
const os7 = platform4 === "win32" ? "windows" : platform4;
|
|
21209
|
-
return `${BASE_PACKAGE_NAME}-${os7}-${arch2}`;
|
|
21210
|
-
}
|
|
21211
|
-
function getLoadablePath() {
|
|
21212
|
-
if (!validPlatform(platform3, arch)) {
|
|
21213
|
-
throw new Error(invalidPlatformErrorMessage);
|
|
21214
|
-
}
|
|
21215
|
-
const packageName = platformPackageName(platform3, arch);
|
|
21216
|
-
const loadablePath = __require.resolve(packageName + "/" + ENTRYPOINT_BASE_NAME + "." + extensionSuffix(platform3));
|
|
21217
|
-
return loadablePath;
|
|
21218
|
-
}
|
|
21219
|
-
function load(db) {
|
|
21220
|
-
db.loadExtension(getLoadablePath());
|
|
21221
|
-
}
|
|
21222
|
-
module.exports = { getLoadablePath, load };
|
|
21223
|
-
});
|
|
21224
|
-
|
|
21225
21225
|
// node_modules/.bun/grammy@1.45.1/node_modules/grammy/out/filter.js
|
|
21226
21226
|
var require_filter = __commonJS((exports) => {
|
|
21227
21227
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -57285,7 +57285,7 @@ var require_dist10 = __commonJS((exports, module) => {
|
|
|
57285
57285
|
var import_node_worker_threads2 = __require("worker_threads");
|
|
57286
57286
|
var import_collection2 = require_dist3();
|
|
57287
57287
|
var import_node_events = __require("events");
|
|
57288
|
-
var
|
|
57288
|
+
var import_node_path126 = __require("path");
|
|
57289
57289
|
var import_node_worker_threads = __require("worker_threads");
|
|
57290
57290
|
var import_collection = require_dist3();
|
|
57291
57291
|
var WorkerSendPayloadOp = /* @__PURE__ */ ((WorkerSendPayloadOp2) => {
|
|
@@ -57420,18 +57420,18 @@ var require_dist10 = __commonJS((exports, module) => {
|
|
|
57420
57420
|
resolveWorkerPath() {
|
|
57421
57421
|
const path28 = this.options.workerPath;
|
|
57422
57422
|
if (!path28) {
|
|
57423
|
-
return (0,
|
|
57423
|
+
return (0, import_node_path126.join)(__dirname, "defaultWorker.js");
|
|
57424
57424
|
}
|
|
57425
|
-
if ((0,
|
|
57425
|
+
if ((0, import_node_path126.isAbsolute)(path28)) {
|
|
57426
57426
|
return path28;
|
|
57427
57427
|
}
|
|
57428
57428
|
if (/^\.\.?[/\\]/.test(path28)) {
|
|
57429
|
-
return (0,
|
|
57429
|
+
return (0, import_node_path126.resolve)(path28);
|
|
57430
57430
|
}
|
|
57431
57431
|
try {
|
|
57432
57432
|
return __require.resolve(path28);
|
|
57433
57433
|
} catch {
|
|
57434
|
-
return (0,
|
|
57434
|
+
return (0, import_node_path126.resolve)(path28);
|
|
57435
57435
|
}
|
|
57436
57436
|
}
|
|
57437
57437
|
async waitForWorkerReady(worker) {
|
|
@@ -233073,7 +233073,7 @@ import * as Crypto from "crypto";
|
|
|
233073
233073
|
import { once } from "events";
|
|
233074
233074
|
import { createReadStream, createWriteStream, promises as fs26, WriteStream } from "fs";
|
|
233075
233075
|
import { tmpdir as tmpdir8 } from "os";
|
|
233076
|
-
import { join as
|
|
233076
|
+
import { join as join134 } from "path";
|
|
233077
233077
|
import { Readable as Readable2, Transform } from "stream";
|
|
233078
233078
|
import { URL as URL2 } from "url";
|
|
233079
233079
|
async function getMediaKeys(buffer2, mediaType) {
|
|
@@ -233151,7 +233151,7 @@ async function generateThumbnail(file2, mediaType, options) {
|
|
|
233151
233151
|
};
|
|
233152
233152
|
}
|
|
233153
233153
|
} else if (mediaType === "video") {
|
|
233154
|
-
const imgFilename =
|
|
233154
|
+
const imgFilename = join134(getTmpFilesDirectory(), generateMessageIDV2() + ".jpg");
|
|
233155
233155
|
try {
|
|
233156
233156
|
await extractVideoThumb(file2, imgFilename, "00:00:00", { width: 32, height: 32 });
|
|
233157
233157
|
const buff = await fs26.readFile(imgFilename);
|
|
@@ -233194,7 +233194,7 @@ var import_boom5, getTmpFilesDirectory = () => tmpdir8(), getImageProcessingLibr
|
|
|
233194
233194
|
const { stream: stream3 } = await getStream(media);
|
|
233195
233195
|
logger7?.debug("got stream for raw upload");
|
|
233196
233196
|
const hasher = Crypto.createHash("sha256");
|
|
233197
|
-
const filePath =
|
|
233197
|
+
const filePath = join134(tmpdir8(), mediaType + generateMessageIDV2());
|
|
233198
233198
|
const fileWriteStream = createWriteStream(filePath);
|
|
233199
233199
|
let fileLength = 0;
|
|
233200
233200
|
try {
|
|
@@ -233334,12 +233334,12 @@ var import_boom5, getTmpFilesDirectory = () => tmpdir8(), getImageProcessingLibr
|
|
|
233334
233334
|
logger7?.debug("fetched media stream");
|
|
233335
233335
|
const mediaKey = Crypto.randomBytes(32);
|
|
233336
233336
|
const { cipherKey, iv, macKey } = await getMediaKeys(mediaKey, mediaType);
|
|
233337
|
-
const encFilePath =
|
|
233337
|
+
const encFilePath = join134(getTmpFilesDirectory(), mediaType + generateMessageIDV2() + "-enc");
|
|
233338
233338
|
const encFileWriteStream = createWriteStream(encFilePath);
|
|
233339
233339
|
let originalFileStream;
|
|
233340
233340
|
let originalFilePath;
|
|
233341
233341
|
if (saveOriginalFileIfRequired) {
|
|
233342
|
-
originalFilePath =
|
|
233342
|
+
originalFilePath = join134(getTmpFilesDirectory(), mediaType + generateMessageIDV2() + "-original");
|
|
233343
233343
|
originalFileStream = createWriteStream(originalFilePath);
|
|
233344
233344
|
}
|
|
233345
233345
|
let fileLength = 0;
|
|
@@ -242744,7 +242744,7 @@ var init_auth_utils = __esm(() => {
|
|
|
242744
242744
|
|
|
242745
242745
|
// node_modules/.bun/@whiskeysockets+baileys@7.0.0-rc13+13d21a63c79191a3/node_modules/@whiskeysockets/baileys/lib/Utils/use-multi-file-auth-state.js
|
|
242746
242746
|
import { mkdir as mkdir11, readFile as readFile14, stat as stat8, unlink as unlink3, writeFile as writeFile4 } from "fs/promises";
|
|
242747
|
-
import { join as
|
|
242747
|
+
import { join as join135 } from "path";
|
|
242748
242748
|
var fileLocks, getFileLock = (path28) => {
|
|
242749
242749
|
let mutex = fileLocks.get(path28);
|
|
242750
242750
|
if (!mutex) {
|
|
@@ -242754,7 +242754,7 @@ var fileLocks, getFileLock = (path28) => {
|
|
|
242754
242754
|
return mutex;
|
|
242755
242755
|
}, useMultiFileAuthState = async (folder) => {
|
|
242756
242756
|
const writeData = async (data3, file2) => {
|
|
242757
|
-
const filePath =
|
|
242757
|
+
const filePath = join135(folder, fixFileName(file2));
|
|
242758
242758
|
const mutex = getFileLock(filePath);
|
|
242759
242759
|
return mutex.acquire().then(async (release2) => {
|
|
242760
242760
|
try {
|
|
@@ -242766,7 +242766,7 @@ var fileLocks, getFileLock = (path28) => {
|
|
|
242766
242766
|
};
|
|
242767
242767
|
const readData = async (file2) => {
|
|
242768
242768
|
try {
|
|
242769
|
-
const filePath =
|
|
242769
|
+
const filePath = join135(folder, fixFileName(file2));
|
|
242770
242770
|
const mutex = getFileLock(filePath);
|
|
242771
242771
|
return await mutex.acquire().then(async (release2) => {
|
|
242772
242772
|
try {
|
|
@@ -242782,7 +242782,7 @@ var fileLocks, getFileLock = (path28) => {
|
|
|
242782
242782
|
};
|
|
242783
242783
|
const removeData = async (file2) => {
|
|
242784
242784
|
try {
|
|
242785
|
-
const filePath =
|
|
242785
|
+
const filePath = join135(folder, fixFileName(file2));
|
|
242786
242786
|
const mutex = getFileLock(filePath);
|
|
242787
242787
|
return mutex.acquire().then(async (release2) => {
|
|
242788
242788
|
try {
|
|
@@ -263753,7 +263753,7 @@ var require_thread_stream = __commonJS((exports, module) => {
|
|
|
263753
263753
|
var { version: version2 } = require_package3();
|
|
263754
263754
|
var { EventEmitter: EventEmitter4 } = __require("events");
|
|
263755
263755
|
var { Worker } = __require("worker_threads");
|
|
263756
|
-
var { join:
|
|
263756
|
+
var { join: join136 } = __require("path");
|
|
263757
263757
|
var { pathToFileURL: pathToFileURL2 } = __require("url");
|
|
263758
263758
|
var { wait: wait2 } = require_wait2();
|
|
263759
263759
|
var {
|
|
@@ -263796,7 +263796,7 @@ var require_thread_stream = __commonJS((exports, module) => {
|
|
|
263796
263796
|
function createWorker(stream3, opts) {
|
|
263797
263797
|
const { filename, workerData } = opts;
|
|
263798
263798
|
const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
|
|
263799
|
-
const toExecute = bundlerOverrides["thread-stream-worker"] ||
|
|
263799
|
+
const toExecute = bundlerOverrides["thread-stream-worker"] || join136(__dirname, "lib", "worker.js");
|
|
263800
263800
|
const worker = new Worker(toExecute, {
|
|
263801
263801
|
...opts.workerOpts,
|
|
263802
263802
|
trackUnmanagedFds: false,
|
|
@@ -264197,7 +264197,7 @@ var require_transport = __commonJS((exports, module) => {
|
|
|
264197
264197
|
var __dirname = "/home/shiro/MaTrixOS/node_modules/.bun/pino@9.14.0/node_modules/pino/lib";
|
|
264198
264198
|
var { createRequire: createRequire4 } = __require("module");
|
|
264199
264199
|
var getCallers = require_caller();
|
|
264200
|
-
var { join:
|
|
264200
|
+
var { join: join136, isAbsolute: isAbsolute21, sep: sep3 } = __require("path");
|
|
264201
264201
|
var sleep3 = require_atomic_sleep();
|
|
264202
264202
|
var onExit = require_on_exit_leak_free();
|
|
264203
264203
|
var ThreadStream = require_thread_stream();
|
|
@@ -264260,7 +264260,7 @@ var require_transport = __commonJS((exports, module) => {
|
|
|
264260
264260
|
throw new Error("only one of target or targets can be specified");
|
|
264261
264261
|
}
|
|
264262
264262
|
if (targets) {
|
|
264263
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
264263
|
+
target = bundlerOverrides["pino-worker"] || join136(__dirname, "worker.js");
|
|
264264
264264
|
options.targets = targets.filter((dest) => dest.target).map((dest) => {
|
|
264265
264265
|
return {
|
|
264266
264266
|
...dest,
|
|
@@ -264277,7 +264277,7 @@ var require_transport = __commonJS((exports, module) => {
|
|
|
264277
264277
|
});
|
|
264278
264278
|
});
|
|
264279
264279
|
} else if (pipeline3) {
|
|
264280
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
264280
|
+
target = bundlerOverrides["pino-worker"] || join136(__dirname, "worker.js");
|
|
264281
264281
|
options.pipelines = [pipeline3.map((dest) => {
|
|
264282
264282
|
return {
|
|
264283
264283
|
...dest,
|
|
@@ -264299,7 +264299,7 @@ var require_transport = __commonJS((exports, module) => {
|
|
|
264299
264299
|
return origin;
|
|
264300
264300
|
}
|
|
264301
264301
|
if (origin === "pino/file") {
|
|
264302
|
-
return
|
|
264302
|
+
return join136(__dirname, "..", "file.js");
|
|
264303
264303
|
}
|
|
264304
264304
|
let fixTarget2;
|
|
264305
264305
|
for (const filePath of callers) {
|
|
@@ -265237,7 +265237,7 @@ var require_safe_stable_stringify = __commonJS((exports, module) => {
|
|
|
265237
265237
|
return circularValue;
|
|
265238
265238
|
}
|
|
265239
265239
|
let res = "";
|
|
265240
|
-
let
|
|
265240
|
+
let join136 = ",";
|
|
265241
265241
|
const originalIndentation = indentation;
|
|
265242
265242
|
if (Array.isArray(value)) {
|
|
265243
265243
|
if (value.length === 0) {
|
|
@@ -265251,7 +265251,7 @@ var require_safe_stable_stringify = __commonJS((exports, module) => {
|
|
|
265251
265251
|
indentation += spacer;
|
|
265252
265252
|
res += `
|
|
265253
265253
|
${indentation}`;
|
|
265254
|
-
|
|
265254
|
+
join136 = `,
|
|
265255
265255
|
${indentation}`;
|
|
265256
265256
|
}
|
|
265257
265257
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -265259,13 +265259,13 @@ ${indentation}`;
|
|
|
265259
265259
|
for (;i < maximumValuesToStringify - 1; i++) {
|
|
265260
265260
|
const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
265261
265261
|
res += tmp2 !== undefined ? tmp2 : "null";
|
|
265262
|
-
res +=
|
|
265262
|
+
res += join136;
|
|
265263
265263
|
}
|
|
265264
265264
|
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
265265
265265
|
res += tmp !== undefined ? tmp : "null";
|
|
265266
265266
|
if (value.length - 1 > maximumBreadth) {
|
|
265267
265267
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
265268
|
-
res += `${
|
|
265268
|
+
res += `${join136}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
265269
265269
|
}
|
|
265270
265270
|
if (spacer !== "") {
|
|
265271
265271
|
res += `
|
|
@@ -265286,7 +265286,7 @@ ${originalIndentation}`;
|
|
|
265286
265286
|
let separator = "";
|
|
265287
265287
|
if (spacer !== "") {
|
|
265288
265288
|
indentation += spacer;
|
|
265289
|
-
|
|
265289
|
+
join136 = `,
|
|
265290
265290
|
${indentation}`;
|
|
265291
265291
|
whitespace = " ";
|
|
265292
265292
|
}
|
|
@@ -265300,13 +265300,13 @@ ${indentation}`;
|
|
|
265300
265300
|
const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
|
|
265301
265301
|
if (tmp !== undefined) {
|
|
265302
265302
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
265303
|
-
separator =
|
|
265303
|
+
separator = join136;
|
|
265304
265304
|
}
|
|
265305
265305
|
}
|
|
265306
265306
|
if (keyLength > maximumBreadth) {
|
|
265307
265307
|
const removedKeys = keyLength - maximumBreadth;
|
|
265308
265308
|
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
265309
|
-
separator =
|
|
265309
|
+
separator = join136;
|
|
265310
265310
|
}
|
|
265311
265311
|
if (spacer !== "" && separator.length > 1) {
|
|
265312
265312
|
res = `
|
|
@@ -265346,7 +265346,7 @@ ${originalIndentation}`;
|
|
|
265346
265346
|
}
|
|
265347
265347
|
const originalIndentation = indentation;
|
|
265348
265348
|
let res = "";
|
|
265349
|
-
let
|
|
265349
|
+
let join136 = ",";
|
|
265350
265350
|
if (Array.isArray(value)) {
|
|
265351
265351
|
if (value.length === 0) {
|
|
265352
265352
|
return "[]";
|
|
@@ -265359,7 +265359,7 @@ ${originalIndentation}`;
|
|
|
265359
265359
|
indentation += spacer;
|
|
265360
265360
|
res += `
|
|
265361
265361
|
${indentation}`;
|
|
265362
|
-
|
|
265362
|
+
join136 = `,
|
|
265363
265363
|
${indentation}`;
|
|
265364
265364
|
}
|
|
265365
265365
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -265367,13 +265367,13 @@ ${indentation}`;
|
|
|
265367
265367
|
for (;i < maximumValuesToStringify - 1; i++) {
|
|
265368
265368
|
const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
265369
265369
|
res += tmp2 !== undefined ? tmp2 : "null";
|
|
265370
|
-
res +=
|
|
265370
|
+
res += join136;
|
|
265371
265371
|
}
|
|
265372
265372
|
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
265373
265373
|
res += tmp !== undefined ? tmp : "null";
|
|
265374
265374
|
if (value.length - 1 > maximumBreadth) {
|
|
265375
265375
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
265376
|
-
res += `${
|
|
265376
|
+
res += `${join136}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
265377
265377
|
}
|
|
265378
265378
|
if (spacer !== "") {
|
|
265379
265379
|
res += `
|
|
@@ -265386,7 +265386,7 @@ ${originalIndentation}`;
|
|
|
265386
265386
|
let whitespace = "";
|
|
265387
265387
|
if (spacer !== "") {
|
|
265388
265388
|
indentation += spacer;
|
|
265389
|
-
|
|
265389
|
+
join136 = `,
|
|
265390
265390
|
${indentation}`;
|
|
265391
265391
|
whitespace = " ";
|
|
265392
265392
|
}
|
|
@@ -265395,7 +265395,7 @@ ${indentation}`;
|
|
|
265395
265395
|
const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
|
|
265396
265396
|
if (tmp !== undefined) {
|
|
265397
265397
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
265398
|
-
separator =
|
|
265398
|
+
separator = join136;
|
|
265399
265399
|
}
|
|
265400
265400
|
}
|
|
265401
265401
|
if (spacer !== "" && separator.length > 1) {
|
|
@@ -265452,20 +265452,20 @@ ${originalIndentation}`;
|
|
|
265452
265452
|
indentation += spacer;
|
|
265453
265453
|
let res2 = `
|
|
265454
265454
|
${indentation}`;
|
|
265455
|
-
const
|
|
265455
|
+
const join137 = `,
|
|
265456
265456
|
${indentation}`;
|
|
265457
265457
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
265458
265458
|
let i = 0;
|
|
265459
265459
|
for (;i < maximumValuesToStringify - 1; i++) {
|
|
265460
265460
|
const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
265461
265461
|
res2 += tmp2 !== undefined ? tmp2 : "null";
|
|
265462
|
-
res2 +=
|
|
265462
|
+
res2 += join137;
|
|
265463
265463
|
}
|
|
265464
265464
|
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
265465
265465
|
res2 += tmp !== undefined ? tmp : "null";
|
|
265466
265466
|
if (value.length - 1 > maximumBreadth) {
|
|
265467
265467
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
265468
|
-
res2 += `${
|
|
265468
|
+
res2 += `${join137}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
265469
265469
|
}
|
|
265470
265470
|
res2 += `
|
|
265471
265471
|
${originalIndentation}`;
|
|
@@ -265481,16 +265481,16 @@ ${originalIndentation}`;
|
|
|
265481
265481
|
return '"[Object]"';
|
|
265482
265482
|
}
|
|
265483
265483
|
indentation += spacer;
|
|
265484
|
-
const
|
|
265484
|
+
const join136 = `,
|
|
265485
265485
|
${indentation}`;
|
|
265486
265486
|
let res = "";
|
|
265487
265487
|
let separator = "";
|
|
265488
265488
|
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
265489
265489
|
if (isTypedArrayWithEntries(value)) {
|
|
265490
|
-
res += stringifyTypedArray(value,
|
|
265490
|
+
res += stringifyTypedArray(value, join136, maximumBreadth);
|
|
265491
265491
|
keys = keys.slice(value.length);
|
|
265492
265492
|
maximumPropertiesToStringify -= value.length;
|
|
265493
|
-
separator =
|
|
265493
|
+
separator = join136;
|
|
265494
265494
|
}
|
|
265495
265495
|
if (deterministic) {
|
|
265496
265496
|
keys = sort(keys, comparator);
|
|
@@ -265501,13 +265501,13 @@ ${indentation}`;
|
|
|
265501
265501
|
const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
|
|
265502
265502
|
if (tmp !== undefined) {
|
|
265503
265503
|
res += `${separator}${strEscape(key2)}: ${tmp}`;
|
|
265504
|
-
separator =
|
|
265504
|
+
separator = join136;
|
|
265505
265505
|
}
|
|
265506
265506
|
}
|
|
265507
265507
|
if (keyLength > maximumBreadth) {
|
|
265508
265508
|
const removedKeys = keyLength - maximumBreadth;
|
|
265509
265509
|
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
265510
|
-
separator =
|
|
265510
|
+
separator = join136;
|
|
265511
265511
|
}
|
|
265512
265512
|
if (separator !== "") {
|
|
265513
265513
|
res = `
|
|
@@ -266157,7 +266157,7 @@ var init_Defaults = __esm(() => {
|
|
|
266157
266157
|
import { createHash as createHash13 } from "crypto";
|
|
266158
266158
|
import { createWriteStream as createWriteStream2, promises as fs28 } from "fs";
|
|
266159
266159
|
import { tmpdir as tmpdir9 } from "os";
|
|
266160
|
-
import { join as
|
|
266160
|
+
import { join as join136 } from "path";
|
|
266161
266161
|
async function uploadingNecessaryImagesOfProduct(product, waUploadToServer, timeoutMs = 30000) {
|
|
266162
266162
|
product = {
|
|
266163
266163
|
...product,
|
|
@@ -266335,7 +266335,7 @@ var import_boom12, parseCatalogNode = (node) => {
|
|
|
266335
266335
|
}
|
|
266336
266336
|
const { stream: stream3 } = await getStream(img);
|
|
266337
266337
|
const hasher = createHash13("sha256");
|
|
266338
|
-
const filePath =
|
|
266338
|
+
const filePath = join136(tmpdir9(), "img" + generateMessageIDV2());
|
|
266339
266339
|
const encFileWriteStream = createWriteStream2(filePath);
|
|
266340
266340
|
for await (const block2 of stream3) {
|
|
266341
266341
|
hasher.update(block2);
|
|
@@ -297194,7 +297194,7 @@ var init_types7 = __esm(() => {
|
|
|
297194
297194
|
});
|
|
297195
297195
|
|
|
297196
297196
|
// packages/omo-config-core/src/loader/paths.ts
|
|
297197
|
-
import { dirname as dirname45, isAbsolute as isAbsolute21, join as
|
|
297197
|
+
import { dirname as dirname45, isAbsolute as isAbsolute21, join as join137, relative as relative15, resolve as resolve42 } from "path";
|
|
297198
297198
|
function containsPath2(parent, child) {
|
|
297199
297199
|
const pathToChild = relative15(parent, child);
|
|
297200
297200
|
return pathToChild === "" || !pathToChild.startsWith("..") && !isAbsolute21(pathToChild);
|
|
@@ -297203,23 +297203,23 @@ function resolveHomeDir(env2 = process.env) {
|
|
|
297203
297203
|
return resolve42(env2.HOME ?? env2.USERPROFILE ?? process.cwd());
|
|
297204
297204
|
}
|
|
297205
297205
|
function resolveUserMatrixosConfigPath(env2 = process.env, platform4 = process.platform) {
|
|
297206
|
-
return
|
|
297206
|
+
return join137(resolveUserMatrixosConfigDirectory(env2, platform4), "omo.jsonc");
|
|
297207
297207
|
}
|
|
297208
297208
|
function resolveUserMatrixosConfigDirectory(env2 = process.env, platform4 = process.platform) {
|
|
297209
297209
|
if (platform4 === "win32" && env2.APPDATA !== undefined && env2.APPDATA.length > 0) {
|
|
297210
|
-
return
|
|
297210
|
+
return join137(env2.APPDATA, "omo");
|
|
297211
297211
|
}
|
|
297212
297212
|
if (env2.XDG_CONFIG_HOME !== undefined && env2.XDG_CONFIG_HOME.length > 0) {
|
|
297213
|
-
return
|
|
297213
|
+
return join137(env2.XDG_CONFIG_HOME, "omo");
|
|
297214
297214
|
}
|
|
297215
|
-
return
|
|
297215
|
+
return join137(resolveHomeDir(env2), ".config", "omo");
|
|
297216
297216
|
}
|
|
297217
297217
|
function detectUserOmoJsonPath(env2, platform4, fileSystem) {
|
|
297218
297218
|
const configDir = resolveUserMatrixosConfigDirectory(env2, platform4);
|
|
297219
|
-
const jsoncPath =
|
|
297219
|
+
const jsoncPath = join137(configDir, "omo.jsonc");
|
|
297220
297220
|
if (fileSystem.existsSync(jsoncPath))
|
|
297221
297221
|
return jsoncPath;
|
|
297222
|
-
const jsonPath =
|
|
297222
|
+
const jsonPath = join137(configDir, "omo.json");
|
|
297223
297223
|
return fileSystem.existsSync(jsonPath) ? jsonPath : jsoncPath;
|
|
297224
297224
|
}
|
|
297225
297225
|
function isSymlinkedProjectPath(path28, fileSystem) {
|
|
@@ -297237,13 +297237,13 @@ function isLoadableProjectConfigFile(path28, fileSystem) {
|
|
|
297237
297237
|
return fileSystem.existsSync(path28) && !isSymlinkedProjectPath(path28, fileSystem);
|
|
297238
297238
|
}
|
|
297239
297239
|
function detectOmoJsonPath(dir2, fileSystem) {
|
|
297240
|
-
const omoDir =
|
|
297240
|
+
const omoDir = join137(dir2, ".omo");
|
|
297241
297241
|
if (isSymlinkedProjectPath(omoDir, fileSystem))
|
|
297242
297242
|
return null;
|
|
297243
|
-
const jsoncPath =
|
|
297243
|
+
const jsoncPath = join137(omoDir, "omo.jsonc");
|
|
297244
297244
|
if (isLoadableProjectConfigFile(jsoncPath, fileSystem))
|
|
297245
297245
|
return jsoncPath;
|
|
297246
|
-
const jsonPath =
|
|
297246
|
+
const jsonPath = join137(omoDir, "omo.json");
|
|
297247
297247
|
return isLoadableProjectConfigFile(jsonPath, fileSystem) ? jsonPath : null;
|
|
297248
297248
|
}
|
|
297249
297249
|
function findProjectConfigPathsFarthestFirst(cwd, homeDir, fileSystem) {
|
|
@@ -297544,7 +297544,7 @@ var init_types8 = __esm(() => {
|
|
|
297544
297544
|
|
|
297545
297545
|
// packages/omo-config-core/src/writer/writer.ts
|
|
297546
297546
|
import { randomUUID as randomUUID13 } from "crypto";
|
|
297547
|
-
import { dirname as dirname46, join as
|
|
297547
|
+
import { dirname as dirname46, join as join138 } from "path";
|
|
297548
297548
|
function backupSuffix() {
|
|
297549
297549
|
return new Date().toISOString().replace(/[:.]/g, "-");
|
|
297550
297550
|
}
|
|
@@ -297575,13 +297575,13 @@ function resolveWritePath(options) {
|
|
|
297575
297575
|
const jsoncPath2 = resolveUserMatrixosConfigPath(options.env, options.platform ?? process.platform);
|
|
297576
297576
|
if (fileSystem.existsSync(jsoncPath2))
|
|
297577
297577
|
return jsoncPath2;
|
|
297578
|
-
const jsonPath2 =
|
|
297578
|
+
const jsonPath2 = join138(dirname46(jsoncPath2), "omo.json");
|
|
297579
297579
|
return fileSystem.existsSync(jsonPath2) ? jsonPath2 : jsoncPath2;
|
|
297580
297580
|
}
|
|
297581
|
-
const jsoncPath =
|
|
297581
|
+
const jsoncPath = join138(options.projectDir ?? process.cwd(), ".omo", "omo.jsonc");
|
|
297582
297582
|
if (fileSystem.existsSync(jsoncPath))
|
|
297583
297583
|
return jsoncPath;
|
|
297584
|
-
const jsonPath =
|
|
297584
|
+
const jsonPath = join138(dirname46(jsoncPath), "omo.json");
|
|
297585
297585
|
return fileSystem.existsSync(jsonPath) ? jsonPath : jsoncPath;
|
|
297586
297586
|
}
|
|
297587
297587
|
function writeAtomically(path28, content, fileSystem) {
|
|
@@ -297694,7 +297694,7 @@ var init_writer2 = __esm(() => {
|
|
|
297694
297694
|
|
|
297695
297695
|
// packages/omo-config-core/src/generator/mini-os-generator.ts
|
|
297696
297696
|
import { existsSync as existsSync115, mkdirSync as mkdirSync25, writeFileSync as writeFileSync26 } from "fs";
|
|
297697
|
-
import { dirname as dirname47, join as
|
|
297697
|
+
import { dirname as dirname47, join as join139 } from "path";
|
|
297698
297698
|
function generateMiniOS(options) {
|
|
297699
297699
|
const fs29 = options.fs ?? defaultFS;
|
|
297700
297700
|
const profile3 = options.profile;
|
|
@@ -297705,29 +297705,29 @@ function generateMiniOS(options) {
|
|
|
297705
297705
|
if (!fs29.existsSync(targetDir)) {
|
|
297706
297706
|
fs29.mkdirSync(targetDir, { recursive: true });
|
|
297707
297707
|
}
|
|
297708
|
-
const pkgPath =
|
|
297708
|
+
const pkgPath = join139(targetDir, "package.json");
|
|
297709
297709
|
writeIfMissing(fs29, pkgPath, TPL_PACKAGE_JSON(packageName, displayName, profile3.version, profile3.description, profile3.extends, profile3.baseAgent));
|
|
297710
297710
|
filesWritten.push(pkgPath);
|
|
297711
|
-
const srcDir =
|
|
297711
|
+
const srcDir = join139(targetDir, "src");
|
|
297712
297712
|
fs29.mkdirSync(srcDir, { recursive: true });
|
|
297713
|
-
const indexPath =
|
|
297713
|
+
const indexPath = join139(srcDir, "index.ts");
|
|
297714
297714
|
writeIfMissing(fs29, indexPath, TPL_INDEX_TS(profile3.name, displayName, profile3.description));
|
|
297715
297715
|
filesWritten.push(indexPath);
|
|
297716
|
-
const binDir =
|
|
297716
|
+
const binDir = join139(targetDir, "bin");
|
|
297717
297717
|
fs29.mkdirSync(binDir, { recursive: true });
|
|
297718
|
-
const binPath =
|
|
297718
|
+
const binPath = join139(binDir, "matrixos-mini.js");
|
|
297719
297719
|
writeIfMissing(fs29, binPath, TPL_BIN);
|
|
297720
297720
|
filesWritten.push(binPath);
|
|
297721
|
-
const scriptDir =
|
|
297721
|
+
const scriptDir = join139(targetDir, "script");
|
|
297722
297722
|
fs29.mkdirSync(scriptDir, { recursive: true });
|
|
297723
|
-
const buildPath =
|
|
297723
|
+
const buildPath = join139(scriptDir, "build.ts");
|
|
297724
297724
|
writeIfMissing(fs29, buildPath, TPL_BUILD_TS);
|
|
297725
297725
|
filesWritten.push(buildPath);
|
|
297726
297726
|
if (Object.keys(profile3.agents).length > 0) {
|
|
297727
|
-
const agentsDir =
|
|
297727
|
+
const agentsDir = join139(targetDir, "agents");
|
|
297728
297728
|
fs29.mkdirSync(agentsDir, { recursive: true });
|
|
297729
297729
|
for (const [agentName, agentDef] of Object.entries(profile3.agents)) {
|
|
297730
|
-
const agentFile =
|
|
297730
|
+
const agentFile = join139(agentsDir, `${agentName}.ts`);
|
|
297731
297731
|
const description2 = agentDef.description ?? `Custom ${displayName} agent: ${agentName}`;
|
|
297732
297732
|
writeIfMissing(fs29, agentFile, `// ${description2}
|
|
297733
297733
|
// Generated by MaTrixOS Mini-OS Profile Generator.
|
|
@@ -297738,10 +297738,10 @@ export const description = ${JSON.stringify(description2)}
|
|
|
297738
297738
|
}
|
|
297739
297739
|
}
|
|
297740
297740
|
if (profile3.skills.length > 0) {
|
|
297741
|
-
const skillsDir =
|
|
297741
|
+
const skillsDir = join139(targetDir, "skills");
|
|
297742
297742
|
fs29.mkdirSync(skillsDir, { recursive: true });
|
|
297743
297743
|
for (const skill2 of profile3.skills) {
|
|
297744
|
-
const skillFile =
|
|
297744
|
+
const skillFile = join139(skillsDir, `${skill2}.md`);
|
|
297745
297745
|
writeIfMissing(fs29, skillFile, `# ${skill2}
|
|
297746
297746
|
|
|
297747
297747
|
_Skill required by the ${displayName} profile. Implementation goes here._
|
|
@@ -297749,12 +297749,12 @@ _Skill required by the ${displayName} profile. Implementation goes here._
|
|
|
297749
297749
|
filesWritten.push(skillFile);
|
|
297750
297750
|
}
|
|
297751
297751
|
}
|
|
297752
|
-
const readmePath =
|
|
297752
|
+
const readmePath = join139(targetDir, "README.md");
|
|
297753
297753
|
const agentsList = Object.keys(profile3.agents);
|
|
297754
297754
|
const skillsList = profile3.skills;
|
|
297755
297755
|
writeIfMissing(fs29, readmePath, TPL_README(packageName, displayName, profile3.description, profile3.version, profile3.baseAgent, profile3.extends, agentsList, skillsList));
|
|
297756
297756
|
filesWritten.push(readmePath);
|
|
297757
|
-
const agentsMdPath =
|
|
297757
|
+
const agentsMdPath = join139(targetDir, "AGENTS.md");
|
|
297758
297758
|
writeIfMissing(fs29, agentsMdPath, TPL_AGENT_MD(displayName, profile3.description));
|
|
297759
297759
|
filesWritten.push(agentsMdPath);
|
|
297760
297760
|
return { packageName, packageDir: targetDir, filesWritten };
|
|
@@ -367932,7 +367932,7 @@ function getCachedVersion(options = {}) {
|
|
|
367932
367932
|
// package.json
|
|
367933
367933
|
var package_default = {
|
|
367934
367934
|
name: "@kl-c/matrixos",
|
|
367935
|
-
version: "0.1.
|
|
367935
|
+
version: "0.1.6",
|
|
367936
367936
|
description: "MaTrixOS \u2014 Agentic OS for OpenCode. Personalizable, communicating, self-improving, resilient.",
|
|
367937
367937
|
main: "./dist/index.js",
|
|
367938
367938
|
types: "dist/index.d.ts",
|
|
@@ -405449,8 +405449,673 @@ function createHooks(args) {
|
|
|
405449
405449
|
}
|
|
405450
405450
|
};
|
|
405451
405451
|
}
|
|
405452
|
+
|
|
405453
|
+
// packages/learning-loop/src/schema.ts
|
|
405454
|
+
import * as z7 from "zod";
|
|
405455
|
+
var LearningSchema = z7.object({
|
|
405456
|
+
id: z7.string().min(1),
|
|
405457
|
+
target: z7.string().min(1),
|
|
405458
|
+
rule: z7.string().min(1),
|
|
405459
|
+
rationale: z7.string().min(1),
|
|
405460
|
+
occurrences: z7.number().int().nonnegative(),
|
|
405461
|
+
confidence: z7.number().min(0).max(1),
|
|
405462
|
+
created_at: z7.string()
|
|
405463
|
+
}).strict();
|
|
405464
|
+
|
|
405465
|
+
// packages/learning-loop/src/store.ts
|
|
405466
|
+
import * as nodeFs from "fs";
|
|
405467
|
+
var NodeFs = {
|
|
405468
|
+
appendFileSync: nodeFs.appendFileSync,
|
|
405469
|
+
readFileSync: (p) => nodeFs.readFileSync(p, "utf8"),
|
|
405470
|
+
writeFileSync: nodeFs.writeFileSync,
|
|
405471
|
+
existsSync: nodeFs.existsSync,
|
|
405472
|
+
mkdirSync: (p, o) => nodeFs.mkdirSync(p, o)
|
|
405473
|
+
};
|
|
405474
|
+
function readLearnings(path22, fs23 = NodeFs) {
|
|
405475
|
+
if (!fs23.existsSync(path22))
|
|
405476
|
+
return [];
|
|
405477
|
+
const raw = fs23.readFileSync(path22);
|
|
405478
|
+
const lines = raw.split(`
|
|
405479
|
+
`).filter((l) => l.trim().length > 0);
|
|
405480
|
+
const out = [];
|
|
405481
|
+
for (const line of lines) {
|
|
405482
|
+
const parsed = LearningSchema.safeParse(JSON.parse(line));
|
|
405483
|
+
if (parsed.success)
|
|
405484
|
+
out.push(parsed.data);
|
|
405485
|
+
}
|
|
405486
|
+
return out;
|
|
405487
|
+
}
|
|
405488
|
+
function appendLearning(path22, learning, fs23 = NodeFs) {
|
|
405489
|
+
LearningSchema.parse(learning);
|
|
405490
|
+
fs23.appendFileSync(path22, JSON.stringify(learning) + `
|
|
405491
|
+
`);
|
|
405492
|
+
}
|
|
405493
|
+
|
|
405494
|
+
// packages/learning-loop/src/scanner.ts
|
|
405495
|
+
var DEFAULT_KEY = (ev) => `${ev.type}:${ev.reason ?? ""}`;
|
|
405496
|
+
var DEFAULT_LEARNING = (key, events) => {
|
|
405497
|
+
const first = events[0];
|
|
405498
|
+
const [type2, reason] = key.split(":", 2);
|
|
405499
|
+
return {
|
|
405500
|
+
id: `scan-${type2}-${reason}-${first.timestamp ?? Date.now()}`.replace(/[^a-zA-Z0-9_-]/g, "_"),
|
|
405501
|
+
target: type2 ?? "unknown",
|
|
405502
|
+
rule: `Recurring audit event: ${key} (see ${events.length} occurrences).`,
|
|
405503
|
+
rationale: `Auto-detected by Scanner on ${first.timestamp ?? "n/a"}.`,
|
|
405504
|
+
confidence: 0.85,
|
|
405505
|
+
created_at: new Date().toISOString()
|
|
405506
|
+
};
|
|
405507
|
+
};
|
|
405508
|
+
function scanAuditLog(options) {
|
|
405509
|
+
const fs23 = options.fs;
|
|
405510
|
+
if (!fs23 || !fs23.existsSync(options.auditLogPath)) {
|
|
405511
|
+
return { proposed: [], auditEventsScanned: 0 };
|
|
405512
|
+
}
|
|
405513
|
+
const raw = fs23.readFileSync(options.auditLogPath);
|
|
405514
|
+
const events = [];
|
|
405515
|
+
for (const line of raw.split(`
|
|
405516
|
+
`)) {
|
|
405517
|
+
if (!line.trim())
|
|
405518
|
+
continue;
|
|
405519
|
+
try {
|
|
405520
|
+
const parsed = JSON.parse(line);
|
|
405521
|
+
events.push(parsed);
|
|
405522
|
+
} catch {}
|
|
405523
|
+
}
|
|
405524
|
+
const keyFor = options.keyFor ?? DEFAULT_KEY;
|
|
405525
|
+
const learningFor = options.learningFor ?? DEFAULT_LEARNING;
|
|
405526
|
+
const threshold = options.threshold ?? 3;
|
|
405527
|
+
const groups = new Map;
|
|
405528
|
+
for (const ev of events) {
|
|
405529
|
+
const k = keyFor(ev);
|
|
405530
|
+
if (!k)
|
|
405531
|
+
continue;
|
|
405532
|
+
const arr = groups.get(k) ?? [];
|
|
405533
|
+
arr.push(ev);
|
|
405534
|
+
groups.set(k, arr);
|
|
405535
|
+
}
|
|
405536
|
+
const proposed = [];
|
|
405537
|
+
for (const [key, group] of groups) {
|
|
405538
|
+
if (group.length < threshold)
|
|
405539
|
+
continue;
|
|
405540
|
+
const template = learningFor(key, group);
|
|
405541
|
+
const learning = {
|
|
405542
|
+
...template,
|
|
405543
|
+
occurrences: group.length
|
|
405544
|
+
};
|
|
405545
|
+
const safe = LearningSchema.safeParse(learning);
|
|
405546
|
+
if (safe.success)
|
|
405547
|
+
proposed.push(safe.data);
|
|
405548
|
+
}
|
|
405549
|
+
return { proposed, auditEventsScanned: events.length };
|
|
405550
|
+
}
|
|
405551
|
+
|
|
405552
|
+
// packages/learning-loop/src/memory.ts
|
|
405553
|
+
function createMemoryStore() {
|
|
405554
|
+
const episodes = [];
|
|
405555
|
+
let counter = 0;
|
|
405556
|
+
const recordEpisode = (input) => {
|
|
405557
|
+
counter += 1;
|
|
405558
|
+
const ep = {
|
|
405559
|
+
id: input.id ?? `ep-${Date.now()}-${counter}`,
|
|
405560
|
+
sessionId: input.sessionId,
|
|
405561
|
+
type: input.type,
|
|
405562
|
+
summary: input.summary,
|
|
405563
|
+
timestamp: input.timestamp ?? new Date().toISOString(),
|
|
405564
|
+
metadata: input.metadata
|
|
405565
|
+
};
|
|
405566
|
+
episodes.push(ep);
|
|
405567
|
+
return ep;
|
|
405568
|
+
};
|
|
405569
|
+
const searchEpisodes = (query) => {
|
|
405570
|
+
const limit = query.limit ?? 50;
|
|
405571
|
+
const needle = query.textContains?.toLowerCase();
|
|
405572
|
+
const out = [];
|
|
405573
|
+
for (const ep of episodes) {
|
|
405574
|
+
if (query.sessionId && ep.sessionId !== query.sessionId)
|
|
405575
|
+
continue;
|
|
405576
|
+
if (query.type && ep.type !== query.type)
|
|
405577
|
+
continue;
|
|
405578
|
+
if (needle && !ep.summary.toLowerCase().includes(needle))
|
|
405579
|
+
continue;
|
|
405580
|
+
out.push(ep);
|
|
405581
|
+
if (out.length >= limit)
|
|
405582
|
+
break;
|
|
405583
|
+
}
|
|
405584
|
+
return out;
|
|
405585
|
+
};
|
|
405586
|
+
return {
|
|
405587
|
+
recordEpisode,
|
|
405588
|
+
searchEpisodes,
|
|
405589
|
+
size: () => episodes.length,
|
|
405590
|
+
clear: () => {
|
|
405591
|
+
episodes.length = 0;
|
|
405592
|
+
counter = 0;
|
|
405593
|
+
}
|
|
405594
|
+
};
|
|
405595
|
+
}
|
|
405596
|
+
|
|
405597
|
+
// packages/learning-loop/src/memory-sqlite.ts
|
|
405598
|
+
import { Database } from "bun:sqlite";
|
|
405599
|
+
import * as nodeFs2 from "fs";
|
|
405600
|
+
import * as nodePath from "path";
|
|
405601
|
+
import * as nodeOs from "os";
|
|
405602
|
+
import { randomUUID as randomUUID9 } from "crypto";
|
|
405603
|
+
var CREATE_EPISODES_TABLE = `
|
|
405604
|
+
CREATE TABLE IF NOT EXISTS episodes (
|
|
405605
|
+
id TEXT PRIMARY KEY,
|
|
405606
|
+
session_id TEXT NOT NULL,
|
|
405607
|
+
type TEXT NOT NULL,
|
|
405608
|
+
summary TEXT NOT NULL,
|
|
405609
|
+
timestamp TEXT NOT NULL,
|
|
405610
|
+
metadata TEXT
|
|
405611
|
+
)
|
|
405612
|
+
`;
|
|
405613
|
+
var CREATE_INDEX_SESSION_ID = `CREATE INDEX IF NOT EXISTS idx_session_id ON episodes(session_id)`;
|
|
405614
|
+
var CREATE_INDEX_TYPE = `CREATE INDEX IF NOT EXISTS idx_type ON episodes(type)`;
|
|
405615
|
+
var CREATE_FTS5_TABLE = `
|
|
405616
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS episodes_fts USING fts5(
|
|
405617
|
+
summary,
|
|
405618
|
+
content=episodes,
|
|
405619
|
+
content_rowid=rowid
|
|
405620
|
+
)
|
|
405621
|
+
`;
|
|
405622
|
+
var CREATE_FTS_TRIGGER_INSERT = `
|
|
405623
|
+
CREATE TRIGGER IF NOT EXISTS episodes_ai AFTER INSERT ON episodes
|
|
405624
|
+
BEGIN
|
|
405625
|
+
INSERT INTO episodes_fts(rowid, summary) VALUES (new.rowid, new.summary);
|
|
405626
|
+
END
|
|
405627
|
+
`;
|
|
405628
|
+
var CREATE_FTS_TRIGGER_DELETE = `
|
|
405629
|
+
CREATE TRIGGER IF NOT EXISTS episodes_ad AFTER DELETE ON episodes
|
|
405630
|
+
BEGIN
|
|
405631
|
+
INSERT INTO episodes_fts(episodes_fts, rowid, summary) VALUES('delete', old.rowid, old.summary);
|
|
405632
|
+
END
|
|
405633
|
+
`;
|
|
405634
|
+
var CREATE_FTS_TRIGGER_UPDATE = `
|
|
405635
|
+
CREATE TRIGGER IF NOT EXISTS episodes_au AFTER UPDATE OF summary ON episodes
|
|
405636
|
+
BEGIN
|
|
405637
|
+
INSERT INTO episodes_fts(episodes_fts, rowid, summary) VALUES('delete', old.rowid, old.summary);
|
|
405638
|
+
INSERT INTO episodes_fts(rowid, summary) VALUES(new.rowid, new.summary);
|
|
405639
|
+
END
|
|
405640
|
+
`;
|
|
405641
|
+
var CREATE_VEC0_TABLE = `
|
|
405642
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS episode_vec USING vec0(embedding float[384])
|
|
405643
|
+
`;
|
|
405644
|
+
var CREATE_VEC_META_TABLE = `
|
|
405645
|
+
CREATE TABLE IF NOT EXISTS episode_vec_meta(
|
|
405646
|
+
episode_id TEXT PRIMARY KEY REFERENCES episodes(id),
|
|
405647
|
+
vec_rowid INTEGER NOT NULL
|
|
405648
|
+
)
|
|
405649
|
+
`;
|
|
405650
|
+
var CREATE_VEC_META_INDEX = `CREATE INDEX IF NOT EXISTS idx_vec_meta_rowid ON episode_vec_meta(vec_rowid)`;
|
|
405651
|
+
function initSchema(db, fts5Available) {
|
|
405652
|
+
db.exec(CREATE_EPISODES_TABLE);
|
|
405653
|
+
db.exec(CREATE_INDEX_SESSION_ID);
|
|
405654
|
+
db.exec(CREATE_INDEX_TYPE);
|
|
405655
|
+
if (fts5Available) {
|
|
405656
|
+
db.exec(CREATE_FTS5_TABLE);
|
|
405657
|
+
db.exec(CREATE_FTS_TRIGGER_INSERT);
|
|
405658
|
+
db.exec(CREATE_FTS_TRIGGER_DELETE);
|
|
405659
|
+
db.exec(CREATE_FTS_TRIGGER_UPDATE);
|
|
405660
|
+
}
|
|
405661
|
+
}
|
|
405662
|
+
function applySchema(execFn, fts5Available) {
|
|
405663
|
+
execFn(CREATE_EPISODES_TABLE);
|
|
405664
|
+
execFn(CREATE_INDEX_SESSION_ID);
|
|
405665
|
+
execFn(CREATE_INDEX_TYPE);
|
|
405666
|
+
if (fts5Available) {
|
|
405667
|
+
execFn(CREATE_FTS5_TABLE);
|
|
405668
|
+
execFn(CREATE_FTS_TRIGGER_INSERT);
|
|
405669
|
+
execFn(CREATE_FTS_TRIGGER_DELETE);
|
|
405670
|
+
execFn(CREATE_FTS_TRIGGER_UPDATE);
|
|
405671
|
+
}
|
|
405672
|
+
}
|
|
405673
|
+
function detectFts5(db) {
|
|
405674
|
+
try {
|
|
405675
|
+
db.exec(CREATE_FTS5_TABLE);
|
|
405676
|
+
const rows = db.prepare("SELECT name FROM sqlite_master WHERE name = 'episodes_fts'").all();
|
|
405677
|
+
return rows.length > 0;
|
|
405678
|
+
} catch {
|
|
405679
|
+
return false;
|
|
405680
|
+
}
|
|
405681
|
+
}
|
|
405682
|
+
function rowToEpisode(row) {
|
|
405683
|
+
return {
|
|
405684
|
+
id: row.id,
|
|
405685
|
+
sessionId: row.session_id,
|
|
405686
|
+
type: row.type,
|
|
405687
|
+
summary: row.summary,
|
|
405688
|
+
timestamp: row.timestamp,
|
|
405689
|
+
metadata: row.metadata ? JSON.parse(row.metadata) : undefined
|
|
405690
|
+
};
|
|
405691
|
+
}
|
|
405692
|
+
function escapeFts5Quotes(text) {
|
|
405693
|
+
return text.replace(/"/g, '""');
|
|
405694
|
+
}
|
|
405695
|
+
var DEFAULT_DB_PATH = nodePath.join(nodeOs.homedir(), ".matrixos", "memory", "episodic.db");
|
|
405696
|
+
function ensureDbPath(dbPath) {
|
|
405697
|
+
const dir = nodePath.dirname(dbPath);
|
|
405698
|
+
if (!nodeFs2.existsSync(dir)) {
|
|
405699
|
+
nodeFs2.mkdirSync(dir, { recursive: true });
|
|
405700
|
+
}
|
|
405701
|
+
}
|
|
405702
|
+
function setPermissions(dbPath) {
|
|
405703
|
+
try {
|
|
405704
|
+
nodeFs2.chmodSync(dbPath, 384);
|
|
405705
|
+
} catch {}
|
|
405706
|
+
}
|
|
405707
|
+
function tryEnableVectorIndex(db) {
|
|
405708
|
+
try {
|
|
405709
|
+
const { getLoadablePath } = require_sqlite_vec();
|
|
405710
|
+
db.loadExtension(getLoadablePath());
|
|
405711
|
+
db.exec(CREATE_VEC0_TABLE);
|
|
405712
|
+
db.exec(CREATE_VEC_META_TABLE);
|
|
405713
|
+
db.exec(CREATE_VEC_META_INDEX);
|
|
405714
|
+
return true;
|
|
405715
|
+
} catch {
|
|
405716
|
+
return false;
|
|
405717
|
+
}
|
|
405718
|
+
}
|
|
405719
|
+
function createSqliteMemoryStore(options) {
|
|
405720
|
+
let db;
|
|
405721
|
+
let port;
|
|
405722
|
+
let fts5Available = false;
|
|
405723
|
+
let vecAvailable = false;
|
|
405724
|
+
let dbPath;
|
|
405725
|
+
if (options?.dbPort) {
|
|
405726
|
+
port = options.dbPort;
|
|
405727
|
+
fts5Available = false;
|
|
405728
|
+
applySchema((sql) => port.exec(sql), fts5Available);
|
|
405729
|
+
} else if (options?.db) {
|
|
405730
|
+
db = options.db;
|
|
405731
|
+
fts5Available = detectFts5(db);
|
|
405732
|
+
initSchema(db, fts5Available);
|
|
405733
|
+
vecAvailable = tryEnableVectorIndex(db);
|
|
405734
|
+
} else {
|
|
405735
|
+
dbPath = options?.path ?? DEFAULT_DB_PATH;
|
|
405736
|
+
ensureDbPath(dbPath);
|
|
405737
|
+
db = new Database(dbPath);
|
|
405738
|
+
setPermissions(dbPath);
|
|
405739
|
+
db.exec("PRAGMA journal_mode = WAL");
|
|
405740
|
+
db.exec("PRAGMA foreign_keys = ON");
|
|
405741
|
+
fts5Available = detectFts5(db);
|
|
405742
|
+
initSchema(db, fts5Available);
|
|
405743
|
+
vecAvailable = tryEnableVectorIndex(db);
|
|
405744
|
+
}
|
|
405745
|
+
function exec2(sql, ...params) {
|
|
405746
|
+
if (port) {
|
|
405747
|
+
port.exec(sql, ...params);
|
|
405748
|
+
return;
|
|
405749
|
+
}
|
|
405750
|
+
if (params.length === 0) {
|
|
405751
|
+
db.run(sql);
|
|
405752
|
+
} else {
|
|
405753
|
+
const named = params[0];
|
|
405754
|
+
db.run(sql, named);
|
|
405755
|
+
}
|
|
405756
|
+
}
|
|
405757
|
+
function queryFn(sql, ...params) {
|
|
405758
|
+
if (port) {
|
|
405759
|
+
return port.query(sql, ...params);
|
|
405760
|
+
}
|
|
405761
|
+
if (params.length === 0) {
|
|
405762
|
+
return db.prepare(sql).all();
|
|
405763
|
+
}
|
|
405764
|
+
const named = params[0];
|
|
405765
|
+
return db.prepare(sql).all(named);
|
|
405766
|
+
}
|
|
405767
|
+
const recordEpisode = (input) => {
|
|
405768
|
+
const ep = {
|
|
405769
|
+
id: input.id ?? randomUUID9(),
|
|
405770
|
+
sessionId: input.sessionId,
|
|
405771
|
+
type: input.type,
|
|
405772
|
+
summary: input.summary,
|
|
405773
|
+
timestamp: input.timestamp ?? new Date().toISOString(),
|
|
405774
|
+
metadata: input.metadata
|
|
405775
|
+
};
|
|
405776
|
+
exec2(`
|
|
405777
|
+
INSERT OR REPLACE INTO episodes (id, session_id, type, summary, timestamp, metadata)
|
|
405778
|
+
VALUES ($id, $session_id, $type, $summary, $timestamp, $metadata)
|
|
405779
|
+
`, {
|
|
405780
|
+
$id: ep.id,
|
|
405781
|
+
$session_id: ep.sessionId,
|
|
405782
|
+
$type: ep.type,
|
|
405783
|
+
$summary: ep.summary,
|
|
405784
|
+
$timestamp: ep.timestamp,
|
|
405785
|
+
$metadata: ep.metadata ? JSON.stringify(ep.metadata) : null
|
|
405786
|
+
});
|
|
405787
|
+
if (vecAvailable && options?.embeddingPort) {
|
|
405788
|
+
const portRef = options.embeddingPort;
|
|
405789
|
+
queueMicrotask(async () => {
|
|
405790
|
+
try {
|
|
405791
|
+
const [vector] = await portRef.embed([ep.summary]);
|
|
405792
|
+
const vecJson = JSON.stringify(vector);
|
|
405793
|
+
exec2("INSERT INTO episode_vec(embedding) VALUES ($embedding)", { $embedding: vecJson });
|
|
405794
|
+
const [ridRow] = queryFn("SELECT last_insert_rowid() AS rowid");
|
|
405795
|
+
const vecRowid = ridRow?.rowid ?? 0;
|
|
405796
|
+
exec2("INSERT OR REPLACE INTO episode_vec_meta(episode_id, vec_rowid) VALUES ($episodeId, $vecRowid)", { $episodeId: ep.id, $vecRowid: vecRowid });
|
|
405797
|
+
} catch (e) {
|
|
405798
|
+
console.warn("[memory] background embedding failed for", ep.id, e);
|
|
405799
|
+
}
|
|
405800
|
+
});
|
|
405801
|
+
}
|
|
405802
|
+
return ep;
|
|
405803
|
+
};
|
|
405804
|
+
const searchEpisodes = (queryArg) => {
|
|
405805
|
+
const limit = Math.min(queryArg.limit ?? 50, 200);
|
|
405806
|
+
const conditions = [];
|
|
405807
|
+
const params = {};
|
|
405808
|
+
if (queryArg.sessionId) {
|
|
405809
|
+
conditions.push("session_id = $session_id");
|
|
405810
|
+
params.$session_id = queryArg.sessionId;
|
|
405811
|
+
}
|
|
405812
|
+
if (queryArg.type) {
|
|
405813
|
+
conditions.push("type = $type");
|
|
405814
|
+
params.$type = queryArg.type;
|
|
405815
|
+
}
|
|
405816
|
+
let sql;
|
|
405817
|
+
const whereBase = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
405818
|
+
const searchText = queryArg.textContains ?? queryArg.semanticQuery;
|
|
405819
|
+
if (searchText) {
|
|
405820
|
+
if (fts5Available) {
|
|
405821
|
+
const escaped = escapeFts5Quotes(searchText);
|
|
405822
|
+
sql = `
|
|
405823
|
+
SELECT e.id, e.session_id, e.type, e.summary, e.timestamp, e.metadata
|
|
405824
|
+
FROM episodes e
|
|
405825
|
+
JOIN episodes_fts f ON e.rowid = f.rowid
|
|
405826
|
+
${whereBase ? `${whereBase} AND` : "WHERE"} f.summary MATCH $match
|
|
405827
|
+
ORDER BY rank
|
|
405828
|
+
LIMIT $limit
|
|
405829
|
+
`;
|
|
405830
|
+
params.$match = `"${escaped}"`;
|
|
405831
|
+
} else {
|
|
405832
|
+
sql = `
|
|
405833
|
+
SELECT id, session_id, type, summary, timestamp, metadata
|
|
405834
|
+
FROM episodes
|
|
405835
|
+
${whereBase ? `${whereBase} AND` : "WHERE"} summary LIKE $like
|
|
405836
|
+
LIMIT $limit
|
|
405837
|
+
`;
|
|
405838
|
+
params.$like = `%${searchText}%`;
|
|
405839
|
+
}
|
|
405840
|
+
} else {
|
|
405841
|
+
sql = `
|
|
405842
|
+
SELECT id, session_id, type, summary, timestamp, metadata
|
|
405843
|
+
FROM episodes
|
|
405844
|
+
${whereBase}
|
|
405845
|
+
LIMIT $limit
|
|
405846
|
+
`;
|
|
405847
|
+
}
|
|
405848
|
+
params.$limit = limit;
|
|
405849
|
+
const rows = queryFn(sql, params);
|
|
405850
|
+
return rows.map(rowToEpisode);
|
|
405851
|
+
};
|
|
405852
|
+
const size = () => {
|
|
405853
|
+
const rows = queryFn("SELECT COUNT(*) AS count FROM episodes");
|
|
405854
|
+
return rows[0]?.count ?? 0;
|
|
405855
|
+
};
|
|
405856
|
+
const clear = () => {
|
|
405857
|
+
if (vecAvailable) {
|
|
405858
|
+
exec2("DELETE FROM episode_vec_meta");
|
|
405859
|
+
}
|
|
405860
|
+
exec2("DELETE FROM episodes");
|
|
405861
|
+
if (vecAvailable) {
|
|
405862
|
+
exec2("DELETE FROM episode_vec");
|
|
405863
|
+
}
|
|
405864
|
+
};
|
|
405865
|
+
return {
|
|
405866
|
+
recordEpisode,
|
|
405867
|
+
searchEpisodes,
|
|
405868
|
+
size,
|
|
405869
|
+
clear
|
|
405870
|
+
};
|
|
405871
|
+
}
|
|
405872
|
+
|
|
405873
|
+
// packages/learning-loop/src/contradictions.ts
|
|
405874
|
+
import * as z8 from "zod";
|
|
405875
|
+
var ContradictionResultSchema = z8.object({
|
|
405876
|
+
hasContradiction: z8.boolean(),
|
|
405877
|
+
conflicting: z8.array(LearningSchema),
|
|
405878
|
+
merged: LearningSchema.optional(),
|
|
405879
|
+
action: z8.enum(["merge", "flag", "none"])
|
|
405880
|
+
}).strict();
|
|
405881
|
+
function levenshtein(a, b) {
|
|
405882
|
+
const m = a.length;
|
|
405883
|
+
const n = b.length;
|
|
405884
|
+
if (m === 0)
|
|
405885
|
+
return n;
|
|
405886
|
+
if (n === 0)
|
|
405887
|
+
return m;
|
|
405888
|
+
const prev = new Uint32Array(n + 1);
|
|
405889
|
+
const curr = new Uint32Array(n + 1);
|
|
405890
|
+
for (let j = 0;j <= n; j++)
|
|
405891
|
+
prev[j] = j;
|
|
405892
|
+
for (let i = 1;i <= m; i++) {
|
|
405893
|
+
curr[0] = i;
|
|
405894
|
+
const ai = a.charCodeAt(i - 1);
|
|
405895
|
+
for (let j = 1;j <= n; j++) {
|
|
405896
|
+
const cost = ai === b.charCodeAt(j - 1) ? 0 : 1;
|
|
405897
|
+
curr[j] = Math.min(prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + cost);
|
|
405898
|
+
}
|
|
405899
|
+
prev.set(curr);
|
|
405900
|
+
}
|
|
405901
|
+
return prev[n];
|
|
405902
|
+
}
|
|
405903
|
+
function levRatio(a, b) {
|
|
405904
|
+
const maxLen = Math.max(a.length, b.length);
|
|
405905
|
+
if (maxLen === 0)
|
|
405906
|
+
return 1;
|
|
405907
|
+
const dist = levenshtein(a, b);
|
|
405908
|
+
return 1 - dist / maxLen;
|
|
405909
|
+
}
|
|
405910
|
+
function detectContradictions(proposed, existing, options = {}) {
|
|
405911
|
+
const threshold = options.conflictThreshold ?? 0.7;
|
|
405912
|
+
const conflicts = existing.filter((e) => {
|
|
405913
|
+
if (e.target !== proposed.target)
|
|
405914
|
+
return false;
|
|
405915
|
+
return levRatio(proposed.rule, e.rule) < threshold;
|
|
405916
|
+
});
|
|
405917
|
+
if (conflicts.length === 0) {
|
|
405918
|
+
return {
|
|
405919
|
+
hasContradiction: false,
|
|
405920
|
+
conflicting: [],
|
|
405921
|
+
action: "none"
|
|
405922
|
+
};
|
|
405923
|
+
}
|
|
405924
|
+
const maxExistingConfidence = Math.max(...conflicts.map((c) => c.confidence));
|
|
405925
|
+
if (proposed.confidence > maxExistingConfidence) {
|
|
405926
|
+
const confidences = [proposed.confidence, ...conflicts.map((c) => c.confidence)];
|
|
405927
|
+
const avgConfidence = confidences.reduce((sum, c) => sum + c, 0) / confidences.length;
|
|
405928
|
+
const totalOccurrences = proposed.occurrences + conflicts.reduce((sum, c) => sum + c.occurrences, 0);
|
|
405929
|
+
const dates = [new Date(proposed.created_at), ...conflicts.map((c) => new Date(c.created_at))];
|
|
405930
|
+
const earliest = new Date(Math.min(...dates.map((d) => d.getTime())));
|
|
405931
|
+
const merged = {
|
|
405932
|
+
id: proposed.id,
|
|
405933
|
+
target: proposed.target,
|
|
405934
|
+
rule: proposed.rule,
|
|
405935
|
+
rationale: proposed.rationale,
|
|
405936
|
+
occurrences: totalOccurrences,
|
|
405937
|
+
confidence: Math.min(1, Math.max(0, avgConfidence)),
|
|
405938
|
+
created_at: earliest.toISOString()
|
|
405939
|
+
};
|
|
405940
|
+
return {
|
|
405941
|
+
hasContradiction: true,
|
|
405942
|
+
conflicting: conflicts,
|
|
405943
|
+
merged,
|
|
405944
|
+
action: "merge"
|
|
405945
|
+
};
|
|
405946
|
+
}
|
|
405947
|
+
return {
|
|
405948
|
+
hasContradiction: true,
|
|
405949
|
+
conflicting: conflicts,
|
|
405950
|
+
action: "flag"
|
|
405951
|
+
};
|
|
405952
|
+
}
|
|
405953
|
+
|
|
405954
|
+
// packages/learning-loop/src/background-scanner.ts
|
|
405955
|
+
function collectAuditLogSignals(options) {
|
|
405956
|
+
const { proposed, auditEventsScanned } = scanAuditLog({
|
|
405957
|
+
auditLogPath: options.auditLogPath,
|
|
405958
|
+
threshold: options.threshold ?? 3,
|
|
405959
|
+
fs: options.fs
|
|
405960
|
+
});
|
|
405961
|
+
return {
|
|
405962
|
+
proposals: proposed,
|
|
405963
|
+
sourcesScanned: auditEventsScanned > 0 ? [`gateway-audit-log (${auditEventsScanned} events)`] : []
|
|
405964
|
+
};
|
|
405965
|
+
}
|
|
405966
|
+
async function collectMemorySignals(options) {
|
|
405967
|
+
const proposals = [];
|
|
405968
|
+
const sourcesScanned = ["episodic-memory"];
|
|
405969
|
+
const threshold = options.threshold ?? 2;
|
|
405970
|
+
try {
|
|
405971
|
+
const errorEpisodes = options.memoryStore.searchEpisodes({
|
|
405972
|
+
type: "error"
|
|
405973
|
+
});
|
|
405974
|
+
const patternGroups = new Map;
|
|
405975
|
+
for (const ep of errorEpisodes) {
|
|
405976
|
+
const pattern = ep.summary.slice(0, 80).toLowerCase();
|
|
405977
|
+
const group = patternGroups.get(pattern) ?? [];
|
|
405978
|
+
group.push(ep);
|
|
405979
|
+
patternGroups.set(pattern, group);
|
|
405980
|
+
}
|
|
405981
|
+
for (const [pattern, episodes] of patternGroups) {
|
|
405982
|
+
if (episodes.length < threshold)
|
|
405983
|
+
continue;
|
|
405984
|
+
proposals.push({
|
|
405985
|
+
id: `memory-${Buffer.from(pattern).toString("base64url").slice(0, 32)}`,
|
|
405986
|
+
target: "recurring-error",
|
|
405987
|
+
rule: `Recurring error pattern detected (${episodes.length}x): ${pattern}`,
|
|
405988
|
+
rationale: `Auto-detected by MemoryScanner on ${new Date().toISOString()}. Episodes span ${episodes[0]?.timestamp ?? "unknown"} to ${episodes[episodes.length - 1]?.timestamp ?? "unknown"}.`,
|
|
405989
|
+
occurrences: episodes.length,
|
|
405990
|
+
confidence: Math.min(0.6 + episodes.length * 0.05, 0.95),
|
|
405991
|
+
created_at: new Date().toISOString()
|
|
405992
|
+
});
|
|
405993
|
+
}
|
|
405994
|
+
} catch {}
|
|
405995
|
+
return { proposals, sourcesScanned };
|
|
405996
|
+
}
|
|
405997
|
+
async function collectSessionSignals(options) {
|
|
405998
|
+
const proposals = [];
|
|
405999
|
+
const sourcesScanned = [];
|
|
406000
|
+
const threshold = options.threshold ?? 3;
|
|
406001
|
+
try {
|
|
406002
|
+
const loopEpisodes = options.memoryStore.searchEpisodes({ type: "loop" });
|
|
406003
|
+
if (loopEpisodes.length >= threshold) {
|
|
406004
|
+
proposals.push({
|
|
406005
|
+
id: `session-loops-${Date.now()}`,
|
|
406006
|
+
target: "session-loop",
|
|
406007
|
+
rule: `Session anti-loop triggered ${loopEpisodes.length >= threshold ? `${loopEpisodes.length}x` : ""} \u2014 consider adjusting loop detection sensitivity.`,
|
|
406008
|
+
rationale: `Auto-detected by SessionScanner on ${new Date().toISOString()}. ${loopEpisodes.length} loop events recorded.`,
|
|
406009
|
+
occurrences: loopEpisodes.length,
|
|
406010
|
+
confidence: Math.min(0.5 + loopEpisodes.length * 0.08, 0.9),
|
|
406011
|
+
created_at: new Date().toISOString()
|
|
406012
|
+
});
|
|
406013
|
+
sourcesScanned.push(`loop-episodes (${loopEpisodes.length})`);
|
|
406014
|
+
}
|
|
406015
|
+
const toolEpisodes = options.memoryStore.searchEpisodes({ type: "tool_call" });
|
|
406016
|
+
if (toolEpisodes.length > 0) {
|
|
406017
|
+
const toolGroups = new Map;
|
|
406018
|
+
for (const ep of toolEpisodes) {
|
|
406019
|
+
const toolName = ep.metadata?.toolName ?? ep.summary.slice(0, 60);
|
|
406020
|
+
const group = toolGroups.get(toolName) ?? [];
|
|
406021
|
+
group.push(ep);
|
|
406022
|
+
toolGroups.set(toolName, group);
|
|
406023
|
+
}
|
|
406024
|
+
for (const [, episodes] of toolGroups) {
|
|
406025
|
+
if (episodes.length < threshold)
|
|
406026
|
+
continue;
|
|
406027
|
+
proposals.push({
|
|
406028
|
+
id: `tool-${Buffer.from(episodes[0].summary).toString("base64url").slice(0, 24)}`,
|
|
406029
|
+
target: "repeated-tool",
|
|
406030
|
+
rule: `Tool called repeatedly (${episodes.length}x): ${episodes[0].summary.slice(0, 120)}. Consider creating a dedicated skill.`,
|
|
406031
|
+
rationale: `Auto-detected by SessionScanner on ${new Date().toISOString()}.`,
|
|
406032
|
+
occurrences: episodes.length,
|
|
406033
|
+
confidence: Math.min(0.5 + episodes.length * 0.08, 0.9),
|
|
406034
|
+
created_at: new Date().toISOString()
|
|
406035
|
+
});
|
|
406036
|
+
}
|
|
406037
|
+
sourcesScanned.push(`tool-calls (${toolEpisodes.length} total, ${toolGroups.size} groups)`);
|
|
406038
|
+
}
|
|
406039
|
+
} catch {}
|
|
406040
|
+
return { proposals, sourcesScanned };
|
|
406041
|
+
}
|
|
406042
|
+
function collectSkillsSignals(options) {
|
|
406043
|
+
return { proposals: [], sourcesScanned: ["skills-audit (stub)"] };
|
|
406044
|
+
}
|
|
406045
|
+
function createScannerDaemon(options) {
|
|
406046
|
+
const intervalMs = options.intervalMs ?? 14400000;
|
|
406047
|
+
const fs23 = options.fs;
|
|
406048
|
+
let timerId = null;
|
|
406049
|
+
async function scan() {
|
|
406050
|
+
const allProposals = [];
|
|
406051
|
+
const allSources = [];
|
|
406052
|
+
if (options.auditLogPath && fs23) {
|
|
406053
|
+
const result2 = await Promise.resolve(collectAuditLogSignals({
|
|
406054
|
+
auditLogPath: options.auditLogPath,
|
|
406055
|
+
fs: fs23
|
|
406056
|
+
}));
|
|
406057
|
+
allProposals.push(...result2.proposals);
|
|
406058
|
+
allSources.push(...result2.sourcesScanned);
|
|
406059
|
+
}
|
|
406060
|
+
if (options.memoryStore) {
|
|
406061
|
+
const result2 = await collectMemorySignals({
|
|
406062
|
+
memoryStore: options.memoryStore
|
|
406063
|
+
});
|
|
406064
|
+
allProposals.push(...result2.proposals);
|
|
406065
|
+
allSources.push(...result2.sourcesScanned);
|
|
406066
|
+
}
|
|
406067
|
+
if (options.memoryStore) {
|
|
406068
|
+
const result2 = await collectSessionSignals({
|
|
406069
|
+
memoryStore: options.memoryStore
|
|
406070
|
+
});
|
|
406071
|
+
allProposals.push(...result2.proposals);
|
|
406072
|
+
allSources.push(...result2.sourcesScanned);
|
|
406073
|
+
}
|
|
406074
|
+
if (options.projectDir && fs23) {
|
|
406075
|
+
const result2 = await Promise.resolve(collectSkillsSignals({
|
|
406076
|
+
skillsDir: options.projectDir,
|
|
406077
|
+
fs: fs23
|
|
406078
|
+
}));
|
|
406079
|
+
allProposals.push(...result2.proposals);
|
|
406080
|
+
allSources.push(...result2.sourcesScanned);
|
|
406081
|
+
}
|
|
406082
|
+
let writtenTo = null;
|
|
406083
|
+
const learningsPath = options.learningsPath ?? (options.projectDir ? `${options.projectDir}/.matrix/learnings.jsonl` : null);
|
|
406084
|
+
if (learningsPath && fs23) {
|
|
406085
|
+
for (const proposal of allProposals) {
|
|
406086
|
+
appendLearning(learningsPath, proposal, fs23);
|
|
406087
|
+
}
|
|
406088
|
+
writtenTo = learningsPath;
|
|
406089
|
+
}
|
|
406090
|
+
const result = {
|
|
406091
|
+
totalProposals: allProposals.length,
|
|
406092
|
+
sourcesScanned: allSources,
|
|
406093
|
+
writtenTo,
|
|
406094
|
+
timestamp: new Date().toISOString()
|
|
406095
|
+
};
|
|
406096
|
+
options.onScanComplete?.(result);
|
|
406097
|
+
return result;
|
|
406098
|
+
}
|
|
406099
|
+
return {
|
|
406100
|
+
start() {
|
|
406101
|
+
if (timerId)
|
|
406102
|
+
return;
|
|
406103
|
+
scan().catch(() => {});
|
|
406104
|
+
timerId = setInterval(() => {
|
|
406105
|
+
scan().catch(() => {});
|
|
406106
|
+
}, intervalMs);
|
|
406107
|
+
},
|
|
406108
|
+
stop() {
|
|
406109
|
+
if (timerId) {
|
|
406110
|
+
clearInterval(timerId);
|
|
406111
|
+
timerId = null;
|
|
406112
|
+
}
|
|
406113
|
+
},
|
|
406114
|
+
scanNow: scan
|
|
406115
|
+
};
|
|
406116
|
+
}
|
|
405452
406117
|
// packages/omo-opencode/src/features/background-agent/manager.ts
|
|
405453
|
-
import { join as
|
|
406118
|
+
import { join as join122 } from "path";
|
|
405454
406119
|
init_tmux();
|
|
405455
406120
|
|
|
405456
406121
|
// packages/omo-opencode/src/features/background-agent/abort-with-timeout.ts
|
|
@@ -405738,8 +406403,8 @@ function writeBackgroundTaskMarker(input) {
|
|
|
405738
406403
|
}
|
|
405739
406404
|
|
|
405740
406405
|
// packages/omo-opencode/src/features/background-agent/compaction-aware-message-resolver.ts
|
|
405741
|
-
import { readdirSync as readdirSync26, readFileSync as
|
|
405742
|
-
import { join as
|
|
406406
|
+
import { readdirSync as readdirSync26, readFileSync as readFileSync68 } from "fs";
|
|
406407
|
+
import { join as join121 } from "path";
|
|
405743
406408
|
function hasFullAgentAndModel(message) {
|
|
405744
406409
|
return !!message.agent && !isCompactionAgent(message.agent) && !!message.model?.providerID && !!message.model?.modelID;
|
|
405745
406410
|
}
|
|
@@ -405818,7 +406483,7 @@ function findNearestMessageExcludingCompaction(messageDir, sessionID) {
|
|
|
405818
406483
|
const messages = [];
|
|
405819
406484
|
for (const file2 of files) {
|
|
405820
406485
|
try {
|
|
405821
|
-
const content =
|
|
406486
|
+
const content = readFileSync68(join121(messageDir, file2), "utf-8");
|
|
405822
406487
|
const parsed = JSON.parse(content);
|
|
405823
406488
|
if (hasCompactionPartInStorage(parsed.id) || isCompactionAgent(parsed.agent)) {
|
|
405824
406489
|
continue;
|
|
@@ -410575,7 +411240,7 @@ The task was re-queued on a fallback model after a retryable failure.
|
|
|
410575
411240
|
parentSessionID: task.parentSessionId
|
|
410576
411241
|
});
|
|
410577
411242
|
}
|
|
410578
|
-
const messageDir =
|
|
411243
|
+
const messageDir = join122(MESSAGE_STORAGE, task.parentSessionId);
|
|
410579
411244
|
const currentMessage = messageDir ? findNearestMessageExcludingCompaction(messageDir, task.parentSessionId) : null;
|
|
410580
411245
|
agent = currentMessage?.agent ?? task.parentAgent;
|
|
410581
411246
|
model = currentMessage?.model?.providerID && currentMessage?.model?.modelID ? { providerID: currentMessage.model.providerID, modelID: currentMessage.model.modelID } : undefined;
|
|
@@ -412196,24 +412861,24 @@ function createMonitorManager(options) {
|
|
|
412196
412861
|
// packages/mcp-client-core/src/mcp-oauth/storage.ts
|
|
412197
412862
|
import { createHash as createHash6 } from "crypto";
|
|
412198
412863
|
import {
|
|
412199
|
-
chmodSync as
|
|
412200
|
-
existsSync as
|
|
412201
|
-
mkdirSync as
|
|
412864
|
+
chmodSync as chmodSync5,
|
|
412865
|
+
existsSync as existsSync106,
|
|
412866
|
+
mkdirSync as mkdirSync22,
|
|
412202
412867
|
readdirSync as readdirSync27,
|
|
412203
|
-
readFileSync as
|
|
412868
|
+
readFileSync as readFileSync70,
|
|
412204
412869
|
renameSync as renameSync9,
|
|
412205
412870
|
unlinkSync as unlinkSync16,
|
|
412206
|
-
writeFileSync as
|
|
412871
|
+
writeFileSync as writeFileSync23
|
|
412207
412872
|
} from "fs";
|
|
412208
|
-
import { basename as basename22, dirname as
|
|
412873
|
+
import { basename as basename22, dirname as dirname42, join as join125 } from "path";
|
|
412209
412874
|
|
|
412210
412875
|
// packages/mcp-client-core/src/config-dir.ts
|
|
412211
|
-
import { existsSync as
|
|
412212
|
-
import { homedir as
|
|
412213
|
-
import { join as
|
|
412876
|
+
import { existsSync as existsSync104, realpathSync as realpathSync18 } from "fs";
|
|
412877
|
+
import { homedir as homedir31 } from "os";
|
|
412878
|
+
import { join as join123, resolve as resolve36 } from "path";
|
|
412214
412879
|
function resolveConfigPath4(pathValue) {
|
|
412215
412880
|
const resolvedPath = resolve36(pathValue);
|
|
412216
|
-
if (!
|
|
412881
|
+
if (!existsSync104(resolvedPath))
|
|
412217
412882
|
return resolvedPath;
|
|
412218
412883
|
try {
|
|
412219
412884
|
return realpathSync18(resolvedPath);
|
|
@@ -412228,13 +412893,13 @@ function getOpenCodeCliConfigDir(env2 = process.env) {
|
|
|
412228
412893
|
if (customConfigDir) {
|
|
412229
412894
|
return resolveConfigPath4(customConfigDir);
|
|
412230
412895
|
}
|
|
412231
|
-
const xdgConfigDir = env2["XDG_CONFIG_HOME"]?.trim() ||
|
|
412232
|
-
return resolveConfigPath4(
|
|
412896
|
+
const xdgConfigDir = env2["XDG_CONFIG_HOME"]?.trim() || join123(homedir31(), ".config");
|
|
412897
|
+
return resolveConfigPath4(join123(xdgConfigDir, "opencode"));
|
|
412233
412898
|
}
|
|
412234
412899
|
|
|
412235
412900
|
// packages/mcp-client-core/src/mcp-oauth/storage-index.ts
|
|
412236
|
-
import { chmodSync as
|
|
412237
|
-
import { join as
|
|
412901
|
+
import { chmodSync as chmodSync4, existsSync as existsSync105, readFileSync as readFileSync69, renameSync as renameSync8, writeFileSync as writeFileSync22 } from "fs";
|
|
412902
|
+
import { join as join124 } from "path";
|
|
412238
412903
|
var INDEX_FILE_NAME = "index.json";
|
|
412239
412904
|
function isTokenIndex(value) {
|
|
412240
412905
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
@@ -412242,14 +412907,14 @@ function isTokenIndex(value) {
|
|
|
412242
412907
|
return Object.values(value).every((entry) => typeof entry === "string");
|
|
412243
412908
|
}
|
|
412244
412909
|
function getIndexPath(storageDir) {
|
|
412245
|
-
return
|
|
412910
|
+
return join124(storageDir, INDEX_FILE_NAME);
|
|
412246
412911
|
}
|
|
412247
412912
|
function readTokenIndex(storageDir) {
|
|
412248
412913
|
const indexPath = getIndexPath(storageDir);
|
|
412249
|
-
if (!
|
|
412914
|
+
if (!existsSync105(indexPath))
|
|
412250
412915
|
return {};
|
|
412251
412916
|
try {
|
|
412252
|
-
const parsed = JSON.parse(
|
|
412917
|
+
const parsed = JSON.parse(readFileSync69(indexPath, "utf-8"));
|
|
412253
412918
|
return isTokenIndex(parsed) ? parsed : {};
|
|
412254
412919
|
} catch (readError) {
|
|
412255
412920
|
if (!(readError instanceof Error))
|
|
@@ -412261,8 +412926,8 @@ function writeTokenIndex(storageDir, index) {
|
|
|
412261
412926
|
try {
|
|
412262
412927
|
const indexPath = getIndexPath(storageDir);
|
|
412263
412928
|
const tempPath = `${indexPath}.tmp.${Date.now()}`;
|
|
412264
|
-
|
|
412265
|
-
|
|
412929
|
+
writeFileSync22(tempPath, JSON.stringify(index, null, 2), { encoding: "utf-8", mode: 384 });
|
|
412930
|
+
chmodSync4(tempPath, 384);
|
|
412266
412931
|
renameSync8(tempPath, indexPath);
|
|
412267
412932
|
return true;
|
|
412268
412933
|
} catch (writeError) {
|
|
@@ -412279,16 +412944,16 @@ function saveTokenIndexEntry(storageDir, hash, key) {
|
|
|
412279
412944
|
var STORAGE_DIR_NAME = "mcp-oauth";
|
|
412280
412945
|
var LEGACY_STORAGE_FILE_NAME = "mcp-oauth.json";
|
|
412281
412946
|
function getMcpOauthStorageDir() {
|
|
412282
|
-
return
|
|
412947
|
+
return join125(getOpenCodeCliConfigDir(), STORAGE_DIR_NAME);
|
|
412283
412948
|
}
|
|
412284
412949
|
function getMcpOauthServerHash(serverHost, resource) {
|
|
412285
412950
|
return createHash6("sha256").update(buildKey(serverHost, resource)).digest("hex").slice(0, 32);
|
|
412286
412951
|
}
|
|
412287
412952
|
function getMcpOauthStoragePath(serverHost, resource) {
|
|
412288
|
-
return
|
|
412953
|
+
return join125(getMcpOauthStorageDir(), `${getMcpOauthServerHash(serverHost, resource)}.json`);
|
|
412289
412954
|
}
|
|
412290
412955
|
function getLegacyStoragePath() {
|
|
412291
|
-
return
|
|
412956
|
+
return join125(getOpenCodeCliConfigDir(), LEGACY_STORAGE_FILE_NAME);
|
|
412292
412957
|
}
|
|
412293
412958
|
function normalizeHost(serverHost) {
|
|
412294
412959
|
let host = serverHost.trim();
|
|
@@ -412349,10 +413014,10 @@ function isOAuthTokenData(value) {
|
|
|
412349
413014
|
return clientSecret === undefined || typeof clientSecret === "string";
|
|
412350
413015
|
}
|
|
412351
413016
|
function readTokenFile(filePath) {
|
|
412352
|
-
if (!
|
|
413017
|
+
if (!existsSync106(filePath))
|
|
412353
413018
|
return null;
|
|
412354
413019
|
try {
|
|
412355
|
-
const parsed = JSON.parse(
|
|
413020
|
+
const parsed = JSON.parse(readFileSync70(filePath, "utf-8"));
|
|
412356
413021
|
return isOAuthTokenData(parsed) ? parsed : null;
|
|
412357
413022
|
} catch (readError) {
|
|
412358
413023
|
if (!(readError instanceof Error))
|
|
@@ -412362,10 +413027,10 @@ function readTokenFile(filePath) {
|
|
|
412362
413027
|
}
|
|
412363
413028
|
function readLegacyStore() {
|
|
412364
413029
|
const filePath = getLegacyStoragePath();
|
|
412365
|
-
if (!
|
|
413030
|
+
if (!existsSync106(filePath))
|
|
412366
413031
|
return null;
|
|
412367
413032
|
try {
|
|
412368
|
-
const parsed = JSON.parse(
|
|
413033
|
+
const parsed = JSON.parse(readFileSync70(filePath, "utf-8"));
|
|
412369
413034
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
412370
413035
|
return null;
|
|
412371
413036
|
const result = {};
|
|
@@ -412382,13 +413047,13 @@ function readLegacyStore() {
|
|
|
412382
413047
|
}
|
|
412383
413048
|
function writeTokenFile(filePath, token) {
|
|
412384
413049
|
try {
|
|
412385
|
-
const dir =
|
|
412386
|
-
if (!
|
|
412387
|
-
|
|
413050
|
+
const dir = dirname42(filePath);
|
|
413051
|
+
if (!existsSync106(dir)) {
|
|
413052
|
+
mkdirSync22(dir, { recursive: true });
|
|
412388
413053
|
}
|
|
412389
413054
|
const tempPath = `${filePath}.tmp.${Date.now()}`;
|
|
412390
|
-
|
|
412391
|
-
|
|
413055
|
+
writeFileSync23(tempPath, JSON.stringify(token, null, 2), { encoding: "utf-8", mode: 384 });
|
|
413056
|
+
chmodSync5(tempPath, 384);
|
|
412392
413057
|
renameSync9(tempPath, filePath);
|
|
412393
413058
|
return true;
|
|
412394
413059
|
} catch (writeError) {
|
|
@@ -413069,63 +413734,63 @@ function getLiteralValue(schema2) {
|
|
|
413069
413734
|
}
|
|
413070
413735
|
|
|
413071
413736
|
// node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
413072
|
-
import * as
|
|
413737
|
+
import * as z9 from "zod/v4";
|
|
413073
413738
|
var LATEST_PROTOCOL_VERSION = "2025-11-25";
|
|
413074
413739
|
var SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-06-18", "2025-03-26", "2024-11-05", "2024-10-07"];
|
|
413075
413740
|
var RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
|
|
413076
413741
|
var JSONRPC_VERSION = "2.0";
|
|
413077
|
-
var AssertObjectSchema =
|
|
413078
|
-
var ProgressTokenSchema =
|
|
413079
|
-
var CursorSchema =
|
|
413080
|
-
var TaskCreationParamsSchema =
|
|
413081
|
-
ttl:
|
|
413082
|
-
pollInterval:
|
|
413742
|
+
var AssertObjectSchema = z9.custom((v) => v !== null && (typeof v === "object" || typeof v === "function"));
|
|
413743
|
+
var ProgressTokenSchema = z9.union([z9.string(), z9.number().int()]);
|
|
413744
|
+
var CursorSchema = z9.string();
|
|
413745
|
+
var TaskCreationParamsSchema = z9.looseObject({
|
|
413746
|
+
ttl: z9.number().optional(),
|
|
413747
|
+
pollInterval: z9.number().optional()
|
|
413083
413748
|
});
|
|
413084
|
-
var TaskMetadataSchema =
|
|
413085
|
-
ttl:
|
|
413749
|
+
var TaskMetadataSchema = z9.object({
|
|
413750
|
+
ttl: z9.number().optional()
|
|
413086
413751
|
});
|
|
413087
|
-
var RelatedTaskMetadataSchema =
|
|
413088
|
-
taskId:
|
|
413752
|
+
var RelatedTaskMetadataSchema = z9.object({
|
|
413753
|
+
taskId: z9.string()
|
|
413089
413754
|
});
|
|
413090
|
-
var RequestMetaSchema =
|
|
413755
|
+
var RequestMetaSchema = z9.looseObject({
|
|
413091
413756
|
progressToken: ProgressTokenSchema.optional(),
|
|
413092
413757
|
[RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
|
|
413093
413758
|
});
|
|
413094
|
-
var BaseRequestParamsSchema =
|
|
413759
|
+
var BaseRequestParamsSchema = z9.object({
|
|
413095
413760
|
_meta: RequestMetaSchema.optional()
|
|
413096
413761
|
});
|
|
413097
413762
|
var TaskAugmentedRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
413098
413763
|
task: TaskMetadataSchema.optional()
|
|
413099
413764
|
});
|
|
413100
413765
|
var isTaskAugmentedRequestParams = (value) => TaskAugmentedRequestParamsSchema.safeParse(value).success;
|
|
413101
|
-
var RequestSchema =
|
|
413102
|
-
method:
|
|
413766
|
+
var RequestSchema = z9.object({
|
|
413767
|
+
method: z9.string(),
|
|
413103
413768
|
params: BaseRequestParamsSchema.loose().optional()
|
|
413104
413769
|
});
|
|
413105
|
-
var NotificationsParamsSchema =
|
|
413770
|
+
var NotificationsParamsSchema = z9.object({
|
|
413106
413771
|
_meta: RequestMetaSchema.optional()
|
|
413107
413772
|
});
|
|
413108
|
-
var NotificationSchema =
|
|
413109
|
-
method:
|
|
413773
|
+
var NotificationSchema = z9.object({
|
|
413774
|
+
method: z9.string(),
|
|
413110
413775
|
params: NotificationsParamsSchema.loose().optional()
|
|
413111
413776
|
});
|
|
413112
|
-
var ResultSchema =
|
|
413777
|
+
var ResultSchema = z9.looseObject({
|
|
413113
413778
|
_meta: RequestMetaSchema.optional()
|
|
413114
413779
|
});
|
|
413115
|
-
var RequestIdSchema =
|
|
413116
|
-
var JSONRPCRequestSchema =
|
|
413117
|
-
jsonrpc:
|
|
413780
|
+
var RequestIdSchema = z9.union([z9.string(), z9.number().int()]);
|
|
413781
|
+
var JSONRPCRequestSchema = z9.object({
|
|
413782
|
+
jsonrpc: z9.literal(JSONRPC_VERSION),
|
|
413118
413783
|
id: RequestIdSchema,
|
|
413119
413784
|
...RequestSchema.shape
|
|
413120
413785
|
}).strict();
|
|
413121
413786
|
var isJSONRPCRequest = (value) => JSONRPCRequestSchema.safeParse(value).success;
|
|
413122
|
-
var JSONRPCNotificationSchema =
|
|
413123
|
-
jsonrpc:
|
|
413787
|
+
var JSONRPCNotificationSchema = z9.object({
|
|
413788
|
+
jsonrpc: z9.literal(JSONRPC_VERSION),
|
|
413124
413789
|
...NotificationSchema.shape
|
|
413125
413790
|
}).strict();
|
|
413126
413791
|
var isJSONRPCNotification = (value) => JSONRPCNotificationSchema.safeParse(value).success;
|
|
413127
|
-
var JSONRPCResultResponseSchema =
|
|
413128
|
-
jsonrpc:
|
|
413792
|
+
var JSONRPCResultResponseSchema = z9.object({
|
|
413793
|
+
jsonrpc: z9.literal(JSONRPC_VERSION),
|
|
413129
413794
|
id: RequestIdSchema,
|
|
413130
413795
|
result: ResultSchema
|
|
413131
413796
|
}).strict();
|
|
@@ -413141,153 +413806,153 @@ var ErrorCode;
|
|
|
413141
413806
|
ErrorCode2[ErrorCode2["InternalError"] = -32603] = "InternalError";
|
|
413142
413807
|
ErrorCode2[ErrorCode2["UrlElicitationRequired"] = -32042] = "UrlElicitationRequired";
|
|
413143
413808
|
})(ErrorCode || (ErrorCode = {}));
|
|
413144
|
-
var JSONRPCErrorResponseSchema =
|
|
413145
|
-
jsonrpc:
|
|
413809
|
+
var JSONRPCErrorResponseSchema = z9.object({
|
|
413810
|
+
jsonrpc: z9.literal(JSONRPC_VERSION),
|
|
413146
413811
|
id: RequestIdSchema.optional(),
|
|
413147
|
-
error:
|
|
413148
|
-
code:
|
|
413149
|
-
message:
|
|
413150
|
-
data:
|
|
413812
|
+
error: z9.object({
|
|
413813
|
+
code: z9.number().int(),
|
|
413814
|
+
message: z9.string(),
|
|
413815
|
+
data: z9.unknown().optional()
|
|
413151
413816
|
})
|
|
413152
413817
|
}).strict();
|
|
413153
413818
|
var isJSONRPCErrorResponse = (value) => JSONRPCErrorResponseSchema.safeParse(value).success;
|
|
413154
|
-
var JSONRPCMessageSchema =
|
|
413819
|
+
var JSONRPCMessageSchema = z9.union([
|
|
413155
413820
|
JSONRPCRequestSchema,
|
|
413156
413821
|
JSONRPCNotificationSchema,
|
|
413157
413822
|
JSONRPCResultResponseSchema,
|
|
413158
413823
|
JSONRPCErrorResponseSchema
|
|
413159
413824
|
]);
|
|
413160
|
-
var JSONRPCResponseSchema =
|
|
413825
|
+
var JSONRPCResponseSchema = z9.union([JSONRPCResultResponseSchema, JSONRPCErrorResponseSchema]);
|
|
413161
413826
|
var EmptyResultSchema = ResultSchema.strict();
|
|
413162
413827
|
var CancelledNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
413163
413828
|
requestId: RequestIdSchema.optional(),
|
|
413164
|
-
reason:
|
|
413829
|
+
reason: z9.string().optional()
|
|
413165
413830
|
});
|
|
413166
413831
|
var CancelledNotificationSchema = NotificationSchema.extend({
|
|
413167
|
-
method:
|
|
413832
|
+
method: z9.literal("notifications/cancelled"),
|
|
413168
413833
|
params: CancelledNotificationParamsSchema
|
|
413169
413834
|
});
|
|
413170
|
-
var IconSchema =
|
|
413171
|
-
src:
|
|
413172
|
-
mimeType:
|
|
413173
|
-
sizes:
|
|
413174
|
-
theme:
|
|
413835
|
+
var IconSchema = z9.object({
|
|
413836
|
+
src: z9.string(),
|
|
413837
|
+
mimeType: z9.string().optional(),
|
|
413838
|
+
sizes: z9.array(z9.string()).optional(),
|
|
413839
|
+
theme: z9.enum(["light", "dark"]).optional()
|
|
413175
413840
|
});
|
|
413176
|
-
var IconsSchema =
|
|
413177
|
-
icons:
|
|
413841
|
+
var IconsSchema = z9.object({
|
|
413842
|
+
icons: z9.array(IconSchema).optional()
|
|
413178
413843
|
});
|
|
413179
|
-
var BaseMetadataSchema =
|
|
413180
|
-
name:
|
|
413181
|
-
title:
|
|
413844
|
+
var BaseMetadataSchema = z9.object({
|
|
413845
|
+
name: z9.string(),
|
|
413846
|
+
title: z9.string().optional()
|
|
413182
413847
|
});
|
|
413183
413848
|
var ImplementationSchema = BaseMetadataSchema.extend({
|
|
413184
413849
|
...BaseMetadataSchema.shape,
|
|
413185
413850
|
...IconsSchema.shape,
|
|
413186
|
-
version:
|
|
413187
|
-
websiteUrl:
|
|
413188
|
-
description:
|
|
413189
|
-
});
|
|
413190
|
-
var FormElicitationCapabilitySchema =
|
|
413191
|
-
applyDefaults:
|
|
413192
|
-
}),
|
|
413193
|
-
var ElicitationCapabilitySchema =
|
|
413851
|
+
version: z9.string(),
|
|
413852
|
+
websiteUrl: z9.string().optional(),
|
|
413853
|
+
description: z9.string().optional()
|
|
413854
|
+
});
|
|
413855
|
+
var FormElicitationCapabilitySchema = z9.intersection(z9.object({
|
|
413856
|
+
applyDefaults: z9.boolean().optional()
|
|
413857
|
+
}), z9.record(z9.string(), z9.unknown()));
|
|
413858
|
+
var ElicitationCapabilitySchema = z9.preprocess((value) => {
|
|
413194
413859
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
413195
413860
|
if (Object.keys(value).length === 0) {
|
|
413196
413861
|
return { form: {} };
|
|
413197
413862
|
}
|
|
413198
413863
|
}
|
|
413199
413864
|
return value;
|
|
413200
|
-
},
|
|
413865
|
+
}, z9.intersection(z9.object({
|
|
413201
413866
|
form: FormElicitationCapabilitySchema.optional(),
|
|
413202
413867
|
url: AssertObjectSchema.optional()
|
|
413203
|
-
}),
|
|
413204
|
-
var ClientTasksCapabilitySchema =
|
|
413868
|
+
}), z9.record(z9.string(), z9.unknown()).optional()));
|
|
413869
|
+
var ClientTasksCapabilitySchema = z9.looseObject({
|
|
413205
413870
|
list: AssertObjectSchema.optional(),
|
|
413206
413871
|
cancel: AssertObjectSchema.optional(),
|
|
413207
|
-
requests:
|
|
413208
|
-
sampling:
|
|
413872
|
+
requests: z9.looseObject({
|
|
413873
|
+
sampling: z9.looseObject({
|
|
413209
413874
|
createMessage: AssertObjectSchema.optional()
|
|
413210
413875
|
}).optional(),
|
|
413211
|
-
elicitation:
|
|
413876
|
+
elicitation: z9.looseObject({
|
|
413212
413877
|
create: AssertObjectSchema.optional()
|
|
413213
413878
|
}).optional()
|
|
413214
413879
|
}).optional()
|
|
413215
413880
|
});
|
|
413216
|
-
var ServerTasksCapabilitySchema =
|
|
413881
|
+
var ServerTasksCapabilitySchema = z9.looseObject({
|
|
413217
413882
|
list: AssertObjectSchema.optional(),
|
|
413218
413883
|
cancel: AssertObjectSchema.optional(),
|
|
413219
|
-
requests:
|
|
413220
|
-
tools:
|
|
413884
|
+
requests: z9.looseObject({
|
|
413885
|
+
tools: z9.looseObject({
|
|
413221
413886
|
call: AssertObjectSchema.optional()
|
|
413222
413887
|
}).optional()
|
|
413223
413888
|
}).optional()
|
|
413224
413889
|
});
|
|
413225
|
-
var ClientCapabilitiesSchema =
|
|
413226
|
-
experimental:
|
|
413227
|
-
sampling:
|
|
413890
|
+
var ClientCapabilitiesSchema = z9.object({
|
|
413891
|
+
experimental: z9.record(z9.string(), AssertObjectSchema).optional(),
|
|
413892
|
+
sampling: z9.object({
|
|
413228
413893
|
context: AssertObjectSchema.optional(),
|
|
413229
413894
|
tools: AssertObjectSchema.optional()
|
|
413230
413895
|
}).optional(),
|
|
413231
413896
|
elicitation: ElicitationCapabilitySchema.optional(),
|
|
413232
|
-
roots:
|
|
413233
|
-
listChanged:
|
|
413897
|
+
roots: z9.object({
|
|
413898
|
+
listChanged: z9.boolean().optional()
|
|
413234
413899
|
}).optional(),
|
|
413235
413900
|
tasks: ClientTasksCapabilitySchema.optional(),
|
|
413236
|
-
extensions:
|
|
413901
|
+
extensions: z9.record(z9.string(), AssertObjectSchema).optional()
|
|
413237
413902
|
});
|
|
413238
413903
|
var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
413239
|
-
protocolVersion:
|
|
413904
|
+
protocolVersion: z9.string(),
|
|
413240
413905
|
capabilities: ClientCapabilitiesSchema,
|
|
413241
413906
|
clientInfo: ImplementationSchema
|
|
413242
413907
|
});
|
|
413243
413908
|
var InitializeRequestSchema = RequestSchema.extend({
|
|
413244
|
-
method:
|
|
413909
|
+
method: z9.literal("initialize"),
|
|
413245
413910
|
params: InitializeRequestParamsSchema
|
|
413246
413911
|
});
|
|
413247
|
-
var ServerCapabilitiesSchema =
|
|
413248
|
-
experimental:
|
|
413912
|
+
var ServerCapabilitiesSchema = z9.object({
|
|
413913
|
+
experimental: z9.record(z9.string(), AssertObjectSchema).optional(),
|
|
413249
413914
|
logging: AssertObjectSchema.optional(),
|
|
413250
413915
|
completions: AssertObjectSchema.optional(),
|
|
413251
|
-
prompts:
|
|
413252
|
-
listChanged:
|
|
413916
|
+
prompts: z9.object({
|
|
413917
|
+
listChanged: z9.boolean().optional()
|
|
413253
413918
|
}).optional(),
|
|
413254
|
-
resources:
|
|
413255
|
-
subscribe:
|
|
413256
|
-
listChanged:
|
|
413919
|
+
resources: z9.object({
|
|
413920
|
+
subscribe: z9.boolean().optional(),
|
|
413921
|
+
listChanged: z9.boolean().optional()
|
|
413257
413922
|
}).optional(),
|
|
413258
|
-
tools:
|
|
413259
|
-
listChanged:
|
|
413923
|
+
tools: z9.object({
|
|
413924
|
+
listChanged: z9.boolean().optional()
|
|
413260
413925
|
}).optional(),
|
|
413261
413926
|
tasks: ServerTasksCapabilitySchema.optional(),
|
|
413262
|
-
extensions:
|
|
413927
|
+
extensions: z9.record(z9.string(), AssertObjectSchema).optional()
|
|
413263
413928
|
});
|
|
413264
413929
|
var InitializeResultSchema = ResultSchema.extend({
|
|
413265
|
-
protocolVersion:
|
|
413930
|
+
protocolVersion: z9.string(),
|
|
413266
413931
|
capabilities: ServerCapabilitiesSchema,
|
|
413267
413932
|
serverInfo: ImplementationSchema,
|
|
413268
|
-
instructions:
|
|
413933
|
+
instructions: z9.string().optional()
|
|
413269
413934
|
});
|
|
413270
413935
|
var InitializedNotificationSchema = NotificationSchema.extend({
|
|
413271
|
-
method:
|
|
413936
|
+
method: z9.literal("notifications/initialized"),
|
|
413272
413937
|
params: NotificationsParamsSchema.optional()
|
|
413273
413938
|
});
|
|
413274
413939
|
var isInitializedNotification = (value) => InitializedNotificationSchema.safeParse(value).success;
|
|
413275
413940
|
var PingRequestSchema = RequestSchema.extend({
|
|
413276
|
-
method:
|
|
413941
|
+
method: z9.literal("ping"),
|
|
413277
413942
|
params: BaseRequestParamsSchema.optional()
|
|
413278
413943
|
});
|
|
413279
|
-
var ProgressSchema =
|
|
413280
|
-
progress:
|
|
413281
|
-
total:
|
|
413282
|
-
message:
|
|
413944
|
+
var ProgressSchema = z9.object({
|
|
413945
|
+
progress: z9.number(),
|
|
413946
|
+
total: z9.optional(z9.number()),
|
|
413947
|
+
message: z9.optional(z9.string())
|
|
413283
413948
|
});
|
|
413284
|
-
var ProgressNotificationParamsSchema =
|
|
413949
|
+
var ProgressNotificationParamsSchema = z9.object({
|
|
413285
413950
|
...NotificationsParamsSchema.shape,
|
|
413286
413951
|
...ProgressSchema.shape,
|
|
413287
413952
|
progressToken: ProgressTokenSchema
|
|
413288
413953
|
});
|
|
413289
413954
|
var ProgressNotificationSchema = NotificationSchema.extend({
|
|
413290
|
-
method:
|
|
413955
|
+
method: z9.literal("notifications/progress"),
|
|
413291
413956
|
params: ProgressNotificationParamsSchema
|
|
413292
413957
|
});
|
|
413293
413958
|
var PaginatedRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
@@ -413299,60 +413964,60 @@ var PaginatedRequestSchema = RequestSchema.extend({
|
|
|
413299
413964
|
var PaginatedResultSchema = ResultSchema.extend({
|
|
413300
413965
|
nextCursor: CursorSchema.optional()
|
|
413301
413966
|
});
|
|
413302
|
-
var TaskStatusSchema2 =
|
|
413303
|
-
var TaskSchema2 =
|
|
413304
|
-
taskId:
|
|
413967
|
+
var TaskStatusSchema2 = z9.enum(["working", "input_required", "completed", "failed", "cancelled"]);
|
|
413968
|
+
var TaskSchema2 = z9.object({
|
|
413969
|
+
taskId: z9.string(),
|
|
413305
413970
|
status: TaskStatusSchema2,
|
|
413306
|
-
ttl:
|
|
413307
|
-
createdAt:
|
|
413308
|
-
lastUpdatedAt:
|
|
413309
|
-
pollInterval:
|
|
413310
|
-
statusMessage:
|
|
413971
|
+
ttl: z9.union([z9.number(), z9.null()]),
|
|
413972
|
+
createdAt: z9.string(),
|
|
413973
|
+
lastUpdatedAt: z9.string(),
|
|
413974
|
+
pollInterval: z9.optional(z9.number()),
|
|
413975
|
+
statusMessage: z9.optional(z9.string())
|
|
413311
413976
|
});
|
|
413312
413977
|
var CreateTaskResultSchema = ResultSchema.extend({
|
|
413313
413978
|
task: TaskSchema2
|
|
413314
413979
|
});
|
|
413315
413980
|
var TaskStatusNotificationParamsSchema = NotificationsParamsSchema.merge(TaskSchema2);
|
|
413316
413981
|
var TaskStatusNotificationSchema = NotificationSchema.extend({
|
|
413317
|
-
method:
|
|
413982
|
+
method: z9.literal("notifications/tasks/status"),
|
|
413318
413983
|
params: TaskStatusNotificationParamsSchema
|
|
413319
413984
|
});
|
|
413320
413985
|
var GetTaskRequestSchema = RequestSchema.extend({
|
|
413321
|
-
method:
|
|
413986
|
+
method: z9.literal("tasks/get"),
|
|
413322
413987
|
params: BaseRequestParamsSchema.extend({
|
|
413323
|
-
taskId:
|
|
413988
|
+
taskId: z9.string()
|
|
413324
413989
|
})
|
|
413325
413990
|
});
|
|
413326
413991
|
var GetTaskResultSchema = ResultSchema.merge(TaskSchema2);
|
|
413327
413992
|
var GetTaskPayloadRequestSchema = RequestSchema.extend({
|
|
413328
|
-
method:
|
|
413993
|
+
method: z9.literal("tasks/result"),
|
|
413329
413994
|
params: BaseRequestParamsSchema.extend({
|
|
413330
|
-
taskId:
|
|
413995
|
+
taskId: z9.string()
|
|
413331
413996
|
})
|
|
413332
413997
|
});
|
|
413333
413998
|
var GetTaskPayloadResultSchema = ResultSchema.loose();
|
|
413334
413999
|
var ListTasksRequestSchema = PaginatedRequestSchema.extend({
|
|
413335
|
-
method:
|
|
414000
|
+
method: z9.literal("tasks/list")
|
|
413336
414001
|
});
|
|
413337
414002
|
var ListTasksResultSchema = PaginatedResultSchema.extend({
|
|
413338
|
-
tasks:
|
|
414003
|
+
tasks: z9.array(TaskSchema2)
|
|
413339
414004
|
});
|
|
413340
414005
|
var CancelTaskRequestSchema = RequestSchema.extend({
|
|
413341
|
-
method:
|
|
414006
|
+
method: z9.literal("tasks/cancel"),
|
|
413342
414007
|
params: BaseRequestParamsSchema.extend({
|
|
413343
|
-
taskId:
|
|
414008
|
+
taskId: z9.string()
|
|
413344
414009
|
})
|
|
413345
414010
|
});
|
|
413346
414011
|
var CancelTaskResultSchema = ResultSchema.merge(TaskSchema2);
|
|
413347
|
-
var ResourceContentsSchema =
|
|
413348
|
-
uri:
|
|
413349
|
-
mimeType:
|
|
413350
|
-
_meta:
|
|
414012
|
+
var ResourceContentsSchema = z9.object({
|
|
414013
|
+
uri: z9.string(),
|
|
414014
|
+
mimeType: z9.optional(z9.string()),
|
|
414015
|
+
_meta: z9.record(z9.string(), z9.unknown()).optional()
|
|
413351
414016
|
});
|
|
413352
414017
|
var TextResourceContentsSchema = ResourceContentsSchema.extend({
|
|
413353
|
-
text:
|
|
414018
|
+
text: z9.string()
|
|
413354
414019
|
});
|
|
413355
|
-
var Base64Schema =
|
|
414020
|
+
var Base64Schema = z9.string().refine((val) => {
|
|
413356
414021
|
try {
|
|
413357
414022
|
atob(val);
|
|
413358
414023
|
return true;
|
|
@@ -413363,447 +414028,447 @@ var Base64Schema = z7.string().refine((val) => {
|
|
|
413363
414028
|
var BlobResourceContentsSchema = ResourceContentsSchema.extend({
|
|
413364
414029
|
blob: Base64Schema
|
|
413365
414030
|
});
|
|
413366
|
-
var RoleSchema =
|
|
413367
|
-
var AnnotationsSchema =
|
|
413368
|
-
audience:
|
|
413369
|
-
priority:
|
|
413370
|
-
lastModified:
|
|
414031
|
+
var RoleSchema = z9.enum(["user", "assistant"]);
|
|
414032
|
+
var AnnotationsSchema = z9.object({
|
|
414033
|
+
audience: z9.array(RoleSchema).optional(),
|
|
414034
|
+
priority: z9.number().min(0).max(1).optional(),
|
|
414035
|
+
lastModified: z9.iso.datetime({ offset: true }).optional()
|
|
413371
414036
|
});
|
|
413372
|
-
var ResourceSchema =
|
|
414037
|
+
var ResourceSchema = z9.object({
|
|
413373
414038
|
...BaseMetadataSchema.shape,
|
|
413374
414039
|
...IconsSchema.shape,
|
|
413375
|
-
uri:
|
|
413376
|
-
description:
|
|
413377
|
-
mimeType:
|
|
413378
|
-
size:
|
|
414040
|
+
uri: z9.string(),
|
|
414041
|
+
description: z9.optional(z9.string()),
|
|
414042
|
+
mimeType: z9.optional(z9.string()),
|
|
414043
|
+
size: z9.optional(z9.number()),
|
|
413379
414044
|
annotations: AnnotationsSchema.optional(),
|
|
413380
|
-
_meta:
|
|
414045
|
+
_meta: z9.optional(z9.looseObject({}))
|
|
413381
414046
|
});
|
|
413382
|
-
var ResourceTemplateSchema =
|
|
414047
|
+
var ResourceTemplateSchema = z9.object({
|
|
413383
414048
|
...BaseMetadataSchema.shape,
|
|
413384
414049
|
...IconsSchema.shape,
|
|
413385
|
-
uriTemplate:
|
|
413386
|
-
description:
|
|
413387
|
-
mimeType:
|
|
414050
|
+
uriTemplate: z9.string(),
|
|
414051
|
+
description: z9.optional(z9.string()),
|
|
414052
|
+
mimeType: z9.optional(z9.string()),
|
|
413388
414053
|
annotations: AnnotationsSchema.optional(),
|
|
413389
|
-
_meta:
|
|
414054
|
+
_meta: z9.optional(z9.looseObject({}))
|
|
413390
414055
|
});
|
|
413391
414056
|
var ListResourcesRequestSchema = PaginatedRequestSchema.extend({
|
|
413392
|
-
method:
|
|
414057
|
+
method: z9.literal("resources/list")
|
|
413393
414058
|
});
|
|
413394
414059
|
var ListResourcesResultSchema = PaginatedResultSchema.extend({
|
|
413395
|
-
resources:
|
|
414060
|
+
resources: z9.array(ResourceSchema)
|
|
413396
414061
|
});
|
|
413397
414062
|
var ListResourceTemplatesRequestSchema = PaginatedRequestSchema.extend({
|
|
413398
|
-
method:
|
|
414063
|
+
method: z9.literal("resources/templates/list")
|
|
413399
414064
|
});
|
|
413400
414065
|
var ListResourceTemplatesResultSchema = PaginatedResultSchema.extend({
|
|
413401
|
-
resourceTemplates:
|
|
414066
|
+
resourceTemplates: z9.array(ResourceTemplateSchema)
|
|
413402
414067
|
});
|
|
413403
414068
|
var ResourceRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
413404
|
-
uri:
|
|
414069
|
+
uri: z9.string()
|
|
413405
414070
|
});
|
|
413406
414071
|
var ReadResourceRequestParamsSchema = ResourceRequestParamsSchema;
|
|
413407
414072
|
var ReadResourceRequestSchema = RequestSchema.extend({
|
|
413408
|
-
method:
|
|
414073
|
+
method: z9.literal("resources/read"),
|
|
413409
414074
|
params: ReadResourceRequestParamsSchema
|
|
413410
414075
|
});
|
|
413411
414076
|
var ReadResourceResultSchema = ResultSchema.extend({
|
|
413412
|
-
contents:
|
|
414077
|
+
contents: z9.array(z9.union([TextResourceContentsSchema, BlobResourceContentsSchema]))
|
|
413413
414078
|
});
|
|
413414
414079
|
var ResourceListChangedNotificationSchema = NotificationSchema.extend({
|
|
413415
|
-
method:
|
|
414080
|
+
method: z9.literal("notifications/resources/list_changed"),
|
|
413416
414081
|
params: NotificationsParamsSchema.optional()
|
|
413417
414082
|
});
|
|
413418
414083
|
var SubscribeRequestParamsSchema = ResourceRequestParamsSchema;
|
|
413419
414084
|
var SubscribeRequestSchema = RequestSchema.extend({
|
|
413420
|
-
method:
|
|
414085
|
+
method: z9.literal("resources/subscribe"),
|
|
413421
414086
|
params: SubscribeRequestParamsSchema
|
|
413422
414087
|
});
|
|
413423
414088
|
var UnsubscribeRequestParamsSchema = ResourceRequestParamsSchema;
|
|
413424
414089
|
var UnsubscribeRequestSchema = RequestSchema.extend({
|
|
413425
|
-
method:
|
|
414090
|
+
method: z9.literal("resources/unsubscribe"),
|
|
413426
414091
|
params: UnsubscribeRequestParamsSchema
|
|
413427
414092
|
});
|
|
413428
414093
|
var ResourceUpdatedNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
413429
|
-
uri:
|
|
414094
|
+
uri: z9.string()
|
|
413430
414095
|
});
|
|
413431
414096
|
var ResourceUpdatedNotificationSchema = NotificationSchema.extend({
|
|
413432
|
-
method:
|
|
414097
|
+
method: z9.literal("notifications/resources/updated"),
|
|
413433
414098
|
params: ResourceUpdatedNotificationParamsSchema
|
|
413434
414099
|
});
|
|
413435
|
-
var PromptArgumentSchema =
|
|
413436
|
-
name:
|
|
413437
|
-
description:
|
|
413438
|
-
required:
|
|
414100
|
+
var PromptArgumentSchema = z9.object({
|
|
414101
|
+
name: z9.string(),
|
|
414102
|
+
description: z9.optional(z9.string()),
|
|
414103
|
+
required: z9.optional(z9.boolean())
|
|
413439
414104
|
});
|
|
413440
|
-
var PromptSchema =
|
|
414105
|
+
var PromptSchema = z9.object({
|
|
413441
414106
|
...BaseMetadataSchema.shape,
|
|
413442
414107
|
...IconsSchema.shape,
|
|
413443
|
-
description:
|
|
413444
|
-
arguments:
|
|
413445
|
-
_meta:
|
|
414108
|
+
description: z9.optional(z9.string()),
|
|
414109
|
+
arguments: z9.optional(z9.array(PromptArgumentSchema)),
|
|
414110
|
+
_meta: z9.optional(z9.looseObject({}))
|
|
413446
414111
|
});
|
|
413447
414112
|
var ListPromptsRequestSchema = PaginatedRequestSchema.extend({
|
|
413448
|
-
method:
|
|
414113
|
+
method: z9.literal("prompts/list")
|
|
413449
414114
|
});
|
|
413450
414115
|
var ListPromptsResultSchema = PaginatedResultSchema.extend({
|
|
413451
|
-
prompts:
|
|
414116
|
+
prompts: z9.array(PromptSchema)
|
|
413452
414117
|
});
|
|
413453
414118
|
var GetPromptRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
413454
|
-
name:
|
|
413455
|
-
arguments:
|
|
414119
|
+
name: z9.string(),
|
|
414120
|
+
arguments: z9.record(z9.string(), z9.string()).optional()
|
|
413456
414121
|
});
|
|
413457
414122
|
var GetPromptRequestSchema = RequestSchema.extend({
|
|
413458
|
-
method:
|
|
414123
|
+
method: z9.literal("prompts/get"),
|
|
413459
414124
|
params: GetPromptRequestParamsSchema
|
|
413460
414125
|
});
|
|
413461
|
-
var TextContentSchema =
|
|
413462
|
-
type:
|
|
413463
|
-
text:
|
|
414126
|
+
var TextContentSchema = z9.object({
|
|
414127
|
+
type: z9.literal("text"),
|
|
414128
|
+
text: z9.string(),
|
|
413464
414129
|
annotations: AnnotationsSchema.optional(),
|
|
413465
|
-
_meta:
|
|
414130
|
+
_meta: z9.record(z9.string(), z9.unknown()).optional()
|
|
413466
414131
|
});
|
|
413467
|
-
var ImageContentSchema =
|
|
413468
|
-
type:
|
|
414132
|
+
var ImageContentSchema = z9.object({
|
|
414133
|
+
type: z9.literal("image"),
|
|
413469
414134
|
data: Base64Schema,
|
|
413470
|
-
mimeType:
|
|
414135
|
+
mimeType: z9.string(),
|
|
413471
414136
|
annotations: AnnotationsSchema.optional(),
|
|
413472
|
-
_meta:
|
|
414137
|
+
_meta: z9.record(z9.string(), z9.unknown()).optional()
|
|
413473
414138
|
});
|
|
413474
|
-
var AudioContentSchema =
|
|
413475
|
-
type:
|
|
414139
|
+
var AudioContentSchema = z9.object({
|
|
414140
|
+
type: z9.literal("audio"),
|
|
413476
414141
|
data: Base64Schema,
|
|
413477
|
-
mimeType:
|
|
414142
|
+
mimeType: z9.string(),
|
|
413478
414143
|
annotations: AnnotationsSchema.optional(),
|
|
413479
|
-
_meta:
|
|
413480
|
-
});
|
|
413481
|
-
var ToolUseContentSchema =
|
|
413482
|
-
type:
|
|
413483
|
-
name:
|
|
413484
|
-
id:
|
|
413485
|
-
input:
|
|
413486
|
-
_meta:
|
|
413487
|
-
});
|
|
413488
|
-
var EmbeddedResourceSchema =
|
|
413489
|
-
type:
|
|
413490
|
-
resource:
|
|
414144
|
+
_meta: z9.record(z9.string(), z9.unknown()).optional()
|
|
414145
|
+
});
|
|
414146
|
+
var ToolUseContentSchema = z9.object({
|
|
414147
|
+
type: z9.literal("tool_use"),
|
|
414148
|
+
name: z9.string(),
|
|
414149
|
+
id: z9.string(),
|
|
414150
|
+
input: z9.record(z9.string(), z9.unknown()),
|
|
414151
|
+
_meta: z9.record(z9.string(), z9.unknown()).optional()
|
|
414152
|
+
});
|
|
414153
|
+
var EmbeddedResourceSchema = z9.object({
|
|
414154
|
+
type: z9.literal("resource"),
|
|
414155
|
+
resource: z9.union([TextResourceContentsSchema, BlobResourceContentsSchema]),
|
|
413491
414156
|
annotations: AnnotationsSchema.optional(),
|
|
413492
|
-
_meta:
|
|
414157
|
+
_meta: z9.record(z9.string(), z9.unknown()).optional()
|
|
413493
414158
|
});
|
|
413494
414159
|
var ResourceLinkSchema = ResourceSchema.extend({
|
|
413495
|
-
type:
|
|
414160
|
+
type: z9.literal("resource_link")
|
|
413496
414161
|
});
|
|
413497
|
-
var ContentBlockSchema =
|
|
414162
|
+
var ContentBlockSchema = z9.union([
|
|
413498
414163
|
TextContentSchema,
|
|
413499
414164
|
ImageContentSchema,
|
|
413500
414165
|
AudioContentSchema,
|
|
413501
414166
|
ResourceLinkSchema,
|
|
413502
414167
|
EmbeddedResourceSchema
|
|
413503
414168
|
]);
|
|
413504
|
-
var PromptMessageSchema =
|
|
414169
|
+
var PromptMessageSchema = z9.object({
|
|
413505
414170
|
role: RoleSchema,
|
|
413506
414171
|
content: ContentBlockSchema
|
|
413507
414172
|
});
|
|
413508
414173
|
var GetPromptResultSchema = ResultSchema.extend({
|
|
413509
|
-
description:
|
|
413510
|
-
messages:
|
|
414174
|
+
description: z9.string().optional(),
|
|
414175
|
+
messages: z9.array(PromptMessageSchema)
|
|
413511
414176
|
});
|
|
413512
414177
|
var PromptListChangedNotificationSchema = NotificationSchema.extend({
|
|
413513
|
-
method:
|
|
414178
|
+
method: z9.literal("notifications/prompts/list_changed"),
|
|
413514
414179
|
params: NotificationsParamsSchema.optional()
|
|
413515
414180
|
});
|
|
413516
|
-
var ToolAnnotationsSchema =
|
|
413517
|
-
title:
|
|
413518
|
-
readOnlyHint:
|
|
413519
|
-
destructiveHint:
|
|
413520
|
-
idempotentHint:
|
|
413521
|
-
openWorldHint:
|
|
414181
|
+
var ToolAnnotationsSchema = z9.object({
|
|
414182
|
+
title: z9.string().optional(),
|
|
414183
|
+
readOnlyHint: z9.boolean().optional(),
|
|
414184
|
+
destructiveHint: z9.boolean().optional(),
|
|
414185
|
+
idempotentHint: z9.boolean().optional(),
|
|
414186
|
+
openWorldHint: z9.boolean().optional()
|
|
413522
414187
|
});
|
|
413523
|
-
var ToolExecutionSchema =
|
|
413524
|
-
taskSupport:
|
|
414188
|
+
var ToolExecutionSchema = z9.object({
|
|
414189
|
+
taskSupport: z9.enum(["required", "optional", "forbidden"]).optional()
|
|
413525
414190
|
});
|
|
413526
|
-
var ToolSchema =
|
|
414191
|
+
var ToolSchema = z9.object({
|
|
413527
414192
|
...BaseMetadataSchema.shape,
|
|
413528
414193
|
...IconsSchema.shape,
|
|
413529
|
-
description:
|
|
413530
|
-
inputSchema:
|
|
413531
|
-
type:
|
|
413532
|
-
properties:
|
|
413533
|
-
required:
|
|
413534
|
-
}).catchall(
|
|
413535
|
-
outputSchema:
|
|
413536
|
-
type:
|
|
413537
|
-
properties:
|
|
413538
|
-
required:
|
|
413539
|
-
}).catchall(
|
|
414194
|
+
description: z9.string().optional(),
|
|
414195
|
+
inputSchema: z9.object({
|
|
414196
|
+
type: z9.literal("object"),
|
|
414197
|
+
properties: z9.record(z9.string(), AssertObjectSchema).optional(),
|
|
414198
|
+
required: z9.array(z9.string()).optional()
|
|
414199
|
+
}).catchall(z9.unknown()),
|
|
414200
|
+
outputSchema: z9.object({
|
|
414201
|
+
type: z9.literal("object"),
|
|
414202
|
+
properties: z9.record(z9.string(), AssertObjectSchema).optional(),
|
|
414203
|
+
required: z9.array(z9.string()).optional()
|
|
414204
|
+
}).catchall(z9.unknown()).optional(),
|
|
413540
414205
|
annotations: ToolAnnotationsSchema.optional(),
|
|
413541
414206
|
execution: ToolExecutionSchema.optional(),
|
|
413542
|
-
_meta:
|
|
414207
|
+
_meta: z9.record(z9.string(), z9.unknown()).optional()
|
|
413543
414208
|
});
|
|
413544
414209
|
var ListToolsRequestSchema = PaginatedRequestSchema.extend({
|
|
413545
|
-
method:
|
|
414210
|
+
method: z9.literal("tools/list")
|
|
413546
414211
|
});
|
|
413547
414212
|
var ListToolsResultSchema = PaginatedResultSchema.extend({
|
|
413548
|
-
tools:
|
|
414213
|
+
tools: z9.array(ToolSchema)
|
|
413549
414214
|
});
|
|
413550
414215
|
var CallToolResultSchema = ResultSchema.extend({
|
|
413551
|
-
content:
|
|
413552
|
-
structuredContent:
|
|
413553
|
-
isError:
|
|
414216
|
+
content: z9.array(ContentBlockSchema).default([]),
|
|
414217
|
+
structuredContent: z9.record(z9.string(), z9.unknown()).optional(),
|
|
414218
|
+
isError: z9.boolean().optional()
|
|
413554
414219
|
});
|
|
413555
414220
|
var CompatibilityCallToolResultSchema = CallToolResultSchema.or(ResultSchema.extend({
|
|
413556
|
-
toolResult:
|
|
414221
|
+
toolResult: z9.unknown()
|
|
413557
414222
|
}));
|
|
413558
414223
|
var CallToolRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
413559
|
-
name:
|
|
413560
|
-
arguments:
|
|
414224
|
+
name: z9.string(),
|
|
414225
|
+
arguments: z9.record(z9.string(), z9.unknown()).optional()
|
|
413561
414226
|
});
|
|
413562
414227
|
var CallToolRequestSchema = RequestSchema.extend({
|
|
413563
|
-
method:
|
|
414228
|
+
method: z9.literal("tools/call"),
|
|
413564
414229
|
params: CallToolRequestParamsSchema
|
|
413565
414230
|
});
|
|
413566
414231
|
var ToolListChangedNotificationSchema = NotificationSchema.extend({
|
|
413567
|
-
method:
|
|
414232
|
+
method: z9.literal("notifications/tools/list_changed"),
|
|
413568
414233
|
params: NotificationsParamsSchema.optional()
|
|
413569
414234
|
});
|
|
413570
|
-
var ListChangedOptionsBaseSchema =
|
|
413571
|
-
autoRefresh:
|
|
413572
|
-
debounceMs:
|
|
414235
|
+
var ListChangedOptionsBaseSchema = z9.object({
|
|
414236
|
+
autoRefresh: z9.boolean().default(true),
|
|
414237
|
+
debounceMs: z9.number().int().nonnegative().default(300)
|
|
413573
414238
|
});
|
|
413574
|
-
var LoggingLevelSchema =
|
|
414239
|
+
var LoggingLevelSchema = z9.enum(["debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"]);
|
|
413575
414240
|
var SetLevelRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
413576
414241
|
level: LoggingLevelSchema
|
|
413577
414242
|
});
|
|
413578
414243
|
var SetLevelRequestSchema = RequestSchema.extend({
|
|
413579
|
-
method:
|
|
414244
|
+
method: z9.literal("logging/setLevel"),
|
|
413580
414245
|
params: SetLevelRequestParamsSchema
|
|
413581
414246
|
});
|
|
413582
414247
|
var LoggingMessageNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
413583
414248
|
level: LoggingLevelSchema,
|
|
413584
|
-
logger:
|
|
413585
|
-
data:
|
|
414249
|
+
logger: z9.string().optional(),
|
|
414250
|
+
data: z9.unknown()
|
|
413586
414251
|
});
|
|
413587
414252
|
var LoggingMessageNotificationSchema = NotificationSchema.extend({
|
|
413588
|
-
method:
|
|
414253
|
+
method: z9.literal("notifications/message"),
|
|
413589
414254
|
params: LoggingMessageNotificationParamsSchema
|
|
413590
414255
|
});
|
|
413591
|
-
var ModelHintSchema =
|
|
413592
|
-
name:
|
|
414256
|
+
var ModelHintSchema = z9.object({
|
|
414257
|
+
name: z9.string().optional()
|
|
413593
414258
|
});
|
|
413594
|
-
var ModelPreferencesSchema =
|
|
413595
|
-
hints:
|
|
413596
|
-
costPriority:
|
|
413597
|
-
speedPriority:
|
|
413598
|
-
intelligencePriority:
|
|
414259
|
+
var ModelPreferencesSchema = z9.object({
|
|
414260
|
+
hints: z9.array(ModelHintSchema).optional(),
|
|
414261
|
+
costPriority: z9.number().min(0).max(1).optional(),
|
|
414262
|
+
speedPriority: z9.number().min(0).max(1).optional(),
|
|
414263
|
+
intelligencePriority: z9.number().min(0).max(1).optional()
|
|
413599
414264
|
});
|
|
413600
|
-
var ToolChoiceSchema =
|
|
413601
|
-
mode:
|
|
414265
|
+
var ToolChoiceSchema = z9.object({
|
|
414266
|
+
mode: z9.enum(["auto", "required", "none"]).optional()
|
|
413602
414267
|
});
|
|
413603
|
-
var ToolResultContentSchema =
|
|
413604
|
-
type:
|
|
413605
|
-
toolUseId:
|
|
413606
|
-
content:
|
|
413607
|
-
structuredContent:
|
|
413608
|
-
isError:
|
|
413609
|
-
_meta:
|
|
414268
|
+
var ToolResultContentSchema = z9.object({
|
|
414269
|
+
type: z9.literal("tool_result"),
|
|
414270
|
+
toolUseId: z9.string().describe("The unique identifier for the corresponding tool call."),
|
|
414271
|
+
content: z9.array(ContentBlockSchema).default([]),
|
|
414272
|
+
structuredContent: z9.object({}).loose().optional(),
|
|
414273
|
+
isError: z9.boolean().optional(),
|
|
414274
|
+
_meta: z9.record(z9.string(), z9.unknown()).optional()
|
|
413610
414275
|
});
|
|
413611
|
-
var SamplingContentSchema =
|
|
413612
|
-
var SamplingMessageContentBlockSchema =
|
|
414276
|
+
var SamplingContentSchema = z9.discriminatedUnion("type", [TextContentSchema, ImageContentSchema, AudioContentSchema]);
|
|
414277
|
+
var SamplingMessageContentBlockSchema = z9.discriminatedUnion("type", [
|
|
413613
414278
|
TextContentSchema,
|
|
413614
414279
|
ImageContentSchema,
|
|
413615
414280
|
AudioContentSchema,
|
|
413616
414281
|
ToolUseContentSchema,
|
|
413617
414282
|
ToolResultContentSchema
|
|
413618
414283
|
]);
|
|
413619
|
-
var SamplingMessageSchema =
|
|
414284
|
+
var SamplingMessageSchema = z9.object({
|
|
413620
414285
|
role: RoleSchema,
|
|
413621
|
-
content:
|
|
413622
|
-
_meta:
|
|
414286
|
+
content: z9.union([SamplingMessageContentBlockSchema, z9.array(SamplingMessageContentBlockSchema)]),
|
|
414287
|
+
_meta: z9.record(z9.string(), z9.unknown()).optional()
|
|
413623
414288
|
});
|
|
413624
414289
|
var CreateMessageRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
413625
|
-
messages:
|
|
414290
|
+
messages: z9.array(SamplingMessageSchema),
|
|
413626
414291
|
modelPreferences: ModelPreferencesSchema.optional(),
|
|
413627
|
-
systemPrompt:
|
|
413628
|
-
includeContext:
|
|
413629
|
-
temperature:
|
|
413630
|
-
maxTokens:
|
|
413631
|
-
stopSequences:
|
|
414292
|
+
systemPrompt: z9.string().optional(),
|
|
414293
|
+
includeContext: z9.enum(["none", "thisServer", "allServers"]).optional(),
|
|
414294
|
+
temperature: z9.number().optional(),
|
|
414295
|
+
maxTokens: z9.number().int(),
|
|
414296
|
+
stopSequences: z9.array(z9.string()).optional(),
|
|
413632
414297
|
metadata: AssertObjectSchema.optional(),
|
|
413633
|
-
tools:
|
|
414298
|
+
tools: z9.array(ToolSchema).optional(),
|
|
413634
414299
|
toolChoice: ToolChoiceSchema.optional()
|
|
413635
414300
|
});
|
|
413636
414301
|
var CreateMessageRequestSchema = RequestSchema.extend({
|
|
413637
|
-
method:
|
|
414302
|
+
method: z9.literal("sampling/createMessage"),
|
|
413638
414303
|
params: CreateMessageRequestParamsSchema
|
|
413639
414304
|
});
|
|
413640
414305
|
var CreateMessageResultSchema = ResultSchema.extend({
|
|
413641
|
-
model:
|
|
413642
|
-
stopReason:
|
|
414306
|
+
model: z9.string(),
|
|
414307
|
+
stopReason: z9.optional(z9.enum(["endTurn", "stopSequence", "maxTokens"]).or(z9.string())),
|
|
413643
414308
|
role: RoleSchema,
|
|
413644
414309
|
content: SamplingContentSchema
|
|
413645
414310
|
});
|
|
413646
414311
|
var CreateMessageResultWithToolsSchema = ResultSchema.extend({
|
|
413647
|
-
model:
|
|
413648
|
-
stopReason:
|
|
414312
|
+
model: z9.string(),
|
|
414313
|
+
stopReason: z9.optional(z9.enum(["endTurn", "stopSequence", "maxTokens", "toolUse"]).or(z9.string())),
|
|
413649
414314
|
role: RoleSchema,
|
|
413650
|
-
content:
|
|
413651
|
-
});
|
|
413652
|
-
var BooleanSchemaSchema =
|
|
413653
|
-
type:
|
|
413654
|
-
title:
|
|
413655
|
-
description:
|
|
413656
|
-
default:
|
|
413657
|
-
});
|
|
413658
|
-
var StringSchemaSchema =
|
|
413659
|
-
type:
|
|
413660
|
-
title:
|
|
413661
|
-
description:
|
|
413662
|
-
minLength:
|
|
413663
|
-
maxLength:
|
|
413664
|
-
format:
|
|
413665
|
-
default:
|
|
413666
|
-
});
|
|
413667
|
-
var NumberSchemaSchema =
|
|
413668
|
-
type:
|
|
413669
|
-
title:
|
|
413670
|
-
description:
|
|
413671
|
-
minimum:
|
|
413672
|
-
maximum:
|
|
413673
|
-
default:
|
|
413674
|
-
});
|
|
413675
|
-
var UntitledSingleSelectEnumSchemaSchema =
|
|
413676
|
-
type:
|
|
413677
|
-
title:
|
|
413678
|
-
description:
|
|
413679
|
-
enum:
|
|
413680
|
-
default:
|
|
413681
|
-
});
|
|
413682
|
-
var TitledSingleSelectEnumSchemaSchema =
|
|
413683
|
-
type:
|
|
413684
|
-
title:
|
|
413685
|
-
description:
|
|
413686
|
-
oneOf:
|
|
413687
|
-
const:
|
|
413688
|
-
title:
|
|
414315
|
+
content: z9.union([SamplingMessageContentBlockSchema, z9.array(SamplingMessageContentBlockSchema)])
|
|
414316
|
+
});
|
|
414317
|
+
var BooleanSchemaSchema = z9.object({
|
|
414318
|
+
type: z9.literal("boolean"),
|
|
414319
|
+
title: z9.string().optional(),
|
|
414320
|
+
description: z9.string().optional(),
|
|
414321
|
+
default: z9.boolean().optional()
|
|
414322
|
+
});
|
|
414323
|
+
var StringSchemaSchema = z9.object({
|
|
414324
|
+
type: z9.literal("string"),
|
|
414325
|
+
title: z9.string().optional(),
|
|
414326
|
+
description: z9.string().optional(),
|
|
414327
|
+
minLength: z9.number().optional(),
|
|
414328
|
+
maxLength: z9.number().optional(),
|
|
414329
|
+
format: z9.enum(["email", "uri", "date", "date-time"]).optional(),
|
|
414330
|
+
default: z9.string().optional()
|
|
414331
|
+
});
|
|
414332
|
+
var NumberSchemaSchema = z9.object({
|
|
414333
|
+
type: z9.enum(["number", "integer"]),
|
|
414334
|
+
title: z9.string().optional(),
|
|
414335
|
+
description: z9.string().optional(),
|
|
414336
|
+
minimum: z9.number().optional(),
|
|
414337
|
+
maximum: z9.number().optional(),
|
|
414338
|
+
default: z9.number().optional()
|
|
414339
|
+
});
|
|
414340
|
+
var UntitledSingleSelectEnumSchemaSchema = z9.object({
|
|
414341
|
+
type: z9.literal("string"),
|
|
414342
|
+
title: z9.string().optional(),
|
|
414343
|
+
description: z9.string().optional(),
|
|
414344
|
+
enum: z9.array(z9.string()),
|
|
414345
|
+
default: z9.string().optional()
|
|
414346
|
+
});
|
|
414347
|
+
var TitledSingleSelectEnumSchemaSchema = z9.object({
|
|
414348
|
+
type: z9.literal("string"),
|
|
414349
|
+
title: z9.string().optional(),
|
|
414350
|
+
description: z9.string().optional(),
|
|
414351
|
+
oneOf: z9.array(z9.object({
|
|
414352
|
+
const: z9.string(),
|
|
414353
|
+
title: z9.string()
|
|
413689
414354
|
})),
|
|
413690
|
-
default:
|
|
413691
|
-
});
|
|
413692
|
-
var LegacyTitledEnumSchemaSchema =
|
|
413693
|
-
type:
|
|
413694
|
-
title:
|
|
413695
|
-
description:
|
|
413696
|
-
enum:
|
|
413697
|
-
enumNames:
|
|
413698
|
-
default:
|
|
413699
|
-
});
|
|
413700
|
-
var SingleSelectEnumSchemaSchema =
|
|
413701
|
-
var UntitledMultiSelectEnumSchemaSchema =
|
|
413702
|
-
type:
|
|
413703
|
-
title:
|
|
413704
|
-
description:
|
|
413705
|
-
minItems:
|
|
413706
|
-
maxItems:
|
|
413707
|
-
items:
|
|
413708
|
-
type:
|
|
413709
|
-
enum:
|
|
414355
|
+
default: z9.string().optional()
|
|
414356
|
+
});
|
|
414357
|
+
var LegacyTitledEnumSchemaSchema = z9.object({
|
|
414358
|
+
type: z9.literal("string"),
|
|
414359
|
+
title: z9.string().optional(),
|
|
414360
|
+
description: z9.string().optional(),
|
|
414361
|
+
enum: z9.array(z9.string()),
|
|
414362
|
+
enumNames: z9.array(z9.string()).optional(),
|
|
414363
|
+
default: z9.string().optional()
|
|
414364
|
+
});
|
|
414365
|
+
var SingleSelectEnumSchemaSchema = z9.union([UntitledSingleSelectEnumSchemaSchema, TitledSingleSelectEnumSchemaSchema]);
|
|
414366
|
+
var UntitledMultiSelectEnumSchemaSchema = z9.object({
|
|
414367
|
+
type: z9.literal("array"),
|
|
414368
|
+
title: z9.string().optional(),
|
|
414369
|
+
description: z9.string().optional(),
|
|
414370
|
+
minItems: z9.number().optional(),
|
|
414371
|
+
maxItems: z9.number().optional(),
|
|
414372
|
+
items: z9.object({
|
|
414373
|
+
type: z9.literal("string"),
|
|
414374
|
+
enum: z9.array(z9.string())
|
|
413710
414375
|
}),
|
|
413711
|
-
default:
|
|
413712
|
-
});
|
|
413713
|
-
var TitledMultiSelectEnumSchemaSchema =
|
|
413714
|
-
type:
|
|
413715
|
-
title:
|
|
413716
|
-
description:
|
|
413717
|
-
minItems:
|
|
413718
|
-
maxItems:
|
|
413719
|
-
items:
|
|
413720
|
-
anyOf:
|
|
413721
|
-
const:
|
|
413722
|
-
title:
|
|
414376
|
+
default: z9.array(z9.string()).optional()
|
|
414377
|
+
});
|
|
414378
|
+
var TitledMultiSelectEnumSchemaSchema = z9.object({
|
|
414379
|
+
type: z9.literal("array"),
|
|
414380
|
+
title: z9.string().optional(),
|
|
414381
|
+
description: z9.string().optional(),
|
|
414382
|
+
minItems: z9.number().optional(),
|
|
414383
|
+
maxItems: z9.number().optional(),
|
|
414384
|
+
items: z9.object({
|
|
414385
|
+
anyOf: z9.array(z9.object({
|
|
414386
|
+
const: z9.string(),
|
|
414387
|
+
title: z9.string()
|
|
413723
414388
|
}))
|
|
413724
414389
|
}),
|
|
413725
|
-
default:
|
|
414390
|
+
default: z9.array(z9.string()).optional()
|
|
413726
414391
|
});
|
|
413727
|
-
var MultiSelectEnumSchemaSchema =
|
|
413728
|
-
var EnumSchemaSchema =
|
|
413729
|
-
var PrimitiveSchemaDefinitionSchema =
|
|
414392
|
+
var MultiSelectEnumSchemaSchema = z9.union([UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema]);
|
|
414393
|
+
var EnumSchemaSchema = z9.union([LegacyTitledEnumSchemaSchema, SingleSelectEnumSchemaSchema, MultiSelectEnumSchemaSchema]);
|
|
414394
|
+
var PrimitiveSchemaDefinitionSchema = z9.union([EnumSchemaSchema, BooleanSchemaSchema, StringSchemaSchema, NumberSchemaSchema]);
|
|
413730
414395
|
var ElicitRequestFormParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
413731
|
-
mode:
|
|
413732
|
-
message:
|
|
413733
|
-
requestedSchema:
|
|
413734
|
-
type:
|
|
413735
|
-
properties:
|
|
413736
|
-
required:
|
|
414396
|
+
mode: z9.literal("form").optional(),
|
|
414397
|
+
message: z9.string(),
|
|
414398
|
+
requestedSchema: z9.object({
|
|
414399
|
+
type: z9.literal("object"),
|
|
414400
|
+
properties: z9.record(z9.string(), PrimitiveSchemaDefinitionSchema),
|
|
414401
|
+
required: z9.array(z9.string()).optional()
|
|
413737
414402
|
})
|
|
413738
414403
|
});
|
|
413739
414404
|
var ElicitRequestURLParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
413740
|
-
mode:
|
|
413741
|
-
message:
|
|
413742
|
-
elicitationId:
|
|
413743
|
-
url:
|
|
414405
|
+
mode: z9.literal("url"),
|
|
414406
|
+
message: z9.string(),
|
|
414407
|
+
elicitationId: z9.string(),
|
|
414408
|
+
url: z9.string().url()
|
|
413744
414409
|
});
|
|
413745
|
-
var ElicitRequestParamsSchema =
|
|
414410
|
+
var ElicitRequestParamsSchema = z9.union([ElicitRequestFormParamsSchema, ElicitRequestURLParamsSchema]);
|
|
413746
414411
|
var ElicitRequestSchema = RequestSchema.extend({
|
|
413747
|
-
method:
|
|
414412
|
+
method: z9.literal("elicitation/create"),
|
|
413748
414413
|
params: ElicitRequestParamsSchema
|
|
413749
414414
|
});
|
|
413750
414415
|
var ElicitationCompleteNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
413751
|
-
elicitationId:
|
|
414416
|
+
elicitationId: z9.string()
|
|
413752
414417
|
});
|
|
413753
414418
|
var ElicitationCompleteNotificationSchema = NotificationSchema.extend({
|
|
413754
|
-
method:
|
|
414419
|
+
method: z9.literal("notifications/elicitation/complete"),
|
|
413755
414420
|
params: ElicitationCompleteNotificationParamsSchema
|
|
413756
414421
|
});
|
|
413757
414422
|
var ElicitResultSchema = ResultSchema.extend({
|
|
413758
|
-
action:
|
|
413759
|
-
content:
|
|
414423
|
+
action: z9.enum(["accept", "decline", "cancel"]),
|
|
414424
|
+
content: z9.preprocess((val) => val === null ? undefined : val, z9.record(z9.string(), z9.union([z9.string(), z9.number(), z9.boolean(), z9.array(z9.string())])).optional())
|
|
413760
414425
|
});
|
|
413761
|
-
var ResourceTemplateReferenceSchema =
|
|
413762
|
-
type:
|
|
413763
|
-
uri:
|
|
414426
|
+
var ResourceTemplateReferenceSchema = z9.object({
|
|
414427
|
+
type: z9.literal("ref/resource"),
|
|
414428
|
+
uri: z9.string()
|
|
413764
414429
|
});
|
|
413765
|
-
var PromptReferenceSchema =
|
|
413766
|
-
type:
|
|
413767
|
-
name:
|
|
414430
|
+
var PromptReferenceSchema = z9.object({
|
|
414431
|
+
type: z9.literal("ref/prompt"),
|
|
414432
|
+
name: z9.string()
|
|
413768
414433
|
});
|
|
413769
414434
|
var CompleteRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
413770
|
-
ref:
|
|
413771
|
-
argument:
|
|
413772
|
-
name:
|
|
413773
|
-
value:
|
|
414435
|
+
ref: z9.union([PromptReferenceSchema, ResourceTemplateReferenceSchema]),
|
|
414436
|
+
argument: z9.object({
|
|
414437
|
+
name: z9.string(),
|
|
414438
|
+
value: z9.string()
|
|
413774
414439
|
}),
|
|
413775
|
-
context:
|
|
413776
|
-
arguments:
|
|
414440
|
+
context: z9.object({
|
|
414441
|
+
arguments: z9.record(z9.string(), z9.string()).optional()
|
|
413777
414442
|
}).optional()
|
|
413778
414443
|
});
|
|
413779
414444
|
var CompleteRequestSchema = RequestSchema.extend({
|
|
413780
|
-
method:
|
|
414445
|
+
method: z9.literal("completion/complete"),
|
|
413781
414446
|
params: CompleteRequestParamsSchema
|
|
413782
414447
|
});
|
|
413783
414448
|
var CompleteResultSchema = ResultSchema.extend({
|
|
413784
|
-
completion:
|
|
413785
|
-
values:
|
|
413786
|
-
total:
|
|
413787
|
-
hasMore:
|
|
414449
|
+
completion: z9.looseObject({
|
|
414450
|
+
values: z9.array(z9.string()).max(100),
|
|
414451
|
+
total: z9.optional(z9.number().int()),
|
|
414452
|
+
hasMore: z9.optional(z9.boolean())
|
|
413788
414453
|
})
|
|
413789
414454
|
});
|
|
413790
|
-
var RootSchema =
|
|
413791
|
-
uri:
|
|
413792
|
-
name:
|
|
413793
|
-
_meta:
|
|
414455
|
+
var RootSchema = z9.object({
|
|
414456
|
+
uri: z9.string().startsWith("file://"),
|
|
414457
|
+
name: z9.string().optional(),
|
|
414458
|
+
_meta: z9.record(z9.string(), z9.unknown()).optional()
|
|
413794
414459
|
});
|
|
413795
414460
|
var ListRootsRequestSchema = RequestSchema.extend({
|
|
413796
|
-
method:
|
|
414461
|
+
method: z9.literal("roots/list"),
|
|
413797
414462
|
params: BaseRequestParamsSchema.optional()
|
|
413798
414463
|
});
|
|
413799
414464
|
var ListRootsResultSchema = ResultSchema.extend({
|
|
413800
|
-
roots:
|
|
414465
|
+
roots: z9.array(RootSchema)
|
|
413801
414466
|
});
|
|
413802
414467
|
var RootsListChangedNotificationSchema = NotificationSchema.extend({
|
|
413803
|
-
method:
|
|
414468
|
+
method: z9.literal("notifications/roots/list_changed"),
|
|
413804
414469
|
params: NotificationsParamsSchema.optional()
|
|
413805
414470
|
});
|
|
413806
|
-
var ClientRequestSchema =
|
|
414471
|
+
var ClientRequestSchema = z9.union([
|
|
413807
414472
|
PingRequestSchema,
|
|
413808
414473
|
InitializeRequestSchema,
|
|
413809
414474
|
CompleteRequestSchema,
|
|
@@ -413822,14 +414487,14 @@ var ClientRequestSchema = z7.union([
|
|
|
413822
414487
|
ListTasksRequestSchema,
|
|
413823
414488
|
CancelTaskRequestSchema
|
|
413824
414489
|
]);
|
|
413825
|
-
var ClientNotificationSchema =
|
|
414490
|
+
var ClientNotificationSchema = z9.union([
|
|
413826
414491
|
CancelledNotificationSchema,
|
|
413827
414492
|
ProgressNotificationSchema,
|
|
413828
414493
|
InitializedNotificationSchema,
|
|
413829
414494
|
RootsListChangedNotificationSchema,
|
|
413830
414495
|
TaskStatusNotificationSchema
|
|
413831
414496
|
]);
|
|
413832
|
-
var ClientResultSchema =
|
|
414497
|
+
var ClientResultSchema = z9.union([
|
|
413833
414498
|
EmptyResultSchema,
|
|
413834
414499
|
CreateMessageResultSchema,
|
|
413835
414500
|
CreateMessageResultWithToolsSchema,
|
|
@@ -413839,7 +414504,7 @@ var ClientResultSchema = z7.union([
|
|
|
413839
414504
|
ListTasksResultSchema,
|
|
413840
414505
|
CreateTaskResultSchema
|
|
413841
414506
|
]);
|
|
413842
|
-
var ServerRequestSchema =
|
|
414507
|
+
var ServerRequestSchema = z9.union([
|
|
413843
414508
|
PingRequestSchema,
|
|
413844
414509
|
CreateMessageRequestSchema,
|
|
413845
414510
|
ElicitRequestSchema,
|
|
@@ -413849,7 +414514,7 @@ var ServerRequestSchema = z7.union([
|
|
|
413849
414514
|
ListTasksRequestSchema,
|
|
413850
414515
|
CancelTaskRequestSchema
|
|
413851
414516
|
]);
|
|
413852
|
-
var ServerNotificationSchema =
|
|
414517
|
+
var ServerNotificationSchema = z9.union([
|
|
413853
414518
|
CancelledNotificationSchema,
|
|
413854
414519
|
ProgressNotificationSchema,
|
|
413855
414520
|
LoggingMessageNotificationSchema,
|
|
@@ -413860,7 +414525,7 @@ var ServerNotificationSchema = z7.union([
|
|
|
413860
414525
|
TaskStatusNotificationSchema,
|
|
413861
414526
|
ElicitationCompleteNotificationSchema
|
|
413862
414527
|
]);
|
|
413863
|
-
var ServerResultSchema =
|
|
414528
|
+
var ServerResultSchema = z9.union([
|
|
413864
414529
|
EmptyResultSchema,
|
|
413865
414530
|
InitializeResultSchema,
|
|
413866
414531
|
CompleteResultSchema,
|
|
@@ -415464,149 +416129,149 @@ async function pkceChallenge(length) {
|
|
|
415464
416129
|
}
|
|
415465
416130
|
|
|
415466
416131
|
// node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.js
|
|
415467
|
-
import * as
|
|
415468
|
-
var SafeUrlSchema =
|
|
416132
|
+
import * as z10 from "zod/v4";
|
|
416133
|
+
var SafeUrlSchema = z10.url().superRefine((val, ctx) => {
|
|
415469
416134
|
if (!URL.canParse(val)) {
|
|
415470
416135
|
ctx.addIssue({
|
|
415471
|
-
code:
|
|
416136
|
+
code: z10.ZodIssueCode.custom,
|
|
415472
416137
|
message: "URL must be parseable",
|
|
415473
416138
|
fatal: true
|
|
415474
416139
|
});
|
|
415475
|
-
return
|
|
416140
|
+
return z10.NEVER;
|
|
415476
416141
|
}
|
|
415477
416142
|
}).refine((url2) => {
|
|
415478
416143
|
const u = new URL(url2);
|
|
415479
416144
|
return u.protocol !== "javascript:" && u.protocol !== "data:" && u.protocol !== "vbscript:";
|
|
415480
416145
|
}, { message: "URL cannot use javascript:, data:, or vbscript: scheme" });
|
|
415481
|
-
var OAuthProtectedResourceMetadataSchema =
|
|
415482
|
-
resource:
|
|
415483
|
-
authorization_servers:
|
|
415484
|
-
jwks_uri:
|
|
415485
|
-
scopes_supported:
|
|
415486
|
-
bearer_methods_supported:
|
|
415487
|
-
resource_signing_alg_values_supported:
|
|
415488
|
-
resource_name:
|
|
415489
|
-
resource_documentation:
|
|
415490
|
-
resource_policy_uri:
|
|
415491
|
-
resource_tos_uri:
|
|
415492
|
-
tls_client_certificate_bound_access_tokens:
|
|
415493
|
-
authorization_details_types_supported:
|
|
415494
|
-
dpop_signing_alg_values_supported:
|
|
415495
|
-
dpop_bound_access_tokens_required:
|
|
415496
|
-
});
|
|
415497
|
-
var OAuthMetadataSchema =
|
|
415498
|
-
issuer:
|
|
416146
|
+
var OAuthProtectedResourceMetadataSchema = z10.looseObject({
|
|
416147
|
+
resource: z10.string().url(),
|
|
416148
|
+
authorization_servers: z10.array(SafeUrlSchema).optional(),
|
|
416149
|
+
jwks_uri: z10.string().url().optional(),
|
|
416150
|
+
scopes_supported: z10.array(z10.string()).optional(),
|
|
416151
|
+
bearer_methods_supported: z10.array(z10.string()).optional(),
|
|
416152
|
+
resource_signing_alg_values_supported: z10.array(z10.string()).optional(),
|
|
416153
|
+
resource_name: z10.string().optional(),
|
|
416154
|
+
resource_documentation: z10.string().optional(),
|
|
416155
|
+
resource_policy_uri: z10.string().url().optional(),
|
|
416156
|
+
resource_tos_uri: z10.string().url().optional(),
|
|
416157
|
+
tls_client_certificate_bound_access_tokens: z10.boolean().optional(),
|
|
416158
|
+
authorization_details_types_supported: z10.array(z10.string()).optional(),
|
|
416159
|
+
dpop_signing_alg_values_supported: z10.array(z10.string()).optional(),
|
|
416160
|
+
dpop_bound_access_tokens_required: z10.boolean().optional()
|
|
416161
|
+
});
|
|
416162
|
+
var OAuthMetadataSchema = z10.looseObject({
|
|
416163
|
+
issuer: z10.string(),
|
|
415499
416164
|
authorization_endpoint: SafeUrlSchema,
|
|
415500
416165
|
token_endpoint: SafeUrlSchema,
|
|
415501
416166
|
registration_endpoint: SafeUrlSchema.optional(),
|
|
415502
|
-
scopes_supported:
|
|
415503
|
-
response_types_supported:
|
|
415504
|
-
response_modes_supported:
|
|
415505
|
-
grant_types_supported:
|
|
415506
|
-
token_endpoint_auth_methods_supported:
|
|
415507
|
-
token_endpoint_auth_signing_alg_values_supported:
|
|
416167
|
+
scopes_supported: z10.array(z10.string()).optional(),
|
|
416168
|
+
response_types_supported: z10.array(z10.string()),
|
|
416169
|
+
response_modes_supported: z10.array(z10.string()).optional(),
|
|
416170
|
+
grant_types_supported: z10.array(z10.string()).optional(),
|
|
416171
|
+
token_endpoint_auth_methods_supported: z10.array(z10.string()).optional(),
|
|
416172
|
+
token_endpoint_auth_signing_alg_values_supported: z10.array(z10.string()).optional(),
|
|
415508
416173
|
service_documentation: SafeUrlSchema.optional(),
|
|
415509
416174
|
revocation_endpoint: SafeUrlSchema.optional(),
|
|
415510
|
-
revocation_endpoint_auth_methods_supported:
|
|
415511
|
-
revocation_endpoint_auth_signing_alg_values_supported:
|
|
415512
|
-
introspection_endpoint:
|
|
415513
|
-
introspection_endpoint_auth_methods_supported:
|
|
415514
|
-
introspection_endpoint_auth_signing_alg_values_supported:
|
|
415515
|
-
code_challenge_methods_supported:
|
|
415516
|
-
client_id_metadata_document_supported:
|
|
415517
|
-
});
|
|
415518
|
-
var OpenIdProviderMetadataSchema =
|
|
415519
|
-
issuer:
|
|
416175
|
+
revocation_endpoint_auth_methods_supported: z10.array(z10.string()).optional(),
|
|
416176
|
+
revocation_endpoint_auth_signing_alg_values_supported: z10.array(z10.string()).optional(),
|
|
416177
|
+
introspection_endpoint: z10.string().optional(),
|
|
416178
|
+
introspection_endpoint_auth_methods_supported: z10.array(z10.string()).optional(),
|
|
416179
|
+
introspection_endpoint_auth_signing_alg_values_supported: z10.array(z10.string()).optional(),
|
|
416180
|
+
code_challenge_methods_supported: z10.array(z10.string()).optional(),
|
|
416181
|
+
client_id_metadata_document_supported: z10.boolean().optional()
|
|
416182
|
+
});
|
|
416183
|
+
var OpenIdProviderMetadataSchema = z10.looseObject({
|
|
416184
|
+
issuer: z10.string(),
|
|
415520
416185
|
authorization_endpoint: SafeUrlSchema,
|
|
415521
416186
|
token_endpoint: SafeUrlSchema,
|
|
415522
416187
|
userinfo_endpoint: SafeUrlSchema.optional(),
|
|
415523
416188
|
jwks_uri: SafeUrlSchema,
|
|
415524
416189
|
registration_endpoint: SafeUrlSchema.optional(),
|
|
415525
|
-
scopes_supported:
|
|
415526
|
-
response_types_supported:
|
|
415527
|
-
response_modes_supported:
|
|
415528
|
-
grant_types_supported:
|
|
415529
|
-
acr_values_supported:
|
|
415530
|
-
subject_types_supported:
|
|
415531
|
-
id_token_signing_alg_values_supported:
|
|
415532
|
-
id_token_encryption_alg_values_supported:
|
|
415533
|
-
id_token_encryption_enc_values_supported:
|
|
415534
|
-
userinfo_signing_alg_values_supported:
|
|
415535
|
-
userinfo_encryption_alg_values_supported:
|
|
415536
|
-
userinfo_encryption_enc_values_supported:
|
|
415537
|
-
request_object_signing_alg_values_supported:
|
|
415538
|
-
request_object_encryption_alg_values_supported:
|
|
415539
|
-
request_object_encryption_enc_values_supported:
|
|
415540
|
-
token_endpoint_auth_methods_supported:
|
|
415541
|
-
token_endpoint_auth_signing_alg_values_supported:
|
|
415542
|
-
display_values_supported:
|
|
415543
|
-
claim_types_supported:
|
|
415544
|
-
claims_supported:
|
|
415545
|
-
service_documentation:
|
|
415546
|
-
claims_locales_supported:
|
|
415547
|
-
ui_locales_supported:
|
|
415548
|
-
claims_parameter_supported:
|
|
415549
|
-
request_parameter_supported:
|
|
415550
|
-
request_uri_parameter_supported:
|
|
415551
|
-
require_request_uri_registration:
|
|
416190
|
+
scopes_supported: z10.array(z10.string()).optional(),
|
|
416191
|
+
response_types_supported: z10.array(z10.string()),
|
|
416192
|
+
response_modes_supported: z10.array(z10.string()).optional(),
|
|
416193
|
+
grant_types_supported: z10.array(z10.string()).optional(),
|
|
416194
|
+
acr_values_supported: z10.array(z10.string()).optional(),
|
|
416195
|
+
subject_types_supported: z10.array(z10.string()),
|
|
416196
|
+
id_token_signing_alg_values_supported: z10.array(z10.string()),
|
|
416197
|
+
id_token_encryption_alg_values_supported: z10.array(z10.string()).optional(),
|
|
416198
|
+
id_token_encryption_enc_values_supported: z10.array(z10.string()).optional(),
|
|
416199
|
+
userinfo_signing_alg_values_supported: z10.array(z10.string()).optional(),
|
|
416200
|
+
userinfo_encryption_alg_values_supported: z10.array(z10.string()).optional(),
|
|
416201
|
+
userinfo_encryption_enc_values_supported: z10.array(z10.string()).optional(),
|
|
416202
|
+
request_object_signing_alg_values_supported: z10.array(z10.string()).optional(),
|
|
416203
|
+
request_object_encryption_alg_values_supported: z10.array(z10.string()).optional(),
|
|
416204
|
+
request_object_encryption_enc_values_supported: z10.array(z10.string()).optional(),
|
|
416205
|
+
token_endpoint_auth_methods_supported: z10.array(z10.string()).optional(),
|
|
416206
|
+
token_endpoint_auth_signing_alg_values_supported: z10.array(z10.string()).optional(),
|
|
416207
|
+
display_values_supported: z10.array(z10.string()).optional(),
|
|
416208
|
+
claim_types_supported: z10.array(z10.string()).optional(),
|
|
416209
|
+
claims_supported: z10.array(z10.string()).optional(),
|
|
416210
|
+
service_documentation: z10.string().optional(),
|
|
416211
|
+
claims_locales_supported: z10.array(z10.string()).optional(),
|
|
416212
|
+
ui_locales_supported: z10.array(z10.string()).optional(),
|
|
416213
|
+
claims_parameter_supported: z10.boolean().optional(),
|
|
416214
|
+
request_parameter_supported: z10.boolean().optional(),
|
|
416215
|
+
request_uri_parameter_supported: z10.boolean().optional(),
|
|
416216
|
+
require_request_uri_registration: z10.boolean().optional(),
|
|
415552
416217
|
op_policy_uri: SafeUrlSchema.optional(),
|
|
415553
416218
|
op_tos_uri: SafeUrlSchema.optional(),
|
|
415554
|
-
client_id_metadata_document_supported:
|
|
416219
|
+
client_id_metadata_document_supported: z10.boolean().optional()
|
|
415555
416220
|
});
|
|
415556
|
-
var OpenIdProviderDiscoveryMetadataSchema =
|
|
416221
|
+
var OpenIdProviderDiscoveryMetadataSchema = z10.object({
|
|
415557
416222
|
...OpenIdProviderMetadataSchema.shape,
|
|
415558
416223
|
...OAuthMetadataSchema.pick({
|
|
415559
416224
|
code_challenge_methods_supported: true
|
|
415560
416225
|
}).shape
|
|
415561
416226
|
});
|
|
415562
|
-
var OAuthTokensSchema =
|
|
415563
|
-
access_token:
|
|
415564
|
-
id_token:
|
|
415565
|
-
token_type:
|
|
415566
|
-
expires_in:
|
|
415567
|
-
scope:
|
|
415568
|
-
refresh_token:
|
|
416227
|
+
var OAuthTokensSchema = z10.object({
|
|
416228
|
+
access_token: z10.string(),
|
|
416229
|
+
id_token: z10.string().optional(),
|
|
416230
|
+
token_type: z10.string(),
|
|
416231
|
+
expires_in: z10.coerce.number().optional(),
|
|
416232
|
+
scope: z10.string().optional(),
|
|
416233
|
+
refresh_token: z10.string().optional()
|
|
415569
416234
|
}).strip();
|
|
415570
|
-
var OAuthErrorResponseSchema =
|
|
415571
|
-
error:
|
|
415572
|
-
error_description:
|
|
415573
|
-
error_uri:
|
|
416235
|
+
var OAuthErrorResponseSchema = z10.object({
|
|
416236
|
+
error: z10.string(),
|
|
416237
|
+
error_description: z10.string().optional(),
|
|
416238
|
+
error_uri: z10.string().optional()
|
|
415574
416239
|
});
|
|
415575
|
-
var OptionalSafeUrlSchema = SafeUrlSchema.optional().or(
|
|
416240
|
+
var OptionalSafeUrlSchema = SafeUrlSchema.optional().or(z10.literal("").transform(() => {
|
|
415576
416241
|
return;
|
|
415577
416242
|
}));
|
|
415578
|
-
var OAuthClientMetadataSchema =
|
|
415579
|
-
redirect_uris:
|
|
415580
|
-
token_endpoint_auth_method:
|
|
415581
|
-
grant_types:
|
|
415582
|
-
response_types:
|
|
415583
|
-
client_name:
|
|
416243
|
+
var OAuthClientMetadataSchema = z10.object({
|
|
416244
|
+
redirect_uris: z10.array(SafeUrlSchema),
|
|
416245
|
+
token_endpoint_auth_method: z10.string().optional(),
|
|
416246
|
+
grant_types: z10.array(z10.string()).optional(),
|
|
416247
|
+
response_types: z10.array(z10.string()).optional(),
|
|
416248
|
+
client_name: z10.string().optional(),
|
|
415584
416249
|
client_uri: SafeUrlSchema.optional(),
|
|
415585
416250
|
logo_uri: OptionalSafeUrlSchema,
|
|
415586
|
-
scope:
|
|
415587
|
-
contacts:
|
|
416251
|
+
scope: z10.string().optional(),
|
|
416252
|
+
contacts: z10.array(z10.string()).optional(),
|
|
415588
416253
|
tos_uri: OptionalSafeUrlSchema,
|
|
415589
|
-
policy_uri:
|
|
416254
|
+
policy_uri: z10.string().optional(),
|
|
415590
416255
|
jwks_uri: SafeUrlSchema.optional(),
|
|
415591
|
-
jwks:
|
|
415592
|
-
software_id:
|
|
415593
|
-
software_version:
|
|
415594
|
-
software_statement:
|
|
416256
|
+
jwks: z10.any().optional(),
|
|
416257
|
+
software_id: z10.string().optional(),
|
|
416258
|
+
software_version: z10.string().optional(),
|
|
416259
|
+
software_statement: z10.string().optional()
|
|
415595
416260
|
}).strip();
|
|
415596
|
-
var OAuthClientInformationSchema =
|
|
415597
|
-
client_id:
|
|
415598
|
-
client_secret:
|
|
415599
|
-
client_id_issued_at:
|
|
415600
|
-
client_secret_expires_at:
|
|
416261
|
+
var OAuthClientInformationSchema = z10.object({
|
|
416262
|
+
client_id: z10.string(),
|
|
416263
|
+
client_secret: z10.string().optional(),
|
|
416264
|
+
client_id_issued_at: z10.number().optional(),
|
|
416265
|
+
client_secret_expires_at: z10.number().optional()
|
|
415601
416266
|
}).strip();
|
|
415602
416267
|
var OAuthClientInformationFullSchema = OAuthClientMetadataSchema.merge(OAuthClientInformationSchema);
|
|
415603
|
-
var OAuthClientRegistrationErrorSchema =
|
|
415604
|
-
error:
|
|
415605
|
-
error_description:
|
|
416268
|
+
var OAuthClientRegistrationErrorSchema = z10.object({
|
|
416269
|
+
error: z10.string(),
|
|
416270
|
+
error_description: z10.string().optional()
|
|
415606
416271
|
}).strip();
|
|
415607
|
-
var OAuthTokenRevocationRequestSchema =
|
|
415608
|
-
token:
|
|
415609
|
-
token_type_hint:
|
|
416272
|
+
var OAuthTokenRevocationRequestSchema = z10.object({
|
|
416273
|
+
token: z10.string(),
|
|
416274
|
+
token_type_hint: z10.string().optional()
|
|
415610
416275
|
}).strip();
|
|
415611
416276
|
|
|
415612
416277
|
// node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth-utils.js
|
|
@@ -417775,16 +418440,16 @@ var WRITE_DEBOUNCE_MS = 250;
|
|
|
417775
418440
|
init_logger2();
|
|
417776
418441
|
|
|
417777
418442
|
// packages/omo-opencode/src/features/tui-sidebar/mirror-io.ts
|
|
417778
|
-
import { mkdirSync as
|
|
417779
|
-
import { dirname as
|
|
418443
|
+
import { mkdirSync as mkdirSync23, readFileSync as readFileSync71 } from "fs";
|
|
418444
|
+
import { dirname as dirname43 } from "path";
|
|
417780
418445
|
|
|
417781
418446
|
// packages/omo-opencode/src/features/tui-sidebar/mirror-path.ts
|
|
417782
418447
|
import { createHash as createHash8 } from "crypto";
|
|
417783
418448
|
import { realpathSync as realpathSync19 } from "fs";
|
|
417784
|
-
import { homedir as
|
|
417785
|
-
import { join as
|
|
418449
|
+
import { homedir as homedir32 } from "os";
|
|
418450
|
+
import { join as join126, resolve as resolve37 } from "path";
|
|
417786
418451
|
function mirrorStorageDir() {
|
|
417787
|
-
return
|
|
418452
|
+
return join126(process.env.XDG_DATA_HOME ?? join126(homedir32(), ".local", "share"), "opencode", "storage", "matrixos", MIRROR_DIR_NAME);
|
|
417788
418453
|
}
|
|
417789
418454
|
function canonicalProjectDir(projectDir) {
|
|
417790
418455
|
try {
|
|
@@ -417798,11 +418463,11 @@ function canonicalProjectDir(projectDir) {
|
|
|
417798
418463
|
}
|
|
417799
418464
|
function mirrorFilePath(projectDir) {
|
|
417800
418465
|
const projectHash = createHash8("sha1").update(canonicalProjectDir(projectDir)).digest("hex").slice(0, 16);
|
|
417801
|
-
return
|
|
418466
|
+
return join126(mirrorStorageDir(), `${projectHash}.json`);
|
|
417802
418467
|
}
|
|
417803
418468
|
|
|
417804
418469
|
// packages/omo-opencode/src/features/tui-sidebar/snapshot-schema.ts
|
|
417805
|
-
import { z as
|
|
418470
|
+
import { z as z11 } from "zod";
|
|
417806
418471
|
var AGENT_STATUS_VALUES = [
|
|
417807
418472
|
"busy",
|
|
417808
418473
|
"idle",
|
|
@@ -417818,32 +418483,32 @@ var BACKGROUND_TASK_STATUS_VALUES = [
|
|
|
417818
418483
|
"cancelled",
|
|
417819
418484
|
"interrupt"
|
|
417820
418485
|
];
|
|
417821
|
-
var AgentRowSchema =
|
|
417822
|
-
name:
|
|
417823
|
-
status:
|
|
417824
|
-
});
|
|
417825
|
-
var JobRowSchema =
|
|
417826
|
-
title:
|
|
417827
|
-
status:
|
|
417828
|
-
toolCalls:
|
|
417829
|
-
lastTool:
|
|
417830
|
-
});
|
|
417831
|
-
var LoopLiveSchema =
|
|
417832
|
-
kind:
|
|
417833
|
-
goalsDone:
|
|
417834
|
-
goalsTotal:
|
|
417835
|
-
pass:
|
|
417836
|
-
fail:
|
|
417837
|
-
pending:
|
|
417838
|
-
blocked:
|
|
417839
|
-
activeGoal:
|
|
417840
|
-
});
|
|
417841
|
-
var TuiRuntimeSnapshotSchema =
|
|
417842
|
-
version:
|
|
417843
|
-
projectDir:
|
|
417844
|
-
updatedAt:
|
|
417845
|
-
activeAgents:
|
|
417846
|
-
jobBoard:
|
|
418486
|
+
var AgentRowSchema = z11.object({
|
|
418487
|
+
name: z11.string(),
|
|
418488
|
+
status: z11.enum(AGENT_STATUS_VALUES)
|
|
418489
|
+
});
|
|
418490
|
+
var JobRowSchema = z11.object({
|
|
418491
|
+
title: z11.string(),
|
|
418492
|
+
status: z11.enum(BACKGROUND_TASK_STATUS_VALUES),
|
|
418493
|
+
toolCalls: z11.number().int().nonnegative().nullable(),
|
|
418494
|
+
lastTool: z11.string().nullable()
|
|
418495
|
+
});
|
|
418496
|
+
var LoopLiveSchema = z11.object({
|
|
418497
|
+
kind: z11.literal("live"),
|
|
418498
|
+
goalsDone: z11.number().int().nonnegative(),
|
|
418499
|
+
goalsTotal: z11.number().int().nonnegative(),
|
|
418500
|
+
pass: z11.number().int().nonnegative(),
|
|
418501
|
+
fail: z11.number().int().nonnegative(),
|
|
418502
|
+
pending: z11.number().int().nonnegative(),
|
|
418503
|
+
blocked: z11.number().int().nonnegative(),
|
|
418504
|
+
activeGoal: z11.string().nullable()
|
|
418505
|
+
});
|
|
418506
|
+
var TuiRuntimeSnapshotSchema = z11.object({
|
|
418507
|
+
version: z11.literal(MIRROR_SCHEMA_VERSION),
|
|
418508
|
+
projectDir: z11.string(),
|
|
418509
|
+
updatedAt: z11.number(),
|
|
418510
|
+
activeAgents: z11.array(AgentRowSchema),
|
|
418511
|
+
jobBoard: z11.array(JobRowSchema),
|
|
417847
418512
|
loop: LoopLiveSchema.nullable()
|
|
417848
418513
|
});
|
|
417849
418514
|
|
|
@@ -417851,32 +418516,32 @@ var TuiRuntimeSnapshotSchema = z9.object({
|
|
|
417851
418516
|
function writeMirror(projectDir, snapshot) {
|
|
417852
418517
|
const filePath = mirrorFilePath(projectDir);
|
|
417853
418518
|
const content = JSON.stringify(snapshot);
|
|
417854
|
-
|
|
418519
|
+
mkdirSync23(dirname43(filePath), { recursive: true });
|
|
417855
418520
|
writeFileAtomically2(filePath, content, { mode: 384 });
|
|
417856
418521
|
}
|
|
417857
418522
|
|
|
417858
418523
|
// packages/omo-opencode/src/features/tui-sidebar/loop-reader.ts
|
|
417859
|
-
import { readdirSync as readdirSync28, readFileSync as
|
|
417860
|
-
import { join as
|
|
417861
|
-
import { z as
|
|
417862
|
-
var CriterionSchema =
|
|
417863
|
-
status:
|
|
417864
|
-
});
|
|
417865
|
-
var GoalBaseSchema =
|
|
417866
|
-
id:
|
|
417867
|
-
title:
|
|
417868
|
-
status:
|
|
417869
|
-
});
|
|
417870
|
-
var CurrentLoopSchema =
|
|
417871
|
-
version:
|
|
417872
|
-
activeGoalId:
|
|
417873
|
-
goals:
|
|
417874
|
-
successCriteria:
|
|
418524
|
+
import { readdirSync as readdirSync28, readFileSync as readFileSync72, statSync as statSync13 } from "fs";
|
|
418525
|
+
import { join as join127 } from "path";
|
|
418526
|
+
import { z as z12 } from "zod";
|
|
418527
|
+
var CriterionSchema = z12.object({
|
|
418528
|
+
status: z12.string()
|
|
418529
|
+
});
|
|
418530
|
+
var GoalBaseSchema = z12.object({
|
|
418531
|
+
id: z12.string(),
|
|
418532
|
+
title: z12.string(),
|
|
418533
|
+
status: z12.string()
|
|
418534
|
+
});
|
|
418535
|
+
var CurrentLoopSchema = z12.object({
|
|
418536
|
+
version: z12.literal(1),
|
|
418537
|
+
activeGoalId: z12.string().optional(),
|
|
418538
|
+
goals: z12.array(GoalBaseSchema.extend({
|
|
418539
|
+
successCriteria: z12.array(CriterionSchema)
|
|
417875
418540
|
}))
|
|
417876
418541
|
});
|
|
417877
|
-
var LegacyLoopSchema =
|
|
417878
|
-
goals:
|
|
417879
|
-
criteria:
|
|
418542
|
+
var LegacyLoopSchema = z12.object({
|
|
418543
|
+
goals: z12.array(GoalBaseSchema.extend({
|
|
418544
|
+
criteria: z12.array(CriterionSchema)
|
|
417880
418545
|
}))
|
|
417881
418546
|
});
|
|
417882
418547
|
function readActiveLoop(projectDir) {
|
|
@@ -417887,7 +418552,7 @@ function enumerateCandidates(projectDir) {
|
|
|
417887
418552
|
return [...currentLoopCandidates(projectDir), legacyLoopCandidate(projectDir)].filter((candidate) => candidate !== null);
|
|
417888
418553
|
}
|
|
417889
418554
|
function currentLoopCandidates(projectDir) {
|
|
417890
|
-
const loopRoot =
|
|
418555
|
+
const loopRoot = join127(projectDir, ".omo", "ulw-loop");
|
|
417891
418556
|
let entries;
|
|
417892
418557
|
try {
|
|
417893
418558
|
entries = readdirSync28(loopRoot, { withFileTypes: true });
|
|
@@ -417897,10 +418562,10 @@ function currentLoopCandidates(projectDir) {
|
|
|
417897
418562
|
}
|
|
417898
418563
|
throw error;
|
|
417899
418564
|
}
|
|
417900
|
-
return entries.filter((entry) => entry.isDirectory()).map((entry) => statCandidate(
|
|
418565
|
+
return entries.filter((entry) => entry.isDirectory()).map((entry) => statCandidate(join127(loopRoot, entry.name, "goals.json"))).filter((candidate) => candidate !== null);
|
|
417901
418566
|
}
|
|
417902
418567
|
function legacyLoopCandidate(projectDir) {
|
|
417903
|
-
return statCandidate(
|
|
418568
|
+
return statCandidate(join127(projectDir, ".omo", "loop", "goals.json"));
|
|
417904
418569
|
}
|
|
417905
418570
|
function statCandidate(path22) {
|
|
417906
418571
|
try {
|
|
@@ -417925,7 +418590,7 @@ function readLiveCandidate(candidate) {
|
|
|
417925
418590
|
function readParsedLoop(path22) {
|
|
417926
418591
|
let raw;
|
|
417927
418592
|
try {
|
|
417928
|
-
raw = JSON.parse(
|
|
418593
|
+
raw = JSON.parse(readFileSync72(path22, "utf8"));
|
|
417929
418594
|
} catch (error) {
|
|
417930
418595
|
if (error instanceof Error) {
|
|
417931
418596
|
return null;
|
|
@@ -420386,25 +421051,25 @@ async function createRuntimeSkillSourceServer(options, runtimeEnv = runtime6) {
|
|
|
420386
421051
|
};
|
|
420387
421052
|
}
|
|
420388
421053
|
// packages/claude-code-compat-core/src/features/claude-code-mcp-loader/loader.ts
|
|
420389
|
-
import { existsSync as
|
|
420390
|
-
import { join as
|
|
420391
|
-
import { homedir as
|
|
421054
|
+
import { existsSync as existsSync107, readFileSync as readFileSync73 } from "fs";
|
|
421055
|
+
import { join as join128 } from "path";
|
|
421056
|
+
import { homedir as homedir33 } from "os";
|
|
420392
421057
|
function getMcpConfigPaths() {
|
|
420393
421058
|
const claudeConfigDir = getClaudeConfigDir3();
|
|
420394
421059
|
const homeDir = getHomeDir();
|
|
420395
421060
|
const cwd = process.cwd();
|
|
420396
421061
|
return [
|
|
420397
|
-
{ path:
|
|
420398
|
-
{ path:
|
|
420399
|
-
{ path:
|
|
420400
|
-
{ path:
|
|
421062
|
+
{ path: join128(homeDir, ".claude.json"), scope: "user" },
|
|
421063
|
+
{ path: join128(claudeConfigDir, ".mcp.json"), scope: "user" },
|
|
421064
|
+
{ path: join128(cwd, ".mcp.json"), scope: "project" },
|
|
421065
|
+
{ path: join128(cwd, ".claude", ".mcp.json"), scope: "local" }
|
|
420401
421066
|
];
|
|
420402
421067
|
}
|
|
420403
421068
|
function getHomeDir() {
|
|
420404
|
-
return process.env.HOME || process.env.USERPROFILE ||
|
|
421069
|
+
return process.env.HOME || process.env.USERPROFILE || homedir33();
|
|
420405
421070
|
}
|
|
420406
421071
|
async function loadMcpConfigFile(filePath) {
|
|
420407
|
-
if (!
|
|
421072
|
+
if (!existsSync107(filePath)) {
|
|
420408
421073
|
return null;
|
|
420409
421074
|
}
|
|
420410
421075
|
try {
|
|
@@ -420424,10 +421089,10 @@ function getSystemMcpServerNames() {
|
|
|
420424
421089
|
const paths2 = getMcpConfigPaths();
|
|
420425
421090
|
const cwd = process.cwd();
|
|
420426
421091
|
for (const { path: path22 } of paths2) {
|
|
420427
|
-
if (!
|
|
421092
|
+
if (!existsSync107(path22))
|
|
420428
421093
|
continue;
|
|
420429
421094
|
try {
|
|
420430
|
-
const content =
|
|
421095
|
+
const content = readFileSync73(path22, "utf-8");
|
|
420431
421096
|
const config = JSON.parse(content);
|
|
420432
421097
|
if (!config?.mcpServers)
|
|
420433
421098
|
continue;
|
|
@@ -427607,15 +428272,15 @@ function createTankAgent(model, availableAgents, availableToolNames, availableSk
|
|
|
427607
428272
|
}
|
|
427608
428273
|
createTankAgent.mode = MODE9;
|
|
427609
428274
|
// packages/omo-opencode/src/agents/builtin-agents/resolve-file-uri.ts
|
|
427610
|
-
import { existsSync as
|
|
427611
|
-
import { homedir as
|
|
427612
|
-
import { isAbsolute as isAbsolute19, join as
|
|
428275
|
+
import { existsSync as existsSync108, readFileSync as readFileSync74 } from "fs";
|
|
428276
|
+
import { homedir as homedir34 } from "os";
|
|
428277
|
+
import { isAbsolute as isAbsolute19, join as join129, resolve as resolve38 } from "path";
|
|
427613
428278
|
init_logger2();
|
|
427614
428279
|
var ALLOWED_HOME_SUBDIRS = [
|
|
427615
|
-
|
|
427616
|
-
|
|
427617
|
-
|
|
427618
|
-
|
|
428280
|
+
join129(homedir34(), ".config", "opencode"),
|
|
428281
|
+
join129(homedir34(), ".config", "MaTrixOS"),
|
|
428282
|
+
join129(homedir34(), ".omo"),
|
|
428283
|
+
join129(homedir34(), ".opencode")
|
|
427619
428284
|
];
|
|
427620
428285
|
function isWithinAllowedPaths(filePath, projectRoot) {
|
|
427621
428286
|
if (isWithinProject(filePath, projectRoot))
|
|
@@ -427633,7 +428298,7 @@ function resolvePromptAppend(promptAppend, configDir) {
|
|
|
427633
428298
|
let filePath;
|
|
427634
428299
|
try {
|
|
427635
428300
|
const decoded = decodeURIComponent(encoded);
|
|
427636
|
-
const expanded = decoded.startsWith("~/") ? decoded.replace(/^~\//, `${
|
|
428301
|
+
const expanded = decoded.startsWith("~/") ? decoded.replace(/^~\//, `${homedir34()}/`) : decoded;
|
|
427637
428302
|
filePath = isAbsolute19(expanded) ? expanded : resolve38(configDir ?? process.cwd(), expanded);
|
|
427638
428303
|
} catch (error) {
|
|
427639
428304
|
if (!(error instanceof Error)) {
|
|
@@ -427651,11 +428316,11 @@ function resolvePromptAppend(promptAppend, configDir) {
|
|
|
427651
428316
|
});
|
|
427652
428317
|
return `[WARNING: Path rejected: ${promptAppend} (resolved outside project root ${projectRoot} and allowed home directories; file:// prompts must reside within the project directory, ~/.config/opencode/, ~/.config/MaTrixOS/, ~/.omo/, or ~/.opencode/)]`;
|
|
427653
428318
|
}
|
|
427654
|
-
if (!
|
|
428319
|
+
if (!existsSync108(filePath)) {
|
|
427655
428320
|
return `[WARNING: Could not resolve file URI: ${promptAppend}]`;
|
|
427656
428321
|
}
|
|
427657
428322
|
try {
|
|
427658
|
-
return
|
|
428323
|
+
return readFileSync74(filePath, "utf8");
|
|
427659
428324
|
} catch (error) {
|
|
427660
428325
|
if (!(error instanceof Error)) {
|
|
427661
428326
|
throw error;
|
|
@@ -430827,7 +431492,7 @@ async function applyAgentConfig(params) {
|
|
|
430827
431492
|
}
|
|
430828
431493
|
// packages/claude-code-compat-core/src/features/claude-code-command-loader/loader.ts
|
|
430829
431494
|
import { promises as fs23 } from "fs";
|
|
430830
|
-
import { join as
|
|
431495
|
+
import { join as join130, basename as basename23 } from "path";
|
|
430831
431496
|
|
|
430832
431497
|
// packages/claude-code-compat-core/src/features/claude-code-command-loader/loader-cache.ts
|
|
430833
431498
|
var commandLoaderCache = new Map;
|
|
@@ -430875,7 +431540,7 @@ async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix
|
|
|
430875
431540
|
continue;
|
|
430876
431541
|
if (entry.name.startsWith("."))
|
|
430877
431542
|
continue;
|
|
430878
|
-
const subDirPath =
|
|
431543
|
+
const subDirPath = join130(commandsDir, entry.name);
|
|
430879
431544
|
const subPrefix = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
430880
431545
|
const subCommands = await loadCommandsFromDir(subDirPath, scope, visited, subPrefix);
|
|
430881
431546
|
commands.push(...subCommands);
|
|
@@ -430883,7 +431548,7 @@ async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix
|
|
|
430883
431548
|
}
|
|
430884
431549
|
if (!isMarkdownFile(entry))
|
|
430885
431550
|
continue;
|
|
430886
|
-
const commandPath =
|
|
431551
|
+
const commandPath = join130(commandsDir, entry.name);
|
|
430887
431552
|
const baseCommandName = basename23(entry.name, ".md");
|
|
430888
431553
|
const commandName = prefix ? `${prefix}/${baseCommandName}` : baseCommandName;
|
|
430889
431554
|
try {
|
|
@@ -430946,12 +431611,12 @@ function commandsToRecord(commands) {
|
|
|
430946
431611
|
return result;
|
|
430947
431612
|
}
|
|
430948
431613
|
async function loadUserCommands() {
|
|
430949
|
-
const userCommandsDir =
|
|
431614
|
+
const userCommandsDir = join130(getClaudeConfigDir3(), "commands");
|
|
430950
431615
|
const commands = await loadCommandsFromDir(userCommandsDir, "user");
|
|
430951
431616
|
return commandsToRecord(commands);
|
|
430952
431617
|
}
|
|
430953
431618
|
async function loadProjectCommands(directory) {
|
|
430954
|
-
const projectCommandsDir =
|
|
431619
|
+
const projectCommandsDir = join130(directory ?? process.cwd(), ".claude", "commands");
|
|
430955
431620
|
const commands = await loadCommandsFromDir(projectCommandsDir, "project");
|
|
430956
431621
|
return commandsToRecord(commands);
|
|
430957
431622
|
}
|
|
@@ -431141,8 +431806,8 @@ var grep_app = {
|
|
|
431141
431806
|
|
|
431142
431807
|
// packages/omo-opencode/src/mcp/codegraph.ts
|
|
431143
431808
|
init_src();
|
|
431144
|
-
import { existsSync as
|
|
431145
|
-
import { join as
|
|
431809
|
+
import { existsSync as existsSync109 } from "fs";
|
|
431810
|
+
import { join as join131 } from "path";
|
|
431146
431811
|
|
|
431147
431812
|
// packages/omo-opencode/src/mcp/runtime-executable.ts
|
|
431148
431813
|
init_bun_which_shim();
|
|
@@ -431189,7 +431854,7 @@ function createWhichResolver(resolveExecutable) {
|
|
|
431189
431854
|
function provisionedBinFromInstallDir2(installDir, fileExists2) {
|
|
431190
431855
|
if (installDir === undefined)
|
|
431191
431856
|
return null;
|
|
431192
|
-
const candidate =
|
|
431857
|
+
const candidate = join131(installDir, "bin", process.platform === "win32" ? "codegraph.cmd" : "codegraph");
|
|
431193
431858
|
return fileExists2(candidate) ? candidate : null;
|
|
431194
431859
|
}
|
|
431195
431860
|
function codegraphEnvForConfig(config, homeDir) {
|
|
@@ -431200,7 +431865,7 @@ function createCodegraphMcpConfig(options = {}) {
|
|
|
431200
431865
|
const env2 = options.env ?? process.env;
|
|
431201
431866
|
const resolveExecutable = options.resolveExecutable ?? resolveRuntimeExecutable;
|
|
431202
431867
|
const which2 = createWhichResolver(resolveExecutable);
|
|
431203
|
-
const fileExists2 = options.fileExists ??
|
|
431868
|
+
const fileExists2 = options.fileExists ?? existsSync109;
|
|
431204
431869
|
const resolvedCommand = resolveCodegraphCommand({
|
|
431205
431870
|
env: env2,
|
|
431206
431871
|
fileExists: fileExists2,
|
|
@@ -431226,10 +431891,10 @@ function createCodegraphMcpConfig(options = {}) {
|
|
|
431226
431891
|
}
|
|
431227
431892
|
|
|
431228
431893
|
// packages/omo-opencode/src/mcp/lsp.ts
|
|
431229
|
-
import { existsSync as
|
|
431230
|
-
import { delimiter as delimiter2, dirname as
|
|
431894
|
+
import { existsSync as existsSync110, readFileSync as readFileSync75 } from "fs";
|
|
431895
|
+
import { delimiter as delimiter2, dirname as dirname44, resolve as resolve40 } from "path";
|
|
431231
431896
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
431232
|
-
import { z as
|
|
431897
|
+
import { z as z13 } from "zod";
|
|
431233
431898
|
|
|
431234
431899
|
// packages/omo-opencode/src/mcp/cli-suffix.ts
|
|
431235
431900
|
function normalizeCliPath(path22) {
|
|
@@ -431295,8 +431960,8 @@ var PROJECT_LSP_CONFIGS = [".opencode/lsp.json", ".omo/lsp.json", ".omo/lsp-clie
|
|
|
431295
431960
|
var DAEMON_PACKAGE_NAME = "@code-yeongyu/lsp-daemon";
|
|
431296
431961
|
var OMO_LSP_DAEMON_CLI = "OMO_LSP_DAEMON_CLI";
|
|
431297
431962
|
var OMO_LSP_DAEMON_VERSION = "OMO_LSP_DAEMON_VERSION";
|
|
431298
|
-
var DaemonPackageSchema =
|
|
431299
|
-
version:
|
|
431963
|
+
var DaemonPackageSchema = z13.object({
|
|
431964
|
+
version: z13.string().min(1)
|
|
431300
431965
|
});
|
|
431301
431966
|
var LSP_BOOTSTRAP_SCRIPT = [
|
|
431302
431967
|
"const { existsSync } = require('node:fs')",
|
|
@@ -431324,7 +431989,7 @@ var LSP_BOOTSTRAP_SCRIPT = [
|
|
|
431324
431989
|
].join(";");
|
|
431325
431990
|
function getModuleDirectory(moduleUrl) {
|
|
431326
431991
|
try {
|
|
431327
|
-
return
|
|
431992
|
+
return dirname44(fileURLToPath7(moduleUrl));
|
|
431328
431993
|
} catch (error) {
|
|
431329
431994
|
if (!(error instanceof Error))
|
|
431330
431995
|
throw error;
|
|
@@ -431336,7 +432001,7 @@ function findBootstrapRoot(candidates, pathExists) {
|
|
|
431336
432001
|
}
|
|
431337
432002
|
function readDaemonPackageVersion(root) {
|
|
431338
432003
|
try {
|
|
431339
|
-
const packageJson = JSON.parse(
|
|
432004
|
+
const packageJson = JSON.parse(readFileSync75(resolve40(root, PACKAGE_REL, "package.json"), "utf-8"));
|
|
431340
432005
|
return DaemonPackageSchema.parse(packageJson).version;
|
|
431341
432006
|
} catch (error) {
|
|
431342
432007
|
if (!(error instanceof Error))
|
|
@@ -431358,7 +432023,7 @@ function createBootstrapCandidate(root, pathExists, resolveExecutable) {
|
|
|
431358
432023
|
};
|
|
431359
432024
|
}
|
|
431360
432025
|
function resolveLspCommand(options = {}) {
|
|
431361
|
-
const pathExists = options.exists ??
|
|
432026
|
+
const pathExists = options.exists ?? existsSync110;
|
|
431362
432027
|
const resolveExecutable = options.resolveExecutable ?? resolveRuntimeExecutable;
|
|
431363
432028
|
const moduleDirectory = getModuleDirectory(options.moduleUrl ?? import.meta.url);
|
|
431364
432029
|
const candidates = moduleDirectory ? createAncestorCliCandidates({
|
|
@@ -431402,9 +432067,9 @@ function createLspMcpConfig(options = {}) {
|
|
|
431402
432067
|
}
|
|
431403
432068
|
|
|
431404
432069
|
// packages/omo-opencode/src/mcp/types.ts
|
|
431405
|
-
import { z as
|
|
431406
|
-
var McpNameSchema =
|
|
431407
|
-
var AnyMcpNameSchema =
|
|
432070
|
+
import { z as z14 } from "zod";
|
|
432071
|
+
var McpNameSchema = z14.enum(["websearch", "context7", "grep_app", "lsp", "codegraph"]);
|
|
432072
|
+
var AnyMcpNameSchema = z14.string().min(1);
|
|
431408
432073
|
|
|
431409
432074
|
// packages/omo-opencode/src/mcp/index.ts
|
|
431410
432075
|
function createBuiltinMcps(disabledMcps = [], config, options = {}) {
|
|
@@ -431808,6 +432473,7 @@ function createConfigHandler(deps) {
|
|
|
431808
432473
|
}
|
|
431809
432474
|
// packages/omo-opencode/src/create-managers.ts
|
|
431810
432475
|
init_server_health2();
|
|
432476
|
+
import { join as join132 } from "path";
|
|
431811
432477
|
var defaultCreateManagersDeps = {
|
|
431812
432478
|
BackgroundManagerClass: BackgroundManager,
|
|
431813
432479
|
SkillMcpManagerClass: SkillMcpManager,
|
|
@@ -431851,6 +432517,7 @@ function createManagers(args) {
|
|
|
431851
432517
|
deps.registerManagerForCleanupFn({
|
|
431852
432518
|
shutdown: async () => {
|
|
431853
432519
|
tuiStateMirror?.stop();
|
|
432520
|
+
scannerDaemon?.stop();
|
|
431854
432521
|
await cleanupTeamModeRuns().catch((error) => {
|
|
431855
432522
|
log2("[create-managers] team-mode cleanup error during process shutdown:", error);
|
|
431856
432523
|
});
|
|
@@ -431862,6 +432529,17 @@ function createManagers(args) {
|
|
|
431862
432529
|
});
|
|
431863
432530
|
}
|
|
431864
432531
|
});
|
|
432532
|
+
const scannerDaemon = createScannerDaemon({
|
|
432533
|
+
auditLogPath: join132(getDataDir(), "opencode", "matrix-gateway-audit.jsonl"),
|
|
432534
|
+
projectDir: ctx.directory,
|
|
432535
|
+
learningsPath: join132(ctx.directory, ".matrix", "learnings.jsonl"),
|
|
432536
|
+
intervalMs: 14400000,
|
|
432537
|
+
onScanComplete(result) {
|
|
432538
|
+
log2("[scanner-daemon] scan complete", result);
|
|
432539
|
+
}
|
|
432540
|
+
});
|
|
432541
|
+
scannerDaemon.start();
|
|
432542
|
+
log2("[create-managers] scanner daemon started (4h interval)");
|
|
431865
432543
|
backgroundManager = new deps.BackgroundManagerClass({
|
|
431866
432544
|
pluginContext: ctx,
|
|
431867
432545
|
config: pluginConfig.background_task,
|
|
@@ -435470,14 +436148,14 @@ class OpencodeClient2 extends HeyApiClient {
|
|
|
435470
436148
|
// node_modules/.bun/@opencode-ai+sdk@1.15.13/node_modules/@opencode-ai/sdk/dist/v2/server.js
|
|
435471
436149
|
var import_cross_spawn3 = __toESM(require_cross_spawn(), 1);
|
|
435472
436150
|
// packages/omo-opencode/src/plugin/native-skills.ts
|
|
435473
|
-
import { z as
|
|
435474
|
-
var NativeSkillEntrySchema =
|
|
435475
|
-
name:
|
|
435476
|
-
description:
|
|
435477
|
-
location:
|
|
435478
|
-
content:
|
|
436151
|
+
import { z as z15 } from "zod";
|
|
436152
|
+
var NativeSkillEntrySchema = z15.object({
|
|
436153
|
+
name: z15.string(),
|
|
436154
|
+
description: z15.string().default(""),
|
|
436155
|
+
location: z15.string(),
|
|
436156
|
+
content: z15.string()
|
|
435479
436157
|
});
|
|
435480
|
-
var NativeSkillEntriesSchema =
|
|
436158
|
+
var NativeSkillEntriesSchema = z15.array(NativeSkillEntrySchema);
|
|
435481
436159
|
function getObjectProperty(value, property) {
|
|
435482
436160
|
if (typeof value !== "object" || value === null)
|
|
435483
436161
|
return;
|
|
@@ -436604,7 +437282,7 @@ async function resolveParticipant2(teamRunId, sessionID, config, deps) {
|
|
|
436604
437282
|
}
|
|
436605
437283
|
|
|
436606
437284
|
// packages/omo-opencode/src/features/team-mode/tools/lifecycle-inline-spec.ts
|
|
436607
|
-
import { z as
|
|
437285
|
+
import { z as z16 } from "zod";
|
|
436608
437286
|
init_types2();
|
|
436609
437287
|
var TEAM_CREATE_USAGE = 'team_create requires exactly one of teamName or inline_spec. Use team_create({ teamName: "existing-team" }) or team_create({ inline_spec: { name: "team-name", members: [{ name: "worker", category: "quick", prompt: "Do the assigned work." }] } }).';
|
|
436610
437288
|
function omitEmptyStringArgs(rawArgs) {
|
|
@@ -436613,10 +437291,10 @@ function omitEmptyStringArgs(rawArgs) {
|
|
|
436613
437291
|
}
|
|
436614
437292
|
return Object.fromEntries(Object.entries(rawArgs).filter(([, value]) => value !== ""));
|
|
436615
437293
|
}
|
|
436616
|
-
var TeamCreateArgsSchema =
|
|
436617
|
-
teamName:
|
|
436618
|
-
inline_spec:
|
|
436619
|
-
leadSessionId:
|
|
437294
|
+
var TeamCreateArgsSchema = z16.preprocess(omitEmptyStringArgs, z16.object({
|
|
437295
|
+
teamName: z16.string().min(1).nullish(),
|
|
437296
|
+
inline_spec: z16.unknown().nullish(),
|
|
437297
|
+
leadSessionId: z16.string().nullish()
|
|
436620
437298
|
}).superRefine((value, ctx) => {
|
|
436621
437299
|
const optionCount = Number(value.teamName != null) + Number(value.inline_spec != null);
|
|
436622
437300
|
if (optionCount !== 1) {
|
|
@@ -436737,7 +437415,7 @@ function createTeamCreateTool(config, client5, bgMgr, tmuxMgr, executorConfig, d
|
|
|
436737
437415
|
});
|
|
436738
437416
|
}
|
|
436739
437417
|
// packages/omo-opencode/src/features/team-mode/tools/lifecycle-shutdown-tools.ts
|
|
436740
|
-
import { z as
|
|
437418
|
+
import { z as z17 } from "zod";
|
|
436741
437419
|
// packages/omo-opencode/src/features/team-mode/team-runtime/shutdown.ts
|
|
436742
437420
|
init_store3();
|
|
436743
437421
|
init_shutdown_helpers();
|
|
@@ -436826,13 +437504,13 @@ async function rejectShutdown(teamRunId, memberName, rejectorName, reason, confi
|
|
|
436826
437504
|
|
|
436827
437505
|
// packages/omo-opencode/src/features/team-mode/tools/lifecycle-shutdown-tools.ts
|
|
436828
437506
|
init_store2();
|
|
436829
|
-
var TeamDeleteArgsSchema =
|
|
436830
|
-
var TeamShutdownRequestArgsSchema =
|
|
436831
|
-
var TeamApproveShutdownArgsSchema =
|
|
436832
|
-
var TeamRejectShutdownArgsSchema =
|
|
436833
|
-
teamRunId:
|
|
436834
|
-
memberName:
|
|
436835
|
-
reason:
|
|
437507
|
+
var TeamDeleteArgsSchema = z17.object({ teamRunId: z17.string().min(1), force: z17.boolean().optional() });
|
|
437508
|
+
var TeamShutdownRequestArgsSchema = z17.object({ teamRunId: z17.string().min(1), targetMemberName: z17.string().min(1) });
|
|
437509
|
+
var TeamApproveShutdownArgsSchema = z17.object({ teamRunId: z17.string().min(1), memberName: z17.string().min(1) });
|
|
437510
|
+
var TeamRejectShutdownArgsSchema = z17.object({
|
|
437511
|
+
teamRunId: z17.string().min(1),
|
|
437512
|
+
memberName: z17.string().min(1),
|
|
437513
|
+
reason: z17.string().min(1)
|
|
436836
437514
|
});
|
|
436837
437515
|
var defaultTeamShutdownToolDeps = {
|
|
436838
437516
|
listActiveTeams,
|
|
@@ -437858,8 +438536,8 @@ function createChatHeadersHandler(args) {
|
|
|
437858
438536
|
}
|
|
437859
438537
|
|
|
437860
438538
|
// packages/omo-opencode/src/plugin/ultrawork-db-model-override.ts
|
|
437861
|
-
import { join as
|
|
437862
|
-
import { existsSync as
|
|
438539
|
+
import { join as join133 } from "path";
|
|
438540
|
+
import { existsSync as existsSync111 } from "fs";
|
|
437863
438541
|
async function importBunSqlite() {
|
|
437864
438542
|
if (typeof globalThis.Bun === "undefined") {
|
|
437865
438543
|
return null;
|
|
@@ -437875,7 +438553,7 @@ async function importBunSqlite() {
|
|
|
437875
438553
|
}
|
|
437876
438554
|
}
|
|
437877
438555
|
function getDbPath() {
|
|
437878
|
-
return
|
|
438556
|
+
return join133(getDataDir(), "opencode", "opencode.db");
|
|
437879
438557
|
}
|
|
437880
438558
|
var MAX_MICROTASK_RETRIES = 10;
|
|
437881
438559
|
function logCaughtDbError(message, metadata, error) {
|
|
@@ -437972,19 +438650,19 @@ async function retryViaMicrotask(db, messageId, targetModel, variant, attempt) {
|
|
|
437972
438650
|
async function scheduleDeferredModelOverride(messageId, targetModel, variant) {
|
|
437973
438651
|
await nextMicrotask();
|
|
437974
438652
|
const sqliteModule = await importBunSqlite();
|
|
437975
|
-
const
|
|
437976
|
-
if (typeof
|
|
438653
|
+
const Database2 = sqliteModule?.Database;
|
|
438654
|
+
if (typeof Database2 !== "function") {
|
|
437977
438655
|
log2("[ultrawork-db-override] bun:sqlite unavailable, skipping deferred override", { messageId });
|
|
437978
438656
|
return;
|
|
437979
438657
|
}
|
|
437980
438658
|
const dbPath = getDbPath();
|
|
437981
|
-
if (!
|
|
438659
|
+
if (!existsSync111(dbPath)) {
|
|
437982
438660
|
log2("[ultrawork-db-override] DB not found, skipping deferred override");
|
|
437983
438661
|
return;
|
|
437984
438662
|
}
|
|
437985
438663
|
let db;
|
|
437986
438664
|
try {
|
|
437987
|
-
db = new
|
|
438665
|
+
db = new Database2(dbPath);
|
|
437988
438666
|
} catch (error) {
|
|
437989
438667
|
logCaughtDbError("[ultrawork-db-override] Failed to open DB, skipping deferred override", { messageId }, error);
|
|
437990
438668
|
if (error instanceof Error)
|
|
@@ -439142,449 +439820,6 @@ function createModelFallbackEventHandler(args) {
|
|
|
439142
439820
|
};
|
|
439143
439821
|
}
|
|
439144
439822
|
|
|
439145
|
-
// packages/learning-loop/src/schema.ts
|
|
439146
|
-
import * as z16 from "zod";
|
|
439147
|
-
var LearningSchema = z16.object({
|
|
439148
|
-
id: z16.string().min(1),
|
|
439149
|
-
target: z16.string().min(1),
|
|
439150
|
-
rule: z16.string().min(1),
|
|
439151
|
-
rationale: z16.string().min(1),
|
|
439152
|
-
occurrences: z16.number().int().nonnegative(),
|
|
439153
|
-
confidence: z16.number().min(0).max(1),
|
|
439154
|
-
created_at: z16.string()
|
|
439155
|
-
}).strict();
|
|
439156
|
-
|
|
439157
|
-
// packages/learning-loop/src/store.ts
|
|
439158
|
-
import * as nodeFs from "fs";
|
|
439159
|
-
var NodeFs = {
|
|
439160
|
-
appendFileSync: nodeFs.appendFileSync,
|
|
439161
|
-
readFileSync: (p) => nodeFs.readFileSync(p, "utf8"),
|
|
439162
|
-
writeFileSync: nodeFs.writeFileSync,
|
|
439163
|
-
existsSync: nodeFs.existsSync,
|
|
439164
|
-
mkdirSync: (p, o) => nodeFs.mkdirSync(p, o)
|
|
439165
|
-
};
|
|
439166
|
-
function readLearnings(path26, fs24 = NodeFs) {
|
|
439167
|
-
if (!fs24.existsSync(path26))
|
|
439168
|
-
return [];
|
|
439169
|
-
const raw = fs24.readFileSync(path26);
|
|
439170
|
-
const lines = raw.split(`
|
|
439171
|
-
`).filter((l) => l.trim().length > 0);
|
|
439172
|
-
const out = [];
|
|
439173
|
-
for (const line of lines) {
|
|
439174
|
-
const parsed = LearningSchema.safeParse(JSON.parse(line));
|
|
439175
|
-
if (parsed.success)
|
|
439176
|
-
out.push(parsed.data);
|
|
439177
|
-
}
|
|
439178
|
-
return out;
|
|
439179
|
-
}
|
|
439180
|
-
function appendLearning(path26, learning, fs24 = NodeFs) {
|
|
439181
|
-
LearningSchema.parse(learning);
|
|
439182
|
-
fs24.appendFileSync(path26, JSON.stringify(learning) + `
|
|
439183
|
-
`);
|
|
439184
|
-
}
|
|
439185
|
-
|
|
439186
|
-
// packages/learning-loop/src/memory.ts
|
|
439187
|
-
function createMemoryStore() {
|
|
439188
|
-
const episodes = [];
|
|
439189
|
-
let counter = 0;
|
|
439190
|
-
const recordEpisode = (input) => {
|
|
439191
|
-
counter += 1;
|
|
439192
|
-
const ep = {
|
|
439193
|
-
id: input.id ?? `ep-${Date.now()}-${counter}`,
|
|
439194
|
-
sessionId: input.sessionId,
|
|
439195
|
-
type: input.type,
|
|
439196
|
-
summary: input.summary,
|
|
439197
|
-
timestamp: input.timestamp ?? new Date().toISOString(),
|
|
439198
|
-
metadata: input.metadata
|
|
439199
|
-
};
|
|
439200
|
-
episodes.push(ep);
|
|
439201
|
-
return ep;
|
|
439202
|
-
};
|
|
439203
|
-
const searchEpisodes = (query) => {
|
|
439204
|
-
const limit = query.limit ?? 50;
|
|
439205
|
-
const needle = query.textContains?.toLowerCase();
|
|
439206
|
-
const out = [];
|
|
439207
|
-
for (const ep of episodes) {
|
|
439208
|
-
if (query.sessionId && ep.sessionId !== query.sessionId)
|
|
439209
|
-
continue;
|
|
439210
|
-
if (query.type && ep.type !== query.type)
|
|
439211
|
-
continue;
|
|
439212
|
-
if (needle && !ep.summary.toLowerCase().includes(needle))
|
|
439213
|
-
continue;
|
|
439214
|
-
out.push(ep);
|
|
439215
|
-
if (out.length >= limit)
|
|
439216
|
-
break;
|
|
439217
|
-
}
|
|
439218
|
-
return out;
|
|
439219
|
-
};
|
|
439220
|
-
return {
|
|
439221
|
-
recordEpisode,
|
|
439222
|
-
searchEpisodes,
|
|
439223
|
-
size: () => episodes.length,
|
|
439224
|
-
clear: () => {
|
|
439225
|
-
episodes.length = 0;
|
|
439226
|
-
counter = 0;
|
|
439227
|
-
}
|
|
439228
|
-
};
|
|
439229
|
-
}
|
|
439230
|
-
|
|
439231
|
-
// packages/learning-loop/src/memory-sqlite.ts
|
|
439232
|
-
import { Database } from "bun:sqlite";
|
|
439233
|
-
import * as nodeFs2 from "fs";
|
|
439234
|
-
import * as nodePath from "path";
|
|
439235
|
-
import * as nodeOs from "os";
|
|
439236
|
-
import { randomUUID as randomUUID10 } from "crypto";
|
|
439237
|
-
var CREATE_EPISODES_TABLE = `
|
|
439238
|
-
CREATE TABLE IF NOT EXISTS episodes (
|
|
439239
|
-
id TEXT PRIMARY KEY,
|
|
439240
|
-
session_id TEXT NOT NULL,
|
|
439241
|
-
type TEXT NOT NULL,
|
|
439242
|
-
summary TEXT NOT NULL,
|
|
439243
|
-
timestamp TEXT NOT NULL,
|
|
439244
|
-
metadata TEXT
|
|
439245
|
-
)
|
|
439246
|
-
`;
|
|
439247
|
-
var CREATE_INDEX_SESSION_ID = `CREATE INDEX IF NOT EXISTS idx_session_id ON episodes(session_id)`;
|
|
439248
|
-
var CREATE_INDEX_TYPE = `CREATE INDEX IF NOT EXISTS idx_type ON episodes(type)`;
|
|
439249
|
-
var CREATE_FTS5_TABLE = `
|
|
439250
|
-
CREATE VIRTUAL TABLE IF NOT EXISTS episodes_fts USING fts5(
|
|
439251
|
-
summary,
|
|
439252
|
-
content=episodes,
|
|
439253
|
-
content_rowid=rowid
|
|
439254
|
-
)
|
|
439255
|
-
`;
|
|
439256
|
-
var CREATE_FTS_TRIGGER_INSERT = `
|
|
439257
|
-
CREATE TRIGGER IF NOT EXISTS episodes_ai AFTER INSERT ON episodes
|
|
439258
|
-
BEGIN
|
|
439259
|
-
INSERT INTO episodes_fts(rowid, summary) VALUES (new.rowid, new.summary);
|
|
439260
|
-
END
|
|
439261
|
-
`;
|
|
439262
|
-
var CREATE_FTS_TRIGGER_DELETE = `
|
|
439263
|
-
CREATE TRIGGER IF NOT EXISTS episodes_ad AFTER DELETE ON episodes
|
|
439264
|
-
BEGIN
|
|
439265
|
-
INSERT INTO episodes_fts(episodes_fts, rowid, summary) VALUES('delete', old.rowid, old.summary);
|
|
439266
|
-
END
|
|
439267
|
-
`;
|
|
439268
|
-
var CREATE_FTS_TRIGGER_UPDATE = `
|
|
439269
|
-
CREATE TRIGGER IF NOT EXISTS episodes_au AFTER UPDATE OF summary ON episodes
|
|
439270
|
-
BEGIN
|
|
439271
|
-
INSERT INTO episodes_fts(episodes_fts, rowid, summary) VALUES('delete', old.rowid, old.summary);
|
|
439272
|
-
INSERT INTO episodes_fts(rowid, summary) VALUES(new.rowid, new.summary);
|
|
439273
|
-
END
|
|
439274
|
-
`;
|
|
439275
|
-
var CREATE_VEC0_TABLE = `
|
|
439276
|
-
CREATE VIRTUAL TABLE IF NOT EXISTS episode_vec USING vec0(embedding float[384])
|
|
439277
|
-
`;
|
|
439278
|
-
var CREATE_VEC_META_TABLE = `
|
|
439279
|
-
CREATE TABLE IF NOT EXISTS episode_vec_meta(
|
|
439280
|
-
episode_id TEXT PRIMARY KEY REFERENCES episodes(id),
|
|
439281
|
-
vec_rowid INTEGER NOT NULL
|
|
439282
|
-
)
|
|
439283
|
-
`;
|
|
439284
|
-
var CREATE_VEC_META_INDEX = `CREATE INDEX IF NOT EXISTS idx_vec_meta_rowid ON episode_vec_meta(vec_rowid)`;
|
|
439285
|
-
function initSchema(db, fts5Available) {
|
|
439286
|
-
db.exec(CREATE_EPISODES_TABLE);
|
|
439287
|
-
db.exec(CREATE_INDEX_SESSION_ID);
|
|
439288
|
-
db.exec(CREATE_INDEX_TYPE);
|
|
439289
|
-
if (fts5Available) {
|
|
439290
|
-
db.exec(CREATE_FTS5_TABLE);
|
|
439291
|
-
db.exec(CREATE_FTS_TRIGGER_INSERT);
|
|
439292
|
-
db.exec(CREATE_FTS_TRIGGER_DELETE);
|
|
439293
|
-
db.exec(CREATE_FTS_TRIGGER_UPDATE);
|
|
439294
|
-
}
|
|
439295
|
-
}
|
|
439296
|
-
function applySchema(execFn, fts5Available) {
|
|
439297
|
-
execFn(CREATE_EPISODES_TABLE);
|
|
439298
|
-
execFn(CREATE_INDEX_SESSION_ID);
|
|
439299
|
-
execFn(CREATE_INDEX_TYPE);
|
|
439300
|
-
if (fts5Available) {
|
|
439301
|
-
execFn(CREATE_FTS5_TABLE);
|
|
439302
|
-
execFn(CREATE_FTS_TRIGGER_INSERT);
|
|
439303
|
-
execFn(CREATE_FTS_TRIGGER_DELETE);
|
|
439304
|
-
execFn(CREATE_FTS_TRIGGER_UPDATE);
|
|
439305
|
-
}
|
|
439306
|
-
}
|
|
439307
|
-
function detectFts5(db) {
|
|
439308
|
-
try {
|
|
439309
|
-
db.exec(CREATE_FTS5_TABLE);
|
|
439310
|
-
const rows = db.prepare("SELECT name FROM sqlite_master WHERE name = 'episodes_fts'").all();
|
|
439311
|
-
return rows.length > 0;
|
|
439312
|
-
} catch {
|
|
439313
|
-
return false;
|
|
439314
|
-
}
|
|
439315
|
-
}
|
|
439316
|
-
function rowToEpisode(row) {
|
|
439317
|
-
return {
|
|
439318
|
-
id: row.id,
|
|
439319
|
-
sessionId: row.session_id,
|
|
439320
|
-
type: row.type,
|
|
439321
|
-
summary: row.summary,
|
|
439322
|
-
timestamp: row.timestamp,
|
|
439323
|
-
metadata: row.metadata ? JSON.parse(row.metadata) : undefined
|
|
439324
|
-
};
|
|
439325
|
-
}
|
|
439326
|
-
function escapeFts5Quotes(text) {
|
|
439327
|
-
return text.replace(/"/g, '""');
|
|
439328
|
-
}
|
|
439329
|
-
var DEFAULT_DB_PATH = nodePath.join(nodeOs.homedir(), ".matrixos", "memory", "episodic.db");
|
|
439330
|
-
function ensureDbPath(dbPath) {
|
|
439331
|
-
const dir = nodePath.dirname(dbPath);
|
|
439332
|
-
if (!nodeFs2.existsSync(dir)) {
|
|
439333
|
-
nodeFs2.mkdirSync(dir, { recursive: true });
|
|
439334
|
-
}
|
|
439335
|
-
}
|
|
439336
|
-
function setPermissions(dbPath) {
|
|
439337
|
-
try {
|
|
439338
|
-
nodeFs2.chmodSync(dbPath, 384);
|
|
439339
|
-
} catch {}
|
|
439340
|
-
}
|
|
439341
|
-
function tryEnableVectorIndex(db) {
|
|
439342
|
-
try {
|
|
439343
|
-
const { getLoadablePath } = require_sqlite_vec();
|
|
439344
|
-
db.loadExtension(getLoadablePath());
|
|
439345
|
-
db.exec(CREATE_VEC0_TABLE);
|
|
439346
|
-
db.exec(CREATE_VEC_META_TABLE);
|
|
439347
|
-
db.exec(CREATE_VEC_META_INDEX);
|
|
439348
|
-
return true;
|
|
439349
|
-
} catch {
|
|
439350
|
-
return false;
|
|
439351
|
-
}
|
|
439352
|
-
}
|
|
439353
|
-
function createSqliteMemoryStore(options) {
|
|
439354
|
-
let db;
|
|
439355
|
-
let port;
|
|
439356
|
-
let fts5Available = false;
|
|
439357
|
-
let vecAvailable = false;
|
|
439358
|
-
let dbPath;
|
|
439359
|
-
if (options?.dbPort) {
|
|
439360
|
-
port = options.dbPort;
|
|
439361
|
-
fts5Available = false;
|
|
439362
|
-
applySchema((sql) => port.exec(sql), fts5Available);
|
|
439363
|
-
} else if (options?.db) {
|
|
439364
|
-
db = options.db;
|
|
439365
|
-
fts5Available = detectFts5(db);
|
|
439366
|
-
initSchema(db, fts5Available);
|
|
439367
|
-
vecAvailable = tryEnableVectorIndex(db);
|
|
439368
|
-
} else {
|
|
439369
|
-
dbPath = options?.path ?? DEFAULT_DB_PATH;
|
|
439370
|
-
ensureDbPath(dbPath);
|
|
439371
|
-
db = new Database(dbPath);
|
|
439372
|
-
setPermissions(dbPath);
|
|
439373
|
-
db.exec("PRAGMA journal_mode = WAL");
|
|
439374
|
-
db.exec("PRAGMA foreign_keys = ON");
|
|
439375
|
-
fts5Available = detectFts5(db);
|
|
439376
|
-
initSchema(db, fts5Available);
|
|
439377
|
-
vecAvailable = tryEnableVectorIndex(db);
|
|
439378
|
-
}
|
|
439379
|
-
function exec2(sql, ...params) {
|
|
439380
|
-
if (port) {
|
|
439381
|
-
port.exec(sql, ...params);
|
|
439382
|
-
return;
|
|
439383
|
-
}
|
|
439384
|
-
if (params.length === 0) {
|
|
439385
|
-
db.run(sql);
|
|
439386
|
-
} else {
|
|
439387
|
-
const named = params[0];
|
|
439388
|
-
db.run(sql, named);
|
|
439389
|
-
}
|
|
439390
|
-
}
|
|
439391
|
-
function queryFn(sql, ...params) {
|
|
439392
|
-
if (port) {
|
|
439393
|
-
return port.query(sql, ...params);
|
|
439394
|
-
}
|
|
439395
|
-
if (params.length === 0) {
|
|
439396
|
-
return db.prepare(sql).all();
|
|
439397
|
-
}
|
|
439398
|
-
const named = params[0];
|
|
439399
|
-
return db.prepare(sql).all(named);
|
|
439400
|
-
}
|
|
439401
|
-
const recordEpisode = (input) => {
|
|
439402
|
-
const ep = {
|
|
439403
|
-
id: input.id ?? randomUUID10(),
|
|
439404
|
-
sessionId: input.sessionId,
|
|
439405
|
-
type: input.type,
|
|
439406
|
-
summary: input.summary,
|
|
439407
|
-
timestamp: input.timestamp ?? new Date().toISOString(),
|
|
439408
|
-
metadata: input.metadata
|
|
439409
|
-
};
|
|
439410
|
-
exec2(`
|
|
439411
|
-
INSERT OR REPLACE INTO episodes (id, session_id, type, summary, timestamp, metadata)
|
|
439412
|
-
VALUES ($id, $session_id, $type, $summary, $timestamp, $metadata)
|
|
439413
|
-
`, {
|
|
439414
|
-
$id: ep.id,
|
|
439415
|
-
$session_id: ep.sessionId,
|
|
439416
|
-
$type: ep.type,
|
|
439417
|
-
$summary: ep.summary,
|
|
439418
|
-
$timestamp: ep.timestamp,
|
|
439419
|
-
$metadata: ep.metadata ? JSON.stringify(ep.metadata) : null
|
|
439420
|
-
});
|
|
439421
|
-
if (vecAvailable && options?.embeddingPort) {
|
|
439422
|
-
const portRef = options.embeddingPort;
|
|
439423
|
-
queueMicrotask(async () => {
|
|
439424
|
-
try {
|
|
439425
|
-
const [vector] = await portRef.embed([ep.summary]);
|
|
439426
|
-
const vecJson = JSON.stringify(vector);
|
|
439427
|
-
exec2("INSERT INTO episode_vec(embedding) VALUES ($embedding)", { $embedding: vecJson });
|
|
439428
|
-
const [ridRow] = queryFn("SELECT last_insert_rowid() AS rowid");
|
|
439429
|
-
const vecRowid = ridRow?.rowid ?? 0;
|
|
439430
|
-
exec2("INSERT OR REPLACE INTO episode_vec_meta(episode_id, vec_rowid) VALUES ($episodeId, $vecRowid)", { $episodeId: ep.id, $vecRowid: vecRowid });
|
|
439431
|
-
} catch (e) {
|
|
439432
|
-
console.warn("[memory] background embedding failed for", ep.id, e);
|
|
439433
|
-
}
|
|
439434
|
-
});
|
|
439435
|
-
}
|
|
439436
|
-
return ep;
|
|
439437
|
-
};
|
|
439438
|
-
const searchEpisodes = (queryArg) => {
|
|
439439
|
-
const limit = Math.min(queryArg.limit ?? 50, 200);
|
|
439440
|
-
const conditions = [];
|
|
439441
|
-
const params = {};
|
|
439442
|
-
if (queryArg.sessionId) {
|
|
439443
|
-
conditions.push("session_id = $session_id");
|
|
439444
|
-
params.$session_id = queryArg.sessionId;
|
|
439445
|
-
}
|
|
439446
|
-
if (queryArg.type) {
|
|
439447
|
-
conditions.push("type = $type");
|
|
439448
|
-
params.$type = queryArg.type;
|
|
439449
|
-
}
|
|
439450
|
-
let sql;
|
|
439451
|
-
const whereBase = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
439452
|
-
const searchText = queryArg.textContains ?? queryArg.semanticQuery;
|
|
439453
|
-
if (searchText) {
|
|
439454
|
-
if (fts5Available) {
|
|
439455
|
-
const escaped = escapeFts5Quotes(searchText);
|
|
439456
|
-
sql = `
|
|
439457
|
-
SELECT e.id, e.session_id, e.type, e.summary, e.timestamp, e.metadata
|
|
439458
|
-
FROM episodes e
|
|
439459
|
-
JOIN episodes_fts f ON e.rowid = f.rowid
|
|
439460
|
-
${whereBase ? `${whereBase} AND` : "WHERE"} f.summary MATCH $match
|
|
439461
|
-
ORDER BY rank
|
|
439462
|
-
LIMIT $limit
|
|
439463
|
-
`;
|
|
439464
|
-
params.$match = `"${escaped}"`;
|
|
439465
|
-
} else {
|
|
439466
|
-
sql = `
|
|
439467
|
-
SELECT id, session_id, type, summary, timestamp, metadata
|
|
439468
|
-
FROM episodes
|
|
439469
|
-
${whereBase ? `${whereBase} AND` : "WHERE"} summary LIKE $like
|
|
439470
|
-
LIMIT $limit
|
|
439471
|
-
`;
|
|
439472
|
-
params.$like = `%${searchText}%`;
|
|
439473
|
-
}
|
|
439474
|
-
} else {
|
|
439475
|
-
sql = `
|
|
439476
|
-
SELECT id, session_id, type, summary, timestamp, metadata
|
|
439477
|
-
FROM episodes
|
|
439478
|
-
${whereBase}
|
|
439479
|
-
LIMIT $limit
|
|
439480
|
-
`;
|
|
439481
|
-
}
|
|
439482
|
-
params.$limit = limit;
|
|
439483
|
-
const rows = queryFn(sql, params);
|
|
439484
|
-
return rows.map(rowToEpisode);
|
|
439485
|
-
};
|
|
439486
|
-
const size = () => {
|
|
439487
|
-
const rows = queryFn("SELECT COUNT(*) AS count FROM episodes");
|
|
439488
|
-
return rows[0]?.count ?? 0;
|
|
439489
|
-
};
|
|
439490
|
-
const clear = () => {
|
|
439491
|
-
if (vecAvailable) {
|
|
439492
|
-
exec2("DELETE FROM episode_vec_meta");
|
|
439493
|
-
}
|
|
439494
|
-
exec2("DELETE FROM episodes");
|
|
439495
|
-
if (vecAvailable) {
|
|
439496
|
-
exec2("DELETE FROM episode_vec");
|
|
439497
|
-
}
|
|
439498
|
-
};
|
|
439499
|
-
return {
|
|
439500
|
-
recordEpisode,
|
|
439501
|
-
searchEpisodes,
|
|
439502
|
-
size,
|
|
439503
|
-
clear
|
|
439504
|
-
};
|
|
439505
|
-
}
|
|
439506
|
-
|
|
439507
|
-
// packages/learning-loop/src/contradictions.ts
|
|
439508
|
-
import * as z17 from "zod";
|
|
439509
|
-
var ContradictionResultSchema = z17.object({
|
|
439510
|
-
hasContradiction: z17.boolean(),
|
|
439511
|
-
conflicting: z17.array(LearningSchema),
|
|
439512
|
-
merged: LearningSchema.optional(),
|
|
439513
|
-
action: z17.enum(["merge", "flag", "none"])
|
|
439514
|
-
}).strict();
|
|
439515
|
-
function levenshtein(a, b) {
|
|
439516
|
-
const m = a.length;
|
|
439517
|
-
const n = b.length;
|
|
439518
|
-
if (m === 0)
|
|
439519
|
-
return n;
|
|
439520
|
-
if (n === 0)
|
|
439521
|
-
return m;
|
|
439522
|
-
const prev = new Uint32Array(n + 1);
|
|
439523
|
-
const curr = new Uint32Array(n + 1);
|
|
439524
|
-
for (let j = 0;j <= n; j++)
|
|
439525
|
-
prev[j] = j;
|
|
439526
|
-
for (let i = 1;i <= m; i++) {
|
|
439527
|
-
curr[0] = i;
|
|
439528
|
-
const ai = a.charCodeAt(i - 1);
|
|
439529
|
-
for (let j = 1;j <= n; j++) {
|
|
439530
|
-
const cost = ai === b.charCodeAt(j - 1) ? 0 : 1;
|
|
439531
|
-
curr[j] = Math.min(prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + cost);
|
|
439532
|
-
}
|
|
439533
|
-
prev.set(curr);
|
|
439534
|
-
}
|
|
439535
|
-
return prev[n];
|
|
439536
|
-
}
|
|
439537
|
-
function levRatio(a, b) {
|
|
439538
|
-
const maxLen = Math.max(a.length, b.length);
|
|
439539
|
-
if (maxLen === 0)
|
|
439540
|
-
return 1;
|
|
439541
|
-
const dist = levenshtein(a, b);
|
|
439542
|
-
return 1 - dist / maxLen;
|
|
439543
|
-
}
|
|
439544
|
-
function detectContradictions(proposed, existing, options = {}) {
|
|
439545
|
-
const threshold = options.conflictThreshold ?? 0.7;
|
|
439546
|
-
const conflicts = existing.filter((e) => {
|
|
439547
|
-
if (e.target !== proposed.target)
|
|
439548
|
-
return false;
|
|
439549
|
-
return levRatio(proposed.rule, e.rule) < threshold;
|
|
439550
|
-
});
|
|
439551
|
-
if (conflicts.length === 0) {
|
|
439552
|
-
return {
|
|
439553
|
-
hasContradiction: false,
|
|
439554
|
-
conflicting: [],
|
|
439555
|
-
action: "none"
|
|
439556
|
-
};
|
|
439557
|
-
}
|
|
439558
|
-
const maxExistingConfidence = Math.max(...conflicts.map((c) => c.confidence));
|
|
439559
|
-
if (proposed.confidence > maxExistingConfidence) {
|
|
439560
|
-
const confidences = [proposed.confidence, ...conflicts.map((c) => c.confidence)];
|
|
439561
|
-
const avgConfidence = confidences.reduce((sum, c) => sum + c, 0) / confidences.length;
|
|
439562
|
-
const totalOccurrences = proposed.occurrences + conflicts.reduce((sum, c) => sum + c.occurrences, 0);
|
|
439563
|
-
const dates = [new Date(proposed.created_at), ...conflicts.map((c) => new Date(c.created_at))];
|
|
439564
|
-
const earliest = new Date(Math.min(...dates.map((d) => d.getTime())));
|
|
439565
|
-
const merged = {
|
|
439566
|
-
id: proposed.id,
|
|
439567
|
-
target: proposed.target,
|
|
439568
|
-
rule: proposed.rule,
|
|
439569
|
-
rationale: proposed.rationale,
|
|
439570
|
-
occurrences: totalOccurrences,
|
|
439571
|
-
confidence: Math.min(1, Math.max(0, avgConfidence)),
|
|
439572
|
-
created_at: earliest.toISOString()
|
|
439573
|
-
};
|
|
439574
|
-
return {
|
|
439575
|
-
hasContradiction: true,
|
|
439576
|
-
conflicting: conflicts,
|
|
439577
|
-
merged,
|
|
439578
|
-
action: "merge"
|
|
439579
|
-
};
|
|
439580
|
-
}
|
|
439581
|
-
return {
|
|
439582
|
-
hasContradiction: true,
|
|
439583
|
-
conflicting: conflicts,
|
|
439584
|
-
action: "flag"
|
|
439585
|
-
};
|
|
439586
|
-
}
|
|
439587
|
-
|
|
439588
439823
|
// packages/omo-opencode/src/plugin/session-memory-recorder.ts
|
|
439589
439824
|
function createSessionMemoryRecorder(options = {}) {
|
|
439590
439825
|
const store3 = options.memoryStore ?? createMemoryStore();
|
|
@@ -443934,21 +444169,21 @@ init_plugin_identity();
|
|
|
443934
444169
|
init_atomic_write();
|
|
443935
444170
|
init_xdg_data_dir();
|
|
443936
444171
|
import { existsSync as existsSync118, mkdirSync as mkdirSync26, readFileSync as readFileSync80 } from "fs";
|
|
443937
|
-
import { basename as basename26, join as
|
|
444172
|
+
import { basename as basename26, join as join141 } from "path";
|
|
443938
444173
|
var POSTHOG_ACTIVITY_STATE_FILE = "posthog-activity.json";
|
|
443939
444174
|
function resolveTelemetryStateDir(product, options = {}) {
|
|
443940
444175
|
const dataDir = resolveXdgDataDir(product.cacheDirName, {
|
|
443941
444176
|
env: options.env,
|
|
443942
444177
|
osProvider: options.osProvider
|
|
443943
444178
|
});
|
|
443944
|
-
const xdgStateDir = options.env?.XDG_DATA_HOME === undefined ? undefined :
|
|
444179
|
+
const xdgStateDir = options.env?.XDG_DATA_HOME === undefined ? undefined : join141(options.env.XDG_DATA_HOME, product.cacheDirName);
|
|
443945
444180
|
if (dataDir === xdgStateDir || xdgStateDir === undefined && basename26(dataDir) === product.cacheDirName) {
|
|
443946
444181
|
return dataDir;
|
|
443947
444182
|
}
|
|
443948
|
-
return
|
|
444183
|
+
return join141(dataDir, product.cacheDirName);
|
|
443949
444184
|
}
|
|
443950
444185
|
function getTelemetryActivityStateFilePath(stateDir) {
|
|
443951
|
-
return
|
|
444186
|
+
return join141(stateDir, POSTHOG_ACTIVITY_STATE_FILE);
|
|
443952
444187
|
}
|
|
443953
444188
|
function getDailyActiveCaptureState(input2) {
|
|
443954
444189
|
const state3 = readPostHogActivityState(input2.stateDir, input2.diagnostics);
|