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/index.js CHANGED
@@ -1,15 +1,23 @@
1
+ import {
2
+ ENGINE_INFO,
3
+ EngineType,
4
+ createEngine,
5
+ getAvailableEngines,
6
+ getEngineInfo,
7
+ getEnginesByEnvironment
8
+ } from "./chunk-VW3KBDK5.js";
1
9
  import {
2
10
  FileIO_exports,
3
11
  Loader_exports
4
- } from "./chunk-VYDZR4ZD.js";
12
+ } from "./chunk-CHXIVTQV.js";
5
13
  import {
6
14
  LLMRuntime,
7
15
  chatMonad,
8
16
  promptMonad
9
- } from "./chunk-KVZYFZJ5.js";
17
+ } from "./chunk-JUQ2VQZA.js";
10
18
  import {
11
19
  LLMConfig
12
- } from "./chunk-OUW2SUGM.js";
20
+ } from "./chunk-2APJYBH4.js";
13
21
  import {
14
22
  NETWORK_DEFAULT_HOST,
15
23
  PROCESS_TERMINATE_WAIT_MS,
@@ -61,7 +69,7 @@ import {
61
69
  storeTerm,
62
70
  termExists,
63
71
  termToMCard
64
- } from "./chunk-QKH3N62B.js";
72
+ } from "./chunk-NOPYSBOQ.js";
65
73
  import {
66
74
  ErrorCodes,
67
75
  FaroSidecar,
@@ -80,7 +88,11 @@ import {
80
88
  } from "./chunk-XJZOEM5F.js";
81
89
  import {
82
90
  IndexedDBEngine
83
- } from "./chunk-NGTY4P6A.js";
91
+ } from "./chunk-ZMK2HTZ5.js";
92
+ import {
93
+ CardCollection,
94
+ Maybe
95
+ } from "./chunk-VJPXJVEH.js";
84
96
  import {
85
97
  IO
86
98
  } from "./chunk-MPMRBT5R.js";
@@ -89,36 +101,32 @@ import {
89
101
  } from "./chunk-2KADE3SE.js";
90
102
  import {
91
103
  SqliteNodeEngine
92
- } from "./chunk-Z7EFXSTO.js";
104
+ } from "./chunk-5HRZV4R3.js";
93
105
  import {
94
106
  SqliteWasmEngine
95
- } from "./chunk-7AXRV7NS.js";
96
- import "./chunk-HIVVDGE5.js";
107
+ } from "./chunk-XETU7TV4.js";
108
+ import "./chunk-GIKMCG4D.js";
97
109
  import "./chunk-3EIBJPNF.js";
110
+ import {
111
+ ContentTypeInterpreter,
112
+ MCard,
113
+ createPCardDOTSMetadata,
114
+ createVCardDOTSMetadata
115
+ } from "./chunk-GGQCF7ZK.js";
98
116
  import {
99
117
  ContentHandle,
100
118
  HandleValidationError,
101
119
  init_Handle,
102
120
  validateHandle
103
121
  } from "./chunk-ADV52544.js";
