xcode-copilot-server 3.0.0 → 3.1.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 (112) hide show
  1. package/dist/cli-validators.d.ts +2 -0
  2. package/dist/cli-validators.js +8 -1
  3. package/dist/cli-validators.js.map +1 -1
  4. package/dist/config.js +1 -1
  5. package/dist/config.js.map +1 -1
  6. package/dist/index.js +48 -2
  7. package/dist/index.js.map +1 -1
  8. package/dist/launchd/agent.d.ts +52 -0
  9. package/dist/launchd/agent.js +185 -0
  10. package/dist/launchd/agent.js.map +1 -0
  11. package/dist/launchd/index.d.ts +4 -0
  12. package/dist/launchd/index.js +3 -0
  13. package/dist/launchd/index.js.map +1 -0
  14. package/dist/launchd/socket.d.ts +5 -0
  15. package/dist/launchd/socket.js +31 -0
  16. package/dist/launchd/socket.js.map +1 -0
  17. package/dist/launchd-agent.d.ts +50 -0
  18. package/dist/launchd-agent.js +175 -0
  19. package/dist/launchd-agent.js.map +1 -0
  20. package/dist/launchd-socket.d.ts +5 -0
  21. package/dist/launchd-socket.js +33 -0
  22. package/dist/launchd-socket.js.map +1 -0
  23. package/dist/startup.d.ts +2 -0
  24. package/dist/startup.js +44 -5
  25. package/dist/startup.js.map +1 -1
  26. package/package.json +8 -5
  27. package/LICENSE +0 -21
  28. package/README.md +0 -269
  29. package/dist/config-schema.d.ts +0 -85
  30. package/dist/config-schema.js +0 -38
  31. package/dist/config-schema.js.map +0 -1
  32. package/dist/handlers/completions/session-config.d.ts +0 -12
  33. package/dist/handlers/completions/session-config.js +0 -63
  34. package/dist/handlers/completions/session-config.js.map +0 -1
  35. package/dist/handlers/completions/streaming.d.ts +0 -4
  36. package/dist/handlers/completions/streaming.js +0 -121
  37. package/dist/handlers/completions/streaming.js.map +0 -1
  38. package/dist/handlers/completions.d.ts +0 -4
  39. package/dist/handlers/completions.js +0 -120
  40. package/dist/handlers/completions.js.map +0 -1
  41. package/dist/handlers/errors.d.ts +0 -5
  42. package/dist/handlers/errors.js +0 -10
  43. package/dist/handlers/errors.js.map +0 -1
  44. package/dist/handlers/messages/count-tokens.d.ts +0 -3
  45. package/dist/handlers/messages/count-tokens.js +0 -72
  46. package/dist/handlers/messages/count-tokens.js.map +0 -1
  47. package/dist/handlers/messages/streaming.d.ts +0 -6
  48. package/dist/handlers/messages/streaming.js +0 -274
  49. package/dist/handlers/messages/streaming.js.map +0 -1
  50. package/dist/handlers/messages/tool-result-handler.d.ts +0 -4
  51. package/dist/handlers/messages/tool-result-handler.js +0 -19
  52. package/dist/handlers/messages/tool-result-handler.js.map +0 -1
  53. package/dist/handlers/messages.d.ts +0 -4
  54. package/dist/handlers/messages.js +0 -150
  55. package/dist/handlers/messages.js.map +0 -1
  56. package/dist/handlers/models.d.ts +0 -3
  57. package/dist/handlers/models.js +0 -28
  58. package/dist/handlers/models.js.map +0 -1
  59. package/dist/handlers/responses/streaming.d.ts +0 -6
  60. package/dist/handlers/responses/streaming.js +0 -265
  61. package/dist/handlers/responses/streaming.js.map +0 -1
  62. package/dist/handlers/responses/tool-result-handler.d.ts +0 -4
  63. package/dist/handlers/responses/tool-result-handler.js +0 -9
  64. package/dist/handlers/responses/tool-result-handler.js.map +0 -1
  65. package/dist/handlers/responses.d.ts +0 -4
  66. package/dist/handlers/responses.js +0 -164
  67. package/dist/handlers/responses.js.map +0 -1
  68. package/dist/handlers/session-config.d.ts +0 -15
  69. package/dist/handlers/session-config.js +0 -79
  70. package/dist/handlers/session-config.js.map +0 -1
  71. package/dist/handlers/streaming-utils.d.ts +0 -10
  72. package/dist/handlers/streaming-utils.js +0 -22
  73. package/dist/handlers/streaming-utils.js.map +0 -1
  74. package/dist/providers/anthropic.d.ts +0 -5
  75. package/dist/providers/anthropic.js +0 -28
  76. package/dist/providers/anthropic.js.map +0 -1
  77. package/dist/providers/codex.d.ts +0 -5
  78. package/dist/providers/codex.js +0 -24
  79. package/dist/providers/codex.js.map +0 -1
  80. package/dist/providers/openai.d.ts +0 -5
  81. package/dist/providers/openai.js +0 -25
  82. package/dist/providers/openai.js.map +0 -1
  83. package/dist/schemas/anthropic.d.ts +0 -140
  84. package/dist/schemas/anthropic.js +0 -58
  85. package/dist/schemas/anthropic.js.map +0 -1
  86. package/dist/schemas/openai.d.ts +0 -98
  87. package/dist/schemas/openai.js +0 -76
  88. package/dist/schemas/openai.js.map +0 -1
  89. package/dist/schemas/responses.d.ts +0 -122
  90. package/dist/schemas/responses.js +0 -54
  91. package/dist/schemas/responses.js.map +0 -1
  92. package/dist/schemas.d.ts +0 -49
  93. package/dist/schemas.js +0 -75
  94. package/dist/schemas.js.map +0 -1
  95. package/dist/settings-patcher/anthropic.d.ts +0 -5
  96. package/dist/settings-patcher/anthropic.js +0 -75
  97. package/dist/settings-patcher/anthropic.js.map +0 -1
  98. package/dist/types.d.ts +0 -83
  99. package/dist/types.js +0 -2
  100. package/dist/types.js.map +0 -1
  101. package/dist/utils/anthropic-prompt.d.ts +0 -2
  102. package/dist/utils/anthropic-prompt.js +0 -52
  103. package/dist/utils/anthropic-prompt.js.map +0 -1
  104. package/dist/utils/model-resolver.d.ts +0 -3
  105. package/dist/utils/model-resolver.js +0 -45
  106. package/dist/utils/model-resolver.js.map +0 -1
  107. package/dist/utils/prompt.d.ts +0 -3
  108. package/dist/utils/prompt.js +0 -50
  109. package/dist/utils/prompt.js.map +0 -1
  110. package/dist/utils/responses-prompt.d.ts +0 -4
  111. package/dist/utils/responses-prompt.js +0 -58
  112. package/dist/utils/responses-prompt.js.map +0 -1
