@wirecat/attio-cli 0.8.0 → 0.10.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 (207) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/contracts/wirecat.json +1 -0
  3. package/dist/bin/attio.js +11 -11
  4. package/dist/bundle/attio.js +5 -166
  5. package/dist/bundle/{chunk-UXJZISVL.js → chunk-OGWKDPR5.js} +2 -1
  6. package/dist/bundle/chunk-TQAECZFO.js +13 -0
  7. package/dist/bundle/{definitions-FODOIPM2.js → definitions-J73IBAHT.js} +1 -1
  8. package/dist/bundle/program-NSBWZ25F.js +6201 -0
  9. package/dist/bundle/{schemas-YGSTNU6F.js → schemas-G3HFAS45.js} +576 -29
  10. package/dist/commands/api.js +1 -2
  11. package/dist/commands/crm.js +1 -4
  12. package/dist/commands/schedule.js +1 -1
  13. package/dist/commands/session.js +1 -2
  14. package/dist/config.js +1 -2
  15. package/dist/context.js +1 -1
  16. package/dist/identity.js +1 -0
  17. package/dist/program.js +1 -2
  18. package/dist/version.js +1 -1
  19. package/package.json +4 -4
  20. package/dist/activities.d.ts +0 -4
  21. package/dist/activities.d.ts.map +0 -1
  22. package/dist/activities.js.map +0 -1
  23. package/dist/bin/attio.d.ts +0 -3
  24. package/dist/bin/attio.d.ts.map +0 -1
  25. package/dist/bin/attio.js.map +0 -1
  26. package/dist/bundle/agent-GUXXSLT5.js +0 -38
  27. package/dist/bundle/all-profiles-63N3EQ46.js +0 -320
  28. package/dist/bundle/anthropic-B4W7MZQE.js +0 -91
  29. package/dist/bundle/app-server-EXNGTHWO.js +0 -250
  30. package/dist/bundle/bun-OPDGMZZQ.js +0 -169
  31. package/dist/bundle/bun-sqlite-NBAY7FR2.js +0 -76
  32. package/dist/bundle/chunk-2JHVQMVC.js +0 -16
  33. package/dist/bundle/chunk-2QDUP74I.js +0 -794
  34. package/dist/bundle/chunk-2XBDILVW.js +0 -53
  35. package/dist/bundle/chunk-3HC5F3P7.js +0 -24
  36. package/dist/bundle/chunk-3MSHGNVE.js +0 -1243
  37. package/dist/bundle/chunk-3YM4B2GT.js +0 -63
  38. package/dist/bundle/chunk-4N7PP76S.js +0 -6848
  39. package/dist/bundle/chunk-4RBMCXZT.js +0 -1337
  40. package/dist/bundle/chunk-4RSWOPKL.js +0 -323
  41. package/dist/bundle/chunk-5JKTVAXX.js +0 -2788
  42. package/dist/bundle/chunk-5N2V6XO7.js +0 -119
  43. package/dist/bundle/chunk-5WD22IXQ.js +0 -66
  44. package/dist/bundle/chunk-6K4Z6CAM.js +0 -43997
  45. package/dist/bundle/chunk-6TD3DCWC.js +0 -106
  46. package/dist/bundle/chunk-7Z53MLQP.js +0 -388
  47. package/dist/bundle/chunk-AATTOFNY.js +0 -2045
  48. package/dist/bundle/chunk-APARYILG.js +0 -743
  49. package/dist/bundle/chunk-D72URWJE.js +0 -532
  50. package/dist/bundle/chunk-DFDN6AUB.js +0 -21
  51. package/dist/bundle/chunk-DM7KWVDZ.js +0 -3752
  52. package/dist/bundle/chunk-DNCLQPOM.js +0 -7
  53. package/dist/bundle/chunk-DPD4FMHN.js +0 -388
  54. package/dist/bundle/chunk-DPV53EZC.js +0 -206
  55. package/dist/bundle/chunk-DURNR4RO.js +0 -353
  56. package/dist/bundle/chunk-EH6ZEJGT.js +0 -932
  57. package/dist/bundle/chunk-EVUMQKV7.js +0 -76
  58. package/dist/bundle/chunk-EY36BTKZ.js +0 -108
  59. package/dist/bundle/chunk-FH6OEGGN.js +0 -557
  60. package/dist/bundle/chunk-FOP6G45D.js +0 -358
  61. package/dist/bundle/chunk-GGMAIIVE.js +0 -38
  62. package/dist/bundle/chunk-GTEX4IUO.js +0 -334
  63. package/dist/bundle/chunk-HZ3C4WXD.js +0 -142
  64. package/dist/bundle/chunk-IA7LLLEI.js +0 -100
  65. package/dist/bundle/chunk-J6GVVISK.js +0 -185
  66. package/dist/bundle/chunk-JG6LCSEX.js +0 -407
  67. package/dist/bundle/chunk-JIGEJZ4I.js +0 -68943
  68. package/dist/bundle/chunk-KVTNYRDO.js +0 -1007
  69. package/dist/bundle/chunk-L45WN3AR.js +0 -80
  70. package/dist/bundle/chunk-L72WUJAS.js +0 -54
  71. package/dist/bundle/chunk-LKH3UKLO.js +0 -230
  72. package/dist/bundle/chunk-LM3W7YOM.js +0 -274
  73. package/dist/bundle/chunk-M4AC55ZB.js +0 -12733
  74. package/dist/bundle/chunk-MCLQTCGH.js +0 -1202
  75. package/dist/bundle/chunk-NB7EOAUZ.js +0 -123
  76. package/dist/bundle/chunk-NISH4UXM.js +0 -58
  77. package/dist/bundle/chunk-OYEVYOCL.js +0 -259
  78. package/dist/bundle/chunk-P7G5HFY3.js +0 -288
  79. package/dist/bundle/chunk-PAEKXVJW.js +0 -188
  80. package/dist/bundle/chunk-PL5P7UKW.js +0 -25216
  81. package/dist/bundle/chunk-PLPBEWD4.js +0 -170
  82. package/dist/bundle/chunk-PMQ7GP6X.js +0 -95
  83. package/dist/bundle/chunk-Q7ICVP25.js +0 -18
  84. package/dist/bundle/chunk-QPPOIWPY.js +0 -1246
  85. package/dist/bundle/chunk-QSJKSPWF.js +0 -131
  86. package/dist/bundle/chunk-RDVTHFPP.js +0 -338
  87. package/dist/bundle/chunk-RQORQN2V.js +0 -4072
  88. package/dist/bundle/chunk-RRTMPSQR.js +0 -29
  89. package/dist/bundle/chunk-S4UUN6LD.js +0 -1410
  90. package/dist/bundle/chunk-S6JG4YUH.js +0 -72
  91. package/dist/bundle/chunk-SCI7QEHF.js +0 -362
  92. package/dist/bundle/chunk-SSA6JBPA.js +0 -778
  93. package/dist/bundle/chunk-T4J7XFXT.js +0 -9667
  94. package/dist/bundle/chunk-TTF5DP4V.js +0 -1197
  95. package/dist/bundle/chunk-TXDR6YSF.js +0 -23
  96. package/dist/bundle/chunk-TY7NDMFY.js +0 -46
  97. package/dist/bundle/chunk-UDSL3MUU.js +0 -2333
  98. package/dist/bundle/chunk-UKHF37ZU.js +0 -1068
  99. package/dist/bundle/chunk-V57E7PJQ.js +0 -161
  100. package/dist/bundle/chunk-V7IF2K3P.js +0 -52
  101. package/dist/bundle/chunk-VB7FZOYX.js +0 -633
  102. package/dist/bundle/chunk-VZ5PPYDG.js +0 -77
  103. package/dist/bundle/chunk-WOPVBRPV.js +0 -29
  104. package/dist/bundle/chunk-WXQGA6XK.js +0 -50
  105. package/dist/bundle/chunk-XQGN2D44.js +0 -86
  106. package/dist/bundle/chunk-XQUUANA2.js +0 -24600
  107. package/dist/bundle/chunk-Y5E2WNWB.js +0 -35
  108. package/dist/bundle/chunk-YNGU36GW.js +0 -218
  109. package/dist/bundle/chunk-YWDFYQOU.js +0 -82
  110. package/dist/bundle/chunk-ZVVMGPBJ.js +0 -50
  111. package/dist/bundle/chunk-ZZD2YPOX.js +0 -156
  112. package/dist/bundle/command-contract-KCCW4LNI.js +0 -37
  113. package/dist/bundle/command-server-entry-3NPPABQQ.js +0 -166
  114. package/dist/bundle/decode-26M7XE2B.js +0 -297
  115. package/dist/bundle/dispatch-2FTOHA5D.js +0 -411
  116. package/dist/bundle/dist-EM7KLEG4.js +0 -7577
  117. package/dist/bundle/dist-PAKDDIBT.js +0 -191
  118. package/dist/bundle/echarts-O3TNDAXJ.js +0 -42501
  119. package/dist/bundle/embed-XJLEAWXE.js +0 -38
  120. package/dist/bundle/embedder-OEL6PXEH.js +0 -111
  121. package/dist/bundle/failure-OHIXWTR6.js +0 -25
  122. package/dist/bundle/first-run-CIXGBXY6.js +0 -29
  123. package/dist/bundle/first-screen-5FK4D45F.js +0 -38
  124. package/dist/bundle/instructions-AMH5RWVJ.js +0 -11
  125. package/dist/bundle/mcp-5HFPWC3W.js +0 -167
  126. package/dist/bundle/meeting-combined-DMVGQNJ7.js +0 -24
  127. package/dist/bundle/meeting-model-2THAT7OH.js +0 -25
  128. package/dist/bundle/meeting-semantic-Q6XYFYUD.js +0 -22
  129. package/dist/bundle/node-EGMCBAO7.js +0 -176
  130. package/dist/bundle/node-KM3CUABH.js +0 -2340
  131. package/dist/bundle/node-TLZSIHIJ.js +0 -21
  132. package/dist/bundle/node-sqlite-2SWWGW6H.js +0 -74
  133. package/dist/bundle/oauth-V5LGTXF2.js +0 -20
  134. package/dist/bundle/open-25EKOTZA.js +0 -23
  135. package/dist/bundle/openai-VX3OLIHM.js +0 -238
  136. package/dist/bundle/process-SGHEN6MQ.js +0 -91
  137. package/dist/bundle/program-Z5NUNXME.js +0 -34214
  138. package/dist/bundle/prompt-2VSPX5S7.js +0 -17
  139. package/dist/bundle/recognize-NA5XUFKK.js +0 -26
  140. package/dist/bundle/remote-BOME6XOE.js +0 -31
  141. package/dist/bundle/rerank-NG3XMFCV.js +0 -52
  142. package/dist/bundle/serve-MR67OBED.js +0 -199
  143. package/dist/bundle/server-4BWAGJQO.js +0 -80
  144. package/dist/bundle/server-OP2HJNXD.js +0 -213
  145. package/dist/bundle/sqlite-runtime-V5U6F5EB.js +0 -20
  146. package/dist/bundle/state-L4MWAATO.js +0 -36
  147. package/dist/bundle/store-2ALTEH55.js +0 -181
  148. package/dist/bundle/store-CXZFRG5D.js +0 -297
  149. package/dist/bundle/store-maintenance-command-LC55DRQA.js +0 -67
  150. package/dist/bundle/surface-3GRJ7473.js +0 -66
  151. package/dist/commands/api.d.ts +0 -12
  152. package/dist/commands/api.d.ts.map +0 -1
  153. package/dist/commands/api.js.map +0 -1
  154. package/dist/commands/crm.d.ts +0 -7
  155. package/dist/commands/crm.d.ts.map +0 -1
  156. package/dist/commands/crm.js.map +0 -1
  157. package/dist/commands/schedule.d.ts +0 -3
  158. package/dist/commands/schedule.d.ts.map +0 -1
  159. package/dist/commands/schedule.js.map +0 -1
  160. package/dist/commands/session.d.ts +0 -8
  161. package/dist/commands/session.d.ts.map +0 -1
  162. package/dist/commands/session.js.map +0 -1
  163. package/dist/config.d.ts +0 -13
  164. package/dist/config.d.ts.map +0 -1
  165. package/dist/config.js.map +0 -1
  166. package/dist/context.d.ts +0 -37
  167. package/dist/context.d.ts.map +0 -1
  168. package/dist/context.js.map +0 -1
  169. package/dist/generated/definitions.d.ts +0 -3
  170. package/dist/generated/definitions.d.ts.map +0 -1
  171. package/dist/generated/definitions.js.map +0 -1
  172. package/dist/generated/manifest.d.ts +0 -6
  173. package/dist/generated/manifest.d.ts.map +0 -1
  174. package/dist/generated/manifest.js.map +0 -1
  175. package/dist/generated/schemas.d.ts +0 -383
  176. package/dist/generated/schemas.d.ts.map +0 -1
  177. package/dist/generated/schemas.js.map +0 -1
  178. package/dist/generated/types.d.ts +0 -10166
  179. package/dist/generated/types.d.ts.map +0 -1
  180. package/dist/generated/types.js.map +0 -1
  181. package/dist/generated/wirecat-config.d.ts +0 -15
  182. package/dist/generated/wirecat-config.d.ts.map +0 -1
  183. package/dist/generated/wirecat-config.js.map +0 -1
  184. package/dist/hooks.d.ts +0 -33
  185. package/dist/hooks.d.ts.map +0 -1
  186. package/dist/hooks.js.map +0 -1
  187. package/dist/identity.d.ts +0 -33
  188. package/dist/identity.d.ts.map +0 -1
  189. package/dist/identity.js.map +0 -1
  190. package/dist/index.d.ts +0 -3
  191. package/dist/index.d.ts.map +0 -1
  192. package/dist/index.js.map +0 -1
  193. package/dist/links.d.ts +0 -10
  194. package/dist/links.d.ts.map +0 -1
  195. package/dist/links.js.map +0 -1
  196. package/dist/meetings.d.ts +0 -57
  197. package/dist/meetings.d.ts.map +0 -1
  198. package/dist/meetings.js.map +0 -1
  199. package/dist/program.d.ts +0 -6
  200. package/dist/program.d.ts.map +0 -1
  201. package/dist/program.js.map +0 -1
  202. package/dist/version.d.ts +0 -2
  203. package/dist/version.d.ts.map +0 -1
  204. package/dist/version.js.map +0 -1
  205. package/dist/wcat.d.ts +0 -3
  206. package/dist/wcat.d.ts.map +0 -1
  207. package/dist/wcat.js.map +0 -1
