@neosh/api 0.2.0 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neosh/api",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "The neosh plugin API. Types are generated from the Rust side and drift-checked in CI.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -366,6 +366,7 @@ export type ApiCall =
366
366
  | { "call": "swarm_probe"; addr: string }
367
367
  | { "call": "swarm_pair"; node: NodeId; name: string; addr?: string | null }
368
368
  | { "call": "swarm_unpair"; node: NodeId }
369
+ | { "call": "swarm_rename"; node: NodeId; name?: string | null }
369
370
  | { "call": "swarm_reconnect"; node: NodeId }
370
371
  | { "call": "swarm_disconnect"; node: NodeId }
371
372
  | { "call": "swarm_strangers" }
@@ -1,6 +1,8 @@
1
1
  // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ import type { ApiCall } from "./ApiCall";
2
3
  import type { BuildId } from "./BuildId";
3
4
  import type { KeyPress } from "./KeyPress";
5
+ import type { SessionId } from "./SessionId";
4
6
  import type { WindowId } from "./WindowId";
5
7
 
6
8
  /**
@@ -32,11 +34,33 @@ export type ClientMessage =
32
34
  * from the workspace anyway, and refusing it would be a worse answer than saying nothing.
33
35
  */
34
36
  build: BuildId;
37
+ /**
38
+ * Open in this conversation. See [`InputEvent::Attached::session`].
39
+ */
40
+ session?: SessionId | null;
35
41
  }
36
42
  | { "kind": "input" }
37
43
  & (
38
44
  | { "type": "ready"; width: number; height: number }
39
- | { "type": "attached"; width: number; height: number }
45
+ | {
46
+ "type": "attached";
47
+ width: number;
48
+ height: number;
49
+ /**
50
+ * Which conversation this terminal would like to open in.
51
+ *
52
+ * `None` — every attach until `neosh "a prompt"` existed — is the ordinary placement: the
53
+ * most recent conversation nobody else is reading, or the screen a workspace nobody was
54
+ * watching kept for whoever came back. That second case is why this cannot be left to
55
+ * "the newest conversation wins": a terminal starting one and then attaching would be
56
+ * handed the abandoned screen instead, and the conversation it had just started would be
57
+ * running somewhere nothing on that screen mentions.
58
+ *
59
+ * A request rather than an instruction: a conversation deleted between the ask and the
60
+ * arrival gets the ordinary placement rather than an error nobody can act on.
61
+ */
62
+ session?: SessionId | null;
63
+ }
40
64
  | { "type": "detached" }
41
65
  | { "type": "key"; key: KeyPress }
42
66
  | { "type": "paste"; text: string }
@@ -65,4 +89,14 @@ export type ClientMessage =
65
89
  )
66
90
  | { "kind": "detach" }
67
91
  | { "kind": "stop" }
68
- | { "kind": "status" };
92
+ | { "kind": "status" }
93
+ | {
94
+ "kind": "call";
95
+ /**
96
+ * Echoed on [`ServerMessage::Called`]. Any string the caller likes — several may be in
97
+ * flight at once, which is the point of it being here rather than implied by order.
98
+ */
99
+ id: string;
100
+ call: ApiCall;
101
+ }
102
+ | { "kind": "subscribe" };
@@ -1,10 +1,29 @@
1
1
  // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
2
  import type { KeyPress } from "./KeyPress";
3
+ import type { SessionId } from "./SessionId";
3
4
  import type { WindowId } from "./WindowId";
4
5
 
5
6
  export type InputEvent =
6
7
  | { "type": "ready"; width: number; height: number }
7
- | { "type": "attached"; width: number; height: number }
8
+ | {
9
+ "type": "attached";
10
+ width: number;
11
+ height: number;
12
+ /**
13
+ * Which conversation this terminal would like to open in.
14
+ *
15
+ * `None` — every attach until `neosh "a prompt"` existed — is the ordinary placement: the
16
+ * most recent conversation nobody else is reading, or the screen a workspace nobody was
17
+ * watching kept for whoever came back. That second case is why this cannot be left to
18
+ * "the newest conversation wins": a terminal starting one and then attaching would be
19
+ * handed the abandoned screen instead, and the conversation it had just started would be
20
+ * running somewhere nothing on that screen mentions.
21
+ *
22
+ * A request rather than an instruction: a conversation deleted between the ask and the
23
+ * arrival gets the ordinary placement rather than an error nobody can act on.
24
+ */
25
+ session?: SessionId | null;
26
+ }
8
27
  | { "type": "detached" }
