@mcoda/mswarm 0.1.56 → 0.1.60
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 +20 -1
- package/dist/codali-executor.d.ts +266 -0
- package/dist/codali-executor.d.ts.map +1 -0
- package/dist/codali-executor.js +227 -0
- package/dist/codali-executor.js.map +1 -0
- package/dist/runtime.d.ts +47 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +248 -30
- package/dist/runtime.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +83 -3
- package/dist/server.js.map +1 -1
- package/dist/vendor/codali/agents/AgentProtocol.d.ts +287 -0
- package/dist/vendor/codali/agents/AgentProtocol.d.ts.map +1 -0
- package/dist/vendor/codali/agents/AgentProtocol.js +365 -0
- package/dist/vendor/codali/agents/AgentResolver.d.ts +23 -0
- package/dist/vendor/codali/agents/AgentResolver.d.ts.map +1 -0
- package/dist/vendor/codali/agents/AgentResolver.js +77 -0
- package/dist/vendor/codali/agents/PhaseAgentSelector.d.ts +23 -0
- package/dist/vendor/codali/agents/PhaseAgentSelector.d.ts.map +1 -0
- package/dist/vendor/codali/agents/PhaseAgentSelector.js +287 -0
- package/dist/vendor/codali/cli/EvalCommand.d.ts +37 -0
- package/dist/vendor/codali/cli/EvalCommand.d.ts.map +1 -0
- package/dist/vendor/codali/cli/EvalCommand.js +333 -0
- package/dist/vendor/codali/cli/FeedbackCommand.d.ts +22 -0
- package/dist/vendor/codali/cli/FeedbackCommand.d.ts.map +1 -0
- package/dist/vendor/codali/cli/FeedbackCommand.js +163 -0
- package/dist/vendor/codali/cli/RunCommand.d.ts +78 -0
- package/dist/vendor/codali/cli/RunCommand.d.ts.map +1 -0
- package/dist/vendor/codali/cli/RunCommand.js +2261 -0
- package/dist/vendor/codali/cli.d.ts +3 -0
- package/dist/vendor/codali/cli.d.ts.map +1 -0
- package/dist/vendor/codali/cli.js +109 -0
- package/dist/vendor/codali/cognitive/ArchitectPlanner.d.ts +107 -0
- package/dist/vendor/codali/cognitive/ArchitectPlanner.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ArchitectPlanner.js +1726 -0
- package/dist/vendor/codali/cognitive/BuilderOutputParser.d.ts +25 -0
- package/dist/vendor/codali/cognitive/BuilderOutputParser.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/BuilderOutputParser.js +164 -0
- package/dist/vendor/codali/cognitive/BuilderRunner.d.ts +76 -0
- package/dist/vendor/codali/cognitive/BuilderRunner.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/BuilderRunner.js +1159 -0
- package/dist/vendor/codali/cognitive/ContextAssembler.d.ts +91 -0
- package/dist/vendor/codali/cognitive/ContextAssembler.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextAssembler.js +4547 -0
- package/dist/vendor/codali/cognitive/ContextBudget.d.ts +19 -0
- package/dist/vendor/codali/cognitive/ContextBudget.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextBudget.js +35 -0
- package/dist/vendor/codali/cognitive/ContextFileLoader.d.ts +30 -0
- package/dist/vendor/codali/cognitive/ContextFileLoader.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextFileLoader.js +307 -0
- package/dist/vendor/codali/cognitive/ContextManager.d.ts +47 -0
- package/dist/vendor/codali/cognitive/ContextManager.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextManager.js +272 -0
- package/dist/vendor/codali/cognitive/ContextRedactor.d.ts +18 -0
- package/dist/vendor/codali/cognitive/ContextRedactor.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextRedactor.js +53 -0
- package/dist/vendor/codali/cognitive/ContextSelector.d.ts +22 -0
- package/dist/vendor/codali/cognitive/ContextSelector.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextSelector.js +431 -0
- package/dist/vendor/codali/cognitive/ContextSerializer.d.ts +8 -0
- package/dist/vendor/codali/cognitive/ContextSerializer.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextSerializer.js +882 -0
- package/dist/vendor/codali/cognitive/ContextStore.d.ts +27 -0
- package/dist/vendor/codali/cognitive/ContextStore.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextStore.js +79 -0
- package/dist/vendor/codali/cognitive/ContextSummarizer.d.ts +16 -0
- package/dist/vendor/codali/cognitive/ContextSummarizer.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextSummarizer.js +45 -0
- package/dist/vendor/codali/cognitive/CostEstimator.d.ts +31 -0
- package/dist/vendor/codali/cognitive/CostEstimator.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/CostEstimator.js +66 -0
- package/dist/vendor/codali/cognitive/CriticEvaluator.d.ts +32 -0
- package/dist/vendor/codali/cognitive/CriticEvaluator.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/CriticEvaluator.js +297 -0
- package/dist/vendor/codali/cognitive/EvidenceGate.d.ts +9 -0
- package/dist/vendor/codali/cognitive/EvidenceGate.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/EvidenceGate.js +75 -0
- package/dist/vendor/codali/cognitive/GoldenExampleIndexer.d.ts +12 -0
- package/dist/vendor/codali/cognitive/GoldenExampleIndexer.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/GoldenExampleIndexer.js +34 -0
- package/dist/vendor/codali/cognitive/GoldenSetStore.d.ts +33 -0
- package/dist/vendor/codali/cognitive/GoldenSetStore.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/GoldenSetStore.js +159 -0
- package/dist/vendor/codali/cognitive/IntentSignals.d.ts +7 -0
- package/dist/vendor/codali/cognitive/IntentSignals.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/IntentSignals.js +285 -0
- package/dist/vendor/codali/cognitive/LearningGovernance.d.ts +100 -0
- package/dist/vendor/codali/cognitive/LearningGovernance.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/LearningGovernance.js +276 -0
- package/dist/vendor/codali/cognitive/MemoryWriteback.d.ts +64 -0
- package/dist/vendor/codali/cognitive/MemoryWriteback.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/MemoryWriteback.js +287 -0
- package/dist/vendor/codali/cognitive/PatchApplier.d.ts +49 -0
- package/dist/vendor/codali/cognitive/PatchApplier.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/PatchApplier.js +199 -0
- package/dist/vendor/codali/cognitive/PatchInterpreter.d.ts +35 -0
- package/dist/vendor/codali/cognitive/PatchInterpreter.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/PatchInterpreter.js +100 -0
- package/dist/vendor/codali/cognitive/PatchOutputNormalizer.d.ts +7 -0
- package/dist/vendor/codali/cognitive/PatchOutputNormalizer.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/PatchOutputNormalizer.js +59 -0
- package/dist/vendor/codali/cognitive/PostMortemAnalyzer.d.ts +17 -0
- package/dist/vendor/codali/cognitive/PostMortemAnalyzer.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/PostMortemAnalyzer.js +131 -0
- package/dist/vendor/codali/cognitive/PreferenceExtraction.d.ts +3 -0
- package/dist/vendor/codali/cognitive/PreferenceExtraction.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/PreferenceExtraction.js +85 -0
- package/dist/vendor/codali/cognitive/Prompts.d.ts +15 -0
- package/dist/vendor/codali/cognitive/Prompts.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/Prompts.js +326 -0
- package/dist/vendor/codali/cognitive/ProviderRouting.d.ts +16 -0
- package/dist/vendor/codali/cognitive/ProviderRouting.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ProviderRouting.js +24 -0
- package/dist/vendor/codali/cognitive/QueryExtraction.d.ts +12 -0
- package/dist/vendor/codali/cognitive/QueryExtraction.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/QueryExtraction.js +262 -0
- package/dist/vendor/codali/cognitive/RunHistoryIndexer.d.ts +13 -0
- package/dist/vendor/codali/cognitive/RunHistoryIndexer.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/RunHistoryIndexer.js +125 -0
- package/dist/vendor/codali/cognitive/SmartPipeline.d.ts +92 -0
- package/dist/vendor/codali/cognitive/SmartPipeline.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/SmartPipeline.js +4804 -0
- package/dist/vendor/codali/cognitive/Types.d.ts +474 -0
- package/dist/vendor/codali/cognitive/Types.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/Types.js +7 -0
- package/dist/vendor/codali/cognitive/ValidationRunner.d.ts +57 -0
- package/dist/vendor/codali/cognitive/ValidationRunner.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ValidationRunner.js +515 -0
- package/dist/vendor/codali/config/Config.d.ts +249 -0
- package/dist/vendor/codali/config/Config.d.ts.map +1 -0
- package/dist/vendor/codali/config/Config.js +200 -0
- package/dist/vendor/codali/config/ConfigLoader.d.ts +56 -0
- package/dist/vendor/codali/config/ConfigLoader.d.ts.map +1 -0
- package/dist/vendor/codali/config/ConfigLoader.js +1246 -0
- package/dist/vendor/codali/docdex/DocdexClient.d.ts +113 -0
- package/dist/vendor/codali/docdex/DocdexClient.d.ts.map +1 -0
- package/dist/vendor/codali/docdex/DocdexClient.js +524 -0
- package/dist/vendor/codali/eval/EvalRunner.d.ts +35 -0
- package/dist/vendor/codali/eval/EvalRunner.d.ts.map +1 -0
- package/dist/vendor/codali/eval/EvalRunner.js +38 -0
- package/dist/vendor/codali/eval/EvalTaskExecutor.d.ts +81 -0
- package/dist/vendor/codali/eval/EvalTaskExecutor.d.ts.map +1 -0
- package/dist/vendor/codali/eval/EvalTaskExecutor.js +371 -0
- package/dist/vendor/codali/eval/GateEvaluator.d.ts +31 -0
- package/dist/vendor/codali/eval/GateEvaluator.d.ts.map +1 -0
- package/dist/vendor/codali/eval/GateEvaluator.js +134 -0
- package/dist/vendor/codali/eval/MetricTypes.d.ts +28 -0
- package/dist/vendor/codali/eval/MetricTypes.d.ts.map +1 -0
- package/dist/vendor/codali/eval/MetricTypes.js +1 -0
- package/dist/vendor/codali/eval/MetricsAggregator.d.ts +4 -0
- package/dist/vendor/codali/eval/MetricsAggregator.d.ts.map +1 -0
- package/dist/vendor/codali/eval/MetricsAggregator.js +97 -0
- package/dist/vendor/codali/eval/RegressionComparator.d.ts +29 -0
- package/dist/vendor/codali/eval/RegressionComparator.d.ts.map +1 -0
- package/dist/vendor/codali/eval/RegressionComparator.js +155 -0
- package/dist/vendor/codali/eval/ReportInputAdapter.d.ts +52 -0
- package/dist/vendor/codali/eval/ReportInputAdapter.d.ts.map +1 -0
- package/dist/vendor/codali/eval/ReportInputAdapter.js +229 -0
- package/dist/vendor/codali/eval/ReportSerializer.d.ts +32 -0
- package/dist/vendor/codali/eval/ReportSerializer.d.ts.map +1 -0
- package/dist/vendor/codali/eval/ReportSerializer.js +33 -0
- package/dist/vendor/codali/eval/ReportStore.d.ts +18 -0
- package/dist/vendor/codali/eval/ReportStore.d.ts.map +1 -0
- package/dist/vendor/codali/eval/ReportStore.js +96 -0
- package/dist/vendor/codali/eval/SuiteLoader.d.ts +12 -0
- package/dist/vendor/codali/eval/SuiteLoader.d.ts.map +1 -0
- package/dist/vendor/codali/eval/SuiteLoader.js +51 -0
- package/dist/vendor/codali/eval/SuiteSchema.d.ts +56 -0
- package/dist/vendor/codali/eval/SuiteSchema.d.ts.map +1 -0
- package/dist/vendor/codali/eval/SuiteSchema.js +357 -0
- package/dist/vendor/codali/index.d.ts +11 -0
- package/dist/vendor/codali/index.d.ts.map +1 -0
- package/dist/vendor/codali/index.js +5 -0
- package/dist/vendor/codali/providers/CodexCliProvider.d.ts +8 -0
- package/dist/vendor/codali/providers/CodexCliProvider.d.ts.map +1 -0
- package/dist/vendor/codali/providers/CodexCliProvider.js +282 -0
- package/dist/vendor/codali/providers/OllamaRemoteProvider.d.ts +8 -0
- package/dist/vendor/codali/providers/OllamaRemoteProvider.d.ts.map +1 -0
- package/dist/vendor/codali/providers/OllamaRemoteProvider.js +300 -0
- package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts +8 -0
- package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts.map +1 -0
- package/dist/vendor/codali/providers/OpenAiCompatibleProvider.js +192 -0
- package/dist/vendor/codali/providers/ProviderRegistry.d.ts +12 -0
- package/dist/vendor/codali/providers/ProviderRegistry.d.ts.map +1 -0
- package/dist/vendor/codali/providers/ProviderRegistry.js +28 -0
- package/dist/vendor/codali/providers/ProviderTypes.d.ts +81 -0
- package/dist/vendor/codali/providers/ProviderTypes.d.ts.map +1 -0
- package/dist/vendor/codali/providers/ProviderTypes.js +1 -0
- package/dist/vendor/codali/runtime/CodaliRuntime.d.ts +183 -0
- package/dist/vendor/codali/runtime/CodaliRuntime.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/CodaliRuntime.js +1363 -0
- package/dist/vendor/codali/runtime/DeepInvestigationErrors.d.ts +39 -0
- package/dist/vendor/codali/runtime/DeepInvestigationErrors.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/DeepInvestigationErrors.js +57 -0
- package/dist/vendor/codali/runtime/RunContext.d.ts +27 -0
- package/dist/vendor/codali/runtime/RunContext.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/RunContext.js +51 -0
- package/dist/vendor/codali/runtime/RunLogQuery.d.ts +48 -0
- package/dist/vendor/codali/runtime/RunLogQuery.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/RunLogQuery.js +36 -0
- package/dist/vendor/codali/runtime/RunLogReader.d.ts +19 -0
- package/dist/vendor/codali/runtime/RunLogReader.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/RunLogReader.js +361 -0
- package/dist/vendor/codali/runtime/RunLogger.d.ts +71 -0
- package/dist/vendor/codali/runtime/RunLogger.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/RunLogger.js +100 -0
- package/dist/vendor/codali/runtime/RunTelemetryTypes.d.ts +117 -0
- package/dist/vendor/codali/runtime/RunTelemetryTypes.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/RunTelemetryTypes.js +299 -0
- package/dist/vendor/codali/runtime/Runner.d.ts +66 -0
- package/dist/vendor/codali/runtime/Runner.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/Runner.js +215 -0
- package/dist/vendor/codali/runtime/StoragePaths.d.ts +3 -0
- package/dist/vendor/codali/runtime/StoragePaths.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/StoragePaths.js +19 -0
- package/dist/vendor/codali/runtime/WorkspaceLock.d.ts +30 -0
- package/dist/vendor/codali/runtime/WorkspaceLock.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/WorkspaceLock.js +141 -0
- package/dist/vendor/codali/session/InstructionLoader.d.ts +14 -0
- package/dist/vendor/codali/session/InstructionLoader.d.ts.map +1 -0
- package/dist/vendor/codali/session/InstructionLoader.js +107 -0
- package/dist/vendor/codali/session/SessionStore.d.ts +81 -0
- package/dist/vendor/codali/session/SessionStore.d.ts.map +1 -0
- package/dist/vendor/codali/session/SessionStore.js +244 -0
- package/dist/vendor/codali/subagents/SubagentOrchestrator.d.ts +68 -0
- package/dist/vendor/codali/subagents/SubagentOrchestrator.d.ts.map +1 -0
- package/dist/vendor/codali/subagents/SubagentOrchestrator.js +150 -0
- package/dist/vendor/codali/tools/ToolRegistry.d.ts +9 -0
- package/dist/vendor/codali/tools/ToolRegistry.d.ts.map +1 -0
- package/dist/vendor/codali/tools/ToolRegistry.js +263 -0
- package/dist/vendor/codali/tools/ToolTypes.d.ts +66 -0
- package/dist/vendor/codali/tools/ToolTypes.d.ts.map +1 -0
- package/dist/vendor/codali/tools/ToolTypes.js +32 -0
- package/dist/vendor/codali/tools/diff/DiffTool.d.ts +3 -0
- package/dist/vendor/codali/tools/diff/DiffTool.d.ts.map +1 -0
- package/dist/vendor/codali/tools/diff/DiffTool.js +34 -0
- package/dist/vendor/codali/tools/docdex/DocdexTools.d.ts +4 -0
- package/dist/vendor/codali/tools/docdex/DocdexTools.d.ts.map +1 -0
- package/dist/vendor/codali/tools/docdex/DocdexTools.js +453 -0
- package/dist/vendor/codali/tools/filesystem/FileTools.d.ts +3 -0
- package/dist/vendor/codali/tools/filesystem/FileTools.d.ts.map +1 -0
- package/dist/vendor/codali/tools/filesystem/FileTools.js +141 -0
- package/dist/vendor/codali/tools/search/SearchTool.d.ts +3 -0
- package/dist/vendor/codali/tools/search/SearchTool.d.ts.map +1 -0
- package/dist/vendor/codali/tools/search/SearchTool.js +46 -0
- package/dist/vendor/codali/tools/shell/ShellTool.d.ts +3 -0
- package/dist/vendor/codali/tools/shell/ShellTool.d.ts.map +1 -0
- package/dist/vendor/codali/tools/shell/ShellTool.js +104 -0
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -74,7 +74,7 @@ mswarm node logs --error
|
|
|
74
74
|
mswarm node uninstall
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
`node start`, `node stop`, and `node restart` control the installed macOS launchd agent, Linux systemd user service, or Windows scheduled task. `node status` reports the service manager status plus the stored node config. `node health` and `node doctor` check local config, the runtime token, gateway health, heartbeat authorization, and local agent discovery.
|
|
77
|
+
`node start`, `node stop`, and `node restart` control the installed macOS launchd agent, Linux systemd user service, or Windows scheduled task. `node uninstall` also sends a best-effort runtime-token signal to the gateway after stopping the local daemon so the server is immediately marked unreachable. `node status` reports the service manager status plus the stored node config. `node health` and `node doctor` check local config, the runtime token, gateway health, heartbeat authorization, and local agent discovery.
|
|
78
78
|
|
|
79
79
|
## Advanced Setup
|
|
80
80
|
|
|
@@ -125,6 +125,25 @@ mswarm serve
|
|
|
125
125
|
|
|
126
126
|
The legacy aliases `mswarm install <MSWARM_API_KEY>`, `mswarm start`, `mswarm doctor`, and `mswarm status` remain available. `mswarm start` is a foreground run alias; use `mswarm node start` to start the installed daemon. `mswarm status` keeps the old one-shot heartbeat/status behavior; use `mswarm node status` for service manager status. The package also installs `mswarm-self-hosted-node`; it accepts the same commands.
|
|
127
127
|
|
|
128
|
+
## Codali Execution
|
|
129
|
+
|
|
130
|
+
Self-hosted jobs for local `mcoda` agents run through the vendored Codali runtime shipped with `@mcoda/mswarm`. The node resolves the requested `source_agent_slug` or model from local `mcoda agent list --json --refresh-health` inventory, maps the selected local adapter and model into Codali, and enforces the job policy before running tools.
|
|
131
|
+
|
|
132
|
+
Direct-mode `stream: true` jobs are returned as OpenAI-compatible Server-Sent Events:
|
|
133
|
+
|
|
134
|
+
```text
|
|
135
|
+
data: {"object":"chat.completion.chunk",...}
|
|
136
|
+
data: [DONE]
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Codali status and tool events are tracked internally, but tool outputs are not emitted as assistant stream content. Raw `provider: "ollama"` jobs remain available as a minimal no-tool fallback path.
|
|
140
|
+
|
|
141
|
+
Jobs can additionally scope execution with:
|
|
142
|
+
|
|
143
|
+
- `workspace.root` and `workspace.read_only`
|
|
144
|
+
- `docdex.base_url`, `docdex.repo_root`, `docdex.repo_id`, and Docdex write/web/index flags
|
|
145
|
+
- `policy.allow_tools`, `policy.allowed_tools`, `policy.denied_tools`, write/shell/destructive flags, `policy.max_runtime_ms`, and `policy.max_tool_calls`
|
|
146
|
+
|
|
128
147
|
## Environment
|
|
129
148
|
|
|
130
149
|
`MSWARM_API_KEY` can replace `--api-key` during legacy `setup`, but the preferred flow is `mswarm node install <MSWARM_API_KEY>` or `mswarm node install --api-key-stdin` so the key is never exported into the shell environment. `MSWARM_GATEWAY_BASE_URL` overrides the gateway. The default discovery mode is `mcoda`, so the node reads `mcoda agent list --json --refresh-health`; set `MSWARM_SELF_HOSTED_DISCOVERY_MODE=ollama` only for raw Ollama fallback discovery. `MSWARM_SELF_HOSTED_EXPOSURE_POLICY=none` disables default exposure while keeping allowlists/blocklists available. `MSWARM_SELF_HOSTED_REQUEST_TIMEOUT_MS` controls short gateway and inventory requests; self-hosted execution jobs default to one hour and can be overridden with `MSWARM_SELF_HOSTED_JOB_TIMEOUT_MS` or `--job-timeout-ms` during install.
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
export type ProviderRole = "system" | "user" | "assistant" | "tool";
|
|
2
|
+
export interface ProviderMessage {
|
|
3
|
+
role: ProviderRole;
|
|
4
|
+
content: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
toolCallId?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ProviderUsage {
|
|
9
|
+
inputTokens?: number;
|
|
10
|
+
outputTokens?: number;
|
|
11
|
+
totalTokens?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface CodaliRuntimeWorkspace {
|
|
14
|
+
root: string;
|
|
15
|
+
readOnly?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface CodaliRuntimeProviderInput {
|
|
18
|
+
name: "openai-compatible" | "ollama-remote" | "codex-cli" | string;
|
|
19
|
+
model: string;
|
|
20
|
+
baseUrl?: string;
|
|
21
|
+
apiKey?: string;
|
|
22
|
+
timeoutMs?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface CodaliRuntimeDocdexInput {
|
|
25
|
+
baseUrl?: string;
|
|
26
|
+
repoRoot?: string;
|
|
27
|
+
repoId?: string;
|
|
28
|
+
dagSessionId?: string;
|
|
29
|
+
initialize?: boolean;
|
|
30
|
+
allowWeb?: boolean;
|
|
31
|
+
allowMemoryWrite?: boolean;
|
|
32
|
+
allowProfileWrite?: boolean;
|
|
33
|
+
allowIndexRebuild?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface CodaliRuntimeAgentInput {
|
|
36
|
+
slug: string;
|
|
37
|
+
adapter: string;
|
|
38
|
+
provider?: string;
|
|
39
|
+
model: string;
|
|
40
|
+
baseUrl?: string;
|
|
41
|
+
supportsTools?: boolean;
|
|
42
|
+
capabilities?: string[];
|
|
43
|
+
contextWindow?: number;
|
|
44
|
+
maxOutputTokens?: number;
|
|
45
|
+
}
|
|
46
|
+
export interface CodaliRuntimePolicy {
|
|
47
|
+
allowWrites: boolean;
|
|
48
|
+
allowShell: boolean;
|
|
49
|
+
allowDestructiveOperations: boolean;
|
|
50
|
+
allowOutsideWorkspace: boolean;
|
|
51
|
+
allowedTools?: string[];
|
|
52
|
+
deniedTools?: string[];
|
|
53
|
+
maxSteps: number;
|
|
54
|
+
maxToolCalls: number;
|
|
55
|
+
maxTokens?: number;
|
|
56
|
+
timeoutMs: number;
|
|
57
|
+
mode: "tool_loop" | "protocol_loop" | "smart_pipeline" | "patch_json" | "freeform";
|
|
58
|
+
}
|
|
59
|
+
export interface CodaliRuntimeSubagentsInput {
|
|
60
|
+
enabled?: boolean;
|
|
61
|
+
maxParallel?: number;
|
|
62
|
+
maxSubagents?: number;
|
|
63
|
+
defaultTimeoutMs?: number;
|
|
64
|
+
allowWrites?: boolean;
|
|
65
|
+
defaultTools?: string[];
|
|
66
|
+
}
|
|
67
|
+
export interface CodaliRuntimeSessionInput {
|
|
68
|
+
id?: string;
|
|
69
|
+
storageDir?: string;
|
|
70
|
+
resume?: boolean;
|
|
71
|
+
compactOnFinish?: boolean;
|
|
72
|
+
loadInstructions?: boolean;
|
|
73
|
+
includeLocalInstructions?: boolean;
|
|
74
|
+
focusPaths?: string[];
|
|
75
|
+
}
|
|
76
|
+
export type CodaliRuntimeEvent = {
|
|
77
|
+
type: "status";
|
|
78
|
+
phase: string;
|
|
79
|
+
message?: string;
|
|
80
|
+
at: string;
|
|
81
|
+
} | {
|
|
82
|
+
type: "token";
|
|
83
|
+
content: string;
|
|
84
|
+
at: string;
|
|
85
|
+
} | {
|
|
86
|
+
type: "tool_call";
|
|
87
|
+
id: string;
|
|
88
|
+
name: string;
|
|
89
|
+
args: unknown;
|
|
90
|
+
at: string;
|
|
91
|
+
} | {
|
|
92
|
+
type: "tool_result";
|
|
93
|
+
id: string;
|
|
94
|
+
name: string;
|
|
95
|
+
ok: boolean;
|
|
96
|
+
output: string;
|
|
97
|
+
errorCode?: string;
|
|
98
|
+
retryable?: boolean;
|
|
99
|
+
at: string;
|
|
100
|
+
} | {
|
|
101
|
+
type: "usage";
|
|
102
|
+
usage: ProviderUsage;
|
|
103
|
+
at: string;
|
|
104
|
+
} | {
|
|
105
|
+
type: "subagent_start";
|
|
106
|
+
id: string;
|
|
107
|
+
role: string;
|
|
108
|
+
goal: string;
|
|
109
|
+
at: string;
|
|
110
|
+
} | {
|
|
111
|
+
type: "subagent_result";
|
|
112
|
+
id: string;
|
|
113
|
+
role: string;
|
|
114
|
+
status: string;
|
|
115
|
+
summary: string;
|
|
116
|
+
at: string;
|
|
117
|
+
} | {
|
|
118
|
+
type: "final";
|
|
119
|
+
content: string;
|
|
120
|
+
at: string;
|
|
121
|
+
} | {
|
|
122
|
+
type: "error";
|
|
123
|
+
message: string;
|
|
124
|
+
code?: string;
|
|
125
|
+
retryable?: boolean;
|
|
126
|
+
at: string;
|
|
127
|
+
};
|
|
128
|
+
export interface CodaliRuntimeInput {
|
|
129
|
+
task: string;
|
|
130
|
+
messages?: ProviderMessage[];
|
|
131
|
+
workspace: CodaliRuntimeWorkspace;
|
|
132
|
+
provider: CodaliRuntimeProviderInput;
|
|
133
|
+
agent?: CodaliRuntimeAgentInput;
|
|
134
|
+
docdex?: CodaliRuntimeDocdexInput;
|
|
135
|
+
policy: CodaliRuntimePolicy;
|
|
136
|
+
response?: {
|
|
137
|
+
format?: "text" | "json" | "json_schema" | "gbnf";
|
|
138
|
+
schema?: Record<string, unknown>;
|
|
139
|
+
grammar?: string;
|
|
140
|
+
};
|
|
141
|
+
streaming?: {
|
|
142
|
+
enabled: boolean;
|
|
143
|
+
flushEveryMs?: number;
|
|
144
|
+
};
|
|
145
|
+
metadata?: {
|
|
146
|
+
jobId?: string;
|
|
147
|
+
requestId?: string;
|
|
148
|
+
tenantId?: string;
|
|
149
|
+
ownerUserId?: string;
|
|
150
|
+
apiKeyId?: string;
|
|
151
|
+
agentSlug?: string;
|
|
152
|
+
};
|
|
153
|
+
subagents?: CodaliRuntimeSubagentsInput;
|
|
154
|
+
session?: CodaliRuntimeSessionInput;
|
|
155
|
+
onEvent?: (event: CodaliRuntimeEvent) => void | Promise<void>;
|
|
156
|
+
providerInstance?: unknown;
|
|
157
|
+
toolRegistry?: unknown;
|
|
158
|
+
tools?: unknown[];
|
|
159
|
+
toolContext?: Record<string, unknown>;
|
|
160
|
+
logger?: unknown;
|
|
161
|
+
}
|
|
162
|
+
export interface CodaliRuntimeResult {
|
|
163
|
+
finalMessage: string;
|
|
164
|
+
messages: ProviderMessage[];
|
|
165
|
+
toolCallsExecuted: number;
|
|
166
|
+
usage?: ProviderUsage;
|
|
167
|
+
touchedFiles: string[];
|
|
168
|
+
warnings: string[];
|
|
169
|
+
events: CodaliRuntimeEvent[];
|
|
170
|
+
runId: string;
|
|
171
|
+
session?: {
|
|
172
|
+
id: string;
|
|
173
|
+
summaryRefs: string[];
|
|
174
|
+
instructionSources: string[];
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
export interface MswarmCodaliChatMessage {
|
|
178
|
+
role: string;
|
|
179
|
+
content: string | Array<{
|
|
180
|
+
type: string;
|
|
181
|
+
text?: string;
|
|
182
|
+
}>;
|
|
183
|
+
}
|
|
184
|
+
export interface MswarmCodaliAgent {
|
|
185
|
+
slug: string;
|
|
186
|
+
adapter: string;
|
|
187
|
+
provider?: string;
|
|
188
|
+
model: string;
|
|
189
|
+
baseUrl?: string;
|
|
190
|
+
apiKey?: string;
|
|
191
|
+
supportsTools?: boolean;
|
|
192
|
+
capabilities?: string[];
|
|
193
|
+
contextWindow?: number;
|
|
194
|
+
maxOutputTokens?: number;
|
|
195
|
+
}
|
|
196
|
+
export interface MswarmCodaliWorkspace {
|
|
197
|
+
root: string;
|
|
198
|
+
readOnly?: boolean;
|
|
199
|
+
}
|
|
200
|
+
export interface MswarmCodaliDocdex {
|
|
201
|
+
baseUrl?: string;
|
|
202
|
+
repoRoot?: string;
|
|
203
|
+
repoId?: string;
|
|
204
|
+
dagSessionId?: string;
|
|
205
|
+
initialize?: boolean;
|
|
206
|
+
allowWeb?: boolean;
|
|
207
|
+
allowMemoryWrite?: boolean;
|
|
208
|
+
allowProfileWrite?: boolean;
|
|
209
|
+
allowIndexRebuild?: boolean;
|
|
210
|
+
}
|
|
211
|
+
export interface MswarmCodaliPolicy {
|
|
212
|
+
allowTools?: boolean;
|
|
213
|
+
allowedTools?: string[];
|
|
214
|
+
deniedTools?: string[];
|
|
215
|
+
allowShell?: boolean;
|
|
216
|
+
allowWrites?: boolean;
|
|
217
|
+
allowDestructiveOperations?: boolean;
|
|
218
|
+
allowOutsideWorkspace?: boolean;
|
|
219
|
+
maxRuntimeMs?: number;
|
|
220
|
+
maxToolCalls?: number;
|
|
221
|
+
maxOutputTokens?: number;
|
|
222
|
+
}
|
|
223
|
+
export interface MswarmCodaliSession extends CodaliRuntimeSessionInput {
|
|
224
|
+
}
|
|
225
|
+
export interface MswarmCodaliSubagents extends CodaliRuntimeSubagentsInput {
|
|
226
|
+
}
|
|
227
|
+
export interface MswarmCodaliInvocationInput {
|
|
228
|
+
jobId: string;
|
|
229
|
+
requestId: string;
|
|
230
|
+
model: string;
|
|
231
|
+
messages: MswarmCodaliChatMessage[];
|
|
232
|
+
agent: MswarmCodaliAgent;
|
|
233
|
+
workspace?: MswarmCodaliWorkspace;
|
|
234
|
+
docdex?: MswarmCodaliDocdex;
|
|
235
|
+
policy?: MswarmCodaliPolicy;
|
|
236
|
+
session?: MswarmCodaliSession;
|
|
237
|
+
subagents?: MswarmCodaliSubagents;
|
|
238
|
+
temperature?: number;
|
|
239
|
+
responseFormat?: Record<string, unknown> | null;
|
|
240
|
+
stream?: boolean;
|
|
241
|
+
onOpenAIChunk?: (chunk: Record<string, unknown>) => void | Promise<void>;
|
|
242
|
+
onRuntimeEvent?: (event: CodaliRuntimeEvent) => void | Promise<void>;
|
|
243
|
+
runCodali?: (input: CodaliRuntimeInput) => Promise<CodaliRuntimeResult>;
|
|
244
|
+
}
|
|
245
|
+
export interface MswarmCodaliInvocationResult {
|
|
246
|
+
output: string;
|
|
247
|
+
usage?: ProviderUsage;
|
|
248
|
+
runtimeResult: CodaliRuntimeResult;
|
|
249
|
+
openAIChunks: Record<string, unknown>[];
|
|
250
|
+
metadata: {
|
|
251
|
+
provider: string;
|
|
252
|
+
adapter: string;
|
|
253
|
+
local_model: string;
|
|
254
|
+
agent_slug: string;
|
|
255
|
+
run_id: string;
|
|
256
|
+
tool_calls_executed: number;
|
|
257
|
+
touched_files: string[];
|
|
258
|
+
warnings: string[];
|
|
259
|
+
mode: CodaliRuntimeInput["policy"]["mode"];
|
|
260
|
+
session_id?: string;
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
export declare class MswarmCodaliExecutor {
|
|
264
|
+
invoke(input: MswarmCodaliInvocationInput): Promise<MswarmCodaliInvocationResult>;
|
|
265
|
+
}
|
|
266
|
+
//# sourceMappingURL=codali-executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codali-executor.d.ts","sourceRoot":"","sources":["../src/codali-executor.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;AAEpE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,mBAAmB,GAAG,eAAe,GAAG,WAAW,GAAG,MAAM,CAAC;IACnE,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,M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B,aAAa,EAAE,mBAAmB,CAAC;IACnC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IACxC,QAAQ,EAAE;QACR,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,mBAAmB,EAAE,MAAM,CAAC;QAC5B,aAAa,EAAE,MAAM,EAAE,CAAC;QACxB,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,IAAI,EAAE,kBAAkB,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;QAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAoMD,qBAAa,oBAAoB;IACzB,MAAM,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO,CAAC,4BAA4B,CAAC;CAsExF"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
const DEFAULT_RUNTIME_MS = 3600000;
|
|
2
|
+
const DEFAULT_MAX_STEPS = 24;
|
|
3
|
+
const DEFAULT_MAX_TOOL_CALLS = 40;
|
|
4
|
+
const DEFAULT_DOCDEX_BASE_URL = "http://127.0.0.1:28491";
|
|
5
|
+
const dynamicImport = new Function("specifier", "return import(specifier)");
|
|
6
|
+
let codaliModulePromise;
|
|
7
|
+
async function importCodaliModule(specifier) {
|
|
8
|
+
return (await dynamicImport(specifier));
|
|
9
|
+
}
|
|
10
|
+
async function loadCodaliModule() {
|
|
11
|
+
if (!codaliModulePromise) {
|
|
12
|
+
codaliModulePromise = (async () => {
|
|
13
|
+
if (process.env.MSWARM_CODALI_VENDOR_ONLY !== "1") {
|
|
14
|
+
try {
|
|
15
|
+
return await importCodaliModule("@mcoda/codali");
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
// Fall through to the vendored copy included in the published mswarm tarball.
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const vendorUrl = new URL("./vendor/codali/index.js", import.meta.url).href;
|
|
22
|
+
return importCodaliModule(vendorUrl);
|
|
23
|
+
})();
|
|
24
|
+
}
|
|
25
|
+
return codaliModulePromise;
|
|
26
|
+
}
|
|
27
|
+
function optionalText(value) {
|
|
28
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
|
29
|
+
}
|
|
30
|
+
function textFromMessageContent(content) {
|
|
31
|
+
if (typeof content === "string") {
|
|
32
|
+
return content;
|
|
33
|
+
}
|
|
34
|
+
return content
|
|
35
|
+
.map((part) => (part.type === "text" && typeof part.text === "string" ? part.text : ""))
|
|
36
|
+
.filter(Boolean)
|
|
37
|
+
.join("\n");
|
|
38
|
+
}
|
|
39
|
+
function toProviderMessages(messages) {
|
|
40
|
+
return messages.map((message) => {
|
|
41
|
+
const role = message.role === "system" ||
|
|
42
|
+
message.role === "assistant" ||
|
|
43
|
+
message.role === "tool" ||
|
|
44
|
+
message.role === "user"
|
|
45
|
+
? message.role
|
|
46
|
+
: "user";
|
|
47
|
+
return {
|
|
48
|
+
role,
|
|
49
|
+
content: textFromMessageContent(message.content),
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function messagesToTask(messages) {
|
|
54
|
+
return messages
|
|
55
|
+
.map((message) => {
|
|
56
|
+
const content = textFromMessageContent(message.content).trim();
|
|
57
|
+
return content ? `${message.role || "user"}: ${content}` : "";
|
|
58
|
+
})
|
|
59
|
+
.filter(Boolean)
|
|
60
|
+
.join("\n\n")
|
|
61
|
+
.trim();
|
|
62
|
+
}
|
|
63
|
+
function responseFormatToCodali(responseFormat) {
|
|
64
|
+
if (!responseFormat)
|
|
65
|
+
return undefined;
|
|
66
|
+
if (responseFormat.type === "json_object") {
|
|
67
|
+
return { format: "json" };
|
|
68
|
+
}
|
|
69
|
+
if (responseFormat.type === "json_schema") {
|
|
70
|
+
const jsonSchema = responseFormat.json_schema && typeof responseFormat.json_schema === "object"
|
|
71
|
+
? responseFormat.json_schema
|
|
72
|
+
: undefined;
|
|
73
|
+
const schema = jsonSchema?.schema && typeof jsonSchema.schema === "object"
|
|
74
|
+
? jsonSchema.schema
|
|
75
|
+
: jsonSchema ?? responseFormat;
|
|
76
|
+
return { format: "json_schema", schema };
|
|
77
|
+
}
|
|
78
|
+
if (responseFormat.type === "text") {
|
|
79
|
+
return { format: "text" };
|
|
80
|
+
}
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
function providerNameForAgent(agent) {
|
|
84
|
+
if (agent.provider) {
|
|
85
|
+
return agent.provider;
|
|
86
|
+
}
|
|
87
|
+
if (agent.adapter === "ollama-remote" || agent.adapter === "ollama") {
|
|
88
|
+
return "ollama-remote";
|
|
89
|
+
}
|
|
90
|
+
if (agent.adapter === "openai" ||
|
|
91
|
+
agent.adapter === "openai-compatible" ||
|
|
92
|
+
agent.adapter === "openai-cli") {
|
|
93
|
+
return "openai-compatible";
|
|
94
|
+
}
|
|
95
|
+
if (agent.adapter === "codex-cli") {
|
|
96
|
+
return "codex-cli";
|
|
97
|
+
}
|
|
98
|
+
return agent.adapter;
|
|
99
|
+
}
|
|
100
|
+
function runtimeModeForAgent(agent, policy) {
|
|
101
|
+
if (policy?.allowTools === false) {
|
|
102
|
+
return "freeform";
|
|
103
|
+
}
|
|
104
|
+
if (agent.supportsTools === false) {
|
|
105
|
+
return "protocol_loop";
|
|
106
|
+
}
|
|
107
|
+
return "tool_loop";
|
|
108
|
+
}
|
|
109
|
+
function buildRuntimePolicy(agent, policy) {
|
|
110
|
+
const allowTools = policy?.allowTools !== false;
|
|
111
|
+
const mode = runtimeModeForAgent(agent, policy);
|
|
112
|
+
const allowRuntimeTools = allowTools && (mode === "tool_loop" || mode === "protocol_loop");
|
|
113
|
+
const maxOutputTokens = policy?.maxOutputTokens ?? agent.maxOutputTokens ?? undefined;
|
|
114
|
+
return {
|
|
115
|
+
allowWrites: policy?.allowWrites === true,
|
|
116
|
+
allowShell: policy?.allowShell === true,
|
|
117
|
+
allowDestructiveOperations: policy?.allowDestructiveOperations === true,
|
|
118
|
+
allowOutsideWorkspace: policy?.allowOutsideWorkspace === true,
|
|
119
|
+
allowedTools: allowTools ? policy?.allowedTools : [],
|
|
120
|
+
deniedTools: policy?.deniedTools,
|
|
121
|
+
maxSteps: allowRuntimeTools ? DEFAULT_MAX_STEPS : 2,
|
|
122
|
+
maxToolCalls: allowRuntimeTools
|
|
123
|
+
? policy?.maxToolCalls ?? DEFAULT_MAX_TOOL_CALLS
|
|
124
|
+
: 0,
|
|
125
|
+
maxTokens: maxOutputTokens,
|
|
126
|
+
timeoutMs: policy?.maxRuntimeMs ?? DEFAULT_RUNTIME_MS,
|
|
127
|
+
mode,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function buildRuntimeDocdex(workspace, docdex, requestId) {
|
|
131
|
+
return {
|
|
132
|
+
baseUrl: docdex?.baseUrl ?? DEFAULT_DOCDEX_BASE_URL,
|
|
133
|
+
repoRoot: docdex?.repoRoot ?? workspace.root,
|
|
134
|
+
repoId: docdex?.repoId,
|
|
135
|
+
dagSessionId: docdex?.dagSessionId ?? requestId,
|
|
136
|
+
initialize: docdex?.initialize,
|
|
137
|
+
allowWeb: docdex?.allowWeb ?? false,
|
|
138
|
+
allowMemoryWrite: docdex?.allowMemoryWrite ?? false,
|
|
139
|
+
allowProfileWrite: docdex?.allowProfileWrite ?? false,
|
|
140
|
+
allowIndexRebuild: docdex?.allowIndexRebuild ?? false,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function runtimeAgent(agent) {
|
|
144
|
+
return {
|
|
145
|
+
slug: agent.slug,
|
|
146
|
+
adapter: agent.adapter,
|
|
147
|
+
provider: providerNameForAgent(agent),
|
|
148
|
+
model: agent.model,
|
|
149
|
+
baseUrl: agent.baseUrl,
|
|
150
|
+
supportsTools: agent.supportsTools,
|
|
151
|
+
capabilities: agent.capabilities,
|
|
152
|
+
contextWindow: agent.contextWindow,
|
|
153
|
+
maxOutputTokens: agent.maxOutputTokens,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function openAIChunkOptions(input) {
|
|
157
|
+
return { requestId: input.requestId, model: input.model };
|
|
158
|
+
}
|
|
159
|
+
export class MswarmCodaliExecutor {
|
|
160
|
+
async invoke(input) {
|
|
161
|
+
const codali = await loadCodaliModule();
|
|
162
|
+
const workspace = input.workspace ?? {
|
|
163
|
+
root: process.cwd(),
|
|
164
|
+
readOnly: true,
|
|
165
|
+
};
|
|
166
|
+
const providerName = providerNameForAgent(input.agent);
|
|
167
|
+
const runtimePolicy = buildRuntimePolicy(input.agent, input.policy);
|
|
168
|
+
const openAIChunks = [];
|
|
169
|
+
const emitChunk = async (chunk) => {
|
|
170
|
+
openAIChunks.push(chunk);
|
|
171
|
+
await input.onOpenAIChunk?.(chunk);
|
|
172
|
+
};
|
|
173
|
+
const runCodali = input.runCodali ?? codali.runCodaliTask;
|
|
174
|
+
const runtimeResult = await runCodali({
|
|
175
|
+
task: messagesToTask(input.messages),
|
|
176
|
+
messages: toProviderMessages(input.messages),
|
|
177
|
+
workspace,
|
|
178
|
+
provider: {
|
|
179
|
+
name: providerName,
|
|
180
|
+
model: input.agent.model,
|
|
181
|
+
baseUrl: input.agent.baseUrl,
|
|
182
|
+
apiKey: input.agent.apiKey,
|
|
183
|
+
timeoutMs: runtimePolicy.timeoutMs,
|
|
184
|
+
},
|
|
185
|
+
agent: runtimeAgent(input.agent),
|
|
186
|
+
docdex: buildRuntimeDocdex(workspace, input.docdex, input.requestId),
|
|
187
|
+
policy: runtimePolicy,
|
|
188
|
+
response: responseFormatToCodali(input.responseFormat),
|
|
189
|
+
streaming: { enabled: input.stream === true, flushEveryMs: 250 },
|
|
190
|
+
session: input.session,
|
|
191
|
+
subagents: input.subagents,
|
|
192
|
+
metadata: {
|
|
193
|
+
jobId: input.jobId,
|
|
194
|
+
requestId: input.requestId,
|
|
195
|
+
agentSlug: input.agent.slug,
|
|
196
|
+
},
|
|
197
|
+
onEvent: async (event) => {
|
|
198
|
+
await input.onRuntimeEvent?.(event);
|
|
199
|
+
if (input.stream) {
|
|
200
|
+
const chunk = codali.codaliEventToOpenAIChatCompletionChunk(event, openAIChunkOptions(input));
|
|
201
|
+
if (chunk) {
|
|
202
|
+
await emitChunk(chunk);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
return {
|
|
208
|
+
output: runtimeResult.finalMessage,
|
|
209
|
+
usage: runtimeResult.usage,
|
|
210
|
+
runtimeResult,
|
|
211
|
+
openAIChunks,
|
|
212
|
+
metadata: {
|
|
213
|
+
provider: providerName,
|
|
214
|
+
adapter: input.agent.adapter,
|
|
215
|
+
local_model: optionalText(input.agent.model) ?? input.model,
|
|
216
|
+
agent_slug: input.agent.slug,
|
|
217
|
+
run_id: runtimeResult.runId,
|
|
218
|
+
tool_calls_executed: runtimeResult.toolCallsExecuted,
|
|
219
|
+
touched_files: runtimeResult.touchedFiles,
|
|
220
|
+
warnings: runtimeResult.warnings,
|
|
221
|
+
mode: runtimePolicy.mode,
|
|
222
|
+
session_id: runtimeResult.session?.id,
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
//# sourceMappingURL=codali-executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codali-executor.js","sourceRoot":"","sources":["../src/codali-executor.ts"],"names":[],"mappings":"AAqQA,MAAM,kBAAkB,GAAG,OAAS,CAAC;AACrC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AACzD,MAAM,aAAa,GAAG,IAAI,QAAQ,CAAC,WAAW,EAAE,0BAA0B,CAErD,CAAC;AACtB,IAAI,mBAAsD,CAAC;AAE3D,KAAK,UAAU,kBAAkB,CAAC,SAAiB;IAC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K,CAAC,KAAK,CAAC,IAAI;aAC5B;YACD,OAAO,EAAE,KAAK,EAAE,KAAyB,EAAE,EAAE;gBAC3C,MAAM,KAAK,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC,CAAC;gBACpC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;oBACjB,MAAM,KAAK,GAAG,MAAM,CAAC,sCAAsC,CACzD,KAAK,EACL,kBAAkB,CAAC,KAAK,CAAC,CAC1B,CAAC;oBACF,IAAI,KAAK,EAAE,CAAC;wBACV,MAAM,SAAS,CAAC,KAAK,CAAC,CAAC;oBACzB,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC,CAAC;QAEH,OAAO;YACL,MAAM,EAAE,aAAa,CAAC,YAAY;YAClC,KAAK,EAAE,aAAa,CAAC,KAAK;YAC1B,aAAa;YACb,YAAY;YACZ,QAAQ,EAAE;gBACR,QAAQ,EAAE,YAAY;gBACtB,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO;gBAC5B,WAAW,EAAE,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK;gBAC3D,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI;gBAC5B,MAAM,EAAE,aAAa,CAAC,KAAK;gBAC3B,mBAAmB,EAAE,aAAa,CAAC,iBAAiB;gBACpD,aAAa,EAAE,aAAa,CAAC,YAAY;gBACzC,QAAQ,EAAE,aAAa,CAAC,QAAQ;gBAChC,IAAI,EAAE,aAAa,CAAC,IAAI;gBACxB,UAAU,EAAE,aAAa,CAAC,OAAO,EAAE,EAAE;aACtC;SACF,CAAC;IACJ,CAAC;CACF"}
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MswarmCodaliExecutor } from "./codali-executor.js";
|
|
1
2
|
export type FetchLike = typeof fetch;
|
|
2
3
|
export type SelfHostedDiscoveryMode = "mcoda" | "ollama";
|
|
3
4
|
export type SelfHostedRelayMode = "outbound" | "direct";
|
|
@@ -139,6 +140,11 @@ export interface SelfHostedNodeSetupResult {
|
|
|
139
140
|
runtimeTokenPath: string;
|
|
140
141
|
start: boolean;
|
|
141
142
|
}
|
|
143
|
+
export interface SelfHostedNodeUninstallNotificationResult {
|
|
144
|
+
notified: boolean;
|
|
145
|
+
response?: unknown;
|
|
146
|
+
error?: string;
|
|
147
|
+
}
|
|
142
148
|
export interface SelfHostedOpenAIChatMessage {
|
|
143
149
|
role: string;
|
|
144
150
|
content: string | Array<{
|
|
@@ -153,9 +159,25 @@ export interface SelfHostedNodeInvocationJob {
|
|
|
153
159
|
agent_slug: string;
|
|
154
160
|
remote_slug?: string;
|
|
155
161
|
provider?: "mcoda" | "ollama";
|
|
162
|
+
execution_runtime?: "codali" | "raw" | string;
|
|
156
163
|
adapter?: string | null;
|
|
157
164
|
source_agent_slug?: string | null;
|
|
158
165
|
model?: string | null;
|
|
166
|
+
workspace?: {
|
|
167
|
+
root?: string;
|
|
168
|
+
read_only?: boolean;
|
|
169
|
+
};
|
|
170
|
+
docdex?: {
|
|
171
|
+
base_url?: string;
|
|
172
|
+
repo_root?: string;
|
|
173
|
+
repo_id?: string;
|
|
174
|
+
dag_session_id?: string;
|
|
175
|
+
initialize?: boolean;
|
|
176
|
+
allow_web?: boolean;
|
|
177
|
+
allow_memory_write?: boolean;
|
|
178
|
+
allow_profile_write?: boolean;
|
|
179
|
+
allow_index_rebuild?: boolean;
|
|
180
|
+
};
|
|
159
181
|
openai_request: {
|
|
160
182
|
model: string;
|
|
161
183
|
messages: SelfHostedOpenAIChatMessage[];
|
|
@@ -171,6 +193,13 @@ export interface SelfHostedNodeInvocationJob {
|
|
|
171
193
|
max_output_tokens?: number;
|
|
172
194
|
allow_tools?: boolean;
|
|
173
195
|
allow_images?: boolean;
|
|
196
|
+
allowed_tools?: string[];
|
|
197
|
+
denied_tools?: string[];
|
|
198
|
+
allow_shell?: boolean;
|
|
199
|
+
allow_writes?: boolean;
|
|
200
|
+
allow_outside_workspace?: boolean;
|
|
201
|
+
allow_destructive_operations?: boolean;
|
|
202
|
+
max_tool_calls?: number;
|
|
174
203
|
};
|
|
175
204
|
}
|
|
176
205
|
export interface SelfHostedNodeInvocationResult {
|
|
@@ -178,6 +207,8 @@ export interface SelfHostedNodeInvocationResult {
|
|
|
178
207
|
request_id: string;
|
|
179
208
|
status: "success" | "failed";
|
|
180
209
|
openai_response?: Record<string, unknown>;
|
|
210
|
+
stream_events?: Record<string, unknown>[];
|
|
211
|
+
progress_events?: Record<string, unknown>[];
|
|
181
212
|
error?: {
|
|
182
213
|
code: string;
|
|
183
214
|
message: string;
|
|
@@ -186,6 +217,10 @@ export interface SelfHostedNodeInvocationResult {
|
|
|
186
217
|
local_latency_ms: number;
|
|
187
218
|
};
|
|
188
219
|
}
|
|
220
|
+
export interface SelfHostedJobExecutionOptions {
|
|
221
|
+
onOpenAIChunk?: (chunk: Record<string, unknown>) => void | Promise<void>;
|
|
222
|
+
onProgress?: (event: Record<string, unknown>) => void | Promise<void>;
|
|
223
|
+
}
|
|
189
224
|
export interface SelfHostedNodeHeartbeatResult {
|
|
190
225
|
enrolled: boolean;
|
|
191
226
|
status: "online" | "degraded";
|
|
@@ -331,6 +366,7 @@ export declare class McodaAgentInventoryClient {
|
|
|
331
366
|
timeoutMs?: number;
|
|
332
367
|
runner?: CommandRunner;
|
|
333
368
|
});
|
|
369
|
+
listRawAgents(): Promise<McodaAgentListEntry[]>;
|
|
334
370
|
listAgents(config: Pick<SelfHostedNodeConfig, "exposeAllModels" | "modelAllowlist" | "modelBlocklist">): Promise<SelfHostedModelInput[]>;
|
|
335
371
|
}
|
|
336
372
|
export declare class OllamaClient {
|
|
@@ -385,6 +421,7 @@ export declare class MswarmSelfHostedNodeClient {
|
|
|
385
421
|
bootstrap(apiKey: string, payload: Record<string, unknown>): Promise<GatewayBootstrapResponse>;
|
|
386
422
|
health(): Promise<unknown>;
|
|
387
423
|
heartbeat(runtimeToken: string, payload: Record<string, unknown>): Promise<unknown>;
|
|
424
|
+
uninstall(runtimeToken: string, payload: Record<string, unknown>): Promise<unknown>;
|
|
388
425
|
pushModels(runtimeToken: string, payload: {
|
|
389
426
|
node_id: string;
|
|
390
427
|
models: SelfHostedModelInput[];
|
|
@@ -405,12 +442,14 @@ export declare class SelfHostedNodeRuntime {
|
|
|
405
442
|
private readonly gateway;
|
|
406
443
|
private readonly mcoda;
|
|
407
444
|
private readonly mcodaExecutor;
|
|
445
|
+
private readonly codaliExecutor;
|
|
408
446
|
private readonly ollama;
|
|
409
447
|
private readonly jobOllama;
|
|
410
448
|
constructor(config: SelfHostedNodeConfig, deps?: {
|
|
411
449
|
gateway?: MswarmSelfHostedNodeClient;
|
|
412
450
|
mcoda?: McodaAgentInventoryClient;
|
|
413
451
|
mcodaExecutor?: McodaLocalAgentExecutor;
|
|
452
|
+
codaliExecutor?: MswarmCodaliExecutor;
|
|
414
453
|
ollama?: OllamaClient;
|
|
415
454
|
fetchImpl?: FetchLike;
|
|
416
455
|
});
|
|
@@ -418,6 +457,7 @@ export declare class SelfHostedNodeRuntime {
|
|
|
418
457
|
gateway?: MswarmSelfHostedNodeClient;
|
|
419
458
|
mcoda?: McodaAgentInventoryClient;
|
|
420
459
|
mcodaExecutor?: McodaLocalAgentExecutor;
|
|
460
|
+
codaliExecutor?: MswarmCodaliExecutor;
|
|
421
461
|
ollama?: OllamaClient;
|
|
422
462
|
fetchImpl?: FetchLike;
|
|
423
463
|
}): Promise<SelfHostedNodeSetupResult>;
|
|
@@ -427,8 +467,14 @@ export declare class SelfHostedNodeRuntime {
|
|
|
427
467
|
state: SelfHostedNodeState;
|
|
428
468
|
enrolled: boolean;
|
|
429
469
|
}>;
|
|
430
|
-
|
|
470
|
+
private resolveMcodaAgentForJob;
|
|
471
|
+
executeJob(job: SelfHostedNodeInvocationJob, options?: SelfHostedJobExecutionOptions): Promise<SelfHostedNodeInvocationResult>;
|
|
431
472
|
runOnce(): Promise<SelfHostedNodeHeartbeatResult>;
|
|
473
|
+
notifyUninstall(input?: {
|
|
474
|
+
reason?: string;
|
|
475
|
+
source?: string;
|
|
476
|
+
serviceManager?: string | null;
|
|
477
|
+
}): Promise<SelfHostedNodeUninstallNotificationResult>;
|
|
432
478
|
pushModelsOnly(): Promise<{
|
|
433
479
|
count: number;
|
|
434
480
|
response: unknown;
|