mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-07 06:28:48 +00:00
Compare commits
4 Commits
sno-agent
...
fix/lgraph
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06e5fd4a08 | ||
|
|
522095b79f | ||
|
|
777163f419 | ||
|
|
e9c397c0c0 |
@@ -46,9 +46,3 @@ ALGOLIA_API_KEY=684d998c36b67a9a9fce8fc2d8860579
|
||||
# SENTRY_ORG=comfy-org
|
||||
# SENTRY_PROJECT=cloud-frontend-staging
|
||||
# SENTRY_PROJECT_PROD= # prod project slug for sourcemap uploads
|
||||
|
||||
# Ashby (apps/website careers page build).
|
||||
# Server-only; read inside the Astro build context. Do NOT prefix with PUBLIC_.
|
||||
# When unset, the committed snapshot at apps/website/src/data/ashby-roles.snapshot.json is used.
|
||||
# WEBSITE_ASHBY_API_KEY=
|
||||
# WEBSITE_ASHBY_JOB_BOARD_NAME=comfy-org
|
||||
|
||||
147
.github/workflows/ci-deploy-preview.yaml
vendored
147
.github/workflows/ci-deploy-preview.yaml
vendored
@@ -1,147 +0,0 @@
|
||||
# Description: Builds ComfyUI frontend and deploys previews to Cloudflare Pages
|
||||
name: 'CI: Deploy Preview'
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
# Post starting comment for non-forked PRs
|
||||
comment-on-pr-start:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Post starting comment
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
chmod +x scripts/cicd/pr-preview-deploy-and-comment.sh
|
||||
./scripts/cicd/pr-preview-deploy-and-comment.sh \
|
||||
"${{ github.event.pull_request.number }}" \
|
||||
"starting"
|
||||
|
||||
# Build frontend for all PRs and pushes
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
conclusion: ${{ steps.job-status.outputs.conclusion }}
|
||||
workflow-url: ${{ steps.workflow-url.outputs.url }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Setup frontend
|
||||
uses: ./.github/actions/setup-frontend
|
||||
|
||||
- name: Build frontend
|
||||
env:
|
||||
FRONTEND_COMMIT_HASH: ${{ github.sha }}
|
||||
CI_BRANCH: ${{ github.head_ref || github.ref_name }}
|
||||
CI_PR_NUMBER: ${{ github.event.pull_request.number || '' }}
|
||||
CI_PR_AUTHOR: ${{ github.event.pull_request.user.login || '' }}
|
||||
CI_RUN_ID: ${{ github.run_id }}
|
||||
CI_JOB_ID: ${{ github.job }}
|
||||
USE_PROD_CONFIG: 'true'
|
||||
run: pnpm build
|
||||
|
||||
- name: Set job status
|
||||
id: job-status
|
||||
if: always()
|
||||
run: |
|
||||
echo "conclusion=${{ job.status }}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Get workflow URL
|
||||
id: workflow-url
|
||||
if: always()
|
||||
run: |
|
||||
echo "url=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Upload build artifact
|
||||
if: success() && github.event.pull_request.head.repo.fork == false
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: dist
|
||||
path: dist/
|
||||
retention-days: 7
|
||||
|
||||
# Deploy and comment for non-forked PRs only
|
||||
deploy-and-comment:
|
||||
needs: [comment-on-pr-start, build]
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false && always()
|
||||
permissions:
|
||||
pull-requests: write
|
||||
contents: read
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: '.nvmrc'
|
||||
|
||||
- name: Download build artifact
|
||||
if: needs.build.outputs.conclusion == 'success'
|
||||
uses: actions/download-artifact@v7
|
||||
with:
|
||||
name: dist
|
||||
path: dist
|
||||
|
||||
- name: Make deployment script executable
|
||||
run: chmod +x scripts/cicd/pr-preview-deploy-and-comment.sh
|
||||
|
||||
- name: Deploy preview and comment on PR
|
||||
env:
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
WORKFLOW_CONCLUSION: ${{ needs.build.outputs.conclusion }}
|
||||
WORKFLOW_URL: ${{ needs.build.outputs.workflow-url }}
|
||||
BRANCH_NAME: ${{ github.head_ref }}
|
||||
run: |
|
||||
./scripts/cicd/pr-preview-deploy-and-comment.sh \
|
||||
"${{ github.event.pull_request.number }}" \
|
||||
"completed"
|
||||
|
||||
# Deploy to production URL on main branch push
|
||||
deploy-production:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Setup frontend
|
||||
uses: ./.github/actions/setup-frontend
|
||||
|
||||
- name: Build frontend
|
||||
env:
|
||||
FRONTEND_COMMIT_HASH: ${{ github.sha }}
|
||||
CI_BRANCH: ${{ github.ref_name }}
|
||||
CI_RUN_ID: ${{ github.run_id }}
|
||||
CI_JOB_ID: ${{ github.job }}
|
||||
run: pnpm build
|
||||
|
||||
- name: Deploy to Cloudflare Pages (production)
|
||||
env:
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
run: |
|
||||
pnpm dlx wrangler@^4.0.0 pages deploy dist \
|
||||
--project-name=comfy-ui \
|
||||
--branch=main
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -99,5 +99,4 @@ vitest.config.*.timestamp*
|
||||
# Weekly docs check output
|
||||
/output.txt
|
||||
|
||||
.amp
|
||||
.claude/scheduled_tasks.lock
|
||||
.amp
|
||||
1
apps/website/.gitignore
vendored
1
apps/website/.gitignore
vendored
@@ -2,7 +2,6 @@ dist/
|
||||
.astro/
|
||||
test-results/
|
||||
playwright-report/
|
||||
results.json
|
||||
|
||||
# Platform-specific Playwright snapshots (CI runs Linux)
|
||||
*-win32.png
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
# @comfyorg/website
|
||||
|
||||
Marketing/brand website built with Astro + Vue.
|
||||
|
||||
## Ashby careers integration
|
||||
|
||||
`/careers` and `/zh-CN/careers` are rendered from Ashby's public job board
|
||||
API at build time. Data flow:
|
||||
|
||||
1. `src/pages/careers.astro` awaits `fetchRolesForBuild()` during the
|
||||
Astro build.
|
||||
2. `src/utils/ashby.ts` calls
|
||||
`GET https://api.ashbyhq.com/posting-api/job-board/{board}?includeCompensation=false`,
|
||||
validates the envelope and each posting with Zod
|
||||
(`src/utils/ashby.schema.ts`), and maps to the domain type in
|
||||
`src/data/roles.ts`.
|
||||
3. On any failure (network, HTTP 4xx/5xx, envelope schema drift),
|
||||
the fetcher falls back to the committed JSON snapshot at
|
||||
`src/data/ashby-roles.snapshot.json`.
|
||||
4. `src/utils/ashby.ci.ts` emits GitHub Actions annotations and a
|
||||
`$GITHUB_STEP_SUMMARY` block so stale fetches are visible on green
|
||||
builds.
|
||||
|
||||
### Required environment variables
|
||||
|
||||
Both are build-time only. Never prefix with `PUBLIC_` (Astro would
|
||||
inline that into the client bundle).
|
||||
|
||||
| Name | Purpose | Default (when unset) |
|
||||
| ------------------------------ | --------------------------- | --------------------------------- |
|
||||
| `WEBSITE_ASHBY_API_KEY` | Ashby API key (Basic auth) | Build uses the committed snapshot |
|
||||
| `WEBSITE_ASHBY_JOB_BOARD_NAME` | Ashby public job board slug | Build uses the committed snapshot |
|
||||
|
||||
### CI wiring (manual step — required)
|
||||
|
||||
This repo's `.github/workflows/*.yaml` changes cannot be pushed by a
|
||||
GitHub App. A maintainer must apply the following edits **once**:
|
||||
|
||||
**`.github/workflows/ci-website-build.yaml`** — pass the env into the
|
||||
build step and run the unit tests before it:
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- name: Setup frontend
|
||||
uses: ./.github/actions/setup-frontend
|
||||
|
||||
- name: Run website unit tests
|
||||
run: pnpm --filter @comfyorg/website test:unit
|
||||
|
||||
- name: Build website
|
||||
env:
|
||||
WEBSITE_ASHBY_API_KEY: ${{ secrets.WEBSITE_ASHBY_API_KEY }}
|
||||
WEBSITE_ASHBY_JOB_BOARD_NAME: ${{ vars.WEBSITE_ASHBY_JOB_BOARD_NAME || 'comfy-org' }}
|
||||
run: pnpm --filter @comfyorg/website build
|
||||
|
||||
- name: Verify API key is not leaked into build output
|
||||
env:
|
||||
WEBSITE_ASHBY_API_KEY: ${{ secrets.WEBSITE_ASHBY_API_KEY }}
|
||||
run: |
|
||||
set +x
|
||||
if [ -z "${WEBSITE_ASHBY_API_KEY:-}" ]; then
|
||||
echo "Secret not available in this run; skipping leak check."
|
||||
exit 0
|
||||
fi
|
||||
# grep -rlF prints only file paths (never match content).
|
||||
MATCHES=$(grep -rlF --exclude-dir=node_modules --null \
|
||||
-e "$WEBSITE_ASHBY_API_KEY" apps/website/dist/ 2>/dev/null \
|
||||
| tr '\0' '\n' || true)
|
||||
if [ -n "$MATCHES" ]; then
|
||||
echo "::error title=Ashby API key leaked into build output::$MATCHES"
|
||||
exit 1
|
||||
fi
|
||||
```
|
||||
|
||||
**`.github/workflows/ci-vercel-website-preview.yaml`** — add the
|
||||
two env vars to the top-level `env:` block so `vercel build` (both
|
||||
`deploy-preview` and `deploy-production` jobs) sees them:
|
||||
|
||||
```yaml
|
||||
env:
|
||||
VERCEL_ORG_ID: ${{ secrets.VERCEL_WEBSITE_ORG_ID }}
|
||||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_WEBSITE_PROJECT_ID }}
|
||||
VERCEL_TOKEN: ${{ secrets.VERCEL_WEBSITE_TOKEN }}
|
||||
VERCEL_SCOPE: comfyui
|
||||
WEBSITE_ASHBY_API_KEY: ${{ secrets.WEBSITE_ASHBY_API_KEY }}
|
||||
WEBSITE_ASHBY_JOB_BOARD_NAME: ${{ vars.WEBSITE_ASHBY_JOB_BOARD_NAME || 'comfy-org' }}
|
||||
```
|
||||
|
||||
The secret must also be added to the Vercel project environment
|
||||
(`vercel env add WEBSITE_ASHBY_API_KEY …` or via the Vercel UI) so
|
||||
that `vercel build` in the preview job has access to it.
|
||||
|
||||
Fork PRs do not exercise this path: `ci-vercel-website-preview.yaml`
|
||||
receives an empty `VERCEL_TOKEN` for forks and fails at `vercel pull`
|
||||
before the build runs. Fork-safe PR interactions (the preview-URL
|
||||
comment) are handled by `pr-vercel-website-preview.yaml`.
|
||||
|
||||
### Refreshing the snapshot
|
||||
|
||||
When a maintainer wants to update the committed snapshot (e.g. after
|
||||
onboarding/offboarding roles):
|
||||
|
||||
```bash
|
||||
WEBSITE_ASHBY_API_KEY=… WEBSITE_ASHBY_JOB_BOARD_NAME=comfy-org \
|
||||
pnpm --filter @comfyorg/website ashby:refresh-snapshot
|
||||
git commit apps/website/src/data/ashby-roles.snapshot.json
|
||||
```
|
||||
|
||||
The script exits non-zero on any non-fresh outcome so stale/empty
|
||||
snapshots can't be accidentally committed.
|
||||
|
||||
## Scripts
|
||||
|
||||
- `pnpm dev` — Astro dev server
|
||||
- `pnpm build` — production build to `dist/`
|
||||
- `pnpm typecheck` — `astro check`
|
||||
- `pnpm test:unit` — Vitest unit tests
|
||||
- `pnpm test:e2e` — Playwright E2E tests (requires `pnpm build` first)
|
||||
- `pnpm ashby:refresh-snapshot` — refresh the committed careers snapshot
|
||||
@@ -7,12 +7,6 @@ export default defineConfig({
|
||||
site: 'https://comfy.org',
|
||||
output: 'static',
|
||||
prefetch: { prefetchAll: true },
|
||||
redirects: {
|
||||
'/cloud/enterprise-case-studies/comfyui-at-architectural-scale-how-moment-factory-reimagined-3d-projection-mapping':
|
||||
'/customers/moment-factory/',
|
||||
'/cloud/enterprise-case-studies/how-series-entertainment-rebuilt-game-and-video-production-with-comfyui':
|
||||
'/customers/series-entertainment/'
|
||||
},
|
||||
build: {
|
||||
assets: '_website'
|
||||
},
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
import { expect } from '@playwright/test'
|
||||
|
||||
import { test } from './fixtures/blockExternalMedia'
|
||||
|
||||
test.describe('Careers page @smoke', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/careers')
|
||||
})
|
||||
|
||||
test('has correct title', async ({ page }) => {
|
||||
await expect(page).toHaveTitle('Careers — Comfy')
|
||||
})
|
||||
|
||||
test('Roles section heading is visible', async ({ page }) => {
|
||||
await expect(
|
||||
page.getByRole('heading', { name: 'Roles', level: 2 })
|
||||
).toBeVisible()
|
||||
})
|
||||
|
||||
test('renders at least one role from the snapshot', async ({ page }) => {
|
||||
const roles = page.getByTestId('careers-role-link')
|
||||
await expect(roles.first()).toBeVisible()
|
||||
expect(await roles.count()).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
test('each role links to jobs.ashbyhq.com', async ({ page }) => {
|
||||
const roles = page.getByTestId('careers-role-link')
|
||||
const count = await roles.count()
|
||||
for (let i = 0; i < count; i++) {
|
||||
const href = await roles.nth(i).getAttribute('href')
|
||||
expect(href).toMatch(/^https:\/\/jobs\.ashbyhq\.com\//)
|
||||
}
|
||||
})
|
||||
|
||||
test('ENGINEERING category filter narrows the role list', async ({
|
||||
page
|
||||
}) => {
|
||||
const allCount = await page.getByTestId('careers-role-link').count()
|
||||
await page.getByRole('button', { name: 'ENGINEERING', exact: true }).click()
|
||||
const engineeringLocator = page.getByTestId('careers-role-link')
|
||||
await expect(engineeringLocator.first()).toBeVisible()
|
||||
const engineeringCount = await engineeringLocator.count()
|
||||
expect(engineeringCount).toBeLessThanOrEqual(allCount)
|
||||
expect(engineeringCount).toBeGreaterThan(0)
|
||||
})
|
||||
})
|
||||
|
||||
test.describe('Careers page (zh-CN) @smoke', () => {
|
||||
test('renders localized heading and roles', async ({ page }) => {
|
||||
await page.goto('/zh-CN/careers')
|
||||
await expect(page).toHaveTitle('招聘 — Comfy')
|
||||
await expect(
|
||||
page.getByRole('heading', { name: '职位', level: 2 })
|
||||
).toBeVisible()
|
||||
await expect(page.getByTestId('careers-role-link').first()).toBeVisible()
|
||||
})
|
||||
})
|
||||
@@ -9,13 +9,10 @@
|
||||
"build": "astro build",
|
||||
"preview": "astro preview",
|
||||
"typecheck": "astro check",
|
||||
"test:unit": "vitest run",
|
||||
"test:coverage": "vitest run --coverage",
|
||||
"test:e2e": "playwright test",
|
||||
"test:e2e:local": "cross-env PLAYWRIGHT_LOCAL=1 playwright test",
|
||||
"test:visual": "playwright test --project visual",
|
||||
"test:visual:update": "playwright test --project visual --update-snapshots",
|
||||
"ashby:refresh-snapshot": "tsx ./scripts/refresh-ashby-snapshot.ts"
|
||||
"test:visual:update": "playwright test --project visual --update-snapshots"
|
||||
},
|
||||
"dependencies": {
|
||||
"@astrojs/sitemap": "catalog:",
|
||||
@@ -26,8 +23,7 @@
|
||||
"cva": "catalog:",
|
||||
"gsap": "catalog:",
|
||||
"lenis": "catalog:",
|
||||
"vue": "catalog:",
|
||||
"zod": "catalog:"
|
||||
"vue": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@astrojs/check": "catalog:",
|
||||
@@ -36,9 +32,7 @@
|
||||
"@tailwindcss/vite": "catalog:",
|
||||
"astro": "catalog:",
|
||||
"tailwindcss": "catalog:",
|
||||
"tsx": "catalog:",
|
||||
"typescript": "catalog:",
|
||||
"vitest": "catalog:"
|
||||
"typescript": "catalog:"
|
||||
},
|
||||
"nx": {
|
||||
"tags": [
|
||||
@@ -95,22 +89,6 @@
|
||||
"command": "astro check"
|
||||
}
|
||||
},
|
||||
"test:unit": {
|
||||
"executor": "nx:run-commands",
|
||||
"cache": true,
|
||||
"options": {
|
||||
"cwd": "apps/website",
|
||||
"command": "vitest run"
|
||||
}
|
||||
},
|
||||
"test:coverage": {
|
||||
"executor": "nx:run-commands",
|
||||
"cache": true,
|
||||
"options": {
|
||||
"cwd": "apps/website",
|
||||
"command": "vitest run --coverage"
|
||||
}
|
||||
},
|
||||
"test:e2e": {
|
||||
"executor": "nx:run-commands",
|
||||
"dependsOn": [
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
import { renameSync, writeFileSync } from 'node:fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
import { fetchRolesForBuild } from '../src/utils/ashby'
|
||||
|
||||
const snapshotPath = fileURLToPath(
|
||||
new URL('../src/data/ashby-roles.snapshot.json', import.meta.url)
|
||||
)
|
||||
const tempPath = `${snapshotPath}.tmp`
|
||||
|
||||
const outcome = await fetchRolesForBuild()
|
||||
|
||||
if (outcome.status !== 'fresh') {
|
||||
const reason = 'reason' in outcome ? outcome.reason : '(none)'
|
||||
console.error(
|
||||
`Snapshot refresh aborted. Outcome: ${outcome.status}; reason: ${reason}`
|
||||
)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
writeFileSync(
|
||||
tempPath,
|
||||
JSON.stringify(outcome.snapshot, null, 2) + '\n',
|
||||
'utf8'
|
||||
)
|
||||
renameSync(tempPath, snapshotPath)
|
||||
const totalRoles = outcome.snapshot.departments.reduce(
|
||||
(n, d) => n + d.roles.length,
|
||||
0
|
||||
)
|
||||
process.stdout.write(
|
||||
`Wrote snapshot with ${totalRoles} role(s) to ${snapshotPath}\n`
|
||||
)
|
||||
@@ -1,104 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import type { Locale } from '../../i18n/translations'
|
||||
|
||||
import { t } from '../../i18n/translations'
|
||||
|
||||
const { locale = 'en' } = defineProps<{ locale?: Locale }>()
|
||||
|
||||
const investors = [
|
||||
{ name: 'CRAFT', icon: '/icons/investors/craft.svg' },
|
||||
{ name: 'PACE CAPITAL', icon: '/icons/investors/pace-capital.svg' },
|
||||
{ name: 'chemistry_', icon: '/icons/investors/chemistry.svg' },
|
||||
{ name: 'ABSTRACT', icon: '/icons/investors/abstract.svg' },
|
||||
{ name: 'TRUARROW PARTNERS', icon: '/icons/investors/truarrow-partners.svg' },
|
||||
{ name: 'ESSENCE', icon: '/icons/investors/essence.svg' }
|
||||
]
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="px-6 py-24 lg:px-20 lg:py-32">
|
||||
<div class="mx-auto text-center">
|
||||
<span
|
||||
class="text-primary-comfy-yellow text-xs font-semibold tracking-widest uppercase"
|
||||
>
|
||||
{{ t('about.story.label', locale) }}
|
||||
</span>
|
||||
<h2
|
||||
class="text-primary-comfy-canvas mt-6 text-3xl font-light lg:text-5xl"
|
||||
>
|
||||
{{ t('about.story.headingBefore', locale)
|
||||
}}<span class="text-primary-comfy-yellow">{{
|
||||
t('about.story.headingHighlight', locale)
|
||||
}}</span
|
||||
>{{ t('about.story.headingAfter', locale) }}
|
||||
</h2>
|
||||
<p class="text-primary-warm-white mt-8 text-base/relaxed lg:text-lg">
|
||||
{{ t('about.story.body', locale) }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Investor card -->
|
||||
<div
|
||||
class="mx-auto mt-16 max-w-5xl rounded-4xl border border-white/10 bg-black/30 p-8 lg:p-12"
|
||||
>
|
||||
<div class="inline-flex items-center">
|
||||
<!-- OUR badge (shorter) -->
|
||||
<div class="relative z-10 flex h-9 items-center">
|
||||
<img src="/icons/node-left.svg" alt="" class="h-full w-auto" />
|
||||
<span
|
||||
class="bg-primary-comfy-yellow text-primary-comfy-ink flex h-full items-center px-2 text-sm font-bold tracking-wider"
|
||||
>
|
||||
OUR
|
||||
</span>
|
||||
</div>
|
||||
<!-- Union connector (overlaps both badges to eliminate seams) -->
|
||||
<img
|
||||
src="/icons/node-union-2size-reverse.svg"
|
||||
alt=""
|
||||
class="relative z-20 -mx-px h-12 w-auto"
|
||||
/>
|
||||
<!-- INVESTORS badge (taller) -->
|
||||
<div class="relative z-10 flex h-12 items-center">
|
||||
<span
|
||||
class="bg-primary-comfy-yellow text-primary-comfy-ink flex h-full items-center px-3 text-lg font-bold tracking-wider"
|
||||
>
|
||||
INVESTORS
|
||||
</span>
|
||||
<img src="/icons/node-right.svg" alt="" class="h-full w-auto" />
|
||||
</div>
|
||||
</div>
|
||||
<p
|
||||
class="text-primary-warm-white mt-6 max-w-3xl text-sm/relaxed lg:text-base"
|
||||
>
|
||||
{{ t('about.story.investorsBody', locale) }}
|
||||
</p>
|
||||
<div class="mt-10 grid grid-cols-2 gap-4 sm:grid-cols-3 lg:gap-6">
|
||||
<div
|
||||
v-for="investor in investors"
|
||||
:key="investor.name"
|
||||
class="flex h-16 items-center justify-center rounded-xl border border-white/10 bg-white/5 px-4"
|
||||
>
|
||||
<img
|
||||
:src="investor.icon"
|
||||
:alt="investor.name"
|
||||
class="max-h-8 w-auto"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Quote card -->
|
||||
<div
|
||||
class="bg-primary-comfy-yellow mx-auto mt-12 max-w-5xl rounded-4xl p-10 lg:p-16"
|
||||
>
|
||||
<p class="text-primary-comfy-ink text-xl/relaxed font-medium lg:text-3xl">
|
||||
{{ t('about.quote.text', locale) }}
|
||||
</p>
|
||||
<p
|
||||
class="text-primary-comfy-ink/70 mt-8 text-sm font-semibold lg:text-base"
|
||||
>
|
||||
{{ t('about.quote.attribution', locale) }}
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -1,42 +1,121 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import type { Department } from '../../data/roles'
|
||||
import type { Locale } from '../../i18n/translations'
|
||||
|
||||
import { t } from '../../i18n/translations'
|
||||
import CategoryNav from '../common/CategoryNav.vue'
|
||||
import SectionLabel from '../common/SectionLabel.vue'
|
||||
|
||||
const { locale = 'en', departments = [] } = defineProps<{
|
||||
locale?: Locale
|
||||
departments?: readonly Department[]
|
||||
}>()
|
||||
const { locale = 'en' } = defineProps<{ locale?: Locale }>()
|
||||
|
||||
const activeCategory = ref('all')
|
||||
|
||||
const visibleDepartments = computed(() =>
|
||||
departments.filter((d) => d.roles.length > 0)
|
||||
)
|
||||
interface Role {
|
||||
title: string
|
||||
department: string
|
||||
location: string
|
||||
id: string
|
||||
}
|
||||
|
||||
interface Department {
|
||||
name: string
|
||||
key: string
|
||||
roles: Role[]
|
||||
}
|
||||
|
||||
const departments: Department[] = [
|
||||
{
|
||||
name: 'ENGINEERING',
|
||||
key: 'engineering',
|
||||
roles: [
|
||||
{
|
||||
title: 'Design Engineer',
|
||||
department: 'Engineering',
|
||||
location: 'San Francisco',
|
||||
id: 'abc787b9-ad85-421c-8218-debd23bea096'
|
||||
},
|
||||
{
|
||||
title: 'Software Engineer',
|
||||
department: 'Engineering',
|
||||
location: 'San Francisco',
|
||||
id: '99dc26c7-51ca-43cd-a1ba-7d475a0f4a40'
|
||||
},
|
||||
{
|
||||
title: 'Product Manager',
|
||||
department: 'Engineering',
|
||||
location: 'London, UK',
|
||||
id: '12dbc26e-9f6d-49bf-83c6-130f7566d03c'
|
||||
},
|
||||
{
|
||||
title: 'Tech Lead Manager, Frontend',
|
||||
department: 'Engineering',
|
||||
location: 'San Francisco',
|
||||
id: 'a0665088-3314-457a-aa7b-12ca5c3eb261'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'DESIGN',
|
||||
key: 'design',
|
||||
roles: [
|
||||
{
|
||||
title: 'Creative Director',
|
||||
department: 'Design',
|
||||
location: 'San Francisco',
|
||||
id: '49fa0b07-3fa1-4a3a-b2c6-d2cc684ad63f'
|
||||
},
|
||||
{
|
||||
title: 'Graphic Designer',
|
||||
department: 'Design',
|
||||
location: 'London, UK',
|
||||
id: '19ba10aa-4961-45e8-8473-66a8a7a8079d'
|
||||
},
|
||||
{
|
||||
title: 'Freelance Motion Designer',
|
||||
department: 'Design',
|
||||
location: 'Remote',
|
||||
id: 'a7ccc2b4-4d9d-4e04-b39c-28a711995b5b'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'MARKETING',
|
||||
key: 'marketing',
|
||||
roles: [
|
||||
{
|
||||
title: 'Lifecycle Growth Marketer',
|
||||
department: 'Marketing',
|
||||
location: 'San Francisco',
|
||||
id: 'be74d210-3b50-408c-9f61-8fee8833ce64'
|
||||
},
|
||||
{
|
||||
title: 'Graphic Designer',
|
||||
department: 'Marketing',
|
||||
location: 'London, UK',
|
||||
id: '28dea965-662b-4786-b024-c9a1b6bc1f23'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
const categories = computed(() => [
|
||||
{ label: 'ALL', value: 'all' },
|
||||
...visibleDepartments.value.map((d) => ({ label: d.name, value: d.key }))
|
||||
...departments.map((d) => ({ label: d.name, value: d.key }))
|
||||
])
|
||||
|
||||
const filteredDepartments = computed(() =>
|
||||
activeCategory.value === 'all'
|
||||
? visibleDepartments.value
|
||||
: visibleDepartments.value.filter((d) => d.key === activeCategory.value)
|
||||
? departments
|
||||
: departments.filter((d) => d.key === activeCategory.value)
|
||||
)
|
||||
|
||||
const hasRoles = computed(() => visibleDepartments.value.length > 0)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="px-6 py-20 md:px-20 md:py-32" data-testid="careers-roles">
|
||||
<section class="px-6 py-20 md:px-20 md:py-32">
|
||||
<div class="mx-auto max-w-6xl">
|
||||
<div class="flex flex-col gap-12 md:flex-row md:gap-20">
|
||||
<!-- Left sidebar -->
|
||||
<div class="shrink-0 md:w-48">
|
||||
<div
|
||||
class="bg-primary-comfy-ink sticky top-20 z-10 py-4 md:top-28 md:py-0"
|
||||
@@ -47,7 +126,6 @@ const hasRoles = computed(() => visibleDepartments.value.length > 0)
|
||||
{{ t('careers.roles.heading', locale) }}
|
||||
</h2>
|
||||
<CategoryNav
|
||||
v-if="hasRoles"
|
||||
v-model="activeCategory"
|
||||
:categories="categories"
|
||||
class="mt-4"
|
||||
@@ -55,15 +133,8 @@ const hasRoles = computed(() => visibleDepartments.value.length > 0)
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Role listings -->
|
||||
<div class="min-w-0 flex-1">
|
||||
<p
|
||||
v-if="!hasRoles"
|
||||
class="text-primary-warm-gray text-base md:text-lg"
|
||||
data-testid="careers-roles-empty"
|
||||
>
|
||||
{{ t('careers.roles.empty', locale) }}
|
||||
</p>
|
||||
|
||||
<div
|
||||
v-for="dept in filteredDepartments"
|
||||
:key="dept.key"
|
||||
@@ -76,11 +147,10 @@ const hasRoles = computed(() => visibleDepartments.value.length > 0)
|
||||
<a
|
||||
v-for="role in dept.roles"
|
||||
:key="role.id"
|
||||
:href="role.applyUrl"
|
||||
:href="`https://jobs.ashbyhq.com/comfy-org/${role.id}`"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="border-primary-warm-gray/20 group flex items-center justify-between border-b py-5"
|
||||
data-testid="careers-role-link"
|
||||
>
|
||||
<div class="min-w-0">
|
||||
<span
|
||||
|
||||
@@ -223,7 +223,7 @@ onUnmounted(() => {
|
||||
|
||||
<div class="mt-8 flex flex-col gap-4 lg:flex-row">
|
||||
<BrandButton
|
||||
:href="externalLinks.apiKeys"
|
||||
:href="externalLinks.platform"
|
||||
size="lg"
|
||||
class="text-center lg:min-w-60 lg:p-4"
|
||||
>
|
||||
|
||||
@@ -13,13 +13,13 @@ const steps = [
|
||||
number: '01',
|
||||
titleKey: 'api.steps.step1.title' as const,
|
||||
descriptionKey: 'api.steps.step1.description' as const,
|
||||
image: 'https://media.comfy.org/website/enterprise/enterprise_node_1.webp'
|
||||
image: 'https://media.comfy.org/website/api/logo-purple.webp'
|
||||
},
|
||||
{
|
||||
number: '02',
|
||||
titleKey: 'api.steps.step2.title' as const,
|
||||
descriptionKey: 'api.steps.step2.description' as const,
|
||||
image: 'https://media.comfy.org/website/enterprise/enterprise_node_2.webp'
|
||||
image: 'https://media.comfy.org/website/api/logo-yellow.webp'
|
||||
},
|
||||
{
|
||||
number: '03',
|
||||
@@ -61,7 +61,7 @@ const steps = [
|
||||
class="mt-12 flex flex-col items-center gap-4 lg:flex-row lg:justify-center"
|
||||
>
|
||||
<BrandButton
|
||||
:href="externalLinks.apiKeys"
|
||||
:href="externalLinks.cloud"
|
||||
variant="solid"
|
||||
size="lg"
|
||||
class="w-full text-center lg:w-auto lg:min-w-48"
|
||||
@@ -69,7 +69,7 @@ const steps = [
|
||||
{{ t('api.hero.getApiKeys', locale) }}
|
||||
</BrandButton>
|
||||
<BrandButton
|
||||
:href="externalLinks.docsApi"
|
||||
:href="externalLinks.docs"
|
||||
variant="outline"
|
||||
size="lg"
|
||||
class="w-full text-center lg:w-auto lg:min-w-48"
|
||||
|
||||
@@ -10,12 +10,12 @@ const cards = [
|
||||
{
|
||||
titleKey: 'enterprise.byoKey.card1.title' as const,
|
||||
descriptionKey: 'enterprise.byoKey.card1.description' as const,
|
||||
image: 'https://media.comfy.org/website/enterprise/enterprise_node_1.webp'
|
||||
image: 'https://media.comfy.org/website/api/logo-purple.webp'
|
||||
},
|
||||
{
|
||||
titleKey: 'enterprise.byoKey.card2.title' as const,
|
||||
descriptionKey: 'enterprise.byoKey.card2.description' as const,
|
||||
image: 'https://media.comfy.org/website/enterprise/enterprise_node_2.webp'
|
||||
image: 'https://media.comfy.org/website/api/logo-yellow.webp'
|
||||
}
|
||||
]
|
||||
</script>
|
||||
|
||||
@@ -16,11 +16,9 @@ const midRightRef = ref<HTMLElement>()
|
||||
const bottomLeftRef = ref<HTMLElement>()
|
||||
const bottomRightRef = ref<HTMLElement>()
|
||||
|
||||
const parallaxOpts = { trigger: sectionRef, mediaQuery: '(min-width: 1024px)' }
|
||||
|
||||
useParallax([topLeftRef, topRightRef], { ...parallaxOpts, y: 200 })
|
||||
useParallax([midLeftRef, midRightRef], { ...parallaxOpts, y: 300 })
|
||||
useParallax([bottomLeftRef, bottomRightRef], { ...parallaxOpts, y: 400 })
|
||||
useParallax([topLeftRef, topRightRef], { trigger: sectionRef, y: 200 })
|
||||
useParallax([midLeftRef, midRightRef], { trigger: sectionRef, y: 300 })
|
||||
useParallax([bottomLeftRef, bottomRightRef], { trigger: sectionRef, y: 400 })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -44,303 +44,162 @@ onMounted(() => {
|
||||
<svg
|
||||
ref="svgRef"
|
||||
class="block size-full"
|
||||
viewBox="0 0 1600 1046"
|
||||
viewBox="600 -50 1000 1100"
|
||||
fill="none"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<g clip-path="url(#enterpriseHeroClip)">
|
||||
<rect width="1600" height="1046" fill="#211927" />
|
||||
<rect
|
||||
width="800"
|
||||
height="800"
|
||||
transform="translate(712 112)"
|
||||
fill="#211927"
|
||||
/>
|
||||
<!-- Ripple rings -->
|
||||
<path
|
||||
class="ripple-path"
|
||||
d="M862.278 684.584L1064.22 801.244C1091.06 816.752 1134.58 816.764 1161.41 801.27L1363.29 684.716C1380.29 674.902 1395.18 648.204 1395.17 628.577L1395.11 395.363C1395.1 364.36 1373.34 326.656 1346.49 311.148L1144.55 194.488C1127.56 184.67 1097 184.223 1080 194.037L878.12 310.591C851.283 326.085 829.535 363.778 829.543 394.78L829.604 627.993C829.61 647.659 845.248 674.747 862.278 684.584Z"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="ripple-path ripple-delay-1"
|
||||
d="M862.278 684.584L1064.22 801.244C1091.06 816.752 1134.58 816.764 1161.41 801.27L1363.29 684.716C1380.29 674.902 1395.18 648.204 1395.17 628.577L1395.11 395.363C1395.1 364.36 1373.34 326.656 1346.49 311.148L1144.55 194.488C1127.56 184.67 1097 184.223 1080 194.037L878.12 310.591C851.283 326.085 829.535 363.778 829.543 394.78L829.604 627.993C829.61 647.659 845.248 674.747 862.278 684.584Z"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="ripple-path ripple-delay-2"
|
||||
d="M862.278 684.584L1064.22 801.244C1091.06 816.752 1134.58 816.764 1161.41 801.27L1363.29 684.716C1380.29 674.902 1395.18 648.204 1395.17 628.577L1395.11 395.363C1395.1 364.36 1373.34 326.656 1346.49 311.148L1144.55 194.488C1127.56 184.67 1097 184.223 1080 194.037L878.12 310.591C851.283 326.085 829.535 363.778 829.543 394.78L829.604 627.993C829.61 647.659 845.248 674.747 862.278 684.584Z"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="ripple-path ripple-delay-3"
|
||||
d="M862.278 684.584L1064.22 801.244C1091.06 816.752 1134.58 816.764 1161.41 801.27L1363.29 684.716C1380.29 674.902 1395.18 648.204 1395.17 628.577L1395.11 395.363C1395.1 364.36 1373.34 326.656 1346.49 311.148L1144.55 194.488C1127.56 184.67 1097 184.223 1080 194.037L878.12 310.591C851.283 326.085 829.535 363.778 829.543 394.78L829.604 627.993C829.61 647.659 845.248 674.747 862.278 684.584Z"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
|
||||
<!-- Ripple rings -->
|
||||
<!-- Exploding block cluster -->
|
||||
<g stroke="#4D3762" stroke-width="2">
|
||||
<path
|
||||
class="ripple-path"
|
||||
d="M862.278 684.584L1064.22 801.244C1091.06 816.752 1134.58 816.764 1161.41 801.27L1363.29 684.716C1380.29 674.902 1395.18 648.204 1395.17 628.577L1395.11 395.363C1395.1 364.36 1373.34 326.656 1346.49 311.148L1144.55 194.488C1127.56 184.67 1097 184.223 1080 194.037L878.12 310.591C851.283 326.085 829.535 363.778 829.543 394.78L829.604 627.993C829.61 647.659 845.248 674.747 862.278 684.584Z"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
class="block-piece"
|
||||
d="M1018.44 635.715L1018.45 581.73C1018.46 574.554 1013.42 565.829 1007.21 562.242L960.479 535.262C956.544 532.99 949.469 533.096 945.535 535.368L898.79 562.373C892.576 565.963 887.537 574.691 887.535 581.867L887.52 635.852C887.519 640.395 890.967 646.574 894.902 648.845L941.632 675.825C947.845 679.412 957.918 679.409 964.132 675.819L1010.88 648.815C1014.82 646.538 1018.44 640.267 1018.44 635.715Z"
|
||||
fill="#37303F"
|
||||
/>
|
||||
<path
|
||||
class="ripple-path delay-1"
|
||||
d="M862.278 684.584L1064.22 801.244C1091.06 816.752 1134.58 816.764 1161.41 801.27L1363.29 684.716C1380.29 674.902 1395.18 648.204 1395.17 628.577L1395.11 395.363C1395.1 364.36 1373.34 326.656 1346.49 311.148L1144.55 194.488C1127.56 184.67 1097 184.223 1080 194.037L878.12 310.591C851.283 326.085 829.535 363.778 829.543 394.78L829.604 627.993C829.61 647.659 845.248 674.747 862.278 684.584Z"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
class="block-piece"
|
||||
d="M1098.58 681.434L1098.6 627.449C1098.6 620.273 1093.57 611.548 1087.35 607.961L1040.62 580.981C1036.69 578.709 1029.61 578.814 1025.68 581.087L978.934 608.092C972.72 611.682 967.681 620.409 967.679 627.586L967.665 681.57C967.664 686.114 971.111 692.292 975.046 694.564L1021.78 721.544C1027.99 725.131 1038.06 725.128 1044.28 721.538L1091.02 694.534C1094.96 692.256 1098.58 685.986 1098.58 681.434Z"
|
||||
fill="#251D2B"
|
||||
/>
|
||||
<path
|
||||
class="ripple-path delay-2"
|
||||
d="M862.278 684.584L1064.22 801.244C1091.06 816.752 1134.58 816.764 1161.41 801.27L1363.29 684.716C1380.29 674.902 1395.18 648.204 1395.17 628.577L1395.11 395.363C1395.1 364.36 1373.34 326.656 1346.49 311.148L1144.55 194.488C1127.56 184.67 1097 184.223 1080 194.037L878.12 310.591C851.283 326.085 829.535 363.778 829.543 394.78L829.604 627.993C829.61 647.659 845.248 674.747 862.278 684.584Z"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
class="block-piece"
|
||||
d="M1205.98 635.714L1205.97 581.73C1205.97 574.553 1211 565.828 1217.21 562.241L1263.94 535.261C1267.88 532.989 1274.95 533.095 1278.89 535.367L1325.63 562.372C1331.85 565.962 1336.89 574.69 1336.89 581.866L1336.9 635.851C1336.9 640.394 1333.46 646.573 1329.52 648.844L1282.79 675.824C1276.58 679.411 1266.5 679.408 1260.29 675.818L1213.54 648.814C1209.6 646.537 1205.98 640.266 1205.98 635.714Z"
|
||||
fill="#37303F"
|
||||
/>
|
||||
<path
|
||||
class="ripple-path delay-3"
|
||||
d="M862.278 684.584L1064.22 801.244C1091.06 816.752 1134.58 816.764 1161.41 801.27L1363.29 684.716C1380.29 674.902 1395.18 648.204 1395.17 628.577L1395.11 395.363C1395.1 364.36 1373.34 326.656 1346.49 311.148L1144.55 194.488C1127.56 184.67 1097 184.223 1080 194.037L878.12 310.591C851.283 326.085 829.535 363.778 829.543 394.78L829.604 627.993C829.61 647.659 845.248 674.747 862.278 684.584Z"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
class="block-piece"
|
||||
d="M1125.83 681.434L1125.81 627.45C1125.81 620.273 1130.84 611.548 1137.06 607.961L1183.79 580.981C1187.72 578.71 1194.8 578.815 1198.73 581.087L1245.48 608.092C1251.69 611.682 1256.73 620.41 1256.73 627.586L1256.75 681.571C1256.75 686.114 1253.3 692.293 1249.36 694.565L1202.63 721.545C1196.42 725.131 1186.35 725.128 1180.13 721.539L1133.39 694.534C1129.45 692.257 1125.83 685.987 1125.83 681.434Z"
|
||||
fill="#251D2B"
|
||||
/>
|
||||
|
||||
<!-- Exploding block cluster -->
|
||||
<g class="block-cluster">
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1018.44 635.715L1018.45 581.73C1018.46 574.554 1013.42 565.829 1007.21 562.242L960.479 535.262C956.544 532.99 949.469 533.096 945.535 535.368L898.79 562.373C892.576 565.963 887.537 574.691 887.535 581.867L887.52 635.852C887.519 640.395 890.967 646.574 894.902 648.845L941.632 675.825C947.845 679.412 957.918 679.409 964.132 675.819L1010.88 648.815C1014.82 646.538 1018.44 640.267 1018.44 635.715Z"
|
||||
fill="#37303F"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1098.58 681.434L1098.6 627.449C1098.6 620.273 1093.57 611.548 1087.35 607.961L1040.62 580.981C1036.69 578.709 1029.61 578.814 1025.68 581.087L978.934 608.092C972.72 611.682 967.681 620.409 967.679 627.586L967.665 681.57C967.664 686.114 971.111 692.292 975.046 694.564L1021.78 721.544C1027.99 725.131 1038.06 725.128 1044.28 721.538L1091.02 694.534C1094.96 692.256 1098.58 685.986 1098.58 681.434Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1205.98 635.714L1205.97 581.73C1205.97 574.553 1211 565.828 1217.21 562.241L1263.94 535.261C1267.88 532.989 1274.95 533.095 1278.89 535.367L1325.63 562.372C1331.85 565.962 1336.89 574.69 1336.89 581.866L1336.9 635.851C1336.9 640.394 1333.46 646.573 1329.52 648.844L1282.79 675.824C1276.58 679.411 1266.5 679.408 1260.29 675.818L1213.54 648.814C1209.6 646.537 1205.98 640.266 1205.98 635.714Z"
|
||||
fill="#37303F"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1125.83 681.434L1125.81 627.45C1125.81 620.273 1130.84 611.548 1137.06 607.961L1183.79 580.981C1187.72 578.71 1194.8 578.815 1198.73 581.087L1245.48 608.092C1251.69 611.682 1256.73 620.41 1256.73 627.586L1256.75 681.571C1256.75 686.114 1253.3 692.293 1249.36 694.565L1202.63 721.545C1196.42 725.131 1186.35 725.128 1180.13 721.539L1133.39 694.534C1129.45 692.257 1125.83 685.987 1125.83 681.434Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1045.67 726.53L1045.66 672.545C1045.65 665.369 1050.69 656.644 1056.9 653.057L1103.63 626.077C1107.57 623.805 1114.64 623.911 1118.57 626.183L1165.32 653.188C1171.53 656.778 1176.57 665.506 1176.57 672.682L1176.59 726.667C1176.59 731.21 1173.14 737.388 1169.21 739.66L1122.48 766.64C1116.26 770.227 1106.19 770.224 1099.98 766.634L1053.23 739.63C1049.29 737.353 1045.67 731.082 1045.67 726.53Z"
|
||||
fill="#37303F"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1175.17 536.369L1175.18 482.384C1175.19 475.208 1170.15 466.483 1163.94 462.896L1117.21 435.916C1113.27 433.644 1106.2 433.749 1102.27 436.022L1055.52 463.027C1049.31 466.617 1044.27 475.344 1044.27 482.521L1044.25 536.506C1044.25 541.049 1047.7 547.227 1051.63 549.499L1098.36 576.479C1104.58 580.066 1114.65 580.063 1120.86 576.473L1167.61 549.469C1171.55 547.191 1175.17 540.921 1175.17 536.369Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1052.83 458.666L1099.57 485.671C1105.79 489.261 1115.86 489.263 1122.07 485.677L1168.8 458.697C1172.74 456.425 1176.19 450.245 1176.18 445.702L1176.17 391.717C1176.17 384.54 1171.13 375.812 1164.92 372.223L1118.17 345.218C1114.24 342.945 1107.16 342.842 1103.23 345.114L1056.5 372.094C1050.28 375.68 1045.25 384.405 1045.25 391.582L1045.27 445.566C1045.27 450.119 1048.89 456.389 1052.83 458.666Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1247.76 420.64L1201.02 393.635C1194.81 390.045 1184.73 390.043 1178.52 393.629L1131.79 420.609C1127.85 422.881 1124.41 429.061 1124.41 433.604L1124.42 487.589C1124.43 494.766 1129.46 503.493 1135.68 507.083L1182.42 534.088C1186.36 536.361 1193.43 536.464 1197.37 534.192L1244.1 507.212C1250.31 503.626 1255.34 494.901 1255.34 487.724L1255.33 433.74C1255.33 429.187 1251.71 422.917 1247.76 420.64Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M975.833 420.641L1022.58 393.636C1028.79 390.047 1038.87 390.044 1045.08 393.63L1091.81 420.61C1095.74 422.882 1099.19 429.062 1099.19 433.606L1099.17 487.59C1099.17 494.767 1094.13 503.495 1087.92 507.085L1041.17 534.089C1037.24 536.362 1030.17 536.465 1026.23 534.194L979.501 507.214C973.288 503.627 968.254 494.902 968.256 487.725L968.27 433.741C968.271 429.188 971.891 422.918 975.833 420.641Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1018.03 536.368L1018.04 482.384C1018.04 475.207 1013.01 466.482 1006.8 462.895L960.065 435.915C956.13 433.644 949.055 433.749 945.121 436.021L898.376 463.026C892.162 466.616 887.123 475.344 887.121 482.52L887.106 536.505C887.105 541.048 890.553 547.227 894.488 549.499L941.218 576.479C947.431 580.065 957.504 580.062 963.718 576.473L1010.46 549.468C1014.4 547.191 1018.02 540.921 1018.03 536.368Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1018.03 536.368L1018.04 482.384C1018.04 475.207 1013.01 466.482 1006.8 462.895L960.065 435.915C956.13 433.644 949.055 433.749 945.121 436.021L898.376 463.026C892.162 466.616 887.123 475.344 887.121 482.52L887.106 536.505C887.105 541.048 890.553 547.227 894.488 549.499L941.218 576.479C947.431 580.065 957.504 580.062 963.718 576.473L1010.46 549.468C1014.4 547.191 1018.02 540.921 1018.03 536.368Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1175.17 536.369L1175.18 482.384C1175.19 475.208 1170.15 466.483 1163.94 462.896L1117.21 435.916C1113.27 433.644 1106.2 433.749 1102.27 436.022L1055.52 463.027C1049.31 466.617 1044.27 475.344 1044.27 482.521L1044.25 536.506C1044.25 541.049 1047.7 547.227 1051.63 549.499L1098.36 576.479C1104.58 580.066 1114.65 580.063 1120.86 576.473L1167.61 549.469C1171.55 547.191 1175.17 540.921 1175.17 536.369Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1175.17 536.369L1175.18 482.384C1175.19 475.208 1170.15 466.483 1163.94 462.896L1117.21 435.916C1113.27 433.644 1106.2 433.749 1102.27 436.022L1055.52 463.027C1049.31 466.617 1044.27 475.344 1044.27 482.521L1044.25 536.506C1044.25 541.049 1047.7 547.227 1051.63 549.499L1098.36 576.479C1104.58 580.066 1114.65 580.063 1120.86 576.473L1167.61 549.469C1171.55 547.191 1175.17 540.921 1175.17 536.369Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1098.18 582.085L1098.19 528.1C1098.19 520.924 1093.16 512.199 1086.95 508.612L1040.22 481.632C1036.28 479.36 1029.21 479.465 1025.27 481.738L978.528 508.743C972.314 512.333 967.275 521.061 967.273 528.237L967.259 582.222C967.257 586.765 970.705 592.943 974.64 595.215L1021.37 622.195C1027.58 625.782 1037.66 625.779 1043.87 622.189L1090.62 595.185C1094.56 592.907 1098.18 586.637 1098.18 582.085Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1098.18 582.085L1098.19 528.1C1098.19 520.924 1093.16 512.199 1086.95 508.612L1040.22 481.632C1036.28 479.36 1029.21 479.465 1025.27 481.738L978.528 508.743C972.314 512.333 967.275 521.061 967.273 528.237L967.259 582.222C967.257 586.765 970.705 592.943 974.64 595.215L1021.37 622.195C1027.58 625.782 1037.66 625.779 1043.87 622.189L1090.62 595.185C1094.56 592.907 1098.18 586.637 1098.18 582.085Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1205.57 536.367L1205.56 482.383C1205.56 475.206 1210.59 466.481 1216.8 462.894L1263.53 435.914C1267.47 433.643 1274.54 433.748 1278.48 436.02L1325.22 463.025C1331.44 466.615 1336.48 475.343 1336.48 482.519L1336.49 536.504C1336.49 541.047 1333.04 547.226 1329.11 549.497L1282.38 576.477C1276.17 580.064 1266.09 580.061 1259.88 576.471L1213.13 549.467C1209.19 547.19 1205.57 540.919 1205.57 536.367Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1205.57 536.367L1205.56 482.383C1205.56 475.206 1210.59 466.481 1216.8 462.894L1263.53 435.914C1267.47 433.643 1274.54 433.748 1278.48 436.02L1325.22 463.025C1331.44 466.615 1336.48 475.343 1336.48 482.519L1336.49 536.504C1336.49 541.047 1333.04 547.226 1329.11 549.497L1282.38 576.477C1276.17 580.064 1266.09 580.061 1259.88 576.471L1213.13 549.467C1209.19 547.19 1205.57 540.919 1205.57 536.367Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1125.42 582.085L1125.4 528.101C1125.4 520.924 1130.43 512.199 1136.65 508.613L1183.38 481.633C1187.31 479.361 1194.39 479.466 1198.32 481.739L1245.07 508.743C1251.28 512.333 1256.32 521.061 1256.32 528.238L1256.34 582.222C1256.34 586.766 1252.89 592.944 1248.95 595.216L1202.22 622.196C1196.01 625.782 1185.94 625.78 1179.72 622.19L1132.98 595.185C1129.04 592.908 1125.42 586.638 1125.42 582.085Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1125.42 582.085L1125.4 528.101C1125.4 520.924 1130.43 512.199 1136.65 508.613L1183.38 481.633C1187.31 479.361 1194.39 479.466 1198.32 481.739L1245.07 508.743C1251.28 512.333 1256.32 521.061 1256.32 528.238L1256.34 582.222C1256.34 586.766 1252.89 592.944 1248.95 595.216L1202.22 622.196C1196.01 625.782 1185.94 625.78 1179.72 622.19L1132.98 595.185C1129.04 592.908 1125.42 586.638 1125.42 582.085Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1045.26 627.181L1045.25 573.197C1045.24 566.02 1050.28 557.295 1056.49 553.709L1103.22 526.729C1107.16 524.457 1114.23 524.562 1118.16 526.835L1164.91 553.839C1171.12 557.429 1176.16 566.157 1176.16 573.333L1176.18 627.318C1176.18 631.862 1172.73 638.04 1168.8 640.312L1122.07 667.292C1115.85 670.878 1105.78 670.876 1099.57 667.286L1052.82 640.281C1048.88 638.004 1045.26 631.734 1045.26 627.181Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1045.26 627.181L1045.25 573.197C1045.24 566.02 1050.28 557.295 1056.49 553.709L1103.22 526.729C1107.16 524.457 1114.23 524.562 1118.16 526.835L1164.91 553.839C1171.12 557.429 1176.16 566.157 1176.16 573.333L1176.18 627.318C1176.18 631.862 1172.73 638.04 1168.8 640.312L1122.07 667.292C1115.85 670.878 1105.78 670.876 1099.57 667.286L1052.82 640.281C1048.88 638.004 1045.26 631.734 1045.26 627.181Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1175.17 536.372L1175.19 482.387C1175.19 475.211 1170.16 466.485 1163.94 462.899L1117.21 435.919C1113.28 433.647 1106.2 433.752 1102.27 436.025L1055.52 463.03C1049.31 466.62 1044.27 475.347 1044.27 482.524L1044.25 536.508C1044.25 541.052 1047.7 547.23 1051.64 549.502L1098.37 576.482C1104.58 580.069 1114.65 580.066 1120.87 576.476L1167.61 549.472C1171.55 547.194 1175.17 540.924 1175.17 536.372Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1098.18 582.085L1098.2 528.1C1098.2 520.924 1093.16 512.198 1086.95 508.612L1040.22 481.632C1036.29 479.36 1029.21 479.465 1025.28 481.738L978.532 508.743C972.318 512.333 967.279 521.06 967.277 528.237L967.263 582.221C967.261 586.765 970.709 592.943 974.644 595.215L1021.37 622.195C1027.59 625.782 1037.66 625.779 1043.87 622.189L1090.62 595.185C1094.56 592.907 1098.18 586.637 1098.18 582.085Z"
|
||||
fill="#F2FF59"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1125.42 582.085L1125.41 528.1C1125.4 520.924 1130.44 512.198 1136.65 508.612L1183.38 481.632C1187.32 479.36 1194.39 479.465 1198.32 481.738L1245.07 508.743C1251.28 512.333 1256.32 521.06 1256.32 528.237L1256.34 582.221C1256.34 586.765 1252.89 592.943 1248.96 595.215L1202.23 622.195C1196.01 625.782 1185.94 625.779 1179.73 622.189L1132.98 595.184C1129.04 592.907 1125.42 586.637 1125.42 582.085Z"
|
||||
fill="#F2FF59"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1045.26 627.173L1045.25 573.188C1045.25 566.012 1050.28 557.286 1056.49 553.7L1103.22 526.72C1107.16 524.448 1114.23 524.553 1118.17 526.826L1164.91 553.831C1171.13 557.42 1176.17 566.148 1176.17 573.325L1176.18 627.309C1176.18 631.853 1172.74 638.031 1168.8 640.303L1122.07 667.283C1115.86 670.87 1105.79 670.867 1099.57 667.277L1052.83 640.272C1048.88 637.995 1045.26 631.725 1045.26 627.173Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1175.17 445.81L1175.18 391.826C1175.18 384.649 1170.15 375.924 1163.94 372.337L1117.21 345.357C1113.27 343.086 1106.2 343.191 1102.26 345.464L1055.52 372.468C1049.3 376.058 1044.26 384.786 1044.26 391.962L1044.25 445.947C1044.25 450.49 1047.69 456.669 1051.63 458.941L1098.36 485.921C1104.57 489.507 1114.64 489.505 1120.86 485.915L1167.6 458.91C1171.55 456.633 1175.17 450.363 1175.17 445.81Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1052.82 368.108L1099.57 395.112C1105.78 398.702 1115.85 398.705 1122.07 395.118L1168.8 368.138C1172.73 365.866 1176.18 359.686 1176.18 355.143L1176.16 301.158C1176.16 293.982 1171.12 285.254 1164.91 281.664L1118.16 254.659C1114.23 252.387 1107.15 252.283 1103.22 254.555L1056.49 281.535C1050.28 285.122 1045.24 293.847 1045.24 301.023L1045.26 355.008C1045.26 359.56 1048.88 365.83 1052.82 368.108Z"
|
||||
fill="#37303F"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1247.76 330.081L1201.02 303.077C1194.81 299.487 1184.73 299.484 1178.52 303.071L1131.79 330.051C1127.85 332.322 1124.41 338.502 1124.41 343.046L1124.42 397.031C1124.43 404.207 1129.46 412.935 1135.67 416.525L1182.42 443.529C1186.35 445.802 1193.43 445.906 1197.36 443.634L1244.09 416.654C1250.31 413.067 1255.34 404.342 1255.34 397.166L1255.32 343.181C1255.32 338.629 1251.7 332.358 1247.76 330.081Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M975.826 330.082L1022.57 303.078C1028.78 299.488 1038.86 299.485 1045.07 303.072L1091.8 330.052C1095.74 332.323 1099.18 338.503 1099.18 343.047L1099.17 397.032C1099.16 404.208 1094.13 412.936 1087.91 416.526L1041.17 443.53C1037.23 445.803 1030.16 445.907 1026.22 443.635L979.493 416.655C973.281 413.068 968.246 404.343 968.248 397.167L968.262 343.182C968.263 338.630 971.884 332.359 975.826 330.082Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1018.02 445.809L1018.04 391.825C1018.04 384.649 1013 375.923 1006.79 372.337L960.061 345.357C956.126 343.085 949.051 343.19 945.117 345.463L898.372 372.468C892.158 376.057 887.119 384.785 887.117 391.962L887.103 445.946C887.101 450.49 890.549 456.668 894.484 458.94L941.215 485.92C947.427 489.507 957.5 489.504 963.714 485.914L1010.46 458.909C1014.4 456.632 1018.02 450.362 1018.02 445.809Z"
|
||||
fill="#37303F"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1175.17 445.81L1175.18 391.826C1175.18 384.649 1170.15 375.924 1163.94 372.337L1117.21 345.357C1113.27 343.086 1106.2 343.191 1102.26 345.464L1055.52 372.468C1049.3 376.058 1044.26 384.786 1044.26 391.962L1044.25 445.947C1044.25 450.49 1047.69 456.669 1051.63 458.941L1098.36 485.921C1104.57 489.507 1114.64 489.505 1120.86 485.915L1167.6 458.91C1171.55 456.633 1175.17 450.363 1175.17 445.81Z"
|
||||
fill="#F2FF59"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1098.17 491.528L1098.18 437.544C1098.19 430.367 1093.15 421.642 1086.94 418.056L1040.21 391.076C1036.27 388.804 1029.2 388.909 1025.27 391.182L978.52 418.186C972.306 421.776 967.267 430.504 967.265 437.681L967.251 491.665C967.25 496.209 970.697 502.387 974.632 504.659L1021.36 531.639C1027.58 535.225 1037.65 535.223 1043.86 531.633L1090.61 504.628C1094.55 502.351 1098.17 496.081 1098.17 491.528Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1205.57 445.809L1205.55 391.824C1205.55 384.648 1210.59 375.923 1216.8 372.336L1263.53 345.356C1267.46 343.084 1274.54 343.189 1278.47 345.462L1325.22 372.467C1331.43 376.057 1336.47 384.784 1336.47 391.961L1336.49 445.946C1336.49 450.489 1333.04 456.667 1329.11 458.939L1282.38 485.919C1276.16 489.506 1266.09 489.503 1259.88 485.913L1213.13 458.909C1209.19 456.631 1205.57 450.361 1205.57 445.809Z"
|
||||
fill="#37303F"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1125.41 491.529L1125.4 437.544C1125.4 430.368 1130.43 421.643 1136.64 418.056L1183.37 391.076C1187.31 388.804 1194.38 388.910 1198.32 391.182L1245.06 418.187C1251.28 421.777 1256.32 430.505 1256.32 437.681L1256.33 491.666C1256.33 496.209 1252.88 502.387 1248.95 504.659L1202.22 531.639C1196.01 535.226 1185.93 535.223 1179.72 531.633L1132.97 504.629C1129.03 502.352 1125.41 496.081 1125.41 491.529Z"
|
||||
fill="#251D2B"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1045.26 536.625L1045.24 482.64C1045.24 475.464 1050.27 466.738 1056.49 463.152L1103.22 436.172C1107.15 433.9 1114.23 434.005 1118.16 436.278L1164.91 463.283C1171.12 466.873 1176.16 475.6 1176.16 482.777L1176.17 536.761C1176.18 541.305 1172.73 547.483 1168.79 549.755L1122.06 576.735C1115.85 580.322 1105.78 580.319 1099.56 576.729L1052.82 549.725C1048.88 547.447 1045.26 541.177 1045.26 536.625Z"
|
||||
fill="#37303F"
|
||||
stroke="#4D3762"
|
||||
stroke-width="2"
|
||||
/>
|
||||
</g>
|
||||
|
||||
<!-- Left-edge fade -->
|
||||
<rect
|
||||
width="422.621"
|
||||
height="1125.11"
|
||||
transform="matrix(-1 0 0 1 909.219 9.26587)"
|
||||
fill="url(#enterpriseHeroFade)"
|
||||
style="pointer-events: none"
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1045.67 726.53L1045.66 672.545C1045.65 665.369 1050.69 656.644 1056.9 653.057L1103.63 626.077C1107.57 623.805 1114.64 623.911 1118.57 626.183L1165.32 653.188C1171.53 656.778 1176.57 665.506 1176.57 672.682L1176.59 726.667C1176.59 731.21 1173.14 737.388 1169.21 739.66L1122.48 766.64C1116.26 770.227 1106.19 770.224 1099.98 766.634L1053.23 739.63C1049.29 737.353 1045.67 731.082 1045.67 726.53Z"
|
||||
fill="#37303F"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1175.17 536.369L1175.18 482.384C1175.19 475.208 1170.15 466.483 1163.94 462.896L1117.21 435.916C1113.27 433.644 1106.2 433.749 1102.27 436.022L1055.52 463.027C1049.31 466.617 1044.27 475.344 1044.27 482.521L1044.25 536.506C1044.25 541.049 1047.7 547.227 1051.63 549.499L1098.36 576.479C1104.58 580.066 1114.65 580.063 1120.86 576.473L1167.61 549.469C1171.55 547.191 1175.17 540.921 1175.17 536.369Z"
|
||||
fill="#251D2B"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1052.83 458.666L1099.57 485.671C1105.79 489.261 1115.86 489.263 1122.07 485.677L1168.8 458.697C1172.74 456.425 1176.19 450.245 1176.18 445.702L1176.17 391.717C1176.17 384.54 1171.13 375.812 1164.92 372.223L1118.17 345.218C1114.24 342.945 1107.16 342.842 1103.23 345.114L1056.5 372.094C1050.28 375.68 1045.25 384.405 1045.25 391.582L1045.27 445.566C1045.27 450.119 1048.89 456.389 1052.83 458.666Z"
|
||||
fill="#251D2B"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1247.76 420.64L1201.02 393.635C1194.81 390.045 1184.73 390.043 1178.52 393.629L1131.79 420.609C1127.85 422.881 1124.41 429.061 1124.41 433.604L1124.42 487.589C1124.43 494.766 1129.46 503.493 1135.68 507.083L1182.42 534.088C1186.36 536.361 1193.43 536.464 1197.37 534.192L1244.1 507.212C1250.31 503.626 1255.34 494.901 1255.34 487.724L1255.33 433.74C1255.33 429.187 1251.71 422.917 1247.76 420.64Z"
|
||||
fill="#251D2B"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M975.833 420.641L1022.58 393.636C1028.79 390.047 1038.87 390.044 1045.08 393.63L1091.81 420.61C1095.74 422.882 1099.19 429.062 1099.19 433.606L1099.17 487.59C1099.17 494.767 1094.13 503.495 1087.92 507.085L1041.17 534.089C1037.24 536.362 1030.17 536.465 1026.23 534.194L979.501 507.214C973.288 503.627 968.254 494.902 968.256 487.725L968.27 433.741C968.271 429.188 971.891 422.918 975.833 420.641Z"
|
||||
fill="#251D2B"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1018.03 536.368L1018.04 482.384C1018.04 475.207 1013.01 466.482 1006.8 462.895L960.065 435.915C956.13 433.644 949.055 433.749 945.121 436.021L898.376 463.026C892.162 466.616 887.123 475.344 887.121 482.52L887.106 536.505C887.105 541.048 890.553 547.227 894.488 549.499L941.218 576.479C947.431 580.065 957.504 580.062 963.718 576.473L1010.46 549.468C1014.4 547.191 1018.02 540.921 1018.03 536.368Z"
|
||||
fill="#251D2B"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1098.18 582.085L1098.19 528.1C1098.19 520.924 1093.16 512.199 1086.95 508.612L1040.22 481.632C1036.28 479.36 1029.21 479.465 1025.27 481.738L978.528 508.743C972.314 512.333 967.275 521.061 967.273 528.237L967.259 582.222C967.257 586.765 970.705 592.943 974.64 595.215L1021.37 622.195C1027.58 625.782 1037.66 625.779 1043.87 622.189L1090.62 595.185C1094.56 592.907 1098.18 586.637 1098.18 582.085Z"
|
||||
fill="#F2FF59"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1125.42 582.085L1125.4 528.101C1125.4 520.924 1130.43 512.199 1136.65 508.613L1183.38 481.633C1187.31 479.361 1194.39 479.466 1198.32 481.739L1245.07 508.743C1251.28 512.333 1256.32 521.061 1256.32 528.238L1256.34 582.222C1256.34 586.766 1252.89 592.944 1248.95 595.216L1202.22 622.196C1196.01 625.782 1185.94 625.78 1179.72 622.19L1132.98 595.185C1129.04 592.908 1125.42 586.638 1125.42 582.085Z"
|
||||
fill="#F2FF59"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1205.57 536.367L1205.56 482.383C1205.56 475.206 1210.59 466.481 1216.8 462.894L1263.53 435.914C1267.47 433.643 1274.54 433.748 1278.48 436.02L1325.22 463.025C1331.44 466.615 1336.48 475.343 1336.48 482.519L1336.49 536.504C1336.49 541.047 1333.04 547.226 1329.11 549.497L1282.38 576.477C1276.17 580.064 1266.09 580.061 1259.88 576.471L1213.13 549.467C1209.19 547.19 1205.57 540.919 1205.57 536.367Z"
|
||||
fill="#251D2B"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1045.26 627.181L1045.25 573.197C1045.24 566.02 1050.28 557.295 1056.49 553.709L1103.22 526.729C1107.16 524.457 1114.23 524.562 1118.16 526.835L1164.91 553.839C1171.12 557.429 1176.16 566.157 1176.16 573.333L1176.18 627.318C1176.18 631.862 1172.73 638.04 1168.8 640.312L1122.07 667.292C1115.85 670.878 1105.78 670.876 1099.57 667.286L1052.82 640.281C1048.88 638.004 1045.26 631.734 1045.26 627.181Z"
|
||||
fill="#251D2B"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1175.17 445.81L1175.18 391.826C1175.18 384.649 1170.15 375.924 1163.94 372.337L1117.21 345.357C1113.27 343.086 1106.2 343.191 1102.26 345.464L1055.52 372.468C1049.3 376.058 1044.26 384.786 1044.26 391.962L1044.25 445.947C1044.25 450.49 1047.69 456.669 1051.63 458.941L1098.36 485.921C1104.57 489.507 1114.64 489.505 1120.86 485.915L1167.6 458.91C1171.55 456.633 1175.17 450.363 1175.17 445.81Z"
|
||||
fill="#F2FF59"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1098.17 491.528L1098.18 437.544C1098.19 430.367 1093.15 421.642 1086.94 418.056L1040.21 391.076C1036.27 388.804 1029.2 388.909 1025.27 391.182L978.52 418.186C972.306 421.776 967.267 430.504 967.265 437.681L967.251 491.665C967.25 496.209 970.697 502.387 974.632 504.659L1021.36 531.639C1027.58 535.225 1037.65 535.223 1043.86 531.633L1090.61 504.628C1094.55 502.351 1098.17 496.081 1098.17 491.528Z"
|
||||
fill="#251D2B"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1247.76 330.081L1201.02 303.077C1194.81 299.487 1184.73 299.484 1178.52 303.071L1131.79 330.051C1127.85 332.322 1124.41 338.502 1124.41 343.046L1124.42 397.031C1124.43 404.207 1129.46 412.935 1135.67 416.525L1182.42 443.529C1186.35 445.802 1193.43 445.906 1197.36 443.634L1244.09 416.654C1250.31 413.067 1255.34 404.342 1255.34 397.166L1255.32 343.181C1255.32 338.629 1251.7 332.358 1247.76 330.081Z"
|
||||
fill="#251D2B"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M975.826 330.082L1022.57 303.078C1028.78 299.488 1038.86 299.485 1045.07 303.072L1091.8 330.052C1095.74 332.323 1099.18 338.503 1099.18 343.047L1099.17 397.032C1099.16 404.208 1094.13 412.936 1087.91 416.526L1041.17 443.53C1037.23 445.803 1030.16 445.907 1026.22 443.635L979.493 416.655C973.281 413.068 968.246 404.343 968.248 397.167L968.262 343.182C968.263 338.63 971.884 332.359 975.826 330.082Z"
|
||||
fill="#251D2B"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1018.02 445.809L1018.04 391.825C1018.04 384.649 1013 375.923 1006.79 372.337L960.061 345.357C956.126 343.085 949.051 343.19 945.117 345.463L898.372 372.468C892.158 376.057 887.119 384.785 887.117 391.962L887.103 445.946C887.101 450.49 890.549 456.668 894.484 458.94L941.215 485.92C947.427 489.507 957.5 489.504 963.714 485.914L1010.46 458.909C1014.4 456.632 1018.02 450.362 1018.02 445.809Z"
|
||||
fill="#37303F"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1205.57 445.809L1205.55 391.824C1205.55 384.648 1210.59 375.923 1216.8 372.336L1263.53 345.356C1267.46 343.084 1274.54 343.189 1278.47 345.462L1325.22 372.467C1331.43 376.057 1336.47 384.784 1336.47 391.961L1336.49 445.946C1336.49 450.489 1333.04 456.667 1329.11 458.939L1282.38 485.919C1276.16 489.506 1266.09 489.503 1259.88 485.913L1213.13 458.909C1209.19 456.631 1205.57 450.361 1205.57 445.809Z"
|
||||
fill="#37303F"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1125.41 491.529L1125.4 437.544C1125.4 430.368 1130.43 421.643 1136.64 418.056L1183.37 391.076C1187.31 388.804 1194.38 388.91 1198.32 391.182L1245.06 418.187C1251.28 421.777 1256.32 430.505 1256.32 437.681L1256.33 491.666C1256.33 496.209 1252.88 502.387 1248.95 504.659L1202.22 531.639C1196.01 535.226 1185.93 535.223 1179.72 531.633L1132.97 504.629C1129.03 502.352 1125.41 496.081 1125.41 491.529Z"
|
||||
fill="#251D2B"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1045.26 536.625L1045.24 482.64C1045.24 475.464 1050.27 466.738 1056.49 463.152L1103.22 436.172C1107.15 433.9 1114.23 434.005 1118.16 436.278L1164.91 463.283C1171.12 466.873 1176.16 475.6 1176.16 482.777L1176.17 536.761C1176.18 541.305 1172.73 547.483 1168.79 549.755L1122.06 576.735C1115.85 580.322 1105.78 580.319 1099.56 576.729L1052.82 549.725C1048.88 547.447 1045.26 541.177 1045.26 536.625Z"
|
||||
fill="#37303F"
|
||||
/>
|
||||
<path
|
||||
class="block-piece"
|
||||
d="M1052.82 368.108L1099.57 395.112C1105.78 398.702 1115.85 398.705 1122.07 395.118L1168.8 368.138C1172.73 365.866 1176.18 359.686 1176.18 355.143L1176.16 301.158C1176.16 293.982 1171.12 285.254 1164.91 281.664L1118.16 254.659C1114.23 252.387 1107.15 252.283 1103.22 254.555L1056.49 281.535C1050.28 285.122 1045.24 293.847 1045.24 301.023L1045.26 355.008C1045.26 359.56 1048.88 365.83 1052.82 368.108Z"
|
||||
fill="#37303F"
|
||||
/>
|
||||
</g>
|
||||
|
||||
<!-- Left-edge fade -->
|
||||
<rect
|
||||
width="422.621"
|
||||
height="1125.11"
|
||||
transform="matrix(-1 0 0 1 909.219 9.26587)"
|
||||
fill="url(#enterpriseHeroFade)"
|
||||
/>
|
||||
<defs>
|
||||
<linearGradient
|
||||
id="enterpriseHeroFade"
|
||||
@@ -353,9 +212,6 @@ onMounted(() => {
|
||||
<stop stop-color="#211927" stop-opacity="0" />
|
||||
<stop offset="1" stop-color="#211927" />
|
||||
</linearGradient>
|
||||
<clipPath id="enterpriseHeroClip">
|
||||
<rect width="1600" height="1046" fill="white" />
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
</div>
|
||||
@@ -399,13 +255,13 @@ onMounted(() => {
|
||||
animation: ripple-effect 4s linear infinite;
|
||||
}
|
||||
|
||||
.delay-1 {
|
||||
.ripple-delay-1 {
|
||||
animation-delay: -1s;
|
||||
}
|
||||
.delay-2 {
|
||||
.ripple-delay-2 {
|
||||
animation-delay: -2s;
|
||||
}
|
||||
.delay-3 {
|
||||
.ripple-delay-3 {
|
||||
animation-delay: -3s;
|
||||
}
|
||||
|
||||
@@ -425,11 +281,6 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
.block-cluster {
|
||||
transform-origin: center;
|
||||
transform-box: fill-box;
|
||||
}
|
||||
|
||||
.block-piece {
|
||||
transform-origin: center;
|
||||
transform-box: fill-box;
|
||||
|
||||
@@ -19,8 +19,6 @@ interface ParallaxOptions {
|
||||
start?: string
|
||||
/** ScrollTrigger end value (default: 'bottom top') */
|
||||
end?: string
|
||||
/** Media query string — animation only runs when matched (responsive) */
|
||||
mediaQuery?: string
|
||||
}
|
||||
|
||||
export function useParallax(
|
||||
@@ -28,27 +26,24 @@ export function useParallax(
|
||||
options: ParallaxOptions = {}
|
||||
) {
|
||||
const { fromY = 0, y = 200 } = options
|
||||
let ctx: gsap.Context | gsap.MatchMedia | undefined
|
||||
let ctx: gsap.Context | undefined
|
||||
|
||||
onMounted(() => {
|
||||
if (prefersReducedMotion()) return
|
||||
|
||||
const triggerEl = options.trigger?.value
|
||||
const els = elements
|
||||
.map((r) => r.value)
|
||||
.filter((el): el is HTMLElement => !!el && el.offsetParent !== null)
|
||||
if (!els.length || prefersReducedMotion()) return
|
||||
|
||||
const createAnimations = () => {
|
||||
const els = elements
|
||||
.map((r) => r.value)
|
||||
.filter((el): el is HTMLElement => !!el && el.offsetParent !== null)
|
||||
if (!els.length) return
|
||||
|
||||
const trigger = triggerEl ?? els[0]
|
||||
const scrollTrigger = {
|
||||
trigger,
|
||||
start: options.start ?? 'top bottom',
|
||||
end: options.end ?? 'bottom top',
|
||||
scrub: 1
|
||||
}
|
||||
const trigger = triggerEl ?? els[0]
|
||||
const scrollTrigger = {
|
||||
trigger,
|
||||
start: options.start ?? 'top bottom',
|
||||
end: options.end ?? 'bottom top',
|
||||
scrub: 1
|
||||
}
|
||||
|
||||
ctx = gsap.context(() => {
|
||||
els.forEach((el) => {
|
||||
gsap.fromTo(
|
||||
el,
|
||||
@@ -56,15 +51,7 @@ export function useParallax(
|
||||
{ y: resolve(y, el, trigger), ease: 'none', scrollTrigger }
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
if (options.mediaQuery) {
|
||||
const mm = gsap.matchMedia()
|
||||
mm.add(options.mediaQuery, createAnimations)
|
||||
ctx = mm
|
||||
} else {
|
||||
ctx = gsap.context(createAnimations)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
|
||||
@@ -27,7 +27,6 @@ export function getRoutes(locale: Locale = 'en'): Routes {
|
||||
}
|
||||
|
||||
export const externalLinks = {
|
||||
apiKeys: 'https://platform.comfy.org/profile/api-keys',
|
||||
blog: 'https://blog.comfy.org/',
|
||||
cloud: 'https://cloud.comfy.org',
|
||||
discord: 'https://discord.com/invite/comfyorg',
|
||||
|
||||
@@ -1,169 +0,0 @@
|
||||
{
|
||||
"fetchedAt": "2026-04-24T18:59:03.989Z",
|
||||
"departments": [
|
||||
{
|
||||
"name": "DESIGN",
|
||||
"key": "design",
|
||||
"roles": [
|
||||
{
|
||||
"id": "4c5d6afb78652df7",
|
||||
"title": "Freelance Motion Designer",
|
||||
"department": "Design",
|
||||
"location": "San Francisco",
|
||||
"applyUrl": "https://jobs.ashbyhq.com/comfy-org/a7ccc2b4-4d9d-4e04-b39c-28a711995b5b/application"
|
||||
},
|
||||
{
|
||||
"id": "0f5256cf302e552b",
|
||||
"title": "Creative Artist",
|
||||
"department": "Design",
|
||||
"location": "San Francisco",
|
||||
"applyUrl": "https://jobs.ashbyhq.com/comfy-org/19ba10aa-4961-45e8-8473-66a8a7a8079d/application"
|
||||
},
|
||||
{
|
||||
"id": "e915f2c78b17f93b",
|
||||
"title": "Senior Product Designer",
|
||||
"department": "Design",
|
||||
"location": "San Francisco",
|
||||
"applyUrl": "https://jobs.ashbyhq.com/comfy-org/b2e864c6-4754-4e04-8f46-1022baa103c3/application"
|
||||
},
|
||||
{
|
||||
"id": "b9f9a23219be7cd4",
|
||||
"title": "Design Engineer",
|
||||
"department": "Design",
|
||||
"location": "San Francisco",
|
||||
"applyUrl": "https://jobs.ashbyhq.com/comfy-org/abc787b9-ad85-421c-8218-debd23bea096/application"
|
||||
},
|
||||
{
|
||||
"id": "5746486d87874937",
|
||||
"title": "Graphic Designer",
|
||||
"department": "Design",
|
||||
"location": "San Francisco",
|
||||
"applyUrl": "https://jobs.ashbyhq.com/comfy-org/49fa0b07-3fa1-4a3a-b2c6-d2cc684ad63f/application"
|
||||
},
|
||||
{
|
||||
"id": "547b6ba622c800a5",
|
||||
"title": "Senior Product Designer - Craft",
|
||||
"department": "Design",
|
||||
"location": "San Francisco",
|
||||
"applyUrl": "https://jobs.ashbyhq.com/comfy-org/a32c6769-b791-41f4-9225-50bbd8a1cf0f/application"
|
||||
},
|
||||
{
|
||||
"id": "7bb02634a24763bc",
|
||||
"title": "Staff Product Designer - Systems",
|
||||
"department": "Design",
|
||||
"location": "San Francisco",
|
||||
"applyUrl": "https://jobs.ashbyhq.com/comfy-org/0bc8356b-615e-4f40-b632-fd3b2691be34/application"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ENGINEERING",
|
||||
"key": "engineering",
|
||||
"roles": [
|
||||
{
|
||||
"id": "102d58e35a8a9817",
|
||||
"title": "Senior Software Engineer, Frontend",
|
||||
"department": "Engineering",
|
||||
"location": "San Francisco",
|
||||
"applyUrl": "https://jobs.ashbyhq.com/comfy-org/c3e0584d-5490-491f-aae4-b5922ef63fd2/application"
|
||||
},
|
||||
{
|
||||
"id": "d01d69fba7743905",
|
||||
"title": "Senior Software Engineer, Backend Generalist",
|
||||
"department": "Engineering",
|
||||
"location": "San Francisco",
|
||||
"applyUrl": "https://jobs.ashbyhq.com/comfy-org/732f8b39-076d-4847-afe3-f54d4451607e/application"
|
||||
},
|
||||
{
|
||||
"id": "f36f60cfd5bb5910",
|
||||
"title": "Senior/Staff Applied Machine Learning Engineer",
|
||||
"department": "Engineering",
|
||||
"location": "San Francisco",
|
||||
"applyUrl": "https://jobs.ashbyhq.com/comfy-org/5cc4d0bc-97b0-463b-8466-3ec1d07f6ac0/application"
|
||||
},
|
||||
{
|
||||
"id": "9d8ec4c65e20b19e",
|
||||
"title": "Software Engineer, Frontend",
|
||||
"department": "Engineering",
|
||||
"location": "Remote",
|
||||
"applyUrl": "https://jobs.ashbyhq.com/comfy-org/99dc26c7-51ca-43cd-a1ba-7d475a0f4a40/application"
|
||||
},
|
||||
{
|
||||
"id": "be94b193d1f4d482",
|
||||
"title": "Tech Lead Manager, Frontend",
|
||||
"department": "Engineering",
|
||||
"location": "San Francisco",
|
||||
"applyUrl": "https://jobs.ashbyhq.com/comfy-org/a0665088-3314-457a-aa7b-12ca5c3eb261/application"
|
||||
},
|
||||
{
|
||||
"id": "ab48f5db6bd1783c",
|
||||
"title": "Software Engineer, Core ComfyUI Contributor",
|
||||
"department": "Engineering",
|
||||
"location": "San Francisco",
|
||||
"applyUrl": "https://jobs.ashbyhq.com/comfy-org/7d4062d6-d500-445a-9a5f-014971af259f/application"
|
||||
},
|
||||
{
|
||||
"id": "c5dff4ee628bdcd1",
|
||||
"title": "Software Engineer, ComfyUI Desktop",
|
||||
"department": "Engineering",
|
||||
"location": "San Francisco",
|
||||
"applyUrl": "https://jobs.ashbyhq.com/comfy-org/ad2f76cb-a787-47d8-81c5-7e7f917747c0/application"
|
||||
},
|
||||
{
|
||||
"id": "4302a7aaa87e16e3",
|
||||
"title": "Product Manager, ComfyUI",
|
||||
"department": "Engineering",
|
||||
"location": "San Francisco",
|
||||
"applyUrl": "https://jobs.ashbyhq.com/comfy-org/9e4b9029-c3e9-436b-82c4-a1a9f1b8c16e/application"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MARKETING",
|
||||
"key": "marketing",
|
||||
"roles": [
|
||||
{
|
||||
"id": "b5803a0d4785d406",
|
||||
"title": "Lifecycle Growth Marketer",
|
||||
"department": "Marketing",
|
||||
"location": "San Francisco",
|
||||
"applyUrl": "https://jobs.ashbyhq.com/comfy-org/be74d210-3b50-408c-9f61-8fee8833ce64/application"
|
||||
},
|
||||
{
|
||||
"id": "130d7218d7895bdb",
|
||||
"title": "Partnership & Events Marketing Manager",
|
||||
"department": "Marketing",
|
||||
"location": "San Francisco",
|
||||
"applyUrl": "https://jobs.ashbyhq.com/comfy-org/89d3ff75-2055-4e92-9c69-81feff55627c/application"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "OPERATIONS",
|
||||
"key": "operations",
|
||||
"roles": [
|
||||
{
|
||||
"id": "ec68ae44dd5943c9",
|
||||
"title": "Senior Technical Recruiter",
|
||||
"department": "Operations",
|
||||
"location": "San Francisco",
|
||||
"applyUrl": "https://jobs.ashbyhq.com/comfy-org/d5008532-c45d-46e6-ba2c-20489d364362/application"
|
||||
},
|
||||
{
|
||||
"id": "16f556001ce1cef4",
|
||||
"title": "BizOps Strategist",
|
||||
"department": "Operations",
|
||||
"location": "San Francisco",
|
||||
"applyUrl": "https://jobs.ashbyhq.com/comfy-org/145b8558-0ab4-43e8-8fac-b59059cf2537/application"
|
||||
},
|
||||
{
|
||||
"id": "8e773a72c1b8e099",
|
||||
"title": "Founding Customer Success Manager",
|
||||
"department": "Operations",
|
||||
"location": "San Francisco",
|
||||
"applyUrl": "https://jobs.ashbyhq.com/comfy-org/a1c5c5ed-62ac-4767-af57-a3ba4e0bf5e4/application"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
export interface Role {
|
||||
id: string
|
||||
title: string
|
||||
department: string
|
||||
location: string
|
||||
applyUrl: string
|
||||
}
|
||||
|
||||
export interface Department {
|
||||
name: string
|
||||
key: string
|
||||
roles: Role[]
|
||||
}
|
||||
|
||||
export interface RolesSnapshot {
|
||||
fetchedAt: string
|
||||
departments: Department[]
|
||||
}
|
||||
@@ -1505,10 +1505,6 @@ const translations = {
|
||||
|
||||
// CareersRolesSection
|
||||
'careers.roles.heading': { en: 'Roles', 'zh-CN': '职位' },
|
||||
'careers.roles.empty': {
|
||||
en: 'No open roles right now. Check back soon.',
|
||||
'zh-CN': '目前暂无开放职位,请稍后再来查看。'
|
||||
},
|
||||
|
||||
// CareersFAQSection
|
||||
'careers.faq.heading': { en: 'Q&A', 'zh-CN': 'Q&A' },
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
---
|
||||
import BaseLayout from '../layouts/BaseLayout.astro'
|
||||
import HeroSection from '../components/about/HeroSection.vue'
|
||||
import StorySection from '../components/about/StorySection.vue'
|
||||
import OurValuesSection from '../components/about/OurValuesSection.vue'
|
||||
import ValuesSection from '../components/about/ValuesSection.vue'
|
||||
import CareersSection from '../components/about/CareersSection.vue'
|
||||
@@ -9,7 +8,6 @@ import CareersSection from '../components/about/CareersSection.vue'
|
||||
|
||||
<BaseLayout title="About Us — Comfy">
|
||||
<HeroSection client:load />
|
||||
<StorySection />
|
||||
<OurValuesSection />
|
||||
<ValuesSection client:visible />
|
||||
<CareersSection />
|
||||
|
||||
@@ -5,20 +5,6 @@ import RolesSection from '../components/careers/RolesSection.vue'
|
||||
import WhyJoinSection from '../components/careers/WhyJoinSection.vue'
|
||||
import TeamPhotosSection from '../components/careers/TeamPhotosSection.vue'
|
||||
import FAQSection from '../components/common/FAQSection.vue'
|
||||
import { fetchRolesForBuild } from '../utils/ashby'
|
||||
import { reportAshbyOutcome } from '../utils/ashby.ci'
|
||||
|
||||
const outcome = await fetchRolesForBuild()
|
||||
reportAshbyOutcome(outcome)
|
||||
|
||||
if (outcome.status === 'failed') {
|
||||
throw new Error(
|
||||
`Ashby fetch failed and no snapshot is available. Reason: ${outcome.reason}. ` +
|
||||
'Run `pnpm --filter @comfyorg/website ashby:refresh-snapshot` locally and commit the snapshot.'
|
||||
)
|
||||
}
|
||||
|
||||
const departments = outcome.snapshot.departments
|
||||
---
|
||||
|
||||
<BaseLayout
|
||||
@@ -26,7 +12,7 @@ const departments = outcome.snapshot.departments
|
||||
description="Join the team building the operating system for generative AI. Open roles in engineering, design, marketing, and more."
|
||||
>
|
||||
<HeroSection />
|
||||
<RolesSection departments={departments} client:visible />
|
||||
<RolesSection client:visible />
|
||||
<WhyJoinSection client:visible />
|
||||
<TeamPhotosSection client:visible />
|
||||
<FAQSection
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
---
|
||||
import BaseLayout from '../../layouts/BaseLayout.astro'
|
||||
import HeroSection from '../../components/about/HeroSection.vue'
|
||||
import StorySection from '../../components/about/StorySection.vue'
|
||||
import OurValuesSection from '../../components/about/OurValuesSection.vue'
|
||||
import ValuesSection from '../../components/about/ValuesSection.vue'
|
||||
import CareersSection from '../../components/about/CareersSection.vue'
|
||||
@@ -9,7 +8,6 @@ import CareersSection from '../../components/about/CareersSection.vue'
|
||||
|
||||
<BaseLayout title="关于我们 — Comfy" description="了解 ComfyUI 背后的团队和使命——开源的生成式 AI 平台。">
|
||||
<HeroSection locale="zh-CN" client:load />
|
||||
<StorySection locale="zh-CN" />
|
||||
<OurValuesSection locale="zh-CN" />
|
||||
<ValuesSection locale="zh-CN" client:visible />
|
||||
<CareersSection locale="zh-CN" />
|
||||
|
||||
@@ -5,20 +5,6 @@ import RolesSection from '../../components/careers/RolesSection.vue'
|
||||
import WhyJoinSection from '../../components/careers/WhyJoinSection.vue'
|
||||
import TeamPhotosSection from '../../components/careers/TeamPhotosSection.vue'
|
||||
import FAQSection from '../../components/common/FAQSection.vue'
|
||||
import { fetchRolesForBuild } from '../../utils/ashby'
|
||||
import { reportAshbyOutcome } from '../../utils/ashby.ci'
|
||||
|
||||
const outcome = await fetchRolesForBuild()
|
||||
reportAshbyOutcome(outcome)
|
||||
|
||||
if (outcome.status === 'failed') {
|
||||
throw new Error(
|
||||
`Ashby fetch failed and no snapshot is available. Reason: ${outcome.reason}. ` +
|
||||
'Run `pnpm --filter @comfyorg/website ashby:refresh-snapshot` locally and commit the snapshot.'
|
||||
)
|
||||
}
|
||||
|
||||
const departments = outcome.snapshot.departments
|
||||
---
|
||||
|
||||
<BaseLayout
|
||||
@@ -26,7 +12,7 @@ const departments = outcome.snapshot.departments
|
||||
description="加入构建生成式 AI 操作系统的团队。工程、设计、市场营销等岗位开放招聘中。"
|
||||
>
|
||||
<HeroSection locale="zh-CN" />
|
||||
<RolesSection locale="zh-CN" departments={departments} client:visible />
|
||||
<RolesSection locale="zh-CN" client:visible />
|
||||
<WhyJoinSection locale="zh-CN" client:visible />
|
||||
<TeamPhotosSection client:visible />
|
||||
<FAQSection
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import type { FetchOutcome } from './ashby'
|
||||
import type { RolesSnapshot } from '../data/roles'
|
||||
|
||||
import { reportAshbyOutcome, resetAshbyReporterForTests } from './ashby.ci'
|
||||
|
||||
function baseSnapshot(): RolesSnapshot {
|
||||
return {
|
||||
fetchedAt: new Date().toISOString(),
|
||||
departments: [
|
||||
{
|
||||
name: 'ENGINEERING',
|
||||
key: 'engineering',
|
||||
roles: [
|
||||
{
|
||||
id: 'x',
|
||||
title: 'Design Engineer',
|
||||
department: 'Engineering',
|
||||
location: 'San Francisco',
|
||||
applyUrl: 'https://jobs.ashbyhq.com/comfy-org/x'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
function freshOutcome(droppedCount = 0): FetchOutcome {
|
||||
return {
|
||||
status: 'fresh',
|
||||
droppedCount,
|
||||
droppedRoles:
|
||||
droppedCount === 0
|
||||
? []
|
||||
: [{ title: 'Bad Role', reason: 'jobUrl: Invalid url' }],
|
||||
snapshot: {
|
||||
fetchedAt: new Date().toISOString(),
|
||||
departments: [
|
||||
{
|
||||
name: 'ENGINEERING',
|
||||
key: 'engineering',
|
||||
roles: [
|
||||
{
|
||||
id: 'x',
|
||||
title: 'Design Engineer',
|
||||
department: 'Engineering',
|
||||
location: 'San Francisco',
|
||||
applyUrl: 'https://jobs.ashbyhq.com/comfy-org/x'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
describe('reportAshbyOutcome', () => {
|
||||
let writeSpy: ReturnType<typeof vi.spyOn>
|
||||
let summaryDir: string
|
||||
let summaryPath: string
|
||||
const originalSummary = process.env.GITHUB_STEP_SUMMARY
|
||||
|
||||
beforeEach(() => {
|
||||
resetAshbyReporterForTests()
|
||||
writeSpy = vi.spyOn(process.stdout, 'write').mockImplementation(() => true)
|
||||
summaryDir = mkdtempSync(join(tmpdir(), 'ashby-summary-'))
|
||||
summaryPath = join(summaryDir, 'summary.md')
|
||||
writeFileSync(summaryPath, '')
|
||||
process.env.GITHUB_STEP_SUMMARY = summaryPath
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
writeSpy.mockRestore()
|
||||
rmSync(summaryDir, { recursive: true, force: true })
|
||||
if (originalSummary === undefined) delete process.env.GITHUB_STEP_SUMMARY
|
||||
else process.env.GITHUB_STEP_SUMMARY = originalSummary
|
||||
})
|
||||
|
||||
it('emits nothing on a clean fresh outcome', () => {
|
||||
reportAshbyOutcome(freshOutcome(0))
|
||||
expect(writeSpy).not.toHaveBeenCalled()
|
||||
expect(readFileSync(summaryPath, 'utf8')).toContain('Fresh')
|
||||
})
|
||||
|
||||
it('emits exactly one set of annotations across repeated calls', () => {
|
||||
reportAshbyOutcome(freshOutcome(1))
|
||||
reportAshbyOutcome(freshOutcome(1))
|
||||
expect(writeSpy).toHaveBeenCalledTimes(1)
|
||||
const annotation = writeSpy.mock.calls[0]![0] as string
|
||||
expect(annotation).toContain('::warning title=Ashby: dropped 1 invalid')
|
||||
expect(readFileSync(summaryPath, 'utf8')).toContain('Dropped')
|
||||
})
|
||||
|
||||
it('emits ::error for auth failures in a stale outcome', () => {
|
||||
reportAshbyOutcome({
|
||||
status: 'stale',
|
||||
reason: 'HTTP 401 Unauthorized',
|
||||
snapshot: baseSnapshot()
|
||||
})
|
||||
const annotation = writeSpy.mock.calls[0]![0] as string
|
||||
expect(annotation).toContain('::error title=Ashby authentication failed')
|
||||
})
|
||||
|
||||
it('emits ::warning for missing-env stale outcomes', () => {
|
||||
reportAshbyOutcome({
|
||||
status: 'stale',
|
||||
reason: 'missing WEBSITE_ASHBY_API_KEY or WEBSITE_ASHBY_JOB_BOARD_NAME',
|
||||
snapshot: baseSnapshot()
|
||||
})
|
||||
const annotation = writeSpy.mock.calls[0]![0] as string
|
||||
expect(annotation).toContain('::warning title=Ashby integration')
|
||||
})
|
||||
|
||||
it('emits ::error for a failed outcome and writes no fresh-only sections', () => {
|
||||
reportAshbyOutcome({ status: 'failed', reason: 'HTTP 500 Server Error' })
|
||||
const annotation = writeSpy.mock.calls[0]![0] as string
|
||||
expect(annotation).toContain('::error title=Ashby fetch failed')
|
||||
expect(readFileSync(summaryPath, 'utf8')).toContain('Failed')
|
||||
})
|
||||
|
||||
it('does not throw when GITHUB_STEP_SUMMARY is not set', () => {
|
||||
delete process.env.GITHUB_STEP_SUMMARY
|
||||
expect(() => reportAshbyOutcome(freshOutcome(0))).not.toThrow()
|
||||
})
|
||||
})
|
||||
@@ -1,113 +0,0 @@
|
||||
import { appendFileSync } from 'node:fs'
|
||||
|
||||
import type { FetchOutcome } from './ashby'
|
||||
|
||||
let hasReported = false
|
||||
|
||||
export function resetAshbyReporterForTests(): void {
|
||||
hasReported = false
|
||||
}
|
||||
|
||||
export function reportAshbyOutcome(outcome: FetchOutcome): void {
|
||||
if (hasReported) return
|
||||
hasReported = true
|
||||
|
||||
const lines = buildAnnotations(outcome)
|
||||
for (const line of lines) {
|
||||
process.stdout.write(`${line}\n`)
|
||||
}
|
||||
|
||||
const summaryPath = process.env.GITHUB_STEP_SUMMARY
|
||||
if (summaryPath) {
|
||||
try {
|
||||
appendFileSync(summaryPath, buildStepSummary(outcome))
|
||||
} catch {
|
||||
// Writing the summary is best-effort; do not fail the build if the
|
||||
// runner's summary file is unavailable (e.g. local dev).
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function buildAnnotations(outcome: FetchOutcome): string[] {
|
||||
if (outcome.status === 'fresh') {
|
||||
if (outcome.droppedCount === 0) return []
|
||||
const roleCount = outcome.droppedCount === 1 ? 'role' : 'roles'
|
||||
const drops = outcome.droppedRoles
|
||||
.map((d) => ` - ${d.title ? `"${d.title}"` : '(untitled)'}: ${d.reason}`)
|
||||
.join('%0A')
|
||||
return [
|
||||
`::warning title=Ashby: dropped ${outcome.droppedCount} invalid ${roleCount}::Dropped roles:%0A${drops}%0A%0AAction items:%0A 1. Fix the posting in Ashby admin (e.g. assign a department, fix the URL).%0A 2. If the v1 schema is too strict for a legitimate case, relax the field in apps/website/src/utils/ashby.schema.ts and add a test.%0A 3. These roles will not appear on the careers page until fixed.`
|
||||
]
|
||||
}
|
||||
|
||||
if (outcome.status === 'stale') {
|
||||
return [staleAnnotation(outcome.reason)]
|
||||
}
|
||||
|
||||
return [
|
||||
`::error title=Ashby fetch failed and no snapshot is available::Cannot build careers page without data.%0A%0AReason: ${escapeAnnotation(outcome.reason)}%0A%0AAction items:%0A 1. Run \`pnpm --filter @comfyorg/website ashby:refresh-snapshot\` locally with a valid WEBSITE_ASHBY_API_KEY.%0A 2. Commit apps/website/src/data/ashby-roles.snapshot.json.%0A 3. Push and re-run CI.`
|
||||
]
|
||||
}
|
||||
|
||||
function staleAnnotation(reason: string): string {
|
||||
const escaped = escapeAnnotation(reason)
|
||||
if (reason.startsWith('missing ')) {
|
||||
return `::warning title=Ashby integration::${escaped}. Falling back to committed snapshot.%0A%0AAction items:%0A 1. If you're a contributor without key access, this is expected. The snapshot will be used.%0A 2. If this is CI, check that the \`WEBSITE_ASHBY_API_KEY\` secret exists in the repo and is referenced in .github/workflows/ci-website-build.yaml.`
|
||||
}
|
||||
if (reason.startsWith('HTTP 401') || reason.startsWith('HTTP 403')) {
|
||||
return `::error title=Ashby authentication failed::${escaped}. The WEBSITE_ASHBY_API_KEY is missing, invalid, or revoked. Build continues with the last-known-good snapshot.%0A%0AAction items:%0A 1. Open Ashby → Settings → API Keys and confirm the key is active.%0A 2. Update the \`WEBSITE_ASHBY_API_KEY\` secret in GitHub Actions and Vercel.%0A 3. Re-run this workflow.`
|
||||
}
|
||||
if (reason.startsWith('envelope')) {
|
||||
return `::error title=Ashby schema mismatch::${escaped}. The Ashby API contract has likely changed. Build continues with the snapshot, but future updates will fail until the schema is fixed.%0A%0AAction items:%0A 1. Check https://developers.ashbyhq.com/reference for API changelog.%0A 2. Update apps/website/src/utils/ashby.schema.ts to match the new shape.`
|
||||
}
|
||||
return `::warning title=Ashby API unavailable::${escaped}. Using last-known-good snapshot.%0A%0AAction items:%0A 1. Check https://status.ashbyhq.com%0A 2. Re-run this workflow once Ashby is healthy.`
|
||||
}
|
||||
|
||||
function escapeAnnotation(value: string): string {
|
||||
return value.replace(/\r?\n/g, '%0A').replace(/\r/g, '%0D')
|
||||
}
|
||||
|
||||
function buildStepSummary(outcome: FetchOutcome): string {
|
||||
const header = '## 💼 Careers (Ashby)\n'
|
||||
const rows: Array<[string, string]> = []
|
||||
|
||||
if (outcome.status === 'fresh') {
|
||||
rows.push(['Status', '✅ Fresh (fetched from Ashby)'])
|
||||
rows.push([
|
||||
'Roles',
|
||||
String(
|
||||
outcome.snapshot.departments.reduce((n, d) => n + d.roles.length, 0)
|
||||
)
|
||||
])
|
||||
rows.push(['Dropped', String(outcome.droppedCount)])
|
||||
} else if (outcome.status === 'stale') {
|
||||
rows.push(['Status', '⚠️ Stale (using snapshot — Ashby fetch failed)'])
|
||||
rows.push([
|
||||
'Roles',
|
||||
String(
|
||||
outcome.snapshot.departments.reduce((n, d) => n + d.roles.length, 0)
|
||||
)
|
||||
])
|
||||
rows.push(['Reason', outcome.reason])
|
||||
rows.push(['Snapshot age', describeSnapshotAge(outcome.snapshot.fetchedAt)])
|
||||
} else {
|
||||
rows.push(['Status', '❌ Failed (no snapshot available)'])
|
||||
rows.push(['Reason', outcome.reason])
|
||||
}
|
||||
|
||||
const table =
|
||||
'| | |\n|---|---|\n' +
|
||||
rows.map(([k, v]) => `| **${k}** | ${v} |`).join('\n') +
|
||||
'\n'
|
||||
|
||||
return `${header}${table}\n`
|
||||
}
|
||||
|
||||
function describeSnapshotAge(fetchedAt: string): string {
|
||||
const fetched = new Date(fetchedAt).getTime()
|
||||
if (Number.isNaN(fetched)) return 'unknown'
|
||||
const days = Math.floor((Date.now() - fetched) / 86_400_000)
|
||||
if (days <= 0) return 'today'
|
||||
if (days === 1) return '1 day'
|
||||
return `${days} days`
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const AshbyJobPostingSchema = z.object({
|
||||
title: z.string().min(1),
|
||||
department: z.string().optional(),
|
||||
location: z.string().optional(),
|
||||
isListed: z.boolean(),
|
||||
jobUrl: z.string().url(),
|
||||
applyUrl: z.string().url().optional()
|
||||
})
|
||||
|
||||
export const AshbyJobBoardResponseSchema = z.object({
|
||||
apiVersion: z.literal('1'),
|
||||
jobs: z.array(z.unknown())
|
||||
})
|
||||
|
||||
export type AshbyJobPosting = z.infer<typeof AshbyJobPostingSchema>
|
||||
@@ -1,328 +0,0 @@
|
||||
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import type { AshbyJobPosting } from './ashby.schema'
|
||||
import type { RolesSnapshot } from '../data/roles'
|
||||
|
||||
import { fetchRolesForBuild, resetAshbyFetcherForTests } from './ashby'
|
||||
|
||||
const BASE_URL = 'https://ashby.test'
|
||||
const BOARD = 'comfy-org'
|
||||
const KEY = 'abc-123-secret'
|
||||
|
||||
function validJob(overrides: Partial<AshbyJobPosting> = {}): unknown {
|
||||
return {
|
||||
title: 'Design Engineer',
|
||||
department: 'Engineering',
|
||||
location: 'San Francisco',
|
||||
isListed: true,
|
||||
jobUrl: 'https://jobs.ashbyhq.com/comfy-org/design-engineer',
|
||||
applyUrl: 'https://jobs.ashbyhq.com/comfy-org/design-engineer/apply',
|
||||
...overrides
|
||||
}
|
||||
}
|
||||
|
||||
function response(body: unknown, init: Partial<ResponseInit> = {}): Response {
|
||||
const base: ResponseInit = {
|
||||
status: 200,
|
||||
headers: { 'content-type': 'application/json' }
|
||||
}
|
||||
return new Response(JSON.stringify(body), { ...base, ...init })
|
||||
}
|
||||
|
||||
function makeSnapshot(roleCount = 2): RolesSnapshot {
|
||||
const roles = Array.from({ length: roleCount }, (_, i) => ({
|
||||
id: `snapshot-role-${i}`,
|
||||
title: `Snapshot Role ${i}`,
|
||||
department: 'Engineering',
|
||||
location: 'San Francisco',
|
||||
applyUrl: `https://jobs.ashbyhq.com/comfy-org/snapshot-${i}`
|
||||
}))
|
||||
return {
|
||||
fetchedAt: '2026-04-01T00:00:00.000Z',
|
||||
departments: [{ name: 'ENGINEERING', key: 'engineering', roles }]
|
||||
}
|
||||
}
|
||||
|
||||
function withSnapshotDir(snapshot: RolesSnapshot | null): URL {
|
||||
const dir = mkdtempSync(join(tmpdir(), 'ashby-test-'))
|
||||
const file = join(dir, 'ashby-roles.snapshot.json')
|
||||
if (snapshot) writeFileSync(file, JSON.stringify(snapshot))
|
||||
return pathToFileURL(file)
|
||||
}
|
||||
|
||||
describe('fetchRolesForBuild', () => {
|
||||
const savedApiKey = process.env.WEBSITE_ASHBY_API_KEY
|
||||
const savedBoardName = process.env.WEBSITE_ASHBY_JOB_BOARD_NAME
|
||||
|
||||
beforeEach(() => {
|
||||
resetAshbyFetcherForTests()
|
||||
delete process.env.WEBSITE_ASHBY_API_KEY
|
||||
delete process.env.WEBSITE_ASHBY_JOB_BOARD_NAME
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
process.env.WEBSITE_ASHBY_API_KEY = savedApiKey
|
||||
process.env.WEBSITE_ASHBY_JOB_BOARD_NAME = savedBoardName
|
||||
})
|
||||
|
||||
it('returns fresh when the API succeeds', async () => {
|
||||
const fetchImpl = vi.fn(async () =>
|
||||
response({ apiVersion: '1', jobs: [validJob()] })
|
||||
)
|
||||
const outcome = await fetchRolesForBuild({
|
||||
apiKey: KEY,
|
||||
boardName: BOARD,
|
||||
baseUrl: BASE_URL,
|
||||
fetchImpl: fetchImpl as unknown as typeof fetch
|
||||
})
|
||||
expect(outcome.status).toBe('fresh')
|
||||
if (outcome.status !== 'fresh') return
|
||||
expect(outcome.droppedCount).toBe(0)
|
||||
expect(outcome.snapshot.departments).toHaveLength(1)
|
||||
expect(outcome.snapshot.departments[0]!.roles[0]!.applyUrl).toMatch(
|
||||
/design-engineer\/apply$/
|
||||
)
|
||||
})
|
||||
|
||||
it('falls back to jobUrl when applyUrl is missing and keeps the role', async () => {
|
||||
const job = validJob()
|
||||
delete (job as Record<string, unknown>).applyUrl
|
||||
const fetchImpl = vi.fn(async () =>
|
||||
response({ apiVersion: '1', jobs: [job] })
|
||||
)
|
||||
const outcome = await fetchRolesForBuild({
|
||||
apiKey: KEY,
|
||||
boardName: BOARD,
|
||||
baseUrl: BASE_URL,
|
||||
fetchImpl: fetchImpl as unknown as typeof fetch
|
||||
})
|
||||
expect(outcome.status).toBe('fresh')
|
||||
if (outcome.status !== 'fresh') return
|
||||
expect(outcome.snapshot.departments[0]!.roles[0]!.applyUrl).toBe(
|
||||
'https://jobs.ashbyhq.com/comfy-org/design-engineer'
|
||||
)
|
||||
})
|
||||
|
||||
it('drops invalid roles individually and keeps the valid ones', async () => {
|
||||
const snapshotUrl = withSnapshotDir(makeSnapshot())
|
||||
const fetchImpl = vi.fn(async () =>
|
||||
response({
|
||||
apiVersion: '1',
|
||||
jobs: [validJob(), validJob({ title: 'Bad Role', jobUrl: 'not-a-url' })]
|
||||
})
|
||||
)
|
||||
const outcome = await fetchRolesForBuild({
|
||||
apiKey: KEY,
|
||||
boardName: BOARD,
|
||||
baseUrl: BASE_URL,
|
||||
snapshotUrl,
|
||||
fetchImpl: fetchImpl as unknown as typeof fetch
|
||||
})
|
||||
expect(outcome.status).toBe('fresh')
|
||||
if (outcome.status !== 'fresh') return
|
||||
expect(outcome.droppedCount).toBe(1)
|
||||
expect(outcome.droppedRoles[0]!.title).toBe('Bad Role')
|
||||
expect(outcome.snapshot.departments[0]!.roles).toHaveLength(1)
|
||||
rmSync(new URL('.', snapshotUrl), { recursive: true, force: true })
|
||||
})
|
||||
|
||||
it('renders an empty-but-fresh outcome when hiring is paused', async () => {
|
||||
const snapshotUrl = withSnapshotDir(makeSnapshot())
|
||||
const fetchImpl = vi.fn(async () => response({ apiVersion: '1', jobs: [] }))
|
||||
const outcome = await fetchRolesForBuild({
|
||||
apiKey: KEY,
|
||||
boardName: BOARD,
|
||||
baseUrl: BASE_URL,
|
||||
snapshotUrl,
|
||||
fetchImpl: fetchImpl as unknown as typeof fetch
|
||||
})
|
||||
expect(outcome.status).toBe('fresh')
|
||||
if (outcome.status !== 'fresh') return
|
||||
expect(outcome.snapshot.departments).toEqual([])
|
||||
expect(outcome.droppedCount).toBe(0)
|
||||
rmSync(new URL('.', snapshotUrl), { recursive: true, force: true })
|
||||
})
|
||||
|
||||
it('normalizes missing department and location to safe defaults', async () => {
|
||||
const snapshotUrl = withSnapshotDir(makeSnapshot())
|
||||
const job = validJob()
|
||||
delete (job as Record<string, unknown>).department
|
||||
delete (job as Record<string, unknown>).location
|
||||
const fetchImpl = vi.fn(async () =>
|
||||
response({ apiVersion: '1', jobs: [job] })
|
||||
)
|
||||
const outcome = await fetchRolesForBuild({
|
||||
apiKey: KEY,
|
||||
boardName: BOARD,
|
||||
baseUrl: BASE_URL,
|
||||
snapshotUrl,
|
||||
fetchImpl: fetchImpl as unknown as typeof fetch
|
||||
})
|
||||
expect(outcome.status).toBe('fresh')
|
||||
if (outcome.status !== 'fresh') return
|
||||
const [department] = outcome.snapshot.departments
|
||||
expect(department?.name).toBe('OTHER')
|
||||
expect(department?.roles[0]?.location).toBe('Remote')
|
||||
rmSync(new URL('.', snapshotUrl), { recursive: true, force: true })
|
||||
})
|
||||
|
||||
it('filters out roles with isListed=false', async () => {
|
||||
const snapshotUrl = withSnapshotDir(makeSnapshot())
|
||||
const fetchImpl = vi.fn(async () =>
|
||||
response({
|
||||
apiVersion: '1',
|
||||
jobs: [validJob(), validJob({ title: 'Hidden', isListed: false })]
|
||||
})
|
||||
)
|
||||
const outcome = await fetchRolesForBuild({
|
||||
apiKey: KEY,
|
||||
boardName: BOARD,
|
||||
baseUrl: BASE_URL,
|
||||
snapshotUrl,
|
||||
fetchImpl: fetchImpl as unknown as typeof fetch
|
||||
})
|
||||
expect(outcome.status).toBe('fresh')
|
||||
if (outcome.status !== 'fresh') return
|
||||
const titles = outcome.snapshot.departments.flatMap((d) =>
|
||||
d.roles.map((r) => r.title)
|
||||
)
|
||||
expect(titles).not.toContain('Hidden')
|
||||
rmSync(new URL('.', snapshotUrl), { recursive: true, force: true })
|
||||
})
|
||||
|
||||
it('returns stale with missing env when the snapshot is present', async () => {
|
||||
const snapshot = makeSnapshot()
|
||||
const snapshotUrl = withSnapshotDir(snapshot)
|
||||
const fetchImpl = vi.fn()
|
||||
const outcome = await fetchRolesForBuild({
|
||||
snapshotUrl,
|
||||
fetchImpl: fetchImpl as unknown as typeof fetch
|
||||
})
|
||||
expect(outcome.status).toBe('stale')
|
||||
if (outcome.status !== 'stale') return
|
||||
expect(outcome.reason).toMatch(/^missing /)
|
||||
expect(fetchImpl).not.toHaveBeenCalled()
|
||||
rmSync(new URL('.', snapshotUrl), { recursive: true, force: true })
|
||||
})
|
||||
|
||||
it('returns failed when both env and snapshot are missing', async () => {
|
||||
const snapshotUrl = withSnapshotDir(null)
|
||||
const outcome = await fetchRolesForBuild({
|
||||
snapshotUrl,
|
||||
fetchImpl: vi.fn() as unknown as typeof fetch
|
||||
})
|
||||
expect(outcome.status).toBe('failed')
|
||||
rmSync(new URL('.', snapshotUrl), { recursive: true, force: true })
|
||||
})
|
||||
|
||||
it('does not retry on HTTP 401', async () => {
|
||||
const snapshotUrl = withSnapshotDir(makeSnapshot())
|
||||
const fetchImpl = vi.fn(async () => response({}, { status: 401 }))
|
||||
const outcome = await fetchRolesForBuild({
|
||||
apiKey: KEY,
|
||||
boardName: BOARD,
|
||||
baseUrl: BASE_URL,
|
||||
snapshotUrl,
|
||||
fetchImpl: fetchImpl as unknown as typeof fetch
|
||||
})
|
||||
expect(outcome.status).toBe('stale')
|
||||
if (outcome.status !== 'stale') return
|
||||
expect(outcome.reason).toMatch(/^HTTP 401/)
|
||||
expect(fetchImpl).toHaveBeenCalledTimes(1)
|
||||
rmSync(new URL('.', snapshotUrl), { recursive: true, force: true })
|
||||
})
|
||||
|
||||
it('retries 5xx up to the configured limit then falls back to snapshot', async () => {
|
||||
const snapshotUrl = withSnapshotDir(makeSnapshot())
|
||||
const fetchImpl = vi.fn(async () => response({}, { status: 503 }))
|
||||
const sleep = vi.fn(async () => undefined)
|
||||
const outcome = await fetchRolesForBuild({
|
||||
apiKey: KEY,
|
||||
boardName: BOARD,
|
||||
baseUrl: BASE_URL,
|
||||
snapshotUrl,
|
||||
retryDelaysMs: [1, 1, 1],
|
||||
sleep,
|
||||
fetchImpl: fetchImpl as unknown as typeof fetch
|
||||
})
|
||||
expect(outcome.status).toBe('stale')
|
||||
expect(fetchImpl).toHaveBeenCalledTimes(4)
|
||||
expect(sleep).toHaveBeenCalledTimes(3)
|
||||
rmSync(new URL('.', snapshotUrl), { recursive: true, force: true })
|
||||
})
|
||||
|
||||
it('falls back to snapshot on envelope schema mismatch', async () => {
|
||||
const snapshotUrl = withSnapshotDir(makeSnapshot())
|
||||
const fetchImpl = vi.fn(async () => response({ apiVersion: '2', jobs: [] }))
|
||||
const outcome = await fetchRolesForBuild({
|
||||
apiKey: KEY,
|
||||
boardName: BOARD,
|
||||
baseUrl: BASE_URL,
|
||||
snapshotUrl,
|
||||
fetchImpl: fetchImpl as unknown as typeof fetch
|
||||
})
|
||||
expect(outcome.status).toBe('stale')
|
||||
if (outcome.status !== 'stale') return
|
||||
expect(outcome.reason).toMatch(/^envelope schema/)
|
||||
rmSync(new URL('.', snapshotUrl), { recursive: true, force: true })
|
||||
})
|
||||
|
||||
it('memoizes within a single process', async () => {
|
||||
const fetchImpl = vi.fn(async () =>
|
||||
response({ apiVersion: '1', jobs: [validJob()] })
|
||||
)
|
||||
const opts = {
|
||||
apiKey: KEY,
|
||||
boardName: BOARD,
|
||||
baseUrl: BASE_URL,
|
||||
fetchImpl: fetchImpl as unknown as typeof fetch
|
||||
}
|
||||
const [a, b] = await Promise.all([
|
||||
fetchRolesForBuild(opts),
|
||||
fetchRolesForBuild(opts)
|
||||
])
|
||||
expect(a).toBe(b)
|
||||
expect(fetchImpl).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('never writes to the snapshot file on success', async () => {
|
||||
const snapshot = makeSnapshot()
|
||||
const snapshotUrl = withSnapshotDir(snapshot)
|
||||
const before = new URL(snapshotUrl.href)
|
||||
const fs = await import('node:fs')
|
||||
const initial = fs.readFileSync(before).toString()
|
||||
const fetchImpl = vi.fn(async () =>
|
||||
response({ apiVersion: '1', jobs: [validJob()] })
|
||||
)
|
||||
await fetchRolesForBuild({
|
||||
apiKey: KEY,
|
||||
boardName: BOARD,
|
||||
baseUrl: BASE_URL,
|
||||
snapshotUrl,
|
||||
fetchImpl: fetchImpl as unknown as typeof fetch
|
||||
})
|
||||
const after = fs.readFileSync(before).toString()
|
||||
expect(after).toBe(initial)
|
||||
rmSync(new URL('.', snapshotUrl), { recursive: true, force: true })
|
||||
})
|
||||
|
||||
it('does not retry on 4xx auth failures for 403', async () => {
|
||||
const snapshotUrl = withSnapshotDir(makeSnapshot())
|
||||
const fetchImpl = vi.fn(async () => response({}, { status: 403 }))
|
||||
await fetchRolesForBuild({
|
||||
apiKey: KEY,
|
||||
boardName: BOARD,
|
||||
baseUrl: BASE_URL,
|
||||
snapshotUrl,
|
||||
fetchImpl: fetchImpl as unknown as typeof fetch
|
||||
})
|
||||
expect(fetchImpl).toHaveBeenCalledTimes(1)
|
||||
rmSync(new URL('.', snapshotUrl), { recursive: true, force: true })
|
||||
})
|
||||
})
|
||||
@@ -1,299 +0,0 @@
|
||||
import { createHash } from 'node:crypto'
|
||||
import { readFile } from 'node:fs/promises'
|
||||
|
||||
import type { AshbyJobPosting } from './ashby.schema'
|
||||
import type { Department, Role, RolesSnapshot } from '../data/roles'
|
||||
|
||||
import bundledSnapshot from '../data/ashby-roles.snapshot.json' with { type: 'json' }
|
||||
import {
|
||||
AshbyJobBoardResponseSchema,
|
||||
AshbyJobPostingSchema
|
||||
} from './ashby.schema'
|
||||
|
||||
const DEFAULT_BASE_URL = 'https://api.ashbyhq.com'
|
||||
const DEFAULT_TIMEOUT_MS = 10_000
|
||||
const RETRY_DELAYS_MS = [1_000, 2_000, 4_000]
|
||||
|
||||
export interface DroppedRole {
|
||||
title: string
|
||||
reason: string
|
||||
}
|
||||
|
||||
export type FetchOutcome =
|
||||
| {
|
||||
status: 'fresh'
|
||||
snapshot: RolesSnapshot
|
||||
droppedCount: number
|
||||
droppedRoles: DroppedRole[]
|
||||
}
|
||||
| { status: 'stale'; snapshot: RolesSnapshot; reason: string }
|
||||
| { status: 'failed'; reason: string }
|
||||
|
||||
interface FetchRolesOptions {
|
||||
apiKey?: string
|
||||
boardName?: string
|
||||
baseUrl?: string
|
||||
timeoutMs?: number
|
||||
retryDelaysMs?: readonly number[]
|
||||
fetchImpl?: typeof fetch
|
||||
snapshotUrl?: URL
|
||||
sleep?: (ms: number) => Promise<void>
|
||||
}
|
||||
|
||||
let inflight: Promise<FetchOutcome> | undefined
|
||||
|
||||
export function resetAshbyFetcherForTests(): void {
|
||||
inflight = undefined
|
||||
}
|
||||
|
||||
export function fetchRolesForBuild(
|
||||
options: FetchRolesOptions = {}
|
||||
): Promise<FetchOutcome> {
|
||||
inflight ??= doFetchRolesForBuild(options)
|
||||
return inflight
|
||||
}
|
||||
|
||||
async function doFetchRolesForBuild(
|
||||
options: FetchRolesOptions
|
||||
): Promise<FetchOutcome> {
|
||||
const apiKey = options.apiKey ?? process.env.WEBSITE_ASHBY_API_KEY
|
||||
const boardName =
|
||||
options.boardName ?? process.env.WEBSITE_ASHBY_JOB_BOARD_NAME
|
||||
|
||||
if (!apiKey || !boardName) {
|
||||
return fallback(
|
||||
'missing WEBSITE_ASHBY_API_KEY or WEBSITE_ASHBY_JOB_BOARD_NAME',
|
||||
options.snapshotUrl
|
||||
)
|
||||
}
|
||||
|
||||
const result = await tryFetchAndParse(apiKey, boardName, options)
|
||||
if (result.kind === 'ok') {
|
||||
return {
|
||||
status: 'fresh',
|
||||
snapshot: {
|
||||
fetchedAt: new Date().toISOString(),
|
||||
departments: result.departments
|
||||
},
|
||||
droppedCount: result.droppedRoles.length,
|
||||
droppedRoles: result.droppedRoles
|
||||
}
|
||||
}
|
||||
|
||||
return fallback(result.reason, options.snapshotUrl)
|
||||
}
|
||||
|
||||
async function fallback(
|
||||
reason: string,
|
||||
snapshotUrl: URL | undefined
|
||||
): Promise<FetchOutcome> {
|
||||
const snapshot = await readSnapshot(snapshotUrl)
|
||||
if (snapshot) return { status: 'stale', snapshot, reason }
|
||||
return { status: 'failed', reason }
|
||||
}
|
||||
|
||||
interface FetchOk {
|
||||
kind: 'ok'
|
||||
departments: Department[]
|
||||
droppedRoles: DroppedRole[]
|
||||
}
|
||||
|
||||
interface FetchErr {
|
||||
kind: 'err'
|
||||
reason: string
|
||||
}
|
||||
|
||||
async function tryFetchAndParse(
|
||||
apiKey: string,
|
||||
boardName: string,
|
||||
options: FetchRolesOptions
|
||||
): Promise<FetchOk | FetchErr> {
|
||||
const baseUrl = options.baseUrl ?? DEFAULT_BASE_URL
|
||||
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS
|
||||
const retryDelaysMs = options.retryDelaysMs ?? RETRY_DELAYS_MS
|
||||
const fetchImpl = options.fetchImpl ?? fetch
|
||||
const sleep = options.sleep ?? defaultSleep
|
||||
|
||||
const url = `${baseUrl}/posting-api/job-board/${encodeURIComponent(
|
||||
boardName
|
||||
)}?includeCompensation=false`
|
||||
const authHeader = `Basic ${Buffer.from(`${apiKey}:`).toString('base64')}`
|
||||
|
||||
let lastReason = 'unknown error'
|
||||
for (let attempt = 0; attempt <= retryDelaysMs.length; attempt++) {
|
||||
if (attempt > 0) await sleep(retryDelaysMs[attempt - 1])
|
||||
|
||||
const response = await callOnce(fetchImpl, url, authHeader, timeoutMs)
|
||||
if (response.kind === 'err') {
|
||||
lastReason = response.reason
|
||||
if (!response.retryable) return response
|
||||
continue
|
||||
}
|
||||
|
||||
const envelope = AshbyJobBoardResponseSchema.safeParse(response.body)
|
||||
if (!envelope.success) {
|
||||
return {
|
||||
kind: 'err',
|
||||
reason: `envelope schema validation failed: ${envelope.error.issues
|
||||
.map((i) => `${i.path.join('.') || '<root>'}: ${i.message}`)
|
||||
.join('; ')}`
|
||||
}
|
||||
}
|
||||
|
||||
return parseRoles(envelope.data.jobs)
|
||||
}
|
||||
|
||||
return { kind: 'err', reason: lastReason }
|
||||
}
|
||||
|
||||
type CallResponse =
|
||||
| { kind: 'ok'; body: unknown }
|
||||
| { kind: 'err'; reason: string; retryable: boolean }
|
||||
|
||||
async function callOnce(
|
||||
fetchImpl: typeof fetch,
|
||||
url: string,
|
||||
authHeader: string,
|
||||
timeoutMs: number
|
||||
): Promise<CallResponse> {
|
||||
const controller = new AbortController()
|
||||
const timer = setTimeout(() => controller.abort(), timeoutMs)
|
||||
try {
|
||||
const res = await fetchImpl(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: authHeader,
|
||||
Accept: 'application/json; version=1'
|
||||
},
|
||||
signal: controller.signal
|
||||
})
|
||||
if (res.ok) {
|
||||
return { kind: 'ok', body: await res.json() }
|
||||
}
|
||||
const retryable =
|
||||
res.status === 429 || (res.status >= 500 && res.status < 600)
|
||||
return {
|
||||
kind: 'err',
|
||||
reason: `HTTP ${res.status} ${res.statusText || ''}`.trim(),
|
||||
retryable
|
||||
}
|
||||
} catch (error) {
|
||||
const reason =
|
||||
error instanceof Error
|
||||
? `network error: ${error.message}`
|
||||
: 'network error'
|
||||
return { kind: 'err', reason, retryable: true }
|
||||
} finally {
|
||||
clearTimeout(timer)
|
||||
}
|
||||
}
|
||||
|
||||
function parseRoles(jobs: readonly unknown[]): FetchOk {
|
||||
const valid: AshbyJobPosting[] = []
|
||||
const droppedRoles: DroppedRole[] = []
|
||||
|
||||
for (const raw of jobs) {
|
||||
const parsed = AshbyJobPostingSchema.safeParse(raw)
|
||||
if (!parsed.success) {
|
||||
droppedRoles.push({
|
||||
title: extractTitle(raw),
|
||||
reason: parsed.error.issues
|
||||
.map((i) => `${i.path.join('.') || '<root>'}: ${i.message}`)
|
||||
.join('; ')
|
||||
})
|
||||
continue
|
||||
}
|
||||
if (!parsed.data.isListed) continue
|
||||
valid.push(parsed.data)
|
||||
}
|
||||
|
||||
return { kind: 'ok', departments: groupByDepartment(valid), droppedRoles }
|
||||
}
|
||||
|
||||
function extractTitle(raw: unknown): string {
|
||||
if (
|
||||
raw !== null &&
|
||||
typeof raw === 'object' &&
|
||||
'title' in raw &&
|
||||
typeof (raw as { title: unknown }).title === 'string'
|
||||
) {
|
||||
return (raw as { title: string }).title
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
const DEFAULT_DEPARTMENT = 'Other'
|
||||
const DEFAULT_LOCATION = 'Remote'
|
||||
|
||||
function groupByDepartment(jobs: readonly AshbyJobPosting[]): Department[] {
|
||||
const byKey = new Map<string, Department>()
|
||||
for (const job of jobs) {
|
||||
const displayDepartment = normalizeDepartment(job.department)
|
||||
const name = displayDepartment.toUpperCase()
|
||||
const key = slugify(name)
|
||||
const existing = byKey.get(key)
|
||||
const role = toDomainRole(job, displayDepartment)
|
||||
if (existing) {
|
||||
existing.roles.push(role)
|
||||
} else {
|
||||
byKey.set(key, { name, key, roles: [role] })
|
||||
}
|
||||
}
|
||||
return [...byKey.values()].sort((a, b) => a.name.localeCompare(b.name))
|
||||
}
|
||||
|
||||
function toDomainRole(job: AshbyJobPosting, department: string): Role {
|
||||
const applyUrl = job.applyUrl ?? job.jobUrl
|
||||
return {
|
||||
id: createHash('sha1').update(applyUrl).digest('hex').slice(0, 16),
|
||||
title: job.title,
|
||||
department: capitalize(department),
|
||||
location: (job.location ?? '').trim() || DEFAULT_LOCATION,
|
||||
applyUrl
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeDepartment(raw: string | undefined): string {
|
||||
const trimmed = (raw ?? '').trim()
|
||||
return trimmed.length > 0 ? trimmed : DEFAULT_DEPARTMENT
|
||||
}
|
||||
|
||||
function slugify(value: string): string {
|
||||
return value
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9]+/g, '-')
|
||||
.replace(/^-+|-+$/g, '')
|
||||
}
|
||||
|
||||
function capitalize(value: string): string {
|
||||
return value.charAt(0).toUpperCase() + value.slice(1).toLowerCase()
|
||||
}
|
||||
|
||||
async function readSnapshot(
|
||||
snapshotUrl: URL | undefined
|
||||
): Promise<RolesSnapshot | null> {
|
||||
if (!snapshotUrl) {
|
||||
return isRolesSnapshot(bundledSnapshot) ? bundledSnapshot : null
|
||||
}
|
||||
try {
|
||||
const text = await readFile(snapshotUrl, 'utf8')
|
||||
const parsed: unknown = JSON.parse(text)
|
||||
if (isRolesSnapshot(parsed)) return parsed
|
||||
return null
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
function isRolesSnapshot(value: unknown): value is RolesSnapshot {
|
||||
if (value === null || typeof value !== 'object') return false
|
||||
const candidate = value as { fetchedAt?: unknown; departments?: unknown }
|
||||
return (
|
||||
typeof candidate.fetchedAt === 'string' &&
|
||||
Array.isArray(candidate.departments)
|
||||
)
|
||||
}
|
||||
|
||||
function defaultSleep(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms))
|
||||
}
|
||||
@@ -8,10 +8,8 @@
|
||||
"include": [
|
||||
"src/**/*",
|
||||
"e2e/**/*",
|
||||
"scripts/**/*",
|
||||
"astro.config.ts",
|
||||
"playwright.config.ts",
|
||||
"vitest.config.ts"
|
||||
"playwright.config.ts"
|
||||
],
|
||||
"exclude": ["src/**/*.stories.ts"],
|
||||
"references": [{ "path": "./tsconfig.stories.json" }]
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import { defineConfig } from 'vitest/config'
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
environment: 'node',
|
||||
include: ['src/**/*.{test,spec}.ts'],
|
||||
globals: false
|
||||
}
|
||||
})
|
||||
@@ -119,15 +119,7 @@
|
||||
{ "name": "CLIP", "type": "CLIP", "links": [3, 5], "slot_index": 1 },
|
||||
{ "name": "VAE", "type": "VAE", "links": [8], "slot_index": 2 }
|
||||
],
|
||||
"properties": {
|
||||
"models": [
|
||||
{
|
||||
"name": "v1-5-pruned-emaonly-fp16.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/stable-diffusion-v1-5-archive/resolve/main/v1-5-pruned-emaonly-fp16.safetensors?download=true",
|
||||
"directory": "checkpoints"
|
||||
}
|
||||
]
|
||||
},
|
||||
"properties": {},
|
||||
"widgets_values": ["v1-5-pruned-emaonly-fp16.safetensors"]
|
||||
}
|
||||
],
|
||||
|
||||
@@ -518,16 +518,6 @@ export const comfyPageFixture = base.extend<{
|
||||
|
||||
await comfyPage.setup()
|
||||
|
||||
// Hide agent UI in all tests except those explicitly testing the agent.
|
||||
// The FAB is positioned over the canvas viewport, which would cause
|
||||
// unrelated screenshot tests to fail.
|
||||
if (!testInfo.tags.includes('@agent')) {
|
||||
await page.addStyleTag({
|
||||
content:
|
||||
'[data-testid="agent-fab"],[data-testid="agent-panel"]{display:none!important}'
|
||||
})
|
||||
}
|
||||
|
||||
if (isVueNodes) {
|
||||
await comfyPage.vueNodes.waitForNodes()
|
||||
}
|
||||
|
||||
@@ -261,7 +261,6 @@ export class AssetsSidebarTab extends SidebarTab {
|
||||
// --- Search & filter ---
|
||||
public readonly searchInput: Locator
|
||||
public readonly settingsButton: Locator
|
||||
public readonly filterButton: Locator
|
||||
|
||||
// --- View mode ---
|
||||
public readonly listViewOption: Locator
|
||||
@@ -300,7 +299,6 @@ export class AssetsSidebarTab extends SidebarTab {
|
||||
)
|
||||
this.searchInput = page.getByPlaceholder('Search Assets...')
|
||||
this.settingsButton = page.getByRole('button', { name: 'View settings' })
|
||||
this.filterButton = page.getByRole('button', { name: 'Filter by' })
|
||||
this.listViewOption = page.getByText('List view')
|
||||
this.gridViewOption = page.getByText('Grid view')
|
||||
this.sortNewestFirst = page.getByText('Newest first')
|
||||
@@ -336,10 +334,6 @@ export class AssetsSidebarTab extends SidebarTab {
|
||||
return this.page.getByText(title)
|
||||
}
|
||||
|
||||
filterCheckbox(label: string) {
|
||||
return this.page.getByRole('checkbox', { name: label })
|
||||
}
|
||||
|
||||
getAssetCardByName(name: string) {
|
||||
return this.assetCards.filter({ hasText: name })
|
||||
}
|
||||
@@ -389,16 +383,6 @@ export class AssetsSidebarTab extends SidebarTab {
|
||||
.waitFor({ state: 'visible', timeout: 3000 })
|
||||
}
|
||||
|
||||
async openFilterMenu() {
|
||||
await this.dismissToasts()
|
||||
await this.filterButton.click()
|
||||
// Wait for popover content with checkboxes to render
|
||||
await this.filterCheckbox('Image').waitFor({
|
||||
state: 'visible',
|
||||
timeout: 3000
|
||||
})
|
||||
}
|
||||
|
||||
async rightClickAsset(name: string) {
|
||||
const card = this.getAssetCardByName(name)
|
||||
await card.click({ button: 'right' })
|
||||
|
||||
@@ -10,8 +10,6 @@ export class SubgraphBreadcrumbPanel {
|
||||
readonly activeItem: Locator
|
||||
readonly missingNodesIcon: Locator
|
||||
readonly blueprintTag: Locator
|
||||
readonly rootItem: Locator
|
||||
readonly rootBlueprintTag: Locator
|
||||
|
||||
constructor(public readonly page: Page) {
|
||||
this.root = page.getByTestId(TestIds.breadcrumb.subgraph)
|
||||
@@ -25,10 +23,10 @@ export class SubgraphBreadcrumbPanel {
|
||||
TestIds.breadcrumb.missingNodesIcon
|
||||
)
|
||||
this.blueprintTag = this.root.getByTestId(TestIds.breadcrumb.blueprintTag)
|
||||
this.rootItem = page.getByTestId(TestIds.breadcrumb.item('root'))
|
||||
this.rootBlueprintTag = this.rootItem.getByTestId(
|
||||
TestIds.breadcrumb.blueprintTag
|
||||
)
|
||||
}
|
||||
|
||||
rootItem(): Locator {
|
||||
return this.page.getByTestId(TestIds.breadcrumb.item('root'))
|
||||
}
|
||||
|
||||
subgraphItem(subgraphId: string): Locator {
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
import { expect } from '@playwright/test'
|
||||
|
||||
import type { ComfyPage } from '@e2e/fixtures/ComfyPage'
|
||||
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
||||
|
||||
/**
|
||||
* E2E coverage for the in-browser agent terminal (AgentFab + FoldablePanel).
|
||||
*
|
||||
* The panel is now a Vue-native scrollback (no xterm.js), so the tests
|
||||
* target the plain DOM directly: the input is a `<textarea>` inside
|
||||
* `[data-testid="agent-terminal"]`, and the scrollback lives in the same
|
||||
* container as a list of message blocks. We exercise the deterministic
|
||||
* shell surface — typing into the textarea runs commands directly through
|
||||
* the runtime, which is what the LLM ends up calling via `run_shell`.
|
||||
*/
|
||||
|
||||
async function openPanel(comfyPage: ComfyPage): Promise<void> {
|
||||
const fab = comfyPage.page.getByTestId('agent-fab')
|
||||
await expect(fab).toBeVisible()
|
||||
await fab.click()
|
||||
await expect(comfyPage.page.getByTestId('agent-panel')).toBeVisible()
|
||||
}
|
||||
|
||||
async function readTerminalText(comfyPage: ComfyPage): Promise<string> {
|
||||
return await comfyPage.page.getByTestId('agent-terminal').innerText()
|
||||
}
|
||||
|
||||
async function typeAndEnter(comfyPage: ComfyPage, text: string): Promise<void> {
|
||||
const input = comfyPage.page.getByTestId('agent-terminal').locator('textarea')
|
||||
await input.focus()
|
||||
await comfyPage.page.keyboard.type(text)
|
||||
await comfyPage.page.keyboard.press('Enter')
|
||||
}
|
||||
|
||||
test.describe('Agent terminal', { tag: ['@ui', '@agent'] }, () => {
|
||||
test('FAB opens the panel and shows the COMFY-AI title + prompt', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
await openPanel(comfyPage)
|
||||
|
||||
await expect(comfyPage.page.getByTestId('agent-panel-title')).toHaveText(
|
||||
'COMFY-AI'
|
||||
)
|
||||
await expect.poll(() => readTerminalText(comfyPage)).toMatch(/comfy>/)
|
||||
})
|
||||
|
||||
test('Clicking the FAB again closes the panel', async ({ comfyPage }) => {
|
||||
await openPanel(comfyPage)
|
||||
await comfyPage.page.getByTestId('agent-fab').click()
|
||||
await expect(comfyPage.page.getByTestId('agent-panel')).toBeHidden()
|
||||
})
|
||||
|
||||
test('Enter submits; help command lists built-ins', async ({ comfyPage }) => {
|
||||
await openPanel(comfyPage)
|
||||
await typeAndEnter(comfyPage, 'help')
|
||||
await expect
|
||||
.poll(() => readTerminalText(comfyPage))
|
||||
.toMatch(/run-js|cmd-list|comfy/)
|
||||
})
|
||||
|
||||
test('Shift+Enter inserts a literal newline (no submit)', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
await openPanel(comfyPage)
|
||||
const input = comfyPage.page
|
||||
.getByTestId('agent-terminal')
|
||||
.locator('textarea')
|
||||
await input.focus()
|
||||
await comfyPage.page.keyboard.type('echo one')
|
||||
await comfyPage.page.keyboard.press('Shift+Enter')
|
||||
await comfyPage.page.keyboard.type('echo two')
|
||||
// Single submission should run BOTH lines as one multi-line script.
|
||||
await comfyPage.page.keyboard.press('Enter')
|
||||
|
||||
const out = await readTerminalText(comfyPage)
|
||||
expect(out).toContain('one')
|
||||
expect(out).toContain('two')
|
||||
})
|
||||
|
||||
test('coreutils: pwd / echo', async ({ comfyPage }) => {
|
||||
await openPanel(comfyPage)
|
||||
await typeAndEnter(comfyPage, 'pwd')
|
||||
await expect.poll(() => readTerminalText(comfyPage)).toMatch(/^\//m)
|
||||
|
||||
await typeAndEnter(comfyPage, 'echo hello world')
|
||||
await expect
|
||||
.poll(() => readTerminalText(comfyPage))
|
||||
.toContain('hello world')
|
||||
})
|
||||
|
||||
test('comfy namespace lists subcommands', async ({ comfyPage }) => {
|
||||
await openPanel(comfyPage)
|
||||
await typeAndEnter(comfyPage, 'comfy')
|
||||
await expect
|
||||
.poll(() => readTerminalText(comfyPage))
|
||||
.toMatch(/ComfyUI command namespace/)
|
||||
})
|
||||
|
||||
test('run-js evaluates in the page scope', async ({ comfyPage }) => {
|
||||
await openPanel(comfyPage)
|
||||
await typeAndEnter(comfyPage, 'run-js return 1 + 2')
|
||||
await expect.poll(() => readTerminalText(comfyPage)).toMatch(/\b3\b/)
|
||||
})
|
||||
|
||||
test('graph summary reports node count for the active graph', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
await openPanel(comfyPage)
|
||||
await typeAndEnter(comfyPage, 'graph summary')
|
||||
await expect
|
||||
.poll(() => readTerminalText(comfyPage))
|
||||
.toMatch(/node|count|nodes/i)
|
||||
})
|
||||
|
||||
test('queue-status command returns output', async ({ comfyPage }) => {
|
||||
await openPanel(comfyPage)
|
||||
await typeAndEnter(comfyPage, 'queue-status')
|
||||
await expect
|
||||
.poll(() => readTerminalText(comfyPage))
|
||||
.toMatch(/running|pending|queue/i)
|
||||
})
|
||||
|
||||
test('active-workflow reports path / state', async ({ comfyPage }) => {
|
||||
await openPanel(comfyPage)
|
||||
await typeAndEnter(comfyPage, 'active-workflow')
|
||||
await expect
|
||||
.poll(() => readTerminalText(comfyPage))
|
||||
.toMatch(/path|modified|persisted|none/i)
|
||||
})
|
||||
|
||||
test('pipe: echo foo | wc -c emits a byte count', async ({ comfyPage }) => {
|
||||
await openPanel(comfyPage)
|
||||
await typeAndEnter(comfyPage, 'echo foo | wc -c')
|
||||
// "foo\n" = 4 bytes
|
||||
await expect.poll(() => readTerminalText(comfyPage)).toMatch(/\b4\b/)
|
||||
})
|
||||
|
||||
test('unknown command surfaces an error', async ({ comfyPage }) => {
|
||||
await openPanel(comfyPage)
|
||||
await typeAndEnter(comfyPage, 'definitely-not-a-real-command-xyz')
|
||||
await expect
|
||||
.poll(() => readTerminalText(comfyPage))
|
||||
.toMatch(/not found|unknown|no such/i)
|
||||
})
|
||||
|
||||
test('Ctrl+O folds and unfolds tool blocks', async ({ comfyPage }) => {
|
||||
await openPanel(comfyPage)
|
||||
await typeAndEnter(comfyPage, 'graph summary')
|
||||
// Tool blocks default to folded — body shouldn't be visible yet.
|
||||
const panel = comfyPage.page.getByTestId('agent-panel')
|
||||
await expect(
|
||||
panel.locator('button:has-text("graph summary")')
|
||||
).toBeVisible()
|
||||
|
||||
// Ctrl+O expands all
|
||||
await comfyPage.page.keyboard.press('Control+o')
|
||||
await expect.poll(() => readTerminalText(comfyPage)).toMatch(/nodes|types/i)
|
||||
|
||||
// Ctrl+O folds all back — `nodes:` from the body should be hidden again.
|
||||
await comfyPage.page.keyboard.press('Control+o')
|
||||
})
|
||||
})
|
||||
@@ -772,119 +772,3 @@ test.describe('Assets sidebar - delete confirmation', () => {
|
||||
await expect(tab.assetCards).toHaveCount(initialCount)
|
||||
})
|
||||
})
|
||||
|
||||
// ==========================================================================
|
||||
// 12. Media type filter (cloud-only)
|
||||
// ==========================================================================
|
||||
|
||||
const MIXED_MEDIA_JOBS: RawJobListItem[] = [
|
||||
createMockJob({
|
||||
id: 'job-image',
|
||||
create_time: 1000,
|
||||
execution_start_time: 1000,
|
||||
execution_end_time: 1010,
|
||||
preview_output: {
|
||||
filename: 'photo.png',
|
||||
subfolder: '',
|
||||
type: 'output',
|
||||
nodeId: '1',
|
||||
mediaType: 'images'
|
||||
},
|
||||
outputs_count: 1
|
||||
}),
|
||||
createMockJob({
|
||||
id: 'job-video',
|
||||
create_time: 2000,
|
||||
execution_start_time: 2000,
|
||||
execution_end_time: 2010,
|
||||
preview_output: {
|
||||
filename: 'clip.mp4',
|
||||
subfolder: '',
|
||||
type: 'output',
|
||||
nodeId: '2',
|
||||
mediaType: 'video'
|
||||
},
|
||||
outputs_count: 1
|
||||
}),
|
||||
createMockJob({
|
||||
id: 'job-audio',
|
||||
create_time: 3000,
|
||||
execution_start_time: 3000,
|
||||
execution_end_time: 3010,
|
||||
preview_output: {
|
||||
filename: 'track.mp3',
|
||||
subfolder: '',
|
||||
type: 'output',
|
||||
nodeId: '3',
|
||||
mediaType: 'audio'
|
||||
},
|
||||
outputs_count: 1
|
||||
})
|
||||
]
|
||||
|
||||
// Filter button is guarded by isCloud (compile-time). The cloud CI project
|
||||
// cannot use comfyPageFixture (auth required). Enable once cloud E2E infra
|
||||
// supports authenticated comfyPage setup.
|
||||
test.describe('Assets sidebar - media type filter', () => {
|
||||
test.fixme(true, 'Requires DISTRIBUTION=cloud build with auth bypass')
|
||||
|
||||
test.beforeEach(async ({ comfyPage }) => {
|
||||
await comfyPage.assets.mockOutputHistory(MIXED_MEDIA_JOBS)
|
||||
await comfyPage.assets.mockInputFiles([])
|
||||
await comfyPage.setup()
|
||||
})
|
||||
|
||||
test.afterEach(async ({ comfyPage }) => {
|
||||
await comfyPage.assets.clearMocks()
|
||||
})
|
||||
|
||||
test('Filter menu shows media type options', async ({ comfyPage }) => {
|
||||
const tab = comfyPage.menu.assetsTab
|
||||
await tab.open()
|
||||
|
||||
await tab.openFilterMenu()
|
||||
|
||||
await expect(tab.filterCheckbox('Image')).toBeVisible()
|
||||
await expect(tab.filterCheckbox('Video')).toBeVisible()
|
||||
await expect(tab.filterCheckbox('Audio')).toBeVisible()
|
||||
await expect(tab.filterCheckbox('3D')).toBeVisible()
|
||||
})
|
||||
|
||||
test('Unchecking image filter hides image assets', async ({ comfyPage }) => {
|
||||
const tab = comfyPage.menu.assetsTab
|
||||
await tab.open()
|
||||
await tab.waitForAssets()
|
||||
|
||||
const initialCount = tab.assetCards
|
||||
await expect(
|
||||
initialCount,
|
||||
'All three mixed-media jobs should render'
|
||||
).toHaveCount(3)
|
||||
|
||||
// Open filter menu and enable only image filter (selecting a filter
|
||||
// restricts to that type only, hiding unselected types)
|
||||
await tab.openFilterMenu()
|
||||
await tab.filterCheckbox('Image').click()
|
||||
|
||||
// Only the image asset should remain
|
||||
await expect(tab.assetCards).toHaveCount(1, { timeout: 5000 })
|
||||
await expect(tab.getAssetCardByName('photo.png')).toBeVisible()
|
||||
})
|
||||
|
||||
test('Re-enabling filter restores hidden assets', async ({ comfyPage }) => {
|
||||
const tab = comfyPage.menu.assetsTab
|
||||
await tab.open()
|
||||
await tab.waitForAssets()
|
||||
|
||||
const initialCount = await tab.assetCards.count()
|
||||
|
||||
// Enable image filter to restrict to images only
|
||||
await tab.openFilterMenu()
|
||||
await tab.filterCheckbox('Image').click()
|
||||
await expect(tab.assetCards).toHaveCount(1, { timeout: 5000 })
|
||||
|
||||
// Uncheck image filter to remove all filters (restores all assets)
|
||||
await tab.filterCheckbox('Image').click()
|
||||
await expect(tab.assetCards).toHaveCount(initialCount, { timeout: 5000 })
|
||||
})
|
||||
})
|
||||
|
||||
@@ -251,7 +251,7 @@ test.describe('Subgraph Breadcrumb', { tag: ['@subgraph'] }, () => {
|
||||
await comfyPage.workflow.loadWorkflow(NESTED_WORKFLOW)
|
||||
await enterNestedSubgraphs(comfyPage)
|
||||
|
||||
await expect(subgraphBreadcrumb.panel.rootItem).toBeAttached()
|
||||
await expect(subgraphBreadcrumb.panel.rootItem()).toBeAttached()
|
||||
await expect(
|
||||
subgraphBreadcrumb.panel.subgraphItem(SUBGRAPH_2_ID)
|
||||
).toContainText(SUBGRAPH_2_NAME)
|
||||
@@ -265,65 +265,12 @@ test.describe('Subgraph Breadcrumb', { tag: ['@subgraph'] }, () => {
|
||||
)
|
||||
})
|
||||
|
||||
test(
|
||||
'shows Blueprint tag only when editing a published blueprint',
|
||||
{
|
||||
tag: ['@vue-nodes']
|
||||
},
|
||||
async ({ comfyPage, subgraphBreadcrumb }) => {
|
||||
const { panel } = subgraphBreadcrumb
|
||||
const blueprintName = `bp-breadcrumb-tag-${Date.now()}`
|
||||
|
||||
await test.step('Tag is not shown on a normal workflow', async () => {
|
||||
await expect(panel.blueprintTag).toHaveCount(0)
|
||||
})
|
||||
|
||||
await test.step('Convert to Subgraph', async () => {
|
||||
const ksampler = await comfyPage.vueNodes.getFixtureByTitle('KSampler')
|
||||
await comfyPage.contextMenu.openForVueNode(ksampler.header)
|
||||
await comfyPage.contextMenu.clickMenuItemExact('Convert to Subgraph')
|
||||
})
|
||||
|
||||
const subgraphNodeId = await comfyPage.subgraph.findSubgraphNodeId()
|
||||
const subgraphNode =
|
||||
await comfyPage.nodeOps.getNodeRefById(subgraphNodeId)
|
||||
|
||||
await test.step('Unpublished subgraph does not show the blueprint tag', async () => {
|
||||
await subgraphNode.centerOnNode()
|
||||
await comfyPage.vueNodes.enterSubgraph(subgraphNodeId)
|
||||
await expect.poll(() => comfyPage.subgraph.isInSubgraph()).toBe(true)
|
||||
await expect(panel.blueprintTag).toHaveCount(0)
|
||||
await comfyPage.subgraph.exitViaBreadcrumb()
|
||||
})
|
||||
|
||||
await test.step('Publish the subgraph as a blueprint', async () => {
|
||||
await subgraphNode.click('title')
|
||||
await comfyPage.subgraph.publishSubgraph(blueprintName)
|
||||
})
|
||||
|
||||
await test.step('Open the blueprint from the node library', async () => {
|
||||
const tab = comfyPage.menu.nodeLibraryTabV2
|
||||
await tab.open()
|
||||
await tab.getFolder('My Blueprints').click()
|
||||
await tab.getFolder('User').click()
|
||||
|
||||
const blueprintNode = tab.getNode(blueprintName)
|
||||
await expect(blueprintNode).toBeVisible()
|
||||
await blueprintNode.getByRole('button', { name: 'Edit' }).click()
|
||||
})
|
||||
|
||||
await test.step('Blueprint tag renders on the root breadcrumb', async () => {
|
||||
await expect(panel.rootBlueprintTag).toBeVisible()
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
test('collapses when overflowing and expands when there is room', async ({
|
||||
comfyPage,
|
||||
subgraphBreadcrumb
|
||||
}) => {
|
||||
const { panel } = subgraphBreadcrumb
|
||||
const rootItem = panel.rootItem
|
||||
const rootItem = panel.rootItem()
|
||||
const subgraph2Item = panel.subgraphItem(SUBGRAPH_2_ID)
|
||||
const subgraph3Item = panel.subgraphItem(SUBGRAPH_3_ID)
|
||||
const originalViewport = comfyPage.page.viewportSize()
|
||||
|
||||
@@ -196,48 +196,6 @@ test.describe('Image Crop', { tag: ['@widget', '@vue-nodes'] }, () => {
|
||||
})
|
||||
.toStrictEqual(before)
|
||||
})
|
||||
|
||||
test('Selecting a ratio preset auto-enables aspect ratio lock', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const node = comfyPage.vueNodes.getNodeLocator('1')
|
||||
|
||||
await expect(
|
||||
node.getByRole('button', { name: 'Lock aspect ratio' }),
|
||||
'lock button should start in unlocked state'
|
||||
).toBeVisible()
|
||||
|
||||
await node.getByRole('combobox').click()
|
||||
await comfyPage.page
|
||||
.getByRole('option', { name: '4:3', exact: true })
|
||||
.click()
|
||||
|
||||
await expect(
|
||||
node.getByRole('button', { name: 'Unlock aspect ratio' }),
|
||||
'selecting a preset should auto-lock the ratio'
|
||||
).toBeVisible()
|
||||
})
|
||||
|
||||
test('Unlocking after a preset selection shows Custom in ratio dropdown', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const node = comfyPage.vueNodes.getNodeLocator('1')
|
||||
|
||||
await node.getByRole('combobox').click()
|
||||
await comfyPage.page
|
||||
.getByRole('option', { name: '1:1', exact: true })
|
||||
.click()
|
||||
await expect(
|
||||
node.getByRole('button', { name: 'Unlock aspect ratio' })
|
||||
).toBeVisible()
|
||||
|
||||
await node.getByRole('button', { name: 'Unlock aspect ratio' }).click()
|
||||
|
||||
await expect(
|
||||
node.getByRole('combobox'),
|
||||
'dropdown should revert to Custom after unlock'
|
||||
).toContainText('Custom')
|
||||
})
|
||||
})
|
||||
|
||||
test.describe(
|
||||
@@ -855,339 +813,6 @@ test.describe('Image Crop', { tag: ['@widget', '@vue-nodes'] }, () => {
|
||||
await comfyPage.page.unroute('**/api/view**')
|
||||
}
|
||||
})
|
||||
|
||||
test('Selecting 16:9 ratio adjusts crop height proportionally', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const node = comfyPage.vueNodes.getNodeLocator('2')
|
||||
await setCropBounds(comfyPage, 2, {
|
||||
x: 50,
|
||||
y: 50,
|
||||
width: 360,
|
||||
height: 360
|
||||
})
|
||||
|
||||
const before = await getCropValue(comfyPage, 2)
|
||||
if (!before) throw new Error('missing crop')
|
||||
const expectedHeight = Math.round(before.width / (16 / 9))
|
||||
|
||||
await node.getByRole('combobox').click()
|
||||
await comfyPage.page
|
||||
.getByRole('option', { name: '16:9', exact: true })
|
||||
.click()
|
||||
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
const v = await getCropValue(comfyPage, 2)
|
||||
if (!v || v.width !== before.width) return false
|
||||
return Math.abs(v.height - expectedHeight) <= 2
|
||||
},
|
||||
{ message: '16:9 ratio should adjust crop height proportionally' }
|
||||
)
|
||||
.toBe(true)
|
||||
})
|
||||
|
||||
test('Selecting Custom from ratio dropdown unlocks aspect ratio', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const node = comfyPage.vueNodes.getNodeLocator('2')
|
||||
await setCropBounds(comfyPage, 2, {
|
||||
x: 50,
|
||||
y: 50,
|
||||
width: 200,
|
||||
height: 200
|
||||
})
|
||||
|
||||
await node.getByRole('combobox').click()
|
||||
await comfyPage.page
|
||||
.getByRole('option', { name: '1:1', exact: true })
|
||||
.click()
|
||||
await expect(
|
||||
node
|
||||
.locator('[data-testid^="crop-resize-"]')
|
||||
.filter({ visible: true }),
|
||||
'preset selection should lock ratio and show 4 handles'
|
||||
).toHaveCount(4)
|
||||
|
||||
await node.getByRole('combobox').click()
|
||||
await comfyPage.page
|
||||
.getByRole('option', { name: 'Custom', exact: true })
|
||||
.click()
|
||||
|
||||
await expect(
|
||||
node
|
||||
.locator('[data-testid^="crop-resize-"]')
|
||||
.filter({ visible: true }),
|
||||
'selecting Custom should unlock ratio and restore 8 handles'
|
||||
).toHaveCount(8)
|
||||
})
|
||||
|
||||
test('Unlock button releases locked ratio and restores all 8 resize handles', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const node = comfyPage.vueNodes.getNodeLocator('2')
|
||||
|
||||
await node.getByRole('button', { name: 'Lock aspect ratio' }).click()
|
||||
|
||||
await expect(
|
||||
node
|
||||
.locator('[data-testid^="crop-resize-"]')
|
||||
.filter({ visible: true }),
|
||||
'lock should reduce handles to 4'
|
||||
).toHaveCount(4)
|
||||
await expect(
|
||||
node.getByRole('button', { name: 'Unlock aspect ratio' }),
|
||||
'lock button aria-label should update after locking'
|
||||
).toBeVisible()
|
||||
|
||||
await node.getByRole('button', { name: 'Unlock aspect ratio' }).click()
|
||||
|
||||
await expect(
|
||||
node
|
||||
.locator('[data-testid^="crop-resize-"]')
|
||||
.filter({ visible: true }),
|
||||
'unlock should restore all 8 handles'
|
||||
).toHaveCount(8)
|
||||
await expect(
|
||||
node.getByRole('button', { name: 'Lock aspect ratio' }),
|
||||
'lock button aria-label should revert after unlocking'
|
||||
).toBeVisible()
|
||||
})
|
||||
|
||||
test('Constrained resize from NW corner adjusts origin and dimensions proportionally', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const node = comfyPage.vueNodes.getNodeLocator('2')
|
||||
await setCropBounds(comfyPage, 2, {
|
||||
x: 150,
|
||||
y: 140,
|
||||
width: 200,
|
||||
height: 150
|
||||
})
|
||||
await node.getByRole('button', { name: 'Lock aspect ratio' }).click()
|
||||
|
||||
const before = await getCropValue(comfyPage, 2)
|
||||
if (!before) throw new Error('missing crop')
|
||||
const ratio = before.width / before.height
|
||||
|
||||
await dragOnLocator(
|
||||
comfyPage,
|
||||
node.getByTestId('crop-resize-nw'),
|
||||
-45,
|
||||
-35
|
||||
)
|
||||
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
const v = await getCropValue(comfyPage, 2)
|
||||
if (!v) return false
|
||||
return (
|
||||
v.x < before.x &&
|
||||
v.y < before.y &&
|
||||
v.width > before.width &&
|
||||
v.height > before.height &&
|
||||
Math.abs(v.width / v.height - ratio) < 0.06
|
||||
)
|
||||
},
|
||||
{
|
||||
message:
|
||||
'constrained NW resize should grow box and maintain aspect ratio'
|
||||
}
|
||||
)
|
||||
.toBe(true)
|
||||
})
|
||||
|
||||
test('Constrained resize clamps to image boundary while maintaining ratio', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const node = comfyPage.vueNodes.getNodeLocator('2')
|
||||
const img = node.locator('img')
|
||||
await waitForImageNaturalSize(img)
|
||||
const { nw, nh } = await img.evaluate((el: HTMLImageElement) => ({
|
||||
nw: el.naturalWidth,
|
||||
nh: el.naturalHeight
|
||||
}))
|
||||
|
||||
await setCropBounds(comfyPage, 2, {
|
||||
x: nw - 100,
|
||||
y: nh - 75,
|
||||
width: 80,
|
||||
height: 60
|
||||
})
|
||||
await node.getByRole('button', { name: 'Lock aspect ratio' }).click()
|
||||
|
||||
const before = await getCropValue(comfyPage, 2)
|
||||
if (!before) throw new Error('missing crop')
|
||||
const initialRatio = before.width / before.height
|
||||
|
||||
await dragOnLocator(
|
||||
comfyPage,
|
||||
node.getByTestId('crop-resize-se'),
|
||||
600,
|
||||
400
|
||||
)
|
||||
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
const v = await getCropValue(comfyPage, 2)
|
||||
if (!v) return false
|
||||
const withinBounds = v.x + v.width <= nw && v.y + v.height <= nh
|
||||
const ratio = v.width / v.height
|
||||
const ratioPreserved = Math.abs(ratio - initialRatio) < 0.05
|
||||
return withinBounds && ratioPreserved
|
||||
},
|
||||
{
|
||||
message:
|
||||
'constrained resize should stay within image boundaries and preserve aspect ratio'
|
||||
}
|
||||
)
|
||||
.toBe(true)
|
||||
})
|
||||
|
||||
test('Constrained NW corner resize clamps at top-left image boundary', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const node = comfyPage.vueNodes.getNodeLocator('2')
|
||||
await setCropBounds(comfyPage, 2, {
|
||||
x: 30,
|
||||
y: 25,
|
||||
width: 160,
|
||||
height: 120
|
||||
})
|
||||
await node.getByRole('button', { name: 'Lock aspect ratio' }).click()
|
||||
|
||||
await dragOnLocator(
|
||||
comfyPage,
|
||||
node.getByTestId('crop-resize-nw'),
|
||||
-400,
|
||||
-300
|
||||
)
|
||||
|
||||
await expect
|
||||
.poll(async () => (await getCropValue(comfyPage, 2))?.x ?? -1, {
|
||||
message: 'constrained NW resize should clamp x to image boundary'
|
||||
})
|
||||
.toBeGreaterThanOrEqual(0)
|
||||
await expect
|
||||
.poll(async () => (await getCropValue(comfyPage, 2))?.y ?? -1, {
|
||||
message: 'constrained NW resize should clamp y to image boundary'
|
||||
})
|
||||
.toBeGreaterThanOrEqual(0)
|
||||
})
|
||||
|
||||
test('Constrained resize enforces minimum crop size', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const node = comfyPage.vueNodes.getNodeLocator('2')
|
||||
await setCropBounds(comfyPage, 2, {
|
||||
x: 100,
|
||||
y: 100,
|
||||
width: 60,
|
||||
height: 60
|
||||
})
|
||||
await node.getByRole('button', { name: 'Lock aspect ratio' }).click()
|
||||
|
||||
await dragOnLocator(
|
||||
comfyPage,
|
||||
node.getByTestId('crop-resize-se'),
|
||||
-300,
|
||||
-300
|
||||
)
|
||||
|
||||
await expect
|
||||
.poll(async () => (await getCropValue(comfyPage, 2))?.width ?? 0, {
|
||||
message: 'constrained resize should respect minimum width'
|
||||
})
|
||||
.toBeGreaterThanOrEqual(MIN_CROP_SIZE)
|
||||
await expect
|
||||
.poll(async () => (await getCropValue(comfyPage, 2))?.height ?? 0, {
|
||||
message: 'constrained resize should respect minimum height'
|
||||
})
|
||||
.toBeGreaterThanOrEqual(MIN_CROP_SIZE)
|
||||
})
|
||||
|
||||
test('Incrementing X in BoundingBox moves crop box right', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const node = comfyPage.vueNodes.getNodeLocator('2')
|
||||
await setCropBounds(comfyPage, 2, {
|
||||
x: 100,
|
||||
y: 80,
|
||||
width: 200,
|
||||
height: 150
|
||||
})
|
||||
|
||||
const before = await getCropValue(comfyPage, 2)
|
||||
if (!before) throw new Error('missing crop')
|
||||
|
||||
await node
|
||||
.getByTestId('bounding-box-x')
|
||||
.getByTestId('increment')
|
||||
.click()
|
||||
|
||||
await expect
|
||||
.poll(async () => (await getCropValue(comfyPage, 2))?.x, {
|
||||
message: 'incrementing X should move crop right by 1'
|
||||
})
|
||||
.toBe(before.x + 1)
|
||||
})
|
||||
|
||||
test('Incrementing Width in BoundingBox increases crop width', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const node = comfyPage.vueNodes.getNodeLocator('2')
|
||||
await setCropBounds(comfyPage, 2, {
|
||||
x: 100,
|
||||
y: 80,
|
||||
width: 200,
|
||||
height: 150
|
||||
})
|
||||
|
||||
const before = await getCropValue(comfyPage, 2)
|
||||
if (!before) throw new Error('missing crop')
|
||||
|
||||
await node
|
||||
.getByTestId('bounding-box-width')
|
||||
.getByTestId('increment')
|
||||
.click()
|
||||
|
||||
await expect
|
||||
.poll(async () => (await getCropValue(comfyPage, 2))?.width, {
|
||||
message: 'incrementing Width should increase crop width by 1'
|
||||
})
|
||||
.toBe(before.width + 1)
|
||||
})
|
||||
|
||||
test('BoundingBox numeric inputs reflect crop position after drag', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const node = comfyPage.vueNodes.getNodeLocator('2')
|
||||
await setCropBounds(comfyPage, 2, {
|
||||
x: 50,
|
||||
y: 60,
|
||||
width: 200,
|
||||
height: 150
|
||||
})
|
||||
|
||||
const xInput = node.getByTestId('bounding-box-x').locator('input')
|
||||
|
||||
await expect
|
||||
.poll(async () => Number(await xInput.inputValue()), {
|
||||
message: 'X input should show initial crop x value'
|
||||
})
|
||||
.toBe(50)
|
||||
|
||||
await dragOnLocator(comfyPage, node.getByTestId('crop-overlay'), 40, 20)
|
||||
|
||||
await expect
|
||||
.poll(async () => Number(await xInput.inputValue()), {
|
||||
message: 'X input should update after crop drag'
|
||||
})
|
||||
.toBeGreaterThan(50)
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
import { appendFileSync, existsSync, mkdirSync } from 'fs'
|
||||
import { join } from 'path'
|
||||
import type { Plugin } from 'vite'
|
||||
|
||||
/**
|
||||
* Dev-only Vite plugin: accept POSTs to /__agent-log and append each
|
||||
* JSONL line to a per-session file under ./tmp/agent-logs/.
|
||||
*
|
||||
* Filename: ./tmp/agent-logs/<YYYY-MM-DD>-<sessionId>.jsonl
|
||||
* - <sessionId> is the 8-char id assigned in the browser logger and
|
||||
* attached to every entry. One file per page load makes individual
|
||||
* conversations trivially diff-able and grep-able without sifting
|
||||
* through a daily mixed log.
|
||||
* - Entries without a sessionId fall back to '<date>-orphan.jsonl' so
|
||||
* unattributed lines don't get silently dropped.
|
||||
*
|
||||
* GET /__agent-log → returns the directory + a 1-line summary of recent
|
||||
* session files (debugging aid).
|
||||
*
|
||||
* No-op in production builds (apply: 'serve'). Same origin as the Vite
|
||||
* dev server so the browser-side logger can POST with a simple fetch().
|
||||
*/
|
||||
export function agentLogPlugin(): Plugin {
|
||||
const LOG_DIR = join(process.cwd(), 'tmp', 'agent-logs')
|
||||
|
||||
return {
|
||||
name: 'agent-log',
|
||||
apply: 'serve',
|
||||
configureServer(server) {
|
||||
server.middlewares.use('/__agent-log', (req, res) => {
|
||||
if (req.method === 'GET') {
|
||||
res.setHeader('Content-Type', 'application/json')
|
||||
res.end(JSON.stringify({ dir: LOG_DIR, mode: 'per-session' }))
|
||||
return
|
||||
}
|
||||
|
||||
if (req.method !== 'POST') {
|
||||
res.statusCode = 405
|
||||
res.end()
|
||||
return
|
||||
}
|
||||
|
||||
const chunks: Buffer[] = []
|
||||
req.on('data', (c: Buffer) => chunks.push(c))
|
||||
req.on('end', () => {
|
||||
try {
|
||||
if (!existsSync(LOG_DIR)) {
|
||||
mkdirSync(LOG_DIR, { recursive: true })
|
||||
}
|
||||
const date = new Date().toISOString().slice(0, 10)
|
||||
const body = Buffer.concat(chunks).toString('utf8')
|
||||
|
||||
// Group lines by sessionId so a single batch carrying multiple
|
||||
// sessions (rare but possible) lands in the right files.
|
||||
const buckets = new Map<string, string[]>()
|
||||
for (const raw of body.split('\n')) {
|
||||
const line = raw.trim()
|
||||
if (!line) continue
|
||||
let sessionId = 'orphan'
|
||||
try {
|
||||
const parsed = JSON.parse(line) as { sessionId?: string }
|
||||
if (
|
||||
parsed.sessionId &&
|
||||
/^[A-Za-z0-9-]{1,64}$/.test(parsed.sessionId)
|
||||
) {
|
||||
sessionId = parsed.sessionId
|
||||
}
|
||||
} catch {
|
||||
// Keep raw text in the orphan bucket; don't drop it.
|
||||
}
|
||||
const arr = buckets.get(sessionId) ?? []
|
||||
arr.push(line)
|
||||
buckets.set(sessionId, arr)
|
||||
}
|
||||
|
||||
for (const [sessionId, lines] of buckets) {
|
||||
const file = join(LOG_DIR, `${date}-${sessionId}.jsonl`)
|
||||
appendFileSync(file, lines.join('\n') + '\n', 'utf8')
|
||||
}
|
||||
res.statusCode = 204
|
||||
res.end()
|
||||
} catch (err) {
|
||||
res.statusCode = 500
|
||||
res.end(err instanceof Error ? err.message : String(err))
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1 @@
|
||||
export { agentLogPlugin } from './agentLog'
|
||||
export { comfyAPIPlugin } from './comfyAPIPlugin'
|
||||
|
||||
@@ -1,164 +0,0 @@
|
||||
# 9. Frontend-only In-app Agent + Future Local-Agent Bridge
|
||||
|
||||
Date: 2026-04-26
|
||||
|
||||
## Status
|
||||
|
||||
Proposed
|
||||
|
||||
## Context
|
||||
|
||||
PR #11547 introduces an experimental in-browser agent (`ComfyAI`) that
|
||||
lets users drive ComfyUI with natural language. It lives entirely in
|
||||
`src/agent/` and runs in the SPA — prompt assembly, tool execution
|
||||
(browser-side `run-js` + Comfy API calls), message storage, and IndexedDB
|
||||
chat history all happen client-side. The LLM is reached directly from
|
||||
the browser via the user's API key (OpenAI / OpenRouter / any
|
||||
OpenAI-compatible gateway), with optional Comfy Cloud auth for the
|
||||
small set of cloud nodes (Tripo / Tencent / Meshy / Gemini).
|
||||
|
||||
This frontend-only architecture is deliberate. It keeps the deployment
|
||||
story trivial (no backend changes), keeps the user's API key out of
|
||||
ComfyUI's backend, and works whether the backend is local or remote.
|
||||
But it raises a coordination problem the moment users want their
|
||||
**other agents** — Claude Code, a self-hosted CLI agent, a teammate's
|
||||
agent on a different machine — to participate in the same conversation,
|
||||
see the same workflow state, or take actions on the user's behalf.
|
||||
|
||||
The forces at play:
|
||||
|
||||
- **Privacy**: API keys must not leak to ComfyUI's backend or to other
|
||||
observers. The frontend-only model makes this trivially true today.
|
||||
- **Source of truth for graph state**: the canonical workflow lives in
|
||||
LiteGraph's in-memory tree inside the SPA. Backend has the queue +
|
||||
history but doesn't track unsaved edits. Any other agent that wants
|
||||
current state must either read from the SPA or read a snapshot the
|
||||
SPA publishes.
|
||||
- **Tool affordance**: the agent's `run_shell` tool currently executes
|
||||
in the browser page context (DOM, stores, fetch with same-origin
|
||||
cookies). A local agent has none of that — it would need either a
|
||||
separate REST surface or to drive the SPA remotely.
|
||||
- **Identity**: the SPA can hold a Comfy Cloud token; a local agent is
|
||||
a separate principal and should hold its own credentials.
|
||||
- **Versioning**: the moment we expose a wire format, breaking changes
|
||||
hurt. Whatever we ship first becomes the contract.
|
||||
|
||||
The question this ADR exists to answer: **how should a local agent
|
||||
participate in the in-app agent's session, given the frontend-only
|
||||
constraint we want to preserve?**
|
||||
|
||||
## Decision
|
||||
|
||||
**Short term (this PR and the next few): keep the agent strictly
|
||||
frontend-only.** Do not add any backend session state, message
|
||||
relaying, or local-agent bridge. The current architecture is small,
|
||||
auditable, and removes whole categories of risk.
|
||||
|
||||
**Long term: when local-agent integration is taken on, prefer Option C
|
||||
("opt-in publish bus with execution staying in the SPA") over the
|
||||
alternatives.** The detailed shape:
|
||||
|
||||
1. Define a small JSON-RPC schema for "agent context" — current
|
||||
workflow id + serialized graph, last N messages, last K tool
|
||||
invocations, agent settings (model + base URL only, never key).
|
||||
Versioned from the start.
|
||||
2. SPA exposes a "Share session" toggle in agent settings. When on,
|
||||
it publishes that snapshot to a configurable WS endpoint
|
||||
(default: `ws://localhost:7437/agent`). The user explicitly opts
|
||||
in per session.
|
||||
3. Provide a tiny reference subscriber library that local agents use
|
||||
to consume. They get **read-only access by default**; getting
|
||||
write access (post a message back into the user's panel) requires
|
||||
the SPA to authorize via a one-time pairing code shown to the
|
||||
user.
|
||||
4. **Tool execution stays in the SPA.** Local agents can _propose_
|
||||
actions ("run this run-js"); the SPA executes and streams the
|
||||
result back. The local agent is a peer that suggests, not an
|
||||
actor that mutates.
|
||||
|
||||
**Alternatives considered and rejected (for now):**
|
||||
|
||||
- **Option A — ComfyUI backend as session broker.** Push messages to
|
||||
the running ComfyUI server, local agents subscribe via WS or
|
||||
polling. Rejected because ComfyUI is meant to be largely stateless,
|
||||
adding session storage is scope creep, and it puts API keys / chat
|
||||
content in front of the backend (privacy regression).
|
||||
- **Option B — browser extension or local sidecar daemon.** A
|
||||
companion daemon reads the SPA's IndexedDB via Chrome DevTools
|
||||
Protocol, or the SPA opens a localhost WS to it. Rejected as the
|
||||
default path because of the cross-platform packaging burden and
|
||||
because it doesn't help when the local agent runs on a different
|
||||
machine than the SPA.
|
||||
|
||||
**Comfy Cloud creds reuse (a related future work item):** when the
|
||||
user is signed into Comfy Cloud (the `auth_token_comfy_org` flow we
|
||||
already use for Tripo/Gemini), the agent could optionally route LLM
|
||||
calls through a Comfy-managed inference endpoint instead of OpenAI
|
||||
direct. This would gate naturally on the same auth as the cloud
|
||||
nodes and simplifies onboarding for users who don't have their own
|
||||
OpenAI/OpenRouter key. Out of scope here, but worth noting because
|
||||
it interacts with the local-agent identity story above.
|
||||
|
||||
## Consequences
|
||||
|
||||
### Positive
|
||||
|
||||
- **No backend changes today.** PR #11547 lands without touching
|
||||
ComfyUI core. Reviewers don't need to evaluate session-state
|
||||
infrastructure they didn't ask for.
|
||||
- **Privacy posture stays strong.** API keys + chat content stay in
|
||||
the user's browser; ComfyUI backend continues to see only what it
|
||||
always saw (queue prompts, file uploads).
|
||||
- **Future local-agent path is clear** without committing to a
|
||||
protocol prematurely. When we build it, the SPA stays the
|
||||
source-of-truth + execution sandbox; the local agent is a peer that
|
||||
suggests. Mirrors how editors coexist with Claude Code, GitHub
|
||||
Copilot, etc.
|
||||
- **Headroom for multi-subscriber.** Option C naturally supports
|
||||
agent + observer + log-tap subscribers with the same protocol —
|
||||
useful for future debugging tools.
|
||||
- **Versioned wire format** means breaking changes are explicit.
|
||||
|
||||
### Negative
|
||||
|
||||
- **Local agents have no participation today.** Users who want their
|
||||
Claude Code session to see what they're doing in ComfyUI need to
|
||||
copy/paste workflow JSON manually.
|
||||
- **When we do build the bridge, it's net-new infrastructure** — a
|
||||
WS server, a pairing flow, a versioning policy, a reference
|
||||
subscriber library. Not trivial.
|
||||
- **Tool execution stays in the SPA** even after the bridge ships,
|
||||
which means a local agent on a different machine can't `run-js`
|
||||
against the user's session without the SPA being open. (We accept
|
||||
this as a privacy + simplicity tradeoff.)
|
||||
- **The "Share session" toggle is yet another decision the user has
|
||||
to make**, with non-obvious risks. Mitigations: clear UX copy,
|
||||
default off, pairing-code requirement for write access.
|
||||
|
||||
## Notes
|
||||
|
||||
- The frontend-only constraint also drove several smaller decisions
|
||||
in the PR that are worth recording briefly:
|
||||
- Reasoning guardrails (`PROMISSORY_PATTERN`, `vetScript`,
|
||||
`verifyClaims`) live in the SPA in `src/agent/llm/session.ts`,
|
||||
not in a separate service. They survive prompt drift because
|
||||
they're code, not text.
|
||||
- Chat history is persisted via `useIDBKeyval` to IndexedDB. This
|
||||
is a per-browser-profile store; switching profiles or clearing
|
||||
site data wipes history. Acceptable for the experimental phase;
|
||||
if local-agent bridge ships, the snapshot the SPA publishes
|
||||
becomes another effective "external" history mechanism.
|
||||
- The default LLM is `gpt-5.4` via OpenAI's official API. The
|
||||
settings panel exposes a base-URL field so users can target
|
||||
OpenRouter (`https://openrouter.ai/api/v1`) or any OpenAI-compatible
|
||||
gateway. This base-URL flexibility also makes Option C's "Comfy
|
||||
Cloud as inference endpoint" trivially achievable later — it's just
|
||||
another base-URL choice.
|
||||
- Concrete near-term TODOs flagged by this PR's stress-testing,
|
||||
_not_ covered by this ADR but related:
|
||||
- Layer 3 of the reasoning guardrails (structured JSON answers
|
||||
with provenance) needs SDK plumbing to surface tool-call IDs
|
||||
alongside text. Currently deferred.
|
||||
- Verifier registry and shell-idiom blocklist are open
|
||||
registries; entries grow as new failure modes surface in real
|
||||
use.
|
||||
@@ -8,17 +8,16 @@ An Architecture Decision Record captures an important architectural decision mad
|
||||
|
||||
## ADR Index
|
||||
|
||||
| ADR | Title | Status | Date |
|
||||
| ---------------------------------------------------------- | ------------------------------------------------------ | -------- | ---------- |
|
||||
| [0001](0001-merge-litegraph-into-frontend.md) | Merge LiteGraph.js into ComfyUI Frontend | Accepted | 2025-08-05 |
|
||||
| [0002](0002-monorepo-conversion.md) | Restructure as a Monorepo | Accepted | 2025-08-25 |
|
||||
| [0003](0003-crdt-based-layout-system.md) | Centralized Layout Management with CRDT | Proposed | 2025-08-27 |
|
||||
| [0004](0004-fork-primevue-ui-library.md) | Fork PrimeVue UI Library | Rejected | 2025-08-27 |
|
||||
| [0005](0005-remove-importmap-for-vue-extensions.md) | Remove Import Map for Vue Extensions | Accepted | 2025-12-13 |
|
||||
| [0006](0006-primitive-node-copy-paste-lifecycle.md) | PrimitiveNode Copy/Paste Lifecycle | Proposed | 2026-02-22 |
|
||||
| [0007](0007-node-execution-output-passthrough-schema.md) | NodeExecutionOutput Passthrough Schema | Accepted | 2026-03-11 |
|
||||
| [0008](0008-entity-component-system.md) | Entity Component System | Proposed | 2026-03-23 |
|
||||
| [0009](0009-frontend-only-agent-and-local-agent-bridge.md) | Frontend-only In-app Agent + Future Local-Agent Bridge | Proposed | 2026-04-26 |
|
||||
| ADR | Title | Status | Date |
|
||||
| -------------------------------------------------------- | ---------------------------------------- | -------- | ---------- |
|
||||
| [0001](0001-merge-litegraph-into-frontend.md) | Merge LiteGraph.js into ComfyUI Frontend | Accepted | 2025-08-05 |
|
||||
| [0002](0002-monorepo-conversion.md) | Restructure as a Monorepo | Accepted | 2025-08-25 |
|
||||
| [0003](0003-crdt-based-layout-system.md) | Centralized Layout Management with CRDT | Proposed | 2025-08-27 |
|
||||
| [0004](0004-fork-primevue-ui-library.md) | Fork PrimeVue UI Library | Rejected | 2025-08-27 |
|
||||
| [0005](0005-remove-importmap-for-vue-extensions.md) | Remove Import Map for Vue Extensions | Accepted | 2025-12-13 |
|
||||
| [0006](0006-primitive-node-copy-paste-lifecycle.md) | PrimitiveNode Copy/Paste Lifecycle | Proposed | 2026-02-22 |
|
||||
| [0007](0007-node-execution-output-passthrough-schema.md) | NodeExecutionOutput Passthrough Schema | Accepted | 2026-03-11 |
|
||||
| [0008](0008-entity-component-system.md) | Entity Component System | Proposed | 2026-03-23 |
|
||||
|
||||
## Creating a New ADR
|
||||
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
# 案 B: バックエンドの `/features` に `comfy_api_base` を追加する
|
||||
|
||||
## 背景
|
||||
|
||||
ComfyUI バックエンドは `--comfy-api-base` CLI フラグで Comfy Cloud の API ベース URL(prod / staging / カスタム)を選択する。
|
||||
フロントエンドは `__USE_PROD_CONFIG__` ビルド時定数で同じ値を選ぶ。
|
||||
両者が食い違うと、フロントエンドが発行した Firebase トークン(または API キー)が
|
||||
バックエンド経由で別の環境に投げられ、認証や課金が落ちる。
|
||||
|
||||
現状の検出方法(案 A、`src/views/ConnectionPanelView.vue`)は
|
||||
`/api/system_stats` の `system.argv`(CLI 全引数)から `--comfy-api-base` を grep するもの。
|
||||
動くが脆い:
|
||||
|
||||
- 引数の書式(`--flag VALUE` vs `--flag=VALUE`)に依存する
|
||||
- バックエンド側の CLI シグネチャが変わると壊れる
|
||||
- 「公開 API ではない情報」を検出ロジックに使っている
|
||||
|
||||
## 提案
|
||||
|
||||
ComfyUI 本体の `/features` エンドポイントに `comfy_api_base` を追加する。
|
||||
`/features` はすでに「構造化された機能/設定の公開 API」という位置付けがあり、ここに含めるのが自然。
|
||||
|
||||
### バックエンドの実装スケッチ
|
||||
|
||||
```python
|
||||
# tmp/ComfyUI/comfy_api/feature_flags.py:65 付近
|
||||
def get_server_features() -> dict[str, Any]:
|
||||
from comfy.cli_args import args
|
||||
return {
|
||||
...,
|
||||
"comfy_api_base": args.comfy_api_base,
|
||||
}
|
||||
```
|
||||
|
||||
### フロントエンドの変更
|
||||
|
||||
```ts
|
||||
// 例: src/platform/connectionPanel/ あたりに移設
|
||||
const features = await fetch(`${base}/api/features`).then((r) => r.json())
|
||||
const backendCloudBase =
|
||||
features.comfy_api_base ?? parseBackendCloudBase(stats.system?.argv)
|
||||
```
|
||||
|
||||
`features.comfy_api_base` を優先し、未定義の場合のみ `argv` フォールバックを使う。
|
||||
|
||||
## メリット
|
||||
|
||||
- 構造化された公開 API になり、CLI 変更の影響を受けない
|
||||
- 拡張機能 / カスタムノードからも安定して参照できる
|
||||
- 既存の `/features` パターン(ファースト クラスのバックエンド能力公開)に合致
|
||||
- フロントエンドの検出コードが自明になる
|
||||
|
||||
## デメリット
|
||||
|
||||
- `Comfy-Org/ComfyUI` 本体への PR とリリースが必要
|
||||
- リリース前は案 A をフォールバックとして残す必要がある
|
||||
- `comfy_api_base` を「公開してよい情報」と扱う合意が必要
|
||||
(カスタム URL を使うユーザーには内部 URL が露出することになる)
|
||||
|
||||
## ロードマップ
|
||||
|
||||
1. **案 A をフロントエンドに実装(このコミット)**
|
||||
- `ConnectionPanelView.vue` で `/system_stats` の `argv` を解析
|
||||
- 不一致を検出した場合は黄色の警告を表示
|
||||
2. `Comfy-Org/ComfyUI` に `/features` 拡張 PR を提出
|
||||
- `comfy_api/feature_flags.py:65` に `comfy_api_base` を追加
|
||||
3. 本体リリース後、フロントエンドを `features.comfy_api_base` 優先に切替
|
||||
- `argv` フォールバックは互換性のために残す
|
||||
4. 数バージョン後、`argv` フォールバックを削除
|
||||
|
||||
## 関連ファイル
|
||||
|
||||
- ComfyUI 本体: `comfy/cli_args.py:229` — `--comfy-api-base` 引数定義(デフォルト `https://api.comfy.org`)
|
||||
- ComfyUI 本体: `comfy_api/feature_flags.py:65` — `get_server_features()` の現状
|
||||
- ComfyUI 本体: `server.py:646-685` — `/system_stats` ハンドラ(`argv` を返している)
|
||||
- フロントエンド: `src/config/comfyApi.ts:21-31` — `getComfyApiBaseUrl()`(フロント側のビルド時定数)
|
||||
- フロントエンド: `src/views/ConnectionPanelView.vue` — 案 A 実装場所
|
||||
- フロントエンド: `src/platform/remoteConfig/refreshRemoteConfig.ts` — `/features` 既存利用
|
||||
@@ -27,12 +27,7 @@ const commonGlobals = {
|
||||
__COMFYUI_FRONTEND_VERSION__: 'readonly',
|
||||
__COMFYUI_FRONTEND_COMMIT__: 'readonly',
|
||||
__DISTRIBUTION__: 'readonly',
|
||||
__IS_NIGHTLY__: 'readonly',
|
||||
__CI_BRANCH__: 'readonly',
|
||||
__CI_PR_NUMBER__: 'readonly',
|
||||
__CI_PR_AUTHOR__: 'readonly',
|
||||
__CI_RUN_ID__: 'readonly',
|
||||
__CI_JOB_ID__: 'readonly'
|
||||
__IS_NIGHTLY__: 'readonly'
|
||||
} as const
|
||||
|
||||
const settings = {
|
||||
|
||||
5
global.d.ts
vendored
5
global.d.ts
vendored
@@ -2,11 +2,6 @@ declare const __COMFYUI_FRONTEND_VERSION__: string
|
||||
declare const __COMFYUI_FRONTEND_COMMIT__: string
|
||||
declare const __SENTRY_ENABLED__: boolean
|
||||
declare const __SENTRY_DSN__: string
|
||||
declare const __CI_BRANCH__: string
|
||||
declare const __CI_PR_NUMBER__: string
|
||||
declare const __CI_PR_AUTHOR__: string
|
||||
declare const __CI_RUN_ID__: string
|
||||
declare const __CI_JOB_ID__: string
|
||||
declare const __ALGOLIA_APP_ID__: string
|
||||
declare const __ALGOLIA_API_KEY__: string
|
||||
declare const __USE_PROD_CONFIG__: boolean
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@comfyorg/comfyui-frontend",
|
||||
"version": "1.44.10",
|
||||
"version": "1.44.9",
|
||||
"private": true,
|
||||
"description": "Official front-end implementation of ComfyUI",
|
||||
"homepage": "https://comfy.org",
|
||||
@@ -56,7 +56,6 @@
|
||||
"clean": "nx reset"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ai-sdk/openai": "catalog:",
|
||||
"@alloc/quick-lru": "catalog:",
|
||||
"@atlaskit/pragmatic-drag-and-drop": "^1.3.1",
|
||||
"@comfyorg/comfyui-electron-types": "catalog:",
|
||||
@@ -90,7 +89,6 @@
|
||||
"@xterm/addon-fit": "^0.10.0",
|
||||
"@xterm/addon-serialize": "^0.13.0",
|
||||
"@xterm/xterm": "^5.5.0",
|
||||
"ai": "catalog:",
|
||||
"algoliasearch": "catalog:",
|
||||
"axios": "catalog:",
|
||||
"chart.js": "^4.5.0",
|
||||
@@ -103,7 +101,6 @@
|
||||
"firebase": "catalog:",
|
||||
"fuse.js": "^7.0.0",
|
||||
"glob": "catalog:",
|
||||
"idb-keyval": "catalog:",
|
||||
"jsonata": "catalog:",
|
||||
"loglevel": "^1.9.2",
|
||||
"marked": "^15.0.11",
|
||||
@@ -113,7 +110,6 @@
|
||||
"primevue": "catalog:",
|
||||
"reka-ui": "catalog:",
|
||||
"semver": "^7.7.2",
|
||||
"shell-quote": "catalog:",
|
||||
"three": "^0.170.0",
|
||||
"tiptap-markdown": "^0.8.10",
|
||||
"typegpu": "catalog:",
|
||||
@@ -151,7 +147,6 @@
|
||||
"@types/jsdom": "catalog:",
|
||||
"@types/node": "catalog:",
|
||||
"@types/semver": "catalog:",
|
||||
"@types/shell-quote": "catalog:",
|
||||
"@types/three": "catalog:",
|
||||
"@vitejs/plugin-vue": "catalog:",
|
||||
"@vitest/coverage-v8": "catalog:",
|
||||
|
||||
310
pnpm-lock.yaml
generated
310
pnpm-lock.yaml
generated
@@ -6,15 +6,12 @@ settings:
|
||||
|
||||
catalogs:
|
||||
default:
|
||||
'@ai-sdk/openai':
|
||||
specifier: ^3.0.53
|
||||
version: 3.0.53
|
||||
'@alloc/quick-lru':
|
||||
specifier: ^5.2.0
|
||||
version: 5.2.0
|
||||
'@astrojs/check':
|
||||
specifier: ^0.9.8
|
||||
version: 0.9.9
|
||||
version: 0.9.8
|
||||
'@astrojs/sitemap':
|
||||
specifier: ^3.7.1
|
||||
version: 3.7.1
|
||||
@@ -162,9 +159,6 @@ catalogs:
|
||||
'@types/semver':
|
||||
specifier: ^7.7.0
|
||||
version: 7.7.0
|
||||
'@types/shell-quote':
|
||||
specifier: ^1.7.5
|
||||
version: 1.7.5
|
||||
'@types/three':
|
||||
specifier: ^0.169.0
|
||||
version: 0.169.0
|
||||
@@ -189,9 +183,6 @@ catalogs:
|
||||
'@webgpu/types':
|
||||
specifier: ^0.1.66
|
||||
version: 0.1.66
|
||||
ai:
|
||||
specifier: ^6.0.168
|
||||
version: 6.0.168
|
||||
algoliasearch:
|
||||
specifier: ^5.21.0
|
||||
version: 5.21.0
|
||||
@@ -260,16 +251,13 @@ catalogs:
|
||||
version: 16.5.0
|
||||
gsap:
|
||||
specifier: ^3.14.2
|
||||
version: 3.15.0
|
||||
version: 3.14.2
|
||||
happy-dom:
|
||||
specifier: ^20.0.11
|
||||
version: 20.0.11
|
||||
husky:
|
||||
specifier: ^9.1.7
|
||||
version: 9.1.7
|
||||
idb-keyval:
|
||||
specifier: ^6.2.2
|
||||
version: 6.2.2
|
||||
jiti:
|
||||
specifier: 2.6.1
|
||||
version: 2.6.1
|
||||
@@ -284,7 +272,7 @@ catalogs:
|
||||
version: 6.3.1
|
||||
lenis:
|
||||
specifier: ^1.3.21
|
||||
version: 1.3.23
|
||||
version: 1.3.21
|
||||
lint-staged:
|
||||
specifier: ^16.2.7
|
||||
version: 16.4.0
|
||||
@@ -296,7 +284,7 @@ catalogs:
|
||||
version: 2.71.0
|
||||
monocart-coverage-reports:
|
||||
specifier: ^2.12.9
|
||||
version: 2.12.11
|
||||
version: 2.12.9
|
||||
nx:
|
||||
specifier: 22.6.1
|
||||
version: 22.6.1
|
||||
@@ -336,9 +324,6 @@ catalogs:
|
||||
rollup-plugin-visualizer:
|
||||
specifier: ^6.0.4
|
||||
version: 6.0.4
|
||||
shell-quote:
|
||||
specifier: ^1.8.3
|
||||
version: 1.8.3
|
||||
storybook:
|
||||
specifier: ^10.2.10
|
||||
version: 10.2.10
|
||||
@@ -431,9 +416,6 @@ importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
'@ai-sdk/openai':
|
||||
specifier: 'catalog:'
|
||||
version: 3.0.53(zod@3.25.76)
|
||||
'@alloc/quick-lru':
|
||||
specifier: 'catalog:'
|
||||
version: 5.2.0
|
||||
@@ -520,7 +502,7 @@ importers:
|
||||
version: 14.2.0(vue@3.5.13(typescript@5.9.3))
|
||||
'@vueuse/integrations':
|
||||
specifier: 'catalog:'
|
||||
version: 14.2.0(axios@1.13.5)(fuse.js@7.0.0)(idb-keyval@6.2.2)(vue@3.5.13(typescript@5.9.3))
|
||||
version: 14.2.0(axios@1.13.5)(fuse.js@7.0.0)(vue@3.5.13(typescript@5.9.3))
|
||||
'@vueuse/router':
|
||||
specifier: ^14.2.0
|
||||
version: 14.2.1(vue-router@4.4.3(vue@3.5.13(typescript@5.9.3)))(vue@3.5.13(typescript@5.9.3))
|
||||
@@ -533,9 +515,6 @@ importers:
|
||||
'@xterm/xterm':
|
||||
specifier: ^5.5.0
|
||||
version: 5.5.0
|
||||
ai:
|
||||
specifier: 'catalog:'
|
||||
version: 6.0.168(zod@3.25.76)
|
||||
algoliasearch:
|
||||
specifier: 'catalog:'
|
||||
version: 5.21.0
|
||||
@@ -572,9 +551,6 @@ importers:
|
||||
glob:
|
||||
specifier: 'catalog:'
|
||||
version: 13.0.6
|
||||
idb-keyval:
|
||||
specifier: 'catalog:'
|
||||
version: 6.2.2
|
||||
jsonata:
|
||||
specifier: 'catalog:'
|
||||
version: 2.1.0
|
||||
@@ -602,9 +578,6 @@ importers:
|
||||
semver:
|
||||
specifier: ^7.7.2
|
||||
version: 7.7.4
|
||||
shell-quote:
|
||||
specifier: 'catalog:'
|
||||
version: 1.8.3
|
||||
three:
|
||||
specifier: ^0.170.0
|
||||
version: 0.170.0
|
||||
@@ -711,9 +684,6 @@ importers:
|
||||
'@types/semver':
|
||||
specifier: 'catalog:'
|
||||
version: 7.7.0
|
||||
'@types/shell-quote':
|
||||
specifier: 'catalog:'
|
||||
version: 1.7.5
|
||||
'@types/three':
|
||||
specifier: 'catalog:'
|
||||
version: 0.169.0
|
||||
@@ -800,7 +770,7 @@ importers:
|
||||
version: 2.71.0
|
||||
monocart-coverage-reports:
|
||||
specifier: 'catalog:'
|
||||
version: 2.12.11
|
||||
version: 2.12.9
|
||||
nx:
|
||||
specifier: 'catalog:'
|
||||
version: 22.6.1
|
||||
@@ -975,23 +945,20 @@ importers:
|
||||
version: 1.0.0-beta.4(typescript@5.9.3)
|
||||
gsap:
|
||||
specifier: 'catalog:'
|
||||
version: 3.15.0
|
||||
version: 3.14.2
|
||||
lenis:
|
||||
specifier: 'catalog:'
|
||||
version: 1.3.23(react@19.2.4)(vue@3.5.13(typescript@5.9.3))
|
||||
version: 1.3.21(react@19.2.4)(vue@3.5.13(typescript@5.9.3))
|
||||
vue:
|
||||
specifier: 'catalog:'
|
||||
version: 3.5.13(typescript@5.9.3)
|
||||
zod:
|
||||
specifier: 'catalog:'
|
||||
version: 3.25.76
|
||||
devDependencies:
|
||||
'@astrojs/check':
|
||||
specifier: 'catalog:'
|
||||
version: 0.9.9(prettier@3.7.4)(typescript@5.9.3)
|
||||
version: 0.9.8(prettier@3.7.4)(typescript@5.9.3)
|
||||
'@astrojs/vue':
|
||||
specifier: 'catalog:'
|
||||
version: 5.1.4(@types/node@25.0.3)(astro@5.18.1(@types/node@25.0.3)(idb-keyval@6.2.2)(jiti@2.6.1)(rollup@4.53.5)(terser@5.39.2)(tsx@4.19.4)(typescript@5.9.3)(yaml@2.8.2))(esbuild@0.27.3)(jiti@2.6.1)(rollup@4.53.5)(terser@5.39.2)(tsx@4.19.4)(vue@3.5.13(typescript@5.9.3))(yaml@2.8.2)
|
||||
version: 5.1.4(@types/node@25.0.3)(astro@5.18.1(@types/node@25.0.3)(jiti@2.6.1)(rollup@4.53.5)(terser@5.39.2)(tsx@4.19.4)(typescript@5.9.3)(yaml@2.8.2))(esbuild@0.27.3)(jiti@2.6.1)(rollup@4.53.5)(terser@5.39.2)(tsx@4.19.4)(vue@3.5.13(typescript@5.9.3))(yaml@2.8.2)
|
||||
'@playwright/test':
|
||||
specifier: 'catalog:'
|
||||
version: 1.58.1
|
||||
@@ -1000,19 +967,13 @@ importers:
|
||||
version: 4.2.0(vite@8.0.0(@types/node@25.0.3)(esbuild@0.27.3)(jiti@2.6.1)(terser@5.39.2)(tsx@4.19.4)(yaml@2.8.2))
|
||||
astro:
|
||||
specifier: 'catalog:'
|
||||
version: 5.18.1(@types/node@25.0.3)(idb-keyval@6.2.2)(jiti@2.6.1)(rollup@4.53.5)(terser@5.39.2)(tsx@4.19.4)(typescript@5.9.3)(yaml@2.8.2)
|
||||
version: 5.18.1(@types/node@25.0.3)(jiti@2.6.1)(rollup@4.53.5)(terser@5.39.2)(tsx@4.19.4)(typescript@5.9.3)(yaml@2.8.2)
|
||||
tailwindcss:
|
||||
specifier: 'catalog:'
|
||||
version: 4.2.0
|
||||
tsx:
|
||||
specifier: 'catalog:'
|
||||
version: 4.19.4
|
||||
typescript:
|
||||
specifier: 'catalog:'
|
||||
version: 5.9.3
|
||||
vitest:
|
||||
specifier: 'catalog:'
|
||||
version: 4.0.16(@opentelemetry/api@1.9.0)(@types/node@25.0.3)(@vitest/ui@4.0.16)(esbuild@0.27.3)(happy-dom@20.0.11)(jiti@2.6.1)(jsdom@27.4.0)(terser@5.39.2)(tsx@4.19.4)(yaml@2.8.2)
|
||||
|
||||
packages/design-system:
|
||||
dependencies:
|
||||
@@ -1085,28 +1046,6 @@ packages:
|
||||
'@adobe/css-tools@4.4.4':
|
||||
resolution: {integrity: sha512-Elp+iwUx5rN5+Y8xLt5/GRoG20WGoDCQ/1Fb+1LiGtvwbDavuSk0jhD/eZdckHAuzcDzccnkv+rEjyWfRx18gg==}
|
||||
|
||||
'@ai-sdk/gateway@3.0.104':
|
||||
resolution: {integrity: sha512-ZKX5n74io8VIRlhIMSLWVlvT3sXC8Z7cZ9GHuWBWZDVi96+62AIsWuLGvMfcBA1STYuSoDrp6rIziZmvrTq0TA==}
|
||||
engines: {node: '>=18'}
|
||||
peerDependencies:
|
||||
zod: ^3.25.76 || ^4.1.8
|
||||
|
||||
'@ai-sdk/openai@3.0.53':
|
||||
resolution: {integrity: sha512-Wld+Rbc05KaUn08uBt06eEuwcgalcIFtIl32Yp+GxuZXUQwOb6YeAuq+C6da4ch6BurFoqEaLemJVwjBb7x+PQ==}
|
||||
engines: {node: '>=18'}
|
||||
peerDependencies:
|
||||
zod: ^3.25.76 || ^4.1.8
|
||||
|
||||
'@ai-sdk/provider-utils@4.0.23':
|
||||
resolution: {integrity: sha512-z8GlDaCmRSDlqkMF2f4/RFgWxdarvIbyuk+m6WXT1LYgsnGiXRJGTD2Z1+SDl3LqtFuRtGX1aghYvQLoHL/9pg==}
|
||||
engines: {node: '>=18'}
|
||||
peerDependencies:
|
||||
zod: ^3.25.76 || ^4.1.8
|
||||
|
||||
'@ai-sdk/provider@3.0.8':
|
||||
resolution: {integrity: sha512-oGMAgGoQdBXbZqNG0Ze56CHjDZ1IDYOwGYxYjO5KLSlz5HiNQ9udIXsPZ61VWaHGZ5XW/jyjmr6t2xz2jGVwbQ==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
'@alcalzone/ansi-tokenize@0.2.5':
|
||||
resolution: {integrity: sha512-3NX/MpTdroi0aKz134A6RC2Gb2iXVECN4QaAXnvCIxxIm3C3AVB1mkUe8NaaiyvOpDfsrqWhYtj+Q6a62RrTsw==}
|
||||
engines: {node: '>=18'}
|
||||
@@ -1182,11 +1121,11 @@ packages:
|
||||
'@asamuzakjp/nwsapi@2.3.9':
|
||||
resolution: {integrity: sha512-n8GuYSrI9bF7FFZ/SjhwevlHc8xaVlb/7HmHelnc/PZXBD2ZR49NnN9sMMuDdEGPeeRQ5d0hqlSlEpgCX3Wl0Q==}
|
||||
|
||||
'@astrojs/check@0.9.9':
|
||||
resolution: {integrity: sha512-A5UW8uIuErLWEoRQvzgXpO1gTjUFtK8r7nU2Z7GewAMxUb7bPvpk11qaKKgxqXlHJWlAvaaxy+Xg28A6bmQ1Tg==}
|
||||
'@astrojs/check@0.9.8':
|
||||
resolution: {integrity: sha512-LDng8446QLS5ToKjRHd3bgUdirvemVVExV7nRyJfW2wV36xuv7vDxwy5NWN9zqeSEDgg0Tv84sP+T3yEq+Zlkw==}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
typescript: ^5.0.0 || ^6.0.0
|
||||
typescript: ^5.0.0
|
||||
|
||||
'@astrojs/compiler@2.13.1':
|
||||
resolution: {integrity: sha512-f3FN83d2G/v32ipNClRKgYv30onQlMZX1vCeZMjPsMMPl1mDpmbl0+N5BYo4S/ofzqJyS5hvwacEo0CCVDn/Qg==}
|
||||
@@ -1194,8 +1133,8 @@ packages:
|
||||
'@astrojs/internal-helpers@0.7.6':
|
||||
resolution: {integrity: sha512-GOle7smBWKfMSP8osUIGOlB5kaHdQLV3foCsf+5Q9Wsuu+C6Fs3Ez/ttXmhjZ1HkSgsogcM1RXSjjOVieHq16Q==}
|
||||
|
||||
'@astrojs/language-server@2.16.7':
|
||||
resolution: {integrity: sha512-b64bWT74Vq/ORcSqW7TdIjjpB6hcl+Ei/lMANIUaAGlLPiYNtPTRI/j2tzvugT+LoVwfJtE2Ukq/t2OGCyEtfQ==}
|
||||
'@astrojs/language-server@2.16.6':
|
||||
resolution: {integrity: sha512-N990lu+HSFiG57owR0XBkr02BYMgiLCshLf+4QG4v6jjSWkBeQGnzqi+E1L08xFPPJ7eEeXnxPXGLaVv5pa4Ug==}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
prettier: ^3.0.0
|
||||
@@ -4542,9 +4481,6 @@ packages:
|
||||
'@types/semver@7.7.0':
|
||||
resolution: {integrity: sha512-k107IF4+Xr7UHjwDc7Cfd6PRQfbdkiRabXGRjo07b4WyPahFBZCZ1sE+BNxYIJPPg73UkfOsVOLwqVc/6ETrIA==}
|
||||
|
||||
'@types/shell-quote@1.7.5':
|
||||
resolution: {integrity: sha512-+UE8GAGRPbJVQDdxi16dgadcBfQ+KG2vgZhV1+3A1XmHbmwcdwhCUwIdy+d3pAGrbvgRoVSjeI9vOWyq376Yzw==}
|
||||
|
||||
'@types/stats.js@0.17.3':
|
||||
resolution: {integrity: sha512-pXNfAD3KHOdif9EQXZ9deK82HVNaXP5ZIF5RP2QG6OQFNTaY2YIetfrE9t528vEreGQvEPRDDc8muaoYeK0SxQ==}
|
||||
|
||||
@@ -4805,10 +4741,6 @@ packages:
|
||||
vue-router:
|
||||
optional: true
|
||||
|
||||
'@vercel/oidc@3.2.0':
|
||||
resolution: {integrity: sha512-UycprH3T6n3jH0k44NHMa7pnFHGu/N05MjojYr+Mc6I7obkoLIJujSWwin1pCvdy/eOxrI/l3uDLQsmcrOb4ug==}
|
||||
engines: {node: '>= 20'}
|
||||
|
||||
'@vitejs/plugin-vue-jsx@4.2.0':
|
||||
resolution: {integrity: sha512-DSTrmrdLp+0LDNF77fqrKfx7X0ErRbOcUAgJL/HbSesqQwoUvUQ4uYQqaex+rovqgGcoPqVk+AwUh3v9CuiYIw==}
|
||||
engines: {node: ^18.0.0 || >=20.0.0}
|
||||
@@ -5188,12 +5120,6 @@ packages:
|
||||
resolution: {integrity: sha512-kja8j7PjmncONqaTsB8fQ+wE2mSU2DJ9D4XKoJ5PFWIdRMa6SLSN1ff4mOr4jCbfRSsxR4keIiySJU0N9T5hIQ==}
|
||||
engines: {node: '>= 8.0.0'}
|
||||
|
||||
ai@6.0.168:
|
||||
resolution: {integrity: sha512-2HqCJuO+1V2aV7vfYs5LFEUfxbkGX+5oa54q/gCCTL7KLTdbxcCu5D7TdLA5kwsrs3Szgjah9q6D9tpjHM3hUQ==}
|
||||
engines: {node: '>=18'}
|
||||
peerDependencies:
|
||||
zod: ^3.25.76 || ^4.1.8
|
||||
|
||||
ajv-draft-04@1.0.0:
|
||||
resolution: {integrity: sha512-mv00Te6nmYbRp5DCwclxtt7yV/joXJPGS7nM+97GdxvuttCOfgI3K4U25zboyeX0O+myI8ERluxQe5wljMmVIw==}
|
||||
peerDependencies:
|
||||
@@ -5752,8 +5678,8 @@ packages:
|
||||
resolution: {integrity: sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA==}
|
||||
engines: {node: ^14.18.0 || >=16.10.0}
|
||||
|
||||
console-grid@2.2.4:
|
||||
resolution: {integrity: sha512-OLjCRTiHhOpTRo9lQp/2FgJDyq5uQHwkEmVJulEnQ6JVf27oKKzXHZnNOv/e72V4++UdMZCrDWtvXW5sx4lyQg==}
|
||||
console-grid@2.2.3:
|
||||
resolution: {integrity: sha512-+mecFacaFxGl+1G31IsCx41taUXuW2FxX+4xIE0TIPhgML+Jb9JFcBWGhhWerd1/vhScubdmHqTwOhB0KCUUAg==}
|
||||
|
||||
constantinople@4.0.1:
|
||||
resolution: {integrity: sha512-vCrqcSIq4//Gx74TXXCGnHpulY1dskqLTFGDmhrGxzeXL8lF8kvXv6mpNWlJj1uD4DW23D4ljAqbY4RRaaUZIw==}
|
||||
@@ -6447,10 +6373,6 @@ packages:
|
||||
eventemitter3@5.0.4:
|
||||
resolution: {integrity: sha512-mlsTRyGaPBjPedk6Bvw+aqbsXDtoAyAzm5MO7JgU+yVRyMQ5O8bD4Kcci7BS85f93veegeCPkL8R4GLClnjLFw==}
|
||||
|
||||
eventsource-parser@3.0.8:
|
||||
resolution: {integrity: sha512-70QWGkr4snxr0OXLRWsFLeRBIRPuQOvt4s8QYjmUlmlkyTZkRqS7EDVRZtzU3TiyDbXSzaOeF0XUKy8PchzukQ==}
|
||||
engines: {node: '>=18.0.0'}
|
||||
|
||||
execa@9.6.1:
|
||||
resolution: {integrity: sha512-9Be3ZoN4LmYR90tUoVu2te2BsbzHfhJyfEiAVfz7N5/zv+jduIfLrV2xdQXOHbaD6KgpGdO9PRPM1Y4Q9QkPkA==}
|
||||
engines: {node: ^18.19.0 || >=20.5.0}
|
||||
@@ -6608,10 +6530,6 @@ packages:
|
||||
resolution: {integrity: sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==}
|
||||
engines: {node: '>=14'}
|
||||
|
||||
foreground-child@4.0.3:
|
||||
resolution: {integrity: sha512-yeXZaNbCBGaT9giTpLPBdtedzjwhlJBUoL/R4BVQU5mn0TQXOHwVIl1Q2DMuBIdNno4ktA1abZ7dQFVxD6uHxw==}
|
||||
engines: {node: '>=16'}
|
||||
|
||||
form-data-encoder@1.7.2:
|
||||
resolution: {integrity: sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==}
|
||||
|
||||
@@ -6789,8 +6707,8 @@ packages:
|
||||
resolution: {integrity: sha512-5v6yZd4JK3eMI3FqqCouswVqwugaA9r4dNZB1wwcmrD02QkV5H0y7XBQW8QwQqEaZY1pM9aqORSORhJRdNK44Q==}
|
||||
engines: {node: '>=6.0'}
|
||||
|
||||
gsap@3.15.0:
|
||||
resolution: {integrity: sha512-dMW4CWBTUK1AEEDeZc1g4xpPGIrSf9fJF960qbTZmN/QwZIWY5wgliS6JWl9/25fpTGJrMRtSjGtOmPnfjZB+A==}
|
||||
gsap@3.14.2:
|
||||
resolution: {integrity: sha512-P8/mMxVLU7o4+55+1TCnQrPmgjPKnwkzkXOK1asnR9Jg2lna4tEY5qBJjMmAaOBDDZWtlRjBXjLa0w53G/uBLA==}
|
||||
|
||||
h3@1.15.10:
|
||||
resolution: {integrity: sha512-YzJeWSkDZxAhvmp8dexjRK5hxziRO7I9m0N53WhvYL5NiWfkUkzssVzY9jvGu0HBoLFW6+duYmNSn6MaZBCCtg==}
|
||||
@@ -6928,9 +6846,6 @@ packages:
|
||||
engines: {node: '>=18'}
|
||||
hasBin: true
|
||||
|
||||
idb-keyval@6.2.2:
|
||||
resolution: {integrity: sha512-yjD9nARJ/jb1g+CvD0tlhUHOrJ9Sy0P8T9MF3YaLlHnSRpwPfpTX0XIvpmw3gAJUmEu3FiICLBDPXVwyEvrleg==}
|
||||
|
||||
idb@7.1.1:
|
||||
resolution: {integrity: sha512-gchesWBzyvGHRO9W8tzUWFDycow5gwjvFKfyV9FF32Y7F50yZMp7mP+T2mJIWFx49zicqyC4uefHM17o6xKIVQ==}
|
||||
|
||||
@@ -7321,9 +7236,6 @@ packages:
|
||||
json-schema-typed@8.0.2:
|
||||
resolution: {integrity: sha512-fQhoXdcvc3V28x7C7BMs4P5+kNlgUURe2jmUT1T//oBRMDrqy1QPelJimwZGo7Hg9VPV3EQV5Bnq4hbFy2vetA==}
|
||||
|
||||
json-schema@0.4.0:
|
||||
resolution: {integrity: sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==}
|
||||
|
||||
json-stable-stringify-without-jsonify@1.0.1:
|
||||
resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==}
|
||||
|
||||
@@ -7409,8 +7321,8 @@ packages:
|
||||
resolution: {integrity: sha512-7W0vV3rqv5tokqkBAFV1LbR7HPOWzXQDpDgEuib/aJ1jsZZx6x3c2mBI+TJhJzOhkGeaLbCKEHXEXLfirtG2JA==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
lenis@1.3.23:
|
||||
resolution: {integrity: sha512-YxYq3TJqj9sJNv0V9SkyQHejt14xwyIwgDaaMK89Uf9SxQfIszu+gTQSSphh6BWlLTNVKvvXAGkg+Zf+oFIevg==}
|
||||
lenis@1.3.21:
|
||||
resolution: {integrity: sha512-RXWTYm7KQE4Kv8ezxL6wvK0Oiv7aRr6FDo+eNaaniTeu7pLdHokqMIJ5CXO4x5ezvd+9ONdpSFkprLpXsVWmEw==}
|
||||
peerDependencies:
|
||||
'@nuxt/kit': '>=3.0.0'
|
||||
react: '>=17.0.0'
|
||||
@@ -7681,8 +7593,8 @@ packages:
|
||||
resolution: {integrity: sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==}
|
||||
hasBin: true
|
||||
|
||||
lz-utils@2.1.1:
|
||||
resolution: {integrity: sha512-d3Thjos0PSJQAoyMj6vipSSrtrRHS7DImqUNR8x9NW3+zQIftPIbMJAWhi5nPdg5Q9zHz6lxtN8kp/VdMlhi/Q==}
|
||||
lz-utils@2.1.0:
|
||||
resolution: {integrity: sha512-CMkfimAypidTtWjNDxY8a1bc1mJdyEh04V2FfEQ5Zh8Nx4v7k850EYa+dOWGn9hKG5xOyHP5MkuduAZCTHRvJw==}
|
||||
|
||||
magic-string-ast@1.0.3:
|
||||
resolution: {integrity: sha512-CvkkH1i81zl7mmb94DsRiFeG9V2fR2JeuK8yDgS8oiZSFa++wWLEgZ5ufEOyLHbvSbD1gTRKv9NdX69Rnvr9JA==}
|
||||
@@ -7960,12 +7872,12 @@ packages:
|
||||
resolution: {integrity: sha512-4W79zekKGyYU4JXVmB78DOscMFaJth2gGhgfTl2alWE4rNe3nf4N2pqenQ0rEtIewrnD79M687Ouba3YGTLOvg==}
|
||||
engines: {node: '>=18.0.0'}
|
||||
|
||||
monocart-coverage-reports@2.12.11:
|
||||
resolution: {integrity: sha512-yo4/FdUdFIWoc9OjhBZCNXM95tYHS4e8nov9Q3AGbpvteT/W5aQSc4B+Q0nhmedZFvjvm3BUH/Xu9GT2n/0wkw==}
|
||||
monocart-coverage-reports@2.12.9:
|
||||
resolution: {integrity: sha512-vtFqbC3Egl4nVa1FSIrQvMPO6HZtb9lo+3IW7/crdvrLNW2IH8lUsxaK0TsKNmMO2mhFWwqQywLV2CZelqPgwA==}
|
||||
hasBin: true
|
||||
|
||||
monocart-locator@1.0.3:
|
||||
resolution: {integrity: sha512-pe29W2XAoA1WQmZZqxXoP7s06ZEXUhcb81086v68cqjk1HnVL7Q/iU/WJnnetxjPcLqwb4qG8vaSGUOMQU602g==}
|
||||
monocart-locator@1.0.2:
|
||||
resolution: {integrity: sha512-v8W5hJLcWMIxLCcSi/MHh+VeefI+ycFmGz23Froer9QzWjrbg4J3gFJBuI/T1VLNoYxF47bVPPxq8ZlNX4gVCw==}
|
||||
|
||||
mrmime@2.0.1:
|
||||
resolution: {integrity: sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ==}
|
||||
@@ -8334,10 +8246,6 @@ packages:
|
||||
resolution: {integrity: sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
picomatch@4.0.4:
|
||||
resolution: {integrity: sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
pinia@3.0.4:
|
||||
resolution: {integrity: sha512-l7pqLUFTI/+ESXn6k3nu30ZIzW5E2WZF/LaHJEpoq6ElcLD+wduZoB2kBN19du6K/4FDpPMazY2wJr+IndBtQw==}
|
||||
peerDependencies:
|
||||
@@ -8922,10 +8830,6 @@ packages:
|
||||
resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
shell-quote@1.8.3:
|
||||
resolution: {integrity: sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
shiki@3.23.0:
|
||||
resolution: {integrity: sha512-55Dj73uq9ZXL5zyeRPzHQsK7Nbyt6Y10k5s7OjuFZGMhpp4r/rsLBH0o/0fstIzX1Lep9VxefWljK/SKCzygIA==}
|
||||
|
||||
@@ -9257,10 +9161,6 @@ packages:
|
||||
resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
|
||||
tinyglobby@0.2.16:
|
||||
resolution: {integrity: sha512-pn99VhoACYR8nFHhxqix+uvsbXineAasWm5ojXoN8xEwK5Kd3/TrhNn1wByuD52UxWRLy8pu+kRMniEi6Eq9Zg==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
|
||||
tinypool@2.1.0:
|
||||
resolution: {integrity: sha512-Pugqs6M0m7Lv1I7FtxN4aoyToKg1C4tu+/381vH35y8oENM/Ai7f7C4StcoK4/+BSw9ebcS8jRiVrORFKCALLw==}
|
||||
engines: {node: ^20.0.0 || >=22.0.0}
|
||||
@@ -10330,30 +10230,6 @@ snapshots:
|
||||
|
||||
'@adobe/css-tools@4.4.4': {}
|
||||
|
||||
'@ai-sdk/gateway@3.0.104(zod@3.25.76)':
|
||||
dependencies:
|
||||
'@ai-sdk/provider': 3.0.8
|
||||
'@ai-sdk/provider-utils': 4.0.23(zod@3.25.76)
|
||||
'@vercel/oidc': 3.2.0
|
||||
zod: 3.25.76
|
||||
|
||||
'@ai-sdk/openai@3.0.53(zod@3.25.76)':
|
||||
dependencies:
|
||||
'@ai-sdk/provider': 3.0.8
|
||||
'@ai-sdk/provider-utils': 4.0.23(zod@3.25.76)
|
||||
zod: 3.25.76
|
||||
|
||||
'@ai-sdk/provider-utils@4.0.23(zod@3.25.76)':
|
||||
dependencies:
|
||||
'@ai-sdk/provider': 3.0.8
|
||||
'@standard-schema/spec': 1.1.0
|
||||
eventsource-parser: 3.0.8
|
||||
zod: 3.25.76
|
||||
|
||||
'@ai-sdk/provider@3.0.8':
|
||||
dependencies:
|
||||
json-schema: 0.4.0
|
||||
|
||||
'@alcalzone/ansi-tokenize@0.2.5':
|
||||
dependencies:
|
||||
ansi-styles: 6.2.3
|
||||
@@ -10463,9 +10339,9 @@ snapshots:
|
||||
|
||||
'@asamuzakjp/nwsapi@2.3.9': {}
|
||||
|
||||
'@astrojs/check@0.9.9(prettier@3.7.4)(typescript@5.9.3)':
|
||||
'@astrojs/check@0.9.8(prettier@3.7.4)(typescript@5.9.3)':
|
||||
dependencies:
|
||||
'@astrojs/language-server': 2.16.7(prettier@3.7.4)(typescript@5.9.3)
|
||||
'@astrojs/language-server': 2.16.6(prettier@3.7.4)(typescript@5.9.3)
|
||||
chokidar: 4.0.3
|
||||
kleur: 4.1.5
|
||||
typescript: 5.9.3
|
||||
@@ -10478,7 +10354,7 @@ snapshots:
|
||||
|
||||
'@astrojs/internal-helpers@0.7.6': {}
|
||||
|
||||
'@astrojs/language-server@2.16.7(prettier@3.7.4)(typescript@5.9.3)':
|
||||
'@astrojs/language-server@2.16.6(prettier@3.7.4)(typescript@5.9.3)':
|
||||
dependencies:
|
||||
'@astrojs/compiler': 2.13.1
|
||||
'@astrojs/yaml2ts': 0.2.3
|
||||
@@ -10488,7 +10364,7 @@ snapshots:
|
||||
'@volar/language-server': 2.4.28
|
||||
'@volar/language-service': 2.4.28
|
||||
muggle-string: 0.4.1
|
||||
tinyglobby: 0.2.16
|
||||
tinyglobby: 0.2.15
|
||||
volar-service-css: 0.0.70(@volar/language-service@2.4.28)
|
||||
volar-service-emmet: 0.0.70(@volar/language-service@2.4.28)
|
||||
volar-service-html: 0.0.70(@volar/language-service@2.4.28)
|
||||
@@ -10551,12 +10427,12 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@astrojs/vue@5.1.4(@types/node@25.0.3)(astro@5.18.1(@types/node@25.0.3)(idb-keyval@6.2.2)(jiti@2.6.1)(rollup@4.53.5)(terser@5.39.2)(tsx@4.19.4)(typescript@5.9.3)(yaml@2.8.2))(esbuild@0.27.3)(jiti@2.6.1)(rollup@4.53.5)(terser@5.39.2)(tsx@4.19.4)(vue@3.5.13(typescript@5.9.3))(yaml@2.8.2)':
|
||||
'@astrojs/vue@5.1.4(@types/node@25.0.3)(astro@5.18.1(@types/node@25.0.3)(jiti@2.6.1)(rollup@4.53.5)(terser@5.39.2)(tsx@4.19.4)(typescript@5.9.3)(yaml@2.8.2))(esbuild@0.27.3)(jiti@2.6.1)(rollup@4.53.5)(terser@5.39.2)(tsx@4.19.4)(vue@3.5.13(typescript@5.9.3))(yaml@2.8.2)':
|
||||
dependencies:
|
||||
'@vitejs/plugin-vue': 5.2.4(vite@8.0.0(@types/node@25.0.3)(esbuild@0.27.3)(jiti@2.6.1)(terser@5.39.2)(tsx@4.19.4)(yaml@2.8.2))(vue@3.5.13(typescript@5.9.3))
|
||||
'@vitejs/plugin-vue-jsx': 4.2.0(vite@8.0.0(@types/node@25.0.3)(esbuild@0.27.3)(jiti@2.6.1)(terser@5.39.2)(tsx@4.19.4)(yaml@2.8.2))(vue@3.5.13(typescript@5.9.3))
|
||||
'@vue/compiler-sfc': 3.5.28
|
||||
astro: 5.18.1(@types/node@25.0.3)(idb-keyval@6.2.2)(jiti@2.6.1)(rollup@4.53.5)(terser@5.39.2)(tsx@4.19.4)(typescript@5.9.3)(yaml@2.8.2)
|
||||
astro: 5.18.1(@types/node@25.0.3)(jiti@2.6.1)(rollup@4.53.5)(terser@5.39.2)(tsx@4.19.4)(typescript@5.9.3)(yaml@2.8.2)
|
||||
vite: 8.0.0(@types/node@25.0.3)(esbuild@0.27.3)(jiti@2.6.1)(terser@5.39.2)(tsx@4.19.4)(yaml@2.8.2)
|
||||
vite-plugin-vue-devtools: 7.7.9(rollup@4.53.5)(vite@8.0.0(@types/node@25.0.3)(esbuild@0.27.3)(jiti@2.6.1)(terser@5.39.2)(tsx@4.19.4)(yaml@2.8.2))(vue@3.5.13(typescript@5.9.3))
|
||||
vue: 3.5.13(typescript@5.9.3)
|
||||
@@ -13922,8 +13798,6 @@ snapshots:
|
||||
|
||||
'@types/semver@7.7.0': {}
|
||||
|
||||
'@types/shell-quote@1.7.5': {}
|
||||
|
||||
'@types/stats.js@0.17.3': {}
|
||||
|
||||
'@types/three@0.169.0':
|
||||
@@ -14161,8 +14035,6 @@ snapshots:
|
||||
vue: 3.5.13(typescript@5.9.3)
|
||||
vue-router: 4.4.3(vue@3.5.13(typescript@5.9.3))
|
||||
|
||||
'@vercel/oidc@3.2.0': {}
|
||||
|
||||
'@vitejs/plugin-vue-jsx@4.2.0(vite@8.0.0(@types/node@25.0.3)(esbuild@0.27.3)(jiti@2.6.1)(terser@5.39.2)(tsx@4.19.4)(yaml@2.8.2))(vue@3.5.13(typescript@5.9.3))':
|
||||
dependencies:
|
||||
'@babel/core': 7.29.0
|
||||
@@ -14233,14 +14105,6 @@ snapshots:
|
||||
optionalDependencies:
|
||||
vite: 8.0.0(@types/node@24.10.4)(esbuild@0.27.3)(jiti@2.6.1)(terser@5.39.2)(tsx@4.19.4)(yaml@2.8.2)
|
||||
|
||||
'@vitest/mocker@4.0.16(vite@8.0.0(@types/node@25.0.3)(esbuild@0.27.3)(jiti@2.6.1)(terser@5.39.2)(tsx@4.19.4)(yaml@2.8.2))':
|
||||
dependencies:
|
||||
'@vitest/spy': 4.0.16
|
||||
estree-walker: 3.0.3
|
||||
magic-string: 0.30.21
|
||||
optionalDependencies:
|
||||
vite: 8.0.0(@types/node@25.0.3)(esbuild@0.27.3)(jiti@2.6.1)(terser@5.39.2)(tsx@4.19.4)(yaml@2.8.2)
|
||||
|
||||
'@vitest/pretty-format@3.2.4':
|
||||
dependencies:
|
||||
tinyrainbow: 2.0.0
|
||||
@@ -14275,7 +14139,7 @@ snapshots:
|
||||
sirv: 3.0.2
|
||||
tinyglobby: 0.2.15
|
||||
tinyrainbow: 3.0.3
|
||||
vitest: 4.0.16(@opentelemetry/api@1.9.0)(@types/node@25.0.3)(@vitest/ui@4.0.16)(esbuild@0.27.3)(happy-dom@20.0.11)(jiti@2.6.1)(jsdom@27.4.0)(terser@5.39.2)(tsx@4.19.4)(yaml@2.8.2)
|
||||
vitest: 4.0.16(@opentelemetry/api@1.9.0)(@types/node@24.10.4)(@vitest/ui@4.0.16)(esbuild@0.27.3)(happy-dom@20.0.11)(jiti@2.6.1)(jsdom@27.4.0)(terser@5.39.2)(tsx@4.19.4)(yaml@2.8.2)
|
||||
|
||||
'@vitest/utils@3.2.4':
|
||||
dependencies:
|
||||
@@ -14597,7 +14461,7 @@ snapshots:
|
||||
'@vueuse/shared': 14.2.0(vue@3.5.13(typescript@5.9.3))
|
||||
vue: 3.5.13(typescript@5.9.3)
|
||||
|
||||
'@vueuse/integrations@14.2.0(axios@1.13.5)(fuse.js@7.0.0)(idb-keyval@6.2.2)(vue@3.5.13(typescript@5.9.3))':
|
||||
'@vueuse/integrations@14.2.0(axios@1.13.5)(fuse.js@7.0.0)(vue@3.5.13(typescript@5.9.3))':
|
||||
dependencies:
|
||||
'@vueuse/core': 14.2.0(vue@3.5.13(typescript@5.9.3))
|
||||
'@vueuse/shared': 14.2.0(vue@3.5.13(typescript@5.9.3))
|
||||
@@ -14605,7 +14469,6 @@ snapshots:
|
||||
optionalDependencies:
|
||||
axios: 1.13.5
|
||||
fuse.js: 7.0.0
|
||||
idb-keyval: 6.2.2
|
||||
|
||||
'@vueuse/metadata@12.8.2': {}
|
||||
|
||||
@@ -14694,14 +14557,6 @@ snapshots:
|
||||
dependencies:
|
||||
humanize-ms: 1.2.1
|
||||
|
||||
ai@6.0.168(zod@3.25.76):
|
||||
dependencies:
|
||||
'@ai-sdk/gateway': 3.0.104(zod@3.25.76)
|
||||
'@ai-sdk/provider': 3.0.8
|
||||
'@ai-sdk/provider-utils': 4.0.23(zod@3.25.76)
|
||||
'@opentelemetry/api': 1.9.0
|
||||
zod: 3.25.76
|
||||
|
||||
ajv-draft-04@1.0.0(ajv@8.13.0):
|
||||
optionalDependencies:
|
||||
ajv: 8.13.0
|
||||
@@ -14898,7 +14753,7 @@ snapshots:
|
||||
|
||||
astral-regex@2.0.0: {}
|
||||
|
||||
astro@5.18.1(@types/node@25.0.3)(idb-keyval@6.2.2)(jiti@2.6.1)(rollup@4.53.5)(terser@5.39.2)(tsx@4.19.4)(typescript@5.9.3)(yaml@2.8.2):
|
||||
astro@5.18.1(@types/node@25.0.3)(jiti@2.6.1)(rollup@4.53.5)(terser@5.39.2)(tsx@4.19.4)(typescript@5.9.3)(yaml@2.8.2):
|
||||
dependencies:
|
||||
'@astrojs/compiler': 2.13.1
|
||||
'@astrojs/internal-helpers': 0.7.6
|
||||
@@ -14953,7 +14808,7 @@ snapshots:
|
||||
ultrahtml: 1.6.0
|
||||
unifont: 0.7.4
|
||||
unist-util-visit: 5.1.0
|
||||
unstorage: 1.17.4(idb-keyval@6.2.2)
|
||||
unstorage: 1.17.4
|
||||
vfile: 6.0.3
|
||||
vite: 8.0.0(@types/node@25.0.3)(esbuild@0.27.3)(jiti@2.6.1)(terser@5.39.2)(tsx@4.19.4)(yaml@2.8.2)
|
||||
vitefu: 1.1.2(vite@8.0.0(@types/node@25.0.3)(esbuild@0.27.3)(jiti@2.6.1)(terser@5.39.2)(tsx@4.19.4)(yaml@2.8.2))
|
||||
@@ -15413,7 +15268,7 @@ snapshots:
|
||||
|
||||
consola@3.4.2: {}
|
||||
|
||||
console-grid@2.2.4: {}
|
||||
console-grid@2.2.3: {}
|
||||
|
||||
constantinople@4.0.1:
|
||||
dependencies:
|
||||
@@ -16251,8 +16106,6 @@ snapshots:
|
||||
|
||||
eventemitter3@5.0.4: {}
|
||||
|
||||
eventsource-parser@3.0.8: {}
|
||||
|
||||
execa@9.6.1:
|
||||
dependencies:
|
||||
'@sindresorhus/merge-streams': 4.0.0
|
||||
@@ -16355,10 +16208,6 @@ snapshots:
|
||||
optionalDependencies:
|
||||
picomatch: 4.0.3
|
||||
|
||||
fdir@6.5.0(picomatch@4.0.4):
|
||||
optionalDependencies:
|
||||
picomatch: 4.0.4
|
||||
|
||||
fflate@0.4.8: {}
|
||||
|
||||
fflate@0.8.2: {}
|
||||
@@ -16461,10 +16310,6 @@ snapshots:
|
||||
cross-spawn: 7.0.6
|
||||
signal-exit: 4.1.0
|
||||
|
||||
foreground-child@4.0.3:
|
||||
dependencies:
|
||||
signal-exit: 4.1.0
|
||||
|
||||
form-data-encoder@1.7.2: {}
|
||||
|
||||
form-data@4.0.5:
|
||||
@@ -16664,7 +16509,7 @@ snapshots:
|
||||
section-matter: 1.0.0
|
||||
strip-bom-string: 1.0.0
|
||||
|
||||
gsap@3.15.0: {}
|
||||
gsap@3.14.2: {}
|
||||
|
||||
h3@1.15.10:
|
||||
dependencies:
|
||||
@@ -16870,8 +16715,6 @@ snapshots:
|
||||
|
||||
husky@9.1.7: {}
|
||||
|
||||
idb-keyval@6.2.2: {}
|
||||
|
||||
idb@7.1.1: {}
|
||||
|
||||
ieee754@1.2.1: {}
|
||||
@@ -17261,8 +17104,6 @@ snapshots:
|
||||
|
||||
json-schema-typed@8.0.2: {}
|
||||
|
||||
json-schema@0.4.0: {}
|
||||
|
||||
json-stable-stringify-without-jsonify@1.0.1: {}
|
||||
|
||||
json-stable-stringify@1.3.0:
|
||||
@@ -17359,7 +17200,7 @@ snapshots:
|
||||
dependencies:
|
||||
package-json: 10.0.1
|
||||
|
||||
lenis@1.3.23(react@19.2.4)(vue@3.5.13(typescript@5.9.3)):
|
||||
lenis@1.3.21(react@19.2.4)(vue@3.5.13(typescript@5.9.3)):
|
||||
optionalDependencies:
|
||||
react: 19.2.4
|
||||
vue: 3.5.13(typescript@5.9.3)
|
||||
@@ -17568,7 +17409,7 @@ snapshots:
|
||||
|
||||
lz-string@1.5.0: {}
|
||||
|
||||
lz-utils@2.1.1: {}
|
||||
lz-utils@2.1.0: {}
|
||||
|
||||
magic-string-ast@1.0.3:
|
||||
dependencies:
|
||||
@@ -18042,22 +17883,22 @@ snapshots:
|
||||
|
||||
modern-tar@0.7.3: {}
|
||||
|
||||
monocart-coverage-reports@2.12.11:
|
||||
monocart-coverage-reports@2.12.9:
|
||||
dependencies:
|
||||
acorn: 8.16.0
|
||||
acorn-loose: 8.5.2
|
||||
acorn-walk: 8.3.5
|
||||
commander: 14.0.3
|
||||
console-grid: 2.2.4
|
||||
console-grid: 2.2.3
|
||||
eight-colors: 1.3.3
|
||||
foreground-child: 4.0.3
|
||||
foreground-child: 3.3.1
|
||||
istanbul-lib-coverage: 3.2.2
|
||||
istanbul-lib-report: 3.0.1
|
||||
istanbul-reports: 3.2.0
|
||||
lz-utils: 2.1.1
|
||||
monocart-locator: 1.0.3
|
||||
lz-utils: 2.1.0
|
||||
monocart-locator: 1.0.2
|
||||
|
||||
monocart-locator@1.0.3: {}
|
||||
monocart-locator@1.0.2: {}
|
||||
|
||||
mrmime@2.0.1: {}
|
||||
|
||||
@@ -18548,8 +18389,6 @@ snapshots:
|
||||
|
||||
picomatch@4.0.3: {}
|
||||
|
||||
picomatch@4.0.4: {}
|
||||
|
||||
pinia@3.0.4(typescript@5.9.3)(vue@3.5.13(typescript@5.9.3)):
|
||||
dependencies:
|
||||
'@vue/devtools-api': 7.7.9
|
||||
@@ -19374,8 +19213,6 @@ snapshots:
|
||||
|
||||
shebang-regex@3.0.0: {}
|
||||
|
||||
shell-quote@1.8.3: {}
|
||||
|
||||
shiki@3.23.0:
|
||||
dependencies:
|
||||
'@shikijs/core': 3.23.0
|
||||
@@ -19781,11 +19618,6 @@ snapshots:
|
||||
fdir: 6.5.0(picomatch@4.0.3)
|
||||
picomatch: 4.0.3
|
||||
|
||||
tinyglobby@0.2.16:
|
||||
dependencies:
|
||||
fdir: 6.5.0(picomatch@4.0.4)
|
||||
picomatch: 4.0.4
|
||||
|
||||
tinypool@2.1.0: {}
|
||||
|
||||
tinyrainbow@2.0.0: {}
|
||||
@@ -20152,7 +19984,7 @@ snapshots:
|
||||
'@unrs/resolver-binding-win32-ia32-msvc': 1.11.1
|
||||
'@unrs/resolver-binding-win32-x64-msvc': 1.11.1
|
||||
|
||||
unstorage@1.17.4(idb-keyval@6.2.2):
|
||||
unstorage@1.17.4:
|
||||
dependencies:
|
||||
anymatch: 3.1.3
|
||||
chokidar: 5.0.0
|
||||
@@ -20162,8 +19994,6 @@ snapshots:
|
||||
node-fetch-native: 1.6.7
|
||||
ofetch: 1.5.1
|
||||
ufo: 1.6.3
|
||||
optionalDependencies:
|
||||
idb-keyval: 6.2.2
|
||||
|
||||
update-browserslist-db@1.2.2(browserslist@4.28.1):
|
||||
dependencies:
|
||||
@@ -20490,48 +20320,6 @@ snapshots:
|
||||
- tsx
|
||||
- yaml
|
||||
|
||||
vitest@4.0.16(@opentelemetry/api@1.9.0)(@types/node@25.0.3)(@vitest/ui@4.0.16)(esbuild@0.27.3)(happy-dom@20.0.11)(jiti@2.6.1)(jsdom@27.4.0)(terser@5.39.2)(tsx@4.19.4)(yaml@2.8.2):
|
||||
dependencies:
|
||||
'@vitest/expect': 4.0.16
|
||||
'@vitest/mocker': 4.0.16(vite@8.0.0(@types/node@25.0.3)(esbuild@0.27.3)(jiti@2.6.1)(terser@5.39.2)(tsx@4.19.4)(yaml@2.8.2))
|
||||
'@vitest/pretty-format': 4.0.16
|
||||
'@vitest/runner': 4.0.16
|
||||
'@vitest/snapshot': 4.0.16
|
||||
'@vitest/spy': 4.0.16
|
||||
'@vitest/utils': 4.0.16
|
||||
es-module-lexer: 1.7.0
|
||||
expect-type: 1.3.0
|
||||
magic-string: 0.30.21
|
||||
obug: 2.1.1
|
||||
pathe: 2.0.3
|
||||
picomatch: 4.0.3
|
||||
std-env: 3.10.0
|
||||
tinybench: 2.9.0
|
||||
tinyexec: 1.0.4
|
||||
tinyglobby: 0.2.15
|
||||
tinyrainbow: 3.0.3
|
||||
vite: 8.0.0(@types/node@25.0.3)(esbuild@0.27.3)(jiti@2.6.1)(terser@5.39.2)(tsx@4.19.4)(yaml@2.8.2)
|
||||
why-is-node-running: 2.3.0
|
||||
optionalDependencies:
|
||||
'@opentelemetry/api': 1.9.0
|
||||
'@types/node': 25.0.3
|
||||
'@vitest/ui': 4.0.16(vitest@4.0.16)
|
||||
happy-dom: 20.0.11
|
||||
jsdom: 27.4.0
|
||||
transitivePeerDependencies:
|
||||
- '@vitejs/devtools'
|
||||
- esbuild
|
||||
- jiti
|
||||
- less
|
||||
- msw
|
||||
- sass
|
||||
- sass-embedded
|
||||
- stylus
|
||||
- sugarss
|
||||
- terser
|
||||
- tsx
|
||||
- yaml
|
||||
|
||||
void-elements@3.1.0: {}
|
||||
|
||||
volar-service-css@0.0.70(@volar/language-service@2.4.28):
|
||||
|
||||
@@ -3,7 +3,6 @@ packages:
|
||||
- packages/**
|
||||
|
||||
catalog:
|
||||
'@ai-sdk/openai': ^3.0.53
|
||||
'@alloc/quick-lru': ^5.2.0
|
||||
'@astrojs/check': ^0.9.8
|
||||
'@astrojs/sitemap': ^3.7.1
|
||||
@@ -55,7 +54,6 @@ catalog:
|
||||
'@types/jsdom': ^21.1.7
|
||||
'@types/node': ^24.1.0
|
||||
'@types/semver': ^7.7.0
|
||||
'@types/shell-quote': ^1.7.5
|
||||
'@types/three': ^0.169.0
|
||||
'@vercel/analytics': ^2.0.1
|
||||
'@vitejs/plugin-vue': ^6.0.0
|
||||
@@ -64,7 +62,6 @@ catalog:
|
||||
'@vueuse/core': ^14.2.0
|
||||
'@vueuse/integrations': ^14.2.0
|
||||
'@webgpu/types': ^0.1.66
|
||||
ai: ^6.0.168
|
||||
algoliasearch: ^5.21.0
|
||||
astro: ^5.10.0
|
||||
axios: ^1.13.5
|
||||
@@ -90,7 +87,6 @@ catalog:
|
||||
gsap: ^3.14.2
|
||||
happy-dom: ^20.0.11
|
||||
husky: ^9.1.7
|
||||
idb-keyval: ^6.2.2
|
||||
jiti: 2.6.1
|
||||
jsdom: ^27.4.0
|
||||
jsonata: ^2.1.0
|
||||
@@ -113,7 +109,6 @@ catalog:
|
||||
primevue: ^4.2.5
|
||||
reka-ui: ^2.5.0
|
||||
rollup-plugin-visualizer: ^6.0.4
|
||||
shell-quote: ^1.8.3
|
||||
storybook: ^10.2.10
|
||||
stylelint: ^16.26.1
|
||||
tailwindcss: ^4.2.0
|
||||
|
||||
@@ -1,209 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Deploy frontend preview to Cloudflare Pages and comment on PR
|
||||
# Usage: ./pr-preview-deploy-and-comment.sh <pr_number> <status>
|
||||
|
||||
# Input validation
|
||||
# Validate PR number is numeric
|
||||
case "$1" in
|
||||
''|*[!0-9]*)
|
||||
echo "Error: PR_NUMBER must be numeric" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
PR_NUMBER="$1"
|
||||
|
||||
# Validate status parameter
|
||||
STATUS="${2:-completed}"
|
||||
case "$STATUS" in
|
||||
starting|completed) ;;
|
||||
*)
|
||||
echo "Error: STATUS must be 'starting' or 'completed'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# Required environment variables
|
||||
: "${GITHUB_TOKEN:?GITHUB_TOKEN is required}"
|
||||
: "${GITHUB_REPOSITORY:?GITHUB_REPOSITORY is required}"
|
||||
|
||||
# Cloudflare variables only required for deployment
|
||||
if [ "$STATUS" = "completed" ]; then
|
||||
: "${CLOUDFLARE_API_TOKEN:?CLOUDFLARE_API_TOKEN is required for deployment}"
|
||||
: "${CLOUDFLARE_ACCOUNT_ID:?CLOUDFLARE_ACCOUNT_ID is required for deployment}"
|
||||
fi
|
||||
|
||||
# Configuration
|
||||
COMMENT_MARKER="<!-- COMFYUI_PREVIEW_DEPLOY -->"
|
||||
|
||||
# Resolve wrangler invocation: prefer a locally-available binary, otherwise
|
||||
# run via pnpm dlx to honour the repo's package-manager policy.
|
||||
if command -v wrangler > /dev/null 2>&1; then
|
||||
WRANGLER="wrangler"
|
||||
else
|
||||
WRANGLER="pnpm dlx wrangler@^4.0.0"
|
||||
fi
|
||||
|
||||
# Deploy frontend preview, WARN: ensure inputs are sanitized before calling this function
|
||||
deploy_preview() {
|
||||
dir="$1"
|
||||
branch="$2"
|
||||
|
||||
[ ! -d "$dir" ] && echo "failed" && return
|
||||
|
||||
project="comfy-ui"
|
||||
|
||||
echo "Deploying frontend preview to project $project on branch $branch..." >&2
|
||||
|
||||
# Try deployment up to 3 times
|
||||
i=1
|
||||
while [ $i -le 3 ]; do
|
||||
echo "Deployment attempt $i of 3..." >&2
|
||||
# Branch is already sanitized, use it directly
|
||||
if output=$($WRANGLER pages deploy "$dir" \
|
||||
--project-name="$project" \
|
||||
--branch="$branch" 2>&1); then
|
||||
|
||||
# Prefer the branch alias URL over the deployment hash URL so the
|
||||
# link in the PR comment stays stable across redeploys.
|
||||
branch_url="https://${branch}.${project}.pages.dev"
|
||||
if echo "$output" | grep -qF "$branch_url"; then
|
||||
result="$branch_url"
|
||||
else
|
||||
# Fall back to first pages.dev URL in wrangler output
|
||||
url=$(echo "$output" | grep -oE 'https://[a-zA-Z0-9.-]+\.pages\.dev\S*' | head -1)
|
||||
result="${url:-$branch_url}"
|
||||
fi
|
||||
echo "Success! URL: $result" >&2
|
||||
echo "$result" # Only this goes to stdout for capture
|
||||
return
|
||||
else
|
||||
echo "Deployment failed on attempt $i: $output" >&2
|
||||
fi
|
||||
[ $i -lt 3 ] && sleep 10
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
echo "failed"
|
||||
}
|
||||
|
||||
# Post or update GitHub comment
|
||||
post_comment() {
|
||||
body="$1"
|
||||
temp_file=$(mktemp)
|
||||
echo "$body" > "$temp_file"
|
||||
|
||||
if command -v gh > /dev/null 2>&1; then
|
||||
# Find existing comment ID
|
||||
existing=$(gh api "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" \
|
||||
--jq ".[] | select(.body | contains(\"$COMMENT_MARKER\")) | .id" | head -1)
|
||||
|
||||
if [ -n "$existing" ]; then
|
||||
# Update specific comment by ID
|
||||
gh api --method PATCH "repos/$GITHUB_REPOSITORY/issues/comments/$existing" \
|
||||
--field body="$(cat "$temp_file")"
|
||||
else
|
||||
gh pr comment "$PR_NUMBER" --body-file "$temp_file"
|
||||
fi
|
||||
else
|
||||
echo "GitHub CLI not available, outputting comment:"
|
||||
cat "$temp_file"
|
||||
fi
|
||||
|
||||
rm -f "$temp_file"
|
||||
}
|
||||
|
||||
# Main execution
|
||||
if [ "$STATUS" = "starting" ]; then
|
||||
# Post starting comment
|
||||
comment="$COMMENT_MARKER
|
||||
## 🌐 Frontend Preview: <img alt='loading' src='https://github.com/user-attachments/assets/755c86ee-e445-4ea8-bc2c-cca85df48686' width='14px' height='14px'/> Building..."
|
||||
post_comment "$comment"
|
||||
|
||||
elif [ "$STATUS" = "completed" ]; then
|
||||
# Deploy and post completion comment
|
||||
# Convert branch name to Cloudflare-compatible format (lowercase, only alphanumeric and dashes)
|
||||
# Falls back to pr-$PR_NUMBER if BRANCH_NAME is unset
|
||||
if [ -n "$BRANCH_NAME" ]; then
|
||||
cloudflare_branch=$(echo "$BRANCH_NAME" | tr '[:upper:]' '[:lower:]' | \
|
||||
sed 's/[^a-z0-9-]/-/g' | sed 's/--*/-/g' | sed 's/^-\|-$//g')
|
||||
else
|
||||
cloudflare_branch="pr-$PR_NUMBER"
|
||||
fi
|
||||
|
||||
echo "Looking for frontend build in: $(pwd)/dist"
|
||||
|
||||
# Deploy preview if build exists
|
||||
deployment_url="Not deployed"
|
||||
if [ -d "dist" ]; then
|
||||
echo "Found frontend build, deploying..."
|
||||
url=$(deploy_preview "dist" "$cloudflare_branch")
|
||||
if [ "$url" != "failed" ] && [ -n "$url" ]; then
|
||||
deployment_url="[🌐 Open Preview]($url)"
|
||||
else
|
||||
deployment_url="Deployment failed"
|
||||
fi
|
||||
else
|
||||
echo "Frontend build not found at dist"
|
||||
fi
|
||||
|
||||
# Get workflow conclusion from environment or default to success
|
||||
WORKFLOW_CONCLUSION="${WORKFLOW_CONCLUSION:-success}"
|
||||
WORKFLOW_URL="${WORKFLOW_URL:-}"
|
||||
|
||||
# Generate compact header based on conclusion
|
||||
if [ "$WORKFLOW_CONCLUSION" = "success" ]; then
|
||||
status_icon="✅"
|
||||
status_text="Built"
|
||||
elif [ "$WORKFLOW_CONCLUSION" = "skipped" ]; then
|
||||
status_icon="⏭️"
|
||||
status_text="Skipped"
|
||||
elif [ "$WORKFLOW_CONCLUSION" = "cancelled" ]; then
|
||||
status_icon="🚫"
|
||||
status_text="Cancelled"
|
||||
else
|
||||
status_icon="❌"
|
||||
status_text="Failed"
|
||||
fi
|
||||
|
||||
# Build compact header with optional preview link
|
||||
header="## 🌐 Frontend Preview: $status_icon $status_text"
|
||||
if [ "$deployment_url" != "Not deployed" ] && [ "$deployment_url" != "Deployment failed" ] && [ "$WORKFLOW_CONCLUSION" = "success" ]; then
|
||||
header="$header — $deployment_url"
|
||||
fi
|
||||
|
||||
# Build details section
|
||||
details="<details>
|
||||
<summary>Details</summary>
|
||||
|
||||
⏰ Completed at: $(date -u '+%m/%d/%Y, %I:%M:%S %p') UTC
|
||||
|
||||
**Links**
|
||||
- [📊 View Workflow Run]($WORKFLOW_URL)"
|
||||
|
||||
if [ "$deployment_url" != "Not deployed" ]; then
|
||||
if [ "$deployment_url" = "Deployment failed" ]; then
|
||||
details="$details
|
||||
- ❌ Preview deployment failed"
|
||||
elif [ "$WORKFLOW_CONCLUSION" != "success" ]; then
|
||||
details="$details
|
||||
- ⚠️ Build failed — $deployment_url"
|
||||
fi
|
||||
elif [ "$WORKFLOW_CONCLUSION" != "success" ]; then
|
||||
details="$details
|
||||
- ⏭️ Preview deployment skipped (build did not succeed)"
|
||||
fi
|
||||
|
||||
details="$details
|
||||
|
||||
</details>"
|
||||
|
||||
comment="$COMMENT_MARKER
|
||||
$header
|
||||
|
||||
$details"
|
||||
|
||||
post_comment "$comment"
|
||||
fi
|
||||
@@ -1,7 +1,6 @@
|
||||
<template>
|
||||
<router-view />
|
||||
<GlobalDialog />
|
||||
<AgentRoot />
|
||||
<BlockUI full-screen :blocked="isLoading" />
|
||||
</template>
|
||||
|
||||
@@ -10,7 +9,6 @@ import { captureException } from '@sentry/vue'
|
||||
import BlockUI from 'primevue/blockui'
|
||||
import { computed, onMounted, watch } from 'vue'
|
||||
|
||||
import AgentRoot from '@/agent/ui/AgentRoot.vue'
|
||||
import GlobalDialog from '@/components/dialog/GlobalDialog.vue'
|
||||
import config from '@/config'
|
||||
import { isDesktop } from '@/platform/distribution/types'
|
||||
|
||||
@@ -1,265 +0,0 @@
|
||||
import { useLocalStorage } from '@vueuse/core'
|
||||
import type { ModelMessage } from 'ai'
|
||||
import { shallowRef } from 'vue'
|
||||
|
||||
import { useCommandStore } from '@/stores/commandStore'
|
||||
|
||||
import type { ToolInvocation } from '../llm/session'
|
||||
import { streamSession } from '../llm/session'
|
||||
import { log } from '../services/logger'
|
||||
import { registerBrowserCommands } from '../shell/commands/browser'
|
||||
import { registerCodesearchCommands } from '../shell/commands/codesearch'
|
||||
import { registerComfyCommands } from '../shell/commands/comfy'
|
||||
import { registerComfyNamespace } from '../shell/commands/comfyNs'
|
||||
import { registerCoreutils } from '../shell/commands/coreutils'
|
||||
import { registerExecutionCommands } from '../shell/commands/execution'
|
||||
import { registerGraphCommands } from '../shell/commands/graph'
|
||||
import { registerImageCommands } from '../shell/commands/images'
|
||||
import { registerInstallCommands } from '../shell/commands/install'
|
||||
import { registerLayoutCommands } from '../shell/commands/layout'
|
||||
import { registerNodeOpsCommands } from '../shell/commands/nodeOps'
|
||||
import { registerRegistrySearchCommands } from '../shell/commands/registrySearch'
|
||||
import { registerSeeCommands } from '../shell/commands/see'
|
||||
import { registerStateCommands } from '../shell/commands/state'
|
||||
import { registerSweepCommands } from '../shell/commands/sweep'
|
||||
import { registerTemplateCommands } from '../shell/commands/templates'
|
||||
import { registerValidateCommands } from '../shell/commands/validate'
|
||||
import { registerWorkflowCommands } from '../shell/commands/workflow'
|
||||
import { CommandRegistryImpl, runScript } from '../shell/runtime'
|
||||
import type { ExecContext } from '../shell/runtime'
|
||||
import { collect, emptyIter, stringIter } from '../shell/types'
|
||||
import type { Command } from '../shell/types'
|
||||
import { MemoryVFS } from '../shell/vfs/memory'
|
||||
import { MountedVFS } from '../shell/vfs/mount'
|
||||
import { UserdataVFS } from '../shell/vfs/userdata'
|
||||
import type { IngestedAsset } from '../stores/agentStore'
|
||||
import { useAgentStore } from '../stores/agentStore'
|
||||
|
||||
// User's preferred smartest-available model. Override via settings.
|
||||
const DEFAULT_MODEL = 'gpt-5.5'
|
||||
const DEFAULT_REASONING_EFFORT = 'high'
|
||||
const DEFAULT_SYSTEM_APPEND = ''
|
||||
// Empty by default — the OpenAI SDK falls back to https://api.openai.com.
|
||||
// User can point this at OpenRouter / a local LLM proxy / a self-hosted
|
||||
// gateway by overriding via the settings panel.
|
||||
const DEFAULT_BASE_URL = ''
|
||||
|
||||
function buildExecContext(signal: AbortSignal): ExecContext {
|
||||
const registry = new CommandRegistryImpl()
|
||||
registerCoreutils(registry)
|
||||
registerComfyCommands(registry)
|
||||
registerComfyNamespace(registry)
|
||||
registerStateCommands(registry)
|
||||
registerBrowserCommands(registry)
|
||||
registerCodesearchCommands(registry)
|
||||
registerExecutionCommands(registry)
|
||||
registerGraphCommands(registry)
|
||||
registerImageCommands(registry)
|
||||
registerInstallCommands(registry)
|
||||
registerLayoutCommands(registry)
|
||||
registerNodeOpsCommands(registry)
|
||||
registerRegistrySearchCommands(registry)
|
||||
registerSeeCommands(registry)
|
||||
registerSweepCommands(registry)
|
||||
registerTemplateCommands(registry)
|
||||
registerValidateCommands(registry)
|
||||
registerWorkflowCommands(registry)
|
||||
|
||||
// Fallback: any Comfy.* (or other registered) command id can be invoked
|
||||
// directly as if it were a shell command. Case-insensitive.
|
||||
registry.addResolver((name) => {
|
||||
const store = useCommandStore()
|
||||
const target =
|
||||
store.getCommand(name) ??
|
||||
store.commands.find((c) => c.id.toLowerCase() === name.toLowerCase())
|
||||
if (!target) return undefined
|
||||
const handler: Command = async () => {
|
||||
try {
|
||||
await store.execute(target.id)
|
||||
return { stdout: stringIter(`ok: ${target.id}\n`), exitCode: 0 }
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: err instanceof Error ? err.message : String(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return handler
|
||||
})
|
||||
|
||||
const vfs = new MountedVFS({
|
||||
'/tmp': new MemoryVFS(),
|
||||
'/workflows': new UserdataVFS('workflows')
|
||||
})
|
||||
return {
|
||||
registry,
|
||||
vfs,
|
||||
env: new Map(),
|
||||
cwd: '/',
|
||||
signal
|
||||
}
|
||||
}
|
||||
|
||||
function envApiKey(): string {
|
||||
const key = import.meta.env.VITE_OPENAI_API_KEY
|
||||
return typeof key === 'string' ? key : ''
|
||||
}
|
||||
|
||||
export function useAgentSession() {
|
||||
const store = useAgentStore()
|
||||
const apiKey = useLocalStorage('Comfy.Agent.OpenAIKey', envApiKey())
|
||||
const model = useLocalStorage('Comfy.Agent.Model', DEFAULT_MODEL)
|
||||
const baseURL = useLocalStorage('Comfy.Agent.BaseURL', DEFAULT_BASE_URL)
|
||||
const reasoningEffort = useLocalStorage(
|
||||
'Comfy.Agent.ReasoningEffort',
|
||||
DEFAULT_REASONING_EFFORT
|
||||
)
|
||||
const systemPromptAppend = useLocalStorage(
|
||||
'Comfy.Agent.SystemPromptAppend',
|
||||
DEFAULT_SYSTEM_APPEND
|
||||
)
|
||||
const abortController = shallowRef<AbortController | null>(null)
|
||||
|
||||
function buildHistory(): ModelMessage[] {
|
||||
return store.messages
|
||||
.filter((m) => m.role !== 'system')
|
||||
.map((m) => ({
|
||||
role: m.role as 'user' | 'assistant',
|
||||
content: m.text
|
||||
}))
|
||||
}
|
||||
|
||||
async function send(text: string, assets: IngestedAsset[]): Promise<void> {
|
||||
// Abort any in-flight stream from a prior turn so the old callbacks
|
||||
// stop writing into the wrong placeholder and the new turn starts
|
||||
// from a clean state.
|
||||
if (abortController.value) {
|
||||
abortController.value.abort()
|
||||
abortController.value = null
|
||||
store.isStreaming = false
|
||||
}
|
||||
|
||||
const userContent =
|
||||
assets.length > 0
|
||||
? `${text}\n\nAttached files:\n${assets.map((a) => `- ${a.path}`).join('\n')}`
|
||||
: text
|
||||
store.addMessage({ role: 'user', text, assets })
|
||||
|
||||
if (!apiKey.value) {
|
||||
store.addMessage({
|
||||
role: 'assistant',
|
||||
text:
|
||||
'No API key configured yet. Click the ⚙ settings gear at the top of this panel and paste an OpenAI or OpenRouter API key. ' +
|
||||
"This agent runs entirely in your browser — your key is stored in localStorage and only sent to the API endpoint you configure (default: OpenAI). It's never seen by the ComfyUI frontend or backend."
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const placeholder = store.addMessage({ role: 'assistant', text: '' })
|
||||
const ac = new AbortController()
|
||||
abortController.value = ac
|
||||
store.isStreaming = true
|
||||
|
||||
const history = buildHistory()
|
||||
history[history.length - 1] = { role: 'user', content: userContent }
|
||||
|
||||
try {
|
||||
let streamed = ''
|
||||
const toolCalls: ToolInvocation[] = []
|
||||
await streamSession(
|
||||
{
|
||||
apiKey: apiKey.value,
|
||||
model: model.value,
|
||||
baseURL: baseURL.value || undefined,
|
||||
reasoningEffort: reasoningEffort.value,
|
||||
systemPromptAppend: systemPromptAppend.value,
|
||||
messages: history,
|
||||
execContext: buildExecContext(ac.signal),
|
||||
signal: ac.signal
|
||||
},
|
||||
(delta) => {
|
||||
if (ac.signal.aborted) return
|
||||
streamed += delta
|
||||
placeholder.text = streamed
|
||||
},
|
||||
(inv) => {
|
||||
if (ac.signal.aborted) return
|
||||
toolCalls.push(inv)
|
||||
const summary = `$ ${inv.script}\n${inv.stdout}${inv.stderr ? `\n[stderr] ${inv.stderr}` : ''}`
|
||||
store.addMessage({
|
||||
role: 'system',
|
||||
text: summary,
|
||||
tool: {
|
||||
script: inv.script,
|
||||
stdout: inv.stdout,
|
||||
stderr: inv.stderr,
|
||||
exitCode: inv.exitCode
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
// Fallback: model ran tools but didn't speak — surface a minimal
|
||||
// confirmation so the user isn't staring at tool traces alone.
|
||||
if (!ac.signal.aborted && !streamed.trim() && toolCalls.length > 0) {
|
||||
const last = toolCalls[toolCalls.length - 1]
|
||||
placeholder.text =
|
||||
last.exitCode === 0
|
||||
? `(${toolCalls.length} tool call${toolCalls.length > 1 ? 's' : ''} completed)`
|
||||
: `(tool exited ${last.exitCode})`
|
||||
}
|
||||
// Log the FINAL assistant text (agentStore.addMessage only logs the
|
||||
// empty placeholder at creation time; we need a follow-up entry so
|
||||
// the server log captures what the user actually saw).
|
||||
if (!ac.signal.aborted && placeholder.text) {
|
||||
log({ kind: 'assistant', text: placeholder.text })
|
||||
}
|
||||
} catch (err) {
|
||||
if (!ac.signal.aborted) {
|
||||
placeholder.text =
|
||||
'Error: ' + (err instanceof Error ? err.message : String(err))
|
||||
}
|
||||
} finally {
|
||||
// Only clear shared flags if we are still the active stream.
|
||||
if (abortController.value === ac) {
|
||||
store.isStreaming = false
|
||||
abortController.value = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function stop(): void {
|
||||
abortController.value?.abort()
|
||||
}
|
||||
|
||||
let cachedCtx: ExecContext | null = null
|
||||
|
||||
function buildExecContextOnce(): ExecContext {
|
||||
if (!cachedCtx) {
|
||||
cachedCtx = buildExecContext(new AbortController().signal)
|
||||
}
|
||||
return cachedCtx
|
||||
}
|
||||
|
||||
async function execShell(
|
||||
script: string
|
||||
): Promise<{ stdout: string; stderr?: string; exitCode: number }> {
|
||||
const ctx = buildExecContextOnce()
|
||||
const ac = new AbortController()
|
||||
const res = await runScript(script, { ...ctx, signal: ac.signal })
|
||||
const stdout = await collect(res.stdout)
|
||||
return { stdout, stderr: res.stderr, exitCode: res.exitCode }
|
||||
}
|
||||
|
||||
return {
|
||||
apiKey,
|
||||
baseURL,
|
||||
model,
|
||||
reasoningEffort,
|
||||
systemPromptAppend,
|
||||
send,
|
||||
stop,
|
||||
execShell,
|
||||
buildExecContextOnce
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { useAssetIngest } from './useAssetIngest'
|
||||
|
||||
function mockFile(name: string, type = 'image/png', size = 10): File {
|
||||
return new File([new Uint8Array(size)], name, { type })
|
||||
}
|
||||
|
||||
describe('useAssetIngest', () => {
|
||||
it('uses uploader result path when upload succeeds', async () => {
|
||||
const uploader = vi.fn().mockResolvedValue('/input/sub/foo.png')
|
||||
const { ingestFile } = useAssetIngest({ uploader })
|
||||
const result = await ingestFile(mockFile('foo.png'))
|
||||
expect(result.remote).toBe(true)
|
||||
expect(result.asset.path).toBe('/input/sub/foo.png')
|
||||
expect(result.asset.mime).toBe('image/png')
|
||||
})
|
||||
|
||||
it('falls back to /tmp/pasted when uploader returns null', async () => {
|
||||
const uploader = vi.fn().mockResolvedValue(null)
|
||||
const { ingestFile } = useAssetIngest({ uploader })
|
||||
const result = await ingestFile(mockFile('x.png'))
|
||||
expect(result.remote).toBe(false)
|
||||
expect(result.asset.path).toMatch(/^\/tmp\/pasted\//)
|
||||
})
|
||||
|
||||
it('sanitizes filenames', async () => {
|
||||
const uploader = vi.fn().mockResolvedValue(null)
|
||||
const { ingestFile } = useAssetIngest({ uploader })
|
||||
const result = await ingestFile(mockFile('weird name !@#.png'))
|
||||
expect(result.asset.path).not.toMatch(/[!@#]/)
|
||||
})
|
||||
|
||||
it('creates preview URL for images only', async () => {
|
||||
const uploader = vi.fn().mockResolvedValue(null)
|
||||
const { ingestFile } = useAssetIngest({ uploader })
|
||||
const img = await ingestFile(mockFile('a.png', 'image/png'))
|
||||
const txt = await ingestFile(mockFile('a.txt', 'text/plain'))
|
||||
expect(img.asset.previewUrl).toBeDefined()
|
||||
expect(txt.asset.previewUrl).toBeUndefined()
|
||||
})
|
||||
|
||||
it('ingests multiple files from DataTransfer', async () => {
|
||||
const uploader = vi.fn().mockResolvedValue('/input/x')
|
||||
const { ingestFromClipboard } = useAssetIngest({ uploader })
|
||||
const dt = {
|
||||
items: [
|
||||
{ kind: 'file', getAsFile: () => mockFile('a.png') },
|
||||
{ kind: 'file', getAsFile: () => mockFile('b.png') },
|
||||
{ kind: 'string', getAsFile: () => null }
|
||||
],
|
||||
files: []
|
||||
} as unknown as DataTransfer
|
||||
const results = await ingestFromClipboard(dt)
|
||||
expect(results).toHaveLength(2)
|
||||
})
|
||||
|
||||
it('returns empty list when DataTransfer is null', async () => {
|
||||
const { ingestFromClipboard } = useAssetIngest({})
|
||||
expect(await ingestFromClipboard(null)).toEqual([])
|
||||
})
|
||||
})
|
||||
@@ -1,92 +0,0 @@
|
||||
import { api } from '@/scripts/api'
|
||||
|
||||
import type { IngestedAsset } from '../stores/agentStore'
|
||||
|
||||
interface IngestResult {
|
||||
asset: IngestedAsset
|
||||
remote: boolean
|
||||
}
|
||||
|
||||
function safeName(raw: string): string {
|
||||
return raw.replace(/[^\w.-]+/g, '_').slice(0, 120) || `pasted_${Date.now()}`
|
||||
}
|
||||
|
||||
function detectExt(mime: string): string {
|
||||
if (mime === 'image/png') return '.png'
|
||||
if (mime === 'image/jpeg') return '.jpg'
|
||||
if (mime === 'image/webp') return '.webp'
|
||||
if (mime === 'image/gif') return '.gif'
|
||||
if (mime === 'text/plain') return '.txt'
|
||||
return ''
|
||||
}
|
||||
|
||||
async function uploadToInput(file: File): Promise<string | null> {
|
||||
const body = new FormData()
|
||||
body.append('image', file, file.name)
|
||||
body.append('type', 'input')
|
||||
body.append('overwrite', 'false')
|
||||
try {
|
||||
const resp = await api.fetchApi('/upload/image', { method: 'POST', body })
|
||||
if (!resp.ok) return null
|
||||
const json = (await resp.json()) as { name?: string; subfolder?: string }
|
||||
if (!json.name) return null
|
||||
const prefix = json.subfolder ? `${json.subfolder}/` : ''
|
||||
return `/input/${prefix}${json.name}`
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
interface AssetIngestOptions {
|
||||
uploader?: (file: File) => Promise<string | null>
|
||||
}
|
||||
|
||||
export function useAssetIngest(options: AssetIngestOptions = {}) {
|
||||
const uploader = options.uploader ?? uploadToInput
|
||||
|
||||
async function ingestFile(file: File): Promise<IngestResult> {
|
||||
const remotePath = await uploader(file)
|
||||
const fallbackName =
|
||||
file.name && file.name.length > 0
|
||||
? safeName(file.name)
|
||||
: safeName('pasted') + detectExt(file.type)
|
||||
const path = remotePath ?? `/tmp/pasted/${fallbackName}`
|
||||
const previewUrl = file.type.startsWith('image/')
|
||||
? URL.createObjectURL(file)
|
||||
: undefined
|
||||
return {
|
||||
asset: {
|
||||
id: crypto.randomUUID(),
|
||||
name: fallbackName,
|
||||
path,
|
||||
mime: file.type || 'application/octet-stream',
|
||||
size: file.size,
|
||||
previewUrl
|
||||
},
|
||||
remote: remotePath !== null
|
||||
}
|
||||
}
|
||||
|
||||
async function ingestFromClipboard(
|
||||
data: DataTransfer | null
|
||||
): Promise<IngestResult[]> {
|
||||
if (!data) return []
|
||||
const results: IngestResult[] = []
|
||||
for (const item of Array.from(data.items)) {
|
||||
if (item.kind !== 'file') continue
|
||||
const file = item.getAsFile()
|
||||
if (file) results.push(await ingestFile(file))
|
||||
}
|
||||
if (results.length === 0 && data.files && data.files.length > 0) {
|
||||
for (const file of Array.from(data.files)) {
|
||||
results.push(await ingestFile(file))
|
||||
}
|
||||
}
|
||||
return results
|
||||
}
|
||||
|
||||
return {
|
||||
ingestFile,
|
||||
ingestFromClipboard
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
|
||||
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
|
||||
|
||||
/**
|
||||
* Drop an uploaded image into the active graph as a LoadImage node.
|
||||
*
|
||||
* Given an uploaded filename (the part after `/input/` returned by
|
||||
* /upload/image), add a LoadImage node at a reasonable position and
|
||||
* set its widget to the filename. Capture an undo snapshot so Ctrl/Cmd+Z
|
||||
* reverts the insertion.
|
||||
*
|
||||
* Returns the id of the newly created node, or null if the graph was
|
||||
* not available or the node type is not registered.
|
||||
*/
|
||||
export function dropImageAsLoadImageNode(filename: string): number | null {
|
||||
const canvas = useCanvasStore().canvas
|
||||
const graph = canvas?.graph as
|
||||
| { _nodes: { pos: [number, number]; size: [number, number] }[] }
|
||||
| undefined
|
||||
if (!canvas || !graph) return null
|
||||
|
||||
// Position: to the right of the rightmost existing node, same y as the
|
||||
// topmost. Feels natural when adding a reference image alongside a
|
||||
// workflow.
|
||||
let right = 100
|
||||
let top = 100
|
||||
const nodes = graph._nodes ?? []
|
||||
if (nodes.length > 0) {
|
||||
right = Math.max(
|
||||
...nodes.map((n) => (n.pos?.[0] ?? 0) + (n.size?.[0] ?? 200))
|
||||
)
|
||||
right += 40
|
||||
top = Math.min(...nodes.map((n) => n.pos?.[1] ?? 0))
|
||||
}
|
||||
|
||||
// The global LiteGraph instance is installed by the app startup; access
|
||||
// it via window to avoid tangling imports.
|
||||
const LG = (
|
||||
window as unknown as { LiteGraph?: { createNode: (t: string) => unknown } }
|
||||
).LiteGraph
|
||||
if (!LG) return null
|
||||
const node = LG.createNode('LoadImage') as {
|
||||
id: number
|
||||
pos: [number, number]
|
||||
widgets?: {
|
||||
name?: string
|
||||
value?: unknown
|
||||
callback?: (v: unknown) => void
|
||||
}[]
|
||||
} | null
|
||||
if (!node) return null
|
||||
|
||||
node.pos = [right, top]
|
||||
// Set the 'image' widget to the uploaded filename
|
||||
const widget = node.widgets?.find((w) => w.name === 'image')
|
||||
if (widget) {
|
||||
widget.value = filename
|
||||
widget.callback?.(filename)
|
||||
}
|
||||
;(graph as unknown as { add: (n: unknown) => void }).add(node)
|
||||
canvas.setDirty(true, true)
|
||||
|
||||
try {
|
||||
useWorkflowStore().activeWorkflow?.changeTracker?.checkState()
|
||||
} catch {
|
||||
/* no active workflow */
|
||||
}
|
||||
|
||||
return node.id
|
||||
}
|
||||
@@ -1,236 +0,0 @@
|
||||
import { onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
|
||||
import { useAgentStore } from '../stores/agentStore'
|
||||
import { useAgentSession } from './useAgentSession'
|
||||
|
||||
const DAEMON_WS = 'ws://127.0.0.1:7437/spa'
|
||||
const PROTOCOL_VERSION = 1
|
||||
const SESSION_ID = crypto.randomUUID()
|
||||
|
||||
type SpaEventPayload =
|
||||
| { kind: 'delta'; role: 'assistant'; text: string }
|
||||
| { kind: 'message'; role: 'user' | 'assistant' | 'system'; text: string }
|
||||
| {
|
||||
kind: 'tool'
|
||||
script: string
|
||||
stdout: string
|
||||
stderr?: string
|
||||
exitCode: number
|
||||
}
|
||||
| { kind: 'state'; isStreaming: boolean }
|
||||
| { kind: 'clear' }
|
||||
|
||||
type SpaToDaemon =
|
||||
| { v: number; type: 'hello'; sessionId: string; title?: string }
|
||||
| {
|
||||
v: number
|
||||
type: 'evalResult'
|
||||
sessionId: string
|
||||
opId: string
|
||||
stdout: string
|
||||
stderr?: string
|
||||
exitCode: number
|
||||
}
|
||||
| { v: number; type: 'pair-request'; sessionId: string; code: string }
|
||||
| { v: number; type: 'pong'; sessionId: string }
|
||||
| { v: number; type: 'event'; payload: SpaEventPayload }
|
||||
|
||||
type DaemonToSpa =
|
||||
| { v: number; type: 'send'; text: string }
|
||||
| { v: number; type: 'eval'; opId: string; script: string }
|
||||
| { v: number; type: 'abort' }
|
||||
| { v: number; type: 'paired'; code: string }
|
||||
| { v: number; type: 'ping' }
|
||||
|
||||
// Singleton state — shared across all callers of useLocalBridge()
|
||||
const connected = ref(false)
|
||||
const activePairCode = ref<string | null>(null)
|
||||
|
||||
let ws: WebSocket | null = null
|
||||
let refCount = 0
|
||||
let sendFn: ((text: string) => void) | null = null
|
||||
let evalFn:
|
||||
| ((
|
||||
opId: string,
|
||||
script: string
|
||||
) => Promise<{ stdout: string; stderr?: string; exitCode: number }>)
|
||||
| null = null
|
||||
let stopFn: (() => void) | null = null
|
||||
|
||||
// Tracks how many messages from the store have been emitted to the daemon.
|
||||
// Reset to 0 when messages are cleared or a new WS connection opens.
|
||||
let emittedMsgCount = 0
|
||||
|
||||
function sendMsg(msg: SpaToDaemon) {
|
||||
if (ws?.readyState === WebSocket.OPEN) ws.send(JSON.stringify(msg))
|
||||
}
|
||||
|
||||
function emitEvent(payload: SpaEventPayload) {
|
||||
sendMsg({ v: PROTOCOL_VERSION, type: 'event', payload })
|
||||
}
|
||||
|
||||
function connect(
|
||||
onSend: typeof sendFn,
|
||||
onEval: typeof evalFn,
|
||||
onStop: typeof stopFn
|
||||
) {
|
||||
sendFn = onSend
|
||||
evalFn = onEval
|
||||
stopFn = onStop
|
||||
if (ws && ws.readyState !== WebSocket.CLOSED) return
|
||||
|
||||
ws = new WebSocket(DAEMON_WS)
|
||||
|
||||
ws.addEventListener('open', () => {
|
||||
connected.value = true
|
||||
emittedMsgCount = 0
|
||||
sendMsg({
|
||||
v: PROTOCOL_VERSION,
|
||||
type: 'hello',
|
||||
sessionId: SESSION_ID,
|
||||
title: 'ComfyUI'
|
||||
})
|
||||
})
|
||||
|
||||
ws.addEventListener('message', async (ev) => {
|
||||
let msg: DaemonToSpa
|
||||
try {
|
||||
msg = JSON.parse(ev.data as string) as DaemonToSpa
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
if (msg.v !== PROTOCOL_VERSION) return
|
||||
|
||||
switch (msg.type) {
|
||||
case 'ping':
|
||||
sendMsg({ v: PROTOCOL_VERSION, type: 'pong', sessionId: SESSION_ID })
|
||||
break
|
||||
case 'send':
|
||||
sendFn?.(msg.text)
|
||||
break
|
||||
case 'eval': {
|
||||
const result = (await evalFn?.(msg.opId, msg.script)) ?? {
|
||||
stdout: '',
|
||||
exitCode: 0
|
||||
}
|
||||
sendMsg({
|
||||
v: PROTOCOL_VERSION,
|
||||
type: 'evalResult',
|
||||
sessionId: SESSION_ID,
|
||||
opId: msg.opId,
|
||||
stdout: result.stdout,
|
||||
stderr: result.stderr,
|
||||
exitCode: result.exitCode
|
||||
})
|
||||
break
|
||||
}
|
||||
case 'abort':
|
||||
stopFn?.()
|
||||
break
|
||||
case 'paired':
|
||||
if (activePairCode.value === msg.code) activePairCode.value = null
|
||||
break
|
||||
}
|
||||
})
|
||||
|
||||
ws.addEventListener('close', () => {
|
||||
connected.value = false
|
||||
ws = null
|
||||
// Reconnect after 3s if still mounted
|
||||
if (refCount > 0)
|
||||
setTimeout(() => {
|
||||
if (refCount > 0) connect(sendFn, evalFn, stopFn)
|
||||
}, 3000)
|
||||
})
|
||||
|
||||
ws.addEventListener('error', () => {
|
||||
connected.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function disconnect() {
|
||||
refCount--
|
||||
if (refCount <= 0) {
|
||||
ws?.close()
|
||||
ws = null
|
||||
refCount = 0
|
||||
connected.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** Mount in the root component (AgentRoot) to manage the WS lifecycle. */
|
||||
export function useLocalBridge() {
|
||||
const { send, stop, execShell } = useAgentSession()
|
||||
const agentStore = useAgentStore()
|
||||
|
||||
onMounted(() => {
|
||||
refCount++
|
||||
connect(
|
||||
(text) => void send(text, []),
|
||||
(_opId, script) => execShell(script),
|
||||
() => stop()
|
||||
)
|
||||
})
|
||||
|
||||
onUnmounted(disconnect)
|
||||
|
||||
// Forward new messages to any subscribed tail/attach clients.
|
||||
// We track `emittedMsgCount` so reconnects don't re-emit history.
|
||||
watch(
|
||||
() => agentStore.messages.length,
|
||||
(newLen) => {
|
||||
if (newLen < emittedMsgCount) {
|
||||
emitEvent({ kind: 'clear' })
|
||||
emittedMsgCount = 0
|
||||
return
|
||||
}
|
||||
for (let i = emittedMsgCount; i < newLen; i++) {
|
||||
const msg = agentStore.messages[i]
|
||||
if (msg.tool) {
|
||||
emitEvent({ kind: 'tool', ...msg.tool })
|
||||
} else if (msg.role === 'assistant' && agentStore.isStreaming) {
|
||||
// Streaming placeholder — wait until done to emit
|
||||
} else {
|
||||
emitEvent({
|
||||
kind: 'message',
|
||||
role: msg.role as 'user' | 'assistant' | 'system',
|
||||
text: msg.text
|
||||
})
|
||||
}
|
||||
emittedMsgCount = i + 1
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
// Emit streaming state transitions and flush the final assistant message.
|
||||
watch(
|
||||
() => agentStore.isStreaming,
|
||||
(isStreaming) => {
|
||||
emitEvent({ kind: 'state', isStreaming })
|
||||
if (!isStreaming) {
|
||||
const msgs = agentStore.messages
|
||||
const last = msgs[msgs.length - 1]
|
||||
if (last?.role === 'assistant' && last.text) {
|
||||
emitEvent({ kind: 'message', role: 'assistant', text: last.text })
|
||||
emittedMsgCount = msgs.length
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
function requestPair(): void {
|
||||
const code = Math.random().toString(36).slice(2, 8).toUpperCase()
|
||||
activePairCode.value = code
|
||||
sendMsg({
|
||||
v: PROTOCOL_VERSION,
|
||||
type: 'pair-request',
|
||||
sessionId: SESSION_ID,
|
||||
code
|
||||
})
|
||||
}
|
||||
|
||||
/** Read bridge state from any component — no lifecycle side-effects. */
|
||||
export function useBridgeStatus() {
|
||||
return { connected, activePairCode, requestPair }
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,79 +0,0 @@
|
||||
/**
|
||||
* Agent log — streamed in real time to the Vite dev server's
|
||||
* /__agent-log endpoint, which appends each JSONL line to
|
||||
* ./tmp/agent-logs/<YYYY-MM-DD>.jsonl on the repo host.
|
||||
*
|
||||
* In production (no dev-plugin endpoint) the POST silently 404s and the
|
||||
* logger becomes a no-op. To persist in production a later backend
|
||||
* endpoint (or userdata fallback) would be needed.
|
||||
*/
|
||||
interface LogEntry {
|
||||
t: number
|
||||
kind: 'user' | 'assistant' | 'system' | 'tool' | 'error' | 'session'
|
||||
sessionId?: string
|
||||
text?: string
|
||||
script?: string
|
||||
stdout?: string
|
||||
stderr?: string
|
||||
exitCode?: number
|
||||
}
|
||||
|
||||
const SESSION_ID =
|
||||
typeof crypto !== 'undefined' && 'randomUUID' in crypto
|
||||
? (crypto as Crypto).randomUUID().slice(0, 8)
|
||||
: Math.random().toString(36).slice(2, 10)
|
||||
|
||||
const ENDPOINT = '/__agent-log'
|
||||
|
||||
let queue: LogEntry[] = []
|
||||
let flushTimer: ReturnType<typeof setTimeout> | null = null
|
||||
let flushing = false
|
||||
let disabled = false
|
||||
|
||||
async function doFlush(): Promise<void> {
|
||||
if (flushing || queue.length === 0 || disabled) return
|
||||
flushing = true
|
||||
const batch = queue.splice(0)
|
||||
const body = batch.map((e) => JSON.stringify(e)).join('\n') + '\n'
|
||||
try {
|
||||
const res = await fetch(ENDPOINT, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/x-ndjson' },
|
||||
body,
|
||||
keepalive: true
|
||||
})
|
||||
if (res.status === 404) {
|
||||
// Endpoint doesn't exist (production build). Stop trying.
|
||||
disabled = true
|
||||
}
|
||||
} catch {
|
||||
// Keep the entries for a retry
|
||||
queue = batch.concat(queue)
|
||||
} finally {
|
||||
flushing = false
|
||||
if (queue.length > 0) schedule(400)
|
||||
}
|
||||
}
|
||||
|
||||
function schedule(delay = 250): void {
|
||||
if (flushTimer || disabled) return
|
||||
flushTimer = setTimeout(() => {
|
||||
flushTimer = null
|
||||
void doFlush()
|
||||
}, delay)
|
||||
}
|
||||
|
||||
export function log(partial: Omit<LogEntry, 't' | 'sessionId'>): void {
|
||||
if (disabled) return
|
||||
queue.push({ t: Date.now(), sessionId: SESSION_ID, ...partial })
|
||||
schedule()
|
||||
}
|
||||
|
||||
// Best-effort flush on tab close (uses navigator.sendBeacon-style fetch keepalive)
|
||||
if (typeof window !== 'undefined') {
|
||||
window.addEventListener('beforeunload', () => {
|
||||
void doFlush()
|
||||
})
|
||||
// Mark session start
|
||||
log({ kind: 'session', text: 'session started' })
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
import { useMissingModelStore } from '@/platform/missingModel/missingModelStore'
|
||||
import { useSettingStore } from '@/platform/settings/settingStore'
|
||||
import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
|
||||
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
|
||||
import { api } from '@/scripts/api'
|
||||
import { app } from '@/scripts/app'
|
||||
import { useCommandStore } from '@/stores/commandStore'
|
||||
import { useExecutionErrorStore } from '@/stores/executionErrorStore'
|
||||
import { useColorPaletteStore } from '@/stores/workspace/colorPaletteStore'
|
||||
|
||||
import type { Command, CommandRegistry } from '../types'
|
||||
import { stringIter } from '../types'
|
||||
|
||||
/**
|
||||
* run-js: Execute arbitrary JavaScript with the ComfyUI app + Pinia stores
|
||||
* injected as locals, so snippets like
|
||||
* useCanvasStore().canvas.graph._nodes
|
||||
* work without any import dance.
|
||||
*
|
||||
* Locals bound in the eval scope:
|
||||
* app, api, document, window,
|
||||
* useCanvasStore, useCommandStore, useWorkflowStore,
|
||||
* useMissingModelStore, useExecutionErrorStore, useSettingStore
|
||||
*/
|
||||
const INJECT = [
|
||||
'app',
|
||||
'api',
|
||||
'document',
|
||||
'window',
|
||||
'useCanvasStore',
|
||||
'useCommandStore',
|
||||
'useWorkflowStore',
|
||||
'useMissingModelStore',
|
||||
'useExecutionErrorStore',
|
||||
'useSettingStore',
|
||||
'useColorPaletteStore'
|
||||
] as const
|
||||
|
||||
/**
|
||||
* Strip outermost matching quotes (single/double/backtick). The pre-parse
|
||||
* shortcut for run-js passes the arg verbatim so the LLM often wraps its
|
||||
* snippet in quotes as it would in a shell — but here those quotes become
|
||||
* part of the JS source and collapse the whole thing to a string literal
|
||||
* that evaluates to undefined. Strip them so it works either way.
|
||||
*/
|
||||
function stripOuterQuotes(s: string): string {
|
||||
const trimmed = s.trim()
|
||||
if (trimmed.length < 2) return trimmed
|
||||
const first = trimmed[0]
|
||||
const last = trimmed[trimmed.length - 1]
|
||||
if ((first === '"' || first === "'" || first === '`') && first === last) {
|
||||
return trimmed.slice(1, -1)
|
||||
}
|
||||
return trimmed
|
||||
}
|
||||
|
||||
const runJs: Command = async (ctx) => {
|
||||
const code = stripOuterQuotes(ctx.argv.slice(1).join(' '))
|
||||
if (!code.trim()) {
|
||||
return {
|
||||
stdout: stringIter(''),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: run-js <js expression or statement>'
|
||||
}
|
||||
}
|
||||
try {
|
||||
// Intentional: run-js is a DevTools-equivalent eval entry point.
|
||||
const FnCtor = Function
|
||||
const fn = new FnCtor(...INJECT, `return (async () => { ${code} })()`) as (
|
||||
...args: unknown[]
|
||||
) => Promise<unknown>
|
||||
const result: unknown = await fn(
|
||||
app,
|
||||
api,
|
||||
document,
|
||||
window,
|
||||
useCanvasStore,
|
||||
useCommandStore,
|
||||
useWorkflowStore,
|
||||
useMissingModelStore,
|
||||
useExecutionErrorStore,
|
||||
useSettingStore,
|
||||
useColorPaletteStore
|
||||
)
|
||||
const out =
|
||||
result === undefined ? '' : JSON.stringify(result, null, 2) + '\n'
|
||||
return { stdout: stringIter(out), exitCode: 0 }
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: stringIter(''),
|
||||
exitCode: 1,
|
||||
stderr: err instanceof Error ? err.message : String(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* describe <js-expression>
|
||||
*
|
||||
* Introspect the shape of any value in the run-js scope (stores, app,
|
||||
* canvas, nodes …). Returns type, constructor, own-property summary,
|
||||
* and prototype methods — without dumping huge payloads.
|
||||
*
|
||||
* Examples:
|
||||
* describe useCanvasStore().canvas.graph
|
||||
* describe app.canvas
|
||||
* describe useCanvasStore().canvas.graph._nodes[0]
|
||||
*/
|
||||
const describeCmd: Command = async (ctx) => {
|
||||
const expr = stripOuterQuotes(ctx.argv.slice(1).join(' '))
|
||||
if (!expr) {
|
||||
return {
|
||||
stdout: stringIter(''),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: describe <expression>'
|
||||
}
|
||||
}
|
||||
try {
|
||||
const FnCtor = Function
|
||||
const fn = new FnCtor(
|
||||
...INJECT,
|
||||
`return (async () => { return (${expr}) })()`
|
||||
) as (...args: unknown[]) => Promise<unknown>
|
||||
const value: unknown = await fn(
|
||||
app,
|
||||
api,
|
||||
document,
|
||||
window,
|
||||
useCanvasStore,
|
||||
useCommandStore,
|
||||
useWorkflowStore,
|
||||
useMissingModelStore,
|
||||
useExecutionErrorStore,
|
||||
useSettingStore,
|
||||
useColorPaletteStore
|
||||
)
|
||||
return { stdout: stringIter(formatShape(value) + '\n'), exitCode: 0 }
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: stringIter(''),
|
||||
exitCode: 1,
|
||||
stderr: err instanceof Error ? err.message : String(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function formatShape(value: unknown): string {
|
||||
if (value === null) return 'null'
|
||||
if (value === undefined) return 'undefined'
|
||||
const t = typeof value
|
||||
if (t !== 'object' && t !== 'function') {
|
||||
return `${t}: ${JSON.stringify(value)}`
|
||||
}
|
||||
const ctor =
|
||||
(value as object).constructor?.name ??
|
||||
(t === 'function' ? 'Function' : 'object')
|
||||
const lines: string[] = [`${ctor} (${t})`]
|
||||
if (Array.isArray(value)) {
|
||||
lines.push(` length: ${value.length}`)
|
||||
if (value.length > 0) {
|
||||
lines.push(` [0]: ${summariseValue(value[0])}`)
|
||||
if (value.length > 1)
|
||||
lines.push(` [-1]: ${summariseValue(value[value.length - 1])}`)
|
||||
}
|
||||
return lines.join('\n')
|
||||
}
|
||||
const obj = value as Record<string, unknown>
|
||||
const keys = Object.keys(obj).sort()
|
||||
if (keys.length > 0) {
|
||||
lines.push(` own properties (${keys.length}):`)
|
||||
for (const k of keys.slice(0, 40)) {
|
||||
lines.push(` ${k}: ${summariseValue(obj[k])}`)
|
||||
}
|
||||
if (keys.length > 40) lines.push(` …${keys.length - 40} more`)
|
||||
}
|
||||
// Prototype methods (one level up, shallow)
|
||||
const proto = Object.getPrototypeOf(value)
|
||||
if (proto && proto !== Object.prototype && proto !== Function.prototype) {
|
||||
const protoKeys = Object.getOwnPropertyNames(proto)
|
||||
.filter((k) => k !== 'constructor')
|
||||
.sort()
|
||||
if (protoKeys.length > 0) {
|
||||
lines.push(` prototype methods (${protoKeys.length}):`)
|
||||
lines.push(' ' + protoKeys.slice(0, 30).join(', '))
|
||||
if (protoKeys.length > 30)
|
||||
lines.push(` …${protoKeys.length - 30} more`)
|
||||
}
|
||||
}
|
||||
return lines.join('\n')
|
||||
}
|
||||
|
||||
function summariseValue(v: unknown): string {
|
||||
if (v === null) return 'null'
|
||||
if (v === undefined) return 'undefined'
|
||||
const t = typeof v
|
||||
if (t === 'function') return 'function'
|
||||
if (t === 'string') return `string(${(v as string).length})`
|
||||
if (t === 'number' || t === 'boolean') return `${t} ${String(v)}`
|
||||
if (Array.isArray(v)) return `Array(${v.length})`
|
||||
if (t === 'object') {
|
||||
const ctor = (v as object).constructor?.name ?? 'object'
|
||||
return ctor
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
export function registerBrowserCommands(registry: CommandRegistry): void {
|
||||
registry.register('run-js', runJs)
|
||||
registry.register('describe', describeCmd)
|
||||
}
|
||||
@@ -1,171 +0,0 @@
|
||||
import type { Command, CommandRegistry } from '../types'
|
||||
import { emptyIter, stringIter } from '../types'
|
||||
|
||||
const API_BASE = 'https://comfy-codesearch.vercel.app'
|
||||
const DEFAULT_COUNT = 20
|
||||
|
||||
interface LineMatch {
|
||||
preview?: string
|
||||
lineNumber?: number
|
||||
}
|
||||
interface FileMatch {
|
||||
__typename?: string
|
||||
repository?: { name?: string }
|
||||
file?: { path?: string }
|
||||
lineMatches?: LineMatch[]
|
||||
}
|
||||
interface RepoMatch {
|
||||
__typename?: string
|
||||
name?: string
|
||||
}
|
||||
interface SearchResponse {
|
||||
data?: {
|
||||
search?: {
|
||||
stats?: { approximateResultCount?: string }
|
||||
results?: {
|
||||
matchCount?: number
|
||||
elapsedMilliseconds?: number
|
||||
results?: (FileMatch | RepoMatch)[]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function csFetch(
|
||||
endpoint: 'code' | 'repo',
|
||||
query: string
|
||||
): Promise<SearchResponse> {
|
||||
const url = `${API_BASE}/api/search/${endpoint}?query=${encodeURIComponent(query)}`
|
||||
const res = await fetch(url)
|
||||
if (!res.ok) {
|
||||
throw new Error(
|
||||
`comfy-codesearch ${endpoint}: API error ${res.status} ${res.statusText}`
|
||||
)
|
||||
}
|
||||
return (await res.json()) as SearchResponse
|
||||
}
|
||||
|
||||
function formatCodeResults(json: SearchResponse, query: string): string {
|
||||
const r = json.data?.search?.results
|
||||
const stats = json.data?.search?.stats
|
||||
const hits = (r?.results ?? []) as FileMatch[]
|
||||
if (hits.length === 0) {
|
||||
return `no matches for "${query}" across the public ComfyUI codebase.\n`
|
||||
}
|
||||
const repos = new Set<string>()
|
||||
for (const h of hits) if (h.repository?.name) repos.add(h.repository.name)
|
||||
const header =
|
||||
`${r?.matchCount ?? hits.length} match(es) in ${repos.size} repo(s)` +
|
||||
(stats?.approximateResultCount
|
||||
? ` (~${stats.approximateResultCount} total)`
|
||||
: '') +
|
||||
(r?.elapsedMilliseconds !== undefined
|
||||
? `, took ${r.elapsedMilliseconds}ms`
|
||||
: '') +
|
||||
':\n'
|
||||
const lines: string[] = []
|
||||
for (const h of hits) {
|
||||
const repo = h.repository?.name ?? '?'
|
||||
const path = h.file?.path ?? '?'
|
||||
const lms = h.lineMatches ?? []
|
||||
if (lms.length === 0) {
|
||||
lines.push(` ${repo} ${path}`)
|
||||
continue
|
||||
}
|
||||
for (const lm of lms) {
|
||||
const ln = lm.lineNumber ?? '?'
|
||||
const preview = (lm.preview ?? '').replace(/\s+$/, '')
|
||||
lines.push(` ${repo} ${path}:${ln}\n ${preview}`)
|
||||
}
|
||||
}
|
||||
return header + lines.join('\n') + '\n'
|
||||
}
|
||||
|
||||
function formatRepoResults(json: SearchResponse, query: string): string {
|
||||
const r = json.data?.search?.results
|
||||
const hits = (r?.results ?? []) as RepoMatch[]
|
||||
if (hits.length === 0) {
|
||||
return `no repos match "${query}" in the public ComfyUI codebase index.\n`
|
||||
}
|
||||
const lines = hits.map((h) => ' ' + (h.name ?? '?'))
|
||||
return `${hits.length} repo(s) match "${query}":\n` + lines.join('\n') + '\n'
|
||||
}
|
||||
|
||||
/**
|
||||
* comfy-codesearch <query> [--repo] [--count N]
|
||||
*
|
||||
* Search source code (or repo names) across the WHOLE public ComfyUI
|
||||
* community via cs.comfy.org. Use this to find node-class definitions,
|
||||
* extension APIs, or example code in repos that aren't yet published to
|
||||
* the registry — `node-search-registry` only sees published packs, but
|
||||
* many custom nodes live as plain GitHub repos.
|
||||
*
|
||||
* Query syntax is Sourcegraph-flavored:
|
||||
* - plain text fuzzy substring across all indexed repos
|
||||
* - `repo:Comfy-Org/ComfyUI foo` scope to a specific repo
|
||||
* - `count:50 foo` cap result count (otherwise --count is used)
|
||||
* - `class\\s+Wacom` regex
|
||||
*
|
||||
* Examples:
|
||||
* comfy-codesearch "NODE_CLASS_MAPPINGS.*[Ww]acom"
|
||||
* comfy-codesearch --repo wacom
|
||||
* comfy-codesearch "repo:Comfy-Org/ComfyUI last_node_id" --count 5
|
||||
*/
|
||||
const comfyCodesearch: Command = async (ctx) => {
|
||||
const args = ctx.argv.slice(1)
|
||||
let mode: 'code' | 'repo' = 'code'
|
||||
let count = DEFAULT_COUNT
|
||||
const queryParts: string[] = []
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
const a = args[i]
|
||||
if (a === '--repo' || a === '-r') {
|
||||
mode = 'repo'
|
||||
} else if (a === '--count' || a === '-c') {
|
||||
const next = args[i + 1]
|
||||
const n = Number(next)
|
||||
if (!Number.isFinite(n) || n <= 0) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: `comfy-codesearch: --count needs a positive number, got "${next ?? ''}"`
|
||||
}
|
||||
}
|
||||
count = n
|
||||
i++
|
||||
} else {
|
||||
queryParts.push(a)
|
||||
}
|
||||
}
|
||||
const query = queryParts.join(' ').trim()
|
||||
if (!query) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr:
|
||||
'usage: comfy-codesearch <query> [--repo] [--count N]\n' +
|
||||
' (searches the whole public ComfyUI community via cs.comfy.org)'
|
||||
}
|
||||
}
|
||||
let effectiveQuery = query
|
||||
if (mode === 'code' && !/\bcount:\d+/.test(query)) {
|
||||
effectiveQuery = `count:${count} ${query}`
|
||||
}
|
||||
try {
|
||||
const json = await csFetch(mode, effectiveQuery)
|
||||
const text =
|
||||
mode === 'code'
|
||||
? formatCodeResults(json, query)
|
||||
: formatRepoResults(json, query)
|
||||
return { stdout: stringIter(text), exitCode: 0 }
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: err instanceof Error ? err.message : String(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function registerCodesearchCommands(registry: CommandRegistry): void {
|
||||
registry.register('comfy-codesearch', comfyCodesearch)
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
import { useCommandStore } from '@/stores/commandStore'
|
||||
|
||||
import type { Command, CommandRegistry } from '../types'
|
||||
import { emptyIter, stringIter } from '../types'
|
||||
|
||||
const cmd: Command = async (ctx) => {
|
||||
const id = ctx.argv[1]
|
||||
if (!id) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: cmd <command-id> [args...]'
|
||||
}
|
||||
}
|
||||
const store = useCommandStore()
|
||||
const target = store.getCommand(id)
|
||||
if (!target) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 127,
|
||||
stderr: `cmd: unknown command id: ${id}`
|
||||
}
|
||||
}
|
||||
try {
|
||||
await store.execute(id)
|
||||
return { stdout: stringIter(`ok: ${id}\n`), exitCode: 0 }
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: err instanceof Error ? err.message : String(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const cmdList: Command = async (ctx) => {
|
||||
const store = useCommandStore()
|
||||
const patterns = ctx.argv.slice(1).filter(Boolean)
|
||||
const ids = store.commands
|
||||
.map((c) => c.id)
|
||||
.filter((id) => {
|
||||
if (patterns.length === 0) return true
|
||||
const lc = id.toLowerCase()
|
||||
return patterns.some((p) => {
|
||||
try {
|
||||
return new RegExp(p, 'i').test(id)
|
||||
} catch {
|
||||
return lc.includes(p.toLowerCase())
|
||||
}
|
||||
})
|
||||
})
|
||||
.sort()
|
||||
const out = ids.length === 0 ? '(no matches)\n' : ids.join('\n') + '\n'
|
||||
return { stdout: stringIter(out), exitCode: 0 }
|
||||
}
|
||||
|
||||
export function registerComfyCommands(registry: CommandRegistry): void {
|
||||
registry.register('cmd', cmd)
|
||||
registry.register('cmd-list', cmdList)
|
||||
}
|
||||
@@ -1,222 +0,0 @@
|
||||
import { useKeybindingStore } from '@/platform/keybindings/keybindingStore'
|
||||
import { useCommandStore } from '@/stores/commandStore'
|
||||
|
||||
import type { CmdContext, Command, CommandRegistry } from '../types'
|
||||
import { emptyIter, stringIter } from '../types'
|
||||
|
||||
/**
|
||||
* Namespace dispatcher for Comfy.* UI commands.
|
||||
*
|
||||
* Usage:
|
||||
* comfy list top-level namespaces (Canvas, Workflow…)
|
||||
* comfy --help same
|
||||
* comfy canvas list commands under Canvas
|
||||
* comfy canvas --help same
|
||||
* comfy canvas fitview execute Comfy.Canvas.FitView
|
||||
* comfy canvas fitview --help show description / shortcut / version
|
||||
*
|
||||
* Names match case-insensitive. Dot form (Comfy.Canvas.FitView) also works —
|
||||
* that's routed via the registry resolver, this command just gives the
|
||||
* nicer space-separated git-like ergonomics and --help at every level.
|
||||
*/
|
||||
interface CommandEntry {
|
||||
id: string
|
||||
label: string
|
||||
tooltip?: string
|
||||
versionAdded?: string
|
||||
}
|
||||
|
||||
function allCommands(): CommandEntry[] {
|
||||
return useCommandStore().commands.map((c) => ({
|
||||
id: c.id,
|
||||
label: c.label ?? c.id,
|
||||
tooltip: c.tooltip,
|
||||
versionAdded: c.versionAdded
|
||||
}))
|
||||
}
|
||||
|
||||
function filterByPath(
|
||||
cmds: CommandEntry[],
|
||||
pathParts: string[]
|
||||
): {
|
||||
exact: CommandEntry | null
|
||||
childNamesAtNextLevel: string[]
|
||||
descendants: CommandEntry[]
|
||||
} {
|
||||
const lower = pathParts.map((p) => p.toLowerCase())
|
||||
const descendants = cmds.filter((c) => {
|
||||
const parts = c.id.split('.').map((p) => p.toLowerCase())
|
||||
if (parts.length <= lower.length) return false
|
||||
for (let i = 0; i < lower.length; i++) {
|
||||
if (parts[i + 1] !== lower[i]) return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
const exact =
|
||||
cmds.find(
|
||||
(c) => c.id.toLowerCase() === ['comfy', ...lower].join('.').toLowerCase()
|
||||
) ?? null
|
||||
const nextLevelSet = new Set<string>()
|
||||
for (const c of descendants) {
|
||||
const parts = c.id.split('.')
|
||||
const nextPart = parts[lower.length + 1]
|
||||
if (nextPart) nextLevelSet.add(nextPart)
|
||||
}
|
||||
return {
|
||||
exact,
|
||||
childNamesAtNextLevel: [...nextLevelSet].sort(),
|
||||
descendants
|
||||
}
|
||||
}
|
||||
|
||||
function formatHelp(
|
||||
path: string[],
|
||||
entries: CommandEntry[],
|
||||
children: string[]
|
||||
): string {
|
||||
const header = path.length === 0 ? 'comfy' : 'comfy ' + path.join(' ')
|
||||
const lines: string[] = []
|
||||
lines.push(`\x1b[1m${header}\x1b[0m — ComfyUI command namespace`)
|
||||
lines.push('')
|
||||
if (children.length > 0) {
|
||||
lines.push('namespaces / subcommands:')
|
||||
for (const name of children) {
|
||||
// count how many commands are at or under this child
|
||||
const prefix = 'Comfy.' + [...path, name].join('.').toLowerCase()
|
||||
const count = entries.filter((c) =>
|
||||
c.id.toLowerCase().startsWith(prefix)
|
||||
).length
|
||||
const suffix = count > 1 ? ` (${count} commands)` : ''
|
||||
lines.push(` ${name.toLowerCase()}${suffix}`)
|
||||
}
|
||||
lines.push('')
|
||||
}
|
||||
lines.push(
|
||||
'tip: append --help at any level for details, or run the leaf to execute.'
|
||||
)
|
||||
return lines.join('\n') + '\n'
|
||||
}
|
||||
|
||||
function formatLeafHelp(entry: CommandEntry): string {
|
||||
const lines: string[] = []
|
||||
lines.push(`\x1b[1m${entry.id}\x1b[0m`)
|
||||
if (entry.label && entry.label !== entry.id)
|
||||
lines.push(` label: ${entry.label}`)
|
||||
if (entry.tooltip) lines.push(` tooltip: ${entry.tooltip}`)
|
||||
const kb = useKeybindingStore().getKeybindingByCommandId(entry.id)
|
||||
if (kb?.combo) {
|
||||
const keys = [
|
||||
kb.combo.ctrl && 'Ctrl',
|
||||
kb.combo.alt && 'Alt',
|
||||
kb.combo.shift && 'Shift',
|
||||
kb.combo.key
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join('+')
|
||||
lines.push(` shortcut: ${keys}`)
|
||||
}
|
||||
if (entry.versionAdded) lines.push(` added: v${entry.versionAdded}`)
|
||||
lines.push('')
|
||||
lines.push(
|
||||
'invocation: run without --help to execute, e.g. comfy ' +
|
||||
entry.id
|
||||
.replace(/^Comfy\./, '')
|
||||
.split('.')
|
||||
.join(' ')
|
||||
.toLowerCase()
|
||||
)
|
||||
lines.push(' or: ' + entry.id)
|
||||
return lines.join('\n') + '\n'
|
||||
}
|
||||
|
||||
async function executeLeaf(
|
||||
id: string,
|
||||
args: string[] = []
|
||||
): Promise<{
|
||||
stdout: AsyncIterable<string>
|
||||
exitCode: number
|
||||
stderr?: string
|
||||
}> {
|
||||
const store = useCommandStore()
|
||||
try {
|
||||
await store.execute(id, { metadata: { args } })
|
||||
const suffix = args.length > 0 ? ` (args: ${args.join(' ')})` : ''
|
||||
return { stdout: stringIter(`ok: ${id}${suffix}\n`), exitCode: 0 }
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: err instanceof Error ? err.message : String(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Progressive leaf resolution: walk the path from longest to shortest,
|
||||
* returning the first prefix that resolves to an exact registered command.
|
||||
* The remaining trailing tokens become passthrough args (delivered via
|
||||
* `metadata.args` to the command function).
|
||||
*/
|
||||
function resolveLongestLeaf(
|
||||
cmds: CommandEntry[],
|
||||
pathParts: string[]
|
||||
): { leaf: CommandEntry; args: string[] } | null {
|
||||
for (let n = pathParts.length; n >= 1; n--) {
|
||||
const prefix = pathParts.slice(0, n)
|
||||
const { exact } = filterByPath(cmds, prefix)
|
||||
if (exact) return { leaf: exact, args: pathParts.slice(n) }
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
const comfyCmd: Command = async (ctx: CmdContext) => {
|
||||
const rawArgs = ctx.argv.slice(1)
|
||||
const wantsHelp =
|
||||
rawArgs[rawArgs.length - 1] === '--help' ||
|
||||
rawArgs[rawArgs.length - 1] === '-h'
|
||||
const pathParts = rawArgs.filter((a) => a !== '--help' && a !== '-h')
|
||||
|
||||
const cmds = allCommands()
|
||||
const { exact, childNamesAtNextLevel, descendants } = filterByPath(
|
||||
cmds,
|
||||
pathParts
|
||||
)
|
||||
|
||||
// Leaf command + --help → show that command's detail
|
||||
if (exact && wantsHelp) {
|
||||
return { stdout: stringIter(formatLeafHelp(exact)), exitCode: 0 }
|
||||
}
|
||||
|
||||
// Leaf command (no --help) → execute
|
||||
if (exact && childNamesAtNextLevel.length === 0) {
|
||||
return executeLeaf(exact.id)
|
||||
}
|
||||
|
||||
// If there's an exact match AND children, ambiguous: prefer execute when
|
||||
// no more args, else treat as a namespace (shouldn't really happen in
|
||||
// the current ComfyUI namespace but guard anyway).
|
||||
if (exact && pathParts.length > 0 && !wantsHelp) {
|
||||
return executeLeaf(exact.id)
|
||||
}
|
||||
|
||||
// Not a leaf — try progressive resolution: maybe the first N tokens
|
||||
// name a leaf and the rest are passthrough args (e.g.
|
||||
// `comfy saveworkflowas bbb` → Comfy.SaveWorkflowAs with args=['bbb']).
|
||||
if (pathParts.length > 0 && descendants.length === 0 && !exact) {
|
||||
const resolved = resolveLongestLeaf(cmds, pathParts)
|
||||
if (resolved) return executeLeaf(resolved.leaf.id, resolved.args)
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `comfy: no command or namespace '${pathParts.join(' ')}'`
|
||||
}
|
||||
}
|
||||
return {
|
||||
stdout: stringIter(formatHelp(pathParts, cmds, childNamesAtNextLevel)),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
|
||||
export function registerComfyNamespace(registry: CommandRegistry): void {
|
||||
registry.register('comfy', comfyCmd)
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { CommandRegistryImpl } from '../runtime'
|
||||
import type { CmdContext } from '../types'
|
||||
import { collect, emptyIter, stringIter } from '../types'
|
||||
import { MemoryVFS } from '../vfs/memory'
|
||||
import { coreutils, registerCoreutils } from './coreutils'
|
||||
|
||||
function baseCtx(
|
||||
argv: string[],
|
||||
stdin: AsyncIterable<string> = emptyIter(),
|
||||
vfs = new MemoryVFS()
|
||||
): CmdContext {
|
||||
return {
|
||||
argv,
|
||||
stdin,
|
||||
env: new Map(),
|
||||
cwd: '/',
|
||||
vfs,
|
||||
signal: new AbortController().signal
|
||||
}
|
||||
}
|
||||
|
||||
describe('coreutils', () => {
|
||||
it('echo joins args with space', async () => {
|
||||
const r = await coreutils.echo(baseCtx(['echo', 'hello', 'world']))
|
||||
expect(await collect(r.stdout)).toBe('hello world\n')
|
||||
})
|
||||
|
||||
it('echo -n omits newline', async () => {
|
||||
const r = await coreutils.echo(baseCtx(['echo', '-n', 'hi']))
|
||||
expect(await collect(r.stdout)).toBe('hi')
|
||||
})
|
||||
|
||||
it('cat reads file', async () => {
|
||||
const fs = new MemoryVFS()
|
||||
await fs.write('/f', 'contents')
|
||||
const r = await coreutils.cat(baseCtx(['cat', '/f'], emptyIter(), fs))
|
||||
expect(await collect(r.stdout)).toBe('contents')
|
||||
})
|
||||
|
||||
it('cat passes through stdin with no args', async () => {
|
||||
const r = await coreutils.cat(baseCtx(['cat'], stringIter('passed\n')))
|
||||
expect(await collect(r.stdout)).toBe('passed\n')
|
||||
})
|
||||
|
||||
it('ls lists sorted entries', async () => {
|
||||
const fs = new MemoryVFS()
|
||||
await fs.write('/b', '')
|
||||
await fs.write('/a', '')
|
||||
await fs.write('/sub/x', '')
|
||||
const r = await coreutils.ls(baseCtx(['ls', '/'], emptyIter(), fs))
|
||||
expect(await collect(r.stdout)).toBe('a\nb\nsub/\n')
|
||||
})
|
||||
|
||||
it('pwd emits cwd', async () => {
|
||||
const r = await coreutils.pwd(baseCtx(['pwd']))
|
||||
expect(await collect(r.stdout)).toBe('/\n')
|
||||
})
|
||||
|
||||
it('wc counts lines, words, bytes', async () => {
|
||||
const r = await coreutils.wc(baseCtx(['wc'], stringIter('a\nb\nc\n')))
|
||||
expect(await collect(r.stdout)).toBe('3 3 6\n')
|
||||
})
|
||||
|
||||
it('head -n 2 keeps first 2', async () => {
|
||||
const r = await coreutils.head(
|
||||
baseCtx(['head', '-n', '2'], stringIter('1\n2\n3\n4\n'))
|
||||
)
|
||||
expect(await collect(r.stdout)).toBe('1\n2\n')
|
||||
})
|
||||
|
||||
it('tail -n 2 keeps last 2', async () => {
|
||||
const r = await coreutils.tail(
|
||||
baseCtx(['tail', '-n', '2'], stringIter('1\n2\n3\n4\n'))
|
||||
)
|
||||
expect(await collect(r.stdout)).toBe('3\n4\n')
|
||||
})
|
||||
|
||||
it('grep filters', async () => {
|
||||
const r = await coreutils.grep(
|
||||
baseCtx(['grep', 'foo'], stringIter('foo\nbar\nfood\n'))
|
||||
)
|
||||
expect(await collect(r.stdout)).toBe('foo\nfood\n')
|
||||
})
|
||||
|
||||
it('true exits 0, false exits 1', async () => {
|
||||
expect((await coreutils.true(baseCtx(['true']))).exitCode).toBe(0)
|
||||
expect((await coreutils.false(baseCtx(['false']))).exitCode).toBe(1)
|
||||
})
|
||||
|
||||
it('seq N counts 1..N inclusive', async () => {
|
||||
const r = await coreutils.seq(baseCtx(['seq', '3']))
|
||||
expect(await collect(r.stdout)).toBe('1\n2\n3\n')
|
||||
})
|
||||
|
||||
it('seq A B counts A..B inclusive', async () => {
|
||||
const r = await coreutils.seq(baseCtx(['seq', '5', '8']))
|
||||
expect(await collect(r.stdout)).toBe('5\n6\n7\n8\n')
|
||||
})
|
||||
|
||||
it('seq A STEP B supports custom step', async () => {
|
||||
const r = await coreutils.seq(baseCtx(['seq', '10', '5', '25']))
|
||||
expect(await collect(r.stdout)).toBe('10\n15\n20\n25\n')
|
||||
})
|
||||
|
||||
it('seq supports negative step', async () => {
|
||||
const r = await coreutils.seq(baseCtx(['seq', '3', '-1', '1']))
|
||||
expect(await collect(r.stdout)).toBe('3\n2\n1\n')
|
||||
})
|
||||
|
||||
it('registerCoreutils registers all commands', () => {
|
||||
const reg = new CommandRegistryImpl()
|
||||
registerCoreutils(reg)
|
||||
expect(reg.list()).toEqual(
|
||||
[
|
||||
'cat',
|
||||
'echo',
|
||||
'false',
|
||||
'grep',
|
||||
'head',
|
||||
'ls',
|
||||
'pwd',
|
||||
'seq',
|
||||
'tail',
|
||||
'true',
|
||||
'wc'
|
||||
].sort()
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -1,184 +0,0 @@
|
||||
import type { CmdContext, CmdResult, Command, CommandRegistry } from '../types'
|
||||
import { collect, emptyIter, lines, stringIter } from '../types'
|
||||
|
||||
function ok(stdout: AsyncIterable<string>, exitCode = 0): CmdResult {
|
||||
return { stdout, exitCode }
|
||||
}
|
||||
|
||||
function err(message: string, exitCode = 2): CmdResult {
|
||||
return { stdout: emptyIter(), exitCode, stderr: message }
|
||||
}
|
||||
|
||||
const echo: Command = async (ctx) => {
|
||||
const args = ctx.argv.slice(1)
|
||||
let newline = true
|
||||
if (args[0] === '-n') {
|
||||
newline = false
|
||||
args.shift()
|
||||
}
|
||||
const text = args.join(' ') + (newline ? '\n' : '')
|
||||
return ok(stringIter(text))
|
||||
}
|
||||
|
||||
const cat: Command = async (ctx) => {
|
||||
const paths = ctx.argv.slice(1)
|
||||
if (paths.length === 0) return ok(ctx.stdin)
|
||||
async function* gen(): AsyncIterable<string> {
|
||||
for (const p of paths) {
|
||||
yield await ctx.vfs.read(p)
|
||||
}
|
||||
}
|
||||
return ok(gen())
|
||||
}
|
||||
|
||||
const ls: Command = async (ctx) => {
|
||||
const path = ctx.argv[1] ?? ctx.cwd
|
||||
const entries = await ctx.vfs.list(path)
|
||||
const out =
|
||||
entries.map((e) => (e.type === 'dir' ? e.name + '/' : e.name)).join('\n') +
|
||||
(entries.length > 0 ? '\n' : '')
|
||||
return ok(stringIter(out))
|
||||
}
|
||||
|
||||
const pwd: Command = async (ctx) => ok(stringIter(ctx.cwd + '\n'))
|
||||
|
||||
const wc: Command = async (ctx) => {
|
||||
const data = await collect(ctx.stdin)
|
||||
const bytes = data.length
|
||||
const lineCount =
|
||||
data === '' ? 0 : data.split('\n').length - (data.endsWith('\n') ? 1 : 0)
|
||||
const words = data.split(/\s+/).filter((w) => w.length > 0).length
|
||||
return ok(stringIter(`${lineCount} ${words} ${bytes}\n`))
|
||||
}
|
||||
|
||||
function parseNFlag(
|
||||
argv: string[],
|
||||
defaultN: number
|
||||
): { n: number; rest: string[] } {
|
||||
const rest = argv.slice(1)
|
||||
let n = defaultN
|
||||
if (rest[0] === '-n') {
|
||||
const parsed = Number(rest[1])
|
||||
if (!Number.isFinite(parsed)) throw new Error('invalid -n value')
|
||||
n = parsed
|
||||
rest.splice(0, 2)
|
||||
} else if (rest[0]?.startsWith('-n')) {
|
||||
const parsed = Number(rest[0].slice(2))
|
||||
if (!Number.isFinite(parsed)) throw new Error('invalid -n value')
|
||||
n = parsed
|
||||
rest.shift()
|
||||
}
|
||||
return { n, rest }
|
||||
}
|
||||
|
||||
const head: Command = async (ctx) => {
|
||||
let n: number
|
||||
try {
|
||||
;({ n } = parseNFlag(ctx.argv, 10))
|
||||
} catch (e) {
|
||||
return err('usage: head [-n N]')
|
||||
}
|
||||
async function* gen(): AsyncIterable<string> {
|
||||
let i = 0
|
||||
for await (const line of lines(ctx.stdin)) {
|
||||
if (i >= n) break
|
||||
yield line + '\n'
|
||||
i++
|
||||
}
|
||||
}
|
||||
return ok(gen())
|
||||
}
|
||||
|
||||
const tail: Command = async (ctx) => {
|
||||
let n: number
|
||||
try {
|
||||
;({ n } = parseNFlag(ctx.argv, 10))
|
||||
} catch (e) {
|
||||
return err('usage: tail [-n N]')
|
||||
}
|
||||
const buf: string[] = []
|
||||
for await (const line of lines(ctx.stdin)) {
|
||||
buf.push(line)
|
||||
if (buf.length > n) buf.shift()
|
||||
}
|
||||
const out = buf.length > 0 ? buf.join('\n') + '\n' : ''
|
||||
return ok(stringIter(out))
|
||||
}
|
||||
|
||||
const grep: Command = async (ctx) => {
|
||||
const pattern = ctx.argv[1]
|
||||
if (!pattern) return err('usage: grep <pattern>')
|
||||
const re = new RegExp(pattern)
|
||||
// POSIX grep returns 1 when nothing matched. To honour that we have to
|
||||
// drain stdin eagerly — exit codes are set on the Command return, but a
|
||||
// generator can't change them after the fact. The agent relies on this
|
||||
// for `grep ... && ...` / `grep ... || ...` flows; without the right
|
||||
// exit code the LLM would conclude evidence existed when stdout was
|
||||
// actually empty.
|
||||
let matched = false
|
||||
let out = ''
|
||||
for await (const line of lines(ctx.stdin)) {
|
||||
if (re.test(line)) {
|
||||
out += line + '\n'
|
||||
matched = true
|
||||
}
|
||||
}
|
||||
return ok(stringIter(out), matched ? 0 : 1)
|
||||
}
|
||||
|
||||
const trueCmd: Command = async () => ok(emptyIter(), 0)
|
||||
const falseCmd: Command = async () => ok(emptyIter(), 1)
|
||||
|
||||
const seqCmd: Command = async (ctx) => {
|
||||
const args = ctx.argv.slice(1).map(Number)
|
||||
if (args.some((n) => !Number.isFinite(n))) {
|
||||
return err('usage: seq [start] [step] end')
|
||||
}
|
||||
let start = 1,
|
||||
step = 1,
|
||||
end: number
|
||||
if (args.length === 1) end = args[0]
|
||||
else if (args.length === 2) {
|
||||
start = args[0]
|
||||
end = args[1]
|
||||
} else if (args.length === 3) {
|
||||
start = args[0]
|
||||
step = args[1]
|
||||
end = args[2]
|
||||
} else {
|
||||
return err('usage: seq [start] [step] end')
|
||||
}
|
||||
if (step === 0) return err('step must not be zero')
|
||||
const out: string[] = []
|
||||
if (step > 0) for (let i = start; i <= end; i += step) out.push(String(i))
|
||||
else for (let i = start; i >= end; i += step) out.push(String(i))
|
||||
return ok(stringIter(out.join('\n') + (out.length ? '\n' : '')))
|
||||
}
|
||||
|
||||
export function registerCoreutils(registry: CommandRegistry): void {
|
||||
registry.register('echo', echo)
|
||||
registry.register('cat', cat)
|
||||
registry.register('ls', ls)
|
||||
registry.register('pwd', pwd)
|
||||
registry.register('wc', wc)
|
||||
registry.register('head', head)
|
||||
registry.register('tail', tail)
|
||||
registry.register('grep', grep)
|
||||
registry.register('true', trueCmd)
|
||||
registry.register('false', falseCmd)
|
||||
registry.register('seq', seqCmd)
|
||||
}
|
||||
|
||||
export const coreutils = {
|
||||
echo,
|
||||
cat,
|
||||
ls,
|
||||
pwd,
|
||||
wc,
|
||||
head,
|
||||
tail,
|
||||
grep,
|
||||
true: trueCmd,
|
||||
false: falseCmd,
|
||||
seq: seqCmd
|
||||
} satisfies Record<string, (ctx: CmdContext) => Promise<CmdResult>>
|
||||
@@ -1,145 +0,0 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
vi.mock('@/scripts/api', () => {
|
||||
class FakeApi extends EventTarget {
|
||||
getQueue = vi.fn()
|
||||
getHistory = vi.fn()
|
||||
getJobDetail = vi.fn()
|
||||
}
|
||||
return { api: new FakeApi() }
|
||||
})
|
||||
|
||||
import { api } from '@/scripts/api'
|
||||
|
||||
import { CommandRegistryImpl } from '../runtime'
|
||||
import type { CmdContext } from '../types'
|
||||
import { collect, emptyIter } from '../types'
|
||||
import { MemoryVFS } from '../vfs/memory'
|
||||
import { registerExecutionCommands } from './execution'
|
||||
|
||||
const mocked = vi.mocked(api)
|
||||
|
||||
function ctx(argv: string[], signal?: AbortSignal): CmdContext {
|
||||
return {
|
||||
argv,
|
||||
stdin: emptyIter(),
|
||||
env: new Map(),
|
||||
cwd: '/',
|
||||
vfs: new MemoryVFS(),
|
||||
signal: signal ?? new AbortController().signal
|
||||
}
|
||||
}
|
||||
|
||||
describe('execution commands', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
it('queue-status lists running and pending', async () => {
|
||||
mocked.getQueue.mockResolvedValue({
|
||||
Running: [
|
||||
{ id: 'r1', status: 'in_progress', create_time: 1, priority: 0 }
|
||||
],
|
||||
Pending: [
|
||||
{ id: 'p1', status: 'pending', create_time: 2, priority: 0 },
|
||||
{ id: 'p2', status: 'pending', create_time: 3, priority: 0 }
|
||||
]
|
||||
})
|
||||
const r = new CommandRegistryImpl()
|
||||
registerExecutionCommands(r)
|
||||
const res = await r.get('queue-status')!(ctx(['queue-status']))
|
||||
const out = await collect(res.stdout)
|
||||
expect(out).toContain('running: 1')
|
||||
expect(out).toContain('pending: 2')
|
||||
expect(out).toContain('r1')
|
||||
expect(out).toContain('p2')
|
||||
})
|
||||
|
||||
it('history --last=2 returns 2 rows', async () => {
|
||||
mocked.getHistory.mockResolvedValue([
|
||||
{
|
||||
id: 'a',
|
||||
status: 'completed',
|
||||
create_time: 1,
|
||||
priority: 0
|
||||
},
|
||||
{
|
||||
id: 'b',
|
||||
status: 'completed',
|
||||
create_time: 2,
|
||||
priority: 0
|
||||
}
|
||||
])
|
||||
const r = new CommandRegistryImpl()
|
||||
registerExecutionCommands(r)
|
||||
const res = await r.get('history')!(ctx(['history', '--last=2']))
|
||||
expect(mocked.getHistory).toHaveBeenCalledWith(2)
|
||||
const out = await collect(res.stdout)
|
||||
expect(out.split('\n').filter(Boolean)).toHaveLength(2)
|
||||
})
|
||||
|
||||
it('wait-queue returns immediately when idle', async () => {
|
||||
mocked.getQueue.mockResolvedValue({ Running: [], Pending: [] })
|
||||
const r = new CommandRegistryImpl()
|
||||
registerExecutionCommands(r)
|
||||
const res = await r.get('wait-queue')!(
|
||||
ctx(['wait-queue', '--timeout=1', '--poll=1'])
|
||||
)
|
||||
expect(res.exitCode).toBe(0)
|
||||
expect(await collect(res.stdout)).toMatch(/queue idle/)
|
||||
})
|
||||
|
||||
it('wait-queue respects aborted signal', async () => {
|
||||
mocked.getQueue.mockResolvedValue({
|
||||
Running: [
|
||||
{ id: 'r', status: 'in_progress', create_time: 1, priority: 0 }
|
||||
],
|
||||
Pending: []
|
||||
})
|
||||
const ac = new AbortController()
|
||||
ac.abort()
|
||||
const r = new CommandRegistryImpl()
|
||||
registerExecutionCommands(r)
|
||||
const res = await r.get('wait-queue')!(
|
||||
ctx(['wait-queue', '--timeout=1', '--poll=1'], ac.signal)
|
||||
)
|
||||
expect(res.exitCode).toBe(130)
|
||||
})
|
||||
|
||||
it('latest-output returns no history when empty', async () => {
|
||||
mocked.getHistory.mockResolvedValue([])
|
||||
const r = new CommandRegistryImpl()
|
||||
registerExecutionCommands(r)
|
||||
const res = await r.get('latest-output')!(ctx(['latest-output']))
|
||||
expect(res.exitCode).toBe(1)
|
||||
expect(res.stderr).toContain('no history')
|
||||
})
|
||||
|
||||
it('latest-output emits view URLs for image outputs', async () => {
|
||||
mocked.getHistory.mockResolvedValue([
|
||||
{
|
||||
id: 'job-1',
|
||||
status: 'completed',
|
||||
create_time: 1,
|
||||
priority: 0
|
||||
}
|
||||
])
|
||||
mocked.getJobDetail.mockResolvedValue({
|
||||
id: 'job-1',
|
||||
status: 'completed',
|
||||
create_time: 1,
|
||||
priority: 0,
|
||||
outputs: {
|
||||
'9': {
|
||||
images: [{ filename: 'out.png', subfolder: '', type: 'output' }]
|
||||
}
|
||||
}
|
||||
})
|
||||
const r = new CommandRegistryImpl()
|
||||
registerExecutionCommands(r)
|
||||
const res = await r.get('latest-output')!(ctx(['latest-output']))
|
||||
const out = await collect(res.stdout)
|
||||
expect(out).toContain('job-1')
|
||||
expect(out).toContain('/view?filename=out.png')
|
||||
})
|
||||
})
|
||||
@@ -1,120 +0,0 @@
|
||||
import { api } from '@/scripts/api'
|
||||
|
||||
import type { Command, CommandRegistry } from '../types'
|
||||
import { emptyIter, stringIter } from '../types'
|
||||
|
||||
interface RawJob {
|
||||
id: string
|
||||
status: string
|
||||
execution_error?: unknown
|
||||
outputs_count?: number | null
|
||||
workflow_id?: string | null
|
||||
}
|
||||
|
||||
function jobState(j: RawJob): string {
|
||||
if (j.execution_error) return 'error'
|
||||
return j.status || 'unknown'
|
||||
}
|
||||
|
||||
function fmtJob(j: RawJob): string {
|
||||
return `${jobState(j)}\t${j.id}\t${j.workflow_id ?? ''}`
|
||||
}
|
||||
|
||||
const queueStatus: Command = async () => {
|
||||
const { Running, Pending } = await api.getQueue()
|
||||
const lines: string[] = []
|
||||
lines.push(`running: ${Running.length}`)
|
||||
for (const j of Running) lines.push(' ' + fmtJob(j as unknown as RawJob))
|
||||
lines.push(`pending: ${Pending.length}`)
|
||||
for (const j of Pending) lines.push(' ' + fmtJob(j as unknown as RawJob))
|
||||
return { stdout: stringIter(lines.join('\n') + '\n'), exitCode: 0 }
|
||||
}
|
||||
|
||||
const historyCmd: Command = async (ctx) => {
|
||||
const arg = ctx.argv.find((a) => a.startsWith('--last='))
|
||||
const last = arg ? Number(arg.slice(7)) : 10
|
||||
const max = Number.isFinite(last) && last > 0 ? Math.min(last, 200) : 10
|
||||
const items = await api.getHistory(max)
|
||||
const lines = items.map((j) => fmtJob(j as unknown as RawJob))
|
||||
return {
|
||||
stdout: stringIter(lines.join('\n') + (lines.length ? '\n' : '')),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
|
||||
const waitQueue: Command = async (ctx) => {
|
||||
const timeoutArg = ctx.argv.find((a) => a.startsWith('--timeout='))
|
||||
const timeoutMs = timeoutArg ? Number(timeoutArg.slice(10)) * 1000 : 300_000
|
||||
const pollArg = ctx.argv.find((a) => a.startsWith('--poll='))
|
||||
const pollMs = pollArg ? Number(pollArg.slice(7)) * 1000 : 1000
|
||||
const started = Date.now()
|
||||
|
||||
while (Date.now() - started < timeoutMs) {
|
||||
if (ctx.signal.aborted) {
|
||||
return { stdout: emptyIter(), exitCode: 130, stderr: 'aborted' }
|
||||
}
|
||||
const { Running, Pending } = await api.getQueue()
|
||||
if (Running.length === 0 && Pending.length === 0) {
|
||||
const elapsed = ((Date.now() - started) / 1000).toFixed(1)
|
||||
return {
|
||||
stdout: stringIter(`queue idle after ${elapsed}s\n`),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
await new Promise((r) => setTimeout(r, pollMs))
|
||||
}
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 124,
|
||||
stderr: `timed out after ${timeoutMs / 1000}s`
|
||||
}
|
||||
}
|
||||
|
||||
const latestOutput: Command = async () => {
|
||||
const items = await api.getHistory(1)
|
||||
if (items.length === 0) {
|
||||
return { stdout: emptyIter(), exitCode: 1, stderr: 'no history' }
|
||||
}
|
||||
const job = items[0] as unknown as RawJob
|
||||
const detail = await api.getJobDetail(job.id)
|
||||
const outputs = detail?.outputs ?? {}
|
||||
const previews: string[] = []
|
||||
for (const [nodeId, out] of Object.entries(outputs)) {
|
||||
const images = (
|
||||
out as {
|
||||
images?: { filename?: string; subfolder?: string; type?: string }[]
|
||||
}
|
||||
).images
|
||||
if (!images) continue
|
||||
for (const img of images) {
|
||||
if (!img.filename) continue
|
||||
const sub = img.subfolder
|
||||
? `&subfolder=${encodeURIComponent(img.subfolder)}`
|
||||
: ''
|
||||
const type = img.type ? `&type=${encodeURIComponent(img.type)}` : ''
|
||||
previews.push(
|
||||
`node=${nodeId}\t/view?filename=${encodeURIComponent(img.filename)}${sub}${type}`
|
||||
)
|
||||
}
|
||||
}
|
||||
const state = jobState(job)
|
||||
if (previews.length === 0) {
|
||||
return {
|
||||
stdout: stringIter(`job ${job.id}\t${state}\tno images\n`),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
return {
|
||||
stdout: stringIter(
|
||||
[`job: ${job.id}`, `state: ${state}`, ...previews].join('\n') + '\n'
|
||||
),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
|
||||
export function registerExecutionCommands(registry: CommandRegistry): void {
|
||||
registry.register('queue-status', queueStatus)
|
||||
registry.register('history', historyCmd)
|
||||
registry.register('wait-queue', waitQueue)
|
||||
registry.register('latest-output', latestOutput)
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const canvasRef = { value: null as unknown }
|
||||
vi.mock('@/renderer/core/canvas/canvasStore', () => ({
|
||||
useCanvasStore: () => ({
|
||||
get canvas() {
|
||||
return canvasRef.value
|
||||
},
|
||||
set canvas(v: unknown) {
|
||||
canvasRef.value = v
|
||||
}
|
||||
})
|
||||
}))
|
||||
|
||||
import { CommandRegistryImpl } from '../runtime'
|
||||
import type { CmdContext } from '../types'
|
||||
import { collect, emptyIter } from '../types'
|
||||
import { MemoryVFS } from '../vfs/memory'
|
||||
import { registerGraphCommands } from './graph'
|
||||
|
||||
function ctx(argv: string[]): CmdContext {
|
||||
return {
|
||||
argv,
|
||||
stdin: emptyIter(),
|
||||
env: new Map(),
|
||||
cwd: '/',
|
||||
vfs: new MemoryVFS(),
|
||||
signal: new AbortController().signal
|
||||
}
|
||||
}
|
||||
|
||||
function setGraph(nodes: unknown[]) {
|
||||
canvasRef.value = { graph: { _nodes: nodes } }
|
||||
}
|
||||
|
||||
describe('graph command', () => {
|
||||
beforeEach(() => {
|
||||
canvasRef.value = null
|
||||
})
|
||||
|
||||
it('errors when no active graph', async () => {
|
||||
const r = new CommandRegistryImpl()
|
||||
registerGraphCommands(r)
|
||||
const res = await r.get('graph')!(ctx(['graph', 'summary']))
|
||||
expect(res.exitCode).toBe(1)
|
||||
expect(res.stderr).toContain('no active graph')
|
||||
})
|
||||
|
||||
it('summary lists type counts', async () => {
|
||||
setGraph([
|
||||
{ id: 1, comfyClass: 'KSampler' },
|
||||
{ id: 2, comfyClass: 'KSampler' },
|
||||
{ id: 3, comfyClass: 'CheckpointLoaderSimple' }
|
||||
])
|
||||
const r = new CommandRegistryImpl()
|
||||
registerGraphCommands(r)
|
||||
const res = await r.get('graph')!(ctx(['graph', 'summary']))
|
||||
const out = await collect(res.stdout)
|
||||
expect(out).toContain('nodes: 3')
|
||||
expect(out).toContain('2\tKSampler')
|
||||
expect(out).toContain('1\tCheckpointLoaderSimple')
|
||||
})
|
||||
|
||||
it('nodes with regex filters by type', async () => {
|
||||
setGraph([
|
||||
{ id: 1, comfyClass: 'KSampler', title: 'main' },
|
||||
{ id: 2, comfyClass: 'CLIPTextEncode' }
|
||||
])
|
||||
const r = new CommandRegistryImpl()
|
||||
registerGraphCommands(r)
|
||||
const res = await r.get('graph')!(ctx(['graph', 'nodes', 'KSampler']))
|
||||
const out = await collect(res.stdout)
|
||||
expect(out).toContain('1\tKSampler\tmain')
|
||||
expect(out).not.toContain('CLIPTextEncode')
|
||||
})
|
||||
|
||||
it('node <id> returns JSON summary', async () => {
|
||||
setGraph([
|
||||
{
|
||||
id: 5,
|
||||
comfyClass: 'KSampler',
|
||||
pos: [10, 20],
|
||||
widgets: [{ name: 'seed', value: 42, type: 'int' }],
|
||||
inputs: [{ name: 'model', type: 'MODEL', link: null }],
|
||||
outputs: [{ name: 'LATENT', type: 'LATENT', links: [1, 2] }]
|
||||
}
|
||||
])
|
||||
const r = new CommandRegistryImpl()
|
||||
registerGraphCommands(r)
|
||||
const res = await r.get('graph')!(ctx(['graph', 'node', '5']))
|
||||
const out = await collect(res.stdout)
|
||||
const parsed = JSON.parse(out)
|
||||
expect(parsed.id).toBe(5)
|
||||
expect(parsed.type).toBe('KSampler')
|
||||
expect(parsed.widgets[0]).toEqual({ name: 'seed', value: 42, type: 'int' })
|
||||
expect(parsed.outputs[0].linkCount).toBe(2)
|
||||
})
|
||||
|
||||
it('node <id> errors on missing node', async () => {
|
||||
setGraph([{ id: 1, comfyClass: 'X' }])
|
||||
const r = new CommandRegistryImpl()
|
||||
registerGraphCommands(r)
|
||||
const res = await r.get('graph')!(ctx(['graph', 'node', '99']))
|
||||
expect(res.exitCode).toBe(1)
|
||||
expect(res.stderr).toContain('no node 99')
|
||||
})
|
||||
|
||||
it('set-widget mutates value and fires callback', async () => {
|
||||
const cb = vi.fn()
|
||||
setGraph([
|
||||
{
|
||||
id: 3,
|
||||
comfyClass: 'KSampler',
|
||||
widgets: [{ name: 'cfg', type: 'FLOAT', value: 8, callback: cb }]
|
||||
}
|
||||
])
|
||||
const r = new CommandRegistryImpl()
|
||||
registerGraphCommands(r)
|
||||
const res = await r.get('set-widget')!(
|
||||
ctx(['set-widget', '3', 'cfg', '6.5'])
|
||||
)
|
||||
expect(res.exitCode).toBe(0)
|
||||
expect(cb).toHaveBeenCalledWith(6.5)
|
||||
expect(await collect(res.stdout)).toContain('6.5')
|
||||
})
|
||||
|
||||
it('set-widget errors on missing widget', async () => {
|
||||
setGraph([{ id: 3, comfyClass: 'KSampler', widgets: [] }])
|
||||
const r = new CommandRegistryImpl()
|
||||
registerGraphCommands(r)
|
||||
const res = await r.get('set-widget')!(
|
||||
ctx(['set-widget', '3', 'nope', '1'])
|
||||
)
|
||||
expect(res.exitCode).toBe(1)
|
||||
expect(res.stderr).toContain('no widget')
|
||||
})
|
||||
})
|
||||
@@ -1,197 +0,0 @@
|
||||
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
|
||||
|
||||
import type { Command, CommandRegistry } from '../types'
|
||||
import { emptyIter, stringIter } from '../types'
|
||||
|
||||
interface WidgetSummary {
|
||||
name: string
|
||||
value: unknown
|
||||
type?: string
|
||||
}
|
||||
|
||||
interface NodeSummary {
|
||||
id: number | string
|
||||
type: string
|
||||
title?: string
|
||||
pos?: [number, number]
|
||||
mode?: number
|
||||
widgets?: WidgetSummary[]
|
||||
inputs?: { name: string; type: string; linkId?: number | null }[]
|
||||
outputs?: { name: string; type: string; linkCount: number }[]
|
||||
}
|
||||
|
||||
function getGraph() {
|
||||
const canvas = useCanvasStore().canvas
|
||||
return canvas?.graph ?? null
|
||||
}
|
||||
|
||||
function summarizeNode(node: unknown): NodeSummary {
|
||||
const n = node as {
|
||||
id: number
|
||||
type?: string
|
||||
comfyClass?: string
|
||||
title?: string
|
||||
pos?: [number, number]
|
||||
mode?: number
|
||||
widgets?: { name?: string; value?: unknown; type?: string }[]
|
||||
inputs?: { name?: string; type?: string; link?: number | null }[]
|
||||
outputs?: {
|
||||
name?: string
|
||||
type?: string
|
||||
links?: (number | null)[] | null
|
||||
}[]
|
||||
}
|
||||
return {
|
||||
id: n.id,
|
||||
type: n.comfyClass ?? n.type ?? 'Unknown',
|
||||
title: n.title,
|
||||
pos: n.pos,
|
||||
mode: n.mode,
|
||||
widgets: n.widgets?.map((w) => ({
|
||||
name: w.name ?? '',
|
||||
value: w.value,
|
||||
type: w.type
|
||||
})),
|
||||
inputs: n.inputs?.map((i) => ({
|
||||
name: i.name ?? '',
|
||||
type: i.type ?? '*',
|
||||
linkId: i.link ?? null
|
||||
})),
|
||||
outputs: n.outputs?.map((o) => ({
|
||||
name: o.name ?? '',
|
||||
type: o.type ?? '*',
|
||||
linkCount: Array.isArray(o.links)
|
||||
? o.links.filter((l) => l != null).length
|
||||
: 0
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
const graphCmd: Command = async (ctx) => {
|
||||
const graph = getGraph()
|
||||
if (!graph) {
|
||||
return { stdout: emptyIter(), exitCode: 1, stderr: 'no active graph' }
|
||||
}
|
||||
const sub = ctx.argv[1] ?? 'summary'
|
||||
if (sub === 'summary') {
|
||||
const nodes = (graph as { _nodes: unknown[] })._nodes ?? []
|
||||
const types = new Map<string, number>()
|
||||
for (const n of nodes) {
|
||||
const s = summarizeNode(n)
|
||||
types.set(s.type, (types.get(s.type) ?? 0) + 1)
|
||||
}
|
||||
const lines = [`nodes: ${nodes.length}`, 'types:']
|
||||
for (const [t, c] of [...types.entries()].sort((a, b) => b[1] - a[1])) {
|
||||
lines.push(` ${c}\t${t}`)
|
||||
}
|
||||
return { stdout: stringIter(lines.join('\n') + '\n'), exitCode: 0 }
|
||||
}
|
||||
if (sub === 'nodes') {
|
||||
const nodes = (graph as { _nodes: unknown[] })._nodes ?? []
|
||||
const filter = ctx.argv[2]
|
||||
const summaries = nodes.map(summarizeNode)
|
||||
const filtered = filter
|
||||
? summaries.filter((s) => new RegExp(filter, 'i').test(s.type))
|
||||
: summaries
|
||||
const out = filtered
|
||||
.map((s) => `${s.id}\t${s.type}\t${s.title ?? ''}`)
|
||||
.join('\n')
|
||||
return { stdout: stringIter(out + (out ? '\n' : '')), exitCode: 0 }
|
||||
}
|
||||
if (sub === 'node') {
|
||||
const id = ctx.argv[2]
|
||||
if (!id) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: graph node <id>'
|
||||
}
|
||||
}
|
||||
const nodes = (graph as { _nodes: unknown[] })._nodes ?? []
|
||||
const node = nodes.find((n) => String((n as { id: number }).id) === id)
|
||||
if (!node) {
|
||||
return { stdout: emptyIter(), exitCode: 1, stderr: `no node ${id}` }
|
||||
}
|
||||
return {
|
||||
stdout: stringIter(JSON.stringify(summarizeNode(node), null, 2) + '\n'),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
if (sub === 'json') {
|
||||
const nodes = (graph as { _nodes: unknown[] })._nodes ?? []
|
||||
const payload = { nodes: nodes.map(summarizeNode) }
|
||||
return {
|
||||
stdout: stringIter(JSON.stringify(payload, null, 2) + '\n'),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: `usage: graph <summary|nodes [regex]|node <id>|json>`
|
||||
}
|
||||
}
|
||||
|
||||
interface LiteWidget {
|
||||
name?: string
|
||||
type?: string
|
||||
value?: unknown
|
||||
callback?: (v: unknown) => void
|
||||
}
|
||||
|
||||
interface LiteNode {
|
||||
id: number | string
|
||||
widgets?: LiteWidget[]
|
||||
}
|
||||
|
||||
function coerce(type: string | undefined, raw: string): unknown {
|
||||
if (type === 'number' || type === 'INT' || type === 'FLOAT') {
|
||||
const n = Number(raw)
|
||||
if (Number.isFinite(n)) return n
|
||||
}
|
||||
if (type === 'BOOLEAN' || type === 'toggle') {
|
||||
if (raw === 'true') return true
|
||||
if (raw === 'false') return false
|
||||
}
|
||||
return raw
|
||||
}
|
||||
|
||||
const setWidget: Command = async (ctx) => {
|
||||
const [, idArg, name, ...rest] = ctx.argv
|
||||
if (!idArg || !name || rest.length === 0) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: set-widget <nodeId> <widgetName> <value...>'
|
||||
}
|
||||
}
|
||||
const graph = getGraph()
|
||||
if (!graph) {
|
||||
return { stdout: emptyIter(), exitCode: 1, stderr: 'no active graph' }
|
||||
}
|
||||
const nodes = (graph as { _nodes: LiteNode[] })._nodes ?? []
|
||||
const node = nodes.find((n) => String(n.id) === idArg)
|
||||
if (!node) {
|
||||
return { stdout: emptyIter(), exitCode: 1, stderr: `no node ${idArg}` }
|
||||
}
|
||||
const widget = node.widgets?.find((w) => w.name === name)
|
||||
if (!widget) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `node ${idArg} has no widget "${name}"`
|
||||
}
|
||||
}
|
||||
const value = coerce(widget.type, rest.join(' '))
|
||||
widget.value = value
|
||||
widget.callback?.(value)
|
||||
return {
|
||||
stdout: stringIter(`set ${idArg}.${name} = ${JSON.stringify(value)}\n`),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
|
||||
export function registerGraphCommands(registry: CommandRegistry): void {
|
||||
registry.register('graph', graphCmd)
|
||||
registry.register('set-widget', setWidget)
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
import { api } from '@/scripts/api'
|
||||
|
||||
import type { Command, CommandRegistry } from '../types'
|
||||
import { emptyIter, stringIter } from '../types'
|
||||
|
||||
/**
|
||||
* copy-to-input <output_filename> [as <input_filename>]
|
||||
*
|
||||
* Copies a file from the output/ directory into input/ so it can be used
|
||||
* as a LoadImage source in the NEXT workflow. Unlocks multi-phase pipelines
|
||||
* (e.g. T2I generates image → image-to-3D consumes it) in pure natural
|
||||
* language via the agent.
|
||||
*
|
||||
* Fetches via /view?type=output, re-uploads via /upload/image.
|
||||
*/
|
||||
const copyToInput: Command = async (ctx) => {
|
||||
const args = ctx.argv.slice(1)
|
||||
if (args.length === 0) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr:
|
||||
'usage: copy-to-input <output_filename> [as <input_filename>]\n' +
|
||||
' copies output/<src> → input/<dst> (defaults dst = src)'
|
||||
}
|
||||
}
|
||||
const src = args[0]
|
||||
let dst = src
|
||||
const asIdx = args.indexOf('as')
|
||||
if (asIdx >= 0 && args[asIdx + 1]) {
|
||||
dst = args[asIdx + 1]
|
||||
}
|
||||
|
||||
try {
|
||||
// Fetch the image from ComfyUI's output folder.
|
||||
const viewUrl = api.apiURL(
|
||||
`/view?filename=${encodeURIComponent(src)}&type=output`
|
||||
)
|
||||
const imgRes = await fetch(viewUrl)
|
||||
if (!imgRes.ok) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `copy-to-input: cannot read output/${src} (HTTP ${imgRes.status})`
|
||||
}
|
||||
}
|
||||
const blob = await imgRes.blob()
|
||||
|
||||
// Upload into input/.
|
||||
const form = new FormData()
|
||||
form.append('image', blob, dst)
|
||||
form.append('overwrite', 'true')
|
||||
const uploadRes = await fetch(api.apiURL('/upload/image'), {
|
||||
method: 'POST',
|
||||
body: form
|
||||
})
|
||||
if (!uploadRes.ok) {
|
||||
const text = await uploadRes.text().catch(() => '')
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `copy-to-input: upload failed (${uploadRes.status}) ${text.slice(0, 200)}`
|
||||
}
|
||||
}
|
||||
const out = (await uploadRes.json()) as { name?: string }
|
||||
return {
|
||||
stdout: stringIter(`copied output/${src} → input/${out.name ?? dst}\n`),
|
||||
exitCode: 0
|
||||
}
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: err instanceof Error ? err.message : String(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* latest-output-name — print the filename of the most recent SaveImage
|
||||
* output. Convenience wrapper around latest-output so the LLM can grab
|
||||
* just the name and pipe it into copy-to-input.
|
||||
*/
|
||||
const latestOutputName: Command = async () => {
|
||||
try {
|
||||
const res = await fetch(api.apiURL('/history'))
|
||||
if (!res.ok) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `latest-output-name: /history ${res.status}`
|
||||
}
|
||||
}
|
||||
const history = (await res.json()) as Record<
|
||||
string,
|
||||
{
|
||||
outputs?: Record<
|
||||
string,
|
||||
{
|
||||
images?: Array<{
|
||||
filename: string
|
||||
subfolder?: string
|
||||
type?: string
|
||||
}>
|
||||
}
|
||||
>
|
||||
}
|
||||
>
|
||||
const entries = Object.values(history)
|
||||
for (const entry of entries.reverse()) {
|
||||
const outs = entry.outputs ?? {}
|
||||
for (const nodeOut of Object.values(outs)) {
|
||||
const img = nodeOut.images?.[0]
|
||||
if (img?.filename) {
|
||||
const sub = img.subfolder ? img.subfolder + '/' : ''
|
||||
return {
|
||||
stdout: stringIter(sub + img.filename + '\n'),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
stdout: stringIter(''),
|
||||
exitCode: 0,
|
||||
stderr: '(no outputs in history)'
|
||||
}
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: err instanceof Error ? err.message : String(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function registerImageCommands(registry: CommandRegistry): void {
|
||||
registry.register('copy-to-input', copyToInput)
|
||||
registry.register('latest-output-name', latestOutputName)
|
||||
}
|
||||
@@ -1,277 +0,0 @@
|
||||
import { api } from '@/scripts/api'
|
||||
|
||||
import type { Command, CommandRegistry } from '../types'
|
||||
import { emptyIter, stringIter } from '../types'
|
||||
|
||||
interface ExternalModelEntry {
|
||||
name: string
|
||||
type?: string
|
||||
base: string
|
||||
save_path: string
|
||||
filename: string
|
||||
url: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch ComfyUI-Manager's curated model list and return a map from url →
|
||||
* entry. Manager's whitelist check requires save_path+base+filename to match
|
||||
* an entry; we lift those values from here automatically.
|
||||
*/
|
||||
async function fetchManagerModelList(): Promise<ExternalModelEntry[]> {
|
||||
const res = await fetch(api.apiURL('/externalmodel/getlist?mode=cache'))
|
||||
if (!res.ok) throw new Error(`externalmodel/getlist ${res.status}`)
|
||||
const json = (await res.json()) as { models?: ExternalModelEntry[] }
|
||||
return json.models ?? []
|
||||
}
|
||||
|
||||
/**
|
||||
* install-model <url> <saveAs>
|
||||
* OR install-model --find <filename> (search the DB)
|
||||
*
|
||||
* Queue a model download in ComfyUI-Manager. <saveAs> is the target path
|
||||
* relative to ComfyUI's models dir, e.g.:
|
||||
* install-model https://huggingface.co/.../model.safetensors checkpoints/model.safetensors
|
||||
*
|
||||
* The command auto-fills required `base` and exact `save_path` from
|
||||
* Manager's curated model list (/externalmodel/getlist). If the URL isn't
|
||||
* recognised, installation will still be attempted with save_path=type,
|
||||
* but the Manager whitelist may reject it.
|
||||
*
|
||||
* Requires ComfyUI-Manager. 404 → manager not available.
|
||||
*/
|
||||
const installModel: Command = async (ctx) => {
|
||||
const args = ctx.argv.slice(1)
|
||||
if (args[0] === '--find') {
|
||||
const query = args.slice(1).join(' ').trim()
|
||||
if (!query) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: install-model --find <filename-substring>'
|
||||
}
|
||||
}
|
||||
try {
|
||||
const models = await fetchManagerModelList()
|
||||
const lower = query.toLowerCase()
|
||||
const matches = models.filter(
|
||||
(m) =>
|
||||
m.filename?.toLowerCase().includes(lower) ||
|
||||
m.name?.toLowerCase().includes(lower)
|
||||
)
|
||||
if (matches.length === 0) {
|
||||
return {
|
||||
stdout: stringIter('(no matches in manager model list)\n'),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
const lines = matches
|
||||
.slice(0, 20)
|
||||
.map((m) => `${m.save_path}/${m.filename} [${m.base}]\n ${m.url}`)
|
||||
lines.push(
|
||||
'',
|
||||
`${matches.length} match(es). Use the URL + save_path/filename shown.`
|
||||
)
|
||||
return { stdout: stringIter(lines.join('\n') + '\n'), exitCode: 0 }
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: err instanceof Error ? err.message : String(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const [url, saveAs] = args
|
||||
if (!url || !saveAs) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr:
|
||||
'usage: install-model <url> <save_path/filename>\n' +
|
||||
' install-model --find <filename> # search Manager DB\n' +
|
||||
' example: install-model https://huggingface.co/stabilityai/sdxl-vae/resolve/main/sdxl_vae.safetensors vae/SDXL/sdxl_vae.safetensors'
|
||||
}
|
||||
}
|
||||
const lastSlash = saveAs.lastIndexOf('/')
|
||||
if (lastSlash <= 0) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr:
|
||||
'install-model: <saveAs> must be of the form "<save_path>/<filename>"\n' +
|
||||
' hint: install-model --find <filename> to look up the exact save_path'
|
||||
}
|
||||
}
|
||||
const savePath = saveAs.slice(0, lastSlash)
|
||||
const filename = saveAs.slice(lastSlash + 1)
|
||||
const type = savePath.split('/')[0]
|
||||
if (!filename) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'install-model: filename is empty'
|
||||
}
|
||||
}
|
||||
|
||||
// Auto-fill required `base` from Manager's curated list (whitelist check
|
||||
// in manager_server.py requires save_path + base + filename match).
|
||||
let base = 'Other'
|
||||
try {
|
||||
const models = await fetchManagerModelList()
|
||||
const entry =
|
||||
models.find((m) => m.url === url) ??
|
||||
models.find((m) => m.filename === filename && m.save_path === savePath)
|
||||
if (entry) base = entry.base
|
||||
} catch {
|
||||
/* Manager list unreachable — try anyway */
|
||||
}
|
||||
|
||||
// Legacy endpoint. The v2 routes in the frontend's type schema are only
|
||||
// present in manager-v4 (pip-installed); most deployments run main.
|
||||
const uiId =
|
||||
typeof crypto !== 'undefined' && 'randomUUID' in crypto
|
||||
? crypto.randomUUID()
|
||||
: String(Date.now())
|
||||
|
||||
const body = {
|
||||
name: filename,
|
||||
type,
|
||||
base,
|
||||
url,
|
||||
filename,
|
||||
save_path: savePath,
|
||||
ui_id: uiId
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await fetch(api.apiURL('/manager/queue/install_model'), {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(body)
|
||||
})
|
||||
if (res.status === 404) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr:
|
||||
'install-model: ComfyUI-Manager not available on this backend.\n' +
|
||||
' The user must install it manually and restart ComfyUI.'
|
||||
}
|
||||
}
|
||||
if (res.status === 403) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `install-model: rejected by security policy (403). URL may be on a deny list.`
|
||||
}
|
||||
}
|
||||
if (!res.ok) {
|
||||
const text = await res.text().catch(() => '')
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `install-model: queue failed (${res.status}) ${text.slice(0, 200)}`
|
||||
}
|
||||
}
|
||||
// Queue must be started after adding tasks (matches manager UI flow).
|
||||
// Route is POST (legacy Manager) — GET returns 404.
|
||||
const startRes = await fetch(api.apiURL('/manager/queue/start'), {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: '{}'
|
||||
})
|
||||
const startOk = startRes.ok || startRes.status === 409 // 409 = already running
|
||||
return {
|
||||
stdout: stringIter(
|
||||
`queued install of ${saveAs} from ${url}\n` +
|
||||
` ui_id: ${uiId}\n` +
|
||||
(startOk
|
||||
? ' queue started — track with: install-status\n'
|
||||
: ` WARNING: queue-start returned ${startRes.status}; task may not run\n`)
|
||||
),
|
||||
exitCode: 0
|
||||
}
|
||||
} catch (err) {
|
||||
// A bare TypeError "Failed to fetch" almost always means the Manager
|
||||
// route isn't registered (plugin missing) and the request never reached
|
||||
// a real handler. Surface that explicitly so the user knows to install
|
||||
// ComfyUI-Manager rather than debugging their network.
|
||||
const msg = err instanceof Error ? err.message : String(err)
|
||||
const hint = /Failed to fetch/i.test(msg)
|
||||
? '\n hint: ComfyUI-Manager plugin is likely not installed on this backend.\n' +
|
||||
' See: https://github.com/Comfy-Org/ComfyUI-Manager'
|
||||
: ''
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: msg + hint
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* install-status
|
||||
*
|
||||
* Show the manager install queue: what's running, pending, and recent
|
||||
* history. Useful right after install-model to watch progress.
|
||||
*/
|
||||
interface ManagerQueueStatus {
|
||||
running_queue?: Array<{ ui_id: string; kind: string; params?: unknown }>
|
||||
pending_queue?: Array<{ ui_id: string; kind: string; params?: unknown }>
|
||||
}
|
||||
|
||||
const installStatus: Command = async () => {
|
||||
try {
|
||||
const statusRes = await fetch(api.apiURL('/manager/queue/status'))
|
||||
if (statusRes.status === 404) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: 'install-status: ComfyUI-Manager not available on this backend.'
|
||||
}
|
||||
}
|
||||
if (!statusRes.ok) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `install-status: queue/status failed (${statusRes.status})`
|
||||
}
|
||||
}
|
||||
const status = (await statusRes.json()) as ManagerQueueStatus & {
|
||||
done_count?: number
|
||||
in_progress_count?: number
|
||||
is_processing?: boolean
|
||||
}
|
||||
|
||||
const lines: string[] = []
|
||||
lines.push(
|
||||
`processing: ${status.is_processing ? 'yes' : 'no'}` +
|
||||
` done: ${status.done_count ?? 0}` +
|
||||
` in_progress: ${status.in_progress_count ?? 0}`
|
||||
)
|
||||
lines.push(`running: ${status.running_queue?.length ?? 0}`)
|
||||
for (const t of status.running_queue ?? []) {
|
||||
lines.push(` [${t.ui_id.slice(0, 8)}] ${t.kind}`)
|
||||
}
|
||||
lines.push(`pending: ${status.pending_queue?.length ?? 0}`)
|
||||
for (const t of status.pending_queue ?? []) {
|
||||
lines.push(` [${t.ui_id.slice(0, 8)}] ${t.kind}`)
|
||||
}
|
||||
return { stdout: stringIter(lines.join('\n') + '\n'), exitCode: 0 }
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : String(err)
|
||||
const hint = /Failed to fetch/i.test(msg)
|
||||
? '\n hint: ComfyUI-Manager plugin is likely not installed on this backend.'
|
||||
: ''
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: msg + hint
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function registerInstallCommands(registry: CommandRegistry): void {
|
||||
registry.register('install-model', installModel)
|
||||
registry.register('install-status', installStatus)
|
||||
}
|
||||
@@ -1,325 +0,0 @@
|
||||
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
|
||||
import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
|
||||
|
||||
import type { Command, CommandRegistry } from '../types'
|
||||
import { emptyIter, stringIter } from '../types'
|
||||
|
||||
/**
|
||||
* Snapshot current canvas state to ComfyUI's undo stack. Call AFTER a
|
||||
* bulk mutation so Ctrl/Cmd+Z restores the pre-change layout in one step.
|
||||
*/
|
||||
function captureUndo(): void {
|
||||
try {
|
||||
useWorkflowStore().activeWorkflow?.changeTracker?.checkState()
|
||||
} catch {
|
||||
/* no-op: no workflow or tracker available */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Low-level primitives for managing node geometry on the active canvas.
|
||||
*
|
||||
* node-list [--filter <regex>] [--json]
|
||||
* List nodes with: id, type, posX, posY, sizeW, sizeH, title.
|
||||
* Tab-separated for easy piping; --json emits machine-readable form.
|
||||
*
|
||||
* node-pos <id> → prints 'x y'
|
||||
* node-pos <id> <x> <y> → sets position
|
||||
*
|
||||
* node-size <id> → prints 'w h'
|
||||
* node-size <id> <w> <h> → sets size
|
||||
*
|
||||
* graph-links [--filter <id>]
|
||||
* List links: id, from-node:from-slot, to-node:to-slot, type.
|
||||
* Useful for the LLM to compute its own topological / tree layouts.
|
||||
*
|
||||
* canvas-redraw
|
||||
* Trigger a repaint after bulk geometry changes.
|
||||
*
|
||||
* With these primitives the agent can implement any layout algorithm
|
||||
* (tree, dagre, spring, grid, …) entirely in the shell or via run-js.
|
||||
*/
|
||||
interface LNode {
|
||||
id: number
|
||||
type?: string
|
||||
comfyClass?: string
|
||||
title?: string
|
||||
pos: [number, number]
|
||||
size: [number, number]
|
||||
}
|
||||
|
||||
interface LLink {
|
||||
id: number
|
||||
origin_id: number
|
||||
origin_slot: number
|
||||
target_id: number
|
||||
target_slot: number
|
||||
type?: string
|
||||
}
|
||||
|
||||
interface LGraphLike {
|
||||
_nodes: LNode[]
|
||||
links: Record<number, LLink> | LLink[] | Map<number, LLink>
|
||||
setDirtyCanvas?: (fg: boolean, bg: boolean) => void
|
||||
}
|
||||
|
||||
function getGraph(): LGraphLike | null {
|
||||
const g = useCanvasStore().canvas?.graph as LGraphLike | undefined
|
||||
return g ?? null
|
||||
}
|
||||
|
||||
function iterateLinks(links: LGraphLike['links']): LLink[] {
|
||||
if (Array.isArray(links)) return links.filter(Boolean)
|
||||
if (links instanceof Map) return [...links.values()]
|
||||
return Object.values(links ?? {}).filter((l): l is LLink => !!l)
|
||||
}
|
||||
|
||||
function findNode(g: LGraphLike, id: string): LNode | undefined {
|
||||
return g._nodes.find((n) => String(n.id) === id)
|
||||
}
|
||||
|
||||
const nodeList: Command = async (ctx) => {
|
||||
const g = getGraph()
|
||||
if (!g) return { stdout: emptyIter(), exitCode: 1, stderr: 'no active graph' }
|
||||
const filterArg = ctx.argv.find((a) => a.startsWith('--filter='))
|
||||
const re = filterArg ? new RegExp(filterArg.slice(9), 'i') : null
|
||||
const json = ctx.argv.includes('--json')
|
||||
const rows = g._nodes
|
||||
.filter((n) => !re || re.test(n.comfyClass ?? n.type ?? ''))
|
||||
.map((n) => ({
|
||||
id: n.id,
|
||||
type: n.comfyClass ?? n.type ?? 'Unknown',
|
||||
x: Math.round(n.pos?.[0] ?? 0),
|
||||
y: Math.round(n.pos?.[1] ?? 0),
|
||||
w: Math.round(n.size?.[0] ?? 0),
|
||||
h: Math.round(n.size?.[1] ?? 0),
|
||||
title: n.title ?? ''
|
||||
}))
|
||||
if (json) {
|
||||
return {
|
||||
stdout: stringIter(JSON.stringify(rows, null, 2) + '\n'),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
const lines = [
|
||||
'id\ttype\tx\ty\tw\th\ttitle',
|
||||
...rows.map(
|
||||
(r) => `${r.id}\t${r.type}\t${r.x}\t${r.y}\t${r.w}\t${r.h}\t${r.title}`
|
||||
)
|
||||
]
|
||||
return { stdout: stringIter(lines.join('\n') + '\n'), exitCode: 0 }
|
||||
}
|
||||
|
||||
const nodePos: Command = async (ctx) => {
|
||||
const g = getGraph()
|
||||
if (!g) return { stdout: emptyIter(), exitCode: 1, stderr: 'no active graph' }
|
||||
const [, id, xArg, yArg] = ctx.argv
|
||||
if (!id) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: node-pos <id> [<x> <y>]'
|
||||
}
|
||||
}
|
||||
const n = findNode(g, id)
|
||||
if (!n) return { stdout: emptyIter(), exitCode: 1, stderr: `no node ${id}` }
|
||||
if (xArg === undefined) {
|
||||
return {
|
||||
stdout: stringIter(`${Math.round(n.pos[0])} ${Math.round(n.pos[1])}\n`),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
const x = Number(xArg)
|
||||
const y = Number(yArg)
|
||||
if (!Number.isFinite(x) || !Number.isFinite(y)) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'x and y must be numbers'
|
||||
}
|
||||
}
|
||||
n.pos = [x, y]
|
||||
g.setDirtyCanvas?.(true, true)
|
||||
captureUndo()
|
||||
return { stdout: stringIter(`set ${id} pos=${x},${y}\n`), exitCode: 0 }
|
||||
}
|
||||
|
||||
const nodeSize: Command = async (ctx) => {
|
||||
const g = getGraph()
|
||||
if (!g) return { stdout: emptyIter(), exitCode: 1, stderr: 'no active graph' }
|
||||
const [, id, wArg, hArg] = ctx.argv
|
||||
if (!id) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: node-size <id> [<w> <h>]'
|
||||
}
|
||||
}
|
||||
const n = findNode(g, id)
|
||||
if (!n) return { stdout: emptyIter(), exitCode: 1, stderr: `no node ${id}` }
|
||||
if (wArg === undefined) {
|
||||
return {
|
||||
stdout: stringIter(`${Math.round(n.size[0])} ${Math.round(n.size[1])}\n`),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
const w = Number(wArg)
|
||||
const h = Number(hArg)
|
||||
if (!Number.isFinite(w) || !Number.isFinite(h) || w <= 0 || h <= 0) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'w and h must be positive numbers'
|
||||
}
|
||||
}
|
||||
n.size = [w, h]
|
||||
g.setDirtyCanvas?.(true, true)
|
||||
captureUndo()
|
||||
return { stdout: stringIter(`set ${id} size=${w}x${h}\n`), exitCode: 0 }
|
||||
}
|
||||
|
||||
const graphLinks: Command = async (ctx) => {
|
||||
const g = getGraph()
|
||||
if (!g) return { stdout: emptyIter(), exitCode: 1, stderr: 'no active graph' }
|
||||
const filterArg = ctx.argv.find((a) => a.startsWith('--filter='))
|
||||
const nodeFilter = filterArg ? filterArg.slice(9) : null
|
||||
const rows = iterateLinks(g.links)
|
||||
.filter((l) =>
|
||||
nodeFilter
|
||||
? String(l.origin_id) === nodeFilter ||
|
||||
String(l.target_id) === nodeFilter
|
||||
: true
|
||||
)
|
||||
.map(
|
||||
(l) =>
|
||||
`${l.id}\t${l.origin_id}:${l.origin_slot}\t→\t${l.target_id}:${l.target_slot}\t${l.type ?? ''}`
|
||||
)
|
||||
const header = 'link\tfrom\t\tto\ttype'
|
||||
return {
|
||||
stdout: stringIter([header, ...rows].join('\n') + '\n'),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
|
||||
const canvasRedraw: Command = async () => {
|
||||
const g = getGraph()
|
||||
if (!g) return { stdout: emptyIter(), exitCode: 1, stderr: 'no active graph' }
|
||||
g.setDirtyCanvas?.(true, true)
|
||||
return { stdout: stringIter('canvas redrawn\n'), exitCode: 0 }
|
||||
}
|
||||
|
||||
/**
|
||||
* graph-dot — emit a DOT-like text description of the graph. Nodes are
|
||||
* labelled by id and type, with size and current position. Directed edges
|
||||
* follow slot-to-slot links. This is a compact, human/LLM-readable view
|
||||
* the agent can use as input when reasoning about a layout.
|
||||
*/
|
||||
const graphDot: Command = async () => {
|
||||
const g = getGraph()
|
||||
if (!g) return { stdout: emptyIter(), exitCode: 1, stderr: 'no active graph' }
|
||||
const lines: string[] = []
|
||||
lines.push('digraph graph {')
|
||||
lines.push(' rankdir=TB;')
|
||||
for (const n of g._nodes) {
|
||||
const type = n.comfyClass ?? n.type ?? 'Unknown'
|
||||
const x = Math.round(n.pos?.[0] ?? 0)
|
||||
const y = Math.round(n.pos?.[1] ?? 0)
|
||||
const w = Math.round(n.size?.[0] ?? 0)
|
||||
const h = Math.round(n.size?.[1] ?? 0)
|
||||
lines.push(` ${n.id} [label="${type}" pos="${x},${y}" size="${w}x${h}"];`)
|
||||
}
|
||||
for (const l of iterateLinks(g.links)) {
|
||||
lines.push(` ${l.origin_id} -> ${l.target_id};`)
|
||||
}
|
||||
lines.push('}')
|
||||
return { stdout: stringIter(lines.join('\n') + '\n'), exitCode: 0 }
|
||||
}
|
||||
|
||||
/**
|
||||
* apply-layout — accept JSON (from stdin or arg) describing bulk
|
||||
* position / size updates. Shape:
|
||||
* [{"id": 3, "pos": [100, 100], "size": [240, 160]}, ...]
|
||||
* Unknown ids are skipped. One redraw at the end.
|
||||
*/
|
||||
const applyLayout: Command = async (ctx) => {
|
||||
const g = getGraph()
|
||||
if (!g) return { stdout: emptyIter(), exitCode: 1, stderr: 'no active graph' }
|
||||
let input = ''
|
||||
const inline = ctx.argv.slice(1).join(' ').trim()
|
||||
if (inline) input = inline
|
||||
else {
|
||||
const chunks: string[] = []
|
||||
for await (const c of ctx.stdin) chunks.push(c)
|
||||
input = chunks.join('')
|
||||
}
|
||||
if (!input.trim()) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: apply-layout <json> | echo <json> | apply-layout'
|
||||
}
|
||||
}
|
||||
let parsed: unknown
|
||||
try {
|
||||
parsed = JSON.parse(input)
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr:
|
||||
'invalid JSON: ' + (err instanceof Error ? err.message : String(err))
|
||||
}
|
||||
}
|
||||
if (!Array.isArray(parsed)) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'expected JSON array of {id, pos?, size?}'
|
||||
}
|
||||
}
|
||||
let updated = 0
|
||||
let skipped = 0
|
||||
for (const item of parsed as Array<{
|
||||
id?: number | string
|
||||
pos?: [number, number]
|
||||
size?: [number, number]
|
||||
}>) {
|
||||
if (item?.id === undefined) {
|
||||
skipped++
|
||||
continue
|
||||
}
|
||||
const n = findNode(g, String(item.id))
|
||||
if (!n) {
|
||||
skipped++
|
||||
continue
|
||||
}
|
||||
if (Array.isArray(item.pos) && item.pos.length === 2) {
|
||||
const [x, y] = item.pos
|
||||
if (Number.isFinite(x) && Number.isFinite(y)) n.pos = [x, y]
|
||||
}
|
||||
if (Array.isArray(item.size) && item.size.length === 2) {
|
||||
const [w, h] = item.size
|
||||
if (Number.isFinite(w) && Number.isFinite(h) && w > 0 && h > 0)
|
||||
n.size = [w, h]
|
||||
}
|
||||
updated++
|
||||
}
|
||||
g.setDirtyCanvas?.(true, true)
|
||||
captureUndo()
|
||||
return {
|
||||
stdout: stringIter(
|
||||
`applied: ${updated} nodes, skipped: ${skipped} — Ctrl/Cmd+Z to undo\n`
|
||||
),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
|
||||
export function registerLayoutCommands(registry: CommandRegistry): void {
|
||||
registry.register('node-list', nodeList)
|
||||
registry.register('node-pos', nodePos)
|
||||
registry.register('node-size', nodeSize)
|
||||
registry.register('graph-links', graphLinks)
|
||||
registry.register('graph-dot', graphDot)
|
||||
registry.register('apply-layout', applyLayout)
|
||||
registry.register('canvas-redraw', canvasRedraw)
|
||||
}
|
||||
@@ -1,858 +0,0 @@
|
||||
import { LiteGraph } from '@/lib/litegraph/src/litegraph'
|
||||
import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
|
||||
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
|
||||
import { useRightSidePanelStore } from '@/stores/workspace/rightSidePanelStore'
|
||||
import type { RightSidePanelTab } from '@/stores/workspace/rightSidePanelStore'
|
||||
import { useCommandStore } from '@/stores/commandStore'
|
||||
import { useSidebarTabStore } from '@/stores/workspace/sidebarTabStore'
|
||||
|
||||
import type { Command, CommandRegistry } from '../types'
|
||||
import { emptyIter, stringIter } from '../types'
|
||||
|
||||
interface PosSizeNode {
|
||||
id: number | string
|
||||
pos: [number, number]
|
||||
size: [number, number]
|
||||
comfyClass?: string
|
||||
type?: string
|
||||
}
|
||||
|
||||
function captureUndo(): void {
|
||||
try {
|
||||
useWorkflowStore().activeWorkflow?.changeTracker?.checkState()
|
||||
} catch {
|
||||
/* no-op */
|
||||
}
|
||||
}
|
||||
|
||||
function getCanvas() {
|
||||
return useCanvasStore().canvas
|
||||
}
|
||||
|
||||
function getGraph() {
|
||||
return getCanvas()?.graph ?? null
|
||||
}
|
||||
|
||||
function getSelectedNodes(): PosSizeNode[] {
|
||||
const canvas = getCanvas()
|
||||
if (!canvas) return []
|
||||
const selected = (canvas as { selected_nodes?: Record<string, PosSizeNode> })
|
||||
.selected_nodes
|
||||
if (!selected) return []
|
||||
return Object.values(selected)
|
||||
}
|
||||
|
||||
/**
|
||||
* node-search <pattern>
|
||||
*
|
||||
* Returns matching node type names from LiteGraph.registered_node_types.
|
||||
* Case-insensitive substring or regex match. One per line, sorted.
|
||||
*/
|
||||
const nodeSearch: Command = async (ctx) => {
|
||||
const pattern = ctx.argv.slice(1).join(' ').trim()
|
||||
if (!pattern) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: node-search <pattern>'
|
||||
}
|
||||
}
|
||||
const registered = LiteGraph.registered_node_types ?? {}
|
||||
let regex: RegExp
|
||||
try {
|
||||
regex = new RegExp(pattern, 'i')
|
||||
} catch {
|
||||
const escaped = pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||
regex = new RegExp(escaped, 'i')
|
||||
}
|
||||
const matches = Object.keys(registered)
|
||||
.filter((type) => regex.test(type))
|
||||
.sort()
|
||||
if (matches.length === 0) {
|
||||
return { stdout: stringIter(''), exitCode: 0 }
|
||||
}
|
||||
return {
|
||||
stdout: stringIter(matches.join('\n') + '\n'),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* add-node <type> [x] [y]
|
||||
*
|
||||
* Create a node of the given registered type and add it to the active
|
||||
* graph. Positions at [x, y] (default [100, 100]). Prints the new node id.
|
||||
*/
|
||||
interface ViewportCanvas {
|
||||
ds?: { offset: [number, number]; scale: number }
|
||||
canvas?: { width: number; height: number }
|
||||
}
|
||||
|
||||
/**
|
||||
* Pick a non-overlapping position near the viewport center. Scans outward
|
||||
* in a spiral grid until it finds a cell that doesn't intersect any
|
||||
* existing node's AABB. Returns the top-left for the new node.
|
||||
*/
|
||||
function pickEmptySpot(
|
||||
graph: { _nodes?: PosSizeNode[] },
|
||||
canvas: ViewportCanvas,
|
||||
nodeSize: [number, number] = [220, 100]
|
||||
): [number, number] {
|
||||
const nodes = graph._nodes ?? []
|
||||
const ds = canvas.ds
|
||||
const vp = canvas.canvas
|
||||
let centerX = 0
|
||||
let centerY = 0
|
||||
if (ds && vp) {
|
||||
// Viewport center in graph coords: (-offset + viewport/2) / scale
|
||||
centerX = (-ds.offset[0] + vp.width / 2) / ds.scale
|
||||
centerY = (-ds.offset[1] + vp.height / 2) / ds.scale
|
||||
} else if (nodes.length > 0) {
|
||||
centerX = nodes.reduce((s, n) => s + n.pos[0], 0) / nodes.length
|
||||
centerY = nodes.reduce((s, n) => s + n.pos[1], 0) / nodes.length
|
||||
}
|
||||
const [w, h] = nodeSize
|
||||
const pad = 40
|
||||
const stepX = w + pad
|
||||
const stepY = h + pad
|
||||
|
||||
const overlaps = (x: number, y: number): boolean =>
|
||||
nodes.some((n) => {
|
||||
const [nx, ny] = n.pos
|
||||
const [nw, nh] = n.size ?? [220, 100]
|
||||
return !(x + w < nx || nx + nw < x || y + h < ny || ny + nh < y)
|
||||
})
|
||||
|
||||
const origin: [number, number] = [centerX - w / 2, centerY - h / 2]
|
||||
if (!overlaps(origin[0], origin[1])) return origin
|
||||
|
||||
// Spiral outward: rings of radius r, check each grid cell.
|
||||
for (let r = 1; r < 40; r++) {
|
||||
for (let dx = -r; dx <= r; dx++) {
|
||||
for (let dy = -r; dy <= r; dy++) {
|
||||
if (Math.abs(dx) !== r && Math.abs(dy) !== r) continue
|
||||
const x = origin[0] + dx * stepX
|
||||
const y = origin[1] + dy * stepY
|
||||
if (!overlaps(x, y)) return [x, y]
|
||||
}
|
||||
}
|
||||
}
|
||||
return origin
|
||||
}
|
||||
|
||||
const addNode: Command = async (ctx) => {
|
||||
const [, typeArg, xArg, yArg] = ctx.argv
|
||||
if (!typeArg) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: add-node <type> [x] [y]'
|
||||
}
|
||||
}
|
||||
const graph = getGraph()
|
||||
if (!graph) {
|
||||
return { stdout: emptyIter(), exitCode: 1, stderr: 'no active graph' }
|
||||
}
|
||||
if (!LiteGraph.registered_node_types?.[typeArg]) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `add-node: unknown type "${typeArg}" — try: node-search <pattern>`
|
||||
}
|
||||
}
|
||||
const xyGiven = xArg !== undefined && yArg !== undefined
|
||||
const x = xArg !== undefined ? Number(xArg) : Number.NaN
|
||||
const y = yArg !== undefined ? Number(yArg) : Number.NaN
|
||||
if (xyGiven && (!Number.isFinite(x) || !Number.isFinite(y))) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'add-node: x and y must be numbers'
|
||||
}
|
||||
}
|
||||
try {
|
||||
const node = LiteGraph.createNode(typeArg)
|
||||
if (!node) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `add-node: failed to create node of type "${typeArg}"`
|
||||
}
|
||||
}
|
||||
if (xyGiven) {
|
||||
node.pos = [x, y]
|
||||
} else {
|
||||
const canvas = getCanvas() as unknown as ViewportCanvas
|
||||
const pos = pickEmptySpot(
|
||||
graph as { _nodes?: PosSizeNode[] },
|
||||
canvas,
|
||||
(node as { size?: [number, number] }).size ?? [220, 100]
|
||||
)
|
||||
node.pos = pos
|
||||
}
|
||||
;(graph as { add: (n: unknown) => void }).add(node)
|
||||
getCanvas()?.setDirty(true, true)
|
||||
captureUndo()
|
||||
return {
|
||||
stdout: stringIter(`${(node as { id: number | string }).id}\n`),
|
||||
exitCode: 0
|
||||
}
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: err instanceof Error ? err.message : String(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type AlignAxis = 'left' | 'right' | 'center-x' | 'top' | 'bottom' | 'center-y'
|
||||
|
||||
const ALIGN_AXES: readonly AlignAxis[] = [
|
||||
'left',
|
||||
'right',
|
||||
'center-x',
|
||||
'top',
|
||||
'bottom',
|
||||
'center-y'
|
||||
]
|
||||
|
||||
/**
|
||||
* align-nodes <axis>
|
||||
*
|
||||
* Align currently-selected nodes to a common edge/center on the given axis.
|
||||
* Axis: left | right | center-x | top | bottom | center-y
|
||||
*/
|
||||
const alignNodes: Command = async (ctx) => {
|
||||
const axis = ctx.argv[1] as AlignAxis | undefined
|
||||
if (!axis || !ALIGN_AXES.includes(axis)) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: `usage: align-nodes <${ALIGN_AXES.join('|')}>`
|
||||
}
|
||||
}
|
||||
const selected = getSelectedNodes()
|
||||
if (selected.length < 2) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: 'align-nodes: select at least 2 nodes'
|
||||
}
|
||||
}
|
||||
const xs = selected.map((n) => n.pos[0])
|
||||
const ys = selected.map((n) => n.pos[1])
|
||||
const rights = selected.map((n) => n.pos[0] + (n.size?.[0] ?? 0))
|
||||
const bottoms = selected.map((n) => n.pos[1] + (n.size?.[1] ?? 0))
|
||||
|
||||
for (const n of selected) {
|
||||
const w = n.size?.[0] ?? 0
|
||||
const h = n.size?.[1] ?? 0
|
||||
if (axis === 'left') n.pos[0] = Math.min(...xs)
|
||||
else if (axis === 'right') n.pos[0] = Math.max(...rights) - w
|
||||
else if (axis === 'center-x') {
|
||||
const cx =
|
||||
(Math.min(...xs) +
|
||||
Math.max(...selected.map((s) => s.pos[0] + (s.size?.[0] ?? 0)))) /
|
||||
2
|
||||
n.pos[0] = cx - w / 2
|
||||
} else if (axis === 'top') n.pos[1] = Math.min(...ys)
|
||||
else if (axis === 'bottom') n.pos[1] = Math.max(...bottoms) - h
|
||||
else if (axis === 'center-y') {
|
||||
const cy =
|
||||
(Math.min(...ys) +
|
||||
Math.max(...selected.map((s) => s.pos[1] + (s.size?.[1] ?? 0)))) /
|
||||
2
|
||||
n.pos[1] = cy - h / 2
|
||||
}
|
||||
}
|
||||
getCanvas()?.setDirty(true, true)
|
||||
captureUndo()
|
||||
return {
|
||||
stdout: stringIter(`aligned ${selected.length} nodes (${axis})\n`),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* distribute-nodes <h|v>
|
||||
*
|
||||
* Distribute selected nodes evenly along horizontal (h) or vertical (v)
|
||||
* axis between the first and last node's current positions.
|
||||
*/
|
||||
const distributeNodes: Command = async (ctx) => {
|
||||
const axis = ctx.argv[1]
|
||||
if (axis !== 'h' && axis !== 'v') {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: distribute-nodes <h|v>'
|
||||
}
|
||||
}
|
||||
const selected = getSelectedNodes()
|
||||
if (selected.length < 3) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: 'distribute-nodes: select at least 3 nodes'
|
||||
}
|
||||
}
|
||||
const dim = axis === 'h' ? 0 : 1
|
||||
const sorted = [...selected].sort((a, b) => a.pos[dim] - b.pos[dim])
|
||||
const first = sorted[0].pos[dim]
|
||||
const last = sorted[sorted.length - 1].pos[dim]
|
||||
const step = (last - first) / (sorted.length - 1)
|
||||
sorted.forEach((n, i) => {
|
||||
n.pos[dim] = first + step * i
|
||||
})
|
||||
getCanvas()?.setDirty(true, true)
|
||||
captureUndo()
|
||||
return {
|
||||
stdout: stringIter(
|
||||
`distributed ${sorted.length} nodes along ${axis === 'h' ? 'horizontal' : 'vertical'}\n`
|
||||
),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* toggle-panel <name>
|
||||
*
|
||||
* Open/close a right-side or left-side sidebar tab by name.
|
||||
*
|
||||
* Right-side panel tabs: parameters | nodes | settings | info | subgraph | errors
|
||||
* Left-side sidebar tabs: whatever is registered (queue, history, assets, workflows, models, node-library, apps)
|
||||
*/
|
||||
const RIGHT_TABS: readonly RightSidePanelTab[] = [
|
||||
'parameters',
|
||||
'nodes',
|
||||
'settings',
|
||||
'info',
|
||||
'subgraph',
|
||||
'errors'
|
||||
]
|
||||
|
||||
const togglePanel: Command = async (ctx) => {
|
||||
const name = ctx.argv[1]?.trim().toLowerCase()
|
||||
if (!name) {
|
||||
const right = `right: ${RIGHT_TABS.join(', ')}`
|
||||
const leftTabs = useSidebarTabStore()
|
||||
.sidebarTabs.map((t) => t.id)
|
||||
.join(', ')
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: `usage: toggle-panel <name>\n ${right}\n left (sidebar): ${leftTabs}`
|
||||
}
|
||||
}
|
||||
|
||||
// Queue + history are command-driven overlays, not sidebar tabs — route
|
||||
// them through the command store so the user's mental model ("open the
|
||||
// queue panel") still works.
|
||||
const overlayCommands: Record<string, string> = {
|
||||
queue: 'Comfy.Queue.ToggleOverlay',
|
||||
history: 'Comfy.Queue.ToggleOverlay',
|
||||
'job-history': 'Comfy.Queue.ToggleOverlay'
|
||||
}
|
||||
if (overlayCommands[name]) {
|
||||
try {
|
||||
await useCommandStore().execute(overlayCommands[name])
|
||||
return {
|
||||
stdout: stringIter(`toggled ${name} overlay\n`),
|
||||
exitCode: 0
|
||||
}
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: err instanceof Error ? err.message : String(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Alias common names to panel/sidebar ids. Only alias names that we know
|
||||
// map to a real registered tab id in this build.
|
||||
const aliases: Record<string, string> = {
|
||||
'missing-models': 'errors',
|
||||
'model-library': 'models',
|
||||
'node-library': 'node-library'
|
||||
}
|
||||
const resolved = aliases[name] ?? name
|
||||
|
||||
if ((RIGHT_TABS as readonly string[]).includes(resolved)) {
|
||||
const store = useRightSidePanelStore()
|
||||
const isSame = store.activeTab === resolved && store.isOpen
|
||||
if (isSame) {
|
||||
store.closePanel()
|
||||
return {
|
||||
stdout: stringIter(`closed right panel (${resolved})\n`),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
store.openPanel(resolved as RightSidePanelTab)
|
||||
return {
|
||||
stdout: stringIter(`opened right panel (${resolved})\n`),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
|
||||
const sidebar = useSidebarTabStore()
|
||||
const tab = sidebar.sidebarTabs.find((t) => t.id === resolved)
|
||||
if (!tab) {
|
||||
const known = sidebar.sidebarTabs.map((t) => t.id).join(', ')
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `toggle-panel: unknown panel "${name}"\n right: ${RIGHT_TABS.join(', ')}\n sidebar: ${known}`
|
||||
}
|
||||
}
|
||||
sidebar.toggleSidebarTab(tab.id)
|
||||
const nowActive = sidebar.activeSidebarTabId === tab.id
|
||||
return {
|
||||
stdout: stringIter(
|
||||
`${nowActive ? 'opened' : 'closed'} sidebar tab (${tab.id})\n`
|
||||
),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* select <idOrSpec...>
|
||||
*
|
||||
* Select one or more nodes. Accepts:
|
||||
* - node ids: select 3 5 7
|
||||
* - type filter: select type=KSampler
|
||||
* - "all": select all
|
||||
* - "none": select none (clears)
|
||||
*
|
||||
* Needed before align-nodes / distribute-nodes.
|
||||
*/
|
||||
interface CanvasWithSelection {
|
||||
selected_nodes: Record<string, unknown>
|
||||
selectNode?: (node: unknown, keep?: boolean) => void
|
||||
deselectAllNodes?: () => void
|
||||
setDirty?: (a: boolean, b: boolean) => void
|
||||
}
|
||||
|
||||
const selectCmd: Command = async (ctx) => {
|
||||
const args = ctx.argv.slice(1)
|
||||
if (args.length === 0) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: select <id...> | type=<Type> | all | none'
|
||||
}
|
||||
}
|
||||
const graph = getGraph() as { _nodes?: unknown[] } | null
|
||||
const canvas = getCanvas() as unknown as CanvasWithSelection | null
|
||||
if (!graph?._nodes || !canvas) {
|
||||
return { stdout: emptyIter(), exitCode: 1, stderr: 'no active graph' }
|
||||
}
|
||||
canvas.deselectAllNodes?.()
|
||||
|
||||
const nodes = graph._nodes as Array<{ id: number; type?: string }>
|
||||
let picked: typeof nodes = []
|
||||
|
||||
if (args[0] === 'none') {
|
||||
canvas.setDirty?.(true, true)
|
||||
return { stdout: stringIter('selection cleared\n'), exitCode: 0 }
|
||||
}
|
||||
if (args[0] === 'all') {
|
||||
picked = nodes
|
||||
} else {
|
||||
for (const a of args) {
|
||||
if (a.startsWith('type=')) {
|
||||
const t = a.slice(5)
|
||||
picked.push(...nodes.filter((n) => n.type === t))
|
||||
} else if (/^\d+$/.test(a)) {
|
||||
const id = Number(a)
|
||||
const n = nodes.find((node) => node.id === id)
|
||||
if (n) picked.push(n)
|
||||
} else {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: `select: unrecognised token "${a}" (expected id, type=X, all, or none)`
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const n of picked) canvas.selectNode?.(n, true)
|
||||
canvas.setDirty?.(true, true)
|
||||
return {
|
||||
stdout: stringIter(
|
||||
`selected ${picked.length} node${picked.length === 1 ? '' : 's'}: ${picked
|
||||
.map((n) => n.id)
|
||||
.join(', ')}\n`
|
||||
),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* connect <fromId>.<output> <toId>.<input>
|
||||
*
|
||||
* Create a link. output/input may be the socket index (0-based) or name.
|
||||
* Example:
|
||||
* connect 3.0 5.0 # first output of node 3 → first input of 5
|
||||
* connect 3.LATENT 5.samples # by socket name
|
||||
*/
|
||||
interface LinkableNode {
|
||||
id: number
|
||||
outputs?: Array<{ name?: string }>
|
||||
inputs?: Array<{ name?: string }>
|
||||
connect: (fromSlot: number, target: LinkableNode, toSlot: number) => unknown
|
||||
}
|
||||
|
||||
function resolveSlot(
|
||||
socket: string,
|
||||
slots: Array<{ name?: string }> | undefined
|
||||
): number | null {
|
||||
if (!slots) return null
|
||||
if (/^\d+$/.test(socket)) {
|
||||
const i = Number(socket)
|
||||
return i >= 0 && i < slots.length ? i : null
|
||||
}
|
||||
const idx = slots.findIndex((s) => s.name === socket)
|
||||
return idx >= 0 ? idx : null
|
||||
}
|
||||
|
||||
const connectCmd: Command = async (ctx) => {
|
||||
const [, from, to] = ctx.argv
|
||||
if (!from || !to) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: connect <fromId>.<output> <toId>.<input>'
|
||||
}
|
||||
}
|
||||
const fromMatch = from.match(/^(\d+)\.(.+)$/)
|
||||
const toMatch = to.match(/^(\d+)\.(.+)$/)
|
||||
if (!fromMatch || !toMatch) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'connect: both args must be <id>.<socket>'
|
||||
}
|
||||
}
|
||||
const graph = getGraph() as { _nodes?: LinkableNode[] } | null
|
||||
const nodes = graph?._nodes
|
||||
if (!nodes) {
|
||||
return { stdout: emptyIter(), exitCode: 1, stderr: 'no active graph' }
|
||||
}
|
||||
const fromNode = nodes.find((n) => n.id === Number(fromMatch[1]))
|
||||
const toNode = nodes.find((n) => n.id === Number(toMatch[1]))
|
||||
if (!fromNode || !toNode) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `connect: node not found (${!fromNode ? fromMatch[1] : toMatch[1]})`
|
||||
}
|
||||
}
|
||||
const fromSlot = resolveSlot(fromMatch[2], fromNode.outputs)
|
||||
const toSlot = resolveSlot(toMatch[2], toNode.inputs)
|
||||
if (fromSlot === null || toSlot === null) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `connect: socket not found (from=${fromMatch[2]} to=${toMatch[2]})`
|
||||
}
|
||||
}
|
||||
try {
|
||||
const link = fromNode.connect(fromSlot, toNode, toSlot)
|
||||
if (!link) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: 'connect: link rejected (type mismatch?)'
|
||||
}
|
||||
}
|
||||
getCanvas()?.setDirty(true, true)
|
||||
captureUndo()
|
||||
// Auto-layout after successful connect so the canvas stays readable.
|
||||
// Opt out with --no-layout for users hand-placing nodes.
|
||||
const suppress = ctx.argv.includes('--no-layout')
|
||||
let extra = ''
|
||||
if (!suppress) {
|
||||
extra = ' + ' + runLayout('lr')
|
||||
}
|
||||
return {
|
||||
stdout: stringIter(
|
||||
`connected ${fromNode.id}.${fromMatch[2]} → ${toNode.id}.${toMatch[2]}${extra}\n`
|
||||
),
|
||||
exitCode: 0
|
||||
}
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: err instanceof Error ? err.message : String(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* layout [lr|tb]
|
||||
*
|
||||
* Topological tree layout of the active graph. `lr` = left-to-right (default,
|
||||
* natural for ComfyUI pipelines); `tb` = top-to-bottom. Uses longest-path
|
||||
* levelling with stable within-level ordering by id. Captures undo.
|
||||
*/
|
||||
interface LayoutNode {
|
||||
id: number
|
||||
pos: [number, number]
|
||||
size?: [number, number]
|
||||
}
|
||||
|
||||
interface LayoutLink {
|
||||
origin_id: number
|
||||
target_id: number
|
||||
}
|
||||
|
||||
function runLayout(direction: 'lr' | 'tb' = 'lr'): string {
|
||||
const graph = getGraph() as {
|
||||
_nodes?: LayoutNode[]
|
||||
links?: LayoutLink[] | Record<string, LayoutLink>
|
||||
} | null
|
||||
const nodes = graph?._nodes
|
||||
if (!nodes || nodes.length === 0) return 'layout: nothing to do'
|
||||
const rawLinks = graph?.links
|
||||
const links: LayoutLink[] = Array.isArray(rawLinks)
|
||||
? rawLinks.filter(Boolean)
|
||||
: Object.values(rawLinks ?? {}).filter(Boolean)
|
||||
|
||||
const parents = new Map<number, Set<number>>()
|
||||
for (const n of nodes) parents.set(n.id, new Set())
|
||||
for (const l of links) parents.get(l.target_id)?.add(l.origin_id)
|
||||
|
||||
const lvl = new Map<number, number>()
|
||||
for (const n of nodes) lvl.set(n.id, 0)
|
||||
let changed = true
|
||||
let guard = nodes.length * 2
|
||||
while (changed && guard-- > 0) {
|
||||
changed = false
|
||||
for (const n of nodes) {
|
||||
let m = -1
|
||||
for (const p of parents.get(n.id) ?? []) m = Math.max(m, lvl.get(p) ?? 0)
|
||||
if (m + 1 > (lvl.get(n.id) ?? 0)) {
|
||||
lvl.set(n.id, m + 1)
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const byLv = new Map<number, LayoutNode[]>()
|
||||
for (const n of nodes) {
|
||||
const k = lvl.get(n.id) ?? 0
|
||||
if (!byLv.has(k)) byLv.set(k, [])
|
||||
byLv.get(k)?.push(n)
|
||||
}
|
||||
const keys = [...byLv.keys()].sort((a, b) => a - b)
|
||||
|
||||
if (direction === 'lr') {
|
||||
let x = 60
|
||||
for (const k of keys) {
|
||||
const col = (byLv.get(k) ?? []).sort((a, b) => a.id - b.id)
|
||||
let y = 60
|
||||
let maxW = 0
|
||||
for (const n of col) {
|
||||
n.pos = [x, y]
|
||||
y += (n.size?.[1] ?? 100) + 40
|
||||
maxW = Math.max(maxW, n.size?.[0] ?? 220)
|
||||
}
|
||||
x += maxW + 60
|
||||
}
|
||||
} else {
|
||||
let y = 60
|
||||
for (const k of keys) {
|
||||
const row = (byLv.get(k) ?? []).sort((a, b) => a.id - b.id)
|
||||
let x = 60
|
||||
let maxH = 0
|
||||
for (const n of row) {
|
||||
n.pos = [x, y]
|
||||
x += (n.size?.[0] ?? 220) + 40
|
||||
maxH = Math.max(maxH, n.size?.[1] ?? 100)
|
||||
}
|
||||
y += maxH + 60
|
||||
}
|
||||
}
|
||||
getCanvas()?.setDirty(true, true)
|
||||
captureUndo()
|
||||
return `laid out ${nodes.length} nodes (${direction})`
|
||||
}
|
||||
|
||||
const layoutCmd: Command = async (ctx) => {
|
||||
const dir = (ctx.argv[1] ?? 'lr').toLowerCase()
|
||||
if (dir !== 'lr' && dir !== 'tb') {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: layout [lr|tb]'
|
||||
}
|
||||
}
|
||||
return { stdout: stringIter(runLayout(dir) + '\n'), exitCode: 0 }
|
||||
}
|
||||
|
||||
/**
|
||||
* disconnect <id>.<input>
|
||||
*
|
||||
* Remove the link feeding a specific input socket. Auto-layouts afterwards
|
||||
* (opt out with --no-layout). To clear multiple, call repeatedly.
|
||||
*/
|
||||
interface DisconnectableNode {
|
||||
id: number
|
||||
inputs?: Array<{ name?: string }>
|
||||
disconnectInput: (slot: number) => boolean
|
||||
}
|
||||
|
||||
const disconnectCmd: Command = async (ctx) => {
|
||||
const target = ctx.argv[1]
|
||||
if (!target) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: disconnect <id>.<input> [--no-layout]'
|
||||
}
|
||||
}
|
||||
const match = target.match(/^(\d+)\.(.+)$/)
|
||||
if (!match) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'disconnect: arg must be <id>.<socket>'
|
||||
}
|
||||
}
|
||||
const graph = getGraph() as { _nodes?: DisconnectableNode[] } | null
|
||||
const node = graph?._nodes?.find((n) => n.id === Number(match[1]))
|
||||
if (!node) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `disconnect: no node ${match[1]}`
|
||||
}
|
||||
}
|
||||
const slot = resolveSlot(match[2], node.inputs)
|
||||
if (slot === null) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `disconnect: unknown input "${match[2]}" on node ${node.id}`
|
||||
}
|
||||
}
|
||||
const ok = node.disconnectInput(slot)
|
||||
getCanvas()?.setDirty(true, true)
|
||||
captureUndo()
|
||||
const suppress = ctx.argv.includes('--no-layout')
|
||||
const extra = !suppress ? ' + ' + runLayout('lr') : ''
|
||||
return {
|
||||
stdout: stringIter(
|
||||
ok
|
||||
? `disconnected ${node.id}.${match[2]}${extra}\n`
|
||||
: `disconnect: ${node.id}.${match[2]} was not connected\n`
|
||||
),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* remove-node <id...>
|
||||
*
|
||||
* Delete one or more nodes from the active graph. Auto-layouts after.
|
||||
*/
|
||||
interface RemovableGraph {
|
||||
_nodes?: Array<{ id: number }>
|
||||
remove: (node: unknown) => void
|
||||
}
|
||||
|
||||
const removeNode: Command = async (ctx) => {
|
||||
const ids = ctx.argv
|
||||
.slice(1)
|
||||
.filter((a) => !a.startsWith('--'))
|
||||
.map((a) => Number(a))
|
||||
.filter((n) => Number.isFinite(n))
|
||||
if (ids.length === 0) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: remove-node <id...> [--no-layout]'
|
||||
}
|
||||
}
|
||||
const graph = getGraph() as unknown as RemovableGraph | null
|
||||
if (!graph?._nodes) {
|
||||
return { stdout: emptyIter(), exitCode: 1, stderr: 'no active graph' }
|
||||
}
|
||||
const removed: number[] = []
|
||||
for (const id of ids) {
|
||||
const n = graph._nodes.find((x) => x.id === id)
|
||||
if (n) {
|
||||
graph.remove(n)
|
||||
removed.push(id)
|
||||
}
|
||||
}
|
||||
getCanvas()?.setDirty(true, true)
|
||||
captureUndo()
|
||||
const suppress = ctx.argv.includes('--no-layout')
|
||||
const extra = !suppress && removed.length > 0 ? ' + ' + runLayout('lr') : ''
|
||||
return {
|
||||
stdout: stringIter(
|
||||
`removed ${removed.length} node(s): ${removed.join(', ')}${extra}\n`
|
||||
),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get-widget <id> <name>
|
||||
*
|
||||
* Read a widget's current value. Complements set-widget.
|
||||
*/
|
||||
interface WidgetCarrier {
|
||||
id: number
|
||||
widgets?: Array<{ name?: string; value?: unknown }>
|
||||
}
|
||||
|
||||
const getWidget: Command = async (ctx) => {
|
||||
const [, idArg, nameArg] = ctx.argv
|
||||
if (!idArg || !nameArg) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: get-widget <id> <name>'
|
||||
}
|
||||
}
|
||||
const graph = getGraph() as { _nodes?: WidgetCarrier[] } | null
|
||||
const node = graph?._nodes?.find((n) => n.id === Number(idArg))
|
||||
if (!node) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `get-widget: no node ${idArg}`
|
||||
}
|
||||
}
|
||||
const widget = node.widgets?.find((w) => w.name === nameArg)
|
||||
if (!widget) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `get-widget: no widget "${nameArg}" on node ${idArg}`
|
||||
}
|
||||
}
|
||||
return {
|
||||
stdout: stringIter(JSON.stringify(widget.value) + '\n'),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
|
||||
export function registerNodeOpsCommands(registry: CommandRegistry): void {
|
||||
registry.register('node-search', nodeSearch)
|
||||
registry.register('add-node', addNode)
|
||||
registry.register('align-nodes', alignNodes)
|
||||
registry.register('distribute-nodes', distributeNodes)
|
||||
registry.register('toggle-panel', togglePanel)
|
||||
registry.register('select', selectCmd)
|
||||
registry.register('connect', connectCmd)
|
||||
registry.register('get-widget', getWidget)
|
||||
registry.register('layout', layoutCmd)
|
||||
registry.register('disconnect', disconnectCmd)
|
||||
registry.register('remove-node', removeNode)
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
import { useComfyRegistryService } from '@/services/comfyRegistryService'
|
||||
import type { components } from '@comfyorg/registry-types'
|
||||
|
||||
import type { Command, CommandRegistry } from '../types'
|
||||
import { emptyIter, stringIter } from '../types'
|
||||
|
||||
type Pack = components['schemas']['Node']
|
||||
type ComfyNode = components['schemas']['ComfyNode']
|
||||
|
||||
const DEFAULT_LIMIT = 20
|
||||
|
||||
function packLine(p: Pack): string {
|
||||
const id = p.id ?? '?'
|
||||
const ver = p.latest_version?.version ?? 'unknown'
|
||||
const name = p.name ?? id
|
||||
const desc = (p.description ?? '').replace(/\s+/g, ' ').slice(0, 80)
|
||||
return `${id}@${ver} ${name}${desc ? ' — ' + desc : ''}`
|
||||
}
|
||||
|
||||
function nodeLine(n: ComfyNode): string {
|
||||
const name = n.comfy_node_name ?? '?'
|
||||
const cat = n.category ?? ''
|
||||
const desc = (n.description ?? '').replace(/\s+/g, ' ').slice(0, 80)
|
||||
const tail = [cat, desc].filter(Boolean).join(' — ')
|
||||
return tail ? `${name} (${tail})` : name
|
||||
}
|
||||
|
||||
/**
|
||||
* node-search-registry <pattern>
|
||||
*
|
||||
* Search the public Comfy Registry for node-classes matching <pattern>
|
||||
* across ALL published custom-node packs — including ones the user has
|
||||
* not installed locally. Use this when local `node-search` returns no
|
||||
* results: the node may exist in a pack that hasn't been installed yet.
|
||||
*
|
||||
* Output: one pack per line with install hint underneath.
|
||||
*/
|
||||
const nodeSearchRegistry: Command = async (ctx) => {
|
||||
const pattern = ctx.argv.slice(1).join(' ').trim()
|
||||
if (!pattern) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: node-search-registry <pattern>'
|
||||
}
|
||||
}
|
||||
const svc = useComfyRegistryService()
|
||||
const res = await svc.search({
|
||||
comfy_node_search: pattern,
|
||||
limit: DEFAULT_LIMIT
|
||||
})
|
||||
const packs = res?.nodes ?? []
|
||||
if (packs.length === 0) {
|
||||
return {
|
||||
stdout: stringIter(
|
||||
`no registry packs expose a node matching "${pattern}".\n` +
|
||||
'note: registry only indexes published packs. Try `pack-search ' +
|
||||
pattern +
|
||||
'` for pack-name/description match, or fall back to a github repo search.\n'
|
||||
),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
const total = res?.total ?? packs.length
|
||||
const lines = packs.map(
|
||||
(p) => packLine(p) + (p.id ? '\n inspect: pack-info ' + p.id : '')
|
||||
)
|
||||
const header =
|
||||
packs.length < total
|
||||
? `${packs.length} of ${total} pack(s) expose a node matching "${pattern}". To install one, ask the user to use ComfyUI-Manager (Settings → Extensions) — there is no shell command for pack installs yet.\n`
|
||||
: `${packs.length} pack(s) expose a node matching "${pattern}". To install one, ask the user to use ComfyUI-Manager (Settings → Extensions) — there is no shell command for pack installs yet.\n`
|
||||
return {
|
||||
stdout: stringIter(header + lines.join('\n') + '\n'),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* pack-search <pattern>
|
||||
*
|
||||
* Search the public Comfy Registry for packs whose name or description
|
||||
* matches <pattern>. Complements `node-search-registry` (which matches
|
||||
* node-class names) — use this when looking for a pack by topic rather
|
||||
* than by a specific node-class.
|
||||
*/
|
||||
const packSearch: Command = async (ctx) => {
|
||||
const pattern = ctx.argv.slice(1).join(' ').trim()
|
||||
if (!pattern) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: pack-search <pattern>'
|
||||
}
|
||||
}
|
||||
const svc = useComfyRegistryService()
|
||||
const res = await svc.search({ search: pattern, limit: DEFAULT_LIMIT })
|
||||
const packs = res?.nodes ?? []
|
||||
if (packs.length === 0) {
|
||||
return {
|
||||
stdout: stringIter(`no registry packs match "${pattern}".\n`),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
const total = res?.total ?? packs.length
|
||||
const header =
|
||||
packs.length < total
|
||||
? `${packs.length} of ${total} pack(s) match "${pattern}":\n`
|
||||
: `${packs.length} pack(s) match "${pattern}":\n`
|
||||
const lines = packs.map(
|
||||
(p) => packLine(p) + (p.id ? '\n inspect: pack-info ' + p.id : '')
|
||||
)
|
||||
return {
|
||||
stdout: stringIter(header + lines.join('\n') + '\n'),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* pack-info <pack_id>
|
||||
*
|
||||
* List all node-classes provided by <pack_id>'s latest version. Use this
|
||||
* to verify a pack actually contains the node you want before installing
|
||||
* it — registry node-search returns the pack, but not the full node list.
|
||||
*/
|
||||
const packInfo: Command = async (ctx) => {
|
||||
const packId = ctx.argv[1]?.trim()
|
||||
if (!packId) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: pack-info <pack_id>'
|
||||
}
|
||||
}
|
||||
const svc = useComfyRegistryService()
|
||||
const pack = await svc.getPackById(packId)
|
||||
if (!pack) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `pack-info: pack "${packId}" not found in registry`
|
||||
}
|
||||
}
|
||||
const version = pack.latest_version?.version
|
||||
if (!version) {
|
||||
return {
|
||||
stdout: stringIter(packLine(pack) + '\n (no published version)\n'),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
const defs = await svc.getNodeDefs({ packId, version })
|
||||
const nodes = defs?.comfy_nodes ?? []
|
||||
const head = packLine(pack)
|
||||
if (nodes.length === 0) {
|
||||
return {
|
||||
stdout: stringIter(head + '\n (this pack publishes no node defs)\n'),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
return {
|
||||
stdout: stringIter(
|
||||
head +
|
||||
`\nnodes (${nodes.length}):\n` +
|
||||
nodes.map((n) => ' ' + nodeLine(n)).join('\n') +
|
||||
'\n'
|
||||
),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
|
||||
export function registerRegistrySearchCommands(
|
||||
registry: CommandRegistry
|
||||
): void {
|
||||
registry.register('node-search-registry', nodeSearchRegistry)
|
||||
registry.register('pack-search', packSearch)
|
||||
registry.register('pack-info', packInfo)
|
||||
}
|
||||
@@ -1,175 +0,0 @@
|
||||
import { api } from '@/scripts/api'
|
||||
|
||||
import type { Command, CommandRegistry } from '../types'
|
||||
import { emptyIter, stringIter } from '../types'
|
||||
|
||||
/**
|
||||
* see [<question>]
|
||||
*
|
||||
* Capture the visible canvas (LiteGraph node graph) as a PNG, upload to
|
||||
* ComfyUI's input/ folder, and feed to Gemini 3.1 Pro for analysis.
|
||||
* Default question asks Gemini to describe what's on the canvas — useful
|
||||
* after a workflow run to confirm a Preview3D / PreviewImage actually
|
||||
* rendered, or to spot disconnected nodes / red error frames.
|
||||
*
|
||||
* Returns Gemini's text response. Requires Comfy Cloud auth (validate
|
||||
* uses the same auth flow).
|
||||
*
|
||||
* NOTE: Preview3D / Preview Audio render their own internal canvases,
|
||||
* which the main LiteGraph capture does not include. To inspect those,
|
||||
* pair `see` with the relevant filename via `validate <file>`.
|
||||
*/
|
||||
const see: Command = async (ctx) => {
|
||||
const question =
|
||||
ctx.argv.slice(1).join(' ').trim() ||
|
||||
'Describe what is visible on this ComfyUI canvas: what workflow is loaded, what node types are present, are any nodes showing errors or disconnected sockets, are there any visible image/3D previews?'
|
||||
|
||||
// Find the LiteGraph canvas — the main node-graph rendering surface.
|
||||
const canvas = document.querySelector(
|
||||
'canvas#graph-canvas, canvas.litegraph, .agent-xterm-panel + * canvas, body > canvas'
|
||||
) as HTMLCanvasElement | null
|
||||
const liteCanvas =
|
||||
canvas ??
|
||||
(Array.from(document.querySelectorAll('canvas')).find(
|
||||
(c) => c.width > 200 && c.height > 200
|
||||
) as HTMLCanvasElement | undefined)
|
||||
if (!liteCanvas) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: 'see: could not locate the canvas element'
|
||||
}
|
||||
}
|
||||
|
||||
// Capture as PNG blob.
|
||||
const blob = await new Promise<Blob | null>((resolve) =>
|
||||
liteCanvas.toBlob((b) => resolve(b), 'image/png')
|
||||
)
|
||||
if (!blob) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr:
|
||||
'see: canvas toBlob returned null (likely tainted by cross-origin content)'
|
||||
}
|
||||
}
|
||||
|
||||
// Upload to input/ under a stable agent-staging subfolder so we can use
|
||||
// it as a LoadImage source for Gemini.
|
||||
const ts = Date.now()
|
||||
const filename = `agent-see-${ts}.png`
|
||||
try {
|
||||
const form = new FormData()
|
||||
form.append('image', blob, filename)
|
||||
form.append('subfolder', 'agent-see')
|
||||
form.append('overwrite', 'true')
|
||||
const up = await fetch(api.apiURL('/upload/image'), {
|
||||
method: 'POST',
|
||||
body: form
|
||||
})
|
||||
if (!up.ok) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `see: upload failed (${up.status})`
|
||||
}
|
||||
}
|
||||
const upJson = (await up.json()) as { name?: string; subfolder?: string }
|
||||
const stagedPath = upJson.subfolder
|
||||
? `${upJson.subfolder}/${upJson.name}`
|
||||
: (upJson.name ?? filename)
|
||||
|
||||
// Submit a Gemini-only prompt with PreviewAny so the response isn't
|
||||
// culled (GeminiNode is api but not OUTPUT_NODE).
|
||||
const prompt = {
|
||||
prompt: {
|
||||
'1': { class_type: 'LoadImage', inputs: { image: stagedPath } },
|
||||
'2': {
|
||||
class_type: 'GeminiNode',
|
||||
inputs: {
|
||||
prompt: question,
|
||||
model: 'gemini-3-1-pro',
|
||||
seed: 1,
|
||||
images: ['1', 0]
|
||||
}
|
||||
},
|
||||
'3': { class_type: 'PreviewAny', inputs: { source: ['2', 0] } }
|
||||
},
|
||||
client_id: 'sno-agent-see'
|
||||
}
|
||||
const queueRes = await fetch(api.apiURL('/prompt'), {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(prompt)
|
||||
})
|
||||
if (!queueRes.ok) {
|
||||
const text = await queueRes.text().catch(() => '')
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `see: queue failed (${queueRes.status}) ${text.slice(0, 300)}`
|
||||
}
|
||||
}
|
||||
const queued = (await queueRes.json()) as { prompt_id?: string }
|
||||
const pid = queued.prompt_id
|
||||
if (!pid) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: 'see: queue did not return prompt_id'
|
||||
}
|
||||
}
|
||||
|
||||
// Poll history (Gemini ~5-10s).
|
||||
const deadline = Date.now() + 60_000
|
||||
while (Date.now() < deadline) {
|
||||
const hRes = await fetch(api.apiURL(`/history/${pid}`))
|
||||
if (hRes.ok) {
|
||||
const hJson = (await hRes.json()) as Record<
|
||||
string,
|
||||
{
|
||||
status?: { completed?: boolean }
|
||||
outputs?: Record<string, { text?: string[] }>
|
||||
}
|
||||
>
|
||||
const entry = hJson[pid]
|
||||
if (entry?.status?.completed) {
|
||||
const outs = entry.outputs ?? {}
|
||||
const texts: string[] = []
|
||||
for (const node of Object.values(outs)) {
|
||||
if (Array.isArray(node.text)) texts.push(...node.text)
|
||||
}
|
||||
return {
|
||||
stdout: stringIter(
|
||||
(texts.length ? texts.join('\n') : '(no text returned)') +
|
||||
'\n\n[saw: input/' +
|
||||
stagedPath +
|
||||
']\n'
|
||||
),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
await new Promise((r) => setTimeout(r, 1500))
|
||||
}
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `see: timed out (prompt_id=${pid})`
|
||||
}
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : String(err)
|
||||
const hint = /Failed to fetch/i.test(msg)
|
||||
? '\n hint: requires Comfy Cloud sign-in.'
|
||||
: ''
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: msg + hint
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function registerSeeCommands(registry: CommandRegistry): void {
|
||||
registry.register('see', see)
|
||||
}
|
||||
@@ -1,156 +0,0 @@
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
vi.mock('@/scripts/api', () => {
|
||||
class FakeApi extends EventTarget {
|
||||
listUserDataFullInfo = vi.fn()
|
||||
getUserData = vi.fn()
|
||||
storeUserData = vi.fn()
|
||||
deleteUserData = vi.fn()
|
||||
moveUserData = vi.fn()
|
||||
fetchApi = vi.fn()
|
||||
init = vi.fn()
|
||||
}
|
||||
return { api: new FakeApi() }
|
||||
})
|
||||
|
||||
vi.mock('@/platform/workflow/management/stores/workflowStore', () => ({
|
||||
useWorkflowStore: () => ({ activeWorkflow: null })
|
||||
}))
|
||||
|
||||
const openPanel = vi.fn()
|
||||
vi.mock('@/stores/workspace/rightSidePanelStore', () => ({
|
||||
useRightSidePanelStore: () => ({ openPanel })
|
||||
}))
|
||||
|
||||
import { useMissingModelStore } from '@/platform/missingModel/missingModelStore'
|
||||
|
||||
import { CommandRegistryImpl } from '../runtime'
|
||||
import type { CmdContext } from '../types'
|
||||
import { collect, emptyIter } from '../types'
|
||||
import { MemoryVFS } from '../vfs/memory'
|
||||
import { registerStateCommands } from './state'
|
||||
|
||||
function baseCtx(argv: string[]): CmdContext {
|
||||
return {
|
||||
argv,
|
||||
stdin: emptyIter(),
|
||||
env: new Map(),
|
||||
cwd: '/',
|
||||
vfs: new MemoryVFS(),
|
||||
signal: new AbortController().signal
|
||||
}
|
||||
}
|
||||
|
||||
describe('state commands', () => {
|
||||
beforeEach(() => {
|
||||
setActivePinia(createPinia())
|
||||
})
|
||||
|
||||
it('missing-models reports 0 when none', async () => {
|
||||
const r = new CommandRegistryImpl()
|
||||
registerStateCommands(r)
|
||||
const cmd = r.get('missing-models')!
|
||||
const res = await cmd(baseCtx(['missing-models']))
|
||||
expect(await collect(res.stdout)).toContain('0 missing')
|
||||
})
|
||||
|
||||
it('missing-models lists candidates from the store', async () => {
|
||||
const store = useMissingModelStore()
|
||||
store.setMissingModels([
|
||||
{
|
||||
nodeId: 5,
|
||||
nodeType: 'CheckpointLoaderSimple',
|
||||
widgetName: 'ckpt_name',
|
||||
isAssetSupported: false,
|
||||
name: 'v1-5-pruned.safetensors',
|
||||
directory: 'checkpoints',
|
||||
isMissing: true
|
||||
}
|
||||
])
|
||||
const r = new CommandRegistryImpl()
|
||||
registerStateCommands(r)
|
||||
const res = await r.get('missing-models')!(baseCtx(['missing-models']))
|
||||
const out = await collect(res.stdout)
|
||||
expect(out).toContain('MISSING')
|
||||
expect(out).toContain('v1-5-pruned.safetensors')
|
||||
expect(out).toContain('checkpoints')
|
||||
expect(out).toContain('CheckpointLoaderSimple')
|
||||
})
|
||||
|
||||
it('workflow-errors reports "no errors" when clean', async () => {
|
||||
const r = new CommandRegistryImpl()
|
||||
registerStateCommands(r)
|
||||
const res = await r.get('workflow-errors')!(baseCtx(['workflow-errors']))
|
||||
expect(await collect(res.stdout)).toContain('no errors')
|
||||
})
|
||||
|
||||
it('workflow-errors counts missing models', async () => {
|
||||
const store = useMissingModelStore()
|
||||
store.setMissingModels([
|
||||
{
|
||||
nodeType: 'X',
|
||||
widgetName: 'w',
|
||||
isAssetSupported: false,
|
||||
name: 'a',
|
||||
isMissing: true
|
||||
}
|
||||
])
|
||||
const r = new CommandRegistryImpl()
|
||||
registerStateCommands(r)
|
||||
const res = await r.get('workflow-errors')!(baseCtx(['workflow-errors']))
|
||||
expect(await collect(res.stdout)).toContain('missing models: 1')
|
||||
})
|
||||
|
||||
it('help emits command overview', async () => {
|
||||
const r = new CommandRegistryImpl()
|
||||
registerStateCommands(r)
|
||||
const res = await r.get('help')!(baseCtx(['help']))
|
||||
const out = await collect(res.stdout)
|
||||
expect(out).toContain('coreutils')
|
||||
expect(out).toContain('missing-models')
|
||||
expect(out).toContain('Mounts')
|
||||
})
|
||||
|
||||
it('show-errors opens right-side errors panel', async () => {
|
||||
openPanel.mockClear()
|
||||
const r = new CommandRegistryImpl()
|
||||
registerStateCommands(r)
|
||||
const res = await r.get('show-errors')!(baseCtx(['show-errors']))
|
||||
expect(res.exitCode).toBe(0)
|
||||
expect(openPanel).toHaveBeenCalledWith('errors')
|
||||
})
|
||||
|
||||
it('show-missing-models does nothing when count is 0', async () => {
|
||||
openPanel.mockClear()
|
||||
const r = new CommandRegistryImpl()
|
||||
registerStateCommands(r)
|
||||
const res = await r.get('show-missing-models')!(
|
||||
baseCtx(['show-missing-models'])
|
||||
)
|
||||
expect(res.exitCode).toBe(0)
|
||||
expect(res.stderr).toContain('no missing')
|
||||
expect(openPanel).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('show-missing-models opens panel when missing models exist', async () => {
|
||||
openPanel.mockClear()
|
||||
const store = useMissingModelStore()
|
||||
store.setMissingModels([
|
||||
{
|
||||
nodeType: 'X',
|
||||
widgetName: 'w',
|
||||
isAssetSupported: false,
|
||||
name: 'a',
|
||||
isMissing: true
|
||||
}
|
||||
])
|
||||
const r = new CommandRegistryImpl()
|
||||
registerStateCommands(r)
|
||||
const res = await r.get('show-missing-models')!(
|
||||
baseCtx(['show-missing-models'])
|
||||
)
|
||||
expect(res.exitCode).toBe(0)
|
||||
expect(openPanel).toHaveBeenCalledWith('errors')
|
||||
})
|
||||
})
|
||||
@@ -1,117 +0,0 @@
|
||||
import { useMissingModelStore } from '@/platform/missingModel/missingModelStore'
|
||||
import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
|
||||
import { useExecutionErrorStore } from '@/stores/executionErrorStore'
|
||||
import { useRightSidePanelStore } from '@/stores/workspace/rightSidePanelStore'
|
||||
|
||||
import type { Command, CommandRegistry } from '../types'
|
||||
import { emptyIter, stringIter } from '../types'
|
||||
|
||||
/**
|
||||
* Read-only state commands that mirror what the user sees in the UI.
|
||||
* Each command is backed by a Pinia store (not a raw API call), so the
|
||||
* numbers stay consistent with banners, error panels, and badges.
|
||||
*/
|
||||
|
||||
const missingModels: Command = async () => {
|
||||
const store = useMissingModelStore()
|
||||
const candidates = store.missingModelCandidates ?? []
|
||||
if (candidates.length === 0) {
|
||||
return { stdout: stringIter('0 missing models\n'), exitCode: 0 }
|
||||
}
|
||||
const lines = candidates.map((m) => {
|
||||
const where = m.nodeId !== undefined ? `node #${m.nodeId}` : 'workflow'
|
||||
const dir = m.directory ? ` (${m.directory})` : ''
|
||||
const status =
|
||||
m.isMissing === true
|
||||
? 'MISSING'
|
||||
: m.isMissing === false
|
||||
? 'installed'
|
||||
: 'pending'
|
||||
return `${status}\t${m.nodeType}.${m.widgetName}\t${m.name}${dir}\t${where}`
|
||||
})
|
||||
return {
|
||||
stdout: stringIter(lines.join('\n') + '\n'),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
|
||||
const workflowErrors: Command = async () => {
|
||||
const errorStore = useExecutionErrorStore()
|
||||
const missingStore = useMissingModelStore()
|
||||
const lines: string[] = []
|
||||
if (missingStore.missingModelCount > 0) {
|
||||
lines.push(`missing models: ${missingStore.missingModelCount}`)
|
||||
}
|
||||
if (errorStore.hasAnyError) {
|
||||
lines.push(`errors detected (see UI error overlay for detail)`)
|
||||
}
|
||||
if (lines.length === 0) {
|
||||
return { stdout: stringIter('no errors\n'), exitCode: 0 }
|
||||
}
|
||||
return { stdout: stringIter(lines.join('\n') + '\n'), exitCode: 0 }
|
||||
}
|
||||
|
||||
const activeWorkflow: Command = async () => {
|
||||
const store = useWorkflowStore()
|
||||
const wf = store.activeWorkflow
|
||||
if (!wf) {
|
||||
return { stdout: stringIter('no active workflow\n'), exitCode: 0 }
|
||||
}
|
||||
const lines = [
|
||||
`path: ${wf.path}`,
|
||||
`modified: ${wf.isModified ? 'yes' : 'no'}`,
|
||||
`persisted: ${wf.isPersisted ? 'yes' : 'no'}`
|
||||
]
|
||||
return { stdout: stringIter(lines.join('\n') + '\n'), exitCode: 0 }
|
||||
}
|
||||
|
||||
const help: Command = async () => {
|
||||
const lines = [
|
||||
'Available commands (this session):',
|
||||
' coreutils: echo cat ls pwd wc head tail grep true false',
|
||||
' comfy: cmd <id> invoke a registered UI command',
|
||||
' cmd-list [regex] discover command ids',
|
||||
' state: missing-models list missing models (same as UI banner)',
|
||||
' workflow-errors summarize errors on the active workflow',
|
||||
' active-workflow show the active workflow path + flags',
|
||||
' show-errors open the right-side errors panel',
|
||||
' show-missing-models open the errors panel and focus missing models',
|
||||
' help this message',
|
||||
'Mounts: /tmp (in-memory scratch), /workflows (saved workflows)'
|
||||
]
|
||||
return { stdout: stringIter(lines.join('\n') + '\n'), exitCode: 0 }
|
||||
}
|
||||
|
||||
const showErrorsPanel: Command = async () => {
|
||||
const panel = useRightSidePanelStore()
|
||||
panel.openPanel('errors')
|
||||
const errorStore = useExecutionErrorStore()
|
||||
errorStore.dismissErrorOverlay()
|
||||
return { stdout: stringIter('opened right-side errors panel\n'), exitCode: 0 }
|
||||
}
|
||||
|
||||
const showMissingModels: Command = async () => {
|
||||
const missing = useMissingModelStore()
|
||||
if (missing.missingModelCount === 0) {
|
||||
return { stdout: emptyIter(), exitCode: 0, stderr: 'no missing models' }
|
||||
}
|
||||
const panel = useRightSidePanelStore()
|
||||
panel.openPanel('errors')
|
||||
const errorStore = useExecutionErrorStore()
|
||||
errorStore.dismissErrorOverlay()
|
||||
return {
|
||||
stdout: stringIter(
|
||||
`opened errors panel (${missing.missingModelCount} missing models)\n`
|
||||
),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
|
||||
export function registerStateCommands(registry: CommandRegistry): void {
|
||||
registry.register('missing-models', missingModels)
|
||||
registry.register('workflow-errors', workflowErrors)
|
||||
registry.register('active-workflow', activeWorkflow)
|
||||
registry.register('show-errors', showErrorsPanel)
|
||||
registry.register('show-missing-models', showMissingModels)
|
||||
registry.register('help', help)
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
import { api } from '@/scripts/api'
|
||||
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
|
||||
import { useCommandStore } from '@/stores/commandStore'
|
||||
|
||||
import type { Command, CmdContext, CommandRegistry } from '../types'
|
||||
import { stringIter } from '../types'
|
||||
|
||||
interface LiteWidget {
|
||||
name?: string
|
||||
type?: string
|
||||
value?: unknown
|
||||
callback?: (v: unknown) => void
|
||||
}
|
||||
|
||||
interface LiteNode {
|
||||
id: number | string
|
||||
widgets?: LiteWidget[]
|
||||
}
|
||||
|
||||
function coerce(type: string | undefined, raw: string): unknown {
|
||||
if (type === 'number' || type === 'INT' || type === 'FLOAT') {
|
||||
const n = Number(raw)
|
||||
if (Number.isFinite(n)) return n
|
||||
}
|
||||
return raw
|
||||
}
|
||||
|
||||
async function pollUntilIdle(timeoutMs: number, signal: AbortSignal) {
|
||||
const deadline = Date.now() + timeoutMs
|
||||
while (Date.now() < deadline) {
|
||||
if (signal.aborted) throw new Error('aborted')
|
||||
const { Running, Pending } = await api.getQueue()
|
||||
if (Running.length === 0 && Pending.length === 0) return
|
||||
await new Promise((r) => setTimeout(r, 1200))
|
||||
}
|
||||
throw new Error('timed out waiting for queue')
|
||||
}
|
||||
|
||||
async function* runSweep(ctx: CmdContext): AsyncIterable<string> {
|
||||
const [, idArg, name, ...vals] = ctx.argv
|
||||
if (!idArg || !name || vals.length === 0) {
|
||||
yield 'usage: sweep <nodeId> <widgetName> <val1> [<val2> ...]\n'
|
||||
return
|
||||
}
|
||||
const canvas = useCanvasStore().canvas
|
||||
if (!canvas?.graph) {
|
||||
yield 'error: no active graph\n'
|
||||
return
|
||||
}
|
||||
const nodes = (canvas.graph as { _nodes: LiteNode[] })._nodes ?? []
|
||||
const node = nodes.find((n) => String(n.id) === idArg)
|
||||
if (!node) {
|
||||
yield `error: no node ${idArg}\n`
|
||||
return
|
||||
}
|
||||
const widget = node.widgets?.find((w) => w.name === name)
|
||||
if (!widget) {
|
||||
yield `error: node ${idArg} has no widget "${name}"\n`
|
||||
return
|
||||
}
|
||||
const cmdStore = useCommandStore()
|
||||
const results: string[] = []
|
||||
|
||||
for (const raw of vals) {
|
||||
if (ctx.signal.aborted) {
|
||||
yield 'aborted\n'
|
||||
return
|
||||
}
|
||||
const value = coerce(widget.type, raw)
|
||||
widget.value = value
|
||||
widget.callback?.(value)
|
||||
yield `[${raw}] set ${name}=${JSON.stringify(value)} — queuing...\n`
|
||||
await cmdStore.execute('Comfy.QueuePrompt')
|
||||
yield `[${raw}] queued. waiting for idle...\n`
|
||||
await pollUntilIdle(300_000, ctx.signal)
|
||||
results.push(String(value))
|
||||
yield `[${raw}] done.\n`
|
||||
}
|
||||
yield `sweep complete: ${name} over ${results.join(', ')}\n`
|
||||
}
|
||||
|
||||
const sweepCmd: Command = async (ctx) => ({
|
||||
stdout: runSweep(ctx),
|
||||
exitCode: 0
|
||||
})
|
||||
|
||||
const sweepHelpStr = `sweep <nodeId> <widgetName> <val1> [<val2> ...]
|
||||
|
||||
Sets the named widget on the given node to each value in turn,
|
||||
queues a prompt after each set, and waits for the queue to drain
|
||||
before moving to the next value.
|
||||
|
||||
Example — try CFG 5, 6, 7, 8 on node 3:
|
||||
sweep 3 cfg 5 6 7 8
|
||||
|
||||
Combine with seq for ranges:
|
||||
graph nodes KSampler | head -1 | ...
|
||||
(seq output is line-based; use set-widget for single values)
|
||||
`
|
||||
|
||||
export function registerSweepCommands(registry: CommandRegistry): void {
|
||||
registry.register('sweep', sweepCmd)
|
||||
registry.register('sweep-help', async () => ({
|
||||
stdout: stringIter(sweepHelpStr),
|
||||
exitCode: 0
|
||||
}))
|
||||
}
|
||||
@@ -1,177 +0,0 @@
|
||||
import { useWorkflowTemplatesStore } from '@/platform/workflow/templates/repositories/workflowTemplatesStore'
|
||||
import { api } from '@/scripts/api'
|
||||
import { app } from '@/scripts/app'
|
||||
|
||||
import type { Command, CommandRegistry } from '../types'
|
||||
import { emptyIter, stringIter } from '../types'
|
||||
|
||||
interface TemplateInfoSlim {
|
||||
name?: string
|
||||
title?: string
|
||||
localizedTitle?: string
|
||||
description?: string
|
||||
sourceModule?: string
|
||||
}
|
||||
|
||||
interface TemplateModuleSlim {
|
||||
moduleName: string
|
||||
templates: TemplateInfoSlim[]
|
||||
}
|
||||
|
||||
async function fetchTemplateJson(
|
||||
id: string,
|
||||
sourceModule: string
|
||||
): Promise<unknown> {
|
||||
if (sourceModule === 'default') {
|
||||
return fetch(api.fileURL(`/templates/${id}.json`)).then((r) => r.json())
|
||||
}
|
||||
return fetch(
|
||||
api.apiURL(`/workflow_templates/${sourceModule}/${id}.json`)
|
||||
).then((r) => r.json())
|
||||
}
|
||||
|
||||
/**
|
||||
* templates [filter]
|
||||
*
|
||||
* List available workflow templates. Output columns: moduleName/id — title.
|
||||
* Optional regex/substring filter (case-insensitive) matches title, id, or
|
||||
* description. Use before `load-template` to find a starting workflow.
|
||||
*/
|
||||
const templatesList: Command = async (ctx) => {
|
||||
const filter = ctx.argv.slice(1).join(' ').trim()
|
||||
let regex: RegExp | null = null
|
||||
if (filter) {
|
||||
try {
|
||||
regex = new RegExp(filter, 'i')
|
||||
} catch {
|
||||
const escaped = filter.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||
regex = new RegExp(escaped, 'i')
|
||||
}
|
||||
}
|
||||
|
||||
const store = useWorkflowTemplatesStore()
|
||||
try {
|
||||
if (!store.isLoaded) await store.loadWorkflowTemplates()
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr:
|
||||
'templates: failed to load index — ' +
|
||||
(err instanceof Error ? err.message : String(err))
|
||||
}
|
||||
}
|
||||
|
||||
const groups = store.groupedTemplates as Array<{
|
||||
label: string
|
||||
modules: TemplateModuleSlim[]
|
||||
}>
|
||||
const lines: string[] = []
|
||||
let total = 0
|
||||
for (const group of groups) {
|
||||
for (const mod of group.modules) {
|
||||
for (const tpl of mod.templates) {
|
||||
const id = tpl.name ?? ''
|
||||
const title = tpl.localizedTitle ?? tpl.title ?? id
|
||||
const desc = (tpl.description ?? '').replace(/\s+/g, ' ').slice(0, 80)
|
||||
if (
|
||||
regex &&
|
||||
!regex.test(id) &&
|
||||
!regex.test(title) &&
|
||||
!regex.test(desc)
|
||||
) {
|
||||
continue
|
||||
}
|
||||
lines.push(`${mod.moduleName}/${id} — ${title}`)
|
||||
total++
|
||||
}
|
||||
}
|
||||
}
|
||||
if (total === 0) {
|
||||
return {
|
||||
stdout: stringIter(
|
||||
filter
|
||||
? `(no templates match "${filter}")\n`
|
||||
: '(no templates loaded)\n'
|
||||
),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
lines.push('', `${total} template(s). Use: load-template <moduleName> <id>`)
|
||||
return { stdout: stringIter(lines.join('\n') + '\n'), exitCode: 0 }
|
||||
}
|
||||
|
||||
/**
|
||||
* load-template <moduleName> <id>
|
||||
*
|
||||
* Load a workflow template by module + id (as shown by `templates`).
|
||||
* Replaces the active workflow. Use when the user asks for something
|
||||
* starting from a standard pipeline instead of building from scratch.
|
||||
*/
|
||||
const loadTemplate: Command = async (ctx) => {
|
||||
const [, moduleName, id] = ctx.argv
|
||||
if (!moduleName || !id) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: load-template <moduleName> <id> (run `templates` first)'
|
||||
}
|
||||
}
|
||||
const store = useWorkflowTemplatesStore()
|
||||
try {
|
||||
if (!store.isLoaded) await store.loadWorkflowTemplates()
|
||||
} catch {
|
||||
/* keep going with whatever sourceModule was passed */
|
||||
}
|
||||
|
||||
// Resolve the real sourceModule: when listings show moduleName='all',
|
||||
// the template carries its own sourceModule. Also handles the common
|
||||
// case of a template id that only lives under one known sourceModule.
|
||||
let resolvedSource = moduleName
|
||||
const groups = store.groupedTemplates as Array<{
|
||||
modules: TemplateModuleSlim[]
|
||||
}>
|
||||
outer: for (const g of groups) {
|
||||
for (const mod of g.modules) {
|
||||
if (mod.moduleName !== moduleName && moduleName !== 'all') continue
|
||||
for (const tpl of mod.templates) {
|
||||
if (tpl.name === id) {
|
||||
resolvedSource = tpl.sourceModule ?? mod.moduleName
|
||||
break outer
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const json = (await fetchTemplateJson(id, resolvedSource)) as Parameters<
|
||||
typeof app.loadGraphData
|
||||
>[0]
|
||||
await app.loadGraphData(json, true, true, id, {
|
||||
openSource: 'template'
|
||||
})
|
||||
return {
|
||||
stdout: stringIter(
|
||||
`loaded template ${resolvedSource}/${id}` +
|
||||
(resolvedSource !== moduleName
|
||||
? ` (resolved from ${moduleName})`
|
||||
: '') +
|
||||
'\n'
|
||||
),
|
||||
exitCode: 0
|
||||
}
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr:
|
||||
`load-template: failed to load ${resolvedSource}/${id} — ` +
|
||||
(err instanceof Error ? err.message : String(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function registerTemplateCommands(registry: CommandRegistry): void {
|
||||
registry.register('templates', templatesList)
|
||||
registry.register('load-template', loadTemplate)
|
||||
}
|
||||
@@ -1,172 +0,0 @@
|
||||
import { api } from '@/scripts/api'
|
||||
|
||||
import type { Command, CommandRegistry } from '../types'
|
||||
import { emptyIter, stringIter } from '../types'
|
||||
|
||||
/**
|
||||
* validate <filename> [<prompt-text...>]
|
||||
*
|
||||
* Send an image (from ComfyUI's output/ folder) through the cloud
|
||||
* GeminiNode (gemini-3-1-pro) to get a visual quality assessment. Use
|
||||
* after any SaveImage to confirm the result matches user intent before
|
||||
* moving on to expensive next-phase work (e.g. image-to-3D).
|
||||
*
|
||||
* If no prompt is given, asks Gemini for a concise 1-5 rating and
|
||||
* description. Requires Comfy Cloud auth (same as other api_* nodes).
|
||||
*/
|
||||
const validate: Command = async (ctx) => {
|
||||
const args = ctx.argv.slice(1)
|
||||
if (args.length === 0) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr:
|
||||
'usage: validate <filename_in_output> [<question...>]\n' +
|
||||
' hint: `latest-output-name` gives the most recent filename'
|
||||
}
|
||||
}
|
||||
const filename = args[0]
|
||||
const question =
|
||||
args.slice(1).join(' ').trim() ||
|
||||
'Describe this image in one short sentence. Then rate its overall quality from 1-5. Format: "<description> | rating: N/5"'
|
||||
|
||||
// Minimal workflow: LoadImage (from output/) → GeminiNode → (implicit
|
||||
// return in /history). We use type=output because SaveImage writes there.
|
||||
// LoadImage reads from input/, so copy via the existing /upload/image
|
||||
// path first — keeps this command side-effect-free on input/ by using
|
||||
// subfolder='validate-staging'.
|
||||
try {
|
||||
const viewRes = await fetch(
|
||||
api.apiURL(`/view?filename=${encodeURIComponent(filename)}&type=output`)
|
||||
)
|
||||
if (!viewRes.ok) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `validate: cannot read output/${filename} (${viewRes.status})`
|
||||
}
|
||||
}
|
||||
const blob = await viewRes.blob()
|
||||
const form = new FormData()
|
||||
form.append('image', blob, filename)
|
||||
form.append('subfolder', 'agent-validate')
|
||||
form.append('overwrite', 'true')
|
||||
const up = await fetch(api.apiURL('/upload/image'), {
|
||||
method: 'POST',
|
||||
body: form
|
||||
})
|
||||
if (!up.ok) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `validate: upload-to-input failed (${up.status})`
|
||||
}
|
||||
}
|
||||
const upJson = (await up.json()) as { name?: string; subfolder?: string }
|
||||
const stagedName = upJson.subfolder
|
||||
? `${upJson.subfolder}/${upJson.name}`
|
||||
: (upJson.name ?? filename)
|
||||
|
||||
const prompt = {
|
||||
prompt: {
|
||||
'1': {
|
||||
class_type: 'LoadImage',
|
||||
inputs: { image: stagedName }
|
||||
},
|
||||
'2': {
|
||||
class_type: 'GeminiNode',
|
||||
inputs: {
|
||||
prompt: question,
|
||||
model: 'gemini-3-1-pro',
|
||||
seed: 1,
|
||||
images: ['1', 0]
|
||||
}
|
||||
},
|
||||
// PreviewAny is an OUTPUT_NODE — without it ComfyUI's executor
|
||||
// culls the Gemini call as a dead branch (no consumer of its
|
||||
// STRING output) and returns success without invoking the API.
|
||||
'3': {
|
||||
class_type: 'PreviewAny',
|
||||
inputs: { source: ['2', 0] }
|
||||
}
|
||||
},
|
||||
client_id: 'sno-agent-validate'
|
||||
}
|
||||
|
||||
const queueRes = await fetch(api.apiURL('/prompt'), {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(prompt)
|
||||
})
|
||||
if (!queueRes.ok) {
|
||||
const text = await queueRes.text().catch(() => '')
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `validate: queue rejected (${queueRes.status}) ${text.slice(0, 300)}`
|
||||
}
|
||||
}
|
||||
const queued = (await queueRes.json()) as { prompt_id?: string }
|
||||
const pid = queued.prompt_id
|
||||
if (!pid) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: 'validate: queue did not return a prompt_id'
|
||||
}
|
||||
}
|
||||
|
||||
// Poll history for completion. Gemini API round-trips in seconds.
|
||||
const deadline = Date.now() + 60_000
|
||||
while (Date.now() < deadline) {
|
||||
const hRes = await fetch(api.apiURL(`/history/${pid}`))
|
||||
if (hRes.ok) {
|
||||
const hJson = (await hRes.json()) as Record<
|
||||
string,
|
||||
{
|
||||
status?: { completed?: boolean }
|
||||
outputs?: Record<string, { text?: string[] }>
|
||||
}
|
||||
>
|
||||
const entry = hJson[pid]
|
||||
if (entry?.status?.completed) {
|
||||
const outputs = entry.outputs ?? {}
|
||||
const texts: string[] = []
|
||||
for (const node of Object.values(outputs)) {
|
||||
if (Array.isArray(node.text)) texts.push(...node.text)
|
||||
}
|
||||
if (texts.length === 0) {
|
||||
return {
|
||||
stdout: stringIter('(validate: no text output)\n'),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
return {
|
||||
stdout: stringIter(texts.join('\n') + '\n'),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
await new Promise((r) => setTimeout(r, 1500))
|
||||
}
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: `validate: timed out waiting for Gemini (prompt_id=${pid})`
|
||||
}
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : String(err)
|
||||
const hint = /Failed to fetch/i.test(msg)
|
||||
? '\n hint: requires Comfy Cloud sign-in (menu → Sign In).'
|
||||
: ''
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: msg + hint
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function registerValidateCommands(registry: CommandRegistry): void {
|
||||
registry.register('validate', validate)
|
||||
}
|
||||
@@ -1,288 +0,0 @@
|
||||
import { useWorkflowService } from '@/platform/workflow/core/services/workflowService'
|
||||
import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
|
||||
import type { ComfyWorkflow } from '@/platform/workflow/management/stores/workflowStore'
|
||||
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
|
||||
import { api } from '@/scripts/api'
|
||||
import { app } from '@/scripts/app'
|
||||
import { useCommandStore } from '@/stores/commandStore'
|
||||
import { ensureWorkflowSuffix, getWorkflowSuffix } from '@/utils/formatUtil'
|
||||
import { getAllNonIoNodesInSubgraph } from '@/utils/graphTraversalUtil'
|
||||
|
||||
import type { Command, CommandRegistry } from '../types'
|
||||
import { emptyIter, stringIter } from '../types'
|
||||
|
||||
function stripQuotes(s: string): string {
|
||||
return s.trim().replace(/^['"`]|['"`]$/g, '')
|
||||
}
|
||||
|
||||
/**
|
||||
* save-as <name>
|
||||
*
|
||||
* Non-interactive "Save Workflow As". The core Comfy.SaveWorkflowAs command
|
||||
* opens a modal prompt for the filename, which blocks the agent's
|
||||
* tool-call flow. This wrapper calls workflowService.saveWorkflowAs with
|
||||
* a pre-supplied filename so the LLM can save in one step.
|
||||
*/
|
||||
const saveAs: Command = async (ctx) => {
|
||||
const name = stripQuotes(ctx.argv.slice(1).join(' '))
|
||||
if (!name) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: save-as <filename>'
|
||||
}
|
||||
}
|
||||
const workflow = useWorkflowStore().activeWorkflow as ComfyWorkflow | null
|
||||
if (!workflow) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: 'save-as: no active workflow'
|
||||
}
|
||||
}
|
||||
try {
|
||||
const ok = await useWorkflowService().saveWorkflowAs(workflow, {
|
||||
filename: name
|
||||
})
|
||||
if (!ok) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: 'save-as: cancelled or failed'
|
||||
}
|
||||
}
|
||||
return { stdout: stringIter(`saved as ${name}\n`), exitCode: 0 }
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: err instanceof Error ? err.message : String(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* new-workflow [name]
|
||||
*
|
||||
* Create a new blank workflow. If a name is given, immediately persist it
|
||||
* via save-as so the file is visible in /workflows without a modal.
|
||||
*/
|
||||
const newWorkflow: Command = async (ctx) => {
|
||||
const name = stripQuotes(ctx.argv.slice(1).join(' '))
|
||||
try {
|
||||
await useCommandStore().execute('Comfy.NewBlankWorkflow')
|
||||
if (!name) {
|
||||
return { stdout: stringIter('new blank workflow\n'), exitCode: 0 }
|
||||
}
|
||||
const workflow = useWorkflowStore().activeWorkflow as ComfyWorkflow | null
|
||||
if (!workflow) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: 'new-workflow: no active workflow after create'
|
||||
}
|
||||
}
|
||||
const ok = await useWorkflowService().saveWorkflowAs(workflow, {
|
||||
filename: name
|
||||
})
|
||||
if (!ok) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: 'new-workflow: save-as cancelled or failed'
|
||||
}
|
||||
}
|
||||
return {
|
||||
stdout: stringIter(`new workflow saved as ${name}\n`),
|
||||
exitCode: 0
|
||||
}
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: err instanceof Error ? err.message : String(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* rename-workflow <newname>
|
||||
*
|
||||
* Non-interactive rename of the active persisted workflow. Bypasses the
|
||||
* modal prompt opened by Comfy.RenameWorkflow.
|
||||
*/
|
||||
const renameWorkflow: Command = async (ctx) => {
|
||||
const newName = stripQuotes(ctx.argv.slice(1).join(' '))
|
||||
if (!newName) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: rename-workflow <newname>'
|
||||
}
|
||||
}
|
||||
const workflow = useWorkflowStore().activeWorkflow as ComfyWorkflow | null
|
||||
if (!workflow) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: 'rename-workflow: no active workflow'
|
||||
}
|
||||
}
|
||||
if (!workflow.isPersisted) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: 'rename-workflow: workflow is not persisted — use save-as instead'
|
||||
}
|
||||
}
|
||||
if (newName === workflow.filename) {
|
||||
return {
|
||||
stdout: stringIter(`rename-workflow: unchanged (${newName})\n`),
|
||||
exitCode: 0
|
||||
}
|
||||
}
|
||||
try {
|
||||
const suffix = getWorkflowSuffix(workflow.suffix)
|
||||
const newPath =
|
||||
workflow.directory + '/' + ensureWorkflowSuffix(newName, suffix)
|
||||
await useWorkflowService().renameWorkflow(workflow, newPath)
|
||||
return {
|
||||
stdout: stringIter(`renamed to ${newPath}\n`),
|
||||
exitCode: 0
|
||||
}
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: err instanceof Error ? err.message : String(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* set-subgraph-desc <description...>
|
||||
*
|
||||
* Set the BlueprintDescription on the currently-open subgraph.
|
||||
* Bypasses the modal prompt opened by Comfy.Subgraph.SetDescription.
|
||||
*/
|
||||
const setSubgraphDesc: Command = async (ctx) => {
|
||||
const description = ctx.argv.slice(1).join(' ').trim()
|
||||
if (!description) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: set-subgraph-desc <description...>'
|
||||
}
|
||||
}
|
||||
const canvas = useCanvasStore().canvas
|
||||
const subgraph = canvas?.subgraph
|
||||
if (!subgraph) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: 'set-subgraph-desc: no active subgraph'
|
||||
}
|
||||
}
|
||||
try {
|
||||
const extra = (subgraph.extra ??= {}) as Record<string, unknown>
|
||||
extra.BlueprintDescription = description.trim() || undefined
|
||||
useWorkflowStore().activeWorkflow?.changeTracker?.checkState()
|
||||
return {
|
||||
stdout: stringIter(`subgraph description set\n`),
|
||||
exitCode: 0
|
||||
}
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: err instanceof Error ? err.message : String(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* set-subgraph-aliases <alias1> [alias2 ...]
|
||||
*
|
||||
* Set the BlueprintSearchAliases on the currently-open subgraph.
|
||||
* Bypasses the modal prompt opened by Comfy.Subgraph.SetSearchAliases.
|
||||
*/
|
||||
const setSubgraphAliases: Command = async (ctx) => {
|
||||
const raw = ctx.argv.slice(1)
|
||||
if (raw.length === 0) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: set-subgraph-aliases <alias1> [alias2 ...]'
|
||||
}
|
||||
}
|
||||
const aliases = raw
|
||||
.flatMap((s) => s.split(','))
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean)
|
||||
const canvas = useCanvasStore().canvas
|
||||
const subgraph = canvas?.subgraph
|
||||
if (!subgraph) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: 'set-subgraph-aliases: no active subgraph'
|
||||
}
|
||||
}
|
||||
try {
|
||||
const extra = (subgraph.extra ??= {}) as Record<string, unknown>
|
||||
extra.BlueprintSearchAliases = aliases.length > 0 ? aliases : undefined
|
||||
useWorkflowStore().activeWorkflow?.changeTracker?.checkState()
|
||||
return {
|
||||
stdout: stringIter(`subgraph aliases: ${aliases.join(', ')}\n`),
|
||||
exitCode: 0
|
||||
}
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: err instanceof Error ? err.message : String(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* clear-workflow --force
|
||||
*
|
||||
* Clear the active workflow without the native confirm() dialog.
|
||||
* The --force flag is mandatory to prevent accidental destruction.
|
||||
*/
|
||||
const clearWorkflow: Command = async (ctx) => {
|
||||
const force = ctx.argv.slice(1).includes('--force')
|
||||
if (!force) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: 'usage: clear-workflow --force (required to confirm destruction)'
|
||||
}
|
||||
}
|
||||
try {
|
||||
app.clean()
|
||||
if (app.canvas.subgraph) {
|
||||
const subgraph = app.canvas.subgraph
|
||||
const nonIoNodes = getAllNonIoNodesInSubgraph(subgraph)
|
||||
nonIoNodes.forEach((node) => subgraph.remove(node))
|
||||
}
|
||||
api.dispatchCustomEvent('graphCleared')
|
||||
return { stdout: stringIter('workflow cleared\n'), exitCode: 0 }
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: err instanceof Error ? err.message : String(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function registerWorkflowCommands(registry: CommandRegistry): void {
|
||||
registry.register('save-as', saveAs)
|
||||
registry.register('new-workflow', newWorkflow)
|
||||
registry.register('rename-workflow', renameWorkflow)
|
||||
registry.register('set-subgraph-desc', setSubgraphDesc)
|
||||
registry.register('set-subgraph-aliases', setSubgraphAliases)
|
||||
registry.register('clear-workflow', clearWorkflow)
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
vi.mock('@/scripts/api', () => ({
|
||||
api: {
|
||||
listUserDataFullInfo: vi.fn(),
|
||||
getUserData: vi.fn(),
|
||||
storeUserData: vi.fn(),
|
||||
deleteUserData: vi.fn(),
|
||||
moveUserData: vi.fn()
|
||||
}
|
||||
}))
|
||||
|
||||
import { api } from '@/scripts/api'
|
||||
import { useCommandStore } from '@/stores/commandStore'
|
||||
|
||||
import { registerComfyCommands } from './commands/comfy'
|
||||
import { registerCoreutils } from './commands/coreutils'
|
||||
import { CommandRegistryImpl, runScript } from './runtime'
|
||||
import { collect } from './types'
|
||||
import { MemoryVFS } from './vfs/memory'
|
||||
import { MountedVFS } from './vfs/mount'
|
||||
import { UserdataVFS } from './vfs/userdata'
|
||||
|
||||
function setupRegistry() {
|
||||
const r = new CommandRegistryImpl()
|
||||
registerCoreutils(r)
|
||||
registerComfyCommands(r)
|
||||
return r
|
||||
}
|
||||
|
||||
function setupVfs() {
|
||||
return new MountedVFS({
|
||||
'/tmp': new MemoryVFS(),
|
||||
'/workflows': new UserdataVFS('workflows')
|
||||
})
|
||||
}
|
||||
|
||||
function ctx(registry = setupRegistry(), vfs = setupVfs()) {
|
||||
return {
|
||||
registry,
|
||||
vfs,
|
||||
env: new Map<string, string>(),
|
||||
cwd: '/',
|
||||
signal: new AbortController().signal
|
||||
}
|
||||
}
|
||||
|
||||
describe('shell integration', () => {
|
||||
beforeEach(() => {
|
||||
setActivePinia(createPinia())
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
it('lists mount roots at /', async () => {
|
||||
const r = await runScript('ls /', ctx())
|
||||
expect(r.exitCode).toBe(0)
|
||||
const out = await collect(r.stdout)
|
||||
expect(out).toContain('tmp')
|
||||
expect(out).toContain('workflows')
|
||||
})
|
||||
|
||||
it('ls /workflows routes through userdata API', async () => {
|
||||
vi.mocked(api.listUserDataFullInfo).mockResolvedValue([
|
||||
{ path: 'workflows/a.json', size: 10, modified: 1 },
|
||||
{ path: 'workflows/b.json', size: 20, modified: 2 }
|
||||
])
|
||||
const r = await runScript('ls /workflows', ctx())
|
||||
expect(r.exitCode).toBe(0)
|
||||
expect(await collect(r.stdout)).toBe('a.json\nb.json\n')
|
||||
expect(api.listUserDataFullInfo).toHaveBeenCalledWith('workflows')
|
||||
})
|
||||
|
||||
it('cat /workflows/foo.json reads via userdata', async () => {
|
||||
vi.mocked(api.getUserData).mockResolvedValue(
|
||||
new Response('{"nodes":[]}', { status: 200 })
|
||||
)
|
||||
const r = await runScript('cat /workflows/foo.json', ctx())
|
||||
expect(r.exitCode).toBe(0)
|
||||
expect(await collect(r.stdout)).toBe('{"nodes":[]}')
|
||||
expect(api.getUserData).toHaveBeenCalledWith('workflows/foo.json')
|
||||
})
|
||||
|
||||
it('pipeline: ls | grep filters userdata listing', async () => {
|
||||
vi.mocked(api.listUserDataFullInfo).mockResolvedValue([
|
||||
{ path: 'workflows/cat.json', size: 1, modified: 1 },
|
||||
{ path: 'workflows/dog.json', size: 1, modified: 1 }
|
||||
])
|
||||
const r = await runScript('ls /workflows | grep cat', ctx())
|
||||
expect(await collect(r.stdout)).toBe('cat.json\n')
|
||||
})
|
||||
|
||||
it('redirect > /tmp persists to memory mount', async () => {
|
||||
const c = ctx()
|
||||
await runScript('echo hello > /tmp/out.txt', c)
|
||||
const r2 = await runScript('cat /tmp/out.txt', c)
|
||||
expect(await collect(r2.stdout)).toBe('hello\n')
|
||||
})
|
||||
|
||||
it('redirect > /workflows writes via userdata', async () => {
|
||||
vi.mocked(api.storeUserData).mockResolvedValue(
|
||||
new Response('', { status: 200 })
|
||||
)
|
||||
const r = await runScript('echo data > /workflows/new.json', ctx())
|
||||
expect(r.exitCode).toBe(0)
|
||||
expect(api.storeUserData).toHaveBeenCalledWith(
|
||||
'workflows/new.json',
|
||||
'data\n',
|
||||
expect.anything()
|
||||
)
|
||||
})
|
||||
|
||||
it('&& short-circuits on ls failure', async () => {
|
||||
vi.mocked(api.listUserDataFullInfo).mockRejectedValue(new Error('boom'))
|
||||
const r = await runScript('ls /workflows && echo yes', ctx())
|
||||
expect(r.exitCode).toBe(1)
|
||||
expect(await collect(r.stdout)).not.toContain('yes')
|
||||
})
|
||||
|
||||
it('cmd-list returns registered command ids', async () => {
|
||||
const store = useCommandStore()
|
||||
store.registerCommand({
|
||||
id: 'Comfy.Test.Foo',
|
||||
function: () => {},
|
||||
label: 'Foo'
|
||||
})
|
||||
store.registerCommand({
|
||||
id: 'Comfy.Test.Bar',
|
||||
function: () => {},
|
||||
label: 'Bar'
|
||||
})
|
||||
const r = await runScript('cmd-list Test', ctx())
|
||||
const out = await collect(r.stdout)
|
||||
expect(out).toContain('Comfy.Test.Foo')
|
||||
expect(out).toContain('Comfy.Test.Bar')
|
||||
})
|
||||
|
||||
it('cmd invokes a registered command', async () => {
|
||||
const store = useCommandStore()
|
||||
const spy = vi.fn()
|
||||
store.registerCommand({
|
||||
id: 'Comfy.Test.Click',
|
||||
function: spy,
|
||||
label: 'Click'
|
||||
})
|
||||
const r = await runScript('cmd Comfy.Test.Click', ctx())
|
||||
expect(r.exitCode).toBe(0)
|
||||
expect(spy).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('cmd returns 127 for unknown command', async () => {
|
||||
const r = await runScript('cmd Comfy.Nope', ctx())
|
||||
expect(r.exitCode).toBe(127)
|
||||
expect(r.stderr).toContain('unknown')
|
||||
})
|
||||
|
||||
it('unknown mount path errors cleanly', async () => {
|
||||
const r = await runScript('ls /nowhere', ctx())
|
||||
expect(r.exitCode).toBe(1)
|
||||
expect(r.stderr).toMatch(/no mount/)
|
||||
})
|
||||
|
||||
it('empty /workflows listing returns no output', async () => {
|
||||
vi.mocked(api.listUserDataFullInfo).mockResolvedValue([])
|
||||
const r = await runScript('ls /workflows', ctx())
|
||||
expect(r.exitCode).toBe(0)
|
||||
expect(await collect(r.stdout)).toBe('')
|
||||
})
|
||||
|
||||
it('write then read roundtrip on /tmp via shell', async () => {
|
||||
const c = ctx()
|
||||
await runScript('echo line1 > /tmp/a ; echo line2 >> /tmp/a', c)
|
||||
const r = await runScript('cat /tmp/a | wc', c)
|
||||
expect(await collect(r.stdout)).toBe('2 2 12\n')
|
||||
})
|
||||
})
|
||||
@@ -1,96 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { parseScript } from './parser'
|
||||
|
||||
describe('parseScript', () => {
|
||||
it('parses single command', () => {
|
||||
expect(parseScript('echo hi')).toEqual({
|
||||
type: 'simple',
|
||||
cmd: { argv: ['echo', 'hi'], redirect: undefined }
|
||||
})
|
||||
})
|
||||
|
||||
it('parses quoted arguments', () => {
|
||||
const node = parseScript('echo "hello world"')
|
||||
expect(node).toMatchObject({
|
||||
type: 'simple',
|
||||
cmd: { argv: ['echo', 'hello world'] }
|
||||
})
|
||||
})
|
||||
|
||||
it('parses pipes', () => {
|
||||
const node = parseScript('a | b | c')
|
||||
expect(node.type).toBe('pipe')
|
||||
if (node.type === 'pipe') {
|
||||
expect(node.cmds.map((c) => c.argv[0])).toEqual(['a', 'b', 'c'])
|
||||
}
|
||||
})
|
||||
|
||||
it('parses seq ;', () => {
|
||||
const node = parseScript('a ; b')
|
||||
expect(node.type).toBe('seq')
|
||||
})
|
||||
|
||||
it('parses && as and', () => {
|
||||
const node = parseScript('a && b')
|
||||
expect(node.type).toBe('and')
|
||||
})
|
||||
|
||||
it('parses || as or', () => {
|
||||
const node = parseScript('a || b')
|
||||
expect(node.type).toBe('or')
|
||||
})
|
||||
|
||||
it('precedence: pipe binds tightest, then and/or, then seq', () => {
|
||||
const node = parseScript('a && b | c || d ; e')
|
||||
expect(node.type).toBe('seq')
|
||||
if (node.type !== 'seq') return
|
||||
expect(node.right).toMatchObject({
|
||||
type: 'simple',
|
||||
cmd: { argv: ['e'] }
|
||||
})
|
||||
expect(node.left.type).toBe('or')
|
||||
})
|
||||
|
||||
it('parses > redirect on simple cmd', () => {
|
||||
const node = parseScript('echo hi > /tmp/x')
|
||||
expect(node).toMatchObject({
|
||||
type: 'simple',
|
||||
cmd: { argv: ['echo', 'hi'], redirect: { op: '>', path: '/tmp/x' } }
|
||||
})
|
||||
})
|
||||
|
||||
it('parses >> redirect', () => {
|
||||
const node = parseScript('echo hi >> /tmp/x')
|
||||
if (node.type !== 'simple') throw new Error('expected simple')
|
||||
expect(node.cmd.redirect).toEqual({ op: '>>', path: '/tmp/x' })
|
||||
})
|
||||
|
||||
it('lifts pipe final redirect to pipe node', () => {
|
||||
const node = parseScript('a | b > /tmp/x')
|
||||
expect(node.type).toBe('pipe')
|
||||
if (node.type !== 'pipe') return
|
||||
expect(node.redirect).toEqual({ op: '>', path: '/tmp/x' })
|
||||
expect(node.cmds[1].redirect).toBeUndefined()
|
||||
})
|
||||
|
||||
it('expands $VAR from env', () => {
|
||||
const node = parseScript('echo $FOO', { FOO: 'bar' })
|
||||
expect(node).toMatchObject({
|
||||
type: 'simple',
|
||||
cmd: { argv: ['echo', 'bar'] }
|
||||
})
|
||||
})
|
||||
|
||||
it('throws on command substitution $(...)', () => {
|
||||
expect(() => parseScript('echo $(ls)')).toThrow()
|
||||
})
|
||||
|
||||
it('throws on glob', () => {
|
||||
expect(() => parseScript('echo *.txt')).toThrow(/glob/)
|
||||
})
|
||||
|
||||
it('throws on background &', () => {
|
||||
expect(() => parseScript('sleep 1 &')).toThrow()
|
||||
})
|
||||
})
|
||||
@@ -1,132 +0,0 @@
|
||||
import { parse as tokenize } from 'shell-quote'
|
||||
|
||||
import type { Cmd, Node, Redirect } from './types'
|
||||
|
||||
type Token =
|
||||
| string
|
||||
| { op: string; pattern?: string }
|
||||
| { pattern: string }
|
||||
| { comment: string }
|
||||
|
||||
const UNSUPPORTED_OPS = new Set([
|
||||
'(',
|
||||
')',
|
||||
'&',
|
||||
'<',
|
||||
'<<',
|
||||
'<<<',
|
||||
'<(',
|
||||
'>(',
|
||||
'>&',
|
||||
'<&'
|
||||
])
|
||||
|
||||
export function parseScript(src: string, env?: Record<string, string>): Node {
|
||||
const tokens = tokenize(src, env) as Token[]
|
||||
if (tokens.length === 0) {
|
||||
return { type: 'simple', cmd: { argv: [] } }
|
||||
}
|
||||
for (const t of tokens) {
|
||||
if (typeof t === 'object') {
|
||||
if ('pattern' in t && !('op' in t)) {
|
||||
throw new Error(`glob not supported: ${t.pattern}`)
|
||||
}
|
||||
if ('comment' in t) continue
|
||||
if ('op' in t) {
|
||||
const op = t.op
|
||||
if (op === 'glob') {
|
||||
throw new Error(`glob not supported: ${t.pattern ?? ''}`)
|
||||
}
|
||||
if (UNSUPPORTED_OPS.has(op)) {
|
||||
throw new Error(`unsupported operator: ${op}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return foldSeq(tokens)
|
||||
}
|
||||
|
||||
function splitBy(tokens: Token[], ops: string[]): Token[][] {
|
||||
const parts: Token[][] = [[]]
|
||||
for (const t of tokens) {
|
||||
if (typeof t === 'object' && 'op' in t && ops.includes(t.op)) {
|
||||
parts.push([{ op: t.op } as Token], [])
|
||||
} else {
|
||||
parts[parts.length - 1].push(t)
|
||||
}
|
||||
}
|
||||
return parts
|
||||
}
|
||||
|
||||
function foldSeq(tokens: Token[]): Node {
|
||||
const parts = splitBy(tokens, [';'])
|
||||
const segs: Token[][] = []
|
||||
for (let i = 0; i < parts.length; i += 2) segs.push(parts[i])
|
||||
const filtered = segs.filter((s) => s.length > 0)
|
||||
if (filtered.length === 0) return { type: 'simple', cmd: { argv: [] } }
|
||||
let acc = foldLogical(filtered[0])
|
||||
for (let i = 1; i < filtered.length; i++) {
|
||||
acc = { type: 'seq', left: acc, right: foldLogical(filtered[i]) }
|
||||
}
|
||||
return acc
|
||||
}
|
||||
|
||||
function foldLogical(tokens: Token[]): Node {
|
||||
const parts: Array<{ op?: '&&' | '||'; toks: Token[] }> = [{ toks: [] }]
|
||||
for (const t of tokens) {
|
||||
if (
|
||||
typeof t === 'object' &&
|
||||
'op' in t &&
|
||||
(t.op === '&&' || t.op === '||')
|
||||
) {
|
||||
parts.push({ op: t.op, toks: [] })
|
||||
} else {
|
||||
parts[parts.length - 1].toks.push(t)
|
||||
}
|
||||
}
|
||||
let acc = foldPipe(parts[0].toks)
|
||||
for (let i = 1; i < parts.length; i++) {
|
||||
const right = foldPipe(parts[i].toks)
|
||||
acc = { type: parts[i].op === '&&' ? 'and' : 'or', left: acc, right }
|
||||
}
|
||||
return acc
|
||||
}
|
||||
|
||||
function foldPipe(tokens: Token[]): Node {
|
||||
const parts = splitBy(tokens, ['|'])
|
||||
const segs: Token[][] = []
|
||||
for (let i = 0; i < parts.length; i += 2) segs.push(parts[i])
|
||||
const cmds = segs.map(toCmd)
|
||||
if (cmds.length === 1) {
|
||||
return { type: 'simple', cmd: cmds[0] }
|
||||
}
|
||||
const last = cmds[cmds.length - 1]
|
||||
const redirect = last.redirect
|
||||
const pipeCmds = cmds.map((c, i) =>
|
||||
i === cmds.length - 1 ? { ...c, redirect: undefined } : c
|
||||
)
|
||||
return { type: 'pipe', cmds: pipeCmds, redirect }
|
||||
}
|
||||
|
||||
function toCmd(tokens: Token[]): Cmd {
|
||||
const argv: string[] = []
|
||||
let redirect: Redirect | undefined
|
||||
for (let i = 0; i < tokens.length; i++) {
|
||||
const t = tokens[i]
|
||||
if (typeof t === 'string') {
|
||||
argv.push(t)
|
||||
} else if (typeof t === 'object' && 'op' in t) {
|
||||
if (t.op === '>' || t.op === '>>') {
|
||||
const next = tokens[i + 1]
|
||||
if (typeof next !== 'string') {
|
||||
throw new Error(`redirect target missing after ${t.op}`)
|
||||
}
|
||||
redirect = { op: t.op, path: next }
|
||||
i++
|
||||
} else {
|
||||
throw new Error(`unexpected operator in command: ${t.op}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
return { argv, redirect }
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { CommandRegistryImpl, runScript } from './runtime'
|
||||
import type { ExecContext } from './runtime'
|
||||
import { collect, emptyIter, lines, stringIter } from './types'
|
||||
import type { Command } from './types'
|
||||
import { MemoryVFS } from './vfs/memory'
|
||||
|
||||
function setup(): ExecContext & { registry: CommandRegistryImpl } {
|
||||
const registry = new CommandRegistryImpl()
|
||||
const echo: Command = async (ctx) => ({
|
||||
stdout: stringIter(ctx.argv.slice(1).join(' ') + '\n'),
|
||||
exitCode: 0
|
||||
})
|
||||
const cat: Command = async (ctx) => ({ stdout: ctx.stdin, exitCode: 0 })
|
||||
const grep: Command = async (ctx) => {
|
||||
const re = new RegExp(ctx.argv[1])
|
||||
async function* gen(): AsyncIterable<string> {
|
||||
for await (const l of lines(ctx.stdin)) {
|
||||
if (re.test(l)) yield l + '\n'
|
||||
}
|
||||
}
|
||||
return { stdout: gen(), exitCode: 0 }
|
||||
}
|
||||
const fail: Command = async () => ({ stdout: emptyIter(), exitCode: 2 })
|
||||
const count: Command = async (ctx) => {
|
||||
let n = 0
|
||||
for await (const _l of lines(ctx.stdin)) n++
|
||||
return { stdout: stringIter(String(n) + '\n'), exitCode: 0 }
|
||||
}
|
||||
const boom: Command = async () => {
|
||||
throw new Error('kaboom')
|
||||
}
|
||||
registry.register('echo', echo)
|
||||
registry.register('cat', cat)
|
||||
registry.register('grep', grep)
|
||||
registry.register('fail', fail)
|
||||
registry.register('count', count)
|
||||
registry.register('boom', boom)
|
||||
return {
|
||||
registry,
|
||||
vfs: new MemoryVFS(),
|
||||
env: new Map(),
|
||||
cwd: '/'
|
||||
}
|
||||
}
|
||||
|
||||
describe('runScript', () => {
|
||||
it('runs simple command', async () => {
|
||||
const ctx = setup()
|
||||
const r = await runScript('echo hi', ctx)
|
||||
expect(r.exitCode).toBe(0)
|
||||
expect(await collect(r.stdout)).toBe('hi\n')
|
||||
})
|
||||
|
||||
it('pipes through stages', async () => {
|
||||
const ctx = setup()
|
||||
const r = await runScript('echo a | cat | cat', ctx)
|
||||
expect(await collect(r.stdout)).toBe('a\n')
|
||||
})
|
||||
|
||||
it('grep filters piped input', async () => {
|
||||
const ctx = setup()
|
||||
const r = await runScript('echo foo | grep oo', ctx)
|
||||
expect(await collect(r.stdout)).toBe('foo\n')
|
||||
const r2 = await runScript('echo bar | grep oo', ctx)
|
||||
expect(await collect(r2.stdout)).toBe('')
|
||||
})
|
||||
|
||||
it('&& short-circuits on failure', async () => {
|
||||
const ctx = setup()
|
||||
const r = await runScript('fail && echo nope', ctx)
|
||||
expect(r.exitCode).toBe(2)
|
||||
expect(await collect(r.stdout)).toBe('')
|
||||
})
|
||||
|
||||
it('&& runs right on success', async () => {
|
||||
const ctx = setup()
|
||||
const r = await runScript('echo a && echo b', ctx)
|
||||
expect(r.exitCode).toBe(0)
|
||||
expect(await collect(r.stdout)).toBe('a\nb\n')
|
||||
})
|
||||
|
||||
it('|| runs right on failure', async () => {
|
||||
const ctx = setup()
|
||||
const r = await runScript('fail || echo recover', ctx)
|
||||
expect(r.exitCode).toBe(0)
|
||||
expect(await collect(r.stdout)).toContain('recover')
|
||||
})
|
||||
|
||||
it('redirect > writes stdout to vfs', async () => {
|
||||
const ctx = setup()
|
||||
const r = await runScript('echo hello > /out.txt', ctx)
|
||||
expect(r.exitCode).toBe(0)
|
||||
expect(await collect(r.stdout)).toBe('')
|
||||
expect(await ctx.vfs.read('/out.txt')).toBe('hello\n')
|
||||
})
|
||||
|
||||
it('redirect >> appends', async () => {
|
||||
const ctx = setup()
|
||||
await runScript('echo a >> /log', ctx)
|
||||
await runScript('echo b >> /log', ctx)
|
||||
expect(await ctx.vfs.read('/log')).toBe('a\nb\n')
|
||||
})
|
||||
|
||||
it('pipe redirect writes final stage output', async () => {
|
||||
const ctx = setup()
|
||||
await runScript('echo foo | cat > /p.txt', ctx)
|
||||
expect(await ctx.vfs.read('/p.txt')).toBe('foo\n')
|
||||
})
|
||||
|
||||
it('unknown command returns 127', async () => {
|
||||
const ctx = setup()
|
||||
const r = await runScript('notreal', ctx)
|
||||
expect(r.exitCode).toBe(127)
|
||||
expect(r.stderr).toContain('not found')
|
||||
})
|
||||
|
||||
it('throwing command returns 1', async () => {
|
||||
const ctx = setup()
|
||||
const r = await runScript('boom', ctx)
|
||||
expect(r.exitCode).toBe(1)
|
||||
expect(r.stderr).toContain('kaboom')
|
||||
})
|
||||
|
||||
it('pre-aborted signal returns 130', async () => {
|
||||
const ctx = setup()
|
||||
const ac = new AbortController()
|
||||
ac.abort()
|
||||
const r = await runScript('echo hi', { ...ctx, signal: ac.signal })
|
||||
expect(r.exitCode).toBe(130)
|
||||
})
|
||||
|
||||
it('seq runs both sides', async () => {
|
||||
const ctx = setup()
|
||||
const r = await runScript('echo a ; echo b', ctx)
|
||||
expect(await collect(r.stdout)).toBe('a\nb\n')
|
||||
})
|
||||
|
||||
it('count consumes piped lines', async () => {
|
||||
const ctx = setup()
|
||||
const r = await runScript('echo a | count', ctx)
|
||||
expect(await collect(r.stdout)).toBe('1\n')
|
||||
})
|
||||
|
||||
it('parse error returns exit 2', async () => {
|
||||
const ctx = setup()
|
||||
const r = await runScript('echo $(ls)', ctx)
|
||||
expect(r.exitCode).toBe(2)
|
||||
})
|
||||
})
|
||||
@@ -1,214 +0,0 @@
|
||||
import type {
|
||||
Cmd,
|
||||
CmdContext,
|
||||
CmdResult,
|
||||
Command,
|
||||
CommandRegistry,
|
||||
Node,
|
||||
Redirect,
|
||||
VFS
|
||||
} from './types'
|
||||
import { collect, emptyIter } from './types'
|
||||
import { parseScript } from './parser'
|
||||
|
||||
type Resolver = (name: string) => Command | undefined
|
||||
|
||||
export class CommandRegistryImpl implements CommandRegistry {
|
||||
private map = new Map<string, Command>()
|
||||
private resolvers: Resolver[] = []
|
||||
|
||||
get(name: string): Command | undefined {
|
||||
const direct = this.map.get(name)
|
||||
if (direct) return direct
|
||||
for (const r of this.resolvers) {
|
||||
const hit = r(name)
|
||||
if (hit) return hit
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
register(name: string, cmd: Command): void {
|
||||
this.map.set(name, cmd)
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a lookup fallback used when a name isn't in the main registry.
|
||||
* Resolvers are tried in registration order until one returns a handler.
|
||||
*/
|
||||
addResolver(resolver: Resolver): void {
|
||||
this.resolvers.push(resolver)
|
||||
}
|
||||
|
||||
list(): string[] {
|
||||
return [...this.map.keys()].sort()
|
||||
}
|
||||
}
|
||||
|
||||
export interface ExecContext {
|
||||
registry: CommandRegistry
|
||||
vfs: VFS
|
||||
env: Map<string, string>
|
||||
cwd: string
|
||||
signal?: AbortSignal
|
||||
stdin?: AsyncIterable<string>
|
||||
}
|
||||
|
||||
function makeCtx(
|
||||
ctx: ExecContext,
|
||||
argv: string[],
|
||||
stdin: AsyncIterable<string>
|
||||
): CmdContext {
|
||||
return {
|
||||
argv,
|
||||
stdin,
|
||||
env: ctx.env,
|
||||
cwd: ctx.cwd,
|
||||
vfs: ctx.vfs,
|
||||
signal: ctx.signal ?? new AbortController().signal
|
||||
}
|
||||
}
|
||||
|
||||
async function applyRedirect(
|
||||
res: CmdResult,
|
||||
redirect: Redirect,
|
||||
vfs: VFS
|
||||
): Promise<CmdResult> {
|
||||
const data = await collect(res.stdout)
|
||||
if (redirect.op === '>') await vfs.write(redirect.path, data)
|
||||
else await vfs.append(redirect.path, data)
|
||||
return { stdout: emptyIter(), exitCode: res.exitCode, stderr: res.stderr }
|
||||
}
|
||||
|
||||
async function runSimple(
|
||||
cmd: Cmd,
|
||||
ctx: ExecContext,
|
||||
stdin: AsyncIterable<string>
|
||||
): Promise<CmdResult> {
|
||||
if (ctx.signal?.aborted) {
|
||||
return { stdout: emptyIter(), exitCode: 130, stderr: 'aborted' }
|
||||
}
|
||||
const name = cmd.argv[0]
|
||||
const handler = ctx.registry.get(name)
|
||||
if (!handler) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 127,
|
||||
stderr: `${name}: command not found`
|
||||
}
|
||||
}
|
||||
let res: CmdResult
|
||||
try {
|
||||
res = await handler(makeCtx(ctx, cmd.argv, stdin))
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 1,
|
||||
stderr: err instanceof Error ? err.message : String(err)
|
||||
}
|
||||
}
|
||||
if (cmd.redirect) res = await applyRedirect(res, cmd.redirect, ctx.vfs)
|
||||
return res
|
||||
}
|
||||
|
||||
async function runPipe(
|
||||
cmds: Cmd[],
|
||||
ctx: ExecContext,
|
||||
stdin: AsyncIterable<string>,
|
||||
redirect: Redirect | undefined
|
||||
): Promise<CmdResult> {
|
||||
let cur = stdin
|
||||
let exit = 0
|
||||
let stderr: string | undefined
|
||||
for (let i = 0; i < cmds.length; i++) {
|
||||
const last = i === cmds.length - 1
|
||||
const cmd = cmds[i]
|
||||
const inner = last ? cmd : { ...cmd, redirect: undefined }
|
||||
const res = await runSimple(inner, ctx, cur)
|
||||
cur = res.stdout
|
||||
exit = res.exitCode
|
||||
if (res.stderr) stderr = res.stderr
|
||||
if (ctx.signal?.aborted) {
|
||||
return { stdout: emptyIter(), exitCode: 130, stderr: 'aborted' }
|
||||
}
|
||||
}
|
||||
let result: CmdResult = { stdout: cur, exitCode: exit, stderr }
|
||||
if (redirect) result = await applyRedirect(result, redirect, ctx.vfs)
|
||||
return result
|
||||
}
|
||||
|
||||
async function runNode(node: Node, ctx: ExecContext): Promise<CmdResult> {
|
||||
const stdin = ctx.stdin ?? emptyIter()
|
||||
if (ctx.signal?.aborted) {
|
||||
return { stdout: emptyIter(), exitCode: 130, stderr: 'aborted' }
|
||||
}
|
||||
if (node.type === 'simple') return runSimple(node.cmd, ctx, stdin)
|
||||
if (node.type === 'pipe') return runPipe(node.cmds, ctx, stdin, node.redirect)
|
||||
|
||||
const left = await runNode(node.left, ctx)
|
||||
const leftOut = await collect(left.stdout)
|
||||
if (node.type === 'and' && left.exitCode !== 0) {
|
||||
return {
|
||||
stdout: toIter(leftOut),
|
||||
exitCode: left.exitCode,
|
||||
stderr: left.stderr
|
||||
}
|
||||
}
|
||||
if (node.type === 'or' && left.exitCode === 0) {
|
||||
return { stdout: toIter(leftOut), exitCode: 0, stderr: left.stderr }
|
||||
}
|
||||
const right = await runNode(node.right, ctx)
|
||||
const rightOut = await collect(right.stdout)
|
||||
const combined = leftOut + rightOut
|
||||
return {
|
||||
stdout: toIter(combined),
|
||||
exitCode: right.exitCode,
|
||||
stderr: right.stderr ?? left.stderr
|
||||
}
|
||||
}
|
||||
|
||||
async function* toIter(s: string): AsyncIterable<string> {
|
||||
if (s.length > 0) yield s
|
||||
}
|
||||
|
||||
/**
|
||||
* Commands whose argument list is taken literally (unparsed), so embedded
|
||||
* quotes, newlines, semicolons, and pipes pass through to the command.
|
||||
* This lets the user (or LLM) write raw JS with no shell escaping.
|
||||
*/
|
||||
const RAW_ARG_COMMANDS = ['run-js', 'describe']
|
||||
|
||||
/**
|
||||
* If the input matches `<cmd> <rest>` where <cmd> is a raw-arg command,
|
||||
* bypass shell-quote and build a single simple node by hand. This avoids
|
||||
* escaping hell for run-js and describe.
|
||||
*/
|
||||
function tryRawArgShortcut(src: string): Node | null {
|
||||
const trimmed = src.replace(/^\s+/, '')
|
||||
for (const c of RAW_ARG_COMMANDS) {
|
||||
if (trimmed.startsWith(c + ' ') || trimmed === c) {
|
||||
const rest = trimmed.slice(c.length).replace(/^\s+/, '')
|
||||
if (!rest) return null // let normal parser handle usage
|
||||
return { type: 'simple', cmd: { argv: [c, rest], redirect: undefined } }
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
export async function runScript(
|
||||
src: string,
|
||||
ctx: ExecContext
|
||||
): Promise<CmdResult> {
|
||||
const shortcut = tryRawArgShortcut(src)
|
||||
if (shortcut) return runNode(shortcut, ctx)
|
||||
let node: Node
|
||||
try {
|
||||
node = parseScript(src, Object.fromEntries(ctx.env))
|
||||
} catch (err) {
|
||||
return {
|
||||
stdout: emptyIter(),
|
||||
exitCode: 2,
|
||||
stderr: err instanceof Error ? err.message : String(err)
|
||||
}
|
||||
}
|
||||
return runNode(node, ctx)
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
export interface Redirect {
|
||||
op: '>' | '>>'
|
||||
path: string
|
||||
}
|
||||
|
||||
export interface Cmd {
|
||||
argv: string[]
|
||||
redirect?: Redirect
|
||||
}
|
||||
|
||||
export type Node =
|
||||
| { type: 'pipe'; cmds: Cmd[]; redirect?: Redirect }
|
||||
| { type: 'and' | 'or' | 'seq'; left: Node; right: Node }
|
||||
| { type: 'simple'; cmd: Cmd }
|
||||
|
||||
export interface VFS {
|
||||
list(path: string): Promise<VfsEntry[]>
|
||||
read(path: string): Promise<string>
|
||||
write(path: string, data: string): Promise<void>
|
||||
append(path: string, data: string): Promise<void>
|
||||
delete(path: string): Promise<void>
|
||||
move(src: string, dest: string): Promise<void>
|
||||
exists(path: string): Promise<boolean>
|
||||
}
|
||||
|
||||
export interface VfsEntry {
|
||||
name: string
|
||||
path: string
|
||||
type: 'file' | 'dir'
|
||||
size?: number
|
||||
modified?: number
|
||||
}
|
||||
|
||||
export interface CmdContext {
|
||||
argv: string[]
|
||||
stdin: AsyncIterable<string>
|
||||
env: Map<string, string>
|
||||
cwd: string
|
||||
vfs: VFS
|
||||
signal: AbortSignal
|
||||
}
|
||||
|
||||
export interface CmdResult {
|
||||
stdout: AsyncIterable<string>
|
||||
exitCode: number
|
||||
stderr?: string
|
||||
}
|
||||
|
||||
export type Command = (ctx: CmdContext) => Promise<CmdResult>
|
||||
|
||||
export interface CommandRegistry {
|
||||
get(name: string): Command | undefined
|
||||
register(name: string, cmd: Command): void
|
||||
list(): string[]
|
||||
}
|
||||
|
||||
export async function* emptyIter(): AsyncIterable<string> {
|
||||
// no-op
|
||||
}
|
||||
|
||||
export async function* stringIter(s: string): AsyncIterable<string> {
|
||||
if (s.length > 0) yield s
|
||||
}
|
||||
|
||||
export async function collect(iter: AsyncIterable<string>): Promise<string> {
|
||||
const parts: string[] = []
|
||||
for await (const chunk of iter) parts.push(chunk)
|
||||
return parts.join('')
|
||||
}
|
||||
|
||||
export async function* lines(
|
||||
iter: AsyncIterable<string>
|
||||
): AsyncIterable<string> {
|
||||
let buf = ''
|
||||
for await (const chunk of iter) {
|
||||
buf += chunk
|
||||
let nl: number
|
||||
while ((nl = buf.indexOf('\n')) >= 0) {
|
||||
yield buf.slice(0, nl)
|
||||
buf = buf.slice(nl + 1)
|
||||
}
|
||||
}
|
||||
if (buf.length > 0) yield buf
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { MemoryVFS } from './memory'
|
||||
|
||||
describe('MemoryVFS', () => {
|
||||
it('write + read roundtrip', async () => {
|
||||
const fs = new MemoryVFS()
|
||||
await fs.write('/a.txt', 'hello')
|
||||
expect(await fs.read('/a.txt')).toBe('hello')
|
||||
})
|
||||
|
||||
it('list direct children', async () => {
|
||||
const fs = new MemoryVFS()
|
||||
await fs.write('/dir/a.txt', '1')
|
||||
await fs.write('/dir/b.txt', '2')
|
||||
await fs.write('/dir/sub/c.txt', '3')
|
||||
const entries = await fs.list('/dir')
|
||||
expect(entries.map((e) => e.name)).toEqual(['a.txt', 'b.txt', 'sub'])
|
||||
expect(entries.find((e) => e.name === 'sub')?.type).toBe('dir')
|
||||
expect(entries.find((e) => e.name === 'a.txt')?.type).toBe('file')
|
||||
})
|
||||
|
||||
it('list root', async () => {
|
||||
const fs = new MemoryVFS()
|
||||
await fs.write('/foo.txt', 'x')
|
||||
const entries = await fs.list('/')
|
||||
expect(entries.map((e) => e.name)).toEqual(['foo.txt'])
|
||||
})
|
||||
|
||||
it('append', async () => {
|
||||
const fs = new MemoryVFS()
|
||||
await fs.append('/log', 'a\n')
|
||||
await fs.append('/log', 'b\n')
|
||||
expect(await fs.read('/log')).toBe('a\nb\n')
|
||||
})
|
||||
|
||||
it('move', async () => {
|
||||
const fs = new MemoryVFS()
|
||||
await fs.write('/from', 'data')
|
||||
await fs.move('/from', '/to')
|
||||
expect(await fs.exists('/from')).toBe(false)
|
||||
expect(await fs.read('/to')).toBe('data')
|
||||
})
|
||||
|
||||
it('delete', async () => {
|
||||
const fs = new MemoryVFS()
|
||||
await fs.write('/a', 'x')
|
||||
await fs.delete('/a')
|
||||
expect(await fs.exists('/a')).toBe(false)
|
||||
})
|
||||
|
||||
it('normalizes . and ..', async () => {
|
||||
const fs = new MemoryVFS()
|
||||
await fs.write('/a/b/../c.txt', 'v')
|
||||
expect(await fs.read('/a/c.txt')).toBe('v')
|
||||
})
|
||||
|
||||
it('throws on missing file', async () => {
|
||||
const fs = new MemoryVFS()
|
||||
await expect(fs.read('/nope')).rejects.toThrow(/no such/)
|
||||
})
|
||||
|
||||
it('throws listing nonexistent dir', async () => {
|
||||
const fs = new MemoryVFS()
|
||||
await expect(fs.list('/nope')).rejects.toThrow(/no such/)
|
||||
})
|
||||
|
||||
it('exists returns true for dir prefixes', async () => {
|
||||
const fs = new MemoryVFS()
|
||||
await fs.write('/dir/a', '1')
|
||||
expect(await fs.exists('/dir')).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -1,86 +0,0 @@
|
||||
import type { VFS, VfsEntry } from '../types'
|
||||
|
||||
function normalize(path: string): string {
|
||||
if (!path.startsWith('/')) path = '/' + path
|
||||
const parts = path.split('/').filter((p) => p.length > 0)
|
||||
const stack: string[] = []
|
||||
for (const p of parts) {
|
||||
if (p === '.') continue
|
||||
if (p === '..') stack.pop()
|
||||
else stack.push(p)
|
||||
}
|
||||
return '/' + stack.join('/')
|
||||
}
|
||||
|
||||
export class MemoryVFS implements VFS {
|
||||
private files = new Map<string, string>()
|
||||
|
||||
async list(path: string): Promise<VfsEntry[]> {
|
||||
const dir = normalize(path)
|
||||
const entries = new Map<string, VfsEntry>()
|
||||
let found = dir === '/'
|
||||
for (const key of this.files.keys()) {
|
||||
if (!key.startsWith(dir === '/' ? '/' : dir + '/') && key !== dir)
|
||||
continue
|
||||
if (key === dir) continue
|
||||
const rest = key.slice(dir === '/' ? 1 : dir.length + 1)
|
||||
const slash = rest.indexOf('/')
|
||||
if (slash === -1) {
|
||||
entries.set(rest, {
|
||||
name: rest,
|
||||
path: key,
|
||||
type: 'file',
|
||||
size: this.files.get(key)!.length
|
||||
})
|
||||
} else {
|
||||
const name = rest.slice(0, slash)
|
||||
entries.set(name, { name, path: dir + '/' + name, type: 'dir' })
|
||||
}
|
||||
found = true
|
||||
}
|
||||
if (!found && dir !== '/') {
|
||||
throw new Error(`no such file or directory: ${dir}`)
|
||||
}
|
||||
return [...entries.values()].sort((a, b) => a.name.localeCompare(b.name))
|
||||
}
|
||||
|
||||
async read(path: string): Promise<string> {
|
||||
const p = normalize(path)
|
||||
const data = this.files.get(p)
|
||||
if (data === undefined) throw new Error(`no such file or directory: ${p}`)
|
||||
return data
|
||||
}
|
||||
|
||||
async write(path: string, data: string): Promise<void> {
|
||||
this.files.set(normalize(path), data)
|
||||
}
|
||||
|
||||
async append(path: string, data: string): Promise<void> {
|
||||
const p = normalize(path)
|
||||
this.files.set(p, (this.files.get(p) ?? '') + data)
|
||||
}
|
||||
|
||||
async delete(path: string): Promise<void> {
|
||||
const p = normalize(path)
|
||||
if (!this.files.delete(p)) {
|
||||
throw new Error(`no such file or directory: ${p}`)
|
||||
}
|
||||
}
|
||||
|
||||
async move(src: string, dest: string): Promise<void> {
|
||||
const s = normalize(src)
|
||||
const d = normalize(dest)
|
||||
const data = this.files.get(s)
|
||||
if (data === undefined) throw new Error(`no such file or directory: ${s}`)
|
||||
this.files.delete(s)
|
||||
this.files.set(d, data)
|
||||
}
|
||||
|
||||
async exists(path: string): Promise<boolean> {
|
||||
const p = normalize(path)
|
||||
if (this.files.has(p)) return true
|
||||
const prefix = p === '/' ? '/' : p + '/'
|
||||
for (const k of this.files.keys()) if (k.startsWith(prefix)) return true
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { MemoryVFS } from './memory'
|
||||
import { MountedVFS } from './mount'
|
||||
|
||||
function setup() {
|
||||
const tmp = new MemoryVFS()
|
||||
const wf = new MemoryVFS()
|
||||
const fs = new MountedVFS({
|
||||
'/tmp': tmp,
|
||||
'/workflows': wf
|
||||
})
|
||||
return { fs, tmp, wf }
|
||||
}
|
||||
|
||||
describe('MountedVFS', () => {
|
||||
it('list / shows mount roots', async () => {
|
||||
const { fs } = setup()
|
||||
const entries = await fs.list('/')
|
||||
expect(entries.map((e) => e.name).sort()).toEqual(['tmp', 'workflows'])
|
||||
expect(entries.every((e) => e.type === 'dir')).toBe(true)
|
||||
})
|
||||
|
||||
it('dispatches read to correct mount', async () => {
|
||||
const { fs, tmp } = setup()
|
||||
await tmp.write('/a.txt', 'hello')
|
||||
expect(await fs.read('/tmp/a.txt')).toBe('hello')
|
||||
})
|
||||
|
||||
it('write routes to mount and list reflects prefix', async () => {
|
||||
const { fs } = setup()
|
||||
await fs.write('/workflows/foo.json', '{}')
|
||||
const entries = await fs.list('/workflows')
|
||||
expect(entries.map((e) => e.name)).toEqual(['foo.json'])
|
||||
expect(entries[0].path).toBe('/workflows/foo.json')
|
||||
})
|
||||
|
||||
it('move within same mount', async () => {
|
||||
const { fs } = setup()
|
||||
await fs.write('/tmp/a', 'x')
|
||||
await fs.move('/tmp/a', '/tmp/b')
|
||||
expect(await fs.exists('/tmp/a')).toBe(false)
|
||||
expect(await fs.read('/tmp/b')).toBe('x')
|
||||
})
|
||||
|
||||
it('move across mounts copies + deletes', async () => {
|
||||
const { fs } = setup()
|
||||
await fs.write('/tmp/a', 'x')
|
||||
await fs.move('/tmp/a', '/workflows/a')
|
||||
expect(await fs.exists('/tmp/a')).toBe(false)
|
||||
expect(await fs.read('/workflows/a')).toBe('x')
|
||||
})
|
||||
|
||||
it('throws on unmounted path', async () => {
|
||||
const { fs } = setup()
|
||||
await expect(fs.read('/unknown/x')).rejects.toThrow(/no mount/)
|
||||
})
|
||||
|
||||
it('exists returns false for unmounted', async () => {
|
||||
const { fs } = setup()
|
||||
expect(await fs.exists('/unknown/x')).toBe(false)
|
||||
})
|
||||
|
||||
it('normalizes .. in paths', async () => {
|
||||
const { fs } = setup()
|
||||
await fs.write('/tmp/a', 'x')
|
||||
expect(await fs.read('/tmp/sub/../a')).toBe('x')
|
||||
})
|
||||
})
|
||||
@@ -1,124 +0,0 @@
|
||||
import type { VFS, VfsEntry } from '../types'
|
||||
|
||||
interface Mount {
|
||||
prefix: string
|
||||
fs: VFS
|
||||
}
|
||||
|
||||
function normalize(path: string): string {
|
||||
if (!path.startsWith('/')) path = '/' + path
|
||||
const parts = path.split('/').filter((p) => p.length > 0)
|
||||
const stack: string[] = []
|
||||
for (const p of parts) {
|
||||
if (p === '.') continue
|
||||
if (p === '..') stack.pop()
|
||||
else stack.push(p)
|
||||
}
|
||||
return '/' + stack.join('/')
|
||||
}
|
||||
|
||||
export class MountedVFS implements VFS {
|
||||
private mounts: Mount[]
|
||||
|
||||
constructor(mounts: Record<string, VFS>) {
|
||||
this.mounts = Object.entries(mounts)
|
||||
.map(([prefix, fs]) => ({
|
||||
prefix: prefix === '/' ? '' : prefix.replace(/\/$/, ''),
|
||||
fs
|
||||
}))
|
||||
.sort((a, b) => b.prefix.length - a.prefix.length)
|
||||
}
|
||||
|
||||
private resolve(path: string): { mount: Mount; relative: string } {
|
||||
const abs = normalize(path)
|
||||
for (const mount of this.mounts) {
|
||||
if (mount.prefix === '') {
|
||||
return { mount, relative: abs }
|
||||
}
|
||||
if (abs === mount.prefix) {
|
||||
return { mount, relative: '/' }
|
||||
}
|
||||
if (abs.startsWith(mount.prefix + '/')) {
|
||||
return { mount, relative: abs.slice(mount.prefix.length) || '/' }
|
||||
}
|
||||
}
|
||||
throw new Error(`no mount for path: ${abs}`)
|
||||
}
|
||||
|
||||
private decorate(mount: Mount, entries: VfsEntry[]): VfsEntry[] {
|
||||
if (mount.prefix === '') return entries
|
||||
return entries.map((e) => ({
|
||||
...e,
|
||||
path: mount.prefix + (e.path.startsWith('/') ? e.path : '/' + e.path)
|
||||
}))
|
||||
}
|
||||
|
||||
async list(path: string): Promise<VfsEntry[]> {
|
||||
const abs = normalize(path)
|
||||
if (abs === '/') {
|
||||
const topMounts = this.mounts
|
||||
.filter((m) => m.prefix !== '')
|
||||
.map((m) => m.prefix)
|
||||
const roots = new Set<string>()
|
||||
for (const p of topMounts) {
|
||||
const name = p.split('/').filter(Boolean)[0]
|
||||
if (name) roots.add(name)
|
||||
}
|
||||
const hasRoot = this.mounts.some((m) => m.prefix === '')
|
||||
if (hasRoot) {
|
||||
const { mount } = this.resolve('/')
|
||||
const rootEntries = await mount.fs.list('/')
|
||||
for (const e of rootEntries) roots.add(e.name.replace(/\/$/, ''))
|
||||
}
|
||||
return [...roots].sort().map((name) => ({
|
||||
name,
|
||||
path: '/' + name,
|
||||
type: 'dir'
|
||||
}))
|
||||
}
|
||||
const { mount, relative } = this.resolve(abs)
|
||||
const entries = await mount.fs.list(relative)
|
||||
return this.decorate(mount, entries)
|
||||
}
|
||||
|
||||
async read(path: string): Promise<string> {
|
||||
const { mount, relative } = this.resolve(path)
|
||||
return mount.fs.read(relative)
|
||||
}
|
||||
|
||||
async write(path: string, data: string): Promise<void> {
|
||||
const { mount, relative } = this.resolve(path)
|
||||
return mount.fs.write(relative, data)
|
||||
}
|
||||
|
||||
async append(path: string, data: string): Promise<void> {
|
||||
const { mount, relative } = this.resolve(path)
|
||||
return mount.fs.append(relative, data)
|
||||
}
|
||||
|
||||
async delete(path: string): Promise<void> {
|
||||
const { mount, relative } = this.resolve(path)
|
||||
return mount.fs.delete(relative)
|
||||
}
|
||||
|
||||
async move(src: string, dest: string): Promise<void> {
|
||||
const s = this.resolve(src)
|
||||
const d = this.resolve(dest)
|
||||
if (s.mount !== d.mount) {
|
||||
const data = await s.mount.fs.read(s.relative)
|
||||
await d.mount.fs.write(d.relative, data)
|
||||
await s.mount.fs.delete(s.relative)
|
||||
return
|
||||
}
|
||||
return s.mount.fs.move(s.relative, d.relative)
|
||||
}
|
||||
|
||||
async exists(path: string): Promise<boolean> {
|
||||
try {
|
||||
const { mount, relative } = this.resolve(path)
|
||||
return mount.fs.exists(relative)
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
vi.mock('@/scripts/api', () => ({
|
||||
api: {
|
||||
listUserDataFullInfo: vi.fn(),
|
||||
getUserData: vi.fn(),
|
||||
storeUserData: vi.fn(),
|
||||
deleteUserData: vi.fn(),
|
||||
moveUserData: vi.fn()
|
||||
}
|
||||
}))
|
||||
|
||||
import { api } from '@/scripts/api'
|
||||
|
||||
import { UserdataVFS } from './userdata'
|
||||
|
||||
const mocked = vi.mocked(api)
|
||||
|
||||
function respOk(body = ''): Response {
|
||||
return new Response(body, { status: 200 })
|
||||
}
|
||||
|
||||
describe('UserdataVFS', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
it('list returns files under the root', async () => {
|
||||
mocked.listUserDataFullInfo.mockResolvedValue([
|
||||
{ path: 'workflows/a.json', size: 10, modified: 1 },
|
||||
{ path: 'workflows/b.json', size: 20, modified: 2 }
|
||||
])
|
||||
const fs = new UserdataVFS('workflows')
|
||||
const entries = await fs.list('/')
|
||||
expect(mocked.listUserDataFullInfo).toHaveBeenCalledWith('workflows')
|
||||
expect(entries.map((e) => e.name)).toEqual(['a.json', 'b.json'])
|
||||
expect(entries[0].type).toBe('file')
|
||||
})
|
||||
|
||||
it('list infers subdirs', async () => {
|
||||
mocked.listUserDataFullInfo.mockResolvedValue([
|
||||
{ path: 'workflows/a.json', size: 10, modified: 1 },
|
||||
{ path: 'workflows/sub/b.json', size: 20, modified: 2 }
|
||||
])
|
||||
const fs = new UserdataVFS('workflows')
|
||||
const entries = await fs.list('/')
|
||||
expect(entries.map((e) => e.name).sort()).toEqual(['a.json', 'sub'])
|
||||
expect(entries.find((e) => e.name === 'sub')?.type).toBe('dir')
|
||||
})
|
||||
|
||||
it('read returns body text', async () => {
|
||||
mocked.getUserData.mockResolvedValue(respOk('hello'))
|
||||
const fs = new UserdataVFS('workflows')
|
||||
expect(await fs.read('/a.json')).toBe('hello')
|
||||
expect(mocked.getUserData).toHaveBeenCalledWith('workflows/a.json')
|
||||
})
|
||||
|
||||
it('write POSTs via storeUserData', async () => {
|
||||
mocked.storeUserData.mockResolvedValue(respOk())
|
||||
const fs = new UserdataVFS('workflows')
|
||||
await fs.write('/a.json', '{}')
|
||||
expect(mocked.storeUserData).toHaveBeenCalledWith(
|
||||
'workflows/a.json',
|
||||
'{}',
|
||||
expect.objectContaining({ stringify: false })
|
||||
)
|
||||
})
|
||||
|
||||
it('delete calls deleteUserData', async () => {
|
||||
mocked.deleteUserData.mockResolvedValue(respOk())
|
||||
const fs = new UserdataVFS('workflows')
|
||||
await fs.delete('/a.json')
|
||||
expect(mocked.deleteUserData).toHaveBeenCalledWith('workflows/a.json')
|
||||
})
|
||||
|
||||
it('move calls moveUserData', async () => {
|
||||
mocked.moveUserData.mockResolvedValue(respOk())
|
||||
const fs = new UserdataVFS('workflows')
|
||||
await fs.move('/a.json', '/b.json')
|
||||
expect(mocked.moveUserData).toHaveBeenCalledWith(
|
||||
'workflows/a.json',
|
||||
'workflows/b.json',
|
||||
{ overwrite: false }
|
||||
)
|
||||
})
|
||||
|
||||
it('read throws on non-ok', async () => {
|
||||
mocked.getUserData.mockResolvedValue(new Response('no', { status: 404 }))
|
||||
const fs = new UserdataVFS('workflows')
|
||||
await expect(fs.read('/x')).rejects.toThrow(/read failed/)
|
||||
})
|
||||
|
||||
it('empty root lists from user root', async () => {
|
||||
mocked.listUserDataFullInfo.mockResolvedValue([
|
||||
{ path: 'settings.json', size: 5, modified: 1 }
|
||||
])
|
||||
const fs = new UserdataVFS('')
|
||||
const entries = await fs.list('/')
|
||||
expect(entries[0].name).toBe('settings.json')
|
||||
})
|
||||
})
|
||||
@@ -1,105 +0,0 @@
|
||||
import { api } from '@/scripts/api'
|
||||
|
||||
import type { VFS, VfsEntry } from '../types'
|
||||
|
||||
function stripLead(p: string): string {
|
||||
return p.replace(/^\/+/, '')
|
||||
}
|
||||
|
||||
function joinRoot(root: string, rel: string): string {
|
||||
const base = root.replace(/^\/+|\/+$/g, '')
|
||||
const suffix = stripLead(rel)
|
||||
if (!suffix || suffix === '/') return base
|
||||
return base ? `${base}/${suffix}` : suffix
|
||||
}
|
||||
|
||||
export class UserdataVFS implements VFS {
|
||||
constructor(private root: string = 'workflows') {}
|
||||
|
||||
private toRemote(rel: string): string {
|
||||
return joinRoot(this.root, rel)
|
||||
}
|
||||
|
||||
async list(path: string): Promise<VfsEntry[]> {
|
||||
const prefix = this.toRemote(path)
|
||||
const infos = await api.listUserDataFullInfo(prefix || '.')
|
||||
const seen = new Map<string, VfsEntry>()
|
||||
const prefixSlash = prefix ? prefix + '/' : ''
|
||||
for (const info of infos) {
|
||||
const rest = info.path.startsWith(prefixSlash)
|
||||
? info.path.slice(prefixSlash.length)
|
||||
: info.path
|
||||
if (!rest) continue
|
||||
const slash = rest.indexOf('/')
|
||||
if (slash === -1) {
|
||||
seen.set(rest, {
|
||||
name: rest,
|
||||
path: '/' + info.path,
|
||||
type: 'file',
|
||||
size: info.size,
|
||||
modified: info.modified
|
||||
})
|
||||
} else {
|
||||
const name = rest.slice(0, slash)
|
||||
if (!seen.has(name)) {
|
||||
seen.set(name, {
|
||||
name,
|
||||
path: '/' + (prefix ? prefix + '/' : '') + name,
|
||||
type: 'dir'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
return [...seen.values()].sort((a, b) => a.name.localeCompare(b.name))
|
||||
}
|
||||
|
||||
async read(path: string): Promise<string> {
|
||||
const resp = await api.getUserData(this.toRemote(path))
|
||||
if (!resp.ok) throw new Error(`read failed: ${resp.status} ${path}`)
|
||||
return resp.text()
|
||||
}
|
||||
|
||||
async write(path: string, data: string): Promise<void> {
|
||||
const resp = await api.storeUserData(this.toRemote(path), data, {
|
||||
overwrite: true,
|
||||
stringify: false,
|
||||
throwOnError: false
|
||||
})
|
||||
if (!resp.ok) {
|
||||
throw new Error(`write failed: ${resp.status} ${path}`)
|
||||
}
|
||||
}
|
||||
|
||||
async append(path: string, data: string): Promise<void> {
|
||||
let current = ''
|
||||
try {
|
||||
current = await this.read(path)
|
||||
} catch {
|
||||
current = ''
|
||||
}
|
||||
return this.write(path, current + data)
|
||||
}
|
||||
|
||||
async delete(path: string): Promise<void> {
|
||||
const resp = await api.deleteUserData(this.toRemote(path))
|
||||
if (!resp.ok && resp.status !== 404) {
|
||||
throw new Error(`delete failed: ${resp.status} ${path}`)
|
||||
}
|
||||
}
|
||||
|
||||
async move(src: string, dest: string): Promise<void> {
|
||||
const resp = await api.moveUserData(
|
||||
this.toRemote(src),
|
||||
this.toRemote(dest),
|
||||
{ overwrite: false }
|
||||
)
|
||||
if (!resp.ok) {
|
||||
throw new Error(`move failed: ${resp.status} ${src} -> ${dest}`)
|
||||
}
|
||||
}
|
||||
|
||||
async exists(path: string): Promise<boolean> {
|
||||
const resp = await api.getUserData(this.toRemote(path), { method: 'HEAD' })
|
||||
return resp.ok
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import { beforeEach, describe, expect, it } from 'vitest'
|
||||
|
||||
import type { IngestedAsset } from './agentStore'
|
||||
import { useAgentStore } from './agentStore'
|
||||
|
||||
function fakeAsset(overrides: Partial<IngestedAsset> = {}): IngestedAsset {
|
||||
return {
|
||||
id: crypto.randomUUID(),
|
||||
name: 'a.png',
|
||||
path: '/input/a.png',
|
||||
mime: 'image/png',
|
||||
size: 10,
|
||||
...overrides
|
||||
}
|
||||
}
|
||||
|
||||
describe('useAgentStore', () => {
|
||||
beforeEach(() => {
|
||||
setActivePinia(createPinia())
|
||||
localStorage.clear()
|
||||
})
|
||||
|
||||
it('starts closed with no messages', () => {
|
||||
const s = useAgentStore()
|
||||
expect(s.isOpen).toBe(false)
|
||||
expect(s.messages).toEqual([])
|
||||
expect(s.hasMessages).toBe(false)
|
||||
})
|
||||
|
||||
it('toggle flips open state', () => {
|
||||
const s = useAgentStore()
|
||||
s.toggle()
|
||||
expect(s.isOpen).toBe(true)
|
||||
s.toggle()
|
||||
expect(s.isOpen).toBe(false)
|
||||
})
|
||||
|
||||
it('adds message with generated id and timestamp', () => {
|
||||
const s = useAgentStore()
|
||||
const m = s.addMessage({ role: 'user', text: 'hi' })
|
||||
expect(m.id).toMatch(/[0-9a-f-]{36}/)
|
||||
expect(m.createdAt).toBeGreaterThan(0)
|
||||
expect(s.messages).toHaveLength(1)
|
||||
expect(s.hasMessages).toBe(true)
|
||||
})
|
||||
|
||||
it('increments unread for assistant messages while closed', () => {
|
||||
const s = useAgentStore()
|
||||
s.addMessage({ role: 'assistant', text: 'reply' })
|
||||
expect(s.unreadCount).toBe(1)
|
||||
s.addMessage({ role: 'user', text: 'mine' })
|
||||
expect(s.unreadCount).toBe(1)
|
||||
})
|
||||
|
||||
it('does not increment unread while open', () => {
|
||||
const s = useAgentStore()
|
||||
s.open()
|
||||
s.addMessage({ role: 'assistant', text: 'reply' })
|
||||
expect(s.unreadCount).toBe(0)
|
||||
})
|
||||
|
||||
it('open resets unread', () => {
|
||||
const s = useAgentStore()
|
||||
s.addMessage({ role: 'assistant', text: 'reply' })
|
||||
expect(s.unreadCount).toBe(1)
|
||||
s.open()
|
||||
expect(s.unreadCount).toBe(0)
|
||||
})
|
||||
|
||||
it('clearMessages empties history', () => {
|
||||
const s = useAgentStore()
|
||||
s.addMessage({ role: 'user', text: 'hi' })
|
||||
s.clearMessages()
|
||||
expect(s.messages).toEqual([])
|
||||
})
|
||||
|
||||
it('pending assets add / consume / remove', () => {
|
||||
const s = useAgentStore()
|
||||
const a = fakeAsset({ id: 'a' })
|
||||
const b = fakeAsset({ id: 'b' })
|
||||
s.addPendingAsset(a)
|
||||
s.addPendingAsset(b)
|
||||
s.removePendingAsset('a')
|
||||
expect(s.pendingAssets.map((x) => x.id)).toEqual(['b'])
|
||||
const consumed = s.consumePendingAssets()
|
||||
expect(consumed.map((x) => x.id)).toEqual(['b'])
|
||||
expect(s.pendingAssets).toEqual([])
|
||||
})
|
||||
|
||||
it('fabPosition persists via localStorage', async () => {
|
||||
const s = useAgentStore()
|
||||
s.fabPosition = { x: 42, y: 99 }
|
||||
await new Promise((r) => setTimeout(r, 0))
|
||||
const raw = localStorage.getItem('Comfy.Agent.FabPosition')
|
||||
expect(raw).toBeTruthy()
|
||||
expect(JSON.parse(raw!)).toEqual({ x: 42, y: 99 })
|
||||
})
|
||||
})
|
||||
@@ -1,175 +0,0 @@
|
||||
import { useLocalStorage } from '@vueuse/core'
|
||||
import { useIDBKeyval } from '@vueuse/integrations/useIDBKeyval'
|
||||
import { defineStore } from 'pinia'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
|
||||
import { log } from '../services/logger'
|
||||
|
||||
type AgentMessageRole = 'user' | 'assistant' | 'system'
|
||||
|
||||
export interface IngestedAsset {
|
||||
id: string
|
||||
name: string
|
||||
path: string
|
||||
mime: string
|
||||
size: number
|
||||
previewUrl?: string
|
||||
}
|
||||
|
||||
interface ToolMessageMeta {
|
||||
script: string
|
||||
stdout: string
|
||||
stderr?: string
|
||||
exitCode: number
|
||||
}
|
||||
|
||||
interface AgentMessage {
|
||||
id: string
|
||||
role: AgentMessageRole
|
||||
text: string
|
||||
assets?: IngestedAsset[]
|
||||
createdAt: number
|
||||
/**
|
||||
* Present on system messages that record a tool invocation. Lets the
|
||||
* renderer fold/unfold individual tool calls by structure instead of
|
||||
* re-parsing the synthesized text summary.
|
||||
*/
|
||||
tool?: ToolMessageMeta
|
||||
}
|
||||
|
||||
interface FabPosition {
|
||||
x: number
|
||||
y: number
|
||||
}
|
||||
|
||||
// Cap persisted history so IndexedDB stays lean across sessions. Tool
|
||||
// output can get verbose — 300 entries is ~months of casual use.
|
||||
const MAX_PERSISTED_MESSAGES = 300
|
||||
|
||||
export const useAgentStore = defineStore('agent', () => {
|
||||
// IndexedDB-backed: survives reloads, larger quota than localStorage,
|
||||
// doesn't block the main thread like localStorage sync-writes would.
|
||||
// Note: useIDBKeyval populates `data` asynchronously, so the initial
|
||||
// `data.value` is `[]` until the read resolves. We seed `messages` with
|
||||
// whatever's already there (cheap if it's empty) and then hydrate from
|
||||
// the DB once the read completes — only after that do we enable the
|
||||
// write-back watcher, otherwise an early in-memory mutation would
|
||||
// overwrite real persisted history with the empty seed.
|
||||
const persisted = useIDBKeyval<AgentMessage[]>('Comfy.Agent.Messages', [], {
|
||||
shallow: false
|
||||
})
|
||||
const messages = ref<AgentMessage[]>([...(persisted.data.value ?? [])])
|
||||
|
||||
let hydrated = false
|
||||
watch(
|
||||
persisted.isFinished,
|
||||
(done) => {
|
||||
if (!done || hydrated) return
|
||||
hydrated = true
|
||||
const stored = persisted.data.value ?? []
|
||||
// If the user already typed before the IDB read resolved, prepend
|
||||
// stored entries so the new ones come last.
|
||||
if (messages.value.length === 0) {
|
||||
messages.value = [...stored]
|
||||
} else if (stored.length > 0) {
|
||||
messages.value = [...stored, ...messages.value]
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
// Sync in-memory → persisted (truncated to the cap). Deep watch so edits
|
||||
// to message text during streaming also flush. Skip writes until the
|
||||
// initial DB read has settled, otherwise a pre-hydration mutation
|
||||
// clobbers the stored history.
|
||||
watch(
|
||||
messages,
|
||||
(next) => {
|
||||
if (!hydrated) return
|
||||
persisted.data.value = next.slice(-MAX_PERSISTED_MESSAGES)
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
const isOpen = ref(false)
|
||||
const isStreaming = ref(false)
|
||||
const fabPosition = useLocalStorage<FabPosition>('Comfy.Agent.FabPosition', {
|
||||
x: 0,
|
||||
y: 0
|
||||
})
|
||||
const pendingAssets = ref<IngestedAsset[]>([])
|
||||
const unreadCount = ref(0)
|
||||
|
||||
const hasMessages = computed(() => messages.value.length > 0)
|
||||
|
||||
function open(): void {
|
||||
isOpen.value = true
|
||||
unreadCount.value = 0
|
||||
}
|
||||
|
||||
function close(): void {
|
||||
isOpen.value = false
|
||||
}
|
||||
|
||||
function toggle(): void {
|
||||
if (isOpen.value) close()
|
||||
else open()
|
||||
}
|
||||
|
||||
function addMessage(
|
||||
msg: Omit<AgentMessage, 'id' | 'createdAt'>
|
||||
): AgentMessage {
|
||||
const full: AgentMessage = {
|
||||
...msg,
|
||||
id: crypto.randomUUID(),
|
||||
createdAt: Date.now()
|
||||
}
|
||||
messages.value.push(full)
|
||||
// Return the reactive proxy view, NOT the plain object we pushed.
|
||||
// Vue 3's reactivity wraps array items lazily on read access; mutating
|
||||
// `full.text` directly bypasses the proxy's set trap and fails to
|
||||
// trigger watchers (the bug that left assistant streaming silently
|
||||
// invisible in xterm). Read-through the array index to get the
|
||||
// proxy-wrapped reference, so callers' mutations fire reactivity.
|
||||
const reactiveItem = messages.value[messages.value.length - 1]
|
||||
if (!isOpen.value && msg.role !== 'user') unreadCount.value++
|
||||
log({ kind: msg.role, text: msg.text })
|
||||
return reactiveItem
|
||||
}
|
||||
|
||||
function clearMessages(): void {
|
||||
messages.value = []
|
||||
}
|
||||
|
||||
function addPendingAsset(asset: IngestedAsset): void {
|
||||
pendingAssets.value.push(asset)
|
||||
}
|
||||
|
||||
function consumePendingAssets(): IngestedAsset[] {
|
||||
const out = pendingAssets.value
|
||||
pendingAssets.value = []
|
||||
return out
|
||||
}
|
||||
|
||||
function removePendingAsset(id: string): void {
|
||||
pendingAssets.value = pendingAssets.value.filter((a) => a.id !== id)
|
||||
}
|
||||
|
||||
return {
|
||||
messages,
|
||||
isOpen,
|
||||
isStreaming,
|
||||
fabPosition,
|
||||
pendingAssets,
|
||||
unreadCount,
|
||||
hasMessages,
|
||||
open,
|
||||
close,
|
||||
toggle,
|
||||
addMessage,
|
||||
clearMessages,
|
||||
addPendingAsset,
|
||||
consumePendingAssets,
|
||||
removePendingAsset
|
||||
}
|
||||
})
|
||||
@@ -1,113 +0,0 @@
|
||||
<template>
|
||||
<div
|
||||
v-show="positioned"
|
||||
ref="fabEl"
|
||||
class="agent-fab pointer-events-auto fixed select-none"
|
||||
data-testid="agent-fab"
|
||||
:style="[style, { zIndex: 9999 }]"
|
||||
:class="cn(isDragging && 'cursor-grabbing')"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
:aria-label="t('agent.fab.aria')"
|
||||
@click="onClick"
|
||||
@keydown.enter="onClick"
|
||||
@keydown.space.prevent="onClick"
|
||||
@dragover.prevent="onDragOver"
|
||||
@dragleave="isHoveringDrop = false"
|
||||
@drop.prevent="onDrop"
|
||||
>
|
||||
<div
|
||||
class="relative flex items-center justify-center transition-transform hover:scale-110"
|
||||
:class="
|
||||
cn(
|
||||
isHoveringDrop &&
|
||||
'scale-110 drop-shadow-[0_0_8px_rgba(240,255,65,0.9)]'
|
||||
)
|
||||
"
|
||||
>
|
||||
<img
|
||||
src="/assets/images/comfy-logo-single.svg"
|
||||
:alt="t('agent.panel.logoAlt')"
|
||||
class="size-12 drop-shadow-[0_2px_6px_rgba(0,0,0,0.5)] select-none"
|
||||
draggable="false"
|
||||
/>
|
||||
<span
|
||||
v-if="store.unreadCount > 0"
|
||||
class="absolute -top-1 -right-1 flex size-5 items-center justify-center rounded-full bg-electric-400 text-xs font-bold text-charcoal-800"
|
||||
>
|
||||
{{ store.unreadCount > 9 ? '9+' : store.unreadCount }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useDraggable, watchDebounced } from '@vueuse/core'
|
||||
import { clamp } from 'es-toolkit'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
import { cn } from '@comfyorg/tailwind-utils'
|
||||
|
||||
import { useAssetIngest } from '../composables/useAssetIngest'
|
||||
import { useAgentStore } from '../stores/agentStore'
|
||||
|
||||
const { t } = useI18n()
|
||||
const store = useAgentStore()
|
||||
const { ingestFromClipboard } = useAssetIngest()
|
||||
|
||||
const fabEl = ref<HTMLElement | null>(null)
|
||||
const isHoveringDrop = ref(false)
|
||||
const positioned = ref(false)
|
||||
|
||||
const { x, y, style, isDragging } = useDraggable(fabEl, {
|
||||
initialValue: store.fabPosition,
|
||||
containerElement: document.body,
|
||||
preventDefault: true
|
||||
})
|
||||
|
||||
let didDrag = false
|
||||
|
||||
watchDebounced(
|
||||
[x, y],
|
||||
([nx, ny]) => {
|
||||
store.fabPosition = { x: nx, y: ny }
|
||||
},
|
||||
{ debounce: 300 }
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
const el = fabEl.value
|
||||
if (!el) return
|
||||
const w = el.offsetWidth || 48
|
||||
const h = el.offsetHeight || 48
|
||||
if (store.fabPosition.x === 0 && store.fabPosition.y === 0) {
|
||||
x.value = window.innerWidth - w - 24
|
||||
y.value = window.innerHeight - h - 24
|
||||
} else {
|
||||
x.value = clamp(store.fabPosition.x, 0, window.innerWidth - w)
|
||||
y.value = clamp(store.fabPosition.y, 0, window.innerHeight - h)
|
||||
}
|
||||
positioned.value = true
|
||||
})
|
||||
|
||||
function onClick(): void {
|
||||
if (isDragging.value || didDrag) {
|
||||
didDrag = false
|
||||
return
|
||||
}
|
||||
store.toggle()
|
||||
}
|
||||
|
||||
function onDragOver(e: DragEvent): void {
|
||||
isHoveringDrop.value = true
|
||||
if (e.dataTransfer) e.dataTransfer.dropEffect = 'copy'
|
||||
}
|
||||
|
||||
async function onDrop(e: DragEvent): Promise<void> {
|
||||
isHoveringDrop.value = false
|
||||
const results = await ingestFromClipboard(e.dataTransfer)
|
||||
for (const r of results) store.addPendingAsset(r.asset)
|
||||
if (results.length > 0) store.open()
|
||||
}
|
||||
</script>
|
||||
@@ -1,54 +0,0 @@
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<AgentFab />
|
||||
<FoldablePanel />
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue'
|
||||
|
||||
import { KeybindingImpl } from '@/platform/keybindings/keybinding'
|
||||
import { useKeybindingStore } from '@/platform/keybindings/keybindingStore'
|
||||
import { useCommandStore } from '@/stores/commandStore'
|
||||
|
||||
import { useLocalBridge } from '../composables/useLocalBridge'
|
||||
import { useAgentStore } from '../stores/agentStore'
|
||||
import AgentFab from './AgentFab.vue'
|
||||
import FoldablePanel from './FoldablePanel.vue'
|
||||
|
||||
useLocalBridge()
|
||||
|
||||
onMounted(() => {
|
||||
const commandStore = useCommandStore()
|
||||
const keybindingStore = useKeybindingStore()
|
||||
const agentStore = useAgentStore()
|
||||
|
||||
// Register the toggle command idempotently — hot-reload may remount.
|
||||
if (!commandStore.isRegistered('Comfy.Agent.Toggle')) {
|
||||
commandStore.registerCommand({
|
||||
id: 'Comfy.Agent.Toggle',
|
||||
label: 'Toggle ComfyAI Agent',
|
||||
menubarLabel: 'Toggle ComfyAI',
|
||||
icon: 'pi pi-sparkles',
|
||||
function: () => {
|
||||
agentStore.toggle()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Single-key 'c' — matches the single-key style of 'r' (refresh) and
|
||||
// 'w' (workflows sidebar). Wrapped in try/catch because addDefaultKeybinding
|
||||
// throws on duplicates.
|
||||
try {
|
||||
keybindingStore.addDefaultKeybinding(
|
||||
new KeybindingImpl({
|
||||
commandId: 'Comfy.Agent.Toggle',
|
||||
combo: { key: 'c' }
|
||||
})
|
||||
)
|
||||
} catch {
|
||||
/* already registered */
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@@ -1,216 +0,0 @@
|
||||
<template>
|
||||
<div class="flex flex-1 flex-col gap-3 overflow-y-auto p-3">
|
||||
<!-- Frontend-only reassurance + onboarding hint when no key -->
|
||||
<div
|
||||
class="rounded-sm border border-azure-600/40 bg-azure-600/10 px-2.5 py-2 text-xs text-(--fg-color)"
|
||||
>
|
||||
<p class="leading-snug">
|
||||
<span class="font-semibold">{{
|
||||
t('agent.settings.frontendOnly')
|
||||
}}</span>
|
||||
— {{ t('agent.settings.frontendOnlyHint') }}
|
||||
</p>
|
||||
<p v-if="!apiKey" class="mt-1 leading-snug text-electric-400">
|
||||
⚠️ {{ t('agent.settings.noKeyWarning') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Compact 3-field row: API base / API key / Model -->
|
||||
<section class="flex flex-col gap-2">
|
||||
<label
|
||||
for="agent-baseurl"
|
||||
class="text-xs font-medium text-muted-foreground"
|
||||
>
|
||||
{{ t('agent.settings.baseUrl') }}
|
||||
</label>
|
||||
<input
|
||||
id="agent-baseurl"
|
||||
v-model="baseURL"
|
||||
type="url"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
class="border-default rounded-sm border bg-secondary-background px-2 py-1.5 font-mono text-xs focus:ring-1 focus:ring-(--border-default) focus:outline-none"
|
||||
:placeholder="baseUrlPlaceholder"
|
||||
/>
|
||||
<p class="text-xs text-muted-foreground">
|
||||
{{ t('agent.settings.baseUrlHint') }}
|
||||
</p>
|
||||
|
||||
<label
|
||||
for="agent-apikey"
|
||||
class="mt-1 text-xs font-medium text-muted-foreground"
|
||||
>
|
||||
{{ t('agent.settings.apiKey') }}
|
||||
</label>
|
||||
<input
|
||||
id="agent-apikey"
|
||||
v-model="apiKey"
|
||||
type="password"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
class="border-default rounded-sm border bg-secondary-background px-2 py-1.5 font-mono text-xs focus:ring-1 focus:ring-(--border-default) focus:outline-none"
|
||||
:placeholder="apiKeyPlaceholder"
|
||||
/>
|
||||
<p class="text-xs text-muted-foreground">
|
||||
{{ t('agent.settings.apiKeyHint') }}
|
||||
<a
|
||||
href="https://platform.openai.com/api-keys"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="text-azure-400 underline hover:text-azure-300"
|
||||
>{{ t('agent.settings.apiKeyLinkOpenAI') }}</a
|
||||
>
|
||||
{{ t('agent.settings.apiKeyOr') }}
|
||||
<a
|
||||
href="https://openrouter.ai/workspaces/default/keys"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="text-azure-400 underline hover:text-azure-300"
|
||||
>{{ t('agent.settings.apiKeyLinkOpenRouter') }}</a
|
||||
>
|
||||
{{ t('agent.settings.apiKeyOrAny') }}
|
||||
</p>
|
||||
|
||||
<label
|
||||
for="agent-model"
|
||||
class="mt-1 text-xs font-medium text-muted-foreground"
|
||||
>
|
||||
{{ t('agent.settings.model') }}
|
||||
</label>
|
||||
<input
|
||||
id="agent-model"
|
||||
v-model="model"
|
||||
type="text"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
class="border-default rounded-sm border bg-secondary-background px-2 py-1.5 font-mono text-xs focus:ring-1 focus:ring-(--border-default) focus:outline-none"
|
||||
:placeholder="t('agent.settings.modelPlaceholder')"
|
||||
/>
|
||||
<p class="text-xs text-muted-foreground">
|
||||
{{ t('agent.settings.modelHint') }}
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<!-- Local agent bridge -->
|
||||
<section class="border-default border-t pt-3">
|
||||
<p class="mb-1.5 text-xs font-medium text-muted-foreground">
|
||||
{{ t('agent.settings.localBridge') }}
|
||||
</p>
|
||||
<div class="flex items-center gap-2">
|
||||
<span
|
||||
:class="
|
||||
cn(
|
||||
'inline-flex size-2 shrink-0 rounded-full',
|
||||
connected ? 'bg-emerald-400' : 'bg-muted-foreground/40'
|
||||
)
|
||||
"
|
||||
/>
|
||||
<span class="text-xs text-muted-foreground">
|
||||
{{
|
||||
connected
|
||||
? t('agent.settings.bridgeConnected')
|
||||
: t('agent.settings.bridgeDisconnected')
|
||||
}}
|
||||
</span>
|
||||
<button
|
||||
v-if="connected && !activePairCode"
|
||||
class="ml-auto rounded-sm border border-azure-600/40 bg-azure-600/10 px-2 py-0.5 text-xs text-azure-400 hover:bg-azure-600/20"
|
||||
@click="requestPair()"
|
||||
>
|
||||
{{ t('agent.settings.bridgePair') }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="activePairCode"
|
||||
class="border-default mt-2 rounded-sm border bg-secondary-background/60 p-2 text-xs"
|
||||
>
|
||||
<p class="mb-1 text-muted-foreground">
|
||||
{{ t('agent.settings.bridgePairHint') }}
|
||||
</p>
|
||||
<code class="block font-mono break-all text-azure-300 select-all"
|
||||
>comfy-ai pair http://127.0.0.1:7437/pair/{{ activePairCode }}</code
|
||||
>
|
||||
<p class="mt-1.5 text-muted-foreground/70">
|
||||
{{ t('agent.settings.bridgePairWaiting') }}
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<details class="border-default border-t pt-3 text-sm">
|
||||
<summary
|
||||
class="cursor-pointer text-xs font-medium text-muted-foreground select-none"
|
||||
>
|
||||
{{ t('agent.settings.advanced') }}
|
||||
</summary>
|
||||
|
||||
<section class="mt-2 flex flex-col gap-1">
|
||||
<label
|
||||
for="agent-reasoning"
|
||||
class="text-xs font-medium text-muted-foreground"
|
||||
>
|
||||
{{ t('agent.settings.reasoning') }}
|
||||
</label>
|
||||
<select
|
||||
id="agent-reasoning"
|
||||
v-model="reasoningEffort"
|
||||
class="border-default rounded-sm border bg-secondary-background px-2 py-1.5 text-sm focus:ring-1 focus:ring-(--border-default) focus:outline-none"
|
||||
>
|
||||
<option value="minimal">
|
||||
{{ t('agent.settings.reasoningMinimal') }}
|
||||
</option>
|
||||
<option value="low">{{ t('agent.settings.reasoningLow') }}</option>
|
||||
<option value="medium">
|
||||
{{ t('agent.settings.reasoningMedium') }}
|
||||
</option>
|
||||
<option value="high">
|
||||
{{ t('agent.settings.reasoningHigh') }}
|
||||
</option>
|
||||
</select>
|
||||
<p class="text-xs text-muted-foreground">
|
||||
{{ t('agent.settings.reasoningHint') }}
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section class="mt-3 flex flex-1 flex-col gap-1">
|
||||
<label
|
||||
for="agent-sysprompt"
|
||||
class="text-xs font-medium text-muted-foreground"
|
||||
>
|
||||
{{ t('agent.settings.systemPrompt') }}
|
||||
</label>
|
||||
<textarea
|
||||
id="agent-sysprompt"
|
||||
v-model="systemPromptAppend"
|
||||
rows="6"
|
||||
class="border-default flex-1 resize-none rounded-sm border bg-secondary-background px-2 py-1.5 font-mono text-xs focus:ring-1 focus:ring-(--border-default) focus:outline-none"
|
||||
:placeholder="t('agent.settings.systemPromptPlaceholder')"
|
||||
/>
|
||||
<p class="text-xs text-muted-foreground">
|
||||
{{ t('agent.settings.systemPromptHint') }}
|
||||
</p>
|
||||
</section>
|
||||
</details>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
import { cn } from '@comfyorg/tailwind-utils'
|
||||
|
||||
import { useBridgeStatus } from '../composables/useLocalBridge'
|
||||
import { useAgentSession } from '../composables/useAgentSession'
|
||||
|
||||
const { t } = useI18n()
|
||||
const { apiKey, baseURL, model, reasoningEffort, systemPromptAppend } =
|
||||
useAgentSession()
|
||||
const { connected, activePairCode, requestPair } = useBridgeStatus()
|
||||
|
||||
const apiKeyPlaceholder = computed(() =>
|
||||
apiKey.value ? '•••••• (stored)' : 'sk-... or sk-or-...'
|
||||
)
|
||||
const baseUrlPlaceholder = computed(
|
||||
() => 'https://api.openai.com/v1 (default — leave blank for OpenAI)'
|
||||
)
|
||||
</script>
|
||||
@@ -1,744 +0,0 @@
|
||||
<template>
|
||||
<div
|
||||
v-if="store.isOpen"
|
||||
v-show="positioned"
|
||||
ref="panelEl"
|
||||
class="agent-foldable-panel border-default/30 pointer-events-auto fixed flex flex-col rounded-lg border bg-comfy-menu-bg/80 shadow-2xl backdrop-blur-xl backdrop-saturate-150"
|
||||
data-testid="agent-panel"
|
||||
:style="[
|
||||
panelStyle,
|
||||
{
|
||||
zIndex: 9998,
|
||||
width: size.width + 'px',
|
||||
height: size.height + 'px'
|
||||
}
|
||||
]"
|
||||
>
|
||||
<header
|
||||
ref="dragHandleRef"
|
||||
class="border-default/30 flex cursor-grab items-center justify-between border-b px-3 py-2 select-none active:cursor-grabbing"
|
||||
>
|
||||
<div class="flex items-center gap-2">
|
||||
<img
|
||||
src="/assets/images/comfy-logo-single.svg"
|
||||
:alt="t('agent.panel.logoAlt')"
|
||||
:class="cn('size-4 select-none', store.isStreaming && 'animate-spin')"
|
||||
draggable="false"
|
||||
/>
|
||||
<span
|
||||
v-if="!showSettings"
|
||||
data-testid="agent-panel-title"
|
||||
class="rounded-sm bg-charcoal-700 px-1.5 py-0.5 font-serif text-xs font-semibold tracking-wider text-electric-400 italic"
|
||||
>
|
||||
{{ t('agent.panel.brandTitle') }}
|
||||
</span>
|
||||
<span v-else class="text-sm font-medium text-(--fg-color)">
|
||||
{{ t('agent.settings.title') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex items-center gap-0.5">
|
||||
<button
|
||||
v-if="!showSettings"
|
||||
:class="iconBtnClass(false)"
|
||||
:title="
|
||||
allFolded ? t('agent.panel.unfoldAll') : t('agent.panel.foldAll')
|
||||
"
|
||||
@click.stop="toggleAllFolds"
|
||||
>
|
||||
<i
|
||||
:class="
|
||||
cn(
|
||||
'size-3.5',
|
||||
allFolded
|
||||
? 'icon-[lucide--unfold-vertical]'
|
||||
: 'icon-[lucide--fold-vertical]'
|
||||
)
|
||||
"
|
||||
/>
|
||||
</button>
|
||||
<button
|
||||
v-if="!showSettings && store.isStreaming"
|
||||
:class="iconBtnClass(false)"
|
||||
:aria-label="t('agent.panel.stop')"
|
||||
@click.stop="session.stop()"
|
||||
>
|
||||
<i class="icon-[lucide--square] size-3.5" />
|
||||
</button>
|
||||
<button
|
||||
v-if="!showSettings"
|
||||
:class="iconBtnClass(false)"
|
||||
:aria-label="t('agent.panel.clear')"
|
||||
@click.stop="clearAll()"
|
||||
>
|
||||
<i class="icon-[lucide--eraser] size-3.5" />
|
||||
</button>
|
||||
<button
|
||||
:class="iconBtnClass(showSettings)"
|
||||
:aria-label="t('agent.panel.settings')"
|
||||
:aria-pressed="showSettings"
|
||||
@click.stop="showSettings = !showSettings"
|
||||
>
|
||||
<i
|
||||
:class="
|
||||
cn(
|
||||
'size-3.5',
|
||||
showSettings
|
||||
? 'icon-[lucide--terminal]'
|
||||
: 'icon-[lucide--settings]'
|
||||
)
|
||||
"
|
||||
/>
|
||||
</button>
|
||||
<button
|
||||
:class="iconBtnClass(false, true)"
|
||||
:aria-label="t('agent.panel.close')"
|
||||
@click.stop="store.close()"
|
||||
>
|
||||
<i class="icon-[lucide--x] size-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<AgentSettings v-if="showSettings" />
|
||||
|
||||
<div
|
||||
v-else
|
||||
class="terminal-host relative flex flex-1 flex-col overflow-hidden"
|
||||
data-testid="agent-terminal"
|
||||
@dragover.prevent.capture="isHovering = true"
|
||||
@dragleave.capture="isHovering = false"
|
||||
@drop.prevent.stop.capture="onDrop"
|
||||
@paste.capture="onPaste"
|
||||
>
|
||||
<div
|
||||
ref="scrollEl"
|
||||
class="flex-1 overflow-y-auto p-2 font-mono text-xs/snug"
|
||||
@scroll="onScroll"
|
||||
@mousedown="onScrollMouseDown"
|
||||
>
|
||||
<div v-for="m in store.messages" :key="m.id" class="agent-block">
|
||||
<div
|
||||
v-if="m.role === 'user'"
|
||||
class="my-1 wrap-break-word whitespace-pre-wrap text-azure-400"
|
||||
>
|
||||
<span class="opacity-60 select-none">> </span>{{ m.text }}
|
||||
</div>
|
||||
<div
|
||||
v-else-if="m.role === 'assistant'"
|
||||
class="my-1 wrap-break-word whitespace-pre-wrap text-(--fg-color)"
|
||||
>
|
||||
{{ m.text || (store.isStreaming ? '…' : '') }}
|
||||
</div>
|
||||
<div
|
||||
v-else-if="m.tool"
|
||||
:class="
|
||||
cn(
|
||||
'border-default/30 my-1 rounded-sm border bg-secondary-background/40 transition',
|
||||
'hover:border-default/60'
|
||||
)
|
||||
"
|
||||
>
|
||||
<button
|
||||
:class="
|
||||
cn(
|
||||
'flex w-full items-center gap-1.5 px-2 py-1 text-left',
|
||||
'hover:bg-secondary-background/70'
|
||||
)
|
||||
"
|
||||
@click="toggleFold(m.id)"
|
||||
>
|
||||
<i
|
||||
:class="
|
||||
cn(
|
||||
'size-3 shrink-0',
|
||||
isFolded(m.id)
|
||||
? 'icon-[lucide--chevron-right]'
|
||||
: 'icon-[lucide--chevron-down]'
|
||||
)
|
||||
"
|
||||
/>
|
||||
<span class="opacity-60 select-none">$</span>
|
||||
<span class="flex-1 truncate text-(--fg-color)">{{
|
||||
summariseScript(m.tool.script)
|
||||
}}</span>
|
||||
<span
|
||||
:class="
|
||||
cn(
|
||||
'shrink-0 text-xs tabular-nums',
|
||||
m.tool.exitCode === 0
|
||||
? 'text-emerald-400'
|
||||
: 'text-coral-500'
|
||||
)
|
||||
"
|
||||
>
|
||||
{{
|
||||
t('agent.panel.toolFolded', {
|
||||
count: countLines(m.tool.stdout, m.tool.stderr),
|
||||
exit: m.tool.exitCode
|
||||
})
|
||||
}}
|
||||
</span>
|
||||
</button>
|
||||
<div
|
||||
v-if="!isFolded(m.id)"
|
||||
class="border-default/30 border-t px-2 py-1.5"
|
||||
>
|
||||
<pre
|
||||
v-if="m.tool.stdout"
|
||||
class="wrap-break-word whitespace-pre-wrap text-(--fg-color)/85"
|
||||
>{{ m.tool.stdout }}</pre
|
||||
>
|
||||
<pre
|
||||
v-if="m.tool.stderr"
|
||||
class="mt-1 wrap-break-word whitespace-pre-wrap text-coral-500"
|
||||
>
|
||||
[stderr] {{ m.tool.stderr }}</pre
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
class="my-1 wrap-break-word whitespace-pre-wrap text-muted-foreground/70"
|
||||
>
|
||||
{{ m.text }}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="store.messages.length === 0"
|
||||
class="text-muted-foreground/70"
|
||||
>
|
||||
{{ t('agent.panel.prompt') }} {{ t('agent.panel.brandTitle') }}
|
||||
{{ t('agent.panel.readyHint') }}
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="store.pendingAssets.length > 0"
|
||||
class="my-1 flex flex-wrap gap-1"
|
||||
>
|
||||
<div
|
||||
v-for="asset in store.pendingAssets"
|
||||
:key="asset.id"
|
||||
class="group flex items-center gap-1 rounded-sm bg-secondary-background/60 px-1.5 py-0.5 text-xs"
|
||||
>
|
||||
<img
|
||||
v-if="asset.previewUrl"
|
||||
:src="asset.previewUrl"
|
||||
:alt="asset.name"
|
||||
class="size-5 rounded-sm object-cover"
|
||||
/>
|
||||
<i v-else class="icon-[lucide--file] size-3" />
|
||||
<span class="max-w-32 truncate">{{ asset.path }}</span>
|
||||
<button
|
||||
class="opacity-50 hover:opacity-100"
|
||||
:aria-label="t('agent.input.removeAsset')"
|
||||
@click="store.removePendingAsset(asset.id)"
|
||||
>
|
||||
<i class="icon-[lucide--x] size-3" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
Inline prompt — visually flows as the next line of scrollback
|
||||
rather than a separate input widget. Same font / colour scheme
|
||||
as user-message blocks; no border, no background.
|
||||
-->
|
||||
<div class="agent-prompt-row flex items-start gap-1.5">
|
||||
<span class="text-azure-400 select-none">{{
|
||||
t('agent.panel.prompt')
|
||||
}}</span>
|
||||
<textarea
|
||||
ref="inputEl"
|
||||
v-model="inputText"
|
||||
rows="1"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
:placeholder="
|
||||
store.isStreaming
|
||||
? t('agent.panel.streamingPlaceholder')
|
||||
: t('agent.panel.inputPlaceholder')
|
||||
"
|
||||
:class="
|
||||
cn(
|
||||
'flex-1 resize-none border-0 bg-transparent p-0 font-mono text-xs/snug',
|
||||
'text-(--fg-color) placeholder:text-muted-foreground/50',
|
||||
'focus:ring-0 focus:outline-none'
|
||||
)
|
||||
"
|
||||
@keydown="onInputKey"
|
||||
@input="autoGrow"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="isHovering"
|
||||
class="pointer-events-none absolute inset-0 flex items-center justify-center border-2 border-dashed border-azure-600 bg-azure-600/10 text-sm text-white"
|
||||
>
|
||||
{{ t('agent.panel.dropHint') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="absolute inset-y-0 right-0 w-1.5 cursor-ew-resize"
|
||||
:aria-label="t('agent.panel.resize')"
|
||||
@pointerdown.stop="(e) => startResize(e, 'e')"
|
||||
/>
|
||||
<div
|
||||
class="absolute inset-x-0 bottom-0 h-1.5 cursor-ns-resize"
|
||||
:aria-label="t('agent.panel.resize')"
|
||||
@pointerdown.stop="(e) => startResize(e, 's')"
|
||||
/>
|
||||
<div
|
||||
class="absolute inset-y-0 left-0 w-1.5 cursor-ew-resize"
|
||||
:aria-label="t('agent.panel.resize')"
|
||||
@pointerdown.stop="(e) => startResize(e, 'w')"
|
||||
/>
|
||||
<div
|
||||
class="absolute inset-x-0 top-0 h-1.5 cursor-ns-resize"
|
||||
:aria-label="t('agent.panel.resize')"
|
||||
@pointerdown.stop="(e) => startResize(e, 'n')"
|
||||
/>
|
||||
<div
|
||||
class="absolute right-0 bottom-0 size-3 cursor-se-resize"
|
||||
:aria-label="t('agent.panel.resize')"
|
||||
@pointerdown.stop="(e) => startResize(e, 'se')"
|
||||
/>
|
||||
<div
|
||||
class="absolute bottom-0 left-0 size-3 cursor-sw-resize"
|
||||
:aria-label="t('agent.panel.resize')"
|
||||
@pointerdown.stop="(e) => startResize(e, 'sw')"
|
||||
/>
|
||||
<div
|
||||
class="absolute top-0 right-0 size-3 cursor-ne-resize"
|
||||
:aria-label="t('agent.panel.resize')"
|
||||
@pointerdown.stop="(e) => startResize(e, 'ne')"
|
||||
/>
|
||||
<div
|
||||
class="absolute top-0 left-0 size-3 cursor-nw-resize"
|
||||
:aria-label="t('agent.panel.resize')"
|
||||
@pointerdown.stop="(e) => startResize(e, 'nw')"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useDraggable, useLocalStorage, watchDebounced } from '@vueuse/core'
|
||||
import { clamp } from 'es-toolkit'
|
||||
import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
import { cn } from '@comfyorg/tailwind-utils'
|
||||
|
||||
import { useAssetIngest } from '../composables/useAssetIngest'
|
||||
import { useAgentSession } from '../composables/useAgentSession'
|
||||
import { dropImageAsLoadImageNode } from '../composables/useImageNodeDrop'
|
||||
import { log as logEntry } from '../services/logger'
|
||||
import { useAgentStore } from '../stores/agentStore'
|
||||
import AgentSettings from './AgentSettings.vue'
|
||||
|
||||
const PANEL_W = 560
|
||||
const PANEL_H = 560
|
||||
const PANEL_MIN_W = 320
|
||||
const PANEL_MIN_H = 240
|
||||
const HISTORY_KEY = 'Comfy.Agent.InputHistory'
|
||||
const MAX_HISTORY = 100
|
||||
|
||||
const { t } = useI18n()
|
||||
const store = useAgentStore()
|
||||
const session = useAgentSession()
|
||||
const { ingestFromClipboard } = useAssetIngest()
|
||||
|
||||
const panelEl = ref<HTMLElement | null>(null)
|
||||
const dragHandleRef = ref<HTMLElement | null>(null)
|
||||
const scrollEl = ref<HTMLElement | null>(null)
|
||||
const inputEl = ref<HTMLTextAreaElement | null>(null)
|
||||
const showSettings = ref(!session.apiKey.value)
|
||||
const positioned = ref(false)
|
||||
const isHovering = ref(false)
|
||||
|
||||
// Tool messages start folded so the scrollback stays compact. Track per-id
|
||||
// override so users can pin individual blocks open even when the global
|
||||
// "fold all" toggle is on.
|
||||
const explicitFold = ref<Map<string, boolean>>(new Map())
|
||||
const allFolded = ref(true)
|
||||
|
||||
function isFolded(id: string): boolean {
|
||||
const explicit = explicitFold.value.get(id)
|
||||
if (explicit !== undefined) return explicit
|
||||
return allFolded.value
|
||||
}
|
||||
|
||||
function toggleFold(id: string): void {
|
||||
explicitFold.value.set(id, !isFolded(id))
|
||||
// Force reactivity on Map mutation
|
||||
explicitFold.value = new Map(explicitFold.value)
|
||||
}
|
||||
|
||||
function toggleAllFolds(): void {
|
||||
allFolded.value = !allFolded.value
|
||||
// Reset per-id overrides so the global state actually applies everywhere.
|
||||
explicitFold.value = new Map()
|
||||
}
|
||||
|
||||
const inputText = ref('')
|
||||
const inputHistory = useLocalStorage<string[]>(HISTORY_KEY, [])
|
||||
const historyIndex = ref<number | null>(null)
|
||||
|
||||
const savedPos = useLocalStorage('Comfy.Agent.PanelPosition', { x: 0, y: 0 })
|
||||
const size = useLocalStorage('Comfy.Agent.PanelSize', {
|
||||
width: PANEL_W,
|
||||
height: PANEL_H
|
||||
})
|
||||
|
||||
type ResizeDir = 'n' | 's' | 'e' | 'w' | 'ne' | 'nw' | 'se' | 'sw'
|
||||
|
||||
function startResize(e: PointerEvent, dir: ResizeDir): void {
|
||||
const startX = e.clientX
|
||||
const startY = e.clientY
|
||||
const startW = size.value.width
|
||||
const startH = size.value.height
|
||||
const startPosX = x.value
|
||||
const startPosY = y.value
|
||||
const movesX = dir.includes('w')
|
||||
const movesY = dir.includes('n')
|
||||
const onMove = (ev: PointerEvent) => {
|
||||
const dx = ev.clientX - startX
|
||||
const dy = ev.clientY - startY
|
||||
let newW = startW
|
||||
let newH = startH
|
||||
if (dir.includes('e')) newW = Math.max(PANEL_MIN_W, startW + dx)
|
||||
if (dir.includes('w')) newW = Math.max(PANEL_MIN_W, startW - dx)
|
||||
if (dir.includes('s')) newH = Math.max(PANEL_MIN_H, startH + dy)
|
||||
if (dir.includes('n')) newH = Math.max(PANEL_MIN_H, startH - dy)
|
||||
size.value = { width: newW, height: newH }
|
||||
if (movesX) x.value = startPosX + (startW - newW)
|
||||
if (movesY) y.value = startPosY + (startH - newH)
|
||||
}
|
||||
const onUp = () => {
|
||||
window.removeEventListener('pointermove', onMove)
|
||||
window.removeEventListener('pointerup', onUp)
|
||||
}
|
||||
window.addEventListener('pointermove', onMove)
|
||||
window.addEventListener('pointerup', onUp)
|
||||
}
|
||||
|
||||
const {
|
||||
x,
|
||||
y,
|
||||
style: panelStyle
|
||||
} = useDraggable(panelEl, {
|
||||
initialValue: savedPos.value,
|
||||
handle: dragHandleRef,
|
||||
containerElement: document.body
|
||||
})
|
||||
|
||||
watchDebounced(
|
||||
[x, y],
|
||||
([nx, ny]) => {
|
||||
savedPos.value = { x: nx, y: ny }
|
||||
},
|
||||
{ debounce: 300 }
|
||||
)
|
||||
|
||||
function setDefaultPosition(): void {
|
||||
const w = size.value.width
|
||||
const h = size.value.height
|
||||
if (savedPos.value.x === 0 && savedPos.value.y === 0) {
|
||||
x.value = Math.max(0, window.innerWidth - w - 400)
|
||||
y.value = Math.max(0, window.innerHeight - h - 24)
|
||||
} else {
|
||||
x.value = clamp(savedPos.value.x, 0, window.innerWidth - w)
|
||||
y.value = clamp(savedPos.value.y, 0, window.innerHeight - h)
|
||||
}
|
||||
positioned.value = true
|
||||
}
|
||||
|
||||
function iconBtnClass(active: boolean, danger = false): string {
|
||||
return cn(
|
||||
'flex size-7 items-center justify-center rounded-md border border-transparent text-muted-foreground transition',
|
||||
active
|
||||
? 'border-azure-600/60 bg-azure-600/20 text-azure-600'
|
||||
: danger
|
||||
? 'hover:border-coral-500/40 hover:bg-coral-500/15 hover:text-coral-500'
|
||||
: 'hover:border-default/40 hover:bg-secondary-background/60 hover:text-(--fg-color)',
|
||||
'focus-visible:ring-2 focus-visible:ring-azure-600 focus-visible:outline-none active:scale-95'
|
||||
)
|
||||
}
|
||||
|
||||
function summariseScript(script: string): string {
|
||||
// Single line preview — collapse any internal newlines, trim long lines.
|
||||
const single = script.replace(/\s+/g, ' ').trim()
|
||||
return single.length > 200 ? single.slice(0, 200) + '…' : single
|
||||
}
|
||||
|
||||
function countLines(stdout: string, stderr?: string): number {
|
||||
let n = 0
|
||||
if (stdout) n += stdout.split('\n').filter((l) => l.length > 0).length
|
||||
if (stderr) n += stderr.split('\n').filter((l) => l.length > 0).length
|
||||
return n
|
||||
}
|
||||
|
||||
const userScrolledUp = ref(false)
|
||||
|
||||
function onScroll(): void {
|
||||
const el = scrollEl.value
|
||||
if (!el) return
|
||||
const distanceFromBottom = el.scrollHeight - el.scrollTop - el.clientHeight
|
||||
// 80px slack so micro-scrolls during streaming still count as "at bottom"
|
||||
userScrolledUp.value = distanceFromBottom > 80
|
||||
}
|
||||
|
||||
function scrollToBottom(force = false): void {
|
||||
void nextTick(() => {
|
||||
const el = scrollEl.value
|
||||
if (!el) return
|
||||
if (force || !userScrolledUp.value) {
|
||||
el.scrollTop = el.scrollHeight
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
watch(
|
||||
() => store.messages.length,
|
||||
() => scrollToBottom()
|
||||
)
|
||||
watch(
|
||||
() => store.messages.map((m) => m.text).join('\n').length,
|
||||
() => scrollToBottom()
|
||||
)
|
||||
|
||||
function isDirectShellCommand(line: string): boolean {
|
||||
const first = line.trim().split(/\s+/)[0]
|
||||
if (!first) return false
|
||||
const ctx = session.buildExecContextOnce()
|
||||
// Don't treat a leading '/' as a shell-redirection sigil — the
|
||||
// attachment flow prefills the composer with paths like '/input/foo.png'
|
||||
// or '/tmp/x.json' and pressing Enter would route those to exec instead
|
||||
// of the LLM. Real shell operators (|, &, ;, <, >) are still honoured.
|
||||
return !!ctx.registry.get(first) || /^[|&;<>]/.test(first)
|
||||
}
|
||||
|
||||
async function handleSubmit(line: string): Promise<void> {
|
||||
const trimmed = line.trim()
|
||||
if (!trimmed && store.pendingAssets.length === 0) return
|
||||
|
||||
if (trimmed) {
|
||||
inputHistory.value = [
|
||||
...inputHistory.value.filter((h) => h !== trimmed),
|
||||
trimmed
|
||||
].slice(-MAX_HISTORY)
|
||||
}
|
||||
historyIndex.value = null
|
||||
|
||||
const assets = store.consumePendingAssets()
|
||||
|
||||
if (trimmed && isDirectShellCommand(trimmed)) {
|
||||
logEntry({ kind: 'user', text: trimmed })
|
||||
store.addMessage({ role: 'user', text: trimmed })
|
||||
try {
|
||||
const result = await session.execShell(trimmed)
|
||||
logEntry({
|
||||
kind: 'tool',
|
||||
script: trimmed,
|
||||
stdout: result.stdout,
|
||||
stderr: result.stderr,
|
||||
exitCode: result.exitCode
|
||||
})
|
||||
store.addMessage({
|
||||
role: 'system',
|
||||
text: `$ ${trimmed}\n${result.stdout}${result.stderr ? `\n[stderr] ${result.stderr}` : ''}`,
|
||||
tool: {
|
||||
script: trimmed,
|
||||
stdout: result.stdout,
|
||||
stderr: result.stderr,
|
||||
exitCode: result.exitCode
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
const text = err instanceof Error ? err.message : String(err)
|
||||
logEntry({ kind: 'error', text })
|
||||
store.addMessage({ role: 'system', text: `error: ${text}` })
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
await session.send(trimmed, assets)
|
||||
}
|
||||
|
||||
function autoGrow(): void {
|
||||
const el = inputEl.value
|
||||
if (!el) return
|
||||
el.style.height = 'auto'
|
||||
el.style.height = Math.min(el.scrollHeight, 160) + 'px'
|
||||
}
|
||||
|
||||
async function onInputKey(e: KeyboardEvent): Promise<void> {
|
||||
if (e.key === 'Enter' && !e.shiftKey && !e.altKey) {
|
||||
e.preventDefault()
|
||||
if (store.isStreaming) return
|
||||
const line = inputText.value
|
||||
inputText.value = ''
|
||||
autoGrow()
|
||||
await handleSubmit(line)
|
||||
return
|
||||
}
|
||||
if (e.key === 'ArrowUp' && (inputText.value === '' || e.altKey)) {
|
||||
e.preventDefault()
|
||||
const hist = inputHistory.value
|
||||
if (hist.length === 0) return
|
||||
historyIndex.value =
|
||||
historyIndex.value === null
|
||||
? hist.length - 1
|
||||
: Math.max(0, historyIndex.value - 1)
|
||||
inputText.value = hist[historyIndex.value] ?? ''
|
||||
void nextTick(autoGrow)
|
||||
return
|
||||
}
|
||||
if (e.key === 'ArrowDown' && historyIndex.value !== null) {
|
||||
e.preventDefault()
|
||||
const hist = inputHistory.value
|
||||
historyIndex.value = historyIndex.value + 1
|
||||
if (historyIndex.value >= hist.length) {
|
||||
historyIndex.value = null
|
||||
inputText.value = ''
|
||||
} else {
|
||||
inputText.value = hist[historyIndex.value] ?? ''
|
||||
}
|
||||
void nextTick(autoGrow)
|
||||
return
|
||||
}
|
||||
if (e.key === 'l' && e.ctrlKey) {
|
||||
e.preventDefault()
|
||||
clearAll()
|
||||
}
|
||||
}
|
||||
|
||||
function clearAll(): void {
|
||||
store.clearMessages()
|
||||
explicitFold.value = new Map()
|
||||
allFolded.value = true
|
||||
inputEl.value?.focus()
|
||||
}
|
||||
|
||||
function focusInput(): void {
|
||||
void nextTick(() => inputEl.value?.focus())
|
||||
}
|
||||
|
||||
/**
|
||||
* Click anywhere in the scrollback — but only on the bare container
|
||||
* itself, not on a message — focuses the input. Mirrors how a real
|
||||
* terminal lets you keep typing after scrolling away.
|
||||
*/
|
||||
function onScrollMouseDown(e: MouseEvent): void {
|
||||
const target = e.target as HTMLElement | null
|
||||
if (!target) return
|
||||
if (target === scrollEl.value) {
|
||||
focusInput()
|
||||
}
|
||||
}
|
||||
|
||||
async function onDrop(e: DragEvent): Promise<void> {
|
||||
isHovering.value = false
|
||||
const dt = e.dataTransfer
|
||||
if (!dt) return
|
||||
const text =
|
||||
dt.getData('text/plain') ||
|
||||
dt.getData('text') ||
|
||||
dt.getData('text/uri-list')
|
||||
if (text && (!dt.files || dt.files.length === 0)) {
|
||||
inputText.value += text
|
||||
void nextTick(autoGrow)
|
||||
focusInput()
|
||||
return
|
||||
}
|
||||
const results = await ingestFromClipboard(dt)
|
||||
for (const r of results) {
|
||||
store.addPendingAsset(r.asset)
|
||||
const isImage = r.asset.mime.startsWith('image/')
|
||||
if (isImage && r.remote) {
|
||||
const filename = r.asset.path.replace(/^\/input\/?/, '')
|
||||
const nodeId = dropImageAsLoadImageNode(filename)
|
||||
store.addMessage({
|
||||
role: 'system',
|
||||
text:
|
||||
nodeId !== null
|
||||
? `[+] LoadImage #${nodeId} — ${filename}`
|
||||
: `(uploaded ${filename} — could not add LoadImage node)`
|
||||
})
|
||||
} else {
|
||||
inputText.value += r.asset.path + ' '
|
||||
}
|
||||
}
|
||||
void nextTick(autoGrow)
|
||||
focusInput()
|
||||
}
|
||||
|
||||
async function onPaste(e: ClipboardEvent): Promise<void> {
|
||||
if (!e.clipboardData) return
|
||||
const hasFiles = Array.from(e.clipboardData.items).some(
|
||||
(i) => i.kind === 'file'
|
||||
)
|
||||
if (!hasFiles) return
|
||||
e.stopPropagation()
|
||||
e.preventDefault()
|
||||
const results = await ingestFromClipboard(e.clipboardData)
|
||||
for (const r of results) {
|
||||
store.addPendingAsset(r.asset)
|
||||
inputText.value += r.asset.path + ' '
|
||||
}
|
||||
void nextTick(autoGrow)
|
||||
}
|
||||
|
||||
watch(
|
||||
() => store.isOpen,
|
||||
(open) => {
|
||||
if (!open) return
|
||||
void nextTick(() => {
|
||||
setDefaultPosition()
|
||||
void nextTick(() => {
|
||||
scrollToBottom(true)
|
||||
focusInput()
|
||||
})
|
||||
})
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
// Global Ctrl+O / ⌘+O handler — registered on window so the browser's
|
||||
// default "Open File" dialog can be preempted regardless of which element
|
||||
// inside the panel currently has focus. Only acts while the panel is open.
|
||||
function handleGlobalKey(e: KeyboardEvent): void {
|
||||
if (!store.isOpen) return
|
||||
if (e.key !== 'o' && e.key !== 'O') return
|
||||
if (!(e.ctrlKey || e.metaKey)) return
|
||||
if (e.altKey || e.shiftKey) return
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
toggleAllFolds()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener('keydown', handleGlobalKey, { capture: true })
|
||||
if (store.isOpen) {
|
||||
setDefaultPosition()
|
||||
void nextTick(() => {
|
||||
scrollToBottom(true)
|
||||
focusInput()
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('keydown', handleGlobalKey, { capture: true })
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.agent-block pre {
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
line-height: inherit;
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -3,43 +3,19 @@
|
||||
<label class="content-center text-xs text-node-component-slot-text">
|
||||
{{ $t('boundingBox.x') }}
|
||||
</label>
|
||||
<ScrubableNumberInput
|
||||
v-model="x"
|
||||
:min="0"
|
||||
:step="1"
|
||||
:disabled
|
||||
data-testid="bounding-box-x"
|
||||
/>
|
||||
<ScrubableNumberInput v-model="x" :min="0" :step="1" :disabled />
|
||||
<label class="content-center text-xs text-node-component-slot-text">
|
||||
{{ $t('boundingBox.y') }}
|
||||
</label>
|
||||
<ScrubableNumberInput
|
||||
v-model="y"
|
||||
:min="0"
|
||||
:step="1"
|
||||
:disabled
|
||||
data-testid="bounding-box-y"
|
||||
/>
|
||||
<ScrubableNumberInput v-model="y" :min="0" :step="1" :disabled />
|
||||
<label class="content-center text-xs text-node-component-slot-text">
|
||||
{{ $t('boundingBox.width') }}
|
||||
</label>
|
||||
<ScrubableNumberInput
|
||||
v-model="width"
|
||||
:min="1"
|
||||
:step="1"
|
||||
:disabled
|
||||
data-testid="bounding-box-width"
|
||||
/>
|
||||
<ScrubableNumberInput v-model="width" :min="1" :step="1" :disabled />
|
||||
<label class="content-center text-xs text-node-component-slot-text">
|
||||
{{ $t('boundingBox.height') }}
|
||||
</label>
|
||||
<ScrubableNumberInput
|
||||
v-model="height"
|
||||
:min="1"
|
||||
:step="1"
|
||||
:disabled
|
||||
data-testid="bounding-box-height"
|
||||
/>
|
||||
<ScrubableNumberInput v-model="height" :min="1" :step="1" :disabled />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user