@huddle-marketplace/skills 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 (86) hide show
  1. package/README.md +256 -0
  2. package/dist/adapters/openclaw.d.ts +42 -0
  3. package/dist/adapters/openclaw.d.ts.map +1 -0
  4. package/dist/adapters/openclaw.js +94 -0
  5. package/dist/adapters/openclaw.js.map +1 -0
  6. package/dist/base.d.ts +26 -0
  7. package/dist/base.d.ts.map +1 -0
  8. package/dist/base.js +97 -0
  9. package/dist/base.js.map +1 -0
  10. package/dist/compose.d.ts +87 -0
  11. package/dist/compose.d.ts.map +1 -0
  12. package/dist/compose.js +119 -0
  13. package/dist/compose.js.map +1 -0
  14. package/dist/index.d.ts +104 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +167 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/jurisdictions/ca-bc/index.d.ts +49 -0
  19. package/dist/jurisdictions/ca-bc/index.d.ts.map +1 -0
  20. package/dist/jurisdictions/ca-bc/index.js +212 -0
  21. package/dist/jurisdictions/ca-bc/index.js.map +1 -0
  22. package/dist/jurisdictions/ca-ns/index.d.ts +27 -0
  23. package/dist/jurisdictions/ca-ns/index.d.ts.map +1 -0
  24. package/dist/jurisdictions/ca-ns/index.js +127 -0
  25. package/dist/jurisdictions/ca-ns/index.js.map +1 -0
  26. package/dist/jurisdictions/ca-on/index.d.ts +26 -0
  27. package/dist/jurisdictions/ca-on/index.d.ts.map +1 -0
  28. package/dist/jurisdictions/ca-on/index.js +109 -0
  29. package/dist/jurisdictions/ca-on/index.js.map +1 -0
  30. package/dist/jurisdictions/ca-qc/index.d.ts +75 -0
  31. package/dist/jurisdictions/ca-qc/index.d.ts.map +1 -0
  32. package/dist/jurisdictions/ca-qc/index.js +232 -0
  33. package/dist/jurisdictions/ca-qc/index.js.map +1 -0
  34. package/dist/jurisdictions/canadian-template.d.ts +49 -0
  35. package/dist/jurisdictions/canadian-template.d.ts.map +1 -0
  36. package/dist/jurisdictions/canadian-template.js +228 -0
  37. package/dist/jurisdictions/canadian-template.js.map +1 -0
  38. package/dist/jurisdictions/lifecycle/active-tenancy.d.ts +55 -0
  39. package/dist/jurisdictions/lifecycle/active-tenancy.d.ts.map +1 -0
  40. package/dist/jurisdictions/lifecycle/active-tenancy.js +227 -0
  41. package/dist/jurisdictions/lifecycle/active-tenancy.js.map +1 -0
  42. package/dist/jurisdictions/lifecycle/homeownership-readiness.d.ts +60 -0
  43. package/dist/jurisdictions/lifecycle/homeownership-readiness.d.ts.map +1 -0
  44. package/dist/jurisdictions/lifecycle/homeownership-readiness.js +401 -0
  45. package/dist/jurisdictions/lifecycle/homeownership-readiness.js.map +1 -0
  46. package/dist/jurisdictions/us-ca/index.d.ts +65 -0
  47. package/dist/jurisdictions/us-ca/index.d.ts.map +1 -0
  48. package/dist/jurisdictions/us-ca/index.js +265 -0
  49. package/dist/jurisdictions/us-ca/index.js.map +1 -0
  50. package/dist/jurisdictions/us-cftc/index.d.ts +48 -0
  51. package/dist/jurisdictions/us-cftc/index.d.ts.map +1 -0
  52. package/dist/jurisdictions/us-cftc/index.js +192 -0
  53. package/dist/jurisdictions/us-cftc/index.js.map +1 -0
  54. package/dist/jurisdictions/us-fl/index.d.ts +43 -0
  55. package/dist/jurisdictions/us-fl/index.d.ts.map +1 -0
  56. package/dist/jurisdictions/us-fl/index.js +129 -0
  57. package/dist/jurisdictions/us-fl/index.js.map +1 -0
  58. package/dist/jurisdictions/us-ny/index.d.ts +77 -0
  59. package/dist/jurisdictions/us-ny/index.d.ts.map +1 -0
  60. package/dist/jurisdictions/us-ny/index.js +344 -0
  61. package/dist/jurisdictions/us-ny/index.js.map +1 -0
  62. package/dist/jurisdictions/us-state-factory.d.ts +79 -0
  63. package/dist/jurisdictions/us-state-factory.d.ts.map +1 -0
  64. package/dist/jurisdictions/us-state-factory.js +425 -0
  65. package/dist/jurisdictions/us-state-factory.js.map +1 -0
  66. package/dist/jurisdictions/us-tx/index.d.ts +43 -0
  67. package/dist/jurisdictions/us-tx/index.d.ts.map +1 -0
  68. package/dist/jurisdictions/us-tx/index.js +160 -0
  69. package/dist/jurisdictions/us-tx/index.js.map +1 -0
  70. package/dist/mcp/index.d.ts +49 -0
  71. package/dist/mcp/index.d.ts.map +1 -0
  72. package/dist/mcp/index.js +211 -0
  73. package/dist/mcp/index.js.map +1 -0
  74. package/dist/registry/index.d.ts +27 -0
  75. package/dist/registry/index.d.ts.map +1 -0
  76. package/dist/registry/index.js +47 -0
  77. package/dist/registry/index.js.map +1 -0
  78. package/dist/traiga/index.d.ts +24 -0
  79. package/dist/traiga/index.d.ts.map +1 -0
  80. package/dist/traiga/index.js +67 -0
  81. package/dist/traiga/index.js.map +1 -0
  82. package/dist/types/index.d.ts +814 -0
  83. package/dist/types/index.d.ts.map +1 -0
  84. package/dist/types/index.js +150 -0
  85. package/dist/types/index.js.map +1 -0
  86. package/package.json +77 -0