9
28
  | { "type": "key"; key: KeyPress }
10
29
  | { "type": "paste"; text: string }
@@ -3,14 +3,15 @@
3
3
  /**
4
4
  * How the connection to a peer stands, beyond the fact of it being up or not.
5
5
  *
6
- * `up` is the summary and this is the story, because "not connected" is three different rows on a
6
+ * `up` is the summary and this is the story, because "not connected" is four different rows on a
7
7
  * board: a machine being dialled that has never answered, one that was here and is being dialled
8
- * again, and one nothing is dialling at all — it reached us last time, or it was told to stop.
9
- * `attempt` counts dials since the last success, so a panel can say `try 4` instead of drawing a
10
- * spinner that has been spinning since Tuesday.
8
+ * again, one nothing is dialling at all — it reached us last time, or it was told to stop — and
9
+ * one that answered and is waiting on a person. `attempt` counts dials since the last success, so
10
+ * a panel can say `try 4` instead of drawing a spinner that has been spinning since Tuesday.
11
11
  */
12
12
  export type LinkState =
13
13
  | { "state": "connecting"; attempt: number }
14
14
  | { "state": "up" }
15
+ | { "state": "waiting" }
15
16
  | { "state": "retrying"; attempt: number }
16
17
  | { "state": "down" };
@@ -1,6 +1,8 @@
1
1
  // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ import type { ApiResponse } from "./ApiResponse";
2
3
  import type { BuildId } from "./BuildId";
3
4
  import type { DetachReason } from "./DetachReason";
5
+ import type { PluginEvent } from "./PluginEvent";
4
6
  import type { UiEvent } from "./UiEvent";
5
7
  import type { WorkspaceStatus } from "./WorkspaceStatus";
6
8
 
@@ -12,4 +14,6 @@ export type ServerMessage =
12
14
  | { "kind": "refused"; reason: string; protocol_version: number }
13
15
  | { "kind": "events"; batch: Array<UiEvent> }
14
16
  | { "kind": "detached"; reason: DetachReason }
15
- | { "kind": "status"; status: WorkspaceStatus };
17
+ | { "kind": "status"; status: WorkspaceStatus }
18
+ | { "kind": "called"; id: string; response: ApiResponse }
19
+ | { "kind": "event"; event: PluginEvent };
package/src/index.ts CHANGED
@@ -1641,6 +1641,17 @@ export interface SwarmApi {
1641
1641
  pair(node: NodeId, opts?: { name?: string; addr?: string }): Promise<void>;
1642
1642
  /** Withdraw authorisation and stop connecting. Refuses for a machine your config declared. */
1643
1643
  unpair(node: NodeId): Promise<void>;
1644
+ /**
1645
+ * Call a machine something else — an SSH `Host` alias, and for the same reasons.
1646
+ *
1647
+ * A hostname is chosen by whoever set the machine up, is often `Mac` or `ubuntu` on every box
1648
+ * somebody owns, and is not what its owner calls it. This wins over the announced name
1649
+ * everywhere a `SwarmNode` is read, so every panel agrees; `null` gives the announced name back.
1650
+ *
1651
+ * Refuses for a machine your `config.toml` declared, naming the `name` field to change instead —
1652
+ * an alias stored beside a config peer would be reverted by the next reload.
1653
+ */
1654
+ rename(node: NodeId, name: string | null): Promise<void>;
1644
1655
  /**
1645
1656
  * Dial a down peer again now, rather than waiting out its retry delay.
1646
1657
  *
@@ -2053,6 +2064,9 @@ function build(
2053
2064
  async unpair(node) {
2054
2065
  await c({ call: "swarm_unpair", node });
2055
2066
  },
2067
+ async rename(node, name) {
2068
+ await c({ call: "swarm_rename", node, name });
2069
+ },
2056
2070
  async reconnect(node) {
2057
2071
  await c({ call: "swarm_reconnect", node });
2058
2072
  },