@netnodeag/kraftwerk 0.96.0 → 0.98.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 (69) hide show
  1. package/README.md +52 -0
  2. package/dist/cli/boards.js +6 -5
  3. package/dist/cli/init.js +2 -0
  4. package/dist/cli/knowledge.js +9 -6
  5. package/dist/cli/presentations.js +8 -4
  6. package/dist/cli/projects.js +1 -1
  7. package/dist/client/index.d.ts +2 -0
  8. package/dist/client/index.js +3 -0
  9. package/dist/client/routes.d.ts +12 -0
  10. package/dist/client/routes.js +12 -0
  11. package/dist/config.d.ts +34 -0
  12. package/dist/config.js +28 -1
  13. package/dist/core/boards.d.ts +3 -1
  14. package/dist/core/boards.js +32 -9
  15. package/dist/core/chat/sessions.d.ts +3 -3
  16. package/dist/core/chat/sessions.js +6 -5
  17. package/dist/core/chat/types.d.ts +2 -0
  18. package/dist/core/cloud.d.ts +45 -0
  19. package/dist/core/cloud.js +35 -0
  20. package/dist/core/knowledge.d.ts +0 -7
  21. package/dist/core/knowledge.js +6 -6
  22. package/dist/core/person.d.ts +41 -0
  23. package/dist/core/person.js +47 -0
  24. package/dist/core/projects.d.ts +1 -1
  25. package/dist/core/projects.js +3 -2
  26. package/dist/server/api/agents.js +2 -2
  27. package/dist/server/api/boards.js +1 -1
  28. package/dist/server/api/chats.js +11 -7
  29. package/dist/server/api/cloud.d.ts +8 -0
  30. package/dist/server/api/index.d.ts +86 -2
  31. package/dist/server/api/index.js +2 -0
  32. package/dist/server/api/presentations.js +2 -2
  33. package/dist/server/api/projects.d.ts +1 -1
  34. package/dist/server/api/projects.js +1 -1
  35. package/dist/server/api/remote-boards.d.ts +118 -0
  36. package/dist/server/api/remote-boards.js +51 -0
  37. package/dist/server/api/router.js +5 -2
  38. package/dist/server/api/workspace.d.ts +14 -1
  39. package/dist/server/api/workspace.js +21 -1
  40. package/dist/server/cloud.d.ts +3 -0
  41. package/dist/server/cloud.js +20 -4
  42. package/dist/server/person.d.ts +9 -0
  43. package/dist/server/person.js +14 -0
  44. package/dist/server/remote-boards.d.ts +35 -0
  45. package/dist/server/remote-boards.js +73 -0
  46. package/dist/server/server.js +60 -4
  47. package/dist/server/trust.d.ts +5 -1
  48. package/dist/server/users.d.ts +55 -0
  49. package/dist/server/users.js +258 -0
  50. package/package.json +1 -1
  51. package/schema/kraftwerk.schema.json +8 -0
  52. package/web/dist/assets/{dist-DkDmdJNX.js → dist-BKTdKbao.js} +1 -1
  53. package/web/dist/assets/{dist-DOW1X_nG.js → dist-BNpBR7sT.js} +1 -1
  54. package/web/dist/assets/dist-BRk23y92.js +1 -0
  55. package/web/dist/assets/{dist-DbBrc07-.js → dist-C83QYgqx.js} +1 -1
  56. package/web/dist/assets/{dist-14HFV7uD.js → dist-CJK_j1TB.js} +1 -1
  57. package/web/dist/assets/{dist-wkkpVezb.js → dist-CR_7NDsL.js} +1 -1
  58. package/web/dist/assets/{dist-DKQkCBo9.js → dist-ChYhEmdo.js} +1 -1
  59. package/web/dist/assets/{dist-DO04nOS3.js → dist-D-MsPdYw.js} +1 -1
  60. package/web/dist/assets/{dist-BYgXVWBg.js → dist-DxlgW6a_.js} +1 -1
  61. package/web/dist/assets/{dist-qkoQQWNK.js → dist-OpHqdZBt.js} +1 -1
  62. package/web/dist/assets/{dist-BiyjchCb.js → dist-gtc4RPDu.js} +1 -1
  63. package/web/dist/assets/{editor-DvkpSp7h.js → editor-RdZyT8Y9.js} +3 -3
  64. package/web/dist/assets/index-BGgQaaA9.css +2 -0
  65. package/web/dist/assets/index-J1hXaKgp.js +488 -0
  66. package/web/dist/index.html +2 -2
  67. package/web/dist/assets/dist-CCZcAg77.js +0 -1
  68. package/web/dist/assets/index-B5PLhJ-C.js +0 -488
  69. package/web/dist/assets/index-CWopPK15.css +0 -2
package/README.md CHANGED
@@ -535,6 +535,58 @@ names no origin — and `cloud.interval` is ignored: the cloud sets the
535
535
  cadence.) `/api/meta` and `/api/cloud` report the machine's state and claim
536
536
  code; `kraftwerk doctor` prints what happens to the workspace.
537
537
 
