@alveus-ai/std 0.1.57 → 0.1.58
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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.ts +53 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +45 -0
- package/dist/mcp.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,cAAc,mBAAmB,CAAC;AAGlC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,qBAAqB,CAAC;AAGpC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,cAAc,mBAAmB,CAAC;AAGlC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,qBAAqB,CAAC;AAGpC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -27,4 +27,6 @@ export * from './patterns/index.js';
|
|
|
27
27
|
export * from './composition/index.js';
|
|
28
28
|
// Re-export all utilities
|
|
29
29
|
export * from './utils/index.js';
|
|
30
|
+
// MCP tools — call tools on connected external MCP servers
|
|
31
|
+
export * from './mcp.js';
|
|
30
32
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,uBAAuB;AACvB,cAAc,mBAAmB,CAAC;AAElC,iCAAiC;AACjC,cAAc,mBAAmB,CAAC;AAElC,yBAAyB;AACzB,cAAc,qBAAqB,CAAC;AAEpC,sCAAsC;AACtC,cAAc,wBAAwB,CAAC;AAEvC,0BAA0B;AAC1B,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,uBAAuB;AACvB,cAAc,mBAAmB,CAAC;AAElC,iCAAiC;AACjC,cAAc,mBAAmB,CAAC;AAElC,yBAAyB;AACzB,cAAc,qBAAqB,CAAC;AAEpC,sCAAsC;AACtC,cAAc,wBAAwB,CAAC;AAEvC,0BAA0B;AAC1B,cAAc,kBAAkB,CAAC;AAEjC,2DAA2D;AAC3D,cAAc,UAAU,CAAC"}
|
package/dist/mcp.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tools — call tools exposed by connected external MCP servers from an agent.
|
|
3
|
+
*/
|
|
4
|
+
import type { ExecutionContext, MCPServerRef, MCPToolResult } from '@alveus-ai/core';
|
|
5
|
+
/**
|
|
6
|
+
* Specification of a tool on an MCP server. Provide exactly one of `connection`
|
|
7
|
+
* (a server configured on your account, the usual case) or `server` (an inline
|
|
8
|
+
* reference for a server that needs no authorization or uses a static token).
|
|
9
|
+
*/
|
|
10
|
+
export interface MCPToolSpec {
|
|
11
|
+
/** Name of a connection configured on your account. */
|
|
12
|
+
connection?: string;
|
|
13
|
+
/** An inline server reference (no-auth or static token). */
|
|
14
|
+
server?: MCPServerRef;
|
|
15
|
+
/** The tool name to invoke. */
|
|
16
|
+
tool: string;
|
|
17
|
+
/** The tool's input schema, recorded as call evidence when provided. */
|
|
18
|
+
inputSchema?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
/** A reusable handle to a tool on an MCP server. */
|
|
21
|
+
export interface MCPToolHandle {
|
|
22
|
+
(ctx: ExecutionContext, args?: Record<string, unknown>): Promise<MCPToolResult>;
|
|
23
|
+
/** The connection name this handle calls, if configured by name. */
|
|
24
|
+
readonly connection?: string;
|
|
25
|
+
/** The inline server this handle calls, if configured inline. */
|
|
26
|
+
readonly server?: MCPServerRef;
|
|
27
|
+
/** The tool this handle invokes. */
|
|
28
|
+
readonly tool: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Define a reusable handle to a tool on an MCP server.
|
|
32
|
+
*
|
|
33
|
+
* Call the returned handle inside an agent with the execution context and the
|
|
34
|
+
* tool's arguments. The call runs through the durable runtime and returns the
|
|
35
|
+
* tool result with reconstructable evidence of exactly what was invoked.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* // A server connected on your account (authorization handled for you):
|
|
40
|
+
* const search = mcpTool({ connection: 'my-search', tool: 'search' });
|
|
41
|
+
*
|
|
42
|
+
* // Or an inline server that needs no authorization:
|
|
43
|
+
* const ping = mcpTool({ server: { url: 'https://example.com/mcp' }, tool: 'ping' });
|
|
44
|
+
*
|
|
45
|
+
* // inside an agent handler:
|
|
46
|
+
* const result = await search(ctx, { query: 'alveus' });
|
|
47
|
+
* if (!result.isError) {
|
|
48
|
+
* // use result.content / result.structuredContent
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function mcpTool(spec: MCPToolSpec): MCPToolHandle;
|
|
53
|
+
//# sourceMappingURL=mcp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErF;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,uDAAuD;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED,oDAAoD;AACpD,MAAM,WAAW,aAAa;IAC5B,CAAC,GAAG,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAChF,oEAAoE;IACpE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,iEAAiE;IACjE,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;IAC/B,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,aAAa,CAuBxD"}
|
package/dist/mcp.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Define a reusable handle to a tool on an MCP server.
|
|
3
|
+
*
|
|
4
|
+
* Call the returned handle inside an agent with the execution context and the
|
|
5
|
+
* tool's arguments. The call runs through the durable runtime and returns the
|
|
6
|
+
* tool result with reconstructable evidence of exactly what was invoked.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* // A server connected on your account (authorization handled for you):
|
|
11
|
+
* const search = mcpTool({ connection: 'my-search', tool: 'search' });
|
|
12
|
+
*
|
|
13
|
+
* // Or an inline server that needs no authorization:
|
|
14
|
+
* const ping = mcpTool({ server: { url: 'https://example.com/mcp' }, tool: 'ping' });
|
|
15
|
+
*
|
|
16
|
+
* // inside an agent handler:
|
|
17
|
+
* const result = await search(ctx, { query: 'alveus' });
|
|
18
|
+
* if (!result.isError) {
|
|
19
|
+
* // use result.content / result.structuredContent
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export function mcpTool(spec) {
|
|
24
|
+
if ((spec.connection && spec.server) || (!spec.connection && !spec.server)) {
|
|
25
|
+
throw new Error('mcpTool requires exactly one of `connection` or `server`.');
|
|
26
|
+
}
|
|
27
|
+
const handle = (async (ctx, args) => {
|
|
28
|
+
if (!ctx.mcp) {
|
|
29
|
+
throw new Error('MCP tools require the durable runtime; ctx.mcp is not available in this environment.');
|
|
30
|
+
}
|
|
31
|
+
return ctx.mcp.callTool({
|
|
32
|
+
connection: spec.connection,
|
|
33
|
+
server: spec.server,
|
|
34
|
+
tool: spec.tool,
|
|
35
|
+
arguments: args ?? {},
|
|
36
|
+
inputSchema: spec.inputSchema,
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
return Object.assign(handle, {
|
|
40
|
+
connection: spec.connection,
|
|
41
|
+
server: spec.server,
|
|
42
|
+
tool: spec.tool,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=mcp.js.map
|
package/dist/mcp.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,OAAO,CAAC,IAAiB;IACvC,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3E,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;IAC/E,CAAC;IACD,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,GAAqB,EAAE,IAA8B,EAAE,EAAE;QAC9E,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CACb,sFAAsF,CACvF,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC;YACtB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAC,CAAC;IACL,CAAC,CAAkB,CAAC;IACpB,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;QAC3B,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB,CAAC,CAAC;AACL,CAAC"}
|