agents-chain 0.0.2 → 0.0.3
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/README.md +238 -52
- package/dist/app/app-wrapper.d.ts +43 -0
- package/dist/app/app-wrapper.d.ts.map +1 -0
- package/dist/app/app-wrapper.js +122 -0
- package/dist/app/app-wrapper.js.map +1 -0
- package/dist/app/capability-registry.d.ts +31 -0
- package/dist/app/capability-registry.d.ts.map +1 -0
- package/dist/app/capability-registry.js +65 -0
- package/dist/app/capability-registry.js.map +1 -0
- package/dist/audit/audit-exporter.d.ts +82 -0
- package/dist/audit/audit-exporter.d.ts.map +1 -0
- package/dist/audit/audit-exporter.js +94 -0
- package/dist/audit/audit-exporter.js.map +1 -0
- package/dist/audit/audit-log.d.ts +10 -0
- package/dist/audit/audit-log.d.ts.map +1 -1
- package/dist/audit/audit-log.js +18 -0
- package/dist/audit/audit-log.js.map +1 -1
- package/dist/auth/constraints.d.ts +19 -0
- package/dist/auth/constraints.d.ts.map +1 -0
- package/dist/auth/constraints.js +85 -0
- package/dist/auth/constraints.js.map +1 -0
- package/dist/auth/token-verifier.d.ts +26 -2
- package/dist/auth/token-verifier.d.ts.map +1 -1
- package/dist/auth/token-verifier.js +47 -9
- package/dist/auth/token-verifier.js.map +1 -1
- package/dist/chain.d.ts +59 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +115 -0
- package/dist/chain.js.map +1 -1
- package/dist/crypto/ed25519.d.ts.map +1 -1
- package/dist/crypto/ed25519.js +2 -1
- package/dist/crypto/ed25519.js.map +1 -1
- package/dist/crypto/utils.d.ts +1 -1
- package/dist/crypto/utils.d.ts.map +1 -1
- package/dist/host/host-identity.d.ts +66 -0
- package/dist/host/host-identity.d.ts.map +1 -0
- package/dist/host/host-identity.js +109 -0
- package/dist/host/host-identity.js.map +1 -0
- package/dist/index.d.ts +14 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/memory/jti-cache.d.ts +31 -4
- package/dist/memory/jti-cache.d.ts.map +1 -1
- package/dist/memory/jti-cache.js +40 -13
- package/dist/memory/jti-cache.js.map +1 -1
- package/dist/types/capabilities.d.ts +64 -0
- package/dist/types/capabilities.d.ts.map +1 -0
- package/dist/types/capabilities.js +9 -0
- package/dist/types/capabilities.js.map +1 -0
- package/dist/types/chain.d.ts +51 -1
- package/dist/types/chain.d.ts.map +1 -1
- package/dist/types/protocol.d.ts +61 -0
- package/dist/types/protocol.d.ts.map +1 -0
- package/dist/types/protocol.js +10 -0
- package/dist/types/protocol.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability types — define what an app exposes and how agents interact with it.
|
|
3
|
+
*
|
|
4
|
+
* A Capability is a named, schema-described, executable function.
|
|
5
|
+
* When agents-chain wraps an app, every method call is mapped to a Capability
|
|
6
|
+
* and gated by the agent's CapabilityGrants.
|
|
7
|
+
*/
|
|
8
|
+
export type JsonSchemaType = "object" | "array" | "string" | "number" | "boolean" | "null";
|
|
9
|
+
export type JsonSchemaObject = {
|
|
10
|
+
type?: JsonSchemaType | JsonSchemaType[];
|
|
11
|
+
properties?: Record<string, JsonSchemaObject>;
|
|
12
|
+
items?: JsonSchemaObject;
|
|
13
|
+
required?: string[];
|
|
14
|
+
description?: string;
|
|
15
|
+
enum?: unknown[];
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
};
|
|
18
|
+
export type ConstraintPrimitive = string | number | boolean;
|
|
19
|
+
export type ConstraintOperator = {
|
|
20
|
+
max?: number;
|
|
21
|
+
min?: number;
|
|
22
|
+
in?: ConstraintPrimitive[];
|
|
23
|
+
not_in?: ConstraintPrimitive[];
|
|
24
|
+
};
|
|
25
|
+
export type ConstraintValue = ConstraintPrimitive | ConstraintOperator;
|
|
26
|
+
/**
|
|
27
|
+
* Per-capability argument constraints.
|
|
28
|
+
* Key = argument field name.
|
|
29
|
+
* Value = primitive (exact match) or operator (range/whitelist/blacklist).
|
|
30
|
+
*
|
|
31
|
+
* Example:
|
|
32
|
+
* { amount: { max: 1000 }, currency: { in: ["USD", "EUR"] } }
|
|
33
|
+
*/
|
|
34
|
+
export type GrantConstraints = Record<string, ConstraintValue>;
|
|
35
|
+
/**
|
|
36
|
+
* Context passed to every Capability.execute() call.
|
|
37
|
+
* Tells the capability who is calling and what they are allowed to do.
|
|
38
|
+
*/
|
|
39
|
+
export type AgentContext = {
|
|
40
|
+
agentId: string;
|
|
41
|
+
hostId: string;
|
|
42
|
+
permissions: string[];
|
|
43
|
+
metadata?: Record<string, string[]>;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* A named, schema-described, executable function exposed by an app.
|
|
47
|
+
*
|
|
48
|
+
* Usage:
|
|
49
|
+
* const cap: Capability<{ userId: string }, { balance: number }> = {
|
|
50
|
+
* name: "get_balance",
|
|
51
|
+
* description: "Get the current account balance for a user",
|
|
52
|
+
* inputSchema: { type: "object", required: ["userId"], properties: { userId: { type: "string" } } },
|
|
53
|
+
* outputSchema: { type: "object", properties: { balance: { type: "number" } } },
|
|
54
|
+
* execute: async ({ userId }, ctx) => accountService.getBalance(userId),
|
|
55
|
+
* };
|
|
56
|
+
*/
|
|
57
|
+
export type Capability<TInput = unknown, TOutput = unknown> = {
|
|
58
|
+
name: string;
|
|
59
|
+
description: string;
|
|
60
|
+
inputSchema: JsonSchemaObject;
|
|
61
|
+
outputSchema: JsonSchemaObject;
|
|
62
|
+
execute: (params: TInput, context: AgentContext) => Promise<TOutput>;
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../src/types/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,QAA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B,WAAW,EAAE,gBAAgB,CAAC;IAC9B,YAAY,EAAE,gBAAgB,CAAC;IAC/B,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACxE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability types — define what an app exposes and how agents interact with it.
|
|
3
|
+
*
|
|
4
|
+
* A Capability is a named, schema-described, executable function.
|
|
5
|
+
* When agents-chain wraps an app, every method call is mapped to a Capability
|
|
6
|
+
* and gated by the agent's CapabilityGrants.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=capabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../src/types/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
package/dist/types/chain.d.ts
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AuditExporter } from "../audit/audit-exporter.js";
|
|
2
|
+
import type { VerifierConfig } from "../auth/token-verifier.js";
|
|
3
|
+
import type { HostConfig } from "../host/host-identity.js";
|
|
4
|
+
import type { JtiPersistenceAdapter } from "../memory/jti-cache.js";
|
|
2
5
|
import type { AuditEntry } from "./audit.js";
|
|
6
|
+
import type { Capability } from "./capabilities.js";
|
|
7
|
+
import type { AgentConfig } from "./identity.js";
|
|
3
8
|
export type { AgentConfig };
|
|
9
|
+
export type AppChainConfig = {
|
|
10
|
+
/**
|
|
11
|
+
* Short name for this app, e.g. "billing-service", "github".
|
|
12
|
+
* Used in well-known config as provider_name.
|
|
13
|
+
*/
|
|
14
|
+
providerName: string;
|
|
15
|
+
/**
|
|
16
|
+
* The base URL of this server, e.g. "https://billing.mycompany.com".
|
|
17
|
+
* Used in well-known config as issuer and in Host JWT aud claim.
|
|
18
|
+
*/
|
|
19
|
+
issuer: string;
|
|
20
|
+
/**
|
|
21
|
+
* The capabilities this app exposes.
|
|
22
|
+
* Registered in the CapabilityRegistry at chain creation.
|
|
23
|
+
*/
|
|
24
|
+
capabilities: Capability[];
|
|
25
|
+
/**
|
|
26
|
+
* Optional AES-256-GCM encryption key (64 hex chars = 32 bytes).
|
|
27
|
+
* If omitted, a random key is generated per session.
|
|
28
|
+
*/
|
|
29
|
+
encryptionKey?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Optional Host identity config. If provided, a HostIdentity is created
|
|
32
|
+
* with this config so the chain can sign Host JWTs.
|
|
33
|
+
* Defaults to { name: providerName, issuerUrl: issuer }.
|
|
34
|
+
*/
|
|
35
|
+
host?: Partial<HostConfig>;
|
|
36
|
+
/**
|
|
37
|
+
* Optional JTI persistence adapter (e.g. Redis).
|
|
38
|
+
* If omitted, JTI cache is in-memory (resets on process restart).
|
|
39
|
+
*/
|
|
40
|
+
jtiAdapter?: JtiPersistenceAdapter;
|
|
41
|
+
/**
|
|
42
|
+
* Optional audit exporter for auto-draining entries on drain().
|
|
43
|
+
* Default: ConsoleAuditExporter (logs to stdout).
|
|
44
|
+
*/
|
|
45
|
+
auditExporter?: AuditExporter;
|
|
46
|
+
/**
|
|
47
|
+
* Optional external grant resolver.
|
|
48
|
+
* If provided, grants are resolved from this function instead of
|
|
49
|
+
* the grants passed to chain.wrap().
|
|
50
|
+
* Useful for looking up grants from your DB/Redis.
|
|
51
|
+
*/
|
|
52
|
+
grantResolver?: VerifierConfig["grantResolver"];
|
|
53
|
+
};
|
|
4
54
|
export type ChainStats = {
|
|
5
55
|
agentId: string;
|
|
6
56
|
agentName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../src/types/chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../src/types/chain.ts"],"names":[],"mappings":"AAAA,OAA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AM,CAAC;IAChB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACtB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protocol types — the wire format shared between agents-chain and any
|
|
3
|
+
* compliant agent-auth server.
|
|
4
|
+
*
|
|
5
|
+
* These mirror the types in agent-auth/src/types/protocol.ts so that
|
|
6
|
+
* agents-chain can participate in the same Host → Agent → CapabilityGrant
|
|
7
|
+
* protocol without coupling to the server implementation.
|
|
8
|
+
*/
|
|
9
|
+
import type { GrantConstraints } from "./capabilities.js";
|
|
10
|
+
/**
|
|
11
|
+
* Claims carried in a host+jwt — signed by the Host's private key.
|
|
12
|
+
* Used for management operations: registering agents, revoking, rotating keys.
|
|
13
|
+
*/
|
|
14
|
+
export type HostJwtClaims = {
|
|
15
|
+
iss: string;
|
|
16
|
+
aud: string;
|
|
17
|
+
iat: number;
|
|
18
|
+
exp: number;
|
|
19
|
+
jti: string;
|
|
20
|
+
host_public_key?: JsonWebKey;
|
|
21
|
+
agent_public_key?: JsonWebKey;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Claims carried in an agent+jwt — signed by the Agent's private key.
|
|
25
|
+
* Used for capability execution.
|
|
26
|
+
*/
|
|
27
|
+
export type AgentJwtClaims = {
|
|
28
|
+
iss: string;
|
|
29
|
+
sub: string;
|
|
30
|
+
aud: string;
|
|
31
|
+
iat: number;
|
|
32
|
+
exp: number;
|
|
33
|
+
jti: string;
|
|
34
|
+
capabilities?: string[];
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* The response shape for GET /.well-known/agent-configuration.
|
|
38
|
+
* Tells agents what capabilities are available and where the endpoints are.
|
|
39
|
+
*/
|
|
40
|
+
export type AgentConfiguration = {
|
|
41
|
+
version: string;
|
|
42
|
+
provider_name: string;
|
|
43
|
+
issuer: string;
|
|
44
|
+
algorithms: string[];
|
|
45
|
+
modes: string[];
|
|
46
|
+
approval_methods: string[];
|
|
47
|
+
endpoints: Record<string, string>;
|
|
48
|
+
default_capabilities: string[];
|
|
49
|
+
};
|
|
50
|
+
export type GrantStatus = "active" | "pending" | "denied";
|
|
51
|
+
/**
|
|
52
|
+
* A resolved capability grant — what an agent is allowed (or not) to do.
|
|
53
|
+
* Returned by a grantResolver or held in-memory after registration.
|
|
54
|
+
*/
|
|
55
|
+
export type ResolvedGrant = {
|
|
56
|
+
capability: string;
|
|
57
|
+
status: GrantStatus;
|
|
58
|
+
constraints?: GrantConstraints;
|
|
59
|
+
expiresAt?: number;
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/types/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAI1D;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,eAAe,CAAC,EAAE,UAAU,CAAC;IAC7B,gBAAgB,CAAC,EAAE,UAAU,CAAC;CACjC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B,CAAC;AAIF;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAClC,CAAC;AAIF,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE1D;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,WAAW,CAAC;IACpB,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protocol types — the wire format shared between agents-chain and any
|
|
3
|
+
* compliant agent-auth server.
|
|
4
|
+
*
|
|
5
|
+
* These mirror the types in agent-auth/src/types/protocol.ts so that
|
|
6
|
+
* agents-chain can participate in the same Host → Agent → CapabilityGrant
|
|
7
|
+
* protocol without coupling to the server implementation.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/types/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|