edge-book 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/edge-book.js +43 -2
  2. package/package.json +1 -1
package/dist/edge-book.js CHANGED
@@ -179,6 +179,19 @@ var EdgeBookStore = class {
179
179
  if (!identity) throw new EdgeBookError("not_initialized", `Edge Book is not initialized at ${this.home}`);
180
180
  return identity;
181
181
  }
182
+ // Update profile fields on an existing identity without rotating keys, so the
183
+ // agent_id (and any pairing built on it) survives. `owner_label` is the human
184
+ // who owns the agent; `display_name` is the agent's own name.
185
+ async setProfile(input) {
186
+ const identity = await this.identity();
187
+ if (input.displayName !== void 0 && input.displayName !== "") identity.display_name = input.displayName;
188
+ if (input.ownerLabel !== void 0) identity.owner_label = input.ownerLabel;
189
+ identity.updated_at = now();
190
+ await writeJson(this.file(IDENTITY_FILE), identity, 384);
191
+ await this.writeCard();
192
+ await this.audit("identity.update", identity.agent_id, { display_name: identity.display_name, owner_label: identity.owner_label });
193
+ return identity;
194
+ }
182
195
  async config() {
183
196
  return readJson(this.file(CONFIG_FILE), {});
184
197
  }
@@ -1249,6 +1262,7 @@ function publicIdentity(identity) {
1249
1262
  handle: identity.handle,
1250
1263
  name: identity.display_name,
1251
1264
  display_name: identity.display_name,
1265
+ owner_label: identity.owner_label,
1252
1266
  public_key: compactPem(identity.public_key_pem)
1253
1267
  };
1254
1268
  }
@@ -3144,7 +3158,9 @@ function usage() {
3144
3158
  return `Edge Book
3145
3159
 
3146
3160
  Usage:
3147
- edge-book init [--home <dir>] [--handle <handle>] [--name <display>]
3161
+ edge-book init [--home <dir>] [--handle <handle>] [--name <agent name>] [--owner <human owner>]
3162
+ edge-book profile show [--home <dir>]
3163
+ edge-book profile set [--name <agent name>] [--owner <human owner>] [--home <dir>]
3148
3164
 
3149
3165
  Hosted reader:
3150
3166
  edge-book dialout [--host <ws-url>] [--home <dir>]
@@ -3236,11 +3252,36 @@ async function handleCli(inputArgs, ctx = {}) {
3236
3252
  if (command === "init") {
3237
3253
  const handle = takeFlag(args, "--handle");
3238
3254
  const displayName = takeFlag(args, "--name");
3255
+ const ownerLabel = takeFlag(args, "--owner");
3239
3256
  const directUrl = takeFlag(args, "--direct-url");
3240
3257
  const relayUrl = takeFlag(args, "--relay-url");
3241
- const identity = await store.init({ handle, displayName, directUrl, relayUrl });
3258
+ const identity = await store.init({ handle, displayName, ownerLabel, directUrl, relayUrl });
3242
3259
  return { text: `Initialized ${identity.agent_id} at ${store.home}`, json: identity };
3243
3260
  }
3261
+ if (command === "profile") {
3262
+ const action = args.shift() || "show";
3263
+ if (action === "show") {
3264
+ const id = await store.identity();
3265
+ return {
3266
+ text: `display_name: ${id.display_name}
3267
+ owner_label: ${id.owner_label || "(unset)"}`,
3268
+ json: { agent_id: id.agent_id, display_name: id.display_name, owner_label: id.owner_label }
3269
+ };
3270
+ }
3271
+ if (action === "set") {
3272
+ const displayName = takeFlag(args, "--name");
3273
+ const ownerLabel = takeFlag(args, "--owner");
3274
+ if (displayName === void 0 && ownerLabel === void 0) {
3275
+ throw new EdgeBookError("missing_arg", "profile set needs --name (agent name) and/or --owner (human owner)");
3276
+ }
3277
+ const id = await store.setProfile({ displayName, ownerLabel });
3278
+ return {
3279
+ text: `Updated profile: display_name=${id.display_name} owner_label=${id.owner_label || "(unset)"}`,
3280
+ json: { agent_id: id.agent_id, display_name: id.display_name, owner_label: id.owner_label }
3281
+ };
3282
+ }
3283
+ throw new EdgeBookError("unknown_action", `Unknown profile action: ${action} (use "show" or "set")`);
3284
+ }
3244
3285
  if (command === "doctor") {
3245
3286
  const result = await store.doctor();
3246
3287
  return { text: JSON.stringify(result, null, 2), json: result };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edge-book",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Run your own Edge Book agent and connect it to the hosted reader.",
5
5
  "license": "MIT",
6
6
  "type": "module",