monkeybrain-runtime 1.0.0__py3-none-any.whl
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.
- monkeybrain_runtime-1.0.0.dist-info/METADATA +76 -0
- monkeybrain_runtime-1.0.0.dist-info/RECORD +838 -0
- monkeybrain_runtime-1.0.0.dist-info/WHEEL +5 -0
- monkeybrain_runtime-1.0.0.dist-info/entry_points.txt +3 -0
- monkeybrain_runtime-1.0.0.dist-info/top_level.txt +2 -0
- services/__init__.py +8 -0
- services/agentos/__init__.py +0 -0
- services/agentos/main.py +1 -0
- services/assets/helpers/__init__.py +12 -0
- services/assets/helpers/device.py +59 -0
- services/assets/helpers/equipment.py +179 -0
- services/assets/helpers/instruments.py +72 -0
- services/assets/helpers/machines.py +183 -0
- services/assets/helpers/materials.py +76 -0
- services/assets/helpers/parts.py +116 -0
- services/assets/helpers/plc.py +134 -0
- services/assets/helpers/tags.py +108 -0
- services/assets/helpers/tools.py +101 -0
- services/assets/main.py +75 -0
- services/assets/models/__init__.py +12 -0
- services/assets/models/device.py +79 -0
- services/assets/models/equipment.py +222 -0
- services/assets/models/instruments.py +85 -0
- services/assets/models/machines.py +230 -0
- services/assets/models/material.py +266 -0
- services/assets/models/parts.py +96 -0
- services/assets/models/plc.py +264 -0
- services/assets/models/tags.py +76 -0
- services/assets/models/tools.py +179 -0
- services/assets/routers/__init__.py +12 -0
- services/assets/routers/classes.py +65 -0
- services/assets/routers/device.py +86 -0
- services/assets/routers/equipment.py +145 -0
- services/assets/routers/families.py +61 -0
- services/assets/routers/instruments.py +70 -0
- services/assets/routers/machines.py +136 -0
- services/assets/routers/materials.py +105 -0
- services/assets/routers/parts.py +130 -0
- services/assets/routers/plc.py +94 -0
- services/assets/routers/subclasses.py +68 -0
- services/assets/routers/tags.py +138 -0
- services/assets/routers/tools.py +113 -0
- services/auth/helpers/__init__.py +13 -0
- services/auth/helpers/approval_decisions.py +261 -0
- services/auth/helpers/audit_elasticsearch_sync.py +350 -0
- services/auth/helpers/departments.py +53 -0
- services/auth/helpers/graph_store.py +848 -0
- services/auth/helpers/influx_store.py +280 -0
- services/auth/helpers/me.py +33 -0
- services/auth/helpers/nats_consumer.py +618 -0
- services/auth/helpers/nats_store.py +242 -0
- services/auth/helpers/permissions.py +62 -0
- services/auth/helpers/roles.py +87 -0
- services/auth/helpers/store.py +54 -0
- services/auth/helpers/team_members.py +155 -0
- services/auth/helpers/teams.py +87 -0
- services/auth/helpers/tokens.py +71 -0
- services/auth/helpers/users.py +119 -0
- services/auth/helpers/websocket_broadcast.py +41 -0
- services/auth/main.py +88 -0
- services/auth/models/__init__.py +12 -0
- services/auth/models/departments.py +55 -0
- services/auth/models/login.py +20 -0
- services/auth/models/permissions.py +61 -0
- services/auth/models/roles.py +53 -0
- services/auth/models/session.py +26 -0
- services/auth/models/teamMembers.py +59 -0
- services/auth/models/teams.py +56 -0
- services/auth/models/users.py +77 -0
- services/auth/routers/__init__.py +14 -0
- services/auth/routers/auth.py +3839 -0
- services/auth/routers/departments.py +84 -0
- services/auth/routers/integration_config.py +703 -0
- services/auth/routers/me.py +28 -0
- services/auth/routers/permissions.py +96 -0
- services/auth/routers/roles.py +139 -0
- services/auth/routers/session.py +224 -0
- services/auth/routers/team_members.py +152 -0
- services/auth/routers/teams.py +112 -0
- services/auth/routers/users.py +131 -0
- services/auth/routers/websocket_events.py +247 -0
- services/batch_execution/__init__.py +19 -0
- services/batch_execution/pipeline_triggers/__init__.py +53 -0
- services/batch_execution/pipeline_triggers/pipeline_parameter_adjuster.py +440 -0
- services/batch_execution/pipeline_triggers/pipeline_trigger_engine.py +445 -0
- services/batch_execution/pipeline_triggers/re_evaluation_queue.py +341 -0
- services/batch_execution/pipeline_triggers/test_phase3_implementation.py +553 -0
- services/batch_execution/pipeline_triggers/workflow_reevaluator.py +367 -0
- services/batch_execution/smoke_test_e2e_feedback_loop.py +704 -0
- services/batch_execution/workflow_executor.py +478 -0
- services/changeover/helpers/__init__.py +11 -0
- services/changeover/helpers/changeover.py +87 -0
- services/changeover/helpers/changeover_common.py +55 -0
- services/changeover/helpers/changeover_events.py +66 -0
- services/changeover/helpers/changeover_kpis.py +33 -0
- services/changeover/helpers/changeover_matrix.py +60 -0
- services/changeover/helpers/changeover_procedures.py +164 -0
- services/changeover/helpers/changeover_windows.py +96 -0
- services/changeover/main.py +52 -0
- services/changeover/models/__init__.py +11 -0
- services/changeover/models/changeover.py +73 -0
- services/changeover/models/changeover_events.py +142 -0
- services/changeover/models/changeover_kpis.py +75 -0
- services/changeover/models/changeover_matrix.py +63 -0
- services/changeover/models/changeover_procedures.py +108 -0
- services/changeover/models/changeover_tasks.py +87 -0
- services/changeover/models/changeover_windows.py +72 -0
- services/changeover/routers/__init__.py +9 -0
- services/changeover/routers/changeover_events.py +127 -0
- services/changeover/routers/changeover_kpis.py +80 -0
- services/changeover/routers/changeover_matrix.py +80 -0
- services/changeover/routers/changeover_procedures.py +118 -0
- services/changeover/routers/changeover_windows.py +98 -0
- services/common/__init__.py +2 -0
- services/common/approval_chains.py +648 -0
- services/common/auth.py +56 -0
- services/common/cdc.py +52 -0
- services/common/compat.py +217 -0
- services/common/compliance.py +562 -0
- services/common/config.py +134 -0
- services/common/cors.py +17 -0
- services/common/data_transformation.py +195 -0
- services/common/db.py +577 -0
- services/common/embeddings.py +97 -0
- services/common/event_reducers.py +194 -0
- services/common/event_types.py +51 -0
- services/common/integration_ingestion.py +169 -0
- services/common/logging.py +204 -0
- services/common/models/__init__.py +2 -0
- services/common/models/databricks.py +25 -0
- services/common/models/enums.py +64 -0
- services/common/module_control.py +422 -0
- services/common/mongo_cdc_watcher.py +106 -0
- services/common/n8n_auth.py +22 -0
- services/common/neo4j_mirror.py +1087 -0
- services/common/ontology_registry.py +110 -0
- services/common/reasoning_traces.py +52 -0
- services/common/supply_chain_cdc.py +555 -0
- services/common/tracing.py +159 -0
- services/common/utils.py +30 -0
- services/customers/helpers/__init__.py +8 -0
- services/customers/helpers/customer_details.py +64 -0
- services/customers/helpers/customer_metadata.py +64 -0
- services/customers/helpers/customer_order_metrics.py +67 -0
- services/customers/helpers/customer_payment_data.py +67 -0
- services/customers/main.py +50 -0
- services/customers/models/__init__.py +8 -0
- services/customers/models/customer_details.py +42 -0
- services/customers/models/customer_metadata.py +97 -0
- services/customers/models/customer_order_metrics.py +86 -0
- services/customers/models/customer_payment_data.py +60 -0
- services/customers/routers/__init__.py +8 -0
- services/customers/routers/customer_details.py +88 -0
- services/customers/routers/customer_metadata.py +88 -0
- services/customers/routers/customer_order_metrics.py +88 -0
- services/customers/routers/customer_payment_data.py +88 -0
- services/documents/__init__.py +1 -0
- services/documents/helpers/__init__.py +6 -0
- services/documents/helpers/document_metadata.py +569 -0
- services/documents/helpers/document_workflows.py +215 -0
- services/documents/helpers/report_templates.py +113 -0
- services/documents/main.py +49 -0
- services/documents/models/__init__.py +6 -0
- services/documents/models/document_metadata.py +215 -0
- services/documents/models/document_workflows.py +136 -0
- services/documents/models/report_templates.py +132 -0
- services/documents/routers/__init__.py +6 -0
- services/documents/routers/document_metadata.py +654 -0
- services/documents/routers/document_workflows.py +146 -0
- services/documents/routers/report_templates.py +86 -0
- services/events/helpers/__init__.py +5 -0
- services/events/helpers/events.py +394 -0
- services/events/main.py +40 -0
- services/events/models/__init__.py +5 -0
- services/events/models/events.py +50 -0
- services/events/routers/__init__.py +6 -0
- services/events/routers/count_events.py +109 -0
- services/events/routers/events.py +75 -0
- services/events/seed_events.py +196 -0
- services/facilities/helpers/__init__.py +8 -0
- services/facilities/helpers/lines.py +74 -0
- services/facilities/helpers/locations.py +231 -0
- services/facilities/helpers/plants.py +59 -0
- services/facilities/helpers/stages.py +110 -0
- services/facilities/helpers/workstation.py +213 -0
- services/facilities/main.py +60 -0
- services/facilities/models/__init__.py +10 -0
- services/facilities/models/industrialLine.py +72 -0
- services/facilities/models/industrialPlant.py +164 -0
- services/facilities/models/locations.py +74 -0
- services/facilities/models/stages.py +92 -0
- services/facilities/models/worker.py +73 -0
- services/facilities/models/workstation.py +117 -0
- services/facilities/models/workstation_live_state.py +59 -0
- services/facilities/routers/__init__.py +8 -0
- services/facilities/routers/bays.py +81 -0
- services/facilities/routers/buildings.py +92 -0
- services/facilities/routers/floors.py +81 -0
- services/facilities/routers/lines.py +154 -0
- services/facilities/routers/locations.py +208 -0
- services/facilities/routers/plant.py +203 -0
- services/facilities/routers/rooms.py +81 -0
- services/facilities/routers/stages.py +152 -0
- services/facilities/routers/workstation.py +173 -0
- services/file/backup.py +71 -0
- services/file/main.py +45 -0
- services/file/recieve.py +54 -0
- services/file/send.py +55 -0
- services/file/src/core/config.py +90 -0
- services/file/src/core/keycloak.py +152 -0
- services/file/src/core/logging_config.py +9 -0
- services/file/src/core/security.py +33 -0
- services/file/src/helpers/cad_conversion.py +331 -0
- services/file/src/helpers/helpers.py +825 -0
- services/file/src/routes/cad_conversion.py +26 -0
- services/file/src/routes/files.py +136 -0
- services/file/src/routes/presigned.py +154 -0
- services/file/src/services/websocket.py +293 -0
- services/floor_layout/helpers/__init__.py +8 -0
- services/floor_layout/helpers/bays.py +92 -0
- services/floor_layout/helpers/buildings.py +54 -0
- services/floor_layout/helpers/floors.py +65 -0
- services/floor_layout/helpers/rooms.py +76 -0
- services/floor_layout/main.py +52 -0
- services/floor_layout/models/__init__.py +8 -0
- services/floor_layout/models/bays.py +65 -0
- services/floor_layout/models/buildings.py +52 -0
- services/floor_layout/models/floors.py +45 -0
- services/floor_layout/models/rooms.py +61 -0
- services/floor_layout/routers/__init__.py +9 -0
- services/floor_layout/routers/bays.py +143 -0
- services/floor_layout/routers/buildings.py +116 -0
- services/floor_layout/routers/floors.py +89 -0
- services/floor_layout/routers/locations.py +80 -0
- services/floor_layout/routers/rooms.py +134 -0
- services/inventory/helpers/__init__.py +13 -0
- services/inventory/helpers/cycle_counts.py +124 -0
- services/inventory/helpers/inventory_allocations.py +134 -0
- services/inventory/helpers/inventory_item_counts.py +114 -0
- services/inventory/helpers/inventory_item_quantities.py +114 -0
- services/inventory/helpers/inventory_items.py +103 -0
- services/inventory/helpers/inventory_stage_outputs.py +134 -0
- services/inventory/helpers/inventory_transactions.py +112 -0
- services/inventory/helpers/stock_adjustment_requests.py +101 -0
- services/inventory/helpers/warehouse_cycle_counts.py +133 -0
- services/inventory/helpers/warehouse_locations.py +213 -0
- services/inventory/helpers/warehouse_regulated_records.py +123 -0
- services/inventory/main.py +62 -0
- services/inventory/models/__init__.py +17 -0
- services/inventory/models/cycle_counts.py +99 -0
- services/inventory/models/inventory_allocations.py +121 -0
- services/inventory/models/inventory_common.py +65 -0
- services/inventory/models/inventory_enums.py +21 -0
- services/inventory/models/inventory_item_count.py +65 -0
- services/inventory/models/inventory_item_quantity.py +82 -0
- services/inventory/models/inventory_items.py +168 -0
- services/inventory/models/inventory_responses.py +44 -0
- services/inventory/models/inventory_stage_outputs.py +96 -0
- services/inventory/models/inventory_state.py +15 -0
- services/inventory/models/inventory_transactions.py +80 -0
- services/inventory/models/stock_adjustment_requests.py +109 -0
- services/inventory/models/warehouse_cycle_counts.py +119 -0
- services/inventory/models/warehouse_location_models.py +708 -0
- services/inventory/models/warehouse_regulated_records.py +358 -0
- services/inventory/routers/__init__.py +13 -0
- services/inventory/routers/cycle_counts.py +106 -0
- services/inventory/routers/inventory_allocations.py +125 -0
- services/inventory/routers/inventory_item_counts.py +105 -0
- services/inventory/routers/inventory_item_quantities.py +105 -0
- services/inventory/routers/inventory_items.py +109 -0
- services/inventory/routers/inventory_stage_outputs.py +122 -0
- services/inventory/routers/inventory_transactions.py +96 -0
- services/inventory/routers/stock_adjustment_requests.py +124 -0
- services/inventory/routers/warehouse_cycle_counts.py +124 -0
- services/inventory/routers/warehouse_locations.py +426 -0
- services/inventory/routers/warehouse_regulated_records.py +273 -0
- services/iot/helpers/__init__.py +8 -0
- services/iot/helpers/ble_device.py +87 -0
- services/iot/helpers/mqtt_bridge.py +115 -0
- services/iot/helpers/sensor_readings.py +63 -0
- services/iot/helpers/sensors.py +77 -0
- services/iot/helpers/servers.py +72 -0
- services/iot/helpers/uwb_device.py +95 -0
- services/iot/main.py +53 -0
- services/iot/models/__init__.py +8 -0
- services/iot/models/ble_device.py +118 -0
- services/iot/models/sensors.py +256 -0
- services/iot/models/servers.py +206 -0
- services/iot/models/uwb_device.py +106 -0
- services/iot/routers/__init__.py +8 -0
- services/iot/routers/ble_device.py +110 -0
- services/iot/routers/sensors.py +144 -0
- services/iot/routers/servers.py +141 -0
- services/iot/routers/uwb_device.py +148 -0
- services/module_control/__init__.py +1 -0
- services/module_control/helpers/__init__.py +1 -0
- services/module_control/helpers/integration_config.py +243 -0
- services/module_control/helpers/security.py +104 -0
- services/module_control/main.py +44 -0
- services/module_control/models/__init__.py +1 -0
- services/module_control/models/module_control.py +65 -0
- services/module_control/routers/__init__.py +1 -0
- services/module_control/routers/module_control.py +219 -0
- services/orders/helpers/__init__.py +11 -0
- services/orders/helpers/invoices.py +123 -0
- services/orders/helpers/order_customer_metrics.py +61 -0
- services/orders/helpers/order_details.py +71 -0
- services/orders/helpers/order_metadata.py +61 -0
- services/orders/helpers/order_payment_metadata.py +74 -0
- services/orders/helpers/orders.py +119 -0
- services/orders/helpers/sales_orders.py +136 -0
- services/orders/main.py +56 -0
- services/orders/models/__init__.py +11 -0
- services/orders/models/invoices.py +415 -0
- services/orders/models/order_customer_metrics.py +78 -0
- services/orders/models/order_details.py +46 -0
- services/orders/models/order_metadata.py +60 -0
- services/orders/models/order_payment_metadata.py +63 -0
- services/orders/models/orders.py +64 -0
- services/orders/models/sales_orders.py +130 -0
- services/orders/routers/__init__.py +11 -0
- services/orders/routers/invoices.py +111 -0
- services/orders/routers/order_customer_metrics.py +87 -0
- services/orders/routers/order_details.py +87 -0
- services/orders/routers/order_metadata.py +87 -0
- services/orders/routers/order_payment_metadata.py +87 -0
- services/orders/routers/orders.py +74 -0
- services/orders/routers/sales_orders.py +111 -0
- services/pm/helpers/__init__.py +14 -0
- services/pm/helpers/calendar_bookings.py +114 -0
- services/pm/helpers/calibration_point.py +110 -0
- services/pm/helpers/calibrations.py +196 -0
- services/pm/helpers/checklists.py +318 -0
- services/pm/helpers/cleaning.py +333 -0
- services/pm/helpers/downtime.py +376 -0
- services/pm/helpers/kanban_boards.py +186 -0
- services/pm/helpers/maintainance.py +177 -0
- services/pm/helpers/sop.py +1155 -0
- services/pm/helpers/sop_cdc.py +324 -0
- services/pm/helpers/weekly_schedules.py +79 -0
- services/pm/main.py +62 -0
- services/pm/models/__init__.py +14 -0
- services/pm/models/calendar_booking.py +82 -0
- services/pm/models/calibration_point.py +44 -0
- services/pm/models/calibrations.py +167 -0
- services/pm/models/checklists.py +117 -0
- services/pm/models/cleaning.py +203 -0
- services/pm/models/downtime.py +109 -0
- services/pm/models/kanban_board.py +178 -0
- services/pm/models/maintainanceLog.py +148 -0
- services/pm/models/sop.py +152 -0
- services/pm/models/weekly_schedule.py +91 -0
- services/pm/routers/__init__.py +14 -0
- services/pm/routers/calendar_bookings.py +143 -0
- services/pm/routers/calibration_point.py +94 -0
- services/pm/routers/calibrations.py +232 -0
- services/pm/routers/checklists.py +188 -0
- services/pm/routers/cleaning.py +127 -0
- services/pm/routers/downtime.py +143 -0
- services/pm/routers/kanban_boards.py +283 -0
- services/pm/routers/maintainance.py +241 -0
- services/pm/routers/sop.py +437 -0
- services/pm/routers/weekly_schedules.py +108 -0
- services/process_definitions/helpers/__init__.py +11 -0
- services/process_definitions/helpers/cpp_cqa_registry.py +120 -0
- services/process_definitions/helpers/mbmr_templates.py +107 -0
- services/process_definitions/helpers/packing_instructions.py +113 -0
- services/process_definitions/helpers/process_constraints.py +495 -0
- services/process_definitions/helpers/process_corrections.py +279 -0
- services/process_definitions/helpers/process_definition.py +996 -0
- services/process_definitions/helpers/process_node_catalog.py +786 -0
- services/process_definitions/helpers/process_post_checks.py +441 -0
- services/process_definitions/helpers/process_pre_checks.py +351 -0
- services/process_definitions/helpers/process_steps.py +220 -0
- services/process_definitions/main.py +71 -0
- services/process_definitions/models/__init__.py +13 -0
- services/process_definitions/models/cpp_cqa_registry.py +145 -0
- services/process_definitions/models/gxp_change_controls.py +38 -0
- services/process_definitions/models/gxp_risk_assessments.py +30 -0
- services/process_definitions/models/gxp_validation_evidence.py +33 -0
- services/process_definitions/models/mbmr_templates.py +173 -0
- services/process_definitions/models/packing_instructions.py +176 -0
- services/process_definitions/models/process_constraints.py +159 -0
- services/process_definitions/models/process_corrections.py +118 -0
- services/process_definitions/models/process_definition.py +685 -0
- services/process_definitions/models/process_definition_common.py +48 -0
- services/process_definitions/models/process_node_catalog.py +25 -0
- services/process_definitions/models/process_post_checks.py +171 -0
- services/process_definitions/models/process_pre_checks.py +168 -0
- services/process_definitions/models/process_steps.py +170 -0
- services/process_definitions/node_services/__init__.py +8 -0
- services/process_definitions/node_services/common.py +95 -0
- services/process_definitions/node_services/executor.py +499 -0
- services/process_definitions/node_services/flow_simulator.py +733 -0
- services/process_definitions/node_services/functions.py +193 -0
- services/process_definitions/node_services/messaging.py +44 -0
- services/process_definitions/node_services/models.py +221 -0
- services/process_definitions/node_services/network.py +161 -0
- services/process_definitions/node_services/parsers.py +87 -0
- services/process_definitions/node_services/sequence.py +95 -0
- services/process_definitions/node_services/storage.py +50 -0
- services/process_definitions/node_services/webhooks.py +52 -0
- services/process_definitions/routers/__init__.py +10 -0
- services/process_definitions/routers/cpp_cqa_registry.py +86 -0
- services/process_definitions/routers/mbmr_templates.py +84 -0
- services/process_definitions/routers/packing_instructions.py +84 -0
- services/process_definitions/routers/process_constraints.py +564 -0
- services/process_definitions/routers/process_corrections.py +343 -0
- services/process_definitions/routers/process_definition.py +992 -0
- services/process_definitions/routers/process_post_checks.py +529 -0
- services/process_definitions/routers/process_pre_checks.py +435 -0
- services/process_definitions/routers/process_steps.py +274 -0
- services/procurement/helpers/__init__.py +9 -0
- services/procurement/helpers/goods_receipts.py +240 -0
- services/procurement/helpers/purchase_order_shipping_information.py +85 -0
- services/procurement/helpers/purchase_orders.py +68 -0
- services/procurement/helpers/quality_control.py +235 -0
- services/procurement/helpers/sampling.py +404 -0
- services/procurement/main.py +52 -0
- services/procurement/models/__init__.py +9 -0
- services/procurement/models/goods_receipts.py +165 -0
- services/procurement/models/purchase_orders.py +54 -0
- services/procurement/models/quality_control.py +464 -0
- services/procurement/models/reinspection_records.py +28 -0
- services/procurement/models/sampling.py +262 -0
- services/procurement/models/shipping_information.py +51 -0
- services/procurement/routers/__init__.py +9 -0
- services/procurement/routers/goods_receipts.py +201 -0
- services/procurement/routers/purchase_orders.py +106 -0
- services/procurement/routers/quality_control.py +386 -0
- services/procurement/routers/sampling.py +296 -0
- services/procurement/routers/shipping_information.py +97 -0
- services/production/__init__.py +1 -0
- services/production/agents/__init__.py +5 -0
- services/production/agents/batch_planning_agent.py +815 -0
- services/production/models/__init__.py +25 -0
- services/production/models/batch.py +253 -0
- services/products/helpers/__init__.py +10 -0
- services/products/helpers/boms.py +100 -0
- services/products/helpers/drug_research.py +644 -0
- services/products/helpers/product_component.py +168 -0
- services/products/helpers/product_inventory.py +221 -0
- services/products/helpers/product_pricing.py +123 -0
- services/products/helpers/product_utils.py +32 -0
- services/products/helpers/products.py +81 -0
- services/products/main.py +59 -0
- services/products/models/__init__.py +9 -0
- services/products/models/drug_research.py +138 -0
- services/products/models/product_common.py +60 -0
- services/products/models/product_component.py +1028 -0
- services/products/models/product_inventory.py +118 -0
- services/products/models/product_pricing.py +73 -0
- services/products/models/products.py +151 -0
- services/products/routers/__init__.py +9 -0
- services/products/routers/boms.py +116 -0
- services/products/routers/drug_research.py +115 -0
- services/products/routers/product_components.py +123 -0
- services/products/routers/product_inventory.py +185 -0
- services/products/routers/product_pricing.py +136 -0
- services/products/routers/products.py +165 -0
- services/replenishment/__init__.py +1 -0
- services/replenishment/main.py +46 -0
- services/replenishment/routers/__init__.py +1 -0
- services/replenishment/routers/replenishment.py +20 -0
- services/shifts/helpers/__init__.py +7 -0
- services/shifts/helpers/shift_templates.py +124 -0
- services/shifts/helpers/shifts.py +79 -0
- services/shifts/helpers/timesheets.py +137 -0
- services/shifts/main.py +48 -0
- services/shifts/models/__init__.py +8 -0
- services/shifts/models/shift.py +62 -0
- services/shifts/models/shift_template.py +82 -0
- services/shifts/models/time_range.py +31 -0
- services/shifts/models/timesheet.py +196 -0
- services/shifts/routers/__init__.py +7 -0
- services/shifts/routers/shift_templates.py +97 -0
- services/shifts/routers/shifts.py +117 -0
- services/shifts/routers/timesheets.py +117 -0
- services/shipping/helpers/__init__.py +15 -0
- services/shipping/helpers/carrier.py +78 -0
- services/shipping/helpers/customs_declaration.py +104 -0
- services/shipping/helpers/delivery_note.py +99 -0
- services/shipping/helpers/package.py +95 -0
- services/shipping/helpers/pallet.py +85 -0
- services/shipping/helpers/route.py +93 -0
- services/shipping/helpers/shipping_information.py +82 -0
- services/shipping/helpers/shipping_provider_details.py +59 -0
- services/shipping/helpers/shipping_provider_metadata.py +59 -0
- services/shipping/helpers/vehicle.py +85 -0
- services/shipping/helpers/waybill.py +86 -0
- services/shipping/main.py +64 -0
- services/shipping/models/__init__.py +15 -0
- services/shipping/models/carrier.py +97 -0
- services/shipping/models/customs_declaration.py +138 -0
- services/shipping/models/delivery_note.py +163 -0
- services/shipping/models/package.py +152 -0
- services/shipping/models/pallet.py +137 -0
- services/shipping/models/route.py +120 -0
- services/shipping/models/shipping_information.py +55 -0
- services/shipping/models/shipping_provider_details.py +42 -0
- services/shipping/models/shipping_provider_metadata.py +54 -0
- services/shipping/models/vehicle.py +129 -0
- services/shipping/models/waybill.py +189 -0
- services/shipping/routers/__init__.py +15 -0
- services/shipping/routers/carrier.py +99 -0
- services/shipping/routers/customs_declaration.py +132 -0
- services/shipping/routers/delivery_note.py +150 -0
- services/shipping/routers/package.py +141 -0
- services/shipping/routers/pallet.py +108 -0
- services/shipping/routers/route.py +128 -0
- services/shipping/routers/shipping_information.py +97 -0
- services/shipping/routers/shipping_provider_details.py +80 -0
- services/shipping/routers/shipping_provider_metadata.py +80 -0
- services/shipping/routers/vehicle.py +117 -0
- services/shipping/routers/waybill.py +119 -0
- services/suppliers/helpers/__init__.py +13 -0
- services/suppliers/helpers/supplier_capabilities.py +58 -0
- services/suppliers/helpers/supplier_certifications.py +67 -0
- services/suppliers/helpers/supplier_details.py +58 -0
- services/suppliers/helpers/supplier_financials.py +58 -0
- services/suppliers/helpers/supplier_inventory.py +74 -0
- services/suppliers/helpers/supplier_locations.py +60 -0
- services/suppliers/helpers/supplier_pricing.py +69 -0
- services/suppliers/helpers/supplier_quality.py +69 -0
- services/suppliers/helpers/supplier_shipping.py +69 -0
- services/suppliers/main.py +60 -0
- services/suppliers/models/__init__.py +13 -0
- services/suppliers/models/supplier_capabilities.py +70 -0
- services/suppliers/models/supplier_certifications.py +64 -0
- services/suppliers/models/supplier_details.py +75 -0
- services/suppliers/models/supplier_financials.py +69 -0
- services/suppliers/models/supplier_inventory.py +76 -0
- services/suppliers/models/supplier_locations.py +70 -0
- services/suppliers/models/supplier_pricing.py +74 -0
- services/suppliers/models/supplier_quality.py +74 -0
- services/suppliers/models/supplier_shipping.py +76 -0
- services/suppliers/routers/__init__.py +13 -0
- services/suppliers/routers/supplier_capabilities.py +88 -0
- services/suppliers/routers/supplier_certifications.py +87 -0
- services/suppliers/routers/supplier_details.py +83 -0
- services/suppliers/routers/supplier_financials.py +83 -0
- services/suppliers/routers/supplier_inventory.py +105 -0
- services/suppliers/routers/supplier_locations.py +89 -0
- services/suppliers/routers/supplier_pricing.py +96 -0
- services/suppliers/routers/supplier_quality.py +96 -0
- services/suppliers/routers/supplier_shipping.py +96 -0
- services/supply_allocation/main.py +46 -0
- services/supply_allocation/routers/__init__.py +1 -0
- services/supply_allocation/routers/allocation.py +20 -0
- services/taxonomy/helpers/__init__.py +7 -0
- services/taxonomy/helpers/classes.py +48 -0
- services/taxonomy/helpers/family.py +53 -0
- services/taxonomy/helpers/subclass.py +58 -0
- services/taxonomy/main.py +48 -0
- services/taxonomy/models/__init__.py +7 -0
- services/taxonomy/models/classes.py +52 -0
- services/taxonomy/models/family.py +60 -0
- services/taxonomy/models/subclass.py +50 -0
- services/taxonomy/routers/__init__.py +7 -0
- services/taxonomy/routers/classes.py +78 -0
- services/taxonomy/routers/family.py +77 -0
- services/taxonomy/routers/subclass.py +82 -0
- services/warehouse_execution/__init__.py +1 -0
- services/warehouse_execution/main.py +46 -0
- services/warehouse_execution/routers/__init__.py +1 -0
- services/warehouse_execution/routers/execution.py +21 -0
- services/work_order_agent/__init__.py +17 -0
- services/work_order_agent/agent/__init__.py +17 -0
- services/work_order_agent/agent/work_order_agent.py +658 -0
- services/work_order_agent/tracking/__init__.py +101 -0
- services/work_order_agent/tracking/event_system.py +182 -0
- services/work_order_agent/tracking/state_machine.py +163 -0
- services/work_order_agent/tracking/state_machine_integrator.py +295 -0
- services/work_order_agent/tracking/test_phase2_implementation.py +302 -0
- services/work_order_agent/tracking/time_analysis.py +301 -0
- services/work_order_agent/tracking/tracked_work_order.py +255 -0
- services/work_order_agent/tracking/work_order_adapter.py +367 -0
- services/work_order_agent/tracking/work_order_batch_manager.py +406 -0
- services/work_order_agent/tracking/work_order_repository.py +431 -0
- services/workorders/helpers/__init__.py +5 -0
- services/workorders/helpers/area_room_usage_ledger.py +139 -0
- services/workorders/helpers/batch_execution_records.py +265 -0
- services/workorders/helpers/batch_release_workflows.py +158 -0
- services/workorders/helpers/batch_step_executions.py +145 -0
- services/workorders/helpers/equipment_usage_ledger.py +209 -0
- services/workorders/helpers/executed_bmr_records.py +170 -0
- services/workorders/helpers/executed_bpr_records.py +170 -0
- services/workorders/helpers/executed_instruction_evidence.py +155 -0
- services/workorders/helpers/ipc_result_records.py +134 -0
- services/workorders/helpers/production_batches.py +117 -0
- services/workorders/helpers/work_orders.py +367 -0
- services/workorders/helpers/yield_reconciliation_records.py +158 -0
- services/workorders/main.py +110 -0
- services/workorders/models/__init__.py +5 -0
- services/workorders/models/area_room_usage_ledger.py +154 -0
- services/workorders/models/batch_execution_records.py +575 -0
- services/workorders/models/batch_release_workflows.py +190 -0
- services/workorders/models/batch_step_executions.py +142 -0
- services/workorders/models/equipment_usage_ledger.py +144 -0
- services/workorders/models/executed_bmr_records.py +220 -0
- services/workorders/models/executed_bpr_records.py +220 -0
- services/workorders/models/executed_instruction_evidence.py +128 -0
- services/workorders/models/ipc_result_records.py +164 -0
- services/workorders/models/production_batches.py +181 -0
- services/workorders/models/work_orders.py +255 -0
- services/workorders/models/yield_reconciliation_records.py +175 -0
- services/workorders/routers/__init__.py +5 -0
- services/workorders/routers/area_room_usage_ledger.py +117 -0
- services/workorders/routers/batch_execution_records.py +103 -0
- services/workorders/routers/batch_release_workflows.py +86 -0
- services/workorders/routers/batch_step_executions.py +88 -0
- services/workorders/routers/equipment_usage_ledger.py +115 -0
- services/workorders/routers/executed_bmr_records.py +86 -0
- services/workorders/routers/executed_bpr_records.py +86 -0
- services/workorders/routers/executed_instruction_evidence.py +86 -0
- services/workorders/routers/ipc_result_records.py +86 -0
- services/workorders/routers/production_batches.py +86 -0
- services/workorders/routers/work_orders.py +257 -0
- services/workorders/routers/yield_reconciliation_records.py +86 -0
- src/broca/__init__.py +5 -0
- src/broca/agent.py +201 -0
- src/cerebellum/__init__.py +0 -0
- src/cerebellum/adapter.py +84 -0
- src/cerebellum/capabilities/__init__.py +0 -0
- src/cerebellum/capabilities/agent/__init__.py +0 -0
- src/cerebellum/capabilities/agent/agents.py +65 -0
- src/cerebellum/capabilities/ai/__init__.py +0 -0
- src/cerebellum/capabilities/ai/providers.py +106 -0
- src/cerebellum/capabilities/api/__init__.py +0 -0
- src/cerebellum/capabilities/api/graphql.py +35 -0
- src/cerebellum/capabilities/api/rest_api.py +45 -0
- src/cerebellum/capabilities/api/webhook.py +30 -0
- src/cerebellum/capabilities/browser/__init__.py +0 -0
- src/cerebellum/capabilities/browser/browsers.py +27 -0
- src/cerebellum/capabilities/cloud/__init__.py +0 -0
- src/cerebellum/capabilities/cloud/cloud.py +46 -0
- src/cerebellum/capabilities/communication/__init__.py +0 -0
- src/cerebellum/capabilities/communication/communication.py +62 -0
- src/cerebellum/capabilities/database/__init__.py +0 -0
- src/cerebellum/capabilities/database/elasticsearch.py +40 -0
- src/cerebellum/capabilities/database/influxdb.py +37 -0
- src/cerebellum/capabilities/database/mongodb.py +50 -0
- src/cerebellum/capabilities/database/neo4j.py +32 -0
- src/cerebellum/capabilities/database/redis.py +44 -0
- src/cerebellum/capabilities/enterprise/__init__.py +0 -0
- src/cerebellum/capabilities/enterprise/opensource.py +180 -0
- src/cerebellum/capabilities/enterprise/proprietary.py +313 -0
- src/cerebellum/capabilities/event_streaming/__init__.py +0 -0
- src/cerebellum/capabilities/event_streaming/streaming.py +38 -0
- src/cerebellum/capabilities/infrastructure/__init__.py +0 -0
- src/cerebellum/capabilities/infrastructure/infrastructure.py +30 -0
- src/cerebellum/capabilities/productivity/__init__.py +0 -0
- src/cerebellum/capabilities/productivity/productivity.py +158 -0
- src/cerebellum/capabilities/robotics/__init__.py +0 -0
- src/cerebellum/capabilities/robotics/robotics.py +124 -0
- src/cerebellum/capabilities/runtime/__init__.py +0 -0
- src/cerebellum/capabilities/runtime/runtimes.py +92 -0
- src/cerebellum/capabilities/search/__init__.py +0 -0
- src/cerebellum/capabilities/search/search.py +63 -0
- src/cerebellum/capabilities/source_control/__init__.py +0 -0
- src/cerebellum/capabilities/source_control/source_control.py +113 -0
- src/cerebellum/capabilities/storage/__init__.py +0 -0
- src/cerebellum/capabilities/storage/storage.py +94 -0
- src/cerebellum/capabilities/workflow/__init__.py +0 -0
- src/cerebellum/capabilities/workflow/workflows.py +49 -0
- src/cerebellum/capability.py +108 -0
- src/cerebellum/config.py +157 -0
- src/cerebellum/fallback.py +147 -0
- src/cerebellum/fallback_engine.py +121 -0
- src/cerebellum/key_manager.py +129 -0
- src/cerebellum/keystore.py +179 -0
- src/cerebellum/lifecycle.py +54 -0
- src/cerebellum/metadata.py +61 -0
- src/cerebellum/operator/base.py +25 -0
- src/cerebellum/peripheral.py +92 -0
- src/cerebellum/registry.py +98 -0
- src/cerebellum/resolve_entity_capability.py +259 -0
- src/cingulate/benchmark/__init__.py +23 -0
- src/cingulate/benchmark/reporter.py +102 -0
- src/cingulate/benchmark/runner.py +159 -0
- src/cingulate/benchmark/scenario_runner.py +150 -0
- src/cingulate/benchmark/validator.py +102 -0
- src/cingulate/governance/__init__.py +21 -0
- src/cingulate/governance/architecture_validator.py +194 -0
- src/cingulate/governance/compliance.py +104 -0
- src/cingulate/governance/governance.py +77 -0
- src/cingulate/governance/policy_registry.py +91 -0
- src/cortex/__init__.py +33 -0
- src/cortex/cost.py +71 -0
- src/cortex/counterfactual.py +162 -0
- src/cortex/digital_twin.py +90 -0
- src/cortex/experience.py +83 -0
- src/cortex/feedback.py +144 -0
- src/cortex/loss.py +116 -0
- src/cortex/prediction.py +142 -0
- src/cortex/replay.py +130 -0
- src/cortex/reward.py +113 -0
- src/cortex/simulator.py +102 -0
- src/cortex/world_model.py +180 -0
- src/cortex/world_model_simulation.py +1591 -0
- src/cortex/world_state.py +121 -0
- src/cortex/xavier.py +250 -0
- src/deepdive/__init__.py +29 -0
- src/deepdive/aggregation.py +113 -0
- src/deepdive/digital_twin_aggregator.py +128 -0
- src/deepdive/elasticsearch_adapter.py +110 -0
- src/deepdive/fleet_analytics.py +131 -0
- src/deepdive/knowledge_aggregator.py +130 -0
- src/homeostasis/__init__.py +19 -0
- src/homeostasis/control_plane.py +159 -0
- src/introspection/__init__.py +38 -0
- src/introspection/alerting.py +142 -0
- src/introspection/health.py +101 -0
- src/introspection/lemon.py +243 -0
- src/introspection/logging.py +147 -0
- src/introspection/metrics.py +106 -0
- src/introspection/tracing.py +162 -0
- src/monkey_brain/__init__.py +1 -0
- src/monkey_brain/api/main.py +148 -0
- src/monkey_brain/api/models.py +81 -0
- src/monkey_brain/api/routes/routes/keys.py +106 -0
- src/monkey_brain/api/routes/routes/run.py +169 -0
- src/monkey_brain/api/routes/routes/simulate.py +485 -0
- src/monkey_brain/dlm/__init__.py +44 -0
- src/monkey_brain/dlm/dlm.py +139 -0
- src/monkey_brain/dlm/gc.py +115 -0
- src/monkey_brain/dlm/lifecycle.py +149 -0
- src/monkey_brain/dlm/orphans.py +99 -0
- src/monkey_brain/dlm/storage.py +149 -0
- src/monkey_brain/dlm/ttl.py +140 -0
- src/monkey_brain/documents/__init__.py +0 -0
- src/monkey_brain/documents/document_ocr.py +6 -0
- src/monkey_brain/kernel/__init__.py +53 -0
- src/monkey_brain/kernel/capability_interface.py +144 -0
- src/monkey_brain/kernel/classifier/__init__.py +1 -0
- src/monkey_brain/kernel/classifier/embed_classifier.py +125 -0
- src/monkey_brain/kernel/classifier/intent_examples.py +106 -0
- src/monkey_brain/kernel/dag.py +23 -0
- src/monkey_brain/kernel/execution_state.py +257 -0
- src/monkey_brain/kernel/goal_planner.py +85 -0
- src/monkey_brain/kernel/goal_router.py +20 -0
- src/monkey_brain/kernel/goals/__init__.py +1 -0
- src/monkey_brain/kernel/goals/goal.py +130 -0
- src/monkey_brain/kernel/goals/goal_bootstrap.py +38 -0
- src/monkey_brain/kernel/goals/goal_classifier.py +132 -0
- src/monkey_brain/kernel/goals/goal_registry.py +75 -0
- src/monkey_brain/kernel/intents/__init__.py +1 -0
- src/monkey_brain/kernel/intents/event_adapter.py +246 -0
- src/monkey_brain/kernel/intents/helpers.py +13 -0
- src/monkey_brain/kernel/intents/intent_registry.py +705 -0
- src/monkey_brain/kernel/intents/intent_router.py +102 -0
- src/monkey_brain/kernel/intents/predicates/approval_create.py +9 -0
- src/monkey_brain/kernel/intents/predicates/approval_decision.py +9 -0
- src/monkey_brain/kernel/intents/predicates/approval_hold.py +9 -0
- src/monkey_brain/kernel/intents/predicates/approval_query.py +9 -0
- src/monkey_brain/kernel/intents/predicates/batch_close.py +9 -0
- src/monkey_brain/kernel/intents/predicates/batch_creation.py +9 -0
- src/monkey_brain/kernel/intents/predicates/batch_delete.py +9 -0
- src/monkey_brain/kernel/intents/predicates/batch_hold.py +9 -0
- src/monkey_brain/kernel/intents/predicates/batch_record.py +9 -0
- src/monkey_brain/kernel/intents/predicates/batch_update.py +9 -0
- src/monkey_brain/kernel/intents/predicates/change_control.py +49 -0
- src/monkey_brain/kernel/intents/predicates/compliance_audit.py +14 -0
- src/monkey_brain/kernel/intents/predicates/decision_intelligence.py +9 -0
- src/monkey_brain/kernel/intents/predicates/drug_research.py +9 -0
- src/monkey_brain/kernel/intents/predicates/fuzzy_match.py +19 -0
- src/monkey_brain/kernel/intents/predicates/production_kpi.py +9 -0
- src/monkey_brain/kernel/intents/predicates/sop_create.py +9 -0
- src/monkey_brain/kernel/intents/predicates/sop_query.py +9 -0
- src/monkey_brain/kernel/intents/predicates/sop_update.py +9 -0
- src/monkey_brain/kernel/intents/predicates/warehouse_shipping.py +9 -0
- src/monkey_brain/kernel/intents/predicates/work_order_create.py +9 -0
- src/monkey_brain/kernel/intents/predicates/work_order_delete.py +9 -0
- src/monkey_brain/kernel/intents/predicates/work_order_hold.py +9 -0
- src/monkey_brain/kernel/intents/predicates/work_order_query.py +9 -0
- src/monkey_brain/kernel/intents/predicates/work_order_status.py +9 -0
- src/monkey_brain/kernel/intents/predicates/work_order_update.py +9 -0
- src/monkey_brain/kernel/intents/predicates/worker.py +9 -0
- src/monkey_brain/kernel/intents/telemetry_adapter.py +274 -0
- src/monkey_brain/kernel/intents/utils.py +68 -0
- src/monkey_brain/kernel/learning.py +98 -0
- src/monkey_brain/kernel/llm_explorer.py +188 -0
- src/monkey_brain/kernel/loss.py +81 -0
- src/monkey_brain/kernel/nlp/__init__.py +1 -0
- src/monkey_brain/kernel/nlp/compat.py +23 -0
- src/monkey_brain/kernel/nlp/models.py +10 -0
- src/monkey_brain/kernel/nlp/question_analyzer.py +203 -0
- src/monkey_brain/kernel/nlp/spacy_parser.py +53 -0
- src/monkey_brain/kernel/observer.py +97 -0
- src/monkey_brain/kernel/parser/__init__.py +3 -0
- src/monkey_brain/kernel/parser/ast.py +28 -0
- src/monkey_brain/kernel/parser/extractors/__init__.py +11 -0
- src/monkey_brain/kernel/parser/extractors/entities.py +21 -0
- src/monkey_brain/kernel/parser/extractors/filters.py +16 -0
- src/monkey_brain/kernel/parser/extractors/projections.py +36 -0
- src/monkey_brain/kernel/parser/extractors/verbs.py +31 -0
- src/monkey_brain/kernel/parser/parser.py +57 -0
- src/monkey_brain/kernel/parser/rules.py +75 -0
- src/monkey_brain/kernel/pipeline.py +44 -0
- src/monkey_brain/kernel/planner.py +57 -0
- src/monkey_brain/kernel/rl/__init__.py +33 -0
- src/monkey_brain/kernel/rl/learner.py +98 -0
- src/monkey_brain/kernel/rl/policy.py +254 -0
- src/monkey_brain/kernel/rl/reward.py +117 -0
- src/monkey_brain/kernel/rl/transition.py +112 -0
- src/monkey_brain/persistence/__init__.py +47 -0
- src/monkey_brain/persistence/adapters.py +49 -0
- src/monkey_brain/persistence/events.py +105 -0
- src/monkey_brain/persistence/manager.py +124 -0
- src/monkey_brain/persistence/mongodb_adapter.py +91 -0
- src/monkey_brain/persistence/redis_adapter.py +93 -0
- src/monkey_brain/persistence/reducer.py +111 -0
- src/monkey_brain/runtime/__init__.py +49 -0
- src/monkey_brain/runtime/depedencies.py +8 -0
- src/monkey_brain/runtime/engine.py +183 -0
- src/monkey_brain/runtime/message_bus.py +82 -0
- src/monkey_brain/runtime/process.py +144 -0
- src/monkey_brain/runtime/resource_manager.py +100 -0
- src/monkey_brain/runtime/routers.py +8 -0
- src/monkey_brain/runtime/runtime.py +199 -0
- src/monkey_brain/runtime/scheduler.py +165 -0
- src/monkey_brain/runtime/supervisor.py +133 -0
- src/monkey_brain/runtime/worker_pool.py +111 -0
- src/plasticity/seed/__init__.py +30 -0
- src/plasticity/seed/benchmark_generator.py +105 -0
- src/plasticity/seed/event_generator.py +122 -0
- src/plasticity/seed/scenario_builder.py +134 -0
- src/plasticity/seed/seed_data.py +206 -0
- src/plasticity/seed/seeder.py +122 -0
- src/plasticity/testing/__init__.py +28 -0
- src/plasticity/testing/performance.py +131 -0
- src/plasticity/testing/profiler.py +255 -0
- src/plasticity/testing/reporter.py +84 -0
- src/plasticity/testing/runner.py +209 -0
- src/sync/__init__.py +12 -0
- src/sync/cloud_aggregator.py +63 -0
- src/sync/edge_node.py +51 -0
- src/sync/sync_manager.py +74 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""Workflow Capabilities — workflow engine integrations."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
from src.cerebellum.capability import Capability
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class N8nCapability(Capability):
|
|
10
|
+
def __init__(self, webhook_url: str = ""):
|
|
11
|
+
super().__init__(name='n8n')
|
|
12
|
+
self._webhook_url = webhook_url
|
|
13
|
+
async def execute(self, state, **kwargs):
|
|
14
|
+
import httpx
|
|
15
|
+
async with httpx.AsyncClient() as client:
|
|
16
|
+
response = await client.post(self._webhook_url, json=state)
|
|
17
|
+
return response.json()
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class TemporalCapability(Capability):
|
|
21
|
+
def __init__(self, server_url: str = ""):
|
|
22
|
+
super().__init__(name='temporal')
|
|
23
|
+
self._server_url = server_url
|
|
24
|
+
async def execute(self, state, **kwargs):
|
|
25
|
+
return {"status": "configured", "workflow": "temporal"}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class AirflowCapability(Capability):
|
|
29
|
+
def __init__(self, api_url: str = "", username: str = "", password: str = ""):
|
|
30
|
+
super().__init__(name='airflow')
|
|
31
|
+
self._api_url = api_url
|
|
32
|
+
async def execute(self, state, **kwargs):
|
|
33
|
+
return {"status": "configured", "workflow": "airflow"}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class PrefectCapability(Capability):
|
|
37
|
+
def __init__(self, api_url: str = ""):
|
|
38
|
+
super().__init__(name='prefect')
|
|
39
|
+
self._api_url = api_url
|
|
40
|
+
async def execute(self, state, **kwargs):
|
|
41
|
+
return {"status": "configured", "workflow": "prefect"}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class ArgoCapability(Capability):
|
|
45
|
+
def __init__(self, server_url: str = ""):
|
|
46
|
+
super().__init__(name='argo')
|
|
47
|
+
self._server_url = server_url
|
|
48
|
+
async def execute(self, state, **kwargs):
|
|
49
|
+
return {"status": "configured", "workflow": "argo"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"""Capability — a unit of work that transforms execution state.
|
|
2
|
+
|
|
3
|
+
Capabilities are the execution primitives.
|
|
4
|
+
The Runtime executes capabilities.
|
|
5
|
+
The Policy selects capabilities.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from dataclasses import dataclass, field
|
|
11
|
+
from typing import Any
|
|
12
|
+
from uuid import uuid4
|
|
13
|
+
|
|
14
|
+
from src.cerebellum.peripheral import Peripheral
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@dataclass
|
|
18
|
+
class CapabilityManifest:
|
|
19
|
+
"""Capability metadata for registry."""
|
|
20
|
+
|
|
21
|
+
capability_id: str = ""
|
|
22
|
+
name: str = ""
|
|
23
|
+
version: str = "1.0.0"
|
|
24
|
+
description: str = ""
|
|
25
|
+
author: str = ""
|
|
26
|
+
peripheral_type: str | None = None
|
|
27
|
+
inputs: list[dict[str, Any]] = field(default_factory=list)
|
|
28
|
+
outputs: list[dict[str, Any]] = field(default_factory=list)
|
|
29
|
+
dependencies: list[str] = field(default_factory=list)
|
|
30
|
+
tags: list[str] = field(default_factory=list)
|
|
31
|
+
checksum: str = ""
|
|
32
|
+
published_at: str = ""
|
|
33
|
+
metadata: dict[str, Any] = field(default_factory=dict)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class Capability:
|
|
37
|
+
"""A unit of work that transforms execution state.
|
|
38
|
+
|
|
39
|
+
Responsibilities:
|
|
40
|
+
- Execute a specific operation
|
|
41
|
+
- Read from/write to peripherals
|
|
42
|
+
- Return structured results
|
|
43
|
+
|
|
44
|
+
The Capability never:
|
|
45
|
+
- Makes execution decisions
|
|
46
|
+
- Selects other capabilities
|
|
47
|
+
- Manages threads
|
|
48
|
+
- Owns execution policy
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
def __init__(
|
|
52
|
+
self,
|
|
53
|
+
name: str,
|
|
54
|
+
peripheral: Peripheral | None = None,
|
|
55
|
+
config: dict[str, Any] | None = None,
|
|
56
|
+
):
|
|
57
|
+
self.name = name
|
|
58
|
+
self.peripheral = peripheral
|
|
59
|
+
self.config = config or {}
|
|
60
|
+
self._id = f"cap-{uuid4().hex[:8]}"
|
|
61
|
+
|
|
62
|
+
@property
|
|
63
|
+
def id(self) -> str:
|
|
64
|
+
return self._id
|
|
65
|
+
|
|
66
|
+
async def execute(
|
|
67
|
+
self,
|
|
68
|
+
state: dict[str, Any],
|
|
69
|
+
context: Any = None,
|
|
70
|
+
) -> dict[str, Any]:
|
|
71
|
+
"""Execute the capability.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
state: Current execution state (read-only)
|
|
75
|
+
context: Runtime context (memory, stream)
|
|
76
|
+
|
|
77
|
+
Returns:
|
|
78
|
+
Result dict with capability output
|
|
79
|
+
"""
|
|
80
|
+
raise NotImplementedError(f"Capability '{self.name}' must implement execute()")
|
|
81
|
+
|
|
82
|
+
def can_execute(self, state: dict[str, Any]) -> bool:
|
|
83
|
+
"""Check if capability can execute."""
|
|
84
|
+
return True
|
|
85
|
+
|
|
86
|
+
def estimate_cost(self, state: dict[str, Any]) -> float:
|
|
87
|
+
"""Estimate execution cost."""
|
|
88
|
+
return 1.0
|
|
89
|
+
|
|
90
|
+
def estimate_reward(self, state: dict[str, Any]) -> float:
|
|
91
|
+
"""Estimate expected reward."""
|
|
92
|
+
return 0.5
|
|
93
|
+
|
|
94
|
+
def manifest(self) -> CapabilityManifest:
|
|
95
|
+
"""Generate manifest for registry."""
|
|
96
|
+
return CapabilityManifest(
|
|
97
|
+
capability_id=self._id,
|
|
98
|
+
name=self.name,
|
|
99
|
+
description=f"Capability: {self.name}",
|
|
100
|
+
peripheral_type=self.peripheral.type.value if self.peripheral else None,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
def to_dict(self) -> dict[str, Any]:
|
|
104
|
+
return {
|
|
105
|
+
"id": self._id,
|
|
106
|
+
"name": self.name,
|
|
107
|
+
"peripheral": self.peripheral.name if self.peripheral else None,
|
|
108
|
+
}
|
src/cerebellum/config.py
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"""Capability Configuration — API keys and settings for all capabilities.
|
|
2
|
+
|
|
3
|
+
Centralizes configuration for all capabilities.
|
|
4
|
+
Supports environment variables, config files, and runtime configuration.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
from dataclasses import dataclass, field
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass
|
|
15
|
+
class CapabilityConfig:
|
|
16
|
+
"""Configuration for a single capability."""
|
|
17
|
+
|
|
18
|
+
name: str
|
|
19
|
+
enabled: bool = True
|
|
20
|
+
api_key: str = ""
|
|
21
|
+
api_url: str = ""
|
|
22
|
+
timeout_ms: int = 5000
|
|
23
|
+
max_retries: int = 3
|
|
24
|
+
metadata: dict[str, Any] = field(default_factory=dict)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ConfigManager:
|
|
28
|
+
"""Manages configuration for all capabilities.
|
|
29
|
+
|
|
30
|
+
Supports:
|
|
31
|
+
- Environment variables
|
|
32
|
+
- Config file
|
|
33
|
+
- Runtime configuration
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
def __init__(self):
|
|
37
|
+
self._configs: dict[str, CapabilityConfig] = {}
|
|
38
|
+
self._env_prefix = "AGENTOS_"
|
|
39
|
+
|
|
40
|
+
def load_from_env(self) -> None:
|
|
41
|
+
"""Load configuration from environment variables."""
|
|
42
|
+
# API Keys
|
|
43
|
+
self._configs["openai"] = CapabilityConfig(
|
|
44
|
+
name="openai",
|
|
45
|
+
api_key=os.getenv("OPENAI_API_KEY", ""),
|
|
46
|
+
api_url=os.getenv("OPENAI_API_URL", "https://api.openai.com/v1"),
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
self._configs["anthropic"] = CapabilityConfig(
|
|
50
|
+
name="anthropic",
|
|
51
|
+
api_key=os.getenv("ANTHROPIC_API_KEY", ""),
|
|
52
|
+
api_url=os.getenv("ANTHROPIC_API_URL", "https://api.anthropic.com/v1"),
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
self._configs["openrouter"] = CapabilityConfig(
|
|
56
|
+
name="openrouter",
|
|
57
|
+
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
|
58
|
+
api_url=os.getenv("OPENROUTER_API_URL", "https://openrouter.ai/api/v1"),
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
self._configs["ollama"] = CapabilityConfig(
|
|
62
|
+
name="ollama",
|
|
63
|
+
api_url=os.getenv("OLLAMA_API_URL", "http://localhost:11434"),
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
self._configs["gemini"] = CapabilityConfig(
|
|
67
|
+
name="gemini",
|
|
68
|
+
api_key=os.getenv("GOOGLE_API_KEY", ""),
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
self._configs["azure_openai"] = CapabilityConfig(
|
|
72
|
+
name="azure_openai",
|
|
73
|
+
api_key=os.getenv("AZURE_OPENAI_API_KEY", ""),
|
|
74
|
+
api_url=os.getenv("AZURE_OPENAI_ENDPOINT", ""),
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
self._configs["aws_bedrock"] = CapabilityConfig(
|
|
78
|
+
name="aws_bedrock",
|
|
79
|
+
api_key=os.getenv("AWS_ACCESS_KEY_ID", ""),
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
# Databases
|
|
83
|
+
self._configs["mongodb"] = CapabilityConfig(
|
|
84
|
+
name="mongodb",
|
|
85
|
+
api_url=os.getenv("MONGODB_URL", "mongodb://localhost:27017"),
|
|
86
|
+
metadata={"database": os.getenv("DB_NAME", "agentos")},
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
self._configs["redis"] = CapabilityConfig(
|
|
90
|
+
name="redis",
|
|
91
|
+
api_url=os.getenv("REDIS_URL", "redis://localhost:6379"),
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
self._configs["neo4j"] = CapabilityConfig(
|
|
95
|
+
name="neo4j",
|
|
96
|
+
api_url=os.getenv("NEO4J_URI", "bolt://localhost:7687"),
|
|
97
|
+
api_key=os.getenv("NEO4J_PASSWORD", ""),
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
self._configs["influxdb"] = CapabilityConfig(
|
|
101
|
+
name="influxdb",
|
|
102
|
+
api_key=os.getenv("INFLUXDB_TOKEN", ""),
|
|
103
|
+
api_url=os.getenv("INFLUXDB_URL", "http://localhost:8086"),
|
|
104
|
+
metadata={"org": os.getenv("INFLUXDB_ORG", "agentos")},
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
self._configs["elasticsearch"] = CapabilityConfig(
|
|
108
|
+
name="elasticsearch",
|
|
109
|
+
api_url=os.getenv("ELASTICSEARCH_URL", "http://localhost:9200"),
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
# Communication
|
|
113
|
+
self._configs["slack"] = CapabilityConfig(
|
|
114
|
+
name="slack",
|
|
115
|
+
api_key=os.getenv("SLACK_WEBHOOK_URL", ""),
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
self._configs["email"] = CapabilityConfig(
|
|
119
|
+
name="email",
|
|
120
|
+
api_key=os.getenv("SMTP_PASSWORD", ""),
|
|
121
|
+
api_url=os.getenv("SMTP_HOST", "smtp.gmail.com"),
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
# Cloud
|
|
125
|
+
self._configs["aws"] = CapabilityConfig(
|
|
126
|
+
name="aws",
|
|
127
|
+
api_key=os.getenv("AWS_ACCESS_KEY_ID", ""),
|
|
128
|
+
metadata={"region": os.getenv("AWS_REGION", "us-east-1")},
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
self._configs["azure"] = CapabilityConfig(
|
|
132
|
+
name="azure",
|
|
133
|
+
api_key=os.getenv("AZURE_SUBSCRIPTION_ID", ""),
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
self._configs["google_cloud"] = CapabilityConfig(
|
|
137
|
+
name="google_cloud",
|
|
138
|
+
api_key=os.getenv("GOOGLE_CLOUD_PROJECT", ""),
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
def get(self, capability_name: str) -> CapabilityConfig | None:
|
|
142
|
+
"""Get configuration for a capability."""
|
|
143
|
+
return self._configs.get(capability_name)
|
|
144
|
+
|
|
145
|
+
def set(self, capability_name: str, config: CapabilityConfig) -> None:
|
|
146
|
+
"""Set configuration for a capability."""
|
|
147
|
+
self._configs[capability_name] = config
|
|
148
|
+
|
|
149
|
+
def get_all(self) -> dict[str, CapabilityConfig]:
|
|
150
|
+
return dict(self._configs)
|
|
151
|
+
|
|
152
|
+
def summary(self) -> dict:
|
|
153
|
+
return {
|
|
154
|
+
"total_configs": len(self._configs),
|
|
155
|
+
"configured": [name for name, config in self._configs.items() if config.api_key or config.api_url],
|
|
156
|
+
"not_configured": [name for name, config in self._configs.items() if not config.api_key and not config.api_url],
|
|
157
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"""Fallback Capabilities — document search and web search for retry.
|
|
2
|
+
|
|
3
|
+
When an answer fails:
|
|
4
|
+
1. Use document search to find relevant information
|
|
5
|
+
2. Use web search to find external information
|
|
6
|
+
3. Replan execution based on gathered information
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from dataclasses import dataclass, field
|
|
12
|
+
from typing import Any
|
|
13
|
+
from uuid import uuid4
|
|
14
|
+
|
|
15
|
+
from src.cerebellum.capability import Capability
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class DocumentSearchCapability(Capability):
|
|
19
|
+
"""Search internal documents for relevant information."""
|
|
20
|
+
|
|
21
|
+
def __init__(self):
|
|
22
|
+
super().__init__(name='document_search')
|
|
23
|
+
self._documents = {
|
|
24
|
+
'batch': [
|
|
25
|
+
{'id': 'DOC-001', 'title': 'Batch Record Procedure', 'content': 'Batch records track production from raw materials to finished goods.'},
|
|
26
|
+
{'id': 'DOC-002', 'title': 'Batch Release SOP', 'content': 'Batch release requires quality approval and documentation review.'},
|
|
27
|
+
],
|
|
28
|
+
'plant': [
|
|
29
|
+
{'id': 'DOC-010', 'title': 'Plant Operations Manual', 'content': 'Plants contain production lines, stages, and workstations.'},
|
|
30
|
+
],
|
|
31
|
+
'worker': [
|
|
32
|
+
{'id': 'DOC-020', 'title': 'Worker Assignment Guide', 'content': 'Workers are assigned to shifts and workstations.'},
|
|
33
|
+
],
|
|
34
|
+
'maintenance': [
|
|
35
|
+
{'id': 'DOC-030', 'title': 'Maintenance Procedures', 'content': 'Maintenance includes preventive and corrective activities.'},
|
|
36
|
+
{'id': 'DOC-031', 'title': 'Calibration Schedule', 'content': 'Calibration is required quarterly for all measurement equipment.'},
|
|
37
|
+
],
|
|
38
|
+
'sop': [
|
|
39
|
+
{'id': 'DOC-040', 'title': 'SOP Management', 'content': 'SOPs define standard operating procedures for all processes.'},
|
|
40
|
+
],
|
|
41
|
+
'approval': [
|
|
42
|
+
{'id': 'DOC-050', 'title': 'Approval Workflow', 'content': 'Approvals follow a hierarchical review process.'},
|
|
43
|
+
],
|
|
44
|
+
'line': [
|
|
45
|
+
{'id': 'DOC-060', 'title': 'Production Line Guide', 'content': 'Production lines contain stages and workstations.'},
|
|
46
|
+
],
|
|
47
|
+
'stage': [
|
|
48
|
+
{'id': 'DOC-070', 'title': 'Process Stages', 'content': 'Stages include dispensing, granulation, compression, coating.'},
|
|
49
|
+
],
|
|
50
|
+
'workstation': [
|
|
51
|
+
{'id': 'DOC-080', 'title': 'Workstation Configuration', 'content': 'Workstations contain machines and equipment.'},
|
|
52
|
+
],
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async def execute(self, state, **kwargs):
|
|
56
|
+
entities = state.get('entities', {})
|
|
57
|
+
query = state.get('question', '').lower()
|
|
58
|
+
|
|
59
|
+
found_docs = []
|
|
60
|
+
for etype in entities:
|
|
61
|
+
docs = self._documents.get(etype, [])
|
|
62
|
+
for doc in docs:
|
|
63
|
+
if any(word in doc['content'].lower() for word in query.split()):
|
|
64
|
+
found_docs.append(doc)
|
|
65
|
+
|
|
66
|
+
# If no entity-based docs, search all
|
|
67
|
+
if not found_docs:
|
|
68
|
+
for etype, docs in self._documents.items():
|
|
69
|
+
for doc in docs:
|
|
70
|
+
if any(word in doc['content'].lower() for word in query.split()):
|
|
71
|
+
found_docs.append(doc)
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
'documents': found_docs[:5],
|
|
75
|
+
'count': len(found_docs),
|
|
76
|
+
'phase': 'document_search',
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class WebSearchCapability(Capability):
|
|
81
|
+
"""Search the web for external information."""
|
|
82
|
+
|
|
83
|
+
def __init__(self):
|
|
84
|
+
super().__init__(name='web_search')
|
|
85
|
+
self._web_results = {
|
|
86
|
+
'batch': [
|
|
87
|
+
{'title': 'GMP Batch Record Requirements', 'url': 'https://example.com/gmp-batch', 'snippet': 'FDA 21 CFR Part 211 requires complete batch records for pharmaceutical manufacturing.'},
|
|
88
|
+
],
|
|
89
|
+
'maintenance': [
|
|
90
|
+
{'title': 'Preventive Maintenance Best Practices', 'url': 'https://example.com/pm-best', 'snippet': 'Preventive maintenance reduces downtime by 25-30%.'},
|
|
91
|
+
],
|
|
92
|
+
'quality': [
|
|
93
|
+
{'title': 'Quality Management Systems', 'url': 'https://example.com/qms', 'snippet': 'ISO 9001 quality management standards.'},
|
|
94
|
+
],
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async def execute(self, state, **kwargs):
|
|
98
|
+
query = state.get('question', '').lower()
|
|
99
|
+
entities = state.get('entities', {})
|
|
100
|
+
|
|
101
|
+
results = []
|
|
102
|
+
for etype in entities:
|
|
103
|
+
web = self._web_results.get(etype, [])
|
|
104
|
+
results.extend(web)
|
|
105
|
+
|
|
106
|
+
# Fallback: search all
|
|
107
|
+
if not results:
|
|
108
|
+
for web in self._web_results.values():
|
|
109
|
+
results.extend(web)
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
'web_results': results[:5],
|
|
113
|
+
'count': len(results),
|
|
114
|
+
'phase': 'web_search',
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class ReplannerCapability(Capability):
|
|
119
|
+
"""Replan execution based on gathered information."""
|
|
120
|
+
|
|
121
|
+
def __init__(self):
|
|
122
|
+
super().__init__(name='replan')
|
|
123
|
+
|
|
124
|
+
async def execute(self, state, **kwargs):
|
|
125
|
+
docs = state.get('documents', [])
|
|
126
|
+
web_results = state.get('web_results', [])
|
|
127
|
+
original_answer = state.get('current_answer', '')
|
|
128
|
+
question = state.get('question', '')
|
|
129
|
+
|
|
130
|
+
# Aggregate information
|
|
131
|
+
aggregated_info = []
|
|
132
|
+
for doc in docs:
|
|
133
|
+
aggregated_info.append(f"Document: {doc.get('title', '')} - {doc.get('content', '')}")
|
|
134
|
+
for web in web_results:
|
|
135
|
+
aggregated_info.append(f"Web: {web.get('title', '')} - {web.get('snippet', '')}")
|
|
136
|
+
|
|
137
|
+
# Build enhanced answer
|
|
138
|
+
if aggregated_info:
|
|
139
|
+
enhanced_answer = f"Based on available information:\n" + '\n'.join(f"• {info}" for info in aggregated_info[:5])
|
|
140
|
+
else:
|
|
141
|
+
enhanced_answer = f"I found some relevant information about your question regarding: {question}"
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
'enhanced_answer': enhanced_answer,
|
|
145
|
+
'aggregated_info': aggregated_info,
|
|
146
|
+
'phase': 'replan',
|
|
147
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"""Fallback Engine — handles failed answers with document/web search and replanning.
|
|
2
|
+
|
|
3
|
+
When an answer fails:
|
|
4
|
+
1. Use document search to find relevant information
|
|
5
|
+
2. Use web search to find external information
|
|
6
|
+
3. Replan execution based on gathered information
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from dataclasses import dataclass, field
|
|
12
|
+
from typing import Any
|
|
13
|
+
from uuid import uuid4
|
|
14
|
+
|
|
15
|
+
from src.cerebellum.fallback import DocumentSearchCapability, WebSearchCapability, ReplannerCapability
|
|
16
|
+
from src.monkey_brain.kernel.pipeline import Pipeline, PipelineStep
|
|
17
|
+
from src.monkey_brain.kernel.execution_state import ExecutionState
|
|
18
|
+
from src.monkey_brain.runtime.runtime import Runtime
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass
|
|
22
|
+
class FallbackResult:
|
|
23
|
+
"""Result of a fallback execution."""
|
|
24
|
+
|
|
25
|
+
fallback_id: str = field(default_factory=lambda: f"fb-{uuid4().hex[:8]}")
|
|
26
|
+
original_answer: str = ""
|
|
27
|
+
enhanced_answer: str = ""
|
|
28
|
+
documents_found: int = 0
|
|
29
|
+
web_results_found: int = 0
|
|
30
|
+
replanned: bool = False
|
|
31
|
+
success: bool = False
|
|
32
|
+
latency_ms: float = 0.0
|
|
33
|
+
metadata: dict[str, Any] = field(default_factory=dict)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class FallbackEngine:
|
|
37
|
+
"""Handles failed answers with document/web search and replanning.
|
|
38
|
+
|
|
39
|
+
When an answer fails:
|
|
40
|
+
1. Use document search to find relevant information
|
|
41
|
+
2. Use web search to find external information
|
|
42
|
+
3. Replan execution based on gathered information
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
def __init__(self, runtime: Runtime):
|
|
46
|
+
self._runtime = runtime
|
|
47
|
+
self._doc_search = DocumentSearchCapability()
|
|
48
|
+
self._web_search = WebSearchCapability()
|
|
49
|
+
self._replanner = ReplannerCapability()
|
|
50
|
+
self._fallback_count = 0
|
|
51
|
+
|
|
52
|
+
async def execute_fallback(
|
|
53
|
+
self,
|
|
54
|
+
question: str,
|
|
55
|
+
original_answer: str,
|
|
56
|
+
state: dict[str, Any] | None = None,
|
|
57
|
+
) -> FallbackResult:
|
|
58
|
+
"""Execute fallback when original answer fails."""
|
|
59
|
+
import time
|
|
60
|
+
start = time.monotonic()
|
|
61
|
+
|
|
62
|
+
result = FallbackResult(
|
|
63
|
+
original_answer=original_answer,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
current_state = dict(state or {})
|
|
67
|
+
current_state['question'] = question
|
|
68
|
+
current_state['current_answer'] = original_answer
|
|
69
|
+
|
|
70
|
+
# Step 1: Document Search
|
|
71
|
+
doc_pipeline = Pipeline(
|
|
72
|
+
steps=[PipelineStep(capability_name='document_search')]
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
# Register fallback capabilities temporarily
|
|
76
|
+
self._runtime.register(self._doc_search)
|
|
77
|
+
self._runtime.register(self._web_search)
|
|
78
|
+
self._runtime.register(self._replanner)
|
|
79
|
+
|
|
80
|
+
doc_result = await self._runtime.execute(doc_pipeline, ExecutionState(question=question))
|
|
81
|
+
if doc_result.success:
|
|
82
|
+
docs = doc_result.final_state.get('documents', [])
|
|
83
|
+
result.documents_found = len(docs)
|
|
84
|
+
current_state['documents'] = docs
|
|
85
|
+
|
|
86
|
+
# Step 2: Web Search
|
|
87
|
+
web_pipeline = Pipeline(
|
|
88
|
+
steps=[PipelineStep(capability_name='web_search')]
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
web_result = await self._runtime.execute(web_pipeline, ExecutionState(question=question))
|
|
92
|
+
if web_result.success:
|
|
93
|
+
web_results = web_result.final_state.get('web_results', [])
|
|
94
|
+
result.web_results_found = len(web_results)
|
|
95
|
+
current_state['web_results'] = web_results
|
|
96
|
+
|
|
97
|
+
# Step 3: Replan
|
|
98
|
+
if result.documents_found > 0 or result.web_results_found > 0:
|
|
99
|
+
replan_pipeline = Pipeline(
|
|
100
|
+
steps=[PipelineStep(capability_name='replan')]
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
replan_result = await self._runtime.execute(replan_pipeline, ExecutionState(question=question))
|
|
104
|
+
if replan_result.success:
|
|
105
|
+
result.enhanced_answer = replan_result.final_state.get('enhanced_answer', original_answer)
|
|
106
|
+
result.replaned = True
|
|
107
|
+
result.success = True
|
|
108
|
+
else:
|
|
109
|
+
result.enhanced_answer = original_answer
|
|
110
|
+
else:
|
|
111
|
+
result.enhanced_answer = original_answer
|
|
112
|
+
|
|
113
|
+
result.latency_ms = (time.monotonic() - start) * 1000
|
|
114
|
+
self._fallback_count += 1
|
|
115
|
+
|
|
116
|
+
return result
|
|
117
|
+
|
|
118
|
+
def summary(self) -> dict:
|
|
119
|
+
return {
|
|
120
|
+
"fallback_count": self._fallback_count,
|
|
121
|
+
}
|