codex-copilot-dx 1.3.5 → 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/docs/ARCHITECTURE.md +13 -0
- package/docs/README.md +1 -0
- package/docs/REFERENCE.md +17 -1
- package/package.json +1 -1
- package/src/adapter.mjs +9 -4
- package/src/claude-capability-config.mjs +5 -6
- package/src/claude-client-config.mjs +2 -2
- package/src/claude-gateway.mjs +10 -9
- package/src/connection-runtime.mjs +7 -1
- package/src/dashboard/console.js +2 -0
- package/src/dashboard/index.html +13 -0
- package/src/dashboard/language.js +5 -0
- package/src/dashboard/preferences.js +2 -2
- package/src/dashboard/privacy.js +67 -0
- package/src/dashboard/status.js +2 -1
- package/src/dashboard/ui.css +4 -0
- package/src/dashboard/ui.js +1 -0
- package/src/dashboard-api.mjs +15 -0
- package/src/dashboard.mjs +1 -0
- package/src/local-privacy.mjs +135 -0
- package/src/optional-routes.mjs +2 -2
- package/src/privacy-model.mjs +161 -0
- package/src/privacy-notices.txt +104 -0
- package/src/privacy-transform.mjs +192 -0
- package/src/provider-runtime.mjs +4 -3
- package/src/responses-handler.mjs +11 -2
- package/src/responses-proxy.mjs +3 -3
- package/src/service-control.mjs +2 -1
- package/src/settings-preferences.mjs +3 -2
- package/src/stream-performance.mjs +1 -1
- package/src/user-settings.mjs +1 -1
package/src/provider-runtime.mjs
CHANGED
|
@@ -27,13 +27,14 @@ export function createProviderRuntime(options = {}) {
|
|
|
27
27
|
options = { ...options, corePort: options.corePort ?? Number((options.env || process.env).ADAPTER_PORT || 2026) };
|
|
28
28
|
let connections;
|
|
29
29
|
const legacy = createBuiltinProviderRuntime({ ...options, managedClaude: () => connections?.managesClaude() !== false,
|
|
30
|
+
privacy: { wrap: (fn, context) => connections?.privacy.wrap(fn, context) || fn },
|
|
30
31
|
onClaudeReady: () => connections?.syncSourceClients("m365") });
|
|
31
32
|
connections = createConnectionRuntime({ ...options, legacy });return connections;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
function createBuiltinProviderRuntime({ githubClient, githubRegistry, refreshGithubCatalog, githubCredentialFingerprint = "", githubClientConfigured = true, home, env = process.env, platform = process.platform,
|
|
35
36
|
corePort = Number(env.ADAPTER_PORT || 2026), log = () => {}, createM365, startGateway, configureClients, restoreClients,
|
|
36
|
-
discoverM365 = requestM365Accounts, managedClaude, onClaudeReady, preserveClientConfiguration } = {}) {
|
|
37
|
+
discoverM365 = requestM365Accounts, managedClaude, onClaudeReady, preserveClientConfiguration, privacy } = {}) {
|
|
37
38
|
const options = { home, env, platform }, github = { ...createGithubProvider({ client: githubClient,
|
|
38
39
|
profileId: () => { const value = typeof githubCredentialFingerprint === "function" ? githubCredentialFingerprint() : githubCredentialFingerprint;
|
|
39
40
|
return value ? `codex:${value}` : "codex"; } }), registry: githubRegistry };
|
|
@@ -85,7 +86,7 @@ function createBuiltinProviderRuntime({ githubClient, githubRegistry, refreshGit
|
|
|
85
86
|
const apiKey = ensureM365GatewayKey({ ...options, create: !preserveClientConfiguration?.() });
|
|
86
87
|
if (!gateway) {
|
|
87
88
|
const start = startGateway || (await import("./claude-gateway.mjs")).createClaudeGateway;
|
|
88
|
-
const opened = await start({ provider: m365, apiKey, port: corePort, env, log, performance: claudePerformance,
|
|
89
|
+
const opened = await start({ privacy, provider: m365, apiKey, port: corePort, env, log, performance: claudePerformance,
|
|
89
90
|
onRequest({ client }) { lastClients[client] = new Date().toISOString(); } });
|
|
90
91
|
if (closed || !enabled) { await opened.close();return null; }
|
|
91
92
|
gateway = opened;
|
|
@@ -152,7 +153,7 @@ function createBuiltinProviderRuntime({ githubClient, githubRegistry, refreshGit
|
|
|
152
153
|
if (closed) throw unavailable("m365_runtime_closed");
|
|
153
154
|
if (candidate.models("claude").length) {
|
|
154
155
|
const start = startGateway || (await import("./claude-gateway.mjs")).createClaudeGateway;
|
|
155
|
-
opened = await start({ provider: candidate, apiKey: ensureM365GatewayKey(options), port: corePort, env, log, performance: claudePerformance,
|
|
156
|
+
opened = await start({ privacy, provider: candidate, apiKey: ensureM365GatewayKey(options), port: corePort, env, log, performance: claudePerformance,
|
|
156
157
|
onRequest({ client }) { lastClients[client] = new Date().toISOString(); } });
|
|
157
158
|
}
|
|
158
159
|
candidate.commitSelection(discovered.binding);
|
|
@@ -270,6 +270,11 @@ export function createResponsesHandler(options) {
|
|
|
270
270
|
prepared = selected instanceof Promise ? await selected : selected;
|
|
271
271
|
if (prepared.historyParentId === null) releaseHistorySnapshot();
|
|
272
272
|
provider.applyRequestPolicies(prepared.body);
|
|
273
|
+
if (options.privacy) {
|
|
274
|
+
prepared.privacyRestore = value => options.privacy.restoreResponse(res, value);
|
|
275
|
+
responsesFn = options.privacy.wrap(responsesFn, { res, protocol: "responses", client: "codex" });
|
|
276
|
+
chatCompletionsFn = options.privacy.wrap(chatCompletionsFn, { res, protocol: "chat", client: "codex" });
|
|
277
|
+
}
|
|
273
278
|
if (routePlan.protocol === "openai-responses") {
|
|
274
279
|
const restorePlaintextHistory = async (context, { reserveHistory } = {}) => {
|
|
275
280
|
assertPrepareActive();
|
|
@@ -322,7 +327,7 @@ export function createResponsesHandler(options) {
|
|
|
322
327
|
const written = await writeOrDrain(res, `event: ${event}\ndata: ${JSON.stringify(data)}\n\n`, { signal: abort.signal });
|
|
323
328
|
if (!written) return false;
|
|
324
329
|
if (event === "response.completed" || event === "response.incomplete") {
|
|
325
|
-
if (event === "response.completed") rememberResponseHistory(prepared, data.response);
|
|
330
|
+
if (event === "response.completed") rememberResponseHistory(prepared, prepared.privacyRestore?.(data.response) || data.response);
|
|
326
331
|
recordResponsesUsage({ surface: prepared.surface, mode: "stream", model, response: data.response, event: data });
|
|
327
332
|
}
|
|
328
333
|
return true;
|
|
@@ -385,7 +390,7 @@ export function createResponsesHandler(options) {
|
|
|
385
390
|
markResponseTerminal(response.status, {
|
|
386
391
|
model: response.model || model, origin: "chat_completion", reason: response.incomplete_details?.reason,
|
|
387
392
|
});
|
|
388
|
-
rememberResponseHistory(prepared, response);
|
|
393
|
+
rememberResponseHistory(prepared, prepared.privacyRestore?.(response) || response);
|
|
389
394
|
if (response.status === "completed") imagePressure?.markSuccess?.(responseHistoryPressureRootId(prepared));
|
|
390
395
|
recordResponsesUsage({ surface: prepared.surface, mode: "json", model, response, event: response });
|
|
391
396
|
res.writeHead(200, safeUpstreamResponseHeaders(upstream.headers, {
|
|
@@ -553,6 +558,10 @@ export function createResponsesCompactHandler(options) {
|
|
|
553
558
|
prepared = selected instanceof Promise ? await selected : selected;
|
|
554
559
|
releaseHistorySnapshot();
|
|
555
560
|
provider.applyRequestPolicies(prepared.body);
|
|
561
|
+
if (options.privacy) {
|
|
562
|
+
prepared.privacyRestore = value => options.privacy.restoreResponse(res, value);
|
|
563
|
+
responsesCompactFn = options.privacy.wrap(responsesCompactFn, { res, protocol: "responses", client: "codex" });
|
|
564
|
+
}
|
|
556
565
|
const result = await proxyCopilotResponses(prepared, req, res, responsesCompactFn, {
|
|
557
566
|
compatibility: provider.compatibility,
|
|
558
567
|
assertPrepareActive,
|
package/src/responses-proxy.mjs
CHANGED
|
@@ -316,7 +316,7 @@ function parseSuccessfulResponsesResult(text) {
|
|
|
316
316
|
|
|
317
317
|
function storeCompletedResponse(reqContext, completed) {
|
|
318
318
|
if (!completed) return;
|
|
319
|
-
rememberResponseHistory(reqContext, completed.response);
|
|
319
|
+
rememberResponseHistory(reqContext, reqContext.privacyRestore?.(completed.response) || completed.response);
|
|
320
320
|
recordResponsesUsage({
|
|
321
321
|
surface: reqContext.surface,
|
|
322
322
|
mode: "stream",
|
|
@@ -571,7 +571,7 @@ export async function proxyCopilotResponses(reqContext, req, res, upstream = cop
|
|
|
571
571
|
compactionInputWithoutTrigger(reqContext.body.input),
|
|
572
572
|
data,
|
|
573
573
|
);
|
|
574
|
-
rememberResponseHistory(reqContext, response);
|
|
574
|
+
rememberResponseHistory(reqContext, reqContext.privacyRestore?.(response) || response);
|
|
575
575
|
recordResponsesUsage({
|
|
576
576
|
surface: reqContext.surface,
|
|
577
577
|
mode: "json",
|
|
@@ -620,7 +620,7 @@ export async function proxyCopilotResponses(reqContext, req, res, upstream = cop
|
|
|
620
620
|
continue;
|
|
621
621
|
}
|
|
622
622
|
}
|
|
623
|
-
rememberResponseHistory(reqContext, response);
|
|
623
|
+
rememberResponseHistory(reqContext, reqContext.privacyRestore?.(response) || response);
|
|
624
624
|
recordResponsesUsage({
|
|
625
625
|
surface: reqContext.surface,
|
|
626
626
|
mode: "json",
|
package/src/service-control.mjs
CHANGED
|
@@ -18,7 +18,7 @@ export function createServiceControl({ env = process.env, home, providerRuntime,
|
|
|
18
18
|
try { imageConfigured = Boolean(readImages()); } catch {}
|
|
19
19
|
try { predictionConfigured = readPrediction().enabled === true; } catch {}
|
|
20
20
|
const enabled = nightlyUpdatePreference(options), nightly = nightlyStatus();
|
|
21
|
-
return { source: "service_settings", saved, theme, color_theme, preferences: settingsPreferencesSnapshot(options),
|
|
21
|
+
return { source: "service_settings", saved, theme, color_theme, preferences: settingsPreferencesSnapshot(options), local_privacy: providerRuntime?.privacy?.snapshot(),
|
|
22
22
|
nightly_update: { enabled, ...nightly, effect: enabled && !nightly ? "next_start" : "immediate" },
|
|
23
23
|
effective: {
|
|
24
24
|
terminal_animation_enabled: { value: terminal?.enabled === true && saved.terminal_animation_enabled && !/^(0|false|no|off)$/i.test(env.CCDX_TERMINAL_ANIMATION || ""),
|
|
@@ -40,6 +40,7 @@ export function createServiceControl({ env = process.env, home, providerRuntime,
|
|
|
40
40
|
if (["preferences", "reset_preferences", "restore_preferences"].includes(input.action)) {
|
|
41
41
|
const before = nightlyUpdatePreference(options);
|
|
42
42
|
writeSettingsPreferences(input, options);
|
|
43
|
+
if (input.action !== "preferences" || Object.keys(input.values || {}).some(key => key.startsWith("privacy_"))) providerRuntime?.privacy?.settingsChanged();
|
|
43
44
|
const current = settingsPreferencesSnapshot(options).values;
|
|
44
45
|
terminal?.apply?.({ ...servicePreferences(options), theme: current.terminal_animation, color_theme: current.terminal_color_theme });
|
|
45
46
|
if (before !== current.nightly_updates) nightlyChanged(current.nightly_updates);
|
|
@@ -9,7 +9,7 @@ import { atomicWriteFileIfChangedSync, atomicWriteFilePairSync } from "./atomic-
|
|
|
9
9
|
import { withFileLockSync } from "./lock.mjs";
|
|
10
10
|
|
|
11
11
|
export const SETTINGS_DEFAULTS = Object.freeze({ terminal_color_theme: "green", terminal_animation: DEFAULT_TERMINAL_ANIMATION_THEME,
|
|
12
|
-
terminal_animation_enabled: true, open_webui: true, nightly_updates: false, auto_save_settings: true });
|
|
12
|
+
terminal_animation_enabled: true, open_webui: true, nightly_updates: false, auto_save_settings: true, privacy_enabled: false, privacy_personal: false });
|
|
13
13
|
const keys = Object.keys(SETTINGS_DEFAULTS);
|
|
14
14
|
const fail = (code, message, statusCode = 409) => Object.assign(new Error(message), { code, statusCode });
|
|
15
15
|
const idValid = value => typeof value === "string" && /^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/.test(value);
|
|
@@ -30,7 +30,8 @@ function readBackup(options) {
|
|
|
30
30
|
const value = JSON.parse(readBoundedFileSync(settingsBackupPath(options), { encoding: "utf8", maxBytes: 8192 }));
|
|
31
31
|
if (value?.version !== 1 || !idValid(value.id) || typeof value.created_at !== "string" || !Number.isFinite(Date.parse(value.created_at))
|
|
32
32
|
|| Object.keys(value).some(key => !["version", "id", "created_at", "values"].includes(key))
|
|
33
|
-
|| keys.some(key => !Object.hasOwn(value.values || {}, key))) throw Error();
|
|
33
|
+
|| keys.filter(key => !key.startsWith("privacy_")).some(key => !Object.hasOwn(value.values || {}, key))) throw Error();
|
|
34
|
+
value.values = { privacy_enabled: false, privacy_personal: false, ...value.values };
|
|
34
35
|
checkedPreferenceValues(value.values);return value;
|
|
35
36
|
} catch (error) {
|
|
36
37
|
if (error.code === "ENOENT") return null;
|
|
@@ -342,7 +342,7 @@ export function createStreamPerformanceMetrics({ now = () => performance.now(),
|
|
|
342
342
|
observeContext(values) {
|
|
343
343
|
if (finished || !values || typeof values !== "object") return;
|
|
344
344
|
if (Number.isSafeInteger(values.cached_input_tokens) && values.cached_input_tokens >= 0) cachedInput = values.cached_input_tokens;
|
|
345
|
-
for (const key of [...Object.keys(context), "capability_revision", "capability_constraints"]) {
|
|
345
|
+
for (const key of [...Object.keys(context), "capability_revision", "capability_constraints", "privacy_count", "privacy_ms"]) {
|
|
346
346
|
const value = values[key];
|
|
347
347
|
if (["capability_revision", "capability_constraints"].includes(key)) {
|
|
348
348
|
if (typeof value === "string" && /^[a-z0-9_,]{1,80}$/.test(value)) context[key] = value;continue;
|
package/src/user-settings.mjs
CHANGED
|
@@ -51,7 +51,7 @@ export function readUserSettings({ env = process.env, home = os.homedir(), stric
|
|
|
51
51
|
delete parsed[key];
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
for (const key of ["nightly_updates", "auto_save_settings"]) if (Object.hasOwn(parsed, key) && typeof parsed[key] !== "boolean") {
|
|
54
|
+
for (const key of ["nightly_updates", "auto_save_settings", "privacy_enabled", "privacy_personal"]) if (Object.hasOwn(parsed, key) && typeof parsed[key] !== "boolean") {
|
|
55
55
|
if (strict) throw invalidSettings(filePath, `${key} must be a boolean`);
|
|
56
56
|
delete parsed[key];
|
|
57
57
|
}
|