@ramme-io/devkit 0.2.1 → 0.3.1

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 CHANGED
@@ -79,8 +79,14 @@ validate before sending:
79
79
  - `ramme_list_boards`: your boards, and when each last checked in.
80
80
  - `ramme_board_parts`: what one board has plugged in, whether each part works,
81
81
  and each sensor's latest reading as a Signal (a temperature probe's
82
- `temperature` in °C, say).
82
+ `temperature` in °C, say), plus its settings and the apps it holds.
83
83
  - `ramme_send_app`: sends a validated app to a board, by id or name.
84
+ - `ramme_configure_board`: changes a board's settings: its name, whether its
85
+ screen's light and dark are swapped, which of its apps is on show, and how
86
+ often they take turns. It needs a token that can change settings.
87
+
88
+ No tool installs firmware, or claims or releases a board. Those stay on the
89
+ board's page on ramme.io, for you to do.
84
90
 
85
91
  Claude Code:
86
92
 
@@ -95,4 +101,5 @@ own server, `RAMME_API_URL`) in its environment. Nothing but protocol messages i
95
101
 
96
102
  Everything. A token reaches only your own boards and only what its scopes
97
103
  allow, 60 requests a minute; every app is validated again on arrival; and a
98
- token cannot make tokens, change your account or see anyone else's boards.
104
+ token cannot make tokens, change your account, install firmware or see
105
+ anyone else's boards.
@@ -71,9 +71,22 @@ var createClient = (options) => {
71
71
  boards: async () => (await call("GET", "/api/device/list")).devices,
72
72
  parts: async (deviceId) => {
73
73
  const page = await call("GET", `/api/device/vitals?id=${encodeURIComponent(deviceId)}`);
74
- return { features: page.vitals?.features ?? {}, readings: page.readings ?? [] };
74
+ return {
75
+ features: page.vitals?.features ?? {},
76
+ readings: page.readings ?? [],
77
+ ...page.screen ? { screen: { invert: page.screen.invert } } : {},
78
+ ...page.shelf !== void 0 ? {
79
+ shelf: page.shelf && {
80
+ apps: page.shelf.apps.map((a) => ({ id: a.id, name: a.name })),
81
+ show: page.shelf.show,
82
+ rotateMinutes: page.shelf.rotateMinutes
83
+ }
84
+ } : {}
85
+ };
75
86
  },
76
- send: async (deviceId, document) => await call("POST", "/api/device/send", { deviceId, document })
87
+ send: async (deviceId, document) => await call("POST", "/api/device/send", { deviceId, document }),
88
+ rename: async (deviceId, label) => await call("PATCH", "/api/device/claim", { deviceId, label }),
89
+ change: async (deviceId, change) => await call("POST", "/api/device/shelf", { deviceId, ...change })
77
90
  };
78
91
  };
79
92
  var resolveBoard = (boards, said) => {
@@ -130,7 +143,8 @@ var INSTRUCTIONS = [
130
143
  "Call ramme_app_guide first: it is the format, with its limits.",
131
144
  "Check every app with ramme_validate_app before sending it, and fix what it reports.",
132
145
  "ramme_list_boards shows the boards this token can reach; ramme_board_parts shows what one has plugged in and what its sensors last read;",
133
- "ramme_send_app sends an app to one, by id or by name.",
146
+ "ramme_send_app sends an app to one, by id or by name; ramme_configure_board renames one, swaps its light and dark, puts one of its apps on show or sets how often they rotate.",
147
+ "Installing firmware and claiming or releasing a board are the owner\u2019s, on the board\u2019s page \u2014 no tool does them.",
134
148
  "A board picks up a new app at its next check-in: within about 30 seconds if someone is using it, 5 minutes if idle."
135
149
  ].join(" ");
136
150
  var DOCUMENT = { type: "object", description: "The app document, as JSON \u2014 see ramme_app_guide." };
@@ -169,14 +183,62 @@ var TOOLS = [
169
183
  required: ["board", "document"],
170
184
  additionalProperties: false
171
185
  }
186
+ },
187
+ {
188
+ name: "ramme_configure_board",
189
+ description: "Change one of the owner\u2019s boards\u2019 settings, by its id or name: its name, whether the panel\u2019s light and dark are swapped, which app it holds is on show, and how often its apps rotate. Give only what should change. ramme_board_parts shows the current settings and the apps it holds. Needs a token that can see boards and change their settings.",
190
+ inputSchema: {
191
+ type: "object",
192
+ properties: {
193
+ board: { type: "string", description: "The board\u2019s id or its name." },
194
+ name: { type: "string", description: 'A new name for the board, up to 48 characters; "" clears it.' },
195
+ invertScreen: { type: "boolean", description: "true swaps the panel\u2019s light and dark, for a unit whose screen shows white on black where it should not." },
196
+ show: { type: "string", description: "One of the apps the board holds, by its id or name, to put on show now." },
197
+ rotateMinutes: { type: "integer", minimum: 0, maximum: 1440, description: "Show each app it holds in turn for this many minutes; 0 stays on one." }
198
+ },
199
+ required: ["board"],
200
+ additionalProperties: false
201
+ }
172
202
  }
