@coffer-org/plugin-claude-agent 2.5.0 → 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.
- package/dist/index.js +0 -1
- package/dist/runtime/agent.js +2 -2
- package/dist/runtime/coffer.d.ts +2 -2
- package/dist/runtime/coffer.js +10 -1
- package/dist/runtime/config.d.ts +0 -1
- package/dist/runtime/config.js +0 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +2 -1
- package/dist/runtime/types.d.ts +10 -0
- package/dist/schema.js +8 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -44,7 +44,6 @@ export default definePlugin({
|
|
|
44
44
|
fields: [
|
|
45
45
|
field.boolean({ key: 'rag_enabled', label: 'claude-agent.settings.rag_enabled', default: true }),
|
|
46
46
|
field.password({ key: 'openai_api_key', label: 'claude-agent.settings.openai_api_key' }),
|
|
47
|
-
field.int({ key: 'rag_top_k', label: 'claude-agent.settings.rag_top_k', default: 5, view: { hidden: true } }),
|
|
48
47
|
],
|
|
49
48
|
}),
|
|
50
49
|
field.group({
|
package/dist/runtime/agent.js
CHANGED
|
@@ -134,9 +134,9 @@ export async function runAgent(request, deps = {}) {
|
|
|
134
134
|
const turns = [];
|
|
135
135
|
try {
|
|
136
136
|
const client = makeClientFn(cfg);
|
|
137
|
-
const rag = cfg.ragEnabled && cfg.embeddingApiKey ? { embeddingApiKey: cfg.embeddingApiKey
|
|
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,
|
package/dist/runtime/coffer.d.ts
CHANGED
|
@@ -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
|
}>;
|
package/dist/runtime/coffer.js
CHANGED
|
@@ -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({
|
package/dist/runtime/config.d.ts
CHANGED
package/dist/runtime/config.js
CHANGED
|
@@ -36,7 +36,6 @@ export function loadAgentConfig(opts = {}) {
|
|
|
36
36
|
skipPermissions: db.skip_permissions !== false,
|
|
37
37
|
responseTimeout: Math.max(60, Number(env.AGENT_RESPONSE_TIMEOUT ?? db.response_timeout ?? 600) || 600),
|
|
38
38
|
ragEnabled: db.rag_enabled !== false,
|
|
39
|
-
ragTopK: 5,
|
|
40
39
|
thinkingEnabled: (env.AGENT_THINKING_ENABLED ?? String(db.thinking_enabled)) === 'true'
|
|
41
40
|
&& supportsAdaptiveThinking(modelId(claudeModel)),
|
|
42
41
|
embeddingApiKey: env.OPENAI_API_KEY ?? db.openai_api_key ?? '',
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -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;
|
package/dist/runtime/index.js
CHANGED
|
@@ -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: ${
|
|
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')
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -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/dist/schema.js
CHANGED
|
@@ -7164,23 +7164,14 @@ var src_default = definePlugin({
|
|
|
7164
7164
|
field.group({
|
|
7165
7165
|
label: "claude-agent.settings.groups.rag",
|
|
7166
7166
|
icon: "lucide:search",
|
|
7167
|
-
fields: [
|
|
7168
|
-
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
label: "claude-agent.settings.openai_api_key"
|
|
7176
|
-
}),
|
|
7177
|
-
field.int({
|
|
7178
|
-
key: "rag_top_k",
|
|
7179
|
-
label: "claude-agent.settings.rag_top_k",
|
|
7180
|
-
default: 5,
|
|
7181
|
-
view: { hidden: true }
|
|
7182
|
-
})
|
|
7183
|
-
]
|
|
7167
|
+
fields: [field.boolean({
|
|
7168
|
+
key: "rag_enabled",
|
|
7169
|
+
label: "claude-agent.settings.rag_enabled",
|
|
7170
|
+
default: true
|
|
7171
|
+
}), field.password({
|
|
7172
|
+
key: "openai_api_key",
|
|
7173
|
+
label: "claude-agent.settings.openai_api_key"
|
|
7174
|
+
})]
|
|
7184
7175
|
}),
|
|
7185
7176
|
field.group({
|
|
7186
7177
|
label: "claude-agent.settings.groups.langfuse",
|