@reactive-agents/identity 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tyler Buell
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # @reactive-agents/identity
2
+
3
+ Identity and access control for the [Reactive Agents](https://tylerjrbuell.github.io/reactive-agents-ts/) framework.
4
+
5
+ Manages agent certificates and role-based access control (RBAC) so agents can safely act on behalf of users with well-defined permissions.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ bun add @reactive-agents/identity effect
11
+ ```
12
+
13
+ ## Features
14
+
15
+ - **Agent certificates** — cryptographically identified agent instances
16
+ - **RBAC** — role and permission checks before privileged operations
17
+ - **Identity context** — propagated through the execution engine
18
+
19
+ ## Usage
20
+
21
+ ```typescript
22
+ import { ReactiveAgents } from "reactive-agents";
23
+
24
+ const agent = await ReactiveAgents.create()
25
+ .withName("privileged-agent")
26
+ .withProvider("anthropic")
27
+ .withIdentity({
28
+ roles: ["reader", "writer"],
29
+ issuer: "my-org",
30
+ })
31
+ .build();
32
+ ```
33
+
34
+ ## Documentation
35
+
36
+ Full documentation at [tylerjrbuell.github.io/reactive-agents-ts](https://tylerjrbuell.github.io/reactive-agents-ts/)
@@ -0,0 +1,209 @@
1
+ import { Schema, Effect, Context, Layer } from 'effect';
2
+ import * as effect_Cause from 'effect/Cause';
3
+ import * as effect_Types from 'effect/Types';
4
+ import * as effect_Layer from 'effect/Layer';
5
+
6
+ declare const AgentIdentitySchema: Schema.Struct<{
7
+ agentId: typeof Schema.String;
8
+ name: typeof Schema.String;
9
+ type: Schema.Literal<["primary", "worker", "orchestrator", "specialist"]>;
10
+ createdAt: typeof Schema.DateFromSelf;
11
+ metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
12
+ }>;
13
+ type AgentIdentity = typeof AgentIdentitySchema.Type;
14
+ declare const CertificateSchema: Schema.Struct<{
15
+ serialNumber: typeof Schema.String;
16
+ agentId: typeof Schema.String;
17
+ issuedAt: typeof Schema.DateFromSelf;
18
+ expiresAt: typeof Schema.DateFromSelf;
19
+ publicKey: typeof Schema.String;
20
+ issuer: typeof Schema.String;
21
+ fingerprint: typeof Schema.String;
22
+ status: Schema.Literal<["active", "expired", "revoked"]>;
23
+ }>;
24
+ type Certificate = typeof CertificateSchema.Type;
25
+ declare const AuthResultSchema: Schema.Struct<{
26
+ authenticated: typeof Schema.Boolean;
27
+ agentId: Schema.optional<typeof Schema.String>;
28
+ reason: Schema.optional<typeof Schema.String>;
29
+ expiresAt: Schema.optional<typeof Schema.DateFromSelf>;
30
+ }>;
31
+ type AuthResult = typeof AuthResultSchema.Type;
32
+ declare const PermissionSchema: Schema.Struct<{
33
+ resource: typeof Schema.String;
34
+ actions: Schema.Array$<Schema.Literal<["read", "write", "execute", "delete", "admin"]>>;
35
+ expiresAt: Schema.optional<typeof Schema.DateFromSelf>;
36
+ }>;
37
+ type Permission = typeof PermissionSchema.Type;
38
+ declare const RoleSchema: Schema.Struct<{
39
+ name: typeof Schema.String;
40
+ permissions: Schema.Array$<Schema.Struct<{
41
+ resource: typeof Schema.String;
42
+ actions: Schema.Array$<Schema.Literal<["read", "write", "execute", "delete", "admin"]>>;
43
+ expiresAt: Schema.optional<typeof Schema.DateFromSelf>;
44
+ }>>;
45
+ description: typeof Schema.String;
46
+ }>;
47
+ type Role = typeof RoleSchema.Type;
48
+ declare const DefaultRoles: Record<string, Role>;
49
+ declare const AuditEntrySchema: Schema.Struct<{
50
+ id: typeof Schema.String;
51
+ timestamp: typeof Schema.DateFromSelf;
52
+ agentId: typeof Schema.String;
53
+ sessionId: typeof Schema.String;
54
+ action: typeof Schema.String;
55
+ resource: Schema.optional<typeof Schema.String>;
56
+ result: Schema.Literal<["success", "failure", "denied"]>;
57
+ metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
58
+ parentAgentId: Schema.optional<typeof Schema.String>;
59
+ durationMs: Schema.optional<typeof Schema.Number>;
60
+ }>;
61
+ type AuditEntry = typeof AuditEntrySchema.Type;
62
+ declare const DelegationSchema: Schema.Struct<{
63
+ id: typeof Schema.String;
64
+ fromAgentId: typeof Schema.String;
65
+ toAgentId: typeof Schema.String;
66
+ permissions: Schema.Array$<Schema.Struct<{
67
+ resource: typeof Schema.String;
68
+ actions: Schema.Array$<Schema.Literal<["read", "write", "execute", "delete", "admin"]>>;
69
+ expiresAt: Schema.optional<typeof Schema.DateFromSelf>;
70
+ }>>;
71
+ issuedAt: typeof Schema.DateFromSelf;
72
+ expiresAt: typeof Schema.DateFromSelf;
73
+ reason: typeof Schema.String;
74
+ status: Schema.Literal<["active", "expired", "revoked"]>;
75
+ }>;
76
+ type Delegation = typeof DelegationSchema.Type;
77
+ declare const AuthzDecisionSchema: Schema.Struct<{
78
+ allowed: typeof Schema.Boolean;
79
+ resource: typeof Schema.String;
80
+ action: typeof Schema.String;
81
+ reason: Schema.optional<typeof Schema.String>;
82
+ matchedPermission: Schema.optional<Schema.Struct<{
83
+ resource: typeof Schema.String;
84
+ actions: Schema.Array$<Schema.Literal<["read", "write", "execute", "delete", "admin"]>>;
85
+ expiresAt: Schema.optional<typeof Schema.DateFromSelf>;
86
+ }>>;
87
+ }>;
88
+ type AuthzDecision = typeof AuthzDecisionSchema.Type;
89
+
90
+ declare const AuthenticationError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
91
+ readonly _tag: "AuthenticationError";
92
+ } & Readonly<A>;
93
+ declare class AuthenticationError extends AuthenticationError_base<{
94
+ readonly message: string;
95
+ readonly reason: "invalid-certificate" | "expired" | "revoked" | "unknown-agent";
96
+ readonly agentId?: string;
97
+ }> {
98
+ }
99
+ declare const AuthorizationError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
100
+ readonly _tag: "AuthorizationError";
101
+ } & Readonly<A>;
102
+ declare class AuthorizationError extends AuthorizationError_base<{
103
+ readonly message: string;
104
+ readonly agentId: string;
105
+ readonly resource: string;
106
+ readonly action: string;
107
+ }> {
108
+ }
109
+ declare const AuditError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
110
+ readonly _tag: "AuditError";
111
+ } & Readonly<A>;
112
+ declare class AuditError extends AuditError_base<{
113
+ readonly message: string;
114
+ readonly cause?: unknown;
115
+ }> {
116
+ }
117
+ declare const DelegationError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
118
+ readonly _tag: "DelegationError";
119
+ } & Readonly<A>;
120
+ declare class DelegationError extends DelegationError_base<{
121
+ readonly message: string;
122
+ readonly fromAgentId: string;
123
+ readonly toAgentId: string;
124
+ }> {
125
+ }
126
+ declare const CredentialError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
127
+ readonly _tag: "CredentialError";
128
+ } & Readonly<A>;
129
+ declare class CredentialError extends CredentialError_base<{
130
+ readonly message: string;
131
+ readonly agentId: string;
132
+ readonly operation: "issue" | "rotate" | "revoke";
133
+ }> {
134
+ }
135
+
136
+ interface CertificateAuth {
137
+ readonly authenticate: (cert: Certificate) => Effect.Effect<AuthResult, AuthenticationError>;
138
+ readonly issueCertificate: (agentId: string, ttlMs?: number) => Effect.Effect<Certificate, CredentialError>;
139
+ readonly rotateCertificate: (agentId: string) => Effect.Effect<Certificate, CredentialError>;
140
+ readonly revokeCertificate: (serialNumber: string) => Effect.Effect<void, CredentialError>;
141
+ }
142
+ declare const makeCertificateAuth: Effect.Effect<{
143
+ authenticate: (cert: Certificate) => Effect.Effect<AuthResult, AuthenticationError>;
144
+ issueCertificate: (agentId: string, ttlMs?: number) => Effect.Effect<Certificate, CredentialError>;
145
+ rotateCertificate: (agentId: string) => Effect.Effect<Certificate, CredentialError>;
146
+ revokeCertificate: (serialNumber: string) => Effect.Effect<void, CredentialError>;
147
+ }, never, never>;
148
+
149
+ interface PermissionManager {
150
+ readonly assignRole: (agentId: string, role: Role) => Effect.Effect<void, never>;
151
+ readonly getRoles: (agentId: string) => Effect.Effect<readonly Role[], never>;
152
+ readonly authorize: (agentId: string, resource: string, action: "read" | "write" | "execute" | "delete" | "admin") => Effect.Effect<AuthzDecision, AuthorizationError>;
153
+ readonly delegate: (fromAgentId: string, toAgentId: string, permissions: readonly Permission[], reason: string, durationMs: number) => Effect.Effect<Delegation, DelegationError>;
154
+ readonly revokeDelegation: (delegationId: string) => Effect.Effect<void, DelegationError>;
155
+ }
156
+ declare const makePermissionManager: Effect.Effect<{
157
+ assignRole: (agentId: string, role: Role) => Effect.Effect<void, never>;
158
+ getRoles: (agentId: string) => Effect.Effect<readonly Role[], never>;
159
+ authorize: (agentId: string, resource: string, action: "read" | "write" | "execute" | "delete" | "admin") => Effect.Effect<AuthzDecision, AuthorizationError>;
160
+ delegate: (fromAgentId: string, toAgentId: string, permissions: readonly Permission[], reason: string, durationMs: number) => Effect.Effect<Delegation, DelegationError>;
161
+ revokeDelegation: (delegationId: string) => Effect.Effect<void, DelegationError>;
162
+ }, never, never>;
163
+
164
+ interface AuditLogger {
165
+ readonly log: (entry: Omit<AuditEntry, "id" | "timestamp">) => Effect.Effect<void, AuditError>;
166
+ readonly query: (agentId: string, options?: {
167
+ startDate?: Date;
168
+ endDate?: Date;
169
+ action?: string;
170
+ limit?: number;
171
+ }) => Effect.Effect<readonly AuditEntry[], AuditError>;
172
+ }
173
+ declare const makeAuditLogger: Effect.Effect<{
174
+ log: (entry: Omit<AuditEntry, "id" | "timestamp">) => Effect.Effect<void, AuditError>;
175
+ query: (agentId: string, options?: {
176
+ startDate?: Date;
177
+ endDate?: Date;
178
+ action?: string;
179
+ limit?: number;
180
+ }) => Effect.Effect<readonly AuditEntry[], AuditError>;
181
+ }, never, never>;
182
+
183
+ declare const IdentityService_base: Context.TagClass<IdentityService, "IdentityService", {
184
+ readonly authenticate: (certificate: Certificate) => Effect.Effect<AuthResult, AuthenticationError>;
185
+ readonly authorize: (agentId: string, resource: string, action: "read" | "write" | "execute" | "delete" | "admin") => Effect.Effect<AuthzDecision, AuthorizationError>;
186
+ readonly assignRole: (agentId: string, role: Role) => Effect.Effect<void, never>;
187
+ readonly getRoles: (agentId: string) => Effect.Effect<readonly Role[], never>;
188
+ readonly audit: (entry: Omit<AuditEntry, "id" | "timestamp">) => Effect.Effect<void, AuditError>;
189
+ readonly queryAudit: (agentId: string, options?: {
190
+ startDate?: Date;
191
+ endDate?: Date;
192
+ action?: string;
193
+ limit?: number;
194
+ }) => Effect.Effect<readonly AuditEntry[], AuditError>;
195
+ readonly delegate: (fromAgentId: string, toAgentId: string, permissions: readonly Permission[], reason: string, durationMs: number) => Effect.Effect<Delegation, DelegationError>;
196
+ readonly revokeDelegation: (delegationId: string) => Effect.Effect<void, DelegationError>;
197
+ readonly issueCertificate: (agentId: string, ttlMs?: number) => Effect.Effect<Certificate, CredentialError>;
198
+ readonly rotateCertificate: (agentId: string) => Effect.Effect<Certificate, CredentialError>;
199
+ readonly getIdentity: (agentId: string) => Effect.Effect<AgentIdentity & {
200
+ roles: readonly Role[];
201
+ }, AuthenticationError>;
202
+ }>;
203
+ declare class IdentityService extends IdentityService_base {
204
+ }
205
+ declare const IdentityServiceLive: Layer.Layer<IdentityService, never, never>;
206
+
207
+ declare const createIdentityLayer: () => effect_Layer.Layer<IdentityService, never, never>;
208
+
209
+ export { type AgentIdentity, AgentIdentitySchema, type AuditEntry, AuditEntrySchema, AuditError, type AuditLogger, type AuthResult, AuthResultSchema, AuthenticationError, AuthorizationError, type AuthzDecision, AuthzDecisionSchema, type Certificate, type CertificateAuth, CertificateSchema, CredentialError, DefaultRoles, type Delegation, DelegationError, DelegationSchema, IdentityService, IdentityServiceLive, type Permission, type PermissionManager, PermissionSchema, type Role, RoleSchema, createIdentityLayer, makeAuditLogger, makeCertificateAuth, makePermissionManager };
package/dist/index.js ADDED
@@ -0,0 +1,385 @@
1
+ // src/types.ts
2
+ import { Schema } from "effect";
3
+ var AgentIdentitySchema = Schema.Struct({
4
+ agentId: Schema.String,
5
+ name: Schema.String,
6
+ type: Schema.Literal("primary", "worker", "orchestrator", "specialist"),
7
+ createdAt: Schema.DateFromSelf,
8
+ metadata: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Unknown }))
9
+ });
10
+ var CertificateSchema = Schema.Struct({
11
+ serialNumber: Schema.String,
12
+ agentId: Schema.String,
13
+ issuedAt: Schema.DateFromSelf,
14
+ expiresAt: Schema.DateFromSelf,
15
+ publicKey: Schema.String,
16
+ issuer: Schema.String,
17
+ fingerprint: Schema.String,
18
+ status: Schema.Literal("active", "expired", "revoked")
19
+ });
20
+ var AuthResultSchema = Schema.Struct({
21
+ authenticated: Schema.Boolean,
22
+ agentId: Schema.optional(Schema.String),
23
+ reason: Schema.optional(Schema.String),
24
+ expiresAt: Schema.optional(Schema.DateFromSelf)
25
+ });
26
+ var PermissionSchema = Schema.Struct({
27
+ resource: Schema.String,
28
+ actions: Schema.Array(Schema.Literal("read", "write", "execute", "delete", "admin")),
29
+ expiresAt: Schema.optional(Schema.DateFromSelf)
30
+ });
31
+ var RoleSchema = Schema.Struct({
32
+ name: Schema.String,
33
+ permissions: Schema.Array(PermissionSchema),
34
+ description: Schema.String
35
+ });
36
+ var DefaultRoles = {
37
+ "agent-basic": {
38
+ name: "agent-basic",
39
+ description: "Basic agent with limited tool access",
40
+ permissions: [
41
+ { resource: "memory/working", actions: ["read", "write"] },
42
+ { resource: "tools/basic/*", actions: ["execute"] },
43
+ { resource: "llm/haiku", actions: ["execute"] }
44
+ ]
45
+ },
46
+ "agent-standard": {
47
+ name: "agent-standard",
48
+ description: "Standard agent with full tool and memory access",
49
+ permissions: [
50
+ { resource: "memory/*", actions: ["read", "write"] },
51
+ { resource: "tools/*", actions: ["execute"] },
52
+ { resource: "llm/haiku", actions: ["execute"] },
53
+ { resource: "llm/sonnet", actions: ["execute"] }
54
+ ]
55
+ },
56
+ "agent-privileged": {
57
+ name: "agent-privileged",
58
+ description: "Privileged agent with full access including admin ops",
59
+ permissions: [
60
+ { resource: "*", actions: ["read", "write", "execute", "delete"] },
61
+ { resource: "llm/*", actions: ["execute"] }
62
+ ]
63
+ },
64
+ orchestrator: {
65
+ name: "orchestrator",
66
+ description: "Orchestrator with agent management and delegation rights",
67
+ permissions: [
68
+ { resource: "*", actions: ["read", "write", "execute", "delete", "admin"] },
69
+ { resource: "llm/*", actions: ["execute"] },
70
+ { resource: "agents/*", actions: ["read", "write", "execute", "admin"] }
71
+ ]
72
+ }
73
+ };
74
+ var AuditEntrySchema = Schema.Struct({
75
+ id: Schema.String,
76
+ timestamp: Schema.DateFromSelf,
77
+ agentId: Schema.String,
78
+ sessionId: Schema.String,
79
+ action: Schema.String,
80
+ resource: Schema.optional(Schema.String),
81
+ result: Schema.Literal("success", "failure", "denied"),
82
+ metadata: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Unknown })),
83
+ parentAgentId: Schema.optional(Schema.String),
84
+ durationMs: Schema.optional(Schema.Number)
85
+ });
86
+ var DelegationSchema = Schema.Struct({
87
+ id: Schema.String,
88
+ fromAgentId: Schema.String,
89
+ toAgentId: Schema.String,
90
+ permissions: Schema.Array(PermissionSchema),
91
+ issuedAt: Schema.DateFromSelf,
92
+ expiresAt: Schema.DateFromSelf,
93
+ reason: Schema.String,
94
+ status: Schema.Literal("active", "expired", "revoked")
95
+ });
96
+ var AuthzDecisionSchema = Schema.Struct({
97
+ allowed: Schema.Boolean,
98
+ resource: Schema.String,
99
+ action: Schema.String,
100
+ reason: Schema.optional(Schema.String),
101
+ matchedPermission: Schema.optional(PermissionSchema)
102
+ });
103
+
104
+ // src/errors.ts
105
+ import { Data } from "effect";
106
+ var AuthenticationError = class extends Data.TaggedError("AuthenticationError") {
107
+ };
108
+ var AuthorizationError = class extends Data.TaggedError("AuthorizationError") {
109
+ };
110
+ var AuditError = class extends Data.TaggedError("AuditError") {
111
+ };
112
+ var DelegationError = class extends Data.TaggedError("DelegationError") {
113
+ };
114
+ var CredentialError = class extends Data.TaggedError("CredentialError") {
115
+ };
116
+
117
+ // src/auth/certificate-auth.ts
118
+ import { Effect, Ref } from "effect";
119
+ var makeCertificateAuth = Effect.gen(function* () {
120
+ const certsRef = yield* Ref.make(/* @__PURE__ */ new Map());
121
+ const revokedRef = yield* Ref.make(/* @__PURE__ */ new Set());
122
+ const authenticate = (cert) => Effect.gen(function* () {
123
+ if (!cert.serialNumber || !cert.publicKey || !cert.fingerprint) {
124
+ return yield* Effect.fail(
125
+ new AuthenticationError({
126
+ message: `Invalid certificate for agent ${cert.agentId}`,
127
+ reason: "invalid-certificate",
128
+ agentId: cert.agentId
129
+ })
130
+ );
131
+ }
132
+ if (cert.expiresAt < /* @__PURE__ */ new Date()) {
133
+ return yield* Effect.fail(
134
+ new AuthenticationError({
135
+ message: `Certificate expired for agent ${cert.agentId}`,
136
+ reason: "expired",
137
+ agentId: cert.agentId
138
+ })
139
+ );
140
+ }
141
+ const revoked = yield* Ref.get(revokedRef);
142
+ if (revoked.has(cert.serialNumber)) {
143
+ return yield* Effect.fail(
144
+ new AuthenticationError({
145
+ message: `Certificate revoked for agent ${cert.agentId}`,
146
+ reason: "revoked",
147
+ agentId: cert.agentId
148
+ })
149
+ );
150
+ }
151
+ return {
152
+ authenticated: true,
153
+ agentId: cert.agentId,
154
+ expiresAt: cert.expiresAt
155
+ };
156
+ });
157
+ const issueCertificate = (agentId, ttlMs = 7 * 24 * 60 * 60 * 1e3) => Effect.try({
158
+ try: () => {
159
+ const now = /* @__PURE__ */ new Date();
160
+ const serialNumber = crypto.randomUUID();
161
+ const publicKey = `pk-${crypto.randomUUID()}`;
162
+ const fingerprint = `fp-${crypto.randomUUID().slice(0, 16)}`;
163
+ const cert = {
164
+ serialNumber,
165
+ agentId,
166
+ issuedAt: now,
167
+ expiresAt: new Date(now.getTime() + ttlMs),
168
+ publicKey,
169
+ issuer: "reactive-agents-ca",
170
+ fingerprint,
171
+ status: "active"
172
+ };
173
+ return cert;
174
+ },
175
+ catch: (e) => new CredentialError({
176
+ message: `Failed to issue certificate: ${e}`,
177
+ agentId,
178
+ operation: "issue"
179
+ })
180
+ }).pipe(
181
+ Effect.tap(
182
+ (cert) => Ref.update(certsRef, (certs) => {
183
+ const newCerts = new Map(certs);
184
+ newCerts.set(cert.serialNumber, cert);
185
+ return newCerts;
186
+ })
187
+ )
188
+ );
189
+ const rotateCertificate = (agentId) => Effect.gen(function* () {
190
+ const certs = yield* Ref.get(certsRef);
191
+ for (const [serial, cert] of certs) {
192
+ if (cert.agentId === agentId && cert.status === "active") {
193
+ yield* Ref.update(revokedRef, (revoked) => /* @__PURE__ */ new Set([...revoked, serial]));
194
+ }
195
+ }
196
+ return yield* issueCertificate(agentId);
197
+ });
198
+ const revokeCertificate = (serialNumber) => Ref.update(revokedRef, (revoked) => /* @__PURE__ */ new Set([...revoked, serialNumber])).pipe(
199
+ Effect.mapError(
200
+ () => new CredentialError({ message: "Revocation failed", agentId: "unknown", operation: "revoke" })
201
+ )
202
+ );
203
+ return { authenticate, issueCertificate, rotateCertificate, revokeCertificate };
204
+ });
205
+
206
+ // src/authz/permission-manager.ts
207
+ import { Effect as Effect2, Ref as Ref2 } from "effect";
208
+ var makePermissionManager = Effect2.gen(function* () {
209
+ const agentRolesRef = yield* Ref2.make(/* @__PURE__ */ new Map());
210
+ const delegationsRef = yield* Ref2.make([]);
211
+ const assignRole = (agentId, role) => Ref2.update(agentRolesRef, (map) => {
212
+ const newMap = new Map(map);
213
+ const existing = newMap.get(agentId) ?? [];
214
+ if (!existing.find((r) => r.name === role.name)) {
215
+ newMap.set(agentId, [...existing, role]);
216
+ }
217
+ return newMap;
218
+ });
219
+ const getRoles = (agentId) => Ref2.get(agentRolesRef).pipe(Effect2.map((map) => map.get(agentId) ?? []));
220
+ const authorize = (agentId, resource, action) => Effect2.gen(function* () {
221
+ const roles = yield* Ref2.get(agentRolesRef).pipe(
222
+ Effect2.map((map) => map.get(agentId) ?? [])
223
+ );
224
+ const delegations = yield* Ref2.get(delegationsRef).pipe(
225
+ Effect2.map(
226
+ (dels) => dels.filter(
227
+ (d) => d.toAgentId === agentId && d.status === "active" && d.expiresAt > /* @__PURE__ */ new Date()
228
+ )
229
+ )
230
+ );
231
+ const allPermissions = [
232
+ ...roles.flatMap((r) => r.permissions),
233
+ ...delegations.flatMap((d) => [...d.permissions])
234
+ ];
235
+ const matched = allPermissions.find((p) => {
236
+ const resourceMatch = matchWildcard(p.resource, resource);
237
+ const actionMatch = p.actions.includes(action) || p.actions.includes("admin");
238
+ const notExpired = !p.expiresAt || p.expiresAt > /* @__PURE__ */ new Date();
239
+ return resourceMatch && actionMatch && notExpired;
240
+ });
241
+ if (matched) {
242
+ return { allowed: true, resource, action, matchedPermission: matched };
243
+ }
244
+ return yield* Effect2.fail(
245
+ new AuthorizationError({
246
+ message: `Agent ${agentId} not authorized for ${action} on ${resource}`,
247
+ agentId,
248
+ resource,
249
+ action
250
+ })
251
+ );
252
+ });
253
+ const delegate = (fromAgentId, toAgentId, permissions, reason, durationMs) => Effect2.gen(function* () {
254
+ for (const perm of permissions) {
255
+ for (const action of perm.actions) {
256
+ yield* authorize(fromAgentId, perm.resource, action).pipe(
257
+ Effect2.mapError(
258
+ () => new DelegationError({
259
+ message: `Cannot delegate ${action} on ${perm.resource}: delegator lacks permission`,
260
+ fromAgentId,
261
+ toAgentId
262
+ })
263
+ )
264
+ );
265
+ }
266
+ }
267
+ const now = /* @__PURE__ */ new Date();
268
+ const delegation = {
269
+ id: crypto.randomUUID(),
270
+ fromAgentId,
271
+ toAgentId,
272
+ permissions: [...permissions],
273
+ issuedAt: now,
274
+ expiresAt: new Date(now.getTime() + durationMs),
275
+ reason,
276
+ status: "active"
277
+ };
278
+ yield* Ref2.update(delegationsRef, (dels) => [...dels, delegation]);
279
+ return delegation;
280
+ });
281
+ const revokeDelegation = (delegationId) => Ref2.update(
282
+ delegationsRef,
283
+ (dels) => dels.map((d) => d.id === delegationId ? { ...d, status: "revoked" } : d)
284
+ ).pipe(
285
+ Effect2.mapError(
286
+ () => new DelegationError({ message: "Revocation failed", fromAgentId: "", toAgentId: "" })
287
+ )
288
+ );
289
+ return { assignRole, getRoles, authorize, delegate, revokeDelegation };
290
+ });
291
+ function matchWildcard(pattern, value) {
292
+ if (pattern === "*") return true;
293
+ const regex = new RegExp("^" + pattern.replace(/\*/g, ".*").replace(/\?/g, ".") + "$");
294
+ return regex.test(value);
295
+ }
296
+
297
+ // src/audit/audit-logger.ts
298
+ import { Effect as Effect3, Ref as Ref3 } from "effect";
299
+ var makeAuditLogger = Effect3.gen(function* () {
300
+ const logRef = yield* Ref3.make([]);
301
+ const log = (entry) => Ref3.update(logRef, (entries) => [
302
+ ...entries,
303
+ { ...entry, id: crypto.randomUUID(), timestamp: /* @__PURE__ */ new Date() }
304
+ ]).pipe(
305
+ Effect3.mapError((e) => new AuditError({ message: "Audit logging failed", cause: e }))
306
+ );
307
+ const query = (agentId, options) => Effect3.gen(function* () {
308
+ const allEntries = yield* Ref3.get(logRef);
309
+ let filtered = allEntries.filter((e) => {
310
+ if (e.agentId !== agentId) return false;
311
+ if (options?.startDate && e.timestamp < options.startDate) return false;
312
+ if (options?.endDate && e.timestamp > options.endDate) return false;
313
+ if (options?.action && e.action !== options.action) return false;
314
+ return true;
315
+ });
316
+ if (options?.limit) {
317
+ filtered = filtered.slice(-options.limit);
318
+ }
319
+ return filtered;
320
+ }).pipe(
321
+ Effect3.mapError((e) => new AuditError({ message: "Audit query failed", cause: e }))
322
+ );
323
+ return { log, query };
324
+ });
325
+
326
+ // src/identity-service.ts
327
+ import { Effect as Effect4, Context, Layer } from "effect";
328
+ var IdentityService = class extends Context.Tag("IdentityService")() {
329
+ };
330
+ var IdentityServiceLive = Layer.effect(
331
+ IdentityService,
332
+ Effect4.gen(function* () {
333
+ const certAuth = yield* makeCertificateAuth;
334
+ const permissions = yield* makePermissionManager;
335
+ const auditLogger = yield* makeAuditLogger;
336
+ return {
337
+ authenticate: (cert) => certAuth.authenticate(cert),
338
+ authorize: (agentId, resource, action) => permissions.authorize(agentId, resource, action),
339
+ assignRole: (agentId, role) => permissions.assignRole(agentId, role),
340
+ getRoles: (agentId) => permissions.getRoles(agentId),
341
+ audit: (entry) => auditLogger.log(entry),
342
+ queryAudit: (agentId, options) => auditLogger.query(agentId, options),
343
+ delegate: (from, to, perms, reason, dur) => permissions.delegate(from, to, perms, reason, dur),
344
+ revokeDelegation: (id) => permissions.revokeDelegation(id),
345
+ issueCertificate: (agentId, ttlMs) => certAuth.issueCertificate(agentId, ttlMs),
346
+ rotateCertificate: (agentId) => certAuth.rotateCertificate(agentId),
347
+ getIdentity: (agentId) => Effect4.gen(function* () {
348
+ const roles = yield* permissions.getRoles(agentId);
349
+ return {
350
+ agentId,
351
+ name: agentId,
352
+ type: "primary",
353
+ createdAt: /* @__PURE__ */ new Date(),
354
+ roles: roles.length > 0 ? roles : [DefaultRoles["agent-standard"]]
355
+ };
356
+ })
357
+ };
358
+ })
359
+ );
360
+
361
+ // src/runtime.ts
362
+ var createIdentityLayer = () => IdentityServiceLive;
363
+ export {
364
+ AgentIdentitySchema,
365
+ AuditEntrySchema,
366
+ AuditError,
367
+ AuthResultSchema,
368
+ AuthenticationError,
369
+ AuthorizationError,
370
+ AuthzDecisionSchema,
371
+ CertificateSchema,
372
+ CredentialError,
373
+ DefaultRoles,
374
+ DelegationError,
375
+ DelegationSchema,
376
+ IdentityService,
377
+ IdentityServiceLive,
378
+ PermissionSchema,
379
+ RoleSchema,
380
+ createIdentityLayer,
381
+ makeAuditLogger,
382
+ makeCertificateAuth,
383
+ makePermissionManager
384
+ };
385
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types.ts","../src/errors.ts","../src/auth/certificate-auth.ts","../src/authz/permission-manager.ts","../src/audit/audit-logger.ts","../src/identity-service.ts","../src/runtime.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\n// ─── Agent Identity ───\n\nexport const AgentIdentitySchema = Schema.Struct({\n agentId: Schema.String,\n name: Schema.String,\n type: Schema.Literal(\"primary\", \"worker\", \"orchestrator\", \"specialist\"),\n createdAt: Schema.DateFromSelf,\n metadata: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Unknown })),\n});\nexport type AgentIdentity = typeof AgentIdentitySchema.Type;\n\n// ─── Certificate ───\n\nexport const CertificateSchema = Schema.Struct({\n serialNumber: Schema.String,\n agentId: Schema.String,\n issuedAt: Schema.DateFromSelf,\n expiresAt: Schema.DateFromSelf,\n publicKey: Schema.String,\n issuer: Schema.String,\n fingerprint: Schema.String,\n status: Schema.Literal(\"active\", \"expired\", \"revoked\"),\n});\nexport type Certificate = typeof CertificateSchema.Type;\n\n// ─── Authentication Result ───\n\nexport const AuthResultSchema = Schema.Struct({\n authenticated: Schema.Boolean,\n agentId: Schema.optional(Schema.String),\n reason: Schema.optional(Schema.String),\n expiresAt: Schema.optional(Schema.DateFromSelf),\n});\nexport type AuthResult = typeof AuthResultSchema.Type;\n\n// ─── Permission ───\n\nexport const PermissionSchema = Schema.Struct({\n resource: Schema.String,\n actions: Schema.Array(Schema.Literal(\"read\", \"write\", \"execute\", \"delete\", \"admin\")),\n expiresAt: Schema.optional(Schema.DateFromSelf),\n});\nexport type Permission = typeof PermissionSchema.Type;\n\n// ─── Role ───\n\nexport const RoleSchema = Schema.Struct({\n name: Schema.String,\n permissions: Schema.Array(PermissionSchema),\n description: Schema.String,\n});\nexport type Role = typeof RoleSchema.Type;\n\n// ─── Pre-defined Roles ───\n\nexport const DefaultRoles: Record<string, Role> = {\n \"agent-basic\": {\n name: \"agent-basic\",\n description: \"Basic agent with limited tool access\",\n permissions: [\n { resource: \"memory/working\", actions: [\"read\", \"write\"] },\n { resource: \"tools/basic/*\", actions: [\"execute\"] },\n { resource: \"llm/haiku\", actions: [\"execute\"] },\n ],\n },\n \"agent-standard\": {\n name: \"agent-standard\",\n description: \"Standard agent with full tool and memory access\",\n permissions: [\n { resource: \"memory/*\", actions: [\"read\", \"write\"] },\n { resource: \"tools/*\", actions: [\"execute\"] },\n { resource: \"llm/haiku\", actions: [\"execute\"] },\n { resource: \"llm/sonnet\", actions: [\"execute\"] },\n ],\n },\n \"agent-privileged\": {\n name: \"agent-privileged\",\n description: \"Privileged agent with full access including admin ops\",\n permissions: [\n { resource: \"*\", actions: [\"read\", \"write\", \"execute\", \"delete\"] },\n { resource: \"llm/*\", actions: [\"execute\"] },\n ],\n },\n orchestrator: {\n name: \"orchestrator\",\n description: \"Orchestrator with agent management and delegation rights\",\n permissions: [\n { resource: \"*\", actions: [\"read\", \"write\", \"execute\", \"delete\", \"admin\"] },\n { resource: \"llm/*\", actions: [\"execute\"] },\n { resource: \"agents/*\", actions: [\"read\", \"write\", \"execute\", \"admin\"] },\n ],\n },\n};\n\n// ─── Audit Entry ───\n\nexport const AuditEntrySchema = Schema.Struct({\n id: Schema.String,\n timestamp: Schema.DateFromSelf,\n agentId: Schema.String,\n sessionId: Schema.String,\n action: Schema.String,\n resource: Schema.optional(Schema.String),\n result: Schema.Literal(\"success\", \"failure\", \"denied\"),\n metadata: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Unknown })),\n parentAgentId: Schema.optional(Schema.String),\n durationMs: Schema.optional(Schema.Number),\n});\nexport type AuditEntry = typeof AuditEntrySchema.Type;\n\n// ─── Delegation ───\n\nexport const DelegationSchema = Schema.Struct({\n id: Schema.String,\n fromAgentId: Schema.String,\n toAgentId: Schema.String,\n permissions: Schema.Array(PermissionSchema),\n issuedAt: Schema.DateFromSelf,\n expiresAt: Schema.DateFromSelf,\n reason: Schema.String,\n status: Schema.Literal(\"active\", \"expired\", \"revoked\"),\n});\nexport type Delegation = typeof DelegationSchema.Type;\n\n// ─── Authorization Decision ───\n\nexport const AuthzDecisionSchema = Schema.Struct({\n allowed: Schema.Boolean,\n resource: Schema.String,\n action: Schema.String,\n reason: Schema.optional(Schema.String),\n matchedPermission: Schema.optional(PermissionSchema),\n});\nexport type AuthzDecision = typeof AuthzDecisionSchema.Type;\n","import { Data } from \"effect\";\n\nexport class AuthenticationError extends Data.TaggedError(\"AuthenticationError\")<{\n readonly message: string;\n readonly reason: \"invalid-certificate\" | \"expired\" | \"revoked\" | \"unknown-agent\";\n readonly agentId?: string;\n}> {}\n\nexport class AuthorizationError extends Data.TaggedError(\"AuthorizationError\")<{\n readonly message: string;\n readonly agentId: string;\n readonly resource: string;\n readonly action: string;\n}> {}\n\nexport class AuditError extends Data.TaggedError(\"AuditError\")<{\n readonly message: string;\n readonly cause?: unknown;\n}> {}\n\nexport class DelegationError extends Data.TaggedError(\"DelegationError\")<{\n readonly message: string;\n readonly fromAgentId: string;\n readonly toAgentId: string;\n}> {}\n\nexport class CredentialError extends Data.TaggedError(\"CredentialError\")<{\n readonly message: string;\n readonly agentId: string;\n readonly operation: \"issue\" | \"rotate\" | \"revoke\";\n}> {}\n","import { Effect, Ref } from \"effect\";\nimport type { Certificate, AuthResult } from \"../types.js\";\nimport { AuthenticationError, CredentialError } from \"../errors.js\";\n\nexport interface CertificateAuth {\n readonly authenticate: (cert: Certificate) => Effect.Effect<AuthResult, AuthenticationError>;\n readonly issueCertificate: (agentId: string, ttlMs?: number) => Effect.Effect<Certificate, CredentialError>;\n readonly rotateCertificate: (agentId: string) => Effect.Effect<Certificate, CredentialError>;\n readonly revokeCertificate: (serialNumber: string) => Effect.Effect<void, CredentialError>;\n}\n\nexport const makeCertificateAuth = Effect.gen(function* () {\n const certsRef = yield* Ref.make<Map<string, Certificate>>(new Map());\n const revokedRef = yield* Ref.make<Set<string>>(new Set());\n\n const authenticate = (\n cert: Certificate,\n ): Effect.Effect<AuthResult, AuthenticationError> =>\n Effect.gen(function* () {\n // Verify certificate format\n if (!cert.serialNumber || !cert.publicKey || !cert.fingerprint) {\n return yield* Effect.fail(\n new AuthenticationError({\n message: `Invalid certificate for agent ${cert.agentId}`,\n reason: \"invalid-certificate\",\n agentId: cert.agentId,\n }),\n );\n }\n\n // Check expiration\n if (cert.expiresAt < new Date()) {\n return yield* Effect.fail(\n new AuthenticationError({\n message: `Certificate expired for agent ${cert.agentId}`,\n reason: \"expired\",\n agentId: cert.agentId,\n }),\n );\n }\n\n // Check revocation\n const revoked = yield* Ref.get(revokedRef);\n if (revoked.has(cert.serialNumber)) {\n return yield* Effect.fail(\n new AuthenticationError({\n message: `Certificate revoked for agent ${cert.agentId}`,\n reason: \"revoked\",\n agentId: cert.agentId,\n }),\n );\n }\n\n return {\n authenticated: true,\n agentId: cert.agentId,\n expiresAt: cert.expiresAt,\n };\n });\n\n const issueCertificate = (\n agentId: string,\n ttlMs: number = 7 * 24 * 60 * 60 * 1000,\n ): Effect.Effect<Certificate, CredentialError> =>\n Effect.try({\n try: () => {\n const now = new Date();\n const serialNumber = crypto.randomUUID();\n const publicKey = `pk-${crypto.randomUUID()}`;\n const fingerprint = `fp-${crypto.randomUUID().slice(0, 16)}`;\n\n const cert: Certificate = {\n serialNumber,\n agentId,\n issuedAt: now,\n expiresAt: new Date(now.getTime() + ttlMs),\n publicKey,\n issuer: \"reactive-agents-ca\",\n fingerprint,\n status: \"active\",\n };\n\n return cert;\n },\n catch: (e) =>\n new CredentialError({\n message: `Failed to issue certificate: ${e}`,\n agentId,\n operation: \"issue\",\n }),\n }).pipe(\n Effect.tap((cert) =>\n Ref.update(certsRef, (certs) => {\n const newCerts = new Map(certs);\n newCerts.set(cert.serialNumber, cert);\n return newCerts;\n }),\n ),\n );\n\n const rotateCertificate = (\n agentId: string,\n ): Effect.Effect<Certificate, CredentialError> =>\n Effect.gen(function* () {\n // Revoke all existing certificates for this agent\n const certs = yield* Ref.get(certsRef);\n for (const [serial, cert] of certs) {\n if (cert.agentId === agentId && cert.status === \"active\") {\n yield* Ref.update(revokedRef, (revoked) => new Set([...revoked, serial]));\n }\n }\n // Issue new certificate\n return yield* issueCertificate(agentId);\n });\n\n const revokeCertificate = (\n serialNumber: string,\n ): Effect.Effect<void, CredentialError> =>\n Ref.update(revokedRef, (revoked) => new Set([...revoked, serialNumber])).pipe(\n Effect.mapError(\n () => new CredentialError({ message: \"Revocation failed\", agentId: \"unknown\", operation: \"revoke\" }),\n ),\n );\n\n return { authenticate, issueCertificate, rotateCertificate, revokeCertificate } satisfies CertificateAuth;\n});\n","import { Effect, Ref } from \"effect\";\nimport type { Role, Permission, AuthzDecision, Delegation } from \"../types.js\";\nimport { AuthorizationError, DelegationError } from \"../errors.js\";\n\nexport interface PermissionManager {\n readonly assignRole: (agentId: string, role: Role) => Effect.Effect<void, never>;\n readonly getRoles: (agentId: string) => Effect.Effect<readonly Role[], never>;\n readonly authorize: (agentId: string, resource: string, action: \"read\" | \"write\" | \"execute\" | \"delete\" | \"admin\") => Effect.Effect<AuthzDecision, AuthorizationError>;\n readonly delegate: (fromAgentId: string, toAgentId: string, permissions: readonly Permission[], reason: string, durationMs: number) => Effect.Effect<Delegation, DelegationError>;\n readonly revokeDelegation: (delegationId: string) => Effect.Effect<void, DelegationError>;\n}\n\nexport const makePermissionManager = Effect.gen(function* () {\n const agentRolesRef = yield* Ref.make<Map<string, Role[]>>(new Map());\n const delegationsRef = yield* Ref.make<Delegation[]>([]);\n\n const assignRole = (agentId: string, role: Role): Effect.Effect<void, never> =>\n Ref.update(agentRolesRef, (map) => {\n const newMap = new Map(map);\n const existing = newMap.get(agentId) ?? [];\n // Don't add duplicate roles\n if (!existing.find((r) => r.name === role.name)) {\n newMap.set(agentId, [...existing, role]);\n }\n return newMap;\n });\n\n const getRoles = (agentId: string): Effect.Effect<readonly Role[], never> =>\n Ref.get(agentRolesRef).pipe(Effect.map((map) => map.get(agentId) ?? []));\n\n const authorize = (\n agentId: string,\n resource: string,\n action: \"read\" | \"write\" | \"execute\" | \"delete\" | \"admin\",\n ): Effect.Effect<AuthzDecision, AuthorizationError> =>\n Effect.gen(function* () {\n const roles = yield* Ref.get(agentRolesRef).pipe(\n Effect.map((map) => map.get(agentId) ?? []),\n );\n\n const delegations = yield* Ref.get(delegationsRef).pipe(\n Effect.map((dels) =>\n dels.filter(\n (d) => d.toAgentId === agentId && d.status === \"active\" && d.expiresAt > new Date(),\n ),\n ),\n );\n\n const allPermissions: Permission[] = [\n ...roles.flatMap((r) => r.permissions),\n ...delegations.flatMap((d) => [...d.permissions]),\n ];\n\n const matched = allPermissions.find((p) => {\n const resourceMatch = matchWildcard(p.resource, resource);\n const actionMatch = p.actions.includes(action) || p.actions.includes(\"admin\");\n const notExpired = !p.expiresAt || p.expiresAt > new Date();\n return resourceMatch && actionMatch && notExpired;\n });\n\n if (matched) {\n return { allowed: true, resource, action, matchedPermission: matched };\n }\n\n return yield* Effect.fail(\n new AuthorizationError({\n message: `Agent ${agentId} not authorized for ${action} on ${resource}`,\n agentId,\n resource,\n action,\n }),\n );\n });\n\n const delegate = (\n fromAgentId: string,\n toAgentId: string,\n permissions: readonly Permission[],\n reason: string,\n durationMs: number,\n ): Effect.Effect<Delegation, DelegationError> =>\n Effect.gen(function* () {\n // Verify delegator has the permissions they're delegating\n for (const perm of permissions) {\n for (const action of perm.actions) {\n yield* authorize(fromAgentId, perm.resource, action).pipe(\n Effect.mapError(\n () =>\n new DelegationError({\n message: `Cannot delegate ${action} on ${perm.resource}: delegator lacks permission`,\n fromAgentId,\n toAgentId,\n }),\n ),\n );\n }\n }\n\n const now = new Date();\n const delegation: Delegation = {\n id: crypto.randomUUID(),\n fromAgentId,\n toAgentId,\n permissions: [...permissions],\n issuedAt: now,\n expiresAt: new Date(now.getTime() + durationMs),\n reason,\n status: \"active\",\n };\n\n yield* Ref.update(delegationsRef, (dels) => [...dels, delegation]);\n return delegation;\n });\n\n const revokeDelegation = (delegationId: string): Effect.Effect<void, DelegationError> =>\n Ref.update(delegationsRef, (dels) =>\n dels.map((d) => (d.id === delegationId ? { ...d, status: \"revoked\" as const } : d)),\n ).pipe(\n Effect.mapError(\n () => new DelegationError({ message: \"Revocation failed\", fromAgentId: \"\", toAgentId: \"\" }),\n ),\n );\n\n return { assignRole, getRoles, authorize, delegate, revokeDelegation } satisfies PermissionManager;\n});\n\nfunction matchWildcard(pattern: string, value: string): boolean {\n if (pattern === \"*\") return true;\n const regex = new RegExp(\"^\" + pattern.replace(/\\*/g, \".*\").replace(/\\?/g, \".\") + \"$\");\n return regex.test(value);\n}\n","import { Effect, Ref } from \"effect\";\nimport type { AuditEntry } from \"../types.js\";\nimport { AuditError } from \"../errors.js\";\n\nexport interface AuditLogger {\n readonly log: (entry: Omit<AuditEntry, \"id\" | \"timestamp\">) => Effect.Effect<void, AuditError>;\n readonly query: (agentId: string, options?: { startDate?: Date; endDate?: Date; action?: string; limit?: number }) => Effect.Effect<readonly AuditEntry[], AuditError>;\n}\n\nexport const makeAuditLogger = Effect.gen(function* () {\n const logRef = yield* Ref.make<AuditEntry[]>([]);\n\n const log = (\n entry: Omit<AuditEntry, \"id\" | \"timestamp\">,\n ): Effect.Effect<void, AuditError> =>\n Ref.update(logRef, (entries) => [\n ...entries,\n { ...entry, id: crypto.randomUUID(), timestamp: new Date() },\n ]).pipe(\n Effect.mapError((e) => new AuditError({ message: \"Audit logging failed\", cause: e })),\n );\n\n const query = (\n agentId: string,\n options?: { startDate?: Date; endDate?: Date; action?: string; limit?: number },\n ): Effect.Effect<readonly AuditEntry[], AuditError> =>\n Effect.gen(function* () {\n const allEntries = yield* Ref.get(logRef);\n\n let filtered = allEntries.filter((e) => {\n if (e.agentId !== agentId) return false;\n if (options?.startDate && e.timestamp < options.startDate) return false;\n if (options?.endDate && e.timestamp > options.endDate) return false;\n if (options?.action && e.action !== options.action) return false;\n return true;\n });\n\n if (options?.limit) {\n filtered = filtered.slice(-options.limit);\n }\n\n return filtered;\n }).pipe(\n Effect.mapError((e) => new AuditError({ message: \"Audit query failed\", cause: e })),\n );\n\n return { log, query } satisfies AuditLogger;\n});\n","import { Effect, Context, Layer } from \"effect\";\nimport type { Certificate, AuthResult, Permission, Role, AuditEntry, Delegation, AuthzDecision, AgentIdentity } from \"./types.js\";\nimport { DefaultRoles } from \"./types.js\";\nimport type { AuthenticationError, AuthorizationError, AuditError, DelegationError, CredentialError } from \"./errors.js\";\nimport { makeCertificateAuth } from \"./auth/certificate-auth.js\";\nimport { makePermissionManager } from \"./authz/permission-manager.js\";\nimport { makeAuditLogger } from \"./audit/audit-logger.js\";\n\n// ─── Service Tag ───\n\nexport class IdentityService extends Context.Tag(\"IdentityService\")<\n IdentityService,\n {\n readonly authenticate: (certificate: Certificate) => Effect.Effect<AuthResult, AuthenticationError>;\n readonly authorize: (agentId: string, resource: string, action: \"read\" | \"write\" | \"execute\" | \"delete\" | \"admin\") => Effect.Effect<AuthzDecision, AuthorizationError>;\n readonly assignRole: (agentId: string, role: Role) => Effect.Effect<void, never>;\n readonly getRoles: (agentId: string) => Effect.Effect<readonly Role[], never>;\n readonly audit: (entry: Omit<AuditEntry, \"id\" | \"timestamp\">) => Effect.Effect<void, AuditError>;\n readonly queryAudit: (agentId: string, options?: { startDate?: Date; endDate?: Date; action?: string; limit?: number }) => Effect.Effect<readonly AuditEntry[], AuditError>;\n readonly delegate: (fromAgentId: string, toAgentId: string, permissions: readonly Permission[], reason: string, durationMs: number) => Effect.Effect<Delegation, DelegationError>;\n readonly revokeDelegation: (delegationId: string) => Effect.Effect<void, DelegationError>;\n readonly issueCertificate: (agentId: string, ttlMs?: number) => Effect.Effect<Certificate, CredentialError>;\n readonly rotateCertificate: (agentId: string) => Effect.Effect<Certificate, CredentialError>;\n readonly getIdentity: (agentId: string) => Effect.Effect<AgentIdentity & { roles: readonly Role[] }, AuthenticationError>;\n }\n>() {}\n\n// ─── Live Implementation ───\n\nexport const IdentityServiceLive = Layer.effect(\n IdentityService,\n Effect.gen(function* () {\n const certAuth = yield* makeCertificateAuth;\n const permissions = yield* makePermissionManager;\n const auditLogger = yield* makeAuditLogger;\n\n return {\n authenticate: (cert) => certAuth.authenticate(cert),\n authorize: (agentId, resource, action) => permissions.authorize(agentId, resource, action),\n assignRole: (agentId, role) => permissions.assignRole(agentId, role),\n getRoles: (agentId) => permissions.getRoles(agentId),\n audit: (entry) => auditLogger.log(entry),\n queryAudit: (agentId, options) => auditLogger.query(agentId, options),\n delegate: (from, to, perms, reason, dur) => permissions.delegate(from, to, perms, reason, dur),\n revokeDelegation: (id) => permissions.revokeDelegation(id),\n issueCertificate: (agentId, ttlMs) => certAuth.issueCertificate(agentId, ttlMs),\n rotateCertificate: (agentId) => certAuth.rotateCertificate(agentId),\n getIdentity: (agentId) =>\n Effect.gen(function* () {\n const roles = yield* permissions.getRoles(agentId);\n return {\n agentId,\n name: agentId,\n type: \"primary\" as const,\n createdAt: new Date(),\n roles: roles.length > 0 ? roles : [DefaultRoles[\"agent-standard\"]!],\n };\n }),\n };\n }),\n);\n","import { IdentityServiceLive } from \"./identity-service.js\";\n\nexport const createIdentityLayer = () => IdentityServiceLive;\n"],"mappings":";AAAA,SAAS,cAAc;AAIhB,IAAM,sBAAsB,OAAO,OAAO;AAAA,EAC/C,SAAS,OAAO;AAAA,EAChB,MAAM,OAAO;AAAA,EACb,MAAM,OAAO,QAAQ,WAAW,UAAU,gBAAgB,YAAY;AAAA,EACtE,WAAW,OAAO;AAAA,EAClB,UAAU,OAAO,SAAS,OAAO,OAAO,EAAE,KAAK,OAAO,QAAQ,OAAO,OAAO,QAAQ,CAAC,CAAC;AACxF,CAAC;AAKM,IAAM,oBAAoB,OAAO,OAAO;AAAA,EAC7C,cAAc,OAAO;AAAA,EACrB,SAAS,OAAO;AAAA,EAChB,UAAU,OAAO;AAAA,EACjB,WAAW,OAAO;AAAA,EAClB,WAAW,OAAO;AAAA,EAClB,QAAQ,OAAO;AAAA,EACf,aAAa,OAAO;AAAA,EACpB,QAAQ,OAAO,QAAQ,UAAU,WAAW,SAAS;AACvD,CAAC;AAKM,IAAM,mBAAmB,OAAO,OAAO;AAAA,EAC5C,eAAe,OAAO;AAAA,EACtB,SAAS,OAAO,SAAS,OAAO,MAAM;AAAA,EACtC,QAAQ,OAAO,SAAS,OAAO,MAAM;AAAA,EACrC,WAAW,OAAO,SAAS,OAAO,YAAY;AAChD,CAAC;AAKM,IAAM,mBAAmB,OAAO,OAAO;AAAA,EAC5C,UAAU,OAAO;AAAA,EACjB,SAAS,OAAO,MAAM,OAAO,QAAQ,QAAQ,SAAS,WAAW,UAAU,OAAO,CAAC;AAAA,EACnF,WAAW,OAAO,SAAS,OAAO,YAAY;AAChD,CAAC;AAKM,IAAM,aAAa,OAAO,OAAO;AAAA,EACtC,MAAM,OAAO;AAAA,EACb,aAAa,O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CAAC,SAAS,UAAU,SAAS,iBAAiB,SAAS,KAAK;AAAA,MAC9E,mBAAmB,CAAC,YAAY,SAAS,kBAAkB,OAAO;AAAA,MAClE,aAAa,CAAC,YACZA,QAAO,IAAI,aAAa;AACtB,cAAM,QAAQ,OAAO,YAAY,SAAS,OAAO;AACjD,eAAO;AAAA,UACL;AAAA,UACA,MAAM;AAAA,UACN,MAAM;AAAA,UACN,WAAW,oBAAI,KAAK;AAAA,UACpB,OAAO,MAAM,SAAS,IAAI,QAAQ,CAAC,aAAa,gBAAgB,CAAE;AAAA,QACpE;AAAA,MACF,CAAC;AAAA,IACL;AAAA,EACF,CAAC;AACH;;;AC1DO,IAAM,sBAAsB,MAAM;","names":["Effect","Ref","Effect","Ref","Effect","Ref","Effect","Ref","Effect","Effect"]}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@reactive-agents/identity",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsup --config ../../tsup.config.base.ts",
9
+ "typecheck": "tsc --noEmit",
10
+ "test": "bun test",
11
+ "test:watch": "bun test --watch"
12
+ },
13
+ "dependencies": {
14
+ "effect": "^3.10.0",
15
+ "@reactive-agents/core": "0.1.0",
16
+ "@noble/ed25519": "^2.0.0"
17
+ },
18
+ "devDependencies": {
19
+ "typescript": "^5.7.0",
20
+ "bun-types": "latest"
21
+ },
22
+ "license": "MIT",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/tylerjrbuell/reactive-agents-ts.git",
26
+ "directory": "packages/identity"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "files": [
32
+ "dist",
33
+ "README.md",
34
+ "LICENSE"
35
+ ],
36
+ "exports": {
37
+ ".": {
38
+ "types": "./dist/index.d.ts",
39
+ "import": "./dist/index.js",
40
+ "default": "./dist/index.js"
41
+ }
42
+ },
43
+ "description": "Identity and access control for Reactive Agents — agent certificates and RBAC",
44
+ "homepage": "https://tylerjrbuell.github.io/reactive-agents-ts/",
45
+ "bugs": {
46
+ "url": "https://github.com/tylerjrbuell/reactive-agents-ts/issues"
47
+ }
48
+ }