the-citadel 0.4.4 → 0.4.5
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.
Potentially problematic release.
This version of the-citadel might be problematic. Click here for more details.
package/dist/config/schema.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export declare const ConfigSchema: z.ZodObject<{
|
|
|
25
25
|
}>;
|
|
26
26
|
model: z.ZodString;
|
|
27
27
|
mcpTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
28
|
+
mcpResources: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
|
|
28
29
|
}, z.core.$strip>;
|
|
29
30
|
worker: z.ZodObject<{
|
|
30
31
|
provider: z.ZodEnum<{
|
|
@@ -34,6 +35,7 @@ export declare const ConfigSchema: z.ZodObject<{
|
|
|
34
35
|
}>;
|
|
35
36
|
model: z.ZodString;
|
|
36
37
|
mcpTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
38
|
+
mcpResources: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
|
|
37
39
|
}, z.core.$strip>;
|
|
38
40
|
gatekeeper: z.ZodObject<{
|
|
39
41
|
provider: z.ZodEnum<{
|
|
@@ -43,6 +45,7 @@ export declare const ConfigSchema: z.ZodObject<{
|
|
|
43
45
|
}>;
|
|
44
46
|
model: z.ZodString;
|
|
45
47
|
mcpTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
48
|
+
mcpResources: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
|
|
46
49
|
}, z.core.$strip>;
|
|
47
50
|
}, z.core.$strip>;
|
|
48
51
|
mcpServers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
package/dist/core/formula.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export declare const FormulaSchema: z.ZodObject<{
|
|
|
27
27
|
default: z.ZodOptional<z.ZodString>;
|
|
28
28
|
}, z.core.$strip>>>;
|
|
29
29
|
prompts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
30
|
+
mcp_resources: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
|
|
30
31
|
steps: z.ZodArray<z.ZodObject<{
|
|
31
32
|
id: z.ZodString;
|
|
32
33
|
title: z.ZodString;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { InstructionContext, InstructionProvider } from "./instruction";
|
|
2
|
+
export declare class MCPResourceProvider implements InstructionProvider {
|
|
3
|
+
name: string;
|
|
4
|
+
priority: number;
|
|
5
|
+
getInstructions(ctx: InstructionContext): Promise<string | null>;
|
|
6
|
+
private mergeResources;
|
|
7
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -64994,17 +64994,20 @@ var ConfigSchema = exports_external.object({
|
|
|
64994
64994
|
router: exports_external.object({
|
|
64995
64995
|
provider: exports_external.enum(["openai", "anthropic", "ollama"]),
|
|
64996
64996
|
model: exports_external.string(),
|
|
64997
|
-
mcpTools: exports_external.array(exports_external.string()).optional()
|
|
64997
|
+
mcpTools: exports_external.array(exports_external.string()).optional(),
|
|
64998
|
+
mcpResources: exports_external.record(exports_external.string(), exports_external.array(exports_external.string())).optional()
|
|
64998
64999
|
}),
|
|
64999
65000
|
worker: exports_external.object({
|
|
65000
65001
|
provider: exports_external.enum(["openai", "anthropic", "ollama"]),
|
|
65001
65002
|
model: exports_external.string(),
|
|
65002
|
-
mcpTools: exports_external.array(exports_external.string()).optional()
|
|
65003
|
+
mcpTools: exports_external.array(exports_external.string()).optional(),
|
|
65004
|
+
mcpResources: exports_external.record(exports_external.string(), exports_external.array(exports_external.string())).optional()
|
|
65003
65005
|
}),
|
|
65004
65006
|
gatekeeper: exports_external.object({
|
|
65005
65007
|
provider: exports_external.enum(["openai", "anthropic", "ollama"]),
|
|
65006
65008
|
model: exports_external.string(),
|
|
65007
|
-
mcpTools: exports_external.array(exports_external.string()).optional()
|
|
65009
|
+
mcpTools: exports_external.array(exports_external.string()).optional(),
|
|
65010
|
+
mcpResources: exports_external.record(exports_external.string(), exports_external.array(exports_external.string())).optional()
|
|
65008
65011
|
})
|
|
65009
65012
|
}),
|
|
65010
65013
|
mcpServers: exports_external.record(exports_external.string(), exports_external.object({
|
|
@@ -81464,6 +81467,48 @@ class MCPService {
|
|
|
81464
81467
|
arguments: args
|
|
81465
81468
|
});
|
|
81466
81469
|
}
|
|
81470
|
+
async readResource(serverName, uri) {
|
|
81471
|
+
const client = this.clients.get(serverName);
|
|
81472
|
+
if (!client) {
|
|
81473
|
+
logger.warn(`[MCP] Server ${serverName} not connected for resource ${uri}`);
|
|
81474
|
+
return [];
|
|
81475
|
+
}
|
|
81476
|
+
try {
|
|
81477
|
+
logger.info(`[MCP] Reading resource ${serverName}:${uri}`);
|
|
81478
|
+
const result = await client.request({
|
|
81479
|
+
method: "resources/read",
|
|
81480
|
+
params: { uri }
|
|
81481
|
+
}, ReadResourceRequestSchema);
|
|
81482
|
+
return result.contents.map((content) => {
|
|
81483
|
+
if ("text" in content && content.text) {
|
|
81484
|
+
return content.text;
|
|
81485
|
+
}
|
|
81486
|
+
if ("blob" in content) {
|
|
81487
|
+
logger.warn(`[MCP] Skipping binary resource content for ${uri}`);
|
|
81488
|
+
}
|
|
81489
|
+
return null;
|
|
81490
|
+
}).filter((text2) => text2 !== null);
|
|
81491
|
+
} catch (error48) {
|
|
81492
|
+
logger.error(`[MCP] Failed to read resource ${serverName}:${uri}:`, error48);
|
|
81493
|
+
return [];
|
|
81494
|
+
}
|
|
81495
|
+
}
|
|
81496
|
+
async listResources(serverName) {
|
|
81497
|
+
const client = this.clients.get(serverName);
|
|
81498
|
+
if (!client) {
|
|
81499
|
+
logger.warn(`[MCP] Server ${serverName} not connected for listResources`);
|
|
81500
|
+
return [];
|
|
81501
|
+
}
|
|
81502
|
+
try {
|
|
81503
|
+
const result = await client.request({
|
|
81504
|
+
method: "resources/list"
|
|
81505
|
+
}, ListResourcesRequestSchema);
|
|
81506
|
+
return result.resources;
|
|
81507
|
+
} catch (error48) {
|
|
81508
|
+
logger.error(`[MCP] Failed to list resources for ${serverName}:`, error48);
|
|
81509
|
+
return [];
|
|
81510
|
+
}
|
|
81511
|
+
}
|
|
81467
81512
|
async shutdown() {
|
|
81468
81513
|
for (const [name18, client] of this.clients) {
|
|
81469
81514
|
try {
|
|
@@ -84763,6 +84808,7 @@ var FormulaSchema = exports_external.object({
|
|
|
84763
84808
|
description: exports_external.string(),
|
|
84764
84809
|
vars: exports_external.record(exports_external.string(), FormulaVariableSchema).optional(),
|
|
84765
84810
|
prompts: exports_external.record(exports_external.string(), exports_external.string()).optional(),
|
|
84811
|
+
mcp_resources: exports_external.record(exports_external.string(), exports_external.array(exports_external.string())).optional(),
|
|
84766
84812
|
steps: exports_external.array(FormulaStepSchema)
|
|
84767
84813
|
});
|
|
84768
84814
|
|
|
@@ -84809,6 +84855,81 @@ function getFormulaRegistry(basePath) {
|
|
|
84809
84855
|
return _registry;
|
|
84810
84856
|
}
|
|
84811
84857
|
|
|
84858
|
+
// src/core/mcp-resource-provider.ts
|
|
84859
|
+
class MCPResourceProvider {
|
|
84860
|
+
name = "mcp-resources";
|
|
84861
|
+
priority = 25;
|
|
84862
|
+
async getInstructions(ctx) {
|
|
84863
|
+
const resourcesToFetch = {};
|
|
84864
|
+
const config2 = getConfig();
|
|
84865
|
+
const roleConfig = config2.agents[ctx.role];
|
|
84866
|
+
if (roleConfig && "mcpResources" in roleConfig && roleConfig.mcpResources) {
|
|
84867
|
+
this.mergeResources(resourcesToFetch, roleConfig.mcpResources);
|
|
84868
|
+
}
|
|
84869
|
+
if (ctx.beadId) {
|
|
84870
|
+
try {
|
|
84871
|
+
const bead = await getBeads().get(ctx.beadId);
|
|
84872
|
+
const formulaLabel = bead.labels?.find((l) => l.startsWith("formula:"));
|
|
84873
|
+
if (formulaLabel) {
|
|
84874
|
+
const formulaName = formulaLabel.split(":")[1];
|
|
84875
|
+
if (formulaName) {
|
|
84876
|
+
const formula = getFormulaRegistry().get(formulaName);
|
|
84877
|
+
if (formula?.mcp_resources) {
|
|
84878
|
+
this.mergeResources(resourcesToFetch, formula.mcp_resources);
|
|
84879
|
+
}
|
|
84880
|
+
}
|
|
84881
|
+
}
|
|
84882
|
+
if (bead.context?.mcp_resources) {
|
|
84883
|
+
this.mergeResources(resourcesToFetch, bead.context.mcp_resources);
|
|
84884
|
+
}
|
|
84885
|
+
} catch (err) {
|
|
84886
|
+
logger.debug(`[MCPResourceProvider] Error fetching resources from bead/formula: ${err}`);
|
|
84887
|
+
}
|
|
84888
|
+
}
|
|
84889
|
+
if (Object.keys(resourcesToFetch).length === 0)
|
|
84890
|
+
return null;
|
|
84891
|
+
const mcpService = getMCPService();
|
|
84892
|
+
const results = [];
|
|
84893
|
+
for (const [serverName, uris] of Object.entries(resourcesToFetch)) {
|
|
84894
|
+
for (const uri of uris) {
|
|
84895
|
+
try {
|
|
84896
|
+
const contents = await mcpService.readResource(serverName, uri);
|
|
84897
|
+
if (contents.length > 0) {
|
|
84898
|
+
results.push(`## RESOURCE: ${serverName}:${uri}
|
|
84899
|
+
${contents.join(`
|
|
84900
|
+
|
|
84901
|
+
`)}`);
|
|
84902
|
+
}
|
|
84903
|
+
} catch (err) {
|
|
84904
|
+
logger.warn(`[MCPResourceProvider] Failed to fetch resource ${serverName}:${uri}: ${err}`);
|
|
84905
|
+
}
|
|
84906
|
+
}
|
|
84907
|
+
}
|
|
84908
|
+
if (results.length === 0)
|
|
84909
|
+
return null;
|
|
84910
|
+
return `
|
|
84911
|
+
# CONTEXT RESOURCES
|
|
84912
|
+
The following resources have been injected into your context for this task:
|
|
84913
|
+
|
|
84914
|
+
${results.join(`
|
|
84915
|
+
|
|
84916
|
+
---
|
|
84917
|
+
|
|
84918
|
+
`)}
|
|
84919
|
+
`;
|
|
84920
|
+
}
|
|
84921
|
+
mergeResources(target, source) {
|
|
84922
|
+
for (const [server, uris] of Object.entries(source)) {
|
|
84923
|
+
if (!target[server]) {
|
|
84924
|
+
target[server] = new Set;
|
|
84925
|
+
}
|
|
84926
|
+
for (const uri of uris) {
|
|
84927
|
+
target[server].add(uri);
|
|
84928
|
+
}
|
|
84929
|
+
}
|
|
84930
|
+
}
|
|
84931
|
+
}
|
|
84932
|
+
|
|
84812
84933
|
// src/core/instruction.ts
|
|
84813
84934
|
class GlobalProvider {
|
|
84814
84935
|
name = "global";
|
|
@@ -84961,6 +85082,7 @@ class InstructionService {
|
|
|
84961
85082
|
new GlobalProvider,
|
|
84962
85083
|
new BuiltinProvider,
|
|
84963
85084
|
new RoleProvider,
|
|
85085
|
+
new MCPResourceProvider,
|
|
84964
85086
|
new FormulaProvider,
|
|
84965
85087
|
new TagProvider,
|
|
84966
85088
|
new ContextProvider
|
package/dist/services/mcp.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export declare class MCPService {
|
|
|
13
13
|
initialize(): Promise<void>;
|
|
14
14
|
getToolsForAgent(assignedTools?: string[]): Promise<MCPTool[]>;
|
|
15
15
|
callTool(serverName: string, toolName: string, args: Record<string, unknown>): Promise<unknown>;
|
|
16
|
+
readResource(serverName: string, uri: string): Promise<string[]>;
|
|
17
|
+
listResources(serverName: string): Promise<unknown[]>;
|
|
16
18
|
shutdown(): Promise<void>;
|
|
17
19
|
}
|
|
18
20
|
export declare function getMCPService(): MCPService;
|
package/dist/tools/worker.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare const createReportProgressTool: (_context: AgentContext) => impor
|
|
|
20
20
|
}>;
|
|
21
21
|
export declare const createDelegateTaskTool: (_context: AgentContext) => import("ai").Tool<{
|
|
22
22
|
title: string;
|
|
23
|
-
priority: "
|
|
23
|
+
priority: "critical" | "low" | "normal" | "high";
|
|
24
24
|
parentBeadId?: string | undefined;
|
|
25
25
|
tags?: string[] | undefined;
|
|
26
26
|
description?: string | undefined;
|