@fluxpointstudios/orynq-sdk-process-trace 0.1.0
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/LICENSE +21 -0
- package/dist/index.cjs +1339 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1758 -0
- package/dist/index.d.ts +1758 -0
- package/dist/index.js +1285 -0
- package/dist/index.js.map +1 -0
- package/package.json +69 -0
- package/src/.gitkeep +0 -0
- package/src/__tests__/bundle.test.ts +860 -0
- package/src/__tests__/integration.test.ts +611 -0
- package/src/__tests__/merkle.test.ts +756 -0
- package/src/__tests__/rolling-hash.test.ts +622 -0
- package/src/__tests__/trace-builder.test.ts +1012 -0
- package/src/__tests__/types.test.ts +414 -0
- package/src/bundle.ts +810 -0
- package/src/disclosure.ts +527 -0
- package/src/index.ts +265 -0
- package/src/manifest.ts +687 -0
- package/src/merkle.ts +428 -0
- package/src/rolling-hash.ts +366 -0
- package/src/trace-builder.ts +725 -0
- package/src/types.ts +522 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @summary Main entry point for @fluxpointstudios/orynq-sdk-process-trace package.
|
|
3
|
+
*
|
|
4
|
+
* This package provides cryptographic process tracing for Proof-of-Intent SDK.
|
|
5
|
+
* It enables agents to create tamper-evident execution traces with:
|
|
6
|
+
* - Rolling hash chains for event ordering verification
|
|
7
|
+
* - Span-level Merkle trees for selective disclosure
|
|
8
|
+
* - Public/private visibility controls for privacy-preserving audits
|
|
9
|
+
*
|
|
10
|
+
* Key features:
|
|
11
|
+
* - TraceBuilder API for creating and managing trace runs
|
|
12
|
+
* - Event and span hash computation with domain separation
|
|
13
|
+
* - Bundle creation with cryptographic commitments
|
|
14
|
+
* - Merkle proof generation for selective disclosure
|
|
15
|
+
* - Signature support via pluggable providers
|
|
16
|
+
*
|
|
17
|
+
* Usage:
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import {
|
|
20
|
+
* createTrace,
|
|
21
|
+
* addSpan,
|
|
22
|
+
* addEvent,
|
|
23
|
+
* closeSpan,
|
|
24
|
+
* finalizeTrace,
|
|
25
|
+
* } from "@fluxpointstudios/orynq-sdk-process-trace";
|
|
26
|
+
*
|
|
27
|
+
* const run = await createTrace({ agentId: "agent-1" });
|
|
28
|
+
* const span = addSpan(run, { name: "build-project" });
|
|
29
|
+
* await addEvent(run, span.id, { kind: "command", command: "npm install" });
|
|
30
|
+
* await closeSpan(run, span.id);
|
|
31
|
+
* const bundle = await finalizeTrace(run);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
// Type Exports
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
// Visibility and common types
|
|
40
|
+
export type {
|
|
41
|
+
Visibility,
|
|
42
|
+
TraceStatus,
|
|
43
|
+
SchemaVersion,
|
|
44
|
+
} from "./types.js";
|
|
45
|
+
|
|
46
|
+
// Event types
|
|
47
|
+
export type {
|
|
48
|
+
BaseTraceEvent,
|
|
49
|
+
CommandEvent,
|
|
50
|
+
OutputEvent,
|
|
51
|
+
DecisionEvent,
|
|
52
|
+
ObservationEvent,
|
|
53
|
+
ErrorTraceEvent,
|
|
54
|
+
CustomEvent,
|
|
55
|
+
TraceEvent,
|
|
56
|
+
TraceEventKind,
|
|
57
|
+
} from "./types.js";
|
|
58
|
+
|
|
59
|
+
export { DEFAULT_EVENT_VISIBILITY } from "./types.js";
|
|
60
|
+
|
|
61
|
+
// Span types
|
|
62
|
+
export type { TraceSpan } from "./types.js";
|
|
63
|
+
|
|
64
|
+
// Run types
|
|
65
|
+
export type {
|
|
66
|
+
TraceRun,
|
|
67
|
+
RollingHashState,
|
|
68
|
+
} from "./types.js";
|
|
69
|
+
|
|
70
|
+
// Merkle tree types
|
|
71
|
+
export type {
|
|
72
|
+
TraceMerkleTree,
|
|
73
|
+
MerkleProof,
|
|
74
|
+
} from "./types.js";
|
|
75
|
+
|
|
76
|
+
// Bundle types
|
|
77
|
+
export type {
|
|
78
|
+
AnnotatedSpan,
|
|
79
|
+
TraceBundlePublicView,
|
|
80
|
+
TraceBundle,
|
|
81
|
+
} from "./types.js";
|
|
82
|
+
|
|
83
|
+
// Signature types
|
|
84
|
+
export type { SignatureProvider } from "./types.js";
|
|
85
|
+
|
|
86
|
+
// Manifest and chunk types
|
|
87
|
+
export type {
|
|
88
|
+
ChunkInfo,
|
|
89
|
+
Chunk,
|
|
90
|
+
TraceManifest,
|
|
91
|
+
} from "./types.js";
|
|
92
|
+
|
|
93
|
+
// Disclosure types
|
|
94
|
+
export type {
|
|
95
|
+
DisclosureMode,
|
|
96
|
+
DisclosureResult,
|
|
97
|
+
} from "./types.js";
|
|
98
|
+
|
|
99
|
+
// Disclosure request type (from disclosure module)
|
|
100
|
+
export type { DisclosureRequest } from "./disclosure.js";
|
|
101
|
+
|
|
102
|
+
// Verification types
|
|
103
|
+
export type {
|
|
104
|
+
TraceVerificationResult,
|
|
105
|
+
ManifestVerificationResult,
|
|
106
|
+
} from "./types.js";
|
|
107
|
+
|
|
108
|
+
// Builder option types
|
|
109
|
+
export type {
|
|
110
|
+
CreateTraceOptions,
|
|
111
|
+
CreateSpanOptions,
|
|
112
|
+
CreateManifestOptions,
|
|
113
|
+
} from "./types.js";
|
|
114
|
+
|
|
115
|
+
// Domain separation constants
|
|
116
|
+
export { HASH_DOMAIN_PREFIXES } from "./types.js";
|
|
117
|
+
export type { HashDomain } from "./types.js";
|
|
118
|
+
|
|
119
|
+
// ---------------------------------------------------------------------------
|
|
120
|
+
// Trace Builder Exports
|
|
121
|
+
// ---------------------------------------------------------------------------
|
|
122
|
+
|
|
123
|
+
export {
|
|
124
|
+
// Core builder functions
|
|
125
|
+
createTrace,
|
|
126
|
+
addSpan,
|
|
127
|
+
addEvent,
|
|
128
|
+
closeSpan,
|
|
129
|
+
finalizeTrace,
|
|
130
|
+
|
|
131
|
+
// Query functions
|
|
132
|
+
getSpan,
|
|
133
|
+
getSpanEvents,
|
|
134
|
+
isFinalized,
|
|
135
|
+
|
|
136
|
+
// Utility functions
|
|
137
|
+
getEventCount,
|
|
138
|
+
getSpanCount,
|
|
139
|
+
getRootSpans,
|
|
140
|
+
getChildSpans,
|
|
141
|
+
getEvent,
|
|
142
|
+
getEventsByKind,
|
|
143
|
+
} from "./trace-builder.js";
|
|
144
|
+
|
|
145
|
+
// ---------------------------------------------------------------------------
|
|
146
|
+
// Rolling Hash Exports
|
|
147
|
+
// ---------------------------------------------------------------------------
|
|
148
|
+
|
|
149
|
+
export {
|
|
150
|
+
// Event hash computation
|
|
151
|
+
computeEventHash,
|
|
152
|
+
computeEventHashes,
|
|
153
|
+
|
|
154
|
+
// Rolling hash state management
|
|
155
|
+
initRollingHash,
|
|
156
|
+
updateRollingHash,
|
|
157
|
+
|
|
158
|
+
// Batch computation
|
|
159
|
+
computeRollingHash,
|
|
160
|
+
|
|
161
|
+
// Verification
|
|
162
|
+
verifyRollingHash,
|
|
163
|
+
|
|
164
|
+
// Root hash
|
|
165
|
+
computeRootHash,
|
|
166
|
+
|
|
167
|
+
// Testing utilities
|
|
168
|
+
getGenesisHash,
|
|
169
|
+
} from "./rolling-hash.js";
|
|
170
|
+
|
|
171
|
+
// ---------------------------------------------------------------------------
|
|
172
|
+
// Merkle Tree Exports
|
|
173
|
+
// ---------------------------------------------------------------------------
|
|
174
|
+
|
|
175
|
+
export {
|
|
176
|
+
// Span hash computation
|
|
177
|
+
computeSpanHash,
|
|
178
|
+
|
|
179
|
+
// Tree building
|
|
180
|
+
buildSpanMerkleTree,
|
|
181
|
+
|
|
182
|
+
// Proof generation and verification
|
|
183
|
+
generateMerkleProof,
|
|
184
|
+
verifyMerkleProof,
|
|
185
|
+
verifySpanInclusion,
|
|
186
|
+
} from "./merkle.js";
|
|
187
|
+
|
|
188
|
+
// ---------------------------------------------------------------------------
|
|
189
|
+
// Bundle Exports
|
|
190
|
+
// ---------------------------------------------------------------------------
|
|
191
|
+
|
|
192
|
+
export {
|
|
193
|
+
// Visibility helpers
|
|
194
|
+
isPublicSpan,
|
|
195
|
+
isPublicEvent,
|
|
196
|
+
filterPublicEvents,
|
|
197
|
+
|
|
198
|
+
// Bundle creation
|
|
199
|
+
createBundle,
|
|
200
|
+
|
|
201
|
+
// Public view extraction
|
|
202
|
+
extractPublicView,
|
|
203
|
+
|
|
204
|
+
// Bundle verification
|
|
205
|
+
verifyBundle,
|
|
206
|
+
|
|
207
|
+
// Bundle signing
|
|
208
|
+
signBundle,
|
|
209
|
+
verifyBundleSignature,
|
|
210
|
+
|
|
211
|
+
// Utility functions
|
|
212
|
+
getSpanEvents as getBundleSpanEvents,
|
|
213
|
+
countEventsByVisibility,
|
|
214
|
+
countSpansByVisibility,
|
|
215
|
+
} from "./bundle.js";
|
|
216
|
+
|
|
217
|
+
// ---------------------------------------------------------------------------
|
|
218
|
+
// Disclosure Exports
|
|
219
|
+
// ---------------------------------------------------------------------------
|
|
220
|
+
|
|
221
|
+
export {
|
|
222
|
+
// Selective disclosure
|
|
223
|
+
selectiveDisclose,
|
|
224
|
+
|
|
225
|
+
// Verification
|
|
226
|
+
verifyDisclosure,
|
|
227
|
+
verifySpanDisclosure,
|
|
228
|
+
|
|
229
|
+
// Utility functions
|
|
230
|
+
canDisclose,
|
|
231
|
+
getSpanIndex,
|
|
232
|
+
createDisclosureRequest,
|
|
233
|
+
} from "./disclosure.js";
|
|
234
|
+
|
|
235
|
+
// ---------------------------------------------------------------------------
|
|
236
|
+
// Manifest Exports
|
|
237
|
+
// ---------------------------------------------------------------------------
|
|
238
|
+
|
|
239
|
+
export {
|
|
240
|
+
// Manifest creation
|
|
241
|
+
createManifest,
|
|
242
|
+
|
|
243
|
+
// Manifest verification
|
|
244
|
+
verifyManifest,
|
|
245
|
+
|
|
246
|
+
// Manifest hash computation
|
|
247
|
+
computeManifestHash,
|
|
248
|
+
|
|
249
|
+
// Bundle reconstruction
|
|
250
|
+
reconstructBundleFromManifest,
|
|
251
|
+
|
|
252
|
+
// Chunk utilities
|
|
253
|
+
getChunkPath,
|
|
254
|
+
parseChunkContent,
|
|
255
|
+
} from "./manifest.js";
|
|
256
|
+
|
|
257
|
+
// ---------------------------------------------------------------------------
|
|
258
|
+
// Version
|
|
259
|
+
// ---------------------------------------------------------------------------
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Package version.
|
|
263
|
+
* Updated automatically during build.
|
|
264
|
+
*/
|
|
265
|
+
export const VERSION = "0.1.0";
|