@mcoda/codali 0.1.133 → 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/CHANGELOG.md +37 -0
- package/ORCHESTRATION.md +387 -0
- package/README.md +103 -1
- package/config/alternate-local.example.json +49 -0
- package/config/docdex-runtime.json +21 -0
- package/config/orchestration.schema.json +548 -0
- package/config/raijin-suku.example.json +172 -0
- package/config/terminal-long-scenarios.v1.json +70 -0
- package/dist/agents/RoleResolution.d.ts.map +1 -1
- package/dist/agents/RoleResolution.js +4 -4
- package/dist/api/CodaliApi.d.ts +16 -0
- package/dist/api/CodaliApi.d.ts.map +1 -1
- package/dist/api/CodaliApi.js +39 -10
- package/dist/cli/AskCommand.d.ts +3 -0
- package/dist/cli/AskCommand.d.ts.map +1 -1
- package/dist/cli/AskCommand.js +76 -13
- package/dist/cli/RunCommand.d.ts +4 -0
- package/dist/cli/RunCommand.d.ts.map +1 -1
- package/dist/cli/RunCommand.js +110 -24
- package/dist/cli/TerminalCommand.d.ts +35 -0
- package/dist/cli/TerminalCommand.d.ts.map +1 -0
- package/dist/cli/TerminalCommand.js +616 -0
- package/dist/cli/TerminalCredentials.d.ts +3 -0
- package/dist/cli/TerminalCredentials.d.ts.map +1 -0
- package/dist/cli/TerminalCredentials.js +89 -0
- package/dist/cli/TerminalInput.d.ts +24 -0
- package/dist/cli/TerminalInput.d.ts.map +1 -0
- package/dist/cli/TerminalInput.js +98 -0
- package/dist/cli/TerminalText.d.ts +10 -0
- package/dist/cli/TerminalText.d.ts.map +1 -0
- package/dist/cli/TerminalText.js +53 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +33 -4
- package/dist/cognitive/ConfiguredPipeline.d.ts +34 -0
- package/dist/cognitive/ConfiguredPipeline.d.ts.map +1 -0
- package/dist/cognitive/ConfiguredPipeline.js +50 -0
- package/dist/cognitive/ValidationRunner.d.ts +4 -0
- package/dist/cognitive/ValidationRunner.d.ts.map +1 -1
- package/dist/cognitive/ValidationRunner.js +18 -41
- package/dist/config/NodeOrchestration.d.ts +21 -0
- package/dist/config/NodeOrchestration.d.ts.map +1 -0
- package/dist/config/NodeOrchestration.js +54 -0
- package/dist/config/OrchestrationConfig.d.ts +100 -0
- package/dist/config/OrchestrationConfig.d.ts.map +1 -0
- package/dist/config/OrchestrationConfig.js +245 -0
- package/dist/connectors/mcp/McpClient.d.ts +3 -1
- package/dist/connectors/mcp/McpClient.d.ts.map +1 -1
- package/dist/connectors/mcp/McpClient.js +3 -2
- package/dist/connectors/mcp/McpServerRegistry.d.ts +2 -2
- package/dist/connectors/mcp/McpServerRegistry.d.ts.map +1 -1
- package/dist/connectors/mcp/McpServerRegistry.js +39 -16
- package/dist/connectors/mcp/McpToolAdapter.js +2 -2
- package/dist/connectors/media/ConfiguredMediaTools.d.ts +6 -0
- package/dist/connectors/media/ConfiguredMediaTools.d.ts.map +1 -0
- package/dist/connectors/media/ConfiguredMediaTools.js +41 -0
- package/dist/connectors/media/ImageGenerationTool.js +3 -3
- package/dist/connectors/media/MediaArtifactReceipt.d.ts +5 -0
- package/dist/connectors/media/MediaArtifactReceipt.d.ts.map +1 -0
- package/dist/connectors/media/MediaArtifactReceipt.js +65 -0
- package/dist/connectors/media/MediaJobStore.d.ts +68 -0
- package/dist/connectors/media/MediaJobStore.d.ts.map +1 -0
- package/dist/connectors/media/MediaJobStore.js +199 -0
- package/dist/connectors/media/MediaJobWorker.d.ts +2 -0
- package/dist/connectors/media/MediaJobWorker.d.ts.map +1 -0
- package/dist/connectors/media/MediaJobWorker.js +65 -0
- package/dist/connectors/media/RemoteMediaJob.d.ts +6 -0
- package/dist/connectors/media/RemoteMediaJob.d.ts.map +1 -0
- package/dist/connectors/media/RemoteMediaJob.js +80 -0
- package/dist/docdex/DocdexClient.d.ts +18 -1
- package/dist/docdex/DocdexClient.d.ts.map +1 -1
- package/dist/docdex/DocdexClient.js +135 -19
- package/dist/docdex/ManagedDocdex.d.ts +29 -0
- package/dist/docdex/ManagedDocdex.d.ts.map +1 -0
- package/dist/docdex/ManagedDocdex.js +215 -0
- package/dist/docdex/ManagedRuntime.d.ts +28 -0
- package/dist/docdex/ManagedRuntime.d.ts.map +1 -0
- package/dist/docdex/ManagedRuntime.js +212 -0
- package/dist/eval/EvaluationProcess.d.ts +13 -0
- package/dist/eval/EvaluationProcess.d.ts.map +1 -0
- package/dist/eval/EvaluationProcess.js +76 -0
- package/dist/eval/LongWorkflowJourney.d.ts +34 -0
- package/dist/eval/LongWorkflowJourney.d.ts.map +1 -0
- package/dist/eval/LongWorkflowJourney.js +243 -0
- package/dist/eval/PlanningCorpus.d.ts +45 -0
- package/dist/eval/PlanningCorpus.d.ts.map +1 -0
- package/dist/eval/PlanningCorpus.js +189 -0
- package/dist/eval/PlanningCorpusRunner.d.ts +13 -0
- package/dist/eval/PlanningCorpusRunner.d.ts.map +1 -0
- package/dist/eval/PlanningCorpusRunner.js +89 -0
- package/dist/eval/TerminalCorpusRunner.d.ts +36 -0
- package/dist/eval/TerminalCorpusRunner.d.ts.map +1 -0
- package/dist/eval/TerminalCorpusRunner.js +222 -0
- package/dist/eval/TerminalTaskCorpus.d.ts +26 -0
- package/dist/eval/TerminalTaskCorpus.d.ts.map +1 -0
- package/dist/eval/TerminalTaskCorpus.js +105 -0
- package/dist/eval/TerminalWorkflowCorpus.d.ts +11 -0
- package/dist/eval/TerminalWorkflowCorpus.d.ts.map +1 -0
- package/dist/eval/TerminalWorkflowCorpus.js +116 -0
- package/dist/eval/fixtures/TerminalRecoveryJourney.d.ts +4 -0
- package/dist/eval/fixtures/TerminalRecoveryJourney.d.ts.map +1 -0
- package/dist/eval/fixtures/TerminalRecoveryJourney.js +132 -0
- package/dist/gateway/CodaliGateway.d.ts +2 -0
- package/dist/gateway/CodaliGateway.d.ts.map +1 -1
- package/dist/gateway/CodaliGateway.js +16 -4
- package/dist/gateway/ConfiguredGateway.d.ts +23 -0
- package/dist/gateway/ConfiguredGateway.d.ts.map +1 -0
- package/dist/gateway/ConfiguredGateway.js +44 -0
- package/dist/gateway/GatewayTracer.d.ts +1 -1
- package/dist/gateway/GatewayTracer.d.ts.map +1 -1
- package/dist/gateway/GatewayTracer.js +2 -27
- package/dist/gateway/LocalGatewayTaskRunner.d.ts.map +1 -1
- package/dist/gateway/LocalGatewayTaskRunner.js +13 -1
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/permissions/PermissionGate.d.ts +44 -0
- package/dist/permissions/PermissionGate.d.ts.map +1 -0
- package/dist/permissions/PermissionGate.js +97 -0
- package/dist/providers/ConfiguredEmbeddings.d.ts +43 -0
- package/dist/providers/ConfiguredEmbeddings.d.ts.map +1 -0
- package/dist/providers/ConfiguredEmbeddings.js +87 -0
- package/dist/providers/ConfiguredModelScope.d.ts +69 -0
- package/dist/providers/ConfiguredModelScope.d.ts.map +1 -0
- package/dist/providers/ConfiguredModelScope.js +113 -0
- package/dist/providers/ConfiguredProvider.d.ts +79 -0
- package/dist/providers/ConfiguredProvider.d.ts.map +1 -0
- package/dist/providers/ConfiguredProvider.js +238 -0
- package/dist/providers/ModelServiceError.d.ts +10 -0
- package/dist/providers/ModelServiceError.d.ts.map +1 -0
- package/dist/providers/ModelServiceError.js +45 -0
- package/dist/providers/MswarmWorkerProvider.d.ts.map +1 -1
- package/dist/providers/MswarmWorkerProvider.js +4 -0
- package/dist/providers/OpenAiCompatibleProvider.d.ts.map +1 -1
- package/dist/providers/OpenAiCompatibleProvider.js +134 -52
- package/dist/providers/ProviderTypes.d.ts +14 -0
- package/dist/providers/ProviderTypes.d.ts.map +1 -1
- package/dist/runtime/CodaliJobRuntime.d.ts +6 -0
- package/dist/runtime/CodaliJobRuntime.d.ts.map +1 -1
- package/dist/runtime/CodaliJobRuntime.js +36 -1
- package/dist/runtime/CodaliRuntime.d.ts +30 -0
- package/dist/runtime/CodaliRuntime.d.ts.map +1 -1
- package/dist/runtime/CodaliRuntime.js +71 -1
- package/dist/runtime/CompletionReport.d.ts +5 -0
- package/dist/runtime/CompletionReport.d.ts.map +1 -0
- package/dist/runtime/CompletionReport.js +12 -0
- package/dist/runtime/ProgressTracker.d.ts +17 -0
- package/dist/runtime/ProgressTracker.d.ts.map +1 -0
- package/dist/runtime/ProgressTracker.js +27 -0
- package/dist/runtime/RequestedTestEvidence.d.ts +12 -0
- package/dist/runtime/RequestedTestEvidence.d.ts.map +1 -0
- package/dist/runtime/RequestedTestEvidence.js +16 -0
- package/dist/runtime/RequiredRetrieval.d.ts +13 -0
- package/dist/runtime/RequiredRetrieval.d.ts.map +1 -0
- package/dist/runtime/RequiredRetrieval.js +25 -0
- package/dist/runtime/ReviewSource.d.ts +6 -0
- package/dist/runtime/ReviewSource.d.ts.map +1 -0
- package/dist/runtime/ReviewSource.js +38 -0
- package/dist/runtime/Runner.d.ts +13 -0
- package/dist/runtime/Runner.d.ts.map +1 -1
- package/dist/runtime/Runner.js +220 -158
- package/dist/runtime/SecretRedaction.d.ts +11 -0
- package/dist/runtime/SecretRedaction.d.ts.map +1 -0
- package/dist/runtime/SecretRedaction.js +85 -0
- package/dist/runtime/SessionController.d.ts +148 -0
- package/dist/runtime/SessionController.d.ts.map +1 -0
- package/dist/runtime/SessionController.js +1356 -0
- package/dist/runtime/StructuralEvidence.d.ts +22 -0
- package/dist/runtime/StructuralEvidence.d.ts.map +1 -0
- package/dist/runtime/StructuralEvidence.js +87 -0
- package/dist/runtime/TaskReviewContext.d.ts +34 -0
- package/dist/runtime/TaskReviewContext.d.ts.map +1 -0
- package/dist/runtime/TaskReviewContext.js +34 -0
- package/dist/runtime/ValidationOutput.d.ts +5 -0
- package/dist/runtime/ValidationOutput.d.ts.map +1 -0
- package/dist/runtime/ValidationOutput.js +32 -0
- package/dist/runtime/VerificationCommand.d.ts +3 -0
- package/dist/runtime/VerificationCommand.d.ts.map +1 -0
- package/dist/runtime/VerificationCommand.js +48 -0
- package/dist/runtime/WorkStatusPage.d.ts +15 -0
- package/dist/runtime/WorkStatusPage.d.ts.map +1 -0
- package/dist/runtime/WorkStatusPage.js +58 -0
- package/dist/runtime/WorkspaceLedger.d.ts +13 -0
- package/dist/runtime/WorkspaceLedger.d.ts.map +1 -0
- package/dist/runtime/WorkspaceLedger.js +145 -0
- package/dist/runtime/WorkspaceLock.d.ts.map +1 -1
- package/dist/runtime/WorkspaceLock.js +20 -17
- package/dist/runtime/WorkspaceSnapshot.d.ts +13 -0
- package/dist/runtime/WorkspaceSnapshot.d.ts.map +1 -0
- package/dist/runtime/WorkspaceSnapshot.js +88 -0
- package/dist/session/AtomicState.d.ts +13 -0
- package/dist/session/AtomicState.d.ts.map +1 -0
- package/dist/session/AtomicState.js +109 -0
- package/dist/session/SessionStoragePath.d.ts +15 -0
- package/dist/session/SessionStoragePath.d.ts.map +1 -0
- package/dist/session/SessionStoragePath.js +89 -0
- package/dist/session/SessionStore.d.ts +9 -0
- package/dist/session/SessionStore.d.ts.map +1 -1
- package/dist/session/SessionStore.js +181 -47
- package/dist/session/WorkState.d.ts +23 -0
- package/dist/session/WorkState.d.ts.map +1 -0
- package/dist/session/WorkState.js +367 -0
- package/dist/session/WorkTypes.d.ts +94 -0
- package/dist/session/WorkTypes.d.ts.map +1 -0
- package/dist/session/WorkTypes.js +1 -0
- package/dist/tools/ToolRegistry.d.ts +2 -0
- package/dist/tools/ToolRegistry.d.ts.map +1 -1
- package/dist/tools/ToolRegistry.js +12 -2
- package/dist/tools/ToolTypes.d.ts +16 -0
- package/dist/tools/ToolTypes.d.ts.map +1 -1
- package/dist/tools/docdex/DocdexTools.d.ts +2 -0
- package/dist/tools/docdex/DocdexTools.d.ts.map +1 -1
- package/dist/tools/docdex/DocdexTools.js +17 -2
- package/dist/tools/filesystem/FileTools.d.ts.map +1 -1
- package/dist/tools/filesystem/FileTools.js +30 -10
- package/dist/tools/shell/AsyncProcess.d.ts +16 -0
- package/dist/tools/shell/AsyncProcess.d.ts.map +1 -0
- package/dist/tools/shell/AsyncProcess.js +94 -0
- package/dist/tools/shell/DarwinRuntimeLibraries.d.ts +13 -0
- package/dist/tools/shell/DarwinRuntimeLibraries.d.ts.map +1 -0
- package/dist/tools/shell/DarwinRuntimeLibraries.js +130 -0
- package/dist/tools/shell/HostToolchain.d.ts +19 -0
- package/dist/tools/shell/HostToolchain.d.ts.map +1 -0
- package/dist/tools/shell/HostToolchain.js +264 -0
- package/dist/tools/shell/IsolatedExecutor.d.ts +15 -0
- package/dist/tools/shell/IsolatedExecutor.d.ts.map +1 -0
- package/dist/tools/shell/IsolatedExecutor.js +134 -0
- package/dist/tools/shell/ShellTool.d.ts.map +1 -1
- package/dist/tools/shell/ShellTool.js +9 -29
- package/dist/tools/shell/ShellWorkingDirectory.d.ts +3 -0
- package/dist/tools/shell/ShellWorkingDirectory.d.ts.map +1 -0
- package/dist/tools/shell/ShellWorkingDirectory.js +30 -0
- package/package.json +27 -24
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { credentialFilePath, parseCredentialFile, resetCredentialCache } from "../runcontext/CredentialFile.js";
|
|
5
|
+
import { withStateLock } from "../session/AtomicState.js";
|
|
6
|
+
export const setTerminalCredential = async (key) => {
|
|
7
|
+
if (key !== undefined && (!key.trim() || /[\r\n\0]/.test(key) || key.length > 8192))
|
|
8
|
+
throw new Error("Invalid API key");
|
|
9
|
+
const file = credentialFilePath();
|
|
10
|
+
await fs.mkdir(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
11
|
+
await withStateLock(file, async () => {
|
|
12
|
+
let existing = "";
|
|
13
|
+
try {
|
|
14
|
+
const stat = await fs.lstat(file);
|
|
15
|
+
if (stat.isSymbolicLink())
|
|
16
|
+
throw new Error("Credential file must not be a symlink");
|
|
17
|
+
existing = await fs.readFile(file, "utf8");
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (error.code !== "ENOENT")
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
const lines = existing.split(/\r?\n/).filter(line => !Object.keys(parseCredentialFile(line)).some(name => ["MCODA_MSWARM_API_KEY", "MSWARM_API_KEY", "CODALI_MSWARM_LOGGED_OUT"].includes(name)));
|
|
24
|
+
lines.push(key === undefined ? "CODALI_MSWARM_LOGGED_OUT=1" : `MCODA_MSWARM_API_KEY=${key.trim()}`);
|
|
25
|
+
const temporary = `${file}.${randomUUID()}.tmp`;
|
|
26
|
+
const handle = await fs.open(temporary, "wx", 0o600);
|
|
27
|
+
try {
|
|
28
|
+
await handle.writeFile(`${lines.filter(Boolean).join("\n")}\n`);
|
|
29
|
+
await handle.sync();
|
|
30
|
+
await handle.close();
|
|
31
|
+
await fs.rename(temporary, file);
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
await handle.close().catch(() => undefined);
|
|
35
|
+
await fs.unlink(temporary).catch(() => undefined);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
resetCredentialCache();
|
|
39
|
+
};
|
|
40
|
+
export const readTerminalCredential = async (fromStdin) => {
|
|
41
|
+
if (fromStdin) {
|
|
42
|
+
if (process.stdin.isTTY)
|
|
43
|
+
throw new Error("--stdin requires piped input");
|
|
44
|
+
let value = "";
|
|
45
|
+
for await (const chunk of process.stdin) {
|
|
46
|
+
value += String(chunk);
|
|
47
|
+
if (value.length > 8192)
|
|
48
|
+
throw new Error("API key input is too large");
|
|
49
|
+
}
|
|
50
|
+
return value.trim();
|
|
51
|
+
}
|
|
52
|
+
if (!process.stdin.isTTY)
|
|
53
|
+
throw new Error("Use codali login --stdin with piped input");
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
let value = "";
|
|
56
|
+
const wasRaw = process.stdin.isRaw;
|
|
57
|
+
const finish = (error) => { process.stdin.off("data", onData); process.stdin.setRawMode(wasRaw); process.stdin.pause(); process.stderr.write("\n"); error ? reject(error) : resolve(value); };
|
|
58
|
+
const onData = (chunk) => {
|
|
59
|
+
for (const character of chunk.toString("utf8")) {
|
|
60
|
+
if (character === "\u0003") {
|
|
61
|
+
finish(new Error("Login cancelled"));
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (character === "\r" || character === "\n") {
|
|
65
|
+
finish();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (character === "\u007f" || character === "\b") {
|
|
69
|
+
if (value) {
|
|
70
|
+
value = value.slice(0, -1);
|
|
71
|
+
process.stderr.write("\b \b");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else if (character >= " " && character <= "~") {
|
|
75
|
+
value += character;
|
|
76
|
+
process.stderr.write("*");
|
|
77
|
+
if (value.length > 8192) {
|
|
78
|
+
finish(new Error("API key is too large"));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
process.stderr.write("mSwarm API key: ");
|
|
85
|
+
process.stdin.setRawMode(true);
|
|
86
|
+
process.stdin.resume();
|
|
87
|
+
process.stdin.on("data", onData);
|
|
88
|
+
});
|
|
89
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Transform, type TransformCallback } from "node:stream";
|
|
2
|
+
import type { Interface } from "node:readline";
|
|
3
|
+
/** Bracketed paste is one editable input, never a sequence of submitted commands. */
|
|
4
|
+
export declare class TerminalInput extends Transform {
|
|
5
|
+
private readonly options;
|
|
6
|
+
private readonly decoder;
|
|
7
|
+
private pending;
|
|
8
|
+
private pasting;
|
|
9
|
+
private pasted;
|
|
10
|
+
private bytes;
|
|
11
|
+
private overflow;
|
|
12
|
+
constructor(options: {
|
|
13
|
+
onPaste: (text: string) => void;
|
|
14
|
+
onRejected: (reason: string) => void;
|
|
15
|
+
maxPasteBytes?: number;
|
|
16
|
+
});
|
|
17
|
+
private append;
|
|
18
|
+
private consume;
|
|
19
|
+
_transform(chunk: Buffer, _encoding: BufferEncoding, callback: TransformCallback): void;
|
|
20
|
+
_flush(callback: TransformCallback): void;
|
|
21
|
+
}
|
|
22
|
+
/** readline exposes the current editable line and cursor; refresh preserves multiline content. */
|
|
23
|
+
export declare const insertTerminalPaste: (readline: Interface, text: string) => void;
|
|
24
|
+
//# sourceMappingURL=TerminalInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TerminalInput.d.ts","sourceRoot":"","sources":["../../src/cli/TerminalInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAS/C,qFAAqF;AACrF,qBAAa,aAAc,SAAQ,SAAS;IAO9B,OAAO,CAAC,QAAQ,CAAC,OAAO;IANpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IACrD,OAAO,CAAC,OAAO,CAAM;IACrB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,QAAQ,CAAS;gBACI,OAAO,EAAE;QAAE,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;QAAC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE;IACvI,OAAO,CAAC,MAAM;IAKd,OAAO,CAAC,OAAO;IAmBN,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IAGvF,MAAM,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI;CAOnD;AAED,kGAAkG;AAClG,eAAO,MAAM,mBAAmB,GAAI,UAAU,SAAS,EAAE,MAAM,MAAM,KAAG,IAOvE,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Transform } from "node:stream";
|
|
2
|
+
import { StringDecoder } from "node:string_decoder";
|
|
3
|
+
const START = "\u001b[200~";
|
|
4
|
+
const END = "\u001b[201~";
|
|
5
|
+
const suffixLength = (text, token) => {
|
|
6
|
+
for (let size = Math.min(text.length, token.length - 1); size > 0; size--)
|
|
7
|
+
if (text.endsWith(token.slice(0, size)))
|
|
8
|
+
return size;
|
|
9
|
+
return 0;
|
|
10
|
+
};
|
|
11
|
+
/** Bracketed paste is one editable input, never a sequence of submitted commands. */
|
|
12
|
+
export class TerminalInput extends Transform {
|
|
13
|
+
constructor(options) {
|
|
14
|
+
super();
|
|
15
|
+
this.options = options;
|
|
16
|
+
this.decoder = new StringDecoder("utf8");
|
|
17
|
+
this.pending = "";
|
|
18
|
+
this.pasting = false;
|
|
19
|
+
this.pasted = "";
|
|
20
|
+
this.bytes = 0;
|
|
21
|
+
this.overflow = false;
|
|
22
|
+
}
|
|
23
|
+
append(text) {
|
|
24
|
+
this.bytes += Buffer.byteLength(text);
|
|
25
|
+
if (this.bytes > (this.options.maxPasteBytes ?? 262144)) {
|
|
26
|
+
this.overflow = true;
|
|
27
|
+
this.pasted = "";
|
|
28
|
+
}
|
|
29
|
+
else if (!this.overflow)
|
|
30
|
+
this.pasted += text;
|
|
31
|
+
}
|
|
32
|
+
consume(text) {
|
|
33
|
+
this.pending += text;
|
|
34
|
+
while (this.pending) {
|
|
35
|
+
const token = this.pasting ? END : START;
|
|
36
|
+
const index = this.pending.indexOf(token);
|
|
37
|
+
if (index < 0) {
|
|
38
|
+
const keep = suffixLength(this.pending, token);
|
|
39
|
+
const ready = this.pending.slice(0, this.pending.length - keep);
|
|
40
|
+
if (this.pasting)
|
|
41
|
+
this.append(ready);
|
|
42
|
+
else if (ready)
|
|
43
|
+
this.push(ready);
|
|
44
|
+
this.pending = keep ? this.pending.slice(-keep) : "";
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const ready = this.pending.slice(0, index);
|
|
48
|
+
this.pending = this.pending.slice(index + token.length);
|
|
49
|
+
if (this.pasting) {
|
|
50
|
+
this.append(ready);
|
|
51
|
+
if (this.overflow)
|
|
52
|
+
this.options.onRejected("Paste exceeds the 256 KiB input limit");
|
|
53
|
+
else
|
|
54
|
+
this.options.onPaste(this.pasted.replace(/\r\n?/g, "\n").replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]/g, ""));
|
|
55
|
+
this.pasting = false;
|
|
56
|
+
this.pasted = "";
|
|
57
|
+
this.bytes = 0;
|
|
58
|
+
this.overflow = false;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
if (ready)
|
|
62
|
+
this.push(ready);
|
|
63
|
+
this.pasting = true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
_transform(chunk, _encoding, callback) {
|
|
68
|
+
try {
|
|
69
|
+
this.consume(this.decoder.write(chunk));
|
|
70
|
+
callback();
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
callback(error);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
_flush(callback) {
|
|
77
|
+
try {
|
|
78
|
+
this.consume(this.decoder.end());
|
|
79
|
+
if (this.pasting)
|
|
80
|
+
this.options.onRejected("Incomplete paste discarded");
|
|
81
|
+
else if (this.pending)
|
|
82
|
+
this.push(this.pending);
|
|
83
|
+
callback();
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
callback(error);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/** readline exposes the current editable line and cursor; refresh preserves multiline content. */
|
|
91
|
+
export const insertTerminalPaste = (readline, text) => {
|
|
92
|
+
// Node documents coordinated line/cursor updates; @types/node marks both readonly.
|
|
93
|
+
// Keep this compatibility boundary together: https://nodejs.org/api/readline.html#rlline
|
|
94
|
+
const editable = readline;
|
|
95
|
+
editable.line = editable.line.slice(0, editable.cursor) + text + editable.line.slice(editable.cursor);
|
|
96
|
+
editable.cursor += text.length;
|
|
97
|
+
readline.prompt(true);
|
|
98
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const terminalText: (value: string) => string;
|
|
2
|
+
/** Buffers incomplete ANSI/OSC sequences split across streamed chunks. */
|
|
3
|
+
export declare class TerminalTextStream {
|
|
4
|
+
private pending;
|
|
5
|
+
private secrets;
|
|
6
|
+
write(chunk: string): string;
|
|
7
|
+
finish(): string;
|
|
8
|
+
reset(): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=TerminalText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TerminalText.d.ts","sourceRoot":"","sources":["../../src/cli/TerminalText.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,MAA0D,CAAC;AAExG,0EAA0E;AAC1E,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,OAAO,CAAM;IACrB,OAAO,CAAC,OAAO,CAAiC;IAChD,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAwB5B,MAAM,IAAI,MAAM;IAChB,KAAK,IAAI,IAAI;CACd"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { stripVTControlCharacters } from "node:util";
|
|
2
|
+
import { redactSecretValues } from "../gateway/GatewayTracer.js";
|
|
3
|
+
import { StreamingSecretRedactor } from "../runtime/SecretRedaction.js";
|
|
4
|
+
/** Model/tool text is data, never terminal control sequences or clipboard commands. */
|
|
5
|
+
const stripTerminalControls = (value) => stripVTControlCharacters(value)
|
|
6
|
+
.replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/g, "")
|
|
7
|
+
.replace(/[\u202a-\u202e\u2066-\u2069]/g, "");
|
|
8
|
+
export const terminalText = (value) => redactSecretValues(stripTerminalControls(value));
|
|
9
|
+
/** Buffers incomplete ANSI/OSC sequences split across streamed chunks. */
|
|
10
|
+
export class TerminalTextStream {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.pending = "";
|
|
13
|
+
this.secrets = new StreamingSecretRedactor();
|
|
14
|
+
}
|
|
15
|
+
write(chunk) {
|
|
16
|
+
this.pending += chunk;
|
|
17
|
+
let cutoff = this.pending.length;
|
|
18
|
+
for (let index = 0; index < this.pending.length; index++) {
|
|
19
|
+
if (this.pending[index] !== "\u001b")
|
|
20
|
+
continue;
|
|
21
|
+
const next = this.pending[index + 1];
|
|
22
|
+
if (next === undefined) {
|
|
23
|
+
cutoff = index;
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
if (["]", "P", "_", "^", "X"].includes(next)) {
|
|
27
|
+
const rest = this.pending.slice(index + 2);
|
|
28
|
+
const end = rest.search(/\u0007|\u001b\\/);
|
|
29
|
+
if (end < 0) {
|
|
30
|
+
cutoff = index;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
index += end + 2;
|
|
34
|
+
}
|
|
35
|
+
else if (next === "[") {
|
|
36
|
+
const rest = this.pending.slice(index + 2);
|
|
37
|
+
const end = rest.search(/[\x40-\x7e]/);
|
|
38
|
+
if (end < 0) {
|
|
39
|
+
cutoff = index;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
index += end + 2;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const ready = this.pending.slice(0, cutoff);
|
|
46
|
+
this.pending = this.pending.slice(cutoff);
|
|
47
|
+
if (this.pending.length > 8192)
|
|
48
|
+
this.pending = "";
|
|
49
|
+
return this.secrets.write(stripTerminalControls(ready));
|
|
50
|
+
}
|
|
51
|
+
finish() { this.pending = ""; return this.secrets.finish(); }
|
|
52
|
+
reset() { this.pending = ""; this.secrets = new StreamingSecretRedactor(); }
|
|
53
|
+
}
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AA2FA,eAAO,MAAM,MAAM,GAAU,OAAM,MAAM,EAA0B,KAAG,OAAO,CAAC,IAAI,CAyEjF,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -11,7 +11,12 @@ import { FeedbackCommand } from "./cli/FeedbackCommand.js";
|
|
|
11
11
|
import { EvalCommand } from "./cli/EvalCommand.js";
|
|
12
12
|
import { DatasetCommand } from "./cli/DatasetCommand.js";
|
|
13
13
|
import { ImprovementCommand } from "./cli/ImprovementCommand.js";
|
|
14
|
-
|
|
14
|
+
import { TerminalCommand, terminalDoctor } from "./cli/TerminalCommand.js";
|
|
15
|
+
const HELP_TEXT = "Usage: codali [chat] [prompt] [--effort low|medium|high|max] [--permissions plan|ask|workspace]\n" +
|
|
16
|
+
" or: codali exec <prompt> [--json] [--config <path>]\n" +
|
|
17
|
+
" or: codali setup | login [--stdin] | logout | auth status\n" +
|
|
18
|
+
" or: codali sessions | resume <id> | inspect <id>\n" +
|
|
19
|
+
" or: codali ask \"<question>\" [--trace] [--json] [--workspace-root <path>]\n" +
|
|
15
20
|
" or: codali tools <list|describe|call|health> [options]\n" +
|
|
16
21
|
" or: codali auth <microsoft>\n" +
|
|
17
22
|
" or: codali serve [--port <n>] [--api-key <key>]\n" +
|
|
@@ -79,6 +84,10 @@ const printDoctor = () => {
|
|
|
79
84
|
console.log(lines.join("\n"));
|
|
80
85
|
};
|
|
81
86
|
export const runCli = async (argv = process.argv.slice(2)) => {
|
|
87
|
+
if (argv.length === 0 && process.stdin.isTTY) {
|
|
88
|
+
await TerminalCommand.run(["chat"]);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
82
91
|
if (argv.includes("--help") || argv.includes("-h") || argv.length === 0) {
|
|
83
92
|
// eslint-disable-next-line no-console
|
|
84
93
|
console.log(HELP_TEXT);
|
|
@@ -86,13 +95,25 @@ export const runCli = async (argv = process.argv.slice(2)) => {
|
|
|
86
95
|
}
|
|
87
96
|
const [command, ...rest] = argv;
|
|
88
97
|
if (command === "--version" || command === "-v" || command === "version") {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
console.log("dev");
|
|
98
|
+
const pkg = JSON.parse(fs.readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
99
|
+
console.log(pkg.version);
|
|
92
100
|
return;
|
|
93
101
|
}
|
|
94
102
|
if (command === "doctor" || command === "--doctor") {
|
|
103
|
+
if (rest.includes("--json")) {
|
|
104
|
+
await TerminalCommand.run(["doctor", ...rest]);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
95
107
|
printDoctor();
|
|
108
|
+
console.log(JSON.stringify(await terminalDoctor(rest.includes("--config") ? rest[rest.indexOf("--config") + 1] : undefined), null, 2));
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (["chat", "exec", "setup", "login", "logout", "sessions", "resume", "status", "inspect", "checkpoint", "amend"].includes(command)) {
|
|
112
|
+
await TerminalCommand.run(argv);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (["--effort", "--permissions", "--config", "--workspace-root", "--plain", "--json", "--stdin"].includes(command)) {
|
|
116
|
+
await TerminalCommand.run(["chat", ...argv]);
|
|
96
117
|
return;
|
|
97
118
|
}
|
|
98
119
|
if (command === "ask") {
|
|
@@ -100,6 +121,10 @@ export const runCli = async (argv = process.argv.slice(2)) => {
|
|
|
100
121
|
return;
|
|
101
122
|
}
|
|
102
123
|
if (command === "auth") {
|
|
124
|
+
if (rest[0] === "status") {
|
|
125
|
+
await TerminalCommand.run(["auth-status", ...rest.slice(1)]);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
103
128
|
await AuthCommand.run(rest);
|
|
104
129
|
return;
|
|
105
130
|
}
|
|
@@ -131,6 +156,10 @@ export const runCli = async (argv = process.argv.slice(2)) => {
|
|
|
131
156
|
await FeedbackCommand.run(rest);
|
|
132
157
|
return;
|
|
133
158
|
}
|
|
159
|
+
if (!command.startsWith("-")) {
|
|
160
|
+
await TerminalCommand.run(["chat", ...argv]);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
134
163
|
throw new Error(HELP_TEXT);
|
|
135
164
|
};
|
|
136
165
|
const isMain = (() => {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ConfiguredModelScope, type ScopedModelEvent, type ScopedModelUsage } from "../providers/ConfiguredModelScope.js";
|
|
2
|
+
import type { EffortLevel, ResolvedOrchestrationConfig } from "../config/OrchestrationConfig.js";
|
|
3
|
+
import type { ModelCallerContext } from "../providers/ConfiguredProvider.js";
|
|
4
|
+
import type { DocdexClient } from "../docdex/DocdexClient.js";
|
|
5
|
+
import { type ArchitectPlannerOptions } from "./ArchitectPlanner.js";
|
|
6
|
+
import { type BuilderRunnerOptions } from "./BuilderRunner.js";
|
|
7
|
+
import { type ContextAssemblerOptions } from "./ContextAssembler.js";
|
|
8
|
+
import { type PatchInterpreterOptions } from "./PatchInterpreter.js";
|
|
9
|
+
import { type SmartPipelineOptions, type SmartPipelineResult } from "./SmartPipeline.js";
|
|
10
|
+
export interface ConfiguredPipelineHost {
|
|
11
|
+
/** Host supplies a managed/configured retrieval client and owns its tool permissions. */
|
|
12
|
+
docdex: DocdexClient;
|
|
13
|
+
context?: Omit<ContextAssemblerOptions, "queryProvider">;
|
|
14
|
+
architect?: ArchitectPlannerOptions;
|
|
15
|
+
builder: Omit<BuilderRunnerOptions, "provider" | "interpreter">;
|
|
16
|
+
interpreter?: Omit<PatchInterpreterOptions, "provider">;
|
|
17
|
+
/** ValidationRunner and other host operations must use scope.signal. */
|
|
18
|
+
pipeline: Omit<SmartPipelineOptions, "contextAssembler" | "architectPlanner" | "builderRunner" | "onPhaseProviderFailure">;
|
|
19
|
+
}
|
|
20
|
+
export interface ConfiguredPipelineOptions {
|
|
21
|
+
orchestration: ResolvedOrchestrationConfig;
|
|
22
|
+
effort?: EffortLevel;
|
|
23
|
+
signal?: AbortSignal;
|
|
24
|
+
caller?: ModelCallerContext;
|
|
25
|
+
onModelEvent?: (event: ScopedModelEvent) => Promise<void> | void;
|
|
26
|
+
configure: (scope: ConfiguredModelScope) => ConfiguredPipelineHost | Promise<ConfiguredPipelineHost>;
|
|
27
|
+
}
|
|
28
|
+
/** Adapter for the existing cognitive pipeline; no second execution loop or undeclared fallback. */
|
|
29
|
+
export declare const runConfiguredPipeline: (task: string, options: ConfiguredPipelineOptions) => Promise<{
|
|
30
|
+
result: SmartPipelineResult;
|
|
31
|
+
usage: ScopedModelUsage;
|
|
32
|
+
toolCalls: number;
|
|
33
|
+
}>;
|
|
34
|
+
//# sourceMappingURL=ConfiguredPipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfiguredPipeline.d.ts","sourceRoot":"","sources":["../../src/cognitive/ConfiguredPipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC1H,OAAO,KAAK,EAAE,WAAW,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AACjG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAoB,KAAK,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAoB,KAAK,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAoB,KAAK,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAiB,KAAK,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAExG,MAAM,WAAW,sBAAsB;IACrC,yFAAyF;IACzF,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,CAAC,EAAE,IAAI,CAAC,uBAAuB,EAAE,eAAe,CAAC,CAAC;IACzD,SAAS,CAAC,EAAE,uBAAuB,CAAC;IACpC,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,UAAU,GAAG,aAAa,CAAC,CAAC;IAChE,WAAW,CAAC,EAAE,IAAI,CAAC,uBAAuB,EAAE,UAAU,CAAC,CAAC;IACxD,wEAAwE;IACxE,QAAQ,EAAE,IAAI,CAAC,oBAAoB,EAAE,kBAAkB,GAAG,kBAAkB,GAAG,eAAe,GAAG,wBAAwB,CAAC,CAAC;CAC5H;AACD,MAAM,WAAW,yBAAyB;IACxC,aAAa,EAAE,2BAA2B,CAAC;IAC3C,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACjE,SAAS,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACtG;AAED,oGAAoG;AACpG,eAAO,MAAM,qBAAqB,GAAU,MAAM,MAAM,EAAE,SAAS,yBAAyB,KAAG,OAAO,CAAC;IAAE,MAAM,EAAE,mBAAmB,CAAC;IAAC,KAAK,EAAE,gBAAgB,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAgCjL,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ConfiguredModelScope } from "../providers/ConfiguredModelScope.js";
|
|
2
|
+
import { ArchitectPlanner } from "./ArchitectPlanner.js";
|
|
3
|
+
import { BuilderRunner } from "./BuilderRunner.js";
|
|
4
|
+
import { ContextAssembler } from "./ContextAssembler.js";
|
|
5
|
+
import { PatchInterpreter } from "./PatchInterpreter.js";
|
|
6
|
+
import { SmartPipeline } from "./SmartPipeline.js";
|
|
7
|
+
/** Adapter for the existing cognitive pipeline; no second execution loop or undeclared fallback. */
|
|
8
|
+
export const runConfiguredPipeline = async (task, options) => {
|
|
9
|
+
const scope = new ConfiguredModelScope(options.orchestration, { effort: options.effort, signal: options.signal, caller: options.caller, onEvent: options.onModelEvent });
|
|
10
|
+
let toolCalls = 0;
|
|
11
|
+
try {
|
|
12
|
+
const host = await options.configure(scope);
|
|
13
|
+
const budget = scope.budget();
|
|
14
|
+
for (const [record, forbidden] of [[host.context, ["queryProvider"]], [host.builder, ["provider", "interpreter"]], [host.interpreter, ["provider"]],
|
|
15
|
+
[host.pipeline, ["contextAssembler", "architectPlanner", "builderRunner", "onPhaseProviderFailure"]]]) {
|
|
16
|
+
for (const key of forbidden)
|
|
17
|
+
if (record && key in record)
|
|
18
|
+
throw new Error(`Configured pipeline cannot accept a legacy ${key} override`);
|
|
19
|
+
}
|
|
20
|
+
scope.signal.throwIfAborted();
|
|
21
|
+
const beforeTool = host.builder.context.beforeTool;
|
|
22
|
+
const afterTool = host.builder.context.afterTool;
|
|
23
|
+
const context = { ...host.builder.context, signal: scope.signal,
|
|
24
|
+
beforeTool: async (...args) => {
|
|
25
|
+
scope.signal.throwIfAborted();
|
|
26
|
+
if (toolCalls >= budget.maxToolCalls)
|
|
27
|
+
throw new Error("Shared pipeline tool budget exhausted");
|
|
28
|
+
toolCalls++;
|
|
29
|
+
await beforeTool?.(...args);
|
|
30
|
+
scope.signal.throwIfAborted();
|
|
31
|
+
},
|
|
32
|
+
afterTool: async (...args) => { await afterTool?.(...args); scope.signal.throwIfAborted(); },
|
|
33
|
+
};
|
|
34
|
+
const pipeline = new SmartPipeline({ ...host.pipeline,
|
|
35
|
+
contextAssembler: new ContextAssembler(host.docdex, { ...host.context, queryProvider: scope.provider("router") }),
|
|
36
|
+
architectPlanner: new ArchitectPlanner(scope.provider("architect"), host.architect),
|
|
37
|
+
builderRunner: new BuilderRunner({ ...host.builder, context, provider: scope.provider("worker"),
|
|
38
|
+
maxTokens: Math.min(host.builder.maxTokens ?? budget.maxOutputTokens, budget.maxOutputTokens),
|
|
39
|
+
maxSteps: Math.min(host.builder.maxSteps, budget.maxSteps), maxToolCalls: Math.min(host.builder.maxToolCalls, budget.maxToolCalls),
|
|
40
|
+
timeoutMs: Math.min(host.builder.timeoutMs ?? budget.timeoutMs, budget.timeoutMs),
|
|
41
|
+
interpreter: host.interpreter ? new PatchInterpreter({ ...host.interpreter, provider: scope.provider("repair") }) : undefined }),
|
|
42
|
+
});
|
|
43
|
+
const result = await pipeline.run(task);
|
|
44
|
+
scope.signal.throwIfAborted();
|
|
45
|
+
return { result, usage: scope.snapshot(), toolCalls };
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
scope.close();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { type ToolContext } from "../tools/ToolTypes.js";
|
|
1
2
|
import type { DocdexClient } from "../docdex/DocdexClient.js";
|
|
2
3
|
import type { VerificationCheckResult, VerificationCheckType, VerificationOutcome, VerificationPolicySummary, VerificationReasonCode, VerificationReport } from "./Types.js";
|
|
3
4
|
export interface ValidationRunnerOptions {
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
shellExecutor?: ToolContext["shellExecutor"];
|
|
7
|
+
onOutput?: ToolContext["onOutput"];
|
|
4
8
|
allowShell: boolean;
|
|
5
9
|
shellAllowlist: string[];
|
|
6
10
|
workspaceRoot: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationRunner.d.ts","sourceRoot":"","sources":["../../src/cognitive/ValidationRunner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ValidationRunner.d.ts","sourceRoot":"","sources":["../../src/cognitive/ValidationRunner.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAG7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EACV,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EACzB,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,aAAa,CAAC,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC;IAC7C,QAAQ,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IACnC,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,4BAA4B,CAAC,EAAE,OAAO,CAAC;CACxC;AAED,MAAM,WAAW,oBAAoB;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,wBAAwB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC3E;AAED,KAAK,gBAAgB,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AAErD,MAAM,MAAM,yBAAyB,GACjC,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,GACN,SAAS,CAAC;AAEd,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,qBAAqB,CAAC;IAClC,QAAQ,EAAE,yBAAyB,CAAC;IACpC,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,UAAU,GAAG,SAAS,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,wBAAwB;IACvC,cAAc,EAAE,CAAC,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC;IACzC,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,MAAM,EAAE,yBAAyB,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,EAAE,mBAAmB,CAAC;IAC7B,YAAY,EAAE,sBAAsB,EAAE,CAAC;IACvC,MAAM,EAAE,uBAAuB,EAAE,CAAC;IAClC,MAAM,EAAE,yBAAyB,CAAC;IAClC,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,MAAM,EAAE,gBAAgB,CAAC;IACzB,MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAuQD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAA0B;gBAE7B,OAAO,EAAE,uBAAuB;IAItC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,UAAU,GAAE,oBAAyB,GAAG,OAAO,CAAC,gBAAgB,CAAC;CA4O7F"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { runProcess } from "../tools/shell/AsyncProcess.js";
|
|
2
|
+
import { ToolExecutionError } from "../tools/ToolTypes.js";
|
|
2
3
|
import { existsSync } from "node:fs";
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
const DEFAULT_SHELL_TIMEOUT_MS = 120000;
|
|
@@ -266,6 +267,7 @@ export class ValidationRunner {
|
|
|
266
267
|
this.options = options;
|
|
267
268
|
}
|
|
268
269
|
async run(steps, runOptions = {}) {
|
|
270
|
+
this.options.signal?.throwIfAborted();
|
|
269
271
|
const errors = [];
|
|
270
272
|
const touchedFiles = (runOptions.touchedFiles ?? []).map((entry) => entry.trim()).filter(Boolean);
|
|
271
273
|
const languageSignals = detectLanguageSignals(touchedFiles);
|
|
@@ -330,6 +332,7 @@ export class ValidationRunner {
|
|
|
330
332
|
}
|
|
331
333
|
};
|
|
332
334
|
for (const check of checks) {
|
|
335
|
+
this.options.signal?.throwIfAborted();
|
|
333
336
|
const startedAt = Date.now();
|
|
334
337
|
const step = check.step;
|
|
335
338
|
if (!step) {
|
|
@@ -405,54 +408,28 @@ export class ValidationRunner {
|
|
|
405
408
|
});
|
|
406
409
|
continue;
|
|
407
410
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
});
|
|
413
|
-
if (result.error) {
|
|
414
|
-
const errorMessage = result.error.message;
|
|
415
|
-
const timeoutHit = result.error.name === "TimeoutError"
|
|
416
|
-
|| result.error.code === "ETIMEDOUT"
|
|
417
|
-
|| result.error.message.toLowerCase().includes("timed out");
|
|
418
|
-
pushResult({
|
|
419
|
-
...check,
|
|
420
|
-
status: "failed",
|
|
421
|
-
reason_code: timeoutHit
|
|
422
|
-
? "verification_command_timeout"
|
|
423
|
-
: "verification_tool_unavailable",
|
|
424
|
-
message: errorMessage,
|
|
425
|
-
duration_ms: Date.now() - startedAt,
|
|
411
|
+
try {
|
|
412
|
+
const result = await (this.options.shellExecutor ?? runProcess)(command, args, {
|
|
413
|
+
workspaceRoot: this.options.workspaceRoot, signal: this.options.signal,
|
|
414
|
+
shellTimeoutMs: this.options.shellTimeoutMs ?? DEFAULT_SHELL_TIMEOUT_MS, onOutput: this.options.onOutput,
|
|
426
415
|
});
|
|
427
|
-
|
|
416
|
+
this.options.signal?.throwIfAborted();
|
|
417
|
+
const details = result.data;
|
|
418
|
+
pushResult({ ...check, status: "passed", evidence: compactText(details?.stdout ?? result.output) ?? `command succeeded: ${command}`, duration_ms: Date.now() - startedAt });
|
|
428
419
|
}
|
|
429
|
-
|
|
420
|
+
catch (error) {
|
|
421
|
+
this.options.signal?.throwIfAborted();
|
|
422
|
+
const code = error instanceof ToolExecutionError ? error.code : undefined;
|
|
423
|
+
const details = error instanceof ToolExecutionError ? error.details : undefined;
|
|
430
424
|
pushResult({
|
|
431
425
|
...check,
|
|
432
426
|
status: "failed",
|
|
433
|
-
reason_code: "verification_command_timeout",
|
|
434
|
-
message:
|
|
427
|
+
reason_code: code === "tool_timeout" ? "verification_command_timeout" : code === "tool_execution_failed" ? "verification_command_failed" : "verification_tool_unavailable",
|
|
428
|
+
message: error instanceof Error ? error.message : String(error),
|
|
429
|
+
evidence: compactText(details?.stdout),
|
|
435
430
|
duration_ms: Date.now() - startedAt,
|
|
436
431
|
});
|
|
437
|
-
continue;
|
|
438
|
-
}
|
|
439
|
-
if (result.status !== 0) {
|
|
440
|
-
pushResult({
|
|
441
|
-
...check,
|
|
442
|
-
status: "failed",
|
|
443
|
-
reason_code: "verification_command_failed",
|
|
444
|
-
message: result.stderr?.toString().trim() || `command failed: ${command}`,
|
|
445
|
-
evidence: compactText(result.stdout?.toString()),
|
|
446
|
-
duration_ms: Date.now() - startedAt,
|
|
447
|
-
});
|
|
448
|
-
continue;
|
|
449
432
|
}
|
|
450
|
-
pushResult({
|
|
451
|
-
...check,
|
|
452
|
-
status: "passed",
|
|
453
|
-
evidence: compactText(result.stdout?.toString()) ?? `command succeeded: ${command}`,
|
|
454
|
-
duration_ms: Date.now() - startedAt,
|
|
455
|
-
});
|
|
456
433
|
}
|
|
457
434
|
const totals = {
|
|
458
435
|
configured: checks.length,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface ApprovedNodeModel {
|
|
2
|
+
model: string;
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
modelDigest?: string;
|
|
5
|
+
contextWindow?: number;
|
|
6
|
+
maxOutputTokens?: number;
|
|
7
|
+
modelsPath?: string;
|
|
8
|
+
supportsTools?: boolean;
|
|
9
|
+
supportsStreaming?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** The node may serve only the model already admitted by its registry/job boundary. */
|
|
12
|
+
export declare function loadNodeOrchestrationConfig(file: string, approved: ApprovedNodeModel, nativeReasoning?: {
|
|
13
|
+
reasoning_effort?: string;
|
|
14
|
+
reasoning_budget_tokens?: number;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
sourceHash: string;
|
|
17
|
+
config: import("./OrchestrationConfig.js").OrchestrationConfig;
|
|
18
|
+
hash: string;
|
|
19
|
+
source: string;
|
|
20
|
+
}>;
|
|
21
|
+
//# sourceMappingURL=NodeOrchestration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeOrchestration.d.ts","sourceRoot":"","sources":["../../src/config/NodeOrchestration.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,uFAAuF;AACvF,wBAAsB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,EAAE,eAAe,GAAE;IAAE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,uBAAuB,CAAC,EAAE,MAAM,CAAA;CAAO;;;;;GAyCjL"}
|