@chrisromp/copilot-bridge 0.9.2 → 0.10.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.
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Bridge documentation content for the fetch_copilot_bridge_documentation tool.
3
+ * Each topic returns focused markdown content with source pointers.
4
+ */
5
+ declare const TOPICS: readonly ["overview", "commands", "config", "mcp", "permissions", "workspaces", "hooks", "skills", "inter-agent", "scheduling", "troubleshooting", "status"];
6
+ export type DocTopic = typeof TOPICS[number];
7
+ export declare function isValidTopic(topic: string): topic is DocTopic;
8
+ export interface DocRequest {
9
+ topic?: string;
10
+ isAdmin: boolean;
11
+ channelId: string;
12
+ model?: string;
13
+ sessionId?: string;
14
+ }
15
+ export declare function getBridgeDocs(req: DocRequest): string;
16
+ export {};
17
+ //# sourceMappingURL=bridge-docs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge-docs.d.ts","sourceRoot":"","sources":["../../src/core/bridge-docs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,QAAA,MAAM,MAAM,8JAGF,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;AAE7C,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,QAAQ,CAE7D;AAgpBD,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CA2BrD"}
@@ -0,0 +1,658 @@
1
+ /**
2
+ * Bridge documentation content for the fetch_copilot_bridge_documentation tool.
3
+ * Each topic returns focused markdown content with source pointers.
4
+ */
5
+ import { createLogger } from '../logger.js';
6
+ import { getConfig } from '../config.js';
7
+ import * as fs from 'node:fs';
8
+ import * as path from 'node:path';
9
+ import { fileURLToPath } from 'node:url';
10
+ const log = createLogger('bridge-docs');
11
+ const TOPICS = [
12
+ 'overview', 'commands', 'config', 'mcp', 'permissions', 'workspaces',
13
+ 'hooks', 'skills', 'inter-agent', 'scheduling', 'troubleshooting', 'status',
14
+ ];
15
+ export function isValidTopic(topic) {
16
+ return TOPICS.includes(topic);
17
+ }
18
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
19
+ let _cachedVersion = null;
20
+ function getVersion() {
21
+ if (_cachedVersion)
22
+ return _cachedVersion;
23
+ try {
24
+ const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '../../package.json'), 'utf8'));
25
+ let version = pkg.version ?? 'unknown';
26
+ const gitDir = path.join(__dirname, '../../.git');
27
+ if (fs.existsSync(gitDir)) {
28
+ try {
29
+ const head = fs.readFileSync(path.join(gitDir, 'HEAD'), 'utf8').trim();
30
+ if (head.startsWith('ref: ')) {
31
+ const refPath = path.join(gitDir, head.slice(5));
32
+ if (fs.existsSync(refPath)) {
33
+ const hash = fs.readFileSync(refPath, 'utf8').trim().slice(0, 7);
34
+ version += ` (${hash})`;
35
+ }
36
+ }
37
+ else {
38
+ version += ` (${head.slice(0, 7)})`;
39
+ }
40
+ }
41
+ catch { /* best-effort */ }
42
+ }
43
+ _cachedVersion = version;
44
+ return version;
45
+ }
46
+ catch {
47
+ return 'unknown';
48
+ }
49
+ }
50
+ function topicList() {
51
+ return `Available topics: ${TOPICS.map(t => `\`${t}\``).join(', ')}
52
+
53
+ Call with a specific topic for focused information, e.g. \`fetch_copilot_bridge_documentation({ topic: "commands" })\``;
54
+ }
55
+ // ---------------------------------------------------------------------------
56
+ // Topic: overview
57
+ // ---------------------------------------------------------------------------
58
+ function topicOverview() {
59
+ return `# copilot-bridge Overview
60
+
61
+ copilot-bridge connects GitHub Copilot CLI sessions to messaging platforms (Mattermost, Slack). It runs as a background service, managing one Copilot session per chat channel.
62
+
63
+ ## Key Features
64
+
65
+ - **Multi-bot support** — multiple bot identities, each with its own workspace, AGENTS.md, and MCP servers
66
+ - **Streaming responses** — edit-in-place messages with throttled updates
67
+ - **Slash commands** — \`/model\`, \`/new\`, \`/status\`, \`/context\`, etc. (use \`fetch_copilot_bridge_documentation({ topic: "commands" })\` for full list)
68
+ - **Permission system** — interactive prompts, autopilot mode, persistent rules
69
+ - **MCP servers** — auto-loads from plugins, user config, and workspace config
70
+ - **Skills** — skill directories discovered from standard Copilot locations
71
+ - **Hooks** — preToolUse/postToolUse shell hooks for custom logic
72
+ - **Inter-agent communication** — bots can query each other via \`ask_agent\` tool
73
+ - **Task scheduling** — cron and one-off scheduled prompts
74
+ - **Model fallback** — automatic failover on model capacity/availability errors
75
+ - **Infinite sessions** — SDK-managed context compaction for long conversations
76
+
77
+ ## Architecture
78
+
79
+ 1. Channel adapter receives platform message, normalizes to \`InboundMessage\`
80
+ 2. Messages serialized per-channel via promise chains
81
+ 3. \`SessionManager\` creates/resumes Copilot sessions via \`CopilotBridge\` (SDK wrapper)
82
+ 4. SDK events flow back through formatters → streaming handler → platform
83
+
84
+ ## Source
85
+
86
+ - Repository: https://github.com/ChrisRomp/copilot-bridge
87
+ - Docs: \`docs/\` directory in the repository
88
+ - Key files: \`src/index.ts\` (orchestrator), \`src/core/session-manager.ts\` (session lifecycle), \`src/core/bridge.ts\` (SDK wrapper)`;
89
+ }
90
+ // ---------------------------------------------------------------------------
91
+ // Topic: commands
92
+ // ---------------------------------------------------------------------------
93
+ function topicCommands() {
94
+ return `# Slash Commands
95
+
96
+ Commands are intercepted by the bridge before reaching the Copilot session. The agent does not see these commands. Use \`/help all\` for the complete list — below are the most commonly used commands.
97
+
98
+ ## Session Management
99
+ | Command | Description |
100
+ |---------|-------------|
101
+ | \`/new\` | Create a new session (destroys current) |
102
+ | \`/stop\`, \`/cancel\` | Stop the current task |
103
+ | \`/reload\` | Re-attach session (re-reads AGENTS.md, config, MCP) |
104
+ | \`/reload config\` | Hot-reload bridge config file |
105
+ | \`/resume [id]\` | Resume a past session (no args = list recent) |
106
+
107
+ ## Model & Agent
108
+ | Command | Description |
109
+ |---------|-------------|
110
+ | \`/model [name]\` | Show available models or switch model |
111
+ | \`/agent <name>\` | Switch to a named agent persona |
112
+ | \`/agents\` | List available agent definitions |
113
+ | \`/reasoning [level]\` | Set reasoning effort (low/medium/high/xhigh) |
114
+
115
+ ## Permissions & Mode
116
+ | Command | Description |
117
+ |---------|-------------|
118
+ | \`/approve\` | Approve pending permission request |
119
+ | \`/deny\` | Deny pending permission request |
120
+ | \`/yolo\` | Toggle auto-approve all permissions |
121
+ | \`/autopilot\`, \`/auto\` | Toggle autonomous mode |
122
+ | \`/plan [on|off|show|summary|clear]\` | Toggle plan mode. On entry, surfaces existing plan if found |
123
+ | \`/implement [yolo|interactive]\` | Start implementing the current plan. Default: autopilot. \`yolo\`: autopilot + auto-approve. \`interactive\`: step-by-step |
124
+ | \`/always approve|deny <pattern>\` | Persist a permission rule |
125
+ | \`/rules\` | List all stored permission rules |
126
+
127
+ ## Information
128
+ | Command | Description |
129
+ |---------|-------------|
130
+ | \`/status\` | Show session info, model, mode, context usage |
131
+ | \`/context\` | Show context window usage |
132
+ | \`/verbose\` | Toggle verbose tool output |
133
+ | \`/mcp\` | Show loaded MCP servers and their source |
134
+ | \`/skills\`, \`/tools\` | Show available skills, enable/disable |
135
+ | \`/schedule\`, \`/tasks\` | List scheduled tasks |
136
+ | \`/help [all]\` | Show common commands (or all) |
137
+
138
+ ## Display
139
+ | Command | Description |
140
+ |---------|-------------|
141
+ | \`/streamer-mode\`, \`/on-air\` | Toggle sensitive data redaction |
142
+
143
+ ## Source
144
+ - Command parsing: \`src/core/command-handler.ts\`
145
+ - Command dispatch: \`src/index.ts\` (handleInboundMessage)`;
146
+ }
147
+ // ---------------------------------------------------------------------------
148
+ // Topic: config
149
+ // ---------------------------------------------------------------------------
150
+ function topicConfig(isAdmin) {
151
+ const editNote = isAdmin
152
+ ? 'Config file: `~/.copilot-bridge/config.json` (or `COPILOT_BRIDGE_CONFIG` env var)'
153
+ : 'Config changes require editing `~/.copilot-bridge/config.json`. Ask your administrator or the user to make config modifications.';
154
+ return `# Configuration
155
+
156
+ ${editNote}
157
+
158
+ ## Key Top-Level Settings
159
+
160
+ | Field | Type | Description |
161
+ |-------|------|-------------|
162
+ | \`platforms\` | object | Platform configs keyed by name (e.g., \`"mattermost": { url, bots }\`) |
163
+ | \`channels\` | array | Per-channel config entries (each has \`id\`, \`platform\`, \`bot\`, etc.) |
164
+ | \`defaults\` | object | Default values for channel settings |
165
+ | \`logLevel\` | string | \`"debug"\`, \`"info"\`, \`"warn"\`, \`"error"\` |
166
+ | \`infiniteSessions\` | boolean | Enable SDK context compaction (default: false) |
167
+ | \`permissions\` | object | Permission rules (allow/deny patterns) |
168
+ | \`interAgent\` | object | Inter-agent communication settings |
169
+
170
+ ## Defaults Section (per-channel overridable)
171
+
172
+ | Field | Default | Description |
173
+ |-------|---------|-------------|
174
+ | \`model\` | \`"claude-sonnet-4.6"\` | Default model |
175
+ | \`verbose\` | \`false\` | Show tool call details |
176
+ | \`permissionMode\` | \`"interactive"\` | Permission handling mode |
177
+ | \`fallbackModels\` | \`[]\` | Model fallback chain |
178
+
179
+ ## Channel Entries
180
+
181
+ Each entry in the \`channels\` array configures one channel:
182
+ \`\`\`json
183
+ {
184
+ "channels": [
185
+ {
186
+ "id": "channel-id-from-platform",
187
+ "platform": "mattermost",
188
+ "bot": "copilot",
189
+ "name": "My Project",
190
+ "workingDirectory": "/path/to/workspace",
191
+ "model": "claude-opus-4.6"
192
+ }
193
+ ]
194
+ }
195
+ \`\`\`
196
+
197
+ ## Hot-Reloadable Settings
198
+
199
+ These apply immediately on \`/reload config\`: \`defaults\`, \`permissions\`, \`interAgent\`, \`channels\`.
200
+ Top-level settings like \`infiniteSessions\` take effect at next session create/resume.
201
+
202
+ ## Source
203
+ - Config loading/validation: \`src/config.ts\`
204
+ - Sample: \`config.sample.json\`
205
+ - Docs: \`docs/configuration.md\``;
206
+ }
207
+ // ---------------------------------------------------------------------------
208
+ // Topic: mcp
209
+ // ---------------------------------------------------------------------------
210
+ function topicMcp() {
211
+ return `# MCP Server Configuration
212
+
213
+ MCP (Model Context Protocol) servers provide external tools to agents. Loaded in three layers:
214
+
215
+ 1. **Plugins** (\`~/.copilot/installed-plugins/**/.mcp.json\`) — lowest priority
216
+ 2. **User config** (\`~/.copilot/mcp-config.json\`) — overrides plugins
217
+ 3. **Workspace config** (\`<workspace>/mcp-config.json\`) — highest priority, per-bot
218
+
219
+ ## Format
220
+
221
+ \`\`\`json
222
+ {
223
+ "mcpServers": {
224
+ "my-server": {
225
+ "type": "stdio",
226
+ "command": "node",
227
+ "args": ["/path/to/server.js"]
228
+ }
229
+ }
230
+ }
231
+ \`\`\`
232
+
233
+ ## Working Directory
234
+
235
+ Local MCP servers automatically run with \`cwd\` set to the bot's workspace. Override with explicit \`cwd\` in config.
236
+
237
+ ## Environment Variables
238
+
239
+ Workspace \`.env\` vars are injected into every local MCP server's \`env\` field. Use \`\${VAR}\` in config to remap variable names.
240
+
241
+ Priority: explicit \`env\` in config > \`.env\` values.
242
+
243
+ ## Troubleshooting
244
+
245
+ - **Server not loading**: Check \`~/.copilot-bridge/copilot-bridge.log\` for MCP startup errors
246
+ - **Tools not visible**: Server may start but fail to connect to backend (missing env vars). Run \`/reload\` after fixing.
247
+ - **Wrong server version**: \`npx\` caches — use \`npx --yes package@latest\` to force update
248
+ - **\`/mcp\` command**: Shows all loaded servers and which layer they came from
249
+
250
+ ## Source
251
+ - Server resolution: \`src/core/session-manager.ts\` (resolveMcpServers, loadWorkspaceMcpServers, mergeMcpServers)
252
+ - Docs: \`docs/workspaces.md\` (MCP section)`;
253
+ }
254
+ // ---------------------------------------------------------------------------
255
+ // Topic: permissions
256
+ // ---------------------------------------------------------------------------
257
+ function topicPermissions() {
258
+ return `# Permission System
259
+
260
+ The bridge controls which tools agents can use. Permissions are resolved in order:
261
+
262
+ 1. **Hardcoded safety denies** (cannot override)
263
+ 2. **Autopilot/yolo mode** (auto-approve if enabled)
264
+ 3. **Config deny rules** (from \`permissions.deny\`)
265
+ 4. **Config allow rules** (from \`permissions.allow\`)
266
+ 5. **SQLite stored rules** (from \`/always approve\` or \`/always deny\`)
267
+ 6. **Interactive prompt** (asks user in chat)
268
+
269
+ ## Config Rules
270
+
271
+ \`\`\`json
272
+ {
273
+ "permissions": {
274
+ "allow": ["read", "shell(ls)", "shell(cat)", "vault-search"],
275
+ "deny": ["shell(rm)", "shell(git push)"],
276
+ "allowPaths": [],
277
+ "allowUrls": ["docs.github.com"]
278
+ }
279
+ }
280
+ \`\`\`
281
+
282
+ ## Pattern Syntax
283
+
284
+ | Pattern | Matches |
285
+ |---------|---------|
286
+ | \`"read"\` | All file reads |
287
+ | \`"write"\` | All file writes |
288
+ | \`"shell"\` | All shell commands |
289
+ | \`"shell(ls)"\` | The \`ls\` command specifically |
290
+ | \`"shell(git push)"\` | \`git push\` with any args |
291
+ | \`"mcp-server-name"\` | All tools from that MCP server |
292
+ | \`"mcp-server(tool)"\` | Specific MCP tool |
293
+
294
+ ## User Commands
295
+
296
+ | Command | Effect |
297
+ |---------|--------|
298
+ | \`/approve\` | Approve current pending request |
299
+ | \`/deny\` | Deny current pending request |
300
+ | \`/yolo\` | Toggle auto-approve all |
301
+ | \`/autopilot\` | Toggle autonomous mode (auto-approve + continues without user input) |
302
+ | \`/always approve <pattern>\` | Persist an allow rule |
303
+ | \`/always deny <pattern>\` | Persist a deny rule |
304
+ | \`/rules\` | View all stored rules |
305
+ | \`/rules clear\` | Clear all stored rules |
306
+
307
+ ## Source
308
+ - Permission resolution: \`src/core/session-manager.ts\` (handlePermissionRequest)
309
+ - Access control: \`src/core/access-control.ts\`
310
+ - Docs: \`docs/configuration.md\` (Permissions section)`;
311
+ }
312
+ // ---------------------------------------------------------------------------
313
+ // Topic: workspaces
314
+ // ---------------------------------------------------------------------------
315
+ function topicWorkspaces() {
316
+ return `# Workspaces
317
+
318
+ Each bot has a dedicated workspace directory (default: \`~/.copilot-bridge/workspaces/<bot-name>/\`).
319
+
320
+ ## Structure
321
+
322
+ \`\`\`
323
+ <workspace>/
324
+ ├── AGENTS.md # Agent instructions (read by Copilot CLI)
325
+ ├── .env # Environment variables (secrets, API tokens)
326
+ ├── mcp-config.json # Workspace-specific MCP servers (optional)
327
+ ├── agents/ # Named agent personas (*.agent.md)
328
+ ├── .github/skills/ # Project-level skills
329
+ └── .agents/skills/ # Legacy skill location
330
+ \`\`\`
331
+
332
+ ## .env Files
333
+
334
+ - Loaded into shell environment at session start
335
+ - Injected into MCP server \`env\` fields automatically
336
+ - **Never read or display .env contents** — secrets must stay out of chat context
337
+
338
+ ## Agent Personas
339
+
340
+ Files in \`<workspace>/agents/*.agent.md\` define named personas. Users switch with \`/agent <name>\`.
341
+
342
+ ## Workspace Resolution
343
+
344
+ 1. Channel-specific \`workingDirectory\` in config
345
+ 2. Bot-specific workspace: \`~/.copilot-bridge/workspaces/<bot-name>/\`
346
+ 3. Fallback to bridge cwd
347
+
348
+ ## Additional Paths
349
+
350
+ Admins can grant bots access to folders outside their workspace via the \`grant_path_access\` API.
351
+
352
+ ## Source
353
+ - Workspace resolution: \`src/core/session-manager.ts\` (resolveWorkingDirectory)
354
+ - Docs: \`docs/workspaces.md\``;
355
+ }
356
+ // ---------------------------------------------------------------------------
357
+ // Topic: hooks
358
+ // ---------------------------------------------------------------------------
359
+ function topicHooks() {
360
+ return `# Hooks
361
+
362
+ Hooks run shell commands at session lifecycle points. They can allow, deny, or prompt for tool usage.
363
+
364
+ ## Configuration
365
+
366
+ Hooks are defined in \`hooks.json\` files, discovered in order (lowest → highest priority):
367
+ 1. Plugin hooks (\`~/.copilot/installed-plugins/**/hooks.json\`)
368
+ 2. User hooks (\`~/.copilot/hooks.json\`)
369
+ 3. Workspace hooks (\`<workspace>/.github/hooks/hooks.json\`, \`<workspace>/.github/hooks.json\`, or \`<workspace>/hooks.json\`) — requires \`allowWorkspaceHooks: true\` in config
370
+
371
+ ## Format
372
+
373
+ \`\`\`json
374
+ {
375
+ "version": 1,
376
+ "hooks": {
377
+ "preToolUse": [
378
+ {
379
+ "type": "command",
380
+ "bash": "./scripts/guard.sh",
381
+ "timeoutSec": 5
382
+ }
383
+ ]
384
+ }
385
+ }
386
+ \`\`\`
387
+
388
+ ## Hook Types
389
+
390
+ | Type | When | Can Control? |
391
+ |------|------|-------------|
392
+ | \`preToolUse\` | Before tool execution | Yes — allow/deny/ask |
393
+ | \`postToolUse\` | After tool execution | No |
394
+
395
+ ## Hook Script I/O
396
+
397
+ - **Input**: JSON on stdin with \`toolName\`, \`toolArgs\`, \`sessionId\`
398
+ - **Output**: JSON on stdout with \`permissionDecision\` (\`"allow"\`, \`"deny"\`, \`"ask"\`)
399
+ - **Important**: \`toolArgs\` may be a JSON string (not object) — parse with \`jq '(.toolArgs | if type == "string" then fromjson else . end)'\`
400
+
401
+ ## Performance
402
+
403
+ Hooks fire on **every tool call** — keep scripts fast. Use low \`timeoutSec\` (5s) and early-exit for non-matching tools.
404
+
405
+ ## Source
406
+ - Hook loading: \`src/core/hooks-loader.ts\`
407
+ - Hook integration: \`src/core/session-manager.ts\` (resolveHooks, wrapHooksWithAsk)
408
+ - Docs: \`docs/configuration.md\` (Hooks section)`;
409
+ }
410
+ // ---------------------------------------------------------------------------
411
+ // Topic: skills
412
+ // ---------------------------------------------------------------------------
413
+ function topicSkills() {
414
+ return `# Skills
415
+
416
+ Skills are prompt-based capabilities discovered from standard Copilot directory conventions.
417
+
418
+ ## Discovery Paths (checked in order)
419
+
420
+ 1. \`~/.copilot/skills/\` — user-level
421
+ 2. \`~/.agents/skills/\` — user-level (alternate)
422
+ 3. \`<workspace>/.github/skills/\` — project-level (standard)
423
+ 4. \`<workspace>/.agents/skills/\` — project-level (legacy)
424
+ 5. \`~/.copilot/installed-plugins/**/skills/\` — plugin skills
425
+
426
+ Each subdirectory in these locations is a skill. Skills contain a \`SKILL.md\` file with instructions.
427
+
428
+ ## Managing Skills
429
+
430
+ | Command | Effect |
431
+ |---------|--------|
432
+ | \`/skills\` | List all discovered skills and their status |
433
+ | \`/skills enable <name>\` | Enable a disabled skill |
434
+ | \`/skills disable <name>\` | Disable a skill for this channel |
435
+
436
+ Disabled skills are persisted per-channel in SQLite and passed to the SDK as \`disabledSkills\`.
437
+
438
+ ## Source
439
+ - Skill discovery: \`src/core/session-manager.ts\` (discoverSkillDirectories)
440
+ - Skill toggle: \`src/core/command-handler.ts\` (/skills command)
441
+ - State: \`src/state/store.ts\` (channel_prefs.disabled_skills)`;
442
+ }
443
+ // ---------------------------------------------------------------------------
444
+ // Topic: inter-agent
445
+ // ---------------------------------------------------------------------------
446
+ function topicInterAgent() {
447
+ return `# Inter-Agent Communication
448
+
449
+ Bots can query each other via the \`ask_agent\` tool, creating ephemeral sessions.
450
+
451
+ ## Configuration
452
+
453
+ \`\`\`json
454
+ {
455
+ "interAgent": {
456
+ "enabled": true,
457
+ "defaultTimeout": 60,
458
+ "maxTimeout": 300,
459
+ "maxDepth": 3,
460
+ "allow": {
461
+ "bot-a": { "canCall": ["bot-b"], "canBeCalledBy": ["bot-b"] },
462
+ "bot-b": { "canCall": ["bot-a"], "canBeCalledBy": ["bot-a"] },
463
+ "helper": { "canCall": [], "canBeCalledBy": ["*"] }
464
+ }
465
+ }
466
+ }
467
+ \`\`\`
468
+
469
+ ## How It Works
470
+
471
+ 1. Agent calls \`ask_agent({ target: "other-bot", message: "question" })\`
472
+ 2. Bridge validates allowlist and depth limits
473
+ 3. Creates ephemeral session for target bot with its own workspace/AGENTS.md
474
+ 4. Sends message, collects response, tears down session
475
+ 5. Returns response to calling agent
476
+
477
+ ## Tool Parameters
478
+
479
+ | Param | Required | Description |
480
+ |-------|----------|-------------|
481
+ | \`target\` | Yes | Bot name to ask |
482
+ | \`message\` | Yes | Question or request |
483
+ | \`agent\` | No | Specific agent persona |
484
+ | \`timeout\` | No | Timeout in seconds |
485
+ | \`autopilot\` | No | Auto-approve tools in target session |
486
+ | \`denyTools\` | No | Tools to deny in target session |
487
+ | \`grantTools\` | No | Tools to pre-approve |
488
+
489
+ ## Safety
490
+
491
+ - **Allowlist**: Both caller and target must be configured
492
+ - **Depth limit**: Prevents infinite chains (default: 3)
493
+ - **Visited set**: Same bot can't be called twice in a chain
494
+ - **Audit**: All calls logged to SQLite \`agent_calls\` table
495
+
496
+ ## Source
497
+ - Inter-agent logic: \`src/core/inter-agent.ts\`
498
+ - Ephemeral sessions: \`src/core/session-manager.ts\` (executeEphemeralCall)
499
+ - Docs: \`docs/configuration.md\` (Inter-agent section)`;
500
+ }
501
+ // ---------------------------------------------------------------------------
502
+ // Topic: scheduling
503
+ // ---------------------------------------------------------------------------
504
+ function topicScheduling() {
505
+ return `# Task Scheduling
506
+
507
+ The \`schedule\` tool allows creating recurring (cron) or one-off scheduled tasks.
508
+
509
+ ## How It Works
510
+
511
+ Tasks are stored in SQLite and checked by a timer. When a task fires, it sends the configured prompt to the bot's channel as if a user sent it.
512
+
513
+ ## Creating Tasks
514
+
515
+ Via the \`schedule\` tool:
516
+ - **Recurring**: \`schedule({ action: "create", prompt: "Check for updates", cron: "0 9 * * 1-5", timezone: "America/Los_Angeles" })\`
517
+ - **One-off**: \`schedule({ action: "create", prompt: "Remind me about the meeting", run_at: "2026-03-20T15:00:00Z" })\`
518
+
519
+ ## Managing Tasks
520
+
521
+ | Action | Description |
522
+ |--------|-------------|
523
+ | \`create\` | Create a new task (requires \`prompt\` + \`cron\` or \`run_at\`) |
524
+ | \`list\` | List all tasks for this channel |
525
+ | \`cancel\` | Cancel a task by ID |
526
+ | \`pause\` | Pause a recurring task |
527
+ | \`resume\` | Resume a paused task |
528
+
529
+ User command: \`/schedule\` or \`/tasks\` lists all scheduled tasks.
530
+
531
+ ## Timezone
532
+
533
+ - \`cron\` expressions are evaluated in the specified \`timezone\` (default: UTC)
534
+ - \`run_at\` is always ISO 8601 (include \`Z\` suffix for UTC)
535
+ - Display uses the task's timezone
536
+
537
+ ## Source
538
+ - Schedule tool: \`src/core/session-manager.ts\` (buildScheduleToolDef)
539
+ - Job storage/execution: \`src/core/scheduler.ts\``;
540
+ }
541
+ // ---------------------------------------------------------------------------
542
+ // Topic: troubleshooting
543
+ // ---------------------------------------------------------------------------
544
+ function topicTroubleshooting(isAdmin) {
545
+ const logNote = isAdmin
546
+ ? 'Logs are at `~/.copilot-bridge/copilot-bridge.log`. Use `grep` to search for relevant errors.'
547
+ : 'Ask the user or admin to check `~/.copilot-bridge/copilot-bridge.log` for error details.';
548
+ return `# Troubleshooting
549
+
550
+ ${logNote}
551
+
552
+ ## Common Issues
553
+
554
+ ### MCP server not loading
555
+ - Check logs for MCP startup errors
556
+ - Verify env vars in workspace \`.env\`
557
+ - Run \`/reload\` after config changes
558
+ - Use \`/mcp\` to see loaded servers and their source
559
+
560
+ ### Permission prompt not appearing
561
+ - Check if \`/yolo\` or \`/autopilot\` is enabled (\`/status\` shows this)
562
+ - Check \`permissions\` config for matching allow rules
563
+ - Stored rules from \`/always approve\` may be auto-allowing
564
+
565
+ ### Model errors / fallback
566
+ - The bridge auto-falls back on capacity/availability errors
567
+ - "Failed to get response" with "Unknown error" = transient API issue (not model-specific, no fallback)
568
+ - Use \`/model\` to check current model and available alternatives
569
+
570
+ ### Stale session
571
+ - \`/new\` creates a fresh session
572
+ - \`/reload\` re-attaches the same session with updated config
573
+ - After bridge restart, sessions auto-resume
574
+
575
+ ### Context window full
576
+ - \`/context\` shows current usage
577
+ - Enable \`infiniteSessions\` in config for automatic compaction
578
+ - \`/new\` starts fresh
579
+
580
+ ### Hooks not firing
581
+ - Check hook script permissions (\`chmod +x\`)
582
+ - Workspace hooks need \`allowWorkspaceHooks: true\` in config
583
+ - Hook timeout may be too short (check \`timeoutSec\`)
584
+
585
+ ## Filing Issues
586
+
587
+ Report bugs at: https://github.com/ChrisRomp/copilot-bridge/issues
588
+
589
+ Use the repository's issue templates:
590
+ - **Bug report**: Summary, Steps to Reproduce, Expected/Actual Behavior
591
+ - **Feature request**: Summary, Motivation, Proposed Solution
592
+
593
+ Always include:
594
+ - Bridge version (\`/status\` or \`fetch_copilot_bridge_documentation({ topic: "status" })\`)
595
+ - Relevant log excerpts (redact any unique identifiers, tokens, or URLs)
596
+ - Platform (macOS/Linux) and Node.js version
597
+
598
+ ## Source
599
+ - Issue templates: \`.github/ISSUE_TEMPLATE/\`
600
+ - Model fallback: \`src/core/model-fallback.ts\`
601
+ - Loop detection: \`src/core/loop-detector.ts\``;
602
+ }
603
+ function topicStatus(ctx) {
604
+ const version = getVersion();
605
+ const config = getConfig();
606
+ const lines = ['# Bridge Status (Live)', ''];
607
+ lines.push(`- **Version**: ${version}`);
608
+ lines.push(`- **Platforms**: ${Object.keys(config.platforms).join(', ') || 'none'}`);
609
+ lines.push(`- **Log level**: ${config.logLevel ?? 'info'}`);
610
+ lines.push(`- **Infinite sessions**: ${config.infiniteSessions ? 'enabled' : 'disabled'}`);
611
+ if (ctx.model)
612
+ lines.push(`- **Current model**: ${ctx.model}`);
613
+ if (ctx.sessionId)
614
+ lines.push(`- **Session ID**: \`${ctx.sessionId}\``);
615
+ // Configured bots (from platforms)
616
+ const bots = new Set();
617
+ for (const platform of Object.values(config.platforms)) {
618
+ if (platform.bots) {
619
+ for (const name of Object.keys(platform.bots))
620
+ bots.add(name);
621
+ }
622
+ }
623
+ if (bots.size > 0) {
624
+ lines.push(`- **Configured bots**: ${[...bots].join(', ')}`);
625
+ }
626
+ lines.push('');
627
+ lines.push('## Source');
628
+ lines.push('- Config: `src/config.ts`');
629
+ lines.push('- Session manager: `src/core/session-manager.ts`');
630
+ return lines.join('\n');
631
+ }
632
+ export function getBridgeDocs(req) {
633
+ if (!req.topic) {
634
+ return `# copilot-bridge Documentation
635
+
636
+ Use this tool with a \`topic\` parameter to get focused information.
637
+
638
+ ${topicList()}`;
639
+ }
640
+ if (!isValidTopic(req.topic)) {
641
+ return `Unknown topic: "${req.topic}"\n\n${topicList()}`;
642
+ }
643
+ switch (req.topic) {
644
+ case 'overview': return topicOverview();
645
+ case 'commands': return topicCommands();
646
+ case 'config': return topicConfig(req.isAdmin);
647
+ case 'mcp': return topicMcp();
648
+ case 'permissions': return topicPermissions();
649
+ case 'workspaces': return topicWorkspaces();
650
+ case 'hooks': return topicHooks();
651
+ case 'skills': return topicSkills();
652
+ case 'inter-agent': return topicInterAgent();
653
+ case 'scheduling': return topicScheduling();
654
+ case 'troubleshooting': return topicTroubleshooting(req.isAdmin);
655
+ case 'status': return topicStatus({ channelId: req.channelId, model: req.model, sessionId: req.sessionId });
656
+ }
657
+ }
658
+ //# sourceMappingURL=bridge-docs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge-docs.js","sourceRoot":"","sources":["../../src/core/bridge-docs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,GAAG,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC;AAExC,MAAM,MAAM,GAAG;IACb,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,YAAY;IACpE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,iBAAiB,EAAE,QAAQ;CACnE,CAAC;AAIX,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAiB,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/D,IAAI,cA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