@codex-app-sdk/electron 0.0.0-stage → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://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
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,39 @@
1
- # Temporary Holding Version
1
+ # `@codex-app-sdk/electron`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Electron adapter for Codex applications. It binds one authorized backend
4
+ surface to typed main/preload/renderer IPC and provides native attachments,
5
+ clipboard, external links, image previews, and Apple speech transcription.
6
+
7
+ ```bash
8
+ npm install @codex-app-sdk/backend @codex-app-sdk/core \
9
+ @codex-app-sdk/electron
10
+ ```
11
+
12
+ ```ts
13
+ // Electron main
14
+ import { registerCodexElectronMain } from '@codex-app-sdk/electron';
15
+
16
+ const unregister = registerCodexElectronMain({
17
+ surface: backend.surface,
18
+ ipcMain,
19
+ sender: { send: (channel, payload) => window.webContents.send(channel, payload) },
20
+ clipboard,
21
+ dialog,
22
+ shell,
23
+ });
24
+ ```
25
+
26
+ ```ts
27
+ // Preload
28
+ import { exposeCodexElectronPreload } from '@codex-app-sdk/electron/preload';
29
+
30
+ exposeCodexElectronPreload(contextBridge, ipcRenderer);
31
+ ```
32
+
33
+ The complete registration owns one attachment registry, so renderer-safe
34
+ references become filesystem paths only immediately before the trusted backend
35
+ call. Keep context isolation and renderer sandboxing enabled.
36
+
37
+ See the [Electron integration
38
+ guide](https://codex-app-sdk.github.io/codex-app-sdk/guide/electron.html) and [Electron
39
+ API](https://codex-app-sdk.github.io/codex-app-sdk/api/electron.html).
@@ -0,0 +1,254 @@
1
+ import { invokeCodexSurfaceBridgeOperation as e, isCodexSurfaceStatePatchSource as t, subscribeCodexSurfaceState as n } from "@codex-app-sdk/core/surface-bridge";
2
+ //#region src/typed-ipc.ts
3
+ var r = class {
4
+ port;
5
+ constructor(e) {
6
+ this.port = e;
7
+ }
8
+ invoke(e, ...t) {
9
+ return this.port.invoke(e, ...t);
10
+ }
11
+ on(e, t) {
12
+ let n = (e, n) => t(n);
13
+ return this.port.on(e, n), () => this.port.off(e, n);
14
+ }
15
+ }, i = class {
16
+ port;
17
+ registeredChannels = /* @__PURE__ */ new Set();
18
+ constructor(e) {
19
+ this.port = e;
20
+ }
21
+ handle(e, t) {
22
+ this.port.handle(e, (e, ...n) => t(e, ...n)), this.registeredChannels.add(e);
23
+ }
24
+ removeHandler(e) {
25
+ this.port.removeHandler(e), this.registeredChannels.delete(e);
26
+ }
27
+ dispose() {
28
+ for (let e of this.registeredChannels) this.port.removeHandler(e);
29
+ this.registeredChannels.clear();
30
+ }
31
+ };
32
+ function a(e, t, n = {}) {
33
+ let r = new i(e), a = Object.keys(t), { isTrustedSender: o } = n;
34
+ for (let e of a) {
35
+ let n = t[e];
36
+ r.handle(e, o ? (t, ...r) => {
37
+ if (!o(t)) throw Error(`Rejected ${e} from an untrusted sender`);
38
+ return n(t, ...r);
39
+ } : n);
40
+ }
41
+ return () => r.dispose();
42
+ }
43
+ function o(e, t, n) {
44
+ e.send(t, n);
45
+ }
46
+ function s(e, t, n) {
47
+ let r = n.map((n) => e.on(n, (e) => t.emit(n, e)));
48
+ return () => {
49
+ for (let e of r) e();
50
+ };
51
+ }
52
+ //#endregion
53
+ //#region src/codex-surface-ipc.ts
54
+ var c = {
55
+ archiveConversation: "codex-surface:archive-conversation",
56
+ cancelLogin: "codex-surface:cancel-login",
57
+ clearGoal: "codex-surface:clear-goal",
58
+ compactConversation: "codex-surface:compact-conversation",
59
+ connect: "codex-surface:connect",
60
+ continueInterruptedTurn: "codex-surface:continue-interrupted-turn",
61
+ createConversation: "codex-surface:create-conversation",
62
+ deleteConversation: "codex-surface:delete-conversation",
63
+ deleteTurn: "codex-surface:delete-turn",
64
+ deleteQueuedPrompt: "codex-surface:delete-queued-prompt",
65
+ editTurn: "codex-surface:edit-turn",
66
+ forkTurn: "codex-surface:fork-turn",
67
+ getSnapshot: "codex-surface:get-snapshot",
68
+ getVersionedSnapshot: "codex-surface:get-versioned-snapshot",
69
+ interrupt: "codex-surface:interrupt",
70
+ listConversations: "codex-surface:list-conversations",
71
+ listModels: "codex-surface:list-models",
72
+ logout: "codex-surface:logout",
73
+ readConversationHistory: "codex-surface:read-conversation-history",
74
+ readConversationPromptHistory: "codex-surface:read-conversation-prompt-history",
75
+ loadOlderConversationHistory: "codex-surface:load-older-conversation-history",
76
+ refreshAccount: "codex-surface:refresh-account",
77
+ refreshConversations: "codex-surface:refresh-conversations",
78
+ renameConversation: "codex-surface:rename-conversation",
79
+ respondToClientRequest: "codex-surface:respond-to-client-request",
80
+ resolveApproval: "codex-surface:resolve-approval",
81
+ retryTurn: "codex-surface:retry-turn",
82
+ setGoal: "codex-surface:set-goal",
83
+ selectConversation: "codex-surface:select-conversation",
84
+ sendMessage: "codex-surface:send-message",
85
+ startReview: "codex-surface:start-review",
86
+ startLiveChat: "codex-surface:start-live-chat",
87
+ stopLiveChat: "codex-surface:stop-live-chat",
88
+ startChatGptDeviceCodeLogin: "codex-surface:start-chatgpt-device-code-login",
89
+ startChatGptLogin: "codex-surface:start-chatgpt-login",
90
+ steerMessage: "codex-surface:steer-message",
91
+ steerQueuedPrompt: "codex-surface:steer-queued-prompt",
92
+ unarchiveConversation: "codex-surface:unarchive-conversation",
93
+ updateConversationSettings: "codex-surface:update-conversation-settings",
94
+ updateQueuedPrompt: "codex-surface:update-queued-prompt",
95
+ stateChanged: "codex-surface:state-changed",
96
+ statePatch: "codex-surface:state-patch",
97
+ event: "codex-surface:event"
98
+ };
99
+ function l(n, r, i, o = {}) {
100
+ let s = t(i) ? i : null, l = !1, u = (t, n) => t === "loadOlderConversationHistory" && !i.loadOlderConversationHistory ? Promise.reject(/* @__PURE__ */ Error("Conversation history paging is not available.")) : (t === "startLiveChat" || t === "stopLiveChat") && !i[t] ? Promise.reject(/* @__PURE__ */ Error("Live chat is not available.")) : e(i, t, n, {
101
+ operationLabel: c[t],
102
+ ...o.resolveAttachment === void 0 ? {} : { resolveAttachment: o.resolveAttachment }
103
+ }), d = a(n, {
104
+ [c.archiveConversation]: (e, ...t) => u("archiveConversation", t),
105
+ [c.cancelLogin]: (e, ...t) => u("cancelLogin", t),
106
+ [c.clearGoal]: (e, ...t) => u("clearGoal", t),
107
+ [c.compactConversation]: (e, ...t) => u("compactConversation", t),
108
+ [c.connect]: (e, ...t) => u("connect", t),
109
+ [c.continueInterruptedTurn]: (e, ...t) => u("continueInterruptedTurn", t),
110
+ [c.createConversation]: (e, ...t) => u("createConversation", t),
111
+ [c.deleteConversation]: (e, ...t) => u("deleteConversation", t),
112
+ [c.deleteTurn]: (e, ...t) => u("deleteTurn", t),
113
+ [c.deleteQueuedPrompt]: (e, ...t) => u("deleteQueuedPrompt", t),
114
+ [c.editTurn]: (e, ...t) => u("editTurn", t),
115
+ [c.forkTurn]: (e, ...t) => u("forkTurn", t),
116
+ [c.getSnapshot]: (e, ...t) => u("getSnapshot", t),
117
+ [c.getVersionedSnapshot]: async () => s ? (l = !0, s.getVersionedSnapshot()) : null,
118
+ [c.interrupt]: (e, ...t) => u("interrupt", t),
119
+ [c.listConversations]: (e, ...t) => u("listConversations", t),
120
+ [c.listModels]: (e, ...t) => u("listModels", t),
121
+ [c.logout]: (e, ...t) => u("logout", t),
122
+ [c.readConversationHistory]: (e, ...t) => u("readConversationHistory", t),
123
+ [c.readConversationPromptHistory]: (e, ...t) => u("readConversationPromptHistory", t),
124
+ [c.loadOlderConversationHistory]: (e, ...t) => u("loadOlderConversationHistory", t),
125
+ [c.refreshAccount]: (e, ...t) => u("refreshAccount", t),
126
+ [c.refreshConversations]: (e, ...t) => u("refreshConversations", t),
127
+ [c.renameConversation]: (e, ...t) => u("renameConversation", t),
128
+ [c.respondToClientRequest]: (e, ...t) => u("respondToClientRequest", t),
129
+ [c.resolveApproval]: (e, ...t) => u("resolveApproval", t),
130
+ [c.retryTurn]: (e, ...t) => u("retryTurn", t),
131
+ [c.setGoal]: (e, ...t) => u("setGoal", t),
132
+ [c.selectConversation]: (e, ...t) => u("selectConversation", t),
133
+ [c.sendMessage]: (e, ...t) => u("sendMessage", t),
134
+ [c.startReview]: (e, ...t) => u("startReview", t),
135
+ [c.startLiveChat]: (e, ...t) => u("startLiveChat", t),
136
+ [c.stopLiveChat]: (e, ...t) => u("stopLiveChat", t),
137
+ [c.startChatGptDeviceCodeLogin]: (e, ...t) => u("startChatGptDeviceCodeLogin", t),
138
+ [c.startChatGptLogin]: (e, ...t) => u("startChatGptLogin", t),
139
+ [c.steerMessage]: (e, ...t) => u("steerMessage", t),
140
+ [c.steerQueuedPrompt]: (e, ...t) => u("steerQueuedPrompt", t),
141
+ [c.unarchiveConversation]: (e, ...t) => u("unarchiveConversation", t),
142
+ [c.updateConversationSettings]: (e, ...t) => u("updateConversationSettings", t),
143
+ [c.updateQueuedPrompt]: (e, ...t) => u("updateQueuedPrompt", t)
144
+ }, o), f = i.onStateChange((e) => {
145
+ l || r.send(c.stateChanged, e);
146
+ }), p = s?.onStatePatch((e) => {
147
+ l && r.send(c.statePatch, e);
148
+ }), m = () => {
149
+ p?.(), f();
150
+ }, h = i.onEvent((e) => r.send(c.event, e));
151
+ return () => {
152
+ h(), m(), d();
153
+ };
154
+ }
155
+ function u(e) {
156
+ let t = new r(e), i = () => t.invoke(c.getVersionedSnapshot), a = (e) => t.on(c.statePatch, e), o = {
157
+ getVersionedSnapshot: i,
158
+ onStatePatch: a
159
+ };
160
+ return {
161
+ getVersionedSnapshot: i,
162
+ onStatePatch: a,
163
+ archiveConversation: (e) => t.invoke(c.archiveConversation, e),
164
+ cancelLogin: (e) => t.invoke(c.cancelLogin, e),
165
+ clearGoal: () => t.invoke(c.clearGoal),
166
+ compactConversation: () => t.invoke(c.compactConversation),
167
+ connect: () => t.invoke(c.connect),
168
+ continueInterruptedTurn: () => t.invoke(c.continueInterruptedTurn),
169
+ createConversation: (e) => t.invoke(c.createConversation, e),
170
+ deleteConversation: (e) => t.invoke(c.deleteConversation, e),
171
+ deleteTurn: (e) => t.invoke(c.deleteTurn, e),
172
+ deleteQueuedPrompt: (e) => t.invoke(c.deleteQueuedPrompt, e),
173
+ editTurn: (e, n) => t.invoke(c.editTurn, e, n),
174
+ forkTurn: (e) => t.invoke(c.forkTurn, e),
175
+ getSnapshot: () => t.invoke(c.getSnapshot),
176
+ interrupt: () => t.invoke(c.interrupt),
177
+ listConversations: (e) => t.invoke(c.listConversations, e),
178
+ listModels: (e) => t.invoke(c.listModels, e),
179
+ logout: () => t.invoke(c.logout),
180
+ onEvent: (e) => t.on(c.event, e),
181
+ onStateChange: (e) => {
182
+ let r = t.on(c.stateChanged, e), i = n(o, e, { emitInitialSnapshot: !1 });
183
+ return () => {
184
+ i(), r();
185
+ };
186
+ },
187
+ readConversationHistory: (e) => t.invoke(c.readConversationHistory, e),
188
+ readConversationPromptHistory: (e) => t.invoke(c.readConversationPromptHistory, e),
189
+ loadOlderConversationHistory: (e) => t.invoke(c.loadOlderConversationHistory, e),
190
+ refreshAccount: () => t.invoke(c.refreshAccount),
191
+ refreshConversations: () => t.invoke(c.refreshConversations),
192
+ renameConversation: (e) => t.invoke(c.renameConversation, e),
193
+ respondToClientRequest: (e) => t.invoke(c.respondToClientRequest, e),
194
+ resolveApproval: (e, n, r) => t.invoke(c.resolveApproval, e, n, r),
195
+ retryTurn: (e) => t.invoke(c.retryTurn, e),
196
+ setGoal: (e, n) => t.invoke(c.setGoal, e, n),
197
+ selectConversation: (e) => t.invoke(c.selectConversation, e),
198
+ sendMessage: (e, n) => t.invoke(c.sendMessage, e, n),
199
+ startReview: (e) => t.invoke(c.startReview, e),
200
+ startLiveChat: (e, n) => t.invoke(c.startLiveChat, e, n),
201
+ stopLiveChat: (e) => t.invoke(c.stopLiveChat, e),
202
+ startChatGptDeviceCodeLogin: () => t.invoke(c.startChatGptDeviceCodeLogin),
203
+ startChatGptLogin: () => t.invoke(c.startChatGptLogin),
204
+ steerMessage: (e, n) => t.invoke(c.steerMessage, e, n),
205
+ steerQueuedPrompt: (e, n) => t.invoke(c.steerQueuedPrompt, e, n),
206
+ unarchiveConversation: (e) => t.invoke(c.unarchiveConversation, e),
207
+ updateConversationSettings: (e) => t.invoke(c.updateConversationSettings, e),
208
+ updateQueuedPrompt: (e, n) => t.invoke(c.updateQueuedPrompt, e, n)
209
+ };
210
+ }
211
+ //#endregion
212
+ //#region src/codex-native-renderer.ts
213
+ var d = {
214
+ copyToClipboard: "codex-native:copy-to-clipboard",
215
+ ingestAttachments: "codex-native:ingest-attachments",
216
+ openExternal: "codex-native:open-external",
217
+ pickAttachments: "codex-native:pick-attachments",
218
+ readImagePreview: "codex-native:read-image-preview",
219
+ transcribeAudio: "codex-native:transcribe-audio"
220
+ };
221
+ function f(e, t = {}) {
222
+ let n = new r(e);
223
+ return {
224
+ capabilities: {
225
+ attachments: !0,
226
+ clipboard: !0,
227
+ externalLinks: !0,
228
+ transcription: t.transcription ?? process.platform === "darwin"
229
+ },
230
+ copyToClipboard: (e) => n.invoke(d.copyToClipboard, e),
231
+ ingestAttachments: (e) => n.invoke(d.ingestAttachments, e),
232
+ openExternal: (e) => n.invoke(d.openExternal, e),
233
+ pickAttachments: () => n.invoke(d.pickAttachments),
234
+ readImagePreview: (e) => n.invoke(d.readImagePreview, e),
235
+ transcribeAudio: (e, t) => n.invoke(d.transcribeAudio, e, t)
236
+ };
237
+ }
238
+ function p(e, t, n) {
239
+ let r = f(t, n);
240
+ return e.exposeInMainWorld("codexAppSdkNative", r), r;
241
+ }
242
+ //#endregion
243
+ //#region src/codex-electron-preload.ts
244
+ function m(e, t, n) {
245
+ let r = u(t), i = f(t, n);
246
+ return e.exposeInMainWorld("codexSurface", r), e.exposeInMainWorld("codexAppSdkNative", i), {
247
+ native: i,
248
+ surface: r
249
+ };
250
+ }
251
+ //#endregion
252
+ export { u as a, r as c, o as d, p as i, s as l, d as n, l as o, f as r, i as s, m as t, a as u };
253
+
254
+ //# sourceMappingURL=codex-electron-preload-z_8XhSEC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-electron-preload-z_8XhSEC.js","names":[],"sources":["../../src/typed-ipc.ts","../../src/codex-surface-ipc.ts","../../src/codex-native-renderer.ts","../../src/codex-electron-preload.ts"],"sourcesContent":["import type { TypedEventBus } from '@codex-app-sdk/core/events';\n\nexport type IpcRequest<Arguments extends unknown[] = unknown[], Result = unknown> = {\n args: Arguments;\n result: Result;\n};\n\nexport type IpcRequestArguments<Request> = Request extends IpcRequest<infer Arguments, unknown>\n ? Arguments\n : never;\n\nexport type IpcRequestResult<Request> = Request extends IpcRequest<unknown[], infer Result>\n ? Result\n : never;\n\nexport type IpcRendererPort = {\n invoke(channel: string, ...args: unknown[]): Promise<unknown>;\n on(channel: string, listener: (event: unknown, payload: unknown) => void): void;\n off(channel: string, listener: (event: unknown, payload: unknown) => void): void;\n};\n\nexport type IpcMainPort = {\n handle(channel: string, handler: (event: unknown, ...args: unknown[]) => unknown): void;\n removeHandler(channel: string): void;\n};\n\nexport type IpcEventSender = {\n send(channel: string, payload: unknown): void;\n};\n\ntype RequestName<Requests> = keyof Requests & string;\ntype EventName<Events> = keyof Events & string;\n\nexport class TypedIpcRenderer<Requests extends object, Events extends object> {\n constructor(private readonly port: IpcRendererPort) {}\n\n invoke<Name extends RequestName<Requests>>(\n channel: Name,\n ...args: IpcRequestArguments<Requests[Name]>\n ): Promise<IpcRequestResult<Requests[Name]>> {\n return this.port.invoke(channel, ...args) as Promise<IpcRequestResult<Requests[Name]>>;\n }\n\n on<Name extends EventName<Events>>(channel: Name, listener: (payload: Events[Name]) => void): () => void {\n const handler = (_event: unknown, payload: unknown) => listener(payload as Events[Name]);\n this.port.on(channel, handler);\n return () => this.port.off(channel, handler);\n }\n}\n\nexport type IpcMainHandlers<Requests extends object> = {\n [Name in keyof Requests]: (\n event: unknown,\n ...args: IpcRequestArguments<Requests[Name]>\n ) => IpcRequestResult<Requests[Name]> | Promise<IpcRequestResult<Requests[Name]>>;\n};\n\nexport class TypedIpcMain<Requests extends object> {\n private readonly registeredChannels = new Set<RequestName<Requests>>();\n\n constructor(private readonly port: IpcMainPort) {}\n\n handle<Name extends RequestName<Requests>>(\n channel: Name,\n handler: IpcMainHandlers<Pick<Requests, Name>>[Name],\n ): void {\n this.port.handle(channel, (event, ...args) => handler(\n event,\n ...args as IpcRequestArguments<Requests[Name]>,\n ));\n this.registeredChannels.add(channel);\n }\n\n removeHandler<Name extends RequestName<Requests>>(channel: Name): void {\n this.port.removeHandler(channel);\n this.registeredChannels.delete(channel);\n }\n\n dispose(): void {\n for (const channel of this.registeredChannels) {\n this.port.removeHandler(channel);\n }\n this.registeredChannels.clear();\n }\n}\n\nexport type IpcSenderPolicy = {\n /** Rejects an invocation before its handler runs when this returns false. */\n isTrustedSender?: (event: unknown) => boolean;\n};\n\nexport function registerIpcMainHandlers<Requests extends object>(\n port: IpcMainPort,\n handlers: IpcMainHandlers<Requests>,\n policy: IpcSenderPolicy = {},\n): () => void {\n const main = new TypedIpcMain<Requests>(port);\n const channels = Object.keys(handlers) as Array<RequestName<Requests>>;\n const { isTrustedSender } = policy;\n for (const channel of channels) {\n const handler = handlers[channel];\n main.handle(channel, isTrustedSender\n ? (event, ...args) => {\n if (!isTrustedSender(event)) throw new Error(`Rejected ${channel} from an untrusted sender`);\n return handler(event, ...args);\n }\n : handler);\n }\n return () => main.dispose();\n}\n\nexport function sendIpcEvent<Events extends object, Name extends EventName<Events>>(\n sender: IpcEventSender,\n channel: Name,\n payload: Events[Name],\n): void {\n sender.send(channel, payload);\n}\n\nexport function connectIpcEventsToBus<Events extends object>(\n renderer: Pick<TypedIpcRenderer<object, Events>, 'on'>,\n bus: TypedEventBus<Events>,\n channels: ReadonlyArray<EventName<Events>>,\n): () => void {\n const unsubscribers = channels.map((channel) => renderer.on(channel, (payload) => bus.emit(channel, payload)));\n return () => {\n for (const unsubscribe of unsubscribers) {\n unsubscribe();\n }\n };\n}\n","import {\n invokeCodexSurfaceBridgeOperation,\n type CodexSurfaceBridgeOperation,\n type CodexSurfaceBridgeTarget,\n} from '@codex-app-sdk/core/surface-bridge';\nimport type {\n CodexConversationHistory,\n CodexConversationPromptHistory,\n CodexConversationSummary,\n CodexSurfaceApprovalDecision,\n CodexSurfaceApprovalScope,\n CodexSurfaceChatGptDeviceCodeLogin,\n CodexSurfaceChatGptLogin,\n CodexSurfaceClientRequestResponse,\n CodexSurfaceEvent,\n CodexSurfaceModel,\n CodexSurfaceRendererApi,\n CodexSurfaceSnapshot,\n CreateCodexRendererConversationOptions,\n ListCodexConversationsOptions,\n ListCodexModelsOptions,\n CodexRendererSendMessageOptions,\n StartCodexReviewOptions,\n StartCodexLiveChatOptions,\n UpdateCodexConversationSettings,\n CodexSurfaceStatePatch,\n CodexVersionedSurfaceSnapshot,\n} from '@codex-app-sdk/core/surface';\nimport {\n isCodexSurfaceStatePatchSource,\n subscribeCodexSurfaceState,\n type CodexSurfaceStatePatchSource,\n} from '@codex-app-sdk/core/surface-bridge';\nimport {\n registerIpcMainHandlers,\n TypedIpcRenderer,\n type IpcEventSender,\n type IpcMainPort,\n type IpcRendererPort,\n type IpcRequest,\n type IpcSenderPolicy,\n} from './typed-ipc';\n\nexport type CodexSurfaceIpcOptions = IpcSenderPolicy & {\n resolveAttachment?: import('@codex-app-sdk/core/surface-bridge').CodexSurfaceBridgeAttachmentResolver;\n};\n\nconst channels = {\n archiveConversation: 'codex-surface:archive-conversation',\n cancelLogin: 'codex-surface:cancel-login',\n clearGoal: 'codex-surface:clear-goal',\n compactConversation: 'codex-surface:compact-conversation',\n connect: 'codex-surface:connect',\n continueInterruptedTurn: 'codex-surface:continue-interrupted-turn',\n createConversation: 'codex-surface:create-conversation',\n deleteConversation: 'codex-surface:delete-conversation',\n deleteTurn: 'codex-surface:delete-turn',\n deleteQueuedPrompt: 'codex-surface:delete-queued-prompt',\n editTurn: 'codex-surface:edit-turn',\n forkTurn: 'codex-surface:fork-turn',\n getSnapshot: 'codex-surface:get-snapshot',\n getVersionedSnapshot: 'codex-surface:get-versioned-snapshot',\n interrupt: 'codex-surface:interrupt',\n listConversations: 'codex-surface:list-conversations',\n listModels: 'codex-surface:list-models',\n logout: 'codex-surface:logout',\n readConversationHistory: 'codex-surface:read-conversation-history',\n readConversationPromptHistory: 'codex-surface:read-conversation-prompt-history',\n loadOlderConversationHistory: 'codex-surface:load-older-conversation-history',\n refreshAccount: 'codex-surface:refresh-account',\n refreshConversations: 'codex-surface:refresh-conversations',\n renameConversation: 'codex-surface:rename-conversation',\n respondToClientRequest: 'codex-surface:respond-to-client-request',\n resolveApproval: 'codex-surface:resolve-approval',\n retryTurn: 'codex-surface:retry-turn',\n setGoal: 'codex-surface:set-goal',\n selectConversation: 'codex-surface:select-conversation',\n sendMessage: 'codex-surface:send-message',\n startReview: 'codex-surface:start-review',\n startLiveChat: 'codex-surface:start-live-chat',\n stopLiveChat: 'codex-surface:stop-live-chat',\n startChatGptDeviceCodeLogin: 'codex-surface:start-chatgpt-device-code-login',\n startChatGptLogin: 'codex-surface:start-chatgpt-login',\n steerMessage: 'codex-surface:steer-message',\n steerQueuedPrompt: 'codex-surface:steer-queued-prompt',\n unarchiveConversation: 'codex-surface:unarchive-conversation',\n updateConversationSettings: 'codex-surface:update-conversation-settings',\n updateQueuedPrompt: 'codex-surface:update-queued-prompt',\n stateChanged: 'codex-surface:state-changed',\n statePatch: 'codex-surface:state-patch',\n event: 'codex-surface:event',\n} as const;\n\ntype SurfaceRequests = {\n [channels.archiveConversation]: IpcRequest<[conversationId: string], CodexSurfaceSnapshot>;\n [channels.cancelLogin]: IpcRequest<[loginId?: string], CodexSurfaceSnapshot>;\n [channels.clearGoal]: IpcRequest<[], CodexSurfaceSnapshot>;\n [channels.compactConversation]: IpcRequest<[], CodexSurfaceSnapshot>;\n [channels.connect]: IpcRequest<[], CodexSurfaceSnapshot>;\n [channels.continueInterruptedTurn]: IpcRequest<[], CodexSurfaceSnapshot>;\n [channels.createConversation]: IpcRequest<[options?: CreateCodexRendererConversationOptions], CodexSurfaceSnapshot>;\n [channels.deleteConversation]: IpcRequest<[conversationId: string], CodexSurfaceSnapshot>;\n [channels.deleteTurn]: IpcRequest<[turnId: string], CodexSurfaceSnapshot>;\n [channels.deleteQueuedPrompt]: IpcRequest<[promptId: string], CodexSurfaceSnapshot>;\n [channels.editTurn]: IpcRequest<[turnId: string, content: string], CodexSurfaceSnapshot>;\n [channels.forkTurn]: IpcRequest<[turnId: string], CodexSurfaceSnapshot>;\n [channels.getSnapshot]: IpcRequest<[], CodexSurfaceSnapshot>;\n [channels.getVersionedSnapshot]: IpcRequest<[], CodexVersionedSurfaceSnapshot | null>;\n [channels.interrupt]: IpcRequest<[], CodexSurfaceSnapshot>;\n [channels.listConversations]: IpcRequest<[\n options?: ListCodexConversationsOptions,\n ], CodexConversationSummary[]>;\n [channels.listModels]: IpcRequest<[options?: ListCodexModelsOptions], CodexSurfaceModel[]>;\n [channels.logout]: IpcRequest<[], CodexSurfaceSnapshot>;\n [channels.readConversationHistory]: IpcRequest<[conversationId?: string], CodexConversationHistory>;\n [channels.readConversationPromptHistory]: IpcRequest<[\n conversationId?: string,\n ], CodexConversationPromptHistory>;\n [channels.loadOlderConversationHistory]: IpcRequest<[conversationId?: string], import('@codex-app-sdk/core/surface').CodexConversationHistoryPage>;\n [channels.refreshAccount]: IpcRequest<[], CodexSurfaceSnapshot>;\n [channels.refreshConversations]: IpcRequest<[], CodexSurfaceSnapshot>;\n [channels.renameConversation]: IpcRequest<[title: string], CodexSurfaceSnapshot>;\n [channels.respondToClientRequest]: IpcRequest<[response: CodexSurfaceClientRequestResponse], CodexSurfaceSnapshot>;\n [channels.resolveApproval]: IpcRequest<[\n approvalId: string,\n decision: CodexSurfaceApprovalDecision,\n scope?: CodexSurfaceApprovalScope,\n ], CodexSurfaceSnapshot>;\n [channels.retryTurn]: IpcRequest<[turnId: string], CodexSurfaceSnapshot>;\n [channels.setGoal]: IpcRequest<[objective: string, tokenBudget?: number | null], CodexSurfaceSnapshot>;\n [channels.selectConversation]: IpcRequest<[conversationId: string], CodexSurfaceSnapshot>;\n [channels.sendMessage]: IpcRequest<[prompt: string, options?: CodexRendererSendMessageOptions], CodexSurfaceSnapshot>;\n [channels.startReview]: IpcRequest<[options?: StartCodexReviewOptions], CodexSurfaceSnapshot>;\n [channels.startLiveChat]: IpcRequest<[conversationId: string, options: StartCodexLiveChatOptions], { sdp: string }>;\n [channels.stopLiveChat]: IpcRequest<[conversationId: string], void>;\n [channels.startChatGptDeviceCodeLogin]: IpcRequest<[], CodexSurfaceChatGptDeviceCodeLogin>;\n [channels.startChatGptLogin]: IpcRequest<[], CodexSurfaceChatGptLogin>;\n [channels.steerMessage]: IpcRequest<[\n prompt: string,\n options?: CodexRendererSendMessageOptions,\n ], CodexSurfaceSnapshot>;\n [channels.steerQueuedPrompt]: IpcRequest<[promptId: string, prompt?: string], CodexSurfaceSnapshot>;\n [channels.unarchiveConversation]: IpcRequest<[conversationId: string], CodexSurfaceSnapshot>;\n [channels.updateConversationSettings]: IpcRequest<[settings: UpdateCodexConversationSettings], CodexSurfaceSnapshot>;\n [channels.updateQueuedPrompt]: IpcRequest<[promptId: string, prompt: string], CodexSurfaceSnapshot>;\n};\n\ntype SurfaceEvents = {\n [channels.stateChanged]: CodexSurfaceSnapshot;\n [channels.statePatch]: CodexSurfaceStatePatch;\n [channels.event]: CodexSurfaceEvent;\n};\n\nexport type { CodexSurfaceRendererApi } from '@codex-app-sdk/core/surface';\n\ntype OptionalSurfaceOperation = 'loadOlderConversationHistory' | 'startLiveChat' | 'stopLiveChat';\n\nexport function registerCodexSurfaceIpc(\n port: IpcMainPort,\n sender: IpcEventSender,\n surface: Omit<CodexSurfaceBridgeTarget, OptionalSurfaceOperation>\n & Partial<Pick<CodexSurfaceBridgeTarget, OptionalSurfaceOperation>>\n & Partial<CodexSurfaceStatePatchSource>,\n options: CodexSurfaceIpcOptions = {},\n): () => void {\n // State crosses IPC as full snapshots until a renderer asks for a versioned\n // base; from then on it streams small patches. Older renderers never ask, and\n // surfaces without native patch support decline, so both keep snapshots.\n const patchSource = isCodexSurfaceStatePatchSource(surface) ? surface : null;\n let streamingPatches = false;\n const invoke = <Name extends CodexSurfaceBridgeOperation>(name: Name, args: readonly unknown[]) => {\n if (name === 'loadOlderConversationHistory' && !surface.loadOlderConversationHistory) {\n return Promise.reject(new Error('Conversation history paging is not available.'));\n }\n if ((name === 'startLiveChat' || name === 'stopLiveChat') && !surface[name]) {\n return Promise.reject(new Error('Live chat is not available.'));\n }\n return invokeCodexSurfaceBridgeOperation(\n surface as CodexSurfaceBridgeTarget,\n name,\n args,\n {\n operationLabel: channels[name],\n ...(options.resolveAttachment === undefined\n ? {}\n : { resolveAttachment: options.resolveAttachment }),\n },\n );\n };\n const unregisterHandlers = registerIpcMainHandlers<SurfaceRequests>(port, {\n [channels.archiveConversation]: (_event, ...args) => invoke('archiveConversation', args),\n [channels.cancelLogin]: (_event, ...args) => invoke('cancelLogin', args),\n [channels.clearGoal]: (_event, ...args) => invoke('clearGoal', args),\n [channels.compactConversation]: (_event, ...args) => invoke('compactConversation', args),\n [channels.connect]: (_event, ...args) => invoke('connect', args),\n [channels.continueInterruptedTurn]: (_event, ...args) => invoke('continueInterruptedTurn', args),\n [channels.createConversation]: (_event, ...args) => invoke('createConversation', args),\n [channels.deleteConversation]: (_event, ...args) => invoke('deleteConversation', args),\n [channels.deleteTurn]: (_event, ...args) => invoke('deleteTurn', args),\n [channels.deleteQueuedPrompt]: (_event, ...args) => invoke('deleteQueuedPrompt', args),\n [channels.editTurn]: (_event, ...args) => invoke('editTurn', args),\n [channels.forkTurn]: (_event, ...args) => invoke('forkTurn', args),\n [channels.getSnapshot]: (_event, ...args) => invoke('getSnapshot', args),\n [channels.getVersionedSnapshot]: async () => {\n if (!patchSource) return null;\n streamingPatches = true;\n return patchSource.getVersionedSnapshot();\n },\n [channels.interrupt]: (_event, ...args) => invoke('interrupt', args),\n [channels.listConversations]: (_event, ...args) => invoke('listConversations', args),\n [channels.listModels]: (_event, ...args) => invoke('listModels', args),\n [channels.logout]: (_event, ...args) => invoke('logout', args),\n [channels.readConversationHistory]: (_event, ...args) => invoke('readConversationHistory', args),\n [channels.readConversationPromptHistory]: (_event, ...args) => invoke('readConversationPromptHistory', args),\n [channels.loadOlderConversationHistory]: (_event, ...args) => invoke('loadOlderConversationHistory', args),\n [channels.refreshAccount]: (_event, ...args) => invoke('refreshAccount', args),\n [channels.refreshConversations]: (_event, ...args) => invoke('refreshConversations', args),\n [channels.renameConversation]: (_event, ...args) => invoke('renameConversation', args),\n [channels.respondToClientRequest]: (_event, ...args) => invoke('respondToClientRequest', args),\n [channels.resolveApproval]: (_event, ...args) => invoke('resolveApproval', args),\n [channels.retryTurn]: (_event, ...args) => invoke('retryTurn', args),\n [channels.setGoal]: (_event, ...args) => invoke('setGoal', args),\n [channels.selectConversation]: (_event, ...args) => invoke('selectConversation', args),\n [channels.sendMessage]: (_event, ...args) => invoke('sendMessage', args),\n [channels.startReview]: (_event, ...args) => invoke('startReview', args),\n [channels.startLiveChat]: (_event, ...args) => invoke('startLiveChat', args),\n [channels.stopLiveChat]: (_event, ...args) => invoke('stopLiveChat', args),\n [channels.startChatGptDeviceCodeLogin]: (_event, ...args) => invoke('startChatGptDeviceCodeLogin', args),\n [channels.startChatGptLogin]: (_event, ...args) => invoke('startChatGptLogin', args),\n [channels.steerMessage]: (_event, ...args) => invoke('steerMessage', args),\n [channels.steerQueuedPrompt]: (_event, ...args) => invoke('steerQueuedPrompt', args),\n [channels.unarchiveConversation]: (_event, ...args) => invoke('unarchiveConversation', args),\n [channels.updateConversationSettings]: (_event, ...args) => invoke('updateConversationSettings', args),\n [channels.updateQueuedPrompt]: (_event, ...args) => invoke('updateQueuedPrompt', args),\n }, options);\n const unsubscribeSnapshots = surface.onStateChange((snapshot) => {\n if (!streamingPatches) sender.send(channels.stateChanged, snapshot);\n });\n const unsubscribePatches = patchSource?.onStatePatch((patch) => {\n if (streamingPatches) sender.send(channels.statePatch, patch);\n });\n const unsubscribeState = () => {\n unsubscribePatches?.();\n unsubscribeSnapshots();\n };\n const unsubscribeEvents = surface.onEvent((event) => sender.send(channels.event, event));\n return () => {\n unsubscribeEvents();\n unsubscribeState();\n unregisterHandlers();\n };\n}\n\nexport function createCodexSurfaceRendererApi(port: IpcRendererPort): CodexSurfaceRendererApi {\n const renderer = new TypedIpcRenderer<SurfaceRequests, SurfaceEvents>(port);\n const getVersionedSnapshot = () => renderer.invoke(channels.getVersionedSnapshot);\n const onStatePatch = (listener: (patch: CodexSurfaceStatePatch) => void) => renderer.on(channels.statePatch, listener);\n const stateSource = { getVersionedSnapshot, onStatePatch };\n return {\n // Mirror patches in the renderer's own world: contextBridge copies every\n // value it passes, so a mirror kept in the preload would lose identity.\n getVersionedSnapshot,\n onStatePatch,\n archiveConversation: (conversationId) => renderer.invoke(channels.archiveConversation, conversationId),\n cancelLogin: (loginId) => renderer.invoke(channels.cancelLogin, loginId),\n clearGoal: () => renderer.invoke(channels.clearGoal),\n compactConversation: () => renderer.invoke(channels.compactConversation),\n connect: () => renderer.invoke(channels.connect),\n continueInterruptedTurn: () => renderer.invoke(channels.continueInterruptedTurn),\n createConversation: (options) => renderer.invoke(channels.createConversation, options),\n deleteConversation: (conversationId) => renderer.invoke(channels.deleteConversation, conversationId),\n deleteTurn: (turnId) => renderer.invoke(channels.deleteTurn, turnId),\n deleteQueuedPrompt: (promptId) => renderer.invoke(channels.deleteQueuedPrompt, promptId),\n editTurn: (turnId, content) => renderer.invoke(channels.editTurn, turnId, content),\n forkTurn: (turnId) => renderer.invoke(channels.forkTurn, turnId),\n getSnapshot: () => renderer.invoke(channels.getSnapshot),\n interrupt: () => renderer.invoke(channels.interrupt),\n listConversations: (options) => renderer.invoke(channels.listConversations, options),\n listModels: (options) => renderer.invoke(channels.listModels, options),\n logout: () => renderer.invoke(channels.logout),\n onEvent: (listener) => renderer.on(channels.event, listener),\n onStateChange: (listener) => {\n // Snapshots arrive until the main process switches to patches; the\n // switch point's base was already delivered as a snapshot, so it stays silent.\n const unsubscribeSnapshots = renderer.on(channels.stateChanged, listener);\n const unsubscribePatches = subscribeCodexSurfaceState(stateSource, listener, { emitInitialSnapshot: false });\n return () => {\n unsubscribePatches();\n unsubscribeSnapshots();\n };\n },\n readConversationHistory: (conversationId) => renderer.invoke(channels.readConversationHistory, conversationId),\n readConversationPromptHistory: (conversationId) => (\n renderer.invoke(channels.readConversationPromptHistory, conversationId)\n ),\n loadOlderConversationHistory: (conversationId) => renderer.invoke(channels.loadOlderConversationHistory, conversationId),\n refreshAccount: () => renderer.invoke(channels.refreshAccount),\n refreshConversations: () => renderer.invoke(channels.refreshConversations),\n renameConversation: (title) => renderer.invoke(channels.renameConversation, title),\n respondToClientRequest: (response) => renderer.invoke(channels.respondToClientRequest, response),\n resolveApproval: (approvalId, decision, scope) => renderer.invoke(channels.resolveApproval, approvalId, decision, scope),\n retryTurn: (turnId) => renderer.invoke(channels.retryTurn, turnId),\n setGoal: (objective, tokenBudget) => renderer.invoke(channels.setGoal, objective, tokenBudget),\n selectConversation: (conversationId) => renderer.invoke(channels.selectConversation, conversationId),\n sendMessage: (prompt, options) => renderer.invoke(channels.sendMessage, prompt, options),\n startReview: (options) => renderer.invoke(channels.startReview, options),\n startLiveChat: (conversationId, options) => renderer.invoke(channels.startLiveChat, conversationId, options),\n stopLiveChat: (conversationId) => renderer.invoke(channels.stopLiveChat, conversationId),\n startChatGptDeviceCodeLogin: () => renderer.invoke(channels.startChatGptDeviceCodeLogin),\n startChatGptLogin: () => renderer.invoke(channels.startChatGptLogin),\n steerMessage: (prompt, options) => renderer.invoke(channels.steerMessage, prompt, options),\n steerQueuedPrompt: (promptId, prompt) => renderer.invoke(channels.steerQueuedPrompt, promptId, prompt),\n unarchiveConversation: (conversationId) => renderer.invoke(channels.unarchiveConversation, conversationId),\n updateConversationSettings: (settings) => renderer.invoke(channels.updateConversationSettings, settings),\n updateQueuedPrompt: (promptId, prompt) => renderer.invoke(channels.updateQueuedPrompt, promptId, prompt),\n };\n}\n","import type {\n CodexNativeAttachment,\n CodexNativeAttachmentInput,\n CodexNativeClipboardContent,\n CodexNativeRendererApi,\n CodexSpeechTranscriptionResult,\n} from '@codex-app-sdk/core/native';\nimport {\n TypedIpcRenderer,\n type IpcRendererPort,\n type IpcRequest,\n} from './typed-ipc';\n\nexport const codexNativeChannels = {\n copyToClipboard: 'codex-native:copy-to-clipboard',\n ingestAttachments: 'codex-native:ingest-attachments',\n openExternal: 'codex-native:open-external',\n pickAttachments: 'codex-native:pick-attachments',\n readImagePreview: 'codex-native:read-image-preview',\n transcribeAudio: 'codex-native:transcribe-audio',\n} as const;\n\nexport type CodexNativeRequests = {\n [codexNativeChannels.copyToClipboard]: IpcRequest<[content: CodexNativeClipboardContent], void>;\n [codexNativeChannels.ingestAttachments]: IpcRequest<[\n files: readonly CodexNativeAttachmentInput[],\n ], CodexNativeAttachment[]>;\n [codexNativeChannels.openExternal]: IpcRequest<[href: string], void>;\n [codexNativeChannels.pickAttachments]: IpcRequest<[], CodexNativeAttachment[]>;\n [codexNativeChannels.readImagePreview]: IpcRequest<[path: string], string | null>;\n [codexNativeChannels.transcribeAudio]: IpcRequest<[\n audioData: ArrayBuffer,\n options?: { locale?: string; live?: boolean },\n ], CodexSpeechTranscriptionResult>;\n};\n\nexport type CodexContextBridge = {\n exposeInMainWorld(key: string, api: unknown): void;\n};\n\nexport function createCodexNativeRendererApi(\n port: IpcRendererPort,\n options: { transcription?: boolean } = {},\n): CodexNativeRendererApi {\n const renderer = new TypedIpcRenderer<CodexNativeRequests, object>(port);\n return {\n capabilities: {\n attachments: true,\n clipboard: true,\n externalLinks: true,\n transcription: options.transcription ?? process.platform === 'darwin',\n },\n copyToClipboard: (content) => renderer.invoke(codexNativeChannels.copyToClipboard, content),\n ingestAttachments: (files) => renderer.invoke(codexNativeChannels.ingestAttachments, files),\n openExternal: (href) => renderer.invoke(codexNativeChannels.openExternal, href),\n pickAttachments: () => renderer.invoke(codexNativeChannels.pickAttachments),\n readImagePreview: (path) => renderer.invoke(codexNativeChannels.readImagePreview, path),\n transcribeAudio: (audioData, transcriptionOptions) => (\n renderer.invoke(codexNativeChannels.transcribeAudio, audioData, transcriptionOptions)\n ),\n };\n}\n\nexport function exposeCodexNativeRendererApi(\n contextBridge: CodexContextBridge,\n port: IpcRendererPort,\n options?: { transcription?: boolean },\n): CodexNativeRendererApi {\n const api = createCodexNativeRendererApi(port, options);\n contextBridge.exposeInMainWorld('codexAppSdkNative', api);\n return api;\n}\n","import type { CodexNativeRendererApi } from '@codex-app-sdk/core/native';\nimport type { CodexSurfaceRendererApi } from '@codex-app-sdk/core/surface';\nimport {\n createCodexNativeRendererApi,\n type CodexContextBridge,\n} from './codex-native-renderer';\nimport { createCodexSurfaceRendererApi } from './codex-surface-ipc';\nimport type { IpcRendererPort } from './typed-ipc';\n\nexport type CodexElectronRendererApis = {\n native: CodexNativeRendererApi;\n surface: CodexSurfaceRendererApi;\n};\n\n/** Exposes the SDK-owned renderer APIs under stable, automatically detected names. */\nexport function exposeCodexElectronPreload(\n contextBridge: CodexContextBridge,\n ipcRenderer: IpcRendererPort,\n options?: { transcription?: boolean },\n): CodexElectronRendererApis {\n const surface = createCodexSurfaceRendererApi(ipcRenderer);\n const native = createCodexNativeRendererApi(ipcRenderer, options);\n contextBridge.exposeInMainWorld('codexSurface', surface);\n contextBridge.exposeInMainWorld('codexAppSdkNative', native);\n return { native, surface };\n}\n"],"mappings":";;AAiCA,IAAa,IAAb,MAA8E;CAC/C;CAA7B,YAAY,GAAwC;EAAvB,KAAA,OAAA;CAAwB;CAErD,OACE,GACA,GAAG,GACwC;EAC3C,OAAO,KAAK,KAAK,OAAO,GAAS,GAAG,CAAI;CAC1C;CAEA,GAAmC,GAAe,GAAuD;EACvG,IAAM,KAAW,GAAiB,MAAqB,EAAS,CAAuB;EAEvF,OADA,KAAK,KAAK,GAAG,GAAS,CAAO,SAChB,KAAK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,oBAAoB,GAAU,CAAM;CACzG;AACF;;;AC/SA,IAAa,IAAsB;CACjC,iBAAiB;CACjB,mBAAmB;CACnB,cAAc;CACd,iBAAiB;CACjB,kBAAkB;CAClB,iBAAiB;AACnB;AAoBA,SAAgB,EACd,GACA,IAAuC,CAAC,GAChB;CACxB,IAAM,IAAW,IAAI,EAA8C,CAAI;CACvE,OAAO;EACL,cAAc;GACZ,aAAa;GACb,WAAW;GACX,eAAe;GACf,eAAe,EAAQ,iBAAiB,QAAQ,aAAa;EAC/D;EACA,kBAAkB,MAAY,EAAS,OAAO,EAAoB,iBAAiB,CAAO;EAC1F,oBAAoB,MAAU,EAAS,OAAO,EAAoB,mBAAmB,CAAK;EAC1F,eAAe,MAAS,EAAS,OAAO,EAAoB,cAAc,CAAI;EAC9E,uBAAuB,EAAS,OAAO,EAAoB,eAAe;EAC1E,mBAAmB,MAAS,EAAS,OAAO,EAAoB,kBAAkB,CAAI;EACtF,kBAAkB,GAAW,MAC3B,EAAS,OAAO,EAAoB,iBAAiB,GAAW,CAAoB;CAExF;AACF;AAEA,SAAgB,EACd,GACA,GACA,GACwB;CACxB,IAAM,IAAM,EAA6B,GAAM,CAAO;CAEtD,OADA,EAAc,kBAAkB,qBAAqB,CAAG,GACjD;AACT;;;ACxDA,SAAgB,EACd,GACA,GACA,GAC2B;CAC3B,IAAM,IAAU,EAA8B,CAAW,GACnD,IAAS,EAA6B,GAAa,CAAO;CAGhE,OAFA,EAAc,kBAAkB,gBAAgB,CAAO,GACvD,EAAc,kBAAkB,qBAAqB,CAAM,GACpD;EAAE;EAAQ;CAAQ;AAC3B"}
@@ -0,0 +1,19 @@
1
+ import type { CodexHostAttachment } from '@codex-app-sdk/core/native';
2
+ import type { CodexRendererAttachment, CodexSurfaceAttachment } from '@codex-app-sdk/core/surface';
3
+ export type CodexElectronAttachmentRegistration = {
4
+ type: CodexHostAttachment['type'];
5
+ path: string;
6
+ name: string;
7
+ mimeType: string;
8
+ size: number;
9
+ previewUrl?: string;
10
+ };
11
+ /** Keeps trusted local paths out of the renderer and scopes references to one Electron integration. */
12
+ export declare class CodexElectronAttachmentRegistry {
13
+ #private;
14
+ register(input: CodexElectronAttachmentRegistration): CodexHostAttachment;
15
+ resolve(attachment: CodexRendererAttachment): CodexSurfaceAttachment;
16
+ path(reference: string): string;
17
+ clear(): void;
18
+ }
19
+ //# sourceMappingURL=codex-attachment-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-attachment-registry.d.ts","sourceRoot":"","sources":["../src/codex-attachment-registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,KAAK,EACV,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,6BAA6B,CAAC;AAErC,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAIF,uGAAuG;AACvG,qBAAa,+BAA+B;;IAG1C,QAAQ,CAAC,KAAK,EAAE,mCAAmC,GAAG,mBAAmB;IAoBzE,OAAO,CAAC,UAAU,EAAE,uBAAuB,GAAG,sBAAsB;IAgBpE,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAI/B,KAAK,IAAI,IAAI;CASd"}
@@ -0,0 +1,11 @@
1
+ import type { CodexSurface } from '@codex-app-sdk/backend';
2
+ import { type CodexNativeMainDependencies, type CodexNativeMainOptions } from './codex-native-ipc';
3
+ import type { IpcEventSender, IpcSenderPolicy } from './typed-ipc';
4
+ export type CodexElectronMainOptions = CodexNativeMainDependencies & IpcSenderPolicy & {
5
+ native?: CodexNativeMainOptions;
6
+ sender: IpcEventSender;
7
+ surface: CodexSurface;
8
+ };
9
+ /** Installs the complete SDK-owned surface and native capability bridge. */
10
+ export declare function registerCodexElectronMain(options: CodexElectronMainOptions): () => void;
11
+ //# sourceMappingURL=codex-electron-integration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-electron-integration.d.ts","sourceRoot":"","sources":["../src/codex-electron-integration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAEL,KAAK,2BAA2B,EAChC,KAAK,sBAAsB,EAC5B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnE,MAAM,MAAM,wBAAwB,GAAG,2BAA2B,GAAG,eAAe,GAAG;IACrF,MAAM,CAAC,EAAE,sBAAsB,CAAC;IAChC,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF,4EAA4E;AAC5E,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,wBAAwB,GAAG,MAAM,IAAI,CAmBvF"}
@@ -0,0 +1,13 @@
1
+ import type { CodexNativeRendererApi } from '@codex-app-sdk/core/native';
2
+ import type { CodexSurfaceRendererApi } from '@codex-app-sdk/core/surface';
3
+ import { type CodexContextBridge } from './codex-native-renderer';
4
+ import type { IpcRendererPort } from './typed-ipc';
5
+ export type CodexElectronRendererApis = {
6
+ native: CodexNativeRendererApi;
7
+ surface: CodexSurfaceRendererApi;
8
+ };
9
+ /** Exposes the SDK-owned renderer APIs under stable, automatically detected names. */
10
+ export declare function exposeCodexElectronPreload(contextBridge: CodexContextBridge, ipcRenderer: IpcRendererPort, options?: {
11
+ transcription?: boolean;
12
+ }): CodexElectronRendererApis;
13
+ //# sourceMappingURL=codex-electron-preload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-electron-preload.d.ts","sourceRoot":"","sources":["../src/codex-electron-preload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,MAAM,yBAAyB,GAAG;IACtC,MAAM,EAAE,sBAAsB,CAAC;IAC/B,OAAO,EAAE,uBAAuB,CAAC;CAClC,CAAC;AAEF,sFAAsF;AACtF,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,kBAAkB,EACjC,WAAW,EAAE,eAAe,EAC5B,OAAO,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE,GACpC,yBAAyB,CAM3B"}