@quantiya/codevibe-core 2.0.84 → 2.0.86

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.
@@ -84,7 +84,7 @@ interface ShadowMarkerScan {
84
84
  detail: string;
85
85
  }>;
86
86
  }
87
- export declare function scanShadowMarkers(env?: ShadowEnv): Promise<ShadowMarkerScan>;
87
+ export declare function scanShadowMarkers(env?: ShadowEnv, ownedTaskIds?: ReadonlySet<string>): Promise<ShadowMarkerScan>;
88
88
  export declare function reconcileExposureRetentions(retentions: ShadowMarkerScan['exposureRetentions'], recovered: readonly RecoveredShadow[], physicalCopyScope: string, env: ShadowEnv, retained: string[], snapshotIncarnations: SnapshotIncarnationIndex | null): Promise<void>;
89
89
  export declare function reclaimDisplacedShadow(record: DisplacedShadowMarkerRecord, env: ShadowEnv, physicalCopyScope: string, opts: {
90
90
  allowLiveOwner: boolean;
@@ -110,7 +110,7 @@ export declare function reconcileDisplacedSnapshots(records: readonly DisplacedS
110
110
  * self-consistent pair. A v2 root of a format this desktop does not know is list-only, so it is not offered for
111
111
  * recovery at all — recovery acts on what it is given.
112
112
  */
113
- export declare function listRecoverableShadows(env?: ShadowEnv): Promise<RecoveredShadow[]>;
113
+ export declare function listRecoverableShadows(env?: ShadowEnv, ownedTaskIds?: ReadonlySet<string>): Promise<RecoveredShadow[]>;
114
114
  /** `env` pinned to one root pair, so every default inside a pass resolves to that pair and nothing else. */
115
115
  export declare function pairEnv(env: ShadowEnv, pass: {
116
116
  stateRootDir: string;
@@ -35885,14 +35885,6 @@ function attachmentsToPipelineImages(attachments) {
35885
35885
  read: () => readImageFdSafe(attachment.sourcePath, MAX_IMAGE_BYTES)
35886
35886
  }));
35887
35887
  }
35888
- function isBlindImageClarification(prompt, clarifyingQuestion) {
35889
- if (clarifyingQuestion && clarifyingQuestion.trim().length > 0) {
35890
- let q = clarifyingQuestion.toLowerCase();
35891
- return /what .*like me to do with the (screenshot|image)/i.test(q) || /what .*want me to do with the (screenshot|image)/i.test(q) || /how should i use (that|this) information/i.test(q) || /information from the (screenshot|image)/i.test(q) || /rephrase that as a specific command or request/i.test(q) || /cannot (see|view|read|inspect) (the )?(image|screenshot)/i.test(q) || /describe what you('d| would) like me to do with (the )?(screenshot|image)/i.test(q);
35892
- }
35893
- let p = prompt.toLowerCase();
35894
- return /what('s| is| do you see) (in |on )?(the |this )?(screenshot|image|picture)/i.test(p) || /what does (the |this )?(screenshot|image|picture) (show|contain|depict)/i.test(p) || /what (shape|color|text) is (in |on )?(this |the )?(image|screenshot)/i.test(p);
35895
- }
35896
35888
 
35897
35889
  // src/orchestration-shell/slash-suggest.ts
35898
35890
  function isSlashCommandInProgress(value) {
@@ -46359,7 +46351,24 @@ async function readAnchoredStateMarkerSnapshotForScan(stateRootAuthority, stateD
46359
46351
  }
46360
46352
  };
46361
46353
  }
46362
- async function scanShadowMarkers(env = {}) {
46354
+ function pinShadowTaskScope(ownedTaskIds) {
46355
+ let taskScope = ownedTaskIds === void 0 ? void 0 : new Set(ownedTaskIds);
46356
+ if (taskScope)
46357
+ for (let taskId of taskScope) {
46358
+ if (taskId.length === 0) throw new Error("WorkspaceShadow: empty owned task id");
46359
+ assertSafeStateComponent(taskId);
46360
+ }
46361
+ return taskScope;
46362
+ }
46363
+ async function scanShadowMarkers(env = {}, ownedTaskIds) {
46364
+ let taskScope = pinShadowTaskScope(ownedTaskIds);
46365
+ if (taskScope?.size === 0) return {
46366
+ recovered: [],
46367
+ exposureRetentions: [],
46368
+ displacedSnapshots: [],
46369
+ protectedDirNames: /* @__PURE__ */ new Set(),
46370
+ unresolved: []
46371
+ };
46363
46372
  let helperTimeout = env.helperTimeoutMs ?? env.workspaceAuthorityHelperTimeoutMs ?? (env.signal ? 2e3 : void 0), maxStateMarkerBytes = resolveStateMarkerByteLimit(env), requestedStateRoot = env.stateRootDir ?? defaultStateRoot(), requestedShadowRoot = (await resolveShadowRoots(env)).shadowRootDir;
46364
46373
  if (env.signal?.aborted) return { recovered: [], exposureRetentions: [], displacedSnapshots: [], protectedDirNames: /* @__PURE__ */ new Set(), unresolved: [] };
46365
46374
  let stateRootAuthority = await captureWorkspaceRootAuthority(requestedStateRoot, {
@@ -46413,7 +46422,9 @@ async function scanShadowMarkers(env = {}) {
46413
46422
  for (let taskEntry of entries) {
46414
46423
  if (env.signal?.aborted) break;
46415
46424
  if (isStateRootInfrastructureDirectory(taskEntry.name) || !taskEntry.isDirectory() || taskEntry.isSymbolicLink()) continue;
46416
- let taskId = taskEntry.name, stateDir = path54.join(stateRoot, taskId), stateDirAuthority;
46425
+ let taskId = taskEntry.name;
46426
+ if (taskScope && !taskScope.has(taskId)) continue;
46427
+ let stateDir = path54.join(stateRoot, taskId), stateDirAuthority;
46417
46428
  try {
46418
46429
  stateDirAuthority = await captureWorkspaceRootAuthority(stateDir, {
46419
46430
  helperTimeoutMs: helperTimeout,
@@ -47075,7 +47086,9 @@ async function reconcileDisplacedSnapshots(records, keepTaskIds, ttlMs, now, phy
47075
47086
  });
47076
47087
  }
47077
47088
  }
47078
- async function listRecoverableShadows(env = {}) {
47089
+ async function listRecoverableShadows(env = {}, ownedTaskIds) {
47090
+ let taskScope = pinShadowTaskScope(ownedTaskIds);
47091
+ if (taskScope?.size === 0) return [];
47079
47092
  let out = [];
47080
47093
  for (let pass of await shadowRootPasses(env)) {
47081
47094
  if (!await passIsActionable(pass)) {
@@ -47084,7 +47097,7 @@ async function listRecoverableShadows(env = {}) {
47084
47097
  });
47085
47098
  continue;
47086
47099
  }
47087
- let scan = await scanShadowMarkers(pairEnv(env, pass));
47100
+ let scan = await scanShadowMarkers(pairEnv(env, pass), taskScope);
47088
47101
  for (let recovered of scan.recovered)
47089
47102
  out.push({ ...recovered, rootPair: { stateRootDir: pass.stateRootDir, shadowRootDir: pass.shadowRootDir } });
47090
47103
  }
@@ -47178,16 +47191,18 @@ async function reconcileShadowPublicationAuthorityInPair(taskIds, env) {
47178
47191
  );
47179
47192
  }
47180
47193
  async function listShadowCleanupResidue(taskIds, env = {}) {
47194
+ let taskScope = pinShadowTaskScope(taskIds);
47195
+ if (taskScope.size === 0) return [];
47181
47196
  let residue = [];
47182
47197
  for (let pass of await shadowRootPasses(env))
47183
- residue.push(...await listShadowCleanupResidueInPair(taskIds, pairEnv(env, pass)));
47198
+ residue.push(...await listShadowCleanupResidueInPair(taskScope, pairEnv(env, pass)));
47184
47199
  return residue;
47185
47200
  }
47186
47201
  async function listShadowCleanupResidueInPair(taskIds, env) {
47187
47202
  if (taskIds.size === 0) return [];
47188
47203
  for (let taskId of taskIds)
47189
47204
  if (taskId.length === 0 || taskId === "." || taskId === ".." || taskId.includes("\0") || path54.basename(taskId) !== taskId) throw new Error("invalid owned task id for workspace cleanup audit");
47190
- let scan = await scanShadowMarkers(env), residue = [], add = (record2) => {
47205
+ let scan = await scanShadowMarkers(env, taskIds), residue = [], add = (record2) => {
47191
47206
  taskIds.has(record2.taskId) && (residue.some(
47192
47207
  (item2) => item2.taskId === record2.taskId && item2.path === record2.path && item2.kind === record2.kind
47193
47208
  ) || residue.push(record2));
@@ -60849,7 +60864,7 @@ var LocalExecutorImpl = class {
60849
60864
  try {
60850
60865
  [canonicalRepo, recovered, owner] = await Promise.all([
60851
60866
  captureWorkspaceRootAuthority(repoRoot).then((value) => value.canonicalPath),
60852
- listRecoverableShadows(env),
60867
+ listRecoverableShadows(env, this.integrationTaskIdsOwned),
60853
60868
  currentProcessIdentity()
60854
60869
  ]);
60855
60870
  } catch (err) {
@@ -67567,34 +67582,6 @@ function isWebAccessNeeded(text2) {
67567
67582
  text2
67568
67583
  ));
67569
67584
  }
67570
- function hasFileMutationIntent(text2) {
67571
- if (!text2 || typeof text2 != "string") return !1;
67572
- let stripped = stripLeadingAgentControlToken(text2).trim(), textWithoutUrls = stripped.replace(/https?:\/\/[^\s]+/gi, " ").trim();
67573
- if (/\b(?:how\s+(?:to|do\s+I|can\s+I)|explain\s+how\s+to|tell\s+me\s+how\s+to)\b/i.test(stripped) || /(?:^|[.?!;])\s*(?:what\s+(?:is|are)\b|c[oó]mo\s+(?:hacer|puedo|se\s+puede|escribir|guardar|crear)|comment\s+(?:faire|écrire|sauvegarder|créer|enregistrer)|wie\s+(?:kann\s+ich|macht\s+man|schreibt\s+man|speichert\s+man|erstellt\s+man))\b/i.test(stripped) || /(?:如何|怎么|怎样|告诉我(?:如何|怎么|怎样)|解释如何|请问|什么是)/.test(stripped) || /(?:どうやって|方法(?:を(?:教えて|説明して))|やり方を教えて|でしょうか|とは(?:何|なん)ですか)/.test(stripped) || /(?:어떻게|방법을?\s*(?:알려줘|설명해줘)|법\s*설명|하는지\s*알려줘)/.test(stripped))
67574
- return !1;
67575
- if (/>{1,2}\s*[\w./-]+\b/.test(textWithoutUrls))
67576
- return !0;
67577
- let fileExt = "(?:md|markdown|txt|json|csv|ts|js|tsx|jsx|py|html|css|yaml|yml|log|sh|xml|toml|sql|env)", writeToFilePatternEn = new RegExp(
67578
- `\\b(?:write|save|create|dump|output|put|export|store|record|guardar|escribir|crear|enregistrer|\xE9crire|cr\xE9er|sauvegarder|speichern|schreiben|erstellen)\\b[\\s\\S]*?\\b(?:into|to|in|as|en|dans|auf|zu)\\b(?!\\s+(?:chat|console|stdout|screen|terminal)\\b)[\\s\\S]*?(?:(?:a|an|the|un|une|ein|eine|el|la)?\\s*file(?:\\s+named|\\s+called)?\\s+)?[\\w./-]+\\.${fileExt}\\b`,
67579
- "i"
67580
- ), writeToFilePatternGermanic = new RegExp(
67581
- `\\b(?:in|auf|zu|into|to)\\s+[\\w./-]+\\.${fileExt}[\\s\\S]*?\\b(?:speichern|schreiben|erstellen|ablegen)\\b`,
67582
- "i"
67583
- ), namedFilePatternEn = /\b(?:into|to|in|en|dans|auf|zu)\s+(?:a|an|un|une|ein|eine|el|la)?\s*file(?:\s+(?:named|called))?\s+[\w./-]+\b/i, createFilePatternEn = /\b(?:create|add|touch)\s+(?:a|an|the)?\s*(?:new\s+)?(?:file|markdown\s+file|script)\b/i, directFileVerbPatternEn = new RegExp(
67584
- `\\b(?:create|write|touch|add|crear|escribir|cr\xE9er|\xE9crire|erstellen)\\s+[\\w./-]+\\.${fileExt}\\b`,
67585
- "i"
67586
- ), writeToFilePatternZh = new RegExp(
67587
- `(?:\u5199\u5165|\u4FDD\u5B58\u5230?|\u521B\u5EFA|\u751F\u6210|\u8F93\u51FA\u5230|\u5B58\u5165|\u5BFC\u51FA\u5230?|\u8BB0\u5F55\u5230?)[\\s\\S]*?[\\w./-]+\\.${fileExt}\\b`,
67588
- "i"
67589
- ), writeToFilePatternJa = new RegExp(
67590
- `(?:[\\w./-]+\\.${fileExt}[\\s\\S]*?(?:\u306B|\u3078)?\\s*(?:\u66F8\u304D\u51FA|\u4FDD\u5B58|\u4F5C\u6210|\u751F\u6210|\u51FA\u529B|\u8A18\u9332|\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8)|(?:\u66F8\u304D\u51FA|\u4FDD\u5B58|\u4F5C\u6210|\u751F\u6210|\u51FA\u529B|\u8A18\u9332|\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8)[\\s\\S]*?[\\w./-]+\\.${fileExt})`,
67591
- "i"
67592
- ), writeToFilePatternKo = new RegExp(
67593
- `(?:[\\w./-]+\\.${fileExt}[\\s\\S]*?(?:\uC5D0|\uC73C\uB85C|\uB85C)?\\s*(?:\uC800\uC7A5|\uC791\uC131|\uC0DD\uC131|\uAE30\uB85D|\uCD9C\uB825|\uB0B4\uBCF4\uB0B4\uAE30)|(?:\uC800\uC7A5|\uC791\uC131|\uC0DD\uC131|\uAE30\uB85D|\uCD9C\uB825|\uB0B4\uBCF4\uB0B4\uAE30)[\\s\\S]*?[\\w./-]+\\.${fileExt})`,
67594
- "i"
67595
- );
67596
- return writeToFilePatternEn.test(textWithoutUrls) || writeToFilePatternGermanic.test(textWithoutUrls) || namedFilePatternEn.test(textWithoutUrls) || createFilePatternEn.test(textWithoutUrls) || directFileVerbPatternEn.test(textWithoutUrls) || writeToFilePatternZh.test(textWithoutUrls) || writeToFilePatternJa.test(textWithoutUrls) || writeToFilePatternKo.test(textWithoutUrls);
67597
- }
67598
67585
 
67599
67586
  // src/orchestration-shell/quorum-loop.ts
67600
67587
  var CONTINUATION_EXPIRES_TTL_MS = 1440 * 60 * 1e3, ACTIVE_AGENT_KINDS = ["CLAUDE", "CODEX", "ANTIGRAVITY"], TEAM_RECOVERY_RELAUNCH_CONCURRENCY = 3;
@@ -74246,7 +74233,8 @@ ${section}`);
74246
74233
  * unresolved authority are preserved, but returned as explicit failures.
74247
74234
  */
74248
74235
  async cleanupOwnedTaskSnapshots(taskIds, context) {
74249
- let failures = [], attemptFailures = [], env = this.deps.shadowEnv ?? {};
74236
+ if (taskIds.size === 0) return [];
74237
+ let failures = [], attemptFailures = [], env = this.deps.shadowEnv ?? {}, cleanupStartedAt = Date.now();
74250
74238
  (await Promise.allSettled([...taskIds].map(
74251
74239
  (taskId) => this.runExclusiveShadowOp(taskId, async () => {
74252
74240
  let shadow = this.shadowsByTask.get(taskId);
@@ -74258,11 +74246,11 @@ ${section}`);
74258
74246
  `${context} mapped workspace ${[...taskIds][index]} disposal failed`
74259
74247
  ));
74260
74248
  });
74261
- let canonicalWorkingDir, recovered, currentOwner;
74249
+ let mappedSettledAt = Date.now(), canonicalWorkingDir, recovered, currentOwner;
74262
74250
  try {
74263
74251
  [canonicalWorkingDir, recovered, currentOwner] = await Promise.all([
74264
74252
  captureWorkspaceRootAuthority(this.deps.workingDir).then((authority) => authority.canonicalPath),
74265
- (this.deps.shadowRecoveryOps?.listRecoverableShadows ?? listRecoverableShadows)(env),
74253
+ (this.deps.shadowRecoveryOps?.listRecoverableShadows ?? listRecoverableShadows)(env, taskIds),
74266
74254
  currentProcessIdentity()
74267
74255
  ]);
74268
74256
  } catch (err) {
@@ -74271,10 +74259,10 @@ ${section}`);
74271
74259
  `${context} durable workspace enumeration failed`
74272
74260
  )), failures.push(...attemptFailures), failures;
74273
74261
  }
74274
- let ownedRecovered = recovered.filter(
74262
+ let enumeratedAt = Date.now(), ownedRecovered = recovered.filter(
74275
74263
  (item2) => item2.workingDir === canonicalWorkingDir && taskIds.has(item2.taskId)
74276
74264
  );
74277
- if ((await Promise.allSettled(ownedRecovered.map(
74265
+ (await Promise.allSettled(ownedRecovered.map(
74278
74266
  (item2) => this.runExclusiveShadowOp(item2.taskId, async () => {
74279
74267
  if (!(item2.ownerProcessIdentity.pid === currentOwner.pid && item2.ownerProcessIdentity.incarnationId === currentOwner.incarnationId) && await isProcessIdentityAlive(item2.ownerProcessIdentity))
74280
74268
  throw new Error(
@@ -74295,7 +74283,9 @@ ${section}`);
74295
74283
  `${context} durable workspace ${item2.taskId} (${item2.stateFile}) disposal failed`
74296
74284
  ));
74297
74285
  }
74298
- }), !this.deps.shadowRecoveryOps)
74286
+ });
74287
+ let recoveredSettledAt = Date.now();
74288
+ if (!this.deps.shadowRecoveryOps)
74299
74289
  try {
74300
74290
  await reconcileShadowPublicationAuthority(taskIds, env);
74301
74291
  } catch (err) {
@@ -74306,7 +74296,7 @@ ${section}`);
74306
74296
  }
74307
74297
  try {
74308
74298
  let remaining;
74309
- this.deps.shadowRecoveryOps?.listShadowCleanupResidue ? remaining = await this.deps.shadowRecoveryOps.listShadowCleanupResidue(taskIds, env) : this.deps.shadowRecoveryOps?.listRecoverableShadows ? remaining = (await this.deps.shadowRecoveryOps.listRecoverableShadows(env)).filter(
74299
+ this.deps.shadowRecoveryOps?.listShadowCleanupResidue ? remaining = await this.deps.shadowRecoveryOps.listShadowCleanupResidue(taskIds, env) : this.deps.shadowRecoveryOps?.listRecoverableShadows ? remaining = (await this.deps.shadowRecoveryOps.listRecoverableShadows(env, taskIds)).filter(
74310
74300
  (item2) => item2.workingDir === canonicalWorkingDir && taskIds.has(item2.taskId)
74311
74301
  ).map((item2) => ({
74312
74302
  taskId: item2.taskId,
@@ -74330,7 +74320,15 @@ ${section}`);
74330
74320
  `${context} final durable workspace enumeration failed`
