@decionis/agent-safe-pipeline 0.4.0 → 0.4.1

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 (43) hide show
  1. package/README.md +19 -0
  2. package/dist/Index.d.ts +3 -0
  3. package/dist/Index.d.ts.map +1 -1
  4. package/dist/Index.js +3 -0
  5. package/dist/Index.js.map +1 -1
  6. package/dist/execution/GovernedExecutionRunner.d.ts +6 -0
  7. package/dist/execution/GovernedExecutionRunner.d.ts.map +1 -1
  8. package/dist/execution/GovernedExecutionRunner.js +18 -1
  9. package/dist/execution/GovernedExecutionRunner.js.map +1 -1
  10. package/dist/execution/NativeExecutor.d.ts +7 -1
  11. package/dist/execution/NativeExecutor.d.ts.map +1 -1
  12. package/dist/execution/NativeExecutor.js.map +1 -1
  13. package/dist/intent/CanonicalIntentHasher.d.ts.map +1 -1
  14. package/dist/intent/CanonicalIntentHasher.js +11 -0
  15. package/dist/intent/CanonicalIntentHasher.js.map +1 -1
  16. package/dist/intent/ExecutionIntent.d.ts +44 -4
  17. package/dist/intent/ExecutionIntent.d.ts.map +1 -1
  18. package/dist/intent/ExecutionIntent.js +25 -0
  19. package/dist/intent/ExecutionIntent.js.map +1 -1
  20. package/dist/intent/IntentBindingSchema.d.ts +6 -0
  21. package/dist/intent/IntentBindingSchema.d.ts.map +1 -1
  22. package/dist/intent/IntentBindingSchema.js +10 -0
  23. package/dist/intent/IntentBindingSchema.js.map +1 -1
  24. package/dist/intent/IntentCapture.d.ts.map +1 -1
  25. package/dist/intent/IntentCapture.js +3 -0
  26. package/dist/intent/IntentCapture.js.map +1 -1
  27. package/dist/profile/ApiProfile.d.ts +154 -0
  28. package/dist/profile/ApiProfile.d.ts.map +1 -0
  29. package/dist/profile/ApiProfile.js +369 -0
  30. package/dist/profile/ApiProfile.js.map +1 -0
  31. package/dist/profile/ApiProfiles.d.ts +16 -0
  32. package/dist/profile/ApiProfiles.d.ts.map +1 -0
  33. package/dist/profile/ApiProfiles.js +29 -0
  34. package/dist/profile/ApiProfiles.js.map +1 -0
  35. package/dist/profile/BuiltInApiProfiles.d.ts +9 -0
  36. package/dist/profile/BuiltInApiProfiles.d.ts.map +1 -0
  37. package/dist/profile/BuiltInApiProfiles.js +296 -0
  38. package/dist/profile/BuiltInApiProfiles.js.map +1 -0
  39. package/dist/testing/LocalAuthority.d.ts +6 -0
  40. package/dist/testing/LocalAuthority.d.ts.map +1 -1
  41. package/dist/testing/LocalAuthority.js +8 -0
  42. package/dist/testing/LocalAuthority.js.map +1 -1
  43. package/package.json +4 -3
@@ -1 +1 @@
1
- {"version":3,"file":"ExecutionIntent.js","sourceRoot":"","sources":["../../src/intent/ExecutionIntent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAmB,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACpD,MAAM,UAAU,GAAG,CAAC;KACjB,MAAM,EAAE;KACR,IAAI,EAAE;KACN,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,GAAG,CAAC;KACR,KAAK,CAAC,sBAAsB,CAAC,CAAC;AACjC,qFAAqF;AACrF,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;AAE/D,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC;KACjC,MAAM,CAAC;IACN,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IACzC,UAAU,EAAE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AAC;KACnC,MAAM,CAAC;IACN,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC;IACzC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IAC3B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IAC3B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,KAAK,EAAE,iBAAiB;IACxB,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IACzC,UAAU,EAAE,gBAAgB;IAC5B,gBAAgB,EAAE,sBAAsB;IACxC,OAAO,EAAE,gBAAgB;IACzB,aAAa,EAAE,SAAS,CAAC,QAAQ,EAAE;IACnC,oBAAoB,EAAE,YAAY,CAAC,QAAQ,EAAE;IAC7C,gBAAgB,EAAE,sBAAsB,CAAC,QAAQ,EAAE;IACnD,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;CAClD,CAAC;KACD,MAAM,EAAE,CAAC"}
@@ -36,6 +36,12 @@ export declare const AuthorityIntentBindingSchema: z.ZodObject<{
36
36
  environment: z.ZodOptional<z.ZodString>;
37
37
  endpoint: z.ZodOptional<z.ZodString>;
38
38
  }, z.core.$strict>;
39
+ policy_projection: z.ZodOptional<z.ZodObject<{
40
+ decision_type: z.ZodString;
41
+ transaction_type: z.ZodNullable<z.ZodString>;
42
+ workflow_key: z.ZodNullable<z.ZodString>;
43
+ channel: z.ZodNullable<z.ZodString>;
44
+ }, z.core.$strict>>;
39
45
  expected_effect_digest: z.ZodOptional<z.ZodString>;
40
46
  }, z.core.$strict>;
