chatroom-cli 1.144.2 → 1.144.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.
package/dist/index.js CHANGED
@@ -48907,6 +48907,11 @@ var init_errorCodes = __esm(() => {
48907
48907
  FILE_ATTACHMENTS_REQUIRE_USER_TARGET: "FILE_ATTACHMENTS_REQUIRE_USER_TARGET",
48908
48908
  FILE_UPLOADS_UNAVAILABLE: "FILE_UPLOADS_UNAVAILABLE",
48909
48909
  WEB_SESSION_REQUIRED: "WEB_SESSION_REQUIRED",
48910
+ INTEGRATION_NOT_FOUND: "INTEGRATION_NOT_FOUND",
48911
+ INTEGRATION_WRONG_PLATFORM: "INTEGRATION_WRONG_PLATFORM",
48912
+ INTEGRATION_DISABLED: "INTEGRATION_DISABLED",
48913
+ INTEGRATION_NOT_CONFIGURED: "INTEGRATION_NOT_CONFIGURED",
48914
+ TELEGRAM_SEND_FAILED: "TELEGRAM_SEND_FAILED",
48910
48915
  CONFLICT: "CONFLICT"
48911
48916
  };
48912
48917
  FATAL_ERROR_CODES = [
@@ -49027,6 +49032,11 @@ var init_errorCodes = __esm(() => {
49027
49032
  BACKEND_ERROR_CODES.TEAM_REQUIRED,
49028
49033
  BACKEND_ERROR_CODES.WEBHOOK_REGISTRATION_FAILED,
49029
49034
  BACKEND_ERROR_CODES.WEBHOOK_REMOVAL_FAILED,
49035
+ BACKEND_ERROR_CODES.INTEGRATION_NOT_FOUND,
49036
+ BACKEND_ERROR_CODES.INTEGRATION_WRONG_PLATFORM,
49037
+ BACKEND_ERROR_CODES.INTEGRATION_DISABLED,
49038
+ BACKEND_ERROR_CODES.INTEGRATION_NOT_CONFIGURED,
49039
+ BACKEND_ERROR_CODES.TELEGRAM_SEND_FAILED,
49030
49040
  BACKEND_ERROR_CODES.OAUTH_ERROR,
49031
49041
  BACKEND_ERROR_CODES.LOGIN_ERROR,
49032
49042
  BACKEND_ERROR_CODES.WORKFLOW_REQUIRED,
@@ -87799,6 +87809,89 @@ var init_get_role_guidance = __esm(() => {
87799
87809
  init_shared();
87800
87810
  });
87801
87811
 
87812
+ // src/commands/integrations/index.ts
87813
+ var exports_integrations = {};
87814
+ __export(exports_integrations, {
87815
+ listIntegrationsEffect: () => listIntegrationsEffect,
87816
+ listIntegrations: () => listIntegrations
87817
+ });
87818
+ function toIntegrationSummary(i3) {
87819
+ return {
87820
+ integrationId: i3._id,
87821
+ platform: i3.platform,
87822
+ name: i3.name ?? null,
87823
+ description: i3.description ?? null,
87824
+ enabled: i3.enabled,
87825
+ chatId: i3.config.chatId ?? null,
87826
+ createdAt: i3.createdAt,
87827
+ updatedAt: i3.updatedAt
87828
+ };
87829
+ }
87830
+ function singleLine2(text) {
87831
+ return sanitizeForTerminal(text).replace(/\s+/g, " ").trim();
87832
+ }
87833
+ function printIntegrations(chatroomId, platform, summaries) {
87834
+ const room = singleLine2(chatroomId);
87835
+ if (summaries.length === 0) {
87836
+ const label = platform ? `${singleLine2(platform)} integrations` : "integrations";
87837
+ console.log(`No ${label} found for chatroom ${room}.`);
87838
+ console.log("\uD83D\uDCA1 Integrations are set up in the web app: chatroom settings → Integrations.");
87839
+ return;
87840
+ }
87841
+ console.log(`Integrations for chatroom ${room} (${summaries.length}):`);
87842
+ for (const s of summaries) {
87843
+ console.log("");
87844
+ console.log(` ${singleLine2(s.integrationId)}`);
87845
+ console.log(` Platform: ${singleLine2(s.platform)}`);
87846
+ console.log(` Name: ${s.name ? singleLine2(s.name) || "(unnamed)" : "(unnamed)"}`);
87847
+ console.log(` Description: ${s.description ? singleLine2(s.description) || "(none)" : "(none)"}`);
87848
+ console.log(` Status: ${s.enabled ? "enabled" : "disabled"}`);
87849
+ console.log(` Chat ID: ${s.chatId ? singleLine2(s.chatId) || "(not set)" : "(not set)"}`);
87850
+ }
87851
+ console.log("");
87852
+ console.log(`\uD83D\uDCA1 Send to one: chatroom telegram send-message --chatroom-id=${room} --integration-id=<integration-id> --message="..." --role=<your-role>`);
87853
+ }
87854
+ function handleListIntegrationsError(err2) {
87855
+ return exports_Effect.sync(() => {
87856
+ switch (err2._tag) {
87857
+ case "NotAuthenticated":
87858
+ formatAuthError(err2.convexUrl, err2.otherUrls);
87859
+ break;
87860
+ case "InvalidChatroomId":
87861
+ formatChatroomIdError(err2.id);
87862
+ break;
87863
+ case "QueryFailed":
87864
+ console.error(`❌ Failed to list integrations: ${getErrorMessage(err2.cause)}`);
87865
+ break;
87866
+ }
87867
+ process.exit(1);
87868
+ });
87869
+ }
87870
+ async function listIntegrations(options, deps) {
87871
+ const d = deps ?? await createConvexCommandDeps();
87872
+ await exports_Effect.runPromise(listIntegrationsEffect(options).pipe(exports_Effect.catch((err2) => handleListIntegrationsError(err2)), exports_Effect.provide(commandServicesLayerFromDeps(d))));
87873
+ }
87874
+ var listIntegrationsEffect = (options) => exports_Effect.gen(function* () {
87875
+ const backend2 = yield* BackendService;
87876
+ const sessionId = yield* requireSessionForChatroomEffect({ chatroomId: options.chatroomId });
87877
+ const rows = yield* backend2.query(api.integrations.list, {
87878
+ sessionId,
87879
+ chatroomId: options.chatroomId
87880
+ }).pipe(exports_Effect.mapError((cause) => ({ _tag: "QueryFailed", cause })));
87881
+ const platform = options.platform?.trim().toLowerCase();
87882
+ const summaries = (rows ?? []).map(toIntegrationSummary).filter((s) => !platform || s.platform.toLowerCase() === platform);
87883
+ yield* exports_Effect.sync(() => options.format === "json" ? console.log(JSON.stringify({ integrations: summaries }, null, 2)) : printIntegrations(options.chatroomId, platform, summaries));
87884
+ });
87885
+ var init_integrations = __esm(() => {
87886
+ init_dist();
87887
+ init_api3();
87888
+ init_create_convex_command_deps();
87889
+ init_services();
87890
+ init_convex_error();
87891
+ init_error_formatting();
87892
+ init_terminal_safety();
87893
+ });
87894
+
87802
87895
  // src/commands/telegram/index.ts
87803
87896
  var exports_telegram = {};
87804
87897
  __export(exports_telegram, {
@@ -87853,10 +87946,15 @@ function handleSendMessageError(err2) {
87853
87946
  } else if (err2._tag === "InvalidChatroomId") {
87854
87947
  console.error(`❌ Invalid chatroom ID format: ID must be 20-40 characters (got ${err2.id?.length || 0})`);
87855
87948
  process.exit(1);
87949
+ } else if (err2._tag === "InvalidIntegrationId") {
87950
+ console.error(`❌ Invalid integration ID format: ${sanitizeForTerminal(err2.id)}`);
87951
+ console.error(`\uD83D\uDCA1 Find it with: chatroom integrations list --chatroom-id=${sanitizeForTerminal(err2.chatroomId)} --platform=telegram`);
87952
+ process.exit(1);
87856
87953
  } else if (err2._tag === "EmptyMessage") {
87857
87954
  console.error("❌ Message cannot be empty");
87858
87955
  console.error(` Provide a message via --message flag
87859
- Example: chatroom telegram send-message --chatroom-id=<id> --integration-id=<id> --message="Hello"`);
87956
+ Example: chatroom telegram send-message --chatroom-id=<id> --integration-id=<id> --message="Hello"
87957
+ (--integration-id comes from: chatroom integrations list --chatroom-id=<id>)`);
87860
87958
  process.exit(1);
87861
87959
  } else if (err2._tag === "ActionFailed") {
87862
87960
  console.error(`
@@ -87865,6 +87963,9 @@ function handleSendMessageError(err2) {
87865
87963
  const errorData = err2.cause.data;
87866
87964
  console.error(`
87867
87965
  ${errorData.message || "An unexpected error occurred"}`);
87966
+ if (getConvexErrorCode(err2.cause) === "INTEGRATION_NOT_FOUND") {
87967
+ console.error(`\uD83D\uDCA1 Find it with: chatroom integrations list --chatroom-id=${sanitizeForTerminal(err2.chatroomId)} --platform=telegram`);
87968
+ }
87868
87969
  if (process.env.CHATROOM_DEBUG === "true") {
87869
87970
  console.error(`
87870
87971
  \uD83D\uDD0D Debug Info:`);
@@ -87893,7 +87994,7 @@ async function sendMessage(options, deps) {
87893
87994
  }
87894
87995
  var sendMessageEffect = (options) => exports_Effect.gen(function* () {
87895
87996
  const backend2 = yield* BackendService;
87896
- const { chatroomId, message, role } = options;
87997
+ const { chatroomId, integrationId, message, role } = options;
87897
87998
  const sessionId = yield* requireSessionIdEffect((a) => ({
87898
87999
  _tag: "NotAuthenticated",
87899
88000
  convexUrl: a.convexUrl,
@@ -87903,6 +88004,13 @@ var sendMessageEffect = (options) => exports_Effect.gen(function* () {
87903
88004
  _tag: "InvalidChatroomId",
87904
88005
  id
87905
88006
  }));
88007
+ if (!/^[a-z0-9]{20,40}$/.test(integrationId)) {
88008
+ return yield* exports_Effect.fail({
88009
+ _tag: "InvalidIntegrationId",
88010
+ id: integrationId,
88011
+ chatroomId
88012
+ });
88013
+ }
87906
88014
  if (!message || message.trim().length === 0) {
87907
88015
  return yield* exports_Effect.fail({ _tag: "EmptyMessage" });
87908
88016
  }
@@ -87910,14 +88018,21 @@ var sendMessageEffect = (options) => exports_Effect.gen(function* () {
87910
88018
  const result3 = yield* backend2.action(api.integrations.telegram.actions.sendMessage, {
87911
88019
  sessionId,
87912
88020
  chatroomId,
88021
+ integrationId,
87913
88022
  message,
87914
88023
  senderRole
87915
- }).pipe(exports_Effect.mapError((cause) => ({ _tag: "ActionFailed", cause })));
88024
+ }).pipe(exports_Effect.mapError((cause) => ({ _tag: "ActionFailed", cause, chatroomId })));
88025
+ if (result3?.success !== true) {
88026
+ return yield* exports_Effect.fail({
88027
+ _tag: "ActionFailed",
88028
+ cause: new Error("Unexpected response from backend; the message may not have been delivered"),
88029
+ chatroomId
88030
+ });
88031
+ }
87916
88032
  yield* exports_Effect.sync(() => {
87917
- if (result3?.success) {
87918
- console.log("✅ Message sent to Telegram");
87919
- console.log(`\uD83D\uDCE8 "${message}"`);
87920
- }
88033
+ console.log("✅ Message sent to Telegram");
88034
+ console.log(` Integration: ${integrationId}`);
88035
+ console.log(`\uD83D\uDCE8 "${message}"`);
87921
88036
  });
87922
88037
  });
87923
88038
  var init_telegram = __esm(() => {
@@ -87927,6 +88042,8 @@ var init_telegram = __esm(() => {
87927
88042
  init_storage();
87928
88043
  init_client2();
87929
88044
  init_services();
88045
+ init_convex_error();
88046
+ init_terminal_safety();
87930
88047
  });
87931
88048
 
87932
88049
  // src/daemon/entry/capabilities-snapshot.ts
@@ -124145,8 +124262,21 @@ registerChatroomRoleCommand(program2, {
124145
124262
  await getRoleGuidance2(chatroomId, { role });
124146
124263
  }
124147
124264
  });
124265
+ var integrationsCommand = program2.command("integrations").description("Chat platform integrations for a chatroom (read-only)");
124266
+ integrationsCommand.command("list").description("List a chatroom's integrations (ID, platform, name, description, status, chat ID). Never prints secrets.").requiredOption("--chatroom-id <id>", "Chatroom identifier").option("--platform <platform>", "Only show integrations for this platform (e.g. telegram)").option("--format <format>", "Output format: text or json", "text").action(async (options) => {
124267
+ if (options.format !== "text" && options.format !== "json") {
124268
+ throw new Error("--format must be text or json");
124269
+ }
124270
+ await maybeRequireAuth();
124271
+ const { listIntegrations: listIntegrations2 } = await Promise.resolve().then(() => (init_integrations(), exports_integrations));
124272
+ await listIntegrations2({
124273
+ chatroomId: options.chatroomId,
124274
+ platform: options.platform,
124275
+ format: options.format
124276
+ });
124277
+ });
124148
124278
  var telegramCommand = program2.command("telegram").description("Telegram integration commands");
124149
- telegramCommand.command("send-message").description("Send a message to a connected Telegram integration").requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--integration-id <id>", "Telegram integration ID").requiredOption("--message <text>", "Message to send").option("--role <role>", "Sender role label (default: user)").action(async (options) => {
124279
+ telegramCommand.command("send-message").description("Send a message to a connected Telegram integration").requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--integration-id <id>", "Telegram integration ID (find it with: chatroom integrations list --chatroom-id=<id> --platform=telegram)").requiredOption("--message <text>", "Message to send").option("--role <role>", "Sender role label shown as [role] (default: user)").action(async (options) => {
124150
124280
  await maybeRequireAuth();
124151
124281
  const { sendMessage: sendMessage2 } = await Promise.resolve().then(() => (init_telegram(), exports_telegram));
124152
124282
  await sendMessage2(options);
@@ -124192,4 +124322,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
124192
124322
  });
124193
124323
  program2.parse();
124194
124324
 
124195
- //# debugId=030D7C51B871E61A64756E2164756E21
124325
+ //# debugId=E81786B5A51D9FFC64756E2164756E21