@armoriq/sdk-dev 0.2.13 → 0.2.14

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 (63) hide show
  1. package/README.md +3 -3
  2. package/dist/_build_env.d.ts +33 -0
  3. package/dist/_build_env.d.ts.map +1 -0
  4. package/dist/_build_env.js +47 -0
  5. package/dist/_build_env.js.map +1 -0
  6. package/dist/client.d.ts.map +1 -1
  7. package/dist/client.js +34 -12
  8. package/dist/client.js.map +1 -1
  9. package/dist/credentials.d.ts.map +1 -0
  10. package/dist/credentials.js.map +1 -0
  11. package/package.json +2 -7
  12. package/dist/cli/commands/login.d.ts +0 -4
  13. package/dist/cli/commands/login.d.ts.map +0 -1
  14. package/dist/cli/commands/login.js +0 -221
  15. package/dist/cli/commands/login.js.map +0 -1
  16. package/dist/cli/commands/logout.d.ts +0 -2
  17. package/dist/cli/commands/logout.d.ts.map +0 -1
  18. package/dist/cli/commands/logout.js +0 -14
  19. package/dist/cli/commands/logout.js.map +0 -1
  20. package/dist/cli/commands/whoami.d.ts +0 -2
  21. package/dist/cli/commands/whoami.d.ts.map +0 -1
  22. package/dist/cli/commands/whoami.js +0 -22
  23. package/dist/cli/commands/whoami.js.map +0 -1
  24. package/dist/cli/credentials.d.ts.map +0 -1
  25. package/dist/cli/credentials.js.map +0 -1
  26. package/dist/cli/index.d.ts +0 -3
  27. package/dist/cli/index.d.ts.map +0 -1
  28. package/dist/cli/index.js +0 -33
  29. package/dist/cli/index.js.map +0 -1
  30. package/dist/integrations/anthropic.d.ts +0 -18
  31. package/dist/integrations/anthropic.d.ts.map +0 -1
  32. package/dist/integrations/anthropic.js +0 -27
  33. package/dist/integrations/anthropic.js.map +0 -1
  34. package/dist/integrations/crewai.d.ts +0 -68
  35. package/dist/integrations/crewai.d.ts.map +0 -1
  36. package/dist/integrations/crewai.js +0 -178
  37. package/dist/integrations/crewai.js.map +0 -1
  38. package/dist/integrations/google-adk.d.ts +0 -72
  39. package/dist/integrations/google-adk.d.ts.map +0 -1
  40. package/dist/integrations/google-adk.js +0 -260
  41. package/dist/integrations/google-adk.js.map +0 -1
  42. package/dist/integrations/index.d.ts +0 -29
  43. package/dist/integrations/index.d.ts.map +0 -1
  44. package/dist/integrations/index.js +0 -37
  45. package/dist/integrations/index.js.map +0 -1
  46. package/dist/integrations/langchain.d.ts +0 -20
  47. package/dist/integrations/langchain.d.ts.map +0 -1
  48. package/dist/integrations/langchain.js +0 -28
  49. package/dist/integrations/langchain.js.map +0 -1
  50. package/dist/integrations/openai.d.ts +0 -19
  51. package/dist/integrations/openai.d.ts.map +0 -1
  52. package/dist/integrations/openai.js +0 -28
  53. package/dist/integrations/openai.js.map +0 -1
  54. package/dist/plan-builder.d.ts +0 -36
  55. package/dist/plan-builder.d.ts.map +0 -1
  56. package/dist/plan-builder.js +0 -98
  57. package/dist/plan-builder.js.map +0 -1
  58. package/dist/session.d.ts +0 -152
  59. package/dist/session.d.ts.map +0 -1
  60. package/dist/session.js +0 -547
  61. package/dist/session.js.map +0 -1
  62. /package/dist/{cli/credentials.d.ts → credentials.d.ts} +0 -0
  63. /package/dist/{cli/credentials.js → credentials.js} +0 -0
