@gitkraken/core-gitlens 0.33.0 → 0.34.0

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.
Files changed (88) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/dist/git/cache.d.ts +31 -0
  3. package/dist/git/cache.js +101 -30
  4. package/dist/git/cache.js.map +1 -1
  5. package/dist/git/context.d.ts +3 -1
  6. package/dist/git/context.js.map +1 -1
  7. package/dist/git/errors.d.ts +3 -1
  8. package/dist/git/errors.js +4 -1
  9. package/dist/git/errors.js.map +1 -1
  10. package/dist/git/models/pullRequest.d.ts +90 -1
  11. package/dist/git/models/pullRequest.js +18 -2
  12. package/dist/git/models/pullRequest.js.map +1 -1
  13. package/dist/git/providers/shared/remotes.js +2 -0
  14. package/dist/git/providers/shared/remotes.js.map +1 -1
  15. package/dist/git/utils/pullRequest.utils.d.ts +72 -1
  16. package/dist/git/utils/pullRequest.utils.js +99 -1
  17. package/dist/git/utils/pullRequest.utils.js.map +1 -1
  18. package/dist/git/utils/repository.utils.d.ts +6 -0
  19. package/dist/git/utils/repository.utils.js +14 -2
  20. package/dist/git/utils/repository.utils.js.map +1 -1
  21. package/dist/git/watching/gitDirPoller.d.ts +10 -1
  22. package/dist/git/watching/gitDirPoller.js +9 -3
  23. package/dist/git/watching/gitDirPoller.js.map +1 -1
  24. package/dist/git/watching/unwatchedCacheValidator.d.ts +144 -0
  25. package/dist/git/watching/unwatchedCacheValidator.js +884 -0
  26. package/dist/git/watching/unwatchedCacheValidator.js.map +1 -0
  27. package/dist/git/watching/watchGroup.d.ts +2 -0
  28. package/dist/git/watching/watchGroup.js +4 -8
  29. package/dist/git/watching/watchGroup.js.map +1 -1
  30. package/dist/git/watching/watchService.d.ts +23 -0
  31. package/dist/git/watching/watchService.js +42 -2
  32. package/dist/git/watching/watchService.js.map +1 -1
  33. package/dist/git/watching/watchSession.d.ts +2 -0
  34. package/dist/git/watching/watchSession.js +3 -2
  35. package/dist/git/watching/watchSession.js.map +1 -1
  36. package/dist/git-cli/cliGitProvider.js +1 -1
  37. package/dist/git-cli/cliGitProvider.js.map +1 -1
  38. package/dist/git-cli/exec/commandClassifier.d.ts +31 -1
  39. package/dist/git-cli/exec/commandClassifier.js +67 -16
  40. package/dist/git-cli/exec/commandClassifier.js.map +1 -1
  41. package/dist/git-cli/exec/git.d.ts +46 -2
  42. package/dist/git-cli/exec/git.js +80 -7
  43. package/dist/git-cli/exec/git.js.map +1 -1
  44. package/dist/git-cli/exec/gitDirResolver.d.ts +11 -0
  45. package/dist/git-cli/exec/gitDirResolver.js +34 -1
  46. package/dist/git-cli/exec/gitDirResolver.js.map +1 -1
  47. package/dist/git-cli/exec/gitQueue.js +2 -28
  48. package/dist/git-cli/exec/gitQueue.js.map +1 -1
  49. package/dist/git-cli/providers/branches.d.ts +1 -0
  50. package/dist/git-cli/providers/branches.js +6 -0
  51. package/dist/git-cli/providers/branches.js.map +1 -1
  52. package/dist/git-cli/providers/config.d.ts +13 -1
  53. package/dist/git-cli/providers/config.js +48 -14
  54. package/dist/git-cli/providers/config.js.map +1 -1
  55. package/dist/git-cli/providers/pausedOperations.d.ts +1 -0
  56. package/dist/git-cli/providers/pausedOperations.js +4 -0
  57. package/dist/git-cli/providers/pausedOperations.js.map +1 -1
  58. package/dist/git-cli/providers/revision.js +2 -0
  59. package/dist/git-cli/providers/revision.js.map +1 -1
  60. package/dist/git-cli/providers/worktrees.js +2 -0
  61. package/dist/git-cli/providers/worktrees.js.map +1 -1
  62. package/dist/git-cli/service.d.ts +25 -1
  63. package/dist/git-cli/service.js +45 -0
  64. package/dist/git-cli/service.js.map +1 -1
  65. package/dist/plus/ai/errors.d.ts +8 -2
  66. package/dist/plus/ai/errors.js +15 -3
  67. package/dist/plus/ai/errors.js.map +1 -1
  68. package/dist/plus/git-github/api/github.d.ts +51 -1
  69. package/dist/plus/git-github/api/github.js +276 -3
  70. package/dist/plus/git-github/api/github.js.map +1 -1
  71. package/dist/plus/git-github/models.d.ts +54 -1
  72. package/dist/plus/git-github/models.js +48 -3
  73. package/dist/plus/git-github/models.js.map +1 -1
  74. package/dist/plus/integrations/fieldPresence.d.ts +6 -1
  75. package/dist/plus/integrations/fieldPresence.js +19 -9
  76. package/dist/plus/integrations/fieldPresence.js.map +1 -1
  77. package/dist/plus/integrations/models/gitHostIntegration.d.ts +26 -1
  78. package/dist/plus/integrations/models/gitHostIntegration.js +51 -0
  79. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  80. package/dist/plus/integrations/models/integration.d.ts +15 -2
  81. package/dist/plus/integrations/models/integration.js.map +1 -1
  82. package/dist/plus/integrations/providers/github.d.ts +16 -1
  83. package/dist/plus/integrations/providers/github.js +53 -1
  84. package/dist/plus/integrations/providers/github.js.map +1 -1
  85. package/dist/plus/integrations/reads/etag.js +11 -0
  86. package/dist/plus/integrations/reads/etag.js.map +1 -1
  87. package/docs/integrations.md +39 -6
  88. package/package.json +1 -1
