@blogic-cz/agent-tools 1.7.2 → 1.7.4
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/dist/az-tool/service.d.ts +1 -1
- package/dist/az-tool/service.d.ts.map +1 -1
- package/dist/azdo-tool/service.d.ts +1 -1
- package/dist/azdo-tool/service.d.ts.map +1 -1
- package/dist/credential-guard/index.d.ts.map +1 -1
- package/dist/db-tool/service.d.ts +1 -1
- package/dist/db-tool/service.d.ts.map +1 -1
- package/dist/gh-tool/api.d.ts.map +1 -1
- package/dist/gh-tool/branch.d.ts +1 -1
- package/dist/gh-tool/branch.d.ts.map +1 -1
- package/dist/gh-tool/config.d.ts +1 -0
- package/dist/gh-tool/config.d.ts.map +1 -1
- package/dist/gh-tool/errors.d.ts +2 -1
- package/dist/gh-tool/errors.d.ts.map +1 -1
- package/dist/gh-tool/gist.d.ts +1 -1
- package/dist/gh-tool/gist.d.ts.map +1 -1
- package/dist/gh-tool/issue/commands.d.ts +1 -1
- package/dist/gh-tool/issue/commands.d.ts.map +1 -1
- package/dist/gh-tool/issue/triage.d.ts +4 -4
- package/dist/gh-tool/issue/triage.d.ts.map +1 -1
- package/dist/gh-tool/pr/check-status-cache.d.ts +6 -0
- package/dist/gh-tool/pr/check-status-cache.d.ts.map +1 -0
- package/dist/gh-tool/pr/commands.d.ts +9 -8
- package/dist/gh-tool/pr/commands.d.ts.map +1 -1
- package/dist/gh-tool/pr/core.d.ts +11 -8
- package/dist/gh-tool/pr/core.d.ts.map +1 -1
- package/dist/gh-tool/pr/helpers.d.ts +1 -1
- package/dist/gh-tool/pr/helpers.d.ts.map +1 -1
- package/dist/gh-tool/release.d.ts +1 -1
- package/dist/gh-tool/release.d.ts.map +1 -1
- package/dist/gh-tool/repo.d.ts +1 -1
- package/dist/gh-tool/repo.d.ts.map +1 -1
- package/dist/gh-tool/service.d.ts +1 -1
- package/dist/gh-tool/service.d.ts.map +1 -1
- package/dist/gh-tool/types.d.ts +2 -0
- package/dist/gh-tool/types.d.ts.map +1 -1
- package/dist/gh-tool/workflow.d.ts +1 -1
- package/dist/gh-tool/workflow.d.ts.map +1 -1
- package/dist/k8s-tool/service.d.ts +1 -1
- package/dist/k8s-tool/service.d.ts.map +1 -1
- package/dist/logs-tool/main.d.ts +1 -1
- package/dist/logs-tool/main.d.ts.map +1 -1
- package/dist/logs-tool/service.d.ts +1 -1
- package/dist/logs-tool/service.d.ts.map +1 -1
- package/dist/observability-tool/logs.d.ts +1 -1
- package/dist/observability-tool/logs.d.ts.map +1 -1
- package/dist/observability-tool/metrics.d.ts +1 -1
- package/dist/observability-tool/metrics.d.ts.map +1 -1
- package/dist/observability-tool/shared.d.ts +1 -1
- package/dist/observability-tool/shared.d.ts.map +1 -1
- package/dist/observability-tool/trace.d.ts +1 -1
- package/dist/observability-tool/trace.d.ts.map +1 -1
- package/dist/session-tool/main.d.ts +1 -1
- package/dist/session-tool/main.d.ts.map +1 -1
- package/dist/shared/exec.d.ts +1 -1
- package/dist/shared/exec.d.ts.map +1 -1
- package/dist/shared/format.d.ts +1 -1
- package/dist/shared/format.d.ts.map +1 -1
- package/dist/shared/prerequisites/driver-commands.d.ts +1 -1
- package/dist/shared/prerequisites/driver-commands.d.ts.map +1 -1
- package/dist/shared/prerequisites/types.d.ts +1 -1
- package/dist/shared/prerequisites/types.d.ts.map +1 -1
- package/dist/shared/retry-transient.d.ts +1 -0
- package/dist/shared/retry-transient.d.ts.map +1 -1
- package/dist/shared/schema-dump.d.ts +1 -1
- package/dist/shared/schema-dump.d.ts.map +1 -1
- package/dist/shared/types.d.ts +1 -1
- package/dist/shared/types.d.ts.map +1 -1
- package/package.json +12 -14
- package/src/api-tool/main.ts +1 -1
- package/src/audit-tool/main.ts +1 -1
- package/src/az-tool/main.ts +1 -1
- package/src/az-tool/service.ts +1 -1
- package/src/azdo-tool/main.ts +1 -1
- package/src/azdo-tool/service.ts +1 -1
- package/src/credential-guard/index.ts +21 -1
- package/src/db-tool/main.ts +1 -1
- package/src/db-tool/service.ts +1 -1
- package/src/gh-tool/api.ts +40 -4
- package/src/gh-tool/branch.ts +1 -1
- package/src/gh-tool/config.ts +1 -0
- package/src/gh-tool/errors.ts +4 -2
- package/src/gh-tool/gist.ts +1 -1
- package/src/gh-tool/issue/commands.ts +1 -1
- package/src/gh-tool/issue/triage.ts +1 -1
- package/src/gh-tool/main.ts +1 -1
- package/src/gh-tool/pr/check-status-cache.ts +142 -0
- package/src/gh-tool/pr/commands.ts +16 -9
- package/src/gh-tool/pr/core.ts +166 -28
- package/src/gh-tool/pr/helpers.ts +1 -1
- package/src/gh-tool/release.ts +1 -1
- package/src/gh-tool/repo.ts +1 -1
- package/src/gh-tool/service.ts +30 -1
- package/src/gh-tool/types.ts +2 -0
- package/src/gh-tool/workflow.ts +10 -2
- package/src/k8s-tool/main.ts +1 -1
- package/src/k8s-tool/service.ts +1 -1
- package/src/logs-tool/main.ts +1 -1
- package/src/observability-tool/logs.ts +1 -1
- package/src/observability-tool/main.ts +1 -1
- package/src/observability-tool/metrics.ts +1 -1
- package/src/observability-tool/shared.ts +1 -1
- package/src/observability-tool/trace.ts +1 -1
- package/src/session-tool/main.ts +1 -1
- package/src/shared/exec.ts +1 -1
- package/src/shared/format.ts +1 -1
- package/src/shared/prerequisites/driver-commands.ts +1 -1
- package/src/shared/prerequisites/types.ts +1 -1
- package/src/shared/retry-transient.ts +7 -3
- package/src/shared/schema-dump.ts +4 -5
- package/src/shared/types.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../src/observability-tool/logs.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,OAAO,EAAQ,MAAM,
|
|
1
|
+
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../src/observability-tool/logs.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,OAAO,EAAQ,MAAM,YAAY,CAAC;AAarD,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,SAAS,CAAC;AA6C1D,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE;IAC/C,OAAO,EAAE;QACP,CAAC,EAAE;YACD,MAAM,CAAC,EAAE,KAAK,CAAC;gBACb,MAAM,EAAE;oBAAE,MAAM,EAAE,KAAK,CAAC;wBAAE,IAAI,EAAE,MAAM,CAAC;wBAAC,IAAI,CAAC,EAAE,MAAM,CAAC;wBAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;qBAAE,CAAC,CAAA;iBAAE,CAAC;gBAC5F,IAAI,EAAE;oBAAE,MAAM,EAAE,OAAO,EAAE,EAAE,CAAA;iBAAE,CAAC;aAC/B,CAAC,CAAC;SACJ,CAAC;KACH,CAAC;CACH,GAAG,OAAO,EAAE,CAiCZ;AA4ED,eAAO,MAAM,WAAW,gFAGvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/observability-tool/metrics.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,OAAO,EAAQ,MAAM,
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/observability-tool/metrics.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,OAAO,EAAQ,MAAM,YAAY,CAAC;AA4HrD,eAAO,MAAM,cAAc,mFAG1B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect, Option } from "effect";
|
|
2
|
-
import { Flag } from "effect/
|
|
2
|
+
import { Flag } from "effect/cli";
|
|
3
3
|
import { ConfigService } from "#config";
|
|
4
4
|
import { ObservabilityToolError } from "./errors";
|
|
5
5
|
import type { DsQueryOpts, DsQueryResponse, ObservabilityEnvConfig } from "./types";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/observability-tool/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/observability-tool/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,aAAa,EAAiB,MAAM,SAAS,CAAC;AAGvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAElD,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EAEf,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAOjB,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAe/D;AAED,eAAO,MAAM,SAAS,mBAGrB,CAAC;AAEF,eAAO,MAAM,aAAa,kCAMzB,CAAC;AAkCF;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,sBAAsB,GAC7B,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAU/C;AAyDD,eAAO,MAAM,aAAa,QAAS,MAAM,WAAW,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,iFA4BrE,CAAC;AAEL,wBAAgB,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAWpD;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,MAAM,EAAE,sBAAsB,EAC9B,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,WAAW,GACjB,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,sBAAsB,CAAC,CAgE1C;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,sBAAsB,EAC9B,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,YAAY,GAAG,MAAM,EACrC,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,WAAW,GACpB,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,sBAAsB,CAAC,CAkCxD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import { Command } from "effect/
|
|
2
|
+
import { Command } from "effect/cli";
|
|
3
3
|
import { ObservabilityToolError } from "./errors";
|
|
4
4
|
import type { ObservabilityEnvConfig, SearchWindow, TempoSearchResponse, TraceSearchHit } from "./types";
|
|
5
5
|
export declare function summarizeSearchHits(response: TempoSearchResponse): TraceSearchHit[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../src/observability-tool/trace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAe,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAY,OAAO,EAAQ,MAAM,
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../src/observability-tool/trace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAe,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAY,OAAO,EAAQ,MAAM,YAAY,CAAC;AAKrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAWlD,OAAO,KAAK,EAEV,sBAAsB,EAItB,YAAY,EAEZ,mBAAmB,EAEnB,cAAc,EAEf,MAAM,SAAS,CAAC;AAuVjB,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,mBAAmB,GAAG,cAAc,EAAE,CAsBnF;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,sBAAsB,EAC9B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,MAAM,GACZ,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,CA4C5D;AAoPD,eAAO,MAAM,YAAY,iFAGxB,CAAC"}
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
import { Effect } from "effect";
|
|
9
9
|
import { ResolvedPaths } from "./config";
|
|
10
10
|
import { SessionService } from "./service";
|
|
11
|
-
export declare const run: (args: ReadonlyArray<string>) => Effect.Effect<void, import("effect/
|
|
11
|
+
export declare const run: (args: ReadonlyArray<string>) => Effect.Effect<void, import("effect/cli/CliError").CliError, import("effect/process/ChildProcessSpawner").ChildProcessSpawner | import("effect/FileSystem").FileSystem | import("effect/Path").Path | ResolvedPaths | SessionService | import("effect/Stdio").Stdio | import("effect/Terminal").Terminal>;
|
|
12
12
|
//# sourceMappingURL=main.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/session-tool/main.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAIH,OAAO,EAAE,MAAM,EAAiB,MAAM,QAAQ,CAAC;AAgB/C,OAAO,EAAE,aAAa,EAAsB,MAAM,UAAU,CAAC;AAE7D,OAAO,EAAc,cAAc,EAAuB,MAAM,WAAW,CAAC;AAqT5E,eAAO,MAAM,GAAG,SAAU,aAAa,CAAC,MAAM,CAAC
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/session-tool/main.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAIH,OAAO,EAAE,MAAM,EAAiB,MAAM,QAAQ,CAAC;AAgB/C,OAAO,EAAE,aAAa,EAAsB,MAAM,UAAU,CAAC;AAE7D,OAAO,EAAc,cAAc,EAAuB,MAAM,WAAW,CAAC;AAqT5E,eAAO,MAAM,GAAG,SAAU,aAAa,CAAC,MAAM,CAAC,6SAC6C,CAAC"}
|
package/dist/shared/exec.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChildProcessSpawner } from "effect/
|
|
1
|
+
import { ChildProcessSpawner } from "effect/process";
|
|
2
2
|
import { Effect, Schema } from "effect";
|
|
3
3
|
declare const ExecError_base: Schema.Class<ExecError, Schema.TaggedStruct<"ExecError", {
|
|
4
4
|
readonly message: Schema.String;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/shared/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/shared/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;;;;;;;AAIhD,qBAAa,SAAU,SAAQ,cAK7B;CAAG;AAEL,eAAO,MAAM,oBAAoB,YAAa,mBAAmB,CAAC,kBAAkB;;;;uDAUhF,CAAC;AAEL,eAAO,MAAM,UAAU,eACT,MAAM,SACZ,SAAS,MAAM,EAAE,cACZ,MAAM,KAChB,MAAM,CAAC,MAAM,CACd;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,EACpD,SAAS,EACT,mBAAmB,CAAC,mBAAmB,CAyCxC,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,MAAM,WAA0C,CAAC;AAEtF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,gBAAiB,MAAM,KAAG,MAAM,EAwC/D,CAAC;AAEF,eAAO,MAAM,iBAAiB,SAAU,SAAS,MAAM,EAAE,KAAG,MACmC,CAAC"}
|
package/dist/shared/format.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/shared/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/shared/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAExD,eAAO,MAAM,YAAY,4BAGxB,CAAC;AAEF,wBAAgB,YAAY,CAAC,CAAC,SAAS,UAAU,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM,CAK1F;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM,CAKlE;AAiCD,eAAO,MAAM,OAAO,SAAU,MAAM,2CAShC,CAAC;AAEL,eAAO,MAAM,YAAY,GAAI,CAAC,QAAQ,CAAC,UAAU,YAAY,2CAAqC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChildProcess } from "effect/
|
|
1
|
+
import { ChildProcess } from "effect/process";
|
|
2
2
|
import type { ResolvedVpnDriver } from "#shared/prerequisites/types";
|
|
3
3
|
import type { SanitizedVpnDriver } from "#shared/prerequisites/store";
|
|
4
4
|
export type VpnDriverAction = "status" | "start" | "stop";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver-commands.d.ts","sourceRoot":"","sources":["../../../src/shared/prerequisites/driver-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"driver-commands.d.ts","sourceRoot":"","sources":["../../../src/shared/prerequisites/driver-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAC1D,MAAM,MAAM,cAAc,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAE/F,eAAO,MAAM,iBAAiB,WAAY,iBAAiB,KAAG,kBAQ7D,CAAC;AAEF,eAAO,MAAM,cAAc,WACjB,kBAAkB,UAClB,eAAe,KACtB,cA4BF,CAAC;AAEF,eAAO,MAAM,oBAAoB,WACvB,iBAAiB,UACjB,eAAe,WACd,MAAM;IAOb,OAAO;IACP,KAAK;CAER,CAAC;AAEF,eAAO,MAAM,cAAc,WACjB,kBAAkB,UAClB;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,KAC7D,OAAO,GAAG,SAkBZ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema, type Effect } from "effect";
|
|
2
|
-
import type { ChildProcess } from "effect/
|
|
2
|
+
import type { ChildProcess } from "effect/process";
|
|
3
3
|
import type { LinuxNmcliVpnDriverConfig, MacosScutilVpnDriverConfig, VpnPrerequisite, WindowsRasdialVpnDriverConfig } from "#config/types";
|
|
4
4
|
export type PrerequisiteResolution = {
|
|
5
5
|
success: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shared/prerequisites/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shared/prerequisites/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,eAAe,EACf,6BAA6B,EAC9B,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,sBAAsB,GAC9B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,aAAa,EAAE,SAAS,eAAe,EAAE,CAAA;CAAE,GAC5D;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpD,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;AAE7D,MAAM,MAAM,iBAAiB,GACzB,CAAC,0BAA0B,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,GAC1E,CAAC,yBAAyB,GAAG;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,CAAC,GAC3E,CAAC,6BAA6B,GAAG;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE/E,MAAM,MAAM,mBAAmB,GAC3B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,iBAAiB,CAAA;CAAE,GAC5C;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpD,eAAO,MAAM,gBAAgB,gEAAwD,CAAC;AACtF,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE3E,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,yBAAyB,CAAC,CAAC,IAAI,CACzC,OAAO,EAAE,YAAY,CAAC,OAAO,EAC7B,KAAK,EAAE,MAAM,KACV,MAAM,CAAC,MAAM,CAAC,yBAAyB,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC"}
|
|
@@ -3,5 +3,6 @@ export declare const retryTransient: <A, E, R>(opts: {
|
|
|
3
3
|
attempt: () => Effect.Effect<A, E, R>;
|
|
4
4
|
isTransient: (error: E) => boolean;
|
|
5
5
|
maxRetries: number;
|
|
6
|
+
retryDelayMs?: (error: E, attempt: number, fallbackMs: number) => number;
|
|
6
7
|
}) => Effect.Effect<A, E, R>;
|
|
7
8
|
//# sourceMappingURL=retry-transient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry-transient.d.ts","sourceRoot":"","sources":["../../src/shared/retry-transient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAE,MAAM,QAAQ,CAAC;AAI1C,eAAO,MAAM,cAAc,GAAI,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ;IAC5C,OAAO,EAAE,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACtC,WAAW,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"retry-transient.d.ts","sourceRoot":"","sources":["../../src/shared/retry-transient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAE,MAAM,QAAQ,CAAC;AAI1C,eAAO,MAAM,cAAc,GAAI,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ;IAC5C,OAAO,EAAE,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACtC,WAAW,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;CAC1E,KAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAkBxB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Command } from "effect/
|
|
1
|
+
import { Command } from "effect/cli";
|
|
2
2
|
/**
|
|
3
3
|
* Machine-readable command-tree dump so an agent can discover the whole CLI surface in ONE call
|
|
4
4
|
* instead of repeated `--help` round-trips (the top remaining discovery friction in the usage audit).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-dump.d.ts","sourceRoot":"","sources":["../../src/shared/schema-dump.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"schema-dump.d.ts","sourceRoot":"","sources":["../../src/shared/schema-dump.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAKrC;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,SAAS,aAAa,EAAE,CAAC;CAChD,CAAC;AAgDF,eAAO,MAAM,iBAAiB,YAAa,OAAO,KAAG,aASpD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,YAAa,MAAM,OAAO;;oBAOrD,CAAC"}
|
package/dist/shared/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,CAAC;AAC3C,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpD,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAGF,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,CAAC;AAC3C,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpD,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAGF,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC,OAAO,GAAG,MAAM,GAAG,IAAI,CAAC;IAC3C,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blogic-cz/agent-tools",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.4",
|
|
4
4
|
"description": "CLI tools for AI coding agent workflows — GitHub, database, Kubernetes, Azure platform, Azure DevOps, logs, sessions, and audit",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -162,24 +162,22 @@
|
|
|
162
162
|
"api-proxy": "bun src/api-tool/proxy-entry.ts"
|
|
163
163
|
},
|
|
164
164
|
"dependencies": {
|
|
165
|
-
"@effect/platform-bun": "4.0.
|
|
166
|
-
"@
|
|
165
|
+
"@effect/platform-bun": "4.0.4",
|
|
166
|
+
"@effect/platform-node-shared": "4.0.4",
|
|
167
|
+
"@toon-format/toon": "4.4.0"
|
|
167
168
|
},
|
|
168
169
|
"devDependencies": {
|
|
169
|
-
"@effect/tsgo": "0.
|
|
170
|
-
"@effect/vitest": "4.0.
|
|
171
|
-
"@types/bun": "1.4.
|
|
172
|
-
"effect": "4.0.
|
|
173
|
-
"oxfmt": "0.
|
|
174
|
-
"oxlint": "1.
|
|
170
|
+
"@effect/tsgo": "0.51.1",
|
|
171
|
+
"@effect/vitest": "4.0.4",
|
|
172
|
+
"@types/bun": "1.4.3",
|
|
173
|
+
"effect": "4.0.4",
|
|
174
|
+
"oxfmt": "0.72.0",
|
|
175
|
+
"oxlint": "1.87.0",
|
|
175
176
|
"typescript": "7.0.2",
|
|
176
|
-
"vitest": "5.0.
|
|
177
|
+
"vitest": "5.0.4"
|
|
177
178
|
},
|
|
178
179
|
"peerDependencies": {
|
|
179
|
-
"effect": "^4.0.
|
|
180
|
-
},
|
|
181
|
-
"overrides": {
|
|
182
|
-
"@effect/platform-node-shared": "4.0.0-rc.117"
|
|
180
|
+
"effect": "^4.0.4"
|
|
183
181
|
},
|
|
184
182
|
"engines": {
|
|
185
183
|
"bun": ">=1.3.0"
|
package/src/api-tool/main.ts
CHANGED
package/src/audit-tool/main.ts
CHANGED
package/src/az-tool/main.ts
CHANGED
package/src/az-tool/service.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChildProcess, ChildProcessSpawner } from "effect/
|
|
1
|
+
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
2
2
|
import { Context, Effect, Layer, Option, Stream } from "effect";
|
|
3
3
|
|
|
4
4
|
import type { AzurePlatformConfig } from "#config/types";
|
package/src/azdo-tool/main.ts
CHANGED
package/src/azdo-tool/service.ts
CHANGED
|
@@ -1174,6 +1174,24 @@ function hasProvedPythonCompileInvocation(command: string): boolean {
|
|
|
1174
1174
|
);
|
|
1175
1175
|
}
|
|
1176
1176
|
|
|
1177
|
+
/** Only literal navigation may precede an unqualified writer; shell state can change what runs. */
|
|
1178
|
+
function isLiteralWriterHeader(command: string, pipelines: string[][][]): boolean {
|
|
1179
|
+
const commands = pipelines.flat();
|
|
1180
|
+
const writer = commands.at(-1);
|
|
1181
|
+
return (
|
|
1182
|
+
!command.includes("\r") &&
|
|
1183
|
+
pipelines.at(-1)?.length === 1 &&
|
|
1184
|
+
(writer?.[0] === "cat" || writer?.[0] === "tee") &&
|
|
1185
|
+
commands
|
|
1186
|
+
.slice(0, -1)
|
|
1187
|
+
.every(
|
|
1188
|
+
(words) =>
|
|
1189
|
+
(words[0] === "cd" && isStaticNavigationCommand(words)) ||
|
|
1190
|
+
(words.length === 1 && words[0] === "pwd"),
|
|
1191
|
+
)
|
|
1192
|
+
);
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1177
1195
|
/** Move a complete, literal Python stdin program into the existing inline argv boundary. */
|
|
1178
1196
|
function normalizeProgramHeredocs(command: string, depth = 0): string {
|
|
1179
1197
|
if (depth >= 32 || new TextEncoder().encode(command).byteLength > 65_536) return command;
|
|
@@ -1185,8 +1203,9 @@ function normalizeProgramHeredocs(command: string, depth = 0): string {
|
|
|
1185
1203
|
const last = parsed.pipelines.at(-1)?.at(-1);
|
|
1186
1204
|
const argv = last ? unwrapStaticCommand(last) : [];
|
|
1187
1205
|
const name = argv[0]?.split("/").at(-1);
|
|
1206
|
+
// A quoted delimiter disables expansion, so a first cat/tee body is data too.
|
|
1188
1207
|
if (
|
|
1189
|
-
depth > 0 &&
|
|
1208
|
+
(depth > 0 || (heredoc.quoted && isLiteralWriterHeader(command, parsed.pipelines))) &&
|
|
1190
1209
|
((name === "cat" && argv.slice(1).every((arg) => arg === "--" || !arg.startsWith("-"))) ||
|
|
1191
1210
|
(name === "tee" &&
|
|
1192
1211
|
argv
|
|
@@ -3896,6 +3915,7 @@ export function createCredentialGuard(config?: CredentialGuardConfig): Credentia
|
|
|
3896
3915
|
}
|
|
3897
3916
|
|
|
3898
3917
|
function detectSleepPolling(command: string): string | null {
|
|
3918
|
+
command = normalizeProgramHeredocs(command);
|
|
3899
3919
|
if (!/\bsleep\s+\d+/.test(command)) return null;
|
|
3900
3920
|
|
|
3901
3921
|
for (const { pattern, suggestion } of DEFAULT_POLLING_DETECTION_RULES) {
|
package/src/db-tool/main.ts
CHANGED
package/src/db-tool/service.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChildProcess, ChildProcessSpawner } from "effect/
|
|
1
|
+
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
2
2
|
import { Clock, Context, Duration, Effect, Layer, Ref, Result, Stream } from "effect";
|
|
3
3
|
|
|
4
4
|
import type { DbConfig, DbMutationOperation, QueryResult, SchemaMode } from "./types";
|
package/src/gh-tool/api.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Effect } from "effect";
|
|
1
|
+
import { Clock, Effect } from "effect";
|
|
2
2
|
|
|
3
3
|
import { retryTransient } from "#shared/retry-transient";
|
|
4
4
|
|
|
@@ -68,6 +68,8 @@ export type GitHubApiRequest = {
|
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
const MAX_API_RETRIES = 2;
|
|
71
|
+
const MAX_RATE_LIMIT_WAIT_MS = 60_000;
|
|
72
|
+
const rateLimitRetryDelays = new WeakMap<GitHubCommandError, number>();
|
|
71
73
|
|
|
72
74
|
// Traverse only parsed JSON, never the caller's getters or toJSON hooks.
|
|
73
75
|
const decodedBodyText = (value: unknown): string => {
|
|
@@ -142,13 +144,43 @@ const githubApiAttempt = Effect.fn("gh.githubApiAttempt")(function* <T>(
|
|
|
142
144
|
});
|
|
143
145
|
}
|
|
144
146
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
+
const now = yield* Clock.currentTimeMillis;
|
|
148
|
+
const resetSeconds = Number(response.headers.get("x-ratelimit-reset"));
|
|
149
|
+
const resetDelay =
|
|
150
|
+
Number.isFinite(resetSeconds) && resetSeconds > 0
|
|
151
|
+
? Math.max(0, resetSeconds * 1000 - now + 1000)
|
|
152
|
+
: undefined;
|
|
153
|
+
const retryAfter = response.headers.get("retry-after");
|
|
154
|
+
const retryAfterMs =
|
|
155
|
+
retryAfter === null
|
|
156
|
+
? undefined
|
|
157
|
+
: /^\d+(?:\.\d+)?$/.test(retryAfter)
|
|
158
|
+
? Number(retryAfter) * 1000
|
|
159
|
+
: Date.parse(retryAfter) - now;
|
|
160
|
+
const waitMs =
|
|
161
|
+
retryAfterMs !== undefined && Number.isFinite(retryAfterMs) && retryAfterMs >= 0
|
|
162
|
+
? retryAfterMs
|
|
163
|
+
: resetDelay;
|
|
164
|
+
const canWait = waitMs !== undefined && waitMs <= MAX_RATE_LIMIT_WAIT_MS;
|
|
165
|
+
const rateLimit =
|
|
166
|
+
response.status === 429 ||
|
|
167
|
+
(response.status === 403 &&
|
|
168
|
+
(response.headers.get("x-ratelimit-remaining") === "0" ||
|
|
169
|
+
/rate limit|secondary rate limit|abuse detection/i.test(
|
|
170
|
+
apiErrorMessage(parsed, response.status),
|
|
171
|
+
)));
|
|
172
|
+
|
|
173
|
+
const error = new GitHubCommandError({
|
|
174
|
+
message: rateLimit
|
|
175
|
+
? `${apiErrorMessage(parsed, response.status)}; reset time: ${resetDelay === undefined ? "unavailable" : new Date(resetSeconds * 1000).toISOString()}; remaining quota: ${response.headers.get("x-ratelimit-remaining") ?? "unavailable"}`
|
|
176
|
+
: apiErrorMessage(parsed, response.status),
|
|
147
177
|
command: `${method} ${opts.path}`,
|
|
148
178
|
exitCode: response.status,
|
|
149
179
|
stderr: text,
|
|
150
|
-
...(response.status >= 500 ? { retryable: true } : {}),
|
|
180
|
+
...(response.status >= 500 || (rateLimit && canWait) ? { retryable: true } : {}),
|
|
151
181
|
});
|
|
182
|
+
if (rateLimit && canWait && waitMs !== undefined) rateLimitRetryDelays.set(error, waitMs);
|
|
183
|
+
return yield* error;
|
|
152
184
|
});
|
|
153
185
|
|
|
154
186
|
// Mirrors GitHubService.runGh: replay a transient failure, and only for an idempotent read.
|
|
@@ -190,6 +222,10 @@ export const githubApi = <T>(
|
|
|
190
222
|
isTransient: (error) =>
|
|
191
223
|
error._tag === "GitHubCommandError" && error.retryable === true && request.method === "GET",
|
|
192
224
|
maxRetries: MAX_API_RETRIES,
|
|
225
|
+
retryDelayMs: (error, _attempt, fallbackMs) =>
|
|
226
|
+
error instanceof GitHubCommandError
|
|
227
|
+
? Math.max(fallbackMs, rateLimitRetryDelays.get(error) ?? 0)
|
|
228
|
+
: fallbackMs,
|
|
193
229
|
});
|
|
194
230
|
});
|
|
195
231
|
|
package/src/gh-tool/branch.ts
CHANGED
package/src/gh-tool/config.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export const DEFAULT_MERGE_STRATEGY = "squash" as const;
|
|
2
2
|
export const DEFAULT_DELETE_BRANCH = true as const;
|
|
3
3
|
export const CI_CHECK_WATCH_TIMEOUT_MS = 600_000 as const; // 10 minutes
|
|
4
|
+
export const PR_WATCH_TIMEOUT_SECONDS = 1_800 as const;
|
|
4
5
|
export const GRAPHQL_PAGE_SIZE = 100 as const;
|
|
5
6
|
export const GH_BINARY = "gh" as const;
|
|
6
7
|
|
package/src/gh-tool/errors.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
1
|
+
import { Runtime, Schema } from "effect";
|
|
2
2
|
|
|
3
3
|
export class GitHubCommandError extends Schema.TaggedError<GitHubCommandError>()(
|
|
4
4
|
"GitHubCommandError",
|
|
@@ -55,7 +55,9 @@ export class GitHubTimeoutError extends Schema.TaggedError<GitHubTimeoutError>()
|
|
|
55
55
|
nextCommand: Schema.optionalKey(Schema.String),
|
|
56
56
|
retryable: Schema.optionalKey(Schema.Boolean),
|
|
57
57
|
},
|
|
58
|
-
) {
|
|
58
|
+
) {
|
|
59
|
+
readonly [Runtime.errorExitCode] = 124;
|
|
60
|
+
}
|
|
59
61
|
|
|
60
62
|
export type GitHubServiceError =
|
|
61
63
|
| GitHubCommandError
|
package/src/gh-tool/gist.ts
CHANGED
package/src/gh-tool/main.ts
CHANGED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Context } from "effect";
|
|
2
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
3
|
+
import { chmod, mkdir, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
|
|
7
|
+
import type { CheckResult } from "#gh/types";
|
|
8
|
+
|
|
9
|
+
const CACHE_TTL_MS = 30_000;
|
|
10
|
+
const WATCH_PENDING_TTL_MS = 5_000;
|
|
11
|
+
const CACHE_DIR = join(homedir(), ".cache", "agent-tools", "gh-check-status-v1");
|
|
12
|
+
|
|
13
|
+
export const CheckStatusCacheDirectory = Context.Reference<string | undefined>(
|
|
14
|
+
"@agent-tools/CheckStatusCacheDirectory",
|
|
15
|
+
{ defaultValue: () => CACHE_DIR },
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
type CacheEntry = { fetchedAt: number; checks: CheckResult[] };
|
|
19
|
+
|
|
20
|
+
const keyFor = (identity: string, repo: string, pr: number, headSha: string) =>
|
|
21
|
+
createHash("sha256")
|
|
22
|
+
.update(`${identity}\n${repo.toLowerCase()}\n${pr}\n${headSha}`)
|
|
23
|
+
.digest("hex");
|
|
24
|
+
|
|
25
|
+
const validChecks = (value: unknown): value is CheckResult[] =>
|
|
26
|
+
Array.isArray(value) &&
|
|
27
|
+
value.every(
|
|
28
|
+
(item) =>
|
|
29
|
+
item !== null &&
|
|
30
|
+
typeof item === "object" &&
|
|
31
|
+
typeof item.name === "string" &&
|
|
32
|
+
typeof item.state === "string" &&
|
|
33
|
+
typeof item.bucket === "string" &&
|
|
34
|
+
typeof item.link === "string",
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export const readCheckStatusCache = async (
|
|
38
|
+
identity: string,
|
|
39
|
+
repo: string,
|
|
40
|
+
pr: number,
|
|
41
|
+
headSha: string,
|
|
42
|
+
now: number,
|
|
43
|
+
watchPending = false,
|
|
44
|
+
directory = CACHE_DIR,
|
|
45
|
+
): Promise<CheckResult[] | null> => {
|
|
46
|
+
try {
|
|
47
|
+
const prefix = keyFor(identity, repo, pr, headSha);
|
|
48
|
+
const files = (await readdir(directory)).filter((name) => name.startsWith(`${prefix}.`));
|
|
49
|
+
let latest: CacheEntry | null = null;
|
|
50
|
+
const entries = await Promise.all(
|
|
51
|
+
files.map(async (name) => {
|
|
52
|
+
try {
|
|
53
|
+
return {
|
|
54
|
+
name,
|
|
55
|
+
value: JSON.parse(await readFile(join(directory, name), "utf8")) as unknown,
|
|
56
|
+
};
|
|
57
|
+
} catch {
|
|
58
|
+
return { name, value: null };
|
|
59
|
+
}
|
|
60
|
+
}),
|
|
61
|
+
);
|
|
62
|
+
const staleFiles: string[] = [];
|
|
63
|
+
for (const { name, value: entry } of entries) {
|
|
64
|
+
if (!name.endsWith(".json")) continue;
|
|
65
|
+
if (entry === null || typeof entry !== "object") continue;
|
|
66
|
+
const candidate = entry as Partial<CacheEntry>;
|
|
67
|
+
const fetchedAt = candidate.fetchedAt;
|
|
68
|
+
if (
|
|
69
|
+
typeof fetchedAt !== "number" ||
|
|
70
|
+
!Number.isFinite(fetchedAt) ||
|
|
71
|
+
!validChecks(candidate.checks) ||
|
|
72
|
+
candidate.checks.length === 0
|
|
73
|
+
) {
|
|
74
|
+
staleFiles.push(join(directory, name));
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (fetchedAt > now || now - fetchedAt > CACHE_TTL_MS) {
|
|
78
|
+
staleFiles.push(join(directory, name));
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (watchPending && !candidate.checks.some((check) => check.bucket === "pending")) continue;
|
|
82
|
+
if (latest === null || fetchedAt > latest.fetchedAt)
|
|
83
|
+
latest = { fetchedAt, checks: candidate.checks };
|
|
84
|
+
}
|
|
85
|
+
await Promise.all(staleFiles.map((path) => rm(path, { force: true }).catch(() => undefined)));
|
|
86
|
+
if (latest === null || (watchPending && now - latest.fetchedAt > WATCH_PENDING_TTL_MS))
|
|
87
|
+
return null;
|
|
88
|
+
return latest.checks;
|
|
89
|
+
} catch {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const writeCheckStatusCache = async (
|
|
95
|
+
identity: string,
|
|
96
|
+
repo: string,
|
|
97
|
+
pr: number,
|
|
98
|
+
headSha: string,
|
|
99
|
+
checks: CheckResult[],
|
|
100
|
+
fetchedAt: number,
|
|
101
|
+
directory = CACHE_DIR,
|
|
102
|
+
): Promise<void> => {
|
|
103
|
+
if (checks.length === 0) return;
|
|
104
|
+
try {
|
|
105
|
+
await mkdir(directory, { recursive: true, mode: 0o700 });
|
|
106
|
+
await chmod(directory, 0o700);
|
|
107
|
+
await Promise.all(
|
|
108
|
+
(await readdir(directory))
|
|
109
|
+
.filter((name) => name.endsWith(".json"))
|
|
110
|
+
.map(async (name) => {
|
|
111
|
+
const path = join(directory, name);
|
|
112
|
+
try {
|
|
113
|
+
const entry: unknown = JSON.parse(await readFile(path, "utf8"));
|
|
114
|
+
if (
|
|
115
|
+
entry !== null &&
|
|
116
|
+
typeof entry === "object" &&
|
|
117
|
+
"fetchedAt" in entry &&
|
|
118
|
+
typeof entry.fetchedAt === "number" &&
|
|
119
|
+
Number.isFinite(entry.fetchedAt) &&
|
|
120
|
+
fetchedAt - entry.fetchedAt <= CACHE_TTL_MS
|
|
121
|
+
)
|
|
122
|
+
return;
|
|
123
|
+
await rm(path, { force: true });
|
|
124
|
+
} catch {
|
|
125
|
+
/* Another writer can remove a stale snapshot first. */
|
|
126
|
+
}
|
|
127
|
+
}),
|
|
128
|
+
);
|
|
129
|
+
const prefix = keyFor(identity, repo, pr, headSha);
|
|
130
|
+
const temporary = join(directory, `${prefix}.${process.pid}.${randomUUID()}.tmp`);
|
|
131
|
+
const destination = join(
|
|
132
|
+
directory,
|
|
133
|
+
`${prefix}.${fetchedAt}.${process.pid}.${randomUUID()}.json`,
|
|
134
|
+
);
|
|
135
|
+
await writeFile(temporary, JSON.stringify({ fetchedAt, checks } satisfies CacheEntry), {
|
|
136
|
+
mode: 0o600,
|
|
137
|
+
});
|
|
138
|
+
await rename(temporary, destination);
|
|
139
|
+
} catch {
|
|
140
|
+
// A cache write must never replace a successful GitHub response with an error.
|
|
141
|
+
}
|
|
142
|
+
};
|