@crediolabs/policy-synth 0.1.4 → 0.1.6
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/codegen/template.js +3 -3
- package/dist/record/decode.d.ts +6 -3
- package/dist/record/decode.js +56 -3
- package/dist/record/freshness.d.ts +14 -1
- package/dist/record/freshness.js +32 -2
- package/dist/record/index.d.ts +11 -0
- package/dist/record/index.js +25 -0
- package/dist/record/movements.d.ts +15 -3
- package/dist/record/movements.js +42 -7
- package/dist/run/index.d.ts +43 -0
- package/dist/run/index.js +222 -0
- package/dist/run/schemas.d.ts +2016 -0
- package/dist/run/schemas.js +223 -0
- package/dist/synth/address.d.ts +7 -0
- package/dist/synth/address.js +12 -0
- package/dist/synth/compose-from-recording.d.ts +4 -3
- package/dist/synth/compose-from-recording.js +16 -6
- package/dist/synth/deny-cases.d.ts +12 -2
- package/dist/synth/deny-cases.js +76 -4
- package/dist/synth/evaluate.js +2 -2
- package/dist/synth/index.d.ts +1 -0
- package/dist/synth/index.js +4 -0
- package/dist/synth/minimize.d.ts +1 -1
- package/dist/synth/minimize.js +3 -3
- package/dist/synth/synthesize-from-recording.d.ts +5 -2
- package/dist/synth/synthesize-from-recording.js +175 -69
- package/dist/types.d.ts +41 -1
- package/dist/types.js +17 -0
- package/dist/verify/simulate.js +18 -2
- package/dist/verify/verify.js +18 -2
- package/dist-cjs/adapters/interpreter/adapter.d.ts +38 -0
- package/dist-cjs/adapters/interpreter/adapter.js +527 -0
- package/dist-cjs/adapters/interpreter/index.d.ts +1 -0
- package/dist-cjs/adapters/interpreter/index.js +8 -0
- package/dist-cjs/adapters/oz/adapter.d.ts +20 -0
- package/dist-cjs/adapters/oz/adapter.js +289 -0
- package/dist-cjs/adapters/oz/index.d.ts +1 -0
- package/dist-cjs/adapters/oz/index.js +8 -0
- package/dist-cjs/codegen/compile-gate.d.ts +33 -0
- package/dist-cjs/codegen/compile-gate.js +123 -0
- package/dist-cjs/codegen/index.d.ts +2 -0
- package/dist-cjs/codegen/index.js +14 -0
- package/dist-cjs/codegen/template.d.ts +18 -0
- package/dist-cjs/codegen/template.js +134 -0
- package/dist-cjs/errors.d.ts +37 -0
- package/dist-cjs/errors.js +3 -0
- package/dist-cjs/index.d.ts +11 -0
- package/dist-cjs/index.js +27 -0
- package/dist-cjs/ir/index.d.ts +1 -0
- package/dist-cjs/ir/index.js +3 -0
- package/dist-cjs/ir/types.d.ts +108 -0
- package/dist-cjs/ir/types.js +12 -0
- package/dist-cjs/mandate/index.d.ts +2 -0
- package/dist-cjs/mandate/index.js +6 -0
- package/dist-cjs/mandate/to-ir.d.ts +3 -0
- package/dist-cjs/mandate/to-ir.js +63 -0
- package/dist-cjs/mandate/types.d.ts +20 -0
- package/dist-cjs/mandate/types.js +9 -0
- package/dist-cjs/package.json +3 -0
- package/dist-cjs/predicate/encode.d.ts +10 -0
- package/dist-cjs/predicate/encode.js +252 -0
- package/dist-cjs/predicate/index.d.ts +1 -0
- package/dist-cjs/predicate/index.js +6 -0
- package/dist-cjs/record/decode.d.ts +79 -0
- package/dist-cjs/record/decode.js +441 -0
- package/dist-cjs/record/freshness.d.ts +30 -0
- package/dist-cjs/record/freshness.js +85 -0
- package/dist-cjs/record/index.d.ts +32 -0
- package/dist-cjs/record/index.js +191 -0
- package/dist-cjs/record/movements.d.ts +32 -0
- package/dist-cjs/record/movements.js +227 -0
- package/dist-cjs/record/rpc.d.ts +22 -0
- package/dist-cjs/record/rpc.js +74 -0
- package/dist-cjs/record/validate.d.ts +22 -0
- package/dist-cjs/record/validate.js +63 -0
- package/dist-cjs/registry/identify.d.ts +11 -0
- package/dist-cjs/registry/identify.js +87 -0
- package/dist-cjs/registry/index.d.ts +3 -0
- package/dist-cjs/registry/index.js +15 -0
- package/dist-cjs/registry/known-addresses.d.ts +16 -0
- package/dist-cjs/registry/known-addresses.js +53 -0
- package/dist-cjs/registry/protocols.d.ts +38 -0
- package/dist-cjs/registry/protocols.js +153 -0
- package/dist-cjs/review-card/builder.d.ts +14 -0
- package/dist-cjs/review-card/builder.js +264 -0
- package/dist-cjs/review-card/conflict.d.ts +40 -0
- package/dist-cjs/review-card/conflict.js +114 -0
- package/dist-cjs/review-card/cross-check.d.ts +11 -0
- package/dist-cjs/review-card/cross-check.js +151 -0
- package/dist-cjs/review-card/index.d.ts +3 -0
- package/dist-cjs/review-card/index.js +10 -0
- package/dist-cjs/run/index.d.ts +43 -0
- package/dist-cjs/run/index.js +237 -0
- package/dist-cjs/run/schemas.d.ts +2016 -0
- package/dist-cjs/run/schemas.js +226 -0
- package/dist-cjs/seams/index.d.ts +1 -0
- package/dist-cjs/seams/index.js +3 -0
- package/dist-cjs/seams/types.d.ts +66 -0
- package/dist-cjs/seams/types.js +12 -0
- package/dist-cjs/synth/address.d.ts +7 -0
- package/dist-cjs/synth/address.js +15 -0
- package/dist-cjs/synth/compose-from-recording.d.ts +65 -0
- package/dist-cjs/synth/compose-from-recording.js +366 -0
- package/dist-cjs/synth/deny-cases.d.ts +22 -0
- package/dist-cjs/synth/deny-cases.js +438 -0
- package/dist-cjs/synth/evaluate.d.ts +39 -0
- package/dist-cjs/synth/evaluate.js +428 -0
- package/dist-cjs/synth/harness.d.ts +16 -0
- package/dist-cjs/synth/harness.js +29 -0
- package/dist-cjs/synth/index.d.ts +10 -0
- package/dist-cjs/synth/index.js +28 -0
- package/dist-cjs/synth/lower.d.ts +23 -0
- package/dist-cjs/synth/lower.js +119 -0
- package/dist-cjs/synth/minimize.d.ts +4 -0
- package/dist-cjs/synth/minimize.js +41 -0
- package/dist-cjs/synth/predicate-literals.d.ts +5 -0
- package/dist-cjs/synth/predicate-literals.js +28 -0
- package/dist-cjs/synth/scope.d.ts +26 -0
- package/dist-cjs/synth/scope.js +81 -0
- package/dist-cjs/synth/synthesize-from-mandate.d.ts +5 -0
- package/dist-cjs/synth/synthesize-from-mandate.js +37 -0
- package/dist-cjs/synth/synthesize-from-recording.d.ts +49 -0
- package/dist-cjs/synth/synthesize-from-recording.js +759 -0
- package/dist-cjs/types.d.ts +311 -0
- package/dist-cjs/types.js +55 -0
- package/dist-cjs/verify/envelope.d.ts +15 -0
- package/dist-cjs/verify/envelope.js +23 -0
- package/dist-cjs/verify/index.d.ts +3 -0
- package/dist-cjs/verify/index.js +8 -0
- package/dist-cjs/verify/simulate.d.ts +31 -0
- package/dist-cjs/verify/simulate.js +261 -0
- package/dist-cjs/verify/verify.d.ts +21 -0
- package/dist-cjs/verify/verify.js +192 -0
- package/package.json +43 -3
- package/src/codegen/template.ts +3 -3
- package/src/contracts/policy-template/OZ_POLICY_TRAIT.md +171 -0
- package/src/record/corpus-fixtures.json +532 -0
- package/src/record/decode.ts +63 -10
- package/src/record/freshness.ts +34 -2
- package/src/record/index.ts +40 -0
- package/src/record/movements.ts +40 -7
- package/src/run/index.ts +277 -0
- package/src/run/schemas.ts +250 -0
- package/src/synth/address.ts +14 -0
- package/src/synth/compose-from-recording.ts +20 -9
- package/src/synth/deny-cases.ts +87 -4
- package/src/synth/evaluate.ts +2 -2
- package/src/synth/index.ts +4 -0
- package/src/synth/minimize.ts +7 -3
- package/src/synth/synthesize-from-recording.ts +200 -68
- package/src/types.ts +37 -1
- package/src/verify/simulate.ts +21 -2
- package/src/verify/verify.ts +21 -2
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.minimize = minimize;
|
|
4
|
+
const deny_cases_ts_1 = require("./deny-cases.js");
|
|
5
|
+
const harness_ts_1 = require("./harness.js");
|
|
6
|
+
/** Remove top-level conjuncts only when the current and regenerated batteries still deny. */
|
|
7
|
+
function minimize(predicate, permitCtx, dimensions) {
|
|
8
|
+
if (predicate.op !== 'and')
|
|
9
|
+
return predicate;
|
|
10
|
+
let children = [...predicate.children];
|
|
11
|
+
let index = 0;
|
|
12
|
+
while (index < children.length) {
|
|
13
|
+
const current = { op: 'and', children };
|
|
14
|
+
const currentCases = (0, deny_cases_ts_1.generateCases)(current, permitCtx, dimensions);
|
|
15
|
+
const candidateChildren = children.filter((_, childIndex) => childIndex !== index);
|
|
16
|
+
const candidate = { op: 'and', children: candidateChildren };
|
|
17
|
+
const candidateCases = (0, deny_cases_ts_1.generateCases)(candidate, permitCtx, dimensions);
|
|
18
|
+
const verificationCases = {
|
|
19
|
+
permit: candidateCases.permit,
|
|
20
|
+
denies: mergeDenyCases(currentCases.denies, candidateCases.denies),
|
|
21
|
+
};
|
|
22
|
+
if ((0, harness_ts_1.runHarness)(candidate, verificationCases).ok) {
|
|
23
|
+
children = candidateChildren;
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
index += 1;
|
|
27
|
+
}
|
|
28
|
+
return { op: 'and', children };
|
|
29
|
+
}
|
|
30
|
+
function mergeDenyCases(current, candidate) {
|
|
31
|
+
const merged = [];
|
|
32
|
+
const seen = new Set();
|
|
33
|
+
for (const deny of [...current, ...candidate]) {
|
|
34
|
+
const key = `${deny.dimension}:${JSON.stringify(deny.ctx)}`;
|
|
35
|
+
if (seen.has(key))
|
|
36
|
+
continue;
|
|
37
|
+
seen.add(key);
|
|
38
|
+
merged.push(deny);
|
|
39
|
+
}
|
|
40
|
+
return merged;
|
|
41
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PredicateLeaf } from '../types.ts';
|
|
2
|
+
/** BigInt value of a numeric-integer literal leaf (`literal_i128` / `literal_u64`
|
|
3
|
+
* / `literal_u32`), or null for a non-numeric literal (address / symbol / bytes
|
|
4
|
+
* / vec). Callers fail closed on null. */
|
|
5
|
+
export declare function literalNumericBigInt(leaf: PredicateLeaf): bigint | null;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/synth/predicate-literals.ts - read scalar values out of predicate literal leaves.
|
|
3
|
+
//
|
|
4
|
+
// Small shared helpers for interpreting a `PredicateLeaf` literal. Kept out of
|
|
5
|
+
// `evaluate.ts` so the evaluator stays focused on the deny-order semantics; the
|
|
6
|
+
// deny-case generator uses the same reader so both sides agree on what a numeric
|
|
7
|
+
// literal means.
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.literalNumericBigInt = literalNumericBigInt;
|
|
10
|
+
/** BigInt value of a numeric-integer literal leaf (`literal_i128` / `literal_u64`
|
|
11
|
+
* / `literal_u32`), or null for a non-numeric literal (address / symbol / bytes
|
|
12
|
+
* / vec). Callers fail closed on null. */
|
|
13
|
+
function literalNumericBigInt(leaf) {
|
|
14
|
+
switch (leaf.kind) {
|
|
15
|
+
case 'literal_i128':
|
|
16
|
+
case 'literal_u64':
|
|
17
|
+
try {
|
|
18
|
+
return BigInt(leaf.value);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
case 'literal_u32':
|
|
24
|
+
return BigInt(leaf.value);
|
|
25
|
+
default:
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ToolResponse } from '../errors.ts';
|
|
2
|
+
import type { AmbiguityPrompt, ContextRuleDraft, Network } from '../types.ts';
|
|
3
|
+
import type { IntentFacts } from './lower.ts';
|
|
4
|
+
export type ScopeDecision = {
|
|
5
|
+
kind: 'call_contract';
|
|
6
|
+
contract: string;
|
|
7
|
+
ambiguities: AmbiguityPrompt[];
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'default';
|
|
10
|
+
ambiguities: AmbiguityPrompt[];
|
|
11
|
+
};
|
|
12
|
+
/** Options for the scope decision. `validUntilLedger` may be supplied via the
|
|
13
|
+
* synth opts; when absent the DURATION_UNSPECIFIED ambiguity is surfaced so
|
|
14
|
+
* the LLM can ask the user rather than the synth fabricating a window. */
|
|
15
|
+
export interface DecideScopeOptions {
|
|
16
|
+
network: Network;
|
|
17
|
+
validUntilLedger?: number;
|
|
18
|
+
}
|
|
19
|
+
/** Decide the OZ context-rule scope. Returns `ScopeDecision` on success or a
|
|
20
|
+
* `ToolError` with code `SCOPE_UNRESOLVED` when the recorded tx spans
|
|
21
|
+
* multiple unrelated call targets. */
|
|
22
|
+
export declare function decideScope(facts: IntentFacts, opts: DecideScopeOptions): ToolResponse<ScopeDecision>;
|
|
23
|
+
/** Helper to project a `ScopeDecision` into the OZ `ContextRuleDraft`
|
|
24
|
+
* contextRuleType shape consumed by `composeFromRecording` and the OZ
|
|
25
|
+
* adapter. */
|
|
26
|
+
export declare function scopeToContextRuleType(scope: ScopeDecision): ContextRuleDraft['contextRuleType'];
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/synth/scope.ts - decide the OZ context-rule scope from IntentFacts.
|
|
3
|
+
//
|
|
4
|
+
// Pure decision function. Three branches:
|
|
5
|
+
// - single call target -> CallContract(target)
|
|
6
|
+
// - multiple targets w/ sharedRouter -> CallContract(sharedRouter)
|
|
7
|
+
// - multiple unrelated targets -> SCOPE_UNRESOLVED ToolError
|
|
8
|
+
//
|
|
9
|
+
// `decideScope` also surfaces the `DURATION_UNSPECIFIED` ambiguity when the
|
|
10
|
+
// caller has NOT supplied a validUntilLedger - the synth never fabricates a
|
|
11
|
+
// window. The orchestrator is responsible for assembling any
|
|
12
|
+
// `AmbiguityPrompt[]` from this and other decision points into the
|
|
13
|
+
// `ProposedPolicy.ambiguities` field.
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.decideScope = decideScope;
|
|
16
|
+
exports.scopeToContextRuleType = scopeToContextRuleType;
|
|
17
|
+
/** Decide the OZ context-rule scope. Returns `ScopeDecision` on success or a
|
|
18
|
+
* `ToolError` with code `SCOPE_UNRESOLVED` when the recorded tx spans
|
|
19
|
+
* multiple unrelated call targets. */
|
|
20
|
+
function decideScope(facts, opts) {
|
|
21
|
+
const ambiguities = [];
|
|
22
|
+
if (opts.validUntilLedger === undefined) {
|
|
23
|
+
ambiguities.push({
|
|
24
|
+
code: 'DURATION_UNSPECIFIED',
|
|
25
|
+
question: 'No expiry supplied for this policy. What `validUntilLedger` should the policy carry?',
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
// Single target -> scope directly.
|
|
29
|
+
if (facts.callTargets.length === 1) {
|
|
30
|
+
const contract = facts.callTargets[0];
|
|
31
|
+
if (contract === undefined) {
|
|
32
|
+
return {
|
|
33
|
+
ok: false,
|
|
34
|
+
error: scopeUnresolvedError(facts, 'no contract address resolvable from the recording'),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
ok: true,
|
|
39
|
+
data: { kind: 'call_contract', contract, ambiguities },
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
// Multiple targets with a shared router -> scope by the router.
|
|
43
|
+
if (facts.sharedRouter) {
|
|
44
|
+
return {
|
|
45
|
+
ok: true,
|
|
46
|
+
data: {
|
|
47
|
+
kind: 'call_contract',
|
|
48
|
+
contract: facts.sharedRouter,
|
|
49
|
+
ambiguities,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
// Multiple unrelated targets -> fail closed.
|
|
54
|
+
return {
|
|
55
|
+
ok: false,
|
|
56
|
+
error: scopeUnresolvedError(facts, `multiple unrelated call targets: ${facts.callTargets.join(', ')}`),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** Helper to project a `ScopeDecision` into the OZ `ContextRuleDraft`
|
|
60
|
+
* contextRuleType shape consumed by `composeFromRecording` and the OZ
|
|
61
|
+
* adapter. */
|
|
62
|
+
function scopeToContextRuleType(scope) {
|
|
63
|
+
return scope.kind === 'call_contract'
|
|
64
|
+
? { kind: 'call_contract', contract: scope.contract }
|
|
65
|
+
: { kind: 'default' };
|
|
66
|
+
}
|
|
67
|
+
function scopeUnresolvedError(facts, message) {
|
|
68
|
+
return {
|
|
69
|
+
code: 'SCOPE_UNRESOLVED',
|
|
70
|
+
message,
|
|
71
|
+
severity: 'error',
|
|
72
|
+
retryable: false,
|
|
73
|
+
details: { callTargets: facts.callTargets, sharedRouter: facts.sharedRouter ?? null },
|
|
74
|
+
remediation: {
|
|
75
|
+
userQuestion: {
|
|
76
|
+
code: 'MULTIPLE_UNRELATED_TARGETS',
|
|
77
|
+
question: `Recording spans ${facts.callTargets.length} call targets (${facts.callTargets.join(', ')}). Which contract (or shared router) should this policy scope to?`,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { OzAdapterConfig } from '../adapters/oz/adapter.ts';
|
|
2
|
+
import type { ToolResponse } from '../errors.ts';
|
|
3
|
+
import type { MandateSpec } from '../mandate/types.ts';
|
|
4
|
+
import type { ProposedPolicy } from '../types.ts';
|
|
5
|
+
export declare function synthesizeFromMandate(spec: MandateSpec, ozConfig: OzAdapterConfig): ToolResponse<ProposedPolicy>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/synth/synthesize-from-mandate.ts - the deterministic Mandate front-end.
|
|
3
|
+
//
|
|
4
|
+
// synthesizeFromMandate is the clean end-to-end demo path: a declarative
|
|
5
|
+
// MandateSpec is lowered deterministically to a PolicyIR and compiled by the OZ
|
|
6
|
+
// adapter to a ProposedPolicy. No decoding, no inference, so parseConfidence is
|
|
7
|
+
// the full/not-applicable value. Constructs the OZ built-in primitives cannot
|
|
8
|
+
// express (compile's `uncovered`) are surfaced in `ProposedPolicy.warnings`
|
|
9
|
+
// rather than failing the call - the covered primitives still install; the
|
|
10
|
+
// uncovered ones are reported.
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.synthesizeFromMandate = synthesizeFromMandate;
|
|
13
|
+
const adapter_ts_1 = require("../adapters/oz/adapter.js");
|
|
14
|
+
const to_ir_ts_1 = require("../mandate/to-ir.js");
|
|
15
|
+
const UNCOVERED_PREFIX = 'Not covered by OZ built-in primitives: ';
|
|
16
|
+
function synthesizeFromMandate(spec, ozConfig) {
|
|
17
|
+
const ir = (0, to_ir_ts_1.mandateToPolicyIR)(spec);
|
|
18
|
+
const adapter = (0, adapter_ts_1.createOzAdapter)(ozConfig);
|
|
19
|
+
const result = adapter.compile(ir);
|
|
20
|
+
if (!result.proposed) {
|
|
21
|
+
return {
|
|
22
|
+
ok: false,
|
|
23
|
+
error: {
|
|
24
|
+
code: 'SYNTHESIS_ERROR',
|
|
25
|
+
message: `mandate lowered to no installable OZ policy: ${result.uncovered.join('; ')}`,
|
|
26
|
+
severity: 'error',
|
|
27
|
+
retryable: false,
|
|
28
|
+
details: { uncovered: result.uncovered },
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const proposed = {
|
|
33
|
+
...result.proposed,
|
|
34
|
+
warnings: result.uncovered.map((u) => `${UNCOVERED_PREFIX}${u}`),
|
|
35
|
+
};
|
|
36
|
+
return { ok: true, data: proposed };
|
|
37
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { OzAdapterConfig } from '../adapters/oz/adapter.ts';
|
|
2
|
+
import type { ToolError, ToolResponse } from '../errors.ts';
|
|
3
|
+
import { type Network, type PredicateNode, type ProposedPolicy, type RecordedTransaction } from '../types.ts';
|
|
4
|
+
import { type ComposeUserResponses } from './compose-from-recording.ts';
|
|
5
|
+
/** Per-policy interpreter adapter config the caller opts into. Absent ->
|
|
6
|
+
* recording path runs in week-1 mode (OZ adapter only, warnings for the
|
|
7
|
+
* constraints OZ cannot express). */
|
|
8
|
+
export interface InterpreterAdapterOptions {
|
|
9
|
+
/** The smart account this interpreter policy will be installed against.
|
|
10
|
+
* Must be a C... contract address - the on-chain policy-bound account.
|
|
11
|
+
* The G... source account from the recording is a separate concept. */
|
|
12
|
+
smartAccountAddress: string;
|
|
13
|
+
/** Per-rule install nonce (first install = 1). Defaults to 1. */
|
|
14
|
+
installNonce?: number;
|
|
15
|
+
/** Per-policy oracle overrides. Tighten-only vs the wasm defaults
|
|
16
|
+
* (maxStalenessSeconds <= 600, maxDeviationBps <= 200); widening is
|
|
17
|
+
* rejected at the options boundary. */
|
|
18
|
+
oracleParams?: {
|
|
19
|
+
maxStalenessSeconds?: number;
|
|
20
|
+
maxDeviationBps?: number;
|
|
21
|
+
};
|
|
22
|
+
/** @internal Test-only seam. When set, the orchestrator uses this
|
|
23
|
+
* PredicateNode as the starting point for self-verify + minimise instead
|
|
24
|
+
* of calling the interpreter adapter's compile(). Production callers MUST
|
|
25
|
+
* NOT set this; the field exists so the self-verify pipeline can be
|
|
26
|
+
* exercised on hand-crafted predicates (redundant conjuncts for
|
|
27
|
+
* minimise, deliberately over-broad leaves for DENY_CASE_FAILURE). The
|
|
28
|
+
* `smartAccountAddress` + `installNonce` + `oracleParams` are still
|
|
29
|
+
* carried through so the emitted PolicyRef + PolicyDocument match the
|
|
30
|
+
* recorded call shape. */
|
|
31
|
+
__testPredicateNode?: PredicateNode;
|
|
32
|
+
}
|
|
33
|
+
/** Top-level orchestrator inputs. `userResponses` carries the LLM-collected
|
|
34
|
+
* answers to the ambiguity prompts (windowSeconds, validUntilLedger,
|
|
35
|
+
* limitAmount, invocationLimit, oraclePriceBound, swapRecipientAllowlist).
|
|
36
|
+
* `interpreter` opts the recording path into the interpreter adapter. */
|
|
37
|
+
export interface SynthesizeFromRecordingOptions {
|
|
38
|
+
network: Network;
|
|
39
|
+
userResponses?: ComposeUserResponses;
|
|
40
|
+
confidenceOverride?: {
|
|
41
|
+
threshold: number;
|
|
42
|
+
};
|
|
43
|
+
interpreter?: InterpreterAdapterOptions;
|
|
44
|
+
}
|
|
45
|
+
export declare function synthesizeFromRecording(tx: RecordedTransaction, opts: SynthesizeFromRecordingOptions, ozConfig: OzAdapterConfig): ToolResponse<ProposedPolicy>;
|
|
46
|
+
/** ToolError-shaped error helper used by the body to surface a structured
|
|
47
|
+
* failure that the envelope converts to `{ok:false, error}`. */
|
|
48
|
+
declare function throwToolError(code: ToolError['code'], message: string): never;
|
|
49
|
+
export { throwToolError };
|