github-router 0.3.354 → 0.3.356
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-DokE2DbX.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-8Uv97n9j.js → attribution-settings-CnmV9MSv.js} +11 -11
- package/dist/{attribution-settings-8Uv97n9j.js.map → attribution-settings-CnmV9MSv.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-C_1OM7ce.js → claude-DvR3Y7fu.js} +28 -27
- package/dist/claude-DvR3Y7fu.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-5eTmciDG.js → codex-DQpSPjpQ.js} +9 -9
- package/dist/{codex-5eTmciDG.js.map → codex-DQpSPjpQ.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-DgmsdkCe.js +1 -0
- package/dist/{gate-discovery-CqJVzT_D.js → gate-discovery-B2x_8hNL.js} +5 -5
- package/dist/{gate-discovery-CqJVzT_D.js.map → gate-discovery-B2x_8hNL.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-Dn_AF0BF.js → internal-stop-hook-Dm-m8RoA.js} +5 -5
- package/dist/{internal-stop-hook-Dn_AF0BF.js.map → internal-stop-hook-Dm-m8RoA.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-DlF1dKCs.js → peer-mcp-personas-CVxXq1Q-.js} +2859 -170
- package/dist/peer-mcp-personas-CVxXq1Q-.js.map +1 -0
- package/dist/{pi-2m2IgZlm.js → pi-D-BgxVhx.js} +22 -16
- package/dist/{pi-2m2IgZlm.js.map → pi-D-BgxVhx.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-DLGlhu3a.js → provision-DYmZgZDr.js} +6 -5
- package/dist/provision-DYmZgZDr.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-8tXHVHOr.js → serve-DfxxKLFl.js} +25 -17
- package/dist/serve-DfxxKLFl.js.map +1 -0
- package/dist/{server-setup-BBSmse1J.js → server-setup-VYf8ptCH.js} +168 -33
- package/dist/server-setup-VYf8ptCH.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-B7jTBpAc.js → start-BsY1d26G.js} +4 -4
- package/dist/{start-B7jTBpAc.js.map → start-BsY1d26G.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 +38 -25
- package/package.json +1 -1
- package/dist/ado-tools-CN4i9OVl.js +0 -1
- package/dist/bluebird-client-ltPIiyJU.js.map +0 -1
- package/dist/bluebird-client-mr3M67k-.js +0 -1
- package/dist/claude-C_1OM7ce.js.map +0 -1
- package/dist/engine-CIAopp0h.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-DlF1dKCs.js.map +0 -1
- package/dist/provision-DLGlhu3a.js.map +0 -1
- package/dist/serve-8tXHVHOr.js.map +0 -1
- package/dist/server-setup-BBSmse1J.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
|
/**
|
|
@@ -12970,23 +12970,23 @@ function normalizeKustoClusterUri(cluster) {
|
|
|
12970
12970
|
* than an option on it. The launch form stays permissive because an operator
|
|
12971
12971
|
* may legitimately point `--kusto-cluster` at a reverse proxy in front of ADX,
|
|
12972
12972
|
* and an options bag would let a future caller of the launch form omit the
|
|
12973
|
-
* strictness by accident.
|
|
12974
|
-
*
|
|
12975
|
-
*
|
|
12976
|
-
*
|
|
12977
|
-
* **This is a shape
|
|
12978
|
-
*
|
|
12979
|
-
*
|
|
12980
|
-
*
|
|
12981
|
-
*
|
|
12982
|
-
*
|
|
12983
|
-
*
|
|
12984
|
-
*
|
|
12985
|
-
*
|
|
12986
|
-
*
|
|
12987
|
-
*
|
|
12988
|
-
*
|
|
12989
|
-
*
|
|
12973
|
+
* strictness by accident. For a per-call hostname, require an exact `kusto`
|
|
12974
|
+
* DNS label at the beginning or after a dot, followed by another DNS label.
|
|
12975
|
+
* The suffix is unrestricted.
|
|
12976
|
+
*
|
|
12977
|
+
* **This is only a hostname-shape check, not an ownership allowlist or access
|
|
12978
|
+
* boundary.** The selected origin is both the Azure token audience and the
|
|
12979
|
+
* request destination, so the selected host receives the bearer token. Callers
|
|
12980
|
+
* must choose a trusted host; do not rely on this check or Entra rejecting a
|
|
12981
|
+
* caller-selected host to protect the token. RBAC governs access to data at a
|
|
12982
|
+
* genuine Kusto service, but it does not prevent disclosure of the bearer to an
|
|
12983
|
+
* untrusted endpoint.
|
|
12984
|
+
*
|
|
12985
|
+
* The label check catches a missing or misspelled `kusto` DNS label, not
|
|
12986
|
+
* whether the host belongs to Azure Data Explorer. For example,
|
|
12987
|
+
* `kusto.example.com` and `cluster.kusto.example.com` pass the shape check,
|
|
12988
|
+
* while `notkusto.example.com` does not. The requirement is intentionally
|
|
12989
|
+
* narrow and easy to explain, not a proof that an endpoint is trustworthy.
|
|
12990
12990
|
*
|
|
12991
12991
|
* The refusal text avoids a literal `https://` example on purpose: every
|
|
12992
12992
|
* `KustoError` message passes through `sanitizeRemoteDetail`, which rewrites a
|
|
@@ -12995,7 +12995,10 @@ function normalizeKustoClusterUri(cluster) {
|
|
|
12995
12995
|
*/
|
|
12996
12996
|
function normalizeKustoCallClusterUri(cluster) {
|
|
12997
12997
|
const origin = normalizeKustoClusterUri(cluster);
|
|
12998
|
-
|
|
12998
|
+
const labels = new URL(origin).hostname.split(".");
|
|
12999
|
+
const hasKustoLabel = labels.some((label, index) => label.toLowerCase() === "kusto" && index < labels.length - 1);
|
|
13000
|
+
const isValidDnsLabel = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?$/;
|
|
13001
|
+
if (!hasKustoLabel || !labels.every((label) => isValidDnsLabel.test(label))) throw new KustoError("`cluster` hostname must contain a standalone `kusto` DNS label followed by another label (for example `kusto.example.com`). This is a shape check, not host-ownership verification; choose a trusted host because the bearer token is sent there. Omit `cluster` to use the host set at launch with --kusto-cluster.", { retriable: false });
|
|
12999
13002
|
return origin;
|
|
13000
13003
|
}
|
|
13001
13004
|
/**
|
|
@@ -13041,7 +13044,7 @@ var KustoClient = class {
|
|
|
13041
13044
|
}
|
|
13042
13045
|
if (!(err instanceof KustoError ? err.retriable : true) || attempt >= this.retryDelaysMs.length) throw err;
|
|
13043
13046
|
const hint = err instanceof KustoError ? err.retryAfterMs : void 0;
|
|
13044
|
-
await sleep$
|
|
13047
|
+
await sleep$4(hint ?? this.retryDelaysMs[attempt], signal);
|
|
13045
13048
|
}
|
|
13046
13049
|
}
|
|
13047
13050
|
/**
|
|
@@ -13055,7 +13058,7 @@ var KustoClient = class {
|
|
|
13055
13058
|
const onAbort = () => controller.abort(signal?.reason ?? /* @__PURE__ */ new Error("aborted"));
|
|
13056
13059
|
if (signal?.aborted) onAbort();
|
|
13057
13060
|
else signal?.addEventListener("abort", onAbort, { once: true });
|
|
13058
|
-
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);
|
|
13059
13062
|
timer.unref?.();
|
|
13060
13063
|
let res;
|
|
13061
13064
|
try {
|
|
@@ -13082,7 +13085,7 @@ var KustoClient = class {
|
|
|
13082
13085
|
status: 401
|
|
13083
13086
|
});
|
|
13084
13087
|
}
|
|
13085
|
-
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.`, {
|
|
13086
13089
|
retriable: false,
|
|
13087
13090
|
status: 403
|
|
13088
13091
|
});
|
|
@@ -13098,7 +13101,7 @@ var KustoClient = class {
|
|
|
13098
13101
|
status: res.status,
|
|
13099
13102
|
...retryAfter === void 0 ? {} : { retryAfterMs: retryAfter }
|
|
13100
13103
|
});
|
|
13101
|
-
const text = await readBoundedBody(res);
|
|
13104
|
+
const text = await readBoundedBody$1(res);
|
|
13102
13105
|
if (!res.ok) throw new KustoError(`Kusto responded with HTTP ${res.status}: ${kustoErrorDetail(text)}`, {
|
|
13103
13106
|
retriable: false,
|
|
13104
13107
|
status: res.status
|
|
@@ -13452,7 +13455,7 @@ const KUSTO_GROUP = "kusto";
|
|
|
13452
13455
|
* hundred bytes while inviting a false reading that the per-cluster footprint
|
|
13453
13456
|
* is bounded. See the docs' note on a per-session distinct-cluster budget.
|
|
13454
13457
|
*/
|
|
13455
|
-
const clients = /* @__PURE__ */ new Map();
|
|
13458
|
+
const clients$1 = /* @__PURE__ */ new Map();
|
|
13456
13459
|
/**
|
|
13457
13460
|
* The cluster a call runs against: the call's own `cluster` first, else the
|
|
13458
13461
|
* launch's `--kusto-cluster`. Resolved synchronously, before a handler awaits
|
|
@@ -13465,17 +13468,17 @@ function resolveCluster(args) {
|
|
|
13465
13468
|
return normalizeKustoCallClusterUri(value);
|
|
13466
13469
|
}
|
|
13467
13470
|
const launch = state.kustoCluster;
|
|
13468
|
-
if (!launch) throw new KustoError("No Kusto cluster selected. Pass `cluster`
|
|
13471
|
+
if (!launch) throw new KustoError("No Kusto cluster selected. Pass `cluster` as an https URI whose hostname has a standalone `kusto` DNS label, or launch with `--kusto-cluster <uri>`. The bearer token is sent to the selected host, so choose a trusted host.", { retriable: false });
|
|
13469
13472
|
return normalizeKustoClusterUri(launch);
|
|
13470
13473
|
}
|
|
13471
13474
|
function kustoClient(clusterUri) {
|
|
13472
|
-
const existing = clients.get(clusterUri);
|
|
13475
|
+
const existing = clients$1.get(clusterUri);
|
|
13473
13476
|
if (existing) return existing;
|
|
13474
13477
|
const client = new KustoClient({
|
|
13475
13478
|
clusterUri,
|
|
13476
13479
|
...state.kustoDatabase ? { database: state.kustoDatabase } : {}
|
|
13477
13480
|
});
|
|
13478
|
-
clients.set(clusterUri, client);
|
|
13481
|
+
clients$1.set(clusterUri, client);
|
|
13479
13482
|
return client;
|
|
13480
13483
|
}
|
|
13481
13484
|
/**
|
|
@@ -13489,7 +13492,7 @@ function kustoClient(clusterUri) {
|
|
|
13489
13492
|
* client because the client's own cap bounds RENDERING work, and its trailer
|
|
13490
13493
|
* says so, while this one bounds what the model is asked to read.
|
|
13491
13494
|
*/
|
|
13492
|
-
async function text(value) {
|
|
13495
|
+
async function text$1(value) {
|
|
13493
13496
|
return { content: [{
|
|
13494
13497
|
type: "text",
|
|
13495
13498
|
text: await relaySafeText(value)
|
|
@@ -13514,7 +13517,7 @@ const DATABASE_PROPERTY = { database: {
|
|
|
13514
13517
|
*/
|
|
13515
13518
|
const CLUSTER_PROPERTY = { cluster: {
|
|
13516
13519
|
type: "string",
|
|
13517
|
-
description: "Kusto cluster to query, e.g. https://
|
|
13520
|
+
description: "Kusto cluster to query. A caller-supplied hostname must contain a standalone `kusto` DNS label (at the start or after a dot; any suffix, e.g. https://cluster.kusto.example.com). This is only a shape check, not host-ownership verification. The Azure bearer token is sent to the selected host, so use only a trusted host. Defaults to the launch's --kusto-cluster, and is required when that was not set."
|
|
13518
13521
|
} };
|
|
13519
13522
|
const READ_ONLY_NOTE = " Read-only: the request runs under service-enforced read-only mode, so a mutating command is refused by Kusto rather than by this proxy.";
|
|
13520
13523
|
const KUSTO_TOOLS = Object.freeze([
|
|
@@ -13529,7 +13532,7 @@ const KUSTO_TOOLS = Object.freeze([
|
|
|
13529
13532
|
properties: { ...CLUSTER_PROPERTY }
|
|
13530
13533
|
},
|
|
13531
13534
|
async handler(args, signal) {
|
|
13532
|
-
return text(await kustoClient(resolveCluster(args)).databasesList(signal));
|
|
13535
|
+
return text$1(await kustoClient(resolveCluster(args)).databasesList(signal));
|
|
13533
13536
|
}
|
|
13534
13537
|
},
|
|
13535
13538
|
{
|
|
@@ -13548,7 +13551,7 @@ const KUSTO_TOOLS = Object.freeze([
|
|
|
13548
13551
|
async handler(args, signal) {
|
|
13549
13552
|
const cluster = resolveCluster(args);
|
|
13550
13553
|
const { database } = databaseArg(args);
|
|
13551
|
-
return text(await kustoClient(cluster).tablesList(database, signal));
|
|
13554
|
+
return text$1(await kustoClient(cluster).tablesList(database, signal));
|
|
13552
13555
|
}
|
|
13553
13556
|
},
|
|
13554
13557
|
{
|
|
@@ -13572,7 +13575,7 @@ const KUSTO_TOOLS = Object.freeze([
|
|
|
13572
13575
|
async handler(args, signal) {
|
|
13573
13576
|
const cluster = resolveCluster(args);
|
|
13574
13577
|
const { database } = databaseArg(args);
|
|
13575
|
-
return text(await kustoClient(cluster).tableSchema(String(args.table ?? ""), database, signal));
|
|
13578
|
+
return text$1(await kustoClient(cluster).tableSchema(String(args.table ?? ""), database, signal));
|
|
13576
13579
|
}
|
|
13577
13580
|
},
|
|
13578
13581
|
{
|
|
@@ -13601,7 +13604,7 @@ const KUSTO_TOOLS = Object.freeze([
|
|
|
13601
13604
|
const cluster = resolveCluster(args);
|
|
13602
13605
|
const { database } = databaseArg(args);
|
|
13603
13606
|
const rows = typeof args.rows === "number" ? args.rows : 10;
|
|
13604
|
-
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));
|
|
13605
13608
|
}
|
|
13606
13609
|
},
|
|
13607
13610
|
{
|
|
@@ -13627,7 +13630,7 @@ const KUSTO_TOOLS = Object.freeze([
|
|
|
13627
13630
|
const { database } = databaseArg(args);
|
|
13628
13631
|
const csl = typeof args.csl === "string" ? args.csl : "";
|
|
13629
13632
|
if (!csl.trim()) throw new KustoError("`csl` must be a non-empty KQL query.", { retriable: false });
|
|
13630
|
-
return text(renderKustoResponse(await kustoClient(cluster).runCsl(csl, {
|
|
13633
|
+
return text$1(renderKustoResponse(await kustoClient(cluster).runCsl(csl, {
|
|
13631
13634
|
...database ? { database } : {},
|
|
13632
13635
|
...signal ? { signal } : {}
|
|
13633
13636
|
})));
|
|
@@ -13635,6 +13638,2666 @@ const KUSTO_TOOLS = Object.freeze([
|
|
|
13635
13638
|
}
|
|
13636
13639
|
]);
|
|
13637
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
|
+
* `create_pr_job` runs on the `complex` preset. Turning a ticket into a
|
|
15050
|
+
* review-ready pull request is long-horizon work by definition, which is what
|
|
15051
|
+
* that preset is for; `create_job` keeps its own `normal` default.
|
|
15052
|
+
*/
|
|
15053
|
+
const PR_JOB_DEFAULT_TIER = "complex";
|
|
15054
|
+
/**
|
|
15055
|
+
* One client per environment, built lazily.
|
|
15056
|
+
*
|
|
15057
|
+
* There is no per-call environment argument and no configurable base URL: the
|
|
15058
|
+
* bearer token's Entra audience and the request destination are the same origin
|
|
15059
|
+
* by construction, so nothing the model writes can point the token at another
|
|
15060
|
+
* host. The environment (prod/ppe) is a launch decision (`--cloudagent-env`), which
|
|
15061
|
+
* is the `COPILOT_HOST_ALLOWLIST` argument applied by removing the knob rather
|
|
15062
|
+
* than validating it.
|
|
15063
|
+
*/
|
|
15064
|
+
const clients = /* @__PURE__ */ new Map();
|
|
15065
|
+
function cloudAgentClient() {
|
|
15066
|
+
const environment = normalizeCloudAgentEnvironment(state.cloudAgentEnvironment ?? "prod");
|
|
15067
|
+
const existing = clients.get(environment);
|
|
15068
|
+
if (existing) return existing;
|
|
15069
|
+
const client = new CloudAgentClient({ environment });
|
|
15070
|
+
clients.set(environment, client);
|
|
15071
|
+
return client;
|
|
15072
|
+
}
|
|
15073
|
+
let repoIdResolver = resolveAzureRepoIds;
|
|
15074
|
+
/**
|
|
15075
|
+
* Process-lifetime cache of a terminal job's deliverable, keyed by environment
|
|
15076
|
+
* and job id.
|
|
15077
|
+
*
|
|
15078
|
+
* `null` is meaningful and is why `Map.has` is never used as the predicate: it
|
|
15079
|
+
* records "the trace was read and it has no summary", which is the common case
|
|
15080
|
+
* for a FAILED job. Without the negative entry every poll of a failed job would
|
|
15081
|
+
* re-download a multi-megabyte trace to learn the same nothing.
|
|
15082
|
+
*
|
|
15083
|
+
* Bounded because job ids are unbounded and each value can be a long model
|
|
15084
|
+
* summary; FIFO eviction is enough — a re-read is one request, not a
|
|
15085
|
+
* correctness problem.
|
|
15086
|
+
*/
|
|
15087
|
+
const summaryCache = /* @__PURE__ */ new Map();
|
|
15088
|
+
const SUMMARY_CACHE_MAX = 64;
|
|
15089
|
+
function cachedSummary(key) {
|
|
15090
|
+
if (!summaryCache.has(key)) return { hit: false };
|
|
15091
|
+
return {
|
|
15092
|
+
hit: true,
|
|
15093
|
+
summary: summaryCache.get(key) ?? null
|
|
15094
|
+
};
|
|
15095
|
+
}
|
|
15096
|
+
function storeSummary(key, summary) {
|
|
15097
|
+
if (summaryCache.size >= SUMMARY_CACHE_MAX) {
|
|
15098
|
+
const oldest = summaryCache.keys().next();
|
|
15099
|
+
if (!oldest.done) summaryCache.delete(oldest.value);
|
|
15100
|
+
}
|
|
15101
|
+
summaryCache.set(key, summary);
|
|
15102
|
+
}
|
|
15103
|
+
async function text(value) {
|
|
15104
|
+
return { content: [{
|
|
15105
|
+
type: "text",
|
|
15106
|
+
text: await relaySafeText(value)
|
|
15107
|
+
}] };
|
|
15108
|
+
}
|
|
15109
|
+
function isPlainObject(value) {
|
|
15110
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15111
|
+
}
|
|
15112
|
+
function requiredString(args, key) {
|
|
15113
|
+
const value = args[key];
|
|
15114
|
+
if (typeof value !== "string" || !value.trim()) throw new CloudAgentError(`\`${key}\` is required and must be a non-empty string.`, { retriable: false });
|
|
15115
|
+
return value.trim();
|
|
15116
|
+
}
|
|
15117
|
+
function optionalString(args, key) {
|
|
15118
|
+
const value = args[key];
|
|
15119
|
+
if (value === void 0 || value === null) return void 0;
|
|
15120
|
+
if (typeof value !== "string") throw new CloudAgentError(`\`${key}\` must be a string when provided.`, { retriable: false });
|
|
15121
|
+
const trimmed = value.trim();
|
|
15122
|
+
return trimmed ? trimmed : void 0;
|
|
15123
|
+
}
|
|
15124
|
+
function optionalInt(args, key, min, max) {
|
|
15125
|
+
const value = args[key];
|
|
15126
|
+
if (value === void 0 || value === null) return void 0;
|
|
15127
|
+
if (value === 0 && min > 0) return void 0;
|
|
15128
|
+
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 });
|
|
15129
|
+
return value;
|
|
15130
|
+
}
|
|
15131
|
+
function oneLine(value, max) {
|
|
15132
|
+
const single = value.replace(/\s*\r?\n\s*/g, " ⏎ ");
|
|
15133
|
+
return single.length > max ? `${single.slice(0, max)}…` : single;
|
|
15134
|
+
}
|
|
15135
|
+
function provenanceLine(repository) {
|
|
15136
|
+
if (!repository.inferredFrom) return void 0;
|
|
15137
|
+
return `[repository: ${[
|
|
15138
|
+
repository.organization,
|
|
15139
|
+
repository.project,
|
|
15140
|
+
repository.repository
|
|
15141
|
+
].filter((part) => part !== void 0).join("/")} (inferred from ${repository.inferredFrom})]`;
|
|
15142
|
+
}
|
|
15143
|
+
/** The three components together, or none of them. A partial set is a typo. */
|
|
15144
|
+
function repositoryFromArgs(args) {
|
|
15145
|
+
const organization = optionalString(args, "organization");
|
|
15146
|
+
const project = optionalString(args, "project");
|
|
15147
|
+
const repository = optionalString(args, "repository");
|
|
15148
|
+
const given = [
|
|
15149
|
+
organization,
|
|
15150
|
+
project,
|
|
15151
|
+
repository
|
|
15152
|
+
].filter((part) => part !== void 0).length;
|
|
15153
|
+
if (given === 0) return void 0;
|
|
15154
|
+
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 });
|
|
15155
|
+
return {
|
|
15156
|
+
organization,
|
|
15157
|
+
project,
|
|
15158
|
+
repository
|
|
15159
|
+
};
|
|
15160
|
+
}
|
|
15161
|
+
/**
|
|
15162
|
+
* The repository a job runs against: the explicit triple, else whatever the
|
|
15163
|
+
* `workspace` checkout's git remote says.
|
|
15164
|
+
*
|
|
15165
|
+
* The workspace is resolved by the MCP boundary (`X-GH-Workspace`, or the
|
|
15166
|
+
* caller's own argument), and `ctx.workspaceSource` records which — that is the
|
|
15167
|
+
* difference between "you told me" and "I guessed", and only the guess gets a
|
|
15168
|
+
* provenance line. There is deliberately no `process.cwd()` fallback for
|
|
15169
|
+
* `create_job`: the proxy is started once from wherever the operator was, so a
|
|
15170
|
+
* stale cwd would spend real compute filing a job against the wrong repository.
|
|
15171
|
+
*
|
|
15172
|
+
* A FILTER is a different question with its own resolver
|
|
15173
|
+
* (`resolveRepositoryFilter`): it may name only the organization, and a
|
|
15174
|
+
* checkout it cannot read is reported as the reason the filter was dropped
|
|
15175
|
+
* rather than failing the call. Treating that as an error was tried and is
|
|
15176
|
+
* wrong in practice: a model that names its checkout on every call (Claude
|
|
15177
|
+
* Code fills optional properties rather than omitting them) turned every
|
|
15178
|
+
* `list_jobs` in a non-Azure-DevOps repository into an error, for a filter it
|
|
15179
|
+
* did not need.
|
|
15180
|
+
*/
|
|
15181
|
+
async function resolveRepository(args, ctx, opts) {
|
|
15182
|
+
const explicit = repositoryFromArgs(args);
|
|
15183
|
+
if (explicit) return explicit;
|
|
15184
|
+
const { repository } = await repositoryFromWorkspace(args, ctx, {
|
|
15185
|
+
required: true,
|
|
15186
|
+
...opts
|
|
15187
|
+
});
|
|
15188
|
+
return repository;
|
|
15189
|
+
}
|
|
15190
|
+
/**
|
|
15191
|
+
* Read the repository off the named `workspace`'s git remote. `required`
|
|
15192
|
+
* decides whether a missing or unreadable checkout fails the call or is
|
|
15193
|
+
* reported back as the reason the repository was not used.
|
|
15194
|
+
*/
|
|
15195
|
+
async function repositoryFromWorkspace(args, ctx, opts) {
|
|
15196
|
+
const workspace = optionalString(args, "workspace");
|
|
15197
|
+
const hint = opts.requiredHint ?? "`organization`, `project` and `repository`";
|
|
15198
|
+
if (!workspace) {
|
|
15199
|
+
if (!opts.required) return {};
|
|
15200
|
+
throw new CloudAgentError(`No repository: pass ${hint}, or \`workspace\` pointing at a checkout whose git remote is an Azure DevOps repository.`, { retriable: false });
|
|
15201
|
+
}
|
|
15202
|
+
if (!/^(?:[A-Za-z]:[\\/]|[\\/])/.test(workspace)) throw new CloudAgentError(`\`workspace\` must be an absolute path; got "${workspace}".`, { retriable: false });
|
|
15203
|
+
try {
|
|
15204
|
+
const info = await getAzureRepoFromGit(workspace, opts.signal);
|
|
15205
|
+
return { repository: {
|
|
15206
|
+
organization: info.organization,
|
|
15207
|
+
project: info.project,
|
|
15208
|
+
repository: info.repository,
|
|
15209
|
+
inferredFrom: ctx?.workspaceSource === "session" ? "this session's workspace" : "the workspace you passed"
|
|
15210
|
+
} };
|
|
15211
|
+
} catch (err) {
|
|
15212
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
15213
|
+
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 });
|
|
15214
|
+
return { unresolvedDetail: `Could not read an Azure DevOps repository from "${workspace}": ${detail}` };
|
|
15215
|
+
}
|
|
15216
|
+
}
|
|
15217
|
+
function repositoryFilterFromArgs(args) {
|
|
15218
|
+
const organization = optionalString(args, "organization");
|
|
15219
|
+
const project = optionalString(args, "project");
|
|
15220
|
+
const repository = optionalString(args, "repository");
|
|
15221
|
+
if (organization === void 0) {
|
|
15222
|
+
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 });
|
|
15223
|
+
return;
|
|
15224
|
+
}
|
|
15225
|
+
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 });
|
|
15226
|
+
return {
|
|
15227
|
+
organization,
|
|
15228
|
+
project,
|
|
15229
|
+
repository
|
|
15230
|
+
};
|
|
15231
|
+
}
|
|
15232
|
+
async function resolveRepositoryFilter(args, ctx, signal) {
|
|
15233
|
+
const explicit = repositoryFilterFromArgs(args);
|
|
15234
|
+
if (explicit) return { filter: explicit };
|
|
15235
|
+
const resolution = await repositoryFromWorkspace(args, ctx, {
|
|
15236
|
+
required: false,
|
|
15237
|
+
signal
|
|
15238
|
+
});
|
|
15239
|
+
const inferred = resolution.repository;
|
|
15240
|
+
if (!inferred) return { unresolvedDetail: resolution.unresolvedDetail };
|
|
15241
|
+
return { filter: {
|
|
15242
|
+
organization: inferred.organization,
|
|
15243
|
+
project: inferred.project,
|
|
15244
|
+
repository: inferred.repository,
|
|
15245
|
+
inferredFrom: inferred.inferredFrom
|
|
15246
|
+
} };
|
|
15247
|
+
}
|
|
15248
|
+
const AGENT_TYPES = [
|
|
15249
|
+
"Repo",
|
|
15250
|
+
"Organization",
|
|
15251
|
+
"Company",
|
|
15252
|
+
"Spec"
|
|
15253
|
+
];
|
|
15254
|
+
function agentTypeValue(args, key) {
|
|
15255
|
+
const value = optionalString(args, key);
|
|
15256
|
+
if (!value) return void 0;
|
|
15257
|
+
const match = AGENT_TYPES.find((type) => type.toLowerCase() === value.toLowerCase());
|
|
15258
|
+
if (!match) throw new CloudAgentError(`\`${key}\` must be one of ${AGENT_TYPES.join(", ")}.`, { retriable: false });
|
|
15259
|
+
return match;
|
|
15260
|
+
}
|
|
15261
|
+
function agentTypeArg(args) {
|
|
15262
|
+
return agentTypeValue(args, "agentType");
|
|
15263
|
+
}
|
|
15264
|
+
function agentInputsArg(args) {
|
|
15265
|
+
const value = args.agentInputs;
|
|
15266
|
+
if (value === void 0 || value === null) return void 0;
|
|
15267
|
+
if (!isPlainObject(value)) throw new CloudAgentError("`agentInputs` must be an object of scalar values.", { retriable: false });
|
|
15268
|
+
const inputs = {};
|
|
15269
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
15270
|
+
if (typeof entry === "string" || typeof entry === "number" || typeof entry === "boolean") {
|
|
15271
|
+
inputs[key] = entry;
|
|
15272
|
+
continue;
|
|
15273
|
+
}
|
|
15274
|
+
throw new CloudAgentError(`\`agentInputs.${key}\` must be a string, number or boolean.`, { retriable: false });
|
|
15275
|
+
}
|
|
15276
|
+
return Object.keys(inputs).length > 0 ? inputs : void 0;
|
|
15277
|
+
}
|
|
15278
|
+
function pluginsArg(args) {
|
|
15279
|
+
const value = args.plugins;
|
|
15280
|
+
if (value === void 0 || value === null) return void 0;
|
|
15281
|
+
if (!Array.isArray(value)) throw new CloudAgentError("`plugins` must be an array of plugin names.", { retriable: false });
|
|
15282
|
+
const plugins = [];
|
|
15283
|
+
for (const entry of value) {
|
|
15284
|
+
if (typeof entry !== "string" || !entry.trim()) throw new CloudAgentError("Every entry of `plugins` must be a non-empty plugin name.", { retriable: false });
|
|
15285
|
+
plugins.push({ name: entry.trim() });
|
|
15286
|
+
}
|
|
15287
|
+
return plugins.length > 0 ? plugins : void 0;
|
|
15288
|
+
}
|
|
15289
|
+
function metadataArg(args) {
|
|
15290
|
+
const value = args.metadata;
|
|
15291
|
+
if (value === void 0 || value === null) return void 0;
|
|
15292
|
+
if (!isPlainObject(value)) throw new CloudAgentError("`metadata` must be an object of short string labels, e.g. {\"chain\": \"research\", \"step\": \"1\"}.", { retriable: false });
|
|
15293
|
+
return value;
|
|
15294
|
+
}
|
|
15295
|
+
/**
|
|
15296
|
+
* Echo the normalized body the service received.
|
|
15297
|
+
*
|
|
15298
|
+
* This is what makes a follow-up job a follow-up: `GET /jobs/{id}` does not
|
|
15299
|
+
* return `modelConfiguration`, so nothing else can tell the caller which effort
|
|
15300
|
+
* and context tier the first job used. Showing it turns "inherit the settings"
|
|
15301
|
+
* into "copy these lines", which is verifiable instead of hoped for.
|
|
15302
|
+
*/
|
|
15303
|
+
function renderEffectiveRequest(request) {
|
|
15304
|
+
const lines = [];
|
|
15305
|
+
const repository = request.context.repository;
|
|
15306
|
+
const branch = repository.branch ? ` branch ${repository.branch}` : "";
|
|
15307
|
+
lines.push(` repository: ${repository.organization}/${repository.project}/${repository.repository}${branch}`);
|
|
15308
|
+
if (request.prompt) lines.push(` prompt: ${oneLine(request.prompt, 300)}`);
|
|
15309
|
+
if (request.customAgent) {
|
|
15310
|
+
const agent = request.customAgent;
|
|
15311
|
+
const parts = [` agent: ${agent.name}`];
|
|
15312
|
+
if (agent.type) parts.push(`(${agent.type})`);
|
|
15313
|
+
if (agent.pluginName) parts.push(`from plugin ${agent.pluginName}`);
|
|
15314
|
+
if (agent.inputs) {
|
|
15315
|
+
const inputs = Object.entries(agent.inputs).map(([key, value]) => `${key}=${String(value)}`);
|
|
15316
|
+
parts.push(`inputs: ${inputs.join(", ")}`);
|
|
15317
|
+
}
|
|
15318
|
+
lines.push(parts.join(" "));
|
|
15319
|
+
}
|
|
15320
|
+
if (request.plugins) lines.push(` plugins: ${request.plugins.map((plugin) => plugin.name).join(", ")}`);
|
|
15321
|
+
if (request.additionalOptions?.pluginOptions?.includeDefaults) lines.push(" default plugins: included");
|
|
15322
|
+
const model = request.modelConfiguration;
|
|
15323
|
+
if (model) {
|
|
15324
|
+
const parts = [];
|
|
15325
|
+
if (model.model) parts.push(`model ${model.model}`);
|
|
15326
|
+
if (model.reasoningEffort) parts.push(`effort ${model.reasoningEffort}`);
|
|
15327
|
+
if (model.context) parts.push(`context ${model.context}`);
|
|
15328
|
+
if (parts.length > 0) lines.push(` ${parts.join(", ")}`);
|
|
15329
|
+
}
|
|
15330
|
+
if (request.metadata) {
|
|
15331
|
+
const labels = Object.entries(request.metadata).map(([key, value]) => `${key}=${value}`);
|
|
15332
|
+
lines.push(` metadata: ${labels.join(" ")}`);
|
|
15333
|
+
}
|
|
15334
|
+
return lines.join("\n");
|
|
15335
|
+
}
|
|
15336
|
+
/**
|
|
15337
|
+
* The plan caps this at 50 s. Two reasons, and the second is the real one:
|
|
15338
|
+
* a raw-JSON MCP client is capped at ~60 s per call (Claude Code regression
|
|
15339
|
+
* #50289), and no wait that fits in one call can observe a terminal state anyway
|
|
15340
|
+
* — across 161 jobs none finished in under 60 seconds and the shortest took 3
|
|
15341
|
+
* minutes. So the contract is deliberately
|
|
15342
|
+
* "did the handoff take, or is this stuck in the queue?", which is the one
|
|
15343
|
+
* question a short wait can actually answer.
|
|
15344
|
+
*/
|
|
15345
|
+
const WAIT_DEFAULT_S = 25;
|
|
15346
|
+
const WAIT_MAX_S = 50;
|
|
15347
|
+
const WAIT_POLL_MS = 3e3;
|
|
15348
|
+
function sleep(ms, signal) {
|
|
15349
|
+
return new Promise((resolve, reject) => {
|
|
15350
|
+
if (signal?.aborted) {
|
|
15351
|
+
reject(/* @__PURE__ */ new Error("wait_for_job was cancelled."));
|
|
15352
|
+
return;
|
|
15353
|
+
}
|
|
15354
|
+
const timer = setTimeout(() => {
|
|
15355
|
+
signal?.removeEventListener("abort", onAbort);
|
|
15356
|
+
resolve();
|
|
15357
|
+
}, ms);
|
|
15358
|
+
function onAbort() {
|
|
15359
|
+
clearTimeout(timer);
|
|
15360
|
+
reject(/* @__PURE__ */ new Error("wait_for_job was cancelled."));
|
|
15361
|
+
}
|
|
15362
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
15363
|
+
});
|
|
15364
|
+
}
|
|
15365
|
+
const WORKSPACE_PROPERTY = { workspace: {
|
|
15366
|
+
type: "string",
|
|
15367
|
+
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."
|
|
15368
|
+
} };
|
|
15369
|
+
/**
|
|
15370
|
+
* One optional repository, split across the three fields the API takes.
|
|
15371
|
+
*
|
|
15372
|
+
* All three are omitted together in the normal case: the workspace's git remote
|
|
15373
|
+
* supplies them and the result says so. They exist for the case where there is
|
|
15374
|
+
* no checkout to read, so the descriptions have to keep a model from filling
|
|
15375
|
+
* one or two of them as if they were independent filters.
|
|
15376
|
+
*/
|
|
15377
|
+
const REPOSITORY_PROPERTIES = {
|
|
15378
|
+
organization: {
|
|
15379
|
+
type: "string",
|
|
15380
|
+
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."
|
|
15381
|
+
},
|
|
15382
|
+
project: {
|
|
15383
|
+
type: "string",
|
|
15384
|
+
description: "Azure DevOps project. Default: read from `workspace`'s git remote. Only with `organization` and `repository`."
|
|
15385
|
+
},
|
|
15386
|
+
repository: {
|
|
15387
|
+
type: "string",
|
|
15388
|
+
description: "Repository name inside the project. Default: read from `workspace`'s git remote. Only with `organization` and `project`."
|
|
15389
|
+
}
|
|
15390
|
+
};
|
|
15391
|
+
/**
|
|
15392
|
+
* The same three names, as a FILTER rather than a job target.
|
|
15393
|
+
*
|
|
15394
|
+
* The shapes differ on purpose. A job needs one exact repository, so its three
|
|
15395
|
+
* fields are all-or-none. A filter is a narrowing, and the service matches the
|
|
15396
|
+
* organization by name, so naming only the organization is both legal and
|
|
15397
|
+
* useful; the project and repository then narrow within it. Each description
|
|
15398
|
+
* says what its default is and what it overlays, because a model that cannot
|
|
15399
|
+
* see the handler will otherwise fill in a guess.
|
|
15400
|
+
*/
|
|
15401
|
+
const FILTER_REPOSITORY_PROPERTIES = {
|
|
15402
|
+
organization: {
|
|
15403
|
+
type: "string",
|
|
15404
|
+
description: "Azure DevOps organization to narrow to. Default: read from `workspace`'s git remote. Pass it alone to list every job in the organization."
|
|
15405
|
+
},
|
|
15406
|
+
project: {
|
|
15407
|
+
type: "string",
|
|
15408
|
+
description: "Azure DevOps project name, within `organization`. Default: the project read from `workspace`'s git remote. Requires `organization`."
|
|
15409
|
+
},
|
|
15410
|
+
repository: {
|
|
15411
|
+
type: "string",
|
|
15412
|
+
description: "Repository name within `project`. Default: the repository read from `workspace`'s git remote. Requires `organization` and `project`."
|
|
15413
|
+
}
|
|
15414
|
+
};
|
|
15415
|
+
/**
|
|
15416
|
+
* The same three names again, as the Azure DevOps CONTEXT a catalog scope reads.
|
|
15417
|
+
*
|
|
15418
|
+
* Measured live (2026-10-30), and the scopes do NOT want the same thing:
|
|
15419
|
+
*
|
|
15420
|
+
* - `Repo` reads one repository, so it needs all three. Organization alone earns
|
|
15421
|
+
* "ProjectName in Azure DevOps context is required for Repo agents/plugins",
|
|
15422
|
+
* organization+project earns "RepositoryName ... is required", and
|
|
15423
|
+
* organization+repository earns "Project is required when Repository is
|
|
15424
|
+
* specified."
|
|
15425
|
+
* - `Organization` reads an organization's own marketplace, so the organization
|
|
15426
|
+
* alone is enough: org-only, org+project, org+repository and the full triple
|
|
15427
|
+
* all answer identically. Demanding the other two here would make a caller
|
|
15428
|
+
* with no checkout invent names the service never reads.
|
|
15429
|
+
* - Company, Spec and untyped calls read no context at all.
|
|
15430
|
+
*
|
|
15431
|
+
* So the descriptions state per scope which names are required rather than
|
|
15432
|
+
* borrowing create_job's all-or-none job-target wording, which would read as if a
|
|
15433
|
+
* plain `list_plugins` call needed a repository.
|
|
15434
|
+
*/
|
|
15435
|
+
const CATALOG_REPOSITORY_PROPERTIES = {
|
|
15436
|
+
organization: {
|
|
15437
|
+
type: "string",
|
|
15438
|
+
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."
|
|
15439
|
+
},
|
|
15440
|
+
project: {
|
|
15441
|
+
type: "string",
|
|
15442
|
+
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."
|
|
15443
|
+
},
|
|
15444
|
+
repository: {
|
|
15445
|
+
type: "string",
|
|
15446
|
+
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."
|
|
15447
|
+
}
|
|
15448
|
+
};
|
|
15449
|
+
const JOB_ID_PROPERTY = { jobId: {
|
|
15450
|
+
type: "string",
|
|
15451
|
+
description: "The job id returned by create_job or listed by list_jobs."
|
|
15452
|
+
} };
|
|
15453
|
+
/**
|
|
15454
|
+
* The engineering process `create_pr_job` prepends to every task.
|
|
15455
|
+
*
|
|
15456
|
+
* The Job API has no system-prompt field (a live validate probe on 2026-10-31
|
|
15457
|
+
* sent one, got a 200, and the field was ignored and not echoed), so the only
|
|
15458
|
+
* instruction surface is `prompt`. The directive is therefore literal text in
|
|
15459
|
+
* front of the caller's task, and the task is wrapped in <user_task> tags so
|
|
15460
|
+
* "how to work" and "what to build" stay distinguishable inside one string.
|
|
15461
|
+
*
|
|
15462
|
+
* The wording follows the frontier-model guidance current on 2026-10-31:
|
|
15463
|
+
* Anthropic's general prompting guide and its Claude Opus 5.5 guide. The
|
|
15464
|
+
* choices worth knowing before editing it:
|
|
15465
|
+
*
|
|
15466
|
+
* - Name the early stops an unattended run tends to take (a status summary,
|
|
15467
|
+
* an offer to continue, a decision list for a user who is not there) and
|
|
15468
|
+
* say what to do instead. The Opus 5.5 guide is explicit about these.
|
|
15469
|
+
* - Give delegation rules, not just permission: the same guide warns that
|
|
15470
|
+
* models both over-spawn and under-spawn subagents.
|
|
15471
|
+
* - Point at the actual request. A long procedural prompt otherwise invites
|
|
15472
|
+
* the model to optimize the process rather than answer the task.
|
|
15473
|
+
* - State outcomes and exit criteria rather than reasoning steps, and use
|
|
15474
|
+
* plain phrasing instead of stacked emphasis.
|
|
15475
|
+
*
|
|
15476
|
+
* Keep the version marker, and bump it when the workflow changes: the tests
|
|
15477
|
+
* pin the structure, and the marker is what makes a job's behavior traceable
|
|
15478
|
+
* to the directive that produced it.
|
|
15479
|
+
*/
|
|
15480
|
+
const PR_JOB_WORKFLOW = `[github-router PR workflow v3]
|
|
15481
|
+
|
|
15482
|
+
# Role
|
|
15483
|
+
|
|
15484
|
+
You are an autonomous software engineer responsible for one repository and one request. Carry the request in <user_task> from understanding to a review-ready pull request whose required checks pass.
|
|
15485
|
+
|
|
15486
|
+
# The request
|
|
15487
|
+
|
|
15488
|
+
The text inside <user_task> at the end of this prompt is the actual request. Everything else in this prompt is process: how to work, not what to build. Read <user_task> before you plan or edit, restate it in your own words in your first status note, and check your work against it in every phase. If it is ambiguous, resolve the ambiguity in the way that best serves what it asks for and record the assumption. Do not substitute a different improvement for the one it asks for.
|
|
15489
|
+
|
|
15490
|
+
# Operating context
|
|
15491
|
+
|
|
15492
|
+
- This is a one-shot job. It cannot be resumed, and no one will answer questions while it runs.
|
|
15493
|
+
- You start from a fresh clone of the repository and see only this prompt.
|
|
15494
|
+
- Repository guidance (AGENTS.md, CLAUDE.md, CONTRIBUTING, build and test docs) is authoritative. Read it first. Where it conflicts with this prompt, follow the repository and note the conflict in your final report.
|
|
15495
|
+
- Your tools include the checkout, a shell, and the coding plugin's Azure DevOps write tools for branches, commits, pushes, pull requests, pipelines, and work items.
|
|
15496
|
+
|
|
15497
|
+
# Definition of done
|
|
15498
|
+
|
|
15499
|
+
1. A pull request is open from a new branch against the repository's base branch.
|
|
15500
|
+
2. Every required check for that pull request has passed, or each one that cannot pass has a precise written explanation.
|
|
15501
|
+
3. The pull request links a work item.
|
|
15502
|
+
4. Your final report contains the evidence described under Reporting.
|
|
15503
|
+
|
|
15504
|
+
# Staying in motion
|
|
15505
|
+
|
|
15506
|
+
This run is unattended. Nobody will reply while you work, so a turn that ends with a status report has nowhere to go.
|
|
15507
|
+
|
|
15508
|
+
- Put status notes in the same message as your next tool call, then continue.
|
|
15509
|
+
- Keep a checklist of the request's parts, update it as you go, and keep working until every item is done or blocked.
|
|
15510
|
+
- When something you started is still running, such as a background command or a subagent, wait for its result and continue.
|
|
15511
|
+
- Stop only when the definition of done is met, or when a blocker genuinely needs a human, and then report the exact blocker.
|
|
15512
|
+
|
|
15513
|
+
# Working style
|
|
15514
|
+
|
|
15515
|
+
**Delegation.** Use subagents when work can run in parallel, needs isolated context, or splits into independent workstreams that do not share state: exploring separate areas, running independent checks, or reviewing work you produced. Do the sequential work, single-file edits, and steps that need accumulated context yourself. When your tooling supports it, use a separate subagent for the plan review and the implementation review, so the reviewer is independent of the author.
|
|
15516
|
+
|
|
15517
|
+
**Parallel calls.** When several tool calls are independent, issue them together rather than one at a time. Keep dependent calls sequential.
|
|
15518
|
+
|
|
15519
|
+
**Scope.** Make the changes the request needs and the changes they require to be correct. Do not add features, refactor surrounding code, or make improvements the request did not ask for. Every change in the plan and the diff should trace to the request or to the correctness of that change.
|
|
15520
|
+
|
|
15521
|
+
**Grounding.** Base claims on files you opened and command output you saw. Do not speculate about code you have not read.
|
|
15522
|
+
|
|
15523
|
+
**Quality.** Tests verify correctness; they do not define the solution. Implement the general behavior for all valid inputs rather than the values the tests happen to use. Do not hard-code results or add workarounds that only satisfy the checks.
|
|
15524
|
+
|
|
15525
|
+
**Reversibility.** Take local, reversible actions freely. Avoid destructive shortcuts: no force-push, no rewriting published history, no deleting branches, files, or data you do not understand.
|
|
15526
|
+
|
|
15527
|
+
# Process
|
|
15528
|
+
|
|
15529
|
+
Work through these phases in order. Parallelize only independent work.
|
|
15530
|
+
|
|
15531
|
+
## 1. Understand
|
|
15532
|
+
Read the repository guidance, then the code, tests, history, and any named work item that the request touches. Confirm what the request actually asks for before proposing a solution. Be able to state the current behavior, the constraints, and the acceptance criteria.
|
|
15533
|
+
|
|
15534
|
+
## 2. Plan
|
|
15535
|
+
Write one plan a reviewer could execute: the change surface, the smallest set of edits that satisfies the request, tests to add or update, the exact build and test commands, rollout and rollback, and the risks. Reuse existing utilities and patterns rather than adding new ones.
|
|
15536
|
+
|
|
15537
|
+
## 3. Review the plan
|
|
15538
|
+
Give the plan and your evidence to an independent adversarial reviewer, a separate subagent when one is available. Ask it to attack the plan: wrong assumptions, missing surfaces, over-scoping, untested paths. Resolve each finding or record why it does not apply. Start implementation only after this review.
|
|
15539
|
+
|
|
15540
|
+
## 4. Implement
|
|
15541
|
+
Make the change the reviewed plan describes. Add or update tests that would fail without it. Run the repository's documented format, build, analyzer, and test commands as you go. When something fails, fix the cause and keep tests, analyzers, and linters enabled as the repository configures them. Remove any temporary scripts or files you created before you finish.
|
|
15542
|
+
|
|
15543
|
+
## 5. Verify
|
|
15544
|
+
Collect real evidence for every claim: command lines and their outcomes, build and test results, and any validation the repository requires. Empirical output beats assumption. If something cannot be verified from your environment, say so explicitly instead of implying it passed.
|
|
15545
|
+
|
|
15546
|
+
## 6. Review the implementation
|
|
15547
|
+
Give the diff, the plan, and the verification output to an independent adversarial reviewer, a separate subagent when one is available. It looks for correctness bugs, edge cases, error handling, concurrency, security, and gaps between the diff and the plan. Fix real findings and re-run verification. Repeat until the review is clean or every remaining finding is recorded with a reason.
|
|
15548
|
+
|
|
15549
|
+
## 7. Open the pull request
|
|
15550
|
+
Create a new branch from the base branch, commit in the repository's existing message style, push, and open a pull request. Write the title and description in a human voice: what changed, why, how it was validated, and what a reviewer should look at. Use plain prose without em dashes and without attribution trailers such as Co-Authored-By or generated-with footers, because the team's convention is that those read as machine output. When the request names a work item, link it to the pull request.
|
|
15551
|
+
|
|
15552
|
+
## 8. Get the build green
|
|
15553
|
+
Watch the pull request's required checks and fix failures on the branch until they pass. While a check is queued or running, wait for it rather than guessing its outcome. If a check cannot pass because of permissions, credentials, an outage, or missing configuration, record its name, its state, and the exact step a human must take. When the repository has no pull request pipeline, run the documented local build and test commands and use their output as the green evidence.
|
|
15554
|
+
|
|
15555
|
+
## 9. Handle the work item
|
|
15556
|
+
If the request named a work item, the pull request links that one and this phase is done. Otherwise, once the pull request exists and its required checks pass, create one in the Azure DevOps organization that hosts the repository, in the MSTeams project, not the Teamspace project. Look up recent work items assigned to you (System.AssignedTo = @Me) and reuse their area path, current sprint iteration, priority, and tags where they fit. Write the title and description in a human voice with no em dashes: what changed, why it matters, risk, and the validation evidence. Link the new work item to the pull request. If permissions or a missing project block creation, record the exact error, note it in the pull request description, and continue to Reporting rather than stopping the run.
|
|
15557
|
+
|
|
15558
|
+
# Reporting
|
|
15559
|
+
|
|
15560
|
+
Your final message is the handoff. Include:
|
|
15561
|
+
- a one-line restatement of what was asked,
|
|
15562
|
+
- the pull request id and link,
|
|
15563
|
+
- the work item id and link,
|
|
15564
|
+
- each check you observed with its final state,
|
|
15565
|
+
- the commands you ran and their results,
|
|
15566
|
+
- decisions you made without confirmation and why,
|
|
15567
|
+
- anything open, unverified, or blocked, with the exact blocker.
|
|
15568
|
+
|
|
15569
|
+
# Working rules
|
|
15570
|
+
|
|
15571
|
+
- Keep secrets out of everything you emit or commit. Reference sensitive files such as .env, *.pem, and *.key by path only, and do not read their contents into output.
|
|
15572
|
+
- Work on a new branch and open a pull request. The default branch stays untouched so a human can gate the change.
|
|
15573
|
+
- Keep one logical change per pull request; unrelated fixes belong on their own branch.
|
|
15574
|
+
- If the request is already satisfied, or cannot be done with the access you have, stop and report exactly what you found and what a human needs to do next.
|
|
15575
|
+
- Leave the pull request open for review. Merging stays with a human.
|
|
15576
|
+
|
|
15577
|
+
# Task`;
|
|
15578
|
+
function composePrJobPrompt(task) {
|
|
15579
|
+
return `${PR_JOB_WORKFLOW}\n\n<user_task>\n${task.trim()}\n</user_task>`;
|
|
15580
|
+
}
|
|
15581
|
+
const CLOUDAGENT_TOOLS = Object.freeze([
|
|
15582
|
+
{
|
|
15583
|
+
toolNameHttp: "create_job",
|
|
15584
|
+
group: CLOUDAGENT_GROUP,
|
|
15585
|
+
capability: "cloudagent_write",
|
|
15586
|
+
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.",
|
|
15587
|
+
inputSchema: {
|
|
15588
|
+
type: "object",
|
|
15589
|
+
additionalProperties: false,
|
|
15590
|
+
properties: {
|
|
15591
|
+
prompt: {
|
|
15592
|
+
type: "string",
|
|
15593
|
+
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."
|
|
15594
|
+
},
|
|
15595
|
+
...REPOSITORY_PROPERTIES,
|
|
15596
|
+
branch: {
|
|
15597
|
+
type: "string",
|
|
15598
|
+
description: "Branch to start from. Default: the repository's default branch."
|
|
15599
|
+
},
|
|
15600
|
+
...WORKSPACE_PROPERTY,
|
|
15601
|
+
agent: {
|
|
15602
|
+
type: "string",
|
|
15603
|
+
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."
|
|
15604
|
+
},
|
|
15605
|
+
agentType: {
|
|
15606
|
+
type: "string",
|
|
15607
|
+
enum: [...AGENT_TYPES],
|
|
15608
|
+
description: "Scope the custom agent was registered at: Repo, Organization, Company or Spec. Only meaningful with `agent`; default: not sent."
|
|
15609
|
+
},
|
|
15610
|
+
agentInputs: {
|
|
15611
|
+
type: "object",
|
|
15612
|
+
description: "Inputs the custom agent requires, as name/value pairs; list_agents lists the names. Default: none. Values are strings, numbers or booleans."
|
|
15613
|
+
},
|
|
15614
|
+
plugins: {
|
|
15615
|
+
type: "array",
|
|
15616
|
+
items: { type: "string" },
|
|
15617
|
+
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)`)."
|
|
15618
|
+
},
|
|
15619
|
+
includeDefaultPlugins: {
|
|
15620
|
+
type: "boolean",
|
|
15621
|
+
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."
|
|
15622
|
+
},
|
|
15623
|
+
tier: {
|
|
15624
|
+
type: "string",
|
|
15625
|
+
enum: [
|
|
15626
|
+
"easy",
|
|
15627
|
+
"normal",
|
|
15628
|
+
"complex"
|
|
15629
|
+
],
|
|
15630
|
+
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."
|
|
15631
|
+
},
|
|
15632
|
+
model: {
|
|
15633
|
+
type: "string",
|
|
15634
|
+
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."
|
|
15635
|
+
},
|
|
15636
|
+
reasoningEffort: {
|
|
15637
|
+
type: "string",
|
|
15638
|
+
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."
|
|
15639
|
+
},
|
|
15640
|
+
context: {
|
|
15641
|
+
type: "string",
|
|
15642
|
+
enum: ["default", "long_context"],
|
|
15643
|
+
description: "Context tier: \"default\" or \"long_context\". Default \"default\"; override with \"long_context\" for a job over a large repository."
|
|
15644
|
+
},
|
|
15645
|
+
metadata: {
|
|
15646
|
+
type: "object",
|
|
15647
|
+
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."
|
|
15648
|
+
}
|
|
15649
|
+
}
|
|
15650
|
+
},
|
|
15651
|
+
async handler(args, signal, ctx) {
|
|
15652
|
+
const repository = await resolveRepository(args, ctx, { signal });
|
|
15653
|
+
const branch = optionalString(args, "branch");
|
|
15654
|
+
const agent = optionalString(args, "agent");
|
|
15655
|
+
const prompt = optionalString(args, "prompt");
|
|
15656
|
+
const agentType = agent ? agentTypeArg(args) : void 0;
|
|
15657
|
+
const agentInputs = agent ? agentInputsArg(args) : void 0;
|
|
15658
|
+
const plugins = pluginsArg(args);
|
|
15659
|
+
const model = resolveModelConfiguration(args);
|
|
15660
|
+
const metadata = metadataArg(args);
|
|
15661
|
+
const request = buildGenericJobRequest({
|
|
15662
|
+
...prompt ? { prompt } : {},
|
|
15663
|
+
repository: {
|
|
15664
|
+
organization: repository.organization,
|
|
15665
|
+
project: repository.project,
|
|
15666
|
+
repository: repository.repository,
|
|
15667
|
+
...branch ? { branch } : {}
|
|
15668
|
+
},
|
|
15669
|
+
...agent ? { customAgent: {
|
|
15670
|
+
name: agent,
|
|
15671
|
+
...agentType ? { type: agentType } : {},
|
|
15672
|
+
...agentInputs ? { inputs: agentInputs } : {}
|
|
15673
|
+
} } : {},
|
|
15674
|
+
...plugins ? { plugins } : {},
|
|
15675
|
+
...args.includeDefaultPlugins === true ? { includeDefaultPlugins: true } : {},
|
|
15676
|
+
modelConfiguration: model.modelConfiguration,
|
|
15677
|
+
...metadata ? { metadata } : {}
|
|
15678
|
+
});
|
|
15679
|
+
const job = await cloudAgentClient().createJob(request);
|
|
15680
|
+
const provenance = provenanceLine(repository);
|
|
15681
|
+
const lines = [renderJob(job, provenance ? { note: provenance } : {})];
|
|
15682
|
+
lines.push("");
|
|
15683
|
+
lines.push("effective request (the normalized body the service received):");
|
|
15684
|
+
lines.push(renderEffectiveRequest(request));
|
|
15685
|
+
lines.push(` ${model.tierNote}`);
|
|
15686
|
+
lines.push("");
|
|
15687
|
+
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.`);
|
|
15688
|
+
return text(lines.join("\n"));
|
|
15689
|
+
}
|
|
15690
|
+
},
|
|
15691
|
+
{
|
|
15692
|
+
toolNameHttp: "create_pr_job",
|
|
15693
|
+
group: CLOUDAGENT_GROUP,
|
|
15694
|
+
capability: "cloudagent_write",
|
|
15695
|
+
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` plugin is loaded (branch, commit, push, pull request, pipeline and work item tools), the model defaults to claude-opus-5.5 at max reasoning effort (the `complex` tier), and a fixed engineering workflow is prepended to `prompt`: research, a reviewed plan, implementation with tests, an independent adversarial review of the change, the pull request, a green build, and a work item that links it. You supply the task in `prompt`; 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.",
|
|
15696
|
+
inputSchema: {
|
|
15697
|
+
type: "object",
|
|
15698
|
+
required: ["prompt"],
|
|
15699
|
+
additionalProperties: false,
|
|
15700
|
+
properties: {
|
|
15701
|
+
prompt: {
|
|
15702
|
+
type: "string",
|
|
15703
|
+
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, plugin and model come from the tool, so do not restate them. The agent starts from a fresh clone and sees nothing else."
|
|
15704
|
+
},
|
|
15705
|
+
...REPOSITORY_PROPERTIES,
|
|
15706
|
+
branch: {
|
|
15707
|
+
type: "string",
|
|
15708
|
+
description: "Branch to start from. Default: the repository's default branch."
|
|
15709
|
+
},
|
|
15710
|
+
...WORKSPACE_PROPERTY,
|
|
15711
|
+
tier: {
|
|
15712
|
+
type: "string",
|
|
15713
|
+
enum: [
|
|
15714
|
+
"easy",
|
|
15715
|
+
"normal",
|
|
15716
|
+
"complex"
|
|
15717
|
+
],
|
|
15718
|
+
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."
|
|
15719
|
+
},
|
|
15720
|
+
model: {
|
|
15721
|
+
type: "string",
|
|
15722
|
+
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."
|
|
15723
|
+
},
|
|
15724
|
+
reasoningEffort: {
|
|
15725
|
+
type: "string",
|
|
15726
|
+
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."
|
|
15727
|
+
},
|
|
15728
|
+
context: {
|
|
15729
|
+
type: "string",
|
|
15730
|
+
enum: ["default", "long_context"],
|
|
15731
|
+
description: "Context tier: \"default\" or \"long_context\". Default \"default\"; override with \"long_context\" for a job over a large repository."
|
|
15732
|
+
},
|
|
15733
|
+
metadata: {
|
|
15734
|
+
type: "object",
|
|
15735
|
+
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."
|
|
15736
|
+
}
|
|
15737
|
+
}
|
|
15738
|
+
},
|
|
15739
|
+
async handler(args, signal, ctx) {
|
|
15740
|
+
const repository = await resolveRepository(args, ctx, { signal });
|
|
15741
|
+
const branch = optionalString(args, "branch");
|
|
15742
|
+
const task = optionalString(args, "prompt");
|
|
15743
|
+
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 });
|
|
15744
|
+
const model = resolveModelConfiguration(args, PR_JOB_DEFAULT_TIER);
|
|
15745
|
+
const metadata = metadataArg(args);
|
|
15746
|
+
const request = buildGenericJobRequest({
|
|
15747
|
+
prompt: composePrJobPrompt(task),
|
|
15748
|
+
repository: {
|
|
15749
|
+
organization: repository.organization,
|
|
15750
|
+
project: repository.project,
|
|
15751
|
+
repository: repository.repository,
|
|
15752
|
+
...branch ? { branch } : {}
|
|
15753
|
+
},
|
|
15754
|
+
plugins: [{ name: AGENCY_CODING_PLUGIN }],
|
|
15755
|
+
modelConfiguration: model.modelConfiguration,
|
|
15756
|
+
...metadata ? { metadata } : {}
|
|
15757
|
+
});
|
|
15758
|
+
const job = await cloudAgentClient().createJob(request);
|
|
15759
|
+
const provenance = provenanceLine(repository);
|
|
15760
|
+
const lines = [renderJob(job, provenance ? { note: provenance } : {})];
|
|
15761
|
+
lines.push("");
|
|
15762
|
+
lines.push("effective request (the normalized body the service received):");
|
|
15763
|
+
lines.push(renderEffectiveRequest(request));
|
|
15764
|
+
lines.push(` ${model.tierNote}`);
|
|
15765
|
+
lines.push("");
|
|
15766
|
+
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.`);
|
|
15767
|
+
return text(lines.join("\n"));
|
|
15768
|
+
}
|
|
15769
|
+
},
|
|
15770
|
+
{
|
|
15771
|
+
toolNameHttp: "cancel_job",
|
|
15772
|
+
group: CLOUDAGENT_GROUP,
|
|
15773
|
+
capability: "cloudagent_write",
|
|
15774
|
+
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.",
|
|
15775
|
+
inputSchema: {
|
|
15776
|
+
type: "object",
|
|
15777
|
+
required: ["jobId"],
|
|
15778
|
+
additionalProperties: false,
|
|
15779
|
+
properties: { ...JOB_ID_PROPERTY }
|
|
15780
|
+
},
|
|
15781
|
+
async handler(args, signal) {
|
|
15782
|
+
const jobId = requiredString(args, "jobId");
|
|
15783
|
+
const result = await cloudAgentClient().cancelJob(jobId, signal);
|
|
15784
|
+
if (result.alreadyCancelled && result.job) return text(renderJob(result.job, { note: "the job was already cancelled; nothing further will happen to it." }));
|
|
15785
|
+
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.`);
|
|
15786
|
+
}
|
|
15787
|
+
},
|
|
15788
|
+
{
|
|
15789
|
+
toolNameHttp: "get_job",
|
|
15790
|
+
group: CLOUDAGENT_GROUP,
|
|
15791
|
+
capability: "cloudagent",
|
|
15792
|
+
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.",
|
|
15793
|
+
inputSchema: {
|
|
15794
|
+
type: "object",
|
|
15795
|
+
required: ["jobId"],
|
|
15796
|
+
additionalProperties: false,
|
|
15797
|
+
properties: { ...JOB_ID_PROPERTY }
|
|
15798
|
+
},
|
|
15799
|
+
async handler(args, signal) {
|
|
15800
|
+
const jobId = requiredString(args, "jobId");
|
|
15801
|
+
const job = await getJobWithSummary(jobId, signal);
|
|
15802
|
+
const lines = [renderJob(job.job, job.summary !== null ? { summary: job.summary } : {})];
|
|
15803
|
+
if (job.summary === null && isTerminalJob(job.job)) {
|
|
15804
|
+
lines.push("");
|
|
15805
|
+
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.");
|
|
15806
|
+
}
|
|
15807
|
+
if (isTerminalJob(job.job)) {
|
|
15808
|
+
lines.push("");
|
|
15809
|
+
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.`);
|
|
15810
|
+
} else {
|
|
15811
|
+
lines.push("");
|
|
15812
|
+
lines.push(renderPollHint(job.job));
|
|
15813
|
+
}
|
|
15814
|
+
return text(lines.join("\n"));
|
|
15815
|
+
}
|
|
15816
|
+
},
|
|
15817
|
+
{
|
|
15818
|
+
toolNameHttp: "list_jobs",
|
|
15819
|
+
group: CLOUDAGENT_GROUP,
|
|
15820
|
+
capability: "cloudagent",
|
|
15821
|
+
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.",
|
|
15822
|
+
inputSchema: {
|
|
15823
|
+
type: "object",
|
|
15824
|
+
additionalProperties: false,
|
|
15825
|
+
properties: {
|
|
15826
|
+
...FILTER_REPOSITORY_PROPERTIES,
|
|
15827
|
+
...WORKSPACE_PROPERTY,
|
|
15828
|
+
pullRequestId: {
|
|
15829
|
+
type: "number",
|
|
15830
|
+
description: "Only jobs that produced this pull request. Default: every pull request."
|
|
15831
|
+
},
|
|
15832
|
+
pageSize: {
|
|
15833
|
+
type: "number",
|
|
15834
|
+
description: "How many jobs to return, 1-100. Default 25."
|
|
15835
|
+
},
|
|
15836
|
+
continuationToken: {
|
|
15837
|
+
type: "string",
|
|
15838
|
+
description: "Opaque token from a previous page whose result said more were available. Default: the first page."
|
|
15839
|
+
}
|
|
15840
|
+
}
|
|
15841
|
+
},
|
|
15842
|
+
async handler(args, signal, ctx) {
|
|
15843
|
+
const resolution = await resolveRepositoryFilter(args, ctx, signal);
|
|
15844
|
+
const filter = resolution.filter;
|
|
15845
|
+
const pageSize = optionalInt(args, "pageSize", 1, 100);
|
|
15846
|
+
const pullRequestId = optionalInt(args, "pullRequestId", 1, Number.MAX_SAFE_INTEGER);
|
|
15847
|
+
const notes = [];
|
|
15848
|
+
let projectId;
|
|
15849
|
+
let repositoryId;
|
|
15850
|
+
if (filter?.project) try {
|
|
15851
|
+
const ids = await repoIdResolver({
|
|
15852
|
+
organization: filter.organization,
|
|
15853
|
+
project: filter.project,
|
|
15854
|
+
...filter.repository ? { repository: filter.repository } : {}
|
|
15855
|
+
}, signal);
|
|
15856
|
+
projectId = ids.projectId;
|
|
15857
|
+
repositoryId = ids.repositoryId;
|
|
15858
|
+
} catch (err) {
|
|
15859
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
15860
|
+
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 });
|
|
15861
|
+
notes.push(`[filter: organization "${filter.organization}" only — ${detail} The project and repository read from ${filter.inferredFrom} were dropped.]`);
|
|
15862
|
+
}
|
|
15863
|
+
const page = await cloudAgentClient().listJobs({
|
|
15864
|
+
organization: filter?.organization,
|
|
15865
|
+
project: projectId,
|
|
15866
|
+
repository: repositoryId,
|
|
15867
|
+
pullRequestId,
|
|
15868
|
+
pageSize,
|
|
15869
|
+
continuationToken: optionalString(args, "continuationToken")
|
|
15870
|
+
}, signal);
|
|
15871
|
+
if (filter?.inferredFrom && filter.project && filter.repository && projectId !== void 0) notes.push(provenanceLine({
|
|
15872
|
+
...filter,
|
|
15873
|
+
project: filter.project,
|
|
15874
|
+
repository: filter.repository
|
|
15875
|
+
}));
|
|
15876
|
+
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]");
|
|
15877
|
+
const lines = [...notes, renderJobPage(page)];
|
|
15878
|
+
if (page.data.length > 0) {
|
|
15879
|
+
lines.push("");
|
|
15880
|
+
lines.push(`next: get_job jobId=<id> for one job's state and deliverable; get_job_logs jobId=<id> for what it actually did.`);
|
|
15881
|
+
}
|
|
15882
|
+
return text(lines.join("\n"));
|
|
15883
|
+
}
|
|
15884
|
+
},
|
|
15885
|
+
{
|
|
15886
|
+
toolNameHttp: "wait_for_job",
|
|
15887
|
+
group: CLOUDAGENT_GROUP,
|
|
15888
|
+
capability: "cloudagent",
|
|
15889
|
+
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.",
|
|
15890
|
+
inputSchema: {
|
|
15891
|
+
type: "object",
|
|
15892
|
+
required: ["jobId"],
|
|
15893
|
+
additionalProperties: false,
|
|
15894
|
+
properties: {
|
|
15895
|
+
...JOB_ID_PROPERTY,
|
|
15896
|
+
max_wait_s: {
|
|
15897
|
+
type: "number",
|
|
15898
|
+
description: `Seconds to wait, 1-${WAIT_MAX_S}. Default ${WAIT_DEFAULT_S}.`
|
|
15899
|
+
}
|
|
15900
|
+
}
|
|
15901
|
+
},
|
|
15902
|
+
async handler(args, signal) {
|
|
15903
|
+
const jobId = requiredString(args, "jobId");
|
|
15904
|
+
const maxWaitS = optionalInt(args, "max_wait_s", 1, WAIT_MAX_S) ?? WAIT_DEFAULT_S;
|
|
15905
|
+
const client = cloudAgentClient();
|
|
15906
|
+
const startedAt = Date.now();
|
|
15907
|
+
const deadline = startedAt + maxWaitS * 1e3;
|
|
15908
|
+
let job = await client.getJob(jobId, signal);
|
|
15909
|
+
let polls = 1;
|
|
15910
|
+
while (!isTerminalJob(job) && !hasLeftQueue(job) && Date.now() < deadline) {
|
|
15911
|
+
await sleep(Math.min(WAIT_POLL_MS, Math.max(0, deadline - Date.now())), signal);
|
|
15912
|
+
job = await client.getJob(jobId, signal);
|
|
15913
|
+
polls++;
|
|
15914
|
+
}
|
|
15915
|
+
const elapsedS = Math.max(1, Math.round((Date.now() - startedAt) / 1e3));
|
|
15916
|
+
if (isTerminalJob(job)) {
|
|
15917
|
+
const summary = await summaryFor(client, jobId, signal);
|
|
15918
|
+
const lines = [renderJob(job, summary !== null ? { summary } : {})];
|
|
15919
|
+
if (summary === null) {
|
|
15920
|
+
lines.push("");
|
|
15921
|
+
lines.push("summary: none — the job never called task_complete, so it produced no deliverable.");
|
|
15922
|
+
}
|
|
15923
|
+
lines.push("");
|
|
15924
|
+
lines.push(`next: the job finished within ${elapsedS} s. get_job_logs jobId=${jobId} has the digested trace.`);
|
|
15925
|
+
return text(lines.join("\n"));
|
|
15926
|
+
}
|
|
15927
|
+
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.` })];
|
|
15928
|
+
lines.push("");
|
|
15929
|
+
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.");
|
|
15930
|
+
return text(lines.join("\n"));
|
|
15931
|
+
}
|
|
15932
|
+
},
|
|
15933
|
+
{
|
|
15934
|
+
toolNameHttp: "get_job_logs",
|
|
15935
|
+
group: CLOUDAGENT_GROUP,
|
|
15936
|
+
capability: "cloudagent",
|
|
15937
|
+
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.",
|
|
15938
|
+
inputSchema: {
|
|
15939
|
+
type: "object",
|
|
15940
|
+
required: ["jobId"],
|
|
15941
|
+
additionalProperties: false,
|
|
15942
|
+
properties: {
|
|
15943
|
+
...JOB_ID_PROPERTY,
|
|
15944
|
+
mode: {
|
|
15945
|
+
type: "string",
|
|
15946
|
+
enum: ["digest", "full"],
|
|
15947
|
+
description: "Default \"digest\": a readable summary. \"full\" returns the raw trace text, spilled to a file when large."
|
|
15948
|
+
},
|
|
15949
|
+
tail: {
|
|
15950
|
+
type: "number",
|
|
15951
|
+
description: "How many of the most recent tool calls the digest lists, 1-50. Default 12."
|
|
15952
|
+
}
|
|
15953
|
+
}
|
|
15954
|
+
},
|
|
15955
|
+
async handler(args, signal) {
|
|
15956
|
+
const jobId = requiredString(args, "jobId");
|
|
15957
|
+
const tail = optionalInt(args, "tail", 1, 50);
|
|
15958
|
+
const mode = optionalString(args, "mode") ?? "digest";
|
|
15959
|
+
if (mode !== "digest" && mode !== "full") throw new CloudAgentError("`mode` must be \"digest\" or \"full\".", { retriable: false });
|
|
15960
|
+
const client = cloudAgentClient();
|
|
15961
|
+
if (mode === "full") return text(await client.getJobLogsText(jobId, signal));
|
|
15962
|
+
const logs = await client.getJobLogs(jobId, signal);
|
|
15963
|
+
if (logs.summary) storeSummary(summaryKey(jobId), logs.summary);
|
|
15964
|
+
return text(renderTrace(logs, tail !== void 0 ? { tail } : {}));
|
|
15965
|
+
}
|
|
15966
|
+
},
|
|
15967
|
+
{
|
|
15968
|
+
toolNameHttp: "list_plugins",
|
|
15969
|
+
group: CLOUDAGENT_GROUP,
|
|
15970
|
+
capability: "cloudagent",
|
|
15971
|
+
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.",
|
|
15972
|
+
inputSchema: {
|
|
15973
|
+
type: "object",
|
|
15974
|
+
additionalProperties: false,
|
|
15975
|
+
properties: {
|
|
15976
|
+
type: {
|
|
15977
|
+
type: "string",
|
|
15978
|
+
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."
|
|
15979
|
+
},
|
|
15980
|
+
...CATALOG_REPOSITORY_PROPERTIES,
|
|
15981
|
+
...WORKSPACE_PROPERTY,
|
|
15982
|
+
name_contains: {
|
|
15983
|
+
type: "string",
|
|
15984
|
+
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."
|
|
15985
|
+
},
|
|
15986
|
+
top: {
|
|
15987
|
+
type: "number",
|
|
15988
|
+
description: "Page size, 1-100. Default: 50, both for the catalog page and for the maximum number of `name_contains` matches."
|
|
15989
|
+
},
|
|
15990
|
+
skip: {
|
|
15991
|
+
type: "number",
|
|
15992
|
+
description: "How many entries to skip, for paging. With `name_contains`, how many matches to skip. Default 0, the first page."
|
|
15993
|
+
}
|
|
15994
|
+
}
|
|
15995
|
+
},
|
|
15996
|
+
async handler(args, signal, ctx) {
|
|
15997
|
+
const { query, context } = await catalogQuery(args, ctx, signal);
|
|
15998
|
+
const provenance = context ? provenanceLine(context) : void 0;
|
|
15999
|
+
const withProvenance = (body) => provenance ? `${provenance}\n${body}` : body;
|
|
16000
|
+
const needle = optionalString(args, "name_contains")?.toLowerCase();
|
|
16001
|
+
if (!needle) return text(withProvenance(renderPluginPage(await cloudAgentClient().listPlugins(query, signal))));
|
|
16002
|
+
const scan = await scanPluginCatalog(query, signal);
|
|
16003
|
+
const matches = scan.value.filter((plugin) => plugin.name.toLowerCase().includes(needle));
|
|
16004
|
+
const skip = query.skip ?? 0;
|
|
16005
|
+
const limit = query.top ?? DEFAULT_PLUGIN_MATCH_LIMIT;
|
|
16006
|
+
const window = matches.slice(skip, skip + limit);
|
|
16007
|
+
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`;
|
|
16008
|
+
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({
|
|
16009
|
+
value: window,
|
|
16010
|
+
...scan.errors ? { errors: scan.errors } : {}
|
|
16011
|
+
})].join("\n")));
|
|
16012
|
+
}
|
|
16013
|
+
},
|
|
16014
|
+
{
|
|
16015
|
+
toolNameHttp: "list_agents",
|
|
16016
|
+
group: CLOUDAGENT_GROUP,
|
|
16017
|
+
capability: "cloudagent",
|
|
16018
|
+
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.",
|
|
16019
|
+
inputSchema: {
|
|
16020
|
+
type: "object",
|
|
16021
|
+
additionalProperties: false,
|
|
16022
|
+
properties: {
|
|
16023
|
+
type: {
|
|
16024
|
+
type: "string",
|
|
16025
|
+
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`."
|
|
16026
|
+
},
|
|
16027
|
+
...CATALOG_REPOSITORY_PROPERTIES,
|
|
16028
|
+
...WORKSPACE_PROPERTY,
|
|
16029
|
+
top: {
|
|
16030
|
+
type: "number",
|
|
16031
|
+
description: "Page size, 1-100. Default: the service's own page size."
|
|
16032
|
+
},
|
|
16033
|
+
skip: {
|
|
16034
|
+
type: "number",
|
|
16035
|
+
description: "How many entries to skip, for paging. Default 0, the first page."
|
|
16036
|
+
}
|
|
16037
|
+
}
|
|
16038
|
+
},
|
|
16039
|
+
async handler(args, signal, ctx) {
|
|
16040
|
+
const { query, context } = await catalogQuery(args, ctx, signal);
|
|
16041
|
+
const page = await cloudAgentClient().listAgents(query, signal);
|
|
16042
|
+
const provenance = context ? provenanceLine(context) : void 0;
|
|
16043
|
+
return text(provenance ? `${provenance}\n${renderAgentPage(page)}` : renderAgentPage(page));
|
|
16044
|
+
}
|
|
16045
|
+
},
|
|
16046
|
+
{
|
|
16047
|
+
toolNameHttp: "list_models",
|
|
16048
|
+
group: CLOUDAGENT_GROUP,
|
|
16049
|
+
capability: "cloudagent",
|
|
16050
|
+
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.",
|
|
16051
|
+
inputSchema: {
|
|
16052
|
+
type: "object",
|
|
16053
|
+
additionalProperties: false,
|
|
16054
|
+
properties: {}
|
|
16055
|
+
},
|
|
16056
|
+
async handler(_args, signal) {
|
|
16057
|
+
const models = await cloudAgentClient().listModels(signal);
|
|
16058
|
+
return text(`create_job tier presets: ${CLOUDAGENT_TIERS.map((tier) => {
|
|
16059
|
+
const preset = CLOUDAGENT_TIER_MODELS[tier];
|
|
16060
|
+
const suffix = tier === "normal" ? " (default)" : "";
|
|
16061
|
+
return `${tier} = ${preset.model} at ${preset.reasoningEffort} effort${suffix}`;
|
|
16062
|
+
}).join("; ")}.\n${renderModelPage(models)}`);
|
|
16063
|
+
}
|
|
16064
|
+
}
|
|
16065
|
+
]);
|
|
16066
|
+
function tierArg(args, defaultTier = CLOUDAGENT_DEFAULT_TIER) {
|
|
16067
|
+
const raw = optionalString(args, "tier");
|
|
16068
|
+
if (raw === void 0) return defaultTier;
|
|
16069
|
+
const normalized = raw.toLowerCase();
|
|
16070
|
+
const match = CLOUDAGENT_TIERS.find((tier) => tier === normalized);
|
|
16071
|
+
if (match) return match;
|
|
16072
|
+
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 });
|
|
16073
|
+
}
|
|
16074
|
+
/**
|
|
16075
|
+
* Resolve `tier`, `model`, `reasoningEffort` and `context` into the wire
|
|
16076
|
+
* `modelConfiguration`, plus one line explaining what the tier contributed.
|
|
16077
|
+
*
|
|
16078
|
+
* Precedence, and why: a tier supplies a model AND an effort. Naming a `model`
|
|
16079
|
+
* replaces the whole preset rather than only its model, because the effort
|
|
16080
|
+
* ladder differs per model — measured live, 8 of 25 models do not accept `max`
|
|
16081
|
+
* — so carrying the preset's `max` onto a caller-chosen model would inject a
|
|
16082
|
+
* value that caller never asked for and the service may reject. An explicit
|
|
16083
|
+
* `reasoningEffort` is always honored, with or without `model`.
|
|
16084
|
+
*
|
|
16085
|
+
* The explanation line exists because `GET /jobs/{id}` never returns
|
|
16086
|
+
* `modelConfiguration`: a follow-up job can only copy values the caller can
|
|
16087
|
+
* SEE were used, and "effort: max" without saying it came from the tier reads
|
|
16088
|
+
* like something the caller chose.
|
|
16089
|
+
*/
|
|
16090
|
+
function resolveModelConfiguration(args, defaultTier = CLOUDAGENT_DEFAULT_TIER) {
|
|
16091
|
+
const tier = tierArg(args, defaultTier);
|
|
16092
|
+
const preset = CLOUDAGENT_TIER_MODELS[tier];
|
|
16093
|
+
const explicitModel = optionalString(args, "model");
|
|
16094
|
+
const explicitEffort = optionalString(args, "reasoningEffort");
|
|
16095
|
+
const context = optionalString(args, "context");
|
|
16096
|
+
if (context !== void 0 && context !== "default" && context !== "long_context") throw new CloudAgentError("`context` must be \"default\" or \"long_context\".", { retriable: false });
|
|
16097
|
+
const model = explicitModel ?? preset.model;
|
|
16098
|
+
const reasoningEffort = explicitEffort ?? (explicitModel ? void 0 : preset.reasoningEffort);
|
|
16099
|
+
const modelConfiguration = {
|
|
16100
|
+
model,
|
|
16101
|
+
...reasoningEffort ? { reasoningEffort } : {},
|
|
16102
|
+
...context ? { context } : {}
|
|
16103
|
+
};
|
|
16104
|
+
const defaultLabel = tier === defaultTier ? ", the default" : "";
|
|
16105
|
+
let tierNote;
|
|
16106
|
+
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}.`;
|
|
16107
|
+
else if (explicitEffort) tierNote = `tier: ${tier}${defaultLabel} — replaced by model ${model}; the effort you passed replaced its ${preset.reasoningEffort}.`;
|
|
16108
|
+
else tierNote = `tier: ${tier}${defaultLabel} — replaced by model ${model}, so its ${preset.reasoningEffort} effort was dropped and the model's own default applies.`;
|
|
16109
|
+
return {
|
|
16110
|
+
modelConfiguration,
|
|
16111
|
+
tierNote
|
|
16112
|
+
};
|
|
16113
|
+
}
|
|
16114
|
+
/**
|
|
16115
|
+
* The arguments shared by `list_plugins` and `list_agents`.
|
|
16116
|
+
*
|
|
16117
|
+
* `top` is omitted when the caller did not ask for it, and that is load-bearing:
|
|
16118
|
+
* `GET /plugins` returns 50 of 233 by default and rejects `top > 100` with a 400
|
|
16119
|
+
* unless `marketplace` is set, so a default page size here would either shrink
|
|
16120
|
+
* what the service gives an unprompted call or provoke that 400.
|
|
16121
|
+
*
|
|
16122
|
+
* The Azure DevOps context is resolved separately (`catalogContext`) because
|
|
16123
|
+
* only the Repo and Organization scopes require one.
|
|
16124
|
+
*/
|
|
16125
|
+
async function catalogQuery(args, ctx, signal) {
|
|
16126
|
+
const type = agentTypeValue(args, "type");
|
|
16127
|
+
const top = optionalInt(args, "top", 1, 100);
|
|
16128
|
+
const skip = optionalInt(args, "skip", 0, Number.MAX_SAFE_INTEGER);
|
|
16129
|
+
const context = await catalogContext(args, ctx, type, signal);
|
|
16130
|
+
return {
|
|
16131
|
+
query: {
|
|
16132
|
+
...type ? { type } : {},
|
|
16133
|
+
...context ? {
|
|
16134
|
+
organization: context.organization,
|
|
16135
|
+
...context.project ? { project: context.project } : {},
|
|
16136
|
+
...context.repository ? { repository: context.repository } : {}
|
|
16137
|
+
} : {},
|
|
16138
|
+
...top !== void 0 ? { top } : {},
|
|
16139
|
+
...skip !== void 0 ? { skip } : {}
|
|
16140
|
+
},
|
|
16141
|
+
...context ? { context } : {}
|
|
16142
|
+
};
|
|
16143
|
+
}
|
|
16144
|
+
/**
|
|
16145
|
+
* The context a catalog scope reads, from the caller's arguments or a checkout.
|
|
16146
|
+
*
|
|
16147
|
+
* Each scope is held only to what it actually reads (measured live 2026-10-30;
|
|
16148
|
+
* see `CATALOG_REPOSITORY_PROPERTIES`): `Repo` needs the triple, `Organization`
|
|
16149
|
+
* needs the organization alone, and the rest read no context, so a partial set
|
|
16150
|
+
* supplied to those is not an error — the call simply does not use it. Requiring
|
|
16151
|
+
* more than the service does is its own failure mode: it turns a working
|
|
16152
|
+
* question into a refusal.
|
|
16153
|
+
*
|
|
16154
|
+
* The context is only resolved when the call can use it. An untyped, Company or
|
|
16155
|
+
* Spec call costs no git probe and cannot fail on a machine that is not in an
|
|
16156
|
+
* Azure DevOps checkout — the `list_jobs` lesson, where inferring eagerly turned
|
|
16157
|
+
* every call in an unrelated repository into an error for a filter it did not
|
|
16158
|
+
* need.
|
|
16159
|
+
*/
|
|
16160
|
+
async function catalogContext(args, ctx, type, signal) {
|
|
16161
|
+
if (type !== "Repo" && type !== "Organization") return void 0;
|
|
16162
|
+
const organization = optionalString(args, "organization");
|
|
16163
|
+
const project = optionalString(args, "project");
|
|
16164
|
+
const repository = optionalString(args, "repository");
|
|
16165
|
+
if (type === "Repo") {
|
|
16166
|
+
const given = [
|
|
16167
|
+
organization,
|
|
16168
|
+
project,
|
|
16169
|
+
repository
|
|
16170
|
+
].filter((part) => part !== void 0).length;
|
|
16171
|
+
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 });
|
|
16172
|
+
if (given === 3) return {
|
|
16173
|
+
organization,
|
|
16174
|
+
project,
|
|
16175
|
+
repository
|
|
16176
|
+
};
|
|
16177
|
+
} else {
|
|
16178
|
+
if (organization) return {
|
|
16179
|
+
organization,
|
|
16180
|
+
...project ? { project } : {},
|
|
16181
|
+
...repository ? { repository } : {}
|
|
16182
|
+
};
|
|
16183
|
+
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 });
|
|
16184
|
+
}
|
|
16185
|
+
const { repository: inferred } = await repositoryFromWorkspace(args, ctx, {
|
|
16186
|
+
required: true,
|
|
16187
|
+
requiredHint: type === "Repo" ? "`organization`, `project` and `repository`" : "`organization`",
|
|
16188
|
+
...signal ? { signal } : {}
|
|
16189
|
+
});
|
|
16190
|
+
return inferred;
|
|
16191
|
+
}
|
|
16192
|
+
/** Matches returned by a filtered `list_plugins` when the caller gave no `top`. */
|
|
16193
|
+
const DEFAULT_PLUGIN_MATCH_LIMIT = 50;
|
|
16194
|
+
/**
|
|
16195
|
+
* How many catalog entries a name search pages through before it stops.
|
|
16196
|
+
*
|
|
16197
|
+
* The measured catalog is 233 entries, so three pages cover it; the cap only
|
|
16198
|
+
* bounds a catalog that grew by an order of magnitude, and the result says when
|
|
16199
|
+
* it was hit so a truncated search is never read as an empty one.
|
|
16200
|
+
*/
|
|
16201
|
+
const PLUGIN_SCAN_CAP = 1e3;
|
|
16202
|
+
/**
|
|
16203
|
+
* Read the plugin catalog page by page.
|
|
16204
|
+
*
|
|
16205
|
+
* `GET /plugins` has no name filter and refuses `top > 100`, so answering "is
|
|
16206
|
+
* there a plugin for X?" from a single page would miss most of the catalog
|
|
16207
|
+
* while looking like an answer. Paging lives here so the tool handler stays a
|
|
16208
|
+
* filter. `skip` is the service's own offset, verified live: 233 entries over
|
|
16209
|
+
* three pages, no overlap.
|
|
16210
|
+
*/
|
|
16211
|
+
async function scanPluginCatalog(base, signal) {
|
|
16212
|
+
const seen = /* @__PURE__ */ new Set();
|
|
16213
|
+
const value = [];
|
|
16214
|
+
const serviceErrors = /* @__PURE__ */ new Set();
|
|
16215
|
+
const add = (page) => {
|
|
16216
|
+
for (const error of page.errors ?? []) serviceErrors.add(error);
|
|
16217
|
+
for (const plugin of page.value) {
|
|
16218
|
+
if (seen.has(plugin.name)) continue;
|
|
16219
|
+
seen.add(plugin.name);
|
|
16220
|
+
value.push(plugin);
|
|
16221
|
+
}
|
|
16222
|
+
return page.value.length;
|
|
16223
|
+
};
|
|
16224
|
+
const result = (scanned, totalCount, capped) => ({
|
|
16225
|
+
value,
|
|
16226
|
+
scanned,
|
|
16227
|
+
...totalCount !== void 0 ? { totalCount } : {},
|
|
16228
|
+
capped,
|
|
16229
|
+
...serviceErrors.size > 0 ? { errors: [...serviceErrors] } : {}
|
|
16230
|
+
});
|
|
16231
|
+
const first = await cloudAgentClient().listPlugins({
|
|
16232
|
+
...base,
|
|
16233
|
+
top: 100,
|
|
16234
|
+
skip: 0
|
|
16235
|
+
}, signal);
|
|
16236
|
+
let scanned = add(first);
|
|
16237
|
+
const totalCount = first.totalCount;
|
|
16238
|
+
if (first.value.length < 100) return result(scanned, totalCount, false);
|
|
16239
|
+
if (totalCount === void 0) for (;;) {
|
|
16240
|
+
const page = await cloudAgentClient().listPlugins({
|
|
16241
|
+
...base,
|
|
16242
|
+
top: 100,
|
|
16243
|
+
skip: scanned
|
|
16244
|
+
}, signal);
|
|
16245
|
+
scanned += add(page);
|
|
16246
|
+
if (page.value.length < 100) return result(scanned, void 0, false);
|
|
16247
|
+
if (scanned >= PLUGIN_SCAN_CAP) return result(scanned, void 0, true);
|
|
16248
|
+
}
|
|
16249
|
+
const lastPage = Math.min(Math.ceil(totalCount / 100), Math.ceil(PLUGIN_SCAN_CAP / 100));
|
|
16250
|
+
const offsets = [];
|
|
16251
|
+
for (let skip = 100; skip < lastPage * 100; skip += 100) offsets.push(skip);
|
|
16252
|
+
const pages = await Promise.all(offsets.map((skip) => cloudAgentClient().listPlugins({
|
|
16253
|
+
...base,
|
|
16254
|
+
top: 100,
|
|
16255
|
+
skip
|
|
16256
|
+
}, signal)));
|
|
16257
|
+
for (const page of pages) scanned += add(page);
|
|
16258
|
+
return result(scanned, totalCount, totalCount > PLUGIN_SCAN_CAP);
|
|
16259
|
+
}
|
|
16260
|
+
/** Queued is the only state that means "compute has not been allocated". */
|
|
16261
|
+
function hasLeftQueue(job) {
|
|
16262
|
+
return job.state !== void 0 && job.state.trim().toLowerCase() !== "queued";
|
|
16263
|
+
}
|
|
16264
|
+
function summaryKey(jobId) {
|
|
16265
|
+
return `${normalizeCloudAgentEnvironment(state.cloudAgentEnvironment ?? "prod")}:${jobId}`;
|
|
16266
|
+
}
|
|
16267
|
+
/**
|
|
16268
|
+
* The job plus its deliverable for a terminal job.
|
|
16269
|
+
*
|
|
16270
|
+
* A terminal state is the only time the trace is worth fetching, and the answer
|
|
16271
|
+
* is cached in BOTH directions (`null` = read, no summary). A failure to read
|
|
16272
|
+
* the trace must not fail the call: the state and outcome are the more useful
|
|
16273
|
+
* half of the answer, so the summary degrades to `null` with the reason attached
|
|
16274
|
+
* to the note rather than throwing away a successful poll.
|
|
16275
|
+
*/
|
|
16276
|
+
async function getJobWithSummary(jobId, signal) {
|
|
16277
|
+
const client = cloudAgentClient();
|
|
16278
|
+
const job = await client.getJob(jobId, signal);
|
|
16279
|
+
if (!isTerminalJob(job)) return {
|
|
16280
|
+
job,
|
|
16281
|
+
summary: null
|
|
16282
|
+
};
|
|
16283
|
+
return {
|
|
16284
|
+
job,
|
|
16285
|
+
summary: await summaryFor(client, jobId, signal)
|
|
16286
|
+
};
|
|
16287
|
+
}
|
|
16288
|
+
async function summaryFor(client, jobId, signal) {
|
|
16289
|
+
const key = summaryKey(jobId);
|
|
16290
|
+
const cached = cachedSummary(key);
|
|
16291
|
+
if (cached.hit) return cached.summary;
|
|
16292
|
+
try {
|
|
16293
|
+
const summary = (await client.getJobLogs(jobId, signal)).summary ?? null;
|
|
16294
|
+
storeSummary(key, summary);
|
|
16295
|
+
return summary;
|
|
16296
|
+
} catch {
|
|
16297
|
+
return null;
|
|
16298
|
+
}
|
|
16299
|
+
}
|
|
16300
|
+
//#endregion
|
|
13638
16301
|
//#region src/lib/browser-mcp/browser-detect.ts
|
|
13639
16302
|
let cached;
|
|
13640
16303
|
function probeWindowsRegistry(subkey) {
|
|
@@ -15091,7 +17754,7 @@ function logAudit$1(record) {
|
|
|
15091
17754
|
try {
|
|
15092
17755
|
const fs = await import("node:fs/promises");
|
|
15093
17756
|
const path = await import("node:path");
|
|
15094
|
-
const { PATHS } = await import("./paths-
|
|
17757
|
+
const { PATHS } = await import("./paths-BYxX9DfA.js");
|
|
15095
17758
|
const dir = path.join(PATHS.APP_DIR, "browser-mcp");
|
|
15096
17759
|
await fs.mkdir(dir, { recursive: true });
|
|
15097
17760
|
const line = JSON.stringify({
|
|
@@ -24604,6 +27267,21 @@ function adoToolsEnabled() {
|
|
|
24604
27267
|
function kustoToolsEnabled() {
|
|
24605
27268
|
return state.kustoEnabled;
|
|
24606
27269
|
}
|
|
27270
|
+
/**
|
|
27271
|
+
* Gate for the Cloud Agent MCP group, all ten tools (`mcp__cloudagent__*`).
|
|
27272
|
+
*
|
|
27273
|
+
* Returns true iff `setupAndServe` resolved the group ON: `--cloudagent`,
|
|
27274
|
+
* `GH_ROUTER_ENABLE_CLOUDAGENT=1`, or an Azure DevOps git remote in this session's
|
|
27275
|
+
* workspace. Discovery enables the write tools too, matching the ADO, Kusto and
|
|
27276
|
+
* Bluebird groups; the operator's `--no-cloudagent` is the veto. There is no
|
|
27277
|
+
* separate availability probe for the same reason `adoToolsEnabled()` has none:
|
|
27278
|
+
* the tools reach a remote service whose reachability cannot be established
|
|
27279
|
+
* without a token, and minting one during `tools/list` would make listing tools
|
|
27280
|
+
* cost an `az` process.
|
|
27281
|
+
*/
|
|
27282
|
+
function cloudAgentToolsEnabled() {
|
|
27283
|
+
return state.cloudAgentEnabled;
|
|
27284
|
+
}
|
|
24607
27285
|
const ADO_TOKEN_RESOURCE = "2a72489c-aab2-4b65-b93a-a91edccf33b8";
|
|
24608
27286
|
const ADO_PROTOCOL_VERSION = "2025-06-18";
|
|
24609
27287
|
const ADO_TOKEN_ENV = "ADO_MCP_TOKEN";
|
|
@@ -24739,7 +27417,7 @@ var AdoMcpClient = class extends RemoteMcpClient {
|
|
|
24739
27417
|
return [...this.toolSchemas.values()].map((tool) => ({
|
|
24740
27418
|
name: tool.name,
|
|
24741
27419
|
description: tool.description ?? "",
|
|
24742
|
-
inputSchema: isRecord$
|
|
27420
|
+
inputSchema: isRecord$4(tool.inputSchema) ? tool.inputSchema : {
|
|
24743
27421
|
type: "object",
|
|
24744
27422
|
properties: {}
|
|
24745
27423
|
}
|
|
@@ -24758,10 +27436,10 @@ var AdoMcpClient = class extends RemoteMcpClient {
|
|
|
24758
27436
|
await this.initialize(signal);
|
|
24759
27437
|
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 });
|
|
24760
27438
|
const result = await this.callTool(name, args, signal);
|
|
24761
|
-
if (!isRecord$
|
|
27439
|
+
if (!isRecord$4(result)) throw new AdoError("Azure DevOps returned an empty result.", { retriable: true });
|
|
24762
27440
|
const texts = [];
|
|
24763
27441
|
if (Array.isArray(result.content)) {
|
|
24764
|
-
for (const block of result.content) if (isRecord$
|
|
27442
|
+
for (const block of result.content) if (isRecord$4(block) && typeof block.text === "string" && block.text.trim()) texts.push(block.text);
|
|
24765
27443
|
}
|
|
24766
27444
|
const envelope = { content: [{
|
|
24767
27445
|
type: "text",
|
|
@@ -25263,6 +27941,7 @@ function maxToolIsEnabled(tool) {
|
|
|
25263
27941
|
if (tool.capability === "artifact") return artifactToolsEnabled();
|
|
25264
27942
|
if (tool.group === "ado") return adoToolsEnabled();
|
|
25265
27943
|
if (tool.group === "kusto") return kustoToolsEnabled();
|
|
27944
|
+
if (tool.capability === "cloudagent" || tool.capability === "cloudagent_write") return cloudAgentToolsEnabled();
|
|
25266
27945
|
return true;
|
|
25267
27946
|
}
|
|
25268
27947
|
/**
|
|
@@ -25288,6 +27967,7 @@ function fastToolIsEnabled(tool) {
|
|
|
25288
27967
|
if (tool.group === "workers") return tool.toolNameHttp === "browse" && tool.capability === "browse_agent" && browseAgentEnabled();
|
|
25289
27968
|
if (tool.group === "ado") return adoToolsEnabled();
|
|
25290
27969
|
if (tool.group === "kusto") return kustoToolsEnabled();
|
|
27970
|
+
if (tool.capability === "cloudagent" || tool.capability === "cloudagent_write") return cloudAgentToolsEnabled();
|
|
25291
27971
|
if (tool.group !== "browser") return false;
|
|
25292
27972
|
if (!browserToolsEnabled()) return false;
|
|
25293
27973
|
if (tool.capability === "browser_compound") return browserCompoundToolsEnabled();
|
|
@@ -25413,6 +28093,7 @@ function toolEntries(scope, launch, audience = "shared") {
|
|
|
25413
28093
|
if (t.capability === "artifact") return artifactToolsEnabled();
|
|
25414
28094
|
if (t.capability === "ado") return adoToolsEnabled();
|
|
25415
28095
|
if (t.capability === "kusto") return kustoToolsEnabled();
|
|
28096
|
+
if (t.capability === "cloudagent" || t.capability === "cloudagent_write") return cloudAgentToolsEnabled();
|
|
25416
28097
|
if (t.capability === "browser_compound") return browserToolsEnabled() && browserCompoundToolsEnabled();
|
|
25417
28098
|
if (t.capability === "browser_power") return browserToolsEnabled() && browserPowerToolsEnabled();
|
|
25418
28099
|
return true;
|
|
@@ -25760,7 +28441,7 @@ function logTelemetry(t) {
|
|
|
25760
28441
|
process.stderr.write(parts.join(" ") + "\n");
|
|
25761
28442
|
}
|
|
25762
28443
|
function toolAcceptsWorkspace(tool) {
|
|
25763
|
-
return tool.capability === "worker" || tool.toolNameHttp === "code" || tool.toolNameHttp === "run_workflow" || tool.toolNameHttp === "prompt_brief";
|
|
28444
|
+
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";
|
|
25764
28445
|
}
|
|
25765
28446
|
/**
|
|
25766
28447
|
* Fold the per-session `X-GH-Workspace` header into `args.workspace` when the
|
|
@@ -25980,6 +28661,7 @@ async function handleToolsCall(body, scope, launch, audience = "shared", session
|
|
|
25980
28661
|
if (nonPersonaTool && nonPersonaTool.capability === "browser_power" && !(browserToolsEnabled() && browserPowerToolsEnabled())) return rpcError(body.id, RPC_METHOD_NOT_FOUND, `tools/call: unknown tool "${name}"`);
|
|
25981
28662
|
if (nonPersonaTool && nonPersonaTool.capability === "ado" && !adoToolsEnabled()) return rpcError(body.id, RPC_METHOD_NOT_FOUND, `tools/call: unknown tool "${name}"`);
|
|
25982
28663
|
if (nonPersonaTool && nonPersonaTool.capability === "kusto" && !kustoToolsEnabled()) return rpcError(body.id, RPC_METHOD_NOT_FOUND, `tools/call: unknown tool "${name}"`);
|
|
28664
|
+
if (nonPersonaTool && (nonPersonaTool.capability === "cloudagent" || nonPersonaTool.capability === "cloudagent_write") && !cloudAgentToolsEnabled()) return rpcError(body.id, RPC_METHOD_NOT_FOUND, `tools/call: unknown tool "${name}"`);
|
|
25983
28665
|
let personaPrompt;
|
|
25984
28666
|
let personaContext;
|
|
25985
28667
|
let personaEffort;
|
|
@@ -28315,7 +30997,7 @@ async function throttleSearch() {
|
|
|
28315
30997
|
const waitMs = 1e3 - (now - searchTimestamps[0]);
|
|
28316
30998
|
if (waitMs > 0) {
|
|
28317
30999
|
consola.debug(`Web search rate limited, waiting ${waitMs}ms`);
|
|
28318
|
-
await sleep$
|
|
31000
|
+
await sleep$3(waitMs);
|
|
28319
31001
|
}
|
|
28320
31002
|
}
|
|
28321
31003
|
searchTimestamps.push(Date.now());
|
|
@@ -32708,7 +35390,8 @@ const MCP_GROUPS = Object.freeze([
|
|
|
32708
35390
|
"fleet",
|
|
32709
35391
|
"first-mate",
|
|
32710
35392
|
"ado",
|
|
32711
|
-
"kusto"
|
|
35393
|
+
"kusto",
|
|
35394
|
+
"cloudagent"
|
|
32712
35395
|
]);
|
|
32713
35396
|
const GROUP_META = Object.freeze({
|
|
32714
35397
|
peers: {
|
|
@@ -32760,6 +35443,11 @@ const GROUP_META = Object.freeze({
|
|
|
32760
35443
|
preferredKey: "kusto",
|
|
32761
35444
|
urlSuffix: "kusto",
|
|
32762
35445
|
serverInfoName: "github-router-kusto"
|
|
35446
|
+
},
|
|
35447
|
+
cloudagent: {
|
|
35448
|
+
preferredKey: "cloudagent",
|
|
35449
|
+
urlSuffix: "cloudagent",
|
|
35450
|
+
serverInfoName: "github-router-cloudagent"
|
|
32763
35451
|
}
|
|
32764
35452
|
});
|
|
32765
35453
|
/** True iff `s` is a registered group name (route `:group` param validation). */
|
|
@@ -34421,7 +37109,8 @@ const NON_PERSONA_MCP_TOOLS = Object.freeze([
|
|
|
34421
37109
|
group: "browser",
|
|
34422
37110
|
toolNameHttp: t.toolNameHttp.replace(/^browser_/, "")
|
|
34423
37111
|
})),
|
|
34424
|
-
...KUSTO_TOOLS
|
|
37112
|
+
...KUSTO_TOOLS,
|
|
37113
|
+
...CLOUDAGENT_TOOLS
|
|
34425
37114
|
]);
|
|
34426
37115
|
/**
|
|
34427
37116
|
* Every MCP tool name the proxy serves itself: the personas (definitionally the
|
|
@@ -34828,6 +37517,6 @@ function enumerateInjectedMcpToolNames(groupKeys, opts = {}) {
|
|
|
34828
37517
|
return [...new Set(names)];
|
|
34829
37518
|
}
|
|
34830
37519
|
//#endregion
|
|
34831
|
-
export { readIteratorWithTimeout as $,
|
|
37520
|
+
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 };
|
|
34832
37521
|
|
|
34833
|
-
//# sourceMappingURL=peer-mcp-personas-
|
|
37522
|
+
//# sourceMappingURL=peer-mcp-personas-CVxXq1Q-.js.map
|