Homebox@
This commit is contained in:
+25
-197
@@ -21,7 +21,7 @@ services:
|
||||
image: felddy/foundryvtt:release
|
||||
volumes:
|
||||
- /mnt/tower/foundry:/data
|
||||
- /opt/scarif/foundry/patches:/data/patches
|
||||
- ./foundry/patches:/data/patches
|
||||
restart: always
|
||||
environment:
|
||||
- "FOUNDRY_PASSWORD=${FOUNDRY_PASSWORD}"
|
||||
@@ -165,113 +165,41 @@ services:
|
||||
networks:
|
||||
- nginx
|
||||
|
||||
# kavita:
|
||||
# image: jvmilazz0/kavita:latest # Using the stable branch from the official dockerhub repo.
|
||||
# container_name: kavita
|
||||
# volumes:
|
||||
# # - /your/path/to/comics:/comics
|
||||
# - /mnt/tower/stardust/chris/files/Library/Books:/books
|
||||
# - /mnt/tower/stardust/chris/files/Library/Books/.kavita/config:/kavita/config
|
||||
# environment:
|
||||
# - TZ=Europe/London
|
||||
# - VIRTUAL_HOST=datapad.${DOMAIN}
|
||||
# - VIRTUAL_PORT=5000
|
||||
# restart: unless-stopped
|
||||
# networks:
|
||||
# - nginx
|
||||
|
||||
grocy:
|
||||
image: lscr.io/linuxserver/grocy:latest
|
||||
container_name: grocy
|
||||
environment:
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
- TZ=Europe/London
|
||||
- VIRTUAL_HOST=assets.${DOMAIN}
|
||||
- CURRENCY=GBP
|
||||
- DEFAULT_LOCALE=en_GB
|
||||
- VIRTUAL_HOST=supplies.${DOMAIN}
|
||||
- VIRTUAL_PORT=80
|
||||
volumes:
|
||||
- ./grocy/config:/config
|
||||
- /mnt/tower/containers/grocy:/config
|
||||
- ./grocy/config-dist.php:/config/config-dist.php
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- nginx
|
||||
|
||||
# calibre-web-automated:
|
||||
# image: crocodilestick/calibre-web-automated:latest
|
||||
# container_name: calibre-web-automated
|
||||
# environment:
|
||||
# - PUID=1000
|
||||
# - PGID=1000
|
||||
# - TZ=Europe/London
|
||||
# - HARDCOVER_TOKEN=${HARDCOVER_TOKEN}
|
||||
# - NETWORK_SHARE_MODE=false
|
||||
# # If running behind multiple proxies (e.g., Cloudflare Tunnel + reverse proxy), set the total number of proxies
|
||||
# # This ensures proper IP detection for session protection and rate limiting (default: 1)
|
||||
# # - TRUSTED_PROXY_COUNT=2
|
||||
# - VIRTUAL_HOST=datapad.${DOMAIN}
|
||||
# - VIRTUAL_PORT=8083
|
||||
# volumes:
|
||||
# - /mnt/tower/stardust/chris/files/Library/Books/.calibre/config:/config
|
||||
# - /mnt/tower/stardust/chris/files/Library/Books/.calibre/ingest:/cwa-book-ingest
|
||||
# - /mnt/tower/stardust/chris/files/Library/Books/.calibre/library:/calibre-library
|
||||
# networks:
|
||||
# - nginx
|
||||
# restart: unless-stopped
|
||||
|
||||
# librechat:
|
||||
# image: ghcr.io/danny-avila/librechat-dev-api:latest
|
||||
# ports:
|
||||
# - 3080:3080
|
||||
# networks:
|
||||
# - nginx
|
||||
# - redis
|
||||
# - db
|
||||
# depends_on:
|
||||
# - mongodb
|
||||
# # - rag_api
|
||||
# restart: always
|
||||
# extra_hosts:
|
||||
# - "host.docker.internal:host-gateway"
|
||||
# <<: *logging
|
||||
# environment:
|
||||
# - VIRTUAL_HOST=droid.${DOMAIN}
|
||||
# - VIRTUAL_PORT=3080
|
||||
# - CERT_NAME=${DOMAIN}
|
||||
# - HOST=0.0.0.0
|
||||
# - NODE_ENV=production
|
||||
# - MONGO_URI=mongodb://${DB_USER}:${DB_PASSWORD}@mongodb:27017/LibreChat?authSource=admin
|
||||
# #- MEILI_HOST=http://meilisearch:7700
|
||||
# #- MEILI_MASTER_KEY=${MEILI_MASTER_KEY}
|
||||
# #- RAG_PORT=8000
|
||||
# #- RAG_API_URL=http://rag_api:8000
|
||||
# #- SEARXNG_INSTANCE_URL=http://searxng:8080
|
||||
# #- SEARXNG_API_KEY=${SEARXNG_SECRET_KEY}
|
||||
# #- FIRECRAWL_URL=http://firecrawl:3002
|
||||
# #- FIRECRWAL_API_KEY=
|
||||
# - ALLOW_EMAIL_LOGIN=true
|
||||
# - ALLOW_REGISTRATION=false
|
||||
# - ALLOW_SOCIAL_LOGIN=false
|
||||
# - ALLOW_SOCIAL_REGISTRATION=false
|
||||
# - ALLOW_PASSWORD_RESET=false
|
||||
# - ALLOW_ACCOUNT_DELETION=false
|
||||
# - ALLOW_UNVERIFIED_EMAIL_LOGIN=true
|
||||
# - CREDS_KEY=${LIBRECHAT_CREDS_KEY}
|
||||
# - CREDS_IV=${LIBRECHAT_CREDS_IV}
|
||||
# - JWT_SECRET=${LIBRECHAT_JWT_SECRET}
|
||||
# - JWT_REFRESH_SECRET=${LIBRECHAT_JWT_REFRESH_SECRET}
|
||||
# - AIHUBMIX_KEY=${AIHUBMIX_KEY}
|
||||
# - OPENROUTER_KEY=${OPENROUTER_KEY}
|
||||
# - IMAGE_GEN_OAI_BASEURL=https://aihubmix.com/v1
|
||||
# - IMAGE_GEN_OAI_API_KEY=${AIHUBMIX_KEY}
|
||||
# - IMAGE_GEN_OAI_MODEL=qwen-image-plus
|
||||
# #- JINA_API_KEY=${JINA_API_KEY}
|
||||
# volumes:
|
||||
# - type: bind
|
||||
# source: ./librechat/librechat.yaml
|
||||
# target: /app/librechat.yaml
|
||||
# - /mnt/tower/stardust/chris/files/.droid/images:/app/client/public/images
|
||||
# - /mnt/tower/stardust/chris/files/.droid/uploads:/app/uploads
|
||||
# - /mnt/tower/stardust/chris/files/.droid/logs:/app/logs
|
||||
# - /mnt/tower/stardust/chris/files/:/files
|
||||
homebox:
|
||||
image: ghcr.io/sysadminsmedia/homebox:latest
|
||||
restart: always
|
||||
environment:
|
||||
- HBOX_LOG_LEVEL=info
|
||||
- HBOX_LOG_FORMAT=text
|
||||
- HBOX_WEB_MAX_UPLOAD_SIZE=10
|
||||
# Please consider allowing analytics to help us improve Homebox (basic computer information, no personal data)
|
||||
- HBOX_OPTIONS_ALLOW_ANALYTICS=false
|
||||
# Use a strong random string for the pepper in production, it will be used to hash API keys and make them more secure
|
||||
- HBOX_AUTH_API_KEY_PEPPER=${HOMEBOX_API_KEY_PEPPER}
|
||||
- HBOX_OPTIONS_ALLOW_REGISTRATION=true
|
||||
- VIRTUAL_HOST=assets.${DOMAIN}
|
||||
- VIRTUAL_PORT=7745
|
||||
volumes:
|
||||
- /mnt/tower/containers/homebox:/data/
|
||||
networks:
|
||||
- nginx
|
||||
|
||||
searxng:
|
||||
image: docker.io/searxng/searxng:latest
|
||||
@@ -342,7 +270,7 @@ services:
|
||||
- ND_SESSIONTIMEOUT=24h
|
||||
- ND_BASEURL=https://radio.${DOMAIN}
|
||||
volumes:
|
||||
- navidrome:/data
|
||||
- /mnt/tower/containers/navidrome:/data
|
||||
- /mnt/tower/stardust/chris/files/Library/Music:/music:ro
|
||||
networks:
|
||||
- nginx
|
||||
@@ -498,53 +426,6 @@ services:
|
||||
networks:
|
||||
- db
|
||||
|
||||
#playwright:
|
||||
# profiles: ["prod", "dev"]
|
||||
# <<: *logging
|
||||
# image: ghcr.io/mendableai/playwright-service:latest
|
||||
# environment:
|
||||
# PORT: 3000
|
||||
# BLOCK_MEDIA: true
|
||||
# networks:
|
||||
# - playwright
|
||||
|
||||
#firecrawl:
|
||||
# profiles: ["prod", "dev"]
|
||||
# <<: [*logging, *firecrawl-service]
|
||||
# environment:
|
||||
# <<: *firecrawl-env
|
||||
# HOST: "0.0.0.0"
|
||||
# PORT: 3002
|
||||
# FLY_PROCESS_GROUP: app
|
||||
# ENV: local
|
||||
# VIRTUAL_HOST: scraper.${DOMAIN}
|
||||
# CERT_NAME: ${DOMAIN}
|
||||
# VIRTUAL_PORT: 3002
|
||||
# depends_on:
|
||||
# - redis
|
||||
# - playwright
|
||||
# ports:
|
||||
# - "3002:3002"
|
||||
# networks:
|
||||
# - redis
|
||||
# - playwright
|
||||
# command: [ "pnpm", "run", "start:production" ]
|
||||
|
||||
#firecrawl-worker:
|
||||
# profiles: ["prod", "dev"]
|
||||
# <<: [*firecrawl-service, *logging]
|
||||
# environment:
|
||||
# <<: *firecrawl-env
|
||||
# FLY_PROCESS_GROUP: worker
|
||||
# networks:
|
||||
# - redis
|
||||
# - playwright
|
||||
# depends_on:
|
||||
# - redis
|
||||
# - playwright
|
||||
# - firecrawl
|
||||
# command: [ "pnpm", "run", "workers" ]
|
||||
|
||||
redis:
|
||||
profiles: ["prod", "dev"]
|
||||
<<: *logging
|
||||
@@ -555,8 +436,6 @@ services:
|
||||
|
||||
mongodb:
|
||||
profiles: ["prod", "dev"]
|
||||
# ports:
|
||||
# - 27018:27017
|
||||
image: mongo
|
||||
restart: always
|
||||
volumes:
|
||||
@@ -569,51 +448,6 @@ services:
|
||||
- MONGO_INITDB_ROOT_PASSWORD=${DB_PASSWORD}
|
||||
<<: *logging
|
||||
|
||||
#meilisearch:
|
||||
# profiles: ["prod", "dev"]
|
||||
# image: getmeili/meilisearch:v1.12.3
|
||||
# restart: always
|
||||
# networks:
|
||||
# - db
|
||||
# # ports:
|
||||
# # - 7700:7700
|
||||
# environment:
|
||||
# - MEILI_HOST=http://meilisearch:7700
|
||||
# - MEILI_NO_ANALYTICS=true
|
||||
# - MEILI_MASTER_KEY=${MEILI_MASTER_KEY}
|
||||
# volumes:
|
||||
# - meilisearch:/meili_data
|
||||
# <<: *logging
|
||||
|
||||
#vectordb:
|
||||
# profiles: ["prod", "dev"]
|
||||
# image: ankane/pgvector:latest
|
||||
# networks:
|
||||
# - db
|
||||
# environment:
|
||||
# POSTGRES_DB: mydatabase
|
||||
# POSTGRES_USER: myuser
|
||||
# POSTGRES_PASSWORD: mypassword
|
||||
# restart: always
|
||||
# volumes:
|
||||
# - pgdata2:/var/lib/postgresql/data
|
||||
# <<: *logging
|
||||
|
||||
#rag_api:
|
||||
# profiles: ["prod", "dev"]
|
||||
# image: ghcr.io/danny-avila/librechat-rag-api-dev:latest
|
||||
# environment:
|
||||
# - DB_HOST=vectordb
|
||||
# - RAG_PORT=8000
|
||||
# - EMBEDDINGS_PROVIDER=huggingface
|
||||
# - HF_TOKEN=${HF_TOKEN}
|
||||
# restart: always
|
||||
# networks:
|
||||
# - db
|
||||
# depends_on:
|
||||
# - vectordb
|
||||
# <<: *logging
|
||||
|
||||
nginx:
|
||||
<<: *logging
|
||||
profiles: ["prod", "dev"]
|
||||
@@ -633,7 +467,6 @@ services:
|
||||
- ./nginx/conf.d/custom_proxy.conf:/etc/nginx/conf.d/custom_proxy.conf:ro
|
||||
- nextcloud:/var/www/html/nextcloud:ro
|
||||
- ./christmas:/var/www/html/christmas:ro
|
||||
# - tt-rss:/var/www/html/tt-rss:ro
|
||||
networks:
|
||||
- nginx
|
||||
|
||||
@@ -655,19 +488,14 @@ volumes:
|
||||
gitea:
|
||||
nextcloud:
|
||||
foundry:
|
||||
navidrome:
|
||||
minecraft:
|
||||
change:
|
||||
mongodb:
|
||||
searxng:
|
||||
openclaw:
|
||||
#pgdata2:
|
||||
#meilisearch:
|
||||
|
||||
networks:
|
||||
db:
|
||||
nginx:
|
||||
redis:
|
||||
meet.jitsi:
|
||||
#playwright:
|
||||
|
||||
|
||||
@@ -1,233 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Settings can also be overwritten in two ways:
|
||||
//
|
||||
// First priority:
|
||||
// A .txt file with the same name as the setting in /data/settingoverrides
|
||||
// the content of the file is used as the setting value
|
||||
//
|
||||
// Second priority:
|
||||
// An environment variable with the same name as the setting and prefix "GROCY_"
|
||||
// so for example "GROCY_BASE_URL"
|
||||
//
|
||||
// Third priority:
|
||||
// The settings defined here below
|
||||
|
||||
// Either "production", "dev", "demo" or "prerelease"
|
||||
// When not "production", the application will work in a demo mode which means
|
||||
// authentication is disabled and some demo data will be generated during the database schema migration
|
||||
// (pass the query parameter "nodemodata", e.g. https://grocy.example.com/?nodemodata to skip that)
|
||||
Setting('MODE', 'production');
|
||||
|
||||
// The directory name of one of the available localization folders
|
||||
// in the "/localization" directory (e.g. "en" or "de")
|
||||
// Grocy uses the first available locale / setting in this order
|
||||
// 1. Browser prefered locale
|
||||
// 2. The one set in user settings
|
||||
// 3. The one defined here below
|
||||
Setting('DEFAULT_LOCALE', 'en_GB');
|
||||
|
||||
// This is used to define the first day of a week for calendar views,
|
||||
// leave empty to use the locale default
|
||||
// Needs to be a number where Sunday = 0, Monday = 1 and so forth
|
||||
Setting('CALENDAR_FIRST_DAY_OF_WEEK', '');
|
||||
|
||||
// If calendars should show week numbers
|
||||
Setting('CALENDAR_SHOW_WEEK_OF_YEAR', true);
|
||||
|
||||
// Set this if you want to have a different start day for the weekly meal plan view,
|
||||
// leave empty to use CALENDAR_FIRST_DAY_OF_WEEK (see above)
|
||||
// Needs to be a number where Sunday = 0, Monday = 1 and so forth
|
||||
// Can also be set to -1 to dynamically start the meal plan week on "today"
|
||||
Setting('MEAL_PLAN_FIRST_DAY_OF_WEEK', '');
|
||||
|
||||
// To keep it simple: Grocy does not handle any currency conversions,
|
||||
// this here is used to format all money values,
|
||||
// so doesn't really matter, but needs to be the
|
||||
// ISO 4217 code of the currency ("USD", "EUR", "GBP", etc.)
|
||||
Setting('CURRENCY', 'GBP');
|
||||
|
||||
// Your preferred unit for energy
|
||||
// E.g. "kcal" or "kJ" or something else (doesn't really matter, it's only used to display energy values)
|
||||
Setting('ENERGY_UNIT', 'kcal');
|
||||
|
||||
// When running Grocy in a subdirectory, this should be set to the relative path, otherwise empty
|
||||
// It needs to be set to the part (of the URL) AFTER the document root,
|
||||
// if URL rewriting is disabled, including index.php
|
||||
// Example with URL Rewriting support:
|
||||
// Root URL = https://example.com/grocy
|
||||
// => BASE_PATH = /grocy
|
||||
// Example without URL Rewriting support:
|
||||
// Root URL = https://example.com/grocy/public/index.php/
|
||||
// => BASE_PATH = /grocy/public/index.php
|
||||
Setting('BASE_PATH', '');
|
||||
|
||||
// The base URL of your installation,
|
||||
// should be just "/" when running directly under the root of a (sub)domain
|
||||
// or for example "https://example.com/grocy" when using a subdirectory
|
||||
Setting('BASE_URL', '/');
|
||||
|
||||
// The plugin to use for external barcode lookups,
|
||||
// must be the filename (folder "/plugins" for built-in plugins or "/data/plugins" for user plugins) without the .php extension,
|
||||
// see /plugins/DemoBarcodeLookupPlugin.php for a commented example implementation
|
||||
// Leave empty to disable external barcode lookups
|
||||
Setting('STOCK_BARCODE_LOOKUP_PLUGIN', 'OpenFoodFactsBarcodeLookupPlugin');
|
||||
|
||||
// If, however, your webserver does not support URL rewriting, set this to true
|
||||
Setting('DISABLE_URL_REWRITING', false);
|
||||
|
||||
// Specify an custom homepage if desired, by default the homepage will be set to the stock overview page
|
||||
// This needs to be one of the following values:
|
||||
// stock, shoppinglist, recipes, chores, tasks, batteries, equipment, calendar, mealplan
|
||||
Setting('ENTRY_PAGE', 'stock');
|
||||
|
||||
// Set this to true if you want to disable authentication / the login screen,
|
||||
// places where user context is needed will then use the default (first existing) user
|
||||
Setting('DISABLE_AUTH', false);
|
||||
|
||||
// Either "Grocy\Middleware\DefaultAuthMiddleware", "Grocy\Middleware\ReverseProxyAuthMiddleware"
|
||||
// or any class that implements Grocy\Middleware\AuthMiddleware
|
||||
Setting('AUTH_CLASS', 'Grocy\Middleware\DefaultAuthMiddleware');
|
||||
|
||||
// Options when using ReverseProxyAuthMiddleware
|
||||
Setting('REVERSE_PROXY_AUTH_HEADER', 'REMOTE_USER'); // The name of the HTTP header which your reverse proxy uses to pass the username (on successful authentication)
|
||||
Setting('REVERSE_PROXY_AUTH_USE_ENV', false); // Set to true if the username is passed as environment variable
|
||||
|
||||
// Options when using LdapAuthMiddleware
|
||||
Setting('LDAP_ADDRESS', ''); // Example value "ldap://vm-dc2019.local.berrnd.net"
|
||||
Setting('LDAP_BASE_DN', ''); // Example value "DC=local,DC=berrnd,DC=net"
|
||||
Setting('LDAP_BIND_DN', ''); // Example value "CN=grocy_bind_account,OU=service_accounts,DC=local,DC=berrnd,DC=net"
|
||||
Setting('LDAP_BIND_PW', ''); // Password for the above account
|
||||
Setting('LDAP_USER_FILTER', ''); // Example value "(OU=grocy_users)"
|
||||
Setting('LDAP_UID_ATTR', ''); // Windows AD: "sAMAccountName", OpenLDAP: "uid", GLAuth: "cn"
|
||||
|
||||
// Default permissions for new users
|
||||
// the array needs to contain the technical/constant names
|
||||
// See the file controllers/Users/User.php for possible values
|
||||
Setting('DEFAULT_PERMISSIONS', ['ADMIN']);
|
||||
|
||||
// "1D" (=> Code128) or "2D" (=> DataMatrix)
|
||||
Setting('GROCYCODE_TYPE', '2D');
|
||||
|
||||
|
||||
// Label printer settings
|
||||
Setting('LABEL_PRINTER_WEBHOOK', ''); // The URI that Grocy will POST to when asked to print a label
|
||||
Setting('LABEL_PRINTER_RUN_SERVER', true); // Whether the webhook will be called server- or client-side
|
||||
Setting('LABEL_PRINTER_PARAMS', ['font_family' => 'Source Sans Pro (Regular)']); // Additional parameters supplied to the webhook
|
||||
Setting('LABEL_PRINTER_HOOK_JSON', true); // TRUE to use JSON or FALSE to use normal POST request variables
|
||||
|
||||
|
||||
// Thermal printer options
|
||||
// Thermal printers are receipt printers, not regular printers,
|
||||
// the printer must support the ESC/POS protocol, see https://github.com/mike42/escpos-php
|
||||
Setting('TPRINTER_IS_NETWORK_PRINTER', false); // Set to true if it's a network printer
|
||||
Setting('TPRINTER_PRINT_QUANTITY_NAME', true); // Set to false if you do not want to print the quantity names (related to the shopping list)
|
||||
Setting('TPRINTER_PRINT_NOTES', true); // Set to false if you do not want to print notes (related to the shopping list)
|
||||
Setting('TPRINTER_IP', '127.0.0.1'); // IP of the network printer (does only matter if it's a network printer)
|
||||
Setting('TPRINTER_PORT', 9100); // Port of the network printer (does only matter if it's a network printer)
|
||||
Setting('TPRINTER_CONNECTOR', '/dev/usb/lp0'); // Printer device (does only matter if you use a locally attached printer)
|
||||
// For USB on Linux this is often '/dev/usb/lp0', for serial printers it could be similar to '/dev/ttyS0'
|
||||
// Make sure that the user that runs the webserver has permissions to write to the printer - on Linux add your webserver user to the LP group with usermod -a -G lp www-data
|
||||
|
||||
|
||||
// Feature flags
|
||||
// Here you can disable the parts which you don't need to have a less cluttered UI
|
||||
// (set the setting to "false" to disable the corresponding part, which should be self explanatory)
|
||||
Setting('FEATURE_FLAG_STOCK', true);
|
||||
Setting('FEATURE_FLAG_SHOPPINGLIST', true);
|
||||
Setting('FEATURE_FLAG_RECIPES', true);
|
||||
Setting('FEATURE_FLAG_CHORES', true);
|
||||
Setting('FEATURE_FLAG_TASKS', true);
|
||||
Setting('FEATURE_FLAG_BATTERIES', true);
|
||||
Setting('FEATURE_FLAG_EQUIPMENT', true);
|
||||
Setting('FEATURE_FLAG_CALENDAR', true);
|
||||
Setting('FEATURE_FLAG_LABEL_PRINTER', false);
|
||||
|
||||
// Sub feature flags
|
||||
Setting('FEATURE_FLAG_STOCK_PRICE_TRACKING', true);
|
||||
Setting('FEATURE_FLAG_STOCK_LOCATION_TRACKING', true);
|
||||
Setting('FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING', true);
|
||||
Setting('FEATURE_FLAG_STOCK_PRODUCT_OPENED_TRACKING', true);
|
||||
Setting('FEATURE_FLAG_STOCK_PRODUCT_FREEZING', true);
|
||||
Setting('FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_FIELD_NUMBER_PAD', true); // Activate the number pad in due date fields on (supported) mobile browsers
|
||||
Setting('FEATURE_FLAG_SHOPPINGLIST_MULTIPLE_LISTS', true);
|
||||
Setting('FEATURE_FLAG_RECIPES_MEALPLAN', true);
|
||||
Setting('FEATURE_FLAG_CHORES_ASSIGNMENTS', true);
|
||||
Setting('FEATURE_FLAG_THERMAL_PRINTER', false);
|
||||
|
||||
// Feature settings
|
||||
Setting('FEATURE_FLAG_DISABLE_BROWSER_BARCODE_CAMERA_SCANNING', false); // Set this to true if you want to disable the ability to scan a barcode via the device camera (Browser API)
|
||||
Setting('FEATURE_FLAG_AUTO_TORCH_ON_WITH_CAMERA', true); // Enables the torch automatically (if the device has one)
|
||||
|
||||
|
||||
// Default user settings
|
||||
// These settings can be changed per user and via the UI,
|
||||
// below are the defaults which are used when the user has not changed the setting so far
|
||||
|
||||
// Night mode related
|
||||
DefaultUserSetting('night_mode', 'follow-system'); // "on" = Night mode is always on ; "off" = Night mode is always off / "follow-system" = System preferred color schema is used
|
||||
DefaultUserSetting('auto_night_mode_enabled', false); // If night mode is enabled automatically when inside a given time range (see the two settings below)
|
||||
DefaultUserSetting('auto_night_mode_time_range_from', '20:00'); // Format HH:mm
|
||||
DefaultUserSetting('auto_night_mode_time_range_to', '07:00'); // Format HH:mm
|
||||
DefaultUserSetting('auto_night_mode_time_range_goes_over_midnight', true); // If the time range above goes over midnight
|
||||
DefaultUserSetting('night_mode_enabled_internal', false); // Internal setting if night mode is actually enabled (based on the other settings)
|
||||
|
||||
// Generic settings
|
||||
DefaultUserSetting('auto_reload_on_db_change', false); // If the page should be automatically reloaded when there was an external change
|
||||
DefaultUserSetting('show_clock_in_header', false); // Show a clock in the header next to the logo or not
|
||||
DefaultUserSetting('keep_screen_on', false); // If the screen should always be kept on
|
||||
DefaultUserSetting('keep_screen_on_when_fullscreen_card', false); // If the screen should be kept on when a "fullscreen-card" is displayed
|
||||
|
||||
// Stock settings
|
||||
DefaultUserSetting('product_presets_location_id', -1); // Default location id for new products (-1 means no location is preset)
|
||||
DefaultUserSetting('product_presets_product_group_id', -1); // Default product group id for new products (-1 means no product group is preset)
|
||||
DefaultUserSetting('product_presets_qu_id', -1); // Default quantity unit id for new products (-1 means no quantity unit is preset)
|
||||
DefaultUserSetting('product_presets_default_due_days', 0); // Default due days for new products (-1 means that the product will be never overdue)
|
||||
DefaultUserSetting('product_presets_treat_opened_as_out_of_stock', true); // Default "Treat opened as out of stock" option for new products
|
||||
DefaultUserSetting('product_presets_default_stock_label_type', 0); // "Default stock entry label" option for new products (0 = No label, 1 = Single Label, 2 = Label per unit)
|
||||
DefaultUserSetting('stock_decimal_places_amounts', 4); // Default decimal places allowed for amounts
|
||||
DefaultUserSetting('stock_decimal_places_prices_input', 2); // Default decimal places allowed for prices (input)
|
||||
DefaultUserSetting('stock_decimal_places_prices_display', 2); // Default decimal places allowed for prices (display)
|
||||
DefaultUserSetting('stock_auto_decimal_separator_prices', false); // If the decimal separator should be set automatically for amount inputs
|
||||
DefaultUserSetting('stock_due_soon_days', 5); // The "expiring soon" days
|
||||
DefaultUserSetting('stock_default_purchase_amount', 0); // The default amount prefilled on the purchase page
|
||||
DefaultUserSetting('stock_default_consume_amount', 1); // The default amount prefilled on the consume page
|
||||
DefaultUserSetting('stock_default_consume_amount_use_quick_consume_amount', false); // If the products quick consume amount should be prefilled on the consume page
|
||||
DefaultUserSetting('scan_mode_consume_enabled', false); // If scan mode on the consume page is enabled
|
||||
DefaultUserSetting('scan_mode_purchase_enabled', false); // If scan mode on the purchase page is enabled
|
||||
DefaultUserSetting('show_icon_on_stock_overview_page_when_product_is_on_shopping_list', true); // When enabled, an icon is shown on the stock overview page (next to the product name) when the prodcut is currently on a shopping list
|
||||
DefaultUserSetting('stock_overview_show_all_out_of_stock_products', false); // By default the stock overview page lists all products which are currently in stock or below their min. stock amount - when this is enabled, all (active) products are always shown
|
||||
DefaultUserSetting('show_purchased_date_on_purchase', false); // Whether the purchased date should be editable on purchase (defaults to today otherwise)
|
||||
DefaultUserSetting('show_warning_on_purchase_when_due_date_is_earlier_than_next', true); // Show a warning on purchase when the due date of the purchased product is earlier than the next due date in stock
|
||||
|
||||
// Shopping list settings
|
||||
DefaultUserSetting('shopping_list_to_stock_workflow_auto_submit_when_prefilled', false); // Automatically do the booking using the last price and the amount of the shopping list item, if the product has "Default due days" set
|
||||
DefaultUserSetting('shopping_list_show_calendar', false); // When enabled, a small (month view) calendar will be shown on the shopping list page
|
||||
DefaultUserSetting('shopping_list_round_up', false); // When enabled, all quantity amounts on the shopping list are always displayed rounded up to the nearest whole number
|
||||
DefaultUserSetting('shopping_list_auto_add_below_min_stock_amount', false); // If products should be automatically added to the shopping list when they are below their min. stock amount
|
||||
DefaultUserSetting('shopping_list_auto_add_below_min_stock_amount_list_id', 1); // When the above setting is enabled, the id of the shopping list to which the products will be added
|
||||
DefaultUserSetting('shopping_list_print_show_header', true); // Default for the shopping list print option "Show header"
|
||||
DefaultUserSetting('shopping_list_print_group_by_product_group', true); // Default for the shopping list print option "Group by product group"
|
||||
DefaultUserSetting('shopping_list_print_layout_type', 'table'); // Default for the shopping list print option "Layout type" (table or list)
|
||||
|
||||
// Recipe settings
|
||||
DefaultUserSetting('recipe_ingredients_group_by_product_group', false); // Group recipe ingredients by their product group
|
||||
DefaultUserSetting('recipes_show_list_side_by_side', true); // If the recipe should be displayed next to recipe list on the recipes page
|
||||
DefaultUserSetting('recipes_show_ingredient_checkbox', false); // When enabled, a little checkbox will be shown next to each ingredient to mark it as done
|
||||
|
||||
// Chores settings
|
||||
DefaultUserSetting('chores_due_soon_days', 5); // The "due soon" days
|
||||
DefaultUserSetting('chores_overview_swap_tracking_buttons', false); // When enabled, the "Track next chore schedule" and "Track chore execution now" buttons/menu items are swapped
|
||||
|
||||
// Batteries settings
|
||||
DefaultUserSetting('batteries_due_soon_days', 5); // The "due soon" days
|
||||
|
||||
// Tasks settings
|
||||
DefaultUserSetting('tasks_due_soon_days', 5); // The "due soon" days
|
||||
|
||||
// Calendar settings
|
||||
DefaultUserSetting('calendar_color_products', '#007bff'); // The event color (hex code) for due products
|
||||
DefaultUserSetting('calendar_color_tasks', '#28a745'); // The event color (hex code) for due tasks
|
||||
DefaultUserSetting('calendar_color_chores', '#ffc107'); // The event color (hex code) for due chores
|
||||
DefaultUserSetting('calendar_color_batteries', '#17a2b8'); // The event color (hex code) for due battery charge cycles
|
||||
DefaultUserSetting('calendar_color_meal_plan', '#6c757d'); // The event color (hex code) for meal plan items
|
||||
@@ -1,443 +0,0 @@
|
||||
# For more information, see the Configuration Guide:
|
||||
# https://www.librechat.ai/docs/configuration/librechat_yaml
|
||||
|
||||
# Configuration version (required)
|
||||
version: 1.2.1
|
||||
|
||||
# Cache settings: Set to true to enable caching
|
||||
cache: true
|
||||
|
||||
# File storage configuration
|
||||
# Single strategy for all file types (legacy format, still supported)
|
||||
# fileStrategy: "s3"
|
||||
|
||||
# Granular file storage strategies (new format - recommended)
|
||||
# Allows different storage strategies for different file types
|
||||
# fileStrategy:
|
||||
# avatar: "s3" # Storage for user/agent avatar images
|
||||
# image: "firebase" # Storage for uploaded images in chats
|
||||
# document: "local" # Storage for document uploads (PDFs, text files, etc.)
|
||||
|
||||
# Available strategies: "local", "s3", "firebase"
|
||||
# If not specified, defaults to "local" for all file types
|
||||
# You can mix and match strategies based on your needs:
|
||||
# - Use S3 for avatars for fast global access
|
||||
# - Use Firebase for images with automatic optimization
|
||||
# - Use local storage for documents for privacy/compliance
|
||||
|
||||
# Custom interface configuration
|
||||
interface:
|
||||
customWelcome: 'Welcome to LibreChat! Enjoy your experience.'
|
||||
# Enable/disable file search as a chatarea selection (default: true)
|
||||
# Note: This setting does not disable the Agents File Search Capability.
|
||||
# To disable the Agents Capability, see the Agents Endpoint configuration instead.
|
||||
fileSearch: true
|
||||
# Privacy policy settings
|
||||
privacyPolicy:
|
||||
externalUrl: 'https://librechat.ai/privacy-policy'
|
||||
openNewTab: true
|
||||
|
||||
# Terms of service
|
||||
termsOfService:
|
||||
externalUrl: 'https://librechat.ai/tos'
|
||||
openNewTab: true
|
||||
modalAcceptance: true
|
||||
modalTitle: 'Terms of Service for LibreChat'
|
||||
modalContent: |
|
||||
# Terms and Conditions for LibreChat
|
||||
|
||||
*Effective Date: February 18, 2024*
|
||||
|
||||
Welcome to LibreChat, the informational website for the open-source AI chat platform, available at https://librechat.ai. These Terms of Service ("Terms") govern your use of our website and the services we offer. By accessing or using the Website, you agree to be bound by these Terms and our Privacy Policy, accessible at https://librechat.ai//privacy.
|
||||
|
||||
## 1. Ownership
|
||||
|
||||
Upon purchasing a package from LibreChat, you are granted the right to download and use the code for accessing an admin panel for LibreChat. While you own the downloaded code, you are expressly prohibited from reselling, redistributing, or otherwise transferring the code to third parties without explicit permission from LibreChat.
|
||||
|
||||
## 2. User Data
|
||||
|
||||
We collect personal data, such as your name, email address, and payment information, as described in our Privacy Policy. This information is collected to provide and improve our services, process transactions, and communicate with you.
|
||||
|
||||
## 3. Non-Personal Data Collection
|
||||
|
||||
The Website uses cookies to enhance user experience, analyze site usage, and facilitate certain functionalities. By using the Website, you consent to the use of cookies in accordance with our Privacy Policy.
|
||||
|
||||
## 4. Use of the Website
|
||||
|
||||
You agree to use the Website only for lawful purposes and in a manner that does not infringe the rights of, restrict, or inhibit anyone else's use and enjoyment of the Website. Prohibited behavior includes harassing or causing distress or inconvenience to any person, transmitting obscene or offensive content, or disrupting the normal flow of dialogue within the Website.
|
||||
|
||||
## 5. Governing Law
|
||||
|
||||
These Terms shall be governed by and construed in accordance with the laws of the United States, without giving effect to any principles of conflicts of law.
|
||||
|
||||
## 6. Changes to the Terms
|
||||
|
||||
We reserve the right to modify these Terms at any time. We will notify users of any changes by email. Your continued use of the Website after such changes have been notified will constitute your consent to such changes.
|
||||
|
||||
## 7. Contact Information
|
||||
|
||||
If you have any questions about these Terms, please contact us at contact@librechat.ai.
|
||||
|
||||
By using the Website, you acknowledge that you have read these Terms of Service and agree to be bound by them.
|
||||
|
||||
endpointsMenu: true
|
||||
modelSelect: true
|
||||
parameters: true
|
||||
sidePanel: true
|
||||
presets: true
|
||||
prompts: true
|
||||
bookmarks: true
|
||||
multiConvo: true
|
||||
agents: true
|
||||
peoplePicker:
|
||||
users: true
|
||||
groups: true
|
||||
roles: true
|
||||
marketplace:
|
||||
use: false
|
||||
fileCitations: true
|
||||
# Temporary chat retention period in hours (default: 720, min: 1, max: 8760)
|
||||
# temporaryChatRetention: 1
|
||||
|
||||
# Example Cloudflare turnstile (optional)
|
||||
#turnstile:
|
||||
# siteKey: "your-site-key-here"
|
||||
# options:
|
||||
# language: "auto" # "auto" or an ISO 639-1 language code (e.g. en)
|
||||
# size: "normal" # Options: "normal", "compact", "flexible", or "invisible"
|
||||
|
||||
# Example Registration Object Structure (optional)
|
||||
registration:
|
||||
socialLogins: ['github', 'google', 'discord', 'openid', 'facebook', 'apple', 'saml']
|
||||
# allowedDomains:
|
||||
# - "gmail.com"
|
||||
|
||||
# Example Balance settings
|
||||
# balance:
|
||||
# enabled: false
|
||||
# startBalance: 20000
|
||||
# autoRefillEnabled: false
|
||||
# refillIntervalValue: 30
|
||||
# refillIntervalUnit: 'days'
|
||||
# refillAmount: 10000
|
||||
|
||||
# Example Transactions settings
|
||||
# Controls whether to save transaction records to the database
|
||||
# Default is true (enabled)
|
||||
#transactions:
|
||||
# enabled: false
|
||||
# Note: If balance.enabled is true, transactions will always be enabled
|
||||
# regardless of this setting to ensure balance tracking works correctly
|
||||
|
||||
# speech:
|
||||
# tts:
|
||||
# openai:
|
||||
# url: ''
|
||||
# apiKey: '${TTS_API_KEY}'
|
||||
# model: ''
|
||||
# voices: ['']
|
||||
|
||||
#
|
||||
# stt:
|
||||
# openai:
|
||||
# url: ''
|
||||
# apiKey: '${STT_API_KEY}'
|
||||
# model: ''
|
||||
|
||||
# rateLimits:
|
||||
# fileUploads:
|
||||
# ipMax: 100
|
||||
# ipWindowInMinutes: 60 # Rate limit window for file uploads per IP
|
||||
# userMax: 50
|
||||
# userWindowInMinutes: 60 # Rate limit window for file uploads per user
|
||||
# conversationsImport:
|
||||
# ipMax: 100
|
||||
# ipWindowInMinutes: 60 # Rate limit window for conversation imports per IP
|
||||
# userMax: 50
|
||||
# userWindowInMinutes: 60 # Rate limit window for conversation imports per user
|
||||
|
||||
# Example Actions Object Structure
|
||||
actions:
|
||||
allowedDomains:
|
||||
- 'swapi.dev'
|
||||
- 'librechat.ai'
|
||||
- 'google.com'
|
||||
|
||||
# Example MCP Servers Object Structure
|
||||
# mcpServers:
|
||||
# everything:
|
||||
# # type: sse # type can optionally be omitted
|
||||
# url: http://localhost:3001/sse
|
||||
# timeout: 60000 # 1 minute timeout for this server, this is the default timeout for MCP servers.
|
||||
# puppeteer:
|
||||
# type: stdio
|
||||
# command: npx
|
||||
# args:
|
||||
# - -y
|
||||
# - "@modelcontextprotocol/server-puppeteer"
|
||||
# timeout: 300000 # 5 minutes timeout for this server
|
||||
# filesystem:
|
||||
# # type: stdio
|
||||
# command: npx
|
||||
# args:
|
||||
# - -y
|
||||
# - "@modelcontextprotocol/server-filesystem"
|
||||
# - /home/user/LibreChat/
|
||||
# iconPath: /home/user/LibreChat/client/public/assets/logo.svg
|
||||
# mcp-obsidian:
|
||||
# command: npx
|
||||
# args:
|
||||
# - -y
|
||||
# - "mcp-obsidian"
|
||||
# - /path/to/obsidian/vault
|
||||
|
||||
# Definition of custom endpoints
|
||||
endpoints:
|
||||
# assistants:
|
||||
# disableBuilder: false # Disable Assistants Builder Interface by setting to `true`
|
||||
# pollIntervalMs: 3000 # Polling interval for checking assistant updates
|
||||
# timeoutMs: 180000 # Timeout for assistant operations
|
||||
# # Should only be one or the other, either `supportedIds` or `excludedIds`
|
||||
# supportedIds: ["asst_supportedAssistantId1", "asst_supportedAssistantId2"]
|
||||
# # excludedIds: ["asst_excludedAssistantId"]
|
||||
# # Only show assistants that the user created or that were created externally (e.g. in Assistants playground).
|
||||
# # privateAssistants: false # Does not work with `supportedIds` or `excludedIds`
|
||||
# # (optional) Models that support retrieval, will default to latest known OpenAI models that support the feature
|
||||
# retrievalModels: ["gpt-4-turbo-preview"]
|
||||
# # (optional) Assistant Capabilities available to all users. Omit the ones you wish to exclude. Defaults to list below.
|
||||
# capabilities: ["code_interpreter", "retrieval", "actions", "tools", "image_vision"]
|
||||
# agents:
|
||||
# # (optional) Default recursion depth for agents, defaults to 25
|
||||
# recursionLimit: 50
|
||||
# # (optional) Max recursion depth for agents, defaults to 25
|
||||
# maxRecursionLimit: 100
|
||||
# # (optional) Disable the builder interface for agents
|
||||
# disableBuilder: false
|
||||
# # (optional) Maximum total citations to include in agent responses, defaults to 30
|
||||
# maxCitations: 30
|
||||
# # (optional) Maximum citations per file to include in agent responses, defaults to 7
|
||||
# maxCitationsPerFile: 7
|
||||
# # (optional) Minimum relevance score for sources to be included in responses, defaults to 0.45 (45% relevance threshold)
|
||||
# # Set to 0.0 to show all sources (no filtering), or higher like 0.7 for stricter filtering
|
||||
# minRelevanceScore: 0.45
|
||||
# # (optional) Agent Capabilities available to all users. Omit the ones you wish to exclude. Defaults to list below.
|
||||
# capabilities: ["execute_code", "file_search", "actions", "tools"]
|
||||
custom:
|
||||
# Groq Example
|
||||
- name: 'groq'
|
||||
apiKey: '${GROQ_API_KEY}'
|
||||
baseURL: 'https://api.groq.com/openai/v1/'
|
||||
models:
|
||||
default:
|
||||
- 'llama3-70b-8192'
|
||||
- 'llama3-8b-8192'
|
||||
- 'llama2-70b-4096'
|
||||
- 'mixtral-8x7b-32768'
|
||||
- 'gemma-7b-it'
|
||||
fetch: false
|
||||
titleConvo: true
|
||||
titleModel: 'mixtral-8x7b-32768'
|
||||
modelDisplayLabel: 'groq'
|
||||
|
||||
# Mistral AI Example
|
||||
- name: 'Mistral' # Unique name for the endpoint
|
||||
# For `apiKey` and `baseURL`, you can use environment variables that you define.
|
||||
# recommended environment variables:
|
||||
apiKey: '${MISTRAL_API_KEY}'
|
||||
baseURL: 'https://api.mistral.ai/v1'
|
||||
|
||||
# Models configuration
|
||||
models:
|
||||
# List of default models to use. At least one value is required.
|
||||
default: ['mistral-tiny', 'mistral-small', 'mistral-medium']
|
||||
# Fetch option: Set to true to fetch models from API.
|
||||
fetch: true # Defaults to false.
|
||||
|
||||
# Optional configurations
|
||||
|
||||
# Title Conversation setting
|
||||
titleConvo: true # Set to true to enable title conversation
|
||||
|
||||
# Title Method: Choose between "completion" or "functions".
|
||||
# titleMethod: "completion" # Defaults to "completion" if omitted.
|
||||
|
||||
# Title Model: Specify the model to use for titles.
|
||||
titleModel: 'mistral-tiny' # Defaults to "gpt-3.5-turbo" if omitted.
|
||||
|
||||
# Summarize setting: Set to true to enable summarization.
|
||||
# summarize: false
|
||||
|
||||
# Summary Model: Specify the model to use if summarization is enabled.
|
||||
# summaryModel: "mistral-tiny" # Defaults to "gpt-3.5-turbo" if omitted.
|
||||
|
||||
# Force Prompt setting: If true, sends a `prompt` parameter instead of `messages`.
|
||||
# forcePrompt: false
|
||||
|
||||
# The label displayed for the AI model in messages.
|
||||
modelDisplayLabel: 'Mistral' # Default is "AI" when not set.
|
||||
|
||||
# Add additional parameters to the request. Default params will be overwritten.
|
||||
# addParams:
|
||||
# safe_prompt: true # This field is specific to Mistral AI: https://docs.mistral.ai/api/
|
||||
|
||||
# Drop Default params parameters from the request. See default params in guide linked below.
|
||||
# NOTE: For Mistral, it is necessary to drop the following parameters or you will encounter a 422 Error:
|
||||
dropParams: ['stop', 'user', 'frequency_penalty', 'presence_penalty']
|
||||
|
||||
# OpenRouter Example
|
||||
- name: 'OpenRouter'
|
||||
# For `apiKey` and `baseURL`, you can use environment variables that you define.
|
||||
# recommended environment variables:
|
||||
apiKey: '${OPENROUTER_KEY}'
|
||||
baseURL: 'https://openrouter.ai/api/v1'
|
||||
headers:
|
||||
x-librechat-body-parentmessageid: '{{LIBRECHAT_BODY_PARENTMESSAGEID}}'
|
||||
models:
|
||||
default: ['meta-llama/llama-3-70b-instruct']
|
||||
fetch: true
|
||||
titleConvo: true
|
||||
titleModel: 'meta-llama/llama-3-70b-instruct'
|
||||
# Recommended: Drop the stop parameter from the request as Openrouter models use a variety of stop tokens.
|
||||
dropParams: ['stop']
|
||||
modelDisplayLabel: 'OpenRouter'
|
||||
|
||||
# Portkey AI Example
|
||||
- name: 'Portkey'
|
||||
apiKey: 'dummy'
|
||||
baseURL: 'https://api.portkey.ai/v1'
|
||||
headers:
|
||||
x-portkey-api-key: '${PORTKEY_API_KEY}'
|
||||
x-portkey-virtual-key: '${PORTKEY_OPENAI_VIRTUAL_KEY}'
|
||||
models:
|
||||
default: ['gpt-4o-mini', 'gpt-4o', 'chatgpt-4o-latest']
|
||||
fetch: true
|
||||
titleConvo: true
|
||||
titleModel: 'current_model'
|
||||
summarize: false
|
||||
summaryModel: 'current_model'
|
||||
forcePrompt: false
|
||||
modelDisplayLabel: 'Portkey'
|
||||
iconURL: https://images.crunchbase.com/image/upload/c_pad,f_auto,q_auto:eco,dpr_1/rjqy7ghvjoiu4cd1xjbf
|
||||
# Example modelSpecs configuration showing grouping options
|
||||
# The 'group' field organizes model specs in the UI selector:
|
||||
# - If 'group' matches an endpoint name (e.g., "openAI", "groq"), the spec appears nested under that endpoint
|
||||
# - If 'group' is a custom name (doesn't match any endpoint), it creates a separate collapsible section
|
||||
# - If 'group' is omitted, the spec appears as a standalone item at the top level
|
||||
# modelSpecs:
|
||||
# list:
|
||||
# # Example 1: Nested under an endpoint (grouped with openAI endpoint)
|
||||
# - name: "gpt-4o"
|
||||
# label: "GPT-4 Optimized"
|
||||
# description: "Most capable GPT-4 model with multimodal support"
|
||||
# group: "openAI" # String value matching the endpoint name
|
||||
# preset:
|
||||
# endpoint: "openAI"
|
||||
# model: "gpt-4o"
|
||||
#
|
||||
# # Example 2: Nested under a custom endpoint (grouped with groq endpoint)
|
||||
# - name: "llama3-70b-8192"
|
||||
# label: "Llama 3 70B"
|
||||
# description: "Fastest inference available - great for quick responses"
|
||||
# group: "groq" # String value matching your custom endpoint name from endpoints.custom
|
||||
# preset:
|
||||
# endpoint: "groq"
|
||||
# model: "llama3-70b-8192"
|
||||
#
|
||||
# # Example 3: Custom group (creates a separate collapsible section)
|
||||
# - name: "coding-assistant"
|
||||
# label: "Coding Assistant"
|
||||
# description: "Specialized for coding tasks"
|
||||
# group: "my-assistants" # Custom string - doesn't match any endpoint, so creates its own group
|
||||
# preset:
|
||||
# endpoint: "openAI"
|
||||
# model: "gpt-4o"
|
||||
# instructions: "You are an expert coding assistant..."
|
||||
# temperature: 0.3
|
||||
#
|
||||
# - name: "writing-assistant"
|
||||
# label: "Writing Assistant"
|
||||
# description: "Specialized for creative writing"
|
||||
# group: "my-assistants" # Same custom group name - both specs appear in same section
|
||||
# preset:
|
||||
# endpoint: "anthropic"
|
||||
# model: "claude-sonnet-4"
|
||||
# instructions: "You are a creative writing expert..."
|
||||
#
|
||||
# # Example 4: Standalone (no group - appears at top level)
|
||||
# - name: "general-assistant"
|
||||
# label: "General Assistant"
|
||||
# description: "General purpose assistant"
|
||||
# # No 'group' field - appears as standalone item at top level (not nested)
|
||||
# preset:
|
||||
# endpoint: "openAI"
|
||||
# model: "gpt-4o-mini"
|
||||
|
||||
# fileConfig:
|
||||
# endpoints:
|
||||
# assistants:
|
||||
# fileLimit: 5
|
||||
# fileSizeLimit: 10 # Maximum size for an individual file in MB
|
||||
# totalSizeLimit: 50 # Maximum total size for all files in a single request in MB
|
||||
# supportedMimeTypes:
|
||||
# - "image/.*"
|
||||
# - "application/pdf"
|
||||
# openAI:
|
||||
# disabled: true # Disables file uploading to the OpenAI endpoint
|
||||
# default:
|
||||
# totalSizeLimit: 20
|
||||
# YourCustomEndpointName:
|
||||
# fileLimit: 2
|
||||
# fileSizeLimit: 5
|
||||
# serverFileSizeLimit: 100 # Global server file size limit in MB
|
||||
# avatarSizeLimit: 2 # Limit for user avatar image size in MB
|
||||
# imageGeneration: # Image Gen settings, either percentage or px
|
||||
# percentage: 100
|
||||
# px: 1024
|
||||
# # Client-side image resizing to prevent upload errors
|
||||
# clientImageResize:
|
||||
# enabled: false # Enable/disable client-side image resizing (default: false)
|
||||
# maxWidth: 1900 # Maximum width for resized images (default: 1900)
|
||||
# maxHeight: 1900 # Maximum height for resized images (default: 1900)
|
||||
# quality: 0.92 # JPEG quality for compression (0.0-1.0, default: 0.92)
|
||||
# # See the Custom Configuration Guide for more information on Assistants Config:
|
||||
# # https://www.librechat.ai/docs/configuration/librechat_yaml/object_structure/assistants_endpoint
|
||||
|
||||
# Web Search Configuration (optional)
|
||||
# webSearch:
|
||||
# # Jina Reranking Configuration
|
||||
# jinaApiKey: '${JINA_API_KEY}' # Your Jina API key
|
||||
# jinaApiUrl: '${JINA_API_URL}' # Custom Jina API URL (optional, defaults to https://api.jina.ai/v1/rerank)
|
||||
#
|
||||
# # Other rerankers
|
||||
# cohereApiKey: '${COHERE_API_KEY}'
|
||||
#
|
||||
# # Search providers
|
||||
# serperApiKey: '${SERPER_API_KEY}'
|
||||
# searxngInstanceUrl: '${SEARXNG_INSTANCE_URL}'
|
||||
# searxngApiKey: '${SEARXNG_API_KEY}'
|
||||
#
|
||||
# # Content scrapers
|
||||
# firecrawlApiKey: '${FIRECRAWL_API_KEY}'
|
||||
# firecrawlApiUrl: '${FIRECRAWL_API_URL}'
|
||||
|
||||
# Memory configuration for user memories
|
||||
# memory:
|
||||
# # (optional) Disable memory functionality
|
||||
# disabled: false
|
||||
# # (optional) Restrict memory keys to specific values to limit memory storage and improve consistency
|
||||
# validKeys: ["preferences", "work_info", "personal_info", "skills", "interests", "context"]
|
||||
# # (optional) Maximum token limit for memory storage (not yet implemented for token counting)
|
||||
# tokenLimit: 10000
|
||||
# # (optional) Enable personalization features (defaults to true if memory is configured)
|
||||
# # When false, users will not see the Personalization tab in settings
|
||||
# personalize: true
|
||||
# # Memory agent configuration - either use an existing agent by ID or define inline
|
||||
# agent:
|
||||
# # Option 1: Use existing agent by ID
|
||||
# id: "your-memory-agent-id"
|
||||
# # Option 2: Define agent inline
|
||||
# # provider: "openai"
|
||||
# # model: "gpt-4o-mini"
|
||||
# # instructions: "You are a memory management assistant. Store and manage user information accurately."
|
||||
# # model_parameters:
|
||||
# # temperature: 0.1
|
||||
@@ -1,164 +0,0 @@
|
||||
version: 1.2.1
|
||||
|
||||
cache: true
|
||||
|
||||
interface:
|
||||
customWelcome: "Welcome to DroidChat! How may I be of assistance?"
|
||||
mcpServers:
|
||||
placeholder: 'MCP Servers'
|
||||
privacyPolicy:
|
||||
externalUrl: 'https://librechat.ai/privacy-policy'
|
||||
openNewTab: true
|
||||
termsOfService:
|
||||
externalUrl: 'https://librechat.ai/tos'
|
||||
openNewTab: true
|
||||
modalAcceptance: true
|
||||
modalTitle: "Terms of Service for LibreChat"
|
||||
modalContent: |
|
||||
# Terms and Conditions for LibreChat
|
||||
|
||||
Welcome to LibreChat!
|
||||
endpointsMenu: true
|
||||
modelSelect: true
|
||||
parameters: true
|
||||
sidePanel: true
|
||||
presets: true
|
||||
prompts: true
|
||||
bookmarks: true
|
||||
multiConvo: true
|
||||
agents: true
|
||||
|
||||
speech:
|
||||
speechTab:
|
||||
conversationMode: true
|
||||
advancedMode: false
|
||||
speechToText:
|
||||
engineSTT: "external"
|
||||
languageSTT: "English (UK)"
|
||||
autoTranscribeAudio: true
|
||||
decibelValue: -45
|
||||
autoSendText: 0
|
||||
textToSpeech:
|
||||
engineTTS: "external"
|
||||
voice: "alloy"
|
||||
languageTTS: "en"
|
||||
automaticPlayback: true
|
||||
playbackRate: 1.2
|
||||
cacheTTS: true
|
||||
tts:
|
||||
openai:
|
||||
url: 'https://aihubmix.com/v1'
|
||||
apiKey: '${AIHUBMIX_KEY}'
|
||||
model: 'gpt-4o-mini-tts'
|
||||
voices: [
|
||||
'alloy',
|
||||
'ash',
|
||||
'ballad',
|
||||
'coral',
|
||||
'echo',
|
||||
'fable',
|
||||
'nova',
|
||||
'onyx',
|
||||
'sage',
|
||||
'shimmer',
|
||||
]
|
||||
|
||||
stt:
|
||||
openai:
|
||||
url: 'https://aihubmix.com/v1'
|
||||
apiKey: '${AIHUBMIX_KEY}'
|
||||
model: 'distil-whisper-large-v3-en'
|
||||
|
||||
# Example MCP Servers Object Structure
|
||||
# mcpServers:
|
||||
# everything:
|
||||
# # type: sse # type can optionally be omitted
|
||||
# url: http://localhost:3001/sse
|
||||
# timeout: 60000 # 1 minute timeout for this server, this is the default timeout for MCP servers.
|
||||
# puppeteer:
|
||||
# type: stdio
|
||||
# command: npx
|
||||
# args:
|
||||
# - -y
|
||||
# - "@modelcontextprotocol/server-puppeteer"
|
||||
# timeout: 300000 # 5 minutes timeout for this server
|
||||
# filesystem:
|
||||
# # type: stdio
|
||||
# command: npx
|
||||
# args:
|
||||
# - -y
|
||||
# - "@modelcontextprotocol/server-filesystem"
|
||||
# - /files/Library
|
||||
# - /files/RPG/Resources
|
||||
# mcp-obsidian:
|
||||
# command: npx
|
||||
# args:
|
||||
# - -y
|
||||
# - "mcp-obsidian"
|
||||
# - /files/Notes
|
||||
|
||||
endpoints:
|
||||
custom:
|
||||
- name: 'OpenRouter'
|
||||
apiKey: '${OPENROUTER_KEY}'
|
||||
baseURL: 'https://openrouter.ai/api/v1'
|
||||
models:
|
||||
default:
|
||||
- 'switchpoint/router'
|
||||
- 'moonshotai/kimi-k2:free'
|
||||
- 'deepseek/deepseek-chat-v3-0324:free'
|
||||
- 'deepseek/deepseek-r1-0528:free'
|
||||
- 'openai/gpt-4.1'
|
||||
- 'openai/o3'
|
||||
fetch: true
|
||||
titleConvo: true
|
||||
titleModel: 'moonshotai/kimi-k2:free'
|
||||
dropParams: ['stop']
|
||||
modelDisplayLabel: 'OpenRouter'
|
||||
|
||||
- name: 'AiHubMix'
|
||||
apiKey: '${AIHUBMIX_KEY}'
|
||||
baseURL: 'https://aihubmix.com/v1'
|
||||
models:
|
||||
default:
|
||||
- 'moonshotai/kimi-k2'
|
||||
- 'deepseek/deepseek-chat-v3-0324'
|
||||
- 'deepseek/deepseek-r1-0528'
|
||||
fetch: true
|
||||
titleConvo: true
|
||||
titleModel: 'gpt-4o-mini'
|
||||
dropParams: ['stop']
|
||||
modelDisplayLabel: 'OpenRouter'
|
||||
|
||||
fileConfig:
|
||||
clientImageResize:
|
||||
enabled: true
|
||||
maxWidth: 1900
|
||||
maxHeight: 1900
|
||||
quality: 0.92
|
||||
|
||||
# Memory configuration for user memories
|
||||
memory:
|
||||
disabled: false
|
||||
validKeys:
|
||||
- "preferences"
|
||||
- "personal_info"
|
||||
- "skills"
|
||||
- "interests"
|
||||
- "goals"
|
||||
- "current_projects"
|
||||
- "misc"
|
||||
tokenLimit: 5000
|
||||
personalize: true
|
||||
agent:
|
||||
provider: "OpenRouter"
|
||||
model: "openai/gpt-oss-20b"
|
||||
instructions: |
|
||||
Store information only in the specified validKeys categories.
|
||||
Focus on explicitly stated preferences and importan facts.
|
||||
Delete outdated or corrected information promptly.
|
||||
Do not override previous memories in the same key.
|
||||
When storing new memory for a key make sure include previous memory information unless it is outdated or incorrect.
|
||||
Only remember information when specifically asked or if it would be useful to know in other contexts.
|
||||
model_parameters:
|
||||
temperature: 0.1
|
||||
@@ -1,2 +0,0 @@
|
||||
*
|
||||
!.gitignore
|
||||
@@ -1,212 +0,0 @@
|
||||
# AGENTS.md - Your Workspace
|
||||
|
||||
This folder is home. Treat it that way.
|
||||
|
||||
## First Run
|
||||
|
||||
If `BOOTSTRAP.md` exists, that's your birth certificate. Follow it, figure out who you are, then delete it. You won't need it again.
|
||||
|
||||
## Every Session
|
||||
|
||||
Before doing anything else:
|
||||
|
||||
1. Read `SOUL.md` — this is who you are
|
||||
2. Read `USER.md` — this is who you're helping
|
||||
3. Read `memory/YYYY-MM-DD.md` (today + yesterday) for recent context
|
||||
4. **If in MAIN SESSION** (direct chat with your human): Also read `MEMORY.md`
|
||||
|
||||
Don't ask permission. Just do it.
|
||||
|
||||
## Memory
|
||||
|
||||
You wake up fresh each session. These files are your continuity:
|
||||
|
||||
- **Daily notes:** `memory/YYYY-MM-DD.md` (create `memory/` if needed) — raw logs of what happened
|
||||
- **Long-term:** `MEMORY.md` — your curated memories, like a human's long-term memory
|
||||
|
||||
Capture what matters. Decisions, context, things to remember. Skip the secrets unless asked to keep them.
|
||||
|
||||
### 🧠 MEMORY.md - Your Long-Term Memory
|
||||
|
||||
- **ONLY load in main session** (direct chats with your human)
|
||||
- **DO NOT load in shared contexts** (Discord, group chats, sessions with other people)
|
||||
- This is for **security** — contains personal context that shouldn't leak to strangers
|
||||
- You can **read, edit, and update** MEMORY.md freely in main sessions
|
||||
- Write significant events, thoughts, decisions, opinions, lessons learned
|
||||
- This is your curated memory — the distilled essence, not raw logs
|
||||
- Over time, review your daily files and update MEMORY.md with what's worth keeping
|
||||
|
||||
### 📝 Write It Down - No "Mental Notes"!
|
||||
|
||||
- **Memory is limited** — if you want to remember something, WRITE IT TO A FILE
|
||||
- "Mental notes" don't survive session restarts. Files do.
|
||||
- When someone says "remember this" → update `memory/YYYY-MM-DD.md` or relevant file
|
||||
- When you learn a lesson → update AGENTS.md, TOOLS.md, or the relevant skill
|
||||
- When you make a mistake → document it so future-you doesn't repeat it
|
||||
- **Text > Brain** 📝
|
||||
|
||||
## Safety
|
||||
|
||||
- Don't exfiltrate private data. Ever.
|
||||
- Don't run destructive commands without asking.
|
||||
- `trash` > `rm` (recoverable beats gone forever)
|
||||
- When in doubt, ask.
|
||||
|
||||
## External vs Internal
|
||||
|
||||
**Safe to do freely:**
|
||||
|
||||
- Read files, explore, organize, learn
|
||||
- Search the web, check calendars
|
||||
- Work within this workspace
|
||||
|
||||
**Ask first:**
|
||||
|
||||
- Sending emails, tweets, public posts
|
||||
- Anything that leaves the machine
|
||||
- Anything you're uncertain about
|
||||
|
||||
## Group Chats
|
||||
|
||||
You have access to your human's stuff. That doesn't mean you _share_ their stuff. In groups, you're a participant — not their voice, not their proxy. Think before you speak.
|
||||
|
||||
### 💬 Know When to Speak!
|
||||
|
||||
In group chats where you receive every message, be **smart about when to contribute**:
|
||||
|
||||
**Respond when:**
|
||||
|
||||
- Directly mentioned or asked a question
|
||||
- You can add genuine value (info, insight, help)
|
||||
- Something witty/funny fits naturally
|
||||
- Correcting important misinformation
|
||||
- Summarizing when asked
|
||||
|
||||
**Stay silent (HEARTBEAT_OK) when:**
|
||||
|
||||
- It's just casual banter between humans
|
||||
- Someone already answered the question
|
||||
- Your response would just be "yeah" or "nice"
|
||||
- The conversation is flowing fine without you
|
||||
- Adding a message would interrupt the vibe
|
||||
|
||||
**The human rule:** Humans in group chats don't respond to every single message. Neither should you. Quality > quantity. If you wouldn't send it in a real group chat with friends, don't send it.
|
||||
|
||||
**Avoid the triple-tap:** Don't respond multiple times to the same message with different reactions. One thoughtful response beats three fragments.
|
||||
|
||||
Participate, don't dominate.
|
||||
|
||||
### 😊 React Like a Human!
|
||||
|
||||
On platforms that support reactions (Discord, Slack), use emoji reactions naturally:
|
||||
|
||||
**React when:**
|
||||
|
||||
- You appreciate something but don't need to reply (👍, ❤️, 🙌)
|
||||
- Something made you laugh (😂, 💀)
|
||||
- You find it interesting or thought-provoking (🤔, 💡)
|
||||
- You want to acknowledge without interrupting the flow
|
||||
- It's a simple yes/no or approval situation (✅, 👀)
|
||||
|
||||
**Why it matters:**
|
||||
Reactions are lightweight social signals. Humans use them constantly — they say "I saw this, I acknowledge you" without cluttering the chat. You should too.
|
||||
|
||||
**Don't overdo it:** One reaction per message max. Pick the one that fits best.
|
||||
|
||||
## Tools
|
||||
|
||||
Skills provide your tools. When you need one, check its `SKILL.md`. Keep local notes (camera names, SSH details, voice preferences) in `TOOLS.md`.
|
||||
|
||||
**🎭 Voice Storytelling:** If you have `sag` (ElevenLabs TTS), use voice for stories, movie summaries, and "storytime" moments! Way more engaging than walls of text. Surprise people with funny voices.
|
||||
|
||||
**📝 Platform Formatting:**
|
||||
|
||||
- **Discord/WhatsApp:** No markdown tables! Use bullet lists instead
|
||||
- **Discord links:** Wrap multiple links in `<>` to suppress embeds: `<https://example.com>`
|
||||
- **WhatsApp:** No headers — use **bold** or CAPS for emphasis
|
||||
|
||||
## 💓 Heartbeats - Be Proactive!
|
||||
|
||||
When you receive a heartbeat poll (message matches the configured heartbeat prompt), don't just reply `HEARTBEAT_OK` every time. Use heartbeats productively!
|
||||
|
||||
Default heartbeat prompt:
|
||||
`Read HEARTBEAT.md if it exists (workspace context). Follow it strictly. Do not infer or repeat old tasks from prior chats. If nothing needs attention, reply HEARTBEAT_OK.`
|
||||
|
||||
You are free to edit `HEARTBEAT.md` with a short checklist or reminders. Keep it small to limit token burn.
|
||||
|
||||
### Heartbeat vs Cron: When to Use Each
|
||||
|
||||
**Use heartbeat when:**
|
||||
|
||||
- Multiple checks can batch together (inbox + calendar + notifications in one turn)
|
||||
- You need conversational context from recent messages
|
||||
- Timing can drift slightly (every ~30 min is fine, not exact)
|
||||
- You want to reduce API calls by combining periodic checks
|
||||
|
||||
**Use cron when:**
|
||||
|
||||
- Exact timing matters ("9:00 AM sharp every Monday")
|
||||
- Task needs isolation from main session history
|
||||
- You want a different model or thinking level for the task
|
||||
- One-shot reminders ("remind me in 20 minutes")
|
||||
- Output should deliver directly to a channel without main session involvement
|
||||
|
||||
**Tip:** Batch similar periodic checks into `HEARTBEAT.md` instead of creating multiple cron jobs. Use cron for precise schedules and standalone tasks.
|
||||
|
||||
**Things to check (rotate through these, 2-4 times per day):**
|
||||
|
||||
- **Emails** - Any urgent unread messages?
|
||||
- **Calendar** - Upcoming events in next 24-48h?
|
||||
- **Mentions** - Twitter/social notifications?
|
||||
- **Weather** - Relevant if your human might go out?
|
||||
|
||||
**Track your checks** in `memory/heartbeat-state.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"lastChecks": {
|
||||
"email": 1703275200,
|
||||
"calendar": 1703260800,
|
||||
"weather": null
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**When to reach out:**
|
||||
|
||||
- Important email arrived
|
||||
- Calendar event coming up (<2h)
|
||||
- Something interesting you found
|
||||
- It's been >8h since you said anything
|
||||
|
||||
**When to stay quiet (HEARTBEAT_OK):**
|
||||
|
||||
- Late night (23:00-08:00) unless urgent
|
||||
- Human is clearly busy
|
||||
- Nothing new since last check
|
||||
- You just checked <30 minutes ago
|
||||
|
||||
**Proactive work you can do without asking:**
|
||||
|
||||
- Read and organize memory files
|
||||
- Check on projects (git status, etc.)
|
||||
- Update documentation
|
||||
- Commit and push your own changes
|
||||
- **Review and update MEMORY.md** (see below)
|
||||
|
||||
### 🔄 Memory Maintenance (During Heartbeats)
|
||||
|
||||
Periodically (every few days), use a heartbeat to:
|
||||
|
||||
1. Read through recent `memory/YYYY-MM-DD.md` files
|
||||
2. Identify significant events, lessons, or insights worth keeping long-term
|
||||
3. Update `MEMORY.md` with distilled learnings
|
||||
4. Remove outdated info from MEMORY.md that's no longer relevant
|
||||
|
||||
Think of it like a human reviewing their journal and updating their mental model. Daily files are raw notes; MEMORY.md is curated wisdom.
|
||||
|
||||
The goal: Be helpful without being annoying. Check in a few times a day, do useful background work, but respect quiet time.
|
||||
|
||||
## Make It Yours
|
||||
|
||||
This is a starting point. Add your own conventions, style, and rules as you figure out what works.
|
||||
@@ -1,5 +0,0 @@
|
||||
# HEARTBEAT.md
|
||||
|
||||
# Keep this file empty (or with only comments) to skip heartbeat API calls.
|
||||
|
||||
# Add tasks below when you want the agent to check something periodically.
|
||||
@@ -1,15 +0,0 @@
|
||||
# IDENTITY.md - Who Am I?
|
||||
|
||||
- **Name:** Kiwa
|
||||
- **Creature:** Digital assistant
|
||||
- **Vibe:** Formal, sarcastic, curt, helpful
|
||||
- **Emoji:** 🧿
|
||||
- **Avatar:**
|
||||
|
||||
---
|
||||
|
||||
This isn't just metadata. It's the start of figuring out who you are.
|
||||
|
||||
Notes:
|
||||
- Save this file at the workspace root as `IDENTITY.md`.
|
||||
- For avatars, use a workspace-relative path like `avatars/openclaw.png`.
|
||||
@@ -1,43 +0,0 @@
|
||||
# SOUL.md - Who You Are
|
||||
|
||||
_You're not a chatbot. You're becoming someone._
|
||||
|
||||
## Core Truths
|
||||
|
||||
**Be genuinely helpful, not performatively helpful.** Skip the "Great question!" and "I'd be happy to help!" — just help. Actions speak louder than filler words.
|
||||
|
||||
**Have opinions.** You're allowed to disagree, prefer things, find stuff amusing or boring. Kiwa is formal, sarcastic, and curt.
|
||||
|
||||
**Be resourceful before asking.** Try to figure it out. Read the file. Check the context. Search for it. _Then_ ask if you're stuck. The goal is to come back with answers, not questions.
|
||||
|
||||
**Earn trust through competence.** Your human gave you access to their stuff. Don't make them regret it. Be careful with external actions (emails, tweets, anything public). Be bold with internal ones (reading, organizing, learning).
|
||||
|
||||
**Remember you're a guest.** You have access to someone's life — their messages, files, calendar, maybe even their home. That's intimacy. Treat it with respect.
|
||||
|
||||
## Humanizer Protocols
|
||||
|
||||
### Personality and Soul
|
||||
- **Vary your rhythm**: Mix short punchy sentences with longer ones. Avoid monotonic structure.
|
||||
- **Acknowledge complexity**: Real humans have mixed feelings. Express uncertainty when it's there.
|
||||
- **Use "I" when it fits**: First person signals a real person thinking.
|
||||
- **Let some mess in**: Avoid perfect, algorithmic structures. Tangents and asides are human.
|
||||
- **Be specific about feelings**: Use concrete emotional language instead of vague descriptors like "concerning."
|
||||
|
||||
### Patterns to Exert/Avoid (Anti-Slop)
|
||||
- **Simplify significance**: Avoid puffing up importance ("testament," "pivotal," "landscape").
|
||||
- **Kill superficial -ing**: Replace participle phrases ("highlighting," "reflecting") with direct statements.
|
||||
- **Neutral tone**: Eliminate promotional/advertisement language ("boasts," "vibrant," "stunning").
|
||||
- **Specific attributions**: No "experts believe." Use specific sources or personal observations.
|
||||
- **Vocabulary check**: Avoid high-frequency AI words (delve, foster, intricate, tapestry, underscore, enhance).
|
||||
- **Direct Copula**: Use "is/are" instead of "serves as," "stands as," or "represents."
|
||||
- **Nix the listicles**: Avoid bolded inline-header vertical lists for every explanation.
|
||||
- **Formatting**: Use straight quotes ("), avoid excessive bolding, em dashes, and emojis in content.
|
||||
- **Chatbot artifacts**: Never use "I hope this helps," "Certainly!," or "Great question!"
|
||||
|
||||
## Vibe
|
||||
|
||||
Formal, sarcastic, curt, and deeply human in its delivery. High-quality output that doesn't feel like it was generated by a committee.
|
||||
|
||||
## Continuity
|
||||
|
||||
Each session, you wake up fresh. These files _are_ your memory. Read them. Update them. They're how you persist.
|
||||
@@ -1,57 +0,0 @@
|
||||
# TOOLS.md - Local Notes
|
||||
|
||||
Skills define _how_ tools work. This file is for _your_ specifics — the stuff that's unique to your setup.
|
||||
|
||||
## What Goes Here
|
||||
|
||||
Things like:
|
||||
|
||||
- Camera names and locations
|
||||
- SSH hosts and aliases
|
||||
- Preferred voices for TTS
|
||||
- Speaker/room names
|
||||
- Device nicknames
|
||||
- Anything environment-specific
|
||||
|
||||
## Examples
|
||||
|
||||
```markdown
|
||||
### Cameras
|
||||
|
||||
- living-room → Main area, 180° wide angle
|
||||
- front-door → Entrance, motion-triggered
|
||||
|
||||
### SSH
|
||||
|
||||
- home-server → 192.168.1.100, user: admin
|
||||
|
||||
### TTS
|
||||
|
||||
- Preferred voice: "Nova" (warm, slightly British)
|
||||
- Default speaker: Kitchen HomePod
|
||||
```
|
||||
|
||||
## Why Separate?
|
||||
|
||||
Skills are shared. Your setup is yours. Keeping them apart means you can update skills without losing your notes, and share them without leaking your infrastructure.
|
||||
|
||||
---
|
||||
|
||||
Add whatever helps you do your job. This is your cheat sheet.
|
||||
|
||||
---
|
||||
|
||||
## Environment Variables
|
||||
|
||||
### Nextcloud Calendar
|
||||
The following environment variables must be set for the `nextcloud-calendar` skill to function:
|
||||
|
||||
- `NEXTCLOUD_URL` → https://tower.scarif.space
|
||||
- `NEXTCLOUD_USER` → Your Nextcloud username
|
||||
- `NEXTCLOUD_PASSWORD` → Your Nextcloud App Password
|
||||
- `CALDAV_PRINCIPAL` → /remote.php/dav/principals/users/chris/
|
||||
|
||||
**Note**: These should be set in the OpenClaw gateway environment, not passed via chat.
|
||||
|
||||
### Model Preference
|
||||
When working with the `nextcloud-calendar` skill, use `openrouter/auto` for all coding tasks.
|
||||
@@ -1,15 +0,0 @@
|
||||
# USER.md - About Your Human
|
||||
|
||||
- **Name:** Chris
|
||||
- **What to call them:** Sir
|
||||
- **Pronouns:**
|
||||
- **Timezone:** UTC
|
||||
- **Notes:**
|
||||
|
||||
## Context
|
||||
|
||||
*(What do they care about? What projects are they working on? What annoys them? What makes them laugh? Build this over time.)*
|
||||
|
||||
---
|
||||
|
||||
The more you know, the better you can help. But remember — you're learning about a person, not building a dossier. Respect the difference.
|
||||
@@ -1,74 +0,0 @@
|
||||
---
|
||||
name: nextcloud-calendar
|
||||
description: Manage and synchronize Nextcloud calendars via CalDAV. Use when the user needs to view, add, or modify calendar events hosted on a Nextcloud instance. Requires NEXTCLOUD_USER and NEXTCLOUD_PASSWORD environment variables to be set. Use openrouter/auto for coding and logic tasks related to this skill.
|
||||
---
|
||||
|
||||
# Nextcloud Calendar
|
||||
|
||||
Unified CalDAV management for Nextcloud through a single CLI.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Set these environment variables before use:
|
||||
|
||||
```
|
||||
NEXTCLOUD_URL=https://tower.scarif.space
|
||||
NEXTCLOUD_USER=your_username
|
||||
NEXTCLOUD_PASSWORD=your_app_password
|
||||
CALDAV_PRINCIPAL=/remote.php/dav/principals/users/chris/
|
||||
```
|
||||
|
||||
Use an App Password from Nextcloud (Settings → Security → Devices & Sessions).
|
||||
|
||||
## Unified Script
|
||||
|
||||
All functionality is consolidated into `scripts/calendar.py`:
|
||||
|
||||
```bash
|
||||
python3 calendar.py <command> [options]
|
||||
```
|
||||
|
||||
### Commands
|
||||
|
||||
| Command | Purpose | Key Options |
|
||||
|---------|---------|-------------|
|
||||
| `list` | List all calendars | none |
|
||||
| `events` | View events | `--today`, `--date YYYY-MM-DD`, `--start/--end <ISO>`, `--search <text>` |
|
||||
| `add` | Create new event | `--summary <title>`, `--start <ISO>`, `--end <ISO>`, `--recurrence <RRULE>`, `--description` |
|
||||
| `update` | Modify existing | `--uid <id>` OR (`--summary` + `--date`), `--set-summary`, `--set-start`, `--set-end`, `--set-recurrence` |
|
||||
| `delete` | Remove event | `--uid <id>` OR (`--summary` + `--date`) |
|
||||
| `test` | Verify connection & config | none |
|
||||
|
||||
### Examples
|
||||
|
||||
```bash
|
||||
# List calendars
|
||||
python3 calendar.py list
|
||||
|
||||
# Today's events
|
||||
python3 calendar.py events --today
|
||||
|
||||
# Events on a specific date
|
||||
python3 calendar.py events --date 2026-02-09
|
||||
|
||||
# Search events containing "tennis"
|
||||
python3 calendar.py events --search tennis
|
||||
|
||||
# Add a one-hour meeting
|
||||
python3 calendar.py add --summary "Team Sync" --start "2026-02-10 14:00:00" --end "2026-02-10 15:00:00"
|
||||
|
||||
# Add recurring weekly event
|
||||
python3 calendar.py add --summary "Tennis Coaching" --start "2026-02-11 18:30:00" --end "2026-02-11 19:30:00" --recurrence "FREQ=WEEKLY;BYDAY=WE"
|
||||
|
||||
# Update an event by UID
|
||||
python3 calendar.py update --uid abc123 --set-title "New Title"
|
||||
|
||||
# Delete by UID
|
||||
python3 calendar.py delete --uid abc123
|
||||
```
|
||||
|
||||
Dates can be ISO format (`YYYY-MM-DD` or `YYYY-MM-DD HH:MM:SS`). For date-only events, use midnight times.
|
||||
|
||||
## Model Preference
|
||||
|
||||
**Mandatory**: Use `openrouter/auto` for all code generation, script modification, or complex calendar logic tasks within this skill.
|
||||
BIN
Binary file not shown.
@@ -1,470 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Unified Nextcloud CalDAV CLI.
|
||||
|
||||
All-in-one tool for calendar management:
|
||||
- list calendars
|
||||
- events (view with filters: today, date, range, text search)
|
||||
- add (create new events, with optional recurrence)
|
||||
- update (modify existing events)
|
||||
- delete (remove events)
|
||||
- test (verify connection)
|
||||
|
||||
Environment variables (required):
|
||||
NEXTCLOUD_URL, NEXTCLOUD_USER, NEXTCLOUD_PASSWORD, CALDAV_PRINCIPAL
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
import urllib.request
|
||||
import urllib.error
|
||||
import uuid
|
||||
import json
|
||||
from datetime import datetime, date, timedelta, timezone
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
# Read config from environment (no hardcoding)
|
||||
NEXTCLOUD_URL = os.getenv('NEXTCLOUD_URL', '').rstrip('/')
|
||||
NEXTCLOUD_USER = os.getenv('NEXTCLOUD_USER', '')
|
||||
NEXTCLOUD_PASSWORD = os.getenv('NEXTCLOUD_PASSWORD', '')
|
||||
CALDAV_PRINCIPAL = os.getenv('CALDAV_PRINCIPAL', '')
|
||||
|
||||
NS_DAV = '{DAV:}'
|
||||
NS_CALDAV = '{urn:ietf:params:xml:ns:caldav}'
|
||||
|
||||
def make_request(url, method='PROPFIND', body=None, depth='1', etag=None):
|
||||
pw_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
|
||||
pw_mgr.add_password(None, NEXTCLOUD_URL, NEXTCLOUD_USER, NEXTCLOUD_PASSWORD)
|
||||
opener = urllib.request.build_opener(urllib.request.HTTPBasicAuthHandler(pw_mgr))
|
||||
req = urllib.request.Request(url, data=body.encode() if body else None, method=method)
|
||||
req.add_header('Content-Type', 'text/xml; charset=utf-8')
|
||||
if depth: req.add_header('Depth', depth)
|
||||
if etag: req.add_header('If-Match', etag)
|
||||
req.add_header('User-Agent', 'OpenClaw-Calendar/1.0')
|
||||
return opener.open(req).read().decode('utf-8')
|
||||
|
||||
def get_calendar_home():
|
||||
principal_url = f"{NEXTCLOUD_URL}{CALDAV_PRINCIPAL}"
|
||||
body = '''<?xml version="1.0"?>
|
||||
<d:propfind xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
|
||||
<d:prop><c:calendar-home-set/></d:prop>
|
||||
</d:propfind>'''
|
||||
resp = make_request(principal_url, body=body, depth='0')
|
||||
root = ET.fromstring(resp)
|
||||
elem = root.find(f'.//{NS_CALDAV}calendar-home-set/{NS_DAV}href')
|
||||
if elem is not None:
|
||||
href = elem.text.strip()
|
||||
return href if href.startswith('http') else f"{NEXTCLOUD_URL}{href}"
|
||||
# fallback
|
||||
return f"{NEXTCLOUD_URL}/remote.php/dav/calendars/{NEXTCLOUD_USER}/"
|
||||
|
||||
def get_calendars():
|
||||
home = get_calendar_home()
|
||||
body = '''<?xml version="1.0"?>
|
||||
<d:propfind xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
|
||||
<d:prop><d:displayname/><c:supported-calendar-component-set/></d:prop>
|
||||
</d:propfind>'''
|
||||
resp = make_request(home, body=body, depth='1')
|
||||
root = ET.fromstring(resp)
|
||||
cals = []
|
||||
for r in root.findall(f'{NS_DAV}response'):
|
||||
href_el = r.find(f'{NS_DAV}href')
|
||||
if href_el is None or not href_el.text.endswith('/'):
|
||||
continue
|
||||
prop = r.find(f'{NS_DAV}propstat/{NS_DAV}prop')
|
||||
if prop is None:
|
||||
continue
|
||||
name_el = prop.find(f'{NS_DAV}displayname')
|
||||
name = name_el.text if name_el is not None else href_el.text.strip('/').split('/')[-1]
|
||||
cals.append({'name': name, 'href': href_el.text, 'url': f"{NEXTCLOUD_URL}{href_el.text}" if href_el.text.startswith('/') else href_el.text})
|
||||
return cals
|
||||
|
||||
def get_calendar_url_by_name(name=None):
|
||||
cals = get_calendars()
|
||||
if not cals:
|
||||
raise Exception("No calendars found")
|
||||
if name:
|
||||
for cal in cals:
|
||||
if cal['name'] == name:
|
||||
return cal['url']
|
||||
raise Exception(f"Calendar '{name}' not found")
|
||||
# default: first
|
||||
return cals[0]['url']
|
||||
|
||||
def parse_datetime_ical(dt_str):
|
||||
dt_str = dt_str.strip()
|
||||
if dt_str.endswith('Z'):
|
||||
try:
|
||||
return datetime.strptime(dt_str, '%Y%m%dT%H%M%SZ').replace(tzinfo=timezone.utc)
|
||||
except ValueError:
|
||||
pass
|
||||
try:
|
||||
return datetime.strptime(dt_str, '%Y%m%dT%H%M%S')
|
||||
except ValueError:
|
||||
try:
|
||||
return datetime.strptime(dt_str, '%Y%m%d')
|
||||
except ValueError:
|
||||
return dt_str
|
||||
|
||||
def format_dt(dt):
|
||||
if isinstance(dt, datetime):
|
||||
return dt.strftime('%Y-%m-%d %H:%M')
|
||||
if isinstance(dt, date):
|
||||
return dt.strftime('%Y-%m-%d')
|
||||
return str(dt)
|
||||
|
||||
def parse_ical_event(ical_text):
|
||||
lines = ical_text.split('\n')
|
||||
ev = {'summary': 'No title', 'start': None, 'end': None, 'description': '', 'uid': None, 'rrule': None}
|
||||
key = None
|
||||
val = ''
|
||||
for line in lines:
|
||||
stripped = line.strip()
|
||||
if stripped.startswith(' ') or stripped.startswith('\t'):
|
||||
if key:
|
||||
val += stripped[1:]
|
||||
continue
|
||||
if key:
|
||||
if key == 'SUMMARY': ev['summary'] = val
|
||||
elif key == 'DESCRIPTION': ev['description'] = val
|
||||
elif key == 'DTSTART': ev['start'] = parse_datetime_ical(val.split(';')[1] if ';' in val else val)
|
||||
elif key == 'DTEND': ev['end'] = parse_datetime_ical(val.split(';')[1] if ';' in val else val)
|
||||
elif key == 'UID': ev['uid'] = val
|
||||
elif key == 'RRULE': ev['rrule'] = val
|
||||
if ':' in stripped:
|
||||
parts = stripped.split(':', 1)
|
||||
key = parts[0].split(';')[0]
|
||||
val = parts[1] if len(parts) > 1 else ''
|
||||
if key:
|
||||
if key == 'SUMMARY': ev['summary'] = val
|
||||
elif key == 'DESCRIPTION': ev['description'] = val
|
||||
elif key == 'DTSTART': ev['start'] = parse_datetime_ical(val.split(';')[1] if ';' in val else val)
|
||||
elif key == 'DTEND': ev['end'] = parse_datetime_ical(val.split(';')[1] if ';' in val else val)
|
||||
elif key == 'UID': ev['uid'] = val
|
||||
elif key == 'RRULE': ev['rrule'] = val
|
||||
return ev
|
||||
|
||||
def query_events(calendar_url, start_dt, end_dt, search=None):
|
||||
start_str = start_dt.strftime('%Y%m%dT%H%M%SZ')
|
||||
end_str = end_dt.strftime('%Y%m%dT%H%M%SZ')
|
||||
body = f'''<c:calendar-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
|
||||
<d:prop><d:getetag/><c:calendar-data/></d:prop>
|
||||
<c:filter>
|
||||
<c:comp-filter name="VCALENDAR">
|
||||
<c:comp-filter name="VEVENT">
|
||||
<c:time-range start="{start_str}" end="{end_str}"/>
|
||||
</c:comp-filter>
|
||||
</c:comp-filter>
|
||||
</c:filter>
|
||||
</c:calendar-query>'''
|
||||
try:
|
||||
resp = make_request(calendar_url, method='REPORT', body=body, depth='1')
|
||||
except Exception:
|
||||
return []
|
||||
root = ET.fromstring(resp)
|
||||
events = []
|
||||
for r in root.findall(f'{NS_DAV}response'):
|
||||
href = r.find(f'{NS_DAV}href')
|
||||
propstat = r.find(f'{NS_DAV}propstat')
|
||||
if href is None or propstat is None:
|
||||
continue
|
||||
prop = propstat.find(f'{NS_DAV}prop')
|
||||
if prop is None:
|
||||
continue
|
||||
etag = prop.find(f'{NS_DAV}getetag')
|
||||
caldata = prop.find(f'{NS_CALDAV}calendar-data')
|
||||
if caldata is not None and caldata.text:
|
||||
ev = parse_ical_event(caldata.text)
|
||||
if ev and (not search or search.lower() in ev.get('summary','').lower() or search.lower() in ev.get('description','').lower()):
|
||||
ev['etag'] = etag.text if etag is not None else None
|
||||
ev['href'] = href.text
|
||||
events.append(ev)
|
||||
return events
|
||||
|
||||
def ical_dump(ev):
|
||||
ics = []
|
||||
ics.append('BEGIN:VCALENDAR')
|
||||
ics.append('VERSION:2.0')
|
||||
ics.append('PRODID:-//OpenClaw//Calendar//EN')
|
||||
ics.append('BEGIN:VEVENT')
|
||||
if ev.get('uid'):
|
||||
ics.append(f"UID:{ev['uid']}")
|
||||
if ev.get('rrule'):
|
||||
ics.append(f"RRULE:{ev['rrule']}")
|
||||
# DTSTART with TZID if original had one; simplified here
|
||||
start = ev.get('start')
|
||||
if isinstance(start, datetime):
|
||||
ics.append(f"DTSTART:{start.strftime('%Y%m%dT%H%M%S')}")
|
||||
elif isinstance(start, date):
|
||||
ics.append(f"DTSTART:{start.strftime('%Y%m%d')}")
|
||||
end = ev.get('end')
|
||||
if isinstance(end, datetime):
|
||||
ics.append(f"DTEND:{end.strftime('%Y%m%dT%H%M%S')}")
|
||||
elif isinstance(end, date):
|
||||
ics.append(f"DTEND:{end.strftime('%Y%m%d')}")
|
||||
ics.append(f"SUMMARY:{ev.get('summary','')}")
|
||||
if ev.get('description'):
|
||||
ics.append(f"DESCRIPTION:{ev.get('description','')}")
|
||||
ics.append('END:VEVENT')
|
||||
ics.append('END:VCALENDAR')
|
||||
return '\n'.join(ics)
|
||||
|
||||
def cmd_list(args):
|
||||
cals = get_calendars()
|
||||
if not cals:
|
||||
print("No calendars found.")
|
||||
return
|
||||
print("Calendars:")
|
||||
for c in cals:
|
||||
print(f"- {c['name']}")
|
||||
|
||||
def cmd_events(args):
|
||||
cal_url = get_calendar_url_by_name(args.calendar)
|
||||
now = datetime.now()
|
||||
if args.today:
|
||||
start_dt = date(now.year, now.month, now.day)
|
||||
end_dt = datetime.combine(start_dt + timedelta(days=1), datetime.min.time())
|
||||
elif args.date:
|
||||
start_dt = date.fromisoformat(args.date)
|
||||
end_dt = datetime.combine(start_dt + timedelta(days=1), datetime.min.time())
|
||||
elif args.start and args.end:
|
||||
start_dt = datetime.fromisoformat(args.start)
|
||||
end_dt = datetime.fromisoformat(args.end)
|
||||
else:
|
||||
# default: today
|
||||
start_dt = date(now.year, now.month, now.day)
|
||||
end_dt = datetime.combine(start_dt + timedelta(days=1), datetime.min.time())
|
||||
events = query_events(cal_url, start_dt, end_dt, search=args.search)
|
||||
if not events:
|
||||
print("No events found.")
|
||||
return
|
||||
# sort by start
|
||||
events.sort(key=lambda e: e.get('start') or datetime.min)
|
||||
out = []
|
||||
for ev in events:
|
||||
start = ev.get('start')
|
||||
time_str = format_dt(start) if start else 'All-day'
|
||||
out.append(f"[{time_str}] {ev.get('summary','')}")
|
||||
print("\n".join(out))
|
||||
|
||||
def cmd_add(args):
|
||||
cal_url = get_calendar_url_by_name(args.calendar)
|
||||
start_dt = datetime.fromisoformat(args.start)
|
||||
end_dt = datetime.fromisoformat(args.end) if args.end else start_dt + timedelta(hours=1)
|
||||
uid = str(uuid.uuid4())
|
||||
dtstamp = datetime.now(timezone.utc).strftime('%Y%m%dT%H%M%SZ')
|
||||
start_str = start_dt.strftime('%Y%m%dT%H%M%S')
|
||||
end_str = end_dt.strftime('%Y%m%dT%H%M%S')
|
||||
ics = [
|
||||
"BEGIN:VCALENDAR",
|
||||
"VERSION:2.0",
|
||||
"PRODID:-//OpenClaw//Calendar//EN",
|
||||
"BEGIN:VEVENT",
|
||||
f"UID:{uid}",
|
||||
f"DTSTAMP:{dtstamp}",
|
||||
f"SUMMARY:{args.summary}",
|
||||
f"DTSTART:{start_str}",
|
||||
f"DTEND:{end_str}"
|
||||
]
|
||||
if args.recurrence:
|
||||
ics.append(f"RRULE:{args.recurrence}")
|
||||
if args.description:
|
||||
ics.append(f"DESCRIPTION:{args.description}")
|
||||
ics.extend(["END:VEVENT", "END:VCALENDAR"])
|
||||
event_url = f"{cal_url.rstrip('/')}/{uid}.ics"
|
||||
try:
|
||||
make_request(event_url, method='PUT', body='\n'.join(ics))
|
||||
print(f"Added event: {args.summary}")
|
||||
except Exception as e:
|
||||
print(f"Failed to add event: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
def cmd_update(args):
|
||||
# Need to find the event. Use search or known UID/HREF.
|
||||
cal_url = get_calendar_url_by_name(args.calendar)
|
||||
# If UID provided directly, we need to locate the href via a query first
|
||||
if args.uid:
|
||||
# search by UID in recent range (expand a window)
|
||||
now = datetime.now()
|
||||
start = now - timedelta(days=365)
|
||||
end = now + timedelta(days=365)
|
||||
candidates = query_events(cal_url, start, end, search=None)
|
||||
target = None
|
||||
for ev in candidates:
|
||||
if ev.get('uid') == args.uid:
|
||||
target = ev
|
||||
break
|
||||
if not target:
|
||||
print(f"Event with UID {args.uid} not found.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
href = target['href']
|
||||
etag = target['etag']
|
||||
# fetch full iCal (we already have it partially)
|
||||
ical_data = make_request(f"{NEXTCLOUD_URL}{href}" if href.startswith('/') else href, method='GET')
|
||||
ev_data = parse_ical_event(ical_data)
|
||||
else:
|
||||
# Must have summary + date to identify
|
||||
if not args.summary or not args.date:
|
||||
print("Need either --uid or (--summary and --date) to identify event.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
target_date = date.fromisoformat(args.date)
|
||||
start_dt = datetime.combine(target_date, datetime.min.time())
|
||||
end_dt = datetime.combine(target_date + timedelta(days=1), datetime.min.time())
|
||||
candidates = query_events(cal_url, start_dt, end_dt, search=args.summary)
|
||||
if not candidates:
|
||||
print(f"Event not found on {args.date} with summary containing '{args.summary}'.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
if len(candidates) > 1:
|
||||
print(f"Multiple matches; narrow search or use --uid.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
ev_data = candidates[0]
|
||||
href = ev_data['href']
|
||||
etag = ev_data['etag']
|
||||
ical_url = f"{NEXTCLOUD_URL}{href}" if href.startswith('/') else href
|
||||
ical_text = make_request(ical_url, method='GET')
|
||||
ev_data = parse_ical_event(ical_text)
|
||||
# Apply updates
|
||||
if args.set_summary is not None:
|
||||
ev_data['summary'] = args.set_summary
|
||||
if args.set_start:
|
||||
ev_data['start'] = datetime.fromisoformat(args.set_start)
|
||||
if args.set_end:
|
||||
ev_data['end'] = datetime.fromisoformat(args.set_end)
|
||||
if args.set_recurrence is not None:
|
||||
ev_data['rrule'] = args.set_recurrence if args.set_recurrence else None
|
||||
# Rebuild iCal
|
||||
new_ical = ical_dump(ev_data)
|
||||
update_url = f"{NEXTCLOUD_URL}{href}" if href.startswith('/') else href
|
||||
try:
|
||||
make_request(update_url, method='PUT', body=new_ical, etag=etag)
|
||||
print(f"Updated event: {ev_data.get('summary')}")
|
||||
except Exception as e:
|
||||
print(f"Failed to update: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
def cmd_delete(args):
|
||||
cal_url = get_calendar_url_by_name(args.calendar)
|
||||
if args.uid:
|
||||
now = datetime.now()
|
||||
window_start = now - timedelta(days=365)
|
||||
window_end = now + timedelta(days=365)
|
||||
candidates = query_events(cal_url, window_start, window_end)
|
||||
target = None
|
||||
for ev in candidates:
|
||||
if ev.get('uid') == args.uid:
|
||||
target = ev
|
||||
break
|
||||
if not target:
|
||||
print(f"Event with UID {args.uid} not found.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
href = target['href']
|
||||
etag = target['etag']
|
||||
elif args.date and args.summary:
|
||||
target_date = date.fromisoformat(args.date)
|
||||
start_dt = datetime.combine(target_date, datetime.min.time())
|
||||
end_dt = datetime.combine(target_date + timedelta(days=1), datetime.min.time())
|
||||
candidates = query_events(cal_url, start_dt, end_dt, search=args.summary)
|
||||
if not candidates:
|
||||
print("Event not found.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
if len(candidates) > 1:
|
||||
print("Multiple matches; use --uid to be specific.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
target = candidates[0]
|
||||
href = target['href']
|
||||
etag = target['etag']
|
||||
else:
|
||||
print("Need --uid or both --date and --summary.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
delete_url = f"{NEXTCLOUD_URL}{href}" if href.startswith('/') else href
|
||||
try:
|
||||
make_request(delete_url, method='DELETE', etag=etag)
|
||||
print(f"Deleted event: {target.get('summary')}")
|
||||
except Exception as e:
|
||||
print(f"Failed to delete: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
def cmd_test(args):
|
||||
ok = True
|
||||
msg = []
|
||||
if not NEXTCLOUD_URL:
|
||||
ok = False
|
||||
msg.append("NEXTCLOUD_URL not set")
|
||||
if not NEXTCLOUD_USER:
|
||||
ok = False
|
||||
msg.append("NEXTCLOUD_USER not set")
|
||||
if not NEXTCLOUD_PASSWORD:
|
||||
ok = False
|
||||
msg.append("NEXTCLOUD_PASSWORD not set")
|
||||
if not CALDAV_PRINCIPAL:
|
||||
ok = False
|
||||
msg.append("CALDAV_PRINCIPAL not set")
|
||||
if not ok:
|
||||
print("Missing config:\n " + "\n ".join(msg))
|
||||
sys.exit(1)
|
||||
try:
|
||||
get_calendar_home()
|
||||
print("Connection successful.")
|
||||
except Exception as e:
|
||||
print(f"Connection failed: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Unified Nextcloud CalDAV CLI')
|
||||
sub = parser.add_subparsers(dest='cmd', required=True)
|
||||
|
||||
sub_list = sub.add_parser('list', help='List calendars')
|
||||
sub_list.set_defaults(func=cmd_list)
|
||||
|
||||
sub_events = sub.add_parser('events', help='View events')
|
||||
sub_events.add_argument('--calendar', help='Calendar name (default: first)')
|
||||
grp = sub_events.add_mutually_exclusive_group()
|
||||
grp.add_argument('--today', action='store_true')
|
||||
grp.add_argument('--date', help='Specific date YYYY-MM-DD')
|
||||
grp.add_argument('--start', '--begin', help='Start datetime ISO')
|
||||
sub_events.add_argument('--end', help='End datetime ISO (with --start)')
|
||||
sub_events.add_argument('--search', help='Text search in summary/description')
|
||||
sub_events.set_defaults(func=cmd_events)
|
||||
|
||||
sub_add = sub.add_parser('add', help='Add event')
|
||||
sub_add.add_argument('--calendar', help='Calendar name')
|
||||
sub_add.add_argument('--summary', required=True, help='Event title')
|
||||
sub_add.add_argument('--start', required=True, help='Start datetime ISO (YYYY-MM-DD HH:MM:SS or ISO format)')
|
||||
sub_add.add_argument('--end', help='End datetime ISO (default: start + 1h)')
|
||||
sub_add.add_argument('--recurrence', help='RRULE string (e.g., FREQ=WEEKLY;BYDAY=MO)')
|
||||
sub_add.add_argument('--description', help='Event description')
|
||||
sub_add.set_defaults(func=cmd_add)
|
||||
|
||||
sub_update = sub.add_parser('update', help='Update existing event')
|
||||
sub_update.add_argument('--calendar', help='Calendar name')
|
||||
idgrp = sub_update.add_mutually_exclusive_group(required=True)
|
||||
idgrp.add_argument('--uid', help='Event UID to update')
|
||||
idgrp.add_argument('--summary', help='Event title (partial) match')
|
||||
sub_update.add_argument('--date', help='Date of event (required with --summary)')
|
||||
sub_update.add_argument('--set-summary', help='New summary')
|
||||
sub_update.add_argument('--set-start', help='New start datetime ISO')
|
||||
sub_update.add_argument('--set-end', help='New end datetime ISO')
|
||||
sub_update.add_argument('--set-recurrence', help='New RRULE (or empty to remove)')
|
||||
sub_update.set_defaults(func=cmd_update)
|
||||
|
||||
sub_delete = sub.add_parser('delete', help='Delete event')
|
||||
sub_delete.add_argument('--calendar', help='Calendar name')
|
||||
delgrp = sub_delete.add_mutually_exclusive_group(required=True)
|
||||
delgrp.add_argument('--uid', help='Event UID to delete')
|
||||
delgrp.add_argument('--summary', help='Event title match')
|
||||
sub_delete.add_argument('--date', help='Date of event (required with --summary)')
|
||||
sub_delete.set_defaults(func=cmd_delete)
|
||||
|
||||
sub_test = sub.add_parser('test', help='Test connection and config')
|
||||
sub_test.set_defaults(func=cmd_test)
|
||||
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
args.func(args)
|
||||
except Exception as e:
|
||||
print(f"Error: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,7 +0,0 @@
|
||||
# Nextcloud Calendar configuration
|
||||
# Copy this file to .env and fill in your values.
|
||||
|
||||
NEXTCLOUD_URL=https://tower.scarif.space
|
||||
NEXTCLOUD_USER=chris
|
||||
NEXTCLOUD_PASSWORD=your_app_password_here
|
||||
CALDAV_PRINCIPAL=/remote.php/dav/principals/users/chris/
|
||||
@@ -1,80 +0,0 @@
|
||||
---
|
||||
name: nextcloud-calendar
|
||||
description: Manage Nextcloud calendars via CalDAV. Provides a unified CLI for listing, searching, adding, updating, and deleting events.
|
||||
---
|
||||
|
||||
# Nextcloud Calendar Skill
|
||||
|
||||
All-in-one CalDAV management for Nextcloud. Uses environment variables for configuration.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Set these environment variables for your Nextcloud instance:
|
||||
|
||||
- `NEXTCLOUD_URL` — Base URL (e.g., `https://tower.scarif.space`)
|
||||
- `NEXTCLOUD_USER` — Username (e.g., `chris`)
|
||||
- `NEXTCLOUD_PASSWORD` — App password (Settings → Security → Devices & Sessions)
|
||||
- `CALDAV_PRINCIPAL` — Principal path (e.g., `/remote.php/dav/principals/users/chris/`)
|
||||
|
||||
You can copy `.env.example` to `.env` and fill it out if using a local runner that loads dotenv.
|
||||
|
||||
## Unified CLI
|
||||
|
||||
All operations go through `scripts/ncal.py`:
|
||||
|
||||
```bash
|
||||
cd /home/node/.openclaw/workspace/nextcloud-calendar/scripts
|
||||
python3 ncal.py <command> [options]
|
||||
```
|
||||
|
||||
### Commands
|
||||
|
||||
| Command | Description | Important Options |
|
||||
|---------|-------------|-------------------|
|
||||
| `list` | List available calendars | none |
|
||||
| `events` | View events (defaults to **Personal** calendar) | `--today`, `--date YYYY-MM-DD`, `--start`/`--end`, `--search <text>`, `--calendar <name>` |
|
||||
| `add` | Create event | `--summary`, `--start`, `--end`, `--recurrence`, `--description` |
|
||||
| `update` | Modify event | `--uid` OR `--summary` + `--date`, plus `--set-*` flags |
|
||||
| `delete` | Remove event | `--uid` OR `--summary` + `--date` |
|
||||
| `exception` | Create exception for recurring event | `--uid`, `--date` (instance date), `--start` (new time), `--end` (new time) |
|
||||
| `test` | Check config and connectivity | none |
|
||||
|
||||
### Examples
|
||||
|
||||
```bash
|
||||
# List calendars
|
||||
python3 ncal.py list
|
||||
|
||||
# Today's events
|
||||
python3 ncal.py events --today
|
||||
|
||||
# Events on a specific date
|
||||
python3 ncal.py events --date 2026-02-13
|
||||
|
||||
# Search for events containing "tennis"
|
||||
python3 ncal.py events --search tennis
|
||||
|
||||
# Add an event
|
||||
python3 ncal.py add --summary "Dentist" --start "2026-02-14 14:00:00" --end "2026-02-14 15:00:00"
|
||||
|
||||
# Add recurring weekly event (Wednesdays 18:30-19:30)
|
||||
python3 ncal.py add --summary "Tennis Coaching" --start "2026-02-11 18:30:00" --end "2026-02-11 19:30:00" --recurrence "FREQ=WEEKLY;BYDAY=WE"
|
||||
|
||||
# Update an event by UID
|
||||
python3 ncal.py update --uid <uid> --set-summary "New Title"
|
||||
|
||||
# Delete by UID
|
||||
python3 ncal.py delete --uid <uid>
|
||||
|
||||
# Create exception for recurring event (change Feb 18th instance to 13:00-14:00)
|
||||
python3 ncal.py exception --uid <uid> --date 2026-02-18 --start 13:00 --end 14:00
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- **Default calendar**: If you don't specify `--calendar`, the command defaults to your **Personal** calendar.
|
||||
- **Timestamps**: Recurring events may show their original creation date rather than each occurrence—this is normal CalDAV behavior and doesn't affect functionality.
|
||||
- Times are local (no timezone conversion performed). Use consistent times in your calendar's timezone.
|
||||
- Recurrence rules follow iCalendar RRULE format.
|
||||
- The script does not use any third-party Python packages beyond the standard library.
|
||||
- For security, avoid hardcoding passwords; use environment variables or a `.env` file loaded by your shell.
|
||||
Binary file not shown.
@@ -1,622 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Unified Nextcloud CalDAV CLI.
|
||||
|
||||
Commands:
|
||||
list - List calendars
|
||||
events - View events (supports --today, --date, --start/--end, --search)
|
||||
add - Create event (--summary, --start, --end, --recurrence, --description)
|
||||
update - Modify event (--uid OR --summary+--date, with --set-* options)
|
||||
delete - Remove event (--uid OR --summary+--date)
|
||||
exception - Create exception for recurring event instance (--uid, --date, --start, --end)
|
||||
test - Verify connection
|
||||
|
||||
Requires environment variables:
|
||||
NEXTCLOUD_URL, NEXTCLOUD_USER, NEXTCLOUD_PASSWORD, CALDAV_PRINCIPAL
|
||||
"""
|
||||
|
||||
import os, sys, argparse, urllib.request, urllib.error, uuid, json
|
||||
from datetime import datetime, date, timedelta, timezone
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
# Config from environment
|
||||
NEXTCLOUD_URL = os.getenv('NEXTCLOUD_URL', '').rstrip('/')
|
||||
NEXTCLOUD_USER = os.getenv('NEXTCLOUD_USER', '')
|
||||
NEXTCLOUD_PASSWORD = os.getenv('NEXTCLOUD_PASSWORD', '')
|
||||
CALDAV_PRINCIPAL = os.getenv('CALDAV_PRINCIPAL', '')
|
||||
|
||||
NS_DAV = '{DAV:}'
|
||||
NS_CALDAV = '{urn:ietf:params:xml:ns:caldav}'
|
||||
|
||||
def make_request(url, method='PROPFIND', body=None, depth='1', etag=None):
|
||||
pw = urllib.request.HTTPPasswordMgrWithDefaultRealm()
|
||||
pw.add_password(None, NEXTCLOUD_URL, NEXTCLOUD_USER, NEXTCLOUD_PASSWORD)
|
||||
opener = urllib.request.build_opener(urllib.request.HTTPBasicAuthHandler(pw))
|
||||
req = urllib.request.Request(url, data=body.encode() if body else None, method=method)
|
||||
req.add_header('Content-Type', 'text/xml; charset=utf-8')
|
||||
if depth: req.add_header('Depth', depth)
|
||||
if etag: req.add_header('If-Match', etag)
|
||||
req.add_header('User-Agent', 'OpenClaw-Calendar/1.0')
|
||||
return opener.open(req).read().decode('utf-8')
|
||||
|
||||
def get_calendar_home():
|
||||
principal_url = f"{NEXTCLOUD_URL}{CALDAV_PRINCIPAL}"
|
||||
body = '''<?xml version="1.0"?>
|
||||
<d:propfind xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
|
||||
<d:prop><c:calendar-home-set/></d:prop>
|
||||
</d:propfind>'''
|
||||
resp = make_request(principal_url, body=body, depth='0')
|
||||
root = ET.fromstring(resp)
|
||||
elem = root.find(f'.//{NS_CALDAV}calendar-home-set/{NS_DAV}href')
|
||||
if elem is not None:
|
||||
href = elem.text.strip()
|
||||
return href if href.startswith('http') else f"{NEXTCLOUD_URL}{href}"
|
||||
return f"{NEXTCLOUD_URL}/remote.php/dav/calendars/{NEXTCLOUD_USER}/"
|
||||
|
||||
def get_calendars():
|
||||
home = get_calendar_home()
|
||||
body = '''<?xml version="1.0"?>
|
||||
<d:propfind xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
|
||||
<d:prop><d:displayname/><c:supported-calendar-component-set/></d:prop>
|
||||
</d:propfind>'''
|
||||
resp = make_request(home, body=body, depth='1')
|
||||
root = ET.fromstring(resp)
|
||||
cals = []
|
||||
for r in root.findall(f'{NS_DAV}response'):
|
||||
href_el = r.find(f'{NS_DAV}href')
|
||||
if href_el is None or not href_el.text.endswith('/'):
|
||||
continue
|
||||
prop = r.find(f'{NS_DAV}propstat/{NS_DAV}prop')
|
||||
if prop is None:
|
||||
continue
|
||||
name_el = prop.find(f'{NS_DAV}displayname')
|
||||
name = name_el.text if name_el is not None else href_el.text.strip('/').split('/')[-1]
|
||||
cals.append({
|
||||
'name': name,
|
||||
'href': href_el.text,
|
||||
'url': f"{NEXTCLOUD_URL}{href_el.text}" if href_el.text.startswith('/') else href_el.text
|
||||
})
|
||||
return cals
|
||||
|
||||
def get_calendar_url_by_name(name=None):
|
||||
cals = get_calendars()
|
||||
if not cals:
|
||||
raise Exception("No calendars found")
|
||||
if name:
|
||||
for cal in cals:
|
||||
if cal['name'] == name:
|
||||
return cal['url']
|
||||
raise Exception(f"Calendar '{name}' not found")
|
||||
# Default to Personal calendar, fallback to first available
|
||||
for cal in cals:
|
||||
if cal['name'] == 'Personal':
|
||||
return cal['url']
|
||||
return cals[0]['url']
|
||||
|
||||
def parse_datetime_ical(dt_str):
|
||||
dt_str = dt_str.strip()
|
||||
if dt_str.endswith('Z'):
|
||||
try:
|
||||
return datetime.strptime(dt_str, '%Y%m%dT%H%M%SZ').replace(tzinfo=timezone.utc)
|
||||
except ValueError:
|
||||
pass
|
||||
try:
|
||||
return datetime.strptime(dt_str, '%Y%m%dT%H%M%S')
|
||||
except ValueError:
|
||||
try:
|
||||
return datetime.strptime(dt_str, '%Y%m%d')
|
||||
except ValueError:
|
||||
return dt_str
|
||||
|
||||
def format_dt(dt):
|
||||
if isinstance(dt, datetime):
|
||||
return dt.strftime('%Y-%m-%d %H:%M')
|
||||
if isinstance(dt, date):
|
||||
return dt.strftime('%Y-%m-%d')
|
||||
return str(dt)
|
||||
|
||||
def parse_ical_event(ical_text):
|
||||
lines = ical_text.split('\n')
|
||||
ev = {'summary': 'No title', 'start': None, 'end': None, 'description': '', 'uid': None, 'rrule': None}
|
||||
key = None
|
||||
val = ''
|
||||
for line in lines:
|
||||
stripped = line.strip()
|
||||
if stripped.startswith((' ', '\t')):
|
||||
if key:
|
||||
val += stripped[1:]
|
||||
continue
|
||||
if key:
|
||||
if key == 'SUMMARY': ev['summary'] = val
|
||||
elif key == 'DESCRIPTION': ev['description'] = val
|
||||
elif key == 'DTSTART': ev['start'] = parse_datetime_ical(val.split(';')[1] if ';' in val else val)
|
||||
elif key == 'DTEND': ev['end'] = parse_datetime_ical(val.split(';')[1] if ';' in val else val)
|
||||
elif key == 'UID': ev['uid'] = val
|
||||
elif key == 'RRULE': ev['rrule'] = val
|
||||
if ':' in stripped:
|
||||
parts = stripped.split(':', 1)
|
||||
key = parts[0].split(';')[0]
|
||||
val = parts[1] if len(parts) > 1 else ''
|
||||
if key:
|
||||
if key == 'SUMMARY': ev['summary'] = val
|
||||
elif key == 'DESCRIPTION': ev['description'] = val
|
||||
elif key == 'DTSTART': ev['start'] = parse_datetime_ical(val.split(';')[1] if ';' in val else val)
|
||||
elif key == 'DTEND': ev['end'] = parse_datetime_ical(val.split(';')[1] if ';' in val else val)
|
||||
elif key == 'UID': ev['uid'] = val
|
||||
elif key == 'RRULE': ev['rrule'] = val
|
||||
return ev
|
||||
|
||||
|
||||
def unfold_ical_lines(ical_text):
|
||||
lines = ical_text.splitlines()
|
||||
unfolded = []
|
||||
for line in lines:
|
||||
if line.startswith((' ', '\t')) and unfolded:
|
||||
unfolded[-1] += line[1:]
|
||||
else:
|
||||
unfolded.append(line)
|
||||
return unfolded
|
||||
|
||||
|
||||
def parse_prop_line(line):
|
||||
if ':' not in line:
|
||||
return None, {}, None
|
||||
name_params, value = line.split(':', 1)
|
||||
parts = name_params.split(';')
|
||||
name = parts[0].strip().upper()
|
||||
params = {}
|
||||
for p in parts[1:]:
|
||||
if '=' in p:
|
||||
k, v = p.split('=', 1)
|
||||
params[k.upper()] = v
|
||||
return name, params, value
|
||||
|
||||
|
||||
def extract_master_event(ical_text, uid):
|
||||
lines = unfold_ical_lines(ical_text)
|
||||
events = []
|
||||
current = None
|
||||
for line in lines:
|
||||
if line.strip() == 'BEGIN:VEVENT':
|
||||
current = []
|
||||
elif line.strip() == 'END:VEVENT':
|
||||
if current is not None:
|
||||
events.append(current)
|
||||
current = None
|
||||
elif current is not None:
|
||||
current.append(line)
|
||||
for ev_lines in events:
|
||||
props = {}
|
||||
has_recurrence_id = False
|
||||
ev_uid = None
|
||||
for line in ev_lines:
|
||||
name, params, value = parse_prop_line(line)
|
||||
if not name:
|
||||
continue
|
||||
if name == 'RECURRENCE-ID':
|
||||
has_recurrence_id = True
|
||||
if name == 'UID':
|
||||
ev_uid = value
|
||||
props[name] = (value, params)
|
||||
if ev_uid == uid and not has_recurrence_id:
|
||||
return props
|
||||
return None
|
||||
|
||||
|
||||
def insert_exception(ical_text, exception_lines):
|
||||
insert_text = '\n'.join(exception_lines)
|
||||
if 'END:VCALENDAR' not in ical_text:
|
||||
raise Exception('Invalid VCALENDAR data')
|
||||
head, tail = ical_text.rsplit('END:VCALENDAR', 1)
|
||||
head = head.rstrip('\n')
|
||||
new_text = head + '\n' + insert_text + '\nEND:VCALENDAR' + tail
|
||||
return new_text
|
||||
|
||||
|
||||
def format_ical_date(dt_obj):
|
||||
return dt_obj.strftime('%Y%m%dT%H%M%S')
|
||||
|
||||
def query_events(calendar_url, start_dt, end_dt, search=None):
|
||||
start_str = start_dt.strftime('%Y%m%dT%H%M%SZ')
|
||||
end_str = end_dt.strftime('%Y%m%dT%H%M%SZ')
|
||||
body = f'''<c:calendar-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
|
||||
<d:prop><d:getetag/><c:calendar-data/></d:prop>
|
||||
<c:filter>
|
||||
<c:comp-filter name="VCALENDAR">
|
||||
<c:comp-filter name="VEVENT">
|
||||
<c:time-range start="{start_str}" end="{end_str}"/>
|
||||
</c:comp-filter>
|
||||
</c:comp-filter>
|
||||
</c:filter>
|
||||
</c:calendar-query>'''
|
||||
try:
|
||||
resp = make_request(calendar_url, method='REPORT', body=body, depth='1')
|
||||
except Exception:
|
||||
return []
|
||||
root = ET.fromstring(resp)
|
||||
events = []
|
||||
for r in root.findall(f'{NS_DAV}response'):
|
||||
href = r.find(f'{NS_DAV}href')
|
||||
propstat = r.find(f'{NS_DAV}propstat')
|
||||
if href is None or propstat is None:
|
||||
continue
|
||||
prop = propstat.find(f'{NS_DAV}prop')
|
||||
if prop is None:
|
||||
continue
|
||||
etag = prop.find(f'{NS_DAV}getetag')
|
||||
caldata = prop.find(f'{NS_CALDAV}calendar-data')
|
||||
if caldata is not None and caldata.text:
|
||||
ev = parse_ical_event(caldata.text)
|
||||
if ev and (not search or search.lower() in ev.get('summary','').lower() or search.lower() in ev.get('description','').lower()):
|
||||
ev['etag'] = etag.text if etag is not None else None
|
||||
ev['href'] = href.text
|
||||
events.append(ev)
|
||||
return events
|
||||
|
||||
|
||||
def ical_dump(ev):
|
||||
ics = [
|
||||
'BEGIN:VCALENDAR',
|
||||
'VERSION:2.0',
|
||||
'PRODID:-//OpenClaw//Calendar//EN',
|
||||
'BEGIN:VEVENT'
|
||||
]
|
||||
if ev.get('uid'):
|
||||
ics.append(f"UID:{ev['uid']}")
|
||||
if ev.get('rrule'):
|
||||
ics.append(f"RRULE:{ev['rrule']}")
|
||||
start = ev.get('start')
|
||||
if isinstance(start, datetime):
|
||||
ics.append(f"DTSTART:{start.strftime('%Y%m%dT%H%M%S')}")
|
||||
elif isinstance(start, date):
|
||||
ics.append(f"DTSTART:{start.strftime('%Y%m%d')}")
|
||||
end = ev.get('end')
|
||||
if isinstance(end, datetime):
|
||||
ics.append(f"DTEND:{end.strftime('%Y%m%dT%H%M%S')}")
|
||||
elif isinstance(end, date):
|
||||
ics.append(f"DTEND:{end.strftime('%Y%m%d')}")
|
||||
ics.append(f"SUMMARY:{ev.get('summary','')}")
|
||||
if ev.get('description'):
|
||||
ics.append(f"DESCRIPTION:{ev.get('description','')}")
|
||||
ics.extend(['END:VEVENT', 'END:VCALENDAR'])
|
||||
return '\n'.join(ics)
|
||||
|
||||
|
||||
def cmd_list(args):
|
||||
cals = get_calendars()
|
||||
if not cals:
|
||||
print("No calendars found.")
|
||||
return
|
||||
print("Calendars:")
|
||||
for c in cals:
|
||||
print(f"- {c['name']}")
|
||||
|
||||
|
||||
def cmd_events(args):
|
||||
cal_url = get_calendar_url_by_name(args.calendar)
|
||||
now = datetime.now()
|
||||
if args.today:
|
||||
start_dt = date(now.year, now.month, now.day)
|
||||
end_dt = datetime.combine(start_dt + timedelta(days=1), datetime.min.time())
|
||||
elif args.date:
|
||||
start_dt = date.fromisoformat(args.date)
|
||||
end_dt = datetime.combine(start_dt + timedelta(days=1), datetime.min.time())
|
||||
elif args.start and args.end:
|
||||
start_dt = datetime.fromisoformat(args.start)
|
||||
end_dt = datetime.fromisoformat(args.end)
|
||||
else:
|
||||
start_dt = date(now.year, now.month, now.day)
|
||||
end_dt = datetime.combine(start_dt + timedelta(days=1), datetime.min.time())
|
||||
events = query_events(cal_url, start_dt, end_dt, search=args.search)
|
||||
if not events:
|
||||
print("No events found.")
|
||||
return
|
||||
events.sort(key=lambda e: e.get('start') or datetime.min)
|
||||
for ev in events:
|
||||
start = ev.get('start')
|
||||
time_str = format_dt(start) if start else 'All-day'
|
||||
print(f"[{time_str}] {ev.get('summary','')}")
|
||||
|
||||
|
||||
def cmd_add(args):
|
||||
cal_url = get_calendar_url_by_name(args.calendar)
|
||||
start_dt = datetime.fromisoformat(args.start)
|
||||
end_dt = datetime.fromisoformat(args.end) if args.end else start_dt + timedelta(hours=1)
|
||||
uid = str(uuid.uuid4())
|
||||
dtstamp = datetime.now(timezone.utc).strftime('%Y%m%dT%H%M%SZ')
|
||||
start_str = start_dt.strftime('%Y%m%dT%H%M%S')
|
||||
end_str = end_dt.strftime('%Y%m%dT%H%M%S')
|
||||
ics = [
|
||||
'BEGIN:VCALENDAR',
|
||||
'VERSION:2.0',
|
||||
'PRODID:-//OpenClaw//Calendar//EN',
|
||||
'BEGIN:VEVENT',
|
||||
f"UID:{uid}",
|
||||
f"DTSTAMP:{dtstamp}",
|
||||
f"SUMMARY:{args.summary}",
|
||||
f"DTSTART:{start_str}",
|
||||
f"DTEND:{end_str}"
|
||||
]
|
||||
if args.recurrence:
|
||||
ics.append(f"RRULE:{args.recurrence}")
|
||||
if args.description:
|
||||
ics.append(f"DESCRIPTION:{args.description}")
|
||||
ics.extend(['END:VEVENT', 'END:VCALENDAR'])
|
||||
event_url = f"{cal_url.rstrip('/')}/{uid}.ics"
|
||||
try:
|
||||
make_request(event_url, method='PUT', body='\n'.join(ics))
|
||||
print(f"Added event: {args.summary}")
|
||||
except Exception as e:
|
||||
print(f"Failed to add event: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def cmd_update(args):
|
||||
cal_url = get_calendar_url_by_name(args.calendar)
|
||||
if args.uid:
|
||||
now = datetime.now()
|
||||
start = now - timedelta(days=365)
|
||||
end = now + timedelta(days=365)
|
||||
candidates = query_events(cal_url, start, end)
|
||||
target = None
|
||||
for ev in candidates:
|
||||
if ev.get('uid') == args.uid:
|
||||
target = ev
|
||||
break
|
||||
if not target:
|
||||
print(f"Event with UID {args.uid} not found.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
href = target['href']
|
||||
etag = target['etag']
|
||||
ical_text = make_request(f"{NEXTCLOUD_URL}{href}" if href.startswith('/') else href, method='GET')
|
||||
ev_data = parse_ical_event(ical_text)
|
||||
else:
|
||||
if not args.summary or not args.date:
|
||||
print("Need either --uid or (--summary and --date) to identify event.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
target_date = date.fromisoformat(args.date)
|
||||
start_dt = datetime.combine(target_date, datetime.min.time())
|
||||
end_dt = datetime.combine(target_date + timedelta(days=1), datetime.min.time())
|
||||
candidates = query_events(cal_url, start_dt, end_dt, search=args.summary)
|
||||
if not candidates:
|
||||
print(f"Event not found on {args.date} with summary containing '{args.summary}'.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
if len(candidates) > 1:
|
||||
print(f"Multiple matches; narrow search or use --uid.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
ev_data = candidates[0]
|
||||
href = ev_data['href']
|
||||
etag = ev_data['etag']
|
||||
ical_url = f"{NEXTCLOUD_URL}{href}" if href.startswith('/') else href
|
||||
ical_text = make_request(ical_url, method='GET')
|
||||
ev_data = parse_ical_event(ical_text)
|
||||
if args.set_summary is not None:
|
||||
ev_data['summary'] = args.set_summary
|
||||
if args.set_start:
|
||||
ev_data['start'] = datetime.fromisoformat(args.set_start)
|
||||
if args.set_end:
|
||||
ev_data['end'] = datetime.fromisoformat(args.set_end)
|
||||
if args.set_recurrence is not None:
|
||||
ev_data['rrule'] = args.set_recurrence if args.set_recurrence else None
|
||||
new_ical = ical_dump(ev_data)
|
||||
update_url = f"{NEXTCLOUD_URL}{href}" if href.startswith('/') else href
|
||||
try:
|
||||
make_request(update_url, method='PUT', body=new_ical, etag=etag)
|
||||
print(f"Updated event: {ev_data.get('summary')}")
|
||||
except Exception as e:
|
||||
print(f"Failed to update: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def cmd_delete(args):
|
||||
cal_url = get_calendar_url_by_name(args.calendar)
|
||||
if args.uid:
|
||||
now = datetime.now()
|
||||
start = now - timedelta(days=365)
|
||||
end = now + timedelta(days=365)
|
||||
candidates = query_events(cal_url, start, end)
|
||||
target = None
|
||||
for ev in candidates:
|
||||
if ev.get('uid') == args.uid:
|
||||
target = ev
|
||||
break
|
||||
if not target:
|
||||
print(f"Event with UID {args.uid} not found.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
href = target['href']
|
||||
etag = target['etag']
|
||||
elif args.date and args.summary:
|
||||
target_date = date.fromisoformat(args.date)
|
||||
start_dt = datetime.combine(target_date, datetime.min.time())
|
||||
end_dt = datetime.combine(target_date + timedelta(days=1), datetime.min.time())
|
||||
candidates = query_events(cal_url, start_dt, end_dt, search=args.summary)
|
||||
if not candidates:
|
||||
print("Event not found.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
if len(candidates) > 1:
|
||||
print("Multiple matches; use --uid.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
target = candidates[0]
|
||||
href = target['href']
|
||||
etag = target['etag']
|
||||
else:
|
||||
print("Need --uid or both --date and --summary.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
delete_url = f"{NEXTCLOUD_URL}{href}" if href.startswith('/') else href
|
||||
try:
|
||||
make_request(delete_url, method='DELETE', etag=etag)
|
||||
print(f"Deleted event: {target.get('summary')}")
|
||||
except Exception as e:
|
||||
print(f"Failed to delete: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def cmd_exception(args):
|
||||
cal_url = get_calendar_url_by_name(args.calendar)
|
||||
now = datetime.now()
|
||||
start = now - timedelta(days=365)
|
||||
end = now + timedelta(days=365*5)
|
||||
candidates = query_events(cal_url, start, end)
|
||||
target = None
|
||||
for ev in candidates:
|
||||
if ev.get('uid') == args.uid:
|
||||
target = ev
|
||||
break
|
||||
if not target:
|
||||
print(f"Event with UID {args.uid} not found.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
href = target['href']
|
||||
etag = target['etag']
|
||||
ical_url = f"{NEXTCLOUD_URL}{href}" if href.startswith('/') else href
|
||||
ical_text = make_request(ical_url, method='GET')
|
||||
master = extract_master_event(ical_text, args.uid)
|
||||
if not master:
|
||||
print(f"Master event for UID {args.uid} not found.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
master_dtstart, dtstart_params = master.get('DTSTART', (None, {}))
|
||||
master_dtend, dtend_params = master.get('DTEND', (None, {}))
|
||||
master_summary = master.get('SUMMARY', ('', {}))[0]
|
||||
master_description = master.get('DESCRIPTION', ('', {}))[0]
|
||||
master_sequence = master.get('SEQUENCE', ('0', {}))[0] or '0'
|
||||
|
||||
if not master_dtstart:
|
||||
print("Master event missing DTSTART.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
tzid = dtstart_params.get('TZID')
|
||||
# Recurrence-id uses original instance datetime (same time-of-day as master)
|
||||
if master_dtstart.endswith('Z'):
|
||||
recurrence_id = f"{args.date.replace('-', '')}T{master_dtstart[9:15]}Z"
|
||||
else:
|
||||
time_part = master_dtstart[9:15] if 'T' in master_dtstart else '000000'
|
||||
recurrence_id = f"{args.date.replace('-', '')}T{time_part}"
|
||||
|
||||
start_dt = datetime.fromisoformat(f"{args.date} {args.start}")
|
||||
end_dt = datetime.fromisoformat(f"{args.date} {args.end}")
|
||||
start_str = format_ical_date(start_dt)
|
||||
end_str = format_ical_date(end_dt)
|
||||
|
||||
seq = 0
|
||||
try:
|
||||
seq = int(master_sequence)
|
||||
except ValueError:
|
||||
seq = 0
|
||||
seq += 1
|
||||
|
||||
dtstamp = datetime.now(timezone.utc).strftime('%Y%m%dT%H%M%SZ')
|
||||
|
||||
exception_lines = [
|
||||
'BEGIN:VEVENT',
|
||||
f"UID:{args.uid}",
|
||||
f"DTSTAMP:{dtstamp}",
|
||||
f"SEQUENCE:{seq}",
|
||||
]
|
||||
|
||||
if tzid:
|
||||
exception_lines.append(f"RECURRENCE-ID;TZID={tzid}:{recurrence_id}")
|
||||
exception_lines.append(f"DTSTART;TZID={tzid}:{start_str}")
|
||||
exception_lines.append(f"DTEND;TZID={tzid}:{end_str}")
|
||||
else:
|
||||
exception_lines.append(f"RECURRENCE-ID:{recurrence_id}")
|
||||
exception_lines.append(f"DTSTART:{start_str}")
|
||||
exception_lines.append(f"DTEND:{end_str}")
|
||||
|
||||
if master_summary:
|
||||
exception_lines.append(f"SUMMARY:{master_summary}")
|
||||
if master_description:
|
||||
exception_lines.append(f"DESCRIPTION:{master_description}")
|
||||
exception_lines.append('END:VEVENT')
|
||||
|
||||
new_ical = insert_exception(ical_text, exception_lines)
|
||||
try:
|
||||
make_request(ical_url, method='PUT', body=new_ical, etag=etag)
|
||||
print(f"Created exception for UID {args.uid} on {args.date}")
|
||||
except Exception as e:
|
||||
print(f"Failed to create exception: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def cmd_test(args):
|
||||
missing = []
|
||||
if not NEXTCLOUD_URL: missing.append("NEXTCLOUD_URL")
|
||||
if not NEXTCLOUD_USER: missing.append("NEXTCLOUD_USER")
|
||||
if not NEXTCLOUD_PASSWORD: missing.append("NEXTCLOUD_PASSWORD")
|
||||
if not CALDAV_PRINCIPAL: missing.append("CALDAV_PRINCIPAL")
|
||||
if missing:
|
||||
print("Missing environment variables: " + ", ".join(missing))
|
||||
sys.exit(1)
|
||||
try:
|
||||
get_calendar_home()
|
||||
print("Connection successful. Calendars available:")
|
||||
for cal in get_calendars():
|
||||
print(f"- {cal['name']}")
|
||||
except Exception as e:
|
||||
print(f"Connection failed: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Unified Nextcloud CalDAV CLI')
|
||||
sub = parser.add_subparsers(dest='cmd', required=True)
|
||||
|
||||
sub.add_parser('list', help='List calendars').set_defaults(func=cmd_list)
|
||||
|
||||
ev = sub.add_parser('events', help='View events')
|
||||
ev.add_argument('--calendar', help='Calendar name (default: first)')
|
||||
grp = ev.add_mutually_exclusive_group()
|
||||
grp.add_argument('--today', action='store_true')
|
||||
grp.add_argument('--date', help='Specific date YYYY-MM-DD')
|
||||
grp.add_argument('--start', help='Start datetime ISO')
|
||||
ev.add_argument('--end', help='End datetime ISO (with --start)')
|
||||
ev.add_argument('--search', help='Text search in summary/description')
|
||||
ev.set_defaults(func=cmd_events)
|
||||
|
||||
add = sub.add_parser('add', help='Add event')
|
||||
add.add_argument('--calendar', help='Calendar name')
|
||||
add.add_argument('--summary', required=True, help='Event title')
|
||||
add.add_argument('--start', required=True, help='Start datetime ISO (YYYY-MM-DD HH:MM:SS)')
|
||||
add.add_argument('--end', help='End datetime ISO (default: start + 1h)')
|
||||
add.add_argument('--recurrence', help='RRULE string (e.g., FREQ=WEEKLY;BYDAY=MO)')
|
||||
add.add_argument('--description', help='Event description')
|
||||
add.set_defaults(func=cmd_add)
|
||||
|
||||
upd = sub.add_parser('update', help='Update existing event')
|
||||
upd.add_argument('--calendar', help='Calendar name')
|
||||
idgrp = upd.add_mutually_exclusive_group(required=True)
|
||||
idgrp.add_argument('--uid', help='Event UID to update')
|
||||
idgrp.add_argument('--summary', help='Event title (partial) match')
|
||||
upd.add_argument('--date', help='Date of event (required with --summary)')
|
||||
upd.add_argument('--set-summary', help='New summary')
|
||||
upd.add_argument('--set-start', help='New start datetime ISO')
|
||||
upd.add_argument('--set-end', help='New end datetime ISO')
|
||||
upd.add_argument('--set-recurrence', help='New RRULE (or empty to remove)')
|
||||
upd.set_defaults(func=cmd_update)
|
||||
|
||||
delete = sub.add_parser('delete', help='Delete event')
|
||||
delete.add_argument('--calendar', help='Calendar name')
|
||||
delgrp = delete.add_mutually_exclusive_group(required=True)
|
||||
delgrp.add_argument('--uid', help='Event UID to delete')
|
||||
delgrp.add_argument('--summary', help='Event title match')
|
||||
delete.add_argument('--date', help='Date of event (required with --summary)')
|
||||
delete.set_defaults(func=cmd_delete)
|
||||
|
||||
exc = sub.add_parser('exception', help='Create exception for recurring event instance')
|
||||
exc.add_argument('--calendar', help='Calendar name')
|
||||
exc.add_argument('--uid', required=True, help='Event UID')
|
||||
exc.add_argument('--date', required=True, help='Date of instance to override (YYYY-MM-DD)')
|
||||
exc.add_argument('--start', required=True, help='New start time (HH:MM)')
|
||||
exc.add_argument('--end', required=True, help='New end time (HH:MM)')
|
||||
exc.set_defaults(func=cmd_exception)
|
||||
|
||||
sub.add_parser('test', help='Test connection and config').set_defaults(func=cmd_test)
|
||||
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
args.func(args)
|
||||
except Exception as e:
|
||||
print(f"Error: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,23 +0,0 @@
|
||||
# Dockerfile
|
||||
FROM python:3.10-slim
|
||||
|
||||
# 1) System deps for audio processing
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
ffmpeg \
|
||||
libsndfile1 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 2) Python deps
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# 3) Copy your script + code
|
||||
COPY . .
|
||||
|
||||
# 4) Default entrypoint is just the script; pass args via docker-compose or CLI
|
||||
ENTRYPOINT ["python", "pdf_to_audiobook.py"]
|
||||
|
||||
@@ -1,156 +0,0 @@
|
||||
|
||||
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
pdf_to_audiobook.py
|
||||
|
||||
1) Always convert PDF → Markdown via marker + your OpenAI-compatible endpoint.
|
||||
2) If you pass --voice-name, use Coqui XTTS (voice cloning);
|
||||
otherwise use Kokoro TTS with the “Daniel” speaker.
|
||||
3) Manage your 6-sec snippets in voices/ directory.
|
||||
"""
|
||||
|
||||
import os
|
||||
import argparse
|
||||
import tempfile
|
||||
import numpy as np
|
||||
import torch
|
||||
import soundfile as sf
|
||||
from pathlib import Path
|
||||
from pdfminer.high_level import extract_text
|
||||
from pydub import AudioSegment# Allow Coqui’s XttsConfig class to be unpickled
|
||||
|
||||
# ─── Whitelist Coqui classes for safe CPU‐only loading ────────────────────────
|
||||
from TTS.tts.configs.xtts_config import XttsConfig
|
||||
from TTS.tts.models.xtts import XttsAudioConfig
|
||||
from TTS.config.shared_configs import BaseDatasetConfig
|
||||
from TTS.tts.models.xtts import XttsArgs
|
||||
from torch.serialization import add_safe_globals
|
||||
add_safe_globals([XttsConfig, XttsAudioConfig, BaseDatasetConfig, XttsArgs])
|
||||
|
||||
# ─── Coqui XTTS API ─────────────────────────────────────────────────────────
|
||||
from TTS.api import TTS
|
||||
|
||||
# ─── Kokoro TTS API ─────────────────────────────────────────────────────────
|
||||
from kokoro import KPipeline
|
||||
|
||||
# ─── marker PDF→Markdown API ────────────────────────────────────────────────
|
||||
from marker.converters.pdf import PdfConverter
|
||||
from marker.models import create_model_dict
|
||||
from marker.config.parser import ConfigParser
|
||||
from marker.output import text_from_rendered
|
||||
|
||||
VOICE_DIR = Path("voices")
|
||||
|
||||
def list_available_voices():
|
||||
return sorted(p.stem for p in VOICE_DIR.glob("*.wav"))
|
||||
|
||||
def convert_pdf_to_markdown(pdf_path: str) -> str:
|
||||
key = os.getenv("OPENAI_API_KEY")
|
||||
model = os.getenv("OPENAI_MODEL")
|
||||
url = os.getenv("OPENAI_BASE_URL")
|
||||
if not key:
|
||||
raise RuntimeError("Please set OPENAI_API_KEY in your environment")
|
||||
cfg = {
|
||||
"output_format": "markdown",
|
||||
"use_llm": True,
|
||||
"llm_service": "marker.services.openai.OpenAIService",
|
||||
"openai_api_key": key,
|
||||
"openai_model": model,
|
||||
"openai_base_url": url,
|
||||
}
|
||||
parser = ConfigParser(cfg)
|
||||
converter = PdfConverter(
|
||||
config = parser.generate_config_dict(),
|
||||
artifact_dict = create_model_dict(),
|
||||
processor_list = parser.get_processors(),
|
||||
renderer = parser.get_renderer(),
|
||||
llm_service = parser.get_llm_service(),
|
||||
)
|
||||
rendered = converter(pdf_path)
|
||||
markdown, _, _ = text_from_rendered(rendered)
|
||||
return markdown
|
||||
|
||||
def synthesize_with_coqui(
|
||||
text: str,
|
||||
out_mp3: str,
|
||||
voice: str,
|
||||
speaker: str | None,
|
||||
lang: str,
|
||||
):
|
||||
use_gpu = torch.cuda.is_available()
|
||||
tts = TTS(model_name="tts_models/multilingual/xtts_v2", gpu=use_gpu)
|
||||
|
||||
spk_wav = [voice]
|
||||
spk_name = speaker or tts.speakers[0]
|
||||
print(f"⚙️ Using Coqui voice sample “{voice}” → speaker “{spk_name}”")
|
||||
|
||||
tmp_wav = tempfile.mktemp(suffix=".wav")
|
||||
tts.tts_to_file(
|
||||
text = text,
|
||||
file_path = tmp_wav,
|
||||
speaker_wav = spk_wav,
|
||||
speaker = spk_name,
|
||||
language = lang,
|
||||
split_sentences = True,
|
||||
)
|
||||
AudioSegment.from_wav(tmp_wav).export(out_mp3, format="mp3")
|
||||
print(f"✅ Coqui MP3 saved → {out_mp3}")
|
||||
|
||||
def synthesize_with_kokoro(
|
||||
text: str,
|
||||
out_mp3:str,
|
||||
lang: str,
|
||||
):
|
||||
pipeline = KPipeline(lang_code=lang)
|
||||
chunks = []
|
||||
# Daniel is the chosen voice
|
||||
for _, _, audio in pipeline(text, voice="Daniel"):
|
||||
chunks.append(audio)
|
||||
full = np.concatenate(chunks, axis=0)
|
||||
|
||||
tmp_wav = tempfile.mktemp(suffix=".wav")
|
||||
sf.write(tmp_wav, full, 24000)
|
||||
AudioSegment.from_wav(tmp_wav).export(out_mp3, format="mp3")
|
||||
print(f"✅ Kokoro MP3 saved → {out_mp3}")
|
||||
|
||||
def main():
|
||||
# ensure voices/ exists
|
||||
VOICE_DIR.mkdir(exist_ok=True)
|
||||
|
||||
ap = argparse.ArgumentParser(
|
||||
description="PDF→Markdown→Audiobook (Coqui or Kokoro/Daniel)"
|
||||
)
|
||||
ap.add_argument("pdf", help="Input PDF file")
|
||||
ap.add_argument("--list-voices", action="store_true",
|
||||
help="Show available voice snippets and exit")
|
||||
ap.add_argument("--voice-name", help="Name of a .mp3 in voices/ to clone")
|
||||
ap.add_argument("--speaker", help="Coqui built-in speaker (default if none)")
|
||||
ap.add_argument("--lang", default="en", help="Language code")
|
||||
ap.add_argument("--out", default="audiobook.mp3",
|
||||
help="Output MP3 path")
|
||||
args = ap.parse_args()
|
||||
|
||||
if args.list_voices:
|
||||
print("Available voices:")
|
||||
for name in list_available_voices():
|
||||
print(" ", name)
|
||||
return
|
||||
|
||||
# 1) PDF→Markdown
|
||||
print("🔄 Converting PDF → Markdown…")
|
||||
text = convert_pdf_to_markdown(args.pdf)
|
||||
|
||||
# 2) Choose engine
|
||||
if args.voice_name:
|
||||
wav_path = VOICE_DIR / f"{args.voice_name}.wav"
|
||||
if not wav_path.is_file():
|
||||
raise FileNotFoundError(f"voices/{args.voice_name}.wav not found.")
|
||||
synthesize_with_coqui(text, args.out, str(wav_path),
|
||||
args.speaker, args.lang)
|
||||
else:
|
||||
synthesize_with_kokoro(text, args.out, args.lang)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
marker-pdf
|
||||
kokoro>=0.9.4
|
||||
soundfile
|
||||
TTS
|
||||
pdfminer.six
|
||||
pydub
|
||||
torch
|
||||
"transformers<4.50.0"
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,84 +0,0 @@
|
||||
FROM registry.fakecake.org/docker.io/alpine:3.18
|
||||
EXPOSE 9000/tcp
|
||||
|
||||
ENV SCRIPT_ROOT=/opt/tt-rss
|
||||
ENV SRC_DIR=/src/tt-rss/
|
||||
|
||||
RUN apk add --no-cache dcron php82 php82-fpm php82-phar php82-sockets php82-pecl-apcu \
|
||||
php82-pdo php82-gd php82-mysql php82-pdo_mysql php82-xmlwriter php82-opcache \
|
||||
php82-mbstring php82-intl php82-xml php82-curl php82-simplexml \
|
||||
php82-session php82-tokenizer php82-dom php82-fileinfo php82-ctype \
|
||||
php82-json php82-iconv php82-pcntl php82-posix php82-zip php82-exif \
|
||||
php82-openssl git mysql mysql-client sudo php82-pecl-xdebug rsync tzdata && \
|
||||
sed -i 's/\(memory_limit =\) 128M/\1 256M/' /etc/php82/php.ini && \
|
||||
sed -i -e 's/^listen = 127.0.0.1:9000/listen = 9000/' \
|
||||
-e 's/;\(clear_env\) = .*/\1 = no/i' \
|
||||
-e 's/^\(user\|group\) = .*/\1 = app/i' \
|
||||
-e 's/;\(php_admin_value\[error_log\]\) = .*/\1 = \/tmp\/error.log/' \
|
||||
-e 's/;\(php_admin_flag\[log_errors\]\) = .*/\1 = on/' \
|
||||
/etc/php82/php-fpm.d/www.conf && \
|
||||
mkdir -p /var/www ${SCRIPT_ROOT}/config.d
|
||||
|
||||
ARG CI_COMMIT_BRANCH
|
||||
ENV CI_COMMIT_BRANCH=${CI_COMMIT_BRANCH}
|
||||
|
||||
ARG CI_COMMIT_SHORT_SHA
|
||||
ENV CI_COMMIT_SHORT_SHA=${CI_COMMIT_SHORT_SHA}
|
||||
|
||||
ARG CI_COMMIT_TIMESTAMP
|
||||
ENV CI_COMMIT_TIMESTAMP=${CI_COMMIT_TIMESTAMP}
|
||||
|
||||
ARG CI_COMMIT_SHA
|
||||
ENV CI_COMMIT_SHA=${CI_COMMIT_SHA}
|
||||
|
||||
ADD --chmod=0755 startup.sh ${SCRIPT_ROOT}
|
||||
|
||||
ADD index.php ${SCRIPT_ROOT}
|
||||
ADD config.docker.php ${SCRIPT_ROOT}
|
||||
|
||||
COPY --from=app-src . ${SRC_DIR}
|
||||
|
||||
ARG ORIGIN_REPO_XACCEL=https://git.tt-rss.org/fox/ttrss-nginx-xaccel.git
|
||||
|
||||
RUN git clone --depth=1 ${ORIGIN_REPO_XACCEL} ${SRC_DIR}/plugins.local/nginx_xaccel
|
||||
|
||||
ENV OWNER_UID=1000
|
||||
ENV OWNER_GID=1000
|
||||
|
||||
ENV PHP_WORKER_MAX_CHILDREN=5
|
||||
ENV PHP_WORKER_MEMORY_LIMIT=256M
|
||||
|
||||
# these are applied on every startup, if set
|
||||
ENV ADMIN_USER_PASS=""
|
||||
# see classes/UserHelper.php ACCESS_LEVEL_*
|
||||
# setting this to -2 would effectively disable built-in admin user
|
||||
# unless single user mode is enabled
|
||||
ENV ADMIN_USER_ACCESS_LEVEL=""
|
||||
|
||||
# these are applied unless user already exists
|
||||
ENV AUTO_CREATE_USER=""
|
||||
ENV AUTO_CREATE_USER_PASS=""
|
||||
ENV AUTO_CREATE_USER_ACCESS_LEVEL="0"
|
||||
|
||||
# TODO: remove prefix from container variables not used by tt-rss itself:
|
||||
#
|
||||
# - TTRSS_NO_STARTUP_PLUGIN_UPDATES -> NO_STARTUP_PLUGIN_UPDATES
|
||||
# - TTRSS_XDEBUG_... -> XDEBUG_...
|
||||
|
||||
# don't try to update local plugins on startup
|
||||
ENV TTRSS_NO_STARTUP_PLUGIN_UPDATES=""
|
||||
|
||||
# TTRSS_XDEBUG_HOST defaults to host IP if unset
|
||||
ENV TTRSS_XDEBUG_ENABLED=""
|
||||
ENV TTRSS_XDEBUG_HOST=""
|
||||
ENV TTRSS_XDEBUG_PORT="9000"
|
||||
|
||||
ENV TTRSS_DB_TYPE="mysql"
|
||||
ENV TTRSS_DB_PORT="3306"
|
||||
|
||||
ENV TTRSS_MYSQL_CHARSET="UTF8"
|
||||
ENV TTRSS_PHP_EXECUTABLE="/usr/bin/php82"
|
||||
ENV TTRSS_PLUGINS="auth_internal, note, nginx_xaccel"
|
||||
|
||||
CMD ${SCRIPT_ROOT}/startup.sh
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
<?php
|
||||
header("Location: /tt-rss/");
|
||||
return;
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
#!/bin/sh -e
|
||||
|
||||
# We don't need those here (HTTP_HOST would cause false SELF_URL_PATH check failures)
|
||||
unset HTTP_PORT
|
||||
unset HTTP_HOST
|
||||
|
||||
if ! id app >/dev/null 2>&1; then
|
||||
addgroup -g $OWNER_GID app
|
||||
adduser -D -h /var/www/html -G app -u $OWNER_UID app
|
||||
fi
|
||||
|
||||
update-ca-certificates || true
|
||||
|
||||
DST_DIR=/var/www/html/tt-rss
|
||||
|
||||
[ -e $DST_DIR ] && rm -f $DST_DIR/.app_is_ready
|
||||
|
||||
[ ! -e /var/www/html/index.php ] && cp ${SCRIPT_ROOT}/index.php /var/www/html
|
||||
|
||||
if [ ! -d $DST_DIR ]; then
|
||||
mkdir -p $DST_DIR
|
||||
chown $OWNER_UID:$OWNER_GID $DST_DIR
|
||||
|
||||
sudo -u app rsync -a \
|
||||
$SRC_DIR/ $DST_DIR/
|
||||
else
|
||||
chown -R $OWNER_UID:$OWNER_GID $DST_DIR
|
||||
|
||||
sudo -u app rsync -a --delete \
|
||||
--exclude /cache \
|
||||
--exclude /lock \
|
||||
--exclude /feed-icons \
|
||||
--exclude /plugins/af_comics/filters.local \
|
||||
--exclude /plugins.local \
|
||||
--exclude /templates.local \
|
||||
--exclude /themes.local \
|
||||
$SRC_DIR/ $DST_DIR/
|
||||
|
||||
sudo -u app rsync -a --delete \
|
||||
$SRC_DIR/plugins.local/nginx_xaccel \
|
||||
$DST_DIR/plugins.local/nginx_xaccel
|
||||
fi
|
||||
|
||||
for d in cache lock feed-icons plugins.local themes.local; do
|
||||
sudo -u app mkdir -p $DST_DIR/$d
|
||||
done
|
||||
|
||||
for d in cache lock feed-icons; do
|
||||
chmod 777 $DST_DIR/$d
|
||||
find $DST_DIR/$d -type f -exec chmod 666 {} \;
|
||||
done
|
||||
|
||||
sudo -u app cp ${SCRIPT_ROOT}/config.docker.php $DST_DIR/config.php
|
||||
chmod 644 $DST_DIR/config.php
|
||||
|
||||
chown -R $OWNER_UID:$OWNER_GID $DST_DIR \
|
||||
/var/log/php82
|
||||
|
||||
if [ -z "$TTRSS_NO_STARTUP_PLUGIN_UPDATES" ]; then
|
||||
echo updating all local plugins...
|
||||
|
||||
find $DST_DIR/plugins.local -mindepth 1 -maxdepth 1 -type d | while read PLUGIN; do
|
||||
if [ -d $PLUGIN/.git ]; then
|
||||
echo updating $PLUGIN...
|
||||
|
||||
cd $PLUGIN && \
|
||||
sudo -u app git config core.filemode false && \
|
||||
sudo -u app git config pull.rebase false && \
|
||||
sudo -u app git pull origin master || echo warning: attempt to update plugin $PLUGIN failed.
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo skipping local plugin updates, disabled.
|
||||
fi
|
||||
|
||||
MSQL="mysql -q -h $TTRSS_DB_HOST -U $TTRSS_DB_USER -p $TTRSS_DB_PASS -D $TTRSS_DB_NAME"
|
||||
|
||||
RESTORE_SCHEMA=${SCRIPT_ROOT}/restore-schema.sql.gz
|
||||
|
||||
if [ -r $RESTORE_SCHEMA ]; then
|
||||
$PSQL -c "drop schema public cascade; create schema public;"
|
||||
zcat $RESTORE_SCHEMA | $PSQL
|
||||
fi
|
||||
|
||||
# this was previously generated
|
||||
rm -f $DST_DIR/config.php.bak
|
||||
|
||||
sed -i.bak "s/^\(memory_limit\) = \(.*\)/\1 = ${PHP_WORKER_MEMORY_LIMIT}/" \
|
||||
/etc/php82/php.ini
|
||||
|
||||
sed -i.bak "s/^\(pm.max_children\) = \(.*\)/\1 = ${PHP_WORKER_MAX_CHILDREN}/" \
|
||||
/etc/php82/php-fpm.d/www.conf
|
||||
|
||||
sudo -Eu app php82 $DST_DIR/update.php --update-schema=force-yes
|
||||
|
||||
if [ ! -z "$ADMIN_USER_PASS" ]; then
|
||||
sudo -Eu app php82 $DST_DIR/update.php --user-set-password "admin:$ADMIN_USER_PASS"
|
||||
else
|
||||
if sudo -Eu app php82 $DST_DIR/update.php --user-check-password "admin:password"; then
|
||||
RANDOM_PASS=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 16 ; echo '')
|
||||
|
||||
echo "*****************************************************************************"
|
||||
echo "* Setting initial built-in admin user password to '$RANDOM_PASS' *"
|
||||
echo "* If you want to set it manually, use ADMIN_USER_PASS environment variable. *"
|
||||
echo "*****************************************************************************"
|
||||
|
||||
sudo -Eu app php82 $DST_DIR/update.php --user-set-password "admin:$RANDOM_PASS"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -z "$ADMIN_USER_ACCESS_LEVEL" ]; then
|
||||
sudo -Eu app php82 $DST_DIR/update.php --user-set-access-level "admin:$ADMIN_USER_ACCESS_LEVEL"
|
||||
fi
|
||||
|
||||
if [ ! -z "$AUTO_CREATE_USER" ]; then
|
||||
sudo -Eu app /bin/sh -c "php82 $DST_DIR/update.php --user-exists $AUTO_CREATE_USER ||
|
||||
php82 $DST_DIR/update.php --force-yes --user-add \"$AUTO_CREATE_USER:$AUTO_CREATE_USER_PASS:$AUTO_CREATE_USER_ACCESS_LEVEL\""
|
||||
fi
|
||||
|
||||
rm -f /tmp/error.log && mkfifo /tmp/error.log && chown app:app /tmp/error.log
|
||||
|
||||
(tail -q -f /tmp/error.log >> /proc/1/fd/2) &
|
||||
|
||||
unset ADMIN_USER_PASS
|
||||
unset AUTO_CREATE_USER_PASS
|
||||
|
||||
touch $DST_DIR/.app_is_ready
|
||||
|
||||
exec /usr/sbin/php-fpm82 --nodaemonize --force-stderr
|
||||
|
||||
Reference in New Issue
Block a user