codex-relay 1.0.4 → 1.0.6

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/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ https://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Codex Relay contributors
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ https://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md CHANGED
@@ -16,7 +16,7 @@ Run the server from the workspace you want Codex to use:
16
16
  npx codex-relay@latest
17
17
  ```
18
18
 
19
- The CLI prints a QR code, a mobile URL, and a `codex-relay://pair...` pairing payload. Scan the QR code from the mobile app. If scanning is not available, paste the full pairing payload into the app.
19
+ The CLI prints a QR code, a mobile URL, and a `codex-relay://pair...` pairing payload. Scan the QR code from the mobile app. If the relay detects multiple possible network addresses, the QR includes them and the app automatically uses the first address it can reach. If scanning is not available, paste the full pairing payload into the app.
20
20
 
21
21
  When the app shows an approval code, approve it on the computer:
22
22
 
@@ -117,10 +117,11 @@ CODEX_RELAY_WORKSPACE_PATH=/path/to/project npx codex-relay@latest
117
117
 
118
118
  ## Network Notes
119
119
 
120
- The phone must be able to reach the URL printed as `Mobile:` by the relay.
120
+ The phone must be able to reach one of the URLs printed by the relay.
121
121
 
122
122
  - On the same Wi-Fi network, the relay usually prints a local network address.
123
123
  - On Tailscale, the relay prefers your Tailscale address when it can detect one.
124
+ - If several Wi-Fi, VPN, or virtual network addresses are available, the QR includes all detected candidates and the app tries them automatically.
124
125
  - If the printed URL is not reachable from the phone, set `CODEX_RELAY_PUBLIC_URL` to a reachable HTTP URL.
125
126
 
126
127
  ## Troubleshooting
