xcode-copilot-server 3.4.0 → 3.4.1
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/banner.d.ts +4 -4
- package/dist/banner.js +45 -12
- package/dist/banner.js.map +1 -1
- package/dist/bridge-constants.d.ts +2 -0
- package/dist/bridge-constants.js +3 -0
- package/dist/bridge-constants.js.map +1 -0
- package/dist/cli-validators.d.ts +0 -1
- package/dist/cli-validators.js +2 -2
- package/dist/cli-validators.js.map +1 -1
- package/dist/config-schema.d.ts +107 -0
- package/dist/config-schema.js +53 -0
- package/dist/config-schema.js.map +1 -0
- package/dist/config.d.ts +3 -28
- package/dist/config.js +23 -62
- package/dist/config.js.map +1 -1
- package/dist/context.d.ts +1 -1
- package/dist/conversation-manager.d.ts +9 -4
- package/dist/conversation-manager.js +44 -61
- package/dist/conversation-manager.js.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/launchd/agent.d.ts +5 -9
- package/dist/launchd/agent.js +13 -12
- package/dist/launchd/agent.js.map +1 -1
- package/dist/launchd/index.d.ts +3 -3
- package/dist/launchd/index.js +1 -1
- package/dist/launchd/index.js.map +1 -1
- package/dist/launchd/socket.d.ts +2 -1
- package/dist/providers/claude/provider.js +40 -64
- package/dist/providers/claude/provider.js.map +1 -1
- package/dist/providers/claude/streaming.d.ts +10 -1
- package/dist/providers/claude/streaming.js +7 -3
- package/dist/providers/claude/streaming.js.map +1 -1
- package/dist/providers/claude/tool-results.js +1 -1
- package/dist/providers/claude/tool-results.js.map +1 -1
- package/dist/providers/codex/provider.js +28 -60
- package/dist/providers/codex/provider.js.map +1 -1
- package/dist/providers/codex/streaming.d.ts +12 -3
- package/dist/providers/codex/streaming.js +6 -6
- package/dist/providers/codex/streaming.js.map +1 -1
- package/dist/providers/codex/tool-results.js +1 -1
- package/dist/providers/codex/tool-results.js.map +1 -1
- package/dist/providers/index.d.ts +4 -23
- package/dist/providers/index.js +1 -1
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/names.d.ts +4 -0
- package/dist/providers/names.js +7 -0
- package/dist/providers/names.js.map +1 -0
- package/dist/providers/openai/provider.js +5 -14
- package/dist/providers/openai/provider.js.map +1 -1
- package/dist/providers/shared/continuation.d.ts +10 -0
- package/dist/providers/shared/continuation.js +18 -0
- package/dist/providers/shared/continuation.js.map +1 -0
- package/dist/providers/shared/prompt-utils.d.ts +0 -11
- package/dist/providers/shared/prompt-utils.js +0 -11
- package/dist/providers/shared/prompt-utils.js.map +1 -1
- package/dist/providers/shared/session-config.d.ts +12 -3
- package/dist/providers/shared/session-config.js +24 -7
- package/dist/providers/shared/session-config.js.map +1 -1
- package/dist/providers/shared/streaming-core.d.ts +12 -2
- package/dist/providers/shared/streaming-core.js +183 -161
- package/dist/providers/shared/streaming-core.js.map +1 -1
- package/dist/providers/shared/streaming-orchestrator.d.ts +11 -0
- package/dist/providers/shared/streaming-orchestrator.js +11 -0
- package/dist/providers/shared/streaming-orchestrator.js.map +1 -0
- package/dist/providers/shared/user-agent-guard.d.ts +3 -0
- package/dist/providers/shared/user-agent-guard.js +17 -0
- package/dist/providers/shared/user-agent-guard.js.map +1 -0
- package/dist/settings-patcher/claude.d.ts +1 -2
- package/dist/settings-patcher/claude.js +35 -13
- package/dist/settings-patcher/claude.js.map +1 -1
- package/dist/settings-patcher/codex.d.ts +1 -20
- package/dist/settings-patcher/codex.js +58 -31
- package/dist/settings-patcher/codex.js.map +1 -1
- package/dist/settings-patcher/index.d.ts +2 -15
- package/dist/settings-patcher/index.js +15 -36
- package/dist/settings-patcher/index.js.map +1 -1
- package/dist/settings-patcher/types.d.ts +21 -0
- package/dist/settings-patcher/url-utils.d.ts +1 -0
- package/dist/settings-patcher/url-utils.js +6 -0
- package/dist/settings-patcher/url-utils.js.map +1 -0
- package/dist/shutdown.d.ts +16 -0
- package/dist/shutdown.js +53 -0
- package/dist/shutdown.js.map +1 -0
- package/dist/startup.js +65 -139
- package/dist/startup.js.map +1 -1
- package/dist/tool-bridge/constants.d.ts +4 -2
- package/dist/tool-bridge/constants.js +4 -2
- package/dist/tool-bridge/constants.js.map +1 -1
- package/dist/tool-bridge/index.d.ts +2 -2
- package/dist/tool-bridge/index.js +6 -5
- package/dist/tool-bridge/index.js.map +1 -1
- package/dist/tool-bridge/routes.d.ts +2 -2
- package/dist/tool-bridge/routes.js +24 -22
- package/dist/tool-bridge/routes.js.map +1 -1
- package/dist/tool-bridge/session-lifecycle.js +6 -3
- package/dist/tool-bridge/session-lifecycle.js.map +1 -1
- package/dist/tool-bridge/state.d.ts +4 -25
- package/dist/tool-bridge/state.js +6 -65
- package/dist/tool-bridge/state.js.map +1 -1
- package/dist/tool-bridge/tool-router.d.ts +1 -0
- package/dist/tool-bridge/tool-router.js +26 -19
- package/dist/tool-bridge/tool-router.js.map +1 -1
- package/dist/utils/child-process.d.ts +2 -0
- package/dist/utils/child-process.js +8 -0
- package/dist/utils/child-process.js.map +1 -0
- package/dist/utils/type-guards.d.ts +2 -0
- package/dist/utils/type-guards.js +7 -0
- package/dist/utils/type-guards.js.map +1 -0
- package/package.json +1 -1
package/dist/banner.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import type { Logger } from "copilot-sdk-proxy";
|
|
2
|
+
import type { ProxyMode } from "./providers/index.js";
|
|
1
3
|
export interface ProxyBannerInfo {
|
|
2
4
|
providerName: string;
|
|
3
|
-
proxyFlag:
|
|
5
|
+
proxyFlag: ProxyMode;
|
|
4
6
|
routes: string[];
|
|
5
7
|
cwd: string;
|
|
6
8
|
autoPatch?: boolean | undefined;
|
|
7
|
-
|
|
8
|
-
agentBinaryName?: string | undefined;
|
|
9
|
-
agentsDir?: string | undefined;
|
|
9
|
+
logger?: Logger | undefined;
|
|
10
10
|
}
|
|
11
11
|
export declare function printProxyBanner(info: ProxyBannerInfo): void;
|
package/dist/banner.js
CHANGED
|
@@ -1,23 +1,56 @@
|
|
|
1
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { homedir } from "node:os";
|
|
1
4
|
import { dim } from "copilot-sdk-proxy";
|
|
5
|
+
const AGENTS_DIR = join(homedir(), "Library/Developer/Xcode/CodingAssistant/Agents/Versions");
|
|
6
|
+
const AGENT_BINARY_NAMES = {
|
|
7
|
+
claude: "claude",
|
|
8
|
+
codex: "codex",
|
|
9
|
+
};
|
|
10
|
+
function findAgentBinary(proxy, logger) {
|
|
11
|
+
const binaryName = AGENT_BINARY_NAMES[proxy];
|
|
12
|
+
if (!binaryName)
|
|
13
|
+
return null;
|
|
14
|
+
if (!existsSync(AGENTS_DIR))
|
|
15
|
+
return null;
|
|
16
|
+
let versions;
|
|
17
|
+
try {
|
|
18
|
+
versions = readdirSync(AGENTS_DIR);
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
logger?.debug(`Failed to read agents directory: ${String(err)}`);
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
for (const version of versions) {
|
|
25
|
+
const binaryPath = join(AGENTS_DIR, version, binaryName);
|
|
26
|
+
if (existsSync(binaryPath))
|
|
27
|
+
return binaryPath;
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
2
31
|
export function printProxyBanner(info) {
|
|
3
|
-
console.log();
|
|
4
32
|
const providerHint = info.proxyFlag === "auto"
|
|
5
33
|
? ""
|
|
6
34
|
: ` ${dim(`(--proxy ${info.proxyFlag})`)}`;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
35
|
+
const lines = [
|
|
36
|
+
"",
|
|
37
|
+
` ${dim("Provider")} ${info.providerName}${providerHint}`,
|
|
38
|
+
` ${dim("Routes")} ${info.routes.join(dim(", "))}`,
|
|
39
|
+
` ${dim("Directory")} ${info.cwd}`,
|
|
40
|
+
];
|
|
10
41
|
if (info.autoPatch) {
|
|
11
|
-
|
|
42
|
+
lines.push(` ${dim("Auto-patch")} enabled`);
|
|
12
43
|
}
|
|
13
|
-
if (info.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
44
|
+
if (info.proxyFlag !== "auto") {
|
|
45
|
+
const binaryName = AGENT_BINARY_NAMES[info.proxyFlag];
|
|
46
|
+
if (binaryName) {
|
|
47
|
+
const agentPath = findAgentBinary(info.proxyFlag, info.logger);
|
|
48
|
+
lines.push(agentPath
|
|
49
|
+
? ` ${dim("Agent")} ${agentPath}`
|
|
50
|
+
: ` ${dim("Agent")} ${dim(`not found (expected at ${AGENTS_DIR}/<version>/${binaryName})`)}`);
|
|
19
51
|
}
|
|
20
52
|
}
|
|
21
|
-
|
|
53
|
+
lines.push("");
|
|
54
|
+
console.log(lines.join("\n"));
|
|
22
55
|
}
|
|
23
56
|
//# sourceMappingURL=banner.js.map
|
package/dist/banner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner.js","sourceRoot":"","sources":["../src/banner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"banner.js","sourceRoot":"","sources":["../src/banner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAIxC,MAAM,UAAU,GAAG,IAAI,CACrB,OAAO,EAAE,EACT,yDAAyD,CAC1D,CAAC;AAEF,MAAM,kBAAkB,GAAuC;IAC7D,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;CACf,CAAC;AAEF,SAAS,eAAe,CAAC,KAAgB,EAAE,MAAe;IACxD,MAAM,UAAU,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAC7C,IAA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AC;IAED,IAAI,IAAI,CAAC,SAAS,KAAK,MAAM,EAAE,CAAC;QAC9B,MAAM,UAAU,GAAG,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACtD,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YAC/D,KAAK,CAAC,IAAI,CAAC,SAAS;gBAClB,CAAC,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC,SAAS,SAAS,EAAE;gBACvC,CAAC,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC,SAAS,GAAG,CAAC,0BAA0B,UAAU,cAAc,UAAU,GAAG,CAAC,EAAE,CAAC,CAAC;QACxG,CAAC;IACH,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge-constants.js","sourceRoot":"","sources":["../src/bridge-constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAAC;AACjD,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,kBAAkB,GAAG,CAAC"}
|
package/dist/cli-validators.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { parsePort, parseLogLevel, parseIdleTimeout } from "copilot-sdk-proxy";
|
|
2
2
|
import { type ProxyName, type ProxyMode } from "./providers/index.js";
|
|
3
3
|
export { parsePort, parseLogLevel, parseIdleTimeout };
|
|
4
|
-
export type { ProxyName, ProxyMode };
|
|
5
4
|
export declare function isProxyName(value: string): value is ProxyName;
|
|
6
5
|
export declare function parseProxy(value: string): ProxyName;
|
|
7
6
|
export declare function parseProxyMode(value: string): ProxyMode;
|
package/dist/cli-validators.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { parsePort, parseLogLevel, parseIdleTimeout } from "copilot-sdk-proxy";
|
|
2
2
|
import { providers } from "./providers/index.js";
|
|
3
|
+
import { PROVIDER_NAMES } from "./providers/names.js";
|
|
3
4
|
export { parsePort, parseLogLevel, parseIdleTimeout };
|
|
4
|
-
const VALID_PROXIES = Object.keys(providers);
|
|
5
5
|
export function isProxyName(value) {
|
|
6
6
|
return value in providers;
|
|
7
7
|
}
|
|
8
8
|
export function parseProxy(value) {
|
|
9
9
|
if (!isProxyName(value)) {
|
|
10
|
-
throw new Error(`Invalid proxy "${value}". Valid: ${
|
|
10
|
+
throw new Error(`Invalid proxy "${value}". Valid: ${PROVIDER_NAMES.join(", ")}`);
|
|
11
11
|
}
|
|
12
12
|
return value;
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-validators.js","sourceRoot":"","sources":["../src/cli-validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAkC,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli-validators.js","sourceRoot":"","sources":["../src/cli-validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAkC,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,CAAC;AAEtD,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,OAAO,KAAK,IAAI,SAAS,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,kBAAkB,KAAK,aAAa,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAChE,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,MAAM,CAAC;IACpC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,iBAAiB,GAAwB,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAE5E,MAAM,UAAU,iBAAiB,CAAC,KAAgB,EAAE,SAAkB;IACpE,IAAI,SAAS,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CACb,uCAAuC,CAAC,GAAG,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC3E,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { MCPServer } from "copilot-sdk-proxy";
|
|
3
|
+
export type { MCPLocalServer } from "copilot-sdk-proxy";
|
|
4
|
+
export declare const BYTES_PER_MIB: number;
|
|
5
|
+
declare const ApprovalRuleSchema: z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodEnum<{
|
|
6
|
+
url: "url";
|
|
7
|
+
read: "read";
|
|
8
|
+
write: "write";
|
|
9
|
+
shell: "shell";
|
|
10
|
+
mcp: "mcp";
|
|
11
|
+
}>>]>;
|
|
12
|
+
declare const ReasoningEffortSchema: z.ZodEnum<{
|
|
13
|
+
low: "low";
|
|
14
|
+
medium: "medium";
|
|
15
|
+
high: "high";
|
|
16
|
+
xhigh: "xhigh";
|
|
17
|
+
}>;
|
|
18
|
+
export declare const ServerConfigSchema: z.ZodObject<{
|
|
19
|
+
openai: z.ZodDefault<z.ZodObject<{
|
|
20
|
+
toolBridge: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
21
|
+
mcpServers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
|
|
22
|
+
type: z.ZodUnion<readonly [z.ZodLiteral<"local">, z.ZodLiteral<"stdio">]>;
|
|
23
|
+
command: z.ZodString;
|
|
24
|
+
args: z.ZodArray<z.ZodString>;
|
|
25
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
26
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
27
|
+
allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
28
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
30
|
+
type: z.ZodUnion<readonly [z.ZodLiteral<"http">, z.ZodLiteral<"sse">]>;
|
|
31
|
+
url: z.ZodURL;
|
|
32
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
33
|
+
allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
34
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
}, z.core.$strip>]>>>;
|
|
36
|
+
}, z.core.$strip>>;
|
|
37
|
+
claude: z.ZodDefault<z.ZodObject<{
|
|
38
|
+
toolBridge: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
39
|
+
mcpServers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
|
|
40
|
+
type: z.ZodUnion<readonly [z.ZodLiteral<"local">, z.ZodLiteral<"stdio">]>;
|
|
41
|
+
command: z.ZodString;
|
|
42
|
+
args: z.ZodArray<z.ZodString>;
|
|
43
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
44
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
45
|
+
allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
46
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
48
|
+
type: z.ZodUnion<readonly [z.ZodLiteral<"http">, z.ZodLiteral<"sse">]>;
|
|
49
|
+
url: z.ZodURL;
|
|
50
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
51
|
+
allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
52
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
53
|
+
}, z.core.$strip>]>>>;
|
|
54
|
+
}, z.core.$strip>>;
|
|
55
|
+
codex: z.ZodDefault<z.ZodObject<{
|
|
56
|
+
toolBridge: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
57
|
+
mcpServers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
|
|
58
|
+
type: z.ZodUnion<readonly [z.ZodLiteral<"local">, z.ZodLiteral<"stdio">]>;
|
|
59
|
+
command: z.ZodString;
|
|
60
|
+
args: z.ZodArray<z.ZodString>;
|
|
61
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
62
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
63
|
+
allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
64
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
65
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
66
|
+
type: z.ZodUnion<readonly [z.ZodLiteral<"http">, z.ZodLiteral<"sse">]>;
|
|
67
|
+
url: z.ZodURL;
|
|
68
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
69
|
+
allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
70
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
71
|
+
}, z.core.$strip>]>>>;
|
|
72
|
+
}, z.core.$strip>>;
|
|
73
|
+
allowedCliTools: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
74
|
+
excludedFilePatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
75
|
+
bodyLimitMiB: z.ZodDefault<z.ZodNumber>;
|
|
76
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
77
|
+
low: "low";
|
|
78
|
+
medium: "medium";
|
|
79
|
+
high: "high";
|
|
80
|
+
xhigh: "xhigh";
|
|
81
|
+
}>>;
|
|
82
|
+
autoApprovePermissions: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodEnum<{
|
|
83
|
+
url: "url";
|
|
84
|
+
read: "read";
|
|
85
|
+
write: "write";
|
|
86
|
+
shell: "shell";
|
|
87
|
+
mcp: "mcp";
|
|
88
|
+
}>>]>>;
|
|
89
|
+
}, z.core.$strip>;
|
|
90
|
+
type ApprovalRule = z.infer<typeof ApprovalRuleSchema>;
|
|
91
|
+
export type ServerConfig = {
|
|
92
|
+
toolBridge: boolean;
|
|
93
|
+
mcpServers: Record<string, MCPServer>;
|
|
94
|
+
allowedCliTools: string[];
|
|
95
|
+
excludedFilePatterns: string[];
|
|
96
|
+
bodyLimit: number;
|
|
97
|
+
autoApprovePermissions: ApprovalRule;
|
|
98
|
+
reasoningEffort?: z.infer<typeof ReasoningEffortSchema> | undefined;
|
|
99
|
+
};
|
|
100
|
+
export declare const DEFAULT_CONFIG: {
|
|
101
|
+
toolBridge: false;
|
|
102
|
+
mcpServers: {};
|
|
103
|
+
allowedCliTools: never[];
|
|
104
|
+
excludedFilePatterns: never[];
|
|
105
|
+
bodyLimit: number;
|
|
106
|
+
autoApprovePermissions: ("read" | "mcp")[];
|
|
107
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const BYTES_PER_MIB = 1024 * 1024;
|
|
3
|
+
const MCPLocalServerSchema = z.object({
|
|
4
|
+
type: z.union([z.literal("local"), z.literal("stdio")]),
|
|
5
|
+
command: z.string().min(1, "MCP server command cannot be empty"),
|
|
6
|
+
args: z.array(z.string()),
|
|
7
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
8
|
+
cwd: z.string().optional(),
|
|
9
|
+
allowedTools: z.array(z.string()).optional(),
|
|
10
|
+
timeout: z.number().positive().optional(),
|
|
11
|
+
});
|
|
12
|
+
const MCPRemoteServerSchema = z.object({
|
|
13
|
+
type: z.union([z.literal("http"), z.literal("sse")]),
|
|
14
|
+
url: z.url(),
|
|
15
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
16
|
+
allowedTools: z.array(z.string()).optional(),
|
|
17
|
+
timeout: z.number().positive().optional(),
|
|
18
|
+
});
|
|
19
|
+
const MCPServerSchema = z.union([MCPLocalServerSchema, MCPRemoteServerSchema]);
|
|
20
|
+
const VALID_PERMISSION_KINDS = ["read", "write", "shell", "mcp", "url"];
|
|
21
|
+
const ApprovalRuleSchema = z.union([
|
|
22
|
+
z.boolean(),
|
|
23
|
+
z.array(z.enum(VALID_PERMISSION_KINDS)),
|
|
24
|
+
]);
|
|
25
|
+
const VALID_REASONING_EFFORTS = ["low", "medium", "high", "xhigh"];
|
|
26
|
+
const ReasoningEffortSchema = z.enum(VALID_REASONING_EFFORTS);
|
|
27
|
+
const ProviderConfigSchema = z.object({
|
|
28
|
+
toolBridge: z.boolean().optional().default(false),
|
|
29
|
+
mcpServers: z.record(z.string(), MCPServerSchema).default({}),
|
|
30
|
+
});
|
|
31
|
+
export const ServerConfigSchema = z.object({
|
|
32
|
+
openai: ProviderConfigSchema.default({ toolBridge: false, mcpServers: {} }),
|
|
33
|
+
claude: ProviderConfigSchema.default({ toolBridge: false, mcpServers: {} }),
|
|
34
|
+
codex: ProviderConfigSchema.default({ toolBridge: false, mcpServers: {} }),
|
|
35
|
+
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([]),
|
|
36
|
+
excludedFilePatterns: z.array(z.string()).default([]),
|
|
37
|
+
bodyLimitMiB: z
|
|
38
|
+
.number()
|
|
39
|
+
.positive()
|
|
40
|
+
.max(100, "bodyLimitMiB cannot exceed 100")
|
|
41
|
+
.default(10),
|
|
42
|
+
reasoningEffort: ReasoningEffortSchema.optional(),
|
|
43
|
+
autoApprovePermissions: ApprovalRuleSchema.default(["read", "mcp"]),
|
|
44
|
+
});
|
|
45
|
+
export const DEFAULT_CONFIG = {
|
|
46
|
+
toolBridge: false,
|
|
47
|
+
mcpServers: {},
|
|
48
|
+
allowedCliTools: [],
|
|
49
|
+
excludedFilePatterns: [],
|
|
50
|
+
bodyLimit: 10 * BYTES_PER_MIB,
|
|
51
|
+
autoApprovePermissions: ["read", "mcp"],
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=config-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-schema.js","sourceRoot":"","sources":["../src/config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,CAAC;AAEzC,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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AAC,EAAE,CAAC;IACd,eAAe,EAAE,qBAAqB,CAAC,QAAQ,EAAE;IACjD,sBAAsB,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CACpE,CAAC,CAAC;AAcH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE,EAAE;IACd,eAAe,EAAE,EAAE;IACnB,oBAAoB,EAAE,EAAE;IACxB,SAAS,EAAE,EAAE,GAAG,aAAa;IAC7B,sBAAsB,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;CACjB,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,31 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
import { type ProxyName } from "./providers/index.js";
|
|
5
|
-
export type { ProxyName };
|
|
6
|
-
declare const ApprovalRuleSchema: z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodEnum<{
|
|
7
|
-
url: "url";
|
|
8
|
-
read: "read";
|
|
9
|
-
write: "write";
|
|
10
|
-
shell: "shell";
|
|
11
|
-
mcp: "mcp";
|
|
12
|
-
}>>]>;
|
|
13
|
-
declare const ReasoningEffortSchema: z.ZodEnum<{
|
|
14
|
-
low: "low";
|
|
15
|
-
medium: "medium";
|
|
16
|
-
high: "high";
|
|
17
|
-
xhigh: "xhigh";
|
|
18
|
-
}>;
|
|
19
|
-
type ApprovalRule = z.infer<typeof ApprovalRuleSchema>;
|
|
20
|
-
export type ServerConfig = {
|
|
21
|
-
toolBridge: boolean;
|
|
22
|
-
mcpServers: Record<string, MCPServer>;
|
|
23
|
-
allowedCliTools: string[];
|
|
24
|
-
excludedFilePatterns: string[];
|
|
25
|
-
bodyLimit: number;
|
|
26
|
-
autoApprovePermissions: ApprovalRule;
|
|
27
|
-
reasoningEffort?: z.infer<typeof ReasoningEffortSchema> | undefined;
|
|
28
|
-
};
|
|
1
|
+
import type { Logger } from "copilot-sdk-proxy";
|
|
2
|
+
import type { ProxyName } from "./providers/names.js";
|
|
3
|
+
import type { ServerConfig } from "./config-schema.js";
|
|
29
4
|
export declare function resolveConfigPath(projectCwd: string | undefined, processCwd: string, defaultPath: string): string;
|
|
30
5
|
export declare function loadConfig(configPath: string, logger: Logger, proxy: ProxyName): Promise<ServerConfig>;
|
|
31
6
|
export type AllProviderConfigs = {
|
package/dist/config.js
CHANGED
|
@@ -1,60 +1,11 @@
|
|
|
1
|
+
// resolveConfigPath is sync (runs once at startup). The loaders are async because they read disk.
|
|
1
2
|
import { existsSync } from "node:fs";
|
|
2
3
|
import { readFile } from "node:fs/promises";
|
|
3
4
|
import { resolve, dirname, isAbsolute } from "node:path";
|
|
4
5
|
import JSON5 from "json5";
|
|
5
6
|
import { z } from "zod";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
const MCPLocalServerSchema = z.object({
|
|
9
|
-
type: z.union([z.literal("local"), z.literal("stdio")]),
|
|
10
|
-
command: z.string().min(1, "MCP server command cannot be empty"),
|
|
11
|
-
args: z.array(z.string()),
|
|
12
|
-
env: z.record(z.string(), z.string()).optional(),
|
|
13
|
-
cwd: z.string().optional(),
|
|
14
|
-
allowedTools: z.array(z.string()).optional(),
|
|
15
|
-
timeout: z.number().positive().optional(),
|
|
16
|
-
});
|
|
17
|
-
const MCPRemoteServerSchema = z.object({
|
|
18
|
-
type: z.union([z.literal("http"), z.literal("sse")]),
|
|
19
|
-
url: z.url(),
|
|
20
|
-
headers: z.record(z.string(), z.string()).optional(),
|
|
21
|
-
allowedTools: z.array(z.string()).optional(),
|
|
22
|
-
timeout: z.number().positive().optional(),
|
|
23
|
-
});
|
|
24
|
-
const MCPServerSchema = z.union([MCPLocalServerSchema, MCPRemoteServerSchema]);
|
|
25
|
-
const VALID_PERMISSION_KINDS = ["read", "write", "shell", "mcp", "url"];
|
|
26
|
-
const ApprovalRuleSchema = z.union([
|
|
27
|
-
z.boolean(),
|
|
28
|
-
z.array(z.enum(VALID_PERMISSION_KINDS)),
|
|
29
|
-
]);
|
|
30
|
-
const VALID_REASONING_EFFORTS = ["low", "medium", "high", "xhigh"];
|
|
31
|
-
const ReasoningEffortSchema = z.enum(VALID_REASONING_EFFORTS);
|
|
32
|
-
const ProviderConfigSchema = z.object({
|
|
33
|
-
toolBridge: z.boolean().optional().default(false),
|
|
34
|
-
mcpServers: z.record(z.string(), MCPServerSchema).default({}),
|
|
35
|
-
});
|
|
36
|
-
const ServerConfigSchema = z.object({
|
|
37
|
-
openai: ProviderConfigSchema.default({ toolBridge: false, mcpServers: {} }),
|
|
38
|
-
claude: ProviderConfigSchema.default({ toolBridge: false, mcpServers: {} }),
|
|
39
|
-
codex: ProviderConfigSchema.default({ toolBridge: false, mcpServers: {} }),
|
|
40
|
-
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([]),
|
|
41
|
-
excludedFilePatterns: z.array(z.string()).default([]),
|
|
42
|
-
bodyLimitMiB: z
|
|
43
|
-
.number()
|
|
44
|
-
.positive()
|
|
45
|
-
.max(100, "bodyLimitMiB cannot exceed 100")
|
|
46
|
-
.default(10),
|
|
47
|
-
reasoningEffort: ReasoningEffortSchema.optional(),
|
|
48
|
-
autoApprovePermissions: ApprovalRuleSchema.default(["read", "mcp"]),
|
|
49
|
-
});
|
|
50
|
-
const DEFAULT_CONFIG = {
|
|
51
|
-
toolBridge: false,
|
|
52
|
-
mcpServers: {},
|
|
53
|
-
allowedCliTools: [],
|
|
54
|
-
excludedFilePatterns: [],
|
|
55
|
-
bodyLimit: 10 * 1024 * 1024,
|
|
56
|
-
autoApprovePermissions: ["read", "mcp"],
|
|
57
|
-
};
|
|
7
|
+
import { ServerConfigSchema, DEFAULT_CONFIG, BYTES_PER_MIB } from "./config-schema.js";
|
|
8
|
+
import { isErrnoException } from "./utils/type-guards.js";
|
|
58
9
|
function resolveServerPaths(servers, configDir) {
|
|
59
10
|
return Object.fromEntries(Object.entries(servers).map(([name, server]) => [
|
|
60
11
|
name,
|
|
@@ -88,11 +39,11 @@ async function parseConfigFile(configPath, logger) {
|
|
|
88
39
|
text = await readFile(absolutePath, "utf-8");
|
|
89
40
|
}
|
|
90
41
|
catch (err) {
|
|
91
|
-
if (err
|
|
42
|
+
if (isErrnoException(err) && err.code === "ENOENT") {
|
|
92
43
|
logger.warn(`No config file at ${absolutePath}, using defaults`);
|
|
93
44
|
return null;
|
|
94
45
|
}
|
|
95
|
-
throw err;
|
|
46
|
+
throw new Error(`Failed to read config file at ${absolutePath}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
96
47
|
}
|
|
97
48
|
let raw;
|
|
98
49
|
try {
|
|
@@ -122,7 +73,7 @@ function buildServerConfig(parsed, configDir, proxy) {
|
|
|
122
73
|
excludedFilePatterns: parsed.excludedFilePatterns,
|
|
123
74
|
autoApprovePermissions: parsed.autoApprovePermissions,
|
|
124
75
|
reasoningEffort: parsed.reasoningEffort,
|
|
125
|
-
bodyLimit: parsed.bodyLimitMiB *
|
|
76
|
+
bodyLimit: parsed.bodyLimitMiB * BYTES_PER_MIB,
|
|
126
77
|
toolBridge: provider.toolBridge,
|
|
127
78
|
mcpServers: resolveServerPaths(provider.mcpServers, configDir),
|
|
128
79
|
};
|
|
@@ -135,13 +86,23 @@ export async function loadConfig(configPath, logger, proxy) {
|
|
|
135
86
|
}
|
|
136
87
|
export async function loadAllProviderConfigs(configPath, logger) {
|
|
137
88
|
const result = await parseConfigFile(configPath, logger);
|
|
138
|
-
const providers =
|
|
139
|
-
|
|
140
|
-
result ? buildServerConfig(result.data, result.configDir,
|
|
141
|
-
|
|
142
|
-
return {
|
|
143
|
-
providers,
|
|
144
|
-
shared: { ...providers.openai, toolBridge: false, mcpServers: {} },
|
|
89
|
+
const providers = {
|
|
90
|
+
openai: result ? buildServerConfig(result.data, result.configDir, "openai") : DEFAULT_CONFIG,
|
|
91
|
+
claude: result ? buildServerConfig(result.data, result.configDir, "claude") : DEFAULT_CONFIG,
|
|
92
|
+
codex: result ? buildServerConfig(result.data, result.configDir, "codex") : DEFAULT_CONFIG,
|
|
145
93
|
};
|
|
94
|
+
// Common fields only, no per-provider toolBridge / mcpServers.
|
|
95
|
+
const shared = result
|
|
96
|
+
? {
|
|
97
|
+
allowedCliTools: result.data.allowedCliTools,
|
|
98
|
+
excludedFilePatterns: result.data.excludedFilePatterns,
|
|
99
|
+
autoApprovePermissions: result.data.autoApprovePermissions,
|
|
100
|
+
reasoningEffort: result.data.reasoningEffort,
|
|
101
|
+
bodyLimit: result.data.bodyLimitMiB * BYTES_PER_MIB,
|
|
102
|
+
toolBridge: false,
|
|
103
|
+
mcpServers: {},
|
|
104
|
+
}
|
|
105
|
+
: DEFAULT_CONFIG;
|
|
106
|
+
return { providers, shared };
|
|
146
107
|
}
|
|
147
108
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAElG,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,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
import type { CopilotService, Logger, Stats } from "copilot-sdk-proxy";
|
|
2
|
-
import type { ServerConfig } from "./config.js";
|
|
2
|
+
import type { ServerConfig } from "./config-schema.js";
|
|
3
3
|
import type { ConversationManager } from "./conversation-manager.js";
|
|
4
4
|
export interface AppContext {
|
|
5
5
|
service: CopilotService;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { ToolBridgeState } from "./tool-bridge/state.js";
|
|
2
|
-
import type { Conversation as CoreConversation,
|
|
2
|
+
import type { Conversation as CoreConversation, Logger } from "copilot-sdk-proxy";
|
|
3
3
|
export interface Conversation extends CoreConversation {
|
|
4
4
|
state: ToolBridgeState;
|
|
5
5
|
}
|
|
6
|
-
export
|
|
6
|
+
export interface ToolStateProvider {
|
|
7
|
+
getState(convId: string): ToolBridgeState | undefined;
|
|
8
|
+
findByExpectedTool(name: string): ToolBridgeState | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare function asConversation(conv: CoreConversation): Conversation;
|
|
11
|
+
export declare class ConversationManager implements ToolStateProvider {
|
|
7
12
|
private readonly conversations;
|
|
8
13
|
private readonly logger;
|
|
9
14
|
private primaryId;
|
|
@@ -11,13 +16,13 @@ export declare class ConversationManager {
|
|
|
11
16
|
create(options?: {
|
|
12
17
|
isPrimary?: boolean;
|
|
13
18
|
}): Conversation;
|
|
14
|
-
getPrimary(): Conversation |
|
|
19
|
+
getPrimary(): Conversation | undefined;
|
|
15
20
|
clearPrimary(): void;
|
|
21
|
+
private evictStale;
|
|
16
22
|
findForNewRequest(): {
|
|
17
23
|
conversation: Conversation;
|
|
18
24
|
isReuse: boolean;
|
|
19
25
|
};
|
|
20
|
-
findByContinuation(messages: AnthropicMessage[]): Conversation | undefined;
|
|
21
26
|
findByContinuationIds(callIds: string[]): Conversation | undefined;
|
|
22
27
|
findByExpectedTool(name: string): ToolBridgeState | undefined;
|
|
23
28
|
getState(convId: string): ToolBridgeState | undefined;
|