github-router 0.3.355 → 0.3.357
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/ado-tools-DqLJ-u19.js +1 -0
- package/dist/{aic-ledger-BdvCgRmx.js → aic-ledger-BuFrsGur.js} +3 -3
- package/dist/{aic-ledger-BdvCgRmx.js.map → aic-ledger-BuFrsGur.js.map} +1 -1
- package/dist/{aic-statusline-settings-EdsV1gzY.js → aic-statusline-settings-DBS9sEGC.js} +2 -2
- package/dist/{aic-statusline-settings-EdsV1gzY.js.map → aic-statusline-settings-DBS9sEGC.js.map} +1 -1
- package/dist/{attribution-settings-N48QlHu2.js → attribution-settings-D9PxJxkL.js} +11 -11
- package/dist/{attribution-settings-N48QlHu2.js.map → attribution-settings-D9PxJxkL.js.map} +1 -1
- package/dist/{auth-a_1lXYZ1.js → auth-DFawaLJU.js} +4 -4
- package/dist/{auth-a_1lXYZ1.js.map → auth-DFawaLJU.js.map} +1 -1
- package/dist/{bluebird-client-ltPIiyJU.js → bluebird-client-C29-JOkG.js} +92 -4
- package/dist/bluebird-client-C29-JOkG.js.map +1 -0
- package/dist/bluebird-client-DGE3WZqh.js +1 -0
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/{check-usage-Bsbc-Sn6.js → check-usage-BkVEl-Su.js} +4 -4
- package/dist/{check-usage-Bsbc-Sn6.js.map → check-usage-BkVEl-Su.js.map} +1 -1
- package/dist/{claude-BAKFTVqA.js → claude-BTYQjK-K.js} +28 -27
- package/dist/claude-BTYQjK-K.js.map +1 -0
- package/dist/{claude-md-injection-CDOoGNEJ.js → claude-md-injection-Cpzolxin.js} +4 -4
- package/dist/{claude-md-injection-CDOoGNEJ.js.map → claude-md-injection-Cpzolxin.js.map} +1 -1
- package/dist/{codex-CspHNGZA.js → codex-TdsG6C9K.js} +9 -9
- package/dist/{codex-CspHNGZA.js.map → codex-TdsG6C9K.js.map} +1 -1
- package/dist/{copilot-discount-kpOLluHm.js → copilot-discount-Bsmv_3OX.js} +2 -2
- package/dist/{copilot-discount-kpOLluHm.js.map → copilot-discount-Bsmv_3OX.js.map} +1 -1
- package/dist/{debug-BtqbflcL.js → debug-DkNTuErv.js} +2 -2
- package/dist/{debug-BtqbflcL.js.map → debug-DkNTuErv.js.map} +1 -1
- package/dist/engine-CmhUwYI5.js +1 -0
- package/dist/{gate-discovery-JeKibE14.js → gate-discovery-NNQg0t0H.js} +5 -5
- package/dist/{gate-discovery-JeKibE14.js.map → gate-discovery-NNQg0t0H.js.map} +1 -1
- package/dist/{get-copilot-usage-0_S8pRWJ.js → get-copilot-usage-P9chc-X2.js} +3 -3
- package/dist/{get-copilot-usage-0_S8pRWJ.js.map → get-copilot-usage-P9chc-X2.js.map} +1 -1
- package/dist/hooks.mjs +2 -0
- package/dist/hooks.sha256 +1 -1
- package/dist/{index-cmd-CJXUOH4q.js → index-cmd-BkfYr9FH.js} +4 -4
- package/dist/{index-cmd-CJXUOH4q.js.map → index-cmd-BkfYr9FH.js.map} +1 -1
- package/dist/{internal-aic-status-wYPsCG4r.js → internal-aic-status-C6L4-ncP.js} +3 -3
- package/dist/{internal-aic-status-wYPsCG4r.js.map → internal-aic-status-C6L4-ncP.js.map} +1 -1
- package/dist/{internal-artifact-open-C67gDjKo.js → internal-artifact-open-DgJ3PCtt.js} +2 -2
- package/dist/{internal-artifact-open-C67gDjKo.js.map → internal-artifact-open-DgJ3PCtt.js.map} +1 -1
- package/dist/{internal-fast-dispatch-guard-D_TCtJhQ.js → internal-fast-dispatch-guard-CgBtUsQI.js} +2 -2
- package/dist/{internal-fast-dispatch-guard-D_TCtJhQ.js.map → internal-fast-dispatch-guard-CgBtUsQI.js.map} +1 -1
- package/dist/{internal-fast-dispatch-guard-A8teEib4.js → internal-fast-dispatch-guard-CicGz6oM.js} +1 -1
- package/dist/{internal-first-mate-guard-BJvCsVlU.js → internal-first-mate-guard-BfWYN6Jb.js} +3 -3
- package/dist/{internal-first-mate-guard-BJvCsVlU.js.map → internal-first-mate-guard-BfWYN6Jb.js.map} +1 -1
- package/dist/{internal-first-mate-guard-D-IQGiTs.js → internal-first-mate-guard-DTXPT7JW.js} +1 -1
- package/dist/{internal-max-dispatch-guard-D7ByWH4v.js → internal-max-dispatch-guard-CY8l9SDw.js} +3 -3
- package/dist/{internal-max-dispatch-guard-D7ByWH4v.js.map → internal-max-dispatch-guard-CY8l9SDw.js.map} +1 -1
- package/dist/{internal-max-dispatch-guard-BM_B15EH.js → internal-max-dispatch-guard-mNl9CCir.js} +1 -1
- package/dist/{internal-plan-review-DIvaBBUd.js → internal-plan-review-2OHTs8Nk.js} +3 -3
- package/dist/{internal-plan-review-DIvaBBUd.js.map → internal-plan-review-2OHTs8Nk.js.map} +1 -1
- package/dist/{internal-prompt-submit-C77GnEaW.js → internal-prompt-submit-CkfUcu34.js} +4 -4
- package/dist/{internal-prompt-submit-C77GnEaW.js.map → internal-prompt-submit-CkfUcu34.js.map} +1 -1
- package/dist/{internal-prompt-submit-CDTwamkW.js → internal-prompt-submit-DZ_-2A6a.js} +2 -2
- package/dist/{internal-rebrief-DZygfGHp.js → internal-rebrief-EhBHAHsz.js} +4 -4
- package/dist/{internal-rebrief-DZygfGHp.js.map → internal-rebrief-EhBHAHsz.js.map} +1 -1
- package/dist/{internal-session-bind-CQLDPuTx.js → internal-session-bind-Bv50ju2n.js} +2 -2
- package/dist/{internal-session-bind-CQLDPuTx.js.map → internal-session-bind-Bv50ju2n.js.map} +1 -1
- package/dist/{internal-stop-hook-Dz6mdfcL.js → internal-stop-hook-Iz8XXE07.js} +5 -5
- package/dist/{internal-stop-hook-Dz6mdfcL.js.map → internal-stop-hook-Iz8XXE07.js.map} +1 -1
- package/dist/{internal-stop-review-X7zRRhyc.js → internal-stop-review-K6f8xsCh.js} +2 -2
- package/dist/{internal-stop-review-X7zRRhyc.js.map → internal-stop-review-K6f8xsCh.js.map} +1 -1
- package/dist/{internal-worker-guard-wP3UN-3D.js → internal-worker-guard-GVhTjVlR.js} +2 -2
- package/dist/{internal-worker-guard-wP3UN-3D.js.map → internal-worker-guard-GVhTjVlR.js.map} +1 -1
- package/dist/{internal-workspace-header-DiUnkUeU.js → internal-workspace-header-d2hFf9Jy.js} +2 -2
- package/dist/{internal-workspace-header-DiUnkUeU.js.map → internal-workspace-header-d2hFf9Jy.js.map} +1 -1
- package/dist/lifecycle-BU_d2QMs.js +1 -0
- package/dist/lifecycle-ByFyew_w.js +1 -0
- package/dist/{lifecycle-BJ83L0tz.js → lifecycle-C6cxM_Nk.js} +2 -2
- package/dist/{lifecycle-BJ83L0tz.js.map → lifecycle-C6cxM_Nk.js.map} +1 -1
- package/dist/{lifecycle-aApO0hZW.js → lifecycle-pl9QpvqD.js} +2 -2
- package/dist/{lifecycle-aApO0hZW.js.map → lifecycle-pl9QpvqD.js.map} +1 -1
- package/dist/main.js +23 -23
- package/dist/{max-profile-contract-CMvzKSsg.js → max-profile-contract-Cx5_Z1Y7.js} +2 -2
- package/dist/{max-profile-contract-CMvzKSsg.js.map → max-profile-contract-Cx5_Z1Y7.js.map} +1 -1
- package/dist/{mcp-workspace-header-DBQugQlQ.js → mcp-workspace-header-Su8uUxJg.js} +2 -2
- package/dist/{mcp-workspace-header-DBQugQlQ.js.map → mcp-workspace-header-Su8uUxJg.js.map} +1 -1
- package/dist/{models-JIvKAGn0.js → models-D8v8OTbN.js} +3 -3
- package/dist/{models-JIvKAGn0.js.map → models-D8v8OTbN.js.map} +1 -1
- package/dist/{orchestration-D-S_0GVt.js → orchestration-Bov4rZEi.js} +2 -2
- package/dist/{orchestration-D-S_0GVt.js.map → orchestration-Bov4rZEi.js.map} +1 -1
- package/dist/{paths-xTSEAWfN.js → paths-BSI_EtDT.js} +18 -18
- package/dist/paths-BSI_EtDT.js.map +1 -0
- package/dist/paths-BYxX9DfA.js +1 -0
- package/dist/{peer-mcp-personas-Ch4VWo40.js → peer-mcp-personas-GANlrtNR.js} +2857 -150
- package/dist/peer-mcp-personas-GANlrtNR.js.map +1 -0
- package/dist/{pi-Cwj383nc.js → pi-TKFwPyLA.js} +22 -16
- package/dist/{pi-Cwj383nc.js.map → pi-TKFwPyLA.js.map} +1 -1
- package/dist/{plan-review-hook-BQ29WGv7.js → plan-review-hook-CHK1wL3-.js} +3 -3
- package/dist/{plan-review-hook-BQ29WGv7.js.map → plan-review-hook-CHK1wL3-.js.map} +1 -1
- package/dist/{provision-PodfFQu-.js → provision-BNN6yRk8.js} +6 -5
- package/dist/provision-BNN6yRk8.js.map +1 -0
- package/dist/{self-invocation-Dr5zlbpM.js → self-invocation-Dk_UHD_v.js} +2 -2
- package/dist/{self-invocation-Dr5zlbpM.js.map → self-invocation-Dk_UHD_v.js.map} +1 -1
- package/dist/{serve-D-OuW7kz.js → serve-BaeLm9Um.js} +25 -17
- package/dist/serve-BaeLm9Um.js.map +1 -0
- package/dist/{server-setup-DDZxJgl0.js → server-setup-BcUQv5ac.js} +161 -27
- package/dist/server-setup-BcUQv5ac.js.map +1 -0
- package/dist/{service-backend-DV1u5x0Q.js → service-backend-DHyd9vjW.js} +3 -3
- package/dist/{service-backend-DV1u5x0Q.js.map → service-backend-DHyd9vjW.js.map} +1 -1
- package/dist/{start-CZZ0cTV9.js → start-BdoGJc36.js} +4 -4
- package/dist/{start-CZZ0cTV9.js.map → start-BdoGJc36.js.map} +1 -1
- package/dist/{state-CfEVoqBM.js → state-CiwCLVDZ.js} +3 -1
- package/dist/{state-CfEVoqBM.js.map → state-CiwCLVDZ.js.map} +1 -1
- package/dist/{static-context-pack-BRqt4ajJ.js → static-context-pack-dKrzbfIN.js} +3 -3
- package/dist/{static-context-pack-BRqt4ajJ.js.map → static-context-pack-dKrzbfIN.js.map} +1 -1
- package/dist/{stop-gate-hook-BYd0NruJ.js → stop-gate-hook-CC7VWkZM.js} +3 -3
- package/dist/{stop-gate-hook-BYd0NruJ.js.map → stop-gate-hook-CC7VWkZM.js.map} +1 -1
- package/dist/{stop-gate-policy-FGAfpfc-.js → stop-gate-policy-CoR8xKNQ.js} +2 -2
- package/dist/{stop-gate-policy-FGAfpfc-.js.map → stop-gate-policy-CoR8xKNQ.js.map} +1 -1
- package/dist/{token-CTf5jCmP.js → token-CA2s70qj.js} +3 -3
- package/dist/{token-CTf5jCmP.js.map → token-CA2s70qj.js.map} +1 -1
- package/dist/{worker-dispatch-BjfROaic.js → worker-dispatch-B_rriT7z.js} +2 -2
- package/dist/{worker-dispatch-BjfROaic.js.map → worker-dispatch-B_rriT7z.js.map} +1 -1
- package/docs/azure-mcp.md +10 -1
- package/package.json +1 -1
- package/dist/ado-tools-B5TCtnlQ.js +0 -1
- package/dist/bluebird-client-ltPIiyJU.js.map +0 -1
- package/dist/bluebird-client-mr3M67k-.js +0 -1
- package/dist/claude-BAKFTVqA.js.map +0 -1
- package/dist/engine-YvnWaTnR.js +0 -1
- package/dist/lifecycle-CVg2-zQ3.js +0 -1
- package/dist/lifecycle-Dk_BHtfz.js +0 -1
- package/dist/paths-C9x5U3dO.js +0 -1
- package/dist/paths-xTSEAWfN.js.map +0 -1
- package/dist/peer-mcp-personas-Ch4VWo40.js.map +0 -1
- package/dist/provision-PodfFQu-.js.map +0 -1
- package/dist/serve-D-OuW7kz.js.map +0 -1
- package/dist/server-setup-DDZxJgl0.js.map +0 -1
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { A as validateWorkspace, C as provisionColbert, D as colbertPlatformSupported, F as outlineFile, M as isSensitivePath, N as recommendedRgThreads, O as resolveRipgrep, S as colbertSmokeOk, _ as gitState, d as runSemanticSearch, f as startupKickAllowed, j as confineToWorkspaceResult, k as searchCode, o as serviceBackendEnabled, r as runServiceSearch, u as kickBackgroundInit, x as colbertArtifactsPresent, y as readColbertMeta } from "./service-backend-
|
|
1
|
+
import { A as validateWorkspace, C as provisionColbert, D as colbertPlatformSupported, F as outlineFile, M as isSensitivePath, N as recommendedRgThreads, O as resolveRipgrep, S as colbertSmokeOk, _ as gitState, d as runSemanticSearch, f as startupKickAllowed, j as confineToWorkspaceResult, k as searchCode, o as serviceBackendEnabled, r as runServiceSearch, u as kickBackgroundInit, x as colbertArtifactsPresent, y as readColbertMeta } from "./service-backend-DHyd9vjW.js";
|
|
2
2
|
import { n as explicitPackageRoot } from "./package-root-B-osctCk.js";
|
|
3
3
|
import { t as getPackageVersion } from "./version-C8x2hQrZ.js";
|
|
4
|
-
import { t as PATHS } from "./paths-
|
|
5
|
-
import { t as state } from "./state-
|
|
6
|
-
import { C as githubAgentGraphQLHeaders, S as copilotVersion, b as copilotBaseUrl, d as resolveModel, f as sleep$
|
|
4
|
+
import { t as PATHS } from "./paths-BSI_EtDT.js";
|
|
5
|
+
import { t as state } from "./state-CiwCLVDZ.js";
|
|
6
|
+
import { C as githubAgentGraphQLHeaders, S as copilotVersion, b as copilotBaseUrl, d as resolveModel, f as sleep$3, g as HTTPError, h as isAllowedCopilotHost, i as tryRefreshAndRetry, v as GITHUB_API_BASE_URL, w as githubAgentHeaders, x as copilotHeaders, y as GITHUB_GRAPHQL_URL } from "./token-CA2s70qj.js";
|
|
7
7
|
import { a as withTransientRetry, i as sanitizeTransportText, n as classifyTransportError, r as fetchWithTransientRetry } from "./upstream-retry-i1k1Xai2.js";
|
|
8
8
|
import { a as parseBoolEnv, d as runManagedExeCapture, o as parseIntEnv, s as resolveExecutable } from "./exec-Bf8g_bIR.js";
|
|
9
9
|
import { a as FAST_PROFILE_ASTRA_MODEL, c as FAST_PROFILE_MODELS, d as FAST_PROFILE_NATIVE_MODELS, f as FAST_PROFILE_ORACLE_EFFORT, n as FAST_PROFILE_ADVISOR_EFFORT, p as FAST_PROFILE_ORACLE_MODEL, r as FAST_PROFILE_ADVISOR_MODEL, u as FAST_PROFILE_NATIVE_EFFORTS } from "./fast-profile-contract-JOnZBgFB.js";
|
|
10
|
-
import { C as CHEAPEST_PROFILE_ADVISOR_MODEL, D as CHEAPEST_PROFILE_MODELS, E as CHEAPEST_PROFILE_ADVISOR_TRANSCRIPT_TOKENS_MIN, T as CHEAPEST_PROFILE_ADVISOR_TRANSCRIPT_TOKENS_MAX, _ as isBalancedFamily, b as CHEAPEST2_PROFILE_MODELS, d as isCheapestRewriteEligible, f as runCheapestRewrite, g as displayModelName, h as cheapestRewriteModelFor, m as cheapestContractFor, p as balancedContractFor, s as isNonTrivialPrompt, t as buildStaticPack, u as isCheapestRewriteDisabledEnv, v as isCheapestFamily, w as CHEAPEST_PROFILE_ADVISOR_TRANSCRIPT_TOKENS_DEFAULT, x as BALANCED2_PROFILE_MODELS, y as isPinnedLaunchProfile } from "./static-context-pack-
|
|
10
|
+
import { C as CHEAPEST_PROFILE_ADVISOR_MODEL, D as CHEAPEST_PROFILE_MODELS, E as CHEAPEST_PROFILE_ADVISOR_TRANSCRIPT_TOKENS_MIN, T as CHEAPEST_PROFILE_ADVISOR_TRANSCRIPT_TOKENS_MAX, _ as isBalancedFamily, b as CHEAPEST2_PROFILE_MODELS, d as isCheapestRewriteEligible, f as runCheapestRewrite, g as displayModelName, h as cheapestRewriteModelFor, m as cheapestContractFor, p as balancedContractFor, s as isNonTrivialPrompt, t as buildStaticPack, u as isCheapestRewriteDisabledEnv, v as isCheapestFamily, w as CHEAPEST_PROFILE_ADVISOR_TRANSCRIPT_TOKENS_DEFAULT, x as BALANCED2_PROFILE_MODELS, y as isPinnedLaunchProfile } from "./static-context-pack-dKrzbfIN.js";
|
|
11
11
|
import { r as BALANCED_PROFILE_MODELS } from "./balanced-profile-contract-DtnTIBjL.js";
|
|
12
|
-
import { A as normalizeTrailingOneMSuffix, D as maxPeerInstructions, E as maxPeerDescription, O as fastEndpointForCatalogId, b as MAX_ADVISOR_SYSTEM_PROMPT, f as maxCodexReviewerModel, g as maxProReplacementModel, h as maxOpusModel, i as MAX_PROFILE_MODELS, k as fastEndpointForModel, m as maxGrokModel, p as maxGeminiModel, r as MAX_PROFILE_LEAD_MODEL, v as maxSonnetModel } from "./max-profile-contract-
|
|
13
|
-
import { i as registerExitHandlers$1, n as getInstanceUuid, r as recordWorkerRepo, t as WorktreeRegistry } from "./lifecycle-
|
|
14
|
-
import { t as MCP_WORKSPACE_HEADER } from "./mcp-workspace-header-
|
|
12
|
+
import { A as normalizeTrailingOneMSuffix, D as maxPeerInstructions, E as maxPeerDescription, O as fastEndpointForCatalogId, b as MAX_ADVISOR_SYSTEM_PROMPT, f as maxCodexReviewerModel, g as maxProReplacementModel, h as maxOpusModel, i as MAX_PROFILE_MODELS, k as fastEndpointForModel, m as maxGrokModel, p as maxGeminiModel, r as MAX_PROFILE_LEAD_MODEL, v as maxSonnetModel } from "./max-profile-contract-Cx5_Z1Y7.js";
|
|
13
|
+
import { i as registerExitHandlers$1, n as getInstanceUuid, r as recordWorkerRepo, t as WorktreeRegistry } from "./lifecycle-pl9QpvqD.js";
|
|
14
|
+
import { t as MCP_WORKSPACE_HEADER } from "./mcp-workspace-header-Su8uUxJg.js";
|
|
15
15
|
import { n as ArtifactError, r as applyInsecureTls, t as ArtifactClient } from "./client-CQMfroGV.js";
|
|
16
|
-
import { f as stopReviewStateDir, o as fileRewriteFlagStore } from "./stop-gate-policy-
|
|
17
|
-
import { _ as
|
|
18
|
-
import { r as registerColbertExitHandlers } from "./lifecycle-
|
|
19
|
-
import { a as extractAndRecordPricedAic, i as extractAndRecordAic, l as recordAic, p as extractCopilotUsage } from "./aic-ledger-
|
|
20
|
-
import { h as runGateChecks, m as sealedGateIds, p as resolveSealedGate } from "./stop-gate-hook-
|
|
21
|
-
import { t as liveExec } from "./orchestration-
|
|
16
|
+
import { f as stopReviewStateDir, o as fileRewriteFlagStore } from "./stop-gate-policy-CoR8xKNQ.js";
|
|
17
|
+
import { _ as RemoteMcpError, b as sanitizeRemoteDetail, f as getAzureRepoFromGit, g as RemoteMcpClient, h as describeAzFailure, l as ensureBluebirdClient, m as AzCliAccessTokenCache, o as BluebirdError, p as resolveAzureRepoIds, v as isRecord$4, x as sleep$4, y as parseRetryAfter } from "./bluebird-client-C29-JOkG.js";
|
|
18
|
+
import { r as registerColbertExitHandlers } from "./lifecycle-C6cxM_Nk.js";
|
|
19
|
+
import { a as extractAndRecordPricedAic, i as extractAndRecordAic, l as recordAic, p as extractCopilotUsage } from "./aic-ledger-BuFrsGur.js";
|
|
20
|
+
import { h as runGateChecks, m as sealedGateIds, p as resolveSealedGate } from "./stop-gate-hook-CC7VWkZM.js";
|
|
21
|
+
import { t as liveExec } from "./orchestration-Bov4rZEi.js";
|
|
22
22
|
import { createRequire } from "node:module";
|
|
23
23
|
import consola from "consola";
|
|
24
24
|
import { chmodSync, closeSync, constants, cpSync, existsSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
@@ -754,7 +754,7 @@ const ARTIFACT_TOOLS = Object.freeze([
|
|
|
754
754
|
}, ["file"]), async (args, signal) => {
|
|
755
755
|
const env = readArtifactEnv();
|
|
756
756
|
if (!env) return missingEnvResult();
|
|
757
|
-
const file = requiredString$
|
|
757
|
+
const file = requiredString$3(args, "file");
|
|
758
758
|
const mode = optionalEnum(args, "mode", ["static", "interactive"]);
|
|
759
759
|
const response = await clientFromEnv(env).open(file, {
|
|
760
760
|
mode,
|
|
@@ -774,10 +774,10 @@ const ARTIFACT_TOOLS = Object.freeze([
|
|
|
774
774
|
}, []), async (args, signal) => {
|
|
775
775
|
const env = readArtifactEnv();
|
|
776
776
|
if (!env) return missingEnvResult();
|
|
777
|
-
const file = optionalString$
|
|
778
|
-
const html = optionalString$
|
|
777
|
+
const file = optionalString$3(args, "file");
|
|
778
|
+
const html = optionalString$3(args, "html");
|
|
779
779
|
if (file === void 0 === (html === void 0)) throw new ArtifactToolInputError("INVALID_ARGUMENT", "artifact_update requires EXACTLY ONE of arguments.file or arguments.html");
|
|
780
|
-
const idempotencyKey = optionalString$
|
|
780
|
+
const idempotencyKey = optionalString$3(args, "idempotencyKey");
|
|
781
781
|
return ok$2(formatUpdateSuccess(await clientFromEnv(env).update({
|
|
782
782
|
file,
|
|
783
783
|
html,
|
|
@@ -796,7 +796,7 @@ const ARTIFACT_TOOLS = Object.freeze([
|
|
|
796
796
|
}, []), async (args, signal) => {
|
|
797
797
|
const env = readArtifactEnv();
|
|
798
798
|
if (!env) return missingEnvResult();
|
|
799
|
-
const cursor = optionalString$
|
|
799
|
+
const cursor = optionalString$3(args, "cursor");
|
|
800
800
|
const timeoutMs = optionalNumber$2(args, "timeoutMs");
|
|
801
801
|
return ok$2(formatAwaitResponse(await clientFromEnv(env).awaitEvents({
|
|
802
802
|
cursor,
|
|
@@ -812,7 +812,7 @@ const ARTIFACT_TOOLS = Object.freeze([
|
|
|
812
812
|
tool("artifact_reply", "Sends the agent's reply back to the ai-or-die Artifact review panel after applying or responding to human feedback. The caller provides the reply text, and the tool returns a minimal success signal plus next-step guidance for either continuing the review loop or moving on. Use it to acknowledge what changed, answer a reviewer question, or summarize how feedback was handled after artifact_await returns events. Do not use it to replace panel content, wait for more feedback, hide the UI, or close the review. Only works inside an ai-or-die tab-backed Claude session.", objectSchema$2({ text: stringProp$2("Agent reply text to deliver to the human Artifact review panel.") }, ["text"]), async (args, signal) => {
|
|
813
813
|
const env = readArtifactEnv();
|
|
814
814
|
if (!env) return missingEnvResult();
|
|
815
|
-
const text = requiredString$
|
|
815
|
+
const text = requiredString$3(args, "text");
|
|
816
816
|
return ok$2(formatReplySuccess(await clientFromEnv(env).agentReply(text, signal)));
|
|
817
817
|
}),
|
|
818
818
|
tool("artifact_end", "Ends and closes the ai-or-die Artifact review panel when the review loop is complete. The tool takes no inputs and returns a minimal success signal plus terminal next-step guidance. Use it after the human review is finished and no further feedback should arrive. Do not use it for a temporary hide or pause; use artifact_dismiss when the review should stay live. Only works inside an ai-or-die tab-backed Claude session.", objectSchema$2({}, []), async (_args, signal) => {
|
|
@@ -901,27 +901,27 @@ function formatPollResponse(response) {
|
|
|
901
901
|
function formatUpdateSuccess(response) {
|
|
902
902
|
return definedObject$1({
|
|
903
903
|
ok: true,
|
|
904
|
-
viewUrl: stringField$
|
|
904
|
+
viewUrl: stringField$2(response, "viewUrl"),
|
|
905
905
|
next_step: "The panel now shows the updated content. Call artifact_await for further feedback."
|
|
906
906
|
});
|
|
907
907
|
}
|
|
908
908
|
function formatRefreshSuccess(response) {
|
|
909
909
|
return definedObject$1({
|
|
910
910
|
ok: true,
|
|
911
|
-
viewUrl: stringField$
|
|
912
|
-
panelUrl: stringField$
|
|
913
|
-
status: stringField$
|
|
914
|
-
visibility: stringField$
|
|
911
|
+
viewUrl: stringField$2(response, "viewUrl"),
|
|
912
|
+
panelUrl: stringField$2(response, "panelUrl"),
|
|
913
|
+
status: stringField$2(response, "status"),
|
|
914
|
+
visibility: stringField$2(response, "visibility"),
|
|
915
915
|
next_step: "The panel reloaded the artifact. Call artifact_await for feedback."
|
|
916
916
|
});
|
|
917
917
|
}
|
|
918
918
|
function formatDismissSuccess(response) {
|
|
919
919
|
return definedObject$1({
|
|
920
920
|
ok: true,
|
|
921
|
-
viewUrl: stringField$
|
|
922
|
-
panelUrl: stringField$
|
|
923
|
-
status: stringField$
|
|
924
|
-
visibility: stringField$
|
|
921
|
+
viewUrl: stringField$2(response, "viewUrl"),
|
|
922
|
+
panelUrl: stringField$2(response, "panelUrl"),
|
|
923
|
+
status: stringField$2(response, "status"),
|
|
924
|
+
visibility: stringField$2(response, "visibility"),
|
|
925
925
|
next_step: "The panel is hidden but the review is still live. Re-open the artifact or call artifact_await when ready."
|
|
926
926
|
});
|
|
927
927
|
}
|
|
@@ -929,9 +929,9 @@ function formatReplySuccess(response) {
|
|
|
929
929
|
return definedObject$1({
|
|
930
930
|
ok: true,
|
|
931
931
|
reply: response.reply,
|
|
932
|
-
delivered: booleanField(response, "delivered"),
|
|
933
|
-
confirmed: booleanField(response, "confirmed"),
|
|
934
|
-
status: stringField$
|
|
932
|
+
delivered: booleanField$1(response, "delivered"),
|
|
933
|
+
confirmed: booleanField$1(response, "confirmed"),
|
|
934
|
+
status: stringField$2(response, "status"),
|
|
935
935
|
next_step: "Wait for further human review, or continue if the review loop is complete."
|
|
936
936
|
});
|
|
937
937
|
}
|
|
@@ -973,12 +973,12 @@ function isWaitingStatus(status) {
|
|
|
973
973
|
const normalized = status.toLowerCase();
|
|
974
974
|
return normalized === "waiting" || normalized === "pending" || normalized === "open" || normalized === "idle" || normalized === "timeout" || normalized === "no_feedback";
|
|
975
975
|
}
|
|
976
|
-
function requiredString$
|
|
976
|
+
function requiredString$3(args, key) {
|
|
977
977
|
const value = args[key];
|
|
978
978
|
if (typeof value !== "string" || value.trim() === "") throw new ArtifactToolInputError("INVALID_ARGUMENT", `arguments.${key} is required and must be a non-empty string`);
|
|
979
979
|
return value;
|
|
980
980
|
}
|
|
981
|
-
function optionalString$
|
|
981
|
+
function optionalString$3(args, key) {
|
|
982
982
|
const value = args[key];
|
|
983
983
|
if (value === void 0 || value === null) return void 0;
|
|
984
984
|
if (typeof value !== "string" || value.trim() === "") throw new ArtifactToolInputError("INVALID_ARGUMENT", `arguments.${key} must be a non-empty string when provided`);
|
|
@@ -991,7 +991,7 @@ function optionalNumber$2(args, key) {
|
|
|
991
991
|
return value;
|
|
992
992
|
}
|
|
993
993
|
function optionalEnum(args, key, allowed) {
|
|
994
|
-
const value = optionalString$
|
|
994
|
+
const value = optionalString$3(args, key);
|
|
995
995
|
if (value === void 0) return void 0;
|
|
996
996
|
if (!allowed.includes(value)) throw new ArtifactToolInputError("INVALID_ARGUMENT", `arguments.${key} must be one of ${allowed.join(", ")}`);
|
|
997
997
|
return value;
|
|
@@ -1046,11 +1046,11 @@ function definedObject$1(input) {
|
|
|
1046
1046
|
for (const [key, value] of Object.entries(input)) if (value !== void 0) result[key] = value;
|
|
1047
1047
|
return result;
|
|
1048
1048
|
}
|
|
1049
|
-
function stringField$
|
|
1049
|
+
function stringField$2(input, key) {
|
|
1050
1050
|
const value = input[key];
|
|
1051
1051
|
return typeof value === "string" ? value : void 0;
|
|
1052
1052
|
}
|
|
1053
|
-
function booleanField(input, key) {
|
|
1053
|
+
function booleanField$1(input, key) {
|
|
1054
1054
|
const value = input[key];
|
|
1055
1055
|
return typeof value === "boolean" ? value : void 0;
|
|
1056
1056
|
}
|
|
@@ -3280,10 +3280,10 @@ function createFleetTools(options = {}) {
|
|
|
3280
3280
|
return getRegistry().resolveInstance(arg);
|
|
3281
3281
|
}
|
|
3282
3282
|
async function resolveSession(args) {
|
|
3283
|
-
const globalId = requiredString$
|
|
3283
|
+
const globalId = requiredString$2(args, "sessionId");
|
|
3284
3284
|
const decoded = decodeSessionId(globalId);
|
|
3285
3285
|
const instance = await resolve(decoded.instanceId);
|
|
3286
|
-
const explicitInstance = optionalString$
|
|
3286
|
+
const explicitInstance = optionalString$2(args, "instance");
|
|
3287
3287
|
if (explicitInstance !== void 0) {
|
|
3288
3288
|
const explicit = await resolve(explicitInstance);
|
|
3289
3289
|
if (explicit.id !== decoded.instanceId) throw new FleetToolInputError("INSTANCE_MISMATCH", `sessionId is for instance ${JSON.stringify(decoded.instanceId)} but arguments.instance resolved to ${JSON.stringify(explicit.id)}`);
|
|
@@ -3361,7 +3361,7 @@ function createFleetTools(options = {}) {
|
|
|
3361
3361
|
return ok$1({ instances: await mapWithConcurrency(await getRegistry().listInstances(), fleetFanoutConcurrency(LIST_INSTANCES_FANOUT_CONCURRENCY), (instance) => probeInstance(instance)) });
|
|
3362
3362
|
}),
|
|
3363
3363
|
tool("list_sessions", "Lists sessions on one remote ai-or-die fleet instance and returns session ids that can be used by the other fleet session tools. The optional instance input is an id or label; when it is omitted, the registry default or sole instance is used. It returns resolvedInstance and sessions, with each sessionId globalized as instanceId:localSessionId. It is useful after list_instances to choose a remote session to inspect, message, drive, or stop. It is not a fleet-wide listing and does not read transcript output; call it per instance, and use read_session for a session's text tail.", objectSchema$1({ instance: stringProp$1("Instance id or label. Defaults to the registry default, or the sole instance.") }, []), async (args, signal) => {
|
|
3364
|
-
const instance = await resolve(optionalString$
|
|
3364
|
+
const instance = await resolve(optionalString$2(args, "instance"));
|
|
3365
3365
|
const response = await clientFor(instance).listSessions(signal);
|
|
3366
3366
|
return ok$1({
|
|
3367
3367
|
resolvedInstance: publicInstance(instance),
|
|
@@ -3428,8 +3428,8 @@ function createFleetTools(options = {}) {
|
|
|
3428
3428
|
}
|
|
3429
3429
|
}
|
|
3430
3430
|
const response = await client.sendMessage(localId, {
|
|
3431
|
-
message: requiredString$
|
|
3432
|
-
idempotencyKey: optionalString$
|
|
3431
|
+
message: requiredString$2(args, "message"),
|
|
3432
|
+
idempotencyKey: optionalString$2(args, "idempotencyKey") ?? randomUUID(),
|
|
3433
3433
|
...awaitMs === void 0 ? {} : { awaitMs }
|
|
3434
3434
|
}, signal);
|
|
3435
3435
|
const delivered = !(response.delivered === false || response.delivery?.status === "failed" || response.delivery?.status === "error");
|
|
@@ -3460,8 +3460,8 @@ function createFleetTools(options = {}) {
|
|
|
3460
3460
|
raw: booleanProp("Pass keys through as raw literal bytes when the instance supports it. Ignored when op is set.")
|
|
3461
3461
|
}, ["sessionId"]), async (args, signal) => {
|
|
3462
3462
|
const { instance, localId, globalId } = await resolveSession(args);
|
|
3463
|
-
const op = optionalString$
|
|
3464
|
-
const literalKeys = optionalString$
|
|
3463
|
+
const op = optionalString$2(args, "op");
|
|
3464
|
+
const literalKeys = optionalString$2(args, "keys");
|
|
3465
3465
|
if (op !== void 0 && literalKeys !== void 0) throw new FleetToolInputError("INVALID_ARGUMENT", "provide either arguments.op or arguments.keys, not both");
|
|
3466
3466
|
if (op === void 0 && literalKeys === void 0) throw new FleetToolInputError("INVALID_ARGUMENT", "one of arguments.op or arguments.keys is required");
|
|
3467
3467
|
let keys;
|
|
@@ -3476,7 +3476,7 @@ function createFleetTools(options = {}) {
|
|
|
3476
3476
|
}
|
|
3477
3477
|
const response = await clientFor(instance).sendKeys(localId, {
|
|
3478
3478
|
keys,
|
|
3479
|
-
idempotencyKey: optionalString$
|
|
3479
|
+
idempotencyKey: optionalString$2(args, "idempotencyKey") ?? randomUUID(),
|
|
3480
3480
|
...raw === void 0 ? {} : { raw }
|
|
3481
3481
|
}, signal);
|
|
3482
3482
|
return ok$1({
|
|
@@ -3500,10 +3500,10 @@ function createFleetTools(options = {}) {
|
|
|
3500
3500
|
}, ["sessionId"]), async (args, signal) => {
|
|
3501
3501
|
const { instance, localId, globalId } = await resolveSession(args);
|
|
3502
3502
|
const input = definedObject({
|
|
3503
|
-
choice: optionalString$
|
|
3504
|
-
optionValue: optionalString$
|
|
3505
|
-
keys: optionalString$
|
|
3506
|
-
idempotencyKey: optionalString$
|
|
3503
|
+
choice: optionalString$2(args, "choice"),
|
|
3504
|
+
optionValue: optionalString$2(args, "optionValue"),
|
|
3505
|
+
keys: optionalString$2(args, "keys"),
|
|
3506
|
+
idempotencyKey: optionalString$2(args, "idempotencyKey") ?? randomUUID()
|
|
3507
3507
|
});
|
|
3508
3508
|
const response = await clientFor(instance).respond(localId, input, signal);
|
|
3509
3509
|
const delivered = response.delivered !== false;
|
|
@@ -3536,10 +3536,10 @@ function createFleetTools(options = {}) {
|
|
|
3536
3536
|
agentArgs: arrayProp("Claude-only extra launcher args appended after the github-router prefix. Do not include --permission-mode or --dangerously-skip-permissions; use permissionMode instead."),
|
|
3537
3537
|
disableStopGate: booleanProp("Claude-only option to disable the structural Stop-gate on the launched session by injecting --no-stop-gate into agentArgs, so a driven session's turn-end does not hang on a blocking Stop hook. Requires a remote github-router that understands the flag.")
|
|
3538
3538
|
}, ["instance", "agent"]), async (args, signal) => {
|
|
3539
|
-
const instance = await resolve(requiredString$
|
|
3540
|
-
const agent = requiredString$
|
|
3541
|
-
const idempotencyKey = optionalString$
|
|
3542
|
-
const permissionMode = optionalString$
|
|
3539
|
+
const instance = await resolve(requiredString$2(args, "instance"));
|
|
3540
|
+
const agent = requiredString$2(args, "agent");
|
|
3541
|
+
const idempotencyKey = optionalString$2(args, "idempotencyKey") ?? randomUUID();
|
|
3542
|
+
const permissionMode = optionalString$2(args, "permissionMode");
|
|
3543
3543
|
const disableStopGate = optionalBoolean$1(args, "disableStopGate") === true;
|
|
3544
3544
|
const requestedAgentArgs = optionalStringArray(args, "agentArgs");
|
|
3545
3545
|
const agentArgs = disableStopGate ? [...requestedAgentArgs ?? [], "--no-stop-gate"] : requestedAgentArgs;
|
|
@@ -3547,8 +3547,8 @@ function createFleetTools(options = {}) {
|
|
|
3547
3547
|
if (agentArgs !== void 0) await assertCapability(instance, "agent_args", disableStopGate ? "disableStopGate" : "agentArgs", signal);
|
|
3548
3548
|
const response = await clientFor(instance).createSession(definedObject({
|
|
3549
3549
|
agent,
|
|
3550
|
-
name: optionalString$
|
|
3551
|
-
workingDir: optionalString$
|
|
3550
|
+
name: optionalString$2(args, "name"),
|
|
3551
|
+
workingDir: optionalString$2(args, "workingDir"),
|
|
3552
3552
|
start: optionalBoolean$1(args, "start"),
|
|
3553
3553
|
readyTimeoutMs: optionalNumber$1(args, "readyTimeoutMs"),
|
|
3554
3554
|
permissionMode,
|
|
@@ -3569,9 +3569,9 @@ function createFleetTools(options = {}) {
|
|
|
3569
3569
|
mode: stringProp$1("Optional stop mode understood by the remote instance.")
|
|
3570
3570
|
}, ["sessionId"]), async (args, signal) => {
|
|
3571
3571
|
const { instance, localId, globalId } = await resolveSession(args);
|
|
3572
|
-
const idempotencyKey = optionalString$
|
|
3572
|
+
const idempotencyKey = optionalString$2(args, "idempotencyKey") ?? randomUUID();
|
|
3573
3573
|
const response = await clientFor(instance).stopSession(localId, definedObject({
|
|
3574
|
-
mode: optionalString$
|
|
3574
|
+
mode: optionalString$2(args, "mode"),
|
|
3575
3575
|
idempotencyKey
|
|
3576
3576
|
}), signal);
|
|
3577
3577
|
return ok$1({
|
|
@@ -3588,7 +3588,7 @@ function createFleetTools(options = {}) {
|
|
|
3588
3588
|
watcherId: stringProp$1("Optional stable id for this watcher. Use a distinct value for concurrent watchers over the same target set to keep cursors isolated.")
|
|
3589
3589
|
}, []), async (args, signal) => {
|
|
3590
3590
|
const target = await resolveAwaitTarget(args, getRegistry());
|
|
3591
|
-
const cursorByInstance = takeAwaitTurnCursorMap(awaitTurnCursorKey(optionalString$
|
|
3591
|
+
const cursorByInstance = takeAwaitTurnCursorMap(awaitTurnCursorKey(optionalString$2(args, "watcherId")));
|
|
3592
3592
|
const timeoutMs = optionalNumber$1(args, "timeoutMs");
|
|
3593
3593
|
const kinds = optionalStringArray(args, "kinds");
|
|
3594
3594
|
const results = await mapWithConcurrency(target.instances, fleetFanoutConcurrency(AWAIT_TURN_FANOUT_CONCURRENCY), async (instance) => {
|
|
@@ -3657,7 +3657,7 @@ function createFleetTools(options = {}) {
|
|
|
3657
3657
|
const result = await driveTask({
|
|
3658
3658
|
client: clientFor(instance),
|
|
3659
3659
|
localId,
|
|
3660
|
-
prompt: requiredString$
|
|
3660
|
+
prompt: requiredString$2(args, "prompt"),
|
|
3661
3661
|
timeoutMs: optionalNumber$1(args, "timeoutMs") ?? DRIVE_TASK_DEFAULT_TIMEOUT_MS,
|
|
3662
3662
|
expectReport: optionalBoolean$1(args, "expectReport") ?? true,
|
|
3663
3663
|
idempotencyKey: randomUUID(),
|
|
@@ -3675,8 +3675,8 @@ function createFleetTools(options = {}) {
|
|
|
3675
3675
|
instance: stringProp$1("Instance id or label. Defaults to the registry default, or the sole instance."),
|
|
3676
3676
|
path: stringProp$1("Remote file path to read.")
|
|
3677
3677
|
}, ["path"]), async (args, signal) => {
|
|
3678
|
-
const instance = await resolve(optionalString$
|
|
3679
|
-
const response = await clientFor(instance).readFile(requiredString$
|
|
3678
|
+
const instance = await resolve(optionalString$2(args, "instance"));
|
|
3679
|
+
const response = await clientFor(instance).readFile(requiredString$2(args, "path"), signal);
|
|
3680
3680
|
return ok$1({
|
|
3681
3681
|
resolvedInstance: publicInstance(instance),
|
|
3682
3682
|
...response
|
|
@@ -3686,8 +3686,8 @@ function createFleetTools(options = {}) {
|
|
|
3686
3686
|
instance: stringProp$1("Instance id or label. Defaults to the registry default, or the sole instance."),
|
|
3687
3687
|
path: stringProp$1("Remote directory path to list.")
|
|
3688
3688
|
}, ["path"]), async (args, signal) => {
|
|
3689
|
-
const instance = await resolve(optionalString$
|
|
3690
|
-
const response = await clientFor(instance).listDir(requiredString$
|
|
3689
|
+
const instance = await resolve(optionalString$2(args, "instance"));
|
|
3690
|
+
const response = await clientFor(instance).listDir(requiredString$2(args, "path"), signal);
|
|
3691
3691
|
return ok$1({
|
|
3692
3692
|
resolvedInstance: publicInstance(instance),
|
|
3693
3693
|
...response
|
|
@@ -3698,8 +3698,8 @@ function createFleetTools(options = {}) {
|
|
|
3698
3698
|
query: stringProp$1("Search query."),
|
|
3699
3699
|
path: stringProp$1("Optional path scope.")
|
|
3700
3700
|
}, ["query"]), async (args, signal) => {
|
|
3701
|
-
const instance = await resolve(optionalString$
|
|
3702
|
-
const response = await clientFor(instance).search(requiredString$
|
|
3701
|
+
const instance = await resolve(optionalString$2(args, "instance"));
|
|
3702
|
+
const response = await clientFor(instance).search(requiredString$2(args, "query"), optionalString$2(args, "path"), signal);
|
|
3703
3703
|
return ok$1({
|
|
3704
3704
|
resolvedInstance: publicInstance(instance),
|
|
3705
3705
|
...response
|
|
@@ -3710,10 +3710,10 @@ function createFleetTools(options = {}) {
|
|
|
3710
3710
|
path: stringProp$1("Remote repository path or file path for git-show."),
|
|
3711
3711
|
ref: stringProp$1("Optional git ref, revision, or commit-ish, such as HEAD, a branch, a tag, or a commit SHA.")
|
|
3712
3712
|
}, ["path"]), async (args, signal) => {
|
|
3713
|
-
const instance = await resolve(optionalString$
|
|
3713
|
+
const instance = await resolve(optionalString$2(args, "instance"));
|
|
3714
3714
|
const response = await clientFor(instance).gitShow(definedObject({
|
|
3715
|
-
path: requiredString$
|
|
3716
|
-
ref: optionalString$
|
|
3715
|
+
path: requiredString$2(args, "path"),
|
|
3716
|
+
ref: optionalString$2(args, "ref")
|
|
3717
3717
|
}), signal);
|
|
3718
3718
|
return ok$1({
|
|
3719
3719
|
resolvedInstance: publicInstance(instance),
|
|
@@ -4021,12 +4021,12 @@ function definedObject(input) {
|
|
|
4021
4021
|
for (const [key, value] of Object.entries(input)) if (value !== void 0) result[key] = value;
|
|
4022
4022
|
return result;
|
|
4023
4023
|
}
|
|
4024
|
-
function requiredString$
|
|
4024
|
+
function requiredString$2(args, key) {
|
|
4025
4025
|
const value = args[key];
|
|
4026
4026
|
if (typeof value !== "string" || value.trim() === "") throw new FleetToolInputError("INVALID_ARGUMENT", `arguments.${key} is required and must be a non-empty string`);
|
|
4027
4027
|
return value;
|
|
4028
4028
|
}
|
|
4029
|
-
function optionalString$
|
|
4029
|
+
function optionalString$2(args, key) {
|
|
4030
4030
|
const value = args[key];
|
|
4031
4031
|
if (value === void 0) return void 0;
|
|
4032
4032
|
if (typeof value !== "string") throw new FleetToolInputError("INVALID_ARGUMENT", `arguments.${key} must be a string`);
|
|
@@ -5043,13 +5043,13 @@ function taskPath(repo, taskId) {
|
|
|
5043
5043
|
function asRecord$6(value) {
|
|
5044
5044
|
return typeof value === "object" && value !== null ? value : void 0;
|
|
5045
5045
|
}
|
|
5046
|
-
function stringField(record, keys) {
|
|
5046
|
+
function stringField$1(record, keys) {
|
|
5047
5047
|
for (const key of keys) {
|
|
5048
5048
|
const value = record?.[key];
|
|
5049
5049
|
if (typeof value === "string" && value.length > 0) return value;
|
|
5050
5050
|
}
|
|
5051
5051
|
}
|
|
5052
|
-
function numberField(record, keys) {
|
|
5052
|
+
function numberField$1(record, keys) {
|
|
5053
5053
|
for (const key of keys) {
|
|
5054
5054
|
const value = record?.[key];
|
|
5055
5055
|
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
@@ -5092,30 +5092,30 @@ function tailExcerpt(text) {
|
|
|
5092
5092
|
return `${TRUNCATED_MARKER}${text.slice(-3987)}`;
|
|
5093
5093
|
}
|
|
5094
5094
|
function taskPrUrl(record) {
|
|
5095
|
-
const direct = stringField(record, [
|
|
5095
|
+
const direct = stringField$1(record, [
|
|
5096
5096
|
"pr_url",
|
|
5097
5097
|
"prUrl",
|
|
5098
5098
|
"pull_request_url",
|
|
5099
5099
|
"pullRequestUrl"
|
|
5100
5100
|
]);
|
|
5101
5101
|
if (direct) return direct;
|
|
5102
|
-
return stringField(asRecord$6(record?.pull_request) ?? asRecord$6(record?.pullRequest), ["html_url", "url"]);
|
|
5102
|
+
return stringField$1(asRecord$6(record?.pull_request) ?? asRecord$6(record?.pullRequest), ["html_url", "url"]);
|
|
5103
5103
|
}
|
|
5104
5104
|
function taskPrNumber$1(record) {
|
|
5105
|
-
const direct = numberField(record, [
|
|
5105
|
+
const direct = numberField$1(record, [
|
|
5106
5106
|
"pr",
|
|
5107
5107
|
"pr_number",
|
|
5108
5108
|
"prNumber",
|
|
5109
5109
|
"pull_request_number"
|
|
5110
5110
|
]);
|
|
5111
5111
|
if (direct !== void 0) return direct;
|
|
5112
|
-
return numberField(asRecord$6(record?.pull_request) ?? asRecord$6(record?.pullRequest), ["number"]) ?? void 0;
|
|
5112
|
+
return numberField$1(asRecord$6(record?.pull_request) ?? asRecord$6(record?.pullRequest), ["number"]) ?? void 0;
|
|
5113
5113
|
}
|
|
5114
5114
|
function latestSessionId(record) {
|
|
5115
5115
|
const sessions = record?.sessions;
|
|
5116
5116
|
if (!Array.isArray(sessions) || sessions.length === 0) return void 0;
|
|
5117
5117
|
for (let i = sessions.length - 1; i >= 0; i -= 1) {
|
|
5118
|
-
const id = stringField(asRecord$6(sessions[i]), [
|
|
5118
|
+
const id = stringField$1(asRecord$6(sessions[i]), [
|
|
5119
5119
|
"id",
|
|
5120
5120
|
"session_id",
|
|
5121
5121
|
"sessionId"
|
|
@@ -5135,12 +5135,12 @@ async function startTask(repo, input) {
|
|
|
5135
5135
|
...input.idempotencyKey ? { headers: { "Idempotency-Key": input.idempotencyKey } } : {}
|
|
5136
5136
|
});
|
|
5137
5137
|
return {
|
|
5138
|
-
taskId: stringField(response, [
|
|
5138
|
+
taskId: stringField$1(response, [
|
|
5139
5139
|
"task_id",
|
|
5140
5140
|
"taskId",
|
|
5141
5141
|
"id"
|
|
5142
5142
|
]) ?? "",
|
|
5143
|
-
state: stringField(response, ["state", "status"]) ?? "unknown"
|
|
5143
|
+
state: stringField$1(response, ["state", "status"]) ?? "unknown"
|
|
5144
5144
|
};
|
|
5145
5145
|
}
|
|
5146
5146
|
async function getTask(repo, taskId) {
|
|
@@ -5150,12 +5150,12 @@ async function getTask(repo, taskId) {
|
|
|
5150
5150
|
const fallbackText = collectText(record).join("\n\n");
|
|
5151
5151
|
const logExcerpt = sessionLog?.excerpt && sessionLog.excerpt.length > 0 ? sessionLog.excerpt : tailExcerpt(fallbackText.length > 0 ? fallbackText : compactKnownKeysSummary(record));
|
|
5152
5152
|
return {
|
|
5153
|
-
taskId: stringField(record, [
|
|
5153
|
+
taskId: stringField$1(record, [
|
|
5154
5154
|
"task_id",
|
|
5155
5155
|
"taskId",
|
|
5156
5156
|
"id"
|
|
5157
5157
|
]) ?? taskId,
|
|
5158
|
-
state: stringField(record, ["state", "status"]) ?? "unknown",
|
|
5158
|
+
state: stringField$1(record, ["state", "status"]) ?? "unknown",
|
|
5159
5159
|
prUrl: taskPrUrl(record),
|
|
5160
5160
|
pr: taskPrNumber$1(record),
|
|
5161
5161
|
logExcerpt,
|
|
@@ -5187,12 +5187,12 @@ async function continueTaskOnBranch(repo, input) {
|
|
|
5187
5187
|
...input.idempotencyKey ? { headers: { "Idempotency-Key": input.idempotencyKey } } : {}
|
|
5188
5188
|
});
|
|
5189
5189
|
return {
|
|
5190
|
-
taskId: stringField(response, [
|
|
5190
|
+
taskId: stringField$1(response, [
|
|
5191
5191
|
"task_id",
|
|
5192
5192
|
"taskId",
|
|
5193
5193
|
"id"
|
|
5194
5194
|
]) ?? "",
|
|
5195
|
-
state: stringField(response, ["state", "status"]) ?? "unknown"
|
|
5195
|
+
state: stringField$1(response, ["state", "status"]) ?? "unknown"
|
|
5196
5196
|
};
|
|
5197
5197
|
}
|
|
5198
5198
|
async function cancelTask(repo, taskId) {
|
|
@@ -5448,7 +5448,7 @@ function runFenced(token, fn) {
|
|
|
5448
5448
|
function currentFenceToken() {
|
|
5449
5449
|
return fenceStore.getStore();
|
|
5450
5450
|
}
|
|
5451
|
-
function sleep$
|
|
5451
|
+
function sleep$2(ms) {
|
|
5452
5452
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
5453
5453
|
}
|
|
5454
5454
|
/**
|
|
@@ -5487,7 +5487,7 @@ async function writeJsonSecure(target, value) {
|
|
|
5487
5487
|
break;
|
|
5488
5488
|
} catch (err) {
|
|
5489
5489
|
lastErr = err;
|
|
5490
|
-
if (attempt < RENAME_RETRY_DELAYS_MS.length) await sleep$
|
|
5490
|
+
if (attempt < RENAME_RETRY_DELAYS_MS.length) await sleep$2(RENAME_RETRY_DELAYS_MS[attempt]);
|
|
5491
5491
|
}
|
|
5492
5492
|
if (!renamed) throw lastErr;
|
|
5493
5493
|
await fs$1.chmod(target, 384).catch(() => {});
|
|
@@ -5530,7 +5530,7 @@ async function withFileLock(target, fn) {
|
|
|
5530
5530
|
}
|
|
5531
5531
|
} catch {}
|
|
5532
5532
|
if (Date.now() - start > LOCK_MAX_WAIT_MS) throw new Error(`first-mate durable-store lock timeout for ${target}`, { cause: err });
|
|
5533
|
-
await sleep$
|
|
5533
|
+
await sleep$2(LOCK_RETRY_MS);
|
|
5534
5534
|
}
|
|
5535
5535
|
const verifyOwner = async () => {
|
|
5536
5536
|
try {
|
|
@@ -5609,7 +5609,7 @@ async function commitJsonCas(opts) {
|
|
|
5609
5609
|
};
|
|
5610
5610
|
if (explicit) throw new DurableConflictError(`durable store rev changed under CAS for ${opts.path} (expected ${base})`);
|
|
5611
5611
|
lastConflict = new DurableConflictError(`durable store contention for ${opts.path} (attempt ${attempt + 1}/${OCC_MAX_ATTEMPTS})`);
|
|
5612
|
-
await sleep$
|
|
5612
|
+
await sleep$2(Math.floor(OCC_BACKOFF_MS * (attempt + 1) * (.5 + Math.random())));
|
|
5613
5613
|
}
|
|
5614
5614
|
throw lastConflict ?? new DurableConflictError(`durable store failed to converge for ${opts.path}`);
|
|
5615
5615
|
}
|
|
@@ -5917,19 +5917,19 @@ function resolveTierModel(tier, opts = {}) {
|
|
|
5917
5917
|
}
|
|
5918
5918
|
//#endregion
|
|
5919
5919
|
//#region src/lib/first-mate/classifier.ts
|
|
5920
|
-
function isRecord$
|
|
5920
|
+
function isRecord$3(value) {
|
|
5921
5921
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5922
5922
|
}
|
|
5923
5923
|
function firstMessageContent$1(value) {
|
|
5924
|
-
if (!isRecord$
|
|
5924
|
+
if (!isRecord$3(value) || !Array.isArray(value.choices)) return null;
|
|
5925
5925
|
const first = value.choices[0];
|
|
5926
|
-
if (!isRecord$
|
|
5926
|
+
if (!isRecord$3(first) || !isRecord$3(first.message)) return null;
|
|
5927
5927
|
return typeof first.message.content === "string" ? first.message.content : null;
|
|
5928
5928
|
}
|
|
5929
5929
|
function parseJsonObject(value) {
|
|
5930
5930
|
try {
|
|
5931
5931
|
const parsed = JSON.parse(value);
|
|
5932
|
-
return isRecord$
|
|
5932
|
+
return isRecord$3(parsed) ? parsed : null;
|
|
5933
5933
|
} catch {
|
|
5934
5934
|
return null;
|
|
5935
5935
|
}
|
|
@@ -6001,7 +6001,7 @@ async function classifyPlanReady(logExcerpt) {
|
|
|
6001
6001
|
schemaHint: "{\"planReady\":boolean,\"planExcerpt\":\"<=1200 chars from the completed plan, or empty\",\"confidence\":number}",
|
|
6002
6002
|
maxTokens: 500,
|
|
6003
6003
|
validate(value) {
|
|
6004
|
-
if (!isRecord$
|
|
6004
|
+
if (!isRecord$3(value)) return null;
|
|
6005
6005
|
const planReady = booleanValue$1(value.planReady);
|
|
6006
6006
|
const planExcerpt = stringValue$1(value.planExcerpt);
|
|
6007
6007
|
if (planReady === null || planExcerpt === null) return null;
|
|
@@ -6018,7 +6018,7 @@ async function classifyQuestionAnswerable(question, acceptanceCriteria) {
|
|
|
6018
6018
|
user: `Acceptance criteria:\n${acceptanceCriteria}\n\nAgent question:\n${question}`,
|
|
6019
6019
|
schemaHint: "{\"answerable\":boolean,\"answer\":\"present only when answerable\",\"confidence\":number}",
|
|
6020
6020
|
validate(value) {
|
|
6021
|
-
if (!isRecord$
|
|
6021
|
+
if (!isRecord$3(value)) return null;
|
|
6022
6022
|
const answerable = booleanValue$1(value.answerable);
|
|
6023
6023
|
if (answerable === null) return null;
|
|
6024
6024
|
const answer = stringValue$1(value.answer);
|
|
@@ -6036,7 +6036,7 @@ async function classifyFixAddressed(failureSummary, latestLogExcerpt) {
|
|
|
6036
6036
|
user: `Failure summary:\n${failureSummary}\n\nLatest log excerpt:\n${latestLogExcerpt}`,
|
|
6037
6037
|
schemaHint: "{\"addressed\":boolean,\"confidence\":number}",
|
|
6038
6038
|
validate(value) {
|
|
6039
|
-
if (!isRecord$
|
|
6039
|
+
if (!isRecord$3(value)) return null;
|
|
6040
6040
|
const addressed = booleanValue$1(value.addressed);
|
|
6041
6041
|
return addressed === null ? null : { addressed };
|
|
6042
6042
|
}
|
|
@@ -6048,7 +6048,7 @@ async function classifyStuck(logExcerpt) {
|
|
|
6048
6048
|
user: `Log excerpt:\n${logExcerpt}`,
|
|
6049
6049
|
schemaHint: "{\"stuck\":boolean,\"confidence\":number}",
|
|
6050
6050
|
validate(value) {
|
|
6051
|
-
if (!isRecord$
|
|
6051
|
+
if (!isRecord$3(value)) return null;
|
|
6052
6052
|
const stuck = booleanValue$1(value.stuck);
|
|
6053
6053
|
return stuck === null ? null : { stuck };
|
|
6054
6054
|
}
|
|
@@ -10926,7 +10926,7 @@ function segment(value) {
|
|
|
10926
10926
|
}
|
|
10927
10927
|
//#endregion
|
|
10928
10928
|
//#region src/lib/first-mate/scheduler/answer-inbox.ts
|
|
10929
|
-
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
10929
|
+
const sleep$1 = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
10930
10930
|
/**
|
|
10931
10931
|
* Windows sharing-violation codes. When two processes rename the SAME source
|
|
10932
10932
|
* concurrently, POSIX gives the loser a clean `ENOENT` (source already gone),
|
|
@@ -10988,7 +10988,7 @@ async function claimByRename(from, to) {
|
|
|
10988
10988
|
const code = err.code;
|
|
10989
10989
|
if (code === "ENOENT") return false;
|
|
10990
10990
|
if (WIN_RENAME_TRANSIENT.has(code ?? "") && attempt < 25) {
|
|
10991
|
-
await sleep(4 + attempt);
|
|
10991
|
+
await sleep$1(4 + attempt);
|
|
10992
10992
|
continue;
|
|
10993
10993
|
}
|
|
10994
10994
|
throw err;
|
|
@@ -11721,14 +11721,14 @@ function createFirstMateTools(depsOverride = {}) {
|
|
|
11721
11721
|
const repos = requiredStringArray(args, "repos").map(parseRepoRef);
|
|
11722
11722
|
const now = Date.now();
|
|
11723
11723
|
const missionId = randomUUID();
|
|
11724
|
-
const defaultModel = optionalString(args, "default_model");
|
|
11724
|
+
const defaultModel = optionalString$1(args, "default_model");
|
|
11725
11725
|
resolveCloudAgentModel(ctx?.profileId === "max" && defaultModel === "gemini-3.1-pro-preview" ? maxProReplacementModel() : defaultModel);
|
|
11726
11726
|
const planGate = optionalPlanGate(args, "plan_gate");
|
|
11727
11727
|
await upsertMission({
|
|
11728
11728
|
id: missionId,
|
|
11729
|
-
goal: requiredString(args, "goal"),
|
|
11730
|
-
acceptanceCriteria: requiredString(args, "acceptance_criteria"),
|
|
11731
|
-
houseRules: optionalString(args, "house_rules"),
|
|
11729
|
+
goal: requiredString$1(args, "goal"),
|
|
11730
|
+
acceptanceCriteria: requiredString$1(args, "acceptance_criteria"),
|
|
11731
|
+
houseRules: optionalString$1(args, "house_rules"),
|
|
11732
11732
|
priority: optionalNumber(args, "priority"),
|
|
11733
11733
|
defaultModel,
|
|
11734
11734
|
...planGate !== void 0 ? { planGate } : {},
|
|
@@ -11828,7 +11828,7 @@ function createFirstMateTools(depsOverride = {}) {
|
|
|
11828
11828
|
humanDecisions: optionalHumanDecisions(args),
|
|
11829
11829
|
topK: optionalNumber(args, "top_k"),
|
|
11830
11830
|
maxInFlightPerProvider: optionalNumber(args, "max_in_flight_per_provider"),
|
|
11831
|
-
missionId: optionalString(args, "mission_id"),
|
|
11831
|
+
missionId: optionalString$1(args, "mission_id"),
|
|
11832
11832
|
includeAll: optionalBoolean(args, "include_all") ?? false,
|
|
11833
11833
|
answerQueue: answerInbox,
|
|
11834
11834
|
...ctx?.profileId === "max" ? { maxProfileReviewModel: maxProReplacementModel() } : {},
|
|
@@ -11872,7 +11872,7 @@ function createFirstMateTools(depsOverride = {}) {
|
|
|
11872
11872
|
});
|
|
11873
11873
|
}),
|
|
11874
11874
|
tool("read_strategy", "Reads the durable strategic record for one first-mate mission so a fresh CEO can rehydrate its current phase, active bet, greatness evidence, decisions, assumptions, and next action. Returns a minimal empty record when no strategy has been written yet. Use at the start of each strategic wake before making portfolio decisions.", objectSchema({ mission_id: stringProp("Mission id whose strategy should be read.") }, ["mission_id"]), async (args) => {
|
|
11875
|
-
const missionId = requiredString(args, "mission_id");
|
|
11875
|
+
const missionId = requiredString$1(args, "mission_id");
|
|
11876
11876
|
return ok(await readStrategy(missionId) ?? {
|
|
11877
11877
|
missionId,
|
|
11878
11878
|
currentPhase: null,
|
|
@@ -11961,11 +11961,11 @@ function createFirstMateTools(depsOverride = {}) {
|
|
|
11961
11961
|
"pr",
|
|
11962
11962
|
"expected_head_sha"
|
|
11963
11963
|
]), async (args) => {
|
|
11964
|
-
const repoSlug = requiredString(args, "repo");
|
|
11964
|
+
const repoSlug = requiredString$1(args, "repo");
|
|
11965
11965
|
const repo = parseRepoSlug(repoSlug);
|
|
11966
11966
|
const pr = requiredPrNumber(args, "pr");
|
|
11967
|
-
const expectedHead = requiredString(args, "expected_head_sha");
|
|
11968
|
-
const expectedBase = optionalString(args, "expected_base");
|
|
11967
|
+
const expectedHead = requiredString$1(args, "expected_head_sha");
|
|
11968
|
+
const expectedBase = optionalString$1(args, "expected_base");
|
|
11969
11969
|
const method = optionalMergeMethod(args, "method");
|
|
11970
11970
|
const allowUnowned = optionalBoolean(args, "allow_unowned") ?? false;
|
|
11971
11971
|
const live = await deps.getPullRequestState(repo, pr);
|
|
@@ -11992,7 +11992,7 @@ function createFirstMateTools(depsOverride = {}) {
|
|
|
11992
11992
|
pr: numberProp("Pull request number."),
|
|
11993
11993
|
allow_unowned: boolProp("Set true to close a PR that is neither agent-authored nor correlated to a first-mate unit (unit.pr === pr). Explicit opt-in; audit-logged.")
|
|
11994
11994
|
}, ["repo", "pr"]), async (args) => {
|
|
11995
|
-
const repoSlug = requiredString(args, "repo");
|
|
11995
|
+
const repoSlug = requiredString$1(args, "repo");
|
|
11996
11996
|
const repo = parseRepoSlug(repoSlug);
|
|
11997
11997
|
const pr = requiredPrNumber(args, "pr");
|
|
11998
11998
|
const allowUnowned = optionalBoolean(args, "allow_unowned") ?? false;
|
|
@@ -12022,7 +12022,7 @@ function createFirstMateTools(depsOverride = {}) {
|
|
|
12022
12022
|
pr: numberProp("Pull request number."),
|
|
12023
12023
|
allow_unowned: boolProp("Set true to mark a PR ready when it is neither agent-authored nor correlated to a first-mate unit (unit.pr === pr). Explicit opt-in; audit-logged.")
|
|
12024
12024
|
}, ["repo", "pr"]), async (args) => {
|
|
12025
|
-
const repoSlug = requiredString(args, "repo");
|
|
12025
|
+
const repoSlug = requiredString$1(args, "repo");
|
|
12026
12026
|
const repo = parseRepoSlug(repoSlug);
|
|
12027
12027
|
const pr = requiredPrNumber(args, "pr");
|
|
12028
12028
|
const allowUnowned = optionalBoolean(args, "allow_unowned") ?? false;
|
|
@@ -12061,7 +12061,7 @@ function createFirstMateTools(depsOverride = {}) {
|
|
|
12061
12061
|
model: stringProp("Optional model override for this unit.")
|
|
12062
12062
|
}, ["title"])
|
|
12063
12063
|
}, ["mission_id", "units"]), async (args, _signal, ctx) => {
|
|
12064
|
-
const missionId = requiredString(args, "mission_id");
|
|
12064
|
+
const missionId = requiredString$1(args, "mission_id");
|
|
12065
12065
|
const mission = (await deps.readMissions()).find((entry) => entry.id === missionId);
|
|
12066
12066
|
if (mission === void 0) return errorResult(new FirstMateToolInputError("MISSION_NOT_FOUND", `mission ${missionId} was not found`));
|
|
12067
12067
|
if (mission.status !== "active") return errorResult(new FirstMateToolInputError("MISSION_NOT_ACTIVE", `mission ${missionId} is ${mission.status}; only active missions can receive units`));
|
|
@@ -12081,8 +12081,8 @@ function createFirstMateTools(depsOverride = {}) {
|
|
|
12081
12081
|
mission_id: stringProp("Mission id to abandon."),
|
|
12082
12082
|
reason: stringProp("Optional short reason for the abandonment.")
|
|
12083
12083
|
}, ["mission_id"]), async (args) => {
|
|
12084
|
-
const missionId = requiredString(args, "mission_id");
|
|
12085
|
-
const reason = optionalString(args, "reason");
|
|
12084
|
+
const missionId = requiredString$1(args, "mission_id");
|
|
12085
|
+
const reason = optionalString$1(args, "reason");
|
|
12086
12086
|
const mission = (await deps.readMissions()).find((entry) => entry.id === missionId);
|
|
12087
12087
|
if (mission === void 0) return errorResult(new FirstMateToolInputError("MISSION_NOT_FOUND", `mission ${missionId} was not found`));
|
|
12088
12088
|
if (mission.status === "done") return errorResult(new FirstMateToolInputError("MISSION_TERMINAL", `mission ${missionId} is done and cannot be abandoned`));
|
|
@@ -12114,7 +12114,7 @@ function createFirstMateTools(depsOverride = {}) {
|
|
|
12114
12114
|
}, []), async (args) => {
|
|
12115
12115
|
const [missions, units] = await Promise.all([readMissions(), loadAllUnits()]);
|
|
12116
12116
|
return ok({
|
|
12117
|
-
missions: buildMissionStatus(missions, units, optionalString(args, "mission_id"), optionalBoolean(args, "include_all") ?? false),
|
|
12117
|
+
missions: buildMissionStatus(missions, units, optionalString$1(args, "mission_id"), optionalBoolean(args, "include_all") ?? false),
|
|
12118
12118
|
inactiveSummary: summarizeInactiveMissions(missions)
|
|
12119
12119
|
});
|
|
12120
12120
|
})
|
|
@@ -12327,7 +12327,7 @@ function optionalBoolean(args, key) {
|
|
|
12327
12327
|
return value;
|
|
12328
12328
|
}
|
|
12329
12329
|
function optionalMergeMethod(args, key) {
|
|
12330
|
-
const value = optionalString(args, key);
|
|
12330
|
+
const value = optionalString$1(args, key);
|
|
12331
12331
|
if (value === void 0) return void 0;
|
|
12332
12332
|
if (value !== "merge" && value !== "squash" && value !== "rebase") throw new FirstMateToolInputError("INVALID_ARGUMENT", `arguments.${key} must be one of "merge", "squash", or "rebase"`);
|
|
12333
12333
|
return value;
|
|
@@ -12373,7 +12373,7 @@ function optionalModelAnswers(args) {
|
|
|
12373
12373
|
return entries.map((entry) => {
|
|
12374
12374
|
if (!Object.prototype.hasOwnProperty.call(entry, "verdict")) throw new FirstMateToolInputError("INVALID_ARGUMENT", "arguments.model_answers entries must include verdict");
|
|
12375
12375
|
return {
|
|
12376
|
-
requestId: requiredString(entry, "requestId"),
|
|
12376
|
+
requestId: requiredString$1(entry, "requestId"),
|
|
12377
12377
|
verdict: entry.verdict
|
|
12378
12378
|
};
|
|
12379
12379
|
});
|
|
@@ -12382,8 +12382,8 @@ function optionalHumanDecisions(args) {
|
|
|
12382
12382
|
const entries = optionalRecordArray(args, "human_decisions");
|
|
12383
12383
|
if (entries === void 0) return void 0;
|
|
12384
12384
|
return entries.map((entry) => ({
|
|
12385
|
-
requestId: requiredString(entry, "requestId"),
|
|
12386
|
-
choice: requiredString(entry, "choice")
|
|
12385
|
+
requestId: requiredString$1(entry, "requestId"),
|
|
12386
|
+
choice: requiredString$1(entry, "choice")
|
|
12387
12387
|
}));
|
|
12388
12388
|
}
|
|
12389
12389
|
async function detectScaffoldOptions(input) {
|
|
@@ -12515,7 +12515,7 @@ function parsePackageJson(text) {
|
|
|
12515
12515
|
if (text === void 0) return void 0;
|
|
12516
12516
|
try {
|
|
12517
12517
|
const parsed = JSON.parse(text);
|
|
12518
|
-
if (!isRecord$
|
|
12518
|
+
if (!isRecord$2(parsed)) return void 0;
|
|
12519
12519
|
return {
|
|
12520
12520
|
scripts: stringRecord(parsed.scripts),
|
|
12521
12521
|
dependencies: stringRecord(parsed.dependencies),
|
|
@@ -12715,11 +12715,11 @@ function buildScaffoldPrBody(reports) {
|
|
|
12715
12715
|
"No factory protocol files are seeded; orchestration remains external to the repository."
|
|
12716
12716
|
].join("\n");
|
|
12717
12717
|
}
|
|
12718
|
-
function isRecord$
|
|
12718
|
+
function isRecord$2(value) {
|
|
12719
12719
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12720
12720
|
}
|
|
12721
12721
|
function stringRecord(value) {
|
|
12722
|
-
if (!isRecord$
|
|
12722
|
+
if (!isRecord$2(value)) return {};
|
|
12723
12723
|
const result = {};
|
|
12724
12724
|
for (const [key, entry] of Object.entries(value)) if (typeof entry === "string") result[key] = entry;
|
|
12725
12725
|
return result;
|
|
@@ -12764,12 +12764,12 @@ function errorCode(err) {
|
|
|
12764
12764
|
}
|
|
12765
12765
|
return "FIRST_MATE_ERROR";
|
|
12766
12766
|
}
|
|
12767
|
-
function requiredString(args, key) {
|
|
12767
|
+
function requiredString$1(args, key) {
|
|
12768
12768
|
const value = args[key];
|
|
12769
12769
|
if (typeof value !== "string" || value.trim() === "") throw new FirstMateToolInputError("INVALID_ARGUMENT", `arguments.${key} is required and must be a non-empty string`);
|
|
12770
12770
|
return value;
|
|
12771
12771
|
}
|
|
12772
|
-
function optionalString(args, key) {
|
|
12772
|
+
function optionalString$1(args, key) {
|
|
12773
12773
|
const value = args[key];
|
|
12774
12774
|
if (value === void 0) return void 0;
|
|
12775
12775
|
if (typeof value !== "string") throw new FirstMateToolInputError("INVALID_ARGUMENT", `arguments.${key} must be a string`);
|
|
@@ -12782,7 +12782,7 @@ function optionalNumber(args, key) {
|
|
|
12782
12782
|
return value;
|
|
12783
12783
|
}
|
|
12784
12784
|
function optionalPlanGate(args, key) {
|
|
12785
|
-
const value = optionalString(args, key);
|
|
12785
|
+
const value = optionalString$1(args, key);
|
|
12786
12786
|
if (value === void 0) return void 0;
|
|
12787
12787
|
if (value !== "hard" && value !== "soft") throw new FirstMateToolInputError("INVALID_ARGUMENT", `arguments.${key} must be one of "hard" or "soft"`);
|
|
12788
12788
|
return value;
|
|
@@ -12899,11 +12899,11 @@ var KustoError = class extends Error {
|
|
|
12899
12899
|
};
|
|
12900
12900
|
/** Wire-shape size limits. A tool result is context, not an export format. */
|
|
12901
12901
|
const MAX_CSL_CHARS = 1e5;
|
|
12902
|
-
const MAX_RESPONSE_BYTES = 8388608;
|
|
12902
|
+
const MAX_RESPONSE_BYTES$1 = 8388608;
|
|
12903
12903
|
const DEFAULT_ROW_CAP = 200;
|
|
12904
12904
|
const DEFAULT_CELL_CHARS = 300;
|
|
12905
12905
|
const DEFAULT_RENDER_CHARS = 6e4;
|
|
12906
|
-
const REQUEST_TIMEOUT_MS = 6e4;
|
|
12906
|
+
const REQUEST_TIMEOUT_MS$1 = 6e4;
|
|
12907
12907
|
/**
|
|
12908
12908
|
* Backoff for a retriable verdict (429/5xx/transport), mirroring the shared
|
|
12909
12909
|
* remote-MCP transport's `initializeWithRecovery`: three retries at 1/2/4 s,
|
|
@@ -12925,16 +12925,16 @@ const KUSTO_RETRY_DELAYS_MS = [
|
|
|
12925
12925
|
* it is buffered at all; a chunked or header-less response falls back to the
|
|
12926
12926
|
* byte count after the read, which is the only remaining signal.
|
|
12927
12927
|
*/
|
|
12928
|
-
async function readBoundedBody(res) {
|
|
12928
|
+
async function readBoundedBody$1(res) {
|
|
12929
12929
|
const declaredHeader = res.headers.get("content-length");
|
|
12930
12930
|
const declared = declaredHeader ? Number(declaredHeader) : NaN;
|
|
12931
|
-
if (Number.isFinite(declared) && declared > MAX_RESPONSE_BYTES) {
|
|
12931
|
+
if (Number.isFinite(declared) && declared > MAX_RESPONSE_BYTES$1) {
|
|
12932
12932
|
await res.body?.cancel().catch(() => {});
|
|
12933
12933
|
throw new KustoError(`Kusto response declared ${declared} bytes, over the 8 MiB client cap. Narrow the query.`, { retriable: false });
|
|
12934
12934
|
}
|
|
12935
12935
|
const text = await res.text();
|
|
12936
12936
|
const bytes = Buffer.byteLength(text, "utf8");
|
|
12937
|
-
if (bytes > MAX_RESPONSE_BYTES) throw new KustoError(`Kusto response exceeded the 8 MiB client cap (${bytes} bytes). Narrow the query.`, { retriable: false });
|
|
12937
|
+
if (bytes > MAX_RESPONSE_BYTES$1) throw new KustoError(`Kusto response exceeded the 8 MiB client cap (${bytes} bytes). Narrow the query.`, { retriable: false });
|
|
12938
12938
|
return text;
|
|
12939
12939
|
}
|
|
12940
12940
|
/**
|
|
@@ -13044,7 +13044,7 @@ var KustoClient = class {
|
|
|
13044
13044
|
}
|
|
13045
13045
|
if (!(err instanceof KustoError ? err.retriable : true) || attempt >= this.retryDelaysMs.length) throw err;
|
|
13046
13046
|
const hint = err instanceof KustoError ? err.retryAfterMs : void 0;
|
|
13047
|
-
await sleep$
|
|
13047
|
+
await sleep$4(hint ?? this.retryDelaysMs[attempt], signal);
|
|
13048
13048
|
}
|
|
13049
13049
|
}
|
|
13050
13050
|
/**
|
|
@@ -13058,7 +13058,7 @@ var KustoClient = class {
|
|
|
13058
13058
|
const onAbort = () => controller.abort(signal?.reason ?? /* @__PURE__ */ new Error("aborted"));
|
|
13059
13059
|
if (signal?.aborted) onAbort();
|
|
13060
13060
|
else signal?.addEventListener("abort", onAbort, { once: true });
|
|
13061
|
-
const timer = setTimeout(() => controller.abort(/* @__PURE__ */ new Error("Kusto request timed out")), REQUEST_TIMEOUT_MS);
|
|
13061
|
+
const timer = setTimeout(() => controller.abort(/* @__PURE__ */ new Error("Kusto request timed out")), REQUEST_TIMEOUT_MS$1);
|
|
13062
13062
|
timer.unref?.();
|
|
13063
13063
|
let res;
|
|
13064
13064
|
try {
|
|
@@ -13085,7 +13085,7 @@ var KustoClient = class {
|
|
|
13085
13085
|
status: 401
|
|
13086
13086
|
});
|
|
13087
13087
|
}
|
|
13088
|
-
if (res.status === 403) throw new KustoError(`Kusto refused the request (HTTP 403): ${kustoErrorDetail(await readBoundedBody(res))} The token was accepted; this is an access-permission verdict for the cluster or database.`, {
|
|
13088
|
+
if (res.status === 403) throw new KustoError(`Kusto refused the request (HTTP 403): ${kustoErrorDetail(await readBoundedBody$1(res))} The token was accepted; this is an access-permission verdict for the cluster or database.`, {
|
|
13089
13089
|
retriable: false,
|
|
13090
13090
|
status: 403
|
|
13091
13091
|
});
|
|
@@ -13101,7 +13101,7 @@ var KustoClient = class {
|
|
|
13101
13101
|
status: res.status,
|
|
13102
13102
|
...retryAfter === void 0 ? {} : { retryAfterMs: retryAfter }
|
|
13103
13103
|
});
|
|
13104
|
-
const text = await readBoundedBody(res);
|
|
13104
|
+
const text = await readBoundedBody$1(res);
|
|
13105
13105
|
if (!res.ok) throw new KustoError(`Kusto responded with HTTP ${res.status}: ${kustoErrorDetail(text)}`, {
|
|
13106
13106
|
retriable: false,
|
|
13107
13107
|
status: res.status
|
|
@@ -13455,7 +13455,7 @@ const KUSTO_GROUP = "kusto";
|
|
|
13455
13455
|
* hundred bytes while inviting a false reading that the per-cluster footprint
|
|
13456
13456
|
* is bounded. See the docs' note on a per-session distinct-cluster budget.
|
|
13457
13457
|
*/
|
|
13458
|
-
const clients = /* @__PURE__ */ new Map();
|
|
13458
|
+
const clients$1 = /* @__PURE__ */ new Map();
|
|
13459
13459
|
/**
|
|
13460
13460
|
* The cluster a call runs against: the call's own `cluster` first, else the
|
|
13461
13461
|
* launch's `--kusto-cluster`. Resolved synchronously, before a handler awaits
|
|
@@ -13472,13 +13472,13 @@ function resolveCluster(args) {
|
|
|
13472
13472
|
return normalizeKustoClusterUri(launch);
|
|
13473
13473
|
}
|
|
13474
13474
|
function kustoClient(clusterUri) {
|
|
13475
|
-
const existing = clients.get(clusterUri);
|
|
13475
|
+
const existing = clients$1.get(clusterUri);
|
|
13476
13476
|
if (existing) return existing;
|
|
13477
13477
|
const client = new KustoClient({
|
|
13478
13478
|
clusterUri,
|
|
13479
13479
|
...state.kustoDatabase ? { database: state.kustoDatabase } : {}
|
|
13480
13480
|
});
|
|
13481
|
-
clients.set(clusterUri, client);
|
|
13481
|
+
clients$1.set(clusterUri, client);
|
|
13482
13482
|
return client;
|
|
13483
13483
|
}
|
|
13484
13484
|
/**
|
|
@@ -13492,7 +13492,7 @@ function kustoClient(clusterUri) {
|
|
|
13492
13492
|
* client because the client's own cap bounds RENDERING work, and its trailer
|
|
13493
13493
|
* says so, while this one bounds what the model is asked to read.
|
|
13494
13494
|
*/
|
|
13495
|
-
async function text(value) {
|
|
13495
|
+
async function text$1(value) {
|
|
13496
13496
|
return { content: [{
|
|
13497
13497
|
type: "text",
|
|
13498
13498
|
text: await relaySafeText(value)
|
|
@@ -13532,7 +13532,7 @@ const KUSTO_TOOLS = Object.freeze([
|
|
|
13532
13532
|
properties: { ...CLUSTER_PROPERTY }
|
|
13533
13533
|
},
|
|
13534
13534
|
async handler(args, signal) {
|
|
13535
|
-
return text(await kustoClient(resolveCluster(args)).databasesList(signal));
|
|
13535
|
+
return text$1(await kustoClient(resolveCluster(args)).databasesList(signal));
|
|
13536
13536
|
}
|
|
13537
13537
|
},
|
|
13538
13538
|
{
|
|
@@ -13551,7 +13551,7 @@ const KUSTO_TOOLS = Object.freeze([
|
|
|
13551
13551
|
async handler(args, signal) {
|
|
13552
13552
|
const cluster = resolveCluster(args);
|
|
13553
13553
|
const { database } = databaseArg(args);
|
|
13554
|
-
return text(await kustoClient(cluster).tablesList(database, signal));
|
|
13554
|
+
return text$1(await kustoClient(cluster).tablesList(database, signal));
|
|
13555
13555
|
}
|
|
13556
13556
|
},
|
|
13557
13557
|
{
|
|
@@ -13575,7 +13575,7 @@ const KUSTO_TOOLS = Object.freeze([
|
|
|
13575
13575
|
async handler(args, signal) {
|
|
13576
13576
|
const cluster = resolveCluster(args);
|
|
13577
13577
|
const { database } = databaseArg(args);
|
|
13578
|
-
return text(await kustoClient(cluster).tableSchema(String(args.table ?? ""), database, signal));
|
|
13578
|
+
return text$1(await kustoClient(cluster).tableSchema(String(args.table ?? ""), database, signal));
|
|
13579
13579
|
}
|
|
13580
13580
|
},
|
|
13581
13581
|
{
|
|
@@ -13604,7 +13604,7 @@ const KUSTO_TOOLS = Object.freeze([
|
|
|
13604
13604
|
const cluster = resolveCluster(args);
|
|
13605
13605
|
const { database } = databaseArg(args);
|
|
13606
13606
|
const rows = typeof args.rows === "number" ? args.rows : 10;
|
|
13607
|
-
return text(await kustoClient(cluster).sample(String(args.table ?? ""), rows, database, signal));
|
|
13607
|
+
return text$1(await kustoClient(cluster).sample(String(args.table ?? ""), rows, database, signal));
|
|
13608
13608
|
}
|
|
13609
13609
|
},
|
|
13610
13610
|
{
|
|
@@ -13630,7 +13630,7 @@ const KUSTO_TOOLS = Object.freeze([
|
|
|
13630
13630
|
const { database } = databaseArg(args);
|
|
13631
13631
|
const csl = typeof args.csl === "string" ? args.csl : "";
|
|
13632
13632
|
if (!csl.trim()) throw new KustoError("`csl` must be a non-empty KQL query.", { retriable: false });
|
|
13633
|
-
return text(renderKustoResponse(await kustoClient(cluster).runCsl(csl, {
|
|
13633
|
+
return text$1(renderKustoResponse(await kustoClient(cluster).runCsl(csl, {
|
|
13634
13634
|
...database ? { database } : {},
|
|
13635
13635
|
...signal ? { signal } : {}
|
|
13636
13636
|
})));
|
|
@@ -13638,6 +13638,2687 @@ const KUSTO_TOOLS = Object.freeze([
|
|
|
13638
13638
|
}
|
|
13639
13639
|
]);
|
|
13640
13640
|
//#endregion
|
|
13641
|
+
//#region src/lib/cloudagent-client.ts
|
|
13642
|
+
/**
|
|
13643
|
+
* Cloud Agent Job API v2 client.
|
|
13644
|
+
*
|
|
13645
|
+
* Cloud Agent is Microsoft's internal service that runs an agent session against an
|
|
13646
|
+
* Azure DevOps repository. A v2 job is described by a prompt and an optional
|
|
13647
|
+
* custom agent, so it covers non-PR work (open work items, review a branch,
|
|
13648
|
+
* answer a question) that the v1 PR-centric endpoint could not express.
|
|
13649
|
+
*
|
|
13650
|
+
* **The origin is fixed per environment and is deliberately NOT configurable.**
|
|
13651
|
+
* The bearer token's audience is the environment's own Entra resource, so a
|
|
13652
|
+
* caller-supplied base URL would hand the token to an arbitrary host. That is
|
|
13653
|
+
* the same reasoning that makes a per-call Kusto cluster require a shape check:
|
|
13654
|
+
* here the set is small and known, so it is a two-value enum instead of a check.
|
|
13655
|
+
* `GH_ROUTER_CLOUDAGENT_TOKEN` overrides the TOKEN (for tests and manual runs), not
|
|
13656
|
+
* the destination.
|
|
13657
|
+
*
|
|
13658
|
+
* **Auth** is `az account get-access-token --resource <app-id-uri>` through the
|
|
13659
|
+
* shared `AzCliAccessTokenCache`, so a stale token is re-minted on a 401 and
|
|
13660
|
+
* concurrent calls share one `az` process. The CLI appends `/.default` itself;
|
|
13661
|
+
* passing the literal scope form to `--resource` is not the documented shape.
|
|
13662
|
+
* The token is held in memory only: unlike the GitHub credential there is no
|
|
13663
|
+
* token file, and nothing here writes one. Interactive login is disabled — the
|
|
13664
|
+
* group can be enabled by repository discovery, and a device-code prompt raised
|
|
13665
|
+
* inside a spawned `claude` session is invisible to the user and reads as a
|
|
13666
|
+
* hang, so a missing session fails fast with `az login` advice instead.
|
|
13667
|
+
*
|
|
13668
|
+
* **Retry policy is per endpoint, because only some calls are safe to repeat.**
|
|
13669
|
+
* Reads, `POST /v2/jobs/validate` (creates nothing) and cancellation (the
|
|
13670
|
+
* service documents a repeated cancel as safe) retry on 429/5xx. `POST /v2/jobs`
|
|
13671
|
+
* does NOT: a 5xx there may arrive after the job was created, so an automatic
|
|
13672
|
+
* resend could bill and run the same work twice. A 401 on any endpoint still
|
|
13673
|
+
* gets the one re-mint retry, because a rejected request had no effect.
|
|
13674
|
+
*/
|
|
13675
|
+
/** Token override for tests and manual runs. Never logged. */
|
|
13676
|
+
const CLOUDAGENT_TOKEN_ENV = "GH_ROUTER_CLOUDAGENT_TOKEN";
|
|
13677
|
+
/**
|
|
13678
|
+
* Base URL plus the Entra resource (App ID URI) whose `/.default` scope the
|
|
13679
|
+
* token is minted for. The docs list bare client-ID `aud` values as accepted
|
|
13680
|
+
* legacy alternates; the App ID URI is the form `az --resource` takes.
|
|
13681
|
+
*/
|
|
13682
|
+
const ENVIRONMENT_ENDPOINTS = {
|
|
13683
|
+
prod: {
|
|
13684
|
+
baseUrl: "https://copilotswe.app.prod.gitops.startclean.microsoft.com/api/agency",
|
|
13685
|
+
resource: "api://81bbac67-d541-4a6d-a48b-b1c0f9a57888"
|
|
13686
|
+
},
|
|
13687
|
+
ppe: {
|
|
13688
|
+
baseUrl: "https://copilotswe.app.ppe.gitops.startclean.microsoft.com/api/agency",
|
|
13689
|
+
resource: "api://99d8628b-dd58-4123-b33c-7e82ddf37571"
|
|
13690
|
+
}
|
|
13691
|
+
};
|
|
13692
|
+
/** Normalize a launch value. Throws on anything but the two known names. */
|
|
13693
|
+
function normalizeCloudAgentEnvironment(value) {
|
|
13694
|
+
const raw = value.trim().toLowerCase();
|
|
13695
|
+
if (raw === "prod" || raw === "production") return "prod";
|
|
13696
|
+
if (raw === "ppe") return "ppe";
|
|
13697
|
+
throw new CloudAgentError(`Unknown Cloud Agent environment "${value}". Use "prod" or "ppe".`, { retriable: false });
|
|
13698
|
+
}
|
|
13699
|
+
var CloudAgentError = class extends Error {
|
|
13700
|
+
retriable;
|
|
13701
|
+
status;
|
|
13702
|
+
retryAfterMs;
|
|
13703
|
+
constructor(message, opts = {}) {
|
|
13704
|
+
super(sanitizeRemoteDetail(message));
|
|
13705
|
+
this.name = "CloudAgentError";
|
|
13706
|
+
this.retriable = opts.retriable ?? false;
|
|
13707
|
+
if (opts.status !== void 0) this.status = opts.status;
|
|
13708
|
+
if (opts.retryAfterMs !== void 0) this.retryAfterMs = opts.retryAfterMs;
|
|
13709
|
+
}
|
|
13710
|
+
};
|
|
13711
|
+
/**
|
|
13712
|
+
* Wire-shape byte caps. The default bounds a job or catalog response; logs get
|
|
13713
|
+
* a larger one because a transcript with tool diffs is legitimately megabytes
|
|
13714
|
+
* and refusing it would leave the model with nothing. Both are byte budgets, so
|
|
13715
|
+
* both are measured with `Buffer.byteLength` rather than `text.length`.
|
|
13716
|
+
*/
|
|
13717
|
+
const MAX_RESPONSE_BYTES = 8388608;
|
|
13718
|
+
const MAX_LOGS_BYTES = 33554432;
|
|
13719
|
+
const REQUEST_TIMEOUT_MS = 6e4;
|
|
13720
|
+
/**
|
|
13721
|
+
* Backoff for a retriable verdict on an endpoint whose retry is safe. Mirrors
|
|
13722
|
+
* the shared remote-MCP transport and the Kusto client: 1/2/4 s, with a
|
|
13723
|
+
* service `Retry-After` winning when present.
|
|
13724
|
+
*/
|
|
13725
|
+
const CLOUDAGENT_RETRY_DELAYS_MS = [
|
|
13726
|
+
1e3,
|
|
13727
|
+
2e3,
|
|
13728
|
+
4e3
|
|
13729
|
+
];
|
|
13730
|
+
/**
|
|
13731
|
+
* Read a response body under `cap`, in BYTES. A declared `content-length` that
|
|
13732
|
+
* already exceeds the cap is refused before buffering; a chunked or header-less
|
|
13733
|
+
* response falls back to the post-read byte count, which is the only signal
|
|
13734
|
+
* left. The socket is released either way so a refused body is not drained.
|
|
13735
|
+
*/
|
|
13736
|
+
async function readBoundedBody(res, cap, what) {
|
|
13737
|
+
const declaredHeader = res.headers.get("content-length");
|
|
13738
|
+
const declared = declaredHeader ? Number(declaredHeader) : NaN;
|
|
13739
|
+
if (Number.isFinite(declared) && declared > cap) {
|
|
13740
|
+
await res.body?.cancel().catch(() => {});
|
|
13741
|
+
throw new CloudAgentError(`Cloud Agent ${what} declared ${declared} bytes, over the ${Math.floor(cap / 1048576)} MiB client cap.`, { retriable: false });
|
|
13742
|
+
}
|
|
13743
|
+
const text = await res.text();
|
|
13744
|
+
const bytes = Buffer.byteLength(text, "utf8");
|
|
13745
|
+
if (bytes > cap) throw new CloudAgentError(`Cloud Agent ${what} exceeded the ${Math.floor(cap / 1048576)} MiB client cap (${bytes} bytes).`, { retriable: false });
|
|
13746
|
+
return text;
|
|
13747
|
+
}
|
|
13748
|
+
/**
|
|
13749
|
+
* Assemble the v2 wire body.
|
|
13750
|
+
*
|
|
13751
|
+
* The one rule the service enforces itself: `prompt` may be omitted when a
|
|
13752
|
+
* custom agent is supplied, and the request is rejected when BOTH are absent.
|
|
13753
|
+
* Checking it here turns a network round trip into an immediate, actionable
|
|
13754
|
+
* message — and because `validate_job` shares this builder, a caller learns the
|
|
13755
|
+
* same thing without creating anything.
|
|
13756
|
+
*/
|
|
13757
|
+
function buildGenericJobRequest(input) {
|
|
13758
|
+
const prompt = input.prompt?.trim() ?? "";
|
|
13759
|
+
if (!prompt && !input.customAgent) throw new CloudAgentError("A job needs either `prompt` or `agent`. Supply `prompt` to describe the work, or `agent` to run a custom agent (whose own instructions then drive the job).", { retriable: false });
|
|
13760
|
+
const branch = input.repository.branch?.trim();
|
|
13761
|
+
const request = { context: { repository: {
|
|
13762
|
+
$type: "ado",
|
|
13763
|
+
organization: input.repository.organization.trim(),
|
|
13764
|
+
project: input.repository.project.trim(),
|
|
13765
|
+
repository: input.repository.repository.trim(),
|
|
13766
|
+
...branch ? { branch } : {}
|
|
13767
|
+
} } };
|
|
13768
|
+
if (prompt) request.prompt = prompt;
|
|
13769
|
+
if (input.customAgent) {
|
|
13770
|
+
const agent = { name: input.customAgent.name.trim() };
|
|
13771
|
+
if (input.customAgent.type) agent.type = input.customAgent.type;
|
|
13772
|
+
if (input.customAgent.pluginName?.trim()) agent.pluginName = input.customAgent.pluginName.trim();
|
|
13773
|
+
if (input.customAgent.inputs && Object.keys(input.customAgent.inputs).length > 0) agent.inputs = input.customAgent.inputs;
|
|
13774
|
+
request.customAgent = agent;
|
|
13775
|
+
}
|
|
13776
|
+
if (input.plugins && input.plugins.length > 0) request.plugins = input.plugins.map((plugin) => ({
|
|
13777
|
+
name: plugin.name.trim(),
|
|
13778
|
+
...plugin.type ? { type: plugin.type } : {}
|
|
13779
|
+
}));
|
|
13780
|
+
if (input.includeDefaultPlugins === true) request.additionalOptions = { pluginOptions: { includeDefaults: true } };
|
|
13781
|
+
const model = input.modelConfiguration?.model?.trim();
|
|
13782
|
+
const effort = input.modelConfiguration?.reasoningEffort?.trim();
|
|
13783
|
+
const contextTier = input.modelConfiguration?.context;
|
|
13784
|
+
if (model || effort || contextTier) request.modelConfiguration = {
|
|
13785
|
+
...model ? { model } : {},
|
|
13786
|
+
...effort ? { reasoningEffort: effort } : {},
|
|
13787
|
+
...contextTier ? { context: contextTier } : {}
|
|
13788
|
+
};
|
|
13789
|
+
const metadata = normalizeJobMetadata(input.metadata);
|
|
13790
|
+
if (metadata) request.metadata = metadata;
|
|
13791
|
+
return request;
|
|
13792
|
+
}
|
|
13793
|
+
/**
|
|
13794
|
+
* Bound the label map a caller can attach to a job.
|
|
13795
|
+
*
|
|
13796
|
+
* The labels are how a caller finds its own jobs again (a `list_jobs` row
|
|
13797
|
+
* prints them), so they are deliberately free-form. They are also the one
|
|
13798
|
+
* request field whose size a model controls without limit, and a job record is
|
|
13799
|
+
* stored and echoed on every later read, so a whole report pasted into a label
|
|
13800
|
+
* would be paid for on every poll. Rejecting is the honest bound: truncating a
|
|
13801
|
+
* label would change the value the caller later searches for.
|
|
13802
|
+
*/
|
|
13803
|
+
const MAX_METADATA_ENTRIES = 32;
|
|
13804
|
+
const MAX_METADATA_KEY_CHARS = 128;
|
|
13805
|
+
const MAX_METADATA_VALUE_CHARS = 256;
|
|
13806
|
+
function normalizeJobMetadata(metadata) {
|
|
13807
|
+
if (!metadata) return void 0;
|
|
13808
|
+
const entries = Object.entries(metadata);
|
|
13809
|
+
if (entries.length === 0) return void 0;
|
|
13810
|
+
if (entries.length > MAX_METADATA_ENTRIES) throw new CloudAgentError(`\`metadata\` has ${entries.length} entries; at most ${MAX_METADATA_ENTRIES} are allowed. These are short labels (chain, step, issue), not a place to store content.`, { retriable: false });
|
|
13811
|
+
const normalized = {};
|
|
13812
|
+
for (const [rawKey, rawValue] of entries) {
|
|
13813
|
+
const key = rawKey.trim();
|
|
13814
|
+
const value = typeof rawValue === "string" ? rawValue.trim() : String(rawValue ?? "");
|
|
13815
|
+
if (!key) throw new CloudAgentError("`metadata` keys must be non-empty strings.", { retriable: false });
|
|
13816
|
+
if (key.length > MAX_METADATA_KEY_CHARS || value.length > MAX_METADATA_VALUE_CHARS) throw new CloudAgentError(`\`metadata\` entry "${key.slice(0, 40)}" is too long: keys are limited to ${MAX_METADATA_KEY_CHARS} characters and values to ${MAX_METADATA_VALUE_CHARS}. These are short labels, not a place to store content.`, { retriable: false });
|
|
13817
|
+
normalized[key] = value;
|
|
13818
|
+
}
|
|
13819
|
+
return normalized;
|
|
13820
|
+
}
|
|
13821
|
+
function isRecord$1(value) {
|
|
13822
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13823
|
+
}
|
|
13824
|
+
function stringField(record, key) {
|
|
13825
|
+
const value = record[key];
|
|
13826
|
+
return typeof value === "string" && value.trim() ? value : void 0;
|
|
13827
|
+
}
|
|
13828
|
+
function numberField(record, key) {
|
|
13829
|
+
const value = record[key];
|
|
13830
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
13831
|
+
}
|
|
13832
|
+
function booleanField(record, key) {
|
|
13833
|
+
const value = record[key];
|
|
13834
|
+
return typeof value === "boolean" ? value : void 0;
|
|
13835
|
+
}
|
|
13836
|
+
/**
|
|
13837
|
+
* A timestamp, with Go's zero time treated as absent.
|
|
13838
|
+
*
|
|
13839
|
+
* A validated-but-never-created job reports `createdAt: "0001-01-01T00:00:00"`
|
|
13840
|
+
* and so do some logs envelopes (measured). Rendering that as a creation time
|
|
13841
|
+
* would state something false, so it is dropped instead.
|
|
13842
|
+
*/
|
|
13843
|
+
function timestampField(record, key) {
|
|
13844
|
+
const value = stringField(record, key);
|
|
13845
|
+
if (!value) return void 0;
|
|
13846
|
+
if (value.startsWith("0001-01-01")) return void 0;
|
|
13847
|
+
return value;
|
|
13848
|
+
}
|
|
13849
|
+
/** A `Dictionary<string,string>`, honouring only string values. */
|
|
13850
|
+
function stringMap(value) {
|
|
13851
|
+
if (!isRecord$1(value)) return void 0;
|
|
13852
|
+
const map = {};
|
|
13853
|
+
for (const [key, entry] of Object.entries(value)) if (typeof entry === "string") map[key] = entry;
|
|
13854
|
+
return Object.keys(map).length > 0 ? map : void 0;
|
|
13855
|
+
}
|
|
13856
|
+
function numberArray(value) {
|
|
13857
|
+
if (!Array.isArray(value)) return void 0;
|
|
13858
|
+
const numbers = value.filter((entry) => typeof entry === "number" && Number.isFinite(entry));
|
|
13859
|
+
return numbers.length > 0 ? numbers : void 0;
|
|
13860
|
+
}
|
|
13861
|
+
function stringArray(value) {
|
|
13862
|
+
if (!Array.isArray(value)) return void 0;
|
|
13863
|
+
const strings = value.filter((entry) => typeof entry === "string" && entry.trim().length > 0);
|
|
13864
|
+
return strings.length > 0 ? strings : void 0;
|
|
13865
|
+
}
|
|
13866
|
+
function usageFrom(value) {
|
|
13867
|
+
if (value === null) return null;
|
|
13868
|
+
if (!isRecord$1(value)) return void 0;
|
|
13869
|
+
const usage = {};
|
|
13870
|
+
const input = numberField(value, "inputTokens");
|
|
13871
|
+
const output = numberField(value, "outputTokens");
|
|
13872
|
+
const cacheRead = numberField(value, "cacheReadTokens");
|
|
13873
|
+
const cacheWrite = numberField(value, "cacheWriteTokens");
|
|
13874
|
+
if (input !== void 0) usage.inputTokens = input;
|
|
13875
|
+
if (output !== void 0) usage.outputTokens = output;
|
|
13876
|
+
if (cacheRead !== void 0) usage.cacheReadTokens = cacheRead;
|
|
13877
|
+
if (cacheWrite !== void 0) usage.cacheWriteTokens = cacheWrite;
|
|
13878
|
+
return usage;
|
|
13879
|
+
}
|
|
13880
|
+
/** Read one job from either shape: `context.repository` (v2) or `azDoContext`. */
|
|
13881
|
+
function readJob(value) {
|
|
13882
|
+
if (!isRecord$1(value)) throw new CloudAgentError("Cloud Agent returned a job that was not an object.", { retriable: true });
|
|
13883
|
+
const jobId = stringField(value, "jobId") ?? stringField(value, "id");
|
|
13884
|
+
if (!jobId) throw new CloudAgentError("Cloud Agent returned a job without a jobId.", { retriable: true });
|
|
13885
|
+
const job = { jobId };
|
|
13886
|
+
const operationId = stringField(value, "operationId");
|
|
13887
|
+
if (operationId) job.operationId = operationId;
|
|
13888
|
+
const state = stringField(value, "state");
|
|
13889
|
+
if (state) job.state = state;
|
|
13890
|
+
const result = stringField(value, "result");
|
|
13891
|
+
if (result) job.result = result;
|
|
13892
|
+
const reason = stringField(value, "reason");
|
|
13893
|
+
if (reason) job.reason = reason;
|
|
13894
|
+
const createdAt = timestampField(value, "createdAt");
|
|
13895
|
+
if (createdAt) job.createdAt = createdAt;
|
|
13896
|
+
const updatedAt = timestampField(value, "updatedAt");
|
|
13897
|
+
if (updatedAt) job.updatedAt = updatedAt;
|
|
13898
|
+
const prompt = stringField(value, "prompt");
|
|
13899
|
+
if (prompt) job.prompt = prompt;
|
|
13900
|
+
const jobOutcomeType = stringField(value, "jobOutcomeType");
|
|
13901
|
+
if (jobOutcomeType) job.jobOutcomeType = jobOutcomeType;
|
|
13902
|
+
const retryable = booleanField(value, "isRetryable");
|
|
13903
|
+
if (retryable !== void 0) job.isRetryable = retryable;
|
|
13904
|
+
const modelName = stringField(value, "modelName");
|
|
13905
|
+
if (modelName) job.modelName = modelName;
|
|
13906
|
+
const agentPlatform = stringField(value, "agentPlatform");
|
|
13907
|
+
if (agentPlatform) job.agentPlatform = agentPlatform;
|
|
13908
|
+
const source = stringField(value, "source");
|
|
13909
|
+
if (source) job.source = source;
|
|
13910
|
+
const metadata = stringMap(value.metadata);
|
|
13911
|
+
if (metadata) job.metadata = metadata;
|
|
13912
|
+
const commitMetadata = stringMap(value.commitMetadata);
|
|
13913
|
+
if (commitMetadata) job.commitMetadata = commitMetadata;
|
|
13914
|
+
const initiating = value.initiatingUser;
|
|
13915
|
+
if (isRecord$1(initiating)) {
|
|
13916
|
+
const name = stringField(initiating, "name") ?? stringField(initiating, "email");
|
|
13917
|
+
if (name) job.initiatingUserName = name;
|
|
13918
|
+
}
|
|
13919
|
+
const scheduling = value.scheduling;
|
|
13920
|
+
if (isRecord$1(scheduling)) {
|
|
13921
|
+
const dispatchAfter = timestampField(scheduling, "dispatchAfter");
|
|
13922
|
+
if (dispatchAfter) job.dispatchAfter = dispatchAfter;
|
|
13923
|
+
}
|
|
13924
|
+
const rawPlugins = value.plugins;
|
|
13925
|
+
if (Array.isArray(rawPlugins)) {
|
|
13926
|
+
const names = rawPlugins.map((entry) => typeof entry === "string" ? entry : isRecord$1(entry) ? stringField(entry, "name") : void 0).filter((entry) => typeof entry === "string" && entry.trim().length > 0);
|
|
13927
|
+
if (names.length > 0) job.plugins = names;
|
|
13928
|
+
}
|
|
13929
|
+
for (const key of ["pipelineRun", "compute"]) {
|
|
13930
|
+
const entry = value[key];
|
|
13931
|
+
if (!isRecord$1(entry)) continue;
|
|
13932
|
+
const run = {};
|
|
13933
|
+
const definitionId = numberField(entry, "definitionId");
|
|
13934
|
+
const runId = numberField(entry, "runId");
|
|
13935
|
+
if (definitionId !== void 0 && definitionId >= 0) run.definitionId = definitionId;
|
|
13936
|
+
if (runId !== void 0 && runId >= 0) run.runId = runId;
|
|
13937
|
+
if (run.definitionId !== void 0 || run.runId !== void 0) {
|
|
13938
|
+
job.pipelineRun = run;
|
|
13939
|
+
break;
|
|
13940
|
+
}
|
|
13941
|
+
}
|
|
13942
|
+
const outcome = value.outcome;
|
|
13943
|
+
if (isRecord$1(outcome)) {
|
|
13944
|
+
const code = stringField(outcome, "code");
|
|
13945
|
+
if (code) job.outcomeCode = code;
|
|
13946
|
+
const description = stringField(outcome, "description");
|
|
13947
|
+
if (description) job.outcomeDescription = description;
|
|
13948
|
+
}
|
|
13949
|
+
const requester = value.requester;
|
|
13950
|
+
if (isRecord$1(requester)) {
|
|
13951
|
+
const name = stringField(requester, "name");
|
|
13952
|
+
if (name) job.requesterName = name;
|
|
13953
|
+
}
|
|
13954
|
+
const context = value.context;
|
|
13955
|
+
if (isRecord$1(context) && isRecord$1(context.repository)) {
|
|
13956
|
+
const repository = context.repository;
|
|
13957
|
+
const organization = stringField(repository, "organization");
|
|
13958
|
+
const project = stringField(repository, "project");
|
|
13959
|
+
const name = stringField(repository, "repository");
|
|
13960
|
+
if (organization && project && name) job.repository = `${organization}/${project}/${name}`;
|
|
13961
|
+
const branch = stringField(repository, "branch");
|
|
13962
|
+
if (branch) job.sourceBranch = branch;
|
|
13963
|
+
}
|
|
13964
|
+
const azDo = value.azDoContext;
|
|
13965
|
+
if (isRecord$1(azDo)) {
|
|
13966
|
+
const organization = stringField(azDo, "organization");
|
|
13967
|
+
const project = stringField(azDo, "projectName");
|
|
13968
|
+
const name = stringField(azDo, "repositoryName");
|
|
13969
|
+
if (organization && project && name) job.repository = `${organization}/${project}/${name}`;
|
|
13970
|
+
const pullRequestId = numberField(azDo, "pullRequestId");
|
|
13971
|
+
if (pullRequestId !== void 0) job.pullRequestId = pullRequestId;
|
|
13972
|
+
const source = stringField(azDo, "sourceBranchName");
|
|
13973
|
+
if (source) job.sourceBranch = source;
|
|
13974
|
+
const target = stringField(azDo, "targetBranchName");
|
|
13975
|
+
if (target) job.targetBranch = target;
|
|
13976
|
+
const workItemIds = numberArray(azDo.workItemIds);
|
|
13977
|
+
if (workItemIds) job.workItemIds = workItemIds;
|
|
13978
|
+
const tags = stringArray(azDo.pullRequestTags);
|
|
13979
|
+
if (tags) job.pullRequestTags = tags;
|
|
13980
|
+
}
|
|
13981
|
+
const metrics = value.sessionMetrics;
|
|
13982
|
+
if (isRecord$1(metrics)) {
|
|
13983
|
+
const currentModel = stringField(metrics, "currentModel");
|
|
13984
|
+
if (currentModel) job.currentModel = currentModel;
|
|
13985
|
+
const modelMetrics = metrics.modelMetrics;
|
|
13986
|
+
if (isRecord$1(modelMetrics)) {
|
|
13987
|
+
const usage = {};
|
|
13988
|
+
for (const [model, entry] of Object.entries(modelMetrics)) {
|
|
13989
|
+
const parsed = usageFrom(entry);
|
|
13990
|
+
if (parsed !== void 0) usage[model] = parsed;
|
|
13991
|
+
}
|
|
13992
|
+
if (Object.keys(usage).length > 0) job.modelUsage = usage;
|
|
13993
|
+
}
|
|
13994
|
+
}
|
|
13995
|
+
return job;
|
|
13996
|
+
}
|
|
13997
|
+
function readJobPage(value) {
|
|
13998
|
+
if (!isRecord$1(value)) throw new CloudAgentError("Cloud Agent returned a job list that was not an object.", { retriable: true });
|
|
13999
|
+
const rawData = value.data;
|
|
14000
|
+
if (!Array.isArray(rawData)) throw new CloudAgentError("Cloud Agent returned a job list without a `data` array.", { retriable: true });
|
|
14001
|
+
const page = {
|
|
14002
|
+
data: rawData.map((entry) => readJob(entry)),
|
|
14003
|
+
hasMore: value.hasMore === true
|
|
14004
|
+
};
|
|
14005
|
+
const token = stringField(value, "continuationToken");
|
|
14006
|
+
if (token) page.continuationToken = token;
|
|
14007
|
+
return page;
|
|
14008
|
+
}
|
|
14009
|
+
function readAgentPage(value) {
|
|
14010
|
+
return readCatalogPage(value, "agents", readAgent);
|
|
14011
|
+
}
|
|
14012
|
+
function readPluginPage(value) {
|
|
14013
|
+
return readCatalogPage(value, "plugins", readPlugin);
|
|
14014
|
+
}
|
|
14015
|
+
/**
|
|
14016
|
+
* `GET /models` answers `{ "models": [...] }` (measured live 2026-10-31), not
|
|
14017
|
+
* the `value`/`totalCount` page shape the plugin and agent catalogs use, and
|
|
14018
|
+
* it takes no filters: the service ignores repository and organization here.
|
|
14019
|
+
*/
|
|
14020
|
+
function readModelList(value) {
|
|
14021
|
+
if (!isRecord$1(value)) throw new CloudAgentError("Cloud Agent returned a model list that was not an object.", { retriable: true });
|
|
14022
|
+
const raw = value.models;
|
|
14023
|
+
if (!Array.isArray(raw)) throw new CloudAgentError("Cloud Agent returned a model list without a `models` array.", { retriable: true });
|
|
14024
|
+
return raw.filter(isRecord$1).map(readModel);
|
|
14025
|
+
}
|
|
14026
|
+
function readCatalogPage(value, what, readEntry) {
|
|
14027
|
+
if (!isRecord$1(value)) throw new CloudAgentError(`Cloud Agent returned a ${what} list that was not an object.`, { retriable: true });
|
|
14028
|
+
const raw = value.value;
|
|
14029
|
+
if (!Array.isArray(raw)) throw new CloudAgentError(`Cloud Agent returned a ${what} list without a \`value\` array.`, { retriable: true });
|
|
14030
|
+
const page = { value: raw.filter(isRecord$1).map(readEntry) };
|
|
14031
|
+
const totalCount = numberField(value, "totalCount");
|
|
14032
|
+
if (totalCount !== void 0) page.totalCount = totalCount;
|
|
14033
|
+
const top = numberField(value, "top");
|
|
14034
|
+
if (top !== void 0) page.top = top;
|
|
14035
|
+
const skip = numberField(value, "skip");
|
|
14036
|
+
if (skip !== void 0) page.skip = skip;
|
|
14037
|
+
const errors = value.errors;
|
|
14038
|
+
if (Array.isArray(errors)) {
|
|
14039
|
+
const messages = errors.filter((entry) => typeof entry === "string" && entry.trim().length > 0);
|
|
14040
|
+
if (messages.length > 0) page.errors = messages;
|
|
14041
|
+
}
|
|
14042
|
+
return page;
|
|
14043
|
+
}
|
|
14044
|
+
function readAgent(entry) {
|
|
14045
|
+
const agent = { name: stringField(entry, "name") ?? "?" };
|
|
14046
|
+
const type = stringField(entry, "type");
|
|
14047
|
+
if (type) agent.type = type;
|
|
14048
|
+
const engine = stringField(entry, "engine");
|
|
14049
|
+
if (engine) agent.engine = engine;
|
|
14050
|
+
const description = stringField(entry, "description");
|
|
14051
|
+
if (description) agent.description = description;
|
|
14052
|
+
const inputs = entry.inputs;
|
|
14053
|
+
if (isRecord$1(inputs)) {
|
|
14054
|
+
const declared = {};
|
|
14055
|
+
for (const [key, raw] of Object.entries(inputs)) {
|
|
14056
|
+
if (!isRecord$1(raw)) continue;
|
|
14057
|
+
declared[key] = {
|
|
14058
|
+
...stringField(raw, "type") ? { type: stringField(raw, "type") } : {},
|
|
14059
|
+
...booleanField(raw, "required") !== void 0 ? { required: booleanField(raw, "required") } : {},
|
|
14060
|
+
...stringField(raw, "description") ? { description: stringField(raw, "description") } : {}
|
|
14061
|
+
};
|
|
14062
|
+
}
|
|
14063
|
+
if (Object.keys(declared).length > 0) agent.inputs = declared;
|
|
14064
|
+
}
|
|
14065
|
+
return agent;
|
|
14066
|
+
}
|
|
14067
|
+
function readPlugin(entry) {
|
|
14068
|
+
const plugin = { name: stringField(entry, "name") ?? "?" };
|
|
14069
|
+
const type = stringField(entry, "type");
|
|
14070
|
+
if (type) plugin.type = type;
|
|
14071
|
+
const description = stringField(entry, "description");
|
|
14072
|
+
if (description) plugin.description = description;
|
|
14073
|
+
const enabled = booleanField(entry, "enabledByDefault");
|
|
14074
|
+
if (enabled !== void 0) plugin.enabledByDefault = enabled;
|
|
14075
|
+
return plugin;
|
|
14076
|
+
}
|
|
14077
|
+
function readModel(entry) {
|
|
14078
|
+
const model = { id: stringField(entry, "id") ?? "?" };
|
|
14079
|
+
const vendor = stringField(entry, "vendor");
|
|
14080
|
+
if (vendor) model.vendor = vendor;
|
|
14081
|
+
const preview = booleanField(entry, "preview");
|
|
14082
|
+
if (preview !== void 0) model.preview = preview;
|
|
14083
|
+
const capabilities = isRecord$1(entry.capabilities) ? entry.capabilities : void 0;
|
|
14084
|
+
const supports = capabilities && isRecord$1(capabilities.supports) ? capabilities.supports : void 0;
|
|
14085
|
+
const limits = capabilities && isRecord$1(capabilities.limits) ? capabilities.limits : void 0;
|
|
14086
|
+
const efforts = supports?.reasoningEffort;
|
|
14087
|
+
if (Array.isArray(efforts)) {
|
|
14088
|
+
const known = efforts.filter((effort) => typeof effort === "string" && effort.trim().length > 0);
|
|
14089
|
+
if (known.length > 0) model.reasoningEffort = known;
|
|
14090
|
+
}
|
|
14091
|
+
const context = limits ? numberField(limits, "maxContextWindowTokens") : void 0;
|
|
14092
|
+
if (context !== void 0) model.maxContextWindowTokens = context;
|
|
14093
|
+
const output = limits ? numberField(limits, "maxOutputTokens") : void 0;
|
|
14094
|
+
if (output !== void 0) model.maxOutputTokens = output;
|
|
14095
|
+
const billing = isRecord$1(entry.billing) ? entry.billing : void 0;
|
|
14096
|
+
const multiplier = billing ? numberField(billing, "multiplier") : void 0;
|
|
14097
|
+
if (multiplier !== void 0) model.billingMultiplier = multiplier;
|
|
14098
|
+
const info = entry.infoMessages;
|
|
14099
|
+
if (Array.isArray(info)) {
|
|
14100
|
+
const notices = info.map((message) => isRecord$1(message) ? stringField(message, "message") : void 0).filter((message) => message !== void 0);
|
|
14101
|
+
if (notices.length > 0) model.notices = notices;
|
|
14102
|
+
}
|
|
14103
|
+
return model;
|
|
14104
|
+
}
|
|
14105
|
+
/**
|
|
14106
|
+
* Parsing of `GET /jobs/{id}/logs`, whose shape is undocumented but was
|
|
14107
|
+
* measured against prod traces (233 KB–7.5 MB, 372–3991 messages):
|
|
14108
|
+
*
|
|
14109
|
+
* - `chatHistory` is a list of `{role: {label}, items: [...]}` where **every
|
|
14110
|
+
* message carries exactly one item**, so the item list is walked but never
|
|
14111
|
+
* assumed flat.
|
|
14112
|
+
* - Exactly three item types appear: `TextContent {text}`,
|
|
14113
|
+
* `FunctionCallContent {id, functionName, arguments}` and
|
|
14114
|
+
* `FunctionResultContent {callId, result}`. Calls and results are joined on
|
|
14115
|
+
* the call's `id` matching the result's `callId` — nothing else correlates
|
|
14116
|
+
* them, and a result of `null` is normal (measured on 6–21 rows per trace).
|
|
14117
|
+
* - `TextContent` is frequently EMPTY: 127 of 178 in one trace. Those carry no
|
|
14118
|
+
* information and are dropped, which is why `assistantTexts` is not
|
|
14119
|
+
* `messageCount`-shaped.
|
|
14120
|
+
* - `result` is `{content}` or `{content, detailedContent}`; `detailedContent`
|
|
14121
|
+
* is the same text with a status prefix, except on a few agent-run tools
|
|
14122
|
+
* where it is the only place a real diff appears. `toolDiffs` is `[]` on
|
|
14123
|
+
* every sampled job, so it is never read.
|
|
14124
|
+
* - The deliverable is `task_complete.arguments.summary` — NOT the last
|
|
14125
|
+
* assistant message, which is usually narration. A failed job has no
|
|
14126
|
+
* `task_complete` at all.
|
|
14127
|
+
*/
|
|
14128
|
+
function readJobLogs(value) {
|
|
14129
|
+
if (!isRecord$1(value)) throw new CloudAgentError("Cloud Agent returned job logs that were not an object.", { retriable: true });
|
|
14130
|
+
const logs = {
|
|
14131
|
+
messageCount: 0,
|
|
14132
|
+
assistantTexts: [],
|
|
14133
|
+
toolCalls: [],
|
|
14134
|
+
histogram: [],
|
|
14135
|
+
changedFiles: [],
|
|
14136
|
+
unrecognizedItems: 0
|
|
14137
|
+
};
|
|
14138
|
+
const id = stringField(value, "id");
|
|
14139
|
+
if (id) logs.id = id;
|
|
14140
|
+
const createdAt = timestampField(value, "createdAt");
|
|
14141
|
+
if (createdAt) logs.createdAt = createdAt;
|
|
14142
|
+
const updatedAt = timestampField(value, "updatedAt");
|
|
14143
|
+
if (updatedAt) logs.updatedAt = updatedAt;
|
|
14144
|
+
const history = Array.isArray(value.chatHistory) ? value.chatHistory : [];
|
|
14145
|
+
logs.messageCount = history.length;
|
|
14146
|
+
const callsById = /* @__PURE__ */ new Map();
|
|
14147
|
+
const results = /* @__PURE__ */ new Map();
|
|
14148
|
+
const seenFiles = /* @__PURE__ */ new Set();
|
|
14149
|
+
const changedFiles = [];
|
|
14150
|
+
const addFile = (raw) => {
|
|
14151
|
+
const path = normalizeTracePath(raw);
|
|
14152
|
+
if (!path || seenFiles.has(path)) return;
|
|
14153
|
+
seenFiles.add(path);
|
|
14154
|
+
changedFiles.push(path);
|
|
14155
|
+
};
|
|
14156
|
+
for (const message of history) {
|
|
14157
|
+
if (!isRecord$1(message)) {
|
|
14158
|
+
logs.unrecognizedItems++;
|
|
14159
|
+
continue;
|
|
14160
|
+
}
|
|
14161
|
+
const role = isRecord$1(message.role) ? stringField(message.role, "label") : void 0;
|
|
14162
|
+
const items = Array.isArray(message.items) ? message.items : [];
|
|
14163
|
+
if (items.length === 0) {
|
|
14164
|
+
logs.unrecognizedItems++;
|
|
14165
|
+
continue;
|
|
14166
|
+
}
|
|
14167
|
+
for (const item of items) {
|
|
14168
|
+
if (!isRecord$1(item)) {
|
|
14169
|
+
logs.unrecognizedItems++;
|
|
14170
|
+
continue;
|
|
14171
|
+
}
|
|
14172
|
+
const type = stringField(item, "$type");
|
|
14173
|
+
if (type === "TextContent") {
|
|
14174
|
+
const text = stringField(item, "text");
|
|
14175
|
+
if (text && role === "assistant") logs.assistantTexts.push(text);
|
|
14176
|
+
continue;
|
|
14177
|
+
}
|
|
14178
|
+
if (type === "FunctionCallContent") {
|
|
14179
|
+
const name = stringField(item, "functionName");
|
|
14180
|
+
if (!name) {
|
|
14181
|
+
logs.unrecognizedItems++;
|
|
14182
|
+
continue;
|
|
14183
|
+
}
|
|
14184
|
+
const args = argumentsField(item.arguments);
|
|
14185
|
+
const call = {
|
|
14186
|
+
name,
|
|
14187
|
+
args
|
|
14188
|
+
};
|
|
14189
|
+
const callId = stringField(item, "id");
|
|
14190
|
+
if (callId) callsById.set(callId, call);
|
|
14191
|
+
logs.toolCalls.push(call);
|
|
14192
|
+
if (name === "task_complete") {
|
|
14193
|
+
const summary = stringField(args, "summary");
|
|
14194
|
+
if (summary) logs.summary = summary;
|
|
14195
|
+
}
|
|
14196
|
+
if (WRITE_TOOL_NAMES.has(name)) {
|
|
14197
|
+
const path = args.path ?? args.file_path;
|
|
14198
|
+
if (typeof path === "string") addFile(path);
|
|
14199
|
+
}
|
|
14200
|
+
continue;
|
|
14201
|
+
}
|
|
14202
|
+
if (type === "FunctionResultContent") {
|
|
14203
|
+
const callId = stringField(item, "callId");
|
|
14204
|
+
const raw = item.result;
|
|
14205
|
+
const result = isRecord$1(raw) ? stringField(raw, "content") : void 0;
|
|
14206
|
+
const detail = isRecord$1(raw) ? stringField(raw, "detailedContent") : void 0;
|
|
14207
|
+
if (callId && (result || detail)) results.set(callId, {
|
|
14208
|
+
...result ? { result } : {},
|
|
14209
|
+
...detail ? { detail } : {}
|
|
14210
|
+
});
|
|
14211
|
+
if (result) collectDiffPaths(result, addFile);
|
|
14212
|
+
if (detail) collectDiffPaths(detail, addFile);
|
|
14213
|
+
continue;
|
|
14214
|
+
}
|
|
14215
|
+
logs.unrecognizedItems++;
|
|
14216
|
+
}
|
|
14217
|
+
}
|
|
14218
|
+
for (const [callId, found] of results) {
|
|
14219
|
+
const call = callsById.get(callId);
|
|
14220
|
+
if (!call) continue;
|
|
14221
|
+
if (found.result) call.result = found.result;
|
|
14222
|
+
if (found.detail) call.detail = found.detail;
|
|
14223
|
+
}
|
|
14224
|
+
const counts = /* @__PURE__ */ new Map();
|
|
14225
|
+
for (const call of logs.toolCalls) counts.set(call.name, (counts.get(call.name) ?? 0) + 1);
|
|
14226
|
+
logs.histogram = [...counts.entries()].map(([name, count]) => ({
|
|
14227
|
+
name,
|
|
14228
|
+
count
|
|
14229
|
+
})).sort((a, b) => b.count - a.count || a.name.localeCompare(b.name));
|
|
14230
|
+
logs.changedFiles = changedFiles;
|
|
14231
|
+
return logs;
|
|
14232
|
+
}
|
|
14233
|
+
/**
|
|
14234
|
+
* Tools whose `path`/`file_path` argument names a file the agent changed.
|
|
14235
|
+
*
|
|
14236
|
+
* Deliberately a small allowlist: `view`, `grep`, `glob` and the `ado-*` readers
|
|
14237
|
+
* also take a path, and counting a read as a change would fill the digest with
|
|
14238
|
+
* files the job only looked at. `apply_patch` is absent because the service
|
|
14239
|
+
* records its arguments as `{}` — its diff is recovered from the result text.
|
|
14240
|
+
*/
|
|
14241
|
+
const WRITE_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
14242
|
+
"edit",
|
|
14243
|
+
"create",
|
|
14244
|
+
"write"
|
|
14245
|
+
]);
|
|
14246
|
+
/**
|
|
14247
|
+
* Session scaffolding the agent writes for itself, not part of the repository
|
|
14248
|
+
* change. Matched on normalized repository-relative paths so a real source file
|
|
14249
|
+
* that merely contains the word is not dropped.
|
|
14250
|
+
*/
|
|
14251
|
+
const SCAFFOLDING_PATH_PATTERNS = [
|
|
14252
|
+
/^\.engram\//,
|
|
14253
|
+
/^\.copilot\//,
|
|
14254
|
+
/\/session-state\//,
|
|
14255
|
+
/^home\//,
|
|
14256
|
+
/^tmp\//,
|
|
14257
|
+
/\/appdata\/local\/(?:agency|temp)\//i
|
|
14258
|
+
];
|
|
14259
|
+
/**
|
|
14260
|
+
* Normalize a path from a tool argument or a diff header to a
|
|
14261
|
+
* repository-relative POSIX path.
|
|
14262
|
+
*
|
|
14263
|
+
* The agent runs inside an Azure Pipelines checkout, so its own paths carry the
|
|
14264
|
+
* agent's prefix, and both measured forms appear in real traces:
|
|
14265
|
+
* `/mnt/vss/_work/1/s/packages/...` (Linux) and `F:\1\s\source\...` (Windows).
|
|
14266
|
+
* Diff headers from git are already relative (`a/source/...`).
|
|
14267
|
+
*/
|
|
14268
|
+
function normalizeTracePath(raw) {
|
|
14269
|
+
let path = raw.trim().replace(/\\/g, "/");
|
|
14270
|
+
path = path.replace(/^"|"$/g, "");
|
|
14271
|
+
if (!path) return void 0;
|
|
14272
|
+
path = path.replace(/^\/?mnt\/vss\/_work\/\d+\/s\//, "");
|
|
14273
|
+
path = path.replace(/^[A-Za-z]:\/\d+\/s\/(?:source\/)?/, "");
|
|
14274
|
+
path = path.replace(/^\.\//, "").replace(/^\/+/, "");
|
|
14275
|
+
if (!path || path === "dev/null") return void 0;
|
|
14276
|
+
if (SCAFFOLDING_PATH_PATTERNS.some((pattern) => pattern.test(path))) return void 0;
|
|
14277
|
+
return path;
|
|
14278
|
+
}
|
|
14279
|
+
/** Tool `arguments`, which arrive as an object and occasionally as JSON text. */
|
|
14280
|
+
function argumentsField(value) {
|
|
14281
|
+
if (isRecord$1(value)) return value;
|
|
14282
|
+
if (typeof value === "string" && value.trim()) try {
|
|
14283
|
+
const parsed = JSON.parse(value);
|
|
14284
|
+
return isRecord$1(parsed) ? parsed : {};
|
|
14285
|
+
} catch {
|
|
14286
|
+
return {};
|
|
14287
|
+
}
|
|
14288
|
+
return {};
|
|
14289
|
+
}
|
|
14290
|
+
/**
|
|
14291
|
+
* Collect `diff --git` header paths from a result body.
|
|
14292
|
+
*
|
|
14293
|
+
* The guard keeps the common case (no diff) to one `includes`, since a trace can
|
|
14294
|
+
* hold several megabytes of results and the regex would otherwise scan it all.
|
|
14295
|
+
*/
|
|
14296
|
+
function collectDiffPaths(text, addFile) {
|
|
14297
|
+
if (!text.includes("diff --git ")) return;
|
|
14298
|
+
const header = /^diff --git (.+)$/gm;
|
|
14299
|
+
for (let match = header.exec(text); match; match = header.exec(text)) {
|
|
14300
|
+
const path = diffHeaderPath(match[1]);
|
|
14301
|
+
if (path) addFile(path);
|
|
14302
|
+
}
|
|
14303
|
+
}
|
|
14304
|
+
/** `a/<path> b/<path>`, quoted by git when the path needs it. */
|
|
14305
|
+
function diffHeaderPath(header) {
|
|
14306
|
+
const stripped = header.trim();
|
|
14307
|
+
const quoted = /^"a\/(.+)" "b\/(.+)"$/.exec(stripped);
|
|
14308
|
+
if (quoted) return quoted[2];
|
|
14309
|
+
const plain = /^a\/(.+) b\/(.+)$/.exec(stripped);
|
|
14310
|
+
if (plain) return plain[2];
|
|
14311
|
+
}
|
|
14312
|
+
const MAX_PROMPT_CHARS = 800;
|
|
14313
|
+
const MAX_DESCRIPTION_CHARS = 400;
|
|
14314
|
+
const MAX_RENDERED_ROWS = 200;
|
|
14315
|
+
function truncate(value, max) {
|
|
14316
|
+
const single = value.replace(/\s*\r?\n\s*/g, " ⏎ ");
|
|
14317
|
+
return single.length > max ? `${single.slice(0, max)}…` : single;
|
|
14318
|
+
}
|
|
14319
|
+
/**
|
|
14320
|
+
* Render one job as labelled lines instead of wire JSON.
|
|
14321
|
+
*
|
|
14322
|
+
* `result` and `jobOutcomeType` are BOTH printed, with their distinct meanings
|
|
14323
|
+
* spelled out. The docs warn that a job can be `state: Completed` with
|
|
14324
|
+
* `outcome.code: Succeeded` while `result` is `Failure` — the classifier judged
|
|
14325
|
+
* the WORK unsuccessful. Dropping either field would leave the model inferring
|
|
14326
|
+
* one from the other, which is the exact mistake the doc calls out.
|
|
14327
|
+
*/
|
|
14328
|
+
function renderJob(job, opts = {}) {
|
|
14329
|
+
const lines = [`Job ${job.jobId}`];
|
|
14330
|
+
if (opts.note) lines.push(opts.note);
|
|
14331
|
+
if (opts.summary) {
|
|
14332
|
+
lines.push("");
|
|
14333
|
+
lines.push("summary (the job's deliverable):");
|
|
14334
|
+
lines.push(opts.summary);
|
|
14335
|
+
lines.push("");
|
|
14336
|
+
}
|
|
14337
|
+
if (job.state) lines.push(`state: ${job.state}`);
|
|
14338
|
+
if (job.outcomeCode) lines.push(job.outcomeDescription ? `outcome: ${job.outcomeCode} — ${truncate(job.outcomeDescription, MAX_DESCRIPTION_CHARS)}` : `outcome: ${job.outcomeCode}`);
|
|
14339
|
+
if (job.jobOutcomeType) lines.push(`jobOutcomeType (who is responsible): ${job.jobOutcomeType}`);
|
|
14340
|
+
if (job.result) lines.push(`result (legacy classifier verdict on the work): ${job.result}`);
|
|
14341
|
+
if (job.reason && job.reason.trim().toLowerCase() !== "no reason provided.") lines.push(`reason (legacy diagnostic): ${truncate(job.reason, MAX_DESCRIPTION_CHARS)}`);
|
|
14342
|
+
if (job.repository) lines.push(`repository: ${job.repository}`);
|
|
14343
|
+
if (job.metadata) {
|
|
14344
|
+
const labels = Object.entries(job.metadata).map(([key, value]) => `${key}=${value}`);
|
|
14345
|
+
if (labels.length > 0) lines.push(`metadata: ${labels.join(" ")}`);
|
|
14346
|
+
}
|
|
14347
|
+
if (job.plugins && job.plugins.length > 0) lines.push(`plugins: ${job.plugins.join(", ")}`);
|
|
14348
|
+
if (job.pullRequestId !== void 0) {
|
|
14349
|
+
const branches = job.sourceBranch && job.targetBranch ? ` (${job.sourceBranch} -> ${job.targetBranch})` : job.sourceBranch ? ` (${job.sourceBranch})` : "";
|
|
14350
|
+
lines.push(`pull request: #${job.pullRequestId}${branches}`);
|
|
14351
|
+
} else if (job.sourceBranch) lines.push(`branch: ${job.sourceBranch}`);
|
|
14352
|
+
if (job.workItemIds && job.workItemIds.length > 0) lines.push(`work items: ${job.workItemIds.join(", ")}`);
|
|
14353
|
+
if (job.pullRequestTags && job.pullRequestTags.length > 0) lines.push(`pull request tags: ${job.pullRequestTags.join(", ")}`);
|
|
14354
|
+
if (job.prompt) lines.push(`prompt: ${truncate(job.prompt, MAX_PROMPT_CHARS)}`);
|
|
14355
|
+
if (job.requesterName) lines.push(`requested by: ${job.requesterName}`);
|
|
14356
|
+
if (job.initiatingUserName && job.initiatingUserName !== job.requesterName) lines.push(`initiated by: ${job.initiatingUserName}`);
|
|
14357
|
+
if (job.source) lines.push(`started from: ${job.source}`);
|
|
14358
|
+
if (job.createdAt) lines.push(`created: ${job.createdAt}`);
|
|
14359
|
+
if (job.updatedAt) lines.push(`updated: ${job.updatedAt}`);
|
|
14360
|
+
if (job.dispatchAfter) lines.push(`dispatch after: ${job.dispatchAfter} (the job waits in the queue until then)`);
|
|
14361
|
+
if (job.pipelineRun?.runId !== void 0) {
|
|
14362
|
+
const definition = job.pipelineRun.definitionId !== void 0 && job.pipelineRun.definitionId > 0 ? ` (definition ${job.pipelineRun.definitionId})` : "";
|
|
14363
|
+
lines.push(`pipeline run id: ${job.pipelineRun.runId}${definition}`);
|
|
14364
|
+
}
|
|
14365
|
+
if (job.isRetryable !== void 0) lines.push(`retryable: ${job.isRetryable ? "yes" : "no"}`);
|
|
14366
|
+
if (job.modelName) lines.push(`model requested: ${job.modelName}`);
|
|
14367
|
+
if (job.currentModel && job.currentModel !== job.modelName) lines.push(`model at session end: ${job.currentModel}`);
|
|
14368
|
+
if (job.modelUsage) {
|
|
14369
|
+
const usage = Object.entries(job.modelUsage).map(([model, entry]) => {
|
|
14370
|
+
if (entry === null) return `${model}: (recorded as null)`;
|
|
14371
|
+
const parts = [];
|
|
14372
|
+
if (entry.inputTokens !== void 0) parts.push(`in ${entry.inputTokens}`);
|
|
14373
|
+
if (entry.outputTokens !== void 0) parts.push(`out ${entry.outputTokens}`);
|
|
14374
|
+
if (entry.cacheReadTokens !== void 0) parts.push(`cache read ${entry.cacheReadTokens}`);
|
|
14375
|
+
if (entry.cacheWriteTokens !== void 0) parts.push(`cache write ${entry.cacheWriteTokens}`);
|
|
14376
|
+
return `${model}: ${parts.length > 0 ? parts.join(", ") : "(no token counts)"}`;
|
|
14377
|
+
});
|
|
14378
|
+
if (usage.length > 0) lines.push(`tokens: ${usage.join("; ")}`);
|
|
14379
|
+
}
|
|
14380
|
+
return lines.join("\n");
|
|
14381
|
+
}
|
|
14382
|
+
/**
|
|
14383
|
+
* States that mean the job will not change again, so a poll is pointless and a
|
|
14384
|
+
* `get_job` answer is final.
|
|
14385
|
+
*
|
|
14386
|
+
* Lowercased because the service uses PascalCase (`Completed`) while older
|
|
14387
|
+
* rows and docs also spell `Succeeded`; both spellings of cancel appear in the
|
|
14388
|
+
* wild. Deliberately matched by name rather than by "anything not InProgress",
|
|
14389
|
+
* so a state this file has never seen stays non-terminal and keeps being
|
|
14390
|
+
* polled instead of being declared finished.
|
|
14391
|
+
*/
|
|
14392
|
+
const TERMINAL_JOB_STATES = /* @__PURE__ */ new Set([
|
|
14393
|
+
"completed",
|
|
14394
|
+
"failed",
|
|
14395
|
+
"cancelled",
|
|
14396
|
+
"canceled",
|
|
14397
|
+
"succeeded"
|
|
14398
|
+
]);
|
|
14399
|
+
function isTerminalJob(job) {
|
|
14400
|
+
return job.state !== void 0 && TERMINAL_JOB_STATES.has(job.state.trim().toLowerCase());
|
|
14401
|
+
}
|
|
14402
|
+
/**
|
|
14403
|
+
* Queued is the state before compute is allocated. `wait_for_job` exists to
|
|
14404
|
+
* distinguish "still queued" from "started", so it needs this as much as it
|
|
14405
|
+
* needs terminality.
|
|
14406
|
+
*/
|
|
14407
|
+
function isQueuedJob(job) {
|
|
14408
|
+
return job.state !== void 0 && job.state.trim().toLowerCase() === "queued";
|
|
14409
|
+
}
|
|
14410
|
+
/**
|
|
14411
|
+
* The cadence line on a live poll.
|
|
14412
|
+
*
|
|
14413
|
+
* Without it a model re-polls on every turn against a job whose shortest
|
|
14414
|
+
* observed runtime is 3 minutes and whose median is about an hour, which burns
|
|
14415
|
+
* context and tokens to learn nothing. The elapsed figure is what tells the
|
|
14416
|
+
* caller whether a multi-hour job is young or overdue.
|
|
14417
|
+
*/
|
|
14418
|
+
function renderPollHint(job, now = Date.now()) {
|
|
14419
|
+
const elapsed = elapsedMinutes(job.createdAt, now);
|
|
14420
|
+
const since = elapsed !== void 0 ? `job created ${elapsed} min ago` : "creation time not reported";
|
|
14421
|
+
if (isQueuedJob(job)) return `next: check again in ~2 min; ${since}. Still queued means no compute has been allocated yet — if this persists well past a few minutes the queue is the problem, not the job.`;
|
|
14422
|
+
return `next: check again in ~10 min; ${since}. A typical job runs for hours, so checking more often than that will only repeat this answer.`;
|
|
14423
|
+
}
|
|
14424
|
+
function elapsedMinutes(iso, now) {
|
|
14425
|
+
if (!iso) return void 0;
|
|
14426
|
+
const started = Date.parse(iso);
|
|
14427
|
+
if (Number.isNaN(started)) return void 0;
|
|
14428
|
+
const minutes = Math.floor((now - started) / 6e4);
|
|
14429
|
+
return minutes < 0 ? void 0 : minutes;
|
|
14430
|
+
}
|
|
14431
|
+
/**
|
|
14432
|
+
* Render a digested trace: what the job did, and what it left behind.
|
|
14433
|
+
*
|
|
14434
|
+
* The trace is the only place a job's work is visible — `toolDiffs` is `[]` on
|
|
14435
|
+
* every sampled job — but it is also 233 KB to 7.5 MB, so the digest is what
|
|
14436
|
+
* makes it usable: a one-line histogram conveys the shape of four thousand
|
|
14437
|
+
* messages, and the changed files answer "what did it touch" without reading
|
|
14438
|
+
* the run.
|
|
14439
|
+
*
|
|
14440
|
+
* The final tool call's result is shown because for a FAILED job there is no
|
|
14441
|
+
* `task_complete` summary, and the last thing the agent saw before dying is the
|
|
14442
|
+
* only diagnosis available.
|
|
14443
|
+
*/
|
|
14444
|
+
function renderTrace(logs, opts = {}) {
|
|
14445
|
+
const tail = opts.tail ?? 12;
|
|
14446
|
+
const lines = [];
|
|
14447
|
+
const counts = `${logs.messageCount} message(s), ${logs.toolCalls.length} tool call(s)`;
|
|
14448
|
+
lines.push(logs.id ? `trace for job ${logs.id}: ${counts}` : `trace: ${counts}`);
|
|
14449
|
+
if (logs.createdAt) lines.push(`recorded: ${logs.createdAt}${logs.updatedAt ? ` -> ${logs.updatedAt}` : ""}`);
|
|
14450
|
+
if (logs.summary) {
|
|
14451
|
+
lines.push("");
|
|
14452
|
+
lines.push("summary (the job's deliverable):");
|
|
14453
|
+
lines.push(logs.summary);
|
|
14454
|
+
} else if (logs.toolCalls.length > 0) {
|
|
14455
|
+
lines.push("");
|
|
14456
|
+
lines.push("summary: none — the job never called task_complete, so it produced no deliverable. A job that fails has no summary; read the recent tool calls below for why.");
|
|
14457
|
+
}
|
|
14458
|
+
if (logs.histogram.length > 0) {
|
|
14459
|
+
lines.push("");
|
|
14460
|
+
lines.push(`tool use: ${logs.histogram.map((entry) => `${entry.name}=${entry.count}`).join(" ")}`);
|
|
14461
|
+
}
|
|
14462
|
+
if (logs.changedFiles.length > 0) {
|
|
14463
|
+
const shown = logs.changedFiles.slice(0, MAX_CHANGED_FILES);
|
|
14464
|
+
lines.push("");
|
|
14465
|
+
lines.push(`changed files (${logs.changedFiles.length})${logs.changedFiles.length > shown.length ? `, first ${shown.length}` : ""}:`);
|
|
14466
|
+
for (const file of shown) lines.push(` ${file}`);
|
|
14467
|
+
if (logs.changedFiles.length > shown.length) lines.push(` … ${logs.changedFiles.length - shown.length} more; mode: "full" has the whole trace.`);
|
|
14468
|
+
}
|
|
14469
|
+
const last = lastAssistantText(logs.assistantTexts);
|
|
14470
|
+
if (last) {
|
|
14471
|
+
lines.push("");
|
|
14472
|
+
lines.push(`last agent message: ${truncate(last, MAX_LAST_MESSAGE_CHARS)}`);
|
|
14473
|
+
}
|
|
14474
|
+
if (logs.toolCalls.length > 0) {
|
|
14475
|
+
const calls = logs.toolCalls.slice(-Math.max(tail, 0));
|
|
14476
|
+
if (calls.length > 0) {
|
|
14477
|
+
lines.push("");
|
|
14478
|
+
lines.push(`recent tool calls (last ${calls.length}):`);
|
|
14479
|
+
for (const call of calls) lines.push(` ${renderToolCall(call)}`);
|
|
14480
|
+
}
|
|
14481
|
+
const finalResult = lastToolResult(logs.toolCalls);
|
|
14482
|
+
if (finalResult) {
|
|
14483
|
+
lines.push("");
|
|
14484
|
+
lines.push("final tool result (the last thing the agent saw):");
|
|
14485
|
+
lines.push(finalResult);
|
|
14486
|
+
}
|
|
14487
|
+
}
|
|
14488
|
+
if (logs.unrecognizedItems > 0) {
|
|
14489
|
+
lines.push("");
|
|
14490
|
+
lines.push(`note: ${logs.unrecognizedItems} trace item(s) were not in a shape this proxy models and were skipped; they are present in mode: "full".`);
|
|
14491
|
+
}
|
|
14492
|
+
return lines.join("\n");
|
|
14493
|
+
}
|
|
14494
|
+
const MAX_CHANGED_FILES = 40;
|
|
14495
|
+
const MAX_LAST_MESSAGE_CHARS = 1200;
|
|
14496
|
+
const MAX_TOOL_RESULT_CHARS = 1500;
|
|
14497
|
+
function lastAssistantText(texts) {
|
|
14498
|
+
for (let index = texts.length - 1; index >= 0; index--) {
|
|
14499
|
+
const text = texts[index]?.trim();
|
|
14500
|
+
if (text) return text;
|
|
14501
|
+
}
|
|
14502
|
+
}
|
|
14503
|
+
function renderToolCall(call) {
|
|
14504
|
+
const args = Object.keys(call.args).length > 0 ? ` ${truncate(JSON.stringify(call.args), 200)}` : "";
|
|
14505
|
+
return `${call.name}${args}`;
|
|
14506
|
+
}
|
|
14507
|
+
/**
|
|
14508
|
+
* A bounded slice of the final call's result, from the END where possible: the
|
|
14509
|
+
* failure is at the tail of a build log, and the head is boilerplate.
|
|
14510
|
+
*/
|
|
14511
|
+
function lastToolResult(calls) {
|
|
14512
|
+
for (let index = calls.length - 1; index >= 0; index--) {
|
|
14513
|
+
const call = calls[index];
|
|
14514
|
+
const text = (call?.detail ?? call?.result ?? "").trim();
|
|
14515
|
+
if (!text) continue;
|
|
14516
|
+
return text.length > MAX_TOOL_RESULT_CHARS ? `…${text.slice(text.length - MAX_TOOL_RESULT_CHARS)}` : text;
|
|
14517
|
+
}
|
|
14518
|
+
}
|
|
14519
|
+
/** One line per job, so a page of 25 costs a screen rather than a transcript. */
|
|
14520
|
+
/**
|
|
14521
|
+
* Compact `{chain=research step=1 +2}` label for a list row.
|
|
14522
|
+
*
|
|
14523
|
+
* Metadata is the only field on a job that a caller controls and can search by,
|
|
14524
|
+
* so a listing that dropped it would make the chain convention (`create_job`
|
|
14525
|
+
* stores `{chain, step}`) invisible exactly where a model looks for the earlier
|
|
14526
|
+
* steps. Capped at four pairs / 60 characters because this rides on one line of
|
|
14527
|
+
* a page that can hold 100 rows; the remainder is counted, not printed.
|
|
14528
|
+
*/
|
|
14529
|
+
const PAGE_LABEL_PAIRS = 4;
|
|
14530
|
+
const PAGE_LABEL_CHARS = 60;
|
|
14531
|
+
function renderMetadataBrief(metadata) {
|
|
14532
|
+
if (!metadata) return "";
|
|
14533
|
+
const pairs = Object.entries(metadata).filter(([, value]) => value.length > 0);
|
|
14534
|
+
if (pairs.length === 0) return "";
|
|
14535
|
+
const shown = [];
|
|
14536
|
+
let budget = PAGE_LABEL_CHARS;
|
|
14537
|
+
for (const [key, value] of pairs.slice(0, PAGE_LABEL_PAIRS)) {
|
|
14538
|
+
const pair = `${key}=${value}`;
|
|
14539
|
+
if (shown.length > 0 && pair.length > budget) break;
|
|
14540
|
+
shown.push(pair);
|
|
14541
|
+
budget -= pair.length + 1;
|
|
14542
|
+
}
|
|
14543
|
+
const hidden = pairs.length - shown.length;
|
|
14544
|
+
return `[${shown.join(" ")}${hidden > 0 ? ` +${hidden}` : ""}]`;
|
|
14545
|
+
}
|
|
14546
|
+
function renderJobPage(page) {
|
|
14547
|
+
if (page.data.length === 0) return "No jobs matched.";
|
|
14548
|
+
const rows = page.data.map((job) => {
|
|
14549
|
+
const state = job.state ?? "?";
|
|
14550
|
+
const outcome = job.outcomeCode ?? job.result ?? "";
|
|
14551
|
+
const when = job.createdAt ?? "";
|
|
14552
|
+
const tail = [
|
|
14553
|
+
job.repository ?? "",
|
|
14554
|
+
job.pullRequestId !== void 0 ? `PR#${job.pullRequestId}` : "",
|
|
14555
|
+
renderMetadataBrief(job.metadata),
|
|
14556
|
+
job.prompt ? truncate(job.prompt, 120) : ""
|
|
14557
|
+
].filter((part) => part.length > 0).join(" ");
|
|
14558
|
+
return `${job.jobId} ${state}${outcome ? ` ${outcome}` : ""} ${when}${tail ? ` ${tail}` : ""}`;
|
|
14559
|
+
});
|
|
14560
|
+
const lines = [`${page.data.length} job(s):`, ...rows];
|
|
14561
|
+
if (page.hasMore) {
|
|
14562
|
+
lines.push("");
|
|
14563
|
+
lines.push(page.continuationToken ? `More results available. Pass continuationToken "${page.continuationToken}" to continue.` : "More results available, but the service returned no continuationToken.");
|
|
14564
|
+
}
|
|
14565
|
+
return lines.join("\n");
|
|
14566
|
+
}
|
|
14567
|
+
/**
|
|
14568
|
+
* Render an agents or plugins page.
|
|
14569
|
+
*
|
|
14570
|
+
* Agent `inputs` are printed because they are the only way a caller can fill
|
|
14571
|
+
* `customAgent.inputs` correctly: the service rejects a job whose agent is
|
|
14572
|
+
* missing a required input, and nothing else in the surface reveals the names.
|
|
14573
|
+
*/
|
|
14574
|
+
function renderAgentPage(page) {
|
|
14575
|
+
const header = catalogHeader("agent", page);
|
|
14576
|
+
if (page.value.length === 0) return finishCatalog(header, [], page, "No agents matched.");
|
|
14577
|
+
return finishCatalog(header, page.value.slice(0, MAX_RENDERED_ROWS).map((agent) => {
|
|
14578
|
+
const lines = [` ${agent.name}${agent.type ? ` [${agent.type}]` : ""}${agent.engine ? ` (engine: ${agent.engine})` : ""}`];
|
|
14579
|
+
if (agent.description) lines.push(` ${truncate(agent.description, MAX_DESCRIPTION_CHARS)}`);
|
|
14580
|
+
if (agent.inputs) {
|
|
14581
|
+
const inputs = Object.entries(agent.inputs).map(([key, spec]) => {
|
|
14582
|
+
return `${key} (${spec.type ?? "unknown"}, ${spec.required === true ? "required" : "optional"})${spec.description ? ` — ${truncate(spec.description, 200)}` : ""}`;
|
|
14583
|
+
});
|
|
14584
|
+
lines.push(` inputs: ${inputs.join("; ")}`);
|
|
14585
|
+
}
|
|
14586
|
+
return lines.join("\n");
|
|
14587
|
+
}), page);
|
|
14588
|
+
}
|
|
14589
|
+
function renderPluginPage(page) {
|
|
14590
|
+
const header = catalogHeader("plugin", page);
|
|
14591
|
+
if (page.value.length === 0) return finishCatalog(header, [], page, "No plugins matched.");
|
|
14592
|
+
return finishCatalog(header, page.value.slice(0, MAX_RENDERED_ROWS).map((plugin) => {
|
|
14593
|
+
const flags = [plugin.type ? `[${plugin.type}]` : "", plugin.enabledByDefault === true ? "(enabled by default)" : ""].filter((part) => part.length > 0).join(" ");
|
|
14594
|
+
const description = plugin.description ? ` — ${truncate(plugin.description, MAX_DESCRIPTION_CHARS)}` : "";
|
|
14595
|
+
return ` ${plugin.name}${flags ? ` ${flags}` : ""}${description}`;
|
|
14596
|
+
}), page);
|
|
14597
|
+
}
|
|
14598
|
+
/**
|
|
14599
|
+
* Render the model catalog.
|
|
14600
|
+
*
|
|
14601
|
+
* Effort values are printed per row because the ladder is not uniform: measured
|
|
14602
|
+
* live, 8 of 25 models do not accept `max`, so a caller that assumes every
|
|
14603
|
+
* model takes the tier default would get a 400 it could have avoided by
|
|
14604
|
+
* reading the row. `modelPickerCategory` and `modelPickerEnabled` are
|
|
14605
|
+
* deliberately dropped — they describe a UI grouping, not a capability.
|
|
14606
|
+
*/
|
|
14607
|
+
function renderModelPage(models) {
|
|
14608
|
+
if (models.length === 0) return "No models were returned.";
|
|
14609
|
+
const rows = models.slice(0, MAX_RENDERED_ROWS).map((model) => {
|
|
14610
|
+
const tags = [model.vendor, model.preview === true ? "preview" : void 0].filter((part) => part !== void 0 && part.length > 0);
|
|
14611
|
+
const details = [
|
|
14612
|
+
model.maxContextWindowTokens !== void 0 ? `context ${formatTokenCount(model.maxContextWindowTokens)}` : "",
|
|
14613
|
+
model.maxOutputTokens !== void 0 ? `max output ${formatTokenCount(model.maxOutputTokens)}` : "",
|
|
14614
|
+
model.reasoningEffort && model.reasoningEffort.length > 0 ? `effort ${model.reasoningEffort.join("/")}` : "",
|
|
14615
|
+
model.billingMultiplier !== void 0 && model.billingMultiplier > 1 ? `cost ×${model.billingMultiplier}` : ""
|
|
14616
|
+
].filter((part) => part.length > 0);
|
|
14617
|
+
const lines = [` ${model.id}${tags.length > 0 ? ` [${tags.join(", ")}]` : ""}${details.length > 0 ? ` — ${details.join("; ")}` : ""}`];
|
|
14618
|
+
for (const notice of model.notices ?? []) lines.push(` note: ${truncate(notice, 240)}`);
|
|
14619
|
+
return lines.join("\n");
|
|
14620
|
+
});
|
|
14621
|
+
return [models.length > MAX_RENDERED_ROWS ? `${models.length} model(s) (first ${MAX_RENDERED_ROWS} shown):` : `${models.length} model(s):`, ...rows].join("\n");
|
|
14622
|
+
}
|
|
14623
|
+
function formatTokenCount(value) {
|
|
14624
|
+
if (value >= 1e6) return `${Math.round(value / 1e6 * 100) / 100}M`;
|
|
14625
|
+
if (value >= 1e3) return `${Math.round(value / 1e3)}K`;
|
|
14626
|
+
return String(value);
|
|
14627
|
+
}
|
|
14628
|
+
function catalogHeader(kind, page) {
|
|
14629
|
+
const total = page.totalCount !== void 0 ? ` of ${page.totalCount}` : "";
|
|
14630
|
+
const window = [page.top !== void 0 ? `top ${page.top}` : "", page.skip !== void 0 && page.skip > 0 ? `skip ${page.skip}` : ""].filter((part) => part.length > 0).join(", ");
|
|
14631
|
+
return `${page.value.length}${total} ${kind}(s)${window ? ` (${window})` : ""}:`;
|
|
14632
|
+
}
|
|
14633
|
+
/**
|
|
14634
|
+
* Render a page and, when the service explained itself, say so.
|
|
14635
|
+
*
|
|
14636
|
+
* A Repo or Organization scope answers HTTP 200 with an empty page and the
|
|
14637
|
+
* reason in `errors` ("Marketplace manifest not found at …"), so an empty
|
|
14638
|
+
* result is usually not "nothing exists" but "the thing this scope reads
|
|
14639
|
+
* looked elsewhere". Dropping the reason made those two indistinguishable.
|
|
14640
|
+
* On a non-empty page the errors classify the rows instead, hence the
|
|
14641
|
+
* different label: `reason:` explains an emptiness, `partial results:`
|
|
14642
|
+
* qualifies a list.
|
|
14643
|
+
*/
|
|
14644
|
+
function finishCatalog(header, rows, page, empty) {
|
|
14645
|
+
const lines = [header, ...rows];
|
|
14646
|
+
if (rows.length === 0 && empty) lines.push(` ${empty}`);
|
|
14647
|
+
if (page.value.length > MAX_RENDERED_ROWS) lines.push(` … ${page.value.length - MAX_RENDERED_ROWS} more not rendered; raise \`skip\` to page.`);
|
|
14648
|
+
if (page.errors && page.errors.length > 0) {
|
|
14649
|
+
const label = rows.length === 0 ? "reason" : "partial results";
|
|
14650
|
+
lines.push(`${label}: ${page.errors.map((error) => truncate(error, 300)).join("; ")}`);
|
|
14651
|
+
}
|
|
14652
|
+
return lines.join("\n");
|
|
14653
|
+
}
|
|
14654
|
+
/**
|
|
14655
|
+
* Process-lifetime token cache, keyed by the Entra RESOURCE rather than the
|
|
14656
|
+
* base URL: two environments are two audiences, and a token minted for one is
|
|
14657
|
+
* not accepted by the other.
|
|
14658
|
+
*/
|
|
14659
|
+
const cloudAgentTokenCache = new AzCliAccessTokenCache();
|
|
14660
|
+
var CloudAgentClient = class {
|
|
14661
|
+
environment;
|
|
14662
|
+
baseUrl;
|
|
14663
|
+
resource;
|
|
14664
|
+
fetchImpl;
|
|
14665
|
+
tokenProvider;
|
|
14666
|
+
retryDelaysMs;
|
|
14667
|
+
constructor(opts) {
|
|
14668
|
+
this.environment = opts.environment;
|
|
14669
|
+
const endpoints = ENVIRONMENT_ENDPOINTS[opts.environment];
|
|
14670
|
+
this.baseUrl = endpoints.baseUrl;
|
|
14671
|
+
this.resource = endpoints.resource;
|
|
14672
|
+
this.fetchImpl = opts.fetchImpl ?? fetch;
|
|
14673
|
+
this.tokenProvider = opts.tokenProvider ?? ((signal) => getCloudAgentToken(this.resource, signal));
|
|
14674
|
+
this.retryDelaysMs = opts.retryDelaysMs ?? CLOUDAGENT_RETRY_DELAYS_MS;
|
|
14675
|
+
}
|
|
14676
|
+
/**
|
|
14677
|
+
* One logical request: attempt, classify, retry when the caller marked the
|
|
14678
|
+
* call safe to repeat. A 401 is retried exactly once for EVERY method,
|
|
14679
|
+
* including `createJob`, because a rejected request had no effect — that is
|
|
14680
|
+
* not the same as replaying a write that may have landed.
|
|
14681
|
+
*/
|
|
14682
|
+
async request(method, path, opts) {
|
|
14683
|
+
let refreshed = false;
|
|
14684
|
+
for (let attempt = 0;; attempt++) try {
|
|
14685
|
+
return await this.attemptOnce(method, path, opts);
|
|
14686
|
+
} catch (err) {
|
|
14687
|
+
if (opts.signal?.aborted) throw opts.signal.reason ?? err;
|
|
14688
|
+
if (err instanceof CloudAgentError && err.status === 401 && !refreshed) {
|
|
14689
|
+
refreshed = true;
|
|
14690
|
+
continue;
|
|
14691
|
+
}
|
|
14692
|
+
const retriable = err instanceof CloudAgentError ? err.retriable : true;
|
|
14693
|
+
if (!opts.retry || !retriable || attempt >= this.retryDelaysMs.length) throw err;
|
|
14694
|
+
const hint = err instanceof CloudAgentError ? err.retryAfterMs : void 0;
|
|
14695
|
+
await sleep$4(hint ?? this.retryDelaysMs[attempt], opts.signal);
|
|
14696
|
+
}
|
|
14697
|
+
}
|
|
14698
|
+
async attemptOnce(method, path, opts) {
|
|
14699
|
+
const token = await this.tokenProvider(opts.signal);
|
|
14700
|
+
const url = new URL(`${this.baseUrl}${path}`);
|
|
14701
|
+
for (const [key, value] of Object.entries(opts.query ?? {})) if (value !== void 0 && value !== "") url.searchParams.set(key, String(value));
|
|
14702
|
+
const controller = new AbortController();
|
|
14703
|
+
const onAbort = () => controller.abort(opts.signal?.reason ?? /* @__PURE__ */ new Error("aborted"));
|
|
14704
|
+
if (opts.signal?.aborted) onAbort();
|
|
14705
|
+
else opts.signal?.addEventListener("abort", onAbort, { once: true });
|
|
14706
|
+
const timer = setTimeout(() => controller.abort(/* @__PURE__ */ new Error("Cloud Agent request timed out")), REQUEST_TIMEOUT_MS);
|
|
14707
|
+
timer.unref?.();
|
|
14708
|
+
let res;
|
|
14709
|
+
try {
|
|
14710
|
+
try {
|
|
14711
|
+
res = await this.fetchImpl(url.toString(), {
|
|
14712
|
+
method,
|
|
14713
|
+
headers: {
|
|
14714
|
+
Accept: "application/json",
|
|
14715
|
+
Authorization: `Bearer ${token}`,
|
|
14716
|
+
...opts.body === void 0 ? {} : { "Content-Type": "application/json; charset=utf-8" }
|
|
14717
|
+
},
|
|
14718
|
+
...opts.body === void 0 ? {} : { body: JSON.stringify(opts.body) },
|
|
14719
|
+
signal: controller.signal
|
|
14720
|
+
});
|
|
14721
|
+
} catch (err) {
|
|
14722
|
+
if (opts.signal?.aborted) throw opts.signal.reason ?? /* @__PURE__ */ new Error("aborted");
|
|
14723
|
+
throw new CloudAgentError(`Cloud Agent transport failed: ${sanitizeRemoteDetail(err)}`, { retriable: true });
|
|
14724
|
+
}
|
|
14725
|
+
if (res.status === 401) {
|
|
14726
|
+
cloudAgentTokenCache.invalidate(this.resource);
|
|
14727
|
+
throw new CloudAgentError("Cloud Agent rejected the access token (HTTP 401). Verify `az login` targets the tenant that owns Cloud Agent, then retry.", {
|
|
14728
|
+
retriable: false,
|
|
14729
|
+
status: 401
|
|
14730
|
+
});
|
|
14731
|
+
}
|
|
14732
|
+
if (res.status === 403) throw new CloudAgentError(`Cloud Agent refused the request (HTTP 403): ${cloudAgentErrorDetail(await readBoundedBody(res, opts.cap, opts.what))} The token was accepted; this is an authorization verdict for the repository or the caller.`, {
|
|
14733
|
+
retriable: false,
|
|
14734
|
+
status: 403
|
|
14735
|
+
});
|
|
14736
|
+
const retryAfter = parseRetryAfter(res.headers.get("retry-after"));
|
|
14737
|
+
if ([
|
|
14738
|
+
429,
|
|
14739
|
+
500,
|
|
14740
|
+
502,
|
|
14741
|
+
503,
|
|
14742
|
+
504
|
|
14743
|
+
].includes(res.status)) throw new CloudAgentError(`Cloud Agent responded with HTTP ${res.status}.`, {
|
|
14744
|
+
retriable: true,
|
|
14745
|
+
status: res.status,
|
|
14746
|
+
...retryAfter === void 0 ? {} : { retryAfterMs: retryAfter }
|
|
14747
|
+
});
|
|
14748
|
+
const text = await readBoundedBody(res, opts.cap, opts.what);
|
|
14749
|
+
if (!res.ok) {
|
|
14750
|
+
if (res.status === 404) {
|
|
14751
|
+
const jobId = jobIdFromPath(path);
|
|
14752
|
+
if (jobId) throw new CloudAgentError(`No job with id "${jobId}" exists in the ${this.environment} environment (HTTP 404). A job id is the full "<org>-<uuid>" string that create_job and list_jobs return; a bare UUID does not resolve. list_jobs shows the ids this account can see.`, {
|
|
14753
|
+
retriable: false,
|
|
14754
|
+
status: 404
|
|
14755
|
+
});
|
|
14756
|
+
}
|
|
14757
|
+
throw new CloudAgentError(`Cloud Agent responded with HTTP ${res.status}: ${cloudAgentErrorDetail(text)}`, {
|
|
14758
|
+
retriable: false,
|
|
14759
|
+
status: res.status
|
|
14760
|
+
});
|
|
14761
|
+
}
|
|
14762
|
+
if (!text.trim()) return {
|
|
14763
|
+
value: null,
|
|
14764
|
+
text
|
|
14765
|
+
};
|
|
14766
|
+
try {
|
|
14767
|
+
return {
|
|
14768
|
+
value: JSON.parse(text),
|
|
14769
|
+
text
|
|
14770
|
+
};
|
|
14771
|
+
} catch {
|
|
14772
|
+
throw new CloudAgentError("Cloud Agent returned a response that was not JSON.", { retriable: true });
|
|
14773
|
+
}
|
|
14774
|
+
} finally {
|
|
14775
|
+
clearTimeout(timer);
|
|
14776
|
+
opts.signal?.removeEventListener("abort", onAbort);
|
|
14777
|
+
}
|
|
14778
|
+
}
|
|
14779
|
+
/** `POST /v2/jobs` — creates the job. NOT retried (see the module comment). */
|
|
14780
|
+
async createJob(request, signal) {
|
|
14781
|
+
const { value } = await this.request("POST", "/v2/jobs", {
|
|
14782
|
+
body: request,
|
|
14783
|
+
retry: false,
|
|
14784
|
+
cap: MAX_RESPONSE_BYTES,
|
|
14785
|
+
what: "job",
|
|
14786
|
+
...signal ? { signal } : {}
|
|
14787
|
+
});
|
|
14788
|
+
return readJob(value);
|
|
14789
|
+
}
|
|
14790
|
+
/** `POST /v2/jobs/validate` — same body, creates nothing, safe to repeat. */
|
|
14791
|
+
async validateJob(request, signal) {
|
|
14792
|
+
const { value } = await this.request("POST", "/v2/jobs/validate", {
|
|
14793
|
+
body: request,
|
|
14794
|
+
retry: true,
|
|
14795
|
+
cap: MAX_RESPONSE_BYTES,
|
|
14796
|
+
what: "validation",
|
|
14797
|
+
...signal ? { signal } : {}
|
|
14798
|
+
});
|
|
14799
|
+
return readJob(value);
|
|
14800
|
+
}
|
|
14801
|
+
/** `GET /jobs/{jobId}` — the only source of a job's current outcome. */
|
|
14802
|
+
async getJob(jobId, signal) {
|
|
14803
|
+
const { value } = await this.request("GET", `/jobs/${assertJobId(jobId)}`, {
|
|
14804
|
+
retry: true,
|
|
14805
|
+
cap: MAX_RESPONSE_BYTES,
|
|
14806
|
+
what: "job",
|
|
14807
|
+
...signal ? { signal } : {}
|
|
14808
|
+
});
|
|
14809
|
+
return readJob(value);
|
|
14810
|
+
}
|
|
14811
|
+
/** `GET /jobs` — jobs the authenticated caller can see. */
|
|
14812
|
+
async listJobs(query = {}, signal) {
|
|
14813
|
+
const { value } = await this.request("GET", "/jobs", {
|
|
14814
|
+
query: {
|
|
14815
|
+
organization: query.organization,
|
|
14816
|
+
project: query.project,
|
|
14817
|
+
repository: query.repository,
|
|
14818
|
+
pullRequestId: query.pullRequestId,
|
|
14819
|
+
pageSize: query.pageSize,
|
|
14820
|
+
continuationToken: query.continuationToken
|
|
14821
|
+
},
|
|
14822
|
+
retry: true,
|
|
14823
|
+
cap: MAX_RESPONSE_BYTES,
|
|
14824
|
+
what: "job list",
|
|
14825
|
+
...signal ? { signal } : {}
|
|
14826
|
+
});
|
|
14827
|
+
return readJobPage(value);
|
|
14828
|
+
}
|
|
14829
|
+
/**
|
|
14830
|
+
* `POST /jobs/{jobId}/cancel`. The v1-shaped route, deliberately: the docs
|
|
14831
|
+
* state there is no `/v2/.../cancel`.
|
|
14832
|
+
*
|
|
14833
|
+
* 202 means "requested" and carries no body; 200 means the job is already
|
|
14834
|
+
* cancelled and carries the job. Both are returned as a verdict because the
|
|
14835
|
+
* caller's next action is the same either way — poll `getJob` until a
|
|
14836
|
+
* terminal state — but only the 200 can report a final outcome immediately.
|
|
14837
|
+
*/
|
|
14838
|
+
async cancelJob(jobId, signal) {
|
|
14839
|
+
const id = assertJobId(jobId);
|
|
14840
|
+
const { value } = await this.request("POST", `/jobs/${id}/cancel`, {
|
|
14841
|
+
retry: true,
|
|
14842
|
+
cap: MAX_RESPONSE_BYTES,
|
|
14843
|
+
what: "cancel request",
|
|
14844
|
+
...signal ? { signal } : {}
|
|
14845
|
+
});
|
|
14846
|
+
if (value === null) return { alreadyCancelled: false };
|
|
14847
|
+
return {
|
|
14848
|
+
alreadyCancelled: true,
|
|
14849
|
+
job: readJob(value)
|
|
14850
|
+
};
|
|
14851
|
+
}
|
|
14852
|
+
/** `GET /jobs/{jobId}/logs`, parsed into the digest shape. */
|
|
14853
|
+
async getJobLogs(jobId, signal) {
|
|
14854
|
+
const { value } = await this.fetchLogs(jobId, signal);
|
|
14855
|
+
return readJobLogs(value);
|
|
14856
|
+
}
|
|
14857
|
+
/**
|
|
14858
|
+
* `GET /jobs/{jobId}/logs`, returned as the service's own bytes.
|
|
14859
|
+
*
|
|
14860
|
+
* For a caller who wants the whole trace after the digest showed them where
|
|
14861
|
+
* to look. The text comes from the response body, so it is neither
|
|
14862
|
+
* re-serialized nor re-parsed; the MCP boundary's `relaySafeText` then spills
|
|
14863
|
+
* anything over its cap to a file, which is what makes a 7.5 MB trace
|
|
14864
|
+
* recoverable rather than clipped.
|
|
14865
|
+
*/
|
|
14866
|
+
async getJobLogsText(jobId, signal) {
|
|
14867
|
+
const { text } = await this.fetchLogs(jobId, signal);
|
|
14868
|
+
return text;
|
|
14869
|
+
}
|
|
14870
|
+
async fetchLogs(jobId, signal) {
|
|
14871
|
+
const id = assertJobId(jobId);
|
|
14872
|
+
const result = await this.request("GET", `/jobs/${id}/logs`, {
|
|
14873
|
+
retry: true,
|
|
14874
|
+
cap: MAX_LOGS_BYTES,
|
|
14875
|
+
what: "job logs",
|
|
14876
|
+
...signal ? { signal } : {}
|
|
14877
|
+
});
|
|
14878
|
+
if (!isRecord$1(result.value)) throw new CloudAgentError("Cloud Agent returned job logs that were not an object.", { retriable: true });
|
|
14879
|
+
return result;
|
|
14880
|
+
}
|
|
14881
|
+
/** `GET /plugins` — what a job can load. */
|
|
14882
|
+
async listPlugins(query = {}, signal) {
|
|
14883
|
+
const { value } = await this.request("GET", "/plugins", {
|
|
14884
|
+
query: catalogQueryParams(query),
|
|
14885
|
+
retry: true,
|
|
14886
|
+
cap: MAX_RESPONSE_BYTES,
|
|
14887
|
+
what: "plugin list",
|
|
14888
|
+
...signal ? { signal } : {}
|
|
14889
|
+
});
|
|
14890
|
+
return readPluginPage(value);
|
|
14891
|
+
}
|
|
14892
|
+
/** `GET /agents` — what a `customAgent` can name, and the inputs it needs. */
|
|
14893
|
+
async listAgents(query = {}, signal) {
|
|
14894
|
+
const { value } = await this.request("GET", "/agents", {
|
|
14895
|
+
query: catalogQueryParams(query),
|
|
14896
|
+
retry: true,
|
|
14897
|
+
cap: MAX_RESPONSE_BYTES,
|
|
14898
|
+
what: "agent list",
|
|
14899
|
+
...signal ? { signal } : {}
|
|
14900
|
+
});
|
|
14901
|
+
return readAgentPage(value);
|
|
14902
|
+
}
|
|
14903
|
+
/**
|
|
14904
|
+
* `GET /models` — what a job's `modelConfiguration.model` may name.
|
|
14905
|
+
*
|
|
14906
|
+
* Undocumented but live (measured 2026-10-31): the response is global, so
|
|
14907
|
+
* repository and organization filters are not accepted here at all.
|
|
14908
|
+
*/
|
|
14909
|
+
async listModels(signal) {
|
|
14910
|
+
const { value } = await this.request("GET", "/models", {
|
|
14911
|
+
retry: true,
|
|
14912
|
+
cap: MAX_RESPONSE_BYTES,
|
|
14913
|
+
what: "model list",
|
|
14914
|
+
...signal ? { signal } : {}
|
|
14915
|
+
});
|
|
14916
|
+
return readModelList(value);
|
|
14917
|
+
}
|
|
14918
|
+
};
|
|
14919
|
+
function catalogQueryParams(query) {
|
|
14920
|
+
if (query.top !== void 0) {
|
|
14921
|
+
if (!Number.isInteger(query.top) || query.top < 1 || query.top > 100) throw new CloudAgentError(`\`top\` must be an integer from 1 to 100; the service rejects a larger page. Use \`skip\` to page through the rest.`, { retriable: false });
|
|
14922
|
+
}
|
|
14923
|
+
if (query.skip !== void 0 && (!Number.isInteger(query.skip) || query.skip < 0)) throw new CloudAgentError("`skip` must be a non-negative integer.", { retriable: false });
|
|
14924
|
+
return {
|
|
14925
|
+
type: query.type,
|
|
14926
|
+
organization: query.organization,
|
|
14927
|
+
project: query.project,
|
|
14928
|
+
repository: query.repository,
|
|
14929
|
+
branch: query.branch,
|
|
14930
|
+
top: query.top,
|
|
14931
|
+
skip: query.skip
|
|
14932
|
+
};
|
|
14933
|
+
}
|
|
14934
|
+
/**
|
|
14935
|
+
* A job id is interpolated into the request path, so a value containing `/` or
|
|
14936
|
+
* `..` would silently address a different endpoint. The service's ids are
|
|
14937
|
+
* GUID-shaped; this accepts that plus a conservative superset.
|
|
14938
|
+
*/
|
|
14939
|
+
/** `"/jobs/<id>"` or `"/jobs/<id>/logs"` → `<id>`; any other path → `null`. */
|
|
14940
|
+
function jobIdFromPath(path) {
|
|
14941
|
+
const match = /^\/jobs\/([^/]+)/.exec(path);
|
|
14942
|
+
return match?.[1] ? decodeURIComponent(match[1]) : null;
|
|
14943
|
+
}
|
|
14944
|
+
function assertJobId(jobId) {
|
|
14945
|
+
const trimmed = jobId.trim();
|
|
14946
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(trimmed)) throw new CloudAgentError("`jobId` is not a valid Cloud Agent job id. Pass the value returned by create_job, or list_jobs to find it.", { retriable: false });
|
|
14947
|
+
return trimmed;
|
|
14948
|
+
}
|
|
14949
|
+
function cloudAgentErrorDetail(text) {
|
|
14950
|
+
const trimmed = text.trim();
|
|
14951
|
+
if (!trimmed) return "no detail";
|
|
14952
|
+
try {
|
|
14953
|
+
const parsed = JSON.parse(trimmed);
|
|
14954
|
+
if (typeof parsed === "string" && parsed.trim()) return sanitizeRemoteDetail(parsed.trim()).slice(0, 800);
|
|
14955
|
+
if (isRecord$1(parsed)) {
|
|
14956
|
+
for (const key of [
|
|
14957
|
+
"message",
|
|
14958
|
+
"detail",
|
|
14959
|
+
"title",
|
|
14960
|
+
"error"
|
|
14961
|
+
]) {
|
|
14962
|
+
const value = parsed[key];
|
|
14963
|
+
if (typeof value === "string" && value.trim()) return sanitizeRemoteDetail(value).slice(0, 800);
|
|
14964
|
+
if (isRecord$1(value) && typeof value.message === "string" && value.message.trim()) return sanitizeRemoteDetail(value.message).slice(0, 800);
|
|
14965
|
+
}
|
|
14966
|
+
const errors = parsed.errors;
|
|
14967
|
+
if (Array.isArray(errors) && errors.length > 0) {
|
|
14968
|
+
const messages = errors.map((entry) => typeof entry === "string" ? entry : isRecord$1(entry) && typeof entry.message === "string" ? entry.message : "").filter((entry) => entry.trim().length > 0);
|
|
14969
|
+
if (messages.length > 0) return sanitizeRemoteDetail(messages.join("; ")).slice(0, 800);
|
|
14970
|
+
}
|
|
14971
|
+
}
|
|
14972
|
+
} catch {}
|
|
14973
|
+
return sanitizeRemoteDetail(trimmed).slice(0, 800);
|
|
14974
|
+
}
|
|
14975
|
+
/**
|
|
14976
|
+
* Token source: explicit env first (tests/manual), else the `az` ladder.
|
|
14977
|
+
*
|
|
14978
|
+
* `allowInteractiveLogin` is FALSE, unlike the Kusto client. The group can be
|
|
14979
|
+
* enabled by repository discovery rather than by an explicit operator flag, and
|
|
14980
|
+
* it can be reached from inside a spawned `claude` session where a device-code
|
|
14981
|
+
* prompt is invisible to the user and reads as a hang on a tool call that was
|
|
14982
|
+
* supposed to return in seconds. A missing or expired session therefore fails
|
|
14983
|
+
* fast with `describeAzFailure`'s "run `az login`" advice instead of opening a
|
|
14984
|
+
* browser nobody is looking at.
|
|
14985
|
+
*/
|
|
14986
|
+
async function getCloudAgentToken(resource, signal) {
|
|
14987
|
+
if (signal?.aborted) throw signal.reason ?? /* @__PURE__ */ new Error("aborted");
|
|
14988
|
+
const env = process.env[CLOUDAGENT_TOKEN_ENV]?.trim();
|
|
14989
|
+
if (env) return env;
|
|
14990
|
+
try {
|
|
14991
|
+
return await cloudAgentTokenCache.get(resource, {
|
|
14992
|
+
...signal ? { signal } : {},
|
|
14993
|
+
allowInteractiveLogin: false
|
|
14994
|
+
});
|
|
14995
|
+
} catch (err) {
|
|
14996
|
+
if (signal?.aborted) throw signal.reason ?? /* @__PURE__ */ new Error("aborted");
|
|
14997
|
+
throw new CloudAgentError(describeAzFailure("Cloud Agent", err), { retriable: false });
|
|
14998
|
+
}
|
|
14999
|
+
}
|
|
15000
|
+
//#endregion
|
|
15001
|
+
//#region src/lib/cloudagent-tools.ts
|
|
15002
|
+
const CLOUDAGENT_GROUP = "cloudagent";
|
|
15003
|
+
const CLOUDAGENT_DEFAULT_TIER = "normal";
|
|
15004
|
+
const CLOUDAGENT_TIERS = [
|
|
15005
|
+
"easy",
|
|
15006
|
+
"normal",
|
|
15007
|
+
"complex"
|
|
15008
|
+
];
|
|
15009
|
+
/**
|
|
15010
|
+
* The model and reasoning effort each `create_job` tier runs on.
|
|
15011
|
+
*
|
|
15012
|
+
* Measured against the live `GET /models` catalog on 2026-10-31: all three ids
|
|
15013
|
+
* exist and all three accept `max`. `claude-opus-4.8-fast` is flagged
|
|
15014
|
+
* `preview: true` there, which the tool description says out loud rather than
|
|
15015
|
+
* hiding — a preview model can change under the same id.
|
|
15016
|
+
*
|
|
15017
|
+
* Deliberately NOT derived from the catalog at call time. The catalog has 25
|
|
15018
|
+
* entries and no quality ordering, so no default can be computed from it;
|
|
15019
|
+
* picking one and stating it is the only honest option. A preset whose id has
|
|
15020
|
+
* disappeared fails loudly at the service (a 400 naming the model) instead of
|
|
15021
|
+
* silently drifting to whatever looks closest, and `list_models` is the check
|
|
15022
|
+
* a caller runs first in an unfamiliar environment.
|
|
15023
|
+
*/
|
|
15024
|
+
const CLOUDAGENT_TIER_MODELS = Object.freeze({
|
|
15025
|
+
easy: {
|
|
15026
|
+
model: "claude-opus-4.8-fast",
|
|
15027
|
+
reasoningEffort: "max"
|
|
15028
|
+
},
|
|
15029
|
+
normal: {
|
|
15030
|
+
model: "gpt-6-astra",
|
|
15031
|
+
reasoningEffort: "max"
|
|
15032
|
+
},
|
|
15033
|
+
complex: {
|
|
15034
|
+
model: "claude-opus-5.5",
|
|
15035
|
+
reasoningEffort: "max"
|
|
15036
|
+
}
|
|
15037
|
+
});
|
|
15038
|
+
/**
|
|
15039
|
+
* The plugin that makes a pull-request job possible: branch, commit, push,
|
|
15040
|
+
* open and validate a pull request, watch checks, and edit work items.
|
|
15041
|
+
*
|
|
15042
|
+
* Measured live on 2026-10-31: `Company` scope, `enabledByDefault: false`, and
|
|
15043
|
+
* the whole 235-entry catalog has no default-enabled plugin at all. So the
|
|
15044
|
+
* capability is requested explicitly rather than inherited, and a rename shows
|
|
15045
|
+
* up as a synchronous 400 naming the plugin (`list_plugins` is the check).
|
|
15046
|
+
*/
|
|
15047
|
+
const AGENCY_CODING_PLUGIN = "agency-coding";
|
|
15048
|
+
/**
|
|
15049
|
+
* The plugin that reviews the pull request the coding plugin opened.
|
|
15050
|
+
*
|
|
15051
|
+
* Catalog description, measured live on 2026-11-01: "Bundles the review
|
|
15052
|
+
* orchestrator and specialist reviewer agents plus supporting skills (diff
|
|
15053
|
+
* preparation, reviewer planning and dispatch, deduplication, and
|
|
15054
|
+
* finding/comment reconciliation) that produce guideline-based feedback and post
|
|
15055
|
+
* it to the PR via the `ado` MCP." That is the scoped, parallel, bounded review
|
|
15056
|
+
* the workflow asks for, already built, so the directive names this plugin
|
|
15057
|
+
* rather than describing a review process the model would have to improvise.
|
|
15058
|
+
*
|
|
15059
|
+
* `Company` scope, `enabledByDefault: false`, like `agency-coding`: requested
|
|
15060
|
+
* explicitly, and a rename shows up as a synchronous 400 naming the plugin
|
|
15061
|
+
* (`list_plugins` is the check).
|
|
15062
|
+
*/
|
|
15063
|
+
const AGENCY_REVIEW_PLUGIN = "agency-review";
|
|
15064
|
+
/**
|
|
15065
|
+
* `create_pr_job` runs on the `complex` preset. Turning a ticket into a
|
|
15066
|
+
* review-ready pull request is long-horizon work by definition, which is what
|
|
15067
|
+
* that preset is for; `create_job` keeps its own `normal` default.
|
|
15068
|
+
*/
|
|
15069
|
+
const PR_JOB_DEFAULT_TIER = "complex";
|
|
15070
|
+
/**
|
|
15071
|
+
* Long enough for a specific change description, short enough that `list_jobs`
|
|
15072
|
+
* and the job page show all of it. The value is also the pull request title, and
|
|
15073
|
+
* Azure DevOps caps those at 400 characters, so nothing here is fighting a
|
|
15074
|
+
* service limit: this is a readability bound.
|
|
15075
|
+
*/
|
|
15076
|
+
const PR_JOB_TITLE_MAX = 100;
|
|
15077
|
+
/**
|
|
15078
|
+
* One client per environment, built lazily.
|
|
15079
|
+
*
|
|
15080
|
+
* There is no per-call environment argument and no configurable base URL: the
|
|
15081
|
+
* bearer token's Entra audience and the request destination are the same origin
|
|
15082
|
+
* by construction, so nothing the model writes can point the token at another
|
|
15083
|
+
* host. The environment (prod/ppe) is a launch decision (`--cloudagent-env`), which
|
|
15084
|
+
* is the `COPILOT_HOST_ALLOWLIST` argument applied by removing the knob rather
|
|
15085
|
+
* than validating it.
|
|
15086
|
+
*/
|
|
15087
|
+
const clients = /* @__PURE__ */ new Map();
|
|
15088
|
+
function cloudAgentClient() {
|
|
15089
|
+
const environment = normalizeCloudAgentEnvironment(state.cloudAgentEnvironment ?? "prod");
|
|
15090
|
+
const existing = clients.get(environment);
|
|
15091
|
+
if (existing) return existing;
|
|
15092
|
+
const client = new CloudAgentClient({ environment });
|
|
15093
|
+
clients.set(environment, client);
|
|
15094
|
+
return client;
|
|
15095
|
+
}
|
|
15096
|
+
let repoIdResolver = resolveAzureRepoIds;
|
|
15097
|
+
/**
|
|
15098
|
+
* Process-lifetime cache of a terminal job's deliverable, keyed by environment
|
|
15099
|
+
* and job id.
|
|
15100
|
+
*
|
|
15101
|
+
* `null` is meaningful and is why `Map.has` is never used as the predicate: it
|
|
15102
|
+
* records "the trace was read and it has no summary", which is the common case
|
|
15103
|
+
* for a FAILED job. Without the negative entry every poll of a failed job would
|
|
15104
|
+
* re-download a multi-megabyte trace to learn the same nothing.
|
|
15105
|
+
*
|
|
15106
|
+
* Bounded because job ids are unbounded and each value can be a long model
|
|
15107
|
+
* summary; FIFO eviction is enough — a re-read is one request, not a
|
|
15108
|
+
* correctness problem.
|
|
15109
|
+
*/
|
|
15110
|
+
const summaryCache = /* @__PURE__ */ new Map();
|
|
15111
|
+
const SUMMARY_CACHE_MAX = 64;
|
|
15112
|
+
function cachedSummary(key) {
|
|
15113
|
+
if (!summaryCache.has(key)) return { hit: false };
|
|
15114
|
+
return {
|
|
15115
|
+
hit: true,
|
|
15116
|
+
summary: summaryCache.get(key) ?? null
|
|
15117
|
+
};
|
|
15118
|
+
}
|
|
15119
|
+
function storeSummary(key, summary) {
|
|
15120
|
+
if (summaryCache.size >= SUMMARY_CACHE_MAX) {
|
|
15121
|
+
const oldest = summaryCache.keys().next();
|
|
15122
|
+
if (!oldest.done) summaryCache.delete(oldest.value);
|
|
15123
|
+
}
|
|
15124
|
+
summaryCache.set(key, summary);
|
|
15125
|
+
}
|
|
15126
|
+
async function text(value) {
|
|
15127
|
+
return { content: [{
|
|
15128
|
+
type: "text",
|
|
15129
|
+
text: await relaySafeText(value)
|
|
15130
|
+
}] };
|
|
15131
|
+
}
|
|
15132
|
+
function isPlainObject(value) {
|
|
15133
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15134
|
+
}
|
|
15135
|
+
function requiredString(args, key) {
|
|
15136
|
+
const value = args[key];
|
|
15137
|
+
if (typeof value !== "string" || !value.trim()) throw new CloudAgentError(`\`${key}\` is required and must be a non-empty string.`, { retriable: false });
|
|
15138
|
+
return value.trim();
|
|
15139
|
+
}
|
|
15140
|
+
function optionalString(args, key) {
|
|
15141
|
+
const value = args[key];
|
|
15142
|
+
if (value === void 0 || value === null) return void 0;
|
|
15143
|
+
if (typeof value !== "string") throw new CloudAgentError(`\`${key}\` must be a string when provided.`, { retriable: false });
|
|
15144
|
+
const trimmed = value.trim();
|
|
15145
|
+
return trimmed ? trimmed : void 0;
|
|
15146
|
+
}
|
|
15147
|
+
function optionalInt(args, key, min, max) {
|
|
15148
|
+
const value = args[key];
|
|
15149
|
+
if (value === void 0 || value === null) return void 0;
|
|
15150
|
+
if (value === 0 && min > 0) return void 0;
|
|
15151
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < min || value > max) throw new CloudAgentError(`\`${key}\` must be an integer from ${min} to ${max}.`, { retriable: false });
|
|
15152
|
+
return value;
|
|
15153
|
+
}
|
|
15154
|
+
function oneLine(value, max) {
|
|
15155
|
+
const single = value.replace(/\s*\r?\n\s*/g, " ⏎ ");
|
|
15156
|
+
return single.length > max ? `${single.slice(0, max)}…` : single;
|
|
15157
|
+
}
|
|
15158
|
+
function provenanceLine(repository) {
|
|
15159
|
+
if (!repository.inferredFrom) return void 0;
|
|
15160
|
+
return `[repository: ${[
|
|
15161
|
+
repository.organization,
|
|
15162
|
+
repository.project,
|
|
15163
|
+
repository.repository
|
|
15164
|
+
].filter((part) => part !== void 0).join("/")} (inferred from ${repository.inferredFrom})]`;
|
|
15165
|
+
}
|
|
15166
|
+
/** The three components together, or none of them. A partial set is a typo. */
|
|
15167
|
+
function repositoryFromArgs(args) {
|
|
15168
|
+
const organization = optionalString(args, "organization");
|
|
15169
|
+
const project = optionalString(args, "project");
|
|
15170
|
+
const repository = optionalString(args, "repository");
|
|
15171
|
+
const given = [
|
|
15172
|
+
organization,
|
|
15173
|
+
project,
|
|
15174
|
+
repository
|
|
15175
|
+
].filter((part) => part !== void 0).length;
|
|
15176
|
+
if (given === 0) return void 0;
|
|
15177
|
+
if (given < 3) throw new CloudAgentError("Pass all of `organization`, `project` and `repository`, or none of them and let the repository be read from a checkout. A partial set would either be guessed or silently ignored.", { retriable: false });
|
|
15178
|
+
return {
|
|
15179
|
+
organization,
|
|
15180
|
+
project,
|
|
15181
|
+
repository
|
|
15182
|
+
};
|
|
15183
|
+
}
|
|
15184
|
+
/**
|
|
15185
|
+
* The repository a job runs against: the explicit triple, else whatever the
|
|
15186
|
+
* `workspace` checkout's git remote says.
|
|
15187
|
+
*
|
|
15188
|
+
* The workspace is resolved by the MCP boundary (`X-GH-Workspace`, or the
|
|
15189
|
+
* caller's own argument), and `ctx.workspaceSource` records which — that is the
|
|
15190
|
+
* difference between "you told me" and "I guessed", and only the guess gets a
|
|
15191
|
+
* provenance line. There is deliberately no `process.cwd()` fallback for
|
|
15192
|
+
* `create_job`: the proxy is started once from wherever the operator was, so a
|
|
15193
|
+
* stale cwd would spend real compute filing a job against the wrong repository.
|
|
15194
|
+
*
|
|
15195
|
+
* A FILTER is a different question with its own resolver
|
|
15196
|
+
* (`resolveRepositoryFilter`): it may name only the organization, and a
|
|
15197
|
+
* checkout it cannot read is reported as the reason the filter was dropped
|
|
15198
|
+
* rather than failing the call. Treating that as an error was tried and is
|
|
15199
|
+
* wrong in practice: a model that names its checkout on every call (Claude
|
|
15200
|
+
* Code fills optional properties rather than omitting them) turned every
|
|
15201
|
+
* `list_jobs` in a non-Azure-DevOps repository into an error, for a filter it
|
|
15202
|
+
* did not need.
|
|
15203
|
+
*/
|
|
15204
|
+
async function resolveRepository(args, ctx, opts) {
|
|
15205
|
+
const explicit = repositoryFromArgs(args);
|
|
15206
|
+
if (explicit) return explicit;
|
|
15207
|
+
const { repository } = await repositoryFromWorkspace(args, ctx, {
|
|
15208
|
+
required: true,
|
|
15209
|
+
...opts
|
|
15210
|
+
});
|
|
15211
|
+
return repository;
|
|
15212
|
+
}
|
|
15213
|
+
/**
|
|
15214
|
+
* Read the repository off the named `workspace`'s git remote. `required`
|
|
15215
|
+
* decides whether a missing or unreadable checkout fails the call or is
|
|
15216
|
+
* reported back as the reason the repository was not used.
|
|
15217
|
+
*/
|
|
15218
|
+
async function repositoryFromWorkspace(args, ctx, opts) {
|
|
15219
|
+
const workspace = optionalString(args, "workspace");
|
|
15220
|
+
const hint = opts.requiredHint ?? "`organization`, `project` and `repository`";
|
|
15221
|
+
if (!workspace) {
|
|
15222
|
+
if (!opts.required) return {};
|
|
15223
|
+
throw new CloudAgentError(`No repository: pass ${hint}, or \`workspace\` pointing at a checkout whose git remote is an Azure DevOps repository.`, { retriable: false });
|
|
15224
|
+
}
|
|
15225
|
+
if (!/^(?:[A-Za-z]:[\\/]|[\\/])/.test(workspace)) throw new CloudAgentError(`\`workspace\` must be an absolute path; got "${workspace}".`, { retriable: false });
|
|
15226
|
+
try {
|
|
15227
|
+
const info = await getAzureRepoFromGit(workspace, opts.signal);
|
|
15228
|
+
return { repository: {
|
|
15229
|
+
organization: info.organization,
|
|
15230
|
+
project: info.project,
|
|
15231
|
+
repository: info.repository,
|
|
15232
|
+
inferredFrom: ctx?.workspaceSource === "session" ? "this session's workspace" : "the workspace you passed"
|
|
15233
|
+
} };
|
|
15234
|
+
} catch (err) {
|
|
15235
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
15236
|
+
if (opts.required) throw new CloudAgentError(`Could not read an Azure DevOps repository from "${workspace}": ${detail} Pass \`organization\`, \`project\` and \`repository\` explicitly to skip the lookup.`, { retriable: false });
|
|
15237
|
+
return { unresolvedDetail: `Could not read an Azure DevOps repository from "${workspace}": ${detail}` };
|
|
15238
|
+
}
|
|
15239
|
+
}
|
|
15240
|
+
function repositoryFilterFromArgs(args) {
|
|
15241
|
+
const organization = optionalString(args, "organization");
|
|
15242
|
+
const project = optionalString(args, "project");
|
|
15243
|
+
const repository = optionalString(args, "repository");
|
|
15244
|
+
if (organization === void 0) {
|
|
15245
|
+
if (project !== void 0 || repository !== void 0) throw new CloudAgentError("`project` and `repository` narrow within an `organization`, so pass `organization` with them. Omit all three to list every job this account can see, or to fall back to the workspace's repository.", { retriable: false });
|
|
15246
|
+
return;
|
|
15247
|
+
}
|
|
15248
|
+
if (project === void 0 && repository !== void 0) throw new CloudAgentError("`repository` narrows within a `project`, so pass `organization` and `project` with it, or omit it to list every job in the project.", { retriable: false });
|
|
15249
|
+
return {
|
|
15250
|
+
organization,
|
|
15251
|
+
project,
|
|
15252
|
+
repository
|
|
15253
|
+
};
|
|
15254
|
+
}
|
|
15255
|
+
async function resolveRepositoryFilter(args, ctx, signal) {
|
|
15256
|
+
const explicit = repositoryFilterFromArgs(args);
|
|
15257
|
+
if (explicit) return { filter: explicit };
|
|
15258
|
+
const resolution = await repositoryFromWorkspace(args, ctx, {
|
|
15259
|
+
required: false,
|
|
15260
|
+
signal
|
|
15261
|
+
});
|
|
15262
|
+
const inferred = resolution.repository;
|
|
15263
|
+
if (!inferred) return { unresolvedDetail: resolution.unresolvedDetail };
|
|
15264
|
+
return { filter: {
|
|
15265
|
+
organization: inferred.organization,
|
|
15266
|
+
project: inferred.project,
|
|
15267
|
+
repository: inferred.repository,
|
|
15268
|
+
inferredFrom: inferred.inferredFrom
|
|
15269
|
+
} };
|
|
15270
|
+
}
|
|
15271
|
+
const AGENT_TYPES = [
|
|
15272
|
+
"Repo",
|
|
15273
|
+
"Organization",
|
|
15274
|
+
"Company",
|
|
15275
|
+
"Spec"
|
|
15276
|
+
];
|
|
15277
|
+
function agentTypeValue(args, key) {
|
|
15278
|
+
const value = optionalString(args, key);
|
|
15279
|
+
if (!value) return void 0;
|
|
15280
|
+
const match = AGENT_TYPES.find((type) => type.toLowerCase() === value.toLowerCase());
|
|
15281
|
+
if (!match) throw new CloudAgentError(`\`${key}\` must be one of ${AGENT_TYPES.join(", ")}.`, { retriable: false });
|
|
15282
|
+
return match;
|
|
15283
|
+
}
|
|
15284
|
+
function agentTypeArg(args) {
|
|
15285
|
+
return agentTypeValue(args, "agentType");
|
|
15286
|
+
}
|
|
15287
|
+
function agentInputsArg(args) {
|
|
15288
|
+
const value = args.agentInputs;
|
|
15289
|
+
if (value === void 0 || value === null) return void 0;
|
|
15290
|
+
if (!isPlainObject(value)) throw new CloudAgentError("`agentInputs` must be an object of scalar values.", { retriable: false });
|
|
15291
|
+
const inputs = {};
|
|
15292
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
15293
|
+
if (typeof entry === "string" || typeof entry === "number" || typeof entry === "boolean") {
|
|
15294
|
+
inputs[key] = entry;
|
|
15295
|
+
continue;
|
|
15296
|
+
}
|
|
15297
|
+
throw new CloudAgentError(`\`agentInputs.${key}\` must be a string, number or boolean.`, { retriable: false });
|
|
15298
|
+
}
|
|
15299
|
+
return Object.keys(inputs).length > 0 ? inputs : void 0;
|
|
15300
|
+
}
|
|
15301
|
+
function pluginsArg(args) {
|
|
15302
|
+
const value = args.plugins;
|
|
15303
|
+
if (value === void 0 || value === null) return void 0;
|
|
15304
|
+
if (!Array.isArray(value)) throw new CloudAgentError("`plugins` must be an array of plugin names.", { retriable: false });
|
|
15305
|
+
const plugins = [];
|
|
15306
|
+
for (const entry of value) {
|
|
15307
|
+
if (typeof entry !== "string" || !entry.trim()) throw new CloudAgentError("Every entry of `plugins` must be a non-empty plugin name.", { retriable: false });
|
|
15308
|
+
plugins.push({ name: entry.trim() });
|
|
15309
|
+
}
|
|
15310
|
+
return plugins.length > 0 ? plugins : void 0;
|
|
15311
|
+
}
|
|
15312
|
+
function metadataArg(args) {
|
|
15313
|
+
const value = args.metadata;
|
|
15314
|
+
if (value === void 0 || value === null) return void 0;
|
|
15315
|
+
if (!isPlainObject(value)) throw new CloudAgentError("`metadata` must be an object of short string labels, e.g. {\"chain\": \"research\", \"step\": \"1\"}.", { retriable: false });
|
|
15316
|
+
return value;
|
|
15317
|
+
}
|
|
15318
|
+
/**
|
|
15319
|
+
* Echo the normalized body the service received.
|
|
15320
|
+
*
|
|
15321
|
+
* This is what makes a follow-up job a follow-up: `GET /jobs/{id}` does not
|
|
15322
|
+
* return `modelConfiguration`, so nothing else can tell the caller which effort
|
|
15323
|
+
* and context tier the first job used. Showing it turns "inherit the settings"
|
|
15324
|
+
* into "copy these lines", which is verifiable instead of hoped for.
|
|
15325
|
+
*/
|
|
15326
|
+
function renderEffectiveRequest(request) {
|
|
15327
|
+
const lines = [];
|
|
15328
|
+
const repository = request.context.repository;
|
|
15329
|
+
const branch = repository.branch ? ` branch ${repository.branch}` : "";
|
|
15330
|
+
lines.push(` repository: ${repository.organization}/${repository.project}/${repository.repository}${branch}`);
|
|
15331
|
+
if (request.prompt) lines.push(` prompt: ${oneLine(request.prompt, 300)}`);
|
|
15332
|
+
if (request.customAgent) {
|
|
15333
|
+
const agent = request.customAgent;
|
|
15334
|
+
const parts = [` agent: ${agent.name}`];
|
|
15335
|
+
if (agent.type) parts.push(`(${agent.type})`);
|
|
15336
|
+
if (agent.pluginName) parts.push(`from plugin ${agent.pluginName}`);
|
|
15337
|
+
if (agent.inputs) {
|
|
15338
|
+
const inputs = Object.entries(agent.inputs).map(([key, value]) => `${key}=${String(value)}`);
|
|
15339
|
+
parts.push(`inputs: ${inputs.join(", ")}`);
|
|
15340
|
+
}
|
|
15341
|
+
lines.push(parts.join(" "));
|
|
15342
|
+
}
|
|
15343
|
+
if (request.plugins) lines.push(` plugins: ${request.plugins.map((plugin) => plugin.name).join(", ")}`);
|
|
15344
|
+
if (request.additionalOptions?.pluginOptions?.includeDefaults) lines.push(" default plugins: included");
|
|
15345
|
+
const model = request.modelConfiguration;
|
|
15346
|
+
if (model) {
|
|
15347
|
+
const parts = [];
|
|
15348
|
+
if (model.model) parts.push(`model ${model.model}`);
|
|
15349
|
+
if (model.reasoningEffort) parts.push(`effort ${model.reasoningEffort}`);
|
|
15350
|
+
if (model.context) parts.push(`context ${model.context}`);
|
|
15351
|
+
if (parts.length > 0) lines.push(` ${parts.join(", ")}`);
|
|
15352
|
+
}
|
|
15353
|
+
if (request.metadata) {
|
|
15354
|
+
const labels = Object.entries(request.metadata).map(([key, value]) => `${key}=${value}`);
|
|
15355
|
+
lines.push(` metadata: ${labels.join(" ")}`);
|
|
15356
|
+
}
|
|
15357
|
+
return lines.join("\n");
|
|
15358
|
+
}
|
|
15359
|
+
/**
|
|
15360
|
+
* The plan caps this at 50 s. Two reasons, and the second is the real one:
|
|
15361
|
+
* a raw-JSON MCP client is capped at ~60 s per call (Claude Code regression
|
|
15362
|
+
* #50289), and no wait that fits in one call can observe a terminal state anyway
|
|
15363
|
+
* — across 161 jobs none finished in under 60 seconds and the shortest took 3
|
|
15364
|
+
* minutes. So the contract is deliberately
|
|
15365
|
+
* "did the handoff take, or is this stuck in the queue?", which is the one
|
|
15366
|
+
* question a short wait can actually answer.
|
|
15367
|
+
*/
|
|
15368
|
+
const WAIT_DEFAULT_S = 25;
|
|
15369
|
+
const WAIT_MAX_S = 50;
|
|
15370
|
+
const WAIT_POLL_MS = 3e3;
|
|
15371
|
+
function sleep(ms, signal) {
|
|
15372
|
+
return new Promise((resolve, reject) => {
|
|
15373
|
+
if (signal?.aborted) {
|
|
15374
|
+
reject(/* @__PURE__ */ new Error("wait_for_job was cancelled."));
|
|
15375
|
+
return;
|
|
15376
|
+
}
|
|
15377
|
+
const timer = setTimeout(() => {
|
|
15378
|
+
signal?.removeEventListener("abort", onAbort);
|
|
15379
|
+
resolve();
|
|
15380
|
+
}, ms);
|
|
15381
|
+
function onAbort() {
|
|
15382
|
+
clearTimeout(timer);
|
|
15383
|
+
reject(/* @__PURE__ */ new Error("wait_for_job was cancelled."));
|
|
15384
|
+
}
|
|
15385
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
15386
|
+
});
|
|
15387
|
+
}
|
|
15388
|
+
const WORKSPACE_PROPERTY = { workspace: {
|
|
15389
|
+
type: "string",
|
|
15390
|
+
description: "Absolute path to a checkout whose git remote identifies the Azure DevOps repository. Default: the session workspace, when the client sends one; the repository is then read from that checkout's git remote."
|
|
15391
|
+
} };
|
|
15392
|
+
/**
|
|
15393
|
+
* One optional repository, split across the three fields the API takes.
|
|
15394
|
+
*
|
|
15395
|
+
* All three are omitted together in the normal case: the workspace's git remote
|
|
15396
|
+
* supplies them and the result says so. They exist for the case where there is
|
|
15397
|
+
* no checkout to read, so the descriptions have to keep a model from filling
|
|
15398
|
+
* one or two of them as if they were independent filters.
|
|
15399
|
+
*/
|
|
15400
|
+
const REPOSITORY_PROPERTIES = {
|
|
15401
|
+
organization: {
|
|
15402
|
+
type: "string",
|
|
15403
|
+
description: "Azure DevOps organization. Default: read from `workspace`'s git remote. Omit it together with `project` and `repository` unless there is no checkout to read; a partial set is a failed call, not a partial filter."
|
|
15404
|
+
},
|
|
15405
|
+
project: {
|
|
15406
|
+
type: "string",
|
|
15407
|
+
description: "Azure DevOps project. Default: read from `workspace`'s git remote. Only with `organization` and `repository`."
|
|
15408
|
+
},
|
|
15409
|
+
repository: {
|
|
15410
|
+
type: "string",
|
|
15411
|
+
description: "Repository name inside the project. Default: read from `workspace`'s git remote. Only with `organization` and `project`."
|
|
15412
|
+
}
|
|
15413
|
+
};
|
|
15414
|
+
/**
|
|
15415
|
+
* The same three names, as a FILTER rather than a job target.
|
|
15416
|
+
*
|
|
15417
|
+
* The shapes differ on purpose. A job needs one exact repository, so its three
|
|
15418
|
+
* fields are all-or-none. A filter is a narrowing, and the service matches the
|
|
15419
|
+
* organization by name, so naming only the organization is both legal and
|
|
15420
|
+
* useful; the project and repository then narrow within it. Each description
|
|
15421
|
+
* says what its default is and what it overlays, because a model that cannot
|
|
15422
|
+
* see the handler will otherwise fill in a guess.
|
|
15423
|
+
*/
|
|
15424
|
+
const FILTER_REPOSITORY_PROPERTIES = {
|
|
15425
|
+
organization: {
|
|
15426
|
+
type: "string",
|
|
15427
|
+
description: "Azure DevOps organization to narrow to. Default: read from `workspace`'s git remote. Pass it alone to list every job in the organization."
|
|
15428
|
+
},
|
|
15429
|
+
project: {
|
|
15430
|
+
type: "string",
|
|
15431
|
+
description: "Azure DevOps project name, within `organization`. Default: the project read from `workspace`'s git remote. Requires `organization`."
|
|
15432
|
+
},
|
|
15433
|
+
repository: {
|
|
15434
|
+
type: "string",
|
|
15435
|
+
description: "Repository name within `project`. Default: the repository read from `workspace`'s git remote. Requires `organization` and `project`."
|
|
15436
|
+
}
|
|
15437
|
+
};
|
|
15438
|
+
/**
|
|
15439
|
+
* The same three names again, as the Azure DevOps CONTEXT a catalog scope reads.
|
|
15440
|
+
*
|
|
15441
|
+
* Measured live (2026-10-30), and the scopes do NOT want the same thing:
|
|
15442
|
+
*
|
|
15443
|
+
* - `Repo` reads one repository, so it needs all three. Organization alone earns
|
|
15444
|
+
* "ProjectName in Azure DevOps context is required for Repo agents/plugins",
|
|
15445
|
+
* organization+project earns "RepositoryName ... is required", and
|
|
15446
|
+
* organization+repository earns "Project is required when Repository is
|
|
15447
|
+
* specified."
|
|
15448
|
+
* - `Organization` reads an organization's own marketplace, so the organization
|
|
15449
|
+
* alone is enough: org-only, org+project, org+repository and the full triple
|
|
15450
|
+
* all answer identically. Demanding the other two here would make a caller
|
|
15451
|
+
* with no checkout invent names the service never reads.
|
|
15452
|
+
* - Company, Spec and untyped calls read no context at all.
|
|
15453
|
+
*
|
|
15454
|
+
* So the descriptions state per scope which names are required rather than
|
|
15455
|
+
* borrowing create_job's all-or-none job-target wording, which would read as if a
|
|
15456
|
+
* plain `list_plugins` call needed a repository.
|
|
15457
|
+
*/
|
|
15458
|
+
const CATALOG_REPOSITORY_PROPERTIES = {
|
|
15459
|
+
organization: {
|
|
15460
|
+
type: "string",
|
|
15461
|
+
description: "Azure DevOps organization the Repo and Organization scopes read. Required for both; the other scopes do not read it. Default: read from `workspace`'s git remote, or from the session workspace's checkout."
|
|
15462
|
+
},
|
|
15463
|
+
project: {
|
|
15464
|
+
type: "string",
|
|
15465
|
+
description: "Azure DevOps project, for the Repo scope. Required there with `organization` and `repository`; the Organization scope and the others do not read it. Default: read from the checkout."
|
|
15466
|
+
},
|
|
15467
|
+
repository: {
|
|
15468
|
+
type: "string",
|
|
15469
|
+
description: "Repository name inside `project`, for the Repo scope. Required there with `organization` and `project`; the Organization scope and the others do not read it. Default: read from the checkout."
|
|
15470
|
+
}
|
|
15471
|
+
};
|
|
15472
|
+
const JOB_ID_PROPERTY = { jobId: {
|
|
15473
|
+
type: "string",
|
|
15474
|
+
description: "The job id returned by create_job or listed by list_jobs."
|
|
15475
|
+
} };
|
|
15476
|
+
/**
|
|
15477
|
+
* The engineering process `create_pr_job` prepends to every task.
|
|
15478
|
+
*
|
|
15479
|
+
* The Job API has no system-prompt field (a live validate probe on 2026-10-31
|
|
15480
|
+
* sent one, got a 200, and the field was ignored and not echoed), so the only
|
|
15481
|
+
* instruction surface is `prompt`. The directive is therefore literal text in
|
|
15482
|
+
* front of the caller's task, and the task is wrapped in <user_task> tags so
|
|
15483
|
+
* "how to work" and "what to build" stay distinguishable inside one string.
|
|
15484
|
+
*
|
|
15485
|
+
* The wording follows the frontier-model guidance current on 2026-11-01:
|
|
15486
|
+
* Anthropic's context-engineering guide, its prompting best practices, and its
|
|
15487
|
+
* Opus 5.5 guide. They reduce to one rule, and it is the rule to apply before
|
|
15488
|
+
* editing this text:
|
|
15489
|
+
*
|
|
15490
|
+
* - EXPLICIT for outcomes, constraints, load-bearing ordering, and
|
|
15491
|
+
* environment facts the model cannot infer. It cannot see that the clone is
|
|
15492
|
+
* ephemeral, that nobody will reply, or which write tools it holds, so those
|
|
15493
|
+
* are stated.
|
|
15494
|
+
* - IMPLICIT for method. The goal is "the smallest set of high-signal tokens
|
|
15495
|
+
* that maximizes the likelihood of the desired outcome", and "minimal does
|
|
15496
|
+
* not necessarily mean short": Claude's reasoning routinely exceeds what a
|
|
15497
|
+
* human would prescribe. So the directive says what good looks like and
|
|
15498
|
+
* leaves the route to the model. That is why there is no "issue parallel
|
|
15499
|
+
* tool calls together" bullet, no prescriptive verification ritual, and no
|
|
15500
|
+
* rule the model already follows.
|
|
15501
|
+
*
|
|
15502
|
+
* Two properties the text must keep:
|
|
15503
|
+
*
|
|
15504
|
+
* - GENERIC. The same tool is called against arbitrary repositories, so the
|
|
15505
|
+
* directive names no organization, project, repository, language or stack.
|
|
15506
|
+
* The one product it names is conditional: `agency-coding` does not bundle
|
|
15507
|
+
* Bluebird (measured 2026-11-01: of the 235 catalog plugins only
|
|
15508
|
+
* `cloudbuild` bundles the Bluebird MCP, and only for CloudBuild failure
|
|
15509
|
+
* diagnosis), so the directive says "use Bluebird semantic / vector search
|
|
15510
|
+
* if available" rather than assuming it.
|
|
15511
|
+
* - NON-OVERRIDING. `# The request` says the request governs what to build and
|
|
15512
|
+
* the directive governs how. Boilerplate may never narrow, widen or replace
|
|
15513
|
+
* a caller's task.
|
|
15514
|
+
*
|
|
15515
|
+
* ORDER IS THE BUG FIX. On 2026-11-01 a job ran 9.19 h, ended
|
|
15516
|
+
* `jobOutcomeType: Succeeded`, and was still classified a failure because it
|
|
15517
|
+
* never committed, pushed or opened a pull request: the earlier text put branch,
|
|
15518
|
+
* commit and push in phase 7, after implementation and two review phases, so a
|
|
15519
|
+
* run that ended early had pushed nothing. The branch is now created and pushed
|
|
15520
|
+
* before any edit exists, and pushes are required at each milestone, so no run
|
|
15521
|
+
* can end holding work that only it has.
|
|
15522
|
+
*
|
|
15523
|
+
* Traceability does not need a version marker. The full directive is stored
|
|
15524
|
+
* verbatim on every job and returned by `get_job` (`prompt:`), and the
|
|
15525
|
+
* structural assertions in tests/cloudagent-tools.test.ts pin it, so a job's
|
|
15526
|
+
* behavior is traceable to the exact text that produced it.
|
|
15527
|
+
*/
|
|
15528
|
+
const PR_JOB_WORKFLOW = `# The request
|
|
15529
|
+
|
|
15530
|
+
The text in <user_task> is the request; the title above names it. It governs what to build; what follows governs how, and never changes what it asks for. Where it is ambiguous, resolve it the way that best serves it and record the assumption. If it seems mistaken, or a better approach exists, say so and continue as asked.
|
|
15531
|
+
|
|
15532
|
+
# Operating context
|
|
15533
|
+
|
|
15534
|
+
One-shot and unattended, with an ephemeral clone: nobody replies while you work, so work that is not pushed does not survive and a turn that ends on a status report has nowhere to go. Put status notes in the same message as your next tool call, keep a checklist of the request's parts, and keep working until every item is done or blocked. Stop only when the pull request is in the shape below or a blocker needs a human, and report the blocker exactly.
|
|
15535
|
+
|
|
15536
|
+
- Repository guidance (AGENTS.md, CLAUDE.md, CONTRIBUTING, build and test docs) is authoritative: read it first, and where it conflicts with this document, follow the repository and note the conflict.
|
|
15537
|
+
- Your tools include the checkout, a shell, Azure DevOps write tools for branches, commits, pushes, pull requests, pipelines and work items, and the review plugin's reviewers.
|
|
15538
|
+
|
|
15539
|
+
# What a good pull request looks like
|
|
15540
|
+
|
|
15541
|
+
Small enough to review in one sitting and complete enough that merging it needs no follow-up: opened from its own branch against the base branch, with a human-voice title and description explaining what changed, why and how it was validated, the work item linked, every required check passing or a precise written explanation for why one cannot, and reviewers of different scopes satisfied that every finding is fixed or recorded with a reason.
|
|
15542
|
+
|
|
15543
|
+
# How to get there
|
|
15544
|
+
|
|
15545
|
+
These phases are a route that has worked, not a checklist to satisfy. Work them in order, parallelizing wherever work is independent.
|
|
15546
|
+
|
|
15547
|
+
## 1. Search, read, understand
|
|
15548
|
+
Search before you read: it finds the call sites, definitions and neighbours that reading one file will not; use Bluebird semantic / vector search if available. Read the code, tests and history the request touches until you can state the current behavior, the constraints and what done means.
|
|
15549
|
+
|
|
15550
|
+
## 2. Research
|
|
15551
|
+
Research what you do not know: the repository's conventions, the libraries and APIs involved, prior art in the codebase, and the documented behavior of anything you depend on. Base claims on files you opened and output you saw.
|
|
15552
|
+
|
|
15553
|
+
## 3. Plan
|
|
15554
|
+
Write one plan: the change surface, the smallest set of edits that satisfies the request, the tests that prove it, and the exact build and test commands. Prefer existing utilities and patterns, and keep the change contained: no side effects on existing behavior where possible, and the fewest possible where not.
|
|
15555
|
+
|
|
15556
|
+
## 4. Review the plan adversarially
|
|
15557
|
+
Hand the plan, the request and your evidence to an independent reviewer in a separate subagent, and ask it to attack the plan: wrong assumptions, missing surfaces, over-scoping, untested paths. Resolve each finding or record why it does not apply, then implement.
|
|
15558
|
+
|
|
15559
|
+
## 5. Implement with verification, validation and testing
|
|
15560
|
+
Create the working branch from the base branch and push it before you change anything, so the write path is proven while the branch is still empty. Make the change the plan describes, with tests that would fail without it, and run the repository's format, build, analyzer and test commands as you go, reading their output rather than assuming it passed. Commit in the repository's message style and push at each coherent milestone and before anything long-running: unpushed work is the only work this run can lose.
|
|
15561
|
+
|
|
15562
|
+
## 6. Create the pull request and link the work item
|
|
15563
|
+
Push any remaining commits and open the pull request, using the job title as its title unless the repository's convention requires another form. Write the description in a human voice, with no attribution trailers such as Co-Authored-By: what changed, why, and how it was validated. Link the work item the request names; when it names none, create one in the project that hosts the repository, following the conventions of nearby work items, and link it. If permissions or missing configuration block creation, record the exact error in the description and continue. If the pipeline does not start on its own, trigger it, so the build runs while the review does.
|
|
15564
|
+
|
|
15565
|
+
## 7. Review the implementation adversarially
|
|
15566
|
+
Review the pull request, not the working tree: the diff a reviewer sees is what ships. The review plugin is loaded; use its orchestrator, which plans scoped reviewers, dispatches them in parallel and reconciles their findings onto the pull request. Give them what you gave the plan reviewer: the request, the plan, and why the change is shaped this way. Ask for everything they see; deciding what matters is your job, not theirs. Address what is real, commit and push, and re-run only the lenses those fixes could affect, recording in one line why a finding does not apply. Stop when they have returned and every finding is fixed or recorded: time matters, and an early correct result beats a late one.
|
|
15567
|
+
|
|
15568
|
+
## 8. Get to a green build
|
|
15569
|
+
Watch the required checks and fix failures until they pass. If one cannot pass because of permissions, credentials, an outage or missing configuration, record its name, its state and the exact step a human must take. With no pull request pipeline, the documented local build and test commands are the green evidence.
|
|
15570
|
+
|
|
15571
|
+
# Reporting
|
|
15572
|
+
|
|
15573
|
+
Your final message is the handoff: the request in one line; the branch and last commit pushed; the pull request id, link and title; the work item id and link; each check with its final state; the commands you ran and their results; what each reviewer found; decisions you made without confirmation and why; and anything open, unverified or blocked, with the exact blocker.
|
|
15574
|
+
|
|
15575
|
+
# Guardrails
|
|
15576
|
+
|
|
15577
|
+
- Keep secrets out of everything you emit or commit; reference .env, *.pem and *.key by path only.
|
|
15578
|
+
- Tests verify correctness, they do not define the solution: implement the general behavior, not the values the tests happen to use.
|
|
15579
|
+
- Leave the pull request open; merging stays with a human.
|
|
15580
|
+
|
|
15581
|
+
# Task`;
|
|
15582
|
+
/**
|
|
15583
|
+
* The title is composed ahead of the directive so the prompt opens with the
|
|
15584
|
+
* job's own name, which is what a human reading `get_job` or the job page sees
|
|
15585
|
+
* first, and what `# The request` refers to when it says "the title above".
|
|
15586
|
+
*/
|
|
15587
|
+
function composePrJobPrompt(task, title) {
|
|
15588
|
+
return `# Title\n\n${title}\n\n${PR_JOB_WORKFLOW}\n\n<user_task>\n${task.trim()}\n</user_task>`;
|
|
15589
|
+
}
|
|
15590
|
+
const CLOUDAGENT_TOOLS = Object.freeze([
|
|
15591
|
+
{
|
|
15592
|
+
toolNameHttp: "create_job",
|
|
15593
|
+
group: CLOUDAGENT_GROUP,
|
|
15594
|
+
capability: "cloudagent_write",
|
|
15595
|
+
description: "Runs an autonomous coding agent in the Microsoft cloud against an Azure DevOps repository, and returns immediately with a job id. A job is ONE-SHOT: it runs unattended for a median of about an hour and can run for many hours, cannot be messaged, and cannot be resumed — iteration means creating another job. It works in its own cloud clone, not in your working tree; its final answer is retrieved with get_job. Only `prompt` is needed in the normal case, or `agent` for a custom agent that carries its own instructions: the repository is read from the workspace's git remote, the model and reasoning effort come from `tier` (default normal), and every other argument has a working default, so supply one only to change that default — each description states its default and what overrides it. Confirm with the user before creating a job they did not explicitly ask for: it spends real compute for an hour or more. After it returns, do not wait in one call — poll with get_job, or use wait_for_job once to confirm the job left the queue.",
|
|
15596
|
+
inputSchema: {
|
|
15597
|
+
type: "object",
|
|
15598
|
+
additionalProperties: false,
|
|
15599
|
+
properties: {
|
|
15600
|
+
prompt: {
|
|
15601
|
+
type: "string",
|
|
15602
|
+
description: "What the cloud agent should do, in natural language. Required unless `agent` names a custom agent whose own instructions drive the job. This is the whole specification: the agent starts from a fresh clone and sees nothing else."
|
|
15603
|
+
},
|
|
15604
|
+
...REPOSITORY_PROPERTIES,
|
|
15605
|
+
branch: {
|
|
15606
|
+
type: "string",
|
|
15607
|
+
description: "Branch to start from. Default: the repository's default branch."
|
|
15608
|
+
},
|
|
15609
|
+
...WORKSPACE_PROPERTY,
|
|
15610
|
+
agent: {
|
|
15611
|
+
type: "string",
|
|
15612
|
+
description: "Name of a custom agent to run instead of the default one; see list_agents. Default: the service's standard agent, driven by `prompt`. A named agent's `inputs` are usually required."
|
|
15613
|
+
},
|
|
15614
|
+
agentType: {
|
|
15615
|
+
type: "string",
|
|
15616
|
+
enum: [...AGENT_TYPES],
|
|
15617
|
+
description: "Scope the custom agent was registered at: Repo, Organization, Company or Spec. Only meaningful with `agent`; default: not sent."
|
|
15618
|
+
},
|
|
15619
|
+
agentInputs: {
|
|
15620
|
+
type: "object",
|
|
15621
|
+
description: "Inputs the custom agent requires, as name/value pairs; list_agents lists the names. Default: none. Values are strings, numbers or booleans."
|
|
15622
|
+
},
|
|
15623
|
+
plugins: {
|
|
15624
|
+
type: "array",
|
|
15625
|
+
items: { type: "string" },
|
|
15626
|
+
description: "Plugin names to load, from list_plugins. Plugins are the main capability selector — they give the agent skills, tools or house rules. Default: none, so the job runs on the agent's built-in capabilities plus whatever the service enables by default (list_plugins marks those `(enabled by default)`)."
|
|
15627
|
+
},
|
|
15628
|
+
includeDefaultPlugins: {
|
|
15629
|
+
type: "boolean",
|
|
15630
|
+
description: "Set true to load the service's default plugins alongside `plugins`. Default: not sent, so the service applies its own default; only set it when a job needs both the defaults and extra plugins."
|
|
15631
|
+
},
|
|
15632
|
+
tier: {
|
|
15633
|
+
type: "string",
|
|
15634
|
+
enum: [
|
|
15635
|
+
"easy",
|
|
15636
|
+
"normal",
|
|
15637
|
+
"complex"
|
|
15638
|
+
],
|
|
15639
|
+
description: "Preset for model and reasoning effort. Default \"normal\". easy = claude-opus-4.8-fast (a preview model) at max effort, for small well-specified changes; normal = gpt-6-astra at max effort, the everyday coding tier; complex = claude-opus-5.5 at max effort, for hard or long-horizon work. Naming `model` replaces the preset's model AND discards its effort; `context` is independent of the tier. list_models shows the live catalog and each model's effort values."
|
|
15640
|
+
},
|
|
15641
|
+
model: {
|
|
15642
|
+
type: "string",
|
|
15643
|
+
description: "Model the agent runs on, from the Cloud Agent catalog (list_models) — a Cloud Agent model id, not one of this proxy's model ids. Default: the model of `tier` (normal = gpt-6-astra). Overriding it drops the tier's `max` reasoning effort as well, leaving the model's own default unless `reasoningEffort` is also passed — the effort ladder differs per model, so the tier value is not valid everywhere. list_models lists the ids and each model's effort values."
|
|
15644
|
+
},
|
|
15645
|
+
reasoningEffort: {
|
|
15646
|
+
type: "string",
|
|
15647
|
+
description: "Reasoning effort for the job's model. Default: `max`, supplied by `tier`. The values are low, medium, high, xhigh and max, but each model accepts only a subset — list_models prints the ladder per model. Passing an effort without `model` keeps the tier's model."
|
|
15648
|
+
},
|
|
15649
|
+
context: {
|
|
15650
|
+
type: "string",
|
|
15651
|
+
enum: ["default", "long_context"],
|
|
15652
|
+
description: "Context tier: \"default\" or \"long_context\". Default \"default\"; override with \"long_context\" for a job over a large repository."
|
|
15653
|
+
},
|
|
15654
|
+
metadata: {
|
|
15655
|
+
type: "object",
|
|
15656
|
+
description: "Short string labels stored on the job and echoed by list_jobs, e.g. {\"chain\": \"research\", \"step\": \"1\"}. Default: none. Labels are how a later session finds this job, not a place to store content."
|
|
15657
|
+
}
|
|
15658
|
+
}
|
|
15659
|
+
},
|
|
15660
|
+
async handler(args, signal, ctx) {
|
|
15661
|
+
const repository = await resolveRepository(args, ctx, { signal });
|
|
15662
|
+
const branch = optionalString(args, "branch");
|
|
15663
|
+
const agent = optionalString(args, "agent");
|
|
15664
|
+
const prompt = optionalString(args, "prompt");
|
|
15665
|
+
const agentType = agent ? agentTypeArg(args) : void 0;
|
|
15666
|
+
const agentInputs = agent ? agentInputsArg(args) : void 0;
|
|
15667
|
+
const plugins = pluginsArg(args);
|
|
15668
|
+
const model = resolveModelConfiguration(args);
|
|
15669
|
+
const metadata = metadataArg(args);
|
|
15670
|
+
const request = buildGenericJobRequest({
|
|
15671
|
+
...prompt ? { prompt } : {},
|
|
15672
|
+
repository: {
|
|
15673
|
+
organization: repository.organization,
|
|
15674
|
+
project: repository.project,
|
|
15675
|
+
repository: repository.repository,
|
|
15676
|
+
...branch ? { branch } : {}
|
|
15677
|
+
},
|
|
15678
|
+
...agent ? { customAgent: {
|
|
15679
|
+
name: agent,
|
|
15680
|
+
...agentType ? { type: agentType } : {},
|
|
15681
|
+
...agentInputs ? { inputs: agentInputs } : {}
|
|
15682
|
+
} } : {},
|
|
15683
|
+
...plugins ? { plugins } : {},
|
|
15684
|
+
...args.includeDefaultPlugins === true ? { includeDefaultPlugins: true } : {},
|
|
15685
|
+
modelConfiguration: model.modelConfiguration,
|
|
15686
|
+
...metadata ? { metadata } : {}
|
|
15687
|
+
});
|
|
15688
|
+
const job = await cloudAgentClient().createJob(request);
|
|
15689
|
+
const provenance = provenanceLine(repository);
|
|
15690
|
+
const lines = [renderJob(job, provenance ? { note: provenance } : {})];
|
|
15691
|
+
lines.push("");
|
|
15692
|
+
lines.push("effective request (the normalized body the service received):");
|
|
15693
|
+
lines.push(renderEffectiveRequest(request));
|
|
15694
|
+
lines.push(` ${model.tierNote}`);
|
|
15695
|
+
lines.push("");
|
|
15696
|
+
lines.push(`next: the job is ${job.state ?? "created"}. Report the job id to the user and check with get_job jobId=${job.jobId} in about 10 minutes — a typical job runs for hours, so there is nothing to learn before then. wait_for_job tells you whether the handoff took (it leaves Queued) without waiting for the work.`);
|
|
15697
|
+
return text(lines.join("\n"));
|
|
15698
|
+
}
|
|
15699
|
+
},
|
|
15700
|
+
{
|
|
15701
|
+
toolNameHttp: "create_pr_job",
|
|
15702
|
+
group: CLOUDAGENT_GROUP,
|
|
15703
|
+
capability: "cloudagent_write",
|
|
15704
|
+
description: "Runs an autonomous coding agent in the Microsoft cloud that takes one request from understanding to a review-ready pull request, and returns immediately with a job id. It is create_job with three decisions already made: the `agency-coding` and `agency-review` plugins are loaded (branch, commit, push, pull request, pipeline and work item tools, plus a review orchestrator that dispatches scoped reviewers in parallel and reconciles their findings onto the pull request), the model defaults to claude-opus-5.5 at max reasoning effort (the `complex` tier), and a fixed engineering workflow is prepended to `prompt`: search and understand, research, a plan, an adversarial review of that plan, implementation with tests, the pull request and its work item, an adversarial review of the change, and a green build. You supply the task in `prompt` and the job's name in `title`; the workflow and its conventions are added automatically, so do not restate them. A job is ONE-SHOT: it runs unattended for a median of about an hour and can run for many hours, cannot be messaged, and cannot be resumed. The job leaves its pull request open for a human to review and never merges. Confirm with the user before creating a job they did not explicitly ask for: it spends real compute for an hour or more. After it returns, poll with get_job, or use wait_for_job once to confirm the job left the queue.",
|
|
15705
|
+
inputSchema: {
|
|
15706
|
+
type: "object",
|
|
15707
|
+
required: ["prompt", "title"],
|
|
15708
|
+
additionalProperties: false,
|
|
15709
|
+
properties: {
|
|
15710
|
+
title: {
|
|
15711
|
+
type: "string",
|
|
15712
|
+
description: "The job's name, at most 100 characters on one line, e.g. \"Fix shared-channel membership revocation\". It is what list_jobs and get_job show first, it opens the prompt so the agent knows what it is working on, and it becomes the pull request title unless the repository's convention requires another form. Name the change, not the ticket."
|
|
15713
|
+
},
|
|
15714
|
+
prompt: {
|
|
15715
|
+
type: "string",
|
|
15716
|
+
description: "The task, written as a brief rather than a one-liner: the outcome wanted, how the caller will know it is done, constraints, relevant links, and the work item id if one already exists. This is the request the job answers; the workflow, plugins and model come from the tool, so do not restate them. The agent starts from a fresh clone and sees nothing else."
|
|
15717
|
+
},
|
|
15718
|
+
...REPOSITORY_PROPERTIES,
|
|
15719
|
+
branch: {
|
|
15720
|
+
type: "string",
|
|
15721
|
+
description: "Branch to start from. Default: the repository's default branch."
|
|
15722
|
+
},
|
|
15723
|
+
...WORKSPACE_PROPERTY,
|
|
15724
|
+
tier: {
|
|
15725
|
+
type: "string",
|
|
15726
|
+
enum: [
|
|
15727
|
+
"easy",
|
|
15728
|
+
"normal",
|
|
15729
|
+
"complex"
|
|
15730
|
+
],
|
|
15731
|
+
description: "Preset for model and reasoning effort. Default \"complex\": claude-opus-5.5 at max effort, because this workflow is long-horizon work. easy = claude-opus-4.8-fast (a preview model) at max effort, for small well-specified changes; normal = gpt-6-astra at max effort, the everyday coding tier. Naming `model` replaces the preset's model AND discards its effort; `context` is independent of the tier. list_models shows the live catalog and each model's effort values."
|
|
15732
|
+
},
|
|
15733
|
+
model: {
|
|
15734
|
+
type: "string",
|
|
15735
|
+
description: "Model the agent runs on, from the Cloud Agent catalog (list_models) — a Cloud Agent model id, not one of this proxy's model ids. Default: claude-opus-5.5, the model of the `complex` tier. Overriding it drops the tier's `max` reasoning effort as well, leaving the model's own default unless `reasoningEffort` is also passed; the effort ladder differs per model. list_models lists the ids and each model's effort values."
|
|
15736
|
+
},
|
|
15737
|
+
reasoningEffort: {
|
|
15738
|
+
type: "string",
|
|
15739
|
+
description: "Reasoning effort for the job's model. Default: `max`, supplied by `tier`. The values are low, medium, high, xhigh and max, but each model accepts only a subset; list_models prints the ladder per model. Passing an effort without `model` keeps the tier's model."
|
|
15740
|
+
},
|
|
15741
|
+
context: {
|
|
15742
|
+
type: "string",
|
|
15743
|
+
enum: ["default", "long_context"],
|
|
15744
|
+
description: "Context tier: \"default\" or \"long_context\". Default \"default\"; override with \"long_context\" for a job over a large repository."
|
|
15745
|
+
},
|
|
15746
|
+
metadata: {
|
|
15747
|
+
type: "object",
|
|
15748
|
+
description: "Short string labels stored on the job and echoed by list_jobs, e.g. {\"chain\": \"research\", \"step\": \"1\"}. Default: none. Labels are how a later session finds this job, not a place to store content."
|
|
15749
|
+
}
|
|
15750
|
+
}
|
|
15751
|
+
},
|
|
15752
|
+
async handler(args, signal, ctx) {
|
|
15753
|
+
const repository = await resolveRepository(args, ctx, { signal });
|
|
15754
|
+
const branch = optionalString(args, "branch");
|
|
15755
|
+
const task = optionalString(args, "prompt");
|
|
15756
|
+
if (!task) throw new CloudAgentError("`prompt` is required: it is the task the job works on, and the fixed workflow cannot supply one.", { retriable: false });
|
|
15757
|
+
const title = optionalString(args, "title");
|
|
15758
|
+
if (!title) throw new CloudAgentError("`title` is required: it names the job and becomes the pull request title.", { retriable: false });
|
|
15759
|
+
if (/[\r\n]/.test(title)) throw new CloudAgentError("`title` must be a single line: it is the job's name in list_jobs and the pull request title.", { retriable: false });
|
|
15760
|
+
if (title.length > PR_JOB_TITLE_MAX) throw new CloudAgentError(`\`title\` must be at most ${PR_JOB_TITLE_MAX} characters; it is a name, not a summary.`, { retriable: false });
|
|
15761
|
+
const model = resolveModelConfiguration(args, PR_JOB_DEFAULT_TIER);
|
|
15762
|
+
const metadata = metadataArg(args);
|
|
15763
|
+
if (metadata && Object.prototype.hasOwnProperty.call(metadata, "title")) throw new CloudAgentError("`metadata.title` is reserved on create_pr_job; pass the job name as `title`.", { retriable: false });
|
|
15764
|
+
const request = buildGenericJobRequest({
|
|
15765
|
+
prompt: composePrJobPrompt(task, title),
|
|
15766
|
+
repository: {
|
|
15767
|
+
organization: repository.organization,
|
|
15768
|
+
project: repository.project,
|
|
15769
|
+
repository: repository.repository,
|
|
15770
|
+
...branch ? { branch } : {}
|
|
15771
|
+
},
|
|
15772
|
+
plugins: [{ name: AGENCY_CODING_PLUGIN }, { name: AGENCY_REVIEW_PLUGIN }],
|
|
15773
|
+
modelConfiguration: model.modelConfiguration,
|
|
15774
|
+
metadata: {
|
|
15775
|
+
title,
|
|
15776
|
+
...metadata ?? {}
|
|
15777
|
+
}
|
|
15778
|
+
});
|
|
15779
|
+
const job = await cloudAgentClient().createJob(request);
|
|
15780
|
+
const provenance = provenanceLine(repository);
|
|
15781
|
+
const lines = [renderJob(job, provenance ? { note: provenance } : {})];
|
|
15782
|
+
lines.push("");
|
|
15783
|
+
lines.push("effective request (the normalized body the service received):");
|
|
15784
|
+
lines.push(renderEffectiveRequest(request));
|
|
15785
|
+
lines.push(` ${model.tierNote}`);
|
|
15786
|
+
lines.push("");
|
|
15787
|
+
lines.push(`next: the job is ${job.state ?? "created"}. Report the job id to the user and poll with get_job jobId=${job.jobId}; a typical run takes hours. wait_for_job tells you whether the handoff took without waiting for the work.`);
|
|
15788
|
+
return text(lines.join("\n"));
|
|
15789
|
+
}
|
|
15790
|
+
},
|
|
15791
|
+
{
|
|
15792
|
+
toolNameHttp: "cancel_job",
|
|
15793
|
+
group: CLOUDAGENT_GROUP,
|
|
15794
|
+
capability: "cloudagent_write",
|
|
15795
|
+
description: "Stops a running Cloud Agent job. IRREVERSIBLE: a cancelled job cannot be resumed, and work it had not yet pushed is lost. The service acknowledges the request immediately and stops the job asynchronously, so poll get_job afterwards until the state is terminal. Only cancel when the job is clearly wrong or no longer wanted — a long-running job is normal, not stuck.",
|
|
15796
|
+
inputSchema: {
|
|
15797
|
+
type: "object",
|
|
15798
|
+
required: ["jobId"],
|
|
15799
|
+
additionalProperties: false,
|
|
15800
|
+
properties: { ...JOB_ID_PROPERTY }
|
|
15801
|
+
},
|
|
15802
|
+
async handler(args, signal) {
|
|
15803
|
+
const jobId = requiredString(args, "jobId");
|
|
15804
|
+
const result = await cloudAgentClient().cancelJob(jobId, signal);
|
|
15805
|
+
if (result.alreadyCancelled && result.job) return text(renderJob(result.job, { note: "the job was already cancelled; nothing further will happen to it." }));
|
|
15806
|
+
return text(`Cancellation requested for job ${jobId}.\nnext: the service stops the job asynchronously — check with get_job jobId=${jobId} in about a minute until the state is terminal.`);
|
|
15807
|
+
}
|
|
15808
|
+
},
|
|
15809
|
+
{
|
|
15810
|
+
toolNameHttp: "get_job",
|
|
15811
|
+
group: CLOUDAGENT_GROUP,
|
|
15812
|
+
capability: "cloudagent",
|
|
15813
|
+
description: "The current state of one Cloud Agent job, and — once the job has finished — its deliverable, which is the agent's final summary and leads the result. Use this to poll a job you created. On a job that is still running the result ends with how long to wait before checking again; a typical job runs for hours, so polling more often than that only repeats the same answer. A job that ended in a failure is reported as a normal result with its outcome and who is responsible, not as an error.",
|
|
15814
|
+
inputSchema: {
|
|
15815
|
+
type: "object",
|
|
15816
|
+
required: ["jobId"],
|
|
15817
|
+
additionalProperties: false,
|
|
15818
|
+
properties: { ...JOB_ID_PROPERTY }
|
|
15819
|
+
},
|
|
15820
|
+
async handler(args, signal) {
|
|
15821
|
+
const jobId = requiredString(args, "jobId");
|
|
15822
|
+
const job = await getJobWithSummary(jobId, signal);
|
|
15823
|
+
const lines = [renderJob(job.job, job.summary !== null ? { summary: job.summary } : {})];
|
|
15824
|
+
if (job.summary === null && isTerminalJob(job.job)) {
|
|
15825
|
+
lines.push("");
|
|
15826
|
+
lines.push("summary: none — the job never called task_complete, so it produced no deliverable. get_job_logs shows the trace that explains what it did instead.");
|
|
15827
|
+
}
|
|
15828
|
+
if (isTerminalJob(job.job)) {
|
|
15829
|
+
lines.push("");
|
|
15830
|
+
lines.push(`next: the job is finished. get_job_logs jobId=${jobId} has the digested trace: what it ran, which files it changed, and the last tool result.`);
|
|
15831
|
+
} else {
|
|
15832
|
+
lines.push("");
|
|
15833
|
+
lines.push(renderPollHint(job.job));
|
|
15834
|
+
}
|
|
15835
|
+
return text(lines.join("\n"));
|
|
15836
|
+
}
|
|
15837
|
+
},
|
|
15838
|
+
{
|
|
15839
|
+
toolNameHttp: "list_jobs",
|
|
15840
|
+
group: CLOUDAGENT_GROUP,
|
|
15841
|
+
capability: "cloudagent",
|
|
15842
|
+
description: "Lists the Cloud Agent jobs this account can see, newest first, as one line each with state, outcome, repository and prompt. This is the durable ledger of dispatched work: every job carries its prompt, its labels and its outcome, so a chain of jobs can be reconstructed in a later session or after a compaction. Call it with no arguments in the common case: it narrows to the workspace's Azure DevOps repository and returns the first page of 25 jobs. Narrowing is optional and additive — `organization` alone lists every job in that organization, `organization` plus `project` lists a project, and all three list one repository; names you pass override the ones read from a checkout. There is no state filter: the service silently ignores one, so filter the returned lines yourself.",
|
|
15843
|
+
inputSchema: {
|
|
15844
|
+
type: "object",
|
|
15845
|
+
additionalProperties: false,
|
|
15846
|
+
properties: {
|
|
15847
|
+
...FILTER_REPOSITORY_PROPERTIES,
|
|
15848
|
+
...WORKSPACE_PROPERTY,
|
|
15849
|
+
pullRequestId: {
|
|
15850
|
+
type: "number",
|
|
15851
|
+
description: "Only jobs that produced this pull request. Default: every pull request."
|
|
15852
|
+
},
|
|
15853
|
+
pageSize: {
|
|
15854
|
+
type: "number",
|
|
15855
|
+
description: "How many jobs to return, 1-100. Default 25."
|
|
15856
|
+
},
|
|
15857
|
+
continuationToken: {
|
|
15858
|
+
type: "string",
|
|
15859
|
+
description: "Opaque token from a previous page whose result said more were available. Default: the first page."
|
|
15860
|
+
}
|
|
15861
|
+
}
|
|
15862
|
+
},
|
|
15863
|
+
async handler(args, signal, ctx) {
|
|
15864
|
+
const resolution = await resolveRepositoryFilter(args, ctx, signal);
|
|
15865
|
+
const filter = resolution.filter;
|
|
15866
|
+
const pageSize = optionalInt(args, "pageSize", 1, 100);
|
|
15867
|
+
const pullRequestId = optionalInt(args, "pullRequestId", 1, Number.MAX_SAFE_INTEGER);
|
|
15868
|
+
const notes = [];
|
|
15869
|
+
let projectId;
|
|
15870
|
+
let repositoryId;
|
|
15871
|
+
if (filter?.project) try {
|
|
15872
|
+
const ids = await repoIdResolver({
|
|
15873
|
+
organization: filter.organization,
|
|
15874
|
+
project: filter.project,
|
|
15875
|
+
...filter.repository ? { repository: filter.repository } : {}
|
|
15876
|
+
}, signal);
|
|
15877
|
+
projectId = ids.projectId;
|
|
15878
|
+
repositoryId = ids.repositoryId;
|
|
15879
|
+
} catch (err) {
|
|
15880
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
15881
|
+
if (!filter.inferredFrom) throw new CloudAgentError(`${detail} Pass only \`organization\` to narrow by organization, or omit all three to list every job this account can see.`, { retriable: false });
|
|
15882
|
+
notes.push(`[filter: organization "${filter.organization}" only — ${detail} The project and repository read from ${filter.inferredFrom} were dropped.]`);
|
|
15883
|
+
}
|
|
15884
|
+
const page = await cloudAgentClient().listJobs({
|
|
15885
|
+
organization: filter?.organization,
|
|
15886
|
+
project: projectId,
|
|
15887
|
+
repository: repositoryId,
|
|
15888
|
+
pullRequestId,
|
|
15889
|
+
pageSize,
|
|
15890
|
+
continuationToken: optionalString(args, "continuationToken")
|
|
15891
|
+
}, signal);
|
|
15892
|
+
if (filter?.inferredFrom && filter.project && filter.repository && projectId !== void 0) notes.push(provenanceLine({
|
|
15893
|
+
...filter,
|
|
15894
|
+
project: filter.project,
|
|
15895
|
+
repository: filter.repository
|
|
15896
|
+
}));
|
|
15897
|
+
if (!filter) notes.push(resolution.unresolvedDetail ? `[repository: not filtered — ${resolution.unresolvedDetail} Pass organization, project and repository explicitly to filter by one repository.]` : "[repository: not filtered — no repository was given and none could be read from a checkout, so this lists every job the account can see]");
|
|
15898
|
+
const lines = [...notes, renderJobPage(page)];
|
|
15899
|
+
if (page.data.length > 0) {
|
|
15900
|
+
lines.push("");
|
|
15901
|
+
lines.push(`next: get_job jobId=<id> for one job's state and deliverable; get_job_logs jobId=<id> for what it actually did.`);
|
|
15902
|
+
}
|
|
15903
|
+
return text(lines.join("\n"));
|
|
15904
|
+
}
|
|
15905
|
+
},
|
|
15906
|
+
{
|
|
15907
|
+
toolNameHttp: "wait_for_job",
|
|
15908
|
+
group: CLOUDAGENT_GROUP,
|
|
15909
|
+
capability: "cloudagent",
|
|
15910
|
+
description: "Waits a short, bounded time for a Cloud Agent job to leave the queue, i.e. for the service to allocate compute and start it. Returns as soon as the job starts running, reaches a terminal state, or the wait expires — \"still Queued after 25 s\" is a normal answer, not an error. Use it once after create_job to confirm the handoff took. Do not use it to wait for the work: jobs run for a median of about an hour, so use get_job for that.",
|
|
15911
|
+
inputSchema: {
|
|
15912
|
+
type: "object",
|
|
15913
|
+
required: ["jobId"],
|
|
15914
|
+
additionalProperties: false,
|
|
15915
|
+
properties: {
|
|
15916
|
+
...JOB_ID_PROPERTY,
|
|
15917
|
+
max_wait_s: {
|
|
15918
|
+
type: "number",
|
|
15919
|
+
description: `Seconds to wait, 1-${WAIT_MAX_S}. Default ${WAIT_DEFAULT_S}.`
|
|
15920
|
+
}
|
|
15921
|
+
}
|
|
15922
|
+
},
|
|
15923
|
+
async handler(args, signal) {
|
|
15924
|
+
const jobId = requiredString(args, "jobId");
|
|
15925
|
+
const maxWaitS = optionalInt(args, "max_wait_s", 1, WAIT_MAX_S) ?? WAIT_DEFAULT_S;
|
|
15926
|
+
const client = cloudAgentClient();
|
|
15927
|
+
const startedAt = Date.now();
|
|
15928
|
+
const deadline = startedAt + maxWaitS * 1e3;
|
|
15929
|
+
let job = await client.getJob(jobId, signal);
|
|
15930
|
+
let polls = 1;
|
|
15931
|
+
while (!isTerminalJob(job) && !hasLeftQueue(job) && Date.now() < deadline) {
|
|
15932
|
+
await sleep(Math.min(WAIT_POLL_MS, Math.max(0, deadline - Date.now())), signal);
|
|
15933
|
+
job = await client.getJob(jobId, signal);
|
|
15934
|
+
polls++;
|
|
15935
|
+
}
|
|
15936
|
+
const elapsedS = Math.max(1, Math.round((Date.now() - startedAt) / 1e3));
|
|
15937
|
+
if (isTerminalJob(job)) {
|
|
15938
|
+
const summary = await summaryFor(client, jobId, signal);
|
|
15939
|
+
const lines = [renderJob(job, summary !== null ? { summary } : {})];
|
|
15940
|
+
if (summary === null) {
|
|
15941
|
+
lines.push("");
|
|
15942
|
+
lines.push("summary: none — the job never called task_complete, so it produced no deliverable.");
|
|
15943
|
+
}
|
|
15944
|
+
lines.push("");
|
|
15945
|
+
lines.push(`next: the job finished within ${elapsedS} s. get_job_logs jobId=${jobId} has the digested trace.`);
|
|
15946
|
+
return text(lines.join("\n"));
|
|
15947
|
+
}
|
|
15948
|
+
const lines = [renderJob(job, { note: hasLeftQueue(job) ? `the handoff took: the job left the queue within ${elapsedS} s (${polls} poll(s)).` : `still ${job.state ?? "queued"} after ${elapsedS} s (${polls} poll(s)) — the service has not allocated compute yet.` })];
|
|
15949
|
+
lines.push("");
|
|
15950
|
+
lines.push(hasLeftQueue(job) ? "next: the job is running. Check with get_job in about 10 minutes; a typical job runs for hours." : "next: nothing is wrong yet — a job can sit in the queue. Check again with get_job in about 2 minutes; if it is still queued much longer, the queue is the problem, not the job.");
|
|
15951
|
+
return text(lines.join("\n"));
|
|
15952
|
+
}
|
|
15953
|
+
},
|
|
15954
|
+
{
|
|
15955
|
+
toolNameHttp: "get_job_logs",
|
|
15956
|
+
group: CLOUDAGENT_GROUP,
|
|
15957
|
+
capability: "cloudagent",
|
|
15958
|
+
description: "The trace of a Cloud Agent job: what it did and what it left behind. The default digest gives the deliverable summary (when the job produced one), a tool-use histogram, the files it changed, its last message, and the final tool result — which is how a multi-hour, multi-thousand-message run becomes readable. Use mode \"full\" only when the digest is genuinely not enough: the raw trace is often several megabytes and is written to a file with a short preview returned.",
|
|
15959
|
+
inputSchema: {
|
|
15960
|
+
type: "object",
|
|
15961
|
+
required: ["jobId"],
|
|
15962
|
+
additionalProperties: false,
|
|
15963
|
+
properties: {
|
|
15964
|
+
...JOB_ID_PROPERTY,
|
|
15965
|
+
mode: {
|
|
15966
|
+
type: "string",
|
|
15967
|
+
enum: ["digest", "full"],
|
|
15968
|
+
description: "Default \"digest\": a readable summary. \"full\" returns the raw trace text, spilled to a file when large."
|
|
15969
|
+
},
|
|
15970
|
+
tail: {
|
|
15971
|
+
type: "number",
|
|
15972
|
+
description: "How many of the most recent tool calls the digest lists, 1-50. Default 12."
|
|
15973
|
+
}
|
|
15974
|
+
}
|
|
15975
|
+
},
|
|
15976
|
+
async handler(args, signal) {
|
|
15977
|
+
const jobId = requiredString(args, "jobId");
|
|
15978
|
+
const tail = optionalInt(args, "tail", 1, 50);
|
|
15979
|
+
const mode = optionalString(args, "mode") ?? "digest";
|
|
15980
|
+
if (mode !== "digest" && mode !== "full") throw new CloudAgentError("`mode` must be \"digest\" or \"full\".", { retriable: false });
|
|
15981
|
+
const client = cloudAgentClient();
|
|
15982
|
+
if (mode === "full") return text(await client.getJobLogsText(jobId, signal));
|
|
15983
|
+
const logs = await client.getJobLogs(jobId, signal);
|
|
15984
|
+
if (logs.summary) storeSummary(summaryKey(jobId), logs.summary);
|
|
15985
|
+
return text(renderTrace(logs, tail !== void 0 ? { tail } : {}));
|
|
15986
|
+
}
|
|
15987
|
+
},
|
|
15988
|
+
{
|
|
15989
|
+
toolNameHttp: "list_plugins",
|
|
15990
|
+
group: CLOUDAGENT_GROUP,
|
|
15991
|
+
capability: "cloudagent",
|
|
15992
|
+
description: "Lists the plugins a Cloud Agent job can load: skills, tools and house rules the agent gets when the plugin is named in create_job's `plugins`. This is the main capability selector — a plain prompt runs the agent with the default capabilities only. The catalog is large (hundreds of entries): call it with no arguments for the first page of 50, page with `top`/`skip`, or pass `name_contains` to search the WHOLE catalog, in which case `top`/`skip` window the matches instead of the catalog.",
|
|
15993
|
+
inputSchema: {
|
|
15994
|
+
type: "object",
|
|
15995
|
+
additionalProperties: false,
|
|
15996
|
+
properties: {
|
|
15997
|
+
type: {
|
|
15998
|
+
type: "string",
|
|
15999
|
+
description: "Plugin scope to filter on. The known choices are Repo, Organization, Company and Spec, the same vocabulary create_job's `agentType` accepts. Default: every scope. Repo and Organization read a repository's or an organization's own catalog: Repo needs `organization`, `project` and `repository`, Organization needs only `organization`, and by default both are read from the checkout this session is in."
|
|
16000
|
+
},
|
|
16001
|
+
...CATALOG_REPOSITORY_PROPERTIES,
|
|
16002
|
+
...WORKSPACE_PROPERTY,
|
|
16003
|
+
name_contains: {
|
|
16004
|
+
type: "string",
|
|
16005
|
+
description: "Search the whole catalog for plugin names containing this text, case-insensitively. The service has no name filter, so the proxy pages through the catalog itself; `top` and `skip` then window the MATCHES, not the catalog. Default: no search, so the result is a page of the catalog."
|
|
16006
|
+
},
|
|
16007
|
+
top: {
|
|
16008
|
+
type: "number",
|
|
16009
|
+
description: "Page size, 1-100. Default: 50, both for the catalog page and for the maximum number of `name_contains` matches."
|
|
16010
|
+
},
|
|
16011
|
+
skip: {
|
|
16012
|
+
type: "number",
|
|
16013
|
+
description: "How many entries to skip, for paging. With `name_contains`, how many matches to skip. Default 0, the first page."
|
|
16014
|
+
}
|
|
16015
|
+
}
|
|
16016
|
+
},
|
|
16017
|
+
async handler(args, signal, ctx) {
|
|
16018
|
+
const { query, context } = await catalogQuery(args, ctx, signal);
|
|
16019
|
+
const provenance = context ? provenanceLine(context) : void 0;
|
|
16020
|
+
const withProvenance = (body) => provenance ? `${provenance}\n${body}` : body;
|
|
16021
|
+
const needle = optionalString(args, "name_contains")?.toLowerCase();
|
|
16022
|
+
if (!needle) return text(withProvenance(renderPluginPage(await cloudAgentClient().listPlugins(query, signal))));
|
|
16023
|
+
const scan = await scanPluginCatalog(query, signal);
|
|
16024
|
+
const matches = scan.value.filter((plugin) => plugin.name.toLowerCase().includes(needle));
|
|
16025
|
+
const skip = query.skip ?? 0;
|
|
16026
|
+
const limit = query.top ?? DEFAULT_PLUGIN_MATCH_LIMIT;
|
|
16027
|
+
const window = matches.slice(skip, skip + limit);
|
|
16028
|
+
const scanned = scan.capped ? `the first ${scan.scanned} of ${scan.totalCount ?? "?"} plugin(s) — narrow with \`type\`` : scan.totalCount !== void 0 ? `all ${scan.totalCount} plugin(s)` : `the ${scan.scanned} plugin(s) the service returned`;
|
|
16029
|
+
return text(withProvenance([matches.length === 0 ? `[name_contains "${needle}": no plugin name contains it, searched ${scanned}]` : `[name_contains "${needle}": ${matches.length} match(es) in ${scanned}${window.length < matches.length ? `, showing ${skip + 1}-${skip + window.length}` : ""}]`, renderPluginPage({
|
|
16030
|
+
value: window,
|
|
16031
|
+
...scan.errors ? { errors: scan.errors } : {}
|
|
16032
|
+
})].join("\n")));
|
|
16033
|
+
}
|
|
16034
|
+
},
|
|
16035
|
+
{
|
|
16036
|
+
toolNameHttp: "list_agents",
|
|
16037
|
+
group: CLOUDAGENT_GROUP,
|
|
16038
|
+
capability: "cloudagent",
|
|
16039
|
+
description: "Lists the custom agents a Cloud Agent job can run with create_job's `agent`, together with the input names each one requires. This is the only place those input names appear: the service rejects a job whose agent is missing a required input, so read this before naming an agent.",
|
|
16040
|
+
inputSchema: {
|
|
16041
|
+
type: "object",
|
|
16042
|
+
additionalProperties: false,
|
|
16043
|
+
properties: {
|
|
16044
|
+
type: {
|
|
16045
|
+
type: "string",
|
|
16046
|
+
description: "Agent scope to filter on. The known choices are Repo, Organization, Company and Spec, the same vocabulary create_job's `agentType` accepts. Default: every scope. Repo lists the agents a repository defines, which is where custom agents that need `agentInputs` usually live; it needs `organization`, `project` and `repository`, or a checkout to read them from. Organization lists an organization's agents and needs only `organization`."
|
|
16047
|
+
},
|
|
16048
|
+
...CATALOG_REPOSITORY_PROPERTIES,
|
|
16049
|
+
...WORKSPACE_PROPERTY,
|
|
16050
|
+
top: {
|
|
16051
|
+
type: "number",
|
|
16052
|
+
description: "Page size, 1-100. Default: the service's own page size."
|
|
16053
|
+
},
|
|
16054
|
+
skip: {
|
|
16055
|
+
type: "number",
|
|
16056
|
+
description: "How many entries to skip, for paging. Default 0, the first page."
|
|
16057
|
+
}
|
|
16058
|
+
}
|
|
16059
|
+
},
|
|
16060
|
+
async handler(args, signal, ctx) {
|
|
16061
|
+
const { query, context } = await catalogQuery(args, ctx, signal);
|
|
16062
|
+
const page = await cloudAgentClient().listAgents(query, signal);
|
|
16063
|
+
const provenance = context ? provenanceLine(context) : void 0;
|
|
16064
|
+
return text(provenance ? `${provenance}\n${renderAgentPage(page)}` : renderAgentPage(page));
|
|
16065
|
+
}
|
|
16066
|
+
},
|
|
16067
|
+
{
|
|
16068
|
+
toolNameHttp: "list_models",
|
|
16069
|
+
group: CLOUDAGENT_GROUP,
|
|
16070
|
+
capability: "cloudagent",
|
|
16071
|
+
description: "Lists the models a Cloud Agent job can run on, from the service's live catalog, with each model's context window, output limit, reasoning-effort values and any notice the service attaches (for example a scheduled deprecation). These are the Cloud Agent service's own models, a catalog entirely separate from the models this proxy serves; an id from the proxy's catalog is not valid here, and only an id from this list is. This is the vocabulary create_job's `model` draws from, and the check to run before relying on a tier in an unfamiliar environment: create_job's presets name specific ids — easy = claude-opus-4.8-fast at max effort, normal = gpt-6-astra at max effort (the default), complex = claude-opus-5.5 at max effort — and a preset whose id is gone fails at the service. The list is global: it is identical for every repository and organization, which is why it takes no arguments.",
|
|
16072
|
+
inputSchema: {
|
|
16073
|
+
type: "object",
|
|
16074
|
+
additionalProperties: false,
|
|
16075
|
+
properties: {}
|
|
16076
|
+
},
|
|
16077
|
+
async handler(_args, signal) {
|
|
16078
|
+
const models = await cloudAgentClient().listModels(signal);
|
|
16079
|
+
return text(`create_job tier presets: ${CLOUDAGENT_TIERS.map((tier) => {
|
|
16080
|
+
const preset = CLOUDAGENT_TIER_MODELS[tier];
|
|
16081
|
+
const suffix = tier === "normal" ? " (default)" : "";
|
|
16082
|
+
return `${tier} = ${preset.model} at ${preset.reasoningEffort} effort${suffix}`;
|
|
16083
|
+
}).join("; ")}.\n${renderModelPage(models)}`);
|
|
16084
|
+
}
|
|
16085
|
+
}
|
|
16086
|
+
]);
|
|
16087
|
+
function tierArg(args, defaultTier = CLOUDAGENT_DEFAULT_TIER) {
|
|
16088
|
+
const raw = optionalString(args, "tier");
|
|
16089
|
+
if (raw === void 0) return defaultTier;
|
|
16090
|
+
const normalized = raw.toLowerCase();
|
|
16091
|
+
const match = CLOUDAGENT_TIERS.find((tier) => tier === normalized);
|
|
16092
|
+
if (match) return match;
|
|
16093
|
+
throw new CloudAgentError(`\`tier\` must be easy, normal or complex (got "${raw}"). ${CLOUDAGENT_TIERS.map((tier) => `${tier} = ${CLOUDAGENT_TIER_MODELS[tier].model} at ${CLOUDAGENT_TIER_MODELS[tier].reasoningEffort} effort`).join(", ")}.`, { retriable: false });
|
|
16094
|
+
}
|
|
16095
|
+
/**
|
|
16096
|
+
* Resolve `tier`, `model`, `reasoningEffort` and `context` into the wire
|
|
16097
|
+
* `modelConfiguration`, plus one line explaining what the tier contributed.
|
|
16098
|
+
*
|
|
16099
|
+
* Precedence, and why: a tier supplies a model AND an effort. Naming a `model`
|
|
16100
|
+
* replaces the whole preset rather than only its model, because the effort
|
|
16101
|
+
* ladder differs per model — measured live, 8 of 25 models do not accept `max`
|
|
16102
|
+
* — so carrying the preset's `max` onto a caller-chosen model would inject a
|
|
16103
|
+
* value that caller never asked for and the service may reject. An explicit
|
|
16104
|
+
* `reasoningEffort` is always honored, with or without `model`.
|
|
16105
|
+
*
|
|
16106
|
+
* The explanation line exists because `GET /jobs/{id}` never returns
|
|
16107
|
+
* `modelConfiguration`: a follow-up job can only copy values the caller can
|
|
16108
|
+
* SEE were used, and "effort: max" without saying it came from the tier reads
|
|
16109
|
+
* like something the caller chose.
|
|
16110
|
+
*/
|
|
16111
|
+
function resolveModelConfiguration(args, defaultTier = CLOUDAGENT_DEFAULT_TIER) {
|
|
16112
|
+
const tier = tierArg(args, defaultTier);
|
|
16113
|
+
const preset = CLOUDAGENT_TIER_MODELS[tier];
|
|
16114
|
+
const explicitModel = optionalString(args, "model");
|
|
16115
|
+
const explicitEffort = optionalString(args, "reasoningEffort");
|
|
16116
|
+
const context = optionalString(args, "context");
|
|
16117
|
+
if (context !== void 0 && context !== "default" && context !== "long_context") throw new CloudAgentError("`context` must be \"default\" or \"long_context\".", { retriable: false });
|
|
16118
|
+
const model = explicitModel ?? preset.model;
|
|
16119
|
+
const reasoningEffort = explicitEffort ?? (explicitModel ? void 0 : preset.reasoningEffort);
|
|
16120
|
+
const modelConfiguration = {
|
|
16121
|
+
model,
|
|
16122
|
+
...reasoningEffort ? { reasoningEffort } : {},
|
|
16123
|
+
...context ? { context } : {}
|
|
16124
|
+
};
|
|
16125
|
+
const defaultLabel = tier === defaultTier ? ", the default" : "";
|
|
16126
|
+
let tierNote;
|
|
16127
|
+
if (!explicitModel) tierNote = explicitEffort ? `tier: ${tier}${defaultLabel} — its model ${model}; the effort you passed replaced its ${preset.reasoningEffort}.` : `tier: ${tier}${defaultLabel} — supplied model ${model} and effort ${preset.reasoningEffort}.`;
|
|
16128
|
+
else if (explicitEffort) tierNote = `tier: ${tier}${defaultLabel} — replaced by model ${model}; the effort you passed replaced its ${preset.reasoningEffort}.`;
|
|
16129
|
+
else tierNote = `tier: ${tier}${defaultLabel} — replaced by model ${model}, so its ${preset.reasoningEffort} effort was dropped and the model's own default applies.`;
|
|
16130
|
+
return {
|
|
16131
|
+
modelConfiguration,
|
|
16132
|
+
tierNote
|
|
16133
|
+
};
|
|
16134
|
+
}
|
|
16135
|
+
/**
|
|
16136
|
+
* The arguments shared by `list_plugins` and `list_agents`.
|
|
16137
|
+
*
|
|
16138
|
+
* `top` is omitted when the caller did not ask for it, and that is load-bearing:
|
|
16139
|
+
* `GET /plugins` returns 50 of 233 by default and rejects `top > 100` with a 400
|
|
16140
|
+
* unless `marketplace` is set, so a default page size here would either shrink
|
|
16141
|
+
* what the service gives an unprompted call or provoke that 400.
|
|
16142
|
+
*
|
|
16143
|
+
* The Azure DevOps context is resolved separately (`catalogContext`) because
|
|
16144
|
+
* only the Repo and Organization scopes require one.
|
|
16145
|
+
*/
|
|
16146
|
+
async function catalogQuery(args, ctx, signal) {
|
|
16147
|
+
const type = agentTypeValue(args, "type");
|
|
16148
|
+
const top = optionalInt(args, "top", 1, 100);
|
|
16149
|
+
const skip = optionalInt(args, "skip", 0, Number.MAX_SAFE_INTEGER);
|
|
16150
|
+
const context = await catalogContext(args, ctx, type, signal);
|
|
16151
|
+
return {
|
|
16152
|
+
query: {
|
|
16153
|
+
...type ? { type } : {},
|
|
16154
|
+
...context ? {
|
|
16155
|
+
organization: context.organization,
|
|
16156
|
+
...context.project ? { project: context.project } : {},
|
|
16157
|
+
...context.repository ? { repository: context.repository } : {}
|
|
16158
|
+
} : {},
|
|
16159
|
+
...top !== void 0 ? { top } : {},
|
|
16160
|
+
...skip !== void 0 ? { skip } : {}
|
|
16161
|
+
},
|
|
16162
|
+
...context ? { context } : {}
|
|
16163
|
+
};
|
|
16164
|
+
}
|
|
16165
|
+
/**
|
|
16166
|
+
* The context a catalog scope reads, from the caller's arguments or a checkout.
|
|
16167
|
+
*
|
|
16168
|
+
* Each scope is held only to what it actually reads (measured live 2026-10-30;
|
|
16169
|
+
* see `CATALOG_REPOSITORY_PROPERTIES`): `Repo` needs the triple, `Organization`
|
|
16170
|
+
* needs the organization alone, and the rest read no context, so a partial set
|
|
16171
|
+
* supplied to those is not an error — the call simply does not use it. Requiring
|
|
16172
|
+
* more than the service does is its own failure mode: it turns a working
|
|
16173
|
+
* question into a refusal.
|
|
16174
|
+
*
|
|
16175
|
+
* The context is only resolved when the call can use it. An untyped, Company or
|
|
16176
|
+
* Spec call costs no git probe and cannot fail on a machine that is not in an
|
|
16177
|
+
* Azure DevOps checkout — the `list_jobs` lesson, where inferring eagerly turned
|
|
16178
|
+
* every call in an unrelated repository into an error for a filter it did not
|
|
16179
|
+
* need.
|
|
16180
|
+
*/
|
|
16181
|
+
async function catalogContext(args, ctx, type, signal) {
|
|
16182
|
+
if (type !== "Repo" && type !== "Organization") return void 0;
|
|
16183
|
+
const organization = optionalString(args, "organization");
|
|
16184
|
+
const project = optionalString(args, "project");
|
|
16185
|
+
const repository = optionalString(args, "repository");
|
|
16186
|
+
if (type === "Repo") {
|
|
16187
|
+
const given = [
|
|
16188
|
+
organization,
|
|
16189
|
+
project,
|
|
16190
|
+
repository
|
|
16191
|
+
].filter((part) => part !== void 0).length;
|
|
16192
|
+
if (given > 0 && given < 3) throw new CloudAgentError("The Repo scope lists one repository's catalog, so it reads all of `organization`, `project` and `repository`; pass all three, or none of them and let them be read from a checkout. A partial set would either be guessed or silently ignored.", { retriable: false });
|
|
16193
|
+
if (given === 3) return {
|
|
16194
|
+
organization,
|
|
16195
|
+
project,
|
|
16196
|
+
repository
|
|
16197
|
+
};
|
|
16198
|
+
} else {
|
|
16199
|
+
if (organization) return {
|
|
16200
|
+
organization,
|
|
16201
|
+
...project ? { project } : {},
|
|
16202
|
+
...repository ? { repository } : {}
|
|
16203
|
+
};
|
|
16204
|
+
if (project || repository) throw new CloudAgentError("The Organization scope reads an organization's catalog, so it needs `organization`; `project` and `repository` do not identify it. Pass `organization`, or none of the three and let them be read from a checkout.", { retriable: false });
|
|
16205
|
+
}
|
|
16206
|
+
const { repository: inferred } = await repositoryFromWorkspace(args, ctx, {
|
|
16207
|
+
required: true,
|
|
16208
|
+
requiredHint: type === "Repo" ? "`organization`, `project` and `repository`" : "`organization`",
|
|
16209
|
+
...signal ? { signal } : {}
|
|
16210
|
+
});
|
|
16211
|
+
return inferred;
|
|
16212
|
+
}
|
|
16213
|
+
/** Matches returned by a filtered `list_plugins` when the caller gave no `top`. */
|
|
16214
|
+
const DEFAULT_PLUGIN_MATCH_LIMIT = 50;
|
|
16215
|
+
/**
|
|
16216
|
+
* How many catalog entries a name search pages through before it stops.
|
|
16217
|
+
*
|
|
16218
|
+
* The measured catalog is 233 entries, so three pages cover it; the cap only
|
|
16219
|
+
* bounds a catalog that grew by an order of magnitude, and the result says when
|
|
16220
|
+
* it was hit so a truncated search is never read as an empty one.
|
|
16221
|
+
*/
|
|
16222
|
+
const PLUGIN_SCAN_CAP = 1e3;
|
|
16223
|
+
/**
|
|
16224
|
+
* Read the plugin catalog page by page.
|
|
16225
|
+
*
|
|
16226
|
+
* `GET /plugins` has no name filter and refuses `top > 100`, so answering "is
|
|
16227
|
+
* there a plugin for X?" from a single page would miss most of the catalog
|
|
16228
|
+
* while looking like an answer. Paging lives here so the tool handler stays a
|
|
16229
|
+
* filter. `skip` is the service's own offset, verified live: 233 entries over
|
|
16230
|
+
* three pages, no overlap.
|
|
16231
|
+
*/
|
|
16232
|
+
async function scanPluginCatalog(base, signal) {
|
|
16233
|
+
const seen = /* @__PURE__ */ new Set();
|
|
16234
|
+
const value = [];
|
|
16235
|
+
const serviceErrors = /* @__PURE__ */ new Set();
|
|
16236
|
+
const add = (page) => {
|
|
16237
|
+
for (const error of page.errors ?? []) serviceErrors.add(error);
|
|
16238
|
+
for (const plugin of page.value) {
|
|
16239
|
+
if (seen.has(plugin.name)) continue;
|
|
16240
|
+
seen.add(plugin.name);
|
|
16241
|
+
value.push(plugin);
|
|
16242
|
+
}
|
|
16243
|
+
return page.value.length;
|
|
16244
|
+
};
|
|
16245
|
+
const result = (scanned, totalCount, capped) => ({
|
|
16246
|
+
value,
|
|
16247
|
+
scanned,
|
|
16248
|
+
...totalCount !== void 0 ? { totalCount } : {},
|
|
16249
|
+
capped,
|
|
16250
|
+
...serviceErrors.size > 0 ? { errors: [...serviceErrors] } : {}
|
|
16251
|
+
});
|
|
16252
|
+
const first = await cloudAgentClient().listPlugins({
|
|
16253
|
+
...base,
|
|
16254
|
+
top: 100,
|
|
16255
|
+
skip: 0
|
|
16256
|
+
}, signal);
|
|
16257
|
+
let scanned = add(first);
|
|
16258
|
+
const totalCount = first.totalCount;
|
|
16259
|
+
if (first.value.length < 100) return result(scanned, totalCount, false);
|
|
16260
|
+
if (totalCount === void 0) for (;;) {
|
|
16261
|
+
const page = await cloudAgentClient().listPlugins({
|
|
16262
|
+
...base,
|
|
16263
|
+
top: 100,
|
|
16264
|
+
skip: scanned
|
|
16265
|
+
}, signal);
|
|
16266
|
+
scanned += add(page);
|
|
16267
|
+
if (page.value.length < 100) return result(scanned, void 0, false);
|
|
16268
|
+
if (scanned >= PLUGIN_SCAN_CAP) return result(scanned, void 0, true);
|
|
16269
|
+
}
|
|
16270
|
+
const lastPage = Math.min(Math.ceil(totalCount / 100), Math.ceil(PLUGIN_SCAN_CAP / 100));
|
|
16271
|
+
const offsets = [];
|
|
16272
|
+
for (let skip = 100; skip < lastPage * 100; skip += 100) offsets.push(skip);
|
|
16273
|
+
const pages = await Promise.all(offsets.map((skip) => cloudAgentClient().listPlugins({
|
|
16274
|
+
...base,
|
|
16275
|
+
top: 100,
|
|
16276
|
+
skip
|
|
16277
|
+
}, signal)));
|
|
16278
|
+
for (const page of pages) scanned += add(page);
|
|
16279
|
+
return result(scanned, totalCount, totalCount > PLUGIN_SCAN_CAP);
|
|
16280
|
+
}
|
|
16281
|
+
/** Queued is the only state that means "compute has not been allocated". */
|
|
16282
|
+
function hasLeftQueue(job) {
|
|
16283
|
+
return job.state !== void 0 && job.state.trim().toLowerCase() !== "queued";
|
|
16284
|
+
}
|
|
16285
|
+
function summaryKey(jobId) {
|
|
16286
|
+
return `${normalizeCloudAgentEnvironment(state.cloudAgentEnvironment ?? "prod")}:${jobId}`;
|
|
16287
|
+
}
|
|
16288
|
+
/**
|
|
16289
|
+
* The job plus its deliverable for a terminal job.
|
|
16290
|
+
*
|
|
16291
|
+
* A terminal state is the only time the trace is worth fetching, and the answer
|
|
16292
|
+
* is cached in BOTH directions (`null` = read, no summary). A failure to read
|
|
16293
|
+
* the trace must not fail the call: the state and outcome are the more useful
|
|
16294
|
+
* half of the answer, so the summary degrades to `null` with the reason attached
|
|
16295
|
+
* to the note rather than throwing away a successful poll.
|
|
16296
|
+
*/
|
|
16297
|
+
async function getJobWithSummary(jobId, signal) {
|
|
16298
|
+
const client = cloudAgentClient();
|
|
16299
|
+
const job = await client.getJob(jobId, signal);
|
|
16300
|
+
if (!isTerminalJob(job)) return {
|
|
16301
|
+
job,
|
|
16302
|
+
summary: null
|
|
16303
|
+
};
|
|
16304
|
+
return {
|
|
16305
|
+
job,
|
|
16306
|
+
summary: await summaryFor(client, jobId, signal)
|
|
16307
|
+
};
|
|
16308
|
+
}
|
|
16309
|
+
async function summaryFor(client, jobId, signal) {
|
|
16310
|
+
const key = summaryKey(jobId);
|
|
16311
|
+
const cached = cachedSummary(key);
|
|
16312
|
+
if (cached.hit) return cached.summary;
|
|
16313
|
+
try {
|
|
16314
|
+
const summary = (await client.getJobLogs(jobId, signal)).summary ?? null;
|
|
16315
|
+
storeSummary(key, summary);
|
|
16316
|
+
return summary;
|
|
16317
|
+
} catch {
|
|
16318
|
+
return null;
|
|
16319
|
+
}
|
|
16320
|
+
}
|
|
16321
|
+
//#endregion
|
|
13641
16322
|
//#region src/lib/browser-mcp/browser-detect.ts
|
|
13642
16323
|
let cached;
|
|
13643
16324
|
function probeWindowsRegistry(subkey) {
|
|
@@ -15094,7 +17775,7 @@ function logAudit$1(record) {
|
|
|
15094
17775
|
try {
|
|
15095
17776
|
const fs = await import("node:fs/promises");
|
|
15096
17777
|
const path = await import("node:path");
|
|
15097
|
-
const { PATHS } = await import("./paths-
|
|
17778
|
+
const { PATHS } = await import("./paths-BYxX9DfA.js");
|
|
15098
17779
|
const dir = path.join(PATHS.APP_DIR, "browser-mcp");
|
|
15099
17780
|
await fs.mkdir(dir, { recursive: true });
|
|
15100
17781
|
const line = JSON.stringify({
|
|
@@ -24607,6 +27288,21 @@ function adoToolsEnabled() {
|
|
|
24607
27288
|
function kustoToolsEnabled() {
|
|
24608
27289
|
return state.kustoEnabled;
|
|
24609
27290
|
}
|
|
27291
|
+
/**
|
|
27292
|
+
* Gate for the Cloud Agent MCP group, all ten tools (`mcp__cloudagent__*`).
|
|
27293
|
+
*
|
|
27294
|
+
* Returns true iff `setupAndServe` resolved the group ON: `--cloudagent`,
|
|
27295
|
+
* `GH_ROUTER_ENABLE_CLOUDAGENT=1`, or an Azure DevOps git remote in this session's
|
|
27296
|
+
* workspace. Discovery enables the write tools too, matching the ADO, Kusto and
|
|
27297
|
+
* Bluebird groups; the operator's `--no-cloudagent` is the veto. There is no
|
|
27298
|
+
* separate availability probe for the same reason `adoToolsEnabled()` has none:
|
|
27299
|
+
* the tools reach a remote service whose reachability cannot be established
|
|
27300
|
+
* without a token, and minting one during `tools/list` would make listing tools
|
|
27301
|
+
* cost an `az` process.
|
|
27302
|
+
*/
|
|
27303
|
+
function cloudAgentToolsEnabled() {
|
|
27304
|
+
return state.cloudAgentEnabled;
|
|
27305
|
+
}
|
|
24610
27306
|
const ADO_TOKEN_RESOURCE = "2a72489c-aab2-4b65-b93a-a91edccf33b8";
|
|
24611
27307
|
const ADO_PROTOCOL_VERSION = "2025-06-18";
|
|
24612
27308
|
const ADO_TOKEN_ENV = "ADO_MCP_TOKEN";
|
|
@@ -24742,7 +27438,7 @@ var AdoMcpClient = class extends RemoteMcpClient {
|
|
|
24742
27438
|
return [...this.toolSchemas.values()].map((tool) => ({
|
|
24743
27439
|
name: tool.name,
|
|
24744
27440
|
description: tool.description ?? "",
|
|
24745
|
-
inputSchema: isRecord$
|
|
27441
|
+
inputSchema: isRecord$4(tool.inputSchema) ? tool.inputSchema : {
|
|
24746
27442
|
type: "object",
|
|
24747
27443
|
properties: {}
|
|
24748
27444
|
}
|
|
@@ -24761,10 +27457,10 @@ var AdoMcpClient = class extends RemoteMcpClient {
|
|
|
24761
27457
|
await this.initialize(signal);
|
|
24762
27458
|
if (!this.hasTool(name)) throw new AdoError(`Azure DevOps MCP does not advertise a tool named "${name}". Advertised tools: ${[...this.toolSchemas.keys()].sort().join(", ")}.`, { retriable: false });
|
|
24763
27459
|
const result = await this.callTool(name, args, signal);
|
|
24764
|
-
if (!isRecord$
|
|
27460
|
+
if (!isRecord$4(result)) throw new AdoError("Azure DevOps returned an empty result.", { retriable: true });
|
|
24765
27461
|
const texts = [];
|
|
24766
27462
|
if (Array.isArray(result.content)) {
|
|
24767
|
-
for (const block of result.content) if (isRecord$
|
|
27463
|
+
for (const block of result.content) if (isRecord$4(block) && typeof block.text === "string" && block.text.trim()) texts.push(block.text);
|
|
24768
27464
|
}
|
|
24769
27465
|
const envelope = { content: [{
|
|
24770
27466
|
type: "text",
|
|
@@ -25266,6 +27962,7 @@ function maxToolIsEnabled(tool) {
|
|
|
25266
27962
|
if (tool.capability === "artifact") return artifactToolsEnabled();
|
|
25267
27963
|
if (tool.group === "ado") return adoToolsEnabled();
|
|
25268
27964
|
if (tool.group === "kusto") return kustoToolsEnabled();
|
|
27965
|
+
if (tool.capability === "cloudagent" || tool.capability === "cloudagent_write") return cloudAgentToolsEnabled();
|
|
25269
27966
|
return true;
|
|
25270
27967
|
}
|
|
25271
27968
|
/**
|
|
@@ -25291,6 +27988,7 @@ function fastToolIsEnabled(tool) {
|
|
|
25291
27988
|
if (tool.group === "workers") return tool.toolNameHttp === "browse" && tool.capability === "browse_agent" && browseAgentEnabled();
|
|
25292
27989
|
if (tool.group === "ado") return adoToolsEnabled();
|
|
25293
27990
|
if (tool.group === "kusto") return kustoToolsEnabled();
|
|
27991
|
+
if (tool.capability === "cloudagent" || tool.capability === "cloudagent_write") return cloudAgentToolsEnabled();
|
|
25294
27992
|
if (tool.group !== "browser") return false;
|
|
25295
27993
|
if (!browserToolsEnabled()) return false;
|
|
25296
27994
|
if (tool.capability === "browser_compound") return browserCompoundToolsEnabled();
|
|
@@ -25416,6 +28114,7 @@ function toolEntries(scope, launch, audience = "shared") {
|
|
|
25416
28114
|
if (t.capability === "artifact") return artifactToolsEnabled();
|
|
25417
28115
|
if (t.capability === "ado") return adoToolsEnabled();
|
|
25418
28116
|
if (t.capability === "kusto") return kustoToolsEnabled();
|
|
28117
|
+
if (t.capability === "cloudagent" || t.capability === "cloudagent_write") return cloudAgentToolsEnabled();
|
|
25419
28118
|
if (t.capability === "browser_compound") return browserToolsEnabled() && browserCompoundToolsEnabled();
|
|
25420
28119
|
if (t.capability === "browser_power") return browserToolsEnabled() && browserPowerToolsEnabled();
|
|
25421
28120
|
return true;
|
|
@@ -25763,7 +28462,7 @@ function logTelemetry(t) {
|
|
|
25763
28462
|
process.stderr.write(parts.join(" ") + "\n");
|
|
25764
28463
|
}
|
|
25765
28464
|
function toolAcceptsWorkspace(tool) {
|
|
25766
|
-
return tool.capability === "worker" || tool.toolNameHttp === "code" || tool.toolNameHttp === "run_workflow" || tool.toolNameHttp === "prompt_brief";
|
|
28465
|
+
return tool.capability === "worker" || tool.toolNameHttp === "code" || tool.toolNameHttp === "run_workflow" || tool.toolNameHttp === "prompt_brief" || tool.toolNameHttp === "create_job" || tool.toolNameHttp === "create_pr_job" || tool.toolNameHttp === "list_jobs";
|
|
25767
28466
|
}
|
|
25768
28467
|
/**
|
|
25769
28468
|
* Fold the per-session `X-GH-Workspace` header into `args.workspace` when the
|
|
@@ -25983,6 +28682,7 @@ async function handleToolsCall(body, scope, launch, audience = "shared", session
|
|
|
25983
28682
|
if (nonPersonaTool && nonPersonaTool.capability === "browser_power" && !(browserToolsEnabled() && browserPowerToolsEnabled())) return rpcError(body.id, RPC_METHOD_NOT_FOUND, `tools/call: unknown tool "${name}"`);
|
|
25984
28683
|
if (nonPersonaTool && nonPersonaTool.capability === "ado" && !adoToolsEnabled()) return rpcError(body.id, RPC_METHOD_NOT_FOUND, `tools/call: unknown tool "${name}"`);
|
|
25985
28684
|
if (nonPersonaTool && nonPersonaTool.capability === "kusto" && !kustoToolsEnabled()) return rpcError(body.id, RPC_METHOD_NOT_FOUND, `tools/call: unknown tool "${name}"`);
|
|
28685
|
+
if (nonPersonaTool && (nonPersonaTool.capability === "cloudagent" || nonPersonaTool.capability === "cloudagent_write") && !cloudAgentToolsEnabled()) return rpcError(body.id, RPC_METHOD_NOT_FOUND, `tools/call: unknown tool "${name}"`);
|
|
25986
28686
|
let personaPrompt;
|
|
25987
28687
|
let personaContext;
|
|
25988
28688
|
let personaEffort;
|
|
@@ -28318,7 +31018,7 @@ async function throttleSearch() {
|
|
|
28318
31018
|
const waitMs = 1e3 - (now - searchTimestamps[0]);
|
|
28319
31019
|
if (waitMs > 0) {
|
|
28320
31020
|
consola.debug(`Web search rate limited, waiting ${waitMs}ms`);
|
|
28321
|
-
await sleep$
|
|
31021
|
+
await sleep$3(waitMs);
|
|
28322
31022
|
}
|
|
28323
31023
|
}
|
|
28324
31024
|
searchTimestamps.push(Date.now());
|
|
@@ -32711,7 +35411,8 @@ const MCP_GROUPS = Object.freeze([
|
|
|
32711
35411
|
"fleet",
|
|
32712
35412
|
"first-mate",
|
|
32713
35413
|
"ado",
|
|
32714
|
-
"kusto"
|
|
35414
|
+
"kusto",
|
|
35415
|
+
"cloudagent"
|
|
32715
35416
|
]);
|
|
32716
35417
|
const GROUP_META = Object.freeze({
|
|
32717
35418
|
peers: {
|
|
@@ -32763,6 +35464,11 @@ const GROUP_META = Object.freeze({
|
|
|
32763
35464
|
preferredKey: "kusto",
|
|
32764
35465
|
urlSuffix: "kusto",
|
|
32765
35466
|
serverInfoName: "github-router-kusto"
|
|
35467
|
+
},
|
|
35468
|
+
cloudagent: {
|
|
35469
|
+
preferredKey: "cloudagent",
|
|
35470
|
+
urlSuffix: "cloudagent",
|
|
35471
|
+
serverInfoName: "github-router-cloudagent"
|
|
32766
35472
|
}
|
|
32767
35473
|
});
|
|
32768
35474
|
/** True iff `s` is a registered group name (route `:group` param validation). */
|
|
@@ -34424,7 +37130,8 @@ const NON_PERSONA_MCP_TOOLS = Object.freeze([
|
|
|
34424
37130
|
group: "browser",
|
|
34425
37131
|
toolNameHttp: t.toolNameHttp.replace(/^browser_/, "")
|
|
34426
37132
|
})),
|
|
34427
|
-
...KUSTO_TOOLS
|
|
37133
|
+
...KUSTO_TOOLS,
|
|
37134
|
+
...CLOUDAGENT_TOOLS
|
|
34428
37135
|
]);
|
|
34429
37136
|
/**
|
|
34430
37137
|
* Every MCP tool name the proxy serves itself: the personas (definitionally the
|
|
@@ -34831,6 +37538,6 @@ function enumerateInjectedMcpToolNames(groupKeys, opts = {}) {
|
|
|
34831
37538
|
return [...new Set(names)];
|
|
34832
37539
|
}
|
|
34833
37540
|
//#endregion
|
|
34834
|
-
export { readIteratorWithTimeout as $,
|
|
37541
|
+
export { readIteratorWithTimeout as $, getTokenCount as $t, TOOLBELT_TOOLS$1 as A, DEFAULT_PORT as An, fastAstraModel as At, injectAdvisorTool as B, catalogAdvertises1M as Bn, kustoToolsEnabled as Bt, runWorkerAgent as C, collapsePathKeys as Cn, cheapOracleModel as Ct, toolbeltEnabled as D, DEFAULT_CLAUDE_MODEL_FALLBACKS as Dn, cheapestReviewerModel as Dt, buildToolbeltAwareness as E, BUDGET_SMALL_FAST_SLUG as En, cheapestOracleModel as Et, ADVISOR_TOOL_INSTRUCTIONS as F, pickClaudeDefault as Fn, fastScoutModel as Ft, formatThinkingRepairDecline as G, CHEAP_PROFILE_MODELS as Gn, scoutModel as Gt, resolveAdvisorEffort as H, withOneMSuffix as Hn, resolveGeminiReviewModel as Ht, CHEAPEST_ADVISOR_TOOL_INSTRUCTIONS as I, resolveLeadSlugArg as In, fleetToolsEnabled as It, repairRejectedThinkingHistory as J, CHEAP_PROFILE_NATIVE_MODELS as Jn, workerToolsEnabled as Jt, rememberThinkingHistoryRepair as K, CHEAP_PROFILE_NATIVE_AGENT_NAMES as Kn, scribeModel as Kt, CHEAPEST_REVIEWER_ADVISOR_TOOL_INSTRUCTIONS as L, upstreamAllowH2 as Ln, geminiAvailable as Lt, satisfiesMinVersion as M, UPSTREAM_INACTIVITY_TIMEOUT_MS as Mn, fastOracleModel as Mt, searchWeb as N, generateRandomPort as Nn, fastPlanModel as Nt, toolbeltSkipSet as O, DEFAULT_CODEX_MODEL as On, cloudAgentToolsEnabled as Ot, ADVISOR_INTERNAL_TOOL_NAME as P, isBudgetClaudeLead as Pn, fastReviewerModel as Pt, logStreamError as Q, getTextTokenCount as Qt, FAST_ADVISOR_TOOL_INSTRUCTIONS as R, upstreamMaxConnections as Rn, generalPurposeFastModel as Rt, resolveWorkerRunOpts as S, shouldUseInsecureTls as Sn, cheapAdvisorModel as St, availableToolCommands as T, BUDGET_SMALL_FAST_CATALOG_ID as Tn, cheapestAdvisorModel as Tt, resolveAdvisorModel as U, withOneMSuffixForLead as Un, reviewerFastModel as Ut, isAdvisorRequested as V, oneMContextDisabled as Vn, nativeSubagentModel as Vt, resolveCheapestAdvisorModel as W, CHEAP_PROFILE_ADVISOR_CLIENT_MODEL as Wn, reviewerModel as Wt, buildOpenAIErrorEvent as X, countTokens as Xt, buildAnthropicErrorEvent as Y, CHEAP_PROFILE_SUBAGENT_CONTEXT_TOKENS as Yn, shimDefaultsToXhigh as Yt, isControllerClosedError as Z, createMessages as Zt, REVIEW_DEFAULT_MODEL as _, CONDENSED_OPERATING_SEQUENCE as _n, balancedReviewerModel as _t, buildAgentPrompt as a, warnOnTokenPriceDrift as an, handleMcpDelete as at, resolveDefaultModel as b, provisionAndIndexColbert as bn, browserCompoundToolsEnabled as bt, enumerateInjectedMcpToolNames as c, createChatCompletions as cn, buildAdoToolEntries as ct, BROWSE_DEFAULT_MODEL as d, parseJsonOrDiagnose as dn, ADO_DEFAULT_TOOLSETS as dt, getTokenizerFromModel as en, relayAnthropicStream as et, DEFAULT_MODEL_CHAIN as f, normalizeOpenAIUsage as fn, normalizeAdoToolsets as ft, PLAN_DEFAULT_MODEL as g, normalizeKustoClusterUri as gn, balancedOracleModel as gt, IMPLEMENT_DEFAULT_MODEL as h, normalizeCloudAgentEnvironment as hn, artifactToolsEnabled as ht, assertMcpToolSurfaceConsistent as i, assembleResponsesPayload as in, clampEffort as it, assetFor as j, UPSTREAM_FETCH_TIMEOUT_MS as jn, fastGeneralPurposeModel as jt, vscodeRipgrepPath as k, DEFAULT_CODEX_MODEL_FALLBACKS as kn, fastAdvisorModel as kt, maxPersonasFor as l, MAX_RESPONSE_BODY_BYTES as ln, disposeAdoClients as lt, EXPLORE_DEFAULT_THINKING as m, hasSupportedBrowserInstalled as mn, agentToolsEnabled as mt, MCP_GROUPS as n, registerLaunch as nn, UNKNOWN_EFFORT_ANCHOR as nt, buildPeerAwarenessSnippet as o, resolveMcpToolTimeoutMs as on, handleMcpPost as ot, EXPLORE_DEFAULT_MODEL as p, provisionBrowserAssets as pn, adoToolsEnabled as pt, repairKnownThinkingHistory as q, CHEAP_PROFILE_NATIVE_EFFORTS as qn, standInToolEnabled as qt, agentNamesForToolAllowlist as r, unregisterLaunch as rn, bucketEffort as rt, buildPeerAwarenessSummary as s, createResponses as sn, adoMcpToolEntries as st, GROUP_META as t, findLaunchBySecret as tn, EFFORT_ORDER as tt, personasFor as u, readResponseBodyCapped as un, provisionAdoTools as ut, TEST_DEFAULT_MODEL as v, DEFINITION_OF_GREATNESS as vn, brainstormModel as vt, buildEnv as w, toolbeltPathOverride as wn, cheapReviewerModel as wt, resolveModeDefaults as x, semanticSearchOptedIn as xn, browserToolsEnabled as xt, appendPlanReminder as y, colbertDegradedWarning as yn, browseAgentEnabled as yt, buildAdvisorStream as z, classifyMessagesRoute as zn, implementerFastModel as zt };
|
|
34835
37542
|
|
|
34836
|
-
//# sourceMappingURL=peer-mcp-personas-
|
|
37543
|
+
//# sourceMappingURL=peer-mcp-personas-GANlrtNR.js.map
|