@armoriq/sdk-dev 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ArmorIQ Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,204 @@
1
+ # ArmorIQ SDK (TypeScript)
2
+
3
+ **Build secure AI agents with cryptographic intent verification.**
4
+
5
+ The ArmorIQ SDK enables developers to build AI agents with built-in security and auditability. Just one API key - no cloud complexity.
6
+
7
+ ---
8
+
9
+ ## Why ArmorIQ?
10
+
11
+ - **Simple** - Just one API key, no cloud credentials
12
+ - **Secure** - Cryptographic verification for every action
13
+ - **Auditable** - Complete execution trail
14
+ - **Fast** - Get started in 5 minutes
15
+
16
+ ---
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install @armoriq/sdk
22
+ # or
23
+ yarn add @armoriq/sdk
24
+ ```
25
+
26
+ ---
27
+
28
+ ## Quick Start
29
+
30
+ ### 1. Get Your API Key
31
+
32
+ Visit [platform.armoriq.ai](https://platform.armoriq.ai) to generate your API key.
33
+
34
+ ### 2. Initialize the Client
35
+
36
+ ```typescript
37
+ import { ArmorIQClient } from '@armoriq/sdk';
38
+
39
+ const client = new ArmorIQClient({
40
+ apiKey: 'ak_your_key_here',
41
+ userId: 'your-user-id',
42
+ agentId: 'your-agent-id',
43
+ });
44
+ ```
45
+
46
+ ### 3. Capture Your Plan
47
+
48
+ ```typescript
49
+ const plan = {
50
+ goal: 'Get weather forecast',
51
+ steps: [
52
+ {
53
+ action: 'get_weather',
54
+ tool: 'weather_api',
55
+ mcp: 'weather-mcp',
56
+ inputs: { city: 'Boston' },
57
+ },
58
+ ],
59
+ };
60
+
61
+ const planCapture = client.capturePlan('gpt-4', "What's the weather in Boston?", plan);
62
+ ```
63
+
64
+ ### 4. Get Intent Token
65
+
66
+ ```typescript
67
+ const token = await client.getIntentToken(planCapture);
68
+ ```
69
+
70
+ ### 5. Invoke Actions
71
+
72
+ ```typescript
73
+ const result = await client.invoke('weather-mcp', 'get_weather', token, {
74
+ city: 'Boston',
75
+ });
76
+
77
+ console.log(result);
78
+ ```
79
+
80
+ ---
81
+
82
+ ## Environment Variables
83
+
84
+ ```bash
85
+ # Required
86
+ ARMORIQ_API_KEY=ak_your_key_here
87
+ USER_ID=your-user-id
88
+ AGENT_ID=your-agent-id
89
+
90
+ # Optional
91
+ ARMORIQ_ENV=production # or 'development' for local
92
+ CONTEXT_ID=default
93
+ IAP_ENDPOINT=https://customer-iap.armoriq.ai
94
+ PROXY_ENDPOINT=https://customer-proxy.armoriq.ai
95
+ BACKEND_ENDPOINT=https://customer-api.armoriq.ai
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Advanced Usage
101
+
102
+ ### Delegation
103
+
104
+ ```typescript
105
+ import * as crypto from 'crypto';
106
+
107
+ // Generate delegate keypair
108
+ const { publicKey, privateKey } = crypto.generateKeyPairSync('ed25519');
109
+ const pubKeyHex = publicKey.export({ type: 'spki', format: 'der' }).toString('hex');
110
+
111
+ const delegation = await client.delegate(token, pubKeyHex, 1800);
112
+ console.log(`Delegated token: ${delegation.delegatedToken.tokenId}`);
113
+ ```
114
+
115
+ ### Custom Proxy Endpoints
116
+
117
+ ```typescript
118
+ const client = new ArmorIQClient({
119
+ apiKey: 'ak_your_key_here',
120
+ userId: 'user-123',
121
+ agentId: 'agent-456',
122
+ proxyEndpoints: {
123
+ 'weather-mcp': 'https://weather-proxy.example.com',
124
+ 'finance-mcp': 'https://finance-proxy.example.com',
125
+ },
126
+ });
127
+ ```
128
+
129
+ ### Error Handling
130
+
131
+ ```typescript
132
+ import {
133
+ InvalidTokenException,
134
+ IntentMismatchException,
135
+ MCPInvocationException,
136
+ TokenExpiredException,
137
+ } from '@armoriq/sdk';
138
+
139
+ try {
140
+ const result = await client.invoke('weather-mcp', 'get_weather', token, { city: 'Boston' });
141
+ } catch (error) {
142
+ if (error instanceof TokenExpiredException) {
143
+ console.error('Token expired, please get a new one');
144
+ } else if (error instanceof IntentMismatchException) {
145
+ console.error('Action not in original plan');
146
+ } else if (error instanceof MCPInvocationException) {
147
+ console.error('MCP invocation failed:', error.message);
148
+ }
149
+ }
150
+ ```
151
+
152
+ ---
153
+
154
+ ## API Reference
155
+
156
+ ### `ArmorIQClient`
157
+
158
+ #### Constructor Options
159
+
160
+ ```typescript
161
+ interface SDKConfig {
162
+ apiKey: string; // Required: Your API key
163
+ userId: string; // Required: User identifier
164
+ agentId: string; // Required: Agent identifier
165
+ contextId?: string; // Optional: Context identifier (default: 'default')
166
+ useProduction?: boolean; // Optional: Use production endpoints (default: true)
167
+ iapEndpoint?: string; // Optional: Override IAP endpoint
168
+ proxyEndpoint?: string; // Optional: Override proxy endpoint
169
+ backendEndpoint?: string; // Optional: Override backend endpoint
170
+ proxyEndpoints?: Record<string, string>; // Optional: MCP-specific proxies
171
+ timeout?: number; // Optional: Request timeout in ms (default: 30000)
172
+ maxRetries?: number; // Optional: Max retry attempts (default: 3)
173
+ verifySsl?: boolean; // Optional: Verify SSL (default: true)
174
+ }
175
+ ```
176
+
177
+ #### Methods
178
+
179
+ - `capturePlan(llm, prompt, plan, metadata?)` - Capture an execution plan
180
+ - `getIntentToken(planCapture, policy?, validitySeconds?)` - Get a signed intent token
181
+ - `invoke(mcp, action, intentToken, params?, merkleProof?, userEmail?)` - Invoke an MCP action
182
+ - `delegate(intentToken, delegatePublicKey, validitySeconds?, allowedActions?, targetAgent?, subtask?)` - Delegate to another agent
183
+ - `verifyToken(intentToken)` - Verify a token locally
184
+ - `close()` - Cleanup resources
185
+
186
+ ---
187
+
188
+ ## Documentation
189
+
190
+ For complete documentation, visit [docs.armoriq.ai](https://docs.armoriq.ai)
191
+
192
+ ---
193
+
194
+ ## Links
195
+
196
+ - [armoriq.ai](https://armoriq.ai)
197
+ - [docs.armoriq.ai](https://docs.armoriq.ai)
198
+ - [platform.armoriq.ai](https://platform.armoriq.ai)
199
+
200
+ ---
201
+
202
+ ## License
203
+
204
+ MIT License - see [LICENSE](LICENSE) file for details.
@@ -0,0 +1,135 @@
1
+ /**
2
+ * ArmorIQ SDK Client - Main entry point for SDK usage.
3
+ */
4
+ import { IntentToken, PlanCapture, MCPInvocationResult, DelegationResult, SDKConfig, MCPSemanticMetadata, InvokeOptions, DelegationRequestParams, DelegationRequestResult, ApprovedDelegation } from './models';
5
+ /**
6
+ * Main client for ArmorIQ SDK.
7
+ *
8
+ * Provides high-level APIs for:
9
+ * - Plan capture and canonicalization
10
+ * - Intent token management
11
+ * - MCP action invocation
12
+ * - Agent delegation
13
+ */
14
+ export declare class ArmorIQClient {
15
+ private static readonly DEFAULT_IAP_ENDPOINT;
16
+ private static readonly DEFAULT_PROXY_ENDPOINT;
17
+ private static readonly DEFAULT_BACKEND_ENDPOINT;
18
+ private static readonly ARMORCLAW_IAP_ENDPOINT;
19
+ private static readonly ARMORCLAW_PROXY_ENDPOINT;
20
+ private static readonly ARMORCLAW_BACKEND_ENDPOINT;
21
+ private static readonly LOCAL_IAP_ENDPOINT;
22
+ private static readonly LOCAL_PROXY_ENDPOINT;
23
+ private static readonly LOCAL_BACKEND_ENDPOINT;
24
+ private static readonly LOCAL_ARMORCLAW_IAP_ENDPOINT;
25
+ private static readonly LOCAL_ARMORCLAW_PROXY_ENDPOINT;
26
+ private static readonly LOCAL_ARMORCLAW_BACKEND_ENDPOINT;
27
+ private iapEndpoint;
28
+ private defaultProxyEndpoint;
29
+ private backendEndpoint;
30
+ private proxyEndpoints;
31
+ private userId;
32
+ private agentId;
33
+ private contextId;
34
+ private apiKey;
35
+ private timeout;
36
+ private maxRetries;
37
+ private verifySsl;
38
+ private httpClient;
39
+ private tokenCache;
40
+ private metadataCache;
41
+ constructor(options?: Partial<SDKConfig> & {
42
+ apiKey?: string;
43
+ useProduction?: boolean;
44
+ });
45
+ /**
46
+ * Get the default proxy endpoint URL.
47
+ */
48
+ get proxyEndpoint(): string;
49
+ /**
50
+ * Validate API key with the proxy server.
51
+ */
52
+ private validateApiKey;
53
+ /**
54
+ * Capture an execution plan structure.
55
+ */
56
+ capturePlan(llm: string, prompt: string, plan?: Record<string, any>, metadata?: Record<string, any>): PlanCapture;
57
+ /**
58
+ * Request a signed intent token from IAP for the given plan.
59
+ */
60
+ getIntentToken(planCapture: PlanCapture, policy?: Record<string, any>, validitySeconds?: number): Promise<IntentToken>;
61
+ /**
62
+ * Invoke an MCP action through the ArmorIQ proxy with token verification.
63
+ */
64
+ invoke(mcp: string, action: string, intentToken: IntentToken, params?: Record<string, any>, merkleProof?: Array<Record<string, any>>, userEmail?: string): Promise<MCPInvocationResult>;
65
+ /**
66
+ * Delegate authority to another agent using CSRG token delegation.
67
+ */
68
+ delegate(intentToken: IntentToken, delegatePublicKey: string, validitySeconds?: number, allowedActions?: string[], targetAgent?: string, subtask?: Record<string, any>): Promise<DelegationResult>;
69
+ /**
70
+ * Verify an intent token with IAP.
71
+ */
72
+ verifyToken(intentToken: IntentToken): Promise<boolean>;
73
+ /**
74
+ * Fetch and cache semantic tool metadata for an MCP server.
75
+ */
76
+ fetchToolMetadata(mcpName: string): Promise<MCPSemanticMetadata>;
77
+ /**
78
+ * Eagerly load metadata for an MCP so subsequent invoke() calls are fast.
79
+ */
80
+ loadMcp(mcpName: string): Promise<void>;
81
+ /**
82
+ * List all MCPs registered for this org (resolved via API key).
83
+ */
84
+ listMcps(): Promise<Array<{
85
+ mcpId: string;
86
+ name: string;
87
+ url: string;
88
+ }>>;
89
+ /**
90
+ * Get full OpenAI-compatible tool schemas for a named MCP.
91
+ */
92
+ getMcpToolSchemas(mcpName: string): Promise<any[]>;
93
+ /**
94
+ * Enrich policy context from semantic metadata for a tool invocation.
95
+ */
96
+ private enrichPolicyContext;
97
+ /**
98
+ * Resolve an org role to a domain-specific role for an MCP.
99
+ */
100
+ resolveRole(mcpName: string, orgRole: string): Promise<string>;
101
+ /**
102
+ * Resolve the user's role and limit from the backend for delegation.
103
+ */
104
+ private resolveUserRole;
105
+ /**
106
+ * Create a delegation request on the backend.
107
+ */
108
+ createDelegationRequest(params: DelegationRequestParams): Promise<DelegationRequestResult>;
109
+ /**
110
+ * Check if a delegation request has been approved.
111
+ */
112
+ checkApprovedDelegation(userEmail: string, tool: string, amount: number): Promise<ApprovedDelegation | null>;
113
+ /**
114
+ * Mark a delegation as executed.
115
+ */
116
+ markDelegationExecuted(userEmail: string, delegationId: string): Promise<void>;
117
+ /**
118
+ * Mark an intent plan as completed after all tools have been executed.
119
+ */
120
+ completePlan(planId: string): Promise<void>;
121
+ /**
122
+ * Update an intent plan's status.
123
+ * Valid statuses: 'active', 'completed', 'failed', 'expired'
124
+ */
125
+ updatePlanStatus(planId: string, status: string): Promise<void>;
126
+ /**
127
+ * Enhanced invoke with automatic policy context enrichment and delegation handling.
128
+ */
129
+ invokeWithPolicy(mcp: string, action: string, intentToken: IntentToken, params?: Record<string, any>, options?: InvokeOptions): Promise<MCPInvocationResult>;
130
+ /**
131
+ * Close HTTP client and cleanup resources.
132
+ */
133
+ close(): void;
134
+ }
135
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EACL,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,SAAS,EACT,mBAAmB,EAEnB,aAAa,EACb,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAEnB,MAAM,UAAU,CAAC;AAYlB;;;;;;;;GAQG;AACH,qBAAa,aAAa;IAExB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAA4B;IACxE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,sBAAsB,CAAwC;IACtF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAoC;IAGpF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,sBAAsB,CAA8B;IAC5E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAgC;IAChF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,0BAA0B,CAA8B;IAGhF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAA2B;IACrE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAA2B;IACvE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,sBAAsB,CAA2B;IAGzE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,4BAA4B,CAA2B;IAC/E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,8BAA8B,CAA2B;IACjF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gCAAgC,CAA2B;IAEnF,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,oBAAoB,CAAS;IACrC,OAAO,CAAC,eAAe,CAAS;IAChC,O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