Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

add gcs support

Justin D'Souzad419f6241b95
diff --git a/README.md b/README.md
index 809a9852..fbcf1d90 100644
--- a/README.md
+++ b/README.md
@@ -103,10 +103,11 @@ enterprise-grade SIEMs.
| [Customer-managed SIEM pipelines](https://docs.asymptotelabs.ai/cli/siem-forwarding) | Forwarding from local Beacon JSONL under customer control |
| [Datadog](https://docs.asymptotelabs.ai/cli/siem-forwarding-datadog) | Datadog Agent custom log collection over local JSONL |
| [Elastic](https://docs.asymptotelabs.ai/cli/siem-forwarding-elastic) | Filebeat or Elastic Agent content pack over local JSONL |
+| Google Cloud Storage | Vector content pack over local JSONL using customer-managed Google credentials |
| [Local JSONL](https://docs.asymptotelabs.ai/cli/local-testing-logs) | Default endpoint log and local dashboard source |
| [Microsoft Sentinel](https://docs.asymptotelabs.ai/cli/siem-forwarding-microsoft-sentinel) | Azure Monitor Agent and Data Collection Rule content pack over local JSONL |
| [Rapid7 InsightIDR](https://docs.asymptotelabs.ai/cli/siem-forwarding-rapid7) | Custom Logs webhook content pack over local JSONL |
-| AWS S3 | Vector content pack over local JSONL using customer-managed AWS credentials |
+| [AWS S3](https://docs.asymptotelabs.ai/cli/siem-forwarding-s3) | Vector content pack over local JSONL using customer-managed AWS credentials |
| [Splunk HEC](https://docs.asymptotelabs.ai/cli/siem-forwarding-splunk) | Optional endpoint forwarding during install or repair |
| [Sumo Logic](https://docs.asymptotelabs.ai/cli/siem-forwarding-sumo) | HTTP Logs & Metrics Source content pack over local JSONL |
| [Wazuh](https://docs.asymptotelabs.ai/cli/siem-forwarding-wazuh) | Localfile configuration and Beacon Wazuh content pack |
diff --git a/cli/beacon/README.md b/cli/beacon/README.md
index 72391ca0..0d8ed41b 100644
--- a/cli/beacon/README.md
+++ b/cli/beacon/README.md
@@ -155,6 +155,21 @@ Store AWS credentials, profiles, IAM roles, bucket policies, lifecycle rules,
and encryption settings in AWS, Vector, or deployment tooling, not in Beacon
endpoint configuration.
+## Google Cloud Storage
+
+```bash
+./beacon endpoint gcs print-config
+./beacon endpoint gcs install-pack --output ./beacon-gcs-pack
+./beacon endpoint gcs validate
+```
+
+The GCS pack keeps Beacon as a local JSONL producer and documents forwarding
+`runtime.jsonl` into a Google Cloud Storage bucket with a customer-managed
+Vector host agent. Store Google credentials, service accounts, workload
+identity, bucket IAM, lifecycle rules, retention policies, and encryption
+settings in Google Cloud, Vector, or deployment tooling, not in Beacon endpoint
+configuration.
+
## Microsoft Sentinel
```bash
diff --git a/cli/beacon/cmd/endpoint.go b/cli/beacon/cmd/endpoint.go
index 42ce83db..478084e0 100644
--- a/cli/beacon/cmd/endpoint.go
+++ b/cli/beacon/cmd/endpoint.go
@@ -17,6 +17,7 @@ import (
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/dashboard"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/datadog"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/elastic"
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/gcs"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/harness"
endpointhooks "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/hooks"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/integrations/cowork"
@@ -194,6 +195,11 @@ var endpointS3Cmd = &cobra.Command{
Short: "Manage AWS S3 forwarding content",
}
+var endpointGCSCmd = &cobra.Command{
+ Use: "gcs",
+ Short: "Manage Google Cloud Storage forwarding content",
+}
+
var endpointSentinelCmd = &cobra.Command{
Use: "sentinel",
Short: "Manage Microsoft Sentinel integration content",
@@ -641,6 +647,35 @@ var endpointS3ValidateCmd = &cobra.Command{
RunE: runEndpointS3Validate,
}
+var endpointGCSPrintConfigCmd = &cobra.Command{
+ Use: "print-config",
+ Short: "Print a Google Cloud Storage smoke-test uploader for Beacon endpoint events",
+ SilenceUsage: true,
+ RunE: func(cmd *cobra.Command, args []string) error {
+ cfg := loadOrDefaultConfig()
+ snippet, err := gcs.UploadSmokeTest(cfg.LogPath)
+ if err != nil {
+ return err
+ }
+ fmt.Print(snippet)
+ return nil
+ },
+}
+
+var endpointGCSInstallPackCmd = &cobra.Command{
+ Use: "install-pack",
+ Short: "Write Google Cloud Storage forwarding content to a directory",
+ SilenceUsage: true,
+ RunE: runEndpointGCSInstallPack,
+}
+
+var endpointGCSValidateCmd = &cobra.Command{
+ Use: "validate",
+ Short: "Write and describe a Google Cloud Storage validation event",
+ SilenceUsage: true,
+ RunE: runEndpointGCSValidate,
+}
+
var endpointSentinelPrintConfigCmd = &cobra.Command{
Use: "print-config",
Short: "Print a Sentinel DCR transform for Beacon endpoint events",
@@ -687,6 +722,7 @@ func init() {
endpointCmd.AddCommand(endpointSumoCmd)
endpointCmd.AddCommand(endpointRapid7Cmd)
endpointCmd.AddCommand(endpointS3Cmd)
+ endpointCmd.AddCommand(endpointGCSCmd)
endpointCmd.AddCommand(endpointSentinelCmd)
endpointCmd.AddCommand(endpointIntegrationsCmd)
endpointCmd.AddCommand(endpointHooksCmd)
@@ -713,6 +749,9 @@ func init() {
endpointS3Cmd.AddCommand(endpointS3PrintConfigCmd)
endpointS3Cmd.AddCommand(endpointS3InstallPackCmd)
endpointS3Cmd.AddCommand(endpointS3ValidateCmd)
+ endpointGCSCmd.AddCommand(endpointGCSPrintConfigCmd)
+ endpointGCSCmd.AddCommand(endpointGCSInstallPackCmd)
+ endpointGCSCmd.AddCommand(endpointGCSValidateCmd)
endpointSentinelCmd.AddCommand(endpointSentinelPrintConfigCmd)
endpointSentinelCmd.AddCommand(endpointSentinelInstallPackCmd)
endpointSentinelCmd.AddCommand(endpointSentinelValidateCmd)
@@ -827,6 +866,12 @@ func init() {
c.Flags().StringVar(&endpointOpts.logPath, "log-path", "", "Runtime JSONL log path")
}
endpointS3InstallPackCmd.Flags().StringVar(&endpointOpts.outputDir, "output", "", "Output directory for AWS S3 content pack")
+ for _, c := range []*cobra.Command{endpointGCSPrintConfigCmd, endpointGCSInstallPackCmd, endpointGCSValidateCmd} {
+ c.Flags().BoolVar(&endpointOpts.userMode, "user", true, "Use per-user endpoint paths")
+ c.Flags().BoolVar(&endpointOpts.systemMode, "system", false, "Use system endpoint paths and launch daemon")
+ c.Flags().StringVar(&endpointOpts.logPath, "log-path", "", "Runtime JSONL log path")
+ }
+ endpointGCSInstallPackCmd.Flags().StringVar(&endpointOpts.outputDir, "output", "", "Output directory for Google Cloud Storage content pack")
for _, c := range []*cobra.Command{endpointSentinelPrintConfigCmd, endpointSentinelInstallPackCmd, endpointSentinelValidateCmd} {
c.Flags().BoolVar(&endpointOpts.userMode, "user", true, "Use per-user endpoint paths")
c.Flags().BoolVar(&endpointOpts.systemMode, "system", false, "Use system endpoint paths and launch daemon")
@@ -1305,6 +1350,32 @@ func runEndpointS3Validate(cmd *cobra.Command, args []string) error {
return nil
}
+func runEndpointGCSInstallPack(cmd *cobra.Command, args []string) error {
+ cfg := loadOrDefaultConfig()
+ outputDir := endpointOpts.outputDir
+ if outputDir == "" {
+ outputDir = gcs.DefaultOutputDir
+ }
+ if err := gcs.InstallPack(outputDir, cfg.LogPath); err != nil {
+ return err
+ }
+ fmt.Printf("Google Cloud Storage content pack written to %s\n", outputDir)
+ return nil
+}
+
+func runEndpointGCSValidate(cmd *cobra.Command, args []string) error {
+ cfg := loadOrDefaultConfig()
+ path, err := writeValidationEvent(cfg, "gcs")
+ if err != nil {
+ return err
+ }
+ fmt.Printf("Validation event written to %s\n", path)
+ fmt.Println("Expected GCS fields: vendor=beacon product=endpoint-agent destination.type=gcs destination.mode=google_cloud_storage_jsonl")
+ fmt.Println(`Confirm delivery with Google Cloud CLI: gcloud storage ls "gs://${BEACON_GCS_BUCKET}/${BEACON_GCS_PREFIX}/**"`)
+ fmt.Println(`Inspect an object with Google Cloud CLI: gcloud storage cat "gs://${BEACON_GCS_BUCKET}/${BEACON_GCS_PREFIX}/date=<date>/<object>.jsonl.gz" | gzip -dc | grep "Beacon endpoint GCS validation event"`)
+ return nil
+}
+
func runEndpointSentinelInstallPack(cmd *cobra.Command, args []string) error {
cfg := loadOrDefaultConfig()
outputDir := endpointOpts.outputDir
diff --git a/cli/beacon/cmd/endpoint_diagnostics.go b/cli/beacon/cmd/endpoint_diagnostics.go
index 973d6596..47f10a8f 100644
--- a/cli/beacon/cmd/endpoint_diagnostics.go
+++ b/cli/beacon/cmd/endpoint_diagnostics.go
@@ -576,6 +576,9 @@ func syntheticEvent(destination string) schema.Event {
case "s3":
mode = "aws_s3_jsonl"
message = "Beacon endpoint S3 validation event"
+ case "gcs":
+ mode = "google_cloud_storage_jsonl"
+ message = "Beacon endpoint GCS validation event"
case "sentinel":
mode = "azure_monitor_agent_custom_json_logs"
message = "Beacon endpoint Sentinel validation event"
diff --git a/cli/beacon/cmd/endpoint_test.go b/cli/beacon/cmd/endpoint_test.go
index 26d88f8d..94f69678 100644
--- a/cli/beacon/cmd/endpoint_test.go
+++ b/cli/beacon/cmd/endpoint_test.go
@@ -281,6 +281,30 @@ func TestEndpointS3CommandsRegistered(t *testing.T) {
}
}
+func TestEndpointGCSCommandsRegistered(t *testing.T) {
+ for _, path := range [][]string{
+ {"gcs", "print-config"},
+ {"gcs", "install-pack"},
+ {"gcs", "validate"},
+ } {
+ cmd, _, err := endpointCmd.Find(path)
+ if err != nil {
+ t.Fatalf("Find %v returned error: %v", path, err)
+ }
+ if cmd == nil || cmd.Use != path[len(path)-1] {
+ t.Fatalf("gcs command %v not registered: %#v", path, cmd)
+ }
+ for _, name := range []string{"user", "system", "log-path"} {
+ if cmd.Flags().Lookup(name) == nil {
+ t.Fatalf("gcs command %v missing --%s flag", path, name)
+ }
+ }
+ }
+ if endpointGCSInstallPackCmd.Flags().Lookup("output") == nil {
+ t.Fatal("gcs install-pack command missing --output flag")
+ }
+}
+
func TestEndpointSentinelCommandsRegistered(t *testing.T) {
for _, path := range [][]string{
{"sentinel", "print-config"},
@@ -634,6 +658,14 @@ func TestSyntheticEventDestinations(t *testing.T) {
if s3Event.Message != "Beacon endpoint S3 validation event" {
t.Fatalf("s3 message = %q", s3Event.Message)
}
+
+ gcsEvent := syntheticEvent("gcs")
+ if gcsEvent.Destination.Type != "gcs" || gcsEvent.Destination.Mode != "google_cloud_storage_jsonl" {
+ t.Fatalf("gcs destination = %#v", gcsEvent.Destination)
+ }
+ if gcsEvent.Message != "Beacon endpoint GCS validation event" {
+ t.Fatalf("gcs message = %q", gcsEvent.Message)
+ }
}
func TestEndpointS3ValidatePrintsAWSCLIInspectionGuidance(t *testing.T) {
@@ -671,6 +703,41 @@ func TestEndpointS3ValidatePrintsAWSCLIInspectionGuidance(t *testing.T) {
}
}
+func TestEndpointGCSValidatePrintsGoogleCloudCLIInspectionGuidance(t *testing.T) {
+ oldLogPath := endpointOpts.logPath
+ oldUserMode := endpointOpts.userMode
+ oldSystemMode := endpointOpts.systemMode
+ endpointOpts.logPath = filepath.Join(t.TempDir(), "runtime.jsonl")
+ endpointOpts.userMode = true
+ endpointOpts.systemMode = false
+ t.Cleanup(func() {
+ endpointOpts.logPath = oldLogPath
+ endpointOpts.userMode = oldUserMode
+ endpointOpts.systemMode = oldSystemMode
+ })
+
+ output, err := captureStdout(t, func() error {
+ return runEndpointGCSValidate(endpointGCSValidateCmd, nil)
+ })
+ if err != nil {
+ t.Fatalf("runEndpointGCSValidate returned error: %v", err)
+ }
+ for _, want := range []string{
+ "Validation event written to",
+ "destination.type=gcs destination.mode=google_cloud_storage_jsonl",
+ "gcloud storage ls",
+ "gcloud storage cat",
+ "Beacon endpoint GCS validation event",
+ } {
+ if !strings.Contains(output, want) {
+ t.Fatalf("GCS validation output missing %q: %s", want, output)
+ }
+ }
+ if strings.Contains(output, "verified delivery") {
+ t.Fatalf("GCS validation output should not claim remote delivery verification: %s", output)
+ }
+}
+
func captureStdout(t *testing.T, fn func() error) (string, error) {
t.Helper()
oldStdout := os.Stdout
diff --git a/cli/beacon/internal/endpoint/gcs/gcs.go b/cli/beacon/internal/endpoint/gcs/gcs.go
new file mode 100644
index 00000000..b583e50c
--- /dev/null
+++ b/cli/beacon/internal/endpoint/gcs/gcs.go
@@ -0,0 +1,113 @@
+package gcs
+
+import (
+ "embed"
+ "fmt"
+ "io/fs"
+
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/siempack"
+)
+
+//go:embed pack/*
+var packFS embed.FS
+
+const (
+ DefaultLogPath = "/var/log/beacon-agent/runtime.jsonl"
+ DefaultOutputDir = "beacon-gcs-pack"
+)
+
+type File struct {
+ Name string
+ Content string
+ TemplateLogPath bool
+ JSONEscape bool
+}
+
+// readAsset reads an embedded asset using the module-level packFS and returns its
+// contents or an error.
+func readAsset(path string) (string, error) {
+ data, err := siempack.ReadFile(packFS, path)
+ if err != nil {
+ return "", fmt.Errorf("gcs pack asset %q: %w", path, err)
+ }
+ return data, nil
+}
+
+// mustRead returns the embedded asset at path or panics. Retained for test use
+// where the embedded FS is always present; all production code uses readAsset.
+func mustRead(path string) string {
+ s, err := readAsset(path)
+ if err != nil {
+ panic(err.Error())
+ }
+ return s
+}
+
+// uploadSmokeTestFromFS renders the GCS upload smoke-test script using the supplied FS.
+func uploadSmokeTestFromFS(fsys fs.FS, logPath string) (string, error) {
+ if logPath == "" {
+ logPath = DefaultLogPath
+ }
+ content, err := siempack.ReadFile(fsys, "pack/gcs-upload-smoke-test.sh.tmpl")
+ if err != nil {
+ return "", fmt.Errorf("gcs pack asset %q: %w", "pack/gcs-upload-smoke-test.sh.tmpl", err)
+ }
+ return siempack.RenderLogPath(content, logPath), nil
+}
+
+// filesFromFS builds the full file list from the supplied FS, propagating any
+// read errors instead of panicking. Template substitution of LOG_PATH is
+// deferred to siempack.Install via the TemplateLogPath field.
+func filesFromFS(fsys fs.FS) ([]File, error) {
+ readme, err := siempack.ReadFile(fsys, "pack/README.md")
+ if err != nil {
+ return nil, fmt.Errorf("gcs pack asset %q: %w", "pack/README.md", err)
+ }
+ smokeTest, err := siempack.ReadFile(fsys, "pack/gcs-upload-smoke-test.sh.tmpl")
+ if err != nil {
+ return nil, fmt.Errorf("gcs pack asset %q: %w", "pack/gcs-upload-smoke-test.sh.tmpl", err)
+ }
+ sample, err := siempack.ReadFile(fsys, "pack/sample-event.jsonl")
+ if err != nil {
+ return nil, fmt.Errorf("gcs pack asset %q: %w", "pack/sample-event.jsonl", err)
+ }
+ vector, err := siempack.ReadFile(fsys, "pack/vector.toml.tmpl")
+ if err != nil {
+ return nil, fmt.Errorf("gcs pack asset %q: %w", "pack/vector.toml.tmpl", err)
+ }
+ return []File{
+ {Name: "README.md", Content: readme},
+ {Name: "gcs-upload-smoke-test.sh", Content: smokeTest, TemplateLogPath: true},
+ {Name: "sample-event.jsonl", Content: sample},
+ {Name: "vector.toml", Content: vector, TemplateLogPath: true},
+ }, nil
+}
+
+// Files returns all pack files, propagating any embedded asset read error.
+func Files() ([]File, error) {
+ return filesFromFS(packFS)
+}
+
+// UploadSmokeTest returns the GCS upload smoke-test script with logPath substituted.
+func UploadSmokeTest(logPath string) (string, error) {
+ return uploadSmokeTestFromFS(packFS, logPath)
+}
+
+// InstallPack writes the pack files to outputDir with logPath substituted.
+func InstallPack(outputDir, logPath string) error {
+ if outputDir == "" {
+ outputDir = DefaultOutputDir
+ }
+ if logPath == "" {
+ logPath = DefaultLogPath
+ }
+ files, err := filesFromFS(packFS)
+ if err != nil {
+ return err
+ }
+ sfiles := make([]siempack.File, 0, len(files))
+ for _, file := range files {
+ sfiles = append(sfiles, siempack.File(file))
+ }
+ return siempack.Install(outputDir, sfiles, logPath)
+}
diff --git a/cli/beacon/internal/endpoint/gcs/gcs_test.go b/cli/beacon/internal/endpoint/gcs/gcs_test.go
new file mode 100644
index 00000000..92434717
--- /dev/null
+++ b/cli/beacon/internal/endpoint/gcs/gcs_test.go
@@ -0,0 +1,236 @@
+package gcs
+
+import (
+ "bufio"
+ "encoding/json"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+ "testing/fstest"
+)
+
+func TestUploadSmokeTestUsesConfiguredPath(t *testing.T) {
+ got, err := UploadSmokeTest("/tmp/beacon/runtime.jsonl")
+ if err != nil {
+ t.Fatalf("UploadSmokeTest returned unexpected error: %v", err)
+ }
+ if !strings.Contains(got, "/tmp/beacon/runtime.jsonl") {
+ t.Fatalf("script did not include configured path: %s", got)
+ }
+ if strings.Contains(got, "{{LOG_PATH}}") {
+ t.Fatalf("script still contains template token: %s", got)
+ }
+ for _, want := range []string{
+ "BEACON_GCS_BUCKET",
+ "BEACON_GCS_PREFIX",
+ "gcloud storage cp",
+ "gsutil",
+ "--content-type=\"application/x-ndjson\"",
+ "Application Default Credentials",
+ "validation only",
+ } {
+ if !strings.Contains(got, want) {
+ t.Fatalf("script missing %q: %s", want, got)
+ }
+ }
+}
+
+func TestInstallPackWritesExpectedFiles(t *testing.T) {
+ dir := t.TempDir()
+ if err := InstallPack(dir, "/tmp/beacon/runtime.jsonl"); err != nil {
+ t.Fatalf("InstallPack returned error: %v", err)
+ }
+ for _, name := range []string{"README.md", "gcs-upload-smoke-test.sh", "sample-event.jsonl", "vector.toml"} {
+ if _, err := os.Stat(filepath.Join(dir, name)); err != nil {
+ t.Fatalf("expected %s: %v", name, err)
+ }
+ }
+ scriptPath := filepath.Join(dir, "gcs-upload-smoke-test.sh")
+ script, err := os.ReadFile(scriptPath)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !strings.Contains(string(script), "/tmp/beacon/runtime.jsonl") {
+ t.Fatalf("generated script missing configured log path: %s", script)
+ }
+ info, err := os.Stat(scriptPath)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if info.Mode().Perm()&0111 == 0 {
+ t.Fatalf("generated script should be executable, mode=%s", info.Mode())
+ }
+ vectorPath := filepath.Join(dir, "vector.toml")
+ vectorConfig, err := os.ReadFile(vectorPath)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !strings.Contains(string(vectorConfig), "/tmp/beacon/runtime.jsonl") {
+ t.Fatalf("generated vector config missing configured log path: %s", vectorConfig)
+ }
+ info, err = os.Stat(vectorPath)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if info.Mode().Perm() != 0644 {
+ t.Fatalf("generated vector config should be 0644, mode=%s", info.Mode().Perm())
+ }
+}
+
+func TestVectorConfigUsesGCSCloudStorageSinkAndPreservesJSONShape(t *testing.T) {
+ got := mustRead("pack/vector.toml.tmpl")
+ for _, want := range []string{
+ `include = ["{{LOG_PATH}}"]`,
+ `read_from = "end"`,
+ `. = parse_json!(.message)`,
+ `type = "gcp_cloud_storage"`,
+ `bucket = "${BEACON_GCS_BUCKET}"`,
+ `key_prefix = "${BEACON_GCS_PREFIX:-beacon/runtime}/date=%F/"`,
+ `filename_time_format = "%s"`,
+ `filename_append_uuid = true`,
+ `filename_extension = "jsonl.gz"`,
+ `compression = "gzip"`,
+ `content_encoding = "gzip"`,
+ `content_type = "application/x-ndjson"`,
+ `storage_class = "${BEACON_GCS_STORAGE_CLASS:-STANDARD}"`,
+ `codec = "json"`,
+ `method = "newline_delimited"`,
+ `max_bytes = 10000000`,
+ `retry_attempts = 10`,
+ } {
+ if !strings.Contains(got, want) {
+ t.Fatalf("vector config missing %q: %s", want, got)
+ }
+ }
+}
+
+func TestSampleEventsCoverValidationHookAndOTelShapes(t *testing.T) {
+ scanner := bufio.NewScanner(strings.NewReader(mustRead("pack/sample-event.jsonl")))
+ var sawValidation, sawHook, sawOTel bool
+ for scanner.Scan() {
+ var doc map[string]interface{}
+ if err := json.Unmarshal(scanner.Bytes(), &doc); err != nil {
+ t.Fatalf("sample-event.jsonl is not valid JSONL: %v", err)
+ }
+ if destination, ok := doc["destination"].(map[string]interface{}); ok && destination["type"] == "gcs" {
+ sawValidation = true
+ }
+ if _, ok := doc["tool"].(map[string]interface{}); ok {
+ sawHook = true
+ }
+ if raw, ok := doc["raw"].(map[string]interface{}); ok && raw["otel_signal"] != nil {
+ sawOTel = true
+ }
+ }
+ if err := scanner.Err(); err != nil {
+ t.Fatal(err)
+ }
+ if !sawValidation || !sawHook || !sawOTel {
+ t.Fatalf("sample events should include validation, hook-rich, and OTel shapes; validation=%t hook=%t otel=%t", sawValidation, sawHook, sawOTel)
+ }
+}
+
+func TestPackREADMEMentionsGCSSetupAndProductionForwarding(t *testing.T) {
+ readme := mustRead("pack/README.md")
+ for _, want := range []string{
+ "beacon endpoint gcs validate",
+ "Google Cloud Storage bucket",
+ "Application Default Credentials",
+ "roles/storage.objectCreator",
+ "BEACON_GCS_BUCKET",
+ "BEACON_GCS_PREFIX",
+ "gcloud storage ls",
+ "gcloud storage cat",
+ "Beacon endpoint GCS validation event",
+ "vendor=beacon product=endpoint-agent destination.type=gcs destination.mode=google_cloud_storage_jsonl",
+ "vector.toml",
+ "customer-managed host-agent",
+ "without a Vector wrapper",
+ "content retention",
+ "/var/log/beacon-agent/runtime.jsonl",
+ "Beacon does not store Google Cloud credentials",
+ "encryption",
+ } {
+ if !strings.Contains(readme, want) {
+ t.Fatalf("pack README missing %q", want)
+ }
+ }
+}
+
+func TestFiles_NoError(t *testing.T) {
+ files, err := Files()
+ if err != nil {
+ t.Fatalf("Files() returned unexpected error: %v", err)
+ }
+ if len(files) == 0 {
+ t.Fatal("Files() returned no files")
+ }
+}
+
+func TestFiles_ContainsAllRequiredNames(t *testing.T) {
+ files, err := Files()
+ if err != nil {
+ t.Fatal(err)
+ }
+ names := make(map[string]bool)
+ for _, f := range files {
+ names[f.Name] = true
+ }
+ for _, required := range []string{
+ "README.md", "gcs-upload-smoke-test.sh", "sample-event.jsonl", "vector.toml",
+ } {
+ if !names[required] {
+ t.Errorf("Files() missing required file %q", required)
+ }
+ }
+}
+
+func TestFilesFromFS_PropagatesReadError(t *testing.T) {
+ emptyFS := fstest.MapFS{}
+ _, err := filesFromFS(emptyFS)
+ if err == nil {
+ t.Fatal("filesFromFS with empty FS should return an error")
+ }
+ if !strings.Contains(err.Error(), "gcs pack asset") {
+ t.Fatalf("error should identify the pack source, got: %v", err)
+ }
+}
+
+func TestUploadSmokeTestFromFS_ErrorOnMissingAsset(t *testing.T) {
+ emptyFS := fstest.MapFS{}
+ _, err := uploadSmokeTestFromFS(emptyFS, "/some/path.jsonl")
+ if err == nil {
+ t.Fatal("uploadSmokeTestFromFS with empty FS should return error")
+ }
+ if !strings.Contains(err.Error(), "gcs pack asset") {
+ t.Fatalf("error should identify the pack source, got: %v", err)
+ }
+}
+
+func TestInstallPack_ErrorOnWriteFailure(t *testing.T) {
+ if os.Getuid() == 0 {
+ t.Skip("running as root: filesystem permission restrictions do not apply")
+ }
+ dir := t.TempDir()
+ if err := os.Chmod(dir, 0555); err != nil {
+ t.Skip("cannot set directory permissions:", err)
+ }
+ defer os.Chmod(dir, 0755)
+
+ subdir := filepath.Join(dir, "output")
+ err := InstallPack(subdir, DefaultLogPath)
+ if err == nil {
+ t.Fatal("InstallPack into read-only directory should return error")
+ }
+}
+
+func TestUploadSmokeTest_DefaultLogPath(t *testing.T) {
+ got, err := UploadSmokeTest("")
+ if err != nil {
+ t.Fatalf("UploadSmokeTest with empty path returned error: %v", err)
+ }
+ if !strings.Contains(got, DefaultLogPath) {
+ t.Fatalf("UploadSmokeTest with empty logPath should use DefaultLogPath %q, got: %s", DefaultLogPath, got)
+ }
+}
diff --git a/cli/beacon/internal/endpoint/gcs/pack/README.md b/cli/beacon/internal/endpoint/gcs/pack/README.md
new file mode 100644
index 00000000..6e2254ed
--- /dev/null
+++ b/cli/beacon/internal/endpoint/gcs/pack/README.md
@@ -0,0 +1,151 @@
+# Beacon Endpoint Agent Google Cloud Storage Pack
+
+This pack forwards Beacon endpoint JSONL events into a Google Cloud Storage
+bucket. Beacon still writes one local source of truth: `runtime.jsonl`. Google
+credentials, service accounts, workload identity, bucket IAM, object lifecycle
+rules, retention policies, and encryption stay in Google Cloud, Vector, or
+customer-managed deployment tooling, not in Beacon endpoint configuration.
+
+## Prerequisites
+
+- Beacon endpoint installed and writing local JSONL.
+- A Google Cloud Storage bucket for Beacon runtime logs.
+- A service account or workload identity available through Application Default
+ Credentials for the process running Vector, `gcloud`, or `gsutil`.
+
+Recommended GCS layout:
+
+```text
+gs://example-security-logs/beacon/runtime/date=YYYY-MM-DD/<timestamp>-<uuid>.jsonl.gz
+```
+
+Grant the Vector service identity only the bucket/prefix permissions it needs.
+For a dedicated Beacon bucket, `roles/storage.objectCreator` is usually enough
+for production uploads because it can create objects without listing or reading
+them. Add viewer, retention, CMEK, or bucket-specific conditional IAM only if
+your Google Cloud controls require them. Configure lifecycle, retention,
+versioning, audit logs, and encryption in Google Cloud.
+
+## Install
+
+Generate this pack:
+
+```bash
+beacon endpoint gcs install-pack --output ./beacon-gcs-pack
+```
+
+The generated smoke-test script points at the Beacon log path selected by the
+CLI:
+
+- User mode: `~/.beacon/endpoint/logs/runtime.jsonl`
+- System mode: `/var/log/beacon-agent/runtime.jsonl`
+- Custom mode: the value passed with `--log-path`
+
+For MDM or managed endpoint deployment, prefer Beacon system mode so your
+customer-managed log shipper can tail `/var/log/beacon-agent/runtime.jsonl`
+without per-user home directory ACLs.
+
+The generated `vector.toml` uses the same selected Beacon log path.
+
+## One-Shot Smoke Test
+
+Use the generated script to upload the current file once. This is only for
+validation; do not use it as production forwarding because it re-uploads the
+whole file every time.
+
+```bash
+export BEACON_GCS_BUCKET="example-security-logs"
+export BEACON_GCS_PREFIX="beacon/runtime"
+./beacon-gcs-pack/gcs-upload-smoke-test.sh
+```
+
+The script uses `gcloud storage cp` when available and falls back to `gsutil cp`.
+Both rely on Application Default Credentials, workload identity, active gcloud
+configuration, or your managed endpoint secret tooling. Beacon does not store
+Google Cloud credentials.
+
+Beacon does not store Google Cloud credentials in endpoint configuration or
+generated runtime state.
+
+Confirm the uploaded object:
+
+```bash
+gcloud storage ls "gs://${BEACON_GCS_BUCKET}/${BEACON_GCS_PREFIX}/smoke-tests/"
+gcloud storage cat "gs://${BEACON_GCS_BUCKET}/${BEACON_GCS_PREFIX}/smoke-tests/<object>.jsonl" | grep "Beacon endpoint GCS validation event"
+```
+
+## Production Forwarding
+
+For production, use the generated Vector config as a customer-managed host-agent
+forwarding template. Beacon remains the local JSONL producer; Vector tails
+`runtime.jsonl`, checkpoints file offsets in its `data_dir`, batches Beacon
+events, and writes gzip-compressed newline-delimited JSON objects into Google
+Cloud Storage.
+
+Install Vector using your normal endpoint management tooling, then copy the
+generated config into Vector's config directory. On a macOS system-mode Beacon
+deployment, the generated config tails `/var/log/beacon-agent/runtime.jsonl`:
+
+```bash
+sudo mkdir -p /etc/vector
+sudo cp ./beacon-gcs-pack/vector.toml /etc/vector/beacon-gcs.toml
+export BEACON_GCS_BUCKET="example-security-logs"
+export BEACON_GCS_PREFIX="beacon/runtime"
+vector validate /etc/vector/beacon-gcs.toml
+vector --config /etc/vector/beacon-gcs.toml
+```
+
+In managed deployments, provide `BEACON_GCS_BUCKET`, optional
+`BEACON_GCS_PREFIX`, optional `BEACON_GCS_STORAGE_CLASS`, and any Google
+Application Default Credentials or workload identity settings through the Vector
+service environment, host identity, MDM, or secret tooling. Do not store Google
+Cloud destination secrets in Beacon endpoint configuration.
+
+The Vector template is intentionally simple and expects a Vector version with
+the `file` source, `remap` transform, and `gcp_cloud_storage` sink. It parses
+each Beacon JSONL line and re-encodes the original Beacon event as NDJSON so GCS
+receives one Beacon event per line, without a Vector wrapper.
+
+The template uses date-partitioned `key_prefix`, `filename_time_format = "%s"`,
+and `filename_append_uuid = true` so production forwarding does not overwrite
+previous GCS objects. It also sets `compression = "gzip"`,
+`content_encoding = "gzip"`, and `content_type = "application/x-ndjson"`.
+
+If you adapt the config or use another forwarder, it should:
+
+- checkpoint file offsets,
+- batch newline-delimited JSON records,
+- use non-overwriting object keys,
+- retry transient failures without duplicating the whole file,
+- keep Google credentials, service-account bindings, bucket IAM, lifecycle,
+ retention, and encryption outside Beacon endpoint configuration.
+
+## Validate
+
+Write a fresh Beacon validation event:
+
+```bash
+beacon endpoint gcs validate
+```
+
+Run the one-shot smoke test or wait for your production forwarder to ship the
+new line. Beacon can write the local validation event, but remote delivery must
+be confirmed with Google Cloud tooling:
+
+```bash
+gcloud storage ls "gs://${BEACON_GCS_BUCKET}/${BEACON_GCS_PREFIX}/**"
+gcloud storage cat "gs://${BEACON_GCS_BUCKET}/${BEACON_GCS_PREFIX}/date=<date>/<object>.jsonl.gz" | gzip -dc | grep "Beacon endpoint GCS validation event"
+```
+
+Expected validation fields:
+
+```text
+vendor=beacon product=endpoint-agent destination.type=gcs destination.mode=google_cloud_storage_jsonl
+```
+
+## Content Retention
+
+Beacon content retention defaults to `full`, so prompt text, tool input, command
+output, raw tool payloads, and other retained content may be forwarded to GCS.
+Use Beacon's `metadata` or `redacted` content retention modes for stricter
+deployments.
diff --git a/cli/beacon/internal/endpoint/gcs/pack/gcs-upload-smoke-test.sh.tmpl b/cli/beacon/internal/endpoint/gcs/pack/gcs-upload-smoke-test.sh.tmpl
new file mode 100644
index 00000000..d5d18511
--- /dev/null
+++ b/cli/beacon/internal/endpoint/gcs/pack/gcs-upload-smoke-test.sh.tmpl
@@ -0,0 +1,32 @@
+#!/bin/sh
+set -eu
+
+BEACON_LOG="${BEACON_LOG:-{{LOG_PATH}}}"
+BEACON_GCS_PREFIX="${BEACON_GCS_PREFIX:-beacon/runtime}"
+
+if [ -z "${BEACON_GCS_BUCKET:-}" ]; then
+ echo "BEACON_GCS_BUCKET is required." >&2
+ exit 2
+fi
+
+if [ ! -r "$BEACON_LOG" ]; then
+ echo "Beacon runtime log is not readable: $BEACON_LOG" >&2
+ exit 2
+fi
+
+prefix="${BEACON_GCS_PREFIX%/}"
+timestamp="$(date -u +%Y%m%dT%H%M%SZ)"
+uri="gs://${BEACON_GCS_BUCKET}/${prefix}/smoke-tests/beacon-runtime-${timestamp}.jsonl"
+
+if command -v gcloud >/dev/null 2>&1; then
+ gcloud storage cp "$BEACON_LOG" "$uri" --content-type="application/x-ndjson"
+elif command -v gsutil >/dev/null 2>&1; then
+ gsutil -h "Content-Type:application/x-ndjson" cp "$BEACON_LOG" "$uri"
+else
+ echo "gcloud or gsutil is required for this smoke test." >&2
+ exit 2
+fi
+
+echo "Uploaded one-shot Beacon log copy to $uri"
+echo "Google credentials were resolved by Application Default Credentials or gcloud/gsutil configuration."
+echo "This script is for validation only; use vector.toml for production forwarding."
diff --git a/cli/beacon/internal/endpoint/gcs/pack/vector.toml.tmpl b/cli/beacon/internal/endpoint/gcs/pack/vector.toml.tmpl
new file mode 100644
index 00000000..efe1c5b0
--- /dev/null
+++ b/cli/beacon/internal/endpoint/gcs/pack/vector.toml.tmpl
@@ -0,0 +1,48 @@
+# Beacon Endpoint Agent -> Google Cloud Storage
+#
+# Run Vector as a customer-managed host agent. Keep Google credentials,
+# service-account bindings, workload identity, bucket IAM, lifecycle, retention,
+# and encryption in Google Cloud or deployment tooling, not in Beacon config.
+# This template relies on Google Application Default Credentials.
+
+data_dir = "/var/lib/vector/beacon-gcs"
+
+[sources.beacon_runtime]
+type = "file"
+include = ["{{LOG_PATH}}"]
+read_from = "end"
+
+[transforms.beacon_json]
+type = "remap"
+inputs = ["beacon_runtime"]
+source = '''
+. = parse_json!(.message)
+'''
+
+[sinks.beacon_gcs]
+type = "gcp_cloud_storage"
+inputs = ["beacon_json"]
+bucket = "${BEACON_GCS_BUCKET}"
+key_prefix = "${BEACON_GCS_PREFIX:-beacon/runtime}/date=%F/"
+filename_time_format = "%s"
+filename_append_uuid = true
+filename_extension = "jsonl.gz"
+compression = "gzip"
+content_encoding = "gzip"
+content_type = "application/x-ndjson"
+storage_class = "${BEACON_GCS_STORAGE_CLASS:-STANDARD}"
+
+[sinks.beacon_gcs.encoding]
+codec = "json"
+
+[sinks.beacon_gcs.framing]
+method = "newline_delimited"
+
+[sinks.beacon_gcs.batch]
+max_bytes = 10000000
+timeout_secs = 300
+
+[sinks.beacon_gcs.request]
+retry_attempts = 10
+retry_initial_backoff_secs = 1
+retry_max_duration_secs = 300