@coreason-ai/coreason-manifest 0.49.10

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.
@@ -0,0 +1,8 @@
1
+ export * from './ontology';
2
+ import { ExecutionEnvelopeState } from './ontology';
3
+ /**
4
+ * Deterministically serializes an ExecutionEnvelopeState using a stable key-sorting algorithm.
5
+ * Guarantees RFC 8785 byte-for-byte serialization invariance when VSCode transmits JSON-RPC envelopes
6
+ * across the network, exactly matching Python's DeterministicTransportAdapter.
7
+ */
8
+ export declare function serializeEnvelope(envelope: ExecutionEnvelopeState): string;
package/dist/index.js ADDED
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ // Copyright (c) 2026 CoReason, Inc
3
+ // Licensed under the Prosperity Public License 3.0
4
+ // https://github.com/CoReason-AI/coreason-manifest
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ var __importDefault = (this && this.__importDefault) || function (mod) {
20
+ return (mod && mod.__esModule) ? mod : { "default": mod };
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.serializeEnvelope = serializeEnvelope;
24
+ __exportStar(require("./ontology"), exports);
25
+ const fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
26
+ /**
27
+ * AGENT INSTRUCTION: Recursively strips null and undefined values from the payload.
28
+ * Matches the exact physics of Python's `_canonicalize_payload` to guarantee that
29
+ * omitted properties do not fracture the RFC 8785 canonical hash.
30
+ */
31
+ function canonicalizePayload(obj) {
32
+ if (Array.isArray(obj)) {
33
+ return obj.map(canonicalizePayload);
34
+ }
35
+ else if (obj !== null && typeof obj === 'object') {
36
+ const newObj = {};
37
+ for (const key of Object.keys(obj)) {
38
+ const val = obj[key];
39
+ if (val !== null && val !== undefined) {
40
+ newObj[key] = canonicalizePayload(val);
41
+ }
42
+ }
43
+ return newObj;
44
+ }
45
+ return obj;
46
+ }
47
+ /**
48
+ * Deterministically serializes an ExecutionEnvelopeState using a stable key-sorting algorithm.
49
+ * Guarantees RFC 8785 byte-for-byte serialization invariance when VSCode transmits JSON-RPC envelopes
50
+ * across the network, exactly matching Python's DeterministicTransportAdapter.
51
+ */
52
+ function serializeEnvelope(envelope) {
53
+ // 1. Strip nulls to match Python's exclusion physics
54
+ const canonicalParams = canonicalizePayload(envelope);
55
+ // 2. Wrap in the JSON-RPC 2.0 Shell
56
+ const wrappedPayload = {
57
+ jsonrpc: "2.0",
58
+ method: "coreason_execute",
59
+ params: canonicalParams,
60
+ // Extract the trace_cid to use as the RPC request ID
61
+ id: canonicalParams.trace_context?.trace_cid || "unknown"
62
+ };
63
+ // 3. Deterministically sort keys and stringify
64
+ return (0, fast_json_stable_stringify_1.default)(wrappedPayload);
65
+ }