@sideboard-ai/core 0.1.279 → 0.1.281

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 (52) hide show
  1. package/dist/{abletime-VCVPSLSU.js → abletime-WLDBJJUI.js} +3 -3
  2. package/dist/{abletime-VRATUMDO.js → abletime-X64E3GUJ.js} +3 -3
  3. package/dist/{abletime-oauth-4K7MICAD.js → abletime-oauth-AXR676W5.js} +2 -2
  4. package/dist/{abletime-oauth-4C4G2J3R.js → abletime-oauth-UWOCEICP.js} +2 -2
  5. package/dist/{abletime-rest-PIBCNHF3.js → abletime-rest-LPUDJUEP.js} +2 -2
  6. package/dist/{abletime-rest-6N63ZVQ3.js → abletime-rest-S4XWEXV2.js} +2 -2
  7. package/dist/{agents-DYCFLDNL.js → agents-2IE4HKHA.js} +5 -5
  8. package/dist/{agents-RXP5NZBC.js → agents-XA2E64AW.js} +5 -5
  9. package/dist/{chunk-V5DMHB6Y.js → chunk-2KNO2GJQ.js} +781 -159
  10. package/dist/{chunk-TZ5JHIYK.js → chunk-2SJXQ4UX.js} +68 -21
  11. package/dist/{chunk-K7MWJLR7.js → chunk-5MGLNVNK.js} +6 -906
  12. package/dist/{chunk-RK5PIWCW.js → chunk-ADXVTKLC.js} +12 -4
  13. package/dist/{chunk-Y7JPL4WA.js → chunk-BDAUPNHL.js} +3 -4
  14. package/dist/{chunk-R7HLXD4I.js → chunk-BS3QLVPL.js} +93 -57
  15. package/dist/{chunk-CPGJ5ICZ.js → chunk-BYZ7F2BQ.js} +766 -148
  16. package/dist/{chunk-2J34G3WJ.js → chunk-DGPROCE5.js} +93 -57
  17. package/dist/{chunk-HQXBBUQX.js → chunk-DQZPF6WL.js} +12 -11
  18. package/dist/{chunk-YDXNCBA2.js → chunk-EIEAR62M.js} +12 -11
  19. package/dist/{chunk-XKZAVGTT.js → chunk-I6HSGKMZ.js} +1 -1
  20. package/dist/chunk-JPH7PYSK.js +1241 -0
  21. package/dist/{chunk-IPPY3FG5.js → chunk-K5XSTHHP.js} +6 -906
  22. package/dist/chunk-N5UGX3JL.js +1239 -0
  23. package/dist/{chunk-HNNS25SG.js → chunk-OCUIZD4Y.js} +14 -4
  24. package/dist/{chunk-IJDQKC5A.js → chunk-PY4UCMRI.js} +4 -4
  25. package/dist/{chunk-NQ7JMVSU.js → chunk-U7HAVAGJ.js} +1 -1
  26. package/dist/{chunk-PZURG3XN.js → chunk-VA55JG2I.js} +4 -4
  27. package/dist/{chunk-CPA43FBK.js → chunk-W7HIK2A6.js} +3 -4
  28. package/dist/{chunk-SKSOCIJT.js → chunk-WY2IAB7J.js} +68 -21
  29. package/dist/{chunk-QINJKNLR.js → chunk-XTPQEZZA.js} +2 -2
  30. package/dist/{conductor-J6WDOXWM.js → conductor-CNSCOC54.js} +5 -5
  31. package/dist/{conductor-OW6NAK3N.js → conductor-U776JSXQ.js} +5 -5
  32. package/dist/{coordinator-prompt-Z2D32HWK.js → coordinator-prompt-4DJIHSE6.js} +3 -3
  33. package/dist/{coordinator-prompt-ERTHREGJ.js → coordinator-prompt-SVVGU6AZ.js} +3 -3
  34. package/dist/{global-workspace-5PJXO45Z.js → global-workspace-UPUDWIS6.js} +3 -3
  35. package/dist/{global-workspace-AK5PSPQ2.js → global-workspace-XON4YZXE.js} +3 -3
  36. package/dist/index.cjs +3819 -2995
  37. package/dist/index.d.cts +103 -30
  38. package/dist/index.d.ts +103 -30
  39. package/dist/index.js +1013 -1001
  40. package/dist/mcp/run-stdio.cjs +2075 -1313
  41. package/dist/mcp/run-stdio.js +743 -785
  42. package/dist/{orchestrator-KY2KBBE2.js → orchestrator-FPGVKEID.js} +7 -7
  43. package/dist/{orchestrator-E5WK57DA.js → orchestrator-HWJHK5NL.js} +7 -7
  44. package/dist/{thread-store-B3ZM4QEZ.js → thread-store-7XBOUQ5K.js} +1 -1
  45. package/dist/{thread-store-SHCUBWB3.js → thread-store-ZQZDREVH.js} +1 -1
  46. package/dist/{workspaces-UP6DQ3WL.js → workspaces-7AJ5RZ3P.js} +7 -3
  47. package/dist/{workspaces-WU2RNLDV.js → workspaces-F76BWCSI.js} +7 -3
  48. package/dist/{worktree-L57T3KH7.js → worktree-NKLNVNXX.js} +20 -15
  49. package/dist/{worktree-Q6UJHG25.js → worktree-YTZC3UQN.js} +14 -9
  50. package/package.json +1 -1
  51. package/dist/chunk-FWNL62VA.js +0 -308
  52. package/dist/chunk-JANCPF7Z.js +0 -310
