@geoly-ai/social-hub-cli 0.3.52 → 0.3.53

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.
Files changed (31) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cmd-manifest.json +9 -2
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +4 -0
  5. package/dist/index.js.map +1 -1
  6. package/dist/register-calendar-directives.d.ts +1 -1
  7. package/dist/register-calendar-directives.d.ts.map +1 -1
  8. package/dist/register-calendar-directives.js +5 -1
  9. package/dist/register-calendar-directives.js.map +1 -1
  10. package/dist/register-calendar-publication.d.ts +8 -0
  11. package/dist/register-calendar-publication.d.ts.map +1 -0
  12. package/dist/register-calendar-publication.js +71 -0
  13. package/dist/register-calendar-publication.js.map +1 -0
  14. package/dist/register-calendar-publication.test.d.ts +2 -0
  15. package/dist/register-calendar-publication.test.d.ts.map +1 -0
  16. package/dist/register-calendar-publication.test.js +159 -0
  17. package/dist/register-calendar-publication.test.js.map +1 -0
  18. package/dist/register-system-cyberredd-feed.d.ts +10 -0
  19. package/dist/register-system-cyberredd-feed.d.ts.map +1 -0
  20. package/dist/register-system-cyberredd-feed.js +26 -0
  21. package/dist/register-system-cyberredd-feed.js.map +1 -0
  22. package/dist/register-system-cyberredd-feed.test.d.ts +2 -0
  23. package/dist/register-system-cyberredd-feed.test.d.ts.map +1 -0
  24. package/dist/register-system-cyberredd-feed.test.js +51 -0
  25. package/dist/register-system-cyberredd-feed.test.js.map +1 -0
  26. package/package.json +2 -2
  27. package/skills/integrity.json +4 -4
  28. package/skills/manifest.json +1 -1
  29. package/skills/reddit-voc-volume/services/firecrawl/examples/o1_web_crawler/o1_web_crawler.py +152 -152
  30. package/skills/social-hub-intelligence/SKILL.md +17 -0
  31. package/skills/social-hub-publishing/SKILL.md +18 -0
