fix: resolve agent dir in onboarding
This commit is contained in:
@@ -1,11 +1,9 @@
|
|||||||
import fs from "node:fs/promises";
|
import fs from "node:fs/promises";
|
||||||
import os from "node:os";
|
import os from "node:os";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
|
|
||||||
import { describe, expect, it, vi } from "vitest";
|
|
||||||
|
|
||||||
import type { Api, Model } from "@mariozechner/pi-ai";
|
import type { Api, Model } from "@mariozechner/pi-ai";
|
||||||
import { discoverAuthStorage } from "@mariozechner/pi-coding-agent";
|
import { discoverAuthStorage } from "@mariozechner/pi-coding-agent";
|
||||||
|
import { describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
const oauthFixture = {
|
const oauthFixture = {
|
||||||
access: "access-token",
|
access: "access-token",
|
||||||
@@ -17,9 +15,7 @@ const oauthFixture = {
|
|||||||
describe("getApiKeyForModel", () => {
|
describe("getApiKeyForModel", () => {
|
||||||
it("migrates legacy oauth.json into auth.json", async () => {
|
it("migrates legacy oauth.json into auth.json", async () => {
|
||||||
const previousStateDir = process.env.CLAWDBOT_STATE_DIR;
|
const previousStateDir = process.env.CLAWDBOT_STATE_DIR;
|
||||||
const tempDir = await fs.mkdtemp(
|
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-oauth-"));
|
||||||
path.join(os.tmpdir(), "clawdbot-oauth-"),
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
process.env.CLAWDBOT_STATE_DIR = tempDir;
|
process.env.CLAWDBOT_STATE_DIR = tempDir;
|
||||||
|
|||||||
@@ -98,9 +98,15 @@ export function ensureOAuthStorage(): void {
|
|||||||
importLegacyOAuthIfNeeded(oauthPath);
|
importLegacyOAuthIfNeeded(oauthPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidOAuthCredential(entry: OAuthCredentials | undefined): entry is OAuthCredentials {
|
function isValidOAuthCredential(
|
||||||
|
entry: OAuthCredentials | undefined,
|
||||||
|
): entry is OAuthCredentials {
|
||||||
if (!entry) return false;
|
if (!entry) return false;
|
||||||
return Boolean(entry.access?.trim() && entry.refresh?.trim() && Number.isFinite(entry.expires));
|
return Boolean(
|
||||||
|
entry.access?.trim() &&
|
||||||
|
entry.refresh?.trim() &&
|
||||||
|
Number.isFinite(entry.expires),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function migrateOAuthStorageToAuthStorage(
|
function migrateOAuthStorageToAuthStorage(
|
||||||
|
|||||||
@@ -798,8 +798,11 @@ describe("trigger handling", () => {
|
|||||||
workspaceDir: cfg.agent.workspace,
|
workspaceDir: cfg.agent.workspace,
|
||||||
});
|
});
|
||||||
expect(sandbox).not.toBeNull();
|
expect(sandbox).not.toBeNull();
|
||||||
|
if (!sandbox) {
|
||||||
|
throw new Error("Expected sandbox to be set");
|
||||||
|
}
|
||||||
const stagedFullPath = join(
|
const stagedFullPath = join(
|
||||||
sandbox!.workspaceDir,
|
sandbox.workspaceDir,
|
||||||
"media",
|
"media",
|
||||||
"inbound",
|
"inbound",
|
||||||
basename(mediaPath),
|
basename(mediaPath),
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ import {
|
|||||||
} from "../agents/usage.js";
|
} from "../agents/usage.js";
|
||||||
import type { ClawdbotConfig } from "../config/config.js";
|
import type { ClawdbotConfig } from "../config/config.js";
|
||||||
import {
|
import {
|
||||||
resolveSessionTranscriptPath,
|
|
||||||
resolveMainSessionKey,
|
resolveMainSessionKey,
|
||||||
|
resolveSessionTranscriptPath,
|
||||||
type SessionEntry,
|
type SessionEntry,
|
||||||
type SessionScope,
|
type SessionScope,
|
||||||
} from "../config/sessions.js";
|
} from "../config/sessions.js";
|
||||||
@@ -167,7 +167,9 @@ export function buildStatusMessage(args: StatusArgs): string {
|
|||||||
args.resolvedVerbose ?? args.agent?.verboseDefault ?? "off";
|
args.resolvedVerbose ?? args.agent?.verboseDefault ?? "off";
|
||||||
const elevatedLevel =
|
const elevatedLevel =
|
||||||
args.resolvedElevated ??
|
args.resolvedElevated ??
|
||||||
args.sessionEntry?.elevatedLevel ?? args.agent?.elevatedDefault ?? "on";
|
args.sessionEntry?.elevatedLevel ??
|
||||||
|
args.agent?.elevatedDefault ??
|
||||||
|
"on";
|
||||||
|
|
||||||
const runtime = (() => {
|
const runtime = (() => {
|
||||||
const sandboxMode = args.agent?.sandbox?.mode ?? "off";
|
const sandboxMode = args.agent?.sandbox?.mode ?? "off";
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import path from "node:path";
|
|||||||
|
|
||||||
import { loginAnthropic, type OAuthCredentials } from "@mariozechner/pi-ai";
|
import { loginAnthropic, type OAuthCredentials } from "@mariozechner/pi-ai";
|
||||||
import { discoverAuthStorage } from "@mariozechner/pi-coding-agent";
|
import { discoverAuthStorage } from "@mariozechner/pi-coding-agent";
|
||||||
|
import { resolveClawdbotAgentDir } from "../agents/agent-paths.js";
|
||||||
import {
|
import {
|
||||||
isRemoteEnvironment,
|
isRemoteEnvironment,
|
||||||
loginAntigravityVpsAware,
|
loginAntigravityVpsAware,
|
||||||
|
|||||||
Reference in New Issue
Block a user