github-issue-tower-defence-management 2.82.0 → 2.82.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/adapter/entry-points/handlers/OauthTokenSelectHandler.js +3 -23
- package/bin/adapter/entry-points/handlers/OauthTokenSelectHandler.js.map +1 -1
- package/bin/domain/usecases/OauthTokenSelectUseCase.js +1 -51
- package/bin/domain/usecases/OauthTokenSelectUseCase.js.map +1 -1
- package/package.json +1 -1
- package/types/adapter/entry-points/handlers/OauthTokenSelectHandler.d.ts.map +1 -1
- package/types/domain/usecases/OauthTokenSelectUseCase.d.ts +0 -2
- package/types/domain/usecases/OauthTokenSelectUseCase.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -164,7 +164,7 @@ storyProgressCommentEnabled: false
|
|
|
164
164
|
|
|
165
165
|
The `checkIssueReviewReadiness` sub-command lets an agent self-check whether an issue is currently review-ready. It does NOT change the issue Status field and does NOT post any comment. It writes a single JSON line to stdout of the shape `{ "reviewReady": boolean, "rejections": [{ "type": string, "detail": string }] }` and exits 0 on a successful evaluation regardless of readiness; a non-zero exit indicates an operational error (auth failure, network error). The rejection types include: `ISSUE_NOT_FOUND`, `NO_REPORT_FROM_AGENT_BOT`, `REPORT_HAS_NEXT_STEP`, `PULL_REQUEST_NOT_FOUND`, `PULL_REQUEST_IS_DRAFT`, `PULL_REQUEST_CONFLICTED`, `ANY_CI_JOB_FAILED_OR_IN_PROGRESS`, `REQUIRED_CI_JOB_NEVER_STARTED`, `ANY_REVIEW_COMMENT_NOT_RESOLVED`, and `MULTIPLE_PULL_REQUESTS_FOUND`. The `--projectUrl` option is optional; when omitted the command still runs using only the issue URL.
|
|
166
166
|
|
|
167
|
-
The `selectOauthToken` sub-command reads the same per-token rate-limit cache that the `startDaemon` proxy writes (see "Claude OAuth Token Rotation" below) and prints exactly one token string to stdout so a caller can choose an appropriate token before launching Claude Code. It is read-only: it never starts the proxy, never mutates any cache file, and never writes the token anywhere. Selection runs in two stages. First, a candidate filter keeps tokens whose 5-hour window is at least 60% free (5-hour utilization at most 0.40) AND whose 7-day window is at least 14% free (7-day utilization at most 0.86), where "% free" is `1 - utilization`. A token with no cache file, or whose window reset epoch has already passed, is treated as fully free (utilization 0) for these checks. The filter additionally excludes any token carrying a non-expired reactive `seven_day_fable` rejection marker — set when a `fable`-model request on that token was rejected with HTTP 429 (see "Claude OAuth Token Rotation" below) — because these interactive sessions run on the `fable` model; a token without the marker is treated as `fable`-usable, and the marker is ignored once its stored reset epoch has passed. Second, among the surviving candidates it selects the single token whose 7-day window reset epoch is nearest in the future (soonest reset), so weekly quota that would otherwise reset unused is consumed first; a candidate with no active 7-day window is treated as having the farthest reset (now + 7 days) and therefore sorts last. Each token entry may carry an optional `selectionWeight` (a positive number, default `1`); when the eligible candidates carry differing weights the selection among them becomes weighted-random by that weight, so a token with a smaller weight is chosen proportionally less often, while a token that is the only eligible candidate is always chosen regardless of its weight. When every eligible candidate shares the same weight (the default), the deterministic soonest-reset selection above is used unchanged.
|
|
167
|
+
The `selectOauthToken` sub-command reads the same per-token rate-limit cache that the `startDaemon` proxy writes (see "Claude OAuth Token Rotation" below) and prints exactly one token string to stdout so a caller can choose an appropriate token before launching Claude Code. It is read-only: it never starts the proxy, never mutates any cache file, and never writes the token anywhere. Selection runs in two stages. First, a candidate filter keeps tokens whose 5-hour window is at least 60% free (5-hour utilization at most 0.40) AND whose 7-day window is at least 14% free (7-day utilization at most 0.86), where "% free" is `1 - utilization`. A token with no cache file, or whose window reset epoch has already passed, is treated as fully free (utilization 0) for these checks. The filter additionally excludes any token carrying a non-expired reactive `seven_day_fable` rejection marker — set when a `fable`-model request on that token was rejected with HTTP 429 (see "Claude OAuth Token Rotation" below) — because these interactive sessions run on the `fable` model; a token without the marker is treated as `fable`-usable, and the marker is ignored once its stored reset epoch has passed. Second, among the surviving candidates it selects the single token whose 7-day window reset epoch is nearest in the future (soonest reset), so weekly quota that would otherwise reset unused is consumed first; a candidate with no active 7-day window is treated as having the farthest reset (now + 7 days) and therefore sorts last. Each token entry may carry an optional `selectionWeight` (a positive number, default `1`); when the eligible candidates carry differing weights the selection among them becomes weighted-random by that weight, so a token with a smaller weight is chosen proportionally less often, while a token that is the only eligible candidate is always chosen regardless of its weight. When every eligible candidate shares the same weight (the default), the deterministic soonest-reset selection above is used unchanged. The selected token string is written to stdout (pipeable) and the per-candidate decision trace is written to stderr. When no token passes the filter, nothing is written to stdout and the command exits non-zero with an explanatory message on stderr. The token-list path comes from `--tokenListJsonPath` or the `CLAUDE_CODE_OAUTH_TOKEN_LIST_JSON_PATH` environment variable; the cache directory comes from `--cacheDir` or the `TDPM_RATELIMIT_CACHE_DIR` environment variable, defaulting to `${XDG_CACHE_HOME:-~/.cache}/tdpm/ratelimit`.
|
|
168
168
|
|
|
169
169
|
The `selectLiveSessionOauthToken` sub-command picks a token for a new live interactive Claude Code session a human is about to start, so that concurrent interactive sessions spread across distinct tokens instead of stacking onto the same one. It loads the token list and reads the same per-token rate-limit cache as `selectOauthToken`, and it is read-only in exactly the same way: it never starts the proxy, never mutates any cache file, and never writes the token anywhere. It applies a base rate-limit eligibility filter (5-hour window at least 25% free AND 7-day window at least 1% free, with a missing cache file or an expired window treated as fully free, and any token carrying a non-expired reactive `seven_day_fable` rejection marker excluded), and additionally excludes any token whose 5-hour window is less than `minFiveHourFreeRatio` (default 60%) free or whose 7-day window is less than `minSevenDayFreeRatio` (default 14%) free; these stricter thresholds prevent the `cl` script from starting a new interactive session on a token that is nearly exhausted. It additionally measures current live occupancy per token by scanning running Claude Code processes on the local Linux host: for each process under `/proc` it reads the NUL-separated `/proc/<pid>/environ` and, when the process is a Claude Code process, takes its `CLAUDE_CODE_OAUTH_TOKEN` and `CLAUDE_CODE_SESSION_ID`. A token's occupancy is the number of distinct `CLAUDE_CODE_SESSION_ID` values bound to it, so child processes that inherit one session id count once. Processes without `CLAUDE_CODE_OAUTH_TOKEN` (for example API-key sessions) are ignored, and a process whose environ cannot be read is skipped. Among the eligible tokens the selection is deterministic and reset-first. Each eligible token is given a concurrent session limit of `maxConcurrentSessionCount` (default `10`), scaled by its optional `selectionWeight` (a positive number, default `1`). That limit is held at its full value while the free share of the token's 5-hour window is at or above `fullSpeedFiveHourFreeRatio` (default `0.5`), and is tapered linearly in proportion to the free share below that point, never dropping under `1`. The 5-hour window is the only window that lowers the limit: it is the one that runs out within a single working stretch, and a session that hits it mid-flight has to be restarted, which costs more than it saves. The 7-day window never lowers the limit, so a weekly allowance that is about to expire is drained at full speed rather than discarded unused; the 7-day window is instead what orders the candidates. The token whose 7-day window resets soonest among those still under their limit is selected, so allowance that is about to expire is consumed before the reset discards it; ties are broken by the fewer live sessions. All four tuning numbers (`maxConcurrentSessionCount`, `fullSpeedFiveHourFreeRatio`, `minFiveHourFreeRatio`, `minSevenDayFreeRatio`) are read from the fleet-wide config file named by `--fleetConfigFilePath` or the `TDPM_FLEET_CONFIG` environment variable, under a `liveSessionOauthTokenSelection` mapping; a key the file omits keeps its built-in value, while an unreadable file or an out-of-range value is reported as an error rather than silently ignored. A token at its limit is skipped in favour of the next soonest-resetting token that still has room, and when every eligible token is at its limit the soonest-resetting one is returned rather than none. A token that is the only eligible candidate is always chosen regardless of its weight or occupancy. The selected token string is written to stdout (pipeable) and the per-candidate decision trace is written to stderr; when no token passes the filter, nothing is written to stdout and the command exits non-zero with an explanatory message on stderr. The token-list path and cache directory are resolved exactly as for `selectOauthToken`. Because occupancy is read from `/proc/<pid>/environ`, this sub-command is Linux-specific.
|
|
170
170
|
|
|
@@ -78,30 +78,10 @@ class OauthTokenSelectHandler {
|
|
|
78
78
|
};
|
|
79
79
|
});
|
|
80
80
|
const result = this.useCase.run(candidates, input.nowEpochSeconds, this.random, OauthTokenSelectUseCase_1.CL_SCRIPT_OAUTH_TOKEN_SELECTION_THRESHOLDS);
|
|
81
|
-
if (result.selected !== null) {
|
|
82
|
-
return {
|
|
83
|
-
selectedToken: result.selected.token,
|
|
84
|
-
selectedName: result.selected.name,
|
|
85
|
-
diagnostics: this.formatDiagnostics(result, input.nowEpochSeconds),
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
const fallbackResult = this.useCase.selectFallback(candidates, input.nowEpochSeconds);
|
|
89
|
-
const primaryDiagnostics = this.formatDiagnostics(result, input.nowEpochSeconds);
|
|
90
|
-
if (fallbackResult.selected === null) {
|
|
91
|
-
return {
|
|
92
|
-
selectedToken: null,
|
|
93
|
-
selectedName: null,
|
|
94
|
-
diagnostics: primaryDiagnostics,
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
81
|
return {
|
|
98
|
-
selectedToken:
|
|
99
|
-
selectedName:
|
|
100
|
-
diagnostics:
|
|
101
|
-
...primaryDiagnostics,
|
|
102
|
-
'No eligible token passed the CL script rate-limit filter; falling back to the token with the most 5h remaining (>= 3% 7d free required).',
|
|
103
|
-
`Fallback-selected ${fallbackResult.selected.name} (highest 5h free ratio among tokens with >= 3% 7d window remaining).`,
|
|
104
|
-
],
|
|
82
|
+
selectedToken: result.selected?.token ?? null,
|
|
83
|
+
selectedName: result.selected?.name ?? null,
|
|
84
|
+
diagnostics: this.formatDiagnostics(result, input.nowEpochSeconds),
|
|
105
85
|
};
|
|
106
86
|
};
|
|
107
87
|
this.formatDiagnostics = (result, nowEpochSeconds) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OauthTokenSelectHandler.js","sourceRoot":"","sources":["../../../../src/adapter/entry-points/handlers/OauthTokenSelectHandler.ts"],"names":[],"mappings":";;;AAAA,8FAO0D;AAC1D,+DAIoC;AACpC,iEAA+D;AAc/D,MAAM,2BAA2B,GAAG,wCAAwC,CAAC;AAC7E,MAAM,2BAA2B,GAAG,0BAA0B,CAAC;AAExD,MAAM,wBAAwB,GAAG,CACtC,YAA2B,EACZ,EAAE;IACjB,IAAI,YAAY,KAAK,IAAI,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrD,OAAO,YAA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rB,IAAI,CAAC,MAAM,EACX,oEAA0C,CAC3C,CAAC;YAEF,
|
|
1
|
+
{"version":3,"file":"OauthTokenSelectHandler.js","sourceRoot":"","sources":["../../../../src/adapter/entry-points/handlers/OauthTokenSelectHandler.ts"],"names":[],"mappings":";;;AAAA,8FAO0D;AAC1D,+DAIoC;AACpC,iEAA+D;AAc/D,MAAM,2BAA2B,GAAG,wCAAwC,CAAC;AAC7E,MAAM,2BAA2B,GAAG,0BAA0B,CAAC;AAExD,MAAM,wBAAwB,GAAG,CACtC,YAA2B,EACZ,EAAE;IACjB,IAAI,YAAY,KAAK,IAAI,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrD,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;IACzD,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChD,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAXW,QAAA,wBAAwB,4BAWnC;AAEK,MAAM,qBAAqB,GAAG,CACnC,iBAAgC,EACxB,EAAE;IACV,IAAI,iBAAiB,KAAK,IAAI,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/D,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;IACzD,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChD,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,IAAA,yBAAQ,GAAE,CAAC;AACpB,CAAC,CAAC;AAXW,QAAA,qBAAqB,yBAWhC;AAEF,MAAa,uBAAuB;IAClC,YACmB,UAAmC,IAAI,iDAAuB,EAAE,EAChE,SAA0B,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,CAAC,KAAK,CAAC,MAAM,CAAC,iBAAiB,GAAG,GAAG,CAAC,qBAAqB,uBAAuB,kBAAkB,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,MAAM,EAAE,CAAC;YAC3O,CAAC,CAAC,CAAC;YAEH,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;gBAC7B,KAAK,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;YAChE,CAAC;iBAAM,CAAC;gBACN,KAAK,CAAC,IAAI,CACR,YAAY,MAAM,CAAC,QAAQ,CAAC,IAAI,gGAAgG,CACjI,CAAC;YACJ,CAAC;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAC;IA9FC,CAAC;CA+FL;AAnGD,0DAmGC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OauthTokenSelectUseCase = exports.selectWeightedCandidate = exports.sevenDayUrgencyFactor = exports.FIVE_HOUR_SPEND_DEADLINE_HOURS = exports.SEVEN_DAY_SPEND_DEADLINE_HOURS = exports.MIN_HOURS_TO_RESET = exports.SEVEN_DAY_WINDOW_HOURS = exports.
|
|
3
|
+
exports.OauthTokenSelectUseCase = exports.selectWeightedCandidate = exports.sevenDayUrgencyFactor = exports.FIVE_HOUR_SPEND_DEADLINE_HOURS = exports.SEVEN_DAY_SPEND_DEADLINE_HOURS = exports.MIN_HOURS_TO_RESET = exports.SEVEN_DAY_WINDOW_HOURS = exports.CL_SCRIPT_OAUTH_TOKEN_SELECTION_THRESHOLDS = exports.DEFAULT_OAUTH_TOKEN_SELECTION_THRESHOLDS = exports.SEVEN_DAY_MIN_FREE_RATIO = exports.FIVE_HOUR_MIN_FREE_RATIO = exports.selectionWeightOf = exports.DEFAULT_SELECTION_WEIGHT = void 0;
|
|
4
4
|
exports.DEFAULT_SELECTION_WEIGHT = 1;
|
|
5
5
|
const selectionWeightOf = (candidate) => {
|
|
6
6
|
const weight = candidate.selectionWeight ?? exports.DEFAULT_SELECTION_WEIGHT;
|
|
@@ -19,7 +19,6 @@ exports.CL_SCRIPT_OAUTH_TOKEN_SELECTION_THRESHOLDS = {
|
|
|
19
19
|
fiveHourMinFreeRatio: 0.6,
|
|
20
20
|
sevenDayMinFreeRatio: 0.14,
|
|
21
21
|
};
|
|
22
|
-
exports.CL_SCRIPT_FALLBACK_SEVEN_DAY_MIN_FREE_RATIO = 0.03;
|
|
23
22
|
exports.SEVEN_DAY_WINDOW_HOURS = 168;
|
|
24
23
|
exports.MIN_HOURS_TO_RESET = 1;
|
|
25
24
|
exports.SEVEN_DAY_SPEND_DEADLINE_HOURS = 24;
|
|
@@ -78,55 +77,6 @@ class OauthTokenSelectUseCase {
|
|
|
78
77
|
const selected = (0, exports.selectWeightedCandidate)(eligible, (entry) => entry.metric.drawWeight, deterministicBest, random);
|
|
79
78
|
return { selected: selected.candidate, metrics };
|
|
80
79
|
};
|
|
81
|
-
this.selectFallback = (candidates, nowEpochSeconds) => {
|
|
82
|
-
const evaluated = candidates.map((candidate) => {
|
|
83
|
-
const fiveHourFreeRatio = this.fiveHourFreeRatio(candidate.snapshot, nowEpochSeconds);
|
|
84
|
-
const sevenDayFreeRatio = this.sevenDayFreeRatio(candidate.snapshot, nowEpochSeconds);
|
|
85
|
-
const sevenDayEndEpoch = this.sevenDayEndEpoch(candidate.snapshot, nowEpochSeconds);
|
|
86
|
-
const hardRejectionReason = candidate.subscriptionDisabled
|
|
87
|
-
? 'organization has disabled Claude subscription access for Claude Code'
|
|
88
|
-
: candidate.unifiedRejected
|
|
89
|
-
? 'token request was rejected (anthropic-ratelimit-unified-status: rejected)'
|
|
90
|
-
: candidate.fableRejected
|
|
91
|
-
? 'fable weekly limit exhausted (a fable request was rejected with HTTP 429)'
|
|
92
|
-
: null;
|
|
93
|
-
const exclusionReason = hardRejectionReason !== null
|
|
94
|
-
? hardRejectionReason
|
|
95
|
-
: sevenDayFreeRatio < exports.CL_SCRIPT_FALLBACK_SEVEN_DAY_MIN_FREE_RATIO
|
|
96
|
-
? `7d window only ${this.toPercent(sevenDayFreeRatio)}% free (fallback requires >= 3%)`
|
|
97
|
-
: null;
|
|
98
|
-
return {
|
|
99
|
-
candidate,
|
|
100
|
-
metric: {
|
|
101
|
-
name: candidate.name,
|
|
102
|
-
fiveHourFreeRatio,
|
|
103
|
-
sevenDayFreeRatio,
|
|
104
|
-
sevenDayEndEpoch,
|
|
105
|
-
eligible: exclusionReason === null,
|
|
106
|
-
exclusionReason,
|
|
107
|
-
drawWeight: 0,
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
});
|
|
111
|
-
const eligible = evaluated.filter((entry) => entry.metric.eligible);
|
|
112
|
-
const metrics = evaluated.map((entry) => entry.metric);
|
|
113
|
-
if (eligible.length === 0) {
|
|
114
|
-
return { selected: null, metrics };
|
|
115
|
-
}
|
|
116
|
-
const best = eligible.reduce((bestEntry, currentEntry) => {
|
|
117
|
-
if (currentEntry.metric.fiveHourFreeRatio >
|
|
118
|
-
bestEntry.metric.fiveHourFreeRatio) {
|
|
119
|
-
return currentEntry;
|
|
120
|
-
}
|
|
121
|
-
if (currentEntry.metric.fiveHourFreeRatio ===
|
|
122
|
-
bestEntry.metric.fiveHourFreeRatio &&
|
|
123
|
-
currentEntry.metric.sevenDayEndEpoch < bestEntry.metric.sevenDayEndEpoch) {
|
|
124
|
-
return currentEntry;
|
|
125
|
-
}
|
|
126
|
-
return bestEntry;
|
|
127
|
-
});
|
|
128
|
-
return { selected: best.candidate, metrics };
|
|
129
|
-
};
|
|
130
80
|
this.evaluate = (candidate, nowEpochSeconds, thresholds) => {
|
|
131
81
|
const fiveHourFreeRatio = this.fiveHourFreeRatio(candidate.snapshot, nowEpochSeconds);
|
|
132
82
|
const sevenDayFreeRatio = this.sevenDayFreeRatio(candidate.snapshot, nowEpochSeconds);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OauthTokenSelectUseCase.js","sourceRoot":"","sources":["../../../src/domain/usecases/OauthTokenSelectUseCase.ts"],"names":[],"mappings":";;;AAmBa,QAAA,wBAAwB,GAAG,CAAC,CAAC;AAEnC,MAAM,iBAAiB,GAAG,CAAC,SAA8B,EAAU,EAAE;IAC1E,MAAM,MAAM,GAAG,SAAS,CAAC,eAAe,IAAI,gCAAwB,CAAC;IACrE,OAAO,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AACjC,CAAC,CAAC;AAHW,QAAA,iBAAiB,qBAG5B;AAsBF,MAAM,eAAe,GAAG,KAAK,CAAC;AAC9B,MAAM,qBAAqB,GAAG,CAAC,GAAG,eAAe,CAAC;AAErC,QAAA,wBAAwB,GAAG,IAAI,CAAC;AAChC,QAAA,wBAAwB,GAAG,IAAI,CAAC;AAEhC,QAAA,wCAAwC,GACnD;IACE,oBAAoB,EAAE,gCAAwB;IAC9C,oBAAoB,EAAE,gCAAwB;CAC/C,CAAC;AAES,QAAA,0CAA0C,GACrD;IACE,oBAAoB,EAAE,GAAG;IACzB,oBAAoB,EAAE,IAAI;CAC3B,CAAC;AAES,QAAA,
|
|
1
|
+
{"version":3,"file":"OauthTokenSelectUseCase.js","sourceRoot":"","sources":["../../../src/domain/usecases/OauthTokenSelectUseCase.ts"],"names":[],"mappings":";;;AAmBa,QAAA,wBAAwB,GAAG,CAAC,CAAC;AAEnC,MAAM,iBAAiB,GAAG,CAAC,SAA8B,EAAU,EAAE;IAC1E,MAAM,MAAM,GAAG,SAAS,CAAC,eAAe,IAAI,gCAAwB,CAAC;IACrE,OAAO,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AACjC,CAAC,CAAC;AAHW,QAAA,iBAAiB,qBAG5B;AAsBF,MAAM,eAAe,GAAG,KAAK,CAAC;AAC9B,MAAM,qBAAqB,GAAG,CAAC,GAAG,eAAe,CAAC;A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,CACzB,QAAyC,EACzC,eAAuB,EACf,EAAE;YACV,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;gBACtB,OAAO,eAAe,GAAG,qBAAqB,CAAC;YACjD,CAAC;YACD,IAAI,QAAQ,CAAC,aAAa,IAAI,CAAC,EAAE,CAAC;gBAChC,OAAO,eAAe,GAAG,qBAAqB,CAAC;YACjD,CAAC;YACD,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,aAAa,EAAE,eAAe,CAAC,EAAE,CAAC;gBAChE,OAAO,eAAe,GAAG,qBAAqB,CAAC;YACjD,CAAC;YACD,OAAO,QAAQ,CAAC,aAAa,CAAC;QAChC,CAAC,CAAC;QAEM,kBAAa,GAAG,CACtB,UAAkB,EAClB,eAAuB,EACd,EAAE,CAAC,UAAU,GAAG,CAAC,IAAI,eAAe,GAAG,UAAU,CAAC;QAErD,6BAAwB,GAAG,CAAC,WAAmB,EAAU,EAAE;YACjE,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACtD,OAAO,CAAC,GAAG,OAAO,CAAC;QACrB,CAAC,CAAC;QAEM,cAAS,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC;IACzE,CAAC;CAAA;AAxMD,0DAwMC"}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OauthTokenSelectHandler.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/handlers/OauthTokenSelectHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,uBAAuB,EACvB,KAAK,eAAe,EACrB,MAAM,kDAAkD,CAAC;AAQ1D,MAAM,MAAM,4BAA4B,GAAG;IACzC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAKF,eAAO,MAAM,wBAAwB,GACnC,cAAc,MAAM,GAAG,IAAI,KAC1B,MAAM,GAAG,IASX,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,mBAAmB,MAAM,GAAG,IAAI,KAC/B,MASF,CAAC;AAEF,qBAAa,uBAAuB;IAEhC,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,GAAE,uBAAuD,EAChE,MAAM,GAAE,eAA6B;IAGxD,MAAM,GACJ,OAAO,4BAA4B,KAClC,6BAA6B,
|
|
1
|
+
{"version":3,"file":"OauthTokenSelectHandler.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/handlers/OauthTokenSelectHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,uBAAuB,EACvB,KAAK,eAAe,EACrB,MAAM,kDAAkD,CAAC;AAQ1D,MAAM,MAAM,4BAA4B,GAAG;IACzC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAKF,eAAO,MAAM,wBAAwB,GACnC,cAAc,MAAM,GAAG,IAAI,KAC1B,MAAM,GAAG,IASX,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,mBAAmB,MAAM,GAAG,IAAI,KAC/B,MASF,CAAC;AAEF,qBAAa,uBAAuB;IAEhC,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,GAAE,uBAAuD,EAChE,MAAM,GAAE,eAA6B;IAGxD,MAAM,GACJ,OAAO,4BAA4B,KAClC,6BAA6B,CAiE9B;IAEF,OAAO,CAAC,iBAAiB,CAuBvB;CACH"}
|
|
@@ -37,7 +37,6 @@ export declare const FIVE_HOUR_MIN_FREE_RATIO = 0.25;
|
|
|
37
37
|
export declare const SEVEN_DAY_MIN_FREE_RATIO = 0.01;
|
|
38
38
|
export declare const DEFAULT_OAUTH_TOKEN_SELECTION_THRESHOLDS: OauthTokenSelectionThresholds;
|
|
39
39
|
export declare const CL_SCRIPT_OAUTH_TOKEN_SELECTION_THRESHOLDS: OauthTokenSelectionThresholds;
|
|
40
|
-
export declare const CL_SCRIPT_FALLBACK_SEVEN_DAY_MIN_FREE_RATIO = 0.03;
|
|
41
40
|
export declare const SEVEN_DAY_WINDOW_HOURS = 168;
|
|
42
41
|
export declare const MIN_HOURS_TO_RESET = 1;
|
|
43
42
|
export declare const SEVEN_DAY_SPEND_DEADLINE_HOURS = 24;
|
|
@@ -46,7 +45,6 @@ export declare const sevenDayUrgencyFactor: (sevenDayFreeRatio: number, sevenDay
|
|
|
46
45
|
export declare const selectWeightedCandidate: <Entry>(eligible: Entry[], weightOf: (entry: Entry) => number, deterministicBest: Entry, random: SelectionRandom) => Entry;
|
|
47
46
|
export declare class OauthTokenSelectUseCase {
|
|
48
47
|
run: (candidates: OauthTokenCandidate[], nowEpochSeconds: number, random?: SelectionRandom, thresholds?: OauthTokenSelectionThresholds) => OauthTokenSelectResult;
|
|
49
|
-
selectFallback: (candidates: OauthTokenCandidate[], nowEpochSeconds: number) => OauthTokenSelectResult;
|
|
50
48
|
private evaluate;
|
|
51
49
|
private exclusionReason;
|
|
52
50
|
private deadlinePassed;
|
|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