PageSourceSearch

https://fieldagent-radar.netlify.app/_next/static/chunks/837-468aaf894f5230fe.js

js fieldagent-radar.netlify.app collected 2026-10-03 10:44:19 UTC 10,791 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[837],{1837:function(e,t,n){n.d(t,{h:function(){return l}});var a=n(39),o=n(3217),r=n(8123);async function i(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],a=(0,r.hP)(),s={"Content-Type":"application/json",...a?{Authorization:"Bearer ".concat(a)}:{}},c=await fetch("".concat(o.T).concat(e),{...t,headers:{...s,...null==t?void 0:t.headers}});if(401===c.status&&n){if(await (0,r.jb)())return i(e,t,!1);throw(0,r.yE)(),window.location.href="/login",Error("Session expired")}if(!c.ok){let e=await c.json().catch(()=>null);throw Error(e?Object.entries(e).map(e=>{let[t,n]=e;return"".concat(t,": ").concat(Array.isArray(n)?n.join(", "):n)}).join("; "):"API error: ".concat(c.status))}if(204!==c.status)return c.json()}function s(e){return e.filter(e=>e.tool_name&&e.tool_input&&e.tool_output).map((e,t)=>({step:t+1,tool:e.tool_name,input:e.tool_input||{},output:e.tool_output||{},duration_ms:e.duration_ms||0}))}function c(e){let t=e.messages||[],n=t.find(e=>"user"===e.role),a=t.filter(e=>"agent"===e.role||"final_response"===e.role),o=a.length>0?a[a.length-1]:null;return{id:e.session.id,field_id:e.session.field,field_name:e.session.field_name,phone_number:e.session.phone_number,channel:e.session.channel,message:(null==n?void 0:n.content)||"",response:(null==o?void 0:o.content)||"",recommendations:e.recommendations||[],trace:s(t),created_at:e.session.created_at,updated_at:e.session.updated_at,total_duration_ms:0}}let l={startHealthCheck:async e=>i("/agent/message/",{method:"POST",body:JSON.stringify(e)}),getHealthCheckStatus:async e=>i("/agent/status/".concat(e,"/")),getTrace:async e=>{try{let t=await i("/agent/trace/".concat(e,"/"));return c(t)}catch(e){return null}},getTraceSteps:async e=>{try{let t=await i("/agent/trace/".concat(e,"/"));return s(t.messages||[])}catch(e){return[]}},getFields:async()=>{try{return await i("/fields/")}catch(e){return await (0,a.AZ)(300),a.ku}},createField:async e=>i("/fields/",{method:"POST",body:JSON.stringify(e)}),deleteField:async e=>{await i("/fields/".concat(e,"/"),{method:"DELETE"})},getFieldSessions:async e=>{try{return await i("/fields/".concat(e,"/sessions/"))}catch(e){return[]}},enrichSession:async e=>{try{let t=await i("/agent/trace/".concat(e.id,"/"));return c(t)}catch(t){return{id:e.id,field_id:e.field,field_name:e.field_name,phone_number:e.phone_number,channel:e.channel,message:"",response:"",recommendations:[],trace:[],created_at:e.created_at,updated_at:e.updated_at,total_duration_ms:0}}},chatWithAgent:async e=>i("/agent/chat/",{method:"POST",body:JSON.stringify(e)}),getChatHistory:async e=>{try{return(await i("/agent/chat/?field_id=".concat(e))).messages}catch(e){return[]}},getVoiceAudio:async e=>{try{return await i("/voice/".concat(e,"/"))}catch(e){return null}},getFieldWeather:async e=>{try{return await i("/fields/".concat(e,"/weather/"))}catch(e){return[]}},getFieldCropHealth:async e=>{try{return await i("/fields/".concat(e,"/crop-health/"))}catch(e){return[]}},getFieldSoil:async e=>{try{return await i("/fields/".concat(e,"/soil/"))}catch(e){return null}}}},8123:function(e,t,n){n.d(t,{IU:function(){return h},Ms:function(){return c},Vo:function(){return f},aC:function(){return m},hP:function(){return r},jb:function(){return p},jl:function(){return d},x4:function(){return _},yE:function(){return l}});var a=n(2265),o=n(3217);function r(){return localStorage.getItem("access_token")}function i(e,t){localStorage.setItem("access_token",e),localStorage.setItem("refresh_token",t)}function s(e){localStorage.setItem("username",e)}function c(){return localStorage.getItem("username")}function l(){localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token"),localStorage.removeItem("username")}function d(){return!!r()}let u=null;async function p(){return u||(u=(async()=>{let e=localStorage.getItem("refresh_token");if(!e)return!1;try{let t=await fetch("".concat(o.T,"/auth/token/refresh/"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh:e})});if(t.ok){let e=await t.json();return localStorage.setItem("access_token",e.access),!0}return l(),!1}catch(e){return!1}finally{u=null}})())}async function _(e,t){try{let n=await fetch("".concat(o.T,"/auth/login/"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t})});if(n.ok){let t=await n.json();return i(t.access,t.refresh),s(t.username||e),{ok:!0}}let a=await n.json().catch(()=>null),r=(null==a?void 0:a.detail)||(null==a?void 0:a.error)||"Invalid credentials";return{ok:!1,error:r}}catch(e){return{ok:!1,error:"Network error — is the backend running?"}}}async function h(e,t,n,a){try{let r=await fetch("".concat(o.T,"/auth/signup/"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,email:t,phone_number:n,password:a})});if(r.ok||201===r.status){let t=await r.json();return i(t.access,t.refresh),s(t.username||e),{ok:!0}}let c=await r.json().catch(()=>null);if(c){let e=Object.values(c).flat()[0];if("string"==typeof e)return{ok:!1,error:e}}return{ok:!1,error:"Signup failed"}}catch(e){return{ok:!1,error:"Network error — is the backend running?"}}}let f=(0,a.createContext)({loggedIn:!1,logout:()=>{},refresh:()=>{}});function m(){return(0,a.useContext)(f)}},3217:function(e,t,n){n.d(t,{T:function(){return a}});let a="https://crop-advisor-922c34c099bf.herokuapp.com/api/v1"},39:function(e,t,n){n.d(t,{AZ:function(){return c},PV:function(){return s},ku:function(){return a},showcaseResponse:function(){return i}});let a=[{id:"patel-cotton-east",name:"Patel Cotton East",crop_type:"cotton",lat:33.4255,lng:-111.94,area_acres:120,soil_type:"Sandy loam",last_ndvi:.42,last_recommendation:"Irrigate within 24h — moderate drought stress detected"},{id:"mesa-citrus",name:"Mesa Citrus Grove",crop_type:"citrus",lat:33.4152,lng:-111.8315,area_acres:45,soil_type:"Clay loam",last_ndvi:.71,last_recommendation:"Monitor — healthy canopy, no action needed"},{id:"chandler-alfalfa",name:"Chandler Alfalfa",crop_type:"alfalfa",lat:33.3062,lng:-111.8413,area_acres:200,soil_type:"Silty clay",last_ndvi:.28,last_recommendation:"Fertilize immediately — nitrogen deficiency detected"}],o=[{step:1,tool:"get_weather",input:{lat:33.4255,lng:-111.94,field_id:"patel-cotton-east"},output:{temp_f:105,humidity_pct:12,wind_mph:8,precipitation_7d_in:0,forecast:"Clear skies, no rain expected for 10 days",uv_index:11,heat_advisory:!0},duration_ms:340},{step:2,tool:"get_crop_health",input:{field_id:"patel-cotton-east",satellite:"sentinel-2"},output:{ndvi:.42,ndvi_trend:"declining",stress_level:"moderate",canopy_temp_f:112,leaf_water_content:"low",comparison_30d:-.15,affected_area_pct:68},duration_ms:890},{step:3,tool:"get_soil_profile",input:{field_id:"patel-cotton-east",depth_inches:12},output:{soil_type:"Sandy loam",moisture_pct:14,ph:7.8,nitrogen_ppm:22,phosphorus_ppm:18,potassium_ppm:145,water_holding_capacity:"low",organic_matter_pct:1.2},duration_ms:210}],r=[{action_type:"irrigate",urgency:"immediate",description:"Your cotton is showing early drought stress. NDVI has dropped 0.15 in 30 days with 68% of the field affected. No rain in forecast. Begin center pivot irrigation within 6 hours to prevent yield loss.",estimated_cost:"$180",risk_if_delayed:"Yield loss of 12-15% if not irrigated within 48 hours. Boll development will be compromised."}],i={session_id:"sess-001",response:"Your cotton is showing early drought stress — I'd recommend irrigating within the next 6 hours. The satellite data shows your NDVI has dropped to 0.42, and with 105\xb0F temps and zero rain in the forecast, your field needs water. Estimated cost is about $180 for the full 120 acres via center pivot.",recommendations:r,trace:o},s=[{id:"sess-001",field_id:"patel-cotton-east",field_name:"Patel Cotton East",phone_number:"+1 (480) 555-0142",channel:"sms",message:"How's my cotton field looking?",recommendations:r,trace:o,response:i.response,created_at:"2026-04-04T09:23:00Z",updated_at:"2026-04-04T09:23:01Z",total_duration_ms:1440}
1,{id:"sess-002",field_id:"mesa-citrus",field_name:"Mesa Citrus Grove",phone_number:"+1 (480) 555-0198",channel:"dashboard",message:"Check on my citrus trees please",recommendations:[{action_type:"no_action",urgency:"monitor",description:"Citrus grove is in good health. NDVI at 0.71 is within normal range. Continue current irrigation schedule.",estimated_cost:"$0",risk_if_delayed:"No immediate risk. Re-check in 5 days."}],trace:[{step:1,tool:"get_weather",input:{lat:33.4152,lng:-111.8315,field_id:"mesa-citrus"},output:{temp_f:102,humidity_pct:18,precipitation_7d_in:.1,forecast:"Partly cloudy"},duration_ms:280},{step:2,tool:"get_crop_health",input:{field_id:"mesa-citrus",satellite:"sentinel-2"},output:{ndvi:.71,ndvi_trend:"stable",stress_level:"none",canopy_temp_f:98},duration_ms:720},{step:3,tool:"get_soil_profile",input:{field_id:"mesa-citrus",depth_inches:18},output:{soil_type:"Clay loam",moisture_pct:28,ph:6.9,nitrogen_ppm:35},duration_ms:190}],response:"Your citrus grove looks great! NDVI is at 0.71, which is healthy. No action needed right now — just keep your current irrigation going.",created_at:"2026-04-04T08:15:00Z",updated_at:"2026-04-04T08:15:01Z",total_duration_ms:1190},{id:"sess-003",field_id:"chandler-alfalfa",field_name:"Chandler Alfalfa",phone_number:"+1 (480) 555-0267",channel:"sms",message:"My alfalfa looks yellow, what should I do?",recommendations:[{action_type:"fertilize",urgency:"within_24h",description:"Nitrogen deficiency detected across 80% of the field. Apply 40 lbs/acre urea immediately. NDVI at 0.28 indicates severe stress.",estimated_cost:"$320",risk_if_delayed:"Further yield decline of 20-25% per cutting cycle if untreated."}],trace:[{step:1,tool:"get_weather",input:{lat:33.3062,lng:-111.8413,field_id:"chandler-alfalfa"},output:{temp_f:100,humidity_pct:15,precipitation_7d_in:0,forecast:"Hot and dry"},duration_ms:310},{step:2,tool:"get_crop_health",input:{field_id:"chandler-alfalfa",satellite:"sentinel-2"},output:{ndvi:.28,ndvi_trend:"declining",stress_level:"severe",affected_area_pct:80},duration_ms:850},{step:3,tool:"get_soil_profile",input:{field_id:"chandler-alfalfa",depth_inches:12},output:{soil_type:"Silty clay",moisture_pct:22,ph:7.2,nitrogen_ppm:8,phosphorus_ppm:12},duration_ms:240}],response:"Your alfalfa is showing nitrogen deficiency — that's what's causing the yellowing. I'd recommend applying 40 lbs/acre of urea as soon as possible. The estimated cost is about $320 for your 200 acres.",created_at:"2026-04-03T16:45:00Z",updated_at:"2026-04-03T16:45:01Z",total_duration_ms:1400}];function c(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1500;return new Promise(t=>setTimeout(t,e))}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.