typeclaw 0.37.7 → 0.38.0

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.
@@ -1,6 +1,14 @@
1
1
  import { z } from 'zod'
2
2
 
3
- export const ADAPTER_IDS = ['discord-bot', 'github', 'line', 'kakaotalk', 'slack-bot', 'telegram-bot'] as const
3
+ export const ADAPTER_IDS = [
4
+ 'discord-bot',
5
+ 'github',
6
+ 'line',
7
+ 'kakaotalk',
8
+ 'slack-bot',
9
+ 'telegram-bot',
10
+ 'webex-bot',
11
+ ] as const
4
12
 
5
13
  export type AdapterId = (typeof ADAPTER_IDS)[number]
6
14
 
@@ -262,6 +270,12 @@ export const channelsSchema = z
262
270
  kakaotalk: adapterSchema.optional(),
263
271
  'slack-bot': adapterSchema.optional(),
264
272
  'telegram-bot': adapterSchema.optional(),
273
+ // Webex bots receive messages in real time over a Mercury WebSocket
274
+ // (agent-messenger's WebexBotListener), the same persistent-socket model
275
+ // as slack-bot (Socket Mode) and discord-bot (Gateway) — no public
276
+ // webhook URL required. Single bot-token auth; config shape is the
277
+ // standard adapterSchema (engagement + history + enabled).
278
+ 'webex-bot': adapterSchema.optional(),
265
279
  })
266
280
  .default({})
267
281
 
