github-issue-tower-defence-management 1.82.1 → 1.84.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.
- package/.github/workflows/commit-lint.yml +7 -2
- package/.github/workflows/create-pr.yml +23 -5
- package/CHANGELOG.md +14 -0
- package/README.md +67 -4
- package/bin/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.js +19 -2
- package/bin/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.js.map +1 -1
- package/bin/adapter/entry-points/handlers/consoleListsWriter.js +43 -0
- package/bin/adapter/entry-points/handlers/consoleListsWriter.js.map +1 -0
- package/bin/domain/usecases/StartPreparationUseCase.js +60 -46
- package/bin/domain/usecases/StartPreparationUseCase.js.map +1 -1
- package/bin/domain/usecases/console/GenerateConsoleListsUseCase.js +101 -0
- package/bin/domain/usecases/console/GenerateConsoleListsUseCase.js.map +1 -0
- package/package.json +1 -1
- package/src/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.ts +18 -0
- package/src/adapter/entry-points/handlers/consoleListsWriter.test.ts +167 -0
- package/src/adapter/entry-points/handlers/consoleListsWriter.ts +60 -0
- package/src/domain/usecases/StartPreparationUseCase.test.ts +265 -68
- package/src/domain/usecases/StartPreparationUseCase.ts +94 -73
- package/src/domain/usecases/console/GenerateConsoleListsUseCase.test.ts +372 -0
- package/src/domain/usecases/console/GenerateConsoleListsUseCase.ts +206 -0
- package/types/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.d.ts.map +1 -1
- package/types/adapter/entry-points/handlers/consoleListsWriter.d.ts +13 -0
- package/types/adapter/entry-points/handlers/consoleListsWriter.d.ts.map +1 -0
- package/types/domain/usecases/StartPreparationUseCase.d.ts +1 -0
- package/types/domain/usecases/StartPreparationUseCase.d.ts.map +1 -1
- package/types/domain/usecases/console/GenerateConsoleListsUseCase.d.ts +63 -0
- package/types/domain/usecases/console/GenerateConsoleListsUseCase.d.ts.map +1 -0
|
@@ -54,7 +54,12 @@ jobs:
|
|
|
54
54
|
loose-matching: true
|
|
55
55
|
- name: Install commitlint
|
|
56
56
|
run: |
|
|
57
|
-
|
|
57
|
+
mkdir -p /tmp/commitlint-run
|
|
58
|
+
cd /tmp/commitlint-run
|
|
59
|
+
npm init -y
|
|
60
|
+
npm install --no-audit --no-fund --save-dev @commitlint/cli @commitlint/config-conventional
|
|
58
61
|
- name: Lint commits
|
|
62
|
+
env:
|
|
63
|
+
NODE_PATH: /tmp/commitlint-run/node_modules
|
|
59
64
|
run: |
|
|
60
|
-
|
|
65
|
+
/tmp/commitlint-run/node_modules/.bin/commitlint --from=origin/main --to=HEAD --config $GITHUB_WORKSPACE/.github/workflows/configs/commitlint.config.js
|
|
@@ -76,18 +76,36 @@ jobs:
|
|
|
76
76
|
- name: Enable Auto Merge for PR
|
|
77
77
|
if: steps.resolve_pr.outputs.pr_number
|
|
78
78
|
run: |
|
|
79
|
+
RULESET_METHOD=$(gh api "repos/${{ github.repository }}/rules/branches/main" \
|
|
80
|
+
--jq '[.[] | select(.type == "pull_request") | .parameters.allowed_merge_methods // empty][0][0]' 2>/dev/null || echo "")
|
|
81
|
+
if [ -n "$RULESET_METHOD" ] && [ "$RULESET_METHOD" != "null" ]; then
|
|
82
|
+
MERGE_METHOD=$(echo "$RULESET_METHOD" | tr '[:lower:]' '[:upper:]')
|
|
83
|
+
else
|
|
84
|
+
ALLOW_SQUASH=$(gh api "repos/${{ github.repository }}" --jq '.allow_squash_merge')
|
|
85
|
+
ALLOW_REBASE=$(gh api "repos/${{ github.repository }}" --jq '.allow_rebase_merge')
|
|
86
|
+
if [ "$ALLOW_SQUASH" = "true" ]; then
|
|
87
|
+
MERGE_METHOD="SQUASH"
|
|
88
|
+
elif [ "$ALLOW_REBASE" = "true" ]; then
|
|
89
|
+
MERGE_METHOD="REBASE"
|
|
90
|
+
else
|
|
91
|
+
MERGE_METHOD="MERGE"
|
|
92
|
+
fi
|
|
93
|
+
fi
|
|
79
94
|
RESPONSE=$(curl -s -X POST \
|
|
80
95
|
-H "Authorization: bearer ${{ steps.app-token.outputs.token }}" \
|
|
81
96
|
-H "Content-Type: application/json" \
|
|
82
|
-
-d
|
|
83
|
-
"query": "mutation(
|
|
84
|
-
"variables": {
|
|
85
|
-
"id": "
|
|
97
|
+
-d "{
|
|
98
|
+
\"query\": \"mutation(\$id: ID!, \$mergeMethod: PullRequestMergeMethod!) { enablePullRequestAutoMerge(input: { pullRequestId: \$id, mergeMethod: \$mergeMethod }) { clientMutationId } }\",
|
|
99
|
+
\"variables\": {
|
|
100
|
+
\"id\": \"${{ steps.get_pr_id.outputs.node_id }}\",
|
|
101
|
+
\"mergeMethod\": \"$MERGE_METHOD\"
|
|
86
102
|
}
|
|
87
|
-
}
|
|
103
|
+
}" \
|
|
88
104
|
"https://api.github.com/graphql")
|
|
89
105
|
echo "$RESPONSE"
|
|
90
106
|
if echo "$RESPONSE" | jq -e '.errors' >/dev/null; then
|
|
91
107
|
echo "Failed to enable auto merge"
|
|
92
108
|
exit 1
|
|
93
109
|
fi
|
|
110
|
+
env:
|
|
111
|
+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [1.84.0](https://github.com/HiromiShikata/npm-cli-github-issue-tower-defence-management/compare/v1.83.0...v1.84.0) (2026-06-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **console:** generate per-tab Console list.json files in scheduled cycle ([#831](https://github.com/HiromiShikata/npm-cli-github-issue-tower-defence-management/issues/831)) ([0368fb7](https://github.com/HiromiShikata/npm-cli-github-issue-tower-defence-management/commit/0368fb74d572a5d9b73966440da2c62669d1d4f4))
|
|
7
|
+
|
|
8
|
+
# [1.83.0](https://github.com/HiromiShikata/npm-cli-github-issue-tower-defence-management/compare/v1.82.1...v1.83.0) (2026-06-14)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **core:** route spawn model per token from each token's weekly availability ([#829](https://github.com/HiromiShikata/npm-cli-github-issue-tower-defence-management/issues/829)) ([d270a26](https://github.com/HiromiShikata/npm-cli-github-issue-tower-defence-management/commit/d270a2609ed17fff33e010a236af17d9838928be)), closes [#828](https://github.com/HiromiShikata/npm-cli-github-issue-tower-defence-management/issues/828)
|
|
14
|
+
|
|
1
15
|
## [1.82.1](https://github.com/HiromiShikata/npm-cli-github-issue-tower-defence-management/compare/v1.82.0...v1.82.1) (2026-06-12)
|
|
2
16
|
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ Options for startDaemon:
|
|
|
33
33
|
--projectUrl <url> GitHub project URL
|
|
34
34
|
--defaultAgentName <name> Default agent name
|
|
35
35
|
--defaultLlmModelName <name> Default LLM model name
|
|
36
|
-
--fallbackLlmModelName <name> LLM model
|
|
36
|
+
--fallbackLlmModelName <name> LLM model a token falls back to when the default Sonnet model's 7-day weekly limit is exhausted for that token while its fallback weekly window still has capacity; routing is decided per token, so tokens with Sonnet headroom keep using Sonnet in the same pass (default: claude-opus-4-8)
|
|
37
37
|
--defaultLlmAgentName <name> Default LLM agent name
|
|
38
38
|
--maximumPreparingIssuesCount <count> Maximum number of issues in preparation status (default: 6 per available Claude OAuth token, otherwise 6)
|
|
39
39
|
--allowIssueCacheMinutes <minutes> Allow cache for issues in minutes (default: 10)
|
|
@@ -108,7 +108,7 @@ startPreparation?: # Optional: Enable automatic issue preparation workflow
|
|
|
108
108
|
defaultAgentName: string # Default agent name to assign for preparation
|
|
109
109
|
configFilePath: string # Path to config file passed to the aw command
|
|
110
110
|
defaultLlmModelName?: string | null # Optional: Default LLM model name (overridable via llm-model: label)
|
|
111
|
-
fallbackLlmModelName?: string | null # Optional: LLM model
|
|
111
|
+
fallbackLlmModelName?: string | null # Optional: LLM model a token falls back to when defaultLlmModelName is a Sonnet model and that token's 7-day Sonnet weekly limit is exhausted while its fallback weekly window still has capacity (default: claude-opus-4-8). Routing is decided per token, so tokens with Sonnet headroom keep using Sonnet in the same pass. Per-issue llm-model: labels remain authoritative and are never overridden by the fallback
|
|
112
112
|
defaultLlmAgentName?: string | null # Optional: Default LLM agent name (overridable via llm-agent: label)
|
|
113
113
|
maximumPreparingIssuesCount: number | null # Max concurrent preparing issues. When token rotation is active, effective concurrency is also capped at 6 per available token. When null, the default is 6 per available token, or 6 without token rotation
|
|
114
114
|
utilizationPercentageThreshold?: number # Optional: 5-hour utilization hard threshold (percentage, default 90). Tokens at or above this value are excluded from rotation
|
|
@@ -185,7 +185,7 @@ projectUrl: string # URL of the GitHub project
|
|
|
185
185
|
projectName: string # Project name (used for cache directory path)
|
|
186
186
|
defaultAgentName: string # Default agent name for issue preparation
|
|
187
187
|
defaultLlmModelName?: string # Optional: Default LLM model name
|
|
188
|
-
fallbackLlmModelName?: string # Optional: LLM model
|
|
188
|
+
fallbackLlmModelName?: string # Optional: LLM model a token falls back to when defaultLlmModelName is a Sonnet model and that token's 7-day Sonnet weekly limit is exhausted while its fallback weekly window still has capacity (default: claude-opus-4-8). Routing is decided per token, so tokens with Sonnet headroom keep using Sonnet in the same pass. Per-issue llm-model: labels remain authoritative
|
|
189
189
|
defaultLlmAgentName?: string # Optional: Default LLM agent name
|
|
190
190
|
maximumPreparingIssuesCount?: number # Optional: Max concurrent preparing issues. When token rotation is active, effective concurrency is also capped at 6 per available token. Omitted defaults to 6 per available token, or 6 without token rotation
|
|
191
191
|
allowIssueCacheMinutes?: number # Optional: Allow cache for issues in minutes (default: 10)
|
|
@@ -199,6 +199,7 @@ claudeCodeOauthTokenListJsonPath?: string # Optional: Path to a JSON file listin
|
|
|
199
199
|
awLogDirectoryPath?: string # Optional: Directory path where aw log files named {org}_{repo}_{number}_* are written. Used with awLogStaleThresholdMinutes to detect zombie-wrapper orphans
|
|
200
200
|
awLogStaleThresholdMinutes?: number # Optional: Minutes since last aw log mtime after which a Preparation issue is considered orphaned even when pgrep still returns 0. Requires awLogDirectoryPath
|
|
201
201
|
labelsAsLlmAgentName?: string[] # Optional: List of issue labels that are themselves agent names. When an issue carries any label that is included in this list, that label name is used as the agent name. Selection precedence is: (1) explicit `llm-agent:` label, (2) labelsAsLlmAgentName entry match, (3) `category:` label, (4) defaultLlmAgentName, (5) defaultAgentName
|
|
202
|
+
consoleDataOutputDir?: string # Optional: Base output directory for the per-project Console list.json files written each schedule cycle. When unset, Console list generation is skipped
|
|
202
203
|
changeTargetPathAliases?: # Optional: Map of short alias keys to full repository-root-relative directory paths. Allows `change-target:<alias>` labels to reference deeply nested paths that exceed GitHub's 50-character label limit. When a `change-target:` label's value matches a key in this map, it is expanded to the corresponding full path before confinement checking. Values with leading or trailing slashes are normalized automatically. Example below
|
|
203
204
|
adapter-interfaces: src/domain/usecases/adapter-interfaces
|
|
204
205
|
```
|
|
@@ -246,7 +247,7 @@ When `claudeCodeOauthTokenListJsonPath` is set, `startDaemon` distributes prepar
|
|
|
246
247
|
|
|
247
248
|
2. Local reverse proxy (`127.0.0.1:8787`): on each `startDaemon` run, the daemon TCP-probes the port. If nothing responds, it spawns a detached child running `bin/adapter/proxy/proxyEntry.js`. The proxy forwards every request to `api.anthropic.com`, observes the `anthropic-ratelimit-unified-*` response headers, and writes them to a per-token cache file at `${XDG_CACHE_HOME:-~/.cache}/tdpm/ratelimit/<sha256-of-token>.json`. The cache file stores the latest 5-hour and 7-day utilization, reset epochs, and the unified, 5-hour, and 7-day statuses (used to detect `blocked` and `rejected` state per window). In addition to the unified headers, the proxy inspects the streamed response body for `rate_limit` events (objects carrying `rateLimitType`, `status`, and `resetsAt`) and records the model-specific weekly limits — at minimum `seven_day_sonnet` and `seven_day` — per token. These model-specific weekly limits are exposed only in the response body, never in the unified headers, so a token can appear healthy on `anthropic-ratelimit-unified-7d-*` while its Sonnet weekly limit is exhausted. When a response is an HTTP 429 that carries no `anthropic-ratelimit-*` headers at all (for example a `rate_limit_error` with `x-should-retry: true`), the proxy records a short-lived per-token cooldown as a `blockedUntilEpoch` field on that token's cache file without discarding the last-good snapshot: the cooldown end is `now + Retry-After` seconds when the `Retry-After` header is present (clamped to a maximum of 600 seconds), otherwise a fixed default of 90 seconds. A later response that does carry `anthropic-ratelimit-*` headers overwrites the cache and clears the cooldown.
|
|
248
249
|
|
|
249
|
-
3. Selection: before spawning each `aw` job, the daemon reads every token's cache file. A cached observation is treated as expired once its reset epoch has passed: when the current time is past the 5-hour reset, that token's 5-hour utilization is treated as `0` and any 5-hour-window rejection is cleared; likewise, when the 7-day reset has passed, the 7-day utilization is treated as `0` and any 7-day-window rejection is cleared; a model-specific weekly limit rejection is cleared once that limit's `resetsAt` has passed. This stale-reset expiry prevents a token that has actually recovered from being locked out of rotation forever (an excluded token receives no new requests, so the proxy never re-observes it). After expiry normalization, tokens whose status is `blocked`, whose remaining (non-expired) rejection is still active, whose `blockedUntilEpoch` cooldown is still in the future, whose 5-hour utilization meets or exceeds the configured threshold
|
|
250
|
+
3. Selection: before spawning each `aw` job, the daemon reads every token's cache file. A cached observation is treated as expired once its reset epoch has passed: when the current time is past the 5-hour reset, that token's 5-hour utilization is treated as `0` and any 5-hour-window rejection is cleared; likewise, when the 7-day reset has passed, the 7-day utilization is treated as `0` and any 7-day-window rejection is cleared; a model-specific weekly limit rejection is cleared once that limit's `resetsAt` has passed. This stale-reset expiry prevents a token that has actually recovered from being locked out of rotation forever (an excluded token receives no new requests, so the proxy never re-observes it). After expiry normalization, tokens whose status is `blocked`, whose remaining (non-expired) rejection is still active, whose `blockedUntilEpoch` cooldown is still in the future, or whose 5-hour utilization meets or exceeds the configured threshold are excluded. The model for each remaining token is then routed independently: the configured default model is preferred when that token's matching weekly window is not rejected, otherwise the configured fallback model (default `claude-opus-4-8`) is used when its matching weekly window is not rejected; a token is excluded for weekly limits only when every candidate model's weekly window is rejected or the generic `seven_day` window is rejected. This routing is per token, so within a single pass a token whose `seven_day_sonnet` window is exhausted is spawned on the fallback Opus model while sibling tokens that still have Sonnet headroom keep using Sonnet. A cooled-down token becomes selectable again automatically once its `blockedUntilEpoch` has passed. The model name maps to a limit type: a model name containing `sonnet` maps to `seven_day_sonnet`, one containing `opus` maps to `seven_day_opus`, otherwise `seven_day`; the generic `seven_day` rejection excludes a token regardless of model. The remaining eligible tokens are sorted by time until the 7-day reset deadline ascending (soonest 7-day reset first, so quota that would otherwise expire unused is consumed first), with 5-hour utilization ascending as the tiebreaker. The 7-day reset deadline for a given spawn is read from the per-model weekly limit entry in `modelWeeklyLimits` matching the model that will be used (`seven_day_sonnet`, `seven_day_opus`, or the generic `seven_day`); when no model-specific or generic `seven_day` entry exists but the cache snapshot recorded a non-expired top-level `anthropic-ratelimit-unified-7d-reset` deadline, that header value is bridged into a synthesized generic `seven_day` entry whose `rejected` flag matches the (non-expired) `anthropic-ratelimit-unified-7d-status` rejection. When neither source supplies a deadline, the token is treated as having an infinite deadline and sorts last. Each token's per-run concurrent preparation slot count is determined by both its 5-hour and 7-day utilization, taking the more restrictive (minimum) of the two so concurrency ramps down as either window fills: for each window, at or below 80% the token receives the full six concurrent slots; above 80%, the slot count is reduced proportionally — specifically `ceil(6 × (1 − util) / 0.2)` — with a minimum of 1 slot at any utilization level, so near-exhausted tokens still participate rather than being cut off entirely. The final slot count is the minimum of the 5-hour-derived and 7-day-derived counts. Before each `aw` spawn, among the tokens that still have an available slot (slot count minus the in-flight count minus the count already spawned this run, greater than zero), the token whose 7-day reset is soonest is selected; in-flight slot count from prior runs no longer routes new work away from a soon-reset token, so a soon-reset token's slots are filled before a later-reset token receives any, and remaining slot count is used only as the tiebreaker when two candidates share the same 7-day reset. The effective preparation limit for a run is the lesser of the sum of all eligible tokens' slot counts and the explicit `maximumPreparingIssuesCount` (which defaults to 6). When a token list is configured but no eligible token remains after filtering, preparation is skipped for that run. The selected token and the proxy URL (`http://127.0.0.1:8787`) are passed to the child `aw` process as `CLAUDE_CODE_OAUTH_TOKEN` and `ANTHROPIC_BASE_URL` environment variables. The child inherits the parent process's environment, so no further wiring is required inside `aw`.
|
|
250
251
|
|
|
251
252
|
When `claudeCodeOauthTokenListJsonPath` is unset, no proxy is started and `aw` runs with whatever `CLAUDE_CODE_OAUTH_TOKEN` and `ANTHROPIC_BASE_URL` are already in the environment.
|
|
252
253
|
|
|
@@ -331,6 +332,68 @@ This file is written atomically (written to a `.tmp` file then renamed) so exter
|
|
|
331
332
|
|
|
332
333
|
System metrics are read from `/proc/meminfo` at snapshot write time.
|
|
333
334
|
|
|
335
|
+
## Per-Project Console Lists
|
|
336
|
+
|
|
337
|
+
When `consoleDataOutputDir` is configured, each schedule cycle also writes four per-tab Console list files, generated from the same in-memory project and issue data already loaded for the cycle (no additional GitHub API calls):
|
|
338
|
+
|
|
339
|
+
```
|
|
340
|
+
{consoleDataOutputDir}/{projectName}/{tab}/list.json
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
for `tab` in `prs`, `triage`, `unread`, and `failed-preparation`. Each file is written atomically (written to a `.tmp` file then renamed) so external readers never see a partial write. When `consoleDataOutputDir` is unset the generation is skipped, and any error during generation is logged and swallowed so the schedule cycle is never affected.
|
|
344
|
+
|
|
345
|
+
### Item Selection
|
|
346
|
+
|
|
347
|
+
Every tab applies a common actionable filter to the project's issues: the issue is open, is assigned to the project manager, has no depended issue URLs, and has neither a next action date nor a next action hour set. Each tab then applies its own selector:
|
|
348
|
+
|
|
349
|
+
- `prs`: status equals `Awaiting Quality Check` (case-insensitive)
|
|
350
|
+
- `unread`: status equals `Unread` (case-insensitive)
|
|
351
|
+
- `failed-preparation`: status equals `Failed Preparation` (exact case)
|
|
352
|
+
- `triage`: story name contains `no story` (case-insensitive)
|
|
353
|
+
|
|
354
|
+
### JSON Shape
|
|
355
|
+
|
|
356
|
+
The `prs`, `unread`, and `failed-preparation` tabs share this shape:
|
|
357
|
+
|
|
358
|
+
```json
|
|
359
|
+
{
|
|
360
|
+
"pjcode": "my-project",
|
|
361
|
+
"generatedAt": "2026-06-14T07:22:33Z",
|
|
362
|
+
"statusOptions": [
|
|
363
|
+
{ "id": "...", "name": "Awaiting Workspace", "color": "BLUE" }
|
|
364
|
+
],
|
|
365
|
+
"storyOrder": ["Story Alpha", "Story Beta"],
|
|
366
|
+
"storyColors": { "Story Alpha": { "color": "BLUE" } },
|
|
367
|
+
"items": [
|
|
368
|
+
{
|
|
369
|
+
"number": 1,
|
|
370
|
+
"title": "Example",
|
|
371
|
+
"url": "https://github.com/owner/repo/issues/1",
|
|
372
|
+
"repo": "owner/repo",
|
|
373
|
+
"nameWithOwner": "owner/repo",
|
|
374
|
+
"projectItemId": "...",
|
|
375
|
+
"itemId": "...",
|
|
376
|
+
"isPr": false,
|
|
377
|
+
"story": "Story Alpha",
|
|
378
|
+
"labels": ["bug"],
|
|
379
|
+
"createdAt": "2026-06-13T08:18:45.000Z"
|
|
380
|
+
}
|
|
381
|
+
]
|
|
382
|
+
}
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
The `triage` tab omits `statusOptions`, adds `storyOptions` (all story field options), and uses plain color string values in `storyColors` (for example `"Story Alpha": "BLUE"`).
|
|
386
|
+
|
|
387
|
+
### Field Descriptions
|
|
388
|
+
|
|
389
|
+
- `pjcode`: The configured project name.
|
|
390
|
+
- `generatedAt`: UTC timestamp (no milliseconds) when the lists were generated. Item `createdAt` values keep milliseconds.
|
|
391
|
+
- `statusOptions`: Project status field options offered as routing buttons. The current-status option and `Done` are excluded; `failed-preparation` additionally excludes `Preparation`, `Icebox`, `Unread`, and `In Tmux by human`.
|
|
392
|
+
- `storyOptions` (triage tab only): All story field options.
|
|
393
|
+
- `storyOrder`: Story field option names in field order (empty array when the project has no story field).
|
|
394
|
+
- `storyColors`: Map from story name to its color. Object value (`{ "color": ... }`) for `prs`/`unread`/`failed-preparation`; plain string value for `triage`.
|
|
395
|
+
- `items`: Selected issues, stable-sorted by their story's position in `storyOrder` (unknown stories sorted last). No item carries a `body` field.
|
|
396
|
+
|
|
334
397
|
## Token Rotation Order File
|
|
335
398
|
|
|
336
399
|
After each schedule cycle where Claude OAuth token rotation is active, TDPM writes the computed rotation order to:
|
|
@@ -43,6 +43,7 @@ const yaml_1 = __importDefault(require("yaml"));
|
|
|
43
43
|
const typia_1 = __importDefault(require("typia"));
|
|
44
44
|
const fs_1 = __importDefault(require("fs"));
|
|
45
45
|
const situationFileWriter_1 = require("./situationFileWriter");
|
|
46
|
+
const consoleListsWriter_1 = require("./consoleListsWriter");
|
|
46
47
|
const rotationOrderFileWriter_1 = require("./rotationOrderFileWriter");
|
|
47
48
|
const projectConfig_1 = require("../cli/projectConfig");
|
|
48
49
|
const SystemDateRepository_1 = require("../../repositories/SystemDateRepository");
|
|
@@ -86,13 +87,13 @@ class HandleScheduledEventUseCaseHandler {
|
|
|
86
87
|
this.handle = async (configFilePath, _verbose) => {
|
|
87
88
|
const configFileContent = fs_1.default.readFileSync(configFilePath, 'utf8');
|
|
88
89
|
const input = yaml_1.default.parse(configFileContent);
|
|
89
|
-
if (!(() => { const _io0 = input => "string" === typeof input.projectName && "string" === typeof input.org && "string" === typeof input.projectUrl && "string" === typeof input.manager && ("object" === typeof input.workingReport && null !== input.workingReport && _io1(input.workingReport)) && "string" === typeof input.urlOfStoryView && "boolean" === typeof input.disabled && "number" === typeof input.allowIssueCacheMinutes && (null === input.labelsAsLlmAgentName || undefined === input.labelsAsLlmAgentName || Array.isArray(input.labelsAsLlmAgentName) && input.labelsAsLlmAgentName.every(elem => "string" === typeof elem)) && (null === input.changeTargetPathAliases || undefined === input.changeTargetPathAliases || "object" === typeof input.changeTargetPathAliases && null !== input.changeTargetPathAliases && false === Array.isArray(input.changeTargetPathAliases) && _io2(input.changeTargetPathAliases)) && (null === input.startPreparation || undefined === input.startPreparation || "object" === typeof input.startPreparation && null !== input.startPreparation && _io3(input.startPreparation)) && (undefined === input.thresholdForAutoReject || "number" === typeof input.thresholdForAutoReject) && (null === input.dailySecurityScan || undefined === input.dailySecurityScan || "object" === typeof input.dailySecurityScan && null !== input.dailySecurityScan && _io4(input.dailySecurityScan)) && (undefined === input.claudeCodeOauthTokenListJsonPath || "string" === typeof input.claudeCodeOauthTokenListJsonPath) && ("object" === typeof input.credentials && null !== input.credentials && _io5(input.credentials)); const _io1 = input => "string" === typeof input.repo && (Array.isArray(input.members) && input.members.every(elem => "string" === typeof elem)) && "string" === typeof input.spreadsheetUrl; const _io2 = input => Object.keys(input).every(key => {
|
|
90
|
+
if (!(() => { const _io0 = input => "string" === typeof input.projectName && "string" === typeof input.org && "string" === typeof input.projectUrl && "string" === typeof input.manager && ("object" === typeof input.workingReport && null !== input.workingReport && _io1(input.workingReport)) && "string" === typeof input.urlOfStoryView && "boolean" === typeof input.disabled && "number" === typeof input.allowIssueCacheMinutes && (null === input.labelsAsLlmAgentName || undefined === input.labelsAsLlmAgentName || Array.isArray(input.labelsAsLlmAgentName) && input.labelsAsLlmAgentName.every(elem => "string" === typeof elem)) && (null === input.changeTargetPathAliases || undefined === input.changeTargetPathAliases || "object" === typeof input.changeTargetPathAliases && null !== input.changeTargetPathAliases && false === Array.isArray(input.changeTargetPathAliases) && _io2(input.changeTargetPathAliases)) && (null === input.startPreparation || undefined === input.startPreparation || "object" === typeof input.startPreparation && null !== input.startPreparation && _io3(input.startPreparation)) && (undefined === input.thresholdForAutoReject || "number" === typeof input.thresholdForAutoReject) && (null === input.dailySecurityScan || undefined === input.dailySecurityScan || "object" === typeof input.dailySecurityScan && null !== input.dailySecurityScan && _io4(input.dailySecurityScan)) && (undefined === input.claudeCodeOauthTokenListJsonPath || "string" === typeof input.claudeCodeOauthTokenListJsonPath) && (undefined === input.consoleDataOutputDir || "string" === typeof input.consoleDataOutputDir) && ("object" === typeof input.credentials && null !== input.credentials && _io5(input.credentials)); const _io1 = input => "string" === typeof input.repo && (Array.isArray(input.members) && input.members.every(elem => "string" === typeof elem)) && "string" === typeof input.spreadsheetUrl; const _io2 = input => Object.keys(input).every(key => {
|
|
90
91
|
const value = input[key];
|
|
91
92
|
if (undefined === value)
|
|
92
93
|
return true;
|
|
93
94
|
return "string" === typeof value;
|
|
94
95
|
}); const _io3 = input => "string" === typeof input.defaultAgentName && (null === input.defaultLlmModelName || undefined === input.defaultLlmModelName || "string" === typeof input.defaultLlmModelName) && (null === input.fallbackLlmModelName || undefined === input.fallbackLlmModelName || "string" === typeof input.fallbackLlmModelName) && (null === input.defaultLlmAgentName || undefined === input.defaultLlmAgentName || "string" === typeof input.defaultLlmAgentName) && "string" === typeof input.configFilePath && (null === input.maximumPreparingIssuesCount || "number" === typeof input.maximumPreparingIssuesCount) && (undefined === input.utilizationPercentageThreshold || "number" === typeof input.utilizationPercentageThreshold) && (null === input.allowedIssueAuthors || undefined === input.allowedIssueAuthors || Array.isArray(input.allowedIssueAuthors) && input.allowedIssueAuthors.every(elem => "string" === typeof elem)) && (undefined === input.preparationProcessCheckCommand || "string" === typeof input.preparationProcessCheckCommand) && (null === input.codexHomeCandidates || undefined === input.codexHomeCandidates || Array.isArray(input.codexHomeCandidates) && input.codexHomeCandidates.every(elem => "string" === typeof elem)) && (undefined === input.awLogDirectoryPath || "string" === typeof input.awLogDirectoryPath) && (undefined === input.awLogStaleThresholdMinutes || "number" === typeof input.awLogStaleThresholdMinutes) && (null === input.awaitingQualityCheckStatus || undefined === input.awaitingQualityCheckStatus || "string" === typeof input.awaitingQualityCheckStatus) && (null === input.labelsAsLlmAgentName || undefined === input.labelsAsLlmAgentName || Array.isArray(input.labelsAsLlmAgentName) && input.labelsAsLlmAgentName.every(elem => "string" === typeof elem)); const _io4 = input => "string" === typeof input.scanBaseDirectory && "number" === typeof input.targetHourUtc && (undefined === input.enableKevNvdReport || "boolean" === typeof input.enableKevNvdReport) && (undefined === input.kevReportRepo || "string" === typeof input.kevReportRepo); const _io5 = input => "object" === typeof input.manager && null !== input.manager && _io6(input.manager) && ("object" === typeof input.bot && null !== input.bot && _io10(input.bot)); const _io6 = input => "object" === typeof input.github && null !== input.github && _io7(input.github) && ("object" === typeof input.slack && null !== input.slack && _io8(input.slack)) && ("object" === typeof input.googleServiceAccount && null !== input.googleServiceAccount && _io9(input.googleServiceAccount)); const _io7 = input => "string" === typeof input.token; const _io8 = input => "string" === typeof input.userToken; const _io9 = input => "string" === typeof input.serviceAccountKey; const _io10 = input => "object" === typeof input.github && null !== input.github && _io11(input.github); const _io11 = input => "string" === typeof input.token; return input => "object" === typeof input && null !== input && _io0(input); })()(input)) {
|
|
95
|
-
throw new Error(`Invalid input: ${JSON.stringify(input)}\n\n${JSON.stringify((() => { const _io0 = input => "string" === typeof input.projectName && "string" === typeof input.org && "string" === typeof input.projectUrl && "string" === typeof input.manager && ("object" === typeof input.workingReport && null !== input.workingReport && _io1(input.workingReport)) && "string" === typeof input.urlOfStoryView && "boolean" === typeof input.disabled && "number" === typeof input.allowIssueCacheMinutes && (null === input.labelsAsLlmAgentName || undefined === input.labelsAsLlmAgentName || Array.isArray(input.labelsAsLlmAgentName) && input.labelsAsLlmAgentName.every(elem => "string" === typeof elem)) && (null === input.changeTargetPathAliases || undefined === input.changeTargetPathAliases || "object" === typeof input.changeTargetPathAliases && null !== input.changeTargetPathAliases && false === Array.isArray(input.changeTargetPathAliases) && _io2(input.changeTargetPathAliases)) && (null === input.startPreparation || undefined === input.startPreparation || "object" === typeof input.startPreparation && null !== input.startPreparation && _io3(input.startPreparation)) && (undefined === input.thresholdForAutoReject || "number" === typeof input.thresholdForAutoReject) && (null === input.dailySecurityScan || undefined === input.dailySecurityScan || "object" === typeof input.dailySecurityScan && null !== input.dailySecurityScan && _io4(input.dailySecurityScan)) && (undefined === input.claudeCodeOauthTokenListJsonPath || "string" === typeof input.claudeCodeOauthTokenListJsonPath) && ("object" === typeof input.credentials && null !== input.credentials && _io5(input.credentials)); const _io1 = input => "string" === typeof input.repo && (Array.isArray(input.members) && input.members.every(elem => "string" === typeof elem)) && "string" === typeof input.spreadsheetUrl; const _io2 = input => Object.keys(input).every(key => {
|
|
96
|
+
throw new Error(`Invalid input: ${JSON.stringify(input)}\n\n${JSON.stringify((() => { const _io0 = input => "string" === typeof input.projectName && "string" === typeof input.org && "string" === typeof input.projectUrl && "string" === typeof input.manager && ("object" === typeof input.workingReport && null !== input.workingReport && _io1(input.workingReport)) && "string" === typeof input.urlOfStoryView && "boolean" === typeof input.disabled && "number" === typeof input.allowIssueCacheMinutes && (null === input.labelsAsLlmAgentName || undefined === input.labelsAsLlmAgentName || Array.isArray(input.labelsAsLlmAgentName) && input.labelsAsLlmAgentName.every(elem => "string" === typeof elem)) && (null === input.changeTargetPathAliases || undefined === input.changeTargetPathAliases || "object" === typeof input.changeTargetPathAliases && null !== input.changeTargetPathAliases && false === Array.isArray(input.changeTargetPathAliases) && _io2(input.changeTargetPathAliases)) && (null === input.startPreparation || undefined === input.startPreparation || "object" === typeof input.startPreparation && null !== input.startPreparation && _io3(input.startPreparation)) && (undefined === input.thresholdForAutoReject || "number" === typeof input.thresholdForAutoReject) && (null === input.dailySecurityScan || undefined === input.dailySecurityScan || "object" === typeof input.dailySecurityScan && null !== input.dailySecurityScan && _io4(input.dailySecurityScan)) && (undefined === input.claudeCodeOauthTokenListJsonPath || "string" === typeof input.claudeCodeOauthTokenListJsonPath) && (undefined === input.consoleDataOutputDir || "string" === typeof input.consoleDataOutputDir) && ("object" === typeof input.credentials && null !== input.credentials && _io5(input.credentials)); const _io1 = input => "string" === typeof input.repo && (Array.isArray(input.members) && input.members.every(elem => "string" === typeof elem)) && "string" === typeof input.spreadsheetUrl; const _io2 = input => Object.keys(input).every(key => {
|
|
96
97
|
const value = input[key];
|
|
97
98
|
if (undefined === value)
|
|
98
99
|
return true;
|
|
@@ -177,6 +178,10 @@ class HandleScheduledEventUseCaseHandler {
|
|
|
177
178
|
path: _path + ".claudeCodeOauthTokenListJsonPath",
|
|
178
179
|
expected: "(string | undefined)",
|
|
179
180
|
value: input.claudeCodeOauthTokenListJsonPath
|
|
181
|
+
}), undefined === input.consoleDataOutputDir || "string" === typeof input.consoleDataOutputDir || _report(_exceptionable, {
|
|
182
|
+
path: _path + ".consoleDataOutputDir",
|
|
183
|
+
expected: "(string | undefined)",
|
|
184
|
+
value: input.consoleDataOutputDir
|
|
180
185
|
}), ("object" === typeof input.credentials && null !== input.credentials || _report(_exceptionable, {
|
|
181
186
|
path: _path + ".credentials",
|
|
182
187
|
expected: "__type.o2",
|
|
@@ -522,6 +527,18 @@ class HandleScheduledEventUseCaseHandler {
|
|
|
522
527
|
preparationProcessCheckCommand: mergedInput.startPreparation?.preparationProcessCheckCommand ?? null,
|
|
523
528
|
localCommandRunner: nodeLocalCommandRunner,
|
|
524
529
|
});
|
|
530
|
+
try {
|
|
531
|
+
(0, consoleListsWriter_1.writeConsoleLists)({
|
|
532
|
+
consoleDataOutputDir: mergedInput.consoleDataOutputDir ?? null,
|
|
533
|
+
pjcode: input.projectName,
|
|
534
|
+
assigneeLogin: input.manager,
|
|
535
|
+
project: result.project,
|
|
536
|
+
issues: result.issues,
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
catch (error) {
|
|
540
|
+
console.error(`Failed to write console lists: ${error instanceof Error ? error.message : String(error)}`);
|
|
541
|
+
}
|
|
525
542
|
}
|
|
526
543
|
return result;
|
|
527
544
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HandleScheduledEventUseCaseHandler.js","sourceRoot":"","sources":["../../../../src/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAwB;AACxB,kDAA0B;AAC1B,4CAAoB;AACpB,+DAA2D;AAC3D,uEAAmE;AACnE,wDAG8B;AAC9B,kFAA+E;AAC/E,sFAAmF;AACnF,gGAA6F;AAC7F,0FAAuF;AACvF,wFAAqF;AACrF,sFAAmF;AACnF,wGAAqG;AACrG,8GAA2G;AAC3G,sGAAmG;AACnG,gGAA6F;AAC7F,kGAA+F;AAC/F,gIAA6H;AAC7H,oHAAiH;AACjH,wGAAqG;AAIrG,0FAAuF;AACvF,wGAAqG;AACrG,gIAA6H;AAC7H,wGAAqG;AACrG,kIAA+H;AAC/H,8GAA2G;AAC3G,0GAAuG;AACvG,wGAAqG;AACrG,0HAAuH;AACvH,8GAA2G;AAC3G,8FAA2F;AAC3F,sFAAmF;AACnF,wGAAqG;AACrG,oGAAiG;AACjG,sGAAmG;AACnG,gHAA6G;AAC7G,0HAAuH;AACvH,kGAA+F;AAC/F,8GAA2G;AAC3G,gGAA6F;AAC7F,0EAAuE;AACvE,4EAKiD;AAEjD,MAAa,kCAAkC;IAA/C;QACE,WAAM,GAAG,KAAK,EACZ,cAAsB,EACtB,QAAiB,EAMT,EAAE;YACV,MAAM,iBAAiB,GAAG,YAAE,CAAC,YAAY,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;YAClE,MAAM,KAAK,GAAY,cAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"HandleScheduledEventUseCaseHandler.js","sourceRoot":"","sources":["../../../../src/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAwB;AACxB,kDAA0B;AAC1B,4CAAoB;AACpB,+DAA2D;AAC3D,6DAAyD;AACzD,uEAAmE;AACnE,wDAG8B;AAC9B,kFAA+E;AAC/E,sFAAmF;AACnF,gGAA6F;AAC7F,0FAAuF;AACvF,wFAAqF;AACrF,sFAAmF;AACnF,wGAAqG;AACrG,8GAA2G;AAC3G,sGAAmG;AACnG,gGAA6F;AAC7F,kGAA+F;AAC/F,gIAA6H;AAC7H,oHAAiH;AACjH,wGAAqG;AAIrG,0FAAuF;AACvF,wGAAqG;AACrG,gIAA6H;AAC7H,wGAAqG;AACrG,kIAA+H;AAC/H,8GAA2G;AAC3G,0GAAuG;AACvG,wGAAqG;AACrG,0HAAuH;AACvH,8GAA2G;AAC3G,8FAA2F;AAC3F,sFAAmF;AACnF,wGAAqG;AACrG,oGAAiG;AACjG,sGAAmG;AACnG,gHAA6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MAAM;oBACrB,WAAW,EAAE;wBACX,0BAA0B,EAAE,mDAAkC;wBAC9D,iBAAiB,EAAE,wCAAuB;wBAC1C,uBAAuB,EAAE,+CAA8B;wBACvD,uBAAuB,EAAE,+CAA8B;qBACxD;oBACD,MAAM,EAAE;wBACN,2BAA2B,EACzB,WAAW,CAAC,gBAAgB,EAAE,2BAA2B,IAAI,IAAI;wBACnE,8BAA8B,EAC5B,WAAW,CAAC,gBAAgB,EAAE,8BAA8B,IAAI,EAAE;wBACpE,sBAAsB,EAAE,WAAW,CAAC,sBAAsB;wBAC1D,sBAAsB,EAAE,CAAC;qBAC1B;oBACD,8BAA8B,EAC5B,WAAW,CAAC,gBAAgB,EAAE,8BAA8B,IAAI,IAAI;oBACtE,kBAAkB,EAAE,sBAAsB;iBAC3C,CAAC,CAAC;gBAEH,IAAI,CAAC;oBACH,IAAA,sCAAiB,EAAC;wBAChB,oBAAoB,EAAE,WAAW,CAAC,oBAAoB,IAAI,IAAI;wBAC9D,MAAM,EAAE,KAAK,CAAC,WAAW;wBACzB,aAAa,EAAE,KAAK,CAAC,OAAO;wBAC5B,OAAO,EAAE,MAAM,CAAC,OAAO;wBACvB,MAAM,EAAE,MAAM,CAAC,MAAM;qBACtB,CAAC,CAAC;gBACL,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CACX,kCACE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,EAAE,CACH,CAAC;gBACJ,CAAC;YACH,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;IACJ,CAAC;CAAA;AA7UD,gFA6UC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.writeConsoleLists = exports.formatConsoleGeneratedAt = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const GenerateConsoleListsUseCase_1 = require("../../../domain/usecases/console/GenerateConsoleListsUseCase");
|
|
10
|
+
const CONSOLE_TAB_NAMES = [
|
|
11
|
+
'prs',
|
|
12
|
+
'triage',
|
|
13
|
+
'unread',
|
|
14
|
+
'failed-preparation',
|
|
15
|
+
];
|
|
16
|
+
const formatConsoleGeneratedAt = (date) => date.toISOString().replace(/\.\d{3}Z$/, 'Z');
|
|
17
|
+
exports.formatConsoleGeneratedAt = formatConsoleGeneratedAt;
|
|
18
|
+
const writeJsonAtomic = (filePath, data) => {
|
|
19
|
+
const dir = path_1.default.dirname(filePath);
|
|
20
|
+
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
21
|
+
const tmpPath = `${filePath}.tmp`;
|
|
22
|
+
fs_1.default.writeFileSync(tmpPath, JSON.stringify(data));
|
|
23
|
+
fs_1.default.renameSync(tmpPath, filePath);
|
|
24
|
+
};
|
|
25
|
+
const writeConsoleLists = (params) => {
|
|
26
|
+
const { consoleDataOutputDir, pjcode, assigneeLogin } = params;
|
|
27
|
+
if (!consoleDataOutputDir || !pjcode || !assigneeLogin) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const generatedAt = params.generatedAt ?? (0, exports.formatConsoleGeneratedAt)(new Date());
|
|
31
|
+
const lists = new GenerateConsoleListsUseCase_1.GenerateConsoleListsUseCase().run({
|
|
32
|
+
project: params.project,
|
|
33
|
+
issues: params.issues,
|
|
34
|
+
pjcode,
|
|
35
|
+
assigneeLogin,
|
|
36
|
+
generatedAt,
|
|
37
|
+
});
|
|
38
|
+
for (const tab of CONSOLE_TAB_NAMES) {
|
|
39
|
+
writeJsonAtomic(path_1.default.join(consoleDataOutputDir, pjcode, tab, 'list.json'), lists[tab]);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
exports.writeConsoleLists = writeConsoleLists;
|
|
43
|
+
//# sourceMappingURL=consoleListsWriter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consoleListsWriter.js","sourceRoot":"","sources":["../../../../src/adapter/entry-points/handlers/consoleListsWriter.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAGxB,8GAIsE;AAWtE,MAAM,iBAAiB,GAAqB;IAC1C,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,oBAAoB;CACrB,CAAC;AAEK,MAAM,wBAAwB,GAAG,CAAC,IAAU,EAAU,EAAE,CAC7D,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;AADlC,QAAA,wBAAwB,4BACU;AAE/C,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAE,IAAa,EAAQ,EAAE;IAChE,MAAM,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,YAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,GAAG,QAAQ,MAAM,CAAC;IAClC,YAAE,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAChD,YAAE,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACnC,CAAC,CAAC;AAEK,MAAM,iBAAiB,GAAG,CAAC,MAAgC,EAAQ,EAAE;IAC1E,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,CAAC;IAC/D,IAAI,CAAC,oBAAoB,IAAI,CAAC,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QACvD,OAAO;IACT,CAAC;IAED,MAAM,WAAW,GACf,MAAM,CAAC,WAAW,IAAI,IAAA,gCAAwB,EAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IAC7D,MAAM,KAAK,GAAiB,IAAI,yDAA2B,EAAE,CAAC,GAAG,CAAC;QAChE,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,MAAM;QACN,aAAa;QACb,WAAW;KACZ,CAAC,CAAC;IAEH,KAAK,MAAM,GAAG,IAAI,iBAAiB,EAAE,CAAC;QACpC,eAAe,CACb,cAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,CAAC,EACzD,KAAK,CAAC,GAAG,CAAC,CACX,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAtBW,QAAA,iBAAiB,qBAsB5B"}
|
|
@@ -28,6 +28,21 @@ class StartPreparationUseCase {
|
|
|
28
28
|
const general = usage.modelWeeklyLimits['seven_day'];
|
|
29
29
|
return general !== undefined && general.rejected;
|
|
30
30
|
};
|
|
31
|
+
this.selectModelForToken = (usage, defaultModelName, fallbackModelName) => {
|
|
32
|
+
const generalWeeklyLimit = usage.modelWeeklyLimits['seven_day'];
|
|
33
|
+
if (generalWeeklyLimit !== undefined && generalWeeklyLimit.rejected) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const candidateModelNames = [defaultModelName, fallbackModelName].filter((modelName) => modelName !== null && modelName !== '');
|
|
37
|
+
for (const candidateModelName of candidateModelNames) {
|
|
38
|
+
const weeklyLimitType = this.weeklyLimitTypeForModel(candidateModelName);
|
|
39
|
+
const specificWeeklyLimit = usage.modelWeeklyLimits[weeklyLimitType];
|
|
40
|
+
if (specificWeeklyLimit === undefined || !specificWeeklyLimit.rejected) {
|
|
41
|
+
return candidateModelName;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
};
|
|
31
46
|
this.secondsUntilSevenDayReset = (usage, weeklyLimitType, nowEpochSeconds) => {
|
|
32
47
|
const specific = usage.modelWeeklyLimits[weeklyLimitType];
|
|
33
48
|
if (specific !== undefined) {
|
|
@@ -39,9 +54,9 @@ class StartPreparationUseCase {
|
|
|
39
54
|
}
|
|
40
55
|
return Number.POSITIVE_INFINITY;
|
|
41
56
|
};
|
|
42
|
-
this.compareBySevenDayDeadlineThenUtilization = (a, b,
|
|
43
|
-
const aSecondsUntilReset = this.secondsUntilSevenDayReset(a,
|
|
44
|
-
const bSecondsUntilReset = this.secondsUntilSevenDayReset(b,
|
|
57
|
+
this.compareBySevenDayDeadlineThenUtilization = (a, aWeeklyLimitType, b, bWeeklyLimitType, nowEpochSeconds) => {
|
|
58
|
+
const aSecondsUntilReset = this.secondsUntilSevenDayReset(a, aWeeklyLimitType, nowEpochSeconds);
|
|
59
|
+
const bSecondsUntilReset = this.secondsUntilSevenDayReset(b, bWeeklyLimitType, nowEpochSeconds);
|
|
45
60
|
if (aSecondsUntilReset !== bSecondsUntilReset) {
|
|
46
61
|
return aSecondsUntilReset - bSecondsUntilReset;
|
|
47
62
|
}
|
|
@@ -59,23 +74,28 @@ class StartPreparationUseCase {
|
|
|
59
74
|
const fiveHourLimit = this.taperedConcurrentLimit(fiveHourUtilization, FIVE_HOUR_THROTTLE_START_THRESHOLD);
|
|
60
75
|
return Math.min(sevenDayLimit, fiveHourLimit);
|
|
61
76
|
};
|
|
62
|
-
this.selectRotationTokens = (tokenUsages, utilizationPercentageThreshold,
|
|
63
|
-
const weeklyLimitType = this.weeklyLimitTypeForModel(modelName);
|
|
77
|
+
this.selectRotationTokens = (tokenUsages, utilizationPercentageThreshold, defaultModelName, fallbackModelName, maxConcurrent) => {
|
|
64
78
|
const nowEpochSeconds = Date.now() / 1000;
|
|
65
79
|
const eligibleTokens = tokenUsages
|
|
66
80
|
.filter((usage) => !usage.blocked)
|
|
67
81
|
.filter((usage) => !usage.rejected)
|
|
68
82
|
.filter((usage) => !this.isWithinCooldown(usage, nowEpochSeconds))
|
|
69
|
-
.filter((usage) => !this.isModelWeeklyLimitRejected(usage, weeklyLimitType))
|
|
70
83
|
.filter((usage) => usage.fiveHourUtilization * 100 < utilizationPercentageThreshold)
|
|
71
|
-
.
|
|
84
|
+
.flatMap((usage) => {
|
|
85
|
+
const model = this.selectModelForToken(usage, defaultModelName, fallbackModelName);
|
|
86
|
+
if (model === null)
|
|
87
|
+
return [];
|
|
88
|
+
return [{ usage, model }];
|
|
89
|
+
})
|
|
90
|
+
.sort((a, b) => this.compareBySevenDayDeadlineThenUtilization(a.usage, this.weeklyLimitTypeForModel(a.model), b.usage, this.weeklyLimitTypeForModel(b.model), nowEpochSeconds));
|
|
72
91
|
if (eligibleTokens.length === 0) {
|
|
73
92
|
return { tokens: [], effectiveCap: 0, tokensWithLimits: [] };
|
|
74
93
|
}
|
|
75
|
-
const tokensWithLimits = eligibleTokens.map((usage) => ({
|
|
94
|
+
const tokensWithLimits = eligibleTokens.map(({ usage, model }) => ({
|
|
76
95
|
token: usage.token,
|
|
96
|
+
model,
|
|
77
97
|
limit: this.getTokenConcurrentLimit(usage.fiveHourUtilization, usage.sevenDayUtilization),
|
|
78
|
-
secondsUntilSevenDayReset: this.secondsUntilSevenDayReset(usage,
|
|
98
|
+
secondsUntilSevenDayReset: this.secondsUntilSevenDayReset(usage, this.weeklyLimitTypeForModel(model), nowEpochSeconds),
|
|
79
99
|
}));
|
|
80
100
|
const totalCapacity = tokensWithLimits.reduce((sum, t) => sum + t.limit, 0);
|
|
81
101
|
const effectiveCap = Math.min(maxConcurrent, totalCapacity);
|
|
@@ -99,7 +119,7 @@ class StartPreparationUseCase {
|
|
|
99
119
|
.filter((usage) => !this.isWithinCooldown(usage, nowEpochSeconds))
|
|
100
120
|
.filter((usage) => !this.isModelWeeklyLimitRejected(usage, weeklyLimitType))
|
|
101
121
|
.filter((usage) => usage.fiveHourUtilization * 100 < utilizationPercentageThreshold)
|
|
102
|
-
.sort((a, b) => this.compareBySevenDayDeadlineThenUtilization(a, b, weeklyLimitType, nowEpochSeconds));
|
|
122
|
+
.sort((a, b) => this.compareBySevenDayDeadlineThenUtilization(a, weeklyLimitType, b, weeklyLimitType, nowEpochSeconds));
|
|
103
123
|
const selectedTokenValues = new Set(selectedTokens.map((u) => u.token));
|
|
104
124
|
const excluded = tokenUsages
|
|
105
125
|
.filter((usage) => !selectedTokenValues.has(usage.token))
|
|
@@ -138,27 +158,11 @@ class StartPreparationUseCase {
|
|
|
138
158
|
: null;
|
|
139
159
|
const maximumPreparingIssuesCount = params.maximumPreparingIssuesCount ?? NORMAL_CONCURRENT_LIMIT;
|
|
140
160
|
let effectiveMaxPreparingIssuesCount = maximumPreparingIssuesCount;
|
|
141
|
-
|
|
161
|
+
const fallbackLlmModelName = params.fallbackLlmModelName ?? exports.DEFAULT_FALLBACK_LLM_MODEL_NAME;
|
|
142
162
|
if (tokenUsages.length > 0) {
|
|
143
|
-
const { tokens:
|
|
144
|
-
let selectedTokens = ranked;
|
|
145
|
-
let selectedCap = effectiveCap;
|
|
146
|
-
let selectedTokensWithLimitsLocal = rankedTokensWithLimits;
|
|
147
|
-
if (selectedTokens.length === 0 &&
|
|
148
|
-
this.weeklyLimitTypeForModel(params.defaultLlmModelName) ===
|
|
149
|
-
'seven_day_sonnet') {
|
|
150
|
-
const fallbackModelName = params.fallbackLlmModelName ?? exports.DEFAULT_FALLBACK_LLM_MODEL_NAME;
|
|
151
|
-
const { tokens: fallbackRanked, effectiveCap: fallbackCap, tokensWithLimits: fallbackTokensWithLimits, } = this.selectRotationTokens(tokenUsages, params.utilizationPercentageThreshold, fallbackModelName, maximumPreparingIssuesCount);
|
|
152
|
-
if (fallbackRanked.length > 0) {
|
|
153
|
-
console.warn(`Sonnet 7-day weekly limit (${this.weeklyLimitTypeForModel(params.defaultLlmModelName)}) is exhausted across all configured Claude OAuth token(s). Falling back to ${fallbackModelName}.`);
|
|
154
|
-
selectedTokens = fallbackRanked;
|
|
155
|
-
selectedCap = fallbackCap;
|
|
156
|
-
selectedTokensWithLimitsLocal = fallbackTokensWithLimits;
|
|
157
|
-
effectiveDefaultLlmModelName = fallbackModelName;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
163
|
+
const { tokens: selectedTokens, effectiveCap: selectedCap, tokensWithLimits: selectedTokensWithLimitsLocal, } = this.selectRotationTokens(tokenUsages, params.utilizationPercentageThreshold, params.defaultLlmModelName, fallbackLlmModelName, maximumPreparingIssuesCount);
|
|
160
164
|
if (selectedTokens.length === 0) {
|
|
161
|
-
console.warn(`All ${tokenUsages.length} configured Claude OAuth token(s) are unavailable (blocked, rejected, weekly
|
|
165
|
+
console.warn(`All ${tokenUsages.length} configured Claude OAuth token(s) are unavailable (blocked, rejected, weekly limits for the configured model(s) exhausted, or 5h utilization >= ${params.utilizationPercentageThreshold}%). Skipping starting preparation.`);
|
|
162
166
|
return { rotationOrder };
|
|
163
167
|
}
|
|
164
168
|
await this.claudeTokenUsageRepository.ensureObservable();
|
|
@@ -221,11 +225,13 @@ class StartPreparationUseCase {
|
|
|
221
225
|
.trim() ||
|
|
222
226
|
params.defaultLlmAgentName ||
|
|
223
227
|
params.defaultAgentName;
|
|
224
|
-
const
|
|
228
|
+
const labelModelName = issue.labels
|
|
225
229
|
.find((label) => label.startsWith('llm-model:'))
|
|
226
230
|
?.replace('llm-model:', '')
|
|
227
|
-
.trim()
|
|
228
|
-
if (!
|
|
231
|
+
.trim();
|
|
232
|
+
if (!labelModelName &&
|
|
233
|
+
!params.defaultLlmModelName &&
|
|
234
|
+
rotationTokens === null) {
|
|
229
235
|
console.error(`No LLM model configured for issue ${issue.url}. Provide --defaultLlmModelName or add an llm-model: label.`);
|
|
230
236
|
continue;
|
|
231
237
|
}
|
|
@@ -281,25 +287,13 @@ class StartPreparationUseCase {
|
|
|
281
287
|
}
|
|
282
288
|
await this.issueRepository.updateStatus(project, issue, preparationStatusOption.id);
|
|
283
289
|
issue.status = WorkflowStatus_1.PREPARATION_STATUS_NAME;
|
|
284
|
-
const awArgs = [
|
|
285
|
-
issue.url,
|
|
286
|
-
agent,
|
|
287
|
-
model,
|
|
288
|
-
'--configFilePath',
|
|
289
|
-
params.configFilePath,
|
|
290
|
-
'--branch',
|
|
291
|
-
branchName,
|
|
292
|
-
];
|
|
293
|
-
if (params.codexHomeCandidates !== null &&
|
|
294
|
-
params.codexHomeCandidates.length > 0) {
|
|
295
|
-
const codexHome = params.codexHomeCandidates[startedInThisRunCount % params.codexHomeCandidates.length];
|
|
296
|
-
awArgs.push('--codexHome', codexHome);
|
|
297
|
-
}
|
|
298
290
|
let spawnEnv;
|
|
291
|
+
let routedModelName = null;
|
|
299
292
|
if (rotationTokens !== null && proxyBaseUrl !== null) {
|
|
300
293
|
const tokenWithSoonestResetAmongAvailable = selectedTokensWithLimits
|
|
301
294
|
.map((t) => ({
|
|
302
295
|
token: t.token,
|
|
296
|
+
model: t.model,
|
|
303
297
|
remaining: t.limit -
|
|
304
298
|
(tokenInFlightCounts[t.token] ?? 0) -
|
|
305
299
|
(spawnedInThisRunByToken[t.token] ?? 0),
|
|
@@ -316,6 +310,7 @@ class StartPreparationUseCase {
|
|
|
316
310
|
break;
|
|
317
311
|
}
|
|
318
312
|
const selected = tokenWithSoonestResetAmongAvailable.token;
|
|
313
|
+
routedModelName = tokenWithSoonestResetAmongAvailable.model;
|
|
319
314
|
spawnedInThisRunByToken[selected] =
|
|
320
315
|
(spawnedInThisRunByToken[selected] ?? 0) + 1;
|
|
321
316
|
spawnEnv = {
|
|
@@ -323,6 +318,25 @@ class StartPreparationUseCase {
|
|
|
323
318
|
ANTHROPIC_BASE_URL: proxyBaseUrl,
|
|
324
319
|
};
|
|
325
320
|
}
|
|
321
|
+
const model = labelModelName || routedModelName || params.defaultLlmModelName;
|
|
322
|
+
if (!model) {
|
|
323
|
+
console.error(`No LLM model configured for issue ${issue.url}. Provide --defaultLlmModelName or add an llm-model: label.`);
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
const awArgs = [
|
|
327
|
+
issue.url,
|
|
328
|
+
agent,
|
|
329
|
+
model,
|
|
330
|
+
'--configFilePath',
|
|
331
|
+
params.configFilePath,
|
|
332
|
+
'--branch',
|
|
333
|
+
branchName,
|
|
334
|
+
];
|
|
335
|
+
if (params.codexHomeCandidates !== null &&
|
|
336
|
+
params.codexHomeCandidates.length > 0) {
|
|
337
|
+
const codexHome = params.codexHomeCandidates[startedInThisRunCount % params.codexHomeCandidates.length];
|
|
338
|
+
awArgs.push('--codexHome', codexHome);
|
|
339
|
+
}
|
|
326
340
|
await this.localCommandRunner.runCommand('aw', awArgs, spawnEnv ? { env: spawnEnv } : undefined);
|
|
327
341
|
startedInThisRunCount++;
|
|
328
342
|
updatedCurrentPreparationIssueCount++;
|