package/README.md DELETED
@@ -1,269 +0,0 @@
1
- # xcode-copilot-server [![npm version](https://img.shields.io/npm/v/xcode-copilot-server)](https://www.npmjs.com/package/xcode-copilot-server)
2
-
3
- A proxy API server that lets you use GitHub Copilot in Xcode, either as a custom model provider or as the backend for Claude Agent and Codex Agent.
4
-
5
- ## Why
6
-
7
- Xcode 26 added support for third-party LLM providers, but it only supports ChatGPT and Claude out of the box. If you have a GitHub Copilot subscription, there's no built-in way to use it.
8
-
9
- This server bridges the gap by wrapping the [GitHub Copilot SDK](https://github.com/github/copilot-sdk) and exposing it as an API that Xcode can talk to. It supports three providers:
10
-
11
- - **OpenAI** (default): Exposes an OpenAI-compatible completions API so Xcode can use Copilot as a custom model provider. Xcode handles tool execution directly.
12
- - **Claude**: Exposes an Anthropic-compatible API so Xcode can use Copilot as the backend for Claude Agent. A built-in tool bridge intercepts tool calls and routes them back to Xcode for execution.
13
- - **Codex**: Exposes an OpenAI Responses-compatible API so Xcode can use Copilot as the backend for Codex Agent. Same tool bridge as Claude.
14
-
15
- In OpenAI mode, the server also connects to Xcode's built-in MCP tools (via `xcrun mcpbridge`), giving Copilot access to your project's build logs, indexes and other context. This requires Xcode 26.3 or later. Claude and Codex handle MCP internally through their own agents.
16
-
17
- ## Installation
18
-
19
- You need [Node.js](https://nodejs.org) 25.6.0 or later and a GitHub Copilot subscription. Before starting the server, authenticate using one of the following methods (the Copilot CLI is bundled with the SDK, so you only need one of these for initial sign-in):
20
-
21
- - [Install the Copilot CLI](https://docs.github.com/en/copilot/how-tos/copilot-cli/install-copilot-cli) and run `copilot login`
22
- - [Install the GitHub CLI](https://cli.github.com/) and run `gh auth login`
23
- - Set a `GITHUB_TOKEN` environment variable with a valid fine-grained Copilot access token
24
-
25
- Then install the server via:
26
-
27
- ```bash
28
- npm install -g xcode-copilot-server
29
- ```
30
-
31
- Or run it without installing globally:
32
-
33
- ```bash
34
- npx xcode-copilot-server
35
- ```
36
-
37
- ## Usage
38
-
39
- ```bash
40
- xcode-copilot-server [options]
41
-
42
- Options:
43
- -p, --port <number> Port to listen on (default: 8080)
44
- --proxy <provider> API format: openai, claude, codex (default: openai)
45
- -l, --log-level <level> Log verbosity (default: info)
46
- -c, --config <path> Path to config file
47
- --cwd <path> Working directory for Copilot sessions
48
- --auto-patch Auto-patch settings on start, restore on exit
49
- -v, --version Output the version number
50
- -h, --help Show help
51
-
52
- Commands:
53
- patch-settings Patch provider settings and exit (--proxy claude or codex)
54
- restore-settings Restore provider settings from backup and exit
55
- ```
56
-
57
- The `--proxy` flag determines which API the server exposes:
58
-
59
- | Provider | Flag | Routes |
60
- |----------|----------------------------|-------------------------------------------------------|
61
- | OpenAI | `--proxy openai` (default) | `GET /v1/models`, `POST /v1/chat/completions` |
62
- | Claude | `--proxy claude` | `POST /v1/messages`, `POST /v1/messages/count_tokens` |
63
- | Codex | `--proxy codex` | `POST /v1/responses` |
64
-
65
- ## Xcode integration
66
-
67
- ### OpenAI (custom model provider)
68
-
69
- 1. Start the server: `xcode-copilot-server`
70
- 2. Open Xcode and go to Settings > Intelligence > Add a provider
71
- 3. Select "Locally hosted" and set the port to 8080 (or the port that you've chosen)
72
- 4. Give it a description e.g. "Copilot"
73
- 5. Save
74
-
75
- To enable tool calling, select the provider and enable "Allow tools" under "Advanced". To connect Xcode's MCP tools (Xcode 26.3+), enable "Xcode Tools" under "Model Context Protocol".
76
-
77
- ### Claude (Claude Agent)
78
-
79
- 1. Open Xcode and go to Settings > Intelligence > Anthropic > Claude Agent
80
- 2. Enable Claude Agent and sign in with an API key (the key can be any random text, since the calls are proxied through the server)
81
- 3. Start the server with `--auto-patch` to automatically configure `settings.json`:
82
-
83
- ```bash
84
- xcode-copilot-server --proxy claude --auto-patch
85
- ```
86
-
87
- This creates (or updates) `settings.json` at `~/Library/Developer/Xcode/CodingAssistant/ClaudeAgentConfig/` to point to the server, and restores the original file when the server shuts down. If `settings.json` already exists, a backup is saved as `settings.json.backup` and restored on exit.
88
-
89
- Alternatively, you can manage `settings.json` yourself. Create it manually at the path above:
90
-
91
- ```json
92
- {
93
- "env": {
94
- "ANTHROPIC_BASE_URL": "http://localhost:8080",
95
- "ANTHROPIC_AUTH_TOKEN": "12345"
96
- }
97
- }
98
- ```
99
-
100
- Set the port to match your `--port` flag (default 8080). The auth token can be any non-empty string. Then start the server without `--auto-patch`:
101
-
102
- ```bash
103
- xcode-copilot-server --proxy claude
104
- ```
105
-
106
- You can also use the `patch-settings` and `restore-settings` subcommands to patch or restore settings without starting the server:
107
-
108
- ```bash
109
- xcode-copilot-server patch-settings --proxy claude --port 8080
110
- xcode-copilot-server restore-settings --proxy claude
111
- ```
112
-
113
- The tool bridge is enabled by default for Claude (`toolBridge: true` in the config). It intercepts tool calls from the Copilot session and forwards them to Xcode, so Claude Agent can read files, search code, and make edits through the IDE.
114
-
115
- ### Codex (Codex Agent)
116
-
117
- 1. Open Xcode and go to Settings > Intelligence > OpenAI > Codex Agent
118
- 2. Enable Codex Agent and sign in with an API key (the key can be any random text, since the calls are proxied through the server)
119
- 3. Start the server with `--auto-patch` to automatically configure the environment:
120
-
121
- ```bash
122
- xcode-copilot-server --proxy codex --auto-patch
123
- ```
124
-
125
- This sets `OPENAI_BASE_URL` and `OPENAI_API_KEY` via `launchctl setenv` so Xcode (and any Codex process it spawns) can reach the server. The original values are backed up and restored when the server shuts down. If Xcode was already running, you might need to restart it so it picks up the new environment variables.
126
-
127
- Alternatively, you can set the environment variables yourself via `launchctl`:
128
-
129
- ```bash
130
- launchctl setenv OPENAI_BASE_URL http://localhost:8080/v1
131
- launchctl setenv OPENAI_API_KEY 12345
132
- ```
133
-
134
- Set the port to match your `--port` flag (default 8080). The API key can be any non-empty string. Then start the server without `--auto-patch`:
135
-
136
- ```bash
137
- xcode-copilot-server --proxy codex
138
- ```
139
-
140
- To restore the original values when you're done:
141
-
142
- ```bash
143
- launchctl unsetenv OPENAI_BASE_URL
144
- launchctl unsetenv OPENAI_API_KEY
145
- ```
146
-
147
- You can also use the `patch-settings` and `restore-settings` subcommands to do this without starting the server:
148
-
149
- ```bash
150
- xcode-copilot-server patch-settings --proxy codex --port 8080
151
- xcode-copilot-server restore-settings --proxy codex
152
- ```
153
-
154
- The tool bridge works the same way as Claude, as it intercepts tool calls and routes them back to Xcode for execution.
155
-
156
- ### Agent skills
157
-
158
- [Agent skills](https://docs.github.com/en/copilot/concepts/agents/about-agent-skills) are an open standard for extending AI coding agents with specialised instructions and resources. All three providers support them through the underlying Copilot SDK session, and each agent also has its own skill paths:
159
-
160
- | Agent | Project skills | Personal skills |
161
- |---------|--------------------------------------------|------------------------|
162
- | Copilot | `.github/skills/`, `.claude/skills/` | `~/.copilot/skills/` |
163
- | Claude | `.claude/skills/` | `~/.claude/skills/` |
164
- | Codex | `.codex/skills/` | `~/.codex/skills/` |
165
-
166
- ## Configuration
167
-
168
- The server reads its configuration from a `config.json5` file. By default, it uses the bundled one, but you can point to your own with `--config`:
169
-
170
- ```bash
171
- xcode-copilot-server --config ./my-config.json5
172
- ```
173
-
174
- The config file uses [JSON5](https://json5.org/) format, which supports comments and trailing commas. The `--proxy` flag determines which provider section (`openai`, `claude`, or `codex`) is used at runtime:
175
-
176
- ```json5
177
- {
178
- openai: {
179
- // No tool bridge needed, as Xcode drives tool execution directly.
180
- toolBridge: false,
181
-
182
- mcpServers: {
183
- // Proxies Apple's xcrun mcpbridge (Xcode 26.3+).
184
- xcode: {
185
- type: "local",
186
- command: "node",
187
- args: ["./scripts/mcpbridge-proxy.mjs"],
188
- allowedTools: ["*"],
189
- },
190
- },
191
- },
192
-
193
- claude: {
194
- // Intercepts tool calls and forwards them to Xcode so Claude Agent
195
- // drives tool execution through the IDE instead of the Copilot CLI.
196
- toolBridge: true,
197
-
198
- // No MCP servers needed, as Claude Agent handles tools natively.
199
- mcpServers: {},
200
- },
201
-
202
- codex: {
203
- // Same as Claude: intercepts tool calls and forwards them to Xcode
204
- // so Codex drives tool execution through the IDE.
205
- toolBridge: true,
206
-
207
- mcpServers: {},
208
- },
209
-
210
- // Built-in CLI tools allowlist.
211
- // ["*"] to allow all, [] to deny all, or a list of specific tool names.
212
- //
213
- // Empty by default so Xcode can handle all operations (search, read, edit)
214
- // through its UI. Enabling CLI tools lets the Copilot session perform
215
- // those operations directly, bypassing Xcode.
216
- allowedCliTools: [],
217
-
218
- // Maximum request body size in MiB.
219
- bodyLimitMiB: 10,
220
-
221
- // Filename patterns to filter out from search results in the prompt.
222
- //
223
- // Xcode can include full file contents for every search match, so add patterns
224
- // here to strip files that bloat the prompt (e.g. ["mock", "generated"]).
225
- excludedFilePatterns: [],
226
-
227
- // Reasoning effort for models that support it: "low", "medium", "high", "xhigh"
228
- reasoningEffort: "xhigh",
229
-
230
- // Auto-approve permission requests.
231
- // true to approve all, false to deny all,
232
- // or an array of kinds: "read", "write", "shell", "mcp", "url"
233
- autoApprovePermissions: ["read", "mcp"],
234
- }
235
- ```
236
-
237
- ## Security
238
-
239
- This server acts as a local proxy between Xcode and GitHub Copilot. It's designed to run on your machine and isn't intended to be exposed to the internet or shared networks. So, here's what you should know:
240
-
241
- - The server binds to `127.0.0.1`, so it's only reachable from your machine. Incoming requests are checked for expected user-agent headers (`Xcode/` for OpenAI and Codex, `claude-cli/` for Claude), which means casual or accidental connections from other tools will be rejected. This isn't a strong security boundary since user-agent headers can be trivially spoofed, but it helps ensure only the expected client is talking to the server.
242
-
243
- - The bundled config sets `autoApprovePermissions` to `["read", "mcp"]`, which lets the Copilot session read files and call MCP tools without prompting. Writes, shell commands, and URL fetches are denied by default. You can set it to `true` to approve everything, `false` to deny everything, or pick specific kinds from `"read"`, `"write"`, `"shell"`, `"mcp"`, and `"url"`.
244
-
245
- - MCP servers defined in the config are spawned as child processes. The bundled config uses `xcrun mcpbridge`, which is an Apple-signed binary. If you add your own MCP servers, make sure you trust the commands you're configuring.
246
-
247
- ## License
248
-
249
- MIT License
250
-
251
- Copyright (c) 2026 Suyash Srijan
252
-
253
- Permission is hereby granted, free of charge, to any person obtaining a copy
254
- of this software and associated documentation files (the "Software"), to deal
255
- in the Software without restriction, including without limitation the rights
256
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
257
- copies of the Software, and to permit persons to whom the Software is
258
- furnished to do so, subject to the following conditions:
259
-
260
- The above copyright notice and this permission notice shall be included in all
261
- copies or substantial portions of the Software.
262
-
263
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
264
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
265
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
266
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
267
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
268
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
269
- SOFTWARE.
@@ -1,85 +0,0 @@
1
- import { z } from "zod";
2
- declare const MCPLocalServerSchema: z.ZodObject<{
3
- type: z.ZodUnion<readonly [z.ZodLiteral<"local">, z.ZodLiteral<"stdio">]>;
4
- command: z.ZodString;
5
- args: z.ZodArray<z.ZodString>;
6
- env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
7
- cwd: z.ZodOptional<z.ZodString>;
8
- allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
9
- timeout: z.ZodOptional<z.ZodNumber>;
10
- }, z.core.$strip>;
11
- declare const MCPRemoteServerSchema: z.ZodObject<{
12
- type: z.ZodUnion<readonly [z.ZodLiteral<"http">, z.ZodLiteral<"sse">]>;
13
- url: z.ZodURL;
14
- headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
15
- allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
16
- timeout: z.ZodOptional<z.ZodNumber>;
17
- }, z.core.$strip>;
18
- declare const MCPServerSchema: z.ZodUnion<readonly [z.ZodObject<{
19
- type: z.ZodUnion<readonly [z.ZodLiteral<"local">, z.ZodLiteral<"stdio">]>;
20
- command: z.ZodString;
21
- args: z.ZodArray<z.ZodString>;
22
- env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
23
- cwd: z.ZodOptional<z.ZodString>;
24
- allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
25
- timeout: z.ZodOptional<z.ZodNumber>;
26
- }, z.core.$strip>, z.ZodObject<{
27
- type: z.ZodUnion<readonly [z.ZodLiteral<"http">, z.ZodLiteral<"sse">]>;
28
- url: z.ZodURL;
29
- headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
30
- allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
31
- timeout: z.ZodOptional<z.ZodNumber>;
32
- }, z.core.$strip>]>;
33
- declare const ApprovalRuleSchema: z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodEnum<{
34
- url: "url";
35
- read: "read";
36
- write: "write";
37
- shell: "shell";
38
- mcp: "mcp";
39
- }>>]>;
40
- declare const ReasoningEffortSchema: z.ZodEnum<{
41
- low: "low";
42
- medium: "medium";
43
- high: "high";
44
- xhigh: "xhigh";
45
- }>;
46
- export type MCPLocalServer = z.infer<typeof MCPLocalServerSchema>;
47
- export type MCPRemoteServer = z.infer<typeof MCPRemoteServerSchema>;
48
- export type MCPServer = z.infer<typeof MCPServerSchema>;
49
- export type ApprovalRule = z.infer<typeof ApprovalRuleSchema>;
50
- export type ReasoningEffort = z.infer<typeof ReasoningEffortSchema>;
51
- export declare const ServerConfigSchema: z.ZodObject<{
52
- mcpServers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
53
- type: z.ZodUnion<readonly [z.ZodLiteral<"local">, z.ZodLiteral<"stdio">]>;
54
- command: z.ZodString;
55
- args: z.ZodArray<z.ZodString>;
56
- env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
57
- cwd: z.ZodOptional<z.ZodString>;
58
- allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
59
- timeout: z.ZodOptional<z.ZodNumber>;
60
- }, z.core.$strip>, z.ZodObject<{
61
- type: z.ZodUnion<readonly [z.ZodLiteral<"http">, z.ZodLiteral<"sse">]>;
62
- url: z.ZodURL;
63
- headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
64
- allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
65
- timeout: z.ZodOptional<z.ZodNumber>;
66
- }, z.core.$strip>]>>>;
67
- allowedCliTools: z.ZodDefault<z.ZodArray<z.ZodString>>;
68
- excludedFilePatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
69
- bodyLimitMiB: z.ZodDefault<z.ZodNumber>;
70
- reasoningEffort: z.ZodOptional<z.ZodEnum<{
71
- low: "low";
72
- medium: "medium";
73
- high: "high";
74
- xhigh: "xhigh";
75
- }>>;
76
- autoApprovePermissions: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodEnum<{
77
- url: "url";
78
- read: "read";
79
- write: "write";
80
- shell: "shell";
81
- mcp: "mcp";
82
- }>>]>>;
83
- }, z.core.$strip>;
84
- export type RawServerConfig = z.infer<typeof ServerConfigSchema>;
85
- export {};
@@ -1,38 +0,0 @@
1
- import { z } from "zod";
2
- const MCPLocalServerSchema = z.object({
3
- type: z.union([z.literal("local"), z.literal("stdio")]),
4
- command: z.string().min(1, "MCP server command cannot be empty"),
5
- args: z.array(z.string()),
6
- env: z.record(z.string(), z.string()).optional(),
7
- cwd: z.string().optional(),
8
- allowedTools: z.array(z.string()).optional(),
9
- timeout: z.number().positive().optional(),
10
- });
11
- const MCPRemoteServerSchema = z.object({
12
- type: z.union([z.literal("http"), z.literal("sse")]),
13
- url: z.url(),
14
- headers: z.record(z.string(), z.string()).optional(),
15
- allowedTools: z.array(z.string()).optional(),
16
- timeout: z.number().positive().optional(),
17
- });
18
- const MCPServerSchema = z.union([MCPLocalServerSchema, MCPRemoteServerSchema]);
19
- const VALID_PERMISSION_KINDS = ["read", "write", "shell", "mcp", "url"];
20
- const ApprovalRuleSchema = z.union([
21
- z.boolean(),
22
- z.array(z.enum(VALID_PERMISSION_KINDS)),
23
- ]);
24
- const VALID_REASONING_EFFORTS = ["low", "medium", "high", "xhigh"];
25
- const ReasoningEffortSchema = z.enum(VALID_REASONING_EFFORTS);
26
- export const ServerConfigSchema = z.object({
27
- mcpServers: z.record(z.string(), MCPServerSchema).default({}),
28
- allowedCliTools: z.array(z.string()).refine((arr) => !arr.includes("*") || arr.length === 1, 'allowedCliTools: use ["*"] alone to allow all tools, don\'t mix with other entries').default([]),
29
- excludedFilePatterns: z.array(z.string()).default([]),
30
- bodyLimitMiB: z
31
- .number()
32
- .positive()
33
- .max(100, "bodyLimitMiB cannot exceed 100")
34
- .default(4),
35
- reasoningEffort: ReasoningEffortSchema.optional(),
36
- autoApprovePermissions: ApprovalRuleSchema.default(["read", "mcp"]),
37
- });
38
- //# sourceMappingURL=config-schema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config-schema.js","sourceRoot":"","sources":["../src/config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IACvD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,oCAAoC,CAAC;IAChE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACzB,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IAChD,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1B,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC5C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CAC1C,CAAC,CAAC;AAEH,MAAM,qBAAqB,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IAC7D,eAAe,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CACzC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAC/C,oFAAoF,CACrF,CAAC,OAAO,CAAC,EAAE,CAAC;IACb,oBAAoB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IACrD,YAAY,EAAE,CAAC;SACZ,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,GAAG,CAAC,GAAG,EAAE,gCAAgC,CAAC;SAC1C,OAAO,CAAC,CAAC,CAAC;IACb,eAAe,EAAE,qBAAqB,CAAC,QAAQ,EAAE;IACjD,sBAAsB,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CACpE,CAAC,CAAC"}
@@ -1,12 +0,0 @@
1
- import type { SessionConfig } from "@github/copilot-sdk";
2
- import type { ServerConfig } from "../../config.js";
3
- import type { Logger } from "../../logger.js";
4
- export interface SessionConfigOptions {
5
- model: string;
6
- systemMessage?: string | undefined;
7
- logger: Logger;
8
- config: ServerConfig;
9
- supportsReasoningEffort: boolean;
10
- cwd?: string | undefined;
11
- }
12
- export declare function createSessionConfig({ model, systemMessage, logger, config, supportsReasoningEffort, cwd, }: SessionConfigOptions): SessionConfig;
@@ -1,63 +0,0 @@
1
- function isApproved(rule, kind) {
2
- if (typeof rule === "boolean")
3
- return rule;
4
- return rule.some((k) => k === kind);
5
- }
6
- export function createSessionConfig({ model, systemMessage, logger, config, supportsReasoningEffort, cwd, }) {
7
- return {
8
- model,
9
- streaming: true,
10
- infiniteSessions: { enabled: true },
11
- workingDirectory: cwd ?? process.cwd(),
12
- ...(systemMessage && {
13
- systemMessage: {
14
- mode: "replace",
15
- content: systemMessage,
16
- },
17
- }),
18
- mcpServers: Object.fromEntries(Object.entries(config.mcpServers).map(([name, server]) => [
19
- name,
20
- { ...server, tools: ["*"] },
21
- ])),
22
- ...(config.allowedCliTools.length > 0 && {
23
- availableTools: config.allowedCliTools,
24
- }),
25
- ...(config.reasoningEffort && supportsReasoningEffort && {
26
- reasoningEffort: config.reasoningEffort,
27
- }),
28
- onUserInputRequest: (request) => {
29
- logger.debug(`User input requested: "${request.question}"`);
30
- return Promise.resolve({
31
- answer: "User input is not available. Ask your question in your response instead.",
32
- wasFreeform: true,
33
- });
34
- },
35
- onPermissionRequest: (request) => {
36
- const approved = isApproved(config.autoApprovePermissions, request.kind);
37
- logger.debug(`Permission "${request.kind}": ${approved ? "approved" : "denied"}`);
38
- return Promise.resolve(approved
39
- ? { kind: "approved" }
40
- : { kind: "denied-by-rules" });
41
- },
42
- hooks: {
43
- onPreToolUse: (input) => {
44
- const toolName = input.toolName;
45
- if (config.allowedCliTools.includes("*") ||
46
- config.allowedCliTools.includes(toolName)) {
47
- logger.debug(`Tool "${toolName}": allowed (CLI)`);
48
- return Promise.resolve({ permissionDecision: "allow" });
49
- }
50
- for (const [serverName, server] of Object.entries(config.mcpServers)) {
51
- const allowlist = server.allowedTools ?? [];
52
- if (allowlist.includes("*") || allowlist.includes(toolName)) {
53
- logger.debug(`Tool "${toolName}": allowed (${serverName})`);
54
- return Promise.resolve({ permissionDecision: "allow" });
55
- }
56
- }
57
- logger.debug(`Tool "${toolName}": denied (not in any allowlist)`);
58
- return Promise.resolve({ permissionDecision: "deny" });
59
- },
60
- },
61
- };
62
- }
63
- //# sourceMappingURL=session-config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"session-config.js","sourceRoot":"","sources":["../../../src/handlers/completions/session-config.ts"],"names":[],"mappings":"AAaA,SAAS,UAAU,CAAC,IAAkB,EAAE,IAAY;IAClD,IAAI,OAAO,IAAI,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAC3C,OAAO,IAAI,CAA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C;oBACnE,CAAC;gBACH,CAAC;gBAED,MAAM,CAAC,KAAK,CAAC,SAAS,QAAQ,kCAAkC,CAAC,CAAC;gBAClE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,kBAAkB,EAAE,MAAe,EAAE,CAAC,CAAC;YAClE,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -1,4 +0,0 @@
1
- import type { FastifyReply } from "fastify";
2
- import type { CopilotSession } from "@github/copilot-sdk";
3
- import type { Logger } from "../../logger.js";
4
- export declare function handleStreaming(reply: FastifyReply, session: CopilotSession, prompt: string, model: string, logger: Logger): Promise<boolean>;
@@ -1,121 +0,0 @@
1
- import { formatCompaction, SSE_HEADERS } from "../streaming-utils.js";
2
- import { currentTimestamp } from "../../schemas/openai.js";
3
- const REQUEST_TIMEOUT_MS = 5 * 60 * 1000;
4
- export async function handleStreaming(reply, session, prompt, model, logger) {
5
- reply.raw.writeHead(200, SSE_HEADERS);
6
- const completionId = `chatcmpl-${String(Date.now())}`;
7
- function sendChunk(delta, finishReason) {
8
- const chunk = {
9
- id: completionId,
10
- object: "chat.completion.chunk",
11
- created: currentTimestamp(),
12
- model,
13
- choices: [
14
- {
15
- index: 0,
16
- delta,
17
- finish_reason: finishReason,
18
- },
19
- ],
20
- };
21
- reply.raw.write(`data: ${JSON.stringify(chunk)}\n\n`);
22
- }
23
- sendChunk({ role: "assistant" }, null);
24
- const { promise, resolve } = Promise.withResolvers();
25
- let done = false;
26
- function cleanup() {
27
- done = true;
28
- clearTimeout(timeout);
29
- unsubscribe();
30
- }
31
- reply.raw.on("close", () => {
32
- if (!done) {
33
- logger.info("Client disconnected, aborting session");
34
- cleanup();
35
- session.abort().catch((err) => {
36
- logger.error("Failed to abort session:", err);
37
- });
38
- resolve(false);
39
- }
40
- });
41
- const timeout = setTimeout(() => {
42
- logger.warn("Stream timed out after 5 minutes");
43
- cleanup();
44
- reply.raw.end();
45
- resolve(false);
46
- }, REQUEST_TIMEOUT_MS);
47
- // buffer deltas so we can drop intermediate narration before tool calls
48
- let pendingDeltas = [];
49
- const toolNames = new Map();
50
- function flushPending() {
51
- for (const text of pendingDeltas) {
52
- sendChunk({ content: text }, null);
53
- }
54
- pendingDeltas = [];
55
- }
56
- const unsubscribe = session.on((event) => {
57
- if (event.type === "tool.execution_start") {
58
- const d = event.data;
59
- toolNames.set(d.toolCallId, d.toolName);
60
- logger.debug(`Running ${d.toolName} (${JSON.stringify(d.arguments)})`);
61
- return;
62
- }
63
- if (event.type === "tool.execution_complete") {
64
- const d = event.data;
65
- const name = toolNames.get(d.toolCallId) ?? d.toolCallId;
66
- toolNames.delete(d.toolCallId);
67
- const detail = d.success
68
- ? JSON.stringify(d.result?.content)
69
- : d.error?.message ?? "failed";
70
- logger.debug(`${name} done (${detail})`);
71
- return;
72
- }
73
- switch (event.type) {
74
- case "assistant.message_delta":
75
- if (event.data.deltaContent) {
76
- pendingDeltas.push(event.data.deltaContent);
77
- }
78
- break;
79
- case "assistant.message":
80
- if (event.data.toolRequests && event.data.toolRequests.length > 0) {
81
- logger.debug(`Calling tools (dropping buffered text): ${event.data.toolRequests.map((tr) => tr.name).join(", ")}`);
82
- pendingDeltas = [];
83
- }
84
- else {
85
- flushPending();
86
- }
87
- break;
88
- case "session.idle":
89
- logger.info("Done, wrapping up stream");
90
- flushPending();
91
- cleanup();
92
- sendChunk({}, "stop");
93
- reply.raw.write("data: [DONE]\n\n");
94
- reply.raw.end();
95
- resolve(true);
96
- break;
97
- case "session.compaction_start":
98
- logger.info("Compacting context...");
99
- break;
100
- case "session.compaction_complete":
101
- logger.info(`Context compacted: ${formatCompaction(event.data)}`);
102
- break;
103
- case "session.error":
104
- logger.error(`Session error: ${event.data.message}`);
105
- cleanup();
106
- reply.raw.end();
107
- resolve(false);
108
- break;
109
- }
110
- });
111
- session.send({ prompt }).catch((err) => {
112
- logger.error("Failed to send prompt:", err);
113
- if (!done) {
114
- cleanup();
115
- reply.raw.end();
116
- }
117
- resolve(false);
118
- });
119
- return promise;
120
- }
121
- //# sourceMappingURL=streaming.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"streaming.js","sourceRoot":"","sources":["../../../src/handlers/completions/streaming.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAwD,MAAM,yBAAyB,CAAC;AAEjH,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAEzC,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,KAAmB,EACnB,OAAuB,EACvB,MAAc,EACd,KAAa,EACb,MAAc;IAEd,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAEtC,MAAM,YAAY,GAAG,YAAY,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;IAEtD,SAAS,SAAS,CAChB,KAAqC,EACrC,YAA2B;QAE3B,MAAM,KAAK,GAAG;YACZ,EAAE,EAAE,YAAY;YAChB,MAAM,EAAE,uBAAgC;YACxC,OAAO,EAAE,gBAAgB,EAAE;YAC3B,KAAK;YACL,OAAO,EAAE;gBACP;oBACE,KAAK,EAAE,CAAC;oBACR,KAAK;oBACL,aAAa,EAAE,YAAY;iBAC5B;aACF;SAC4B,CAAC;QAChC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;IAED,SAAS,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,IAAI,CAAC,CAAC;IAEvC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,aAAa,EAAW,CAAC;IAC9D,IAAI,IAAI,GAAG,KAAK,CAAC;IAEjB,SAAS,OAAO;QACd,IAAI,GAAG,IAAI,CAAC;QACZ,YAAY,CAAC,OAAO,CAAC,CAAC;QACt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AC,CAAC;IACjB,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1,4 +0,0 @@
1
- import type { FastifyRequest, FastifyReply } from "fastify";
2
- import type { AppContext } from "../context.js";
3
- import type { ConversationManager } from "../conversation-manager.js";
4
- export declare function createCompletionsHandler({ service, logger, config }: AppContext, manager: ConversationManager): (request: FastifyRequest, reply: FastifyReply) => Promise<void>;