diff --git a/.github/workflows/build_tools.yaml b/.github/workflows/build_tools.yaml index 2e4d406a..477971df 100644 --- a/.github/workflows/build_tools.yaml +++ b/.github/workflows/build_tools.yaml @@ -13,64 +13,14 @@ on: required: true type: boolean default: true + have_run_tests: + description: 'Have you run tests successfully?' + required: true + type: boolean + default: false jobs: - run_tests: - runs-on: ubuntu-latest - permissions: - contents: write - - steps: - - uses: actions/checkout@v3 - - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - - - name: Install b3sum - run: cargo install b3sum - - - name: Setup Deno - uses: denoland/setup-deno@v2 - with: - deno-version: v2.x - - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y curl jq zip unzip coreutils - - - name: Run node in background - id: run_node - env: - INITIAL_AGENT_NAMES: ${{ secrets.INITIAL_AGENT_NAMES }} - INITIAL_AGENT_URLS: ${{ secrets.INITIAL_AGENT_URLS }} - INITIAL_AGENT_MODELS: ${{ secrets.INITIAL_AGENT_MODELS }} - INITIAL_AGENT_API_KEYS: ${{ secrets.INITIAL_AGENT_API_KEYS }} - API_V2_KEY: ${{ secrets.API_V2_KEY }} - EMBEDDINGS_SERVER_URL: ${{ secrets.EMBEDDINGS_SERVER_URL }} - SHINKAI_NODE_ADDR: "http://localhost:9550" - BEARER_TOKEN: ${{ secrets.API_V2_KEY }} - INITIALIZATION_DATA: ${{ secrets.INITIALIZATION_DATA }} - DOWNLOAD_PREFIX: ${{ inputs.use_dev_prefix && 'https://download.shinkai.com/dev-tools-' || 'https://download.shinkai.com/tools-' }}${{ inputs.node_version }} - SKIP_IMPORT_FROM_DIRECTORY: true - SHINKAI_STORE_ADDR: "https://shinkai-store-302883622007.us-central1.run.app" - SHINKAI_STORE_TOKEN: ${{ secrets.SHINKAI_STORE_TOKEN }} - USE_DOCKER: true - SHINKAI_NODE_IMAGE: "dcsparkdevops/shinkai-node:${{ inputs.node_version }}" - run: | - ./scripts/run_node.sh & - timeout 60 bash -c 'until curl -s --location "$SHINKAI_NODE_ADDR/v2/health_check" | jq -e ".status == \"ok\"" > /dev/null; do sleep 1; done' - curl --location "$SHINKAI_NODE_ADDR/v2/initial_registration" \ - --header 'Content-Type: application/json; charset=utf-8' \ - --data "$INITIALIZATION_DATA" - rm -rf ./packages && mkdir ./packages - deno test --allow-read --allow-write --allow-env --allow-net --allow-run scripts/ - rm -rf ./shinkai-node/storage build_tools: - needs: run_tests runs-on: ubuntu-latest permissions: contents: write diff --git a/scripts/build_tools/save_tools.ts b/scripts/build_tools/save_tools.ts index 965e083f..2b1b8300 100644 --- a/scripts/build_tools/save_tools.ts +++ b/scripts/build_tools/save_tools.ts @@ -210,7 +210,6 @@ export async function processToolsDirectory(): Promise { toolFile, file: `${Deno.env.get("DOWNLOAD_PREFIX")}/${toolName.toLowerCase().replace(/[^a-z0-9_.-]/g, '_')}.zip`, price_usd: metadata.price_usd || 0.00, - stripeProductId: "prod_P000000000000", // categoryId: "cat_P000000000000", // to-do: categories not implemented yet. dependencies, }); diff --git a/scripts/build_tools/upload.ts b/scripts/build_tools/upload.ts index 08c4cf1f..b89c661b 100644 --- a/scripts/build_tools/upload.ts +++ b/scripts/build_tools/upload.ts @@ -1,5 +1,6 @@ import { DirectoryEntry } from "./interfaces.ts"; +// Upload tools to Shinkai Store export async function uploadTools(tools: DirectoryEntry[]) { const store_addr = Deno.env.get("SHINKAI_STORE_ADDR"); const store_token = Deno.env.get("SHINKAI_STORE_TOKEN"); @@ -45,8 +46,25 @@ export async function uploadTools(tools: DirectoryEntry[]) { } } - console.log(`Upload to Store Response (${response.status}): ${await response.text()}`); - if (response.status !== 200) console.log(`Request body failed: ${JSON.stringify(store_entry, null, 2)}`); + if (response.status !== 200) { + console.log(`Upload to Store Response (${response.status}): ${await response.text()}`); + console.log(`Request body failed: ${JSON.stringify(store_entry, null, 2)}`); + } + if (response.status === 200) { + console.log(`Created/Updated ${entry.routerKey} to Shinkai Store`); + if (entry.isDefault) { + const default_tool = await fetch(`${store_addr}/store/defaults/${entry.routerKey}`, { + method: "POST", + headers: { + "Authorization": `Bearer ${store_token}`, + }, + }); + if (default_tool.status !== 200) { + console.log(`Set default tool for ${entry.routerKey}: ${default_tool.status}`); + console.log(await default_tool.text()); + } + } + } } } \ No newline at end of file