Skip to content

Commit 2b6fa57

Browse files
committed
add
1 parent 2c0e6b1 commit 2b6fa57

782 files changed

Lines changed: 77975 additions & 23 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cursor/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"plugins": {
3+
"render": {
4+
"enabled": true
5+
}
6+
}
7+
}

.dockerignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
node_modules
2+
dist
3+
_tmp
4+
.git
5+
.env
6+
.env.*
7+
!.env.example
8+
*.log
9+
coverage
10+
.nyc_output
11+
legacy

.env.example

Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
# =============================================================================
2+
# X / TWITTER API (Required for polling and posting)
3+
# =============================================================================
4+
# Required: OAuth 2.0 user refresh flow
5+
X_CLIENT_ID=your_x_client_id_here
6+
X_CLIENT_SECRET=your_x_client_secret_here
7+
X_REFRESH_TOKEN=your_x_refresh_token_here
8+
# Optional bootstrap token (runtime refresh preferred)
9+
X_ACCESS_TOKEN=
10+
X_EXPIRES_IN=7200
11+
X_TOKEN_CREATED_AT=
12+
X_REFRESH_BUFFER_SECONDS=300
13+
X_OAUTH_TOKEN_URL=https://api.x.com/2/oauth2/token
14+
X_BOT_USER_ID=
15+
16+
# =============================================================================
17+
# XAI API (LLM Provider)
18+
# =============================================================================
19+
XAI_API_KEY=xai-your_api_key_here
20+
XAI_BASE_URL=https://api.x.ai/v1
21+
XAI_MODEL_PRIMARY=grok-3
22+
XAI_MODEL_FALLBACKS=grok-3-mini
23+
24+
# =============================================================================
25+
# ALTERNATIVE LLM PROVIDERS (Optional)
26+
# =============================================================================
27+
OPENAI_API_KEY=sk-your_openai_key_here
28+
LLM_API_KEY=your_llm_api_key_here
29+
LLM_PROVIDER=xai
30+
OPENAI_MODEL=gpt-4o-mini
31+
OPENAI_BASE_URL=https://api.openai.com/v1
32+
LLM_TEMPERATURE=0.92
33+
LLM_MAX_TOKENS=280
34+
LLM_SYSTEM_PROMPT=
35+
LLM_CANNED_FALLBACK=Sorry, gerade offline – später mehr Fire! 🔥
36+
37+
# =============================================================================
38+
# REPLICATE IMAGE GENERATION (Optional)
39+
# =============================================================================
40+
REPLICATE_API_KEY=r8_your_replicate_key_here
41+
REPLICATE_IMAGE_MODEL=black-forest-labs/flux-schnell
42+
REPLICATE_RUN_TIMEOUT_MS=45000
43+
REPLICATE_DOWNLOAD_TIMEOUT_MS=20000
44+
45+
# =============================================================================
46+
# BOT ACTIVATION & WHITELIST (Test Phase Configuration)
47+
# =============================================================================
48+
49+
# Activation mode: "global" (respond to all) | "whitelist" (only whitelisted users)
50+
BOT_ACTIVATION_MODE=whitelist
51+
52+
# Comma-separated list of usernames (with or without @)
53+
# Example: BOT_WHITELIST_USERNAMES=alice,bob,charlie
54+
BOT_WHITELIST_USERNAMES=
55+
56+
# Comma-separated list of user IDs (numeric)
57+
# Example: BOT_WHITELIST_USER_IDS=123456789,987654321
58+
BOT_WHITELIST_USER_IDS=
59+
60+
# How to handle non-whitelisted mentions: "silent" (ignore) | "tease" (reply with teaser)
61+
BOT_DENY_REPLY_MODE=silent
62+
63+
# Bot's own username/handle (without @)
64+
BOT_USERNAME=Gnomes_onchain
65+
66+
# =============================================================================
67+
# LAUNCH MODE (Central control for rollout stages)
68+
# =============================================================================
69+
70+
# Launch mode: "off" | "dry_run" | "staging" | "prod"
71+
# - off: Bot is disabled
72+
# - dry_run: Process mentions but don't post (simulation)
73+
# - staging: Real posting, but only for ALLOWLIST_HANDLES
74+
# - prod: Full production mode
75+
LAUNCH_MODE=staging
76+
77+
# Legacy dry-run flag (mapped to LAUNCH_MODE if LAUNCH_MODE not set)
78+
DRY_RUN=false
79+
80+
# Comma-separated handles allowed in staging mode
81+
# Example: ALLOWLIST_HANDLES=alice,bob
82+
ALLOWLIST_HANDLES=
83+
84+
# =============================================================================
85+
# CONTEXT ENGINE
86+
# =============================================================================
87+
USE_ENHANCED_CONTEXT=true
88+
CONTEXT_ENGINE_MODE=hybrid
89+
CONTEXT_MAX_THREAD_DEPTH=3
90+
91+
# =============================================================================
92+
# SEMANTIC INTELLIGENCE (Phase 3)
93+
# =============================================================================
94+
SEMANTIC_ENABLED=true
95+
SEMANTIC_MODE=shadow
96+
SEMANTIC_TOPK=20
97+
SEMANTIC_CLUSTER_SIM=0.82
98+
SEMANTIC_QUERY_MAX_RESULTS=50
99+
SEMANTIC_MEMORY_TTL_DAYS=14
100+
SEMANTIC_INDEX_TTL_DAYS=7
101+
SEMANTIC_INDEX_MAX_DOCS=2000
102+
103+
# =============================================================================
104+
# POLLING CONFIGURATION
105+
# =============================================================================
106+
POLL_INTERVAL_MS=30000
107+
ADAPTIVE_POLLING_ENABLED=true
108+
MENTIONS_SOURCE=mentions
109+
110+
# =============================================================================
111+
# UPLOAD CONFIGURATION
112+
# =============================================================================
113+
X_UPLOAD_TIMEOUT_MS=30000
114+
X_UPLOAD_MAX_DIM=1024
115+
116+
# =============================================================================
117+
# RATE LIMITING & BUDGET GATES
118+
# =============================================================================
119+
MAX_LLM_CALLS_PER_MINUTE=30
120+
COST_WEIGHT_THREAD=2
121+
COST_WEIGHT_REPLY=1
122+
123+
# =============================================================================
124+
# FETCH & RETRY CONFIGURATION
125+
# =============================================================================
126+
FETCH_TIMEOUT_MS=30000
127+
FETCH_BACKOFF_BASE_MS=5000
128+
FETCH_BACKOFF_MAX_MS=300000
129+
FETCH_RETRY_JITTER_MS=500
130+
RATE_LIMIT_COOLDOWN_MS=60000
131+
MIN_POLL_INTERVAL_MS=5000
132+
MAX_POLL_INTERVAL_MS=300000
133+
134+
# =============================================================================
135+
# PUBLISH RETRY CONFIGURATION
136+
# =============================================================================
137+
PUBLISH_RETRY_DELAYS_MS=1000,5000,15000
138+
MAX_PUBLISH_RETRIES=3
139+
140+
# =============================================================================
141+
# STATE STORAGE (Redis vs SQLite)
142+
# =============================================================================
143+
144+
# Set to "true" to use Redis instead of local SQLite
145+
USE_REDIS=true
146+
147+
# Redis connection URL - must use redis:// or rediss:// protocol (NOT https://)
148+
# Get this from Upstash Console: Connect > Node.js > ioredis
149+
# Upstash production commonly requires TLS, so rediss:// is preferred there.
150+
# Example: rediss://default:PASSWORD@HOST.upstash.io:6379
151+
KV_URL=rediss://default:********@sharp-wildcat-47616.upstash.io:6379
152+
153+
# Key prefix for Redis keys (prevents collisions if multiple bots share Redis)
154+
REDIS_KEY_PREFIX=GNOMES_ONCHAIN:
155+
156+
# TTL Configuration
157+
EVENT_STATE_TTL_DAYS=7
158+
PUBLISHED_TTL_DAYS=30
159+
PUBLISH_LOCK_TTL_MS=30000
160+
161+
# Cursor Persistence
162+
CURSOR_PERSISTENCE_ENABLED=true
163+
CURSOR_SYNC_INTERVAL_MS=60000
164+
165+
# =============================================================================
166+
# ON-CHAIN / IDENTITY (Optional)
167+
# =============================================================================
168+
BOT_TOKEN_MINT=So11111111111111111111111111111111111111112
169+
BOT_TREASURY_WALLET=
170+
BOT_TICKER=Gnomes
171+
BOT_PROGRAM_ID=
172+
173+
# =============================================================================
174+
# LLM CIRCUIT BREAKER
175+
# =============================================================================
176+
LLM_TIMEOUT_MS=30000
177+
178+
# =============================================================================
179+
# PROMPT & MODE OVERRIDES (CLI / Test)
180+
# =============================================================================
181+
# FULL_SPECTRUM_PROMPT=true # Use StructuredRoast + self-critique + refine loop
182+
# AGGRESSIVE_MODE=horny # analyst | horny
183+
# TEST_MODE=true # Bypass relevance checks
184+
185+
# =============================================================================
186+
# LOGGING & DEBUGGING
187+
# =============================================================================
188+
LOG_LEVEL=INFO
189+
DEBUG_ARTIFACTS=false
190+
191+
# Skip environment validation at boot (use with caution)
192+
SKIP_ENV_VALIDATION=false
193+
194+
# =============================================================================
195+
# SERVER CONFIGURATION
196+
# =============================================================================
197+
PORT=10000
198+
199+
# =============================================================================
200+
# ON-CHAIN / SOLANA RPC (Optional - for on-chain verification)
201+
# =============================================================================
202+
SOLANA_RPC_PRIMARY_URL=https://api.mainnet-beta.solana.com
203+
SOLANA_RPC_FALLBACK_URL=https://solana-api.projectserum.com
204+
205+
# =============================================================================
206+
# DATA DIRECTORY (for filesystem store)
207+
# =============================================================================
208+
DATA_DIR=./data
209+
210+
# =============================================================================
211+
# GNOMES MULTI-PERSONA (Phase 1+)
212+
# =============================================================================
213+
# Enable multi-gnome routing and prompt composition (default: false)
214+
GNOMES_ENABLED=false
215+
216+
# Safe fallback gnome when routing uncertain (default: stillhalter)
217+
DEFAULT_SAFE_GNOME=stillhalter
218+
219+
# Enable user-gnome affinity and interaction writeback (default: false)
220+
GNOME_MEMORY_ENABLED=false
221+
222+
# Enable routing debug logs
223+
GNOME_ROUTING_DEBUG=false
224+
225+
# Preserve gnome continuity within threads (default: true)
226+
GNOME_CONTINUITY_ENABLED=true
227+
228+
# Phase-4: Ensemble orchestration, narrative arcs, autonomy
229+
GNOME_ENSEMBLE_ENABLED=false
230+
GNOME_AUTONOMY_ENABLED=false
231+
GNOME_ARC_ENGINE_ENABLED=false
232+
GNOME_MAX_CAMEOS=2
233+
234+
# Phase-3: Trait evolution (default: false)
235+
GNOME_EVOLUTION_ENABLED=false
236+
237+
# Phase-3: Running jokes (default: false)
238+
GNOME_RUNNING_JOKES_ENABLED=false
239+
240+
# Phase-3: Swarm/cameo replies (default: false)
241+
GNOME_SWARM_ENABLED=false
242+
243+
# Phase-3: Max trait drift per 100 interactions (default: 0.25)
244+
GNOME_TRAIT_DRIFT_LIMIT=0.25

