Files
moloapp/src/google/sandbox/templates.h
T
retoorandClaude Sonnet 5.5 af6ee63211 feat(clients): sandbox: Agent Sandbox lifecycle, code/shell/computer-use execution, templates, snapshots
Typed results with hard caps, one call table checked against Discovery
(tools/check_discovery.py), live read-only probe, /agent/sandbox demo.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 04:36:39 +02:00

69 lines
2.5 KiB
C++

#pragma once
// SandboxEnvironmentTemplate (v1beta1): the container recipe a computer use
// or shell sandbox is created from. Create, get, list, delete.
#include <string>
#include <vector>
#include "google/operation.h"
#include "google/sandbox/sandbox_service.h"
namespace molo::google::sandbox {
enum class ContainerCategory { kNone, kComputerUse, kShellSandbox };
struct TemplatePort {
std::string protocol = "TCP"; // TCP or UDP
int port = 0; // 1..65535
};
struct CreateTemplateRequest {
std::string display_name; // Required, 1..128 characters.
// Exactly one of: a default container category, or a custom container image.
ContainerCategory category = ContainerCategory::kNone;
std::string image_uri; // customContainerEnvironment.customContainerSpec.imageUri
std::vector<TemplatePort> ports; // Custom container only, at most 16.
bool internet_access = false; // egressControlConfig.internetAccess
std::string network_attachment; // egressControlConfig.networkAttachment
bool persistent_disk = false; // persistentDiskConfig.enabled
std::string disk_mount_path; // absolute path, plain characters
long disk_size_gb = 0; // 1..1024 when the disk is enabled
};
struct SandboxTemplate {
std::string name;
std::string display_name;
std::string state; // ACTIVE, PROVISIONING, FAILED, ...
std::string create_time;
std::string update_time;
ContainerCategory category = ContainerCategory::kNone;
std::string image_uri;
bool internet_access = false;
clients::body::Json raw; // Whole document, unknown fields kept.
static SandboxTemplate from_json(const clients::body::Json& doc);
clients::body::Json to_json() const;
};
class Templates : public SandboxService {
public:
explicit Templates(std::shared_ptr<GoogleClient> client, Sleeper sleeper = nullptr);
SandboxTemplate create(const std::string& engine_name,
const CreateTemplateRequest& request) const;
SandboxTemplate get(const std::string& template_name) const;
std::vector<SandboxTemplate> list(const std::string& engine_name,
int page_size = 0) const;
// Explicit delete (long-running; waited on, capped).
void remove(const std::string& template_name) const;
static void validate(const CreateTemplateRequest& request);
static clients::body::Json create_body(const CreateTemplateRequest& request);
private:
Sleeper sleeper_;
};
} // namespace molo::google::sandbox