@decionis/agent-safe-pipeline 0.1.2

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 (72) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +4 -0
  3. package/README.md +60 -0
  4. package/dist/Index.d.ts +14 -0
  5. package/dist/Index.d.ts.map +1 -0
  6. package/dist/Index.js +14 -0
  7. package/dist/Index.js.map +1 -0
  8. package/dist/approval/PresenceApprovalCoordinator.d.ts +18 -0
  9. package/dist/approval/PresenceApprovalCoordinator.d.ts.map +1 -0
  10. package/dist/approval/PresenceApprovalCoordinator.js +105 -0
  11. package/dist/approval/PresenceApprovalCoordinator.js.map +1 -0
  12. package/dist/decision/DecionisGate.d.ts +18 -0
  13. package/dist/decision/DecionisGate.d.ts.map +1 -0
  14. package/dist/decision/DecionisGate.js +108 -0
  15. package/dist/decision/DecionisGate.js.map +1 -0
  16. package/dist/decision/DecisionAuthority.d.ts +29 -0
  17. package/dist/decision/DecisionAuthority.d.ts.map +1 -0
  18. package/dist/decision/DecisionAuthority.js +15 -0
  19. package/dist/decision/DecisionAuthority.js.map +1 -0
  20. package/dist/decision/FixtureDecisionAuthority.d.ts +32 -0
  21. package/dist/decision/FixtureDecisionAuthority.d.ts.map +1 -0
  22. package/dist/decision/FixtureDecisionAuthority.js +117 -0
  23. package/dist/decision/FixtureDecisionAuthority.js.map +1 -0
  24. package/dist/decision/ImmutableGateDecision.d.ts +3 -0
  25. package/dist/decision/ImmutableGateDecision.d.ts.map +1 -0
  26. package/dist/decision/ImmutableGateDecision.js +8 -0
  27. package/dist/decision/ImmutableGateDecision.js.map +1 -0
  28. package/dist/execution/ActionRegistry.d.ts +22 -0
  29. package/dist/execution/ActionRegistry.d.ts.map +1 -0
  30. package/dist/execution/ActionRegistry.js +41 -0
  31. package/dist/execution/ActionRegistry.js.map +1 -0
  32. package/dist/execution/AuthorizationVerifier.d.ts +28 -0
  33. package/dist/execution/AuthorizationVerifier.d.ts.map +1 -0
  34. package/dist/execution/AuthorizationVerifier.js +88 -0
  35. package/dist/execution/AuthorizationVerifier.js.map +1 -0
  36. package/dist/execution/ReplayStore.d.ts +10 -0
  37. package/dist/execution/ReplayStore.d.ts.map +1 -0
  38. package/dist/execution/ReplayStore.js +28 -0
  39. package/dist/execution/ReplayStore.js.map +1 -0
  40. package/dist/execution/SafeExecutor.d.ts +25 -0
  41. package/dist/execution/SafeExecutor.d.ts.map +1 -0
  42. package/dist/execution/SafeExecutor.js +73 -0
  43. package/dist/execution/SafeExecutor.js.map +1 -0
  44. package/dist/http/AuthorityBaseUrl.d.ts +4 -0
  45. package/dist/http/AuthorityBaseUrl.d.ts.map +1 -0
  46. package/dist/http/AuthorityBaseUrl.js +22 -0
  47. package/dist/http/AuthorityBaseUrl.js.map +1 -0
  48. package/dist/http/BoundedResponseBody.d.ts +4 -0
  49. package/dist/http/BoundedResponseBody.d.ts.map +1 -0
  50. package/dist/http/BoundedResponseBody.js +33 -0
  51. package/dist/http/BoundedResponseBody.js.map +1 -0
  52. package/dist/intent/CanonicalIntentHasher.d.ts +20 -0
  53. package/dist/intent/CanonicalIntentHasher.d.ts.map +1 -0
  54. package/dist/intent/CanonicalIntentHasher.js +162 -0
  55. package/dist/intent/CanonicalIntentHasher.js.map +1 -0
  56. package/dist/intent/ExecutionIntent.d.ts +96 -0
  57. package/dist/intent/ExecutionIntent.d.ts.map +1 -0
  58. package/dist/intent/ExecutionIntent.js +59 -0
  59. package/dist/intent/ExecutionIntent.js.map +1 -0
  60. package/dist/intent/IntentCapture.d.ts +17 -0
  61. package/dist/intent/IntentCapture.d.ts.map +1 -0
  62. package/dist/intent/IntentCapture.js +40 -0
  63. package/dist/intent/IntentCapture.js.map +1 -0
  64. package/dist/intent/JsonValue.d.ts +11 -0
  65. package/dist/intent/JsonValue.d.ts.map +1 -0
  66. package/dist/intent/JsonValue.js +11 -0
  67. package/dist/intent/JsonValue.js.map +1 -0
  68. package/dist/shadow/ShadowPipeline.d.ts +13 -0
  69. package/dist/shadow/ShadowPipeline.d.ts.map +1 -0
  70. package/dist/shadow/ShadowPipeline.js +14 -0
  71. package/dist/shadow/ShadowPipeline.js.map +1 -0
  72. package/package.json +57 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BoundedResponseBody.js","sourceRoot":"","sources":["../../src/http/BoundedResponseBody.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,mBAAmB;IACvB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,QAAkB,EAAE,QAAgB;QAC3D,IAAI,QAAQ,CAAC,IAAI,KAAK,IAAI;YAAE,OAAO,EAAE,CAAC;QAEtC,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QACzC,MAAM,MAAM,GAAiB,EAAE,CAAC;QAChC,IAAI,UAAU,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC;YACH,OAAO,IAAI,EAAE,CAAC;gBACZ,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC5C,IAAI,IAAI;oBAAE,MAAM;gBAChB,UAAU,IAAI,KAAK,CAAC,UAAU,CAAC;gBAC/B,IAAI,UAAU,GAAG,QAAQ,EAAE,CAAC;oBAC1B,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;oBAC7C,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,WAAW,EAAE,CAAC;QACvB,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC;QACxC,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC;QAC7B,CAAC;QACD,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChE,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ import type { AuthorityIntentBinding, CapturedIntent, ExecutionIntent } from "./ExecutionIntent.js";