@@ -1,2 +1,2 @@
1
- import { $ as SandboxModeSchema, A as PairResponseSchema, At as isPromptSkillMarkdownMention, B as QueuedThreadInputSchema, C as ListQueuedThreadInputsResponseSchema, Ct as WorkspaceMarkdownPreviewTargetSchema, D as ListWorkspaceFilesResponseSchema, Dt as apiPaths, E as ListWorkspaceDirectoriesResponseSchema, Et as WorkspaceSelectionRequestSchema, F as PromptAttachmentSummarySchema, Ft as promptSkillMentionMarkdown, G as ResolveApprovalRequestSchema, H as RateLimitWindowSchema, I as PromptContextInputSchema, It as promptSkillMentionTextCandidates, J as RunThreadResponseSchema, K as ResolveApprovalResponseSchema, L as PromptContextSchema, Lt as stripPromptSkillMentions, M as PendingInputRequestQuestionSchema, Mt as promptMarkdownWithSkills, N as PendingInputRequestSchema, Nt as promptSkillDisplayName, O as PairEncryptedPayloadSchema, Ot as chatMessageDetailsFromPromptContext, P as PromptAttachmentSchema, Pt as promptSkillMentionLabel, Q as RuntimePreferencesSchema, R as PromptSkillSchema, S as ListModelsResponseSchema, St as WorkspaceGitActionResponseSchema, T as ListThreadsResponseSchema, Tt as WorkspacePreviewTabSchema, U as RateLimitsResponseSchema, V as RateLimitBucketSchema, W as ReasoningEffortSchema, X as RuntimePreferencesByWorkspacePathSchema, Y as RuntimeModeSchema, Z as RuntimePreferencesResponseSchema, _ as EncryptedPayloadSchema, _t as WebPreviewTargetSchema, a as ArchiveThreadResponseSchema, at as ThreadContextWindowResponseSchema, b as InterruptThreadRunResponseSchema, bt as WorkspaceFileContentResponseSchema, c as ChatMessageRoleSchema, ct as ThreadMessageDetailResponseSchema, d as CheckoutWorkspaceBranchRequestSchema, dt as ThreadSummarySchema, et as StatusResponseSchema, f as CodexModelSchema, ft as UpdateRuntimePreferencesRequestSchema, g as CreateThreadResponseSchema, gt as WORKSPACE_PREVIEW_TAB_VALUES, h as CreateThreadRequestSchema, ht as WORKSPACE_PREVIEW_OPEN_PROTOCOL, i as ApprovalModeSchema, it as ThreadCollaborationModeSchema, j as PendingInputRequestOptionSchema, jt as normalizePromptContext, k as PairRequestSchema, kt as createOpenApiDocument, l as ChatMessageSchema, lt as ThreadRunOptionsSchema, m as ContextWindowUsageSchema, mt as VersionResponseSchema, n as AgentSkillSourceSchema, nt as StreamThreadRunRequestSchema, o as ChatMessageKindSchema, ot as ThreadDetailResponseSchema, p as CommitPushWorkspaceRequestSchema, pt as UpdateWorkspaceFileContentRequestSchema, q as RunThreadRequestSchema, r as ApprovalDecisionSchema, rt as SubmitThreadInputResponseSchema, s as ChatMessagePromptDetailsSchema, st as ThreadMessageDetailFieldSchema, t as AgentSkillSchema, tt as StreamThreadRunEventSchema, u as ChatMessageStateSchema, ut as ThreadStateSchema, v as ErrorResponseSchema, vt as WorkspaceChangesResponseSchema, w as ListSkillsResponseSchema, wt as WorkspacePreviewNavigationRequestSchema, x as IsoDateTimeSchema, xt as WorkspaceFileMentionSchema, y as ImageAttachmentUploadResponseSchema, yt as WorkspaceDirectoryEntrySchema, z as QueuedThreadInputActionResponseSchema } from "./api-schema2.js";
2
- export { AgentSkillSchema, AgentSkillSourceSchema, ApprovalDecisionSchema, ApprovalModeSchema, ArchiveThreadResponseSchema, ChatMessageKindSchema, ChatMessagePromptDetailsSchema, ChatMessageRoleSchema, ChatMessageSchema, ChatMessageStateSchema, CheckoutWorkspaceBranchRequestSchema, CodexModelSchema, CommitPushWorkspaceRequestSchema, ContextWindowUsageSchema, CreateThreadRequestSchema, CreateThreadResponseSchema, EncryptedPayloadSchema, ErrorResponseSchema, ImageAttachmentUploadResponseSchema, InterruptThreadRunResponseSchema, IsoDateTimeSchema, ListModelsResponseSchema, ListQueuedThreadInputsResponseSchema, ListSkillsResponseSchema, ListThreadsResponseSchema, ListWorkspaceDirectoriesResponseSchema, ListWorkspaceFilesResponseSchema, PairEncryptedPayloadSchema, PairRequestSchema, PairResponseSchema, PendingInputRequestOptionSchema, PendingInputRequestQuestionSchema, PendingInputRequestSchema, PromptAttachmentSchema, PromptAttachmentSummarySchema, PromptContextInputSchema, PromptContextSchema, PromptSkillSchema, QueuedThreadInputActionResponseSchema, QueuedThreadInputSchema, RateLimitBucketSchema, RateLimitWindowSchema, RateLimitsResponseSchema, ReasoningEffortSchema, ResolveApprovalRequestSchema, ResolveApprovalResponseSchema, RunThreadRequestSchema, RunThreadResponseSchema, RuntimeModeSchema, RuntimePreferencesByWorkspacePathSchema, RuntimePreferencesResponseSchema, RuntimePreferencesSchema, SandboxModeSchema, StatusResponseSchema, StreamThreadRunEventSchema, StreamThreadRunRequestSchema, SubmitThreadInputResponseSchema, ThreadCollaborationModeSchema, ThreadContextWindowResponseSchema, ThreadDetailResponseSchema, ThreadMessageDetailFieldSchema, ThreadMessageDetailResponseSchema, ThreadRunOptionsSchema, ThreadStateSchema, ThreadSummarySchema, UpdateRuntimePreferencesRequestSchema, UpdateWorkspaceFileContentRequestSchema, VersionResponseSchema, WORKSPACE_PREVIEW_OPEN_PROTOCOL, WORKSPACE_PREVIEW_TAB_VALUES, WebPreviewTargetSchema, WorkspaceChangesResponseSchema, WorkspaceDirectoryEntrySchema, WorkspaceFileContentResponseSchema, WorkspaceFileMentionSchema, WorkspaceGitActionResponseSchema, WorkspaceMarkdownPreviewTargetSchema, WorkspacePreviewNavigationRequestSchema, WorkspacePreviewTabSchema, WorkspaceSelectionRequestSchema, apiPaths, chatMessageDetailsFromPromptContext, createOpenApiDocument, isPromptSkillMarkdownMention, normalizePromptContext, promptMarkdownWithSkills, promptSkillDisplayName, promptSkillMentionLabel, promptSkillMentionMarkdown, promptSkillMentionTextCandidates, stripPromptSkillMentions };
1
+ import { $ as SandboxModeSchema, A as PairResponseSchema, At as WorkspaceTerminalResizeRequestSchema, B as QueuedThreadInputSchema, Bt as promptSkillMentionLabel, C as ListQueuedThreadInputsResponseSchema, Ct as WorkspaceMarkdownPreviewTargetSchema, D as ListWorkspaceFilesResponseSchema, Dt as WorkspaceTerminalInputRequestSchema, E as ListWorkspaceDirectoriesResponseSchema, Et as WorkspaceSelectionRequestSchema, F as PromptAttachmentSummarySchema, Ft as createOpenApiDocument, G as ResolveApprovalRequestSchema, H as RateLimitWindowSchema, Ht as promptSkillMentionTextCandidates, I as PromptContextInputSchema, It as isPromptSkillMarkdownMention, J as RunThreadResponseSchema, K as ResolveApprovalResponseSchema, L as PromptContextSchema, Lt as normalizePromptContext, M as PendingInputRequestQuestionSchema, Mt as WorkspaceTerminalStartRequestSchema, N as PendingInputRequestSchema, Nt as apiPaths, O as PairEncryptedPayloadSchema, Ot as WorkspaceTerminalOutputChunkSchema, P as PromptAttachmentSchema, Pt as chatMessageDetailsFromPromptContext, Q as RuntimePreferencesSchema, R as PromptSkillSchema, Rt as promptMarkdownWithSkills, S as ListModelsResponseSchema, St as WorkspaceGitActionResponseSchema, T as ListThreadsResponseSchema, Tt as WorkspacePreviewTabSchema, U as RateLimitsResponseSchema, Ut as stripPromptSkillMentions, V as RateLimitBucketSchema, Vt as promptSkillMentionMarkdown, W as ReasoningEffortSchema, X as RuntimePreferencesByWorkspacePathSchema, Y as RuntimeModeSchema, Z as RuntimePreferencesResponseSchema, _ as EncryptedPayloadSchema, _t as WebPreviewTargetSchema, a as ArchiveThreadResponseSchema, at as ThreadContextWindowResponseSchema, b as InterruptThreadRunResponseSchema, bt as WorkspaceFileContentResponseSchema, c as ChatMessageRoleSchema, ct as ThreadMessageDetailResponseSchema, d as CheckoutWorkspaceBranchRequestSchema, dt as ThreadSummarySchema, et as StatusResponseSchema, f as CodexModelSchema, ft as UpdateRuntimePreferencesRequestSchema, g as CreateThreadResponseSchema, gt as WORKSPACE_PREVIEW_TAB_VALUES, h as CreateThreadRequestSchema, ht as WORKSPACE_PREVIEW_OPEN_PROTOCOL, i as ApprovalModeSchema, it as ThreadCollaborationModeSchema, j as PendingInputRequestOptionSchema, jt as WorkspaceTerminalSessionResponseSchema, k as PairRequestSchema, kt as WorkspaceTerminalOutputResponseSchema, l as ChatMessageSchema, lt as ThreadRunOptionsSchema, m as ContextWindowUsageSchema, mt as VersionResponseSchema, n as AgentSkillSourceSchema, nt as StreamThreadRunRequestSchema, o as ChatMessageKindSchema, ot as ThreadDetailResponseSchema, p as CommitPushWorkspaceRequestSchema, pt as UpdateWorkspaceFileContentRequestSchema, q as RunThreadRequestSchema, r as ApprovalDecisionSchema, rt as SubmitThreadInputResponseSchema, s as ChatMessagePromptDetailsSchema, st as ThreadMessageDetailFieldSchema, t as AgentSkillSchema, tt as StreamThreadRunEventSchema, u as ChatMessageStateSchema, ut as ThreadStateSchema, v as ErrorResponseSchema, vt as WorkspaceChangesResponseSchema, w as ListSkillsResponseSchema, wt as WorkspacePreviewNavigationRequestSchema, x as IsoDateTimeSchema, xt as WorkspaceFileMentionSchema, y as ImageAttachmentUploadResponseSchema, yt as WorkspaceDirectoryEntrySchema, z as QueuedThreadInputActionResponseSchema, zt as promptSkillDisplayName } from "./api-schema2.js";
2
+ export { AgentSkillSchema, AgentSkillSourceSchema, ApprovalDecisionSchema, ApprovalModeSchema, ArchiveThreadResponseSchema, ChatMessageKindSchema, ChatMessagePromptDetailsSchema, ChatMessageRoleSchema, ChatMessageSchema, ChatMessageStateSchema, CheckoutWorkspaceBranchRequestSchema, CodexModelSchema, CommitPushWorkspaceRequestSchema, ContextWindowUsageSchema, CreateThreadRequestSchema, CreateThreadResponseSchema, EncryptedPayloadSchema, ErrorResponseSchema, ImageAttachmentUploadResponseSchema, InterruptThreadRunResponseSchema, IsoDateTimeSchema, ListModelsResponseSchema, ListQueuedThreadInputsResponseSchema, ListSkillsResponseSchema, ListThreadsResponseSchema, ListWorkspaceDirectoriesResponseSchema, ListWorkspaceFilesResponseSchema, PairEncryptedPayloadSchema, PairRequestSchema, PairResponseSchema, PendingInputRequestOptionSchema, PendingInputRequestQuestionSchema, PendingInputRequestSchema, PromptAttachmentSchema, PromptAttachmentSummarySchema, PromptContextInputSchema, PromptContextSchema, PromptSkillSchema, QueuedThreadInputActionResponseSchema, QueuedThreadInputSchema, RateLimitBucketSchema, RateLimitWindowSchema, RateLimitsResponseSchema, ReasoningEffortSchema, ResolveApprovalRequestSchema, ResolveApprovalResponseSchema, RunThreadRequestSchema, RunThreadResponseSchema, RuntimeModeSchema, RuntimePreferencesByWorkspacePathSchema, RuntimePreferencesResponseSchema, RuntimePreferencesSchema, SandboxModeSchema, StatusResponseSchema, StreamThreadRunEventSchema, StreamThreadRunRequestSchema, SubmitThreadInputResponseSchema, ThreadCollaborationModeSchema, ThreadContextWindowResponseSchema, ThreadDetailResponseSchema, ThreadMessageDetailFieldSchema, ThreadMessageDetailResponseSchema, ThreadRunOptionsSchema, ThreadStateSchema, ThreadSummarySchema, UpdateRuntimePreferencesRequestSchema, UpdateWorkspaceFileContentRequestSchema, VersionResponseSchema, WORKSPACE_PREVIEW_OPEN_PROTOCOL, WORKSPACE_PREVIEW_TAB_VALUES, WebPreviewTargetSchema, WorkspaceChangesResponseSchema, WorkspaceDirectoryEntrySchema, WorkspaceFileContentResponseSchema, WorkspaceFileMentionSchema, WorkspaceGitActionResponseSchema, WorkspaceMarkdownPreviewTargetSchema, WorkspacePreviewNavigationRequestSchema, WorkspacePreviewTabSchema, WorkspaceSelectionRequestSchema, WorkspaceTerminalInputRequestSchema, WorkspaceTerminalOutputChunkSchema, WorkspaceTerminalOutputResponseSchema, WorkspaceTerminalResizeRequestSchema, WorkspaceTerminalSessionResponseSchema, WorkspaceTerminalStartRequestSchema, apiPaths, chatMessageDetailsFromPromptContext, createOpenApiDocument, isPromptSkillMarkdownMention, normalizePromptContext, promptMarkdownWithSkills, promptSkillDisplayName, promptSkillMentionLabel, promptSkillMentionMarkdown, promptSkillMentionTextCandidates, stripPromptSkillMentions };
@@ -313,7 +313,8 @@ const WORKSPACE_PREVIEW_TAB_VALUES = [
313
313
  "git",
314
314
  "files",
315
315
  "markdown",
316
- "web"
316
+ "web",
317
+ "ssh"
317
318
  ];
