Skip to content

armgit / pibot

Public Imported from GitHub
0

Open-source, local-first AI agent team for your desktop: multi-agent group chats, computer use, browser, MCP, routines and approvals. macOS, Windows, Linux + Android. Built on pi.

3.3 KB
Raw Blame
import { z } from "zod";

// A runner sends this only to a peer that enabled the extension. Keep the envelope
// closed: no exception text, paths, command arguments or arbitrary details on the wire.
export const RunnerExecutionErrorSchema = z.strictObject({
  kind: z.literal("runner_execution_check_v1"),
  code: z.enum([
    "command_path_discovery_failed",
    "command_not_found",
    "docker_permission_changed",
    "docker_command_invalid",
    "docker_unsupported",
    "docker_endpoint_unavailable",
    "docker_endpoint_changed",
    "invalid_input",
    "outside_workplace",
    "isolation_unavailable",
    "isolation_scan_limit",
    "busy",
    "closed",
    "timeout",
    "write_timeout",
    "file_failed",
    "file_not_found",
    "file_not_directory",
    "file_filter_mismatch",
    "file_sensitive",
    "file_access_denied",
    "file_conflict",
    "file_in_use",
    "edit_not_unique",
    "edit_overlap",
    "output_failed",
    "command_failed",
    "web_blocked",
    "web_failed",
    "git_unavailable",
    "connector_server_unavailable",
    "authorization_changed",
    "managed_identity_changed",
    "script_changed",
    "interpreter_untrusted",
  ]),
  reason: z
    .enum([
      "path_canonicalization_failed",
      "write_path_alias",
      "write_path_protected",
      "write_path_hardlink",
      "write_path_outside_root",
      "workspace_root_alias",
      "workspace_identity_missing",
      "workspace_identity_changed",
      "profile_data_root",
      "profile_bot_home",
      "profile_bot_skills",
      "profile_bot_attachments",
      "profile_group_skills",
      "profile_group_home",
      "profile_skill_package",
      "profile_skill_env",
      "profile_python_env",
      "profile_managed_python",
      "profile_uv_cache",
      "profile_uv_binary",
      "profile_write_root",
      "profile_temp_root",
      "profile_read_root",
      "profile_temp_namespace",
      "proxy_auth_failed",
      "proxy_unavailable",
      "proxy_credentials_unavailable",
      "unsupported_url",
      "private_address",
      "domain_denied",
      "unsupported_content_type",
      "response_too_large",
      "redirect_limit",
      "http_status",
      "cancelled",
      "timeout",
      "dns_failed",
      "connection_failed",
      "tls_failed",
      "dispatcher_incompatible",
      "body_failed",
      "html_failed",
      "cleanup_failed",
      "sandbox_initialization_timeout",
      "sandbox_cleanup_timeout",
      "process_snapshot_timeout",
      "process_snapshot_limit",
      "process_snapshot_failed",
      "process_monitor_failed",
      "process_kill_failed",
      "process_unknown",
      "listener_check_failed",
      "stdin_closed",
      "stdin_unconfirmed",
      "process_stream_failed",
      "process_spawn_failed",
      "unsupported_platform",
      "runner_disconnected",
      "cleanup_unconfirmed",
      "editor_capability_missing",
      "isolation_start_failed",
      "seccomp_helper_unavailable",
      "windows_proxy_credentials",
    ])
    .optional(),
});
export type RunnerExecutionError = z.infer<typeof RunnerExecutionErrorSchema>;

export type ExecutionCheckCode =
  | NonNullable<RunnerExecutionError["reason"]>
  | `execution_${RunnerExecutionError["code"]}`;

export function runnerExecutionCheck(error: RunnerExecutionError): ExecutionCheckCode {
  return error.reason ?? `execution_${error.code}`;
}