@aroha-sdk/langchain-bridge 1.0.0 → 1.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.
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Aroha ↔ LangChain/AutoGen Bridge
3
+ *
4
+ * Aroha is the transport and identity layer. Your existing agent framework
5
+ * (LangChain, AutoGen, Semantic Kernel, LlamaIndex) keeps its reasoning,
6
+ * memory, and tool-calling logic unchanged.
7
+ *
8
+ * This bridge lets you:
9
+ * 1. Expose LangChain tools as Aroha capabilities (so other Aroha agents
10
+ * can discover and call your tools with signed envelopes).
11
+ * 2. Wrap Aroha capabilities as LangChain tools (so your LangChain agent
12
+ * can call remote Aroha agents transparently).
13
+ */
14
+ import { ArohaClient, ArohaServer, type ArohaServerOptions } from "@aroha-sdk/core";
15
+ import { type LangChainToolLike, type OpenAIFunctionLike, type ArohaCapabilityDescriptor } from "./types.js";
16
+ export interface ArohaCapabilityToToolOptions {
17
+ /** The Aroha endpoint URL of the remote agent. */
18
+ endpoint: string;
19
+ /** The DID of the remote agent (the "to" field). */
20
+ agentDID: string;
21
+ /** DID of the calling agent (the "from" field). */
22
+ callerDID: string;
23
+ /** Ed25519 private key of the calling agent for signing envelopes. */
24
+ callerPrivateKey: Uint8Array;
25
+ /** Human-readable description used by the LLM to decide when to call this tool. */
26
+ description: string;
27
+ /** JSON Schema for the capability's params. Optional. */
28
+ schema?: Record<string, unknown>;
29
+ client?: ArohaClient;
30
+ }
31
+ /**
32
+ * Wrap a single Aroha capability as a LangChain-compatible tool.
33
+ *
34
+ * The returned tool sends a signed ArohaRequest to the remote agent and
35
+ * returns the JSON-serialised result as a string (what LangChain expects).
36
+ */
37
+ export declare function arohaCapabilityToLangChainTool(capabilityId: string, opts: ArohaCapabilityToToolOptions): LangChainToolLike;
38
+ /**
39
+ * Wrap a single Aroha capability as an OpenAI function tool.
40
+ * Compatible with AutoGen, Semantic Kernel, and GPT-4 tool calling.
41
+ */
42
+ export declare function arohaCapabilityToOpenAITool(capabilityId: string, opts: ArohaCapabilityToToolOptions): OpenAIFunctionLike;
43
+ export interface LangChainAgentToArohaOptions {
44
+ agentDID: string;
45
+ agentPrivateKey: Uint8Array;
46
+ port: number;
47
+ resolvePublicKey: ArohaServerOptions["resolvePublicKey"];
48
+ didDocument: ArohaServerOptions["didDocument"];
49
+ }
50
+ /**
51
+ * Expose a set of LangChain tools as a Aroha provider agent.
52
+ *
53
+ * Each tool becomes a Aroha capability. Inbound ArohaRequest envelopes are
54
+ * routed to the matching tool. The tool's string result is returned as a
55
+ * ArohaResponse.
56
+ *
57
+ * Returns the ArohaServer — call .start() to begin accepting connections.
58
+ */
59
+ export declare function langChainAgentToArohaProvider(tools: LangChainToolLike[], opts: LangChainAgentToArohaOptions): ArohaServer;
60
+ /**
61
+ * Convert a LangChain tool list to Aroha capability descriptors.
62
+ * Use these to register the agent in InMemoryRegistry or ArohaRegistry.
63
+ */
64
+ export declare function langChainToolsToCapabilities(tools: LangChainToolLike[]): ArohaCapabilityDescriptor[];
65
+ //# sourceMappingURL=bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,WAAW,EACX,WAAW,EAIX,KAAK,kBAAkB,EAIxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC/B,MAAM,YAAY,CAAC;AAIpB,MAAM,WAAW,4BAA4B;IAC3C,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,sEAAsE;IACtE,gBAAgB,EAAE,UAAU,CAAC;IAC7B,mFAAmF;IACnF,WAAW,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,4BAA4B,GACjC,iBAAiB,CAiCnB;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,4BAA4B,GACjC,kBAAkB,CAcpB;AAID,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,UAAU,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,kBAAkB,CAAC,kBAAkB,CAAC,CAAC;IACzD,WAAW,EAAE,kBAAkB,CAAC,aAAa,CAAC,CAAC;CAChD;AAED;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,iBAAiB,EAAE,EAC1B,IAAI,EAAE,4BAA4B,GACjC,WAAW,CAiEb;AAID;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,iBAAiB,EAAE,GACzB,yBAAyB,EAAE,CAM7B"}
package/dist/bridge.js ADDED
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Aroha ↔ LangChain/AutoGen Bridge
3
+ *
4
+ * Aroha is the transport and identity layer. Your existing agent framework
5
+ * (LangChain, AutoGen, Semantic Kernel, LlamaIndex) keeps its reasoning,
6
+ * memory, and tool-calling logic unchanged.
7
+ *
8
+ * This bridge lets you:
9
+ * 1. Expose LangChain tools as Aroha capabilities (so other Aroha agents
10
+ * can discover and call your tools with signed envelopes).
11
+ * 2. Wrap Aroha capabilities as LangChain tools (so your LangChain agent
12
+ * can call remote Aroha agents transparently).
13
+ */
14
+ import { ArohaClient, ArohaServer, buildEnvelope, newCorrelationId, } from "@aroha-sdk/core";
15
+ /**
16
+ * Wrap a single Aroha capability as a LangChain-compatible tool.
17
+ *
18
+ * The returned tool sends a signed ArohaRequest to the remote agent and
19
+ * returns the JSON-serialised result as a string (what LangChain expects).
20
+ */
21
+ export function arohaCapabilityToLangChainTool(capabilityId, opts) {
22
+ const client = opts.client ?? new ArohaClient();
23
+ return {
24
+ name: capabilityId.replace(/[^a-zA-Z0-9_-]/g, "_"),
25
+ description: opts.description,
26
+ schema: opts.schema,
27
+ async call(input) {
28
+ const params = typeof input === "string" ? JSON.parse(input) : input;
29
+ const body = { capability: capabilityId, params };
30
+ const correlationId = newCorrelationId();
31
+ const envelope = await buildEnvelope("ArohaRequest", opts.callerDID, opts.agentDID, body, correlationId, opts.callerPrivateKey);
32
+ const response = await client.send(opts.endpoint, envelope);
33
+ if (!response)
34
+ throw new Error(`No response from ${opts.agentDID}`);
35
+ if (response.type === "ArohaError") {
36
+ throw new Error(response.body.message);
37
+ }
38
+ const result = response.body.result;
39
+ return typeof result === "string" ? result : JSON.stringify(result);
40
+ },
41
+ };
42
+ }
43
+ /**
44
+ * Wrap a single Aroha capability as an OpenAI function tool.
45
+ * Compatible with AutoGen, Semantic Kernel, and GPT-4 tool calling.
46
+ */
47
+ export function arohaCapabilityToOpenAITool(capabilityId, opts) {
48
+ const langChainTool = arohaCapabilityToLangChainTool(capabilityId, opts);
49
+ return {
50
+ type: "function",
51
+ function: {
52
+ name: langChainTool.name,
53
+ description: langChainTool.description,
54
+ parameters: opts.schema,
55
+ },
56
+ async invoke(args) {
57
+ const result = await langChainTool.call(args);
58
+ try {
59
+ return JSON.parse(result);
60
+ }
61
+ catch {
62
+ return result;
63
+ }
64
+ },
65
+ };
66
+ }
67
+ /**
68
+ * Expose a set of LangChain tools as a Aroha provider agent.
69
+ *
70
+ * Each tool becomes a Aroha capability. Inbound ArohaRequest envelopes are
71
+ * routed to the matching tool. The tool's string result is returned as a
72
+ * ArohaResponse.
73
+ *
74
+ * Returns the ArohaServer — call .start() to begin accepting connections.
75
+ */
76
+ export function langChainAgentToArohaProvider(tools, opts) {
77
+ const toolMap = new Map(tools.map((t) => [t.name, t]));
78
+ const onMessage = async (envelope, respond) => {
79
+ if (envelope.type !== "ArohaRequest")
80
+ return;
81
+ const body = envelope.body;
82
+ const tool = toolMap.get(body.capability);
83
+ if (!tool) {
84
+ const errEnvelope = await buildEnvelope("ArohaError", opts.agentDID, envelope.from, {
85
+ code: "Aroha_UNKNOWN_CAPABILITY",
86
+ message: `Unknown capability: ${body.capability}`,
87
+ retryable: false,
88
+ }, envelope.correlationId, opts.agentPrivateKey);
89
+ respond(errEnvelope);
90
+ return;
91
+ }
92
+ try {
93
+ const rawResult = await tool.call(body.params);
94
+ let result;
95
+ try {
96
+ result = JSON.parse(rawResult);
97
+ }
98
+ catch {
99
+ result = { output: rawResult };
100
+ }
101
+ const responseBody = { capability: body.capability, result };
102
+ const reply = await buildEnvelope("ArohaResponse", opts.agentDID, envelope.from, responseBody, envelope.correlationId, opts.agentPrivateKey);
103
+ respond(reply);
104
+ }
105
+ catch (err) {
106
+ const errEnvelope = await buildEnvelope("ArohaError", opts.agentDID, envelope.from, {
107
+ code: "Aroha_INTERNAL_ERROR",
108
+ message: String(err),
109
+ retryable: true,
110
+ }, envelope.correlationId, opts.agentPrivateKey);
111
+ respond(errEnvelope);
112
+ }
113
+ };
114
+ return new ArohaServer({
115
+ agentDID: opts.agentDID,
116
+ didDocument: opts.didDocument,
117
+ port: opts.port,
118
+ onMessage,
119
+ resolvePublicKey: opts.resolvePublicKey,
120
+ });
121
+ }
122
+ // ─── Describe Aroha capabilities ──────────────────────────────────────────────
123
+ /**
124
+ * Convert a LangChain tool list to Aroha capability descriptors.
125
+ * Use these to register the agent in InMemoryRegistry or ArohaRegistry.
126
+ */
127
+ export function langChainToolsToCapabilities(tools) {
128
+ return tools.map((t) => ({
129
+ capabilityId: t.name,
130
+ description: t.description,
131
+ inputSchema: t.schema,
132
+ }));
133
+ }
134
+ //# sourceMappingURL=bridge.js.map
@@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sBAA+B;gBACrC,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC;gBACpB,SAAS,EAAE,IAAI;aAChB,EACD,QAAQ,CAAC,aAAa,EACtB,IAAI,CAAC,eAAe,CACrB,CAAC;YACF,OAAO,CAAC,WAAW,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,IAAI,WAAW,CAAC;QACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,SAAS;QACT,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;KACxC,CAAC,CAAC;AACL,CAAC;AAED,iFAAiF;AAEjF;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAC1C,KAA0B;IAE1B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACvB,YAAY,EAAE,CAAC,CAAC,IAAI;QACpB,WAAW,EAAE,CAAC,CAAC,WAAW;QAC1B,WAAW,EAAE,CAAC,CAAC,MAAM;KACtB,CAAC,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bridge.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.test.d.ts","sourceRoot":"","sources":["../src/bridge.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,208 @@
1
+ import { describe, it, expect, vi } from "vitest";
2
+ import { arohaCapabilityToLangChainTool, arohaCapabilityToOpenAITool, langChainToolsToCapabilities, langChainAgentToArohaProvider, } from "./bridge.js";
3
+ import { ArohaServer, generateDID } from "@aroha-sdk/core";
4
+ // ─── Helpers ──────────────────────────────────────────────────────────────────
5
+ function makeTool(name, description = "A test tool", result = "tool result") {
6
+ return {
7
+ name,
8
+ description,
9
+ call: vi.fn().mockResolvedValue(result),
10
+ };
11
+ }
12
+ // ─── langChainToolsToCapabilities ────────────────────────────────────────────
13
+ describe("langChainToolsToCapabilities", () => {
14
+ it("maps each tool to a ArohaCapabilityDescriptor", () => {
15
+ const tools = [
16
+ makeTool("search-flights", "Search for available flights"),
17
+ makeTool("search-hotels", "Search for hotels"),
18
+ ];
19
+ const caps = langChainToolsToCapabilities(tools);
20
+ expect(caps).toHaveLength(2);
21
+ expect(caps[0].capabilityId).toBe("search-flights");
22
+ expect(caps[0].description).toBe("Search for available flights");
23
+ expect(caps[1].capabilityId).toBe("search-hotels");
24
+ });
25
+ it("passes through the tool schema when present", () => {
26
+ const schema = { type: "object", properties: { q: { type: "string" } } };
27
+ const tools = [{ name: "search", description: "d", schema, call: vi.fn() }];
28
+ const caps = langChainToolsToCapabilities(tools);
29
+ expect(caps[0].inputSchema).toEqual(schema);
30
+ });
31
+ it("sets inputSchema to undefined when the tool has no schema", () => {
32
+ const caps = langChainToolsToCapabilities([makeTool("no-schema")]);
33
+ expect(caps[0].inputSchema).toBeUndefined();
34
+ });
35
+ it("returns an empty array for an empty tool list", () => {
36
+ expect(langChainToolsToCapabilities([])).toEqual([]);
37
+ });
38
+ });
39
+ // ─── arohaCapabilityToLangChainTool ────────────────────────────────────────────
40
+ describe("arohaCapabilityToLangChainTool", () => {
41
+ it("returns a tool with the correct name (sanitised to word-chars)", () => {
42
+ const tool = arohaCapabilityToLangChainTool("search-flights", {
43
+ endpoint: "http://localhost:3001",
44
+ agentDID: "did:aroha:remote",
45
+ callerDID: "did:aroha:caller",
46
+ callerPrivateKey: new Uint8Array(32),
47
+ description: "Search flights",
48
+ client: { send: vi.fn() },
49
+ });
50
+ // Hyphens are replaced with underscores by the sanitiser
51
+ expect(tool.name).toMatch(/^[a-zA-Z0-9_-]+$/);
52
+ });
53
+ it("returns the provided description", () => {
54
+ const tool = arohaCapabilityToLangChainTool("cap", {
55
+ endpoint: "http://localhost:3001",
56
+ agentDID: "did:aroha:remote",
57
+ callerDID: "did:aroha:caller",
58
+ callerPrivateKey: new Uint8Array(32),
59
+ description: "Does something useful",
60
+ client: { send: vi.fn() },
61
+ });
62
+ expect(tool.description).toBe("Does something useful");
63
+ });
64
+ it("passes through the schema option", () => {
65
+ const schema = { type: "object" };
66
+ const tool = arohaCapabilityToLangChainTool("cap", {
67
+ endpoint: "http://localhost:3001",
68
+ agentDID: "did:aroha:remote",
69
+ callerDID: "did:aroha:caller",
70
+ callerPrivateKey: new Uint8Array(32),
71
+ description: "d",
72
+ schema,
73
+ client: { send: vi.fn() },
74
+ });
75
+ expect(tool.schema).toEqual(schema);
76
+ });
77
+ it("returns the result string from a successful ArohaResponse", async () => {
78
+ const identity = await generateDID("caller", "http://localhost:3001");
79
+ const mockSend = vi.fn().mockResolvedValue({
80
+ type: "ArohaResponse",
81
+ body: { capability: "greet", result: { greeting: "hello" } },
82
+ });
83
+ const tool = arohaCapabilityToLangChainTool("greet", {
84
+ endpoint: "http://localhost:3002",
85
+ agentDID: "did:aroha:remote",
86
+ callerDID: identity.did,
87
+ callerPrivateKey: identity.privateKey,
88
+ description: "Greet",
89
+ client: { send: mockSend },
90
+ });
91
+ const result = await tool.call({ name: "World" });
92
+ expect(result).toBe(JSON.stringify({ greeting: "hello" }));
93
+ expect(mockSend).toHaveBeenCalledTimes(1);
94
+ });
95
+ it("returns a plain string result as-is", async () => {
96
+ const identity = await generateDID("caller", "http://localhost:3001");
97
+ const mockSend = vi.fn().mockResolvedValue({
98
+ type: "ArohaResponse",
99
+ body: { capability: "echo", result: "pong" },
100
+ });
101
+ const tool = arohaCapabilityToLangChainTool("echo", {
102
+ endpoint: "http://localhost:3002",
103
+ agentDID: "did:aroha:remote",
104
+ callerDID: identity.did,
105
+ callerPrivateKey: identity.privateKey,
106
+ description: "Echo",
107
+ client: { send: mockSend },
108
+ });
109
+ const result = await tool.call("{}");
110
+ expect(result).toBe("pong");
111
+ });
112
+ it("throws when the response is a ArohaError", async () => {
113
+ const identity = await generateDID("caller", "http://localhost:3001");
114
+ const mockSend = vi.fn().mockResolvedValue({
115
+ type: "ArohaError",
116
+ body: { code: "Aroha_UNKNOWN_CAPABILITY", message: "No such capability" },
117
+ });
118
+ const tool = arohaCapabilityToLangChainTool("missing-cap", {
119
+ endpoint: "http://localhost:3002",
120
+ agentDID: "did:aroha:remote",
121
+ callerDID: identity.did,
122
+ callerPrivateKey: identity.privateKey,
123
+ description: "d",
124
+ client: { send: mockSend },
125
+ });
126
+ await expect(tool.call({})).rejects.toThrow("No such capability");
127
+ });
128
+ it("throws when the client returns no response", async () => {
129
+ const identity = await generateDID("caller", "http://localhost:3001");
130
+ const mockSend = vi.fn().mockResolvedValue(null);
131
+ const tool = arohaCapabilityToLangChainTool("cap", {
132
+ endpoint: "http://localhost:3002",
133
+ agentDID: "did:aroha:remote",
134
+ callerDID: identity.did,
135
+ callerPrivateKey: identity.privateKey,
136
+ description: "d",
137
+ client: { send: mockSend },
138
+ });
139
+ await expect(tool.call({})).rejects.toThrow(/No response/);
140
+ });
141
+ it("accepts string input and parses it as JSON", async () => {
142
+ const identity = await generateDID("caller", "http://localhost:3001");
143
+ const mockSend = vi.fn().mockResolvedValue({
144
+ type: "ArohaResponse",
145
+ body: { capability: "cap", result: { ok: true } },
146
+ });
147
+ const tool = arohaCapabilityToLangChainTool("cap", {
148
+ endpoint: "http://localhost:3002",
149
+ agentDID: "did:aroha:remote",
150
+ callerDID: identity.did,
151
+ callerPrivateKey: identity.privateKey,
152
+ description: "d",
153
+ client: { send: mockSend },
154
+ });
155
+ await tool.call('{"key":"value"}');
156
+ // Should not throw — the string input is parsed and used as params
157
+ expect(mockSend).toHaveBeenCalledTimes(1);
158
+ });
159
+ });
160
+ // ─── arohaCapabilityToOpenAITool ───────────────────────────────────────────────
161
+ describe("arohaCapabilityToOpenAITool", () => {
162
+ it("returns an OpenAI-shaped function tool", () => {
163
+ const tool = arohaCapabilityToOpenAITool("greet", {
164
+ endpoint: "http://localhost:3002",
165
+ agentDID: "did:aroha:remote",
166
+ callerDID: "did:aroha:caller",
167
+ callerPrivateKey: new Uint8Array(32),
168
+ description: "Greet a user",
169
+ client: { send: vi.fn() },
170
+ });
171
+ expect(tool.type).toBe("function");
172
+ expect(tool.function).toBeDefined();
173
+ expect(tool.function.description).toBe("Greet a user");
174
+ expect(typeof tool.invoke).toBe("function");
175
+ });
176
+ it("invoke() parses a JSON string result back to an object", async () => {
177
+ const identity = await generateDID("caller", "http://localhost:3001");
178
+ const mockSend = vi.fn().mockResolvedValue({
179
+ type: "ArohaResponse",
180
+ body: { capability: "greet", result: { msg: "hi" } },
181
+ });
182
+ const tool = arohaCapabilityToOpenAITool("greet", {
183
+ endpoint: "http://localhost:3002",
184
+ agentDID: "did:aroha:remote",
185
+ callerDID: identity.did,
186
+ callerPrivateKey: identity.privateKey,
187
+ description: "d",
188
+ client: { send: mockSend },
189
+ });
190
+ const result = await tool.invoke({ name: "World" });
191
+ expect(result).toEqual({ msg: "hi" });
192
+ });
193
+ });
194
+ // ─── langChainAgentToArohaProvider ─────────────────────────────────────────────
195
+ describe("langChainAgentToArohaProvider", () => {
196
+ it("returns a ArohaServer instance without starting it", async () => {
197
+ const identity = await generateDID("lc-bridge", "http://localhost:3099");
198
+ const server = langChainAgentToArohaProvider([makeTool("search-flights"), makeTool("book-hotel")], {
199
+ agentDID: identity.did,
200
+ agentPrivateKey: identity.privateKey,
201
+ port: 3099,
202
+ didDocument: identity.document,
203
+ resolvePublicKey: async () => null,
204
+ });
205
+ expect(server).toBeInstanceOf(ArohaServer);
206
+ });
207
+ });
208
+ //# sourceMappingURL=bridge.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.test.js","sourceRoot":"","sources":["../src/bridge.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EACL,8BAA8B,EAC9B,2BAA2B,EAC3B,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,aAAa,CAAC;AAErB,OAAO,EAAe,WAAW,EAAE,WAAW,E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IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QACpD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,kFAAkF;AAElF,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;IAC7C,EAAE,CAAC,oDAAoD,EAAE,KAAK,IAAI,EAAE;QAClE,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;QAEzE,MAAM,MAAM,GAAG,6BAA6B,CAC1C,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC,EACpD;YACE,QAAQ,EAAE,QAAQ,CAAC,GAAG;YACtB,eAAe,EAAE,QAAQ,CAAC,UAAU;YACpC,IAAI,EAAE,IAAI;YACV,WAAW,EAAE,QAAQ,CAAC,QAAQ;YAC9B,gBAAgB,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;SACnC,CACF,CAAC;QAEF,MAAM,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./types.js";
2
+ export * from "./bridge.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./types.js";
2
+ export * from "./bridge.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Duck-typed interfaces for LangChain, AutoGen, and Semantic Kernel tools.
3
+ *
4
+ * These interfaces are intentionally minimal — they match the public API surface
5
+ * that matters for Aroha bridging without requiring a hard dependency on any
6
+ * specific framework version.
7
+ */
8
+ export interface LangChainToolLike {
9
+ name: string;
10
+ description: string;
11
+ /** JSON Schema for the tool's input. Optional — used for agent auto-binding. */
12
+ schema?: Record<string, unknown>;
13
+ /** Invoke the tool. Input may be a JSON string or an object. */
14
+ call(input: string | Record<string, unknown>): Promise<string>;
15
+ }
16
+ export interface OpenAIFunctionLike {
17
+ type: "function";
18
+ function: {
19
+ name: string;
20
+ description: string;
21
+ parameters?: Record<string, unknown>;
22
+ };
23
+ /** Invoke the function. */
24
+ invoke(args: Record<string, unknown>): Promise<unknown>;
25
+ }
26
+ export interface ArohaCapabilityDescriptor {
27
+ capabilityId: string;
28
+ description: string;
29
+ inputSchema?: Record<string, unknown>;
30
+ }
31
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,gFAAgF;IAChF,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,gEAAgE;IAChE,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAChE;AAID,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACtC,CAAC;IACF,2BAA2B;IAC3B,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACzD;AAID,MAAM,WAAW,yBAAyB;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC"}
package/dist/types.js ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Duck-typed interfaces for LangChain, AutoGen, and Semantic Kernel tools.
3
+ *
4
+ * These interfaces are intentionally minimal — they match the public API surface
5
+ * that matters for Aroha bridging without requiring a hard dependency on any
6
+ * specific framework version.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@aroha-sdk/langchain-bridge",
3
- "version": "1.0.0",
4
- "description": "Aroha LangChain/AutoGen/Semantic Kernel bridge use Aroha as transport for any agent framework",
3
+ "version": "1.2.0",
4
+ "description": "Aroha ↔ LangChain/AutoGen/Semantic Kernel bridge — use Aroha as transport for any agent framework",
5
+ "files": [
6
+ "dist",
7
+ "src"
8
+ ],
5
9
  "type": "module",
6
10
  "main": "./dist/index.js",
7
11
  "types": "./dist/index.d.ts",
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "rootDir": "src",
5
- "outDir": "dist",
6
- "declarationDir": "dist"
7
- },
8
- "include": ["src/**/*"]
9
- }