import { SessionManager } from "@caupulican/pi-agent-core/session"; import type { ThinkingLevel } from "@caupulican/pi-agent-core/types"; import { type Api, type Model, type ServiceTier } from "@caupulican/pi-ai"; import { AgentSession } from "./agent-session.ts"; import { AuthStorage } from "./auth-storage.ts"; import type { LoadExtensionsResult, SessionStartEvent, ToolDefinition } from "./extensions/index.ts"; import { ModelRegistry } from "./model-registry.ts"; import type { OrchestrationProfile } from "./orchestration/contracts.ts"; import type { ResourceLoader } from "./resource-loader.ts"; import type { ProfileDefinitionInput, ResourceProfileFilterSettings, ResourceProfileSettings } from "./settings-manager.ts"; import { SettingsManager } from "./settings-manager.ts"; import { createBashTool, createCodingTools, createEditTool, createFindTool, createGrepTool, createLsTool, createReadOnlyTools, createReadTool, createWriteTool, withFileMutationQueue } from "./tools/index.ts"; export interface CreateAgentSessionOptions { /** Working directory for project-local discovery. Default: process.cwd() */ cwd?: string; /** Global config directory. Default: ~/.pi/agent */ agentDir?: string; /** Auth storage for credentials. Default: AuthStorage.create(agentDir/auth.json) */ authStorage?: AuthStorage; /** Model registry. Default: ModelRegistry.create(authStorage, agentDir/models.json) */ modelRegistry?: ModelRegistry; /** Model to use. Default: from settings, else first available */ model?: Model; /** Thinking level. Default: from settings, then the model's declared default, else 'medium'. */ thinkingLevel?: ThinkingLevel; /** Default provider processing tier for this session. Per-request options take precedence. */ serviceTier?: ServiceTier; /** * Whether `model` came from an explicit CLI/SDK flag (vs. profile/settings resolution). * When false (default), the active profile's model is re-applied on reload so live profile * edits take effect; when true, the explicit launch-time model is preserved across reloads. */ isExplicitModel?: boolean; /** Whether `thinkingLevel` came from an explicit flag (see isExplicitModel). */ isExplicitThinking?: boolean; /** True when this session is a spawned subagent/child — gates durable memory writes. */ isChildSession?: boolean; /** Models available for cycling (Ctrl+P in interactive mode) */ scopedModels?: Array<{ model: Model; thinkingLevel?: ThinkingLevel; }>; /** * Optional default tool suppression mode when no explicit allowlist is provided. * * - "all": start with no tools enabled * - "builtin": disable the default built-in tools (read, bash, python, edit, write, * goal, delegate, and run_toolkit_script) * but keep extension/custom tools enabled */ noTools?: "all" | "builtin"; /** * Optional allowlist of tool names. * * When omitted, pi enables the shared default built-in tool surface and leaves extension/custom * tools enabled unless `noTools` changes that default. * When provided, only the listed tool names are enabled. */ tools?: string[]; /** Optional denylist of tool names to disable. Applies after `tools` when both are provided. */ excludeTools?: string[]; /** Optional resource-profile allow/block filters for tool names. */ toolProfileFilter?: ResourceProfileFilterSettings; /** Optional one-shot resource filters or complete situation profiles. Never persisted to disk. */ resourceProfileDefinitions?: Record; /** Optional one-shot profile definitions as JSON or tag text. Never persisted to disk. */ resourceProfileJson?: string | string[]; /** Optional runtime profile selection. Never persisted to disk. */ resourceProfiles?: string[]; /** Immutable owner-authored orchestration policy for this session. */ orchestrationProfile?: OrchestrationProfile; /** Custom tools to register (in addition to built-in tools). */ customTools?: ToolDefinition[]; /** Resource loader. When omitted, DefaultResourceLoader is used. */ resourceLoader?: ResourceLoader; /** Session manager. Default: SessionManager.create(cwd, agentDir, getDefaultSessionDir(cwd, agentDir)) */ sessionManager?: SessionManager; /** Settings manager. Default: SettingsManager.create(cwd, agentDir) */ settingsManager?: SettingsManager; /** Session start event metadata for extension runtime startup. */ sessionStartEvent?: SessionStartEvent; } /** Result from createAgentSession */ export interface CreateAgentSessionResult { /** The created session */ session: AgentSession; /** Extensions result (for UI context setup in interactive mode) */ extensionsResult: LoadExtensionsResult; /** Warning if session was restored with a different model than saved */ modelFallbackMessage?: string; } export * from "./agent-session-runtime.ts"; export type { ExtensionAPI, ExtensionCommandContext, ExtensionContext, ExtensionFactory, SlashCommandInfo, SlashCommandSource, ToolDefinition, } from "./extensions/index.ts"; export type { PromptTemplate } from "./prompt-templates.ts"; export type { Skill } from "./skills.ts"; export type { Tool } from "./tools/index.ts"; export { withFileMutationQueue, createCodingTools, createReadOnlyTools, createReadTool, createBashTool, createEditTool, createWriteTool, createGrepTool, createFindTool, createLsTool, }; /** * Create an AgentSession with the specified options. * * @example * ```typescript * // Minimal - uses defaults * const { session } = await createAgentSession(); * * // With explicit model * import { getModel } from '@caupulican/pi-ai'; * const { session } = await createAgentSession({ * model: getModel('anthropic', 'claude-opus-4-5'), * thinkingLevel: 'high', * }); * * // Continue previous session * const { session, modelFallbackMessage } = await createAgentSession({ * continueSession: true, * }); * * // Full control * const loader = new DefaultResourceLoader({ * cwd: process.cwd(), * agentDir: getAgentDir(), * settingsManager: SettingsManager.create(), * }); * await loader.reload(); * const { session } = await createAgentSession({ * model: myModel, * tools: ["read", "bash"], * resourceLoader: loader, * sessionManager: SessionManager.inMemory(), * }); * ``` */ export declare function createAgentSession(options?: CreateAgentSessionOptions): Promise; //# sourceMappingURL=sdk.d.ts.map