@hesohq/node 0.5.0-dev.81 → 0.5.0-dev.95

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.
Files changed (3) hide show
  1. package/index.d.ts +105 -0
  2. package/index.js +6 -1
  3. package/package.json +6 -6
package/index.d.ts CHANGED
@@ -71,6 +71,73 @@ export interface RedactCommitResult {
71
71
  export declare function verify(receiptBytes: Buffer | Uint8Array | string): ActionVerdict
72
72
  /** Verify a receipt AND report its trusted-time status separately. */
73
73
  export declare function verifyWithTime(receiptBytesInput: Buffer | Uint8Array | string): ActionVerdictWithTime
74
+ /**
75
+ * The base verdict + the rendered signed metrics + the offline-recomputed cost.
76
+ *
77
+ * `verdict` / `trustLevel` are exactly what [`verify`] returns. The metric fields
78
+ * are the SIGNED values (the closed `status` / `token_source` enums rendered to
79
+ * their wire snake_case strings). `recomputedCostMicros` / `costDisplay` are
80
+ * RECOMPUTED from the rate card the caller passed in — `priced == false` (and
81
+ * both absent) when that card does not price the model; never a guessed figure.
82
+ * `cardIdMatches` tells the reader whether the card handed in is the one the
83
+ * receipt actually named.
84
+ */
85
+ export interface MetricsVerdict {
86
+ /** The base `ActionOutcome` verdict tag (`"Valid"`, `"HashMismatch"`, …). */
87
+ verdict: string
88
+ /** The re-derived trust level (`"L0"`/`"L1"`); `""` unless `verdict == "Valid"`. */
89
+ trustLevel: string
90
+ /** Whether the receipt carried a signed `metrics` block. */
91
+ hasMetrics: boolean
92
+ /** Wall-clock duration in whole milliseconds. */
93
+ durationMs?: number
94
+ /** Execution-outcome class, wire snake_case (`"ok"`, `"server_error"`, …). */
95
+ status?: string
96
+ /** Transport status code, when one applied. */
97
+ statusCode?: number
98
+ /** Provider-reported (or estimated) input tokens. */
99
+ tokensIn?: number
100
+ /** Provider-reported (or estimated) output tokens. */
101
+ tokensOut?: number
102
+ /** Token-count source, wire snake_case (`"provider_reported"`/`"estimated"`). */
103
+ tokenSource?: string
104
+ /** Request bytes sent, when the transport exposed it. */
105
+ bytesIn?: number
106
+ /** Response bytes received, when the transport exposed it. */
107
+ bytesOut?: number
108
+ /** Transport-level retries before this outcome. */
109
+ retries?: number
110
+ /** The rate-card id AS NAMED in the signed receipt. */
111
+ rateCardId?: string
112
+ /** The `provider/model` key derived from the signed `action.fields`. */
113
+ modelKey?: string
114
+ /** Recomputed cost in micro-USD (`BigInt`); absent when not priced. */
115
+ recomputedCostMicros?: bigint
116
+ /** Recomputed cost as a 6-decimal display string; absent when not priced. */
117
+ costDisplay?: string
118
+ /** `true` iff the model is priced by the passed-in card. */
119
+ priced: boolean
120
+ /** Whether the passed-in card is the one the receipt named. */
121
+ cardIdMatches: boolean
122
+ }
123
+ /**
124
+ * Verify a single `ActionReceipt` AND render its signed metrics + recompute cost
125
+ * from the passed-in public rate card — the node mirror of the WASM
126
+ * `verifyActionReceiptWithRates`.
127
+ *
128
+ * Runs the EXISTING offline verify for the base outcome + trust level (so that
129
+ * path is unchanged), then renders the signed metrics and recomputes the cost via
130
+ * the SHARED `heso_action::metrics_view` glue. Never throws on a malformed receipt
131
+ * or card — those degrade to `has_metrics: false` / `priced: false` exactly as the
132
+ * WASM export does. The cost render is purely informational and NEVER masks a
133
+ * verify failure: a tampered metric flips the `action_hash`, so `verdict` is a
134
+ * non-`Valid` tag while the (meaningless) recompute still reflects whatever bytes
135
+ * are present — the caller branches on `verdict`, never the dollar figure.
136
+ *
137
+ * `receipt_bytes` — the raw `ActionReceipt` JSON bytes (Buffer/Uint8Array/string).
138
+ * `rate_card_json` — the public rate-card JSON the cost is recomputed from.
139
+ */
140
+ export declare function verifyWithRates(receiptBytes: Buffer | Uint8Array | string, rateCardJson: string): MetricsVerdict
74
141
  /**
75
142
  * Verify a receipt AND re-derive its ERT classification from the embedded taxonomy
76
143
  * (heso-engine's ClassifyReDeriver). Only available when `process` is enabled.
@@ -361,6 +428,44 @@ export declare function assembleL1FromParts(suspendedContentJson: string, approv
361
428
  * wasm-reachable).
362
429
  */
363
430
  export declare function assembleQuorumFromParts(suspendedContentJson: string, threshold: number, rosterJson: string, partsJson: string, projectRoot: string, keyPassphrase?: string | undefined | null, chainHead?: string | undefined | null): Buffer
431
+ /**
432
+ * Suspend a gated action: mint the signed `suspended` chain link and return the
433
+ * raw resume token (returned ONCE) plus the action spec hash. Mirrors the PyO3
434
+ * `process_suspend` body 1:1 — the ProcessInput MUST carry `reclassify=false` so
435
+ * the descriptor is signed verbatim and stays byte-stable across the lifecycle.
436
+ *
437
+ * Returns JSON bytes:
438
+ * `{"session_id": str, "resume_token": str, "action_spec": str, "chain_path": str}`.
439
+ */
440
+ export declare function processSuspend(processInputJson: Buffer | Uint8Array | string, projectRoot: string, sessionId: string, sla: string, expiresAt: string, onTimeout: string, contextScheme: string, contextBlob: Buffer, toolVersionHash?: string | undefined | null): Buffer
441
+ /**
442
+ * Resume a suspended session: re-read the chain, apply the decision, fire-or-replay.
443
+ * Mirrors the PyO3 `process_resume` body 1:1. On `Fire` it mints + appends the
444
+ * `completed` link under `ACTION_SIGNING_DOMAIN` and advances the cursor.
445
+ *
446
+ * Returns JSON bytes `{"decision": str, "committed": bool, "kind"?: str,
447
+ * "reason"?: str}` where `decision` is one of
448
+ * `fire`/`replay`/`pending`/`terminal`/`uncertain`/`refused`.
449
+ */
450
+ export declare function processResume(processInputJson: Buffer | Uint8Array | string, projectRoot: string, sessionId: string, presentedToken: string, contextBlob: Buffer): Buffer
451
+ /**
452
+ * Append an approver/ledger-signed decision link to a session's chain. Mirrors the
453
+ * PyO3 `process_append_decision` body 1:1.
454
+ *
455
+ * `kind`: one of `"approved"` / `"denied"` / `"escalated"` / `"expired"`. **Fails
456
+ * closed** without a `decision.key` unless [`INSECURE_DECISION_KEY_ENV`] is set
457
+ * (see `load_decision_signer`) — the approver key is cloud-custodied in prod.
458
+ */
459
+ export declare function processAppendDecision(projectRoot: string, sessionId: string, kind: string, reason?: string | undefined | null, decidedAt?: string | undefined | null): void
460
+ /**
461
+ * Read the current lifecycle state of a session chain (the head link's kind).
462
+ * Mirrors the PyO3 `process_read_chain_head` body 1:1.
463
+ *
464
+ * Returns the head kind as a lowercase string (`"suspended"` / `"approved"` /
465
+ * `"denied"` / `"expired"` / `"completed"` / `"escalated"`), or `None` if no chain
466
+ * exists yet.
467
+ */
468
+ export declare function processReadChainHead(projectRoot: string, sessionId: string): string | null
364
469
  /** A loaded operator key, exposing just the public-key surface. */
365
470
  export declare class OperatorKey {
366
471
  /** Return the base64 standard-alphabet public key. */
package/index.js CHANGED
@@ -310,11 +310,12 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { OperatorKey, verify, verifyWithTime, verifyRederiving, actionCanonicalBytesJs, l1ContentCanonicalBytesJs, contentHash, anchoredContentHashJs, shortHash, chainHashHex, verifyApprovalToken, verifyDelegation, verifyCommitment, commitmentEnvelopeCanonicalBytes, commitmentFingerprint, signerFingerprint, bindIntoChainJs, verifyChain, verifySessionChainJs, verifySessionChainWithRotationJs, verifyInclusionJs, verifyConsistencyJs, verifyAuditChain, taxonomyHash, classify, isDestructive, redactDestructiveJs, redactCommitJs, verifyRevealJs, keyFromSeed, generateKey, blake3Hex, processAction, assembleL1FromParts, assembleQuorumFromParts } = nativeBinding
313
+ const { OperatorKey, verify, verifyWithTime, verifyWithRates, verifyRederiving, actionCanonicalBytesJs, l1ContentCanonicalBytesJs, contentHash, anchoredContentHashJs, shortHash, chainHashHex, verifyApprovalToken, verifyDelegation, verifyCommitment, commitmentEnvelopeCanonicalBytes, commitmentFingerprint, signerFingerprint, bindIntoChainJs, verifyChain, verifySessionChainJs, verifySessionChainWithRotationJs, verifyInclusionJs, verifyConsistencyJs, verifyAuditChain, taxonomyHash, classify, isDestructive, redactDestructiveJs, redactCommitJs, verifyRevealJs, keyFromSeed, generateKey, blake3Hex, processAction, assembleL1FromParts, assembleQuorumFromParts, processSuspend, processResume, processAppendDecision, processReadChainHead } = nativeBinding
314
314
 
315
315
  module.exports.OperatorKey = OperatorKey
316
316
  module.exports.verify = verify
317
317
  module.exports.verifyWithTime = verifyWithTime
318
+ module.exports.verifyWithRates = verifyWithRates
318
319
  module.exports.verifyRederiving = verifyRederiving
319
320
  module.exports.actionCanonicalBytesJs = actionCanonicalBytesJs
320
321
  module.exports.l1ContentCanonicalBytesJs = l1ContentCanonicalBytesJs
@@ -347,3 +348,7 @@ module.exports.blake3Hex = blake3Hex
347
348
  module.exports.processAction = processAction
348
349
  module.exports.assembleL1FromParts = assembleL1FromParts
349
350
  module.exports.assembleQuorumFromParts = assembleQuorumFromParts
351
+ module.exports.processSuspend = processSuspend
352
+ module.exports.processResume = processResume
353
+ module.exports.processAppendDecision = processAppendDecision
354
+ module.exports.processReadChainHead = processReadChainHead
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hesohq/node",
3
- "version": "0.5.0-dev.81",
3
+ "version": "0.5.0-dev.95",
4
4
  "description": "napi-rs native Node.js addon for the HESO Enterprise trust layer",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -34,10 +34,10 @@
34
34
  },
35
35
  "license": "LicenseRef-Proprietary",
36
36
  "optionalDependencies": {
37
- "@hesohq/node-darwin-arm64": "0.5.0-dev.81",
38
- "@hesohq/node-darwin-x64": "0.5.0-dev.81",
39
- "@hesohq/node-linux-arm64-gnu": "0.5.0-dev.81",
40
- "@hesohq/node-linux-x64-gnu": "0.5.0-dev.81",
41
- "@hesohq/node-win32-x64-msvc": "0.5.0-dev.81"
37
+ "@hesohq/node-darwin-arm64": "0.5.0-dev.95",
38
+ "@hesohq/node-darwin-x64": "0.5.0-dev.95",
39
+ "@hesohq/node-linux-arm64-gnu": "0.5.0-dev.95",
40
+ "@hesohq/node-linux-x64-gnu": "0.5.0-dev.95",
41
+ "@hesohq/node-win32-x64-msvc": "0.5.0-dev.95"
42
42
  }
43
43
  }