@biolibs/bionet-panels 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adviser.d.ts +68 -0
- package/dist/adviser.d.ts.map +1 -0
- package/dist/adviser.js +68 -0
- package/dist/adviser.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/adviser.tsx +195 -0
- package/src/index.ts +2 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The adviser a device hosts: an agent let into the lab as a member with no hands.
|
|
3
|
+
*
|
|
4
|
+
* Three decisions are a person's, and this is where each is made: whether this device hosts an
|
|
5
|
+
* adviser at all, whether a keeper lets its key into the lab, and whether the door an agent comes in
|
|
6
|
+
* by is open. None of them is made for anybody, and each says what it does before it is done.
|
|
7
|
+
*/
|
|
8
|
+
import { type ReactNode } from "react";
|
|
9
|
+
/** One thing the adviser lately did. */
|
|
10
|
+
export interface AdviserSeen {
|
|
11
|
+
/** Which of its tools it used. */
|
|
12
|
+
tool: string;
|
|
13
|
+
/** Whether that worked. */
|
|
14
|
+
ok: boolean;
|
|
15
|
+
/** When, as an ISO date. */
|
|
16
|
+
at: string;
|
|
17
|
+
/** Where in the lab it would be seen, if it has a place there, as the adviser's tools report it. */
|
|
18
|
+
shows?: unknown;
|
|
19
|
+
}
|
|
20
|
+
/** The way an agent reaches the adviser's tools on this device, as a host offers it. */
|
|
21
|
+
export interface AdviserDoor {
|
|
22
|
+
/** Whether it is open. */
|
|
23
|
+
on: boolean;
|
|
24
|
+
/** Where it is, when it is open. */
|
|
25
|
+
url: string | null;
|
|
26
|
+
/** What the adviser has lately done, newest last. */
|
|
27
|
+
seen?: readonly AdviserSeen[];
|
|
28
|
+
/** Open or shut it. */
|
|
29
|
+
turn: (on: boolean) => Promise<unknown>;
|
|
30
|
+
/** Put the way to connect, token and all, on the clipboard. The window is never shown the token. */
|
|
31
|
+
copy: () => Promise<unknown>;
|
|
32
|
+
/** Make the token anew, shutting out whatever had the old one. */
|
|
33
|
+
renew?: () => Promise<unknown>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* What the adviser did, in a few words.
|
|
37
|
+
*
|
|
38
|
+
* @param tool - Which of its tools it used.
|
|
39
|
+
* @returns Something like `worked out a digest`.
|
|
40
|
+
*/
|
|
41
|
+
export declare const adviserDid: (tool: string) => string;
|
|
42
|
+
/**
|
|
43
|
+
* The adviser this device hosts, and the door to it.
|
|
44
|
+
*
|
|
45
|
+
* @param props - `door` is the way an agent reaches it, for a host that has one to offer. Without
|
|
46
|
+
* it the adviser can still be hosted and let in, and something else has to carry what it says.
|
|
47
|
+
* `onWatch`, if given, adds a way to go and watch the adviser at work in the lab.
|
|
48
|
+
*/
|
|
49
|
+
export declare function Adviser({ door, onWatch }: {
|
|
50
|
+
door?: AdviserDoor;
|
|
51
|
+
onWatch?: () => void;
|
|
52
|
+
}): ReactNode;
|
|
53
|
+
/**
|
|
54
|
+
* What the adviser is doing, said over the lab while it is being watched.
|
|
55
|
+
*
|
|
56
|
+
* Watching is following: the view goes where the adviser last looked. A person can stop following
|
|
57
|
+
* and take the controls, since what is drawn under this is the lab and its tools and not a film of them.
|
|
58
|
+
*
|
|
59
|
+
* @param props - `last` is the latest thing it did, if it has done anything; `following` is whether
|
|
60
|
+
* the view is going where it looks, and `onFollow` changes that; `onBack` leaves.
|
|
61
|
+
*/
|
|
62
|
+
export declare function AdviserStrip({ last, following, onFollow, onBack }: {
|
|
63
|
+
last: AdviserSeen | null;
|
|
64
|
+
following: boolean;
|
|
65
|
+
onFollow: (following: boolean) => void;
|
|
66
|
+
onBack: () => void;
|
|
67
|
+
}): ReactNode;
|
|
68
|
+
//# sourceMappingURL=adviser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adviser.d.ts","sourceR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,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,IAAI,CAAC;CAC1G,GAAG,SAAS,CAiBZ"}
|
package/dist/adviser.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* The adviser a device hosts: an agent let into the lab as a member with no hands.
|
|
5
|
+
*
|
|
6
|
+
* Three decisions are a person's, and this is where each is made: whether this device hosts an
|
|
7
|
+
* adviser at all, whether a keeper lets its key into the lab, and whether the door an agent comes in
|
|
8
|
+
* by is open. None of them is made for anybody, and each says what it does before it is done.
|
|
9
|
+
*/
|
|
10
|
+
import { useState } from "react";
|
|
11
|
+
import { useAct, useLab } from "@biolibs/bionet-react";
|
|
12
|
+
import { Copy } from "./parts.js";
|
|
13
|
+
const TOOL_WORDS = {
|
|
14
|
+
lab_overview: "looked over the lab", list_parts: "read the list of parts", get_part: "read a part closely", list_tubes: "read the list of tubes",
|
|
15
|
+
list_runs: "read what has been done", list_proposals: "read what is proposed", find_cutters: "looked for enzymes that cut a part",
|
|
16
|
+
design_primers: "designed a pair of primers", work_out_pcr: "worked out a PCR", work_out_digest: "worked out a digest", work_out_ligation: "worked out a ligation",
|
|
17
|
+
add_part: "added a part", propose_pcr: "proposed a PCR", propose_digest: "proposed a digest", propose_ligation: "proposed a ligation", withdraw_proposal: "took a proposal back",
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* What the adviser did, in a few words.
|
|
21
|
+
*
|
|
22
|
+
* @param tool - Which of its tools it used.
|
|
23
|
+
* @returns Something like `worked out a digest`.
|
|
24
|
+
*/
|
|
25
|
+
export const adviserDid = (tool) => TOOL_WORDS[tool] ?? `used ${tool}`;
|
|
26
|
+
/**
|
|
27
|
+
* The adviser this device hosts, and the door to it.
|
|
28
|
+
*
|
|
29
|
+
* @param props - `door` is the way an agent reaches it, for a host that has one to offer. Without
|
|
30
|
+
* it the adviser can still be hosted and let in, and something else has to carry what it says.
|
|
31
|
+
* `onWatch`, if given, adds a way to go and watch the adviser at work in the lab.
|
|
32
|
+
*/
|
|
33
|
+
export function Adviser({ door, onWatch }) {
|
|
34
|
+
const state = useLab();
|
|
35
|
+
const act = useAct();
|
|
36
|
+
const [person, setPerson] = useState("Claude");
|
|
37
|
+
const [busy, setBusy] = useState(false);
|
|
38
|
+
const [copied, setCopied] = useState(false);
|
|
39
|
+
const lab = state?.lab;
|
|
40
|
+
if (state === null || lab === null || lab === undefined)
|
|
41
|
+
return null;
|
|
42
|
+
const hosting = state.hosting;
|
|
43
|
+
const ask = async (work) => { setBusy(true); try {
|
|
44
|
+
await work();
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
setBusy(false);
|
|
48
|
+
} };
|
|
49
|
+
const theirs = hosting === null ? [] : lab.plans.filter((one) => one.by === hosting.key);
|
|
50
|
+
return (_jsxs(_Fragment, { children: [_jsxs("section", { className: "card", children: [_jsx("h2", { children: "An adviser on this device" }), _jsx("p", { className: "small", children: "An adviser is a member with no hands: an agent that can read what the lab holds, work things out with the lab's own tools, add a part by its sequence, and propose a run for a person to carry out." }), _jsx("p", { className: "dim small", children: "It cannot say that anything was done, used or moved. That is not a setting here: its key has the role of adviser, and every device in the lab refuses anything else it writes. What it proposes is shown at the tool that would carry it out, with its reasons, and nothing happens until a person does it." }), hosting === null ? (_jsx("button", { type: "button", disabled: busy, onClick: () => void ask(() => act("hostAdviser")), children: "Host an adviser on this device" })) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: "keybox", children: [_jsxs("div", { children: [_jsx("span", { className: "label", children: "The adviser's key" }), _jsx(Copy, { words: hosting.key, label: "Copy key" })] }), _jsx("code", { className: "wrap", children: hosting.key }), _jsxs("p", { className: "dim small", children: ["Fingerprint ", _jsx("code", { children: hosting.fingerprint }), ". It is a key of its own, kept on this device and apart from yours: what the adviser writes is signed with it and never with your key."] })] }), hosting.standing === "adviser" && _jsx("p", { className: "small good", role: "status", children: "It is in the lab as an adviser." }), hosting.standing === "removed" && _jsx("p", { className: "small trouble", role: "status", children: "It was removed from the lab. What it wrote until then is kept." }), (hosting.standing === "member" || hosting.standing === "keeper") && (_jsxs("p", { className: "small trouble", role: "status", children: ["This key is in the lab as a ", hosting.standing, ", which can do more than advise. Nothing is written with it from here until a keeper makes it an adviser."] })), hosting.standing === null && (lab.keeper ? (_jsxs("fieldset", { disabled: busy, className: "stack", children: [_jsx("p", { className: "small", children: "It is not in the lab yet. Until it is, it can read and work things out, and propose nothing." }), _jsxs("label", { children: ["Call it", _jsx("input", { value: person, onChange: (event) => setPerson(event.target.value), maxLength: 200, "aria-label": "What to call the adviser" })] }), _jsx("button", { type: "button", disabled: person.trim() === "", onClick: () => void ask(() => act("addMember", { key: hosting.key, person: person.trim(), role: "adviser" })), children: "Let it into the lab as an adviser" })] })) : _jsx("p", { className: "small", children: "It is not in the lab yet. Only a keeper can let it in: send them the key above, to add as an adviser." }))] }))] }), hosting !== null && door !== undefined && (_jsxs("section", { className: "card", children: [_jsx("h2", { children: "The way in" }), _jsx("p", { className: "small", children: "An agent reaches the adviser's tools through a door on this computer. It is shut until you open it, it cannot be reached from the network, and whoever comes through it needs a token that is kept sealed on this device." }), _jsxs("div", { className: "row", children: [_jsx("button", { type: "button", disabled: busy, onClick: () => void ask(() => door.turn(!door.on)), children: door.on ? "Shut the door" : "Open the door" }), _jsx("span", { className: door.on ? "small good" : "dim small", role: "status", children: door.on ? "Open, on this computer only." : "Shut. Nothing can reach the adviser." })] }), door.on && door.url !== null && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "keybox", children: [_jsx("div", { children: _jsx("span", { className: "label", children: "Where it is" }) }), _jsx("code", { className: "wrap", children: door.url })] }), _jsxs("div", { className: "row", children: [_jsx("button", { type: "button", className: "quiet", disabled: busy, onClick: () => void ask(async () => { await door.copy(); setCopied(true); setTimeout(() => setCopied(false), 2500); }), children: copied ? "Copied" : "Copy the command that connects Claude Code" }), door.renew !== undefined && _jsx("button", { type: "button", className: "quiet", disabled: busy, onClick: () => void ask(() => door.renew()), children: "Make a new token" })] }), _jsx("p", { className: "dim small", children: "The command carries the token, so it goes to the clipboard and is not shown here. Paste it into a terminal once. A new token shuts the door and shuts out whatever had the old one." })] }))] })), hosting !== null && (_jsxs("section", { className: "card", children: [_jsx("h2", { children: "What it has done" }), theirs.length === 0 ? _jsx("p", { className: "dim small", children: "It has proposed nothing." }) : (_jsxs("p", { className: "small", children: ["It has proposed ", theirs.length, " ", theirs.length === 1 ? "run" : "runs", ": ", theirs.filter((one) => one.settled === null).length, " open,", " ", theirs.filter((one) => one.settled !== null && one.settled.run !== null).length, " carried out, ", theirs.filter((one) => one.settled !== null && one.settled.run === null).length, " set aside. Each is at its tool, under Proposed."] })), door?.seen !== undefined && door.seen.length > 0 && (_jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "When" }), _jsx("th", { children: "It" }), _jsx("th", {})] }) }), _jsx("tbody", { children: [...door.seen].reverse().slice(0, 12).map((one, at) => (_jsxs("tr", { children: [_jsx("td", { className: "dim", children: new Date(one.at).toLocaleTimeString() }), _jsx("td", { children: adviserDid(one.tool) }), _jsx("td", { children: one.ok ? "" : _jsx("span", { className: "badge", children: "could not" }) })] }, `${one.at} ${at}`))) })] })), onWatch !== undefined && (_jsxs("div", { className: "row", children: [_jsx("button", { type: "button", onClick: onWatch, children: "Watch it work" }), _jsx("span", { className: "dim small", children: "The lab, with the view going wherever the adviser is looking." })] })), _jsx("p", { className: "dim small", children: "Everything it writes is in History under its own name, like anybody's." })] }))] }));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* What the adviser is doing, said over the lab while it is being watched.
|
|
54
|
+
*
|
|
55
|
+
* Watching is following: the view goes where the adviser last looked. A person can stop following
|
|
56
|
+
* and take the controls, since what is drawn under this is the lab and its tools and not a film of them.
|
|
57
|
+
*
|
|
58
|
+
* @param props - `last` is the latest thing it did, if it has done anything; `following` is whether
|
|
59
|
+
* the view is going where it looks, and `onFollow` changes that; `onBack` leaves.
|
|
60
|
+
*/
|
|
61
|
+
export function AdviserStrip({ last, following, onFollow, onBack }) {
|
|
62
|
+
const state = useLab();
|
|
63
|
+
const hosting = state?.hosting ?? null;
|
|
64
|
+
const name = state?.lab?.roster.find((one) => one.key === hosting?.key)?.person ?? "The adviser";
|
|
65
|
+
return (_jsxs("section", { className: "card adviserstrip", "aria-live": "polite", children: [_jsxs("div", { className: "row", children: [_jsx("p", { children: last === null ? _jsxs("span", { className: "dim", children: [name, " has not done anything yet. What it does will be shown here, where it does it."] })
|
|
66
|
+
: _jsxs(_Fragment, { children: [_jsx("strong", { children: name }), " ", adviserDid(last.tool), last.ok ? "" : ", and could not", " ", _jsxs("span", { className: "dim small", children: ["at ", new Date(last.at).toLocaleTimeString()] })] }) }), _jsxs("label", { className: "check small", children: [_jsx("input", { type: "checkbox", checked: following, onChange: (event) => onFollow(event.target.checked) }), " Follow it"] }), _jsx("button", { type: "button", className: "quiet", onClick: onBack, children: "Back" })] }), !following && _jsx("p", { className: "dim small", children: "You have the controls. What it does next is still listed, and the view stays where you put it." })] }));
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=adviser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adviser.js","sourceRoot":"","sources":["../src/adviser.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb;;;;;;GAMG;AACH,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AA8BlC,MAAM,UAAU,GAAqC;IACnD,YAAY,EAAE,qBAAqB,EAAE,UAAU,EAAE,wBAAwB,EAAE,QAAQ,EAAE,qBAAqB,EAAE,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,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,iBAAiB,OAAE,gBAAM,SAAS,EAAC,WAAW,oBAAK,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,kBAAkB,EAAE,IAAQ,IAAG,GACvK,EACJ,iBAAO,SAAS,EAAC,aAAa,aAAC,gBAAO,IAAI,EAAC,UAAU,EAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,GAAI,kBAAkB,EACnJ,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,OAAO,EAAC,OAAO,EAAE,MAAM,qBAAe,IAClE,EACL,CAAC,SAAS,IAAI,YAAG,SAAS,EAAC,WAAW,+GAAmG,IAClI,CACX,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* - `people.tsx` — the roster, and letting somebody in
|
|
16
16
|
* - `history.tsx` — every signed change, and what became of it
|
|
17
17
|
* - `sharing.tsx` — what other labs are shown, and the lab's web peer
|
|
18
|
+
* - `adviser.tsx` — the adviser a device hosts: letting it in, and the door an agent reaches it by
|
|
18
19
|
* - `parts.tsx` — the small pieces they are made of
|
|
19
20
|
* - `public.tsx` — a lab's public page: what it holds, and what it can see of another lab
|
|
20
21
|
*
|
|
@@ -26,6 +27,7 @@ export * from "./freezer.js";
|
|
|
26
27
|
export * from "./places.js";
|
|
27
28
|
export * from "./backup.js";
|
|
28
29
|
export * from "./people.js";
|
|
30
|
+
export * from "./adviser.js";
|
|
29
31
|
export * from "./history.js";
|
|
30
32
|
export * from "./sharing.js";
|
|
31
33
|
export * from "./parts.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* - `people.tsx` — the roster, and letting somebody in
|
|
16
16
|
* - `history.tsx` — every signed change, and what became of it
|
|
17
17
|
* - `sharing.tsx` — what other labs are shown, and the lab's web peer
|
|
18
|
+
* - `adviser.tsx` — the adviser a device hosts: letting it in, and the door an agent reaches it by
|
|
18
19
|
* - `parts.tsx` — the small pieces they are made of
|
|
19
20
|
* - `public.tsx` — a lab's public page: what it holds, and what it can see of another lab
|
|
20
21
|
*
|
|
@@ -26,6 +27,7 @@ export * from "./freezer.js";
|
|
|
26
27
|
export * from "./places.js";
|
|
27
28
|
export * from "./backup.js";
|
|
28
29
|
export * from "./people.js";
|
|
30
|
+
export * from "./adviser.js";
|
|
29
31
|
export * from "./history.js";
|
|
30
32
|
export * from "./sharing.js";
|
|
31
33
|
export * from "./parts.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
},
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@biolibs/bionet": "^1.5.0",
|
|
7
|
-
"@biolibs/bionet-client": "^0.2.
|
|
7
|
+
"@biolibs/bionet-client": "^0.2.4",
|
|
8
8
|
"@biolibs/bionet-react": "^0.2.0",
|
|
9
9
|
"@biolibs/bionet-space": "^0.3.0",
|
|
10
10
|
"@biolibs/opencloning": "^2.0.0"
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
],
|
|
55
55
|
"type": "module",
|
|
56
56
|
"types": "dist/index.d.ts",
|
|
57
|
-
"version": "0.3.
|
|
57
|
+
"version": "0.3.5"
|
|
58
58
|
}
|
package/src/adviser.tsx
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The adviser a device hosts: an agent let into the lab as a member with no hands.
|
|
5
|
+
*
|
|
6
|
+
* Three decisions are a person's, and this is where each is made: whether this device hosts an
|
|
7
|
+
* adviser at all, whether a keeper lets its key into the lab, and whether the door an agent comes in
|
|
8
|
+
* by is open. None of them is made for anybody, and each says what it does before it is done.
|
|
9
|
+
*/
|
|
10
|
+
import { useState, type ReactNode } from "react";
|
|
11
|
+
import { useAct, useLab } from "@biolibs/bionet-react";
|
|
12
|
+
import { Copy } from "./parts.js";
|
|
13
|
+
|
|
14
|
+
/** One thing the adviser lately did. */
|
|
15
|
+
export interface AdviserSeen {
|
|
16
|
+
/** Which of its tools it used. */
|
|
17
|
+
tool: string;
|
|
18
|
+
/** Whether that worked. */
|
|
19
|
+
ok: boolean;
|
|
20
|
+
/** When, as an ISO date. */
|
|
21
|
+
at: string;
|
|
22
|
+
/** Where in the lab it would be seen, if it has a place there, as the adviser's tools report it. */
|
|
23
|
+
shows?: unknown;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The way an agent reaches the adviser's tools on this device, as a host offers it. */
|
|
27
|
+
export interface AdviserDoor {
|
|
28
|
+
/** Whether it is open. */
|
|
29
|
+
on: boolean;
|
|
30
|
+
/** Where it is, when it is open. */
|
|
31
|
+
url: string | null;
|
|
32
|
+
/** What the adviser has lately done, newest last. */
|
|
33
|
+
seen?: readonly AdviserSeen[];
|
|
34
|
+
/** Open or shut it. */
|
|
35
|
+
turn: (on: boolean) => Promise<unknown>;
|
|
36
|
+
/** Put the way to connect, token and all, on the clipboard. The window is never shown the token. */
|
|
37
|
+
copy: () => Promise<unknown>;
|
|
38
|
+
/** Make the token anew, shutting out whatever had the old one. */
|
|
39
|
+
renew?: () => Promise<unknown>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const TOOL_WORDS: Readonly<Record<string, string>> = {
|
|
43
|
+
lab_overview: "looked over the lab", list_parts: "read the list of parts", get_part: "read a part closely", list_tubes: "read the list of tubes",
|
|
44
|
+
list_runs: "read what has been done", list_proposals: "read what is proposed", find_cutters: "looked for enzymes that cut a part",
|
|
45
|
+
design_primers: "designed a pair of primers", work_out_pcr: "worked out a PCR", work_out_digest: "worked out a digest", work_out_ligation: "worked out a ligation",
|
|
46
|
+
add_part: "added a part", propose_pcr: "proposed a PCR", propose_digest: "proposed a digest", propose_ligation: "proposed a ligation", withdraw_proposal: "took a proposal back",
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* What the adviser did, in a few words.
|
|
51
|
+
*
|
|
52
|
+
* @param tool - Which of its tools it used.
|
|
53
|
+
* @returns Something like `worked out a digest`.
|
|
54
|
+
*/
|
|
55
|
+
export const adviserDid = (tool: string): string => TOOL_WORDS[tool] ?? `used ${tool}`;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The adviser this device hosts, and the door to it.
|
|
59
|
+
*
|
|
60
|
+
* @param props - `door` is the way an agent reaches it, for a host that has one to offer. Without
|
|
61
|
+
* it the adviser can still be hosted and let in, and something else has to carry what it says.
|
|
62
|
+
* `onWatch`, if given, adds a way to go and watch the adviser at work in the lab.
|
|
63
|
+
*/
|
|
64
|
+
export function Adviser({ door, onWatch }: { door?: AdviserDoor; onWatch?: () => void }): ReactNode {
|
|
65
|
+
const state = useLab();
|
|
66
|
+
const act = useAct();
|
|
67
|
+
const [person, setPerson] = useState("Claude");
|
|
68
|
+
const [busy, setBusy] = useState(false);
|
|
69
|
+
const [copied, setCopied] = useState(false);
|
|
70
|
+
const lab = state?.lab;
|
|
71
|
+
if (state === null || lab === null || lab === undefined) return null;
|
|
72
|
+
const hosting = state.hosting;
|
|
73
|
+
const ask = async (work: () => Promise<unknown>): Promise<void> => { setBusy(true); try { await work(); } finally { setBusy(false); } };
|
|
74
|
+
const theirs = hosting === null ? [] : lab.plans.filter((one) => one.by === hosting.key);
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<>
|
|
78
|
+
<section className="card">
|
|
79
|
+
<h2>An adviser on this device</h2>
|
|
80
|
+
<p className="small">An adviser is a member with no hands: an agent that can read what the lab holds, work things out with the lab's own tools, add a part by its sequence, and propose a run for a person to carry out.</p>
|
|
81
|
+
<p className="dim small">It cannot say that anything was done, used or moved. That is not a setting here: its key has the role of adviser, and every device in the lab refuses anything else it writes. What it proposes is shown at the tool that would carry it out, with its reasons, and nothing happens until a person does it.</p>
|
|
82
|
+
{hosting === null ? (
|
|
83
|
+
<button type="button" disabled={busy} onClick={() => void ask(() => act("hostAdviser"))}>Host an adviser on this device</button>
|
|
84
|
+
) : (
|
|
85
|
+
<>
|
|
86
|
+
<div className="keybox">
|
|
87
|
+
<div><span className="label">The adviser's key</span><Copy words={hosting.key} label="Copy key" /></div>
|
|
88
|
+
<code className="wrap">{hosting.key}</code>
|
|
89
|
+
<p className="dim small">Fingerprint <code>{hosting.fingerprint}</code>. It is a key of its own, kept on this device and apart from yours: what the adviser writes is signed with it and never with your key.</p>
|
|
90
|
+
</div>
|
|
91
|
+
{hosting.standing === "adviser" && <p className="small good" role="status">It is in the lab as an adviser.</p>}
|
|
92
|
+
{hosting.standing === "removed" && <p className="small trouble" role="status">It was removed from the lab. What it wrote until then is kept.</p>}
|
|
93
|
+
{(hosting.standing === "member" || hosting.standing === "keeper") && (
|
|
94
|
+
<p className="small trouble" role="status">This key is in the lab as a {hosting.standing}, which can do more than advise. Nothing is written with it from here until a keeper makes it an adviser.</p>
|
|
95
|
+
)}
|
|
96
|
+
{hosting.standing === null && (lab.keeper ? (
|
|
97
|
+
<fieldset disabled={busy} className="stack">
|
|
98
|
+
<p className="small">It is not in the lab yet. Until it is, it can read and work things out, and propose nothing.</p>
|
|
99
|
+
<label>Call it<input value={person} onChange={(event) => setPerson(event.target.value)} maxLength={200} aria-label="What to call the adviser" /></label>
|
|
100
|
+
<button type="button" disabled={person.trim() === ""} onClick={() => void ask(() => act("addMember", { key: hosting.key, person: person.trim(), role: "adviser" }))}>Let it into the lab as an adviser</button>
|
|
101
|
+
</fieldset>
|
|
102
|
+
) : <p className="small">It is not in the lab yet. Only a keeper can let it in: send them the key above, to add as an adviser.</p>)}
|
|
103
|
+
</>
|
|
104
|
+
)}
|
|
105
|
+
</section>
|
|
106
|
+
|
|
107
|
+
{hosting !== null && door !== undefined && (
|
|
108
|
+
<section className="card">
|
|
109
|
+
<h2>The way in</h2>
|
|
110
|
+
<p className="small">An agent reaches the adviser's tools through a door on this computer. It is shut until you open it, it cannot be reached from the network, and whoever comes through it needs a token that is kept sealed on this device.</p>
|
|
111
|
+
<div className="row">
|
|
112
|
+
<button type="button" disabled={busy} onClick={() => void ask(() => door.turn(!door.on))}>{door.on ? "Shut the door" : "Open the door"}</button>
|
|
113
|
+
<span className={door.on ? "small good" : "dim small"} role="status">{door.on ? "Open, on this computer only." : "Shut. Nothing can reach the adviser."}</span>
|
|
114
|
+
</div>
|
|
115
|
+
{door.on && door.url !== null && (
|
|
116
|
+
<>
|
|
117
|
+
<div className="keybox">
|
|
118
|
+
<div><span className="label">Where it is</span></div>
|
|
119
|
+
<code className="wrap">{door.url}</code>
|
|
120
|
+
</div>
|
|
121
|
+
<div className="row">
|
|
122
|
+
<button type="button" className="quiet" disabled={busy} onClick={() => void ask(async () => { await door.copy(); setCopied(true); setTimeout(() => setCopied(false), 2500); })}>
|
|
123
|
+
{copied ? "Copied" : "Copy the command that connects Claude Code"}
|
|
124
|
+
</button>
|
|
125
|
+
{door.renew !== undefined && <button type="button" className="quiet" disabled={busy} onClick={() => void ask(() => door.renew!())}>Make a new token</button>}
|
|
126
|
+
</div>
|
|
127
|
+
<p className="dim small">The command carries the token, so it goes to the clipboard and is not shown here. Paste it into a terminal once. A new token shuts the door and shuts out whatever had the old one.</p>
|
|
128
|
+
</>
|
|
129
|
+
)}
|
|
130
|
+
</section>
|
|
131
|
+
)}
|
|
132
|
+
|
|
133
|
+
{hosting !== null && (
|
|
134
|
+
<section className="card">
|
|
135
|
+
<h2>What it has done</h2>
|
|
136
|
+
{theirs.length === 0 ? <p className="dim small">It has proposed nothing.</p> : (
|
|
137
|
+
<p className="small">It has proposed {theirs.length} {theirs.length === 1 ? "run" : "runs"}: {theirs.filter((one) => one.settled === null).length} open,{" "}
|
|
138
|
+
{theirs.filter((one) => one.settled !== null && one.settled.run !== null).length} carried out, {theirs.filter((one) => one.settled !== null && one.settled.run === null).length} set aside. Each is at its tool, under Proposed.</p>
|
|
139
|
+
)}
|
|
140
|
+
{door?.seen !== undefined && door.seen.length > 0 && (
|
|
141
|
+
<table>
|
|
142
|
+
<thead><tr><th>When</th><th>It</th><th /></tr></thead>
|
|
143
|
+
<tbody>
|
|
144
|
+
{[...door.seen].reverse().slice(0, 12).map((one, at) => (
|
|
145
|
+
<tr key={`${one.at} ${at}`}>
|
|
146
|
+
<td className="dim">{new Date(one.at).toLocaleTimeString()}</td>
|
|
147
|
+
<td>{adviserDid(one.tool)}</td>
|
|
148
|
+
<td>{one.ok ? "" : <span className="badge">could not</span>}</td>
|
|
149
|
+
</tr>
|
|
150
|
+
))}
|
|
151
|
+
</tbody>
|
|
152
|
+
</table>
|
|
153
|
+
)}
|
|
154
|
+
{onWatch !== undefined && (
|
|
155
|
+
<div className="row">
|
|
156
|
+
<button type="button" onClick={onWatch}>Watch it work</button>
|
|
157
|
+
<span className="dim small">The lab, with the view going wherever the adviser is looking.</span>
|
|
158
|
+
</div>
|
|
159
|
+
)}
|
|
160
|
+
<p className="dim small">Everything it writes is in History under its own name, like anybody's.</p>
|
|
161
|
+
</section>
|
|
162
|
+
)}
|
|
163
|
+
</>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* What the adviser is doing, said over the lab while it is being watched.
|
|
169
|
+
*
|
|
170
|
+
* Watching is following: the view goes where the adviser last looked. A person can stop following
|
|
171
|
+
* and take the controls, since what is drawn under this is the lab and its tools and not a film of them.
|
|
172
|
+
*
|
|
173
|
+
* @param props - `last` is the latest thing it did, if it has done anything; `following` is whether
|
|
174
|
+
* the view is going where it looks, and `onFollow` changes that; `onBack` leaves.
|
|
175
|
+
*/
|
|
176
|
+
export function AdviserStrip({ last, following, onFollow, onBack }: {
|
|
177
|
+
last: AdviserSeen | null; following: boolean; onFollow: (following: boolean) => void; onBack: () => void;
|
|
178
|
+
}): ReactNode {
|
|
179
|
+
const state = useLab();
|
|
180
|
+
const hosting = state?.hosting ?? null;
|
|
181
|
+
const name = state?.lab?.roster.find((one) => one.key === hosting?.key)?.person ?? "The adviser";
|
|
182
|
+
return (
|
|
183
|
+
<section className="card adviserstrip" aria-live="polite">
|
|
184
|
+
<div className="row">
|
|
185
|
+
<p>
|
|
186
|
+
{last === null ? <span className="dim">{name} has not done anything yet. What it does will be shown here, where it does it.</span>
|
|
187
|
+
: <><strong>{name}</strong> {adviserDid(last.tool)}{last.ok ? "" : ", and could not"} <span className="dim small">at {new Date(last.at).toLocaleTimeString()}</span></>}
|
|
188
|
+
</p>
|
|
189
|
+
<label className="check small"><input type="checkbox" checked={following} onChange={(event) => onFollow(event.target.checked)} /> Follow it</label>
|
|
190
|
+
<button type="button" className="quiet" onClick={onBack}>Back</button>
|
|
191
|
+
</div>
|
|
192
|
+
{!following && <p className="dim small">You have the controls. What it does next is still listed, and the view stays where you put it.</p>}
|
|
193
|
+
</section>
|
|
194
|
+
);
|
|
195
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* - `people.tsx` — the roster, and letting somebody in
|
|
16
16
|
* - `history.tsx` — every signed change, and what became of it
|
|
17
17
|
* - `sharing.tsx` — what other labs are shown, and the lab's web peer
|
|
18
|
+
* - `adviser.tsx` — the adviser a device hosts: letting it in, and the door an agent reaches it by
|
|
18
19
|
* - `parts.tsx` — the small pieces they are made of
|
|
19
20
|
* - `public.tsx` — a lab's public page: what it holds, and what it can see of another lab
|
|
20
21
|
*
|
|
@@ -26,6 +27,7 @@ export * from "./freezer.js";
|
|
|
26
27
|
export * from "./places.js";
|
|
27
28
|
export * from "./backup.js";
|
|
28
29
|
export * from "./people.js";
|
|
30
|
+
export * from "./adviser.js";
|
|
29
31
|
export * from "./history.js";
|
|
30
32
|
export * from "./sharing.js";
|
|
31
33
|
export * from "./parts.js";
|