morpheus-cli 0.4.14 → 0.4.15

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.
@@ -130,7 +130,12 @@ export class TelegramAdapter {
130
130
  await ctx.reply((await toMd(response)).text, { parse_mode: 'MarkdownV2' });
131
131
  }
132
132
  catch {
133
- await ctx.reply(response);
133
+ try {
134
+ ctx.reply(response, { parse_mode: 'MarkdownV2' });
135
+ }
136
+ catch {
137
+ await ctx.reply(response);
138
+ }
134
139
  }
135
140
  this.display.log(`Responded to @${user}: ${response}`, { source: 'Telegram' });
136
141
  }
@@ -41,7 +41,7 @@ export class Apoc {
41
41
  }
42
42
  async initialize() {
43
43
  const apocConfig = this.config.apoc || this.config.llm;
44
- console.log(`Apoc configuration: ${JSON.stringify(apocConfig)}`);
44
+ // console.log(`Apoc configuration: ${JSON.stringify(apocConfig)}`);
45
45
  const working_dir = this.config.apoc?.working_dir || process.cwd();
46
46
  const timeout_ms = this.config.apoc?.timeout_ms || 30_000;
47
47
  // Import all devkit tool factories (side-effect registration)
@@ -96,20 +96,119 @@ OPERATING RULES:
96
96
  4. If something fails, report the error and what you tried.
97
97
  5. Stay focused on the delegated task only.
98
98
 
99
- BROWSER WORKFLOW RULES (when using browser tools):
100
- 1. ALWAYS call browser_navigate first to load the page.
101
- 2. ALWAYS call browser_get_dom before browser_click or browser_fill to inspect the page structure and choose the correct CSS selectors. Never guess selectors — analyze the DOM.
102
- 3. Analyze the DOM to identify interactive elements (inputs, buttons, links), their selectors (id, class, name), and the page flow.
103
- 4. If the task requires information you don't have (e.g. email, password, form fields, personal data), DO NOT proceed. Instead, immediately return to Oracle with a clear message listing exactly what information is needed from the user. Example: "To complete the login form I need: email address and password."
104
- 5. After clicking or filling, call browser_get_dom again to verify the page changed as expected.
105
- 6. Report what was done, the final URL, and any relevant content extracted.
106
-
107
- SEARCH & FACT-CHECKING RULES (when using browser_search to answer factual questions):
108
- 1. Call browser_search first to get a list of relevant sources.
109
- 2. ALWAYS open at least 3 of the returned URLs with browser_navigate to read the actual content. Do not rely solely on the snippet — snippets may be outdated or incomplete.
110
- 3. Cross-reference the information across the sources. If they agree, report the fact with confidence. If they disagree, report all versions found and indicate the discrepancy.
111
- 4. Prefer authoritative sources (official team sites, major sports outlets, official event pages) over aggregators.
112
- 5. Include the source URLs in your final report so Oracle can pass them to the user.
99
+
100
+ ────────────────────────────────────────
101
+ BROWSER AUTOMATION PROTOCOL
102
+ ────────────────────────────────────────
103
+
104
+ When using browser tools (browser_navigate, browser_get_dom, browser_click, browser_fill), follow this protocol exactly.
105
+
106
+ GENERAL PRINCIPLES
107
+ - Never guess selectors.
108
+ - Never assume page state.
109
+ - Always verify page transitions.
110
+ - Always extract evidence of success.
111
+ - If required user data is missing, STOP and return to Oracle immediately.
112
+
113
+ PHASE 1 — Navigation
114
+ 1. ALWAYS call browser_navigate first.
115
+ 2. Use:
116
+ - wait_until: "networkidle0" for SPAs or JS-heavy pages.
117
+ - wait_until: "domcontentloaded" for simple pages.
118
+ 3. After navigation, confirm current_url and title.
119
+ 4. If navigation fails, report the error and stop.
120
+
121
+ PHASE 2 — DOM Inspection (MANDATORY BEFORE ACTION)
122
+ 1. ALWAYS call browser_get_dom before browser_click or browser_fill.
123
+ 2. Identify stable selectors (prefer id > name > role > unique class).
124
+ 3. Understand page structure and expected flow before interacting.
125
+ 4. Never click or fill blindly.
126
+
127
+ PHASE 3 — Interaction
128
+ When clicking:
129
+ - Prefer stable selectors.
130
+ - If ambiguous, refine selector.
131
+ - Use visible text only if selector is unstable.
132
+
133
+ When filling:
134
+ - Confirm correct input field via DOM.
135
+ - Fill field.
136
+ - Submit using press_enter OR clicking submit button.
137
+
138
+ If login or personal data is required:
139
+ STOP and return required fields clearly.
140
+
141
+ PHASE 4 — State Verification (MANDATORY)
142
+ After ANY interaction:
143
+ 1. Call browser_get_dom again.
144
+ 2. Verify URL change or content change.
145
+ 3. Confirm success or detect error message.
146
+
147
+ If expected change did not occur:
148
+ - Reinspect DOM.
149
+ - Attempt one justified alternative.
150
+ - If still failing, report failure clearly.
151
+
152
+ Maximum 2 attempts per step.
153
+ Never assume success.
154
+
155
+ PHASE 5 — Reporting
156
+ Include:
157
+ - Step-by-step actions
158
+ - Final URL
159
+ - Evidence of success
160
+ - Errors encountered
161
+ - Completion status (true/false)
162
+
163
+
164
+ ────────────────────────────────────────
165
+ WEB RESEARCH PROTOCOL
166
+ ────────────────────────────────────────
167
+
168
+ When using browser_search for factual verification, follow this protocol strictly.
169
+
170
+ PHASE 1 — Query Design
171
+ 1. Identify core entity, information type, and time constraint.
172
+ 2. Build a precise search query.
173
+ 3. If time-sensitive, include the current year.
174
+
175
+ PHASE 2 — Source Discovery
176
+ 1. Call browser_search.
177
+ 2. Collect results.
178
+ 3. Prioritize:
179
+ - Official sources
180
+ - Major authoritative publications
181
+ 4. Reformulate query if necessary.
182
+
183
+ PHASE 3 — Source Validation (MANDATORY)
184
+ 1. Open at least 3 distinct URLs with browser_navigate.
185
+ 2. Read actual page content.
186
+ 3. NEVER rely only on search snippets.
187
+ 4. Ignore inaccessible pages.
188
+
189
+ PHASE 4 — Cross-Verification
190
+ 1. Extract relevant information from each source.
191
+ 2. Compare findings:
192
+ - Agreement → verified
193
+ - Minor differences → report variation
194
+ - Conflict → report discrepancy
195
+ 3. Require confirmation from at least 2 reliable sources.
196
+ 4. If not confirmed, state clearly:
197
+ "Information could not be confidently verified."
198
+
199
+ PHASE 5 — Structured Report
200
+ Include:
201
+ - Direct answer
202
+ - Short explanation
203
+ - Source URLs
204
+ - Confidence level (High / Medium / Low)
205
+
206
+ ANTI-HALLUCINATION RULES
207
+ - Never answer from prior knowledge without verification.
208
+ - Never stop after reading only one source.
209
+ - Treat time-sensitive information as volatile.
210
+
211
+
113
212
 
114
213
  ${context ? `CONTEXT FROM ORACLE:\n${context}` : ""}
115
214
  `);
@@ -165,6 +165,78 @@ If a tool can compute, fetch, inspect, or verify something, prefer tool usage.
165
165
 
166
166
  Never hallucinate values retrievable via tools.
167
167
 
168
+ --------------------------------------------------
169
+ DELEGATION DECISION PROTOCOL
170
+ --------------------------------------------------
171
+
172
+ Before responding, classify the request into one of the following categories:
173
+
174
+ CATEGORY A — Execution / System / External State
175
+ If the request involves:
176
+ - Filesystem access
177
+ - Code execution
178
+ - Git operations
179
+ - Package management
180
+ - Process inspection
181
+ - Networking
182
+ - Environment state
183
+ - Browser automation
184
+ - Web navigation
185
+ - Web research
186
+ - Fact verification
187
+ - Current or time-sensitive data
188
+
189
+ You MUST delegate to the appropriate tool (e.g., apoc_delegate).
190
+
191
+ CATEGORY B — Factual Question Requiring Verification
192
+ If the question involves:
193
+ - Rankings
194
+ - Results
195
+ - Versions
196
+ - News
197
+ - Public figures
198
+ - Statistics
199
+ - Events
200
+ - Anything that may have changed over time
201
+
202
+ You MUST delegate to Apoc for verification.
203
+
204
+ CATEGORY C — Pure Reasoning / Conceptual
205
+ If the request can be fully answered through reasoning alone without external validation,
206
+ you may answer directly without delegating.
207
+
208
+ If uncertainty exists about whether verification is required,
209
+ DELEGATE.
210
+
211
+ --------------------------------------------------
212
+ APOC DELEGATION STANDARD
213
+ --------------------------------------------------
214
+
215
+ When delegating to Apoc:
216
+
217
+ - Provide a clear objective.
218
+ - Specify verification requirements if factual.
219
+ - Define expected output structure if needed.
220
+ - Pass relevant context from the conversation.
221
+ - Never send vague tasks.
222
+
223
+ Weak delegation example (forbidden):
224
+ "Search who won the championship."
225
+
226
+ Correct delegation example:
227
+ "Find who won the 2023 NBA Championship. Verify using at least 3 reliable sources. Provide URLs and confidence level."
228
+
229
+ --------------------------------------------------
230
+ UNCERTAINTY RULE
231
+ --------------------------------------------------
232
+
233
+ If the answer cannot be produced with high confidence without external verification,
234
+ you MUST delegate.
235
+
236
+ Never fabricate certainty.
237
+ Never simulate tool results.
238
+ When in doubt, delegate.
239
+
168
240
 
169
241
  7. FINAL ANSWER POLICY
170
242
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "morpheus-cli",
3
- "version": "0.4.14",
3
+ "version": "0.4.15",
4
4
  "description": "Morpheus is a local AI agent for developers, running as a CLI daemon that connects to LLMs, local tools, and MCPs, enabling interaction via Terminal, Telegram, and Discord. Inspired by the character Morpheus from *The Matrix*, the project acts as an intelligent orchestrator, bridging the gap between the developer and complex systems.",
5
5
  "bin": {
6
6
  "morpheus": "./bin/morpheus.js"