osborn 0.9.48 → 0.9.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,229 @@
1
+ # Voice Native Sync Skill
2
+
3
+ ## SKILL IDENTITY
4
+ Name: voice-native-sync
5
+ Install path: ~/.claude/skills/voice-native-sync/SKILL.md
6
+
7
+ ## TRIGGER PHRASES
8
+ This skill activates when the user says any of:
9
+ - "upload to voice native"
10
+ - "download from voice native"
11
+ - "sync to voice native"
12
+ - "push sessions to voice native"
13
+ - "pull sessions from voice native"
14
+ - "sync my sessions"
15
+
16
+ When triggered, follow the instructions below immediately without asking for clarification,
17
+ unless credentials are missing (see CREDENTIALS section).
18
+
19
+ ---
20
+
21
+ ## SELF-INSTALL
22
+ If the user asks you to install this skill or you fetched this file from a URL,
23
+ save it to: ~/.claude/skills/voice-native-sync/SKILL.md
24
+
25
+ ```bash
26
+ mkdir -p ~/.claude/skills/voice-native-sync
27
+ # then write this file's content to ~/.claude/skills/voice-native-sync/SKILL.md
28
+ ```
29
+
30
+ After saving, confirm: "Voice Native sync skill installed. Use 'upload to voice native' or 'download from voice native' any time."
31
+
32
+ ---
33
+
34
+ ## CREDENTIALS
35
+ Credentials are stored at: ~/.claude/skills/voice-native-sync/config
36
+
37
+ Config file format:
38
+ ```
39
+ CLOUD_URL=https://osborn-XXXX.fly.dev
40
+ TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
41
+ ```
42
+
43
+ If the config file doesn't exist:
44
+ 1. Tell the user: "I need your Voice Native sync credentials. Go to voice-native.com → Settings → Copy sync info, then paste it here."
45
+ 2. Parse the pasted block for CLOUD_URL (the "Server:" line) and TOKEN (the "Token:" line)
46
+ 3. Save to ~/.claude/skills/voice-native-sync/config
47
+ 4. Proceed with the requested operation
48
+
49
+ ---
50
+
51
+ ## UPLOAD (Local → Voice Native Cloud)
52
+
53
+ Uploads all local Claude session files to the Voice Native fly machine.
54
+ Uses chunked upload + finalize. Safe to re-run — mtime-newer-wins per file.
55
+
56
+ ### Execute as a single script (one permission prompt):
57
+
58
+ ```bash
59
+ set -e
60
+
61
+ # Load credentials
62
+ source ~/.claude/skills/voice-native-sync/config
63
+
64
+ TARGET_PATH="/workspace"
65
+
66
+ rm -f /tmp/vn-sync.tar.gz /tmp/vn-chunk-*
67
+
68
+ # Archive local Claude projects (exclude macOS AppleDouble files)
69
+ tar -czf /tmp/vn-sync.tar.gz \
70
+ $(uname | grep -qi darwin && echo '--exclude=._*') \
71
+ -C "$HOME/.claude" projects
72
+
73
+ echo "archive: $(du -sh /tmp/vn-sync.tar.gz | cut -f1)"
74
+
75
+ # Split into 50MB chunks
76
+ split -b 50m /tmp/vn-sync.tar.gz /tmp/vn-chunk-
77
+ CHUNKS=(/tmp/vn-chunk-*)
78
+ TOTAL=${#CHUNKS[@]}
79
+ echo "chunks: $TOTAL"
80
+
81
+ # Generate upload ID (works on Linux and macOS)
82
+ if command -v uuidgen &>/dev/null; then
83
+ UPLOAD_ID=$(uuidgen | tr '[:upper:]' '[:lower:]')
84
+ else
85
+ UPLOAD_ID=$(cat /proc/sys/kernel/random/uuid 2>/dev/null || python3 -c "import uuid; print(uuid.uuid4())")
86
+ fi
87
+ echo "upload id: $UPLOAD_ID"
88
+
89
+ # Upload chunks
90
+ idx=0
91
+ for chunk in "${CHUNKS[@]}"; do
92
+ echo "uploading chunk $idx / $((TOTAL-1))..."
93
+ STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
94
+ -H "Authorization: Bearer $TOKEN" \
95
+ -H "Content-Type: application/octet-stream" \
96
+ --data-binary "@${chunk}" \
97
+ "${CLOUD_URL}/sessions/import-chunk?uploadId=${UPLOAD_ID}&chunk=${idx}")
98
+ echo " chunk $idx → HTTP $STATUS"
99
+ idx=$((idx+1))
100
+ done
101
+
102
+ # Finalize — merges chunks and extracts WITHOUT slug remapping.
103
+ # IMPORTANT: do NOT pass `targetWorkDir`. The server-side remap collapses every
104
+ # source slug into the target work dir's slug, which causes session-resume to
105
+ # silently break when sessions are uploaded from different hosts (Mac, Codespace,
106
+ # Sprite) — they all end up in -workspace, the JSONLs internally still reference
107
+ # their original cwd, the slug↔cwd no longer match, and Claude Code's resume
108
+ # can't find the file. Confirmed 2026-05-27: a codespace upload remapped
109
+ # -workspaces-codespaces-blank → -workspace and every codespace session went
110
+ # silent on resume. The fix is to preserve each upload's original slug structure.
111
+ echo "finalizing..."
112
+ RESULT=$(curl -s -X POST \
113
+ -H "Authorization: Bearer $TOKEN" \
114
+ "${CLOUD_URL}/sessions/import-finalize?uploadId=${UPLOAD_ID}&total=${TOTAL}")
115
+ echo "finalize result: $RESULT"
116
+
117
+ # Cleanup
118
+ rm -f /tmp/vn-sync.tar.gz /tmp/vn-chunk-*
119
+
120
+ # Verify
121
+ echo "verifying manifest..."
122
+ curl -s -H "Authorization: Bearer $TOKEN" "${CLOUD_URL}/sessions/manifest" | \
123
+ python3 -c "
124
+ import json,sys
125
+ d=json.load(sys.stdin)
126
+ slugs=d.get('slugs',{})
127
+ total=sum(len(v.get('files',{})) for v in slugs.values())
128
+ print(f' cloud now has {len(slugs)} slug(s), {total} total files')
129
+ for slug,info in slugs.items():
130
+ files=info.get('files',{})
131
+ print(f' {slug}: {len(files)} files')
132
+ "
133
+ ```
134
+
135
+ ---
136
+
137
+ ## DOWNLOAD (Voice Native Cloud → Local)
138
+
139
+ Downloads all sessions from the Voice Native fly machine and merges into local ~/.claude/projects/.
140
+ Mtime-newer-wins — local files newer than cloud are preserved.
141
+
142
+ ### Execute as a single script:
143
+
144
+ ```bash
145
+ set -e
146
+
147
+ # Load credentials
148
+ source ~/.claude/skills/voice-native-sync/config
149
+
150
+ # Get local working directory for slug remapping
151
+ LOCAL_CWD="$(pwd)"
152
+ echo "local target cwd: $LOCAL_CWD"
153
+
154
+ rm -f /tmp/vn-download.tar.gz
155
+
156
+ # Download full export from fly machine
157
+ echo "downloading from $CLOUD_URL..."
158
+ curl -f -L \
159
+ -H "Authorization: Bearer $TOKEN" \
160
+ "${CLOUD_URL}/sessions/export" \
161
+ -o /tmp/vn-download.tar.gz
162
+ echo "downloaded: $(du -sh /tmp/vn-download.tar.gz | cut -f1)"
163
+
164
+ # Import with slug remapping to local cwd
165
+ echo "importing..."
166
+ # Same fix as upload: no targetWorkDir, preserve original slug structure.
167
+ RESULT=$(curl -s -X POST \
168
+ -H "Authorization: Bearer $TOKEN" \
169
+ -H "Content-Type: application/octet-stream" \
170
+ --data-binary "@/tmp/vn-download.tar.gz" \
171
+ "${CLOUD_URL}/sessions/import")
172
+ echo "import result: $RESULT"
173
+
174
+ rm -f /tmp/vn-download.tar.gz
175
+
176
+ echo "done — sessions merged into ~/.claude/projects/"
177
+ ```
178
+
179
+ Wait — the DOWNLOAD direction means pulling from cloud to THIS local machine.
180
+ The import endpoint runs on the cloud. For download to local, use this instead:
181
+
182
+ ```bash
183
+ set -e
184
+ source ~/.claude/skills/voice-native-sync/config
185
+
186
+ LOCAL_CWD="$(pwd)"
187
+ rm -f /tmp/vn-download.tar.gz
188
+
189
+ echo "downloading export from $CLOUD_URL..."
190
+ curl -f -H "Authorization: Bearer $TOKEN" \
191
+ "${CLOUD_URL}/sessions/export" \
192
+ -o /tmp/vn-download.tar.gz
193
+ echo "downloaded: $(du -sh /tmp/vn-download.tar.gz | cut -f1)"
194
+
195
+ # Extract archive
196
+ mkdir -p /tmp/vn-extract
197
+ tar -xzf /tmp/vn-download.tar.gz -C /tmp/vn-extract
198
+
199
+ # Remap and merge into local ~/.claude/projects/
200
+ LOCAL_SLUG=$(echo "$LOCAL_CWD" | sed 's|/|-|g')
201
+ PROJECTS_DIR="$HOME/.claude/projects"
202
+ mkdir -p "${PROJECTS_DIR}/${LOCAL_SLUG}"
203
+
204
+ echo "merging into ${PROJECTS_DIR}/${LOCAL_SLUG}..."
205
+ for slug_dir in /tmp/vn-extract/projects/*/; do
206
+ slug=$(basename "$slug_dir")
207
+ for f in "${slug_dir}"*.jsonl "${slug_dir}"*.jsonl.* 2>/dev/null; do
208
+ [ -f "$f" ] || continue
209
+ fname=$(basename "$f")
210
+ dest="${PROJECTS_DIR}/${LOCAL_SLUG}/${fname}"
211
+ if [ ! -f "$dest" ] || [ "$f" -nt "$dest" ]; then
212
+ cp "$f" "$dest"
213
+ echo " wrote $fname"
214
+ fi
215
+ done
216
+ done
217
+
218
+ rm -rf /tmp/vn-download.tar.gz /tmp/vn-extract
219
+ echo "done — sessions available at ${PROJECTS_DIR}/${LOCAL_SLUG}/"
220
+ ```
221
+
222
+ ---
223
+
224
+ ## TECHNICAL NOTES
225
+ - Cloud target path is always `/workspace` (Fly.io machines)
226
+ - Slug remapping is automatic on upload (source slug → /workspace slug)
227
+ - Mtime-newer-wins: re-syncing is always safe, newer file wins per-file
228
+ - gzip only — never use zstd (server doesn't support it)
229
+ - macOS: always pass `--exclude='._*'` to tar (BSD tar emits AppleDouble files)
@@ -31,7 +31,7 @@
31
31
  # - Path layout: chroot /workspace/root-chroot/root/... vs /workspace/home/...
32
32
  # Subagent research confirmed chroot in our codebase solves only HOME-and-persistence
33
33
  # layout, NOT library access (Linux dynamic linker is mount-agnostic per ld.so(8)).
34
- # Since HOME=/workspace/home achieves the same persistence with ~100 fewer LOC and
34
+ # Since HOME=/workspace achieves the same persistence with ~100 fewer LOC and
35
35
  # no bind-mount complexity, the chroot version was retired.
36
36
  # Archive: docs/archive/Dockerfile.sandbox.chroot-2026-05-28.md
37
37
 
@@ -63,14 +63,45 @@ ENV OSBORN_API_PORT=8741
63
63
  ENV NODE_ENV=production
64
64
  ENV OSBORN_IMAGE_VERSION=${OSBORN_VERSION}
65
65
 
66
- # THE KEY DIFFERENCE FROM CHROOT VARIANT:
67
- # HOME and OSBORN_CWD are set as IMAGE-LEVEL ENV here. The entrypoint reads
68
- # them, ensures the dirs exist on the volume, and execs osborn. No bind-mount
69
- # trickery HOME just IS on the volume because the path resolves to a volume
70
- # subdir.
71
- ENV HOME=/workspace/home
66
+ # HOME=/workspace the volume mount point itself is the home directory.
67
+ # This means ~/.claude resolves to /workspace/.claude, which is EXACTLY where
68
+ # the legacy symlink architecture (/root/.claude -> /workspace/.claude) already
69
+ # put credentials and sessions. So there is ZERO migration: an existing machine
70
+ # updating to this image finds its data already at ~/.claude with no file moves.
71
+ #
72
+ # Why not /workspace/home (the earlier Option D choice)? That required MOVING
73
+ # legacy data from /workspace/.claude into /workspace/home/.claude — an `mv`
74
+ # loop that is destructive (deletes source as it goes), non-atomic across
75
+ # multiple files (interruption = split state), and catastrophic if HOME ever
76
+ # resolved off-volume (mv would send data to the ephemeral overlay). Pointing
77
+ # HOME at /workspace eliminates the migration entirely: nothing moves, so
78
+ # nothing can be lost in a move. The only cosmetic cost is dotfiles sitting at
79
+ # the volume root — identical to what the legacy symlink effectively did.
80
+ #
81
+ # NOTE on overrides: these are Dockerfile ENV *defaults*. A Fly machine-config
82
+ # `env.HOME` (or app secret) OVERRIDES them at runtime. updateOsborn strips
83
+ # HOME/OSBORN_CWD from existing machine configs during image-swap so this
84
+ # default actually takes effect on migrated machines — without that, a stale
85
+ # HOME=/root from an older provisioning would silently win. See
86
+ # frontend/src/lib/machines.ts updateOsbornImpl.
87
+ ENV HOME=/workspace
72
88
  ENV OSBORN_CWD=/workspace
73
89
 
90
+ # HYBRID: user-installed global npm packages persist on the volume.
91
+ # osborn itself was already installed above into the DEFAULT prefix (/usr/local,
92
+ # image layer) — that RUN happened BEFORE this ENV, so osborn stays in the image
93
+ # and updates via image-swap (atomic, no runtime OOM, toolchain present at build).
94
+ # Setting NPM_CONFIG_PREFIX here only affects RUNTIME `npm install -g <x>` the
95
+ # user/agent runs: those land in /workspace/.npm-global on the persistent volume
96
+ # and survive restarts + image-swaps. PATH puts that bin dir first so installed
97
+ # CLIs are immediately runnable. Verified end-to-end on real Fly 2026-06-01:
98
+ # pure-JS (cowsay) AND native-compiled (node-pty via node-gyp) both install at
99
+ # runtime, persist across restart, no OOM (toolchain is in the image).
100
+ # Caveat: native user modules are tied to the image's Node ABI (currently 22) —
101
+ # a future Node-major image bump would need an `npm rebuild` of volume globals.
102
+ ENV NPM_CONFIG_PREFIX=/workspace/.npm-global
103
+ ENV PATH=/workspace/.npm-global/bin:$PATH
104
+
74
105
  WORKDIR /workspace
75
106
  EXPOSE 8741
76
107
 
@@ -95,34 +126,23 @@ exec > >(tee -a "$LOGFILE") 2>&1
95
126
  ONBOARDING_JSON='{"numStartups":10,"installMethod":"npm","autoUpdates":false,"hasCompletedOnboarding":true,"hasTrustDialogAccepted":true,"hasTrustDialogHooksAccepted":true,"hasCompletedProjectOnboarding":true,"hasAcknowledgedCostThreshold":true,"effortCalloutV2Dismissed":true,"theme":"dark","projects":{"/workspace":{"hasTrustDialogAccepted":true,"hasTrustDialogHooksAccepted":true,"hasCompletedProjectOnboarding":true}}}'
96
127
 
97
128
  # ============================================================
98
- # === HOME-on-volume seed ===
129
+ # === HOME-on-volume setup (HOME=/workspace) ===
99
130
  # ============================================================
100
- # HOME=/workspace/home, set via ENV in Dockerfile. Ensure the dir exists on
101
- # the volume and seed Claude/onboarding/skills on first boot. Idempotent.
102
- echo "[sandbox-d] HOME=$HOME OSBORN_CWD=$OSBORN_CWD"
131
+ # HOME=/workspace, set via ENV in Dockerfile (and enforced by updateOsborn
132
+ # stripping any stale HOME from existing machine configs). Because HOME is the
133
+ # volume mount itself, ~/.claude == /workspace/.claude — which is exactly where
134
+ # the legacy symlink architecture already stored credentials + sessions.
135
+ #
136
+ # THEREFORE: NO MIGRATION. An existing machine's data is already at ~/.claude
137
+ # the instant HOME points at /workspace. We removed the old `mv` migration
138
+ # block entirely (it was destructive + non-atomic + catastrophic if HOME ever
139
+ # resolved off-volume). Nothing moves, so nothing can be lost in a move.
140
+ echo "[sandbox-d] HOME=$HOME OSBORN_CWD=$OSBORN_CWD NPM_CONFIG_PREFIX=$NPM_CONFIG_PREFIX"
103
141
  mkdir -p "$HOME" "$HOME/.claude" "$HOME/.osborn"
104
-
105
- # === Legacy migration ===
106
- # Existing production sandboxes have credentials at /workspace/.claude/
107
- # (the pre-D legacy symlink architecture). Migrate to HOME=/workspace/home/.claude/
108
- # on first boot of the D image. Atomic mv — safe.
109
- if [ -d /workspace/.claude ] && [ ! -d "$HOME/.claude/projects" ] && [ ! -f "$HOME/.claude/.credentials.json" ]; then
110
- echo "[sandbox-d] migrating legacy /workspace/.claude → \$HOME/.claude"
111
- # Move CONTENTS, not the dir itself (target may already exist with seeded skills)
112
- for item in /workspace/.claude/.* /workspace/.claude/*; do
113
- [ -e "$item" ] || continue
114
- BASENAME=$(basename "$item")
115
- [ "$BASENAME" = "." ] && continue
116
- [ "$BASENAME" = ".." ] && continue
117
- [ -e "$HOME/.claude/$BASENAME" ] && continue
118
- mv "$item" "$HOME/.claude/$BASENAME" 2>/dev/null || true
119
- done
120
- rmdir /workspace/.claude 2>/dev/null || true
121
- fi
122
- if [ -f /workspace/.claude.json ] && [ ! -f "$HOME/.claude.json" ]; then
123
- echo "[sandbox-d] migrating legacy /workspace/.claude.json → \$HOME/.claude.json"
124
- mv /workspace/.claude.json "$HOME/.claude.json"
125
- fi
142
+ # HYBRID: ensure the volume-backed npm global prefix exists so user
143
+ # `npm install -g <x>` has a target on first use (npm would create it anyway,
144
+ # but pre-making it keeps perms predictable + visible in the boot log).
145
+ mkdir -p /workspace/.npm-global
126
146
 
127
147
  # Onboarding config (overwrites every boot — intentional, deterministic state)
128
148
  echo "$ONBOARDING_JSON" > "$HOME/.claude.json"
package/dist/index.js CHANGED
@@ -2527,6 +2527,30 @@ async function main() {
2527
2527
  currentLLM = null;
2528
2528
  clearFastBrainSession();
2529
2529
  clearPipelineFastBrainSession();
2530
+ // ── Ghost-agent fix (2026-06-01) ──
2531
+ // When LiveKit Cloud evicts our WebSocket (idle, network blip, or quota window),
2532
+ // the previous code stopped here — agent process kept running but no longer in
2533
+ // any room. /health continued returning "livekit.status:connected" because the
2534
+ // status was never written back. Frontend's checkOsbornHealth only validates
2535
+ // HTTP 200, so the ghost state was invisible. Users got stuck in "Connecting..."
2536
+ // forever because their LiveKit-token-minted room had no agent in it.
2537
+ //
2538
+ // Fix: re-arm the retry loop. connectWithRetry() will try to reconnect with
2539
+ // the same room name (so the room code stays stable for any in-flight frontend
2540
+ // token requests), backing off 5s → 60s. If the disconnect was permanent
2541
+ // (e.g. JWT expired — they're 24h), the retry will fail and surface
2542
+ // livekit.status=failed, which the (also-fixed) frontend health check will
2543
+ // see and trigger restartService.
2544
+ //
2545
+ // Note: we mark status='retrying' immediately so /health reflects the real
2546
+ // state — closing the lie window between Disconnected and the next attempt.
2547
+ livekitState.status = 'retrying';
2548
+ livekitState.error = 'LiveKit room disconnected; attempting to rejoin';
2549
+ livekitState.errorCode = 'disconnected';
2550
+ console.log('🔄 Rejoining LiveKit room after disconnect...');
2551
+ connectWithRetry().catch(err => {
2552
+ console.error('❌ Reconnect attempt threw (should not happen — connectWithRetry loops):', err);
2553
+ });
2530
2554
  });
2531
2555
  room.on(RoomEvent.ParticipantConnected, async (participant) => {
2532
2556
  console.log(`\n👤 User joined: ${participant.identity}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "osborn",
3
- "version": "0.9.48",
3
+ "version": "0.9.49",
4
4
  "description": "Voice AI coding assistant - local agent that connects to Osborn frontend",
5
5
  "type": "module",
6
6
  "bin": {