@@ -9,16 +9,16 @@ import {
9
9
  resolveSendFollowUp,
10
10
  startOrchestration,
11
11
  waitForPidExit
12
- } from "./chunk-V5DMHB6Y.js";
13
- import "./chunk-HNNS25SG.js";
12
+ } from "./chunk-2KNO2GJQ.js";
13
+ import "./chunk-OCUIZD4Y.js";
14
14
  import "./chunk-GWFVCCJZ.js";
15
- import "./chunk-HQXBBUQX.js";
16
- import "./chunk-Y7JPL4WA.js";
15
+ import "./chunk-DQZPF6WL.js";
16
+ import "./chunk-BDAUPNHL.js";
17
17
  import "./chunk-7H655NEW.js";
18
18
  import "./chunk-PGPSIEMW.js";
19
- import "./chunk-SKSOCIJT.js";
20
- import "./chunk-IPPY3FG5.js";
21
- import "./chunk-FWNL62VA.js";
19
+ import "./chunk-WY2IAB7J.js";
20
+ import "./chunk-K5XSTHHP.js";
21
+ import "./chunk-N5UGX3JL.js";
22
22
  import "./chunk-2P4XKWV2.js";
23
23
  import "./chunk-ROPGQRPU.js";
24
24
  import "./chunk-N7WZ6NIN.js";
@@ -11,18 +11,18 @@ import {
11
11
  resolveSendFollowUp,
12
12
  startOrchestration,
13
13
  waitForPidExit
14
- } from "./chunk-CPGJ5ICZ.js";
14
+ } from "./chunk-BYZ7F2BQ.js";
15
15
  import "./chunk-LX5R5JOR.js";
16
16
  import "./chunk-4GK32AYX.js";
17
17
  import "./chunk-5DZUWGKV.js";
18
- import "./chunk-RK5PIWCW.js";
18
+ import "./chunk-ADXVTKLC.js";
19
19
  import "./chunk-TQRSVE7D.js";
20
20
  import "./chunk-P2BSMNHB.js";
21
21
  import "./chunk-VKQGAWHY.js";
22
- import "./chunk-YDXNCBA2.js";
23
- import "./chunk-CPA43FBK.js";
24
- import "./chunk-TZ5JHIYK.js";
25
- import "./chunk-K7MWJLR7.js";
22
+ import "./chunk-EIEAR62M.js";
23
+ import "./chunk-W7HIK2A6.js";
24
+ import "./chunk-2SJXQ4UX.js";
25
+ import "./chunk-5MGLNVNK.js";
26
26
  import "./chunk-N2WW62LF.js";
27
27
  import "./chunk-DD67JWTN.js";
28
28
  import "./chunk-2UG25RMK.js";