104
- import {
105
- ALGORITHM_HIERARCHY,
106
- EVENT_CONSTANTS
107
- } from "./chunk-KEC7YFG3.js";
108
- import {
109
- CardCollection,
110
- Maybe
111
- } from "./chunk-QPVEUPMU.js";
112
122
  import {
113
123
  DEFAULT_CLM_TIMEOUT_MS,
114
124
  DEFAULT_SANDBOX_TIMEOUT_MS
115
- } from "./chunk-3FFEA2XK.js";
125
+ } from "./chunk-ETJWXHKZ.js";
116
126
  import {
117
- ContentTypeInterpreter,
118
- MCard,
119
- createPCardDOTSMetadata,
120
- createVCardDOTSMetadata
121
- } from "./chunk-GGQCF7ZK.js";
127
+ ALGORITHM_HIERARCHY,
128
+ EVENT_CONSTANTS
129
+ } from "./chunk-KEC7YFG3.js";
122
130
  import {
123
131
  GTime,
124
132
  HashValidator
@@ -130,72 +138,6 @@ import {
130
138
  // src/index.ts
131
139
  init_Handle();
132
140
 
133
- // src/storage/EngineRegistry.ts
134
- var EngineType = /* @__PURE__ */ ((EngineType2) => {
135
- EngineType2["INDEXED_DB"] = "indexeddb";
136
- EngineType2["SQLITE_NODE"] = "sqlite-node";
137
- EngineType2["SQLITE_WASM"] = "sqlite-wasm";
138
- return EngineType2;
139
- })(EngineType || {});
140
- var ENGINE_INFO = {
141
- ["indexeddb" /* INDEXED_DB */]: {
142
- type: "indexeddb" /* INDEXED_DB */,
143
- displayName: "IndexedDB",
144
- environment: "browser",
145
- package: null,
146
- description: "Browser-native IndexedDB key-value store"
147
- },
148
- ["sqlite-node" /* SQLITE_NODE */]: {
149
- type: "sqlite-node" /* SQLITE_NODE */,
150
- displayName: "SQLite (Node.js)",
151
- environment: "node",
152
- package: "better-sqlite3",
153
- description: "SQLite via native better-sqlite3 bindings"
154
- },
155
- ["sqlite-wasm" /* SQLITE_WASM */]: {
156
- type: "sqlite-wasm" /* SQLITE_WASM */,
157
- displayName: "SQLite (WASM)",
158
- environment: "browser",
159
- package: "sql.js",
160
- description: "SQLite via sql.js WebAssembly"
161
- }
162
- };
163
- async function createEngine(type, options = {}) {
164
- switch (type) {
165
- case "indexeddb" /* INDEXED_DB */: {
166
- const { IndexedDBEngine: IndexedDBEngine2 } = await import("./IndexedDBEngine-BWXAB46W.js");
167
- const engine = new IndexedDBEngine2();
168
- await engine.init();
169
- return engine;
170
- }
171
- case "sqlite-node" /* SQLITE_NODE */: {
172
- const { SqliteNodeEngine: SqliteNodeEngine2 } = await import("./storage/SqliteNodeEngine.js");
173
- return SqliteNodeEngine2.create(options.dbPath || ":memory:");
174
- }
175
- case "sqlite-wasm" /* SQLITE_WASM */: {
176
- const { SqliteWasmEngine: SqliteWasmEngine2 } = await import("./storage/SqliteWasmEngine.js");
177
- const engine = new SqliteWasmEngine2();
178
- await engine.init(options.wasmUrl, options.existingData);
179
- return engine;
180
- }
181
- default: {
182
- const validTypes = Object.values(EngineType).join(", ");
183
- throw new Error(
184
- `Unknown engine type: "${type}". Valid types: ${validTypes}`
185
- );
186
- }
187
- }
188
- }
189
- function getAvailableEngines() {
190
- return Object.values(EngineType);
191
- }
192
- function getEngineInfo(type) {
193
- return ENGINE_INFO[type];
194
- }
195
- function getEnginesByEnvironment(env) {
196
- return Object.values(ENGINE_INFO).filter((info) => info.environment === env);
197
- }
198
-
199
141
  // src/ptr/SandboxWorker.ts
200
142
  var WORKER_CODE = `
201
143
  // Multi-runtime sandboxed execution environment
@@ -1748,7 +1690,7 @@ async function runVersionExamples(examples) {
1748
1690
  }
1749
1691
  async function executeVersionSingle(handle, versions) {
1750
1692
  const { SqliteNodeEngine: SqliteNodeEngine2 } = await import("./storage/SqliteNodeEngine.js");
1751
- const { CardCollection: CardCollection2 } = await import("./CardCollection-ZQ3G3Q3A.js");
1693
+ const { CardCollection: CardCollection2 } = await import("./CardCollection-ORGE2XBG.js");
1752
1694
  const { MCard: MCard2 } = await import("./MCard-RHTWJPHJ.js");
1753
1695
  const engine = await SqliteNodeEngine2.create(":memory:");
1754
1696
  const collection = new CardCollection2(engine);
@@ -1809,7 +1751,7 @@ async function runPruneExamples(examples) {
1809
1751
  }
1810
1752
  async function executePruneSingle(handle, versions, pruneType, olderThanSeconds) {
1811
1753
  const { SqliteNodeEngine: SqliteNodeEngine2 } = await import("./storage/SqliteNodeEngine.js");
1812
- const { CardCollection: CardCollection2 } = await import("./CardCollection-ZQ3G3Q3A.js");
1754
+ const { CardCollection: CardCollection2 } = await import("./CardCollection-ORGE2XBG.js");
1813
1755
  const { MCard: MCard2 } = await import("./MCard-RHTWJPHJ.js");
1814
1756
  const engine = await SqliteNodeEngine2.create(":memory:");
1815
1757
  const collection = new CardCollection2(engine);
@@ -2733,7 +2675,8 @@ var CLMRunner = class _CLMRunner {
2733
2675
  const examples = clm.examples || [];
2734
2676
  const results = [];
2735
2677
  for (const example of examples) {
2736
- const result = await this.executeCLM(clm, chapterDir, example.input);
2678
+ const executionInput = example.assumption ?? example.input;
2679
+ const result = await this.executeCLM(clm, chapterDir, executionInput);
2737
2680
  results.push({ name: example.name, result });
2738
2681
  }
2739
2682
  return results;
@@ -2745,7 +2688,7 @@ var CLMRunner = class _CLMRunner {
2745
2688
  let passed = 0;
2746
2689
  const summaryResults = results.map((res, index) => {
2747
2690
  const example = clm.examples?.[index];
2748
- const expected = example?.expected_output;
2691
+ const expected = example?.confirmation ?? example?.expected_output;
2749
2692
  const resultContains = example?.result_contains;
2750
2693
  let match = false;
2751
2694
  if (resultContains !== void 0) {
@@ -2766,7 +2709,7 @@ var CLMRunner = class _CLMRunner {
2766
2709
  return {
2767
2710
  case: index + 1,
2768
2711
  name: res.name,
2769
- input: example?.input,
2712
+ input: example?.assumption ?? example?.input,
2770
2713
  result: res.result.result,
2771
2714
  error: res.result.error,
2772
2715
  expected: resultContains !== void 0 ? `contains: ${resultContains}` : expected,
@@ -2967,21 +2910,41 @@ var CLMRunner = class _CLMRunner {
2967
2910
  };
2968
2911
 
2969
2912
  // src/ptr/node/PTREngine.ts
2970
- var PTREngine = class {
2913
+ var PTREngine = class _PTREngine {
2971
2914
  collection;
2972
2915
  executionLog;
2916
+ identitySpace;
2973
2917
  runner;
2974
2918
  /**
2975
- * Initialize PTREngine.
2919
+ * Async Factory for PTREngine to support automatic Tri-Database Isolation.
2920
+ */
2921
+ static async create(storageCollection, executionLogCollection, identitySpaceCollection, options) {
2922
+ if (!executionLogCollection) {
2923
+ const { createEngine: createEngine2, EngineType: EngineType2 } = await import("./EngineRegistry-EIOT4MUZ.js");
2924
+ const { DEFAULT_EXECUTION_LOG_PATH } = await import("./constants-CLB7B6MN.js");
2925
+ const engine = await createEngine2(EngineType2.SQLITE_NODE, { dbPath: DEFAULT_EXECUTION_LOG_PATH });
2926
+ executionLogCollection = new CardCollection(engine);
2927
+ }
2928
+ if (!identitySpaceCollection) {
2929
+ const { createEngine: createEngine2, EngineType: EngineType2 } = await import("./EngineRegistry-EIOT4MUZ.js");
2930
+ const { DEFAULT_IDENTITY_SPACE_PATH } = await import("./constants-CLB7B6MN.js");
2931
+ const engine = await createEngine2(EngineType2.SQLITE_NODE, { dbPath: DEFAULT_IDENTITY_SPACE_PATH });
2932
+ identitySpaceCollection = new CardCollection(engine);
2933
+ }
2934
+ return new _PTREngine(storageCollection, executionLogCollection, identitySpaceCollection, options);
2935
+ }
2936
+ /**
2937
+ * Initialize PTREngine. (Consider using PTREngine.create() for automatic database isolation)
2976
2938
  *
2977
2939
  * @param storageCollection - MCard collection for long-term knowledge (mcard_collection.db)
2978
2940
  * @param executionLogCollection - MCard collection for execution traces (execution_log.db).
2979
- * If not provided, traces are written to storageCollection.
2941
+ * @param identitySpaceCollection - MCard collection for isolated Zero-Trust checks.
2980
2942
  * @param options - Additional configuration
2981
2943
  */
2982
- constructor(storageCollection, executionLogCollection, options) {
2944
+ constructor(storageCollection, executionLogCollection, identitySpaceCollection, options) {
2983
2945
  this.collection = storageCollection;
2984
2946
  this.executionLog = executionLogCollection || this.collection;
2947
+ this.identitySpace = identitySpaceCollection || this.collection;
2985
2948
  this.runner = new CLMRunner(
2986
2949
  options?.basePath || process.cwd(),
2987
2950
  options?.timeout,
@@ -3006,11 +2969,18 @@ var PTREngine = class {
3006
2969
  * @throws PreconditionViolation if preCheck returns false
3007
2970
  * @throws PostconditionViolation if postCheck returns false
3008
2971
  */
3009
- async runWithSandwich(pcardHash, inputHash, preCheck, postCheck) {
2972
+ async runWithSandwich(pcardHash, inputHash, preCheck, postCheck, context = {}) {
3010
2973
  const pcard = await this.collection.get(pcardHash);
3011
2974
  if (!pcard) throw new Error(`PCard not found: ${pcardHash}`);
3012
2975
  const inputMCard = await this.collection.get(inputHash);
3013
2976
  if (!inputMCard) throw new Error(`Input MCard not found: ${inputHash}`);
2977
+ const callerIdentity = context.caller_identity_hash;
2978
+ if (callerIdentity) {
2979
+ const identityRecord = await this.identitySpace.get(callerIdentity);
2980
+ if (!identityRecord) {
2981
+ throw new Error(`Zero-Trust AuthZ failed: Identity ${callerIdentity} invalid in agent_identities.db.`);
2982
+ }
2983
+ }
3014
2984
  if (preCheck && !preCheck(inputMCard)) {
3015
2985
  throw new PreconditionViolation(pcardHash, inputHash);
3016
2986
  }
@@ -3049,10 +3019,17 @@ var PTREngine = class {
3049
3019
  * @param context - Execution context (inputs)
3050
3020
  * @returns Execution report with VCard Sandwich proof hashes
3051
3021
  */
3052
- async runFile(filePath, context) {
3022
+ async runFile(filePath, context = {}) {
3053
3023
  const loader = new CLMLoader(path6.dirname(filePath));
3054
3024
  const clm = loader.load(filePath);
3055
3025
  const chapterDir = path6.dirname(path6.resolve(filePath));
3026
+ const callerIdentity = context.caller_identity_hash;
3027
+ if (callerIdentity) {
3028
+ const identityRecord = await this.identitySpace.get(callerIdentity);
3029
+ if (!identityRecord) {
3030
+ throw new Error(`Zero-Trust AuthZ failed: Identity ${callerIdentity} invalid in agent_identities.db.`);
3031
+ }
3032
+ }
3056
3033
  const clmContent = yaml3.stringify(clm);
3057
3034
  const pcard = await PCard.create(clmContent);
3058
3035
  if (this.collection) {
@@ -662,12 +662,12 @@ var app_config_default = {
662
662
  },
663
663
  identity: {
664
664
  provider: "sqlite",
665
- space_path: "./data/IDENTITY_SPACE.db",
665
+ space_path: "./data/agent_identities.db",
666
666
  api_endpoint: null,
667
667
  default_vapid_contact: "mailto:developer@example.com"
668
668
  },
669
669
  storage: {
670
- default_db_path: "./data/DEFAULT_DB_FILE.db",
670
+ default_db_path: "./data/content_memory.db",
671
671
  test_db_path: "./tests/data/test_mcard.db",
672
672
  default_data_root_dirname: "data",
673
673
  default_data_user: "guest",
@@ -677,7 +677,7 @@ var app_config_default = {
677
677
  default_mcard_db: "mcard.db",
678
678
  default_server_log_db: "server_log.db",
679
679
  default_push_subscriptions_file: "subscriptions.json",
680
- default_vcard_db_path: "data/vcard.db"
680
+ default_execution_log_path: "./data/execution_log.db"
681
681
  },
682
682
  services: {
683
683
  default_ollama_base_url: "http://localhost:11434",
@@ -727,11 +727,11 @@ var CONTENT_DETECTION_SAMPLE_SIZE = 1024 * 1024;
727
727
  var DEFAULT_MAX_PROBLEM_BYTES = 2 * 1024 * 1024;
728
728
  var SQLITE_BUSY_TIMEOUT_MS = 5e3;
729
729
  var DEFAULT_IDENTITY_PROVIDER = String(identity.provider ?? "sqlite");
730
- var DEFAULT_IDENTITY_SPACE_PATH = String(identity.space_path ?? "./data/IDENTITY_SPACE.db");
730
+ var DEFAULT_IDENTITY_SPACE_PATH = String(identity.space_path ?? "./data/agent_identities.db");
731
+ var DEFAULT_EXECUTION_LOG_PATH = String(app_config_default.storage?.default_execution_log_path ?? "./data/execution_log.db");
731
732
  var DEFAULT_API_PORT = Number(network.default_api_port ?? 5320);
732
733
  var DEFAULT_PYTHON_API_PORT = Number(network.default_python_api_port ?? 28302);
733
734
  var DEFAULT_JS_API_PORT = Number(network.default_js_api_port ?? 28303);
734
- var DEFAULT_VCARD_DB_PATH = String(app_config_default.storage?.default_vcard_db_path ?? "./data/vcard.db");
735
735
  var DEFAULT_WS_PORT = Number(network.default_ws_port ?? 5321);
736
736
  var DEFAULT_WS_HOST = String(network.default_ws_host ?? "127.0.0.1");
737
737
  var DEFAULT_SERVER_HOST = String(network.default_server_host ?? "0.0.0.0");
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  SqliteNodeEngine
3
- } from "../chunk-Z7EFXSTO.js";
4
- import "../chunk-HIVVDGE5.js";
3
+ } from "../chunk-5HRZV4R3.js";
4
+ import "../chunk-GIKMCG4D.js";
5
5
  import "../chunk-3EIBJPNF.js";
6
- import "../chunk-ADV52544.js";
7
- import "../chunk-3FFEA2XK.js";
8
6
  import "../chunk-GGQCF7ZK.js";
7
+ import "../chunk-ADV52544.js";
8
+ import "../chunk-ETJWXHKZ.js";
9
9
  import "../chunk-ASW6AOA7.js";
10
10
  import "../chunk-PNKVD2UK.js";
11
11
  export {
@@ -663,12 +663,12 @@ var app_config_default = {
663
663
  },
664
664
  identity: {
665
665
  provider: "sqlite",
666
- space_path: "./data/IDENTITY_SPACE.db",
666
+ space_path: "./data/agent_identities.db",
667
667
  api_endpoint: null,
668
668
  default_vapid_contact: "mailto:developer@example.com"
669
669
  },
670
670
  storage: {
671
- default_db_path: "./data/DEFAULT_DB_FILE.db",
671
+ default_db_path: "./data/content_memory.db",
672
672
  test_db_path: "./tests/data/test_mcard.db",
673
673
  default_data_root_dirname: "data",
674
674
  default_data_user: "guest",
@@ -678,7 +678,7 @@ var app_config_default = {
678
678
  default_mcard_db: "mcard.db",
679
679
  default_server_log_db: "server_log.db",
680
680
  default_push_subscriptions_file: "subscriptions.json",
681
- default_vcard_db_path: "data/vcard.db"
681
+ default_execution_log_path: "./data/execution_log.db"
682
682
  },
683
683
  services: {
684
684
  default_ollama_base_url: "http://localhost:11434",
@@ -727,11 +727,11 @@ var BINARY_CHECK_SAMPLE_SIZE = 32 * 1024;
727
727
  var CONTENT_DETECTION_SAMPLE_SIZE = 1024 * 1024;
728
728
  var DEFAULT_MAX_PROBLEM_BYTES = 2 * 1024 * 1024;
729
729
  var DEFAULT_IDENTITY_PROVIDER = String(identity.provider ?? "sqlite");
730
- var DEFAULT_IDENTITY_SPACE_PATH = String(identity.space_path ?? "./data/IDENTITY_SPACE.db");
730
+ var DEFAULT_IDENTITY_SPACE_PATH = String(identity.space_path ?? "./data/agent_identities.db");
731
+ var DEFAULT_EXECUTION_LOG_PATH = String(app_config_default.storage?.default_execution_log_path ?? "./data/execution_log.db");
731
732
  var DEFAULT_API_PORT = Number(network.default_api_port ?? 5320);
732
733
  var DEFAULT_PYTHON_API_PORT = Number(network.default_python_api_port ?? 28302);
733
734
  var DEFAULT_JS_API_PORT = Number(network.default_js_api_port ?? 28303);
734
- var DEFAULT_VCARD_DB_PATH = String(app_config_default.storage?.default_vcard_db_path ?? "./data/vcard.db");
735
735
  var DEFAULT_WS_PORT = Number(network.default_ws_port ?? 5321);
736
736
  var DEFAULT_WS_HOST = String(network.default_ws_host ?? "127.0.0.1");
737
737
  var DEFAULT_SERVER_HOST = String(network.default_server_host ?? "0.0.0.0");
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  SqliteWasmEngine
3
- } from "../chunk-7AXRV7NS.js";
4
- import "../chunk-HIVVDGE5.js";
3
+ } from "../chunk-XETU7TV4.js";
4
+ import "../chunk-GIKMCG4D.js";
5
5
  import "../chunk-3EIBJPNF.js";
6
- import "../chunk-ADV52544.js";
7
- import "../chunk-3FFEA2XK.js";
8
6
  import "../chunk-GGQCF7ZK.js";
7
+ import "../chunk-ADV52544.js";
8
+ import "../chunk-ETJWXHKZ.js";
9
9
  import "../chunk-ASW6AOA7.js";
10
10
  import "../chunk-PNKVD2UK.js";
11
11
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcard-js",
3
- "version": "2.1.49",
3
+ "version": "2.1.50",
4
4
  "description": "MCard - Content-addressable storage with cryptographic hashing, handle resolution, and vector search for Node.js and browsers",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",