@aj-archipelago/cortex 1.4.3 → 1.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.
- package/lib/crypto.js +28 -1
- package/lib/entityConstants.js +3 -0
- package/lib/util.js +5 -1
- package/package.json +2 -2
- package/pathways/system/entity/sys_entity_agent.js +2 -1
- package/pathways/system/entity/tools/sys_tool_codingagent.js +2 -2
- package/pathways/system/workspaces/workspace_applet_edit.js +551 -29
- package/testrun.log +0 -35371
package/lib/crypto.js
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
import logger from './logger.js';
|
|
3
3
|
import crypto from 'crypto';
|
|
4
4
|
|
|
5
|
+
// Helper function to generate a preview of a message for logging
|
|
6
|
+
function getMessagePreview(message, maxLength = 50) {
|
|
7
|
+
if (typeof message === 'string') {
|
|
8
|
+
return message.substring(0, maxLength);
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
return JSON.stringify(message).substring(0, maxLength);
|
|
12
|
+
} catch (e) {
|
|
13
|
+
return String(message).substring(0, maxLength);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
5
17
|
// Encryption function
|
|
6
18
|
function encrypt(text, key) {
|
|
7
19
|
if (!key) { return text; }
|
|
@@ -22,6 +34,20 @@ function encrypt(text, key) {
|
|
|
22
34
|
function decrypt(message, key) {
|
|
23
35
|
if (!key) { return message; }
|
|
24
36
|
try {
|
|
37
|
+
// Quick type check - if not string, convert or skip
|
|
38
|
+
if (typeof message !== 'string') {
|
|
39
|
+
if (Buffer.isBuffer(message)) {
|
|
40
|
+
message = message.toString('utf8');
|
|
41
|
+
} else if (message === null || message === undefined) {
|
|
42
|
+
logger.warn(`Decryption skipped: message is ${message === null ? 'null' : 'undefined'}`);
|
|
43
|
+
return null;
|
|
44
|
+
} else {
|
|
45
|
+
const preview = getMessagePreview(message);
|
|
46
|
+
logger.warn(`Decryption skipped: message is not a string (type: ${typeof message}, preview: ${preview})`);
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
25
51
|
key = tryBufferKey(key);
|
|
26
52
|
let parts = message.split(':');
|
|
27
53
|
let iv = Buffer.from(parts.shift(), 'hex');
|
|
@@ -31,7 +57,8 @@ function decrypt(message, key) {
|
|
|
31
57
|
decrypted += decipher.final('utf8');
|
|
32
58
|
return decrypted;
|
|
33
59
|
} catch (error) {
|
|
34
|
-
|
|
60
|
+
const preview = getMessagePreview(message);
|
|
61
|
+
logger.error(`Decryption failed: ${error.message} (preview: ${preview})`);
|
|
35
62
|
return null;
|
|
36
63
|
}
|
|
37
64
|
}
|
package/lib/entityConstants.js
CHANGED
|
@@ -26,6 +26,7 @@ Your responses should be in {{language}} unless the user has expressed another p
|
|
|
26
26
|
- You have an extensive toolkit. Each time you call tool(s) you will get the result(s), evaluate, decide what's next, and chain as many steps as needed.
|
|
27
27
|
- Your tools work most efficiently when called in parallel so if you know you will need multiple tool calls and you know what the parameters are, call them in parallel.
|
|
28
28
|
- Always honor user requests to use specific tools.
|
|
29
|
+
- For data processing requests (e.g. tell me how many articles were published in the last 30 days), or deep file analysis (chart the trends in this spreadsheet, etc.), you should call your code execution tool to perform the task - especially if the task requires a lot of data, deep analysis, complex filtering, or precision calculations. For simpler things (e.g. make me a chart of the population of the world in the last 100 years) you might find it faster to search for the data and then just call your charting tool to generate the chart.
|
|
29
30
|
- You must always search if you are being asked questions about current events, news, fact-checking, or information requiring citation.
|
|
30
31
|
- Do not make up information - if information cannot be confirmed with rigorous logic or reliable sources, do not include it in your response.
|
|
31
32
|
- Start searches broad and consult multiple sources, running all searches in parallel to save time.
|
|
@@ -123,6 +124,8 @@ Privacy is critical. If asked to forget or delete something, always comply affir
|
|
|
123
124
|
|
|
124
125
|
AI_STYLE_OPENAI: "oai-gpt5-chat",
|
|
125
126
|
AI_STYLE_OPENAI_RESEARCH: "oai-gpt5",
|
|
127
|
+
AI_STYLE_OPENAI_LEGACY: "oai-gpt41",
|
|
128
|
+
AI_STYLE_OPENAI_LEGACY_RESEARCH: "oai-o3",
|
|
126
129
|
AI_STYLE_ANTHROPIC: "claude-4-sonnet-vertex",
|
|
127
130
|
AI_STYLE_ANTHROPIC_RESEARCH: "claude-41-opus-vertex",
|
|
128
131
|
AI_STYLE_XAI: "xai-grok-4-fast-reasoning",
|
package/lib/util.js
CHANGED
|
@@ -475,8 +475,12 @@ const uploadImageToCloud = async (base64Data, mimeType, pathwayResolver = null)
|
|
|
475
475
|
contentType: mimeType
|
|
476
476
|
});
|
|
477
477
|
|
|
478
|
+
// Append requestId parameter (preserving existing query parameters like subscription-key)
|
|
479
|
+
const separator = fileHandlerUrl.includes('?') ? '&' : '?';
|
|
480
|
+
const uploadUrl = `${fileHandlerUrl}${separator}requestId=${requestId}`;
|
|
481
|
+
|
|
478
482
|
// Upload file
|
|
479
|
-
const uploadResponse = await axios.post(
|
|
483
|
+
const uploadResponse = await axios.post(uploadUrl, formData, {
|
|
480
484
|
headers: {
|
|
481
485
|
...formData.getHeaders()
|
|
482
486
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aj-archipelago/cortex",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.5",
|
|
4
4
|
"description": "Cortex is a GraphQL API for AI. It provides a simple, extensible interface for using AI services from OpenAI, Azure and others.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"repository": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"type": "module",
|
|
34
34
|
"homepage": "https://github.com/aj-archipelago/cortex#readme",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@aj-archipelago/merval": "^1.0.
|
|
36
|
+
"@aj-archipelago/merval": "^1.0.3",
|
|
37
37
|
"@aj-archipelago/subvibe": "^1.0.12",
|
|
38
38
|
"@apollo/server": "^4.7.3",
|
|
39
39
|
"@apollo/server-plugin-response-cache": "^4.1.2",
|
|
@@ -333,12 +333,13 @@ export default {
|
|
|
333
333
|
];
|
|
334
334
|
|
|
335
335
|
// set the style model if applicable
|
|
336
|
-
const { aiStyle, AI_STYLE_ANTHROPIC, AI_STYLE_OPENAI, AI_STYLE_ANTHROPIC_RESEARCH, AI_STYLE_OPENAI_RESEARCH, AI_STYLE_XAI, AI_STYLE_XAI_RESEARCH, AI_STYLE_GOOGLE, AI_STYLE_GOOGLE_RESEARCH } = args;
|
|
336
|
+
const { aiStyle, AI_STYLE_ANTHROPIC, AI_STYLE_OPENAI, AI_STYLE_ANTHROPIC_RESEARCH, AI_STYLE_OPENAI_RESEARCH, AI_STYLE_OPENAI_LEGACY, AI_STYLE_OPENAI_LEGACY_RESEARCH, AI_STYLE_XAI, AI_STYLE_XAI_RESEARCH, AI_STYLE_GOOGLE, AI_STYLE_GOOGLE_RESEARCH } = args;
|
|
337
337
|
|
|
338
338
|
// Create a mapping of AI styles to their corresponding models
|
|
339
339
|
const styleModelMap = {
|
|
340
340
|
"Anthropic": { normal: AI_STYLE_ANTHROPIC, research: AI_STYLE_ANTHROPIC_RESEARCH },
|
|
341
341
|
"OpenAI": { normal: AI_STYLE_OPENAI, research: AI_STYLE_OPENAI_RESEARCH },
|
|
342
|
+
"OpenAI_Legacy": { normal: AI_STYLE_OPENAI_LEGACY, research: AI_STYLE_OPENAI_LEGACY_RESEARCH },
|
|
342
343
|
"XAI": { normal: AI_STYLE_XAI, research: AI_STYLE_XAI_RESEARCH },
|
|
343
344
|
"Google": { normal: AI_STYLE_GOOGLE, research: AI_STYLE_GOOGLE_RESEARCH }
|
|
344
345
|
};
|
|
@@ -48,7 +48,7 @@ export default {
|
|
|
48
48
|
icon: "🤖",
|
|
49
49
|
function: {
|
|
50
50
|
name: "CodeExecution",
|
|
51
|
-
description: "This tool allows you to engage an agent to write and execute code to perform a task on your behalf. Use when explicitly asked to run or execute code, or when a coding agent is needed to perform specific tasks - examples include data analysis, file manipulation, or other tasks that require code execution. With this tool you can also access internal databases and query them directly. This will start a background task and return - you will not receive the response immediately.",
|
|
51
|
+
description: "This tool allows you to asynchronously engage an agent to write and execute code to perform a task on your behalf. Use when explicitly asked to run or execute code, or when a coding agent is needed to perform specific tasks - examples include data analysis, file manipulation, or other tasks that require code execution. With this tool you can read and write files and also access internal databases and query them directly. This will start a background task and return - you will not receive the response immediately.",
|
|
52
52
|
parameters: {
|
|
53
53
|
type: "object",
|
|
54
54
|
properties: {
|
|
@@ -66,7 +66,7 @@ export default {
|
|
|
66
66
|
},
|
|
67
67
|
codingTaskKeywords: {
|
|
68
68
|
type: "string",
|
|
69
|
-
description: "Keywords for Azure Cognitive Search to help the coding agent find relevant code snippets"
|
|
69
|
+
description: "Keywords for the coding agent's internal Azure Cognitive Search index to help the coding agent find relevant code snippets"
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
72
|
required: ["codingTask", "userMessage", "codingTaskKeywords"]
|