@@ -22,7 +22,11 @@ export interface CliGitServiceOptions {
22
22
  locator?: () => Promise<GitLocation>;
23
23
  /** Host-provided context hooks (cache events, workspace, integrations, telemetry, fs) */
24
24
  context: CliGitProviderOptions['context'];
25
- /** Git execution options passed through to the underlying Git executor */
25
+ /**
26
+ * Git execution options passed through to the underlying Git executor. `gitOptions.isTrusted(repoPath)` is the
27
+ * per-repository trust gate: a `false` answer rejects git runs in that path with `WorkspaceUntrustedError` before
28
+ * any process starts. It applies only when `context.workspace.isTrusted` is unset; that flag wins when present.
29
+ */
26
30
  gitOptions?: CliGitProviderOptions['gitOptions'];
27
31
  /** Use an existing Cache instance, or one will be created */
28
32
  cache?: CliGitProviderOptions['cache'];
@@ -40,6 +44,26 @@ export interface CliGitServiceOptions {
40
44
  * watcher is asked.
41
45
  */
42
46
  watchPolling?: WatchPollingOptions;
47
+ /**
48
+ * Keeps the caches that never expire (branches, current branch, refs, tags, remotes, worktrees, stashes, gk config,
49
+ * paused operation, and what derives from them) fresh for repositories whose `.git` directory nothing watches:
50
+ * before such a read, stats the files a watcher would have reported, and lists the ref directories and worktree
51
+ * admin entries, applying what moved as a watcher event would. Files git writes by rename are read only once the
52
+ * directory they're in moved, so a read of an idle repository costs a stat per git dir, per ref directory, per
53
+ * linked worktree and per file git writes in place, at most once per 250ms per repository; a watched one costs
54
+ * nothing, unless its watch is suspended, which holds what it hears until it resumes. Never runs git: a repository
55
+ * whose git dir nothing resolved yet is read from its own files, and one whose files can't show it (bare, a
56
+ * submodule, `--separate-git-dir`, `core.worktree`) isn't validated until a read resolves it, its files looked at
57
+ * again every 30 seconds. What moves in a worktree under an {@link ignoredWorktreeFolders} folder clears nothing. Without a
58
+ * {@link watchingProvider}, every repository counts as unwatched. A read waits at most `timeoutMs` (default 1000)
59
+ * for the stats, then is served from the cache, and the stats run one at a time per repository and two at once
60
+ * overall. A stat on a hung mount holds one of Node's file-system threads until it returns; one outstanding past
61
+ * `timeoutMs` lets other repositories' stats go on, as long as the stats hold all but two of the threads
62
+ * (`UV_THREADPOOL_SIZE`, default 4), which leaves the host two. Off by default.
63
+ */
64
+ validateUnwatchedCaches?: boolean | {
65
+ readonly timeoutMs?: number;
66
+ };
43
67
  /** For tests only; production never passes it (see `WorktreeSummaryServiceOptions.verifyBaseRemeasure`) */
44
68
  verifyBaseRemeasure?: WorktreeSummaryServiceOptions['verifyBaseRemeasure'];
45
69
  }
@@ -1,7 +1,10 @@
1
1
  import { fileUri } from "../utils/uri.js";
2
+ import { isNotFound } from "../git/watching/watchGroup.js";
2
3
  import { GitService } from "../git/service.js";
3
4
  import { CliGitProvider } from "./cliGitProvider.js";
5
+ import { UnwatchedCacheValidator } from "../git/watching/unwatchedCacheValidator.js";
4
6
  import { findGitPath } from "./exec/locator.js";
7
+ import { env } from "node:process";
5
8
  //#region ../git-cli/src/service.ts
6
9
  /**
7
10
  * Creates a ready-to-use {@link GitService} backed by the CLI git provider.
@@ -39,6 +42,43 @@ function createCliGitService(options) {
39
42
  refreshIndexAfterWrites: options.refreshIndexAfterWrites
40
43
  });
41
44
  service.register(provider, () => true);
45
+ if (options.validateUnwatchedCaches) {
46
+ const fs = options.context.fs;
47
+ const validator = new UnwatchedCacheValidator({
48
+ cache: provider.cache,
49
+ timeoutMs: typeof options.validateUnwatchedCaches === "object" ? options.validateUnwatchedCaches.timeoutMs : void 0,
50
+ maxFsThreads: getThreadPoolSize() - 2,
51
+ stat: async (path) => {
52
+ try {
53
+ const stat = await fs.stat(fileUri(path));
54
+ return stat != null ? {
55
+ mtime: stat.mtime,
56
+ size: stat.size
57
+ } : void 0;
58
+ } catch (ex) {
59
+ if (isNotFound(ex)) return void 0;
60
+ throw ex;
61
+ }
62
+ },
63
+ readDirectory: (path) => fs.readDirectory(fileUri(path)),
64
+ readFile: async (path) => {
65
+ try {
66
+ return await fs.readFile(fileUri(path));
67
+ } catch (ex) {
68
+ if (isNotFound(ex)) return void 0;
69
+ throw ex;
70
+ }
71
+ },
72
+ getIgnoredWorktreeRoots: (repoPath) => provider.cache.gitDir.get(repoPath) != null ? provider.getIgnoredWorktreeRoots(repoPath) : Promise.resolve([]),
73
+ resolveGitDir: (repoPath) => provider.config.resolveGitDirWithoutGit(repoPath),
74
+ isWatched: (repoPath) => service.watchService?.isRepoWatched(repoPath) ?? false
75
+ });
76
+ provider.cache.setReadValidator((repoPath) => validator.validate(repoPath), () => validator.getResourceUsage());
77
+ service.watchService?.onDidChangeRepoWatched((e) => {
78
+ if (e.watched) validator.onWatched(e.repoPath);
79
+ else validator.onUnwatched(e.repoPath);
80
+ });
81
+ }
42
82
  service.watchService?.onDidChangeWorkingTree((repoPath) => provider.cache.onWorkingTreeChanged(repoPath));
43
83
  service.watchService?.onDidChangeRepository((e) => {
44
84
  const changes = e.getUnannouncedChanges();
@@ -47,6 +87,11 @@ function createCliGitService(options) {
47
87
  service.watchService?.onDidChangeFetchHead((repoPath) => provider.cache.onRepositoryChanged(repoPath, ["lastFetched"]));
48
88
  return service;
49
89
  }
90
+ /** The size of libuv's thread pool, which runs Node's file-system calls, as libuv reads it at its first use */
91
+ function getThreadPoolSize() {
92
+ const size = Number.parseInt(env.UV_THREADPOOL_SIZE ?? "", 10);
93
+ return Number.isNaN(size) ? 4 : Math.min(Math.max(size, 1), 1024);
94
+ }
50
95
  //#endregion
51
96
  export { createCliGitService };
52
97
 
@@ -1 +1 @@
1
- {"version":3,"file":"service.js","names":[],"sources":["../../../git-cli/src/service.ts"],"sourcesContent":["import { GitService } from '@gitlens/git/service.js';\nimport type { FileWatchingProvider } from '@gitlens/git/watching/provider.js';\nimport type { WatchPollingOptions } from '@gitlens/git/watching/watchService.js';\nimport type { WorktreeSummaryServiceOptions } from '@gitlens/git/watching/worktreeSummary.js';\nimport { fileUri } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderOptions } from './cliGitProvider.js';\nimport { CliGitProvider } from './cliGitProvider.js';\nimport type { GitLocation } from './exec/locator.js';\nimport { findGitPath } from './exec/locator.js';\n\n/**\n * Options for {@link createCliGitService}.\n */\nexport interface CliGitServiceOptions {\n\t/**\n\t * Path(s) to the git binary.\n\t * Auto-detected if omitted (searches PATH, platform-specific locations).\n\t * Ignored when {@link locator} is provided.\n\t */\n\tgitPath?: string | string[];\n\n\t/**\n\t * Custom git binary resolver. When provided, used instead of the\n\t * default `findGitPath(gitPath)` lookup.\n\t */\n\tlocator?: () => Promise<GitLocation>;\n\n\t/** Host-provided context hooks (cache events, workspace, integrations, telemetry, fs) */\n\tcontext: CliGitProviderOptions['context'];\n\n\t/** Git execution options passed through to the underlying Git executor */\n\tgitOptions?: CliGitProviderOptions['gitOptions'];\n\n\t/** Use an existing Cache instance, or one will be created */\n\tcache?: CliGitProviderOptions['cache'];\n\n\t/** Folders, relative to a repository's common git dir, whose worktrees core acts as if didn't exist */\n\tignoredWorktreeFolders?: CliGitProviderOptions['ignoredWorktreeFolders'];\n\n\t/** Refreshes a checkout's index after core's own writes rewrote it (see `CliGitProviderOptions`); off by default */\n\trefreshIndexAfterWrites?: CliGitProviderOptions['refreshIndexAfterWrites'];\n\n\t/**\n\t * Filesystem watching provider. When provided, the {@link GitService}\n\t * will watch repositories for changes (file creates, edits, deletes).\n\t */\n\twatchingProvider?: FileWatchingProvider;\n\n\t/**\n\t * Polls in place of (or beside) the watchers {@link watchingProvider} reports it can't trust. When omitted, no\n\t * watcher is asked.\n\t */\n\twatchPolling?: WatchPollingOptions;\n\n\t/** For tests only; production never passes it (see `WorktreeSummaryServiceOptions.verifyBaseRemeasure`) */\n\tverifyBaseRemeasure?: WorktreeSummaryServiceOptions['verifyBaseRemeasure'];\n}\n\n/**\n * Creates a ready-to-use {@link GitService} backed by the CLI git provider.\n *\n * This is the primary entry point for standalone (non-VS Code) consumers\n * of the `@gitlens/git-cli` library. It creates a singleton {@link GitService},\n * wires up a {@link CliGitProvider}, and registers it for all repository paths.\n *\n * @example\n * ```typescript\n * const git = createCliGitService({ context: {} });\n *\n * const repo = git.forRepo('/path/to/repo')!;\n * const branches = await repo.branches.getBranches();\n * const status = await repo.status.getStatus();\n * await repo.ops!.fetch({ remote: 'origin' });\n *\n * git.dispose(); // cleans up provider, cache, and module-level state\n * ```\n */\nexport function createCliGitService(options: CliGitServiceOptions): GitService {\n\tconst service = GitService.createSingleton(options.watchingProvider, {\n\t\twatchPolling: options.watchPolling,\n\t\tverifyBaseRemeasure: options.verifyBaseRemeasure,\n\t\t// The host's file system reads the shared `.git/config` the watch service compares reports of\n\t\treadFile: path => options.context.fs.readFile(fileUri(path)),\n\t\t// And lists the directory the admin entries of its worktrees are in\n\t\treadDirectory: path => options.context.fs.readDirectory(fileUri(path)),\n\t});\n\n\tconst locator = options.locator ?? (() => findGitPath(options.gitPath ?? null));\n\tconst provider = new CliGitProvider({\n\t\tcontext: options.context,\n\t\tlocator: locator,\n\t\tgitOptions: options.gitOptions,\n\t\tcache: options.cache,\n\t\tignoredWorktreeFolders: options.ignoredWorktreeFolders,\n\t\trefreshIndexAfterWrites: options.refreshIndexAfterWrites,\n\t});\n\n\tservice.register(provider, () => true);\n\n\t// Advance the provider cache's status generation clock from the watch session's global events — the standalone\n\t// analogue of what the VS Code host wires in `GitProviderService`. Without this, a consumer that passes a\n\t// `watchingProvider` and drives watch sessions gets FS events but a FROZEN clock, so `dedupeByStatusGeneration`\n\t// degrades to the pre-change/post-change stale-join this branch exists to fix. Standalone has no `Repository`\n\t// models, so there are no force-fired `closed`/`lastFetched` bypassing the session for the global repo event to\n\t// miss. Subscriptions are torn down with the service (its `watchService`'s emitters are disposed on dispose).\n\tservice.watchService?.onDidChangeWorkingTree(repoPath => provider.cache.onWorkingTreeChanged(repoPath));\n\t// Announced kinds were evicted when core announced its write; evicting them again would discard what the host\n\t// re-read since\n\tservice.watchService?.onDidChangeRepository(e => {\n\t\tconst changes = e.getUnannouncedChanges();\n\t\tif (changes.length) {\n\t\t\tprovider.cache.onRepositoryChanged(e.repoPath, changes, { movedWorktrees: e.movedWorktrees });\n\t\t}\n\t});\n\t// FETCH_HEAD maps to no session change, and there's no `Repository` model here to force-fire `lastFetched` (as\n\t// the VS Code host does), so bridge it straight to the cache or the last-fetched time is never re-read.\n\tservice.watchService?.onDidChangeFetchHead(repoPath =>\n\t\tprovider.cache.onRepositoryChanged(repoPath, ['lastFetched']),\n\t);\n\treturn service;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA6EA,SAAgB,oBAAoB,SAA2C;CAC9E,MAAM,UAAU,WAAW,gBAAgB,QAAQ,kBAAkB;EACpE,cAAc,QAAQ;EACtB,qBAAqB,QAAQ;EAE7B,WAAU,SAAQ,QAAQ,QAAQ,GAAG,SAAS,QAAQ,IAAI,CAAC;EAE3D,gBAAe,SAAQ,QAAQ,QAAQ,GAAG,cAAc,QAAQ,IAAI,CAAC;CACtE,CAAC;CAED,MAAM,UAAU,QAAQ,kBAAkB,YAAY,QAAQ,WAAW,IAAI;CAC7E,MAAM,WAAW,IAAI,eAAe;EACnC,SAAS,QAAQ;EACR;EACT,YAAY,QAAQ;EACpB,OAAO,QAAQ;EACf,wBAAwB,QAAQ;EAChC,yBAAyB,QAAQ;CAClC,CAAC;CAED,QAAQ,SAAS,gBAAgB,IAAI;CAQrC,QAAQ,cAAc,wBAAuB,aAAY,SAAS,MAAM,qBAAqB,QAAQ,CAAC;CAGtG,QAAQ,cAAc,uBAAsB,MAAK;EAChD,MAAM,UAAU,EAAE,sBAAsB;EACxC,IAAI,QAAQ,QACX,SAAS,MAAM,oBAAoB,EAAE,UAAU,SAAS,EAAE,gBAAgB,EAAE,eAAe,CAAC;CAE9F,CAAC;CAGD,QAAQ,cAAc,sBAAqB,aAC1C,SAAS,MAAM,oBAAoB,UAAU,CAAC,aAAa,CAAC,CAC7D;CACA,OAAO;AACR"}
1
+ {"version":3,"file":"service.js","names":[],"sources":["../../../git-cli/src/service.ts"],"sourcesContent":["import { env } from 'node:process';\nimport { GitService } from '@gitlens/git/service.js';\nimport type { FileWatchingProvider } from '@gitlens/git/watching/provider.js';\nimport { UnwatchedCacheValidator } from '@gitlens/git/watching/unwatchedCacheValidator.js';\nimport { isNotFound } from '@gitlens/git/watching/watchGroup.js';\nimport type { WatchPollingOptions } from '@gitlens/git/watching/watchService.js';\nimport type { WorktreeSummaryServiceOptions } from '@gitlens/git/watching/worktreeSummary.js';\nimport { fileUri } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderOptions } from './cliGitProvider.js';\nimport { CliGitProvider } from './cliGitProvider.js';\nimport type { GitLocation } from './exec/locator.js';\nimport { findGitPath } from './exec/locator.js';\n\n/**\n * Options for {@link createCliGitService}.\n */\nexport interface CliGitServiceOptions {\n\t/**\n\t * Path(s) to the git binary.\n\t * Auto-detected if omitted (searches PATH, platform-specific locations).\n\t * Ignored when {@link locator} is provided.\n\t */\n\tgitPath?: string | string[];\n\n\t/**\n\t * Custom git binary resolver. When provided, used instead of the\n\t * default `findGitPath(gitPath)` lookup.\n\t */\n\tlocator?: () => Promise<GitLocation>;\n\n\t/** Host-provided context hooks (cache events, workspace, integrations, telemetry, fs) */\n\tcontext: CliGitProviderOptions['context'];\n\n\t/**\n\t * Git execution options passed through to the underlying Git executor. `gitOptions.isTrusted(repoPath)` is the\n\t * per-repository trust gate: a `false` answer rejects git runs in that path with `WorkspaceUntrustedError` before\n\t * any process starts. It applies only when `context.workspace.isTrusted` is unset; that flag wins when present.\n\t */\n\tgitOptions?: CliGitProviderOptions['gitOptions'];\n\n\t/** Use an existing Cache instance, or one will be created */\n\tcache?: CliGitProviderOptions['cache'];\n\n\t/** Folders, relative to a repository's common git dir, whose worktrees core acts as if didn't exist */\n\tignoredWorktreeFolders?: CliGitProviderOptions['ignoredWorktreeFolders'];\n\n\t/** Refreshes a checkout's index after core's own writes rewrote it (see `CliGitProviderOptions`); off by default */\n\trefreshIndexAfterWrites?: CliGitProviderOptions['refreshIndexAfterWrites'];\n\n\t/**\n\t * Filesystem watching provider. When provided, the {@link GitService}\n\t * will watch repositories for changes (file creates, edits, deletes).\n\t */\n\twatchingProvider?: FileWatchingProvider;\n\n\t/**\n\t * Polls in place of (or beside) the watchers {@link watchingProvider} reports it can't trust. When omitted, no\n\t * watcher is asked.\n\t */\n\twatchPolling?: WatchPollingOptions;\n\n\t/**\n\t * Keeps the caches that never expire (branches, current branch, refs, tags, remotes, worktrees, stashes, gk config,\n\t * paused operation, and what derives from them) fresh for repositories whose `.git` directory nothing watches:\n\t * before such a read, stats the files a watcher would have reported, and lists the ref directories and worktree\n\t * admin entries, applying what moved as a watcher event would. Files git writes by rename are read only once the\n\t * directory they're in moved, so a read of an idle repository costs a stat per git dir, per ref directory, per\n\t * linked worktree and per file git writes in place, at most once per 250ms per repository; a watched one costs\n\t * nothing, unless its watch is suspended, which holds what it hears until it resumes. Never runs git: a repository\n\t * whose git dir nothing resolved yet is read from its own files, and one whose files can't show it (bare, a\n\t * submodule, `--separate-git-dir`, `core.worktree`) isn't validated until a read resolves it, its files looked at\n\t * again every 30 seconds. What moves in a worktree under an {@link ignoredWorktreeFolders} folder clears nothing. Without a\n\t * {@link watchingProvider}, every repository counts as unwatched. A read waits at most `timeoutMs` (default 1000)\n\t * for the stats, then is served from the cache, and the stats run one at a time per repository and two at once\n\t * overall. A stat on a hung mount holds one of Node's file-system threads until it returns; one outstanding past\n\t * `timeoutMs` lets other repositories' stats go on, as long as the stats hold all but two of the threads\n\t * (`UV_THREADPOOL_SIZE`, default 4), which leaves the host two. Off by default.\n\t */\n\tvalidateUnwatchedCaches?: boolean | { readonly timeoutMs?: number };\n\n\t/** For tests only; production never passes it (see `WorktreeSummaryServiceOptions.verifyBaseRemeasure`) */\n\tverifyBaseRemeasure?: WorktreeSummaryServiceOptions['verifyBaseRemeasure'];\n}\n\n/**\n * Creates a ready-to-use {@link GitService} backed by the CLI git provider.\n *\n * This is the primary entry point for standalone (non-VS Code) consumers\n * of the `@gitlens/git-cli` library. It creates a singleton {@link GitService},\n * wires up a {@link CliGitProvider}, and registers it for all repository paths.\n *\n * @example\n * ```typescript\n * const git = createCliGitService({ context: {} });\n *\n * const repo = git.forRepo('/path/to/repo')!;\n * const branches = await repo.branches.getBranches();\n * const status = await repo.status.getStatus();\n * await repo.ops!.fetch({ remote: 'origin' });\n *\n * git.dispose(); // cleans up provider, cache, and module-level state\n * ```\n */\nexport function createCliGitService(options: CliGitServiceOptions): GitService {\n\tconst service = GitService.createSingleton(options.watchingProvider, {\n\t\twatchPolling: options.watchPolling,\n\t\tverifyBaseRemeasure: options.verifyBaseRemeasure,\n\t\t// The host's file system reads the shared `.git/config` the watch service compares reports of\n\t\treadFile: path => options.context.fs.readFile(fileUri(path)),\n\t\t// And lists the directory the admin entries of its worktrees are in\n\t\treadDirectory: path => options.context.fs.readDirectory(fileUri(path)),\n\t});\n\n\tconst locator = options.locator ?? (() => findGitPath(options.gitPath ?? null));\n\tconst provider = new CliGitProvider({\n\t\tcontext: options.context,\n\t\tlocator: locator,\n\t\tgitOptions: options.gitOptions,\n\t\tcache: options.cache,\n\t\tignoredWorktreeFolders: options.ignoredWorktreeFolders,\n\t\trefreshIndexAfterWrites: options.refreshIndexAfterWrites,\n\t});\n\n\tservice.register(provider, () => true);\n\n\tif (options.validateUnwatchedCaches) {\n\t\tconst fs = options.context.fs;\n\t\tconst validator = new UnwatchedCacheValidator({\n\t\t\tcache: provider.cache,\n\t\t\ttimeoutMs:\n\t\t\t\ttypeof options.validateUnwatchedCaches === 'object'\n\t\t\t\t\t? options.validateUnwatchedCaches.timeoutMs\n\t\t\t\t\t: undefined,\n\t\t\tmaxFsThreads: getThreadPoolSize() - 2,\n\t\t\tstat: async path => {\n\t\t\t\ttry {\n\t\t\t\t\tconst stat = await fs.stat(fileUri(path));\n\t\t\t\t\treturn stat != null ? { mtime: stat.mtime, size: stat.size } : undefined;\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isNotFound(ex)) return undefined;\n\n\t\t\t\t\tthrow ex;\n\t\t\t\t}\n\t\t\t},\n\t\t\treadDirectory: path => fs.readDirectory(fileUri(path)),\n\t\t\treadFile: async path => {\n\t\t\t\ttry {\n\t\t\t\t\treturn await fs.readFile(fileUri(path));\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isNotFound(ex)) return undefined;\n\n\t\t\t\t\tthrow ex;\n\t\t\t\t}\n\t\t\t},\n\t\t\t// Only for a path whose git dir is cached, which it finds the common git dir from without running git\n\t\t\tgetIgnoredWorktreeRoots: repoPath =>\n\t\t\t\tprovider.cache.gitDir.get(repoPath) != null\n\t\t\t\t\t? provider.getIgnoredWorktreeRoots(repoPath)\n\t\t\t\t\t: Promise.resolve([]),\n\t\t\tresolveGitDir: repoPath => provider.config.resolveGitDirWithoutGit(repoPath),\n\t\t\t// The watch service keys repositories as the cache does (`getRepositoryKey` normalizes a file path alike)\n\t\t\tisWatched: repoPath => service.watchService?.isRepoWatched(repoPath) ?? false,\n\t\t});\n\t\tprovider.cache.setReadValidator(\n\t\t\trepoPath => validator.validate(repoPath),\n\t\t\t() => validator.getResourceUsage(),\n\t\t);\n\t\tservice.watchService?.onDidChangeRepoWatched(e => {\n\t\t\tif (e.watched) {\n\t\t\t\tvalidator.onWatched(e.repoPath);\n\t\t\t} else {\n\t\t\t\tvalidator.onUnwatched(e.repoPath);\n\t\t\t}\n\t\t});\n\t}\n\n\t// Advance the provider cache's status generation clock from the watch session's global events — the standalone\n\t// analogue of what the VS Code host wires in `GitProviderService`. Without this, a consumer that passes a\n\t// `watchingProvider` and drives watch sessions gets FS events but a FROZEN clock, so `dedupeByStatusGeneration`\n\t// degrades to the pre-change/post-change stale-join this branch exists to fix. Standalone has no `Repository`\n\t// models, so there are no force-fired `closed`/`lastFetched` bypassing the session for the global repo event to\n\t// miss. Subscriptions are torn down with the service (its `watchService`'s emitters are disposed on dispose).\n\tservice.watchService?.onDidChangeWorkingTree(repoPath => provider.cache.onWorkingTreeChanged(repoPath));\n\t// Announced kinds were evicted when core announced its write; evicting them again would discard what the host\n\t// re-read since\n\tservice.watchService?.onDidChangeRepository(e => {\n\t\tconst changes = e.getUnannouncedChanges();\n\t\tif (changes.length) {\n\t\t\tprovider.cache.onRepositoryChanged(e.repoPath, changes, { movedWorktrees: e.movedWorktrees });\n\t\t}\n\t});\n\t// FETCH_HEAD maps to no session change, and there's no `Repository` model here to force-fire `lastFetched` (as\n\t// the VS Code host does), so bridge it straight to the cache or the last-fetched time is never re-read.\n\tservice.watchService?.onDidChangeFetchHead(repoPath =>\n\t\tprovider.cache.onRepositoryChanged(repoPath, ['lastFetched']),\n\t);\n\treturn service;\n}\n\n/** The size of libuv's thread pool, which runs Node's file-system calls, as libuv reads it at its first use */\nfunction getThreadPoolSize(): number {\n\tconst size = Number.parseInt(env.UV_THREADPOOL_SIZE ?? '', 10);\n\treturn Number.isNaN(size) ? 4 : Math.min(Math.max(size, 1), 1024);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAuGA,SAAgB,oBAAoB,SAA2C;CAC9E,MAAM,UAAU,WAAW,gBAAgB,QAAQ,kBAAkB;EACpE,cAAc,QAAQ;EACtB,qBAAqB,QAAQ;EAE7B,WAAU,SAAQ,QAA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c,cAAc,QAAQ,KAAK;EACzE,CAAC;EACD,SAAS,MAAM,kBACd,aAAY,UAAU,SAAS,QAAQ,SACjC,UAAU,iBAAiB,CAClC;EACA,QAAQ,cAAc,wBAAuB,MAAK;GACjD,IAAI,EAAE,SACL,UAAU,UAAU,EAAE,QAAQ;QAE9B,UAAU,YAAY,EAAE,QAAQ;EAElC,CAAC;CACF;CAQA,QAAQ,cAAc,wBAAuB,aAAY,SAAS,MAAM,qBAAqB,QAAQ,CAAC;CAGtG,QAAQ,cAAc,uBAAsB,MAAK;EAChD,MAAM,UAAU,EAAE,sBAAsB;EACxC,IAAI,QAAQ,QACX,SAAS,MAAM,oBAAoB,EAAE,UAAU,SAAS,EAAE,gBAAgB,EAAE,eAAe,CAAC;CAE9F,CAAC;CAGD,QAAQ,cAAc,sBAAqB,aAC1C,SAAS,MAAM,oBAAoB,UAAU,CAAC,aAAa,CAAC,CAC7D;CACA,OAAO;AACR;;AAGA,SAAS,oBAA4B;CACpC,MAAM,OAAO,OAAO,SAAS,IAAI,sBAAsB,IAAI,EAAE;CAC7D,OAAO,OAAO,MAAM,IAAI,IAAI,IAAI,KAAK,IAAI,KAAK,IAAI,MAAM,CAAC,GAAG,IAAI;AACjE"}
@@ -1,3 +1,4 @@
1
+ import { AIModel } from "./models/model.js";
1
2
  //#region ../plus/ai/src/errors.d.ts
2
3
  export declare const enum AIErrorReason {
3
4
  DeniedByOrganization = 0,
@@ -12,13 +13,18 @@ export declare const enum AIErrorReason {
12
13
  Unauthorized = 9,
13
14
  UserQuotaExceeded = 10,
14
15
  NoNetwork = 11,
15
- Unreachable = 12
16
+ Unreachable = 12,
17
+ ModelUnavailable = 13
16
18
  }
17
19
  export declare class AIError extends Error {
18
20
  readonly diagnosticMessage: string;
19
21
  readonly original?: Error;
20
22
  readonly reason: AIErrorReason | undefined;
21
- constructor(reason: AIErrorReason, original?: Error);
23
+ /** Optional provider context. Omitted preserves the legacy GitKraken quota message and credit offers, so a
24
+ * non-GitKraken provider must pass its own to get provider-neutral text (and no credit offers). Also names
25
+ * the provider in the model-unavailable message. */
26
+ readonly provider?: AIModel['provider'];
27
+ constructor(reason: AIErrorReason, original?: Error, provider?: AIModel['provider']);
22
28
  get diagnosticString(): string;
23
29
  }
24
30
  export declare class AuthenticationRequiredError extends Error {
@@ -1,3 +1,4 @@
1
+ import { gitKrakenProviderDescriptor } from "./constants.js";
1
2
  import * as l10n from "@vscode/l10n";
2
3
  //#region ../plus/ai/src/errors.ts
3
4
  let AIErrorReason = /* @__PURE__ */ function(AIErrorReason) {
@@ -14,13 +15,18 @@ let AIErrorReason = /* @__PURE__ */ function(AIErrorReason) {
14
15
  AIErrorReason[AIErrorReason["UserQuotaExceeded"] = 10] = "UserQuotaExceeded";
15
16
  AIErrorReason[AIErrorReason["NoNetwork"] = 11] = "NoNetwork";
16
17
  AIErrorReason[AIErrorReason["Unreachable"] = 12] = "Unreachable";
18
+ AIErrorReason[AIErrorReason["ModelUnavailable"] = 13] = "ModelUnavailable";
17
19
  return AIErrorReason;
18
20
  }({});
19
21
  var AIError = class extends Error {
20
22
  diagnosticMessage;
21
23
  original;
22
24
  reason;
23
- constructor(reason, original) {
25
+ /** Optional provider context. Omitted preserves the legacy GitKraken quota message and credit offers, so a
26
+ * non-GitKraken provider must pass its own to get provider-neutral text (and no credit offers). Also names
27
+ * the provider in the model-unavailable message. */
28
+ provider;
29
+ constructor(reason, original, provider) {
24
30
  let message;
25
31
  let diagnosticMessage;
26
32
  switch (reason) {
@@ -34,7 +40,7 @@ var AIError = class extends Error {
34
40
  break;
35
41
  case 10:
36
42
  diagnosticMessage = "You have exceeded your user token limit";
37
- message = l10n.t("You’ve reached the weekly AI usage included in your plan.");
43
+ message = provider != null && provider.id !== gitKrakenProviderDescriptor.id ? l10n.t("You’ve reached the AI usage limit for {0}. Check your plan and usage with {0}, or switch to a different provider.", provider.name) : l10n.t("You’ve reached the weekly AI usage included in your plan.");
38
44
  break;
39
45
  case 4:
40
46
  diagnosticMessage = "Rate limit exceeded";
@@ -64,6 +70,10 @@ var AIError = class extends Error {
64
70
  diagnosticMessage = "Model not supported for this request";
65
71
  message = l10n.t("Model not supported for this request");
66
72
  break;
73
+ case 13:
74
+ diagnosticMessage = "Model is no longer available";
75
+ message = provider != null ? l10n.t("The selected model is no longer available from {0}. Switch to a different model and try again.", provider.name) : l10n.t("The selected model is no longer available. Switch to a different model and try again.");
76
+ break;
67
77
  case 9:
68
78
  diagnosticMessage = "You are not authorized to use the specified provider or model";
69
79
  message = l10n.t("You are not authorized to use the specified provider or model");
@@ -84,6 +94,7 @@ var AIError = class extends Error {
84
94
  this.diagnosticMessage = diagnosticMessage;
85
95
  this.original = original;
86
96
  this.reason = reason;
97
+ this.provider = provider;
87
98
  Error.captureStackTrace?.(this, new.target);
88
99
  }
89
100
  get diagnosticString() {
@@ -157,7 +168,8 @@ function isAIUnavailableError(ex) {
157
168
  case 10:
158
169
  case 11:
159
170
  case 12:
160
- case 7: return true;
171
+ case 7:
172
+ case 13: return true;
161
173
  default: return false;
162
174
  }
163
175
  }
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":[],"sources":["../../../../plus/ai/src/errors.ts"],"sourcesContent":["import * as l10n from '@vscode/l10n';\n\nexport const enum AIErrorReason {\n\tDeniedByOrganization,\n\tDeniedByUser,\n\tNoEntitlement,\n\tNoRequestData,\n\tRateLimitExceeded,\n\tRateLimitOrFundsExceeded,\n\tRequestTooLarge,\n\tModelNotSupported,\n\tServiceCapacityExceeded,\n\tUnauthorized,\n\tUserQuotaExceeded,\n\tNoNetwork,\n\tUnreachable,\n}\n\nexport class AIError extends Error {\n\treadonly diagnosticMessage: string;\n\treadonly original?: Error;\n\treadonly reason: AIErrorReason | undefined;\n\n\tconstructor(reason: AIErrorReason, original?: Error) {\n\t\tlet message: string;\n\t\tlet diagnosticMessage: string;\n\t\tswitch (reason) {\n\t\t\tcase AIErrorReason.NoEntitlement:\n\t\t\t\tdiagnosticMessage = 'You do not have the required entitlement to use this feature';\n\t\t\t\tmessage = l10n.t('You do not have the required entitlement to use this feature');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.RequestTooLarge:\n\t\t\t\tdiagnosticMessage = 'The request is too large';\n\t\t\t\tmessage = l10n.t('The request is too large');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.UserQuotaExceeded:\n\t\t\t\tdiagnosticMessage = 'You have exceeded your user token limit';\n\t\t\t\tmessage = l10n.t('You’ve reached the weekly AI usage included in your plan.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.RateLimitExceeded:\n\t\t\t\tdiagnosticMessage = 'Rate limit exceeded';\n\t\t\t\tmessage = l10n.t('Rate limit exceeded.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.RateLimitOrFundsExceeded:\n\t\t\t\tdiagnosticMessage = 'Rate limit exceeded or your account is out of funds';\n\t\t\t\tmessage = l10n.t('Rate limit exceeded or your account is out of funds.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.ServiceCapacityExceeded:\n\t\t\t\tdiagnosticMessage = 'Service capacity exceeded';\n\t\t\t\tmessage = l10n.t('Service capacity exceeded.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.NoNetwork:\n\t\t\t\tdiagnosticMessage = 'Unable to reach the AI service. Please check your internet connection.';\n\t\t\t\tmessage = l10n.t('Unable to reach the AI service. Please check your internet connection.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.Unreachable:\n\t\t\t\tdiagnosticMessage = 'The AI service is temporarily unreachable.';\n\t\t\t\tmessage = l10n.t('The AI service is temporarily unreachable.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.NoRequestData:\n\t\t\t\tdiagnosticMessage = original?.message ?? 'No data was provided for the request';\n\t\t\t\tmessage = original?.message ?? l10n.t('No data was provided for the request');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.ModelNotSupported:\n\t\t\t\tdiagnosticMessage = 'Model not supported for this request';\n\t\t\t\tmessage = l10n.t('Model not supported for this request');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.Unauthorized:\n\t\t\t\tdiagnosticMessage = 'You are not authorized to use the specified provider or model';\n\t\t\t\tmessage = l10n.t('You are not authorized to use the specified provider or model');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.DeniedByOrganization:\n\t\t\t\tdiagnosticMessage = 'Your organization has denied access to the specified provider or model';\n\t\t\t\tmessage = l10n.t('Your organization has denied access to the specified provider or model');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.DeniedByUser:\n\t\t\t\tdiagnosticMessage = 'You have denied access to the specified provider or model';\n\t\t\t\tmessage = l10n.t('You have denied access to the specified provider or model');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tdiagnosticMessage = original?.message ?? 'An unknown error occurred';\n\t\t\t\tmessage = original?.message ?? l10n.t('An unknown error occurred');\n\t\t\t\tbreak;\n\t\t}\n\n\t\tsuper(message);\n\n\t\tthis.diagnosticMessage = diagnosticMessage;\n\t\tthis.original = original;\n\t\tthis.reason = reason;\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n\n\tget diagnosticString(): string {\n\t\treturn `${this.name}: ${this.diagnosticMessage}`;\n\t}\n}\n\nexport class AuthenticationRequiredError extends Error {\n\tconstructor() {\n\t\tsuper(l10n.t('Authentication required'));\n\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\nexport class AINoRequestDataError extends AIError {\n\tconstructor(message?: string) {\n\t\tsuper(AIErrorReason.NoRequestData, message ? new Error(message) : undefined);\n\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\nconst noNetworkErrorCodes = new Set([\n\t'ENOTFOUND',\n\t'ECONNREFUSED',\n\t'EAI_AGAIN',\n\t'EHOSTUNREACH',\n\t'ENETUNREACH',\n\t'ENETDOWN',\n\t'UND_ERR_CONNECT_TIMEOUT',\n]);\n\nconst unreachableErrorCodes = new Set(['ECONNRESET', 'ETIMEDOUT', 'UND_ERR_SOCKET']);\n\nexport function classifyNetworkError(ex: unknown): AIErrorReason.NoNetwork | AIErrorReason.Unreachable | undefined {\n\tlet current: unknown = ex;\n\tlet sawFetchFailed = false;\n\tfor (let depth = 0; depth < 5 && current != null; depth++) {\n\t\tif (!(current instanceof Error)) break;\n\n\t\tif (current.name === 'TypeError' && current.message === 'fetch failed') {\n\t\t\tsawFetchFailed = true;\n\t\t}\n\t\tconst code = (current as { code?: unknown }).code;\n\t\tif (typeof code === 'string') {\n\t\t\tif (noNetworkErrorCodes.has(code)) return AIErrorReason.NoNetwork;\n\t\t\tif (unreachableErrorCodes.has(code)) return AIErrorReason.Unreachable;\n\t\t}\n\n\t\tcurrent = (current as { cause?: unknown }).cause;\n\t}\n\treturn sawFetchFailed ? AIErrorReason.NoNetwork : undefined;\n}\n\n/**\n * Whether an error means AI itself is unavailable, rather than this particular request being\n * unacceptable. The distinction matters to any caller running a loop: an unavailable-AI failure will\n * repeat identically for every remaining item, so the loop should stop and say so, while a\n * request-shaped failure (too large, no data) may well succeed on the next item.\n *\n * `RequestTooLarge` and `NoRequestData` are therefore deliberately excluded — they're properties of\n * the one request that failed.\n *\n * An `AuthenticationRequiredError` (expired GitKraken session) counts too: it isn't an `AIError`, but\n * every remaining request will fail identically until the user signs in again.\n */\nexport function isAIUnavailableError(ex: unknown): ex is AIError | AuthenticationRequiredError {\n\tif (ex instanceof AuthenticationRequiredError) return true;\n\tif (!(ex instanceof AIError)) return false;\n\n\tswitch (ex.reason) {\n\t\tcase AIErrorReason.DeniedByOrganization:\n\t\tcase AIErrorReason.DeniedByUser:\n\t\tcase AIErrorReason.NoEntitlement:\n\t\tcase AIErrorReason.RateLimitExceeded:\n\t\tcase AIErrorReason.RateLimitOrFundsExceeded:\n\t\tcase AIErrorReason.ServiceCapacityExceeded:\n\t\tcase AIErrorReason.Unauthorized:\n\t\tcase AIErrorReason.UserQuotaExceeded:\n\t\tcase AIErrorReason.NoNetwork:\n\t\tcase AIErrorReason.Unreachable:\n\t\tcase AIErr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SAAS,UAAU;GAC7B,IAAI,oBAAoB,IAAI,IAAI,GAAG,OAAA;GACnC,IAAI,sBAAsB,IAAI,IAAI,GAAG,OAAA;EACtC;EAEA,UAAW,QAAgC;CAC5C;CACA,OAAO,iBAAA,KAA2C,KAAA;AACnD;;;;;;;;;;;;;AAcA,SAAgB,qBAAqB,IAA0D;CAC9F,IAAI,cAAc,6BAA6B,OAAO;CACtD,IAAI,EAAE,cAAc,UAAU,OAAO;CAErC,QAAQ,GAAG,QAAX;EACC,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA,GACC,OAAO;EACR,SACC,OAAO;CACT;AACD"}
1
+ {"version":3,"file":"errors.js","names":[],"sources":["../../../../plus/ai/src/errors.ts"],"sourcesContent":["import * as l10n from '@vscode/l10n';\nimport { gitKrakenProviderDescriptor } from './constants.js';\nimport type { AIModel } from './models/model.js';\n\nexport const enum AIErrorReason {\n\tDeniedByOrganization,\n\tDeniedByUser,\n\tNoEntitlement,\n\tNoRequestData,\n\tRateLimitExceeded,\n\tRateLimitOrFundsExceeded,\n\tRequestTooLarge,\n\tModelNotSupported,\n\tServiceCapacityExceeded,\n\tUnauthorized,\n\tUserQuotaExceeded,\n\tNoNetwork,\n\tUnreachable,\n\tModelUnavailable,\n}\n\nexport class AIError extends Error {\n\treadonly diagnosticMessage: string;\n\treadonly original?: Error;\n\treadonly reason: AIErrorReason | undefined;\n\t/** Optional provider context. Omitted preserves the legacy GitKraken quota message and credit offers, so a\n\t * non-GitKraken provider must pass its own to get provider-neutral text (and no credit offers). Also names\n\t * the provider in the model-unavailable message. */\n\treadonly provider?: AIModel['provider'];\n\n\tconstructor(reason: AIErrorReason, original?: Error, provider?: AIModel['provider']) {\n\t\tlet message: string;\n\t\tlet diagnosticMessage: string;\n\t\tswitch (reason) {\n\t\t\tcase AIErrorReason.NoEntitlement:\n\t\t\t\tdiagnosticMessage = 'You do not have the required entitlement to use this feature';\n\t\t\t\tmessage = l10n.t('You do not have the required entitlement to use this feature');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.RequestTooLarge:\n\t\t\t\tdiagnosticMessage = 'The request is too large';\n\t\t\t\tmessage = l10n.t('The request is too large');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.UserQuotaExceeded:\n\t\t\t\tdiagnosticMessage = 'You have exceeded your user token limit';\n\t\t\t\tmessage =\n\t\t\t\t\tprovider != null && provider.id !== gitKrakenProviderDescriptor.id\n\t\t\t\t\t\t? l10n.t(\n\t\t\t\t\t\t\t\t'You’ve reached the AI usage limit for {0}. Check your plan and usage with {0}, or switch to a different provider.',\n\t\t\t\t\t\t\t\tprovider.name,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: l10n.t('You’ve reached the weekly AI usage included in your plan.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.RateLimitExceeded:\n\t\t\t\tdiagnosticMessage = 'Rate limit exceeded';\n\t\t\t\tmessage = l10n.t('Rate limit exceeded.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.RateLimitOrFundsExceeded:\n\t\t\t\tdiagnosticMessage = 'Rate limit exceeded or your account is out of funds';\n\t\t\t\tmessage = l10n.t('Rate limit exceeded or your account is out of funds.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.ServiceCapacityExceeded:\n\t\t\t\tdiagnosticMessage = 'Service capacity exceeded';\n\t\t\t\tmessage = l10n.t('Service capacity exceeded.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.NoNetwork:\n\t\t\t\tdiagnosticMessage = 'Unable to reach the AI service. Please check your internet connection.';\n\t\t\t\tmessage = l10n.t('Unable to reach the AI service. Please check your internet connection.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.Unreachable:\n\t\t\t\tdiagnosticMessage = 'The AI service is temporarily unreachable.';\n\t\t\t\tmessage = l10n.t('The AI service is temporarily unreachable.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.NoRequestData:\n\t\t\t\tdiagnosticMessage = original?.message ?? 'No data was provided for the request';\n\t\t\t\tmessage = original?.message ?? l10n.t('No data was provided for the request');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.ModelNotSupported:\n\t\t\t\tdiagnosticMessage = 'Model not supported for this request';\n\t\t\t\tmessage = l10n.t('Model not supported for this request');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.ModelUnavailable:\n\t\t\t\tdiagnosticMessage = 'Model is no longer available';\n\t\t\t\tmessage =\n\t\t\t\t\tprovider != null\n\t\t\t\t\t\t? l10n.t(\n\t\t\t\t\t\t\t\t'The selected model is no longer available from {0}. Switch to a different model and try again.',\n\t\t\t\t\t\t\t\tprovider.name,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: l10n.t(\n\t\t\t\t\t\t\t\t'The selected model is no longer available. Switch to a different model and try again.',\n\t\t\t\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.Unauthorized:\n\t\t\t\tdiagnosticMessage = 'You are not authorized to use the specified provider or model';\n\t\t\t\tmessage = l10n.t('You are not authorized to use the specified provider or model');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.DeniedByOrganization:\n\t\t\t\tdiagnosticMessage = 'Your organization has denied access to the specified provider or model';\n\t\t\t\tmessage = l10n.t('Your organization has denied access to the specified provider or model');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.DeniedByUser:\n\t\t\t\tdiagnosticMessage = 'You have denied access to the specified provider or model';\n\t\t\t\tmessage = l10n.t('You have denied access to the specified provider or model');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tdiagnosticMessage = original?.message ?? 'An unknown error occurred';\n\t\t\t\tmessage = original?.message ?? l10n.t('An unknown error occurred');\n\t\t\t\tbreak;\n\t\t}\n\n\t\tsuper(message);\n\n\t\tthis.diagnosticMessage = diagnosticMessage;\n\t\tthis.original = original;\n\t\tthis.reason = reason;\n\t\tthis.provider = provider;\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n\n\tget diagnosticString(): string {\n\t\treturn `${this.name}: ${this.diagnosticMessage}`;\n\t}\n}\n\nexport class AuthenticationRequiredError extends Error {\n\tconstructor() {\n\t\tsuper(l10n.t('Authentication required'));\n\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\nexport class AINoRequestDataError extends AIError {\n\tconstructor(message?: string) {\n\t\tsuper(AIErrorReason.NoRequestData, message ? new Error(message) : undefined);\n\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\nconst noNetworkErrorCodes = new Set([\n\t'ENOTFOUND',\n\t'ECONNREFUSED',\n\t'EAI_AGAIN',\n\t'EHOSTUNREACH',\n\t'ENETUNREACH',\n\t'ENETDOWN',\n\t'UND_ERR_CONNECT_TIMEOUT',\n]);\n\nconst unreachableErrorCodes = new Set(['ECONNRESET', 'ETIMEDOUT', 'UND_ERR_SOCKET']);\n\nexport function classifyNetworkError(ex: unknown): AIErrorReason.NoNetwork | AIErrorReason.Unreachable | undefined {\n\tlet current: unknown = ex;\n\tlet sawFetchFailed = false;\n\tfor (let depth = 0; depth < 5 && current != null; depth++) {\n\t\tif (!(current instanceof Error)) break;\n\n\t\tif (current.name === 'TypeError' && current.message === 'fetch failed') {\n\t\t\tsawFetchFailed = true;\n\t\t}\n\t\tconst code = (current as { code?: unknown }).code;\n\t\tif (typeof code === 'string') {\n\t\t\tif (noNetworkErrorCodes.has(code)) return AIErrorReason.NoNetwork;\n\t\t\tif (unreachableErrorCodes.has(code)) return AIErrorReason.Unreachable;\n\t\t}\n\n\t\tcurrent = (current as { cause?: unknown }).cause;\n\t}\n\treturn sawFetchFailed ? AIErrorReason.NoNetwork : undefined;\n}\n\n/**\n * Whether an error means AI itself is unavailable, rather than this particular request being\n * unacceptable. The distinction matters to any caller running a loop: an unavailable-AI failure will\n * repeat identically for every remaining item, so the loop should stop and say so, while a\n * request-shaped failure (too large, no data) may well succeed on the next item.\n *\n * `RequestTooLarge` and `NoRequestData` are therefore deliberately excluded — they're properties of\n * the one request that failed.\n *\n * An `AuthenticationRequiredError` (expired GitKraken session) counts too: it isn't an `AIError`, but\n * every remaining request will fail identically until the user signs in again.\n */\nexport function isAIUnavailableError(ex: unknown): ex is AIError | AuthenticationRequiredError {\n\tif (ex instanceof AuthenticationRequiredError) return true;\n\tif (!(ex instanceof AIError)) return false;\n\n\tswitch (ex.reason) {\n\t\tcase AIErrorReason.DeniedByOrganization:\n\t\tcase AIErrorReason.DeniedByUser:\n\t\tcase AIErrorReason.NoEntitlement:\n\t\tcase AIErrorReason.RateLimitExceeded:\n\t\tcase AIErrorReason.RateLimitOrFundsExceeded:\n\t\tcase AIErrorReason.ServiceCapacityExceeded:\n\t\tcase AIErrorReason.Unauthorized:\n\t\tcase AIErrorReason.UserQuotaExceeded:\n\t\tcase AIErrorReason.NoNetwork:\n\t\tcase AIErrorReason.Unreachable:\n\t\tcase AIErrorReason.ModelNotSupported:\n\t\tcase AIErrorReason.ModelUnavailable:\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n"],"mappings":";;;AAIA,IAAkB,gBAAX,yBAAA,eAAA;CACN,cAAA,cAAA,0BAAA,KAAA;CACA,cAAA,cAAA,kBAAA,KAAA;CACA,cAAA,cAAA,mBAAA,KAAA;CACA,cAAA,cAAA,mBAAA,KAAA;CACA,cAAA,cAAA,uBAAA,KAAA;CACA,cAAA,cAAA,8BAAA,KAAA;CACA,cAAA,cAAA,qBAAA,KAAA;CACA,cAAA,cAAA,uBAAA,KAAA;CACA,cAAA,cAAA,6BAAA,KAAA;CACA,cAAA,cAAA,kBAAA,KAAA;CACA,cAAA,cAAA,uBAAA,MAAA;CACA,cAAA,cAAA,eAAA,MAAA;CACA,cAAA,cAAA,iBAAA,MAAA;CACA,cAAA,cAAA,sBAAA,MAAA;;AACD,EAAA,CAAA,CAAA;AAEA,IAAa,UAAb,cAA6B,MAAM;CAClC;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KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA,IACC,OAAO;EACR,SACC,OAAO;CACT;AACD"}
@@ -6,7 +6,7 @@ import { Provider } from "../../../git/models/remoteProvider.js";
6
6
  import { GitUser } from "../../../git/models/user.js";
7
7
  import { IssueOrPullRequest, IssueOrPullRequestState } from "../../../git/models/issueOrPullRequest.js";
8
8
  import { Issue, IssueSearchCriteria, IssueShape, IssueSorting } from "../../../git/models/issue.js";
9
- import { PullRequest, PullRequestMergeMethod, PullRequestSearchCriteria, PullRequestShape, PullRequestStateFilter } from "../../../git/models/pullRequest.js";
9
+ import { PullRequest, PullRequestMergeMethod, PullRequestMergeQueueActionFailureReason, PullRequestMergeQueueActionResult, PullRequestMergeQueueEntry, PullRequestSearchCriteria, PullRequestShape, PullRequestStateFilter } from "../../../git/models/pullRequest.js";
10
10
  import { Account, UnidentifiedAuthor } from "../../../git/models/author.js";
11
11
  import { DefaultBranch } from "../../../git/models/defaultBranch.js";
12
12
  import { RepositoryMetadata } from "../../../git/models/repositoryMetadata.js";
@@ -647,6 +647,20 @@ export declare class GitHubApi {
647
647
  getRepositoryStacks(provider: Provider, token: GitHubTokenInfo, owner: string, repo: string, options?: {
648
648
  baseUrl?: string;
649
649
  }, cancellation?: AbortSignal): Promise<GitHubStackResource[] | undefined>;
650
+ /**
651
+ * The merge-queue entries of the given base branches, keyed by pull request number, in one request — each
652
+ * branch's queue is an alias on the one `repository` selection. For list surfaces whose pull requests arrive
653
+ * through provider-apis' repository-scoped read, which selects no `mergeQueueEntry`; callers join by number.
654
+ *
655
+ * INTERIM: remove once provider-apis carries the merge-queue entry on its pull requests (goals S6).
656
+ *
657
+ * github.com only, like the `mergeQueueEntry` selection: `undefined` on GitHub Enterprise Server, whose schema
658
+ * isn't verified to have `mergeQueue`, and for a repository GitHub reports not found. A branch without a queue
659
+ * contributes nothing. At most the first 100 entries of each queue are read.
660
+ */
661
+ getMergeQueueEntriesForBranches(provider: Provider, token: GitHubTokenInfo, owner: string, repo: string, branches: readonly string[], options?: {
662
+ baseUrl?: string;
663
+ }, cancellation?: AbortSignal): Promise<Map<number, PullRequestMergeQueueEntry> | undefined>;
650
664
  /**
651
665
  * Merges a stacked pull request, and with it every layer below it.
652
666
  *
@@ -662,7 +676,43 @@ export declare class GitHubApi {
662
676
  mergeMethod?: PullRequestMergeMethod;
663
677
  baseUrl?: string;
664
678
  }, cancellation?: AbortSignal): Promise<boolean>;
679
+ /**
680
+ * Adds a pull request to its base branch's merge queue, at the back (no `jump`). GitHub takes no merge method here:
681
+ * the base branch's ruleset decides it. `expectedHeadSha` makes GitHub refuse a head that moved since it was read.
682
+ *
683
+ * GitHub's refusals come back as a `failed` result saying why (see {@link toGitHubMergeQueueActionFailure}),
684
+ * without prompting to re-authenticate on a FORBIDDEN, which here means the account may not queue, not that the
685
+ * token is bad. A failure to reach GitHub, a refused credential or a rate limit is thrown as from any other request,
686
+ * and cancellation throws `CancellationError`. Like every mutation it is never retried. github.com only, like the
687
+ * merge-queue reads: `unsupported` on GitHub Enterprise Server, whose schema isn't verified to have it.
688
+ */
689
+ enqueuePullRequest(provider: Provider, token: GitHubTokenInfo, nodeId: string, expectedHeadSha: string, options?: {
690
+ baseUrl?: string;
691
+ }, cancellation?: AbortSignal): Promise<PullRequestMergeQueueActionResult>;
692
+ /**
693
+ * Removes a pull request from its base branch's merge queue, losing its place there. Fails and throws as
694
+ * {@link enqueuePullRequest} does, and is github.com only like it.
695
+ */
696
+ dequeuePullRequest(provider: Provider, token: GitHubTokenInfo, nodeId: string, options?: {
697
+ baseUrl?: string;
698
+ }, cancellation?: AbortSignal): Promise<PullRequestMergeQueueActionResult>;
665
699
  }
700
+ /**
701
+ * Why GitHub refused to add a pull request to its merge queue or remove it, from the error its GraphQL answer carried
702
+ * (`errors[]`, which `graphql` throws as a `GraphqlResponseError`, or wraps in an `AuthenticationError` for FORBIDDEN
703
+ * and a `RequestNotFoundError` for NOT_FOUND). `undefined` for anything that isn't GitHub's answer about the action
704
+ * — a failure to reach it, a refused credential (HTTP 401/403), a rate limit — which the caller handles like any
705
+ * other request's failure.
706
+ *
707
+ * Only the wordings observed live (2026-11-06; see {@link mergeQueueActionFailurePatterns}) are recognized. Dequeue's
708
+ * refusal is generic and embeds the pull request's title, so it is never matched by wording and maps to `unknown`.
709
+ * When no message matches, the error's `type` decides (FORBIDDEN is `permission`), and anything else is `unknown`.
710
+ * The message is GitHub's own, for logs, never for display.
711
+ */
712
+ export declare function toGitHubMergeQueueActionFailure(ex: unknown): {
713
+ reason: PullRequestMergeQueueActionFailureReason;
714
+ message: string;
715
+ } | undefined;
666
716
  export declare function toGitHubSearchStateQualifier(include: IssueOrPullRequestState[] | undefined): string;
667
717
  export declare function filterPullRequestsBySearchState<T extends {
668
718
  state: IssueOrPullRequestState;