package/dist/session.d.ts DELETED
@@ -1,152 +0,0 @@
1
- /**
2
- * ArmorIQSession — the core primitive for framework integrations.
3
- *
4
- * Two modes:
5
- *
6
- * 1. Observe mode (default, new) — MCP stays on the agent side:
7
- * await session.startPlan(toolCalls) // capture plan + mint token
8
- * const decision = await session.enforce(toolName, toolArgs) // check policy
9
- * // ... framework calls MCP directly ...
10
- * await session.report(toolName, toolArgs, result) // audit
11
- *
12
- * 2. Proxy mode (legacy) — routes through the Armoriq proxy:
13
- * await session.startPlan(toolCalls)
14
- * return session.dispatch(toolName, toolArgs) // proxy handles everything
15
- */
16
- import { ArmorIQClient } from './client';
17
- import { IntentToken, ToolCall } from './models';
18
- import { ToolNameParser } from './plan-builder';
19
- export type SessionMode = 'local' | 'proxy';
20
- export interface SessionOptions {
21
- toolNameParser?: ToolNameParser;
22
- defaultMcpName?: string;
23
- validitySeconds?: number;
24
- llm?: string;
25
- /**
26
- * Where the policy decision is evaluated.
27
- * - 'local' (default): SDK verifies the intent token signature in-process
28
- * and evaluates the policy snapshot locally. NO network call to the
29
- * proxy on the tool-call hot path.
30
- * - 'proxy': SDK calls the proxy with enforce_only=true. Useful when
31
- * you want centralized real-time policy decisions or shared rate limits.
32
- */
33
- mode?: SessionMode;
34
- }
35
- export interface EnforceResult {
36
- allowed: boolean;
37
- action: 'allow' | 'block' | 'hold';
38
- reason?: string;
39
- delegationId?: string;
40
- matchedPolicy?: string;
41
- }
42
- export interface ReportOptions {
43
- status?: 'success' | 'failed' | 'error';
44
- errorMessage?: string;
45
- durationMs?: number;
46
- isDelegated?: boolean;
47
- delegatedBy?: string;
48
- delegatedTo?: string;
49
- }
50
- export declare class ArmorIQSession {
51
- private client;
52
- private toolNameParser;
53
- private defaultMcpName?;
54
- private validitySeconds;
55
- private llm;
56
- private mode;
57
- private stepIndex;
58
- private currentPlanHash;
59
- private currentTokenValue;
60
- private mcpByAction;
61
- private declaredTools;
62
- private static publicKeyCache;
63
- constructor(client: ArmorIQClient, opts?: SessionOptions);
64
- /**
65
- * Capture a plan from the LLM's tool calls and mint an intent token.
66
- * Idempotent: if called again with the same tool-calls list (by SHA),
67
- * skips the mint and returns the cached token.
68
- */
69
- startPlan(toolCalls: ToolCall[], opts?: {
70
- goal?: string;
71
- }): Promise<IntentToken>;
72
- /**
73
- * Local-mode enforcement.
74
- * Verifies the intent token's lifetime, plan-binding, and the
75
- * policy snapshot — all in-process. NO network call to the proxy.
76
- *
77
- * Returns { allowed, action, reason }. Plugin uses this to short-
78
- * circuit the framework's tool dispatch on a deny.
79
- */
80
- enforceLocal(toolName: string, toolArgs: Record<string, unknown>): Promise<EnforceResult>;
81
- /**
82
- * Check policy for a tool call BEFORE the agent executes it.
83
- * Calls POST /iap/enforce on the backend.
84
- * Returns { allowed, action, reason }. The framework plugin uses this
85
- * to block or let through — the MCP call itself happens on the agent side.
86
- */
87
- enforce(toolName: string, toolArgs: Record<string, unknown>): Promise<EnforceResult>;
88
- /**
89
- * Report a tool execution to the audit log AFTER the agent calls the MCP.
90
- * Calls POST /iap/audit on the backend.
91
- */
92
- report(toolName: string, toolArgs: Record<string, unknown>, result: unknown, opts?: ReportOptions): Promise<void>;
93
- /**
94
- * [Proxy mode] Route a tool call through the Armoriq proxy.
95
- * Returns the raw result so the framework can short-circuit
96
- * its native dispatch. Use this when the proxy handles the
97
- * upstream MCP connection (e.g. Claude Desktop, Cursor).
98
- */
99
- dispatch(toolName: string, toolArgs: Record<string, unknown>): Promise<unknown>;
100
- /**
101
- * Mode-aware enforcement entry point. Plugins should call this and
102
- * not branch themselves — `mode` on the session decides the path.
103
- *
104
- * Behavior by mode:
105
- * - 'local' → allow / block ONLY. In-process, no network calls.
106
- * A 'hold' threshold violation is reported as 'block'
107
- * with an explanatory reason. Use proxy mode if you
108
- * need delegation/approval workflows.
109
- * - 'proxy' → allow / block / hold. The proxy resolves the hold
110
- * via the delegation pipeline (request → approve → re-run).
111
- */
112
- check(toolName: string, toolArgs: Record<string, unknown>, opts?: {
113
- userEmail?: string;
114
- }): Promise<EnforceResult>;
115
- /**
116
- * Handle a 'hold' decision: check for prior approval, otherwise
117
- * create a delegation request. Returns either:
118
- * - allowed: true (prior approval found within window)
119
- * - allowed: false, action: 'hold', delegationId (request created or pending)
120
- */
121
- private handleHold;
122
- /**
123
- * Best-effort extraction of an amount field from arbitrary tool args.
124
- * Used as a FALLBACK when the platform hasn't declared per-tool
125
- * metadata. Fully MCP-agnostic — only checks generic field names.
126
- */
127
- private extractAmount;
128
- /**
129
- * Resolve the canonical "amount" for a tool call:
130
- * 1. Try platform-declared tool metadata (amountFields + amountUnit)
131
- * — same source the proxy uses (toolMetadata column on MCPServer,
132
- * authored in the armorpay UI). MCP-specific units like 'cents'
133
- * are normalized HERE, not in the SDK.
134
- * 2. Fall back to the generic candidate-field extractor.
135
- */
136
- private resolveCanonicalAmount;
137
- /**
138
- * Evaluate an amount-threshold rule from the policy snapshot against
139
- * the tool args. Returns:
140
- * - undefined if no threshold or amount-not-applicable
141
- * - { allowed: false, action: 'block' } if amount > maxPerTransaction
142
- * - { allowed: false, action: 'hold' } if amount > requireApprovalAbove
143
- */
144
- private evaluateAmountThreshold;
145
- /** Drop cached plan + token so the next startPlan() always mints fresh. */
146
- reset(): void;
147
- /** Inspect the currently held intent token (for debugging / audit). */
148
- get currentToken(): IntentToken | null;
149
- /** Current session mode ('local' default, 'proxy' opt-in). */
150
- get currentMode(): SessionMode;
151
- }
152
- //# sourceMappingURL=session.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,WAAW,EAAuB,QAAQ,EAAE,MAAM,UAAU,CAAC;AACtE,OAAO,EACL,cAAc,EAIf,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,OAAO,CAAC;AAE5C,MAAM,WAAW,cAAc;IAC7B,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,SA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