@useagents/redop 0.1.0 → 0.1.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/dist/index.js CHANGED
@@ -60,8 +60,9 @@ function createSessionStore(timeoutMs) {
60
60
  function gc() {
61
61
  const now = Date.now();
62
62
  for (const [id, s] of sessions) {
63
- if (now - s.lastSeen > timeoutMs)
63
+ if (now - s.lastSeen > timeoutMs) {
64
64
  sessions.delete(id);
65
+ }
65
66
  }
66
67
  }
67
68
  const gcTimer = setInterval(gc, 30000);
@@ -73,8 +74,9 @@ function createSessionStore(timeoutMs) {
73
74
  },
74
75
  touch(id) {
75
76
  const s = sessions.get(id);
76
- if (!s)
77
+ if (!s) {
77
78
  return false;
79
+ }
78
80
  s.lastSeen = Date.now();
79
81
  return true;
80
82
  },
@@ -87,8 +89,9 @@ function createSessionStore(timeoutMs) {
87
89
  };
88
90
  }
89
91
  function buildCorsHeaders(cors, requestOrigin) {
90
- if (!cors)
92
+ if (!cors) {
91
93
  return {};
94
+ }
92
95
  if (cors === true) {
93
96
  return {
94
97
  "Access-Control-Allow-Origin": requestOrigin ?? "*",
@@ -151,7 +154,7 @@ async function handleJsonRpc(body, tools, runner, requestMeta, serverInfo, sessi
151
154
  if (method === "tools/call") {
152
155
  const p = params;
153
156
  const toolName = p?.name;
154
- if (!toolName || !tools.has(toolName)) {
157
+ if (!(toolName && tools.has(toolName))) {
155
158
  return {
156
159
  jsonrpc: "2.0",
157
160
  id,
@@ -554,8 +557,9 @@ class Redop {
554
557
  }
555
558
  async _runTool(toolName, rawArgs, request = DEFAULT_REQUEST_META) {
556
559
  const tool = this._tools.get(toolName);
557
- if (!tool)
560
+ if (!tool) {
558
561
  throw new Error(`Unknown tool: ${toolName}`);
562
+ }
559
563
  const ctx = {
560
564
  headers: request.headers,
561
565
  requestId: crypto.randomUUID(),
package/dist/redop.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AfterHook, BeforeHook, Context, ErrorHook, InferSchemaOutput, ListenOptions, MapResponseHook, RedopOptions, PluginDefinition, PluginFactory, ResolvedTool, ToolDef, ToolMiddleware, TransformHook } from "./types";
1
+ import type { AfterHook, BeforeHook, Context, ErrorHook, InferSchemaOutput, ListenOptions, MapResponseHook, PluginDefinition, PluginFactory, RedopOptions, ResolvedTool, ToolDef, ToolMiddleware, TransformHook } from "./types";
2
2
  /**
3
3
  * Bun-native framework for building MCP servers with typed tools, hooks, and plugins.
4
4
  *
package/dist/types.d.ts CHANGED
@@ -151,8 +151,8 @@ export interface PluginDefinition<Options, C extends Context = Context> extends
151
151
  * Callable plugin factory with attached metadata for docs and introspection.
152
152
  */
153
153
  export interface PluginFactory<Options, C extends Context = Context> {
154
- (options: Options): import("./redop").Redop<C>;
155
154
  meta: PluginMeta;
155
+ (options: Options): import("./redop").Redop<C>;
156
156
  }
157
157
  export interface BeforeHookEvent<C extends Context = Context, I = unknown> {
158
158
  ctx: C;
@@ -242,6 +242,8 @@ export interface SchemaAdapter<S = unknown, Parsed = InferSchemaOutput<S>> {
242
242
  * Definition object for a single MCP tool.
243
243
  */
244
244
  export interface ToolDef<S = unknown, I = InferSchemaOutput<S>, C extends Context = Context, O = unknown> {
245
+ /** Tool-local hook that runs after middleware/handler success and before global after hooks. */
246
+ after?: ToolAfterHook<I, O, C>;
245
247
  /** MCP tool annotations surfaced to compatible clients. */
246
248
  annotations?: {
247
249
  title?: string;
@@ -254,8 +256,6 @@ export interface ToolDef<S = unknown, I = InferSchemaOutput<S>, C extends Contex
254
256
  before?: ToolBeforeHook<I, C>;
255
257
  /** Human-friendly tool description shown in tool listings. */
256
258
  description?: string;
257
- /** Tool-local hook that runs after middleware/handler success and before global after hooks. */
258
- after?: ToolAfterHook<I, O, C>;
259
259
  /** Tool handler receiving parsed input, shared context, and request metadata. */
260
260
  handler: ToolHandler<I, O, C>;
261
261
  /** Schema instance (Zod, TypeBox, etc.) or plain JSON Schema object */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useagents/redop",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Bun-native MCP server framework",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -36,7 +36,7 @@
36
36
  "prepublishOnly": "bun run build && bun test"
37
37
  },
38
38
  "devDependencies": {
39
- "bun-types": "^1.3.11",
39
+ "@types/bun": "latest",
40
40
  "typescript": "^5.4.0"
41
41
  },
42
42
  "peerDependencies": {},