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.
Files changed (70) hide show
  1. package/README.md +55 -0
  2. package/dist/adapters/ai-sdk.d.ts +60 -0
  3. package/dist/adapters/ai-sdk.d.ts.map +1 -0
  4. package/dist/adapters/ai-sdk.js +86 -0
  5. package/dist/adapters/ai-sdk.js.map +1 -0
  6. package/dist/adapters/mcp-server.d.ts +37 -0
  7. package/dist/adapters/mcp-server.d.ts.map +1 -0
  8. package/dist/adapters/mcp-server.js +99 -0
  9. package/dist/adapters/mcp-server.js.map +1 -0
  10. package/dist/cache-control.d.ts +78 -0
  11. package/dist/cache-control.d.ts.map +1 -0
  12. package/dist/cache-control.js +57 -0
  13. package/dist/cache-control.js.map +1 -0
  14. package/dist/context.d.ts +62 -0
  15. package/dist/context.d.ts.map +1 -0
  16. package/dist/context.js +2 -0
  17. package/dist/context.js.map +1 -0
  18. package/dist/envelope.d.ts +36 -0
  19. package/dist/envelope.d.ts.map +1 -0
  20. package/dist/envelope.js +9 -0
  21. package/dist/envelope.js.map +1 -0
  22. package/dist/index.d.ts +7 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +8 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/ports/audit-store.d.ts +33 -0
  27. package/dist/ports/audit-store.d.ts.map +1 -0
  28. package/dist/ports/audit-store.js +2 -0
  29. package/dist/ports/audit-store.js.map +1 -0
  30. package/dist/ports/clock.d.ts +22 -0
  31. package/dist/ports/clock.d.ts.map +1 -0
  32. package/dist/ports/clock.js +16 -0
  33. package/dist/ports/clock.js.map +1 -0
  34. package/dist/ports/index.d.ts +9 -0
  35. package/dist/ports/index.d.ts.map +1 -0
  36. package/dist/ports/index.js +4 -0
  37. package/dist/ports/index.js.map +1 -0
  38. package/dist/ports/key-provider.d.ts +18 -0
  39. package/dist/ports/key-provider.d.ts.map +1 -0
  40. package/dist/ports/key-provider.js +2 -0
  41. package/dist/ports/key-provider.js.map +1 -0
  42. package/dist/ports/logger.d.ts +25 -0
  43. package/dist/ports/logger.d.ts.map +1 -0
  44. package/dist/ports/logger.js +22 -0
  45. package/dist/ports/logger.js.map +1 -0
  46. package/dist/ports/memory-store.d.ts +32 -0
  47. package/dist/ports/memory-store.d.ts.map +1 -0
  48. package/dist/ports/memory-store.js +2 -0
  49. package/dist/ports/memory-store.js.map +1 -0
  50. package/dist/ports/quota-store.d.ts +63 -0
  51. package/dist/ports/quota-store.d.ts.map +1 -0
  52. package/dist/ports/quota-store.js +2 -0
  53. package/dist/ports/quota-store.js.map +1 -0
  54. package/dist/ports/telemetry-sink.d.ts +71 -0
  55. package/dist/ports/telemetry-sink.d.ts.map +1 -0
  56. package/dist/ports/telemetry-sink.js +11 -0
  57. package/dist/ports/telemetry-sink.js.map +1 -0
  58. package/dist/ports/turn-store.d.ts +62 -0
  59. package/dist/ports/turn-store.d.ts.map +1 -0
  60. package/dist/ports/turn-store.js +2 -0
  61. package/dist/ports/turn-store.js.map +1 -0
  62. package/dist/safe-tool.d.ts +38 -0
  63. package/dist/safe-tool.d.ts.map +1 -0
  64. package/dist/safe-tool.js +16 -0
  65. package/dist/safe-tool.js.map +1 -0
  66. package/dist/tool.d.ts +86 -0
  67. package/dist/tool.d.ts.map +1 -0
  68. package/dist/tool.js +11 -0
  69. package/dist/tool.js.map +1 -0
  70. 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 +1 @@
1
+ {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE3D;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,YAAY,CAAA;AAEtD,uDAAuD;AACvD,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,WAAW,CAAA;AAE3D;;;;;;;;GAQG;AACH,MAAM,WAAW,mB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C,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
@@ -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
+ }