Skip to content

Commit

Permalink
Merge pull request #39 from docker/cm/remove-credcheck
Browse files Browse the repository at this point in the history
Remove credential check & pat
  • Loading branch information
ColinMcNeil authored Sep 30, 2024
2 parents 306d049 + 888dd56 commit f9247c6
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 72 deletions.
5 changes: 1 addition & 4 deletions src/commands/runPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { showPromptPicker } from "../utils/promptPicker";
import { createOutputBuffer } from "../utils/promptFilename";
import { spawnPromptImage, writeKeyToVolume } from "../utils/promptRunner";
import { verifyHasOpenAIKey } from "./setOpenAIKey";
import { getCredential } from "../utils/credential";
import { setProjectDir } from "./setProjectDir";
import { postToBackendSocket } from "../utils/ddSocket";
import { ctx } from "../extension";
Expand Down Expand Up @@ -162,15 +161,13 @@ export const runPrompt: (secrets: vscode.SecretStorage, mode: PromptOption) => v

progress.report({ increment: 5, message: "Detecting docker desktop token" });

const { Username, Password } = await getCredential("docker");

try {
progress.report({ increment: 5, message: "Mounting secrets..." });
await writeKeyToVolume(apiKey!);
progress.report({ increment: 5, message: "Running..." });
const ranges: Record<string, vscode.Range> = {};
const getBaseFunctionRange = () => new vscode.Range(doc.lineCount, 0, doc.lineCount, 0);
await spawnPromptImage(promptOption.id, runningLocal ? inputWorkspace! : workspaceFolder!.uri.fsPath, Username, process.platform, Password, async (json) => {
await spawnPromptImage(promptOption.id, runningLocal ? inputWorkspace! : workspaceFolder!.uri.fsPath, 'vscode-user', process.platform, async (json) => {
if (json.method === 'functions') {
const functions = json.params;
for (const func of functions) {
Expand Down
31 changes: 0 additions & 31 deletions src/utils/credential.ts

This file was deleted.

33 changes: 0 additions & 33 deletions src/utils/ddSocket.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,10 @@
import os from 'os';
import path from 'path';
import http from 'http';
import { ctx } from '../extension';
import { ExtensionContext } from 'vscode';
const getDevhomePrefix = () => {
return process.env['DEVHOME'] ? path.basename(process.env['DEVHOME']) : '';
}

const getDevhome = (): string => {
return process.env['DEVHOME'] ?? os.homedir();
}
const getUserDataDirectory = (
/** This distinction is only currently meaningful on Windows */
type: 'local' | 'roaming' = 'local',
): string => {
const devhome = getDevhome();
if (os.platform() === 'win32') {
return path.join(
devhome,
'AppData',
type === 'local' ? 'Local' : 'Roaming',
'Docker',
);
}
if (os.platform() === 'linux') {
return path.join(devhome, '.docker', 'desktop');
}
if (os.platform() === 'darwin') {
return path.join(
devhome,
'Library',
'Containers',
'com.docker.docker',
'Data',
);
}

throw new Error('Unrecognized platform');
}

export function getBackendSocketByPlatform(): string {
switch (os.platform()) {
Expand Down
7 changes: 3 additions & 4 deletions src/utils/promptRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CancellationToken, commands, window, workspace } from "vscode";
import { setThreadId } from "../commands/setThreadId";
const output = window.createOutputChannel("Docker Labs: AI Tools");

export const getRunArgs = async (promptRef: string, projectDir: string, username: string, platform: string, pat: string, render = false) => {
export const getRunArgs = async (promptRef: string, projectDir: string, username: string, platform: string, render = false) => {
const isLocal = promptRef.startsWith('local://');
const isMarkdown = promptRef.toLowerCase().endsWith('.md');
const threadId = await commands.executeCommand<ReturnType<typeof setThreadId>>('docker.labs-ai-tools-vscode.thread-id', false)
Expand Down Expand Up @@ -35,7 +35,6 @@ export const getRunArgs = async (promptRef: string, projectDir: string, username
"--platform", platform,
...promptArgs,
'--jsonrpc',
...(pat ? ['--pat', pat] : []),
...(threadId ? ['--thread-id', threadId] : []),
];

Expand Down Expand Up @@ -119,8 +118,8 @@ const runAndStream = async (command: string, args: string[], callback: (json: an
});
};

export const spawnPromptImage = async (promptArg: string, projectDir: string, username: string, platform: string, pat: string, callback: (json: any) => Promise<void>, token: CancellationToken) => {
const args = await getRunArgs(promptArg!, projectDir!, username, platform, pat);
export const spawnPromptImage = async (promptArg: string, projectDir: string, username: string, platform: string, callback: (json: any) => Promise<void>, token: CancellationToken) => {
const args = await getRunArgs(promptArg!, projectDir!, username, platform);
callback({ method: 'message', params: { debug: `Running ${args.join(' ')}` } });
return runAndStream("docker", args, callback, token);
};
Expand Down

0 comments on commit f9247c6

Please sign in to comment.