mcard-js 2.1.49 → 2.1.50
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/CardCollection-ORGE2XBG.js +10 -0
- package/dist/EngineRegistry-EIOT4MUZ.js +17 -0
- package/dist/IndexedDBEngine-RD4447IS.js +12 -0
- package/dist/LLMRuntime-CQ7X43QR.js +17 -0
- package/dist/LLMRuntime-PD45COKE.js +17 -0
- package/dist/LambdaRuntime-HSREEYQG.js +19 -0
- package/dist/LambdaRuntime-IH7NVG6Z.js +19 -0
- package/dist/Loader-W22AEM6F.js +12 -0
- package/dist/OllamaProvider-ABEEFX7M.js +9 -0
- package/dist/chunk-2APJYBH4.js +368 -0
- package/dist/chunk-5HRZV4R3.js +217 -0
- package/dist/chunk-7TXIPJI2.js +2360 -0
- package/dist/chunk-CHXIVTQV.js +364 -0
- package/dist/chunk-ETJWXHKZ.js +246 -0
- package/dist/chunk-GIKMCG4D.js +497 -0
- package/dist/chunk-IJKS3LGK.js +428 -0
- package/dist/chunk-JUQ2VQZA.js +428 -0
- package/dist/chunk-NOPYSBOQ.js +2360 -0
- package/dist/chunk-VJPXJVEH.js +299 -0
- package/dist/chunk-VW3KBDK5.js +74 -0
- package/dist/chunk-XETU7TV4.js +112 -0
- package/dist/chunk-ZMK2HTZ5.js +275 -0
- package/dist/constants-CLB7B6MN.js +101 -0
- package/dist/index.browser.cjs +5 -5
- package/dist/index.browser.js +12 -12
- package/dist/index.cjs +253 -87
- package/dist/index.d.cts +15 -5
- package/dist/index.d.ts +15 -5
- package/dist/index.js +76 -99
- package/dist/storage/SqliteNodeEngine.cjs +5 -5
- package/dist/storage/SqliteNodeEngine.js +4 -4
- package/dist/storage/SqliteWasmEngine.cjs +5 -5
- package/dist/storage/SqliteWasmEngine.js +4 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -472,12 +472,12 @@ var init_app_config = __esm({
|
|
|
472
472
|
},
|
|
473
473
|
identity: {
|
|
474
474
|
provider: "sqlite",
|
|
475
|
-
space_path: "./data/
|
|
475
|
+
space_path: "./data/agent_identities.db",
|
|
476
476
|
api_endpoint: null,
|
|
477
477
|
default_vapid_contact: "mailto:developer@example.com"
|
|
478
478
|
},
|
|
479
479
|
storage: {
|
|
480
|
-
default_db_path: "./data/
|
|
480
|
+
default_db_path: "./data/content_memory.db",
|
|
481
481
|
test_db_path: "./tests/data/test_mcard.db",
|
|
482
482
|
default_data_root_dirname: "data",
|
|
483
483
|
default_data_user: "guest",
|
|
@@ -487,7 +487,7 @@ var init_app_config = __esm({
|
|
|
487
487
|
default_mcard_db: "mcard.db",
|
|
488
488
|
default_server_log_db: "server_log.db",
|
|
489
489
|
default_push_subscriptions_file: "subscriptions.json",
|
|
490
|
-
|
|
490
|
+
default_execution_log_path: "./data/execution_log.db"
|
|
491
491
|
},
|
|
492
492
|
services: {
|
|
493
493
|
default_ollama_base_url: "http://localhost:11434",
|
|
@@ -527,7 +527,58 @@ var init_app_config = __esm({
|
|
|
527
527
|
});
|
|
528
528
|
|
|
529
529
|
// src/config/constants.ts
|
|
530
|
-
var
|
|
530
|
+
var constants_exports = {};
|
|
531
|
+
__export(constants_exports, {
|
|
532
|
+
API_KEY_HEADER_NAME: () => API_KEY_HEADER_NAME,
|
|
533
|
+
BINARY_CHECK_SAMPLE_SIZE: () => BINARY_CHECK_SAMPLE_SIZE,
|
|
534
|
+
CONTENT_DETECTION_SAMPLE_SIZE: () => CONTENT_DETECTION_SAMPLE_SIZE,
|
|
535
|
+
CORS_ORIGINS: () => CORS_ORIGINS,
|
|
536
|
+
DEFAULT_API_PORT: () => DEFAULT_API_PORT,
|
|
537
|
+
DEFAULT_CLM_TIMEOUT_MS: () => DEFAULT_CLM_TIMEOUT_MS,
|
|
538
|
+
DEFAULT_EMBEDDING_MODEL: () => DEFAULT_EMBEDDING_MODEL,
|
|
539
|
+
DEFAULT_EXECUTION_LOG_PATH: () => DEFAULT_EXECUTION_LOG_PATH,
|
|
540
|
+
DEFAULT_IDENTITY_PROVIDER: () => DEFAULT_IDENTITY_PROVIDER,
|
|
541
|
+
DEFAULT_IDENTITY_SPACE_PATH: () => DEFAULT_IDENTITY_SPACE_PATH,
|
|
542
|
+
DEFAULT_JS_API_PORT: () => DEFAULT_JS_API_PORT,
|
|
543
|
+
DEFAULT_LMSTUDIO_BASE_URL: () => DEFAULT_LMSTUDIO_BASE_URL,
|
|
544
|
+
DEFAULT_MAX_ETA_STEPS: () => DEFAULT_MAX_ETA_STEPS,
|
|
545
|
+
DEFAULT_MAX_INTROSPECTION_DEPTH: () => DEFAULT_MAX_INTROSPECTION_DEPTH,
|
|
546
|
+
DEFAULT_MAX_PROBLEM_BYTES: () => DEFAULT_MAX_PROBLEM_BYTES,
|
|
547
|
+
DEFAULT_MAX_REDUCTION_STEPS: () => DEFAULT_MAX_REDUCTION_STEPS,
|
|
548
|
+
DEFAULT_OLLAMA_BASE_URL: () => DEFAULT_OLLAMA_BASE_URL,
|
|
549
|
+
DEFAULT_OTLP_ENDPOINT: () => DEFAULT_OTLP_ENDPOINT,
|
|
550
|
+
DEFAULT_PAGE_SIZE: () => DEFAULT_PAGE_SIZE,
|
|
551
|
+
DEFAULT_PYTHON_API_PORT: () => DEFAULT_PYTHON_API_PORT,
|
|
552
|
+
DEFAULT_SANDBOX_TIMEOUT_MS: () => DEFAULT_SANDBOX_TIMEOUT_MS,
|
|
553
|
+
DEFAULT_SERVER_HOST: () => DEFAULT_SERVER_HOST,
|
|
554
|
+
DEFAULT_SQLJS_WASM_URL: () => DEFAULT_SQLJS_WASM_URL,
|
|
555
|
+
DEFAULT_VISION_MODEL: () => DEFAULT_VISION_MODEL,
|
|
556
|
+
DEFAULT_VLLM_BASE_URL: () => DEFAULT_VLLM_BASE_URL,
|
|
557
|
+
DEFAULT_VM_EXECUTION_TIMEOUT_MS: () => DEFAULT_VM_EXECUTION_TIMEOUT_MS,
|
|
558
|
+
DEFAULT_WS_HOST: () => DEFAULT_WS_HOST,
|
|
559
|
+
DEFAULT_WS_PORT: () => DEFAULT_WS_PORT,
|
|
560
|
+
DEFAULT_WS_RECONNECT_MS: () => DEFAULT_WS_RECONNECT_MS,
|
|
561
|
+
DETECTION_SAMPLE_CAP: () => DETECTION_SAMPLE_CAP,
|
|
562
|
+
EMBEDDING_MODELS: () => EMBEDDING_MODELS,
|
|
563
|
+
ENV_API_PORT: () => ENV_API_PORT,
|
|
564
|
+
ENV_WS_PORT: () => ENV_WS_PORT,
|
|
565
|
+
INDEXEDDB_DEFAULT_DB_NAME: () => INDEXEDDB_DEFAULT_DB_NAME,
|
|
566
|
+
INDEXEDDB_DEFAULT_DB_VERSION: () => INDEXEDDB_DEFAULT_DB_VERSION,
|
|
567
|
+
KNOWN_TYPE_SIZE_LIMIT: () => KNOWN_TYPE_SIZE_LIMIT,
|
|
568
|
+
LLM_DEFAULT_RETRY_COUNT: () => LLM_DEFAULT_RETRY_COUNT,
|
|
569
|
+
LLM_DEFAULT_RETRY_DELAY_SECS: () => LLM_DEFAULT_RETRY_DELAY_SECS,
|
|
570
|
+
LLM_DEFAULT_TIMEOUT_SECS: () => LLM_DEFAULT_TIMEOUT_SECS,
|
|
571
|
+
MAX_FILE_SIZE: () => MAX_FILE_SIZE,
|
|
572
|
+
MAX_PAGE_SIZE: () => MAX_PAGE_SIZE,
|
|
573
|
+
MAX_VECTOR_CONTENT_CHARS: () => MAX_VECTOR_CONTENT_CHARS,
|
|
574
|
+
MIN_PAGE_SIZE: () => MIN_PAGE_SIZE,
|
|
575
|
+
READ_CHUNK_SIZE: () => READ_CHUNK_SIZE,
|
|
576
|
+
READ_TIMEOUT_MS: () => READ_TIMEOUT_MS,
|
|
577
|
+
SQLITE_BUSY_TIMEOUT_MS: () => SQLITE_BUSY_TIMEOUT_MS,
|
|
578
|
+
VISION_MODELS: () => VISION_MODELS,
|
|
579
|
+
WRAP_WIDTH_KNOWN: () => WRAP_WIDTH_KNOWN
|
|
580
|
+
});
|
|
581
|
+
var network, identity, services, web, DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE, MIN_PAGE_SIZE, DETECTION_SAMPLE_CAP, MAX_FILE_SIZE, READ_TIMEOUT_MS, READ_CHUNK_SIZE, KNOWN_TYPE_SIZE_LIMIT, BINARY_CHECK_SAMPLE_SIZE, CONTENT_DETECTION_SAMPLE_SIZE, MAX_VECTOR_CONTENT_CHARS, DEFAULT_MAX_PROBLEM_BYTES, WRAP_WIDTH_KNOWN, INDEXEDDB_DEFAULT_DB_NAME, INDEXEDDB_DEFAULT_DB_VERSION, SQLITE_BUSY_TIMEOUT_MS, DEFAULT_IDENTITY_PROVIDER, DEFAULT_IDENTITY_SPACE_PATH, DEFAULT_EXECUTION_LOG_PATH, DEFAULT_API_PORT, DEFAULT_PYTHON_API_PORT, DEFAULT_JS_API_PORT, ENV_API_PORT, DEFAULT_WS_PORT, DEFAULT_WS_HOST, DEFAULT_SERVER_HOST, CORS_ORIGINS, ENV_WS_PORT, getEnvUrl, API_KEY_HEADER_NAME, DEFAULT_OLLAMA_BASE_URL, DEFAULT_OTLP_ENDPOINT, DEFAULT_VLLM_BASE_URL, DEFAULT_LMSTUDIO_BASE_URL, DEFAULT_SQLJS_WASM_URL, EMBEDDING_MODELS, DEFAULT_EMBEDDING_MODEL, VISION_MODELS, DEFAULT_VISION_MODEL, DEFAULT_SANDBOX_TIMEOUT_MS, DEFAULT_CLM_TIMEOUT_MS, DEFAULT_VM_EXECUTION_TIMEOUT_MS, LLM_DEFAULT_TIMEOUT_SECS, LLM_DEFAULT_RETRY_COUNT, LLM_DEFAULT_RETRY_DELAY_SECS, DEFAULT_WS_RECONNECT_MS, DEFAULT_MAX_REDUCTION_STEPS, DEFAULT_MAX_ETA_STEPS, DEFAULT_MAX_INTROSPECTION_DEPTH;
|
|
531
582
|
var init_constants = __esm({
|
|
532
583
|
"src/config/constants.ts"() {
|
|
533
584
|
"use strict";
|
|
@@ -537,25 +588,33 @@ var init_constants = __esm({
|
|
|
537
588
|
services = app_config_default.services ?? {};
|
|
538
589
|
web = app_config_default.web ?? {};
|
|
539
590
|
DEFAULT_PAGE_SIZE = 10;
|
|
591
|
+
MAX_PAGE_SIZE = 1e3;
|
|
592
|
+
MIN_PAGE_SIZE = 1;
|
|
593
|
+
DETECTION_SAMPLE_CAP = 8192;
|
|
540
594
|
MAX_FILE_SIZE = typeof process !== "undefined" && process.env.MCARD_MAX_SIZE_BYTES ? parseInt(process.env.MCARD_MAX_SIZE_BYTES, 10) : 150 * 1024 * 1024;
|
|
541
595
|
READ_TIMEOUT_MS = 5e3;
|
|
596
|
+
READ_CHUNK_SIZE = 8192;
|
|
542
597
|
KNOWN_TYPE_SIZE_LIMIT = 1024 * 1024;
|
|
543
598
|
BINARY_CHECK_SAMPLE_SIZE = 32 * 1024;
|
|
544
599
|
CONTENT_DETECTION_SAMPLE_SIZE = 1024 * 1024;
|
|
600
|
+
MAX_VECTOR_CONTENT_CHARS = 1e4;
|
|
545
601
|
DEFAULT_MAX_PROBLEM_BYTES = 2 * 1024 * 1024;
|
|
602
|
+
WRAP_WIDTH_KNOWN = 1e3;
|
|
546
603
|
INDEXEDDB_DEFAULT_DB_NAME = "mcard-db";
|
|
547
604
|
INDEXEDDB_DEFAULT_DB_VERSION = 1;
|
|
548
605
|
SQLITE_BUSY_TIMEOUT_MS = 5e3;
|
|
549
606
|
DEFAULT_IDENTITY_PROVIDER = String(identity.provider ?? "sqlite");
|
|
550
|
-
DEFAULT_IDENTITY_SPACE_PATH = String(identity.space_path ?? "./data/
|
|
607
|
+
DEFAULT_IDENTITY_SPACE_PATH = String(identity.space_path ?? "./data/agent_identities.db");
|
|
608
|
+
DEFAULT_EXECUTION_LOG_PATH = String(app_config_default.storage?.default_execution_log_path ?? "./data/execution_log.db");
|
|
551
609
|
DEFAULT_API_PORT = Number(network.default_api_port ?? 5320);
|
|
552
610
|
DEFAULT_PYTHON_API_PORT = Number(network.default_python_api_port ?? 28302);
|
|
553
611
|
DEFAULT_JS_API_PORT = Number(network.default_js_api_port ?? 28303);
|
|
554
|
-
|
|
612
|
+
ENV_API_PORT = "MCARD_API_PORT";
|
|
555
613
|
DEFAULT_WS_PORT = Number(network.default_ws_port ?? 5321);
|
|
556
614
|
DEFAULT_WS_HOST = String(network.default_ws_host ?? "127.0.0.1");
|
|
557
615
|
DEFAULT_SERVER_HOST = String(network.default_server_host ?? "0.0.0.0");
|
|
558
616
|
CORS_ORIGINS = Array.isArray(network.cors_origins) ? network.cors_origins : [];
|
|
617
|
+
ENV_WS_PORT = "MCARD_WS_PORT";
|
|
559
618
|
getEnvUrl = (key, fallback) => {
|
|
560
619
|
try {
|
|
561
620
|
if (typeof process !== "undefined" && process.env && process.env[key]) {
|
|
@@ -583,12 +642,66 @@ var init_constants = __esm({
|
|
|
583
642
|
String(services.default_lmstudio_base_url ?? "http://localhost:1234")
|
|
584
643
|
);
|
|
585
644
|
DEFAULT_SQLJS_WASM_URL = "https://sql.js.org/dist/";
|
|
645
|
+
EMBEDDING_MODELS = {
|
|
646
|
+
"nomic-embed-text": {
|
|
647
|
+
dimensions: 768,
|
|
648
|
+
provider: "ollama",
|
|
649
|
+
max_tokens: 8192,
|
|
650
|
+
description: "High quality, general purpose embeddings"
|
|
651
|
+
},
|
|
652
|
+
"bge-m3": {
|
|
653
|
+
dimensions: 1024,
|
|
654
|
+
provider: "ollama",
|
|
655
|
+
max_tokens: 8192,
|
|
656
|
+
description: "Multi-lingual, multi-granularity embeddings"
|
|
657
|
+
},
|
|
658
|
+
"mxbai-embed-large": {
|
|
659
|
+
dimensions: 1024,
|
|
660
|
+
provider: "ollama",
|
|
661
|
+
max_tokens: 512,
|
|
662
|
+
description: "High quality embeddings for retrieval"
|
|
663
|
+
},
|
|
664
|
+
"all-minilm": {
|
|
665
|
+
dimensions: 384,
|
|
666
|
+
provider: "ollama",
|
|
667
|
+
max_tokens: 256,
|
|
668
|
+
description: "Fast, lightweight embeddings"
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
DEFAULT_EMBEDDING_MODEL = "nomic-embed-text";
|
|
672
|
+
VISION_MODELS = {
|
|
673
|
+
"moondream": {
|
|
674
|
+
size: "1.7GB",
|
|
675
|
+
description: "Moondream - Tiny, high-performance vision language model",
|
|
676
|
+
capabilities: ["image_description", "visual_qa"]
|
|
677
|
+
},
|
|
678
|
+
"llama3.2-vision": {
|
|
679
|
+
size: "7.9GB",
|
|
680
|
+
description: "Llama 3.2 Vision - 11B multimodal model with strong OCR",
|
|
681
|
+
capabilities: ["image_description", "ocr", "visual_qa"]
|
|
682
|
+
},
|
|
683
|
+
"llava": {
|
|
684
|
+
size: "4.7GB",
|
|
685
|
+
description: "LLaVA - Large Language and Vision Assistant",
|
|
686
|
+
capabilities: ["image_description", "visual_qa"]
|
|
687
|
+
},
|
|
688
|
+
"minicpm-v": {
|
|
689
|
+
size: "5.6GB",
|
|
690
|
+
description: "MiniCPM-V - Efficient vision-language model",
|
|
691
|
+
capabilities: ["image_description", "ocr", "multi_image"]
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
DEFAULT_VISION_MODEL = "moondream";
|
|
586
695
|
DEFAULT_SANDBOX_TIMEOUT_MS = 5e3;
|
|
587
696
|
DEFAULT_CLM_TIMEOUT_MS = 5e3;
|
|
588
697
|
DEFAULT_VM_EXECUTION_TIMEOUT_MS = 5e3;
|
|
589
698
|
LLM_DEFAULT_TIMEOUT_SECS = 120;
|
|
590
699
|
LLM_DEFAULT_RETRY_COUNT = 3;
|
|
591
700
|
LLM_DEFAULT_RETRY_DELAY_SECS = 1;
|
|
701
|
+
DEFAULT_WS_RECONNECT_MS = 3e3;
|
|
702
|
+
DEFAULT_MAX_REDUCTION_STEPS = 1e3;
|
|
703
|
+
DEFAULT_MAX_ETA_STEPS = 100;
|
|
704
|
+
DEFAULT_MAX_INTROSPECTION_DEPTH = 100;
|
|
592
705
|
}
|
|
593
706
|
});
|
|
594
707
|
|
|
@@ -2100,6 +2213,87 @@ var init_SqliteNodeEngine2 = __esm({
|
|
|
2100
2213
|
}
|
|
2101
2214
|
});
|
|
2102
2215
|
|
|
2216
|
+
// src/storage/EngineRegistry.ts
|
|
2217
|
+
var EngineRegistry_exports = {};
|
|
2218
|
+
__export(EngineRegistry_exports, {
|
|
2219
|
+
ENGINE_INFO: () => ENGINE_INFO,
|
|
2220
|
+
EngineType: () => EngineType,
|
|
2221
|
+
createEngine: () => createEngine,
|
|
2222
|
+
getAvailableEngines: () => getAvailableEngines,
|
|
2223
|
+
getEngineInfo: () => getEngineInfo,
|
|
2224
|
+
getEnginesByEnvironment: () => getEnginesByEnvironment
|
|
2225
|
+
});
|
|
2226
|
+
async function createEngine(type, options = {}) {
|
|
2227
|
+
switch (type) {
|
|
2228
|
+
case "indexeddb" /* INDEXED_DB */: {
|
|
2229
|
+
const { IndexedDBEngine: IndexedDBEngine2 } = await Promise.resolve().then(() => (init_IndexedDBEngine2(), IndexedDBEngine_exports));
|
|
2230
|
+
const engine = new IndexedDBEngine2();
|
|
2231
|
+
await engine.init();
|
|
2232
|
+
return engine;
|
|
2233
|
+
}
|
|
2234
|
+
case "sqlite-node" /* SQLITE_NODE */: {
|
|
2235
|
+
const { SqliteNodeEngine: SqliteNodeEngine2 } = await Promise.resolve().then(() => (init_SqliteNodeEngine2(), SqliteNodeEngine_exports));
|
|
2236
|
+
return SqliteNodeEngine2.create(options.dbPath || ":memory:");
|
|
2237
|
+
}
|
|
2238
|
+
case "sqlite-wasm" /* SQLITE_WASM */: {
|
|
2239
|
+
const { SqliteWasmEngine: SqliteWasmEngine2 } = await Promise.resolve().then(() => (init_SqliteWasmEngine2(), SqliteWasmEngine_exports));
|
|
2240
|
+
const engine = new SqliteWasmEngine2();
|
|
2241
|
+
await engine.init(options.wasmUrl, options.existingData);
|
|
2242
|
+
return engine;
|
|
2243
|
+
}
|
|
2244
|
+
default: {
|
|
2245
|
+
const validTypes = Object.values(EngineType).join(", ");
|
|
2246
|
+
throw new Error(
|
|
2247
|
+
`Unknown engine type: "${type}". Valid types: ${validTypes}`
|
|
2248
|
+
);
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
function getAvailableEngines() {
|
|
2253
|
+
return Object.values(EngineType);
|
|
2254
|
+
}
|
|
2255
|
+
function getEngineInfo(type) {
|
|
2256
|
+
return ENGINE_INFO[type];
|
|
2257
|
+
}
|
|
2258
|
+
function getEnginesByEnvironment(env) {
|
|
2259
|
+
return Object.values(ENGINE_INFO).filter((info) => info.environment === env);
|
|
2260
|
+
}
|
|
2261
|
+
var EngineType, ENGINE_INFO;
|
|
2262
|
+
var init_EngineRegistry = __esm({
|
|
2263
|
+
"src/storage/EngineRegistry.ts"() {
|
|
2264
|
+
"use strict";
|
|
2265
|
+
EngineType = /* @__PURE__ */ ((EngineType2) => {
|
|
2266
|
+
EngineType2["INDEXED_DB"] = "indexeddb";
|
|
2267
|
+
EngineType2["SQLITE_NODE"] = "sqlite-node";
|
|
2268
|
+
EngineType2["SQLITE_WASM"] = "sqlite-wasm";
|
|
2269
|
+
return EngineType2;
|
|
2270
|
+
})(EngineType || {});
|
|
2271
|
+
ENGINE_INFO = {
|
|
2272
|
+
["indexeddb" /* INDEXED_DB */]: {
|
|
2273
|
+
type: "indexeddb" /* INDEXED_DB */,
|
|
2274
|
+
displayName: "IndexedDB",
|
|
2275
|
+
environment: "browser",
|
|
2276
|
+
package: null,
|
|
2277
|
+
description: "Browser-native IndexedDB key-value store"
|
|
2278
|
+
},
|
|
2279
|
+
["sqlite-node" /* SQLITE_NODE */]: {
|
|
2280
|
+
type: "sqlite-node" /* SQLITE_NODE */,
|
|
2281
|
+
displayName: "SQLite (Node.js)",
|
|
2282
|
+
environment: "node",
|
|
2283
|
+
package: "better-sqlite3",
|
|
2284
|
+
description: "SQLite via native better-sqlite3 bindings"
|
|
2285
|
+
},
|
|
2286
|
+
["sqlite-wasm" /* SQLITE_WASM */]: {
|
|
2287
|
+
type: "sqlite-wasm" /* SQLITE_WASM */,
|
|
2288
|
+
displayName: "SQLite (WASM)",
|
|
2289
|
+
environment: "browser",
|
|
2290
|
+
package: "sql.js",
|
|
2291
|
+
description: "SQLite via sql.js WebAssembly"
|
|
2292
|
+
}
|
|
2293
|
+
};
|
|
2294
|
+
}
|
|
2295
|
+
});
|
|
2296
|
+
|
|
2103
2297
|
// src/monads/Either.ts
|
|
2104
2298
|
var Either;
|
|
2105
2299
|
var init_Either = __esm({
|
|
@@ -2439,7 +2633,7 @@ async function processAndStoreFile(filePath, collection, options = {}) {
|
|
|
2439
2633
|
}
|
|
2440
2634
|
const extension = path2.extname(filePath).toLowerCase();
|
|
2441
2635
|
const isKnownType = ContentTypeInterpreter.isKnownLongLineExtension(extension);
|
|
2442
|
-
const wrapWidth = isKnownType ?
|
|
2636
|
+
const wrapWidth = isKnownType ? WRAP_WIDTH_KNOWN2 : WRAP_WIDTH_DEFAULT;
|
|
2443
2637
|
Logger.warn(`Problematic file detected, processing as safe text: ${filePath}`);
|
|
2444
2638
|
try {
|
|
2445
2639
|
const streamed = await streamReadNormalizedText(filePath, {
|
|
@@ -2583,7 +2777,7 @@ async function loadFileToCollection(targetPath, collection, options = {}) {
|
|
|
2583
2777
|
}
|
|
2584
2778
|
return { metrics, results };
|
|
2585
2779
|
}
|
|
2586
|
-
var fs2, path2, DEFAULT_MAX_PROBLEM_BYTES2,
|
|
2780
|
+
var fs2, path2, DEFAULT_MAX_PROBLEM_BYTES2, WRAP_WIDTH_KNOWN2, WRAP_WIDTH_DEFAULT, Logger;
|
|
2587
2781
|
var init_Loader = __esm({
|
|
2588
2782
|
"src/Loader.ts"() {
|
|
2589
2783
|
"use strict";
|
|
@@ -2593,7 +2787,7 @@ var init_Loader = __esm({
|
|
|
2593
2787
|
init_FileIO();
|
|
2594
2788
|
init_ContentTypeInterpreter();
|
|
2595
2789
|
DEFAULT_MAX_PROBLEM_BYTES2 = 2 * 1024 * 1024;
|
|
2596
|
-
|
|
2790
|
+
WRAP_WIDTH_KNOWN2 = 1e3;
|
|
2597
2791
|
WRAP_WIDTH_DEFAULT = 80;
|
|
2598
2792
|
Logger = {
|
|
2599
2793
|
info: (...args) => console.log("[Loader]", ...args),
|
|
@@ -3354,7 +3548,8 @@ var init_LLMRuntime = __esm({
|
|
|
3354
3548
|
}
|
|
3355
3549
|
const concrete = config;
|
|
3356
3550
|
const llmConfig = LLMConfig.from_concrete(concrete, configCtx);
|
|
3357
|
-
if (llmConfig.provider !== this.provider_name) {
|
|
3551
|
+
if (llmConfig.provider !== this.provider_name || llmConfig.endpoint_url) {
|
|
3552
|
+
this.provider_name = llmConfig.provider;
|
|
3358
3553
|
this._provider = get_provider(llmConfig.provider, llmConfig.endpoint_url, llmConfig.timeout);
|
|
3359
3554
|
}
|
|
3360
3555
|
let prompt = "";
|
|
@@ -7591,74 +7786,7 @@ init_constants2();
|
|
|
7591
7786
|
init_IndexedDBEngine2();
|
|
7592
7787
|
init_SqliteWasmEngine2();
|
|
7593
7788
|
init_SqliteNodeEngine2();
|
|
7594
|
-
|
|
7595
|
-
// src/storage/EngineRegistry.ts
|
|
7596
|
-
var EngineType = /* @__PURE__ */ ((EngineType2) => {
|
|
7597
|
-
EngineType2["INDEXED_DB"] = "indexeddb";
|
|
7598
|
-
EngineType2["SQLITE_NODE"] = "sqlite-node";
|
|
7599
|
-
EngineType2["SQLITE_WASM"] = "sqlite-wasm";
|
|
7600
|
-
return EngineType2;
|
|
7601
|
-
})(EngineType || {});
|
|
7602
|
-
var ENGINE_INFO = {
|
|
7603
|
-
["indexeddb" /* INDEXED_DB */]: {
|
|
7604
|
-
type: "indexeddb" /* INDEXED_DB */,
|
|
7605
|
-
displayName: "IndexedDB",
|
|
7606
|
-
environment: "browser",
|
|
7607
|
-
package: null,
|
|
7608
|
-
description: "Browser-native IndexedDB key-value store"
|
|
7609
|
-
},
|
|
7610
|
-
["sqlite-node" /* SQLITE_NODE */]: {
|
|
7611
|
-
type: "sqlite-node" /* SQLITE_NODE */,
|
|
7612
|
-
displayName: "SQLite (Node.js)",
|
|
7613
|
-
environment: "node",
|
|
7614
|
-
package: "better-sqlite3",
|
|
7615
|
-
description: "SQLite via native better-sqlite3 bindings"
|
|
7616
|
-
},
|
|
7617
|
-
["sqlite-wasm" /* SQLITE_WASM */]: {
|
|
7618
|
-
type: "sqlite-wasm" /* SQLITE_WASM */,
|
|
7619
|
-
displayName: "SQLite (WASM)",
|
|
7620
|
-
environment: "browser",
|
|
7621
|
-
package: "sql.js",
|
|
7622
|
-
description: "SQLite via sql.js WebAssembly"
|
|
7623
|
-
}
|
|
7624
|
-
};
|
|
7625
|
-
async function createEngine(type, options = {}) {
|
|
7626
|
-
switch (type) {
|
|
7627
|
-
case "indexeddb" /* INDEXED_DB */: {
|
|
7628
|
-
const { IndexedDBEngine: IndexedDBEngine2 } = await Promise.resolve().then(() => (init_IndexedDBEngine2(), IndexedDBEngine_exports));
|
|
7629
|
-
const engine = new IndexedDBEngine2();
|
|
7630
|
-
await engine.init();
|
|
7631
|
-
return engine;
|
|
7632
|
-
}
|
|
7633
|
-
case "sqlite-node" /* SQLITE_NODE */: {
|
|
7634
|
-
const { SqliteNodeEngine: SqliteNodeEngine2 } = await Promise.resolve().then(() => (init_SqliteNodeEngine2(), SqliteNodeEngine_exports));
|
|
7635
|
-
return SqliteNodeEngine2.create(options.dbPath || ":memory:");
|
|
7636
|
-
}
|
|
7637
|
-
case "sqlite-wasm" /* SQLITE_WASM */: {
|
|
7638
|
-
const { SqliteWasmEngine: SqliteWasmEngine2 } = await Promise.resolve().then(() => (init_SqliteWasmEngine2(), SqliteWasmEngine_exports));
|
|
7639
|
-
const engine = new SqliteWasmEngine2();
|
|
7640
|
-
await engine.init(options.wasmUrl, options.existingData);
|
|
7641
|
-
return engine;
|
|
7642
|
-
}
|
|
7643
|
-
default: {
|
|
7644
|
-
const validTypes = Object.values(EngineType).join(", ");
|
|
7645
|
-
throw new Error(
|
|
7646
|
-
`Unknown engine type: "${type}". Valid types: ${validTypes}`
|
|
7647
|
-
);
|
|
7648
|
-
}
|
|
7649
|
-
}
|
|
7650
|
-
}
|
|
7651
|
-
function getAvailableEngines() {
|
|
7652
|
-
return Object.values(EngineType);
|
|
7653
|
-
}
|
|
7654
|
-
function getEngineInfo(type) {
|
|
7655
|
-
return ENGINE_INFO[type];
|
|
7656
|
-
}
|
|
7657
|
-
function getEnginesByEnvironment(env) {
|
|
7658
|
-
return Object.values(ENGINE_INFO).filter((info) => info.environment === env);
|
|
7659
|
-
}
|
|
7660
|
-
|
|
7661
|
-
// src/index.ts
|
|
7789
|
+
init_EngineRegistry();
|
|
7662
7790
|
init_HashValidator();
|
|
7663
7791
|
init_Maybe();
|
|
7664
7792
|
init_Either();
|
|
@@ -9740,6 +9868,9 @@ var VCardSimulation = class {
|
|
|
9740
9868
|
}
|
|
9741
9869
|
};
|
|
9742
9870
|
|
|
9871
|
+
// src/ptr/node/PTREngine.ts
|
|
9872
|
+
init_CardCollection();
|
|
9873
|
+
|
|
9743
9874
|
// src/ptr/node/clm/runner.ts
|
|
9744
9875
|
var path14 = __toESM(require("path"), 1);
|
|
9745
9876
|
var yaml2 = __toESM(require("yaml"), 1);
|
|
@@ -10915,7 +11046,8 @@ var CLMRunner = class _CLMRunner {
|
|
|
10915
11046
|
const examples = clm.examples || [];
|
|
10916
11047
|
const results = [];
|
|
10917
11048
|
for (const example of examples) {
|
|
10918
|
-
const
|
|
11049
|
+
const executionInput = example.assumption ?? example.input;
|
|
11050
|
+
const result = await this.executeCLM(clm, chapterDir, executionInput);
|
|
10919
11051
|
results.push({ name: example.name, result });
|
|
10920
11052
|
}
|
|
10921
11053
|
return results;
|
|
@@ -10927,7 +11059,7 @@ var CLMRunner = class _CLMRunner {
|
|
|
10927
11059
|
let passed = 0;
|
|
10928
11060
|
const summaryResults = results.map((res, index) => {
|
|
10929
11061
|
const example = clm.examples?.[index];
|
|
10930
|
-
const expected = example?.expected_output;
|
|
11062
|
+
const expected = example?.confirmation ?? example?.expected_output;
|
|
10931
11063
|
const resultContains = example?.result_contains;
|
|
10932
11064
|
let match = false;
|
|
10933
11065
|
if (resultContains !== void 0) {
|
|
@@ -10948,7 +11080,7 @@ var CLMRunner = class _CLMRunner {
|
|
|
10948
11080
|
return {
|
|
10949
11081
|
case: index + 1,
|
|
10950
11082
|
name: res.name,
|
|
10951
|
-
input: example?.input,
|
|
11083
|
+
input: example?.assumption ?? example?.input,
|
|
10952
11084
|
result: res.result.result,
|
|
10953
11085
|
error: res.result.error,
|
|
10954
11086
|
expected: resultContains !== void 0 ? `contains: ${resultContains}` : expected,
|
|
@@ -11149,21 +11281,41 @@ var CLMRunner = class _CLMRunner {
|
|
|
11149
11281
|
};
|
|
11150
11282
|
|
|
11151
11283
|
// src/ptr/node/PTREngine.ts
|
|
11152
|
-
var PTREngine = class {
|
|
11284
|
+
var PTREngine = class _PTREngine {
|
|
11153
11285
|
collection;
|
|
11154
11286
|
executionLog;
|
|
11287
|
+
identitySpace;
|
|
11155
11288
|
runner;
|
|
11156
11289
|
/**
|
|
11157
|
-
*
|
|
11290
|
+
* Async Factory for PTREngine to support automatic Tri-Database Isolation.
|
|
11291
|
+
*/
|
|
11292
|
+
static async create(storageCollection, executionLogCollection, identitySpaceCollection, options) {
|
|
11293
|
+
if (!executionLogCollection) {
|
|
11294
|
+
const { createEngine: createEngine2, EngineType: EngineType2 } = await Promise.resolve().then(() => (init_EngineRegistry(), EngineRegistry_exports));
|
|
11295
|
+
const { DEFAULT_EXECUTION_LOG_PATH: DEFAULT_EXECUTION_LOG_PATH2 } = await Promise.resolve().then(() => (init_constants(), constants_exports));
|
|
11296
|
+
const engine = await createEngine2(EngineType2.SQLITE_NODE, { dbPath: DEFAULT_EXECUTION_LOG_PATH2 });
|
|
11297
|
+
executionLogCollection = new CardCollection(engine);
|
|
11298
|
+
}
|
|
11299
|
+
if (!identitySpaceCollection) {
|
|
11300
|
+
const { createEngine: createEngine2, EngineType: EngineType2 } = await Promise.resolve().then(() => (init_EngineRegistry(), EngineRegistry_exports));
|
|
11301
|
+
const { DEFAULT_IDENTITY_SPACE_PATH: DEFAULT_IDENTITY_SPACE_PATH2 } = await Promise.resolve().then(() => (init_constants(), constants_exports));
|
|
11302
|
+
const engine = await createEngine2(EngineType2.SQLITE_NODE, { dbPath: DEFAULT_IDENTITY_SPACE_PATH2 });
|
|
11303
|
+
identitySpaceCollection = new CardCollection(engine);
|
|
11304
|
+
}
|
|
11305
|
+
return new _PTREngine(storageCollection, executionLogCollection, identitySpaceCollection, options);
|
|
11306
|
+
}
|
|
11307
|
+
/**
|
|
11308
|
+
* Initialize PTREngine. (Consider using PTREngine.create() for automatic database isolation)
|
|
11158
11309
|
*
|
|
11159
11310
|
* @param storageCollection - MCard collection for long-term knowledge (mcard_collection.db)
|
|
11160
11311
|
* @param executionLogCollection - MCard collection for execution traces (execution_log.db).
|
|
11161
|
-
*
|
|
11312
|
+
* @param identitySpaceCollection - MCard collection for isolated Zero-Trust checks.
|
|
11162
11313
|
* @param options - Additional configuration
|
|
11163
11314
|
*/
|
|
11164
|
-
constructor(storageCollection, executionLogCollection, options) {
|
|
11315
|
+
constructor(storageCollection, executionLogCollection, identitySpaceCollection, options) {
|
|
11165
11316
|
this.collection = storageCollection;
|
|
11166
11317
|
this.executionLog = executionLogCollection || this.collection;
|
|
11318
|
+
this.identitySpace = identitySpaceCollection || this.collection;
|
|
11167
11319
|
this.runner = new CLMRunner(
|
|
11168
11320
|
options?.basePath || process.cwd(),
|
|
11169
11321
|
options?.timeout,
|
|
@@ -11188,11 +11340,18 @@ var PTREngine = class {
|
|
|
11188
11340
|
* @throws PreconditionViolation if preCheck returns false
|
|
11189
11341
|
* @throws PostconditionViolation if postCheck returns false
|
|
11190
11342
|
*/
|
|
11191
|
-
async runWithSandwich(pcardHash, inputHash, preCheck, postCheck) {
|
|
11343
|
+
async runWithSandwich(pcardHash, inputHash, preCheck, postCheck, context = {}) {
|
|
11192
11344
|
const pcard = await this.collection.get(pcardHash);
|
|
11193
11345
|
if (!pcard) throw new Error(`PCard not found: ${pcardHash}`);
|
|
11194
11346
|
const inputMCard = await this.collection.get(inputHash);
|
|
11195
11347
|
if (!inputMCard) throw new Error(`Input MCard not found: ${inputHash}`);
|
|
11348
|
+
const callerIdentity = context.caller_identity_hash;
|
|
11349
|
+
if (callerIdentity) {
|
|
11350
|
+
const identityRecord = await this.identitySpace.get(callerIdentity);
|
|
11351
|
+
if (!identityRecord) {
|
|
11352
|
+
throw new Error(`Zero-Trust AuthZ failed: Identity ${callerIdentity} invalid in agent_identities.db.`);
|
|
11353
|
+
}
|
|
11354
|
+
}
|
|
11196
11355
|
if (preCheck && !preCheck(inputMCard)) {
|
|
11197
11356
|
throw new PreconditionViolation(pcardHash, inputHash);
|
|
11198
11357
|
}
|
|
@@ -11231,10 +11390,17 @@ var PTREngine = class {
|
|
|
11231
11390
|
* @param context - Execution context (inputs)
|
|
11232
11391
|
* @returns Execution report with VCard Sandwich proof hashes
|
|
11233
11392
|
*/
|
|
11234
|
-
async runFile(filePath, context) {
|
|
11393
|
+
async runFile(filePath, context = {}) {
|
|
11235
11394
|
const loader = new CLMLoader(path15.dirname(filePath));
|
|
11236
11395
|
const clm = loader.load(filePath);
|
|
11237
11396
|
const chapterDir = path15.dirname(path15.resolve(filePath));
|
|
11397
|
+
const callerIdentity = context.caller_identity_hash;
|
|
11398
|
+
if (callerIdentity) {
|
|
11399
|
+
const identityRecord = await this.identitySpace.get(callerIdentity);
|
|
11400
|
+
if (!identityRecord) {
|
|
11401
|
+
throw new Error(`Zero-Trust AuthZ failed: Identity ${callerIdentity} invalid in agent_identities.db.`);
|
|
11402
|
+
}
|
|
11403
|
+
}
|
|
11238
11404
|
const clmContent = yaml3.stringify(clm);
|
|
11239
11405
|
const pcard = await PCard.create(clmContent);
|
|
11240
11406
|
if (this.collection) {
|
package/dist/index.d.cts
CHANGED
|
@@ -1544,16 +1544,24 @@ type PostCheck = (output: unknown) => boolean;
|
|
|
1544
1544
|
declare class PTREngine {
|
|
1545
1545
|
private collection;
|
|
1546
1546
|
private executionLog;
|
|
1547
|
+
private identitySpace;
|
|
1547
1548
|
private runner;
|
|
1548
1549
|
/**
|
|
1549
|
-
*
|
|
1550
|
+
* Async Factory for PTREngine to support automatic Tri-Database Isolation.
|
|
1551
|
+
*/
|
|
1552
|
+
static create(storageCollection?: CardCollection, executionLogCollection?: CardCollection, identitySpaceCollection?: CardCollection, options?: {
|
|
1553
|
+
basePath?: string;
|
|
1554
|
+
timeout?: number;
|
|
1555
|
+
}): Promise<PTREngine>;
|
|
1556
|
+
/**
|
|
1557
|
+
* Initialize PTREngine. (Consider using PTREngine.create() for automatic database isolation)
|
|
1550
1558
|
*
|
|
1551
1559
|
* @param storageCollection - MCard collection for long-term knowledge (mcard_collection.db)
|
|
1552
1560
|
* @param executionLogCollection - MCard collection for execution traces (execution_log.db).
|
|
1553
|
-
*
|
|
1561
|
+
* @param identitySpaceCollection - MCard collection for isolated Zero-Trust checks.
|
|
1554
1562
|
* @param options - Additional configuration
|
|
1555
1563
|
*/
|
|
1556
|
-
constructor(storageCollection?: CardCollection, executionLogCollection?: CardCollection, options?: {
|
|
1564
|
+
constructor(storageCollection?: CardCollection, executionLogCollection?: CardCollection, identitySpaceCollection?: CardCollection, options?: {
|
|
1557
1565
|
basePath?: string;
|
|
1558
1566
|
timeout?: number;
|
|
1559
1567
|
});
|
|
@@ -1571,7 +1579,7 @@ declare class PTREngine {
|
|
|
1571
1579
|
* @throws PreconditionViolation if preCheck returns false
|
|
1572
1580
|
* @throws PostconditionViolation if postCheck returns false
|
|
1573
1581
|
*/
|
|
1574
|
-
runWithSandwich(pcardHash: string, inputHash: string, preCheck?: PreCheck, postCheck?: PostCheck): Promise<[unknown, VCard]>;
|
|
1582
|
+
runWithSandwich(pcardHash: string, inputHash: string, preCheck?: PreCheck, postCheck?: PostCheck, context?: Record<string, any>): Promise<[unknown, VCard]>;
|
|
1575
1583
|
/**
|
|
1576
1584
|
* Execute a CLM specification from a YAML file.
|
|
1577
1585
|
*
|
|
@@ -1582,7 +1590,7 @@ declare class PTREngine {
|
|
|
1582
1590
|
* @param context - Execution context (inputs)
|
|
1583
1591
|
* @returns Execution report with VCard Sandwich proof hashes
|
|
1584
1592
|
*/
|
|
1585
|
-
runFile(filePath: string, context?: Record<string,
|
|
1593
|
+
runFile(filePath: string, context?: Record<string, any>): Promise<Record<string, unknown>>;
|
|
1586
1594
|
/**
|
|
1587
1595
|
* Arrow `arr` — lift a pure function into a PCard.
|
|
1588
1596
|
*
|
|
@@ -1686,7 +1694,9 @@ interface RuntimeConfig {
|
|
|
1686
1694
|
interface CLMExample {
|
|
1687
1695
|
name: string;
|
|
1688
1696
|
input?: unknown;
|
|
1697
|
+
assumption?: unknown;
|
|
1689
1698
|
expected_output?: unknown;
|
|
1699
|
+
confirmation?: unknown;
|
|
1690
1700
|
result_contains?: string;
|
|
1691
1701
|
[key: string]: unknown;
|
|
1692
1702
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1544,16 +1544,24 @@ type PostCheck = (output: unknown) => boolean;
|
|
|
1544
1544
|
declare class PTREngine {
|
|
1545
1545
|
private collection;
|
|
1546
1546
|
private executionLog;
|
|
1547
|
+
private identitySpace;
|
|
1547
1548
|
private runner;
|
|
1548
1549
|
/**
|
|
1549
|
-
*
|
|
1550
|
+
* Async Factory for PTREngine to support automatic Tri-Database Isolation.
|
|
1551
|
+
*/
|
|
1552
|
+
static create(storageCollection?: CardCollection, executionLogCollection?: CardCollection, identitySpaceCollection?: CardCollection, options?: {
|
|
1553
|
+
basePath?: string;
|
|
1554
|
+
timeout?: number;
|
|
1555
|
+
}): Promise<PTREngine>;
|
|
1556
|
+
/**
|
|
1557
|
+
* Initialize PTREngine. (Consider using PTREngine.create() for automatic database isolation)
|
|
1550
1558
|
*
|
|
1551
1559
|
* @param storageCollection - MCard collection for long-term knowledge (mcard_collection.db)
|
|
1552
1560
|
* @param executionLogCollection - MCard collection for execution traces (execution_log.db).
|
|
1553
|
-
*
|
|
1561
|
+
* @param identitySpaceCollection - MCard collection for isolated Zero-Trust checks.
|
|
1554
1562
|
* @param options - Additional configuration
|
|
1555
1563
|
*/
|
|
1556
|
-
constructor(storageCollection?: CardCollection, executionLogCollection?: CardCollection, options?: {
|
|
1564
|
+
constructor(storageCollection?: CardCollection, executionLogCollection?: CardCollection, identitySpaceCollection?: CardCollection, options?: {
|
|
1557
1565
|
basePath?: string;
|
|
1558
1566
|
timeout?: number;
|
|
1559
1567
|
});
|
|
@@ -1571,7 +1579,7 @@ declare class PTREngine {
|
|
|
1571
1579
|
* @throws PreconditionViolation if preCheck returns false
|
|
1572
1580
|
* @throws PostconditionViolation if postCheck returns false
|
|
1573
1581
|
*/
|
|
1574
|
-
runWithSandwich(pcardHash: string, inputHash: string, preCheck?: PreCheck, postCheck?: PostCheck): Promise<[unknown, VCard]>;
|
|
1582
|
+
runWithSandwich(pcardHash: string, inputHash: string, preCheck?: PreCheck, postCheck?: PostCheck, context?: Record<string, any>): Promise<[unknown, VCard]>;
|
|
1575
1583
|
/**
|
|
1576
1584
|
* Execute a CLM specification from a YAML file.
|
|
1577
1585
|
*
|
|
@@ -1582,7 +1590,7 @@ declare class PTREngine {
|
|
|
1582
1590
|
* @param context - Execution context (inputs)
|
|
1583
1591
|
* @returns Execution report with VCard Sandwich proof hashes
|
|
1584
1592
|
*/
|
|
1585
|
-
runFile(filePath: string, context?: Record<string,
|
|
1593
|
+
runFile(filePath: string, context?: Record<string, any>): Promise<Record<string, unknown>>;
|
|
1586
1594
|
/**
|
|
1587
1595
|
* Arrow `arr` — lift a pure function into a PCard.
|
|
1588
1596
|
*
|
|
@@ -1686,7 +1694,9 @@ interface RuntimeConfig {
|
|
|
1686
1694
|
interface CLMExample {
|
|
1687
1695
|
name: string;
|
|
1688
1696
|
input?: unknown;
|
|
1697
|
+
assumption?: unknown;
|
|
1689
1698
|
expected_output?: unknown;
|
|
1699
|
+
confirmation?: unknown;
|
|
1690
1700
|
result_contains?: string;
|
|
1691
1701
|
[key: string]: unknown;
|
|
1692
1702
|
}
|