.env.oauth2.example

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# X OAuth2 confidential client settings
2+
X_CLIENT_ID=your_client_id
3+
X_CLIENT_SECRET=your_client_secret
4+
X_REDIRECT_URI=http://127.0.0.1:8080/callback
5+
6+
# IMPORTANT: offline.access is required to receive refresh_token values.
7+
X_OAUTH_SCOPES=tweet.read tweet.write users.read offline.access
8+
9+
# Runtime uses refresh grant with an existing valid refresh token.
10+
# If X_REFRESH_TOKEN becomes invalid/revoked, run scripts/Generate-XOAuthTokens.ps1
11+
# to perform a full OAuth2 PKCE re-authorization and mint a fresh refresh token.
12+
X_ACCESS_TOKEN=replace_after_oauth
13+
X_REFRESH_TOKEN=replace_after_oauth
14+
X_TOKEN_TYPE=bearer
15+
X_EXPIRES_IN=7200
16+
X_TOKEN_CREATED_AT=2026-03-17T22:00:00+01:00
17+
X_REFRESH_BUFFER_SECONDS=300
18+
19+
# Optional override (defaults to https://api.x.com/2/oauth2/token)
20+
X_OAUTH_TOKEN_URL=https://api.x.com/2/oauth2/token
21+
22+
X_BOT_USERNAME=Gnomes_onchain
23+
X_BOT_USER_ID=1234567890

.github/workflows/ci.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
jobs:
10+
ci:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: pnpm/action-setup@v4
16+
with:
17+
version: 9
18+
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: "20"
22+
cache: "pnpm"
23+
24+
- name: Install dependencies
25+
run: pnpm install --frozen-lockfile
26+
27+
- name: Typecheck
28+
run: pnpm run typecheck
29+
30+
- name: Lint
31+
run: pnpm run lint
32+
33+
- name: Test
34+
run: pnpm run test
35+
36+
- name: Build
37+
run: pnpm run build

0 commit comments

Comments
 (0)