41
47
  /** What the schema accepts; the tests hold it to the `AuthorityIntentBinding` wire interface. */
@@ -1 +1 @@
1
- {"version":3,"file":"IntentBindingSchema.d.ts","sourceRoot":"","sources":["../../src/intent/IntentBindingSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,6EAA6E;AAC7E,eAAO,MAAM,gBAAgB,2FAC6D,CAAC;AAU3F;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAsCrC,CAAC;AAEL,iGAAiG;AACjG,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAEvF;;;;;GAKG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOjE"}
1
+ {"version":3,"file":"IntentBindingSchema.d.ts","sourceRoot":"","sources":["../../src/intent/IntentBindingSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,6EAA6E;AAC7E,eAAO,MAAM,gBAAgB,2FAC6D,CAAC;AAW3F;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA+CrC,CAAC;AAEL,iGAAiG;AACjG,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAEvF;;;;;GAKG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOjE"}
@@ -9,6 +9,7 @@ const actionType = z
9
9
  .max(120)
10
10
  .regex(/^[a-z][a-z0-9._:-]*$/);
11
11
  const sha256Digest = z.string().regex(/^sha256:[0-9a-f]{64}$/);
12
+ const projectionValue = z.string().min(1).max(120);
12
13
  /**
13
14
  * The `agent-safe.intent/1` binding as it is hashed and sent, as a strict
14
15
  * schema: what `CanonicalIntentHasher.bindingOf` produces, and what an
@@ -49,6 +50,15 @@ export const AuthorityIntentBindingSchema = z
49
50
  endpoint: z.string().min(1).max(500).optional(),
50
51
  })
51
52
  .strict(),
53
+ policy_projection: z
54
+ .object({
55
+ decision_type: projectionValue,
56
+ transaction_type: projectionValue.nullable(),
57
+ workflow_key: projectionValue.nullable(),
58
+ channel: projectionValue.nullable(),
59
+ })
60
+ .strict()
61
+ .optional(),
52
62
  expected_effect_digest: sha256Digest.optional(),
53
63
  })
54
64
  .strict()
@@ -1 +1 @@
1
- {"version":3,"file":"IntentBindingSchema.js","sourceRoot":"","sources":["../../src/intent/IntentBindingSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEnE,6EAA6E;AAC7E,MAAM,CAAC,MAAM,gBAAgB,GAC3B,wFAAwF,CAAC;AAE3F,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC9C,MAAM,UAAU,GAAG,CAAC;KACjB,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,GAAG,CAAC;KACR,KAAK,CAAC,sBAAsB,CAAC,CAAC;AACjC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;AAE/D;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC;KAC1C,MAAM,CAAC;IACN,gBAAgB,EAAE,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC;IAClD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IAC5B,SAAS,EAAE,CAAC,CAAC,MAAM,EA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CAAC,MAAM,CAAwB;IAC/C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IACnC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IACxC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA4B;gBAE/B,OAAO,CAAC,EAAE,oBAAoB;IAQ1C,OAAO,CAAC,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,oBAAoB,GAAG,cAAc;IAyChG,6EAA6E;IAChE,eAAe,CAC1B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,oBAAoB,GACjC,OAAO,CAAC,cAAc,CAAC;CAK3B"}
@@ -47,6 +47,9 @@ export class IntentCapture {
47
47
  ...(trusted.expectedEffectDigest === undefined
48
48
  ? {}
49
49
  : { expectedEffectDigest: trusted.expectedEffectDigest }),
50
+ ...(trusted.policyProjection === undefined
51
+ ? {}
52
+ : { policyProjection: trusted.policyProjection }),
50
53
  idempotencyKey: trusted.idempotencyKey,
51
54
  });
52
55
  return this.hasher.capture(intent);
@@ -1 +1 @@
1
- {"version":3,"file":"IntentCapture.js","sourceRoot":"","sources":["../../src/intent/IntentCapture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,gCAAgC,EAChC,0BAA0B,GAI3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAUnE,MAAM,OAAO,aAAa;IACP,MAAM,CAAwB;IAC9B,KAAK,CAAa;IAClB,QAAQ,CAAe;IACvB,UAAU,CAAS;IACnB,KAAK,CAA4B;IAElD,YAAmB,OAA8B;QAC/C,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,IAAI,qBA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AO,CAAC,OAAO,CAAC,EAAE;YAC/D,GAAG,CAAC,OAAO,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC;YACxF,GAAG,CAAC,OAAO,CAAC,oBAAoB,KAAK,SAAS;gBAC5C,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,EAAE,oBAAoB,EAAE,OAAO,CAAC,oBAAoB,EAAE,CAAC;YAC3D,GAAG,CAAC,OAAO,CAAC,gBAAgB,KAAK,SAAS;gBACxC,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,EAAE,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,EAAE,CAAC;YACnD,cAAc,EAAE,OAAO,CAAC,cAAc;SACvC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IAED,6EAA6E;IACtE,KAAK,CAAC,eAAe,CAC1B,aAA4B,EAC5B,YAAkC;QAElC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;QAC3D,MAAM,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,QAAQ,EAAE,CAAC,CAAC;QACrE,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
@@ -0,0 +1,154 @@
1
+ import { z } from "zod";
2
+ import type { JsonObject, JsonValue } from "../intent/JsonValue.js";
3
+ /**
4
+ * `agent-safe.profile.api/1`: a platform API described as data, so that every
5
+ * component that turns one of its calls into an intent turns it into the same
6
+ * one. A profile maps method + path (and, where an API overloads a path, an
7
+ * exact query value) to an action type, and names the facts a decision reads
8
+ * by JSON pointer into the call. The gateway reads it to govern an agent's
9
+ * call; a native executor's `prepare` reads it to describe the call it is
10
+ * about to make. One mapping, no code coupling between them.
11
+ */
12
+ export declare const API_PROFILE_CONTRACT = "agent-safe.profile.api/1";
13
+ export declare const API_PROFILE_SCHEMA_ID = "https://github.com/decionis/agent-safe-pipeline/blob/master/spec/profiles/api/v1/schema.json";
14
+ /** The methods a profile governs; a read is never an operation. */
15
+ export declare const API_PROFILE_METHODS: readonly ["POST", "PUT", "PATCH", "DELETE"];
16
+ export type ApiProfileMethod = (typeof API_PROFILE_METHODS)[number];
17
+ /**
18
+ * Fact names a profile may not use. The first group is what the gateway
19
+ * already states in an intent's context; the second is what the Decionis
20
+ * authority states itself, or reads from the request rather than the context,
21
+ * so a fact of that name would be shadowed or refused there.
22
+ */
23
+ export declare const RESERVED_FACT_NAMES: readonly string[];
24
+ /** The most elements one `*` pointer collects; more is not a fact, it is a payload. */
25
+ export declare const MAX_FACT_ELEMENTS = 100;
26
+ /** The longest string a fact carries; a longer value is not stated. */
27
+ export declare const MAX_FACT_STRING = 1000;
28
+ export declare const ApiPolicyProjectionSchema: z.ZodObject<{
29
+ decision_type: z.ZodString;
30
+ transaction_type: z.ZodNullable<z.ZodString>;
31
+ workflow_key: z.ZodNullable<z.ZodString>;
32
+ channel: z.ZodNullable<z.ZodString>;
33
+ }, z.core.$strict>;
34
+ export declare const ApiOperationSchema: z.ZodObject<{
35
+ id: z.ZodString;
36
+ method: z.ZodEnum<{
37
+ POST: "POST";
38
+ PUT: "PUT";
39
+ PATCH: "PATCH";
40
+ DELETE: "DELETE";
41
+ }>;
42
+ path: z.ZodString;
43
+ query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
44
+ action: z.ZodString;
45
+ summary: z.ZodString;
46
+ facts: z.ZodRecord<z.ZodString, z.ZodString>;
47
+ policy_projection: z.ZodNullable<z.ZodObject<{
48
+ decision_type: z.ZodString;
49
+ transaction_type: z.ZodNullable<z.ZodString>;
50
+ workflow_key: z.ZodNullable<z.ZodString>;
51
+ channel: z.ZodNullable<z.ZodString>;
52
+ }, z.core.$strict>>;
53
+ }, z.core.$strict>;
54
+ export declare const ApiProfileDefinitionSchema: z.ZodObject<{
55
+ profile: z.ZodLiteral<"agent-safe.profile.api/1">;
56
+ id: z.ZodString;
57
+ platform: z.ZodString;
58
+ title: z.ZodString;
59
+ prefixes: z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"">, z.ZodString]>>;
60
+ operations: z.ZodArray<z.ZodObject<{
61
+ id: z.ZodString;
62
+ method: z.ZodEnum<{
63
+ POST: "POST";
64
+ PUT: "PUT";
65
+ PATCH: "PATCH";
66
+ DELETE: "DELETE";
67
+ }>;
68
+ path: z.ZodString;
69
+ query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
70
+ action: z.ZodString;
71
+ summary: z.ZodString;
72
+ facts: z.ZodRecord<z.ZodString, z.ZodString>;
73
+ policy_projection: z.ZodNullable<z.ZodObject<{
74
+ decision_type: z.ZodString;
75
+ transaction_type: z.ZodNullable<z.ZodString>;
76
+ workflow_key: z.ZodNullable<z.ZodString>;
77
+ channel: z.ZodNullable<z.ZodString>;
78
+ }, z.core.$strict>>;
79
+ }, z.core.$strict>>;
80
+ }, z.core.$strict>;
81
+ export type ApiPolicyProjection = z.infer<typeof ApiPolicyProjectionSchema>;
82
+ export type ApiOperationDefinition = z.infer<typeof ApiOperationSchema>;
83
+ export type ApiProfileDefinition = z.infer<typeof ApiProfileDefinitionSchema>;
84
+ /** One call as a component is about to make it, or as the gateway received it. */
85
+ export interface ApiRequest {
86
+ readonly method: string;
87
+ /** The URL path, as sent (percent-encoded); without query or fragment. */
88
+ readonly path: string;
89
+ readonly query?: {
90
+ readonly [key: string]: string | readonly string[];
91
+ };
92
+ /** The parsed JSON body, when there is one. */
93
+ readonly body?: JsonValue;
94
+ }
95
+ /** What a profile says about one call. */
96
+ export interface ApiProfileMatch {
97
+ readonly profile: string;
98
+ readonly operation: string;
99
+ readonly action: string;
100
+ /** Every fact whose pointer resolved to a statable value; the others are absent. */
101
+ readonly facts: JsonObject;
102
+ readonly policyProjection: ApiPolicyProjection | null;
103
+ }
104
+ export declare class ApiProfileError extends Error {
105
+ readonly code: "API_PROFILE_INVALID";
106
+ readonly detail: string;
107
+ constructor(code: "API_PROFILE_INVALID", detail: string);
108
+ }
109
+ /**
110
+ * One profile, validated and compiled. Matching is deterministic and total:
111
+ * the first operation, in profile order, whose method, path and query match
112
+ * is the call's operation; a call no operation matches is not described by
113
+ * the profile and the caller decides what that means.
114
+ */
115
+ export declare class ApiProfile {
116
+ readonly definition: ApiProfileDefinition;
117
+ private readonly compiled;
118
+ private constructor();
119
+ /** Validates a definition (closed schema, unique operations, pointers, reserved names) and compiles it. */
120
+ static parse(value: unknown): ApiProfile;
121
+ get id(): string;
122
+ get platform(): string;
123
+ /** Every action type the profile can produce, for a registry to be sealed over. */
124
+ actions(): readonly string[];
125
+ operation(id: string): ApiOperationDefinition | null;
126
+ /**
127
+ * The operation a method, path and query select, before any body is read:
128
+ * what the gateway needs to decide whether to govern a call.
129
+ */
130
+ operationFor(method: string, path: string, query?: ApiRequest["query"]): ApiOperationDefinition | null;
131
+ /** The operation, action type, facts and policy projection of one call; null when no operation matches. */
132
+ match(request: ApiRequest): ApiProfileMatch | null;
133
+ private select;
134
+ /** A template as an anchored expression: placeholders take one segment's text, never a `/`. */
135
+ private static compile;
136
+ private static escape;
137
+ /** A placeholder's value: percent-decoded, OData quotes removed; null when it does not decode. */
138
+ private static decode;
139
+ private static queryMatches;
140
+ private static queryRoot;
141
+ /** RFC 6901 reference tokens, unescaped; one `*` token at most. */
142
+ private static pointerSegments;
143
+ /**
144
+ * The value at a pointer, when it is statable: a string (at most 1000
145
+ * characters), a finite number or a boolean; or, through one `*`, an array
146
+ * of up to 100 of them, every element statable. Anything else is absent.
147
+ */
148
+ private static read;
149
+ private static walk;
150
+ private static statable;
151
+ }
152
+ /** The published JSON Schema of a profile definition, generated from the validator above. */
153
+ export declare function apiProfileJsonSchema(): Record<string, unknown>;
154
+ //# sourceMappingURL=ApiProfile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file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F,OAAO,CAAC,MAAM,CAAC,OAAO;IA2BtB,OAAO,CAAC,MAAM,CAAC,MAAM;IAIrB,kGAAkG;IAClG,OAAO,CAAC,MAAM,CAAC,MAAM;IAarB,OAAO,CAAC,MAAM,CAAC,YAAY;IAU3B,OAAO,CAAC,MAAM,CAAC,SAAS;IASxB,mEAAmE;IACnE,OAAO,CAAC,MAAM,CAAC,eAAe;IAa9B;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,IAAI;IAenB,OAAO,CAAC,MAAM,CAAC,IAAI;IAmBnB,OAAO,CAAC,MAAM,CAAC,QAAQ;CAMxB;AAED,6FAA6F;AAC7F,wBAAgB,oBAAoB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAa9D"}
@@ -0,0 +1,369 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * `agent-safe.profile.api/1`: a platform API described as data, so that every
4
+ * component that turns one of its calls into an intent turns it into the same
5
+ * one. A profile maps method + path (and, where an API overloads a path, an
6
+ * exact query value) to an action type, and names the facts a decision reads
7
+ * by JSON pointer into the call. The gateway reads it to govern an agent's
8
+ * call; a native executor's `prepare` reads it to describe the call it is
9
+ * about to make. One mapping, no code coupling between them.
10
+ */
11
+ export const API_PROFILE_CONTRACT = "agent-safe.profile.api/1";
12
+ export const API_PROFILE_SCHEMA_ID = "https://github.com/decionis/agent-safe-pipeline/blob/master/spec/profiles/api/v1/schema.json";
13
+ /** The methods a profile governs; a read is never an operation. */
14
+ export const API_PROFILE_METHODS = ["POST", "PUT", "PATCH", "DELETE"];
15
+ /**
16
+ * Fact names a profile may not use. The first group is what the gateway
17
+ * already states in an intent's context; the second is what the Decionis
18
+ * authority states itself, or reads from the request rather than the context,
19
+ * so a fact of that name would be shadowed or refused there.
20
+ */
21
+ export const RESERVED_FACT_NAMES = [
22
+ "request_sha256",
23
+ "body_sha256",
24
+ "body_bytes",
25
+ "content_type",
26
+ "body_embedded",
27
+ "ingress",
28
+ "claimed_principal",
29
+ "api_profile",
30
+ "agent_safe",
31
+ "action_context",
32
+ "amount",
33
+ "risk_score",
34
+ "channel",
35
+ "objective_profile",
36
+ "mode",
37
+ "decision_band",
38
+ "transaction_type",
39
+ "workflow_key",
40
+ "vertical_pack",
41
+ "policy_version",
42
+ "org_id",
43
+ "decision_type",
44
+ "decision_domain",
45
+ "signals",
46
+ "signal_provenance",
47
+ "history",
48
+ "override",
49
+ "evidence",
50
+ "attachments",
51
+ "attachment_count",
52
+ "policy",
53
+ "context",
54
+ "intake",
55
+ "runtime_attribution",
56
+ ];
57
+ /** The most elements one `*` pointer collects; more is not a fact, it is a payload. */
58
+ export const MAX_FACT_ELEMENTS = 100;
59
+ /** The longest string a fact carries; a longer value is not stated. */
60
+ export const MAX_FACT_STRING = 1000;
61
+ const PLACEHOLDER = /\{([A-Z]\w{0,63})\}/gi;
62
+ const TEMPLATE = /^(\/[^/?#%\\\s]+)+$/;
63
+ const POINTER = /^\/(path|query|body)(\/.*)?$/;
64
+ const name = z.string().regex(/^[a-z][a-z0-9_]{0,63}$/);
65
+ const projectionText = z.string().trim().min(1).max(120);
66
+ export const ApiPolicyProjectionSchema = z.strictObject({
67
+ decision_type: projectionText,
68
+ transaction_type: projectionText.nullable(),
69
+ workflow_key: projectionText.nullable(),
70
+ channel: projectionText.nullable(),
71
+ });
72
+ export const ApiOperationSchema = z.strictObject({
73
+ /** The operation's name in the profile, unique, dotted lower camel case. */
74
+ id: z
75
+ .string()
76
+ .regex(/^[a-z][A-Za-z0-9]*(\.[a-z][A-Za-z0-9]*)*$/)
77
+ .max(120),
78
+ method: z.enum(API_PROFILE_METHODS),
79
+ /** A path template: literal text and `{name}` placeholders, each within one segment. */
80
+ path: z.string().max(500).regex(TEMPLATE),
81
+ /** Exact query values the call must carry to be this operation (an API that overloads a path). */
82
+ query: z.record(z.string().regex(/^[a-z][\w.-]{0,63}$/), z.string().max(200)).optional(),
83
+ /** The intent's action type. */
84
+ action: z
85
+ .string()
86
+ .max(120)
87
+ .regex(/^[a-z][a-z0-9._:-]*$/),
88
+ summary: z.string().trim().min(1).max(300),
89
+ /** Fact name → RFC 6901 pointer into `{ path, query, body }`; one `*` segment collects an array. */
90
+ facts: z.record(name, z.string().max(300).regex(POINTER)),
91
+ /** The policy path the authority decides the call under, when the profile states one. */
92
+ policy_projection: ApiPolicyProjectionSchema.nullable(),
93
+ });
94
+ export const ApiProfileDefinitionSchema = z.strictObject({
95
+ profile: z.literal(API_PROFILE_CONTRACT),
96
+ /** `<platform>/<api>/<version>`, the profile's directory under `profiles/`. */
97
+ id: z
98
+ .string()
99
+ .regex(/^[a-z][a-z0-9]*\/[a-z][a-z0-9]*\/v\d+(\.\d+)?$/)
100
+ .max(120),
101
+ platform: z
102
+ .string()
103
+ .regex(/^[a-z][a-z0-9-]*$/)
104
+ .max(80),
105
+ title: z.string().trim().min(1).max(200),
106
+ /** Path templates an operation's path may follow; `""` is the bare path. Tried in order. */
107
+ prefixes: z
108
+ .array(z.union([z.literal(""), z.string().max(300).regex(TEMPLATE)]))
109
+ .min(1)
110
+ .max(8),
111
+ operations: z.array(ApiOperationSchema).min(1).max(200),
112
+ });
113
+ export class ApiProfileError extends Error {
114
+ code;
115
+ detail;
116
+ constructor(code, detail) {
117
+ super(code);
118
+ this.code = code;
119
+ this.detail = detail;
120
+ this.name = "ApiProfileError";
121
+ }
122
+ }
123
+ /**
124
+ * One profile, validated and compiled. Matching is deterministic and total:
125
+ * the first operation, in profile order, whose method, path and query match
126
+ * is the call's operation; a call no operation matches is not described by
127
+ * the profile and the caller decides what that means.
128
+ */
129
+ export class ApiProfile {
130
+ definition;
131
+ compiled;
132
+ constructor(definition) {
133
+ this.definition = definition;
134
+ const ids = new Set();
135
+ const signatures = new Set();
136
+ this.compiled = definition.operations.map((operation) => {
137
+ if (ids.has(operation.id))
138
+ throw new ApiProfileError("API_PROFILE_INVALID", `duplicate operation ${operation.id}`);
139
+ ids.add(operation.id);
140
+ const signature = `${operation.method} ${operation.path.replace(PLACEHOLDER, "{}")} ${JSON.stringify(Object.entries(operation.query ?? {}).sort(([a], [b]) => a.localeCompare(b)))}`;
141
+ if (signatures.has(signature))
142
+ throw new ApiProfileError("API_PROFILE_INVALID", `operation ${operation.id} repeats another operation's method, path and query`);
143
+ signatures.add(signature);
144
+ for (const fact of Object.keys(operation.facts)) {
145
+ if (RESERVED_FACT_NAMES.includes(fact))
146
+ throw new ApiProfileError("API_PROFILE_INVALID", `operation ${operation.id} names the reserved fact ${fact}`);
147
+ }
148
+ for (const pointer of Object.values(operation.facts))
149
+ ApiProfile.pointerSegments(pointer, operation.id);
150
+ const matchers = [];
151
+ const placeholders = [];
152
+ for (const prefix of definition.prefixes) {
153
+ const { pattern, names } = ApiProfile.compile(`${prefix}${operation.path}`, operation.id);
154
+ matchers.push(pattern);
155
+ placeholders.push(names);
156
+ }
157
+ return { definition: operation, matchers, placeholders };
158
+ });
159
+ }
160
+ /** Validates a definition (closed schema, unique operations, pointers, reserved names) and compiles it. */
161
+ static parse(value) {
162
+ const parsed = ApiProfileDefinitionSchema.safeParse(value);
163
+ if (!parsed.success)
164
+ throw new ApiProfileError("API_PROFILE_INVALID", parsed.error.issues
165
+ .slice(0, 3)
166
+ .map((issue) => `${issue.path.join(".") || "(root)"}: ${issue.message}`)
167
+ .join("; "));
168
+ return new ApiProfile(parsed.data);
169
+ }
170
+ get id() {
171
+ return this.definition.id;
172
+ }
173
+ get platform() {
174
+ return this.definition.platform;
175
+ }
176
+ /** Every action type the profile can produce, for a registry to be sealed over. */
177
+ actions() {
178
+ return [...new Set(this.definition.operations.map((operation) => operation.action))];
179
+ }
180
+ operation(id) {
181
+ return this.definition.operations.find((operation) => operation.id === id) ?? null;
182
+ }
183
+ /**
184
+ * The operation a method, path and query select, before any body is read:
185
+ * what the gateway needs to decide whether to govern a call.
186
+ */
187
+ operationFor(method, path, query = {}) {
188
+ return this.select(method, path, query)?.operation.definition ?? null;
189
+ }
190
+ /** The operation, action type, facts and policy projection of one call; null when no operation matches. */
191
+ match(request) {
192
+ const selected = this.select(request.method, request.path, request.query ?? {});
193
+ if (selected === null)
194
+ return null;
195
+ const { operation, parameters } = selected;
196
+ const root = {
197
+ path: parameters,
198
+ query: ApiProfile.queryRoot(request.query ?? {}),
199
+ ...(request.body === undefined ? {} : { body: request.body }),
200
+ };
201
+ const facts = {};
202
+ for (const [fact, pointer] of Object.entries(operation.definition.facts)) {
203
+ const value = ApiProfile.read(root, ApiProfile.pointerSegments(pointer, operation.definition.id));
204
+ if (value !== undefined)
205
+ facts[fact] = value;
206
+ }
207
+ return {
208
+ profile: this.definition.id,
209
+ operation: operation.definition.id,
210
+ action: operation.definition.action,
211
+ facts,
212
+ policyProjection: operation.definition.policy_projection,
213
+ };
214
+ }
215
+ select(method, path, query) {
216
+ const upper = method.toUpperCase();
217
+ if (!path.startsWith("/") || /[?#]/.test(path))
218
+ return null;
219
+ for (const operation of this.compiled) {
220
+ if (operation.definition.method !== upper)
221
+ continue;
222
+ if (!ApiProfile.queryMatches(operation.definition.query ?? {}, query))
223
+ continue;
224
+ for (let index = 0; index < operation.matchers.length; index += 1) {
225
+ const found = operation.matchers[index].exec(path);
226
+ if (found === null)
227
+ continue;
228
+ const parameters = {};
229
+ let decodable = true;
230
+ operation.placeholders[index].forEach((placeholder, position) => {
231
+ const decoded = ApiProfile.decode(found[position + 1] ?? "");
232
+ if (decoded === null)
233
+ decodable = false;
234
+ else
235
+ parameters[placeholder] = decoded;
236
+ });
237
+ if (decodable)
238
+ return { operation, parameters };
239
+ }
240
+ }
241
+ return null;
242
+ }
243
+ /** A template as an anchored expression: placeholders take one segment's text, never a `/`. */
244
+ static compile(template, operation) {
245
+ const names = [];
246
+ let source = "";
247
+ let last = 0;
248
+ for (const found of template.matchAll(PLACEHOLDER)) {
249
+ const placeholder = found[1];
250
+ if (names.includes(placeholder))
251
+ throw new ApiProfileError("API_PROFILE_INVALID", `operation ${operation} repeats the placeholder ${placeholder}`);
252
+ names.push(placeholder);
253
+ source += ApiProfile.escape(template.slice(last, found.index)) + "([^/()]+)";
254
+ last = (found.index ?? 0) + found[0].length;
255
+ }
256
+ source += ApiProfile.escape(template.slice(last));
257
+ if (/[{}]/.test(template.replace(PLACEHOLDER, "")))
258
+ throw new ApiProfileError("API_PROFILE_INVALID", `operation ${operation} has a malformed placeholder`);
259
+ return { pattern: new RegExp(`^${source}$`), names };
260
+ }
261
+ static escape(text) {
262
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
263
+ }
264
+ /** A placeholder's value: percent-decoded, OData quotes removed; null when it does not decode. */
265
+ static decode(raw) {
266
+ let value;
267
+ try {
268
+ value = decodeURIComponent(raw);
269
+ }
270
+ catch {
271
+ return null;
272
+ }
273
+ if (value.length >= 2 && value.startsWith("'") && value.endsWith("'"))
274
+ value = value.slice(1, -1);
275
+ if (value === "" || value === "." || value === ".." || value.includes("/"))
276
+ return null;
277
+ return value;
278
+ }
279
+ static queryMatches(expected, query) {
280
+ return Object.entries(expected).every(([key, value]) => {
281
+ const actual = query[key];
282
+ return typeof actual === "string" ? actual === value : false;
283
+ });
284
+ }
285
+ static queryRoot(query) {
286
+ const root = {};
287
+ for (const [key, value] of Object.entries(query)) {
288
+ if (key === "__proto__" || key === "constructor" || key === "prototype")
289
+ continue;
290
+ root[key] = typeof value === "string" ? value : [...value];
291
+ }
292
+ return root;
293
+ }
294
+ /** RFC 6901 reference tokens, unescaped; one `*` token at most. */
295
+ static pointerSegments(pointer, operation) {
296
+ const tokens = pointer
297
+ .slice(1)
298
+ .split("/")
299
+ .map((token) => token.replaceAll("~1", "/").replaceAll("~0", "~"));
300
+ if (tokens.filter((token) => token === "*").length > 1 || /~[^01]|~$/.test(pointer))
301
+ throw new ApiProfileError("API_PROFILE_INVALID", `operation ${operation} has an invalid fact pointer ${pointer}`);
302
+ return tokens;
303
+ }
304
+ /**
305
+ * The value at a pointer, when it is statable: a string (at most 1000
306
+ * characters), a finite number or a boolean; or, through one `*`, an array
307
+ * of up to 100 of them, every element statable. Anything else is absent.
308
+ */
309
+ static read(root, tokens) {
310
+ const wildcard = tokens.indexOf("*");
311
+ if (wildcard === -1)
312
+ return ApiProfile.statable(ApiProfile.walk(root, tokens));
313
+ const list = ApiProfile.walk(root, tokens.slice(0, wildcard));
314
+ if (!Array.isArray(list) || list.length === 0 || list.length > MAX_FACT_ELEMENTS)
315
+ return undefined;
316
+ const values = [];
317
+ for (const element of list) {
318
+ const value = ApiProfile.statable(ApiProfile.walk(element, tokens.slice(wildcard + 1)));
319
+ if (value === undefined)
320
+ return undefined;
321
+ values.push(value);
322
+ }
323
+ return values;
324
+ }
325
+ static walk(value, tokens) {
326
+ let current = value;
327
+ for (const token of tokens) {
328
+ if (Array.isArray(current)) {
329
+ if (!/^(?:0|[1-9]\d{0,5})$/.test(token))
330
+ return undefined;
331
+ current = current[Number(token)];
332
+ }
333
+ else if (current !== null && typeof current === "object") {
334
+ current = Object.hasOwn(current, token) ? current[token] : undefined;
335
+ }
336
+ else {
337
+ return undefined;
338
+ }
339
+ if (current === undefined)
340
+ return undefined;
341
+ }
342
+ return current;
343
+ }
344
+ static statable(value) {
345
+ if (typeof value === "string")
346
+ return value.length <= MAX_FACT_STRING ? value : undefined;
347
+ if (typeof value === "number")
348
+ return Number.isFinite(value) ? value : undefined;
349
+ if (typeof value === "boolean")
350
+ return value;
351
+ return undefined;
352
+ }
353
+ }
354
+ /** The published JSON Schema of a profile definition, generated from the validator above. */
355
+ export function apiProfileJsonSchema() {
356
+ const generated = z.toJSONSchema(ApiProfileDefinitionSchema, {
357
+ target: "draft-2020-12",
358
+ io: "input",
359
+ });
360
+ const schema = { ...generated };
361
+ delete schema["$schema"];
362
+ return {
363
+ $schema: "https://json-schema.org/draft/2020-12/schema",
364
+ $id: API_PROFILE_SCHEMA_ID,
365
+ title: API_PROFILE_CONTRACT,
366
+ ...schema,
367
+ };
368
+ }
369
+ //# sourceMappingURL=ApiProfile.js.map