@coffer-org/plugin-claude-agent 2.5.1 → 2.5.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.
@@ -136,7 +136,7 @@ export async function runAgent(request, deps = {}) {
136
136
  const client = makeClientFn(cfg);
137
137
  const rag = cfg.ragEnabled && cfg.embeddingApiKey ? { embeddingApiKey: cfg.embeddingApiKey } : null;
138
138
  const attachmentRefs = request.messages.flatMap((m) => m.attachments ?? []);
139
- const { tools, handlers } = await makeAgentToolsFn(rag, attachmentRefs);
139
+ const { tools, handlers } = await makeAgentToolsFn(rag, attachmentRefs, request.toolProvider);
140
140
  const system = request.system.map((l) => ({
141
141
  type: 'text',
142
142
  text: l.text,
@@ -1,12 +1,12 @@
1
1
  import { type RagDeps } from '@coffer-org/server/mcp-tools';
2
- import type { AttachmentRef } from './types.ts';
2
+ import type { AgentToolProvider, AttachmentRef } from './types.ts';
3
3
  export interface AgentTool {
4
4
  name: string;
5
5
  description: string;
6
6
  input_schema: Record<string, unknown>;
7
7
  }
8
8
  export type ToolHandler = (args: Record<string, unknown>) => Promise<unknown>;
9
- export declare function makeAgentTools(rag: RagDeps | null, attachments?: AttachmentRef[]): Promise<{
9
+ export declare function makeAgentTools(rag: RagDeps | null, attachments?: AttachmentRef[], provider?: AgentToolProvider): Promise<{
10
10
  tools: AgentTool[];
11
11
  handlers: Record<string, ToolHandler>;
12
12
  }>;
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { collectMcpTools } from '@coffer-org/server/mcp-tools';
3
3
  import { inspectAttachment } from "./inspect-attachment.js";
4
- export async function makeAgentTools(rag, attachments = []) {
4
+ export async function makeAgentTools(rag, attachments = [], provider) {
5
5
  const defs = await collectMcpTools({ rag });
6
6
  const tools = [];
7
7
  const handlers = {};
@@ -14,6 +14,15 @@ export async function makeAgentTools(rag, attachments = []) {
14
14
  });
15
15
  handlers[name] = (args) => d.handler(args);
16
16
  }
17
+ for (const d of provider?.tools ?? []) {
18
+ const name = d.name.startsWith('mcp__') ? d.name : `mcp__coffer__${d.name}`;
19
+ tools.push({
20
+ name,
21
+ description: d.description,
22
+ input_schema: d.inputSchema,
23
+ });
24
+ handlers[name] = d.handler;
25
+ }
17
26
  if (attachments.length) {
18
27
  const name = 'mcp__coffer__inspect_attachment';
19
28
  tools.push({
@@ -1,5 +1,5 @@
1
1
  import type { PluginHooks } from '@coffer-org/server/plugin-hooks';
2
2
  export { runAgent, agentSystemBase } from './agent.ts';
3
3
  export type { AgentRunDeps, AgentTracer } from './agent.ts';
4
- export type { AttachmentRef, ConvMessage, SystemLayer, AgentRequest, AgentResult } from './types.ts';
4
+ export type { AttachmentRef, AgentToolDefinition, AgentToolProvider, ConvMessage, SystemLayer, AgentRequest, AgentResult, } from './types.ts';
5
5
  export declare const serverHooks: PluginHooks;
@@ -7,6 +7,7 @@ import { makeScheduler } from "./nudge-scheduler.js";
7
7
  import { initTracing, flushTracing, isTracing } from "./tracing.js";
8
8
  import { migrations } from "./migrations.js";
9
9
  import { getLogger } from '@coffer-org/sdk/logger';
10
+ import { embeddingFailureMessage } from '@coffer-org/server/embed-openai';
10
11
  const log = getLogger('agent');
11
12
  export { runAgent, agentSystemBase } from "./agent.js";
12
13
  let indexTimer;
@@ -21,7 +22,7 @@ export const serverHooks = {
21
22
  : `Langfuse tracing OFF (tracing_enabled=${cfg.tracingEnabled}, keys=${cfg.langfusePublicKey && cfg.langfuseSecretKey ? 'set' : 'missing'})`);
22
23
  ensureWorkspace(cfg, console);
23
24
  if (cfg.ragEnabled && cfg.embeddingApiKey) {
24
- const run = () => indexOnce({ apiKey: cfg.embeddingApiKey }).catch((e) => log.warn(`indexer: ${e instanceof Error ? e.message : String(e)}`));
25
+ const run = () => indexOnce({ apiKey: cfg.embeddingApiKey }).catch((e) => log.warn(`indexer: ${embeddingFailureMessage(e)}`));
25
26
  void run();
26
27
  indexTimer = setInterval(() => void run(), 60_000);
27
28
  if (typeof indexTimer.unref === 'function')
@@ -4,6 +4,15 @@ export interface AttachmentRef {
4
4
  size?: number;
5
5
  label?: string;
6
6
  }
7
+ export interface AgentToolDefinition {
8
+ name: string;
9
+ description: string;
10
+ inputSchema: Record<string, unknown>;
11
+ handler: (args: Record<string, unknown>) => Promise<unknown>;
12
+ }
13
+ export interface AgentToolProvider {
14
+ tools: AgentToolDefinition[];
15
+ }
7
16
  export interface ConvMessage {
8
17
  role: 'user' | 'assistant';
9
18
  content: string;
@@ -19,6 +28,7 @@ export interface SystemLayer {
19
28
  export interface AgentRequest {
20
29
  system: SystemLayer[];
21
30
  messages: ConvMessage[];
31
+ toolProvider?: AgentToolProvider;
22
32
  onDelta?: (accumulated: string) => void;
23
33
  onReasoning?: (accumulated: string) => void;
24
34
  onSegment?: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffer-org/plugin-claude-agent",
3
- "version": "2.5.1",
3
+ "version": "2.5.2",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=24"