@netnodeag/kraftwerk 0.97.0 → 0.99.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 (32) hide show
  1. package/README.md +29 -0
  2. package/dist/cli/boards.js +69 -20
  3. package/dist/client/routes.d.ts +11 -0
  4. package/dist/client/routes.js +11 -0
  5. package/dist/core/boards.d.ts +6 -0
  6. package/dist/core/boards.js +22 -3
  7. package/dist/server/api/boards.d.ts +15 -3
  8. package/dist/server/api/boards.js +61 -18
  9. package/dist/server/api/index.d.ts +79 -3
  10. package/dist/server/api/index.js +2 -0
  11. package/dist/server/api/remote-boards.d.ts +118 -0
  12. package/dist/server/api/remote-boards.js +51 -0
  13. package/dist/server/cloud-boards.d.ts +79 -0
  14. package/dist/server/cloud-boards.js +200 -0
  15. package/dist/server/remote-boards.d.ts +37 -0
  16. package/dist/server/remote-boards.js +87 -0
  17. package/package.json +1 -1
  18. package/web/dist/assets/{dist-lcPkaK4d.js → dist-BRxqHunp.js} +1 -1
  19. package/web/dist/assets/{dist-D_uWSMLk.js → dist-BXFsZFyR.js} +1 -1
  20. package/web/dist/assets/{dist-BD4ooe-Y.js → dist-CLgsXxq9.js} +1 -1
  21. package/web/dist/assets/{dist-BduOHHOY.js → dist-CRwoZ0QP.js} +1 -1
  22. package/web/dist/assets/{dist-P7JCq9c3.js → dist-CZyarE8b.js} +1 -1
  23. package/web/dist/assets/{dist-oRcLByHn.js → dist-DAw93zvk.js} +1 -1
  24. package/web/dist/assets/{dist-BoajTxbz.js → dist-DIla3sxz.js} +1 -1
  25. package/web/dist/assets/{dist-DJACzcZZ.js → dist-MYpSAhEK.js} +1 -1
  26. package/web/dist/assets/{dist-DGLb7wE6.js → dist-Ntegnq0p.js} +1 -1
  27. package/web/dist/assets/dist-Whol13-K.js +1 -0
  28. package/web/dist/assets/{dist-DY6QplYX.js → dist-trHwQ1EL.js} +1 -1
  29. package/web/dist/assets/{editor-hTceN7Iz.js → editor-BIPcwrnh.js} +3 -3
  30. package/web/dist/assets/{index-BOkjCxut.js → index-DbBIKEeD.js} +121 -121
  31. package/web/dist/index.html +1 -1
  32. package/web/dist/assets/dist-ajNgHt2Q.js +0 -1