@@ -1,152 +1,152 @@
1
- import os
2
- from firecrawl import FirecrawlApp
3
- import json
4
- from dotenv import load_dotenv
5
- from openai import OpenAI
6
-
7
- # ANSI color codes
8
- class Colors:
9
- CYAN = '\033[96m'
10
- YELLOW = '\033[93m'
11
- GREEN = '\033[92m'
12
- RED = '\033[91m'
13
- MAGENTA = '\033[95m'
14
- BLUE = '\033[94m'
15
- RESET = '\033[0m'
16
-
17
- # Load environment variables
18
- load_dotenv()
19
-
20
- # Retrieve API keys from environment variables
21
- firecrawl_api_key = os.getenv("FIRECRAWL_API_KEY")
22
- openai_api_key = os.getenv("OPENAI_API_KEY")
23
-
24
- # Initialize the FirecrawlApp and OpenAI client
25
- app = FirecrawlApp(api_key=firecrawl_api_key)
26
- client = OpenAI(api_key=openai_api_key)
27
-
28
- # Find the page that most likely contains the objective
29
- def find_relevant_page_via_map(objective, url, app, client):
30
- try:
31
- print(f"{Colors.CYAN}Understood. The objective is: {objective}{Colors.RESET}")
32
- print(f"{Colors.CYAN}Initiating search on the website: {url}{Colors.RESET}")
33
-
34
- map_prompt = f"""
35
- The map function generates a list of URLs from a website and it accepts a search parameter. Based on the objective of: {objective}, come up with a 1-2 word search parameter that will help us find the information we need. Only respond with 1-2 words nothing else.
36
- """
37
-
38
- print(f"{Colors.YELLOW}Analyzing objective to determine optimal search parameter...{Colors.RESET}")
39
- completion = client.chat.completions.create(
40
- model="o1-preview",
41
- messages=[
42
- {
43
- "role": "user",
44
- "content": [
45
- {
46
- "type": "text",
47
- "text": map_prompt
48
- }
49
- ]
50
- }
51
- ]
52
- )
53
-
54
- map_search_parameter = completion.choices[0].message.content
55
- print(f"{Colors.GREEN}Optimal search parameter identified: {map_search_parameter}{Colors.RESET}")
56
-
57
- print(f"{Colors.YELLOW}Mapping website using the identified search parameter...{Colors.RESET}")
58
- map_website = app.map_url(url, params={"search": map_search_parameter})
59
- print(f"{Colors.GREEN}Website mapping completed successfully.{Colors.RESET}")
60
- print(f"{Colors.GREEN}Located {len(map_website)} relevant links.{Colors.RESET}")
61
- return map_website
62
- except Exception as e:
63
- print(f"{Colors.RED}Error encountered during relevant page identification: {str(e)}{Colors.RESET}")
64
- return None
65
-
66
- # Scrape the top 3 pages and see if the objective is met, if so return in json format else return None
67
- def find_objective_in_top_pages(map_website, objective, app, client):
68
- try:
69
- # Get top 3 links from the map result
70
- top_links = map_website[:3] if isinstance(map_website, list) else []
71
- print(f"{Colors.CYAN}Proceeding to analyze top {len(top_links)} links: {top_links}{Colors.RESET}")
72
-
73
- for link in top_links:
74
- print(f"{Colors.YELLOW}Initiating scrape of page: {link}{Colors.RESET}")
75
- # Scrape the page
76
- scrape_result = app.scrape_url(link, params={'formats': ['markdown']})
77
- print(f"{Colors.GREEN}Page scraping completed successfully.{Colors.RESET}")
78
-
79
-
80
- # Check if objective is met
81
- check_prompt = f"""
82
- Given the following scraped content and objective, determine if the objective is met.
83
- If it is, extract the relevant information in a simple and concise JSON format. Use only the necessary fields and avoid nested structures if possible.
84
- If the objective is not met with confidence, respond with 'Objective not met'.
85
-
86
- Objective: {objective}
87
- Scraped content: {scrape_result['markdown']}
88
-
89
- Remember:
90
- 1. Only return JSON if you are confident the objective is fully met.
91
- 2. Keep the JSON structure as simple and flat as possible.
92
- 3. Do not include any explanations or markdown formatting in your response.
93
- """
94
-
95
- completion = client.chat.completions.create(
96
- model="o1-preview",
97
- messages=[
98
- {
99
- "role": "user",
100
- "content": [
101
- {
102
- "type": "text",
103
- "text": check_prompt
104
- }
105
- ]
106
- }
107
- ]
108
- )
109
-
110
- result = completion.choices[0].message.content
111
-
112
- if result != "Objective not met":
113
- print(f"{Colors.GREEN}Objective potentially fulfilled. Relevant information identified.{Colors.RESET}")
114
- try:
115
- return json.loads(result)
116
- except json.JSONDecodeError:
117
- print(f"{Colors.RED}Error in parsing response. Proceeding to next page...{Colors.RESET}")
118
- else:
119
- print(f"{Colors.YELLOW}Objective not met on this page. Proceeding to next link...{Colors.RESET}")
120
-
121
- print(f"{Colors.RED}All available pages analyzed. Objective not fulfilled in examined content.{Colors.RESET}")
122
- return None
123
-
124
- except Exception as e:
125
- print(f"{Colors.RED}Error encountered during page analysis: {str(e)}{Colors.RESET}")
126
- return None
127
-
128
- # Main function to execute the process
129
- def main():
130
- # Get user input
131
- url = input(f"{Colors.BLUE}Enter the website to crawl: {Colors.RESET}")
132
- objective = input(f"{Colors.BLUE}Enter your objective: {Colors.RESET}")
133
-
134
- print(f"{Colors.YELLOW}Initiating web crawling process...{Colors.RESET}")
135
- # Find the relevant page
136
- map_website = find_relevant_page_via_map(objective, url, app, client)
137
-
138
- if map_website:
139
- print(f"{Colors.GREEN}Relevant pages identified. Proceeding with detailed analysis...{Colors.RESET}")
140
- # Find objective in top pages
141
- result = find_objective_in_top_pages(map_website, objective, app, client)
142
-
143
- if result:
144
- print(f"{Colors.GREEN}Objective successfully fulfilled. Extracted information:{Colors.RESET}")
145
- print(f"{Colors.MAGENTA}{json.dumps(result, indent=2)}{Colors.RESET}")
146
- else:
147
- print(f"{Colors.RED}Unable to fulfill the objective with the available content.{Colors.RESET}")
148
- else:
149
- print(f"{Colors.RED}No relevant pages identified. Consider refining the search parameters or trying a different website.{Colors.RESET}")
150
-
151
- if __name__ == "__main__":
152
- main()
1
+ import os
2
+ from firecrawl import FirecrawlApp
3
+ import json
4
+ from dotenv import load_dotenv
5
+ from openai import OpenAI
6
+
7
+ # ANSI color codes
8
+ class Colors:
9
+ CYAN = '\033[96m'
10
+ YELLOW = '\033[93m'
11
+ GREEN = '\033[92m'
12
+ RED = '\033[91m'
13
+ MAGENTA = '\033[95m'
14
+ BLUE = '\033[94m'
15
+ RESET = '\033[0m'
16
+
17
+ # Load environment variables
18
+ load_dotenv()
19
+
20
+ # Retrieve API keys from environment variables
21
+ firecrawl_api_key = os.getenv("FIRECRAWL_API_KEY")
22
+ openai_api_key = os.getenv("OPENAI_API_KEY")
23
+
24
+ # Initialize the FirecrawlApp and OpenAI client
25
+ app = FirecrawlApp(api_key=firecrawl_api_key)
26
+ client = OpenAI(api_key=openai_api_key)
27
+
28
+ # Find the page that most likely contains the objective
29
+ def find_relevant_page_via_map(objective, url, app, client):
30
+ try:
31
+ print(f"{Colors.CYAN}Understood. The objective is: {objective}{Colors.RESET}")
32
+ print(f"{Colors.CYAN}Initiating search on the website: {url}{Colors.RESET}")
33
+
34
+ map_prompt = f"""
35
+ The map function generates a list of URLs from a website and it accepts a search parameter. Based on the objective of: {objective}, come up with a 1-2 word search parameter that will help us find the information we need. Only respond with 1-2 words nothing else.
36
+ """
37
+
38
+ print(f"{Colors.YELLOW}Analyzing objective to determine optimal search parameter...{Colors.RESET}")
39
+ completion = client.chat.completions.create(
40
+ model="o1-preview",
41
+ messages=[
42
+ {
43
+ "role": "user",
44
+ "content": [
45
+ {
46
+ "type": "text",
47
+ "text": map_prompt
48
+ }
49
+ ]
50
+ }
51
+ ]
52
+ )
53
+
54
+ map_search_parameter = completion.choices[0].message.content
55
+ print(f"{Colors.GREEN}Optimal search parameter identified: {map_search_parameter}{Colors.RESET}")
56
+
57
+ print(f"{Colors.YELLOW}Mapping website using the identified search parameter...{Colors.RESET}")
58
+ map_website = app.map_url(url, params={"search": map_search_parameter})
59
+ print(f"{Colors.GREEN}Website mapping completed successfully.{Colors.RESET}")
60
+ print(f"{Colors.GREEN}Located {len(map_website)} relevant links.{Colors.RESET}")
61
+ return map_website
62
+ except Exception as e:
63
+ print(f"{Colors.RED}Error encountered during relevant page identification: {str(e)}{Colors.RESET}")
64
+ return None
65
+
66
+ # Scrape the top 3 pages and see if the objective is met, if so return in json format else return None
67
+ def find_objective_in_top_pages(map_website, objective, app, client):
68
+ try:
69
+ # Get top 3 links from the map result
70
+ top_links = map_website[:3] if isinstance(map_website, list) else []
71
+ print(f"{Colors.CYAN}Proceeding to analyze top {len(top_links)} links: {top_links}{Colors.RESET}")
72
+
73
+ for link in top_links:
74
+ print(f"{Colors.YELLOW}Initiating scrape of page: {link}{Colors.RESET}")
75
+ # Scrape the page
76
+ scrape_result = app.scrape_url(link, params={'formats': ['markdown']})
77
+ print(f"{Colors.GREEN}Page scraping completed successfully.{Colors.RESET}")
78
+
79
+
80
+ # Check if objective is met
81
+ check_prompt = f"""
82
+ Given the following scraped content and objective, determine if the objective is met.
83
+ If it is, extract the relevant information in a simple and concise JSON format. Use only the necessary fields and avoid nested structures if possible.
84
+ If the objective is not met with confidence, respond with 'Objective not met'.
85
+
86
+ Objective: {objective}
87
+ Scraped content: {scrape_result['markdown']}
88
+
89
+ Remember:
90
+ 1. Only return JSON if you are confident the objective is fully met.
91
+ 2. Keep the JSON structure as simple and flat as possible.
92
+ 3. Do not include any explanations or markdown formatting in your response.
93
+ """
94
+
95
+ completion = client.chat.completions.create(
96
+ model="o1-preview",
97
+ messages=[
98
+ {
99
+ "role": "user",
100
+ "content": [
101
+ {
102
+ "type": "text",
103
+ "text": check_prompt
104
+ }
105
+ ]
106
+ }
107
+ ]
108
+ )
109
+
110
+ result = completion.choices[0].message.content
111
+
112
+ if result != "Objective not met":
113
+ print(f"{Colors.GREEN}Objective potentially fulfilled. Relevant information identified.{Colors.RESET}")
114
+ try:
115
+ return json.loads(result)
116
+ except json.JSONDecodeError:
117
+ print(f"{Colors.RED}Error in parsing response. Proceeding to next page...{Colors.RESET}")
118
+ else:
119
+ print(f"{Colors.YELLOW}Objective not met on this page. Proceeding to next link...{Colors.RESET}")
120
+
121
+ print(f"{Colors.RED}All available pages analyzed. Objective not fulfilled in examined content.{Colors.RESET}")
122
+ return None
123
+
124
+ except Exception as e:
125
+ print(f"{Colors.RED}Error encountered during page analysis: {str(e)}{Colors.RESET}")
126
+ return None
127
+
128
+ # Main function to execute the process
129
+ def main():
130
+ # Get user input
131
+ url = input(f"{Colors.BLUE}Enter the website to crawl: {Colors.RESET}")
132
+ objective = input(f"{Colors.BLUE}Enter your objective: {Colors.RESET}")
133
+
134
+ print(f"{Colors.YELLOW}Initiating web crawling process...{Colors.RESET}")
135
+ # Find the relevant page
136
+ map_website = find_relevant_page_via_map(objective, url, app, client)
137
+
138
+ if map_website:
139
+ print(f"{Colors.GREEN}Relevant pages identified. Proceeding with detailed analysis...{Colors.RESET}")
140
+ # Find objective in top pages
141
+ result = find_objective_in_top_pages(map_website, objective, app, client)
142
+
143
+ if result:
144
+ print(f"{Colors.GREEN}Objective successfully fulfilled. Extracted information:{Colors.RESET}")
145
+ print(f"{Colors.MAGENTA}{json.dumps(result, indent=2)}{Colors.RESET}")
146
+ else:
147
+ print(f"{Colors.RED}Unable to fulfill the objective with the available content.{Colors.RESET}")
148
+ else:
149
+ print(f"{Colors.RED}No relevant pages identified. Consider refining the search parameters or trying a different website.{Colors.RESET}")
150
+
151
+ if __name__ == "__main__":
152
+ main()
@@ -77,6 +77,23 @@ social-hub intelligence public-status
77
77
 