2
+ import type { JsonValue } from "./JsonValue.js";
3
+ export interface CanonicalLimits {
4
+ readonly maxDepth: number;
5
+ readonly maxEntries: number;
6
+ readonly maxArrayLength: number;
7
+ readonly maxBytes: number;
8
+ }
9
+ export declare class CanonicalIntentHasher {
10
+ private readonly limits;
11
+ constructor(limits?: Partial<CanonicalLimits>);
12
+ capture(intent: ExecutionIntent): CapturedIntent;
13
+ assertInputBounded(value: unknown): void;
14
+ static bindingOf(intent: ExecutionIntent): AuthorityIntentBinding;
15
+ static stringify(value: JsonValue): string;
16
+ private static canonicalize;
17
+ private static deepFreeze;
18
+ private assertBounded;
19
+ }
20
+ //# sourceMappingURL=CanonicalIntentHasher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CanonicalIntentHasher.d.ts","sourceRoot":"","sources":["../../src/intent/CanonicalIntentHasher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACpG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIhD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;gBAEtB,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC;IAS7C,OAAO,CAAC,MAAM,EAAE,eAAe,GAAG,cAAc;IAqBhD,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;WAoDjC,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,sBAAsB;WA8B1D,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM;IAIjD,OAAO,CAAC,MAAM,CAAC,YAAY;IAW3B,OAAO,CAAC,MAAM,CAAC,UAAU;IAUzB,OAAO,CAAC,aAAa;CAoBtB"}
@@ -0,0 +1,162 @@
1
+ import { createHash } from "node:crypto";
2
+ const FORBIDDEN_KEYS = new Set(["__proto__", "constructor", "prototype"]);
3
+ export class CanonicalIntentHasher {
4
+ limits;
5
+ constructor(limits) {
6
+ this.limits = {
7
+ maxDepth: limits?.maxDepth ?? 20,
8
+ maxEntries: limits?.maxEntries ?? 5_000,
9
+ maxArrayLength: limits?.maxArrayLength ?? 1_000,
10
+ maxBytes: limits?.maxBytes ?? 100 * 1024,
11
+ };
12
+ }
13
+ capture(intent) {
14
+ const binding = CanonicalIntentHasher.bindingOf(intent);
15
+ let entries = 0;
16
+ this.assertBounded(binding, 0, () => {
17
+ entries += 1;
18
+ if (entries > this.limits.maxEntries) {
19
+ throw new Error("INTENT_TOO_COMPLEX");
20
+ }
21
+ });
22
+ const canonicalIntent = CanonicalIntentHasher.stringify(binding);
23
+ const byteLength = Buffer.byteLength(canonicalIntent, "utf8");
24
+ if (byteLength > this.limits.maxBytes)
25
+ throw new Error("INTENT_TOO_LARGE");
26
+ const digest = createHash("sha256").update(canonicalIntent, "utf8").digest("hex");
27
+ return Object.freeze({
28
+ intent: CanonicalIntentHasher.deepFreeze(intent),
29
+ canonicalIntent,
30
+ intentHash: `sha256:${digest}`,
31
+ byteLength,
32
+ });
33
+ }
34
+ assertInputBounded(value) {
35
+ const pending = [{ value, depth: 0, leaving: false }];
36
+ const ancestors = new WeakSet();
37
+ let entries = 0;
38
+ while (pending.length > 0) {
39
+ const current = pending.pop();
40
+ if (current === undefined || current.value === null || typeof current.value !== "object") {
41
+ continue;
42
+ }
43
+ if (current.leaving) {
44
+ ancestors.delete(current.value);
45
+ continue;
46
+ }
47
+ if (current.depth > this.limits.maxDepth)
48
+ throw new Error("INTENT_TOO_DEEP");
49
+ if (ancestors.has(current.value))
50
+ throw new Error("CYCLIC_INTENT");
51
+ ancestors.add(current.value);
52
+ pending.push({ value: current.value, depth: current.depth, leaving: true });
53
+ if (Array.isArray(current.value)) {
54
+ if (current.value.length > this.limits.maxArrayLength) {
55
+ throw new Error("INTENT_ARRAY_TOO_LARGE");
56
+ }
57
+ for (const child of current.value) {
58
+ entries += 1;
59
+ if (entries > this.limits.maxEntries)
60
+ throw new Error("INTENT_TOO_COMPLEX");
61
+ pending.push({ value: child, depth: current.depth + 1, leaving: false });
62
+ }
63
+ continue;
64
+ }
65
+ const prototype = Object.getPrototypeOf(current.value);
66
+ if (prototype !== Object.prototype && prototype !== null) {
67
+ throw new Error("INVALID_JSON_OBJECT");
68
+ }
69
+ for (const key of Object.keys(current.value)) {
70
+ if (FORBIDDEN_KEYS.has(key))
71
+ throw new Error("UNSAFE_INTENT_KEY");
72
+ entries += 1;
73
+ if (entries > this.limits.maxEntries)
74
+ throw new Error("INTENT_TOO_COMPLEX");
75
+ pending.push({
76
+ value: current.value[key],
77
+ depth: current.depth + 1,
78
+ leaving: false,
79
+ });
80
+ }
81
+ }
82
+ }
83
+ static bindingOf(intent) {
84
+ return {
85
+ protocol_version: intent.version,
86
+ tenant_id: intent.tenantId,
87
+ intent_id: intent.intentId,
88
+ idempotency_key: intent.idempotencyKey,
89
+ captured_at: intent.capturedAt,
90
+ expires_at: intent.expiresAt,
91
+ actor: {
92
+ id: intent.actor.id,
93
+ type: intent.actor.type,
94
+ ...(intent.actor.runtime === undefined ? {} : { runtime: intent.actor.runtime }),
95
+ ...(intent.actor.trustLevel === undefined ? {} : { trust_level: intent.actor.trustLevel }),
96
+ },
97
+ action: {
98
+ type: intent.action,
99
+ resource: intent.target,
100
+ parameters: intent.parameters,
101
+ },
102
+ context: intent.context,
103
+ downstream_target: {
104
+ system: intent.downstreamTarget.system,
105
+ operation: intent.downstreamTarget.operation,
106
+ ...(intent.downstreamTarget.endpoint === undefined
107
+ ? {}
108
+ : { endpoint: intent.downstreamTarget.endpoint }),
109
+ },
110
+ };
111
+ }
112
+ static stringify(value) {
113
+ return JSON.stringify(CanonicalIntentHasher.canonicalize(value));
114
+ }
115
+ static canonicalize(value) {
116
+ if (Array.isArray(value))
117
+ return value.map((item) => CanonicalIntentHasher.canonicalize(item));
118
+ if (value === null || typeof value !== "object")
119
+ return value;
120
+ const normalized = {};
121
+ for (const key of Object.keys(value).sort()) {
122
+ const entry = value[key];
123
+ if (entry !== undefined)
124
+ normalized[key] = CanonicalIntentHasher.canonicalize(entry);
125
+ }
126
+ return normalized;
127
+ }
128
+ static deepFreeze(value) {
129
+ if (value && typeof value === "object" && !Object.isFrozen(value)) {
130
+ Object.freeze(value);
131
+ for (const child of Object.values(value)) {
132
+ CanonicalIntentHasher.deepFreeze(child);
133
+ }
134
+ }
135
+ return value;
136
+ }
137
+ assertBounded(value, depth, count) {
138
+ if (depth > this.limits.maxDepth)
139
+ throw new Error("INTENT_TOO_DEEP");
140
+ if (value === null || typeof value !== "object") {
141
+ if (typeof value === "number" && !Number.isFinite(value))
142
+ throw new Error("INVALID_NUMBER");
143
+ return;
144
+ }
145
+ if (Array.isArray(value)) {
146
+ if (value.length > this.limits.maxArrayLength)
147
+ throw new Error("INTENT_ARRAY_TOO_LARGE");
148
+ for (const child of value) {
149
+ count();
150
+ this.assertBounded(child, depth + 1, count);
151
+ }
152
+ return;
153
+ }
154
+ for (const [key, child] of Object.entries(value)) {
155
+ if (FORBIDDEN_KEYS.has(key))
156
+ throw new Error("UNSAFE_INTENT_KEY");
157
+ count();
158
+ this.assertBounded(child, depth + 1, count);
159
+ }
160
+ }
161
+ }
162
+ //# sourceMappingURL=CanonicalIntentHasher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CanonicalIntentHasher.js","sourceRoot":"","sources":["../../src/intent/CanonicalIntentHasher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC;AAS1E,MAAM,OAAO,qBAAqB;IACf,MAAM,CAAkB;IAEzC,YAAmB,MAAiC;QAClD,IAAI,CAAC,MAAM,GAAG;YACZ,QAAQ,EAAE,MAAM,EAAE,QAAQ,IAAI,EAAE;YAChC,UAAU,EAAE,MAAM,EAAE,UAAU,IAAI,KAAK;YACvC,cAAc,EAAE,MAAM,EAAE,cAAc,IAAI,KAAK;YAC/C,QAAQ,EAAE,MAAM,EAAE,QAAQ,IAAI,GAAG,GAAG,IAAI;SACzC,CAAC;IACJ,CAAC;IAEM,OAAO,CAAC,MAAuB;QACpC,MAAM,OAAO,GAAG,qBAAqB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACxD,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,aAAa,CAAC,OAA+B,EAAE,CAAC,EAAE,GAAG,EAAE;YAC1D,OAAO,IAAI,CAAC,CAAC;YACb,IAAI,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;gBACrC,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;YACxC,CAAC;QACH,CAAC,CAAC,CAAC;QACH,MAAM,eAAe,GAAG,qBAAqB,CAAC,SAAS,CAAC,OAA+B,CAAC,CAAC;QACzF,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;QAC9D,IAAI,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ;YAAE,M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AAC,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,96 @@
1
+ import { z } from "zod";
2
+ import { type JsonObject } from "./JsonValue.js";
3
+ export declare const AgentProposalSchema: z.ZodObject<{
4
+ action: z.ZodString;
5
+ target: z.ZodString;
6
+ parameters: z.ZodDefault<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
7
+ }, z.core.$strict>;
8
+ export declare const IntentActorSchema: z.ZodObject<{
9
+ id: z.ZodString;
10
+ type: z.ZodString;
11
+ runtime: z.ZodOptional<z.ZodString>;
12
+ trustLevel: z.ZodOptional<z.ZodString>;
13
+ }, z.core.$strict>;
14
+ export declare const DownstreamTargetSchema: z.ZodObject<{
15
+ system: z.ZodString;
16
+ operation: z.ZodString;
17
+ endpoint: z.ZodOptional<z.ZodString>;
18
+ }, z.core.$strict>;
19
+ export declare const TrustedIntentContextSchema: z.ZodObject<{
20
+ tenantId: z.ZodString;
21
+ actor: z.ZodObject<{
22
+ id: z.ZodString;
23
+ type: z.ZodString;
24
+ runtime: z.ZodOptional<z.ZodString>;
25
+ trustLevel: z.ZodOptional<z.ZodString>;
26
+ }, z.core.$strict>;
27
+ downstreamTarget: z.ZodObject<{
28
+ system: z.ZodString;
29
+ operation: z.ZodString;
30
+ endpoint: z.ZodOptional<z.ZodString>;
31
+ }, z.core.$strict>;
32
+ context: z.ZodDefault<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
33
+ correlationId: z.ZodOptional<z.ZodString>;
34
+ idempotencyKey: z.ZodString;
35
+ }, z.core.$strict>;
36
+ export declare const ExecutionIntentSchema: z.ZodObject<{
37
+ version: z.ZodLiteral<"agent-safe.intent/1">;
38
+ intentId: z.ZodString;
39
+ tenantId: z.ZodString;
40
+ capturedAt: z.ZodString;
41
+ expiresAt: z.ZodString;
42
+ actor: z.ZodObject<{
43
+ id: z.ZodString;
44
+ type: z.ZodString;
45
+ runtime: z.ZodOptional<z.ZodString>;
46
+ trustLevel: z.ZodOptional<z.ZodString>;
47
+ }, z.core.$strict>;
48
+ action: z.ZodString;
49
+ target: z.ZodString;
50
+ parameters: z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>;
51
+ downstreamTarget: z.ZodObject<{
52
+ system: z.ZodString;
53
+ operation: z.ZodString;
54
+ endpoint: z.ZodOptional<z.ZodString>;
55
+ }, z.core.$strict>;
56
+ context: z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>;
57
+ correlationId: z.ZodOptional<z.ZodString>;
58
+ idempotencyKey: z.ZodString;
59
+ }, z.core.$strict>;
60
+ export type AgentProposal = z.infer<typeof AgentProposalSchema>;
61
+ export type IntentActor = z.infer<typeof IntentActorSchema>;
62
+ export type DownstreamTarget = z.infer<typeof DownstreamTargetSchema>;
63
+ export type TrustedIntentContext = z.infer<typeof TrustedIntentContextSchema>;
64
+ export type ExecutionIntent = z.infer<typeof ExecutionIntentSchema>;
65
+ export interface CapturedIntent {
66
+ readonly intent: Readonly<ExecutionIntent>;
67
+ readonly canonicalIntent: string;
68
+ readonly intentHash: `sha256:${string}`;
69
+ readonly byteLength: number;
70
+ }
71
+ export interface AuthorityIntentBinding {
72
+ readonly protocol_version: "agent-safe.intent/1";
73
+ readonly tenant_id: string;
74
+ readonly intent_id: string;
75
+ readonly idempotency_key: string;
76
+ readonly captured_at: string;
77
+ readonly expires_at: string;
78
+ readonly actor: {
79
+ readonly id: string;
80
+ readonly type: string;
81
+ readonly runtime?: string;
82
+ readonly trust_level?: string;
83
+ };
84
+ readonly action: {
85
+ readonly type: string;
86
+ readonly resource: string;
87
+ readonly parameters: JsonObject;
88
+ };
89
+ readonly context: JsonObject;
90
+ readonly downstream_target: {
91
+ readonly system: string;
92
+ readonly operation: string;
93
+ readonly endpoint?: string;
94
+ };
95
+ }
96
+ //# sourceMappingURL=Execution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C,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;KAC/B,CAAC;IACF,QAAQ,CAAC,MAAM,EAAE;QACf,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;KACjC,CAAC;IACF,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,iBAAiB,EAAE;QAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;KAC5B,CAAC;CACH"}
@@ -0,0 +1,59 @@
1
+ import { z } from "zod";
2
+ import { JsonObjectSchema } from "./JsonValue.js";
3
+ const boundedId = z.string().trim().min(1).max(200);
4
+ const actionName = z
5
+ .string()
6
+ .trim()
7
+ .min(1)
8
+ .max(120)
9
+ .regex(/^[a-z][a-z0-9._:-]*$/);
10
+ export const AgentProposalSchema = z
11
+ .object({
12
+ action: actionName,
13
+ target: z.string().trim().min(1).max(500),
14
+ parameters: JsonObjectSchema.default({}),
15
+ })
16
+ .strict();
17
+ export const IntentActorSchema = z
18
+ .object({
19
+ id: boundedId,
20
+ type: boundedId,
21
+ runtime: boundedId.optional(),
22
+ trustLevel: z.string().trim().min(1).max(80).optional(),
23
+ })
24
+ .strict();
25
+ export const DownstreamTargetSchema = z
26
+ .object({
27
+ system: boundedId,
28
+ operation: boundedId,
29
+ endpoint: z.string().trim().min(1).max(500).optional(),
30
+ })
31
+ .strict();
32
+ export const TrustedIntentContextSchema = z
33
+ .object({
34
+ tenantId: z.string().uuid(),
35
+ actor: IntentActorSchema,
36
+ downstreamTarget: DownstreamTargetSchema,
37
+ context: JsonObjectSchema.default({}),
38
+ correlationId: boundedId.optional(),
39
+ idempotencyKey: z.string().trim().min(1).max(180),
40
+ })
41
+ .strict();
42
+ export const ExecutionIntentSchema = z
43
+ .object({
44
+ version: z.literal("agent-safe.intent/1"),
45
+ intentId: z.string().uuid(),
46
+ tenantId: z.string().uuid(),
47
+ capturedAt: z.string().datetime(),
48
+ expiresAt: z.string().datetime(),
49
+ actor: IntentActorSchema,
50
+ action: actionName,
51
+ target: z.string().trim().min(1).max(500),
52
+ parameters: JsonObjectSchema,
53
+ downstreamTarget: DownstreamTargetSchema,
54
+ context: JsonObjectSchema,
55
+ correlationId: boundedId.optional(),
56
+ idempotencyKey: z.string().trim().min(1).max(180),
57
+ })
58
+ .strict();
59
+ //# sourceMappingURL=ExecutionIntent.js.map
@@ -0,0 +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;AAEnE,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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EAAE;IACnC,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;AAEZ,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC;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,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"}
@@ -0,0 +1,17 @@
1
+ import { type AgentProposal, type CapturedIntent, type TrustedIntentContext } from "./ExecutionIntent.js";
2
+ import { CanonicalIntentHasher } from "./CanonicalIntentHasher.js";
3
+ export interface IntentCaptureOptions {
4
+ readonly hasher?: CanonicalIntentHasher;
5
+ readonly clock?: () => Date;
6
+ readonly createId?: () => string;
7
+ readonly ttlSeconds?: number;
8
+ }
9
+ export declare class IntentCapture {
10
+ private readonly hasher;
11
+ private readonly clock;
12
+ private readonly createId;
13
+ private readonly ttlSeconds;
14
+ constructor(options?: IntentCaptureOptions);
15
+ capture(proposalInput: AgentProposal, trustedInput: TrustedIntentContext): CapturedIntent;
16
+ }
17
+ //# sourceMappingURL=IntentCapture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IntentCapture.d.ts","sourceRoot":"","sources":["../../src/intent/IntentCapture.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,CAAC,EAAE,qBAAqB,CAAC;IACxC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,MAAM,CAAC;IACjC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,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;gBAEjB,OAAO,CAAC,EAAE,oBAAoB;IAO1C,OAAO,CAAC,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,oBAAoB,GAAG,cAAc;CAwBjG"}
@@ -0,0 +1,40 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { AgentProposalSchema, ExecutionIntentSchema, TrustedIntentContextSchema, } from "./ExecutionIntent.js";
3
+ import { CanonicalIntentHasher } from "./CanonicalIntentHasher.js";
4
+ export class IntentCapture {
5
+ hasher;
6
+ clock;
7
+ createId;
8
+ ttlSeconds;
9
+ constructor(options) {
10
+ this.hasher = options?.hasher ?? new CanonicalIntentHasher();
11
+ this.clock = options?.clock ?? (() => new Date());
12
+ this.createId = options?.createId ?? randomUUID;
13
+ this.ttlSeconds = Math.min(Math.max(options?.ttlSeconds ?? 60, 1), 300);
14
+ }
15
+ capture(proposalInput, trustedInput) {
16
+ this.hasher.assertInputBounded(proposalInput);
17
+ this.hasher.assertInputBounded(trustedInput);
18
+ const proposal = AgentProposalSchema.parse(proposalInput);
19
+ const trusted = TrustedIntentContextSchema.parse(trustedInput);
20
+ const capturedAt = this.clock();
21
+ const expiresAt = new Date(capturedAt.valueOf() + this.ttlSeconds * 1_000);
22
+ const intent = ExecutionIntentSchema.parse({
23
+ version: "agent-safe.intent/1",
24
+ intentId: this.createId(),
25
+ tenantId: trusted.tenantId,
26
+ capturedAt: capturedAt.toISOString(),
27
+ expiresAt: expiresAt.toISOString(),
28
+ actor: trusted.actor,
29
+ action: proposal.action,
30
+ target: proposal.target,
31
+ parameters: proposal.parameters,
32
+ downstreamTarget: trusted.downstreamTarget,
33
+ context: trusted.context,
34
+ ...(trusted.correlationId === undefined ? {} : { correlationId: trusted.correlationId }),
35
+ idempotencyKey: trusted.idempotencyKey,
36
+ });
37
+ return this.hasher.capture(intent);
38
+ }
39
+ }
40
+ //# sourceMappingURL=IntentCapture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IntentCapture.js","sourceRoot":"","sources":["../../src/intent/IntentCapture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,GAI3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AASnE,MAAM,OAAO,aAAa;IACP,MAAM,CAAwB;IAC9B,KAAK,CAAa;IAClB,QAAQ,CAAe;IACvB,UAAU,CAAS;IAEpC,YAAmB,OAA8B;QAC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AE,QAAQ,CAAC,MAAM;YACvB,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;YAC1C,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,GAAG,CAAC,OAAO,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC;YACxF,cAAc,EAAE,OAAO,CAAC,cAAc;SACvC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;CACF"}
@@ -0,0 +1,11 @@
1
+ import { z } from "zod";
2
+ export type JsonPrimitive = boolean | number | string | null;
3
+ export type JsonValue = JsonPrimitive | JsonValue[] | {
4
+ [key: string]: JsonValue;
5
+ };
6
+ export type JsonObject = {
7
+ [key: string]: JsonValue;
8
+ };
9
+ export declare const JsonValueSchema: z.ZodType<JsonValue>;
10
+ export declare const JsonObjectSchema: z.ZodType<JsonObject>;
11
+ //# sourceMappingURL=JsonValue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JsonValue.d.ts","sourceRoot":"","sources":["../../src/intent/JsonValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAC7D,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,SAAS,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AACnF,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEtD,eAAO,MAAM,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAShD,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAyC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { z } from "zod";
2
+ export const JsonValueSchema = z.lazy(() => z.union([
3
+ z.boolean(),
4
+ z.number().finite(),
5
+ z.string(),
6
+ z.null(),
7
+ z.array(JsonValueSchema),
8
+ z.record(z.string(), JsonValueSchema),
9
+ ]));
10
+ export const JsonObjectSchema = z.record(z.string(), JsonValueSchema);
11
+ //# sourceMappingURL=JsonValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JsonValue.js","sourceRoot":"","sources":["../../src/intent/JsonValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,MAAM,CAAC,MAAM,eAAe,GAAyB,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAC/D,CAAC,CAAC,KAAK,CAAC;IACN,CAAC,CAAC,OAAO,EAAE;IACX,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE;IACnB,CAAC,CAAC,MAAM,EAAE;IACV,CAAC,CAAC,IAAI,EAAE;IACR,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC;IACxB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC;CACtC,CAAC,CACH,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAA0B,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { DecisionAuthority, GateDecision } from "../decision/DecisionAuthority.js";
2
+ import type { CapturedIntent } from "../intent/ExecutionIntent.js";
3
+ export interface ShadowComparison<TResult> {
4
+ readonly mode: "SHADOW";
5
+ readonly productionResult: TResult;
6
+ readonly hypotheticalDecision: GateDecision;
7
+ }
8
+ export declare class ShadowPipeline {
9
+ private readonly authority;
10
+ constructor(authority: DecisionAuthority);
11
+ compare<TResult>(captured: CapturedIntent, existingExecution: () => Promise<TResult> | TResult): Promise<ShadowComparison<TResult>>;
12
+ }
13
+ //# sourceMappingURL=ShadowPipeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShadowPipeline.d.ts","sourceRoot":"","sources":["../../src/shadow/ShadowPipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACxF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE,MAAM,WAAW,gBAAgB,CAAC,OAAO;IACvC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,oBAAoB,EAAE,YAAY,CAAC;CAC7C;AAED,qBAAa,cAAc;IACN,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,iBAAiB;IAEnD,OAAO,CAAC,OAAO,EAC1B,QAAQ,EAAE,cAAc,EACxB,iBAAiB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,GAClD,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;CAOtC"}
@@ -0,0 +1,14 @@
1
+ export class ShadowPipeline {
2
+ authority;
3
+ constructor(authority) {
4
+ this.authority = authority;
5
+ }
6
+ async compare(captured, existingExecution) {
7
+ const [productionResult, hypotheticalDecision] = await Promise.all([
8
+ existingExecution(),
9
+ this.authority.evaluate(captured),
10
+ ]);
11
+ return { mode: "SHADOW", productionResult, hypotheticalDecision };
12
+ }
13
+ }
14
+ //# sourceMappingURL=ShadowPipeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShadowPipeline.js","sourceRoot":"","sources":["../../src/shadow/ShadowPipeline.ts"],"names":[],"mappings":"AASA,MAAM,OAAO,cAAc;IACW;IAApC,YAAoC,SAA4B;QAA5B,cAAS,GAAT,SAAS,CAAmB;IAAG,CAAC;IAE7D,KAAK,CAAC,OAAO,CAClB,QAAwB,EACxB,iBAAmD;QAEnD,MAAM,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACjE,iBAAiB,EAAE;YACnB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC;SAClC,CAAC,CAAC;QACH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,CAAC;IACpE,CAAC;CACF"}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@decionis/agent-safe-pipeline",
3
+ "version": "0.1.2",
4
+ "description": "An execution architecture where AI agents may propose actions but cannot authorize their own execution.",
5
+ "license": "Apache-2.0",
6
+ "author": "Decionis, Inc.",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/decionis/agent-safe-pipeline.git",
10
+ "directory": "packages/pipeline"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/decionis/agent-safe-pipeline/issues"
14
+ },
15
+ "homepage": "https://github.com/decionis/agent-safe-pipeline/tree/master/packages/pipeline#readme",
16
+ "type": "module",
17
+ "sideEffects": false,
18
+ "files": [
19
+ "dist",
20
+ "README.md",
21
+ "LICENSE",
22
+ "NOTICE"
23
+ ],
24
+ "main": "./dist/Index.js",
25
+ "types": "./dist/Index.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/Index.d.ts",
29
+ "import": "./dist/Index.js"
30
+ }
31
+ },
32
+ "engines": {
33
+ "node": ">=22.14.0"
34
+ },
35
+ "dependencies": {
36
+ "@decionis/presence-node": "^0.2.0",
37
+ "jose": "^6.2.8",
38
+ "zod": "^4.4.3"
39
+ },
40
+ "devDependencies": {
41
+ "@stryker-mutator/core": "10.0.0",
42
+ "@stryker-mutator/vitest-runner": "10.0.0",
43
+ "@vitest/coverage-v8": "^4.1.10",
44
+ "vitest": "^4.1.10"
45
+ },
46
+ "publishConfig": {
47
+ "access": "public",
48
+ "provenance": true
49
+ },
50
+ "scripts": {
51
+ "build": "node ../../scripts/CleanBuildOutput.mjs && tsc -p tsconfig.build.json",
52
+ "test": "vitest run --coverage",
53
+ "test:mutation": "stryker run",
54
+ "test:performance": "vitest run test/performance",
55
+ "typecheck": "tsc -p tsconfig.json --noEmit"
56
+ }
57
+ }