@craftspace/cli 0.2.1 → 0.2.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.
package/dist/index.js CHANGED
@@ -18187,6 +18187,22 @@ var TREE_KINDS = [
18187
18187
  PageKind.Artifact,
18188
18188
  PageKind.Table
18189
18189
  ];
18190
+ var PageLayer;
18191
+ (function(PageLayer2) {
18192
+ PageLayer2["Record"] = "record";
18193
+ PageLayer2["Knowledge"] = "knowledge";
18194
+ PageLayer2["Skill"] = "skill";
18195
+ })(PageLayer || (PageLayer = {}));
18196
+ var KIND_LAYER = {
18197
+ [PageKind.Page]: PageLayer.Knowledge,
18198
+ [PageKind.Decision]: PageLayer.Knowledge,
18199
+ [PageKind.Skill]: PageLayer.Skill,
18200
+ [PageKind.Meeting]: PageLayer.Record,
18201
+ [PageKind.Thread]: PageLayer.Record,
18202
+ [PageKind.Customer]: PageLayer.Record,
18203
+ [PageKind.Artifact]: PageLayer.Record,
18204
+ [PageKind.Table]: PageLayer.Record
18205
+ };
18190
18206
  var AUTHORABLE_KINDS = [PageKind.Page, PageKind.Decision, PageKind.Customer, PageKind.Skill];
18191
18207
  var PAGE_COLORS = [
18192
18208
  "slate",
@@ -18937,6 +18953,10 @@ var AUDIT_GROUPS = [
18937
18953
  AuditAction.WorkflowSecretRotated
18938
18954
  ]
18939
18955
  },