@@ -42,6 +42,7 @@ const CHANNEL_LABELS: Record<ChannelKind, string> = {
42
42
  'slack-bot': 'Slack',
43
43
  'discord-bot': 'Discord',
44
44
  'telegram-bot': 'Telegram',
45
+ 'webex-bot': 'Webex',
45
46
  line: 'LINE',
46
47
  kakaotalk: 'KakaoTalk',
47
48
  github: 'GitHub',
@@ -104,7 +105,7 @@ const addSub = defineCommand({
104
105
  // is included here but routed through its own prompt path because it has
105
106
  // three independent secrets (PAT or App private key + webhook secret) and a
106
107
  // structural auth-type flip is forbidden during rotation.
107
- const SETTABLE_ADAPTERS = ['slack-bot', 'discord-bot', 'telegram-bot', 'github'] as const
108
+ const SETTABLE_ADAPTERS = ['slack-bot', 'discord-bot', 'telegram-bot', 'webex-bot', 'github'] as const
108
109
  type SettableAdapter = (typeof SETTABLE_ADAPTERS)[number]
109
110
 
110
111
  const setSub = defineCommand({
@@ -651,6 +652,9 @@ async function runSet(cwd: string, adapter: SettableAdapter): Promise<void> {
651
652
  case 'telegram-bot':
652
653
  await runSetTelegram(cwd)
653
654
  break
655
+ case 'webex-bot':
656
+ await runSetWebex(cwd)
657
+ break
654
658
  case 'slack-bot':
655
659
  await runSetSlack(cwd)
656
660
  break
@@ -680,6 +684,16 @@ async function runSetTelegram(cwd: string): Promise<void> {
680
684
  await maybePromptCredentialRefresh(cwd, CHANNEL_LABELS['telegram-bot'], 'credentials updated')
681
685
  }
682
686
 
687
+ async function runSetWebex(cwd: string): Promise<void> {
688
+ const token = await promptWebexToken()
689
+ const result = await setChannelSecrets(cwd, 'webex-bot', { token })
690
+ if (!result.ok) {
691
+ console.error(errorLine(result.reason))
692
+ process.exit(1)
693
+ }
694
+ await maybePromptCredentialRefresh(cwd, CHANNEL_LABELS['webex-bot'], 'credentials updated')
695
+ }
696
+
683
697
  type SlackSetChoice = 'bot' | 'app' | 'both'
684
698
 
685
699
  async function runSetSlack(cwd: string): Promise<void> {
@@ -778,6 +792,7 @@ type CollectedCredentials =
778
792
  | { channel: 'discord-bot'; discordBotToken: string }
779
793
  | { channel: 'slack-bot'; slackBotToken: string; slackAppToken: string }
780
794
  | { channel: 'telegram-bot'; telegramBotToken: string }
795
+ | { channel: 'webex-bot'; webexBotToken: string }
781
796
  | { channel: 'line'; runLineAuth: (options: { cwd: string }) => Promise<LineAuthResult> }
782
797
  | { channel: 'kakaotalk'; runKakaotalkAuth: (options: { cwd: string }) => Promise<KakaotalkAuthResult> }
783
798
  | {
@@ -804,6 +819,8 @@ async function collectCredentials(
804
819
  }
805
820
  case 'telegram-bot':
806
821
  return { channel, telegramBotToken: await promptTelegramToken() }
822
+ case 'webex-bot':
823
+ return { channel, webexBotToken: await promptWebexToken() }
807
824
  case 'line': {
808
825
  const login = await promptLineLogin(lineSpinnerHolder ? holderSpinnerControl(lineSpinnerHolder) : undefined)
809
826
  return {
@@ -1212,6 +1229,25 @@ async function promptTelegramToken(): Promise<string> {
1212
1229
  return token
1213
1230
  }
1214
1231
 
1232
+ async function promptWebexToken(): Promise<string> {
1233
+ note(
1234
+ [
1235
+ 'Create a bot at https://developer.webex.com/my-apps/new/bot.',
1236
+ 'Copy the Bot Access Token from the bot settings page.',
1237
+ ].join('\n'),
1238
+ 'Get a Webex bot token',
1239
+ )
1240
+ const token = await password({
1241
+ message: 'Webex bot access token',
1242
+ validate: (value) => (value && value.length > 0 ? undefined : 'Token is required'),
1243
+ })
1244
+ if (isCancel(token)) {
1245
+ cancel('Aborted.')
1246
+ process.exit(0)
1247
+ }
1248
+ return token
1249
+ }
1250
+
1215
1251
  async function promptKakaotalkCredentials(
1216
1252
  opts: { defaultEmail?: string } = {},
1217
1253
  ): Promise<{ email: string; password: string }> {
package/src/cli/init.ts CHANGED
@@ -532,6 +532,15 @@ export async function collectWizardInputs(
532
532
  let pendingBackOrigin: StepId | null = null
533
533
  let oauthCredentialsSaved = false
534
534
 
535
+ // One-shot replay of checkpoint answers: while active, choice steps whose
536
+ // answer was seeded auto-advance (running their normal tail) instead of
537
+ // re-prompting. The first interactive prompt or any Back ends the replay
538
+ // (cleared in `onResult`), so back-navigation behaves like a fresh wizard.
539
+ // Secret-entry steps are never in `resumeCovered`, so a checkpointed
540
+ // `authMethod` still drops to its key/login prompt when nothing is on disk.
541
+ const resumeReplay = { active: false }
542
+ const resumeCovered = new Set<StepId>()
543
+
535
544
  // Resume saved wizard answers from a prior unfinished init. `--reset` skips
536
545
  // this entirely (the user asked to re-answer everything). Route through the
537
546
  // shared detectInitProgress() predicate so init/start/restart classify a
@@ -555,6 +564,8 @@ export async function collectWizardInputs(
555
564
  if (decision === 'resume') {
556
565
  seedWizardState(state, sanitized)
557
566
  step = resumeStep(state)
567
+ resumeReplay.active = true
568
+ for (const covered of resumeCoveredSteps(state)) resumeCovered.add(covered)
558
569
  } else {
559
570
  await checkpointStore.clear(cwd)
560
571
  }
@@ -571,6 +582,11 @@ export async function collectWizardInputs(
571
582
  }
572
583
 
573
584
  const onResult = <T>(currentStep: StepId, result: StepResult<T>): StepResult<T> => {
585
+ // Any Back, or any non-auto (interactive) answer, ends the resume replay:
586
+ // from here on the user is driving, so downstream seeded steps prompt
587
+ // normally. Synthesized auto-skips keep replay alive and, as before, leave
588
+ // `pendingBackOrigin` untouched so they never affect double-back abort.
589
+ if (result.kind === 'back' || !result.auto) resumeReplay.active = false
574
590
  if (result.kind === 'back') {
575
591
  if (pendingBackOrigin === currentStep) abort()
576
592
  pendingBackOrigin = currentStep
@@ -580,6 +596,16 @@ export async function collectWizardInputs(
580
596
  return result
581
597
  }
582
598
 
599
+ // Synthesize a step's seeded answer as an auto-advance result during resume
600
+ // replay, so the step runs its normal tail (state assignment, on-disk
601
+ // credential reconstruction, routing) without re-prompting. Returns
602
+ // undefined when replay is off, this step isn't checkpoint-covered, or the
603
+ // value is unset — callers fall back to the real prompt.
604
+ const resumeSkip = <T>(currentStep: StepId, value: T | undefined): StepResult<T> | undefined => {
605
+ if (!resumeReplay.active || !resumeCovered.has(currentStep) || value === undefined) return undefined
606
+ return { kind: 'value', value, auto: true }
607
+ }
608
+
583
609
  const readExistingApiKey = async (providerId: KnownProviderId): Promise<string | null> => {
584
610
  if (reset) return null
585
611
  return await prompts.readExistingApiKey(cwd, providerId)
@@ -725,7 +751,11 @@ export async function collectWizardInputs(
725
751
  }
726
752
 
727
753
  case 'pick-model': {
728
- const result = onResult(step, await prompts.pickModel(catalog.options, state.providerId!, state.model?.ref))
754
+ const result = onResult(
755
+ step,
756
+ resumeSkip(step, state.model) ??
757
+ (await prompts.pickModel(catalog.options, state.providerId!, state.model?.ref)),
758
+ )
729
759
  if (result.kind === 'back') {
730
760
  step = stepBeforeModel(state)
731
761
  break
@@ -758,7 +788,11 @@ export async function collectWizardInputs(
758
788
 
759
789
  case 'pick-vision-vendor': {
760
790
  const visionOptions = catalog.options.filter((o) => o.supportsVision)
761
- const result = onResult(step, await prompts.pickVisionVendor(visionOptions, state.visionVendorId))
791
+ const result: StepResult<KnownProviderVendorId | 'skip'> = onResult(
792
+ step,
793
+ resumeSkip<KnownProviderVendorId | 'skip'>(step, state.visionVendorId) ??
794
+ (await prompts.pickVisionVendor(visionOptions, state.visionVendorId)),
795
+ )
762
796
  if (result.kind === 'back') {
763
797
  step = stepBeforeVision(state)
764
798
  break
@@ -789,7 +823,8 @@ export async function collectWizardInputs(
789
823
  const visionOptions = catalog.options.filter((o) => o.supportsVision)
790
824
  const result = onResult(
791
825
  step,
792
- await prompts.pickVisionProviderVariant(state.visionVendorId!, visionOptions, state.visionProviderId),
826
+ resumeSkip(step, state.visionProviderId) ??
827
+ (await prompts.pickVisionProviderVariant(state.visionVendorId!, visionOptions, state.visionProviderId)),
793
828
  )
794
829
  if (result.kind === 'back') {
795
830
  step = 'pick-vision-vendor'
@@ -810,7 +845,8 @@ export async function collectWizardInputs(
810
845
  const visionOptions = catalog.options.filter((o) => o.supportsVision)
811
846
  const result = onResult(
812
847
  step,
813
- await prompts.pickVisionModel(visionOptions, state.visionProviderId!, state.visionModel?.ref),
848
+ resumeSkip(step, state.visionModel) ??
849
+ (await prompts.pickVisionModel(visionOptions, state.visionProviderId!, state.visionModel?.ref)),
814
850
  )
815
851
  if (result.kind === 'back') {
816
852
  step = 'pick-vision-provider-variant'
@@ -902,7 +938,10 @@ export async function collectWizardInputs(
902
938
  }
903
939
 
904
940
  case 'pick-channel': {
905
- const result: StepResult<ChannelChoice> = onResult(step, await prompts.pickChannel(state.channelChoice))
941
+ const result: StepResult<ChannelChoice> = onResult(
942
+ step,
943
+ resumeSkip(step, state.channelChoice) ?? (await prompts.pickChannel(state.channelChoice)),
944
+ )
906
945
  if (result.kind === 'back') {
907
946
  step = stepBeforePickChannel(state)
908
947
  break
@@ -1037,6 +1076,21 @@ function resumeStep(state: WizardState): StepId {
1037
1076
  return 'pick-vendor'
1038
1077
  }
1039
1078
 
1079
+ // Choice steps whose seeded answer lets resume replay auto-advance them. Only
1080
+ // non-secret picks the checkpoint actually carries — never `enter-api-key` /
1081
+ // `enter-vision-api-key` (key values aren't checkpointed) and never the
1082
+ // reuse-* / channel-flow steps (those reconstruct from disk or collect secrets,
1083
+ // so they must run their own logic, not replay a stored answer).
1084
+ function resumeCoveredSteps(state: WizardState): StepId[] {
1085
+ const covered: StepId[] = []
1086
+ if (state.model !== undefined) covered.push('pick-model')
1087
+ if (state.visionVendorId !== undefined) covered.push('pick-vision-vendor')
1088
+ if (state.visionProviderId !== undefined) covered.push('pick-vision-provider-variant')
1089
+ if (state.visionModel !== undefined) covered.push('pick-vision-model')
1090
+ if (state.channelChoice !== undefined) covered.push('pick-channel')
1091
+ return covered
1092
+ }
1093
+
1040
1094
  function projectCheckpoint(cwd: string, state: WizardState): WizardAnswerCheckpointV1 {
1041
1095
  return checkpointFromSelections({
1042
1096
  cwd,
@@ -7,7 +7,15 @@ import { SecretsBackend } from '@/secrets'
7
7
  const CONFIG_FILE = 'typeclaw.json'
8
8
  const SECRETS_FILE = 'secrets.json'
9
9
 
10
- export const CHANNEL_KINDS = ['slack-bot', 'discord-bot', 'telegram-bot', 'line', 'kakaotalk', 'github'] as const
10
+ export const CHANNEL_KINDS = [
11
+ 'slack-bot',
12
+ 'discord-bot',
13
+ 'telegram-bot',
14
+ 'webex-bot',
15
+ 'line',
16
+ 'kakaotalk',
17
+ 'github',
18
+ ] as const
11
19
 
12
20
  export type ChannelKind = (typeof CHANNEL_KINDS)[number]
13
21
 
@@ -28,6 +28,7 @@ export function buildChannelChecks(): DoctorCheck[] {
28
28
  slackBotCredentials(),
29
29
  discordBotCredentials(),
30
30
  telegramBotCredentials(),
31
+ webexBotCredentials(),
31
32
  lineCredentials(),
32
33
  kakaotalkCredentials(),
33
34
  githubCredentials(),
@@ -65,6 +66,16 @@ function telegramBotCredentials(): DoctorCheck {
65
66
  }
66
67
  }
67
68
 
69
+ function webexBotCredentials(): DoctorCheck {
70
+ return {
71
+ name: 'channel.webex-bot.credentials',
72
+ category: 'channels',
73
+ description: 'webex-bot adapter has WEBEX_BOT_TOKEN',
74
+ applies: (ctx) => ctx.hasAgentFolder,
75
+ run: (ctx) => runTokenAdapterCheck(ctx, 'webex-bot', ['WEBEX_BOT_TOKEN']),
76
+ }
77
+ }
78
+
68
79
  function lineCredentials(): DoctorCheck {
69
80
  return {
70
81
  name: 'channel.line.credentials',
@@ -216,7 +227,7 @@ function githubWebhookDelivery(): DoctorCheck {
216
227
 
217
228
  async function runTokenAdapterCheck(
218
229
  ctx: CheckContext,
219
- adapter: Extract<AdapterId, 'slack-bot' | 'discord-bot' | 'telegram-bot'>,
230
+ adapter: Extract<AdapterId, 'slack-bot' | 'discord-bot' | 'telegram-bot' | 'webex-bot'>,
220
231
  envNames: readonly string[],
221
232
  ): Promise<CheckResult> {
222
233
  const channels = readDeclaredChannels(ctx)
@@ -297,6 +308,7 @@ function fieldNameForEnv(adapter: AdapterId, envName: string): string | undefine
297
308
  'slack-bot': ['botToken', 'appToken'],
298
309
  'discord-bot': ['token'],
299
310
  'telegram-bot': ['token'],
311
+ 'webex-bot': ['token'],
300
312
  }
301
313
  const fields = candidates[adapter]
302
314
  if (!fields) return undefined
package/src/init/index.ts CHANGED
@@ -199,6 +199,7 @@ export type InitOptions = {
199
199
  slackBotToken?: string
200
200
  slackAppToken?: string
201
201
  telegramBotToken?: string
202
+ webexBotToken?: string
202
203
  // When reusing existing channel credentials from a pre-init `secrets.json`,
203
204
  // the CLI passes `with<Adapter>: true` without a corresponding token so the
204
205
  // scaffolded `typeclaw.json` wires the adapter while `writeSecrets` leaves
@@ -207,6 +208,7 @@ export type InitOptions = {
207
208
  withDiscord?: boolean
208
209
  withSlack?: boolean
209
210
  withTelegram?: boolean
211
+ withWebex?: boolean
210
212
  withKakaotalk?: boolean
211
213
  withGithub?: boolean
212
214
  runKakaotalkAuth?: KakaotalkAuthRunner
@@ -243,9 +245,11 @@ export async function runInit({
243
245
  slackBotToken,
244
246
  slackAppToken,
245
247
  telegramBotToken,
248
+ webexBotToken,
246
249
  withDiscord,
247
250
  withSlack,
248
251
  withTelegram,
252
+ withWebex,
249
253
  withKakaotalk = false,
250
254
  withGithub = false,
251
255
  runKakaotalkAuth,
@@ -314,6 +318,7 @@ export async function runInit({
314
318
  const wantsDiscord = withDiscord ?? (discordBotToken !== undefined && discordBotToken !== '')
315
319
  const wantsSlack = withSlack ?? (slackBotToken !== undefined && slackBotToken !== '')
316
320
  const wantsTelegram = withTelegram ?? (telegramBotToken !== undefined && telegramBotToken !== '')
321
+ const wantsWebex = withWebex ?? (webexBotToken !== undefined && webexBotToken !== '')
317
322
  emit({ step: 'scaffold', phase: 'start' })
318
323
  await scaffold(cwd, {
319
324
  model,
@@ -323,6 +328,7 @@ export async function runInit({
323
328
  withDiscord: wantsDiscord,
324
329
  withSlack: wantsSlack,
325
330
  withTelegram: wantsTelegram,
331
+ withWebex: wantsWebex,
326
332
  withKakaotalk,
327
333
  })
328
334
  // Only write the LLM API key on the api-key path. OAuth providers persist
@@ -338,6 +344,7 @@ export async function runInit({
338
344
  slackBotToken,
339
345
  slackAppToken,
340
346
  telegramBotToken,
347
+ webexBotToken,
341
348
  })
342
349
  emit({ step: 'scaffold', phase: 'done' })
343
350
 
@@ -398,6 +405,7 @@ export async function runInit({
398
405
  if (wantsDiscord) configuredChannels.push('discord-bot')
399
406
  if (wantsSlack) configuredChannels.push('slack-bot')
400
407
  if (wantsTelegram) configuredChannels.push('telegram-bot')
408
+ if (wantsWebex) configuredChannels.push('webex-bot')
401
409
  if (withKakaotalk) configuredChannels.push('kakaotalk')
402
410
  if (withGithub) configuredChannels.push('github')
403
411
 
@@ -551,6 +559,7 @@ export type ScaffoldOptions = {
551
559
  withDiscord?: boolean
552
560
  withSlack?: boolean
553
561
  withTelegram?: boolean
562
+ withWebex?: boolean
554
563
  withKakaotalk?: boolean
555
564
  }
556
565
 
@@ -583,6 +592,7 @@ export async function scaffold(root: string, options: ScaffoldOptions = {}): Pro
583
592
  if (options.withDiscord) channels['discord-bot'] = {}
584
593
  if (options.withSlack) channels['slack-bot'] = {}
585
594
  if (options.withTelegram) channels['telegram-bot'] = {}
595
+ if (options.withWebex) channels['webex-bot'] = {}
586
596
  if (options.withKakaotalk) channels.kakaotalk = {}
587
597
  if (Object.keys(channels).length > 0) config.channels = channels
588
598
  // No default `member` match is seeded. A fresh chat agent starts with every
@@ -796,6 +806,7 @@ export async function writeSecrets(
796
806
  slackBotToken,
797
807
  slackAppToken,
798
808
  telegramBotToken,
809
+ webexBotToken,
799
810
  }: {
800
811
  model?: ModelRef | string
801
812
  // Omitted on the OAuth path — credentials live in secrets.json via the OAuth runner.
@@ -806,6 +817,7 @@ export async function writeSecrets(
806
817
  slackBotToken?: string
807
818
  slackAppToken?: string
808
819
  telegramBotToken?: string
820
+ webexBotToken?: string
809
821
  },
810
822
  ): Promise<void> {
811
823
  const providerId = providerForModelRef(model)
@@ -839,6 +851,9 @@ export async function writeSecrets(
839
851
  if (telegramBotToken !== undefined && telegramBotToken !== '') {
840
852
  channelTokens['telegram-bot'] = { token: { value: telegramBotToken } }
841
853
  }
854
+ if (webexBotToken !== undefined && webexBotToken !== '') {
855
+ channelTokens['webex-bot'] = { token: { value: webexBotToken } }
856
+ }
842
857
  if (Object.keys(channelTokens).length === 0) return
843
858
 
844
859
  const backend = new SecretsBackend(join(root, 'secrets.json'))
@@ -865,18 +880,19 @@ export async function readExistingProviderApiKey(root: string, providerId: Known
865
880
  // browser login entirely instead of dragging them through a second OAuth
866
881
  // flow.
867
882
  //
868
- // Mirrors `readExistingProviderApiKey`'s contract — returns `false` when:
869
- // - The provider has no OAuth support (`oauthProviderId === null`)
870
- // - The file doesn't exist
871
- // - The slot exists but has the wrong shape (api-key instead of oauth, or
872
- // missing access_token)
873
- // - The token is empty / whitespace
883
+ // Mirrors `readExistingProviderApiKey`'s contract — returns `false` when the
884
+ // provider has no OAuth support, the file is missing, the slot is api-key
885
+ // shaped, or the access token is absent/blank.
886
+ //
887
+ // The token lives under `access` — pi-ai's secrets.json shape (`{ type:
888
+ // 'oauth', access, refresh, expires, accountId }`), the same field
889
+ // `export-codex-auth-file.ts` reads. NOT `access_token`: that key belongs to
890
+ // the unrelated `~/.codex/auth.json` export (`{ tokens: { access_token } }`).
891
+ // Reading `access_token` here silently returned false for every real
892
+ // credential, re-running the browser login on resume instead of reusing it.
874
893
  //
875
- // We do NOT validate the token's freshness here. A stale access_token still
876
- // counts as "exists" — pi-ai's secrets store handles refresh on first use,
877
- // and surfacing an "expired token" check at init-time would require a
878
- // network call we'd rather not run during a wizard. The runtime will fall
879
- // back to OAuth login on use if refresh fails; that's a separate UX path.
894
+ // Freshness is intentionally not checked: pi-ai refreshes on first use, and a
895
+ // network call mid-wizard isn't worth it.
880
896
  export async function hasExistingOAuthCredentials(root: string, providerId: KnownProviderId): Promise<boolean> {
881
897
  const provider = KNOWN_PROVIDERS[providerId]
882
898
  if (provider.oauthProviderId === null) return false
@@ -885,8 +901,8 @@ export async function hasExistingOAuthCredentials(root: string, providerId: Know
885
901
  const credential = providers[provider.oauthProviderId]
886
902
  if (credential === undefined) return false
887
903
  if (credential.type !== 'oauth') return false
888
- const accessToken = (credential as { access_token?: unknown }).access_token
889
- return typeof accessToken === 'string' && accessToken.trim().length > 0
904
+ const access = (credential as { access?: unknown }).access
905
+ return typeof access === 'string' && access.trim().length > 0
890
906
  }
891
907
 
892
908
  // Detects whether the requested channel already has usable credentials in
@@ -908,7 +924,7 @@ export async function hasExistingOAuthCredentials(root: string, providerId: Know
908
924
  // kakaotalk` anyway — better to re-auth now during init.
909
925
  export async function hasExistingChannelSecrets(
910
926
  root: string,
911
- channel: 'discord' | 'slack' | 'telegram' | 'line' | 'kakaotalk' | 'github',
927
+ channel: 'discord' | 'slack' | 'telegram' | 'webex' | 'line' | 'kakaotalk' | 'github',
912
928
  ): Promise<boolean> {
913
929
  const channels = new SecretsBackend(join(root, 'secrets.json')).tryReadChannelsSync()
914
930
  if (channels === null) return false
@@ -919,6 +935,8 @@ export async function hasExistingChannelSecrets(
919
935
  return hasSecretField(channels['slack-bot'], 'botToken') && hasSecretField(channels['slack-bot'], 'appToken')
920
936
  case 'telegram':
921
937
  return hasSecretField(channels['telegram-bot'], 'token')
938
+ case 'webex':
939
+ return hasSecretField(channels['webex-bot'], 'token')
922
940
  case 'github':
923
941
  // GitHub credentials alone are not enough to scaffold a working
924
942
  // channel: typeclaw.json#channels.github also needs webhookUrl and
@@ -1013,7 +1031,7 @@ function ignoreExists(error: NodeJS.ErrnoException): void {
1013
1031
  // scaffold-test cases above demonstrates how easy it is to lose a single
1014
1032
  // behavior under a mode flag.
1015
1033
 
1016
- export type ChannelKind = 'discord-bot' | 'slack-bot' | 'telegram-bot' | 'line' | 'kakaotalk' | 'github'
1034
+ export type ChannelKind = 'discord-bot' | 'slack-bot' | 'telegram-bot' | 'webex-bot' | 'line' | 'kakaotalk' | 'github'
1017
1035
 
1018
1036
  // Public adapter names match the typeclaw.json `channels.*` keys exactly.
1019
1037
  // The CLI takes these as the optional positional arg, the picker shows
@@ -1023,6 +1041,7 @@ export const CHANNEL_KINDS: ReadonlyArray<ChannelKind> = [
1023
1041
  'slack-bot',
1024
1042
  'discord-bot',
1025
1043
  'telegram-bot',
1044
+ 'webex-bot',
1026
1045
  'line',
1027
1046
  'kakaotalk',
1028
1047
  'github',
@@ -1052,6 +1071,7 @@ export type AddChannelOptions = {
1052
1071
  | { channel: 'discord-bot'; discordBotToken: string }
1053
1072
  | { channel: 'slack-bot'; slackBotToken: string; slackAppToken: string }
1054
1073
  | { channel: 'telegram-bot'; telegramBotToken: string }
1074
+ | { channel: 'webex-bot'; webexBotToken: string }
1055
1075
  | { channel: 'line'; runLineAuth: LineAuthRunner }
1056
1076
  | { channel: 'kakaotalk'; runKakaotalkAuth: KakaotalkAuthRunner }
1057
1077
  | {
@@ -1165,6 +1185,8 @@ function channelSecretsFromOptions(options: AddChannelOptions): ChannelSecrets {
1165
1185
  return { botToken: options.slackBotToken, appToken: options.slackAppToken }
1166
1186
  case 'telegram-bot':
1167
1187
  return { token: options.telegramBotToken }
1188
+ case 'webex-bot':
1189
+ return { token: options.webexBotToken }
1168
1190
  case 'line':
1169
1191
  // LINE auth writes its structured account block directly to
1170
1192
  // secrets.json#channels.line before config mutation.
@@ -1448,7 +1470,7 @@ async function appendChannelSecrets(cwd: string, channel: ChannelKind, tokens: C
1448
1470
 
1449
1471
  export type SetChannelTokensResult = { ok: true } | { ok: false; reason: string }
1450
1472
 
1451
- type BotTokenAdapter = 'discord-bot' | 'slack-bot' | 'telegram-bot'
1473
+ type BotTokenAdapter = 'discord-bot' | 'slack-bot' | 'telegram-bot' | 'webex-bot'
1452
1474
 
1453
1475
  // Required credential fields per adapter. Used post-merge to refuse a
1454
1476
  // rotation that would leave the adapter half-configured — e.g. rotating
@@ -1459,6 +1481,7 @@ const REQUIRED_CHANNEL_FIELDS: Record<BotTokenAdapter, readonly string[]> = {
1459
1481
  'discord-bot': ['token'],
1460
1482
  'slack-bot': ['botToken', 'appToken'],
1461
1483
  'telegram-bot': ['token'],
1484
+ 'webex-bot': ['token'],
1462
1485
  }
1463
1486
 
1464
1487
  // Preserve a user-authored `{ env: 'CUSTOM_NAME' }` rebinding when rotating
@@ -10,6 +10,7 @@ const CHANNEL_LABELS: Record<ChannelKind, string> = {
10
10
  'discord-bot': 'Discord',
11
11
  github: 'GitHub',
12
12
  'telegram-bot': 'Telegram',
13
+ 'webex-bot': 'Webex',
13
14
  line: 'LINE',
14
15
  kakaotalk: 'KakaoTalk',
15
16
  }
@@ -16,7 +16,7 @@
16
16
  // error messages with typo suggestions; a single big regex would only ever
17
17
  // say "didn't match".
18
18
 
19
- export const PLATFORMS = ['slack', 'discord', 'telegram', 'line', 'kakao', 'github'] as const
19
+ export const PLATFORMS = ['slack', 'discord', 'telegram', 'webex', 'line', 'kakao', 'github'] as const
20
20
  export type Platform = (typeof PLATFORMS)[number]
21
21
 
22
22
  const SUBAGENT_NAME = /^[a-z][a-z0-9-]*$/
@@ -50,8 +50,12 @@ export type ParseMatchRuleResult = { ok: true; value: MatchRule } | { ok: false;
50
50
  // run and emit typo suggestions like `autor:` -> `author:`. If we tightened
51
51
  // this to `author:` only, the JSON schema would reject typos with a generic
52
52
  // "did not match pattern" error and the user would lose the actionable hint.
53
- export const MATCH_RULE_REGEX_SOURCE =
54
- '^(tui|cron|subagent(:[a-z][a-z0-9-]*)?|\\*|(slack|discord|telegram|line|kakao|github):[^\\s]+)(\\s+[a-zA-Z][a-zA-Z0-9_]*:[^\\s]+)*$'
53
+ //
54
+ // The platform alternation is derived from PLATFORMS so a newly added
55
+ // platform can never validate at the parser but be rejected by this schema
56
+ // regex (the bug that shipped when 'webex' was added to PLATFORMS but not
57
+ // here).
58
+ export const MATCH_RULE_REGEX_SOURCE = `^(tui|cron|subagent(:[a-z][a-z0-9-]*)?|\\*|(${PLATFORMS.join('|')}):[^\\s]+)(\\s+[a-zA-Z][a-zA-Z0-9_]*:[^\\s]+)*$`
55
59
 
56
60
  export function parseMatchRule(input: string): ParseMatchRuleResult {
57
61
  if (input !== input.trim() || input.length === 0) {
@@ -7,6 +7,7 @@ const ADAPTER_TO_PLATFORM: Record<AdapterId, Platform> = {
7
7
  'discord-bot': 'discord',
8
8
  github: 'github',
9
9
  'telegram-bot': 'telegram',
10
+ 'webex-bot': 'webex',
10
11
  line: 'line',
11
12
  kakaotalk: 'kakao',
12
13
  }
@@ -57,12 +58,12 @@ function matchesChannel(rule: Extract<MatchRule, { kind: 'channel' }>, origin: M
57
58
  }
58
59
 
59
60
  // DM and group buckets are inferred from the workspace/chat shape of the
60
- // inbound origin. Different adapters mark DMs differently — Slack uses an
61
- // `@dm` workspace marker today, Discord uses a `dm` workspace marker, and
61
+ // inbound origin. Different adapters mark DMs differently — Slack and Webex
62
+ // use an `@dm` workspace marker, Discord uses a `dm` workspace marker, and
62
63
  // KakaoTalk preserves group/open/dm explicitly in its workspace field. We
63
64
  // keep the heuristic narrow: a rule that says `slack:dm/*` matches only when
64
- // the origin's workspace is `@dm` (Slack) or `dm` (Discord). KakaoTalk uses
65
- // the workspace prefix itself.
65
+ // the origin's workspace is `@dm` (Slack/Webex) or `dm` (Discord). KakaoTalk
66
+ // uses the workspace prefix itself.
66
67
  function matchesBucket(
67
68
  bucket: 'dm' | 'group' | 'open' | 'square',
68
69
  origin: Extract<MatchableOrigin, { kind: 'channel' }>,
@@ -84,6 +85,7 @@ function matchesBucket(
84
85
  if (platform === 'slack') return origin.workspace === '@dm'
85
86
  if (platform === 'discord') return origin.workspace === 'dm' || origin.workspace === '@dm'
86
87
  if (platform === 'telegram') return origin.workspace === 'dm' || origin.workspace.startsWith('@')
88
+ if (platform === 'webex') return origin.workspace === '@dm'
87
89
  return false
88
90
  }
89
91
 
@@ -27,12 +27,13 @@ export type PartialChannelOrigin = {
27
27
 
28
28
  const ADAPTER_TO_PLATFORM: Record<
29
29
  ChannelKey['adapter'],
30
- 'slack' | 'discord' | 'telegram' | 'kakao' | 'line' | 'github'
30
+ 'slack' | 'discord' | 'telegram' | 'webex' | 'kakao' | 'line' | 'github'
31
31
  > = {
32
32
  'slack-bot': 'slack',
33
33
  'discord-bot': 'discord',
34
34
  github: 'github',
35
35
  'telegram-bot': 'telegram',
36
+ 'webex-bot': 'webex',
36
37
  line: 'line',
37
38
  kakaotalk: 'kakao',
38
39
  }
@@ -19,6 +19,7 @@ export const CHANNEL_FIELD_ENV = {
19
19
  'discord-bot': { token: 'DISCORD_BOT_TOKEN' },
20
20
  'slack-bot': { botToken: 'SLACK_BOT_TOKEN', appToken: 'SLACK_APP_TOKEN' },
21
21
  'telegram-bot': { token: 'TELEGRAM_BOT_TOKEN' },
22
+ 'webex-bot': { token: 'WEBEX_BOT_TOKEN' },
22
23
  } as const satisfies Record<string, Record<string, string>>
23
24
 
24
25
  export type KnownAdapterId = keyof typeof CHANNEL_FIELD_ENV