78
78
  窗口:`--window` 与 `--from/--to` 互斥,`--from` 含、`--to` 不含,ISO 8601 带时区,跨度 ≤366 天。
79
79
 
80
+ ### CyberRedd 增量接口状态面(只读,仅 unrestricted admin)
81
+
82
+ CyberRedd 的墓碑流 / 变更流 / ack 由 worker 的 `cyberredd-feed` cron 自动驱动(`CYBERREDD_FEED_MODE`,缺省 off),
83
+ 不对外暴露写命令;运营只看状态:
84
+
85
+ ```bash
86
+ social-hub system cyberredd-feed status
87
+ ```
88
+
89
+ 输出两条流(`tombstones` / `changes`)的相位(normal / reconciling / halted)、ack 状态、租约与到期时间、队列与墓碑计数、
90
+ 库外唯一索引是否就绪,以及 `alerts`(`index_not_ready` / `stream_halted` / `reconciling` / `lease_expired` /
91
+ `ack_due_within_12h` / `pending_ack`;空数组 = 无需关注)。**不含**游标原文与帖子正文。
92
+
93
+ 口径(务必照此对外表述):ack = **已收到并停用**,不是已全部删除。热帖行被物理删除或清洗停用,派生读路径一律排除;
94
+ 已生成的历史产物(监听报告、回放命中标题、飞书通知、风格画像生成证据、派单 payload、已送外部 LLM 的输入)保留为接受边界。
95
+ **对外不得说「已全部删除」。** 启用前必须先完成库外唯一索引,见 `docs/cyberredd-feed-runbook.md`。
96
+
80
97
  ### 什么时候用,什么时候不用
