weaver-work-cli 0.1.45 → 0.1.46
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/dist/chunks/{attachment-content-CE3GMWTS.js → attachment-content-MCXQBD6N.js} +3 -3
- package/dist/chunks/{chunk-VIMCY4DI.js → chunk-4RWS2YYL.js} +2 -2
- package/dist/chunks/{chunk-4EXOIQDI.js → chunk-6AXKWFKG.js} +4 -14
- package/dist/chunks/{chunk-JWWTI63L.js → chunk-6V5ZPKHV.js} +2 -8
- package/dist/chunks/{chunk-3ZMAQQ3W.js → chunk-76H3IKH6.js} +39 -26
- package/dist/chunks/{chunk-LGKWL4OH.js → chunk-AD46OMQK.js} +86 -25
- package/dist/chunks/{chunk-3WBIQLMB.js → chunk-GSZTA43P.js} +2 -2
- package/dist/chunks/{chunk-OAE3AZBQ.js → chunk-IP4CWQCF.js} +6 -6
- package/dist/chunks/{chunk-77YP6I52.js → chunk-IRMIEDXN.js} +1 -1
- package/dist/chunks/{chunk-T4MWQAQB.js → chunk-JFAWZX53.js} +128 -9
- package/dist/chunks/{chunk-DGMYACGJ.js → chunk-OXHHJWNC.js} +1 -1
- package/dist/chunks/{chunk-LXFVWZLM.js → chunk-PSOMGA3U.js} +3 -3
- package/dist/chunks/{chunk-LRCPNDZA.js → chunk-UFIFZ4YC.js} +10 -8
- package/dist/chunks/{conflict-IYJETSGT.js → conflict-H7EHQXYY.js} +2 -2
- package/dist/chunks/{create-flow-7JLC7UID.js → create-flow-VRVJEOBX.js} +6 -6
- package/dist/chunks/{ehr-MYRDCHZ4.js → ehr-SH2LM3NK.js} +528 -40
- package/dist/chunks/{env-3MBHAWBL.js → env-66FPSJDV.js} +2 -2
- package/dist/chunks/{factory-TZEVU4DU.js → factory-UH2TZBVA.js} +1 -1
- package/dist/chunks/{group-chat-KL3HFKRM.js → group-chat-CAKMMV7K.js} +3 -3
- package/dist/chunks/{lazy-dispatch-UH6HGK2I.js → lazy-dispatch-DD6ULZ3I.js} +1 -1
- package/dist/chunks/{meeting-C67EHQ4Z.js → meeting-VTBFW4HI.js} +10 -10
- package/dist/chunks/{recruit-stage-AHY5QAMF.js → recruit-stage-CAKZTUA7.js} +917 -85
- package/dist/chunks/{registry-XPWPGHYE.js → registry-JVQBLFQ5.js} +10 -10
- package/dist/chunks/{room-recommend-CNWE5WQK.js → room-recommend-5U55FMXZ.js} +4 -4
- package/dist/chunks/{schedule-YYNYBQIE.js → schedule-IDETODCA.js} +4 -4
- package/dist/cmd/action.js +14 -10
- package/dist/index.js +5 -5
- package/dist/shortcuts/ehr/host.js +2 -2
- package/dist/shortcuts/ehr/index.js +14 -3
- package/dist/shortcuts/ehr/manifest.js +5 -1
- package/dist/shortcuts/ehr/operations/recruit-candidate-import.js +40 -10
- package/dist/shortcuts/ehr/operations/recruit-interview-overview.js +258 -0
- package/dist/shortcuts/ehr/operations/recruit-position.js +10 -8
- package/dist/shortcuts/ehr/operations/recruit-stats.js +14 -1
- package/dist/shortcuts/ehr/operations/recruit-tag.js +173 -0
- package/dist/shortcuts/ehr/operations/recruit-write.js +137 -18
- package/dist/shortcuts/ehr/operations/recruit.js +180 -8
- package/dist/shortcuts/ehr/operations/registry.js +4 -0
- package/dist/shortcuts/ehr/operations.js +24 -0
- package/dist/shortcuts/ehr/recruit-stage/batch-store.js +78 -0
- package/dist/shortcuts/ehr/recruit-stage/context.js +231 -0
- package/dist/shortcuts/ehr/recruit-stage/continuation.js +74 -0
- package/dist/shortcuts/ehr/recruit-stage/errors.js +65 -0
- package/dist/shortcuts/ehr/recruit-stage/fs-scan.js +165 -0
- package/dist/shortcuts/ehr/recruit-stage/host.js +109 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/interview-arrange.js +1049 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/interview-feedback.js +295 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/jd-create.js +961 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/list.js +431 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/registry.js +50 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/resume-import.js +1647 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/search.js +158 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/types.js +34 -0
- package/dist/shortcuts/ehr/recruit-stage/runtime.js +31 -0
- package/dist/shortcuts/ehr/recruit-stage/school-tiers.json +318 -0
- package/dist/shortcuts/ehr/recruit-stage/shared.js +805 -0
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +93 -18
- package/dist/shortcuts/meeting/operations/eb/factory.js +5 -8
- package/dist/shortcuts/meeting/operations/eb/room-recommend.js +2 -13
- package/dist/shortcuts/meeting/operations/invitation.js +27 -4
- package/dist/shortcuts/recruit-stage/batch-store.js +78 -0
- package/dist/shortcuts/recruit-stage/fs-scan.js +165 -0
- package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +277 -20
- package/dist/shortcuts/recruit-stage/operations/interview-feedback.js +31 -7
- package/dist/shortcuts/recruit-stage/operations/jd-create.js +106 -16
- package/dist/shortcuts/recruit-stage/operations/registry.js +12 -0
- package/dist/shortcuts/recruit-stage/operations/resume-import.js +273 -6
- package/dist/shortcuts/recruit-stage/operations/types.js +9 -0
- package/dist/shortcuts/recruit-stage/shared.js +60 -6
- package/package.json +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-compare-report-template.html +2 -2
- package/skills/weaver-e10-jucailin/SKILL.md +12 -3
- package/skills/weaver-e10-jucailin/archive/LEGACY-README.md +18 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-SKILL.md +239 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-openai.yaml +131 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-position-templates.md +221 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-arrange-interview.md +334 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-capability-check.md +127 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-check-install.md +65 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-detail-process.md +63 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-edit-interview-feedback.md +142 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-jd-create.md +114 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-jd-template.md +56 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-list-candidate.md +101 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-list-interview.md +148 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-match-candidates.md +77 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-output-links.md +72 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-creator.md +69 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-metadata.md +241 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resume-import.md +457 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resume-parse.md +128 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-search-candidate.md +146 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-urge-feedback.md +69 -0
- package/skills/weaver-e10-jucailin/lib/recruit-xiaoe-file.mjs +192 -0
- package/skills/weaver-e10-jucailin/lib/xiaoe-session.mjs +66 -0
- package/skills/weaver-e10-jucailin/references/recruit-create.md +19 -93
- package/skills/weaver-e10-jucailin/references/recruit-interview-overview.md +64 -0
- package/skills/weaver-e10-jucailin/references/recruit-read.md +63 -1
- package/skills/weaver-e10-jucailin/references/recruit-screening-to-interview-sop.md +95 -0
- package/skills/weaver-e10-jucailin/references/recruit-stage-ops.md +89 -0
- package/skills/weaver-e10-jucailin/references/recruit-tag.md +81 -0
- package/skills/weaver-e10-jucailin/references/recruit-write.md +53 -9
- package/skills/weaver-e10-meeting/SKILL.md +48 -4
- package/skills/weaver-e10-meeting/references/meeting-eb.md +1 -1
- package/skills/weaver-e10-recruit-stage/SKILL.md +8 -5
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +16 -6
- package/skills/weaver-e10-recruit-stage/lib/recruit-xiaoe-file.mjs +5 -1
- package/skills/weaver-e10-recruit-stage/references/position-templates.md +20 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +21 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +4 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { CONTINUATION_TTL_MS } from '../../../core/continuation-ttl.js';
|
|
2
|
+
import { createHmac, randomBytes, timingSafeEqual } from 'node:crypto';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { chmod, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
5
|
+
import { homedir } from 'node:os';
|
|
6
|
+
import { resolve } from 'node:path';
|
|
7
|
+
import { rsValidationError } from './errors.js';
|
|
8
|
+
function stateRoot(ctx) {
|
|
9
|
+
const configured = ctx?.config?.path();
|
|
10
|
+
if (configured)
|
|
11
|
+
return resolve(configured, '..');
|
|
12
|
+
return process.env.WEAVER_WORK_CLI_HOME || process.env.WORK_CLI_HOME || resolve(homedir(), '.weaver-work-cli');
|
|
13
|
+
}
|
|
14
|
+
async function loadKey(ctx) {
|
|
15
|
+
const keysDir = resolve(stateRoot(ctx), 'keys');
|
|
16
|
+
const filename = resolve(keysDir, 'recruit-stage-continuation.key');
|
|
17
|
+
await mkdir(keysDir, { recursive: true, mode: 0o700 });
|
|
18
|
+
if (existsSync(filename))
|
|
19
|
+
return readFile(filename);
|
|
20
|
+
const key = randomBytes(32);
|
|
21
|
+
try {
|
|
22
|
+
await writeFile(filename, key, { flag: 'wx', mode: 0o600 });
|
|
23
|
+
if (process.platform !== 'win32')
|
|
24
|
+
await chmod(filename, 0o600).catch(() => undefined);
|
|
25
|
+
return key;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return readFile(filename);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function encode(value) {
|
|
32
|
+
return Buffer.from(JSON.stringify(value)).toString('base64url');
|
|
33
|
+
}
|
|
34
|
+
function signature(payload, key) {
|
|
35
|
+
return createHmac('sha256', key).update(payload).digest('base64url');
|
|
36
|
+
}
|
|
37
|
+
export function createRecruitStageContinuationSigner(ctx) {
|
|
38
|
+
return {
|
|
39
|
+
async issue(payload, ttlMs = CONTINUATION_TTL_MS) {
|
|
40
|
+
const issuedAt = Date.now();
|
|
41
|
+
const body = encode({ ...payload, issuedAt, expiresAt: issuedAt + ttlMs });
|
|
42
|
+
const sig = signature(body, await loadKey(ctx));
|
|
43
|
+
return `${body}.${sig}`;
|
|
44
|
+
},
|
|
45
|
+
async verify(token, expectedOperation) {
|
|
46
|
+
if (typeof token !== 'string' || !token.includes('.')) {
|
|
47
|
+
throw rsValidationError('continuation_invalid', 'continuation 无效');
|
|
48
|
+
}
|
|
49
|
+
const [body, provided] = token.split('.');
|
|
50
|
+
const expected = signature(body, await loadKey(ctx));
|
|
51
|
+
const valid = provided.length === expected.length
|
|
52
|
+
&& timingSafeEqual(Buffer.from(provided), Buffer.from(expected));
|
|
53
|
+
if (!valid)
|
|
54
|
+
throw rsValidationError('continuation_invalid', 'continuation 签名校验失败');
|
|
55
|
+
let payload;
|
|
56
|
+
try {
|
|
57
|
+
payload = JSON.parse(Buffer.from(body, 'base64url').toString('utf8'));
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
throw rsValidationError('continuation_invalid', 'continuation 载荷解析失败');
|
|
61
|
+
}
|
|
62
|
+
if (!payload || typeof payload !== 'object') {
|
|
63
|
+
throw rsValidationError('continuation_invalid', 'continuation 载荷必须是对象');
|
|
64
|
+
}
|
|
65
|
+
if (typeof payload.expiresAt === 'number' && Date.now() > payload.expiresAt) {
|
|
66
|
+
throw rsValidationError('continuation_expired', 'continuation 已过期,请重新 prepare');
|
|
67
|
+
}
|
|
68
|
+
if (payload.operation && String(payload.operation) !== String(expectedOperation)) {
|
|
69
|
+
throw rsValidationError('continuation_operation_mismatch', `continuation 属于操作 ${String(payload.operation)},不能用于 ${expectedOperation}`);
|
|
70
|
+
}
|
|
71
|
+
return payload;
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { CliError, ExitCode } from '../../../core/errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* recruit-stage 模块错误类型。
|
|
4
|
+
* 形态与 ehr 模块一致(type/subtype/details/partialData),
|
|
5
|
+
* 前缀 rs 避免与 ehr 的错误类型混淆。
|
|
6
|
+
*/
|
|
7
|
+
export class RecruitStageCliError extends CliError {
|
|
8
|
+
type;
|
|
9
|
+
subtype;
|
|
10
|
+
code;
|
|
11
|
+
retryable;
|
|
12
|
+
stage;
|
|
13
|
+
details;
|
|
14
|
+
partialData;
|
|
15
|
+
constructor(type, subtype, message, options = {}) {
|
|
16
|
+
super(message, options.exitCode ?? ExitCode.InternalError);
|
|
17
|
+
this.name = 'RecruitStageCliError';
|
|
18
|
+
this.type = type;
|
|
19
|
+
this.subtype = subtype;
|
|
20
|
+
this.code = options.code;
|
|
21
|
+
this.retryable = options.retryable ?? false;
|
|
22
|
+
this.stage = options.stage;
|
|
23
|
+
this.details = options.details;
|
|
24
|
+
this.partialData = options.partialData;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function rsValidationError(subtype, message, details) {
|
|
28
|
+
return new RecruitStageCliError('validation', subtype, message, {
|
|
29
|
+
details,
|
|
30
|
+
exitCode: ExitCode.UsageError,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export function rsAuthError(subtype, message, details) {
|
|
34
|
+
return new RecruitStageCliError('authentication', subtype, message, {
|
|
35
|
+
details,
|
|
36
|
+
exitCode: ExitCode.AuthError,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export function rsNetworkError(subtype, message, options = {}) {
|
|
40
|
+
return new RecruitStageCliError('network', subtype, message, {
|
|
41
|
+
...options,
|
|
42
|
+
retryable: options.retryable ?? true,
|
|
43
|
+
exitCode: ExitCode.NetworkError,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export function rsConfirmationError(action, details) {
|
|
47
|
+
return new RecruitStageCliError('confirmation', 'required', '该操作需要明确确认', {
|
|
48
|
+
details: { action, ...details },
|
|
49
|
+
exitCode: ExitCode.ConfirmationRequired,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/** 业务失败(对应脚本版 throw new Error(...) 的主通道)。 */
|
|
53
|
+
export function rsFail(message, details) {
|
|
54
|
+
return new RecruitStageCliError('api', 'business_error', message, {
|
|
55
|
+
details,
|
|
56
|
+
exitCode: ExitCode.GeneralError,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
export function rsPartialError(message, partialData, details) {
|
|
60
|
+
return new RecruitStageCliError('partial', 'write_uncertain', message, {
|
|
61
|
+
details,
|
|
62
|
+
partialData,
|
|
63
|
+
exitCode: ExitCode.Partial,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 批量简历导入的本地文件枚举(2026-11-06)。
|
|
3
|
+
*
|
|
4
|
+
* 职责边界:
|
|
5
|
+
* - 只做「把用户给的文件夹 / zip 包变成待处理文件清单」,不解析简历内容;
|
|
6
|
+
* - 解压走 Node 内置 zlib(不引第三方依赖,不调系统 unzip),Windows/macOS/Linux 一致;
|
|
7
|
+
* - 文件名编码:zip 通用标志位 bit 11 = UTF-8,否则按 GBK 尝试(Windows 中文系统常见);
|
|
8
|
+
* - 路径安全:拒绝绝对路径与 `..`(zip-slip),跳过 `__MACOSX/` 与目录项。
|
|
9
|
+
*/
|
|
10
|
+
import { mkdtempSync, readdirSync, readFileSync, statSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
11
|
+
import { tmpdir } from 'node:os';
|
|
12
|
+
import { basename, dirname, extname, join, resolve } from 'node:path';
|
|
13
|
+
import { inflateRawSync } from 'node:zlib';
|
|
14
|
+
export const RESUME_EXTS = new Set(['.pdf', '.doc', '.docx', '.rtf', '.txt', '.wps']);
|
|
15
|
+
function decodeName(bytes, utf8Flag) {
|
|
16
|
+
if (utf8Flag)
|
|
17
|
+
return bytes.toString('utf8');
|
|
18
|
+
try {
|
|
19
|
+
return new TextDecoder('gbk').decode(bytes);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return bytes.toString('utf8');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** 解压 zip 到系统临时目录,返回目录路径。只支持 store/deflate(覆盖常规压缩方式)。 */
|
|
26
|
+
export function extractZip(zipPath) {
|
|
27
|
+
const buf = readFileSync(zipPath);
|
|
28
|
+
let eocd = -1;
|
|
29
|
+
const floor = Math.max(0, buf.length - 22 - 65535);
|
|
30
|
+
for (let i = buf.length - 22; i >= floor; i--) {
|
|
31
|
+
if (buf.readUInt32LE(i) === 0x06054b50) {
|
|
32
|
+
eocd = i;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (eocd < 0)
|
|
37
|
+
throw new Error('不是有效的 zip 文件(找不到中央目录结尾标记)');
|
|
38
|
+
const count = buf.readUInt16LE(eocd + 10);
|
|
39
|
+
let off = buf.readUInt32LE(eocd + 16);
|
|
40
|
+
if (count === 0xffff || off === 0xffffffff) {
|
|
41
|
+
throw new Error('暂不支持 ZIP64(超大压缩包),请拆分成多个普通 zip 后重试');
|
|
42
|
+
}
|
|
43
|
+
const dest = mkdtempSync(join(tmpdir(), 'e10-resume-'));
|
|
44
|
+
let written = 0;
|
|
45
|
+
for (let i = 0; i < count; i++) {
|
|
46
|
+
if (off + 46 > buf.length || buf.readUInt32LE(off) !== 0x02014b50)
|
|
47
|
+
break;
|
|
48
|
+
const flags = buf.readUInt16LE(off + 8);
|
|
49
|
+
const method = buf.readUInt16LE(off + 10);
|
|
50
|
+
const compSize = buf.readUInt32LE(off + 20);
|
|
51
|
+
const nameLen = buf.readUInt16LE(off + 28);
|
|
52
|
+
const extraLen = buf.readUInt16LE(off + 30);
|
|
53
|
+
const commentLen = buf.readUInt16LE(off + 32);
|
|
54
|
+
const localOff = buf.readUInt32LE(off + 42);
|
|
55
|
+
const rawName = buf.subarray(off + 46, off + 46 + nameLen);
|
|
56
|
+
const name = decodeName(rawName, (flags & 0x800) !== 0);
|
|
57
|
+
off += 46 + nameLen + extraLen + commentLen;
|
|
58
|
+
if (!name || name.endsWith('/') || name.startsWith('__MACOSX/'))
|
|
59
|
+
continue;
|
|
60
|
+
const rawParts = name.replace(/\\/g, '/').split('/');
|
|
61
|
+
// zip-slip 防护:路径里出现 .. 直接丢弃整个条目(不做"剥离后落盘",避免歧义)
|
|
62
|
+
if (rawParts.some((s) => s === '..'))
|
|
63
|
+
continue;
|
|
64
|
+
const parts = rawParts.filter((s) => s && s !== '.' && !/^[a-zA-Z]:$/.test(s));
|
|
65
|
+
if (!parts.length)
|
|
66
|
+
continue;
|
|
67
|
+
if (method !== 0 && method !== 8)
|
|
68
|
+
continue; // 只处理 store/deflate
|
|
69
|
+
const lNameLen = buf.readUInt16LE(localOff + 26);
|
|
70
|
+
const lExtraLen = buf.readUInt16LE(localOff + 28);
|
|
71
|
+
const dataStart = localOff + 30 + lNameLen + lExtraLen;
|
|
72
|
+
if (dataStart + compSize > buf.length)
|
|
73
|
+
continue;
|
|
74
|
+
const raw = buf.subarray(dataStart, dataStart + compSize);
|
|
75
|
+
let out;
|
|
76
|
+
try {
|
|
77
|
+
out = method === 0 ? raw : inflateRawSync(raw);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
continue; // 单个条目损坏不影响其他文件
|
|
81
|
+
}
|
|
82
|
+
const target = join(dest, ...parts);
|
|
83
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
84
|
+
writeFileSync(target, out);
|
|
85
|
+
written++;
|
|
86
|
+
}
|
|
87
|
+
if (!written)
|
|
88
|
+
throw new Error('zip 内没有可读取的文件(可能为空包或使用了不支持的压缩方式)');
|
|
89
|
+
return dest;
|
|
90
|
+
}
|
|
91
|
+
function walk(dir, root, out, warnings, depth) {
|
|
92
|
+
if (depth > 4)
|
|
93
|
+
return;
|
|
94
|
+
let entries;
|
|
95
|
+
try {
|
|
96
|
+
entries = readdirSync(dir);
|
|
97
|
+
}
|
|
98
|
+
catch (e) {
|
|
99
|
+
warnings.push(`目录不可读:${dir}(${e?.message || '未知原因'})`);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
for (const name of entries) {
|
|
103
|
+
const p = join(dir, name);
|
|
104
|
+
let st;
|
|
105
|
+
try {
|
|
106
|
+
st = statSync(p);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (st.isDirectory()) {
|
|
112
|
+
if (name === '__MACOSX' || name.startsWith('.'))
|
|
113
|
+
continue;
|
|
114
|
+
walk(p, root, out, warnings, depth + 1);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (!RESUME_EXTS.has(extname(name).toLowerCase()))
|
|
118
|
+
continue;
|
|
119
|
+
out.push({ path: p, name, size: st.size });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/** 扫描文件夹或 zip,返回按文件名排序的简历文件清单。 */
|
|
123
|
+
export function scanResumeSource(source) {
|
|
124
|
+
const warnings = [];
|
|
125
|
+
const abs = resolve(source);
|
|
126
|
+
let st;
|
|
127
|
+
try {
|
|
128
|
+
st = statSync(abs);
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
throw new Error(`路径不存在或不可读:${source}`);
|
|
132
|
+
}
|
|
133
|
+
let root = abs;
|
|
134
|
+
let tempDir;
|
|
135
|
+
if (st.isFile()) {
|
|
136
|
+
if (extname(abs).toLowerCase() !== '.zip') {
|
|
137
|
+
throw new Error('source 只支持文件夹或 .zip 压缩包');
|
|
138
|
+
}
|
|
139
|
+
tempDir = extractZip(abs);
|
|
140
|
+
root = tempDir;
|
|
141
|
+
}
|
|
142
|
+
else if (!st.isDirectory()) {
|
|
143
|
+
throw new Error('source 只支持文件夹或 .zip 压缩包');
|
|
144
|
+
}
|
|
145
|
+
const files = [];
|
|
146
|
+
walk(root, root, files, warnings, 0);
|
|
147
|
+
files.sort((a, b) => a.name.localeCompare(b.name, 'zh-Hans-CN'));
|
|
148
|
+
return { root, files, warnings, tempDir };
|
|
149
|
+
}
|
|
150
|
+
/** 为某个简历文件找同名结构化 JSON(同目录或指定目录)。 */
|
|
151
|
+
export function findStructuredJson(file, structuredDir) {
|
|
152
|
+
const base = basename(file.name, extname(file.name));
|
|
153
|
+
const candidates = [
|
|
154
|
+
join(dirname(file.path), base + '.json'),
|
|
155
|
+
...(structuredDir ? [join(resolve(structuredDir), base + '.json')] : []),
|
|
156
|
+
];
|
|
157
|
+
for (const c of candidates) {
|
|
158
|
+
try {
|
|
159
|
+
if (statSync(c).isFile())
|
|
160
|
+
return c;
|
|
161
|
+
}
|
|
162
|
+
catch { /* 继续找下一个 */ }
|
|
163
|
+
}
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { E10_SESSION_EXPIRED_MESSAGE } from '../../../internal/e10/auth/messages.js';
|
|
2
|
+
import { requireE10Session } from '../../../internal/e10/context.js';
|
|
3
|
+
import { getActiveProfile } from '../../../internal/e10/auth/session.js';
|
|
4
|
+
import { E10ApiError, createE10RequestRuntime } from '../../../internal/e10/request-runtime.js';
|
|
5
|
+
import { isE10SessionExpiredResponse } from '../../../internal/e10/auth-recovery.js';
|
|
6
|
+
import { rsAuthError, rsNetworkError, RecruitStageCliError, rsValidationError } from './errors.js';
|
|
7
|
+
function inferProfile(ctx) {
|
|
8
|
+
const options = ctx.getGlobalOptions();
|
|
9
|
+
return options.profile || getActiveProfile();
|
|
10
|
+
}
|
|
11
|
+
export function assertPath(requestPath) {
|
|
12
|
+
if (typeof requestPath !== 'string' || !requestPath.startsWith('/') || requestPath.startsWith('//')) {
|
|
13
|
+
throw rsValidationError('path_invalid', '请求路径必须是相对绝对路径');
|
|
14
|
+
}
|
|
15
|
+
if (/^https?:/i.test(requestPath) || /[\r\n]/.test(requestPath) || requestPath.includes('/../')) {
|
|
16
|
+
throw rsValidationError('path_invalid', '请求路径不允许跨域或路径逃逸');
|
|
17
|
+
}
|
|
18
|
+
if (!requestPath.startsWith('/api/')) {
|
|
19
|
+
throw rsValidationError('path_not_allowed', '只能调用 /api/ 路径');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 与 ehr host 的刻意差异:**不做全局 isBusinessSuccess 强判定**。
|
|
24
|
+
* 原因:EB 表单引擎各接口响应契约不一(getListDatas 返回 {data:{...}} 未必带 status/success/code),
|
|
25
|
+
* 脚本版(write-op/e10-request.mjs)也只在 saveFormData 等个别接口做业务判定——
|
|
26
|
+
* 业务成功判定留给各 operation 按接口语义自行处理,宿主只判 HTTP 状态与会话失效。
|
|
27
|
+
*/
|
|
28
|
+
export function createRecruitStageHost(ctx, dependencies = {}) {
|
|
29
|
+
let e10Session = null;
|
|
30
|
+
let sessionContext = null;
|
|
31
|
+
const requireSession = dependencies.requireSession
|
|
32
|
+
|| ((innerCtx) => requireE10Session(innerCtx, { skipProfileEnrichment: true }));
|
|
33
|
+
async function ensureSession() {
|
|
34
|
+
if (!e10Session) {
|
|
35
|
+
e10Session = await requireSession(ctx);
|
|
36
|
+
sessionContext = {
|
|
37
|
+
baseUrl: e10Session.getBaseUrl(),
|
|
38
|
+
profile: inferProfile(ctx),
|
|
39
|
+
userId: e10Session.userId,
|
|
40
|
+
tenantKey: e10Session.tenantKey,
|
|
41
|
+
eteamsId: e10Session.eteamsId,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return e10Session;
|
|
45
|
+
}
|
|
46
|
+
async function getSession() {
|
|
47
|
+
await ensureSession();
|
|
48
|
+
return sessionContext;
|
|
49
|
+
}
|
|
50
|
+
async function runtime() {
|
|
51
|
+
return createE10RequestRuntime(ctx, await ensureSession(), {
|
|
52
|
+
interceptors: dependencies.interceptors,
|
|
53
|
+
fetch: dependencies.fetch,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async function request(request) {
|
|
57
|
+
const { method, path, query, body, operation, multipart, headers: extraHeaders = {}, timeoutMs = 30_000, } = request;
|
|
58
|
+
assertPath(path);
|
|
59
|
+
const resolvedMethod = method || (body === undefined && multipart === undefined ? 'GET' : 'POST');
|
|
60
|
+
let response;
|
|
61
|
+
try {
|
|
62
|
+
response = await (await runtime()).requestJson({
|
|
63
|
+
module: 'recruit-stage',
|
|
64
|
+
operation,
|
|
65
|
+
method: resolvedMethod,
|
|
66
|
+
path,
|
|
67
|
+
query,
|
|
68
|
+
body: multipart === undefined ? body : undefined,
|
|
69
|
+
formData: multipart,
|
|
70
|
+
headers: { 'X-Requested-With': 'XMLHttpRequest', ...extraHeaders },
|
|
71
|
+
timeoutMs,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (error instanceof E10ApiError && error.type === 'network') {
|
|
76
|
+
throw rsNetworkError(error.subtype, error.message, {
|
|
77
|
+
retryable: error.retryable,
|
|
78
|
+
details: error.details,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
if (isE10SessionExpiredResponse(response)) {
|
|
84
|
+
throw rsAuthError('session_expired', E10_SESSION_EXPIRED_MESSAGE, { httpStatus: response.status });
|
|
85
|
+
}
|
|
86
|
+
if (response.parseError) {
|
|
87
|
+
if (response.status < 200 || response.status >= 300) {
|
|
88
|
+
throw new RecruitStageCliError('api', 'http_error', `泛微接口 HTTP ${response.status}`, {
|
|
89
|
+
code: response.status,
|
|
90
|
+
details: { status: response.status },
|
|
91
|
+
exitCode: 1,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
throw rsNetworkError('protocol', `接口返回不是合法 JSON(HTTP ${response.status})`, { retryable: false });
|
|
95
|
+
}
|
|
96
|
+
if (response.status < 200 || response.status >= 300) {
|
|
97
|
+
throw new RecruitStageCliError('api', 'http_error', `泛微接口 HTTP ${response.status}`, {
|
|
98
|
+
code: response.status,
|
|
99
|
+
details: { status: response.status, message: response.value?.msg },
|
|
100
|
+
exitCode: 1,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
// 注意:运行时对响应做了 parseJsonPreservingBigInts(16+ 位整数加引号保精度),
|
|
104
|
+
// 业务代码拿到的 18 位 id 已是字符串形态——脚本版「从原文提取 formDataIds 防丢精度」的
|
|
105
|
+
// 特殊处理在 CLI 侧不再需要。
|
|
106
|
+
return response.value;
|
|
107
|
+
}
|
|
108
|
+
return { request, getSession };
|
|
109
|
+
}
|