173
203
  ];
204
+ var plannedChanges = (args, parts) => {
205
+ const changes = [];
206
+ if (args.invertScreen !== void 0) {
207
+ if (typeof args.invertScreen !== "boolean") return { ok: false, message: "invertScreen is true or false." };
208
+ changes.push({ op: "screen", invert: args.invertScreen });
209
+ }
210
+ if (args.show !== void 0) {
211
+ const apps = parts.shelf?.apps ?? [];
212
+ const want = String(args.show).trim().toLowerCase();
213
+ const matches = apps.map((a, index) => ({ ...a, index })).filter((a) => a.id.toLowerCase() === want || a.name.trim().toLowerCase() === want);
214
+ if (matches.length !== 1) {
215
+ const held = apps.map((a) => `\u201C${a.name}\u201D (${a.id})`).join(", ") || "none \u2014 send it one first";
216
+ return { ok: false, message: `${matches.length ? "More than one app" : "No app"} on that board is called \u201C${String(args.show)}\u201D. It holds: ${held}.` };
217
+ }
218
+ changes.push({ op: "show", index: matches[0].index });
219
+ }
220
+ if (args.rotateMinutes !== void 0) {
221
+ const m = args.rotateMinutes;
222
+ if (typeof m !== "number" || !Number.isInteger(m) || m < 0 || m > 1440) return { ok: false, message: "rotateMinutes is a whole number from 0 to 1440." };
223
+ changes.push({ op: "rotate", minutes: m });
224
+ }
225
+ if (args.name !== void 0 && typeof args.name !== "string") return { ok: false, message: "name is text." };
226
+ const rename = typeof args.name === "string" ? args.name : void 0;
227
+ if (rename === void 0 && !changes.length) return { ok: false, message: "Nothing to change: give a name, invertScreen, show or rotateMinutes." };
228
+ return { ok: true, rename, changes };
229
+ };
174
230
  var describeParts = (name, parts, now = Date.now()) => {
175
231
  const features = Object.entries(parts.features);
176
232
  const lines = [name, ""];
177
233
  lines.push(
178
234
  features.length ? `Parts: ${features.map(([k, state]) => `${k} (${state})`).join(", ")}.` : "Parts: not reported yet. Boards say what they have from firmware 2026-10-25 on."
179
235
  );
236
+ if (parts.screen) lines.push(`Screen: ${parts.screen.invert ? "light and dark swapped" : "as wired"}.`);
237
+ if (parts.shelf !== void 0) {
238
+ lines.push(
239
+ parts.shelf && parts.shelf.apps.length ? `Apps: ${parts.shelf.apps.map((a, i) => `\u201C${a.name}\u201D (${a.id})${i === parts.shelf.show ? ", on show" : ""}`).join("; ")}. ${parts.shelf.rotateMinutes ? `They take turns every ${parts.shelf.rotateMinutes} minutes.` : "They do not rotate."}` : "Apps: none sent yet."
240
+ );
241
+ }
180
242
  if (!parts.readings.length) {
181
243
  lines.push("Readings: none. A sensor reports while it is plugged in, at the board\u2019s check-in rhythm.");
182
244
  } else {
@@ -215,6 +277,30 @@ var callTool = async (client, name, args = {}) => {
215
277
  [`Sent \u201C${v.document.name}\u201D to ${board.label ?? board.deviceId} (${board.deviceId}), revision ${sent.revision ?? "?"}. It shows at the board\u2019s next check-in.`, sent.message].filter(Boolean).join(" ")
216
278
  );
217
279
  }
280
+ case "ramme_configure_board": {
281
+ const board = resolveBoard(await client.boards(), String(args.board ?? ""));
282
+ const plan = plannedChanges(args, await client.parts(board.deviceId));
283
+ if (!plan.ok) return text(`Nothing changed. ${plan.message}`, true);
284
+ const done = [];
285
+ let label = board.label;
286
+ try {
287
+ if (plan.rename !== void 0) {
288
+ label = (await client.rename(board.deviceId, plan.rename)).label ?? void 0;
289
+ done.push(label ? `renamed it \u201C${label}\u201D` : "cleared its name");
290
+ }
291
+ for (const change of plan.changes) {
292
+ await client.change(board.deviceId, change);
293
+ done.push(
294
+ change.op === "screen" ? change.invert ? "swapped its light and dark" : "put its light and dark back as wired" : change.op === "rotate" ? change.minutes ? `set its apps to take turns every ${change.minutes} minutes` : "stopped its apps rotating" : "put that app on show"
295
+ );
296
+ }
297
+ } catch (e) {
298
+ if (!done.length) throw e;
299
+ const why = e instanceof RammeApiError ? `${e.message} (${e.code})` : e.message;
300
+ return text(`${board.label ?? board.deviceId} (${board.deviceId}): ${done.join(", ")} \u2014 then stopped: ${why}`, true);
301
+ }
302
+ return text(`${label ?? board.deviceId} (${board.deviceId}): ${done.join(", ")}. It takes effect at the board\u2019s next check-in.`);
303
+ }
218
304
  default:
219
305
  return text(`No tool called ${name}.`, true);
220
306
  }