@@ -31,7 +31,7 @@ import "./chunk-NSTQ6QKD.js";
31
31
  import "./chunk-WWUABK6B.js";
32
32
  import "./chunk-FJZWM2ON.js";
33
33
  import "./chunk-UN5Q7POQ.js";
34
- import "./chunk-JANCPF7Z.js";
34
+ import "./chunk-JPH7PYSK.js";
35
35
  import "./chunk-4RZRHTSZ.js";
36
36
  import "./chunk-KGZBYWZ3.js";
37
37
  import "./chunk-H5XL4KUS.js";
@@ -17,7 +17,7 @@ import {
17
17
  updateThread,
18
18
  withThreadLock,
19
19
  writeThread
20
- } from "./chunk-JANCPF7Z.js";
20
+ } from "./chunk-JPH7PYSK.js";
21
21
  import "./chunk-4RZRHTSZ.js";
22
22
  import "./chunk-KGZBYWZ3.js";
23
23
  import "./chunk-H5XL4KUS.js";
@@ -15,7 +15,7 @@ import {
15
15
  updateThread,
16
16
  withThreadLock,
17
17
  writeThread
18
- } from "./chunk-FWNL62VA.js";
18
+ } from "./chunk-N5UGX3JL.js";
19
19
  import "./chunk-UWQ6UCIB.js";
20
20
  import "./chunk-77WWLBCI.js";
21
21
  import "./chunk-EHT2DRT4.js";
@@ -1,13 +1,15 @@
1
1
  import {
2
2
  addWorkspace,
3
3
  ensureWorkspace,
4
+ isRemovedWorkspace,
4
5
  listWorkspaces,
5
6
  primaryCheckoutFromLinkedWorktree,
6
7
  removeWorkspace,
8
+ sameWorkspacePath,
7
9
  syncWorkspacesFromThreads
8
- } from "./chunk-SKSOCIJT.js";
9
- import "./chunk-IPPY3FG5.js";
10
- import "./chunk-FWNL62VA.js";
10
+ } from "./chunk-WY2IAB7J.js";
11
+ import "./chunk-K5XSTHHP.js";
12
+ import "./chunk-N5UGX3JL.js";
11
13
  import "./chunk-2P4XKWV2.js";
12
14
  import "./chunk-6K64FJDD.js";
13
15
  import "./chunk-UWQ6UCIB.js";
@@ -22,8 +24,10 @@ import "./chunk-EHT2DRT4.js";
22
24
  export {
23
25
  addWorkspace,
24
26
  ensureWorkspace,
27
+ isRemovedWorkspace,
25
28
  listWorkspaces,
26
29
  primaryCheckoutFromLinkedWorktree,
27
30
  removeWorkspace,
31
+ sameWorkspacePath,
28
32
  syncWorkspacesFromThreads
29
33
  };
@@ -3,12 +3,14 @@
3
3
  import {
4
4
  addWorkspace,
5
5
  ensureWorkspace,
6
+ isRemovedWorkspace,
6
7
  listWorkspaces,
7
8
  primaryCheckoutFromLinkedWorktree,
8
9
  removeWorkspace,
10
+ sameWorkspacePath,
9
11
  syncWorkspacesFromThreads
10
- } from "./chunk-TZ5JHIYK.js";
11
- import "./chunk-K7MWJLR7.js";
12
+ } from "./chunk-2SJXQ4UX.js";
13
+ import "./chunk-5MGLNVNK.js";
12
14
  import "./chunk-N2WW62LF.js";
13
15
  import "./chunk-DD67JWTN.js";
14
16
  import "./chunk-2UG25RMK.js";
@@ -17,15 +19,17 @@ import "./chunk-NSTQ6QKD.js";
17
19
  import "./chunk-WWUABK6B.js";
18
20
  import "./chunk-FJZWM2ON.js";
19
21
  import "./chunk-UN5Q7POQ.js";
20
- import "./chunk-JANCPF7Z.js";
22
+ import "./chunk-JPH7PYSK.js";
21
23
  import "./chunk-4RZRHTSZ.js";
22
24
  import "./chunk-KGZBYWZ3.js";
23
25
  import "./chunk-H5XL4KUS.js";
