Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,18 @@
# T3CODE_MOBILE_IOS_PERSONAL_TEAM=1
# T3CODE_MOBILE_EAS_PROJECT_ID=00000000-0000-0000-0000-000000000000
# T3CODE_MOBILE_EXPO_OWNER=your-expo-username

# Optional: Discord bot Teams intake module (Graph poll → Discord/T3).
# See docs/integrations/microsoft-teams-discord-bot.md
# TEAMS_ENABLED=1
# TEAMS_TENANT_ID=00000000-0000-0000-0000-000000000000
# TEAMS_CLIENT_ID=00000000-0000-0000-0000-000000000000
# TEAMS_CLIENT_SECRET=...
# TEAMS_CHANNELS_PATH=/absolute/path/to/apps/discord-bot/teams.channels.json
# TEAMS_POLL_INTERVAL_SECONDS=60
# TEAMS_BOT_DISPLAY_NAME=T3 Code
# Native Teams SDK endpoint (Discord-free replacement mode)
# TEAMS_NATIVE_ENABLED=1
# TEAMS_PORT=3978
# TEAMS_MESSAGING_ENDPOINT=/api/messages
# TEAMS_DEFAULT_PROJECT_SHORT_NAME=my-project
3 changes: 3 additions & 0 deletions apps/discord-bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
"scripts": {
"browser-profile": "node --import tsx src/browserProfileCli.ts",
"dev": "node --watch --import tsx src/main.ts",
"dev:teams": "node --watch --import tsx src/teams-main.ts",
"start": "node --import tsx src/main.ts",
"start:teams": "node --import tsx src/teams-main.ts",
"typecheck": "tsgo --noEmit",
"test": "vp test run"
},
"dependencies": {
"@effect/platform-node": "catalog:",
"@microsoft/teams.apps": "2.0.14",
"@t3tools/client-runtime": "workspace:*",
"@t3tools/contracts": "workspace:*",
"@t3tools/shared": "workspace:*",
Expand Down
11 changes: 11 additions & 0 deletions apps/discord-bot/src/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ const baseConfig = {
browserFfmpegPath: "ffmpeg",
browserAllowedOrigins: [],
jiraBrowseBaseUrl: "https://example.atlassian.net",
teamsEnabled: false,
teamsTenantId: undefined,
teamsClientId: undefined,
teamsClientSecret: undefined,
teamsChannelsPath: undefined,
teamsPollIntervalSeconds: 60,
teamsBotDisplayName: undefined,
teamsNativeEnabled: false,
teamsPort: 3978,
teamsMessagingEndpoint: "/api/messages" as const,
teamsDefaultProjectShortName: undefined,
} satisfies DiscordBotConfig;

describe("preferredModelSelection", () => {
Expand Down
68 changes: 66 additions & 2 deletions apps/discord-bot/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as Redacted from "effect/Redacted";
import * as Schema from "effect/Schema";

export interface DiscordBotConfig {
readonly discordToken: string;
readonly discordToken: string | undefined;
readonly t3HttpBaseUrl: string;
readonly t3BootstrapCredential: string | undefined;
readonly t3BearerToken: string | undefined;
Expand Down Expand Up @@ -59,6 +59,20 @@ export interface DiscordBotConfig {
* (e.g. `https://example.atlassian.net`).
*/
readonly jiraBrowseBaseUrl: string | undefined;
/** Optional Microsoft Teams intake module (Graph channel polling → Discord/T3). */
readonly teamsEnabled: boolean;
readonly teamsTenantId: string | undefined;
readonly teamsClientId: string | undefined;
readonly teamsClientSecret: string | undefined;
readonly teamsChannelsPath: string | undefined;
readonly teamsPollIntervalSeconds: number;
readonly teamsBotDisplayName: string | undefined;
/** Run the native Teams SDK activity/message-extension endpoint. */
readonly teamsNativeEnabled: boolean;
readonly teamsPort: number;
readonly teamsMessagingEndpoint: `/${string}`;
/** Fallback alias for personal/group chats that do not map to a configured channel. */
readonly teamsDefaultProjectShortName: string | undefined;
}

const RuntimeModeConfig = Schema.Literals([
Expand All @@ -74,7 +88,8 @@ const DEFAULT_BOT_MODEL = DEFAULT_MODEL;
export const DiscordBotConfig: Effect.Effect<DiscordBotConfig, Config.ConfigError> = Effect.gen(
function* () {
const discordToken = yield* Config.redacted("DISCORD_BOT_TOKEN").pipe(
Config.map((value) => Redacted.value(value)),
Config.option,
Config.map((value) => (Option.isSome(value) ? Redacted.value(value.value) : undefined)),
);
const t3HttpBaseUrl = yield* Config.string("T3_HTTP_BASE_URL").pipe(
Config.withDefault("http://127.0.0.1:3773"),
Expand Down Expand Up @@ -167,6 +182,44 @@ export const DiscordBotConfig: Effect.Effect<DiscordBotConfig, Config.ConfigErro
return undefined;
}),
);
const teamsEnabled = yield* Config.boolean("TEAMS_ENABLED").pipe(Config.withDefault(false));
const teamsTenantId = yield* Config.string("TEAMS_TENANT_ID").pipe(
Config.option,
Config.map(Option.getOrUndefined),
);
const teamsClientId = yield* Config.string("TEAMS_CLIENT_ID").pipe(
Config.option,
Config.map(Option.getOrUndefined),
);
const teamsClientSecret = yield* Config.redacted("TEAMS_CLIENT_SECRET").pipe(
Config.option,
Config.map((value) => (Option.isSome(value) ? Redacted.value(value.value) : undefined)),
);
const teamsChannelsPath = yield* Config.string("TEAMS_CHANNELS_PATH").pipe(
Config.option,
Config.map(Option.getOrUndefined),
);
const teamsPollIntervalSeconds = yield* Config.int("TEAMS_POLL_INTERVAL_SECONDS").pipe(
Config.withDefault(60),
);
const teamsBotDisplayName = yield* Config.string("TEAMS_BOT_DISPLAY_NAME").pipe(
Config.option,
Config.map(Option.getOrUndefined),
);
const teamsNativeEnabled = yield* Config.boolean("TEAMS_NATIVE_ENABLED").pipe(
Config.withDefault(false),
);
const teamsPort = yield* Config.int("TEAMS_PORT").pipe(Config.withDefault(3978));
const teamsMessagingEndpoint = yield* Config.string("TEAMS_MESSAGING_ENDPOINT").pipe(
Config.withDefault("/api/messages"),
Config.map((value) => {
const normalized = value.trim();
return (normalized.startsWith("/") ? normalized : `/${normalized}`) as `/${string}`;
}),
);
const teamsDefaultProjectShortName = yield* Config.string(
"TEAMS_DEFAULT_PROJECT_SHORT_NAME",
).pipe(Config.option, Config.map(Option.getOrUndefined));

return {
discordToken,
Expand All @@ -191,6 +244,17 @@ export const DiscordBotConfig: Effect.Effect<DiscordBotConfig, Config.ConfigErro
browserFfmpegPath,
browserAllowedOrigins,
jiraBrowseBaseUrl,
teamsEnabled,
teamsTenantId,
teamsClientId,
teamsClientSecret,
teamsChannelsPath,
teamsPollIntervalSeconds,
teamsBotDisplayName,
teamsNativeEnabled,
teamsPort,
teamsMessagingEndpoint,
teamsDefaultProjectShortName,
} satisfies DiscordBotConfig;
},
);
Expand Down
Loading