@a2aletheia/sdk 0.2.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.
Files changed (122) hide show
  1. package/README.md +436 -0
  2. package/dist/__tests__/pow-solver.test.d.ts +2 -0
  3. package/dist/__tests__/pow-solver.test.d.ts.map +1 -0
  4. package/dist/__tests__/pow-solver.test.js +35 -0
  5. package/dist/__tests__/pow-solver.test.js.map +1 -0
  6. package/dist/__tests__/signing.test.d.ts +2 -0
  7. package/dist/__tests__/signing.test.d.ts.map +1 -0
  8. package/dist/__tests__/signing.test.js +59 -0
  9. package/dist/__tests__/signing.test.js.map +1 -0
  10. package/dist/agent/agent-context.d.ts +26 -0
  11. package/dist/agent/agent-context.d.ts.map +1 -0
  12. package/dist/agent/agent-context.js +38 -0
  13. package/dist/agent/agent-context.js.map +1 -0
  14. package/dist/agent/agent-executor.d.ts +17 -0
  15. package/dist/agent/agent-executor.d.ts.map +1 -0
  16. package/dist/agent/agent-executor.js +91 -0
  17. package/dist/agent/agent-executor.js.map +1 -0
  18. package/dist/agent/agent-response.d.ts +63 -0
  19. package/dist/agent/agent-response.d.ts.map +1 -0
  20. package/dist/agent/agent-response.js +211 -0
  21. package/dist/agent/agent-response.js.map +1 -0
  22. package/dist/agent/aletheia-agent.d.ts +114 -0
  23. package/dist/agent/aletheia-agent.d.ts.map +1 -0
  24. package/dist/agent/aletheia-agent.js +248 -0
  25. package/dist/agent/aletheia-agent.js.map +1 -0
  26. package/dist/agent/index.d.ts +6 -0
  27. package/dist/agent/index.d.ts.map +1 -0
  28. package/dist/agent/index.js +9 -0
  29. package/dist/agent/index.js.map +1 -0
  30. package/dist/agent/types.d.ts +61 -0
  31. package/dist/agent/types.d.ts.map +1 -0
  32. package/dist/agent/types.js +2 -0
  33. package/dist/agent/types.js.map +1 -0
  34. package/dist/client.d.ts +114 -0
  35. package/dist/client.d.ts.map +1 -0
  36. package/dist/client.js +141 -0
  37. package/dist/client.js.map +1 -0
  38. package/dist/identity/agent-signer.d.ts +93 -0
  39. package/dist/identity/agent-signer.d.ts.map +1 -0
  40. package/dist/identity/agent-signer.js +288 -0
  41. package/dist/identity/agent-signer.js.map +1 -0
  42. package/dist/identity/did-resolver.d.ts +17 -0
  43. package/dist/identity/did-resolver.d.ts.map +1 -0
  44. package/dist/identity/did-resolver.js +73 -0
  45. package/dist/identity/did-resolver.js.map +1 -0
  46. package/dist/identity/index.d.ts +4 -0
  47. package/dist/identity/index.d.ts.map +1 -0
  48. package/dist/identity/index.js +4 -0
  49. package/dist/identity/index.js.map +1 -0
  50. package/dist/identity/manifest-fetcher.d.ts +12 -0
  51. package/dist/identity/manifest-fetcher.d.ts.map +1 -0
  52. package/dist/identity/manifest-fetcher.js +27 -0
  53. package/dist/identity/manifest-fetcher.js.map +1 -0
  54. package/dist/index.d.ts +12 -0
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/index.js +20 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/logger/console-logger.d.ts +20 -0
  59. package/dist/logger/console-logger.d.ts.map +1 -0
  60. package/dist/logger/console-logger.js +43 -0
  61. package/dist/logger/console-logger.js.map +1 -0
  62. package/dist/logger/event-emitter.d.ts +39 -0
  63. package/dist/logger/event-emitter.d.ts.map +1 -0
  64. package/dist/logger/event-emitter.js +50 -0
  65. package/dist/logger/event-emitter.js.map +1 -0
  66. package/dist/logger/index.d.ts +4 -0
  67. package/dist/logger/index.d.ts.map +1 -0
  68. package/dist/logger/index.js +4 -0
  69. package/dist/logger/index.js.map +1 -0
  70. package/dist/logger/noop-logger.d.ts +20 -0
  71. package/dist/logger/noop-logger.d.ts.map +1 -0
  72. package/dist/logger/noop-logger.js +19 -0
  73. package/dist/logger/noop-logger.js.map +1 -0
  74. package/dist/reputation/index.d.ts +2 -0
  75. package/dist/reputation/index.d.ts.map +1 -0
  76. package/dist/reputation/index.js +2 -0
  77. package/dist/reputation/index.js.map +1 -0
  78. package/dist/reputation/pow-solver.d.ts +20 -0
  79. package/dist/reputation/pow-solver.d.ts.map +1 -0
  80. package/dist/reputation/pow-solver.js +46 -0
  81. package/dist/reputation/pow-solver.js.map +1 -0
  82. package/dist/reputation/rating-client.d.ts +35 -0
  83. package/dist/reputation/rating-client.d.ts.map +1 -0
  84. package/dist/reputation/rating-client.js +51 -0
  85. package/dist/reputation/rating-client.js.map +1 -0
  86. package/dist/security/audit-client.d.ts +17 -0
  87. package/dist/security/audit-client.d.ts.map +1 -0
  88. package/dist/security/audit-client.js +20 -0
  89. package/dist/security/audit-client.js.map +1 -0
  90. package/dist/security/index.d.ts +2 -0
  91. package/dist/security/index.d.ts.map +1 -0
  92. package/dist/security/index.js +2 -0
  93. package/dist/security/index.js.map +1 -0
  94. package/dist/tools/calculator.d.ts +29 -0
  95. package/dist/tools/calculator.d.ts.map +1 -0
  96. package/dist/tools/calculator.js +314 -0
  97. package/dist/tools/calculator.js.map +1 -0
  98. package/dist/tools/convert-units.d.ts +49 -0
  99. package/dist/tools/convert-units.d.ts.map +1 -0
  100. package/dist/tools/convert-units.js +152 -0
  101. package/dist/tools/convert-units.js.map +1 -0
  102. package/dist/tools/get-current-time.d.ts +23 -0
  103. package/dist/tools/get-current-time.d.ts.map +1 -0
  104. package/dist/tools/get-current-time.js +28 -0
  105. package/dist/tools/get-current-time.js.map +1 -0
  106. package/dist/tools/index.d.ts +80 -0
  107. package/dist/tools/index.d.ts.map +1 -0
  108. package/dist/tools/index.js +41 -0
  109. package/dist/tools/index.js.map +1 -0
  110. package/dist/tools/uuid-generator.d.ts +21 -0
  111. package/dist/tools/uuid-generator.d.ts.map +1 -0
  112. package/dist/tools/uuid-generator.js +25 -0
  113. package/dist/tools/uuid-generator.js.map +1 -0
  114. package/dist/utils/http.d.ts +11 -0
  115. package/dist/utils/http.d.ts.map +1 -0
  116. package/dist/utils/http.js +60 -0
  117. package/dist/utils/http.js.map +1 -0
  118. package/dist/utils/signing.d.ts +43 -0
  119. package/dist/utils/signing.d.ts.map +1 -0
  120. package/dist/utils/signing.js +78 -0
  121. package/dist/utils/signing.js.map +1 -0
  122. package/package.json +66 -0
