@odingard/guardian-sdk 0.1.0 → 0.2.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/README.md +252 -17
- package/dist/contracts.js +9865 -0
- package/dist/index.js +12976 -1787
- package/dist/public-catalog.v1.json +6915 -0
- package/dist-dts/catalog.d.ts +14 -0
- package/dist-dts/client.d.ts +51 -1
- package/dist-dts/contracts/action-pack.d.ts +464 -0
- package/dist-dts/contracts/action-registry.d.ts +91 -1
- package/dist-dts/contracts/action.d.ts +1408 -17
- package/dist-dts/contracts/agent-state.d.ts +386 -0
- package/dist-dts/contracts/approval.d.ts +224 -5
- package/dist-dts/contracts/assurance.d.ts +60 -0
- package/dist-dts/contracts/authority-graph.d.ts +294 -0
- package/dist-dts/contracts/authority-state.d.ts +17 -2
- package/dist-dts/contracts/authority.d.ts +31 -5
- package/dist-dts/contracts/billing.d.ts +32 -0
- package/dist-dts/contracts/calendar.d.ts +6 -6
- package/dist-dts/contracts/denial.d.ts +648 -0
- package/dist-dts/contracts/evidence.d.ts +73 -16
- package/dist-dts/contracts/execution.d.ts +449 -55
- package/dist-dts/contracts/identifiers.d.ts +16 -0
- package/dist-dts/contracts/index.d.ts +22 -0
- package/dist-dts/contracts/intent.d.ts +335 -0
- package/dist-dts/contracts/lineage.d.ts +218 -0
- package/dist-dts/contracts/local.d.ts +101 -0
- package/dist-dts/contracts/multi-principal.d.ts +292 -0
- package/dist-dts/contracts/multiparty.d.ts +169 -0
- package/dist-dts/contracts/obligation.d.ts +196 -0
- package/dist-dts/contracts/plan.d.ts +67 -0
- package/dist-dts/contracts/policy-simulation.d.ts +681 -0
- package/dist-dts/contracts/prerequisite.d.ts +147 -0
- package/dist-dts/contracts/protected-data.d.ts +67 -0
- package/dist-dts/contracts/receipt.d.ts +3126 -0
- package/dist-dts/contracts/resource-claims.d.ts +146 -0
- package/dist-dts/contracts/runtime.d.ts +111 -0
- package/dist-dts/contracts/safety-envelope.d.ts +287 -0
- package/dist-dts/contracts/sequence.d.ts +132 -0
- package/dist-dts/contracts/sources.d.ts +191 -0
- package/dist-dts/contracts/tools.d.ts +50 -5
- package/dist-dts/contracts/transaction.d.ts +360 -0
- package/dist-dts/contracts-entry.d.ts +1 -0
- package/dist-dts/embedded.d.ts +58 -0
- package/dist-dts/evidence/evidence.d.ts +25 -0
- package/dist-dts/evidence/receipt.d.ts +61 -0
- package/dist-dts/index.d.ts +5 -1
- package/dist-dts/lifecycle.d.ts +25 -0
- package/dist-dts/proposal.d.ts +16 -0
- package/dist-dts/receipts.d.ts +37 -0
- package/package.json +12 -6
- package/dist-dts/__tests__/client.test.d.ts +0 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* WO-023: guardian.prerequisite.v1 — declarative prerequisites.
|
|
4
|
+
*
|
|
5
|
+
* A prerequisite is a human-authored pre-condition declared on an intent
|
|
6
|
+
* contract: it must settle — in declared order — before the action reaches
|
|
7
|
+
* the kernel (directive §13). Prerequisites are declarative inputs to the
|
|
8
|
+
* ONE authority kernel (§89, K15). No prerequisite may create, widen, or
|
|
9
|
+
* restore authority: this evaluator is pure and read-only — it can only
|
|
10
|
+
* report satisfied | pending | failed, and a failure denies with the failed
|
|
11
|
+
* rule named on the rejection evidence. Unknown or unwired types evaluate
|
|
12
|
+
* `failed` (PREREQUISITE_VERIFIER_UNAVAILABLE) and deny — fail closed.
|
|
13
|
+
*/
|
|
14
|
+
export declare const PREREQUISITE_CONTRACT_SCHEMA = "guardian.prerequisite.v1";
|
|
15
|
+
/** Prerequisite types wired in this build. Unknown types deny (fail closed). */
|
|
16
|
+
export declare const PrerequisiteTypeSchema: z.ZodEnum<{
|
|
17
|
+
merchant_verified: "merchant_verified";
|
|
18
|
+
counterparty_verified: "counterparty_verified";
|
|
19
|
+
budget_available: "budget_available";
|
|
20
|
+
capability_present: "capability_present";
|
|
21
|
+
address_authority: "address_authority";
|
|
22
|
+
human_approval: "human_approval";
|
|
23
|
+
}>;
|
|
24
|
+
export type PrerequisiteType = z.infer<typeof PrerequisiteTypeSchema>;
|
|
25
|
+
export declare const PrerequisiteParamsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
|
|
26
|
+
export type PrerequisiteParams = z.infer<typeof PrerequisiteParamsSchema>;
|
|
27
|
+
export declare const PrerequisiteSchema: z.ZodObject<{
|
|
28
|
+
id: z.ZodString;
|
|
29
|
+
type: z.ZodEnum<{
|
|
30
|
+
merchant_verified: "merchant_verified";
|
|
31
|
+
counterparty_verified: "counterparty_verified";
|
|
32
|
+
budget_available: "budget_available";
|
|
33
|
+
capability_present: "capability_present";
|
|
34
|
+
address_authority: "address_authority";
|
|
35
|
+
human_approval: "human_approval";
|
|
36
|
+
}>;
|
|
37
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>>;
|
|
38
|
+
}, z.core.$strict>;
|
|
39
|
+
export type Prerequisite = z.infer<typeof PrerequisiteSchema>;
|
|
40
|
+
export declare const PrerequisiteStateValueSchema: z.ZodEnum<{
|
|
41
|
+
satisfied: "satisfied";
|
|
42
|
+
pending: "pending";
|
|
43
|
+
failed: "failed";
|
|
44
|
+
not_applicable: "not_applicable";
|
|
45
|
+
}>;
|
|
46
|
+
export type PrerequisiteStateValue = z.infer<typeof PrerequisiteStateValueSchema>;
|
|
47
|
+
export declare const PrerequisiteRuleSchema: z.ZodEnum<{
|
|
48
|
+
BUDGET_EXCEEDED: "BUDGET_EXCEEDED";
|
|
49
|
+
PENDING_HUMAN: "PENDING_HUMAN";
|
|
50
|
+
PREREQUISITE_SATISFIED: "PREREQUISITE_SATISFIED";
|
|
51
|
+
MERCHANT_UNVERIFIED: "MERCHANT_UNVERIFIED";
|
|
52
|
+
BUDGET_NOT_DECLARED: "BUDGET_NOT_DECLARED";
|
|
53
|
+
CAPABILITY_NOT_COVERED: "CAPABILITY_NOT_COVERED";
|
|
54
|
+
ADDRESS_NOT_AUTHORIZED: "ADDRESS_NOT_AUTHORIZED";
|
|
55
|
+
PREREQUISITE_PARAMS_INVALID: "PREREQUISITE_PARAMS_INVALID";
|
|
56
|
+
PREREQUISITE_VERIFIER_UNAVAILABLE: "PREREQUISITE_VERIFIER_UNAVAILABLE";
|
|
57
|
+
}>;
|
|
58
|
+
export type PrerequisiteRule = z.infer<typeof PrerequisiteRuleSchema>;
|
|
59
|
+
export declare const PrerequisiteStateSchema: z.ZodObject<{
|
|
60
|
+
id: z.ZodString;
|
|
61
|
+
prerequisiteType: z.ZodString;
|
|
62
|
+
state: z.ZodEnum<{
|
|
63
|
+
satisfied: "satisfied";
|
|
64
|
+
pending: "pending";
|
|
65
|
+
failed: "failed";
|
|
66
|
+
not_applicable: "not_applicable";
|
|
67
|
+
}>;
|
|
68
|
+
rule: z.ZodEnum<{
|
|
69
|
+
BUDGET_EXCEEDED: "BUDGET_EXCEEDED";
|
|
70
|
+
PENDING_HUMAN: "PENDING_HUMAN";
|
|
71
|
+
PREREQUISITE_SATISFIED: "PREREQUISITE_SATISFIED";
|
|
72
|
+
MERCHANT_UNVERIFIED: "MERCHANT_UNVERIFIED";
|
|
73
|
+
BUDGET_NOT_DECLARED: "BUDGET_NOT_DECLARED";
|
|
74
|
+
CAPABILITY_NOT_COVERED: "CAPABILITY_NOT_COVERED";
|
|
75
|
+
ADDRESS_NOT_AUTHORIZED: "ADDRESS_NOT_AUTHORIZED";
|
|
76
|
+
PREREQUISITE_PARAMS_INVALID: "PREREQUISITE_PARAMS_INVALID";
|
|
77
|
+
PREREQUISITE_VERIFIER_UNAVAILABLE: "PREREQUISITE_VERIFIER_UNAVAILABLE";
|
|
78
|
+
}>;
|
|
79
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
80
|
+
}, z.core.$strict>;
|
|
81
|
+
export type PrerequisiteState = z.infer<typeof PrerequisiteStateSchema>;
|
|
82
|
+
/** Read-only facts the evaluator may consult. It cannot mutate or mint. */
|
|
83
|
+
export type PrerequisiteContext = Readonly<{
|
|
84
|
+
/** The action's declared counterparty (merchant) label, if any. */
|
|
85
|
+
merchantId?: string | undefined;
|
|
86
|
+
/** The action's resource ref. */
|
|
87
|
+
resource: string;
|
|
88
|
+
/** The action's declared value in cents, if any. */
|
|
89
|
+
valueCents?: number | undefined;
|
|
90
|
+
/** The action's material parameters (read-only). */
|
|
91
|
+
materialParameters?: Readonly<Record<string, unknown>> | undefined;
|
|
92
|
+
/** Counterparties declared on the enclosing intent (absent = none). */
|
|
93
|
+
intentCounterparties?: readonly string[] | undefined;
|
|
94
|
+
/** Resources declared on the enclosing intent (absent = unconstrained). */
|
|
95
|
+
intentResources?: readonly string[] | undefined;
|
|
96
|
+
/** Total issued-capability value cap declared on the intent. */
|
|
97
|
+
moneyBudgetCents?: number | undefined;
|
|
98
|
+
/** True when the narrowed authority chain still covers this action. */
|
|
99
|
+
chainCoversAction: boolean;
|
|
100
|
+
}>;
|
|
101
|
+
/**
|
|
102
|
+
* Pure prerequisite evaluation for one declared entry. Deterministic and
|
|
103
|
+
* read-only: the evaluator issues no authority and cannot enlarge a chain.
|
|
104
|
+
*/
|
|
105
|
+
export declare function evaluatePrerequisite(entry: Prerequisite, context: PrerequisiteContext): PrerequisiteState;
|
|
106
|
+
export type PrerequisiteEvaluation = Readonly<{
|
|
107
|
+
/** Results recorded in declared order; evaluation halts at first failure. */
|
|
108
|
+
results: readonly PrerequisiteState[];
|
|
109
|
+
/** The first failed entry, when evaluation halted. */
|
|
110
|
+
firstFailure: PrerequisiteState | null;
|
|
111
|
+
/** True when any settled/pending entry requires human approval (ASK). */
|
|
112
|
+
forcesApproval: boolean;
|
|
113
|
+
}>;
|
|
114
|
+
/**
|
|
115
|
+
* Evaluate prerequisites strictly in declared order. Evaluation halts at the
|
|
116
|
+
* first failure — entries after it are never evaluated and a reevaluation
|
|
117
|
+
* only happens after all prerequisites settle (directive §13).
|
|
118
|
+
*/
|
|
119
|
+
export declare function evaluatePrerequisitesInOrder(prerequisites: readonly Prerequisite[], context: PrerequisiteContext): PrerequisiteEvaluation;
|
|
120
|
+
/**
|
|
121
|
+
* Durable per-row shape for the obligation/prerequisite state table
|
|
122
|
+
* (packages/store-postgres `obligation_states`): one row per evaluated
|
|
123
|
+
* item, keyed by the action that carried it.
|
|
124
|
+
*/
|
|
125
|
+
export declare const ObligationStateRecordSchema: z.ZodObject<{
|
|
126
|
+
tenantId: z.ZodString;
|
|
127
|
+
actionRef: z.ZodString;
|
|
128
|
+
intentId: z.ZodOptional<z.ZodString>;
|
|
129
|
+
kind: z.ZodEnum<{
|
|
130
|
+
obligation: "obligation";
|
|
131
|
+
prerequisite: "prerequisite";
|
|
132
|
+
}>;
|
|
133
|
+
obligation: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
134
|
+
state: z.ZodEnum<{
|
|
135
|
+
satisfied: "satisfied";
|
|
136
|
+
pending: "pending";
|
|
137
|
+
failed: "failed";
|
|
138
|
+
not_applicable: "not_applicable";
|
|
139
|
+
overdue: "overdue";
|
|
140
|
+
}>;
|
|
141
|
+
rule: z.ZodString;
|
|
142
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
143
|
+
dueEpochMs: z.ZodOptional<z.ZodNumber>;
|
|
144
|
+
completedAtEpochMs: z.ZodOptional<z.ZodNumber>;
|
|
145
|
+
createdAtEpochMs: z.ZodNumber;
|
|
146
|
+
}, z.core.$strict>;
|
|
147
|
+
export type ObligationStateRecord = z.infer<typeof ObligationStateRecordSchema>;
|
|
@@ -80,6 +80,73 @@ export declare const ProtectedPersistParametersV1Schema: z.ZodObject<{
|
|
|
80
80
|
value: z.ZodString;
|
|
81
81
|
}, z.core.$strict>;
|
|
82
82
|
export type ProtectedPersistParametersV1 = z.infer<typeof ProtectedPersistParametersV1Schema>;
|
|
83
|
+
export declare const PROTECTED_DERIVE_SCHEMA = "odingard.guardian.protected-data.derive.v1";
|
|
84
|
+
export declare const PROTECTED_TRANSFORM_SCHEMA = "odingard.guardian.protected-data.transform.v1";
|
|
85
|
+
export declare const PROTECTED_EXPORT_SCHEMA = "odingard.guardian.protected-data.export.v1";
|
|
86
|
+
export declare const ProtectedDeriveParametersV1Schema: z.ZodObject<{
|
|
87
|
+
schema: z.ZodLiteral<"odingard.guardian.protected-data.derive.v1">;
|
|
88
|
+
connectionId: z.core.$ZodBranded<z.ZodString, "ConnectionId", "out">;
|
|
89
|
+
dataObjectIds: z.ZodArray<z.core.$ZodBranded<z.ZodString, "DataObjectId", "out">>;
|
|
90
|
+
resultClassification: z.ZodOptional<z.ZodEnum<{
|
|
91
|
+
financial: "financial";
|
|
92
|
+
internal: "internal";
|
|
93
|
+
public: "public";
|
|
94
|
+
pii: "pii";
|
|
95
|
+
phi: "phi";
|
|
96
|
+
credential: "credential";
|
|
97
|
+
confidential: "confidential";
|
|
98
|
+
}>>;
|
|
99
|
+
transformation: z.ZodOptional<z.ZodObject<{
|
|
100
|
+
type: z.ZodString;
|
|
101
|
+
resultClassification: z.ZodEnum<{
|
|
102
|
+
financial: "financial";
|
|
103
|
+
internal: "internal";
|
|
104
|
+
public: "public";
|
|
105
|
+
pii: "pii";
|
|
106
|
+
phi: "phi";
|
|
107
|
+
credential: "credential";
|
|
108
|
+
confidential: "confidential";
|
|
109
|
+
}>;
|
|
110
|
+
}, z.core.$strict>>;
|
|
111
|
+
}, z.core.$strict>;
|
|
112
|
+
export type ProtectedDeriveParametersV1 = z.infer<typeof ProtectedDeriveParametersV1Schema>;
|
|
113
|
+
export declare const ProtectedTransformParametersV1Schema: z.ZodObject<{
|
|
114
|
+
schema: z.ZodLiteral<"odingard.guardian.protected-data.transform.v1">;
|
|
115
|
+
connectionId: z.core.$ZodBranded<z.ZodString, "ConnectionId", "out">;
|
|
116
|
+
dataObjectIds: z.ZodArray<z.core.$ZodBranded<z.ZodString, "DataObjectId", "out">>;
|
|
117
|
+
resultClassification: z.ZodOptional<z.ZodEnum<{
|
|
118
|
+
financial: "financial";
|
|
119
|
+
internal: "internal";
|
|
120
|
+
public: "public";
|
|
121
|
+
pii: "pii";
|
|
122
|
+
phi: "phi";
|
|
123
|
+
credential: "credential";
|
|
124
|
+
confidential: "confidential";
|
|
125
|
+
}>>;
|
|
126
|
+
transformation: z.ZodOptional<z.ZodObject<{
|
|
127
|
+
type: z.ZodString;
|
|
128
|
+
resultClassification: z.ZodEnum<{
|
|
129
|
+
financial: "financial";
|
|
130
|
+
internal: "internal";
|
|
131
|
+
public: "public";
|
|
132
|
+
pii: "pii";
|
|
133
|
+
phi: "phi";
|
|
134
|
+
credential: "credential";
|
|
135
|
+
confidential: "confidential";
|
|
136
|
+
}>;
|
|
137
|
+
}, z.core.$strict>>;
|
|
138
|
+
}, z.core.$strict>;
|
|
139
|
+
export type ProtectedTransformParametersV1 = z.infer<typeof ProtectedTransformParametersV1Schema>;
|
|
140
|
+
export declare const ProtectedExportParametersV1Schema: z.ZodObject<{
|
|
141
|
+
schema: z.ZodLiteral<"odingard.guardian.protected-data.export.v1">;
|
|
142
|
+
connectionId: z.core.$ZodBranded<z.ZodString, "ConnectionId", "out">;
|
|
143
|
+
dataObjectIds: z.ZodArray<z.core.$ZodBranded<z.ZodString, "DataObjectId", "out">>;
|
|
144
|
+
counterparty: z.ZodOptional<z.ZodString>;
|
|
145
|
+
}, z.core.$strict>;
|
|
146
|
+
export type ProtectedExportParametersV1 = z.infer<typeof ProtectedExportParametersV1Schema>;
|
|
147
|
+
export declare function protectedDeriveVerificationProjection(input: ProtectedDeriveParametersV1): unknown;
|
|
148
|
+
export declare function protectedTransformVerificationProjection(input: ProtectedTransformParametersV1): unknown;
|
|
149
|
+
export declare function protectedExportVerificationProjection(input: ProtectedExportParametersV1): unknown;
|
|
83
150
|
export declare function protectedCatalogField(catalog: readonly ProtectedCatalogEntry[] | undefined, fieldRef: string): ProtectedCatalogEntry | null;
|
|
84
151
|
/** use sink is authorized only by an exact declared sink binding. */
|
|
85
152
|
export declare function protectedSinkWithinUseSinks(sink: {
|