@zixt/host 0.0.56 → 0.0.58

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 +108 -9
  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.56",
34
+ version: "0.0.58",
35
35
  type: "module",
36
36
  exports: {
37
37
  ".": "./src/client.ts",
@@ -16232,6 +16232,68 @@ var TaskEventRecord = external_exports.object({
16232
16232
  attachments: external_exports.array(TaskAttachmentRef).max(TASK_MESSAGE_MAX_ATTACHMENTS).optional(),
16233
16233
  at: IsoDate
16234
16234
  });
16235
+ var TaskTimingPhaseKind = external_exports.enum([
16236
+ /** Waiting for a Machine: queue, dispatch, and re-queue between runs. */
16237
+ "queued",
16238
+ /** Assigned to a Machine, session not started yet. */
16239
+ "startup",
16240
+ /** Preparing the environment: dependencies, folders, tools, services. */
16241
+ "setup",
16242
+ /** Reading, searching, and browsing to find things out. */
16243
+ "research",
16244
+ /** Doing the Task's actual work: edits, writes, configuration, other tools. */
16245
+ "work",
16246
+ /** Running checks: tests, builds, linters, verification. */
16247
+ "validation",
16248
+ /** Work that happened after checks had already started in the same run. */
16249
+ "rework",
16250
+ /** Reporting and handing off the result: messages, pull requests, files. */
16251
+ "delivery",
16252
+ /** Parked on a question or an approval a person owed. */
16253
+ "awaiting_person",
16254
+ /** Nothing was running: the Task sat between runs with no one waiting on it. */
16255
+ "idle",
16256
+ /** Measured time the Task's activity record cannot break down. */
16257
+ "unattributed"
16258
+ ]);
16259
+ var TaskTimingBasis = external_exports.enum(["measured", "estimated"]);
16260
+ var TaskTimingPhase = external_exports.object({
16261
+ kind: TaskTimingPhaseKind,
16262
+ durationMs: external_exports.number().int().min(0),
16263
+ basis: TaskTimingBasis,
16264
+ /** Activity steps behind an estimated phase; 0 for measured lifecycle phases. */
16265
+ steps: external_exports.number().int().min(0)
16266
+ }).strict();
16267
+ var TaskTimingRun = external_exports.object({
16268
+ epoch: external_exports.number().int().min(1),
16269
+ status: TaskStatus,
16270
+ startedAt: IsoDate.nullable(),
16271
+ finishedAt: IsoDate.nullable(),
16272
+ /** Waiting for this run's Machine, including re-queue after an earlier run. */
16273
+ waitingMs: external_exports.number().int().min(0),
16274
+ activeMs: external_exports.number().int().min(0),
16275
+ unattributedMs: external_exports.number().int().min(0)
16276
+ }).strict();
16277
+ var TASK_TIMING_MAX_RUNS = 50;
16278
+ var TaskTimingBreakdown = external_exports.object({
16279
+ schemaVersion: external_exports.literal(1),
16280
+ from: IsoDate,
16281
+ to: IsoDate,
16282
+ totalElapsedMs: external_exports.number().int().min(0),
16283
+ /** Time a Machine was running the Task, broken down or not. */
16284
+ activeMs: external_exports.number().int().min(0),
16285
+ /** Queue, startup, approval, and idle time: nothing was being worked on. */
16286
+ waitingMs: external_exports.number().int().min(0),
16287
+ /** Active time the activity record cannot name. */
16288
+ unattributedMs: external_exports.number().int().min(0),
16289
+ runCount: external_exports.number().int().min(0),
16290
+ /** False while the Task can still accrue time; the breakdown is then a snapshot. */
16291
+ settled: external_exports.boolean(),
16292
+ /** True once at least one estimated phase carries time worth showing. */
16293
+ attributed: external_exports.boolean(),
16294
+ phases: external_exports.array(TaskTimingPhase),
16295
+ runs: external_exports.array(TaskTimingRun).max(TASK_TIMING_MAX_RUNS)
16296
+ }).strict();
16235
16297
  var CreateTaskInput = external_exports.object({
16236
16298
  /** Stable client-generated key: retrying the same submission returns one Task. */
16237
16299
  requestId: external_exports.uuid().optional(),
@@ -16491,7 +16553,9 @@ var TaskDetailResponse = external_exports.object({
16491
16553
  reviewAuthorization: TaskReviewAuthorization,
16492
16554
  context: TaskResolvedContext,
16493
16555
  /** Newest host-observed folder/Git state; null until a current Host reports it. */
16494
- workingContext: TaskWorkingContext.nullable().default(null)
16556
+ workingContext: TaskWorkingContext.nullable().default(null),
16557
+ /** TS-19 timing breakdown; null when the Task has no usable timing evidence. */
16558
+ timing: TaskTimingBreakdown.nullable().default(null)
16495
16559
  });
16496
16560
  var TaskSupportBundle = external_exports.object({
16497
16561
  schemaVersion: external_exports.literal(1),
@@ -34629,9 +34693,8 @@ async function pullRequestBaseRepositories(gitCommand, cwd, checkoutRepository,
34629
34693
  add(checkoutRepository);
34630
34694
  return repositories;
34631
34695
  }
34632
- function parsePullRequest(output, expectedBaseRepository, expectedHeadRepository, expectedHeadBranch) {
34696
+ function parsePullRequest(value, expectedBaseRepository, expectedHeadRepository, expectedHeadBranch) {
34633
34697
  try {
34634
- const value = JSON.parse(output);
34635
34698
  const state = typeof value["state"] === "string" ? value["state"].toLowerCase() : "";
34636
34699
  const number4 = Number(value["number"]);
34637
34700
  const location = canonicalPullRequestLocation(value["url"], number4);
@@ -34654,10 +34717,41 @@ function parsePullRequest(output, expectedBaseRepository, expectedHeadRepository
34654
34717
  return void 0;
34655
34718
  }
34656
34719
  }
34720
+ var PULL_REQUEST_LIST_LIMIT = 20;
34721
+ var PULL_REQUEST_STATE_RANK = {
34722
+ // A still-open pull request is the branch's current truth even when an
34723
+ // earlier one from the same branch already merged; a closed one is the
34724
+ // weakest evidence because it says only that somebody gave up on it.
34725
+ open: 3,
34726
+ merged: 2,
34727
+ closed: 1
34728
+ };
34729
+ function selectPullRequest(output, expectedBaseRepository, expectedHeadRepository, expectedHeadBranch) {
34730
+ let value;
34731
+ try {
34732
+ value = JSON.parse(output);
34733
+ } catch {
34734
+ return void 0;
34735
+ }
34736
+ if (!Array.isArray(value)) return void 0;
34737
+ let best;
34738
+ for (const entry of value.slice(0, PULL_REQUEST_LIST_LIMIT)) {
34739
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
34740
+ const parsed = parsePullRequest(
34741
+ entry,
34742
+ expectedBaseRepository,
34743
+ expectedHeadRepository,
34744
+ expectedHeadBranch
34745
+ );
34746
+ if (!parsed) continue;
34747
+ if (!best || PULL_REQUEST_STATE_RANK[parsed.state] > PULL_REQUEST_STATE_RANK[best.state] || PULL_REQUEST_STATE_RANK[parsed.state] === PULL_REQUEST_STATE_RANK[best.state] && parsed.number > best.number) {
34748
+ best = parsed;
34749
+ }
34750
+ }
34751
+ return best;
34752
+ }
34657
34753
  async function pullRequest(command, gitCommand, repositoryCwd, commandCwd, repository, branch, signal) {
34658
34754
  if (!command || !repository || !branch) return void 0;
34659
- const headOwner = repository.split("/")[0];
34660
- const selector = `${headOwner}:${branch}`;
34661
34755
  const baseRepositories = await pullRequestBaseRepositories(
34662
34756
  gitCommand,
34663
34757
  repositoryCwd,
@@ -34670,10 +34764,15 @@ async function pullRequest(command, gitCommand, repositoryCwd, commandCwd, repos
34670
34764
  [
34671
34765
  ...command.prefixArgs ?? [],
34672
34766
  "pr",
34673
- "view",
34674
- selector,
34767
+ "list",
34675
34768
  "--repo",
34676
34769
  baseRepository,
34770
+ "--head",
34771
+ branch,
34772
+ "--state",
34773
+ "all",
34774
+ "--limit",
34775
+ String(PULL_REQUEST_LIST_LIMIT),
34677
34776
  "--json",
34678
34777
  "number,title,url,state,isDraft,baseRefName,headRefName,headRepository,headRepositoryOwner"
34679
34778
  ],
@@ -34682,7 +34781,7 @@ async function pullRequest(command, gitCommand, repositoryCwd, commandCwd, repos
34682
34781
  signal
34683
34782
  );
34684
34783
  if (!output) continue;
34685
- const parsed = parsePullRequest(output, baseRepository, repository, branch);
34784
+ const parsed = selectPullRequest(output, baseRepository, repository, branch);
34686
34785
  if (parsed) return parsed;
34687
34786
  }
34688
34787
  return void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zixt/host",
3
- "version": "0.0.56",
3
+ "version": "0.0.58",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/client.ts",