@ccpocket/bridge 1.70.2 → 1.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -4
- package/dist/cli.js +4 -2
- package/dist/cli.js.map +1 -1
- package/dist/codex-process.d.ts +4 -4
- package/dist/codex-process.js +25 -17
- package/dist/codex-process.js.map +1 -1
- package/dist/directory-listing.d.ts +2 -2
- package/dist/directory-listing.js +4 -3
- package/dist/directory-listing.js.map +1 -1
- package/dist/doctor.js +24 -14
- package/dist/doctor.js.map +1 -1
- package/dist/parser.d.ts +10 -0
- package/dist/parser.js +6 -1
- package/dist/parser.js.map +1 -1
- package/dist/push-relay.d.ts +2 -0
- package/dist/push-relay.js +1 -0
- package/dist/push-relay.js.map +1 -1
- package/dist/sdk-process.d.ts +7 -17
- package/dist/sdk-process.js +66 -109
- package/dist/sdk-process.js.map +1 -1
- package/dist/setup-launchd.js +6 -0
- package/dist/setup-launchd.js.map +1 -1
- package/dist/setup-systemd.js +4 -0
- package/dist/setup-systemd.js.map +1 -1
- package/dist/websocket.d.ts +10 -1
- package/dist/websocket.js +137 -41
- package/dist/websocket.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,9 +12,10 @@ npx @ccpocket/bridge@latest
|
|
|
12
12
|
|
|
13
13
|
A QR code will appear in your terminal. Scan it with the ccpocket mobile app to connect.
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
Claude sessions use `ANTHROPIC_API_KEY` by default. Subscription authentication
|
|
16
|
+
through the Bridge machine's Claude Code login is available only after explicit
|
|
17
|
+
opt-in with `BRIDGE_ALLOW_CLAUDE_OAUTH=1`; see
|
|
18
|
+
[Claude Subscription Authentication](#claude-subscription-authentication-explicit-opt-in).
|
|
18
19
|
|
|
19
20
|
## Installation
|
|
20
21
|
|
|
@@ -47,6 +48,7 @@ ccpocket-bridge --version
|
|
|
47
48
|
| `BRIDGE_DEMO_MODE` | (none) | Demo mode: hide Tailscale IPs and API key from QR code / logs |
|
|
48
49
|
| `BRIDGE_RECORDING` | (none) | Enable session recording for debugging (enabled when set) |
|
|
49
50
|
| `BRIDGE_DISABLE_MDNS` | (none) | Disable mDNS auto-discovery advertisement (macOS disables it automatically) |
|
|
51
|
+
| `BRIDGE_ALLOW_CLAUDE_OAUTH` | (none) | Set exactly to `1` to explicitly enable experimental Claude subscription authentication |
|
|
50
52
|
| `BRIDGE_PROMPT_HISTORY_FILE` | `$HOME/.ccpocket/prompt-history-v2.json` | Custom prompt history store path |
|
|
51
53
|
| `BRIDGE_RECENT_SESSIONS_PROFILE` | (none) | Log recent-session index timing when set to `1` or `true` |
|
|
52
54
|
| `BRIDGE_FILE_LIST_MAX_ENTRIES` | `5000` | Maximum file and directory entries returned to a client; non-positive or invalid values use the default |
|
|
@@ -55,7 +57,7 @@ ccpocket-bridge --version
|
|
|
55
57
|
| `BRIDGE_DELTA_BATCH_MAX_CHARS` | `4096` | Maximum Unicode characters per batched streaming payload; non-positive or invalid values use the default |
|
|
56
58
|
| `DIFF_IMAGE_AUTO_DISPLAY_KB` | `1024` (1 MB) | Auto-display diff images up to this size, in KB |
|
|
57
59
|
| `DIFF_IMAGE_MAX_SIZE_MB` | `5` (5 MB) | Maximum diff image size available for on-demand loading, in MB |
|
|
58
|
-
| `ANTHROPIC_API_KEY` | (none) | Claude Agent SDK API key
|
|
60
|
+
| `ANTHROPIC_API_KEY` | (none) | Claude Agent SDK API key; recommended for predictable third-party product usage |
|
|
59
61
|
| `ANTHROPIC_AUTH_TOKEN` | (none) | Advanced Claude SDK auth token; prefer `ANTHROPIC_API_KEY` |
|
|
60
62
|
| `OPENAI_API_KEY` | (none) | Codex API key; Codex can also use `~/.codex/auth.json` |
|
|
61
63
|
| `HTTPS_PROXY` / `HTTP_PROXY` / `ALL_PROXY` | (none) | Proxy for outgoing fetch requests (`http://`, `https://`, `socks4://`, `socks5://`) |
|
|
@@ -68,6 +70,39 @@ supported. When `BRIDGE_PROMPT_HISTORY_FILE` is not set and `BRIDGE_PORT` is not
|
|
|
68
70
|
Push relay uses Firebase Anonymous Auth automatically; no FCM environment
|
|
69
71
|
variables are required.
|
|
70
72
|
|
|
73
|
+
## Claude Subscription Authentication (Explicit Opt-In)
|
|
74
|
+
|
|
75
|
+
Anthropic's [Legal and compliance](https://code.claude.com/docs/en/legal-and-compliance)
|
|
76
|
+
page says its Commercial Terms do not prevent a platform from hosting the
|
|
77
|
+
unmodified Claude Code binary when each end user signs in with their own
|
|
78
|
+
subscription or other credentials, subject to the conditions listed there.
|
|
79
|
+
CC Pocket similarly runs Anthropic's official Agent SDK on the user's Bridge
|
|
80
|
+
machine and delegates credential loading to the host's Claude Code environment.
|
|
81
|
+
CC Pocket does not copy, store, or refresh Claude OAuth credentials itself.
|
|
82
|
+
|
|
83
|
+
Running Claude Code on a user's computer and controlling it remotely is also a
|
|
84
|
+
common pattern among tools such as [OpenClaw](https://github.com/openclaw/openclaw/blob/main/docs/concepts/oauth.md),
|
|
85
|
+
[Happy](https://github.com/slopus/happy), and
|
|
86
|
+
[Termopus](https://github.com/Termopus/termopus), although their exact
|
|
87
|
+
implementations differ from CC Pocket.
|
|
88
|
+
|
|
89
|
+
However, Anthropic's [Agent SDK overview](https://code.claude.com/docs/en/agent-sdk)
|
|
90
|
+
also says that, unless previously approved, third-party products should use API
|
|
91
|
+
keys rather than offer Claude.ai login or subscription rate limits. The scope of
|
|
92
|
+
these two statements is not clear for CC Pocket's architecture, so subscription
|
|
93
|
+
authentication may be restricted or stop working in the future.
|
|
94
|
+
|
|
95
|
+
To avoid that uncertainty, use `ANTHROPIC_API_KEY`. If you understand the risk
|
|
96
|
+
and want to use the Bridge machine's Claude Code subscription login, enable it
|
|
97
|
+
explicitly and restart Bridge:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
BRIDGE_ALLOW_CLAUDE_OAUTH=1 npx @ccpocket/bridge@latest
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Only the exact value `1` enables this behavior. Service setup preserves the
|
|
104
|
+
setting when it is present in the setup environment.
|
|
105
|
+
|
|
71
106
|
```bash
|
|
72
107
|
# Example: custom port with API key
|
|
73
108
|
BRIDGE_PORT=9000 BRIDGE_API_KEY=my-secret npx @ccpocket/bridge@latest
|
|
@@ -116,6 +151,7 @@ that affect startup:
|
|
|
116
151
|
- `BRIDGE_ALLOWED_DIRS`
|
|
117
152
|
- `BRIDGE_PUBLIC_WS_URL` / `--public-ws-url`
|
|
118
153
|
- `BRIDGE_DISABLE_MDNS` / `--no-mdns`
|
|
154
|
+
- `BRIDGE_ALLOW_CLAUDE_OAUTH`
|
|
119
155
|
- `BRIDGE_CODEX_APP_SERVER_MODE` / `--codex-app-server-mode`
|
|
120
156
|
- `BRIDGE_CODEX_SHARED_APP_SERVER_URL` / `--codex-shared-app-server-url`
|
|
121
157
|
- `BRIDGE_CODEX_ASSIST_MODEL`
|
|
@@ -129,6 +165,12 @@ BRIDGE_API_KEY=my-secret \
|
|
|
129
165
|
npx @ccpocket/bridge@latest setup
|
|
130
166
|
```
|
|
131
167
|
|
|
168
|
+
To persist the explicit subscription-authentication opt-in:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
BRIDGE_ALLOW_CLAUDE_OAUTH=1 npx @ccpocket/bridge@latest setup
|
|
172
|
+
```
|
|
173
|
+
|
|
132
174
|
Custom gateway users can persist assist overrides in the same way:
|
|
133
175
|
|
|
134
176
|
```bash
|
package/dist/cli.js
CHANGED
|
@@ -40,11 +40,13 @@ Setup options:
|
|
|
40
40
|
--uninstall Remove the registered service
|
|
41
41
|
setup persists --port, --host, --api-key, --public-ws-url,
|
|
42
42
|
--no-mdns, Codex app-server options, BRIDGE_ALLOWED_DIRS, and
|
|
43
|
-
BRIDGE_CODEX_ASSIST_MODEL
|
|
43
|
+
BRIDGE_ALLOW_CLAUDE_OAUTH, BRIDGE_CODEX_ASSIST_MODEL, and
|
|
44
|
+
BRIDGE_CODEX_ASSIST_REASONING_EFFORT
|
|
44
45
|
|
|
45
46
|
Configuration can also be provided with BRIDGE_PORT, BRIDGE_HOST,
|
|
46
47
|
BRIDGE_API_KEY, BRIDGE_ALLOWED_DIRS, BRIDGE_PUBLIC_WS_URL, and
|
|
47
|
-
BRIDGE_DISABLE_MDNS.
|
|
48
|
+
BRIDGE_DISABLE_MDNS. Claude subscription authentication can be explicitly
|
|
49
|
+
enabled with BRIDGE_ALLOW_CLAUDE_OAUTH=1. Codex app-server configuration can be provided with
|
|
48
50
|
BRIDGE_CODEX_APP_SERVER_MODE and BRIDGE_CODEX_SHARED_APP_SERVER_URL.
|
|
49
51
|
Codex assist calls can be configured with BRIDGE_CODEX_ASSIST_MODEL and
|
|
50
52
|
BRIDGE_CODEX_ASSIST_REASONING_EFFORT.`);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEjE,SAAS,mBAAmB,CAAC,GAAY;IACvC,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;AAElC,SAAS,SAAS;IAChB,OAAO,CAAC,GAAG,CAAC
|
|
1
|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,GAAG,GAAG,CAAC;IAEtE,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QAC1B,OAAO,CAAC,KAAK,CAAC,6BAA6B,mBAAmB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACvE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/codex-process.d.ts
CHANGED
|
@@ -284,10 +284,10 @@ export declare class CodexProcess extends EventEmitter<CodexProcessEvents> {
|
|
|
284
284
|
path: string;
|
|
285
285
|
}>;
|
|
286
286
|
}): Promise<void>;
|
|
287
|
-
approve(toolUseId?: string):
|
|
288
|
-
approveAlways(toolUseId?: string):
|
|
289
|
-
reject(toolUseId?: string, _message?: string):
|
|
290
|
-
answer(toolUseId: string, result: string):
|
|
287
|
+
approve(toolUseId?: string): boolean;
|
|
288
|
+
approveAlways(toolUseId?: string): boolean;
|
|
289
|
+
reject(toolUseId?: string, _message?: string): boolean;
|
|
290
|
+
answer(toolUseId: string, result: string): boolean;
|
|
291
291
|
/**
|
|
292
292
|
* Install a plugin or begin connector authentication proposed by Codex.
|
|
293
293
|
* The elicitation remains pending while external app authentication is
|
package/dist/codex-process.js
CHANGED
|
@@ -595,73 +595,78 @@ export class CodexProcess extends EventEmitter {
|
|
|
595
595
|
if (this.pendingPlanCompletion &&
|
|
596
596
|
toolUseId === this.pendingPlanCompletion.toolUseId) {
|
|
597
597
|
this.handlePlanApproved();
|
|
598
|
-
return;
|
|
598
|
+
return true;
|
|
599
599
|
}
|
|
600
600
|
const pending = this.resolvePendingApproval(toolUseId);
|
|
601
601
|
if (!pending) {
|
|
602
602
|
// Fallback: McpElicitation lives in pendingUserInputs
|
|
603
603
|
if (this.approveUserInput(toolUseId, "Accept"))
|
|
604
|
-
return;
|
|
604
|
+
return true;
|
|
605
605
|
console.log("[codex-process] approve() called but no pending permission requests");
|
|
606
|
-
return;
|
|
606
|
+
return false;
|
|
607
607
|
}
|
|
608
608
|
this.pendingApprovals.delete(pending.toolUseId);
|
|
609
609
|
this.respondToServerRequest(pending.requestId, buildApprovalResponse(pending, "accept"));
|
|
610
|
-
this.emitToolResult(pending.toolUseId, "Approved");
|
|
610
|
+
this.emitToolResult(pending.toolUseId, "Approved", "approved");
|
|
611
611
|
if (this.pendingApprovals.size === 0) {
|
|
612
612
|
this.setStatus("running");
|
|
613
613
|
}
|
|
614
|
+
return true;
|
|
614
615
|
}
|
|
615
616
|
approveAlways(toolUseId) {
|
|
616
617
|
const pending = this.resolvePendingApproval(toolUseId);
|
|
617
618
|
if (!pending) {
|
|
618
619
|
// Fallback: McpElicitation lives in pendingUserInputs
|
|
619
|
-
if (this.approveUserInput(toolUseId, "Allow for this session"))
|
|
620
|
-
return;
|
|
620
|
+
if (this.approveUserInput(toolUseId, "Allow for this session")) {
|
|
621
|
+
return true;
|
|
622
|
+
}
|
|
621
623
|
console.log("[codex-process] approveAlways() called but no pending permission requests");
|
|
622
|
-
return;
|
|
624
|
+
return false;
|
|
623
625
|
}
|
|
624
626
|
this.pendingApprovals.delete(pending.toolUseId);
|
|
625
627
|
this.respondToServerRequest(pending.requestId, buildApprovalResponse(pending, "acceptForSession"));
|
|
626
|
-
this.emitToolResult(pending.toolUseId, "Approved (always)");
|
|
628
|
+
this.emitToolResult(pending.toolUseId, "Approved (always)", "approved_for_session");
|
|
627
629
|
if (this.pendingApprovals.size === 0) {
|
|
628
630
|
this.setStatus("running");
|
|
629
631
|
}
|
|
632
|
+
return true;
|
|
630
633
|
}
|
|
631
634
|
reject(toolUseId, _message) {
|
|
632
635
|
// Check if this is a plan completion rejection
|
|
633
636
|
if (this.pendingPlanCompletion &&
|
|
634
637
|
toolUseId === this.pendingPlanCompletion.toolUseId) {
|
|
635
638
|
this.handlePlanRejected(_message);
|
|
636
|
-
return;
|
|
639
|
+
return true;
|
|
637
640
|
}
|
|
638
641
|
const pending = this.resolvePendingApproval(toolUseId);
|
|
639
642
|
if (!pending) {
|
|
640
643
|
// Fallback: McpElicitation lives in pendingUserInputs
|
|
641
644
|
if (this.rejectUserInput(toolUseId, "Decline"))
|
|
642
|
-
return;
|
|
645
|
+
return true;
|
|
643
646
|
console.log("[codex-process] reject() called but no pending permission requests");
|
|
644
|
-
return;
|
|
647
|
+
return false;
|
|
645
648
|
}
|
|
646
649
|
this.pendingApprovals.delete(pending.toolUseId);
|
|
647
650
|
this.respondToServerRequest(pending.requestId, buildApprovalResponse(pending, resolveApprovalRejectDecision(pending)));
|
|
648
|
-
this.emitToolResult(pending.toolUseId, "Rejected");
|
|
651
|
+
this.emitToolResult(pending.toolUseId, "Rejected", "rejected");
|
|
649
652
|
if (this.pendingApprovals.size === 0) {
|
|
650
653
|
this.setStatus("running");
|
|
651
654
|
}
|
|
655
|
+
return true;
|
|
652
656
|
}
|
|
653
657
|
answer(toolUseId, result) {
|
|
654
658
|
const pending = this.resolvePendingUserInput(toolUseId);
|
|
655
659
|
if (!pending) {
|
|
656
660
|
console.log("[codex-process] answer() called but no pending AskUserQuestion");
|
|
657
|
-
return;
|
|
661
|
+
return false;
|
|
658
662
|
}
|
|
659
663
|
this.pendingUserInputs.delete(pending.toolUseId);
|
|
660
664
|
this.respondToServerRequest(pending.requestId, buildUserInputResponse(pending, result));
|
|
661
|
-
this.emitToolResult(pending.toolUseId, "Answered");
|
|
665
|
+
this.emitToolResult(pending.toolUseId, "Answered", "answered");
|
|
662
666
|
if (this.pendingApprovals.size === 0 && this.pendingUserInputs.size === 0) {
|
|
663
667
|
this.setStatus("running");
|
|
664
668
|
}
|
|
669
|
+
return true;
|
|
665
670
|
}
|
|
666
671
|
/**
|
|
667
672
|
* Install a plugin or begin connector authentication proposed by Codex.
|
|
@@ -780,11 +785,12 @@ export class CodexProcess extends EventEmitter {
|
|
|
780
785
|
};
|
|
781
786
|
}
|
|
782
787
|
/** Emit a synthetic tool_result so history replay can match it to a permission_request. */
|
|
783
|
-
emitToolResult(toolUseId, content) {
|
|
788
|
+
emitToolResult(toolUseId, content, permissionOutcome) {
|
|
784
789
|
this.emitMessage({
|
|
785
790
|
type: "tool_result",
|
|
786
791
|
toolUseId,
|
|
787
792
|
content,
|
|
793
|
+
...(permissionOutcome ? { permissionOutcome } : {}),
|
|
788
794
|
});
|
|
789
795
|
}
|
|
790
796
|
resolvePendingApproval(toolUseId) {
|
|
@@ -820,7 +826,9 @@ export class CodexProcess extends EventEmitter {
|
|
|
820
826
|
}
|
|
821
827
|
this.pendingUserInputs.delete(pending.toolUseId);
|
|
822
828
|
this.respondToServerRequest(pending.requestId, buildUserInputResponse(pending, result));
|
|
823
|
-
this.emitToolResult(pending.toolUseId, "Approved"
|
|
829
|
+
this.emitToolResult(pending.toolUseId, "Approved", result === "Allow for this session"
|
|
830
|
+
? "approved_for_session"
|
|
831
|
+
: "approved");
|
|
824
832
|
if (this.pendingApprovals.size === 0 && this.pendingUserInputs.size === 0) {
|
|
825
833
|
this.setStatus("running");
|
|
826
834
|
}
|
|
@@ -860,7 +868,7 @@ export class CodexProcess extends EventEmitter {
|
|
|
860
868
|
return false;
|
|
861
869
|
this.pendingUserInputs.delete(pending.toolUseId);
|
|
862
870
|
this.respondToServerRequest(pending.requestId, buildUserInputResponse(pending, resolveUserInputRejectResult(pending, result)));
|
|
863
|
-
this.emitToolResult(pending.toolUseId, "Rejected");
|
|
871
|
+
this.emitToolResult(pending.toolUseId, "Rejected", "rejected");
|
|
864
872
|
if (this.pendingApprovals.size === 0 && this.pendingUserInputs.size === 0) {
|
|
865
873
|
this.setStatus("running");
|
|
866
874
|
}
|