@makerbi/remodex 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +483 -0
- package/bin/phodex.js +10 -0
- package/bin/remodex.js +314 -0
- package/package.json +33 -0
- package/src/account-status.js +175 -0
- package/src/bootstrap-codex-cli.js +53 -0
- package/src/bridge.js +2032 -0
- package/src/codex-cli-bootstrap.js +187 -0
- package/src/codex-desktop-refresher.js +780 -0
- package/src/codex-home.js +21 -0
- package/src/codex-transport.js +353 -0
- package/src/daemon-state.js +153 -0
- package/src/desktop-handler.js +465 -0
- package/src/git-handler.js +2371 -0
- package/src/index.js +36 -0
- package/src/ios-app-compatibility.js +244 -0
- package/src/macos-launch-agent.js +506 -0
- package/src/notifications-handler.js +95 -0
- package/src/package-version-status.js +185 -0
- package/src/private-defaults.json +4 -0
- package/src/project-handler.js +359 -0
- package/src/push-notification-completion-dedupe.js +147 -0
- package/src/push-notification-service-client.js +151 -0
- package/src/push-notification-tracker.js +688 -0
- package/src/qr.js +63 -0
- package/src/rollout-live-mirror.js +825 -0
- package/src/rollout-watch.js +834 -0
- package/src/scripts/codex-handoff.applescript +100 -0
- package/src/scripts/codex-refresh.applescript +51 -0
- package/src/secure-device-state.js +430 -0
- package/src/secure-transport.js +738 -0
- package/src/session-state.js +57 -0
- package/src/thread-context-handler.js +80 -0
- package/src/voice-handler.js +321 -0
- package/src/workspace-handler.js +630 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// FILE: push-notification-service-client.js
|
|
2
|
+
// Purpose: Sends push registration and completion requests from the local Mac bridge to the configured notification service.
|
|
3
|
+
// Layer: Bridge helper
|
|
4
|
+
// Exports: createPushNotificationServiceClient
|
|
5
|
+
// Depends on: global fetch
|
|
6
|
+
|
|
7
|
+
const DEFAULT_PUSH_SERVICE_TIMEOUT_MS = 10_000;
|
|
8
|
+
|
|
9
|
+
function createPushNotificationServiceClient({
|
|
10
|
+
baseUrl = "",
|
|
11
|
+
sessionId,
|
|
12
|
+
notificationSecret,
|
|
13
|
+
fetchImpl = globalThis.fetch,
|
|
14
|
+
logPrefix = "[remodex]",
|
|
15
|
+
requestTimeoutMs = DEFAULT_PUSH_SERVICE_TIMEOUT_MS,
|
|
16
|
+
} = {}) {
|
|
17
|
+
const normalizedBaseUrl = normalizeBaseUrl(baseUrl);
|
|
18
|
+
|
|
19
|
+
async function registerDevice({
|
|
20
|
+
deviceToken,
|
|
21
|
+
alertsEnabled,
|
|
22
|
+
apnsEnvironment,
|
|
23
|
+
} = {}) {
|
|
24
|
+
return postJSON("/v1/push/session/register-device", {
|
|
25
|
+
sessionId,
|
|
26
|
+
notificationSecret,
|
|
27
|
+
deviceToken,
|
|
28
|
+
alertsEnabled,
|
|
29
|
+
apnsEnvironment,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function notifyCompletion({
|
|
34
|
+
threadId,
|
|
35
|
+
turnId,
|
|
36
|
+
result,
|
|
37
|
+
title,
|
|
38
|
+
body,
|
|
39
|
+
dedupeKey,
|
|
40
|
+
} = {}) {
|
|
41
|
+
return postJSON("/v1/push/session/notify-completion", {
|
|
42
|
+
sessionId,
|
|
43
|
+
notificationSecret,
|
|
44
|
+
threadId,
|
|
45
|
+
turnId,
|
|
46
|
+
result,
|
|
47
|
+
title,
|
|
48
|
+
body,
|
|
49
|
+
dedupeKey,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function postJSON(pathname, payload) {
|
|
54
|
+
if (!normalizedBaseUrl || typeof fetchImpl !== "function") {
|
|
55
|
+
return { ok: false, skipped: true };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const controller = typeof AbortController === "function" && requestTimeoutMs > 0
|
|
59
|
+
? new AbortController()
|
|
60
|
+
: null;
|
|
61
|
+
const timeoutID = controller
|
|
62
|
+
? setTimeout(() => {
|
|
63
|
+
controller.abort(createTimeoutAbortError(requestTimeoutMs));
|
|
64
|
+
}, requestTimeoutMs)
|
|
65
|
+
: null;
|
|
66
|
+
|
|
67
|
+
let response;
|
|
68
|
+
try {
|
|
69
|
+
response = await fetchImpl(`${normalizedBaseUrl}${pathname}`, {
|
|
70
|
+
method: "POST",
|
|
71
|
+
headers: {
|
|
72
|
+
"content-type": "application/json",
|
|
73
|
+
},
|
|
74
|
+
body: JSON.stringify(payload),
|
|
75
|
+
signal: controller?.signal,
|
|
76
|
+
});
|
|
77
|
+
} catch (error) {
|
|
78
|
+
if (isAbortError(error)) {
|
|
79
|
+
const timeoutError = new Error(`Push service request timed out after ${requestTimeoutMs}ms`);
|
|
80
|
+
timeoutError.code = "push_request_timeout";
|
|
81
|
+
throw timeoutError;
|
|
82
|
+
}
|
|
83
|
+
throw error;
|
|
84
|
+
} finally {
|
|
85
|
+
if (timeoutID) {
|
|
86
|
+
clearTimeout(timeoutID);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const responseText = await response.text();
|
|
91
|
+
const parsed = safeParseJSON(responseText);
|
|
92
|
+
if (!response.ok) {
|
|
93
|
+
const message = parsed?.error || parsed?.message || responseText || `HTTP ${response.status}`;
|
|
94
|
+
const error = new Error(message);
|
|
95
|
+
error.status = response.status;
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return parsed ?? { ok: true };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
hasConfiguredBaseUrl: Boolean(normalizedBaseUrl),
|
|
104
|
+
registerDevice,
|
|
105
|
+
notifyCompletion,
|
|
106
|
+
logUnavailable() {
|
|
107
|
+
if (!normalizedBaseUrl) {
|
|
108
|
+
console.log(`${logPrefix} push notifications disabled: no push service URL configured`);
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function normalizeBaseUrl(value) {
|
|
115
|
+
if (typeof value !== "string") {
|
|
116
|
+
return "";
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const trimmed = value.trim();
|
|
120
|
+
if (!trimmed) {
|
|
121
|
+
return "";
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return trimmed.replace(/\/+$/, "");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function createTimeoutAbortError(timeoutMs) {
|
|
128
|
+
const error = new Error(`Push service request timed out after ${timeoutMs}ms`);
|
|
129
|
+
error.name = "AbortError";
|
|
130
|
+
return error;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function isAbortError(error) {
|
|
134
|
+
return error?.name === "AbortError" || error?.code === "ABORT_ERR";
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function safeParseJSON(value) {
|
|
138
|
+
if (!value || typeof value !== "string") {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
try {
|
|
143
|
+
return JSON.parse(value);
|
|
144
|
+
} catch {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
module.exports = {
|
|
150
|
+
createPushNotificationServiceClient,
|
|
151
|
+
};
|