maestro-core 0.1.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/README.md +55 -0
- package/dist/adapters/ai-sdk.d.ts +60 -0
- package/dist/adapters/ai-sdk.d.ts.map +1 -0
- package/dist/adapters/ai-sdk.js +86 -0
- package/dist/adapters/ai-sdk.js.map +1 -0
- package/dist/adapters/mcp-server.d.ts +37 -0
- package/dist/adapters/mcp-server.d.ts.map +1 -0
- package/dist/adapters/mcp-server.js +99 -0
- package/dist/adapters/mcp-server.js.map +1 -0
- package/dist/cache-control.d.ts +78 -0
- package/dist/cache-control.d.ts.map +1 -0
- package/dist/cache-control.js +57 -0
- package/dist/cache-control.js.map +1 -0
- package/dist/context.d.ts +62 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +2 -0
- package/dist/context.js.map +1 -0
- package/dist/envelope.d.ts +36 -0
- package/dist/envelope.d.ts.map +1 -0
- package/dist/envelope.js +9 -0
- package/dist/envelope.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/ports/audit-store.d.ts +33 -0
- package/dist/ports/audit-store.d.ts.map +1 -0
- package/dist/ports/audit-store.js +2 -0
- package/dist/ports/audit-store.js.map +1 -0
- package/dist/ports/clock.d.ts +22 -0
- package/dist/ports/clock.d.ts.map +1 -0
- package/dist/ports/clock.js +16 -0
- package/dist/ports/clock.js.map +1 -0
- package/dist/ports/index.d.ts +9 -0
- package/dist/ports/index.d.ts.map +1 -0
- package/dist/ports/index.js +4 -0
- package/dist/ports/index.js.map +1 -0
- package/dist/ports/key-provider.d.ts +18 -0
- package/dist/ports/key-provider.d.ts.map +1 -0
- package/dist/ports/key-provider.js +2 -0
- package/dist/ports/key-provider.js.map +1 -0
- package/dist/ports/logger.d.ts +25 -0
- package/dist/ports/logger.d.ts.map +1 -0
- package/dist/ports/logger.js +22 -0
- package/dist/ports/logger.js.map +1 -0
- package/dist/ports/memory-store.d.ts +32 -0
- package/dist/ports/memory-store.d.ts.map +1 -0
- package/dist/ports/memory-store.js +2 -0
- package/dist/ports/memory-store.js.map +1 -0
- package/dist/ports/quota-store.d.ts +63 -0
- package/dist/ports/quota-store.d.ts.map +1 -0
- package/dist/ports/quota-store.js +2 -0
- package/dist/ports/quota-store.js.map +1 -0
- package/dist/ports/telemetry-sink.d.ts +71 -0
- package/dist/ports/telemetry-sink.d.ts.map +1 -0
- package/dist/ports/telemetry-sink.js +11 -0
- package/dist/ports/telemetry-sink.js.map +1 -0
- package/dist/ports/turn-store.d.ts +62 -0
- package/dist/ports/turn-store.d.ts.map +1 -0
- package/dist/ports/turn-store.js +2 -0
- package/dist/ports/turn-store.js.map +1 -0
- package/dist/safe-tool.d.ts +38 -0
- package/dist/safe-tool.d.ts.map +1 -0
- package/dist/safe-tool.js +16 -0
- package/dist/safe-tool.js.map +1 -0
- package/dist/tool.d.ts +86 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +11 -0
- package/dist/tool.js.map +1 -0
- package/package.json +83 -0
package/dist/tool.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { BaseToolContext } from './context.js';
|
|
3
|
+
import type { ToolEnvelope, ToolMeta } from './envelope.js';
|
|
4
|
+
/**
|
|
5
|
+
* Coarse classification used by adapters and admin dashboards.
|
|
6
|
+
*
|
|
7
|
+
* - `read` — pure lookup, no side effects.
|
|
8
|
+
* - `write` — mutates host state. Usually pairs with `requiresConfirmation`.
|
|
9
|
+
* - `navigation` — emits a UX hint (e.g. open a screen). No state change.
|
|
10
|
+
*/
|
|
11
|
+
export type ToolKind = 'read' | 'write' | 'navigation';
|
|
12
|
+
/** Hint for rate-limit tiering and cost dashboards. */
|
|
13
|
+
export type ToolCostBand = 'cheap' | 'medium' | 'expensive';
|
|
14
|
+
/**
|
|
15
|
+
* Definition of a single agent tool. Pure — adapters translate this
|
|
16
|
+
* into AI-SDK / MCP / Anthropic-messages shape at the boundary.
|
|
17
|
+
*
|
|
18
|
+
* Required fields are the irreducible minimum every tool author must
|
|
19
|
+
* supply. Everything else is optional to keep the surface tight for
|
|
20
|
+
* sibling products that don't share barbeiro-specific governance
|
|
21
|
+
* (OAuth scopes, confirmation prompts, cost banding).
|
|
22
|
+
*/
|
|
23
|
+
export interface AgentToolDefinition<TInput extends z.ZodTypeAny, TOutput, TCtx extends BaseToolContext = BaseToolContext> {
|
|
24
|
+
/** Public identifier the model sees. camelCase by convention. */
|
|
25
|
+
name: string;
|
|
26
|
+
/**
|
|
27
|
+
* Entire selection signal for the model. Be explicit about *when*
|
|
28
|
+
* and *when not* to call this tool. Vague descriptions cause misfires.
|
|
29
|
+
*/
|
|
30
|
+
description: string;
|
|
31
|
+
/** Zod schema for tool input. Drives both validation and JSON-Schema export. */
|
|
32
|
+
inputSchema: TInput;
|
|
33
|
+
/**
|
|
34
|
+
* Surfaces where this tool is offered. Adapters filter the registry
|
|
35
|
+
* via `def.transports.includes(transport)`. String values are the
|
|
36
|
+
* host's vocabulary — kernel does not enumerate.
|
|
37
|
+
*/
|
|
38
|
+
transports: readonly string[];
|
|
39
|
+
/**
|
|
40
|
+
* Per-request gate. Runs BEFORE the tool is offered to the model.
|
|
41
|
+
* Failing gate = tool is not advertised that turn. Async OK
|
|
42
|
+
* (feature flags, downstream-config checks).
|
|
43
|
+
*/
|
|
44
|
+
isAvailable?: (ctx: TCtx) => boolean | Promise<boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* Tool body. Returns a `ToolEnvelope` so failures surface as data
|
|
47
|
+
* the model can recover from, instead of throwing.
|
|
48
|
+
*
|
|
49
|
+
* Throwing is allowed — adapters wrap `execute` so the throw is
|
|
50
|
+
* captured by the host-provided onError hook and surfaced as a
|
|
51
|
+
* tool-error result to the model. See `safe-tool.ts`.
|
|
52
|
+
*/
|
|
53
|
+
execute: (input: z.infer<TInput>, ctx: TCtx) => Promise<ToolEnvelope<TOutput>>;
|
|
54
|
+
kind?: ToolKind;
|
|
55
|
+
costBand?: ToolCostBand;
|
|
56
|
+
/**
|
|
57
|
+
* Which host-defined actor strings may invoke this tool. Adapters
|
|
58
|
+
* filter on this in addition to `transports` so the same surface
|
|
59
|
+
* can serve different actor populations (owner-MCP vs client-MCP).
|
|
60
|
+
*/
|
|
61
|
+
actorScope?: readonly string[];
|
|
62
|
+
/**
|
|
63
|
+
* OAuth scope strings consulted by the MCP adapter. Ignored by
|
|
64
|
+
* non-OAuth adapters.
|
|
65
|
+
*/
|
|
66
|
+
scopes?: readonly string[];
|
|
67
|
+
/** Destructive writes should preview-then-commit at the surface layer. */
|
|
68
|
+
requiresConfirmation?: boolean;
|
|
69
|
+
/** Free-form grouping for admin UI and MCP directory listings. */
|
|
70
|
+
category?: string;
|
|
71
|
+
/** Default `meta` returned with every successful envelope. */
|
|
72
|
+
meta?: ToolMeta;
|
|
73
|
+
/** Schema version. Bump on input/output breaking changes. */
|
|
74
|
+
schemaVersion?: number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Identity-factory for tool definitions. Lets call sites write
|
|
78
|
+
* `defineAgentTool({...})` without spelling out the generics — TS
|
|
79
|
+
* infers `TInput` from the zod literal and `TOutput` from the execute
|
|
80
|
+
* return type. `TCtx` defaults to `BaseToolContext` and is set
|
|
81
|
+
* explicitly when the host needs its extended context shape.
|
|
82
|
+
*/
|
|
83
|
+
export declare function defineAgentTool<TInput extends z.ZodTypeAny, TOutput, TCtx extends BaseToolContext = BaseToolContext>(def: AgentToolDefinition<TInput, TOutput, TCtx>): AgentToolDefinition<TInput, TOutput, TCtx>;
|
|
84
|
+
/** Convenient existential for registries that hold mixed tools. */
|
|
85
|
+
export type AnyAgentToolDefinition<TCtx extends BaseToolContext = BaseToolContext> = AgentToolDefinition<z.ZodTypeAny, unknown, TCtx>;
|
|
86
|
+
//# sourceMappingURL=tool.d.ts.map
|
|
@@ -0,0 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AAA;IAE1B,0EAA0E;IAC1E,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAE9B,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,QAAQ,CAAA;IAEf,6DAA6D;IAC7D,aAAa,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC3B,MAAM,SAAS,CAAC,CAAC,UAAU,EAC3B,OAAO,EACP,IAAI,SAAS,eAAe,GAAG,eAAe,EAE9C,GAAG,EAAE,mBAAmB,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,GAChD,mBAAmB,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAE5C;AAED,mEAAmE;AACnE,MAAM,MAAM,sBAAsB,CAAC,IAAI,SAAS,eAAe,GAAG,eAAe,IAC7E,mBAAmB,CAAC,CAAC,CAAC,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA"}
|
package/dist/tool.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity-factory for tool definitions. Lets call sites write
|
|
3
|
+
* `defineAgentTool({...})` without spelling out the generics — TS
|
|
4
|
+
* infers `TInput` from the zod literal and `TOutput` from the execute
|
|
5
|
+
* return type. `TCtx` defaults to `BaseToolContext` and is set
|
|
6
|
+
* explicitly when the host needs its extended context shape.
|
|
7
|
+
*/
|
|
8
|
+
export function defineAgentTool(def) {
|
|
9
|
+
return def;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=tool.js.map
|
package/dist/tool.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAiGA;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAK3B,GAA+C;IAE/C,OAAO,GAAG,CAAA;AACd,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "maestro-core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Runtime kernel for the Maestro agent platform — tool envelope, tool definition factory, base context, port interfaces, and AI-SDK + MCP adapters.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "Costa Software",
|
|
7
|
+
"homepage": "https://github.com/costasoftware/maestro/tree/main/packages/maestro-core#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/costasoftware/maestro.git",
|
|
11
|
+
"directory": "packages/maestro-core"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/costasoftware/maestro/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"ai",
|
|
18
|
+
"agent",
|
|
19
|
+
"tool-calling",
|
|
20
|
+
"anthropic",
|
|
21
|
+
"openai",
|
|
22
|
+
"mcp",
|
|
23
|
+
"ai-sdk",
|
|
24
|
+
"llm",
|
|
25
|
+
"vercel-ai"
|
|
26
|
+
],
|
|
27
|
+
"type": "module",
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"import": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./ports": {
|
|
36
|
+
"types": "./dist/ports/index.d.ts",
|
|
37
|
+
"import": "./dist/ports/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./adapters/ai-sdk": {
|
|
40
|
+
"types": "./dist/adapters/ai-sdk.d.ts",
|
|
41
|
+
"import": "./dist/adapters/ai-sdk.js"
|
|
42
|
+
},
|
|
43
|
+
"./adapters/mcp-server": {
|
|
44
|
+
"types": "./dist/adapters/mcp-server.d.ts",
|
|
45
|
+
"import": "./dist/adapters/mcp-server.js"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"files": [
|
|
49
|
+
"dist",
|
|
50
|
+
"README.md"
|
|
51
|
+
],
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsc -p tsconfig.build.json",
|
|
54
|
+
"test": "vitest run",
|
|
55
|
+
"lint": "echo \"(lint not yet configured)\" && exit 0",
|
|
56
|
+
"typecheck": "tsc -p tsconfig.build.json --noEmit",
|
|
57
|
+
"clean": "rm -rf dist .turbo *.tsbuildinfo"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
61
|
+
"ai": "^6.0.0",
|
|
62
|
+
"zod": "^3.25.0"
|
|
63
|
+
},
|
|
64
|
+
"peerDependenciesMeta": {
|
|
65
|
+
"@modelcontextprotocol/sdk": {
|
|
66
|
+
"optional": true
|
|
67
|
+
},
|
|
68
|
+
"ai": {
|
|
69
|
+
"optional": true
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
74
|
+
"@types/node": "^22.10.0",
|
|
75
|
+
"ai": "^6.0.0",
|
|
76
|
+
"typescript": "^5.7.2",
|
|
77
|
+
"vitest": "^2.1.8",
|
|
78
|
+
"zod": "^3.25.0"
|
|
79
|
+
},
|
|
80
|
+
"publishConfig": {
|
|
81
|
+
"access": "public"
|
|
82
|
+
}
|
|
83
|
+
}
|