@bigmistqke/whiteboard 0.6.0 → 0.6.1

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.
@@ -33,14 +33,20 @@ const RESERVED = /* @__PURE__ */ new Set([
33
33
  "_",
34
34
  "-"
35
35
  ]);
36
- /** The machine config, checked; null when there is none. Throws on one that is malformed. */
36
+ /**
37
+ * The machine config, checked; null when there is none. Throws on one that is malformed, and on one
38
+ * that is there but can't be read (a sandbox without a grant for it), rather than taking it for none.
39
+ */
37
40
  function readMachineConfig(dir = machineDir()) {
38
41
  const file = machineConfigFile(dir);
39
42
  let text;
40
43
  try {
41
44
  text = fs.readFileSync(file, "utf8");
42
- } catch {
43
- return null;
45
+ } catch (err) {
46
+ const code = err.code;
47
+ if (code === "ENOENT" || code === "ENOTDIR") return null;
48
+ if (code === "EPERM" || code === "EACCES") throw new Error(`cannot read ${file} (${code}): if this runs in a sandbox, it needs a read grant for ${dir}. Without it, whiteboard can't tell which server serves this project`);
49
+ throw err;
44
50
  }
45
51
  let raw;
46
52
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigmistqke/whiteboard",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "A whiteboard for you and your agent: it writes markdown pages you read live in the browser, you answer through forms it waits on",
5
5
  "keywords": [
6
6
  "agent",
@@ -34,8 +34,7 @@ PATH, the project has it installed locally: run them as `npx whiteboard …`.
34
34
  prints the URL. Give the user the URL the first time; after that, just
35
35
  keep editing the file — the open page follows. When the project is served
36
36
  by the user's shared server and that isn't running, `show` says so and
37
- starts nothing: tell the user, don't try to start it yourself (it is
38
- started outside your sandbox). A `wait` meanwhile still works: it waits
37
+ starts nothing: tell the user, don't try to start it yourself (it is started outside your sandbox). Should a command say it `cannot read` whiteboard's config, your sandbox lacks a grant for it: tell the user, rather than working around it. A `wait` meanwhile still works: it waits
39
38
  for the server, and answers in the log reach it either way.
40
39
  5. A page that was only for the moment (one question, a check, a demo):
41
40
  once it has done its job and you've acted on its answers, close it with
package/src/entries.ts CHANGED
@@ -72,14 +72,25 @@ const NAME = /^[a-z0-9][a-z0-9._-]*$/i
72
72
  // a served path's first part is an entry's name: these are the server's own
73
73
  const RESERVED = new Set(['api', '_', '-'])
74
74
 
75
- /** The machine config, checked; null when there is none. Throws on one that is malformed. */
75
+ /**
76
+ * The machine config, checked; null when there is none. Throws on one that is malformed, and on one
77
+ * that is there but can't be read (a sandbox without a grant for it), rather than taking it for none.
78
+ */
76
79
  export function readMachineConfig(dir = machineDir()): MachineConfig | null {
77
80
  const file = machineConfigFile(dir)
78
81
  let text: string
79
82
  try {
80
83
  text = fs.readFileSync(file, 'utf8')
81
- } catch {
82
- return null
84
+ } catch (err) {
85
+ const code = (err as NodeJS.ErrnoException).code
86
+ if (code === 'ENOENT' || code === 'ENOTDIR') return null
87
+ // there, but not to be read: most likely a sandbox without a grant for it. Taken for absent, a
88
+ // command would start a server of the project's own beside the shared one that serves it
89
+ if (code === 'EPERM' || code === 'EACCES')
90
+ throw new Error(
91
+ `cannot read ${file} (${code}): if this runs in a sandbox, it needs a read grant for ${dir}. Without it, whiteboard can't tell which server serves this project`,
92
+ )
93
+ throw err
83
94
  }
84
95
  let raw: any
85
96
  try {