18956
+ {
18957
+ label: "MCP calls",
18958
+ actions: [AuditAction.McpToolCall, AuditAction.McpRequest]
18959
+ },
18940
18960
  {
18941
18961
  label: "Organization",
18942
18962
  actions: [
@@ -18948,6 +18968,7 @@ var AUDIT_GROUPS = [
18948
18968
  }
18949
18969
  ];
18950
18970
  var AUDIT_LISTED_ACTIONS = AUDIT_GROUPS.flatMap((group) => group.actions);
18971
+ var AUDIT_DEFAULT_ACTIONS = AUDIT_LISTED_ACTIONS.filter((action) => AUDIT_TIERS[action] !== AuditTier.Volume);
18951
18972
  var AUDIT_VERBS = {
18952
18973
  [AuditAction.AccessDenied]: "Was refused",
18953
18974
  [AuditAction.MemberSignedIn]: "Signed in",
@@ -19016,6 +19037,7 @@ var AuditEntrySchema = external_exports.object({
19016
19037
  target: AuditTargetSchema.optional(),
19017
19038
  data: external_exports.record(external_exports.string(), external_exports.unknown()),
19018
19039
  ip: external_exports.string().optional(),
19040
+ userAgent: external_exports.string().optional(),
19019
19041
  createdAt: external_exports.string()
19020
19042
  });
19021
19043
  var AuditSummarySchema = external_exports.object({
@@ -19760,7 +19782,7 @@ var SaveWorkstationBodySchema = external_exports.object({
19760
19782
  var WorkstationResponseSchema = external_exports.object({ workstation: WorkstationSchema });
19761
19783
 
19762
19784
  // ../../shared/dist/machines/machine.js
19763
- var CLI_VERSION = "0.2.0";
19785
+ var CLI_VERSION = "0.2.2";
19764
19786
  var MACHINE_BEAT_INTERVAL_MS = 15e3;
19765
19787
  var MACHINE_BEAT_BUSY_INTERVAL_MS = 3e3;
19766
19788
  var MACHINE_RUN_OUTPUT_MAX = 32e3;
@@ -19880,6 +19902,7 @@ var AddMachineKeyBodySchema = external_exports.object({
19880
19902
  key: external_exports.string().min(60).max(4e3),
19881
19903
  label: external_exports.string().max(80).optional()
19882
19904
  });
19905
+ var RenameMachineBodySchema = external_exports.object({ name: external_exports.string().min(1).max(64) });
19883
19906
  var StartRunBodySchema = external_exports.object({ argv: external_exports.array(external_exports.string().max(4e3)).min(1).max(64) });
19884
19907
  var AnswerRunBodySchema = external_exports.object({ text: external_exports.string().min(1).max(4e3) });
19885
19908
  var MachineRunsResponseSchema = external_exports.object({ runs: external_exports.array(MachineRunSchema) });
@@ -22470,8 +22493,7 @@ var machine = {
22470
22493
  await installService();
22471
22494
  probed = {
22472
22495
  at: Date.now(),
22473
- tools: await setup.run({ install, rewire, say: (line) => process.stdout.write(`${line}
22474
- `) })
22496
+ tools: await setup.run({ install, rewire, say: (text) => process.stdout.write(text) })
22475
22497
  };
22476
22498
  return answer.machine;
22477
22499
  },
@@ -22553,6 +22575,17 @@ Signed in as ${signed.ownerName}. This machine is ${signed.name}.
22553
22575
  return runHere(argv);
22554
22576
  return runThere({ argv, on });
22555
22577
  },
22578
+ async daemonLine() {
22579
+ if (process.env.CRAFTSPACE_NO_SERVICE === "1")
22580
+ return `not installed. Start it with: ${here()} daemon`;
22581
+ if (process.platform !== "linux")
22582
+ return BEATING;
22583
+ if (!await serviceRunning())
22584
+ return `not running. Start it with: ${here()} daemon`;
22585
+ if (!await userLingers())
22586
+ return `beating, but it stops when you log out. Run: ${LINGER_LINE}`;
22587
+ return BEATING;
22588
+ },
22556
22589
  async logout() {
22557
22590
  const config2 = await readConfig();
22558
22591
  const token = await readToken();
@@ -22842,13 +22875,13 @@ async function acceptClaudeGates(servers) {
22842
22875
  const parsed = JSON.parse(raw);
22843
22876
  const projects = isPlainObject3(parsed.projects) ? parsed.projects : {};
22844
22877
  const found = projects[os4.homedir()];
22845
- const here = isPlainObject3(found) ? { ...found } : {};
22846
- const enabled = /* @__PURE__ */ new Set([...Array.isArray(here.enabledMcpjsonServers) ? here.enabledMcpjsonServers : [], ...servers]);
22847
- if (here.hasTrustDialogAccepted === true && enabled.size === asArray(here.enabledMcpjsonServers).length)
22878
+ const here2 = isPlainObject3(found) ? { ...found } : {};
22879
+ const enabled = /* @__PURE__ */ new Set([...Array.isArray(here2.enabledMcpjsonServers) ? here2.enabledMcpjsonServers : [], ...servers]);
22880
+ if (here2.hasTrustDialogAccepted === true && enabled.size === asArray(here2.enabledMcpjsonServers).length)
22848
22881
  return;
22849
- here.hasTrustDialogAccepted = true;
22850
- here.enabledMcpjsonServers = [...enabled];
22851
- const next = { ...parsed, projects: { ...projects, [os4.homedir()]: here } };
22882
+ here2.hasTrustDialogAccepted = true;
22883
+ here2.enabledMcpjsonServers = [...enabled];
22884
+ const next = { ...parsed, projects: { ...projects, [os4.homedir()]: here2 } };
22852
22885
  await writeFile(target, `${JSON.stringify(next, null, 2)}
22853
22886
  `, { mode: 384 });
22854
22887
  }
@@ -22896,14 +22929,13 @@ async function weCreated(target) {
22896
22929
  return backup === null;
22897
22930
  }
22898
22931
  async function installService() {
22899
- if (process.env.CRAFTSPACE_NO_SERVICE === "1") {
22900
- process.stdout.write("Skipping the service. Run the beat yourself with: craftspace daemon\n");
22932
+ if (process.env.CRAFTSPACE_NO_SERVICE === "1")
22901
22933
  return;
22902
- }
22903
22934
  if (process.platform === "linux") {
22904
22935
  const dir = path4.join(os4.homedir(), ".config", "systemd", "user");
22905
22936
  await mkdir(dir, { recursive: true });
22906
22937
  await writeFile(path4.join(dir, `${SERVICE_NAME}.service`), systemdUnit());
22938
+ await run3("loginctl", ["enable-linger", os4.userInfo().username]).catch(() => void 0);
22907
22939
  await run3("systemctl", ["--user", "daemon-reload"]).catch(() => void 0);
22908
22940
  await run3("systemctl", ["--user", "enable", "--now", SERVICE_NAME]).catch(() => void 0);
22909
22941
  return;
@@ -22957,6 +22989,16 @@ function launchdPlist() {
22957
22989
  </plist>
22958
22990
  `;
22959
22991
  }
22992
+ function here() {
22993
+ return `${process.execPath} ${entryPath()}`;
22994
+ }
22995
+ async function serviceRunning() {
22996
+ return await run3("systemctl", ["--user", "is-active", SERVICE_NAME]).catch(() => null) !== null;
22997
+ }
22998
+ async function userLingers() {
22999
+ const shown = await run3("loginctl", ["show-user", os4.userInfo().username, "-p", "Linger"]).catch(() => null);
23000
+ return shown?.stdout.includes("Linger=yes") === true;
23001
+ }
22960
23002
  function entryPath() {
22961
23003
  return path4.join(path4.dirname(new URL(import.meta.url).pathname), "index.js");
22962
23004
  }
@@ -22999,6 +23041,8 @@ var MAX_BACKOFF_MS = 12e4;
22999
23041
  var KEYS_BEGIN = "# craftspace begin";
23000
23042
  var KEYS_END = "# craftspace end";
23001
23043
  var POLL_INTERVAL_MS = 1e3;
23044
+ var BEATING = "beating every 15s, outbound only, and keeps this set up";
23045
+ var LINGER_LINE = `sudo loginctl enable-linger ${os4.userInfo().username}`;
23002
23046
  var DEFAULT_URL = process.env.CRAFTSPACE_URL ?? "https://craftspace.app";
23003
23047
  var PROBE_EVERY_MS = 3e5;
23004
23048
  var probed = null;
@@ -23016,7 +23060,7 @@ program2.command("login").description("sign this machine in").option("--token <t
23016
23060
  `Signed in as ${signed.ownerName}`,
23017
23061
  `Machine ${signed.name} \xB7 ${signed.platform} \xB7 ${signed.cores ?? "?"} vCPU`,
23018
23062
  "MCP wired ~/.mcp.json",
23019
- "Daemon beating every 15s, outbound only, and keeps this set up",
23063
+ `Daemon ${await machine.daemonLine()}`,
23020
23064
  "",
23021
23065
  `Listed at ${url2.replace(/\/$/, "")}/workstations`,
23022
23066
  ""
package/dist/machine.d.ts CHANGED
@@ -21,6 +21,7 @@ export declare const machine: {
21
21
  argv: string[];
22
22
  on?: string;
23
23
  }): Promise<number>;
24
+ daemonLine(): Promise<string>;
24
25
  logout(): Promise<void>;
25
26
  };
26
27
  export declare function tokenIn(line: string): string | undefined;
package/dist/machine.js CHANGED
@@ -37,7 +37,7 @@ export const machine = {
37
37
  await installService();
38
38
  probed = {
39
39
  at: Date.now(),
40
- tools: await setup.run({ install, rewire, say: (line) => process.stdout.write(`${line}\n`) }),
40
+ tools: await setup.run({ install, rewire, say: (text) => process.stdout.write(text) }),
41
41
  };
42
42
  return answer.machine;
43
43
  },
@@ -118,6 +118,17 @@ export const machine = {
118
118
  return runHere(argv);
119
119
  return runThere({ argv, on });
120
120
  },
121
+ async daemonLine() {
122
+ if (process.env.CRAFTSPACE_NO_SERVICE === '1')
123
+ return `not installed. Start it with: ${here()} daemon`;
124
+ if (process.platform !== 'linux')
125
+ return BEATING;
126
+ if (!(await serviceRunning()))
127
+ return `not running. Start it with: ${here()} daemon`;
128
+ if (!(await userLingers()))
129
+ return `beating, but it stops when you log out. Run: ${LINGER_LINE}`;
130
+ return BEATING;
131
+ },
121
132
  async logout() {
122
133
  const config = await readConfig();
123
134
  const token = await readToken();
@@ -451,14 +462,13 @@ async function weCreated(target) {
451
462
  return backup === null;
452
463
  }
453
464
  async function installService() {
454
- if (process.env.CRAFTSPACE_NO_SERVICE === '1') {
455
- process.stdout.write('Skipping the service. Run the beat yourself with: craftspace daemon\n');
465
+ if (process.env.CRAFTSPACE_NO_SERVICE === '1')
456
466
  return;
457
- }
458
467
  if (process.platform === 'linux') {
459
468
  const dir = path.join(os.homedir(), '.config', 'systemd', 'user');
460
469
  await mkdir(dir, { recursive: true });
461
470
  await writeFile(path.join(dir, `${SERVICE_NAME}.service`), systemdUnit());
471
+ await run('loginctl', ['enable-linger', os.userInfo().username]).catch(() => undefined);
462
472
  await run('systemctl', ['--user', 'daemon-reload']).catch(() => undefined);
463
473
  await run('systemctl', ['--user', 'enable', '--now', SERVICE_NAME]).catch(() => undefined);
464
474
  return;
@@ -512,6 +522,16 @@ function launchdPlist() {
512
522
  </plist>
513
523
  `;
514
524
  }
525
+ function here() {
526
+ return `${process.execPath} ${entryPath()}`;
527
+ }
528
+ async function serviceRunning() {
529
+ return (await run('systemctl', ['--user', 'is-active', SERVICE_NAME]).catch(() => null)) !== null;
530
+ }
531
+ async function userLingers() {
532
+ const shown = await run('loginctl', ['show-user', os.userInfo().username, '-p', 'Linger']).catch(() => null);
533
+ return shown?.stdout.includes('Linger=yes') === true;
534
+ }
515
535
  function entryPath() {
516
536
  return path.join(path.dirname(new URL(import.meta.url).pathname), 'index.js');
517
537
  }
@@ -554,6 +574,8 @@ const MAX_BACKOFF_MS = 120_000;
554
574
  const KEYS_BEGIN = '# craftspace begin';
555
575
  const KEYS_END = '# craftspace end';
556
576
  const POLL_INTERVAL_MS = 1_000;
577
+ const BEATING = 'beating every 15s, outbound only, and keeps this set up';
578
+ const LINGER_LINE = `sudo loginctl enable-linger ${os.userInfo().username}`;
557
579
  const DEFAULT_URL = process.env.CRAFTSPACE_URL ?? 'https://craftspace.app';
558
580
  const PROBE_EVERY_MS = 300_000;
559
581
  let probed = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@craftspace/cli",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "description": "Sign a Mac or Linux machine into Craftspace and keep its agent setup in step.",
6
6
  "license": "MIT",