@quantiya/codevibe-core 2.0.76 → 2.0.78

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.
@@ -403,6 +403,63 @@ export declare const WORKSPACE_TREE_FINGERPRINT_TIMEOUT_MS = 3000;
403
403
  export declare function probeWorkspaceTreeFingerprint(workspaceRoot: string, options?: {
404
404
  timeoutMs?: number;
405
405
  }): Promise<WorkspaceTreeFingerprintProbe>;
406
+ /** Budget of the git-free walk below; past it the probe fails (fail closed). */
407
+ export declare const ADVISORY_WALK_FINGERPRINT_TIMEOUT_MS = 10000;
408
+ /** Entry cap of the git-free walk below; past it the probe fails (fail closed). */
409
+ export declare const ADVISORY_WALK_FINGERPRINT_MAX_ENTRIES = 200000;
410
+ export type AdvisoryWorkspaceFingerprintProbe = {
411
+ kind: 'fingerprint';
412
+ method: 'git' | 'walk';
413
+ value: string;
414
+ entries: number;
415
+ durationMs: number;
416
+ } | {
417
+ kind: 'probe-failed';
418
+ method: 'git' | 'walk' | 'marker';
419
+ reason: string;
420
+ durationMs: number;
421
+ };
422
+ /**
423
+ * The before/after fingerprint of a read-only advisory turn (`@agent` /
424
+ * `@all`), which fails closed when the two differ or cannot be taken.
425
+ *
426
+ * Inside a git repository (a `.git` entry or git-directory shape in the workspace
427
+ * or any ancestor that git accepts, or a repository-locating GIT_* variable) this
428
+ * is {@link probeWorkspaceTreeFingerprint}, unchanged. A folder that is not a
429
+ * repository — no `.git` at all, a `.git` that git rejects (git's own "not a git
430
+ * repository" failure), or no `git` binary (ENOENT; the macOS shim without the
431
+ * command-line tools is a git failure, so that case fails closed) — is walked
432
+ * instead; with no `.git` marker `git` is never run — 2.0 workspaces are git-free,
433
+ * and on a Mac without the command-line tools `/usr/bin/git` opens an install
434
+ * dialog. A marker check that cannot conclude refuses the turn. Core 2.0.77 used
435
+ * the git probe for every folder, so every advisory turn outside a repository
436
+ * failed closed before any agent ran.
437
+ *
438
+ * The walk records the root's mode and each entry's relative path, type and mode; for files and
439
+ * symlinks also size, mtime (rounded to the nearest second) and inode, and a symlink's target.
440
+ * ctime is left out and mtime is coarse on purpose: in an iCloud-synced folder
441
+ * the sync client moves ctime and file flags without changing content, and a
442
+ * file downloaded again because the agent read it comes back with its mtime off
443
+ * by nanoseconds; without git's content index the walk cannot tell those apart
444
+ * from edits, so they would fail the turn. The cost is that a same-size in-place
445
+ * rewrite whose new mtime rounds to the same whole second as the old one (up to
446
+ * half a second either side of it), or whose mtime is put back, goes unseen; the agents are read-only by their own
447
+ * invocations, and this check is the backstop. Symlinks are not followed. A
448
+ * subfolder or entry that cannot be read is recorded with its error code (so
449
+ * changes inside it go unseen), but a root that cannot be listed fails the
450
+ * probe. A deadline races the asynchronous work — a stalled `readdir` or `lstat`
451
+ * cannot hold the turn, though the stalled call itself keeps its libuv worker
452
+ * until the OS answers — and an entry cap is applied while a folder is read; past
453
+ * either it is `probe-failed`. The final sort and hash are synchronous and cannot
454
+ * be interrupted: if they run past the deadline, the result is `probe-failed`
455
+ * (`timeout`) when they finish, never a late success. The method is part of the value,
456
+ * so a `.git` that appears during the turn also reads as a change. Never
457
+ * throws.
458
+ */
459
+ export declare function probeAdvisoryWorkspaceFingerprint(workspaceRoot: string, options?: {
460
+ timeoutMs?: number;
461
+ maxEntries?: number;
462
+ }): Promise<AdvisoryWorkspaceFingerprintProbe>;
406
463
  /**
407
464
  * Hash the generation inputs (§4.2 conjunct (d)). A `StructuralSummary` is a
408
465
  * pure function of `tree content × generation inputs`; this hashes the
@@ -28,6 +28,7 @@ import { runShellResumeInShell } from '../session-resume/shell-resume-io';
28
28
  import type { ShellResumeOutcome } from '../session-resume/shell-resume';
29
29
  import { type RelaunchRequest } from '../session-resume/relaunch';
30
30
  export { executeGitStatusSummary } from './git-status-summary';
31
+ export { probeWorkspaceTreeFingerprint } from './context-store';
31
32
  import { type ContinuationCliResult, type ContinuationCliDeps } from './slash-routes/continuation';
32
33
  import { loadReviewerWizardData } from './slash-routes/reviewers';
33
34
  import { createShellEventEmitter } from './emit-shell-event';
@@ -46,6 +47,7 @@ import type { LocalExecutor } from '../local-executor';
46
47
  import type { WorkItemInput, DisjointnessRejection, RevertManifestStore } from '../local-executor';
47
48
  import type { QuorumLoop } from './quorum-loop';
48
49
  import { type InvocationUsageSnapshot } from '../reviewer/token-usage';
50
+ import { buildImplementorArgv } from '../local-executor/implementor-argv';
49
51
  import { ensureFreshContextStore } from './context-store';
50
52
  import type { EnsureFreshResult } from './context-store';
51
53
  import { contextItemOccurrence, type ContextDurabilityReceipt } from './context-items';
@@ -611,7 +613,22 @@ export declare function readOnlyAgentPrompt(args: {
611
613
  allowRepositoryTools: boolean;
612
614
  hasRetainedPage?: boolean;
613
615
  }): string;
616
+ export declare function readOnlyAdvisoryAllowsRepositoryTools(_input: string): boolean;
617
+ export declare function applyReadOnlyAdvisoryToolPolicy(agent: LocalExecutorAgentKind, plan: ReturnType<typeof buildImplementorArgv>, allowRepositoryTools: boolean, workingDir?: string, attachments?: readonly string[]): ReturnType<typeof buildImplementorArgv>;
614
618
  export declare const BRAINSTORM_PANEL_ADVISORY_TIMEOUT_MS = 1800000;
619
+ /**
620
+ * [#637] The Claude CLI reports a usage-limit INSIDE its stdout result envelope
621
+ * (`{"type":"result","result":"You've reached your usage limit…"}`) — NOT on
622
+ * stderr (`classifyImplementorQuotaFailure`) and NOT as the `error`/`turn.failed`
623
+ * JSONL events `classifyFailureFromStdout` reads — so a real Claude quota-wall
624
+ * used to render the generic 'failed' label. Locate the result envelope
625
+ * (tolerates pre-envelope warning lines; never throws) and run the SAME closed
626
+ * usage-limit patterns (`classifyFailureMessage`) against its `result` field.
627
+ * FAILURE PATH ONLY: the caller invokes this exclusively on the exit!==0 /
628
+ * empty-output branch, so the parsed answer of a SUCCESSFUL run is never
629
+ * classified. Only the closed label is ever surfaced, never the raw text.
630
+ */
631
+ export declare function classifyClaudeResultStdoutQuota(stdout: string): boolean;
615
632
  export declare function routeReadOnlyAgentMention(args: {
616
633
  store: OrchestrationStore;
617
634
  shellArgs: RunOrchestrationShellArgs;
@@ -1271,6 +1288,10 @@ export declare function resetTurnAuthoringStateForTests(): void;
1271
1288
  * on any exit path. Non-throwing (delete on a Map/Set never throws).
1272
1289
  */
1273
1290
  export declare function clearTurnAuthoringSessionState(sessionId: string): void;
1291
+ /**
1292
+ * Returns the set of quota-walled agents for the given session.
1293
+ */
1294
+ export declare function getBrainstormQuotaWalled(sessionId: string): ReadonlySet<BrainstormPanelActiveAgent>;
1274
1295
  /**
1275
1296
  * M7 (SHARED-CONTEXT-M7-ADDENDUM.md §3.1, DL-2) — `/rule <text>`: pin the text
1276
1297
  * verbatim (capped) as a durable `user_rule` decision with source `explicit`,
@@ -0,0 +1,19 @@
1
+ /**
2
+ * `present` — `dir` (resolved as git resolves it) or an ancestor holds a `.git` entry, or may itself be a git directory
3
+ * (`HEAD` plus a `commondir` file or `objects` + `refs`: a bare repository); `absent` — at every level `.git` is
4
+ * missing and the folder is definitely not a git directory (`HEAD` missing or of another type, or `objects`/`refs`
5
+ * missing), so git cannot find a repository; `unknown` — the folder could not be resolved, or a level could not be
6
+ * checked (EACCES, EIO, …), so absence is not proven.
7
+ */
8
+ export type GitMarkerState = 'present' | 'absent' | 'unknown';
9
+ export declare function gitMarkerState(dir: string): Promise<GitMarkerState>;
10
+ /**
11
+ * True when the environment can point git at a repository (or at parts of one) whatever the folder holds: `GIT_DIR`,
12
+ * `GIT_WORK_TREE`, `GIT_OBJECT_DIRECTORY`, `GIT_COMMON_DIR`. Callers then defer to git instead of the marker check.
13
+ */
14
+ export declare function gitEnvSelectsRepository(): boolean;
15
+ /**
16
+ * False only when git provably could not find a repository for `dir`: no repository-locating environment variable and
17
+ * the marker check is `absent`. `unknown` is true, so callers run git and keep exactly the answer they gave before.
18
+ */
19
+ export declare function gitMayApply(dir: string): Promise<boolean>;
@@ -111,7 +111,12 @@ extraWriteDirs?: readonly string[],
111
111
  * file-authed model call reaches its vendor directly). See
112
112
  * {@link SubstrateSpec.networkPosture}.
113
113
  */
114
- networkPosture?: 'loopback' | 'open'): string;
114
+ networkPosture?: 'loopback' | 'open',
115
+ /**
116
+ * When false, denies writes to the worktree, establishing a hard read-only boundary (R5-F1).
117
+ * Default true (writes permitted to workdir).
118
+ */
119
+ writableWorkdir?: boolean): string;
115
120
  /**
116
121
  * A5 macOS `sandbox-exec` substrate (`egressFidelity: 'coarse'`). See file
117
122
  * header. NOT the default — the LE selects it as the macOS Docker-fallback.
@@ -134,6 +134,11 @@ export interface SubstrateSpec {
134
134
  * construction still compiles (absent → loopback, byte-identical profile).
135
135
  */
136
136
  networkPosture?: "loopback" | "open";
137
+ /**
138
+ * When false, the workdir is mounted/granted read-only (writes to workdir are denied).
139
+ * Default true (writes permitted to workdir).
140
+ */
141
+ writableWorkdir?: boolean;
137
142
  }
138
143
  /**
139
144
  * A structural `ChildProcess` subset. The LE widens its internal child
@@ -41,6 +41,11 @@ export interface EngageSubstrateInput {
41
41
  * legacy behavior for every existing caller.
42
42
  */
43
43
  requireConfined?: boolean;
44
+ /**
45
+ * When false, the workdir is mounted/granted read-only (writes to workdir are denied) (R5-F1).
46
+ * Default true (writes permitted to workdir).
47
+ */
48
+ writableWorkdir?: boolean;
44
49
  /** F-P46a-4 — the implementor spawn's process-tree id (descendant reaping marker). */
45
50
  processTreeId?: string;
46
51
  /** Ladder deps (injectable for tests). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quantiya/codevibe-core",
3
- "version": "2.0.76",
3
+ "version": "2.0.78",
4
4
  "description": "Core library for CodeVibe plugins - shared keychain, crypto, AppSync, and auth functionality",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",