niahere 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.
@@ -146,14 +146,10 @@ export function loadConfig(): Config {
146
146
  const chSms = (ch.sms || {}) as Record<string, unknown>;
147
147
  const chWa = (ch.whatsapp || {}) as Record<string, unknown>;
148
148
 
149
- // Helper: read a value from `channels.twilio.<newKey>`, falling back to
150
- // legacy `channels.phone.<oldKey>` (the pre-refactor location), then env.
151
- const twilioOrPhone = (newKey: string, oldKey: string, envKey: string | null): string | null => {
149
+ const twilioField = (key: string, envKey: string | null): string | null => {
152
150
  const envVal = envKey ? process.env[envKey] : undefined;
153
151
  if (envVal) return envVal;
154
- if (typeof chTw[newKey] === "string") return chTw[newKey] as string;
155
- if (typeof chPh[oldKey] === "string") return chPh[oldKey] as string;
156
- return null;
152
+ return typeof chTw[key] === "string" ? (chTw[key] as string) : null;
157
153
  };
158
154
 
159
155
  const channelsEnabled = ch.enabled !== false;
@@ -174,11 +170,7 @@ export function loadConfig(): Config {
174
170
 
175
171
  const slAppToken = process.env.SLACK_APP_TOKEN || (typeof chSl.app_token === "string" ? chSl.app_token : null);
176
172
 
177
- // Legacy: channel_id was removed in favor of dm_user_id. Fall back to channel_id if dm_user_id is not set.
178
- const legacyChannelId =
179
- process.env.SLACK_CHANNEL_ID || (typeof chSl.channel_id === "string" ? chSl.channel_id : null);
180
- const slDmUserId =
181
- process.env.SLACK_DM_USER_ID || (typeof chSl.dm_user_id === "string" ? chSl.dm_user_id : null) || legacyChannelId;
173
+ const slDmUserId = process.env.SLACK_DM_USER_ID || (typeof chSl.dm_user_id === "string" ? chSl.dm_user_id : null);
182
174
 
183
175
  const slBotUserId = typeof chSl.bot_user_id === "string" ? chSl.bot_user_id : null;
184
176
  const slBotName = typeof chSl.bot_name === "string" ? chSl.bot_name : null;
@@ -187,15 +179,12 @@ export function loadConfig(): Config {
187
179
  const slWorkspaceUrl = typeof chSl.workspace_url === "string" ? chSl.workspace_url : null;
188
180
 
189
181
  // --- Twilio shared config (used by phone, sms, whatsapp) ---
190
- // New shape: channels.twilio.{sid,secret,auth_token,owner_number,allowlist,public_base_url,port}.
191
- // Legacy shape kept for one release: channels.phone.{twilio_sid,twilio_secret,twilio_auth_token,
192
- // owner_number,allowlist,public_base_url,port}. Env vars take precedence over both.
193
- const twSid = twilioOrPhone("sid", "twilio_sid", "TWILIO_SID");
194
- const twSecret = twilioOrPhone("secret", "twilio_secret", "TWILIO_SECRET");
195
- const twAuthToken = twilioOrPhone("auth_token", "twilio_auth_token", "TWILIO_AUTH_TOKEN");
196
- const twOwnerNumber = twilioOrPhone("owner_number", "owner_number", "PRIMARY_PHONE_USER");
197
- const twPublicBaseUrl =
198
- (twilioOrPhone("public_base_url", "public_base_url", "PUBLIC_BASE_URL") || "").replace(/\/$/, "") || null;
182
+ // Env vars take precedence over channels.twilio.* values.
183
+ const twSid = twilioField("sid", "TWILIO_SID");
184
+ const twSecret = twilioField("secret", "TWILIO_SECRET");
185
+ const twAuthToken = twilioField("auth_token", "TWILIO_AUTH_TOKEN");
186
+ const twOwnerNumber = twilioField("owner_number", "PRIMARY_PHONE_USER");
187
+ const twPublicBaseUrl = (twilioField("public_base_url", "PUBLIC_BASE_URL") || "").replace(/\/$/, "") || null;
199
188
 
200
189
  const twPortRaw = process.env.PHONE_PORT ? Number(process.env.PHONE_PORT) : null;
201
190
  const twPort =
@@ -203,23 +192,19 @@ export function loadConfig(): Config {
203
192
  ? twPortRaw
204
193
  : typeof chTw.port === "number"
205
194
  ? chTw.port
206
- : typeof chPh.port === "number"
207
- ? chPh.port
208
- : DEFAULTS.channels.twilio.port;
195
+ : DEFAULTS.channels.twilio.port;
209
196
 
210
197
  const twAllowlistRaw =
211
198
  process.env.PHONE_ALLOWLIST ||
212
199
  (Array.isArray(chTw.allowlist)
213
200
  ? (chTw.allowlist as unknown[]).filter((x): x is string => typeof x === "string").join(",")
214
- : Array.isArray(chPh.allowlist)
215
- ? (chPh.allowlist as unknown[]).filter((x): x is string => typeof x === "string").join(",")
216
- : "");
201
+ : "");
217
202
  const twAllowlist = twAllowlistRaw
218
203
  .split(",")
219
204
  .map((s) => s.trim())
220
205
  .filter((s) => s.length > 0);
221
206
 
222
- // --- Phone (voice) — env vars and new keys override legacy ---
207
+ // --- Phone (voice) — env vars override config ---
223
208
  const phFromNumber =
224
209
  process.env.PHONE_FROM_NUMBER || (typeof chPh.from_number === "string" ? chPh.from_number : null);
225
210
  const phOpenAiKey =