Skip to content

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

Polish cloud telemetry object uploads

shukieshaha1026e46a2d6
diff --git a/cli/beacon-hooks/internal/cloudshuttle/shuttle.go b/cli/beacon-hooks/internal/cloudshuttle/shuttle.go
index f05e812f..89cfdb82 100644
--- a/cli/beacon-hooks/internal/cloudshuttle/shuttle.go
+++ b/cli/beacon-hooks/internal/cloudshuttle/shuttle.go
@@ -31,7 +31,7 @@ const (
defaultStatePath = "/tmp/beacon/shuttle-state.json"
defaultTokenURI = "https://oauth2.googleapis.com/token"
defaultGCSEndpoint = "https://storage.googleapis.com"
- contentTypeJSONL = "application/x-ndjson"
+ contentTypeJSONL = "text/plain; charset=utf-8"
)
var httpClient = http.DefaultClient
@@ -76,15 +76,16 @@ func ConfigFromEnv() Config {
interval = parsed
}
}
+ statePath := firstEnvDefault(defaultStatePath, "BEACON_CLOUD_SHUTTLE_STATE")
return Config{
LogPath: firstEnvDefault(defaultLogPath, "BEACON_CLOUD_LOG_PATH", "BEACON_ENDPOINT_LOG", "BEACON_LOG_PATH", "BEACON_RUNTIME_LOG"),
- StatePath: firstEnvDefault(defaultStatePath, "BEACON_CLOUD_SHUTTLE_STATE"),
+ StatePath: statePath,
Bucket: strings.TrimSpace(os.Getenv("BEACON_CLOUD_GCS_BUCKET")),
Prefix: strings.Trim(strings.TrimSpace(os.Getenv("BEACON_CLOUD_GCS_PREFIX")), "/"),
CredentialsB64: strings.TrimSpace(os.Getenv("BEACON_CLOUD_GCS_CREDENTIALS_B64")),
Interval: interval,
Provider: firstEnvDefault("claude_code_web", "BEACON_RUN_PROVIDER"),
- RunID: firstEnvDefault(fmt.Sprintf("manual-%d", time.Now().UTC().UnixNano()), "BEACON_RUN_ID", "CLAUDE_CODE_REMOTE_SESSION_ID"),
+ RunID: firstEnvDefault(stableFallbackRunID(statePath), "BEACON_RUN_ID", "CLAUDE_CODE_REMOTE_SESSION_ID"),
UserID: firstEnvDefault("unknown", "BEACON_CLOUD_USER_ID_HASH", "BEACON_CLOUD_USER_ID"),
Repository: firstEnv("BEACON_RUN_REPOSITORY"),
GCSEndpoint: firstEnvDefault(defaultGCSEndpoint, "BEACON_CLOUD_GCS_ENDPOINT"),
@@ -364,6 +365,20 @@ func writeState(path string, st state) error {
return os.WriteFile(path, data, 0644)
}
+func stableFallbackRunID(statePath string) string {
+ path := statePath + ".run-id"
+ if data, err := os.ReadFile(path); err == nil {
+ if value := strings.TrimSpace(string(data)); value != "" {
+ return value
+ }
+ }
+ value := fmt.Sprintf("manual-%d", time.Now().UTC().UnixNano())
+ if err := os.MkdirAll(filepath.Dir(path), 0755); err == nil {
+ _ = os.WriteFile(path, []byte(value+"\n"), 0644)
+ }
+ return value
+}
+
func cleanKeyParts(value string) []string {
var parts []string
for _, part := range strings.Split(strings.Trim(value, "/"), "/") {
diff --git a/cli/beacon-hooks/internal/cloudshuttle/shuttle_test.go b/cli/beacon-hooks/internal/cloudshuttle/shuttle_test.go
index 41daf73b..95314be6 100644
--- a/cli/beacon-hooks/internal/cloudshuttle/shuttle_test.go
+++ b/cli/beacon-hooks/internal/cloudshuttle/shuttle_test.go
@@ -118,6 +118,15 @@ func TestUploadRespectsInterval(t *testing.T) {
}
}
+func TestStableFallbackRunIDReusesGeneratedValue(t *testing.T) {
+ statePath := filepath.Join(t.TempDir(), "shuttle-state.json")
+ first := stableFallbackRunID(statePath)
+ second := stableFallbackRunID(statePath)
+ if first == "" || second == "" || first != second {
+ t.Fatalf("fallback run id not stable: first=%q second=%q", first, second)
+ }
+}
+
func mustRSAKey(t *testing.T) *rsa.PrivateKey {
t.Helper()
key, err := rsa.GenerateKey(rand.Reader, 2048)
diff --git a/examples/cloud-agents/claude-web-gcs.md b/examples/cloud-agents/claude-web-gcs.md
index 04f25190..a9a1fc19 100644
--- a/examples/cloud-agents/claude-web-gcs.md
+++ b/examples/cloud-agents/claude-web-gcs.md
@@ -9,7 +9,7 @@ The flow is local-only inside the cloud sandbox until upload time:
1. Claude Code on the web starts a cloud VM and clones the repository.
2. The Claude environment setup script installs Beacon hook tooling into
`/tmp/beacon/bin`.
-3. Project-level `.claude/settings.json` is generated inside the sandbox clone.
+3. Project-level `.claude/settings.local.json` is generated inside the sandbox clone.
4. Hooks write Beacon JSONL to `/tmp/beacon/runtime.jsonl`.
5. Beacon periodically uploads the latest snapshot to GCS.
@@ -88,10 +88,10 @@ chmod +x /tmp/beacon/bin/beacon /tmp/beacon/bin/beacon-hooks
mkdir -p .claude
/tmp/beacon/bin/beacon cloud claude-web print-hooks \
--binary-path /tmp/beacon/bin/beacon-hooks \
- --log-path /tmp/beacon/runtime.jsonl > .claude/settings.json
+ --log-path /tmp/beacon/runtime.jsonl > .claude/settings.local.json
```
-The generated `.claude/settings.json` lives only in the cloud sandbox clone
+The generated `.claude/settings.local.json` lives only in the cloud sandbox clone
unless the agent explicitly commits it.
## 3. Run and Verify
@@ -110,6 +110,10 @@ gcloud storage cp "gs://${BEACON_TEST_BUCKET}/${BEACON_CLOUD_GCS_PREFIX}/provide
head -20 /tmp/beacon-cloud-runtime.jsonl
```
+Uploaded objects use a text content type so the GCS console and authenticated
+object URLs can display the JSONL directly instead of forcing an NDJSON
+download.
+
Expected fields include `vendor=beacon`, `product=endpoint-agent`,
`schema_version=1.0`, `origin=cloud`, `harness.name=claude`,
`run.provider=claude_code_web`, and a `run.run_id` matching the Claude remote