@odingard/guardian-sdk 0.0.0-stage → 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.
Files changed (58) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +302 -2
  3. package/dist/contracts.js +9865 -0
  4. package/dist/index.js +14437 -0
  5. package/dist/public-catalog.v1.json +6915 -0
  6. package/dist-dts/catalog.d.ts +14 -0
  7. package/dist-dts/client.d.ts +130 -0
  8. package/dist-dts/contracts/action-pack.d.ts +464 -0
  9. package/dist-dts/contracts/action-parameters.d.ts +34 -0
  10. package/dist-dts/contracts/action-registry.d.ts +287 -0
  11. package/dist-dts/contracts/action.d.ts +2358 -0
  12. package/dist-dts/contracts/agent-state.d.ts +386 -0
  13. package/dist-dts/contracts/api.d.ts +78 -0
  14. package/dist-dts/contracts/approval.d.ts +425 -0
  15. package/dist-dts/contracts/assurance.d.ts +60 -0
  16. package/dist-dts/contracts/authority-graph.d.ts +294 -0
  17. package/dist-dts/contracts/authority-state.d.ts +108 -0
  18. package/dist-dts/contracts/authority.d.ts +339 -0
  19. package/dist-dts/contracts/billing.d.ts +32 -0
  20. package/dist-dts/contracts/calendar.d.ts +146 -0
  21. package/dist-dts/contracts/canonical-json.d.ts +4 -0
  22. package/dist-dts/contracts/capability.d.ts +28 -0
  23. package/dist-dts/contracts/commerce.d.ts +133 -0
  24. package/dist-dts/contracts/denial.d.ts +648 -0
  25. package/dist-dts/contracts/digest.d.ts +2 -0
  26. package/dist-dts/contracts/email.d.ts +45 -0
  27. package/dist-dts/contracts/evidence.d.ts +1087 -0
  28. package/dist-dts/contracts/execution.d.ts +1732 -0
  29. package/dist-dts/contracts/files.d.ts +61 -0
  30. package/dist-dts/contracts/identifiers.d.ts +49 -0
  31. package/dist-dts/contracts/index.d.ts +41 -0
  32. package/dist-dts/contracts/intent.d.ts +335 -0
  33. package/dist-dts/contracts/lineage.d.ts +218 -0
  34. package/dist-dts/contracts/local.d.ts +101 -0
  35. package/dist-dts/contracts/multi-principal.d.ts +292 -0
  36. package/dist-dts/contracts/multiparty.d.ts +169 -0
  37. package/dist-dts/contracts/obligation.d.ts +196 -0
  38. package/dist-dts/contracts/plan.d.ts +67 -0
  39. package/dist-dts/contracts/policy-simulation.d.ts +681 -0
  40. package/dist-dts/contracts/prerequisite.d.ts +147 -0
  41. package/dist-dts/contracts/protected-data.d.ts +160 -0
  42. package/dist-dts/contracts/receipt.d.ts +3126 -0
  43. package/dist-dts/contracts/resource-claims.d.ts +146 -0
  44. package/dist-dts/contracts/runtime.d.ts +111 -0
  45. package/dist-dts/contracts/safety-envelope.d.ts +287 -0
  46. package/dist-dts/contracts/sequence.d.ts +132 -0
  47. package/dist-dts/contracts/sources.d.ts +191 -0
  48. package/dist-dts/contracts/tools.d.ts +232 -0
  49. package/dist-dts/contracts/transaction.d.ts +360 -0
  50. package/dist-dts/contracts-entry.d.ts +1 -0
  51. package/dist-dts/embedded.d.ts +58 -0
  52. package/dist-dts/evidence/evidence.d.ts +25 -0
  53. package/dist-dts/evidence/receipt.d.ts +61 -0
  54. package/dist-dts/index.d.ts +5 -0
  55. package/dist-dts/lifecycle.d.ts +25 -0
  56. package/dist-dts/proposal.d.ts +41 -0
  57. package/dist-dts/receipts.d.ts +37 -0
  58. package/package.json +56 -4