74331
74321
  )), failures.push(...attemptFailures);
74332
74322
  }
74333
- return failures;
74323
+ return logger.debug("[QuorumLoop] owned workspace cleanup phase durations", {
74324
+ context,
74325
+ taskCount: taskIds.size,
74326
+ recoveredCount: ownedRecovered.length,
74327
+ mappedRetirementMs: mappedSettledAt - cleanupStartedAt,
74328
+ durableEnumerationMs: enumeratedAt - mappedSettledAt,
74329
+ recoveredRetirementMs: recoveredSettledAt - enumeratedAt,
74330
+ publicationAndAuditMs: Date.now() - recoveredSettledAt
74331
+ }), failures;
74334
74332
  }
74335
74333
  async disposeWorkspaces(opts = {}) {
74336
74334
  let strict = opts.strict ?? !0;
@@ -83822,6 +83820,155 @@ var DEFAULT_REFRESH_MS = 300 * 1e3, MAX_RESOLUTION_TICK_ATTEMPTS = 12, TERMINAL_
83822
83820
  }
83823
83821
  };
83824
83822
 
83823
+ // src/orchestration-shell/gemma-intent-classifier.ts
83824
+ var INTENT_CLASSIFIER_JSON_SCHEMA = {
83825
+ type: "object",
83826
+ properties: {
83827
+ action: {
83828
+ type: "string",
83829
+ enum: ["start_task", "familiarize", "advisory_response", "browse", "brainstorm", "ask_user"]
83830
+ },
83831
+ is_code_or_disk_mutation: { type: "boolean" },
83832
+ confidence: { type: "string", enum: ["high", "low"] },
83833
+ requires_file_read: { type: "boolean" },
83834
+ rationale: { type: "string" }
83835
+ },
83836
+ required: ["action", "is_code_or_disk_mutation", "confidence", "requires_file_read", "rationale"]
83837
+ }, DEFAULT_INTENT_TIMEOUT_MS = 5e3, INTENT_MAX_OUTPUT_TOKENS = 256;
83838
+ function buildIntentClassifierPrompt(prompt, clarifications) {
83839
+ return [
83840
+ "You are a strict code/workspace intent classifier for CodeVibe.",
83841
+ "Analyze the user prompt and clarifications to determine whether the user is requesting a code or filesystem mutation, or an informational/read-only turn.",
83842
+ "Output STRICT JSON ONLY matching this schema:",
83843
+ '{"action": "start_task"|"familiarize"|"advisory_response"|"browse"|"brainstorm"|"ask_user", "is_code_or_disk_mutation": boolean, "confidence": "high"|"low", "requires_file_read": boolean, "rationale": "short explanation"}',
83844
+ "",
83845
+ "Rules:",
83846
+ '1. "is_code_or_disk_mutation": true if the user asks to create, modify, edit, delete, write, record, note, save, append, refactor, implement, or run code/tests/files on disk (e.g. "fix auth.ts", "delete temp.js", "create a React component", "run the test suite", "update the config file"). CRITICAL: writing, noting, recording, or saving data into any file (e.g. "note X in file.csv", "write X into file.txt", "record X in file.json") IS a disk mutation ("is_code_or_disk_mutation": true, "action": "start_task"). CRITICAL: adding comments to code or commenting helpers/functions in source files (e.g. "comment the helpers in auth.ts", "prepend a comment to auth.ts", "comment out the unused helpers") IS a code modification ("is_code_or_disk_mutation": true, "action": "start_task"), whereas providing commentary or feedback about code in chat (e.g. "comment on the logic in auth.ts", "comment on the error handling") is read-only ("is_code_or_disk_mutation": false, "action": "advisory_response").',
83847
+ '2. "is_code_or_disk_mutation": false for read-only understanding, file inspection, or informational questions (e.g. "What files are here?", "Summarize numbers in statement.pdf", "Explain how auth works", "Organize them by category in your response", "Explain what happens when I press tab and enter", "Read auth.ts and explain why we can populate the values in output.json"). Questions asking to explain why tests fail, analyze crashes, explain system behavior after a change, or explain why an action/step is taken (e.g. "Explain why we update config.json", "Explain why we read notice.pdf and redact the amounts", "Explain why we inspect auth.ts and note findings into report.md"), or asking to paste example commands in a chat reply, are explanatory inquiries ("is_code_or_disk_mutation": false, "action": "advisory_response") when no explicit disk edit is commanded.',
83848
+ "3. Action routing:",
83849
+ ' - "familiarize": Read-only overview or exploration of the project, folder, files, or workspace structure without file modification.',
83850
+ ' - "advisory_response": General questions, capability queries, or reading/summarizing/explaining specific files without disk mutation.',
83851
+ ' - "start_task": Direct request to modify code, edit files, fix bugs, implement features, or run commands on disk.',
83852
+ ' - "browse": Web browsing or search without disk mutation.',
83853
+ ' - "brainstorm": Exploring architecture choices or design options.',
83854
+ '4. "requires_file_read": true if answering the prompt requires reading or inspecting specific file(s) or document(s) in the workspace (e.g. "Tell me the wage amount from w2_2024_employer.txt", "Summarize statement.pdf", "Inspect auth.ts", "w2_2024_employer.txt"). false for general conceptual questions, project structure/familiarize, or questions not referencing specific workspace files.',
83855
+ '5. Conversational keypresses (e.g. "press enter", "hit tab") and data attributes (e.g. "comment text", "table columns") are NOT code or file mutations.',
83856
+ '6. If the request is ambiguous, self-contradictory, contains mixed read and write instructions, or you are uncertain, set "confidence": "low", "is_code_or_disk_mutation": true, and "action": "start_task".',
83857
+ "",
83858
+ clarifications && clarifications.length > 0 ? [
83859
+ "Prior clarifications in this turn:",
83860
+ ...clarifications.map((c, i) => `Q${i + 1}: ${c.question}
83861
+ A${i + 1}: ${c.answer}`),
83862
+ ""
83863
+ ].join(`
83864
+ `) : "",
83865
+ "=== BEGIN USER PROMPT ===",
83866
+ prompt,
83867
+ "=== END USER PROMPT ==="
83868
+ ].join(`
83869
+ `);
83870
+ }
83871
+ function parseIntentGemmaResponse(raw) {
83872
+ try {
83873
+ let parsed = JSON.parse(raw.trim());
83874
+ return typeof parsed != "object" || parsed === null || typeof parsed.is_code_or_disk_mutation != "boolean" || !["start_task", "familiarize", "advisory_response", "browse", "brainstorm", "ask_user"].includes(
83875
+ parsed.action
83876
+ ) || parsed.confidence !== "high" && parsed.confidence !== "low" || typeof parsed.rationale != "string" || parsed.rationale.trim().length === 0 || parsed.action === "start_task" && !parsed.is_code_or_disk_mutation || parsed.action !== "start_task" && parsed.is_code_or_disk_mutation || typeof parsed.requires_file_read != "boolean" ? null : {
83877
+ action: parsed.action,
83878
+ is_code_or_disk_mutation: !!parsed.is_code_or_disk_mutation,
83879
+ confidence: parsed.confidence,
83880
+ rationale: parsed.rationale.trim(),
83881
+ source: "model",
83882
+ requires_file_read: parsed.requires_file_read
83883
+ };
83884
+ } catch {
83885
+ return null;
83886
+ }
83887
+ }
83888
+ function failClosedDefault(rationale, source2 = "semantic_fail_closed") {
83889
+ return {
83890
+ action: "start_task",
83891
+ is_code_or_disk_mutation: !0,
83892
+ confidence: "low",
83893
+ rationale,
83894
+ source: source2,
83895
+ requires_file_read: !1
83896
+ };
83897
+ }
83898
+ function isInfrastructureTransportOutage(err) {
83899
+ if (!err || err instanceof GemmaPolicyError || err instanceof GemmaContextFullError || err instanceof GemmaEmptyOutputError || err instanceof GemmaHiddenTokenLoopError || err instanceof GemmaBackendTooOldError || err?.name === "GemmaPolicyError" || err?.name === "GemmaContextFullError" || err?.name === "GemmaEmptyOutputError" || err?.name === "GemmaHiddenTokenLoopError" || err?.name === "GemmaBackendTooOldError" || err?.name === "AssertionError" || err?.constructor?.name === "AssertionError")
83900
+ return !1;
83901
+ let errMessage = String(err?.message || ""), causeObj = err?.cause, causeMessage = String(causeObj?.message || "");
83902
+ if (/\b(?:has no classify|no classify)\b/i.test(errMessage) || /\b(?:has no classify|no classify)\b/i.test(causeMessage))
83903
+ return !1;
83904
+ let e = err, cause = e.cause || void 0, causeCode = String(cause?.code || ""), causeName = String(cause?.name || ""), nestedCause = cause?.cause || void 0, nestedCauseCode = String(nestedCause?.code || ""), nestedCauseName = String(nestedCause?.name || ""), deepCause = nestedCause?.cause || void 0, deepCauseCode = String(deepCause?.code || "");
83905
+ if (causeName === "AssertionError" || nestedCauseName === "AssertionError" || cause instanceof ReferenceError || cause instanceof RangeError || cause instanceof SyntaxError || nestedCause instanceof ReferenceError || nestedCause instanceof RangeError || nestedCause instanceof SyntaxError || causeName === "ReferenceError" || causeName === "RangeError" || causeName === "SyntaxError" || nestedCauseName === "ReferenceError" || nestedCauseName === "RangeError" || nestedCauseName === "SyntaxError")
83906
+ return !1;
83907
+ let networkCodes = [
83908
+ "ECONNREFUSED",
83909
+ "ENOTFOUND",
83910
+ "EAI_AGAIN",
83911
+ "EHOSTUNREACH",
83912
+ "ENETUNREACH",
83913
+ "ECONNRESET",
83914
+ "EPIPE",
83915
+ "ETIMEDOUT",
83916
+ "UND_ERR_CONNECT_TIMEOUT",
83917
+ "UND_ERR_SOCKET",
83918
+ "UND_ERR_HEADERS_TIMEOUT",
83919
+ "UND_ERR_BODY_TIMEOUT",
83920
+ "UND_ERR_DESTROYED",
83921
+ "UND_ERR_CLOSED"
83922
+ ];
83923
+ if (networkCodes.includes(causeCode) || networkCodes.includes(nestedCauseCode) || networkCodes.includes(deepCauseCode))
83924
+ return !0;
83925
+ if (err instanceof GemmaTransportError || err?.name === "GemmaTransportError")
83926
+ return cause instanceof TypeError || causeName === "TypeError" || nestedCause instanceof TypeError || nestedCauseName === "TypeError" ? !!(networkCodes.includes(nestedCauseCode) || networkCodes.includes(causeCode) || networkCodes.includes(deepCauseCode)) : !0;
83927
+ if (err instanceof TypeError || err?.name === "TypeError") {
83928
+ let causeMsg = String(cause?.message || ""), parentMsg = String(e.message || "");
83929
+ return !!(/\b(?:fetch failed)\b/i.test(parentMsg) && (/\b(?:connect ECONNREFUSED|ENOTFOUND|EAI_AGAIN|network|socket|timed?\s*out|und_err)\b/i.test(causeMsg) || /\b(?:connect ECONNREFUSED|ENOTFOUND|EAI_AGAIN|network|socket|und_err)\b/i.test(parentMsg)));
83930
+ }
83931
+ if (err instanceof ReferenceError || err instanceof RangeError || err instanceof SyntaxError || err?.name === "ReferenceError" || err?.name === "RangeError" || err?.name === "SyntaxError")
83932
+ return !1;
83933
+ if (err instanceof GemmaAbortError || err?.name === "AbortError")
83934
+ return !0;
83935
+ let name = String(e.name || ""), msg = String(e.message || ""), code = String(e.code || "");
83936
+ return !!(name === "TimeoutError" || name === "AbortError" || code === "ETIMEDOUT" || code === "UND_ERR_CONNECT_TIMEOUT" || code === "UND_ERR_SOCKET" || code === "UND_ERR_HEADERS_TIMEOUT" || code === "UND_ERR_BODY_TIMEOUT" || code === "UND_ERR_DESTROYED" || code === "UND_ERR_CLOSED" || /\b(?:timed?\s*out|caller_aborted)\b/i.test(msg) || networkCodes.includes(code) || /\b(?:fetch failed|socket hang up|connection refused|network error|dns lookup failed|cannot reach|und_err_socket|und_err_connect_timeout)\b/i.test(
83937
+ msg
83938
+ ));
83939
+ }
83940
+ async function classifyPromptIntentWithGemma(input, port, opts) {
83941
+ if (!input || !input.prompt || input.prompt.trim().length === 0)
83942
+ return failClosedDefault("empty_prompt", "semantic_fail_closed");
83943
+ if (opts?.signal?.aborted)
83944
+ return failClosedDefault("caller_aborted", "infrastructure_outage");
83945
+ let timeoutMs = opts?.timeoutMs ?? DEFAULT_INTENT_TIMEOUT_MS, controller = new AbortController(), timer, callerAbortHandler, failurePromise = new Promise((_, reject) => {
83946
+ timer = setTimeout(() => {
83947
+ reject(new Error(`Gemma intent classification timed out after ${timeoutMs}ms`)), controller.abort();
83948
+ }, timeoutMs), opts?.signal && (callerAbortHandler = () => {
83949
+ reject(new Error("caller_aborted")), controller.abort();
83950
+ }, opts.signal.addEventListener("abort", callerAbortHandler, { once: !0 }));
83951
+ });
83952
+ try {
83953
+ let prompt = buildIntentClassifierPrompt(input.prompt, input.clarifications), classifyPromise = port.classify({
83954
+ prompt,
83955
+ jsonSchema: INTENT_CLASSIFIER_JSON_SCHEMA,
83956
+ maxOutputTokens: INTENT_MAX_OUTPUT_TOKENS,
83957
+ signal: controller.signal,
83958
+ timeoutMs
83959
+ });
83960
+ classifyPromise.catch(() => {
83961
+ });
83962
+ let res = await Promise.race([classifyPromise, failurePromise]), parsed = parseIntentGemmaResponse(res.text);
83963
+ return parsed ? parsed.confidence === "low" ? failClosedDefault("low_confidence_intent", "semantic_fail_closed") : parsed : failClosedDefault("unparseable_gemma_intent_response", "semantic_fail_closed");
83964
+ } catch (err) {
83965
+ let msg = err?.message || "unknown";
83966
+ return err instanceof GemmaPolicyError || err instanceof GemmaContextFullError || err instanceof GemmaEmptyOutputError || err instanceof GemmaHiddenTokenLoopError || err instanceof GemmaBackendTooOldError || err?.name === "GemmaPolicyError" || err?.name === "GemmaContextFullError" || err?.name === "GemmaEmptyOutputError" || err?.name === "GemmaHiddenTokenLoopError" || err?.name === "GemmaBackendTooOldError" ? failClosedDefault(`gemma_policy_or_capacity_error: ${msg}`, "semantic_fail_closed") : isInfrastructureTransportOutage(err) ? failClosedDefault(`gemma_transport_outage: ${msg}`, "infrastructure_outage") : failClosedDefault(`gemma_intent_error: ${msg}`, "semantic_fail_closed");
83967
+ } finally {
83968
+ timer && clearTimeout(timer), opts?.signal && callerAbortHandler && opts.signal.removeEventListener("abort", callerAbortHandler);
83969
+ }
83970
+ }
83971
+
83825
83972
  // src/orchestration-shell/brainstorm-quorum.ts
