@youdie006/prodex 0.40.1 → 0.40.3

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/dist/cli-args.js CHANGED
@@ -260,6 +260,9 @@ export const ASK_PRO_BOOLEAN_FLAGS = new Set([
260
260
  "--no-auto-login",
261
261
  // Send outside any project for once, overriding a pinned default.
262
262
  "--no-project",
263
+ // Continue the conversation a previous consult left off in, resolved from
264
+ // this repo's own records rather than from whatever the shared tab shows.
265
+ "--continue",
263
266
  // Send even when the requested model/effort could not be applied, rather
264
267
  // than stopping. Off by default: an answer from a step nobody asked for is
265
268
  // usually thrown away.
@@ -268,6 +271,8 @@ export const ASK_PRO_BOOLEAN_FLAGS = new Set([
268
271
  export const ASK_PRO_SELECTION_VALUE_FLAGS = ["--project", "--project-new", "--model", "--pro-mode", "--effort"];
269
272
  export const ASK_PRO_VALUE_FLAGS = new Set([
270
273
  "--cwd",
274
+ // Continue one NAMED past consult, when "the last one" is not the one meant.
275
+ "--continue-task",
271
276
  "--file",
272
277
  // Upload the file itself (pdf/pptx/image) instead of inlining its text.
273
278
  "--attach",
package/dist/cli-help.js CHANGED
@@ -26,7 +26,7 @@ Ask / consult commands:
26
26
  prodex pro browser models [--source-cli /absolute/path/to/dist/cli.js] [--port 9333] [--timeout-ms 15000] # read-only list of model menu options
27
27
  prodex pro browser projects [--source-cli /absolute/path/to/dist/cli.js] [--port 9333] [--timeout-ms 15000] # read-only list of sidebar project names (for --project)
28
28
  prodex pro browser recover [--source-cli /absolute/path/to/dist/cli.js] [--cwd /absolute/path/to/repo] [--port 9333] --target-url <thread-url> [--timeout-ms 60000] # recover a finished answer from a thread whose send timed out
29
- prodex pro browser ask [--source-cli /absolute/path/to/dist/cli.js] [--cwd /absolute/path/to/repo] [--port 9333] [--timeout-ms 300000] [--busy-wait-ms 600000] [--target-url url --confirm-target] [--new-chat] [--temporary] [--allow-model-fallback] [--stdin] [--json] [--auto-login|--no-auto-login] [--file path] [--attach path] [--tool deep-research|web-search|create-image] [--model Pro] [--pro-mode 기본|확장] [--effort 즉시|중간|높음|"매우 높음"|Max|Ultra|Pro] [--project "name" | --project-new "name"] "prompt" # explicit visible-browser send
29
+ prodex pro browser ask [--source-cli /absolute/path/to/dist/cli.js] [--cwd /absolute/path/to/repo] [--port 9333] [--timeout-ms 300000] [--busy-wait-ms 600000] [--target-url url --confirm-target] [--new-chat] [--continue | --continue-task task_id] [--temporary] [--allow-model-fallback] [--stdin] [--json] [--auto-login|--no-auto-login] [--file path] [--attach path] [--tool deep-research|web-search|create-image] [--model Pro] [--pro-mode 기본|확장] [--effort 즉시|중간|높음|"매우 높음"|Max|Ultra|Pro] [--project "name" | --project-new "name"] "prompt" # explicit visible-browser send
30
30
  prodex pro latest [--source-cli /absolute/path/to/dist/cli.js] [--cwd /absolute/path/to/repo] [--json]
31
31
  prodex pro blockers [--cwd /absolute/path/to/repo] [--since 7d] [--limit 10] [--json] # what actually blocks consults, ranked, across every bridge root on this machine
32
32
  prodex pro list [--source-cli /absolute/path/to/dist/cli.js] [--cwd /absolute/path/to/repo] [--json]
@@ -170,7 +170,7 @@ Commands:
170
170
  prodex pro browser check [--source-cli /absolute/path/to/dist/cli.js] [--cwd /absolute/path/to/repo]
171
171
  prodex pro browser smoke [--source-cli /absolute/path/to/dist/cli.js] [--cwd /absolute/path/to/repo]
172
172
  prodex pro browser models [--source-cli /absolute/path/to/dist/cli.js]
173
- prodex pro browser ask [--source-cli /absolute/path/to/dist/cli.js] [--cwd /absolute/path/to/repo] [--target-url url --confirm-target] [--new-chat] [--temporary] [--allow-model-fallback] [--stdin] [--json] [--auto-login|--no-auto-login] [--file path] [--attach path] [--tool deep-research|web-search|create-image] [--model Pro] [--pro-mode 기본|확장] [--effort 즉시|중간|높음|"매우 높음"|Max|Ultra|Pro] [--project "name" | --project-new "name"] "prompt"
173
+ prodex pro browser ask [--source-cli /absolute/path/to/dist/cli.js] [--cwd /absolute/path/to/repo] [--target-url url --confirm-target] [--new-chat] [--continue | --continue-task task_id] [--temporary] [--allow-model-fallback] [--stdin] [--json] [--auto-login|--no-auto-login] [--file path] [--attach path] [--tool deep-research|web-search|create-image] [--model Pro] [--pro-mode 기본|확장] [--effort 즉시|중간|높음|"매우 높음"|Max|Ultra|Pro] [--project "name" | --project-new "name"] "prompt"
174
174
  prodex pro latest [--source-cli /absolute/path/to/dist/cli.js] [--cwd /absolute/path/to/repo] [--json]
175
175
  prodex pro blockers [--cwd /absolute/path/to/repo] [--since 7d] [--limit 10] [--json] # what actually blocks consults, ranked, across every bridge root on this machine
176
176
  prodex pro list [--source-cli /absolute/path/to/dist/cli.js] [--cwd /absolute/path/to/repo] [--json]
@@ -258,8 +258,8 @@ export function printProBrowserHelp(stdout, sourceCli) {
258
258
  : "prodex pro browser smoke [--source-cli /absolute/path/to/dist/cli.js] [--cwd /absolute/path/to/repo] [--port 9333] [--timeout-ms 90000]";
259
259
  const selectionUsage = '[--model Pro] [--pro-mode 기본|확장] [--effort 즉시|중간|높음|"매우 높음"|Max|Ultra|Pro] [--project "name" | --project-new "name"]';
260
260
  const askUsage = sourceCli
261
- ? `${cli} pro browser ask${sourceCliOption} [--cwd /absolute/path/to/repo] [--port 9333] [--timeout-ms 300000] [--busy-wait-ms 600000] [--target-url url --confirm-target] [--new-chat] [--temporary] [--allow-model-fallback] [--stdin] [--json] [--auto-login|--no-auto-login] [--file path] [--attach path] [--tool deep-research|web-search|create-image] ${selectionUsage} "prompt"`
262
- : `prodex pro browser ask [--source-cli /absolute/path/to/dist/cli.js] [--cwd /absolute/path/to/repo] [--port 9333] [--timeout-ms 300000] [--busy-wait-ms 600000] [--target-url url --confirm-target] [--new-chat] [--temporary] [--allow-model-fallback] [--stdin] [--json] [--auto-login|--no-auto-login] [--file path] [--attach path] [--tool deep-research|web-search|create-image] ${selectionUsage} "prompt"`;
261
+ ? `${cli} pro browser ask${sourceCliOption} [--cwd /absolute/path/to/repo] [--port 9333] [--timeout-ms 300000] [--busy-wait-ms 600000] [--target-url url --confirm-target] [--new-chat] [--continue | --continue-task task_id] [--temporary] [--allow-model-fallback] [--stdin] [--json] [--auto-login|--no-auto-login] [--file path] [--attach path] [--tool deep-research|web-search|create-image] ${selectionUsage} "prompt"`
262
+ : `prodex pro browser ask [--source-cli /absolute/path/to/dist/cli.js] [--cwd /absolute/path/to/repo] [--port 9333] [--timeout-ms 300000] [--busy-wait-ms 600000] [--target-url url --confirm-target] [--new-chat] [--continue | --continue-task task_id] [--temporary] [--allow-model-fallback] [--stdin] [--json] [--auto-login|--no-auto-login] [--file path] [--attach path] [--tool deep-research|web-search|create-image] ${selectionUsage} "prompt"`;
263
263
  const modelsUsage = sourceCli
264
264
  ? `${cli} pro browser models${sourceCliOption} [--port 9333] [--timeout-ms 15000]`
265
265
  : "prodex pro browser models [--source-cli /absolute/path/to/dist/cli.js] [--port 9333] [--timeout-ms 15000]";
@@ -306,6 +306,11 @@ Model/project selection (ask):
306
306
  --pro-mode Pro sub-mode: 기본 (standard) or 확장 (extended), used when the model is Pro. A Pro selection raises the default --timeout-ms to 1200000.
307
307
  --effort Reasoning effort: 즉시 / 중간 / 높음 / 매우 높음 / Max / Ultra / Pro (aliases: instant/light, medium, high, extrahigh/max, ultra). One power slider sets the model and the effort together, so picking an effort moves off Pro. Max and Ultra are rungs of the Work surface and only apply when the browser is already on Work; everything else is sent on Chat.
308
308
  --project Enter an existing sidebar project before sending. Cannot be combined with --target-url.
309
+
310
+ Continuing a conversation (ask):
311
+ --continue Send into the conversation a previous consult is already in: the newest FINISHED consult of the same project, read from this repo's own .bridge records. The browser tab is shared and a pinned project starts a new chat on every send, so the tab is not what decides this. A --project here scopes the search rather than navigating. Refuses instead of guessing when this project has no finished consult yet.
312
+ --continue-task Continue one named past consult by its task_id, when the newest is not the conversation meant. List them with \`${cli} pro list\`.
313
+ Cannot be combined with --new-chat, --target-url, --project-new or --temporary.
309
314
  --pro-mode and --effort cannot be combined. Labels are matched in both the Korean and English (US) ChatGPT UI (e.g. 높음/High, Pro 확장/Pro Extended).
310
315
  Run \`${cli} pro browser models${sourceCliOption}\` to list the labels your account currently shows.
311
316
  Persist defaults with \`${cli} setup${sourceCliOption}\`; per-ask flags override them.
package/dist/cli-pro.js CHANGED
@@ -2,7 +2,7 @@ import { existsSync, statSync } from "node:fs";
2
2
  import { mkdir, readFile, writeFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { buildDryRunBundle } from "./bundle.js";
5
- import { DEFAULT_CDP_PORT, resolveCdpPort, resolveConversationToDelete, resolveProjectToDelete, chatGptVisibilityBlocker, defaultChatGptProfileDir, formatDurationMs, getChatGptBrowserStatus, formatModelMenuOption, listChatGptModelOptions, deleteChatGptConversation, endWedgedBrowser, browserRecoveryPlan, findWedgedBrowser, wedgedBrowserBlocker, deleteChatGptProject, listChatGptProjectsWithIds, listRecentChatGptConversations, listChatGptSidebarProjects, normalizeChatGptTargetUrl, openChatGptBrowser, openChatGptTab, parseProMode, parseReasoningEffort, defaultTimeoutForTools, ensureVirtualDisplay, minimizeChatGptWindow, readLastBrowserLoginLaunch, resolveVirtualDisplayPreference, resolveBrowserWindowMode, resolveHeadlessPreference, recordBrowserLoginLaunch, recoverChatGptAnswerFromThread, sendChatGptPrompt, statusMeansBrowserDead, namesPro } from "./chatgpt-browser.js";
5
+ import { DEFAULT_CDP_PORT, resolveCdpPort, resolveConversationToDelete, resolveProjectToDelete, chatGptVisibilityBlocker, defaultChatGptProfileDir, formatDurationMs, getChatGptBrowserStatus, formatModelMenuOption, listChatGptModelOptions, deleteChatGptConversation, endWedgedBrowser, browserRecoveryPlan, findWedgedBrowser, wedgedBrowserBlocker, deleteChatGptProject, listChatGptProjectsWithIds, listRecentChatGptConversations, listChatGptSidebarProjects, normalizeChatGptTargetUrl, openChatGptBrowser, openChatGptTab, parseProMode, parseReasoningEffort, defaultTimeoutForTools, ensureVirtualDisplay, minimizeChatGptWindow, readLastBrowserLoginLaunch, resolveVirtualDisplayPreference, resolveBrowserWindowMode, resolveHeadlessPreference, recordBrowserLoginLaunch, recoverChatGptAnswerFromThread, sendChatGptPrompt, statusMeansBrowserDead, namesPro, destinationVerification, chatGptProjectIdFromUrl } from "./chatgpt-browser.js";
6
6
  import { ASK_PRO_BOOLEAN_FLAGS, ASK_PRO_PREVIEW_VALUE_FLAGS, ASK_PRO_VALUE_FLAGS, assertHelpRequestArgs, assertNoExtraArgs, assertOnlyOptions, findHelpFlagIndexBeforePromptDelimiter, formatCliCommand, hasAskProDryRunMode, hasAskProMode, hasAskProSendMode, isHelpSubcommand, parseAskProArgs, printHelpIfRequested, readFlag, readPortFlag, readPositionalsWithOptions, readNonNegativeIntegerFlag, readPositiveIntegerFlag, readRepeatedFlag, resolveCwdFlag, resolveOptionalFileFlag, unknownSubcommandError } from "./cli-args.js";
7
7
  import { printProBrowserHelp, printProHelp } from "./cli-help.js";
8
8
  import { listRawResultsForInspection, listTasksForInspection } from "./cli-ledger.js";
@@ -11,6 +11,7 @@ import { errorMessage, firstLine, formatBlockedConsultRecordedMessage, formatPro
11
11
  import { getTokenExpiryStatus, loadBrowserDefaults, loadLocalConfig } from "./config.js";
12
12
  import { withBrowserSendLock } from "./browser-send-lock.js";
13
13
  import { blockerCause, buildBlockerReport } from "./blocker-report.js";
14
+ import { resolveContinuationThread } from "./continue-thread.js";
14
15
  import { readBridgeRoots } from "./registry.js";
15
16
  import { BridgeStore, MAX_FETCHABLE_RESULT_ARTIFACT_BYTES } from "./store.js";
16
17
  import { CLI_VERSION } from "./cli-help.js";
@@ -162,6 +163,8 @@ export async function runProCommand(rest, io, runCliFn) {
162
163
  "--effort",
163
164
  "--new-chat",
164
165
  "--temporary",
166
+ "--continue",
167
+ "--continue-task",
165
168
  "--auto-login",
166
169
  "--no-auto-login"
167
170
  ].find((flag) => proArgs.includes(flag));
@@ -1058,7 +1061,8 @@ export async function runAskProCommand(rest, io) {
1058
1061
  throw new Error("--tool only applies when sending (`prodex pro browser ask`); the dry-run preview cannot open ChatGPT's tools menu.");
1059
1062
  }
1060
1063
  const targetUrl = readFlag(parsedAskPro.optionArgs, "--target-url");
1061
- const normalizedTargetUrl = targetUrl ? normalizeChatGptTargetUrl(targetUrl) : undefined;
1064
+ let normalizedTargetUrl = targetUrl ? normalizeChatGptTargetUrl(targetUrl) : undefined;
1065
+ let continuedFromTaskId;
1062
1066
  if (!normalizedTargetUrl && parsedAskPro.optionArgs.includes("--confirm-target")) {
1063
1067
  throw new Error("--confirm-target requires --target-url so the visible browser target is explicit.");
1064
1068
  }
@@ -1104,6 +1108,46 @@ export async function runAskProCommand(rest, io) {
1104
1108
  if (normalizedTargetUrl && (explicitProject !== undefined || explicitProjectNew !== undefined)) {
1105
1109
  throw new Error("ask-pro cannot combine --target-url with --project/--project-new: --target-url pins the confirmed tab while the project step navigates the sidebar away from it. Open the project thread in the browser and pass its URL as --target-url instead.");
1106
1110
  }
1111
+ // Continue the conversation a previous consult left off in. Resolved from
1112
+ // this repo's records rather than from the shared tab: the tab is whatever
1113
+ // the last person or session left on screen, and a pinned project
1114
+ // navigates away from it before every send anyway - which is why a
1115
+ // "continuing" consult on a machine with a default project measurably
1116
+ // started a new thread every time.
1117
+ const continueRequested = parsedAskPro.optionArgs.includes("--continue");
1118
+ const continueTaskId = readFlag(parsedAskPro.optionArgs, "--continue-task");
1119
+ if (continueRequested || continueTaskId !== undefined) {
1120
+ const conflict = [
1121
+ parsedAskPro.optionArgs.includes("--new-chat") ? "--new-chat" : undefined,
1122
+ targetUrl !== undefined ? "--target-url" : undefined,
1123
+ explicitProjectNew !== undefined ? "--project-new" : undefined,
1124
+ parsedAskPro.optionArgs.includes("--temporary") ? "--temporary" : undefined
1125
+ ].find(Boolean);
1126
+ if (conflict) {
1127
+ throw new Error(`ask-pro cannot combine --continue with ${conflict}: continuing means sending into the conversation a previous consult is already in.`);
1128
+ }
1129
+ // Scope by the project this send would have used, so a follow-up cannot
1130
+ // land in another project's conversation.
1131
+ const continuationProject = explicitProject ?? (suppressProject ? undefined : browserDefaults?.project);
1132
+ const resolved = resolveContinuationThread({
1133
+ consults: (await targetStore.listSessionsReadOnly()).map((session) => ({
1134
+ taskId: session.task_id ?? "",
1135
+ ...(session.thread ? { thread: session.thread } : {}),
1136
+ status: session.status,
1137
+ ...(session.created_at ? { createdAt: session.created_at } : {})
1138
+ })),
1139
+ ...(continuationProject ? { project: continuationProject } : {}),
1140
+ ...(continueTaskId !== undefined ? { taskId: continueTaskId } : {})
1141
+ });
1142
+ if ("error" in resolved)
1143
+ throw new Error(resolved.error);
1144
+ continuedFromTaskId = resolved.target.taskId;
1145
+ // The thread pins the tab exactly as --target-url does, and carries its
1146
+ // own project with it - so the project step is suppressed below for the
1147
+ // same reason a pinned target suppresses it.
1148
+ normalizedTargetUrl = normalizeChatGptTargetUrl(resolved.target.thread);
1149
+ io.stderr(`progress: continuing ${resolved.target.taskId}`);
1150
+ }
1107
1151
  const newChat = parsedAskPro.optionArgs.includes("--new-chat");
1108
1152
  // A temporary chat is not saved, so there is nothing to come back to: the
1109
1153
  // recovery path every timeout message points at cannot fetch it later.
@@ -1130,18 +1174,19 @@ export async function runAskProCommand(rest, io) {
1130
1174
  }
1131
1175
  const explicitProMode = explicitProModeRaw === undefined ? undefined : parseProMode(explicitProModeRaw);
1132
1176
  const explicitEffort = explicitEffortRaw === undefined ? undefined : parseReasoningEffort(explicitEffortRaw);
1133
- // Explicit per-ask flags override persisted defaults. Choosing either
1134
- // reasoning axis explicitly suppresses the default for the other axis, and
1135
- // pinning --target-url suppresses a default project (it would navigate away
1136
- // from the confirmed tab).
1137
- // Choosing an effort IS choosing the reasoning axis, and ChatGPT deselects
1138
- // Pro the moment an effort is set - so applying a pinned Pro first would
1139
- // select a model only to undo it, and a quick question would still pay for
1140
- // the Pro selection dance.
1141
- // --pro-mode refines Pro, so it keeps a pinned Pro. --effort replaces it:
1142
- // ChatGPT deselects Pro the moment an effort is set, so applying the pinned
1143
- // Pro first would select a model only to undo it.
1144
- const selectionModel = explicitModel ?? (explicitEffort !== undefined ? undefined : browserDefaults?.model);
1177
+ // Explicit per-ask flags override persisted defaults; resolveSelectionAxes
1178
+ // holds which default a given flag suppresses and why. The project axis is
1179
+ // separate: pinning --target-url suppresses a default project, because
1180
+ // entering one would navigate away from the confirmed tab.
1181
+ const selectionAxes = resolveSelectionAxes({
1182
+ explicit: {
1183
+ ...(explicitModel !== undefined ? { model: explicitModel } : {}),
1184
+ ...(explicitProMode !== undefined ? { proMode: explicitProMode } : {}),
1185
+ ...(explicitEffort !== undefined ? { effort: explicitEffort } : {})
1186
+ },
1187
+ ...(browserDefaults ? { defaults: browserDefaults } : {})
1188
+ });
1189
+ const selectionModel = selectionAxes.model;
1145
1190
  const selectionProjectNew = explicitProjectNew;
1146
1191
  // A persisted default project APPLIES under --new-chat: since 0.16.11 a
1147
1192
  // fresh chat inside the project is exactly what "--new-chat + project"
@@ -1154,15 +1199,24 @@ export async function runAskProCommand(rest, io) {
1154
1199
  // produced "composer did not rebind after entering project" - a temporary
1155
1200
  // chat is never saved, a project chat is, and entering a project leaves
1156
1201
  // temporary mode.
1157
- const selectionProject = explicitProject ??
1158
- (normalizedTargetUrl || selectionProjectNew !== undefined || suppressProject || temporary
1159
- ? undefined
1160
- : browserDefaults?.project);
1161
- const reasoningAxisChosen = explicitProMode !== undefined || explicitEffort !== undefined;
1162
- const selectionProMode = explicitProMode ?? (reasoningAxisChosen ? undefined : browserDefaults?.pro_mode);
1163
- const selectionEffort = explicitEffort ?? (reasoningAxisChosen ? undefined : browserDefaults?.effort);
1202
+ // A continuation sends into a thread that already lives in its project, so
1203
+ // the project step must not run - entering a project navigates AWAY from
1204
+ // the pinned thread and starts a new chat, which is the very failure
1205
+ // --continue exists to fix. An explicit --project on a continuation is the
1206
+ // SCOPE of the search, not an instruction to navigate.
1207
+ const selectionProject = continuedFromTaskId
1208
+ ? undefined
1209
+ : explicitProject ??
1210
+ (normalizedTargetUrl || selectionProjectNew !== undefined || suppressProject || temporary
1211
+ ? undefined
1212
+ : browserDefaults?.project);
1213
+ const selectionProMode = selectionAxes.proMode;
1214
+ const selectionEffort = selectionAxes.effort;
1215
+ const continuationScopeProject = continuedFromTaskId
1216
+ ? explicitProject ?? (suppressProject ? undefined : browserDefaults?.project)
1217
+ : undefined;
1164
1218
  const selectionMetadata = {
1165
- ...(selectionProject ? { project: selectionProject } : {}),
1219
+ ...(selectionProject ?? continuationScopeProject ? { project: (selectionProject ?? continuationScopeProject) } : {}),
1166
1220
  ...(selectionProjectNew ? { project_new: selectionProjectNew } : {}),
1167
1221
  ...(selectionModel ? { model: selectionModel } : {}),
1168
1222
  ...(selectionProMode ? { pro_mode: selectionProMode } : {}),
@@ -1307,10 +1361,7 @@ export async function runAskProCommand(rest, io) {
1307
1361
  // "project not found" error). Local stdout/stderr keep it (useful to the
1308
1362
  // operator), but the persisted task/session cross the MCP boundary, so
1309
1363
  // scrub the project name there the same way provenance.project is redacted.
1310
- const redactProject = (text) => {
1311
- const name = selectionMetadata.project;
1312
- return name ? text.split(name).join("<project>") : text;
1313
- };
1364
+ const redactProject = (text) => redactProjectNames(text, [selectionMetadata.project, selectionMetadata.project_new]);
1314
1365
  // Where the prompt actually landed beats where the caller aimed: with
1315
1366
  // --new-chat there is no target url, and a blocker that started a run
1316
1367
  // still has a thread worth handing back.
@@ -1359,13 +1410,21 @@ export async function runAskProCommand(rest, io) {
1359
1410
  (consult.modelSlug ? ` - it answered as "${consult.modelSlug}"` : "") +
1360
1411
  ". Pin one with `prodex setup --model Pro` or pass --model/--effort.");
1361
1412
  }
1362
- // In-project threads carry the project slug in their URL
1363
- // (/g/g-p-<project>/c/<id>); a bare /c/<id> after requesting a project
1364
- // means the thread landed at root - say so instead of leaving it to a
1365
- // sidebar audit (field-verified failure mode).
1366
- if ((selectionMetadata.project || selectionMetadata.project_new) && !/\/g\/g-p-/.test(consult.url ?? "")) {
1367
- persistenceWarnings.push("project_landing_warning: a project was requested but the answered thread URL is a root /c/ thread, so it likely landed OUTSIDE the project. Move it via the thread menu (Move to project) or re-run; list projects with `prodex pro browser projects`.");
1368
- }
1413
+ // Where the answer actually IS, checked rather than assumed: the project
1414
+ // id the composer bound to before typing, against the project the
1415
+ // answered thread belongs to. The requested name is intent - a send that
1416
+ // ended up elsewhere was recorded under the name of the place it never
1417
+ // reached.
1418
+ const continuationProjectId = continuedFromTaskId ? chatGptProjectIdFromUrl(normalizedTargetUrl) : undefined;
1419
+ const destination = destinationVerification({
1420
+ requestedProject: Boolean(selectionMetadata.project || selectionMetadata.project_new),
1421
+ ...(consult.boundProjectId ?? continuationProjectId
1422
+ ? { boundProjectId: (consult.boundProjectId ?? continuationProjectId) }
1423
+ : {}),
1424
+ ...(consult.url ? { answeredUrl: consult.url } : {})
1425
+ });
1426
+ if (destination.warning)
1427
+ persistenceWarnings.push(destination.warning);
1369
1428
  // Truncation and other send warnings must be visible at runtime, not
1370
1429
  // only inside the persisted receipt: a caller who never opens .bridge
1371
1430
  // would otherwise treat a cut-off answer as complete.
@@ -1414,6 +1473,14 @@ export async function runAskProCommand(rest, io) {
1414
1473
  // receipt used to record only what prodex asked for.
1415
1474
  ...(consult.modelSlug ? { model_used: consult.modelSlug } : {}),
1416
1475
  ...(proVerified !== undefined ? { pro_verified: proVerified } : {}),
1476
+ // Intent and evidence, kept apart. `selection` is what was asked
1477
+ // for; this is where the answer turned out to be, and whether
1478
+ // anything actually confirmed it.
1479
+ ...(continuedFromTaskId ? { continued_from: continuedFromTaskId } : {}),
1480
+ destination: {
1481
+ observed: destination.destination,
1482
+ ...(destination.verified !== undefined ? { verified: destination.verified } : {})
1483
+ },
1417
1484
  warnings: persistenceWarnings
1418
1485
  }
1419
1486
  });
@@ -1579,6 +1646,8 @@ export async function performBrowserConsultForMcp(cwd, input, onProgress) {
1579
1646
  ...(input.attach ?? []).flatMap((file) => ["--attach", file]),
1580
1647
  ...(input.tools ?? []).flatMap((tool) => ["--tool", tool]),
1581
1648
  ...(input.new_chat ? ["--new-chat"] : []),
1649
+ ...(input.continue_thread ? ["--continue"] : []),
1650
+ ...(input.continue_task !== undefined ? ["--continue-task", input.continue_task] : []),
1582
1651
  ...(input.allow_model_fallback ? ["--allow-model-fallback"] : []),
1583
1652
  "--",
1584
1653
  input.prompt
@@ -1823,6 +1892,54 @@ export function temporaryProjectConflict(input) {
1823
1892
  return (`--temporary and --project cannot be combined: a temporary chat is never saved, and a chat inside a project is. ` +
1824
1893
  `Drop --temporary to send into "${input.explicitProject}", or drop --project to send a throwaway chat.`);
1825
1894
  }
1895
+ /**
1896
+ * What a send actually selects, given the per-ask flags and the persisted
1897
+ * defaults.
1898
+ *
1899
+ * Explicit flags beat persisted defaults - except that a saved effort used to
1900
+ * beat an explicit `--model Pro`, because Pro IS the top step of the effort
1901
+ * slider: setting any other step deselects it. So the send ran at the saved
1902
+ * effort, the answer came from a lesser model, and the warning about it told
1903
+ * the caller to clear a saved MODEL default, which was not what overrode
1904
+ * anything. Asking for Pro on the model axis now suppresses a saved effort
1905
+ * exactly as `--effort` suppresses a saved model. A saved pro_mode survives:
1906
+ * it only refines Pro.
1907
+ *
1908
+ * Combining an explicit model with an explicit effort is left alone - that is
1909
+ * the caller saying both out loud, and the picker warns about it.
1910
+ */
1911
+ export function resolveSelectionAxes(input) {
1912
+ const { explicit } = input;
1913
+ const defaults = input.defaults;
1914
+ const reasoningAxisChosen = explicit.proMode !== undefined || explicit.effort !== undefined;
1915
+ const explicitlyPro = explicit.model !== undefined && namesPro(explicit.model);
1916
+ const model = explicit.model ?? (explicit.effort !== undefined ? undefined : defaults?.model);
1917
+ const proMode = explicit.proMode ?? (reasoningAxisChosen ? undefined : defaults?.pro_mode);
1918
+ const effort = explicit.effort ?? (reasoningAxisChosen || explicitlyPro ? undefined : defaults?.effort);
1919
+ return {
1920
+ ...(model !== undefined ? { model } : {}),
1921
+ ...(proMode !== undefined ? { proMode } : {}),
1922
+ ...(effort !== undefined ? { effort } : {})
1923
+ };
1924
+ }
1925
+ /**
1926
+ * Scrub project names out of text that gets persisted.
1927
+ *
1928
+ * Both names count. A send that CREATES its project names it in exactly the
1929
+ * same failures - the binding refusal, the composer that never appeared, the
1930
+ * sidebar click that missed - and only the requested name was ever scrubbed,
1931
+ * so those records kept a real project name while the equivalent record for an
1932
+ * existing project did not.
1933
+ */
1934
+ export function redactProjectNames(text, names) {
1935
+ let redacted = text;
1936
+ // Longest first: a project named "Notes" inside "Notes Archive" would
1937
+ // otherwise leave "<project> Archive" behind.
1938
+ for (const name of [...names].filter((name) => Boolean(name)).sort((a, b) => b.length - a.length)) {
1939
+ redacted = redacted.split(name).join("<project>");
1940
+ }
1941
+ return redacted;
1942
+ }
1826
1943
  export function browserSendBlockerFromError(error) {
1827
1944
  const blocker = typeof error === "object" && error !== null && "blocker" in error ? error.blocker : undefined;
1828
1945
  if (typeof blocker === "object" &&
@@ -1888,6 +2005,18 @@ export function browserSendBlockerFromError(error) {
1888
2005
  next_step: "Another prodex send holds the browser. Wait for it to finish and retry, or pass a longer --timeout-ms, which is also the queue budget."
1889
2006
  };
1890
2007
  }
2008
+ // The composer would have posted somewhere other than the project that was
2009
+ // asked for, so nothing was sent. A prompt that lands in another project is
2010
+ // worse than a blocker: the receipt records the project the caller asked for,
2011
+ // and the answer is somewhere nobody is looking.
2012
+ if (/composer did not bind to project/.test(message)) {
2013
+ return {
2014
+ code: "project_not_bound",
2015
+ message,
2016
+ retryable: true,
2017
+ next_step: "Nothing was sent, so nothing landed in the wrong project. Retry - the composer normally binds on the next navigation - or open the project once in the visible browser and send again."
2018
+ };
2019
+ }
1891
2020
  // The picker could not provide the step that was asked for. Retrying asks
1892
2021
  // the same picker the same question, so this is not retryable; the caller
1893
2022
  // either picks a step it offers or opts into whatever the slider is on.
package/dist/config.js CHANGED
@@ -208,22 +208,56 @@ export function envBrowserDefaults() {
208
208
  });
209
209
  return (model || project) && freeText.success ? freeText.data : undefined;
210
210
  }
211
+ /**
212
+ * Combine the global env defaults with this repo's.
213
+ *
214
+ * The project is independent of the rest, so the repo's wins that field and
215
+ * the env fills it in. The model and the two reasoning fields are NOT
216
+ * independent: an effort is a step ChatGPT deselects the model to reach, and a
217
+ * pro_mode only refines Pro. Merging those field-by-field built a request
218
+ * neither side asked for - a repo pinning `model: Pro` next to
219
+ * PRODEX_DEFAULT_EFFORT ran at the effort and dropped Pro - so whichever side
220
+ * names the reasoning selection provides all of it.
221
+ */
222
+ export function mergeBrowserDefaultSources(env, repo) {
223
+ if (!repo && !env)
224
+ return undefined;
225
+ const namesSelection = (defaults) => Boolean(defaults && (defaults.model !== undefined || defaults.pro_mode !== undefined || defaults.effort !== undefined));
226
+ const selection = namesSelection(repo) ? repo : env;
227
+ const merged = {
228
+ ...(selection?.model !== undefined ? { model: selection.model } : {}),
229
+ ...(selection?.pro_mode !== undefined ? { pro_mode: selection.pro_mode } : {}),
230
+ ...(selection?.effort !== undefined ? { effort: selection.effort } : {})
231
+ };
232
+ const project = repo?.project ?? env?.project;
233
+ if (project !== undefined)
234
+ merged.project = project;
235
+ return Object.keys(merged).length > 0 ? merged : undefined;
236
+ }
211
237
  // Read persisted browser-selection defaults without failing when the local
212
238
  // config is absent or unrelated to this cwd (defaults are optional convenience).
213
- // Per-repo config wins field-by-field; PRODEX_DEFAULT_* env vars are the global
214
- // fallback so a pinned default project/model applies from any cwd.
239
+ // The repo's config provides the project and, if it names any of them, the
240
+ // reasoning selection; PRODEX_DEFAULT_* env vars are the global fallback so a
241
+ // pinned default project/model applies from any cwd.
215
242
  export async function loadBrowserDefaults(cwd) {
216
243
  const env = envBrowserDefaults();
217
244
  let repo;
218
245
  try {
219
246
  repo = (await loadLocalConfig(cwd)).browser_defaults;
220
247
  }
221
- catch {
248
+ catch (error) {
249
+ // Having no config is the ordinary case - browser sends work without one -
250
+ // and stays silent. A config that EXISTS and cannot be read is a different
251
+ // thing, and swallowing it was the quiet failure: the defaults it pins
252
+ // stop applying with nothing said, so a consult that should have landed in
253
+ // a project lands in the general chat and looks like it worked.
254
+ if (!isMissingFileError(error)) {
255
+ throw new Error(`${error instanceof Error ? error.message : String(error)} Until then prodex will not apply the browser defaults ` +
256
+ `pinned there (project, model), so pass them explicitly if you need to send before fixing it.`, { cause: error });
257
+ }
222
258
  repo = undefined;
223
259
  }
224
- if (!repo && !env)
225
- return undefined;
226
- return { ...(env ?? {}), ...(repo ?? {}) };
260
+ return mergeBrowserDefaultSources(env, repo);
227
261
  }
228
262
  export function getTokenExpiryStatus(config, now = new Date()) {
229
263
  if (!config.token_expires_at) {
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Which conversation a follow-up consult belongs to.
3
+ *
4
+ * "Continue" used to mean "whatever thread the shared browser tab is showing",
5
+ * which is not a conversation anyone named: another session, or a person
6
+ * clicking around, moves it. Worse, a pinned project navigates AWAY from that
7
+ * tab before every send, so on a machine with a default project every consult
8
+ * started a fresh thread while the tool description promised the opposite
9
+ * (measured: two consecutive sends into one project landed in two different
10
+ * /c/ threads).
11
+ *
12
+ * prodex already writes down where each consult landed. That record - not the
13
+ * tab - is what a follow-up should resolve against. Pure on purpose: the
14
+ * reading lives in the command.
15
+ */
16
+ /**
17
+ * The project name as it appears inside a thread URL.
18
+ *
19
+ * Measured: a project named "prodex-smoke-project" answers on
20
+ * `/g/g-p-<id>-prodex-smoke-project/c/<id>`, and "Codex" on
21
+ * `/g/g-p-<id>-codex/c/<id>` - the name lowercased, with runs of anything else
22
+ * collapsed to a single dash.
23
+ */
24
+ export function chatGptProjectSlug(name) {
25
+ return name
26
+ .trim()
27
+ .toLowerCase()
28
+ .replace(/[^a-z0-9]+/g, "-")
29
+ .replace(/^-+|-+$/g, "");
30
+ }
31
+ /**
32
+ * Whether a recorded thread belongs to the project this send is for.
33
+ *
34
+ * A send with no project continues only a thread that belongs to no project,
35
+ * so a follow-up meant for the general chat cannot walk into a project - and a
36
+ * project's follow-up cannot land in another project's conversation.
37
+ */
38
+ export function threadMatchesProject(threadUrl, project) {
39
+ const projectSegment = /\/g\/(g-p-[^/?#]+)/.exec(threadUrl)?.[1];
40
+ if (!project)
41
+ return projectSegment === undefined;
42
+ if (!projectSegment)
43
+ return false;
44
+ const slug = chatGptProjectSlug(project);
45
+ if (!slug)
46
+ return false;
47
+ // The id comes first and the name follows it, so an exact suffix match keeps
48
+ // "notes" from answering for "notes-archive".
49
+ return projectSegment.toLowerCase().endsWith(`-${slug}`);
50
+ }
51
+ /**
52
+ * The thread a follow-up should continue, or why it cannot be resolved.
53
+ *
54
+ * Naming a task wins over the search, because the caller who names one knows
55
+ * which conversation they mean. Otherwise it is the most recent consult that
56
+ * finished, in this project - fail-closed when there is none, since guessing
57
+ * the conversation is the failure this exists to prevent.
58
+ */
59
+ export function resolveContinuationThread(input) {
60
+ const withThread = input.consults.filter((consult) => Boolean(consult.thread));
61
+ if (input.taskId) {
62
+ const named = withThread.find((consult) => consult.taskId === input.taskId);
63
+ if (!named) {
64
+ return {
65
+ error: `No recorded consult thread for "${input.taskId}". List what is here with \`prodex pro list\`, ` +
66
+ `or pass the thread itself with --target-url --confirm-target.`
67
+ };
68
+ }
69
+ return { target: { taskId: named.taskId, thread: named.thread } };
70
+ }
71
+ const candidates = withThread
72
+ .filter((consult) => consult.status === "done")
73
+ .filter((consult) => threadMatchesProject(consult.thread, input.project))
74
+ .sort((a, b) => (b.createdAt ?? "").localeCompare(a.createdAt ?? ""));
75
+ const latest = candidates[0];
76
+ if (!latest) {
77
+ const where = input.project ? `project "${input.project}"` : "a chat outside any project";
78
+ return {
79
+ error: `No finished consult of this repo has a thread in ${where} to continue. ` +
80
+ `Send once without --continue, or name a consult with --continue-task <task_id>.`
81
+ };
82
+ }
83
+ return { target: { taskId: latest.taskId, thread: latest.thread } };
84
+ }
package/dist/mcp.js CHANGED
@@ -162,7 +162,7 @@ export function createServer(cwd = process.cwd(), options = {}) {
162
162
  const browserConsult = options.browserConsult;
163
163
  if (browserConsult) {
164
164
  server.registerTool("pro_consult", {
165
- description: "Ask the user's logged-in ChatGPT (Pro) in the visible browser and wait for the full answer. This drives a real browser send: it can take minutes (Pro extended reasoning), is human-paced, and records a durable receipt under .bridge/. Requires a running `prodex pro browser login` session. By DEFAULT the consult continues in the currently-open thread, so consecutive follow-ups on the same topic stay in one conversation (keeps context, avoids sidebar clutter). Pass new_chat:true ONLY to start a fresh thread for a genuinely new topic. If the thread is still generating a previous answer, the send automatically queues behind it (up to the timeout budget) - long 'tab busy' progress is normal, not stuck. `project` and `model` come from saved defaults (per-repo config, or PRODEX_DEFAULT_PROJECT / PRODEX_DEFAULT_MODEL env vars) when omitted - do NOT pass them per-call unless deliberately overriding. Returns task_id, thread URL, and the answer text.",
165
+ description: "Ask the user's logged-in ChatGPT (Pro) in the visible browser and wait for the full answer. This drives a real browser send: it can take minutes (Pro extended reasoning), is human-paced, and records a durable receipt under .bridge/. Requires a running `prodex pro browser login` session. By default the consult continues in whatever thread the browser tab is showing - EXCEPT when a project applies (passed here, or pinned as a saved default), because entering a project starts a new chat in it. To follow up on a previous consult, pass continue_thread:true: it resolves the thread from prodex's own records - the newest finished consult of the same project - instead of trusting the shared tab, and continue_task with a task_id names one exactly. Pass new_chat:true to start a fresh thread for a genuinely new topic. If the thread is still generating a previous answer, the send automatically queues behind it (up to the timeout budget) - long 'tab busy' progress is normal, not stuck. `project` and `model` come from saved defaults (per-repo config, or PRODEX_DEFAULT_PROJECT / PRODEX_DEFAULT_MODEL env vars) when omitted - do NOT pass them per-call unless deliberately overriding. Returns task_id, thread URL, and the answer text.",
166
166
  inputSchema: {
167
167
  prompt: McpBridgeTextSchema.min(1),
168
168
  model: McpShortTextSchema.optional(),
@@ -187,7 +187,17 @@ export function createServer(cwd = process.cwd(), options = {}) {
187
187
  new_chat: z
188
188
  .boolean()
189
189
  .optional()
190
- .describe("Start a fresh thread. Omit to continue the current thread (preferred for follow-ups)."),
190
+ .describe("Start a fresh thread for a new topic."),
191
+ continue_thread: z
192
+ .boolean()
193
+ .optional()
194
+ .describe("Follow up inside the conversation a previous consult is already in, resolved from prodex's records: the newest finished consult of the same project. This is the reliable way to keep a follow-up in one conversation - the tab is shared, and a project default starts a new chat on every send. Fails rather than guessing when this project has no finished consult yet."),
195
+ continue_task: z
196
+ .string()
197
+ .min(1)
198
+ .max(200)
199
+ .optional()
200
+ .describe("Continue one NAMED past consult by its task_id, when the newest one is not the conversation meant."),
191
201
  allow_model_fallback: z
192
202
  .boolean()
193
203
  .optional()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@youdie006/prodex",
3
- "version": "0.40.1",
3
+ "version": "0.40.3",
4
4
  "description": "Local receipt bus for coordinating Codex execution with ChatGPT Pro/Projects consultation.",
5
5
  "author": "youdie006",
6
6
  "license": "MIT",