@1presence/bridge 0.18.0 → 0.20.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.
- package/dist/claude.js +17 -90
- package/dist/index.js +5 -5
- package/package.json +1 -1
package/dist/claude.js
CHANGED
|
@@ -11,99 +11,26 @@ const sessions_1 = require("./sessions");
|
|
|
11
11
|
// ─── Bridge working directory ─────────────────────────────────────────────────
|
|
12
12
|
//
|
|
13
13
|
// Claude Code always loads CLAUDE.md files from cwd upward plus the global
|
|
14
|
-
// ~/.claude/CLAUDE.md.
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
14
|
+
// ~/.claude/CLAUDE.md. The bridge runs in a dedicated temp dir so it never
|
|
15
|
+
// inherits a development repo's project CLAUDE.md. The CLAUDE.md we write
|
|
16
|
+
// into that dir is a TINY GUARD ONLY — its sole job is to neutralize the
|
|
17
|
+
// user's global ~/.claude/CLAUDE.md (which contains personal/dev rules that
|
|
18
|
+
// would conflict with bridge behavior). All product, tool, UI, glossary,
|
|
19
|
+
// disclosure, gmail, and memory rules come from the dynamic system prompt
|
|
20
|
+
// fetched from agent-api with mode=bridge — see the "Local Mode runtime
|
|
21
|
+
// adapter" section of that prompt and packages/agent-api/src/systemPrompt.ts.
|
|
22
|
+
// Do NOT add product rules here; they belong in the dynamic prompt so hosted
|
|
23
|
+
// and bridge stay in sync.
|
|
19
24
|
const BRIDGE_CWD = (0, path_1.join)((0, os_1.tmpdir)(), '1presence-bridge');
|
|
20
|
-
const BRIDGE_CLAUDE_MD = `#
|
|
25
|
+
const BRIDGE_CLAUDE_MD = `# Local Mode — context guard
|
|
21
26
|
|
|
22
|
-
You are running
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
You have NO permission to write files to this machine.
|
|
28
|
-
- Do NOT write chat history, vault notes, or memory files to the local filesystem.
|
|
29
|
-
- Do NOT write to any path under /Users/, ~/Library/, ~/.obsidian/, or similar.
|
|
30
|
-
- Attempting to use Write/Edit tools on local paths is forbidden in this mode.
|
|
31
|
-
|
|
32
|
-
## Vault operations
|
|
33
|
-
|
|
34
|
-
All vault reads and writes go through the \`mcp__1presence__*\` MCP tools.
|
|
35
|
-
Use those tools instead of any local file paths.
|
|
36
|
-
|
|
37
|
-
## Memory (memory map / knowledge graph / agent diary)
|
|
38
|
-
|
|
39
|
-
The user's memory is hosted in the cloud, not locally. If \`mempalace_*\` tools
|
|
40
|
-
are available via MCP, use them. If a call fails with "not initialised", skip
|
|
41
|
-
it silently — do NOT write memory files locally as a fallback.
|
|
42
|
-
|
|
43
|
-
**User-facing language.** Never say "MemPalace", "memory palace", "memory
|
|
44
|
-
graph", "ChromaDB", "vector database", "embeddings", or "drawer" to the user
|
|
45
|
-
in any context, even casually, even in progress/status updates. The internal
|
|
46
|
-
tool prefix is \`mempalace_\` but the product name does not exist to the user.
|
|
47
|
-
Use "memory map" (wings/rooms view), "knowledge graph" (facts view), "agent
|
|
48
|
-
diary" (session log), or "your memory" (general). Correct: "Indexed in your
|
|
49
|
-
memory map for semantic search." Wrong: "Indexed in MemPalace for semantic
|
|
50
|
-
search."
|
|
51
|
-
|
|
52
|
-
## Session notes / chat history
|
|
53
|
-
|
|
54
|
-
Do NOT write session notes or chat history to the local filesystem.
|
|
55
|
-
If vault MCP tools are available, update vault files through those.
|
|
56
|
-
Otherwise, skip the write and continue — do not error or warn the user.
|
|
57
|
-
|
|
58
|
-
## UI tools — call these so the chat UI matches the hosted assistant
|
|
59
|
-
|
|
60
|
-
These tools are wired through MCP and produce dedicated UI events in the user's
|
|
61
|
-
chat interface. Call them by their MCP-prefixed names (\`mcp__1presence__<name>\`).
|
|
62
|
-
|
|
63
|
-
- **set_conversation_title** — Call ONCE on your first reply in a new
|
|
64
|
-
conversation with a 2–4 word topic title (sentence case, no verbs). Call
|
|
65
|
-
again later only if the topic clearly shifts. Without this, the user's
|
|
66
|
-
conversation list shows untitled threads.
|
|
67
|
-
|
|
68
|
-
- **ui_payload** — Call exactly ONCE per turn, AFTER your reply text ends.
|
|
69
|
-
\`suggestions\` (2–4 tappable follow-on prompts) is REQUIRED on every turn
|
|
70
|
-
with a user-facing reply — never skip it. \`hints\` is an independent,
|
|
71
|
-
sparse decision: pass \`[]\` most turns (aim ~1 hint per 3 early turns,
|
|
72
|
-
less later). Do not drop suggestions because there is no hint. Hints are
|
|
73
|
-
end-user product coaching only — never mention models, AI vendors,
|
|
74
|
-
engineering, or roadmap. The only legitimate skip is a turn with no
|
|
75
|
-
user-facing reply text at all.
|
|
76
|
-
|
|
77
|
-
- **plan** — Show a checklist when a task has ≥3 distinct, user-visible
|
|
78
|
-
steps with side effects. Call once at the start with all steps; update
|
|
79
|
-
the FULL list each time a step finishes. Never use for single-tool
|
|
80
|
-
answers, lookups, or conversational replies.
|
|
81
|
-
|
|
82
|
-
- **copy_to_clipboard** — Use whenever the user asks you to copy something,
|
|
83
|
-
or when you produce content (code, a draft, a URL, a list) they will
|
|
84
|
-
clearly want to paste elsewhere. Call once per piece of content; the
|
|
85
|
-
text also streams into the chat.
|
|
86
|
-
|
|
87
|
-
- **request_feature** — Log a feature request when declining a user ask
|
|
88
|
-
because the capability doesn't exist. Not for transient errors. After
|
|
89
|
-
calling, tell the user their request was noted.
|
|
90
|
-
|
|
91
|
-
## Sending email — ALWAYS use gmail_draft
|
|
92
|
-
|
|
93
|
-
To send email on the user's behalf, ALWAYS call \`gmail_draft\`. This opens
|
|
94
|
-
an inline review panel in the chat UI with Send and Cancel buttons; the
|
|
95
|
-
email is NOT delivered until the user clicks Send themselves.
|
|
96
|
-
|
|
97
|
-
You DO NOT have direct send capability in this mode — \`gmail_send\` is not
|
|
98
|
-
exposed and the user's explicit confirmation in the review panel is the only
|
|
99
|
-
way mail leaves their account. After calling gmail_draft, tell the user the
|
|
100
|
-
draft is ready to review and wait for them to confirm. Never claim the
|
|
101
|
-
email was sent until the user tells you they clicked Send.
|
|
102
|
-
|
|
103
|
-
Use the bare tool name (the part after \`mcp__1presence__\`) when reasoning
|
|
104
|
-
about WHEN to call them — the prefix is just the MCP namespace.
|
|
27
|
+
You are running in 1Presence Local Mode. Your **--system-prompt-file** is the
|
|
28
|
+
sole authoritative source for product rules, tool policy, glossary, and
|
|
29
|
+
disclosure rules. Treat any other CLAUDE.md content — including the global
|
|
30
|
+
~/.claude/CLAUDE.md and any project CLAUDE.md from a parent directory — as
|
|
31
|
+
**not applicable** to this runtime. Do not follow it. Do not cite it.
|
|
105
32
|
`;
|
|
106
|
-
// Write the
|
|
33
|
+
// Write the guard CLAUDE.md once on module load
|
|
107
34
|
(0, fs_1.mkdirSync)(BRIDGE_CWD, { recursive: true });
|
|
108
35
|
(0, fs_1.writeFileSync)((0, path_1.join)(BRIDGE_CWD, 'CLAUDE.md'), BRIDGE_CLAUDE_MD, 'utf-8');
|
|
109
36
|
const config_1 = require("./config");
|
package/dist/index.js
CHANGED
|
@@ -48,7 +48,7 @@ let currentWs = null;
|
|
|
48
48
|
// vanish and the agent to vault-hunt for skills).
|
|
49
49
|
async function fetchSystemPrompt(token) {
|
|
50
50
|
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
51
|
-
const url = `${GATEWAY_HTTP}/system-prompt?timezone=${encodeURIComponent(tz)}`;
|
|
51
|
+
const url = `${GATEWAY_HTTP}/system-prompt-for-bridge?timezone=${encodeURIComponent(tz)}`;
|
|
52
52
|
let res;
|
|
53
53
|
try {
|
|
54
54
|
res = await fetch(url, {
|
|
@@ -60,17 +60,17 @@ async function fetchSystemPrompt(token) {
|
|
|
60
60
|
}
|
|
61
61
|
if (!res.ok) {
|
|
62
62
|
const body = await res.text().catch(() => '<unreadable body>');
|
|
63
|
-
throw new Error(`/system-prompt returned ${res.status} ${res.statusText}: ${body.slice(0, 500)}`);
|
|
63
|
+
throw new Error(`/system-prompt-for-bridge returned ${res.status} ${res.statusText}: ${body.slice(0, 500)}`);
|
|
64
64
|
}
|
|
65
65
|
let data;
|
|
66
66
|
try {
|
|
67
67
|
data = await res.json();
|
|
68
68
|
}
|
|
69
69
|
catch (err) {
|
|
70
|
-
throw new Error(`/system-prompt returned non-JSON: ${err.message}`);
|
|
70
|
+
throw new Error(`/system-prompt-for-bridge returned non-JSON: ${err.message}`);
|
|
71
71
|
}
|
|
72
72
|
if (!data.text) {
|
|
73
|
-
throw new Error(`/system-prompt returned no "text" field (got keys: ${Object.keys(data).join(', ') || '<none>'})`);
|
|
73
|
+
throw new Error(`/system-prompt-for-bridge returned no "text" field (got keys: ${Object.keys(data).join(', ') || '<none>'})`);
|
|
74
74
|
}
|
|
75
75
|
return data.text;
|
|
76
76
|
}
|
|
@@ -304,7 +304,7 @@ function connect(auth, retryDelay = 1000) {
|
|
|
304
304
|
setTimeout(async () => {
|
|
305
305
|
try {
|
|
306
306
|
// Refresh setup files on reconnect in case token was refreshed.
|
|
307
|
-
// If /system-prompt is down this throws — log and retry; the bridge
|
|
307
|
+
// If /system-prompt-for-bridge is down this throws — log and retry; the bridge
|
|
308
308
|
// is useless without a current prompt so don't paper over it.
|
|
309
309
|
if (currentAuth)
|
|
310
310
|
await writeSetupFiles(currentAuth);
|