83826
83973
  var BRAINSTORM_PANEL_MIN_TIER = "MAX";
83827
83974
  function resolveBrainstormPanel(input) {
@@ -89163,7 +89310,7 @@ async function redelegateRepoStateReadQuietly(deps) {
89163
89310
  if (!repoStateRedelegationsInFlight.has(workspaceId)) {
89164
89311
  repoStateRedelegationsInFlight.add(workspaceId);
89165
89312
  try {
89166
- let workingDir = args.quorumLoop.getWorkingDir(), detected = typeof args.quorumLoop.getDetectedAgents == "function" ? args.quorumLoop.getDetectedAgents() : [], { agent } = selectImplementorAgent(detected), brief = renderFamiliarizeAgentBrief(
89313
+ let workingDir = args.quorumLoop.getWorkingDir(), detected = typeof args.quorumLoop.getDetectedAgents == "function" ? args.quorumLoop.getDetectedAgents() : [], pref = readImplementorPreferenceSync(), { agent } = selectImplementorAgent(detected, null, [], pref.priorityOrder), brief = renderFamiliarizeAgentBrief(
89167
89314
  "The repository HEAD moved since the last codebase overview. Re-read the codebase and produce an updated structural overview."
89168
89315
  ), baseIntent = agentMentionIntentFromOverride(agent), intent = baseIntent ? { ...baseIntent, promptForPlanning: brief } : {
89169
89316
  target: "CLAUDE",
@@ -89243,7 +89390,7 @@ async function routeFamiliarize(deps) {
89243
89390
  let state = store.getState(), frontierAvailable = !!(args.localExecutor && args.quorumLoop);
89244
89391
  if (state.structuralSummary && frontierAvailable)
89245
89392
  try {
89246
- let workingDir = args.quorumLoop.getWorkingDir(), detected = typeof args.quorumLoop.getDetectedAgents == "function" ? args.quorumLoop.getDetectedAgents() : [], { agent } = selectImplementorAgent(detected), brief = renderFamiliarizeAgentBrief(deps.userPrompt), baseIntent = agentMentionIntentFromOverride(agent), intent = baseIntent ? { ...baseIntent, promptForPlanning: brief } : {
89393
+ let workingDir = args.quorumLoop.getWorkingDir(), detected = typeof args.quorumLoop.getDetectedAgents == "function" ? args.quorumLoop.getDetectedAgents() : [], pref = readImplementorPreferenceSync(), { agent } = selectImplementorAgent(detected, null, [], pref.priorityOrder), brief = renderFamiliarizeAgentBrief(deps.userPrompt), baseIntent = agentMentionIntentFromOverride(agent), intent = baseIntent ? { ...baseIntent, promptForPlanning: brief } : {
89247
89394
  target: "CLAUDE",
89248
89395
  rawMention: "@claude",
89249
89396
  isLeadingControlToken: !0,
@@ -89339,6 +89486,61 @@ function renderFamiliarizeAgentBrief(userPrompt) {
89339
89486
  ].join(`
89340
89487
  `);
89341
89488
  }
89489
+ async function routeDocumentInspectionAdvisory(deps) {
89490
+ let { store, args, userPrompt } = deps;
89491
+ if (!args.localExecutor || !args.quorumLoop)
89492
+ return store.dispatch({
89493
+ type: "SHELL_ADVISORY",
89494
+ source: "shell",
89495
+ text: "A read-capable model is required to inspect and summarize documents in this workspace. No task was started and no files were modified."
89496
+ }), !1;
89497
+ let workingDir = args.quorumLoop.getWorkingDir(), detected = typeof args.quorumLoop.getDetectedAgents == "function" ? args.quorumLoop.getDetectedAgents() : [], pref = readImplementorPreferenceSync(), { agent } = selectImplementorAgent(detected, null, [], pref.priorityOrder), baseIntent = agentMentionIntentFromOverride(agent), intent = baseIntent ? { ...baseIntent, promptForPlanning: userPrompt } : {
89498
+ target: "CLAUDE",
89499
+ rawMention: "@claude",
89500
+ isLeadingControlToken: !1,
89501
+ promptForPlanning: userPrompt,
89502
+ tokenStartUtf16: 0,
89503
+ tokenEndUtf16: 0
89504
+ }, showSpinner = store.getState().progress === null;
89505
+ showSpinner && deps.onProgress?.({
89506
+ phase: "advisory_dispatched",
89507
+ agents: [agentDisplayName(agent)]
89508
+ });
89509
+ try {
89510
+ let result = await runReadOnlyAgentAdvisoryResult({
89511
+ shellArgs: args,
89512
+ agent,
89513
+ intent,
89514
+ advisoryBrief: userPrompt,
89515
+ workingDir
89516
+ });
89517
+ if (result.ok) {
89518
+ let output = sanitizeForTerminal(result.text);
89519
+ return store.dispatch({
89520
+ type: "SHELL_ADVISORY",
89521
+ source: "shell",
89522
+ text: output
89523
+ }), !0;
89524
+ } else {
89525
+ let failureMessage = "A read-capable model is required to inspect and summarize documents in this workspace. No task was started and no files were modified.";
89526
+ return result.usage.unavailableReason === "workspace_mutation_detected" ? failureMessage = "A workspace mutation was detected during document inspection. Please inspect the workspace." : result.usage.unavailableReason === "workspace_verification_unavailable" ? failureMessage = "Workspace integrity could not be verified following document inspection." : result.timedOut && (failureMessage = "Document inspection timed out. No task was started and no files were modified."), store.dispatch({
89527
+ type: "SHELL_ADVISORY",
89528
+ source: "shell",
89529
+ text: failureMessage
89530
+ }), !1;
89531
+ }
89532
+ } catch (err) {
89533
+ return logger.warn("[orchestration-shell] document inspection advisory failed", {
89534
+ error: err.message
89535
+ }), store.dispatch({
89536
+ type: "SHELL_ADVISORY",
89537
+ source: "shell",
89538
+ text: "Document inspection encountered an unexpected error. Please inspect the workspace."
89539
+ }), !1;
89540
+ } finally {
89541
+ showSpinner && deps.onProgress?.({ phase: "waiting_user" });
89542
+ }
89543
+ }
89342
89544
  async function routeBrainstorm(deps) {
89343
89545
  let {
89344
89546
  store,
@@ -91056,7 +91258,7 @@ async function handleShellUserInput(deps) {
91056
91258
  wallClockMsRemaining: 3e4,
91057
91259
  reviseAttempts: 0
91058
91260
  }
91059
- }, decision, pendingStartConfirmation, showClassifySpinner = store.getState().progress === null, classifyPipeline = args.localAdvisoryRunner, stopClassifyRelabel;
91261
+ }, decision, pendingStartConfirmation, isDemotedDocumentInspection = !1, showClassifySpinner = store.getState().progress === null, classifyPipeline = args.localAdvisoryRunner, stopClassifyRelabel;
91060
91262
  showClassifySpinner && (dispatchProgress({
91061
91263
  phase: "planner_classifying",
91062
91264
  ...classifyPipeline ? { runtimeNoun: progressRuntimeNoun(classifyPipeline) } : {}
@@ -91072,20 +91274,71 @@ async function handleShellUserInput(deps) {
91072
91274
  } finally {
91073
91275
  stopClassifyRelabel?.();
91074
91276
  }
91075
- if (logger.info("[orchestration-shell] Planner classified input", {
91277
+ logger.info("[orchestration-shell] Planner classified input", {
91076
91278
  prompt: plannerInput.prompt,
91077
91279
  action: decision.action,
91078
91280
  rationale: decision.rationale
91079
- }), decision.action === "browse" && hasFileMutationIntent(plannerInput.prompt) && (decision = {
91080
- action: "start_task",
91081
- rationale: decision.rationale ? `${decision.rationale} (promoted to start_task due to file mutation intent)` : "web request with file mutation intent"
91082
- }), turnAttachments.length > 0 && decision.action === "ask_user" && isBlindImageClarification(plannerInput.prompt, decision.clarifying_question) && !hasFileMutationIntent(plannerInput.prompt) && !isDestructiveFileRequest(plannerInput.prompt) && (decision = {
91083
- action: "advisory_response",
91084
- rationale: decision.rationale || "analyze and answer inquiry about the attached image"
91085
- }), freshRetainedPage && decision.action === "ask_user" && isPromptRelevantToPage && !hasFileMutationIntent(plannerInput.prompt) && !isDestructiveFileRequest(plannerInput.prompt) && (decision = {
91086
- action: "advisory_response",
91087
- rationale: decision.rationale || "answer inquiry using retained web page context"
91088
- }), decision.action === "start_task" && plannerInput.clarifications.length === 0 && isDestructiveFileRequest(plannerInput.prompt))
91281
+ }), isDemotedDocumentInspection = !1;
91282
+ let gemmaEvaluatedIntent = !1, allTurnTexts = [
91283
+ plannerInput.prompt,
91284
+ ...plannerInput.clarifications.map((c) => c.answer)
91285
+ ];
91286
+ if ((decision.action === "start_task" || decision.action === "browse") && args.localAdvisoryRunner && process.env.CODEVIBE_INTENT_CLASSIFIER !== "regex") {
91287
+ let gemmaIntent = await classifyPromptIntentWithGemma(
91288
+ { prompt: plannerInput.prompt, clarifications: plannerInput.clarifications },
91289
+ args.localAdvisoryRunner
91290
+ );
91291
+ if (gemmaIntent.source === "model")
91292
+ gemmaEvaluatedIntent = !0, decision.action === "browse" ? gemmaIntent.is_code_or_disk_mutation && (logger.info(
91293
+ "[orchestration-shell] Gemma intent classifier: promoting browse to start_task with code/disk mutation",
91294
+ { prompt: plannerInput.prompt, rationale: gemmaIntent.rationale }
91295
+ ), decision = {
91296
+ action: "start_task",
91297
+ rationale: decision.rationale ? `${decision.rationale} (promoted to start_task via Gemma intent classifier)` : gemmaIntent.rationale
91298
+ }) : gemmaIntent.is_code_or_disk_mutation ? logger.info(
91299
+ "[orchestration-shell] Gemma intent classifier: confirmed start_task with code/disk mutation",
91300
+ { prompt: plannerInput.prompt, rationale: gemmaIntent.rationale }
91301
+ ) : gemmaIntent.action === "familiarize" && !gemmaIntent.requires_file_read ? (logger.info(
91302
+ "[orchestration-shell] Gemma intent classifier: demoting start_task to familiarize",
91303
+ { prompt: plannerInput.prompt, rationale: gemmaIntent.rationale }
91304
+ ), decision = {
91305
+ action: "familiarize",
91306
+ rationale: decision.rationale ? `${decision.rationale} (demoted to familiarize via Gemma intent classifier)` : gemmaIntent.rationale
91307
+ }) : (logger.info(
91308
+ "[orchestration-shell] Gemma intent classifier: demoting start_task to advisory_response",
91309
+ { prompt: plannerInput.prompt, rationale: gemmaIntent.rationale }
91310
+ ), gemmaIntent.requires_file_read && (isDemotedDocumentInspection = !0), decision = {
91311
+ action: "advisory_response",
91312
+ rationale: decision.rationale ? `${decision.rationale} (demoted to advisory_response via Gemma intent classifier)` : gemmaIntent.rationale,
91313
+ advisory_summary: void 0
91314
+ });
91315
+ else if (gemmaIntent.source === "semantic_fail_closed")
91316
+ gemmaEvaluatedIntent = !0, logger.warn(
91317
+ "[orchestration-shell] Gemma intent classifier: semantic fail-closed; asking user to clarify intent",
91318
+ { rationale: gemmaIntent.rationale }
91319
+ ), decision = {
91320
+ action: "ask_user",
91321
+ rationale: gemmaIntent.rationale,
91322
+ clarifying_question: "Could you please clarify whether you would like to inspect/read files or modify code on disk?"
91323
+ };
91324
+ else {
91325
+ gemmaEvaluatedIntent = !0;
91326
+ let outageMessage = "Model service is temporarily unavailable. CodeVibe cannot process requests without a responsive model.";
91327
+ logger.warn(
91328
+ "[orchestration-shell] Gemma intent classifier: infrastructure outage; halting with user outage advisory",
91329
+ { rationale: gemmaIntent.rationale }
91330
+ ), store.dispatch({
91331
+ type: "PLANNER_DECISION",
91332
+ decision: {
91333
+ action: "advisory_response",
91334
+ rationale: gemmaIntent.rationale,
91335
+ advisory_summary: outageMessage
91336
+ }
91337
+ }), clearPendingClarificationIfPresent(store);
91338
+ return;
91339
+ }
91340
+ }
91341
+ if (decision.action === "start_task" && plannerInput.clarifications.length === 0 && isDestructiveFileRequest(plannerInput.prompt))
91089
91342
  logger.warn(
91090
91343
  "[orchestration-shell] P43 backstop: a destructive file request was classified start_task without a confirmation this turn; asking first",
91091
91344
  { rationale: decision.rationale }
@@ -91198,7 +91451,7 @@ async function handleShellUserInput(deps) {
91198
91451
  } : void 0, isImageAdvisory = decision.action === "advisory_response" && turnAttachments.length > 0, mentionIntentForLocalSuppression = mentionIntent ?? agentMentionIntentFromOverride(effectiveExplicitAgentOverride), suppressMentionLocalAnswer = shouldSuppressMentionLocalAnswer(
91199
91452
  mentionIntentForLocalSuppression,
91200
91453
  decision
91201
- ), contextualAdvisoryTurns = decision.action === "advisory_response" && !isImageAdvisory && !suppressMentionLocalAnswer && args.localAdvisoryRunner ? collectPriorBrainstormTurns(store.getState().conversation, dispatchText) : [], isTextAdvisory = decision.action === "advisory_response" && !isImageAdvisory && !suppressMentionLocalAnswer && !!args.localAdvisoryRunner, reducerDecision = isImageAdvisory ? { ...decision, advisory_summary: void 0, clarifying_question: void 0, rationale: "" } : isTextAdvisory ? { ...decision, advisory_summary: void 0, clarifying_question: void 0, rationale: "" } : suppressMentionLocalAnswer ? { ...decision, advisory_summary: void 0, clarifying_question: void 0, rationale: "" } : decision.action === "team_decompose" || decision.action === "familiarize" || decision.action === "brainstorm" || // WEB-BROWSING (Stage-2-r3 MED): strip any advisory_summary/clarifying_question
91454
+ ), contextualAdvisoryTurns = decision.action === "advisory_response" && !isImageAdvisory && !suppressMentionLocalAnswer && args.localAdvisoryRunner ? collectPriorBrainstormTurns(store.getState().conversation, dispatchText) : [], isTextAdvisory = decision.action === "advisory_response" && !isImageAdvisory && !suppressMentionLocalAnswer && !!args.localAdvisoryRunner, reducerDecision = isImageAdvisory ? { ...decision, advisory_summary: void 0, clarifying_question: void 0, rationale: "" } : isTextAdvisory ? { ...decision, advisory_summary: void 0, clarifying_question: void 0, rationale: "" } : suppressMentionLocalAnswer ? { ...decision, advisory_summary: void 0, clarifying_question: void 0, rationale: "" } : isDemotedDocumentInspection ? { ...decision, advisory_summary: void 0, clarifying_question: void 0, rationale: "" } : decision.action === "team_decompose" || decision.action === "familiarize" || decision.action === "brainstorm" || // WEB-BROWSING (Stage-2-r3 MED): strip any advisory_summary/clarifying_question
91202
91455
  // off a `browse` so no ungrounded planner text renders before the fetched answer.
91203
91456
  decision.action === "browse" ? { ...decision, advisory_summary: void 0, clarifying_question: void 0 } : decision;
91204
91457
  if (store.dispatch({
@@ -91206,7 +91459,21 @@ async function handleShellUserInput(deps) {
91206
91459
  decision: reducerDecision,
91207
91460
  ...brainstormMetadata ? { brainstorm: brainstormMetadata } : {},
91208
91461
  ...pendingStartConfirmation ? { startConfirmation: pendingStartConfirmation } : {}
91209
- }), suppressMentionLocalAnswer && mentionIntentForLocalSuppression) {
91462
+ }), isDemotedDocumentInspection && !suppressMentionLocalAnswer) {
91463
+ let advisoryBrief = composeReadOnlyAdvisoryBrief(
91464
+ pendingForPlanning,
91465
+ plannerPromptText,
91466
+ answeredThisTurn
91467
+ );
91468
+ await routeDocumentInspectionAdvisory({
91469
+ store,
91470
+ args,
91471
+ userPrompt: advisoryBrief,
91472
+ onProgress: deps.onProgress
91473
+ });
91474
+ return;
91475
+ }
91476
+ if (suppressMentionLocalAnswer && mentionIntentForLocalSuppression) {
91210
91477
  let carriedMentionTargets = mentionTargets.length > 0 ? mentionTargets : latestMentionTargetsFromPendingClarification(pending2, answeredThisTurn), multiDirectedCarried = carriedMentionTargets.length > 1 && !carriedMentionTargets.includes("ALL"), advisoryBrief = composeReadOnlyAdvisoryBrief(
91211
91478
  multiDirectedCarried ? pending2 : pendingForPlanning,
91212
91479
  multiDirectedCarried ? dispatchText : plannerPromptText,
@@ -97637,14 +97904,16 @@ async function triggerStartupOrphanSweep(appsyncClient, currentSessionId, staleT
97637
97904
  ownerRootDir: shadowEnv?.ownerRootDir ?? processOwnerRoot(),
97638
97905
  ...shadowEnv
97639
97906
  };
97640
- return await reapOrphanShadows(/* @__PURE__ */ new Set(), env).catch((err) => {
97907
+ await reapOrphanShadows(/* @__PURE__ */ new Set(), env).catch((err) => {
97641
97908
  logger.warn("[cli] shadow orphan startup sweep error (non-fatal)", {
97642
97909
  err: err?.message
97643
97910
  });
97644
- }), await appsyncClient.sweepOrphanSessions({
97911
+ });
97912
+ let envExcludes = (process.env.CODEVIBE_SWEEP_EXCLUDE_SESSION_IDS ?? "").split(",").map((s) => s.trim()).filter(Boolean), excludeSessionIds = Array.from(/* @__PURE__ */ new Set([currentSessionId, ...envExcludes]));
97913
+ return await appsyncClient.sweepOrphanSessions({
97645
97914
  agentType: "CODEVIBE" /* CODEVIBE */,
97646
97915
  staleThresholdMs,
97647
- excludeSessionIds: [currentSessionId]
97916
+ excludeSessionIds
97648
97917
  });
97649
97918
  } catch (err) {
97650
97919
  return logger.warn("[cli] startup orphan sweep failed (non-fatal)", {
@@ -61,6 +61,24 @@ export declare function buildCommandIntentMetadata(text: string): CommandIntentM
61
61
  * Supports language-agnostic URLs, as well as English, Chinese, and Japanese web search intents.
62
62
  */
63
63
  export declare function isWebAccessNeeded(text: string): boolean;
64
+ /**
65
+ * Common file and document extensions for code, documentation, scripts, data, and office files.
66
+ */
67
+ export declare const DOCUMENT_AND_CODE_EXTENSIONS = "(?:pdf|docx|doc|xlsx|xls|csv|tsv|txt|md|markdown|json|yaml|yml|toml|env|log|ts|js|tsx|jsx|py|rs|go|java|c|cpp|h|html|css|sql|sh)";
68
+ /**
69
+ * Strips negated mutation verb phrases (e.g. "do not fix ...", "don't modify ...",
70
+ * "without changing any code", "不做修改", "修正しないで", "수정하지 말고", "do not write report.md")
71
+ * from text so that negative constraints do not trigger mutation action verbs,
72
+ * while preserving any independent affirmative mutation instructions in the same clause.
73
+ */
74
+ export declare function stripNegatedMutationSpans(text: string): string;
75
+ /**
76
+ * Helper to recognize source content references that describe entities or topics inside a file or database
77
+ * (e.g. "generate a list of the fields in config.json", "generate a summary of the functions in README.md",
78
+ * "generate a summary of the error handling in auth.ts", "output a list of the functions in auth.sh")
79
+ * rather than write destinations.
80
+ */
81
+ export declare function isGenerateSourceContentRef(target: string, hasWebContext?: boolean): boolean;
64
82
  /**
65
83
  * Detects whether a prompt expresses intent to create, write, save, or modify local files/reports,
66
84
  * as opposed to a purely read-only conversational request.