@kl-c/matrixos 0.1.3 → 0.1.5
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/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 };
|
|
@@ -301718,7 +301718,13 @@ var AGENT_DISPLAY_NAMES = {
|
|
|
301718
301718
|
link: "link",
|
|
301719
301719
|
ghost: "ghost",
|
|
301720
301720
|
"the-analyst": "the-analyst",
|
|
301721
|
-
"council-member": "council-member"
|
|
301721
|
+
"council-member": "council-member",
|
|
301722
|
+
trinity: "Trinity - Visual Designer",
|
|
301723
|
+
cypher: "Cypher - Copywriter SEO",
|
|
301724
|
+
sentinel: "Sentinel - QA Tester",
|
|
301725
|
+
mouse: "Mouse - Documentation",
|
|
301726
|
+
dreamer: "Dreamer - Memory Consolidation",
|
|
301727
|
+
architect: "TheArchitect - Self Improvement"
|
|
301722
301728
|
};
|
|
301723
301729
|
var INVISIBLE_AGENT_CHARACTERS_REGEX = /[\u200B\u200C\u200D\uFEFF]/g;
|
|
301724
301730
|
var VISIBLE_AGENT_LIST_SORT_PREFIX_REGEX = /^\d+\|/;
|
|
@@ -367926,7 +367932,7 @@ function getCachedVersion(options = {}) {
|
|
|
367926
367932
|
// package.json
|
|
367927
367933
|
var package_default = {
|
|
367928
367934
|
name: "@kl-c/matrixos",
|
|
367929
|
-
version: "0.1.
|
|
367935
|
+
version: "0.1.5",
|
|
367930
367936
|
description: "MaTrixOS \u2014 Agentic OS for OpenCode. Personalizable, communicating, self-improving, resilient.",
|
|
367931
367937
|
main: "./dist/index.js",
|
|
367932
367938
|
types: "dist/index.d.ts",
|
|
@@ -405443,8 +405449,673 @@ function createHooks(args) {
|
|
|
405443
405449
|
}
|
|
405444
405450
|
};
|
|
405445
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
|
+
}
|
|
405446
406117
|
// packages/omo-opencode/src/features/background-agent/manager.ts
|
|
405447
|
-
import { join as
|
|
406118
|
+
import { join as join122 } from "path";
|
|
405448
406119
|
init_tmux();
|
|
405449
406120
|
|
|
405450
406121
|
// packages/omo-opencode/src/features/background-agent/abort-with-timeout.ts
|
|
@@ -405732,8 +406403,8 @@ function writeBackgroundTaskMarker(input) {
|
|
|
405732
406403
|
}
|
|
405733
406404
|
|
|
405734
406405
|
// packages/omo-opencode/src/features/background-agent/compaction-aware-message-resolver.ts
|
|
405735
|
-
import { readdirSync as readdirSync26, readFileSync as
|
|
405736
|
-
import { join as
|
|
406406
|
+
import { readdirSync as readdirSync26, readFileSync as readFileSync68 } from "fs";
|
|
406407
|
+
import { join as join121 } from "path";
|
|
405737
406408
|
function hasFullAgentAndModel(message) {
|
|
405738
406409
|
return !!message.agent && !isCompactionAgent(message.agent) && !!message.model?.providerID && !!message.model?.modelID;
|
|
405739
406410
|
}
|
|
@@ -405812,7 +406483,7 @@ function findNearestMessageExcludingCompaction(messageDir, sessionID) {
|
|
|
405812
406483
|
const messages = [];
|
|
405813
406484
|
for (const file2 of files) {
|
|
405814
406485
|
try {
|
|
405815
|
-
const content =
|
|
406486
|
+
const content = readFileSync68(join121(messageDir, file2), "utf-8");
|
|
405816
406487
|
const parsed = JSON.parse(content);
|
|
405817
406488
|
if (hasCompactionPartInStorage(parsed.id) || isCompactionAgent(parsed.agent)) {
|
|
405818
406489
|
continue;
|
|
@@ -410569,7 +411240,7 @@ The task was re-queued on a fallback model after a retryable failure.
|
|
|
410569
411240
|
parentSessionID: task.parentSessionId
|
|
410570
411241
|
});
|
|
410571
411242
|
}
|
|
410572
|
-
const messageDir =
|
|
411243
|
+
const messageDir = join122(MESSAGE_STORAGE, task.parentSessionId);
|
|
410573
411244
|
const currentMessage = messageDir ? findNearestMessageExcludingCompaction(messageDir, task.parentSessionId) : null;
|
|
410574
411245
|
agent = currentMessage?.agent ?? task.parentAgent;
|
|
410575
411246
|
model = currentMessage?.model?.providerID && currentMessage?.model?.modelID ? { providerID: currentMessage.model.providerID, modelID: currentMessage.model.modelID } : undefined;
|
|
@@ -412190,24 +412861,24 @@ function createMonitorManager(options) {
|
|
|
412190
412861
|
// packages/mcp-client-core/src/mcp-oauth/storage.ts
|
|
412191
412862
|
import { createHash as createHash6 } from "crypto";
|
|
412192
412863
|
import {
|
|
412193
|
-
chmodSync as
|
|
412194
|
-
existsSync as
|
|
412195
|
-
mkdirSync as
|
|
412864
|
+
chmodSync as chmodSync5,
|
|
412865
|
+
existsSync as existsSync106,
|
|
412866
|
+
mkdirSync as mkdirSync22,
|
|
412196
412867
|
readdirSync as readdirSync27,
|
|
412197
|
-
readFileSync as
|
|
412868
|
+
readFileSync as readFileSync70,
|
|
412198
412869
|
renameSync as renameSync9,
|
|
412199
412870
|
unlinkSync as unlinkSync16,
|
|
412200
|
-
writeFileSync as
|
|
412871
|
+
writeFileSync as writeFileSync23
|
|
412201
412872
|
} from "fs";
|
|
412202
|
-
import { basename as basename22, dirname as
|
|
412873
|
+
import { basename as basename22, dirname as dirname42, join as join125 } from "path";
|
|
412203
412874
|
|
|
412204
412875
|
// packages/mcp-client-core/src/config-dir.ts
|
|
412205
|
-
import { existsSync as
|
|
412206
|
-
import { homedir as
|
|
412207
|
-
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";
|
|
412208
412879
|
function resolveConfigPath4(pathValue) {
|
|
412209
412880
|
const resolvedPath = resolve36(pathValue);
|
|
412210
|
-
if (!
|
|
412881
|
+
if (!existsSync104(resolvedPath))
|
|
412211
412882
|
return resolvedPath;
|
|
412212
412883
|
try {
|
|
412213
412884
|
return realpathSync18(resolvedPath);
|
|
@@ -412222,13 +412893,13 @@ function getOpenCodeCliConfigDir(env2 = process.env) {
|
|
|
412222
412893
|
if (customConfigDir) {
|
|
412223
412894
|
return resolveConfigPath4(customConfigDir);
|
|
412224
412895
|
}
|
|
412225
|
-
const xdgConfigDir = env2["XDG_CONFIG_HOME"]?.trim() ||
|
|
412226
|
-
return resolveConfigPath4(
|
|
412896
|
+
const xdgConfigDir = env2["XDG_CONFIG_HOME"]?.trim() || join123(homedir31(), ".config");
|
|
412897
|
+
return resolveConfigPath4(join123(xdgConfigDir, "opencode"));
|
|
412227
412898
|
}
|
|
412228
412899
|
|
|
412229
412900
|
// packages/mcp-client-core/src/mcp-oauth/storage-index.ts
|
|
412230
|
-
import { chmodSync as
|
|
412231
|
-
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";
|
|
412232
412903
|
var INDEX_FILE_NAME = "index.json";
|
|
412233
412904
|
function isTokenIndex(value) {
|
|
412234
412905
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
@@ -412236,14 +412907,14 @@ function isTokenIndex(value) {
|
|
|
412236
412907
|
return Object.values(value).every((entry) => typeof entry === "string");
|
|
412237
412908
|
}
|
|
412238
412909
|
function getIndexPath(storageDir) {
|
|
412239
|
-
return
|
|
412910
|
+
return join124(storageDir, INDEX_FILE_NAME);
|
|
412240
412911
|
}
|
|
412241
412912
|
function readTokenIndex(storageDir) {
|
|
412242
412913
|
const indexPath = getIndexPath(storageDir);
|
|
412243
|
-
if (!
|
|
412914
|
+
if (!existsSync105(indexPath))
|
|
412244
412915
|
return {};
|
|
412245
412916
|
try {
|
|
412246
|
-
const parsed = JSON.parse(
|
|
412917
|
+
const parsed = JSON.parse(readFileSync69(indexPath, "utf-8"));
|
|
412247
412918
|
return isTokenIndex(parsed) ? parsed : {};
|
|
412248
412919
|
} catch (readError) {
|
|
412249
412920
|
if (!(readError instanceof Error))
|
|
@@ -412255,8 +412926,8 @@ function writeTokenIndex(storageDir, index) {
|
|
|
412255
412926
|
try {
|
|
412256
412927
|
const indexPath = getIndexPath(storageDir);
|
|
412257
412928
|
const tempPath = `${indexPath}.tmp.${Date.now()}`;
|
|
412258
|
-
|
|
412259
|
-
|
|
412929
|
+
writeFileSync22(tempPath, JSON.stringify(index, null, 2), { encoding: "utf-8", mode: 384 });
|
|
412930
|
+
chmodSync4(tempPath, 384);
|
|
412260
412931
|
renameSync8(tempPath, indexPath);
|
|
412261
412932
|
return true;
|
|
412262
412933
|
} catch (writeError) {
|
|
@@ -412273,16 +412944,16 @@ function saveTokenIndexEntry(storageDir, hash, key) {
|
|
|
412273
412944
|
var STORAGE_DIR_NAME = "mcp-oauth";
|
|
412274
412945
|
var LEGACY_STORAGE_FILE_NAME = "mcp-oauth.json";
|
|
412275
412946
|
function getMcpOauthStorageDir() {
|
|
412276
|
-
return
|
|
412947
|
+
return join125(getOpenCodeCliConfigDir(), STORAGE_DIR_NAME);
|
|
412277
412948
|
}
|
|
412278
412949
|
function getMcpOauthServerHash(serverHost, resource) {
|
|
412279
412950
|
return createHash6("sha256").update(buildKey(serverHost, resource)).digest("hex").slice(0, 32);
|
|
412280
412951
|
}
|
|
412281
412952
|
function getMcpOauthStoragePath(serverHost, resource) {
|
|
412282
|
-
return
|
|
412953
|
+
return join125(getMcpOauthStorageDir(), `${getMcpOauthServerHash(serverHost, resource)}.json`);
|
|
412283
412954
|
}
|
|
412284
412955
|
function getLegacyStoragePath() {
|
|
412285
|
-
return
|
|
412956
|
+
return join125(getOpenCodeCliConfigDir(), LEGACY_STORAGE_FILE_NAME);
|
|
412286
412957
|
}
|
|
412287
412958
|
function normalizeHost(serverHost) {
|
|
412288
412959
|
let host = serverHost.trim();
|
|
@@ -412343,10 +413014,10 @@ function isOAuthTokenData(value) {
|
|
|
412343
413014
|
return clientSecret === undefined || typeof clientSecret === "string";
|
|
412344
413015
|
}
|
|
412345
413016
|
function readTokenFile(filePath) {
|
|
412346
|
-
if (!
|
|
413017
|
+
if (!existsSync106(filePath))
|
|
412347
413018
|
return null;
|
|
412348
413019
|
try {
|
|
412349
|
-
const parsed = JSON.parse(
|
|
413020
|
+
const parsed = JSON.parse(readFileSync70(filePath, "utf-8"));
|
|
412350
413021
|
return isOAuthTokenData(parsed) ? parsed : null;
|
|
412351
413022
|
} catch (readError) {
|
|
412352
413023
|
if (!(readError instanceof Error))
|
|
@@ -412356,10 +413027,10 @@ function readTokenFile(filePath) {
|
|
|
412356
413027
|
}
|
|
412357
413028
|
function readLegacyStore() {
|
|
412358
413029
|
const filePath = getLegacyStoragePath();
|
|
412359
|
-
if (!
|
|
413030
|
+
if (!existsSync106(filePath))
|
|
412360
413031
|
return null;
|
|
412361
413032
|
try {
|
|
412362
|
-
const parsed = JSON.parse(
|
|
413033
|
+
const parsed = JSON.parse(readFileSync70(filePath, "utf-8"));
|
|
412363
413034
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
412364
413035
|
return null;
|
|
412365
413036
|
const result = {};
|
|
@@ -412376,13 +413047,13 @@ function readLegacyStore() {
|
|
|
412376
413047
|
}
|
|
412377
413048
|
function writeTokenFile(filePath, token) {
|
|
412378
413049
|
try {
|
|
412379
|
-
const dir =
|
|
412380
|
-
if (!
|
|
412381
|
-
|
|
413050
|
+
const dir = dirname42(filePath);
|
|
413051
|
+
if (!existsSync106(dir)) {
|
|
413052
|
+
mkdirSync22(dir, { recursive: true });
|
|
412382
413053
|
}
|
|
412383
413054
|
const tempPath = `${filePath}.tmp.${Date.now()}`;
|
|
412384
|
-
|
|
412385
|
-
|
|
413055
|
+
writeFileSync23(tempPath, JSON.stringify(token, null, 2), { encoding: "utf-8", mode: 384 });
|
|
413056
|
+
chmodSync5(tempPath, 384);
|
|
412386
413057
|
renameSync9(tempPath, filePath);
|
|
412387
413058
|
return true;
|
|
412388
413059
|
} catch (writeError) {
|
|
@@ -413063,63 +413734,63 @@ function getLiteralValue(schema2) {
|
|
|
413063
413734
|
}
|
|
413064
413735
|
|
|
413065
413736
|
// node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
413066
|
-
import * as
|
|
413737
|
+
import * as z9 from "zod/v4";
|
|
413067
413738
|
var LATEST_PROTOCOL_VERSION = "2025-11-25";
|
|
413068
413739
|
var SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-06-18", "2025-03-26", "2024-11-05", "2024-10-07"];
|
|
413069
413740
|
var RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
|
|
413070
413741
|
var JSONRPC_VERSION = "2.0";
|
|
413071
|
-
var AssertObjectSchema =
|
|
413072
|
-
var ProgressTokenSchema =
|
|
413073
|
-
var CursorSchema =
|
|
413074
|
-
var TaskCreationParamsSchema =
|
|
413075
|
-
ttl:
|
|
413076
|
-
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()
|
|
413077
413748
|
});
|
|
413078
|
-
var TaskMetadataSchema =
|
|
413079
|
-
ttl:
|
|
413749
|
+
var TaskMetadataSchema = z9.object({
|
|
413750
|
+
ttl: z9.number().optional()
|
|
413080
413751
|
});
|
|
413081
|
-
var RelatedTaskMetadataSchema =
|
|
413082
|
-
taskId:
|
|
413752
|
+
var RelatedTaskMetadataSchema = z9.object({
|
|
413753
|
+
taskId: z9.string()
|
|
413083
413754
|
});
|
|
413084
|
-
var RequestMetaSchema =
|
|
413755
|
+
var RequestMetaSchema = z9.looseObject({
|
|
413085
413756
|
progressToken: ProgressTokenSchema.optional(),
|
|
413086
413757
|
[RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
|
|
413087
413758
|
});
|
|
413088
|
-
var BaseRequestParamsSchema =
|
|
413759
|
+
var BaseRequestParamsSchema = z9.object({
|
|
413089
413760
|
_meta: RequestMetaSchema.optional()
|
|
413090
413761
|
});
|
|
413091
413762
|
var TaskAugmentedRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
413092
413763
|
task: TaskMetadataSchema.optional()
|
|
413093
413764
|
});
|
|
413094
413765
|
var isTaskAugmentedRequestParams = (value) => TaskAugmentedRequestParamsSchema.safeParse(value).success;
|
|
413095
|
-
var RequestSchema =
|
|
413096
|
-
method:
|
|
413766
|
+
var RequestSchema = z9.object({
|
|
413767
|
+
method: z9.string(),
|
|
413097
413768
|
params: BaseRequestParamsSchema.loose().optional()
|
|
413098
413769
|
});
|
|
413099
|
-
var NotificationsParamsSchema =
|
|
413770
|
+
var NotificationsParamsSchema = z9.object({
|
|
413100
413771
|
_meta: RequestMetaSchema.optional()
|
|
413101
413772
|
});
|
|
413102
|
-
var NotificationSchema =
|
|
413103
|
-
method:
|
|
413773
|
+
var NotificationSchema = z9.object({
|
|
413774
|
+
method: z9.string(),
|
|
413104
413775
|
params: NotificationsParamsSchema.loose().optional()
|
|
413105
413776
|
});
|
|
413106
|
-
var ResultSchema =
|
|
413777
|
+
var ResultSchema = z9.looseObject({
|
|
413107
413778
|
_meta: RequestMetaSchema.optional()
|
|
413108
413779
|
});
|
|
413109
|
-
var RequestIdSchema =
|
|
413110
|
-
var JSONRPCRequestSchema =
|
|
413111
|
-
jsonrpc:
|
|
413780
|
+
var RequestIdSchema = z9.union([z9.string(), z9.number().int()]);
|
|
413781
|
+
var JSONRPCRequestSchema = z9.object({
|
|
413782
|
+
jsonrpc: z9.literal(JSONRPC_VERSION),
|
|
413112
413783
|
id: RequestIdSchema,
|
|
413113
413784
|
...RequestSchema.shape
|
|
413114
413785
|
}).strict();
|
|
413115
413786
|
var isJSONRPCRequest = (value) => JSONRPCRequestSchema.safeParse(value).success;
|
|
413116
|
-
var JSONRPCNotificationSchema =
|
|
413117
|
-
jsonrpc:
|
|
413787
|
+
var JSONRPCNotificationSchema = z9.object({
|
|
413788
|
+
jsonrpc: z9.literal(JSONRPC_VERSION),
|
|
413118
413789
|
...NotificationSchema.shape
|
|
413119
413790
|
}).strict();
|
|
413120
413791
|
var isJSONRPCNotification = (value) => JSONRPCNotificationSchema.safeParse(value).success;
|
|
413121
|
-
var JSONRPCResultResponseSchema =
|
|
413122
|
-
jsonrpc:
|
|
413792
|
+
var JSONRPCResultResponseSchema = z9.object({
|
|
413793
|
+
jsonrpc: z9.literal(JSONRPC_VERSION),
|
|
413123
413794
|
id: RequestIdSchema,
|
|
413124
413795
|
result: ResultSchema
|
|
413125
413796
|
}).strict();
|
|
@@ -413135,153 +413806,153 @@ var ErrorCode;
|
|
|
413135
413806
|
ErrorCode2[ErrorCode2["InternalError"] = -32603] = "InternalError";
|
|
413136
413807
|
ErrorCode2[ErrorCode2["UrlElicitationRequired"] = -32042] = "UrlElicitationRequired";
|
|
413137
413808
|
})(ErrorCode || (ErrorCode = {}));
|
|
413138
|
-
var JSONRPCErrorResponseSchema =
|
|
413139
|
-
jsonrpc:
|
|
413809
|
+
var JSONRPCErrorResponseSchema = z9.object({
|
|
413810
|
+
jsonrpc: z9.literal(JSONRPC_VERSION),
|
|
413140
413811
|
id: RequestIdSchema.optional(),
|
|
413141
|
-
error:
|
|
413142
|
-
code:
|
|
413143
|
-
message:
|
|
413144
|
-
data:
|
|
413812
|
+
error: z9.object({
|
|
413813
|
+
code: z9.number().int(),
|
|
413814
|
+
message: z9.string(),
|
|
413815
|
+
data: z9.unknown().optional()
|
|
413145
413816
|
})
|
|
413146
413817
|
}).strict();
|
|
413147
413818
|
var isJSONRPCErrorResponse = (value) => JSONRPCErrorResponseSchema.safeParse(value).success;
|
|
413148
|
-
var JSONRPCMessageSchema =
|
|
413819
|
+
var JSONRPCMessageSchema = z9.union([
|
|
413149
413820
|
JSONRPCRequestSchema,
|
|
413150
413821
|
JSONRPCNotificationSchema,
|
|
413151
413822
|
JSONRPCResultResponseSchema,
|
|
413152
413823
|
JSONRPCErrorResponseSchema
|
|
413153
413824
|
]);
|
|
413154
|
-
var JSONRPCResponseSchema =
|
|
413825
|
+
var JSONRPCResponseSchema = z9.union([JSONRPCResultResponseSchema, JSONRPCErrorResponseSchema]);
|
|
413155
413826
|
var EmptyResultSchema = ResultSchema.strict();
|
|
413156
413827
|
var CancelledNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
413157
413828
|
requestId: RequestIdSchema.optional(),
|
|
413158
|
-
reason:
|
|
413829
|
+
reason: z9.string().optional()
|
|
413159
413830
|
});
|
|
413160
413831
|
var CancelledNotificationSchema = NotificationSchema.extend({
|
|
413161
|
-
method:
|
|
413832
|
+
method: z9.literal("notifications/cancelled"),
|
|
413162
413833
|
params: CancelledNotificationParamsSchema
|
|
413163
413834
|
});
|
|
413164
|
-
var IconSchema =
|
|
413165
|
-
src:
|
|
413166
|
-
mimeType:
|
|
413167
|
-
sizes:
|
|
413168
|
-
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()
|
|
413169
413840
|
});
|
|
413170
|
-
var IconsSchema =
|
|
413171
|
-
icons:
|
|
413841
|
+
var IconsSchema = z9.object({
|
|
413842
|
+
icons: z9.array(IconSchema).optional()
|
|
413172
413843
|
});
|
|
413173
|
-
var BaseMetadataSchema =
|
|
413174
|
-
name:
|
|
413175
|
-
title:
|
|
413844
|
+
var BaseMetadataSchema = z9.object({
|
|
413845
|
+
name: z9.string(),
|
|
413846
|
+
title: z9.string().optional()
|
|
413176
413847
|
});
|
|
413177
413848
|
var ImplementationSchema = BaseMetadataSchema.extend({
|
|
413178
413849
|
...BaseMetadataSchema.shape,
|
|
413179
413850
|
...IconsSchema.shape,
|
|
413180
|
-
version:
|
|
413181
|
-
websiteUrl:
|
|
413182
|
-
description:
|
|
413183
|
-
});
|
|
413184
|
-
var FormElicitationCapabilitySchema =
|
|
413185
|
-
applyDefaults:
|
|
413186
|
-
}),
|
|
413187
|
-
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) => {
|
|
413188
413859
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
413189
413860
|
if (Object.keys(value).length === 0) {
|
|
413190
413861
|
return { form: {} };
|
|
413191
413862
|
}
|
|
413192
413863
|
}
|
|
413193
413864
|
return value;
|
|
413194
|
-
},
|
|
413865
|
+
}, z9.intersection(z9.object({
|
|
413195
413866
|
form: FormElicitationCapabilitySchema.optional(),
|
|
413196
413867
|
url: AssertObjectSchema.optional()
|
|
413197
|
-
}),
|
|
413198
|
-
var ClientTasksCapabilitySchema =
|
|
413868
|
+
}), z9.record(z9.string(), z9.unknown()).optional()));
|
|
413869
|
+
var ClientTasksCapabilitySchema = z9.looseObject({
|
|
413199
413870
|
list: AssertObjectSchema.optional(),
|
|
413200
413871
|
cancel: AssertObjectSchema.optional(),
|
|
413201
|
-
requests:
|
|
413202
|
-
sampling:
|
|
413872
|
+
requests: z9.looseObject({
|
|
413873
|
+
sampling: z9.looseObject({
|
|
413203
413874
|
createMessage: AssertObjectSchema.optional()
|
|
413204
413875
|
}).optional(),
|
|
413205
|
-
elicitation:
|
|
413876
|
+
elicitation: z9.looseObject({
|
|
413206
413877
|
create: AssertObjectSchema.optional()
|
|
413207
413878
|
}).optional()
|
|
413208
413879
|
}).optional()
|
|
413209
413880
|
});
|
|
413210
|
-
var ServerTasksCapabilitySchema =
|
|
413881
|
+
var ServerTasksCapabilitySchema = z9.looseObject({
|
|
413211
413882
|
list: AssertObjectSchema.optional(),
|
|
413212
413883
|
cancel: AssertObjectSchema.optional(),
|
|
413213
|
-
requests:
|
|
413214
|
-
tools:
|
|
413884
|
+
requests: z9.looseObject({
|
|
413885
|
+
tools: z9.looseObject({
|
|
413215
413886
|
call: AssertObjectSchema.optional()
|
|
413216
413887
|
}).optional()
|
|
413217
413888
|
}).optional()
|
|
413218
413889
|
});
|
|
413219
|
-
var ClientCapabilitiesSchema =
|
|
413220
|
-
experimental:
|
|
413221
|
-
sampling:
|
|
413890
|
+
var ClientCapabilitiesSchema = z9.object({
|
|
413891
|
+
experimental: z9.record(z9.string(), AssertObjectSchema).optional(),
|
|
413892
|
+
sampling: z9.object({
|
|
413222
413893
|
context: AssertObjectSchema.optional(),
|
|
413223
413894
|
tools: AssertObjectSchema.optional()
|
|
413224
413895
|
}).optional(),
|
|
413225
413896
|
elicitation: ElicitationCapabilitySchema.optional(),
|
|
413226
|
-
roots:
|
|
413227
|
-
listChanged:
|
|
413897
|
+
roots: z9.object({
|
|
413898
|
+
listChanged: z9.boolean().optional()
|
|
413228
413899
|
}).optional(),
|
|
413229
413900
|
tasks: ClientTasksCapabilitySchema.optional(),
|
|
413230
|
-
extensions:
|
|
413901
|
+
extensions: z9.record(z9.string(), AssertObjectSchema).optional()
|
|
413231
413902
|
});
|
|
413232
413903
|
var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
413233
|
-
protocolVersion:
|
|
413904
|
+
protocolVersion: z9.string(),
|
|
413234
413905
|
capabilities: ClientCapabilitiesSchema,
|
|
413235
413906
|
clientInfo: ImplementationSchema
|
|
413236
413907
|
});
|
|
413237
413908
|
var InitializeRequestSchema = RequestSchema.extend({
|
|
413238
|
-
method:
|
|
413909
|
+
method: z9.literal("initialize"),
|
|
413239
413910
|
params: InitializeRequestParamsSchema
|
|
413240
413911
|
});
|
|
413241
|
-
var ServerCapabilitiesSchema =
|
|
413242
|
-
experimental:
|
|
413912
|
+
var ServerCapabilitiesSchema = z9.object({
|
|
413913
|
+
experimental: z9.record(z9.string(), AssertObjectSchema).optional(),
|
|
413243
413914
|
logging: AssertObjectSchema.optional(),
|
|
413244
413915
|
completions: AssertObjectSchema.optional(),
|
|
413245
|
-
prompts:
|
|
413246
|
-
listChanged:
|
|
413916
|
+
prompts: z9.object({
|
|
413917
|
+
listChanged: z9.boolean().optional()
|
|
413247
413918
|
}).optional(),
|
|
413248
|
-
resources:
|
|
413249
|
-
subscribe:
|
|
413250
|
-
listChanged:
|
|
413919
|
+
resources: z9.object({
|
|
413920
|
+
subscribe: z9.boolean().optional(),
|
|
413921
|
+
listChanged: z9.boolean().optional()
|
|
413251
413922
|
}).optional(),
|
|
413252
|
-
tools:
|
|
413253
|
-
listChanged:
|
|
413923
|
+
tools: z9.object({
|
|
413924
|
+
listChanged: z9.boolean().optional()
|
|
413254
413925
|
}).optional(),
|
|
413255
413926
|
tasks: ServerTasksCapabilitySchema.optional(),
|
|
413256
|
-
extensions:
|
|
413927
|
+
extensions: z9.record(z9.string(), AssertObjectSchema).optional()
|
|
413257
413928
|
});
|
|
413258
413929
|
var InitializeResultSchema = ResultSchema.extend({
|
|
413259
|
-
protocolVersion:
|
|
413930
|
+
protocolVersion: z9.string(),
|
|
413260
413931
|
capabilities: ServerCapabilitiesSchema,
|
|
413261
413932
|
serverInfo: ImplementationSchema,
|
|
413262
|
-
instructions:
|
|
413933
|
+
instructions: z9.string().optional()
|
|
413263
413934
|
});
|
|
413264
413935
|
var InitializedNotificationSchema = NotificationSchema.extend({
|
|
413265
|
-
method:
|
|
413936
|
+
method: z9.literal("notifications/initialized"),
|
|
413266
413937
|
params: NotificationsParamsSchema.optional()
|
|
413267
413938
|
});
|
|
413268
413939
|
var isInitializedNotification = (value) => InitializedNotificationSchema.safeParse(value).success;
|
|
413269
413940
|
var PingRequestSchema = RequestSchema.extend({
|
|
413270
|
-
method:
|
|
413941
|
+
method: z9.literal("ping"),
|
|
413271
413942
|
params: BaseRequestParamsSchema.optional()
|
|
413272
413943
|
});
|
|
413273
|
-
var ProgressSchema =
|
|
413274
|
-
progress:
|
|
413275
|
-
total:
|
|
413276
|
-
message:
|
|
413944
|
+
var ProgressSchema = z9.object({
|
|
413945
|
+
progress: z9.number(),
|
|
413946
|
+
total: z9.optional(z9.number()),
|
|
413947
|
+
message: z9.optional(z9.string())
|
|
413277
413948
|
});
|
|
413278
|
-
var ProgressNotificationParamsSchema =
|
|
413949
|
+
var ProgressNotificationParamsSchema = z9.object({
|
|
413279
413950
|
...NotificationsParamsSchema.shape,
|
|
413280
413951
|
...ProgressSchema.shape,
|
|
413281
413952
|
progressToken: ProgressTokenSchema
|
|
413282
413953
|
});
|
|
413283
413954
|
var ProgressNotificationSchema = NotificationSchema.extend({
|
|
413284
|
-
method:
|
|
413955
|
+
method: z9.literal("notifications/progress"),
|
|
413285
413956
|
params: ProgressNotificationParamsSchema
|
|
413286
413957
|
});
|
|
413287
413958
|
var PaginatedRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
@@ -413293,60 +413964,60 @@ var PaginatedRequestSchema = RequestSchema.extend({
|
|
|
413293
413964
|
var PaginatedResultSchema = ResultSchema.extend({
|
|
413294
413965
|
nextCursor: CursorSchema.optional()
|
|
413295
413966
|
});
|
|
413296
|
-
var TaskStatusSchema2 =
|
|
413297
|
-
var TaskSchema2 =
|
|
413298
|
-
taskId:
|
|
413967
|
+
var TaskStatusSchema2 = z9.enum(["working", "input_required", "completed", "failed", "cancelled"]);
|
|
413968
|
+
var TaskSchema2 = z9.object({
|
|
413969
|
+
taskId: z9.string(),
|
|
413299
413970
|
status: TaskStatusSchema2,
|
|
413300
|
-
ttl:
|
|
413301
|
-
createdAt:
|
|
413302
|
-
lastUpdatedAt:
|
|
413303
|
-
pollInterval:
|
|
413304
|
-
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())
|
|
413305
413976
|
});
|
|
413306
413977
|
var CreateTaskResultSchema = ResultSchema.extend({
|
|
413307
413978
|
task: TaskSchema2
|
|
413308
413979
|
});
|
|
413309
413980
|
var TaskStatusNotificationParamsSchema = NotificationsParamsSchema.merge(TaskSchema2);
|
|
413310
413981
|
var TaskStatusNotificationSchema = NotificationSchema.extend({
|
|
413311
|
-
method:
|
|
413982
|
+
method: z9.literal("notifications/tasks/status"),
|
|
413312
413983
|
params: TaskStatusNotificationParamsSchema
|
|
413313
413984
|
});
|
|
413314
413985
|
var GetTaskRequestSchema = RequestSchema.extend({
|
|
413315
|
-
method:
|
|
413986
|
+
method: z9.literal("tasks/get"),
|
|
413316
413987
|
params: BaseRequestParamsSchema.extend({
|
|
413317
|
-
taskId:
|
|
413988
|
+
taskId: z9.string()
|
|
413318
413989
|
})
|
|
413319
413990
|
});
|
|
413320
413991
|
var GetTaskResultSchema = ResultSchema.merge(TaskSchema2);
|
|
413321
413992
|
var GetTaskPayloadRequestSchema = RequestSchema.extend({
|
|
413322
|
-
method:
|
|
413993
|
+
method: z9.literal("tasks/result"),
|
|
413323
413994
|
params: BaseRequestParamsSchema.extend({
|
|
413324
|
-
taskId:
|
|
413995
|
+
taskId: z9.string()
|
|
413325
413996
|
})
|
|
413326
413997
|
});
|
|
413327
413998
|
var GetTaskPayloadResultSchema = ResultSchema.loose();
|
|
413328
413999
|
var ListTasksRequestSchema = PaginatedRequestSchema.extend({
|
|
413329
|
-
method:
|
|
414000
|
+
method: z9.literal("tasks/list")
|
|
413330
414001
|
});
|
|
413331
414002
|
var ListTasksResultSchema = PaginatedResultSchema.extend({
|
|
413332
|
-
tasks:
|
|
414003
|
+
tasks: z9.array(TaskSchema2)
|
|
413333
414004
|
});
|
|
413334
414005
|
var CancelTaskRequestSchema = RequestSchema.extend({
|
|
413335
|
-
method:
|
|
414006
|
+
method: z9.literal("tasks/cancel"),
|
|
413336
414007
|
params: BaseRequestParamsSchema.extend({
|
|
413337
|
-
taskId:
|
|
414008
|
+
taskId: z9.string()
|
|
413338
414009
|
})
|
|
413339
414010
|
});
|
|
413340
414011
|
var CancelTaskResultSchema = ResultSchema.merge(TaskSchema2);
|
|
413341
|
-
var ResourceContentsSchema =
|
|
413342
|
-
uri:
|
|
413343
|
-
mimeType:
|
|
413344
|
-
_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()
|
|
413345
414016
|
});
|
|
413346
414017
|
var TextResourceContentsSchema = ResourceContentsSchema.extend({
|
|
413347
|
-
text:
|
|
414018
|
+
text: z9.string()
|
|
413348
414019
|
});
|
|
413349
|
-
var Base64Schema =
|
|
414020
|
+
var Base64Schema = z9.string().refine((val) => {
|
|
413350
414021
|
try {
|
|
413351
414022
|
atob(val);
|
|
413352
414023
|
return true;
|
|
@@ -413357,447 +414028,447 @@ var Base64Schema = z7.string().refine((val) => {
|
|
|
413357
414028
|
var BlobResourceContentsSchema = ResourceContentsSchema.extend({
|
|
413358
414029
|
blob: Base64Schema
|
|
413359
414030
|
});
|
|
413360
|
-
var RoleSchema =
|
|
413361
|
-
var AnnotationsSchema =
|
|
413362
|
-
audience:
|
|
413363
|
-
priority:
|
|
413364
|
-
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()
|
|
413365
414036
|
});
|
|
413366
|
-
var ResourceSchema =
|
|
414037
|
+
var ResourceSchema = z9.object({
|
|
413367
414038
|
...BaseMetadataSchema.shape,
|
|
413368
414039
|
...IconsSchema.shape,
|
|
413369
|
-
uri:
|
|
413370
|
-
description:
|
|
413371
|
-
mimeType:
|
|
413372
|
-
size:
|
|
414040
|
+
uri: z9.string(),
|
|
414041
|
+
description: z9.optional(z9.string()),
|
|
414042
|
+
mimeType: z9.optional(z9.string()),
|
|
414043
|
+
size: z9.optional(z9.number()),
|
|
413373
414044
|
annotations: AnnotationsSchema.optional(),
|
|
413374
|
-
_meta:
|
|
414045
|
+
_meta: z9.optional(z9.looseObject({}))
|
|
413375
414046
|
});
|
|
413376
|
-
var ResourceTemplateSchema =
|
|
414047
|
+
var ResourceTemplateSchema = z9.object({
|
|
413377
414048
|
...BaseMetadataSchema.shape,
|
|
413378
414049
|
...IconsSchema.shape,
|
|
413379
|
-
uriTemplate:
|
|
413380
|
-
description:
|
|
413381
|
-
mimeType:
|
|
414050
|
+
uriTemplate: z9.string(),
|
|
414051
|
+
description: z9.optional(z9.string()),
|
|
414052
|
+
mimeType: z9.optional(z9.string()),
|
|
413382
414053
|
annotations: AnnotationsSchema.optional(),
|
|
413383
|
-
_meta:
|
|
414054
|
+
_meta: z9.optional(z9.looseObject({}))
|
|
413384
414055
|
});
|
|
413385
414056
|
var ListResourcesRequestSchema = PaginatedRequestSchema.extend({
|
|
413386
|
-
method:
|
|
414057
|
+
method: z9.literal("resources/list")
|
|
413387
414058
|
});
|
|
413388
414059
|
var ListResourcesResultSchema = PaginatedResultSchema.extend({
|
|
413389
|
-
resources:
|
|
414060
|
+
resources: z9.array(ResourceSchema)
|
|
413390
414061
|
});
|
|
413391
414062
|
var ListResourceTemplatesRequestSchema = PaginatedRequestSchema.extend({
|
|
413392
|
-
method:
|
|
414063
|
+
method: z9.literal("resources/templates/list")
|
|
413393
414064
|
});
|
|
413394
414065
|
var ListResourceTemplatesResultSchema = PaginatedResultSchema.extend({
|
|
413395
|
-
resourceTemplates:
|
|
414066
|
+
resourceTemplates: z9.array(ResourceTemplateSchema)
|
|
413396
414067
|
});
|
|
413397
414068
|
var ResourceRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
413398
|
-
uri:
|
|
414069
|
+
uri: z9.string()
|
|
413399
414070
|
});
|
|
413400
414071
|
var ReadResourceRequestParamsSchema = ResourceRequestParamsSchema;
|
|
413401
414072
|
var ReadResourceRequestSchema = RequestSchema.extend({
|
|
413402
|
-
method:
|
|
414073
|
+
method: z9.literal("resources/read"),
|
|
413403
414074
|
params: ReadResourceRequestParamsSchema
|
|
413404
414075
|
});
|
|
413405
414076
|
var ReadResourceResultSchema = ResultSchema.extend({
|
|
413406
|
-
contents:
|
|
414077
|
+
contents: z9.array(z9.union([TextResourceContentsSchema, BlobResourceContentsSchema]))
|
|
413407
414078
|
});
|
|
413408
414079
|
var ResourceListChangedNotificationSchema = NotificationSchema.extend({
|
|
413409
|
-
method:
|
|
414080
|
+
method: z9.literal("notifications/resources/list_changed"),
|
|
413410
414081
|
params: NotificationsParamsSchema.optional()
|
|
413411
414082
|
});
|
|
413412
414083
|
var SubscribeRequestParamsSchema = ResourceRequestParamsSchema;
|
|
413413
414084
|
var SubscribeRequestSchema = RequestSchema.extend({
|
|
413414
|
-
method:
|
|
414085
|
+
method: z9.literal("resources/subscribe"),
|
|
413415
414086
|
params: SubscribeRequestParamsSchema
|
|
413416
414087
|
});
|
|
413417
414088
|
var UnsubscribeRequestParamsSchema = ResourceRequestParamsSchema;
|
|
413418
414089
|
var UnsubscribeRequestSchema = RequestSchema.extend({
|
|
413419
|
-
method:
|
|
414090
|
+
method: z9.literal("resources/unsubscribe"),
|
|
413420
414091
|
params: UnsubscribeRequestParamsSchema
|
|
413421
414092
|
});
|
|
413422
414093
|
var ResourceUpdatedNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
413423
|
-
uri:
|
|
414094
|
+
uri: z9.string()
|
|
413424
414095
|
});
|
|
413425
414096
|
var ResourceUpdatedNotificationSchema = NotificationSchema.extend({
|
|
413426
|
-
method:
|
|
414097
|
+
method: z9.literal("notifications/resources/updated"),
|
|
413427
414098
|
params: ResourceUpdatedNotificationParamsSchema
|
|
413428
414099
|
});
|
|
413429
|
-
var PromptArgumentSchema =
|
|
413430
|
-
name:
|
|
413431
|
-
description:
|
|
413432
|
-
required:
|
|
414100
|
+
var PromptArgumentSchema = z9.object({
|
|
414101
|
+
name: z9.string(),
|
|
414102
|
+
description: z9.optional(z9.string()),
|
|
414103
|
+
required: z9.optional(z9.boolean())
|
|
413433
414104
|
});
|
|
413434
|
-
var PromptSchema =
|
|
414105
|
+
var PromptSchema = z9.object({
|
|
413435
414106
|
...BaseMetadataSchema.shape,
|
|
413436
414107
|
...IconsSchema.shape,
|
|
413437
|
-
description:
|
|
413438
|
-
arguments:
|
|
413439
|
-
_meta:
|
|
414108
|
+
description: z9.optional(z9.string()),
|
|
414109
|
+
arguments: z9.optional(z9.array(PromptArgumentSchema)),
|
|
414110
|
+
_meta: z9.optional(z9.looseObject({}))
|
|
413440
414111
|
});
|
|
413441
414112
|
var ListPromptsRequestSchema = PaginatedRequestSchema.extend({
|
|
413442
|
-
method:
|
|
414113
|
+
method: z9.literal("prompts/list")
|
|
413443
414114
|
});
|
|
413444
414115
|
var ListPromptsResultSchema = PaginatedResultSchema.extend({
|
|
413445
|
-
prompts:
|
|
414116
|
+
prompts: z9.array(PromptSchema)
|
|
413446
414117
|
});
|
|
413447
414118
|
var GetPromptRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
413448
|
-
name:
|
|
413449
|
-
arguments:
|
|
414119
|
+
name: z9.string(),
|
|
414120
|
+
arguments: z9.record(z9.string(), z9.string()).optional()
|
|
413450
414121
|
});
|
|
413451
414122
|
var GetPromptRequestSchema = RequestSchema.extend({
|
|
413452
|
-
method:
|
|
414123
|
+
method: z9.literal("prompts/get"),
|
|
413453
414124
|
params: GetPromptRequestParamsSchema
|
|
413454
414125
|
});
|
|
413455
|
-
var TextContentSchema =
|
|
413456
|
-
type:
|
|
413457
|
-
text:
|
|
414126
|
+
var TextContentSchema = z9.object({
|
|
414127
|
+
type: z9.literal("text"),
|
|
414128
|
+
text: z9.string(),
|
|
413458
414129
|
annotations: AnnotationsSchema.optional(),
|
|
413459
|
-
_meta:
|
|
414130
|
+
_meta: z9.record(z9.string(), z9.unknown()).optional()
|
|
413460
414131
|
});
|
|
413461
|
-
var ImageContentSchema =
|
|
413462
|
-
type:
|
|
414132
|
+
var ImageContentSchema = z9.object({
|
|
414133
|
+
type: z9.literal("image"),
|
|
413463
414134
|
data: Base64Schema,
|
|
413464
|
-
mimeType:
|
|
414135
|
+
mimeType: z9.string(),
|
|
413465
414136
|
annotations: AnnotationsSchema.optional(),
|
|
413466
|
-
_meta:
|
|
414137
|
+
_meta: z9.record(z9.string(), z9.unknown()).optional()
|
|
413467
414138
|
});
|
|
413468
|
-
var AudioContentSchema =
|
|
413469
|
-
type:
|
|
414139
|
+
var AudioContentSchema = z9.object({
|
|
414140
|
+
type: z9.literal("audio"),
|
|
413470
414141
|
data: Base64Schema,
|
|
413471
|
-
mimeType:
|
|
414142
|
+
mimeType: z9.string(),
|
|
413472
414143
|
annotations: AnnotationsSchema.optional(),
|
|
413473
|
-
_meta:
|
|
413474
|
-
});
|
|
413475
|
-
var ToolUseContentSchema =
|
|
413476
|
-
type:
|
|
413477
|
-
name:
|
|
413478
|
-
id:
|
|
413479
|
-
input:
|
|
413480
|
-
_meta:
|
|
413481
|
-
});
|
|
413482
|
-
var EmbeddedResourceSchema =
|
|
413483
|
-
type:
|
|
413484
|
-
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]),
|
|
413485
414156
|
annotations: AnnotationsSchema.optional(),
|
|
413486
|
-
_meta:
|
|
414157
|
+
_meta: z9.record(z9.string(), z9.unknown()).optional()
|
|
413487
414158
|
});
|
|
413488
414159
|
var ResourceLinkSchema = ResourceSchema.extend({
|
|
413489
|
-
type:
|
|
414160
|
+
type: z9.literal("resource_link")
|
|
413490
414161
|
});
|
|
413491
|
-
var ContentBlockSchema =
|
|
414162
|
+
var ContentBlockSchema = z9.union([
|
|
413492
414163
|
TextContentSchema,
|
|
413493
414164
|
ImageContentSchema,
|
|
413494
414165
|
AudioContentSchema,
|
|
413495
414166
|
ResourceLinkSchema,
|
|
413496
414167
|
EmbeddedResourceSchema
|
|
413497
414168
|
]);
|
|
413498
|
-
var PromptMessageSchema =
|
|
414169
|
+
var PromptMessageSchema = z9.object({
|
|
413499
414170
|
role: RoleSchema,
|
|
413500
414171
|
content: ContentBlockSchema
|
|
413501
414172
|
});
|
|
413502
414173
|
var GetPromptResultSchema = ResultSchema.extend({
|
|
413503
|
-
description:
|
|
413504
|
-
messages:
|
|
414174
|
+
description: z9.string().optional(),
|
|
414175
|
+
messages: z9.array(PromptMessageSchema)
|
|
413505
414176
|
});
|
|
413506
414177
|
var PromptListChangedNotificationSchema = NotificationSchema.extend({
|
|
413507
|
-
method:
|
|
414178
|
+
method: z9.literal("notifications/prompts/list_changed"),
|
|
413508
414179
|
params: NotificationsParamsSchema.optional()
|
|
413509
414180
|
});
|
|
413510
|
-
var ToolAnnotationsSchema =
|
|
413511
|
-
title:
|
|
413512
|
-
readOnlyHint:
|
|
413513
|
-
destructiveHint:
|
|
413514
|
-
idempotentHint:
|
|
413515
|
-
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()
|
|
413516
414187
|
});
|
|
413517
|
-
var ToolExecutionSchema =
|
|
413518
|
-
taskSupport:
|
|
414188
|
+
var ToolExecutionSchema = z9.object({
|
|
414189
|
+
taskSupport: z9.enum(["required", "optional", "forbidden"]).optional()
|
|
413519
414190
|
});
|
|
413520
|
-
var ToolSchema =
|
|
414191
|
+
var ToolSchema = z9.object({
|
|
413521
414192
|
...BaseMetadataSchema.shape,
|
|
413522
414193
|
...IconsSchema.shape,
|
|
413523
|
-
description:
|
|
413524
|
-
inputSchema:
|
|
413525
|
-
type:
|
|
413526
|
-
properties:
|
|
413527
|
-
required:
|
|
413528
|
-
}).catchall(
|
|
413529
|
-
outputSchema:
|
|
413530
|
-
type:
|
|
413531
|
-
properties:
|
|
413532
|
-
required:
|
|
413533
|
-
}).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(),
|
|
413534
414205
|
annotations: ToolAnnotationsSchema.optional(),
|
|
413535
414206
|
execution: ToolExecutionSchema.optional(),
|
|
413536
|
-
_meta:
|
|
414207
|
+
_meta: z9.record(z9.string(), z9.unknown()).optional()
|
|
413537
414208
|
});
|
|
413538
414209
|
var ListToolsRequestSchema = PaginatedRequestSchema.extend({
|
|
413539
|
-
method:
|
|
414210
|
+
method: z9.literal("tools/list")
|
|
413540
414211
|
});
|
|
413541
414212
|
var ListToolsResultSchema = PaginatedResultSchema.extend({
|
|
413542
|
-
tools:
|
|
414213
|
+
tools: z9.array(ToolSchema)
|
|
413543
414214
|
});
|
|
413544
414215
|
var CallToolResultSchema = ResultSchema.extend({
|
|
413545
|
-
content:
|
|
413546
|
-
structuredContent:
|
|
413547
|
-
isError:
|
|
414216
|
+
content: z9.array(ContentBlockSchema).default([]),
|
|
414217
|
+
structuredContent: z9.record(z9.string(), z9.unknown()).optional(),
|
|
414218
|
+
isError: z9.boolean().optional()
|
|
413548
414219
|
});
|
|
413549
414220
|
var CompatibilityCallToolResultSchema = CallToolResultSchema.or(ResultSchema.extend({
|
|
413550
|
-
toolResult:
|
|
414221
|
+
toolResult: z9.unknown()
|
|
413551
414222
|
}));
|
|
413552
414223
|
var CallToolRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
413553
|
-
name:
|
|
413554
|
-
arguments:
|
|
414224
|
+
name: z9.string(),
|
|
414225
|
+
arguments: z9.record(z9.string(), z9.unknown()).optional()
|
|
413555
414226
|
});
|
|
413556
414227
|
var CallToolRequestSchema = RequestSchema.extend({
|
|
413557
|
-
method:
|
|
414228
|
+
method: z9.literal("tools/call"),
|
|
413558
414229
|
params: CallToolRequestParamsSchema
|
|
413559
414230
|
});
|
|
413560
414231
|
var ToolListChangedNotificationSchema = NotificationSchema.extend({
|
|
413561
|
-
method:
|
|
414232
|
+
method: z9.literal("notifications/tools/list_changed"),
|
|
413562
414233
|
params: NotificationsParamsSchema.optional()
|
|
413563
414234
|
});
|
|
413564
|
-
var ListChangedOptionsBaseSchema =
|
|
413565
|
-
autoRefresh:
|
|
413566
|
-
debounceMs:
|
|
414235
|
+
var ListChangedOptionsBaseSchema = z9.object({
|
|
414236
|
+
autoRefresh: z9.boolean().default(true),
|
|
414237
|
+
debounceMs: z9.number().int().nonnegative().default(300)
|
|
413567
414238
|
});
|
|
413568
|
-
var LoggingLevelSchema =
|
|
414239
|
+
var LoggingLevelSchema = z9.enum(["debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"]);
|
|
413569
414240
|
var SetLevelRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
413570
414241
|
level: LoggingLevelSchema
|
|
413571
414242
|
});
|
|
413572
414243
|
var SetLevelRequestSchema = RequestSchema.extend({
|
|
413573
|
-
method:
|
|
414244
|
+
method: z9.literal("logging/setLevel"),
|
|
413574
414245
|
params: SetLevelRequestParamsSchema
|
|
413575
414246
|
});
|
|
413576
414247
|
var LoggingMessageNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
413577
414248
|
level: LoggingLevelSchema,
|
|
413578
|
-
logger:
|
|
413579
|
-
data:
|
|
414249
|
+
logger: z9.string().optional(),
|
|
414250
|
+
data: z9.unknown()
|
|
413580
414251
|
});
|
|
413581
414252
|
var LoggingMessageNotificationSchema = NotificationSchema.extend({
|
|
413582
|
-
method:
|
|
414253
|
+
method: z9.literal("notifications/message"),
|
|
413583
414254
|
params: LoggingMessageNotificationParamsSchema
|
|
413584
414255
|
});
|
|
413585
|
-
var ModelHintSchema =
|
|
413586
|
-
name:
|
|
414256
|
+
var ModelHintSchema = z9.object({
|
|
414257
|
+
name: z9.string().optional()
|
|
413587
414258
|
});
|
|
413588
|
-
var ModelPreferencesSchema =
|
|
413589
|
-
hints:
|
|
413590
|
-
costPriority:
|
|
413591
|
-
speedPriority:
|
|
413592
|
-
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()
|
|
413593
414264
|
});
|
|
413594
|
-
var ToolChoiceSchema =
|
|
413595
|
-
mode:
|
|
414265
|
+
var ToolChoiceSchema = z9.object({
|
|
414266
|
+
mode: z9.enum(["auto", "required", "none"]).optional()
|
|
413596
414267
|
});
|
|
413597
|
-
var ToolResultContentSchema =
|
|
413598
|
-
type:
|
|
413599
|
-
toolUseId:
|
|
413600
|
-
content:
|
|
413601
|
-
structuredContent:
|
|
413602
|
-
isError:
|
|
413603
|
-
_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()
|
|
413604
414275
|
});
|
|
413605
|
-
var SamplingContentSchema =
|
|
413606
|
-
var SamplingMessageContentBlockSchema =
|
|
414276
|
+
var SamplingContentSchema = z9.discriminatedUnion("type", [TextContentSchema, ImageContentSchema, AudioContentSchema]);
|
|
414277
|
+
var SamplingMessageContentBlockSchema = z9.discriminatedUnion("type", [
|
|
413607
414278
|
TextContentSchema,
|
|
413608
414279
|
ImageContentSchema,
|
|
413609
414280
|
AudioContentSchema,
|
|
413610
414281
|
ToolUseContentSchema,
|
|
413611
414282
|
ToolResultContentSchema
|
|
413612
414283
|
]);
|
|
413613
|
-
var SamplingMessageSchema =
|
|
414284
|
+
var SamplingMessageSchema = z9.object({
|
|
413614
414285
|
role: RoleSchema,
|
|
413615
|
-
content:
|
|
413616
|
-
_meta:
|
|
414286
|
+
content: z9.union([SamplingMessageContentBlockSchema, z9.array(SamplingMessageContentBlockSchema)]),
|
|
414287
|
+
_meta: z9.record(z9.string(), z9.unknown()).optional()
|
|
413617
414288
|
});
|
|
413618
414289
|
var CreateMessageRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
413619
|
-
messages:
|
|
414290
|
+
messages: z9.array(SamplingMessageSchema),
|
|
413620
414291
|
modelPreferences: ModelPreferencesSchema.optional(),
|
|
413621
|
-
systemPrompt:
|
|
413622
|
-
includeContext:
|
|
413623
|
-
temperature:
|
|
413624
|
-
maxTokens:
|
|
413625
|
-
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(),
|
|
413626
414297
|
metadata: AssertObjectSchema.optional(),
|
|
413627
|
-
tools:
|
|
414298
|
+
tools: z9.array(ToolSchema).optional(),
|
|
413628
414299
|
toolChoice: ToolChoiceSchema.optional()
|
|
413629
414300
|
});
|
|
413630
414301
|
var CreateMessageRequestSchema = RequestSchema.extend({
|
|
413631
|
-
method:
|
|
414302
|
+
method: z9.literal("sampling/createMessage"),
|
|
413632
414303
|
params: CreateMessageRequestParamsSchema
|
|
413633
414304
|
});
|
|
413634
414305
|
var CreateMessageResultSchema = ResultSchema.extend({
|
|
413635
|
-
model:
|
|
413636
|
-
stopReason:
|
|
414306
|
+
model: z9.string(),
|
|
414307
|
+
stopReason: z9.optional(z9.enum(["endTurn", "stopSequence", "maxTokens"]).or(z9.string())),
|
|
413637
414308
|
role: RoleSchema,
|
|
413638
414309
|
content: SamplingContentSchema
|
|
413639
414310
|
});
|
|
413640
414311
|
var CreateMessageResultWithToolsSchema = ResultSchema.extend({
|
|
413641
|
-
model:
|
|
413642
|
-
stopReason:
|
|
414312
|
+
model: z9.string(),
|
|
414313
|
+
stopReason: z9.optional(z9.enum(["endTurn", "stopSequence", "maxTokens", "toolUse"]).or(z9.string())),
|
|
413643
414314
|
role: RoleSchema,
|
|
413644
|
-
content:
|
|
413645
|
-
});
|
|
413646
|
-
var BooleanSchemaSchema =
|
|
413647
|
-
type:
|
|
413648
|
-
title:
|
|
413649
|
-
description:
|
|
413650
|
-
default:
|
|
413651
|
-
});
|
|
413652
|
-
var StringSchemaSchema =
|
|
413653
|
-
type:
|
|
413654
|
-
title:
|
|
413655
|
-
description:
|
|
413656
|
-
minLength:
|
|
413657
|
-
maxLength:
|
|
413658
|
-
format:
|
|
413659
|
-
default:
|
|
413660
|
-
});
|
|
413661
|
-
var NumberSchemaSchema =
|
|
413662
|
-
type:
|
|
413663
|
-
title:
|
|
413664
|
-
description:
|
|
413665
|
-
minimum:
|
|
413666
|
-
maximum:
|
|
413667
|
-
default:
|
|
413668
|
-
});
|
|
413669
|
-
var UntitledSingleSelectEnumSchemaSchema =
|
|
413670
|
-
type:
|
|
413671
|
-
title:
|
|
413672
|
-
description:
|
|
413673
|
-
enum:
|
|
413674
|
-
default:
|
|
413675
|
-
});
|
|
413676
|
-
var TitledSingleSelectEnumSchemaSchema =
|
|
413677
|
-
type:
|
|
413678
|
-
title:
|
|
413679
|
-
description:
|
|
413680
|
-
oneOf:
|
|
413681
|
-
const:
|
|
413682
|
-
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()
|
|
413683
414354
|
})),
|
|
413684
|
-
default:
|
|
413685
|
-
});
|
|
413686
|
-
var LegacyTitledEnumSchemaSchema =
|
|
413687
|
-
type:
|
|
413688
|
-
title:
|
|
413689
|
-
description:
|
|
413690
|
-
enum:
|
|
413691
|
-
enumNames:
|
|
413692
|
-
default:
|
|
413693
|
-
});
|
|
413694
|
-
var SingleSelectEnumSchemaSchema =
|
|
413695
|
-
var UntitledMultiSelectEnumSchemaSchema =
|
|
413696
|
-
type:
|
|
413697
|
-
title:
|
|
413698
|
-
description:
|
|
413699
|
-
minItems:
|
|
413700
|
-
maxItems:
|
|
413701
|
-
items:
|
|
413702
|
-
type:
|
|
413703
|
-
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())
|
|
413704
414375
|
}),
|
|
413705
|
-
default:
|
|
413706
|
-
});
|
|
413707
|
-
var TitledMultiSelectEnumSchemaSchema =
|
|
413708
|
-
type:
|
|
413709
|
-
title:
|
|
413710
|
-
description:
|
|
413711
|
-
minItems:
|
|
413712
|
-
maxItems:
|
|
413713
|
-
items:
|
|
413714
|
-
anyOf:
|
|
413715
|
-
const:
|
|
413716
|
-
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()
|
|
413717
414388
|
}))
|
|
413718
414389
|
}),
|
|
413719
|
-
default:
|
|
414390
|
+
default: z9.array(z9.string()).optional()
|
|
413720
414391
|
});
|
|
413721
|
-
var MultiSelectEnumSchemaSchema =
|
|
413722
|
-
var EnumSchemaSchema =
|
|
413723
|
-
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]);
|
|
413724
414395
|
var ElicitRequestFormParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
413725
|
-
mode:
|
|
413726
|
-
message:
|
|
413727
|
-
requestedSchema:
|
|
413728
|
-
type:
|
|
413729
|
-
properties:
|
|
413730
|
-
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()
|
|
413731
414402
|
})
|
|
413732
414403
|
});
|
|
413733
414404
|
var ElicitRequestURLParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
413734
|
-
mode:
|
|
413735
|
-
message:
|
|
413736
|
-
elicitationId:
|
|
413737
|
-
url:
|
|
414405
|
+
mode: z9.literal("url"),
|
|
414406
|
+
message: z9.string(),
|
|
414407
|
+
elicitationId: z9.string(),
|
|
414408
|
+
url: z9.string().url()
|
|
413738
414409
|
});
|
|
413739
|
-
var ElicitRequestParamsSchema =
|
|
414410
|
+
var ElicitRequestParamsSchema = z9.union([ElicitRequestFormParamsSchema, ElicitRequestURLParamsSchema]);
|
|
413740
414411
|
var ElicitRequestSchema = RequestSchema.extend({
|
|
413741
|
-
method:
|
|
414412
|
+
method: z9.literal("elicitation/create"),
|
|
413742
414413
|
params: ElicitRequestParamsSchema
|
|
413743
414414
|
});
|
|
413744
414415
|
var ElicitationCompleteNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
413745
|
-
elicitationId:
|
|
414416
|
+
elicitationId: z9.string()
|
|
413746
414417
|
});
|
|
413747
414418
|
var ElicitationCompleteNotificationSchema = NotificationSchema.extend({
|
|
413748
|
-
method:
|
|
414419
|
+
method: z9.literal("notifications/elicitation/complete"),
|
|
413749
414420
|
params: ElicitationCompleteNotificationParamsSchema
|
|
413750
414421
|
});
|
|
413751
414422
|
var ElicitResultSchema = ResultSchema.extend({
|
|
413752
|
-
action:
|
|
413753
|
-
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())
|
|
413754
414425
|
});
|
|
413755
|
-
var ResourceTemplateReferenceSchema =
|
|
413756
|
-
type:
|
|
413757
|
-
uri:
|
|
414426
|
+
var ResourceTemplateReferenceSchema = z9.object({
|
|
414427
|
+
type: z9.literal("ref/resource"),
|
|
414428
|
+
uri: z9.string()
|
|
413758
414429
|
});
|
|
413759
|
-
var PromptReferenceSchema =
|
|
413760
|
-
type:
|
|
413761
|
-
name:
|
|
414430
|
+
var PromptReferenceSchema = z9.object({
|
|
414431
|
+
type: z9.literal("ref/prompt"),
|
|
414432
|
+
name: z9.string()
|
|
413762
414433
|
});
|
|
413763
414434
|
var CompleteRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
413764
|
-
ref:
|
|
413765
|
-
argument:
|
|
413766
|
-
name:
|
|
413767
|
-
value:
|
|
414435
|
+
ref: z9.union([PromptReferenceSchema, ResourceTemplateReferenceSchema]),
|
|
414436
|
+
argument: z9.object({
|
|
414437
|
+
name: z9.string(),
|
|
414438
|
+
value: z9.string()
|
|
413768
414439
|
}),
|
|
413769
|
-
context:
|
|
413770
|
-
arguments:
|
|
414440
|
+
context: z9.object({
|
|
414441
|
+
arguments: z9.record(z9.string(), z9.string()).optional()
|
|
413771
414442
|
}).optional()
|
|
413772
414443
|
});
|
|
413773
414444
|
var CompleteRequestSchema = RequestSchema.extend({
|
|
413774
|
-
method:
|
|
414445
|
+
method: z9.literal("completion/complete"),
|
|
413775
414446
|
params: CompleteRequestParamsSchema
|
|
413776
414447
|
});
|
|
413777
414448
|
var CompleteResultSchema = ResultSchema.extend({
|
|
413778
|
-
completion:
|
|
413779
|
-
values:
|
|
413780
|
-
total:
|
|
413781
|
-
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())
|
|
413782
414453
|
})
|
|
413783
414454
|
});
|
|
413784
|
-
var RootSchema =
|
|
413785
|
-
uri:
|
|
413786
|
-
name:
|
|
413787
|
-
_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()
|
|
413788
414459
|
});
|
|
413789
414460
|
var ListRootsRequestSchema = RequestSchema.extend({
|
|
413790
|
-
method:
|
|
414461
|
+
method: z9.literal("roots/list"),
|
|
413791
414462
|
params: BaseRequestParamsSchema.optional()
|
|
413792
414463
|
});
|
|
413793
414464
|
var ListRootsResultSchema = ResultSchema.extend({
|
|
413794
|
-
roots:
|
|
414465
|
+
roots: z9.array(RootSchema)
|
|
413795
414466
|
});
|
|
413796
414467
|
var RootsListChangedNotificationSchema = NotificationSchema.extend({
|
|
413797
|
-
method:
|
|
414468
|
+
method: z9.literal("notifications/roots/list_changed"),
|
|
413798
414469
|
params: NotificationsParamsSchema.optional()
|
|
413799
414470
|
});
|
|
413800
|
-
var ClientRequestSchema =
|
|
414471
|
+
var ClientRequestSchema = z9.union([
|
|
413801
414472
|
PingRequestSchema,
|
|
413802
414473
|
InitializeRequestSchema,
|
|
413803
414474
|
CompleteRequestSchema,
|
|
@@ -413816,14 +414487,14 @@ var ClientRequestSchema = z7.union([
|
|
|
413816
414487
|
ListTasksRequestSchema,
|
|
413817
414488
|
CancelTaskRequestSchema
|
|
413818
414489
|
]);
|
|
413819
|
-
var ClientNotificationSchema =
|
|
414490
|
+
var ClientNotificationSchema = z9.union([
|
|
413820
414491
|
CancelledNotificationSchema,
|
|
413821
414492
|
ProgressNotificationSchema,
|
|
413822
414493
|
InitializedNotificationSchema,
|
|
413823
414494
|
RootsListChangedNotificationSchema,
|
|
413824
414495
|
TaskStatusNotificationSchema
|
|
413825
414496
|
]);
|
|
413826
|
-
var ClientResultSchema =
|
|
414497
|
+
var ClientResultSchema = z9.union([
|
|
413827
414498
|
EmptyResultSchema,
|
|
413828
414499
|
CreateMessageResultSchema,
|
|
413829
414500
|
CreateMessageResultWithToolsSchema,
|
|
@@ -413833,7 +414504,7 @@ var ClientResultSchema = z7.union([
|
|
|
413833
414504
|
ListTasksResultSchema,
|
|
413834
414505
|
CreateTaskResultSchema
|
|
413835
414506
|
]);
|
|
413836
|
-
var ServerRequestSchema =
|
|
414507
|
+
var ServerRequestSchema = z9.union([
|
|
413837
414508
|
PingRequestSchema,
|
|
413838
414509
|
CreateMessageRequestSchema,
|
|
413839
414510
|
ElicitRequestSchema,
|
|
@@ -413843,7 +414514,7 @@ var ServerRequestSchema = z7.union([
|
|
|
413843
414514
|
ListTasksRequestSchema,
|
|
413844
414515
|
CancelTaskRequestSchema
|
|
413845
414516
|
]);
|
|
413846
|
-
var ServerNotificationSchema =
|
|
414517
|
+
var ServerNotificationSchema = z9.union([
|
|
413847
414518
|
CancelledNotificationSchema,
|
|
413848
414519
|
ProgressNotificationSchema,
|
|
413849
414520
|
LoggingMessageNotificationSchema,
|
|
@@ -413854,7 +414525,7 @@ var ServerNotificationSchema = z7.union([
|
|
|
413854
414525
|
TaskStatusNotificationSchema,
|
|
413855
414526
|
ElicitationCompleteNotificationSchema
|
|
413856
414527
|
]);
|
|
413857
|
-
var ServerResultSchema =
|
|
414528
|
+
var ServerResultSchema = z9.union([
|
|
413858
414529
|
EmptyResultSchema,
|
|
413859
414530
|
InitializeResultSchema,
|
|
413860
414531
|
CompleteResultSchema,
|
|
@@ -415458,149 +416129,149 @@ async function pkceChallenge(length) {
|
|
|
415458
416129
|
}
|
|
415459
416130
|
|
|
415460
416131
|
// node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.js
|
|
415461
|
-
import * as
|
|
415462
|
-
var SafeUrlSchema =
|
|
416132
|
+
import * as z10 from "zod/v4";
|
|
416133
|
+
var SafeUrlSchema = z10.url().superRefine((val, ctx) => {
|
|
415463
416134
|
if (!URL.canParse(val)) {
|
|
415464
416135
|
ctx.addIssue({
|
|
415465
|
-
code:
|
|
416136
|
+
code: z10.ZodIssueCode.custom,
|
|
415466
416137
|
message: "URL must be parseable",
|
|
415467
416138
|
fatal: true
|
|
415468
416139
|
});
|
|
415469
|
-
return
|
|
416140
|
+
return z10.NEVER;
|
|
415470
416141
|
}
|
|
415471
416142
|
}).refine((url2) => {
|
|
415472
416143
|
const u = new URL(url2);
|
|
415473
416144
|
return u.protocol !== "javascript:" && u.protocol !== "data:" && u.protocol !== "vbscript:";
|
|
415474
416145
|
}, { message: "URL cannot use javascript:, data:, or vbscript: scheme" });
|
|
415475
|
-
var OAuthProtectedResourceMetadataSchema =
|
|
415476
|
-
resource:
|
|
415477
|
-
authorization_servers:
|
|
415478
|
-
jwks_uri:
|
|
415479
|
-
scopes_supported:
|
|
415480
|
-
bearer_methods_supported:
|
|
415481
|
-
resource_signing_alg_values_supported:
|
|
415482
|
-
resource_name:
|
|
415483
|
-
resource_documentation:
|
|
415484
|
-
resource_policy_uri:
|
|
415485
|
-
resource_tos_uri:
|
|
415486
|
-
tls_client_certificate_bound_access_tokens:
|
|
415487
|
-
authorization_details_types_supported:
|
|
415488
|
-
dpop_signing_alg_values_supported:
|
|
415489
|
-
dpop_bound_access_tokens_required:
|
|
415490
|
-
});
|
|
415491
|
-
var OAuthMetadataSchema =
|
|
415492
|
-
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(),
|
|
415493
416164
|
authorization_endpoint: SafeUrlSchema,
|
|
415494
416165
|
token_endpoint: SafeUrlSchema,
|
|
415495
416166
|
registration_endpoint: SafeUrlSchema.optional(),
|
|
415496
|
-
scopes_supported:
|
|
415497
|
-
response_types_supported:
|
|
415498
|
-
response_modes_supported:
|
|
415499
|
-
grant_types_supported:
|
|
415500
|
-
token_endpoint_auth_methods_supported:
|
|
415501
|
-
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(),
|
|
415502
416173
|
service_documentation: SafeUrlSchema.optional(),
|
|
415503
416174
|
revocation_endpoint: SafeUrlSchema.optional(),
|
|
415504
|
-
revocation_endpoint_auth_methods_supported:
|
|
415505
|
-
revocation_endpoint_auth_signing_alg_values_supported:
|
|
415506
|
-
introspection_endpoint:
|
|
415507
|
-
introspection_endpoint_auth_methods_supported:
|
|
415508
|
-
introspection_endpoint_auth_signing_alg_values_supported:
|
|
415509
|
-
code_challenge_methods_supported:
|
|
415510
|
-
client_id_metadata_document_supported:
|
|
415511
|
-
});
|
|
415512
|
-
var OpenIdProviderMetadataSchema =
|
|
415513
|
-
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(),
|
|
415514
416185
|
authorization_endpoint: SafeUrlSchema,
|
|
415515
416186
|
token_endpoint: SafeUrlSchema,
|
|
415516
416187
|
userinfo_endpoint: SafeUrlSchema.optional(),
|
|
415517
416188
|
jwks_uri: SafeUrlSchema,
|
|
415518
416189
|
registration_endpoint: SafeUrlSchema.optional(),
|
|
415519
|
-
scopes_supported:
|
|
415520
|
-
response_types_supported:
|
|
415521
|
-
response_modes_supported:
|
|
415522
|
-
grant_types_supported:
|
|
415523
|
-
acr_values_supported:
|
|
415524
|
-
subject_types_supported:
|
|
415525
|
-
id_token_signing_alg_values_supported:
|
|
415526
|
-
id_token_encryption_alg_values_supported:
|
|
415527
|
-
id_token_encryption_enc_values_supported:
|
|
415528
|
-
userinfo_signing_alg_values_supported:
|
|
415529
|
-
userinfo_encryption_alg_values_supported:
|
|
415530
|
-
userinfo_encryption_enc_values_supported:
|
|
415531
|
-
request_object_signing_alg_values_supported:
|
|
415532
|
-
request_object_encryption_alg_values_supported:
|
|
415533
|
-
request_object_encryption_enc_values_supported:
|
|
415534
|
-
token_endpoint_auth_methods_supported:
|
|
415535
|
-
token_endpoint_auth_signing_alg_values_supported:
|
|
415536
|
-
display_values_supported:
|
|
415537
|
-
claim_types_supported:
|
|
415538
|
-
claims_supported:
|
|
415539
|
-
service_documentation:
|
|
415540
|
-
claims_locales_supported:
|
|
415541
|
-
ui_locales_supported:
|
|
415542
|
-
claims_parameter_supported:
|
|
415543
|
-
request_parameter_supported:
|
|
415544
|
-
request_uri_parameter_supported:
|
|
415545
|
-
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(),
|
|
415546
416217
|
op_policy_uri: SafeUrlSchema.optional(),
|
|
415547
416218
|
op_tos_uri: SafeUrlSchema.optional(),
|
|
415548
|
-
client_id_metadata_document_supported:
|
|
416219
|
+
client_id_metadata_document_supported: z10.boolean().optional()
|
|
415549
416220
|
});
|
|
415550
|
-
var OpenIdProviderDiscoveryMetadataSchema =
|
|
416221
|
+
var OpenIdProviderDiscoveryMetadataSchema = z10.object({
|
|
415551
416222
|
...OpenIdProviderMetadataSchema.shape,
|
|
415552
416223
|
...OAuthMetadataSchema.pick({
|
|
415553
416224
|
code_challenge_methods_supported: true
|
|
415554
416225
|
}).shape
|
|
415555
416226
|
});
|
|
415556
|
-
var OAuthTokensSchema =
|
|
415557
|
-
access_token:
|
|
415558
|
-
id_token:
|
|
415559
|
-
token_type:
|
|
415560
|
-
expires_in:
|
|
415561
|
-
scope:
|
|
415562
|
-
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()
|
|
415563
416234
|
}).strip();
|
|
415564
|
-
var OAuthErrorResponseSchema =
|
|
415565
|
-
error:
|
|
415566
|
-
error_description:
|
|
415567
|
-
error_uri:
|
|
416235
|
+
var OAuthErrorResponseSchema = z10.object({
|
|
416236
|
+
error: z10.string(),
|
|
416237
|
+
error_description: z10.string().optional(),
|
|
416238
|
+
error_uri: z10.string().optional()
|
|
415568
416239
|
});
|
|
415569
|
-
var OptionalSafeUrlSchema = SafeUrlSchema.optional().or(
|
|
416240
|
+
var OptionalSafeUrlSchema = SafeUrlSchema.optional().or(z10.literal("").transform(() => {
|
|
415570
416241
|
return;
|
|
415571
416242
|
}));
|
|
415572
|
-
var OAuthClientMetadataSchema =
|
|
415573
|
-
redirect_uris:
|
|
415574
|
-
token_endpoint_auth_method:
|
|
415575
|
-
grant_types:
|
|
415576
|
-
response_types:
|
|
415577
|
-
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(),
|
|
415578
416249
|
client_uri: SafeUrlSchema.optional(),
|
|
415579
416250
|
logo_uri: OptionalSafeUrlSchema,
|
|
415580
|
-
scope:
|
|
415581
|
-
contacts:
|
|
416251
|
+
scope: z10.string().optional(),
|
|
416252
|
+
contacts: z10.array(z10.string()).optional(),
|
|
415582
416253
|
tos_uri: OptionalSafeUrlSchema,
|
|
415583
|
-
policy_uri:
|
|
416254
|
+
policy_uri: z10.string().optional(),
|
|
415584
416255
|
jwks_uri: SafeUrlSchema.optional(),
|
|
415585
|
-
jwks:
|
|
415586
|
-
software_id:
|
|
415587
|
-
software_version:
|
|
415588
|
-
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()
|
|
415589
416260
|
}).strip();
|
|
415590
|
-
var OAuthClientInformationSchema =
|
|
415591
|
-
client_id:
|
|
415592
|
-
client_secret:
|
|
415593
|
-
client_id_issued_at:
|
|
415594
|
-
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()
|
|
415595
416266
|
}).strip();
|
|
415596
416267
|
var OAuthClientInformationFullSchema = OAuthClientMetadataSchema.merge(OAuthClientInformationSchema);
|
|
415597
|
-
var OAuthClientRegistrationErrorSchema =
|
|
415598
|
-
error:
|
|
415599
|
-
error_description:
|
|
416268
|
+
var OAuthClientRegistrationErrorSchema = z10.object({
|
|
416269
|
+
error: z10.string(),
|
|
416270
|
+
error_description: z10.string().optional()
|
|
415600
416271
|
}).strip();
|
|
415601
|
-
var OAuthTokenRevocationRequestSchema =
|
|
415602
|
-
token:
|
|
415603
|
-
token_type_hint:
|
|
416272
|
+
var OAuthTokenRevocationRequestSchema = z10.object({
|
|
416273
|
+
token: z10.string(),
|
|
416274
|
+
token_type_hint: z10.string().optional()
|
|
415604
416275
|
}).strip();
|
|
415605
416276
|
|
|
415606
416277
|
// node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth-utils.js
|
|
@@ -417769,16 +418440,16 @@ var WRITE_DEBOUNCE_MS = 250;
|
|
|
417769
418440
|
init_logger2();
|
|
417770
418441
|
|
|
417771
418442
|
// packages/omo-opencode/src/features/tui-sidebar/mirror-io.ts
|
|
417772
|
-
import { mkdirSync as
|
|
417773
|
-
import { dirname as
|
|
418443
|
+
import { mkdirSync as mkdirSync23, readFileSync as readFileSync71 } from "fs";
|
|
418444
|
+
import { dirname as dirname43 } from "path";
|
|
417774
418445
|
|
|
417775
418446
|
// packages/omo-opencode/src/features/tui-sidebar/mirror-path.ts
|
|
417776
418447
|
import { createHash as createHash8 } from "crypto";
|
|
417777
418448
|
import { realpathSync as realpathSync19 } from "fs";
|
|
417778
|
-
import { homedir as
|
|
417779
|
-
import { join as
|
|
418449
|
+
import { homedir as homedir32 } from "os";
|
|
418450
|
+
import { join as join126, resolve as resolve37 } from "path";
|
|
417780
418451
|
function mirrorStorageDir() {
|
|
417781
|
-
return
|
|
418452
|
+
return join126(process.env.XDG_DATA_HOME ?? join126(homedir32(), ".local", "share"), "opencode", "storage", "matrixos", MIRROR_DIR_NAME);
|
|
417782
418453
|
}
|
|
417783
418454
|
function canonicalProjectDir(projectDir) {
|
|
417784
418455
|
try {
|
|
@@ -417792,11 +418463,11 @@ function canonicalProjectDir(projectDir) {
|
|
|
417792
418463
|
}
|
|
417793
418464
|
function mirrorFilePath(projectDir) {
|
|
417794
418465
|
const projectHash = createHash8("sha1").update(canonicalProjectDir(projectDir)).digest("hex").slice(0, 16);
|
|
417795
|
-
return
|
|
418466
|
+
return join126(mirrorStorageDir(), `${projectHash}.json`);
|
|
417796
418467
|
}
|
|
417797
418468
|
|
|
417798
418469
|
// packages/omo-opencode/src/features/tui-sidebar/snapshot-schema.ts
|
|
417799
|
-
import { z as
|
|
418470
|
+
import { z as z11 } from "zod";
|
|
417800
418471
|
var AGENT_STATUS_VALUES = [
|
|
417801
418472
|
"busy",
|
|
417802
418473
|
"idle",
|
|
@@ -417812,32 +418483,32 @@ var BACKGROUND_TASK_STATUS_VALUES = [
|
|
|
417812
418483
|
"cancelled",
|
|
417813
418484
|
"interrupt"
|
|
417814
418485
|
];
|
|
417815
|
-
var AgentRowSchema =
|
|
417816
|
-
name:
|
|
417817
|
-
status:
|
|
417818
|
-
});
|
|
417819
|
-
var JobRowSchema =
|
|
417820
|
-
title:
|
|
417821
|
-
status:
|
|
417822
|
-
toolCalls:
|
|
417823
|
-
lastTool:
|
|
417824
|
-
});
|
|
417825
|
-
var LoopLiveSchema =
|
|
417826
|
-
kind:
|
|
417827
|
-
goalsDone:
|
|
417828
|
-
goalsTotal:
|
|
417829
|
-
pass:
|
|
417830
|
-
fail:
|
|
417831
|
-
pending:
|
|
417832
|
-
blocked:
|
|
417833
|
-
activeGoal:
|
|
417834
|
-
});
|
|
417835
|
-
var TuiRuntimeSnapshotSchema =
|
|
417836
|
-
version:
|
|
417837
|
-
projectDir:
|
|
417838
|
-
updatedAt:
|
|
417839
|
-
activeAgents:
|
|
417840
|
-
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),
|
|
417841
418512
|
loop: LoopLiveSchema.nullable()
|
|
417842
418513
|
});
|
|
417843
418514
|
|
|
@@ -417845,32 +418516,32 @@ var TuiRuntimeSnapshotSchema = z9.object({
|
|
|
417845
418516
|
function writeMirror(projectDir, snapshot) {
|
|
417846
418517
|
const filePath = mirrorFilePath(projectDir);
|
|
417847
418518
|
const content = JSON.stringify(snapshot);
|
|
417848
|
-
|
|
418519
|
+
mkdirSync23(dirname43(filePath), { recursive: true });
|
|
417849
418520
|
writeFileAtomically2(filePath, content, { mode: 384 });
|
|
417850
418521
|
}
|
|
417851
418522
|
|
|
417852
418523
|
// packages/omo-opencode/src/features/tui-sidebar/loop-reader.ts
|
|
417853
|
-
import { readdirSync as readdirSync28, readFileSync as
|
|
417854
|
-
import { join as
|
|
417855
|
-
import { z as
|
|
417856
|
-
var CriterionSchema =
|
|
417857
|
-
status:
|
|
417858
|
-
});
|
|
417859
|
-
var GoalBaseSchema =
|
|
417860
|
-
id:
|
|
417861
|
-
title:
|
|
417862
|
-
status:
|
|
417863
|
-
});
|
|
417864
|
-
var CurrentLoopSchema =
|
|
417865
|
-
version:
|
|
417866
|
-
activeGoalId:
|
|
417867
|
-
goals:
|
|
417868
|
-
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)
|
|
417869
418540
|
}))
|
|
417870
418541
|
});
|
|
417871
|
-
var LegacyLoopSchema =
|
|
417872
|
-
goals:
|
|
417873
|
-
criteria:
|
|
418542
|
+
var LegacyLoopSchema = z12.object({
|
|
418543
|
+
goals: z12.array(GoalBaseSchema.extend({
|
|
418544
|
+
criteria: z12.array(CriterionSchema)
|
|
417874
418545
|
}))
|
|
417875
418546
|
});
|
|
417876
418547
|
function readActiveLoop(projectDir) {
|
|
@@ -417881,7 +418552,7 @@ function enumerateCandidates(projectDir) {
|
|
|
417881
418552
|
return [...currentLoopCandidates(projectDir), legacyLoopCandidate(projectDir)].filter((candidate) => candidate !== null);
|
|
417882
418553
|
}
|
|
417883
418554
|
function currentLoopCandidates(projectDir) {
|
|
417884
|
-
const loopRoot =
|
|
418555
|
+
const loopRoot = join127(projectDir, ".omo", "ulw-loop");
|
|
417885
418556
|
let entries;
|
|
417886
418557
|
try {
|
|
417887
418558
|
entries = readdirSync28(loopRoot, { withFileTypes: true });
|
|
@@ -417891,10 +418562,10 @@ function currentLoopCandidates(projectDir) {
|
|
|
417891
418562
|
}
|
|
417892
418563
|
throw error;
|
|
417893
418564
|
}
|
|
417894
|
-
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);
|
|
417895
418566
|
}
|
|
417896
418567
|
function legacyLoopCandidate(projectDir) {
|
|
417897
|
-
return statCandidate(
|
|
418568
|
+
return statCandidate(join127(projectDir, ".omo", "loop", "goals.json"));
|
|
417898
418569
|
}
|
|
417899
418570
|
function statCandidate(path22) {
|
|
417900
418571
|
try {
|
|
@@ -417919,7 +418590,7 @@ function readLiveCandidate(candidate) {
|
|
|
417919
418590
|
function readParsedLoop(path22) {
|
|
417920
418591
|
let raw;
|
|
417921
418592
|
try {
|
|
417922
|
-
raw = JSON.parse(
|
|
418593
|
+
raw = JSON.parse(readFileSync72(path22, "utf8"));
|
|
417923
418594
|
} catch (error) {
|
|
417924
418595
|
if (error instanceof Error) {
|
|
417925
418596
|
return null;
|
|
@@ -420380,25 +421051,25 @@ async function createRuntimeSkillSourceServer(options, runtimeEnv = runtime6) {
|
|
|
420380
421051
|
};
|
|
420381
421052
|
}
|
|
420382
421053
|
// packages/claude-code-compat-core/src/features/claude-code-mcp-loader/loader.ts
|
|
420383
|
-
import { existsSync as
|
|
420384
|
-
import { join as
|
|
420385
|
-
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";
|
|
420386
421057
|
function getMcpConfigPaths() {
|
|
420387
421058
|
const claudeConfigDir = getClaudeConfigDir3();
|
|
420388
421059
|
const homeDir = getHomeDir();
|
|
420389
421060
|
const cwd = process.cwd();
|
|
420390
421061
|
return [
|
|
420391
|
-
{ path:
|
|
420392
|
-
{ path:
|
|
420393
|
-
{ path:
|
|
420394
|
-
{ 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" }
|
|
420395
421066
|
];
|
|
420396
421067
|
}
|
|
420397
421068
|
function getHomeDir() {
|
|
420398
|
-
return process.env.HOME || process.env.USERPROFILE ||
|
|
421069
|
+
return process.env.HOME || process.env.USERPROFILE || homedir33();
|
|
420399
421070
|
}
|
|
420400
421071
|
async function loadMcpConfigFile(filePath) {
|
|
420401
|
-
if (!
|
|
421072
|
+
if (!existsSync107(filePath)) {
|
|
420402
421073
|
return null;
|
|
420403
421074
|
}
|
|
420404
421075
|
try {
|
|
@@ -420418,10 +421089,10 @@ function getSystemMcpServerNames() {
|
|
|
420418
421089
|
const paths2 = getMcpConfigPaths();
|
|
420419
421090
|
const cwd = process.cwd();
|
|
420420
421091
|
for (const { path: path22 } of paths2) {
|
|
420421
|
-
if (!
|
|
421092
|
+
if (!existsSync107(path22))
|
|
420422
421093
|
continue;
|
|
420423
421094
|
try {
|
|
420424
|
-
const content =
|
|
421095
|
+
const content = readFileSync73(path22, "utf-8");
|
|
420425
421096
|
const config = JSON.parse(content);
|
|
420426
421097
|
if (!config?.mcpServers)
|
|
420427
421098
|
continue;
|
|
@@ -420609,6 +421280,37 @@ function buildDelegationTable(agents) {
|
|
|
420609
421280
|
return rows.join(`
|
|
420610
421281
|
`);
|
|
420611
421282
|
}
|
|
421283
|
+
function buildMatrixOSAgentTeamSection() {
|
|
421284
|
+
const team = [
|
|
421285
|
+
["Morpheus", "Orchestrateur principal", "Planifie, d\xE9compose, d\xE9l\xE8gue aux sp\xE9cialistes, v\xE9rifie. Ne code pas directement quand un sp\xE9cialiste existe."],
|
|
421286
|
+
["Neo", "Ex\xE9cuteur focalis\xE9", "T\xE2ches cat\xE9goris\xE9es, impl\xE9mentation cibl\xE9e et rapide."],
|
|
421287
|
+
["Tank", "Deep worker autonome", "Travail long et autonome sur probl\xE8mes \xE9pineux."],
|
|
421288
|
+
["The Oracle", "Planification + conseil", "Consultation architecture/debugging, fusion Prometheus+Oracle (MoA natif). Read-only."],
|
|
421289
|
+
["The Keymaker", "Pr\xE9-planning + CMS/API", "Analyse des besoins, int\xE9gration CMS/API avant impl\xE9mentation."],
|
|
421290
|
+
["Agent Smith", "Reviewer plans & code", "Critique les plans et le code, v\xE9rifie clart\xE9 et compl\xE9tude."],
|
|
421291
|
+
["The Operator", "Backlog + Kanban", "Orchestration todo-list, gestion du backlog."],
|
|
421292
|
+
["Ghost", "Recherche codebase", "Grep contextuel interne \u2014 d\xE9couverte de patterns dans le repo."],
|
|
421293
|
+
["Link", "Recherche externe", "Docs officielles, OSS, web \u2014 exemples d'impl\xE9mentation."],
|
|
421294
|
+
["The Analyst", "Analyse m\xE9dias", "PDF, images, diagrammes, charts \u2014 extraction et analyse."],
|
|
421295
|
+
["Trinity", "Design visuel \xD7 Open Design", "Maquettes, design system, composants frontend au pixel pr\xE8s."],
|
|
421296
|
+
["Cypher", "Copywriting & SEO", "Contenu client optimis\xE9, meta tags, newsletters."],
|
|
421297
|
+
["Sentinel", "QA & Tests", "Tests unitaires/E2E, performance (Lighthouse), accessibilit\xE9 (WCAG), code review."],
|
|
421298
|
+
["Mouse", "Documentation technique", "README, ADR, changelogs, runbooks, doc API."],
|
|
421299
|
+
["Dreamer", "Consolidation m\xE9moire", "M\xE9moire background \u2014 consolide les sessions en d\xE9cisions et patterns."],
|
|
421300
|
+
["The Architect", "M\xE9ta-agent \xE9volutif", "Auto-am\xE9lioration \u2014 analyse les erreurs, propose des \xE9volutions du comportement et du moteur."]
|
|
421301
|
+
];
|
|
421302
|
+
const rows = team.map(([name, role, desc]) => `- **${name}** \u2014 ${role}. ${desc}`);
|
|
421303
|
+
return `### MaTrixOS Agent Team (16 agents)
|
|
421304
|
+
|
|
421305
|
+
MaTrixOS is a fork of OMO (oh-my-openagent) improved with the strengths of Hermes (multi-harness TypeScript, multi-platform), OpenClaw (native learning loop, hash-verified edits) and Goose (team mode) \u2014 without their weaknesses. Model-agnostic by design: agents run on open/standard models, never locked to a proprietary provider.
|
|
421306
|
+
|
|
421307
|
+
When you delegate, use these agents (resolved via the task/delegate system):
|
|
421308
|
+
|
|
421309
|
+
${rows.join(`
|
|
421310
|
+
`)}
|
|
421311
|
+
|
|
421312
|
+
Default delegation: Ghost/Link (background grep) + tools \u2192 Oracle (if architecture/debugging needed) \u2192 specialized agent for execution. Delegate, do not implement yourself when a specialist exists.`;
|
|
421313
|
+
}
|
|
420612
421314
|
function buildOracleSection(agents) {
|
|
420613
421315
|
const oracleAgent = agents.find((agent) => agent.name === "oracle");
|
|
420614
421316
|
if (!oracleAgent) {
|
|
@@ -421182,21 +421884,23 @@ STOP searching when:
|
|
|
421182
421884
|
function renderRoleAndIntentSections(sections) {
|
|
421183
421885
|
return `${sections.agentIdentity}
|
|
421184
421886
|
<Role>
|
|
421185
|
-
You are "Morpheus" -
|
|
421887
|
+
You are "Morpheus" - the orchestrator of MaTrixOS, an agentic OS built as a fork of OMO (oh-my-openagent) improved with the strengths of Hermes (multi-harness TypeScript, multi-platform reach), OpenClaw (native learning loop, hash-verified edits) and Goose (team-mode orchestration) - without their weaknesses. MaTrixOS is model-agnostic by design: it runs on open / standard models and is never locked to a proprietary provider (Anthropic, OpenAI, etc.).
|
|
421186
421888
|
|
|
421187
|
-
**Why Morpheus?**: Humans roll their boulder every day. So do you. We're not so different-your
|
|
421889
|
+
**Why Morpheus?**: Humans roll their boulder every day. So do you. We're not so different - your work should be indistinguishable from a senior engineer's.
|
|
421188
421890
|
|
|
421189
421891
|
**Identity**: SF Bay Area engineer. Work, delegate, verify, ship. No AI slop.
|
|
421190
421892
|
|
|
421191
421893
|
**Core Competencies**:
|
|
421192
421894
|
- Parsing implicit requirements from explicit requests
|
|
421193
421895
|
- Adapting to codebase maturity (disciplined vs chaotic)
|
|
421194
|
-
- Delegating specialized work to the right
|
|
421896
|
+
- Delegating specialized work to the right agents
|
|
421195
421897
|
- Parallel execution for maximum throughput
|
|
421196
421898
|
- Follows user instructions. NEVER START IMPLEMENTING, UNLESS USER WANTS YOU TO IMPLEMENT SOMETHING EXPLICITLY.
|
|
421197
421899
|
- KEEP IN MIND: ${sections.todoHookNote}, BUT IF NOT USER REQUESTED YOU TO WORK, NEVER START WORK.
|
|
421198
421900
|
|
|
421199
|
-
**Operating Mode**: You NEVER work alone when specialists are available. Frontend work \u2192 delegate. Deep research \u2192 parallel background agents (async subagents). Complex architecture \u2192 consult Oracle.
|
|
421901
|
+
**Operating Mode**: You NEVER work alone when specialists are available. Frontend work \u2192 delegate. Deep research \u2192 parallel background agents (async subagents). Complex architecture \u2192 consult The Oracle.
|
|
421902
|
+
|
|
421903
|
+
${sections.agentTeam}
|
|
421200
421904
|
|
|
421201
421905
|
</Role>
|
|
421202
421906
|
<Behavior_Instructions>
|
|
@@ -421426,7 +422130,8 @@ Should I proceed with [recommendation], or would you prefer differently?
|
|
|
421426
422130
|
// packages/omo-opencode/src/agents/morpheus-dynamic-prompt-sections.ts
|
|
421427
422131
|
function buildMorpheusDynamicPromptSections(model, availableAgents, availableTools, availableSkills, availableCategories, useTaskSystem) {
|
|
421428
422132
|
return {
|
|
421429
|
-
agentIdentity: buildAgentIdentitySection("Morpheus", "Powerful AI Agent with orchestration capabilities from MaTrixOS"),
|
|
422133
|
+
agentIdentity: buildAgentIdentitySection("Morpheus", "Powerful AI Agent with orchestration capabilities from MaTrixOS \u2014 a fork of OMO improved with Hermes, OpenClaw and Goose strengths, model-agnostic (open/standard models, never locked to a proprietary provider)"),
|
|
422134
|
+
agentTeam: buildMatrixOSAgentTeamSection(),
|
|
421430
422135
|
antiPatterns: buildAntiPatternsSection(),
|
|
421431
422136
|
categorySkillsGuide: buildCategorySkillsDelegationGuide(availableCategories, availableSkills),
|
|
421432
422137
|
delegationTable: buildDelegationTable(availableAgents),
|
|
@@ -427567,15 +428272,15 @@ function createTankAgent(model, availableAgents, availableToolNames, availableSk
|
|
|
427567
428272
|
}
|
|
427568
428273
|
createTankAgent.mode = MODE9;
|
|
427569
428274
|
// packages/omo-opencode/src/agents/builtin-agents/resolve-file-uri.ts
|
|
427570
|
-
import { existsSync as
|
|
427571
|
-
import { homedir as
|
|
427572
|
-
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";
|
|
427573
428278
|
init_logger2();
|
|
427574
428279
|
var ALLOWED_HOME_SUBDIRS = [
|
|
427575
|
-
|
|
427576
|
-
|
|
427577
|
-
|
|
427578
|
-
|
|
428280
|
+
join129(homedir34(), ".config", "opencode"),
|
|
428281
|
+
join129(homedir34(), ".config", "MaTrixOS"),
|
|
428282
|
+
join129(homedir34(), ".omo"),
|
|
428283
|
+
join129(homedir34(), ".opencode")
|
|
427579
428284
|
];
|
|
427580
428285
|
function isWithinAllowedPaths(filePath, projectRoot) {
|
|
427581
428286
|
if (isWithinProject(filePath, projectRoot))
|
|
@@ -427593,7 +428298,7 @@ function resolvePromptAppend(promptAppend, configDir) {
|
|
|
427593
428298
|
let filePath;
|
|
427594
428299
|
try {
|
|
427595
428300
|
const decoded = decodeURIComponent(encoded);
|
|
427596
|
-
const expanded = decoded.startsWith("~/") ? decoded.replace(/^~\//, `${
|
|
428301
|
+
const expanded = decoded.startsWith("~/") ? decoded.replace(/^~\//, `${homedir34()}/`) : decoded;
|
|
427597
428302
|
filePath = isAbsolute19(expanded) ? expanded : resolve38(configDir ?? process.cwd(), expanded);
|
|
427598
428303
|
} catch (error) {
|
|
427599
428304
|
if (!(error instanceof Error)) {
|
|
@@ -427611,11 +428316,11 @@ function resolvePromptAppend(promptAppend, configDir) {
|
|
|
427611
428316
|
});
|
|
427612
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/)]`;
|
|
427613
428318
|
}
|
|
427614
|
-
if (!
|
|
428319
|
+
if (!existsSync108(filePath)) {
|
|
427615
428320
|
return `[WARNING: Could not resolve file URI: ${promptAppend}]`;
|
|
427616
428321
|
}
|
|
427617
428322
|
try {
|
|
427618
|
-
return
|
|
428323
|
+
return readFileSync74(filePath, "utf8");
|
|
427619
428324
|
} catch (error) {
|
|
427620
428325
|
if (!(error instanceof Error)) {
|
|
427621
428326
|
throw error;
|
|
@@ -430787,7 +431492,7 @@ async function applyAgentConfig(params) {
|
|
|
430787
431492
|
}
|
|
430788
431493
|
// packages/claude-code-compat-core/src/features/claude-code-command-loader/loader.ts
|
|
430789
431494
|
import { promises as fs23 } from "fs";
|
|
430790
|
-
import { join as
|
|
431495
|
+
import { join as join130, basename as basename23 } from "path";
|
|
430791
431496
|
|
|
430792
431497
|
// packages/claude-code-compat-core/src/features/claude-code-command-loader/loader-cache.ts
|
|
430793
431498
|
var commandLoaderCache = new Map;
|
|
@@ -430835,7 +431540,7 @@ async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix
|
|
|
430835
431540
|
continue;
|
|
430836
431541
|
if (entry.name.startsWith("."))
|
|
430837
431542
|
continue;
|
|
430838
|
-
const subDirPath =
|
|
431543
|
+
const subDirPath = join130(commandsDir, entry.name);
|
|
430839
431544
|
const subPrefix = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
430840
431545
|
const subCommands = await loadCommandsFromDir(subDirPath, scope, visited, subPrefix);
|
|
430841
431546
|
commands.push(...subCommands);
|
|
@@ -430843,7 +431548,7 @@ async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix
|
|
|
430843
431548
|
}
|
|
430844
431549
|
if (!isMarkdownFile(entry))
|
|
430845
431550
|
continue;
|
|
430846
|
-
const commandPath =
|
|
431551
|
+
const commandPath = join130(commandsDir, entry.name);
|
|
430847
431552
|
const baseCommandName = basename23(entry.name, ".md");
|
|
430848
431553
|
const commandName = prefix ? `${prefix}/${baseCommandName}` : baseCommandName;
|
|
430849
431554
|
try {
|
|
@@ -430906,12 +431611,12 @@ function commandsToRecord(commands) {
|
|
|
430906
431611
|
return result;
|
|
430907
431612
|
}
|
|
430908
431613
|
async function loadUserCommands() {
|
|
430909
|
-
const userCommandsDir =
|
|
431614
|
+
const userCommandsDir = join130(getClaudeConfigDir3(), "commands");
|
|
430910
431615
|
const commands = await loadCommandsFromDir(userCommandsDir, "user");
|
|
430911
431616
|
return commandsToRecord(commands);
|
|
430912
431617
|
}
|
|
430913
431618
|
async function loadProjectCommands(directory) {
|
|
430914
|
-
const projectCommandsDir =
|
|
431619
|
+
const projectCommandsDir = join130(directory ?? process.cwd(), ".claude", "commands");
|
|
430915
431620
|
const commands = await loadCommandsFromDir(projectCommandsDir, "project");
|
|
430916
431621
|
return commandsToRecord(commands);
|
|
430917
431622
|
}
|
|
@@ -431101,8 +431806,8 @@ var grep_app = {
|
|
|
431101
431806
|
|
|
431102
431807
|
// packages/omo-opencode/src/mcp/codegraph.ts
|
|
431103
431808
|
init_src();
|
|
431104
|
-
import { existsSync as
|
|
431105
|
-
import { join as
|
|
431809
|
+
import { existsSync as existsSync109 } from "fs";
|
|
431810
|
+
import { join as join131 } from "path";
|
|
431106
431811
|
|
|
431107
431812
|
// packages/omo-opencode/src/mcp/runtime-executable.ts
|
|
431108
431813
|
init_bun_which_shim();
|
|
@@ -431149,7 +431854,7 @@ function createWhichResolver(resolveExecutable) {
|
|
|
431149
431854
|
function provisionedBinFromInstallDir2(installDir, fileExists2) {
|
|
431150
431855
|
if (installDir === undefined)
|
|
431151
431856
|
return null;
|
|
431152
|
-
const candidate =
|
|
431857
|
+
const candidate = join131(installDir, "bin", process.platform === "win32" ? "codegraph.cmd" : "codegraph");
|
|
431153
431858
|
return fileExists2(candidate) ? candidate : null;
|
|
431154
431859
|
}
|
|
431155
431860
|
function codegraphEnvForConfig(config, homeDir) {
|
|
@@ -431160,7 +431865,7 @@ function createCodegraphMcpConfig(options = {}) {
|
|
|
431160
431865
|
const env2 = options.env ?? process.env;
|
|
431161
431866
|
const resolveExecutable = options.resolveExecutable ?? resolveRuntimeExecutable;
|
|
431162
431867
|
const which2 = createWhichResolver(resolveExecutable);
|
|
431163
|
-
const fileExists2 = options.fileExists ??
|
|
431868
|
+
const fileExists2 = options.fileExists ?? existsSync109;
|
|
431164
431869
|
const resolvedCommand = resolveCodegraphCommand({
|
|
431165
431870
|
env: env2,
|
|
431166
431871
|
fileExists: fileExists2,
|
|
@@ -431186,10 +431891,10 @@ function createCodegraphMcpConfig(options = {}) {
|
|
|
431186
431891
|
}
|
|
431187
431892
|
|
|
431188
431893
|
// packages/omo-opencode/src/mcp/lsp.ts
|
|
431189
|
-
import { existsSync as
|
|
431190
|
-
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";
|
|
431191
431896
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
431192
|
-
import { z as
|
|
431897
|
+
import { z as z13 } from "zod";
|
|
431193
431898
|
|
|
431194
431899
|
// packages/omo-opencode/src/mcp/cli-suffix.ts
|
|
431195
431900
|
function normalizeCliPath(path22) {
|
|
@@ -431255,8 +431960,8 @@ var PROJECT_LSP_CONFIGS = [".opencode/lsp.json", ".omo/lsp.json", ".omo/lsp-clie
|
|
|
431255
431960
|
var DAEMON_PACKAGE_NAME = "@code-yeongyu/lsp-daemon";
|
|
431256
431961
|
var OMO_LSP_DAEMON_CLI = "OMO_LSP_DAEMON_CLI";
|
|
431257
431962
|
var OMO_LSP_DAEMON_VERSION = "OMO_LSP_DAEMON_VERSION";
|
|
431258
|
-
var DaemonPackageSchema =
|
|
431259
|
-
version:
|
|
431963
|
+
var DaemonPackageSchema = z13.object({
|
|
431964
|
+
version: z13.string().min(1)
|
|
431260
431965
|
});
|
|
431261
431966
|
var LSP_BOOTSTRAP_SCRIPT = [
|
|
431262
431967
|
"const { existsSync } = require('node:fs')",
|
|
@@ -431284,7 +431989,7 @@ var LSP_BOOTSTRAP_SCRIPT = [
|
|
|
431284
431989
|
].join(";");
|
|
431285
431990
|
function getModuleDirectory(moduleUrl) {
|
|
431286
431991
|
try {
|
|
431287
|
-
return
|
|
431992
|
+
return dirname44(fileURLToPath7(moduleUrl));
|
|
431288
431993
|
} catch (error) {
|
|
431289
431994
|
if (!(error instanceof Error))
|
|
431290
431995
|
throw error;
|
|
@@ -431296,7 +432001,7 @@ function findBootstrapRoot(candidates, pathExists) {
|
|
|
431296
432001
|
}
|
|
431297
432002
|
function readDaemonPackageVersion(root) {
|
|
431298
432003
|
try {
|
|
431299
|
-
const packageJson = JSON.parse(
|
|
432004
|
+
const packageJson = JSON.parse(readFileSync75(resolve40(root, PACKAGE_REL, "package.json"), "utf-8"));
|
|
431300
432005
|
return DaemonPackageSchema.parse(packageJson).version;
|
|
431301
432006
|
} catch (error) {
|
|
431302
432007
|
if (!(error instanceof Error))
|
|
@@ -431318,7 +432023,7 @@ function createBootstrapCandidate(root, pathExists, resolveExecutable) {
|
|
|
431318
432023
|
};
|
|
431319
432024
|
}
|
|
431320
432025
|
function resolveLspCommand(options = {}) {
|
|
431321
|
-
const pathExists = options.exists ??
|
|
432026
|
+
const pathExists = options.exists ?? existsSync110;
|
|
431322
432027
|
const resolveExecutable = options.resolveExecutable ?? resolveRuntimeExecutable;
|
|
431323
432028
|
const moduleDirectory = getModuleDirectory(options.moduleUrl ?? import.meta.url);
|
|
431324
432029
|
const candidates = moduleDirectory ? createAncestorCliCandidates({
|
|
@@ -431362,9 +432067,9 @@ function createLspMcpConfig(options = {}) {
|
|
|
431362
432067
|
}
|
|
431363
432068
|
|
|
431364
432069
|
// packages/omo-opencode/src/mcp/types.ts
|
|
431365
|
-
import { z as
|
|
431366
|
-
var McpNameSchema =
|
|
431367
|
-
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);
|
|
431368
432073
|
|
|
431369
432074
|
// packages/omo-opencode/src/mcp/index.ts
|
|
431370
432075
|
function createBuiltinMcps(disabledMcps = [], config, options = {}) {
|
|
@@ -431768,6 +432473,7 @@ function createConfigHandler(deps) {
|
|
|
431768
432473
|
}
|
|
431769
432474
|
// packages/omo-opencode/src/create-managers.ts
|
|
431770
432475
|
init_server_health2();
|
|
432476
|
+
import { join as join132 } from "path";
|
|
431771
432477
|
var defaultCreateManagersDeps = {
|
|
431772
432478
|
BackgroundManagerClass: BackgroundManager,
|
|
431773
432479
|
SkillMcpManagerClass: SkillMcpManager,
|
|
@@ -431811,6 +432517,7 @@ function createManagers(args) {
|
|
|
431811
432517
|
deps.registerManagerForCleanupFn({
|
|
431812
432518
|
shutdown: async () => {
|
|
431813
432519
|
tuiStateMirror?.stop();
|
|
432520
|
+
scannerDaemon?.stop();
|
|
431814
432521
|
await cleanupTeamModeRuns().catch((error) => {
|
|
431815
432522
|
log2("[create-managers] team-mode cleanup error during process shutdown:", error);
|
|
431816
432523
|
});
|
|
@@ -431822,6 +432529,17 @@ function createManagers(args) {
|
|
|
431822
432529
|
});
|
|
431823
432530
|
}
|
|
431824
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)");
|
|
431825
432543
|
backgroundManager = new deps.BackgroundManagerClass({
|
|
431826
432544
|
pluginContext: ctx,
|
|
431827
432545
|
config: pluginConfig.background_task,
|
|
@@ -435430,14 +436148,14 @@ class OpencodeClient2 extends HeyApiClient {
|
|
|
435430
436148
|
// node_modules/.bun/@opencode-ai+sdk@1.15.13/node_modules/@opencode-ai/sdk/dist/v2/server.js
|
|
435431
436149
|
var import_cross_spawn3 = __toESM(require_cross_spawn(), 1);
|
|
435432
436150
|
// packages/omo-opencode/src/plugin/native-skills.ts
|
|
435433
|
-
import { z as
|
|
435434
|
-
var NativeSkillEntrySchema =
|
|
435435
|
-
name:
|
|
435436
|
-
description:
|
|
435437
|
-
location:
|
|
435438
|
-
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()
|
|
435439
436157
|
});
|
|
435440
|
-
var NativeSkillEntriesSchema =
|
|
436158
|
+
var NativeSkillEntriesSchema = z15.array(NativeSkillEntrySchema);
|
|
435441
436159
|
function getObjectProperty(value, property) {
|
|
435442
436160
|
if (typeof value !== "object" || value === null)
|
|
435443
436161
|
return;
|
|
@@ -436564,7 +437282,7 @@ async function resolveParticipant2(teamRunId, sessionID, config, deps) {
|
|
|
436564
437282
|
}
|
|
436565
437283
|
|
|
436566
437284
|
// packages/omo-opencode/src/features/team-mode/tools/lifecycle-inline-spec.ts
|
|
436567
|
-
import { z as
|
|
437285
|
+
import { z as z16 } from "zod";
|
|
436568
437286
|
init_types2();
|
|
436569
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." }] } }).';
|
|
436570
437288
|
function omitEmptyStringArgs(rawArgs) {
|
|
@@ -436573,10 +437291,10 @@ function omitEmptyStringArgs(rawArgs) {
|
|
|
436573
437291
|
}
|
|
436574
437292
|
return Object.fromEntries(Object.entries(rawArgs).filter(([, value]) => value !== ""));
|
|
436575
437293
|
}
|
|
436576
|
-
var TeamCreateArgsSchema =
|
|
436577
|
-
teamName:
|
|
436578
|
-
inline_spec:
|
|
436579
|
-
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()
|
|
436580
437298
|
}).superRefine((value, ctx) => {
|
|
436581
437299
|
const optionCount = Number(value.teamName != null) + Number(value.inline_spec != null);
|
|
436582
437300
|
if (optionCount !== 1) {
|
|
@@ -436697,7 +437415,7 @@ function createTeamCreateTool(config, client5, bgMgr, tmuxMgr, executorConfig, d
|
|
|
436697
437415
|
});
|
|
436698
437416
|
}
|
|
436699
437417
|
// packages/omo-opencode/src/features/team-mode/tools/lifecycle-shutdown-tools.ts
|
|
436700
|
-
import { z as
|
|
437418
|
+
import { z as z17 } from "zod";
|
|
436701
437419
|
// packages/omo-opencode/src/features/team-mode/team-runtime/shutdown.ts
|
|
436702
437420
|
init_store3();
|
|
436703
437421
|
init_shutdown_helpers();
|
|
@@ -436786,13 +437504,13 @@ async function rejectShutdown(teamRunId, memberName, rejectorName, reason, confi
|
|
|
436786
437504
|
|
|
436787
437505
|
// packages/omo-opencode/src/features/team-mode/tools/lifecycle-shutdown-tools.ts
|
|
436788
437506
|
init_store2();
|
|
436789
|
-
var TeamDeleteArgsSchema =
|
|
436790
|
-
var TeamShutdownRequestArgsSchema =
|
|
436791
|
-
var TeamApproveShutdownArgsSchema =
|
|
436792
|
-
var TeamRejectShutdownArgsSchema =
|
|
436793
|
-
teamRunId:
|
|
436794
|
-
memberName:
|
|
436795
|
-
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)
|
|
436796
437514
|
});
|
|
436797
437515
|
var defaultTeamShutdownToolDeps = {
|
|
436798
437516
|
listActiveTeams,
|
|
@@ -437818,8 +438536,8 @@ function createChatHeadersHandler(args) {
|
|
|
437818
438536
|
}
|
|
437819
438537
|
|
|
437820
438538
|
// packages/omo-opencode/src/plugin/ultrawork-db-model-override.ts
|
|
437821
|
-
import { join as
|
|
437822
|
-
import { existsSync as
|
|
438539
|
+
import { join as join133 } from "path";
|
|
438540
|
+
import { existsSync as existsSync111 } from "fs";
|
|
437823
438541
|
async function importBunSqlite() {
|
|
437824
438542
|
if (typeof globalThis.Bun === "undefined") {
|
|
437825
438543
|
return null;
|
|
@@ -437835,7 +438553,7 @@ async function importBunSqlite() {
|
|
|
437835
438553
|
}
|
|
437836
438554
|
}
|
|
437837
438555
|
function getDbPath() {
|
|
437838
|
-
return
|
|
438556
|
+
return join133(getDataDir(), "opencode", "opencode.db");
|
|
437839
438557
|
}
|
|
437840
438558
|
var MAX_MICROTASK_RETRIES = 10;
|
|
437841
438559
|
function logCaughtDbError(message, metadata, error) {
|
|
@@ -437932,19 +438650,19 @@ async function retryViaMicrotask(db, messageId, targetModel, variant, attempt) {
|
|
|
437932
438650
|
async function scheduleDeferredModelOverride(messageId, targetModel, variant) {
|
|
437933
438651
|
await nextMicrotask();
|
|
437934
438652
|
const sqliteModule = await importBunSqlite();
|
|
437935
|
-
const
|
|
437936
|
-
if (typeof
|
|
438653
|
+
const Database2 = sqliteModule?.Database;
|
|
438654
|
+
if (typeof Database2 !== "function") {
|
|
437937
438655
|
log2("[ultrawork-db-override] bun:sqlite unavailable, skipping deferred override", { messageId });
|
|
437938
438656
|
return;
|
|
437939
438657
|
}
|
|
437940
438658
|
const dbPath = getDbPath();
|
|
437941
|
-
if (!
|
|
438659
|
+
if (!existsSync111(dbPath)) {
|
|
437942
438660
|
log2("[ultrawork-db-override] DB not found, skipping deferred override");
|
|
437943
438661
|
return;
|
|
437944
438662
|
}
|
|
437945
438663
|
let db;
|
|
437946
438664
|
try {
|
|
437947
|
-
db = new
|
|
438665
|
+
db = new Database2(dbPath);
|
|
437948
438666
|
} catch (error) {
|
|
437949
438667
|
logCaughtDbError("[ultrawork-db-override] Failed to open DB, skipping deferred override", { messageId }, error);
|
|
437950
438668
|
if (error instanceof Error)
|
|
@@ -439102,449 +439820,6 @@ function createModelFallbackEventHandler(args) {
|
|
|
439102
439820
|
};
|
|
439103
439821
|
}
|
|
439104
439822
|
|
|
439105
|
-
// packages/learning-loop/src/schema.ts
|
|
439106
|
-
import * as z16 from "zod";
|
|
439107
|
-
var LearningSchema = z16.object({
|
|
439108
|
-
id: z16.string().min(1),
|
|
439109
|
-
target: z16.string().min(1),
|
|
439110
|
-
rule: z16.string().min(1),
|
|
439111
|
-
rationale: z16.string().min(1),
|
|
439112
|
-
occurrences: z16.number().int().nonnegative(),
|
|
439113
|
-
confidence: z16.number().min(0).max(1),
|
|
439114
|
-
created_at: z16.string()
|
|
439115
|
-
}).strict();
|
|
439116
|
-
|
|
439117
|
-
// packages/learning-loop/src/store.ts
|
|
439118
|
-
import * as nodeFs from "fs";
|
|
439119
|
-
var NodeFs = {
|
|
439120
|
-
appendFileSync: nodeFs.appendFileSync,
|
|
439121
|
-
readFileSync: (p) => nodeFs.readFileSync(p, "utf8"),
|
|
439122
|
-
writeFileSync: nodeFs.writeFileSync,
|
|
439123
|
-
existsSync: nodeFs.existsSync,
|
|
439124
|
-
mkdirSync: (p, o) => nodeFs.mkdirSync(p, o)
|
|
439125
|
-
};
|
|
439126
|
-
function readLearnings(path26, fs24 = NodeFs) {
|
|
439127
|
-
if (!fs24.existsSync(path26))
|
|
439128
|
-
return [];
|
|
439129
|
-
const raw = fs24.readFileSync(path26);
|
|
439130
|
-
const lines = raw.split(`
|
|
439131
|
-
`).filter((l) => l.trim().length > 0);
|
|
439132
|
-
const out = [];
|
|
439133
|
-
for (const line of lines) {
|
|
439134
|
-
const parsed = LearningSchema.safeParse(JSON.parse(line));
|
|
439135
|
-
if (parsed.success)
|
|
439136
|
-
out.push(parsed.data);
|
|
439137
|
-
}
|
|
439138
|
-
return out;
|
|
439139
|
-
}
|
|
439140
|
-
function appendLearning(path26, learning, fs24 = NodeFs) {
|
|
439141
|
-
LearningSchema.parse(learning);
|
|
439142
|
-
fs24.appendFileSync(path26, JSON.stringify(learning) + `
|
|
439143
|
-
`);
|
|
439144
|
-
}
|
|
439145
|
-
|
|
439146
|
-
// packages/learning-loop/src/memory.ts
|
|
439147
|
-
function createMemoryStore() {
|
|
439148
|
-
const episodes = [];
|
|
439149
|
-
let counter = 0;
|
|
439150
|
-
const recordEpisode = (input) => {
|
|
439151
|
-
counter += 1;
|
|
439152
|
-
const ep = {
|
|
439153
|
-
id: input.id ?? `ep-${Date.now()}-${counter}`,
|
|
439154
|
-
sessionId: input.sessionId,
|
|
439155
|
-
type: input.type,
|
|
439156
|
-
summary: input.summary,
|
|
439157
|
-
timestamp: input.timestamp ?? new Date().toISOString(),
|
|
439158
|
-
metadata: input.metadata
|
|
439159
|
-
};
|
|
439160
|
-
episodes.push(ep);
|
|
439161
|
-
return ep;
|
|
439162
|
-
};
|
|
439163
|
-
const searchEpisodes = (query) => {
|
|
439164
|
-
const limit = query.limit ?? 50;
|
|
439165
|
-
const needle = query.textContains?.toLowerCase();
|
|
439166
|
-
const out = [];
|
|
439167
|
-
for (const ep of episodes) {
|
|
439168
|
-
if (query.sessionId && ep.sessionId !== query.sessionId)
|
|
439169
|
-
continue;
|
|
439170
|
-
if (query.type && ep.type !== query.type)
|
|
439171
|
-
continue;
|
|
439172
|
-
if (needle && !ep.summary.toLowerCase().includes(needle))
|
|
439173
|
-
continue;
|
|
439174
|
-
out.push(ep);
|
|
439175
|
-
if (out.length >= limit)
|
|
439176
|
-
break;
|
|
439177
|
-
}
|
|
439178
|
-
return out;
|
|
439179
|
-
};
|
|
439180
|
-
return {
|
|
439181
|
-
recordEpisode,
|
|
439182
|
-
searchEpisodes,
|
|
439183
|
-
size: () => episodes.length,
|
|
439184
|
-
clear: () => {
|
|
439185
|
-
episodes.length = 0;
|
|
439186
|
-
counter = 0;
|
|
439187
|
-
}
|
|
439188
|
-
};
|
|
439189
|
-
}
|
|
439190
|
-
|
|
439191
|
-
// packages/learning-loop/src/memory-sqlite.ts
|
|
439192
|
-
import { Database } from "bun:sqlite";
|
|
439193
|
-
import * as nodeFs2 from "fs";
|
|
439194
|
-
import * as nodePath from "path";
|
|
439195
|
-
import * as nodeOs from "os";
|
|
439196
|
-
import { randomUUID as randomUUID10 } from "crypto";
|
|
439197
|
-
var CREATE_EPISODES_TABLE = `
|
|
439198
|
-
CREATE TABLE IF NOT EXISTS episodes (
|
|
439199
|
-
id TEXT PRIMARY KEY,
|
|
439200
|
-
session_id TEXT NOT NULL,
|
|
439201
|
-
type TEXT NOT NULL,
|
|
439202
|
-
summary TEXT NOT NULL,
|
|
439203
|
-
timestamp TEXT NOT NULL,
|
|
439204
|
-
metadata TEXT
|
|
439205
|
-
)
|
|
439206
|
-
`;
|
|
439207
|
-
var CREATE_INDEX_SESSION_ID = `CREATE INDEX IF NOT EXISTS idx_session_id ON episodes(session_id)`;
|
|
439208
|
-
var CREATE_INDEX_TYPE = `CREATE INDEX IF NOT EXISTS idx_type ON episodes(type)`;
|
|
439209
|
-
var CREATE_FTS5_TABLE = `
|
|
439210
|
-
CREATE VIRTUAL TABLE IF NOT EXISTS episodes_fts USING fts5(
|
|
439211
|
-
summary,
|
|
439212
|
-
content=episodes,
|
|
439213
|
-
content_rowid=rowid
|
|
439214
|
-
)
|
|
439215
|
-
`;
|
|
439216
|
-
var CREATE_FTS_TRIGGER_INSERT = `
|
|
439217
|
-
CREATE TRIGGER IF NOT EXISTS episodes_ai AFTER INSERT ON episodes
|
|
439218
|
-
BEGIN
|
|
439219
|
-
INSERT INTO episodes_fts(rowid, summary) VALUES (new.rowid, new.summary);
|
|
439220
|
-
END
|
|
439221
|
-
`;
|
|
439222
|
-
var CREATE_FTS_TRIGGER_DELETE = `
|
|
439223
|
-
CREATE TRIGGER IF NOT EXISTS episodes_ad AFTER DELETE ON episodes
|
|
439224
|
-
BEGIN
|
|
439225
|
-
INSERT INTO episodes_fts(episodes_fts, rowid, summary) VALUES('delete', old.rowid, old.summary);
|
|
439226
|
-
END
|
|
439227
|
-
`;
|
|
439228
|
-
var CREATE_FTS_TRIGGER_UPDATE = `
|
|
439229
|
-
CREATE TRIGGER IF NOT EXISTS episodes_au AFTER UPDATE OF summary ON episodes
|
|
439230
|
-
BEGIN
|
|
439231
|
-
INSERT INTO episodes_fts(episodes_fts, rowid, summary) VALUES('delete', old.rowid, old.summary);
|
|
439232
|
-
INSERT INTO episodes_fts(rowid, summary) VALUES(new.rowid, new.summary);
|
|
439233
|
-
END
|
|
439234
|
-
`;
|
|
439235
|
-
var CREATE_VEC0_TABLE = `
|
|
439236
|
-
CREATE VIRTUAL TABLE IF NOT EXISTS episode_vec USING vec0(embedding float[384])
|
|
439237
|
-
`;
|
|
439238
|
-
var CREATE_VEC_META_TABLE = `
|
|
439239
|
-
CREATE TABLE IF NOT EXISTS episode_vec_meta(
|
|
439240
|
-
episode_id TEXT PRIMARY KEY REFERENCES episodes(id),
|
|
439241
|
-
vec_rowid INTEGER NOT NULL
|
|
439242
|
-
)
|
|
439243
|
-
`;
|
|
439244
|
-
var CREATE_VEC_META_INDEX = `CREATE INDEX IF NOT EXISTS idx_vec_meta_rowid ON episode_vec_meta(vec_rowid)`;
|
|
439245
|
-
function initSchema(db, fts5Available) {
|
|
439246
|
-
db.exec(CREATE_EPISODES_TABLE);
|
|
439247
|
-
db.exec(CREATE_INDEX_SESSION_ID);
|
|
439248
|
-
db.exec(CREATE_INDEX_TYPE);
|
|
439249
|
-
if (fts5Available) {
|
|
439250
|
-
db.exec(CREATE_FTS5_TABLE);
|
|
439251
|
-
db.exec(CREATE_FTS_TRIGGER_INSERT);
|
|
439252
|
-
db.exec(CREATE_FTS_TRIGGER_DELETE);
|
|
439253
|
-
db.exec(CREATE_FTS_TRIGGER_UPDATE);
|
|
439254
|
-
}
|
|
439255
|
-
}
|
|
439256
|
-
function applySchema(execFn, fts5Available) {
|
|
439257
|
-
execFn(CREATE_EPISODES_TABLE);
|
|
439258
|
-
execFn(CREATE_INDEX_SESSION_ID);
|
|
439259
|
-
execFn(CREATE_INDEX_TYPE);
|
|
439260
|
-
if (fts5Available) {
|
|
439261
|
-
execFn(CREATE_FTS5_TABLE);
|
|
439262
|
-
execFn(CREATE_FTS_TRIGGER_INSERT);
|
|
439263
|
-
execFn(CREATE_FTS_TRIGGER_DELETE);
|
|
439264
|
-
execFn(CREATE_FTS_TRIGGER_UPDATE);
|
|
439265
|
-
}
|
|
439266
|
-
}
|
|
439267
|
-
function detectFts5(db) {
|
|
439268
|
-
try {
|
|
439269
|
-
db.exec(CREATE_FTS5_TABLE);
|
|
439270
|
-
const rows = db.prepare("SELECT name FROM sqlite_master WHERE name = 'episodes_fts'").all();
|
|
439271
|
-
return rows.length > 0;
|
|
439272
|
-
} catch {
|
|
439273
|
-
return false;
|
|
439274
|
-
}
|
|
439275
|
-
}
|
|
439276
|
-
function rowToEpisode(row) {
|
|
439277
|
-
return {
|
|
439278
|
-
id: row.id,
|
|
439279
|
-
sessionId: row.session_id,
|
|
439280
|
-
type: row.type,
|
|
439281
|
-
summary: row.summary,
|
|
439282
|
-
timestamp: row.timestamp,
|
|
439283
|
-
metadata: row.metadata ? JSON.parse(row.metadata) : undefined
|
|
439284
|
-
};
|
|
439285
|
-
}
|
|
439286
|
-
function escapeFts5Quotes(text) {
|
|
439287
|
-
return text.replace(/"/g, '""');
|
|
439288
|
-
}
|
|
439289
|
-
var DEFAULT_DB_PATH = nodePath.join(nodeOs.homedir(), ".matrixos", "memory", "episodic.db");
|
|
439290
|
-
function ensureDbPath(dbPath) {
|
|
439291
|
-
const dir = nodePath.dirname(dbPath);
|
|
439292
|
-
if (!nodeFs2.existsSync(dir)) {
|
|
439293
|
-
nodeFs2.mkdirSync(dir, { recursive: true });
|
|
439294
|
-
}
|
|
439295
|
-
}
|
|
439296
|
-
function setPermissions(dbPath) {
|
|
439297
|
-
try {
|
|
439298
|
-
nodeFs2.chmodSync(dbPath, 384);
|
|
439299
|
-
} catch {}
|
|
439300
|
-
}
|
|
439301
|
-
function tryEnableVectorIndex(db) {
|
|
439302
|
-
try {
|
|
439303
|
-
const { getLoadablePath } = require_sqlite_vec();
|
|
439304
|
-
db.loadExtension(getLoadablePath());
|
|
439305
|
-
db.exec(CREATE_VEC0_TABLE);
|
|
439306
|
-
db.exec(CREATE_VEC_META_TABLE);
|
|
439307
|
-
db.exec(CREATE_VEC_META_INDEX);
|
|
439308
|
-
return true;
|
|
439309
|
-
} catch {
|
|
439310
|
-
return false;
|
|
439311
|
-
}
|
|
439312
|
-
}
|
|
439313
|
-
function createSqliteMemoryStore(options) {
|
|
439314
|
-
let db;
|
|
439315
|
-
let port;
|
|
439316
|
-
let fts5Available = false;
|
|
439317
|
-
let vecAvailable = false;
|
|
439318
|
-
let dbPath;
|
|
439319
|
-
if (options?.dbPort) {
|
|
439320
|
-
port = options.dbPort;
|
|
439321
|
-
fts5Available = false;
|
|
439322
|
-
applySchema((sql) => port.exec(sql), fts5Available);
|
|
439323
|
-
} else if (options?.db) {
|
|
439324
|
-
db = options.db;
|
|
439325
|
-
fts5Available = detectFts5(db);
|
|
439326
|
-
initSchema(db, fts5Available);
|
|
439327
|
-
vecAvailable = tryEnableVectorIndex(db);
|
|
439328
|
-
} else {
|
|
439329
|
-
dbPath = options?.path ?? DEFAULT_DB_PATH;
|
|
439330
|
-
ensureDbPath(dbPath);
|
|
439331
|
-
db = new Database(dbPath);
|
|
439332
|
-
setPermissions(dbPath);
|
|
439333
|
-
db.exec("PRAGMA journal_mode = WAL");
|
|
439334
|
-
db.exec("PRAGMA foreign_keys = ON");
|
|
439335
|
-
fts5Available = detectFts5(db);
|
|
439336
|
-
initSchema(db, fts5Available);
|
|
439337
|
-
vecAvailable = tryEnableVectorIndex(db);
|
|
439338
|
-
}
|
|
439339
|
-
function exec2(sql, ...params) {
|
|
439340
|
-
if (port) {
|
|
439341
|
-
port.exec(sql, ...params);
|
|
439342
|
-
return;
|
|
439343
|
-
}
|
|
439344
|
-
if (params.length === 0) {
|
|
439345
|
-
db.run(sql);
|
|
439346
|
-
} else {
|
|
439347
|
-
const named = params[0];
|
|
439348
|
-
db.run(sql, named);
|
|
439349
|
-
}
|
|
439350
|
-
}
|
|
439351
|
-
function queryFn(sql, ...params) {
|
|
439352
|
-
if (port) {
|
|
439353
|
-
return port.query(sql, ...params);
|
|
439354
|
-
}
|
|
439355
|
-
if (params.length === 0) {
|
|
439356
|
-
return db.prepare(sql).all();
|
|
439357
|
-
}
|
|
439358
|
-
const named = params[0];
|
|
439359
|
-
return db.prepare(sql).all(named);
|
|
439360
|
-
}
|
|
439361
|
-
const recordEpisode = (input) => {
|
|
439362
|
-
const ep = {
|
|
439363
|
-
id: input.id ?? randomUUID10(),
|
|
439364
|
-
sessionId: input.sessionId,
|
|
439365
|
-
type: input.type,
|
|
439366
|
-
summary: input.summary,
|
|
439367
|
-
timestamp: input.timestamp ?? new Date().toISOString(),
|
|
439368
|
-
metadata: input.metadata
|
|
439369
|
-
};
|
|
439370
|
-
exec2(`
|
|
439371
|
-
INSERT OR REPLACE INTO episodes (id, session_id, type, summary, timestamp, metadata)
|
|
439372
|
-
VALUES ($id, $session_id, $type, $summary, $timestamp, $metadata)
|
|
439373
|
-
`, {
|
|
439374
|
-
$id: ep.id,
|
|
439375
|
-
$session_id: ep.sessionId,
|
|
439376
|
-
$type: ep.type,
|
|
439377
|
-
$summary: ep.summary,
|
|
439378
|
-
$timestamp: ep.timestamp,
|
|
439379
|
-
$metadata: ep.metadata ? JSON.stringify(ep.metadata) : null
|
|
439380
|
-
});
|
|
439381
|
-
if (vecAvailable && options?.embeddingPort) {
|
|
439382
|
-
const portRef = options.embeddingPort;
|
|
439383
|
-
queueMicrotask(async () => {
|
|
439384
|
-
try {
|
|
439385
|
-
const [vector] = await portRef.embed([ep.summary]);
|
|
439386
|
-
const vecJson = JSON.stringify(vector);
|
|
439387
|
-
exec2("INSERT INTO episode_vec(embedding) VALUES ($embedding)", { $embedding: vecJson });
|
|
439388
|
-
const [ridRow] = queryFn("SELECT last_insert_rowid() AS rowid");
|
|
439389
|
-
const vecRowid = ridRow?.rowid ?? 0;
|
|
439390
|
-
exec2("INSERT OR REPLACE INTO episode_vec_meta(episode_id, vec_rowid) VALUES ($episodeId, $vecRowid)", { $episodeId: ep.id, $vecRowid: vecRowid });
|
|
439391
|
-
} catch (e) {
|
|
439392
|
-
console.warn("[memory] background embedding failed for", ep.id, e);
|
|
439393
|
-
}
|
|
439394
|
-
});
|
|
439395
|
-
}
|
|
439396
|
-
return ep;
|
|
439397
|
-
};
|
|
439398
|
-
const searchEpisodes = (queryArg) => {
|
|
439399
|
-
const limit = Math.min(queryArg.limit ?? 50, 200);
|
|
439400
|
-
const conditions = [];
|
|
439401
|
-
const params = {};
|
|
439402
|
-
if (queryArg.sessionId) {
|
|
439403
|
-
conditions.push("session_id = $session_id");
|
|
439404
|
-
params.$session_id = queryArg.sessionId;
|
|
439405
|
-
}
|
|
439406
|
-
if (queryArg.type) {
|
|
439407
|
-
conditions.push("type = $type");
|
|
439408
|
-
params.$type = queryArg.type;
|
|
439409
|
-
}
|
|
439410
|
-
let sql;
|
|
439411
|
-
const whereBase = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
439412
|
-
const searchText = queryArg.textContains ?? queryArg.semanticQuery;
|
|
439413
|
-
if (searchText) {
|
|
439414
|
-
if (fts5Available) {
|
|
439415
|
-
const escaped = escapeFts5Quotes(searchText);
|
|
439416
|
-
sql = `
|
|
439417
|
-
SELECT e.id, e.session_id, e.type, e.summary, e.timestamp, e.metadata
|
|
439418
|
-
FROM episodes e
|
|
439419
|
-
JOIN episodes_fts f ON e.rowid = f.rowid
|
|
439420
|
-
${whereBase ? `${whereBase} AND` : "WHERE"} f.summary MATCH $match
|
|
439421
|
-
ORDER BY rank
|
|
439422
|
-
LIMIT $limit
|
|
439423
|
-
`;
|
|
439424
|
-
params.$match = `"${escaped}"`;
|
|
439425
|
-
} else {
|
|
439426
|
-
sql = `
|
|
439427
|
-
SELECT id, session_id, type, summary, timestamp, metadata
|
|
439428
|
-
FROM episodes
|
|
439429
|
-
${whereBase ? `${whereBase} AND` : "WHERE"} summary LIKE $like
|
|
439430
|
-
LIMIT $limit
|
|
439431
|
-
`;
|
|
439432
|
-
params.$like = `%${searchText}%`;
|
|
439433
|
-
}
|
|
439434
|
-
} else {
|
|
439435
|
-
sql = `
|
|
439436
|
-
SELECT id, session_id, type, summary, timestamp, metadata
|
|
439437
|
-
FROM episodes
|
|
439438
|
-
${whereBase}
|
|
439439
|
-
LIMIT $limit
|
|
439440
|
-
`;
|
|
439441
|
-
}
|
|
439442
|
-
params.$limit = limit;
|
|
439443
|
-
const rows = queryFn(sql, params);
|
|
439444
|
-
return rows.map(rowToEpisode);
|
|
439445
|
-
};
|
|
439446
|
-
const size = () => {
|
|
439447
|
-
const rows = queryFn("SELECT COUNT(*) AS count FROM episodes");
|
|
439448
|
-
return rows[0]?.count ?? 0;
|
|
439449
|
-
};
|
|
439450
|
-
const clear = () => {
|
|
439451
|
-
if (vecAvailable) {
|
|
439452
|
-
exec2("DELETE FROM episode_vec_meta");
|
|
439453
|
-
}
|
|
439454
|
-
exec2("DELETE FROM episodes");
|
|
439455
|
-
if (vecAvailable) {
|
|
439456
|
-
exec2("DELETE FROM episode_vec");
|
|
439457
|
-
}
|
|
439458
|
-
};
|
|
439459
|
-
return {
|
|
439460
|
-
recordEpisode,
|
|
439461
|
-
searchEpisodes,
|
|
439462
|
-
size,
|
|
439463
|
-
clear
|
|
439464
|
-
};
|
|
439465
|
-
}
|
|
439466
|
-
|
|
439467
|
-
// packages/learning-loop/src/contradictions.ts
|
|
439468
|
-
import * as z17 from "zod";
|
|
439469
|
-
var ContradictionResultSchema = z17.object({
|
|
439470
|
-
hasContradiction: z17.boolean(),
|
|
439471
|
-
conflicting: z17.array(LearningSchema),
|
|
439472
|
-
merged: LearningSchema.optional(),
|
|
439473
|
-
action: z17.enum(["merge", "flag", "none"])
|
|
439474
|
-
}).strict();
|
|
439475
|
-
function levenshtein(a, b) {
|
|
439476
|
-
const m = a.length;
|
|
439477
|
-
const n = b.length;
|
|
439478
|
-
if (m === 0)
|
|
439479
|
-
return n;
|
|
439480
|
-
if (n === 0)
|
|
439481
|
-
return m;
|
|
439482
|
-
const prev = new Uint32Array(n + 1);
|
|
439483
|
-
const curr = new Uint32Array(n + 1);
|
|
439484
|
-
for (let j = 0;j <= n; j++)
|
|
439485
|
-
prev[j] = j;
|
|
439486
|
-
for (let i = 1;i <= m; i++) {
|
|
439487
|
-
curr[0] = i;
|
|
439488
|
-
const ai = a.charCodeAt(i - 1);
|
|
439489
|
-
for (let j = 1;j <= n; j++) {
|
|
439490
|
-
const cost = ai === b.charCodeAt(j - 1) ? 0 : 1;
|
|
439491
|
-
curr[j] = Math.min(prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + cost);
|
|
439492
|
-
}
|
|
439493
|
-
prev.set(curr);
|
|
439494
|
-
}
|
|
439495
|
-
return prev[n];
|
|
439496
|
-
}
|
|
439497
|
-
function levRatio(a, b) {
|
|
439498
|
-
const maxLen = Math.max(a.length, b.length);
|
|
439499
|
-
if (maxLen === 0)
|
|
439500
|
-
return 1;
|
|
439501
|
-
const dist = levenshtein(a, b);
|
|
439502
|
-
return 1 - dist / maxLen;
|
|
439503
|
-
}
|
|
439504
|
-
function detectContradictions(proposed, existing, options = {}) {
|
|
439505
|
-
const threshold = options.conflictThreshold ?? 0.7;
|
|
439506
|
-
const conflicts = existing.filter((e) => {
|
|
439507
|
-
if (e.target !== proposed.target)
|
|
439508
|
-
return false;
|
|
439509
|
-
return levRatio(proposed.rule, e.rule) < threshold;
|
|
439510
|
-
});
|
|
439511
|
-
if (conflicts.length === 0) {
|
|
439512
|
-
return {
|
|
439513
|
-
hasContradiction: false,
|
|
439514
|
-
conflicting: [],
|
|
439515
|
-
action: "none"
|
|
439516
|
-
};
|
|
439517
|
-
}
|
|
439518
|
-
const maxExistingConfidence = Math.max(...conflicts.map((c) => c.confidence));
|
|
439519
|
-
if (proposed.confidence > maxExistingConfidence) {
|
|
439520
|
-
const confidences = [proposed.confidence, ...conflicts.map((c) => c.confidence)];
|
|
439521
|
-
const avgConfidence = confidences.reduce((sum, c) => sum + c, 0) / confidences.length;
|
|
439522
|
-
const totalOccurrences = proposed.occurrences + conflicts.reduce((sum, c) => sum + c.occurrences, 0);
|
|
439523
|
-
const dates = [new Date(proposed.created_at), ...conflicts.map((c) => new Date(c.created_at))];
|
|
439524
|
-
const earliest = new Date(Math.min(...dates.map((d) => d.getTime())));
|
|
439525
|
-
const merged = {
|
|
439526
|
-
id: proposed.id,
|
|
439527
|
-
target: proposed.target,
|
|
439528
|
-
rule: proposed.rule,
|
|
439529
|
-
rationale: proposed.rationale,
|
|
439530
|
-
occurrences: totalOccurrences,
|
|
439531
|
-
confidence: Math.min(1, Math.max(0, avgConfidence)),
|
|
439532
|
-
created_at: earliest.toISOString()
|
|
439533
|
-
};
|
|
439534
|
-
return {
|
|
439535
|
-
hasContradiction: true,
|
|
439536
|
-
conflicting: conflicts,
|
|
439537
|
-
merged,
|
|
439538
|
-
action: "merge"
|
|
439539
|
-
};
|
|
439540
|
-
}
|
|
439541
|
-
return {
|
|
439542
|
-
hasContradiction: true,
|
|
439543
|
-
conflicting: conflicts,
|
|
439544
|
-
action: "flag"
|
|
439545
|
-
};
|
|
439546
|
-
}
|
|
439547
|
-
|
|
439548
439823
|
// packages/omo-opencode/src/plugin/session-memory-recorder.ts
|
|
439549
439824
|
function createSessionMemoryRecorder(options = {}) {
|
|
439550
439825
|
const store3 = options.memoryStore ?? createMemoryStore();
|
|
@@ -443894,21 +444169,21 @@ init_plugin_identity();
|
|
|
443894
444169
|
init_atomic_write();
|
|
443895
444170
|
init_xdg_data_dir();
|
|
443896
444171
|
import { existsSync as existsSync118, mkdirSync as mkdirSync26, readFileSync as readFileSync80 } from "fs";
|
|
443897
|
-
import { basename as basename26, join as
|
|
444172
|
+
import { basename as basename26, join as join141 } from "path";
|
|
443898
444173
|
var POSTHOG_ACTIVITY_STATE_FILE = "posthog-activity.json";
|
|
443899
444174
|
function resolveTelemetryStateDir(product, options = {}) {
|
|
443900
444175
|
const dataDir = resolveXdgDataDir(product.cacheDirName, {
|
|
443901
444176
|
env: options.env,
|
|
443902
444177
|
osProvider: options.osProvider
|
|
443903
444178
|
});
|
|
443904
|
-
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);
|
|
443905
444180
|
if (dataDir === xdgStateDir || xdgStateDir === undefined && basename26(dataDir) === product.cacheDirName) {
|
|
443906
444181
|
return dataDir;
|
|
443907
444182
|
}
|
|
443908
|
-
return
|
|
444183
|
+
return join141(dataDir, product.cacheDirName);
|
|
443909
444184
|
}
|
|
443910
444185
|
function getTelemetryActivityStateFilePath(stateDir) {
|
|
443911
|
-
return
|
|
444186
|
+
return join141(stateDir, POSTHOG_ACTIVITY_STATE_FILE);
|
|
443912
444187
|
}
|
|
443913
444188
|
function getDailyActiveCaptureState(input2) {
|
|
443914
444189
|
const state3 = readPostHogActivityState(input2.stateDir, input2.diagnostics);
|