@1presence/bridge 0.31.0 → 0.32.0

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.
Files changed (2) hide show
  1. package/dist/index.js +15 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -52,9 +52,13 @@ let currentWs = null;
52
52
  // must surface the error, not silently degrade to a different prompt source
53
53
  // (which historically caused the "Skills section authoritative" rule to
54
54
  // vanish and the agent to vault-hunt for skills).
55
- async function fetchSystemPrompt(token) {
55
+ async function fetchSystemPrompt(token, agentSlug) {
56
56
  const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
57
- const url = `${GATEWAY_HTTP}/system-prompt-for-bridge?timezone=${encodeURIComponent(tz)}`;
57
+ // Pass the selected agent slug so agent-api resolves THIS agent (identity,
58
+ // granted connectors, scoped memory) rather than always falling back to the
59
+ // default 1Presence. Without it, every Local Mode turn was the generalist.
60
+ const agentParam = agentSlug ? `&agent=${encodeURIComponent(agentSlug)}` : '';
61
+ const url = `${GATEWAY_HTTP}/system-prompt-for-bridge?timezone=${encodeURIComponent(tz)}${agentParam}`;
58
62
  let res;
59
63
  try {
60
64
  res = await fetch(url, {
@@ -89,9 +93,9 @@ function tmpFile(name) {
89
93
  // connector status, palace, onboarding phase, skills) — call this per turn in
90
94
  // the bridge too, otherwise newly shipped skills and mid-session vault writes
91
95
  // never reach a long-running bridge. Throws on failure; caller must handle.
92
- async function writeSystemPrompt(auth) {
96
+ async function writeSystemPrompt(auth, agentSlug) {
93
97
  const { uid, token } = auth;
94
- const systemPrompt = await fetchSystemPrompt(token);
98
+ const systemPrompt = await fetchSystemPrompt(token, agentSlug);
95
99
  writeRestricted(tmpFile(`agent-${uid}.md`), systemPrompt);
96
100
  if (VERBOSE) {
97
101
  console.log('\n[bridge:verbose] ─── system prompt ───────────────────────');
@@ -112,8 +116,8 @@ function writeMcpConfig(auth) {
112
116
  };
113
117
  writeRestricted(tmpFile(`mcp-${uid}.json`), JSON.stringify(mcpConfig, null, 2));
114
118
  }
115
- async function writeSetupFiles(auth) {
116
- await writeSystemPrompt(auth);
119
+ async function writeSetupFiles(auth, agentSlug) {
120
+ await writeSystemPrompt(auth, agentSlug);
117
121
  writeMcpConfig(auth);
118
122
  }
119
123
  // The MCP config embeds a Bearer JWT and the system prompt may contain vault
@@ -129,7 +133,7 @@ function isUuid(value) {
129
133
  return UUID_RE.test(value);
130
134
  }
131
135
  // ─── Handle a single incoming message (token refresh + spawn) ─────────────────
132
- async function handleMessage(conversationId, text, sessionId, history, auth, vaultFileOpen, clientCapabilities, syncedFolders) {
136
+ async function handleMessage(conversationId, text, sessionId, history, auth, vaultFileOpen, clientCapabilities, syncedFolders, agentSlug) {
133
137
  // Refresh JWT if <10 min remaining before spawning Claude
134
138
  let activeAuth = auth;
135
139
  try {
@@ -137,7 +141,7 @@ async function handleMessage(conversationId, text, sessionId, history, auth, vau
137
141
  if (freshAuth.token !== auth.token) {
138
142
  currentAuth = freshAuth;
139
143
  activeAuth = freshAuth;
140
- await writeSetupFiles(freshAuth);
144
+ await writeSetupFiles(freshAuth, agentSlug);
141
145
  }
142
146
  }
143
147
  catch (err) {
@@ -161,7 +165,7 @@ async function handleMessage(conversationId, text, sessionId, history, auth, vau
161
165
  // (e.g. agent vault-hunting for skills because the Skills authoritative
162
166
  // rule was missing from the previous snapshot).
163
167
  try {
164
- await writeSystemPrompt(activeAuth);
168
+ await writeSystemPrompt(activeAuth, agentSlug);
165
169
  }
166
170
  catch (err) {
167
171
  const message = `System prompt refresh failed: ${err.message}`;
@@ -376,11 +380,11 @@ function connect(auth, retryDelay = 1000) {
376
380
  }
377
381
  if (msg.type !== 'message' || !msg.conversationId || !msg.text)
378
382
  return;
379
- const { conversationId, text, sessionId, history, vaultFileOpen, clientCapabilities, syncedFolders } = msg;
383
+ const { conversationId, text, sessionId, history, vaultFileOpen, clientCapabilities, syncedFolders, agentSlug } = msg;
380
384
  const ts = new Date().toLocaleTimeString();
381
385
  const hist = Array.isArray(history) ? history : [];
382
386
  console.log(`[${ts}] ▶ ${text}${hist.length ? ` (history: ${hist.length} turn${hist.length === 1 ? '' : 's'})` : ''}`);
383
- handleMessage(conversationId, text, sessionId ?? null, hist, auth, vaultFileOpen, clientCapabilities, syncedFolders).catch((err) => {
387
+ handleMessage(conversationId, text, sessionId ?? null, hist, auth, vaultFileOpen, clientCapabilities, syncedFolders, agentSlug).catch((err) => {
384
388
  console.error(`[bridge] handleMessage error: ${err.message}`);
385
389
  });
386
390
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1presence/bridge",
3
- "version": "0.31.0",
3
+ "version": "0.32.0",
4
4
  "description": "Run 1Presence on your Mac and use your Claude.ai Pro subscription from any device",
5
5
  "bin": {
6
6
  "1presence-bridge": "dist/index.js"