@@ -0,0 +1,160 @@
1
+ /**
2
+ * US-TX — Texas SB-38 Virtual Currency Safe Harbor + Property Code §92
3
+ *
4
+ * Texas Senate Bill 38 provides safe harbor for virtual currency custodians
5
+ * under federal preemption. Property Code §92 covers security deposit rules:
6
+ * - No statutory cap on deposit amount (but must be reasonable)
7
+ * - Deposit must be returned within 30 days of lease termination
8
+ * - Landlord must provide itemized list of deductions
9
+ * - Bad faith retention: tenant can recover 3x wrongfully withheld amount + $100 + attorney fees
10
+ */
11
+ import { BaseSkill } from "../../base.js";
12
+ export class USTXSkill extends BaseSkill {
13
+ id = "huddle-compliance-us-tx";
14
+ name = "Texas SB-38 & Property Code §92";
15
+ jurisdiction = "US-TX";
16
+ version = "1.0.0";
17
+ capabilities = [
18
+ "deposit-validation",
19
+ "deposit-return",
20
+ ];
21
+ async validate(input) {
22
+ if (input.type !== "deposit-validation") {
23
+ return this.buildResult([{
24
+ name: "input-type",
25
+ passed: false,
26
+ confidence: 1.0,
27
+ note: `TX skill currently supports deposit-validation, received: ${input.type}`,
28
+ }], input);
29
+ }
30
+ const deposit = input;
31
+ const checks = [
32
+ this.checkReserveRatio(deposit),
33
+ this.checkDepositReasonableness(deposit),
34
+ this.checkCustodialCompliance(deposit),
35
+ this.checkDisclosureRequirements(deposit),
36
+ ];
37
+ return this.buildResult(checks, input);
38
+ }
39
+ /**
40
+ * SB-38 Section 3: Reserve Ratio Requirement
41
+ * Virtual currency custodians must maintain 1:1 reserve
42
+ */
43
+ checkReserveRatio(input) {
44
+ // Not applicable when no virtual currency custodian is involved
45
+ if (input.wbtcUsdcRatio === undefined || input.wbtcUsdcRatio === null) {
46
+ return {
47
+ name: "reserve-ratio",
48
+ passed: true,
49
+ confidence: 0.8,
50
+ note: "Reserve ratio check not applicable (no virtual currency custodian involved)",
51
+ citation: {
52
+ statute: "Texas SB-38",
53
+ section: "Section 3",
54
+ summary: "Minimum 1:1 reserve ratio required for virtual currency custodians",
55
+ effectiveDate: "2023-09-01",
56
+ },
57
+ };
58
+ }
59
+ const ratio = input.wbtcUsdcRatio;
60
+ const passed = ratio >= 1.0;
61
+ return {
62
+ name: "reserve-ratio",
63
+ passed,
64
+ confidence: 1.0,
65
+ note: passed
66
+ ? `Reserve ratio ${ratio.toFixed(2)} meets SB-38 minimum 1:1 requirement`
67
+ : `Reserve ratio ${ratio.toFixed(2)} is below SB-38 minimum 1:1`,
68
+ citation: {
69
+ statute: "Texas SB-38",
70
+ section: "Section 3",
71
+ summary: "Minimum 1:1 reserve ratio required for virtual currency custodians",
72
+ effectiveDate: "2023-09-01",
73
+ },
74
+ details: { currentRatio: ratio, minimumRequired: 1.0 },
75
+ };
76
+ }
77
+ /**
78
+ * TX Property Code §92.102: Deposit Reasonableness
79
+ * Texas has no statutory cap, but deposits must be reasonable.
80
+ * Common practice: 1-2 months' rent. We flag > 2 months as potentially unreasonable.
81
+ */
82
+ checkDepositReasonableness(input) {
83
+ const depositCents = input.depositAmountCents;
84
+ const rentCents = input.monthlyRentCents;
85
+ const monthsEquivalent = rentCents > 0 ? depositCents / rentCents : 0;
86
+ const isReasonable = monthsEquivalent <= 2.0;
87
+ return {
88
+ name: "deposit-reasonableness",
89
+ passed: true, // No statutory cap in TX — advisory only
90
+ confidence: isReasonable ? 1.0 : 0.7,
91
+ note: isReasonable
92
+ ? `Deposit (${monthsEquivalent.toFixed(1)}x rent) is within reasonable range`
93
+ : `Deposit (${monthsEquivalent.toFixed(1)}x rent) exceeds common 2-month practice — no statutory cap in TX, but may be challenged as unreasonable`,
94
+ citation: {
95
+ statute: "Texas Property Code",
96
+ section: "§92.102",
97
+ summary: "No statutory deposit cap; amount must be reasonable. Common practice is 1-2 months' rent.",
98
+ url: "https://statutes.capitol.texas.gov/Docs/PR/htm/PR.92.htm",
99
+ },
100
+ details: { monthsEquivalent, depositCents, rentCents },
101
+ };
102
+ }
103
+ /**
104
+ * SB-38 Section 4: Custodial Compliance
105
+ */
106
+ checkCustodialCompliance(input) {
107
+ const isSmartContract = input.custodyType === "smart_contract";
108
+ const notSpecified = input.custodyType === undefined;
109
+ return {
110
+ name: "custodial-compliance",
111
+ passed: isSmartContract || notSpecified,
112
+ confidence: isSmartContract ? 1.0 : notSpecified ? 0.8 : 0.5,
113
+ note: isSmartContract
114
+ ? "Non-custodial smart contract compliant with SB-38"
115
+ : notSpecified
116
+ ? "Custody type not specified — ensure SB-38 compliance if using virtual currency"
117
+ : "Custodial arrangement should use non-custodial smart contracts per SB-38",
118
+ citation: {
119
+ statute: "Texas SB-38",
120
+ section: "Section 4",
121
+ summary: "Non-custodial smart contract architecture recommended for safe harbor",
122
+ },
123
+ };
124
+ }
125
+ /**
126
+ * TX Property Code §92.104: Disclosure Requirements
127
+ * Landlord must disclose deposit terms in writing
128
+ */
129
+ checkDisclosureRequirements(input) {
130
+ // Check if yield/interest arrangements are disclosed
131
+ const hasYieldDisclosure = input.yieldShareActive !== undefined;
132
+ return {
133
+ name: "disclosure-requirements",
134
+ passed: true, // Advisory — we check if disclosure data exists
135
+ confidence: hasYieldDisclosure ? 1.0 : 0.8,
136
+ note: hasYieldDisclosure
137
+ ? "Deposit terms and yield arrangements are disclosed"
138
+ : "Ensure deposit terms are disclosed in writing per Property Code §92.104",
139
+ citation: {
140
+ statute: "Texas Property Code",
141
+ section: "§92.104",
142
+ summary: "Landlord must provide written notice of deposit terms and conditions",
143
+ url: "https://statutes.capitol.texas.gov/Docs/PR/htm/PR.92.htm",
144
+ },
145
+ };
146
+ }
147
+ checkToRemediation(check) {
148
+ if (check.name === "deposit-reasonableness" && !check.passed) {
149
+ return {
150
+ action: "reduce_deposit",
151
+ description: "Consider reducing deposit to within 2 months' rent to avoid potential reasonableness challenges",
152
+ urgency: "recommended",
153
+ automatable: true,
154
+ };
155
+ }
156
+ return super.checkToRemediation(check);
157
+ }
158
+ }
159
+ export const usTxSkill = new USTXSkill();
160
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/jurisdictions/us-tx/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAU1C,MAAM,OAAO,SAAU,SAAQ,SAAS;IAC7B,EAAE,GAAG,yBAAyB,CAAC;IAC/B,IAAI,GAAG,iCAAiC,CAAC;IACzC,YAAY,GAAG,OAAgB,CAAC;IAChC,OAAO,GAAG,OAAO,CAAC;IAClB,YAAY,GAAsB;QACzC,oBAAoB;QACpB,gBAAgB;KACjB,CAAC;IAEF,KAAK,CAAC,QAAQ,CAAC,KAAiB;QAC9B,IAAI,KAAK,CAAC,IAAI,KAAK,oBAAoB,EAAE,CAAC;YACxC,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC;oBACvB,IAAI,EAAE,YAAY;oBAClB,MAAM,EAAE,KAAK;oBACb,UAAU,EAAE,GAAG;oBACf,IAAI,EAAE,6DAA6D,KAAK,CAAC,IAAI,EAAE;iBAChF,CAAC,EAAE,KAAK,CAAC,CAAC;QACb,CAAC;Q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 /**
2
+ * MCP (Model Context Protocol) Server Wrapper
3
+ *
4
+ * Exposes all Huddle compliance skills as MCP tools via JSON-RPC 2.0.
5
+ * Any MCP-compatible client (Claude Desktop, etc.) can call these tools.
6
+ *
7
+ * Tool schema:
8
+ * - huddle_compliance_check: Validate a transaction against jurisdictional rules
9
+ * - huddle_list_jurisdictions: List all supported jurisdictions
10
+ * - huddle_skill_metadata: Get metadata for a specific skill
11
+ */
12
+ import type { SkillRegistry } from "../registry/index.js";
13
+ /** MCP Tool Definition (JSON Schema format) */
14
+ export interface MCPToolDefinition {
15
+ name: string;
16
+ description: string;
17
+ inputSchema: {
18
+ type: "object";
19
+ properties: Record<string, unknown>;
20
+ required: string[];
21
+ };
22
+ }
23
+ /** MCP JSON-RPC request */
24
+ export interface MCPRequest {
25
+ jsonrpc: "2.0";
26
+ id: string | number;
27
+ method: string;
28
+ params?: Record<string, unknown>;
29
+ }
30
+ /** MCP JSON-RPC response */
31
+ export interface MCPResponse {
32
+ jsonrpc: "2.0";
33
+ id: string | number;
34
+ result?: unknown;
35
+ error?: {
36
+ code: number;
37
+ message: string;
38
+ data?: unknown;
39
+ };
40
+ }
41
+ /**
42
+ * Get MCP tool definitions for all Huddle skills
43
+ */
44
+ export declare function getMCPToolDefinitions(): MCPToolDefinition[];
45
+ /**
46
+ * Handle an MCP JSON-RPC request
47
+ */
48
+ export declare function handleMCPRequest(request: MCPRequest, registry: SkillRegistry): Promise<MCPResponse>;
49
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AASH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,+CAA+C;AAC/C,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACpC,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;CACH;AAED,2BAA2B;AAC3B,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,4BAA4B;AAC5B,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAC3D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,iBAAiB,EAAE,CA+D3D;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,UAAU,EACnB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,WAAW,CAAC,CAkDtB"}
@@ -0,0 +1,211 @@
1
+ /**
2
+ * MCP (Model Context Protocol) Server Wrapper
3
+ *
4
+ * Exposes all Huddle compliance skills as MCP tools via JSON-RPC 2.0.
5
+ * Any MCP-compatible client (Claude Desktop, etc.) can call these tools.
6
+ *
7
+ * Tool schema:
8
+ * - huddle_compliance_check: Validate a transaction against jurisdictional rules
9
+ * - huddle_list_jurisdictions: List all supported jurisdictions
10
+ * - huddle_skill_metadata: Get metadata for a specific skill
11
+ */
12
+ /**
13
+ * Get MCP tool definitions for all Huddle skills
14
+ */
15
+ export function getMCPToolDefinitions() {
16
+ return [
17
+ {
18
+ name: "huddle_compliance_check",
19
+ description: "Validate a rental transaction against jurisdictional compliance rules. " +
20
+ "Supports 63 jurisdictions (50 US states + 13 Canadian provinces). " +
21
+ "Returns compliance status, confidence score, legal citations, and remediation steps.",
22
+ inputSchema: {
23
+ type: "object",
24
+ properties: {
25
+ jurisdiction: {
26
+ type: "string",
27
+ description: "Jurisdiction code (e.g., 'US-TX', 'CA-BC', 'US-CFTC')",
28
+ },
29
+ type: {
30
+ type: "string",
31
+ enum: ["deposit-validation", "payment-compliance", "rent-increase-validation", "deposit-return", "homeownership-readiness"],
32
+ description: "Type of compliance check to perform",
33
+ },
34
+ depositAmountCents: {
35
+ type: "number",
36
+ description: "Deposit amount in cents",
37
+ },
38
+ monthlyRentCents: {
39
+ type: "number",
40
+ description: "Monthly rent amount in cents",
41
+ },
42
+ currency: {
43
+ type: "string",
44
+ enum: ["USD", "CAD", "USDC"],
45
+ description: "Currency code",
46
+ },
47
+ },
48
+ required: ["jurisdiction", "type"],
49
+ },
50
+ },
51
+ {
52
+ name: "huddle_list_jurisdictions",
53
+ description: "List all supported jurisdictions with their skill names and capabilities.",
54
+ inputSchema: {
55
+ type: "object",
56
+ properties: {},
57
+ required: [],
58
+ },
59
+ },
60
+ {
61
+ name: "huddle_skill_metadata",
62
+ description: "Get detailed metadata for a specific jurisdiction's compliance skill.",
63
+ inputSchema: {
64
+ type: "object",
65
+ properties: {
66
+ jurisdiction: {
67
+ type: "string",
68
+ description: "Jurisdiction code (e.g., 'US-TX', 'CA-BC')",
69
+ },
70
+ },
71
+ required: ["jurisdiction"],
72
+ },
73
+ },
74
+ ];
75
+ }
76
+ /**
77
+ * Handle an MCP JSON-RPC request
78
+ */
79
+ export async function handleMCPRequest(request, registry) {
80
+ const { id, method, params } = request;
81
+ try {
82
+ switch (method) {
83
+ case "tools/list":
84
+ return {
85
+ jsonrpc: "2.0",
86
+ id,
87
+ result: { tools: getMCPToolDefinitions() },
88
+ };
89
+ case "tools/call": {
90
+ const toolName = params?.name;
91
+ const args = params?.arguments ?? {};
92
+ if (toolName === "huddle_compliance_check") {
93
+ return await handleComplianceCheck(id, args, registry);
94
+ }
95
+ if (toolName === "huddle_list_jurisdictions") {
96
+ return handleListJurisdictions(id, registry);
97
+ }
98
+ if (toolName === "huddle_skill_metadata") {
99
+ return handleSkillMetadata(id, args, registry);
100
+ }
101
+ return {
102
+ jsonrpc: "2.0",
103
+ id,
104
+ error: { code: -32601, message: `Unknown tool: ${toolName}` },
105
+ };
106
+ }
107
+ default:
108
+ return {
109
+ jsonrpc: "2.0",
110
+ id,
111
+ error: { code: -32601, message: `Unknown method: ${method}` },
112
+ };
113
+ }
114
+ }
115
+ catch (err) {
116
+ return {
117
+ jsonrpc: "2.0",
118
+ id,
119
+ error: {
120
+ code: -32603,
121
+ message: err instanceof Error ? err.message : "Internal error",
122
+ },
123
+ };
124
+ }
125
+ }
126
+ async function handleComplianceCheck(id, args, registry) {
127
+ const jurisdiction = args.jurisdiction;
128
+ const skill = registry.get(jurisdiction);
129
+ if (!skill) {
130
+ return {
131
+ jsonrpc: "2.0",
132
+ id,
133
+ error: {
134
+ code: -32602,
135
+ message: `Unsupported jurisdiction: ${jurisdiction}. Use huddle_list_jurisdictions to see available options.`,
136
+ },
137
+ };
138
+ }
139
+ // Build SkillInput from MCP args
140
+ const input = {
141
+ type: args.type ?? "deposit-validation",
142
+ depositAmountCents: args.depositAmountCents ?? 0,
143
+ monthlyRentCents: args.monthlyRentCents ?? 0,
144
+ currency: args.currency ?? "USD",
145
+ ...args,
146
+ };
147
+ const result = await skill.validate(input);
148
+ const explanation = skill.explain(result);
149
+ return {
150
+ jsonrpc: "2.0",
151
+ id,
152
+ result: {
153
+ content: [
154
+ {
155
+ type: "text",
156
+ text: JSON.stringify({ ...result, explanation }, null, 2),
157
+ },
158
+ ],
159
+ },
160
+ };
161
+ }
162
+ function handleListJurisdictions(id, registry) {
163
+ const skills = registry.list().map((s) => ({
164
+ jurisdiction: s.jurisdiction,
165
+ name: s.name,
166
+ capabilities: s.capabilities,
167
+ version: s.version,
168
+ }));
169
+ return {
170
+ jsonrpc: "2.0",
171
+ id,
172
+ result: {
173
+ content: [
174
+ {
175
+ type: "text",
176
+ text: JSON.stringify({
177
+ total: skills.length,
178
+ jurisdictions: skills,
179
+ }, null, 2),
180
+ },
181
+ ],
182
+ },
183
+ };
184
+ }
185
+ function handleSkillMetadata(id, args, registry) {
186
+ const jurisdiction = args.jurisdiction;
187
+ const skill = registry.get(jurisdiction);
188
+ if (!skill) {
189
+ return {
190
+ jsonrpc: "2.0",
191
+ id,
192
+ error: {
193
+ code: -32602,
194
+ message: `Unknown jurisdiction: ${jurisdiction}`,
195
+ },
196
+ };
197
+ }
198
+ return {
199
+ jsonrpc: "2.0",
200
+ id,
201
+ result: {
202
+ content: [
203
+ {
204
+ type: "text",
205
+ text: JSON.stringify(skill.getMetadata(), null, 2),
206
+ },
207
+ ],
208
+ },
209
+ };
210
+ }
211
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAsCH;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO;QACL;YACE,IAAI,EAAE,yBAAyB;YAC/B,WAAW,EACT,yEAAyE;gBACzE,oEAAoE;gBACpE,sFAAsF;YACxF,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,YAAY,EAAE;wBACZ,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,uDAAuD;qBACrE;oBACD,IAAI,EAAE;wBACJ,IAAI,EAAE,QAAQ;wBACd,IAAI,EAAE,CAAC,oBAAoB,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,yBAAyB,CAAC;wBAC3H,WAAW,EAAE,qCAAqC;qBACnD;oBACD,kBAAkB,EAAE;wBAClB,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,yBAAyB;qBACvC;oBACD,gBAAgB,EAAE;w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AE,IAAI,CAAC,SAAS,CAAC;wBACnB,KAAK,EAAE,MAAM,CAAC,MAAM;wBACpB,aAAa,EAAE,MAAM;qBACtB,EAAE,IAAI,EAAE,CAAC,CAAC;iBACZ;aACF;SACF;KACF,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAC1B,EAAmB,EACnB,IAA6B,EAC7B,QAAuB;IAEvB,MAAM,YAAY,GAAG,IAAI,CAAC,YAAsB,CAAC;IACjD,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,YAAgC,CAAC,CAAC;IAE7D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO;YACL,OAAO,EAAE,KAAK;YACd,EAAE;YACF,KAAK,EAAE;gBACL,IAAI,EAAE,CAAC,KAAK;gBACZ,OAAO,EAAE,yBAAyB,YAAY,EAAE;aACjD;SACF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,KAAK;QACd,EAAE;QACF,MAAM,EAAE;YACN,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;iBACnD;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * SkillRegistry — Central registry for all Huddle compliance skills.
3
+ *
4
+ * Provides lookup by jurisdiction, search by capability, and auto-registration.
5
+ */
6
+ import type { HuddleSkill, SkillCapability, JurisdictionCode, SkillRegistryInterface } from "../types/index.js";
7
+ export declare class SkillRegistry implements SkillRegistryInterface {
8
+ private skills;
9
+ register(skill: HuddleSkill): void;
10
+ get(jurisdiction: JurisdictionCode): HuddleSkill | undefined;
11
+ list(): HuddleSkill[];
12
+ search(capabilities: SkillCapability[]): HuddleSkill[];
13
+ jurisdictions(): JurisdictionCode[];
14
+ isSupported(jurisdiction: string): boolean;
15
+ /** Get summary statistics */
16
+ stats(): {
17
+ total: number;
18
+ usStates: number;
19
+ caProvinces: number;
20
+ federal: number;
21
+ };
22
+ }
23
+ /**
24
+ * Create a registry with skills auto-registered.
25
+ */
26
+ export declare function createRegistry(skills: HuddleSkill[]): SkillRegistry;
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,aAAc,YAAW,sBAAsB;IAC1D,OAAO,CAAC,MAAM,CAAuC;IAErD,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAIlC,GAAG,CAAC,YAAY,EAAE,gBAAgB,GAAG,WAAW,GAAG,SAAS;IAI5D,IAAI,IAAI,WAAW,EAAE;IAIrB,MAAM,CAAC,YAAY,EAAE,eAAe,EAAE,GAAG,WAAW,EAAE;IAMtD,aAAa,IAAI,gBAAgB,EAAE;IAInC,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;IAI1C,6BAA6B;IAC7B,KAAK,IAAI;QACP,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;KACjB;CAWF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,aAAa,CAMnE"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * SkillRegistry — Central registry for all Huddle compliance skills.
3
+ *
4
+ * Provides lookup by jurisdiction, search by capability, and auto-registration.
5
+ */
6
+ export class SkillRegistry {
7
+ skills = new Map();
8
+ register(skill) {
9
+ this.skills.set(skill.jurisdiction, skill);
10
+ }
11
+ get(jurisdiction) {
12
+ return this.skills.get(jurisdiction);
13
+ }
14
+ list() {
15
+ return Array.from(this.skills.values());
16
+ }
17
+ search(capabilities) {
18
+ return this.list().filter((skill) => capabilities.every((cap) => skill.capabilities.includes(cap)));
19
+ }
20
+ jurisdictions() {
21
+ return Array.from(this.skills.keys());
22
+ }
23
+ isSupported(jurisdiction) {
24
+ return this.skills.has(jurisdiction);
25
+ }
26
+ /** Get summary statistics */
27
+ stats() {
28
+ const all = this.jurisdictions();
29
+ return {
30
+ total: all.length,
31
+ usStates: all.filter((j) => j.startsWith("US-") && j.length === 5).length,
32
+ caProvinces: all.filter((j) => j.startsWith("CA-")).length,
33
+ federal: all.filter((j) => ["US-CFTC", "US-CFPB", "US-OFAC", "CA-FINTRAC"].includes(j)).length,
34
+ };
35
+ }
36
+ }
37
+ /**
38
+ * Create a registry with skills auto-registered.
39
+ */
40
+ export function createRegistry(skills) {
41
+ const registry = new SkillRegistry();
42
+ for (const skill of skills) {
43
+ registry.register(skill);
44
+ }
45
+ return registry;
46
+ }
47
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,MAAM,OAAO,aAAa;IAChB,MAAM,GAA6B,IAAI,GAAG,EAAE,CAAC;IAErD,QAAQ,CAAC,KAAkB;QACzB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED,GAAG,CAAC,YAA8B;QAChC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;IAED,IAAI;QACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,CAAC,YAA+B;QACpC,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAClC,YAAY,CA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 /**
2
+ * TRAIGA Compliance Layer
3
+ *
4
+ * Automatically generates TRAIGA-compatible decision logs for every skill invocation.
5
+ * Pluggable storage: console (default), Supabase, or custom adapter.
6
+ *
7
+ * Every invocation is deterministic: same input → same output.
8
+ */
9
+ import type { HuddleSkill, TraigaDecisionLog, TraigaAdapter } from "../types/index.js";
10
+ /** Console adapter — logs to stdout */
11
+ export declare class ConsoleTraigaAdapter implements TraigaAdapter {
12
+ log(entry: TraigaDecisionLog): Promise<void>;
13
+ }
14
+ /**
15
+ * Create a TRAIGA-wrapped skill that logs every validation.
16
+ * The wrapped skill behaves identically but produces an audit trail.
17
+ */
18
+ export declare function withTraiga(skill: HuddleSkill, adapter?: TraigaAdapter, agentId?: string): HuddleSkill;
19
+ /**
20
+ * Wrap an entire registry's worth of skills with TRAIGA logging.
21
+ */
22
+ export declare function withTraigaAll(skills: HuddleSkill[], adapter?: TraigaAdapter, agentId?: string): HuddleSkill[];
23
+ export type { TraigaAdapter, TraigaDecisionLog };
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/traiga/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAGV,WAAW,EACX,iBAAiB,EACjB,aAAa,EACd,MAAM,mBAAmB,CAAC;AAc3B,uCAAuC;AACvC,qBAAa,oBAAqB,YAAW,aAAa;IAClD,GAAG,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;CAGnD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE,aAA0C,EACnD,OAAO,CAAC,EAAE,MAAM,GACf,WAAW,CAmCb;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,WAAW,EAAE,EACrB,OAAO,GAAE,aAA0C,EACnD,OAAO,CAAC,EAAE,MAAM,GACf,WAAW,EAAE,CAEf;AAED,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * TRAIGA Compliance Layer
3
+ *
4
+ * Automatically generates TRAIGA-compatible decision logs for every skill invocation.
5
+ * Pluggable storage: console (default), Supabase, or custom adapter.
6
+ *
7
+ * Every invocation is deterministic: same input → same output.
8
+ */
9
+ /** Simple hash function for deterministic input/output hashing */
10
+ function simpleHash(obj) {
11
+ const str = JSON.stringify(obj, Object.keys(obj).sort());
12
+ let hash = 0;
13
+ for (let i = 0; i < str.length; i++) {
14
+ const char = str.charCodeAt(i);
15
+ hash = ((hash << 5) - hash) + char;
16
+ hash |= 0;
17
+ }
18
+ return "0x" + (hash >>> 0).toString(16).padStart(8, "0");
19
+ }
20
+ /** Console adapter — logs to stdout */
21
+ export class ConsoleTraigaAdapter {
22
+ async log(entry) {
23
+ console.log("[TRAIGA]", JSON.stringify(entry));
24
+ }
25
+ }
26
+ /**
27
+ * Create a TRAIGA-wrapped skill that logs every validation.
28
+ * The wrapped skill behaves identically but produces an audit trail.
29
+ */
30
+ export function withTraiga(skill, adapter = new ConsoleTraigaAdapter(), agentId) {
31
+ const original = skill;
32
+ return {
33
+ ...original,
34
+ id: original.id,
35
+ name: original.name,
36
+ jurisdiction: original.jurisdiction,
37
+ version: original.version,
38
+ capabilities: original.capabilities,
39
+ async validate(input) {
40
+ const result = await original.validate(input);
41
+ const logEntry = {
42
+ timestamp: Date.now(),
43
+ skillId: original.id,
44
+ jurisdiction: original.jurisdiction,
45
+ inputHash: simpleHash(input),
46
+ outputHash: simpleHash(result),
47
+ decision: result.compliant ? "compliant" : "non-compliant",
48
+ confidence: result.confidence,
49
+ explanation: result.explanation ?? original.explain(result),
50
+ citations: result.citations,
51
+ agentId,
52
+ };
53
+ await adapter.log(logEntry);
54
+ return result;
55
+ },
56
+ explain: original.explain.bind(original),
57
+ remediate: original.remediate.bind(original),
58
+ getMetadata: original.getMetadata.bind(original),
59
+ };
60
+ }
61
+ /**
62
+ * Wrap an entire registry's worth of skills with TRAIGA logging.
63
+ */
64
+ export function withTraigaAll(skills, adapter = new ConsoleTraigaAdapter(), agentId) {
65
+ return skills.map((s) => withTraiga(s, adapter, agentId));
66
+ }
67
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/traiga/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH,kEAAkE;AAClE,SAAS,UAAU,CAAC,GAAY;IAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAa,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACnE,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC/B,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;QACnC,IAAI,IAAI,CAAC,CAAC;IACZ,CAAC;IACD,OAAO,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC3D,CAAC;AAED,uCAAuC;AACvC,MAAM,OAAO,oBAAoB;IAC/B,KAAK,CAAC,GAAG,CAAC,KAAwB;QAChC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IACjD,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CACxB,KAAkB,EAClB,UAAyB,IAAI,oBAAoB,EAAE,EACnD,OAAgB;IAEhB,MAAM,QAA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