package/dist/cli.js CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  serveMcp,
15
15
  serverLabel,
16
16
  validateAppText
17
- } from "./chunk-23KDE6U6.js";
17
+ } from "./chunk-IEPOKHAT.js";
18
18
 
19
19
  // src/cli.ts
20
20
  import { readFileSync, realpathSync } from "fs";
package/dist/index.d.ts CHANGED
@@ -25,8 +25,8 @@ declare const describeValidation: (v: Validation) => string;
25
25
 
26
26
  /**
27
27
  * The few ramme.io routes a personal access token can reach: list your
28
- * boards and read one's parts and readings (`boards:read`), and send one an
29
- * app (`boards:send`). Everything is
28
+ * boards and read one's parts and readings (`boards:read`), send one an
29
+ * app (`boards:send`), and change its settings (`boards:configure`). Everything is
30
30
  * authorised by the token; nothing here calls a model, so an agent's own keys
31
31
  * do all the generating.
32
32
  */
@@ -45,7 +45,35 @@ interface Board {
45
45
  interface BoardParts {
46
46
  features: Record<string, DeviceFeatureState>;
47
47
  readings: Signal[];
48
+ /** Whether the panel's light and dark are swapped. Absent from a server older than settings. */
49
+ screen?: {
50
+ invert: boolean;
51
+ };
52
+ /** The apps it holds, which is on show, and how often they rotate (0: they don't). Null before anything was sent. */
53
+ shelf?: BoardShelf | null;
54
+ }
55
+ interface BoardShelf {
56
+ apps: Array<{
57
+ id: string;
58
+ name: string;
59
+ }>;
60
+ show: number;
61
+ rotateMinutes: number;
48
62
  }
63
+ /**
64
+ * One settings change, as the board's page makes it (lib/routes/deviceShelf.ts):
65
+ * swap the panel's light and dark, rotate the shelf, or put one of its apps on show.
66
+ */
67
+ type ShelfChange = {
68
+ op: 'screen';
69
+ invert: boolean;
70
+ } | {
71
+ op: 'rotate';
72
+ minutes: number;
73
+ } | {
74
+ op: 'show';
75
+ index: number;
76
+ };
49
77
  /** What a send answers: the revision the board will draw, and a warning when there is one to pass on. */
50
78
  interface SendResult {
51
79
  revision?: number;
@@ -61,6 +89,12 @@ interface Client {
61
89
  boards(): Promise<Board[]>;
62
90
  parts(deviceId: string): Promise<BoardParts>;
63
91
  send(deviceId: string, document: AppDocument): Promise<SendResult>;
92
+ rename(deviceId: string, label: string): Promise<{
93
+ label: string | null;
94
+ }>;
95
+ change(deviceId: string, change: ShelfChange): Promise<{
96
+ revision?: number;
97
+ }>;
64
98
  }
65
99
  declare const createClient: (options: {
66
100
  base: string;
@@ -153,6 +187,38 @@ declare const TOOLS: readonly [{
153
187
  readonly required: readonly ["board", "document"];
154
188
  readonly additionalProperties: false;
155
189
  };
190
+ }, {
191
+ readonly name: "ramme_configure_board";
192
+ readonly description: "Change one of the owner’s boards’ settings, by its id or name: its name, whether the panel’s light and dark are swapped, which app it holds is on show, and how often its apps rotate. Give only what should change. ramme_board_parts shows the current settings and the apps it holds. Needs a token that can see boards and change their settings.";
193
+ readonly inputSchema: {
194
+ readonly type: "object";
195
+ readonly properties: {
196
+ readonly board: {
197
+ readonly type: "string";
198
+ readonly description: "The board’s id or its name.";
199
+ };
200
+ readonly name: {
201
+ readonly type: "string";
202
+ readonly description: "A new name for the board, up to 48 characters; \"\" clears it.";
203
+ };
204
+ readonly invertScreen: {
205
+ readonly type: "boolean";
206
+ readonly description: "true swaps the panel’s light and dark, for a unit whose screen shows white on black where it should not.";
207
+ };
208
+ readonly show: {
209
+ readonly type: "string";
210
+ readonly description: "One of the apps the board holds, by its id or name, to put on show now.";
211
+ };
212
+ readonly rotateMinutes: {
213
+ readonly type: "integer";
214
+ readonly minimum: 0;
215
+ readonly maximum: 1440;
216
+ readonly description: "Show each app it holds in turn for this many minutes; 0 stays on one.";
217
+ };
218
+ };
219
+ readonly required: readonly ["board"];
220
+ readonly additionalProperties: false;
221
+ };
156
222
  }];
157
223
  /** Run one tool. Every failure is a result the agent can read, never a thrown protocol error. */
158
224
  declare const callTool: (client: Client, name: string, args?: Json) => Promise<Json>;
@@ -161,4 +227,4 @@ declare const handleMessage: (client: Client, message: Json) => Promise<Json | n
161
227
  /** Serve until stdin closes. */
162
228
  declare const serveMcp: (client: Client, input?: Readable, output?: Writable) => Promise<void>;
163
229
 
164
- export { type Board, type Client, DEFAULT_API, RammeApiError, SERVER_INFO, type SendResult, TOOLS, type Validation, apiBase, callTool, createClient, credentialsPath, describeValidation, findToken, forgetToken, handleMessage, resolveBoard, saveToken, serveMcp, validateApp, validateAppText };
230
+ export { type Board, type BoardShelf, type Client, DEFAULT_API, RammeApiError, SERVER_INFO, type SendResult, type ShelfChange, TOOLS, type Validation, apiBase, callTool, createClient, credentialsPath, describeValidation, findToken, forgetToken, handleMessage, resolveBoard, saveToken, serveMcp, validateApp, validateAppText };
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  serveMcp,
17
17
  validateApp,
18
18
  validateAppText
19
- } from "./chunk-23KDE6U6.js";
19
+ } from "./chunk-IEPOKHAT.js";
20
20
  export {
21
21
  DEFAULT_API,
22
22
  RammeApiError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ramme-io/devkit",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "description": "Make Ramme apps on your own machine with your own coding agent: validate an app, list your boards, send it to one — as a CLI or a local MCP server.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://www.ramme.io",
@@ -31,7 +31,7 @@
31
31
  "access": "public"
32
32
  },
33
33
  "dependencies": {
34
- "@ramme-io/shared": "4.1.0"
34
+ "@ramme-io/shared": "4.3.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "^20.14.10",