@4onstudios/iris-agent 0.1.0
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/LICENSE +21 -0
- package/README.md +690 -0
- package/dist/api/acp/acpServer.d.ts +23 -0
- package/dist/api/acp/acpServer.js +814 -0
- package/dist/api/acp/index.d.ts +2 -0
- package/dist/api/acp/index.js +2 -0
- package/dist/api/acp/irisClient.d.ts +58 -0
- package/dist/api/acp/irisClient.js +214 -0
- package/dist/api/agent.d.ts +14 -0
- package/dist/api/agent.js +4171 -0
- package/dist/api/backendService.d.ts +4 -0
- package/dist/api/backendService.js +14 -0
- package/dist/api/core/agent/host/AgentContract.d.ts +82 -0
- package/dist/api/core/agent/host/AgentContract.js +1 -0
- package/dist/api/core/agent/host/AgentRegistry.d.ts +24 -0
- package/dist/api/core/agent/host/AgentRegistry.js +125 -0
- package/dist/api/core/agent/host/defaultRegistry.d.ts +15 -0
- package/dist/api/core/agent/host/defaultRegistry.js +46 -0
- package/dist/api/core/agent/host/externalAgentLifecycle.d.ts +65 -0
- package/dist/api/core/agent/host/externalAgentLifecycle.js +117 -0
- package/dist/api/core/agent/host/hostSessionManager.d.ts +111 -0
- package/dist/api/core/agent/host/hostSessionManager.js +352 -0
- package/dist/api/core/agent/host/index.d.ts +5 -0
- package/dist/api/core/agent/host/index.js +5 -0
- package/dist/api/core/agent/index.d.ts +87 -0
- package/dist/api/core/agent/index.js +1024 -0
- package/dist/api/core/agent/publicContracts.d.ts +35 -0
- package/dist/api/core/agent/publicContracts.js +103 -0
- package/dist/api/core/agent/tools/applyDiff.d.ts +51 -0
- package/dist/api/core/agent/tools/applyDiff.js +131 -0
- package/dist/api/core/agent/tools/backgroundTasks.d.ts +240 -0
- package/dist/api/core/agent/tools/backgroundTasks.js +313 -0
- package/dist/api/core/agent/tools/createDirectory.d.ts +43 -0
- package/dist/api/core/agent/tools/createDirectory.js +77 -0
- package/dist/api/core/agent/tools/deleteFile.d.ts +37 -0
- package/dist/api/core/agent/tools/deleteFile.js +66 -0
- package/dist/api/core/agent/tools/editFile.d.ts +73 -0
- package/dist/api/core/agent/tools/editFile.js +173 -0
- package/dist/api/core/agent/tools/executeCommand.d.ts +59 -0
- package/dist/api/core/agent/tools/executeCommand.js +250 -0
- package/dist/api/core/agent/tools/fileContent.d.ts +54 -0
- package/dist/api/core/agent/tools/fileContent.js +227 -0
- package/dist/api/core/agent/tools/findDefinition.d.ts +72 -0
- package/dist/api/core/agent/tools/findDefinition.js +109 -0
- package/dist/api/core/agent/tools/findReferences.d.ts +86 -0
- package/dist/api/core/agent/tools/findReferences.js +135 -0
- package/dist/api/core/agent/tools/formatDocument.d.ts +67 -0
- package/dist/api/core/agent/tools/formatDocument.js +90 -0
- package/dist/api/core/agent/tools/getCodeActions.d.ts +77 -0
- package/dist/api/core/agent/tools/getCodeActions.js +97 -0
- package/dist/api/core/agent/tools/getCodeCompletion.d.ts +77 -0
- package/dist/api/core/agent/tools/getCodeCompletion.js +174 -0
- package/dist/api/core/agent/tools/getCodeContext.d.ts +14 -0
- package/dist/api/core/agent/tools/getCodeContext.js +282 -0
- package/dist/api/core/agent/tools/getSignatureHelp.d.ts +61 -0
- package/dist/api/core/agent/tools/getSignatureHelp.js +85 -0
- package/dist/api/core/agent/tools/getSymbols.d.ts +50 -0
- package/dist/api/core/agent/tools/getSymbols.js +164 -0
- package/dist/api/core/agent/tools/getSymbolsLSP.d.ts +58 -0
- package/dist/api/core/agent/tools/getSymbolsLSP.js +147 -0
- package/dist/api/core/agent/tools/getTypeInfo.d.ts +70 -0
- package/dist/api/core/agent/tools/getTypeInfo.js +84 -0
- package/dist/api/core/agent/tools/getWorkspaceInfo.d.ts +80 -0
- package/dist/api/core/agent/tools/getWorkspaceInfo.js +281 -0
- package/dist/api/core/agent/tools/getWorkspaceSymbols.d.ts +53 -0
- package/dist/api/core/agent/tools/getWorkspaceSymbols.js +97 -0
- package/dist/api/core/agent/tools/grepSearch.d.ts +100 -0
- package/dist/api/core/agent/tools/grepSearch.js +211 -0
- package/dist/api/core/agent/tools/languageModelToolsIntegration.d.ts +13 -0
- package/dist/api/core/agent/tools/languageModelToolsIntegration.js +22 -0
- package/dist/api/core/agent/tools/listDirectory.d.ts +66 -0
- package/dist/api/core/agent/tools/listDirectory.js +161 -0
- package/dist/api/core/agent/tools/mcpTools.d.ts +48 -0
- package/dist/api/core/agent/tools/mcpTools.js +442 -0
- package/dist/api/core/agent/tools/queryKnowledgeGraph.d.ts +120 -0
- package/dist/api/core/agent/tools/queryKnowledgeGraph.js +306 -0
- package/dist/api/core/agent/tools/readFile.d.ts +92 -0
- package/dist/api/core/agent/tools/readFile.js +337 -0
- package/dist/api/core/agent/tools/renameFile.d.ts +49 -0
- package/dist/api/core/agent/tools/renameFile.js +86 -0
- package/dist/api/core/agent/tools/renameSymbol.d.ts +70 -0
- package/dist/api/core/agent/tools/renameSymbol.js +106 -0
- package/dist/api/core/agent/tools/runTerminalCommand.d.ts +72 -0
- package/dist/api/core/agent/tools/runTerminalCommand.js +69 -0
- package/dist/api/core/agent/tools/searchFiles.d.ts +82 -0
- package/dist/api/core/agent/tools/searchFiles.js +280 -0
- package/dist/api/core/agent/tools/terminalAutoApprove.d.ts +3 -0
- package/dist/api/core/agent/tools/terminalAutoApprove.js +676 -0
- package/dist/api/core/agent/tools/treeTraversal.d.ts +60 -0
- package/dist/api/core/agent/tools/treeTraversal.js +217 -0
- package/dist/api/core/agent/tools/webSearch.d.ts +37 -0
- package/dist/api/core/agent/tools/webSearch.js +80 -0
- package/dist/api/core/agent/tools/writeFile.d.ts +59 -0
- package/dist/api/core/agent/tools/writeFile.js +97 -0
- package/dist/api/core/agent/utils/capturedWorkspaceMutationBridge.d.ts +12 -0
- package/dist/api/core/agent/utils/capturedWorkspaceMutationBridge.js +67 -0
- package/dist/api/core/agent/utils/diffUtils.d.ts +14 -0
- package/dist/api/core/agent/utils/diffUtils.js +39 -0
- package/dist/api/core/agent/utils/environmentSnapshot.d.ts +42 -0
- package/dist/api/core/agent/utils/environmentSnapshot.js +213 -0
- package/dist/api/core/agent/utils/errorRecovery.d.ts +49 -0
- package/dist/api/core/agent/utils/errorRecovery.js +229 -0
- package/dist/api/core/agent/utils/multimodalTokenLimiter.d.ts +8 -0
- package/dist/api/core/agent/utils/multimodalTokenLimiter.js +238 -0
- package/dist/api/core/agent/utils/openRouterModelSettings.d.ts +12 -0
- package/dist/api/core/agent/utils/openRouterModelSettings.js +34 -0
- package/dist/api/core/agent/utils/pathRecovery.d.ts +1 -0
- package/dist/api/core/agent/utils/pathRecovery.js +29 -0
- package/dist/api/core/agent/utils/repoMapIndex.d.ts +3 -0
- package/dist/api/core/agent/utils/repoMapIndex.js +197 -0
- package/dist/api/core/agent/utils/skillsDiscovery.d.ts +10 -0
- package/dist/api/core/agent/utils/skillsDiscovery.js +50 -0
- package/dist/api/core/agent/utils/toolCallBudget.d.ts +9 -0
- package/dist/api/core/agent/utils/toolCallBudget.js +55 -0
- package/dist/api/core/agent/utils/toolLifecycle.d.ts +30 -0
- package/dist/api/core/agent/utils/toolLifecycle.js +361 -0
- package/dist/api/core/agent/utils/toolResultSafetyProcessor.d.ts +12 -0
- package/dist/api/core/agent/utils/toolResultSafetyProcessor.js +57 -0
- package/dist/api/core/agent/utils/workspaceMutationBridge.d.ts +13 -0
- package/dist/api/core/agent/utils/workspaceMutationBridge.js +149 -0
- package/dist/api/core/agent/utils/workspacePathGuard.d.ts +7 -0
- package/dist/api/core/agent/utils/workspacePathGuard.js +79 -0
- package/dist/api/core/containers/chat/toolResultSerialization.d.ts +8 -0
- package/dist/api/core/containers/chat/toolResultSerialization.js +71 -0
- package/dist/api/core/library/BrowserManager.d.ts +11 -0
- package/dist/api/core/library/BrowserManager.js +66 -0
- package/dist/api/core/library/desktopWorkspace.d.ts +1 -0
- package/dist/api/core/library/desktopWorkspace.js +3 -0
- package/dist/api/core/library/extensionManager.d.ts +10 -0
- package/dist/api/core/library/extensionManager.js +27 -0
- package/dist/api/core/library/knowledgeGraph.d.ts +268 -0
- package/dist/api/core/library/knowledgeGraph.js +989 -0
- package/dist/api/core/library/languageModelTools.d.ts +141 -0
- package/dist/api/core/library/languageModelTools.js +207 -0
- package/dist/api/core/library/localRuntime.d.ts +23 -0
- package/dist/api/core/library/localRuntime.js +144 -0
- package/dist/api/core/library/lsp/coreLsp.d.ts +367 -0
- package/dist/api/core/library/lsp/coreLsp.js +2076 -0
- package/dist/api/core/library/lsp/protocol.d.ts +25 -0
- package/dist/api/core/library/lsp/protocol.js +1 -0
- package/dist/api/core/library/lsp/serverManager.d.ts +37 -0
- package/dist/api/core/library/lsp/serverManager.js +427 -0
- package/dist/api/core/library/mcpServerProvider.d.ts +69 -0
- package/dist/api/core/library/mcpServerProvider.js +152 -0
- package/dist/api/core/library/mcpSettings.d.ts +20 -0
- package/dist/api/core/library/mcpSettings.js +131 -0
- package/dist/api/core/library/patternMatcher.d.ts +66 -0
- package/dist/api/core/library/patternMatcher.js +284 -0
- package/dist/api/core/library/regexEscape.d.ts +4 -0
- package/dist/api/core/library/regexEscape.js +4 -0
- package/dist/api/core/library/runtimeEventBus.d.ts +27 -0
- package/dist/api/core/library/runtimeEventBus.js +78 -0
- package/dist/api/core/library/safetyMiddleware.d.ts +98 -0
- package/dist/api/core/library/safetyMiddleware.js +215 -0
- package/dist/api/core/library/tauri.d.ts +71 -0
- package/dist/api/core/library/tauri.js +222 -0
- package/dist/api/core/library/tauriImport.d.ts +5 -0
- package/dist/api/core/library/tauriImport.js +7 -0
- package/dist/api/core/library/terminalAutoApproveSettings.d.ts +32 -0
- package/dist/api/core/library/terminalAutoApproveSettings.js +529 -0
- package/dist/api/core/library/workspaceIdentity.d.ts +10 -0
- package/dist/api/core/library/workspaceIdentity.js +49 -0
- package/dist/api/core/library/workspaceSummary.d.ts +19 -0
- package/dist/api/core/library/workspaceSummary.js +35 -0
- package/dist/api/core/skills/agent-customization/SKILL.md +27 -0
- package/dist/api/core/skills/bug-fix/SKILL.md +21 -0
- package/dist/api/core/skills/create-pr/SKILL.md +32 -0
- package/dist/api/core/skills/dev-server/SKILL.md +20 -0
- package/dist/api/core/skills/fix-suggestions/SKILL.md +21 -0
- package/dist/api/core/skills/github-search/SKILL.md +21 -0
- package/dist/api/core/skills/github-summary/SKILL.md +25 -0
- package/dist/api/core/skills/integration-tests/SKILL.md +29 -0
- package/dist/api/core/skills/pr-comments/SKILL.md +23 -0
- package/dist/api/core/skills/project-setup/SKILL.md +20 -0
- package/dist/api/core/skills/search-integration/SKILL.md +19 -0
- package/dist/api/core/skills/search-results/SKILL.md +19 -0
- package/dist/api/core/skills/typescript-upgrade/SKILL.md +21 -0
- package/dist/api/data/runStore.d.ts +46 -0
- package/dist/api/data/runStore.js +244 -0
- package/dist/api/helpers/agentUtils.d.ts +11 -0
- package/dist/api/helpers/agentUtils.js +23 -0
- package/dist/api/helpers/modelTokenLimits.d.ts +2 -0
- package/dist/api/helpers/modelTokenLimits.js +158 -0
- package/dist/api/helpers/observationalMemory.d.ts +10 -0
- package/dist/api/helpers/observationalMemory.js +36 -0
- package/dist/api/helpers/promptBudget.d.ts +30 -0
- package/dist/api/helpers/promptBudget.js +216 -0
- package/dist/api/helpers/resolveImageMessageParts.d.ts +9 -0
- package/dist/api/helpers/resolveImageMessageParts.js +140 -0
- package/dist/api/helpers/slashCommands.d.ts +31 -0
- package/dist/api/helpers/slashCommands.js +129 -0
- package/dist/api/helpers/tokenUsage.d.ts +19 -0
- package/dist/api/helpers/tokenUsage.js +81 -0
- package/dist/api/routes/fileRoutes.d.ts +2 -0
- package/dist/api/routes/fileRoutes.js +108 -0
- package/dist/api/routes/lspDocumentRoutes.d.ts +4 -0
- package/dist/api/routes/lspDocumentRoutes.js +84 -0
- package/dist/api/routes/lspHierarchyRoutes.d.ts +4 -0
- package/dist/api/routes/lspHierarchyRoutes.js +122 -0
- package/dist/api/routes/lspPositionRoutes.d.ts +4 -0
- package/dist/api/routes/lspPositionRoutes.js +263 -0
- package/dist/api/routes/lspQueryRoutes.d.ts +4 -0
- package/dist/api/routes/lspQueryRoutes.js +679 -0
- package/dist/api/routes/lspResolveRoutes.d.ts +4 -0
- package/dist/api/routes/lspResolveRoutes.js +143 -0
- package/dist/api/routes/lspSemanticDocumentRoutes.d.ts +4 -0
- package/dist/api/routes/lspSemanticDocumentRoutes.js +98 -0
- package/dist/api/routes/semanticRoutes.d.ts +2 -0
- package/dist/api/routes/semanticRoutes.js +126 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +160 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +38 -0
- package/package.json +100 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type SerializableToolResult = {
|
|
2
|
+
tool?: string;
|
|
3
|
+
name?: string;
|
|
4
|
+
status?: string;
|
|
5
|
+
result?: unknown;
|
|
6
|
+
};
|
|
7
|
+
export declare const serializeToolResultForContinuation: (toolResult: SerializableToolResult, unknownToolLabel?: string) => string;
|
|
8
|
+
export declare const serializeToolResultsForContinuation: (toolResults: SerializableToolResult[], unknownToolLabel?: string) => string;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const MAX_RESULT_CHARS = 12_000;
|
|
2
|
+
const MAX_CONTINUATION_CHARS = 240_000;
|
|
3
|
+
const TRUNCATION_MARKER = "\n[truncated for final-answer synthesis]";
|
|
4
|
+
const truncateForContinuation = (value, maxChars) => {
|
|
5
|
+
if (value.length <= maxChars)
|
|
6
|
+
return value;
|
|
7
|
+
return `${value.slice(0, Math.max(0, maxChars - TRUNCATION_MARKER.length))}${TRUNCATION_MARKER}`;
|
|
8
|
+
};
|
|
9
|
+
const toRecord = (value) => {
|
|
10
|
+
if (!value || typeof value !== "object") {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
};
|
|
15
|
+
const firstNonEmptyString = (...values) => {
|
|
16
|
+
for (const value of values) {
|
|
17
|
+
if (typeof value === "string") {
|
|
18
|
+
const trimmed = value.trim();
|
|
19
|
+
if (trimmed.length > 0) {
|
|
20
|
+
return trimmed;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return "";
|
|
25
|
+
};
|
|
26
|
+
export const serializeToolResultForContinuation = (toolResult, unknownToolLabel = "unknown_tool") => {
|
|
27
|
+
const toolName = toolResult.tool || toolResult.name || unknownToolLabel;
|
|
28
|
+
const rawResult = toRecord(toolResult.result) || {};
|
|
29
|
+
const nestedValue = toRecord(rawResult.value);
|
|
30
|
+
const status = firstNonEmptyString(toolResult.status, rawResult.status, nestedValue?.status) || "completed";
|
|
31
|
+
const output = firstNonEmptyString(rawResult.output, rawResult.content, rawResult.text, rawResult.stdout, rawResult.stderr, nestedValue?.output, nestedValue?.content, nestedValue?.text, nestedValue?.stdout, nestedValue?.stderr);
|
|
32
|
+
const error = firstNonEmptyString(rawResult.error, nestedValue?.error);
|
|
33
|
+
const resultPath = firstNonEmptyString(rawResult.filePath, rawResult.path, nestedValue?.filePath, nestedValue?.path);
|
|
34
|
+
const exitCode = typeof rawResult.exitCode !== "undefined"
|
|
35
|
+
? rawResult.exitCode
|
|
36
|
+
: typeof nestedValue?.exitCode !== "undefined"
|
|
37
|
+
? nestedValue.exitCode
|
|
38
|
+
: undefined;
|
|
39
|
+
const indicatesFailure = rawResult.success === false ||
|
|
40
|
+
nestedValue?.success === false ||
|
|
41
|
+
(typeof exitCode === "number" && exitCode !== 0);
|
|
42
|
+
const displayStatus = indicatesFailure ? "failed" : status;
|
|
43
|
+
const parts = [
|
|
44
|
+
`Tool: ${toolName}`,
|
|
45
|
+
`Status: ${displayStatus}`,
|
|
46
|
+
resultPath ? `Path: ${resultPath}` : "",
|
|
47
|
+
typeof exitCode !== "undefined" ? `ExitCode: ${String(exitCode)}` : "",
|
|
48
|
+
error ? `Error: ${error}` : "",
|
|
49
|
+
output ? `Output:\n${output}` : "",
|
|
50
|
+
`ResultJSON:\n${JSON.stringify(toolResult.result ?? {}, null, 2)}`,
|
|
51
|
+
].filter((part) => part.length > 0);
|
|
52
|
+
return truncateForContinuation(parts.join("\n"), MAX_RESULT_CHARS);
|
|
53
|
+
};
|
|
54
|
+
export const serializeToolResultsForContinuation = (toolResults, unknownToolLabel = "unknown_tool") => {
|
|
55
|
+
const serializedResults = toolResults.map((toolResult) => serializeToolResultForContinuation(toolResult, unknownToolLabel));
|
|
56
|
+
const selected = [];
|
|
57
|
+
let remainingChars = MAX_CONTINUATION_CHARS;
|
|
58
|
+
for (let index = serializedResults.length - 1; index >= 0; index -= 1) {
|
|
59
|
+
const separatorChars = selected.length > 0 ? 2 : 0;
|
|
60
|
+
const result = serializedResults[index];
|
|
61
|
+
if (result.length + separatorChars > remainingChars)
|
|
62
|
+
break;
|
|
63
|
+
selected.unshift(result);
|
|
64
|
+
remainingChars -= result.length + separatorChars;
|
|
65
|
+
}
|
|
66
|
+
const omittedCount = serializedResults.length - selected.length;
|
|
67
|
+
const omissionNotice = omittedCount > 0
|
|
68
|
+
? `[${omittedCount} older tool result${omittedCount === 1 ? "" : "s"} omitted for payload safety]\n\n`
|
|
69
|
+
: "";
|
|
70
|
+
return `${omissionNotice}${selected.join("\n\n")}`;
|
|
71
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Browser, Page } from "puppeteer";
|
|
2
|
+
declare class BrowserManager {
|
|
3
|
+
static instance: BrowserManager | null;
|
|
4
|
+
static initPromise: Promise<void> | null;
|
|
5
|
+
browser: Browser | null;
|
|
6
|
+
static getInstance(): Promise<BrowserManager>;
|
|
7
|
+
init(): Promise<void>;
|
|
8
|
+
newPage(): Promise<Page>;
|
|
9
|
+
close(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export default BrowserManager;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
//creating a class to manage the browsing activities and how it will be handled
|
|
2
|
+
class BrowserManager {
|
|
3
|
+
static instance = null;
|
|
4
|
+
static initPromise = null; // shared promise so concurrent callers all await the same init
|
|
5
|
+
browser = null;
|
|
6
|
+
static async getInstance() {
|
|
7
|
+
if (!BrowserManager.initPromise) {
|
|
8
|
+
BrowserManager.initPromise = (async () => {
|
|
9
|
+
BrowserManager.instance = new BrowserManager();
|
|
10
|
+
await BrowserManager.instance.init();
|
|
11
|
+
})().catch((err) => {
|
|
12
|
+
// Reset so the next caller can attempt initialization again
|
|
13
|
+
BrowserManager.initPromise = null;
|
|
14
|
+
BrowserManager.instance = null;
|
|
15
|
+
throw err;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
await BrowserManager.initPromise;
|
|
19
|
+
if (!BrowserManager.instance) {
|
|
20
|
+
throw new Error("Failed to initialize browser manager instance");
|
|
21
|
+
}
|
|
22
|
+
return BrowserManager.instance;
|
|
23
|
+
}
|
|
24
|
+
async init() {
|
|
25
|
+
// Running in headless mode so no visible browser window is opened.
|
|
26
|
+
// --no-sandbox / --disable-setuid-sandbox disable a major Chromium security
|
|
27
|
+
// boundary and should only be used in constrained environments (e.g. CI/Docker)
|
|
28
|
+
// where the OS sandbox is unavailable. Set BROWSER_NO_SANDBOX=true to opt in.
|
|
29
|
+
const { default: puppeteer } = await import("puppeteer");
|
|
30
|
+
const noSandboxArgs = process.env.BROWSER_NO_SANDBOX === "true"
|
|
31
|
+
? ["--no-sandbox", "--disable-setuid-sandbox"]
|
|
32
|
+
: [];
|
|
33
|
+
this.browser = await puppeteer.launch({
|
|
34
|
+
headless: true,
|
|
35
|
+
args: noSandboxArgs,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async newPage() {
|
|
39
|
+
//before create a new page we need to verify of the browser instance is available first
|
|
40
|
+
//because a page cannot be created without no browser instance.
|
|
41
|
+
//if there is none the we return a new page from the browser instance created
|
|
42
|
+
if (!this.browser) {
|
|
43
|
+
throw new Error("No Browser instance was found!");
|
|
44
|
+
}
|
|
45
|
+
return this.browser.newPage();
|
|
46
|
+
}
|
|
47
|
+
//another method of this class to close the browser instance
|
|
48
|
+
//after browsing activities are complete.
|
|
49
|
+
async close() {
|
|
50
|
+
if (!this.browser) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
await this.browser.close();
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
// Ignore errors from browsers that are already closed
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
this.browser = null;
|
|
61
|
+
BrowserManager.instance = null;
|
|
62
|
+
BrowserManager.initPromise = null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export default BrowserManager;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getDesktopWorkspacePath: () => string | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
|
+
export declare class ExtensionManager extends EventEmitter {
|
|
3
|
+
private copilotLanguageServerEnabled;
|
|
4
|
+
constructor();
|
|
5
|
+
isCopilotLanguageServerEnabled(): boolean;
|
|
6
|
+
setCopilotLanguageServerEnabled(enabled: boolean): void;
|
|
7
|
+
onDidChange(listener: () => void): () => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const extensionManager: ExtensionManager;
|
|
10
|
+
export default ExtensionManager;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
|
+
const COPILOT_LANGUAGE_SERVER_FLAG = "IRIS_ENABLE_COPILOT_LANGUAGE_SERVER";
|
|
3
|
+
export class ExtensionManager extends EventEmitter {
|
|
4
|
+
copilotLanguageServerEnabled;
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
this.copilotLanguageServerEnabled = process.env[COPILOT_LANGUAGE_SERVER_FLAG] === "true";
|
|
8
|
+
}
|
|
9
|
+
isCopilotLanguageServerEnabled() {
|
|
10
|
+
return this.copilotLanguageServerEnabled;
|
|
11
|
+
}
|
|
12
|
+
setCopilotLanguageServerEnabled(enabled) {
|
|
13
|
+
if (this.copilotLanguageServerEnabled === enabled) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
this.copilotLanguageServerEnabled = enabled;
|
|
17
|
+
this.emit("change");
|
|
18
|
+
}
|
|
19
|
+
onDidChange(listener) {
|
|
20
|
+
this.on("change", listener);
|
|
21
|
+
return () => {
|
|
22
|
+
this.off("change", listener);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export const extensionManager = new ExtensionManager();
|
|
27
|
+
export default ExtensionManager;
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Knowledge Graph System for Token Optimization
|
|
3
|
+
* Implements intelligent context caching and relationship tracking
|
|
4
|
+
*/
|
|
5
|
+
import { createDefaultMatcher } from "./patternMatcher.js";
|
|
6
|
+
export type KnowledgeNodeType = "file" | "function" | "class" | "import" | "context" | "method" | "interface" | "variable";
|
|
7
|
+
export type KnowledgeRelationship = {
|
|
8
|
+
nodeId: string;
|
|
9
|
+
type: string;
|
|
10
|
+
metadata: Record<string, unknown>;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
confidence?: number;
|
|
13
|
+
};
|
|
14
|
+
export type KnowledgeMethod = {
|
|
15
|
+
name: string;
|
|
16
|
+
isAsync: boolean;
|
|
17
|
+
};
|
|
18
|
+
export type KnowledgeNodeMetadata = Record<string, unknown> & {
|
|
19
|
+
name?: string;
|
|
20
|
+
language?: string;
|
|
21
|
+
path?: string;
|
|
22
|
+
filePath?: string;
|
|
23
|
+
startLine?: number;
|
|
24
|
+
endLine?: number;
|
|
25
|
+
extends?: string | null;
|
|
26
|
+
implements?: string[];
|
|
27
|
+
methods?: KnowledgeMethod[];
|
|
28
|
+
className?: string;
|
|
29
|
+
methodName?: string;
|
|
30
|
+
isAsync?: boolean;
|
|
31
|
+
};
|
|
32
|
+
type RedactionInfo = {
|
|
33
|
+
count: number;
|
|
34
|
+
types: string[];
|
|
35
|
+
};
|
|
36
|
+
type KnowledgeComponent = {
|
|
37
|
+
type: KnowledgeNodeType;
|
|
38
|
+
name: string;
|
|
39
|
+
content: string;
|
|
40
|
+
startLine: number;
|
|
41
|
+
endLine?: number;
|
|
42
|
+
dependencies?: string[];
|
|
43
|
+
calls?: string[];
|
|
44
|
+
uses?: string[];
|
|
45
|
+
extends?: string | null;
|
|
46
|
+
implements?: string[];
|
|
47
|
+
methods?: KnowledgeMethod[];
|
|
48
|
+
};
|
|
49
|
+
type PatternAnalysis = {
|
|
50
|
+
patterns: Record<string, unknown[]>;
|
|
51
|
+
complexity: number;
|
|
52
|
+
structures: string[];
|
|
53
|
+
};
|
|
54
|
+
export type KnowledgeContext = {
|
|
55
|
+
nodes: KnowledgeNode[];
|
|
56
|
+
tokenCount: number;
|
|
57
|
+
contextText: string;
|
|
58
|
+
retrieval?: {
|
|
59
|
+
mode: "entity" | "question";
|
|
60
|
+
question?: string;
|
|
61
|
+
anchorNodeIds?: string[];
|
|
62
|
+
hops?: number;
|
|
63
|
+
matchedTerms?: string[];
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
type CacheEntry = {
|
|
67
|
+
context: KnowledgeContext;
|
|
68
|
+
tokenCount: number;
|
|
69
|
+
timestamp: number;
|
|
70
|
+
node?: KnowledgeNode;
|
|
71
|
+
};
|
|
72
|
+
type ContextQuery = {
|
|
73
|
+
type?: string;
|
|
74
|
+
id: string;
|
|
75
|
+
relatedFiles?: string[];
|
|
76
|
+
maxTokens?: number;
|
|
77
|
+
};
|
|
78
|
+
type QuestionQuery = {
|
|
79
|
+
question: string;
|
|
80
|
+
anchorId?: string;
|
|
81
|
+
relatedFiles?: string[];
|
|
82
|
+
maxTokens?: number;
|
|
83
|
+
maxDepth?: number;
|
|
84
|
+
};
|
|
85
|
+
type ScoredNode = {
|
|
86
|
+
node: KnowledgeNode;
|
|
87
|
+
score: number;
|
|
88
|
+
};
|
|
89
|
+
type IndexedFile = {
|
|
90
|
+
path: string;
|
|
91
|
+
name?: string;
|
|
92
|
+
content: string;
|
|
93
|
+
language?: string | null;
|
|
94
|
+
};
|
|
95
|
+
type GraphStatistics = {
|
|
96
|
+
nodeCount: number;
|
|
97
|
+
cacheSize: number;
|
|
98
|
+
cacheHits: number;
|
|
99
|
+
cacheMisses: number;
|
|
100
|
+
hitRate: string;
|
|
101
|
+
totalTokensSaved: number;
|
|
102
|
+
estimatedCostSaved: string;
|
|
103
|
+
};
|
|
104
|
+
type ExportGraphNode = {
|
|
105
|
+
id: string;
|
|
106
|
+
type: string;
|
|
107
|
+
label: string;
|
|
108
|
+
size: number;
|
|
109
|
+
accessCount: number;
|
|
110
|
+
};
|
|
111
|
+
type ExportGraphEdge = {
|
|
112
|
+
source: string;
|
|
113
|
+
target: string;
|
|
114
|
+
type: string;
|
|
115
|
+
};
|
|
116
|
+
type ExportGraph = {
|
|
117
|
+
nodes: ExportGraphNode[];
|
|
118
|
+
edges: ExportGraphEdge[];
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Knowledge Node - Represents a piece of code context
|
|
122
|
+
*/
|
|
123
|
+
export declare class KnowledgeNode {
|
|
124
|
+
id: string;
|
|
125
|
+
type: KnowledgeNodeType;
|
|
126
|
+
content: string;
|
|
127
|
+
originalContent: string | null;
|
|
128
|
+
redacted: boolean;
|
|
129
|
+
redactionInfo: RedactionInfo | null;
|
|
130
|
+
metadata: KnowledgeNodeMetadata;
|
|
131
|
+
relationships: Set<KnowledgeRelationship>;
|
|
132
|
+
accessCount: number;
|
|
133
|
+
lastAccessed: number;
|
|
134
|
+
tokenCount: number;
|
|
135
|
+
embedding: unknown;
|
|
136
|
+
constructor(id: string, type: KnowledgeNodeType, content: string, metadata?: KnowledgeNodeMetadata);
|
|
137
|
+
estimateTokens(text: string): number;
|
|
138
|
+
addRelationship(nodeId: string, relationshipType: string, metadata?: Record<string, unknown>, confidence?: number): void;
|
|
139
|
+
hasRelationship(nodeId: string, relationshipType: string): boolean;
|
|
140
|
+
getRelationships(type?: string | null): KnowledgeRelationship[];
|
|
141
|
+
access(): void;
|
|
142
|
+
get score(): number;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Knowledge Graph - Manages code context and relationships
|
|
146
|
+
*/
|
|
147
|
+
declare class KnowledgeGraph {
|
|
148
|
+
nodes: Map<string, KnowledgeNode>;
|
|
149
|
+
cache: Map<string, CacheEntry>;
|
|
150
|
+
maxCacheSize: number;
|
|
151
|
+
totalTokensSaved: number;
|
|
152
|
+
cacheHits: number;
|
|
153
|
+
cacheMisses: number;
|
|
154
|
+
patternMatcher: ReturnType<typeof createDefaultMatcher>;
|
|
155
|
+
constructor();
|
|
156
|
+
initializeEventListeners(): void;
|
|
157
|
+
/**
|
|
158
|
+
* Create or update a node
|
|
159
|
+
*/
|
|
160
|
+
upsertNode(id: string, type: KnowledgeNodeType, content: string, metadata?: KnowledgeNodeMetadata): KnowledgeNode;
|
|
161
|
+
/**
|
|
162
|
+
* Index a file and its components
|
|
163
|
+
*/
|
|
164
|
+
indexFile(file: IndexedFile): void;
|
|
165
|
+
normalizePathLike(input: string): string;
|
|
166
|
+
resolveImportPath(sourceFilePath: string, importPath: string): string;
|
|
167
|
+
/**
|
|
168
|
+
* Parse code components (functions, classes, imports)
|
|
169
|
+
*/
|
|
170
|
+
parseComponents(content: string, language?: string | null): KnowledgeComponent[];
|
|
171
|
+
/**
|
|
172
|
+
* Enhanced: Extract function calls from code
|
|
173
|
+
*/
|
|
174
|
+
extractFunctionCalls(code: string): string[];
|
|
175
|
+
/**
|
|
176
|
+
* Enhanced: Extract variable usage from code
|
|
177
|
+
*/
|
|
178
|
+
extractVariableUsage(code: string): string[];
|
|
179
|
+
/**
|
|
180
|
+
* Enhanced: Extract methods from class
|
|
181
|
+
*/
|
|
182
|
+
extractClassMethods(classCode: string): KnowledgeMethod[];
|
|
183
|
+
/**
|
|
184
|
+
* Check if a word is a JavaScript keyword
|
|
185
|
+
*/
|
|
186
|
+
isKeyword(word: string): boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Enhanced: Build semantic relationships between components
|
|
189
|
+
*/
|
|
190
|
+
buildSemanticRelationships(path: string, components: KnowledgeComponent[]): void;
|
|
191
|
+
/**
|
|
192
|
+
* Find a node by name and type
|
|
193
|
+
*/
|
|
194
|
+
findNodeByName(name: string, type: KnowledgeNodeType): string;
|
|
195
|
+
/**
|
|
196
|
+
* Extract code block from position
|
|
197
|
+
*/
|
|
198
|
+
extractBlock(content: string, startIndex: number): string;
|
|
199
|
+
/**
|
|
200
|
+
* Extract statement (for arrow functions, etc.)
|
|
201
|
+
*/
|
|
202
|
+
extractStatement(content: string, startIndex: number): string;
|
|
203
|
+
/**
|
|
204
|
+
* Enhanced: Use pattern matching to analyze code structure
|
|
205
|
+
*/
|
|
206
|
+
analyzeWithPatterns(code: string): {
|
|
207
|
+
patterns: Record<string, unknown[]>;
|
|
208
|
+
complexity: number;
|
|
209
|
+
structures: string[];
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* Calculate code complexity score
|
|
213
|
+
*/
|
|
214
|
+
calculateComplexity(patterns: PatternAnalysis["patterns"]): number;
|
|
215
|
+
/**
|
|
216
|
+
* Query context with caching
|
|
217
|
+
*/
|
|
218
|
+
queryContext(query: ContextQuery): KnowledgeContext;
|
|
219
|
+
/**
|
|
220
|
+
* Build context from knowledge graph
|
|
221
|
+
*/
|
|
222
|
+
buildContext(type: string | undefined, id: string, relatedFiles?: string[], maxTokens?: number): KnowledgeContext;
|
|
223
|
+
extractQuestionTerms(question: string): string[];
|
|
224
|
+
scoreNodeForQuestion(node: KnowledgeNode, terms: string[], relatedFiles: string[]): number;
|
|
225
|
+
findAnchorNodes(question: string, relatedFiles?: string[], limit?: number): {
|
|
226
|
+
terms: string[];
|
|
227
|
+
anchors: ScoredNode[];
|
|
228
|
+
};
|
|
229
|
+
getRelationshipWeight(type: string): number;
|
|
230
|
+
collectNeighbors(nodeId: string): {
|
|
231
|
+
nodeId: string;
|
|
232
|
+
edgeWeight: number;
|
|
233
|
+
}[];
|
|
234
|
+
queryByQuestion(query: QuestionQuery): KnowledgeContext;
|
|
235
|
+
/**
|
|
236
|
+
* Update cache with LRU eviction
|
|
237
|
+
*/
|
|
238
|
+
updateCache(key: string, context: KnowledgeContext): void;
|
|
239
|
+
/**
|
|
240
|
+
* Update context when code changes
|
|
241
|
+
*/
|
|
242
|
+
updateContext(data: {
|
|
243
|
+
filePath: string;
|
|
244
|
+
content: string;
|
|
245
|
+
}): void;
|
|
246
|
+
/**
|
|
247
|
+
* Invalidate cache entries related to a file
|
|
248
|
+
*/
|
|
249
|
+
invalidateCache(filePath: string): void;
|
|
250
|
+
/**
|
|
251
|
+
* Detect language from file extension
|
|
252
|
+
*/
|
|
253
|
+
detectLanguage(filePath: string): string;
|
|
254
|
+
/**
|
|
255
|
+
* Get statistics for telemetry
|
|
256
|
+
*/
|
|
257
|
+
getStatistics(): GraphStatistics;
|
|
258
|
+
/**
|
|
259
|
+
* Export graph for visualization
|
|
260
|
+
*/
|
|
261
|
+
exportGraph(): ExportGraph;
|
|
262
|
+
/**
|
|
263
|
+
* Clear all data
|
|
264
|
+
*/
|
|
265
|
+
clear(): void;
|
|
266
|
+
}
|
|
267
|
+
export declare const knowledgeGraph: KnowledgeGraph;
|
|
268
|
+
export default KnowledgeGraph;
|