Spaces:
Paused
Paused
fix: generate iii-config.yaml with HF Space CORS and absolute paths
Browse files1234522 unmodified lines282930313233343529 unmodified lines6566676869707172#!/bin/bashset -e# Create agentmemory data dirmkdir -p /home/user/.agentmemory22 unmodified linesexport AGENTMEMORY_URL=http://localhost:3111export III_ENGINE_URL=ws://localhost:49134# Allow HF Space's public host through the viewer's host checkif [ -n "${SPACE_HOST}" ]; thenexport VIEWER_ALLOWED_HOSTS="${VIEWER_ALLOWED_HOSTS:-${SPACE_HOST},${SPACE_HOST}:443,${SPACE_HOST}:7860}"export VIEWER_ALLOWED_ORIGINS="${VIEWER_ALLOWED_ORIGINS:-https://${SPACE_HOST},http://${SPACE_HOST},http://localhost:3111,http://localhost:3113,http://127.0.0.1:3111,http://127.0.0.1:3113}"fi29 unmodified linesVIEWER_ALLOWED_ORIGINS=${VIEWER_ALLOWED_ORIGINS}EOF# Start agentmemory daemon (installed binary, not npx)agentmemory &# Wait for daemon to be readysleep 51234522 unmodified lines2829303132333435363729 unmodified lines676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130#!/bin/bash# Note: no set -e — sync failures must not kill the container# Create agentmemory data dirmkdir -p /home/user/.agentmemory22 unmodified linesexport AGENTMEMORY_URL=http://localhost:3111export III_ENGINE_URL=ws://localhost:49134# Build CORS allowed origins — always include HF Space public hostCORS_ORIGINS="http://localhost:3111,http://localhost:3113,http://127.0.0.1:3111,http://127.0.0.1:3113"if [ -n "${SPACE_HOST}" ]; thenCORS_ORIGINS="${CORS_ORIGINS},https://${SPACE_HOST},http://${SPACE_HOST}"export VIEWER_ALLOWED_HOSTS="${VIEWER_ALLOWED_HOSTS:-${SPACE_HOST},${SPACE_HOST}:443,${SPACE_HOST}:7860}"export VIEWER_ALLOWED_ORIGINS="${VIEWER_ALLOWED_ORIGINS:-https://${SPACE_HOST},http://${SPACE_HOST},http://localhost:3111,http://localhost:3113,http://127.0.0.1:3111,http://127.0.0.1:3113}"fi29 unmodified linesVIEWER_ALLOWED_ORIGINS=${VIEWER_ALLOWED_ORIGINS}EOF# Generate iii-config.yaml with correct absolute paths and HF Space CORScat > /home/user/.agentmemory/iii-config.yaml <<EOFworkers:- name: iii-httpconfig:port: 3111host: 0.0.0.0default_timeout: 180000cors:allowed_origins: [${CORS_ORIGINS}]allowed_methods: [GET, POST, PUT, DELETE, OPTIONS]- name: iii-stateconfig:adapter:name: kvconfig:store_method: file_basedfile_path: /home/user/.agentmemory/state_store.db- name: iii-queueconfig:adapter:name: builtin- name: iii-pubsubconfig:adapter:name: local- name: iii-cronconfig:adapter:name: kv- name: iii-streamconfig:port: 3112host: 0.0.0.0adapter:name: kvconfig:store_method: file_basedfile_path: /home/user/.agentmemory/stream_store- name: iii-observabilityconfig:enabled: trueservice_name: agentmemoryexporter: memorysampling_ratio: 1.0metrics_enabled: truelogs_enabled: truelogs_console_output: true- name: iii-execconfig:exec:- node dist/index.mjsEOFecho "[start] iii-config.yaml written with CORS origins: ${CORS_ORIGINS}"# Start agentmemory daemon with our custom iii-configagentmemory --config /home/user/.agentmemory/iii-config.yaml &# Wait for daemon to be readysleep 5
start.sh+62-4