538
+ ### Who works here: users
539
+
540
+ Everything a person does — a task created, a log line, a knowledge page
541
+ verified, a chat message — is signed with who did it. `users:` in
542
+ kraftwerk.yml says who that is:
543
+
544
+ ```yaml
545
+ users:
546
+ mode: local # default: whoever sits at this machine, as human:<handle> (~/.kraftwerk/identity.json)
547
+ mode: cloud # people sign in with their kraftwerk cloud account
548
+ ```
549
+
550
+ With `mode: cloud` this machine's browser signs in before the UI opens: the
551
+ UI sends it to the cloud, the account confirms, and the cloud hands a
552
+ one-time code back that the daemon redeems with the machine's own secret.
553
+ Only accounts on the workspace (its owners and members, an org's people)
554
+ get in. From then on their actions are signed `human:<their handle>`, and
555
+ chats keep the account's uuid — the same person on every machine and clone.
556
+ The cloud is asked again every 15 minutes, so removing someone there signs
557
+ them out here; the person menu in the top bar signs out by hand. The
558
+ machine's own shell (the CLI, scripts on this machine) needs no sign-in: it
559
+ acts as the account that claimed the machine (`~/.kraftwerk/account.json`).
560
+ Paired devices and remote members keep their own credentials. `cloud` needs
561
+ the daemon connected to the cloud and the workspace's `id:`. `GET /api/me`
562
+ says who the caller is.
563
+
564
+ An API caller cannot name another person: a `human:…` actor in a request
565
+ body is replaced by whoever asks. Agents and processes still name
566
+ themselves (`lisa/claude`, `process:sync`).
567
+
568
+ ### Single player and multiplayer: local and cloud boards
569
+
570
+ Local boards (files under `kraftwerk-data/boards`) are single player: a
571
+ task goes to an agent or to yourself (`human:<handle>`, the person
572
+ `GET /api/me` names), and a person is never woken.
573
+
574
+ Cloud boards are multiplayer. They live in kraftwerk cloud, belong to the
575
+ workspace's `id:`, and everyone on the workspace sees and edits them, from
576
+ their own machine or the cloud's web app (`/w/<ws id>`). A task goes to
577
+ anyone on the workspace or to an agent. They show in the boards page
578
+ under the local ones, with a cloud mark, and never sync with them. This
579
+ machine reaches them through `/api/remote-boards/…`:
580
+
581
+ - A signed-in browser (`users: cloud`) acts as its person.
582
+ - Everything else on the machine acts as the account that claimed it.
583
+ - An agent names itself with `actor`.
584
+
585
+ The cloud lets a machine act only for that account and for people who
586
+ signed in to its UI. Offline is offline: while the cloud does not answer,
587
+ cloud boards are marked offline and nothing is cached. Agents are not
588
+ woken from a cloud board yet.
589
+
538
590
  ## Projects
539
591
 
540
592
  Turn on `projects:` in `kraftwerk.yml` (or the checkbox in settings) and
@@ -5,6 +5,7 @@ import { appendTaskLog, assignTask, createBoard, createTask, DEFAULT_BOARD, dele
5
5
  import { taskSessions } from "../core/board-wake.js";
6
6
  import { initContext as prepare } from "./routines.js";
7
7
  import { fmtAgo } from "./workspaces.js";
8
+ import { actorFor } from "../core/person.js";
8
9
  /**
9
10
  * `kraftwerk boards` and `kraftwerk tasks` — the boards (columns of tasks)
10
11
  * of a project or of the workspace, and the tasks on them. The same module
@@ -36,8 +37,8 @@ const die = (msg) => {
36
37
  console.error(chalk.red(msg));
37
38
  process.exit(1);
38
39
  };
39
- /** Who writes: --actor, else the session's KRAFTWERK_ACTOR, else human:user. */
40
- const actorOf = (opt) => (opt ?? process.env.KRAFTWERK_ACTOR ?? "").trim() || "human:user";
40
+ /** Who writes: --actor, else the session's KRAFTWERK_ACTOR (an agent), else this machine's person (core/person.ts). */
41
+ const actorOf = (opt) => (opt ?? process.env.KRAFTWERK_ACTOR ?? "").trim() || undefined;
41
42
  /** Which agent acts: --as, else the session's KRAFTWERK_AGENT. */
42
43
  const agentOf = (opt) => (opt ?? process.env.KRAFTWERK_AGENT ?? "").trim();
43
44
  /** The board a command means: --board, else the project's default board when it exists, else the only board. */
@@ -312,7 +313,7 @@ export function registerBoardCommands(program) {
312
313
  .option("--file <path>", "The task's markdown (what, done-when, notes) from a file")
313
314
  .option("--notes <text>", "The task's markdown inline")
314
315
  .option("-m, --message <text>", "A first log line")
315
- .option("--actor <actor>", "Who writes (default: KRAFTWERK_ACTOR, else human:user)")
316
+ .option("--actor <actor>", "Who writes (default: KRAFTWERK_ACTOR, else you: human:<handle>)")
316
317
  .option("--json", "Print the task as JSON")
317
318
  .action(async (title, opts) => {
318
319
  await prepare();
@@ -420,7 +421,7 @@ export function registerBoardCommands(program) {
420
421
  .argument("[entry]", "The line to record")
421
422
  .option("--file <path>", "Read the entry from a file")
422
423
  .option("--tail <n>", "Print the newest n lines instead of writing")
423
- .option("--actor <actor>", "Who writes (default: KRAFTWERK_ACTOR, else human:user)")
424
+ .option("--actor <actor>", "Who writes (default: KRAFTWERK_ACTOR, else you: human:<handle>)")
424
425
  .action(async (task, entry, opts) => {
425
426
  await prepare();
426
427
  try {
@@ -439,7 +440,7 @@ export function registerBoardCommands(program) {
439
440
  }
440
441
  const text = opts.file ? await readFile(opts.file, "utf8") : entry ?? "";
441
442
  const t = await appendTaskLog(ref, task, text, actorOf(opts.actor));
442
- console.log(`${chalk.green("✔")} logged on ${chalk.cyan(String(t.number))} ${chalk.dim(`(${actorOf(opts.actor)})`)}`);
443
+ console.log(`${chalk.green("✔")} logged on ${chalk.cyan(String(t.number))} ${chalk.dim(`(${await actorFor(actorOf(opts.actor))})`)}`);
443
444
  }
444
445
  catch (err) {
445
446
  die(err.message);
package/dist/cli/init.js CHANGED
@@ -38,6 +38,8 @@ skills: ${DATA_DIR}/skills # workspace skills (shared instruction packag
38
38
  # presentations: # slide decks as folders (deck.md + assets) per project and under ${DATA_DIR}/presentations — rendered from a template into PPTX, PDF and slide images (uncomment to enable)
39
39
  # cloud: # the daemon registers this MACHINE with the kraftwerk cloud and lists this workspace (\`kraftwerk login\` claims the machine)
40
40
  # enabled: false # uncomment both lines to leave this workspace out (\`kraftwerk cloud off\` turns the cloud off for the whole machine)
41
+ # users: # who works here: local (default) = this machine's handle; cloud = people sign in with their kraftwerk cloud account
42
+ # mode: cloud
41
43
  `;
42
44
  const WORKFLOW_TEMPLATE = `# yaml-language-server: $schema=${SCHEMA_URL}
43
45
  name: hello
@@ -5,6 +5,7 @@ import { resolveWorkspace } from "../config.js";
5
5
  import { fsck, getConcept, initBundle, knowledgeRoot, listBundles, listConcepts, searchKnowledge, validateBundle, verifyConcept, writeConcept, } from "../okf.js";
6
6
  import { deleteBundle } from "../core/knowledge.js";
7
7
  import { initContext as prepare } from "./routines.js";
8
+ import { actorFor } from "../core/person.js";
8
9
  /**
9
10
  * `kraftwerk knowledge` — the CLI surface over OKF bundles (the
10
11
  * inspector's Knowledge screen). This is the enforced write path: `put` stamps provenance
@@ -13,10 +14,11 @@ import { initContext as prepare } from "./routines.js";
13
14
  *
14
15
  * Agents identify via --actor (or KRAFTWERK_ACTOR); the OKF convention is
15
16
  * `<producer>/<version>` for agents, `human:<id>` for people,
16
- * `process:<id>` for automation. Humans default to `human:user`.
17
+ * `process:<id>` for automation. A person is this machine's
18
+ * (`human:<handle>`, core/person.ts).
17
19
  */
18
- const DEFAULT_ACTOR = "human:user";
19
- const actorOf = (opts) => opts.actor?.trim() || process.env.KRAFTWERK_ACTOR?.trim() || DEFAULT_ACTOR;
20
+ const DEFAULT_ACTOR = "you: human:<handle>";
21
+ const actorOf = (opts) => actorFor(opts.actor?.trim() || process.env.KRAFTWERK_ACTOR?.trim());
20
22
  async function root() {
21
23
  const project = await resolveWorkspace(process.cwd());
22
24
  return knowledgeRoot(project.root, project.config.knowledge);
@@ -128,9 +130,10 @@ export function registerKnowledgeCommands(program) {
128
130
  process.exit(2);
129
131
  }
130
132
  try {
131
- const result = await writeConcept(await root(), bundle, id, content, actorOf(opts));
133
+ const actor = await actorOf(opts);
134
+ const result = await writeConcept(await root(), bundle, id, content, actor);
132
135
  console.log(`${chalk.green("✔")} ${result.created ? "created" : "updated"} ${chalk.cyan(`${bundle}/${result.concept.id}`)} ` +
133
- chalk.dim(`(${result.concept.type}, by ${actorOf(opts)})`));
136
+ chalk.dim(`(${result.concept.type}, by ${actor})`));
134
137
  }
135
138
  catch (err) {
136
139
  console.error(chalk.red(err.message));
@@ -144,7 +147,7 @@ export function registerKnowledgeCommands(program) {
144
147
  .option("--by <actor>", `Verifier actor (default: ${DEFAULT_ACTOR})`)
145
148
  .action(async (ref, opts) => {
146
149
  const { bundle, id } = splitRef(ref);
147
- const actor = opts.by?.trim() || process.env.KRAFTWERK_ACTOR?.trim() || DEFAULT_ACTOR;
150
+ const actor = await actorFor(opts.by?.trim() || process.env.KRAFTWERK_ACTOR?.trim());
148
151
  try {
149
152
  const concept = await verifyConcept(await root(), bundle, id, actor);
150
153
  console.log(`${chalk.green("✔")} ${ref} verified by ${actor} → ${tierColor(concept.trustTier)}`);
@@ -4,6 +4,7 @@ import { readFile } from "node:fs/promises";
4
4
  import { createDeck, deleteDeck, exportDeck, getDeck, addComment, listComments, updateComment, initTemplate, listAllDecks, listDecks, listTemplates, } from "../core/presentations/index.js";
5
5
  import { initContext as prepare } from "./routines.js";
6
6
  import { fmtAgo } from "./workspaces.js";
7
+ import { machinePerson } from "../core/person.js";
7
8
  /**
8
9
  * kraftwerk presentations [list] [--project <slug>] [--all] [--json]
9
10
  * kraftwerk presentations show <name> [--project <slug>] [--json] the slides, the template's layouts and slots, the warnings
@@ -171,8 +172,11 @@ export function registerPresentationCommands(program) {
171
172
  console.log(`${chalk.green("wrote")} ${f}`);
172
173
  printWarnings(warnings);
173
174
  });
174
- /** Who writes: the session's actor (an agent), else human:user. */
175
- const actor = () => (process.env.KRAFTWERK_ACTOR ?? "").trim() || "human:user";
175
+ /** Who writes: the session's actor (an agent), else this machine's person. */
176
+ const actor = async () => {
177
+ const given = (process.env.KRAFTWERK_ACTOR ?? "").trim();
178
+ return given || (await machinePerson()).handle;
179
+ };
176
180
  cmd
177
181
  .command("comments")
178
182
  .description("The comments on a deck's slides and boxes: the open ones, or --all")
@@ -208,7 +212,7 @@ export function registerPresentationCommands(program) {
208
212
  .option("--slot <box>", "The box it is about")
209
213
  .action(async (name, slide, text, opts) => {
210
214
  await prepare();
211
- const c = await addComment(refOf(name, opts.project), { slide: Number(slide), text, author: actor(), ...(opts.slot ? { slot: opts.slot } : {}) }).catch((err) => die(err.message));
215
+ const c = await addComment(refOf(name, opts.project), { slide: Number(slide), text, author: await actor(), ...(opts.slot ? { slot: opts.slot } : {}) }).catch((err) => die(err.message));
212
216
  console.log(`${chalk.green("commented")} ${c.id} on slide ${c.n}`);
213
217
  });
214
218
  cmd
@@ -221,7 +225,7 @@ export function registerPresentationCommands(program) {
221
225
  .option("--reopen", "Open it again instead")
222
226
  .action(async (name, id, opts) => {
223
227
  await prepare();
224
- await updateComment(refOf(name, opts.project), id, { resolved: !opts.reopen, author: actor(), ...(opts.reply ? { reply: opts.reply } : {}) }).catch((err) => die(err.message));
228
+ await updateComment(refOf(name, opts.project), id, { resolved: !opts.reopen, author: await actor(), ...(opts.reply ? { reply: opts.reply } : {}) }).catch((err) => die(err.message));
225
229
  console.log(`${chalk.green(opts.reopen ? "reopened" : "resolved")} ${id}`);
226
230
  });
227
231
  cmd
@@ -194,7 +194,7 @@ export function registerProjectCommands(program) {
194
194
  .argument("<slug>", "Project folder name")
195
195
  .argument("[entry]", "The line to record; omit with --file")
196
196
  .option("--file <path>", "Read the entry from a file")
197
- .option("--actor <actor>", "Who writes: human:<id>, <agent>/<harness>, process:<id>", "human:user")
197
+ .option("--actor <actor>", "Who writes: <agent>/<harness>, process:<id> (default: you, human:<handle>)")
198
198
  .action(async (slug, entry, opts) => {
199
199
  await prepare();
200
200
  try {
@@ -77,6 +77,8 @@ export interface ClientOptions {
77
77
  token?: string;
78
78
  /** Called when the server says this device is not paired (401 `{pair: true}`) — show the pairing screen. */
79
79
  onUnauthorized?: () => void;
80
+ /** Called when the workspace signs people in (kraftwerk.yml `users: cloud`) and this browser is not: 401 `{signin}` names where. */
81
+ onSignin?: (url: string) => void;
80
82
  }
81
83
  export interface Client {
82
84
  call<N extends ApiName>(name: N, ...input: InputArg<N>): Promise<ApiResult<N>>;
@@ -62,6 +62,9 @@ export function createClient(opts = {}) {
62
62
  fn();
63
63
  if (res.status === 401 && data?.pair === true)
64
64
  opts.onUnauthorized?.();
65
+ const signin = data?.signin;
66
+ if (res.status === 401 && typeof signin === "string")
67
+ opts.onSignin?.(signin);
65
68
  return res.ok ? { ok: true, status: res.status, data } : { ok: false, status: res.status, data, error: errorOf(data) };
66
69
  };
67
70
  return {
@@ -101,6 +101,7 @@ export declare const ROUTES: {
101
101
  readonly "knowledge.list": readonly ["GET", "/api/knowledge"];
102
102
  readonly "knowledge.putConcept": readonly ["POST", "/api/knowledge/:bundle/concept"];
103
103
  readonly "knowledge.verify": readonly ["POST", "/api/knowledge/:bundle/verify"];
104
+ readonly "me.get": readonly ["GET", "/api/me"];
104
105
  readonly "meta.get": readonly ["GET", "/api/meta"];
105
106
  readonly "notifications.clear": readonly ["DELETE", "/api/notifications"];
106
107
  readonly "notifications.diagnose": readonly ["POST", "/api/notifications/:id/diagnose"];
@@ -139,6 +140,17 @@ export declare const ROUTES: {
139
140
  readonly "projects.saveLayout": readonly ["PUT", "/api/projects"];
140
141
  readonly "protocol.get": readonly ["GET", "/api/protocol"];
141
142
  readonly "refs.resolve": readonly ["POST", "/api/refs/resolve"];
143
+ readonly "remoteBoards.create": readonly ["POST", "/api/remote-boards"];
144
+ readonly "remoteBoards.delete": readonly ["DELETE", "/api/remote-boards/:board"];
145
+ readonly "remoteBoards.get": readonly ["GET", "/api/remote-boards/:board"];
146
+ readonly "remoteBoards.list": readonly ["GET", "/api/remote-boards"];
147
+ readonly "remoteBoards.people": readonly ["GET", "/api/remote-boards/people"];
148
+ readonly "remoteBoards.save": readonly ["PUT", "/api/remote-boards/:board"];
149
+ readonly "remoteTasks.create": readonly ["POST", "/api/remote-boards/:board/tasks"];
150
+ readonly "remoteTasks.delete": readonly ["DELETE", "/api/remote-boards/:board/tasks/:task"];
151
+ readonly "remoteTasks.get": readonly ["GET", "/api/remote-boards/:board/tasks/:task"];
152
+ readonly "remoteTasks.log": readonly ["POST", "/api/remote-boards/:board/tasks/:task/log"];
153
+ readonly "remoteTasks.save": readonly ["PUT", "/api/remote-boards/:board/tasks/:task"];
142
154
  readonly "repos.add": readonly ["POST", "/api/repos"];
143
155
  readonly "repos.commit": readonly ["GET", "/api/repos/:slug/commits/:hash"];
144
156
  readonly "repos.diff": readonly ["GET", "/api/repos/:slug/diff"];
@@ -102,6 +102,7 @@ export const ROUTES = {
102
102
  "knowledge.list": ["GET", "/api/knowledge"],
103
103
  "knowledge.putConcept": ["POST", "/api/knowledge/:bundle/concept"],
104
104
  "knowledge.verify": ["POST", "/api/knowledge/:bundle/verify"],
105
+ "me.get": ["GET", "/api/me"],
105
106
  "meta.get": ["GET", "/api/meta"],
106
107
  "notifications.clear": ["DELETE", "/api/notifications"],
107
108
  "notifications.diagnose": ["POST", "/api/notifications/:id/diagnose"],
@@ -140,6 +141,17 @@ export const ROUTES = {
140
141
  "projects.saveLayout": ["PUT", "/api/projects"],
141
142
  "protocol.get": ["GET", "/api/protocol"],
142
143
  "refs.resolve": ["POST", "/api/refs/resolve"],
144
+ "remoteBoards.create": ["POST", "/api/remote-boards"],
145
+ "remoteBoards.delete": ["DELETE", "/api/remote-boards/:board"],
146
+ "remoteBoards.get": ["GET", "/api/remote-boards/:board"],
147
+ "remoteBoards.list": ["GET", "/api/remote-boards"],
148
+ "remoteBoards.people": ["GET", "/api/remote-boards/people"],
149
+ "remoteBoards.save": ["PUT", "/api/remote-boards/:board"],
150
+ "remoteTasks.create": ["POST", "/api/remote-boards/:board/tasks"],
151
+ "remoteTasks.delete": ["DELETE", "/api/remote-boards/:board/tasks/:task"],
152
+ "remoteTasks.get": ["GET", "/api/remote-boards/:board/tasks/:task"],
153
+ "remoteTasks.log": ["POST", "/api/remote-boards/:board/tasks/:task/log"],
154
+ "remoteTasks.save": ["PUT", "/api/remote-boards/:board/tasks/:task"],
143
155
  "repos.add": ["POST", "/api/repos"],
144
156
  "repos.commit": ["GET", "/api/repos/:slug/commits/:hash"],
145
157
  "repos.diff": ["GET", "/api/repos/:slug/diff"],
package/dist/config.d.ts CHANGED
@@ -38,6 +38,8 @@
38
38
  * enabled: false # a per-workspace veto; the machine's switch is `kraftwerk cloud on|off` (~/.kraftwerk/cloud.json)
39
39
  * # No key here: the daemon registers the MACHINE (its relay id) and `kraftwerk login` claims it.
40
40
  * # `url` and `interval` are deprecated: the cloud's origin is the machine's (cloud.json / KRAFTWERK_CLOUD_URL).
41
+ * users: # who works here (see UsersConfig)
42
+ * mode: cloud # local (default): this machine's handle · cloud: sign in with a kraftwerk cloud account
41
43
  */
42
44
  /** Stable, versionless URL of the workflow JSON schema (editor validation). */
43
45
  export declare const SCHEMA_URL = "https://raw.githubusercontent.com/NETNODEAG/kraftwerk/main/kraftwerk/schema/workflow.schema.json";
@@ -188,6 +190,25 @@ export interface CloudConfig {
188
190
  /** @deprecated Ignored: the cloud sets the heartbeat interval. */
189
191
  interval?: number;
190
192
  }
193
+ /**
194
+ * kraftwerk.yml `users:` — who the person working in this workspace is.
195
+ *
196
+ * users:
197
+ * mode: local # default: whoever sits at this machine, named by its handle (~/.kraftwerk/identity.json)
198
+ * mode: cloud # people sign in with their kraftwerk cloud account: the UI asks first, and
199
+ * # what they do is signed with their account (uuid, handle) — the same person
200
+ * # on every machine and clone
201
+ *
202
+ * `cloud` needs the machine's daemon connected to the cloud (it redeems the
203
+ * sign-in) and the workspace's `id`. The machine's own shell (the CLI) acts
204
+ * as the account that claimed the machine (`kraftwerk login`).
205
+ */
206
+ export interface UsersConfig {
207
+ mode?: UsersMode;
208
+ }
209
+ export type UsersMode = "local" | "cloud";
210
+ /** A workspace's users mode: `cloud` only when kraftwerk.yml says so. */
211
+ export declare const usersMode: (config: WorkspaceConfig) => UsersMode;
191
212
  export declare const CLOUD_DEFAULT_URL = "https://srv.kraftwerk-cloud.netnode.cloud";
192
213
  /** A directory as a .gitignore entry: relative, forward slashes, no trailing slash; undefined outside the root. */
193
214
  export declare function ignoreEntryFor(projectRoot: string, dir: string): string | undefined;
@@ -255,6 +276,8 @@ export interface WorkspaceConfig {
255
276
  presentations?: PresentationsConfig;
256
277
  /** The machine's cloud record lists this workspace. Absent = listed; `enabled: false` leaves it out. */
257
278
  cloud?: CloudConfig;
279
+ /** Who the people working here are: local (default) or signed in with a cloud account. */
280
+ users?: UsersConfig;
258
281
  }
259
282
  export interface ResolvedWorkspace {
260
283
  /** Absolute project root the CLI operates on. */
@@ -317,3 +340,14 @@ export declare function newWorkspaceId(): string;
317
340
  * Returns the id, or the one already there.
318
341
  */
319
342
  export declare function addWorkspaceId(configPath: string): Promise<string>;
343
+ /**
344
+ * kraftwerk.yml, parsed and checked — from the file cache while the file is
345
+ * unchanged (every request resolves the workspace, so this runs constantly).
346
+ * Each caller gets its own copy.
347
+ */
348
+ /**
349
+ * The config of a known workspace root, cheap enough for every request (one
350
+ * stat while kraftwerk.yml is unchanged); {} without one or when it does not
351
+ * parse.
352
+ */
353
+ export declare function configAt(root: string): Promise<WorkspaceConfig>;
package/dist/config.js CHANGED
@@ -44,6 +44,8 @@ import { readParsed } from "./core/file-cache.js";
44
44
  * enabled: false # a per-workspace veto; the machine's switch is `kraftwerk cloud on|off` (~/.kraftwerk/cloud.json)
45
45
  * # No key here: the daemon registers the MACHINE (its relay id) and `kraftwerk login` claims it.
46
46
  * # `url` and `interval` are deprecated: the cloud's origin is the machine's (cloud.json / KRAFTWERK_CLOUD_URL).
47
+ * users: # who works here (see UsersConfig)
48
+ * mode: cloud # local (default): this machine's handle · cloud: sign in with a kraftwerk cloud account
47
49
  */
48
50
  /** Stable, versionless URL of the workflow JSON schema (editor validation). */
49
51
  export const SCHEMA_URL = "https://raw.githubusercontent.com/NETNODEAG/kraftwerk/main/kraftwerk/schema/workflow.schema.json";
@@ -123,6 +125,8 @@ export function entitiesRootFor(project, kind) {
123
125
  return undefined;
124
126
  return path.resolve(project.root, e.root ?? entityDefaultRoot(kind));
125
127
  }
128
+ /** A workspace's users mode: `cloud` only when kraftwerk.yml says so. */
129
+ export const usersMode = (config) => (config.users?.mode === "cloud" ? "cloud" : "local");
126
130
  export const CLOUD_DEFAULT_URL = "https://srv.kraftwerk-cloud.netnode.cloud";
127
131
  /** A directory as a .gitignore entry: relative, forward slashes, no trailing slash; undefined outside the root. */
128
132
  export function ignoreEntryFor(projectRoot, dir) {
@@ -258,7 +262,7 @@ export async function addWorkspaceId(configPath) {
258
262
  await writeFile(configPath, out);
259
263
  return id;
260
264
  }
261
- const KNOWN_KEYS = ["id", "name", "slug", "icon", "color", "port", "workflows", "output", "knowledge", "agents", "skills", "switcher", "git", "repos", "vibeables", "projects", "contacts", "places", "events", "boards", "presentations", "cloud"];
265
+ const KNOWN_KEYS = ["id", "name", "slug", "icon", "color", "port", "workflows", "output", "knowledge", "agents", "skills", "switcher", "git", "repos", "vibeables", "projects", "contacts", "places", "events", "boards", "presentations", "cloud", "users"];
262
266
  /**
263
267
  * Keys an older kraftwerk understood and this one ignores, so the files
264
268
  * that still carry them keep loading: `public:` and `tunnel:` (the
@@ -271,6 +275,19 @@ const LEGACY_KEYS = ["public", "tunnel"];
271
275
  * unchanged (every request resolves the workspace, so this runs constantly).
272
276
  * Each caller gets its own copy.
273
277
  */
278
+ /**
279
+ * The config of a known workspace root, cheap enough for every request (one
280
+ * stat while kraftwerk.yml is unchanged); {} without one or when it does not
281
+ * parse.
282
+ */
283
+ export async function configAt(root) {
284
+ for (const name of CONFIG_FILENAMES) {
285
+ const loaded = await loadConfig(path.join(root, name)).catch(() => null);
286
+ if (loaded)
287
+ return loaded.config;
288
+ }
289
+ return {};
290
+ }
274
291
  async function loadConfig(configPath) {
275
292
  try {
276
293
  return await readParsed(configPath, (text) => checkConfig(configPath, text), (r) => ({ config: structuredClone(r.config), legacyKeys: [...r.legacyKeys] }));
@@ -356,6 +373,16 @@ function checkConfig(configPath, text) {
356
373
  config[key] = {};
357
374
  validateCloud(configPath, config[key]);
358
375
  }
376
+ else if (key === "users") {
377
+ if (config[key] === null)
378
+ config[key] = {};
379
+ const u = config[key];
380
+ const bad = typeof u !== "object" || Array.isArray(u) || Object.keys(u).some((k) => k !== "mode");
381
+ const mode = u?.mode;
382
+ if (bad || (mode !== undefined && mode !== "local" && mode !== "cloud")) {
383
+ throw new Error(`${path.basename(configPath)}: users must be a mapping with mode: local (default) or mode: cloud`);
384
+ }
385
+ }
359
386
  else if (typeof config[key] !== "string") {
360
387
  throw new Error(`${path.basename(configPath)}: ${key} must be a string`);
361
388
  }
@@ -146,7 +146,7 @@ export interface TaskInput {
146
146
  refs?: unknown;
147
147
  notes?: string;
148
148
  }
149
- /** Who writes (an actor string: human:user, lisa/claude, …) and an optional message for the log. */
149
+ /** Who writes (an actor string: lisa/claude, process:…; a person is whoever asks) and an optional message for the log. */
150
150
  export interface WriteOpts {
151
151
  actor?: string;
152
152
  message?: string;
@@ -178,6 +178,8 @@ export declare function parseTaskRef(text: string): {
178
178
  export declare function parseBoardRef(text: string): BoardRef;
179
179
  /** "1d", "12h", "90m" -> milliseconds. */
180
180
  export declare function parseDuration(text: string): number;
181
+ /** A person as assignee: `human:<handle>`, the same form logs sign human changes with. */
182
+ export declare const isHumanAssignee: (a: string | undefined | null) => a is string;
181
183
  /** The column `tasks pick` takes from: "todo" when the board has it, else the second column (the first is the inbox), else the only one. */
182
184
  export declare const pickColumn: (columns: Column[]) => Column | undefined;
183
185
  /** A column's role: work columns — from the pick column on, review and done excepted — are where an assigned agent is expected to act. */
@@ -10,6 +10,8 @@ import { openProjects, safeProjectSlug } from "./projects.js";
10
10
  import { findRefs, resolveTokens } from "./refs.js";
11
11
  import { SLUG_RE, slugify } from "./slug.js";
12
12
  import { moveToTrash } from "./trash.js";
13
+ import { IDENTITY_PART_RE } from "./identity.js";
14
+ import { actorFor } from "./person.js";
13
15
  /**
14
16
  * Boards and tasks: the work of a project (or of the whole workspace) as
15
17
  * columns of cards, stored as plain folders so humans, agents and git all
@@ -177,6 +179,23 @@ const cleanAgentSlug = (v) => {
177
179
  throw new Error("agent must be an agent slug");
178
180
  return v.trim();
179
181
  };
182
+ /** A person as assignee: `human:<handle>`, the same form logs sign human changes with. */
183
+ export const isHumanAssignee = (a) => !!a && a.startsWith("human:");
184
+ /** An assignee is an agent slug or a person (`human:<handle>`); a person is never woken. */
185
+ const cleanAssignee = (v) => {
186
+ if (typeof v === "string" && v.trim().startsWith("human:")) {
187
+ const handle = v.trim().slice("human:".length);
188
+ if (!IDENTITY_PART_RE.test(handle))
189
+ throw new Error(`assignee "${v.trim()}" must be an agent slug or human:<handle>`);
190
+ return `human:${handle}`;
191
+ }
192
+ try {
193
+ return cleanAgentSlug(v);
194
+ }
195
+ catch {
196
+ throw new Error(`assignee must be an agent slug or human:<handle>, not "${String(v)}"`);
197
+ }
198
+ };
180
199
  /** Split a Markdown file into its frontmatter text and body (same rule as entities.ts). */
181
200
  function splitFrontmatter(raw) {
182
201
  if (!raw.startsWith("---"))
@@ -306,7 +325,7 @@ function parseTask(slug, data, columns) {
306
325
  if (!Number.isFinite(order))
307
326
  throw new Error("order must be a number");
308
327
  const def = { slug, number, title, status, order, created: cleanDate(data.created, "created") ?? "", tags: strList(data.tags, "tags"), refs: strList(data.refs, "refs") };
309
- const assignee = cleanAgentSlug(data.assignee);
328
+ const assignee = cleanAssignee(data.assignee);
310
329
  if (assignee)
311
330
  def.assignee = assignee;
312
331
  const due = cleanDate(data.due, "due");
@@ -666,7 +685,8 @@ async function writeLogLine(dir, title, text, actor, now = new Date()) {
666
685
  }
667
686
  await fs.writeFile(file, lines.join("\n").replace(/\n{3,}/g, "\n\n"));
668
687
  }
669
- const cleanActor = (actor) => (actor ?? "").trim() || "human:user";
688
+ /** An agent's or a process's own name as given; a person is whoever asks (core/person.ts). */
689
+ const cleanActor = (actor) => actorFor(actor);
670
690
  const oneLine = (text) => text.trim().replace(/\s*\n\s*/g, " ");
671
691
  /** Append a free entry to a task's log: what was done, a comment, a question. */
672
692
  export async function appendTaskLog(ref, idOrNumber, entry, actor) {
@@ -676,7 +696,8 @@ export async function appendTaskLog(ref, idOrNumber, entry, actor) {
676
696
  const text = oneLine(entry);
677
697
  if (!text)
678
698
  throw new Error("entry is required");
679
- await withTaskLock(t.path, () => writeLogLine(t.path, t.title, text, cleanActor(actor)));
699
+ const who = await cleanActor(actor);
700
+ await withTaskLock(t.path, () => writeLogLine(t.path, t.title, text, who));
680
701
  changed();
681
702
  return (await getTask(ref, t.slug));
682
703
  }
@@ -691,7 +712,8 @@ async function emitTaskEvent(ev) {
691
712
  /** After a write: wake the assignee when the (assignee, status) pair changed into "an agent in a work column". */
692
713
  async function maybeEmit(ref, board, before, after, reason, actor, message) {
693
714
  const col = board.columns.find((c) => c.slug === after.status);
694
- if (!after.assignee || !isWorkColumn(col, board.columns))
715
+ // A person works on their own: only agents are woken.
716
+ if (!after.assignee || isHumanAssignee(after.assignee) || !isWorkColumn(col, board.columns))
695
717
  return;
696
718
  if (before && before.assignee === after.assignee && before.status === after.status)
697
719
  return;
@@ -740,7 +762,7 @@ function applyInput(def, input, board) {
740
762
  next.order = Number(input.order);
741
763
  }
742
764
  if (input.assignee !== undefined) {
743
- const a = cleanAgentSlug(input.assignee ?? undefined);
765
+ const a = cleanAssignee(input.assignee ?? undefined);
744
766
  if (a)
745
767
  next.assignee = a;
746
768
  else
@@ -770,7 +792,7 @@ export async function createTask(ref, input) {
770
792
  const title = (input.title ?? "").trim();
771
793
  if (!title)
772
794
  throw new Error("title is required");
773
- const actor = cleanActor(input.actor);
795
+ const actor = await cleanActor(input.actor);
774
796
  const base = emptyTask("0-task", board.columns);
775
797
  base.created = localDate(new Date());
776
798
  let def = applyInput(base, { ...input, title }, board);
@@ -815,7 +837,7 @@ export async function saveTask(ref, idOrNumber, input, opts = {}) {
815
837
  throw new Error(`no task "${idOrNumber}" on board "${boardKey(ref)}"`);
816
838
  if (current.configError)
817
839
  throw new Error(`task "${current.slug}" cannot be saved until its file is fixed by hand (${current.configError}): ${current.path}`);
818
- const actor = cleanActor(opts.actor);
840
+ const actor = await cleanActor(opts.actor);
819
841
  const { ref: _r, path: _p, updatedAt: _u, configError: _c, files: _f, lastLog: _l, stale: _s, notes: _n, log: _g, fileList: _fl, board: _b, project: _pj, ...def } = current;
820
842
  const next = applyInput(def, input, board);
821
843
  if (input.status !== undefined && input.status !== def.status && input.order === undefined)
@@ -900,7 +922,7 @@ export async function pickTask(ref, agent, opts = {}) {
900
922
  const { ref: _r, path: _p, updatedAt: _u, configError: _c, files: _f, lastLog: _l, stale: _s, ...def } = fresh.summary;
901
923
  const next = { ...def, assignee: slugAgent, status: toCol.slug, order: nextOrder(board.items, toCol.slug) };
902
924
  await fs.writeFile(path.join(c.path, TASK_FILE), taskToFile(next, fresh.notes));
903
- await writeLogLine(c.path, next.title, `Picked up (${from.label} → ${toCol.label})`, cleanActor(opts.actor ?? slugAgent));
925
+ await writeLogLine(c.path, next.title, `Picked up (${from.label} → ${toCol.label})`, await cleanActor(opts.actor ?? slugAgent));
904
926
  return true;
905
927
  });
906
928
  if (won) {
@@ -923,7 +945,8 @@ export async function noteTaskFile(reference, what, file, actor) {
923
945
  const t = await findTask(reference);
924
946
  if (!t)
925
947
  return;
926
- await withTaskLock(t.path, () => writeLogLine(t.path, t.title, `File ${what}: ${file}`, cleanActor(actor)));
948
+ const who = await cleanActor(actor);
949
+ await withTaskLock(t.path, () => writeLogLine(t.path, t.title, `File ${what}: ${file}`, who));
927
950
  changed();
928
951
  }
929
952
  /* ---------- agent context ---------- */
@@ -9,9 +9,9 @@ export { disposeAllBackends, disposeWorkspaceBackends } from "./state.js";
9
9
  * process (seats.ts) and channel turns (channel-turns.ts).
10
10
  */
11
11
  /**
12
- * This machine's person: its identity handle (identity.ts). What a chat or
13
- * message is signed with when nobody else is named — local use, a paired
14
- * device, a routine's run. A member session names its member instead.
12
+ * The person a chat or message is signed with when nobody else is named:
13
+ * the one the current request runs as, else this machine's (core/person.ts)
14
+ * — local use, a paired device, a routine's run.
15
15
  */
16
16
  export declare function localPerson(): Promise<ChatPerson>;
17
17
  /**
@@ -6,7 +6,6 @@ import { resolveVibeable } from "../vibeables.js";
6
6
  import { announcedOptions, deleteAgentSession, listAgentSessions } from "./acp.js";
7
7
  import { listPiModels, piOptions } from "./pi.js";
8
8
  import { chatHref, pushNotification } from "../notifications.js";
9
- import { readIdentity } from "../identity.js";
10
9
  import { moveToTrash } from "../trash.js";
11
10
  import { removeSessionTemp } from "../temp.js";
12
11
  import { attachmentPath, copyChatFiles, listChatMetas, newChatId, readMetaAt, safeChatDir, writeMeta } from "./store.js";
@@ -14,6 +13,7 @@ import { postChannelMessage } from "./channel-turns.js";
14
13
  import { expandSkillInvocation, scopeContext } from "./context.js";
15
14
  import { ensureBackend } from "./seats.js";
16
15
  import { MAIN, chatLabel, chatStates, dropBackend, dropSeat, emit, forgetFailedResume, isBusy, isUnattended, lastEventText, loadState, mainSeat, newSeat, ownerLabel, routineRef } from "./state.js";
16
+ import { currentPerson } from "../person.js";
17
17
  export { agentFilesContext, agentJournalContext, agentVibeablesContext, vibeableContext } from "./context.js";
18
18
  export { disposeAllBackends, disposeWorkspaceBackends } from "./state.js";
19
19
  /**
@@ -24,12 +24,13 @@ export { disposeAllBackends, disposeWorkspaceBackends } from "./state.js";
24
24
  */
25
25
  /* ---------- public API (used by server.ts) ---------- */
26
26
  /**
27
- * This machine's person: its identity handle (identity.ts). What a chat or
28
- * message is signed with when nobody else is named — local use, a paired
29
- * device, a routine's run. A member session names its member instead.
27
+ * The person a chat or message is signed with when nobody else is named:
28
+ * the one the current request runs as, else this machine's (core/person.ts)
29
+ * — local use, a paired device, a routine's run.
30
30
  */
31
31
  export async function localPerson() {
32
- return { handle: (await readIdentity()).handle };
32
+ const p = await currentPerson();
33
+ return { handle: p.handle, ...(p.id ? { id: p.id } : {}), ...(p.email ? { email: p.email } : {}) };
33
34
  }
34
35
  /** Where a chat's agent runs when no vibeable is open: the run folder for run chats, else the project root. */
35
36
  const defaultCwd = (scope) => (scope.kind === "run" ? safeRunDir(scope.runId) : workspaceRoot());
@@ -46,6 +46,8 @@ export type ChatScope = {
46
46
  */
47
47
  export interface ChatPerson {
48
48
  handle: string;
49
+ /** The cloud account's uuid (a person signed in with `users: cloud`): the same person on every machine. */
50
+ id?: string;
49
51
  /** A remote member's account email; absent for this machine's own person. */
50
52
  email?: string;
51
53
  }