#capture endpoint
crew Crew(
agentcapture
taskscapturetask
memoryTrue
cacheTrue
maxrpm100
sharecrewTrue
)
@(/api/proposals/capture/ methodsGET)
def captureproposal(proposalid):
if db is None:
return jsonify(error: FIREBASENOTINITIALIZED) 500
try:
# 1 Check proposal existence
doc (proposals).document(proposalid).get()
if not :
return jsonify(error: PROPOSALNOTFOUNDMSG) 404
proposaldata ()
content (content )
# 2 Check if capture already exists
capturedoc (proposalcapture).document(proposalid).get()
if :
# If exists just return the stored intelligence summary
return jsonify(().get(intelligenceSummary )) 200
# 3 Extract organization name
orgname extractorgname(content)
# 4 Run Crew agent
intelsummary (inputsorgname: orgname)
# 5 Normalize CrewOutput to JSON-safe dict
def normalize(result):
jd getattr(result jsondict None)
if jd:
return jd
raw getattr(result raw None) or str(result)
try:
return (raw)
except Exception:
m (rsS* raw)
if m:
try:
return ((0))
except Exception:
pass
# If all fails wrap as a fallback
return
clientProfile:
incumbentVendors:
competitors:
painPoint:
stakeholders:
raw: raw
intelsummarysafe normalize(intelsummary)
# 6 Ensure all top-level keys exist
structuredresponse
clientProfile: (clientProfile )
incumbentVendors: (incumbentVendors )
competitors: (competitors )
painPoint: (painPoint )
stakeholders: (stakeholders )
# 7 Save capture in Firestore
(proposalcapture).document(proposalid).set(
proposalId: proposalid
orgName: orgname
intelligenceSummary: structuredresponse
updatedAt: ().isoformat()
)
# 8 Return structured response
return jsonify(structuredresponse) 200
except Exception as e:
print(f Error capturing proposal proposalid: e)
return jsonify(error: str(e)) 500
Scheduling:
- Shifts are determined or assigned
- 48 hours are approved
- Ratios: 1:1 1:3 1:4