@codexhost/cli-win32-x64 0.29.1 → 0.29.2

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.
@@ -103296,6 +103296,98 @@ function remoteWorkspaceGroups(hosts, threads) {
103296
103296
  });
103297
103297
  }
103298
103298
 
103299
+ // packages/web-server/src/remote-session-list.ts
103300
+ function encodeRemoteGlobalCursor(input3) {
103301
+ return JSON.stringify({
103302
+ codexhostRemoteCursor: 1,
103303
+ includeArchived: input3.includeArchived,
103304
+ localCursor: input3.localCursor,
103305
+ remoteOffset: input3.remoteOffset
103306
+ });
103307
+ }
103308
+ function encodeRemoteWorkspaceCursor(input3) {
103309
+ return JSON.stringify({
103310
+ codexhostRemoteWorkspaceCursor: 1,
103311
+ workspaceId: input3.workspaceId,
103312
+ includeArchived: input3.includeArchived,
103313
+ offset: input3.offset
103314
+ });
103315
+ }
103316
+ function parseRemoteListCursor(cursor) {
103317
+ let parsed;
103318
+ try {
103319
+ parsed = JSON.parse(cursor);
103320
+ } catch {
103321
+ return;
103322
+ }
103323
+ if (typeof parsed != "object" || parsed === null || Array.isArray(parsed)) return;
103324
+ let record6 = parsed;
103325
+ if (record6.codexhostRemoteCursor === 1)
103326
+ return typeof record6.includeArchived != "boolean" || record6.localCursor !== null && typeof record6.localCursor != "string" || typeof record6.remoteOffset != "number" || !Number.isSafeInteger(record6.remoteOffset) || record6.remoteOffset < 0 ? void 0 : {
103327
+ kind: "global",
103328
+ includeArchived: record6.includeArchived,
103329
+ localCursor: record6.localCursor,
103330
+ remoteOffset: record6.remoteOffset
103331
+ };
103332
+ if (record6.codexhostRemoteWorkspaceCursor === 1)
103333
+ return typeof record6.workspaceId != "string" || record6.workspaceId.length === 0 || typeof record6.includeArchived != "boolean" || typeof record6.offset != "number" || !Number.isSafeInteger(record6.offset) || record6.offset < 0 ? void 0 : {
103334
+ kind: "workspace",
103335
+ workspaceId: record6.workspaceId,
103336
+ includeArchived: record6.includeArchived,
103337
+ offset: record6.offset
103338
+ };
103339
+ }
103340
+ function appendWithAncestors(target2, id2, ancestorsOf) {
103341
+ target2.has(id2) || target2.add(id2);
103342
+ for (let ancestorId of ancestorsOf(id2))
103343
+ target2.has(ancestorId) || target2.add(ancestorId);
103344
+ }
103345
+ function selectRemoteHeadPage(options) {
103346
+ let {
103347
+ orderedIds,
103348
+ priorityIds,
103349
+ workspaceIdOf,
103350
+ ancestorsOf,
103351
+ pageSize = 50,
103352
+ workspaceHeadLimit = 6,
103353
+ maxHeadNonPriority = 150
103354
+ } = options, selected = /* @__PURE__ */ new Set(), workspaceCounts = /* @__PURE__ */ new Map();
103355
+ for (let id2 of priorityIds)
103356
+ appendWithAncestors(selected, id2, ancestorsOf);
103357
+ let nonPriorityCount = 0;
103358
+ for (let index = 0; index < orderedIds.length; index++) {
103359
+ let id2 = orderedIds[index], wsId = workspaceIdOf(id2);
103360
+ if (selected.has(id2)) {
103361
+ wsId !== void 0 && workspaceCounts.set(wsId, (workspaceCounts.get(wsId) ?? 0) + 1);
103362
+ continue;
103363
+ }
103364
+ let inHeadSlice = index < pageSize, wsCount = wsId === void 0 ? workspaceHeadLimit : workspaceCounts.get(wsId) ?? 0, inWorkspacePreview = wsId !== void 0 && wsCount < workspaceHeadLimit && nonPriorityCount < maxHeadNonPriority;
103365
+ !inHeadSlice && !inWorkspacePreview || (appendWithAncestors(selected, id2, ancestorsOf), nonPriorityCount += 1, wsId !== void 0 && workspaceCounts.set(wsId, wsCount + 1));
103366
+ }
103367
+ let hasMore = !1;
103368
+ for (let id2 of orderedIds)
103369
+ if (!selected.has(id2)) {
103370
+ hasMore = !0;
103371
+ break;
103372
+ }
103373
+ let nextRemoteOffset = hasMore ? Math.min(pageSize, orderedIds.length) : orderedIds.length;
103374
+ return {
103375
+ ids: [...selected],
103376
+ hasMore,
103377
+ nextRemoteOffset
103378
+ };
103379
+ }
103380
+ function selectRemoteSlicePage(options) {
103381
+ let { orderedIds, offset, pageSize, ancestorsOf } = options, start = Math.max(0, Math.min(offset, orderedIds.length)), end = Math.min(start + pageSize, orderedIds.length), selected = /* @__PURE__ */ new Set();
103382
+ for (let index = start; index < end; index++)
103383
+ appendWithAncestors(selected, orderedIds[index], ancestorsOf);
103384
+ return {
103385
+ ids: [...selected],
103386
+ hasMore: end < orderedIds.length,
103387
+ nextOffset: end
103388
+ };
103389
+ }
103390
+
103299
103391
  // packages/web-server/src/remote-sessions.ts
