@hasna/recordings 0.1.33 → 0.1.34

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/cli/index.js CHANGED
@@ -5098,7 +5098,7 @@ var init_pg_migrate = __esm(() => {
5098
5098
  var require_package = __commonJS((exports, module) => {
5099
5099
  module.exports = {
5100
5100
  name: "@hasna/recordings",
5101
- version: "0.1.33",
5101
+ version: "0.1.34",
5102
5102
  type: "module",
5103
5103
  description: "Speech-to-text recording tool with MCP and CLI \u2014 records, transcribes, and optionally enhances text using AI",
5104
5104
  repository: {
@@ -5148,7 +5148,7 @@ var require_package = __commonJS((exports, module) => {
5148
5148
  "LICENSE"
5149
5149
  ],
5150
5150
  dependencies: {
5151
- "@hasna/events": "^0.1.3",
5151
+ "@hasna/events": "^0.1.7",
5152
5152
  "@modelcontextprotocol/sdk": "^1.12.1",
5153
5153
  chalk: "^5.4.1",
5154
5154
  commander: "^13.1.0",
@@ -5736,9 +5736,15 @@ function print(value, json, text) {
5736
5736
  else
5737
5737
  console.log(text);
5738
5738
  }
5739
+ function hasJsonOption(options) {
5740
+ return Boolean(options?.json || options?.opts?.().json || options?.optsWithGlobals?.().json || options?.parent?.opts?.().json || options?.parent?.optsWithGlobals?.().json);
5741
+ }
5742
+ function wantsJson(actionOptions, command) {
5743
+ return hasJsonOption(actionOptions) || hasJsonOption(command);
5744
+ }
5739
5745
  function registerWebhookCommands(program, options) {
5740
5746
  const webhooks = program.command(options.webhooksCommandName ?? "webhooks").description("Manage Hasna event webhook subscriptions");
5741
- webhooks.command("add").description("Add or replace a webhook or command subscription").argument("<target>", "Webhook URL or command binary").requiredOption("--id <id>", "Subscription/channel identifier").option("--transport <kind>", "Transport kind: webhook or command", "webhook").option("--name <name>", "Display name").option("--type <pattern>", "Event type filter, e.g. todos.task.*").option("--source <pattern>", "Event source filter").option("--subject <pattern>", "Event subject filter").option("--severity <pattern>", "Event severity filter").option("--secret <secret>", "Webhook HMAC secret").option("--header <name=value...>", "Webhook header", collectValues, []).option("--arg <arg...>", "Command argument", collectValues, []).option("--timeout-ms <ms>", "Transport timeout in milliseconds", parseNumber).option("--retry-attempts <n>", "Maximum delivery attempts", parseNumber).option("--retry-backoff-ms <ms>", "Initial retry backoff in milliseconds", parseNumber).option("--redact <path...>", "Event field path to redact before delivery", collectValues, []).option("--disabled", "Create channel disabled", false).option("-j, --json", "Print JSON output", false).action(async (target, actionOptions) => {
5747
+ webhooks.command("add").description("Add or replace a webhook or command subscription").argument("<target>", "Webhook URL or command binary").requiredOption("--id <id>", "Subscription/channel identifier").option("--transport <kind>", "Transport kind: webhook or command", "webhook").option("--name <name>", "Display name").option("--type <pattern>", "Event type filter, e.g. todos.task.*").option("--source <pattern>", "Event source filter").option("--subject <pattern>", "Event subject filter").option("--severity <pattern>", "Event severity filter").option("--secret <secret>", "Webhook HMAC secret").option("--header <name=value...>", "Webhook header", collectValues, []).option("--arg <arg...>", "Command argument", collectValues, []).option("--timeout-ms <ms>", "Transport timeout in milliseconds", parseNumber).option("--retry-attempts <n>", "Maximum delivery attempts", parseNumber).option("--retry-backoff-ms <ms>", "Initial retry backoff in milliseconds", parseNumber).option("--redact <path...>", "Event field path to redact before delivery", collectValues, []).option("--disabled", "Create channel disabled", false).option("-j, --json", "Print JSON output", false).action(async (target, actionOptions, command) => {
5742
5748
  const timestamp = new Date().toISOString();
5743
5749
  const channel = {
5744
5750
  id: actionOptions.id,
@@ -5759,11 +5765,11 @@ function registerWebhookCommands(program, options) {
5759
5765
  throw new Error(`Transport ${actionOptions.transport} is reserved for future use and cannot be added yet`);
5760
5766
  }
5761
5767
  const saved = await createClient(options).addChannel(channel);
5762
- print(sanitizeChannelForOutput(saved), Boolean(actionOptions.json), `Added ${saved.transport} channel ${saved.id}`);
5768
+ print(sanitizeChannelForOutput(saved), wantsJson(actionOptions, command), `Added ${saved.transport} channel ${saved.id}`);
5763
5769
  });
5764
- webhooks.command("list").description("List configured subscriptions").option("-j, --json", "Print JSON output", false).action(async (actionOptions) => {
5770
+ webhooks.command("list").description("List configured subscriptions").option("-j, --json", "Print JSON output", false).action(async (actionOptions, command) => {
5765
5771
  const channels = await createClient(options).listChannels();
5766
- if (actionOptions.json) {
5772
+ if (wantsJson(actionOptions, command)) {
5767
5773
  console.log(JSON.stringify(sanitizeChannelsForOutput(channels), null, 2));
5768
5774
  return;
5769
5775
  }
@@ -5775,11 +5781,11 @@ function registerWebhookCommands(program, options) {
5775
5781
  console.log(`${channel.id} ${channel.enabled ? "enabled" : "disabled"} ${channel.transport} ${channel.webhook?.url ?? channel.command?.command ?? channel.transport}`);
5776
5782
  }
5777
5783
  });
5778
- webhooks.command("remove").description("Remove a subscription").argument("<id>", "Subscription/channel identifier").option("-j, --json", "Print JSON output", false).action(async (id, actionOptions) => {
5784
+ webhooks.command("remove").description("Remove a subscription").argument("<id>", "Subscription/channel identifier").option("-j, --json", "Print JSON output", false).action(async (id, actionOptions, command) => {
5779
5785
  const removed = await createClient(options).removeChannel(id);
5780
- print({ removed }, Boolean(actionOptions.json), removed ? `Removed ${id}` : `Channel not found: ${id}`);
5786
+ print({ removed }, wantsJson(actionOptions, command), removed ? `Removed ${id}` : `Channel not found: ${id}`);
5781
5787
  });
5782
- webhooks.command("test").description("Send a test event to one subscription").argument("<id>", "Subscription/channel identifier").option("--type <type>", "Event type", "events.test").option("--subject <subject>", "Event subject").option("--message <message>", "Event message", "Hasna events test delivery").option("--data <json>", "Event data JSON object").option("-j, --json", "Print JSON output", false).action(async (id, actionOptions) => {
5788
+ webhooks.command("test").description("Send a test event to one subscription").argument("<id>", "Subscription/channel identifier").option("--type <type>", "Event type", "events.test").option("--subject <subject>", "Event subject").option("--message <message>", "Event message", "Hasna events test delivery").option("--data <json>", "Event data JSON object").option("-j, --json", "Print JSON output", false).action(async (id, actionOptions, command) => {
5783
5789
  const result = await createClient(options).testChannel(id, {
5784
5790
  source: options.source,
5785
5791
  type: actionOptions.type,
@@ -5787,13 +5793,13 @@ function registerWebhookCommands(program, options) {
5787
5793
  message: actionOptions.message,
5788
5794
  data: parseJsonObject(actionOptions.data, { test: true })
5789
5795
  });
5790
- print(result, Boolean(actionOptions.json), `${result.status}: ${result.channelId}`);
5796
+ print(result, wantsJson(actionOptions, command), `${result.status}: ${result.channelId}`);
5791
5797
  });
5792
5798
  return webhooks;
5793
5799
  }
5794
5800
  function registerEventCommands(program, options) {
5795
5801
  const events = program.command(options.eventsCommandName ?? "events").description("Emit, list, and replay Hasna events");
5796
- events.command("emit").description("Emit an event from this app").argument("<type>", "Event type").option("--source <source>", "Event source override").option("--subject <subject>", "Event subject").option("--severity <severity>", "Event severity", "info").option("--message <message>", "Event message").option("--dedupe-key <key>", "Dedupe key").option("--data <json>", "Event data JSON object").option("--metadata <json>", "Event metadata JSON object").option("--no-deliver", "Record without delivering").option("--no-dedupe", "Allow duplicate id/dedupeKey events").option("-j, --json", "Print JSON output", false).action(async (type, actionOptions) => {
5802
+ events.command("emit").description("Emit an event from this app").argument("<type>", "Event type").option("--source <source>", "Event source override").option("--subject <subject>", "Event subject").option("--severity <severity>", "Event severity", "info").option("--message <message>", "Event message").option("--dedupe-key <key>", "Dedupe key").option("--data <json>", "Event data JSON object").option("--metadata <json>", "Event metadata JSON object").option("--no-deliver", "Record without delivering").option("--no-dedupe", "Allow duplicate id/dedupeKey events").option("-j, --json", "Print JSON output", false).action(async (type, actionOptions, command) => {
5797
5803
  const result = await createClient(options).emit({
5798
5804
  source: actionOptions.source ?? options.source,
5799
5805
  type,
@@ -5804,9 +5810,9 @@ function registerEventCommands(program, options) {
5804
5810
  data: parseJsonObject(actionOptions.data, {}),
5805
5811
  metadata: parseJsonObject(actionOptions.metadata, {})
5806
5812
  }, { deliver: actionOptions.deliver, dedupe: actionOptions.dedupe });
5807
- print(result, Boolean(actionOptions.json), `${result.deduped ? "Deduped" : "Emitted"} ${result.event.id} to ${result.deliveries.length} channel(s)`);
5813
+ print(result, wantsJson(actionOptions, command), `${result.deduped ? "Deduped" : "Emitted"} ${result.event.id} to ${result.deliveries.length} channel(s)`);
5808
5814
  });
5809
- events.command("list").description("List recorded events").option("--source <source>", "Filter by source").option("--type <type>", "Filter by type").option("--limit <n>", "Limit results", parseNumber).option("-j, --json", "Print JSON output", false).action(async (actionOptions) => {
5815
+ events.command("list").description("List recorded events").option("--source <source>", "Filter by source").option("--type <type>", "Filter by type").option("--limit <n>", "Limit results", parseNumber).option("-j, --json", "Print JSON output", false).action(async (actionOptions, command) => {
5810
5816
  let rows = await createClient(options).listEvents();
5811
5817
  if (actionOptions.source)
5812
5818
  rows = rows.filter((event) => event.source === actionOptions.source);
@@ -5814,7 +5820,7 @@ function registerEventCommands(program, options) {
5814
5820
  rows = rows.filter((event) => event.type === actionOptions.type);
5815
5821
  if (actionOptions.limit)
5816
5822
  rows = rows.slice(-actionOptions.limit);
5817
- if (actionOptions.json) {
5823
+ if (wantsJson(actionOptions, command)) {
5818
5824
  console.log(JSON.stringify(rows, null, 2));
5819
5825
  return;
5820
5826
  }
@@ -5825,14 +5831,14 @@ function registerEventCommands(program, options) {
5825
5831
  for (const event of rows)
5826
5832
  console.log(`${event.time} ${event.id} ${event.source} ${event.type} ${event.severity}`);
5827
5833
  });
5828
- events.command("replay").description("Replay recorded events").option("--id <id>", "Replay one event id").option("--source <source>", "Filter by source").option("--type <type>", "Filter by type").option("--dry-run", "Preview without delivery", false).option("-j, --json", "Print JSON output", false).action(async (actionOptions) => {
5834
+ events.command("replay").description("Replay recorded events").option("--id <id>", "Replay one event id").option("--source <source>", "Filter by source").option("--type <type>", "Filter by type").option("--dry-run", "Preview without delivery", false).option("-j, --json", "Print JSON output", false).action(async (actionOptions, command) => {
5829
5835
  const result = await createClient(options).replay({
5830
5836
  eventId: actionOptions.id,
5831
5837
  source: actionOptions.source,
5832
5838
  type: actionOptions.type,
5833
5839
  dryRun: actionOptions.dryRun
5834
5840
  });
5835
- print(result, Boolean(actionOptions.json), `Replayed ${result.events.length} event(s), ${result.deliveries.length} delivery result(s)`);
5841
+ print(result, wantsJson(actionOptions, command), `Replayed ${result.events.length} event(s), ${result.deliveries.length} delivery result(s)`);
5836
5842
  });
5837
5843
  return events;
5838
5844
  }
package/dist/mcp/index.js CHANGED
@@ -4920,7 +4920,7 @@ var require_lib2 = __commonJS((exports, module) => {
4920
4920
  var require_package = __commonJS((exports, module) => {
4921
4921
  module.exports = {
4922
4922
  name: "@hasna/recordings",
4923
- version: "0.1.33",
4923
+ version: "0.1.34",
4924
4924
  type: "module",
4925
4925
  description: "Speech-to-text recording tool with MCP and CLI \u2014 records, transcribes, and optionally enhances text using AI",
4926
4926
  repository: {
@@ -4970,7 +4970,7 @@ var require_package = __commonJS((exports, module) => {
4970
4970
  "LICENSE"
4971
4971
  ],
4972
4972
  dependencies: {
4973
- "@hasna/events": "^0.1.3",
4973
+ "@hasna/events": "^0.1.7",
4974
4974
  "@modelcontextprotocol/sdk": "^1.12.1",
4975
4975
  chalk: "^5.4.1",
4976
4976
  commander: "^13.1.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/recordings",
3
- "version": "0.1.33",
3
+ "version": "0.1.34",
4
4
  "type": "module",
5
5
  "description": "Speech-to-text recording tool with MCP and CLI — records, transcribes, and optionally enhances text using AI",
6
6
  "repository": {
@@ -50,7 +50,7 @@
50
50
  "LICENSE"
51
51
  ],
52
52
  "dependencies": {
53
- "@hasna/events": "^0.1.3",
53
+ "@hasna/events": "^0.1.7",
54
54
  "@modelcontextprotocol/sdk": "^1.12.1",
55
55
  "chalk": "^5.4.1",
56
56
  "commander": "^13.1.0",