81
98
 
82
99
  - **用**:按板块 + 关键词在公开库里找帖子、估算某词在某板块窗口内的帖子量、看哪些板块在公开库可读。
@@ -91,6 +91,24 @@ social-hub drafts client-review <draft-uuid> -t <team-id> --expected-version 3
91
91
  # 422 DRAFT_HAS_NO_BRAND 草稿没有品牌,不能进客户交付;先给草稿绑品牌
92
92
  # 403 角色不足(client 恒拒,自定义权限也不能绕过)
93
93
 
94
+ # 外部人工代发(deliveryMode=external_manual;老 CLI / SDK 读到该值需先升级):
95
+ # 切模式:calendar set-delivery-mode --mode external_manual --apply(需服务端开 PUBLICATION_EXTERNAL_MANUAL_WRITE_ENABLED)。
96
+ # 人工在 Reddit 发完后登记(supervisor+)——这是「人工声明」,系统不保证 Reddit 上的内容与草稿一致:
97
+ social-hub calendar publication -t <team-id> -e <entry-uuid> # 先读:directiveRevision / 草稿 version / 已有记录
98
+ social-hub calendar publish-register -t <team-id> -e <entry-uuid> --permalink <帖子完整链接> \
99
+ --expected-entry-revision <n> --expected-draft-version <n>
100
+ # 可选:抓帖子比对(只写比对结果 match / mismatch / unavailable,不改登记状态、不挡登记;supervisor+)
101
+ social-hub calendar publish-compare -t <team-id> -e <entry-uuid>
102
+ # 链接登记错了:更正(manager+;只改链接,沿用原授权快照;板块必须仍是授权的那个板块)
103
+ social-hub calendar publish-correct -t <team-id> -e <entry-uuid> --expected-record <active-record-uuid> \
104
+ --permalink <正确链接> --reason "<原因>"
105
+ # 错误码(按 error.code):PUBLICATION_ALREADY_RECORDED / PUBLICATION_STALE_ENTRY / PUBLICATION_STALE_DRAFT /
106
+ # PUBLICATION_STALE_RECORD(重新 publication 读最新再试)、PUBLICATION_REVIEW_NOT_PASSED(内部审核未过)、
107
+ # PUBLICATION_SUBREDDIT_MISMATCH / PUBLICATION_PERMALINK_INVALID(链接须是帖子完整链接且板块一致)、
108
+ # CLIENT_APPROVAL_STALE(品牌已开客户交付:需客户批准当前这版)、EXTERNAL_MANUAL_WRITE_DISABLED。
109
+ # 品牌已开客户交付:不再允许 external_agent(EXTERNAL_AGENT_DISABLED_FOR_CLIENT_DELIVERY);
110
+ # 草稿不能被直接写成 published(422 DRAFT_PUBLISHED_STATUS_RESERVED),只由登记 / 发布完成推进。
111
+
94
112
  social-hub plans list -t <team-id> --brand <brand-uuid>
95
113
  # plan status 为派生值(由 entries 聚合:显式取消 > running > 有待执行=scheduled > failed > succeeded),
96
114
  # 响应含 entryCounts 各状态计数;--status 按派生值过滤