@@ -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>;
@@ -0,0 +1,160 @@
1
+ import { z } from "zod";
2
+ import { filePathWithinAllowlist } from "./files.js";
3
+ /**
4
+ * WO-013 — protected data broker. The adapter injects protected values at
5
+ * execution time; the agent never receives reusable plaintext. The catalog
6
+ * below is declarative (which fields are protected, per connection /
7
+ * principal) — it is not a DLP or classification engine.
8
+ */
9
+ export declare const PROTECTED_FIELD_REF_MAX_LENGTH = 64;
10
+ export declare const PROTECTED_VALUE_MAX_LENGTH = 4096;
11
+ export declare const PROTECTED_CATALOG_MAX_ENTRIES = 128;
12
+ export declare const PROTECTED_USE_SINKS_MAX_ENTRIES = 16;
13
+ export declare const PROTECTED_DISCLOSE_TARGETS_MAX_ENTRIES = 32;
14
+ export declare const ProtectedFieldRefSchema: z.ZodString;
15
+ export declare const ProtectedUseSinkSchema: z.ZodObject<{
16
+ connectionId: z.core.$ZodBranded<z.ZodString, "ConnectionId", "out">;
17
+ pathPrefix: z.ZodString;
18
+ }, z.core.$strict>;
19
+ export type ProtectedUseSink = z.infer<typeof ProtectedUseSinkSchema>;
20
+ /** A declared protected field on one connection (per principal). */
21
+ export declare const ProtectedCatalogEntrySchema: z.ZodObject<{
22
+ fieldRef: z.ZodString;
23
+ label: z.ZodString;
24
+ maskedPreview: z.ZodString;
25
+ allowUse: z.ZodBoolean;
26
+ allowView: z.ZodBoolean;
27
+ allowPersist: z.ZodBoolean;
28
+ useSinks: z.ZodArray<z.ZodObject<{
29
+ connectionId: z.core.$ZodBranded<z.ZodString, "ConnectionId", "out">;
30
+ pathPrefix: z.ZodString;
31
+ }, z.core.$strict>>;
32
+ discloseTargets: z.ZodArray<z.ZodString>;
33
+ }, z.core.$strict>;
34
+ export type ProtectedCatalogEntry = z.infer<typeof ProtectedCatalogEntrySchema>;
35
+ export declare const ProtectedCatalogSchema: z.ZodArray<z.ZodObject<{
36
+ fieldRef: z.ZodString;
37
+ label: z.ZodString;
38
+ maskedPreview: z.ZodString;
39
+ allowUse: z.ZodBoolean;
40
+ allowView: z.ZodBoolean;
41
+ allowPersist: z.ZodBoolean;
42
+ useSinks: z.ZodArray<z.ZodObject<{
43
+ connectionId: z.core.$ZodBranded<z.ZodString, "ConnectionId", "out">;
44
+ pathPrefix: z.ZodString;
45
+ }, z.core.$strict>>;
46
+ discloseTargets: z.ZodArray<z.ZodString>;
47
+ }, z.core.$strict>>;
48
+ export type ProtectedCatalog = readonly ProtectedCatalogEntry[];
49
+ export declare const PROTECTED_USE_SCHEMA = "odingard.guardian.protected-data.use.v1";
50
+ export declare const PROTECTED_VIEW_SCHEMA = "odingard.guardian.protected-data.view.v1";
51
+ export declare const PROTECTED_DISCLOSE_SCHEMA = "odingard.guardian.protected-data.disclose.v1";
52
+ export declare const PROTECTED_PERSIST_SCHEMA = "odingard.guardian.protected-data.persist.v1";
53
+ export declare const ProtectedUseParametersV1Schema: z.ZodObject<{
54
+ schema: z.ZodLiteral<"odingard.guardian.protected-data.use.v1">;
55
+ connectionId: z.core.$ZodBranded<z.ZodString, "ConnectionId", "out">;
56
+ fieldRef: z.ZodString;
57
+ sink: z.ZodObject<{
58
+ connectionId: z.core.$ZodBranded<z.ZodString, "ConnectionId", "out">;
59
+ path: z.ZodString;
60
+ }, z.core.$strict>;
61
+ }, z.core.$strict>;
62
+ export type ProtectedUseParametersV1 = z.infer<typeof ProtectedUseParametersV1Schema>;
63
+ export declare const ProtectedViewParametersV1Schema: z.ZodObject<{
64
+ schema: z.ZodLiteral<"odingard.guardian.protected-data.view.v1">;
65
+ connectionId: z.core.$ZodBranded<z.ZodString, "ConnectionId", "out">;
66
+ fieldRef: z.ZodString;
67
+ }, z.core.$strict>;
68
+ export type ProtectedViewParametersV1 = z.infer<typeof ProtectedViewParametersV1Schema>;
69
+ export declare const ProtectedDiscloseParametersV1Schema: z.ZodObject<{
70
+ schema: z.ZodLiteral<"odingard.guardian.protected-data.disclose.v1">;
71
+ connectionId: z.core.$ZodBranded<z.ZodString, "ConnectionId", "out">;
72
+ fieldRef: z.ZodString;
73
+ counterparty: z.ZodString;
74
+ }, z.core.$strict>;
75
+ export type ProtectedDiscloseParametersV1 = z.infer<typeof ProtectedDiscloseParametersV1Schema>;
76
+ export declare const ProtectedPersistParametersV1Schema: z.ZodObject<{
77
+ schema: z.ZodLiteral<"odingard.guardian.protected-data.persist.v1">;
78
+ connectionId: z.core.$ZodBranded<z.ZodString, "ConnectionId", "out">;
79
+ fieldRef: z.ZodString;
80
+ value: z.ZodString;
81
+ }, z.core.$strict>;
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;
150
+ export declare function protectedCatalogField(catalog: readonly ProtectedCatalogEntry[] | undefined, fieldRef: string): ProtectedCatalogEntry | null;
151
+ /** use sink is authorized only by an exact declared sink binding. */
152
+ export declare function protectedSinkWithinUseSinks(sink: {
153
+ connectionId: string;
154
+ path: string;
155
+ }, useSinks: readonly ProtectedUseSink[]): boolean;
156
+ export declare function protectedUseVerificationProjection(input: ProtectedUseParametersV1): unknown;
157
+ export declare function protectedViewVerificationProjection(input: ProtectedViewParametersV1): unknown;
158
+ export declare function protectedDiscloseVerificationProjection(input: ProtectedDiscloseParametersV1): unknown;
159
+ export declare function protectedPersistVerificationProjection(input: ProtectedPersistParametersV1): unknown;
160
+ export { filePathWithinAllowlist };