@agentkarma/sdk 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.
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Structured errors thrown by the AgentKarma SDK.
3
+ *
4
+ * All errors derive from `AgentKarmaError`, so partner code can write a single
5
+ * `catch (err: unknown) { if (err instanceof AgentKarmaError) … }` block and
6
+ * narrow on subclass when finer handling is needed.
7
+ */
8
+ /** Base class for every error thrown by the SDK. */
9
+ export declare class AgentKarmaError extends Error {
10
+ /** HTTP status code if the error originated from a response. */
11
+ readonly status?: number;
12
+ /** Raw response body when available — useful for debugging unfamiliar errors. */
13
+ readonly response?: unknown;
14
+ /** Underlying cause (network error, parse error, etc.). */
15
+ readonly cause?: unknown;
16
+ constructor(message: string, opts?: {
17
+ status?: number;
18
+ response?: unknown;
19
+ cause?: unknown;
20
+ });
21
+ }
22
+ /** Caller passed an argument that failed local validation before the request was sent. */
23
+ export declare class AgentKarmaValidationError extends AgentKarmaError {
24
+ constructor(message: string);
25
+ }
26
+ /** Server returned HTTP 404 — the requested wallet, agent, or resource doesn't exist. */
27
+ export declare class AgentKarmaNotFoundError extends AgentKarmaError {
28
+ constructor(message: string, opts?: {
29
+ response?: unknown;
30
+ });
31
+ }
32
+ /** Server returned HTTP 429 — caller is being rate-limited. */
33
+ export declare class AgentKarmaRateLimitError extends AgentKarmaError {
34
+ /** Seconds until the limit resets, when the server provides Retry-After. */
35
+ readonly retryAfter?: number;
36
+ constructor(message: string, opts?: {
37
+ response?: unknown;
38
+ retryAfter?: number;
39
+ });
40
+ }
41
+ /** Request did not complete within the configured timeout. */
42
+ export declare class AgentKarmaTimeoutError extends AgentKarmaError {
43
+ readonly timeoutMs: number;
44
+ constructor(timeoutMs: number);
45
+ }
46
+ /** fetch() threw before getting a response — DNS failure, connection refused, offline, etc. */
47
+ export declare class AgentKarmaNetworkError extends AgentKarmaError {
48
+ constructor(message: string, cause?: unknown);
49
+ }
50
+ /** Server returned HTTP 2xx but the body didn't match the expected shape. */
51
+ export declare class AgentKarmaMalformedResponseError extends AgentKarmaError {
52
+ constructor(message: string, opts?: {
53
+ response?: unknown;
54
+ cause?: unknown;
55
+ });
56
+ }
57
+ /** Server returned a non-2xx status that doesn't fit a more specific category. */
58
+ export declare class AgentKarmaServerError extends AgentKarmaError {
59
+ constructor(message: string, opts: {
60
+ status: number;
61
+ response?: unknown;
62
+ });
63
+ }
64
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oDAAoD;AACpD,qBAAa,eAAgB,SAAQ,KAAK;IACxC,gEAAgE;IAChE,SAAgB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChC,iFAAiF;IACjF,SAAgB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnC,2DAA2D;IAC3D,SAAyB,KAAK,CAAC,EAAE,OAAO,CAAC;gBAE7B,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO;CAOjG;AAED,0FAA0F;AAC1F,qBAAa,yBAA0B,SAAQ,eAAe;gBAChD,OAAO,EAAE,MAAM;CAI5B;AAED,yFAAyF;AACzF,qBAAa,uBAAwB,SAAQ,eAAe;gBAC9C,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAO;CAI/D;AAED,+DAA+D;AAC/D,qBAAa,wBAAyB,SAAQ,eAAe;IAC3D,4EAA4E;IAC5E,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;gBAExB,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAO;CAKpF;AAED,8DAA8D;AAC9D,qBAAa,sBAAuB,SAAQ,eAAe;IACzD,SAAgB,SAAS,EAAE,MAAM,CAAC;gBACtB,SAAS,EAAE,MAAM;CAK9B;AAED,+FAA+F;AAC/F,qBAAa,sBAAuB,SAAQ,eAAe;gBAC7C,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAI7C;AAED,6EAA6E;AAC7E,qBAAa,gCAAiC,SAAQ,eAAe;gBACvD,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO;CAIhF;AAED,kFAAkF;AAClF,qBAAa,qBAAsB,SAAQ,eAAe;gBAC5C,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE;CAI1E"}
package/dist/errors.js ADDED
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Structured errors thrown by the AgentKarma SDK.
3
+ *
4
+ * All errors derive from `AgentKarmaError`, so partner code can write a single
5
+ * `catch (err: unknown) { if (err instanceof AgentKarmaError) … }` block and
6
+ * narrow on subclass when finer handling is needed.
7
+ */
8
+ /** Base class for every error thrown by the SDK. */
9
+ export class AgentKarmaError extends Error {
10
+ /** HTTP status code if the error originated from a response. */
11
+ status;
12
+ /** Raw response body when available — useful for debugging unfamiliar errors. */
13
+ response;
14
+ /** Underlying cause (network error, parse error, etc.). */
15
+ cause;
16
+ constructor(message, opts = {}) {
17
+ super(message);
18
+ this.name = 'AgentKarmaError';
19
+ this.status = opts.status;
20
+ this.response = opts.response;
21
+ this.cause = opts.cause;
22
+ }
23
+ }
24
+ /** Caller passed an argument that failed local validation before the request was sent. */
25
+ export class AgentKarmaValidationError extends AgentKarmaError {
26
+ constructor(message) {
27
+ super(message);
28
+ this.name = 'AgentKarmaValidationError';
29
+ }
30
+ }
31
+ /** Server returned HTTP 404 — the requested wallet, agent, or resource doesn't exist. */
32
+ export class AgentKarmaNotFoundError extends AgentKarmaError {
33
+ constructor(message, opts = {}) {
34
+ super(message, { status: 404, response: opts.response });
35
+ this.name = 'AgentKarmaNotFoundError';
36
+ }
37
+ }
38
+ /** Server returned HTTP 429 — caller is being rate-limited. */
39
+ export class AgentKarmaRateLimitError extends AgentKarmaError {
40
+ /** Seconds until the limit resets, when the server provides Retry-After. */
41
+ retryAfter;
42
+ constructor(message, opts = {}) {
43
+ super(message, { status: 429, response: opts.response });
44
+ this.name = 'AgentKarmaRateLimitError';
45
+ this.retryAfter = opts.retryAfter;
46
+ }
47
+ }
48
+ /** Request did not complete within the configured timeout. */
49
+ export class AgentKarmaTimeoutError extends AgentKarmaError {
50
+ timeoutMs;
51
+ constructor(timeoutMs) {
52
+ super(`Request timed out after ${timeoutMs}ms`);
53
+ this.name = 'AgentKarmaTimeoutError';
54
+ this.timeoutMs = timeoutMs;
55
+ }
56
+ }
57
+ /** fetch() threw before getting a response — DNS failure, connection refused, offline, etc. */
58
+ export class AgentKarmaNetworkError extends AgentKarmaError {
59
+ constructor(message, cause) {
60
+ super(message, { cause });
61
+ this.name = 'AgentKarmaNetworkError';
62
+ }
63
+ }
64
+ /** Server returned HTTP 2xx but the body didn't match the expected shape. */
65
+ export class AgentKarmaMalformedResponseError extends AgentKarmaError {
66
+ constructor(message, opts = {}) {
67
+ super(message, { response: opts.response, cause: opts.cause });
68
+ this.name = 'AgentKarmaMalformedResponseError';
69
+ }
70
+ }
71
+ /** Server returned a non-2xx status that doesn't fit a more specific category. */
72
+ export class AgentKarmaServerError extends AgentKarmaError {
73
+ constructor(message, opts) {
74
+ super(message, { status: opts.status, response: opts.response });
75
+ this.name = 'AgentKarmaServerError';
76
+ }
77
+ }
78
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/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,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IACpC,CAAC;CACF;AAED,8DAA8D;AAC9D,MAAM,OAAO,sBAAuB,SAAQ,eAAe;IACzC,SAAS,CAAS;IAClC,YAAY,SAAiB;QAC3B,KAAK,CAAC,2BAA2B,SAAS,IAAI,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF;AAED,+FAA+F;AAC/F,MAAM,OAAO,sBAAuB,SAAQ,eAAe;IACzD,YAAY,OAAe,EAAE,KAAe;QAC1C,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED,6EAA6E;AAC7E,MAAM,OAAO,gCAAiC,SAAQ,eAAe;IACnE,YAAY,OAAe,EAAE,OAAgD,EAAE;QAC7E,KAAK,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAC/D,IAAI,CAAC,IAAI,GAAG,kCAAkC,CAAC;IACjD,CAAC;CACF;AAED,kFAAkF;AAClF,MAAM,OAAO,qBAAsB,SAAQ,eAAe;IACxD,YAAY,OAAe,EAAE,IAA4C;QACvE,KAAK,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjE,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Wallet-agnostic helpers for building consumer feedback messages.
3
+ *
4
+ * The server expects an Ed25519 signature (Solana-flavored) over a specific
5
+ * message string. This module produces the message; the SDK never asks for a
6
+ * private key. The caller signs externally and passes the signature to
7
+ * `client.submitFeedback()`.
8
+ *
9
+ * The message format is fixed by the server (see
10
+ * `web/src/app/api/feedback/route.ts`):
11
+ *
12
+ * AgentKarma: Feedback {rating} for {txSignature} at {timestamp}
13
+ *
14
+ * `{timestamp}` is Date.now() in milliseconds. The server enforces a 5-minute
15
+ * freshness window — don't pre-build messages and use them later.
16
+ */
17
+ import type { FeedbackRating } from './types.js';
18
+ export interface BuildFeedbackMessageInput {
19
+ rating: FeedbackRating;
20
+ txSignature: string;
21
+ /** Defaults to Date.now() at call time. Server allows ±5 minutes. */
22
+ timestamp?: number;
23
+ }
24
+ export interface BuiltFeedbackMessage {
25
+ /** The exact string to sign with the consumer wallet. */
26
+ message: string;
27
+ /** Timestamp embedded in the message — pass through to `submitFeedback()`. */
28
+ timestamp: number;
29
+ }
30
+ export declare function buildFeedbackMessage(input: BuildFeedbackMessageInput): BuiltFeedbackMessage;
31
+ //# sourceMappingURL=feedback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feedback.d.ts","sourceRoot":"","sources":["../src/feedback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,cAAc,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,yDAAyD;IACzD,OAAO,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,oBAAoB,CAgB3F"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Wallet-agnostic helpers for building consumer feedback messages.
3
+ *
4
+ * The server expects an Ed25519 signature (Solana-flavored) over a specific
5
+ * message string. This module produces the message; the SDK never asks for a
6
+ * private key. The caller signs externally and passes the signature to
7
+ * `client.submitFeedback()`.
8
+ *
9
+ * The message format is fixed by the server (see
10
+ * `web/src/app/api/feedback/route.ts`):
11
+ *
12
+ * AgentKarma: Feedback {rating} for {txSignature} at {timestamp}
13
+ *
14
+ * `{timestamp}` is Date.now() in milliseconds. The server enforces a 5-minute
15
+ * freshness window — don't pre-build messages and use them later.
16
+ */
17
+ import { AgentKarmaValidationError } from './errors.js';
18
+ export function buildFeedbackMessage(input) {
19
+ if (!input || typeof input !== 'object') {
20
+ throw new AgentKarmaValidationError('input is required');
21
+ }
22
+ if (input.rating !== 'delivered' && input.rating !== 'failed') {
23
+ throw new AgentKarmaValidationError(`rating must be 'delivered' or 'failed'`);
24
+ }
25
+ if (!input.txSignature || typeof input.txSignature !== 'string') {
26
+ throw new AgentKarmaValidationError('txSignature must be a non-empty string');
27
+ }
28
+ const timestamp = input.timestamp ?? Date.now();
29
+ if (!Number.isInteger(timestamp) || timestamp <= 0) {
30
+ throw new AgentKarmaValidationError('timestamp must be a positive integer (ms)');
31
+ }
32
+ const message = `AgentKarma: Feedback ${input.rating} for ${input.txSignature} at ${timestamp}`;
33
+ return { message, timestamp };
34
+ }
35
+ //# sourceMappingURL=feedback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feedback.js","sourceRoot":"","sources":["../src/feedback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAiBxD,MAAM,UAAU,oBAAoB,CAAC,KAAgC;IACnE,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,MAAM,IAAI,yBAAyB,CAAC,mBAAmB,CAAC,CAAC;IAC3D,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,KAAK,WAAW,IAAI,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC9D,MAAM,IAAI,yBAAyB,CAAC,wCAAwC,CAAC,CAAC;IAChF,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,OAAO,KAAK,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;QAChE,MAAM,IAAI,yBAAyB,CAAC,wCAAwC,CAAC,CAAC;IAChF,CAAC;IACD,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;IAChD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;QACnD,MAAM,IAAI,yBAAyB,CAAC,2CAA2C,CAAC,CAAC;IACnF,CAAC;IACD,MAAM,OAAO,GAAG,wBAAwB,KAAK,CAAC,MAAM,QAAQ,KAAK,CAAC,WAAW,OAAO,SAAS,EAAE,CAAC;IAChG,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAChC,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @agentkarma/sdk — public entry point.
3
+ *
4
+ * AgentKarma is the reputation layer for autonomous on-chain agents.
5
+ * This SDK lets you query Provider Karma and Consumer Karma, look up
6
+ * ERC-8004 agents on Celo, and gate execution on a local trust policy.
7
+ *
8
+ * Non-routing: this SDK never proxies, signs, or executes transactions on
9
+ * your behalf. It reads from agentkarma.io and answers trust-check questions
10
+ * locally.
11
+ *
12
+ * Quick start:
13
+ *
14
+ * import { createAgentKarmaClient, evaluateTrust } from '@agentkarma/sdk';
15
+ * const ak = createAgentKarmaClient();
16
+ * const snap = await ak.getKarma('Agent5VR…wallet…');
17
+ * const decision = evaluateTrust(snap, { minScore: 60, requireReceiptBacked: true });
18
+ * if (!decision.allowed) console.warn('reject:', decision.reasons);
19
+ */
20
+ export { createAgentKarmaClient } from './client.js';
21
+ export type { AgentKarmaClient } from './client.js';
22
+ export { AgentKarmaError, AgentKarmaValidationError, AgentKarmaNotFoundError, AgentKarmaRateLimitError, AgentKarmaTimeoutError, AgentKarmaNetworkError, AgentKarmaMalformedResponseError, AgentKarmaServerError, } from './errors.js';
23
+ export { evaluateTrust } from './policy.js';
24
+ export type { TrustPolicy, TrustDecision, TrustObserved } from './policy.js';
25
+ export { buildFeedbackMessage } from './feedback.js';
26
+ export type { BuildFeedbackMessageInput, BuiltFeedbackMessage } from './feedback.js';
27
+ export type { Chain, KarmaFace, ConfidenceBadge, TrustTier, AutonomyLabel, SignalTier, KarmaSnapshot, KarmaIdentity, KarmaFaceData, AutonomyData, SuccessionStatus, SuccessionHeir, SuccessionView, SuccessionResponse, BondStatus, BondView, BondBlock, BondResponse, SuretyLabel, SuretyView, CeloAgentSnapshot, CeloAgentRegistration, CeloAgentReputation, CeloFeedbackRecord, SearchResult, SearchResponse, AgentHistoryResponse, AgentHistoryTransaction, FeedbackSummary, FeedbackRating, FeedbackSubmission, FeedbackSubmissionResponse, ClientConfig, RequestOptions, } from './types.js';
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EACtB,gCAAgC,EAChC,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,YAAY,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErF,YAAY,EAEV,KAAK,EACL,SAAS,EACT,eAAe,EACf,SAAS,EACT,aAAa,EACb,UAAU,EAEV,aAAa,EACb,aAAa,EACb,aAAa,EACb,YAAY,EAEZ,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,WAAW,EACX,UAAU,EAEV,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAElB,YAAY,EACZ,cAAc,EAEd,oBAAoB,EACpB,uBAAuB,EAEvB,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,0BAA0B,EAE1B,YAAY,EACZ,cAAc,GACf,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @agentkarma/sdk — public entry point.
3
+ *
4
+ * AgentKarma is the reputation layer for autonomous on-chain agents.
5
+ * This SDK lets you query Provider Karma and Consumer Karma, look up
6
+ * ERC-8004 agents on Celo, and gate execution on a local trust policy.
7
+ *
8
+ * Non-routing: this SDK never proxies, signs, or executes transactions on
9
+ * your behalf. It reads from agentkarma.io and answers trust-check questions
10
+ * locally.
11
+ *
12
+ * Quick start:
13
+ *
14
+ * import { createAgentKarmaClient, evaluateTrust } from '@agentkarma/sdk';
15
+ * const ak = createAgentKarmaClient();
16
+ * const snap = await ak.getKarma('Agent5VR…wallet…');
17
+ * const decision = evaluateTrust(snap, { minScore: 60, requireReceiptBacked: true });
18
+ * if (!decision.allowed) console.warn('reject:', decision.reasons);
19
+ */
20
+ export { createAgentKarmaClient } from './client.js';
21
+ export { AgentKarmaError, AgentKarmaValidationError, AgentKarmaNotFoundError, AgentKarmaRateLimitError, AgentKarmaTimeoutError, AgentKarmaNetworkError, AgentKarmaMalformedResponseError, AgentKarmaServerError, } from './errors.js';
22
+ export { evaluateTrust } from './policy.js';
23
+ export { buildFeedbackMessage } from './feedback.js';
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAGrD,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EACtB,gCAAgC,EAChC,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Local, explainable trust policy evaluation.
3
+ *
4
+ * `evaluateTrust(snapshot, policy)` is the canonical `check_trust_before_execute`
5
+ * helper. Given a karma snapshot from `client.getKarma(wallet)` and a policy
6
+ * config, return whether the trust check passes, the human-readable reasons
7
+ * for the decision, and exactly what was observed on the snapshot.
8
+ *
9
+ * This function NEVER routes, executes, signs, or persists anything. It is a
10
+ * pure function over data. Calling it is free — no network, no side effects.
11
+ */
12
+ import type { AutonomyLabel, ConfidenceBadge, KarmaFace, KarmaSnapshot, SignalTier, SuccessionStatus } from './types.js';
13
+ export interface TrustPolicy {
14
+ /** Which face to evaluate. Defaults to 'provider'. */
15
+ face?: KarmaFace;
16
+ /** Reject when the chosen face's score is below this value (0-100). */
17
+ minScore?: number;
18
+ /** Accept only these confidence badges on the chosen face. Empty/omitted = accept all. */
19
+ acceptedConfidenceBadges?: ConfidenceBadge[];
20
+ /** Require at least this many on-chain transactions observed. */
21
+ minTxCount?: number;
22
+ /** Require non-null signal in each of these tiers (per the chosen face's tierAggregates). */
23
+ requireTiers?: SignalTier[];
24
+ /** Require at least one Tier-1 receipt-backed signal somewhere on the chosen face. */
25
+ requireReceiptBacked?: boolean;
26
+ /** Reject when the autonomy label matches one of these. (e.g. reject 'agent-like' for human-only flows.) */
27
+ rejectAutonomyLabels?: AutonomyLabel[];
28
+ /** Reject when the autonomy score is below this value. null autonomy is treated as failing this check. */
29
+ minAutonomyScore?: number;
30
+ /**
31
+ * Reject when the wallet has never been observed active. Defaults to false —
32
+ * a wallet with no recorded activity isn't automatically untrustworthy; the
33
+ * face's score and confidence badge already encode that. Flip on when you
34
+ * specifically want a "must have shown up before" gate.
35
+ */
36
+ requireSeen?: boolean;
37
+ /**
38
+ * Require a live succession plan. Passes only when the snapshot carries a
39
+ * succession block whose derived status is `declared` or `live`. A missing
40
+ * succession block fails this gate (no plan = not live). OBSERVE-ONLY: this
41
+ * reads AK's recorded liveness; AK never receives a real heartbeat.
42
+ */
43
+ requireLiveSuccession?: boolean;
44
+ /**
45
+ * Reject when the succession plan has lapsed or is lapsing — a strong signal
46
+ * the agent may be abandoned. A missing succession block does NOT trip this
47
+ * (no plan ≠ lapsed); use `requireLiveSuccession` to demand a plan.
48
+ */
49
+ rejectLapsed?: boolean;
50
+ /**
51
+ * Require at least one currently-active (open) bond on the agent. Borrowed
52
+ * capital lifts confidence, NOT the trust ceiling — this gate is about
53
+ * presence of skin-in-the-game, evaluated independently of score.
54
+ */
55
+ requireBonded?: boolean;
56
+ /**
57
+ * Require the total USDC currently bonded (open bonds) to be at least this.
58
+ * Demo bonds are EXCLUDED from this total — borrowed-on-paper capital must
59
+ * not satisfy a real-money gate.
60
+ */
61
+ minBondedUSDC?: number;
62
+ /**
63
+ * Reject when the agent has a recent bond failure (`resolved_failure`). A
64
+ * blown bond is a real negative delivery signal. Demo bonds are ignored.
65
+ */
66
+ rejectRecentBondFailure?: boolean;
67
+ }
68
+ export interface TrustObserved {
69
+ face: KarmaFace;
70
+ providerScore: number | null;
71
+ consumerScore: number | null;
72
+ confidenceBadge: ConfidenceBadge | null;
73
+ txCount: number;
74
+ /** Per-tier presence (`true` = signal present for the chosen face). */
75
+ tiers: Record<`tier${SignalTier}`, boolean>;
76
+ autonomyScore: number | null;
77
+ autonomyLabel: AutonomyLabel | null;
78
+ lastActive: string | null;
79
+ /** Derived succession status, or null when no plan was declared. */
80
+ successionStatus: SuccessionStatus | null;
81
+ /** Whether the agent has at least one currently-active (open) bond. */
82
+ bonded: boolean;
83
+ /** Total USDC across open bonds, EXCLUDING demo bonds. */
84
+ activeBondedUsdc: number;
85
+ /** Whether the agent has a resolved-failure bond (demo bonds excluded). */
86
+ hasRecentBondFailure: boolean;
87
+ }
88
+ export interface TrustDecision {
89
+ /** Final allow/deny. False ⇒ at least one reason is populated. */
90
+ allowed: boolean;
91
+ /**
92
+ * Human-readable rejection reasons. Empty array when `allowed === true`.
93
+ * Each reason references the policy field it tripped, so callers can
94
+ * surface them to operators or log them.
95
+ */
96
+ reasons: string[];
97
+ /** Snapshot of what was observed, for logging / audit. */
98
+ observed: TrustObserved;
99
+ }
100
+ /**
101
+ * Evaluate a karma snapshot against a trust policy. Never throws on policy
102
+ * mismatch — only throws on malformed inputs.
103
+ */
104
+ export declare function evaluateTrust(snapshot: KarmaSnapshot, policy?: TrustPolicy): TrustDecision;
105
+ //# sourceMappingURL=policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,SAAS,EACT,aAAa,EACb,UAAU,EACV,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAWpB,MAAM,WAAW,WAAW;IAC1B,sDAAsD;IACtD,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0FAA0F;IAC1F,wBAAwB,CAAC,EAAE,eAAe,EAAE,CAAC;IAC7C,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6FAA6F;IAC7F,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;IAC5B,sFAAsF;IACtF,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,4GAA4G;IAC5G,oBAAoB,CAAC,EA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,aAAa,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,GAAE,WAAgB,GAAG,aAAa,CAmJ9F"}
package/dist/policy.js ADDED
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Local, explainable trust policy evaluation.
3
+ *
4
+ * `evaluateTrust(snapshot, policy)` is the canonical `check_trust_before_execute`
5
+ * helper. Given a karma snapshot from `client.getKarma(wallet)` and a policy
6
+ * config, return whether the trust check passes, the human-readable reasons
7
+ * for the decision, and exactly what was observed on the snapshot.
8
+ *
9
+ * This function NEVER routes, executes, signs, or persists anything. It is a
10
+ * pure function over data. Calling it is free — no network, no side effects.
11
+ */
12
+ import { AgentKarmaValidationError } from './errors.js';
13
+ /**
14
+ * Succession statuses that mean "the agent is still answering". `declared`
15
+ * counts as live: the will exists but no lapse has been observed yet.
16
+ */
17
+ const LIVE_SUCCESSION_STATUSES = new Set([
18
+ 'declared',
19
+ 'live',
20
+ ]);
21
+ /**
22
+ * Evaluate a karma snapshot against a trust policy. Never throws on policy
23
+ * mismatch — only throws on malformed inputs.
24
+ */
25
+ export function evaluateTrust(snapshot, policy = {}) {
26
+ if (!snapshot || typeof snapshot !== 'object') {
27
+ throw new AgentKarmaValidationError('snapshot is required');
28
+ }
29
+ const face = policy.face ?? 'provider';
30
+ if (face !== 'provider' && face !== 'consumer') {
31
+ throw new AgentKarmaValidationError(`policy.face must be 'provider' or 'consumer'`);
32
+ }
33
+ const faceData = face === 'provider' ? snapshot.provider : snapshot.consumer;
34
+ const reasons = [];
35
+ const providerScore = snapshot.provider?.score ?? null;
36
+ const consumerScore = snapshot.consumer?.score ?? null;
37
+ const confidenceBadge = faceData?.confidenceBadge ?? null;
38
+ const txCount = typeof snapshot.txCount === 'number' ? snapshot.txCount : 0;
39
+ const tiers = {
40
+ tier1: hasTier(faceData?.tierAggregates, 1),
41
+ tier2: hasTier(faceData?.tierAggregates, 2),
42
+ tier3: hasTier(faceData?.tierAggregates, 3),
43
+ tier4: hasTier(faceData?.tierAggregates, 4),
44
+ };
45
+ // Score gate. When the face has no data at all (hasSignal === false AND
46
+ // score is 0/null), treat it as a rejection if a minimum was demanded.
47
+ if (policy.minScore != null) {
48
+ const observedScore = face === 'provider' ? providerScore : consumerScore;
49
+ if (observedScore == null || observedScore < policy.minScore) {
50
+ reasons.push(`policy.minScore=${policy.minScore} not met (${face} score ${observedScore ?? 'null'})`);
51
+ }
52
+ }
53
+ // Confidence badge allowlist.
54
+ if (policy.acceptedConfidenceBadges && policy.acceptedConfidenceBadges.length > 0) {
55
+ if (!confidenceBadge || !policy.acceptedConfidenceBadges.includes(confidenceBadge)) {
56
+ reasons.push(`policy.acceptedConfidenceBadges does not include observed badge ${confidenceBadge ?? 'null'}`);
57
+ }
58
+ }
59
+ // Minimum transaction count — useful "must have shown up enough times" gate.
60
+ if (policy.minTxCount != null && txCount < policy.minTxCount) {
61
+ reasons.push(`policy.minTxCount=${policy.minTxCount} not met (observed txCount ${txCount})`);
62
+ }
63
+ // Per-tier presence requirement.
64
+ if (policy.requireTiers && policy.requireTiers.length > 0) {
65
+ for (const tier of policy.requireTiers) {
66
+ if (!tiers[`tier${tier}`]) {
67
+ reasons.push(`policy.requireTiers includes Tier ${tier}, which has no signal on ${face} face`);
68
+ }
69
+ }
70
+ }
71
+ // Receipt-backed shorthand.
72
+ if (policy.requireReceiptBacked && !tiers.tier1) {
73
+ reasons.push(`policy.requireReceiptBacked: ${face} face has no Tier 1 signal`);
74
+ }
75
+ // Autonomy gates.
76
+ const autonomyScore = snapshot.autonomy?.score ?? null;
77
+ const autonomyLabel = snapshot.autonomy?.label ?? null;
78
+ if (policy.rejectAutonomyLabels && policy.rejectAutonomyLabels.length > 0) {
79
+ if (autonomyLabel && policy.rejectAutonomyLabels.includes(autonomyLabel)) {
80
+ reasons.push(`policy.rejectAutonomyLabels includes observed label ${autonomyLabel}`);
81
+ }
82
+ }
83
+ if (policy.minAutonomyScore != null) {
84
+ if (autonomyScore == null || autonomyScore < policy.minAutonomyScore) {
85
+ reasons.push(`policy.minAutonomyScore=${policy.minAutonomyScore} not met (observed ${autonomyScore ?? 'null'})`);
86
+ }
87
+ }
88
+ // Liveness.
89
+ if (policy.requireSeen && !snapshot.lastActive) {
90
+ reasons.push('policy.requireSeen: wallet has no recorded activity');
91
+ }
92
+ // ── Dead Man's Switch (succession) observations + gates ───────────────────
93
+ const successionStatus = snapshot.succession?.status ?? null;
94
+ if (policy.requireLiveSuccession) {
95
+ if (!successionStatus) {
96
+ reasons.push('policy.requireLiveSuccession: no succession plan declared');
97
+ }
98
+ else if (!LIVE_SUCCESSION_STATUSES.has(successionStatus)) {
99
+ reasons.push(`policy.requireLiveSuccession: succession status is ${successionStatus} (not declared/live)`);
100
+ }
101
+ }
102
+ if (policy.rejectLapsed && (successionStatus === 'lapsed' || successionStatus === 'lapsing')) {
103
+ reasons.push(`policy.rejectLapsed: succession status is ${successionStatus}`);
104
+ }
105
+ // ── Agent Bonding observations + gates ────────────────────────────────────
106
+ // Borrowed capital lifts confidence, NEVER the trust ceiling — these gates are
107
+ // about presence/magnitude of skin-in-the-game, kept orthogonal to score.
108
+ const openBonds = snapshot.bond?.open ?? [];
109
+ const resolvedBonds = snapshot.bond?.resolved ?? [];
110
+ const bonded = openBonds.length > 0;
111
+ // Demo bonds are excluded from the real-money total — paper capital must not
112
+ // satisfy a minBondedUSDC gate.
113
+ const activeBondedUsdc = openBonds.reduce((sum, b) => sum + (!b.isDemo && b.currency === 'USDC' ? b.amount : 0), 0);
114
+ const hasRecentBondFailure = resolvedBonds.some((b) => !b.isDemo && b.status === 'resolved_failure');
115
+ if (policy.requireBonded && !bonded) {
116
+ reasons.push('policy.requireBonded: agent has no active bond');
117
+ }
118
+ if (policy.minBondedUSDC != null && activeBondedUsdc < policy.minBondedUSDC) {
119
+ reasons.push(`policy.minBondedUSDC=${policy.minBondedUSDC} not met (active non-demo USDC bonded ${activeBondedUsdc})`);
120
+ }
121
+ if (policy.rejectRecentBondFailure && hasRecentBondFailure) {
122
+ reasons.push('policy.rejectRecentBondFailure: agent has a resolved-failure bond');
123
+ }
124
+ return {
125
+ allowed: reasons.length === 0,
126
+ reasons,
127
+ observed: {
128
+ face,
129
+ providerScore,
130
+ consumerScore,
131
+ confidenceBadge,
132
+ txCount,
133
+ tiers,
134
+ autonomyScore,
135
+ autonomyLabel,
136
+ lastActive: snapshot.lastActive ?? null,
137
+ successionStatus,
138
+ bonded,
139
+ activeBondedUsdc,
140
+ hasRecentBondFailure,
141
+ },
142
+ };
143
+ }
144
+ function hasTier(tierAggregates, tier) {
145
+ if (!tierAggregates)
146
+ return false;
147
+ const v = tierAggregates[`tier${tier}`];
148
+ return v != null;
149
+ }
150
+ //# sourceMappingURL=policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.js","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAUxD;;;GAGG;AACH,MAAM,wBAAwB,GAAkC,IAAI,GAAG,CAAmB;IACxF,UAAU;IACV,MAAM;CACP,CAAC,CAAC;AAgGH;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,QAAuB,EAAE,SAAsB,EAAE;IAC7E,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC9C,MAAM,IAAI,yBAAyB,CAAC,sBAAsB,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,IAAI,GAAc,MAAM,CAAC,IAAI,IAAI,UAAU,CAAC;IAClD,IAAI,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/C,MAAM,IAAI,yBAAyB,CAAC,8CAA8C,CAAC,CAAC;IACtF,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAC7E,MAAM,OAAO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