osborn 0.9.276 → 0.9.277

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.
@@ -115,7 +115,7 @@ Personal values are NOT stored in this skill. They live in a local secret file t
115
115
  | City / State / Zip | `$CANDIDATE_CITY` / `$CANDIDATE_STATE` / `$CANDIDATE_ZIP` |
116
116
 
117
117
  Jobs:
118
- 1. Meta API Consultant at Prehype / Audos — April 2024 to Present
118
+ 1. Senior Engineer at Acme Corp — April 2024 to Present
119
119
  2. Full Stack Developer, Freelance — January 2016 to Present
120
120
 
121
121
  Education:
@@ -34,7 +34,7 @@ export interface ClientRedactor {
34
34
  export interface RedactorOptions {
35
35
  /**
36
36
  * PER-PIECE opt-in un-redaction: denylisted terms to leave visible for ONE
37
- * named draft/render (e.g. reveal: ["Audos"]). Never used by extraction —
37
+ * named draft/render (e.g. reveal: ["Acme"]). Never used by extraction —
38
38
  * the profile and samples are always stored fully redacted. A renderer that
39
39
  * reveals re-pulls the quote rows from session.db by row # and redacts them
40
40
  * with this option, in memory, for that piece only.
package/dist/index.js CHANGED
@@ -42,7 +42,7 @@ import { createClaudeLLM, NAMED_AGENTS, applyTurbo, requestAuthRestart } from '.
42
42
  import { clearPipelineFastBrainSession, prewarmBM25Index } from './pipeline-fastbrain.js';
43
43
  import { ensureClaudeAuth, applyAuthFallback, replayInFlightAuth, startClaudeAuthOnDemand, isOnDemandAuthInFlight } from './claude-auth.js';
44
44
  import { statusManager } from './status-manager.js';
45
- import { decideNextSession, planSwitch, resolveSessionCwd, keepNonConversationItems, recoverySessionId as pickRecoverySessionId, warmParkKey, sessionMessagesDir, createSwitchGuard, scanSlugCwd } from './session-switch.js';
45
+ import { decideNextSession, planSwitch, resolveSessionCwd, keepNonConversationItems, recoverySessionId as pickRecoverySessionId, warmParkKey, sessionMessagesDir, createSwitchGuard, scanSlugCwd, pickConnectWorkingDir } from './session-switch.js';
46
46
  import { createSmitheryProxy, destroySmitheryProxy, parseSmitheryUrl, isSmitheryUrl, SmitheryAuthorizationError } from './smithery-proxy.js';
47
47
  import { DIRECT_MODE_PROMPT } from './prompts.js';
48
48
  import { MCP_CATALOG } from './config.js';
@@ -5095,26 +5095,40 @@ async function main() {
5095
5095
  if (Number.isFinite(c) && c > 0)
5096
5096
  connectTiming.clickTs = c;
5097
5097
  }
5098
- // Read working directory override from frontend.
5098
+ // Working directory for this connection (resume-mismatch fix, #112).
5099
5099
  //
5100
- // If the path doesn't exist yet (new project on first use, or freshly
5101
- // imported sessions on a new sprite), create it with mkdirSync so the
5102
- // agent can accept it. This is safe: recursive mkdirSync is a no-op when
5103
- // the directory already exists, and project paths always live under the
5104
- // workspace root. The Claude SDK child_process.spawn requires the cwd to
5105
- // exist — mkdirSync satisfies that requirement without silently falling back.
5106
- if (metadata.workingDirectory && typeof metadata.workingDirectory === 'string' && metadata.workingDirectory.length > 0) {
5107
- if (!existsSync(metadata.workingDirectory)) {
5108
- mkdirSync(metadata.workingDirectory, { recursive: true });
5109
- console.log(`📁 Created project directory: ${metadata.workingDirectory}`);
5110
- }
5111
- workingDir = metadata.workingDirectory;
5112
- console.log(`📂 Working directory from frontend: ${workingDir}`);
5100
+ // The client's workingDirectory is only a HINT. When a session is pre-
5101
+ // selected, the agent is AUTHORITATIVE about where that session lives:
5102
+ // resolve its real project dir (the only dir whose slug holds the
5103
+ // session's JSONL) and boot there, so `--resume <id>` finds it instead of
5104
+ // coming up in /workspace root — or silently as a different session —
5105
+ // when the hint is stale or empty (e.g. a switch rewrote the URL without
5106
+ // a cwd). resolveCwdForSession returns null only when the JSONL exists
5107
+ // nowhere yet (fresh sprite / brand-new project), in which case the hint
5108
+ // is honoured and created so the SDK spawn still has a valid cwd.
5109
+ const wdHint = (metadata.workingDirectory && typeof metadata.workingDirectory === 'string' && metadata.workingDirectory.length > 0)
5110
+ ? metadata.workingDirectory
5111
+ : null;
5112
+ let resolvedConnectCwd = null;
5113
+ if (preSelectedSessionId) {
5114
+ try {
5115
+ resolvedConnectCwd = await resolveCwdForSession(preSelectedSessionId, wdHint);
5116
+ }
5117
+ catch (e) {
5118
+ console.warn('⚠️ connect cwd resolve failed:', e instanceof Error ? e.message : e);
5119
+ resolvedConnectCwd = null;
5120
+ }
5113
5121
  }
5114
- else {
5115
- // Reset to default for new connections (in case previous session changed it)
5116
- workingDir = defaultWorkingDir;
5122
+ const connectWd = pickConnectWorkingDir({ preSelectedSessionId, resolved: resolvedConnectCwd, hint: wdHint, defaultDir: defaultWorkingDir });
5123
+ // Recursive mkdirSync is a no-op when the dir already exists; only the
5124
+ // hint path (new project / fresh sprite) needs creating — the resolved
5125
+ // dir exists by construction, the default is the agent's own boot dir.
5126
+ if (connectWd.createIfMissing && !existsSync(connectWd.dir)) {
5127
+ mkdirSync(connectWd.dir, { recursive: true });
5128
+ console.log(`📁 Created project directory: ${connectWd.dir}`);
5117
5129
  }
5130
+ workingDir = connectWd.dir;
5131
+ console.log(`📂 Working directory (${connectWd.source}): ${workingDir}`);
5118
5132
  }
5119
5133
  catch (err) {
5120
5134
  console.log('⚠️ Could not parse participant metadata, using config voiceMode:', voiceMode);
@@ -122,6 +122,38 @@ export declare function warmParkKey(llm: {
122
122
  * otherwise the agent's boot dir (today's behaviour). Never trusts the param.
123
123
  */
124
124
  export declare function sessionMessagesDir(sessionId: string, requested: string | null | undefined, bootDir: string, exists: (sessionId: string, cwd: string) => boolean): string;
125
+ /**
126
+ * Working directory the agent boots a CONNECTION in (connect-time, #112).
127
+ *
128
+ * The resume mismatch bug: a client opens `/chat?session=A&workingDirectory=X`,
129
+ * but X is stale/empty (a switch rewrote the URL without a cwd, or the hint was
130
+ * never the session's real project). Trusting the raw hint booted the agent in
131
+ * the wrong dir — often `/workspace` root — so `--resume A` never found A's
132
+ * JSONL and the session silently came up as the wrong one with a generic
133
+ * "Workspace" chip. The fix makes the agent AUTHORITATIVE about a pre-selected
134
+ * session's cwd: its RESOLVED project dir wins over the client hint.
135
+ *
136
+ * `resolved` is resolveSessionCwd(preSelectedSessionId, hint, …) — the only dir
137
+ * where A's JSONL actually exists (null = found nowhere yet). Pure: the caller
138
+ * does the I/O (resolveSessionCwd) and the mkdir when `createIfMissing`.
139
+ *
140
+ * - pre-selected + resolved → the resolved dir (already exists, no mkdir).
141
+ * - pre-selected + unresolved + hint → the hint, created (fresh sprite / new
142
+ * project whose JSONL isn't on disk yet, so --resume can still attach there).
143
+ * - pre-selected + nothing → the default boot dir.
144
+ * - no pre-selected + hint → the hint, created (new project).
145
+ * - no pre-selected + nothing → the default boot dir.
146
+ */
147
+ export declare function pickConnectWorkingDir(args: {
148
+ preSelectedSessionId: string | null | undefined;
149
+ resolved: string | null | undefined;
150
+ hint: string | null | undefined;
151
+ defaultDir: string;
152
+ }): {
153
+ dir: string;
154
+ createIfMissing: boolean;
155
+ source: 'resolved' | 'hint' | 'default';
156
+ };
125
157
  /**
126
158
  * Single-flight guard for performSessionSwitch. Only the critical section
127
159
  * (teardown + arm + session_switched) holds the guard; `after` (the spoken
@@ -127,6 +127,42 @@ export function sessionMessagesDir(sessionId, requested, bootDir, exists) {
127
127
  }
128
128
  return bootDir;
129
129
  }
130
+ /**
131
+ * Working directory the agent boots a CONNECTION in (connect-time, #112).
132
+ *
133
+ * The resume mismatch bug: a client opens `/chat?session=A&workingDirectory=X`,
134
+ * but X is stale/empty (a switch rewrote the URL without a cwd, or the hint was
135
+ * never the session's real project). Trusting the raw hint booted the agent in
136
+ * the wrong dir — often `/workspace` root — so `--resume A` never found A's
137
+ * JSONL and the session silently came up as the wrong one with a generic
138
+ * "Workspace" chip. The fix makes the agent AUTHORITATIVE about a pre-selected
139
+ * session's cwd: its RESOLVED project dir wins over the client hint.
140
+ *
141
+ * `resolved` is resolveSessionCwd(preSelectedSessionId, hint, …) — the only dir
142
+ * where A's JSONL actually exists (null = found nowhere yet). Pure: the caller
143
+ * does the I/O (resolveSessionCwd) and the mkdir when `createIfMissing`.
144
+ *
145
+ * - pre-selected + resolved → the resolved dir (already exists, no mkdir).
146
+ * - pre-selected + unresolved + hint → the hint, created (fresh sprite / new
147
+ * project whose JSONL isn't on disk yet, so --resume can still attach there).
148
+ * - pre-selected + nothing → the default boot dir.
149
+ * - no pre-selected + hint → the hint, created (new project).
150
+ * - no pre-selected + nothing → the default boot dir.
151
+ */
152
+ export function pickConnectWorkingDir(args) {
153
+ const hint = norm(args.hint);
154
+ if (norm(args.preSelectedSessionId)) {
155
+ const resolved = norm(args.resolved);
156
+ if (resolved)
157
+ return { dir: resolved, createIfMissing: false, source: 'resolved' };
158
+ if (hint)
159
+ return { dir: hint, createIfMissing: true, source: 'hint' };
160
+ return { dir: args.defaultDir, createIfMissing: false, source: 'default' };
161
+ }
162
+ if (hint)
163
+ return { dir: hint, createIfMissing: true, source: 'hint' };
164
+ return { dir: args.defaultDir, createIfMissing: false, source: 'default' };
165
+ }
130
166
  // ── Review minors ────────────────────────────────────────────────────────────
131
167
  /**
132
168
  * Single-flight guard for performSessionSwitch. Only the critical section
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "osborn",
3
- "version": "0.9.276",
3
+ "version": "0.9.277",
4
4
  "description": "Voice AI coding assistant - local agent that connects to Osborn frontend",
5
5
  "type": "module",
6
6
  "bin": {