chore(pi): organize mode implementations (#6362)

Co-authored-by: Bill Leoutsakos <billleoutsakos@Bills-MacBook-Pro.local>
This commit is contained in:
Bill Leoutsakos
2026-08-08 15:04:14 -07:00
committed by GitHub
co-authored by Bill Leoutsakos
parent c5499f716d
commit a477a5286c
39 changed files with 124 additions and 124 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ vi.mock('@/lib/core/config/env', async (importOriginal) => {
import { evaluateSubBlockCondition } from '@/lib/workflows/subblocks/visibility'
import { PiBlock } from '@/blocks/blocks/pi'
import { PI_SEARCH_PROVIDERS } from '@/executor/handlers/pi/keys'
import { PI_SEARCH_PROVIDERS } from '@/executor/handlers/pi/core/keys'
const searchProviderField = PiBlock.subBlocks.find((subBlock) => subBlock.id === 'searchProvider')
const searchApiKeyField = PiBlock.subBlocks.find((subBlock) => subBlock.id === 'searchApiKey')
@@ -30,19 +30,19 @@ vi.mock('@/lib/execution/remote-sandbox/pi-lifetime', () => ({
// lifetime is the ceiling because there is nothing shorter to narrow to.
resolvePiRunLifetimeMs: () => 40 * 60 * 1000,
}))
vi.mock('@/executor/handlers/pi/babysit-backend', () => ({
vi.mock('@/executor/handlers/pi/cloud/babysit/backend', () => ({
runBabysitPi: mockRunBabysit,
}))
vi.mock('@/tools', () => ({ executeTool: mockExecuteTool }))
vi.mock('@/executor/handlers/pi/keys', () => ({
vi.mock('@/executor/handlers/pi/core/keys', () => ({
providerApiKeyEnvVar: mockProviderEnvVar,
mapThinkingLevel: () => 'medium',
}))
vi.mock('@/executor/handlers/pi/context', () => ({ buildPiPrompt: () => 'PROMPT' }))
vi.mock('@/executor/handlers/pi/core/context', () => ({ buildPiPrompt: () => 'PROMPT' }))
import { createTimeoutAbortController } from '@/lib/core/execution-limits'
import type { PiCloudBranchRunParams, PiCloudRunParams } from '@/executor/handlers/pi/backend'
import { runCloudBranchPi, runCloudPi } from '@/executor/handlers/pi/cloud-backend'
import { runCloudBranchPi, runCloudPi } from '@/executor/handlers/pi/cloud/authoring/backend'
import type { PiCloudBranchRunParams, PiCloudRunParams } from '@/executor/handlers/pi/core/backend'
function baseParams(overrides: Partial<PiCloudRunParams> = {}): PiCloudRunParams {
return {
@@ -27,14 +27,13 @@ import {
resolvePiRunLifetimeMs,
resolvePiSandboxLifetimeMs,
} from '@/lib/execution/remote-sandbox/pi-lifetime'
import { runBabysitPi } from '@/executor/handlers/pi/babysit-backend'
import type {
PiBackendRun,
PiCloudBranchRunParams,
PiCloudRunParams,
PiRunContext,
PiRunResult,
} from '@/executor/handlers/pi/backend'
import { runBabysitPi } from '@/executor/handlers/pi/cloud/babysit/backend'
import {
type BranchPullRequest,
fetchOpenPrForBranch,
findOpenPrForBranch,
setPullRequestDraftState,
} from '@/executor/handlers/pi/cloud/github-pr'
import {
buildPiScript,
CLONE_TIMEOUT_MS,
@@ -53,22 +52,23 @@ import {
raceAbort,
resolvePiTimeoutMs,
scrubGitSecrets,
} from '@/executor/handlers/pi/cloud-shared'
import { buildPiPrompt } from '@/executor/handlers/pi/context'
} from '@/executor/handlers/pi/cloud/shared'
import type {
PiBackendRun,
PiCloudBranchRunParams,
PiCloudRunParams,
PiRunContext,
PiRunResult,
} from '@/executor/handlers/pi/core/backend'
import { buildPiPrompt } from '@/executor/handlers/pi/core/context'
import {
applyPiEvent,
createPiTotals,
type PiRunTotals,
parseJsonLine,
} from '@/executor/handlers/pi/events'
import {
type BranchPullRequest,
fetchOpenPrForBranch,
findOpenPrForBranch,
setPullRequestDraftState,
} from '@/executor/handlers/pi/github-pr'
import { mapThinkingLevel, providerApiKeyEnvVar } from '@/executor/handlers/pi/keys'
import { createScrubbedPiError, scrubPiEvent } from '@/executor/handlers/pi/redaction'
} from '@/executor/handlers/pi/core/events'
import { mapThinkingLevel, providerApiKeyEnvVar } from '@/executor/handlers/pi/core/keys'
import { createScrubbedPiError, scrubPiEvent } from '@/executor/handlers/pi/core/redaction'
import {
PI_SEARCH_API_KEY_ENV_VAR,
PI_SEARCH_EXTENSION_PATH,
@@ -46,8 +46,9 @@ vi.mock('@/lib/execution/remote-sandbox/pi-lifetime', async (importOriginal) =>
resolvePiSandboxLifetimeMs: mockResolvePiSandboxLifetime,
}
})
vi.mock('@/executor/handlers/pi/babysit-github', async (importOriginal) => {
const original = await importOriginal<typeof import('@/executor/handlers/pi/babysit-github')>()
vi.mock('@/executor/handlers/pi/cloud/babysit/github', async (importOriginal) => {
const original =
await importOriginal<typeof import('@/executor/handlers/pi/cloud/babysit/github')>()
return {
...original,
fetchBabysitSnapshot: mockFetchSnapshot,
@@ -64,10 +65,10 @@ import { createTimeoutAbortController, getMaxExecutionTimeout } from '@/lib/core
import {
resolveBabysitExecutionBudgetMs,
runBabysitPiWithOptions,
} from '@/executor/handlers/pi/babysit-backend'
import { BABYSIT_ROUND_PATH } from '@/executor/handlers/pi/babysit-round'
import type { PiBabysitContinuationParams } from '@/executor/handlers/pi/backend'
import { DIFF_PATH } from '@/executor/handlers/pi/cloud-shared'
} from '@/executor/handlers/pi/cloud/babysit/backend'
import { BABYSIT_ROUND_PATH } from '@/executor/handlers/pi/cloud/babysit/round'
import { DIFF_PATH } from '@/executor/handlers/pi/cloud/shared'
import type { PiBabysitContinuationParams } from '@/executor/handlers/pi/core/backend'
afterAll(resetEnvMock)
@@ -29,18 +29,13 @@ import {
fetchBabysitThreads,
replyAndResolveBabysitThreads,
requestBabysitReview,
} from '@/executor/handlers/pi/babysit-github'
} from '@/executor/handlers/pi/cloud/babysit/github'
import {
BABYSIT_ROUND_PATH,
MAX_ROUND_FILE_BYTES,
MAX_THREADS_PER_ROUND,
parseBabysitRound,
} from '@/executor/handlers/pi/babysit-round'
import type {
PiBabysitContinuationParams,
PiRunContext,
PiRunResult,
} from '@/executor/handlers/pi/backend'
} from '@/executor/handlers/pi/cloud/babysit/round'
import {
buildPiScript,
CLONE_TIMEOUT_MS,
@@ -58,20 +53,25 @@ import {
raceAbort,
resolvePiTimeoutMs,
scrubGitSecrets,
} from '@/executor/handlers/pi/cloud-shared'
import { buildPiPrompt } from '@/executor/handlers/pi/context'
} from '@/executor/handlers/pi/cloud/shared'
import type {
PiBabysitContinuationParams,
PiRunContext,
PiRunResult,
} from '@/executor/handlers/pi/core/backend'
import { buildPiPrompt } from '@/executor/handlers/pi/core/context'
import {
applyPiEvent,
createPiTotals,
type PiRunTotals,
parseJsonLine,
} from '@/executor/handlers/pi/events'
import { mapThinkingLevel, providerApiKeyEnvVar } from '@/executor/handlers/pi/keys'
} from '@/executor/handlers/pi/core/events'
import { mapThinkingLevel, providerApiKeyEnvVar } from '@/executor/handlers/pi/core/keys'
import {
createScrubbedPiError,
scrubPiEvent,
scrubPiSecrets,
} from '@/executor/handlers/pi/redaction'
} from '@/executor/handlers/pi/core/redaction'
import {
PI_SEARCH_API_KEY_ENV_VAR,
PI_SEARCH_EXTENSION_PATH,
@@ -12,7 +12,7 @@ import {
fetchBabysitSnapshot,
fetchBabysitThreads,
replyAndResolveBabysitThreads,
} from '@/executor/handlers/pi/babysit-github'
} from '@/executor/handlers/pi/cloud/babysit/github'
const HEAD_SHA = 'a'.repeat(40)
const BASE_SHA = 'b'.repeat(40)
@@ -1,13 +1,13 @@
import { getErrorMessage } from '@sim/utils/errors'
import { truncate } from '@sim/utils/string'
import type { BabysitRoundDecision } from '@/executor/handlers/pi/babysit-round'
import type { BabysitRoundDecision } from '@/executor/handlers/pi/cloud/babysit/round'
import {
fetchPrSnapshot,
type PullRequestCoordinates,
type PullRequestSnapshot,
validateRepositoryCoordinates,
} from '@/executor/handlers/pi/github-pr'
import { scrubPiSecrets } from '@/executor/handlers/pi/redaction'
} from '@/executor/handlers/pi/cloud/github-pr'
import { scrubPiSecrets } from '@/executor/handlers/pi/core/redaction'
import { executeTool } from '@/tools'
import {
isRecord,
@@ -7,7 +7,7 @@ import {
MAX_ROUND_REPLY_LENGTH,
MAX_THREADS_PER_ROUND,
parseBabysitRound,
} from '@/executor/handlers/pi/babysit-round'
} from '@/executor/handlers/pi/cloud/babysit/round'
const allowed = new Set(['thread-1', 'thread-2'])
@@ -13,7 +13,7 @@ import {
findOpenPrForBranch,
setPullRequestDraftState,
validateRepositoryCoordinates,
} from '@/executor/handlers/pi/github-pr'
} from '@/executor/handlers/pi/cloud/github-pr'
const HEAD_SHA = 'a'.repeat(40)
const BASE_SHA = 'b'.repeat(40)
@@ -64,11 +64,11 @@ vi.mock('@/lib/execution/remote-sandbox', () => ({
fn({ run: mockRun, writeFile: mockWriteFile }),
}))
vi.mock('@/tools', () => ({ executeTool: mockExecuteTool }))
vi.mock('@/executor/handlers/pi/keys', () => ({ mapThinkingLevel: () => 'medium' }))
vi.mock('@/executor/handlers/pi/context', () => ({
vi.mock('@/executor/handlers/pi/core/keys', () => ({ mapThinkingLevel: () => 'medium' }))
vi.mock('@/executor/handlers/pi/core/context', () => ({
buildPiPrompt: ({ task, guidance }: { task: string; guidance: string }) => `${guidance}\n${task}`,
}))
vi.mock('@/executor/handlers/pi/cloud-review-tools', () => ({
vi.mock('@/executor/handlers/pi/cloud/review/tools', () => ({
CLOUD_REVIEW_TOOL_NAMES: [
'read_repo_file',
'search_repo',
@@ -83,16 +83,16 @@ vi.mock('@/executor/handlers/pi/cloud-review-tools', () => ({
createCloudReviewTools: mockCreateTools,
}))
// `toPiTool` stays real so the search tool's scrubbing boundary is the one shipped, not a stub.
vi.mock('@/executor/handlers/pi/pi-sdk', async (importOriginal) => ({
...(await importOriginal<typeof import('@/executor/handlers/pi/pi-sdk')>()),
vi.mock('@/executor/handlers/pi/core/pi-sdk', async (importOriginal) => ({
...(await importOriginal<typeof import('@/executor/handlers/pi/core/pi-sdk')>()),
loadPiSdk: () => Promise.resolve(mockSdk),
createPiModelRuntime: mockCreatePiModelRuntime,
resolvePiSdkModel: () => ({ id: 'claude', provider: 'anthropic' }),
createSealedPiResourceLoader: mockCreateSealedResourceLoader,
}))
import type { PiCloudReviewRunParams } from '@/executor/handlers/pi/backend'
import { runCloudReviewPi } from '@/executor/handlers/pi/cloud-review-backend'
import { runCloudReviewPi } from '@/executor/handlers/pi/cloud/review/backend'
import type { PiCloudReviewRunParams } from '@/executor/handlers/pi/core/backend'
/**
* The mock logger instance the global `@sim/logger` mock handed to the module
@@ -12,41 +12,41 @@ import { createLogger } from '@sim/logger'
import { truncate } from '@sim/utils/string'
import { withPiSandbox } from '@/lib/execution/remote-sandbox'
import { resolvePiRunLifetimeMs } from '@/lib/execution/remote-sandbox/pi-lifetime'
import type { PiBackendRun, PiCloudReviewRunParams } from '@/executor/handlers/pi/backend'
import {
fetchOpenPrSnapshot,
MAX_REVIEW_BODY_LENGTH,
type PullRequestSnapshot,
validateRepositoryCoordinates,
} from '@/executor/handlers/pi/cloud/github-pr'
import {
CLOUD_REVIEW_TOOL_NAMES,
createCloudReviewTools,
installCloudReviewTools,
preflightCloudReviewCheckout,
} from '@/executor/handlers/pi/cloud-review-tools'
} from '@/executor/handlers/pi/cloud/review/tools'
import {
CLONE_TIMEOUT_MS,
extractMarkerValues,
REPO_DIR,
raceAbort,
scrubGitSecrets,
} from '@/executor/handlers/pi/cloud-shared'
import { buildPiPrompt } from '@/executor/handlers/pi/context'
import { applyPiEvent, createPiTotals, normalizePiEvent } from '@/executor/handlers/pi/events'
import {
fetchOpenPrSnapshot,
MAX_REVIEW_BODY_LENGTH,
type PullRequestSnapshot,
validateRepositoryCoordinates,
} from '@/executor/handlers/pi/github-pr'
import { mapThinkingLevel } from '@/executor/handlers/pi/keys'
} from '@/executor/handlers/pi/cloud/shared'
import type { PiBackendRun, PiCloudReviewRunParams } from '@/executor/handlers/pi/core/backend'
import { buildPiPrompt } from '@/executor/handlers/pi/core/context'
import { applyPiEvent, createPiTotals, normalizePiEvent } from '@/executor/handlers/pi/core/events'
import { mapThinkingLevel } from '@/executor/handlers/pi/core/keys'
import {
createPiModelRuntime,
createSealedPiResourceLoader,
loadPiSdk,
resolvePiSdkModel,
toPiTool,
} from '@/executor/handlers/pi/pi-sdk'
} from '@/executor/handlers/pi/core/pi-sdk'
import {
createScrubbedPiError,
getScrubbedPiErrorMessage,
scrubPiEvent,
} from '@/executor/handlers/pi/redaction'
} from '@/executor/handlers/pi/core/redaction'
import {
PI_SEARCH_TOOL_NAME,
PI_SEARCH_UNTRUSTED_SENTENCE,
@@ -19,7 +19,7 @@ import {
CLOUD_REVIEW_TOOL_NAMES,
createCloudReviewTools,
installCloudReviewTools,
} from '@/executor/handlers/pi/cloud-review-tools'
} from '@/executor/handlers/pi/cloud/review/tools'
const BASE_SHA = 'b'.repeat(40)
const HEAD_SHA = 'a'.repeat(40)
@@ -1,10 +1,10 @@
import type { ToolDefinition } from '@earendil-works/pi-coding-agent'
import { Type } from 'typebox'
import type { PiSandboxRunner } from '@/lib/execution/remote-sandbox'
import { REVIEW_TOOLS_SCRIPT } from '@/executor/handlers/pi/cloud-review-tools-script'
import { raceAbort } from '@/executor/handlers/pi/cloud-shared'
import type { PiSdk } from '@/executor/handlers/pi/pi-sdk'
import { scrubPiSecrets } from '@/executor/handlers/pi/redaction'
import { REVIEW_TOOLS_SCRIPT } from '@/executor/handlers/pi/cloud/review/tools-script'
import { raceAbort } from '@/executor/handlers/pi/cloud/shared'
import type { PiSdk } from '@/executor/handlers/pi/core/pi-sdk'
import { scrubPiSecrets } from '@/executor/handlers/pi/core/redaction'
import {
parseReviewFindings,
type ReviewFindings,
@@ -12,7 +12,7 @@ import {
FINALIZE_TIMEOUT_MS,
MIN_PI_TIMEOUT_MS,
resolvePiTimeoutMs,
} from '@/executor/handlers/pi/cloud-shared'
} from '@/executor/handlers/pi/cloud/shared'
describe('resolvePiTimeoutMs', () => {
it('reserves every command budget that brackets the agent turn', () => {
@@ -7,7 +7,7 @@
import { getMaxExecutionTimeout } from '@/lib/core/execution-limits'
import { resolvePiSandboxLifetimeMs } from '@/lib/execution/remote-sandbox/pi-lifetime'
import { scrubPiSecrets } from '@/executor/handlers/pi/redaction'
import { scrubPiSecrets } from '@/executor/handlers/pi/core/redaction'
export const REPO_DIR = '/workspace/repo'
export const PROMPT_PATH = '/workspace/pi-prompt.txt'
@@ -11,8 +11,8 @@
import type { TSchema } from 'typebox'
import type { SSHConnectionConfig } from '@/app/api/tools/ssh/utils'
import type { Message } from '@/executor/handlers/agent/types'
import type { PiEvent, PiRunTotals } from '@/executor/handlers/pi/events'
import type { PiSearchProvider } from '@/executor/handlers/pi/keys'
import type { PiEvent, PiRunTotals } from '@/executor/handlers/pi/core/events'
import type { PiSearchProvider } from '@/executor/handlers/pi/core/keys'
import type { PiSupportedProvider } from '@/providers/pi-provider-configs'
/** A conversation message seeded into the Pi run (subset of the Agent block's message). */
@@ -11,7 +11,7 @@ import { getErrorMessage } from '@sim/utils/errors'
import { memoryService } from '@/executor/handlers/agent/memory'
import { resolveSkillContentById } from '@/executor/handlers/agent/skills-resolver'
import type { AgentInputs, Message, SkillInput } from '@/executor/handlers/agent/types'
import type { PiMessage, PiSkill } from '@/executor/handlers/pi/backend'
import type { PiMessage, PiSkill } from '@/executor/handlers/pi/core/backend'
import type { ExecutionContext } from '@/executor/types'
const logger = createLogger('PiContext')
@@ -8,7 +8,7 @@ import {
normalizePiEvent,
parseJsonLine,
streamTextForEvent,
} from '@/executor/handlers/pi/events'
} from '@/executor/handlers/pi/core/events'
describe('normalizePiEvent', () => {
it('maps a text_delta message_update to a text event', () => {
@@ -33,7 +33,7 @@ import {
providerApiKeyEnvVar,
resolvePiModelKey,
resolvePiSearchKey,
} from '@/executor/handlers/pi/keys'
} from '@/executor/handlers/pi/core/keys'
beforeAll(() => {
envFlagsMockFns.getCostMultiplier.mockReturnValue(2)
@@ -1,7 +1,7 @@
import { InMemoryCredentialStore } from '@earendil-works/pi-ai'
import type { ModelRuntime, ResourceLoader, ToolDefinition } from '@earendil-works/pi-coding-agent'
import type { PiToolSpec } from '@/executor/handlers/pi/backend'
import { createScrubbedPiError, scrubPiSecrets } from '@/executor/handlers/pi/redaction'
import type { PiToolSpec } from '@/executor/handlers/pi/core/backend'
import { createScrubbedPiError, scrubPiSecrets } from '@/executor/handlers/pi/core/redaction'
/** The Pi SDK module, loaded dynamically so it stays externalized from the bundle. */
export type PiSdk = typeof import('@earendil-works/pi-coding-agent')
@@ -7,7 +7,7 @@ import {
getScrubbedPiErrorMessage,
scrubPiEvent,
scrubPiSecrets,
} from '@/executor/handlers/pi/redaction'
} from '@/executor/handlers/pi/core/redaction'
describe('Pi credential diagnostic redaction', () => {
it('redacts literal and URL-encoded credential representations', () => {
@@ -1,5 +1,5 @@
import { getErrorMessage } from '@sim/utils/errors'
import type { PiEvent } from '@/executor/handlers/pi/events'
import type { PiEvent } from '@/executor/handlers/pi/core/events'
/**
* Redacts exact credential values and their URL-encoded forms from diagnostics that may echo
@@ -50,26 +50,26 @@ const mockModelRuntime = {
removeRuntimeApiKey: mockRemoveRuntimeApiKey,
}
vi.mock('@/executor/handlers/pi/context', () => ({
vi.mock('@/executor/handlers/pi/core/context', () => ({
buildPiPrompt: ({ task }: { task: string }) => task,
}))
vi.mock('@/executor/handlers/pi/keys', () => ({ mapThinkingLevel: () => 'medium' }))
vi.mock('@/executor/handlers/pi/core/keys', () => ({ mapThinkingLevel: () => 'medium' }))
// `toPiTool` stays real so these tests cover its distinct success-content and error-diagnostic
// boundaries rather than passing through a stub.
vi.mock('@/executor/handlers/pi/pi-sdk', async (importOriginal) => ({
...(await importOriginal<typeof import('@/executor/handlers/pi/pi-sdk')>()),
vi.mock('@/executor/handlers/pi/core/pi-sdk', async (importOriginal) => ({
...(await importOriginal<typeof import('@/executor/handlers/pi/core/pi-sdk')>()),
loadPiSdk: () => Promise.resolve(mockSdk),
createPiModelRuntime: mockCreatePiModelRuntime,
resolvePiSdkModel: () => ({ id: 'claude', provider: 'anthropic' }),
}))
vi.mock('@/executor/handlers/pi/ssh-tools', () => ({
vi.mock('@/executor/handlers/pi/local/ssh-tools', () => ({
openSshSession: mockOpenSshSession,
buildSshToolSpecs: mockBuildSshToolSpecs,
captureRepoChanges: mockCaptureRepoChanges,
}))
import type { PiLocalRunParams } from '@/executor/handlers/pi/backend'
import { runLocalPi } from '@/executor/handlers/pi/local-backend'
import type { PiLocalRunParams } from '@/executor/handlers/pi/core/backend'
import { runLocalPi } from '@/executor/handlers/pi/local/backend'
function baseParams(): PiLocalRunParams {
return {
@@ -18,28 +18,28 @@ import type {
PiLocalRunParams,
PiRunContext,
PiRunResult,
} from '@/executor/handlers/pi/backend'
import { buildPiPrompt } from '@/executor/handlers/pi/context'
import { applyPiEvent, createPiTotals, normalizePiEvent } from '@/executor/handlers/pi/events'
import { mapThinkingLevel } from '@/executor/handlers/pi/keys'
} from '@/executor/handlers/pi/core/backend'
import { buildPiPrompt } from '@/executor/handlers/pi/core/context'
import { applyPiEvent, createPiTotals, normalizePiEvent } from '@/executor/handlers/pi/core/events'
import { mapThinkingLevel } from '@/executor/handlers/pi/core/keys'
import {
createPiModelRuntime,
loadPiSdk,
type PiSdk,
resolvePiSdkModel,
toPiTool,
} from '@/executor/handlers/pi/pi-sdk'
} from '@/executor/handlers/pi/core/pi-sdk'
import {
createScrubbedPiError,
getScrubbedPiErrorMessage,
scrubPiEvent,
} from '@/executor/handlers/pi/redaction'
} from '@/executor/handlers/pi/core/redaction'
import {
buildSshToolSpecs,
captureRepoChanges,
openSshSession,
type PiSshSession,
} from '@/executor/handlers/pi/ssh-tools'
} from '@/executor/handlers/pi/local/ssh-tools'
import { getPiProviderId } from '@/providers/pi-providers'
const logger = createLogger('PiLocalBackend')
@@ -17,7 +17,7 @@ vi.mock('@/lib/core/security/encryption', () => ({
decryptSecret: encryptionMockFns.mockDecryptSecret,
}))
import { buildSimToolSpecs } from '@/executor/handlers/pi/sim-tools'
import { buildSimToolSpecs } from '@/executor/handlers/pi/local/sim-tools'
import type { ExecutionContext } from '@/executor/types'
import { ResolvedSecretTraceRegistry } from '@/executor/utils/resolved-secret-trace-registry'
import { ToolSchemaEnrichmentError } from '@/tools/params'
@@ -12,7 +12,7 @@ import { getErrorMessage } from '@sim/utils/errors'
import { resolveCustomBlockToolBinding } from '@/lib/workflows/custom-blocks/operations'
import { getAllBlocks } from '@/blocks/registry'
import type { ToolInput } from '@/executor/handlers/agent/types'
import type { PiToolResult, PiToolSpec } from '@/executor/handlers/pi/backend'
import type { PiToolResult, PiToolSpec } from '@/executor/handlers/pi/core/backend'
import type { ExecutionContext } from '@/executor/types'
import { projectResolvedSecretModelContent } from '@/executor/utils/resolved-secret-content-projection'
import type { ResolvedSecretTraceRegistry } from '@/executor/utils/resolved-secret-trace-registry'
@@ -20,8 +20,7 @@ vi.mock('@/app/api/tools/ssh/utils', () => ({
},
}))
import type { PiSshSession } from '@/executor/handlers/pi/ssh-tools'
import { buildSshToolSpecs } from '@/executor/handlers/pi/ssh-tools'
import { buildSshToolSpecs, type PiSshSession } from '@/executor/handlers/pi/local/ssh-tools'
function createSession(files: Record<string, string>): PiSshSession {
const sftp = {
@@ -15,7 +15,7 @@ import {
sanitizeCommand,
sanitizePath,
} from '@/app/api/tools/ssh/utils'
import type { PiSshConnection, PiToolResult, PiToolSpec } from '@/executor/handlers/pi/backend'
import type { PiSshConnection, PiToolResult, PiToolSpec } from '@/executor/handlers/pi/core/backend'
const logger = createLogger('PiSshTools')
@@ -39,7 +39,7 @@ const {
MockToolNotAllowedError: class ToolNotAllowedError extends Error {},
}))
vi.mock('@/executor/handlers/pi/keys', () => ({
vi.mock('@/executor/handlers/pi/core/keys', () => ({
resolvePiModelKey: mockResolveKey,
computePiCost: () => ({ input: 0, output: 0, total: 0 }),
parsePiSearchProvider: mockParseSearchProvider,
@@ -56,20 +56,20 @@ vi.mock('@/ee/access-control/utils/permission-check', () => ({
assertPermissionsAllowed: mockAssertPermissionsAllowed,
ToolNotAllowedError: MockToolNotAllowedError,
}))
vi.mock('@/executor/handlers/pi/context', () => ({
vi.mock('@/executor/handlers/pi/core/context', () => ({
resolvePiSkills: mockResolveSkills,
loadPiMemory: mockLoadMemory,
appendPiMemory: mockAppendMemory,
}))
vi.mock('@/executor/handlers/pi/sim-tools', () => ({
vi.mock('@/executor/handlers/pi/local/sim-tools', () => ({
buildSimToolSpecs: vi.fn().mockResolvedValue([]),
}))
vi.mock('@/executor/handlers/pi/local-backend', () => ({ runLocalPi: mockRunLocal }))
vi.mock('@/executor/handlers/pi/cloud-backend', () => ({
vi.mock('@/executor/handlers/pi/local/backend', () => ({ runLocalPi: mockRunLocal }))
vi.mock('@/executor/handlers/pi/cloud/authoring/backend', () => ({
runCloudPi: mockRunCloud,
runCloudBranchPi: mockRunCloudBranch,
}))
vi.mock('@/executor/handlers/pi/cloud-review-backend', () => ({
vi.mock('@/executor/handlers/pi/cloud/review/backend', () => ({
runCloudReviewPi: mockRunCloudReview,
}))
vi.mock('@/providers/pi-providers', () => ({
+8 -8
View File
@@ -15,6 +15,8 @@ import {
ToolNotAllowedError,
} from '@/ee/access-control/utils/permission-check'
import { BlockType } from '@/executor/constants'
import { runCloudBranchPi, runCloudPi } from '@/executor/handlers/pi/cloud/authoring/backend'
import { runCloudReviewPi } from '@/executor/handlers/pi/cloud/review/backend'
import type {
PiBackendRun,
PiCloudBranchRunParams,
@@ -25,26 +27,24 @@ import type {
PiRunParams,
PiRunResult,
PiSearchConfig,
} from '@/executor/handlers/pi/backend'
import { runCloudBranchPi, runCloudPi } from '@/executor/handlers/pi/cloud-backend'
import { runCloudReviewPi } from '@/executor/handlers/pi/cloud-review-backend'
} from '@/executor/handlers/pi/core/backend'
import {
appendPiMemory,
loadPiMemory,
type PiMemoryConfig,
resolvePiSkills,
} from '@/executor/handlers/pi/context'
import { streamTextForEvent } from '@/executor/handlers/pi/events'
} from '@/executor/handlers/pi/core/context'
import { streamTextForEvent } from '@/executor/handlers/pi/core/events'
import {
computePiCost,
PI_SEARCH_PROVIDERS,
parsePiSearchProvider,
resolvePiModelKey,
resolvePiSearchKey,
} from '@/executor/handlers/pi/keys'
import { runLocalPi } from '@/executor/handlers/pi/local-backend'
} from '@/executor/handlers/pi/core/keys'
import { runLocalPi } from '@/executor/handlers/pi/local/backend'
import { buildSimToolSpecs } from '@/executor/handlers/pi/local/sim-tools'
import { buildPiSearchToolSpec } from '@/executor/handlers/pi/search/tool'
import { buildSimToolSpecs } from '@/executor/handlers/pi/sim-tools'
import type {
BlockHandler,
ExecutionContext,
@@ -11,7 +11,7 @@ import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { pathToFileURL } from 'node:url'
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
import { PI_SEARCH_PROVIDERS, type PiSearchProvider } from '@/executor/handlers/pi/keys'
import { PI_SEARCH_PROVIDERS, type PiSearchProvider } from '@/executor/handlers/pi/core/keys'
import {
PI_SEARCH_API_KEY_ENV_VAR,
PI_SEARCH_EXTENSION_PATH,
@@ -9,7 +9,7 @@
* holds the two request paths together.
*/
import type { PiSearchProvider } from '@/executor/handlers/pi/keys'
import type { PiSearchProvider } from '@/executor/handlers/pi/core/keys'
/** The tool name Pi sees, in every mode. */
export const PI_SEARCH_TOOL_NAME = 'web_search'
@@ -15,7 +15,7 @@ import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { pathToFileURL } from 'node:url'
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
import { PI_SEARCH_PROVIDERS, type PiSearchProvider } from '@/executor/handlers/pi/keys'
import { PI_SEARCH_PROVIDERS, type PiSearchProvider } from '@/executor/handlers/pi/core/keys'
import {
PI_SEARCH_API_KEY_ENV_VAR,
PI_SEARCH_EXTENSION_SOURCE,
+2 -2
View File
@@ -8,8 +8,8 @@
*/
import { createLogger } from '@sim/logger'
import type { PiSearchConfig, PiToolSpec } from '@/executor/handlers/pi/backend'
import { PI_SEARCH_PROVIDERS } from '@/executor/handlers/pi/keys'
import type { PiSearchConfig, PiToolSpec } from '@/executor/handlers/pi/core/backend'
import { PI_SEARCH_PROVIDERS } from '@/executor/handlers/pi/core/keys'
import {
buildPiSearchProviderArgs,
extractPiSearchRecords,