318
319
  const WorkspacePreviewTabSchema = z.enum(WORKSPACE_PREVIEW_TAB_VALUES);
319
320
  const WorkspaceMarkdownPreviewTargetSchema = z.object({
@@ -356,8 +357,39 @@ const WorkspacePreviewNavigationRequestSchema = z.discriminatedUnion("tab", [
356
357
  WorkspacePreviewOpenBaseSchema.extend({
357
358
  tab: z.literal("web"),
358
359
  target: WebPreviewTargetSchema.optional()
359
- })
360
+ }),
361
+ WorkspacePreviewOpenBaseSchema.extend({ tab: z.literal("ssh") })
360
362
  ]);
363
+ const WorkspaceTerminalStartRequestSchema = WorkspaceSelectionRequestSchema.extend({
364
+ cols: z.number().int().min(2).max(300).default(80),
365
+ rows: z.number().int().min(2).max(120).default(24)
366
+ });
367
+ const WorkspaceTerminalOutputChunkSchema = z.object({
368
+ data: z.string(),
369
+ seq: z.number().int().nonnegative()
370
+ });
371
+ const WorkspaceTerminalSessionResponseSchema = z.object({
372
+ cols: z.number().int().positive(),
373
+ rows: z.number().int().positive(),
374
+ sessionId: z.string().min(1),
375
+ startedAt: IsoDateTimeSchema,
376
+ workspacePath: z.string().min(1)
377
+ });
378
+ const WorkspaceTerminalOutputResponseSchema = z.object({
379
+ chunks: z.array(WorkspaceTerminalOutputChunkSchema),
380
+ exitCode: z.number().int().nullable().optional(),
381
+ exitedAt: IsoDateTimeSchema.optional(),
382
+ nextSeq: z.number().int().nonnegative()
383
+ });
384
+ const WorkspaceTerminalInputRequestSchema = z.union([
385
+ z.object({ data: z.string().min(1) }),
386
+ z.object({ input: z.string().min(1) }),
387
+ z.string().min(1)
388
+ ]).transform((payload) => ({ data: typeof payload === "string" ? payload : "data" in payload ? payload.data : payload.input }));
389
+ const WorkspaceTerminalResizeRequestSchema = z.object({
390
+ cols: z.number().int().min(2).max(300),
391
+ rows: z.number().int().min(2).max(120)
392
+ });
361
393
  const PairRequestSchema = z.object({
362
394
  clientSessionId: z.string().trim().min(1).max(120).optional(),
363
395
  clientName: z.string().trim().min(1).max(80).optional(),
@@ -640,6 +672,7 @@ const apiPaths = {
640
672
  pair: "/v1/pair",
641
673
  pairApproval: (approvalCode) => `/v1/pair/${encodeURIComponent(approvalCode)}`,
642
674
  pairApprove: "/v1/pair/approve",
675
+ sessionsClear: "/v1/sessions/clear",
643
676
  sessionRefresh: "/v1/session/refresh",
644
677
  status: "/v1/status",
645
678
  preferences: "/v1/preferences",
@@ -652,6 +685,11 @@ const apiPaths = {
652
685
  workspaceChanges: "/v1/workspace/changes",
653
686
  workspaceCheckout: "/v1/workspace/checkout",
654
687
  workspaceCommitPush: "/v1/workspace/commit-push",
688
+ workspaceTerminalSessions: "/v1/workspace/terminal/sessions",
689
+ workspaceTerminalSession: (sessionId) => `/v1/workspace/terminal/sessions/${encodeURIComponent(sessionId)}`,
690
+ workspaceTerminalInput: (sessionId) => `/v1/workspace/terminal/sessions/${encodeURIComponent(sessionId)}/input`,
691
+ workspaceTerminalOutput: (sessionId) => `/v1/workspace/terminal/sessions/${encodeURIComponent(sessionId)}/output`,
692
+ workspaceTerminalResize: (sessionId) => `/v1/workspace/terminal/sessions/${encodeURIComponent(sessionId)}/resize`,
655
693
  imageAttachments: "/v1/attachments/images",
656
694
  imageAttachment: (attachmentId) => `/v1/attachments/images/${encodeURIComponent(attachmentId)}`,
657
695
  threads: "/v1/threads",
@@ -1522,4 +1560,4 @@ function jsonResponse(schemaName) {
1522
1560
  };
1523
1561
  }
1524
1562
  //#endregion
1525
- export { SandboxModeSchema as $, PairResponseSchema as A, isPromptSkillMarkdownMention as At, QueuedThreadInputSchema as B, ListQueuedThreadInputsResponseSchema as C, WorkspaceMarkdownPreviewTargetSchema as Ct, ListWorkspaceFilesResponseSchema as D, apiPaths as Dt, ListWorkspaceDirectoriesResponseSchema as E, WorkspaceSelectionRequestSchema as Et, PromptAttachmentSummarySchema as F, promptSkillMentionMarkdown as Ft, ResolveApprovalRequestSchema as G, RateLimitWindowSchema as H, PromptContextInputSchema as I, promptSkillMentionTextCandidates as It, RunThreadResponseSchema as J, ResolveApprovalResponseSchema as K, PromptContextSchema as L, stripPromptSkillMentions as Lt, PendingInputRequestQuestionSchema as M, promptMarkdownWithSkills as Mt, PendingInputRequestSchema as N, promptSkillDisplayName as Nt, PairEncryptedPayloadSchema as O, chatMessageDetailsFromPromptContext as Ot, PromptAttachmentSchema as P, promptSkillMentionLabel as Pt, RuntimePreferencesSchema as Q, PromptSkillSchema as R, ListModelsResponseSchema as S, WorkspaceGitActionResponseSchema as St, ListThreadsResponseSchema as T, WorkspacePreviewTabSchema as Tt, RateLimitsResponseSchema as U, RateLimitBucketSchema as V, ReasoningEffortSchema as W, RuntimePreferencesByWorkspacePathSchema as X, RuntimeModeSchema as Y, RuntimePreferencesResponseSchema as Z, EncryptedPayloadSchema as _, WebPreviewTargetSchema as _t, ArchiveThreadResponseSchema as a, ThreadContextWindowResponseSchema as at, InterruptThreadRunResponseSchema as b, WorkspaceFileContentResponseSchema as bt, ChatMessageRoleSchema as c, ThreadMessageDetailResponseSchema as ct, CheckoutWorkspaceBranchRequestSchema as d, ThreadSummarySchema as dt, StatusResponseSchema as et, CodexModelSchema as f, UpdateRuntimePreferencesRequestSchema as ft, CreateThreadResponseSchema as g, WORKSPACE_PREVIEW_TAB_VALUES as gt, CreateThreadRequestSchema as h, WORKSPACE_PREVIEW_OPEN_PROTOCOL as ht, ApprovalModeSchema as i, ThreadCollaborationModeSchema as it, PendingInputRequestOptionSchema as j, normalizePromptContext as jt, PairRequestSchema as k, createOpenApiDocument as kt, ChatMessageSchema as l, ThreadRunOptionsSchema as lt, ContextWindowUsageSchema as m, VersionResponseSchema as mt, AgentSkillSourceSchema as n, StreamThreadRunRequestSchema as nt, ChatMessageKindSchema as o, ThreadDetailResponseSchema as ot, CommitPushWorkspaceRequestSchema as p, UpdateWorkspaceFileContentRequestSchema as pt, RunThreadRequestSchema as q, ApprovalDecisionSchema as r, SubmitThreadInputResponseSchema as rt, ChatMessagePromptDetailsSchema as s, ThreadMessageDetailFieldSchema as st, AgentSkillSchema as t, StreamThreadRunEventSchema as tt, ChatMessageStateSchema as u, ThreadStateSchema as ut, ErrorResponseSchema as v, WorkspaceChangesResponseSchema as vt, ListSkillsResponseSchema as w, WorkspacePreviewNavigationRequestSchema as wt, IsoDateTimeSchema as x, WorkspaceFileMentionSchema as xt, ImageAttachmentUploadResponseSchema as y, WorkspaceDirectoryEntrySchema as yt, QueuedThreadInputActionResponseSchema as z };
1563
+ export { SandboxModeSchema as $, PairResponseSchema as A, WorkspaceTerminalResizeRequestSchema as At, QueuedThreadInputSchema as B, promptSkillMentionLabel as Bt, ListQueuedThreadInputsResponseSchema as C, WorkspaceMarkdownPreviewTargetSchema as Ct, ListWorkspaceFilesResponseSchema as D, WorkspaceTerminalInputRequestSchema as Dt, ListWorkspaceDirectoriesResponseSchema as E, WorkspaceSelectionRequestSchema as Et, PromptAttachmentSummarySchema as F, createOpenApiDocument as Ft, ResolveApprovalRequestSchema as G, RateLimitWindowSchema as H, promptSkillMentionTextCandidates as Ht, PromptContextInputSchema as I, isPromptSkillMarkdownMention as It, RunThreadResponseSchema as J, ResolveApprovalResponseSchema as K, PromptContextSchema as L, normalizePromptContext as Lt, PendingInputRequestQuestionSchema as M, WorkspaceTerminalStartRequestSchema as Mt, PendingInputRequestSchema as N, apiPaths as Nt, PairEncryptedPayloadSchema as O, WorkspaceTerminalOutputChunkSchema as Ot, PromptAttachmentSchema as P, chatMessageDetailsFromPromptContext as Pt, RuntimePreferencesSchema as Q, PromptSkillSchema as R, promptMarkdownWithSkills as Rt, ListModelsResponseSchema as S, WorkspaceGitActionResponseSchema as St, ListThreadsResponseSchema as T, WorkspacePreviewTabSchema as Tt, RateLimitsResponseSchema as U, stripPromptSkillMentions as Ut, RateLimitBucketSchema as V, promptSkillMentionMarkdown as Vt, ReasoningEffortSchema as W, RuntimePreferencesByWorkspacePathSchema as X, RuntimeModeSchema as Y, RuntimePreferencesResponseSchema as Z, EncryptedPayloadSchema as _, WebPreviewTargetSchema as _t, ArchiveThreadResponseSchema as a, ThreadContextWindowResponseSchema as at, InterruptThreadRunResponseSchema as b, WorkspaceFileContentResponseSchema as bt, ChatMessageRoleSchema as c, ThreadMessageDetailResponseSchema as ct, CheckoutWorkspaceBranchRequestSchema as d, ThreadSummarySchema as dt, StatusResponseSchema as et, CodexModelSchema as f, UpdateRuntimePreferencesRequestSchema as ft, CreateThreadResponseSchema as g, WORKSPACE_PREVIEW_TAB_VALUES as gt, CreateThreadRequestSchema as h, WORKSPACE_PREVIEW_OPEN_PROTOCOL as ht, ApprovalModeSchema as i, ThreadCollaborationModeSchema as it, PendingInputRequestOptionSchema as j, WorkspaceTerminalSessionResponseSchema as jt, PairRequestSchema as k, WorkspaceTerminalOutputResponseSchema as kt, ChatMessageSchema as l, ThreadRunOptionsSchema as lt, ContextWindowUsageSchema as m, VersionResponseSchema as mt, AgentSkillSourceSchema as n, StreamThreadRunRequestSchema as nt, ChatMessageKindSchema as o, ThreadDetailResponseSchema as ot, CommitPushWorkspaceRequestSchema as p, UpdateWorkspaceFileContentRequestSchema as pt, RunThreadRequestSchema as q, ApprovalDecisionSchema as r, SubmitThreadInputResponseSchema as rt, ChatMessagePromptDetailsSchema as s, ThreadMessageDetailFieldSchema as st, AgentSkillSchema as t, StreamThreadRunEventSchema as tt, ChatMessageStateSchema as u, ThreadStateSchema as ut, ErrorResponseSchema as v, WorkspaceChangesResponseSchema as vt, ListSkillsResponseSchema as w, WorkspacePreviewNavigationRequestSchema as wt, IsoDateTimeSchema as x, WorkspaceFileMentionSchema as xt, ImageAttachmentUploadResponseSchema as y, WorkspaceDirectoryEntrySchema as yt, QueuedThreadInputActionResponseSchema as z, promptSkillDisplayName as zt };
package/dist/cli.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import { Dt as apiPaths } from "./api-schema2.js";
3
- import { n as codexRelayHome, r as legacyCodexRelayDataPath, t as codexRelayDataPath } from "./paths.js";
2
+ import { Nt as apiPaths } from "./api-schema2.js";
3
+ import { n as codexRelayHome, o as getConnectUrlGuidance, r as legacyCodexRelayDataPath, s as createTursoPairingSessionStore, t as codexRelayDataPath } from "./paths.js";
4
4
  import { Command } from "@commander-js/extra-typings";
5
5
  import qrcode from "qrcode-terminal";
6
6
  import { spawn } from "node:child_process";
7
7
  import { closeSync, openSync } from "node:fs";
8
- import { mkdir, readFile, unlink } from "node:fs/promises";
8
+ import { access, mkdir, readFile, rm, unlink } from "node:fs/promises";
9
9
  import { dirname } from "node:path";
10
10
  import { setTimeout } from "node:timers/promises";
11
11
  import { fileURLToPath } from "node:url";
@@ -17,6 +17,7 @@ Examples:
17
17
  ${npxCommand} Start the relay and print a pairing QR
18
18
  ${npxCommand} --bg Start the relay in the background
19
19
  ${npxCommand} qr Print the current pairing QR
20
+ ${npxCommand} clear Sign out every paired mobile app
20
21
  ${npxCommand} approve CODE Approve a pending mobile pairing request`).action(async (options) => {
21
22
  if (options.debug) process.env.CODEX_RELAY_DEBUG = "1";
22
23
  if (options.dangerouslyAutoApprove) process.env.CODEX_RELAY_DANGEROUSLY_AUTO_APPROVE = "1";
@@ -32,6 +33,9 @@ program.command("qr").description("Print the current pairing QR for an already r
32
33
  program.command("approve").description("Approve a pending mobile pairing request.").argument("<approval-code>", "approval code shown in the mobile app").action(async (approvalCode) => {
33
34
  await approvePairing(approvalCode);
34
35
  });
36
+ program.command("clear").description("Sign out every paired mobile app.").option("--debug", "also delete debug.log").action(async (options, command) => {
37
+ await clearPairings({ clearDebugLog: Boolean(options.debug || command.optsWithGlobals().debug) });
38
+ });
35
39
  await program.parseAsync();
36
40
  async function startBackgroundServer() {
37
41
  const logPath = codexRelayDataPath("server.log");
@@ -135,6 +139,74 @@ async function approvePairing(rawCode) {
135
139
  }
136
140
  console.log("Approved Codex Relay pairing request.");
137
141
  }
142
+ async function clearPairings(options) {
143
+ const result = await clearPairingsViaServer().catch(async (error) => {
144
+ if (await hasRunningBackgroundServer()) throw error;
145
+ return clearPairingsFromLocalStore();
146
+ });
147
+ const removedDebugLogs = options.clearDebugLog ? await clearDebugLogs() : [];
148
+ console.log(`Signed out ${result.sessionsCleared} paired mobile app${result.sessionsCleared === 1 ? "" : "s"}.`);
149
+ if (result.pendingPairingsCleared > 0) console.log(`Removed ${result.pendingPairingsCleared} pending pairing request${result.pendingPairingsCleared === 1 ? "" : "s"}.`);
150
+ if (options.clearDebugLog) console.log(removedDebugLogs.length > 0 ? `Deleted debug logs: ${removedDebugLogs.join(", ")}` : "No debug logs found.");
151
+ }
152
+ async function clearPairingsViaServer() {
153
+ const endpoint = await getApprovalEndpoint();
154
+ const secret = await readApprovalSecret();
155
+ const response = await fetch(`${endpoint}${apiPaths.sessionsClear}`, {
156
+ method: "POST",
157
+ headers: {
158
+ accept: "application/json",
159
+ "x-codex-relay-approve-secret": secret
160
+ }
161
+ });
162
+ const payload = await response.json().catch(() => void 0);
163
+ if (!response.ok) {
164
+ const message = payload && typeof payload === "object" && "error" in payload && payload.error && typeof payload.error === "object" && "message" in payload.error ? String(payload.error.message) : `Codex Relay server returned ${response.status}`;
165
+ throw new Error(message);
166
+ }
167
+ return parseClearPairingResult(payload);
168
+ }
169
+ async function clearPairingsFromLocalStore() {
170
+ const dbPath = await resolveAuthDbPath();
171
+ if (!dbPath) return {
172
+ pendingPairingsCleared: 0,
173
+ sessionsCleared: 0
174
+ };
175
+ return (await createTursoPairingSessionStore(dbPath)).clearAll();
176
+ }
177
+ async function resolveAuthDbPath() {
178
+ if (process.env.CODEX_RELAY_AUTH_DB_PATH) return process.env.CODEX_RELAY_AUTH_DB_PATH;
179
+ const primary = codexRelayDataPath("auth.db");
180
+ if (await pathExists(primary)) return primary;
181
+ const legacy = legacyCodexRelayDataPath("auth.db");
182
+ if (await pathExists(legacy)) return legacy;
183
+ }
184
+ async function clearDebugLogs() {
185
+ const paths = [...new Set([codexRelayDataPath("debug.log"), legacyCodexRelayDataPath("debug.log")])];
186
+ const removed = [];
187
+ for (const path of paths) {
188
+ if (!await pathExists(path)) continue;
189
+ await rm(path, { force: true });
190
+ removed.push(path);
191
+ }
192
+ return removed;
193
+ }
194
+ async function hasRunningBackgroundServer() {
195
+ return Boolean(await readRunningPid(codexRelayDataPath("server.pid")));
196
+ }
197
+ async function pathExists(path) {
198
+ return access(path).then(() => true, () => false);
199
+ }
200
+ function parseClearPairingResult(payload) {
201
+ if (!payload || typeof payload !== "object") return {
202
+ pendingPairingsCleared: 0,
203
+ sessionsCleared: 0
204
+ };
205
+ return {
206
+ pendingPairingsCleared: "pendingPairingsCleared" in payload ? Number(payload.pendingPairingsCleared) || 0 : 0,
207
+ sessionsCleared: "sessionsCleared" in payload ? Number(payload.sessionsCleared) || 0 : 0
208
+ };
209
+ }
138
210
  async function printPairingQr() {
139
211
  const storedState = await readServerState();
140
212
  const state = storedState?.pairingPayload ? storedState : await readServerLogState();
@@ -148,7 +220,15 @@ async function printPairingQr() {
148
220
  console.log("");
149
221
  qrcode.generate(state.pairingPayload, { small: true });
150
222
  console.log("");
151
- if (state.connectUrl) console.log(`Mobile: ${state.connectUrl}`);
223
+ if (state.connectUrl) {
224
+ console.log(`Mobile: ${state.connectUrl}`);
225
+ const guidance = getConnectUrlGuidance(state.connectUrl);
226
+ if (guidance) console.log(`Network: ${guidance}`);
227
+ }
228
+ if (state.connectUrlCandidates && state.connectUrlCandidates.length > 1) {
229
+ console.log(`Candidate addresses: ${state.connectUrlCandidates.length}`);
230
+ for (const candidate of state.connectUrlCandidates.slice(1)) console.log(` ${candidate.label}: ${candidate.url}`);
231
+ }
152
232
  if (state.listenUrl) console.log(`Server: ${state.listenUrl}`);
153
233
  console.log("");
154
234
  console.log(`Pairing: ${state.pairingPayload}`);
@@ -206,6 +286,7 @@ async function readServerState() {
206
286
  if (!state) return;
207
287
  return {
208
288
  connectUrl: typeof state.connectUrl === "string" ? state.connectUrl : void 0,
289
+ connectUrlCandidates: parseConnectUrlCandidates(state.connectUrlCandidates),
209
290
  host: typeof state.host === "string" ? state.host : void 0,
210
291
  listenUrl: typeof state.listenUrl === "string" ? state.listenUrl : void 0,
211
292
  pairingPayload: typeof state.pairingPayload === "string" ? state.pairingPayload : void 0,
@@ -235,6 +316,18 @@ function lastLogValue(log, label) {
235
316
  for (const match of log.matchAll(pattern)) value = match[1];
236
317
  return value;
237
318
  }
319
+ function parseConnectUrlCandidates(value) {
320
+ if (!Array.isArray(value)) return;
321
+ return value.map((candidate) => {
322
+ if (!candidate || typeof candidate !== "object") return;
323
+ const label = "label" in candidate ? candidate.label : void 0;
324
+ const url = "url" in candidate ? candidate.url : void 0;
325
+ return typeof label === "string" && typeof url === "string" ? {
326
+ label,
327
+ url
328
+ } : void 0;
329
+ }).filter((candidate) => Boolean(candidate));
330
+ }
238
331
  function isDatabaseLockError(error) {
239
332
  const message = error instanceof Error ? error.message : String(error);
240
333
  return message.includes("failed to open database") && message.includes("Locking error");