the-citadel 0.4.0 → 0.4.1
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/citadel.config.d.ts +5 -0
- package/dist/index.js +46 -3
- package/dist/src/config/schema.d.ts +5 -0
- package/package.json +1 -1
package/dist/citadel.config.d.ts
CHANGED
|
@@ -62,5 +62,10 @@ declare const _default: {
|
|
|
62
62
|
bridge?: {
|
|
63
63
|
maxLogs?: number | undefined;
|
|
64
64
|
} | undefined;
|
|
65
|
+
context?: {
|
|
66
|
+
maxHistoryMessages?: number | undefined;
|
|
67
|
+
maxToolResponseSize?: number | undefined;
|
|
68
|
+
maxMessageSize?: number | undefined;
|
|
69
|
+
} | undefined;
|
|
65
70
|
};
|
|
66
71
|
export default _default;
|
package/dist/index.js
CHANGED
|
@@ -65045,7 +65045,16 @@ var ConfigSchema = exports_external.object({
|
|
|
65045
65045
|
}),
|
|
65046
65046
|
bridge: exports_external.object({
|
|
65047
65047
|
maxLogs: exports_external.number().default(1000)
|
|
65048
|
-
}).default({ maxLogs: 1000 })
|
|
65048
|
+
}).default({ maxLogs: 1000 }),
|
|
65049
|
+
context: exports_external.object({
|
|
65050
|
+
maxHistoryMessages: exports_external.number().default(50),
|
|
65051
|
+
maxToolResponseSize: exports_external.number().default(50000),
|
|
65052
|
+
maxMessageSize: exports_external.number().default(1e5)
|
|
65053
|
+
}).default({
|
|
65054
|
+
maxHistoryMessages: 20,
|
|
65055
|
+
maxToolResponseSize: 50000,
|
|
65056
|
+
maxMessageSize: 1e5
|
|
65057
|
+
})
|
|
65049
65058
|
});
|
|
65050
65059
|
|
|
65051
65060
|
// src/config/index.ts
|
|
@@ -93845,7 +93854,9 @@ class CoreAgent {
|
|
|
93845
93854
|
}
|
|
93846
93855
|
async checkPermissions(toolName, args) {
|
|
93847
93856
|
const targets = [];
|
|
93848
|
-
if (args
|
|
93857
|
+
if (!args || typeof args !== "object")
|
|
93858
|
+
return { allowed: true };
|
|
93859
|
+
if ("paths" in args && Array.isArray(args.paths)) {
|
|
93849
93860
|
targets.push(...args.paths);
|
|
93850
93861
|
}
|
|
93851
93862
|
if (args.path && typeof args.path === "string")
|
|
@@ -93948,6 +93959,27 @@ Request: ${prompt}`
|
|
|
93948
93959
|
let didRemindForCompletion = false;
|
|
93949
93960
|
let completionToolCalled = false;
|
|
93950
93961
|
for (let i2 = 0;i2 < 50; i2++) {
|
|
93962
|
+
const config2 = getConfig();
|
|
93963
|
+
const { maxHistoryMessages = 20, maxToolResponseSize = 50000, maxMessageSize = 1e5 } = config2.context || {};
|
|
93964
|
+
if (messages.length > maxHistoryMessages) {
|
|
93965
|
+
const systemMessage = messages[0];
|
|
93966
|
+
const lastN = messages.slice(-maxHistoryMessages);
|
|
93967
|
+
if (lastN.length > 0 && lastN[0] && lastN[0].role === "tool") {
|
|
93968
|
+
const toolResult = lastN[0];
|
|
93969
|
+
const originalIndex = messages.indexOf(toolResult);
|
|
93970
|
+
if (originalIndex > 0) {
|
|
93971
|
+
const preceding = messages[originalIndex - 1];
|
|
93972
|
+
if (preceding && preceding !== toolResult) {
|
|
93973
|
+
lastN.unshift(preceding);
|
|
93974
|
+
}
|
|
93975
|
+
}
|
|
93976
|
+
}
|
|
93977
|
+
messages.length = 0;
|
|
93978
|
+
messages.push(...lastN);
|
|
93979
|
+
if (systemMessage) {
|
|
93980
|
+
messages.unshift(systemMessage);
|
|
93981
|
+
}
|
|
93982
|
+
}
|
|
93951
93983
|
const result = await this.executeGenerateText(messages);
|
|
93952
93984
|
const assistantContent = [];
|
|
93953
93985
|
if (result.text) {
|
|
@@ -93962,6 +93994,10 @@ Request: ${prompt}`
|
|
|
93962
93994
|
})));
|
|
93963
93995
|
}
|
|
93964
93996
|
if (assistantContent.length > 0) {
|
|
93997
|
+
const contentStr = JSON.stringify(assistantContent);
|
|
93998
|
+
if (contentStr.length > maxMessageSize) {
|
|
93999
|
+
logger.warn(`[${this.role}] Message size ${contentStr.length} exceeds limit ${maxMessageSize}. Truncating logic not fully implemented for mixed content, but proceeding.`);
|
|
94000
|
+
}
|
|
93965
94001
|
messages.push({ role: "assistant", content: assistantContent });
|
|
93966
94002
|
}
|
|
93967
94003
|
finalResult = result.text;
|
|
@@ -94099,7 +94135,14 @@ If you are still working, continue with your next step.`
|
|
|
94099
94135
|
finished = true;
|
|
94100
94136
|
completionToolCalled = true;
|
|
94101
94137
|
}
|
|
94102
|
-
|
|
94138
|
+
let toolOutputValue = typeof output === "string" ? output : JSON.stringify(output);
|
|
94139
|
+
if (toolOutputValue.length > maxToolResponseSize) {
|
|
94140
|
+
const truncated = toolOutputValue.substring(0, maxToolResponseSize);
|
|
94141
|
+
toolOutputValue = `${truncated}
|
|
94142
|
+
... [Output truncated. Total size: ${toolOutputValue.length} characters (Limit: ${maxToolResponseSize})]`;
|
|
94143
|
+
logger.warn(`[${this.role}] Tool ${toolName} output truncated from ${toolOutputValue.length} to ${maxToolResponseSize}`);
|
|
94144
|
+
}
|
|
94145
|
+
const toolOutput = { type: "text", value: toolOutputValue };
|
|
94103
94146
|
toolResults.push({
|
|
94104
94147
|
type: "tool-result",
|
|
94105
94148
|
toolCallId: tc.toolCallId,
|
|
@@ -82,6 +82,11 @@ export declare const ConfigSchema: z.ZodObject<{
|
|
|
82
82
|
bridge: z.ZodDefault<z.ZodObject<{
|
|
83
83
|
maxLogs: z.ZodDefault<z.ZodNumber>;
|
|
84
84
|
}, z.core.$strip>>;
|
|
85
|
+
context: z.ZodDefault<z.ZodObject<{
|
|
86
|
+
maxHistoryMessages: z.ZodDefault<z.ZodNumber>;
|
|
87
|
+
maxToolResponseSize: z.ZodDefault<z.ZodNumber>;
|
|
88
|
+
maxMessageSize: z.ZodDefault<z.ZodNumber>;
|
|
89
|
+
}, z.core.$strip>>;
|
|
85
90
|
}, z.core.$strip>;
|
|
86
91
|
export type CitadelConfig = z.infer<typeof ConfigSchema>;
|
|
87
92
|
export type CitadelConfigInput = z.input<typeof ConfigSchema>;
|