@nebutra/agent-runtime 0.2.0 → 0.2.2
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/LICENSE +21 -676
- package/README.md +2 -0
- package/dist/adapters/dispatcher-sse.js +1 -0
- package/dist/adapters/index.d.ts +24 -5
- package/dist/adapters/index.js +28 -0
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/mcp-catalog.js +1 -0
- package/dist/adapters/prisma-rollout.js +1 -0
- package/dist/chunk-424PT5DM.js +23 -0
- package/dist/chunk-424PT5DM.js.map +1 -0
- package/dist/{chunk-NN7DATXA.js → chunk-4Y25ZTKI.js} +3 -3
- package/dist/chunk-4Y25ZTKI.js.map +1 -0
- package/dist/{chunk-BJBBR3QA.js → chunk-D4YAPLOW.js} +4 -4
- package/dist/chunk-D4YAPLOW.js.map +1 -0
- package/dist/{chunk-ZMYX5VBU.js → chunk-GQZKYWFT.js} +23 -7
- package/dist/chunk-GQZKYWFT.js.map +1 -0
- package/dist/chunk-KCNN4QUQ.js +255 -0
- package/dist/chunk-KCNN4QUQ.js.map +1 -0
- package/dist/{chunk-PGGWSUTM.js → chunk-NI4EDT4T.js} +2 -2
- package/dist/chunk-NI4EDT4T.js.map +1 -0
- package/dist/chunk-Q62VKHIT.js +178 -0
- package/dist/chunk-Q62VKHIT.js.map +1 -0
- package/dist/{chunk-MUF7ZZTO.js → chunk-R5HOSQUW.js} +2 -1
- package/dist/{chunk-MUF7ZZTO.js.map → chunk-R5HOSQUW.js.map} +1 -1
- package/dist/{chunk-5N4644PB.js → chunk-SD2ZJ7XG.js} +4 -4
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +52 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands.js +1 -0
- package/dist/definitions.js +1 -0
- package/dist/dispatcher.js +1 -0
- package/dist/durable-turn.js +3 -2
- package/dist/hook-pipeline.js +1 -0
- package/dist/index.d.ts +8 -85
- package/dist/index.js +249 -134
- package/dist/index.js.map +1 -1
- package/dist/loop.d.ts +2 -2
- package/dist/loop.js +3 -2
- package/dist/mcp-bridge.d.ts +3 -3
- package/dist/mcp-bridge.js +3 -2
- package/dist/model.js +1 -0
- package/dist/orchestration.d.ts +84 -0
- package/dist/orchestration.js +16 -0
- package/dist/orchestration.js.map +1 -0
- package/dist/policy.js +1 -0
- package/dist/protocol.js +1 -0
- package/dist/pulsar.d.ts +78 -0
- package/dist/pulsar.js +17 -0
- package/dist/pulsar.js.map +1 -0
- package/dist/rollout-store-persistent.js +1 -0
- package/dist/rollout.js +1 -0
- package/dist/sandbox.js +2 -1
- package/dist/skills.js +2 -1
- package/dist/subagents.js +1 -0
- package/dist/tools.d.ts +4 -3
- package/dist/tools.js +5 -3
- package/package.json +84 -27
- package/.turbo/turbo-build.log +0 -115
- package/.turbo/turbo-test.log +0 -44
- package/.turbo/turbo-typecheck.log +0 -4
- package/CHANGELOG.md +0 -253
- package/dist/chunk-BJBBR3QA.js.map +0 -1
- package/dist/chunk-NN7DATXA.js.map +0 -1
- package/dist/chunk-PGGWSUTM.js.map +0 -1
- package/dist/chunk-ZMYX5VBU.js.map +0 -1
- package/src/adapters/dispatcher-sse.test.ts +0 -218
- package/src/adapters/dispatcher-sse.ts +0 -222
- package/src/adapters/index.ts +0 -18
- package/src/adapters/mcp-catalog.test.ts +0 -213
- package/src/adapters/mcp-catalog.ts +0 -188
- package/src/adapters/prisma-rollout.test.ts +0 -153
- package/src/adapters/prisma-rollout.ts +0 -104
- package/src/agent-runtime.test.ts +0 -176
- package/src/artifact-stream.test.ts +0 -330
- package/src/artifact-stream.ts +0 -453
- package/src/channel-gateway.test.ts +0 -432
- package/src/channel-gateway.ts +0 -357
- package/src/code-review.test.ts +0 -501
- package/src/code-review.ts +0 -495
- package/src/command-suggestions.test.ts +0 -251
- package/src/command-suggestions.ts +0 -338
- package/src/commands.test.ts +0 -184
- package/src/commands.ts +0 -140
- package/src/commit-message.test.ts +0 -249
- package/src/commit-message.ts +0 -180
- package/src/context-compaction.test.ts +0 -522
- package/src/context-compaction.ts +0 -434
- package/src/definitions.test.ts +0 -78
- package/src/definitions.ts +0 -190
- package/src/deployment-status.test.ts +0 -215
- package/src/deployment-status.ts +0 -227
- package/src/design-context.test.ts +0 -195
- package/src/design-context.ts +0 -198
- package/src/dispatcher.test.ts +0 -234
- package/src/dispatcher.ts +0 -189
- package/src/durable-turn.test.ts +0 -209
- package/src/durable-turn.ts +0 -135
- package/src/edit-planner.test.ts +0 -204
- package/src/edit-planner.ts +0 -325
- package/src/fuzzy-match.test.ts +0 -311
- package/src/fuzzy-match.ts +0 -444
- package/src/hook-pipeline.test.ts +0 -279
- package/src/hook-pipeline.ts +0 -373
- package/src/inbound-admission.test.ts +0 -394
- package/src/inbound-admission.ts +0 -246
- package/src/index.ts +0 -47
- package/src/loop.test.ts +0 -161
- package/src/loop.ts +0 -211
- package/src/mcp-bridge.test.ts +0 -165
- package/src/mcp-bridge.ts +0 -76
- package/src/memory-provider.test.ts +0 -232
- package/src/memory-provider.ts +0 -257
- package/src/model.ts +0 -168
- package/src/permission-ruleset.test.ts +0 -301
- package/src/permission-ruleset.ts +0 -200
- package/src/policy.ts +0 -151
- package/src/project-repo.test.ts +0 -232
- package/src/project-repo.ts +0 -311
- package/src/protocol.ts +0 -159
- package/src/rollout-store-persistent.test.ts +0 -217
- package/src/rollout-store-persistent.ts +0 -166
- package/src/rollout.ts +0 -150
- package/src/sandbox.ts +0 -113
- package/src/session-share.test.ts +0 -360
- package/src/session-share.ts +0 -310
- package/src/skill-distillation.test.ts +0 -177
- package/src/skill-distillation.ts +0 -369
- package/src/skills.test.ts +0 -277
- package/src/skills.ts +0 -255
- package/src/subagents.test.ts +0 -290
- package/src/subagents.ts +0 -332
- package/src/tools.ts +0 -126
- package/src/workbench.test.ts +0 -0
- package/src/workbench.ts +0 -0
- package/tsconfig.json +0 -12
- package/tsup.config.ts +0 -33
- /package/dist/{chunk-5N4644PB.js.map → chunk-SD2ZJ7XG.js.map} +0 -0
package/src/tools.ts
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tool / MCP abstraction (WRAP — capability #9).
|
|
3
|
-
*
|
|
4
|
-
* Faithful re-expression of the upstream uniform tool model: one
|
|
5
|
-
* `ToolDefinition` interface, JSON-schema in/out, a deferred-load flag, and
|
|
6
|
-
* MCP-as-adapter behind the same interface (MCP tools and native tools are
|
|
7
|
-
* indistinguishable at dispatch). Activates `@nebutra/mcp` primitives rather
|
|
8
|
-
* than re-porting them.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type { z } from "zod";
|
|
12
|
-
|
|
13
|
-
/** A tool definition — pure data; transport-agnostic. */
|
|
14
|
-
export interface ToolDefinition<I = unknown, O = unknown> {
|
|
15
|
-
readonly name: string;
|
|
16
|
-
readonly description: string;
|
|
17
|
-
readonly inputSchema: z.ZodType<I>;
|
|
18
|
-
readonly outputSchema?: z.ZodType<O>;
|
|
19
|
-
/**
|
|
20
|
-
* When true, the full schema is withheld until a `tool_search` discovery
|
|
21
|
-
* step lazily loads it (parity with the upstream deferred-tool pattern).
|
|
22
|
-
*/
|
|
23
|
-
readonly deferLoading?: boolean;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** Source provenance — native vs. adapted from an MCP server. */
|
|
27
|
-
export type ToolOrigin =
|
|
28
|
-
| { readonly kind: "native" }
|
|
29
|
-
| { readonly kind: "mcp"; readonly server: string };
|
|
30
|
-
|
|
31
|
-
export interface RegisteredTool {
|
|
32
|
-
readonly definition: ToolDefinition;
|
|
33
|
-
readonly origin: ToolOrigin;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** A tool invocation routed through the registry. */
|
|
37
|
-
export interface ToolDispatchContext {
|
|
38
|
-
/** Mandatory tenant scope — every dispatch is tenant-bound. */
|
|
39
|
-
readonly tenantId: string;
|
|
40
|
-
readonly threadId: string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export type ToolHandler<I = unknown, O = unknown> = (
|
|
44
|
-
input: I,
|
|
45
|
-
ctx: ToolDispatchContext,
|
|
46
|
-
) => Promise<O>;
|
|
47
|
-
|
|
48
|
-
/** Pre/post dispatch hooks (parity with upstream orchestrator hooks). */
|
|
49
|
-
export interface ToolHooks {
|
|
50
|
-
readonly preToolUse?: (name: string, input: unknown, ctx: ToolDispatchContext) => Promise<void>;
|
|
51
|
-
readonly postToolUse?: (name: string, output: unknown, ctx: ToolDispatchContext) => Promise<void>;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* registry -> router -> orchestrator pipeline. MCP tools register via
|
|
56
|
-
* {@link adaptMcpTool} and are dispatched identically to native tools.
|
|
57
|
-
*/
|
|
58
|
-
export class ToolRegistry {
|
|
59
|
-
readonly #tools = new Map<string, { reg: RegisteredTool; handler: ToolHandler }>();
|
|
60
|
-
readonly #hooks: ToolHooks;
|
|
61
|
-
|
|
62
|
-
constructor(hooks: ToolHooks = {}) {
|
|
63
|
-
this.#hooks = hooks;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
register<I, O>(
|
|
67
|
-
definition: ToolDefinition<I, O>,
|
|
68
|
-
handler: ToolHandler<I, O>,
|
|
69
|
-
origin: ToolOrigin = { kind: "native" },
|
|
70
|
-
): void {
|
|
71
|
-
if (this.#tools.has(definition.name)) {
|
|
72
|
-
throw new Error(`Tool already registered: ${definition.name}`);
|
|
73
|
-
}
|
|
74
|
-
this.#tools.set(definition.name, {
|
|
75
|
-
reg: { definition: definition as ToolDefinition, origin },
|
|
76
|
-
handler: handler as ToolHandler,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
list(): readonly RegisteredTool[] {
|
|
81
|
-
return [...this.#tools.values()].map((e) => e.reg);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
async dispatch(name: string, rawInput: unknown, ctx: ToolDispatchContext): Promise<unknown> {
|
|
85
|
-
const entry = this.#tools.get(name);
|
|
86
|
-
if (!entry) throw new Error(`Unknown tool: ${name}`);
|
|
87
|
-
const input = entry.reg.definition.inputSchema.parse(rawInput);
|
|
88
|
-
await this.#hooks.preToolUse?.(name, input, ctx);
|
|
89
|
-
const output = await entry.handler(input, ctx);
|
|
90
|
-
const validated = entry.reg.definition.outputSchema
|
|
91
|
-
? entry.reg.definition.outputSchema.parse(output)
|
|
92
|
-
: output;
|
|
93
|
-
await this.#hooks.postToolUse?.(name, validated, ctx);
|
|
94
|
-
return validated;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/** Minimal shape of an MCP client (satisfied by `@nebutra/mcp`'s `mcpClient`). */
|
|
99
|
-
export interface McpClientLike {
|
|
100
|
-
executeTool(
|
|
101
|
-
name: string,
|
|
102
|
-
args: unknown,
|
|
103
|
-
ctx: { requestId: string; tenantId: string },
|
|
104
|
-
): Promise<unknown>;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Adapt an external MCP tool into the uniform tool model. The resulting
|
|
109
|
-
* handler delegates to the MCP client; callers cannot tell it apart from a
|
|
110
|
-
* native tool.
|
|
111
|
-
*/
|
|
112
|
-
export function adaptMcpTool(
|
|
113
|
-
server: string,
|
|
114
|
-
definition: ToolDefinition,
|
|
115
|
-
client: McpClientLike,
|
|
116
|
-
): { definition: ToolDefinition; handler: ToolHandler; origin: ToolOrigin } {
|
|
117
|
-
return {
|
|
118
|
-
definition,
|
|
119
|
-
origin: { kind: "mcp", server },
|
|
120
|
-
handler: async (input, ctx) =>
|
|
121
|
-
client.executeTool(definition.name, input, {
|
|
122
|
-
requestId: globalThis.crypto?.randomUUID?.() ?? `${Date.now()}`,
|
|
123
|
-
tenantId: ctx.tenantId,
|
|
124
|
-
}),
|
|
125
|
-
};
|
|
126
|
-
}
|
package/src/workbench.test.ts
DELETED
|
Binary file
|
package/src/workbench.ts
DELETED
|
Binary file
|
package/tsconfig.json
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"target": "esnext",
|
|
7
|
-
"types": ["node"],
|
|
8
|
-
"incremental": false
|
|
9
|
-
},
|
|
10
|
-
"include": ["src"],
|
|
11
|
-
"exclude": ["node_modules", "dist"]
|
|
12
|
-
}
|
package/tsup.config.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "tsup";
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
entry: {
|
|
5
|
-
index: "src/index.ts",
|
|
6
|
-
"adapters/index": "src/adapters/index.ts",
|
|
7
|
-
"adapters/dispatcher-sse": "src/adapters/dispatcher-sse.ts",
|
|
8
|
-
"adapters/mcp-catalog": "src/adapters/mcp-catalog.ts",
|
|
9
|
-
"adapters/prisma-rollout": "src/adapters/prisma-rollout.ts",
|
|
10
|
-
commands: "src/commands.ts",
|
|
11
|
-
definitions: "src/definitions.ts",
|
|
12
|
-
dispatcher: "src/dispatcher.ts",
|
|
13
|
-
"durable-turn": "src/durable-turn.ts",
|
|
14
|
-
"hook-pipeline": "src/hook-pipeline.ts",
|
|
15
|
-
loop: "src/loop.ts",
|
|
16
|
-
"mcp-bridge": "src/mcp-bridge.ts",
|
|
17
|
-
model: "src/model.ts",
|
|
18
|
-
policy: "src/policy.ts",
|
|
19
|
-
protocol: "src/protocol.ts",
|
|
20
|
-
rollout: "src/rollout.ts",
|
|
21
|
-
"rollout-store-persistent": "src/rollout-store-persistent.ts",
|
|
22
|
-
sandbox: "src/sandbox.ts",
|
|
23
|
-
skills: "src/skills.ts",
|
|
24
|
-
subagents: "src/subagents.ts",
|
|
25
|
-
tools: "src/tools.ts",
|
|
26
|
-
},
|
|
27
|
-
format: ["esm"],
|
|
28
|
-
dts: true,
|
|
29
|
-
clean: true,
|
|
30
|
-
sourcemap: true,
|
|
31
|
-
target: "es2022",
|
|
32
|
-
external: ["@nebutra/mcp"],
|
|
33
|
-
});
|
|
File without changes
|