@pushary/agent-hooks 1.9.50 → 1.9.52
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/CHANGELOG.md +22 -0
- package/README.md +9 -1
- package/dist/api-K6ZROHYB.js +55 -0
- package/dist/bin/pushary-bell-hook.js +28 -25
- package/dist/bin/pushary-bell.js +13 -11
- package/dist/bin/pushary-claude.js +37 -33
- package/dist/bin/pushary-clean.js +68 -42
- package/dist/bin/pushary-codex-bridge.js +23 -20
- package/dist/bin/pushary-codex-hook.js +36 -32
- package/dist/bin/pushary-codex-session.js +17 -616
- package/dist/bin/pushary-codex.js +15 -12
- package/dist/bin/pushary-connect.js +31 -28
- package/dist/bin/pushary-cowork.js +7 -6
- package/dist/bin/pushary-daemon.js +57 -52
- package/dist/bin/pushary-disconnect.js +29 -26
- package/dist/bin/pushary-doctor.js +58 -53
- package/dist/bin/pushary-elicitation-hook.js +29 -26
- package/dist/bin/pushary-gemini-bridge.js +17 -15
- package/dist/bin/pushary-gemini-hook.js +33 -29
- package/dist/bin/pushary-hook.js +34 -31
- package/dist/bin/pushary-login.js +19 -16
- package/dist/bin/pushary-logout.js +30 -27
- package/dist/bin/pushary-mcp.js +16 -9
- package/dist/bin/pushary-mode.js +16 -14
- package/dist/bin/pushary-notification-hook.js +27 -24
- package/dist/bin/pushary-opencode-hook.js +32 -28
- package/dist/bin/pushary-permission-denied-hook.js +32 -29
- package/dist/bin/pushary-permission-hook.js +31 -28
- package/dist/bin/pushary-post-hook.js +27 -24
- package/dist/bin/pushary-prompt-hook.js +27 -24
- package/dist/bin/pushary-session-end-hook.js +27 -24
- package/dist/bin/pushary-session-start-hook.js +34 -29
- package/dist/bin/pushary-setup.js +195 -138
- package/dist/bin/pushary-stats.js +8 -7
- package/dist/bin/pushary-status.js +35 -32
- package/dist/bin/pushary-stop-hook.js +27 -24
- package/dist/bin/pushary-stopfailure-hook.js +27 -24
- package/dist/bin/pushary-suggestions.js +16 -14
- package/dist/bin/pushary-transcript-register.js +19 -17
- package/dist/bin/pushary-transcripts.js +10 -9
- package/dist/bin/pushary-upgrade.js +76 -46
- package/dist/bin/pushary-wait.js +16 -14
- package/dist/bin/pushary.js +10 -8
- package/dist/{chunk-GBKSCDEK.js → chunk-2LEH5IGX.js} +17 -4
- package/dist/chunk-36NGFHE4.js +72 -0
- package/dist/{chunk-B7LV6W7U.js → chunk-3RPN7AAT.js} +1 -1
- package/dist/{chunk-GDDXGBTM.js → chunk-46TC24ET.js} +2 -2
- package/dist/{chunk-KEAIIVW3.js → chunk-4QQEUJL4.js} +2 -2
- package/dist/{chunk-XNZB274I.js → chunk-5463UUO2.js} +1 -1
- package/dist/{chunk-FPKQGWAF.js → chunk-56ZTIY6D.js} +2 -2
- package/dist/{chunk-34AQAQKW.js → chunk-63IQRYVP.js} +4 -4
- package/dist/{chunk-25SYEAW4.js → chunk-6C4S3QYD.js} +3 -3
- package/dist/{chunk-4PCJ6DYK.js → chunk-6SWMKF5E.js} +2 -2
- package/dist/{chunk-Y7WD72J7.js → chunk-7CLLWDCP.js} +1 -1
- package/dist/{chunk-WLT6J3SB.js → chunk-ALZZVC3E.js} +2 -2
- package/dist/{chunk-ZMYLVFXC.js → chunk-BL3WAGIK.js} +14 -9
- package/dist/{chunk-PA54A437.js → chunk-BUXDR6US.js} +1 -1
- package/dist/{chunk-VUS6QGND.js → chunk-CQ5JGRML.js} +5 -1
- package/dist/{chunk-IF2UPWD2.js → chunk-DHJSBK63.js} +1 -1
- package/dist/chunk-DMJFW4KL.js +729 -0
- package/dist/{chunk-ABMEBN2R.js → chunk-EK7SZJ4K.js} +6 -4
- package/dist/{chunk-VCZN7NAB.js → chunk-EPOD7QHT.js} +7 -5
- package/dist/{chunk-KIO2MZQC.js → chunk-FCMWUYIE.js} +5 -3
- package/dist/{chunk-YTYXFA5M.js → chunk-FI73DGNB.js} +1 -1
- package/dist/{chunk-JGNYCRB2.js → chunk-FV34HT35.js} +1 -1
- package/dist/{chunk-KK2DIUVV.js → chunk-GCN73COS.js} +1 -1
- package/dist/{chunk-KBGKWB5T.js → chunk-H57DXSHR.js} +4 -2
- package/dist/{chunk-SALUTWPX.js → chunk-IHUFRAHB.js} +4 -4
- package/dist/chunk-JBT3ZSJS.js +92 -0
- package/dist/{chunk-5Q2FRMPC.js → chunk-JOWF4Y4P.js} +4 -4
- package/dist/{chunk-EP6S6VY3.js → chunk-JPABKXK6.js} +6 -6
- package/dist/{chunk-LLRYP5TR.js → chunk-K23WMLPY.js} +5 -5
- package/dist/{chunk-34RXPM5U.js → chunk-L5YTS2BP.js} +3 -3
- package/dist/{chunk-SE4JFMLW.js → chunk-LD4MWJMD.js} +8 -6
- package/dist/{chunk-OR5F63C2.js → chunk-LF3TLC7B.js} +2 -168
- package/dist/{chunk-XTVEW2NG.js → chunk-LIESRXK5.js} +1 -1
- package/dist/{chunk-ZOKMGBPR.js → chunk-MC4VY5LK.js} +16 -5
- package/dist/{chunk-K73CBZKW.js → chunk-MHQB62K5.js} +4 -4
- package/dist/{chunk-DH4BWFU7.js → chunk-MTKV4RUQ.js} +82 -16
- package/dist/{chunk-Y74IJ2IO.js → chunk-N77BH7H2.js} +10 -4
- package/dist/{chunk-ZTTCYHOM.js → chunk-NECZKPJN.js} +31 -6
- package/dist/{chunk-TGCIFEDE.js → chunk-NELH25J7.js} +13 -11
- package/dist/{chunk-HXRH7ZCK.js → chunk-NHVEQLQC.js} +2 -2
- package/dist/{chunk-OW4DNSQ6.js → chunk-NSY2V7XU.js} +1 -1
- package/dist/chunk-OHSHDQZF.js +271 -0
- package/dist/{chunk-ZYYQJSIO.js → chunk-OML4YFBN.js} +44 -462
- package/dist/{chunk-X3RCIOIH.js → chunk-ONCWYACA.js} +1 -1
- package/dist/{chunk-LZYJMSOY.js → chunk-P2546BBI.js} +3 -3
- package/dist/{chunk-WEY5ZHDB.js → chunk-Q7OXI6VS.js} +5 -5
- package/dist/{chunk-APASKZ2I.js → chunk-QKU46TK5.js} +5 -3
- package/dist/chunk-QTOLNRET.js +169 -0
- package/dist/{chunk-TYTIDEBW.js → chunk-RH6KR6EH.js} +5 -5
- package/dist/{chunk-7RMSB4A2.js → chunk-RL7EOD6I.js} +87 -24
- package/dist/{chunk-BOVSUH4N.js → chunk-S6RNS4UL.js} +2 -2
- package/dist/{chunk-LY3OJFBW.js → chunk-T6RIKJUO.js} +2 -1
- package/dist/{chunk-YVO4HIHX.js → chunk-U2L42GVI.js} +12 -10
- package/dist/{chunk-BXK6ZJVJ.js → chunk-UVT6B6XN.js} +2 -2
- package/dist/{chunk-UCF3EZZL.js → chunk-VQPSWD3A.js} +13 -13
- package/dist/{chunk-XH3F66VD.js → chunk-VYBH6D4X.js} +3 -3
- package/dist/chunk-XCEN33UP.js +7 -0
- package/dist/{chunk-GTGXQ7FJ.js → chunk-XDCXTDHH.js} +11 -11
- package/dist/{chunk-OZLGTMIY.js → chunk-XSUJ2PQY.js} +2 -2
- package/dist/chunk-XUW2DRAQ.js +427 -0
- package/dist/{chunk-UHVD7BSV.js → chunk-XZRLFBEA.js} +6 -6
- package/dist/{chunk-AWMMABVB.js → chunk-ZMPR436Z.js} +52 -138
- package/dist/{chunk-PXUNPXOX.js → chunk-ZOP3I2GQ.js} +3 -3
- package/dist/codex-app-cards-switch-OUQ3DUWF.js +52 -0
- package/dist/codex-desktop-launch-EIFLPLB7.js +27 -0
- package/dist/codex-session-launch-KLH2FSSJ.js +331 -0
- package/dist/config-HX6ZNOIL.js +14 -0
- package/dist/{global-upgrade-AIUSS2YH.js → global-upgrade-AZN3BPI3.js} +8 -6
- package/dist/identity-AQIMUWYN.js +15 -0
- package/dist/live-capabilities-4IIFAMHU.js +53 -0
- package/dist/{paths-RO34TYNM.js → paths-X4IPV2WJ.js} +4 -2
- package/dist/{reapply-KTNPP4XE.js → reapply-CXODG53B.js} +27 -21
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.js +22 -19
- package/dist/{upgrade-lock-5UAGXIW7.js → upgrade-lock-AHISGKER.js} +5 -3
- package/dist/usage-ZC6BKIE3.js +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import {
|
|
2
|
+
processGroupHasNothingLeftToSignal
|
|
3
|
+
} from "./chunk-XCEN33UP.js";
|
|
4
|
+
import {
|
|
5
|
+
CodexNativeApprovals,
|
|
6
|
+
answerCodexElicitation,
|
|
7
|
+
answerCodexQuestions,
|
|
8
|
+
claimOwnedQuestion,
|
|
9
|
+
closesOwnedQuestion,
|
|
10
|
+
codexQuestionOwner,
|
|
11
|
+
isCodexQuestionLeftWithTheLocalClient,
|
|
12
|
+
planCodexElicitation,
|
|
13
|
+
reportOwnedQuestion
|
|
14
|
+
} from "./chunk-LD4MWJMD.js";
|
|
15
|
+
import "./chunk-UVT6B6XN.js";
|
|
16
|
+
import "./chunk-2LEH5IGX.js";
|
|
17
|
+
import "./chunk-RIVNNBEK.js";
|
|
18
|
+
import "./chunk-56ZTIY6D.js";
|
|
19
|
+
import "./chunk-5463UUO2.js";
|
|
20
|
+
import "./chunk-GCN73COS.js";
|
|
21
|
+
import "./chunk-XHKBHWLX.js";
|
|
22
|
+
import "./chunk-6ICPEJY5.js";
|
|
23
|
+
import "./chunk-JBT3ZSJS.js";
|
|
24
|
+
import {
|
|
25
|
+
writeDegraded
|
|
26
|
+
} from "./chunk-ZMPR436Z.js";
|
|
27
|
+
import "./chunk-P2546BBI.js";
|
|
28
|
+
import "./chunk-POFBE6ZY.js";
|
|
29
|
+
import "./chunk-L5YTS2BP.js";
|
|
30
|
+
import "./chunk-EK7SZJ4K.js";
|
|
31
|
+
import "./chunk-T6RIKJUO.js";
|
|
32
|
+
import "./chunk-7QLSKOSU.js";
|
|
33
|
+
import "./chunk-KZERVKTD.js";
|
|
34
|
+
import "./chunk-OML4YFBN.js";
|
|
35
|
+
import "./chunk-XUW2DRAQ.js";
|
|
36
|
+
import "./chunk-AQFEP65J.js";
|
|
37
|
+
import "./chunk-CQ5JGRML.js";
|
|
38
|
+
import "./chunk-MC4VY5LK.js";
|
|
39
|
+
import "./chunk-QTOLNRET.js";
|
|
40
|
+
import {
|
|
41
|
+
canonicalJsonText
|
|
42
|
+
} from "./chunk-LF3TLC7B.js";
|
|
43
|
+
|
|
44
|
+
// src/codex-session-launch.ts
|
|
45
|
+
import { spawn as spawn2 } from "child_process";
|
|
46
|
+
import { stat } from "fs/promises";
|
|
47
|
+
import { resolve } from "path";
|
|
48
|
+
|
|
49
|
+
// src/codex-shared-session.ts
|
|
50
|
+
import { spawn } from "child_process";
|
|
51
|
+
import { mkdtemp, rm } from "fs/promises";
|
|
52
|
+
import { createServer } from "http";
|
|
53
|
+
import { tmpdir } from "os";
|
|
54
|
+
import { join } from "path";
|
|
55
|
+
import WebSocket, { WebSocketServer } from "ws";
|
|
56
|
+
|
|
57
|
+
// src/codex-shared-questions.ts
|
|
58
|
+
import { createHash, randomUUID } from "crypto";
|
|
59
|
+
var CodexSharedQuestions = class {
|
|
60
|
+
constructor(options) {
|
|
61
|
+
this.options = options;
|
|
62
|
+
}
|
|
63
|
+
generation = randomUUID();
|
|
64
|
+
pending = /* @__PURE__ */ new Map();
|
|
65
|
+
retired = /* @__PURE__ */ new Set();
|
|
66
|
+
tasks = /* @__PURE__ */ new Set();
|
|
67
|
+
closed = false;
|
|
68
|
+
handle(message, threadId) {
|
|
69
|
+
if (this.closed || !message.method) return;
|
|
70
|
+
const params = message.params ?? {};
|
|
71
|
+
if (message.id === void 0) {
|
|
72
|
+
for (const [id2, pending2] of this.pending) {
|
|
73
|
+
const closed = pending2.dispatch ? closesOwnedQuestion(pending2.dispatch.owner, message.method, params) : message.method === "serverRequest/resolved" && params.requestId === id2 || params.threadId === pending2.threadId && ["thread/closed", "thread/archived", "turn/completed"].includes(message.method);
|
|
74
|
+
if (closed) {
|
|
75
|
+
pending2.controller.abort();
|
|
76
|
+
this.pending.delete(id2);
|
|
77
|
+
this.retired.add(id2);
|
|
78
|
+
if (pending2.dispatch) {
|
|
79
|
+
const task2 = reportOwnedQuestion(this.options, pending2.dispatch, "request_closed").finally(() => this.tasks.delete(task2));
|
|
80
|
+
this.tasks.add(task2);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const id = message.id;
|
|
87
|
+
if (typeof id !== "string" && !(typeof id === "number" && Number.isSafeInteger(id))) return;
|
|
88
|
+
if (this.retired.has(id)) return;
|
|
89
|
+
const subjectHash = createHash("sha256").update(canonicalJsonText(params)).digest("hex");
|
|
90
|
+
const existing = this.pending.get(id);
|
|
91
|
+
if (existing) {
|
|
92
|
+
if (existing.subjectHash !== subjectHash) {
|
|
93
|
+
existing.controller.abort();
|
|
94
|
+
this.pending.delete(id);
|
|
95
|
+
this.retired.add(id);
|
|
96
|
+
}
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (this.pending.size >= 8) return;
|
|
100
|
+
const isQuestion = message.method === "item/tool/requestUserInput";
|
|
101
|
+
if (!isQuestion && message.method !== "mcpServer/elicitation/request") return;
|
|
102
|
+
const owner = isQuestion ? codexQuestionOwner(params, id, { machineId: this.options.machineId, generation: this.generation, threadId }) : null;
|
|
103
|
+
if (isQuestion ? !owner : !planCodexElicitation(params, threadId)) return;
|
|
104
|
+
const duration = params.autoResolutionMs;
|
|
105
|
+
if (duration != null && (typeof duration !== "number" || !Number.isFinite(duration) || duration < 0)) return;
|
|
106
|
+
const dispatch = owner ? { owner, correlationIds: [], deadline: typeof duration === "number" ? Date.now() + duration : null } : void 0;
|
|
107
|
+
const pending = { controller: new AbortController(), dispatch, threadId, subjectHash };
|
|
108
|
+
this.pending.set(id, pending);
|
|
109
|
+
const task = this.answer(id, params, pending).finally(() => this.tasks.delete(task));
|
|
110
|
+
this.tasks.add(task);
|
|
111
|
+
}
|
|
112
|
+
async answer(id, params, pending) {
|
|
113
|
+
const signal = AbortSignal.any([this.options.signal, pending.controller.signal]);
|
|
114
|
+
const options = { ...this.options, shared: true, signal };
|
|
115
|
+
const dispatch = pending.dispatch;
|
|
116
|
+
try {
|
|
117
|
+
const result = dispatch ? await answerCodexQuestions(options, params, signal, "request_user_input", dispatch) : await answerCodexElicitation(options, params, pending.threadId, signal);
|
|
118
|
+
if (signal.aborted || this.closed || "action" in result && result.action !== "accept") return;
|
|
119
|
+
if (dispatch) await claimOwnedQuestion(options, dispatch);
|
|
120
|
+
if (signal.aborted || this.closed || this.pending.get(id) !== pending) return;
|
|
121
|
+
if (dispatch?.deadline != null && Date.now() >= dispatch.deadline) throw new Error("Question expired");
|
|
122
|
+
this.options.reply(id, result);
|
|
123
|
+
if (dispatch) await reportOwnedQuestion(options, dispatch, "reply_queued");
|
|
124
|
+
} catch (error) {
|
|
125
|
+
if (!signal.aborted && !isCodexQuestionLeftWithTheLocalClient(error)) writeDegraded("questions", { reason: "shared_codex_question_unavailable", fallback: "native client", event: "question" });
|
|
126
|
+
} finally {
|
|
127
|
+
if (dispatch && (!dispatch.claimId || signal.aborted)) await reportOwnedQuestion(options, dispatch, "unavailable");
|
|
128
|
+
if (!dispatch?.claimId || signal.aborted) {
|
|
129
|
+
this.pending.delete(id);
|
|
130
|
+
this.retired.add(id);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async close() {
|
|
135
|
+
this.closed = true;
|
|
136
|
+
for (const pending of this.pending.values()) pending.controller.abort();
|
|
137
|
+
await Promise.allSettled(this.tasks);
|
|
138
|
+
await Promise.allSettled([...this.pending.values()].flatMap((pending) => pending.dispatch ? [reportOwnedQuestion(this.options, pending.dispatch, "unavailable")] : []));
|
|
139
|
+
this.pending.clear();
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// src/codex-shared-session.ts
|
|
144
|
+
var record = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
145
|
+
var requestId = (value) => typeof value === "string" || typeof value === "number" && Number.isSafeInteger(value);
|
|
146
|
+
var MAX_MESSAGE_BYTES = 16 * 1024 * 1024;
|
|
147
|
+
var startCodexSharedSession = async (options) => {
|
|
148
|
+
if (process.platform === "win32") throw new Error("Managed Codex sessions currently require macOS or Linux");
|
|
149
|
+
options.signal.throwIfAborted();
|
|
150
|
+
const directory = await mkdtemp(join(tmpdir(), "pushary-codex-"));
|
|
151
|
+
const socketPath = join(directory, "terminal.sock");
|
|
152
|
+
const controller = new AbortController();
|
|
153
|
+
const signal = AbortSignal.any([controller.signal, options.signal]);
|
|
154
|
+
const http = createServer((_request, response) => {
|
|
155
|
+
response.writeHead(404);
|
|
156
|
+
response.end();
|
|
157
|
+
});
|
|
158
|
+
const websocket = new WebSocketServer({ server: http, maxPayload: MAX_MESSAGE_BYTES, perMessageDeflate: false });
|
|
159
|
+
const child = spawn(options.binary, ["app-server"], {
|
|
160
|
+
cwd: options.cwd,
|
|
161
|
+
env: { ...options.env ?? process.env, PUSHARY_CODEX_BRIDGE: "1" },
|
|
162
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
163
|
+
detached: true
|
|
164
|
+
});
|
|
165
|
+
child.stderr.resume();
|
|
166
|
+
const exited = new Promise((resolve2) => {
|
|
167
|
+
child.once("exit", () => {
|
|
168
|
+
controller.abort(new Error("Codex app-server stopped"));
|
|
169
|
+
resolve2();
|
|
170
|
+
});
|
|
171
|
+
child.once("error", () => {
|
|
172
|
+
controller.abort(new Error("Could not start Codex app-server"));
|
|
173
|
+
resolve2();
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
let terminal = null;
|
|
177
|
+
let closing = null;
|
|
178
|
+
let buffered = "";
|
|
179
|
+
const unanswered = /* @__PURE__ */ new Set();
|
|
180
|
+
const write = (message) => {
|
|
181
|
+
if (signal.aborted || child.stdin.destroyed) throw new Error("Codex connection closed");
|
|
182
|
+
child.stdin.write(JSON.stringify(message) + "\n");
|
|
183
|
+
};
|
|
184
|
+
const reply = (id, result) => {
|
|
185
|
+
if (!unanswered.delete(id)) throw new Error("Native request already answered");
|
|
186
|
+
write({ id, result });
|
|
187
|
+
};
|
|
188
|
+
const approvals = new CodexNativeApprovals({ ...options, signal, shared: true, reply });
|
|
189
|
+
const questions = new CodexSharedQuestions({ ...options, signal, reply });
|
|
190
|
+
const observeNative = (message) => {
|
|
191
|
+
if (typeof message.method !== "string") return;
|
|
192
|
+
if (requestId(message.id)) unanswered.add(message.id);
|
|
193
|
+
if (!record(message.params)) return;
|
|
194
|
+
if (message.method === "serverRequest/resolved" && requestId(message.params.requestId)) unanswered.delete(message.params.requestId);
|
|
195
|
+
const event = { id: message.id, method: message.method, params: message.params };
|
|
196
|
+
const threadId = typeof message.params.threadId === "string" ? message.params.threadId : null;
|
|
197
|
+
if (!approvals.handle(event, threadId)) questions.handle(event, threadId);
|
|
198
|
+
};
|
|
199
|
+
child.stdout.setEncoding("utf8");
|
|
200
|
+
child.stdout.on("data", (chunk) => {
|
|
201
|
+
buffered += chunk;
|
|
202
|
+
let end;
|
|
203
|
+
while ((end = buffered.indexOf("\n")) >= 0) {
|
|
204
|
+
const line = buffered.slice(0, end);
|
|
205
|
+
buffered = buffered.slice(end + 1);
|
|
206
|
+
if (!line.trim()) continue;
|
|
207
|
+
if (Buffer.byteLength(line) > MAX_MESSAGE_BYTES) {
|
|
208
|
+
controller.abort();
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
try {
|
|
212
|
+
const message = JSON.parse(line);
|
|
213
|
+
if (!record(message)) throw new Error("Invalid Codex message");
|
|
214
|
+
observeNative(message);
|
|
215
|
+
if (terminal?.readyState === WebSocket.OPEN) terminal.send(line);
|
|
216
|
+
} catch {
|
|
217
|
+
controller.abort();
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (Buffer.byteLength(buffered) > MAX_MESSAGE_BYTES) controller.abort();
|
|
222
|
+
});
|
|
223
|
+
child.stdin.on("error", () => controller.abort());
|
|
224
|
+
websocket.on("connection", (client) => {
|
|
225
|
+
if (terminal || signal.aborted) {
|
|
226
|
+
client.close();
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
terminal = client;
|
|
230
|
+
client.on("error", () => controller.abort());
|
|
231
|
+
client.on("close", () => controller.abort());
|
|
232
|
+
client.on("message", (bytes) => {
|
|
233
|
+
try {
|
|
234
|
+
const message = JSON.parse(bytes.toString());
|
|
235
|
+
if (!record(message)) throw new Error("Invalid terminal message");
|
|
236
|
+
if (requestId(message.id) && !("method" in message)) {
|
|
237
|
+
if (!unanswered.delete(message.id)) return;
|
|
238
|
+
approvals.handle({ method: "serverRequest/resolved", params: { requestId: message.id } }, null);
|
|
239
|
+
questions.handle({ method: "serverRequest/resolved", params: { requestId: message.id } }, null);
|
|
240
|
+
}
|
|
241
|
+
write(message);
|
|
242
|
+
} catch {
|
|
243
|
+
controller.abort();
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
const signalServerGroup = (signal2) => {
|
|
248
|
+
if (!child.pid) return false;
|
|
249
|
+
try {
|
|
250
|
+
process.kill(-child.pid, signal2);
|
|
251
|
+
return true;
|
|
252
|
+
} catch (error) {
|
|
253
|
+
if (processGroupHasNothingLeftToSignal(error)) return false;
|
|
254
|
+
throw error;
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
const stopServer = async () => {
|
|
258
|
+
signalServerGroup("SIGTERM");
|
|
259
|
+
const deadline = Date.now() + 2e3;
|
|
260
|
+
while (signalServerGroup(0) && Date.now() < deadline) await new Promise((resolve2) => setTimeout(resolve2, 25));
|
|
261
|
+
if (signalServerGroup(0)) signalServerGroup("SIGKILL");
|
|
262
|
+
await exited;
|
|
263
|
+
};
|
|
264
|
+
const close = () => {
|
|
265
|
+
if (closing) return closing;
|
|
266
|
+
closing = Promise.resolve().then(async () => {
|
|
267
|
+
controller.abort();
|
|
268
|
+
terminal?.terminate();
|
|
269
|
+
websocket.close();
|
|
270
|
+
http.close();
|
|
271
|
+
try {
|
|
272
|
+
await Promise.all([approvals.close(), questions.close(), stopServer()]);
|
|
273
|
+
} finally {
|
|
274
|
+
await rm(directory, { recursive: true, force: true });
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
return closing;
|
|
278
|
+
};
|
|
279
|
+
signal.addEventListener("abort", () => {
|
|
280
|
+
void close();
|
|
281
|
+
}, { once: true });
|
|
282
|
+
try {
|
|
283
|
+
await new Promise((resolve2, reject) => {
|
|
284
|
+
http.once("error", reject);
|
|
285
|
+
http.listen(socketPath, resolve2);
|
|
286
|
+
});
|
|
287
|
+
signal.throwIfAborted();
|
|
288
|
+
return { endpoint: "unix://" + socketPath, signal, close };
|
|
289
|
+
} catch (error) {
|
|
290
|
+
await close();
|
|
291
|
+
throw error;
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
// src/codex-session-launch.ts
|
|
296
|
+
var codexSessionDirectory = (args, cwd) => {
|
|
297
|
+
if (args.length === 0) return cwd;
|
|
298
|
+
if (args.length === 2 && args[0] === "--cwd" && args[1]) return resolve(cwd, args[1]);
|
|
299
|
+
throw new Error("Usage: pushary codex [--cwd <directory>]");
|
|
300
|
+
};
|
|
301
|
+
var launchCodexSession = async (options) => {
|
|
302
|
+
if (!(await stat(options.cwd)).isDirectory()) throw new Error("Codex needs a project directory");
|
|
303
|
+
const session = await startCodexSharedSession(options);
|
|
304
|
+
try {
|
|
305
|
+
process.stderr.write("[pushary] Managed Codex session. Supported questions and native permissions can reach Pushary; other prompts stay in this terminal.\n");
|
|
306
|
+
const tui = spawn2(options.binary, ["--remote", session.endpoint], {
|
|
307
|
+
cwd: options.cwd,
|
|
308
|
+
env: { ...options.env ?? process.env, PUSHARY_CODEX_BRIDGE: "1" },
|
|
309
|
+
stdio: "inherit"
|
|
310
|
+
});
|
|
311
|
+
const stop = () => {
|
|
312
|
+
tui.kill("SIGTERM");
|
|
313
|
+
};
|
|
314
|
+
session.signal.addEventListener("abort", stop, { once: true });
|
|
315
|
+
if (session.signal.aborted) stop();
|
|
316
|
+
try {
|
|
317
|
+
return await new Promise((resolve2, reject) => {
|
|
318
|
+
tui.once("error", reject);
|
|
319
|
+
tui.once("close", (code) => resolve2(code ?? 1));
|
|
320
|
+
});
|
|
321
|
+
} finally {
|
|
322
|
+
session.signal.removeEventListener("abort", stop);
|
|
323
|
+
}
|
|
324
|
+
} finally {
|
|
325
|
+
await session.close();
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
export {
|
|
329
|
+
codexSessionDirectory,
|
|
330
|
+
launchCodexSession
|
|
331
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
configFilePath,
|
|
3
|
+
getApiKey,
|
|
4
|
+
getBaseUrl,
|
|
5
|
+
resetKeyDriftWarning
|
|
6
|
+
} from "./chunk-CQ5JGRML.js";
|
|
7
|
+
import "./chunk-MC4VY5LK.js";
|
|
8
|
+
import "./chunk-LF3TLC7B.js";
|
|
9
|
+
export {
|
|
10
|
+
configFilePath,
|
|
11
|
+
getApiKey,
|
|
12
|
+
getBaseUrl,
|
|
13
|
+
resetKeyDriftWarning
|
|
14
|
+
};
|
|
@@ -5,15 +5,17 @@ import {
|
|
|
5
5
|
readGlobalUpgradeSubject,
|
|
6
6
|
upgradeInstalledPackage,
|
|
7
7
|
withUpgradeLock
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-NECZKPJN.js";
|
|
9
|
+
import "./chunk-H57DXSHR.js";
|
|
10
|
+
import "./chunk-QKU46TK5.js";
|
|
11
11
|
import "./chunk-POFBE6ZY.js";
|
|
12
12
|
import "./chunk-KZERVKTD.js";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-OML4YFBN.js";
|
|
14
|
+
import "./chunk-XUW2DRAQ.js";
|
|
14
15
|
import "./chunk-AQFEP65J.js";
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-MC4VY5LK.js";
|
|
17
|
+
import "./chunk-QTOLNRET.js";
|
|
18
|
+
import "./chunk-LF3TLC7B.js";
|
|
17
19
|
export {
|
|
18
20
|
finishGlobalUpgrade,
|
|
19
21
|
finishUpgradeWithLock,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getMachineId,
|
|
3
|
+
getOrCreateMachineId,
|
|
4
|
+
readExistingMachineId
|
|
5
|
+
} from "./chunk-T6RIKJUO.js";
|
|
6
|
+
import "./chunk-OML4YFBN.js";
|
|
7
|
+
import "./chunk-XUW2DRAQ.js";
|
|
8
|
+
import "./chunk-AQFEP65J.js";
|
|
9
|
+
import "./chunk-QTOLNRET.js";
|
|
10
|
+
import "./chunk-LF3TLC7B.js";
|
|
11
|
+
export {
|
|
12
|
+
getMachineId,
|
|
13
|
+
getOrCreateMachineId,
|
|
14
|
+
readExistingMachineId
|
|
15
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CLAUDE_BRIDGE_CAPABILITY,
|
|
3
|
+
CLAUDE_RESUME_CAPABILITY,
|
|
4
|
+
CODEX_BRIDGE_CAPABILITY,
|
|
5
|
+
CODEX_RESUME_CAPABILITY,
|
|
6
|
+
GEMINI_BRIDGE_CAPABILITY,
|
|
7
|
+
GEMINI_RESUME_CAPABILITY,
|
|
8
|
+
SPAWN_CAPABILITY,
|
|
9
|
+
codexBinaryIsBroken,
|
|
10
|
+
detectLaunchableProviderCapabilities,
|
|
11
|
+
detectProviderLiveCapabilities,
|
|
12
|
+
discoverProviderInventory,
|
|
13
|
+
expectedLaunchCapabilities,
|
|
14
|
+
geminiLiveCapabilities,
|
|
15
|
+
hasSpawnProvider,
|
|
16
|
+
launchAdvertisement,
|
|
17
|
+
launchableProviders,
|
|
18
|
+
missingControlPrerequisite,
|
|
19
|
+
phoneStartIsRequired,
|
|
20
|
+
providerLiveCapabilities,
|
|
21
|
+
resolveControlPolicy,
|
|
22
|
+
resolveProviderBinary,
|
|
23
|
+
trackProviderInventory
|
|
24
|
+
} from "./chunk-2LEH5IGX.js";
|
|
25
|
+
import "./chunk-RIVNNBEK.js";
|
|
26
|
+
import "./chunk-6ICPEJY5.js";
|
|
27
|
+
import "./chunk-XUW2DRAQ.js";
|
|
28
|
+
import "./chunk-QTOLNRET.js";
|
|
29
|
+
import "./chunk-LF3TLC7B.js";
|
|
30
|
+
export {
|
|
31
|
+
CLAUDE_BRIDGE_CAPABILITY,
|
|
32
|
+
CLAUDE_RESUME_CAPABILITY,
|
|
33
|
+
CODEX_BRIDGE_CAPABILITY,
|
|
34
|
+
CODEX_RESUME_CAPABILITY,
|
|
35
|
+
GEMINI_BRIDGE_CAPABILITY,
|
|
36
|
+
GEMINI_RESUME_CAPABILITY,
|
|
37
|
+
SPAWN_CAPABILITY,
|
|
38
|
+
codexBinaryIsBroken,
|
|
39
|
+
detectLaunchableProviderCapabilities,
|
|
40
|
+
detectProviderLiveCapabilities,
|
|
41
|
+
discoverProviderInventory,
|
|
42
|
+
expectedLaunchCapabilities,
|
|
43
|
+
geminiLiveCapabilities,
|
|
44
|
+
hasSpawnProvider,
|
|
45
|
+
launchAdvertisement,
|
|
46
|
+
launchableProviders,
|
|
47
|
+
missingControlPrerequisite,
|
|
48
|
+
phoneStartIsRequired,
|
|
49
|
+
providerLiveCapabilities,
|
|
50
|
+
resolveControlPolicy,
|
|
51
|
+
resolveProviderBinary,
|
|
52
|
+
trackProviderInventory
|
|
53
|
+
};
|
|
@@ -32,8 +32,10 @@ import {
|
|
|
32
32
|
pusharyDir,
|
|
33
33
|
vscodePluginDir,
|
|
34
34
|
vscodePluginMcp
|
|
35
|
-
} from "./chunk-
|
|
36
|
-
import "./chunk-
|
|
35
|
+
} from "./chunk-OML4YFBN.js";
|
|
36
|
+
import "./chunk-XUW2DRAQ.js";
|
|
37
|
+
import "./chunk-QTOLNRET.js";
|
|
38
|
+
import "./chunk-LF3TLC7B.js";
|
|
37
39
|
export {
|
|
38
40
|
autoUpdateLock,
|
|
39
41
|
autoUpdateLog,
|
|
@@ -11,34 +11,40 @@ import {
|
|
|
11
11
|
reapplyOpenCodePlugin,
|
|
12
12
|
reapplyVsCodePlugin,
|
|
13
13
|
repairCodexHolds
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-25SYEAW4.js";
|
|
20
|
-
import "./chunk-PA54A437.js";
|
|
21
|
-
import "./chunk-XTVEW2NG.js";
|
|
22
|
-
import "./chunk-GMXKITVA.js";
|
|
14
|
+
} from "./chunk-RL7EOD6I.js";
|
|
15
|
+
import "./chunk-FCMWUYIE.js";
|
|
16
|
+
import "./chunk-MTKV4RUQ.js";
|
|
17
|
+
import "./chunk-46TC24ET.js";
|
|
18
|
+
import "./chunk-K23WMLPY.js";
|
|
23
19
|
import "./chunk-RIVNNBEK.js";
|
|
20
|
+
import "./chunk-N77BH7H2.js";
|
|
21
|
+
import "./chunk-Q7OXI6VS.js";
|
|
22
|
+
import "./chunk-6C4S3QYD.js";
|
|
23
|
+
import "./chunk-BUXDR6US.js";
|
|
24
|
+
import "./chunk-LIESRXK5.js";
|
|
25
|
+
import "./chunk-GMXKITVA.js";
|
|
24
26
|
import "./chunk-XHKBHWLX.js";
|
|
25
27
|
import "./chunk-6ICPEJY5.js";
|
|
26
|
-
import "./chunk-
|
|
27
|
-
import "./chunk-
|
|
28
|
-
import "./chunk-
|
|
29
|
-
import "./chunk-
|
|
28
|
+
import "./chunk-VYBH6D4X.js";
|
|
29
|
+
import "./chunk-U2L42GVI.js";
|
|
30
|
+
import "./chunk-3RPN7AAT.js";
|
|
31
|
+
import "./chunk-JBT3ZSJS.js";
|
|
32
|
+
import "./chunk-ZMPR436Z.js";
|
|
33
|
+
import "./chunk-P2546BBI.js";
|
|
30
34
|
import "./chunk-POFBE6ZY.js";
|
|
31
|
-
import "./chunk-
|
|
32
|
-
import "./chunk-
|
|
33
|
-
import "./chunk-
|
|
34
|
-
import "./chunk-LY3OJFBW.js";
|
|
35
|
+
import "./chunk-L5YTS2BP.js";
|
|
36
|
+
import "./chunk-EK7SZJ4K.js";
|
|
37
|
+
import "./chunk-T6RIKJUO.js";
|
|
35
38
|
import "./chunk-7QLSKOSU.js";
|
|
36
39
|
import "./chunk-KZERVKTD.js";
|
|
37
|
-
import "./chunk-
|
|
40
|
+
import "./chunk-4QQEUJL4.js";
|
|
41
|
+
import "./chunk-OML4YFBN.js";
|
|
42
|
+
import "./chunk-XUW2DRAQ.js";
|
|
38
43
|
import "./chunk-AQFEP65J.js";
|
|
39
|
-
import "./chunk-
|
|
40
|
-
import "./chunk-
|
|
41
|
-
import "./chunk-
|
|
44
|
+
import "./chunk-CQ5JGRML.js";
|
|
45
|
+
import "./chunk-MC4VY5LK.js";
|
|
46
|
+
import "./chunk-QTOLNRET.js";
|
|
47
|
+
import "./chunk-LF3TLC7B.js";
|
|
42
48
|
export {
|
|
43
49
|
ensureCodexTrustAfterReapply,
|
|
44
50
|
inspectConfiguredManagedProviders,
|
package/dist/src/index.d.ts
CHANGED
|
@@ -187,9 +187,9 @@ interface AnswerResult {
|
|
|
187
187
|
note?: string;
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
declare const askUser: (apiKey: string, params: AskUserParams, timeoutMs?: number) => Promise<AskUserResponse>;
|
|
191
|
-
declare const waitForAnswer: (apiKey: string, correlationId: string, timeoutMs?: number, signal?: AbortSignal) => Promise<AnswerResult>;
|
|
192
|
-
declare const cancelQuestion: (apiKey: string, correlationId: string, signal?: AbortSignal) => Promise<{
|
|
190
|
+
declare const askUser: (apiKey: string, params: AskUserParams, timeoutMs?: number, baseUrl?: string) => Promise<AskUserResponse>;
|
|
191
|
+
declare const waitForAnswer: (apiKey: string, correlationId: string, timeoutMs?: number, signal?: AbortSignal, baseUrl?: string) => Promise<AnswerResult>;
|
|
192
|
+
declare const cancelQuestion: (apiKey: string, correlationId: string, signal?: AbortSignal, baseUrl?: string) => Promise<{
|
|
193
193
|
cancelled?: boolean;
|
|
194
194
|
status?: string;
|
|
195
195
|
handoffAction?: string;
|
package/dist/src/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
handlePreToolUse
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-NELH25J7.js";
|
|
4
|
+
import "../chunk-JPABKXK6.js";
|
|
5
|
+
import "../chunk-7CLLWDCP.js";
|
|
6
|
+
import "../chunk-DHJSBK63.js";
|
|
7
|
+
import "../chunk-N77BH7H2.js";
|
|
8
|
+
import "../chunk-6C4S3QYD.js";
|
|
9
9
|
import {
|
|
10
10
|
fetchAccountPublicKey
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-GCN73COS.js";
|
|
12
12
|
import "../chunk-6ICPEJY5.js";
|
|
13
13
|
import {
|
|
14
14
|
fetchModeOverride,
|
|
@@ -18,31 +18,34 @@ import {
|
|
|
18
18
|
handlePostToolUse,
|
|
19
19
|
handleStop,
|
|
20
20
|
reportEvent
|
|
21
|
-
} from "../chunk-
|
|
22
|
-
import "../chunk-
|
|
23
|
-
import "../chunk-
|
|
21
|
+
} from "../chunk-U2L42GVI.js";
|
|
22
|
+
import "../chunk-3RPN7AAT.js";
|
|
23
|
+
import "../chunk-JBT3ZSJS.js";
|
|
24
24
|
import {
|
|
25
25
|
askUser,
|
|
26
26
|
cancelQuestion,
|
|
27
27
|
waitForAnswer
|
|
28
|
-
} from "../chunk-
|
|
28
|
+
} from "../chunk-ZMPR436Z.js";
|
|
29
|
+
import "../chunk-P2546BBI.js";
|
|
29
30
|
import "../chunk-POFBE6ZY.js";
|
|
30
|
-
import "../chunk-
|
|
31
|
-
import "../chunk-
|
|
32
|
-
import "../chunk-
|
|
33
|
-
import "../chunk-LY3OJFBW.js";
|
|
31
|
+
import "../chunk-L5YTS2BP.js";
|
|
32
|
+
import "../chunk-EK7SZJ4K.js";
|
|
33
|
+
import "../chunk-T6RIKJUO.js";
|
|
34
34
|
import "../chunk-7QLSKOSU.js";
|
|
35
35
|
import "../chunk-KZERVKTD.js";
|
|
36
|
-
import "../chunk-
|
|
36
|
+
import "../chunk-4QQEUJL4.js";
|
|
37
|
+
import "../chunk-OML4YFBN.js";
|
|
38
|
+
import "../chunk-XUW2DRAQ.js";
|
|
37
39
|
import "../chunk-AQFEP65J.js";
|
|
38
40
|
import {
|
|
39
41
|
getApiKey,
|
|
40
42
|
getBaseUrl
|
|
41
|
-
} from "../chunk-
|
|
42
|
-
import "../chunk-
|
|
43
|
+
} from "../chunk-CQ5JGRML.js";
|
|
44
|
+
import "../chunk-MC4VY5LK.js";
|
|
45
|
+
import "../chunk-QTOLNRET.js";
|
|
43
46
|
import {
|
|
44
47
|
resolvePolicy
|
|
45
|
-
} from "../chunk-
|
|
48
|
+
} from "../chunk-LF3TLC7B.js";
|
|
46
49
|
export {
|
|
47
50
|
askUser,
|
|
48
51
|
cancelQuestion,
|
|
@@ -5,10 +5,12 @@ import {
|
|
|
5
5
|
installWithUpgradeLock,
|
|
6
6
|
ownsUpgradeLock,
|
|
7
7
|
releaseAutoUpdateLock
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-H57DXSHR.js";
|
|
9
|
+
import "./chunk-OML4YFBN.js";
|
|
10
|
+
import "./chunk-XUW2DRAQ.js";
|
|
10
11
|
import "./chunk-AQFEP65J.js";
|
|
11
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-QTOLNRET.js";
|
|
13
|
+
import "./chunk-LF3TLC7B.js";
|
|
12
14
|
export {
|
|
13
15
|
claimUpgradeLock,
|
|
14
16
|
finishWithUpgradeLock,
|