d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
100 lines
2.8 KiB
TypeScript
100 lines
2.8 KiB
TypeScript
/**
|
|
* The seam between the Pi handler and its execution environments. The handler
|
|
* resolves keys, skills, memory, and tools, then hands a {@link PiRunParams} to
|
|
* one backend ({@link PiBackendRun}) selected by `mode`. Backends own only the
|
|
* environment-specific execution (SSH vs E2B) and report progress through
|
|
* {@link PiRunContext.onEvent}.
|
|
*/
|
|
|
|
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'
|
|
|
|
/** A conversation message seeded into the Pi run (subset of the Agent block's message). */
|
|
export type PiMessage = Pick<Message, 'role' | 'content'>
|
|
|
|
/** A resolved skill (name + full content) made available to Pi. */
|
|
export interface PiSkill {
|
|
name: string
|
|
content: string
|
|
}
|
|
|
|
/** SSH connection parameters for local mode (subset of the shared SSH config). */
|
|
export type PiSshConnection = Pick<
|
|
SSHConnectionConfig,
|
|
'host' | 'port' | 'username' | 'password' | 'privateKey' | 'passphrase'
|
|
>
|
|
|
|
/** Result of invoking a tool Pi called. */
|
|
export interface PiToolResult {
|
|
text: string
|
|
isError: boolean
|
|
}
|
|
|
|
/**
|
|
* A tool exposed to Pi in a backend-neutral shape (the SSH file/bash tools and
|
|
* adapted Sim tools both use it). The local backend converts these into Pi
|
|
* `customTools`; keeping them Pi-SDK-free keeps this seam typed.
|
|
*/
|
|
export interface PiToolSpec {
|
|
name: string
|
|
description: string
|
|
parameters: Record<string, unknown>
|
|
execute: (args: Record<string, unknown>) => Promise<PiToolResult>
|
|
}
|
|
|
|
interface PiRunBaseParams {
|
|
model: string
|
|
providerId: string
|
|
apiKey: string
|
|
isBYOK: boolean
|
|
task: string
|
|
thinkingLevel?: string
|
|
skills: PiSkill[]
|
|
initialMessages: PiMessage[]
|
|
}
|
|
|
|
/** Parameters for a local (SSH) Pi run. */
|
|
export interface PiLocalRunParams extends PiRunBaseParams {
|
|
mode: 'local'
|
|
ssh: PiSshConnection
|
|
repoPath: string
|
|
tools: PiToolSpec[]
|
|
}
|
|
|
|
/** Parameters for a cloud (E2B) Pi run. */
|
|
export interface PiCloudRunParams extends PiRunBaseParams {
|
|
mode: 'cloud'
|
|
owner: string
|
|
repo: string
|
|
githubToken: string
|
|
baseBranch?: string
|
|
branchName?: string
|
|
draft: boolean
|
|
prTitle?: string
|
|
prBody?: string
|
|
}
|
|
|
|
export type PiRunParams = PiLocalRunParams | PiCloudRunParams
|
|
|
|
/** Progress callbacks and cancellation passed into a backend run. */
|
|
export interface PiRunContext {
|
|
onEvent: (event: PiEvent) => void
|
|
signal?: AbortSignal
|
|
}
|
|
|
|
/** Final result of a Pi run. */
|
|
export interface PiRunResult {
|
|
totals: PiRunTotals
|
|
changedFiles?: string[]
|
|
diff?: string
|
|
prUrl?: string
|
|
branch?: string
|
|
}
|
|
|
|
/** A Pi execution backend. Implemented by the local (SSH) and cloud (E2B) runners. */
|
|
export type PiBackendRun<P extends PiRunParams = PiRunParams> = (
|
|
params: P,
|
|
context: PiRunContext
|
|
) => Promise<PiRunResult>
|