@@ -1,77 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- __name
5
- } from "./chunk-ZVVMGPBJ.js";
6
-
7
- // node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/node_modules/@wirecat/cli-core/dist/http/listen.js
8
- import { createServer } from "node:http";
9
- import { pipeline, Readable } from "node:stream";
10
- var MAX_BODY = 4 * 1024 * 1024;
11
- var TooLarge = class extends Error {
12
- static {
13
- __name(this, "TooLarge");
14
- }
15
- };
16
- var readBody = /* @__PURE__ */ __name((incoming, limit) => new Promise((resolve, reject) => {
17
- if (Number(incoming.headers["content-length"] ?? 0) > limit)
18
- return reject(new TooLarge());
19
- const chunks = [];
20
- let size = 0;
21
- incoming.on("data", (chunk) => {
22
- size += chunk.length;
23
- if (size > limit) {
24
- incoming.destroy();
25
- reject(new TooLarge());
26
- } else
27
- chunks.push(chunk);
28
- });
29
- incoming.once("end", () => resolve(Buffer.concat(chunks)));
30
- incoming.once("error", reject);
31
- }), "readBody");
32
- var toRequest = /* @__PURE__ */ __name(async (incoming, origin, maxBody) => {
33
- const headers = new Headers();
34
- for (const [name, value] of Object.entries(incoming.headers)) {
35
- if (Array.isArray(value))
36
- for (const one of value)
37
- headers.append(name, one);
38
- else if (value !== void 0)
39
- headers.set(name, value);
40
- }
41
- const method = incoming.method ?? "GET";
42
- const body = method === "GET" || method === "HEAD" ? void 0 : await readBody(incoming, maxBody);
43
- if (body)
44
- headers.set("content-length", String(body.length));
45
- return new Request(new URL(incoming.url ?? "/", origin), { method, headers, ...body ? { body } : {} });
46
- }, "toRequest");
47
- var send = /* @__PURE__ */ __name(async (response, outgoing) => {
48
- outgoing.writeHead(response.status, Object.fromEntries(response.headers));
49
- if (!response.body)
50
- return void outgoing.end();
51
- const body = Readable.fromWeb(response.body);
52
- pipeline(body, outgoing, () => void 0);
53
- }, "send");
54
- var listen = /* @__PURE__ */ __name((handle, { host, port, maxBody = MAX_BODY }) => new Promise((resolve, reject) => {
55
- const server = createServer((incoming, outgoing) => {
56
- toRequest(incoming, `http://${host}`, maxBody).then(handle).then((response) => send(response, outgoing)).catch((error) => {
57
- if (!outgoing.headersSent)
58
- outgoing.writeHead(error instanceof TooLarge ? 413 : 500, { connection: "close" });
59
- outgoing.end();
60
- });
61
- });
62
- server.once("error", reject);
63
- server.listen(port, host, () => {
64
- const { port: bound } = server.address();
65
- resolve({
66
- url: new URL(`http://${host}:${bound}`),
67
- close: /* @__PURE__ */ __name(() => new Promise((done) => {
68
- server.close(() => done());
69
- server.closeAllConnections();
70
- }), "close")
71
- });
72
- });
73
- }), "listen");
74
-
75
- export {
76
- listen
77
- };
@@ -1,29 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- __name
5
- } from "./chunk-ZVVMGPBJ.js";
6
-
7
- // node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/node_modules/@wirecat/cli-core/dist/cli/commander-internals.js
8
- var internals = /* @__PURE__ */ __name((command) => command, "internals");
9
- var hasOwnAction = /* @__PURE__ */ __name((command) => internals(command)._actionHandler != null, "hasOwnAction");
10
- var isHidden = /* @__PURE__ */ __name((command) => internals(command)._hidden === true, "isHidden");
11
- var hide = /* @__PURE__ */ __name((command) => {
12
- internals(command)._hidden = true;
13
- }, "hide");
14
- var helpOptionOf = /* @__PURE__ */ __name((command) => internals(command)._getHelpOption(), "helpOptionOf");
15
- var rejectUnknownOption = /* @__PURE__ */ __name((command, flag) => internals(command).unknownOption(flag), "rejectUnknownOption");
16
- var onUnknownOption = /* @__PURE__ */ __name((command, handle) => {
17
- const own = internals(command);
18
- const fallback = own.unknownOption.bind(command);
19
- own.unknownOption = (flag) => handle(flag, fallback);
20
- }, "onUnknownOption");
21
-
22
- export {
23
- hasOwnAction,
24
- isHidden,
25
- hide,
26
- helpOptionOf,
27
- rejectUnknownOption,
28
- onUnknownOption
29
- };
@@ -1,50 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- AUTHORITY_KEY,
5
- BOT_API_KEY,
6
- authorityAllowed,
7
- botApiAllowed,
8
- changesMessenger,
9
- isBotApi,
10
- keyForCommand,
11
- levelFor,
12
- readKeysForCommand
13
- } from "./chunk-M4AC55ZB.js";
14
- import {
15
- writes
16
- } from "./chunk-QPPOIWPY.js";
17
- import {
18
- __name
19
- } from "./chunk-ZVVMGPBJ.js";
20
-
21
- // node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/node_modules/@wirecat/cli-core/dist/cli/command-availability.js
22
- var commandAvailability = /* @__PURE__ */ __name((info, levels, keyOf, authority, readOnly = false, mcp = true, declared, fetches) => {
23
- const declaredKey = declared?.keyOf(info.path);
24
- const key = declared ? declaredKey : keyOf?.(info.path) ?? keyForCommand(info.path);
25
- const { level } = key ? levelFor(levels, key, declared?.defaults) : { level: "allow" };
26
- const judged = { ...key ? { permission: key } : {}, level };
27
- const blocked = /* @__PURE__ */ __name((reason, permission) => ({
28
- available: false,
29
- reason,
30
- ...judged,
31
- ...permission && permission !== judged.permission ? { permission, level: levelFor(levels, permission).level } : {}
32
- }), "blocked");
33
- const declaredChange = Boolean(declaredKey) && (info.effects === void 0 || info.effects.remote === "write");
34
- if (readOnly && (changesMessenger(info) || declaredChange || authority?.(info.path)))
35
- return blocked("the read-only lock blocks this change");
36
- if (mcp && authority?.(info.path) && !authorityAllowed(levels))
37
- return blocked(`the profile keeps ${AUTHORITY_KEY} off`, AUTHORITY_KEY);
38
- if (mcp && isBotApi(info.path) && !botApiAllowed(levels))
39
- return blocked(`the profile requires ${BOT_API_KEY}: allow`, BOT_API_KEY);
40
- if (level === "deny")
41
- return blocked(`the profile denies ${key}`);
42
- if (level === "readonly" && writes(info.effects) && fetches?.(info.path) !== true)
43
- return blocked(`${key} is readonly in this profile`);
44
- const denied = (declared ? [] : readKeysForCommand(info.path)).find((read) => levelFor(levels, read).level === "deny");
45
- return denied ? blocked(`the profile denies ${denied}`, denied) : { available: true, ...judged };
46
- }, "commandAvailability");
47
-
48
- export {
49
- commandAvailability
50
- };
@@ -1,86 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- alive
5
- } from "./chunk-3YM4B2GT.js";
6
- import {
7
- resolvePaths,
8
- writeSecurely
9
- } from "./chunk-5JKTVAXX.js";
10
- import {
11
- __name
12
- } from "./chunk-ZVVMGPBJ.js";
13
-
14
- // node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/node_modules/@wirecat/cli-core/dist/background/lock.js
15
- import { existsSync, linkSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
16
- import { dirname, join } from "node:path";
17
- var lockPath = /* @__PURE__ */ __name((app, profile, env) => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "serve", `${profile}.lock`), "lockPath");
18
- var readLock = /* @__PURE__ */ __name((path) => {
19
- try {
20
- const lock = JSON.parse(readFileSync(path, "utf8"));
21
- return typeof lock.pid === "number" && typeof lock.startedAt === "string" ? lock : void 0;
22
- } catch {
23
- return void 0;
24
- }
25
- }, "readLock");
26
- var holdLock = /* @__PURE__ */ __name((path, lock) => writeSecurely(path, `${JSON.stringify(lock)}
27
- `, 384), "holdLock");
28
- var takeLock = /* @__PURE__ */ __name((path, lock) => {
29
- mkdirSync(dirname(path), { recursive: true, mode: 448 });
30
- const draft = `${path}.${lock.pid}.tmp`;
31
- writeFileSync(draft, `${JSON.stringify(lock)}
32
- `, { mode: 384 });
33
- try {
34
- for (let attempt = 0; attempt < 5; attempt++) {
35
- try {
36
- linkSync(draft, path);
37
- return void 0;
38
- } catch (error) {
39
- if (error.code !== "EEXIST")
40
- throw error;
41
- }
42
- const held = readLock(path);
43
- if (held && held.pid !== lock.pid && alive(held.pid))
44
- return held;
45
- rmSync(path, { force: true });
46
- }
47
- throw new Error(`could not take the lock ${path}: it keeps changing`);
48
- } finally {
49
- rmSync(draft, { force: true });
50
- }
51
- }, "takeLock");
52
- var releaseLock = /* @__PURE__ */ __name((path, pid = process.pid) => {
53
- if (readLock(path)?.pid === pid)
54
- rmSync(path, { force: true });
55
- }, "releaseLock");
56
- var currentPath = /* @__PURE__ */ __name((lock) => lock.replace(/\.lock$/, ".current"), "currentPath");
57
- var markCurrent = /* @__PURE__ */ __name((lock, at = /* @__PURE__ */ new Date()) => writeSecurely(currentPath(lock), `${JSON.stringify({ at: at.toISOString() })}
58
- `, 384), "markCurrent");
59
- var readCurrent = /* @__PURE__ */ __name((lock) => {
60
- try {
61
- const { at } = JSON.parse(readFileSync(currentPath(lock), "utf8"));
62
- return typeof at === "string" ? at : void 0;
63
- } catch {
64
- return void 0;
65
- }
66
- }, "readCurrent");
67
- var servingProfiles = /* @__PURE__ */ __name((app, env) => {
68
- const dir = dirname(lockPath(app, "default", env));
69
- if (!existsSync(dir))
70
- return [];
71
- return readdirSync(dir).filter((name) => name.endsWith(".lock")).map((name) => name.slice(0, -".lock".length)).filter((profile) => {
72
- const lock = readLock(lockPath(app, profile, env));
73
- return lock !== void 0 && alive(lock.pid);
74
- });
75
- }, "servingProfiles");
76
-
77
- export {
78
- lockPath,
79
- readLock,
80
- holdLock,
81
- takeLock,
82
- releaseLock,
83
- markCurrent,
84
- readCurrent,
85
- servingProfiles
86
- };