@mcoda/codali 0.1.108 → 0.1.110
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/dist/agents/AgentInventory.d.ts +56 -0
- package/dist/agents/AgentInventory.d.ts.map +1 -0
- package/dist/agents/AgentInventory.js +131 -0
- package/dist/agents/RoleResolution.d.ts +49 -0
- package/dist/agents/RoleResolution.d.ts.map +1 -0
- package/dist/agents/RoleResolution.js +166 -0
- package/dist/api/ChatCompletionsAdapter.d.ts +76 -0
- package/dist/api/ChatCompletionsAdapter.d.ts.map +1 -0
- package/dist/api/ChatCompletionsAdapter.js +54 -0
- package/dist/api/CodaliApi.d.ts +78 -0
- package/dist/api/CodaliApi.d.ts.map +1 -0
- package/dist/api/CodaliApi.js +273 -0
- package/dist/api/CodaliServer.d.ts +42 -0
- package/dist/api/CodaliServer.d.ts.map +1 -0
- package/dist/api/CodaliServer.js +118 -0
- package/dist/cli/AskCommand.d.ts +66 -0
- package/dist/cli/AskCommand.d.ts.map +1 -0
- package/dist/cli/AskCommand.js +536 -0
- package/dist/cli/AuthCommand.d.ts +19 -0
- package/dist/cli/AuthCommand.d.ts.map +1 -0
- package/dist/cli/AuthCommand.js +161 -0
- package/dist/cli/ServeCommand.d.ts +5 -0
- package/dist/cli/ServeCommand.d.ts.map +1 -0
- package/dist/cli/ServeCommand.js +87 -0
- package/dist/cli/ToolsCommand.d.ts +22 -0
- package/dist/cli/ToolsCommand.d.ts.map +1 -0
- package/dist/cli/ToolsCommand.js +208 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +29 -1
- package/dist/connectors/http/HttpToolDefinition.d.ts +74 -0
- package/dist/connectors/http/HttpToolDefinition.d.ts.map +1 -0
- package/dist/connectors/http/HttpToolDefinition.js +190 -0
- package/dist/connectors/http/HttpToolSource.d.ts +18 -0
- package/dist/connectors/http/HttpToolSource.d.ts.map +1 -0
- package/dist/connectors/http/HttpToolSource.js +29 -0
- package/dist/connectors/mcp/McpClient.d.ts +132 -0
- package/dist/connectors/mcp/McpClient.d.ts.map +1 -0
- package/dist/connectors/mcp/McpClient.js +215 -0
- package/dist/connectors/mcp/McpServerRegistry.d.ts +75 -0
- package/dist/connectors/mcp/McpServerRegistry.d.ts.map +1 -0
- package/dist/connectors/mcp/McpServerRegistry.js +180 -0
- package/dist/connectors/mcp/McpToolAdapter.d.ts +48 -0
- package/dist/connectors/mcp/McpToolAdapter.d.ts.map +1 -0
- package/dist/connectors/mcp/McpToolAdapter.js +101 -0
- package/dist/connectors/mcp/McpToolSource.d.ts +27 -0
- package/dist/connectors/mcp/McpToolSource.d.ts.map +1 -0
- package/dist/connectors/mcp/McpToolSource.js +33 -0
- package/dist/connectors/media/ImageGenerationTool.d.ts +43 -0
- package/dist/connectors/media/ImageGenerationTool.d.ts.map +1 -0
- package/dist/connectors/media/ImageGenerationTool.js +122 -0
- package/dist/connectors/oauth/DeviceCodeAuth.d.ts +74 -0
- package/dist/connectors/oauth/DeviceCodeAuth.d.ts.map +1 -0
- package/dist/connectors/oauth/DeviceCodeAuth.js +153 -0
- package/dist/docdex/DocdexClient.d.ts +2 -0
- package/dist/docdex/DocdexClient.d.ts.map +1 -1
- package/dist/docdex/DocdexClient.js +4 -0
- package/dist/gateway/CodaliGateway.d.ts +51 -3
- package/dist/gateway/CodaliGateway.d.ts.map +1 -1
- package/dist/gateway/CodaliGateway.js +241 -3
- package/dist/gateway/CodaliGatewayTypes.d.ts +34 -0
- package/dist/gateway/CodaliGatewayTypes.d.ts.map +1 -1
- package/dist/gateway/EvidenceNormalizer.d.ts.map +1 -1
- package/dist/gateway/EvidenceNormalizer.js +98 -1
- package/dist/gateway/Finalizer.d.ts +50 -0
- package/dist/gateway/Finalizer.d.ts.map +1 -0
- package/dist/gateway/Finalizer.js +79 -0
- package/dist/gateway/GatewayPlanner.d.ts +13 -0
- package/dist/gateway/GatewayPlanner.d.ts.map +1 -1
- package/dist/gateway/GatewayPlanner.js +81 -16
- package/dist/gateway/GatewayStateMachine.d.ts.map +1 -1
- package/dist/gateway/GatewayStateMachine.js +6 -0
- package/dist/gateway/GatewayTracer.d.ts +93 -0
- package/dist/gateway/GatewayTracer.d.ts.map +1 -0
- package/dist/gateway/GatewayTracer.js +214 -0
- package/dist/gateway/LocalGatewayProvider.d.ts +59 -0
- package/dist/gateway/LocalGatewayProvider.d.ts.map +1 -0
- package/dist/gateway/LocalGatewayProvider.js +195 -0
- package/dist/gateway/LocalGatewayTaskRunner.d.ts +79 -0
- package/dist/gateway/LocalGatewayTaskRunner.d.ts.map +1 -0
- package/dist/gateway/LocalGatewayTaskRunner.js +361 -0
- package/dist/gateway/RelevanceJudge.d.ts +25 -0
- package/dist/gateway/RelevanceJudge.d.ts.map +1 -0
- package/dist/gateway/RelevanceJudge.js +124 -0
- package/dist/gateway/ResponseSchema.d.ts +32 -0
- package/dist/gateway/ResponseSchema.d.ts.map +1 -0
- package/dist/gateway/ResponseSchema.js +120 -0
- package/dist/gateway/TemporalContext.d.ts +36 -0
- package/dist/gateway/TemporalContext.d.ts.map +1 -0
- package/dist/gateway/TemporalContext.js +115 -0
- package/dist/gateway/ToolCapabilityCompiler.d.ts +5 -0
- package/dist/gateway/ToolCapabilityCompiler.d.ts.map +1 -1
- package/dist/gateway/ToolCapabilityCompiler.js +27 -2
- package/dist/gateway/ToolDescriptorSource.d.ts +6 -0
- package/dist/gateway/ToolDescriptorSource.d.ts.map +1 -0
- package/dist/gateway/ToolDescriptorSource.js +30 -0
- package/dist/gateway/ToolExposure.d.ts +36 -0
- package/dist/gateway/ToolExposure.d.ts.map +1 -0
- package/dist/gateway/ToolExposure.js +154 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +45 -0
- package/dist/providers/ClaudeCliProvider.d.ts +2 -0
- package/dist/providers/ClaudeCliProvider.d.ts.map +1 -1
- package/dist/providers/ClaudeCliProvider.js +2 -0
- package/dist/providers/CodexCliProvider.d.ts +2 -0
- package/dist/providers/CodexCliProvider.d.ts.map +1 -1
- package/dist/providers/CodexCliProvider.js +2 -0
- package/dist/providers/MswarmWorkerProvider.d.ts +2 -0
- package/dist/providers/MswarmWorkerProvider.d.ts.map +1 -1
- package/dist/providers/MswarmWorkerProvider.js +2 -0
- package/dist/providers/OllamaRemoteProvider.d.ts +2 -0
- package/dist/providers/OllamaRemoteProvider.d.ts.map +1 -1
- package/dist/providers/OllamaRemoteProvider.js +2 -0
- package/dist/providers/OpenAiCompatibleProvider.d.ts +2 -0
- package/dist/providers/OpenAiCompatibleProvider.d.ts.map +1 -1
- package/dist/providers/OpenAiCompatibleProvider.js +2 -0
- package/dist/providers/ProviderTypes.d.ts +13 -0
- package/dist/providers/ProviderTypes.d.ts.map +1 -1
- package/dist/providers/ProviderTypes.js +1 -1
- package/dist/runcontext/CredentialFile.d.ts +12 -0
- package/dist/runcontext/CredentialFile.d.ts.map +1 -0
- package/dist/runcontext/CredentialFile.js +81 -0
- package/dist/runcontext/RunContextResolver.d.ts +126 -0
- package/dist/runcontext/RunContextResolver.d.ts.map +1 -0
- package/dist/runcontext/RunContextResolver.js +389 -0
- package/dist/storage/CodaliDatasetPrivacyEngine.d.ts +1 -1
- package/dist/storage/CodaliDatasetPrivacyEngine.d.ts.map +1 -1
- package/dist/storage/CodaliDatasetPrivacyEngine.js +12 -0
- package/dist/tools/ToolRegistry.d.ts +14 -1
- package/dist/tools/ToolRegistry.d.ts.map +1 -1
- package/dist/tools/ToolRegistry.js +38 -1
- package/dist/tools/ToolTypes.d.ts +35 -0
- package/dist/tools/ToolTypes.d.ts.map +1 -1
- package/dist/tools/ToolTypes.js +21 -0
- package/dist/tools/TruncateResult.d.ts +29 -0
- package/dist/tools/TruncateResult.d.ts.map +1 -0
- package/dist/tools/TruncateResult.js +91 -0
- package/dist/tools/diff/DiffTool.d.ts.map +1 -1
- package/dist/tools/diff/DiffTool.js +2 -0
- package/dist/tools/docdex/DocdexTools.d.ts +21 -1
- package/dist/tools/docdex/DocdexTools.d.ts.map +1 -1
- package/dist/tools/docdex/DocdexTools.js +151 -17
- package/dist/tools/filesystem/FileTools.d.ts.map +1 -1
- package/dist/tools/filesystem/FileTools.js +8 -0
- package/dist/tools/search/SearchTool.d.ts.map +1 -1
- package/dist/tools/search/SearchTool.js +3 -1
- package/dist/tools/shell/ShellTool.d.ts.map +1 -1
- package/dist/tools/shell/ShellTool.js +2 -0
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -41,3 +41,48 @@ export { loadInstructionBlocks, formatInstructionBlocks } from "./session/Instru
|
|
|
41
41
|
export { SessionStore } from "./session/SessionStore.js";
|
|
42
42
|
export { SubagentOrchestrator } from "./subagents/SubagentOrchestrator.js";
|
|
43
43
|
export { ClaudeCliProvider } from "./providers/ClaudeCliProvider.js";
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
// Phase 1 orchestrator surface.
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
export { AskCommand, runAsk, parseAskArgs } from "./cli/AskCommand.js";
|
|
48
|
+
export { getAgentInventory, loadAgentInventory, resetAgentInventoryCache, } from "./agents/AgentInventory.js";
|
|
49
|
+
export { PHASE_ONE_ROLES, resolveConfigurableRoles } from "./agents/RoleResolution.js";
|
|
50
|
+
export { LocalConfigRunContextResolver, ProvidedRunContextResolver, mergeRunContexts, resolveRunContext, scrubRepoConfig, } from "./runcontext/RunContextResolver.js";
|
|
51
|
+
export { LocalGatewayTaskRunner, createLocalGatewayTaskRunner, MAX_MODEL_CALLS_PER_TASK, MAX_TOOL_CALLS_PER_TASK, } from "./gateway/LocalGatewayTaskRunner.js";
|
|
52
|
+
export { RoleRoutingProvider, createProviderForAssignment, createProviderForName, providerNameForAdapter, } from "./gateway/LocalGatewayProvider.js";
|
|
53
|
+
export { artifactRefsFromStored, decideFinalizerMode, formatArtifactAnswer, formatDeterministicAnswer, } from "./gateway/Finalizer.js";
|
|
54
|
+
export { describeViolations, extractJsonPayload, validateResponseAgainstSchema, } from "./gateway/ResponseSchema.js";
|
|
55
|
+
export { GatewayTracer, sanitizeArgs } from "./gateway/GatewayTracer.js";
|
|
56
|
+
export { MAX_EXPANDED_TOOLS, renderCapabilityLines, renderToolLines, } from "./gateway/ToolExposure.js";
|
|
57
|
+
export { gatewayToolDescriptorsFromDefinitions, gatewayToolDescriptorsFromRegistry, } from "./gateway/ToolDescriptorSource.js";
|
|
58
|
+
export { toolCapabilityForName, DEFAULT_TOOL_CAPABILITY } from "./tools/ToolTypes.js";
|
|
59
|
+
export { toolDescriptorFor } from "./tools/ToolRegistry.js";
|
|
60
|
+
export { filterLocallyDrivable, isLocallyDrivable } from "./agents/AgentInventory.js";
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
// Phase 2 MCP connector surface.
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
export { CODALI_MCP_CLIENT_INFO, CODALI_MCP_PROTOCOL_VERSION, McpClient, McpClientError, createMcpClient, flattenMcpContent, } from "./connectors/mcp/McpClient.js";
|
|
65
|
+
export { mcpToolName, mcpToolToDefinition, mcpToolsToDefinitions, normalizeMcpInputSchema, parseMcpToolName, } from "./connectors/mcp/McpToolAdapter.js";
|
|
66
|
+
export { DEFAULT_MAX_CONCURRENT_CALLS, McpServerRegistry, createMcpServerRegistry, } from "./connectors/mcp/McpServerRegistry.js";
|
|
67
|
+
export { attachMcpTools } from "./connectors/mcp/McpToolSource.js";
|
|
68
|
+
export { ToolsCommand, runTools, parseToolsArgs } from "./cli/ToolsCommand.js";
|
|
69
|
+
export { redactSecretValues } from "./gateway/GatewayTracer.js";
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
// Phase 3 research surface.
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
export { buildTemporalContext, renderTemporalContext, resolveRelativeRange, } from "./gateway/TemporalContext.js";
|
|
74
|
+
export { applyResponseSelector, buildHttpUrl, httpConnectorToDefinitions, httpToolName, httpToolToDefinition, } from "./connectors/http/HttpToolDefinition.js";
|
|
75
|
+
export { attachHttpTools } from "./connectors/http/HttpToolSource.js";
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
// Phase 4: the canonical product API.
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
export { runCodali, messagesToQuery } from "./api/CodaliApi.js";
|
|
80
|
+
export { handleChatCompletion, toCodaliMessages } from "./api/ChatCompletionsAdapter.js";
|
|
81
|
+
export { createCodaliServer, startCodaliServer } from "./api/CodaliServer.js";
|
|
82
|
+
export { IMAGE_TOOL_NAME, createImageGenerationTool, } from "./connectors/media/ImageGenerationTool.js";
|
|
83
|
+
export { ServeCommand, runServe } from "./cli/ServeCommand.js";
|
|
84
|
+
export { credentialFilePath, loadCredentialFile, parseCredentialFile, resetCredentialCache, resolveCredential, } from "./runcontext/CredentialFile.js";
|
|
85
|
+
export { AuthCommand, runAuth, upsertCredential } from "./cli/AuthCommand.js";
|
|
86
|
+
export { MICROSOFT_GRAPH_SCOPES, DeviceCodeError, microsoftEndpoints, pollForDeviceCodeTokens, refreshAccessToken, startDeviceCode, } from "./connectors/oauth/DeviceCodeAuth.js";
|
|
87
|
+
export { resetAccessTokenCache } from "./connectors/http/HttpToolDefinition.js";
|
|
88
|
+
export { createRelevanceJudge, summarizeResultTitles } from "./gateway/RelevanceJudge.js";
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Provider, ProviderConfig, ProviderRequest, ProviderResponse } from "./ProviderTypes.js";
|
|
2
2
|
export declare class ClaudeCliProvider implements Provider {
|
|
3
3
|
private readonly config;
|
|
4
|
+
/** Driven through the claude CLI's text interface; no structured tool calls. */
|
|
5
|
+
readonly supportsToolCalls = false;
|
|
4
6
|
name: string;
|
|
5
7
|
constructor(config: ProviderConfig);
|
|
6
8
|
generate(request: ProviderRequest): Promise<ProviderResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClaudeCliProvider.d.ts","sourceRoot":"","sources":["../../src/providers/ClaudeCliProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EAEd,eAAe,EACf,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAkB5B,qBAAa,iBAAkB,YAAW,QAAQ;
|
|
1
|
+
{"version":3,"file":"ClaudeCliProvider.d.ts","sourceRoot":"","sources":["../../src/providers/ClaudeCliProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EAEd,eAAe,EACf,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAkB5B,qBAAa,iBAAkB,YAAW,QAAQ;IAMpC,OAAO,CAAC,QAAQ,CAAC,MAAM;IALnC,gFAAgF;IAChF,QAAQ,CAAC,iBAAiB,SAAS;IAEnC,IAAI,SAAgB;gBAES,MAAM,EAAE,cAAc;IAE7C,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;CA4GpE"}
|
|
@@ -13,6 +13,8 @@ const isIgnorableStdinError = (error) => error.code === "EPIPE" || error.code ==
|
|
|
13
13
|
export class ClaudeCliProvider {
|
|
14
14
|
constructor(config) {
|
|
15
15
|
this.config = config;
|
|
16
|
+
/** Driven through the claude CLI's text interface; no structured tool calls. */
|
|
17
|
+
this.supportsToolCalls = false;
|
|
16
18
|
this.name = "claude-cli";
|
|
17
19
|
}
|
|
18
20
|
async generate(request) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Provider, ProviderConfig, ProviderRequest, ProviderResponse } from "./ProviderTypes.js";
|
|
2
2
|
export declare class CodexCliProvider implements Provider {
|
|
3
3
|
private config;
|
|
4
|
+
/** Driven through the codex CLI's text interface; no structured tool calls. */
|
|
5
|
+
readonly supportsToolCalls = false;
|
|
4
6
|
name: string;
|
|
5
7
|
constructor(config: ProviderConfig);
|
|
6
8
|
generate(request: ProviderRequest): Promise<ProviderResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodexCliProvider.d.ts","sourceRoot":"","sources":["../../src/providers/CodexCliProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAmB,eAAe,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAqHvH,qBAAa,gBAAiB,YAAW,QAAQ;
|
|
1
|
+
{"version":3,"file":"CodexCliProvider.d.ts","sourceRoot":"","sources":["../../src/providers/CodexCliProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAmB,eAAe,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAqHvH,qBAAa,gBAAiB,YAAW,QAAQ;IAMnC,OAAO,CAAC,MAAM;IAL1B,+EAA+E;IAC/E,QAAQ,CAAC,iBAAiB,SAAS;IAEnC,IAAI,SAAe;gBAEC,MAAM,EAAE,cAAc;IAEpC,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAoKpE"}
|
|
@@ -118,6 +118,8 @@ const isIgnorableStdinError = (error) => error.code === "EPIPE" || error.code ==
|
|
|
118
118
|
export class CodexCliProvider {
|
|
119
119
|
constructor(config) {
|
|
120
120
|
this.config = config;
|
|
121
|
+
/** Driven through the codex CLI's text interface; no structured tool calls. */
|
|
122
|
+
this.supportsToolCalls = false;
|
|
121
123
|
this.name = "codex-cli";
|
|
122
124
|
}
|
|
123
125
|
async generate(request) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Provider, ProviderRequest, ProviderResponse } from "./ProviderTypes.js";
|
|
2
2
|
export declare class MswarmWorkerProvider implements Provider {
|
|
3
3
|
private readonly config;
|
|
4
|
+
/** Delegates to a remote worker; tool calls are not surfaced to the caller. */
|
|
5
|
+
readonly supportsToolCalls = false;
|
|
4
6
|
readonly name = "mswarm-worker";
|
|
5
7
|
private readonly runUrl;
|
|
6
8
|
private readonly apiKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MswarmWorkerProvider.d.ts","sourceRoot":"","sources":["../../src/providers/MswarmWorkerProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EAER,eAAe,EACf,gBAAgB,EAEjB,MAAM,oBAAoB,CAAC;AA8C5B,qBAAa,oBAAqB,YAAW,QAAQ;
|
|
1
|
+
{"version":3,"file":"MswarmWorkerProvider.d.ts","sourceRoot":"","sources":["../../src/providers/MswarmWorkerProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EAER,eAAe,EACf,gBAAgB,EAEjB,MAAM,oBAAoB,CAAC;AA8C5B,qBAAa,oBAAqB,YAAW,QAAQ;IAQvC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAPnC,+EAA+E;IAC/E,QAAQ,CAAC,iBAAiB,SAAS;IAEnC,QAAQ,CAAC,IAAI,mBAAmB;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAEH,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;IAWvG,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;CA+DpE"}
|
|
@@ -39,6 +39,8 @@ const parseToolCalls = (payload) => {
|
|
|
39
39
|
export class MswarmWorkerProvider {
|
|
40
40
|
constructor(config) {
|
|
41
41
|
this.config = config;
|
|
42
|
+
/** Delegates to a remote worker; tool calls are not surfaced to the caller. */
|
|
43
|
+
this.supportsToolCalls = false;
|
|
42
44
|
this.name = "mswarm-worker";
|
|
43
45
|
if (!config.apiKey) {
|
|
44
46
|
throw new Error("AUTH_REQUIRED: mswarm-worker provider requires a synced Worker API key.");
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Provider, ProviderConfig, ProviderRequest, ProviderResponse } from "./ProviderTypes.js";
|
|
2
2
|
export declare class OllamaRemoteProvider implements Provider {
|
|
3
3
|
private config;
|
|
4
|
+
/** Ollama's chat API returns structured tool calls. */
|
|
5
|
+
readonly supportsToolCalls = true;
|
|
4
6
|
name: string;
|
|
5
7
|
constructor(config: ProviderConfig);
|
|
6
8
|
generate(request: ProviderRequest): Promise<ProviderResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OllamaRemoteProvider.d.ts","sourceRoot":"","sources":["../../src/providers/OllamaRemoteProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,eAAe,EACf,gBAAgB,EAGjB,MAAM,oBAAoB,CAAC;AA2J5B,qBAAa,oBAAqB,YAAW,QAAQ;
|
|
1
|
+
{"version":3,"file":"OllamaRemoteProvider.d.ts","sourceRoot":"","sources":["../../src/providers/OllamaRemoteProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,eAAe,EACf,gBAAgB,EAGjB,MAAM,oBAAoB,CAAC;AA2J5B,qBAAa,oBAAqB,YAAW,QAAQ;IAMvC,OAAO,CAAC,MAAM;IAL1B,uDAAuD;IACvD,QAAQ,CAAC,iBAAiB,QAAQ;IAElC,IAAI,SAAmB;gBAEH,MAAM,EAAE,cAAc;IAEpC,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAwKpE"}
|
|
@@ -132,6 +132,8 @@ const applyResponseFormat = (body, format) => {
|
|
|
132
132
|
export class OllamaRemoteProvider {
|
|
133
133
|
constructor(config) {
|
|
134
134
|
this.config = config;
|
|
135
|
+
/** Ollama's chat API returns structured tool calls. */
|
|
136
|
+
this.supportsToolCalls = true;
|
|
135
137
|
this.name = "ollama-remote";
|
|
136
138
|
}
|
|
137
139
|
async generate(request) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Provider, ProviderConfig, ProviderRequest, ProviderResponse } from "./ProviderTypes.js";
|
|
2
2
|
export declare class OpenAiCompatibleProvider implements Provider {
|
|
3
3
|
private config;
|
|
4
|
+
/** OpenAI-style function calling is supported and parsed from `tool_calls`. */
|
|
5
|
+
readonly supportsToolCalls = true;
|
|
4
6
|
name: string;
|
|
5
7
|
private localRunner;
|
|
6
8
|
private authMode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAiCompatibleProvider.d.ts","sourceRoot":"","sources":["../../src/providers/OpenAiCompatibleProvider.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EAEd,eAAe,EACf,gBAAgB,EAGjB,MAAM,oBAAoB,CAAC;AAsH5B,qBAAa,wBAAyB,YAAW,QAAQ;
|
|
1
|
+
{"version":3,"file":"OpenAiCompatibleProvider.d.ts","sourceRoot":"","sources":["../../src/providers/OpenAiCompatibleProvider.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EAEd,eAAe,EACf,gBAAgB,EAGjB,MAAM,oBAAoB,CAAC;AAsH5B,qBAAa,wBAAyB,YAAW,QAAQ;IAS3C,OAAO,CAAC,MAAM;IAR1B,+EAA+E;IAC/E,QAAQ,CAAC,iBAAiB,QAAQ;IAElC,IAAI,SAAuB;IAC3B,OAAO,CAAC,WAAW,CAAoC;IACvD,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,sBAAsB,CAAoC;gBAE9C,MAAM,EAAE,cAAc;IAWpC,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAsMnE,OAAO,CAAC,WAAW;CAepB"}
|
|
@@ -83,6 +83,8 @@ const buildPromptOnlyFormatInstruction = (format) => {
|
|
|
83
83
|
export class OpenAiCompatibleProvider {
|
|
84
84
|
constructor(config) {
|
|
85
85
|
this.config = config;
|
|
86
|
+
/** OpenAI-style function calling is supported and parsed from `tool_calls`. */
|
|
87
|
+
this.supportsToolCalls = true;
|
|
86
88
|
this.name = "openai-compatible";
|
|
87
89
|
const normalizedLocal = normalizeLocalOpenAiCompatibleRunnerConfig({
|
|
88
90
|
config,
|
|
@@ -91,6 +91,19 @@ export interface ProviderConfig {
|
|
|
91
91
|
}
|
|
92
92
|
export interface Provider {
|
|
93
93
|
name: string;
|
|
94
|
+
/**
|
|
95
|
+
* Whether this adapter can return `ProviderResponse.toolCalls`.
|
|
96
|
+
*
|
|
97
|
+
* Distinct from an agent's advertised `supportsTools`: a CLI-backed agent may
|
|
98
|
+
* well have tools of its own, but this adapter drives it through a text
|
|
99
|
+
* interface and can never surface a structured tool call. Treating the two as
|
|
100
|
+
* the same produces a plan full of tool tasks and then zero tool calls, with
|
|
101
|
+
* nothing in the trace explaining why.
|
|
102
|
+
*
|
|
103
|
+
* Undefined is read as false.
|
|
104
|
+
*/
|
|
105
|
+
supportsToolCalls?: boolean;
|
|
94
106
|
generate(request: ProviderRequest): Promise<ProviderResponse>;
|
|
95
107
|
}
|
|
108
|
+
export declare const providerSupportsToolCalls: (provider: Provider) => boolean;
|
|
96
109
|
//# sourceMappingURL=ProviderTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProviderTypes.d.ts","sourceRoot":"","sources":["../../src/providers/ProviderTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iCAAiC,EACjC,mBAAmB,EACnB,eAAe,EACf,iCAAiC,EAClC,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;AAEpE,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED,MAAM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CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC/D;AAED,eAAO,MAAM,yBAAyB,GAAI,UAAU,QAAQ,KAAG,OAC1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const providerSupportsToolCalls = (provider) => provider.supportsToolCalls === true;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const parseCredentialFile: (contents: string) => Record<string, string>;
|
|
2
|
+
export declare const loadCredentialFile: (filePath?: string, forceReload?: boolean) => Record<string, string>;
|
|
3
|
+
/**
|
|
4
|
+
* Resolves a credential name. The process environment wins over the file, so a
|
|
5
|
+
* one-off `GITHUB_TOKEN=… codali ask …` overrides the stored value without
|
|
6
|
+
* editing anything.
|
|
7
|
+
*/
|
|
8
|
+
export declare const resolveCredential: (name: string) => string | undefined;
|
|
9
|
+
/** Test-only: drops the cached file so a fresh read can be exercised. */
|
|
10
|
+
export declare const resetCredentialCache: () => void;
|
|
11
|
+
export declare const credentialFilePath: () => string;
|
|
12
|
+
//# sourceMappingURL=CredentialFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CredentialFile.d.ts","sourceRoot":"","sources":["../../src/runcontext/CredentialFile.ts"],"names":[],"mappings":"AAwCA,eAAO,MAAM,mBAAmB,GAAI,UAAU,MAAM,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAc3E,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,WAAU,MAAmB,EAC7B,qBAAmB,KAClB,MAAM,CAAC,MAAM,EAAE,MAAM,CAcvB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,SACT,CAAC;AAElD,yEAAyE;AACzE,eAAO,MAAM,oBAAoB,QAAO,IAEvC,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAO,MAAoB,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
/**
|
|
5
|
+
* Reads operator credentials from `~/.codali/.creds`.
|
|
6
|
+
*
|
|
7
|
+
* Config files reference secrets indirectly (`env:GITHUB_TOKEN`) so a config
|
|
8
|
+
* can be read, diffed, and shared without leaking anything. That indirection is
|
|
9
|
+
* only useful if the values live somewhere convenient, and exporting shell
|
|
10
|
+
* variables before every command is not convenient.
|
|
11
|
+
*
|
|
12
|
+
* ## Why only the user-level file
|
|
13
|
+
*
|
|
14
|
+
* This deliberately does **not** read a `.creds` from the workspace. A
|
|
15
|
+
* checked-out repository is untrusted input — the same reason
|
|
16
|
+
* `scrubRepoConfig` refuses repository-supplied credentials. A repo that
|
|
17
|
+
* shipped its own `.creds` could silently substitute the token used for a
|
|
18
|
+
* connector the user configured. Credentials come from the operator's home
|
|
19
|
+
* directory or the process environment, never from the tree being analysed.
|
|
20
|
+
*
|
|
21
|
+
* Format is dotenv-style: `KEY=value`, `#` comments, optional quotes.
|
|
22
|
+
*/
|
|
23
|
+
const CREDS_FILE = path.join(homedir(), ".codali", ".creds");
|
|
24
|
+
let cache;
|
|
25
|
+
const stripQuotes = (value) => {
|
|
26
|
+
const trimmed = value.trim();
|
|
27
|
+
if (trimmed.length >= 2) {
|
|
28
|
+
const first = trimmed[0];
|
|
29
|
+
const last = trimmed[trimmed.length - 1];
|
|
30
|
+
if ((first === '"' && last === '"') || (first === "'" && last === "'")) {
|
|
31
|
+
return trimmed.slice(1, -1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return trimmed;
|
|
35
|
+
};
|
|
36
|
+
export const parseCredentialFile = (contents) => {
|
|
37
|
+
const values = {};
|
|
38
|
+
for (const rawLine of contents.split(/\r?\n/)) {
|
|
39
|
+
const line = rawLine.trim();
|
|
40
|
+
if (!line || line.startsWith("#"))
|
|
41
|
+
continue;
|
|
42
|
+
// `export FOO=bar` is accepted so the same file can also be sourced by a shell.
|
|
43
|
+
const withoutExport = line.startsWith("export ") ? line.slice(7).trim() : line;
|
|
44
|
+
const separator = withoutExport.indexOf("=");
|
|
45
|
+
if (separator <= 0)
|
|
46
|
+
continue;
|
|
47
|
+
const key = withoutExport.slice(0, separator).trim();
|
|
48
|
+
if (!key)
|
|
49
|
+
continue;
|
|
50
|
+
values[key] = stripQuotes(withoutExport.slice(separator + 1));
|
|
51
|
+
}
|
|
52
|
+
return values;
|
|
53
|
+
};
|
|
54
|
+
export const loadCredentialFile = (filePath = CREDS_FILE, forceReload = false) => {
|
|
55
|
+
if (cache && !forceReload)
|
|
56
|
+
return cache;
|
|
57
|
+
if (!existsSync(filePath)) {
|
|
58
|
+
cache = {};
|
|
59
|
+
return cache;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
cache = parseCredentialFile(readFileSync(filePath, "utf8"));
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// An unreadable creds file must not stop a run; the connector will fail
|
|
66
|
+
// with a clearer authentication error than anything raised here.
|
|
67
|
+
cache = {};
|
|
68
|
+
}
|
|
69
|
+
return cache;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Resolves a credential name. The process environment wins over the file, so a
|
|
73
|
+
* one-off `GITHUB_TOKEN=… codali ask …` overrides the stored value without
|
|
74
|
+
* editing anything.
|
|
75
|
+
*/
|
|
76
|
+
export const resolveCredential = (name) => process.env[name] ?? loadCredentialFile()[name];
|
|
77
|
+
/** Test-only: drops the cached file so a fresh read can be exercised. */
|
|
78
|
+
export const resetCredentialCache = () => {
|
|
79
|
+
cache = undefined;
|
|
80
|
+
};
|
|
81
|
+
export const credentialFilePath = () => CREDS_FILE;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { McpServerDefinition } from "../connectors/mcp/McpClient.js";
|
|
2
|
+
import type { HttpConnectorDefinition } from "../connectors/http/HttpToolDefinition.js";
|
|
3
|
+
/**
|
|
4
|
+
* The one seam through which Codali learns what a request is allowed to touch.
|
|
5
|
+
*
|
|
6
|
+
* Codali is meant to serve many products, and a multi-tenant product like
|
|
7
|
+
* okacam has a different tool set, different credentials, and different limits
|
|
8
|
+
* for every tenant. So the tool configuration is never read from a file at run
|
|
9
|
+
* time — it is *resolved* per request.
|
|
10
|
+
*
|
|
11
|
+
* A config file is simply one implementation of this interface, used by the
|
|
12
|
+
* local CLI and single-tenant deployments. An embedded product implements its
|
|
13
|
+
* own, or passes a `RunContext` directly on the request; either way the host
|
|
14
|
+
* supplies the context, and Codali never calls back into the product to fetch
|
|
15
|
+
* it. That callback would create a circular dependency
|
|
16
|
+
* (product -> codali -> product) plus the caching, invalidation, and
|
|
17
|
+
* failure-mode machinery that comes with it, and the authenticated host already
|
|
18
|
+
* holds this data.
|
|
19
|
+
*/
|
|
20
|
+
export interface RunContextRepo {
|
|
21
|
+
root?: string;
|
|
22
|
+
repoId?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface RunContextDocdex {
|
|
25
|
+
baseUrl?: string;
|
|
26
|
+
apiKey?: string;
|
|
27
|
+
repoRoot?: string;
|
|
28
|
+
repoId?: string;
|
|
29
|
+
allowedOperations?: string[];
|
|
30
|
+
}
|
|
31
|
+
export interface RunContextTenant {
|
|
32
|
+
id?: string;
|
|
33
|
+
slug?: string;
|
|
34
|
+
realm?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface RunContextLimits {
|
|
37
|
+
maxRounds?: number;
|
|
38
|
+
maxToolCalls?: number;
|
|
39
|
+
maxModelCalls?: number;
|
|
40
|
+
deadlineMs?: number;
|
|
41
|
+
}
|
|
42
|
+
export interface RunContextAgentRoles {
|
|
43
|
+
/** Routes, plans, assesses completeness, repairs. Runs on every question. */
|
|
44
|
+
orchestrator?: string;
|
|
45
|
+
/** Makes the tool calls. Defaults to the orchestrator when unset. */
|
|
46
|
+
worker?: string;
|
|
47
|
+
/** Produces multi-source answers. */
|
|
48
|
+
synthesizer?: string;
|
|
49
|
+
/** Generates images and other media. */
|
|
50
|
+
media?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface RunContext {
|
|
53
|
+
tenant?: RunContextTenant;
|
|
54
|
+
repo?: RunContextRepo;
|
|
55
|
+
docdex?: RunContextDocdex;
|
|
56
|
+
agentRoles?: RunContextAgentRoles;
|
|
57
|
+
limits?: RunContextLimits;
|
|
58
|
+
/**
|
|
59
|
+
* MCP servers this run may connect to.
|
|
60
|
+
*
|
|
61
|
+
* Only ever populated from user/host config or a host-supplied context —
|
|
62
|
+
* never from repository config. See {@link scrubRepoConfig}.
|
|
63
|
+
*/
|
|
64
|
+
mcpServers?: McpServerDefinition[];
|
|
65
|
+
/**
|
|
66
|
+
* Hand-declared HTTP connectors. Same trust rules as MCP servers: trusted
|
|
67
|
+
* layers only, never repository config.
|
|
68
|
+
*/
|
|
69
|
+
httpConnectors?: HttpConnectorDefinition[];
|
|
70
|
+
/** Tool names permitted for this run. Absent means "registry default". */
|
|
71
|
+
allowedTools?: string[];
|
|
72
|
+
deniedTools?: string[];
|
|
73
|
+
/** Non-fatal problems encountered while resolving, surfaced in the trace. */
|
|
74
|
+
warnings?: string[];
|
|
75
|
+
}
|
|
76
|
+
export interface RunContextResolveInput {
|
|
77
|
+
workspaceRoot: string;
|
|
78
|
+
tenant?: RunContextTenant;
|
|
79
|
+
/** Context supplied directly by an embedding host, taking precedence. */
|
|
80
|
+
provided?: RunContext;
|
|
81
|
+
}
|
|
82
|
+
export interface RunContextResolver {
|
|
83
|
+
readonly id: string;
|
|
84
|
+
resolve(input: RunContextResolveInput): Promise<RunContext>;
|
|
85
|
+
}
|
|
86
|
+
export interface RepoConfigScrubResult {
|
|
87
|
+
value: Record<string, unknown>;
|
|
88
|
+
rejectedKeys: string[];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Strips forbidden keys from a repository config, recording what was dropped.
|
|
92
|
+
* Rejection is loud rather than silent: the keys land in run warnings so a
|
|
93
|
+
* repository that tries to widen its own permissions is visible.
|
|
94
|
+
*/
|
|
95
|
+
export declare const scrubRepoConfig: (config: Record<string, unknown>, pathPrefix?: string) => RepoConfigScrubResult;
|
|
96
|
+
/**
|
|
97
|
+
* Merges a narrower context over a broader one. Allow-lists intersect and
|
|
98
|
+
* deny-lists union, so a later layer can only ever restrict what an earlier one
|
|
99
|
+
* permitted — never widen it.
|
|
100
|
+
*/
|
|
101
|
+
export declare const mergeRunContexts: (base: RunContext, override: RunContext) => RunContext;
|
|
102
|
+
export interface LocalConfigResolverOptions {
|
|
103
|
+
/** Overridden in tests; defaults to `~/.codali`. */
|
|
104
|
+
userConfigDir?: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Resolves run context from trusted user config, then applies the repository's
|
|
108
|
+
* narrowing config on top. Used by the CLI and any single-tenant deployment.
|
|
109
|
+
*/
|
|
110
|
+
export declare class LocalConfigRunContextResolver implements RunContextResolver {
|
|
111
|
+
private readonly options;
|
|
112
|
+
readonly id = "local_config";
|
|
113
|
+
constructor(options?: LocalConfigResolverOptions);
|
|
114
|
+
resolve(input: RunContextResolveInput): Promise<RunContext>;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Uses context handed over by an embedding host. This is the okacam path: the
|
|
118
|
+
* product resolves the tenant's tools and credentials from its own database and
|
|
119
|
+
* passes them on the request.
|
|
120
|
+
*/
|
|
121
|
+
export declare class ProvidedRunContextResolver implements RunContextResolver {
|
|
122
|
+
readonly id = "provided";
|
|
123
|
+
resolve(input: RunContextResolveInput): Promise<RunContext>;
|
|
124
|
+
}
|
|
125
|
+
export declare const resolveRunContext: (input: RunContextResolveInput, resolver?: RunContextResolver) => Promise<RunContext>;
|
|
126
|
+
//# sourceMappingURL=RunContextResolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunContextResolver.d.ts","sourceRoot":"","sources":["../../src/runcontext/Run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