24
26
  export {
25
27
  addWorkspace,
26
28
  ensureWorkspace,
29
+ isRemovedWorkspace,
27
30
  listWorkspaces,
28
31
  primaryCheckoutFromLinkedWorktree,
29
32
  removeWorkspace,
33
+ sameWorkspacePath,
30
34
  syncWorkspacesFromThreads
31
35
  };
@@ -1,11 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import {
4
- FAMOUS_SOCCER_TEAMS,
5
4
  PR_DETAILS_JSON_FIELDS,
6
- allocateTeamName,
7
5
  allocateTeamSlug,
8
- branchDisplayLabel,
9
6
  canonicalizeRepoPath,
10
7
  collectTakenTeamSlugs,
11
8
  commitAll,
@@ -31,15 +28,12 @@ import {
31
28
  githubAgentGitEnv,
32
29
  isDefaultishSourceRef,
33
30
  isDirty,
34
- isPlaceholderBranch,
35
31
  isSideboardScratchPath,
36
32
  listBranches,
37
33
  listPrs,
38
34
  listWorktrees,
39
- lookupSoccerTeam,
40
35
  markPrReady,
41
36
  mergePr,
42
- normalizeWorktreePath,
43
37
  originFetchBranch,
44
38
  originGhRepoEnv,
45
39
  parseGithubSlugFromRemoteUrl,
@@ -55,14 +49,8 @@ import {
55
49
  resolveWorktreeStartPoint,
56
50
  slugify,
57
51
  suggestSlug,
58
- switchWorktreeBranch,
59
- threadDisplayLabel,
60
- ticketSlugForBranch,
61
- worktreeDisplayLabel,
62
- worktreeDisplayLabelForGroup,
63
- worktreeNameFromPath,
64
- worktreeSlugForTicket
65
- } from "./chunk-K7MWJLR7.js";
52
+ switchWorktreeBranch
53
+ } from "./chunk-5MGLNVNK.js";
66
54
  import "./chunk-N2WW62LF.js";
67
55
  import "./chunk-DD67JWTN.js";
68
56
  import "./chunk-2UG25RMK.js";
@@ -71,7 +59,22 @@ import "./chunk-NSTQ6QKD.js";
71
59
  import "./chunk-WWUABK6B.js";
72
60
  import "./chunk-FJZWM2ON.js";
73
61
  import "./chunk-UN5Q7POQ.js";
74
- import "./chunk-JANCPF7Z.js";
62
+ import {
63
+ FAMOUS_SOCCER_TEAMS,
64
+ allocateTeamName,
65
+ branchDisplayLabel,
66
+ isPlaceholderBranch,
67
+ lookupSoccerTeam,
68
+ normalizeWorkspaceTags,
69
+ normalizeWorktreePath,
70
+ threadDisplayLabel,
71
+ ticketSlugForBranch,
72
+ workspaceTagsFromGroup,
73
+ worktreeDisplayLabel,
74
+ worktreeDisplayLabelForGroup,
75
+ worktreeNameFromPath,
76
+ worktreeSlugForTicket
77
+ } from "./chunk-JPH7PYSK.js";
75
78
  import "./chunk-4RZRHTSZ.js";
76
79
  import "./chunk-KGZBYWZ3.js";
77
80
  import "./chunk-H5XL4KUS.js";
@@ -114,6 +117,7 @@ export {
114
117
  lookupSoccerTeam,
115
118
  markPrReady,
116
119
  mergePr,
120
+ normalizeWorkspaceTags,
117
121
  normalizeWorktreePath,
118
122
  originFetchBranch,
119
123
  originGhRepoEnv,
@@ -133,6 +137,7 @@ export {
133
137
  switchWorktreeBranch,
134
138
  threadDisplayLabel,
135
139
  ticketSlugForBranch,
140
+ workspaceTagsFromGroup,
136
141
  worktreeDisplayLabel,
137
142
  worktreeDisplayLabelForGroup,
138
143
  worktreeNameFromPath,
@@ -1,9 +1,6 @@
1
1
  import {
2
- FAMOUS_SOCCER_TEAMS,
3
2
  PR_DETAILS_JSON_FIELDS,
4
- allocateTeamName,
5
3
  allocateTeamSlug,
6
- branchDisplayLabel,
7
4
  canonicalizeRepoPath,
8
5
  collectTakenTeamSlugs,
9
6
  commitAll,
@@ -29,15 +26,12 @@ import {
29
26
  githubAgentGitEnv,
30
27
  isDefaultishSourceRef,
31
28
  isDirty,
32
- isPlaceholderBranch,
33
29
  isSideboardScratchPath,
34
30
  listBranches,
35
31
  listPrs,
36
32
  listWorktrees,
37
- lookupSoccerTeam,
38
33
  markPrReady,
39
34
  mergePr,
40
- normalizeWorktreePath,
41
35
  originFetchBranch,
42
36
  originGhRepoEnv,
43
37
  parseGithubSlugFromRemoteUrl,
@@ -53,15 +47,24 @@ import {
53
47
  resolveWorktreeStartPoint,
54
48
  slugify,
55
49
  suggestSlug,
56
- switchWorktreeBranch,
50
+ switchWorktreeBranch
51
+ } from "./chunk-K5XSTHHP.js";
52
+ import {
53
+ FAMOUS_SOCCER_TEAMS,
54
+ allocateTeamName,
55
+ branchDisplayLabel,
56
+ isPlaceholderBranch,
57
+ lookupSoccerTeam,
58
+ normalizeWorkspaceTags,
59
+ normalizeWorktreePath,
57
60
  threadDisplayLabel,
58
61
  ticketSlugForBranch,
62
+ workspaceTagsFromGroup,
59
63
  worktreeDisplayLabel,
60
64
  worktreeDisplayLabelForGroup,
61
65
  worktreeNameFromPath,
62
66
  worktreeSlugForTicket
63
- } from "./chunk-IPPY3FG5.js";
64
- import "./chunk-FWNL62VA.js";
67
+ } from "./chunk-N5UGX3JL.js";
65
68
  import "./chunk-2P4XKWV2.js";
66
69
  import "./chunk-6K64FJDD.js";
67
70
  import "./chunk-UWQ6UCIB.js";
@@ -112,6 +115,7 @@ export {
112
115
  lookupSoccerTeam,
113
116
  markPrReady,
114
117
  mergePr,
118
+ normalizeWorkspaceTags,
115
119
  normalizeWorktreePath,
116
120
  originFetchBranch,
117
121
  originGhRepoEnv,
@@ -131,6 +135,7 @@ export {
131
135
  switchWorktreeBranch,
132
136
  threadDisplayLabel,
133
137
  ticketSlugForBranch,
138
+ workspaceTagsFromGroup,
134
139
  worktreeDisplayLabel,
135
140
  worktreeDisplayLabelForGroup,
136
141
  worktreeNameFromPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sideboard-ai/core",
3
- "version": "0.1.279",
3
+ "version": "0.1.281",
4
4
  "description": "Sideboard core — orchestration, agents, git worktrees, MCP server",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -1,308 +0,0 @@
1
- import {
2
- cursorSdkStoreDir
3
- } from "./chunk-UWQ6UCIB.js";
4
- import {
5
- normalizeThinkingEffort
6
- } from "./chunk-77WWLBCI.js";
7
- import {
8
- threadFilePath,
9
- threadLockPath,
10
- threadsDir
11
- } from "./chunk-EHT2DRT4.js";
12
-
13
- // src/store/thread-store.ts
14
- import { randomUUID } from "crypto";
15
- import {
16
- existsSync,
17
- readFileSync,
18
- renameSync,
19
- rmSync,
20
- statSync,
21
- unlinkSync,
22
- writeFileSync,
23
- readdirSync
24
- } from "fs";
25
- import { basename } from "path";
26
- import lockfile from "proper-lockfile";
27
- function nowIso() {
28
- return (/* @__PURE__ */ new Date()).toISOString();
29
- }
30
- function resolveThreadEffort(raw) {
31
- const fromField = normalizeThinkingEffort(raw.effort);
32
- if (fromField) return fromField;
33
- if (raw.fast) return "low";
34
- return "high";
35
- }
36
- function normalizeRunScriptRequest(raw) {
37
- if (!raw || typeof raw !== "object") return void 0;
38
- const req = raw;
39
- if (req.op !== "start" && req.op !== "stop") return void 0;
40
- if (typeof req.requestId !== "string" || !req.requestId.trim()) return void 0;
41
- if (typeof req.requestedAt !== "string" || !req.requestedAt.trim()) return void 0;
42
- return {
43
- op: req.op,
44
- scriptName: req.scriptName ?? null,
45
- requestId: req.requestId,
46
- requestedAt: req.requestedAt,
47
- claimedAt: req.claimedAt ?? null,
48
- fulfilledAt: req.fulfilledAt ?? null,
49
- error: req.error ?? null
50
- };
51
- }
52
- function normalizeThread(raw) {
53
- return {
54
- ...raw,
55
- model: raw.model ?? null,
56
- effort: resolveThreadEffort(raw),
57
- fast: Boolean(raw.fast),
58
- planMode: Boolean(raw.planMode),
59
- isolateCodexPlugins: raw.isolateCodexPlugins === true ? true : void 0,
60
- autonomy: raw.autonomy ?? "default",
61
- lastError: raw.lastError ?? null,
62
- agentPid: raw.agentPid ?? null,
63
- attachments: Array.isArray(raw.attachments) ? raw.attachments : [],
64
- pendingTurnAttachments: Array.isArray(raw.pendingTurnAttachments) ? raw.pendingTurnAttachments : [],
65
- queueAttachments: Array.isArray(raw.queueAttachments) ? raw.queueAttachments : [],
66
- prTitle: raw.prTitle ?? null,
67
- prState: raw.prState ?? null,
68
- prIsDraft: Boolean(raw.prIsDraft),
69
- prReviewDecision: raw.prReviewDecision ?? null,
70
- prMergeable: raw.prMergeable ?? null,
71
- prMergeStateStatus: raw.prMergeStateStatus ?? null,
72
- prIsInMergeQueue: Boolean(raw.prIsInMergeQueue),
73
- prLabels: Array.isArray(raw.prLabels) ? raw.prLabels : [],
74
- prChecksFailed: typeof raw.prChecksFailed === "boolean" ? raw.prChecksFailed : void 0,
75
- skipAutoArchiveOnMerge: Boolean(raw.skipAutoArchiveOnMerge),
76
- cowboy: Boolean(raw.cowboy),
77
- stackId: raw.stackId ?? null,
78
- stackLayer: raw.stackLayer ?? null,
79
- userSetTitle: Boolean(raw.userSetTitle),
80
- activeRuns: Array.isArray(raw.activeRuns) ? raw.activeRuns : [],
81
- runScriptRequest: normalizeRunScriptRequest(raw.runScriptRequest),
82
- quotaResumeAt: raw.quotaResumeAt ?? null,
83
- quotaContinuedFromId: raw.quotaContinuedFromId ?? null,
84
- accountId: raw.accountId === null ? null : typeof raw.accountId === "string" && raw.accountId.trim() ? raw.accountId.trim() : void 0,
85
- archivedAt: typeof raw.archivedAt === "string" && raw.archivedAt.trim() ? raw.archivedAt.trim() : void 0,
86
- compactedMessages: Array.isArray(raw.compactedMessages) ? raw.compactedMessages : void 0
87
- };
88
- }
89
- function createEmptyThread(partial) {
90
- const ts = nowIso();
91
- return {
92
- id: randomUUID(),
93
- sessionId: partial.sessionId ?? null,
94
- autonomy: partial.autonomy ?? "default",
95
- model: partial.model ?? null,
96
- effort: partial.effort ?? "high",
97
- fast: partial.fast ?? false,
98
- planMode: partial.planMode ?? false,
99
- sourceIsFork: partial.sourceIsFork ?? false,
100
- status: partial.status ?? "idle",
101
- queue: partial.queue ?? [],
102
- parentThreadId: partial.parentThreadId ?? null,
103
- devPort: partial.devPort ?? null,
104
- activeRuns: partial.activeRuns ?? [],
105
- prUrl: partial.prUrl ?? null,
106
- prTitle: partial.prTitle ?? null,
107
- prState: partial.prState ?? null,
108
- prIsDraft: Boolean(partial.prIsDraft),
109
- prAuthorLogin: partial.prAuthorLogin?.trim() || null,
110
- prReviewerLogins: partial.prReviewerLogins ?? [],
111
- prReviewDecision: partial.prReviewDecision ?? null,
112
- prMergeable: partial.prMergeable ?? null,
113
- prMergeStateStatus: partial.prMergeStateStatus ?? null,
114
- prIsInMergeQueue: Boolean(partial.prIsInMergeQueue),
115
- prLabels: partial.prLabels ?? [],
116
- prChecksFailed: partial.prChecksFailed,
117
- skipAutoArchiveOnMerge: partial.skipAutoArchiveOnMerge ?? false,
118
- cowboy: Boolean(partial.cowboy),
119
- stackId: partial.stackId ?? null,
120
- stackLayer: partial.stackLayer ?? null,
121
- userSetTitle: partial.userSetTitle ?? false,
122
- messages: partial.messages ?? [],
123
- attachments: partial.attachments ?? [],
124
- pendingTurnAttachments: partial.pendingTurnAttachments ?? [],
125
- queueAttachments: partial.queueAttachments ?? [],
126
- createdAt: ts,
127
- updatedAt: ts,
128
- archivedAt: typeof partial.archivedAt === "string" && partial.archivedAt.trim() ? partial.archivedAt.trim() : void 0,
129
- title: partial.title,
130
- sourceType: partial.sourceType,
131
- sourceRef: partial.sourceRef,
132
- branchName: partial.branchName,
133
- worktreePath: partial.worktreePath,
134
- repoPath: partial.repoPath,
135
- agent: partial.agent,
136
- lastError: null,
137
- agentPid: null,
138
- ...partial.accountId !== void 0 ? { accountId: partial.accountId } : {}
139
- };
140
- }
141
- async function withThreadLock(id, fn) {
142
- const lockPath = threadLockPath(id);
143
- writeFileSync(lockPath, "", { flag: "a" });
144
- let release;
145
- try {
146
- release = await lockfile.lock(lockPath, {
147
- retries: { retries: 10, minTimeout: 50, maxTimeout: 200 },
148
- stale: 6e4
149
- });
150
- return await fn();
151
- } finally {
152
- if (release) await release();
153
- }
154
- }
155
- var listCache = null;
156
- function cacheForDir() {
157
- const dir = threadsDir();
158
- if (!listCache || listCache.dir !== dir) {
159
- listCache = { dir, byId: /* @__PURE__ */ new Map(), mtimeMs: /* @__PURE__ */ new Map() };
160
- }
161
- return listCache;
162
- }
163
- function fileMtimeMs(path) {
164
- try {
165
- return statSync(path).mtimeMs;
166
- } catch {
167
- return null;
168
- }
169
- }
170
- function rememberThread(thread, mtimeMs) {
171
- const cache = cacheForDir();
172
- cache.byId.set(thread.id, thread);
173
- if (mtimeMs != null) cache.mtimeMs.set(thread.id, mtimeMs);
174
- }
175
- function forgetThread(id) {
176
- const cache = cacheForDir();
177
- cache.byId.delete(id);
178
- cache.mtimeMs.delete(id);
179
- selfWriteMtimes.delete(id);
180
- }
181
- function invalidateThreadListCache() {
182
- listCache = null;
183
- }
184
- function invalidateThreadRecord(id) {
185
- if (!id) return;
186
- forgetThread(id);
187
- }
188
- function readThread(id) {
189
- const path = threadFilePath(id);
190
- const mtimeMs = fileMtimeMs(path);
191
- if (mtimeMs == null) {
192
- forgetThread(id);
193
- return null;
194
- }
195
- const cache = cacheForDir();
196
- const cached = cache.byId.get(id);
197
- if (cached && cache.mtimeMs.get(id) === mtimeMs) return cached;
198
- const raw = readFileSync(path, "utf8");
199
- const thread = normalizeThread(JSON.parse(raw));
200
- rememberThread(thread, mtimeMs);
201
- return thread;
202
- }
203
- var selfWriteMtimes = /* @__PURE__ */ new Map();
204
- function writeThread(thread, opts) {
205
- const path = threadFilePath(idPath(thread.id));
206
- const tmp = `${path}.${process.pid}.tmp`;
207
- const next = opts?.touch === false ? { ...thread } : { ...thread, updatedAt: nowIso() };
208
- writeFileSync(tmp, JSON.stringify(next, null, 2), "utf8");
209
- renameSync(tmp, path);
210
- const mtimeMs = fileMtimeMs(path) ?? Date.now();
211
- rememberThread(next, mtimeMs);
212
- selfWriteMtimes.set(thread.id, mtimeMs);
213
- }
214
- function isSelfWrittenRecord(id) {
215
- const ours = selfWriteMtimes.get(id);
216
- if (ours == null) return false;
217
- return fileMtimeMs(threadFilePath(id)) === ours;
218
- }
219
- function idPath(id) {
220
- return id;
221
- }
222
- function isThreadRecordFile(nameOrPath) {
223
- const name = basename(nameOrPath);
224
- return name.endsWith(".json") && !name.endsWith(".live.json") && !name.endsWith(".setup.log.json");
225
- }
226
- function listThreads(opts) {
227
- const cache = cacheForDir();
228
- const files = readdirSync(threadsDir()).filter(isThreadRecordFile);
229
- const seen = /* @__PURE__ */ new Set();
230
- for (const f of files) {
231
- const id = f.replace(/\.json$/, "");
232
- if (!id) continue;
233
- seen.add(id);
234
- try {
235
- readThread(id);
236
- } catch {
237
- }
238
- }
239
- for (const id of [...cache.byId.keys()]) {
240
- if (!seen.has(id)) forgetThread(id);
241
- }
242
- const threads = [...cache.byId.values()].sort(
243
- (a, b) => b.updatedAt.localeCompare(a.updatedAt)
244
- );
245
- if (opts?.includeArchived) return threads;
246
- return threads.filter((t) => t.status !== "archived");
247
- }
248
- function deleteThreadRecord(id) {
249
- forgetThread(id);
250
- const path = threadFilePath(id);
251
- if (existsSync(path)) unlinkSync(path);
252
- const lock = threadLockPath(id);
253
- if (existsSync(lock)) {
254
- try {
255
- unlinkSync(lock);
256
- } catch {
257
- }
258
- }
259
- try {
260
- rmSync(cursorSdkStoreDir(id), { recursive: true, force: true });
261
- } catch {
262
- }
263
- }
264
- function updateThread(id, patch) {
265
- const current = readThread(id);
266
- if (!current) throw new Error(`Thread not found: ${id}`);
267
- const next = { ...current, ...patch, id: current.id, updatedAt: nowIso() };
268
- if (next.status === "archived") {
269
- next.archivedAt = typeof next.archivedAt === "string" && next.archivedAt.trim() || current.archivedAt || nowIso();
270
- } else {
271
- delete next.archivedAt;
272
- }
273
- writeThread(next);
274
- return next;
275
- }
276
- function appendMessage(id, message) {
277
- const current = readThread(id);
278
- if (!current) throw new Error(`Thread not found: ${id}`);
279
- return updateThread(id, { messages: [...current.messages, message] });
280
- }
281
- function setStatus(id, status, lastError) {
282
- return updateThread(id, { status, lastError: lastError ?? null });
283
- }
284
- function findThreadByRef(ref) {
285
- const all = listThreads({ includeArchived: true });
286
- return all.find(
287
- (t) => t.id === ref || t.id.startsWith(ref) || t.branchName === ref || t.title === ref
288
- ) ?? null;
289
- }
290
-
291
- export {
292
- resolveThreadEffort,
293
- normalizeThread,
294
- createEmptyThread,
295
- withThreadLock,
296
- invalidateThreadListCache,
297
- invalidateThreadRecord,
298
- readThread,
299
- writeThread,
300
- isSelfWrittenRecord,
301
- isThreadRecordFile,
302
- listThreads,
303
- deleteThreadRecord,
304
- updateThread,
305
- appendMessage,
306
- setStatus,
307
- findThreadByRef
308
- };