@formstr/mcp 0.3.1 → 0.3.2

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/index.js CHANGED
@@ -24436,8 +24436,21 @@ async function loginNostrConnect(deps, log) {
24436
24436
  perms: NIP46_PERMS
24437
24437
  });
24438
24438
  }
24439
- async function doLogout(signer, pubkey) {
24440
- await signer.logout(pubkey);
24439
+ async function doLogout(signer, target) {
24440
+ if (target) {
24441
+ const match = findAccount(listAccounts(signer), target);
24442
+ if (!match) {
24443
+ throw new Error(
24444
+ `No stored account matching "${target}". Run \`formstr-mcp accounts\` to list them.`
24445
+ );
24446
+ }
24447
+ await signer.logout(match.pubkey);
24448
+ return match;
24449
+ }
24450
+ const active = signer.getActiveAccount();
24451
+ if (!active) return null;
24452
+ await signer.logout(active.pubkey);
24453
+ return active;
24441
24454
  }
24442
24455
  function whoami(signer) {
24443
24456
  return signer.getActiveAccount();
@@ -27521,7 +27534,7 @@ function helpText() {
27521
27534
  "Commands:",
27522
27535
  " run Run the stdio MCP server (default when no command is given).",
27523
27536
  " login Sign in (create / import / bunker URI / QR) and store the key.",
27524
- " logout [npub] Remove a stored account (defaults to the active one).",
27537
+ " logout [npub|hex] Permanently remove a stored account from the keystore (defaults to active).",
27525
27538
  " whoami Print the active account.",
27526
27539
  " accounts List stored accounts ('*' marks the active one).",
27527
27540
  " switch <npub> Set the active account (accepts an npub or hex pubkey).",
@@ -34865,6 +34878,25 @@ function computeResults(responses) {
34865
34878
  return { results, totalVotes: totalVoters };
34866
34879
  }
34867
34880
 
34881
+ // ../agent/src/tools/pubkey.ts
34882
+ function normalizePubkey(value) {
34883
+ const trimmed = value.trim();
34884
+ if (!trimmed) return null;
34885
+ if (/^[0-9a-f]{64}$/i.test(trimmed)) return trimmed.toLowerCase();
34886
+ if (trimmed.startsWith("npub1")) {
34887
+ try {
34888
+ const decoded = nip19_exports.decode(trimmed);
34889
+ if (decoded.type === "npub") return decoded.data;
34890
+ } catch {
34891
+ }
34892
+ }
34893
+ return null;
34894
+ }
34895
+ function normalizePubkeyList(values) {
34896
+ if (!Array.isArray(values)) return [];
34897
+ return values.map((v) => typeof v === "string" ? normalizePubkey(v) : null).filter((p) => !!p);
34898
+ }
34899
+
34868
34900
  // ../agent/src/tools/calendar.ts
34869
34901
  var calendarTools = buildCalendarTools();
34870
34902
  function buildCalendarTools() {
@@ -34904,7 +34936,7 @@ function buildCalendarTools() {
34904
34936
  server.registerTool(
34905
34937
  "create_calendar_event",
34906
34938
  {
34907
- description: "Schedule a calendar event. start/end are ISO 8601. Events default to PRIVATE (encrypted) and are linked into a calendar list \u2014 that is the only way they show on calendar.formstr.app, which renders only events referenced in a calendar list. Pass calendarId to choose which calendar; if omitted and the user already has calendars, this tool returns the list so you can ASK the user which one (then re-run with calendarId). Set isPrivate:false for a public, unencrypted event \u2014 note public events do NOT sync to calendar.formstr.app. participants receive NIP-59 invitations.",
34939
+ description: "Schedule a calendar event. start/end are ISO 8601. Events default to PRIVATE (encrypted) and are linked into a calendar list \u2014 that is the only way they show on calendar.formstr.app, which renders only events referenced in a calendar list. Pass calendarId to choose which calendar; if omitted and the user already has calendars, this tool returns the list so you can ASK the user which one (then re-run with calendarId). Set isPrivate:false for a public, unencrypted event \u2014 note public events do NOT sync to calendar.formstr.app. participants (npub or hex) receive NIP-59 invitations.",
34908
34940
  inputSchema: {
34909
34941
  title: external_exports.string(),
34910
34942
  description: external_exports.string().optional(),
@@ -34944,7 +34976,9 @@ function buildCalendarTools() {
34944
34976
  begin,
34945
34977
  end,
34946
34978
  location: args.location,
34947
- participants: args.participants,
34979
+ // Accept npub OR hex for each participant — the wire (["p"] tags, NIP-59
34980
+ // invitation wraps, relay-list query) needs hex, so convert here.
34981
+ participants: normalizePubkeyList(args.participants),
34948
34982
  isPrivate,
34949
34983
  calendarId: args.calendarId,
34950
34984
  rrule: args.rrule,
@@ -34971,7 +35005,8 @@ function buildCalendarTools() {
34971
35005
  inputSchema: { coordinate: external_exports.string() }
34972
35006
  },
34973
35007
  async ({ coordinate }) => {
34974
- const event = await service_exports2.fetchCalendarEventByCoordinate(coordinate);
35008
+ const viewKey = await service_exports2.lookupEventViewKey(coordinate);
35009
+ const event = await service_exports2.fetchCalendarEventByCoordinate(coordinate, viewKey);
34975
35010
  if (!event) return fail(`No event found for ${coordinate}.`, "NOT_FOUND");
34976
35011
  return ok(`Event "${event.title}".`, {
34977
35012
  event: {
@@ -35222,7 +35257,8 @@ function buildCalendarTools() {
35222
35257
  `updates event ${args.coordinate}`
35223
35258
  );
35224
35259
  if (blocked) return blocked;
35225
- const existing = await service_exports2.fetchCalendarEventByCoordinate(args.coordinate);
35260
+ const viewKey = await service_exports2.lookupEventViewKey(args.coordinate);
35261
+ const existing = await service_exports2.fetchCalendarEventByCoordinate(args.coordinate, viewKey);
35226
35262
  if (!existing) return fail(`No event found for ${args.coordinate}.`, "NOT_FOUND");
35227
35263
  const draft = {
35228
35264
  title: args.title ?? existing.title,
@@ -35264,7 +35300,8 @@ function buildCalendarTools() {
35264
35300
  `attaches a form to ${coordinate}`
35265
35301
  );
35266
35302
  if (blocked) return blocked;
35267
- const existing = await service_exports2.fetchCalendarEventByCoordinate(coordinate);
35303
+ const viewKey = await service_exports2.lookupEventViewKey(coordinate);
35304
+ const existing = await service_exports2.fetchCalendarEventByCoordinate(coordinate, viewKey);
35268
35305
  if (!existing) return fail(`No event found for ${coordinate}.`, "NOT_FOUND");
35269
35306
  const draft = {
35270
35307
  title: existing.title,
@@ -35543,23 +35580,6 @@ function buildDriveTools() {
35543
35580
  }
35544
35581
 
35545
35582
  // ../agent/src/tools/shared.ts
35546
- function normalizePubkey(value) {
35547
- const trimmed = value.trim();
35548
- if (!trimmed) return null;
35549
- if (/^[0-9a-f]{64}$/i.test(trimmed)) return trimmed.toLowerCase();
35550
- if (trimmed.startsWith("npub1")) {
35551
- try {
35552
- const decoded = nip19_exports.decode(trimmed);
35553
- if (decoded.type === "npub") return decoded.data;
35554
- } catch {
35555
- }
35556
- }
35557
- return null;
35558
- }
35559
- function normalizePubkeyList(values) {
35560
- if (!Array.isArray(values)) return [];
35561
- return values.map((v) => typeof v === "string" ? normalizePubkey(v) : null).filter((p) => !!p);
35562
- }
35563
35583
  var ANSWER_TYPES = new Set(Object.values(AnswerType));
35564
35584
  var LEGACY_TYPE_ALIASES = {
35565
35585
  multiChoiceGrid: "multipleChoiceGrid" /* multipleChoiceGrid */
@@ -46593,8 +46613,10 @@ async function main() {
46593
46613
  await runLogin(cli);
46594
46614
  return cli.command;
46595
46615
  case "logout": {
46596
- await doLogout(await buildMcpSigner(), cli.account);
46597
- console.error("formstr-mcp: signed out.");
46616
+ const removed = await doLogout(await buildMcpSigner(), cli.target ?? cli.account);
46617
+ console.error(
46618
+ removed ? `formstr-mcp: removed ${removed.npub} (${removed.method}).` : "formstr-mcp: no account to remove."
46619
+ );
46598
46620
  return cli.command;
46599
46621
  }
46600
46622
  case "whoami": {