Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Autotests/test_websearch_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
def test_websearch_returns_results():
code = (
"import os, sys;"
"sys.path.insert(0, os.path.join(os.environ['OMEGACLAW_DIR'], 'channels'));"
"sys.path.insert(0, os.path.join(os.environ['OMEGACLAW_DIR'], 'src'));"
"import websearch;"
"print('COUNT', len(websearch.search_('test')))"
)
Expand Down
19 changes: 19 additions & 0 deletions channels/irc.metta
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
!(import! &self (library OmegaClaw-Core ./channels/irc.py))

(= (IRC_channel) (empty))
(= (IRC_server) (empty))
(= (IRC_port) (empty))
(= (IRC_user) (empty))

(= (commChannelInit)
(progn (configure IRC_channel ##omegaclaw)
(configure IRC_server "irc.quakenet.org")
(configure IRC_port 6667)
(configure IRC_user omegaclaw)
(py-call (irc.start_irc (IRC_channel) (IRC_server) (IRC_port) (IRC_user)))))

(= (commChannelReceiveMessage)
(py-call (irc.getLastMessage)))

(= (commChannelSendMessage $msg)
(py-call (irc.send_message $msg)))
15 changes: 15 additions & 0 deletions channels/mattermost.metta
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
!(import! &self (library OmegaClaw-Core ./channels/mattermost.py))

(= (MM_URL) (empty))
(= (MM_CHANNEL_ID) (empty))

(= (commChannelInit)
(progn (configure MM_URL "https://chat.singularitynet.io")
(configure MM_CHANNEL_ID "8fjrmabjx7gupy7e5kjznpt5qh")
(py-call (mattermost.start_mattermost (MM_URL) (MM_CHANNEL_ID)))))

(= (commChannelReceiveMessage)
(py-call (mattermost.getLastMessage)))

(= (commChannelSendMessage $msg)
(py-call (mattermost.send_message $msg)))
15 changes: 15 additions & 0 deletions channels/slack.metta
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
!(import! &self (library OmegaClaw-Core ./channels/slack.py))

(= (SL_CHANNEL_ID) (empty))
(= (SL_POLL_INTERVAL) (empty))

(= (commChannelInit)
(progn (configure SL_CHANNEL_ID "")
(configure SL_POLL_INTERVAL 60)
(py-call (slack.start_slack (SL_CHANNEL_ID) (SL_POLL_INTERVAL)))))

(= (commChannelReceiveMessage)
(py-call (slack.getLastMessage)))

(= (commChannelSendMessage $msg)
(py-call (slack.send_message $msg)))
15 changes: 15 additions & 0 deletions channels/telegram.metta
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
!(import! &self (library OmegaClaw-Core ./channels/telegram.py))

(= (TG_CHAT_ID) (empty))
(= (TG_POLL_TIMEOUT) (empty))

(= (commChannelInit)
(progn (configure TG_CHAT_ID "")
(configure TG_POLL_TIMEOUT 20)
(py-call (telegram.start_telegram (TG_CHAT_ID) (TG_POLL_TIMEOUT)))))

(= (commChannelReceiveMessage)
(py-call (telegram.getLastMessage)))

(= (commChannelSendMessage $msg)
(py-call (telegram.send_message $msg)))
10 changes: 10 additions & 0 deletions channels/test.metta
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
!(import! &self (library OmegaClaw-Core ./channels/mock.py))

(= (commChannelInit)
(py-call (mock.start_mock)))

(= (commChannelReceiveMessage)
(py-call (mock.getLastMessage)))

(= (commChannelSendMessage $msg)
(py-call (mock.send_message $msg)))
2 changes: 1 addition & 1 deletion docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ lib_omegaclaw.metta loads all submodules
├── src/helper.py parenthesis balancing, normalization
├── src/agentverse.py remote-agent bridge
├── src/skills.pl Prolog helpers (shell, first_char)
├── src/websearch.py web search
├── lib_nal.metta NAL truth functions
├── lib_pln.metta PLN rules
└── lib_llm_ext.py Claude / GPT / MiniMax / local embeddings
Expand All @@ -129,7 +130,6 @@ channels/irc.py IRC adapter
channels/telegram.py Telegram adapter
channels/slack.py Slack adapter
channels/mattermost.py Mattermost adapter
channels/websearch.py web search

memory/prompt.txt system prompt (agent identity + values)
memory/history.metta episodic trace (written at runtime)
Expand Down
4 changes: 0 additions & 4 deletions docs/reference-channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ Slack adapter using Slack Web API polling.
- Adapter respects Slack `Retry-After` backoff on HTTP 429 and enforces a minimum 60s poll interval.
- Uses the same one-time `auth <secret>` ownership gate as the other adapters.

## `channels/websearch.py`

Not a communication channel in the `send`/`receive` sense — this is the backend for the `search` skill. Exposes `search(query)`.

## Adding a new channel

See [tutorial-04-adding-a-channel.md](./tutorial-04-adding-a-channel.md).
Expand Down
2 changes: 1 addition & 1 deletion docs/reference-skills-communication.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The agent does not normally call `receive` itself; the loop wraps it:
```

### Purpose
Perform a web search through the `channels/websearch.py` adapter.
Perform a web search through the `src/websearch.py` adapter.

### Parameters
- `query` — the search string.
Expand Down
9 changes: 3 additions & 6 deletions lib_omegaclaw.metta
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@
!(import! &self (library OmegaClaw-Core ./src/utils))
!(import! &self (library OmegaClaw-Core ./src/helper.py))
!(import! &self (library OmegaClaw-Core ./src/agentverse.py))
!(import! &self (library OmegaClaw-Core ./channels/irc.py))
!(import! &self (library OmegaClaw-Core ./channels/mattermost.py))
!(import! &self (library OmegaClaw-Core ./channels/telegram.py))
!(import! &self (library OmegaClaw-Core ./channels/slack.py))
!(import! &self (library OmegaClaw-Core ./channels/websearch.py))
!(import! &self (library OmegaClaw-Core ./src/channels))
!(import! &self (library OmegaClaw-Core ./src/websearch.py))
!(import! &self (library OmegaClaw-Core ./src/ext.py))
!(import! &self (library OmegaClaw-Core ./src/ext))
!(import! &self (library OmegaClaw-Core ./src/skills))
!(import! &self (library OmegaClaw-Core ./src/memory))
!(import! &self (library OmegaClaw-Core ./src/context))
Expand Down
68 changes: 0 additions & 68 deletions src/channels.metta

This file was deleted.

51 changes: 51 additions & 0 deletions src/ext.metta
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
; TODO: the main reason of moving loading the extensions loading out of the
; (init... ) functions is that dependency should be loaded before the dependent
; module in PeTTa otherwise the dependency functions will not be callable from
; the dependent module (see https://github.com/trueagi-io/PeTTa/issues/181).
; This module is loaded before loop.metta and thus the extensions API is
; available before loop.metta which is critical to call (initChannels) and
; similar. If #181 is fixed it will be possible to move code below into
; (initChannels) in channels.metta and similar.

;configured at runtime:
(= (commchannel) (empty))
!(configure commchannel irc)

(= (load-commchannel-py $extname)
(if (== 1 (py-call (ext.commchannel $extname)))
(progn (add-atom &self (= (commChannelReceiveMessage) (py-call (ext.commChannelReceiveMessage))))
(add-atom &self (= (commChannelSendMessage $msg) (py-call (ext.commChannelSendMessage $msg))))
True)
False))

(= (empty-to-false $x)
(case $x
((() False)
($_ True))))


(= (load-commchannel $extname)
(progn (println! (atom_concat "Loading communication channel extension: " $extname))
(if (empty-to-false (collapse (import! &self (library OmegaClaw-Core (atom_concat "./channels/" $extname))))) True
(if (empty-to-false (collapse (import! &self (library OmegaClaw-Core (atom_concat "./extensions/" $extname))))) True
(if (load-commchannel-py $extname) True
(progn (println! (atom_concat "Could not load communication channel extension: " $extname))
False))))))

!(load-commchannel (commchannel))

;Connect all the channels:
(= (initChannels)
(progn (println! "Initializing channels")
(commChannelInit)))

;Receive the latest user message considering all communication channels:
(= (receive) (commChannelReceiveMessage))

;Send a message to all communication channels:
!(change-state! &lastsend "")
(= (send $msg)
(if (!= $msg (get-state &lastsend))
(progn (change-state! &lastsend $msg)
(let $safemsg (string-replace $msg "\n" "\\n")
(let $temp (cut) (commChannelSendMessage $safemsg))))))
20 changes: 20 additions & 0 deletions src/ext.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import importlib

_mod = None

def commchannel(extname):
global _mod
try:
_mod = importlib.import_module(extname)
if _mod is not None:
return 1
except Exception as e:
return 0

def commChannelReceiveMessage():
global _mod
return _mod.commChannelReceiveMessage()

def commChannelSendMessage(msg):
global _mod
return _mod.commChannelSendMessage(msg)
4 changes: 4 additions & 0 deletions src/skills.metta
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,7 @@

(= (pin $x)
PIN-SUCCESS)

;Search the internet for some information:
(= (search $msg)
(py-call (websearch.search $msg)))
File renamed without changes.
Loading