charness 4.3.0 → 4.4.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.
Files changed (153) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +1 -1
  3. package/agent-plugin/skills/charness-orchestration/SKILL.md +8 -2
  4. package/dist/agentLogin/agentLogin.d.ts.map +1 -1
  5. package/dist/agentLogin/agentLogin.js +6 -5
  6. package/dist/agentLogin/agentLogin.js.map +1 -1
  7. package/dist/apiRetryKick.d.ts +15 -5
  8. package/dist/apiRetryKick.d.ts.map +1 -1
  9. package/dist/apiRetryKick.js +13 -8
  10. package/dist/apiRetryKick.js.map +1 -1
  11. package/dist/bot.d.ts.map +1 -1
  12. package/dist/bot.js +85 -46
  13. package/dist/bot.js.map +1 -1
  14. package/dist/cli/claudeProfiles.d.ts +4 -1
  15. package/dist/cli/claudeProfiles.d.ts.map +1 -1
  16. package/dist/cli/claudeProfiles.js +6 -2
  17. package/dist/cli/claudeProfiles.js.map +1 -1
  18. package/dist/connectors/jira/answerSink.d.ts.map +1 -1
  19. package/dist/connectors/jira/answerSink.js +3 -1
  20. package/dist/connectors/jira/answerSink.js.map +1 -1
  21. package/dist/connectors/telegram/commands/claudeAccounts.d.ts +12 -1
  22. package/dist/connectors/telegram/commands/claudeAccounts.d.ts.map +1 -1
  23. package/dist/connectors/telegram/commands/claudeAccounts.js +253 -89
  24. package/dist/connectors/telegram/commands/claudeAccounts.js.map +1 -1
  25. package/dist/connectors/telegram/commands/fallbackChain.d.ts.map +1 -1
  26. package/dist/connectors/telegram/commands/fallbackChain.js +8 -7
  27. package/dist/connectors/telegram/commands/fallbackChain.js.map +1 -1
  28. package/dist/connectors/telegram/commands/limitsBoard.d.ts.map +1 -1
  29. package/dist/connectors/telegram/commands/limitsBoard.js +3 -1
  30. package/dist/connectors/telegram/commands/limitsBoard.js.map +1 -1
  31. package/dist/connectors/telegram/commands/modelPage.d.ts +2 -0
  32. package/dist/connectors/telegram/commands/modelPage.d.ts.map +1 -1
  33. package/dist/connectors/telegram/commands/modelPage.js +1 -1
  34. package/dist/connectors/telegram/commands/modelPage.js.map +1 -1
  35. package/dist/i18n/de.d.ts.map +1 -1
  36. package/dist/i18n/de.js +42 -25
  37. package/dist/i18n/de.js.map +1 -1
  38. package/dist/i18n/en.d.ts.map +1 -1
  39. package/dist/i18n/en.js +42 -25
  40. package/dist/i18n/en.js.map +1 -1
  41. package/dist/i18n/es.d.ts.map +1 -1
  42. package/dist/i18n/es.js +42 -25
  43. package/dist/i18n/es.js.map +1 -1
  44. package/dist/i18n/fr.d.ts.map +1 -1
  45. package/dist/i18n/fr.js +42 -25
  46. package/dist/i18n/fr.js.map +1 -1
  47. package/dist/i18n/hi.d.ts.map +1 -1
  48. package/dist/i18n/hi.js +42 -25
  49. package/dist/i18n/hi.js.map +1 -1
  50. package/dist/i18n/ja.d.ts.map +1 -1
  51. package/dist/i18n/ja.js +42 -25
  52. package/dist/i18n/ja.js.map +1 -1
  53. package/dist/i18n/ka.d.ts.map +1 -1
  54. package/dist/i18n/ka.js +42 -25
  55. package/dist/i18n/ka.js.map +1 -1
  56. package/dist/i18n/pt.d.ts.map +1 -1
  57. package/dist/i18n/pt.js +42 -25
  58. package/dist/i18n/pt.js.map +1 -1
  59. package/dist/i18n/ru.d.ts.map +1 -1
  60. package/dist/i18n/ru.js +42 -25
  61. package/dist/i18n/ru.js.map +1 -1
  62. package/dist/i18n/uk.d.ts.map +1 -1
  63. package/dist/i18n/uk.js +42 -25
  64. package/dist/i18n/uk.js.map +1 -1
  65. package/dist/i18n/uz.d.ts.map +1 -1
  66. package/dist/i18n/uz.js +42 -25
  67. package/dist/i18n/uz.js.map +1 -1
  68. package/dist/i18n/zh.d.ts.map +1 -1
  69. package/dist/i18n/zh.js +42 -25
  70. package/dist/i18n/zh.js.map +1 -1
  71. package/dist/i18n.d.ts +0 -12
  72. package/dist/i18n.d.ts.map +1 -1
  73. package/dist/i18n.js +6 -4
  74. package/dist/i18n.js.map +1 -1
  75. package/dist/requests/requestHeader.d.ts.map +1 -1
  76. package/dist/requests/requestHeader.js +30 -6
  77. package/dist/requests/requestHeader.js.map +1 -1
  78. package/dist/requests/sessionTurnProbe.d.ts +6 -1
  79. package/dist/requests/sessionTurnProbe.d.ts.map +1 -1
  80. package/dist/requests/sessionTurnProbe.js +4 -0
  81. package/dist/requests/sessionTurnProbe.js.map +1 -1
  82. package/dist/requests/types.d.ts +18 -4
  83. package/dist/requests/types.d.ts.map +1 -1
  84. package/dist/requests/wakeUpEngine.d.ts +13 -1
  85. package/dist/requests/wakeUpEngine.d.ts.map +1 -1
  86. package/dist/requests/wakeUpEngine.js +69 -8
  87. package/dist/requests/wakeUpEngine.js.map +1 -1
  88. package/dist/requests/wakeUpRules.d.ts +63 -2
  89. package/dist/requests/wakeUpRules.d.ts.map +1 -1
  90. package/dist/requests/wakeUpRules.js +67 -36
  91. package/dist/requests/wakeUpRules.js.map +1 -1
  92. package/dist/scheduler/mcpSurface.d.ts +30 -1
  93. package/dist/scheduler/mcpSurface.d.ts.map +1 -1
  94. package/dist/scheduler/mcpSurface.js +75 -15
  95. package/dist/scheduler/mcpSurface.js.map +1 -1
  96. package/dist/shutdown.d.ts +12 -0
  97. package/dist/shutdown.d.ts.map +1 -1
  98. package/dist/shutdown.js +11 -0
  99. package/dist/shutdown.js.map +1 -1
  100. package/dist/state.d.ts +11 -0
  101. package/dist/state.d.ts.map +1 -1
  102. package/dist/state.js +15 -0
  103. package/dist/state.js.map +1 -1
  104. package/dist/utils/backendSwitchPlan.d.ts +4 -1
  105. package/dist/utils/backendSwitchPlan.d.ts.map +1 -1
  106. package/dist/utils/backendSwitchPlan.js +6 -2
  107. package/dist/utils/backendSwitchPlan.js.map +1 -1
  108. package/dist/utils/claudeAccountAlert.d.ts +6 -3
  109. package/dist/utils/claudeAccountAlert.d.ts.map +1 -1
  110. package/dist/utils/claudeAccountAlert.js +13 -7
  111. package/dist/utils/claudeAccountAlert.js.map +1 -1
  112. package/dist/utils/claudeAccountPickerPlan.d.ts +17 -3
  113. package/dist/utils/claudeAccountPickerPlan.d.ts.map +1 -1
  114. package/dist/utils/claudeAccountPickerPlan.js +19 -4
  115. package/dist/utils/claudeAccountPickerPlan.js.map +1 -1
  116. package/dist/utils/claudeProfileLabels.d.ts +160 -0
  117. package/dist/utils/claudeProfileLabels.d.ts.map +1 -0
  118. package/dist/utils/claudeProfileLabels.js +283 -0
  119. package/dist/utils/claudeProfileLabels.js.map +1 -0
  120. package/dist/utils/claudeProfileUsageViews.d.ts +2 -0
  121. package/dist/utils/claudeProfileUsageViews.d.ts.map +1 -1
  122. package/dist/utils/claudeProfileUsageViews.js +3 -1
  123. package/dist/utils/claudeProfileUsageViews.js.map +1 -1
  124. package/dist/utils/claudeUsage.d.ts +5 -0
  125. package/dist/utils/claudeUsage.d.ts.map +1 -1
  126. package/dist/utils/claudeUsage.js +1 -0
  127. package/dist/utils/claudeUsage.js.map +1 -1
  128. package/dist/utils/fallbackChain.d.ts +4 -2
  129. package/dist/utils/fallbackChain.d.ts.map +1 -1
  130. package/dist/utils/fallbackChain.js +4 -3
  131. package/dist/utils/fallbackChain.js.map +1 -1
  132. package/dist/utils/fallbackSwitchNotice.d.ts +1 -1
  133. package/dist/utils/fallbackSwitchNotice.d.ts.map +1 -1
  134. package/dist/utils/fallbackSwitchNotice.js +4 -3
  135. package/dist/utils/fallbackSwitchNotice.js.map +1 -1
  136. package/dist/utils/limitSwitchPlan.d.ts +51 -14
  137. package/dist/utils/limitSwitchPlan.d.ts.map +1 -1
  138. package/dist/utils/limitSwitchPlan.js +33 -15
  139. package/dist/utils/limitSwitchPlan.js.map +1 -1
  140. package/dist/utils/limitsBoardPlan.d.ts +6 -4
  141. package/dist/utils/limitsBoardPlan.d.ts.map +1 -1
  142. package/dist/utils/limitsBoardPlan.js +11 -5
  143. package/dist/utils/limitsBoardPlan.js.map +1 -1
  144. package/dist/utils/threadStatusReport.d.ts +2 -0
  145. package/dist/utils/threadStatusReport.d.ts.map +1 -1
  146. package/dist/utils/threadStatusReport.js +4 -3
  147. package/dist/utils/threadStatusReport.js.map +1 -1
  148. package/dist/utils/workingSignals.d.ts +10 -0
  149. package/dist/utils/workingSignals.d.ts.map +1 -1
  150. package/dist/utils/workingSignals.js +22 -3
  151. package/dist/utils/workingSignals.js.map +1 -1
  152. package/npm-shrinkwrap.json +2 -2
  153. package/package.json +1 -1
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * @description Pure plan of the `/account` picker (`connectors/telegram/commands/claudeAccounts.ts`): the
3
- * `callback_data` codecs and the per-profile row model. Profile names are slugs of at most 32 characters
4
- * (`utils/claudeProfiles.ts`), so a button BAKES THE NAME into its data (`acct_use_<name>` is at most 41
3
+ * `callback_data` codecs and the per-profile row model. A profile's fixed id is a slug of at most 32 characters
4
+ * (`utils/claudeProfiles.ts`), so a button BAKES THE ID into its data (`acct_use_<id>` is at most 41
5
5
  * bytes, under Telegram's 64-byte cap) and an old keyboard can never act on a profile other than the one it
6
- * named — a removed name simply resolves to "unknown profile".
6
+ * named — a removed id simply resolves to "unknown profile". What the row SHOWS is the account's display name
7
+ * (`utils/claudeProfileLabels.ts`), which a rename changes without touching any button.
7
8
  */
8
9
  import type { ClaudeProfileRecord } from '../state';
9
10
  import { type ClaudeAccountKind, type ClaudeProfileBilling } from './claudeProfiles';
@@ -22,6 +23,13 @@ export declare const accountLoginCallbackRe: RegExp;
22
23
  export declare const accountSignInCallbackRe: RegExp;
23
24
  /** Ask to confirm the removal of the named profile, then remove it. */
24
25
  export declare const accountRemoveCallbackRe: RegExp;
26
+ /** ✏️: ask for the named profile's new display name (the id in the data never changes). */
27
+ export declare const accountRenameCallbackRe: RegExp;
28
+ /**
29
+ * «✏️ Rename an account» under the account rows: the choice of the account to rename (one button each, `acct_ren_<id>`). Spelled
30
+ * without the `acct_ren_` prefix, so no account id can be mistaken for it.
31
+ */
32
+ export declare const accountRenameMenuCallback = "acct_renmenu";
25
33
  export declare const accountRemoveConfirmCallbackRe: RegExp;
26
34
  /** Ask for a new profile's name. */
27
35
  export declare const accountAddCallback = "acct_add";
@@ -62,6 +70,7 @@ export declare function buildAccountReconnectCallback(index: number): string;
62
70
  export declare function buildAccountDisconnectConfirmCallback(index: number): string;
63
71
  export declare function buildAccountRemoveCallback(name: string): string;
64
72
  export declare function buildAccountRemoveConfirmCallback(name: string): string;
73
+ export declare function buildAccountRenameCallback(name: string): string;
65
74
  /**
66
75
  * @description The name a callback's data carries, or `null` when the data is not that button's or names an
67
76
  * impossible profile (`default` is a valid target for use / login / removal only where `allowDefault`).
@@ -71,7 +80,10 @@ export declare function parseAccountCallbackName(data: string, re: RegExp, optio
71
80
  }): string | null;
72
81
  /** One line / one button of the picker. */
73
82
  export interface AccountPickerRow {
83
+ /** The fixed id: what the buttons carry. */
74
84
  name: string;
85
+ /** What the row shows: the display name (`default`: «Main» until renamed; else the id). */
86
+ label: string;
75
87
  /** The profile the topic (General: the instance) effectively uses. */
76
88
  isActive: boolean;
77
89
  /** The CLI's last answer; `undefined` when never read. */
@@ -102,6 +114,8 @@ export declare function buildAccountPickerRows(input: {
102
114
  topicCounts: ReadonlyMap<string, number>;
103
115
  /** The operator removed (signed out) `default`: it has no row until it is signed in again. */
104
116
  isDefaultRemoved?: boolean;
117
+ /** What a profile is called (`utils/claudeProfileLabels.ts`); the id when absent. */
118
+ getLabel?: (name: string) => string;
105
119
  }): AccountPickerRow[];
106
120
  /** The profile each bound topic resolves to, counted per profile name. */
107
121
  export declare function countTopicsPerProfile(resolvedNames: Iterable<string>): Map<string, number>;
@@ -1 +1 @@
1
- {"version":3,"file":"claudeAccountPickerPlan.d.ts","sourceRoot":"","sources":["../../src/utils/claudeAccountPickerPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EAC1B,MAAM,kBAAkB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AC5E,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,8FAA8F;IAC9F,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,qFAAqF;IACrF,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACrC,GAAG,gBAAgB,EAAE,CA6BrB;AAED,0EAA0E;AAC1E,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAI1F"}
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
2
  /**
3
3
  * @description Pure plan of the `/account` picker (`connectors/telegram/commands/claudeAccounts.ts`): the
4
- * `callback_data` codecs and the per-profile row model. Profile names are slugs of at most 32 characters
5
- * (`utils/claudeProfiles.ts`), so a button BAKES THE NAME into its data (`acct_use_<name>` is at most 41
4
+ * `callback_data` codecs and the per-profile row model. A profile's fixed id is a slug of at most 32 characters
5
+ * (`utils/claudeProfiles.ts`), so a button BAKES THE ID into its data (`acct_use_<id>` is at most 41
6
6
  * bytes, under Telegram's 64-byte cap) and an old keyboard can never act on a profile other than the one it
7
- * named — a removed name simply resolves to "unknown profile".
7
+ * named — a removed id simply resolves to "unknown profile". What the row SHOWS is the account's display name
8
+ * (`utils/claudeProfileLabels.ts`), which a rename changes without touching any button.
8
9
  */
9
10
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.accountAutoSwitchOffCallback = exports.accountAutoSwitchOnCallback = exports.accountBackCallback = exports.accountOpenCodePageCallbackRe = exports.accountOpenCodeModelCallbackRe = exports.accountOpenCodeUseCallbackRe = exports.accountReconnectCallbackRe = exports.accountDisconnectConfirmCallbackRe = exports.accountDisconnectCallbackRe = exports.accountAddProviderCallback = exports.accountFollowDefaultCallback = exports.accountAddApiCallback = exports.accountAddCallback = exports.accountRemoveConfirmCallbackRe = exports.accountRemoveCallbackRe = exports.accountSignInCallbackRe = exports.accountLoginCallbackRe = exports.accountRemoveMenuCallback = exports.accountLoginMenuCallback = exports.accountUseCallbackRe = void 0;
11
+ exports.accountAutoSwitchOffCallback = exports.accountAutoSwitchOnCallback = exports.accountBackCallback = exports.accountOpenCodePageCallbackRe = exports.accountOpenCodeModelCallbackRe = exports.accountOpenCodeUseCallbackRe = exports.accountReconnectCallbackRe = exports.accountDisconnectConfirmCallbackRe = exports.accountDisconnectCallbackRe = exports.accountAddProviderCallback = exports.accountFollowDefaultCallback = exports.accountAddApiCallback = exports.accountAddCallback = exports.accountRemoveConfirmCallbackRe = exports.accountRenameMenuCallback = exports.accountRenameCallbackRe = exports.accountRemoveCallbackRe = exports.accountSignInCallbackRe = exports.accountLoginCallbackRe = exports.accountRemoveMenuCallback = exports.accountLoginMenuCallback = exports.accountUseCallbackRe = void 0;
11
12
  exports.buildAccountUseCallback = buildAccountUseCallback;
12
13
  exports.buildAccountLoginCallback = buildAccountLoginCallback;
13
14
  exports.buildAccountSignInCallback = buildAccountSignInCallback;
@@ -19,6 +20,7 @@ exports.buildAccountReconnectCallback = buildAccountReconnectCallback;
19
20
  exports.buildAccountDisconnectConfirmCallback = buildAccountDisconnectConfirmCallback;
20
21
  exports.buildAccountRemoveCallback = buildAccountRemoveCallback;
21
22
  exports.buildAccountRemoveConfirmCallback = buildAccountRemoveConfirmCallback;
23
+ exports.buildAccountRenameCallback = buildAccountRenameCallback;
22
24
  exports.parseAccountCallbackName = parseAccountCallbackName;
23
25
  exports.buildAccountPickerRows = buildAccountPickerRows;
24
26
  exports.countTopicsPerProfile = countTopicsPerProfile;
@@ -40,6 +42,13 @@ exports.accountLoginCallbackRe = new RegExp(`^acct_login_${nameGroup}$`);
40
42
  exports.accountSignInCallbackRe = new RegExp(`^acct_signin_${nameGroup}$`);
41
43
  /** Ask to confirm the removal of the named profile, then remove it. */
42
44
  exports.accountRemoveCallbackRe = new RegExp(`^acct_rm_${nameGroup}$`);
45
+ /** ✏️: ask for the named profile's new display name (the id in the data never changes). */
46
+ exports.accountRenameCallbackRe = new RegExp(`^acct_ren_${nameGroup}$`);
47
+ /**
48
+ * «✏️ Rename an account» under the account rows: the choice of the account to rename (one button each, `acct_ren_<id>`). Spelled
49
+ * without the `acct_ren_` prefix, so no account id can be mistaken for it.
50
+ */
51
+ exports.accountRenameMenuCallback = 'acct_renmenu';
43
52
  exports.accountRemoveConfirmCallbackRe = new RegExp(`^acct_rmok_${nameGroup}$`);
44
53
  /** Ask for a new profile's name. */
45
54
  exports.accountAddCallback = 'acct_add';
@@ -102,6 +111,9 @@ function buildAccountRemoveCallback(name) {
102
111
  function buildAccountRemoveConfirmCallback(name) {
103
112
  return `acct_rmok_${name}`;
104
113
  }
114
+ function buildAccountRenameCallback(name) {
115
+ return `acct_ren_${name}`;
116
+ }
105
117
  /**
106
118
  * @description The name a callback's data carries, or `null` when the data is not that button's or names an
107
119
  * impossible profile (`default` is a valid target for use / login / removal only where `allowDefault`).
@@ -121,8 +133,10 @@ function parseAccountCallbackName(data, re, options) {
121
133
  * answers "which topics would a removal or re-login touch".
122
134
  */
123
135
  function buildAccountPickerRows(input) {
136
+ const getLabel = input.getLabel ?? ((name) => name);
124
137
  const rows = input.isDefaultRemoved ? [] : [{
125
138
  name: claudeProfiles_1.defaultClaudeProfileName,
139
+ label: getLabel(claudeProfiles_1.defaultClaudeProfileName),
126
140
  isActive: input.activeName === claudeProfiles_1.defaultClaudeProfileName,
127
141
  loggedIn: input.defaultStatus.loggedIn,
128
142
  email: input.defaultStatus.email,
@@ -136,6 +150,7 @@ function buildAccountPickerRows(input) {
136
150
  for (const [name, record] of added) {
137
151
  rows.push({
138
152
  name,
153
+ label: getLabel(name),
139
154
  isActive: input.activeName === name,
140
155
  loggedIn: (0, claudeAuthRefusal_1.getClaudeProfileSignedIn)(record),
141
156
  email: record.email ?? null,
@@ -1 +1 @@
1
- {"version":3,"file":"claudeAccountPickerPlan.js","sourceRoot":"","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SACxC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IAClE,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACnC,IAAI,CAAC,IAAI,CAAC;YACR,IAAI;YACJ,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC;YACrB,QAAQ,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI;YACnC,QAAQ,EAAE,IAAA,4CAAwB,EAAC,MAAM,CAAC;YAC1C,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,IAAI;YAC3B,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,IAAI,IAAI;YACjD,IAAI,EAAE,IAAA,qCAAoB,EAAC,MAAM,CAAC,gBAAgB,IAAI,IAAI,CAAC;YAC3D,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,IAAI;YAC/B,UAAU,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;SAC7C,CAAC,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,0EAA0E;AAC1E,SAAgB,qBAAqB,CAAC,aAA+B;IACnE,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,KAAK,MAAM,IAAI,IAAI,aAAa;QAAE,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAChF,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,160 @@
1
+ /**
2
+ * @description The DISPLAY NAME of a Claude account (`/accounts`), apart from its fixed internal id. The id names the account's folder
3
+ * (`DATA_DIR/claude-profiles/<id>/`), its button data, the `/limits` list's rungs, every topic's pick and the name agents record — so it
4
+ * never changes once the account exists. The display name is free text the operator gives at ➕ and changes with ✏️ «Rename»:
5
+ * capitals, dots, spaces, `@`, Cyrillic, emoji, up to {@link claudeProfileLabelMaxLength} characters. The bot derives the id from it
6
+ * ({@link deriveClaudeProfileId}) and shows the display name wherever it names the account; an account with no display name (one
7
+ * added before display names existed, one adopted from a folder made by hand) shows its id, and `default` (`~/.claude`) shows «Main»
8
+ * in the reader's language until it is renamed — nothing is migrated.
9
+ *
10
+ * Rules that keep a typed name unambiguous ({@link checkClaudeProfileLabel}): no two accounts share a display name (case ignored) and no
11
+ * display name equals another account's id, so `/accounts use|login|remove <name>` finds one account by either
12
+ * ({@link findClaudeProfileByTypedName}); a derived id never equals another account's display name either.
13
+ *
14
+ * The rules are pure. The resolver every screen calls ({@link getClaudeProfileLabel}) reads the stored names through the reader the bot
15
+ * registers at start-up ({@link setClaudeProfileLabelReader}); the views the ranking, `claude_profiles` and `charness claude-profiles`
16
+ * read carry the name themselves (`utils/claudeProfileUsageViews.ts`). Not loaded by the connector guards: it reads the locale.
17
+ */
18
+ /** The longest display name, in characters (code points). */
19
+ export declare const claudeProfileLabelMaxLength = 40;
20
+ /** The longest display name a BUTTON shows; a longer one is cut there with `…` (the message text shows it whole). */
21
+ export declare const claudeProfileButtonLabelMaxLength = 24;
22
+ /** One account as the name rules see it: its id and the display names it answers to (the first is the one shown). */
23
+ export interface ClaudeProfileNameEntry {
24
+ name: string;
25
+ /** The shown display name first; `default` with no name of its own also answers to «Main» in English. Never empty. */
26
+ labels: readonly string[];
27
+ }
28
+ /** Why a display name is refused. */
29
+ export type ClaudeProfileLabelProblem = {
30
+ kind: 'empty';
31
+ } | {
32
+ kind: 'tooLong';
33
+ max: number;
34
+ }
35
+ /** Another account already shows this name (case ignored); `label` is that account's own spelling. */
36
+ | {
37
+ kind: 'taken';
38
+ label: string;
39
+ }
40
+ /** The name is another account's id (case ignored): a typed command could not tell the two apart. */
41
+ | {
42
+ kind: 'isId';
43
+ label: string;
44
+ };
45
+ /** Why a typed id is refused ({@link describeClaudeProfileIdProblem}). */
46
+ export type ClaudeProfileIdProblem = {
47
+ kind: 'empty';
48
+ } | {
49
+ kind: 'reserved';
50
+ }
51
+ /** A word the account buttons' data uses after their prefix ({@link claudeProfileButtonWordIds}). */
52
+ | {
53
+ kind: 'buttonWord';
54
+ id: string;
55
+ } | {
56
+ kind: 'tooLong';
57
+ max: number;
58
+ }
59
+ /** The first character is not a letter `a–z` or a digit (a `-` or `_` may not start an id). */
60
+ | {
61
+ kind: 'firstCharacter';
62
+ character: string;
63
+ } | {
64
+ kind: 'character';
65
+ character: string;
66
+ };
67
+ /**
68
+ * @description A typed display name as it is kept: Unicode-composed, invisible characters (controls, zero-width marks, bidi overrides)
69
+ * removed — the joiner of an emoji sequence stays —, every run of whitespace (a line break too) one space, trimmed. So a name is always
70
+ * one line and never pretends to be another by an invisible difference.
71
+ */
72
+ export declare function normaliseClaudeProfileLabel(raw: string): string;
73
+ /**
74
+ * @description Why `label` (already {@link normaliseClaudeProfileLabel}d) cannot be the display name of the account `selfName` (`null`
75
+ * for an account about to be added), `null` when it can. `accounts` is every account, `default` included and `selfName` too (it is
76
+ * skipped). Its own id is allowed — renaming an account back to its id gives it no display name of its own.
77
+ */
78
+ export declare function checkClaudeProfileLabel(input: {
79
+ label: string;
80
+ selfName: string | null;
81
+ accounts: readonly ClaudeProfileNameEntry[];
82
+ }): ClaudeProfileLabelProblem | null;
83
+ /**
84
+ * Ids a NEW account never gets: the words the picker's own buttons put where an id goes (`acct_login_menu`, `acct_rm_menu` — the sign-in
85
+ * and remove sub-menus, `utils/claudeAccountPickerPlan.ts`). Their exact handlers answer first, so an account `menu` could not be signed in
86
+ * or removed by its buttons. An account of such an id from before stays valid ({@link checkIsValidClaudeProfileName} lets it through).
87
+ */
88
+ export declare const claudeProfileButtonWordIds: ReadonlySet<string>;
89
+ /**
90
+ * @description The id (folder name) a new account with the display name `label` gets: its slug (`Sergei.Solo@work` →
91
+ * `sergei-solo-work`, `Работа` → `rabota`), `account` when nothing of it survives, cut to {@link claudeProfileNameMaxLength}; on a clash
92
+ * — `isTaken` says so: a known account's id, `default`, another account's display name, a folder already on disk — or on a word the
93
+ * buttons use ({@link claudeProfileButtonWordIds}: «Menu» → `menu-2`) a number is added (`work-2`, `work-3`, …). Always a valid id
94
+ * ({@link checkIsValidClaudeProfileName}).
95
+ */
96
+ export declare function deriveClaudeProfileId(label: string, isTaken: (id: string) => boolean): string;
97
+ /**
98
+ * @description The account a typed name means (`/accounts use|login|remove <name>`): an id or a display name, case and spacing ignored;
99
+ * an id wins over a display name (the rules keep them from clashing, an older state may not). `null` when none matches.
100
+ */
101
+ export declare function findClaudeProfileByTypedName(typed: string, accounts: readonly ClaudeProfileNameEntry[]): string | null;
102
+ /** @description A display name as a button shows it: whole up to `max` characters, else cut there and ended with `…` (cut between characters, never inside one). */
103
+ export declare function shortenClaudeProfileLabel(label: string, max?: number): string;
104
+ /**
105
+ * @description Why `name` cannot be an account id, `null` when it can: one typed by hand (`/accounts add <name> id:<id>`) is lowercased
106
+ * first, so a capital letter is never the problem — the answer names the first character an id cannot hold.
107
+ */
108
+ export declare function describeClaudeProfileIdProblem(name: string): ClaudeProfileIdProblem | null;
109
+ /**
110
+ * @description A display name as a Markdown text (a Jira comment, which the connector renders through Markdown) shows it: every character
111
+ * Markdown could read as inline markup is backslash-escaped, so `my_work*` reads as written, never as emphasis or a link. The Telegram
112
+ * screens send plain text and need none of it.
113
+ */
114
+ export declare function escapeClaudeProfileLabelForMarkdown(label: string): string;
115
+ /** «Main» — what `default` (`~/.claude`) is called until the operator renames it, in the reader's language. */
116
+ export declare function getMainClaudeProfileLabel(): string;
117
+ /**
118
+ * @description «Main» in every locale (`Main`, `Основной`, `Principal`, …), each once. Topics have languages of their own, so what
119
+ * `default` is called depends on who reads it: every one of them is its name, for a typed command and for the rule that no other account
120
+ * takes it.
121
+ */
122
+ export declare function listMainClaudeProfileLabels(): readonly string[];
123
+ /** A stored display name as it is trusted: a non-empty string (a hand-edited `state.json` may hold anything), else none. */
124
+ export declare function readStoredClaudeProfileLabel(value: unknown): string | undefined;
125
+ /**
126
+ * The registry as the names are read off it: every account's record by its id — `default`'s hidden one included when it exists —, of
127
+ * which only the stored display name matters (`state.json` `claudeProfiles`).
128
+ */
129
+ export type ClaudeProfileLabelRecords = Readonly<Record<string, {
130
+ label?: unknown;
131
+ } | undefined>>;
132
+ /**
133
+ * @description What the account `name` is called, read off the whole registry: its display name, else its id — and for `default`
134
+ * «Main» in the reader's language, or «Main (~/.claude)» while another account answers to a «Main» of any locale (an account `main`
135
+ * added before display names existed), so the two never look alike or share a typed name.
136
+ */
137
+ export declare function resolveClaudeProfileLabel(name: string, records: ClaudeProfileLabelRecords): string;
138
+ /**
139
+ * @description The name-rule entry of an account ({@link ClaudeProfileNameEntry}): its shown name, and — for `default` with no name of
140
+ * its own — «Main» in every locale besides it ({@link listMainClaudeProfileLabels}) but those another account answers to, so a typed
141
+ * `основной` finds it in any topic and no other account takes any of them.
142
+ */
143
+ export declare function buildClaudeProfileNameEntry(name: string, records: ClaudeProfileLabelRecords): ClaudeProfileNameEntry;
144
+ /** @description The name-rule entries of every account: `default` (always — signed out or not, its id and names stay taken) first, then the added ones. */
145
+ export declare function buildClaudeProfileNameEntries(records: ClaudeProfileLabelRecords): ClaudeProfileNameEntry[];
146
+ /**
147
+ * @description What a message tells the operator to TYPE for the account `name` (`/accounts login <it>`): its shown name when that name
148
+ * finds this very account ({@link findClaudeProfileByTypedName}), else its id — a name another account answers to first (an account
149
+ * adopted from a folder `work` beside one called «Work») would send the command elsewhere.
150
+ */
151
+ export declare function resolveClaudeProfileCommandName(name: string, records: ClaudeProfileLabelRecords): string;
152
+ /** Where {@link getClaudeProfileLabel} reads the registry from (`state.json`'s profile records). */
153
+ export type ClaudeProfileLabelReader = () => ClaudeProfileLabelRecords;
154
+ /** @description Register where {@link getClaudeProfileLabel} reads the registry from (the bot, once, at start-up). Until then every account shows its id (`default` «Main»). */
155
+ export declare function setClaudeProfileLabelReader(reader: ClaudeProfileLabelReader): void;
156
+ /** @description What the account `name` is called on a screen, in the active locale ({@link resolveClaudeProfileLabel} over the registered registry). */
157
+ export declare function getClaudeProfileLabel(name: string): string;
158
+ /** @description What a message tells the operator to type for the account `name` ({@link resolveClaudeProfileCommandName} over the registered registry). */
159
+ export declare function getClaudeProfileCommandName(name: string): string;
160
+ //# sourceMappingURL=claudeProfileLabels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claudeProfileLabels.d.ts","sourceRoot":"","sources":["../../src/utils/claudeProfileLabels.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,6DAA6D;AAC7D,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAE9C,qHAAqH;AACrH,eAAO,MAAM,iCAAiC,KAAK,CAAC;AAwBpD,qHAAqH;AACrH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,sHAAsH;IACtH,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B;AAED,qCAAqC;AACrC,MAAM,MAAM,yBAAyB,GACjC;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE;AAClC,sGAAsG;GACpG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AAClC,qGAAqG;GACnG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpC,0EAA0E;AAC1E,MAAM,MAAM,sBAAsB,GAC9B;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE;AACtB,qGAAqG;GACnG;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE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;AACH,wBAAgB,2BAA2B,IAAI,SAAS,MAAM,EAAE,CAG/D;AAED,4HAA4H;AAC5H,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAI/E;AAED;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CAAC,CAAC,CAAC;AAkBlG;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,yBAAyB,GAAG,MAAM,CAMlG;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,yBAAyB,GAAG,sBAAsB,CAKpH;AAED,2JAA2J;AAC3J,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,yBAAyB,GAAG,sBAAsB,EAAE,CAG1G;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,yBAAyB,GAAG,MAAM,CAGxG;AAED,oGAAoG;AACpG,MAAM,MAAM,wBAAwB,GAAG,MAAM,yBAAyB,CAAC;AAIvE,gLAAgL;AAChL,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,wBAAwB,GAAG,IAAI,CAElF;AAED,yJAAyJ;AACzJ,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,4JAA4J;AAC5J,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhE"}
@@ -0,0 +1,283 @@
1
+ "use strict";
2
+ /**
3
+ * @description The DISPLAY NAME of a Claude account (`/accounts`), apart from its fixed internal id. The id names the account's folder
4
+ * (`DATA_DIR/claude-profiles/<id>/`), its button data, the `/limits` list's rungs, every topic's pick and the name agents record — so it
5
+ * never changes once the account exists. The display name is free text the operator gives at ➕ and changes with ✏️ «Rename»:
6
+ * capitals, dots, spaces, `@`, Cyrillic, emoji, up to {@link claudeProfileLabelMaxLength} characters. The bot derives the id from it
7
+ * ({@link deriveClaudeProfileId}) and shows the display name wherever it names the account; an account with no display name (one
8
+ * added before display names existed, one adopted from a folder made by hand) shows its id, and `default` (`~/.claude`) shows «Main»
9
+ * in the reader's language until it is renamed — nothing is migrated.
10
+ *
11
+ * Rules that keep a typed name unambiguous ({@link checkClaudeProfileLabel}): no two accounts share a display name (case ignored) and no
12
+ * display name equals another account's id, so `/accounts use|login|remove <name>` finds one account by either
13
+ * ({@link findClaudeProfileByTypedName}); a derived id never equals another account's display name either.
14
+ *
15
+ * The rules are pure. The resolver every screen calls ({@link getClaudeProfileLabel}) reads the stored names through the reader the bot
16
+ * registers at start-up ({@link setClaudeProfileLabelReader}); the views the ranking, `claude_profiles` and `charness claude-profiles`
17
+ * read carry the name themselves (`utils/claudeProfileUsageViews.ts`). Not loaded by the connector guards: it reads the locale.
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.claudeProfileButtonWordIds = exports.claudeProfileButtonLabelMaxLength = exports.claudeProfileLabelMaxLength = void 0;
21
+ exports.normaliseClaudeProfileLabel = normaliseClaudeProfileLabel;
22
+ exports.checkClaudeProfileLabel = checkClaudeProfileLabel;
23
+ exports.deriveClaudeProfileId = deriveClaudeProfileId;
24
+ exports.findClaudeProfileByTypedName = findClaudeProfileByTypedName;
25
+ exports.shortenClaudeProfileLabel = shortenClaudeProfileLabel;
26
+ exports.describeClaudeProfileIdProblem = describeClaudeProfileIdProblem;
27
+ exports.escapeClaudeProfileLabelForMarkdown = escapeClaudeProfileLabelForMarkdown;
28
+ exports.getMainClaudeProfileLabel = getMainClaudeProfileLabel;
29
+ exports.listMainClaudeProfileLabels = listMainClaudeProfileLabels;
30
+ exports.readStoredClaudeProfileLabel = readStoredClaudeProfileLabel;
31
+ exports.resolveClaudeProfileLabel = resolveClaudeProfileLabel;
32
+ exports.buildClaudeProfileNameEntry = buildClaudeProfileNameEntry;
33
+ exports.buildClaudeProfileNameEntries = buildClaudeProfileNameEntries;
34
+ exports.resolveClaudeProfileCommandName = resolveClaudeProfileCommandName;
35
+ exports.setClaudeProfileLabelReader = setClaudeProfileLabelReader;
36
+ exports.getClaudeProfileLabel = getClaudeProfileLabel;
37
+ exports.getClaudeProfileCommandName = getClaudeProfileCommandName;
38
+ const i18n_1 = require("../i18n");
39
+ const claudeProfiles_1 = require("./claudeProfiles");
40
+ /** The longest display name, in characters (code points). */
41
+ exports.claudeProfileLabelMaxLength = 40;
42
+ /** The longest display name a BUTTON shows; a longer one is cut there with `…` (the message text shows it whole). */
43
+ exports.claudeProfileButtonLabelMaxLength = 24;
44
+ /** What a derived id falls back to when nothing of the display name survives (`Работа` keeps `rabota`; `🚀` keeps nothing). */
45
+ const derivedIdFallback = 'account';
46
+ /** The ellipsis a cut label ends with. */
47
+ const ellipsis = '…';
48
+ /** Control and format characters (zero-width, bidi overrides), except the zero-width joiner emoji sequences are made of. */
49
+ const invisibleCharactersRe = /[\p{Cc}\p{Cf}]/gu;
50
+ const zeroWidthJoiner = '‍';
51
+ /**
52
+ * Letters written as Latin for the derived id, looked up BEFORE accents are dropped (`й` must not become `и`): Cyrillic (Russian,
53
+ * Ukrainian, Belarusian) — `Работа` → `rabota` — and the Latin letters no decomposition reaches. Anything else outside `a–z0-9` (after
54
+ * accents are dropped) becomes a `-`.
55
+ */
56
+ const transliteration = {
57
+ а: 'a', б: 'b', в: 'v', г: 'g', д: 'd', е: 'e', ё: 'e', ж: 'zh', з: 'z', и: 'i', й: 'y', к: 'k', л: 'l', м: 'm', н: 'n', о: 'o',
58
+ п: 'p', р: 'r', с: 's', т: 't', у: 'u', ф: 'f', х: 'h', ц: 'ts', ч: 'ch', ш: 'sh', щ: 'sch', ъ: '', ы: 'y', ь: '', э: 'e', ю: 'yu',
59
+ я: 'ya', і: 'i', ї: 'yi', є: 'ye', ґ: 'g', ў: 'u',
60
+ ß: 'ss', æ: 'ae', œ: 'oe', ø: 'o', ł: 'l', đ: 'd', þ: 'th',
61
+ };
62
+ /** The number of characters (code points) of a text. */
63
+ function countCharacters(text) {
64
+ return Array.from(text).length;
65
+ }
66
+ /** The lowercase key two names are compared by: case and Unicode composition ignored. */
67
+ function getComparisonKey(text) {
68
+ return text.normalize('NFC').toLowerCase();
69
+ }
70
+ /**
71
+ * @description A typed display name as it is kept: Unicode-composed, invisible characters (controls, zero-width marks, bidi overrides)
72
+ * removed — the joiner of an emoji sequence stays —, every run of whitespace (a line break too) one space, trimmed. So a name is always
73
+ * one line and never pretends to be another by an invisible difference.
74
+ */
75
+ function normaliseClaudeProfileLabel(raw) {
76
+ return raw
77
+ .normalize('NFC')
78
+ .replace(invisibleCharactersRe, (character) => (character === zeroWidthJoiner ? character : ''))
79
+ .replace(/\s+/gu, ' ')
80
+ .trim();
81
+ }
82
+ /**
83
+ * @description Why `label` (already {@link normaliseClaudeProfileLabel}d) cannot be the display name of the account `selfName` (`null`
84
+ * for an account about to be added), `null` when it can. `accounts` is every account, `default` included and `selfName` too (it is
85
+ * skipped). Its own id is allowed — renaming an account back to its id gives it no display name of its own.
86
+ */
87
+ function checkClaudeProfileLabel(input) {
88
+ const { label } = input;
89
+ if (label === '')
90
+ return { kind: 'empty' };
91
+ if (countCharacters(label) > exports.claudeProfileLabelMaxLength)
92
+ return { kind: 'tooLong', max: exports.claudeProfileLabelMaxLength };
93
+ const key = getComparisonKey(label);
94
+ const others = input.accounts.filter((account) => account.name !== input.selfName);
95
+ // A name shown first: an account with no display name of its own shows its id, and that is a name taken, not a hidden id.
96
+ const namesake = others.find((account) => account.labels.some((known) => getComparisonKey(known) === key));
97
+ if (namesake)
98
+ return { kind: 'taken', label: namesake.labels[0] };
99
+ const idOwner = others.find((account) => getComparisonKey(account.name) === key);
100
+ return idOwner ? { kind: 'isId', label: idOwner.labels[0] ?? idOwner.name } : null;
101
+ }
102
+ /** The slug of a display name: Latin letters (Cyrillic transliterated, accents dropped), digits and single `-` between them. */
103
+ function slugifyClaudeProfileLabel(label) {
104
+ const latin = Array.from(label.normalize('NFC').toLowerCase(), (character) => transliteration[character] ?? character)
105
+ .join('')
106
+ .normalize('NFKD')
107
+ .replace(/\p{M}/gu, '');
108
+ return latin.replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
109
+ }
110
+ /**
111
+ * Ids a NEW account never gets: the words the picker's own buttons put where an id goes (`acct_login_menu`, `acct_rm_menu` — the sign-in
112
+ * and remove sub-menus, `utils/claudeAccountPickerPlan.ts`). Their exact handlers answer first, so an account `menu` could not be signed in
113
+ * or removed by its buttons. An account of such an id from before stays valid ({@link checkIsValidClaudeProfileName} lets it through).
114
+ */
115
+ exports.claudeProfileButtonWordIds = new Set(['menu']);
116
+ /** `base` cut so that `suffix` still fits in an id, with no `-` left dangling at the cut. */
117
+ function fitIdBase(base, suffix) {
118
+ return base.slice(0, claudeProfiles_1.claudeProfileNameMaxLength - suffix.length).replace(/-+$/, '');
119
+ }
120
+ /**
121
+ * @description The id (folder name) a new account with the display name `label` gets: its slug (`Sergei.Solo@work` →
122
+ * `sergei-solo-work`, `Работа` → `rabota`), `account` when nothing of it survives, cut to {@link claudeProfileNameMaxLength}; on a clash
123
+ * — `isTaken` says so: a known account's id, `default`, another account's display name, a folder already on disk — or on a word the
124
+ * buttons use ({@link claudeProfileButtonWordIds}: «Menu» → `menu-2`) a number is added (`work-2`, `work-3`, …). Always a valid id
125
+ * ({@link checkIsValidClaudeProfileName}).
126
+ */
127
+ function deriveClaudeProfileId(label, isTaken) {
128
+ const base = fitIdBase(slugifyClaudeProfileLabel(label), '') || derivedIdFallback;
129
+ const isFree = (id) => (0, claudeProfiles_1.checkIsValidClaudeProfileName)(id) && !exports.claudeProfileButtonWordIds.has(id) && !isTaken(id);
130
+ if (isFree(base))
131
+ return base;
132
+ for (let number = 2;; number += 1) {
133
+ const suffix = `-${number}`;
134
+ const candidate = `${fitIdBase(base, suffix) || derivedIdFallback}${suffix}`;
135
+ if (isFree(candidate))
136
+ return candidate;
137
+ }
138
+ }
139
+ /**
140
+ * @description The account a typed name means (`/accounts use|login|remove <name>`): an id or a display name, case and spacing ignored;
141
+ * an id wins over a display name (the rules keep them from clashing, an older state may not). `null` when none matches.
142
+ */
143
+ function findClaudeProfileByTypedName(typed, accounts) {
144
+ const key = getComparisonKey(normaliseClaudeProfileLabel(typed));
145
+ if (key === '')
146
+ return null;
147
+ const byId = accounts.find((account) => getComparisonKey(account.name) === key);
148
+ if (byId)
149
+ return byId.name;
150
+ return accounts.find((account) => account.labels.some((label) => getComparisonKey(label) === key))?.name ?? null;
151
+ }
152
+ /** @description A display name as a button shows it: whole up to `max` characters, else cut there and ended with `…` (cut between characters, never inside one). */
153
+ function shortenClaudeProfileLabel(label, max = exports.claudeProfileButtonLabelMaxLength) {
154
+ const characters = Array.from(label);
155
+ if (characters.length <= max)
156
+ return label;
157
+ return `${characters.slice(0, max - 1).join('').trimEnd()}${ellipsis}`;
158
+ }
159
+ /**
160
+ * @description Why `name` cannot be an account id, `null` when it can: one typed by hand (`/accounts add <name> id:<id>`) is lowercased
161
+ * first, so a capital letter is never the problem — the answer names the first character an id cannot hold.
162
+ */
163
+ function describeClaudeProfileIdProblem(name) {
164
+ if (name === '')
165
+ return { kind: 'empty' };
166
+ if (name === claudeProfiles_1.defaultClaudeProfileName)
167
+ return { kind: 'reserved' };
168
+ if (exports.claudeProfileButtonWordIds.has(name))
169
+ return { kind: 'buttonWord', id: name };
170
+ const characters = Array.from(name);
171
+ if (!/^[a-z0-9]$/.test(characters[0]))
172
+ return { kind: 'firstCharacter', character: characters[0] };
173
+ const bad = characters.find((character) => !/^[a-z0-9_-]$/.test(character));
174
+ if (bad !== undefined)
175
+ return { kind: 'character', character: bad };
176
+ if (characters.length > claudeProfiles_1.claudeProfileNameMaxLength)
177
+ return { kind: 'tooLong', max: claudeProfiles_1.claudeProfileNameMaxLength };
178
+ return null;
179
+ }
180
+ // ── what the screens show ──
181
+ /** The ASCII punctuation a display name may hold that Markdown reads as inline markup (emphasis, code, links, HTML, strikethrough, tables). */
182
+ const markdownInlinePunctuationRe = /[\\`*_[\]<>~|]/g;
183
+ /**
184
+ * @description A display name as a Markdown text (a Jira comment, which the connector renders through Markdown) shows it: every character
185
+ * Markdown could read as inline markup is backslash-escaped, so `my_work*` reads as written, never as emphasis or a link. The Telegram
186
+ * screens send plain text and need none of it.
187
+ */
188
+ function escapeClaudeProfileLabelForMarkdown(label) {
189
+ return label.replace(markdownInlinePunctuationRe, (character) => `\\${character}`);
190
+ }
191
+ /** «Main» — what `default` (`~/.claude`) is called until the operator renames it, in the reader's language. */
192
+ function getMainClaudeProfileLabel() {
193
+ return (0, i18n_1.t)('account.mainLabel');
194
+ }
195
+ /** {@link listMainClaudeProfileLabels}, read once: the locales are fixed for the process. */
196
+ let mainLabelsOfAllLocales = null;
197
+ /**
198
+ * @description «Main» in every locale (`Main`, `Основной`, `Principal`, …), each once. Topics have languages of their own, so what
199
+ * `default` is called depends on who reads it: every one of them is its name, for a typed command and for the rule that no other account
200
+ * takes it.
201
+ */
202
+ function listMainClaudeProfileLabels() {
203
+ mainLabelsOfAllLocales ??= [...new Set(i18n_1.localeCodes.map((locale) => (0, i18n_1.runWithLocale)(locale, getMainClaudeProfileLabel)))];
204
+ return mainLabelsOfAllLocales;
205
+ }
206
+ /** A stored display name as it is trusted: a non-empty string (a hand-edited `state.json` may hold anything), else none. */
207
+ function readStoredClaudeProfileLabel(value) {
208
+ if (typeof value !== 'string')
209
+ return undefined;
210
+ const label = normaliseClaudeProfileLabel(value);
211
+ return label === '' ? undefined : label;
212
+ }
213
+ /**
214
+ * The «Main» names (any locale) another account already answers to — by its id (an account added before display names, `main`, or
215
+ * `principal`) or by its display name. While one is, `default` unrenamed is not shown by that word alone, and does not answer to it.
216
+ */
217
+ function listClaimedMainLabelKeys(records) {
218
+ const mainKeys = new Set(listMainClaudeProfileLabels().map(getComparisonKey));
219
+ const claimed = new Set();
220
+ for (const [name, record] of Object.entries(records)) {
221
+ if (name === claudeProfiles_1.defaultClaudeProfileName)
222
+ continue;
223
+ for (const known of [name, readStoredClaudeProfileLabel(record?.label)]) {
224
+ if (known !== undefined && mainKeys.has(getComparisonKey(known)))
225
+ claimed.add(getComparisonKey(known));
226
+ }
227
+ }
228
+ return claimed;
229
+ }
230
+ /**
231
+ * @description What the account `name` is called, read off the whole registry: its display name, else its id — and for `default`
232
+ * «Main» in the reader's language, or «Main (~/.claude)» while another account answers to a «Main» of any locale (an account `main`
233
+ * added before display names existed), so the two never look alike or share a typed name.
234
+ */
235
+ function resolveClaudeProfileLabel(name, records) {
236
+ const stored = readStoredClaudeProfileLabel(records[name]?.label);
237
+ if (stored !== undefined)
238
+ return stored;
239
+ if (name !== claudeProfiles_1.defaultClaudeProfileName)
240
+ return name;
241
+ const main = getMainClaudeProfileLabel();
242
+ return listClaimedMainLabelKeys(records).size > 0 ? `${main} (~/.claude)` : main;
243
+ }
244
+ /**
245
+ * @description The name-rule entry of an account ({@link ClaudeProfileNameEntry}): its shown name, and — for `default` with no name of
246
+ * its own — «Main» in every locale besides it ({@link listMainClaudeProfileLabels}) but those another account answers to, so a typed
247
+ * `основной` finds it in any topic and no other account takes any of them.
248
+ */
249
+ function buildClaudeProfileNameEntry(name, records) {
250
+ const shown = resolveClaudeProfileLabel(name, records);
251
+ if (name !== claudeProfiles_1.defaultClaudeProfileName || readStoredClaudeProfileLabel(records[name]?.label) !== undefined)
252
+ return { name, labels: [shown] };
253
+ const claimed = listClaimedMainLabelKeys(records);
254
+ return { name, labels: [shown, ...listMainClaudeProfileLabels().filter((main) => main !== shown && !claimed.has(getComparisonKey(main)))] };
255
+ }
256
+ /** @description The name-rule entries of every account: `default` (always — signed out or not, its id and names stay taken) first, then the added ones. */
257
+ function buildClaudeProfileNameEntries(records) {
258
+ const names = [claudeProfiles_1.defaultClaudeProfileName, ...Object.keys(records).filter((name) => name !== claudeProfiles_1.defaultClaudeProfileName)];
259
+ return names.map((name) => buildClaudeProfileNameEntry(name, records));
260
+ }
261
+ /**
262
+ * @description What a message tells the operator to TYPE for the account `name` (`/accounts login <it>`): its shown name when that name
263
+ * finds this very account ({@link findClaudeProfileByTypedName}), else its id — a name another account answers to first (an account
264
+ * adopted from a folder `work` beside one called «Work») would send the command elsewhere.
265
+ */
266
+ function resolveClaudeProfileCommandName(name, records) {
267
+ const label = resolveClaudeProfileLabel(name, records);
268
+ return findClaudeProfileByTypedName(label, buildClaudeProfileNameEntries(records)) === name ? label : name;
269
+ }
270
+ let labelReader = () => ({});
271
+ /** @description Register where {@link getClaudeProfileLabel} reads the registry from (the bot, once, at start-up). Until then every account shows its id (`default` «Main»). */
272
+ function setClaudeProfileLabelReader(reader) {
273
+ labelReader = reader;
274
+ }
275
+ /** @description What the account `name` is called on a screen, in the active locale ({@link resolveClaudeProfileLabel} over the registered registry). */
276
+ function getClaudeProfileLabel(name) {
277
+ return resolveClaudeProfileLabel(name, labelReader());
278
+ }
279
+ /** @description What a message tells the operator to type for the account `name` ({@link resolveClaudeProfileCommandName} over the registered registry). */
280
+ function getClaudeProfileCommandName(name) {
281
+ return resolveClaudeProfileCommandName(name, labelReader());
282
+ }
283
+ //# sourceMappingURL=claudeProfileLabels.js.map