a1-ai 2.8.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.
- package/dist/cjs/index.d.ts +373 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +574 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/integrations.d.ts +232 -0
- package/dist/cjs/integrations.d.ts.map +1 -0
- package/dist/cjs/integrations.js +368 -0
- package/dist/cjs/integrations.js.map +1 -0
- package/dist/cjs/middleware.d.ts +159 -0
- package/dist/cjs/middleware.d.ts.map +1 -0
- package/dist/cjs/middleware.js +207 -0
- package/dist/cjs/middleware.js.map +1 -0
- package/dist/cjs/passport.d.ts +109 -0
- package/dist/cjs/passport.d.ts.map +1 -0
- package/dist/cjs/passport.js +158 -0
- package/dist/cjs/passport.js.map +1 -0
- package/dist/cjs/swarm.d.ts +78 -0
- package/dist/cjs/swarm.d.ts.map +1 -0
- package/dist/cjs/swarm.js +125 -0
- package/dist/cjs/swarm.js.map +1 -0
- package/dist/esm/index.d.ts +373 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +562 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/integrations.d.ts +232 -0
- package/dist/esm/integrations.d.ts.map +1 -0
- package/dist/esm/integrations.js +358 -0
- package/dist/esm/integrations.js.map +1 -0
- package/dist/esm/middleware.d.ts +159 -0
- package/dist/esm/middleware.d.ts.map +1 -0
- package/dist/esm/middleware.js +201 -0
- package/dist/esm/middleware.js.map +1 -0
- package/dist/esm/passport.d.ts +109 -0
- package/dist/esm/passport.d.ts.map +1 -0
- package/dist/esm/passport.js +151 -0
- package/dist/esm/passport.js.map +1 -0
- package/dist/esm/swarm.d.ts +78 -0
- package/dist/esm/swarm.d.ts.map +1 -0
- package/dist/esm/swarm.js +120 -0
- package/dist/esm/swarm.js.map +1 -0
- package/package.json +112 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* a1 integrations for LangChain.js and the OpenAI Agents SDK.
|
|
3
|
+
*
|
|
4
|
+
* Guards every tool call so that no delegated action executes unless the full
|
|
5
|
+
* cryptographic chain-of-custody is verified first. Both single-intent and
|
|
6
|
+
* multi-intent (batch) authorization patterns are supported.
|
|
7
|
+
*/
|
|
8
|
+
import { A1Client, SignedChain, AuthorizeResult, BatchAuthorizeResult } from "./index.js";
|
|
9
|
+
/** Context attached to every guarded tool invocation. */
|
|
10
|
+
export interface A1GuardContext {
|
|
11
|
+
/** The agent's delegation chain in wire format. */
|
|
12
|
+
chain: SignedChain;
|
|
13
|
+
/** The agent's Ed25519 public key (hex). */
|
|
14
|
+
executorPkHex: string;
|
|
15
|
+
/** Optional intent parameter overrides. */
|
|
16
|
+
intentParams?: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
export type GuardedToolFn<TArgs, TReturn> = (args: TArgs, a1: AuthorizeResult) => Promise<TReturn>;
|
|
19
|
+
export interface LangChainA1ToolOptions {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
intentName: string;
|
|
23
|
+
client: A1Client;
|
|
24
|
+
resolveContext: (rawInput: string) => A1GuardContext;
|
|
25
|
+
run: (rawInput: string, auth: AuthorizeResult) => Promise<string>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Wrap a LangChain tool with a a1 single-intent authorization gate.
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* const tool = buildLangChainA1Tool({
|
|
32
|
+
* name: "execute_trade",
|
|
33
|
+
* description: "Execute an equity trade",
|
|
34
|
+
* intentName: "trade.equity",
|
|
35
|
+
* client: a1Client,
|
|
36
|
+
* resolveContext: (input) => ({ chain: agentChain, executorPkHex: agentPk }),
|
|
37
|
+
* run: async (input, auth) => {
|
|
38
|
+
* const { symbol, qty } = JSON.parse(input);
|
|
39
|
+
* await broker.trade(symbol, qty);
|
|
40
|
+
* return `Executed. Chain depth: ${auth.chainDepth}`;
|
|
41
|
+
* },
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function buildLangChainA1Tool(opts: LangChainA1ToolOptions): {
|
|
46
|
+
name: string;
|
|
47
|
+
description: string;
|
|
48
|
+
call(rawInput: string): Promise<string>;
|
|
49
|
+
};
|
|
50
|
+
export interface LangChainA1BatchToolOptions {
|
|
51
|
+
name: string;
|
|
52
|
+
description: string;
|
|
53
|
+
/** All intents that must be authorized before the tool runs. */
|
|
54
|
+
intentNames: string[];
|
|
55
|
+
client: A1Client;
|
|
56
|
+
resolveContext: (rawInput: string) => A1GuardContext;
|
|
57
|
+
run: (rawInput: string, auth: BatchAuthorizeResult) => Promise<string>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Wrap a LangChain tool with a a1 batch-intent authorization gate.
|
|
61
|
+
*
|
|
62
|
+
* All listed intents are verified atomically in a single round-trip. If any
|
|
63
|
+
* intent fails, the tool does not execute.
|
|
64
|
+
*
|
|
65
|
+
* ```ts
|
|
66
|
+
* const tool = buildLangChainA1BatchTool({
|
|
67
|
+
* name: "portfolio_rebalance",
|
|
68
|
+
* description: "Query portfolio and execute trades",
|
|
69
|
+
* intentNames: ["query.portfolio", "trade.equity"],
|
|
70
|
+
* client: a1Client,
|
|
71
|
+
* resolveContext: (input) => ({ chain: agentChain, executorPkHex: agentPk }),
|
|
72
|
+
* run: async (input, auth) => {
|
|
73
|
+
* if (!auth.allAuthorized) throw new Error("Not all intents authorized");
|
|
74
|
+
* return "Rebalanced.";
|
|
75
|
+
* },
|
|
76
|
+
* });
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare function buildLangChainA1BatchTool(opts: LangChainA1BatchToolOptions): {
|
|
80
|
+
name: string;
|
|
81
|
+
description: string;
|
|
82
|
+
call(rawInput: string): Promise<string>;
|
|
83
|
+
};
|
|
84
|
+
export interface OpenAIA1FunctionOptions<TArgs extends object> {
|
|
85
|
+
name: string;
|
|
86
|
+
description: string;
|
|
87
|
+
parameters: Record<string, unknown>;
|
|
88
|
+
intentName: string;
|
|
89
|
+
client: A1Client;
|
|
90
|
+
resolveContext: (args: TArgs) => A1GuardContext;
|
|
91
|
+
execute: (args: TArgs, auth: AuthorizeResult) => Promise<unknown>;
|
|
92
|
+
}
|
|
93
|
+
export interface OpenAIA1Function<TArgs extends object> {
|
|
94
|
+
definition: {
|
|
95
|
+
type: "function";
|
|
96
|
+
function: {
|
|
97
|
+
name: string;
|
|
98
|
+
description: string;
|
|
99
|
+
parameters: Record<string, unknown>;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
handler: (argsJson: string) => Promise<string>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Build a guarded OpenAI function tool (single-intent variant).
|
|
106
|
+
*
|
|
107
|
+
* ```ts
|
|
108
|
+
* const tradeFn = buildOpenAIA1Function({
|
|
109
|
+
* name: "execute_trade",
|
|
110
|
+
* description: "Execute an equity trade on behalf of the user",
|
|
111
|
+
* parameters: { type: "object", properties: { symbol: { type: "string" } } },
|
|
112
|
+
* intentName: "trade.equity",
|
|
113
|
+
* client: a1Client,
|
|
114
|
+
* resolveContext: (args) => ({ chain: agentChain, executorPkHex: agentPk }),
|
|
115
|
+
* execute: async (args, auth) => ({ ok: true, chain_depth: auth.chainDepth }),
|
|
116
|
+
* });
|
|
117
|
+
* const output = await tradeFn.handler(toolCall.function.arguments);
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export declare function buildOpenAIA1Function<TArgs extends object>(opts: OpenAIA1FunctionOptions<TArgs>): OpenAIA1Function<TArgs>;
|
|
121
|
+
export interface OpenAIA1BatchFunctionOptions<TArgs extends object> {
|
|
122
|
+
name: string;
|
|
123
|
+
description: string;
|
|
124
|
+
parameters: Record<string, unknown>;
|
|
125
|
+
/** All intents that must be authorized before the function executes. */
|
|
126
|
+
intentNames: string[];
|
|
127
|
+
client: A1Client;
|
|
128
|
+
resolveContext: (args: TArgs) => A1GuardContext;
|
|
129
|
+
execute: (args: TArgs, auth: BatchAuthorizeResult) => Promise<unknown>;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Build a guarded OpenAI function tool that requires multiple intents to be
|
|
133
|
+
* authorized atomically in a single round-trip (batch variant).
|
|
134
|
+
*
|
|
135
|
+
* Use this when a single tool action spans multiple intent domains — for
|
|
136
|
+
* example a rebalancing tool that must be authorized for both `query.portfolio`
|
|
137
|
+
* and `trade.equity` before either read or write is permitted.
|
|
138
|
+
*
|
|
139
|
+
* ```ts
|
|
140
|
+
* const rebalanceFn = buildOpenAIA1BatchFunction({
|
|
141
|
+
* name: "rebalance_portfolio",
|
|
142
|
+
* description: "Query and rebalance a portfolio",
|
|
143
|
+
* parameters: { type: "object", properties: { risk_level: { type: "string" } } },
|
|
144
|
+
* intentNames: ["query.portfolio", "trade.equity"],
|
|
145
|
+
* client: a1Client,
|
|
146
|
+
* resolveContext: (args) => ({ chain: agentChain, executorPkHex: agentPk }),
|
|
147
|
+
* execute: async (args, auth) => ({ rebalanced: true, intents: auth.authorizedCount }),
|
|
148
|
+
* });
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
export declare function buildOpenAIA1BatchFunction<TArgs extends object>(opts: OpenAIA1BatchFunctionOptions<TArgs>): OpenAIA1Function<TArgs>;
|
|
152
|
+
/**
|
|
153
|
+
* Middleware factory for Microsoft AutoGen agents — single intent.
|
|
154
|
+
*
|
|
155
|
+
* ```ts
|
|
156
|
+
* const guardedTrade = withA1Guard({
|
|
157
|
+
* intentName: "trade.equity",
|
|
158
|
+
* client: a1Client,
|
|
159
|
+
* resolveContext: (args) => ({ chain: agentChain, executorPkHex: agentPk }),
|
|
160
|
+
* fn: async (args) => broker.trade(args.symbol, args.qty),
|
|
161
|
+
* });
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
export declare function withA1Guard<TArgs extends Record<string, unknown>, TReturn>(opts: {
|
|
165
|
+
intentName: string;
|
|
166
|
+
client: A1Client;
|
|
167
|
+
resolveContext: (args: TArgs) => A1GuardContext;
|
|
168
|
+
fn: (args: TArgs, auth: AuthorizeResult) => Promise<TReturn>;
|
|
169
|
+
}): (args: TArgs) => Promise<TReturn>;
|
|
170
|
+
/**
|
|
171
|
+
* Middleware factory for Microsoft AutoGen agents — batch intents.
|
|
172
|
+
*
|
|
173
|
+
* All listed intents are verified atomically. The wrapped function only
|
|
174
|
+
* receives a `BatchAuthorizeResult` with `allAuthorized === true`.
|
|
175
|
+
*
|
|
176
|
+
* ```ts
|
|
177
|
+
* const guardedRebalance = withA1BatchGuard({
|
|
178
|
+
* intentNames: ["query.portfolio", "trade.equity"],
|
|
179
|
+
* client: a1Client,
|
|
180
|
+
* resolveContext: (args) => ({ chain: agentChain, executorPkHex: agentPk }),
|
|
181
|
+
* fn: async (args, auth) => rebalancer.run(args),
|
|
182
|
+
* });
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
export declare function withA1BatchGuard<TArgs extends Record<string, unknown>, TReturn>(opts: {
|
|
186
|
+
intentNames: string[];
|
|
187
|
+
client: A1Client;
|
|
188
|
+
resolveContext: (args: TArgs) => A1GuardContext;
|
|
189
|
+
fn: (args: TArgs, auth: BatchAuthorizeResult) => Promise<TReturn>;
|
|
190
|
+
}): (args: TArgs) => Promise<TReturn>;
|
|
191
|
+
export interface LangGraphA1NodeOptions<TState> {
|
|
192
|
+
intentName: string;
|
|
193
|
+
client: A1Client;
|
|
194
|
+
resolveContext: (state: TState) => A1GuardContext;
|
|
195
|
+
node: (state: TState, auth: AuthorizeResult) => Promise<Partial<TState>>;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Wraps a LangGraph node so it is authorized before state mutation.
|
|
199
|
+
*
|
|
200
|
+
* ```ts
|
|
201
|
+
* const guardedTradeNode = withDyoloLangGraphNode({
|
|
202
|
+
* intentName: "trade.equity",
|
|
203
|
+
* client: a1Client,
|
|
204
|
+
* resolveContext: (state) => ({ chain: state.chain, executorPkHex: agentPk }),
|
|
205
|
+
* node: async (state, auth) => ({ ...state, result: await executeTrade(state) }),
|
|
206
|
+
* });
|
|
207
|
+
*
|
|
208
|
+
* const graph = new StateGraph(...)
|
|
209
|
+
* .addNode("execute_trade", guardedTradeNode);
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
export declare function withDyoloLangGraphNode<TState extends Record<string, unknown>>(opts: LangGraphA1NodeOptions<TState>): (state: TState) => Promise<Partial<TState>>;
|
|
213
|
+
export interface SemanticKernelA1Options<TArgs, TReturn> {
|
|
214
|
+
intentName: string;
|
|
215
|
+
client: A1Client;
|
|
216
|
+
resolveContext: (args: TArgs) => A1GuardContext;
|
|
217
|
+
fn: (args: TArgs, auth: AuthorizeResult) => Promise<TReturn>;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Wraps a Semantic Kernel plugin function with a1 authorization.
|
|
221
|
+
*
|
|
222
|
+
* ```ts
|
|
223
|
+
* const guardedFn = withDyoloSkFunction({
|
|
224
|
+
* intentName: "execute_trade",
|
|
225
|
+
* client: a1Client,
|
|
226
|
+
* resolveContext: (args) => ({ chain: args.chain, executorPkHex: agentPk }),
|
|
227
|
+
* fn: async (args, auth) => tradeService.execute(args),
|
|
228
|
+
* });
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
export declare function withDyoloSkFunction<TArgs extends Record<string, unknown>, TReturn>(opts: SemanticKernelA1Options<TArgs, TReturn>): (args: TArgs) => Promise<TReturn>;
|
|
232
|
+
//# sourceMappingURL=integrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integrations.d.ts","sourceRoot":"","sources":["../../src/integrations.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAW,WAAW,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAInG,yDAAyD;AACzD,MAAM,WAAW,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AAC;IACjB,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,cAAc,CAAC;IAClD,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,KAAK,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;CAC1E;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3E,IAAI,EAAE,sBAAsB,CAAC,MAAM,CAAC,GACnC,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAgB7C;AAID,MAAM,WAAW,uBAAuB,CAAC,KAAK,EAAE,OAAO;IACrD,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,QAAQ,CAAC;IACjB,cAAc,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,cAAc,CAAC;IAChD,EAAE,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,eAAe,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAChF,IAAI,EAAE,uBAAuB,CAAC,KAAK,EAAE,OAAO,CAAC,GAC5C,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC,CAgBnC"}
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* a1 integrations for LangChain.js and the OpenAI Agents SDK.
|
|
4
|
+
*
|
|
5
|
+
* Guards every tool call so that no delegated action executes unless the full
|
|
6
|
+
* cryptographic chain-of-custody is verified first. Both single-intent and
|
|
7
|
+
* multi-intent (batch) authorization patterns are supported.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.buildLangChainA1Tool = buildLangChainA1Tool;
|
|
11
|
+
exports.buildLangChainA1BatchTool = buildLangChainA1BatchTool;
|
|
12
|
+
exports.buildOpenAIA1Function = buildOpenAIA1Function;
|
|
13
|
+
exports.buildOpenAIA1BatchFunction = buildOpenAIA1BatchFunction;
|
|
14
|
+
exports.withA1Guard = withA1Guard;
|
|
15
|
+
exports.withA1BatchGuard = withA1BatchGuard;
|
|
16
|
+
exports.withDyoloLangGraphNode = withDyoloLangGraphNode;
|
|
17
|
+
exports.withDyoloSkFunction = withDyoloSkFunction;
|
|
18
|
+
const index_js_1 = require("./index.js");
|
|
19
|
+
/**
|
|
20
|
+
* Wrap a LangChain tool with a a1 single-intent authorization gate.
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* const tool = buildLangChainA1Tool({
|
|
24
|
+
* name: "execute_trade",
|
|
25
|
+
* description: "Execute an equity trade",
|
|
26
|
+
* intentName: "trade.equity",
|
|
27
|
+
* client: a1Client,
|
|
28
|
+
* resolveContext: (input) => ({ chain: agentChain, executorPkHex: agentPk }),
|
|
29
|
+
* run: async (input, auth) => {
|
|
30
|
+
* const { symbol, qty } = JSON.parse(input);
|
|
31
|
+
* await broker.trade(symbol, qty);
|
|
32
|
+
* return `Executed. Chain depth: ${auth.chainDepth}`;
|
|
33
|
+
* },
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
function buildLangChainA1Tool(opts) {
|
|
38
|
+
return {
|
|
39
|
+
name: opts.name,
|
|
40
|
+
description: opts.description,
|
|
41
|
+
async call(rawInput) {
|
|
42
|
+
const ctx = opts.resolveContext(rawInput);
|
|
43
|
+
let auth;
|
|
44
|
+
try {
|
|
45
|
+
auth = await opts.client.authorize({
|
|
46
|
+
chain: ctx.chain,
|
|
47
|
+
intentName: opts.intentName,
|
|
48
|
+
intentParams: ctx.intentParams,
|
|
49
|
+
executorPkHex: ctx.executorPkHex,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
if (err instanceof index_js_1.A1Error) {
|
|
54
|
+
throw new Error(`[a1] Authorization denied for intent "${opts.intentName}": ${err.message} (${err.code ?? "unknown"})`);
|
|
55
|
+
}
|
|
56
|
+
throw err;
|
|
57
|
+
}
|
|
58
|
+
return opts.run(rawInput, auth);
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Wrap a LangChain tool with a a1 batch-intent authorization gate.
|
|
64
|
+
*
|
|
65
|
+
* All listed intents are verified atomically in a single round-trip. If any
|
|
66
|
+
* intent fails, the tool does not execute.
|
|
67
|
+
*
|
|
68
|
+
* ```ts
|
|
69
|
+
* const tool = buildLangChainA1BatchTool({
|
|
70
|
+
* name: "portfolio_rebalance",
|
|
71
|
+
* description: "Query portfolio and execute trades",
|
|
72
|
+
* intentNames: ["query.portfolio", "trade.equity"],
|
|
73
|
+
* client: a1Client,
|
|
74
|
+
* resolveContext: (input) => ({ chain: agentChain, executorPkHex: agentPk }),
|
|
75
|
+
* run: async (input, auth) => {
|
|
76
|
+
* if (!auth.allAuthorized) throw new Error("Not all intents authorized");
|
|
77
|
+
* return "Rebalanced.";
|
|
78
|
+
* },
|
|
79
|
+
* });
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
function buildLangChainA1BatchTool(opts) {
|
|
83
|
+
return {
|
|
84
|
+
name: opts.name,
|
|
85
|
+
description: opts.description,
|
|
86
|
+
async call(rawInput) {
|
|
87
|
+
const ctx = opts.resolveContext(rawInput);
|
|
88
|
+
let auth;
|
|
89
|
+
try {
|
|
90
|
+
auth = await opts.client.authorizeBatch({
|
|
91
|
+
chain: ctx.chain,
|
|
92
|
+
executorPkHex: ctx.executorPkHex,
|
|
93
|
+
intents: opts.intentNames.map((name) => ({
|
|
94
|
+
name,
|
|
95
|
+
params: ctx.intentParams,
|
|
96
|
+
})),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
if (err instanceof index_js_1.A1Error) {
|
|
101
|
+
throw new Error(`[a1] Batch authorization denied for intents [${opts.intentNames.join(", ")}]: ${err.message}${err.code ? ` (${err.code})` : ""}`);
|
|
102
|
+
}
|
|
103
|
+
throw err;
|
|
104
|
+
}
|
|
105
|
+
if (!auth.allAuthorized) {
|
|
106
|
+
const denied = auth.results
|
|
107
|
+
.filter((r) => !r.authorized)
|
|
108
|
+
.map((r) => `${r.intentName}: ${r.error ?? "denied"}`)
|
|
109
|
+
.join("; ");
|
|
110
|
+
throw new Error(`[a1] Batch authorization failed — ${denied}`);
|
|
111
|
+
}
|
|
112
|
+
return opts.run(rawInput, auth);
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Build a guarded OpenAI function tool (single-intent variant).
|
|
118
|
+
*
|
|
119
|
+
* ```ts
|
|
120
|
+
* const tradeFn = buildOpenAIA1Function({
|
|
121
|
+
* name: "execute_trade",
|
|
122
|
+
* description: "Execute an equity trade on behalf of the user",
|
|
123
|
+
* parameters: { type: "object", properties: { symbol: { type: "string" } } },
|
|
124
|
+
* intentName: "trade.equity",
|
|
125
|
+
* client: a1Client,
|
|
126
|
+
* resolveContext: (args) => ({ chain: agentChain, executorPkHex: agentPk }),
|
|
127
|
+
* execute: async (args, auth) => ({ ok: true, chain_depth: auth.chainDepth }),
|
|
128
|
+
* });
|
|
129
|
+
* const output = await tradeFn.handler(toolCall.function.arguments);
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
function buildOpenAIA1Function(opts) {
|
|
133
|
+
return {
|
|
134
|
+
definition: {
|
|
135
|
+
type: "function",
|
|
136
|
+
function: {
|
|
137
|
+
name: opts.name,
|
|
138
|
+
description: opts.description,
|
|
139
|
+
parameters: opts.parameters,
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
async handler(argsJson) {
|
|
143
|
+
let args;
|
|
144
|
+
try {
|
|
145
|
+
args = JSON.parse(argsJson);
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
return JSON.stringify({ error: "Invalid arguments JSON" });
|
|
149
|
+
}
|
|
150
|
+
const ctx = opts.resolveContext(args);
|
|
151
|
+
let auth;
|
|
152
|
+
try {
|
|
153
|
+
auth = await opts.client.authorize({
|
|
154
|
+
chain: ctx.chain,
|
|
155
|
+
intentName: opts.intentName,
|
|
156
|
+
intentParams: ctx.intentParams,
|
|
157
|
+
executorPkHex: ctx.executorPkHex,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
catch (err) {
|
|
161
|
+
if (err instanceof index_js_1.A1Error) {
|
|
162
|
+
return JSON.stringify({ error: `Authorization denied: ${err.message}`, code: err.code });
|
|
163
|
+
}
|
|
164
|
+
return JSON.stringify({ error: "Authorization check failed" });
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
const result = await opts.execute(args, auth);
|
|
168
|
+
return JSON.stringify(result);
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
return JSON.stringify({ error: err.message });
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Build a guarded OpenAI function tool that requires multiple intents to be
|
|
178
|
+
* authorized atomically in a single round-trip (batch variant).
|
|
179
|
+
*
|
|
180
|
+
* Use this when a single tool action spans multiple intent domains — for
|
|
181
|
+
* example a rebalancing tool that must be authorized for both `query.portfolio`
|
|
182
|
+
* and `trade.equity` before either read or write is permitted.
|
|
183
|
+
*
|
|
184
|
+
* ```ts
|
|
185
|
+
* const rebalanceFn = buildOpenAIA1BatchFunction({
|
|
186
|
+
* name: "rebalance_portfolio",
|
|
187
|
+
* description: "Query and rebalance a portfolio",
|
|
188
|
+
* parameters: { type: "object", properties: { risk_level: { type: "string" } } },
|
|
189
|
+
* intentNames: ["query.portfolio", "trade.equity"],
|
|
190
|
+
* client: a1Client,
|
|
191
|
+
* resolveContext: (args) => ({ chain: agentChain, executorPkHex: agentPk }),
|
|
192
|
+
* execute: async (args, auth) => ({ rebalanced: true, intents: auth.authorizedCount }),
|
|
193
|
+
* });
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
function buildOpenAIA1BatchFunction(opts) {
|
|
197
|
+
return {
|
|
198
|
+
definition: {
|
|
199
|
+
type: "function",
|
|
200
|
+
function: {
|
|
201
|
+
name: opts.name,
|
|
202
|
+
description: opts.description,
|
|
203
|
+
parameters: opts.parameters,
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
async handler(argsJson) {
|
|
207
|
+
let args;
|
|
208
|
+
try {
|
|
209
|
+
args = JSON.parse(argsJson);
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
return JSON.stringify({ error: "Invalid arguments JSON" });
|
|
213
|
+
}
|
|
214
|
+
const ctx = opts.resolveContext(args);
|
|
215
|
+
let auth;
|
|
216
|
+
try {
|
|
217
|
+
auth = await opts.client.authorizeBatch({
|
|
218
|
+
chain: ctx.chain,
|
|
219
|
+
executorPkHex: ctx.executorPkHex,
|
|
220
|
+
intents: opts.intentNames.map((name) => ({
|
|
221
|
+
name,
|
|
222
|
+
params: ctx.intentParams,
|
|
223
|
+
})),
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
catch (err) {
|
|
227
|
+
if (err instanceof index_js_1.A1Error) {
|
|
228
|
+
return JSON.stringify({ error: `Batch authorization denied: ${err.message}`, code: err.code });
|
|
229
|
+
}
|
|
230
|
+
return JSON.stringify({ error: "Batch authorization check failed" });
|
|
231
|
+
}
|
|
232
|
+
if (!auth.allAuthorized) {
|
|
233
|
+
const denied = auth.results
|
|
234
|
+
.filter((r) => !r.authorized)
|
|
235
|
+
.map((r) => `${r.intentName}: ${r.error ?? "denied"}`)
|
|
236
|
+
.join("; ");
|
|
237
|
+
return JSON.stringify({ error: `Batch authorization failed — ${denied}` });
|
|
238
|
+
}
|
|
239
|
+
try {
|
|
240
|
+
const result = await opts.execute(args, auth);
|
|
241
|
+
return JSON.stringify(result);
|
|
242
|
+
}
|
|
243
|
+
catch (err) {
|
|
244
|
+
return JSON.stringify({ error: err.message });
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
// ── AutoGen (ag2) — single intent ─────────────────────────────────────────────
|
|
250
|
+
/**
|
|
251
|
+
* Middleware factory for Microsoft AutoGen agents — single intent.
|
|
252
|
+
*
|
|
253
|
+
* ```ts
|
|
254
|
+
* const guardedTrade = withA1Guard({
|
|
255
|
+
* intentName: "trade.equity",
|
|
256
|
+
* client: a1Client,
|
|
257
|
+
* resolveContext: (args) => ({ chain: agentChain, executorPkHex: agentPk }),
|
|
258
|
+
* fn: async (args) => broker.trade(args.symbol, args.qty),
|
|
259
|
+
* });
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
function withA1Guard(opts) {
|
|
263
|
+
return async (args) => {
|
|
264
|
+
const ctx = opts.resolveContext(args);
|
|
265
|
+
const auth = await opts.client.authorize({
|
|
266
|
+
chain: ctx.chain,
|
|
267
|
+
intentName: opts.intentName,
|
|
268
|
+
intentParams: ctx.intentParams,
|
|
269
|
+
executorPkHex: ctx.executorPkHex,
|
|
270
|
+
});
|
|
271
|
+
return opts.fn(args, auth);
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
// ── AutoGen (ag2) — batch intents ─────────────────────────────────────────────
|
|
275
|
+
/**
|
|
276
|
+
* Middleware factory for Microsoft AutoGen agents — batch intents.
|
|
277
|
+
*
|
|
278
|
+
* All listed intents are verified atomically. The wrapped function only
|
|
279
|
+
* receives a `BatchAuthorizeResult` with `allAuthorized === true`.
|
|
280
|
+
*
|
|
281
|
+
* ```ts
|
|
282
|
+
* const guardedRebalance = withA1BatchGuard({
|
|
283
|
+
* intentNames: ["query.portfolio", "trade.equity"],
|
|
284
|
+
* client: a1Client,
|
|
285
|
+
* resolveContext: (args) => ({ chain: agentChain, executorPkHex: agentPk }),
|
|
286
|
+
* fn: async (args, auth) => rebalancer.run(args),
|
|
287
|
+
* });
|
|
288
|
+
* ```
|
|
289
|
+
*/
|
|
290
|
+
function withA1BatchGuard(opts) {
|
|
291
|
+
return async (args) => {
|
|
292
|
+
const ctx = opts.resolveContext(args);
|
|
293
|
+
const auth = await opts.client.authorizeBatch({
|
|
294
|
+
chain: ctx.chain,
|
|
295
|
+
executorPkHex: ctx.executorPkHex,
|
|
296
|
+
intents: opts.intentNames.map((name) => ({
|
|
297
|
+
name,
|
|
298
|
+
params: ctx.intentParams,
|
|
299
|
+
})),
|
|
300
|
+
});
|
|
301
|
+
if (!auth.allAuthorized) {
|
|
302
|
+
const denied = auth.results
|
|
303
|
+
.filter((r) => !r.authorized)
|
|
304
|
+
.map((r) => r.intentName)
|
|
305
|
+
.join(", ");
|
|
306
|
+
throw new index_js_1.A1Error(`Batch authorization failed for intents: ${denied}`);
|
|
307
|
+
}
|
|
308
|
+
return opts.fn(args, auth);
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Wraps a LangGraph node so it is authorized before state mutation.
|
|
313
|
+
*
|
|
314
|
+
* ```ts
|
|
315
|
+
* const guardedTradeNode = withDyoloLangGraphNode({
|
|
316
|
+
* intentName: "trade.equity",
|
|
317
|
+
* client: a1Client,
|
|
318
|
+
* resolveContext: (state) => ({ chain: state.chain, executorPkHex: agentPk }),
|
|
319
|
+
* node: async (state, auth) => ({ ...state, result: await executeTrade(state) }),
|
|
320
|
+
* });
|
|
321
|
+
*
|
|
322
|
+
* const graph = new StateGraph(...)
|
|
323
|
+
* .addNode("execute_trade", guardedTradeNode);
|
|
324
|
+
* ```
|
|
325
|
+
*/
|
|
326
|
+
function withDyoloLangGraphNode(opts) {
|
|
327
|
+
return async (state) => {
|
|
328
|
+
const ctx = opts.resolveContext(state);
|
|
329
|
+
const auth = await opts.client.authorize({
|
|
330
|
+
chain: ctx.chain,
|
|
331
|
+
executorPkHex: ctx.executorPkHex,
|
|
332
|
+
intentName: opts.intentName,
|
|
333
|
+
intentParams: ctx.intentParams,
|
|
334
|
+
});
|
|
335
|
+
if (!auth.authorized) {
|
|
336
|
+
throw new index_js_1.A1Error(`LangGraph node '${opts.intentName}' authorization denied: ${"authorization denied"}`);
|
|
337
|
+
}
|
|
338
|
+
return opts.node(state, auth);
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Wraps a Semantic Kernel plugin function with a1 authorization.
|
|
343
|
+
*
|
|
344
|
+
* ```ts
|
|
345
|
+
* const guardedFn = withDyoloSkFunction({
|
|
346
|
+
* intentName: "execute_trade",
|
|
347
|
+
* client: a1Client,
|
|
348
|
+
* resolveContext: (args) => ({ chain: args.chain, executorPkHex: agentPk }),
|
|
349
|
+
* fn: async (args, auth) => tradeService.execute(args),
|
|
350
|
+
* });
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
function withDyoloSkFunction(opts) {
|
|
354
|
+
return async (args) => {
|
|
355
|
+
const ctx = opts.resolveContext(args);
|
|
356
|
+
const auth = await opts.client.authorize({
|
|
357
|
+
chain: ctx.chain,
|
|
358
|
+
executorPkHex: ctx.executorPkHex,
|
|
359
|
+
intentName: opts.intentName,
|
|
360
|
+
intentParams: ctx.intentParams,
|
|
361
|
+
});
|
|
362
|
+
if (!auth.authorized) {
|
|
363
|
+
throw new index_js_1.A1Error(`Semantic Kernel function '${opts.intentName}' authorization denied: ${"authorization denied"}`);
|
|
364
|
+
}
|
|
365
|
+
return opts.fn(args, auth);
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
//# sourceMappingURL=integrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integrations.js","sourceRoot":"","sources":["../../src/integrations.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAkDH,oDA4BC;AAkCD,8DAsCC;AA0CD,sDA8CC;AAm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