@coffer-org/plugin-claude-agent 2.5.1 → 2.5.3

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
@@ -6,6 +6,14 @@ export default definePlugin({
6
6
  id: 'claude-agent',
7
7
  version: '1.0.0',
8
8
  dependsOn: [],
9
+ fieldContribs: [
10
+ {
11
+ library: '_settings',
12
+ shelf: 'orchestrator',
13
+ field: 'agent_id',
14
+ options: [{ value: 'claude-agent', title: 'claude-agent.plugin.label' }],
15
+ },
16
+ ],
9
17
  settings: defineSettings({
10
18
  label: 'claude-agent.settings.label',
11
19
  fields: [
@@ -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 '@coffer-org/plugin-orchestrator/runtime';
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,13 +7,23 @@ 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';
11
+ import { registerAgent } from '@coffer-org/plugin-orchestrator/runtime';
12
+ import { runAgent, agentSystemBase } from "./agent.js";
10
13
  const log = getLogger('agent');
11
14
  export { runAgent, agentSystemBase } from "./agent.js";
12
15
  let indexTimer;
13
16
  let unsubRecords;
17
+ let unregisterAgent;
18
+ const runtime = {
19
+ id: 'claude-agent',
20
+ run: (request) => runAgent(request),
21
+ systemBase: agentSystemBase,
22
+ };
14
23
  export const serverHooks = {
15
24
  migrations,
16
25
  init: async () => {
26
+ unregisterAgent = registerAgent(runtime, { default: true });
17
27
  const cfg = loadAgentConfig({ dbSettings: await getPluginSettings('claude-agent') });
18
28
  initTracing(cfg);
19
29
  log.info(isTracing()
@@ -21,7 +31,7 @@ export const serverHooks = {
21
31
  : `Langfuse tracing OFF (tracing_enabled=${cfg.tracingEnabled}, keys=${cfg.langfusePublicKey && cfg.langfuseSecretKey ? 'set' : 'missing'})`);
22
32
  ensureWorkspace(cfg, console);
23
33
  if (cfg.ragEnabled && cfg.embeddingApiKey) {
24
- const run = () => indexOnce({ apiKey: cfg.embeddingApiKey }).catch((e) => log.warn(`indexer: ${e instanceof Error ? e.message : String(e)}`));
34
+ const run = () => indexOnce({ apiKey: cfg.embeddingApiKey }).catch((e) => log.warn(`indexer: ${embeddingFailureMessage(e)}`));
25
35
  void run();
26
36
  indexTimer = setInterval(() => void run(), 60_000);
27
37
  if (typeof indexTimer.unref === 'function')
@@ -31,6 +41,8 @@ export const serverHooks = {
31
41
  }
32
42
  },
33
43
  teardown: async () => {
44
+ unregisterAgent?.();
45
+ unregisterAgent = undefined;
34
46
  clearInterval(indexTimer);
35
47
  indexTimer = undefined;
36
48
  unsubRecords?.();
@@ -1,32 +1 @@
1
- export interface AttachmentRef {
2
- name: string;
3
- mime?: string;
4
- size?: number;
5
- label?: string;
6
- }
7
- export interface ConvMessage {
8
- role: 'user' | 'assistant';
9
- content: string;
10
- attachments?: AttachmentRef[];
11
- sender?: string | null;
12
- msgId: string;
13
- ts: number;
14
- }
15
- export interface SystemLayer {
16
- text: string;
17
- stable: boolean;
18
- }
19
- export interface AgentRequest {
20
- system: SystemLayer[];
21
- messages: ConvMessage[];
22
- onDelta?: (accumulated: string) => void;
23
- onReasoning?: (accumulated: string) => void;
24
- onSegment?: () => void;
25
- }
26
- export interface AgentResult {
27
- text: string | null;
28
- reasoning: string | null;
29
- tokensIn: number | null;
30
- tokensOut: number | null;
31
- stopReason: string | null;
32
- }
1
+ export type { AttachmentRef, AgentToolDefinition, AgentToolProvider, ConvMessage, SystemLayer, AgentRequest, AgentResult, } from '@coffer-org/plugin-orchestrator/runtime';
package/dist/schema.js CHANGED
@@ -7074,6 +7074,15 @@ var src_default = definePlugin({
7074
7074
  id: "claude-agent",
7075
7075
  version: "1.0.0",
7076
7076
  dependsOn: [],
7077
+ fieldContribs: [{
7078
+ library: "_settings",
7079
+ shelf: "orchestrator",
7080
+ field: "agent_id",
7081
+ options: [{
7082
+ value: "claude-agent",
7083
+ title: "claude-agent.plugin.label"
7084
+ }]
7085
+ }],
7077
7086
  settings: defineSettings({
7078
7087
  label: "claude-agent.settings.label",
7079
7088
  fields: [
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.3",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=24"
@@ -27,7 +27,8 @@
27
27
  "dependencies": {
28
28
  "@anthropic-ai/sdk": "^0.111.0",
29
29
  "@coffer-org/mcp": "^2.3.1",
30
- "@coffer-org/sdk": "^2.1.1",
30
+ "@coffer-org/plugin-orchestrator": "^2.3.0",
31
+ "@coffer-org/sdk": "^2.1.2",
31
32
  "@coffer-org/server": "^2.3.0",
32
33
  "@langfuse/otel": "^4.6.1",
33
34
  "@langfuse/tracing": "^4.6.1",