### window.__wbsStartAutomationPicker() / window.__wbsStopAutomationPicker() Source: https://github.com/babygoton/workdaddy Start and stop the automation picker. ```APIDOC ## Functions: __wbsStartAutomationPicker, __wbsStopAutomationPicker ### Description Start / stop the automation picker. ### Usage ```js window.__wbsStartAutomationPicker(); window.__wbsStopAutomationPicker(); ``` ``` -------------------------------- ### POST /api/installer/console Source: https://github.com/babygoton/workdaddy Installer console channel (debugging). ```APIDOC ## POST /api/installer/console ### Description Installer console channel (debugging). ### Method POST ### Endpoint /api/installer/console ``` -------------------------------- ### Linux DEB パッケージのインストール (apt install) Source: https://github.com/babygoton/workdaddy/blob/main/README_ja.md Ubuntu/Debian で対応する DEB ファイルをインストールする例。`` には amd64 または arm64 を選びます。 ```bash sudo apt install ./CodeDaddy-CN_1.2.9_amd64.deb ``` -------------------------------- ### Run Windows release builder Source: https://github.com/babygoton/workdaddy/blob/main/AGENTS.md Execute the build script using explicit paths for Go and Inno Setup to ensure a reproducible build environment. ```powershell powershell -NoProfile -ExecutionPolicy Bypass -File scripts/build-win-release.ps1 ` -Version ` -GoPath "$env:USERPROFILE\.workdaddy-toolchains\go1.27.0\bin\go.exe" ` -IsccPath "$env:USERPROFILE\.workdaddy-toolchains\Inno Setup 6\ISCC.exe" ``` -------------------------------- ### GET /api/client-launch-settings Source: https://github.com/babygoton/workdaddy Reads client launch settings. ```APIDOC ## GET /api/client-launch-settings ### Description Reads client launch settings. ### Method GET ### Endpoint /api/client-launch-settings ``` -------------------------------- ### Basic usage: discover and preview Source: https://github.com/babygoton/workdaddy Example of discovering CC Switch and reading providers. Logs the number of providers found. ```javascript const { discoverCCSwitch, readCCSwitch, createThirdPartyImport } = require('./third-party-models.js'); const found = discoverCCSwitch(); if (found) { const providers = readCCSwitch(found.file); console.log(providers.length); } ``` -------------------------------- ### Basic usage - start rotation Source: https://github.com/babygoton/workdaddy Creates a rotation service with a config file and sets random mode with a 30-minute interval. ```javascript const { createWallpaperRotation } = require('./wallpaper-rotation.js'); const rotation = createWallpaperRotation({ configFile: path.join(DATA_DIR, 'wallpaper-rotation.json') }); rotation.setConfig({ mode: 'random', directory: '/Pictures/walls', intervalMinutes: 30 }); ``` -------------------------------- ### CLI commands for session-fork.js Source: https://github.com/babygoton/workdaddy/blob/main/docs/session-fork.md CLI usage examples for session-fork.js. Supports listing anchor points, forking by message index or timestamp, and specifying a record file with a custom title suffix. Options like --data-dir, --out, --dry-run, and --json are available. ```bash # 打锚点清单 node scripts/session-fork.js --id <会话ID> --points [--max 60] # 从第 12 条消息分叉 node scripts/session-fork.js --id <会话ID> --until 12 [--out <文件>] [--json] # 按时间点分叉 node scripts/session-fork.js --id <会话ID> --until "09-17 15:30" # 直接指定记录文件,并自定义标题后缀 node scripts/session-fork.js --file <记录文件> --until 7 [--suffix "(副本)"] ``` -------------------------------- ### listProfiles function Source: https://github.com/babygoton/workdaddy Returns a deep copy array of the four official profiles (with cloned capabilities and targetHints) for installation wizard / brand selection. ```javascript function listProfiles() { return Object.values(PROFILES).map((p) => ({ ...p, capabilities: { ...p.capabilities }, targetHints: [...p.targetHints] })); } ``` -------------------------------- ### createGrowthStreakCache(...) Source: https://github.com/babygoton/workdaddy 创建连续天数缓存,返回 `{ get(...), peek, clear(uid) }` 对象。 ```APIDOC ## createGrowthStreakCache(...) ### Description 创建连续天数缓存。 ### Method Function ### Returns - **cache** (object) - 包含以下方法: - **get(...)** (function) - 获取缓存值 - **peek** (function) - 查看缓存值(不更新) - **clear(uid)** (function) - 清除指定 uid 的缓存 ``` -------------------------------- ### createPrimaryAccountStore(dataDir, accountExists) Source: https://github.com/babygoton/workdaddy 创建主账号偏好存储。返回包含 get() 和 set(uid) 方法的对象,用于读写主账号信息。 ```APIDOC ## createPrimaryAccountStore(dataDir, accountExists) ### Description 创建主账号偏好存储。返回包含 get() 和 set(uid) 方法的对象,用于读写主账号信息。 ### Method Function ### Signature `createPrimaryAccountStore(dataDir, accountExists)` ### Parameters - **dataDir** (string) - Required - 数据目录路径 - **accountExists** (function) - Required - 账号存在性检查函数 ### Returns - (object) - 包含以下方法的存储对象 - **get()** - 读取主账号,读到非法/失效账号时清空并返回 '' - **set(uid)** - 设置主账号 ### set(uid) 行为 - uid 必须匹配 `/^[A-Za-z0-9_-]{1,128}$/`,否则抛 '账号 uid 无效' - 非空时必须 `accountExists(uid)`,否则抛 '账号备份不存在' - 临时文件 + rename 原子写,mode 0600 ``` -------------------------------- ### listProfiles() Source: https://github.com/babygoton/workdaddy Returns a deep copy array of the four official profiles, with capabilities and targetHints cloned. Used by installation wizard and brand selection. ```APIDOC ## listProfiles() ### Description Returns a deep copy array of the four official profiles, with capabilities and targetHints cloned. Used by installation wizard and brand selection. ### Returns Array of profile objects, each with `capabilities` and `targetHints` cloned. ``` -------------------------------- ### Classify check-in result and select endpoints Source: https://github.com/babygoton/workdaddy Uses classifyCheckinResult to determine check-in outcome and checkinEndpointsForToken to get billing endpoints for a token. The example passes { httpOk: true, code: 0, message: 'ok' } and a profile object. ```javascript const { classifyCheckinResult, checkinEndpointsForToken } = require('./checkin-result.js'); const { ok, already, inactive } = classifyCheckinResult({ httpOk: true, code: 0, message: 'ok' }); const endpoints = checkinEndpointsForToken('eyJ...', { profile }); // ['https://www.workbuddy.cn/billing/...'] ``` -------------------------------- ### Linux systemd ユーザーサービスの有効化 (systemd-install-linux.sh) Source: https://github.com/babygoton/workdaddy/blob/main/README_ja.md 必要に応じてプロファイルの systemd ユーザーサービスを有効にする例。WBSWITCH_PROFILE 環境変数でプロファイルを指定します。 ```bash WBSWITCH_PROFILE=codebuddy-cn bash /opt/codedaddy-cn/scripts/systemd-install-linux.sh ``` -------------------------------- ### rendererBridgeSource() Source: https://github.com/babygoton/workdaddy Returns JavaScript source code that can be directly injected into the renderer to install the bridge. The daemon injects this source along with the API token before installing the binding. ```APIDOC ## rendererBridgeSource() ### Description Returns JavaScript source code that can be directly injected into the renderer to install the bridge. The daemon injects this source along with the API token before installing the binding. ### Returns - **source** (string) - JavaScript source code for renderer injection ### Usage ```js const source = rendererBridgeSource(); // Inject source into renderer along with __WBS_API_TOKEN__ // Then install binding via Runtime.addBinding ``` ``` -------------------------------- ### Linux のエントリーポイント (launch-gui-linux.sh) Source: https://github.com/babygoton/workdaddy/blob/main/README_ja.md アプリケーションメニューがない場合に、対応するブランドを起動するためのエントリーポイント。各パッケージのスクリプトにプロファイル引数(cn, ai, codebuddy-cn, codebuddy-intl)を渡します。 ```bash bash /opt/workdaddy/scripts/launch-gui-linux.sh cn ``` ```bash bash /opt/workdaddy-ai/scripts/launch-gui-linux.sh ai ``` ```bash bash /opt/codedaddy-cn/scripts/launch-gui-linux.sh codebuddy-cn ``` ```bash bash /opt/codedaddy/scripts/launch-gui-linux.sh codebuddy-intl ``` -------------------------------- ### GET /api/token-stats Source: https://github.com/babygoton/workdaddy Retrieves token statistics. ```APIDOC ## GET /api/token-stats ### Description Retrieves token statistics. ### Method GET ### Endpoint /api/token-stats ``` -------------------------------- ### 从源码运行:克隆、安装并启动守护进程 Source: https://github.com/babygoton/workdaddy/blob/main/README.md 开发者从源码运行 WorkDaddy 的步骤:克隆仓库、进入目录、运行 install.sh 创建备份目录并启动守护进程,然后用 relaunch-with-cdp.sh 将 WorkBuddy 切换到调试模式(端口 9222)。 ```bash git clone https://github.com/babygoton/WorkDaddy.git cd WorkDaddy bash scripts/install.sh # 创建备份目录 + 启动守护进程 bash scripts/relaunch-with-cdp.sh # 把 WorkBuddy 切换到调试模式(端口 9222) ``` -------------------------------- ### createDailyProgressCache Source: https://github.com/babygoton/workdaddy Creates a cache for daily progress. Returns an object with get, peek, and clear methods. ```APIDOC ## createDailyProgressCache ### Description Creates a cache for daily progress. Returns an object with get, peek, and clear methods. ### Method Function ### Signature `createDailyProgressCache(...)` ### Parameters No parameters documented. ### Returns - **get** (Function) - Retrieves a value from the cache. - **peek** (Function) - Peeks at a value without removing it. - **clear** (Function) - Clears the cache for a given UID. ``` -------------------------------- ### GET /api/telemetry-settings Source: https://github.com/babygoton/workdaddy Reads telemetry settings. ```APIDOC ## GET /api/telemetry-settings ### Description Reads telemetry settings. ### Method GET ### Endpoint /api/telemetry-settings ``` -------------------------------- ### GET /wallpapers/ Source: https://github.com/babygoton/workdaddy Serves built-in wallpapers as static files, only .webp format. ```APIDOC ## GET /wallpapers/ ### Description Serves built-in wallpapers as static files, only .webp format. ### Method GET ### Endpoint /wallpapers/ ``` -------------------------------- ### getClientLaunchArgs(dataDir, profileId, platform) Source: https://github.com/babygoton/workdaddy 获取客户端启动参数。软件渲染开启时返回软件渲染参数数组,否则返回空数组。 ```APIDOC ## getClientLaunchArgs(dataDir, profileId, platform) ### Description 获取客户端启动参数。软件渲染开启时返回软件渲染参数数组,否则返回空数组。 ### Method Function ### Signature `getClientLaunchArgs(dataDir, profileId, platform)` ### Parameters - **dataDir** (string) - Required - 数据目录路径 - **profileId** (string) - Required - Profile 标识 - **platform** (string) - Required - 平台标识 ### Returns - (array) - 软件渲染参数数组或空数组 ``` -------------------------------- ### GET /api/personality Source: https://github.com/babygoton/workdaddy Retrieves the list of personalities. ```APIDOC ## GET /api/personality ### Description Retrieves the list of personalities. ### Method GET ### Endpoint /api/personality ``` -------------------------------- ### listInstalledModelSources(activeId) Source: https://github.com/babygoton/workdaddy Lists model sources from other profiles, excluding the current profile. Provides installation and availability status for each model source. ```APIDOC ## listInstalledModelSources(activeId) ### Description Lists model sources from other profiles, excluding the current profile. Provides installation and availability status for each model source. ### Parameters - **activeId** - The current profile ID to exclude ### Returns Array of objects with `{ profileId, name, modelsFile, installed, available, shared }` where `installed` indicates executable file exists, `available` indicates models.json exists, and `shared` indicates both sides use the same modelsFile path. ``` -------------------------------- ### GET /api/persona Source: https://github.com/babygoton/workdaddy Reads personalization settings. ```APIDOC ## GET /api/persona ### Description Reads personalization settings. ### Method GET ### Endpoint /api/persona ``` -------------------------------- ### GET /api/credits/history Source: https://github.com/babygoton/workdaddy Retrieves credit history. ```APIDOC ## GET /api/credits/history ### Description Retrieves credit history. ### Method GET ### Endpoint /api/credits/history ``` -------------------------------- ### supportsClientLaunchSettings(profileId, platform) Source: https://github.com/babygoton/workdaddy 检查客户端是否支持启动兼容设置。仅 win32 平台且 profileId 为 'workbuddy-ai' 时返回 true。 ```APIDOC ## supportsClientLaunchSettings(profileId, platform) ### Description 检查客户端是否支持启动兼容设置。仅 win32 平台且 profileId 为 'workbuddy-ai' 时返回 true。 ### Method Function ### Signature `supportsClientLaunchSettings(profileId, platform)` ### Parameters - **profileId** (string) - Required - Profile 标识 - **platform** (string) - Required - 平台标识 ### Returns - (boolean) - 是否支持 ``` -------------------------------- ### persistentInstallationId() Source: https://github.com/babygoton/workdaddy Reads or atomically creates (via linkSync) the installation instance UUID. Failure does not block startup. ```APIDOC ## persistentInstallationId() ### Description Reads or atomically creates (via linkSync) the installation instance UUID. Failure does not block startup. ### Method Function ### Signature `persistentInstallationId() => string` ### Returns - **string** - The installation instance UUID ``` -------------------------------- ### GET /api/themes Source: https://github.com/babygoton/workdaddy Retrieves the list of themes. ```APIDOC ## GET /api/themes ### Description Retrieves the list of themes. ### Method GET ### Endpoint /api/themes ``` -------------------------------- ### readClientLaunchSettings(dataDir, profileId, platform) Source: https://github.com/babygoton/workdaddy 读取客户端启动兼容设置。从 client-launch-settings.json 文件读取配置并返回。 ```APIDOC ## readClientLaunchSettings(dataDir, profileId, platform) ### Description 读取客户端启动兼容设置。从 client-launch-settings.json 文件读取配置并返回。 ### Method Function ### Signature `readClientLaunchSettings(dataDir, profileId, platform = process.platform)` ### Parameters - **dataDir** (string) - Required - 数据目录路径 - **profileId** (string) - Required - Profile 标识 - **platform** (string) - Optional - 平台标识,默认为当前平台 ### Returns - (object) - 包含以下字段的配置对象 - **supported** (boolean) - 是否支持 - **softwareRendering** (boolean) - 软件渲染开关 ``` -------------------------------- ### Run Windows build with logging Source: https://github.com/babygoton/workdaddy/blob/main/AGENTS.md Execute the build process via Start-Process to capture stdout and stderr into log files, ensuring build completion is verified by the exit code. ```powershell $argString = '-NoProfile -ExecutionPolicy Bypass -File "scripts/build-win-release.ps1" -Version -GoPath "" -IsccPath ""' $p = Start-Process powershell.exe -ArgumentList $argString ` -RedirectStandardOutput release/build.stdout.log ` -RedirectStandardError release/build.stderr.log -Wait -PassThru if ($p.ExitCode -ne 0) { throw "Windows build failed: $($p.ExitCode)" } ``` -------------------------------- ### GET /api/sessions/auto-copy/status Source: https://github.com/babygoton/workdaddy Returns the auto-copy status. ```APIDOC ## GET /api/sessions/auto-copy/status ### Description Returns the auto-copy status. ### Method GET ### Endpoint /api/sessions/auto-copy/status ``` -------------------------------- ### GET /api/sessions/workspaces Source: https://github.com/babygoton/workdaddy Returns the list of workspaces. ```APIDOC ## GET /api/sessions/workspaces ### Description Returns the list of workspaces. ### Method GET ### Endpoint /api/sessions/workspaces ``` -------------------------------- ### Startup cleanup of old backups Source: https://github.com/babygoton/workdaddy Shows how to prune old sync backups at daemon startup and log the counts of removed and retained recovery backups. ```javascript const cleanup = sessionSync.pruneSyncBackups(path.join(DATA_DIR, 'session-sync-backups')); if (cleanup.removed || cleanup.retainedRecovery) { console.log(`移除 ${cleanup.removed} 个,保留 ${cleanup.retainedRecovery} 个 recovery 备份`); } ``` -------------------------------- ### setClientLaunchSettings(dataDir, profileId, body, platform) Source: https://github.com/babygoton/workdaddy 设置客户端启动兼容设置。验证参数后原子写入配置文件并返回读取结果。 ```APIDOC ## setClientLaunchSettings(dataDir, profileId, body, platform) ### Description 设置客户端启动兼容设置。验证参数后原子写入配置文件并返回读取结果。 ### Method Function ### Signature `setClientLaunchSettings(dataDir, profileId, body, platform)` ### Parameters - **dataDir** (string) - Required - 数据目录路径 - **profileId** (string) - Required - Profile 标识 - **body** (object) - Required - 请求体 - **softwareRendering** (boolean) - Required - 软件渲染开关 - **platform** (string) - Required - 平台标识 ### Errors - body.softwareRendering 非布尔时抛 '软件渲染开关值必须是布尔值' - 不支持客户端时抛 '当前客户端不支持此兼容设置' ### Returns - (object) - 读取结果,包含 supported 和 softwareRendering 字段 ``` -------------------------------- ### GET /api/accounts/primary Source: https://github.com/babygoton/workdaddy Reads the primary account. ```APIDOC ## GET /api/accounts/primary ### Description Reads the primary account. ### Method GET ### Endpoint /api/accounts/primary ``` -------------------------------- ### getWorkBuddyLaunchEnv(profile, dataDir, platform, env) Source: https://github.com/babygoton/workdaddy 获取 WorkBuddy 子进程启动环境变量。仅 Windows 官方客户端生效,返回覆盖环境变量对象。 ```APIDOC ## getWorkBuddyLaunchEnv(profile, dataDir, platform, env) ### Description 获取 WorkBuddy 子进程启动环境变量。仅 Windows 官方客户端生效,返回覆盖环境变量对象。 ### Method Function ### Signature `getWorkBuddyLaunchEnv(profile, dataDir, platform = process.platform, env = process.env)` ### Parameters - **profile** (object) - Required - Profile 对象 - **id** (string) - Required - Profile 标识 - **dataRoot** (string) - Required - 数据根目录 - **customTarget** (boolean) - Required - 是否自定义目标 - **dataDir** (string) - Required - 数据目录路径 - **platform** (string) - Optional - 平台标识,默认为当前平台 - **env** (object) - Optional - 环境变量对象,默认为 process.env ### Errors - dataRoot/dataDir 非绝对路径时抛 '无法隔离 WorkBuddy 更新:客户端或 WorkDaddy 数据目录不是绝对路径' - 临时目录创建失败时抛 '无法创建 WorkBuddy 独立临时目录,请检查 WorkDaddy 数据目录的写入权限' ### Returns - (object) - 覆盖环境变量对象 - **WORKBUDDY_UPDATE_URL** (string) - 更新 URL - **WORKBUDDY_CONFIG_DIR** (string) - 配置目录 - **CODEBUDDY_CONFIG_DIR** (string) - 配置目录 - **WORKBUDDY_DATA_FOLDER_NAME** (string) - 数据文件夹名 - **TEMP** (string) - 临时目录 - **TMP** (string) - 临时目录 ``` -------------------------------- ### GET /api/update-download Source: https://github.com/babygoton/workdaddy Triggers the download of an update. ```APIDOC ## GET /api/update-download ### Description Triggers the download of an update. ### Method GET ### Endpoint /api/update-download ``` -------------------------------- ### installRendererBridge(binding) Source: https://github.com/babygoton/workdaddy Installs the renderer-side bridge functions on the window object. This function is serialized and injected into the renderer to provide the API fetch and reply mechanisms. ```APIDOC ## installRendererBridge(binding) ### Description Installs the renderer-side bridge functions on the window object. This function is serialized and injected into the renderer to provide the API fetch and reply mechanisms. ### Parameters - **binding** (string) - Required - The binding name to use ### Installs on window - `window.__wbsApiBridgeDispose()` - Cleans up pending requests and old reply handlers - `window.__wbsApiBridgeReply(reply)` - Dispatches responses; `reply.error` rejects with Error, otherwise constructs fetch-like Response with `{ ok, json(), blob(), headers.get }` - `window.__wbsApiFetch(path, options, token)` - Makes requests; automatically uses chunked upload protocol when `body` is a Blob and `path === '/api/sessions/import'` ### Timeout Single request timeout: 125s ``` -------------------------------- ### macOS 企業向けクライアントの高度な設定 (workbuddy-target.js) Source: https://github.com/babygoton/workdaddy/blob/main/README_ja.md macOS で名前が完全にカスタマイズされたアプリを対象にする場合に、ソースのディレクトリから実行する高度な設定コマンド。--configure フラグで設定し、--platform darwin、--profile workbuddy-cn、--binary にクライアントの実行ファイル、--data-dir にデータディレクトリを指定します。 ```bash node scripts/workbuddy-target.js --configure --platform darwin \ --profile workbuddy-cn \ --binary "/Applications/Enterprise Client.app/Contents/MacOS/Electron" \ --data-dir "$HOME/Library/Application Support/WorkDaddy" ``` -------------------------------- ### GET /api/inject Source: https://github.com/babygoton/workdaddy Probes the injection status. ```APIDOC ## GET /api/inject ### Description Probes the injection status. ### Method GET ### Endpoint /api/inject ``` -------------------------------- ### 按 profile 启动不同客户端(WBSWITCH_PROFILE) Source: https://github.com/babygoton/workdaddy/blob/main/README.md 四款客户端共用同一套 daemon,通过 WBSWITCH_PROFILE 环境变量绑定客户端,不靠第一个 CDP 端口猜测目标。分别对应 workbuddy-cn、workbuddy-ai、codebuddy-cn、codebuddy-intl 四个 profile。 ```bash WBSWITCH_PROFILE=workbuddy-cn bash scripts/relaunch-with-cdp.sh WBSWITCH_PROFILE=workbuddy-ai bash scripts/relaunch-with-cdp.sh WBSWITCH_PROFILE=codebuddy-cn bash scripts/relaunch-with-cdp.sh WBSWITCH_PROFILE=codebuddy-intl bash scripts/relaunch-with-cdp.sh ``` -------------------------------- ### 国际版 WorkBuddy AI 隔离环境安装与重启 Source: https://github.com/babygoton/workdaddy/blob/main/README.md 国际版 WorkBuddy AI 使用隔离环境时执行。需要指定 WBSWITCH_PROFILE 环境变量。 ```bash WBSWITCH_PROFILE=workbuddy-ai bash scripts/workbuddy-ai-linux.sh install bash scripts/workbuddy-ai-linux.sh relaunch ``` -------------------------------- ### Basic usage - refresh catalog and import Source: https://github.com/babygoton/workdaddy Shows how to create a discovery instance, force-refresh the catalog, and import the first task's content. Requires a DATA_DIR path and an importTasks function. ```javascript const { createAutomationDiscovery } = require('./automation-discovery.js'); const discovery = createAutomationDiscovery({ cacheFile: path.join(DATA_DIR, 'automation-discovery-cache.json') }); const catalog = await discovery.getCatalog({ force: true }); const imported = await importTasks(DATA_DIR, { content: discovery.getTaskContent(catalog.items[0].key), selected: ['0'] }, runtime); console.log(imported); ``` -------------------------------- ### GET /api/active-runs Source: https://github.com/babygoton/workdaddy Retrieves a summary of active runs. ```APIDOC ## GET /api/active-runs ### Description Retrieves a summary of active runs. ### Method GET ### Endpoint /api/active-runs ``` -------------------------------- ### getWorkBuddyLaunchEnv 返回的环境覆盖对象 Source: https://github.com/babygoton/workdaddy 仅 Windows 官方客户端生效(platform==='win32' && !profile.customTarget && has UPDATE_ORIGINS[profile.id])。dataRoot/dataDir 非绝对路径抛 '无法隔离 WorkBuddy 更新:客户端或 WorkDaddy 数据目录不是绝对路径'。临时目录创建失败抛 '无法创建 WorkBuddy 独立临时目录,请检查 WorkDaddy 数据目录的写入权限'。写入前删除继承环境中的同名大小写别名。 ```javascript { WORKBUDDY_UPDATE_URL: 'https://www.workbuddy.cn' | 'https://www.workbuddy.ai', WORKBUDDY_CONFIG_DIR: profile.dataRoot, CODEBUDDY_CONFIG_DIR: profile.dataRoot, WORKBUDDY_DATA_FOLDER_NAME: path.basename(profile.dataRoot), TEMP: path.join(dataDir, 'client-tmp', profile.id), TMP: path.join(dataDir, 'client-tmp', profile.id), } ``` -------------------------------- ### GET /api/batch-state Source: https://github.com/babygoton/workdaddy Retrieves batch operation status. ```APIDOC ## GET /api/batch-state ### Description Retrieves batch operation status. ### Method GET ### Endpoint /api/batch-state ``` -------------------------------- ### POST /api/client-launch-settings Source: https://github.com/babygoton/workdaddy Sets client launch settings. Returns 400/404 with error messages. ```APIDOC ## POST /api/client-launch-settings ### Description Sets client launch settings. Returns 400/404 with error messages. ### Method POST ### Endpoint /api/client-launch-settings ``` -------------------------------- ### GET /api/sentry-export Source: https://github.com/babygoton/workdaddy Exports Sentry sentinel reports. ```APIDOC ## GET /api/sentry-export ### Description Exports Sentry sentinel reports. ### Method GET ### Endpoint /api/sentry-export ``` -------------------------------- ### GET /api/credits/credit-stats Source: https://github.com/babygoton/workdaddy Retrieves credit and usage statistics. ```APIDOC ## GET /api/credits/credit-stats ### Description Retrieves credit and usage statistics. ### Method GET ### Endpoint /api/credits/credit-stats ``` -------------------------------- ### Run repository verification commands Source: https://github.com/babygoton/workdaddy/blob/main/AGENTS.md Run from the repository root to verify syntax, tests, and whitespace. PowerShell syntax and real installer/update smoke tests must be run on Windows (or with pwsh); do not claim those checks passed based only on macOS static inspection. ```bash node --check scripts/daemon.js node --check scripts/inject.js node --check scripts/win-launcher.js node --test test/*.test.js git diff --check ``` -------------------------------- ### GET /api/credits Source: https://github.com/babygoton/workdaddy Retrieves account credit information. ```APIDOC ## GET /api/credits ### Description Retrieves account credit information. ### Method GET ### Endpoint /api/credits ``` -------------------------------- ### linuxAppRoot(binary) Source: https://github.com/babygoton/workdaddy Returns the directory name of the given binary path. Used to determine the application root (e.g., /opt/WorkBuddy for official packages). ```APIDOC ## linuxAppRoot(binary) ### Description Returns the directory name of the given binary path. Used to determine the application root (e.g., /opt/WorkBuddy for official packages). ### Parameters - **binary** (string) - Required - The binary path ### Returns - **string** - The directory containing the binary ``` -------------------------------- ### GET /api/wallpaper-rotation/image Source: https://github.com/babygoton/workdaddy Retrieves the current wallpaper image. ```APIDOC ## GET /api/wallpaper-rotation/image ### Description Retrieves the current wallpaper image. ### Method GET ### Endpoint /api/wallpaper-rotation/image ``` -------------------------------- ### switchTo(dataDir, uid, log) Source: https://github.com/babygoton/workdaddy 切换到指定备份账号。该函数会校验备份文件、解密并验证账号身份,然后原子写入登录文件,必要时通过 osascript 委托 GUI 会话写入。 ```APIDOC ## switchTo(dataDir, uid, log) ### Description 切换到指定备份账号。该函数会校验备份文件、解密并验证账号身份,然后原子写入登录文件,必要时通过 osascript 委托 GUI 会话写入。 ### Method Function ### Signature ```js function switchTo(dataDir, uid, log = () => {}) ``` ### Parameters - **dataDir** (string) - Required - WorkDaddy 数据目录 - **uid** (string) - Required - 备份账号的 `accountId`(见 account-identity.md) - **log** (function) - Optional - 日志回调 ### Returns `{ uid, rawUid, type, enterpriseId, nickname, uin, authFile }` ### Throws - `${ACTIVE_PROFILE.name} 暂不支持账号切换` - 当 profile 无 `accounts` 能力时 - `未找到账号 ${uid} 的备份文件` - 当备份文件不存在时 - `'备份文件校验失败:uid 不匹配,已中止切换'` - 当备份内 account 的 identity 不一致时 - `'备份文件认证数据无效,拒绝切换'` - 当 auth 解析失败时 - `'写入登录文件失败...'` - 当直写与 osascript 回退均失败时 ``` -------------------------------- ### GET /api/wallpaper-rotation Source: https://github.com/babygoton/workdaddy Reads wallpaper rotation configuration. ```APIDOC ## GET /api/wallpaper-rotation ### Description Reads wallpaper rotation configuration. ### Method GET ### Endpoint /api/wallpaper-rotation ``` -------------------------------- ### GET /api/automations/agent-info Source: https://github.com/babygoton/workdaddy Retrieves agent bridge information. ```APIDOC ## GET /api/automations/agent-info ### Description Retrieves agent bridge information. ### Method GET ### Endpoint /api/automations/agent-info ``` -------------------------------- ### GET /api/automations Source: https://github.com/babygoton/workdaddy Retrieves the list of automation tasks. ```APIDOC ## GET /api/automations ### Description Retrieves the list of automation tasks. ### Method GET ### Endpoint /api/automations ``` -------------------------------- ### GET /api/sessions/dirty Source: https://github.com/babygoton/workdaddy Returns the dirty session index. ```APIDOC ## GET /api/sessions/dirty ### Description Returns the dirty session index. ### Method GET ### Endpoint /api/sessions/dirty ``` -------------------------------- ### Enterprise custom target merge (getProfile with options) Source: https://github.com/babygoton/workdaddy Simulates daemon startup behavior by passing a custom dataDir. If customTarget is set, apiHost and appPath come from workbuddy-target.json. ```javascript const { getProfile } = require('./profiles.js'); const custom = getProfile('workbuddy-cn', { dataDir: '/Users/x/Library/Application Support/WorkDaddy', }); if (custom.customTarget) { // 企业专享版:apiHost 与 appPath 来自 workbuddy-target.json console.log('目标客户端:', custom.appPath, '绑定 API:', custom.apiHost); } ``` -------------------------------- ### GET /api/models/third-party 发现响应示例 Source: https://github.com/babygoton/workdaddy 展示发现第三方模型源时的 JSON 响应,包含来源 ID、名称、文件路径和格式。 ```json { "ok": true, "sources": [ { "id": "cc-switch", "name": "CC Switch", "file": "/...", "format": "sqlite" } ] } ``` -------------------------------- ### Rebuild commands for scripts/toast-runtime.js Source: https://github.com/babygoton/workdaddy/blob/main/tools/toast-runtime/README.md Run npm ci with ignore-scripts in the tools/toast-runtime prefix, then run the build script to regenerate the bundled runtime file. ```sh npm ci --ignore-scripts --prefix tools/toast-runtime node tools/toast-runtime/build.mjs ``` -------------------------------- ### pickLinuxDataRoot(candidates) Source: https://github.com/babygoton/workdaddy Selects the best data root from candidates. Prefers paths containing workbuddy.db, then app/, then existing directories, then the first candidate. ```APIDOC ## pickLinuxDataRoot(candidates) ### Description Selects the best data root from candidates. Prefers paths containing workbuddy.db, then app/, then existing directories, then the first candidate. ### Parameters - **candidates** (string[]) - Required - Array of candidate paths ### Returns - **string** - The selected data root path ``` -------------------------------- ### GET /api/automations/run-status Source: https://github.com/babygoton/workdaddy Retrieves the run status of automation tasks. ```APIDOC ## GET /api/automations/run-status ### Description Retrieves the run status of automation tasks. ### Method GET ### Endpoint /api/automations/run-status ``` -------------------------------- ### planFork 函数签名 Source: https://github.com/babygoton/workdaddy options.suffix 默认 '(分支)'。返回分叉方案对象:ok: true 时包含 anchor, anchors, records, skipped, keep, drop, keptRecords, droppedRecords, text(新记录文本,保留原始行);ok: false 时包含 reason(可能值:'会话记录为空'、'会话里没有可分叉的消息'、'锚点没解析出来:${spec}'、'分叉点之前没有可保留的消息')。 ```javascript function planFork(text, spec, options = {}) // options.suffix 默认 '(分支)' ``` -------------------------------- ### GET /api/sessions/auto-copy/active Source: https://github.com/babygoton/workdaddy Returns the currently active copy task. ```APIDOC ## GET /api/sessions/auto-copy/active ### Description Returns the currently active copy task. ### Method GET ### Endpoint /api/sessions/auto-copy/active ``` -------------------------------- ### GET /api/devtools-url Source: https://github.com/babygoton/workdaddy Returns the current debug page URL. ```APIDOC ## GET /api/devtools-url ### Description Returns the current debug page URL. ### Method GET ### Endpoint /api/devtools-url ``` -------------------------------- ### looksLikeSiblingRoot / linuxDataRootCandidates / pickLinuxDataRoot 函数签名 Source: https://github.com/babygoton/workdaddy looksLikeSiblingRoot 判断值是否为兄弟端根(AI 端只接受带 ai 的根,CN 端反之);linuxDataRootCandidates 生成三级候选;pickLinuxDataRoot 优先含 workbuddy.db → 含 app/ → 目录存在 → 首个候选。 ```javascript function looksLikeSiblingRoot(value, isAiProfile) { const raw = String(value || '').replace(/[/\\]+$/, ''); const base = path.basename(raw).toLowerCase(); if (!base) return true; // 空值一律视为不可用 const aiNamed = base.includes('ai'); return isAiProfile ? !aiNamed : aiNamed; // AI 端只接受带 ai 的根;CN 端反之 } function linuxDataRootCandidates(kind, options = {}) // { env, home, xdgConfigHome } function pickLinuxDataRoot(candidates) // 优先含 workbuddy.db → 含 app/ → 目录存在 → 首个候选 ``` -------------------------------- ### POST /api/oauth/start Source: https://github.com/babygoton/workdaddy Starts the OAuth silent login flow. ```APIDOC ## POST /api/oauth/start ### Description Starts the OAuth silent login flow. ### Method POST ### Endpoint /api/oauth/start ``` -------------------------------- ### linuxAppBinary(kind) Source: https://github.com/babygoton/workdaddy Returns the first existing candidate binary path for the given kind on Linux. If none exist, returns the preferred path (which may be an empty string). ```APIDOC ## linuxAppBinary(kind) ### Description Returns the first existing candidate binary path for the given kind on Linux. If none exist, returns the preferred path (which may be an empty string). ### Parameters - **kind** (string) - Required - The kind of application ### Returns - **string** - The binary path, or empty string if no candidate exists ``` -------------------------------- ### departBuddyTravel Source: https://github.com/babygoton/workdaddy Starts a buddy travel. This function is part of the growth-daily module. ```APIDOC ## departBuddyTravel ### Description Starts a buddy travel. This function is part of the growth-daily module. ### Method Function ### Signature `departBuddyTravel(...)` ### Parameters No parameters documented. ### Returns No return value documented. ``` -------------------------------- ### GET /api/models/third-party Source: https://github.com/babygoton/workdaddy Discovers third-party model sources (CC Switch/Codex). ```APIDOC ## GET /api/models/third-party ### Description Discovers third-party model sources (CC Switch/Codex). ### Method GET ### Endpoint /api/models/third-party ``` -------------------------------- ### Basic usage: validate and preview a package Source: https://github.com/babygoton/workdaddy Imports previewPackage, calls it with a package document and options (values, runtime), then checks compatibility and logs the task id or issues. Requires the package document to be defined. ```javascript const { previewPackage } = require('./automation-packages.js'); const preview = previewPackage(packageDocument, { values: { label: '我的概况' }, runtime: { version: '1.1.91', profileId: 'workbuddy-cn', platform: process.platform }, }); if (preview.compatible) { console.log('可以导入,任务:', preview.task.id); } else { for (const issue of preview.issues) console.error(issue.code, issue); } ``` -------------------------------- ### GET /api/session-module Source: https://github.com/babygoton/workdaddy Returns the session enhancement module switch status. ```APIDOC ## GET /api/session-module ### Description Returns the session enhancement module switch status. ### Method GET ### Endpoint /api/session-module ``` -------------------------------- ### List release artifacts Source: https://github.com/babygoton/workdaddy/blob/main/AGENTS.md The expected set of files to be delivered after a successful build process. ```text release/windows/WorkDaddy-Setup-.exe release/windows/WorkDaddy-AI-Setup-.exe release/windows/WorkDaddy-Portable-.zip release/windows/WorkDaddy-AI-Portable-.zip ``` -------------------------------- ### activateGrowthAccount 函数签名与选项注释 Source: https://github.com/babygoton/workdaddy 用于通过备份账号 token 发起独立 cloud conversation。options 可指定 apiHost(默认 https://www.workbuddy.cn)、fetchImpl、timeoutMs、prompt、model、purpose。accessToken 缺失或 fetchImpl 非函数时抛出 '成长活跃发起参数不完整'。prompt 默认 '你好',model 默认 'deepseek-r1';purpose 为 'completion-report' 时 prompt 截到 2000 字符,否则 100 字符。 ```javascript async function activateGrowthAccount(accessToken, options = {}) // options: { apiHost(默认 https://www.workbuddy.cn), fetchImpl, timeoutMs, prompt, model, purpose } // accessToken 缺失或 fetchImpl 非函数 → throw '成长活跃发起参数不完整' ``` -------------------------------- ### GET /api/sessions/auto-copy Source: https://github.com/babygoton/workdaddy Reads auto-copy rules at space or session level. ```APIDOC ## GET /api/sessions/auto-copy ### Description Reads auto-copy rules at space or session level. ### Method GET ### Endpoint /api/sessions/auto-copy ``` -------------------------------- ### window.__wbsApiFetch(path, options, token) Source: https://github.com/babygoton/workdaddy Local API bridge function for renderer-side fetch. ```APIDOC ## Function: __wbsApiFetch(path, options, token) ### Description Local API bridge (see renderer-api-bridge.md). ### Parameters - **path** (string) - Required - API path - **options** (object) - Required - Fetch options - **token** (string) - Required - API token ### Returns Promise ### Example ```js const res = await window.__wbsApiFetch('/api/data', { method: 'GET' }, 'token'); ``` ``` -------------------------------- ### GET /api/update-check Source: https://github.com/babygoton/workdaddy Checks for updates. This endpoint is public and does not require authentication. ```APIDOC ## GET /api/update-check ### Description Checks for updates. This endpoint is public and does not require authentication. ### Method GET ### Endpoint /api/update-check ``` -------------------------------- ### GET /api/about Source: https://github.com/babygoton/workdaddy Returns about information. This endpoint is public and does not require authentication. ```APIDOC ## GET /api/about ### Description Returns about information. This endpoint is public and does not require authentication. ### Method GET ### Endpoint /api/about ``` -------------------------------- ### Run release verification checks Source: https://github.com/babygoton/workdaddy/blob/main/AGENTS.md Execute syntax checks and test suites to validate the integrity of the scripts and the repository state before final handoff. ```powershell node --check scripts/daemon.js node --check scripts/inject.js node --check scripts/win-launcher.js node --check scripts/watchdog.js node --test test/*.test.js git diff --check ``` -------------------------------- ### planForkAtMessage 函数签名 Source: https://github.com/babygoton/workdaddy 按 renderer 消息位置分叉。selection 形如 { roles, messageIndex, finishedAt }:roles 是 ^[ua]{2,10000}$ 的角色串(首 u 尾 a),messageIndex 为 assistant 消息位置,finishedAt 为完成时间戳(跨表示匹配的稳定键)。失败返回 { ok: false, reason },reason 可能为 '分支消息参数无效'、'会话记录正在写入或包含损坏的行,请稍后重试'、'无法确认所选消息的分支位置'、'所选消息没有可分支的正文'。 ```javascript function planForkAtMessage(text, selection) ```