dsh-jobs 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 mergedao
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,20 +1,102 @@
1
- # dsh-jobs
1
+ <h1 align="center">dsh-jobs</h1>
2
2
 
3
- [![npm](https://img.shields.io/npm/v/dsh-jobs.svg)](https://www.npmjs.com/package/dsh-jobs)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](#license)
3
+ <p align="center"><strong>在 DeepSeek Harness(dsh)里用原生面板查职位,把投递追踪和新岗巡检放进同一个工作台。</strong></p>
5
4
 
6
- **Background jobs for dsh bots** - a plugin for the [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (`dsh`).
5
+ <p align="center">BOSS 直聘 · 猎聘 · 前程无忧(51job)· 智联招聘</p>
7
6
 
8
- This package name is reserved; the first release is in development.
7
+ <p align="center">
8
+ <a href="https://github.com/mergedao/dsh-jobs/stargazers"><img src="https://img.shields.io/github/stars/mergedao/dsh-jobs?style=flat-square&amp;logo=github&amp;label=Stars" alt="GitHub Stars"></a>
9
+ <a href="https://www.npmjs.com/package/dsh-jobs"><img src="https://img.shields.io/npm/v/dsh-jobs?style=flat-square&amp;logo=npm&amp;label=dsh-jobs" alt="dsh-jobs npm 版本"></a>
10
+ <a href="https://www.npmjs.com/package/dsh-jobs"><img src="https://img.shields.io/npm/dm/dsh-jobs?style=flat-square&amp;label=Downloads%20%2F%20month" alt="npm 近 30 天下载量"></a>
11
+ <a href="https://github.com/mergedao/dsh-jobs/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-475569?style=flat-square" alt="MIT License"></a>
12
+ </p>
9
13
 
10
- The execution half of the bot framework - queued and recurring runs with logs, retries, and a dead-letter view.
14
+ <p align="center">
15
+ <a href="#安装与挂载">安装与挂载</a> ·
16
+ <a href="#dsh-原生工作台">DSH 原生工作台</a> ·
17
+ <a href="#agent-工具与命令">Agent 工具与命令</a> ·
18
+ <a href="#如何读懂搜索与覆盖状态">覆盖与诊断</a> ·
19
+ <a href="#开发与测试">开发与测试</a> ·
20
+ <a href="#english">English</a>
21
+ </p>
11
22
 
12
- Source and roadmap live in the [dsh-plugin monorepo](https://github.com/dushaobindoudou/dsh-plugin).
13
- Watch the repo or the npm package to catch the release. Related releases from
14
- the same suite: [dsh-workflow](https://www.npmjs.com/package/dsh-workflow),
15
- [dsh-selfrepair](https://www.npmjs.com/package/dsh-selfrepair),
16
- [dsh-finder](https://www.npmjs.com/package/dsh-finder).
23
+ ## 安装与挂载
24
+
25
+ **`dsh-jobs` 是面向 DeepSeek Harness(`dsh`)的原生求职插件**,内置零 Playwright 裸 CDP 采集引擎、DSH 原生 Web UI 工作台、8 个 Agent Tools、`/jobs` 斜杠命令以及同步版 [SKILL.md](skills/find-jobs/SKILL.md)。需要 **Node.js 22.12+**。
26
+
27
+ ### 作为 DSH 插件安装
28
+
29
+ ```bash
30
+ dsh plugin install dsh-jobs
31
+ ```
32
+
33
+ 或者在你的 DSH profile `cordis.yml` 中引入(插件自带 [cordis.patch.yml](cordis.patch.yml)):
34
+
35
+ ```yaml
36
+ - id: plugin-jobs
37
+ name: dsh-jobs
38
+ config:
39
+ dataDir: '~/.mcp-jobs'
40
+ defaultCity: '北京'
41
+ defaultAccountId: 'personal'
42
+ ```
43
+
44
+ `dataDir` 默认与 `mcp-jobs` / `skill-jobs` 共用 `~/.mcp-jobs`,持久化浏览器 Profile、本地投递追踪记录与新岗巡检基线完全互通。
45
+
46
+ ## DSH 原生工作台
47
+
48
+ 插件通过 DSH `sidebar.panellist` 与 `main` 槽位挂载原生 Web UI,自动适配 DSH 宿主亮/暗色主题(`--dsw-alias-*` Design Tokens),包含四个标签页:
49
+
50
+ | 面板标签 | 核心能力 |
51
+ | --- | --- |
52
+ | **职位搜索** | 四站并发实时搜岗,支持关键词、城市、薪资、经验筛选;展示每站覆盖状态胶囊与 `diagnostics` 诊断详情;支持一键查 JD、建档待投、原站打开 |
53
+ | **新岗巡检** | 按关键词/城市/平台执行 `watch-check`,首次建立基线,之后展示增量新岗,并强制展示「完整覆盖 / 部分覆盖」与未覆盖平台列表 |
54
+ | **投递追踪** | 按平台切换查看本地已建档(`prepared`)与已投递记录、更新时间及原站链接 |
55
+ | **浏览器与诊断** | 查看本机 Chrome/Edge 裸 CDP 连接状态、持久化 Profile 目录、四站 Cookie 线索;一键打开/重开浏览器、登录监听与优雅关闭 |
56
+
57
+ ## Agent 工具与命令
58
+
59
+ ### 原生 Agent Tools
60
+
61
+ | 工具名 | 用途 |
62
+ | --- | --- |
63
+ | `jobs_search` | 从 BOSS 直聘、猎聘、51job、智联原站实时搜岗,自动区分登录失效与抓包超时,抓包失败自动降级读已渲染 DOM |
64
+ | `jobs_detail` | 读取官方职位详情页完整 JD |
65
+ | `jobs_profile_status` | 查看 CDP 连接、持久化 Profile 及四站 Cookie 线索(页面真实渲染状态优先) |
66
+ | `jobs_login` | 在持久化 Profile 的真实浏览器打开官方登录页并持续监听登录状态(仅前台交互使用) |
67
+ | `jobs_open_browser` | 沿用原 Profile 打开/置前真实浏览器,用于重开浏览器或人工处理安全验证 |
68
+ | `jobs_applications` | 分平台与 `accountId` 查询本地投递追踪记录 |
69
+ | `jobs_prepare_apply` | 为目标岗位本地建档待投(`prepared`) |
70
+ | `jobs_watch_check` | 巡检指定条件的新增岗位并返回 `coverageSummary` |
71
+
72
+ ### 斜杠命令
73
+
74
+ - `/jobs status`:查看本机 CDP 连接状态、持久化 Profile 与四站线索
75
+ - `/jobs doctor`:输出环境与浏览器模式诊断 JSON
76
+ - `/jobs <关键词>`:快速执行四站搜岗并输出覆盖状态与前 8 条结果
77
+
78
+ ## 如何读懂搜索与覆盖状态
79
+
80
+ - **零 Playwright 裸 CDP 架构**:复用本机真实 Chrome/Edge 持久化 Profile,仅附加最小协议域(`Network` / `Page` / `Storage` / `DOM`),不启用 `Runtime` 域,最大限度避免风控探测。
81
+ - **严格区分「抓包失败」与「需要登录」**:
82
+ - `capture_timeout` / `capture_failed` / `parse_empty` 表示已连接浏览器但本次未捕获到接口响应或解析为空,**不是登录失效**,也不代表无新增岗位;附带 `diagnostics`(等待耗时 `waitMs`、匹配请求数 `matchedRequestCount`、响应体长度 `bodyLength`、最终 URL)。
83
+ - 只有站点明确返回登录错误码或页面真实跳转到登录页时才判 `login_required`。
84
+ - **已渲染 DOM 自动降级**:接口抓包超时或取体失败时,自动通过纯协议侧 `DOM.getOuterHTML` 降级提取已渲染职位卡片,标记 `coverage: "rendered_dom"`。
85
+ - **定时任务与覆盖汇总**:每次搜索和巡检都会返回 `coverageSummary`(`status: "full" | "partial" | "none"`、`coveredPlatforms`、`uncoveredPlatforms`、`countsByPlatform`)。覆盖不足时状态为「部分覆盖」,未覆盖平台记为「本轮未覆盖」,绝不误报为「无新增岗位」。
86
+
87
+ ## 开发与测试
88
+
89
+ ```bash
90
+ npm run build # 同步引擎 bundle 并编译 client.js(esbuild -> DSH __ModuleLoader__ IIFE)
91
+ npm test # 运行 Host 插件、Tools、/jobs 命令、引擎与 client.js 产物测试
92
+ ```
93
+
94
+ - 反馈问题请附上平台名、插件版本、来源 `status` 与 `diagnostics`。[提交 Issue](https://github.com/mergedao/dsh-jobs/issues/new)
95
+
96
+ ## English
97
+
98
+ **dsh-jobs** is a native DeepSeek Harness (`dsh`) plugin for all-site job search, application tracking, and scheduled new-job watch loops across BOSS Zhipin, Liepin, 51job, and Zhaopin. It ships a native DSH Web UI workbench (`sidebar.panellist` + `main`), 8 agent tools (`jobs_*`), the `/jobs` slash command, and a zero-Playwright raw-CDP capture engine with rendered-DOM fallback and explicit coverage diagnostics.
17
99
 
18
100
  ## License
19
101
 
20
- MIT
102
+ MIT. Built on [mergedao/mcp-jobs](https://github.com/mergedao/mcp-jobs).
package/client.js ADDED
@@ -0,0 +1,278 @@
1
+ /* eslint-disable */
2
+ /** dsh-jobs — client half (web). BUILD ARTIFACT — edit src/client/ and run npm run build. */
3
+ window.__ModuleLoader__.load({
4
+ id: 'dsh-jobs',
5
+ factory(__shellRequire) {
6
+ const module = { exports: {} }
7
+ const exports = module.exports
8
+ const require = (id) => __shellRequire(id)
9
+ var __create = Object.create;
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __getProtoOf = Object.getPrototypeOf;
14
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
15
+ var __export = (target, all) => {
16
+ for (var name in all)
17
+ __defProp(target, name, { get: all[name], enumerable: true });
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") {
21
+ for (let key of __getOwnPropNames(from))
22
+ if (!__hasOwnProp.call(to, key) && key !== except)
23
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
24
+ }
25
+ return to;
26
+ };
27
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
28
+ // If the importer is in node compatibility mode or this is not an ESM
29
+ // file that has been converted to a CommonJS file using a Babel-
30
+ // compatible transform (i.e. "__esModule" has not been set), then set
31
+ // "default" to the CommonJS "module.exports" for node compatibility.
32
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
33
+ mod
34
+ ));
35
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
+
37
+ // src/client/index.tsx
38
+ var index_exports = {};
39
+ __export(index_exports, {
40
+ apply: () => apply,
41
+ inject: () => inject
42
+ });
43
+ module.exports = __toCommonJS(index_exports);
44
+ var React2 = __toESM(require("react"), 1);
45
+
46
+ // src/client/styles.css
47
+ var styles_default = ".dsh-jobs-root {\n display: flex;\n flex-direction: column;\n height: 100%;\n min-height: 0;\n background: var(--dsw-alias-bg-base, #ffffff);\n color: var(--dsw-alias-label-primary, #111827);\n font-family: inherit;\n font-size: 13px;\n}\n\n.dsh-jobs-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n padding: 14px 20px;\n border-bottom: 1px solid var(--dsw-alias-border-l1, rgba(128, 128, 128, 0.18));\n flex-shrink: 0;\n}\n\n.dsh-jobs-title-group {\n display: flex;\n align-items: center;\n gap: 10px;\n}\n\n.dsh-jobs-title {\n font-size: 16px;\n font-weight: 600;\n margin: 0;\n}\n\n.dsh-jobs-subtitle {\n font-size: 12px;\n color: var(--dsw-alias-label-secondary, #6b7280);\n}\n\n.dsh-jobs-tabs {\n display: flex;\n gap: 6px;\n}\n\n.dsh-jobs-tab {\n padding: 6px 12px;\n border-radius: 8px;\n border: 1px solid transparent;\n background: transparent;\n color: var(--dsw-alias-label-secondary, #6b7280);\n cursor: pointer;\n font-size: 13px;\n font-weight: 500;\n}\n\n.dsh-jobs-tab:hover {\n background: var(--dsw-alias-bg-elevated, rgba(128, 128, 128, 0.08));\n color: var(--dsw-alias-label-primary, #111827);\n}\n\n.dsh-jobs-tab.is-active {\n background: var(--dsw-alias-brand-primary, #111827);\n color: var(--dsw-alias-label-primary-foreground, #ffffff);\n}\n\n.dsh-jobs-body {\n flex: 1;\n min-height: 0;\n overflow-y: auto;\n padding: 18px 20px 28px;\n display: flex;\n flex-direction: column;\n gap: 16px;\n}\n\n.dsh-jobs-card {\n border: 1px solid var(--dsw-alias-border-l1, rgba(128, 128, 128, 0.2));\n border-radius: 12px;\n padding: 14px 16px;\n background: var(--dsw-alias-bg-elevated, rgba(128, 128, 128, 0.04));\n}\n\n.dsh-jobs-row {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 10px;\n}\n\n.dsh-jobs-input {\n padding: 7px 10px;\n border-radius: 8px;\n border: 1px solid var(--dsw-alias-border-l2, rgba(128, 128, 128, 0.28));\n background: var(--dsw-alias-bg-base, #ffffff);\n color: var(--dsw-alias-label-primary, #111827);\n font-size: 13px;\n min-width: 140px;\n}\n\n.dsh-jobs-btn {\n padding: 7px 14px;\n border-radius: 8px;\n border: 1px solid var(--dsw-alias-border-l2, rgba(128, 128, 128, 0.28));\n background: var(--dsw-alias-bg-base, #ffffff);\n color: var(--dsw-alias-label-primary, #111827);\n cursor: pointer;\n font-size: 13px;\n font-weight: 500;\n}\n\n.dsh-jobs-btn:disabled {\n opacity: 0.55;\n cursor: not-allowed;\n}\n\n.dsh-jobs-btn.is-primary {\n background: var(--dsw-alias-brand-primary, #111827);\n color: var(--dsw-alias-label-primary-foreground, #ffffff);\n border-color: transparent;\n}\n\n.dsh-jobs-pill {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 3px 9px;\n border-radius: 999px;\n font-size: 12px;\n border: 1px solid var(--dsw-alias-border-l1, rgba(128, 128, 128, 0.22));\n}\n\n.dsh-jobs-pill.is-ok {\n color: var(--dsw-alias-state-success-primary, #15803d);\n border-color: var(--dsw-alias-state-success-primary, #15803d);\n}\n\n.dsh-jobs-pill.is-warn {\n color: var(--dsw-alias-state-warn-primary, #b45309);\n border-color: var(--dsw-alias-state-warn-primary, #b45309);\n}\n\n.dsh-jobs-pill.is-danger {\n color: var(--dsw-alias-state-danger-primary, #b91c1c);\n border-color: var(--dsw-alias-state-danger-primary, #b91c1c);\n}\n\n.dsh-jobs-list {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.dsh-jobs-item {\n border: 1px solid var(--dsw-alias-border-l1, rgba(128, 128, 128, 0.18));\n border-radius: 10px;\n padding: 12px 14px;\n background: var(--dsw-alias-bg-base, #ffffff);\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n gap: 12px;\n}\n\n.dsh-jobs-item-title {\n font-size: 14px;\n font-weight: 600;\n margin: 0 0 4px;\n}\n\n.dsh-jobs-item-meta {\n font-size: 12px;\n color: var(--dsw-alias-label-secondary, #6b7280);\n display: flex;\n flex-wrap: wrap;\n gap: 10px;\n}\n\n.dsh-jobs-salary {\n color: var(--dsw-alias-state-warn-primary, #b45309);\n font-weight: 600;\n}\n\n.dsh-jobs-detail-box {\n white-space: pre-wrap;\n line-height: 1.55;\n font-size: 13px;\n max-height: 300px;\n overflow-y: auto;\n margin-top: 10px;\n padding-top: 10px;\n border-top: 1px solid var(--dsw-alias-border-l1, rgba(128, 128, 128, 0.16));\n}\n\n.dsh-jobs-entry-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n border: none;\n background: transparent;\n color: inherit;\n cursor: pointer;\n padding: 0;\n}\n";
48
+
49
+ // src/client/app.tsx
50
+ var React = __toESM(require("react"), 1);
51
+ var ALL_PLATFORMS = [
52
+ { id: "zhipin", label: "BOSS \u76F4\u8058" },
53
+ { id: "liepin", label: "\u730E\u8058" },
54
+ { id: "51job", label: "\u524D\u7A0B\u65E0\u5FE7 51job" },
55
+ { id: "zhaopin", label: "\u667A\u8054\u62DB\u8058" }
56
+ ];
57
+ function statusBadge(source) {
58
+ const st = String(source?.status ?? "unknown");
59
+ if (st === "ok") {
60
+ return {
61
+ label: source?.coverage === "rendered_dom" ? `DOM\u964D\u7EA7 (${source.count ?? 0})` : `API\u6B63\u5E38 (${source.count ?? 0})`,
62
+ tone: "ok"
63
+ };
64
+ }
65
+ if (st === "empty") return { label: "\u65E0\u5339\u914D (0)", tone: "ok" };
66
+ if (st === "capture_timeout" || st === "capture_failed" || st === "parse_empty") {
67
+ return { label: `\u6293\u5305\u672A\u6355\u83B7 (${st})`, tone: "warn" };
68
+ }
69
+ if (st === "login_required") return { label: "\u9700\u767B\u5F55", tone: "danger" };
70
+ if (st === "access_restricted") return { label: "\u9700\u5B89\u5168\u9A8C\u8BC1", tone: "warn" };
71
+ if (st === "rate_limited") return { label: "\u89E6\u53D1\u9891\u63A7", tone: "warn" };
72
+ return { label: st, tone: "warn" };
73
+ }
74
+ function JobsApp({ callRpc }) {
75
+ const [tab, setTab] = React.useState("search");
76
+ const [keyword, setKeyword] = React.useState("FDE");
77
+ const [city, setCity] = React.useState("\u5317\u4EAC");
78
+ const [salary, setSalary] = React.useState("");
79
+ const [workYear, setWorkYear] = React.useState("");
80
+ const [selectedPlatforms, setSelectedPlatforms] = React.useState(["zhipin", "liepin", "51job", "zhaopin"]);
81
+ const [loading, setLoading] = React.useState(false);
82
+ const [error, setError] = React.useState(null);
83
+ const [searchRes, setSearchRes] = React.useState(null);
84
+ const [detailRes, setDetailRes] = React.useState(null);
85
+ const [watchRes, setWatchRes] = React.useState(null);
86
+ const [appPlatform, setAppPlatform] = React.useState("zhipin");
87
+ const [appsRes, setAppsRes] = React.useState(null);
88
+ const [profileRes, setProfileRes] = React.useState(null);
89
+ const [notice, setNotice] = React.useState(null);
90
+ const togglePlatform = (p) => {
91
+ setSelectedPlatforms(
92
+ (prev) => prev.includes(p) ? prev.length > 1 ? prev.filter((x) => x !== p) : prev : [...prev, p]
93
+ );
94
+ };
95
+ const runAction = async (fn) => {
96
+ setLoading(true);
97
+ setError(null);
98
+ setNotice(null);
99
+ try {
100
+ await fn();
101
+ } catch (err) {
102
+ setError(String(err?.message ?? err));
103
+ } finally {
104
+ setLoading(false);
105
+ }
106
+ };
107
+ const handleSearch = () => runAction(async () => {
108
+ const res = await callRpc("search", {
109
+ keyword: keyword.trim(),
110
+ city: city.trim() || void 0,
111
+ platforms: selectedPlatforms,
112
+ ...salary.trim() ? { salary: salary.trim() } : {},
113
+ ...workYear.trim() ? { workYear: workYear.trim() } : {}
114
+ });
115
+ setSearchRes(res);
116
+ });
117
+ const handleWatchCheck = () => runAction(async () => {
118
+ const res = await callRpc("watchCheck", {
119
+ keyword: keyword.trim(),
120
+ city: city.trim() || void 0,
121
+ platforms: selectedPlatforms
122
+ });
123
+ setWatchRes(res);
124
+ });
125
+ const handleLoadApps = (platform = appPlatform) => runAction(async () => {
126
+ setAppPlatform(platform);
127
+ const res = await callRpc("applications", { platform });
128
+ setAppsRes(res);
129
+ });
130
+ const handleLoadProfile = () => runAction(async () => {
131
+ const res = await callRpc("profileStatus", {});
132
+ setProfileRes(res);
133
+ });
134
+ const handlePrepareApply = (job) => runAction(async () => {
135
+ const res = await callRpc("prepareApply", {
136
+ platform: job.source,
137
+ url: job.jobDetail,
138
+ title: job.title,
139
+ company: job.company
140
+ });
141
+ setNotice(res?.application?.status === "already_tracked" ? "\u8BE5\u5C97\u4F4D\u5DF2\u5728\u672C\u5730\u8FFD\u8E2A\u5217\u8868\u4E2D" : `\u5DF2\u5EFA\u6863\u5F85\u6295\uFF1A${job.title}`);
142
+ });
143
+ const handleReadDetail = (url) => runAction(async () => {
144
+ const res = await callRpc("detail", { url });
145
+ setDetailRes({ url, data: res });
146
+ });
147
+ const handleLoginPlatform = (platform) => runAction(async () => {
148
+ const res = await callRpc("login", { platform, waitSeconds: 60 });
149
+ setNotice(`${platform} \u767B\u5F55\u72B6\u6001\uFF1A${res?.status ?? "done"}${res?.detail ? ` \u2014 ${res.detail}` : ""}`);
150
+ const refreshed = await callRpc("profileStatus", {});
151
+ setProfileRes(refreshed);
152
+ });
153
+ const handleOpenBrowser = (platform, url) => runAction(async () => {
154
+ const res = await callRpc("openBrowser", { ...platform ? { platform } : {}, ...url ? { url } : {} });
155
+ setNotice(res?.detail || res?.status || "\u5DF2\u89E6\u53D1\u6253\u5F00\u771F\u5B9E\u6D4F\u89C8\u5668");
156
+ const refreshed = await callRpc("profileStatus", {});
157
+ setProfileRes(refreshed);
158
+ });
159
+ React.useEffect(() => {
160
+ if (tab === "browser" && !profileRes) void handleLoadProfile();
161
+ if (tab === "applications" && !appsRes) void handleLoadApps(appPlatform);
162
+ }, [tab]);
163
+ return /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-root" }, /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-header" }, /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-title-group" }, /* @__PURE__ */ React.createElement("h1", { className: "dsh-jobs-title" }, "\u627E\u5DE5\u4F5C\u5DE5\u4F5C\u53F0"), /* @__PURE__ */ React.createElement("span", { className: "dsh-jobs-subtitle" }, "BOSS \xB7 \u730E\u8058 \xB7 51job \xB7 \u667A\u8054\uFF08\u88F8 CDP \u539F\u7AD9\u5B9E\u65F6\uFF09")), /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-tabs" }, /* @__PURE__ */ React.createElement("button", { className: `dsh-jobs-tab ${tab === "search" ? "is-active" : ""}`, onClick: () => setTab("search") }, "\u804C\u4F4D\u641C\u7D22"), /* @__PURE__ */ React.createElement("button", { className: `dsh-jobs-tab ${tab === "watch" ? "is-active" : ""}`, onClick: () => setTab("watch") }, "\u65B0\u5C97\u5DE1\u68C0"), /* @__PURE__ */ React.createElement("button", { className: `dsh-jobs-tab ${tab === "applications" ? "is-active" : ""}`, onClick: () => setTab("applications") }, "\u6295\u9012\u8FFD\u8E2A"), /* @__PURE__ */ React.createElement("button", { className: `dsh-jobs-tab ${tab === "browser" ? "is-active" : ""}`, onClick: () => setTab("browser") }, "\u6D4F\u89C8\u5668\u4E0E\u8BCA\u65AD"))), /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-body" }, error && /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-card", style: { borderColor: "var(--dsw-alias-state-danger-primary, #b91c1c)" } }, error), notice && /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-card" }, notice), tab === "search" && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-card" }, /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-row", style: { marginBottom: 10 } }, /* @__PURE__ */ React.createElement("input", { className: "dsh-jobs-input", value: keyword, onChange: (e) => setKeyword(e.target.value), placeholder: "\u804C\u4F4D\u5173\u952E\u8BCD\uFF0C\u5982 FDE" }), /* @__PURE__ */ React.createElement("input", { className: "dsh-jobs-input", style: { minWidth: 100 }, value: city, onChange: (e) => setCity(e.target.value), placeholder: "\u57CE\u5E02" }), /* @__PURE__ */ React.createElement("input", { className: "dsh-jobs-input", style: { minWidth: 110 }, value: salary, onChange: (e) => setSalary(e.target.value), placeholder: "\u85AA\u8D44\uFF0C\u5982 30-50K" }), /* @__PURE__ */ React.createElement("input", { className: "dsh-jobs-input", style: { minWidth: 110 }, value: workYear, onChange: (e) => setWorkYear(e.target.value), placeholder: "\u7ECF\u9A8C\uFF0C\u5982 5-10\u5E74" }), /* @__PURE__ */ React.createElement("button", { className: "dsh-jobs-btn is-primary", disabled: loading || !keyword.trim(), onClick: handleSearch }, loading ? "\u68C0\u7D22\u4E2D\u2026" : "\u539F\u7AD9\u641C\u7D22")), /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-row" }, ALL_PLATFORMS.map((p) => /* @__PURE__ */ React.createElement("label", { key: p.id, className: "dsh-jobs-pill", style: { cursor: "pointer" } }, /* @__PURE__ */ React.createElement("input", { type: "checkbox", checked: selectedPlatforms.includes(p.id), onChange: () => togglePlatform(p.id) }), /* @__PURE__ */ React.createElement("span", null, p.label))))), searchRes && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-card" }, /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-row", style: { justifyContent: "space-between", marginBottom: 8 } }, /* @__PURE__ */ React.createElement("strong", null, "\u8986\u76D6\u72B6\u6001\uFF1A", searchRes.coverageSummary?.status === "full" ? "\u5B8C\u6574\u8986\u76D6" : searchRes.coverageSummary?.status === "partial" ? "\u90E8\u5206\u8986\u76D6" : "\u672A\u8986\u76D6", "\uFF08\u5171 ", searchRes.jobs?.length ?? 0, " \u6761\uFF09"), /* @__PURE__ */ React.createElement("span", { className: "dsh-jobs-subtitle" }, "\u6D4F\u89C8\u5668\u8FDE\u63A5\uFF1A", searchRes.browserConnected ? "\u5DF2\u8FDE\u63A5" : "\u672A\u8FDE\u63A5")), /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-row" }, (searchRes.sources ?? []).map((src) => {
164
+ const badge = statusBadge(src);
165
+ return /* @__PURE__ */ React.createElement("span", { key: src.source, className: `dsh-jobs-pill is-${badge.tone}`, title: src.diagnostics ? JSON.stringify(src.diagnostics) : src.action }, /* @__PURE__ */ React.createElement("strong", null, src.source), ": ", badge.label, src.diagnostics?.waitMs ? ` \xB7 ${Math.round(src.diagnostics.waitMs / 1e3)}s` : "");
166
+ }))), /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-list" }, (searchRes.jobs ?? []).map((job) => /* @__PURE__ */ React.createElement("div", { key: job.jobDetail, className: "dsh-jobs-item" }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-item-title" }, job.title), /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-item-meta" }, /* @__PURE__ */ React.createElement("span", null, "[", job.source, "]"), job.company && /* @__PURE__ */ React.createElement("span", null, job.company), job.address && /* @__PURE__ */ React.createElement("span", null, job.address), job.salary && /* @__PURE__ */ React.createElement("span", { className: "dsh-jobs-salary" }, job.salary)), detailRes?.url === job.jobDetail && /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-detail-box" }, detailRes.data?.jobDescription || detailRes.data?.detail || JSON.stringify(detailRes.data, null, 2))), /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-row", style: { flexShrink: 0 } }, /* @__PURE__ */ React.createElement("button", { className: "dsh-jobs-btn", disabled: loading, onClick: () => handleReadDetail(job.jobDetail) }, "\u67E5 JD"), /* @__PURE__ */ React.createElement("button", { className: "dsh-jobs-btn", disabled: loading, onClick: () => handlePrepareApply(job) }, "\u5EFA\u6863\u5F85\u6295"), /* @__PURE__ */ React.createElement("a", { className: "dsh-jobs-btn", href: job.jobDetail, target: "_blank", rel: "noreferrer", style: { textDecoration: "none" } }, "\u539F\u7AD9\u6253\u5F00"))))))), tab === "watch" && /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-card" }, /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-row", style: { marginBottom: 12 } }, /* @__PURE__ */ React.createElement("input", { className: "dsh-jobs-input", value: keyword, onChange: (e) => setKeyword(e.target.value), placeholder: "\u76D1\u63A7\u5173\u952E\u8BCD" }), /* @__PURE__ */ React.createElement("input", { className: "dsh-jobs-input", style: { minWidth: 100 }, value: city, onChange: (e) => setCity(e.target.value), placeholder: "\u57CE\u5E02" }), /* @__PURE__ */ React.createElement("button", { className: "dsh-jobs-btn is-primary", disabled: loading || !keyword.trim(), onClick: handleWatchCheck }, loading ? "\u5DE1\u68C0\u4E2D\u2026" : "\u7ACB\u5373\u5DE1\u68C0\u65B0\u5C97\u4F4D")), watchRes && /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-list" }, /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-subtitle" }, watchRes.baseline ? "\u5DF2\u5EFA\u7ACB\u9996\u6B21\u57FA\u7EBF" : `\u65B0\u589E\u5C97\u4F4D\uFF1A${watchRes.newCount ?? 0} \u6761`, " \xB7 ", "\u8986\u76D6\u72B6\u6001\uFF1A", watchRes.coverageSummary?.status === "full" ? "\u5B8C\u6574\u8986\u76D6" : watchRes.coverageSummary?.status === "partial" ? "\u90E8\u5206\u8986\u76D6" : "\u672A\u8986\u76D6"), /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-row" }, (watchRes.sources ?? []).map((src) => {
167
+ const badge = statusBadge(src);
168
+ return /* @__PURE__ */ React.createElement("span", { key: src.source, className: `dsh-jobs-pill is-${badge.tone}` }, src.source, ": ", badge.label);
169
+ })), (watchRes.newJobs ?? []).map((job) => /* @__PURE__ */ React.createElement("div", { key: job.jobDetail, className: "dsh-jobs-item" }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-item-title" }, job.title), /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-item-meta" }, /* @__PURE__ */ React.createElement("span", null, "[", job.source, "]"), job.company && /* @__PURE__ */ React.createElement("span", null, job.company), job.salary && /* @__PURE__ */ React.createElement("span", { className: "dsh-jobs-salary" }, job.salary))), /* @__PURE__ */ React.createElement("a", { className: "dsh-jobs-btn", href: job.jobDetail, target: "_blank", rel: "noreferrer", style: { textDecoration: "none" } }, "\u539F\u7AD9\u67E5\u770B"))))), tab === "applications" && /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-card" }, /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-row", style: { marginBottom: 12 } }, ALL_PLATFORMS.map((p) => /* @__PURE__ */ React.createElement("button", { key: p.id, className: `dsh-jobs-btn ${appPlatform === p.id ? "is-primary" : ""}`, onClick: () => handleLoadApps(p.id) }, p.label))), /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-list" }, (appsRes?.applications ?? []).length === 0 ? /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-subtitle" }, "\u5F53\u524D\u5E73\u53F0\u6682\u65E0\u672C\u5730\u6295\u9012\u8FFD\u8E2A\u8BB0\u5F55\u3002") : (appsRes.applications ?? []).map((app) => /* @__PURE__ */ React.createElement("div", { key: app.url, className: "dsh-jobs-item" }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-item-title" }, app.title || app.url), /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-item-meta" }, /* @__PURE__ */ React.createElement("span", null, "\u72B6\u6001\uFF1A", app.status), app.company && /* @__PURE__ */ React.createElement("span", null, app.company), app.updatedAt && /* @__PURE__ */ React.createElement("span", null, "\u66F4\u65B0\uFF1A", app.updatedAt))), /* @__PURE__ */ React.createElement("a", { className: "dsh-jobs-btn", href: app.url, target: "_blank", rel: "noreferrer", style: { textDecoration: "none" } }, "\u539F\u7AD9\u67E5\u770B"))))), tab === "browser" && /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-card" }, /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-row", style: { marginBottom: 12 } }, /* @__PURE__ */ React.createElement("button", { className: "dsh-jobs-btn is-primary", disabled: loading, onClick: handleLoadProfile }, "\u5237\u65B0\u8BCA\u65AD\u72B6\u6001"), /* @__PURE__ */ React.createElement("button", { className: "dsh-jobs-btn", disabled: loading, onClick: () => handleOpenBrowser() }, "\u6253\u5F00 / \u91CD\u5F00\u6301\u4E45\u5316\u6D4F\u89C8\u5668"), /* @__PURE__ */ React.createElement("button", { className: "dsh-jobs-btn", disabled: loading, onClick: () => runAction(async () => {
170
+ await callRpc("closeBrowser", {});
171
+ setNotice("\u5DF2\u8BF7\u6C42\u4F18\u96C5\u5173\u95ED\u4E13\u7528\u6D4F\u89C8\u5668");
172
+ await handleLoadProfile();
173
+ }) }, "\u4F18\u96C5\u5173\u95ED\u6D4F\u89C8\u5668")), profileRes && /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-list" }, /* @__PURE__ */ React.createElement("div", null, "CDP \u8FDE\u63A5\uFF1A", profileRes.managedChromeRunning ? `\u5DF2\u8FDE\u63A5 (${profileRes.cdpUrl})` : "\u672A\u8FDE\u63A5"), /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-subtitle" }, "Profile \u76EE\u5F55\uFF1A", profileRes.profileDir), /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-subtitle" }, "\u63D0\u793A\uFF1A\u4E0B\u65B9 Cookie \u72B6\u6001\u4EC5\u4E3A\u672C\u5730\u7EBF\u7D22\uFF0C\u7AD9\u70B9\u5B9E\u9645\u767B\u5F55\u6001\u4EE5\u9875\u9762\u6E32\u67D3\u4E3A\u51C6\u3002"), (profileRes.platforms ?? []).map((p) => /* @__PURE__ */ React.createElement("div", { key: p.platform, className: "dsh-jobs-item" }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-item-title" }, p.platform), /* @__PURE__ */ React.createElement("div", { className: "dsh-jobs-item-meta" }, /* @__PURE__ */ React.createElement("span", null, "Cookie \u7EBF\u7D22\uFF1A", p.sessionEvidence ?? "unknown"), p.lastLoginAt && /* @__PURE__ */ React.createElement("span", null, "\u6700\u8FD1\u786E\u8BA4\uFF1A", p.lastLoginAt))), /* @__PURE__ */ React.createElement("button", { className: "dsh-jobs-btn", disabled: loading, onClick: () => handleLoginPlatform(p.platform) }, "\u53BB\u767B\u5F55 / \u76D1\u542C")))))));
174
+ }
175
+
176
+ // src/client/index.tsx
177
+ var NS = "dsh-jobs";
178
+ var inject = ["connection", "slots", "locale", "theme", "layout"];
179
+ function createRpcCaller(ctx) {
180
+ return async (method, payload) => {
181
+ const conn = ctx.get("connection");
182
+ if (!conn) throw new Error("\u8FDE\u63A5\u670D\u52A1\u5C1A\u672A\u5C31\u7EEA");
183
+ const fullMethod = `jobs.${method}`;
184
+ if (typeof conn.call === "function") return conn.call(fullMethod, payload ?? {});
185
+ if (typeof conn.request === "function") return conn.request(fullMethod, payload ?? {});
186
+ if (typeof conn.rpc === "function") return conn.rpc(fullMethod, payload ?? {});
187
+ const remote = conn.remote?.jobs;
188
+ if (remote && typeof remote[method] === "function") return remote[method](payload ?? {});
189
+ throw new Error(`\u65E0\u6CD5\u8C03\u7528\u8FDC\u7AEF\u65B9\u6CD5 ${fullMethod}`);
190
+ };
191
+ }
192
+ function PanelEntry(props) {
193
+ return React2.createElement(
194
+ "button",
195
+ {
196
+ type: "button",
197
+ className: "dsh-jobs-entry-btn",
198
+ title: "\u627E\u5DE5\u4F5C\u5DE5\u4F5C\u53F0 (dsh-jobs)",
199
+ onClick: props?.onClick
200
+ },
201
+ React2.createElement(
202
+ "svg",
203
+ {
204
+ width: 18,
205
+ height: 18,
206
+ viewBox: "0 0 24 24",
207
+ fill: "none",
208
+ stroke: "currentColor",
209
+ strokeWidth: 1.8,
210
+ strokeLinecap: "round",
211
+ strokeLinejoin: "round"
212
+ },
213
+ React2.createElement("rect", { x: 3, y: 7, width: 18, height: 13, rx: 2 }),
214
+ React2.createElement("path", { d: "M8 7V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }),
215
+ React2.createElement("path", { d: "M3 12h18" })
216
+ )
217
+ );
218
+ }
219
+ function apply(ctx) {
220
+ const callRpc = createRpcCaller(ctx);
221
+ ctx.effect(() => {
222
+ const styleEl = document.createElement("style");
223
+ styleEl.setAttribute("data-dsh-plugin", NS);
224
+ styleEl.textContent = styles_default;
225
+ document.head.appendChild(styleEl);
226
+ return () => {
227
+ styleEl.remove();
228
+ };
229
+ }, `${NS}: styles`);
230
+ const slots = ctx.get("slots");
231
+ if (slots) {
232
+ ctx.effect(() => slots.inject("main", () => slots.register(
233
+ { name: "main", key: NS, registrant: NS },
234
+ () => React2.createElement(JobsApp, { callRpc })
235
+ )), `${NS}: main panel`);
236
+ ctx.effect(() => slots.inject("sidebar.panellist", () => slots.register(
237
+ { name: "sidebar.panellist", id: NS, order: 25, label: () => "\u627E\u5DE5\u4F5C", registrant: NS },
238
+ (props) => React2.createElement(PanelEntry, props)
239
+ )), `${NS}: panel entry`);
240
+ }
241
+ const layout = ctx.get("layout");
242
+ if (layout?.panelInfo?.subscribe && slots) {
243
+ ctx.effect(() => {
244
+ const storageKey = `${NS}.panel-selected.v1`;
245
+ let restore = false;
246
+ try {
247
+ restore = sessionStorage.getItem(storageKey) === "1";
248
+ } catch {
249
+ }
250
+ let ready = false;
251
+ const remember = () => {
252
+ if (!ready) return;
253
+ try {
254
+ sessionStorage.setItem(storageKey, layout.panelInfo.getSnapshot()?.activePanelId === NS ? "1" : "0");
255
+ } catch {
256
+ }
257
+ };
258
+ const unsubscribe = layout.panelInfo.subscribe(remember);
259
+ const frame = requestAnimationFrame(() => {
260
+ ready = true;
261
+ if (restore && layout.panelInfo.getSnapshot()?.activePanelId == null) {
262
+ try {
263
+ layout.selectPanel(NS);
264
+ } catch {
265
+ }
266
+ }
267
+ remember();
268
+ });
269
+ return () => {
270
+ cancelAnimationFrame(frame);
271
+ unsubscribe();
272
+ };
273
+ }, `${NS}: panel restore`);
274
+ }
275
+ }
276
+ return module.exports
277
+ },
278
+ })
@@ -0,0 +1,7 @@
1
+ - insert:
2
+ - id: plugin-jobs
3
+ name: dsh-jobs
4
+ config:
5
+ dataDir: '~/.mcp-jobs'
6
+ defaultCity: '北京'
7
+ defaultAccountId: 'personal'
package/icon.svg ADDED
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
2
+ <rect x="3" y="7" width="18" height="13" rx="2" />
3
+ <path d="M8 7V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />
4
+ <path d="M3 12h18" />
5
+ <path d="M10 12v2h4v-2" />
6
+ </svg>
package/index.js ADDED
@@ -0,0 +1,111 @@
1
+ /**
2
+ * dsh-jobs — host half.
3
+ *
4
+ * Publishes the `jobs` Remote namespace (Typert), registers `jobs_*` agent
5
+ * tools, mounts the `/jobs` slash command, and pairs with `client.js` for the
6
+ * native DSH Web UI job-search & tracking workbench.
7
+ *
8
+ * @module dsh-jobs
9
+ */
10
+
11
+ import { JobsEngine } from './lib/engine.js'
12
+ import { installJobsRemote } from './lib/remote.js'
13
+ import { buildToolDefinitions } from './lib/tools.js'
14
+ import { registerJobsSkill } from './lib/skill.js'
15
+
16
+ export const name = 'dsh-jobs'
17
+
18
+ /** Optional services only: without `tools`, `commands`, or `skills`, the UI remote still works. */
19
+ export const inject = []
20
+
21
+ let z = null
22
+ try {
23
+ const { createRequire } = await import('node:module')
24
+ const { realpathSync } = await import('node:fs')
25
+ for (const a of [process.argv?.[1], process.argv?.[0]]) {
26
+ if (typeof a !== 'string' || !a) continue
27
+ try {
28
+ const anchor = realpathSync(a)
29
+ const mod = createRequire(anchor)('@deepseek-ai/schemastery')
30
+ const candidate = mod?.object ? mod : mod?.default
31
+ if (candidate && typeof candidate.object === 'function') { z = candidate; break }
32
+ } catch { /* try next anchor */ }
33
+ }
34
+ } catch { /* schemastery optional outside dsh host */ }
35
+
36
+ export const Config = z
37
+ ? z.object({
38
+ dataDir: z.string().description('数据与持久化浏览器 Profile 目录(默认与 mcp-jobs 共用 ~/.mcp-jobs)').default('~/.mcp-jobs'),
39
+ defaultCity: z.string().description('默认搜索与巡检城市').default('北京'),
40
+ defaultAccountId: z.string().description('默认本地账号代号').default('personal'),
41
+ }).description('dsh-jobs 找工作工作台配置')
42
+ : undefined
43
+
44
+ export function apply(ctx, config = {}) {
45
+ const engine = new JobsEngine(config)
46
+ const remote = installJobsRemote(ctx, engine)
47
+
48
+ // 1. Register DSH Agent Tools
49
+ const tools = typeof ctx?.get === 'function' ? ctx.get('tools') : undefined
50
+ if (tools && typeof tools.register === 'function') {
51
+ for (const def of buildToolDefinitions(remote)) {
52
+ const remove = tools.register(def)
53
+ if (typeof ctx.effect === 'function') {
54
+ ctx.effect(() => () => { try { remove?.() } catch { /* already gone */ } })
55
+ }
56
+ }
57
+ } else {
58
+ ctx?.logger?.warn?.('[dsh-jobs] tools 服务不可用,仅提供 UI 远端与命令')
59
+ }
60
+
61
+ // 2. Register `/jobs` human slash command
62
+ const commands = typeof ctx?.get === 'function' ? ctx.get('commands') : undefined
63
+ if (commands && typeof commands.register === 'function') {
64
+ const removeCmd = commands.register({
65
+ name: 'jobs',
66
+ description: '检查求职浏览器连接状态或快速搜岗:/jobs [status|doctor|<关键词>]',
67
+ async execute(invocation) {
68
+ const raw = String(invocation?.rawInput ?? '').trim()
69
+ if (!raw || raw === 'status') {
70
+ const st = await remote.profileStatus({})
71
+ const lines = [
72
+ `CDP 连接: ${st.managedChromeRunning ? '已连接' : '未连接'}${st.cdpUrl ? ` (${st.cdpUrl})` : ''}`,
73
+ `持久化 Profile: ${st.profileDir ?? '未知'}`,
74
+ ...(Array.isArray(st.platforms)
75
+ ? st.platforms.map((p) => ` - ${p.platform}: ${p.sessionEvidence ?? 'unknown'}`)
76
+ : []),
77
+ ]
78
+ return { kind: 'success', text: lines.join('\n') }
79
+ }
80
+ if (raw === 'doctor') {
81
+ const doc = await remote.doctor()
82
+ return { kind: 'success', text: JSON.stringify(doc, null, 2) }
83
+ }
84
+ const res = await remote.search({ keyword: raw })
85
+ const summary = res.coverageSummary
86
+ const lines = [
87
+ `关键词「${raw}」搜索完成:共 ${res.jobs?.length ?? 0} 条`,
88
+ summary
89
+ ? `覆盖状态:${summary.status === 'full' ? '完整覆盖' : summary.status === 'partial' ? '部分覆盖' : '未覆盖'} | 已覆盖: ${summary.coveredPlatforms.join(', ') || '无'} | 未覆盖: ${summary.uncoveredPlatforms.join(', ') || '无'}`
90
+ : '',
91
+ ...(res.jobs ?? []).slice(0, 8).map((j, i) => `${i + 1}. [${j.source}] ${j.title} · ${j.company ?? ''} · ${j.salary ?? '薪资待核实'} (${j.jobDetail})`),
92
+ ].filter(Boolean)
93
+ return { kind: 'success', text: lines.join('\n') }
94
+ },
95
+ })
96
+ if (typeof ctx.effect === 'function') {
97
+ ctx.effect(() => () => { try { removeCmd?.() } catch { /* already gone */ } })
98
+ }
99
+ }
100
+
101
+ // 3. Register bundled `find-jobs` Skill into DSH skill catalog
102
+ const skills = typeof ctx?.get === 'function' ? ctx.get('skills') : undefined
103
+ if (skills && typeof skills.register === 'function') {
104
+ const removeSkill = registerJobsSkill(skills)
105
+ if (removeSkill && typeof ctx.effect === 'function') {
106
+ ctx.effect(() => () => { try { removeSkill() } catch { /* already gone */ } })
107
+ }
108
+ }
109
+
110
+ return { engine, remote }
111
+ }
package/lib/engine.js ADDED
@@ -0,0 +1,70 @@
1
+ /**
2
+ * dsh-jobs — engine runner.
3
+ *
4
+ * Executes the self-contained raw-CDP jobs engine (`lib/jobs-engine.cjs`)
5
+ * via child_process with isolated UTF-8 JSON input files, sharing the same
6
+ * persistent profile and local tracker store as mcp-jobs / skill-jobs.
7
+ *
8
+ * @module lib/engine.js
9
+ */
10
+
11
+ import { execFile } from 'node:child_process'
12
+ import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'
13
+ import { homedir, tmpdir } from 'node:os'
14
+ import { dirname, join, resolve } from 'node:path'
15
+ import { fileURLToPath } from 'node:url'
16
+ import { promisify } from 'node:util'
17
+
18
+ const execFileAsync = promisify(execFile)
19
+ const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..')
20
+ const DEFAULT_ENGINE = join(ROOT, 'lib/jobs-engine.cjs')
21
+
22
+ function expandHome(p) {
23
+ if (!p || typeof p !== 'string') return p
24
+ return p.startsWith('~/') ? join(homedir(), p.slice(2)) : p
25
+ }
26
+
27
+ export class JobsEngine {
28
+ constructor(config = {}) {
29
+ this.dataDir = resolve(expandHome(config.dataDir || process.env.MCP_JOBS_DATA_DIR || '~/.mcp-jobs'))
30
+ this.profileDir = resolve(expandHome(config.profileDir || process.env.MCP_JOBS_PROFILE_DIR || join(this.dataDir, 'profile')))
31
+ this.defaultCity = config.defaultCity || '北京'
32
+ this.defaultAccountId = config.defaultAccountId || 'personal'
33
+ this.enginePath = config.enginePath || DEFAULT_ENGINE
34
+ }
35
+
36
+ async run(command, payload = {}, opts = {}) {
37
+ const dir = mkdtempSync(join(tmpdir(), 'dsh-jobs-'))
38
+ const inputPath = join(dir, 'input.json')
39
+ writeFileSync(inputPath, JSON.stringify(payload ?? {}), 'utf8')
40
+ const timeoutMs = opts.timeoutMs ?? (command === 'login' ? 620_000 : command === 'search' || command === 'watch-check' ? 90_000 : 45_000)
41
+ const env = {
42
+ ...process.env,
43
+ MCP_JOBS_DATA_DIR: this.dataDir,
44
+ MCP_JOBS_PROFILE_DIR: this.profileDir,
45
+ ...(opts.monitorOnly ? { MCP_JOBS_MONITOR_ONLY: '1' } : {}),
46
+ }
47
+ try {
48
+ const { stdout } = await execFileAsync(
49
+ process.execPath,
50
+ [this.enginePath, command, inputPath],
51
+ { env, timeout: timeoutMs, maxBuffer: 16 * 1024 * 1024, encoding: 'utf8' }
52
+ )
53
+ const trimmed = stdout.trim()
54
+ return trimmed ? JSON.parse(trimmed) : {}
55
+ } catch (err) {
56
+ const out = typeof err?.stdout === 'string' ? err.stdout.trim() : ''
57
+ if (out) {
58
+ try { return JSON.parse(out) } catch { /* fall through */ }
59
+ }
60
+ const stderr = typeof err?.stderr === 'string' ? err.stderr.trim() : ''
61
+ return {
62
+ ok: false,
63
+ error: stderr || err?.message || `jobs command "${command}" failed`,
64
+ command,
65
+ }
66
+ } finally {
67
+ try { rmSync(dir, { recursive: true, force: true }) } catch { /* ignore */ }
68
+ }
69
+ }
70
+ }