codex-relay 1.0.5 → 1.0.7
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 +190 -0
- package/dist/api-schema.js +2 -2
- package/dist/api-schema2.js +41 -3
- package/dist/cli.js +1 -1
- package/dist/src.js +189 -1
- package/package.json +3 -1
- package/src/api-schema.ts +62 -1
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/dist/api-schema.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as SandboxModeSchema, A as PairResponseSchema, At as
|
|
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 };
|
package/dist/api-schema2.js
CHANGED
|
@@ -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(),
|
|
@@ -653,6 +685,12 @@ const apiPaths = {
|
|
|
653
685
|
workspaceChanges: "/v1/workspace/changes",
|
|
654
686
|
workspaceCheckout: "/v1/workspace/checkout",
|
|
655
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
|
+
workspaceTerminalOutputStream: (sessionId) => `/v1/workspace/terminal/sessions/${encodeURIComponent(sessionId)}/output/stream`,
|
|
693
|
+
workspaceTerminalResize: (sessionId) => `/v1/workspace/terminal/sessions/${encodeURIComponent(sessionId)}/resize`,
|
|
656
694
|
imageAttachments: "/v1/attachments/images",
|
|
657
695
|
imageAttachment: (attachmentId) => `/v1/attachments/images/${encodeURIComponent(attachmentId)}`,
|
|
658
696
|
threads: "/v1/threads",
|
|
@@ -1523,4 +1561,4 @@ function jsonResponse(schemaName) {
|
|
|
1523
1561
|
};
|
|
1524
1562
|
}
|
|
1525
1563
|
//#endregion
|
|
1526
|
-
export { SandboxModeSchema as $, PairResponseSchema as A,
|
|
1564
|
+
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,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { Nt as apiPaths } from "./api-schema2.js";
|
|
3
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";
|
package/dist/src.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as PairResponseSchema, C as ListQueuedThreadInputsResponseSchema, D as ListWorkspaceFilesResponseSchema, Dt as
|
|
1
|
+
import { A as PairResponseSchema, At as WorkspaceTerminalResizeRequestSchema, C as ListQueuedThreadInputsResponseSchema, D as ListWorkspaceFilesResponseSchema, Dt as WorkspaceTerminalInputRequestSchema, E as ListWorkspaceDirectoriesResponseSchema, Ft as createOpenApiDocument, G as ResolveApprovalRequestSchema, K as ResolveApprovalResponseSchema, Lt as normalizePromptContext, Mt as WorkspaceTerminalStartRequestSchema, Nt as apiPaths, Pt as chatMessageDetailsFromPromptContext, Q as RuntimePreferencesSchema, Rt as promptMarkdownWithSkills, S as ListModelsResponseSchema, St as WorkspaceGitActionResponseSchema, T as ListThreadsResponseSchema, U as RateLimitsResponseSchema, Ut as stripPromptSkillMentions, X as RuntimePreferencesByWorkspacePathSchema, Z as RuntimePreferencesResponseSchema, _ as EncryptedPayloadSchema, a as ArchiveThreadResponseSchema, at as ThreadContextWindowResponseSchema, b as InterruptThreadRunResponseSchema, bt as WorkspaceFileContentResponseSchema, ct as ThreadMessageDetailResponseSchema, d as CheckoutWorkspaceBranchRequestSchema, dt as ThreadSummarySchema, et as StatusResponseSchema, ft as UpdateRuntimePreferencesRequestSchema, h as CreateThreadRequestSchema, jt as WorkspaceTerminalSessionResponseSchema, k as PairRequestSchema, kt as WorkspaceTerminalOutputResponseSchema, l as ChatMessageSchema, m as ContextWindowUsageSchema, mt as VersionResponseSchema, nt as StreamThreadRunRequestSchema, ot as ThreadDetailResponseSchema, p as CommitPushWorkspaceRequestSchema, pt as UpdateWorkspaceFileContentRequestSchema, q as RunThreadRequestSchema, rt as SubmitThreadInputResponseSchema, st as ThreadMessageDetailFieldSchema, tt as StreamThreadRunEventSchema, vt as WorkspaceChangesResponseSchema, w as ListSkillsResponseSchema, y as ImageAttachmentUploadResponseSchema, z as QueuedThreadInputActionResponseSchema } from "./api-schema2.js";
|
|
2
2
|
import { a as getConnectUrlCandidates, i as createPairingQrPayload, o as getConnectUrlGuidance, r as legacyCodexRelayDataPath, s as createTursoPairingSessionStore, t as codexRelayDataPath } from "./paths.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import qrcode from "qrcode-terminal";
|
|
@@ -17,6 +17,7 @@ import { openRepository } from "es-git";
|
|
|
17
17
|
import { Hono } from "hono";
|
|
18
18
|
import { cors } from "hono/cors";
|
|
19
19
|
import { promisify } from "node:util";
|
|
20
|
+
import * as pty from "@lydell/node-pty";
|
|
20
21
|
import { createInterface } from "node:readline";
|
|
21
22
|
import { Codex } from "@openai/codex-sdk";
|
|
22
23
|
import { gcm } from "@noble/ciphers/aes.js";
|
|
@@ -822,6 +823,7 @@ const defaultWebPreviewPorts = [
|
|
|
822
823
|
];
|
|
823
824
|
const PairApproveRequestSchema = z.object({ approvalCode: z.string().trim().min(1) });
|
|
824
825
|
const maxResolvedApprovals = 100;
|
|
826
|
+
const maxWorkspaceTerminalOutputChunks = 2e3;
|
|
825
827
|
function createApp(options = {}) {
|
|
826
828
|
const app = new Hono();
|
|
827
829
|
const appServer = options.appServer === void 0 ? process.env.VITEST ? null : new CodexAppServerClient() : options.appServer;
|
|
@@ -834,6 +836,7 @@ function createApp(options = {}) {
|
|
|
834
836
|
const pendingApprovals = /* @__PURE__ */ new Map();
|
|
835
837
|
const resolvedApprovals = /* @__PURE__ */ new Map();
|
|
836
838
|
const queuedInputsByThreadId = /* @__PURE__ */ new Map();
|
|
839
|
+
const workspaceTerminalSessions = /* @__PURE__ */ new Map();
|
|
837
840
|
const activeAppServerTurnIdsByThreadId = /* @__PURE__ */ new Map();
|
|
838
841
|
const appServerHistoryLoadsByThreadId = /* @__PURE__ */ new Map();
|
|
839
842
|
const steeringThreads = /* @__PURE__ */ new Set();
|
|
@@ -1152,6 +1155,116 @@ function createApp(options = {}) {
|
|
|
1152
1155
|
return secureJson(c, options.pairing, secureSessionsByTokenHash, apiError("workspace_commit_push_failed", errorMessage(error)), 400);
|
|
1153
1156
|
}
|
|
1154
1157
|
});
|
|
1158
|
+
app.post(apiPaths.workspaceTerminalSessions, async (c) => {
|
|
1159
|
+
const parsed = await parseRequestJson(c, options.pairing, secureSessionsByTokenHash, WorkspaceTerminalStartRequestSchema);
|
|
1160
|
+
if (!parsed.success) return secureJson(c, options.pairing, secureSessionsByTokenHash, validationError(parsed.error), 400);
|
|
1161
|
+
const selectedWorkspacePath = await validateThreadWorkspacePath(workspacePath, parsed.data.workspacePath);
|
|
1162
|
+
if (!selectedWorkspacePath.success) return secureJson(c, options.pairing, secureSessionsByTokenHash, apiError("invalid_workspace_path", selectedWorkspacePath.error), 400);
|
|
1163
|
+
try {
|
|
1164
|
+
const session = createWorkspaceTerminalSession({
|
|
1165
|
+
cols: parsed.data.cols,
|
|
1166
|
+
cwd: selectedWorkspacePath.path,
|
|
1167
|
+
rows: parsed.data.rows
|
|
1168
|
+
});
|
|
1169
|
+
workspaceTerminalSessions.set(session.sessionId, session);
|
|
1170
|
+
const response = WorkspaceTerminalSessionResponseSchema.parse({
|
|
1171
|
+
cols: session.cols,
|
|
1172
|
+
rows: session.rows,
|
|
1173
|
+
sessionId: session.sessionId,
|
|
1174
|
+
startedAt: session.startedAt,
|
|
1175
|
+
workspacePath: session.workspacePath
|
|
1176
|
+
});
|
|
1177
|
+
return secureJson(c, options.pairing, secureSessionsByTokenHash, response);
|
|
1178
|
+
} catch (error) {
|
|
1179
|
+
return secureJson(c, options.pairing, secureSessionsByTokenHash, apiError("workspace_terminal_start_failed", errorMessage(error)), 400);
|
|
1180
|
+
}
|
|
1181
|
+
});
|
|
1182
|
+
app.get("/v1/workspace/terminal/sessions/:sessionId/output", async (c) => {
|
|
1183
|
+
const session = workspaceTerminalSessions.get(c.req.param("sessionId"));
|
|
1184
|
+
if (!session) return secureJson(c, options.pairing, secureSessionsByTokenHash, apiError("workspace_terminal_not_found", "Terminal session was not found."), 404);
|
|
1185
|
+
const since = Number(c.req.query("since") ?? "0");
|
|
1186
|
+
return secureJson(c, options.pairing, secureSessionsByTokenHash, workspaceTerminalOutputResponse(session, since));
|
|
1187
|
+
});
|
|
1188
|
+
app.get("/v1/workspace/terminal/sessions/:sessionId/output/stream", async (c) => {
|
|
1189
|
+
const session = workspaceTerminalSessions.get(c.req.param("sessionId"));
|
|
1190
|
+
if (!session) return secureJson(c, options.pairing, secureSessionsByTokenHash, apiError("workspace_terminal_not_found", "Terminal session was not found."), 404);
|
|
1191
|
+
const since = Number(c.req.query("since") ?? "0");
|
|
1192
|
+
const encoder = new TextEncoder();
|
|
1193
|
+
const secureSession = getSecureSessionForRequest(c, options.pairing, secureSessionsByTokenHash);
|
|
1194
|
+
let streamController;
|
|
1195
|
+
let closed = false;
|
|
1196
|
+
let stopHeartbeat;
|
|
1197
|
+
let unsubscribe = () => {};
|
|
1198
|
+
const closeStream = () => {
|
|
1199
|
+
if (closed) return;
|
|
1200
|
+
closed = true;
|
|
1201
|
+
if (stopHeartbeat) {
|
|
1202
|
+
clearInterval(stopHeartbeat);
|
|
1203
|
+
stopHeartbeat = void 0;
|
|
1204
|
+
}
|
|
1205
|
+
unsubscribe();
|
|
1206
|
+
if (streamController) {
|
|
1207
|
+
activeStreamControllers.delete(streamController);
|
|
1208
|
+
closeSseController(streamController);
|
|
1209
|
+
}
|
|
1210
|
+
};
|
|
1211
|
+
const send = (response) => {
|
|
1212
|
+
if (closed || !streamController) return;
|
|
1213
|
+
if (!sendTerminalOutputSse(streamController, encoder, secureSession, response)) {
|
|
1214
|
+
closeStream();
|
|
1215
|
+
return;
|
|
1216
|
+
}
|
|
1217
|
+
if (response.exitedAt) closeStream();
|
|
1218
|
+
};
|
|
1219
|
+
const stream = new ReadableStream({
|
|
1220
|
+
start(controller) {
|
|
1221
|
+
streamController = controller;
|
|
1222
|
+
activeStreamControllers.add(controller);
|
|
1223
|
+
send(workspaceTerminalOutputResponse(session, since));
|
|
1224
|
+
if (session.exitedAt) return;
|
|
1225
|
+
unsubscribe = subscribeWorkspaceTerminalOutput(session, send);
|
|
1226
|
+
stopHeartbeat = setInterval(() => {
|
|
1227
|
+
if (!closed && streamController) enqueueSseChunk(streamController, encoder.encode(": keep-alive\n\n"));
|
|
1228
|
+
}, 3e4);
|
|
1229
|
+
},
|
|
1230
|
+
cancel() {
|
|
1231
|
+
closeStream();
|
|
1232
|
+
}
|
|
1233
|
+
});
|
|
1234
|
+
return new Response(stream, { headers: {
|
|
1235
|
+
"cache-control": "no-cache, no-transform",
|
|
1236
|
+
connection: "keep-alive",
|
|
1237
|
+
"content-type": "text/event-stream",
|
|
1238
|
+
"x-accel-buffering": "no"
|
|
1239
|
+
} });
|
|
1240
|
+
});
|
|
1241
|
+
app.post("/v1/workspace/terminal/sessions/:sessionId/input", async (c) => {
|
|
1242
|
+
const session = workspaceTerminalSessions.get(c.req.param("sessionId"));
|
|
1243
|
+
if (!session) return secureJson(c, options.pairing, secureSessionsByTokenHash, apiError("workspace_terminal_not_found", "Terminal session was not found."), 404);
|
|
1244
|
+
const parsed = await parseRequestJson(c, options.pairing, secureSessionsByTokenHash, WorkspaceTerminalInputRequestSchema);
|
|
1245
|
+
if (!parsed.success) return secureJson(c, options.pairing, secureSessionsByTokenHash, validationError(parsed.error), 400);
|
|
1246
|
+
if (session.exitedAt) return secureJson(c, options.pairing, secureSessionsByTokenHash, apiError("workspace_terminal_closed", "Terminal session is closed."), 409);
|
|
1247
|
+
session.child.write(parsed.data.data);
|
|
1248
|
+
return new Response(null, { status: 204 });
|
|
1249
|
+
});
|
|
1250
|
+
app.post("/v1/workspace/terminal/sessions/:sessionId/resize", async (c) => {
|
|
1251
|
+
const session = workspaceTerminalSessions.get(c.req.param("sessionId"));
|
|
1252
|
+
if (!session) return secureJson(c, options.pairing, secureSessionsByTokenHash, apiError("workspace_terminal_not_found", "Terminal session was not found."), 404);
|
|
1253
|
+
const parsed = await parseRequestJson(c, options.pairing, secureSessionsByTokenHash, WorkspaceTerminalResizeRequestSchema);
|
|
1254
|
+
if (!parsed.success) return secureJson(c, options.pairing, secureSessionsByTokenHash, validationError(parsed.error), 400);
|
|
1255
|
+
session.cols = parsed.data.cols;
|
|
1256
|
+
session.rows = parsed.data.rows;
|
|
1257
|
+
if (!session.exitedAt) session.child.resize(parsed.data.cols, parsed.data.rows);
|
|
1258
|
+
return new Response(null, { status: 204 });
|
|
1259
|
+
});
|
|
1260
|
+
app.delete("/v1/workspace/terminal/sessions/:sessionId", async (c) => {
|
|
1261
|
+
const session = workspaceTerminalSessions.get(c.req.param("sessionId"));
|
|
1262
|
+
if (session) {
|
|
1263
|
+
closeWorkspaceTerminalSession(session);
|
|
1264
|
+
workspaceTerminalSessions.delete(session.sessionId);
|
|
1265
|
+
}
|
|
1266
|
+
return new Response(null, { status: 204 });
|
|
1267
|
+
});
|
|
1155
1268
|
app.get(apiPaths.models, async (c) => {
|
|
1156
1269
|
try {
|
|
1157
1270
|
const models = appServer ? await appServer.listModels() : fallbackModels();
|
|
@@ -3518,6 +3631,13 @@ function sendSse(controller, encoder, secureSession, event) {
|
|
|
3518
3631
|
threadId
|
|
3519
3632
|
});
|
|
3520
3633
|
}
|
|
3634
|
+
function sendTerminalOutputSse(controller, encoder, secureSession, response) {
|
|
3635
|
+
const parsed = WorkspaceTerminalOutputResponseSchema.parse(response);
|
|
3636
|
+
const data = secureSession ? EncryptedPayloadSchema.parse(encryptForMobile(secureSession.session, JSON.stringify(parsed))) : parsed;
|
|
3637
|
+
if (secureSession) secureSession.persist().catch(() => void 0);
|
|
3638
|
+
if (!enqueueSseChunk(controller, encoder.encode("event: output\n"))) return false;
|
|
3639
|
+
return enqueueSseChunk(controller, encoder.encode(`data: ${JSON.stringify(data)}\n\n`));
|
|
3640
|
+
}
|
|
3521
3641
|
function threadIdFromStreamEvent(event) {
|
|
3522
3642
|
if ("threadId" in event && typeof event.threadId === "string") return event.threadId;
|
|
3523
3643
|
if ("thread" in event && event.thread) return event.thread.id;
|
|
@@ -5213,6 +5333,74 @@ async function git(cwd, args) {
|
|
|
5213
5333
|
});
|
|
5214
5334
|
return stdout.trimEnd();
|
|
5215
5335
|
}
|
|
5336
|
+
function createWorkspaceTerminalSession(input) {
|
|
5337
|
+
const sessionId = randomUUID();
|
|
5338
|
+
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
5339
|
+
const shell = process.env.SHELL || "/bin/sh";
|
|
5340
|
+
const child = pty.spawn(shell, ["-l"], {
|
|
5341
|
+
cols: input.cols,
|
|
5342
|
+
cwd: input.cwd,
|
|
5343
|
+
env: {
|
|
5344
|
+
...process.env,
|
|
5345
|
+
COLORTERM: process.env.COLORTERM ?? "truecolor",
|
|
5346
|
+
TERM: process.env.TERM && process.env.TERM !== "dumb" ? process.env.TERM : "xterm-256color"
|
|
5347
|
+
},
|
|
5348
|
+
name: "xterm-256color",
|
|
5349
|
+
rows: input.rows
|
|
5350
|
+
});
|
|
5351
|
+
const session = {
|
|
5352
|
+
child,
|
|
5353
|
+
cols: input.cols,
|
|
5354
|
+
output: [],
|
|
5355
|
+
rows: input.rows,
|
|
5356
|
+
seq: 0,
|
|
5357
|
+
sessionId,
|
|
5358
|
+
startedAt,
|
|
5359
|
+
subscribers: /* @__PURE__ */ new Set(),
|
|
5360
|
+
workspacePath: input.cwd
|
|
5361
|
+
};
|
|
5362
|
+
const appendOutput = (data) => {
|
|
5363
|
+
const chunk = {
|
|
5364
|
+
data,
|
|
5365
|
+
seq: session.seq
|
|
5366
|
+
};
|
|
5367
|
+
session.output.push(chunk);
|
|
5368
|
+
session.seq += 1;
|
|
5369
|
+
if (session.output.length > maxWorkspaceTerminalOutputChunks) session.output.splice(0, session.output.length - maxWorkspaceTerminalOutputChunks);
|
|
5370
|
+
notifyWorkspaceTerminalOutput(session, {
|
|
5371
|
+
chunks: [chunk],
|
|
5372
|
+
nextSeq: session.seq
|
|
5373
|
+
});
|
|
5374
|
+
};
|
|
5375
|
+
child.onData(appendOutput);
|
|
5376
|
+
child.onExit(({ exitCode }) => {
|
|
5377
|
+
session.exitCode = exitCode;
|
|
5378
|
+
session.exitedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
5379
|
+
notifyWorkspaceTerminalOutput(session, workspaceTerminalOutputResponse(session, session.seq));
|
|
5380
|
+
});
|
|
5381
|
+
return session;
|
|
5382
|
+
}
|
|
5383
|
+
function closeWorkspaceTerminalSession(session) {
|
|
5384
|
+
if (session.exitedAt) return;
|
|
5385
|
+
session.child.kill();
|
|
5386
|
+
}
|
|
5387
|
+
function workspaceTerminalOutputResponse(session, since) {
|
|
5388
|
+
return WorkspaceTerminalOutputResponseSchema.parse({
|
|
5389
|
+
chunks: session.output.filter((chunk) => chunk.seq >= since),
|
|
5390
|
+
exitCode: session.exitCode,
|
|
5391
|
+
exitedAt: session.exitedAt,
|
|
5392
|
+
nextSeq: session.seq
|
|
5393
|
+
});
|
|
5394
|
+
}
|
|
5395
|
+
function subscribeWorkspaceTerminalOutput(session, subscriber) {
|
|
5396
|
+
session.subscribers.add(subscriber);
|
|
5397
|
+
return () => {
|
|
5398
|
+
session.subscribers.delete(subscriber);
|
|
5399
|
+
};
|
|
5400
|
+
}
|
|
5401
|
+
function notifyWorkspaceTerminalOutput(session, response) {
|
|
5402
|
+
for (const subscriber of session.subscribers) subscriber(response);
|
|
5403
|
+
}
|
|
5216
5404
|
async function listWorkspaceFiles(workspacePath, query, directory) {
|
|
5217
5405
|
const normalizedQuery = query.toLowerCase();
|
|
5218
5406
|
const isIgnored = await workspaceIgnoreMatcher(workspacePath);
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codex-relay",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Local Codex Relay CLI bridge for the Codex Relay mobile app.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
7
8
|
"url": "git+https://github.com/gronxb/codex-relay.git",
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
"dependencies": {
|
|
35
36
|
"@commander-js/extra-typings": "^14.0.0",
|
|
36
37
|
"@hono/node-server": "^1.19.6",
|
|
38
|
+
"@lydell/node-pty": "1.2.0-beta.12",
|
|
37
39
|
"@modelcontextprotocol/sdk": "^1.24.0",
|
|
38
40
|
"@noble/ciphers": "2.2.0",
|
|
39
41
|
"@noble/curves": "2.2.0",
|
package/src/api-schema.ts
CHANGED
|
@@ -352,7 +352,7 @@ export const WorkspaceGitActionResponseSchema = z.object({
|
|
|
352
352
|
output: z.string().default(""),
|
|
353
353
|
});
|
|
354
354
|
|
|
355
|
-
export const WORKSPACE_PREVIEW_TAB_VALUES = ["git", "files", "markdown", "web"] as const;
|
|
355
|
+
export const WORKSPACE_PREVIEW_TAB_VALUES = ["git", "files", "markdown", "web", "ssh"] as const;
|
|
356
356
|
|
|
357
357
|
export const WorkspacePreviewTabSchema = z.enum(WORKSPACE_PREVIEW_TAB_VALUES);
|
|
358
358
|
|
|
@@ -399,8 +399,51 @@ export const WorkspacePreviewNavigationRequestSchema = z.discriminatedUnion("tab
|
|
|
399
399
|
tab: z.literal("web"),
|
|
400
400
|
target: WebPreviewTargetSchema.optional(),
|
|
401
401
|
}),
|
|
402
|
+
WorkspacePreviewOpenBaseSchema.extend({
|
|
403
|
+
tab: z.literal("ssh"),
|
|
404
|
+
}),
|
|
402
405
|
]);
|
|
403
406
|
|
|
407
|
+
export const WorkspaceTerminalStartRequestSchema = WorkspaceSelectionRequestSchema.extend({
|
|
408
|
+
cols: z.number().int().min(2).max(300).default(80),
|
|
409
|
+
rows: z.number().int().min(2).max(120).default(24),
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
export const WorkspaceTerminalOutputChunkSchema = z.object({
|
|
413
|
+
data: z.string(),
|
|
414
|
+
seq: z.number().int().nonnegative(),
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
export const WorkspaceTerminalSessionResponseSchema = z.object({
|
|
418
|
+
cols: z.number().int().positive(),
|
|
419
|
+
rows: z.number().int().positive(),
|
|
420
|
+
sessionId: z.string().min(1),
|
|
421
|
+
startedAt: IsoDateTimeSchema,
|
|
422
|
+
workspacePath: z.string().min(1),
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
export const WorkspaceTerminalOutputResponseSchema = z.object({
|
|
426
|
+
chunks: z.array(WorkspaceTerminalOutputChunkSchema),
|
|
427
|
+
exitCode: z.number().int().nullable().optional(),
|
|
428
|
+
exitedAt: IsoDateTimeSchema.optional(),
|
|
429
|
+
nextSeq: z.number().int().nonnegative(),
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
export const WorkspaceTerminalInputRequestSchema = z
|
|
433
|
+
.union([
|
|
434
|
+
z.object({ data: z.string().min(1) }),
|
|
435
|
+
z.object({ input: z.string().min(1) }),
|
|
436
|
+
z.string().min(1),
|
|
437
|
+
])
|
|
438
|
+
.transform((payload) => ({
|
|
439
|
+
data: typeof payload === "string" ? payload : "data" in payload ? payload.data : payload.input,
|
|
440
|
+
}));
|
|
441
|
+
|
|
442
|
+
export const WorkspaceTerminalResizeRequestSchema = z.object({
|
|
443
|
+
cols: z.number().int().min(2).max(300),
|
|
444
|
+
rows: z.number().int().min(2).max(120),
|
|
445
|
+
});
|
|
446
|
+
|
|
404
447
|
export const PairRequestSchema = z.object({
|
|
405
448
|
clientSessionId: z.string().trim().min(1).max(120).optional(),
|
|
406
449
|
clientName: z.string().trim().min(1).max(80).optional(),
|
|
@@ -669,6 +712,13 @@ export type WorkspaceMarkdownPreviewTarget = z.infer<typeof WorkspaceMarkdownPre
|
|
|
669
712
|
export type WorkspacePreviewNavigationRequest = z.infer<
|
|
670
713
|
typeof WorkspacePreviewNavigationRequestSchema
|
|
671
714
|
>;
|
|
715
|
+
export type WorkspaceTerminalStartRequest = z.infer<typeof WorkspaceTerminalStartRequestSchema>;
|
|
716
|
+
export type WorkspaceTerminalSessionResponse = z.infer<
|
|
717
|
+
typeof WorkspaceTerminalSessionResponseSchema
|
|
718
|
+
>;
|
|
719
|
+
export type WorkspaceTerminalOutputResponse = z.infer<typeof WorkspaceTerminalOutputResponseSchema>;
|
|
720
|
+
export type WorkspaceTerminalInputRequest = z.infer<typeof WorkspaceTerminalInputRequestSchema>;
|
|
721
|
+
export type WorkspaceTerminalResizeRequest = z.infer<typeof WorkspaceTerminalResizeRequestSchema>;
|
|
672
722
|
export type WebPreviewTarget = z.infer<typeof WebPreviewTargetSchema>;
|
|
673
723
|
export type PairRequest = z.infer<typeof PairRequestSchema>;
|
|
674
724
|
export type PairResponse = z.infer<typeof PairResponseSchema>;
|
|
@@ -919,6 +969,17 @@ export const apiPaths = {
|
|
|
919
969
|
workspaceChanges: "/v1/workspace/changes",
|
|
920
970
|
workspaceCheckout: "/v1/workspace/checkout",
|
|
921
971
|
workspaceCommitPush: "/v1/workspace/commit-push",
|
|
972
|
+
workspaceTerminalSessions: "/v1/workspace/terminal/sessions",
|
|
973
|
+
workspaceTerminalSession: (sessionId: string) =>
|
|
974
|
+
`/v1/workspace/terminal/sessions/${encodeURIComponent(sessionId)}`,
|
|
975
|
+
workspaceTerminalInput: (sessionId: string) =>
|
|
976
|
+
`/v1/workspace/terminal/sessions/${encodeURIComponent(sessionId)}/input`,
|
|
977
|
+
workspaceTerminalOutput: (sessionId: string) =>
|
|
978
|
+
`/v1/workspace/terminal/sessions/${encodeURIComponent(sessionId)}/output`,
|
|
979
|
+
workspaceTerminalOutputStream: (sessionId: string) =>
|
|
980
|
+
`/v1/workspace/terminal/sessions/${encodeURIComponent(sessionId)}/output/stream`,
|
|
981
|
+
workspaceTerminalResize: (sessionId: string) =>
|
|
982
|
+
`/v1/workspace/terminal/sessions/${encodeURIComponent(sessionId)}/resize`,
|
|
922
983
|
imageAttachments: "/v1/attachments/images",
|
|
923
984
|
imageAttachment: (attachmentId: string) =>
|
|
924
985
|
`/v1/attachments/images/${encodeURIComponent(attachmentId)}`,
|