UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

1,017 lines • 26.8 kB
import type { AgentSession } from "../../core/agent-session.ts"; import { type EffectBegin } from "./effect-ledger.ts"; import { type EffectActor, type EffectCommandKind, type EffectStatus } from "./effect-record.ts"; import { type RpcCommand, type RpcEffectAnswer, type RpcResponse } from "./rpc-types.ts"; type Command<T extends RpcCommand["type"]> = Extract<RpcCommand, { type: T; }>; export interface EffectCommandContext { readonly session: AgentSession; readonly by: EffectActor; /** The routing handle this session is answered on, absent on a classic connection. */ readonly sessionId?: string; } type EffectResponse = Extract<RpcResponse, { success: true; command: "abort" | "set_model" | "set_thinking_level" | "get_effect_status" | "dequeue_message" | "edit_queued_message"; }>; type ResponsePayload<T> = T extends EffectResponse ? Omit<T, "id" | "type" | "success"> : never; export declare function respond(id: string | undefined, response: ResponsePayload<EffectResponse>): RpcResponse; export declare function refuse(id: string | undefined, command: string, message: string, errorCode: string | undefined, errorData: unknown): RpcResponse; export declare function effectAnswer(status: EffectStatus, sessionId: string | undefined, replayed?: boolean): RpcEffectAnswer; export declare function beginEffect(ctx: EffectCommandContext, kind: EffectCommandKind, command: { readonly id?: string; readonly type: string; readonly effectId: string; }): Promise<EffectBegin | RpcResponse>; export declare function isEffectBegin(value: EffectBegin | RpcResponse): value is EffectBegin; /** * `abort`: with `clearQueue` the queued inputs are drained (each gets a `cleared` receipt) before * the abort; with `awaitIdle` the answer waits until the session is idle or `graceMs` passes. Without * either, the abort is acknowledged on dispatch exactly as before. */ export declare function runAbort(ctx: EffectCommandContext, command: Command<"abort">, dispatch: () => Promise<void>): Promise<RpcResponse>; /** * `dequeue_message` / `edit_queued_message`: one queued input, by `queuedId`. With `effectId` the change is a ledger * effect: `done` when it removed or edited the input, `failed` with an outcome when the input was already delivered * or no longer exists. */ export declare function runQueuedInputChange(ctx: EffectCommandContext, command: Command<"dequeue_message"> | Command<"edit_queued_message">): Promise<RpcResponse>; export declare function runSetThinkingLevel(ctx: EffectCommandContext, command: Command<"set_thinking_level">): Promise<import("./admit-external-message-wire.ts").RpcAdmitExternalMessageResponse | import("./session-move-wire.ts").RpcMoveSessionResponse | import("./compact-admission-error.ts").UnknownAdmissionResponse | { readonly id?: string; readonly type: "response"; readonly command: "attach_session"; readonly success: true; readonly data: { readonly sessionId: string; readonly attached: true; readonly holder?: string; readonly generation?: number; readonly released?: number; }; } | { readonly id?: string; readonly type: "response"; readonly command: "release_attachment"; readonly success: true; readonly data: { readonly deferred: boolean; }; } | { readonly id?: string; readonly type: "response"; readonly command: "reclaim_session"; readonly success: true; readonly data: { readonly reclaimed: true; readonly sessionId: string; }; } | { id?: string; type: "response"; command: "park_session"; success: true; data: { state: "parked" | "already_parked" | "full"; }; } | { id?: string; type: "response"; command: "claim_session"; success: true; data: { claimed: false; } | { sessionId: string; state: import("./rpc-session-state-types.ts").RpcSessionState; attached?: boolean; presence?: import("./rpc-host-response-types.ts").RpcSessionPresence; }; } | { id?: string; type: "response"; command: "list_hands"; success: true; data: { hands: ReadonlyArray<{ device: string; label: string; platform: string; reachable: boolean; }>; selected?: string | null; }; } | { id?: string; type: "response"; command: "select_hand"; success: true; data: { sessionId: string; selected: string | null; }; } | { id?: string; type: "response"; command: "cancel_attempt"; success: true; data: { outcome: "cancelled" | "already_complete" | "unknown"; }; } | { id?: string; type: "response"; command: "get_protocol_info"; success: true; data: import("./rpc-protocol-info-types.ts").RpcProtocolInfo; } | { id?: string; type: "response"; command: "open_session"; success: true; data: { sessionId: string; state: import("./rpc-session-state-types.ts").RpcSessionState; attached?: boolean; presence?: import("./rpc-host-response-types.ts").RpcSessionPresence; }; } | { id?: string; type: "response"; command: "close_session"; success: true; data: Record<string, never>; } | { id?: string; type: "response"; command: "unload_session"; success: true; data: import("./rpc-effect-answer-types.ts").RpcUnloadAnswer; } | { id?: string; type: "response"; command: "release_session"; success: true; data: { released: true; session_path: string; attachments: number; dropped: { deliveries: readonly string[]; user_messages: readonly string[]; }; }; } | { id?: string; type: "response"; command: "warm"; success: true; data: { state: "warmed" | "already_warm" | "unsupported"; }; } | { id?: string; type: "response"; command: "find_session"; success: true; data: { found: { sessionPath: string; cwd: string; open: boolean; }; } | { ambiguous: true; } | { unknown: true; }; } | { id?: string; type: "response"; command: "detach_connection"; success: true; data: { deferred: string[]; }; } | { id?: string; type: "response"; command: "get_subscription_limits"; success: true; data: { accounts: ReadonlyArray<Omit<import("./rpc-host-lifecycle-types.ts").RpcSubscriptionLimitsEvent, "type">>; }; } | { id?: string; type: "response"; command: "list_sessions"; success: true; data: { sessions: Array<{ sessionId: string; generation?: number; hostInstanceId?: string; durableSessionId?: string; sessionPath?: string; cwd: string; name?: string; status: "opening" | "open" | "closing" | "closed"; attachments: number; retain_on_disconnect?: boolean; idleMs?: number; tool_child?: { state: "none" | "live" | "exited"; generation?: number; pid?: number; }; presence?: import("./rpc-host-response-types.ts").RpcSessionPresence; }>; handover?: { pending: number; predecessor_draining: boolean; }; }; } | { id?: string; type: "response"; command: "subscribe_sessions"; success: true; data: { subscriptionId: string; snapshot: readonly import("./session-status.ts").SessionStatusRecord[]; seq: number; hostGeneration: string; hostInstanceId: string; }; } | { id?: string; type: "response"; command: "unsubscribe_sessions"; success: true; } | { id?: string; type: "response"; command: "set_session_context"; success: true; data: { context: Readonly<Record<string, string | number | boolean>>; }; } | { id?: string; type: "response"; command: "wake"; success: true; data: { admitted: readonly import("../../index.ts").SessionControlAdmission[]; }; } | { id?: string; type: "response"; command: "prompt"; success: true; data?: import("../../core/client-message-identity.ts").ClientMessageIdentity & { disposition?: import("../../core/agent-session.ts").PromptDisposition; turnId?: string; admission?: import("./client-admission-record.ts").ClientMessageAdmission; heldAsNotice?: boolean; }; } | { id?: string; type: "response"; command: "send_custom_message"; success: true; } | { id?: string; type: "response"; command: "append_user_message"; success: true; } | { id?: string; type: "response"; command: "append_session_entry"; success: true; } | { id?: string; type: "response"; command: "steer"; success: true; data?: import("../../core/client-message-identity.ts").ClientMessageIdentity & { disposition?: import("../../core/agent-session.ts").QueuedInputDisposition; turnId?: string; admission?: import("./client-admission-record.ts").ClientMessageAdmission; heldAsNotice?: boolean; }; } | { id?: string; type: "response"; command: "follow_up"; success: true; data?: import("../../core/client-message-identity.ts").ClientMessageIdentity & { disposition?: import("../../core/agent-session.ts").QueuedInputDisposition; turnId?: string; admission?: import("./client-admission-record.ts").ClientMessageAdmission; heldAsNotice?: boolean; }; } | { id?: string; type: "response"; command: "abort"; success: true; data?: RpcEffectAnswer | (Partial<RpcEffectAnswer> & import("./rpc-effect-answer-types.ts").RpcAbortQuiesce); } | { id?: string; type: "response"; command: "release_tool_barrier"; success: true; data: { released: boolean; }; } | { id?: string; type: "response"; command: "dequeue_message" | "edit_queued_message"; success: true; data: import("./rpc-effect-answer-types.ts").RpcQueuedInputChange & Partial<RpcEffectAnswer>; } | { id?: string; type: "response"; command: "interrupt"; success: true; data: import("./session-control-actions-data.ts").InterruptOutcome; } | { id?: string; type: "response"; command: "abort_compaction"; success: true; } | { id?: string; type: "response"; command: "reload"; success: true; data: { cancelled: boolean; reason?: string; }; } | { id?: string; type: "response"; command: "check_reload_veto"; success: true; data: { cancelled: boolean; reason?: string; }; } | { id?: string; type: "response"; command: "clear_queue"; success: true; data: { steering: string[]; followUp: string[]; ordered: import("../../core/agent-session.ts").QueuedInput[]; }; } | { id?: string; type: "response"; command: "new_session"; success: true; data: { cancelled: boolean; }; } | { id?: string; type: "response"; command: "set_model"; success: true; data: (import("@earendil-works/pi-ai").Model<any> & { systemPromptName?: string; } & Partial<RpcEffectAnswer>) | RpcEffectAnswer; } | { id?: string; type: "response"; command: "set_favorite_models"; success: true; } | { id?: string; type: "response"; command: "set_scoped_models"; success: true; } | { id?: string; type: "response"; command: "cycle_model"; success: true; data: { model: import("@earendil-works/pi-ai").Model<any>; thinkingLevel: import("@earendil-works/pi-agent-core").ThinkingLevel; isScoped: boolean; } | null; } | { id?: string; type: "response"; command: "continue_from_leaf"; success: true; } | { id?: string; type: "response"; command: "set_thinking_level"; success: true; data?: RpcEffectAnswer; } | { id?: string; type: "response"; command: "cycle_thinking_level"; success: true; data: { level: import("@earendil-works/pi-agent-core").ThinkingLevel; } | null; } | { id?: string; type: "response"; command: "set_fast_mode"; success: true; data: { enabled: boolean; serviceTier: import("../../core/extensions/types.ts").ServiceTier; provider: string; modelId: string; }; } | { id?: string; type: "response"; command: "set_steering_mode"; success: true; } | { id?: string; type: "response"; command: "set_project_trust"; success: true; data: import("./project-workspace-commands.ts").RpcProjectTrust; } | { id?: string; type: "response"; command: "set_project_setting"; success: true; data: import("./project-workspace-commands.ts").RpcProjectSettings; } | { id?: string; type: "response"; command: "write_project_file"; success: true; data: import("./project-file-commands.ts").RpcProjectFile; } | { id?: string; type: "response"; command: "set_project_mcp_servers"; success: true; data: import("./project-mcp-commands.ts").RpcProjectMcpServers; } | { id?: string; type: "response"; command: "write_project_skill_file"; success: true; data: import("./project-skill-commands.ts").RpcProjectSkillFile; } | { id?: string; type: "response"; command: "write_user_skill_file"; success: true; data: import("./user-skill-commands.ts").RpcUserSkillFile; } | { id?: string; type: "response"; command: "set_follow_up_mode"; success: true; } | { id?: string; type: "response"; command: "compact"; success: true; data: import("../../index.ts").CompactionResult; } | { id?: string; type: "response"; command: "set_auto_compaction"; success: true; } | { id?: string; type: "response"; command: "set_permission_preset"; success: true; data: import("../../core/permission-mode.ts").PermissionModeReply; } | { id?: string; type: "response"; command: "set_auto_retry"; success: true; } | { id?: string; type: "response"; command: "abort_retry"; success: true; } | { id?: string; type: "response"; command: "set_retry_fallback"; success: true; } | { id?: string; type: "response"; command: "bash"; success: true; data: import("../../core/bash-executor.ts").BashResult; } | { id?: string; type: "response"; command: "navigate_tree"; success: true; data: import("./rpc-result-types.ts").NavigateTreeResult | { cancelled: boolean; leafId: string | null; editorText?: string; aborted?: boolean; summaryEntry?: unknown; }; } | { id?: string; type: "response"; command: "abort_bash"; success: true; } | { id?: string; type: "response"; command: "export_html"; success: true; data: { path: string; }; } | { id?: string; type: "response"; command: "export_jsonl"; success: true; data: { path: string; }; } | { id?: string; type: "response"; command: "switch_session"; success: true; data: { cancelled: boolean; }; } | { id?: string; type: "response"; command: "fork"; success: true; data: { text: string; cancelled: boolean; }; } | { id?: string; type: "response"; command: "edit_assistant_message"; success: true; data: import("./rpc-result-types.ts").EditAssistantMessageResult; } | { id?: string; type: "response"; command: "edit_user_message"; success: true; data: import("./rpc-result-types.ts").EditUserMessageResult; } | { id?: string; type: "response"; command: "clone"; success: true; data: { cancelled: boolean; }; } | { id?: string; type: "response"; command: "set_session_name"; success: true; } | { id?: string; type: "response"; command: "set_session_archived"; success: true; } | { id?: string; type: "response"; command: "set_session_settled"; success: true; } | { id?: string; type: "response"; command: "record_user_activity"; success: true; } | { id?: string; type: "response"; command: "import_jsonl"; success: true; data: { cancelled: boolean; }; } | { id?: string; type: "response"; command: "extension_request"; success: true; data: unknown; } | { id?: string; type: "response"; command: "login_start"; success: true; } | { id?: string; type: "response"; command: "login_cancel"; success: true; } | { id?: string; type: "response"; command: "login_api_key"; success: true; data?: { replaced: "oauth" | "api_key"; backupPath?: string; }; } | { id?: string; type: "response"; command: "logout"; success: true; data?: { notices?: string[]; status?: import("@earendil-works/pi-ai").OAuthRevocationResult["status"]; }; } | { id?: string; type: "response"; command: "verify_api_key"; success: true; data: import("../../core/verify-api-key.ts").ApiKeyVerification; } | { id?: string; type: "response"; command: "account_pin"; success: true; } | { id?: string; type: "response"; command: "account_remove"; success: true; data?: { notice: string; }; } | { id?: string; type: "response"; command: "account_reset"; success: true; } | { id?: string; type: "response"; command: "account_order"; success: true; } | { id?: string; type: "response"; command: "test_provider_account"; success: true; data: { check: NonNullable<import("./rpc-session-state-types.ts").RpcProviderAccount["check"]>; }; } | { id?: string; type: "response"; command: string; success: false; error: string; errorCode?: string; errorData?: unknown; } | { id?: string; type: "response"; command: "hold_input"; success: true; data: { entryId?: string; duplicate?: boolean; alreadyDelivered?: boolean; }; } | { id?: string; type: "response"; command: "withdraw_held_input"; success: true; data: { withdrawn: boolean; }; } | { id?: string; type: "response"; command: "pause_for_run"; success: true; data: { held: true; childSeq: number; }; } | { id?: string; type: "response"; command: "resume_for_run"; success: true; data: { released: boolean; reason?: "stale" | "not_held"; otherHoldLive?: boolean; turnId?: string; }; } | { id?: string; type: "response"; command: "resume_session"; success: true; data?: { resumed: boolean; reason?: "stale" | "not_paused" | "resume_through_parent" | "stopped"; parentSessionId?: string; pauseSeq: number; turnStarted: boolean; deliveredNotices: number; deliveredHeldInputs: number; replayed?: boolean; }; } | { id?: string; type: "response"; command: "get_snapshot"; success: true; data: import("./snapshot-types.ts").RpcSnapshot; } | { id?: string; type: "response"; command: "get_state"; success: true; data: import("./rpc-session-state-types.ts").RpcSessionState; } | { id?: string; type: "response"; command: "request_self_settle"; success: true; data: import("../../index.ts").SelfSettleResult; } | { id?: string; type: "response"; command: "get_effect_status"; success: true; data: { found: true; effect: EffectStatus; } | { found: false; searched: "complete"; }; } | { id?: string; type: "response"; command: "get_pending_inputs"; success: true; data: import("../../core/pending-input-session.ts").PendingInputSnapshot; } | { id?: string; type: "response"; command: "get_available_models"; success: true; data: { models: Array<import("@earendil-works/pi-ai").Model<any> & { supportedThinkingLevels: import("@earendil-works/pi-agent-core").ThinkingLevel[]; supportsAssistantPrefill: boolean; }>; }; } | { id?: string; type: "response"; command: "get_available_thinking_levels"; success: true; data: { levels: import("@earendil-works/pi-agent-core").ThinkingLevel[]; }; } | { id?: string; type: "response"; command: "get_model_thinking_level"; success: true; data: { level: import("@earendil-works/pi-agent-core").ThinkingLevel; source: import("../../core/session-thinking-memory.ts").ThinkingLevelSource; availableLevels: import("@earendil-works/pi-agent-core").ThinkingLevel[]; }; } | { id?: string; type: "response"; command: "get_fast_mode"; success: true; data: { enabled: boolean; serviceTier: import("../../core/extensions/types.ts").ServiceTier | null; }; } | { id?: string; type: "response"; command: "get_session_stats"; success: true; data: import("../../core/agent-session.ts").SessionStats; } | { id?: string; type: "response"; command: "resolve_path"; success: true; data: import("../../core/message-path-resolution.ts").ResolvedMessagePath; } | { id?: string; type: "response"; command: "memory_report"; success: true; data: { path: string; heapSnapshot?: string; }; } | { id?: string; type: "response"; command: "get_fork_messages"; success: true; data: { messages: Array<{ entryId: string; text: string; }>; }; } | { id?: string; type: "response"; command: "get_entries"; success: true; data: { entries: import("../../index.ts").SessionEntry[]; leafId: string | null; hasMore?: boolean; nextSince?: string; next_before?: string; }; } | { id?: string; type: "response"; command: "get_tree"; success: true; data: { tree: import("../../index.ts").SessionTreeNode[]; leafId: string | null; }; } | { id?: string; type: "response"; command: "get_recovery_page"; success: true; data: import("./compact-recovery-requests.ts").RecoveryPageAnswer | import("./compact-recovery-requests.ts").EventPageAnswer; } | { id?: string; type: "response"; command: "release_recovery"; success: true; data: import("./compact-event-leases.ts").ReleaseReceipt; } | { id?: string; type: "response"; command: "get_last_assistant_text"; success: true; data: { text: string | null; }; } | { id?: string; type: "response"; command: "get_messages"; success: true; data: { messages: import("@earendil-works/pi-agent-core").AgentMessage[]; }; } | { id?: string; type: "response"; command: "get_media"; success: true; data: { toolCallId: string; contentIndex: number; content: import("@earendil-works/pi-ai").ImageContent; }; } | { id?: string; type: "response"; command: "get_commands"; success: true; data: { commands: import("./rpc-command-surface.ts").RpcSlashCommand[]; }; } | { id?: string; type: "response"; command: "get_loaded_surfaces"; success: true; data: { extensions: import("./rpc-session-state-types.ts").RpcLoadedExtension[]; mcpServers: import("./rpc-session-state-types.ts").RpcLoadedMcpServer[]; }; } | { id?: string; type: "response"; command: "get_project_trust"; success: true; data: import("./project-workspace-commands.ts").RpcProjectTrust; } | { id?: string; type: "response"; command: "get_project_settings"; success: true; data: import("./project-workspace-commands.ts").RpcProjectSettings; } | { id?: string; type: "response"; command: "read_project_file"; success: true; data: import("./project-file-commands.ts").RpcProjectFile; } | { id?: string; type: "response"; command: "get_project_mcp_servers"; success: true; data: import("./project-mcp-commands.ts").RpcProjectMcpServers; } | { id?: string; type: "response"; command: "read_project_skill_file"; success: true; data: import("./project-skill-commands.ts").RpcProjectSkillFile; } | { id?: string; type: "response"; command: "read_user_skill_file"; success: true; data: import("./user-skill-commands.ts").RpcUserSkillFile; } | { id?: string; type: "response"; command: "eval_cells.list"; success: true; data: import("./rpc-result-types.ts").RpcEvalCell[]; } | { id?: string; type: "response"; command: "eval_cells.peek" | "eval_cells.stop"; success: true; data: import("./rpc-result-types.ts").RpcEvalCellSnapshot; } | { id?: string; type: "response"; command: "get_auth_providers"; success: true; data: { providers: import("./rpc-session-state-types.ts").RpcAuthProvider[]; storeError?: import("./rpc-session-state-types.ts").RpcAuthStoreError; storeBusy?: true; }; } | { id?: string; type: "response"; command: "get_provider_accounts"; success: true; data: { accounts: import("./rpc-session-state-types.ts").RpcProviderAccount[]; ordered: boolean; }; } | { id?: string; type: "response"; command: "set_client_info"; success: true; data?: { capabilities: readonly string[]; }; }>; /** `get_effect_status` on a loaded session; a `sessionPath` naming another transcript reads that file. */ export declare function runGetEffectStatus(ctx: EffectCommandContext, command: Command<"get_effect_status">): Promise<RpcResponse>; /** `get_effect_status { sessionPath }` for a session that is not loaded: an authoritative disk read. */ export declare function answerEffectFromTranscript(id: string | undefined, path: string, effectId: string): Promise<RpcResponse>; export {}; //# sourceMappingURL=effect-commands.d.ts.map