@sparkleideas/guidance 3.5.2-patch.1
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/README.md +1195 -0
- package/package.json +198 -0
- package/wasm-pkg/guidance_kernel.d.ts +53 -0
- package/wasm-pkg/guidance_kernel.js +320 -0
- package/wasm-pkg/guidance_kernel_bg.wasm +0 -0
- package/wasm-pkg/guidance_kernel_bg.wasm.d.ts +16 -0
- package/wasm-pkg/package.json +12 -0
package/package.json
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sparkleideas/guidance",
|
|
3
|
+
"version": "3.5.2-patch.1",
|
|
4
|
+
"description": "Guidance Control Plane - Compiles, retrieves, enforces, and evolves guidance rules for Claude Code sessions",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./compiler": {
|
|
14
|
+
"types": "./dist/compiler.d.ts",
|
|
15
|
+
"import": "./dist/compiler.js"
|
|
16
|
+
},
|
|
17
|
+
"./retriever": {
|
|
18
|
+
"types": "./dist/retriever.d.ts",
|
|
19
|
+
"import": "./dist/retriever.js"
|
|
20
|
+
},
|
|
21
|
+
"./gates": {
|
|
22
|
+
"types": "./dist/gates.d.ts",
|
|
23
|
+
"import": "./dist/gates.js"
|
|
24
|
+
},
|
|
25
|
+
"./hooks": {
|
|
26
|
+
"types": "./dist/hooks.d.ts",
|
|
27
|
+
"import": "./dist/hooks.js"
|
|
28
|
+
},
|
|
29
|
+
"./ledger": {
|
|
30
|
+
"types": "./dist/ledger.d.ts",
|
|
31
|
+
"import": "./dist/ledger.js"
|
|
32
|
+
},
|
|
33
|
+
"./optimizer": {
|
|
34
|
+
"types": "./dist/optimizer.d.ts",
|
|
35
|
+
"import": "./dist/optimizer.js"
|
|
36
|
+
},
|
|
37
|
+
"./headless": {
|
|
38
|
+
"types": "./dist/headless.d.ts",
|
|
39
|
+
"import": "./dist/headless.js"
|
|
40
|
+
},
|
|
41
|
+
"./persistence": {
|
|
42
|
+
"types": "./dist/persistence.d.ts",
|
|
43
|
+
"import": "./dist/persistence.js"
|
|
44
|
+
},
|
|
45
|
+
"./gateway": {
|
|
46
|
+
"types": "./dist/gateway.d.ts",
|
|
47
|
+
"import": "./dist/gateway.js"
|
|
48
|
+
},
|
|
49
|
+
"./manifest-validator": {
|
|
50
|
+
"types": "./dist/manifest-validator.d.ts",
|
|
51
|
+
"import": "./dist/manifest-validator.js"
|
|
52
|
+
},
|
|
53
|
+
"./proof": {
|
|
54
|
+
"types": "./dist/proof.d.ts",
|
|
55
|
+
"import": "./dist/proof.js"
|
|
56
|
+
},
|
|
57
|
+
"./memory-gate": {
|
|
58
|
+
"types": "./dist/memory-gate.d.ts",
|
|
59
|
+
"import": "./dist/memory-gate.js"
|
|
60
|
+
},
|
|
61
|
+
"./coherence": {
|
|
62
|
+
"types": "./dist/coherence.d.ts",
|
|
63
|
+
"import": "./dist/coherence.js"
|
|
64
|
+
},
|
|
65
|
+
"./artifacts": {
|
|
66
|
+
"types": "./dist/artifacts.d.ts",
|
|
67
|
+
"import": "./dist/artifacts.js"
|
|
68
|
+
},
|
|
69
|
+
"./capabilities": {
|
|
70
|
+
"types": "./dist/capabilities.d.ts",
|
|
71
|
+
"import": "./dist/capabilities.js"
|
|
72
|
+
},
|
|
73
|
+
"./evolution": {
|
|
74
|
+
"types": "./dist/evolution.d.ts",
|
|
75
|
+
"import": "./dist/evolution.js"
|
|
76
|
+
},
|
|
77
|
+
"./conformance-kit": {
|
|
78
|
+
"types": "./dist/conformance-kit.d.ts",
|
|
79
|
+
"import": "./dist/conformance-kit.js"
|
|
80
|
+
},
|
|
81
|
+
"./ruvbot-integration": {
|
|
82
|
+
"types": "./dist/ruvbot-integration.d.ts",
|
|
83
|
+
"import": "./dist/ruvbot-integration.js"
|
|
84
|
+
},
|
|
85
|
+
"./trust": {
|
|
86
|
+
"types": "./dist/trust.d.ts",
|
|
87
|
+
"import": "./dist/trust.js"
|
|
88
|
+
},
|
|
89
|
+
"./truth-anchors": {
|
|
90
|
+
"types": "./dist/truth-anchors.d.ts",
|
|
91
|
+
"import": "./dist/truth-anchors.js"
|
|
92
|
+
},
|
|
93
|
+
"./uncertainty": {
|
|
94
|
+
"types": "./dist/uncertainty.d.ts",
|
|
95
|
+
"import": "./dist/uncertainty.js"
|
|
96
|
+
},
|
|
97
|
+
"./temporal": {
|
|
98
|
+
"types": "./dist/temporal.d.ts",
|
|
99
|
+
"import": "./dist/temporal.js"
|
|
100
|
+
},
|
|
101
|
+
"./authority": {
|
|
102
|
+
"types": "./dist/authority.d.ts",
|
|
103
|
+
"import": "./dist/authority.js"
|
|
104
|
+
},
|
|
105
|
+
"./adversarial": {
|
|
106
|
+
"types": "./dist/adversarial.d.ts",
|
|
107
|
+
"import": "./dist/adversarial.js"
|
|
108
|
+
},
|
|
109
|
+
"./meta-governance": {
|
|
110
|
+
"types": "./dist/meta-governance.d.ts",
|
|
111
|
+
"import": "./dist/meta-governance.js"
|
|
112
|
+
},
|
|
113
|
+
"./continue-gate": {
|
|
114
|
+
"types": "./dist/continue-gate.d.ts",
|
|
115
|
+
"import": "./dist/continue-gate.js"
|
|
116
|
+
},
|
|
117
|
+
"./wasm-kernel": {
|
|
118
|
+
"types": "./dist/wasm-kernel.d.ts",
|
|
119
|
+
"import": "./dist/wasm-kernel.js"
|
|
120
|
+
},
|
|
121
|
+
"./generators": {
|
|
122
|
+
"types": "./dist/generators.d.ts",
|
|
123
|
+
"import": "./dist/generators.js"
|
|
124
|
+
},
|
|
125
|
+
"./analyzer": {
|
|
126
|
+
"types": "./dist/analyzer.d.ts",
|
|
127
|
+
"import": "./dist/analyzer.js"
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
"files": [
|
|
131
|
+
"dist",
|
|
132
|
+
"wasm-pkg"
|
|
133
|
+
],
|
|
134
|
+
"scripts": {
|
|
135
|
+
"build": "tsc -p tsconfig.json",
|
|
136
|
+
"clean": "rm -rf dist",
|
|
137
|
+
"test": "vitest run",
|
|
138
|
+
"test:watch": "vitest watch",
|
|
139
|
+
"test:coverage": "vitest run --coverage",
|
|
140
|
+
"typecheck": "tsc --noEmit"
|
|
141
|
+
},
|
|
142
|
+
"dependencies": {
|
|
143
|
+
"@sparkleideas/hooks": "^3.0.0-alpha.7",
|
|
144
|
+
"@sparkleideas/memory": "^3.0.0-alpha.2",
|
|
145
|
+
"@sparkleideas/shared": "^3.0.0-alpha.1"
|
|
146
|
+
},
|
|
147
|
+
"devDependencies": {
|
|
148
|
+
"@types/node": "^20.10.0",
|
|
149
|
+
"typescript": "^5.3.0",
|
|
150
|
+
"vitest": "^4.0.16"
|
|
151
|
+
},
|
|
152
|
+
"engines": {
|
|
153
|
+
"node": ">=20.0.0"
|
|
154
|
+
},
|
|
155
|
+
"keywords": [
|
|
156
|
+
"claude-flow",
|
|
157
|
+
"claude-code",
|
|
158
|
+
"claude",
|
|
159
|
+
"anthropic",
|
|
160
|
+
"ai-agent",
|
|
161
|
+
"ai-governance",
|
|
162
|
+
"agent-governance",
|
|
163
|
+
"guidance",
|
|
164
|
+
"control-plane",
|
|
165
|
+
"policy-enforcement",
|
|
166
|
+
"enforcement-gates",
|
|
167
|
+
"proof-chain",
|
|
168
|
+
"trust-system",
|
|
169
|
+
"long-horizon",
|
|
170
|
+
"autonomous-agent",
|
|
171
|
+
"claude-md",
|
|
172
|
+
"CLAUDE.md",
|
|
173
|
+
"memory-governance",
|
|
174
|
+
"adversarial-defense",
|
|
175
|
+
"prompt-injection",
|
|
176
|
+
"wasm",
|
|
177
|
+
"ruvbot",
|
|
178
|
+
"ruv",
|
|
179
|
+
"ai-safety",
|
|
180
|
+
"agent-orchestration",
|
|
181
|
+
"multi-agent",
|
|
182
|
+
"code-generation",
|
|
183
|
+
"llm-governance",
|
|
184
|
+
"mcp",
|
|
185
|
+
"model-context-protocol"
|
|
186
|
+
],
|
|
187
|
+
"author": "Claude Flow Team",
|
|
188
|
+
"license": "MIT",
|
|
189
|
+
"repository": {
|
|
190
|
+
"type": "git",
|
|
191
|
+
"url": "https://github.com/ruvnet/claude-flow.git",
|
|
192
|
+
"directory": "v3/@claude-flow/guidance"
|
|
193
|
+
},
|
|
194
|
+
"publishConfig": {
|
|
195
|
+
"access": "public",
|
|
196
|
+
"tag": "v3alpha"
|
|
197
|
+
}
|
|
198
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Process a batch of operations in a single host→kernel call.
|
|
6
|
+
* Accepts a JSON array of `BatchOp` and returns a JSON array of results.
|
|
7
|
+
*
|
|
8
|
+
* This is the primary entry point for high-throughput scenarios.
|
|
9
|
+
* The host batches multiple operations into one call to minimize
|
|
10
|
+
* WASM boundary crossings.
|
|
11
|
+
*/
|
|
12
|
+
export function batch_process(ops_json: string): string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Compute content hash with sorted keys (for RunEvent hashing)
|
|
16
|
+
*/
|
|
17
|
+
export function content_hash(json_input: string): string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Detect destructive command patterns, returns matched pattern or empty string
|
|
21
|
+
*/
|
|
22
|
+
export function detect_destructive(command: string): string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Compute HMAC-SHA256 hex digest
|
|
26
|
+
*/
|
|
27
|
+
export function hmac_sha256(key: string, input: string): string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Initialize the kernel (called once on module load).
|
|
31
|
+
* Returns the kernel version string.
|
|
32
|
+
*/
|
|
33
|
+
export function kernel_init(): string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Scan content for secret patterns, returns JSON array of redacted matches
|
|
37
|
+
*/
|
|
38
|
+
export function scan_secrets(content: string): string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Compute SHA-256 hex digest of input
|
|
42
|
+
*/
|
|
43
|
+
export function sha256(input: string): string;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Sign a proof envelope body (HMAC-SHA256)
|
|
47
|
+
*/
|
|
48
|
+
export function sign_envelope(key: string, envelope_json: string): string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Verify an entire proof chain from JSON
|
|
52
|
+
*/
|
|
53
|
+
export function verify_chain(chain_json: string, key: string): boolean;
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
/* @ts-self-types="./guidance_kernel.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Process a batch of operations in a single host→kernel call.
|
|
5
|
+
* Accepts a JSON array of `BatchOp` and returns a JSON array of results.
|
|
6
|
+
*
|
|
7
|
+
* This is the primary entry point for high-throughput scenarios.
|
|
8
|
+
* The host batches multiple operations into one call to minimize
|
|
9
|
+
* WASM boundary crossings.
|
|
10
|
+
* @param {string} ops_json
|
|
11
|
+
* @returns {string}
|
|
12
|
+
*/
|
|
13
|
+
function batch_process(ops_json) {
|
|
14
|
+
let deferred2_0;
|
|
15
|
+
let deferred2_1;
|
|
16
|
+
try {
|
|
17
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
18
|
+
const ptr0 = passStringToWasm0(ops_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
19
|
+
const len0 = WASM_VECTOR_LEN;
|
|
20
|
+
wasm.batch_process(retptr, ptr0, len0);
|
|
21
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
22
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
23
|
+
deferred2_0 = r0;
|
|
24
|
+
deferred2_1 = r1;
|
|
25
|
+
return getStringFromWasm0(r0, r1);
|
|
26
|
+
} finally {
|
|
27
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
28
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.batch_process = batch_process;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Compute content hash with sorted keys (for RunEvent hashing)
|
|
35
|
+
* @param {string} json_input
|
|
36
|
+
* @returns {string}
|
|
37
|
+
*/
|
|
38
|
+
function content_hash(json_input) {
|
|
39
|
+
let deferred2_0;
|
|
40
|
+
let deferred2_1;
|
|
41
|
+
try {
|
|
42
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
43
|
+
const ptr0 = passStringToWasm0(json_input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
44
|
+
const len0 = WASM_VECTOR_LEN;
|
|
45
|
+
wasm.content_hash(retptr, ptr0, len0);
|
|
46
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
47
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
48
|
+
deferred2_0 = r0;
|
|
49
|
+
deferred2_1 = r1;
|
|
50
|
+
return getStringFromWasm0(r0, r1);
|
|
51
|
+
} finally {
|
|
52
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
53
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.content_hash = content_hash;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Detect destructive command patterns, returns matched pattern or empty string
|
|
60
|
+
* @param {string} command
|
|
61
|
+
* @returns {string}
|
|
62
|
+
*/
|
|
63
|
+
function detect_destructive(command) {
|
|
64
|
+
let deferred2_0;
|
|
65
|
+
let deferred2_1;
|
|
66
|
+
try {
|
|
67
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
68
|
+
const ptr0 = passStringToWasm0(command, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
69
|
+
const len0 = WASM_VECTOR_LEN;
|
|
70
|
+
wasm.detect_destructive(retptr, ptr0, len0);
|
|
71
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
72
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
73
|
+
deferred2_0 = r0;
|
|
74
|
+
deferred2_1 = r1;
|
|
75
|
+
return getStringFromWasm0(r0, r1);
|
|
76
|
+
} finally {
|
|
77
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
78
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.detect_destructive = detect_destructive;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Compute HMAC-SHA256 hex digest
|
|
85
|
+
* @param {string} key
|
|
86
|
+
* @param {string} input
|
|
87
|
+
* @returns {string}
|
|
88
|
+
*/
|
|
89
|
+
function hmac_sha256(key, input) {
|
|
90
|
+
let deferred3_0;
|
|
91
|
+
let deferred3_1;
|
|
92
|
+
try {
|
|
93
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
94
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
95
|
+
const len0 = WASM_VECTOR_LEN;
|
|
96
|
+
const ptr1 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
97
|
+
const len1 = WASM_VECTOR_LEN;
|
|
98
|
+
wasm.hmac_sha256(retptr, ptr0, len0, ptr1, len1);
|
|
99
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
100
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
101
|
+
deferred3_0 = r0;
|
|
102
|
+
deferred3_1 = r1;
|
|
103
|
+
return getStringFromWasm0(r0, r1);
|
|
104
|
+
} finally {
|
|
105
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
106
|
+
wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.hmac_sha256 = hmac_sha256;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Initialize the kernel (called once on module load).
|
|
113
|
+
* Returns the kernel version string.
|
|
114
|
+
* @returns {string}
|
|
115
|
+
*/
|
|
116
|
+
function kernel_init() {
|
|
117
|
+
let deferred1_0;
|
|
118
|
+
let deferred1_1;
|
|
119
|
+
try {
|
|
120
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
121
|
+
wasm.kernel_init(retptr);
|
|
122
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
123
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
124
|
+
deferred1_0 = r0;
|
|
125
|
+
deferred1_1 = r1;
|
|
126
|
+
return getStringFromWasm0(r0, r1);
|
|
127
|
+
} finally {
|
|
128
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
129
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.kernel_init = kernel_init;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Scan content for secret patterns, returns JSON array of redacted matches
|
|
136
|
+
* @param {string} content
|
|
137
|
+
* @returns {string}
|
|
138
|
+
*/
|
|
139
|
+
function scan_secrets(content) {
|
|
140
|
+
let deferred2_0;
|
|
141
|
+
let deferred2_1;
|
|
142
|
+
try {
|
|
143
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
144
|
+
const ptr0 = passStringToWasm0(content, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
145
|
+
const len0 = WASM_VECTOR_LEN;
|
|
146
|
+
wasm.scan_secrets(retptr, ptr0, len0);
|
|
147
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
148
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
149
|
+
deferred2_0 = r0;
|
|
150
|
+
deferred2_1 = r1;
|
|
151
|
+
return getStringFromWasm0(r0, r1);
|
|
152
|
+
} finally {
|
|
153
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
154
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.scan_secrets = scan_secrets;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Compute SHA-256 hex digest of input
|
|
161
|
+
* @param {string} input
|
|
162
|
+
* @returns {string}
|
|
163
|
+
*/
|
|
164
|
+
function sha256(input) {
|
|
165
|
+
let deferred2_0;
|
|
166
|
+
let deferred2_1;
|
|
167
|
+
try {
|
|
168
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
169
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
170
|
+
const len0 = WASM_VECTOR_LEN;
|
|
171
|
+
wasm.sha256(retptr, ptr0, len0);
|
|
172
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
173
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
174
|
+
deferred2_0 = r0;
|
|
175
|
+
deferred2_1 = r1;
|
|
176
|
+
return getStringFromWasm0(r0, r1);
|
|
177
|
+
} finally {
|
|
178
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
179
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
exports.sha256 = sha256;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Sign a proof envelope body (HMAC-SHA256)
|
|
186
|
+
* @param {string} key
|
|
187
|
+
* @param {string} envelope_json
|
|
188
|
+
* @returns {string}
|
|
189
|
+
*/
|
|
190
|
+
function sign_envelope(key, envelope_json) {
|
|
191
|
+
let deferred3_0;
|
|
192
|
+
let deferred3_1;
|
|
193
|
+
try {
|
|
194
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
195
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
196
|
+
const len0 = WASM_VECTOR_LEN;
|
|
197
|
+
const ptr1 = passStringToWasm0(envelope_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
198
|
+
const len1 = WASM_VECTOR_LEN;
|
|
199
|
+
wasm.hmac_sha256(retptr, ptr0, len0, ptr1, len1);
|
|
200
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
201
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
202
|
+
deferred3_0 = r0;
|
|
203
|
+
deferred3_1 = r1;
|
|
204
|
+
return getStringFromWasm0(r0, r1);
|
|
205
|
+
} finally {
|
|
206
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
207
|
+
wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
exports.sign_envelope = sign_envelope;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Verify an entire proof chain from JSON
|
|
214
|
+
* @param {string} chain_json
|
|
215
|
+
* @param {string} key
|
|
216
|
+
* @returns {boolean}
|
|
217
|
+
*/
|
|
218
|
+
function verify_chain(chain_json, key) {
|
|
219
|
+
const ptr0 = passStringToWasm0(chain_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
220
|
+
const len0 = WASM_VECTOR_LEN;
|
|
221
|
+
const ptr1 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
222
|
+
const len1 = WASM_VECTOR_LEN;
|
|
223
|
+
const ret = wasm.verify_chain(ptr0, len0, ptr1, len1);
|
|
224
|
+
return ret !== 0;
|
|
225
|
+
}
|
|
226
|
+
exports.verify_chain = verify_chain;
|
|
227
|
+
|
|
228
|
+
function __wbg_get_imports() {
|
|
229
|
+
const import0 = {
|
|
230
|
+
__proto__: null,
|
|
231
|
+
};
|
|
232
|
+
return {
|
|
233
|
+
__proto__: null,
|
|
234
|
+
"./guidance_kernel_bg.js": import0,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
let cachedDataViewMemory0 = null;
|
|
239
|
+
function getDataViewMemory0() {
|
|
240
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
241
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
242
|
+
}
|
|
243
|
+
return cachedDataViewMemory0;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function getStringFromWasm0(ptr, len) {
|
|
247
|
+
ptr = ptr >>> 0;
|
|
248
|
+
return decodeText(ptr, len);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
let cachedUint8ArrayMemory0 = null;
|
|
252
|
+
function getUint8ArrayMemory0() {
|
|
253
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
254
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
255
|
+
}
|
|
256
|
+
return cachedUint8ArrayMemory0;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
260
|
+
if (realloc === undefined) {
|
|
261
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
262
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
263
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
264
|
+
WASM_VECTOR_LEN = buf.length;
|
|
265
|
+
return ptr;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
let len = arg.length;
|
|
269
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
270
|
+
|
|
271
|
+
const mem = getUint8ArrayMemory0();
|
|
272
|
+
|
|
273
|
+
let offset = 0;
|
|
274
|
+
|
|
275
|
+
for (; offset < len; offset++) {
|
|
276
|
+
const code = arg.charCodeAt(offset);
|
|
277
|
+
if (code > 0x7F) break;
|
|
278
|
+
mem[ptr + offset] = code;
|
|
279
|
+
}
|
|
280
|
+
if (offset !== len) {
|
|
281
|
+
if (offset !== 0) {
|
|
282
|
+
arg = arg.slice(offset);
|
|
283
|
+
}
|
|
284
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
285
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
286
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
287
|
+
|
|
288
|
+
offset += ret.written;
|
|
289
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
WASM_VECTOR_LEN = offset;
|
|
293
|
+
return ptr;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
297
|
+
cachedTextDecoder.decode();
|
|
298
|
+
function decodeText(ptr, len) {
|
|
299
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const cachedTextEncoder = new TextEncoder();
|
|
303
|
+
|
|
304
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
305
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
306
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
307
|
+
view.set(buf);
|
|
308
|
+
return {
|
|
309
|
+
read: arg.length,
|
|
310
|
+
written: buf.length
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
let WASM_VECTOR_LEN = 0;
|
|
316
|
+
|
|
317
|
+
const wasmPath = `${__dirname}/guidance_kernel_bg.wasm`;
|
|
318
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
319
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
320
|
+
const wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
|
|
Binary file
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const batch_process: (a: number, b: number, c: number) => void;
|
|
5
|
+
export const content_hash: (a: number, b: number, c: number) => void;
|
|
6
|
+
export const detect_destructive: (a: number, b: number, c: number) => void;
|
|
7
|
+
export const hmac_sha256: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
8
|
+
export const kernel_init: (a: number) => void;
|
|
9
|
+
export const scan_secrets: (a: number, b: number, c: number) => void;
|
|
10
|
+
export const sha256: (a: number, b: number, c: number) => void;
|
|
11
|
+
export const verify_chain: (a: number, b: number, c: number, d: number) => number;
|
|
12
|
+
export const sign_envelope: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
13
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
14
|
+
export const __wbindgen_export: (a: number, b: number) => number;
|
|
15
|
+
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
16
|
+
export const __wbindgen_export3: (a: number, b: number, c: number) => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "guidance-kernel",
|
|
3
|
+
"description": "Rust WASM kernel for @claude-flow/guidance — deterministic policy engine",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"files": [
|
|
6
|
+
"guidance_kernel_bg.wasm",
|
|
7
|
+
"guidance_kernel.js",
|
|
8
|
+
"guidance_kernel.d.ts"
|
|
9
|
+
],
|
|
10
|
+
"main": "guidance_kernel.js",
|
|
11
|
+
"types": "guidance_kernel.d.ts"
|
|
12
|
+
}
|