Add debug directory to gitignore and support unauthenticated assistant loading
This commit is contained in:
parent
cf1277fcdd
commit
07ee41c8eb
3 changed files with 44 additions and 8 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -8,4 +8,6 @@ chat.log
|
|||
*notes.md
|
||||
|
||||
# Local config files (users should not commit their personal configs)
|
||||
config.yaml
|
||||
config.yaml
|
||||
|
||||
.continue-debug/
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
"format": "prettier --write .",
|
||||
"format:check": "prettier --check .",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"watch:logs": "tail -f ~/.continue/logs/cn.log",
|
||||
"watch:logs": "touch ~/.continue/logs/cn.log && tail -f ~/.continue/logs/cn.log",
|
||||
"prepare": "npm run build",
|
||||
"semantic-release": "semantic-release",
|
||||
"semantic-release:dry-run": "semantic-release --dry-run"
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import * as path from "path";
|
|||
|
||||
import {
|
||||
AssistantUnrolled,
|
||||
PackageIdentifier,
|
||||
RegistryClient,
|
||||
unrollAssistant,
|
||||
} from "@continuedev/config-yaml";
|
||||
|
|
@ -276,20 +277,23 @@ async function loadDefaultAgent(
|
|||
}
|
||||
|
||||
/**
|
||||
* Loads a local YAML configuration file
|
||||
* Common function to unroll an assistant with consistent configuration
|
||||
*/
|
||||
async function loadConfigYaml(
|
||||
filePath: string,
|
||||
async function unrollAssistantWithConfig(
|
||||
packageIdentifier: PackageIdentifier,
|
||||
accessToken: string | null,
|
||||
organizationId: string | null,
|
||||
apiClient: DefaultApiInterface,
|
||||
): Promise<AssistantUnrolled> {
|
||||
const unrollResult = await unrollAssistant(
|
||||
{ filePath, uriType: "file" },
|
||||
packageIdentifier,
|
||||
new RegistryClient({
|
||||
accessToken: accessToken ?? undefined,
|
||||
apiBase: env.apiBase,
|
||||
rootPath: dirname(filePath),
|
||||
rootPath:
|
||||
packageIdentifier.uriType === "file"
|
||||
? dirname(packageIdentifier.filePath)
|
||||
: undefined,
|
||||
}),
|
||||
{
|
||||
currentUserSlug: "",
|
||||
|
|
@ -303,7 +307,7 @@ async function loadConfigYaml(
|
|||
|
||||
const errorDetails = unrollResult.errors;
|
||||
if (!unrollResult.config) {
|
||||
throw new Error(`Failed to load config file:\n${errorDetails}`);
|
||||
throw new Error(`Failed to load config:\n${errorDetails}`);
|
||||
} else if (errorDetails?.length) {
|
||||
const warnings =
|
||||
errorDetails?.length > 1
|
||||
|
|
@ -315,6 +319,23 @@ async function loadConfigYaml(
|
|||
return unrollResult.config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a local YAML configuration file
|
||||
*/
|
||||
async function loadConfigYaml(
|
||||
filePath: string,
|
||||
accessToken: string | null,
|
||||
organizationId: string | null,
|
||||
apiClient: DefaultApiInterface,
|
||||
): Promise<AssistantUnrolled> {
|
||||
return await unrollAssistantWithConfig(
|
||||
{ filePath, uriType: "file" },
|
||||
accessToken,
|
||||
organizationId,
|
||||
apiClient,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads an assistant by slug from the Continue platform
|
||||
*/
|
||||
|
|
@ -330,6 +351,19 @@ async function loadAssistantSlug(
|
|||
);
|
||||
}
|
||||
|
||||
// Unroll locally if not logged in
|
||||
if (!(apiClient as any).configuration.apiKey) {
|
||||
return await unrollAssistantWithConfig(
|
||||
{
|
||||
uriType: "slug",
|
||||
fullSlug: { ownerSlug, packageSlug, versionSlug: "latest" },
|
||||
},
|
||||
null,
|
||||
organizationId,
|
||||
apiClient,
|
||||
);
|
||||
}
|
||||
|
||||
const resp = await apiClient.getAssistant({
|
||||
ownerSlug,
|
||||
packageSlug,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue