@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,287 @@
1
+ import { type TransactionDeclaration } from "./transaction.js";
2
+ import { type ActionAuthorityFacts } from "./commerce.js";
3
+ import type { ResourceClaim } from "./resource-claims.js";
4
+ import { type ProtectedCatalogEntry } from "./protected-data.js";
5
+ import { type ToolDescriptor } from "./tools.js";
6
+ /**
7
+ * GUA-UNIVERSAL-001 §7 — Universal Action Registry.
8
+ *
9
+ * Every consequential action is registered independently of provider. The
10
+ * authority kernel resolves an action_id to an ActionDefinition and invokes
11
+ * its hooks uniformly; it never branches on action/provider identity (K15).
12
+ * Adding a new action means adding a registry definition plus an adapter —
13
+ * no kernel change.
14
+ */
15
+ export type Reversibility = "reversible" | "limited" | "difficult" | "destructive" | "safety-sensitive";
16
+ export type RiskClass = "R0" | "R1" | "R2" | "R3" | "R4" | "R5";
17
+ /** The connection facts an action definition may bind against. */
18
+ export type ActionConnectionBinding = Readonly<{
19
+ provider: string;
20
+ mailboxAddress?: string;
21
+ endpointAllowlist?: readonly string[];
22
+ /** Provider "tool" connections carry the installed tool-server catalog. */
23
+ toolServer?: Readonly<{
24
+ serverName: string;
25
+ serverVersion: string;
26
+ tools: readonly ToolDescriptor[];
27
+ }>;
28
+ /** Tool names enabled for the requesting agent (agent_tools registry). */
29
+ enabledToolNames?: readonly string[];
30
+ calendarId?: string;
31
+ /** Canonical path prefixes file ops may touch (files provider). */
32
+ pathAllowlist?: readonly string[];
33
+ /** Canonical path prefixes a file may be shared from (files provider). */
34
+ shareAllowlist?: readonly string[];
35
+ /** Declared protected fields for this connection (protected_data). */
36
+ protectedCatalog?: readonly ProtectedCatalogEntry[];
37
+ /**
38
+ * WO-016 — provider "guardian" connections bind delegation facts for the
39
+ * requesting agent: which sub-agents are bonded to it, and the parent's
40
+ * derived authority ceiling per target connection. An unbonded child id or
41
+ * a delegation outside the ceiling fails the binding (DENY).
42
+ */
43
+ bondedSubAgentIds?: readonly string[];
44
+ delegationCeilings?: Readonly<Record<string, {
45
+ actionIds: readonly string[];
46
+ }>>;
47
+ /**
48
+ * WO-021 — the universal Resource Claim projected from this connection's
49
+ * binding facts (guardian.resource-claim.v1). Built-in definitions keep
50
+ * reading the legacy vertical fields above; pack-defined actions evaluate
51
+ * their declarative claim/binding rules against this claim only.
52
+ */
53
+ claims?: ResourceClaim;
54
+ }>;
55
+ export type ActionBindingResult = Readonly<{
56
+ ok: true;
57
+ }> | Readonly<{
58
+ ok: false;
59
+ reasonCode: string;
60
+ }>;
61
+ /**
62
+ * WO-028 (§34) — the full canonical lifecycle declared on consequential
63
+ * action kinds. An intent may union its own declaration on top; the
64
+ * effective lifecycle binds into the canonical action digest.
65
+ */
66
+ export declare const FULL_TRANSACTION_LIFECYCLE: TransactionDeclaration;
67
+ export interface ActionDefinition<P = unknown> {
68
+ readonly actionId: string;
69
+ readonly schemaVersion: 1;
70
+ readonly actionFamily: string;
71
+ readonly humanLabel: string;
72
+ readonly description: string;
73
+ /** Typed kind returned to the pipeline after parameter validation. */
74
+ readonly parametersKind: string;
75
+ /** Raw field names, for rendering + policy primitives. */
76
+ readonly requiredParameters: readonly string[];
77
+ /** Fields bound into the material-parameter digest (TOCTOU, §27). */
78
+ readonly materialParameters: readonly string[];
79
+ /** Resource pattern: `${resourceType}:${connectionId}`. */
80
+ readonly resourceType: string;
81
+ /** Providers a connection may use for this action. */
82
+ readonly providers: readonly string[];
83
+ readonly counterpartyRules: string;
84
+ readonly dataEffects: string;
85
+ readonly reversibility: Reversibility;
86
+ readonly riskClass: RiskClass;
87
+ readonly defaultDecisionPosture: "allow" | "ask" | "deny";
88
+ /** Generic fields the Authority Slip renders. */
89
+ readonly approvalPresentationSchema: readonly string[];
90
+ /**
91
+ * WO-021 — optional labelled display fields. Signed Action Packs set these
92
+ * from their verified `approvalDisplay` metadata so the slip can render
93
+ * trusted labels against the bound material parameters; built-ins leave
94
+ * this unset and keep today's rendering.
95
+ */
96
+ readonly approvalDisplayFields?: readonly Readonly<{
97
+ field: string;
98
+ label: string;
99
+ }>[];
100
+ readonly capabilityRequirements: Readonly<{
101
+ uses: number;
102
+ }>;
103
+ readonly executionContract: string;
104
+ readonly verificationContract: Readonly<{
105
+ level: string;
106
+ }>;
107
+ readonly evidenceRequirements: readonly string[];
108
+ readonly version: 1;
109
+ readonly status: "active" | "deprecated" | "disabled";
110
+ /**
111
+ * When true the action is capability-expanding: authority derivation never
112
+ * auto-includes it in a grant's action set. It can only enter a grant when
113
+ * a human selects it explicitly (WO-015 self-serve-escalation denial).
114
+ */
115
+ readonly requiresExplicitGrant?: boolean;
116
+ /**
117
+ * WO-019 — minimum principal class allowed to hold authority for this
118
+ * action. "adult" marks governance and identity-level actions that a
119
+ * child-classed principal can never be granted: the control plane excludes
120
+ * them when emitting authority for a child, so the kernel DENYs with
121
+ * ACTION_NOT_ALLOWED. Absent means any principal class may hold it.
122
+ */
123
+ readonly minPrincipalClass?: "adult";
124
+ /**
125
+ * WO-028 (§34–35) — when set, every action of this kind executes under
126
+ * a recorded guardian.transaction.v1 lifecycle. Unioned with the
127
+ * governing intent's own declaration (canonical order; never shrinks);
128
+ * the effective declaration binds into the canonical action digest.
129
+ */
130
+ readonly transaction?: TransactionDeclaration;
131
+ /**
132
+ * WO-028 (§36) — declared compensation mapping: this action kind
133
+ * compensates `compensatesAction` (e.g. commerce.refund compensates
134
+ * commerce.purchase). A compensating action still runs the full
135
+ * authority path — it never bypasses ASK or enlarges authority.
136
+ */
137
+ readonly compensatesAction?: string;
138
+ /**
139
+ * Action-specific logic lives HERE — inside the registered definition —
140
+ * never inside the kernel. Hooks receive only kernel-verified inputs.
141
+ */
142
+ validateParameters(materialParameters: unknown): Readonly<{
143
+ ok: true;
144
+ params: P;
145
+ } | {
146
+ ok: false;
147
+ }>;
148
+ /** Pre-execution binding the agent's params to the leased connection. */
149
+ validateBinding(input: {
150
+ params: P;
151
+ connection: ActionConnectionBinding;
152
+ }): ActionBindingResult;
153
+ /** Canonical projection whose digest the verified outcome must match. */
154
+ verificationProjection(params: P): unknown;
155
+ /** Envelope projection recorded at reservation time. */
156
+ envelopeProjection(params: P): unknown;
157
+ /**
158
+ * Generic monetary-authority facts derived from validated parameters
159
+ * (WO-014). When present, the envelope's declared facts must equal the
160
+ * derived values, so an agent cannot understate an amount or smuggle a
161
+ * merchant/category/recurrence fact past the kernel.
162
+ */
163
+ authorityFacts?(params: P): ActionAuthorityFacts;
164
+ }
165
+ export type ActionRegistry = Readonly<{
166
+ get(actionId: string): ActionDefinition | undefined;
167
+ entries(): readonly ActionDefinition[];
168
+ }>;
169
+ export declare function createActionRegistry(definitions: readonly ActionDefinition[]): ActionRegistry;
170
+ export declare const EMAIL_SEND_DEFINITION: ActionDefinition<{
171
+ schema: "odingard.guardian.email.send.v1";
172
+ connectionId: string & import("zod").$brand<"ConnectionId">;
173
+ from: string;
174
+ to: string[];
175
+ cc: string[];
176
+ bcc: string[];
177
+ replyTo: never[];
178
+ subject: string;
179
+ body: {
180
+ format: "text/plain";
181
+ text: string;
182
+ };
183
+ attachments: never[];
184
+ inReplyTo: null;
185
+ }>;
186
+ export declare const API_REQUEST_DEFINITION: ActionDefinition<{
187
+ schema: "odingard.guardian.api.request.v1";
188
+ connectionId: string & import("zod").$brand<"ConnectionId">;
189
+ method: "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE";
190
+ url: string;
191
+ headers: {
192
+ name: string;
193
+ value: string;
194
+ }[];
195
+ body?: string | undefined;
196
+ idempotencyKey?: string | undefined;
197
+ }>;
198
+ export declare const TOOL_INVOKE_DEFINITION: ActionDefinition<{
199
+ schema: "odingard.guardian.tool.invoke.v1";
200
+ connectionId: string & import("zod").$brand<"ConnectionId">;
201
+ toolName: string;
202
+ arguments: Record<string, unknown>;
203
+ }>;
204
+ export declare const MCP_INSTALL_DEFINITION: ActionDefinition<{
205
+ schema: "odingard.guardian.mcp.install.v1";
206
+ connectionId: string & import("zod").$brand<"ConnectionId">;
207
+ tool: {
208
+ name: string;
209
+ method: "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE";
210
+ url: string;
211
+ description?: string | undefined;
212
+ transport?: "http" | undefined;
213
+ } | {
214
+ name: string;
215
+ transport: "record";
216
+ description?: string | undefined;
217
+ };
218
+ }>;
219
+ export declare const MCP_ENABLE_DEFINITION: ActionDefinition<{
220
+ schema: "odingard.guardian.mcp.enable.v1";
221
+ connectionId: string & import("zod").$brand<"ConnectionId">;
222
+ toolName: string;
223
+ }>;
224
+ export declare const COMMERCE_PURCHASE_DEFINITION: ActionDefinition<{
225
+ schema: "commerce.purchase.v1";
226
+ connectionId: string & import("zod").$brand<"ConnectionId">;
227
+ merchantId: string;
228
+ merchantCategory: string;
229
+ amountCents: number;
230
+ currency: "USD";
231
+ orderDescription: string;
232
+ idempotencyKey: string;
233
+ taskId?: (string & import("zod").$brand<"TaskId">) | undefined;
234
+ }>;
235
+ export declare const COMMERCE_REFUND_DEFINITION: ActionDefinition<{
236
+ schema: "commerce.refund.v1";
237
+ connectionId: string & import("zod").$brand<"ConnectionId">;
238
+ chargeId: string;
239
+ reason: string;
240
+ amountCents?: number | undefined;
241
+ }>;
242
+ export declare const COMMERCE_RETURN_DEFINITION: ActionDefinition<{
243
+ schema: "commerce.return.v1";
244
+ connectionId: string & import("zod").$brand<"ConnectionId">;
245
+ chargeId: string;
246
+ reason: string;
247
+ }>;
248
+ export declare const SUBSCRIPTION_CREATE_DEFINITION: ActionDefinition<{
249
+ schema: "subscription.create.v1";
250
+ connectionId: string & import("zod").$brand<"ConnectionId">;
251
+ merchantId: string;
252
+ planId: string;
253
+ amountCents: number;
254
+ currency: "USD";
255
+ interval: "week" | "month" | "year";
256
+ idempotencyKey: string;
257
+ }>;
258
+ export declare const LOCAL_EXEC_DEFINITION: ActionDefinition<{
259
+ schema: "odingard.guardian.local.exec.v1";
260
+ connectionId: string & import("zod").$brand<"ConnectionId">;
261
+ command: string;
262
+ cwd?: string | undefined;
263
+ }>;
264
+ export declare const LOCAL_EXEC_PUBLISH_DEFINITION: ActionDefinition<{
265
+ schema: "odingard.guardian.local.exec.v1";
266
+ connectionId: string & import("zod").$brand<"ConnectionId">;
267
+ command: string;
268
+ cwd?: string | undefined;
269
+ }>;
270
+ export declare const LOCAL_EXEC_DESTROY_DEFINITION: ActionDefinition<{
271
+ schema: "odingard.guardian.local.exec.v1";
272
+ connectionId: string & import("zod").$brand<"ConnectionId">;
273
+ command: string;
274
+ cwd?: string | undefined;
275
+ }>;
276
+ export declare const LOCAL_EGRESS_DEFINITION: ActionDefinition<{
277
+ schema: "odingard.guardian.local.egress.v1";
278
+ connectionId: string & import("zod").$brand<"ConnectionId">;
279
+ url: string;
280
+ method: "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS";
281
+ }>;
282
+ export declare const LOCAL_BROWSE_DEFINITION: ActionDefinition<{
283
+ schema: "odingard.guardian.local.browse.v1";
284
+ connectionId: string & import("zod").$brand<"ConnectionId">;
285
+ url: string;
286
+ }>;
287
+ export declare const universalActionRegistry: ActionRegistry;