Files
jackwener__opencli/clis/jimeng/workspaces.js
jakevin d2974a9ff6 refactor(adapters): convert adapter layer from TypeScript to JavaScript (#928)
* refactor(adapters): convert adapter layer from TypeScript to JavaScript

Core framework stays TypeScript; adapter layer moves to JS-first.
Adapters are essentially "executable config + browser scripts" that
barely use TS features — this simplifies the build/distribution pipeline
by removing the dist/clis/ intermediate compilation step.

Changes:
- Convert all 753 adapter files in clis/ from .ts to .js
- Update tsconfig to exclude clis/ from compilation
- Simplify build-manifest to scan clis/*.js directly (no dist/clis/)
- Update discovery, main, fetch-adapters to load JS adapters from clis/
- Update generate-verified to output .js artifacts
- Update package.json files field: dist/clis/ → clis/
- Fix all test files for the .ts → .js transition

* fix(main): use findPackageRoot for BUILTIN_CLIS path

The previous relative path (../../clis from __dirname) only worked for
dist/src/main.js but broke dev mode (tsx src/main.ts) where __dirname
is <repo>/src — resolving to /clis instead of <repo>/clis.

Use findPackageRoot() which works for both dev and prod paths.
2026-04-10 14:52:18 +08:00

42 lines
1.5 KiB
JavaScript

import { cli, Strategy } from '@jackwener/opencli/registry';
cli({
site: 'jimeng',
name: 'workspaces',
description: '即梦AI 查看所有工作区(会话窗口)',
domain: 'jimeng.jianying.com',
strategy: Strategy.COOKIE,
browser: true,
columns: ['workspace_id', 'name', 'is_pinned', 'updated_at'],
pipeline: [
{ navigate: 'https://jimeng.jianying.com/ai-tool/generate?type=image&workspace=0' },
{ evaluate: `(async () => {
const res = await fetch('/mweb/v1/workspace/list?aid=513695&web_version=7.5.0&da_version=3.3.12', {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({})
});
const data = await res.json();
if (data.ret === '1014' || data.ret === 1014) {
throw new Error('Not logged in — open jimeng.jianying.com in Chrome and sign in first');
}
if (data.ret !== '0' && data.ret !== 0) {
throw new Error('workspace/list failed: ret=' + data.ret + ' errmsg=' + (data.errmsg || ''));
}
return (data.data?.workspaces || []).map(ws => ({
workspace_id: String(ws.workspace_id),
name: ws.name || '',
is_pinned: ws.is_pinned ? 'yes' : 'no',
updated_at: ws.update_time ? new Date(ws.update_time).toLocaleString('zh-CN') : '',
}));
})()
` },
{ map: {
workspace_id: '${{ item.workspace_id }}',
name: '${{ item.name }}',
is_pinned: '${{ item.is_pinned }}',
updated_at: '${{ item.updated_at }}',
} },
],
});