@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.
- package/README.md +52 -0
- package/dist/cli/boards.js +6 -5
- package/dist/cli/init.js +2 -0
- package/dist/cli/knowledge.js +9 -6
- package/dist/cli/presentations.js +8 -4
- package/dist/cli/projects.js +1 -1
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +3 -0
- package/dist/client/routes.d.ts +12 -0
- package/dist/client/routes.js +12 -0
- package/dist/config.d.ts +34 -0
- package/dist/config.js +28 -1
- package/dist/core/boards.d.ts +3 -1
- package/dist/core/boards.js +32 -9
- package/dist/core/chat/sessions.d.ts +3 -3
- package/dist/core/chat/sessions.js +6 -5
- package/dist/core/chat/types.d.ts +2 -0
- package/dist/core/cloud.d.ts +45 -0
- package/dist/core/cloud.js +35 -0
- package/dist/core/knowledge.d.ts +0 -7
- package/dist/core/knowledge.js +6 -6
- package/dist/core/person.d.ts +41 -0
- package/dist/core/person.js +47 -0
- package/dist/core/projects.d.ts +1 -1
- package/dist/core/projects.js +3 -2
- package/dist/server/api/agents.js +2 -2
- package/dist/server/api/boards.js +1 -1
- package/dist/server/api/chats.js +11 -7
- package/dist/server/api/cloud.d.ts +8 -0
- package/dist/server/api/index.d.ts +86 -2
- package/dist/server/api/index.js +2 -0
- package/dist/server/api/presentations.js +2 -2
- package/dist/server/api/projects.d.ts +1 -1
- package/dist/server/api/projects.js +1 -1
- package/dist/server/api/remote-boards.d.ts +118 -0
- package/dist/server/api/remote-boards.js +51 -0
- package/dist/server/api/router.js +5 -2
- package/dist/server/api/workspace.d.ts +14 -1
- package/dist/server/api/workspace.js +21 -1
- package/dist/server/cloud.d.ts +3 -0
- package/dist/server/cloud.js +20 -4
- package/dist/server/person.d.ts +9 -0
- package/dist/server/person.js +14 -0
- package/dist/server/remote-boards.d.ts +35 -0
- package/dist/server/remote-boards.js +73 -0
- package/dist/server/server.js +60 -4
- package/dist/server/trust.d.ts +5 -1
- package/dist/server/users.d.ts +55 -0
- package/dist/server/users.js +258 -0
- package/package.json +1 -1
- package/schema/kraftwerk.schema.json +8 -0
- package/web/dist/assets/{dist-DkDmdJNX.js → dist-BKTdKbao.js} +1 -1
- package/web/dist/assets/{dist-DOW1X_nG.js → dist-BNpBR7sT.js} +1 -1
- package/web/dist/assets/dist-BRk23y92.js +1 -0
- package/web/dist/assets/{dist-DbBrc07-.js → dist-C83QYgqx.js} +1 -1
- package/web/dist/assets/{dist-14HFV7uD.js → dist-CJK_j1TB.js} +1 -1
- package/web/dist/assets/{dist-wkkpVezb.js → dist-CR_7NDsL.js} +1 -1
- package/web/dist/assets/{dist-DKQkCBo9.js → dist-ChYhEmdo.js} +1 -1
- package/web/dist/assets/{dist-DO04nOS3.js → dist-D-MsPdYw.js} +1 -1
- package/web/dist/assets/{dist-BYgXVWBg.js → dist-DxlgW6a_.js} +1 -1
- package/web/dist/assets/{dist-qkoQQWNK.js → dist-OpHqdZBt.js} +1 -1
- package/web/dist/assets/{dist-BiyjchCb.js → dist-gtc4RPDu.js} +1 -1
- package/web/dist/assets/{editor-DvkpSp7h.js → editor-RdZyT8Y9.js} +3 -3
- package/web/dist/assets/index-BGgQaaA9.css +2 -0
- package/web/dist/assets/index-J1hXaKgp.js +488 -0
- package/web/dist/index.html +2 -2
- package/web/dist/assets/dist-CCZcAg77.js +0 -1
- package/web/dist/assets/index-B5PLhJ-C.js +0 -488
- package/web/dist/assets/index-CWopPK15.css +0 -2
package/dist/core/cloud.d.ts
CHANGED
|
@@ -35,6 +35,13 @@
|
|
|
35
35
|
* — the routines that ran here, private ones left out, at most 500; only
|
|
36
36
|
* while claimed, and only when it changed since the cloud last took it.
|
|
37
37
|
*
|
|
38
|
+
* Signing in to a workspace's own UI (kraftwerk.yml `users: cloud`, server/users.ts):
|
|
39
|
+
*
|
|
40
|
+
* browser → <cloud>/signin?workspace=ws_…&machine=<id>&redirect=http://<slug>.localhost:<port>/auth/callback&state=…
|
|
41
|
+
* /api/signin/exchange {id, secret, code, redirect} → {user: {id, email, handle}, workspaceId, role}
|
|
42
|
+
* (404 unknown code, 410 used or expired, 403 no longer a member)
|
|
43
|
+
* /api/signin/verify {id, secret, workspace, user} → {user, role} (404: not a member any more)
|
|
44
|
+
*
|
|
38
45
|
* Membership (remote members, no clone — they reach a workspace through the
|
|
39
46
|
* relay with a workspace-scoped member token, see server/members.ts):
|
|
40
47
|
*
|
|
@@ -72,13 +79,29 @@ export interface RegisterResponse {
|
|
|
72
79
|
interval: number;
|
|
73
80
|
claimCode: string | null;
|
|
74
81
|
account: string | null;
|
|
82
|
+
/** The claiming account's uuid and handle (clouds before 0.97 send neither). */
|
|
83
|
+
accountId?: string | null;
|
|
84
|
+
accountHandle?: string | null;
|
|
75
85
|
}
|
|
76
86
|
export interface HeartbeatResponse {
|
|
77
87
|
ok: boolean;
|
|
78
88
|
interval: number;
|
|
79
89
|
account: string | null;
|
|
90
|
+
accountId?: string | null;
|
|
91
|
+
accountHandle?: string | null;
|
|
80
92
|
claimCode: string | null;
|
|
81
93
|
}
|
|
94
|
+
/** A person the cloud vouches for: the account's uuid (the same on every machine), email and handle. */
|
|
95
|
+
export interface CloudUser {
|
|
96
|
+
id: string;
|
|
97
|
+
email: string;
|
|
98
|
+
handle: string;
|
|
99
|
+
}
|
|
100
|
+
export interface SigninExchange {
|
|
101
|
+
user: CloudUser;
|
|
102
|
+
workspaceId: string;
|
|
103
|
+
role: "owner" | "member";
|
|
104
|
+
}
|
|
82
105
|
/** What the cloud vouches for about a member token in one workspace. */
|
|
83
106
|
export interface MemberVerdict {
|
|
84
107
|
email: string;
|
|
@@ -150,3 +173,25 @@ export declare const machineGoodbye: (base: string, creds: Credentials, version?
|
|
|
150
173
|
export declare const machineUnlink: (base: string, creds: Credentials, version?: string) => Promise<UnlinkResponse>;
|
|
151
174
|
export declare const memberVerify: (base: string, creds: Credentials, token: string, workspaceId: string, version?: string) => Promise<MemberVerdict>;
|
|
152
175
|
export declare const workspaceInvite: (base: string, creds: Credentials, workspaceId: string, role?: "owner" | "member", version?: string) => Promise<InviteResponse>;
|
|
176
|
+
export declare const signinExchange: (base: string, creds: Credentials, code: string, redirect: string, version?: string) => Promise<SigninExchange>;
|
|
177
|
+
export declare const signinVerify: (base: string, creds: Credentials, workspace: string, user: string, version?: string) => Promise<{
|
|
178
|
+
user: CloudUser;
|
|
179
|
+
role: "owner" | "member";
|
|
180
|
+
}>;
|
|
181
|
+
/** Where the browser goes to sign in to workspace `workspaceId` served by machine `machineId`. */
|
|
182
|
+
export declare function signinUrl(base: string, q: {
|
|
183
|
+
workspace: string;
|
|
184
|
+
machine: string;
|
|
185
|
+
redirect: string;
|
|
186
|
+
state: string;
|
|
187
|
+
}): string;
|
|
188
|
+
/**
|
|
189
|
+
* ~/.kraftwerk/account.json — the account that claimed this machine
|
|
190
|
+
* ({id, email, handle}), written by the daemon when the cloud names it and
|
|
191
|
+
* removed when the claim ends. The machine's own shell (the CLI) acts as
|
|
192
|
+
* this person in a `users: cloud` workspace.
|
|
193
|
+
*/
|
|
194
|
+
export declare const accountFilePath: () => string;
|
|
195
|
+
export declare function readAccountFile(): Promise<CloudUser | null>;
|
|
196
|
+
/** Write (or with null remove) account.json; unchanged content is not rewritten. */
|
|
197
|
+
export declare function writeAccountFile(user: CloudUser | null): Promise<void>;
|
package/dist/core/cloud.js
CHANGED
|
@@ -96,3 +96,38 @@ export const machineGoodbye = (base, creds, version) => cloudPost(base, "/api/ma
|
|
|
96
96
|
export const machineUnlink = (base, creds, version) => cloudPost(base, "/api/machines/unlink", { id: creds.id, secret: creds.secret }, { version });
|
|
97
97
|
export const memberVerify = (base, creds, token, workspaceId, version) => cloudPost(base, "/api/members/verify", { id: creds.id, secret: creds.secret, token, workspaceId }, { version });
|
|
98
98
|
export const workspaceInvite = (base, creds, workspaceId, role, version) => cloudPost(base, `/api/workspaces/${encodeURIComponent(workspaceId)}/invites`, { id: creds.id, secret: creds.secret, ...(role ? { role } : {}) }, { version });
|
|
99
|
+
export const signinExchange = (base, creds, code, redirect, version) => cloudPost(base, "/api/signin/exchange", { id: creds.id, secret: creds.secret, code, redirect }, { version });
|
|
100
|
+
export const signinVerify = (base, creds, workspace, user, version) => cloudPost(base, "/api/signin/verify", { id: creds.id, secret: creds.secret, workspace, user }, { version });
|
|
101
|
+
/** Where the browser goes to sign in to workspace `workspaceId` served by machine `machineId`. */
|
|
102
|
+
export function signinUrl(base, q) {
|
|
103
|
+
return `${base}/signin?${new URLSearchParams(q)}`;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* ~/.kraftwerk/account.json — the account that claimed this machine
|
|
107
|
+
* ({id, email, handle}), written by the daemon when the cloud names it and
|
|
108
|
+
* removed when the claim ends. The machine's own shell (the CLI) acts as
|
|
109
|
+
* this person in a `users: cloud` workspace.
|
|
110
|
+
*/
|
|
111
|
+
export const accountFilePath = () => path.join(kwHome(), "account.json");
|
|
112
|
+
export async function readAccountFile() {
|
|
113
|
+
try {
|
|
114
|
+
const raw = JSON.parse(await fs.readFile(accountFilePath(), "utf8"));
|
|
115
|
+
return typeof raw.id === "string" && typeof raw.email === "string" && typeof raw.handle === "string" ? { id: raw.id, email: raw.email, handle: raw.handle } : null;
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/** Write (or with null remove) account.json; unchanged content is not rewritten. */
|
|
122
|
+
export async function writeAccountFile(user) {
|
|
123
|
+
const file = accountFilePath();
|
|
124
|
+
if (!user)
|
|
125
|
+
return void (await fs.rm(file, { force: true }).catch(() => { }));
|
|
126
|
+
const next = JSON.stringify({ id: user.id, email: user.email, handle: user.handle }, null, 2) + "\n";
|
|
127
|
+
if ((await fs.readFile(file, "utf8").catch(() => "")) === next)
|
|
128
|
+
return;
|
|
129
|
+
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
130
|
+
const tmp = `${file}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
|
|
131
|
+
await fs.writeFile(tmp, next);
|
|
132
|
+
await fs.rename(tmp, file);
|
|
133
|
+
}
|
package/dist/core/knowledge.d.ts
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { type BundleInfo, type ConceptDetail, type ConceptInfo } from "../okf.js";
|
|
2
|
-
/**
|
|
3
|
-
* Knowledge for the inspector: a thin API layer over the OKF
|
|
4
|
-
* core (src/okf.ts). Writes from the UI are stamped as `human:user` — the
|
|
5
|
-
* browser user is the human in the loop; agents write through the CLI (or
|
|
6
|
-
* chat) with their own actor.
|
|
7
|
-
*/
|
|
8
|
-
export declare const UI_ACTOR = "human:user";
|
|
9
2
|
export interface KnowledgeIndex {
|
|
10
3
|
root: string;
|
|
11
4
|
bundles: BundleInfo[];
|
package/dist/core/knowledge.js
CHANGED
|
@@ -4,13 +4,13 @@ import { resolveWorkspace } from "../config.js";
|
|
|
4
4
|
import { getConcept, initBundle, knowledgeRoot, listBundles, listConcepts, safeBundleName, verifyConcept, writeConcept, } from "../okf.js";
|
|
5
5
|
import { workspaceRoot } from "./context.js";
|
|
6
6
|
import { moveToTrash } from "./trash.js";
|
|
7
|
+
import { actorFor } from "./person.js";
|
|
7
8
|
/**
|
|
8
9
|
* Knowledge for the inspector: a thin API layer over the OKF
|
|
9
|
-
* core (src/okf.ts). Writes from the UI are stamped as
|
|
10
|
-
* browser user is the human in the
|
|
11
|
-
* chat) with their own actor.
|
|
10
|
+
* core (src/okf.ts). Writes from the UI are stamped as the person asking
|
|
11
|
+
* (`human:<handle>`, core/person.ts) — the browser user is the human in the
|
|
12
|
+
* loop; agents write through the CLI (or chat) with their own actor.
|
|
12
13
|
*/
|
|
13
|
-
export const UI_ACTOR = "human:user";
|
|
14
14
|
async function root() {
|
|
15
15
|
const project = await resolveWorkspace(workspaceRoot());
|
|
16
16
|
return knowledgeRoot(project.root, project.config.knowledge);
|
|
@@ -41,8 +41,8 @@ export async function conceptDetail(bundle, id) {
|
|
|
41
41
|
return getConcept(await root(), bundle, id);
|
|
42
42
|
}
|
|
43
43
|
export async function putConcept(bundle, id, content) {
|
|
44
|
-
return (await writeConcept(await root(), bundle, id, content,
|
|
44
|
+
return (await writeConcept(await root(), bundle, id, content, await actorFor())).concept;
|
|
45
45
|
}
|
|
46
46
|
export async function verifyFromUi(bundle, id) {
|
|
47
|
-
return verifyConcept(await root(), bundle, id,
|
|
47
|
+
return verifyConcept(await root(), bundle, id, await actorFor());
|
|
48
48
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who a human change is signed with — the person behind a request, else
|
|
3
|
+
* the machine's own.
|
|
4
|
+
*
|
|
5
|
+
* A person is a handle, and with `users: cloud` (kraftwerk.yml, see
|
|
6
|
+
* UsersConfig) also the cloud account's uuid and email: the same person on
|
|
7
|
+
* every machine and clone. Logs and provenance write `human:<handle>`
|
|
8
|
+
* (readable; the cloud keeps handles unique); chats keep the whole person.
|
|
9
|
+
*
|
|
10
|
+
* The server runs every API call as its caller (`runAs`, router.ts): a
|
|
11
|
+
* signed-in browser, a remote member, this machine. Outside a request —
|
|
12
|
+
* the CLI, a routine — it is the machine's person:
|
|
13
|
+
*
|
|
14
|
+
* users: local the identity handle (~/.kraftwerk/identity.json)
|
|
15
|
+
* users: cloud the account that claimed the machine (~/.kraftwerk/account.json),
|
|
16
|
+
* the identity handle while there is none
|
|
17
|
+
*
|
|
18
|
+
* A `human:` actor is never taken from what a caller of the API says:
|
|
19
|
+
* whoever asks is who it is (`actorFor`). The machine's own shell (the CLI,
|
|
20
|
+
* outside any request) may still name one — it can edit the files anyway.
|
|
21
|
+
* Other actors — `lisa/claude`, `process:sync` — are agents and processes
|
|
22
|
+
* naming themselves, and stand as given.
|
|
23
|
+
*/
|
|
24
|
+
export interface Person {
|
|
25
|
+
handle: string;
|
|
26
|
+
/** The cloud account's uuid (users: cloud, or a remote member's when the cloud says it). */
|
|
27
|
+
id?: string;
|
|
28
|
+
email?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Run `fn` as the person `who` resolves to (resolved once, when first asked). */
|
|
31
|
+
export declare function runAs<T>(who: () => Promise<Person>, fn: () => T): T;
|
|
32
|
+
/** This machine's person: the claiming account in a `users: cloud` workspace, else the identity handle. */
|
|
33
|
+
export declare function machinePerson(): Promise<Person>;
|
|
34
|
+
/** The person the current request runs as, else this machine's. */
|
|
35
|
+
export declare function currentPerson(): Promise<Person>;
|
|
36
|
+
export declare const humanActor: (p: Pick<Person, "handle">) => string;
|
|
37
|
+
/**
|
|
38
|
+
* The actor a change is stamped with: an agent's or a process's own name as
|
|
39
|
+
* given, else the person asking — in a request a given `human:…` too.
|
|
40
|
+
*/
|
|
41
|
+
export declare function actorFor(given?: string): Promise<string>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { resolveWorkspace, usersMode } from "../config.js";
|
|
3
|
+
import { readAccountFile } from "./cloud.js";
|
|
4
|
+
import { workspaceRoot } from "./context.js";
|
|
5
|
+
import { readIdentity } from "./identity.js";
|
|
6
|
+
const storage = new AsyncLocalStorage();
|
|
7
|
+
/** Run `fn` as the person `who` resolves to (resolved once, when first asked). */
|
|
8
|
+
export function runAs(who, fn) {
|
|
9
|
+
let memo;
|
|
10
|
+
return storage.run(() => (memo ??= who()), fn);
|
|
11
|
+
}
|
|
12
|
+
/** This machine's person: the claiming account in a `users: cloud` workspace, else the identity handle. */
|
|
13
|
+
export async function machinePerson() {
|
|
14
|
+
// The CLI runs outside any served workspace: the one around its cwd.
|
|
15
|
+
let root;
|
|
16
|
+
try {
|
|
17
|
+
root = workspaceRoot();
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
root = process.cwd();
|
|
21
|
+
}
|
|
22
|
+
const cloud = await resolveWorkspace(root)
|
|
23
|
+
.then((ws) => usersMode(ws.config) === "cloud")
|
|
24
|
+
.catch(() => false);
|
|
25
|
+
if (cloud) {
|
|
26
|
+
const account = await readAccountFile();
|
|
27
|
+
if (account)
|
|
28
|
+
return { handle: account.handle, id: account.id, email: account.email };
|
|
29
|
+
}
|
|
30
|
+
return { handle: (await readIdentity()).handle };
|
|
31
|
+
}
|
|
32
|
+
/** The person the current request runs as, else this machine's. */
|
|
33
|
+
export async function currentPerson() {
|
|
34
|
+
const who = storage.getStore();
|
|
35
|
+
return who ? who() : machinePerson();
|
|
36
|
+
}
|
|
37
|
+
export const humanActor = (p) => `human:${p.handle}`;
|
|
38
|
+
/**
|
|
39
|
+
* The actor a change is stamped with: an agent's or a process's own name as
|
|
40
|
+
* given, else the person asking — in a request a given `human:…` too.
|
|
41
|
+
*/
|
|
42
|
+
export async function actorFor(given) {
|
|
43
|
+
const g = (given ?? "").trim();
|
|
44
|
+
if (g && (!g.startsWith("human:") || !storage.getStore()))
|
|
45
|
+
return g;
|
|
46
|
+
return humanActor(await currentPerson());
|
|
47
|
+
}
|
package/dist/core/projects.d.ts
CHANGED
|
@@ -168,7 +168,7 @@ export declare function linkProject(slug: string, kind: string, target: string,
|
|
|
168
168
|
* knowledge bundle's log). The actor is stamped so a line written by an
|
|
169
169
|
* agent reads as such next to a human's.
|
|
170
170
|
*/
|
|
171
|
-
export declare function appendProjectLog(slug: string, entry: string, actor
|
|
171
|
+
export declare function appendProjectLog(slug: string, entry: string, actor?: string): Promise<string>;
|
|
172
172
|
/** Move the folder to the trash. */
|
|
173
173
|
export declare function deleteProject(slug: string): Promise<void>;
|
|
174
174
|
/**
|
package/dist/core/projects.js
CHANGED
|
@@ -13,6 +13,7 @@ import { listRepos } from "./repos.js";
|
|
|
13
13
|
import { SLUG_RE, slugify } from "./slug.js";
|
|
14
14
|
import { moveToTrash } from "./trash.js";
|
|
15
15
|
import { filesContext } from "./files.js";
|
|
16
|
+
import { actorFor } from "./person.js";
|
|
16
17
|
/**
|
|
17
18
|
* Projects: a goal with everything the agents need to reach it gathered in
|
|
18
19
|
* one folder — the brief, the systems of record where the truth is managed
|
|
@@ -302,7 +303,7 @@ export async function createProject(input) {
|
|
|
302
303
|
for (const [name, content] of Object.entries(projectStarter(def))) {
|
|
303
304
|
await fs.writeFile(path.join(dir, name), content);
|
|
304
305
|
}
|
|
305
|
-
await appendProjectLog(slug, `**Created**: project "${title}"
|
|
306
|
+
await appendProjectLog(slug, `**Created**: project "${title}".`);
|
|
306
307
|
return (await getProject(slug));
|
|
307
308
|
}
|
|
308
309
|
/** Merge the given fields into project.yml (and brief/state when given); lists replace wholesale. */
|
|
@@ -359,7 +360,7 @@ export async function appendProjectLog(slug, entry, actor) {
|
|
|
359
360
|
const text = entry.trim().replace(/\s*\n\s*/g, " ");
|
|
360
361
|
if (!text)
|
|
361
362
|
throw new Error("entry is required");
|
|
362
|
-
const who = actor
|
|
363
|
+
const who = await actorFor(actor);
|
|
363
364
|
const file = path.join(dir, "log.md");
|
|
364
365
|
const today = new Date().toISOString().slice(0, 10);
|
|
365
366
|
let raw = await fs.readFile(file, "utf8").catch(() => null);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
2
|
import { agentsRoot, deleteAgent, getAgent, listAgents, safeAgentSlug, saveAgent, setAgentArchived } from "../../core/agents.js";
|
|
3
3
|
import { appendJournal, readJournal } from "../../core/journal.js";
|
|
4
|
-
import {
|
|
4
|
+
import { actorFor } from "../../core/person.js";
|
|
5
5
|
import { adoptRoutine, deleteRoutine, listRoutines, routineStatuses, runRoutineNow, saveRoutine } from "../../core/routines.js";
|
|
6
6
|
import { deleteAgentSkill, listAgentSkills, readSkill, saveAgentSkill } from "../../core/skills.js";
|
|
7
7
|
import { fail, route } from "./router.js";
|
|
@@ -90,7 +90,7 @@ export const agentRoutes = [
|
|
|
90
90
|
body: z.object({ entry: z.string().default(""), kind: z.string().optional() }),
|
|
91
91
|
}, async (c) => {
|
|
92
92
|
const { entry, kind } = await c.body();
|
|
93
|
-
return { journal: await appendJournal(c.params.slug, entry, { kind, actor:
|
|
93
|
+
return { journal: await appendJournal(c.params.slug, entry, { kind, actor: await actorFor() }) };
|
|
94
94
|
}),
|
|
95
95
|
route({ name: "agents.routines", method: "GET", path: "/api/agents/:slug/routines", summary: "the agent's routines with run state", errors: 400 }, async (c) => ({
|
|
96
96
|
routines: await routineStatuses(own(c.params.slug)),
|
|
@@ -27,7 +27,7 @@ const TaskFields = z.object({
|
|
|
27
27
|
tags: z.array(z.string()).optional(),
|
|
28
28
|
refs: z.array(z.string()).optional(),
|
|
29
29
|
notes: z.string().optional(),
|
|
30
|
-
/** Who writes (
|
|
30
|
+
/** Who writes (an agent or process naming itself; a person is whoever asks) and a line for the log. */
|
|
31
31
|
actor: z.string().optional(),
|
|
32
32
|
message: z.string().optional(),
|
|
33
33
|
});
|
package/dist/server/api/chats.js
CHANGED
|
@@ -2,9 +2,10 @@ import { promises as fs } from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import * as z from "zod";
|
|
4
4
|
import { getAgent } from "../../core/agents.js";
|
|
5
|
-
import { answerElicitation, cancelChat, createChat, deleteChat, forkChat, getChat, listAgentSessionsFor, startOptionsFor, listChats,
|
|
5
|
+
import { answerElicitation, cancelChat, createChat, deleteChat, forkChat, getChat, listAgentSessionsFor, startOptionsFor, listChats, postMessage, renameChat, resetSession, resolvePermission, setChatConfig, setChatProject, setChatVibeable, steerChat, stopChatTask, subscribeChat, } from "../../core/chat/sessions.js";
|
|
6
6
|
import { attachmentPath, readMeta, saveAttachment } from "../../core/chat/store.js";
|
|
7
7
|
import { remoteCaller } from "../trust.js";
|
|
8
|
+
import { personOf } from "../person.js";
|
|
8
9
|
import { findTask } from "../../core/boards.js";
|
|
9
10
|
import { getProject } from "../../core/projects.js";
|
|
10
11
|
import { MIME } from "./mime.js";
|
|
@@ -82,8 +83,11 @@ async function projectSlug(slug) {
|
|
|
82
83
|
fail(404, "project not found");
|
|
83
84
|
return found.slug;
|
|
84
85
|
}
|
|
85
|
-
/** Who a chat or message is signed with:
|
|
86
|
-
const
|
|
86
|
+
/** Who a chat or message is signed with: the person asking (server/person.ts). */
|
|
87
|
+
const chatPersonOf = async (trust) => {
|
|
88
|
+
const p = await personOf(trust);
|
|
89
|
+
return { handle: p.handle, ...(p.id ? { id: p.id } : {}), ...(p.email ? { email: p.email } : {}) };
|
|
90
|
+
};
|
|
87
91
|
/**
|
|
88
92
|
* A private routine's run (meta.private) is not there for a remote caller
|
|
89
93
|
* (trust.ts remoteCaller): a 404, as if it did not exist. This machine and
|
|
@@ -129,7 +133,7 @@ export const chatRoutes = [
|
|
|
129
133
|
return await createChat({
|
|
130
134
|
agent: agent,
|
|
131
135
|
scope,
|
|
132
|
-
author: await
|
|
136
|
+
author: await chatPersonOf(c.trust),
|
|
133
137
|
...(project ? { project } : {}),
|
|
134
138
|
...(task ? { task } : {}),
|
|
135
139
|
...(body.resume ? { resume: body.resume } : {}),
|
|
@@ -203,7 +207,7 @@ export const chatRoutes = [
|
|
|
203
207
|
const { slug } = await c.body();
|
|
204
208
|
return metaOf(await setChatVibeable(c.params.id, slug || null));
|
|
205
209
|
}),
|
|
206
|
-
route({ name: "chats.fork", method: "POST", path: "/api/chats/:id/fork", summary: "a new chat continuing a copy of this one's session", errors: 400 }, async (c) => metaOf(await forkChat(c.params.id, await
|
|
210
|
+
route({ name: "chats.fork", method: "POST", path: "/api/chats/:id/fork", summary: "a new chat continuing a copy of this one's session", errors: 400 }, async (c) => metaOf(await forkChat(c.params.id, await chatPersonOf(c.trust)))),
|
|
207
211
|
route({ name: "chats.resetSession", method: "POST", path: "/api/chats/:id/reset-session", summary: "forget the agent's session; the next message starts fresh", errors: 400 }, async (c) => metaOf(await resetSession(c.params.id))),
|
|
208
212
|
// The body is the file itself; x-file-name names it, content-type types it.
|
|
209
213
|
route({ name: "chats.attach", method: "POST", path: "/api/chats/:id/attachments", summary: "upload an attachment for the next message", errors: 400, upload: true }, async (c) => {
|
|
@@ -235,8 +239,8 @@ export const chatRoutes = [
|
|
|
235
239
|
res.end(data);
|
|
236
240
|
}),
|
|
237
241
|
// Channels: `from` is the poster's display name, which signs the message.
|
|
238
|
-
act("chats.message", "/api/chats/:id/message", "send a message {text, attachments?, from?}", Said.extend({ from: z.string().optional() }), async (c, body) => postMessage(c.params.id, textOf(body), { from: body.from, attachments: body.attachments, by: await
|
|
239
|
-
act("chats.steer", "/api/chats/:id/steer", "add to the running turn {text, attachments?}", Said, async (c, body) => steerChat(c.params.id, textOf(body), body.attachments, await
|
|
242
|
+
act("chats.message", "/api/chats/:id/message", "send a message {text, attachments?, from?}", Said.extend({ from: z.string().optional() }), async (c, body) => postMessage(c.params.id, textOf(body), { from: body.from, attachments: body.attachments, by: await chatPersonOf(c.trust) })),
|
|
243
|
+
act("chats.steer", "/api/chats/:id/steer", "add to the running turn {text, attachments?}", Said, async (c, body) => steerChat(c.params.id, textOf(body), body.attachments, await chatPersonOf(c.trust))),
|
|
240
244
|
act("chats.permission", "/api/chats/:id/permission", "answer a permission request {requestId, optionId | null}", z.object({ requestId: z.string().default(""), optionId: z.string().nullable().default(null) }), (c, body) => resolvePermission(c.params.id, body.requestId, body.optionId)),
|
|
241
245
|
// Channels: `agent` stops one member; without it every agent in the chat.
|
|
242
246
|
act("chats.cancel", "/api/chats/:id/cancel", "stop the running turn {agent?}", z.object({ agent: z.string().optional() }), (c, body) => cancelChat(c.params.id, body.agent || undefined)),
|
|
@@ -30,6 +30,8 @@ export declare const cloudRoutes: (import("./router.js").Route<"cloud.invite", i
|
|
|
30
30
|
id?: string;
|
|
31
31
|
machine?: string;
|
|
32
32
|
account?: string | null;
|
|
33
|
+
accountId?: string | null;
|
|
34
|
+
accountHandle?: string | null;
|
|
33
35
|
interval?: number;
|
|
34
36
|
lastSeen?: string;
|
|
35
37
|
claimCode?: string | null;
|
|
@@ -48,6 +50,8 @@ export declare const cloudRoutes: (import("./router.js").Route<"cloud.invite", i
|
|
|
48
50
|
id?: string;
|
|
49
51
|
machine?: string;
|
|
50
52
|
account?: string | null;
|
|
53
|
+
accountId?: string | null;
|
|
54
|
+
accountHandle?: string | null;
|
|
51
55
|
interval?: number;
|
|
52
56
|
lastSeen?: string;
|
|
53
57
|
claimCode?: string | null;
|
|
@@ -63,6 +67,8 @@ export declare const cloudRoutes: (import("./router.js").Route<"cloud.invite", i
|
|
|
63
67
|
id?: string;
|
|
64
68
|
machine?: string;
|
|
65
69
|
account?: string | null;
|
|
70
|
+
accountId?: string | null;
|
|
71
|
+
accountHandle?: string | null;
|
|
66
72
|
interval?: number;
|
|
67
73
|
lastSeen?: string;
|
|
68
74
|
claimCode?: string | null;
|
|
@@ -78,6 +84,8 @@ export declare const cloudRoutes: (import("./router.js").Route<"cloud.invite", i
|
|
|
78
84
|
id?: string;
|
|
79
85
|
machine?: string;
|
|
80
86
|
account?: string | null;
|
|
87
|
+
accountId?: string | null;
|
|
88
|
+
accountHandle?: string | null;
|
|
81
89
|
interval?: number;
|
|
82
90
|
lastSeen?: string;
|
|
83
91
|
claimCode?: string | null;
|
|
@@ -350,6 +350,8 @@ export declare const routes: (Route<"agents.addJournal", {
|
|
|
350
350
|
id?: string;
|
|
351
351
|
machine?: string;
|
|
352
352
|
account?: string | null;
|
|
353
|
+
accountId?: string | null;
|
|
354
|
+
accountHandle?: string | null;
|
|
353
355
|
interval?: number;
|
|
354
356
|
lastSeen?: string;
|
|
355
357
|
claimCode?: string | null;
|
|
@@ -368,6 +370,8 @@ export declare const routes: (Route<"agents.addJournal", {
|
|
|
368
370
|
id?: string;
|
|
369
371
|
machine?: string;
|
|
370
372
|
account?: string | null;
|
|
373
|
+
accountId?: string | null;
|
|
374
|
+
accountHandle?: string | null;
|
|
371
375
|
interval?: number;
|
|
372
376
|
lastSeen?: string;
|
|
373
377
|
claimCode?: string | null;
|
|
@@ -383,6 +387,8 @@ export declare const routes: (Route<"agents.addJournal", {
|
|
|
383
387
|
id?: string;
|
|
384
388
|
machine?: string;
|
|
385
389
|
account?: string | null;
|
|
390
|
+
accountId?: string | null;
|
|
391
|
+
accountHandle?: string | null;
|
|
386
392
|
interval?: number;
|
|
387
393
|
lastSeen?: string;
|
|
388
394
|
claimCode?: string | null;
|
|
@@ -398,6 +404,8 @@ export declare const routes: (Route<"agents.addJournal", {
|
|
|
398
404
|
id?: string;
|
|
399
405
|
machine?: string;
|
|
400
406
|
account?: string | null;
|
|
407
|
+
accountId?: string | null;
|
|
408
|
+
accountHandle?: string | null;
|
|
401
409
|
interval?: number;
|
|
402
410
|
lastSeen?: string;
|
|
403
411
|
claimCode?: string | null;
|
|
@@ -561,7 +569,16 @@ export declare const routes: (Route<"agents.addJournal", {
|
|
|
561
569
|
content: z.ZodDefault<z.ZodString>;
|
|
562
570
|
}, z.core.$strip>> | Route<"knowledge.verify", import("../../okf.js").ConceptDetail, "/api/knowledge/:bundle/verify", z.ZodObject<{
|
|
563
571
|
id: z.ZodDefault<z.ZodString>;
|
|
564
|
-
}, z.core.$strip>> | Route<"
|
|
572
|
+
}, z.core.$strip>> | Route<"me.get", {
|
|
573
|
+
mode: import("../../config.js").UsersMode;
|
|
574
|
+
handle: string;
|
|
575
|
+
actor: string;
|
|
576
|
+
id?: string | undefined;
|
|
577
|
+
email?: string | undefined;
|
|
578
|
+
signedIn: boolean;
|
|
579
|
+
role?: "member" | "owner" | undefined;
|
|
580
|
+
via: "device" | "local" | "member";
|
|
581
|
+
}, "/api/me", undefined> | Route<"meta.get", {
|
|
565
582
|
workspaceName: string;
|
|
566
583
|
workspaceSlug: string;
|
|
567
584
|
workspaceIcon: string;
|
|
@@ -598,6 +615,8 @@ export declare const routes: (Route<"agents.addJournal", {
|
|
|
598
615
|
id?: string;
|
|
599
616
|
machine?: string;
|
|
600
617
|
account?: string | null;
|
|
618
|
+
accountId?: string | null;
|
|
619
|
+
accountHandle?: string | null;
|
|
601
620
|
interval?: number;
|
|
602
621
|
lastSeen?: string;
|
|
603
622
|
claimCode?: string | null;
|
|
@@ -696,7 +715,7 @@ export declare const routes: (Route<"agents.addJournal", {
|
|
|
696
715
|
log: string;
|
|
697
716
|
}, "/api/projects/:slug/log", z.ZodObject<{
|
|
698
717
|
entry: z.ZodString;
|
|
699
|
-
actor: z.
|
|
718
|
+
actor: z.ZodOptional<z.ZodString>;
|
|
700
719
|
}, z.core.$strip>> | Route<"projects.save", import("../../core/projects.js").ProjectDetail, "/api/projects/:slug", z.ZodObject<{
|
|
701
720
|
title: z.ZodOptional<z.ZodString>;
|
|
702
721
|
status: z.ZodOptional<z.ZodString>;
|
|
@@ -732,6 +751,71 @@ export declare const routes: (Route<"agents.addJournal", {
|
|
|
732
751
|
}, "/api/refs/resolve", z.ZodObject<{
|
|
733
752
|
tokens: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
734
753
|
text: z.ZodDefault<z.ZodString>;
|
|
754
|
+
}, z.core.$strip>> | Route<"remoteBoards.create", import("./router.js").Reply<{
|
|
755
|
+
board: import("./remote-boards.js").RemoteBoardSummary;
|
|
756
|
+
}>, "/api/remote-boards", z.ZodObject<{
|
|
757
|
+
title: z.ZodOptional<z.ZodString>;
|
|
758
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
759
|
+
columns: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
760
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
761
|
+
title: z.ZodString;
|
|
762
|
+
}, z.core.$strip>>>;
|
|
763
|
+
}, z.core.$strip>> | Route<"remoteBoards.delete", {
|
|
764
|
+
ok: true;
|
|
765
|
+
}, "/api/remote-boards/:board", undefined> | Route<"remoteBoards.get", {
|
|
766
|
+
board: import("./remote-boards.js").RemoteBoardSummary;
|
|
767
|
+
tasks: import("./remote-boards.js").RemoteTaskSummary[];
|
|
768
|
+
people: import("./remote-boards.js").RemotePerson[];
|
|
769
|
+
actor: string;
|
|
770
|
+
}, "/api/remote-boards/:board", undefined> | Route<"remoteBoards.list", {
|
|
771
|
+
boards: import("./remote-boards.js").RemoteBoardSummary[];
|
|
772
|
+
role: "owner" | "member";
|
|
773
|
+
actor: string;
|
|
774
|
+
cloudUrl: string | null;
|
|
775
|
+
}, "/api/remote-boards", undefined> | Route<"remoteBoards.people", {
|
|
776
|
+
people: import("./remote-boards.js").RemotePerson[];
|
|
777
|
+
actor: string;
|
|
778
|
+
role: "owner" | "member";
|
|
779
|
+
}, "/api/remote-boards/people", undefined> | Route<"remoteBoards.save", {
|
|
780
|
+
board: import("./remote-boards.js").RemoteBoardSummary;
|
|
781
|
+
}, "/api/remote-boards/:board", z.ZodObject<{
|
|
782
|
+
title: z.ZodOptional<z.ZodString>;
|
|
783
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
784
|
+
columns: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
785
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
786
|
+
title: z.ZodString;
|
|
787
|
+
}, z.core.$strip>>>;
|
|
788
|
+
}, z.core.$strip>> | Route<"remoteTasks.create", import("./router.js").Reply<{
|
|
789
|
+
task: import("./remote-boards.js").RemoteTaskDetail;
|
|
790
|
+
}>, "/api/remote-boards/:board/tasks", z.ZodObject<{
|
|
791
|
+
title: z.ZodOptional<z.ZodString>;
|
|
792
|
+
status: z.ZodOptional<z.ZodString>;
|
|
793
|
+
position: z.ZodOptional<z.ZodNumber>;
|
|
794
|
+
assignee: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
795
|
+
due: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
796
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
797
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
798
|
+
actor: z.ZodOptional<z.ZodString>;
|
|
799
|
+
}, z.core.$strip>> | Route<"remoteTasks.delete", {
|
|
800
|
+
ok: true;
|
|
801
|
+
}, "/api/remote-boards/:board/tasks/:task", undefined> | Route<"remoteTasks.get", {
|
|
802
|
+
task: import("./remote-boards.js").RemoteTaskDetail;
|
|
803
|
+
}, "/api/remote-boards/:board/tasks/:task", undefined> | Route<"remoteTasks.log", {
|
|
804
|
+
task: import("./remote-boards.js").RemoteTaskDetail;
|
|
805
|
+
}, "/api/remote-boards/:board/tasks/:task/log", z.ZodObject<{
|
|
806
|
+
entry: z.ZodString;
|
|
807
|
+
actor: z.ZodOptional<z.ZodString>;
|
|
808
|
+
}, z.core.$strip>> | Route<"remoteTasks.save", {
|
|
809
|
+
task: import("./remote-boards.js").RemoteTaskDetail;
|
|
810
|
+
}, "/api/remote-boards/:board/tasks/:task", z.ZodObject<{
|
|
811
|
+
title: z.ZodOptional<z.ZodString>;
|
|
812
|
+
status: z.ZodOptional<z.ZodString>;
|
|
813
|
+
position: z.ZodOptional<z.ZodNumber>;
|
|
814
|
+
assignee: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
815
|
+
due: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
816
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
817
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
818
|
+
actor: z.ZodOptional<z.ZodString>;
|
|
735
819
|
}, z.core.$strip>> | Route<"repos.add", import("./router.js").Reply<import("../../core/repos.js").RepoInfo>, "/api/repos", z.ZodObject<{
|
|
736
820
|
url: z.ZodDefault<z.ZodString>;
|
|
737
821
|
name: z.ZodOptional<z.ZodString>;
|
package/dist/server/api/index.js
CHANGED
|
@@ -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,
|
|
@@ -3,7 +3,7 @@ import { stat } from "node:fs/promises";
|
|
|
3
3
|
import * as z from "zod";
|
|
4
4
|
import { createDeck, deckSlidePng, deleteDeck, exportBytes, getDeck, listAllDecks, listDecks, listTemplates, openPresentations, saveAsset, addComment, updateComment, deleteComment, StaleDeckError, existingDeckDir, deckVersions, deckVersion, deckFile, templateFile, saveDeck, } from "../../core/presentations/index.js";
|
|
5
5
|
import { ApiError, fail, reply, route, statusByMessage } from "./router.js";
|
|
6
|
-
import {
|
|
6
|
+
import { personOf } from "../person.js";
|
|
7
7
|
import { tasksReferencing } from "../../core/boards.js";
|
|
8
8
|
import { leavePresence, touchPresence } from "../../core/presentations/presence.js";
|
|
9
9
|
/**
|
|
@@ -45,7 +45,7 @@ const refOf = (c) => {
|
|
|
45
45
|
return { ...(project ? { project } : {}), name: c.params.name };
|
|
46
46
|
};
|
|
47
47
|
/** Who writes a comment: a member by their handle, else this machine's person. */
|
|
48
|
-
const authorOf = async (trust) => (
|
|
48
|
+
const authorOf = async (trust) => (await personOf(trust)).handle;
|
|
49
49
|
const requireOn = async () => {
|
|
50
50
|
if ((await openPresentations()).off)
|
|
51
51
|
fail(409, "presentations are off");
|
|
@@ -16,7 +16,7 @@ export declare const projectRoutes: (import("./router.js").Route<"projects.creat
|
|
|
16
16
|
log: string;
|
|
17
17
|
}, "/api/projects/:slug/log", z.ZodObject<{
|
|
18
18
|
entry: z.ZodString;
|
|
19
|
-
actor: z.
|
|
19
|
+
actor: z.ZodOptional<z.ZodString>;
|
|
20
20
|
}, z.core.$strip>> | import("./router.js").Route<"projects.save", import("../../core/projects.js").ProjectDetail, "/api/projects/:slug", z.ZodObject<{
|
|
21
21
|
title: z.ZodOptional<z.ZodString>;
|
|
22
22
|
status: z.ZodOptional<z.ZodString>;
|
|
@@ -58,7 +58,7 @@ export const projectRoutes = [
|
|
|
58
58
|
path: "/api/projects/:slug/log",
|
|
59
59
|
summary: "append a stamped line {entry, actor?} to log.md",
|
|
60
60
|
errors: projectErrors,
|
|
61
|
-
body: z.object({ entry: z.string(), actor: z.string().
|
|
61
|
+
body: z.object({ entry: z.string(), actor: z.string().optional() }),
|
|
62
62
|
}, async (c) => {
|
|
63
63
|
const { entry, actor } = await c.body();
|
|
64
64
|
return { ok: true, log: await appendProjectLog(c.params.slug, entry, actor) };
|