sophhub 0.4.19 → 0.4.21
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/README.md +199 -187
- package/agents/ai-cs-admin/.config.json +51 -51
- package/agents/ai-cs-admin/AGENTS.md +293 -293
- package/agents/ai-cs-admin/HEARTBEAT.md +18 -18
- package/agents/ai-cs-qa/.config.json +47 -47
- package/agents/ai-cs-qa/BOOTSTRAP.md +22 -22
- package/agents/ai-cs-qa/scripts/setup_links.sh +39 -39
- package/agents/beauty/.config.json +17 -17
- package/agents/beauty/AGENTS.md +234 -234
- package/agents/beauty/BOOTSTRAP.md +55 -55
- package/agents/beauty/HEARTBEAT.md +5 -5
- package/agents/beauty/IDENTITY.md +5 -5
- package/agents/beauty/MEMORY.md +44 -44
- package/agents/beauty/SOUL.md +64 -64
- package/agents/beauty/TOOLS.md +160 -160
- package/agents/beauty/USER.md +114 -114
- package/agents/intern-admin/.config.json +60 -60
- package/agents/intern-admin/AGENTS.md +267 -267
- package/agents/intern-admin/BOOTSTRAP.md +21 -21
- package/agents/intern-admin/HEARTBEAT.md +3 -3
- package/agents/intern-admin/IDENTITY.md +6 -6
- package/agents/intern-admin/MEMORY.md +21 -21
- package/agents/intern-admin/SOUL.md +23 -23
- package/agents/intern-admin/TOOLS.md +93 -93
- package/agents/intern-admin/USER.md +16 -16
- package/agents/intern-admin/scripts/init_workspace.sh +27 -27
- package/agents/intern-qa/.config.json +46 -46
- package/agents/intern-qa/AGENTS.md +303 -303
- package/agents/intern-qa/BOOTSTRAP.md +16 -16
- package/agents/intern-qa/HEARTBEAT.md +3 -3
- package/agents/intern-qa/IDENTITY.md +6 -6
- package/agents/intern-qa/MEMORY.md +22 -22
- package/agents/intern-qa/SOUL.md +24 -24
- package/agents/intern-qa/TOOLS.md +24 -24
- package/agents/intern-qa/USER.md +27 -27
- package/agents/intern-qa/scripts/setup_links.sh +54 -54
- package/agents/parent-toddler/.config.json +37 -37
- package/agents/parent-toddler/AGENTS.md +51 -51
- package/agents/parent-toddler/BOOTSTRAP.md +55 -55
- package/agents/parent-toddler/HEARTBEAT.md +5 -5
- package/agents/parent-toddler/IDENTITY.md +5 -5
- package/agents/parent-toddler/MEMORY.md +22 -22
- package/agents/parent-toddler/SOUL.md +35 -35
- package/agents/parent-toddler/TOOLS.md +31 -31
- package/agents/parent-toddler/USER.md +44 -44
- package/agents/vip-admin/.config.json +51 -51
- package/agents/vip-admin/AGENTS.md +314 -314
- package/agents/vip-admin/BOOTSTRAP.md +21 -21
- package/agents/vip-admin/HEARTBEAT.md +19 -19
- package/agents/vip-admin/IDENTITY.md +6 -6
- package/agents/vip-admin/MEMORY.md +30 -30
- package/agents/vip-admin/SOUL.md +25 -25
- package/agents/vip-admin/TOOLS.md +108 -108
- package/agents/vip-admin/USER.md +31 -31
- package/agents/vip-qa/.config.json +58 -58
- package/agents/vip-qa/AGENTS.md +319 -319
- package/agents/vip-qa/BOOTSTRAP.md +73 -73
- package/agents/vip-qa/HEARTBEAT.md +23 -23
- package/agents/vip-qa/IDENTITY.md +7 -7
- package/agents/vip-qa/MEMORY.md +23 -23
- package/agents/vip-qa/SOUL.md +34 -34
- package/agents/vip-qa/TOOLS.md +41 -41
- package/agents/vip-qa/USER.md +16 -16
- package/agents/vip-qa/scripts/setup_links.sh +39 -39
- package/bin/sophhub.js +25 -25
- package/package.json +35 -33
- package/skills/agent-install/skill.json +34 -34
- package/skills/agent-install/src/SKILL.md +240 -240
- package/skills/agent-install/src/pyproject.toml +6 -6
- package/skills/agent-install/src/scripts/backup_agent.py +120 -120
- package/skills/agent-install/src/scripts/check_installed.py +479 -479
- package/skills/agent-install/src/scripts/common.py +568 -568
- package/skills/agent-install/src/scripts/copy_agent_files.py +59 -59
- package/skills/agent-install/src/scripts/list_agents.py +285 -285
- package/skills/agent-install/src/scripts/resolve_install_params.py +90 -90
- package/skills/agent-install/src/scripts/update_agent_md.py +76 -76
- package/skills/agent-install/src/scripts/update_openclaw.py +193 -193
- package/skills/agent-install/src/scripts/verify_download.py +148 -148
- package/skills/aippt/skill.json +20 -20
- package/skills/aippt/src/SKILL.md +235 -235
- package/skills/aippt/src/pyproject.toml +8 -8
- package/skills/aippt/src/scripts/auth.py +122 -122
- package/skills/aippt/src/scripts/ppt.py +361 -361
- package/skills/aippt/src/scripts/provider_docmee.py +299 -299
- package/skills/beauty-salon-inventory/skill.json +16 -16
- package/skills/beauty-salon-inventory/src/SKILL.md +69 -69
- package/skills/beauty-salon-inventory/src/scripts/init_salon_inventory.py +39 -39
- package/skills/beauty-salon-inventory/src/scripts/init_salon_inventory.sh +4 -4
- package/skills/beauty-salon-inventory/src/scripts/salon_inventory_cli.py +244 -244
- package/skills/beauty-salon-marketing/skill.json +10 -10
- package/skills/beauty-salon-marketing/src/SKILL.md +36 -36
- package/skills/beauty-salon-marketing/src/playbooks/beauty-salon-festival.md +19 -19
- package/skills/beauty-salon-marketing/src/playbooks/beauty-salon-segment.md +18 -18
- package/skills/beauty-salon-marketing/src/scripts/beauty_marketing_cli.py +99 -99
- package/skills/beauty-salon-marketing/src/scripts/member_segment.py +114 -114
- package/skills/beauty-salon-member-appointment/skill.json +10 -10
- package/skills/beauty-salon-member-appointment/src/SKILL.md +36 -36
- package/skills/beauty-salon-member-appointment/src/pyproject.toml +9 -9
- package/skills/beauty-salon-member-appointment/src/scripts/run_e2e_smoke.py +160 -160
- package/skills/beauty-salon-member-appointment/src/src/member_appt_cli/__init__.py +1 -1
- package/skills/beauty-salon-member-appointment/src/src/member_appt_cli/__main__.py +4 -4
- package/skills/beauty-salon-member-appointment/src/src/member_appt_cli/cli.py +921 -921
- package/skills/beauty-salon-member-appointment/src/src/member_appt_cli/db.py +30 -30
- package/skills/beauty-salon-membership/skill.json +20 -20
- package/skills/beauty-salon-membership/src/SKILL.md +67 -67
- package/skills/beauty-salon-product-service/skill.json +12 -12
- package/skills/beauty-salon-product-service/src/SKILL.md +42 -42
- package/skills/beauty-salon-product-service/src/pyproject.toml +9 -9
- package/skills/beauty-salon-product-service/src/src/product_service_cli/__init__.py +1 -1
- package/skills/beauty-salon-product-service/src/src/product_service_cli/__main__.py +4 -4
- package/skills/beauty-salon-product-service/src/src/product_service_cli/cli.py +329 -329
- package/skills/beauty-salon-product-service/src/src/product_service_cli/db.py +29 -29
- package/skills/beauty-salon-staff/skill.json +10 -10
- package/skills/beauty-salon-staff/src/SKILL.md +37 -37
- package/skills/beauty-salon-staff/src/pyproject.toml +9 -9
- package/skills/beauty-salon-staff/src/src/staff_cli/__init__.py +1 -1
- package/skills/beauty-salon-staff/src/src/staff_cli/__main__.py +4 -4
- package/skills/beauty-salon-staff/src/src/staff_cli/cli.py +479 -479
- package/skills/beauty-salon-staff/src/src/staff_cli/db.py +28 -28
- package/skills/beauty-salon-suite/skill.json +13 -13
- package/skills/beauty-salon-suite/src/SKILL.md +18 -18
- package/skills/beauty-salon-suite/src/beauty_db/__init__.py +2 -2
- package/skills/beauty-salon-suite/src/beauty_db/db.py +249 -249
- package/skills/beauty-salon-traffic/skill.json +20 -20
- package/skills/beauty-salon-traffic/src/SKILL.md +84 -84
- package/skills/bing-image-search/skill.json +20 -20
- package/skills/bing-image-search/src/SKILL.md +105 -105
- package/skills/bot-api-status/skill.json +44 -44
- package/skills/bot-api-status/src/SKILL.md +99 -99
- package/skills/bot-api-status/src/pyproject.toml +5 -5
- package/skills/bot-api-status/src/scripts/secret.py +496 -496
- package/skills/bot-secret/skill.json +35 -35
- package/skills/bot-secret/src/SKILL.md +51 -51
- package/skills/bot-secret/src/pyproject.toml +5 -5
- package/skills/bot-secret/src/scripts/secret.py +120 -120
- package/skills/cake-flower-holiday-campaign/skill.json +20 -20
- package/skills/cake-flower-holiday-campaign/src/SKILL.md +68 -68
- package/skills/cake-flower-order-sop/skill.json +20 -20
- package/skills/cake-flower-order-sop/src/SKILL.md +65 -65
- package/skills/claw-agent-get-send/skill.json +32 -32
- package/skills/claw-agent-get-send/src/SKILL.md +43 -43
- package/skills/claw-agent-get-send/src/pyproject.toml +5 -5
- package/skills/claw-agent-get-send/src/scripts/appia_claw.py +379 -379
- package/skills/compact-context/skill.json +20 -20
- package/skills/compact-context/src/SKILL.md +133 -133
- package/skills/compact-context/src/scripts/check.sh +381 -381
- package/skills/compact-context/src/scripts/set-keep-recent.mjs +1337 -1337
- package/skills/compact-context/src/scripts/setup.sh +96 -96
- package/skills/consensus/skill.json +20 -20
- package/skills/consensus/src/SKILL.md +93 -93
- package/skills/deepwiki/skill.json +20 -20
- package/skills/deepwiki/src/SKILL.md +45 -45
- package/skills/deepwiki/src/_meta.json +5 -5
- package/skills/deepwiki/src/scripts/deepwiki.js +135 -135
- package/skills/didi-ride/skill.json +20 -20
- package/skills/didi-ride/src/SKILL.md +309 -309
- package/skills/didi-ride/src/_meta.json +5 -5
- package/skills/didi-ride/src/assets/PREFERENCE.md +58 -58
- package/skills/didi-ride/src/package.json +15 -15
- package/skills/didi-ride/src/references/api_references.md +171 -171
- package/skills/didi-ride/src/references/error_handling.md +68 -68
- package/skills/didi-ride/src/references/setup.md +73 -73
- package/skills/didi-ride/src/references/workflow.md +150 -150
- package/skills/feishu-bitable/skill.json +20 -20
- package/skills/feishu-bitable/src/CHECKLIST.md +149 -149
- package/skills/feishu-bitable/src/README.md +177 -177
- package/skills/feishu-bitable/src/SKILL.md +113 -113
- package/skills/feishu-bitable/src/_meta.json +5 -5
- package/skills/feishu-bitable/src/api.js +380 -380
- package/skills/feishu-bitable/src/bin/cli.js +283 -283
- package/skills/feishu-bitable/src/description.md +142 -142
- package/skills/feishu-bitable/src/examples/create-records.json +51 -51
- package/skills/feishu-bitable/src/examples/create-table.json +63 -63
- package/skills/feishu-bitable/src/package-lock.json +324 -324
- package/skills/feishu-bitable/src/package.json +32 -32
- package/skills/feishu-bitable/src/publish-config.json +13 -13
- package/skills/feishu-bitable/src/test-simple.js +60 -60
- package/skills/feishu-bitable/src/utils.js +260 -260
- package/skills/feishu-notes-assistant-universal/skill.json +20 -20
- package/skills/feishu-notes-assistant-universal/src/README.md +55 -55
- package/skills/feishu-notes-assistant-universal/src/SKILL.md +159 -159
- package/skills/feishu-notes-assistant-universal/src/scripts/_resolve_lark_cli.py +58 -58
- package/skills/feishu-notes-assistant-universal/src/scripts/openclaw_meeting_minutes.py +462 -462
- package/skills/feishu-notes-assistant-universal/src/scripts/openclaw_notes_crud.py +547 -547
- package/skills/feishu-notes-assistant-universal/src/scripts/openclaw_notes_crud_test.py +181 -181
- package/skills/feishu-notes-assistant-universal/src/scripts/run_meeting_minutes.py +80 -80
- package/skills/feishu-notes-assistant-universal/src/scripts/run_meeting_minutes.sh +5 -5
- package/skills/feishu-notes-assistant-universal/src/scripts/run_note_crud.py +32 -32
- package/skills/feishu-notes-assistant-universal/src/scripts/run_note_crud.sh +5 -5
- package/skills/flight-booking/skill.json +36 -36
- package/skills/flight-booking/src/SKILL.md +288 -288
- package/skills/flight-booking/src/scripts/flight_booking.py +1237 -1237
- package/skills/flyai/skill.json +20 -20
- package/skills/flyai/src/SKILL.md +119 -119
- package/skills/flyai/src/references/fliggy-fast-search.md +53 -53
- package/skills/flyai/src/references/search-flight.md +89 -89
- package/skills/flyai/src/references/search-hotels.md +57 -57
- package/skills/flyai/src/references/search-poi.md +48 -48
- package/skills/google-maps/skill.json +20 -20
- package/skills/google-maps/src/SKILL.md +237 -237
- package/skills/google-maps/src/_meta.json +5 -5
- package/skills/google-maps/src/lib/map_helper.py +912 -912
- package/skills/image-classify/skill.json +42 -42
- package/skills/image-classify/src/SKILL.md +368 -368
- package/skills/image-classify/src/references/config.json +4 -4
- package/skills/image-classify/src/scripts/face_search.py +1276 -1276
- package/skills/image-description/skill.json +34 -34
- package/skills/image-description/src/SKILL.md +33 -33
- package/skills/image-description/src/pyproject.toml +8 -8
- package/skills/image-description/src/scripts/ana_image.py +112 -112
- package/skills/image-identify-world/skill.json +20 -20
- package/skills/image-identify-world/src/SKILL.md +40 -40
- package/skills/image-identify-world/src/pyproject.toml +8 -8
- package/skills/image-identify-world/src/scripts/identify_world.py +115 -115
- package/skills/insurance-policy-review/skill.json +27 -27
- package/skills/insurance-policy-review/src/SKILL.md +75 -75
- package/skills/insurance-sales-playbook/skill.json +20 -20
- package/skills/insurance-sales-playbook/src/SKILL.md +58 -58
- package/skills/inventory-management/skill.json +20 -20
- package/skills/inventory-management/src/SKILL.md +241 -241
- package/skills/inventory-management/src/scripts/inventory.py +1844 -1844
- package/skills/large-task-router/skill.json +20 -20
- package/skills/large-task-router/src/SKILL.md +79 -79
- package/skills/large-task-router/src/templates/plan.md +74 -74
- package/skills/lawding-contract-review/skill.json +20 -20
- package/skills/lawding-contract-review/src/SKILL.md +284 -284
- package/skills/lawding-contract-review/src/references/legal-language-library.md +1385 -1385
- package/skills/lawding-contract-review/src/scripts/build_reminders.py +471 -471
- package/skills/lawding-contract-review/src/scripts/register_contract_cron.py +457 -457
- package/skills/md2pdf-converter/skill.json +20 -20
- package/skills/md2pdf-converter/src/SKILL.md +244 -244
- package/skills/md2pdf-converter/src/_meta.json +5 -5
- package/skills/md2pdf-converter/src/scripts/generate_emoji_mapping.py +74 -74
- package/skills/md2pdf-converter/src/scripts/md2pdf-local.sh +291 -291
- package/skills/notes-hub-assistant/skill.json +20 -20
- package/skills/notes-hub-assistant/src/SKILL.md +233 -233
- package/skills/notes-hub-assistant/src/scripts/_resolve_lark_cli.py +48 -48
- package/skills/notes-hub-assistant/src/scripts/openclaw_meeting_minutes.py +473 -473
- package/skills/notes-hub-assistant/src/scripts/openclaw_notes_crud.py +596 -596
- package/skills/notes-hub-assistant/src/scripts/openclaw_wolai_notes_crud.py +364 -364
- package/skills/notes-hub-assistant/src/scripts/run_meeting_minutes.py +79 -79
- package/skills/notes-hub-assistant/src/scripts/run_note_crud.py +37 -37
- package/skills/notes-hub-assistant/src/scripts/run_notionbot.py +36 -36
- package/skills/notes-hub-assistant/src/scripts/run_wolai_note_crud.py +27 -27
- package/skills/schedule-reminder/skill.json +20 -20
- package/skills/schedule-reminder/src/SKILL.md +619 -619
- package/skills/schedule-reminder/src/schedule_template.md +68 -68
- package/skills/schedule-reminder/src/scripts/append_event.py +204 -204
- package/skills/schedule-reminder/src/scripts/create_reminders.sh +163 -163
- package/skills/schedule-reminder/src/scripts/daily_activate.sh +175 -175
- package/skills/schedule-reminder/src/scripts/parse_schedule.py +704 -704
- package/skills/schedule-reminder/src/scripts/setup.sh +242 -242
- package/skills/schedule-reminder/src//347/224/250/346/210/267/346/214/207/345/215/227.md +311 -311
- package/skills/sessions-analysis/skill.json +34 -34
- package/skills/sessions-analysis/src/SKILL.md +81 -81
- package/skills/sessions-analysis/src/pyproject.toml +5 -5
- package/skills/sessions-analysis/src/scripts/ana_logs.py +205 -205
- package/skills/share-skill/skill.json +20 -20
- package/skills/share-skill/src/SKILL.md +261 -261
- package/skills/share-skill/src/scripts/share_skill_to_friend.py +1031 -1031
- package/skills/skill-creator/skill.json +20 -20
- package/skills/skill-creator/src/SKILL.md +370 -370
- package/skills/skill-creator/src/license.txt +202 -202
- package/skills/skill-creator/src/scripts/init_skill.py +378 -378
- package/skills/skill-creator/src/scripts/package_skill.py +111 -111
- package/skills/skill-creator/src/scripts/quick_validate.py +101 -101
- package/skills/skillhub/skill.json +27 -27
- package/skills/skillhub/src/SKILL.md +121 -121
- package/skills/sophnet-age-appearance/skill.json +20 -20
- package/skills/sophnet-age-appearance/src/SKILL.md +83 -83
- package/skills/sophnet-age-appearance/src/pyproject.toml +10 -10
- package/skills/sophnet-age-appearance/src/scripts/age_appearance.py +395 -395
- package/skills/sophnet-age-appearance/src/scripts/age_face_crop.py +313 -313
- package/skills/sophnet-bot-client/skill.json +20 -20
- package/skills/sophnet-bot-client/src/SKILL.md +255 -255
- package/skills/sophnet-bot-client/src/pyproject.toml +13 -13
- package/skills/sophnet-bot-client/src/scripts/bot_client_proxy.py +165 -165
- package/skills/sophnet-bot-client/src/scripts/bot_client_safe.sh +29 -29
- package/skills/sophnet-bot-client/src/scripts/bot_client_setup.py +502 -502
- package/skills/sophnet-bot-client/src/tests/test_bot_client_proxy.py +255 -255
- package/skills/sophnet-bot-client/src/tests/test_bot_client_setup.py +679 -679
- package/skills/sophnet-bot-client/src/uv.lock +8 -8
- package/skills/sophnet-customer-management/skill.json +20 -20
- package/skills/sophnet-customer-management/src/SKILL.md +270 -270
- package/skills/sophnet-customer-management/src/pyproject.toml +15 -15
- package/skills/sophnet-customer-management/src/src/customer_mgmt_cli/__init__.py +2 -2
- package/skills/sophnet-customer-management/src/src/customer_mgmt_cli/__main__.py +5 -5
- package/skills/sophnet-customer-management/src/src/customer_mgmt_cli/cli.py +67 -67
- package/skills/sophnet-customer-management/src/src/customer_mgmt_cli/commands/__init__.py +2 -2
- package/skills/sophnet-customer-management/src/src/customer_mgmt_cli/commands/customer.py +60 -60
- package/skills/sophnet-customer-management/src/src/customer_mgmt_cli/commands/export_file.py +18 -18
- package/skills/sophnet-customer-management/src/src/customer_mgmt_cli/commands/import_file.py +15 -15
- package/skills/sophnet-customer-management/src/src/customer_mgmt_cli/commands/reminder.py +26 -26
- package/skills/sophnet-customer-management/src/src/customer_mgmt_cli/commands/schema.py +28 -28
- package/skills/sophnet-customer-management/src/src/customer_mgmt_cli/config.py +54 -54
- package/skills/sophnet-customer-management/src/src/customer_mgmt_core/__init__.py +2 -2
- package/skills/sophnet-customer-management/src/src/customer_mgmt_core/exporter.py +85 -85
- package/skills/sophnet-customer-management/src/src/customer_mgmt_core/models.py +84 -84
- package/skills/sophnet-customer-management/src/src/customer_mgmt_core/normalizer.py +144 -144
- package/skills/sophnet-customer-management/src/src/customer_mgmt_core/parser.py +241 -241
- package/skills/sophnet-customer-management/src/src/customer_mgmt_core/query.py +109 -109
- package/skills/sophnet-customer-management/src/src/customer_mgmt_core/reminder.py +121 -121
- package/skills/sophnet-customer-management/src/src/customer_mgmt_core/repository.py +397 -397
- package/skills/sophnet-customer-management/src/src/customer_mgmt_core/schema.py +106 -106
- package/skills/sophnet-customer-management/src/src/customer_mgmt_core/service.py +565 -565
- package/skills/sophnet-customer-management/src/uv.lock +48 -48
- package/skills/sophnet-customized-marketing/skill.json +28 -28
- package/skills/sophnet-customized-marketing/src/SKILL.md +144 -144
- package/skills/sophnet-customized-marketing/src/playbooks/campaign-planning.md +187 -187
- package/skills/sophnet-customized-marketing/src/playbooks/content-generation.md +124 -124
- package/skills/sophnet-customized-marketing/src/playbooks/marketing-calendar.md +59 -59
- package/skills/sophnet-customized-marketing/src/playbooks/multi-channel-bundle.md +94 -94
- package/skills/sophnet-customized-marketing/src/playbooks/poster-generation.md +182 -182
- package/skills/sophnet-customized-marketing/src/playbooks/style-profile-workflow.md +103 -103
- package/skills/sophnet-customized-marketing/src/pyproject.toml +8 -8
- package/skills/sophnet-customized-marketing/src/references/campaign-mechanics.md +168 -168
- package/skills/sophnet-customized-marketing/src/references/content-safety.md +26 -26
- package/skills/sophnet-customized-marketing/src/references/marketing-date-checklist.md +99 -99
- package/skills/sophnet-customized-marketing/src/references/platform-writing-guidelines.md +88 -88
- package/skills/sophnet-customized-marketing/src/references/quality-checklist.md +44 -44
- package/skills/sophnet-customized-marketing/src/scripts/generate_poster.py +572 -572
- package/skills/sophnet-customized-marketing/src/scripts/style_profile.py +215 -215
- package/skills/sophnet-dailynews/skill.json +20 -20
- package/skills/sophnet-dailynews/src/SKILL.md +179 -179
- package/skills/sophnet-dailynews/src/cache.json +150 -150
- package/skills/sophnet-dailynews/src/sources.json +230 -230
- package/skills/sophnet-docx/skill.json +20 -20
- package/skills/sophnet-docx/src/SKILL.md +463 -463
- package/skills/sophnet-docx/src/package-lock.json +208 -208
- package/skills/sophnet-docx/src/package.json +16 -16
- package/skills/sophnet-docx/src/pyproject.toml +11 -11
- package/skills/sophnet-docx/src/scripts/__init__.py +1 -1
- package/skills/sophnet-docx/src/scripts/accept_changes.py +135 -135
- package/skills/sophnet-docx/src/scripts/comment.py +318 -318
- package/skills/sophnet-docx/src/scripts/ensure_uv_env.sh +68 -68
- package/skills/sophnet-docx/src/scripts/office/helpers/merge_runs.py +199 -199
- package/skills/sophnet-docx/src/scripts/office/helpers/simplify_redlines.py +197 -197
- package/skills/sophnet-docx/src/scripts/office/pack.py +159 -159
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -1499
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -146
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -1085
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -11
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -3081
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -23
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -185
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -287
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -1676
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -28
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -144
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -174
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -25
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -18
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -59
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -56
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -195
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -582
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -25
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -4439
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -570
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -509
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -12
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -108
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -96
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -3646
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -116
- package/skills/sophnet-docx/src/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -42
- package/skills/sophnet-docx/src/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -50
- package/skills/sophnet-docx/src/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -49
- package/skills/sophnet-docx/src/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -33
- package/skills/sophnet-docx/src/scripts/office/schemas/mce/mc.xsd +75 -75
- package/skills/sophnet-docx/src/scripts/office/schemas/microsoft/wml-2010.xsd +560 -560
- package/skills/sophnet-docx/src/scripts/office/schemas/microsoft/wml-2012.xsd +67 -67
- package/skills/sophnet-docx/src/scripts/office/schemas/microsoft/wml-2018.xsd +14 -14
- package/skills/sophnet-docx/src/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -20
- package/skills/sophnet-docx/src/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -13
- package/skills/sophnet-docx/src/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -4
- package/skills/sophnet-docx/src/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -8
- package/skills/sophnet-docx/src/scripts/office/soffice.py +183 -183
- package/skills/sophnet-docx/src/scripts/office/unpack.py +132 -132
- package/skills/sophnet-docx/src/scripts/office/validate.py +111 -111
- package/skills/sophnet-docx/src/scripts/office/validators/__init__.py +15 -15
- package/skills/sophnet-docx/src/scripts/office/validators/base.py +847 -847
- package/skills/sophnet-docx/src/scripts/office/validators/docx.py +446 -446
- package/skills/sophnet-docx/src/scripts/office/validators/pptx.py +275 -275
- package/skills/sophnet-docx/src/scripts/office/validators/redlining.py +247 -247
- package/skills/sophnet-docx/src/scripts/templates/comments.xml +3 -3
- package/skills/sophnet-docx/src/scripts/templates/commentsExtended.xml +3 -3
- package/skills/sophnet-docx/src/scripts/templates/commentsExtensible.xml +3 -3
- package/skills/sophnet-docx/src/scripts/templates/commentsIds.xml +3 -3
- package/skills/sophnet-docx/src/scripts/templates/people.xml +3 -3
- package/skills/sophnet-docx/src/scripts/upload_file.sh +96 -96
- package/skills/sophnet-docx/src/uv.lock +320 -320
- package/skills/sophnet-face-search/skill.json +20 -20
- package/skills/sophnet-face-search/src/SKILL.md +115 -115
- package/skills/sophnet-face-search/src/pyproject.toml +11 -11
- package/skills/sophnet-face-search/src/scripts/face_search.py +335 -335
- package/skills/sophnet-face-search/src/uv.lock +508 -508
- package/skills/sophnet-id-photo/skill.json +20 -20
- package/skills/sophnet-id-photo/src/SKILL.md +107 -107
- package/skills/sophnet-id-photo/src/pyproject.toml +10 -10
- package/skills/sophnet-id-photo/src/scripts/id_photo.py +540 -540
- package/skills/sophnet-id-photo/src/scripts/id_photo_compliance.py +215 -215
- package/skills/sophnet-id-photo/src/scripts/id_photo_face_crop.py +313 -313
- package/skills/sophnet-image-edit/skill.json +20 -20
- package/skills/sophnet-image-edit/src/SKILL.md +140 -140
- package/skills/sophnet-image-edit/src/pyproject.toml +9 -9
- package/skills/sophnet-image-edit/src/scripts/edit_and_preview.sh +68 -68
- package/skills/sophnet-image-edit/src/scripts/edit_image.py +279 -279
- package/skills/sophnet-image-edit/src/uv.lock +234 -234
- package/skills/sophnet-image-generate/skill.json +20 -20
- package/skills/sophnet-image-generate/src/SKILL.md +62 -62
- package/skills/sophnet-image-generate/src/pyproject.toml +9 -9
- package/skills/sophnet-image-generate/src/scripts/generate_image.py +156 -156
- package/skills/sophnet-image-generate/src/uv.lock +234 -234
- package/skills/sophnet-image-ocr/skill.json +20 -20
- package/skills/sophnet-image-ocr/src/SKILL.md +167 -167
- package/skills/sophnet-image-ocr/src/pyproject.toml +13 -13
- package/skills/sophnet-image-ocr/src/scripts/ocr.py +225 -225
- package/skills/sophnet-image-ocr/src/uv.lock +234 -234
- package/skills/sophnet-infinite-talk/skill.json +20 -20
- package/skills/sophnet-infinite-talk/src/SKILL.md +140 -140
- package/skills/sophnet-infinite-talk/src/pyproject.toml +9 -9
- package/skills/sophnet-infinite-talk/src/scripts/gen.py +172 -172
- package/skills/sophnet-oss/skill.json +27 -27
- package/skills/sophnet-oss/src/SKILL.md +118 -118
- package/skills/sophnet-oss/src/pyproject.toml +8 -8
- package/skills/sophnet-oss/src/scripts/upload_file.py +43 -43
- package/skills/sophnet-pdf/skill.json +20 -20
- package/skills/sophnet-pdf/src/SKILL.md +413 -413
- package/skills/sophnet-pdf/src/forms.md +297 -297
- package/skills/sophnet-pdf/src/pyproject.toml +14 -14
- package/skills/sophnet-pdf/src/reference.md +611 -611
- package/skills/sophnet-pdf/src/scripts/check_bounding_boxes.py +65 -65
- package/skills/sophnet-pdf/src/scripts/check_fillable_fields.py +11 -11
- package/skills/sophnet-pdf/src/scripts/convert_pdf_to_images.py +33 -33
- package/skills/sophnet-pdf/src/scripts/create_validation_image.py +37 -37
- package/skills/sophnet-pdf/src/scripts/enhance_tutorial.py +557 -557
- package/skills/sophnet-pdf/src/scripts/ensure_uv_env.sh +68 -68
- package/skills/sophnet-pdf/src/scripts/extract_form_field_info.py +122 -122
- package/skills/sophnet-pdf/src/scripts/extract_form_structure.py +115 -115
- package/skills/sophnet-pdf/src/scripts/extract_pdf_content.py +34 -34
- package/skills/sophnet-pdf/src/scripts/fill_fillable_fields.py +98 -98
- package/skills/sophnet-pdf/src/scripts/fill_pdf_form_with_annotations.py +107 -107
- package/skills/sophnet-pdf/src/scripts/upload_file.sh +88 -88
- package/skills/sophnet-pdf/src/uv.lock +537 -537
- package/skills/sophnet-qa-install/skill.json +27 -27
- package/skills/sophnet-qa-install/src/SKILL.md +210 -210
- package/skills/sophnet-qa-install/src/pyproject.toml +6 -6
- package/skills/sophnet-qa-install/src/scripts/backup_md.py +35 -35
- package/skills/sophnet-qa-install/src/scripts/check_installed.py +143 -143
- package/skills/sophnet-qa-install/src/scripts/update_config.py +142 -142
- package/skills/sophnet-qa-install/src/scripts/update_md.py +73 -73
- package/skills/sophnet-schedule/skill.json +20 -20
- package/skills/sophnet-schedule/src/ARCHITECTURE.md +321 -321
- package/skills/sophnet-schedule/src/IMPROVEMENTS.md +145 -145
- package/skills/sophnet-schedule/src/SKILL.md +1050 -1050
- package/skills/sophnet-schedule/src/_meta.json +6 -6
- package/skills/sophnet-schedule/src/api/models.py +245 -245
- package/skills/sophnet-schedule/src/apps/add_event.py +237 -237
- package/skills/sophnet-schedule/src/apps/check_reminders.py +112 -112
- package/skills/sophnet-schedule/src/apps/check_roc.py +246 -246
- package/skills/sophnet-schedule/src/apps/generate_daily_plan.py +342 -342
- package/skills/sophnet-schedule/src/apps/import_events.py +216 -216
- package/skills/sophnet-schedule/src/apps/monitor_calendar_changes.py +140 -140
- package/skills/sophnet-schedule/src/apps/register_tasks.py +169 -169
- package/skills/sophnet-schedule/src/apps/sync_roc_to_gcal.py +174 -174
- package/skills/sophnet-schedule/src/compat.py +66 -66
- package/skills/sophnet-schedule/src/config/reminder_rules.yaml +96 -96
- package/skills/sophnet-schedule/src/config/roc_events.yaml +44 -44
- package/skills/sophnet-schedule/src/config/settings.py +133 -133
- package/skills/sophnet-schedule/src/config/task_registry.yaml +92 -92
- package/skills/sophnet-schedule/src/docs/FRONTEND_INTEGRATION_GUIDE.md +437 -437
- package/skills/sophnet-schedule/src/gcal/client.py +374 -374
- package/skills/sophnet-schedule/src/gcal/models.py +91 -91
- package/skills/sophnet-schedule/src/requirements.txt +6 -6
- package/skills/sophnet-schedule/src/scripts/setup_gcal_token.py +85 -85
- package/skills/sophnet-schedule/src/server.py +669 -669
- package/skills/sophnet-schedule/src/services/calendar_backend.py +139 -139
- package/skills/sophnet-schedule/src/services/conflict_detector.py +96 -96
- package/skills/sophnet-schedule/src/services/datetime_utils.py +117 -117
- package/skills/sophnet-schedule/src/services/event_classifier.py +100 -100
- package/skills/sophnet-schedule/src/services/event_diff.py +160 -160
- package/skills/sophnet-schedule/src/services/google_integration.py +500 -500
- package/skills/sophnet-schedule/src/services/job_store.py +100 -100
- package/skills/sophnet-schedule/src/services/local_event_store.py +266 -266
- package/skills/sophnet-schedule/src/services/reminder_planner.py +116 -116
- package/skills/sophnet-schedule/src/services/runtime_utils.py +31 -31
- package/skills/sophnet-schedule/src/services/table_parser.py +286 -286
- package/skills/sophnet-schedule/src/services/task_builder.py +167 -167
- package/skills/sophnet-schedule/src/services/time_window.py +72 -72
- package/skills/sophnet-sticker-edit/skill.json +27 -27
- package/skills/sophnet-sticker-edit/src/SKILL.md +80 -80
- package/skills/sophnet-sticker-edit/src/pyproject.toml +9 -9
- package/skills/sophnet-sticker-edit/src/scripts/edit_sticker_image.py +403 -403
- package/skills/sophnet-stock/skill.json +20 -20
- package/skills/sophnet-stock/src/App-Plan.md +442 -442
- package/skills/sophnet-stock/src/README.md +214 -214
- package/skills/sophnet-stock/src/SKILL.md +236 -236
- package/skills/sophnet-stock/src/TODO.md +394 -394
- package/skills/sophnet-stock/src/_meta.json +5 -5
- package/skills/sophnet-stock/src/docs/ARCHITECTURE.md +408 -408
- package/skills/sophnet-stock/src/docs/CONCEPT.md +233 -233
- package/skills/sophnet-stock/src/docs/HOT_SCANNER.md +288 -288
- package/skills/sophnet-stock/src/docs/README.md +95 -95
- package/skills/sophnet-stock/src/docs/USAGE.md +465 -465
- package/skills/sophnet-stock/src/scripts/analyze_stock.py +2565 -2565
- package/skills/sophnet-stock/src/scripts/dividends.py +365 -365
- package/skills/sophnet-stock/src/scripts/hot_scanner.py +582 -582
- package/skills/sophnet-stock/src/scripts/portfolio.py +548 -548
- package/skills/sophnet-stock/src/scripts/rumor_scanner.py +342 -342
- package/skills/sophnet-stock/src/scripts/test_stock_analysis.py +409 -409
- package/skills/sophnet-stock/src/scripts/watchlist.py +336 -336
- package/skills/sophnet-training-install/skill.json +27 -27
- package/skills/sophnet-training-install/src/SKILL.md +211 -211
- package/skills/sophnet-training-install/src/pyproject.toml +6 -6
- package/skills/sophnet-training-install/src/scripts/backup_md.py +35 -35
- package/skills/sophnet-training-install/src/scripts/check_installed.py +144 -144
- package/skills/sophnet-training-install/src/scripts/update_config.py +142 -142
- package/skills/sophnet-training-install/src/scripts/update_md.py +73 -73
- package/skills/sophnet-tts/skill.json +20 -20
- package/skills/sophnet-tts/src/SKILL.md +79 -79
- package/skills/sophnet-tts/src/pyproject.toml +9 -9
- package/skills/sophnet-tts/src/scripts/gen_tts.py +130 -130
- package/skills/sophnet-video-generate/skill.json +37 -37
- package/skills/sophnet-video-generate/src/SKILL.md +117 -117
- package/skills/sophnet-video-generate/src/scripts/gen_video.py +321 -321
- package/skills/sophnet-xlsx/skill.json +20 -20
- package/skills/sophnet-xlsx/src/SKILL.md +399 -399
- package/skills/sophnet-xlsx/src/pyproject.toml +11 -11
- package/skills/sophnet-xlsx/src/scripts/ensure_uv_env.sh +68 -68
- package/skills/sophnet-xlsx/src/scripts/office/helpers/merge_runs.py +199 -199
- package/skills/sophnet-xlsx/src/scripts/office/helpers/simplify_redlines.py +197 -197
- package/skills/sophnet-xlsx/src/scripts/office/pack.py +159 -159
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -1499
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -146
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -1085
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -11
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -3081
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -23
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -185
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -287
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -1676
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -28
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -144
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -174
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -25
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -18
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -59
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -56
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -195
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -582
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -25
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -4439
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -570
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -509
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -12
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -108
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -96
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -3646
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -116
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -42
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -50
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -49
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -33
- package/skills/sophnet-xlsx/src/scripts/office/schemas/mce/mc.xsd +75 -75
- package/skills/sophnet-xlsx/src/scripts/office/schemas/microsoft/wml-2010.xsd +560 -560
- package/skills/sophnet-xlsx/src/scripts/office/schemas/microsoft/wml-2012.xsd +67 -67
- package/skills/sophnet-xlsx/src/scripts/office/schemas/microsoft/wml-2018.xsd +14 -14
- package/skills/sophnet-xlsx/src/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -20
- package/skills/sophnet-xlsx/src/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -13
- package/skills/sophnet-xlsx/src/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -4
- package/skills/sophnet-xlsx/src/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -8
- package/skills/sophnet-xlsx/src/scripts/office/soffice.py +183 -183
- package/skills/sophnet-xlsx/src/scripts/office/unpack.py +132 -132
- package/skills/sophnet-xlsx/src/scripts/office/validate.py +111 -111
- package/skills/sophnet-xlsx/src/scripts/office/validators/__init__.py +15 -15
- package/skills/sophnet-xlsx/src/scripts/office/validators/base.py +847 -847
- package/skills/sophnet-xlsx/src/scripts/office/validators/docx.py +446 -446
- package/skills/sophnet-xlsx/src/scripts/office/validators/pptx.py +275 -275
- package/skills/sophnet-xlsx/src/scripts/office/validators/redlining.py +247 -247
- package/skills/sophnet-xlsx/src/scripts/recalc.py +184 -184
- package/skills/sophnet-xlsx/src/scripts/upload_file.sh +96 -96
- package/skills/sophnet-xlsx/src/uv.lock +319 -319
- package/skills/ui-ux-pro-max/skill.json +20 -20
- package/skills/ui-ux-pro-max/src/SKILL.md +377 -377
- package/skills/ui-ux-pro-max/src/data/icons.csv +101 -101
- package/skills/ui-ux-pro-max/src/data/react-performance.csv +45 -45
- package/skills/ui-ux-pro-max/src/data/stacks/astro.csv +54 -54
- package/skills/ui-ux-pro-max/src/data/stacks/jetpack-compose.csv +53 -53
- package/skills/ui-ux-pro-max/src/data/stacks/nuxt-ui.csv +51 -51
- package/skills/ui-ux-pro-max/src/data/stacks/nuxtjs.csv +59 -59
- package/skills/ui-ux-pro-max/src/data/stacks/shadcn.csv +61 -61
- package/skills/ui-ux-pro-max/src/data/typography.csv +57 -57
- package/skills/ui-ux-pro-max/src/data/ui-reasoning.csv +101 -101
- package/skills/ui-ux-pro-max/src/data/web-interface.csv +31 -31
- package/skills/ui-ux-pro-max/src/scripts/core.py +253 -253
- package/skills/ui-ux-pro-max/src/scripts/design_system.py +1067 -1067
- package/skills/video-understand/skill.json +20 -20
- package/skills/video-understand/src/SKILL.md +79 -79
- package/skills/video-understand/src/scripts/video_understand.py +204 -204
- package/skills/weather/skill.json +19 -19
- package/skills/weather/src/SKILL.md +112 -112
- package/skills/web-scraper/skill.json +20 -20
- package/skills/web-scraper/src/SKILL.md +101 -101
- package/skills/web-scraper/src/scripts/scrape.py +270 -270
- package/skills/website-builder/skill.json +20 -20
- package/skills/website-builder/src/SKILL.md +266 -266
- package/skills/website-builder/src/scripts/deploy_site.sh +46 -46
- package/skills/wechat-article-publisher/skill.json +20 -20
- package/skills/wechat-article-publisher/src/SKILL.md +60 -60
- package/skills/wechat-article-publisher/src/config.json +6 -6
- package/skills/wechat-article-publisher/src/pyproject.toml +12 -12
- package/skills/wechat-article-publisher/src/scripts/publish_wechat.py +825 -825
- package/skills/xiaohongshu/skill.json +20 -20
- package/skills/xiaohongshu/src/SKILL.md +91 -91
- package/skills/xiaohongshu/src/_meta.json +5 -5
- package/skills/xiaohongshu/src/assets/card.html +216 -216
- package/skills/xiaohongshu/src/assets/cover.html +82 -82
- package/skills/xiaohongshu/src/assets/example.md +84 -84
- package/skills/xiaohongshu/src/assets/styles.css +318 -318
- package/skills/xiaohongshu/src/scripts/render_xhs_v2.py +737 -737
- package/skills/xiaohongshu/src/scripts/sign_server.py +158 -158
- package/skills/xiaohongshu/src/scripts/stealth.min.js +6 -6
- package/skills/xiaohongshu/src/scripts/xhs_tool.py +186 -186
- package/skills/xiaohongshu/src/workflow.py +185 -185
- package/src/commands/agent.js +112 -112
- package/src/commands/download.js +101 -101
- package/src/commands/info.js +58 -58
- package/src/commands/list.js +71 -71
- package/src/utils/agents.js +36 -36
- package/src/utils/config.js +22 -22
- package/src/utils/paths.js +31 -31
- package/src/utils/versions.js +57 -57
|
@@ -1,669 +1,669 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Sophnet 日程提醒 HTTP API 服务。
|
|
3
|
-
|
|
4
|
-
启动(在 skills/sophnet-schedule/src 目录下):
|
|
5
|
-
uv run uvicorn server:app --host 0.0.0.0 --port 8765 --reload
|
|
6
|
-
|
|
7
|
-
认证:
|
|
8
|
-
所有接口需要在 Header 中携带 X-API-Key(值来自 .env 中 API_KEY)。
|
|
9
|
-
开发时可设置 API_KEY=dev 跳过认证(不建议生产使用)。
|
|
10
|
-
|
|
11
|
-
接口概览:
|
|
12
|
-
GET /health
|
|
13
|
-
GET /events?date=YYYY-MM-DD
|
|
14
|
-
GET /events?start=...&end=...
|
|
15
|
-
POST /events
|
|
16
|
-
DELETE /events/{event_id}
|
|
17
|
-
GET /events/conflicts?date=YYYY-MM-DD
|
|
18
|
-
GET /roc/events
|
|
19
|
-
POST /roc/events
|
|
20
|
-
PUT /roc/events/{id}
|
|
21
|
-
DELETE /roc/events/{id}
|
|
22
|
-
GET /roc/upcoming?days=30
|
|
23
|
-
GET /reminders?window=30
|
|
24
|
-
GET /tasks
|
|
25
|
-
POST /tasks/trigger/daily-plan
|
|
26
|
-
POST /tasks/sync
|
|
27
|
-
GET /daily-plan?date=YYYY-MM-DD
|
|
28
|
-
"""
|
|
29
|
-
|
|
30
|
-
from __future__ import annotations
|
|
31
|
-
|
|
32
|
-
import os
|
|
33
|
-
import subprocess
|
|
34
|
-
import sys
|
|
35
|
-
from datetime import datetime, timedelta
|
|
36
|
-
from pathlib import Path
|
|
37
|
-
from typing import Optional
|
|
38
|
-
|
|
39
|
-
import yaml
|
|
40
|
-
from fastapi import Depends, FastAPI, Header, HTTPException, Query, Request
|
|
41
|
-
from fastapi.middleware.cors import CORSMiddleware
|
|
42
|
-
from fastapi.responses import HTMLResponse
|
|
43
|
-
|
|
44
|
-
# ── sys.path ──────────────────────────────────────────────────────────
|
|
45
|
-
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
46
|
-
|
|
47
|
-
from config.settings import TIMEZONE, SKILL_BASE, TASK_REGISTRY_FILE
|
|
48
|
-
from gcal.client import CalendarAPIError, CalendarAuthError
|
|
49
|
-
from gcal.models import CalendarEvent
|
|
50
|
-
from services.calendar_backend import (
|
|
51
|
-
active_provider,
|
|
52
|
-
create_event as backend_create_event,
|
|
53
|
-
delete_event as backend_delete_event,
|
|
54
|
-
list_event_views,
|
|
55
|
-
sync_local_events,
|
|
56
|
-
)
|
|
57
|
-
from services.conflict_detector import ConflictPair, detect_conflicts
|
|
58
|
-
from services.time_window import get_today_window
|
|
59
|
-
from services.datetime_utils import (
|
|
60
|
-
DateTimeValidationError,
|
|
61
|
-
build_event_range,
|
|
62
|
-
current_date_str,
|
|
63
|
-
current_year,
|
|
64
|
-
local_date_label,
|
|
65
|
-
local_date_window,
|
|
66
|
-
now_local,
|
|
67
|
-
parse_iso_datetime,
|
|
68
|
-
)
|
|
69
|
-
from services.job_store import append_job_if_absent, list_job_names
|
|
70
|
-
from services.google_integration import (
|
|
71
|
-
complete_oauth_callback,
|
|
72
|
-
get_guide_payload,
|
|
73
|
-
get_last_sync_status,
|
|
74
|
-
get_status_payload,
|
|
75
|
-
start_oauth_session,
|
|
76
|
-
)
|
|
77
|
-
from services.runtime_utils import build_python_command
|
|
78
|
-
from apps.check_roc import build_year_events, upcoming_events, _load_config as _roc_config
|
|
79
|
-
|
|
80
|
-
from api.models import (
|
|
81
|
-
ConflictOut, DailyPlanResponse, EventCreateRequest, EventCreateResponse,
|
|
82
|
-
EventDeleteResponse, EventOut, EventsResponse, OkResponse,
|
|
83
|
-
GoogleGuideResponse, GoogleStartRequest, GoogleStartResponse,
|
|
84
|
-
GoogleStatusResponse, GoogleSyncResponse, GoogleSyncSummary,
|
|
85
|
-
RemindersResponse, RocEventCreateRequest, RocEventOut, RocEventUpdateRequest,
|
|
86
|
-
RocListResponse, RocUpcomingItem, RocUpcomingResponse,
|
|
87
|
-
TaskItem, TasksResponse, TaskSyncResponse,
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
# ── 应用初始化 ────────────────────────────────────────────────────────
|
|
91
|
-
|
|
92
|
-
app = FastAPI(
|
|
93
|
-
title="Sophnet 日程提醒 API",
|
|
94
|
-
description="Google Calendar 日程调度 + ROC 周期事件 HTTP 接口",
|
|
95
|
-
version="1.0.0",
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
app.add_middleware(
|
|
99
|
-
CORSMiddleware,
|
|
100
|
-
allow_origins=["*"], # 生产环境请限定前端域名
|
|
101
|
-
allow_methods=["*"],
|
|
102
|
-
allow_headers=["*"],
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
_ROC_CONFIG_FILE = SKILL_BASE / "config" / "roc_events.yaml"
|
|
106
|
-
_API_KEY = os.environ.get("API_KEY", "dev")
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
# ── 认证 ──────────────────────────────────────────────────────────────
|
|
110
|
-
|
|
111
|
-
def _auth(x_api_key: Optional[str] = Header(None, alias="X-API-Key")) -> None:
|
|
112
|
-
if x_api_key is None or (_API_KEY != "dev" and x_api_key != _API_KEY):
|
|
113
|
-
raise HTTPException(status_code=401, detail="Invalid API key")
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
# ── 内部工具 ──────────────────────────────────────────────────────────
|
|
117
|
-
|
|
118
|
-
def _event_out(ev: CalendarEvent, provider: str = "", sync_state: str = "") -> EventOut:
|
|
119
|
-
return EventOut(
|
|
120
|
-
id=ev.id,
|
|
121
|
-
summary=ev.summary,
|
|
122
|
-
start=ev.start.isoformat(),
|
|
123
|
-
end=ev.end.isoformat(),
|
|
124
|
-
is_all_day=ev.is_all_day,
|
|
125
|
-
location=ev.location,
|
|
126
|
-
description=ev.description,
|
|
127
|
-
status=ev.status,
|
|
128
|
-
duration_minutes=ev.duration_minutes(),
|
|
129
|
-
provider=provider,
|
|
130
|
-
sync_state=sync_state,
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
def _conflict_out(cp: ConflictPair) -> ConflictOut:
|
|
135
|
-
ta = f"{cp.a.start.strftime('%H:%M')}–{cp.a.end.strftime('%H:%M')}"
|
|
136
|
-
tb = f"{cp.b.start.strftime('%H:%M')}–{cp.b.end.strftime('%H:%M')}"
|
|
137
|
-
gap = int((cp.b.start - cp.a.end).total_seconds() / 60) if cp.is_tight else 0
|
|
138
|
-
return ConflictOut(
|
|
139
|
-
type="tight" if cp.is_tight else "conflict",
|
|
140
|
-
event_a=cp.a.summary,
|
|
141
|
-
event_b=cp.b.summary,
|
|
142
|
-
time_a=ta,
|
|
143
|
-
time_b=tb,
|
|
144
|
-
overlap_minutes=cp.overlap_minutes,
|
|
145
|
-
gap_minutes=gap,
|
|
146
|
-
text=cp.format_text(),
|
|
147
|
-
)
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
def _parse_date_window(date: str) -> tuple[datetime, datetime]:
|
|
151
|
-
"""将 YYYY-MM-DD 转为业务时区当日区间。"""
|
|
152
|
-
try:
|
|
153
|
-
return local_date_window(date, TIMEZONE)
|
|
154
|
-
except DateTimeValidationError as e:
|
|
155
|
-
raise HTTPException(400, str(e))
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
def _read_roc_yaml() -> dict:
|
|
159
|
-
with open(_ROC_CONFIG_FILE, encoding="utf-8") as f:
|
|
160
|
-
return yaml.safe_load(f)
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
def _write_roc_yaml(data: dict) -> None:
|
|
164
|
-
with open(_ROC_CONFIG_FILE, "w", encoding="utf-8") as f:
|
|
165
|
-
yaml.dump(data, f, allow_unicode=True, sort_keys=False)
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
def _callback_url(request: Request) -> str:
|
|
169
|
-
return str(request.base_url).rstrip("/") + "/integrations/google/callback"
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
def _callback_html(ok: bool, message: str) -> HTMLResponse:
|
|
173
|
-
title = "授权成功" if ok else "授权失败"
|
|
174
|
-
color = "#1b7f3b" if ok else "#b42318"
|
|
175
|
-
body = (
|
|
176
|
-
"<!doctype html><html><head><meta charset='utf-8'>"
|
|
177
|
-
f"<title>{title}</title></head>"
|
|
178
|
-
"<body style='font-family:sans-serif;padding:32px'>"
|
|
179
|
-
f"<h2 style='color:{color}'>{title}</h2>"
|
|
180
|
-
f"<p>{message}</p>"
|
|
181
|
-
"<p>现在可以关闭这个窗口。</p>"
|
|
182
|
-
"</body></html>"
|
|
183
|
-
)
|
|
184
|
-
return HTMLResponse(body, status_code=200 if ok else 400)
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
# ── 健康检查 ──────────────────────────────────────────────────────────
|
|
188
|
-
|
|
189
|
-
@app.get("/health", tags=["系统"])
|
|
190
|
-
def health() -> dict:
|
|
191
|
-
return {"ok": True, "service": "sophnet-schedule", "version": "1.0.0"}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
# ── 日历事件 ──────────────────────────────────────────────────────────
|
|
195
|
-
|
|
196
|
-
@app.get("/events", response_model=EventsResponse, tags=["日历"])
|
|
197
|
-
def list_events(
|
|
198
|
-
date: Optional[str] = Query(None, description="YYYY-MM-DD,查询当日"),
|
|
199
|
-
start: Optional[str] = Query(None, description="ISO 8601 开始时间"),
|
|
200
|
-
end: Optional[str] = Query(None, description="ISO 8601 结束时间"),
|
|
201
|
-
_: None = Depends(_auth),
|
|
202
|
-
) -> EventsResponse:
|
|
203
|
-
if date:
|
|
204
|
-
t_start, t_end = _parse_date_window(date)
|
|
205
|
-
label = date
|
|
206
|
-
elif start and end:
|
|
207
|
-
try:
|
|
208
|
-
t_start = parse_iso_datetime(start, TIMEZONE)
|
|
209
|
-
t_end = parse_iso_datetime(end, TIMEZONE)
|
|
210
|
-
except DateTimeValidationError as e:
|
|
211
|
-
raise HTTPException(400, str(e))
|
|
212
|
-
if t_end <= t_start:
|
|
213
|
-
raise HTTPException(400, "end 必须晚于 start")
|
|
214
|
-
label = local_date_label(t_start, TIMEZONE)
|
|
215
|
-
else:
|
|
216
|
-
t_start, t_end = get_today_window(TIMEZONE)
|
|
217
|
-
label = current_date_str(TIMEZONE)
|
|
218
|
-
|
|
219
|
-
try:
|
|
220
|
-
views = list_event_views(t_start, t_end)
|
|
221
|
-
except (CalendarAuthError, CalendarAPIError) as e:
|
|
222
|
-
raise HTTPException(502, str(e))
|
|
223
|
-
|
|
224
|
-
events = [item.event for item in views]
|
|
225
|
-
conflicts = detect_conflicts(events)
|
|
226
|
-
provider = active_provider()
|
|
227
|
-
return EventsResponse(
|
|
228
|
-
date=label,
|
|
229
|
-
events=[_event_out(item.event, provider=item.provider, sync_state=item.sync_state) for item in views],
|
|
230
|
-
conflicts=[_conflict_out(c) for c in conflicts],
|
|
231
|
-
provider=provider,
|
|
232
|
-
active_mode=provider,
|
|
233
|
-
)
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
@app.post("/events", response_model=EventCreateResponse, tags=["日历"])
|
|
237
|
-
def create_event(
|
|
238
|
-
body: EventCreateRequest,
|
|
239
|
-
_: None = Depends(_auth),
|
|
240
|
-
) -> EventCreateResponse:
|
|
241
|
-
try:
|
|
242
|
-
start_dt, end_dt = build_event_range(
|
|
243
|
-
body.date,
|
|
244
|
-
body.start,
|
|
245
|
-
body.end,
|
|
246
|
-
body.duration,
|
|
247
|
-
TIMEZONE,
|
|
248
|
-
)
|
|
249
|
-
except DateTimeValidationError as e:
|
|
250
|
-
raise HTTPException(400, str(e))
|
|
251
|
-
|
|
252
|
-
try:
|
|
253
|
-
created = backend_create_event(
|
|
254
|
-
summary=body.summary,
|
|
255
|
-
start=start_dt,
|
|
256
|
-
end=end_dt,
|
|
257
|
-
location=body.location,
|
|
258
|
-
description=body.description,
|
|
259
|
-
remind_minutes=body.remind,
|
|
260
|
-
)
|
|
261
|
-
except (CalendarAuthError, CalendarAPIError) as e:
|
|
262
|
-
return EventCreateResponse(ok=False, error=str(e), provider=active_provider())
|
|
263
|
-
|
|
264
|
-
reminder_registered = False
|
|
265
|
-
if body.remind > 0 and created.event_id:
|
|
266
|
-
try:
|
|
267
|
-
_register_one_off_reminder(body, start_dt, created.event_id)
|
|
268
|
-
reminder_registered = True
|
|
269
|
-
except Exception:
|
|
270
|
-
pass # 提醒注册失败不影响事件创建结果
|
|
271
|
-
|
|
272
|
-
return EventCreateResponse(
|
|
273
|
-
ok=True,
|
|
274
|
-
event_id=created.event_id,
|
|
275
|
-
summary=body.summary,
|
|
276
|
-
start=start_dt.isoformat(),
|
|
277
|
-
end=end_dt.isoformat(),
|
|
278
|
-
reminder_registered=reminder_registered,
|
|
279
|
-
provider=created.provider,
|
|
280
|
-
sync_state=created.sync_state,
|
|
281
|
-
)
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
@app.delete("/events/{event_id}", response_model=EventDeleteResponse, tags=["日历"])
|
|
285
|
-
def delete_event(
|
|
286
|
-
event_id: str,
|
|
287
|
-
_: None = Depends(_auth),
|
|
288
|
-
) -> EventDeleteResponse:
|
|
289
|
-
try:
|
|
290
|
-
deleted = backend_delete_event(event_id)
|
|
291
|
-
if not deleted:
|
|
292
|
-
return EventDeleteResponse(ok=False, event_id=event_id, error="事件不存在")
|
|
293
|
-
return EventDeleteResponse(ok=True, event_id=event_id)
|
|
294
|
-
except (CalendarAuthError, CalendarAPIError) as e:
|
|
295
|
-
return EventDeleteResponse(ok=False, event_id=event_id, error=str(e))
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
@app.get("/events/conflicts", response_model=EventsResponse, tags=["日历"])
|
|
299
|
-
def get_conflicts(
|
|
300
|
-
date: Optional[str] = Query(None, description="YYYY-MM-DD,默认今日"),
|
|
301
|
-
_: None = Depends(_auth),
|
|
302
|
-
) -> EventsResponse:
|
|
303
|
-
return list_events(date=date, start=None, end=None, _=_)
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
# ── ROC 周期事件 ──────────────────────────────────────────────────────
|
|
307
|
-
|
|
308
|
-
@app.get("/roc/events", response_model=RocListResponse, tags=["ROC"])
|
|
309
|
-
def roc_list(
|
|
310
|
-
year: Optional[int] = Query(None, description="年份,默认今年"),
|
|
311
|
-
_: None = Depends(_auth),
|
|
312
|
-
) -> RocListResponse:
|
|
313
|
-
y = year or current_year(TIMEZONE)
|
|
314
|
-
cfg = _read_roc_yaml()
|
|
315
|
-
year_events = build_year_events(y, cfg)
|
|
316
|
-
|
|
317
|
-
ev_map = {e["id"]: e for e in year_events}
|
|
318
|
-
result = []
|
|
319
|
-
for raw in cfg.get("events", []):
|
|
320
|
-
ye = ev_map.get(raw["id"], {})
|
|
321
|
-
result.append(RocEventOut(
|
|
322
|
-
id=raw["id"],
|
|
323
|
-
name=raw["name"],
|
|
324
|
-
rule=raw["rule"],
|
|
325
|
-
reminder_time=raw.get("reminder_time", "09:00"),
|
|
326
|
-
lead_days=int(raw.get("lead_days", 0)),
|
|
327
|
-
description=raw.get("description", ""),
|
|
328
|
-
event_date=ye.get("event_date"),
|
|
329
|
-
reminder_date=ye.get("reminder_date"),
|
|
330
|
-
))
|
|
331
|
-
return RocListResponse(year=y, events=result)
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
@app.post("/roc/events", response_model=OkResponse, tags=["ROC"])
|
|
335
|
-
def roc_create(
|
|
336
|
-
body: RocEventCreateRequest,
|
|
337
|
-
_: None = Depends(_auth),
|
|
338
|
-
) -> OkResponse:
|
|
339
|
-
cfg = _read_roc_yaml()
|
|
340
|
-
events: list = cfg.get("events", [])
|
|
341
|
-
if any(e["id"] == body.id for e in events):
|
|
342
|
-
raise HTTPException(409, f"ROC 事件 ID 已存在:{body.id}")
|
|
343
|
-
events.append({
|
|
344
|
-
"id": body.id,
|
|
345
|
-
"name": body.name,
|
|
346
|
-
"rule": body.rule,
|
|
347
|
-
"reminder_time": body.reminder_time,
|
|
348
|
-
"lead_days": body.lead_days,
|
|
349
|
-
"description": body.description,
|
|
350
|
-
})
|
|
351
|
-
cfg["events"] = events
|
|
352
|
-
_write_roc_yaml(cfg)
|
|
353
|
-
return OkResponse(id=body.id, message=f"已添加 ROC 事件:{body.name}")
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
@app.put("/roc/events/{roc_id}", response_model=OkResponse, tags=["ROC"])
|
|
357
|
-
def roc_update(
|
|
358
|
-
roc_id: str,
|
|
359
|
-
body: RocEventUpdateRequest,
|
|
360
|
-
_: None = Depends(_auth),
|
|
361
|
-
) -> OkResponse:
|
|
362
|
-
cfg = _read_roc_yaml()
|
|
363
|
-
events: list = cfg.get("events", [])
|
|
364
|
-
for ev in events:
|
|
365
|
-
if ev["id"] == roc_id:
|
|
366
|
-
if body.name is not None: ev["name"] = body.name
|
|
367
|
-
if body.rule is not None: ev["rule"] = body.rule
|
|
368
|
-
if body.reminder_time is not None: ev["reminder_time"] = body.reminder_time
|
|
369
|
-
if body.lead_days is not None: ev["lead_days"] = body.lead_days
|
|
370
|
-
if body.description is not None: ev["description"] = body.description
|
|
371
|
-
cfg["events"] = events
|
|
372
|
-
_write_roc_yaml(cfg)
|
|
373
|
-
return OkResponse(message=f"已更新 ROC 事件:{roc_id}")
|
|
374
|
-
raise HTTPException(404, f"ROC 事件不存在:{roc_id}")
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
@app.delete("/roc/events/{roc_id}", response_model=OkResponse, tags=["ROC"])
|
|
378
|
-
def roc_delete(
|
|
379
|
-
roc_id: str,
|
|
380
|
-
_: None = Depends(_auth),
|
|
381
|
-
) -> OkResponse:
|
|
382
|
-
cfg = _read_roc_yaml()
|
|
383
|
-
events: list = cfg.get("events", [])
|
|
384
|
-
new_events = [e for e in events if e["id"] != roc_id]
|
|
385
|
-
if len(new_events) == len(events):
|
|
386
|
-
raise HTTPException(404, f"ROC 事件不存在:{roc_id}")
|
|
387
|
-
cfg["events"] = new_events
|
|
388
|
-
_write_roc_yaml(cfg)
|
|
389
|
-
return OkResponse(message=f"已删除 ROC 事件:{roc_id}")
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
@app.get("/roc/upcoming", response_model=RocUpcomingResponse, tags=["ROC"])
|
|
393
|
-
def roc_upcoming(
|
|
394
|
-
days: int = Query(30, description="查询未来 N 天"),
|
|
395
|
-
_: None = Depends(_auth),
|
|
396
|
-
) -> RocUpcomingResponse:
|
|
397
|
-
today = current_date_str(TIMEZONE)
|
|
398
|
-
year = int(today[:4])
|
|
399
|
-
cfg = _read_roc_yaml()
|
|
400
|
-
year_events = build_year_events(year, cfg)
|
|
401
|
-
ups = upcoming_events(year_events, today, days)
|
|
402
|
-
return RocUpcomingResponse(
|
|
403
|
-
today=today,
|
|
404
|
-
days=days,
|
|
405
|
-
upcoming=[RocUpcomingItem(**{
|
|
406
|
-
"id": u["id"],
|
|
407
|
-
"name": u["name"],
|
|
408
|
-
"event_date": u["event_date"],
|
|
409
|
-
"reminder_date": u["reminder_date"],
|
|
410
|
-
"days_until_reminder": u["days_until_reminder"],
|
|
411
|
-
"days_until_event": u["days_until_event"],
|
|
412
|
-
"description": u.get("description", ""),
|
|
413
|
-
}) for u in ups],
|
|
414
|
-
)
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
# ── 提醒 ──────────────────────────────────────────────────────────────
|
|
418
|
-
|
|
419
|
-
@app.get("/reminders", response_model=RemindersResponse, tags=["提醒"])
|
|
420
|
-
def get_reminders(
|
|
421
|
-
window: int = Query(30, description="时间窗口(分钟),默认 30"),
|
|
422
|
-
_: None = Depends(_auth),
|
|
423
|
-
) -> RemindersResponse:
|
|
424
|
-
result = subprocess.run(
|
|
425
|
-
build_python_command(SKILL_BASE / "apps" / "check_reminders.py", "--window", str(window), "--json"),
|
|
426
|
-
capture_output=True, text=True, cwd=str(SKILL_BASE),
|
|
427
|
-
)
|
|
428
|
-
if result.returncode != 0:
|
|
429
|
-
detail = result.stderr.strip() or result.stdout.strip() or "检查提醒失败"
|
|
430
|
-
raise HTTPException(502, detail[:300])
|
|
431
|
-
|
|
432
|
-
import json as _json
|
|
433
|
-
try:
|
|
434
|
-
data = _json.loads(result.stdout)
|
|
435
|
-
except Exception as e:
|
|
436
|
-
raise HTTPException(502, f"提醒结果解析失败:{e}")
|
|
437
|
-
|
|
438
|
-
if not data.get("ok", True):
|
|
439
|
-
raise HTTPException(502, data.get("error", "提醒检查失败"))
|
|
440
|
-
|
|
441
|
-
provider = active_provider()
|
|
442
|
-
return RemindersResponse(
|
|
443
|
-
window_minutes=window,
|
|
444
|
-
reminders=data.get("reminders", []),
|
|
445
|
-
provider=provider,
|
|
446
|
-
active_mode=provider,
|
|
447
|
-
)
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
# ── Cron 任务 ─────────────────────────────────────────────────────────
|
|
451
|
-
|
|
452
|
-
@app.get("/tasks", response_model=TasksResponse, tags=["任务"])
|
|
453
|
-
def list_tasks(_: None = Depends(_auth)) -> TasksResponse:
|
|
454
|
-
with open(TASK_REGISTRY_FILE, encoding="utf-8") as f:
|
|
455
|
-
cfg = yaml.safe_load(f)
|
|
456
|
-
tasks = []
|
|
457
|
-
for t in cfg.get("tasks", []):
|
|
458
|
-
sch = t.get("schedule", {})
|
|
459
|
-
tasks.append(TaskItem(
|
|
460
|
-
name=t["name"],
|
|
461
|
-
description=t.get("description", ""),
|
|
462
|
-
schedule_kind=sch.get("kind", ""),
|
|
463
|
-
schedule_expr=sch.get("time") or sch.get("expr") or "",
|
|
464
|
-
type=t.get("type", ""),
|
|
465
|
-
))
|
|
466
|
-
return TasksResponse(tasks=tasks)
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
@app.post("/tasks/trigger/daily-plan", response_model=OkResponse, tags=["任务"])
|
|
470
|
-
def trigger_daily_plan(
|
|
471
|
-
dry_run: bool = Query(False),
|
|
472
|
-
_: None = Depends(_auth),
|
|
473
|
-
) -> OkResponse:
|
|
474
|
-
cmd = build_python_command(SKILL_BASE / "apps" / "generate_daily_plan.py")
|
|
475
|
-
if dry_run:
|
|
476
|
-
cmd.append("--dry-run")
|
|
477
|
-
result = subprocess.run(cmd, capture_output=True, text=True, cwd=str(SKILL_BASE))
|
|
478
|
-
if result.returncode != 0:
|
|
479
|
-
raise HTTPException(500, f"生成失败:{result.stderr[:200]}")
|
|
480
|
-
return OkResponse(message="今日计划已生成" + ("(dry-run)" if dry_run else ",提醒已注册"))
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
@app.post("/tasks/sync", response_model=TaskSyncResponse, tags=["任务"])
|
|
484
|
-
def sync_tasks(
|
|
485
|
-
dry_run: bool = Query(False),
|
|
486
|
-
_: None = Depends(_auth),
|
|
487
|
-
) -> TaskSyncResponse:
|
|
488
|
-
"""
|
|
489
|
-
重读 task_registry.yaml 并立即同步到 jobs.json。
|
|
490
|
-
|
|
491
|
-
- 已存在同名任务:跳过(不覆盖)
|
|
492
|
-
- 新任务:写入 jobs.json,当天生效
|
|
493
|
-
- dry_run=true:只计算差异,不写入
|
|
494
|
-
"""
|
|
495
|
-
import json as _json
|
|
496
|
-
from apps.register_tasks import load_fixed_tasks, build_cron_job_from_task
|
|
497
|
-
|
|
498
|
-
today = now_local(TIMEZONE)
|
|
499
|
-
|
|
500
|
-
try:
|
|
501
|
-
tasks = load_fixed_tasks(provider=active_provider())
|
|
502
|
-
except Exception as e:
|
|
503
|
-
raise HTTPException(500, f"读取 task_registry.yaml 失败:{e}")
|
|
504
|
-
|
|
505
|
-
try:
|
|
506
|
-
existing = list_job_names()
|
|
507
|
-
except Exception as e:
|
|
508
|
-
raise HTTPException(500, f"读取 jobs.json 失败:{e}")
|
|
509
|
-
added: list = []
|
|
510
|
-
skipped: list = []
|
|
511
|
-
errors: list = []
|
|
512
|
-
|
|
513
|
-
for task in tasks:
|
|
514
|
-
name = task.get("name", "未命名")
|
|
515
|
-
try:
|
|
516
|
-
payload = build_cron_job_from_task(task, today)
|
|
517
|
-
if payload is None:
|
|
518
|
-
errors.append(f"{name}:配置不完整,跳过")
|
|
519
|
-
continue
|
|
520
|
-
if dry_run and name in existing:
|
|
521
|
-
skipped.append(name)
|
|
522
|
-
continue
|
|
523
|
-
if dry_run:
|
|
524
|
-
existing.add(name)
|
|
525
|
-
added.append(name)
|
|
526
|
-
continue
|
|
527
|
-
if append_job_if_absent(payload):
|
|
528
|
-
existing.add(name)
|
|
529
|
-
added.append(name)
|
|
530
|
-
else:
|
|
531
|
-
skipped.append(name)
|
|
532
|
-
except Exception as e:
|
|
533
|
-
errors.append(f"{name}:{e}")
|
|
534
|
-
|
|
535
|
-
suffix = "(dry-run,未写入)" if dry_run else ""
|
|
536
|
-
return TaskSyncResponse(
|
|
537
|
-
ok=True,
|
|
538
|
-
dry_run=dry_run,
|
|
539
|
-
added=added,
|
|
540
|
-
skipped=skipped,
|
|
541
|
-
errors=errors,
|
|
542
|
-
message=f"同步完成{suffix}:新增 {len(added)} 个,跳过 {len(skipped)} 个,失败 {len(errors)} 个",
|
|
543
|
-
)
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
# ── 日报 ──────────────────────────────────────────────────────────────
|
|
547
|
-
|
|
548
|
-
@app.get("/daily-plan", response_model=DailyPlanResponse, tags=["日报"])
|
|
549
|
-
def get_daily_plan(
|
|
550
|
-
date: Optional[str] = Query(None, description="YYYY-MM-DD,默认今日"),
|
|
551
|
-
_: None = Depends(_auth),
|
|
552
|
-
) -> DailyPlanResponse:
|
|
553
|
-
label = date or current_date_str(TIMEZONE)
|
|
554
|
-
t_start, t_end = _parse_date_window(label)
|
|
555
|
-
|
|
556
|
-
try:
|
|
557
|
-
views = list_event_views(t_start, t_end)
|
|
558
|
-
except (CalendarAuthError, CalendarAPIError) as e:
|
|
559
|
-
raise HTTPException(502, str(e))
|
|
560
|
-
|
|
561
|
-
events = [item.event for item in views]
|
|
562
|
-
conflicts = detect_conflicts(events)
|
|
563
|
-
|
|
564
|
-
# 尝试读取已生成的日报 Markdown
|
|
565
|
-
md_path = SKILL_BASE / "daily" / f"cron-{label.replace('-', '')}.md"
|
|
566
|
-
markdown = md_path.read_text(encoding="utf-8") if md_path.exists() else ""
|
|
567
|
-
|
|
568
|
-
return DailyPlanResponse(
|
|
569
|
-
date=label,
|
|
570
|
-
events=[_event_out(item.event, provider=item.provider, sync_state=item.sync_state) for item in views],
|
|
571
|
-
conflicts=[_conflict_out(c) for c in conflicts],
|
|
572
|
-
reminders_registered=0, # 只读接口,不注册
|
|
573
|
-
markdown=markdown,
|
|
574
|
-
provider=active_provider(),
|
|
575
|
-
)
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
# ── Google 接入 ──────────────────────────────────────────────────────
|
|
579
|
-
|
|
580
|
-
@app.get("/integrations/google/status", response_model=GoogleStatusResponse, tags=["集成"])
|
|
581
|
-
def google_status(_: None = Depends(_auth)) -> GoogleStatusResponse:
|
|
582
|
-
return GoogleStatusResponse(**get_status_payload())
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
@app.get("/integrations/google/guide", response_model=GoogleGuideResponse, tags=["集成"])
|
|
586
|
-
def google_guide(
|
|
587
|
-
request: Request,
|
|
588
|
-
_: None = Depends(_auth),
|
|
589
|
-
) -> GoogleGuideResponse:
|
|
590
|
-
return GoogleGuideResponse(**get_guide_payload(_callback_url(request)))
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
@app.post("/integrations/google/start", response_model=GoogleStartResponse, tags=["集成"])
|
|
594
|
-
def google_start(
|
|
595
|
-
body: GoogleStartRequest,
|
|
596
|
-
request: Request,
|
|
597
|
-
_: None = Depends(_auth),
|
|
598
|
-
) -> GoogleStartResponse:
|
|
599
|
-
result = start_oauth_session(
|
|
600
|
-
client_id=body.client_id,
|
|
601
|
-
client_secret=body.client_secret,
|
|
602
|
-
redirect_uri=_callback_url(request),
|
|
603
|
-
)
|
|
604
|
-
return GoogleStartResponse(**result)
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
@app.get("/integrations/google/callback", response_class=HTMLResponse, tags=["集成"])
|
|
608
|
-
def google_callback(
|
|
609
|
-
state: str,
|
|
610
|
-
code: Optional[str] = Query(None),
|
|
611
|
-
error: Optional[str] = Query(None),
|
|
612
|
-
error_description: Optional[str] = Query(None),
|
|
613
|
-
) -> HTMLResponse:
|
|
614
|
-
try:
|
|
615
|
-
complete_oauth_callback(state, code, error, error_description)
|
|
616
|
-
return _callback_html(True, "Google 授权成功,已保存凭据,下一步可执行首次同步。")
|
|
617
|
-
except CalendarAuthError as e:
|
|
618
|
-
return _callback_html(False, str(e))
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
@app.post("/integrations/google/sync", response_model=GoogleSyncResponse, tags=["集成"])
|
|
622
|
-
def google_sync(_: None = Depends(_auth)) -> GoogleSyncResponse:
|
|
623
|
-
try:
|
|
624
|
-
summary = sync_local_events()
|
|
625
|
-
except (CalendarAuthError, CalendarAPIError) as e:
|
|
626
|
-
raise HTTPException(502, str(e))
|
|
627
|
-
|
|
628
|
-
status = get_status_payload()
|
|
629
|
-
return GoogleSyncResponse(
|
|
630
|
-
active_mode=status["active_mode"],
|
|
631
|
-
google_state=status["google_state"],
|
|
632
|
-
summary=GoogleSyncSummary(**summary),
|
|
633
|
-
)
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
@app.get("/integrations/google/sync-status", response_model=GoogleSyncSummary, tags=["集成"])
|
|
637
|
-
def google_sync_status(_: None = Depends(_auth)) -> GoogleSyncSummary:
|
|
638
|
-
return GoogleSyncSummary(**get_last_sync_status())
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
# ── 内部:提醒注册 ────────────────────────────────────────────────────
|
|
642
|
-
|
|
643
|
-
def _register_one_off_reminder(
|
|
644
|
-
body: EventCreateRequest,
|
|
645
|
-
start_dt: datetime,
|
|
646
|
-
event_id: str,
|
|
647
|
-
) -> None:
|
|
648
|
-
"""直接用 task_builder 注册提醒 cron job,不再调用 add_event.py(避免重复创建事件)。"""
|
|
649
|
-
from datetime import timezone as _tz
|
|
650
|
-
from services.task_builder import build_reminder_task, build_reminder_task_name
|
|
651
|
-
from compat import make_aware
|
|
652
|
-
|
|
653
|
-
start_aware = make_aware(start_dt, TIMEZONE)
|
|
654
|
-
remind_at_utc = (start_aware - timedelta(minutes=body.remind)).astimezone(_tz.utc)
|
|
655
|
-
name = build_reminder_task_name(body.summary, start_aware, event_id)
|
|
656
|
-
payload = build_reminder_task(
|
|
657
|
-
name=name,
|
|
658
|
-
remind_at_utc=remind_at_utc,
|
|
659
|
-
message=(
|
|
660
|
-
f"⏰ **{body.summary}** 将在 {body.remind} 分钟后开始\n"
|
|
661
|
-
f"🕐 {start_dt.strftime('%H:%M')}"
|
|
662
|
-
+ (f" 📍 {body.location}" if body.location else "")
|
|
663
|
-
),
|
|
664
|
-
)
|
|
665
|
-
|
|
666
|
-
try:
|
|
667
|
-
append_job_if_absent(payload)
|
|
668
|
-
except Exception:
|
|
669
|
-
pass # jobs.json 不存在时静默忽略
|
|
1
|
+
"""
|
|
2
|
+
Sophnet 日程提醒 HTTP API 服务。
|
|
3
|
+
|
|
4
|
+
启动(在 skills/sophnet-schedule/src 目录下):
|
|
5
|
+
uv run uvicorn server:app --host 0.0.0.0 --port 8765 --reload
|
|
6
|
+
|
|
7
|
+
认证:
|
|
8
|
+
所有接口需要在 Header 中携带 X-API-Key(值来自 .env 中 API_KEY)。
|
|
9
|
+
开发时可设置 API_KEY=dev 跳过认证(不建议生产使用)。
|
|
10
|
+
|
|
11
|
+
接口概览:
|
|
12
|
+
GET /health
|
|
13
|
+
GET /events?date=YYYY-MM-DD
|
|
14
|
+
GET /events?start=...&end=...
|
|
15
|
+
POST /events
|
|
16
|
+
DELETE /events/{event_id}
|
|
17
|
+
GET /events/conflicts?date=YYYY-MM-DD
|
|
18
|
+
GET /roc/events
|
|
19
|
+
POST /roc/events
|
|
20
|
+
PUT /roc/events/{id}
|
|
21
|
+
DELETE /roc/events/{id}
|
|
22
|
+
GET /roc/upcoming?days=30
|
|
23
|
+
GET /reminders?window=30
|
|
24
|
+
GET /tasks
|
|
25
|
+
POST /tasks/trigger/daily-plan
|
|
26
|
+
POST /tasks/sync
|
|
27
|
+
GET /daily-plan?date=YYYY-MM-DD
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
from __future__ import annotations
|
|
31
|
+
|
|
32
|
+
import os
|
|
33
|
+
import subprocess
|
|
34
|
+
import sys
|
|
35
|
+
from datetime import datetime, timedelta
|
|
36
|
+
from pathlib import Path
|
|
37
|
+
from typing import Optional
|
|
38
|
+
|
|
39
|
+
import yaml
|
|
40
|
+
from fastapi import Depends, FastAPI, Header, HTTPException, Query, Request
|
|
41
|
+
from fastapi.middleware.cors import CORSMiddleware
|
|
42
|
+
from fastapi.responses import HTMLResponse
|
|
43
|
+
|
|
44
|
+
# ── sys.path ──────────────────────────────────────────────────────────
|
|
45
|
+
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
46
|
+
|
|
47
|
+
from config.settings import TIMEZONE, SKILL_BASE, TASK_REGISTRY_FILE
|
|
48
|
+
from gcal.client import CalendarAPIError, CalendarAuthError
|
|
49
|
+
from gcal.models import CalendarEvent
|
|
50
|
+
from services.calendar_backend import (
|
|
51
|
+
active_provider,
|
|
52
|
+
create_event as backend_create_event,
|
|
53
|
+
delete_event as backend_delete_event,
|
|
54
|
+
list_event_views,
|
|
55
|
+
sync_local_events,
|
|
56
|
+
)
|
|
57
|
+
from services.conflict_detector import ConflictPair, detect_conflicts
|
|
58
|
+
from services.time_window import get_today_window
|
|
59
|
+
from services.datetime_utils import (
|
|
60
|
+
DateTimeValidationError,
|
|
61
|
+
build_event_range,
|
|
62
|
+
current_date_str,
|
|
63
|
+
current_year,
|
|
64
|
+
local_date_label,
|
|
65
|
+
local_date_window,
|
|
66
|
+
now_local,
|
|
67
|
+
parse_iso_datetime,
|
|
68
|
+
)
|
|
69
|
+
from services.job_store import append_job_if_absent, list_job_names
|
|
70
|
+
from services.google_integration import (
|
|
71
|
+
complete_oauth_callback,
|
|
72
|
+
get_guide_payload,
|
|
73
|
+
get_last_sync_status,
|
|
74
|
+
get_status_payload,
|
|
75
|
+
start_oauth_session,
|
|
76
|
+
)
|
|
77
|
+
from services.runtime_utils import build_python_command
|
|
78
|
+
from apps.check_roc import build_year_events, upcoming_events, _load_config as _roc_config
|
|
79
|
+
|
|
80
|
+
from api.models import (
|
|
81
|
+
ConflictOut, DailyPlanResponse, EventCreateRequest, EventCreateResponse,
|
|
82
|
+
EventDeleteResponse, EventOut, EventsResponse, OkResponse,
|
|
83
|
+
GoogleGuideResponse, GoogleStartRequest, GoogleStartResponse,
|
|
84
|
+
GoogleStatusResponse, GoogleSyncResponse, GoogleSyncSummary,
|
|
85
|
+
RemindersResponse, RocEventCreateRequest, RocEventOut, RocEventUpdateRequest,
|
|
86
|
+
RocListResponse, RocUpcomingItem, RocUpcomingResponse,
|
|
87
|
+
TaskItem, TasksResponse, TaskSyncResponse,
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
# ── 应用初始化 ────────────────────────────────────────────────────────
|
|
91
|
+
|
|
92
|
+
app = FastAPI(
|
|
93
|
+
title="Sophnet 日程提醒 API",
|
|
94
|
+
description="Google Calendar 日程调度 + ROC 周期事件 HTTP 接口",
|
|
95
|
+
version="1.0.0",
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
app.add_middleware(
|
|
99
|
+
CORSMiddleware,
|
|
100
|
+
allow_origins=["*"], # 生产环境请限定前端域名
|
|
101
|
+
allow_methods=["*"],
|
|
102
|
+
allow_headers=["*"],
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
_ROC_CONFIG_FILE = SKILL_BASE / "config" / "roc_events.yaml"
|
|
106
|
+
_API_KEY = os.environ.get("API_KEY", "dev")
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
# ── 认证 ──────────────────────────────────────────────────────────────
|
|
110
|
+
|
|
111
|
+
def _auth(x_api_key: Optional[str] = Header(None, alias="X-API-Key")) -> None:
|
|
112
|
+
if x_api_key is None or (_API_KEY != "dev" and x_api_key != _API_KEY):
|
|
113
|
+
raise HTTPException(status_code=401, detail="Invalid API key")
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
# ── 内部工具 ──────────────────────────────────────────────────────────
|
|
117
|
+
|
|
118
|
+
def _event_out(ev: CalendarEvent, provider: str = "", sync_state: str = "") -> EventOut:
|
|
119
|
+
return EventOut(
|
|
120
|
+
id=ev.id,
|
|
121
|
+
summary=ev.summary,
|
|
122
|
+
start=ev.start.isoformat(),
|
|
123
|
+
end=ev.end.isoformat(),
|
|
124
|
+
is_all_day=ev.is_all_day,
|
|
125
|
+
location=ev.location,
|
|
126
|
+
description=ev.description,
|
|
127
|
+
status=ev.status,
|
|
128
|
+
duration_minutes=ev.duration_minutes(),
|
|
129
|
+
provider=provider,
|
|
130
|
+
sync_state=sync_state,
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def _conflict_out(cp: ConflictPair) -> ConflictOut:
|
|
135
|
+
ta = f"{cp.a.start.strftime('%H:%M')}–{cp.a.end.strftime('%H:%M')}"
|
|
136
|
+
tb = f"{cp.b.start.strftime('%H:%M')}–{cp.b.end.strftime('%H:%M')}"
|
|
137
|
+
gap = int((cp.b.start - cp.a.end).total_seconds() / 60) if cp.is_tight else 0
|
|
138
|
+
return ConflictOut(
|
|
139
|
+
type="tight" if cp.is_tight else "conflict",
|
|
140
|
+
event_a=cp.a.summary,
|
|
141
|
+
event_b=cp.b.summary,
|
|
142
|
+
time_a=ta,
|
|
143
|
+
time_b=tb,
|
|
144
|
+
overlap_minutes=cp.overlap_minutes,
|
|
145
|
+
gap_minutes=gap,
|
|
146
|
+
text=cp.format_text(),
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def _parse_date_window(date: str) -> tuple[datetime, datetime]:
|
|
151
|
+
"""将 YYYY-MM-DD 转为业务时区当日区间。"""
|
|
152
|
+
try:
|
|
153
|
+
return local_date_window(date, TIMEZONE)
|
|
154
|
+
except DateTimeValidationError as e:
|
|
155
|
+
raise HTTPException(400, str(e))
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def _read_roc_yaml() -> dict:
|
|
159
|
+
with open(_ROC_CONFIG_FILE, encoding="utf-8") as f:
|
|
160
|
+
return yaml.safe_load(f)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def _write_roc_yaml(data: dict) -> None:
|
|
164
|
+
with open(_ROC_CONFIG_FILE, "w", encoding="utf-8") as f:
|
|
165
|
+
yaml.dump(data, f, allow_unicode=True, sort_keys=False)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def _callback_url(request: Request) -> str:
|
|
169
|
+
return str(request.base_url).rstrip("/") + "/integrations/google/callback"
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def _callback_html(ok: bool, message: str) -> HTMLResponse:
|
|
173
|
+
title = "授权成功" if ok else "授权失败"
|
|
174
|
+
color = "#1b7f3b" if ok else "#b42318"
|
|
175
|
+
body = (
|
|
176
|
+
"<!doctype html><html><head><meta charset='utf-8'>"
|
|
177
|
+
f"<title>{title}</title></head>"
|
|
178
|
+
"<body style='font-family:sans-serif;padding:32px'>"
|
|
179
|
+
f"<h2 style='color:{color}'>{title}</h2>"
|
|
180
|
+
f"<p>{message}</p>"
|
|
181
|
+
"<p>现在可以关闭这个窗口。</p>"
|
|
182
|
+
"</body></html>"
|
|
183
|
+
)
|
|
184
|
+
return HTMLResponse(body, status_code=200 if ok else 400)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
# ── 健康检查 ──────────────────────────────────────────────────────────
|
|
188
|
+
|
|
189
|
+
@app.get("/health", tags=["系统"])
|
|
190
|
+
def health() -> dict:
|
|
191
|
+
return {"ok": True, "service": "sophnet-schedule", "version": "1.0.0"}
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
# ── 日历事件 ──────────────────────────────────────────────────────────
|
|
195
|
+
|
|
196
|
+
@app.get("/events", response_model=EventsResponse, tags=["日历"])
|
|
197
|
+
def list_events(
|
|
198
|
+
date: Optional[str] = Query(None, description="YYYY-MM-DD,查询当日"),
|
|
199
|
+
start: Optional[str] = Query(None, description="ISO 8601 开始时间"),
|
|
200
|
+
end: Optional[str] = Query(None, description="ISO 8601 结束时间"),
|
|
201
|
+
_: None = Depends(_auth),
|
|
202
|
+
) -> EventsResponse:
|
|
203
|
+
if date:
|
|
204
|
+
t_start, t_end = _parse_date_window(date)
|
|
205
|
+
label = date
|
|
206
|
+
elif start and end:
|
|
207
|
+
try:
|
|
208
|
+
t_start = parse_iso_datetime(start, TIMEZONE)
|
|
209
|
+
t_end = parse_iso_datetime(end, TIMEZONE)
|
|
210
|
+
except DateTimeValidationError as e:
|
|
211
|
+
raise HTTPException(400, str(e))
|
|
212
|
+
if t_end <= t_start:
|
|
213
|
+
raise HTTPException(400, "end 必须晚于 start")
|
|
214
|
+
label = local_date_label(t_start, TIMEZONE)
|
|
215
|
+
else:
|
|
216
|
+
t_start, t_end = get_today_window(TIMEZONE)
|
|
217
|
+
label = current_date_str(TIMEZONE)
|
|
218
|
+
|
|
219
|
+
try:
|
|
220
|
+
views = list_event_views(t_start, t_end)
|
|
221
|
+
except (CalendarAuthError, CalendarAPIError) as e:
|
|
222
|
+
raise HTTPException(502, str(e))
|
|
223
|
+
|
|
224
|
+
events = [item.event for item in views]
|
|
225
|
+
conflicts = detect_conflicts(events)
|
|
226
|
+
provider = active_provider()
|
|
227
|
+
return EventsResponse(
|
|
228
|
+
date=label,
|
|
229
|
+
events=[_event_out(item.event, provider=item.provider, sync_state=item.sync_state) for item in views],
|
|
230
|
+
conflicts=[_conflict_out(c) for c in conflicts],
|
|
231
|
+
provider=provider,
|
|
232
|
+
active_mode=provider,
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
@app.post("/events", response_model=EventCreateResponse, tags=["日历"])
|
|
237
|
+
def create_event(
|
|
238
|
+
body: EventCreateRequest,
|
|
239
|
+
_: None = Depends(_auth),
|
|
240
|
+
) -> EventCreateResponse:
|
|
241
|
+
try:
|
|
242
|
+
start_dt, end_dt = build_event_range(
|
|
243
|
+
body.date,
|
|
244
|
+
body.start,
|
|
245
|
+
body.end,
|
|
246
|
+
body.duration,
|
|
247
|
+
TIMEZONE,
|
|
248
|
+
)
|
|
249
|
+
except DateTimeValidationError as e:
|
|
250
|
+
raise HTTPException(400, str(e))
|
|
251
|
+
|
|
252
|
+
try:
|
|
253
|
+
created = backend_create_event(
|
|
254
|
+
summary=body.summary,
|
|
255
|
+
start=start_dt,
|
|
256
|
+
end=end_dt,
|
|
257
|
+
location=body.location,
|
|
258
|
+
description=body.description,
|
|
259
|
+
remind_minutes=body.remind,
|
|
260
|
+
)
|
|
261
|
+
except (CalendarAuthError, CalendarAPIError) as e:
|
|
262
|
+
return EventCreateResponse(ok=False, error=str(e), provider=active_provider())
|
|
263
|
+
|
|
264
|
+
reminder_registered = False
|
|
265
|
+
if body.remind > 0 and created.event_id:
|
|
266
|
+
try:
|
|
267
|
+
_register_one_off_reminder(body, start_dt, created.event_id)
|
|
268
|
+
reminder_registered = True
|
|
269
|
+
except Exception:
|
|
270
|
+
pass # 提醒注册失败不影响事件创建结果
|
|
271
|
+
|
|
272
|
+
return EventCreateResponse(
|
|
273
|
+
ok=True,
|
|
274
|
+
event_id=created.event_id,
|
|
275
|
+
summary=body.summary,
|
|
276
|
+
start=start_dt.isoformat(),
|
|
277
|
+
end=end_dt.isoformat(),
|
|
278
|
+
reminder_registered=reminder_registered,
|
|
279
|
+
provider=created.provider,
|
|
280
|
+
sync_state=created.sync_state,
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
@app.delete("/events/{event_id}", response_model=EventDeleteResponse, tags=["日历"])
|
|
285
|
+
def delete_event(
|
|
286
|
+
event_id: str,
|
|
287
|
+
_: None = Depends(_auth),
|
|
288
|
+
) -> EventDeleteResponse:
|
|
289
|
+
try:
|
|
290
|
+
deleted = backend_delete_event(event_id)
|
|
291
|
+
if not deleted:
|
|
292
|
+
return EventDeleteResponse(ok=False, event_id=event_id, error="事件不存在")
|
|
293
|
+
return EventDeleteResponse(ok=True, event_id=event_id)
|
|
294
|
+
except (CalendarAuthError, CalendarAPIError) as e:
|
|
295
|
+
return EventDeleteResponse(ok=False, event_id=event_id, error=str(e))
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
@app.get("/events/conflicts", response_model=EventsResponse, tags=["日历"])
|
|
299
|
+
def get_conflicts(
|
|
300
|
+
date: Optional[str] = Query(None, description="YYYY-MM-DD,默认今日"),
|
|
301
|
+
_: None = Depends(_auth),
|
|
302
|
+
) -> EventsResponse:
|
|
303
|
+
return list_events(date=date, start=None, end=None, _=_)
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
# ── ROC 周期事件 ──────────────────────────────────────────────────────
|
|
307
|
+
|
|
308
|
+
@app.get("/roc/events", response_model=RocListResponse, tags=["ROC"])
|
|
309
|
+
def roc_list(
|
|
310
|
+
year: Optional[int] = Query(None, description="年份,默认今年"),
|
|
311
|
+
_: None = Depends(_auth),
|
|
312
|
+
) -> RocListResponse:
|
|
313
|
+
y = year or current_year(TIMEZONE)
|
|
314
|
+
cfg = _read_roc_yaml()
|
|
315
|
+
year_events = build_year_events(y, cfg)
|
|
316
|
+
|
|
317
|
+
ev_map = {e["id"]: e for e in year_events}
|
|
318
|
+
result = []
|
|
319
|
+
for raw in cfg.get("events", []):
|
|
320
|
+
ye = ev_map.get(raw["id"], {})
|
|
321
|
+
result.append(RocEventOut(
|
|
322
|
+
id=raw["id"],
|
|
323
|
+
name=raw["name"],
|
|
324
|
+
rule=raw["rule"],
|
|
325
|
+
reminder_time=raw.get("reminder_time", "09:00"),
|
|
326
|
+
lead_days=int(raw.get("lead_days", 0)),
|
|
327
|
+
description=raw.get("description", ""),
|
|
328
|
+
event_date=ye.get("event_date"),
|
|
329
|
+
reminder_date=ye.get("reminder_date"),
|
|
330
|
+
))
|
|
331
|
+
return RocListResponse(year=y, events=result)
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
@app.post("/roc/events", response_model=OkResponse, tags=["ROC"])
|
|
335
|
+
def roc_create(
|
|
336
|
+
body: RocEventCreateRequest,
|
|
337
|
+
_: None = Depends(_auth),
|
|
338
|
+
) -> OkResponse:
|
|
339
|
+
cfg = _read_roc_yaml()
|
|
340
|
+
events: list = cfg.get("events", [])
|
|
341
|
+
if any(e["id"] == body.id for e in events):
|
|
342
|
+
raise HTTPException(409, f"ROC 事件 ID 已存在:{body.id}")
|
|
343
|
+
events.append({
|
|
344
|
+
"id": body.id,
|
|
345
|
+
"name": body.name,
|
|
346
|
+
"rule": body.rule,
|
|
347
|
+
"reminder_time": body.reminder_time,
|
|
348
|
+
"lead_days": body.lead_days,
|
|
349
|
+
"description": body.description,
|
|
350
|
+
})
|
|
351
|
+
cfg["events"] = events
|
|
352
|
+
_write_roc_yaml(cfg)
|
|
353
|
+
return OkResponse(id=body.id, message=f"已添加 ROC 事件:{body.name}")
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
@app.put("/roc/events/{roc_id}", response_model=OkResponse, tags=["ROC"])
|
|
357
|
+
def roc_update(
|
|
358
|
+
roc_id: str,
|
|
359
|
+
body: RocEventUpdateRequest,
|
|
360
|
+
_: None = Depends(_auth),
|
|
361
|
+
) -> OkResponse:
|
|
362
|
+
cfg = _read_roc_yaml()
|
|
363
|
+
events: list = cfg.get("events", [])
|
|
364
|
+
for ev in events:
|
|
365
|
+
if ev["id"] == roc_id:
|
|
366
|
+
if body.name is not None: ev["name"] = body.name
|
|
367
|
+
if body.rule is not None: ev["rule"] = body.rule
|
|
368
|
+
if body.reminder_time is not None: ev["reminder_time"] = body.reminder_time
|
|
369
|
+
if body.lead_days is not None: ev["lead_days"] = body.lead_days
|
|
370
|
+
if body.description is not None: ev["description"] = body.description
|
|
371
|
+
cfg["events"] = events
|
|
372
|
+
_write_roc_yaml(cfg)
|
|
373
|
+
return OkResponse(message=f"已更新 ROC 事件:{roc_id}")
|
|
374
|
+
raise HTTPException(404, f"ROC 事件不存在:{roc_id}")
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
@app.delete("/roc/events/{roc_id}", response_model=OkResponse, tags=["ROC"])
|
|
378
|
+
def roc_delete(
|
|
379
|
+
roc_id: str,
|
|
380
|
+
_: None = Depends(_auth),
|
|
381
|
+
) -> OkResponse:
|
|
382
|
+
cfg = _read_roc_yaml()
|
|
383
|
+
events: list = cfg.get("events", [])
|
|
384
|
+
new_events = [e for e in events if e["id"] != roc_id]
|
|
385
|
+
if len(new_events) == len(events):
|
|
386
|
+
raise HTTPException(404, f"ROC 事件不存在:{roc_id}")
|
|
387
|
+
cfg["events"] = new_events
|
|
388
|
+
_write_roc_yaml(cfg)
|
|
389
|
+
return OkResponse(message=f"已删除 ROC 事件:{roc_id}")
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
@app.get("/roc/upcoming", response_model=RocUpcomingResponse, tags=["ROC"])
|
|
393
|
+
def roc_upcoming(
|
|
394
|
+
days: int = Query(30, description="查询未来 N 天"),
|
|
395
|
+
_: None = Depends(_auth),
|
|
396
|
+
) -> RocUpcomingResponse:
|
|
397
|
+
today = current_date_str(TIMEZONE)
|
|
398
|
+
year = int(today[:4])
|
|
399
|
+
cfg = _read_roc_yaml()
|
|
400
|
+
year_events = build_year_events(year, cfg)
|
|
401
|
+
ups = upcoming_events(year_events, today, days)
|
|
402
|
+
return RocUpcomingResponse(
|
|
403
|
+
today=today,
|
|
404
|
+
days=days,
|
|
405
|
+
upcoming=[RocUpcomingItem(**{
|
|
406
|
+
"id": u["id"],
|
|
407
|
+
"name": u["name"],
|
|
408
|
+
"event_date": u["event_date"],
|
|
409
|
+
"reminder_date": u["reminder_date"],
|
|
410
|
+
"days_until_reminder": u["days_until_reminder"],
|
|
411
|
+
"days_until_event": u["days_until_event"],
|
|
412
|
+
"description": u.get("description", ""),
|
|
413
|
+
}) for u in ups],
|
|
414
|
+
)
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
# ── 提醒 ──────────────────────────────────────────────────────────────
|
|
418
|
+
|
|
419
|
+
@app.get("/reminders", response_model=RemindersResponse, tags=["提醒"])
|
|
420
|
+
def get_reminders(
|
|
421
|
+
window: int = Query(30, description="时间窗口(分钟),默认 30"),
|
|
422
|
+
_: None = Depends(_auth),
|
|
423
|
+
) -> RemindersResponse:
|
|
424
|
+
result = subprocess.run(
|
|
425
|
+
build_python_command(SKILL_BASE / "apps" / "check_reminders.py", "--window", str(window), "--json"),
|
|
426
|
+
capture_output=True, text=True, cwd=str(SKILL_BASE),
|
|
427
|
+
)
|
|
428
|
+
if result.returncode != 0:
|
|
429
|
+
detail = result.stderr.strip() or result.stdout.strip() or "检查提醒失败"
|
|
430
|
+
raise HTTPException(502, detail[:300])
|
|
431
|
+
|
|
432
|
+
import json as _json
|
|
433
|
+
try:
|
|
434
|
+
data = _json.loads(result.stdout)
|
|
435
|
+
except Exception as e:
|
|
436
|
+
raise HTTPException(502, f"提醒结果解析失败:{e}")
|
|
437
|
+
|
|
438
|
+
if not data.get("ok", True):
|
|
439
|
+
raise HTTPException(502, data.get("error", "提醒检查失败"))
|
|
440
|
+
|
|
441
|
+
provider = active_provider()
|
|
442
|
+
return RemindersResponse(
|
|
443
|
+
window_minutes=window,
|
|
444
|
+
reminders=data.get("reminders", []),
|
|
445
|
+
provider=provider,
|
|
446
|
+
active_mode=provider,
|
|
447
|
+
)
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
# ── Cron 任务 ─────────────────────────────────────────────────────────
|
|
451
|
+
|
|
452
|
+
@app.get("/tasks", response_model=TasksResponse, tags=["任务"])
|
|
453
|
+
def list_tasks(_: None = Depends(_auth)) -> TasksResponse:
|
|
454
|
+
with open(TASK_REGISTRY_FILE, encoding="utf-8") as f:
|
|
455
|
+
cfg = yaml.safe_load(f)
|
|
456
|
+
tasks = []
|
|
457
|
+
for t in cfg.get("tasks", []):
|
|
458
|
+
sch = t.get("schedule", {})
|
|
459
|
+
tasks.append(TaskItem(
|
|
460
|
+
name=t["name"],
|
|
461
|
+
description=t.get("description", ""),
|
|
462
|
+
schedule_kind=sch.get("kind", ""),
|
|
463
|
+
schedule_expr=sch.get("time") or sch.get("expr") or "",
|
|
464
|
+
type=t.get("type", ""),
|
|
465
|
+
))
|
|
466
|
+
return TasksResponse(tasks=tasks)
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
@app.post("/tasks/trigger/daily-plan", response_model=OkResponse, tags=["任务"])
|
|
470
|
+
def trigger_daily_plan(
|
|
471
|
+
dry_run: bool = Query(False),
|
|
472
|
+
_: None = Depends(_auth),
|
|
473
|
+
) -> OkResponse:
|
|
474
|
+
cmd = build_python_command(SKILL_BASE / "apps" / "generate_daily_plan.py")
|
|
475
|
+
if dry_run:
|
|
476
|
+
cmd.append("--dry-run")
|
|
477
|
+
result = subprocess.run(cmd, capture_output=True, text=True, cwd=str(SKILL_BASE))
|
|
478
|
+
if result.returncode != 0:
|
|
479
|
+
raise HTTPException(500, f"生成失败:{result.stderr[:200]}")
|
|
480
|
+
return OkResponse(message="今日计划已生成" + ("(dry-run)" if dry_run else ",提醒已注册"))
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
@app.post("/tasks/sync", response_model=TaskSyncResponse, tags=["任务"])
|
|
484
|
+
def sync_tasks(
|
|
485
|
+
dry_run: bool = Query(False),
|
|
486
|
+
_: None = Depends(_auth),
|
|
487
|
+
) -> TaskSyncResponse:
|
|
488
|
+
"""
|
|
489
|
+
重读 task_registry.yaml 并立即同步到 jobs.json。
|
|
490
|
+
|
|
491
|
+
- 已存在同名任务:跳过(不覆盖)
|
|
492
|
+
- 新任务:写入 jobs.json,当天生效
|
|
493
|
+
- dry_run=true:只计算差异,不写入
|
|
494
|
+
"""
|
|
495
|
+
import json as _json
|
|
496
|
+
from apps.register_tasks import load_fixed_tasks, build_cron_job_from_task
|
|
497
|
+
|
|
498
|
+
today = now_local(TIMEZONE)
|
|
499
|
+
|
|
500
|
+
try:
|
|
501
|
+
tasks = load_fixed_tasks(provider=active_provider())
|
|
502
|
+
except Exception as e:
|
|
503
|
+
raise HTTPException(500, f"读取 task_registry.yaml 失败:{e}")
|
|
504
|
+
|
|
505
|
+
try:
|
|
506
|
+
existing = list_job_names()
|
|
507
|
+
except Exception as e:
|
|
508
|
+
raise HTTPException(500, f"读取 jobs.json 失败:{e}")
|
|
509
|
+
added: list = []
|
|
510
|
+
skipped: list = []
|
|
511
|
+
errors: list = []
|
|
512
|
+
|
|
513
|
+
for task in tasks:
|
|
514
|
+
name = task.get("name", "未命名")
|
|
515
|
+
try:
|
|
516
|
+
payload = build_cron_job_from_task(task, today)
|
|
517
|
+
if payload is None:
|
|
518
|
+
errors.append(f"{name}:配置不完整,跳过")
|
|
519
|
+
continue
|
|
520
|
+
if dry_run and name in existing:
|
|
521
|
+
skipped.append(name)
|
|
522
|
+
continue
|
|
523
|
+
if dry_run:
|
|
524
|
+
existing.add(name)
|
|
525
|
+
added.append(name)
|
|
526
|
+
continue
|
|
527
|
+
if append_job_if_absent(payload):
|
|
528
|
+
existing.add(name)
|
|
529
|
+
added.append(name)
|
|
530
|
+
else:
|
|
531
|
+
skipped.append(name)
|
|
532
|
+
except Exception as e:
|
|
533
|
+
errors.append(f"{name}:{e}")
|
|
534
|
+
|
|
535
|
+
suffix = "(dry-run,未写入)" if dry_run else ""
|
|
536
|
+
return TaskSyncResponse(
|
|
537
|
+
ok=True,
|
|
538
|
+
dry_run=dry_run,
|
|
539
|
+
added=added,
|
|
540
|
+
skipped=skipped,
|
|
541
|
+
errors=errors,
|
|
542
|
+
message=f"同步完成{suffix}:新增 {len(added)} 个,跳过 {len(skipped)} 个,失败 {len(errors)} 个",
|
|
543
|
+
)
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
# ── 日报 ──────────────────────────────────────────────────────────────
|
|
547
|
+
|
|
548
|
+
@app.get("/daily-plan", response_model=DailyPlanResponse, tags=["日报"])
|
|
549
|
+
def get_daily_plan(
|
|
550
|
+
date: Optional[str] = Query(None, description="YYYY-MM-DD,默认今日"),
|
|
551
|
+
_: None = Depends(_auth),
|
|
552
|
+
) -> DailyPlanResponse:
|
|
553
|
+
label = date or current_date_str(TIMEZONE)
|
|
554
|
+
t_start, t_end = _parse_date_window(label)
|
|
555
|
+
|
|
556
|
+
try:
|
|
557
|
+
views = list_event_views(t_start, t_end)
|
|
558
|
+
except (CalendarAuthError, CalendarAPIError) as e:
|
|
559
|
+
raise HTTPException(502, str(e))
|
|
560
|
+
|
|
561
|
+
events = [item.event for item in views]
|
|
562
|
+
conflicts = detect_conflicts(events)
|
|
563
|
+
|
|
564
|
+
# 尝试读取已生成的日报 Markdown
|
|
565
|
+
md_path = SKILL_BASE / "daily" / f"cron-{label.replace('-', '')}.md"
|
|
566
|
+
markdown = md_path.read_text(encoding="utf-8") if md_path.exists() else ""
|
|
567
|
+
|
|
568
|
+
return DailyPlanResponse(
|
|
569
|
+
date=label,
|
|
570
|
+
events=[_event_out(item.event, provider=item.provider, sync_state=item.sync_state) for item in views],
|
|
571
|
+
conflicts=[_conflict_out(c) for c in conflicts],
|
|
572
|
+
reminders_registered=0, # 只读接口,不注册
|
|
573
|
+
markdown=markdown,
|
|
574
|
+
provider=active_provider(),
|
|
575
|
+
)
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
# ── Google 接入 ──────────────────────────────────────────────────────
|
|
579
|
+
|
|
580
|
+
@app.get("/integrations/google/status", response_model=GoogleStatusResponse, tags=["集成"])
|
|
581
|
+
def google_status(_: None = Depends(_auth)) -> GoogleStatusResponse:
|
|
582
|
+
return GoogleStatusResponse(**get_status_payload())
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
@app.get("/integrations/google/guide", response_model=GoogleGuideResponse, tags=["集成"])
|
|
586
|
+
def google_guide(
|
|
587
|
+
request: Request,
|
|
588
|
+
_: None = Depends(_auth),
|
|
589
|
+
) -> GoogleGuideResponse:
|
|
590
|
+
return GoogleGuideResponse(**get_guide_payload(_callback_url(request)))
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
@app.post("/integrations/google/start", response_model=GoogleStartResponse, tags=["集成"])
|
|
594
|
+
def google_start(
|
|
595
|
+
body: GoogleStartRequest,
|
|
596
|
+
request: Request,
|
|
597
|
+
_: None = Depends(_auth),
|
|
598
|
+
) -> GoogleStartResponse:
|
|
599
|
+
result = start_oauth_session(
|
|
600
|
+
client_id=body.client_id,
|
|
601
|
+
client_secret=body.client_secret,
|
|
602
|
+
redirect_uri=_callback_url(request),
|
|
603
|
+
)
|
|
604
|
+
return GoogleStartResponse(**result)
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
@app.get("/integrations/google/callback", response_class=HTMLResponse, tags=["集成"])
|
|
608
|
+
def google_callback(
|
|
609
|
+
state: str,
|
|
610
|
+
code: Optional[str] = Query(None),
|
|
611
|
+
error: Optional[str] = Query(None),
|
|
612
|
+
error_description: Optional[str] = Query(None),
|
|
613
|
+
) -> HTMLResponse:
|
|
614
|
+
try:
|
|
615
|
+
complete_oauth_callback(state, code, error, error_description)
|
|
616
|
+
return _callback_html(True, "Google 授权成功,已保存凭据,下一步可执行首次同步。")
|
|
617
|
+
except CalendarAuthError as e:
|
|
618
|
+
return _callback_html(False, str(e))
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
@app.post("/integrations/google/sync", response_model=GoogleSyncResponse, tags=["集成"])
|
|
622
|
+
def google_sync(_: None = Depends(_auth)) -> GoogleSyncResponse:
|
|
623
|
+
try:
|
|
624
|
+
summary = sync_local_events()
|
|
625
|
+
except (CalendarAuthError, CalendarAPIError) as e:
|
|
626
|
+
raise HTTPException(502, str(e))
|
|
627
|
+
|
|
628
|
+
status = get_status_payload()
|
|
629
|
+
return GoogleSyncResponse(
|
|
630
|
+
active_mode=status["active_mode"],
|
|
631
|
+
google_state=status["google_state"],
|
|
632
|
+
summary=GoogleSyncSummary(**summary),
|
|
633
|
+
)
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
@app.get("/integrations/google/sync-status", response_model=GoogleSyncSummary, tags=["集成"])
|
|
637
|
+
def google_sync_status(_: None = Depends(_auth)) -> GoogleSyncSummary:
|
|
638
|
+
return GoogleSyncSummary(**get_last_sync_status())
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
# ── 内部:提醒注册 ────────────────────────────────────────────────────
|
|
642
|
+
|
|
643
|
+
def _register_one_off_reminder(
|
|
644
|
+
body: EventCreateRequest,
|
|
645
|
+
start_dt: datetime,
|
|
646
|
+
event_id: str,
|
|
647
|
+
) -> None:
|
|
648
|
+
"""直接用 task_builder 注册提醒 cron job,不再调用 add_event.py(避免重复创建事件)。"""
|
|
649
|
+
from datetime import timezone as _tz
|
|
650
|
+
from services.task_builder import build_reminder_task, build_reminder_task_name
|
|
651
|
+
from compat import make_aware
|
|
652
|
+
|
|
653
|
+
start_aware = make_aware(start_dt, TIMEZONE)
|
|
654
|
+
remind_at_utc = (start_aware - timedelta(minutes=body.remind)).astimezone(_tz.utc)
|
|
655
|
+
name = build_reminder_task_name(body.summary, start_aware, event_id)
|
|
656
|
+
payload = build_reminder_task(
|
|
657
|
+
name=name,
|
|
658
|
+
remind_at_utc=remind_at_utc,
|
|
659
|
+
message=(
|
|
660
|
+
f"⏰ **{body.summary}** 将在 {body.remind} 分钟后开始\n"
|
|
661
|
+
f"🕐 {start_dt.strftime('%H:%M')}"
|
|
662
|
+
+ (f" 📍 {body.location}" if body.location else "")
|
|
663
|
+
),
|
|
664
|
+
)
|
|
665
|
+
|
|
666
|
+
try:
|
|
667
|
+
append_job_if_absent(payload)
|
|
668
|
+
except Exception:
|
|
669
|
+
pass # jobs.json 不存在时静默忽略
|