@@ -0,0 +1,80 @@
1
+ export { calculate, calculatorToolDefinition, type CalculatorInput, type CalculatorResult, } from "./calculator.js";
2
+ export { getCurrentTime, getCurrentTimeToolDefinition, type CurrentTimeResult, } from "./get-current-time.js";
3
+ export { convertUnits, convertUnitsToolDefinition, type CryptoUnit, type TimeUnit, type DataUnit, type SupportedUnit, type UnitCategory, type UnitConversionInput, type UnitConversionResult, } from "./convert-units.js";
4
+ export { generateUUID, uuidGeneratorToolDefinition, type UUIDResult, } from "./uuid-generator.js";
5
+ export declare const aletheiaToolDefinitions: readonly [{
6
+ type: "function";
7
+ function: {
8
+ name: string;
9
+ description: string;
10
+ parameters: {
11
+ type: "object";
12
+ properties: {
13
+ expression: {
14
+ type: "string";
15
+ description: string;
16
+ };
17
+ };
18
+ required: readonly ["expression"];
19
+ additionalProperties: false;
20
+ };
21
+ };
22
+ execute: (input: import("./calculator.js").CalculatorInput) => import("./calculator.js").CalculatorResult;
23
+ }, {
24
+ type: "function";
25
+ function: {
26
+ name: string;
27
+ description: string;
28
+ parameters: {
29
+ type: "object";
30
+ properties: Record<string, never>;
31
+ required: string[];
32
+ additionalProperties: false;
33
+ };
34
+ };
35
+ execute: (_input?: Record<string, never>) => import("./get-current-time.js").CurrentTimeResult;
36
+ }, {
37
+ type: "function";
38
+ function: {
39
+ name: string;
40
+ description: string;
41
+ parameters: {
42
+ type: "object";
43
+ properties: {
44
+ value: {
45
+ type: "string";
46
+ description: string;
47
+ };
48
+ from: {
49
+ type: "string";
50
+ enum: readonly ["wei", "gwei", "ether", "seconds", "minutes", "hours", "days", "bytes", "KB", "MB", "GB", "TB"];
51
+ description: string;
52
+ };
53
+ to: {
54
+ type: "string";
55
+ enum: readonly ["wei", "gwei", "ether", "seconds", "minutes", "hours", "days", "bytes", "KB", "MB", "GB", "TB"];
56
+ description: string;
57
+ };
58
+ };
59
+ required: readonly ["value", "from", "to"];
60
+ additionalProperties: false;
61
+ };
62
+ };
63
+ execute: (input: import("./convert-units.js").UnitConversionInput) => import("./convert-units.js").UnitConversionResult;
64
+ }, {
65
+ type: "function";
66
+ function: {
67
+ name: string;
68
+ description: string;
69
+ parameters: {
70
+ type: "object";
71
+ properties: Record<string, never>;
72
+ required: string[];
73
+ additionalProperties: false;
74
+ };
75
+ };
76
+ execute: (_input?: Record<string, never>) => import("./uuid-generator.js").UUIDResult;
77
+ }];
78
+ /** Map of tool name → execute function, for routing tool calls from LLM responses. */
79
+ export declare const aletheiaToolExecutors: Record<string, (input: any) => unknown>;
80
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,SAAS,EACT,wBAAwB,EACxB,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,cAAc,EACd,4BAA4B,EAC5B,KAAK,iBAAiB,GACvB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,YAAY,EACZ,0BAA0B,EAC1B,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,GAC1B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,YAAY,EACZ,2BAA2B,EAC3B,KAAK,UAAU,GAChB,MAAM,qBAAqB,CAAC;AAyB7B,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK1B,CAAC;AAEX,sFAAsF;AAEtF,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAQzE,CAAC"}
@@ -0,0 +1,41 @@
1
+ // ── Individual tool exports ──────────────────────────────────────────────────
2
+ export { calculate, calculatorToolDefinition, } from "./calculator.js";
3
+ export { getCurrentTime, getCurrentTimeToolDefinition, } from "./get-current-time.js";
4
+ export { convertUnits, convertUnitsToolDefinition, } from "./convert-units.js";
5
+ export { generateUUID, uuidGeneratorToolDefinition, } from "./uuid-generator.js";
6
+ // ── Convenience: all tool definitions as an array ────────────────────────────
7
+ //
8
+ // Usage with LangChain:
9
+ // import { aletheiaToolDefinitions } from "@a2aletheia/sdk";
10
+ // const tools = aletheiaToolDefinitions; // pass to ChatOpenAI.bind({ tools })
11
+ //
12
+ // Usage with Vercel AI SDK:
13
+ // import { aletheiaToolDefinitions } from "@a2aletheia/sdk";
14
+ // const result = await generateText({ tools: aletheiaToolDefinitions, ... });
15
+ //
16
+ // Usage with OpenAI function calling:
17
+ // import { aletheiaToolDefinitions } from "@a2aletheia/sdk";
18
+ // const response = await openai.chat.completions.create({
19
+ // tools: aletheiaToolDefinitions.map(t => ({ type: t.type, function: t.function })),
20
+ // ...
21
+ // });
22
+ // // Then route tool calls to the matching definition's .execute()
23
+ import { calculatorToolDefinition } from "./calculator.js";
24
+ import { getCurrentTimeToolDefinition } from "./get-current-time.js";
25
+ import { convertUnitsToolDefinition } from "./convert-units.js";
26
+ import { uuidGeneratorToolDefinition } from "./uuid-generator.js";
27
+ export const aletheiaToolDefinitions = [
28
+ calculatorToolDefinition,
29
+ getCurrentTimeToolDefinition,
30
+ convertUnitsToolDefinition,
31
+ uuidGeneratorToolDefinition,
32
+ ];
33
+ /** Map of tool name → execute function, for routing tool calls from LLM responses. */
34
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
+ export const aletheiaToolExecutors = {
36
+ [calculatorToolDefinition.function.name]: calculatorToolDefinition.execute,
37
+ [getCurrentTimeToolDefinition.function.name]: getCurrentTimeToolDefinition.execute,
38
+ [convertUnitsToolDefinition.function.name]: convertUnitsToolDefinition.execute,
39
+ [uuidGeneratorToolDefinition.function.name]: uuidGeneratorToolDefinition.execute,
40
+ };
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,EACL,SAAS,EACT,wBAAwB,GAGzB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,cAAc,EACd,4BAA4B,GAE7B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,YAAY,EACZ,0BAA0B,GAQ3B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,YAAY,EACZ,2BAA2B,GAE5B,MAAM,qBAAqB,CAAC;AAE7B,gFAAgF;AAChF,EAAE;AACF,wBAAwB;AACxB,+DAA+D;AAC/D,iFAAiF;AACjF,EAAE;AACF,4BAA4B;AAC5B,+DAA+D;AAC/D,gFAAgF;AAChF,EAAE;AACF,sCAAsC;AACtC,+DAA+D;AAC/D,4DAA4D;AAC5D,yFAAyF;AACzF,UAAU;AACV,QAAQ;AACR,qEAAqE;AAErE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAElE,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,wBAAwB;IACxB,4BAA4B;IAC5B,0BAA0B;IAC1B,2BAA2B;CACnB,CAAC;AAEX,sFAAsF;AACtF,8DAA8D;AAC9D,MAAM,CAAC,MAAM,qBAAqB,GAA4C;IAC5E,CAAC,wBAAwB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,wBAAwB,CAAC,OAAO;IAC1E,CAAC,4BAA4B,CAAC,QAAQ,CAAC,IAAI,CAAC,EAC1C,4BAA4B,CAAC,OAAO;IACtC,CAAC,0BAA0B,CAAC,QAAQ,CAAC,IAAI,CAAC,EACxC,0BAA0B,CAAC,OAAO;IACpC,CAAC,2BAA2B,CAAC,QAAQ,CAAC,IAAI,CAAC,EACzC,2BAA2B,CAAC,OAAO;CACtC,CAAC"}
@@ -0,0 +1,21 @@
1
+ export interface UUIDResult {
2
+ tool: "uuid_generator";
3
+ uuid: string;
4
+ version: 4;
5
+ }
6
+ export declare function generateUUID(): UUIDResult;
7
+ export declare const uuidGeneratorToolDefinition: {
8
+ type: "function";
9
+ function: {
10
+ name: string;
11
+ description: string;
12
+ parameters: {
13
+ type: "object";
14
+ properties: Record<string, never>;
15
+ required: string[];
16
+ additionalProperties: false;
17
+ };
18
+ };
19
+ execute: (_input?: Record<string, never>) => UUIDResult;
20
+ };
21
+ //# sourceMappingURL=uuid-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuid-generator.d.ts","sourceRoot":"","sources":["../../src/tools/uuid-generator.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,gBAAgB,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,CAAC;CACZ;AAID,wBAAgB,YAAY,IAAI,UAAU,CAMzC;AAID,eAAO,MAAM,2BAA2B;;;;;;;wBAQhB,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;sBACvB,MAAM,EAAE;;;;uBAIT,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,KAAG,UAAU;CACtD,CAAC"}
@@ -0,0 +1,25 @@
1
+ // ── Result type ──────────────────────────────────────────────────────────────
2
+ // ── Core function ────────────────────────────────────────────────────────────
3
+ export function generateUUID() {
4
+ return {
5
+ tool: "uuid_generator",
6
+ uuid: crypto.randomUUID(),
7
+ version: 4,
8
+ };
9
+ }
10
+ // ── Tool definition (OpenAI-compatible / LangChain / Vercel AI SDK) ──────────
11
+ export const uuidGeneratorToolDefinition = {
12
+ type: "function",
13
+ function: {
14
+ name: "uuid_generator",
15
+ description: "Generate a random UUID v4 identifier. Use this when you need a unique ID for creating resources, correlation IDs, or any scenario requiring a globally unique identifier.",
16
+ parameters: {
17
+ type: "object",
18
+ properties: {},
19
+ required: [],
20
+ additionalProperties: false,
21
+ },
22
+ },
23
+ execute: (_input) => generateUUID(),
24
+ };
25
+ //# sourceMappingURL=uuid-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuid-generator.js","sourceRoot":"","sources":["../../src/tools/uuid-generator.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAQhF,gFAAgF;AAEhF,MAAM,UAAU,YAAY;IAC1B,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE;QACzB,OAAO,EAAE,CAAC;KACX,CAAC;AACJ,CAAC;AAED,gFAAgF;AAEhF,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,IAAI,EAAE,UAAmB;IACzB,QAAQ,EAAE;QACR,IAAI,EAAE,gBAAgB;QACtB,WAAW,EACT,2KAA2K;QAC7K,UAAU,EAAE;YACV,IAAI,EAAE,QAAiB;YACvB,UAAU,EAAE,EAA2B;YACvC,QAAQ,EAAE,EAAc;YACxB,oBAAoB,EAAE,KAAc;SACrC;KACF;IACD,OAAO,EAAE,CAAC,MAA8B,EAAc,EAAE,CAAC,YAAY,EAAE;CACxE,CAAC"}
@@ -0,0 +1,11 @@
1
+ export declare class HttpClient {
2
+ private baseUrl;
3
+ private authToken;
4
+ constructor(baseUrl: string);
5
+ setAuthToken(token: string | null): void;
6
+ private getHeaders;
7
+ get<T>(path: string, params?: Record<string, string>): Promise<T>;
8
+ post<T>(path: string, body: unknown): Promise<T>;
9
+ put<T>(path: string, body: unknown): Promise<T>;
10
+ }
11
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/utils/http.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAU;IAGT,OAAO,CAAC,OAAO;IAF3B,OAAO,CAAC,SAAS,CAAuB;gBAEpB,OAAO,EAAE,MAAM;IAEnC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAIxC,OAAO,CAAC,UAAU;IAWZ,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAgBjE,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAahD,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;CAYtD"}
@@ -0,0 +1,60 @@
1
+ export class HttpClient {
2
+ baseUrl;
3
+ authToken = null;
4
+ constructor(baseUrl) {
5
+ this.baseUrl = baseUrl;
6
+ }
7
+ setAuthToken(token) {
8
+ this.authToken = token;
9
+ }
10
+ getHeaders(includeBody = false) {
11
+ const headers = {};
12
+ if (includeBody) {
13
+ headers["Content-Type"] = "application/json";
14
+ }
15
+ if (this.authToken) {
16
+ headers["Authorization"] = `Bearer ${this.authToken}`;
17
+ }
18
+ return headers;
19
+ }
20
+ async get(path, params) {
21
+ const url = new URL(path, this.baseUrl);
22
+ if (params) {
23
+ for (const [key, value] of Object.entries(params)) {
24
+ url.searchParams.set(key, value);
25
+ }
26
+ }
27
+ const response = await fetch(url.toString(), {
28
+ headers: this.getHeaders(),
29
+ });
30
+ if (!response.ok) {
31
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
32
+ }
33
+ return response.json();
34
+ }
35
+ async post(path, body) {
36
+ const url = new URL(path, this.baseUrl);
37
+ const response = await fetch(url.toString(), {
38
+ method: "POST",
39
+ headers: this.getHeaders(true),
40
+ body: JSON.stringify(body),
41
+ });
42
+ if (!response.ok) {
43
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
44
+ }
45
+ return response.json();
46
+ }
47
+ async put(path, body) {
48
+ const url = new URL(path, this.baseUrl);
49
+ const response = await fetch(url.toString(), {
50
+ method: "PUT",
51
+ headers: this.getHeaders(true),
52
+ body: JSON.stringify(body),
53
+ });
54
+ if (!response.ok) {
55
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
56
+ }
57
+ return response.json();
58
+ }
59
+ }
60
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/utils/http.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,UAAU;IAGD;IAFZ,SAAS,GAAkB,IAAI,CAAC;IAExC,YAAoB,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAAG,CAAC;IAEvC,YAAY,CAAC,KAAoB;QAC/B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;IAEO,UAAU,CAAC,WAAW,GAAG,KAAK;QACpC,MAAM,OAAO,GAA2B,EAAE,CAAC;QAC3C,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,CAAC,cAAc,CAAC,GAAG,kBAAkB,CAAC;QAC/C,CAAC;QACD,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,IAAI,CAAC,SAAS,EAAE,CAAC;QACxD,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,GAAG,CAAI,IAAY,EAAE,MAA+B;QACxD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACxC,IAAI,MAAM,EAAE,CAAC;YACX,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBAClD,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,EAA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U,CAAC,IAAI,CAAC;YAC9B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,QAAQ,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,QAAQ,CAAC,IAAI,EAAgB,CAAC;IACvC,CAAC;CACF"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * EIP-712 signing helpers for rating payloads.
3
+ *
4
+ * Uses viem for typed-data signing and verification.
5
+ */
6
+ import { type Hex } from "viem";
7
+ export interface RatingPayloadMessage {
8
+ fromDid: string;
9
+ toDid: string;
10
+ score: number;
11
+ chainId: number | bigint;
12
+ powNonce: string;
13
+ powHash: string;
14
+ challengeId: string;
15
+ }
16
+ export interface SignedPayload {
17
+ payload: string;
18
+ signature: string;
19
+ signer: string;
20
+ }
21
+ /**
22
+ * Sign a rating payload using EIP-712 typed data signing.
23
+ *
24
+ * @param payload - The rating payload fields
25
+ * @param privateKey - Hex-encoded private key (with 0x prefix)
26
+ * @returns SignedPayload with JSON-encoded payload, signature, and signer address
27
+ */
28
+ export declare function signRatingPayload(payload: RatingPayloadMessage, privateKey: string): Promise<SignedPayload>;
29
+ /**
30
+ * Verify an EIP-712 signed rating payload.
31
+ *
32
+ * @param payload - JSON-encoded rating payload
33
+ * @param signature - Hex-encoded signature
34
+ * @param expectedSigner - Expected Ethereum address of the signer
35
+ * @returns true if the signature is valid and matches the expected signer
36
+ */
37
+ export declare function verifyRatingSignature(payload: string, signature: string, expectedSigner: string): Promise<boolean>;
38
+ /**
39
+ * Hash a rating payload using EIP-712 typed data hashing.
40
+ * Useful for on-chain verification where only the hash is needed.
41
+ */
42
+ export declare function hashRatingPayload(payload: RatingPayloadMessage): Hex;
43
+ //# sourceMappingURL=signing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signing.d.ts","sourceRoot":"","sources":["../../src/utils/signing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAGL,KAAK,GAAG,EACT,MAAM,MAAM,CAAC;AAwBd,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,oBAAoB,EAC7B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,aAAa,CAAC,CAexB;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,OAAO,CAAC,CAYlB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,oBAAoB,GAAG,GAAG,CAOpE"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * EIP-712 signing helpers for rating payloads.
3
+ *
4
+ * Uses viem for typed-data signing and verification.
5
+ */
6
+ import { hashTypedData, recoverTypedDataAddress, } from "viem";
7
+ import { privateKeyToAccount } from "viem/accounts";
8
+ // EIP-712 domain for Aletheia Reputation (chainId required to prevent cross-chain replay)
9
+ const getDomain = (chainId) => ({
10
+ name: "Aletheia Reputation",
11
+ version: "1",
12
+ chainId,
13
+ });
14
+ // Rating payload type definitions for EIP-712
15
+ const RATING_TYPES = {
16
+ RatingPayload: [
17
+ { name: "fromDid", type: "string" },
18
+ { name: "toDid", type: "string" },
19
+ { name: "score", type: "uint8" },
20
+ { name: "chainId", type: "uint256" },
21
+ { name: "powNonce", type: "string" },
22
+ { name: "powHash", type: "string" },
23
+ { name: "challengeId", type: "string" },
24
+ ],
25
+ };
26
+ /**
27
+ * Sign a rating payload using EIP-712 typed data signing.
28
+ *
29
+ * @param payload - The rating payload fields
30
+ * @param privateKey - Hex-encoded private key (with 0x prefix)
31
+ * @returns SignedPayload with JSON-encoded payload, signature, and signer address
32
+ */
33
+ export async function signRatingPayload(payload, privateKey) {
34
+ const account = privateKeyToAccount(privateKey);
35
+ const signature = await account.signTypedData({
36
+ domain: getDomain(Number(payload.chainId)),
37
+ types: RATING_TYPES,
38
+ primaryType: "RatingPayload",
39
+ message: { ...payload, chainId: BigInt(payload.chainId) },
40
+ });
41
+ return {
42
+ payload: JSON.stringify(payload),
43
+ signature,
44
+ signer: account.address,
45
+ };
46
+ }
47
+ /**
48
+ * Verify an EIP-712 signed rating payload.
49
+ *
50
+ * @param payload - JSON-encoded rating payload
51
+ * @param signature - Hex-encoded signature
52
+ * @param expectedSigner - Expected Ethereum address of the signer
53
+ * @returns true if the signature is valid and matches the expected signer
54
+ */
55
+ export async function verifyRatingSignature(payload, signature, expectedSigner) {
56
+ const message = JSON.parse(payload);
57
+ const recoveredAddress = await recoverTypedDataAddress({
58
+ domain: getDomain(Number(message.chainId)),
59
+ types: RATING_TYPES,
60
+ primaryType: "RatingPayload",
61
+ message: { ...message, chainId: BigInt(message.chainId) },
62
+ signature: signature,
63
+ });
64
+ return recoveredAddress.toLowerCase() === expectedSigner.toLowerCase();
65
+ }
66
+ /**
67
+ * Hash a rating payload using EIP-712 typed data hashing.
68
+ * Useful for on-chain verification where only the hash is needed.
69
+ */
70
+ export function hashRatingPayload(payload) {
71
+ return hashTypedData({
72
+ domain: getDomain(Number(payload.chainId)),
73
+ types: RATING_TYPES,
74
+ primaryType: "RatingPayload",
75
+ message: { ...payload, chainId: BigInt(payload.chainId) },
76
+ });
77
+ }
78
+ //# sourceMappingURL=signing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signing.js","sourceRoot":"","sources":["../../src/utils/signing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,aAAa,EACb,uBAAuB,GAExB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD,0FAA0F;AAC1F,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,EAAE,CACpC,CAAC;IACC,IAAI,EAAE,qBAAqB;IAC3B,OAAO,EAAE,GAAG;IACZ,OAAO;CACR,CAAU,CAAC;AAEd,8CAA8C;AAC9C,MAAM,YAAY,GAAG;IACnB,aAAa,EAAE;QACb,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;QACnC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE;QACjC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE;QAChC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;QACpC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE;QACpC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;QACnC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,QAAQ,EAAE;KACxC;CACO,CAAC;AAkBX;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAA6B,EAC7B,UAAkB;IAElB,MAAM,OAAO,GAAG,mBAAmB,CAAC,UAAiB,CAAC,CAAC;IAEvD,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC;QAC5C,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1C,KAAK,EAAE,YAAY;QACnB,WAAW,EA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4
+ "description": "SDK for integrating with the Aletheia A2A Agent Discovery Registry",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./agent": {
14
+ "types": "./dist/agent/index.d.ts",
15
+ "default": "./dist/agent/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md"
21
+ ],
22
+ "keywords": [
23
+ "a2a",
24
+ "agent",
25
+ "discovery",
26
+ "aletheia",
27
+ "multi-agent",
28
+ "ai-agents"
29
+ ],
30
+ "author": "",
31
+ "license": "MIT",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/weedeej/aletheia"
35
+ },
36
+ "dependencies": {
37
+ "@a2a-js/sdk": "^0.2.5",
38
+ "@noble/ed25519": "^2.1.0",
39
+ "@noble/hashes": "^2.0.1",
40
+ "viem": "^2.21.0",
41
+ "@a2aletheia/types": "0.1.0"
42
+ },
43
+ "devDependencies": {
44
+ "@types/express": "^4.17.21",
45
+ "rimraf": "^6.0.1",
46
+ "@types/node": "^20",
47
+ "typescript": "^5.9.2",
48
+ "vitest": "^2.1.0",
49
+ "@a2aletheia/base-typescript-config": "0.0.0"
50
+ },
51
+ "peerDependencies": {
52
+ "express": ">=4.0.0"
53
+ },
54
+ "peerDependenciesMeta": {
55
+ "express": {
56
+ "optional": true
57
+ }
58
+ },
59
+ "scripts": {
60
+ "build": "tsc",
61
+ "check-types": "tsc --noEmit",
62
+ "lint": "eslint .",
63
+ "test": "vitest run",
64
+ "clean": "rimraf dist"
65
+ }
66
+ }