@mcoda/mswarm 0.1.134 → 0.1.135-codali.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/README.md +40 -0
- package/dist/codali-executor.d.ts +63 -0
- package/dist/codali-executor.d.ts.map +1 -1
- package/dist/codali-executor.js +78 -8
- package/dist/codali-executor.js.map +1 -1
- package/dist/invocation-token.d.ts.map +1 -1
- package/dist/invocation-token.js +1 -0
- package/dist/invocation-token.js.map +1 -1
- package/dist/native-reasoning.d.ts +8 -0
- package/dist/native-reasoning.d.ts.map +1 -0
- package/dist/native-reasoning.js +18 -0
- package/dist/native-reasoning.js.map +1 -0
- package/dist/runtime.d.ts +23 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +181 -15
- package/dist/runtime.js.map +1 -1
- package/dist/server.d.ts +3 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +58 -8
- package/dist/server.js.map +1 -1
- package/dist/vendor/codali/agents/RoleResolution.d.ts.map +1 -1
- package/dist/vendor/codali/agents/RoleResolution.js +4 -4
- package/dist/vendor/codali/api/CodaliApi.d.ts +16 -0
- package/dist/vendor/codali/api/CodaliApi.d.ts.map +1 -1
- package/dist/vendor/codali/api/CodaliApi.js +39 -10
- package/dist/vendor/codali/cli/AskCommand.d.ts +3 -0
- package/dist/vendor/codali/cli/AskCommand.d.ts.map +1 -1
- package/dist/vendor/codali/cli/AskCommand.js +76 -13
- package/dist/vendor/codali/cli/RunCommand.d.ts +4 -0
- package/dist/vendor/codali/cli/RunCommand.d.ts.map +1 -1
- package/dist/vendor/codali/cli/RunCommand.js +110 -24
- package/dist/vendor/codali/cli/TerminalCommand.d.ts +35 -0
- package/dist/vendor/codali/cli/TerminalCommand.d.ts.map +1 -0
- package/dist/vendor/codali/cli/TerminalCommand.js +616 -0
- package/dist/vendor/codali/cli/TerminalCredentials.d.ts +3 -0
- package/dist/vendor/codali/cli/TerminalCredentials.d.ts.map +1 -0
- package/dist/vendor/codali/cli/TerminalCredentials.js +89 -0
- package/dist/vendor/codali/cli/TerminalInput.d.ts +24 -0
- package/dist/vendor/codali/cli/TerminalInput.d.ts.map +1 -0
- package/dist/vendor/codali/cli/TerminalInput.js +98 -0
- package/dist/vendor/codali/cli/TerminalText.d.ts +10 -0
- package/dist/vendor/codali/cli/TerminalText.d.ts.map +1 -0
- package/dist/vendor/codali/cli/TerminalText.js +53 -0
- package/dist/vendor/codali/cli.d.ts.map +1 -1
- package/dist/vendor/codali/cli.js +33 -4
- package/dist/vendor/codali/cognitive/ConfiguredPipeline.d.ts +34 -0
- package/dist/vendor/codali/cognitive/ConfiguredPipeline.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ConfiguredPipeline.js +50 -0
- package/dist/vendor/codali/cognitive/ValidationRunner.d.ts +4 -0
- package/dist/vendor/codali/cognitive/ValidationRunner.d.ts.map +1 -1
- package/dist/vendor/codali/cognitive/ValidationRunner.js +18 -41
- package/dist/vendor/codali/config/NodeOrchestration.d.ts +21 -0
- package/dist/vendor/codali/config/NodeOrchestration.d.ts.map +1 -0
- package/dist/vendor/codali/config/NodeOrchestration.js +54 -0
- package/dist/vendor/codali/config/OrchestrationConfig.d.ts +100 -0
- package/dist/vendor/codali/config/OrchestrationConfig.d.ts.map +1 -0
- package/dist/vendor/codali/config/OrchestrationConfig.js +245 -0
- package/dist/vendor/codali/connectors/mcp/McpClient.d.ts +3 -1
- package/dist/vendor/codali/connectors/mcp/McpClient.d.ts.map +1 -1
- package/dist/vendor/codali/connectors/mcp/McpClient.js +3 -2
- package/dist/vendor/codali/connectors/mcp/McpServerRegistry.d.ts +2 -2
- package/dist/vendor/codali/connectors/mcp/McpServerRegistry.d.ts.map +1 -1
- package/dist/vendor/codali/connectors/mcp/McpServerRegistry.js +39 -16
- package/dist/vendor/codali/connectors/mcp/McpToolAdapter.js +2 -2
- package/dist/vendor/codali/connectors/media/ConfiguredMediaTools.d.ts +6 -0
- package/dist/vendor/codali/connectors/media/ConfiguredMediaTools.d.ts.map +1 -0
- package/dist/vendor/codali/connectors/media/ConfiguredMediaTools.js +41 -0
- package/dist/vendor/codali/connectors/media/ImageGenerationTool.js +3 -3
- package/dist/vendor/codali/connectors/media/MediaArtifactReceipt.d.ts +5 -0
- package/dist/vendor/codali/connectors/media/MediaArtifactReceipt.d.ts.map +1 -0
- package/dist/vendor/codali/connectors/media/MediaArtifactReceipt.js +65 -0
- package/dist/vendor/codali/connectors/media/MediaJobStore.d.ts +68 -0
- package/dist/vendor/codali/connectors/media/MediaJobStore.d.ts.map +1 -0
- package/dist/vendor/codali/connectors/media/MediaJobStore.js +199 -0
- package/dist/vendor/codali/connectors/media/MediaJobWorker.d.ts +2 -0
- package/dist/vendor/codali/connectors/media/MediaJobWorker.d.ts.map +1 -0
- package/dist/vendor/codali/connectors/media/MediaJobWorker.js +65 -0
- package/dist/vendor/codali/connectors/media/RemoteMediaJob.d.ts +6 -0
- package/dist/vendor/codali/connectors/media/RemoteMediaJob.d.ts.map +1 -0
- package/dist/vendor/codali/connectors/media/RemoteMediaJob.js +80 -0
- package/dist/vendor/codali/docdex/DocdexClient.d.ts +18 -1
- package/dist/vendor/codali/docdex/DocdexClient.d.ts.map +1 -1
- package/dist/vendor/codali/docdex/DocdexClient.js +135 -19
- package/dist/vendor/codali/docdex/ManagedDocdex.d.ts +29 -0
- package/dist/vendor/codali/docdex/ManagedDocdex.d.ts.map +1 -0
- package/dist/vendor/codali/docdex/ManagedDocdex.js +215 -0
- package/dist/vendor/codali/docdex/ManagedRuntime.d.ts +28 -0
- package/dist/vendor/codali/docdex/ManagedRuntime.d.ts.map +1 -0
- package/dist/vendor/codali/docdex/ManagedRuntime.js +212 -0
- package/dist/vendor/codali/eval/EvaluationProcess.d.ts +13 -0
- package/dist/vendor/codali/eval/EvaluationProcess.d.ts.map +1 -0
- package/dist/vendor/codali/eval/EvaluationProcess.js +76 -0
- package/dist/vendor/codali/eval/LongWorkflowJourney.d.ts +34 -0
- package/dist/vendor/codali/eval/LongWorkflowJourney.d.ts.map +1 -0
- package/dist/vendor/codali/eval/LongWorkflowJourney.js +243 -0
- package/dist/vendor/codali/eval/PlanningCorpus.d.ts +45 -0
- package/dist/vendor/codali/eval/PlanningCorpus.d.ts.map +1 -0
- package/dist/vendor/codali/eval/PlanningCorpus.js +189 -0
- package/dist/vendor/codali/eval/PlanningCorpusRunner.d.ts +13 -0
- package/dist/vendor/codali/eval/PlanningCorpusRunner.d.ts.map +1 -0
- package/dist/vendor/codali/eval/PlanningCorpusRunner.js +89 -0
- package/dist/vendor/codali/eval/TerminalCorpusRunner.d.ts +36 -0
- package/dist/vendor/codali/eval/TerminalCorpusRunner.d.ts.map +1 -0
- package/dist/vendor/codali/eval/TerminalCorpusRunner.js +222 -0
- package/dist/vendor/codali/eval/TerminalTaskCorpus.d.ts +26 -0
- package/dist/vendor/codali/eval/TerminalTaskCorpus.d.ts.map +1 -0
- package/dist/vendor/codali/eval/TerminalTaskCorpus.js +105 -0
- package/dist/vendor/codali/eval/TerminalWorkflowCorpus.d.ts +11 -0
- package/dist/vendor/codali/eval/TerminalWorkflowCorpus.d.ts.map +1 -0
- package/dist/vendor/codali/eval/TerminalWorkflowCorpus.js +116 -0
- package/dist/vendor/codali/eval/fixtures/TerminalRecoveryJourney.d.ts +4 -0
- package/dist/vendor/codali/eval/fixtures/TerminalRecoveryJourney.d.ts.map +1 -0
- package/dist/vendor/codali/eval/fixtures/TerminalRecoveryJourney.js +132 -0
- package/dist/vendor/codali/gateway/CodaliGateway.d.ts +2 -0
- package/dist/vendor/codali/gateway/CodaliGateway.d.ts.map +1 -1
- package/dist/vendor/codali/gateway/CodaliGateway.js +11 -1
- package/dist/vendor/codali/gateway/ConfiguredGateway.d.ts +23 -0
- package/dist/vendor/codali/gateway/ConfiguredGateway.d.ts.map +1 -0
- package/dist/vendor/codali/gateway/ConfiguredGateway.js +44 -0
- package/dist/vendor/codali/gateway/GatewayTracer.d.ts +1 -1
- package/dist/vendor/codali/gateway/GatewayTracer.d.ts.map +1 -1
- package/dist/vendor/codali/gateway/GatewayTracer.js +2 -27
- package/dist/vendor/codali/index.d.ts +23 -0
- package/dist/vendor/codali/index.d.ts.map +1 -1
- package/dist/vendor/codali/index.js +12 -0
- package/dist/vendor/codali/permissions/PermissionGate.d.ts +44 -0
- package/dist/vendor/codali/permissions/PermissionGate.d.ts.map +1 -0
- package/dist/vendor/codali/permissions/PermissionGate.js +97 -0
- package/dist/vendor/codali/providers/ConfiguredEmbeddings.d.ts +43 -0
- package/dist/vendor/codali/providers/ConfiguredEmbeddings.d.ts.map +1 -0
- package/dist/vendor/codali/providers/ConfiguredEmbeddings.js +87 -0
- package/dist/vendor/codali/providers/ConfiguredModelScope.d.ts +69 -0
- package/dist/vendor/codali/providers/ConfiguredModelScope.d.ts.map +1 -0
- package/dist/vendor/codali/providers/ConfiguredModelScope.js +113 -0
- package/dist/vendor/codali/providers/ConfiguredProvider.d.ts +79 -0
- package/dist/vendor/codali/providers/ConfiguredProvider.d.ts.map +1 -0
- package/dist/vendor/codali/providers/ConfiguredProvider.js +238 -0
- package/dist/vendor/codali/providers/ModelServiceError.d.ts +10 -0
- package/dist/vendor/codali/providers/ModelServiceError.d.ts.map +1 -0
- package/dist/vendor/codali/providers/ModelServiceError.js +45 -0
- package/dist/vendor/codali/providers/MswarmWorkerProvider.d.ts.map +1 -1
- package/dist/vendor/codali/providers/MswarmWorkerProvider.js +4 -0
- package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts.map +1 -1
- package/dist/vendor/codali/providers/OpenAiCompatibleProvider.js +91 -50
- package/dist/vendor/codali/providers/ProviderTypes.d.ts +12 -0
- package/dist/vendor/codali/providers/ProviderTypes.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/CodaliJobRuntime.d.ts +6 -0
- package/dist/vendor/codali/runtime/CodaliJobRuntime.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/CodaliJobRuntime.js +36 -1
- package/dist/vendor/codali/runtime/CodaliRuntime.d.ts +28 -0
- package/dist/vendor/codali/runtime/CodaliRuntime.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/CodaliRuntime.js +69 -1
- package/dist/vendor/codali/runtime/CompletionReport.d.ts +5 -0
- package/dist/vendor/codali/runtime/CompletionReport.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/CompletionReport.js +12 -0
- package/dist/vendor/codali/runtime/ProgressTracker.d.ts +17 -0
- package/dist/vendor/codali/runtime/ProgressTracker.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/ProgressTracker.js +27 -0
- package/dist/vendor/codali/runtime/RequestedTestEvidence.d.ts +12 -0
- package/dist/vendor/codali/runtime/RequestedTestEvidence.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/RequestedTestEvidence.js +16 -0
- package/dist/vendor/codali/runtime/RequiredRetrieval.d.ts +13 -0
- package/dist/vendor/codali/runtime/RequiredRetrieval.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/RequiredRetrieval.js +25 -0
- package/dist/vendor/codali/runtime/ReviewSource.d.ts +6 -0
- package/dist/vendor/codali/runtime/ReviewSource.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/ReviewSource.js +38 -0
- package/dist/vendor/codali/runtime/Runner.d.ts +7 -0
- package/dist/vendor/codali/runtime/Runner.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/Runner.js +215 -171
- package/dist/vendor/codali/runtime/SecretRedaction.d.ts +11 -0
- package/dist/vendor/codali/runtime/SecretRedaction.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/SecretRedaction.js +85 -0
- package/dist/vendor/codali/runtime/SessionController.d.ts +148 -0
- package/dist/vendor/codali/runtime/SessionController.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/SessionController.js +1356 -0
- package/dist/vendor/codali/runtime/StructuralEvidence.d.ts +22 -0
- package/dist/vendor/codali/runtime/StructuralEvidence.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/StructuralEvidence.js +87 -0
- package/dist/vendor/codali/runtime/TaskReviewContext.d.ts +34 -0
- package/dist/vendor/codali/runtime/TaskReviewContext.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/TaskReviewContext.js +34 -0
- package/dist/vendor/codali/runtime/ValidationOutput.d.ts +5 -0
- package/dist/vendor/codali/runtime/ValidationOutput.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/ValidationOutput.js +32 -0
- package/dist/vendor/codali/runtime/VerificationCommand.d.ts +3 -0
- package/dist/vendor/codali/runtime/VerificationCommand.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/VerificationCommand.js +48 -0
- package/dist/vendor/codali/runtime/WorkStatusPage.d.ts +15 -0
- package/dist/vendor/codali/runtime/WorkStatusPage.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/WorkStatusPage.js +58 -0
- package/dist/vendor/codali/runtime/WorkspaceLedger.d.ts +13 -0
- package/dist/vendor/codali/runtime/WorkspaceLedger.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/WorkspaceLedger.js +145 -0
- package/dist/vendor/codali/runtime/WorkspaceLock.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/WorkspaceLock.js +20 -17
- package/dist/vendor/codali/runtime/WorkspaceSnapshot.d.ts +13 -0
- package/dist/vendor/codali/runtime/WorkspaceSnapshot.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/WorkspaceSnapshot.js +88 -0
- package/dist/vendor/codali/session/AtomicState.d.ts +13 -0
- package/dist/vendor/codali/session/AtomicState.d.ts.map +1 -0
- package/dist/vendor/codali/session/AtomicState.js +109 -0
- package/dist/vendor/codali/session/SessionStoragePath.d.ts +15 -0
- package/dist/vendor/codali/session/SessionStoragePath.d.ts.map +1 -0
- package/dist/vendor/codali/session/SessionStoragePath.js +89 -0
- package/dist/vendor/codali/session/SessionStore.d.ts +9 -0
- package/dist/vendor/codali/session/SessionStore.d.ts.map +1 -1
- package/dist/vendor/codali/session/SessionStore.js +181 -47
- package/dist/vendor/codali/session/WorkState.d.ts +23 -0
- package/dist/vendor/codali/session/WorkState.d.ts.map +1 -0
- package/dist/vendor/codali/session/WorkState.js +367 -0
- package/dist/vendor/codali/session/WorkTypes.d.ts +94 -0
- package/dist/vendor/codali/session/WorkTypes.d.ts.map +1 -0
- package/dist/vendor/codali/session/WorkTypes.js +1 -0
- package/dist/vendor/codali/tools/ToolRegistry.d.ts +2 -0
- package/dist/vendor/codali/tools/ToolRegistry.d.ts.map +1 -1
- package/dist/vendor/codali/tools/ToolRegistry.js +12 -2
- package/dist/vendor/codali/tools/ToolTypes.d.ts +16 -0
- package/dist/vendor/codali/tools/ToolTypes.d.ts.map +1 -1
- package/dist/vendor/codali/tools/docdex/DocdexTools.d.ts +2 -0
- package/dist/vendor/codali/tools/docdex/DocdexTools.d.ts.map +1 -1
- package/dist/vendor/codali/tools/docdex/DocdexTools.js +17 -2
- package/dist/vendor/codali/tools/filesystem/FileTools.d.ts.map +1 -1
- package/dist/vendor/codali/tools/filesystem/FileTools.js +30 -10
- package/dist/vendor/codali/tools/shell/AsyncProcess.d.ts +16 -0
- package/dist/vendor/codali/tools/shell/AsyncProcess.d.ts.map +1 -0
- package/dist/vendor/codali/tools/shell/AsyncProcess.js +94 -0
- package/dist/vendor/codali/tools/shell/DarwinRuntimeLibraries.d.ts +13 -0
- package/dist/vendor/codali/tools/shell/DarwinRuntimeLibraries.d.ts.map +1 -0
- package/dist/vendor/codali/tools/shell/DarwinRuntimeLibraries.js +130 -0
- package/dist/vendor/codali/tools/shell/HostToolchain.d.ts +19 -0
- package/dist/vendor/codali/tools/shell/HostToolchain.d.ts.map +1 -0
- package/dist/vendor/codali/tools/shell/HostToolchain.js +264 -0
- package/dist/vendor/codali/tools/shell/IsolatedExecutor.d.ts +15 -0
- package/dist/vendor/codali/tools/shell/IsolatedExecutor.d.ts.map +1 -0
- package/dist/vendor/codali/tools/shell/IsolatedExecutor.js +134 -0
- package/dist/vendor/codali/tools/shell/ShellTool.d.ts.map +1 -1
- package/dist/vendor/codali/tools/shell/ShellTool.js +9 -29
- package/dist/vendor/codali/tools/shell/ShellWorkingDirectory.d.ts +3 -0
- package/dist/vendor/codali/tools/shell/ShellWorkingDirectory.d.ts.map +1 -0
- package/dist/vendor/codali/tools/shell/ShellWorkingDirectory.js +30 -0
- package/package.json +31 -29
- package/scripts/backend-http-drain.mjs +152 -0
- package/scripts/media_gpu_lock.py +238 -0
- package/scripts/stable-audio-3-openai-server.py +45 -14
- package/scripts/stable-diffusion-cpp-openai-server.py +34 -4
- package/scripts/stable-diffusion-cpp-webm-duration.patch +22 -0
- package/scripts/wan22-openai-server.py +97 -18
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { DocdexCapabilitySnapshot } from "../cognitive/Types.js";
|
|
2
2
|
export interface DocdexClientOptions {
|
|
3
|
+
/** Trusted host accounting hook; each retrieval HTTP attempt reserves before dispatch. */
|
|
4
|
+
beforeRequest?: (url: string) => void | Promise<void>;
|
|
5
|
+
signal?: () => AbortSignal | undefined;
|
|
6
|
+
timeoutMs?: number;
|
|
7
|
+
localSearchOnly?: boolean;
|
|
3
8
|
baseUrl: string;
|
|
4
9
|
repoRoot?: string;
|
|
5
10
|
repoId?: string;
|
|
@@ -15,7 +20,7 @@ export interface DocdexClientOptions {
|
|
|
15
20
|
dagSessionId?: string;
|
|
16
21
|
}
|
|
17
22
|
export type DocdexRuntimeErrorCode = "missing_credentials" | "repo_access_denied" | "scope_denied" | "encrypted_operation_disabled" | "docdex_context_missing" | "docdex_api_key_missing" | "docdex_operation_not_allowed" | "docdex_auth_failed" | "docdex_repo_access_denied" | "docdex_unavailable";
|
|
18
|
-
export type DocdexRuntimeOperation = "health" | "initialize" | "search" | "snippet" | "open" | "symbols" | "ast" | "impact_graph" | "impact_diagnostics" | "dag_export" | "tree" | "memory_save" | "memory_recall" | "profile_read" | "profile_write" | "web_research" | "chat_context" | "rerank" | "batch_search" | "capabilities" | "stats" | "files" | "repo_inspect" | "index_rebuild" | "index_ingest" | "delegate" | "hooks_validate";
|
|
23
|
+
export type DocdexRuntimeOperation = "health" | "initialize" | "search" | "snippet" | "open" | "symbols" | "ast" | "impact_graph" | "impact_diagnostics" | "dag_export" | "tree" | "memory_save" | "memory_recall" | "wakeup" | "diary_read" | "diary_write" | "conversation_read" | "conversation_search" | "kg_query" | "profile_read" | "profile_write" | "web_research" | "chat_context" | "rerank" | "batch_search" | "capabilities" | "stats" | "files" | "repo_inspect" | "index_rebuild" | "index_ingest" | "delegate" | "hooks_validate";
|
|
19
24
|
export interface DocdexRuntimeErrorOptions {
|
|
20
25
|
status?: number;
|
|
21
26
|
retryable?: boolean;
|
|
@@ -114,7 +119,10 @@ export declare class DocdexClient {
|
|
|
114
119
|
private healthChecked;
|
|
115
120
|
private repoInitializeAttempted;
|
|
116
121
|
private capabilitySnapshot?;
|
|
122
|
+
private mcpSessionId?;
|
|
123
|
+
private mcpInitialize?;
|
|
117
124
|
constructor(options: DocdexClientOptions);
|
|
125
|
+
private fetch;
|
|
118
126
|
setRepoId(repoId: string): void;
|
|
119
127
|
getRepoId(): string | undefined;
|
|
120
128
|
getRepoRoot(): string | undefined;
|
|
@@ -145,6 +153,8 @@ export declare class DocdexClient {
|
|
|
145
153
|
}>;
|
|
146
154
|
private initializeRepo;
|
|
147
155
|
private ensureRepoInitialized;
|
|
156
|
+
/** Wait locally for a warming index instead of paying for model polling. */
|
|
157
|
+
waitForIndex(timeoutMs?: number, onProgress?: (status: string) => void): Promise<unknown>;
|
|
148
158
|
private withRepoId;
|
|
149
159
|
private extractErrorCode;
|
|
150
160
|
private mapResponseErrorCode;
|
|
@@ -162,6 +172,7 @@ export declare class DocdexClient {
|
|
|
162
172
|
delegate(payload: Record<string, unknown>): Promise<unknown>;
|
|
163
173
|
chatContext(messages: DocdexChatMessage[], options?: DocdexChatContextOptions): Promise<unknown>;
|
|
164
174
|
dagExport(sessionId: string, options?: DocdexDagOptions): Promise<unknown>;
|
|
175
|
+
private ensureMcpSession;
|
|
165
176
|
callMcp<T>(method: string, params: Record<string, unknown>): Promise<T>;
|
|
166
177
|
private normalizeMcpResult;
|
|
167
178
|
private tryParseJson;
|
|
@@ -176,6 +187,12 @@ export declare class DocdexClient {
|
|
|
176
187
|
repoInspect(): Promise<unknown>;
|
|
177
188
|
memorySave(text: string, metadata?: DocdexWriteMetadata): Promise<unknown>;
|
|
178
189
|
memoryRecall(query: string, topK?: number): Promise<unknown>;
|
|
190
|
+
wakeup(query: string, agentId?: string, maxTokens?: number): Promise<unknown>;
|
|
191
|
+
diaryRead(limit?: number): Promise<unknown>;
|
|
192
|
+
diaryWrite(content: string): Promise<unknown>;
|
|
193
|
+
conversationSearch(query: string, limit?: number): Promise<unknown>;
|
|
194
|
+
conversationRead(sessionId: string): Promise<unknown>;
|
|
195
|
+
knowledgeQuery(query: string, limit?: number): Promise<unknown>;
|
|
179
196
|
tree(options?: DocdexTreeOptions): Promise<unknown>;
|
|
180
197
|
openFile(pathValue: string, options?: DocdexOpenFileOptions): Promise<unknown>;
|
|
181
198
|
getProfile(agentId?: string): Promise<unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocdexClient.d.ts","sourceRoot":"","sources":["../../src/docdex/DocdexClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DocdexClient.d.ts","sourceRoot":"","sources":["../../src/docdex/DocdexClient.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,wBAAwB,EAEzB,MAAM,uBAAuB,CAAC;AAG/B,MAAM,WAAW,mBAAmB;IAClC,0FAA0F;IAC1F,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,MAAM,CAAC,EAAE,MAAM,WAAW,GAAG,SAAS,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,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AAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIrD,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,OAAO,CAAC,OAAO,CAAC;IAI1D,IAAI,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC;IAavD,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,OAAO,CAAC;IAalF,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAM9C,cAAc,CACZ,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,mBAAmB,GAC7B,OAAO,CAAC,OAAO,CAAC;IASnB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,OAAO,CAAC;YAgBtE,eAAe;IA4C7B,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAWxE,WAAW,CACf,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,OAAO,CAAA;KAAO,GACtD,OAAO,CAAC,OAAO,CAAC;IAgCb,eAAe,CAAC,YAAY,UAAQ,GAAG,OAAO,CAAC,wBAAwB,CAAC;CAmC/E"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
3
4
|
import { pathToFileURL } from "node:url";
|
|
4
5
|
import { mswarmClientProductHeaders } from "@mcoda/shared";
|
|
5
6
|
export class DocdexRuntimeError extends Error {
|
|
@@ -45,6 +46,12 @@ const DOCDEX_RUNTIME_OPERATIONS = new Set([
|
|
|
45
46
|
"tree",
|
|
46
47
|
"memory_save",
|
|
47
48
|
"memory_recall",
|
|
49
|
+
"wakeup",
|
|
50
|
+
"diary_read",
|
|
51
|
+
"diary_write",
|
|
52
|
+
"conversation_read",
|
|
53
|
+
"conversation_search",
|
|
54
|
+
"kg_query",
|
|
48
55
|
"profile_read",
|
|
49
56
|
"profile_write",
|
|
50
57
|
"web_research",
|
|
@@ -68,6 +75,12 @@ const MCP_OPERATION_BY_METHOD = {
|
|
|
68
75
|
docdex_repo_inspect: "repo_inspect",
|
|
69
76
|
docdex_memory_save: "memory_save",
|
|
70
77
|
docdex_memory_recall: "memory_recall",
|
|
78
|
+
docdex_wakeup: "wakeup",
|
|
79
|
+
docdex_diary_read: "diary_read",
|
|
80
|
+
docdex_diary_write: "diary_write",
|
|
81
|
+
docdex_conversation_read: "conversation_read",
|
|
82
|
+
docdex_conversation_search: "conversation_search",
|
|
83
|
+
docdex_kg_query: "kg_query",
|
|
71
84
|
docdex_tree: "tree",
|
|
72
85
|
docdex_open: "open",
|
|
73
86
|
docdex_get_profile: "profile_read",
|
|
@@ -147,6 +160,14 @@ export class DocdexClient {
|
|
|
147
160
|
this.repoId = options.repoId;
|
|
148
161
|
this.dagSessionId = options.dagSessionId;
|
|
149
162
|
}
|
|
163
|
+
async fetch(input, init = {}) {
|
|
164
|
+
const signals = [init.signal, this.options.signal?.(), AbortSignal.timeout(this.options.timeoutMs ?? 60000)].filter((signal) => !!signal);
|
|
165
|
+
const signal = AbortSignal.any(signals);
|
|
166
|
+
signal.throwIfAborted();
|
|
167
|
+
await this.options.beforeRequest?.(input);
|
|
168
|
+
signal.throwIfAborted();
|
|
169
|
+
return globalThis.fetch(input, { ...init, signal, redirect: "error" });
|
|
170
|
+
}
|
|
150
171
|
setRepoId(repoId) {
|
|
151
172
|
this.repoId = repoId;
|
|
152
173
|
}
|
|
@@ -352,7 +373,7 @@ export class DocdexClient {
|
|
|
352
373
|
}
|
|
353
374
|
let response;
|
|
354
375
|
try {
|
|
355
|
-
response = await fetch(`${this.resolveBaseUrl()}/healthz`);
|
|
376
|
+
response = await this.fetch(`${this.resolveBaseUrl()}/healthz`);
|
|
356
377
|
}
|
|
357
378
|
catch (error) {
|
|
358
379
|
throw this.runtimeError("docdex_unavailable", `Docdex health check failed: ${error instanceof Error ? error.message : String(error)}`, { retryable: true });
|
|
@@ -366,7 +387,7 @@ export class DocdexClient {
|
|
|
366
387
|
}
|
|
367
388
|
async initializeRepo(rootUri) {
|
|
368
389
|
await this.ensureHealth();
|
|
369
|
-
const response = await fetch(`${this.resolveBaseUrl()}/v1/initialize`, {
|
|
390
|
+
const response = await this.fetch(`${this.resolveBaseUrl()}/v1/initialize`, {
|
|
370
391
|
method: "POST",
|
|
371
392
|
headers: this.buildHeaders(),
|
|
372
393
|
body: JSON.stringify({ rootUri }),
|
|
@@ -395,6 +416,31 @@ export class DocdexClient {
|
|
|
395
416
|
// Single-repo daemons can still accept repo_root without a prior initialize.
|
|
396
417
|
}
|
|
397
418
|
}
|
|
419
|
+
/** Wait locally for a warming index instead of paying for model polling. */
|
|
420
|
+
async waitForIndex(timeoutMs = 30000, onProgress) {
|
|
421
|
+
if (this.isEncryptedSearchGateway())
|
|
422
|
+
return { managed: true };
|
|
423
|
+
this.assertOperationAllowed("stats");
|
|
424
|
+
const deadline = Date.now() + timeoutMs;
|
|
425
|
+
await this.ensureHealth();
|
|
426
|
+
await this.ensureRepoInitialized();
|
|
427
|
+
while (Date.now() < deadline) {
|
|
428
|
+
this.options.signal?.()?.throwIfAborted();
|
|
429
|
+
const response = await this.fetch(`${this.resolveBaseUrl()}/v1/index/status`, {
|
|
430
|
+
headers: this.buildHeaders(), signal: AbortSignal.timeout(Math.max(1, deadline - Date.now())),
|
|
431
|
+
});
|
|
432
|
+
if (!response.ok)
|
|
433
|
+
await this.throwResponseError(response, "index readiness");
|
|
434
|
+
const status = await response.json();
|
|
435
|
+
if (status.ready === true && status.indexing_in_progress !== true)
|
|
436
|
+
return status;
|
|
437
|
+
if (status.status === "failed")
|
|
438
|
+
throw this.runtimeError("docdex_unavailable", "Repository indexing failed; inspect Docdex diagnostics", { retryable: false });
|
|
439
|
+
onProgress?.(status.status ?? "indexing");
|
|
440
|
+
await delay(Math.min(1000, Math.max(1, deadline - Date.now())), undefined, { signal: this.options.signal?.() });
|
|
441
|
+
}
|
|
442
|
+
throw this.runtimeError("docdex_unavailable", "Repository index did not become ready within the bounded wait; inspect Docdex health and memory pressure", { retryable: false });
|
|
443
|
+
}
|
|
398
444
|
withRepoId(params) {
|
|
399
445
|
if (this.repoId)
|
|
400
446
|
params.set("repo_id", this.repoId);
|
|
@@ -465,6 +511,9 @@ export class DocdexClient {
|
|
|
465
511
|
return undefined;
|
|
466
512
|
}
|
|
467
513
|
attachResponseMetadata(payload, response, operation) {
|
|
514
|
+
if (payload && typeof payload === "object" && !Array.isArray(payload) && payload.error) {
|
|
515
|
+
this.throwResponseBodyError(response.status, JSON.stringify(payload), operation, this.responseRequestId(response));
|
|
516
|
+
}
|
|
468
517
|
const headerRequestId = this.responseRequestId(response);
|
|
469
518
|
if (!headerRequestId || !payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
470
519
|
return payload;
|
|
@@ -500,13 +549,15 @@ export class DocdexClient {
|
|
|
500
549
|
});
|
|
501
550
|
}
|
|
502
551
|
async search(query, options = {}) {
|
|
552
|
+
if (this.options.localSearchOnly && options.forceWeb)
|
|
553
|
+
throw new Error("Use the separately authorized web research tool");
|
|
503
554
|
this.assertOperationAllowed("search");
|
|
504
555
|
await this.ensureHealth();
|
|
505
556
|
await this.ensureRepoInitialized();
|
|
506
557
|
const dagSessionId = options.dagSessionId ?? this.dagSessionId;
|
|
507
558
|
const executeSearch = (searchQuery) => {
|
|
508
559
|
if (this.isEncryptedSearchGateway()) {
|
|
509
|
-
return fetch(`${this.resolveBaseUrl()}/search`, {
|
|
560
|
+
return this.fetch(`${this.resolveBaseUrl()}/search`, {
|
|
510
561
|
method: "POST",
|
|
511
562
|
headers: this.buildHeaders(dagSessionId),
|
|
512
563
|
body: JSON.stringify({
|
|
@@ -517,6 +568,8 @@ export class DocdexClient {
|
|
|
517
568
|
});
|
|
518
569
|
}
|
|
519
570
|
const params = new URLSearchParams({ q: searchQuery });
|
|
571
|
+
if (this.options.localSearchOnly)
|
|
572
|
+
params.set("repo_only", "true");
|
|
520
573
|
if (options.limit !== undefined)
|
|
521
574
|
params.set("limit", String(options.limit));
|
|
522
575
|
if (dagSessionId)
|
|
@@ -526,7 +579,7 @@ export class DocdexClient {
|
|
|
526
579
|
params.set("skip_local_search", "true");
|
|
527
580
|
}
|
|
528
581
|
this.withRepoId(params);
|
|
529
|
-
return fetch(`${this.resolveBaseUrl()}/search?${params.toString()}`, {
|
|
582
|
+
return this.fetch(`${this.resolveBaseUrl()}/search?${params.toString()}`, {
|
|
530
583
|
headers: this.buildHeaders(dagSessionId),
|
|
531
584
|
});
|
|
532
585
|
};
|
|
@@ -584,7 +637,7 @@ export class DocdexClient {
|
|
|
584
637
|
if (options.query)
|
|
585
638
|
params.set("q", options.query);
|
|
586
639
|
this.withRepoId(params);
|
|
587
|
-
const response = await fetch(`${this.resolveBaseUrl()}/snippet/${encodeURIComponent(docId)}?${params.toString()}`, {
|
|
640
|
+
const response = await this.fetch(`${this.resolveBaseUrl()}/snippet/${encodeURIComponent(docId)}?${params.toString()}`, {
|
|
588
641
|
headers: this.buildHeaders(),
|
|
589
642
|
});
|
|
590
643
|
if (!response.ok) {
|
|
@@ -608,7 +661,7 @@ export class DocdexClient {
|
|
|
608
661
|
if (options.edgeTypes?.length)
|
|
609
662
|
params.set("edge_types", options.edgeTypes.join(","));
|
|
610
663
|
this.withRepoId(params);
|
|
611
|
-
const response = await fetch(`${this.resolveBaseUrl()}/v1/graph/impact?${params.toString()}`, {
|
|
664
|
+
const response = await this.fetch(`${this.resolveBaseUrl()}/v1/graph/impact?${params.toString()}`, {
|
|
612
665
|
headers: this.buildHeaders(),
|
|
613
666
|
});
|
|
614
667
|
if (!response.ok) {
|
|
@@ -628,7 +681,7 @@ export class DocdexClient {
|
|
|
628
681
|
if (options.offset !== undefined)
|
|
629
682
|
params.set("offset", String(options.offset));
|
|
630
683
|
this.withRepoId(params);
|
|
631
|
-
const response = await fetch(`${this.resolveBaseUrl()}/v1/graph/impact/diagnostics?${params.toString()}`, {
|
|
684
|
+
const response = await this.fetch(`${this.resolveBaseUrl()}/v1/graph/impact/diagnostics?${params.toString()}`, {
|
|
632
685
|
headers: this.buildHeaders(),
|
|
633
686
|
});
|
|
634
687
|
if (!response.ok) {
|
|
@@ -639,7 +692,7 @@ export class DocdexClient {
|
|
|
639
692
|
async indexRebuild(libsSources) {
|
|
640
693
|
this.assertOperationAllowed("index_rebuild");
|
|
641
694
|
await this.ensureHealth();
|
|
642
|
-
const response = await fetch(`${this.resolveBaseUrl()}/v1/index/rebuild`, {
|
|
695
|
+
const response = await this.fetch(`${this.resolveBaseUrl()}/v1/index/rebuild`, {
|
|
643
696
|
method: "POST",
|
|
644
697
|
headers: this.buildHeaders(),
|
|
645
698
|
body: JSON.stringify(libsSources ? { libs_sources: libsSources } : {}),
|
|
@@ -652,10 +705,17 @@ export class DocdexClient {
|
|
|
652
705
|
async indexIngest(file) {
|
|
653
706
|
this.assertOperationAllowed("index_ingest");
|
|
654
707
|
await this.ensureHealth();
|
|
655
|
-
|
|
708
|
+
await this.ensureRepoInitialized();
|
|
709
|
+
// The HTTP ingest endpoint resolves filesystem paths against the daemon cwd.
|
|
710
|
+
// Send an absolute path bound to this client, never that incidental cwd.
|
|
711
|
+
const root = this.options.repoRoot ? path.resolve(this.options.repoRoot) : undefined;
|
|
712
|
+
const target = root ? path.resolve(root, file) : file;
|
|
713
|
+
if (root && !target.startsWith(`${root}${path.sep}`))
|
|
714
|
+
throw new Error("Index path escapes the bound repository");
|
|
715
|
+
const response = await this.fetch(`${this.resolveBaseUrl()}/v1/index/ingest`, {
|
|
656
716
|
method: "POST",
|
|
657
717
|
headers: this.buildHeaders(),
|
|
658
|
-
body: JSON.stringify({ file }),
|
|
718
|
+
body: JSON.stringify({ file: target }),
|
|
659
719
|
});
|
|
660
720
|
if (!response.ok) {
|
|
661
721
|
await this.throwResponseError(response, "index ingest");
|
|
@@ -665,7 +725,7 @@ export class DocdexClient {
|
|
|
665
725
|
async hooksValidate(files) {
|
|
666
726
|
this.assertOperationAllowed("hooks_validate");
|
|
667
727
|
await this.ensureHealth();
|
|
668
|
-
const response = await fetch(`${this.resolveBaseUrl()}/v1/hooks/validate`, {
|
|
728
|
+
const response = await this.fetch(`${this.resolveBaseUrl()}/v1/hooks/validate`, {
|
|
669
729
|
method: "POST",
|
|
670
730
|
headers: this.buildHeaders(),
|
|
671
731
|
body: JSON.stringify({ files }),
|
|
@@ -678,7 +738,7 @@ export class DocdexClient {
|
|
|
678
738
|
async delegate(payload) {
|
|
679
739
|
this.assertOperationAllowed("delegate");
|
|
680
740
|
await this.ensureHealth();
|
|
681
|
-
const response = await fetch(`${this.resolveBaseUrl()}/v1/delegate`, {
|
|
741
|
+
const response = await this.fetch(`${this.resolveBaseUrl()}/v1/delegate`, {
|
|
682
742
|
method: "POST",
|
|
683
743
|
headers: this.buildHeaders(),
|
|
684
744
|
body: JSON.stringify(payload),
|
|
@@ -704,7 +764,7 @@ export class DocdexClient {
|
|
|
704
764
|
body.temperature = options.temperature;
|
|
705
765
|
if (options.docdex)
|
|
706
766
|
body.docdex = options.docdex;
|
|
707
|
-
const response = await fetch(`${this.resolveBaseUrl()}/v1/chat/completions`, {
|
|
767
|
+
const response = await this.fetch(`${this.resolveBaseUrl()}/v1/chat/completions`, {
|
|
708
768
|
method: "POST",
|
|
709
769
|
headers: this.buildHeaders(this.dagSessionId),
|
|
710
770
|
body: JSON.stringify(body),
|
|
@@ -724,7 +784,7 @@ export class DocdexClient {
|
|
|
724
784
|
if (options.maxNodes !== undefined)
|
|
725
785
|
params.set("max_nodes", String(options.maxNodes));
|
|
726
786
|
this.withRepoId(params);
|
|
727
|
-
const response = await fetch(`${this.resolveBaseUrl()}/v1/dag/export?${params.toString()}`, {
|
|
787
|
+
const response = await this.fetch(`${this.resolveBaseUrl()}/v1/dag/export?${params.toString()}`, {
|
|
728
788
|
headers: this.buildHeaders(),
|
|
729
789
|
});
|
|
730
790
|
const body = await response.text();
|
|
@@ -750,24 +810,58 @@ export class DocdexClient {
|
|
|
750
810
|
}
|
|
751
811
|
return body;
|
|
752
812
|
}
|
|
813
|
+
async ensureMcpSession() {
|
|
814
|
+
if (!this.options.authToken || this.options.apiKey || this.mcpSessionId)
|
|
815
|
+
return;
|
|
816
|
+
if (!this.mcpInitialize) {
|
|
817
|
+
this.mcpInitialize = (async () => {
|
|
818
|
+
const response = await this.fetch(`${this.resolveBaseUrl()}/v1/mcp`, {
|
|
819
|
+
method: "POST", headers: this.buildHeaders(),
|
|
820
|
+
body: JSON.stringify({ jsonrpc: "2.0", id: randomUUID(), method: "initialize", params: {
|
|
821
|
+
protocolVersion: "2024-11-05", capabilities: {}, clientInfo: { name: "codali", version: "1" },
|
|
822
|
+
auth_token: this.options.authToken,
|
|
823
|
+
...(this.options.repoRoot ? { rootUri: pathToFileURL(path.resolve(this.options.repoRoot)).toString() } : {}),
|
|
824
|
+
} }),
|
|
825
|
+
});
|
|
826
|
+
if (!response.ok)
|
|
827
|
+
await this.throwResponseError(response, "MCP initialize");
|
|
828
|
+
const payload = await response.json();
|
|
829
|
+
if (payload.error)
|
|
830
|
+
throw this.runtimeError("docdex_auth_failed", payload.error.message ?? "MCP authentication failed", { retryable: false });
|
|
831
|
+
const sessionId = response.headers.get("mcp-session-id") ?? response.headers.get("x-docdex-mcp-session");
|
|
832
|
+
if (!sessionId)
|
|
833
|
+
throw this.runtimeError("docdex_unavailable", "Docdex did not issue an authenticated MCP session", { retryable: false });
|
|
834
|
+
this.mcpSessionId = sessionId;
|
|
835
|
+
})();
|
|
836
|
+
}
|
|
837
|
+
try {
|
|
838
|
+
await this.mcpInitialize;
|
|
839
|
+
}
|
|
840
|
+
finally {
|
|
841
|
+
this.mcpInitialize = undefined;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
753
844
|
async callMcp(method, params) {
|
|
754
845
|
const operation = MCP_OPERATION_BY_METHOD[method];
|
|
755
846
|
if (operation) {
|
|
756
847
|
this.assertOperationAllowed(operation);
|
|
757
848
|
}
|
|
758
849
|
await this.ensureHealth();
|
|
850
|
+
await this.ensureMcpSession();
|
|
759
851
|
const payload = {
|
|
760
852
|
jsonrpc: "2.0",
|
|
761
853
|
id: randomUUID(),
|
|
762
854
|
method,
|
|
763
855
|
params,
|
|
764
856
|
};
|
|
765
|
-
const response = await fetch(`${this.resolveBaseUrl()}/v1/mcp`, {
|
|
857
|
+
const response = await this.fetch(`${this.resolveBaseUrl()}/v1/mcp`, {
|
|
766
858
|
method: "POST",
|
|
767
|
-
headers: this.buildHeaders(),
|
|
859
|
+
headers: { ...this.buildHeaders(), ...(this.mcpSessionId ? { "mcp-session-id": this.mcpSessionId } : {}) },
|
|
768
860
|
body: JSON.stringify(payload),
|
|
769
861
|
});
|
|
770
862
|
if (!response.ok) {
|
|
863
|
+
if (response.status === 404)
|
|
864
|
+
this.mcpSessionId = undefined;
|
|
771
865
|
await this.throwResponseError(response, "MCP");
|
|
772
866
|
}
|
|
773
867
|
const raw = (await response.json());
|
|
@@ -785,6 +879,10 @@ export class DocdexClient {
|
|
|
785
879
|
if (!payload || typeof payload !== "object")
|
|
786
880
|
return payload;
|
|
787
881
|
const record = payload;
|
|
882
|
+
if (record.isError === true) {
|
|
883
|
+
const body = JSON.stringify(record.structuredContent ?? record.content ?? "Docdex tool failed");
|
|
884
|
+
throw this.runtimeError(this.mapResponseErrorCode(500, body), body.slice(0, 4000), { retryable: false });
|
|
885
|
+
}
|
|
788
886
|
if (record.structuredContent !== undefined) {
|
|
789
887
|
return record.structuredContent;
|
|
790
888
|
}
|
|
@@ -910,6 +1008,24 @@ export class DocdexClient {
|
|
|
910
1008
|
memoryRecall(query, topK) {
|
|
911
1009
|
return this.callMcp("docdex_memory_recall", this.buildProjectParams({ query, top_k: topK }));
|
|
912
1010
|
}
|
|
1011
|
+
wakeup(query, agentId = "codali-terminal", maxTokens = 1500) {
|
|
1012
|
+
return this.callMcp("docdex_wakeup", this.buildProjectParams({ query, agent_id: agentId, max_tokens: maxTokens }));
|
|
1013
|
+
}
|
|
1014
|
+
diaryRead(limit = 5) {
|
|
1015
|
+
return this.callMcp("docdex_diary_read", this.buildProjectParams({ agent_id: "codali-terminal", limit }));
|
|
1016
|
+
}
|
|
1017
|
+
diaryWrite(content) {
|
|
1018
|
+
return this.callMcp("docdex_diary_write", this.buildProjectParams({ agent_id: "codali-terminal", content, entry_type: "handoff" }));
|
|
1019
|
+
}
|
|
1020
|
+
conversationSearch(query, limit = 5) {
|
|
1021
|
+
return this.callMcp("docdex_conversation_search", this.buildProjectParams({ query, limit }));
|
|
1022
|
+
}
|
|
1023
|
+
conversationRead(sessionId) {
|
|
1024
|
+
return this.callMcp("docdex_conversation_read", this.buildProjectParams({ session_id: sessionId }));
|
|
1025
|
+
}
|
|
1026
|
+
knowledgeQuery(query, limit = 5) {
|
|
1027
|
+
return this.callMcp("docdex_kg_query", this.buildProjectParams({ query, limit }));
|
|
1028
|
+
}
|
|
913
1029
|
tree(options = {}) {
|
|
914
1030
|
return this.callMcp("docdex_tree", this.buildProjectParams({
|
|
915
1031
|
path: options.path,
|
|
@@ -959,7 +1075,7 @@ export class DocdexClient {
|
|
|
959
1075
|
await this.ensureHealth();
|
|
960
1076
|
await this.ensureRepoInitialized();
|
|
961
1077
|
if (this.isEncryptedSearchGateway()) {
|
|
962
|
-
const response = await fetch(`${this.resolveBaseUrl()}/web/search`, {
|
|
1078
|
+
const response = await this.fetch(`${this.resolveBaseUrl()}/web/search`, {
|
|
963
1079
|
method: "POST",
|
|
964
1080
|
headers: this.buildHeaders(this.dagSessionId),
|
|
965
1081
|
body: JSON.stringify({
|
|
@@ -985,7 +1101,7 @@ export class DocdexClient {
|
|
|
985
1101
|
params.set("no_cache", String(options.noCache));
|
|
986
1102
|
}
|
|
987
1103
|
this.withRepoId(params);
|
|
988
|
-
const response = await fetch(`${this.resolveBaseUrl()}/search?${params.toString()}`, {
|
|
1104
|
+
const response = await this.fetch(`${this.resolveBaseUrl()}/search?${params.toString()}`, {
|
|
989
1105
|
headers: this.buildHeaders(this.dagSessionId),
|
|
990
1106
|
});
|
|
991
1107
|
if (!response.ok) {
|
|
@@ -1004,7 +1120,7 @@ export class DocdexClient {
|
|
|
1004
1120
|
if (this.isEncryptedSearchGateway()) {
|
|
1005
1121
|
this.assertOperationAllowed("batch_search");
|
|
1006
1122
|
await this.ensureHealth();
|
|
1007
|
-
const response = await fetch(`${this.resolveBaseUrl()}/search`, {
|
|
1123
|
+
const response = await this.fetch(`${this.resolveBaseUrl()}/search`, {
|
|
1008
1124
|
method: "POST",
|
|
1009
1125
|
headers: this.buildHeaders(this.dagSessionId),
|
|
1010
1126
|
body: JSON.stringify({
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Provider } from "../providers/ProviderTypes.js";
|
|
2
|
+
import { ConfiguredEmbeddings } from "../providers/ConfiguredEmbeddings.js";
|
|
3
|
+
import { DocdexClient } from "./DocdexClient.js";
|
|
4
|
+
/** A private Docdex process whose inference is routed through the owning controller. */
|
|
5
|
+
export declare class ManagedDocdex {
|
|
6
|
+
private readonly options;
|
|
7
|
+
private child?;
|
|
8
|
+
private bridge?;
|
|
9
|
+
private launchDirectory?;
|
|
10
|
+
private abort?;
|
|
11
|
+
private diagnostic;
|
|
12
|
+
private activeRequests;
|
|
13
|
+
private readonly lifetime;
|
|
14
|
+
constructor(options: {
|
|
15
|
+
workspaceRoot: string;
|
|
16
|
+
stateRoot: string;
|
|
17
|
+
embeddings: ConfiguredEmbeddings;
|
|
18
|
+
provider: Provider;
|
|
19
|
+
binary?: string;
|
|
20
|
+
binarySha256?: string;
|
|
21
|
+
signal?: AbortSignal;
|
|
22
|
+
allowWeb?: boolean;
|
|
23
|
+
startupTimeoutMs?: number;
|
|
24
|
+
onStatus?: (status: string) => void;
|
|
25
|
+
});
|
|
26
|
+
start(): Promise<DocdexClient>;
|
|
27
|
+
close(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=ManagedDocdex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ManagedDocdex.d.ts","sourceRoot":"","sources":["../../src/docdex/ManagedDocdex.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAmB,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAajD,wFAAwF;AACxF,qBAAa,aAAa;IAQZ,OAAO,CAAC,QAAQ,CAAC,OAAO;IAPpC,OAAO,CAAC,KAAK,CAAC,CAAe;IAC7B,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,eAAe,CAAC,CAAS;IACjC,OAAO,CAAC,KAAK,CAAC,CAAa;IAC3B,OAAO,CAAC,UAAU,CAAM;IACxB,OAAO,CAAC,cAAc,CAAK;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyB;gBACrB,OAAO,EAAE;QACpC,aAAa,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,oBAAoB,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAC;QAC/F,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC5G,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;KACrC;IAEK,KAAK,IAAI,OAAO,CAAC,YAAY,CAAC;IAyG9B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAa7B"}
|