@zixt/host 0.0.61 → 0.0.63

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 (2) hide show
  1. package/dist/index.js +36 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ import { homedir } from "node:os";
31
31
  // package.json
32
32
  var package_default = {
33
33
  name: "@zixt/host",
34
- version: "0.0.61",
34
+ version: "0.0.63",
35
35
  type: "module",
36
36
  exports: {
37
37
  ".": "./src/client.ts",
@@ -14832,6 +14832,7 @@ var BrowserSessionProjection = external_exports.object({
14832
14832
  /** Present only when active work must use a different Machine-local profile. */
14833
14833
  profileContext: BrowserProfileContext.optional()
14834
14834
  }).strict();
14835
+ var StartBrowserSessionRequest = external_exports.object({ url: external_exports.string().min(1).max(2e3).optional() }).strict();
14835
14836
  var StartBrowserSessionResponse = external_exports.object({
14836
14837
  session: BrowserSessionState,
14837
14838
  profileContext: BrowserProfileContext.optional()
@@ -16152,6 +16153,7 @@ var taskGitSummaryLabel = (maxLength, label) => external_exports.string().min(1)
16152
16153
  isSafeSingleLineDisplayText,
16153
16154
  `${label} must not contain control, line-separator, or bidirectional formatting characters`
16154
16155
  );
16156
+ var PullRequestLookup = external_exports.enum(["observed", "unavailable"]);
16155
16157
  var TaskGitSummary = external_exports.object({
16156
16158
  repositories: external_exports.array(
16157
16159
  external_exports.object({
@@ -16166,6 +16168,12 @@ var TaskGitSummary = external_exports.object({
16166
16168
  ahead: external_exports.number().int().min(0),
16167
16169
  behind: external_exports.number().int().min(0),
16168
16170
  changedFiles: external_exports.number().int().min(0),
16171
+ /**
16172
+ * Whether Zixt could actually ask GitHub about this branch.
16173
+ * Absent is a Host that never reported it, which is also "Zixt
16174
+ * does not know" — never evidence that no pull request exists.
16175
+ */
16176
+ pullRequestLookup: PullRequestLookup.optional(),
16169
16177
  pullRequest: external_exports.object({
16170
16178
  number: external_exports.number().int().min(1),
16171
16179
  url: external_exports.string().max(2e3).regex(
@@ -16555,6 +16563,12 @@ var TaskWorkingContextBase = external_exports.object({
16555
16563
  changedFiles: external_exports.number().int().min(0),
16556
16564
  /** Present only for a safely parsed github.com remote. */
16557
16565
  githubRepository: GithubRepositoryName.optional(),
16566
+ /**
16567
+ * Whether the authenticated branch read reached GitHub at all.
16568
+ * Absence of a pull request only means "there is none" when this
16569
+ * says `observed`.
16570
+ */
16571
+ pullRequestLookup: PullRequestLookup.optional(),
16558
16572
  /** Present only when GitHub associates this exact branch with a PR. */
16559
16573
  pullRequest: external_exports.object({
16560
16574
  number: external_exports.number().int().min(1),
@@ -34836,9 +34850,9 @@ function selectPullRequest(output, expectedBaseRepository, expectedHeadRepositor
34836
34850
  try {
34837
34851
  value = JSON.parse(output);
34838
34852
  } catch {
34839
- return void 0;
34853
+ return { lookup: "unavailable" };
34840
34854
  }
34841
- if (!Array.isArray(value)) return void 0;
34855
+ if (!Array.isArray(value)) return { lookup: "unavailable" };
34842
34856
  let best;
34843
34857
  for (const entry of value.slice(0, PULL_REQUEST_LIST_LIMIT)) {
34844
34858
  if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
@@ -34853,16 +34867,17 @@ function selectPullRequest(output, expectedBaseRepository, expectedHeadRepositor
34853
34867
  best = parsed;
34854
34868
  }
34855
34869
  }
34856
- return best;
34870
+ return { lookup: "observed", ...best ? { pullRequest: best } : {} };
34857
34871
  }
34858
34872
  async function pullRequest(command, gitCommand, repositoryCwd, commandCwd, repository, branch, signal) {
34859
- if (!command || !repository || !branch) return void 0;
34873
+ if (!command || !repository || !branch) return { lookup: "unavailable" };
34860
34874
  const baseRepositories = await pullRequestBaseRepositories(
34861
34875
  gitCommand,
34862
34876
  repositoryCwd,
34863
34877
  repository,
34864
34878
  signal
34865
34879
  );
34880
+ let answered = false;
34866
34881
  for (const baseRepository of baseRepositories) {
34867
34882
  const output = await run(
34868
34883
  command.executablePath,
@@ -34886,10 +34901,11 @@ async function pullRequest(command, gitCommand, repositoryCwd, commandCwd, repos
34886
34901
  signal
34887
34902
  );
34888
34903
  if (!output) continue;
34889
- const parsed = selectPullRequest(output, baseRepository, repository, branch);
34890
- if (parsed) return parsed;
34904
+ const observation = selectPullRequest(output, baseRepository, repository, branch);
34905
+ if (observation.lookup === "observed") answered = true;
34906
+ if (observation.pullRequest) return observation;
34891
34907
  }
34892
- return void 0;
34908
+ return { lookup: answered ? "observed" : "unavailable" };
34893
34909
  }
34894
34910
  async function repositoryState(directory, git, env, signal) {
34895
34911
  if (!git.available || !git.executablePath) return null;
@@ -35034,9 +35050,10 @@ var WorkingContextPullRequestCache = class {
35034
35050
  }
35035
35051
  #entries = /* @__PURE__ */ new Map();
35036
35052
  async enrich(context, command, options = {}) {
35037
- if (!command || !context.repositories || context.repositories.length === 0) return context;
35053
+ if (!context.repositories || context.repositories.length === 0) return context;
35038
35054
  const repositories = await Promise.all(
35039
35055
  context.repositories.map(async (repository) => {
35056
+ if (!command) return { ...repository, pullRequestLookup: "unavailable" };
35040
35057
  if (!repository.githubRepository || !repository.branch) return repository;
35041
35058
  const key = JSON.stringify([
35042
35059
  repository.githubRepository.toLocaleLowerCase("en-US"),
@@ -35044,7 +35061,7 @@ var WorkingContextPullRequestCache = class {
35044
35061
  repository.headSha
35045
35062
  ]);
35046
35063
  const cached2 = this.#entries.get(key);
35047
- let observed = cached2?.pullRequest;
35064
+ let observed = cached2?.observation ?? { lookup: "unavailable" };
35048
35065
  if (options.force || !cached2 || this.now() - cached2.checkedAt >= this.ttlMs) {
35049
35066
  observed = await pullRequest(
35050
35067
  command,
@@ -35057,7 +35074,7 @@ var WorkingContextPullRequestCache = class {
35057
35074
  );
35058
35075
  if (!options.signal?.aborted) {
35059
35076
  this.#entries.delete(key);
35060
- this.#entries.set(key, { checkedAt: this.now(), pullRequest: observed });
35077
+ this.#entries.set(key, { checkedAt: this.now(), observation: observed });
35061
35078
  while (this.#entries.size > Math.max(1, this.maxEntries)) {
35062
35079
  const oldest = this.#entries.keys().next().value;
35063
35080
  if (oldest === void 0) break;
@@ -35065,7 +35082,14 @@ var WorkingContextPullRequestCache = class {
35065
35082
  }
35066
35083
  }
35067
35084
  }
35068
- return observed ? { ...repository, pullRequest: observed } : repository;
35085
+ if (observed.lookup === "unavailable") {
35086
+ return repository.pullRequest || repository.pullRequestLookup === "observed" ? repository : { ...repository, pullRequestLookup: "unavailable" };
35087
+ }
35088
+ return {
35089
+ ...repository,
35090
+ pullRequestLookup: observed.lookup,
35091
+ ...observed.pullRequest ? { pullRequest: observed.pullRequest } : {}
35092
+ };
35069
35093
  })
35070
35094
  );
35071
35095
  return TaskWorkingContextObservation.parse({ ...context, repositories });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zixt/host",
3
- "version": "0.0.61",
3
+ "version": "0.0.63",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/client.ts",