103300
103392
  var PREFIX = "web-remote:", PEER_CATALOG_REFRESH_MIN_INTERVAL_MS = 600, hostsSchema = external_exports.array(
103301
103393
  external_exports.object({
@@ -103383,6 +103475,7 @@ var RemoteSessions = class {
103383
103475
  attachments;
103384
103476
  drafts = /* @__PURE__ */ new Map();
103385
103477
  pendingFirstTurns = /* @__PURE__ */ new Map();
103478
+ remoteWorkspaceBySession = /* @__PURE__ */ new Map();
103386
103479
  titleRequests = /* @__PURE__ */ new Set();
103387
103480
  entries = /* @__PURE__ */ new Map();
103388
103481
  hosts = /* @__PURE__ */ new Map();
@@ -104350,24 +104443,205 @@ var RemoteSessions = class {
104350
104443
  })
104351
104444
  }, draft.submission.result;
104352
104445
  }
104446
+ remoteGroupsSnapshot() {
104447
+ return remoteWorkspaceGroups(this.hosts.values(), [
104448
+ ...[...this.entries].map(([sessionId, entry]) => ({
104449
+ sessionId,
104450
+ ...entry.identity,
104451
+ cwd: entry.row.cwd,
104452
+ projectId: this.workspaces?.remoteProjectId(sessionId)
104453
+ })),
104454
+ ...[...this.drafts.values()].filter((d) => !d.canonicalId).map((d) => ({
104455
+ sessionId: d.id,
104456
+ hostId: d.target.hostId,
104457
+ threadId: d.id,
104458
+ cwd: d.target.cwd,
104459
+ projectId: d.projectId
104460
+ }))
104461
+ ]);
104462
+ }
104353
104463
  syncGroups() {
104354
- this.workspaces?.setRemoteGroups(
104355
- remoteWorkspaceGroups(this.hosts.values(), [
104356
- ...[...this.entries].map(([sessionId, entry]) => ({
104357
- sessionId,
104358
- ...entry.identity,
104359
- cwd: entry.row.cwd,
104360
- projectId: this.workspaces?.remoteProjectId(sessionId)
104361
- })),
104362
- ...[...this.drafts.values()].filter((d) => !d.canonicalId).map((d) => ({
104363
- sessionId: d.id,
104364
- hostId: d.target.hostId,
104365
- threadId: d.id,
104366
- cwd: d.target.cwd,
104367
- projectId: d.projectId
104368
- }))
104369
- ])
104370
- );
104464
+ let groups = this.remoteGroupsSnapshot(), bySession = /* @__PURE__ */ new Map();
104465
+ for (let group of groups)
104466
+ for (let sessionId of group.sessionIds)
104467
+ bySession.set(sessionId, group.workspaceId);
104468
+ this.remoteWorkspaceBySession = bySession, this.workspaces?.setRemoteGroups(groups);
104469
+ }
104470
+ workspaceMapForListing() {
104471
+ if (this.remoteWorkspaceBySession.size > 0 || this.entries.size === 0)
104472
+ return this.remoteWorkspaceBySession;
104473
+ let groups = this.remoteGroupsSnapshot(), bySession = /* @__PURE__ */ new Map();
104474
+ for (let group of groups)
104475
+ for (let sessionId of group.sessionIds)
104476
+ bySession.set(sessionId, group.workspaceId);
104477
+ return this.remoteWorkspaceBySession = bySession, bySession;
104478
+ }
104479
+ remoteAncestors(id2) {
104480
+ let ancestors = [], seen = /* @__PURE__ */ new Set([id2]), current = this.entries.get(id2);
104481
+ for (; current; ) {
104482
+ let parentId = current.peerTreeParent ?? (current.row.parentThreadId ? remoteSessionId(current.identity.hostId, current.row.parentThreadId) : void 0);
104483
+ if (!parentId || seen.has(parentId)) break;
104484
+ let parentEntry = this.entries.get(parentId);
104485
+ if (!parentEntry) break;
104486
+ seen.add(parentId), ancestors.push(parentId), current = parentEntry;
104487
+ }
104488
+ return ancestors;
104489
+ }
104490
+ orderedRemoteIds(includeArchived, workspaceFilter) {
104491
+ let eligible = [];
104492
+ for (let [id2, entry] of this.entries)
104493
+ !includeArchived && entry.archived || workspaceFilter && workspaceFilter.bySession.get(id2) !== workspaceFilter.workspaceId || eligible.push({ id: id2, updatedAt: threadRecencyMs(entry.row) });
104494
+ return eligible.sort((left, right) => right.updatedAt - left.updatedAt), eligible.map((item) => item.id);
104495
+ }
104496
+ remotePriorityIds(includeArchived) {
104497
+ let priority = /* @__PURE__ */ new Set(), pinnedIds = this.workspaces?.pinnedSessionIds() ?? this.syncPins();
104498
+ for (let pinnedId of pinnedIds) {
104499
+ let entry = this.entries.get(pinnedId);
104500
+ entry && (includeArchived || !entry.archived) && priority.add(pinnedId);
104501
+ }
104502
+ for (let [id2, entry] of this.entries)
104503
+ !includeArchived && entry.archived || (entry.online && entry.row.status.type === "active" || entry.view !== void 0 || this.hasPendingInteraction(id2, entry)) && priority.add(id2);
104504
+ return priority;
104505
+ }
104506
+ async listRemoteSessions(args, next) {
104507
+ let request3 = requestOf(args);
104508
+ if (request3.sessionId !== void 0) {
104509
+ let id2 = request3.sessionId;
104510
+ if (typeof id2 != "string" || !id2.startsWith(PREFIX)) return next();
104511
+ if (request3.cursor !== void 0)
104512
+ throw new SessionRuntimeError("session/list-invalid", "Invalid direct-link identity.");
104513
+ let draft = this.drafts.get(id2);
104514
+ if (draft && !draft.canonicalId)
104515
+ return { items: [this.draftSummary(draft)], archivedSessionIds: this.syncArchives() };
104516
+ let canonicalId = draft?.canonicalId ?? id2;
104517
+ if (canonicalId.startsWith(`${PREFIX}draft-`))
104518
+ throw new SessionRuntimeError("session/not-found", "Remote draft Session is no longer available.");
104519
+ let identity2 = remoteSessionIdentity(canonicalId), entry;
104520
+ if (identity2?.hostId.startsWith(REMOTE_PEER_HOST_ID_PREFIX) ? entry = await this.lookupPeerSummary(canonicalId, identity2.hostId) : (this.entries.has(canonicalId) || await this.refresh(), entry = this.entries.get(canonicalId)), !entry) throw new SessionRuntimeError("remote/not-found", "Remote Thread not found");
104521
+ return {
104522
+ items: [this.summary(canonicalId, entry)],
104523
+ archivedSessionIds: this.syncArchives()
104524
+ };
104525
+ }
104526
+ let includeArchived = request3.includeArchived === !0, rawCursor = typeof request3.cursor == "string" ? request3.cursor : void 0, parsedCursor = rawCursor === void 0 ? void 0 : parseRemoteListCursor(rawCursor), workspaceId = typeof request3.workspaceId == "string" ? request3.workspaceId : void 0;
104527
+ if (workspaceId !== void 0 && workspaceId.startsWith("remote-workspace:")) {
104528
+ if (request3.cursor === void 0 || typeof request3.cursor != "string")
104529
+ throw new SessionRuntimeError("session/list-invalid", "workspaceId only continues a cursor page.");
104530
+ if (request3.includeArchived !== void 0 && typeof request3.includeArchived != "boolean")
104531
+ throw new SessionRuntimeError("session/list-invalid", "includeArchived must be a boolean.");
104532
+ let offset = 0;
104533
+ if (parsedCursor?.kind === "workspace") {
104534
+ if (parsedCursor.workspaceId !== workspaceId || parsedCursor.includeArchived !== includeArchived)
104535
+ throw new SessionRuntimeError(
104536
+ "session/list-invalid",
104537
+ "Invalid session list cursor or archive scope."
104538
+ );
104539
+ offset = parsedCursor.offset;
104540
+ } else if (parsedCursor?.kind === "global" && parsedCursor.includeArchived !== includeArchived)
104541
+ throw new SessionRuntimeError("session/list-invalid", "Invalid session list cursor or archive scope.");
104542
+ let bySession2 = this.workspaceMapForListing(), orderedIds2 = this.orderedRemoteIds(includeArchived, { workspaceId, bySession: bySession2 }), page = selectRemoteSlicePage({
104543
+ orderedIds: orderedIds2,
104544
+ offset,
104545
+ pageSize: 50,
104546
+ ancestorsOf: (id2) => this.remoteAncestors(id2)
104547
+ });
104548
+ return {
104549
+ items: [
104550
+ ...offset === 0 ? [...this.drafts.values()].filter((d) => !d.canonicalId && bySession2.get(d.id) === workspaceId).map((d) => this.draftSummary(d)) : [],
104551
+ ...page.ids.map((id2) => {
104552
+ let entry = this.entries.get(id2);
104553
+ return entry ? this.summary(id2, entry) : void 0;
104554
+ }).filter((item) => item !== void 0)
104555
+ ],
104556
+ archivedSessionIds: this.syncArchives(),
104557
+ nextCursor: page.hasMore ? encodeRemoteWorkspaceCursor({
104558
+ workspaceId,
104559
+ includeArchived,
104560
+ offset: page.nextOffset
104561
+ }) : null
104562
+ };
104563
+ }
104564
+ let callLocalWithCursor = async (localCursor) => {
104565
+ if (localCursor === null)
104566
+ return {
104567
+ items: [],
104568
+ archivedSessionIds: this.syncArchives(),
104569
+ nextCursor: null
104570
+ };
104571
+ let target2 = typeof args.request == "object" && args.request !== null && !Array.isArray(args.request) ? args.request : typeof args._request == "object" && args._request !== null && !Array.isArray(args._request) ? args._request : args, hadCursor = Object.hasOwn(target2, "cursor"), previousCursor = target2.cursor;
104572
+ target2.cursor = localCursor;
104573
+ try {
104574
+ return await next();
104575
+ } finally {
104576
+ hadCursor ? target2.cursor = previousCursor : delete target2.cursor;
104577
+ }
104578
+ };
104579
+ if (workspaceId !== void 0) {
104580
+ if (parsedCursor?.kind === "workspace")
104581
+ throw new SessionRuntimeError("session/list-invalid", "Invalid session list cursor or archive scope.");
104582
+ if (parsedCursor?.kind === "global") {
104583
+ if (parsedCursor.includeArchived !== includeArchived)
104584
+ throw new SessionRuntimeError(
104585
+ "session/list-invalid",
104586
+ "Invalid session list cursor or archive scope."
104587
+ );
104588
+ return callLocalWithCursor(parsedCursor.localCursor);
104589
+ }
104590
+ return next();
104591
+ }
104592
+ if (request3.cursor !== void 0) {
104593
+ if (parsedCursor?.kind === "workspace")
104594
+ throw new SessionRuntimeError("session/list-invalid", "Invalid session list cursor or archive scope.");
104595
+ if (parsedCursor?.kind === "global") {
104596
+ if (parsedCursor.includeArchived !== includeArchived)
104597
+ throw new SessionRuntimeError(
104598
+ "session/list-invalid",
104599
+ "Invalid session list cursor or archive scope."
104600
+ );
104601
+ let local2 = await callLocalWithCursor(parsedCursor.localCursor), orderedIds2 = this.orderedRemoteIds(includeArchived), page = selectRemoteSlicePage({
104602
+ orderedIds: orderedIds2,
104603
+ offset: parsedCursor.remoteOffset,
104604
+ pageSize: 50,
104605
+ ancestorsOf: (id2) => this.remoteAncestors(id2)
104606
+ }), remoteItems2 = page.ids.map((id2) => {
104607
+ let entry = this.entries.get(id2);
104608
+ return entry ? this.summary(id2, entry) : void 0;
104609
+ }).filter((item) => item !== void 0), localNextCursor = local2.nextCursor ?? null, nextCursor = page.hasMore ? encodeRemoteGlobalCursor({
104610
+ includeArchived,
104611
+ localCursor: localNextCursor,
104612
+ remoteOffset: page.nextOffset
104613
+ }) : localNextCursor;
104614
+ return {
104615
+ ...local2,
104616
+ items: [...local2.items, ...remoteItems2],
104617
+ nextCursor
104618
+ };
104619
+ }
104620
+ return next();
104621
+ }
104622
+ this.refreshBackground().catch(() => {
104623
+ });
104624
+ let local = await next(), draftItems = [...this.drafts.values()].filter((d) => !d.canonicalId).map((d) => this.draftSummary(d)), bySession = this.workspaceMapForListing(), orderedIds = this.orderedRemoteIds(includeArchived), head = selectRemoteHeadPage({
104625
+ orderedIds,
104626
+ priorityIds: this.remotePriorityIds(includeArchived),
104627
+ workspaceIdOf: (id2) => bySession.get(id2),
104628
+ ancestorsOf: (id2) => this.remoteAncestors(id2)
104629
+ }), remoteItems = head.ids.map((id2) => {
104630
+ let entry = this.entries.get(id2);
104631
+ return entry ? this.summary(id2, entry) : void 0;
104632
+ }).filter((item) => item !== void 0);
104633
+ return head.hasMore ? {
104634
+ ...local,
104635
+ items: [...local.items, ...draftItems, ...remoteItems],
104636
+ nextCursor: encodeRemoteGlobalCursor({
104637
+ includeArchived,
104638
+ localCursor: local.nextCursor ?? null,
104639
+ remoteOffset: head.nextRemoteOffset
104640
+ })
104641
+ } : {
104642
+ ...local,
104643
+ items: [...local.items, ...draftItems, ...remoteItems]
104644
+ };
104371
104645
  }
104372
104646
  reference(entry) {
104373
104647
  return { ...entry.identity };
@@ -104435,7 +104709,6 @@ var RemoteSessions = class {
104435
104709
  kind: "cached",
104436
104710
  asOfSeq: 0,
104437
104711
  values: {
104438
- ...defaultProjections(),
104439
104712
  title: threadListTitle({ ...entry.row, id: entry.identity.threadId }),
104440
104713
  remoteHost: {
104441
104714
  ...entry.identity,
@@ -104931,38 +105204,8 @@ var RemoteSessions = class {
104931
105204
  return this.createInProject(request4.workspaceId, request4.sessionId);
104932
105205
  }
104933
105206
  }
104934
- if (method2 === "session/list") {
104935
- let request4 = requestOf(args);
104936
- if (request4.sessionId !== void 0) {
104937
- let id3 = request4.sessionId;
104938
- if (typeof id3 != "string" || !id3.startsWith(PREFIX)) return next();
104939
- if (request4.cursor !== void 0)
104940
- throw new SessionRuntimeError("session/list-invalid", "Invalid direct-link identity.");
104941
- let draft2 = this.drafts.get(id3);
104942
- if (draft2 && !draft2.canonicalId)
104943
- return { items: [this.draftSummary(draft2)], archivedSessionIds: this.syncArchives() };
104944
- let canonicalId = draft2?.canonicalId ?? id3;
104945
- if (canonicalId.startsWith(`${PREFIX}draft-`))
104946
- throw new SessionRuntimeError("session/not-found", "Remote draft Session is no longer available.");
104947
- let identity2 = remoteSessionIdentity(canonicalId), entry;
104948
- if (identity2?.hostId.startsWith(REMOTE_PEER_HOST_ID_PREFIX) ? entry = await this.lookupPeerSummary(canonicalId, identity2.hostId) : (this.entries.has(canonicalId) || await this.refresh(), entry = this.entries.get(canonicalId)), !entry) throw new SessionRuntimeError("remote/not-found", "Remote Thread not found");
104949
- return {
104950
- items: [this.summary(canonicalId, entry)],
104951
- archivedSessionIds: this.syncArchives()
104952
- };
104953
- }
104954
- this.refreshBackground().catch(() => {
104955
- });
104956
- let local = await next();
104957
- return {
104958
- ...local,
104959
- items: [
104960
- ...local.items,
104961
- ...[...this.drafts.values()].filter((d) => !d.canonicalId).map((d) => this.draftSummary(d)),
104962
- ...[...this.entries].map(([id3, entry]) => this.summary(id3, entry))
104963
- ]
104964
- };
104965
- }
105207
+ if (method2 === "session/list")
105208
+ return this.listRemoteSessions(args, next);
104966
105209
  if (method2 === "session/search")
104967
105210
  return this.search(args, next);
104968
105211
  let request3 = requestOf(args), id2 = request3.sessionId ?? request3.address?.sessionId ?? request3.agentId ?? args.agentId;
@@ -144466,7 +144709,7 @@ async function snapshotPackagedHost(distribution, data2) {
144466
144709
 
144467
144710
  // packages/web-server/src/main.ts
144468
144711
  var RELEASE_WEB = !0, DISTRIBUTION_ROOT = resolve25(import.meta.dirname, ".."), PACKED_WEB = join36(DISTRIBUTION_ROOT, "web"), PACKED = existsSync16(join36(PACKED_WEB, "plugins.json")), REPO_ROOT = resolve25(import.meta.dirname, "../../.."), SERVER_VERSION = resolveServerVersion(
144469
- "0.29.1",
144712
+ "0.29.2",
144470
144713
  [join36(DISTRIBUTION_ROOT, "package.json"), join36(REPO_ROOT, "package.json")]
144471
144714
  );
144472
144715
  if (PACKED) {
package/bin/codexhost.exe CHANGED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codexhost/cli-win32-x64",
3
- "version": "0.29.1",
3
+ "version": "0.29.2",
4
4
  "description": "Run Pi and Claude Code as first-class external harnesses inside Codex Desktop.",
5
5
  "type": "module",
6
6
  "files": [