@@ -107,7 +107,7 @@ export declare const routes: (Route<"agents.addJournal", {
107
107
  content: string;
108
108
  }, "/api/agents/:slug/skills/:name", undefined> | Route<"agents.skills", {
109
109
  skills: import("../../core/skills.js").SkillInfo[];
110
- }, "/api/agents/:slug/skills", undefined> | Route<"agents.status", Record<string, import("../../core/agent-status.js").AgentStatus>, "/api/agent-status", undefined> | Route<"attention.list", import("../../core/attention.js").AttentionView, "/api/attention", undefined> | Route<"boards.create", import("./router.js").Reply<import("../../core/boards.js").BoardDetail>, "/api/boards", z.ZodObject<{
110
+ }, "/api/agents/:slug/skills", undefined> | Route<"agents.status", Record<string, import("../../core/agent-status.js").AgentStatus>, "/api/agent-status", undefined> | Route<"attention.list", import("../../core/attention.js").AttentionView, "/api/attention", undefined> | Route<"boards.create", import("./router.js").Reply<import("../../core/boards.js").BoardSummary & import("../cloud-boards.js").CloudMark>, "/api/boards", z.ZodObject<{
111
111
  title: z.ZodString;
112
112
  slug: z.ZodOptional<z.ZodString>;
113
113
  project: z.ZodOptional<z.ZodString>;
@@ -120,11 +120,21 @@ export declare const routes: (Route<"agents.addJournal", {
120
120
  }, z.core.$strip>]>>>;
121
121
  agent: z.ZodOptional<z.ZodString>;
122
122
  notes: z.ZodOptional<z.ZodString>;
123
+ cloud: z.ZodOptional<z.ZodBoolean>;
123
124
  }, z.core.$strip>> | Route<"boards.delete", {
124
125
  ok: boolean;
125
126
  }, "/api/boards/:board", undefined> | Route<"boards.ensure", import("../../core/boards.js").BoardDetail, "/api/boards/default", z.ZodObject<{
126
127
  project: z.ZodOptional<z.ZodString>;
127
- }, z.core.$strip>> | Route<"boards.get", import("../../core/boards.js").BoardDetail, "/api/boards/:board", undefined> | Route<"boards.list", import("../../core/boards.js").BoardsView, "/api/boards", undefined> | Route<"boards.save", import("../../core/boards.js").BoardDetail, "/api/boards/:board", z.ZodObject<{
128
+ }, z.core.$strip>> | Route<"boards.get", import("../../core/boards.js").BoardDetail, "/api/boards/:board", undefined> | Route<"boards.list", import("../../core/boards.js").BoardsView | {
129
+ enabled: boolean;
130
+ root?: string;
131
+ error?: string;
132
+ boards: import("../../core/boards.js").BoardSummary[];
133
+ cloud: {
134
+ offline?: boolean | undefined;
135
+ error?: string | undefined;
136
+ };
137
+ }, "/api/boards", undefined> | Route<"boards.save", import("../../core/boards.js").BoardSummary & import("../cloud-boards.js").CloudMark, "/api/boards/:board", z.ZodObject<{
128
138
  title: z.ZodOptional<z.ZodString>;
129
139
  columns: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
130
140
  slug: z.ZodString;
@@ -751,6 +761,71 @@ export declare const routes: (Route<"agents.addJournal", {
751
761
  }, "/api/refs/resolve", z.ZodObject<{
752
762
  tokens: z.ZodDefault<z.ZodArray<z.ZodString>>;
753
763
  text: z.ZodDefault<z.ZodString>;
764
+ }, z.core.$strip>> | Route<"remoteBoards.create", import("./router.js").Reply<{
765
+ board: import("./remote-boards.js").RemoteBoardSummary;
766
+ }>, "/api/remote-boards", z.ZodObject<{
767
+ title: z.ZodOptional<z.ZodString>;
768
+ slug: z.ZodOptional<z.ZodString>;
769
+ columns: z.ZodOptional<z.ZodArray<z.ZodObject<{
770
+ slug: z.ZodOptional<z.ZodString>;
771
+ title: z.ZodString;
772
+ }, z.core.$strip>>>;
773
+ }, z.core.$strip>> | Route<"remoteBoards.delete", {
774
+ ok: true;
775
+ }, "/api/remote-boards/:board", undefined> | Route<"remoteBoards.get", {
776
+ board: import("./remote-boards.js").RemoteBoardSummary;
777
+ tasks: import("./remote-boards.js").RemoteTaskSummary[];
778
+ people: import("./remote-boards.js").RemotePerson[];
779
+ actor: string;
780
+ }, "/api/remote-boards/:board", undefined> | Route<"remoteBoards.list", {
781
+ boards: import("./remote-boards.js").RemoteBoardSummary[];
782
+ role: "owner" | "member";
783
+ actor: string;
784
+ cloudUrl: string | null;
785
+ }, "/api/remote-boards", undefined> | Route<"remoteBoards.people", {
786
+ people: import("./remote-boards.js").RemotePerson[];
787
+ actor: string;
788
+ role: "owner" | "member";
789
+ }, "/api/remote-boards/people", undefined> | Route<"remoteBoards.save", {
790
+ board: import("./remote-boards.js").RemoteBoardSummary;
791
+ }, "/api/remote-boards/:board", z.ZodObject<{
792
+ title: z.ZodOptional<z.ZodString>;
793
+ slug: z.ZodOptional<z.ZodString>;
794
+ columns: z.ZodOptional<z.ZodArray<z.ZodObject<{
795
+ slug: z.ZodOptional<z.ZodString>;
796
+ title: z.ZodString;
797
+ }, z.core.$strip>>>;
798
+ }, z.core.$strip>> | Route<"remoteTasks.create", import("./router.js").Reply<{
799
+ task: import("./remote-boards.js").RemoteTaskDetail;
800
+ }>, "/api/remote-boards/:board/tasks", z.ZodObject<{
801
+ title: z.ZodOptional<z.ZodString>;
802
+ status: z.ZodOptional<z.ZodString>;
803
+ position: z.ZodOptional<z.ZodNumber>;
804
+ assignee: z.ZodOptional<z.ZodNullable<z.ZodString>>;
805
+ due: z.ZodOptional<z.ZodNullable<z.ZodString>>;
806
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
807
+ notes: z.ZodOptional<z.ZodString>;
808
+ actor: z.ZodOptional<z.ZodString>;
809
+ }, z.core.$strip>> | Route<"remoteTasks.delete", {
810
+ ok: true;
811
+ }, "/api/remote-boards/:board/tasks/:task", undefined> | Route<"remoteTasks.get", {
812
+ task: import("./remote-boards.js").RemoteTaskDetail;
813
+ }, "/api/remote-boards/:board/tasks/:task", undefined> | Route<"remoteTasks.log", {
814
+ task: import("./remote-boards.js").RemoteTaskDetail;
815
+ }, "/api/remote-boards/:board/tasks/:task/log", z.ZodObject<{
816
+ entry: z.ZodString;
817
+ actor: z.ZodOptional<z.ZodString>;
818
+ }, z.core.$strip>> | Route<"remoteTasks.save", {
819
+ task: import("./remote-boards.js").RemoteTaskDetail;
820
+ }, "/api/remote-boards/:board/tasks/:task", z.ZodObject<{
821
+ title: z.ZodOptional<z.ZodString>;
822
+ status: z.ZodOptional<z.ZodString>;
823
+ position: z.ZodOptional<z.ZodNumber>;
824
+ assignee: z.ZodOptional<z.ZodNullable<z.ZodString>>;
825
+ due: z.ZodOptional<z.ZodNullable<z.ZodString>>;
826
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
827
+ notes: z.ZodOptional<z.ZodString>;
828
+ actor: z.ZodOptional<z.ZodString>;
754
829
  }, z.core.$strip>> | Route<"repos.add", import("./router.js").Reply<import("../../core/repos.js").RepoInfo>, "/api/repos", z.ZodObject<{
755
830
  url: z.ZodDefault<z.ZodString>;
756
831
  name: z.ZodOptional<z.ZodString>;
@@ -894,6 +969,7 @@ export declare const routes: (Route<"agents.addJournal", {
894
969
  files: number;
895
970
  lastLog?: string;
896
971
  stale?: boolean;
972
+ cloud?: true;
897
973
  notes: string;
898
974
  log: string;
899
975
  fileList: string[];
@@ -912,7 +988,7 @@ export declare const routes: (Route<"agents.addJournal", {
912
988
  message: z.ZodOptional<z.ZodString>;
913
989
  actor: z.ZodOptional<z.ZodString>;
914
990
  }, z.core.$strip>> | Route<"tasks.pick", {
915
- task: import("../../core/boards.js").TaskDetail | null;
991
+ task: (import("../../core/boards.js").TaskDetail & import("../cloud-boards.js").CloudMark) | null;
916
992
  }, "/api/boards/:board/pick", z.ZodObject<{
917
993
  agent: z.ZodString;
918
994
  column: z.ZodOptional<z.ZodString>;
@@ -13,6 +13,7 @@ import { gitRoutes } from "./git.js";
13
13
  import { knowledgeRoutes } from "./knowledge.js";
14
14
  import { presentationRoutes } from "./presentations.js";
15
15
  import { projectRoutes } from "./projects.js";
16
+ import { remoteBoardRoutes } from "./remote-boards.js";
16
17
  import { createRouter, route } from "./router.js";
17
18
  import { runRoutes } from "./runs.js";
18
19
  import { vibeableRoutes } from "./vibeables.js";
@@ -34,6 +35,7 @@ const domainRoutes = [
34
35
  ...channelRoutes,
35
36
  ...projectRoutes,
36
37
  ...boardRoutes,
38
+ ...remoteBoardRoutes,
37
39
  ...presentationRoutes,
38
40
  ...contactRoutes,
39
41
  ...placeRoutes,
@@ -0,0 +1,118 @@
1
+ import * as z from "zod";
2
+ /**
3
+ * Remote boards over this machine's API (server/remote-boards.ts): the
4
+ * workspace's boards in kraftwerk cloud, multiplayer, beside the local
5
+ * boards (api/boards.ts). Every call goes to the cloud as the caller's
6
+ * person; 503 `{offline: true}` while the cloud is off or unreachable.
7
+ * Shapes are the cloud's (kraftwerk-cloud src/boards.ts).
8
+ */
9
+ export interface RemoteColumn {
10
+ slug: string;
11
+ title: string;
12
+ }
13
+ export interface RemoteBoardSummary {
14
+ slug: string;
15
+ title: string;
16
+ columns: RemoteColumn[];
17
+ counts: Record<string, number>;
18
+ taskCount: number;
19
+ createdBy: string | null;
20
+ createdAt: number;
21
+ updatedAt: number;
22
+ }
23
+ export interface RemoteTaskSummary {
24
+ number: number;
25
+ title: string;
26
+ status: string;
27
+ position: number;
28
+ /** human:<handle> or an agent slug. */
29
+ assignee: string | null;
30
+ assigneeId?: string;
31
+ due: string | null;
32
+ tags: string[];
33
+ createdBy: string;
34
+ createdAt: number;
35
+ updatedAt: number;
36
+ last: string | null;
37
+ }
38
+ export interface RemoteTaskDetail extends RemoteTaskSummary {
39
+ board: string;
40
+ notes: string;
41
+ log: {
42
+ at: number;
43
+ actor: string;
44
+ entry: string;
45
+ }[];
46
+ }
47
+ export interface RemotePerson {
48
+ id: string;
49
+ handle: string;
50
+ email: string;
51
+ role: "owner" | "member";
52
+ }
53
+ export declare const remoteBoardRoutes: (import("./router.js").Route<"remoteBoards.create", import("./router.js").Reply<{
54
+ board: RemoteBoardSummary;
55
+ }>, "/api/remote-boards", z.ZodObject<{
56
+ title: z.ZodOptional<z.ZodString>;
57
+ slug: z.ZodOptional<z.ZodString>;
58
+ columns: z.ZodOptional<z.ZodArray<z.ZodObject<{
59
+ slug: z.ZodOptional<z.ZodString>;
60
+ title: z.ZodString;
61
+ }, z.core.$strip>>>;
62
+ }, z.core.$strip>> | import("./router.js").Route<"remoteBoards.delete", {
63
+ ok: true;
64
+ }, "/api/remote-boards/:board", undefined> | import("./router.js").Route<"remoteBoards.get", {
65
+ board: RemoteBoardSummary;
66
+ tasks: RemoteTaskSummary[];
67
+ people: RemotePerson[];
68
+ actor: string;
69
+ }, "/api/remote-boards/:board", undefined> | import("./router.js").Route<"remoteBoards.list", {
70
+ boards: RemoteBoardSummary[];
71
+ role: "owner" | "member";
72
+ actor: string;
73
+ cloudUrl: string | null;
74
+ }, "/api/remote-boards", undefined> | import("./router.js").Route<"remoteBoards.people", {
75
+ people: RemotePerson[];
76
+ actor: string;
77
+ role: "owner" | "member";
78
+ }, "/api/remote-boards/people", undefined> | import("./router.js").Route<"remoteBoards.save", {
79
+ board: RemoteBoardSummary;
80
+ }, "/api/remote-boards/:board", z.ZodObject<{
81
+ title: z.ZodOptional<z.ZodString>;
82
+ slug: z.ZodOptional<z.ZodString>;
83
+ columns: z.ZodOptional<z.ZodArray<z.ZodObject<{
84
+ slug: z.ZodOptional<z.ZodString>;
85
+ title: z.ZodString;
86
+ }, z.core.$strip>>>;
87
+ }, z.core.$strip>> | import("./router.js").Route<"remoteTasks.create", import("./router.js").Reply<{
88
+ task: RemoteTaskDetail;
89
+ }>, "/api/remote-boards/:board/tasks", z.ZodObject<{
90
+ title: z.ZodOptional<z.ZodString>;
91
+ status: z.ZodOptional<z.ZodString>;
92
+ position: z.ZodOptional<z.ZodNumber>;
93
+ assignee: z.ZodOptional<z.ZodNullable<z.ZodString>>;
94
+ due: z.ZodOptional<z.ZodNullable<z.ZodString>>;
95
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
96
+ notes: z.ZodOptional<z.ZodString>;
97
+ actor: z.ZodOptional<z.ZodString>;
98
+ }, z.core.$strip>> | import("./router.js").Route<"remoteTasks.delete", {
99
+ ok: true;
100
+ }, "/api/remote-boards/:board/tasks/:task", undefined> | import("./router.js").Route<"remoteTasks.get", {
101
+ task: RemoteTaskDetail;
102
+ }, "/api/remote-boards/:board/tasks/:task", undefined> | import("./router.js").Route<"remoteTasks.log", {
103
+ task: RemoteTaskDetail;
104
+ }, "/api/remote-boards/:board/tasks/:task/log", z.ZodObject<{
105
+ entry: z.ZodString;
106
+ actor: z.ZodOptional<z.ZodString>;
107
+ }, z.core.$strip>> | import("./router.js").Route<"remoteTasks.save", {
108
+ task: RemoteTaskDetail;
109
+ }, "/api/remote-boards/:board/tasks/:task", z.ZodObject<{
110
+ title: z.ZodOptional<z.ZodString>;
111
+ status: z.ZodOptional<z.ZodString>;
112
+ position: z.ZodOptional<z.ZodNumber>;
113
+ assignee: z.ZodOptional<z.ZodNullable<z.ZodString>>;
114
+ due: z.ZodOptional<z.ZodNullable<z.ZodString>>;
115
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
116
+ notes: z.ZodOptional<z.ZodString>;
117
+ actor: z.ZodOptional<z.ZodString>;
118
+ }, z.core.$strip>>)[];
@@ -0,0 +1,51 @@
1
+ import * as z from "zod";
2
+ import { remoteCall, remoteWorkspaceUrl } from "../remote-boards.js";
3
+ import { reply, route } from "./router.js";
4
+ const BoardFields = z.object({
5
+ title: z.string().optional(),
6
+ slug: z.string().optional(),
7
+ columns: z.array(z.object({ slug: z.string().optional(), title: z.string() })).optional(),
8
+ });
9
+ const TaskFields = z.object({
10
+ title: z.string().optional(),
11
+ status: z.string().optional(),
12
+ position: z.number().optional(),
13
+ assignee: z.string().nullable().optional(),
14
+ due: z.string().nullable().optional(),
15
+ tags: z.array(z.string()).optional(),
16
+ notes: z.string().optional(),
17
+ /** An agent or process naming itself; a person is whoever asks. */
18
+ actor: z.string().optional(),
19
+ });
20
+ const board = (c) => `boards/${encodeURIComponent(c.params.board)}`;
21
+ const task = (c) => `${board(c)}/tasks/${encodeURIComponent(c.params.task)}`;
22
+ const actorOf = (c) => c.query.get("actor") ?? undefined;
23
+ const withoutActor = (b) => {
24
+ const { actor: _a, ...rest } = b;
25
+ return rest;
26
+ };
27
+ export const remoteBoardRoutes = [
28
+ route({ name: "remoteBoards.list", method: "GET", path: "/api/remote-boards", summary: "the workspace's remote boards in kraftwerk cloud (503 offline: true while unreachable)" }, async (c) => {
29
+ const r = await remoteCall(c.trust, { method: "GET", path: "boards", actor: actorOf(c) });
30
+ return { ...r, cloudUrl: await remoteWorkspaceUrl() };
31
+ }),
32
+ route({ name: "remoteBoards.create", method: "POST", path: "/api/remote-boards", summary: "create a remote board {title, slug?, columns?}", body: BoardFields }, async (c) => reply(201, await remoteCall(c.trust, { method: "POST", path: "boards", body: await c.body() }))),
33
+ route({ name: "remoteBoards.people", method: "GET", path: "/api/remote-boards/people", summary: "the people of the workspace (assignable as human:<handle>) and who you are there" }, async (c) => remoteCall(c.trust, { method: "GET", path: "people", actor: actorOf(c) })),
34
+ route({ name: "remoteBoards.get", method: "GET", path: "/api/remote-boards/:board", summary: "a remote board: columns, counts, every task, the people" }, async (c) => remoteCall(c.trust, { method: "GET", path: board(c), actor: actorOf(c) })),
35
+ route({ name: "remoteBoards.save", method: "PUT", path: "/api/remote-boards/:board", summary: "rename a remote board or change its columns", body: BoardFields }, async (c) => remoteCall(c.trust, { method: "PUT", path: board(c), body: await c.body() })),
36
+ route({ name: "remoteBoards.delete", method: "DELETE", path: "/api/remote-boards/:board", summary: "delete a remote board with its tasks (owners only; no trash)" }, async (c) => remoteCall(c.trust, { method: "DELETE", path: board(c) })),
37
+ route({ name: "remoteTasks.create", method: "POST", path: "/api/remote-boards/:board/tasks", summary: "create a task {title, status?, assignee?, due?, tags?, notes?, actor?}", body: TaskFields }, async (c) => {
38
+ const b = await c.body();
39
+ return reply(201, await remoteCall(c.trust, { method: "POST", path: `${board(c)}/tasks`, body: withoutActor(b), actor: b.actor }));
40
+ }),
41
+ route({ name: "remoteTasks.get", method: "GET", path: "/api/remote-boards/:board/tasks/:task", summary: "a remote task with notes and its log (:task = number)" }, async (c) => remoteCall(c.trust, { method: "GET", path: task(c), actor: actorOf(c) })),
42
+ route({ name: "remoteTasks.save", method: "PUT", path: "/api/remote-boards/:board/tasks/:task", summary: "change a remote task (status, assignee, …); every change is logged with its actor", body: TaskFields }, async (c) => {
43
+ const b = await c.body();
44
+ return remoteCall(c.trust, { method: "PUT", path: task(c), body: withoutActor(b), actor: b.actor });
45
+ }),
46
+ route({ name: "remoteTasks.log", method: "POST", path: "/api/remote-boards/:board/tasks/:task/log", summary: "add a line to a remote task's log {entry, actor?}", body: z.object({ entry: z.string(), actor: z.string().optional() }) }, async (c) => {
47
+ const b = await c.body();
48
+ return remoteCall(c.trust, { method: "POST", path: `${task(c)}/log`, body: { entry: b.entry }, actor: b.actor });
49
+ }),
50
+ route({ name: "remoteTasks.delete", method: "DELETE", path: "/api/remote-boards/:board/tasks/:task", summary: "delete a remote task (no trash)" }, async (c) => remoteCall(c.trust, { method: "DELETE", path: task(c) })),
51
+ ];
@@ -0,0 +1,79 @@
1
+ import type { RemotePerson } from "./api/remote-boards.js";
2
+ import type { BoardDetail, BoardSummary, ListedTask, TaskDetail } from "../core/boards.js";
3
+ import type { Trust } from "./trust.js";
4
+ /**
5
+ * Cloud boards in the shape of local boards. The boards API (api/boards.ts)
6
+ * serves a cloud board wherever it serves a local one, so every view —
7
+ * home, the boards page, a board, a task beside its chat, the context
8
+ * column — shows and edits it the same way. A cloud board's slug is its
9
+ * cloud slug behind "@" (`@launch-plan`), which no local board can have
10
+ * (SLUG_RE); a task is addressed by its number; refs read `@launch-plan/3`.
11
+ *
12
+ * What a cloud board has not: files in a task folder, a default agent,
13
+ * rules (board.md's body), links to projects, waking an assigned agent.
14
+ * Its "done" and "review" columns are the columns with those slugs.
15
+ */
16
+ export declare const CLOUD_PREFIX = "@";
17
+ export declare const isCloudBoard: (board: string | undefined) => boolean;
18
+ export interface CloudMark {
19
+ /** Kept in kraftwerk cloud, shared with everyone on the workspace. */
20
+ cloud?: true;
21
+ }
22
+ export interface CloudList {
23
+ boards: (BoardSummary & CloudMark)[];
24
+ /** Why there are none to show: offline (the cloud off or not answering), or not set up for this workspace. */
25
+ error?: string;
26
+ offline?: boolean;
27
+ /** This workspace in the cloud's web app. */
28
+ url?: string | null;
29
+ }
30
+ /** The cloud boards beside the local ones; never throws — offline is reported, not raised. */
31
+ export declare function listCloudBoards(trust: Trust): Promise<CloudList>;
32
+ /** Every task of every cloud board, as tasks.list lists them; [] while offline. */
33
+ export declare function listCloudTasks(trust: Trust, boards?: CloudList): Promise<ListedTask[]>;
34
+ export declare function getCloudBoard(trust: Trust, board: string): Promise<BoardDetail & CloudMark & {
35
+ people: RemotePerson[];
36
+ actor: string;
37
+ }>;
38
+ export declare function getCloudTask(trust: Trust, board: string, t: string): Promise<TaskDetail & CloudMark>;
39
+ export declare function createCloudBoard(trust: Trust, input: {
40
+ title: string;
41
+ slug?: string;
42
+ columns?: unknown;
43
+ }): Promise<BoardSummary & CloudMark>;
44
+ export declare function saveCloudBoard(trust: Trust, board: string, input: {
45
+ title?: string;
46
+ columns?: unknown;
47
+ }): Promise<BoardSummary & CloudMark>;
48
+ export declare function deleteCloudBoard(trust: Trust, board: string): Promise<void>;
49
+ export interface CloudTaskInput {
50
+ title?: string;
51
+ status?: string;
52
+ order?: number;
53
+ assignee?: string | null;
54
+ due?: string | null;
55
+ tags?: unknown;
56
+ notes?: string;
57
+ actor?: string;
58
+ message?: string;
59
+ }
60
+ export declare function createCloudTask(trust: Trust, board: string, input: CloudTaskInput & {
61
+ title: string;
62
+ }): Promise<TaskDetail & CloudMark>;
63
+ export declare function saveCloudTask(trust: Trust, board: string, t: string, input: CloudTaskInput): Promise<TaskDetail & CloudMark>;
64
+ /** Into a column, above `before` (a task's number or slug) or at `order`; at the end otherwise. */
65
+ export declare function moveCloudTask(trust: Trust, board: string, t: string, status: string, opts: {
66
+ before?: string;
67
+ order?: number;
68
+ message?: string;
69
+ actor?: string;
70
+ }): Promise<TaskDetail & CloudMark>;
71
+ /** Give the task to an agent or a person; null or "human" hands it back to the review column, as on a local board. */
72
+ export declare function assignCloudTask(trust: Trust, board: string, t: string, to: string | null, opts: {
73
+ message?: string;
74
+ actor?: string;
75
+ }): Promise<TaskDetail & CloudMark>;
76
+ export declare function logCloudTask(trust: Trust, board: string, t: string, entry: string, actor?: string): Promise<TaskDetail & CloudMark>;
77
+ export declare function deleteCloudTask(trust: Trust, board: string, t: string): Promise<void>;
78
+ /** An agent takes the next unassigned task of the pick column (todo, else the second), as on a local board. */
79
+ export declare function pickCloudTask(trust: Trust, board: string, agent: string, column?: string): Promise<(TaskDetail & CloudMark) | null>;
@@ -0,0 +1,200 @@
1
+ import { ApiError } from "./api/router.js";
2
+ import { remoteCall } from "./remote-boards.js";
3
+ /**
4
+ * Cloud boards in the shape of local boards. The boards API (api/boards.ts)
5
+ * serves a cloud board wherever it serves a local one, so every view —
6
+ * home, the boards page, a board, a task beside its chat, the context
7
+ * column — shows and edits it the same way. A cloud board's slug is its
8
+ * cloud slug behind "@" (`@launch-plan`), which no local board can have
9
+ * (SLUG_RE); a task is addressed by its number; refs read `@launch-plan/3`.
10
+ *
11
+ * What a cloud board has not: files in a task folder, a default agent,
12
+ * rules (board.md's body), links to projects, waking an assigned agent.
13
+ * Its "done" and "review" columns are the columns with those slugs.
14
+ */
15
+ export const CLOUD_PREFIX = "@";
16
+ export const isCloudBoard = (board) => !!board && board.startsWith(CLOUD_PREFIX);
17
+ const slugOf = (board) => encodeURIComponent(board.slice(CLOUD_PREFIX.length));
18
+ const boardOf = (slug) => `${CLOUD_PREFIX}${slug}`;
19
+ const iso = (ms) => new Date(ms).toISOString();
20
+ /** The number in "3", "3-book-the-venue". */
21
+ function numberOf(task) {
22
+ const m = /^(\d+)/.exec(task);
23
+ if (!m)
24
+ throw new ApiError(404, `no task "${task}"`);
25
+ return m[1];
26
+ }
27
+ const taskSlug = (t) => {
28
+ const s = t.title.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40);
29
+ return s ? `${t.number}-${s}` : String(t.number);
30
+ };
31
+ const columnsOf = (b) => b.columns.map((c) => ({ slug: c.slug, label: c.title, ...(c.slug === "done" ? { done: true } : {}), ...(c.slug === "review" ? { review: true } : {}) }));
32
+ function summary(b) {
33
+ return {
34
+ board: boardOf(b.slug),
35
+ title: b.title,
36
+ columns: columnsOf(b),
37
+ path: "",
38
+ updatedAt: iso(b.updatedAt),
39
+ counts: b.counts,
40
+ tasks: b.taskCount,
41
+ review: b.counts.review ?? 0,
42
+ cloud: true,
43
+ };
44
+ }
45
+ function task(board, t) {
46
+ return {
47
+ slug: taskSlug(t),
48
+ number: t.number,
49
+ title: t.title,
50
+ status: t.status,
51
+ order: t.position,
52
+ ...(t.assignee ? { assignee: t.assignee } : {}),
53
+ ...(t.due ? { due: t.due } : {}),
54
+ created: iso(t.createdAt).slice(0, 10),
55
+ tags: t.tags,
56
+ refs: [],
57
+ ref: `${board}/${t.number}`,
58
+ path: "",
59
+ updatedAt: iso(t.updatedAt),
60
+ files: 0,
61
+ ...(t.last ? { lastLog: t.last } : {}),
62
+ cloud: true,
63
+ };
64
+ }
65
+ /** The log as log.md writes it: newest day first, "* HH:MM entry (actor)". */
66
+ function logMd(title, log) {
67
+ const lines = [`# ${title} — log`, ""];
68
+ let day = "";
69
+ for (const l of [...log].reverse()) {
70
+ const d = new Date(l.at);
71
+ const date = `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
72
+ if (date !== day) {
73
+ if (day)
74
+ lines.push("");
75
+ lines.push(`## ${date}`);
76
+ day = date;
77
+ }
78
+ lines.push(`* ${String(d.getHours()).padStart(2, "0")}:${String(d.getMinutes()).padStart(2, "0")} ${l.entry.replace(/\n/g, " ")} (${l.actor})`);
79
+ }
80
+ return `${lines.join("\n")}\n`;
81
+ }
82
+ function detail(board, t) {
83
+ return { ...task(board, t), notes: t.notes, log: logMd(t.title, t.log), fileList: [], board };
84
+ }
85
+ /** The cloud boards beside the local ones; never throws — offline is reported, not raised. */
86
+ export async function listCloudBoards(trust) {
87
+ try {
88
+ const r = await remoteCall(trust, { method: "GET", path: "boards" });
89
+ return { boards: r.boards.map(summary) };
90
+ }
91
+ catch (err) {
92
+ const e = err;
93
+ const body = (e.body ?? {});
94
+ return { boards: [], error: e.message, ...(body.offline ? { offline: true } : {}) };
95
+ }
96
+ }
97
+ /** Every task of every cloud board, as tasks.list lists them; [] while offline. */
98
+ export async function listCloudTasks(trust, boards) {
99
+ const list = boards ?? (await listCloudBoards(trust));
100
+ const out = [];
101
+ await Promise.all(list.boards.map(async (b) => {
102
+ const d = await getCloudBoard(trust, b.board).catch(() => null);
103
+ for (const t of d?.items ?? []) {
104
+ const column = b.columns.find((c) => c.slug === t.status)?.label;
105
+ out.push({ ...t, board: b.board, boardTitle: b.title, ...(column ? { column } : {}) });
106
+ }
107
+ }));
108
+ return out;
109
+ }
110
+ export async function getCloudBoard(trust, board) {
111
+ const r = await remoteCall(trust, { method: "GET", path: `boards/${slugOf(board)}` });
112
+ return { ...summary(r.board), notes: "", items: r.tasks.map((t) => task(board, t)), people: r.people, actor: r.actor };
113
+ }
114
+ export async function getCloudTask(trust, board, t) {
115
+ const r = await remoteCall(trust, { method: "GET", path: `boards/${slugOf(board)}/tasks/${numberOf(t)}` });
116
+ return detail(board, r.task);
117
+ }
118
+ /* ---------- writes ---------- */
119
+ export async function createCloudBoard(trust, input) {
120
+ const columns = Array.isArray(input.columns) ? input.columns.map((c) => (typeof c === "string" ? { title: c } : { slug: c.slug, title: c.label ?? c.slug })) : undefined;
121
+ const r = await remoteCall(trust, { method: "POST", path: "boards", body: { title: input.title, ...(input.slug ? { slug: input.slug } : {}), ...(columns ? { columns } : {}) } });
122
+ return summary(r.board);
123
+ }
124
+ export async function saveCloudBoard(trust, board, input) {
125
+ const columns = Array.isArray(input.columns)
126
+ ? input.columns.map((c) => (typeof c === "string" ? { slug: c, title: c } : { slug: c.slug, title: c.label ?? c.slug }))
127
+ : undefined;
128
+ const r = await remoteCall(trust, { method: "PUT", path: `boards/${slugOf(board)}`, body: { ...(input.title !== undefined ? { title: input.title } : {}), ...(columns ? { columns } : {}) } });
129
+ return summary(r.board);
130
+ }
131
+ export async function deleteCloudBoard(trust, board) {
132
+ await remoteCall(trust, { method: "DELETE", path: `boards/${slugOf(board)}` });
133
+ }
134
+ const fieldsOf = (i) => ({
135
+ ...(i.title !== undefined ? { title: i.title } : {}),
136
+ ...(i.status !== undefined ? { status: i.status } : {}),
137
+ ...(i.order !== undefined ? { position: i.order } : {}),
138
+ ...(i.assignee !== undefined ? { assignee: i.assignee } : {}),
139
+ ...(i.due !== undefined ? { due: i.due } : {}),
140
+ ...(i.tags !== undefined ? { tags: i.tags } : {}),
141
+ ...(i.notes !== undefined ? { notes: i.notes } : {}),
142
+ });
143
+ /** A line the caller asked for beside its change (`message`), signed like the change. */
144
+ async function withMessage(trust, board, n, message, actor) {
145
+ if (message?.trim())
146
+ await remoteCall(trust, { method: "POST", path: `boards/${slugOf(board)}/tasks/${n}/log`, body: { entry: message.trim() }, actor });
147
+ }
148
+ export async function createCloudTask(trust, board, input) {
149
+ const r = await remoteCall(trust, { method: "POST", path: `boards/${slugOf(board)}/tasks`, body: fieldsOf(input), actor: input.actor });
150
+ if (input.message?.trim())
151
+ return logCloudTask(trust, board, String(r.task.number), input.message, input.actor);
152
+ return detail(board, r.task);
153
+ }
154
+ export async function saveCloudTask(trust, board, t, input) {
155
+ const n = numberOf(t);
156
+ const r = await remoteCall(trust, { method: "PUT", path: `boards/${slugOf(board)}/tasks/${n}`, body: fieldsOf(input), actor: input.actor });
157
+ if (input.message?.trim()) {
158
+ await withMessage(trust, board, r.task.number, input.message, input.actor);
159
+ return getCloudTask(trust, board, n);
160
+ }
161
+ return detail(board, r.task);
162
+ }
163
+ /** Into a column, above `before` (a task's number or slug) or at `order`; at the end otherwise. */
164
+ export async function moveCloudTask(trust, board, t, status, opts) {
165
+ let order = opts.order;
166
+ if (order === undefined && opts.before) {
167
+ const b = await getCloudBoard(trust, board);
168
+ const lane = b.items.filter((x) => x.status === status).sort((x, y) => x.order - y.order);
169
+ const i = lane.findIndex((x) => String(x.number) === numberOf(opts.before));
170
+ if (i >= 0)
171
+ order = i === 0 ? lane[0].order - 1 : (lane[i - 1].order + lane[i].order) / 2;
172
+ }
173
+ return saveCloudTask(trust, board, t, { status, ...(order !== undefined ? { order } : {}), message: opts.message, actor: opts.actor });
174
+ }
175
+ /** Give the task to an agent or a person; null or "human" hands it back to the review column, as on a local board. */
176
+ export async function assignCloudTask(trust, board, t, to, opts) {
177
+ if (to === null || to === "human") {
178
+ const b = await getCloudBoard(trust, board);
179
+ const review = b.columns.find((c) => c.review);
180
+ return saveCloudTask(trust, board, t, { assignee: null, ...(review ? { status: review.slug } : {}), ...opts });
181
+ }
182
+ return saveCloudTask(trust, board, t, { assignee: to, ...opts });
183
+ }
184
+ export async function logCloudTask(trust, board, t, entry, actor) {
185
+ const r = await remoteCall(trust, { method: "POST", path: `boards/${slugOf(board)}/tasks/${numberOf(t)}/log`, body: { entry }, actor });
186
+ return detail(board, r.task);
187
+ }
188
+ export async function deleteCloudTask(trust, board, t) {
189
+ await remoteCall(trust, { method: "DELETE", path: `boards/${slugOf(board)}/tasks/${numberOf(t)}` });
190
+ }
191
+ /** An agent takes the next unassigned task of the pick column (todo, else the second), as on a local board. */
192
+ export async function pickCloudTask(trust, board, agent, column) {
193
+ const b = await getCloudBoard(trust, board);
194
+ const col = column ?? (b.columns.find((c) => c.slug === "todo") ?? b.columns[1] ?? b.columns[0])?.slug;
195
+ const next = b.items.filter((x) => x.status === col && !x.assignee).sort((x, y) => x.order - y.order || x.number - y.number)[0];
196
+ if (!next)
197
+ return null;
198
+ const work = b.columns.find((c) => c.slug === "doing" || c.slug === "progress");
199
+ return saveCloudTask(trust, board, String(next.number), { assignee: agent, ...(work ? { status: work.slug } : {}), actor: agent });
200
+ }
@@ -0,0 +1,37 @@
1
+ import type { Trust } from "./trust.js";
2
+ /**
3
+ * Remote boards — a workspace's boards kept in kraftwerk cloud (the cloud's
4
+ * boards.ts), multiplayer, beside the local boards (core/boards.ts, files in
5
+ * the repo, single player). They never sync with each other.
6
+ *
7
+ * The daemon is the way there from this machine's UI, CLI and agents: it
8
+ * calls the cloud with the machine's id + secret and says who it acts for —
9
+ *
10
+ * a browser signed in with its cloud account (users: cloud) → that person
11
+ * everyone else on this machine (its shell, a paired device,
12
+ * a users: local workspace) → the account that claimed the machine
13
+ * a remote member through the relay → refused: they use the cloud's own UI
14
+ *
15
+ * — and an agent or process naming itself (`actor`) is passed on as such;
16
+ * the cloud never takes a human actor from a machine. The cloud allows a
17
+ * machine to act only for its account and the people who signed in to it.
18
+ *
19
+ * Offline is offline: no cache. With the machine not connected (cloud off,
20
+ * not claimed, the workspace without a ws_ id) or the cloud not answering,
21
+ * calls fail 503 with `offline: true` and the UI marks remote boards offline.
22
+ */
23
+ export interface RemoteCall {
24
+ method: "GET" | "POST" | "PUT" | "DELETE";
25
+ /** After /api/workspaces/<ws>/, e.g. "boards/launch/tasks/3". */
26
+ path: string;
27
+ body?: unknown;
28
+ /** An agent or process naming itself (lisa/claude, process:sync); a human actor is ignored. */
29
+ actor?: string;
30
+ }
31
+ /** The ws_ id of the workspace this request is in; 409 without one (`kraftwerk doctor --fix` writes it). */
32
+ export declare function remoteWorkspaceId(): Promise<string>;
33
+ export declare function remoteCall<T>(trust: Trust, call: RemoteCall): Promise<T>;
34
+ /** The cloud's address for this workspace's page, for "open in cloud" links. */
35
+ /** Forget that the cloud was down (tests; `kraftwerk cloud sync`). */
36
+ export declare const resetRemoteDown: () => void;
37
+ export declare function remoteWorkspaceUrl(): Promise<string | null>;