@roll-agent/smart-reply-agent 0.4.0 → 1.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.
Files changed (43) hide show
  1. package/SKILL.md +25 -37
  2. package/dist/index.js +1 -1
  3. package/dist/services/reply-authority-client.d.ts +2 -0
  4. package/dist/tools/generate-reply.d.ts +31 -43
  5. package/dist/types/candidate-info.d.ts +57 -0
  6. package/dist/types/funnel-stage.d.ts +4 -0
  7. package/dist/types/model-config.d.ts +66 -0
  8. package/dist/types/reply-authority.d.ts +785 -0
  9. package/package.json +2 -16
  10. package/references/env.yaml +6 -26
  11. package/data/brand-config.sample.json +0 -83
  12. package/dist/ai/model-registry.d.ts +0 -103
  13. package/dist/ai/structured-output.d.ts +0 -61
  14. package/dist/errors/app-error.d.ts +0 -42
  15. package/dist/errors/error-codes.d.ts +0 -48
  16. package/dist/errors/error-factory.d.ts +0 -30
  17. package/dist/errors/error-utils.d.ts +0 -39
  18. package/dist/errors/index.d.ts +0 -8
  19. package/dist/log-control.d.ts +0 -2
  20. package/dist/pipeline/age-eligibility.d.ts +0 -94
  21. package/dist/pipeline/candidate-context.d.ts +0 -8
  22. package/dist/pipeline/candidate-utils.d.ts +0 -5
  23. package/dist/pipeline/classification.d.ts +0 -13
  24. package/dist/pipeline/context-builder.d.ts +0 -21
  25. package/dist/pipeline/pipeline-progress.d.ts +0 -9
  26. package/dist/pipeline/reply-gate.d.ts +0 -19
  27. package/dist/pipeline/smart-reply.d.ts +0 -64
  28. package/dist/pipeline.d.ts +0 -21
  29. package/dist/pipeline.js +0 -1
  30. package/dist/services/brand-alias.d.ts +0 -4
  31. package/dist/services/brand-config-selectors.d.ts +0 -7
  32. package/dist/services/config-loader.d.ts +0 -11
  33. package/dist/services/duliday-api.d.ts +0 -30
  34. package/dist/services/duliday-mapper.d.ts +0 -8
  35. package/dist/tools/sync-brand-data.d.ts +0 -11
  36. package/dist/types/brand-resolution.d.ts +0 -83
  37. package/dist/types/classification.d.ts +0 -181
  38. package/dist/types/config.d.ts +0 -3
  39. package/dist/types/duliday-api.d.ts +0 -7197
  40. package/dist/types/geocoding.d.ts +0 -23
  41. package/dist/types/reply-policy.d.ts +0 -1390
  42. package/dist/types/zhipin.d.ts +0 -2196
  43. package/references/reply-policy-schema.md +0 -148
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roll-agent/smart-reply-agent",
3
- "version": "0.4.0",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,9 +13,7 @@
13
13
  "files": [
14
14
  "dist",
15
15
  "SKILL.md",
16
- "references",
17
- "data/brand-config.sample.json",
18
- "data/reply-policy.json"
16
+ "references"
19
17
  ],
20
18
  "engines": {
21
19
  "node": ">=22.6.0"
@@ -24,10 +22,6 @@
24
22
  ".": {
25
23
  "types": "./dist/index.d.ts",
26
24
  "default": "./dist/index.js"
27
- },
28
- "./pipeline": {
29
- "types": "./dist/pipeline.d.ts",
30
- "default": "./dist/pipeline.js"
31
25
  }
32
26
  },
33
27
  "publishConfig": {
@@ -46,14 +40,6 @@
46
40
  }
47
41
  },
48
42
  "dependencies": {
49
- "@ai-sdk/alibaba": "^1.0.17",
50
- "@ai-sdk/anthropic": "^3.0.68",
51
- "@ai-sdk/deepseek": "^2.0.29",
52
- "@ai-sdk/google": "^3.0.60",
53
- "@ai-sdk/openai": "^3.0.52",
54
- "@ai-sdk/openai-compatible": "^2.0.41",
55
- "ai": "^6.0.154",
56
- "ora": "^8.2.0",
57
43
  "zod": "^3.25.76",
58
44
  "@roll-agent/sdk": "0.1.5"
59
45
  },
@@ -1,27 +1,7 @@
1
1
  required:
2
- - name: DULIDAY_TOKEN
3
- purpose: Duliday 品牌别名与岗位 API 鉴权 token
4
- example: ${DULIDAY_TOKEN}
5
- - name: DULIDAY_BRAND_LIST_URL
6
- purpose: Duliday 品牌列表 API 地址
7
- example: ${DULIDAY_BRAND_LIST_URL}
8
- - name: DULIDAY_JOB_LIST_URL
9
- purpose: Duliday 岗位列表 API 地址
10
- example: ${DULIDAY_JOB_LIST_URL}
11
-
12
- optional:
13
- - name: ANTHROPIC_API_KEY
14
- purpose: Anthropic/OpenAI/OhMyGPT 统一代理鉴权 key(回退读取 OPENAI_API_KEY)
15
- example: ${ANTHROPIC_API_KEY}
16
- - name: OPENAI_API_KEY
17
- purpose: 兼容旧配置的鉴权 key;仅在未设置 ANTHROPIC_API_KEY 时作为回退
18
- example: ${OPENAI_API_KEY}
19
- - name: SMART_REPLY_PROXY_BASE_URL
20
- purpose: 统一代理地址,同时覆盖 anthropic/openai/ohmygpt 端点
21
- example: ${SMART_REPLY_PROXY_BASE_URL}
22
- - name: SMART_REPLY_CLASSIFY_MODEL
23
- purpose: 分类模型
24
- default: openai/gpt-5-mini
25
- - name: SMART_REPLY_REPLY_MODEL
26
- purpose: 回复模型
27
- default: openai/gpt-5.4
2
+ - name: REPLY_AUTHORITY_URL
3
+ purpose: Reply Authority Service 基础地址;`generate_reply` 直接转发到该服务,不再走本地 pipeline fallback
4
+ example: https://reply-authority.duliday.com
5
+ - name: REPLY_AUTHORITY_BEARER_TOKEN
6
+ purpose: Reply Authority Service Bearer token;服务端据此反查 clientId 并校验可访问的 tenantId
7
+ example: ${REPLY_AUTHORITY_BEARER_TOKEN}
@@ -1,83 +0,0 @@
1
- {
2
- "meta": {
3
- "defaultBrandId": "10001",
4
- "syncedAt": "2026-03-17T00:00:00.000Z",
5
- "source": "sample"
6
- },
7
- "brands": [
8
- {
9
- "id": "10001",
10
- "name": "示例品牌",
11
- "stores": [
12
- {
13
- "id": "store-001",
14
- "brandId": "10001",
15
- "name": "示例品牌南山店",
16
- "city": "深圳",
17
- "location": "深圳市南山区科技园路1号",
18
- "district": "南山区",
19
- "subarea": "科技园",
20
- "coordinates": { "lat": 22.5431, "lng": 113.9531 },
21
- "positions": [
22
- {
23
- "id": "pos-001",
24
- "name": "服务员",
25
- "sourceJobName": "示例品牌-南山店-服务员-兼职",
26
- "jobCategory": "普通服务员",
27
- "brandId": "10001",
28
- "brandName": "示例品牌",
29
- "description": "负责门店日常服务工作",
30
- "laborForm": "兼职",
31
- "employmentForm": "长期用工",
32
- "trainingRequired": "不需要",
33
- "probationRequired": "不需要",
34
- "timeSlots": ["08:00~14:00", "14:00~22:00"],
35
- "salary": {
36
- "base": 22,
37
- "unit": "元/时",
38
- "range": "20-25",
39
- "memo": "时薪制,多劳多得"
40
- },
41
- "workHours": "6",
42
- "benefits": {
43
- "insurance": "独立日购买",
44
- "accommodation": "无住宿福利",
45
- "catering": "包吃",
46
- "moreWelfares": null,
47
- "memo": null,
48
- "promotion": null
49
- },
50
- "availableSlots": [
51
- {
52
- "slot": "08:00~14:00",
53
- "maxCapacity": 5,
54
- "currentBooked": 3,
55
- "isAvailable": true,
56
- "priority": "high"
57
- }
58
- ],
59
- "minHoursPerWeek": 18,
60
- "maxHoursPerWeek": 42,
61
- "perMonthMinWorkTime": 80,
62
- "attendanceRequirement": {
63
- "minimumDays": 3,
64
- "requiredDays": [1, 2, 3, 4, 5],
65
- "description": "每周至少3天"
66
- },
67
- "hiringRequirements": {
68
- "minAge": 18,
69
- "maxAge": 45,
70
- "genderRequirement": null,
71
- "education": "不限",
72
- "healthCertificate": "食品健康证",
73
- "languages": "普通话",
74
- "certificatesRaw": "健康证",
75
- "recruitmentRemark": null
76
- }
77
- }
78
- ]
79
- }
80
- ]
81
- }
82
- ]
83
- }
@@ -1,103 +0,0 @@
1
- import type { LanguageModel } from "ai";
2
- import type { ProviderConfig } from "../types/classification.ts";
3
- export type ModelCategory = "chat" | "general";
4
- export declare const MODEL_DICTIONARY: {
5
- readonly "qwen/qwen-max-latest": {
6
- readonly provider: "qwen";
7
- readonly name: "Qwen Max Latest";
8
- readonly categories: ModelCategory[];
9
- };
10
- readonly "qwen/qwen-plus-latest": {
11
- readonly provider: "qwen";
12
- readonly name: "Qwen Plus Latest";
13
- readonly categories: ModelCategory[];
14
- };
15
- readonly "google/gemini-embedding-2-preview": {
16
- readonly provider: "google";
17
- readonly name: "Gemini Embedding 2 Preview";
18
- readonly categories: ModelCategory[];
19
- };
20
- readonly "google/gemini-3.1-flash-lite-preview": {
21
- readonly provider: "google";
22
- readonly name: "Gemini 3.1 Flash Lite Preview";
23
- readonly categories: ModelCategory[];
24
- };
25
- readonly "google/gemini-3.1-pro-preview": {
26
- readonly provider: "google";
27
- readonly name: "Gemini 3.1 Pro Preview";
28
- readonly categories: ModelCategory[];
29
- };
30
- readonly "anthropic/claude-sonnet-4-6": {
31
- readonly provider: "anthropic";
32
- readonly name: "Claude Sonnet 4.6";
33
- readonly categories: ModelCategory[];
34
- };
35
- readonly "anthropic/claude-opus-4-6": {
36
- readonly provider: "anthropic";
37
- readonly name: "Claude Opus 4.6";
38
- readonly categories: ModelCategory[];
39
- };
40
- readonly "anthropic/claude-haiku-4-5": {
41
- readonly provider: "anthropic";
42
- readonly name: "Claude Haiku 4.5";
43
- readonly categories: ModelCategory[];
44
- };
45
- readonly "openai/gpt-5.1": {
46
- readonly provider: "openai";
47
- readonly name: "GPT-5.1";
48
- readonly categories: ModelCategory[];
49
- };
50
- readonly "openai/gpt-5.2": {
51
- readonly provider: "openai";
52
- readonly name: "GPT-5.2";
53
- readonly categories: ModelCategory[];
54
- };
55
- readonly "openai/gpt-5.4": {
56
- readonly provider: "openai";
57
- readonly name: "GPT-5.4";
58
- readonly categories: ModelCategory[];
59
- };
60
- readonly "openai/gpt-5-mini": {
61
- readonly provider: "openai";
62
- readonly name: "GPT-5 Mini";
63
- readonly categories: ModelCategory[];
64
- };
65
- readonly "ohmygpt/gemini-3.1-flash-lite-preview": {
66
- readonly provider: "ohmygpt";
67
- readonly name: "Gemini 3.1 Flash Lite Preview (OhMyGPT)";
68
- readonly categories: ModelCategory[];
69
- };
70
- readonly "ohmygpt/gemini-3.1-pro-preview": {
71
- readonly provider: "ohmygpt";
72
- readonly name: "Gemini 3.1 Pro Preview (OhMyGPT)";
73
- readonly categories: ModelCategory[];
74
- };
75
- readonly "moonshotai/kimi-k2.5": {
76
- readonly provider: "moonshotai";
77
- readonly name: "Kimi K2.5";
78
- readonly categories: ModelCategory[];
79
- };
80
- readonly "moonshotai/kimi-k2-thinking-turbo": {
81
- readonly provider: "moonshotai";
82
- readonly name: "Kimi K2 Thinking Turbo";
83
- readonly categories: ModelCategory[];
84
- };
85
- readonly "deepseek/deepseek-chat": {
86
- readonly provider: "deepseek";
87
- readonly name: "DeepSeek Chat";
88
- readonly categories: ModelCategory[];
89
- };
90
- };
91
- export type ModelId = keyof typeof MODEL_DICTIONARY;
92
- export declare const DEFAULT_PROVIDER_CONFIGS: Record<string, ProviderConfig>;
93
- export declare const DEFAULT_MODEL_CONFIG: {
94
- readonly chatModel: ModelId;
95
- readonly classifyModel: "anthropic/claude-haiku-4-5" | "qwen/qwen-max-latest" | "qwen/qwen-plus-latest" | "google/gemini-embedding-2-preview" | "google/gemini-3.1-flash-lite-preview" | "google/gemini-3.1-pro-preview" | "anthropic/claude-sonnet-4-6" | "anthropic/claude-opus-4-6" | "openai/gpt-5.1" | "openai/gpt-5.2" | "openai/gpt-5.4" | "openai/gpt-5-mini" | "ohmygpt/gemini-3.1-flash-lite-preview" | "ohmygpt/gemini-3.1-pro-preview" | "moonshotai/kimi-k2.5" | "moonshotai/kimi-k2-thinking-turbo" | "deepseek/deepseek-chat";
96
- readonly replyModel: "anthropic/claude-haiku-4-5" | "qwen/qwen-max-latest" | "qwen/qwen-plus-latest" | "google/gemini-embedding-2-preview" | "google/gemini-3.1-flash-lite-preview" | "google/gemini-3.1-pro-preview" | "anthropic/claude-sonnet-4-6" | "anthropic/claude-opus-4-6" | "openai/gpt-5.1" | "openai/gpt-5.2" | "openai/gpt-5.4" | "openai/gpt-5-mini" | "ohmygpt/gemini-3.1-flash-lite-preview" | "ohmygpt/gemini-3.1-pro-preview" | "moonshotai/kimi-k2.5" | "moonshotai/kimi-k2-thinking-turbo" | "deepseek/deepseek-chat";
97
- };
98
- /** 只暴露 registry 实际被消费的 languageModel 方法,避免 .d.ts 引用内部类型导致 TS2742 */
99
- interface ModelRegistry {
100
- languageModel(modelId: string): LanguageModel;
101
- }
102
- export declare function getDynamicRegistry(providerConfigs: Record<string, ProviderConfig>): ModelRegistry;
103
- export {};
@@ -1,61 +0,0 @@
1
- import { type FlexibleSchema, type LanguageModel, type LanguageModelUsage } from "ai";
2
- import { z } from "zod";
3
- import { type AppError } from "../errors/index.ts";
4
- export interface SafeGenerateObjectOptions<T> {
5
- model: LanguageModel;
6
- schema: z.ZodType<T>;
7
- outputSchema?: FlexibleSchema<T> | undefined;
8
- schemaName?: string | undefined;
9
- system?: string | undefined;
10
- prompt: string;
11
- transformOutput?: ((value: unknown) => unknown | Promise<unknown>) | undefined;
12
- onError?: ((error: AppError, rawText?: string) => void) | undefined;
13
- }
14
- export interface SafeGenerateObjectSuccess<T> {
15
- success: true;
16
- data: T;
17
- usage?: LanguageModelUsage | undefined;
18
- }
19
- export interface SafeGenerateObjectFailure {
20
- success: false;
21
- error: AppError;
22
- rawText?: string | undefined;
23
- }
24
- export type SafeGenerateObjectResult<T> = SafeGenerateObjectSuccess<T> | SafeGenerateObjectFailure;
25
- /**
26
- * 按 JSON Schema type 声明不支持的关键词。
27
- * key = JSON Schema type 名称("array" | "number" | "integer" | "string" 等),
28
- * value = 该类型下需要剥离的关键词列表。
29
- * "integer" 会自动合并 "number" 的规则,无需重复声明。
30
- */
31
- export interface StructuredOutputCompatibilityOptions {
32
- unsupportedKeywordsByType?: Readonly<Record<string, readonly string[]>> | undefined;
33
- }
34
- export declare function createStructuredOutputCompatibilitySchema<T>(schema: FlexibleSchema<T>, options?: StructuredOutputCompatibilityOptions): FlexibleSchema<T>;
35
- export declare function safeGenerateObject<T>(options: SafeGenerateObjectOptions<T>): Promise<SafeGenerateObjectResult<T>>;
36
- export interface SafeGenerateTextOptions {
37
- model: LanguageModel;
38
- system?: string | undefined;
39
- prompt: string;
40
- timeoutMs?: number | undefined;
41
- maxOutputTokens?: number | undefined;
42
- context?: string | undefined;
43
- onError?: ((error: AppError) => void) | undefined;
44
- }
45
- export interface SafeGenerateTextUsage {
46
- inputTokens: number | undefined;
47
- outputTokens: number | undefined;
48
- totalTokens: number | undefined;
49
- }
50
- export interface SafeGenerateTextSuccess {
51
- success: true;
52
- text: string;
53
- usage?: SafeGenerateTextUsage | undefined;
54
- latencyMs: number;
55
- }
56
- export interface SafeGenerateTextFailure {
57
- success: false;
58
- error: AppError;
59
- }
60
- export type SafeGenerateTextResult = SafeGenerateTextSuccess | SafeGenerateTextFailure;
61
- export declare function safeGenerateText(options: SafeGenerateTextOptions): Promise<SafeGenerateTextResult>;
@@ -1,42 +0,0 @@
1
- import type { ErrorCode, ErrorCategory } from "./error-codes.ts";
2
- export interface AppErrorOptions {
3
- code: ErrorCode;
4
- message: string;
5
- userMessage?: string | undefined;
6
- cause?: Error | undefined;
7
- details?: unknown | undefined;
8
- }
9
- export interface SerializedAppError {
10
- code: ErrorCode;
11
- category: ErrorCategory;
12
- message: string;
13
- userMessage: string;
14
- timestamp: string;
15
- details?: unknown | undefined;
16
- cause?: SerializedAppError | {
17
- message: string;
18
- stack?: string | undefined;
19
- } | undefined;
20
- }
21
- export declare class AppError extends Error {
22
- readonly code: ErrorCode;
23
- readonly category: ErrorCategory;
24
- readonly userMessage: string;
25
- readonly details?: unknown | undefined;
26
- readonly cause?: Error | undefined;
27
- readonly timestamp: string;
28
- constructor(options: AppErrorOptions);
29
- toJSON(): SerializedAppError;
30
- getErrorChain(): Array<AppError | Error>;
31
- getRootCause(): Error;
32
- hasErrorCode(code: ErrorCode): boolean;
33
- hasErrorCategory(category: ErrorCategory): boolean;
34
- toLogString(): string;
35
- }
36
- export declare function isAppError(error: unknown): error is AppError;
37
- export declare function isErrorCode(error: unknown, code: ErrorCode): boolean;
38
- export declare function isErrorCategory(error: unknown, category: ErrorCategory): boolean;
39
- export declare function isLLMError(error: unknown): boolean;
40
- export declare function isConfigError(error: unknown): boolean;
41
- export declare function isNetworkError(error: unknown): boolean;
42
- export declare function isAuthError(error: unknown): boolean;
@@ -1,48 +0,0 @@
1
- export declare const ErrorCategory: {
2
- readonly CONFIG: "CONFIG";
3
- readonly AUTH: "AUTH";
4
- readonly NETWORK: "NETWORK";
5
- readonly LLM: "LLM";
6
- readonly VALIDATION: "VALIDATION";
7
- readonly BUSINESS: "BUSINESS";
8
- readonly SYSTEM: "SYSTEM";
9
- };
10
- export type ErrorCategory = (typeof ErrorCategory)[keyof typeof ErrorCategory];
11
- export declare const ErrorCode: {
12
- readonly LLM_UNAUTHORIZED: "LLM_UNAUTHORIZED";
13
- readonly LLM_MODEL_NOT_FOUND: "LLM_MODEL_NOT_FOUND";
14
- readonly LLM_RATE_LIMITED: "LLM_RATE_LIMITED";
15
- readonly LLM_TIMEOUT: "LLM_TIMEOUT";
16
- readonly LLM_GENERATION_FAILED: "LLM_GENERATION_FAILED";
17
- readonly LLM_RESPONSE_PARSE_ERROR: "LLM_RESPONSE_PARSE_ERROR";
18
- readonly CONFIG_NOT_FOUND: "CONFIG_NOT_FOUND";
19
- readonly CONFIG_INVALID: "CONFIG_INVALID";
20
- readonly CONFIG_MISSING_FIELD: "CONFIG_MISSING_FIELD";
21
- readonly CONFIG_LOAD_FAILED: "CONFIG_LOAD_FAILED";
22
- readonly NETWORK_TIMEOUT: "NETWORK_TIMEOUT";
23
- readonly NETWORK_CONNECTION_FAILED: "NETWORK_CONNECTION_FAILED";
24
- readonly NETWORK_HTTP_ERROR: "NETWORK_HTTP_ERROR";
25
- readonly NETWORK_DNS_FAILED: "NETWORK_DNS_FAILED";
26
- readonly AUTH_UNAUTHORIZED: "AUTH_UNAUTHORIZED";
27
- readonly AUTH_FORBIDDEN: "AUTH_FORBIDDEN";
28
- readonly AUTH_TOKEN_EXPIRED: "AUTH_TOKEN_EXPIRED";
29
- readonly AUTH_TOKEN_INVALID: "AUTH_TOKEN_INVALID";
30
- readonly VALIDATION_INVALID_INPUT: "VALIDATION_INVALID_INPUT";
31
- readonly VALIDATION_MISSING_REQUIRED: "VALIDATION_MISSING_REQUIRED";
32
- readonly VALIDATION_FORMAT_ERROR: "VALIDATION_FORMAT_ERROR";
33
- readonly VALIDATION_SCHEMA_ERROR: "VALIDATION_SCHEMA_ERROR";
34
- readonly BUSINESS_RULE_VIOLATION: "BUSINESS_RULE_VIOLATION";
35
- readonly BUSINESS_RESOURCE_NOT_FOUND: "BUSINESS_RESOURCE_NOT_FOUND";
36
- readonly BUSINESS_RESOURCE_EXISTS: "BUSINESS_RESOURCE_EXISTS";
37
- readonly BUSINESS_OPERATION_NOT_ALLOWED: "BUSINESS_OPERATION_NOT_ALLOWED";
38
- readonly SYSTEM_INTERNAL: "SYSTEM_INTERNAL";
39
- readonly SYSTEM_DEPENDENCY_FAILED: "SYSTEM_DEPENDENCY_FAILED";
40
- readonly SYSTEM_RESOURCE_UNAVAILABLE: "SYSTEM_RESOURCE_UNAVAILABLE";
41
- readonly SYSTEM_UNKNOWN: "SYSTEM_UNKNOWN";
42
- };
43
- export type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
44
- export declare const ERROR_CODE_TO_CATEGORY: Record<ErrorCode, ErrorCategory>;
45
- export declare const ERROR_USER_MESSAGES: Record<ErrorCode, string>;
46
- export declare function getErrorCategory(code: ErrorCode): ErrorCategory;
47
- export declare function getErrorUserMessage(code: ErrorCode): string;
48
- export declare function isErrorInCategory(code: ErrorCode, category: ErrorCategory): boolean;
@@ -1,30 +0,0 @@
1
- import { AppError } from "./app-error.ts";
2
- import { ErrorCode } from "./error-codes.ts";
3
- export interface LLMErrorContext {
4
- model?: string | undefined;
5
- provider?: string | undefined;
6
- statusCode?: number | undefined;
7
- responseBody?: string | undefined;
8
- }
9
- export interface StructuredOutputErrorContext extends LLMErrorContext {
10
- rawText?: string | undefined;
11
- isMarkdownFormat?: boolean | undefined;
12
- parseErrorMessage?: string | undefined;
13
- schemaName?: string | undefined;
14
- usage?: unknown | undefined;
15
- }
16
- export declare function createLLMError(code: typeof ErrorCode.LLM_UNAUTHORIZED | typeof ErrorCode.LLM_MODEL_NOT_FOUND | typeof ErrorCode.LLM_RATE_LIMITED | typeof ErrorCode.LLM_TIMEOUT | typeof ErrorCode.LLM_GENERATION_FAILED | typeof ErrorCode.LLM_RESPONSE_PARSE_ERROR, cause: Error, context?: LLMErrorContext): AppError;
17
- export declare function createConfigError(code: typeof ErrorCode.CONFIG_NOT_FOUND | typeof ErrorCode.CONFIG_INVALID | typeof ErrorCode.CONFIG_MISSING_FIELD | typeof ErrorCode.CONFIG_LOAD_FAILED, message: string, context?: {
18
- configKey?: string;
19
- missingFields?: string[];
20
- expectedType?: string;
21
- }, cause?: Error): AppError;
22
- export declare function createNetworkError(code: typeof ErrorCode.NETWORK_TIMEOUT | typeof ErrorCode.NETWORK_CONNECTION_FAILED | typeof ErrorCode.NETWORK_HTTP_ERROR | typeof ErrorCode.NETWORK_DNS_FAILED, cause: Error, context?: {
23
- url?: string;
24
- statusCode?: number;
25
- method?: string;
26
- }): AppError;
27
- export declare function createValidationError(code: typeof ErrorCode.VALIDATION_INVALID_INPUT | typeof ErrorCode.VALIDATION_MISSING_REQUIRED | typeof ErrorCode.VALIDATION_FORMAT_ERROR | typeof ErrorCode.VALIDATION_SCHEMA_ERROR, message: string, details?: unknown): AppError;
28
- export declare function createBusinessError(code: typeof ErrorCode.BUSINESS_RULE_VIOLATION | typeof ErrorCode.BUSINESS_RESOURCE_NOT_FOUND | typeof ErrorCode.BUSINESS_RESOURCE_EXISTS | typeof ErrorCode.BUSINESS_OPERATION_NOT_ALLOWED, message: string, userMessage?: string, details?: unknown): AppError;
29
- export declare function createSystemError(code: typeof ErrorCode.SYSTEM_INTERNAL | typeof ErrorCode.SYSTEM_DEPENDENCY_FAILED | typeof ErrorCode.SYSTEM_RESOURCE_UNAVAILABLE | typeof ErrorCode.SYSTEM_UNKNOWN, message: string, cause?: Error, details?: unknown): AppError;
30
- export declare function createStructuredOutputError(code: typeof ErrorCode.LLM_RESPONSE_PARSE_ERROR, cause: Error, context: StructuredOutputErrorContext): AppError;
@@ -1,39 +0,0 @@
1
- import { AppError } from "./app-error.ts";
2
- import type { ErrorCode, ErrorCategory } from "./error-codes.ts";
3
- interface AISDKErrorInfo {
4
- isAuthError: boolean;
5
- isModelNotFound: boolean;
6
- isRateLimited: boolean;
7
- isTimeout: boolean;
8
- statusCode?: number | undefined;
9
- provider?: string | undefined;
10
- model?: string | undefined;
11
- originalMessage?: string | undefined;
12
- responseBody?: string | undefined;
13
- }
14
- export interface NoObjectGeneratedErrorInfo {
15
- isNoObjectGeneratedError: boolean;
16
- rawText?: string | undefined;
17
- isMarkdownFormat: boolean;
18
- cause?: Error | undefined;
19
- response?: {
20
- id?: string | undefined;
21
- timestamp?: Date | undefined;
22
- modelId?: string | undefined;
23
- } | undefined;
24
- usage?: unknown | undefined;
25
- }
26
- export declare function parseAISDKError(error: unknown): AISDKErrorInfo | null;
27
- export declare function parseNoObjectGeneratedError(error: unknown): NoObjectGeneratedErrorInfo | null;
28
- export declare function wrapError(error: unknown, fallbackCode?: ErrorCode, userMessage?: string): AppError;
29
- export declare function toError(error: unknown): Error;
30
- export interface ErrorContext {
31
- errorCode: ErrorCode;
32
- category: ErrorCategory;
33
- originalError?: string | undefined;
34
- details?: unknown | undefined;
35
- }
36
- export declare function extractErrorContext(error: AppError): ErrorContext;
37
- export declare function getUserMessage(error: unknown): string;
38
- export declare function logError(context: string, error: AppError): void;
39
- export {};
@@ -1,8 +0,0 @@
1
- export { ErrorCode, ErrorCategory, ERROR_CODE_TO_CATEGORY, ERROR_USER_MESSAGES, getErrorCategory, getErrorUserMessage, isErrorInCategory, } from "./error-codes.ts";
2
- export type { ErrorCode as ErrorCodeType, ErrorCategory as ErrorCategoryType, } from "./error-codes.ts";
3
- export { AppError, isAppError, isErrorCode, isErrorCategory, isLLMError, isConfigError, isNetworkError, isAuthError, } from "./app-error.ts";
4
- export type { AppErrorOptions, SerializedAppError } from "./app-error.ts";
5
- export { createLLMError, createConfigError, createNetworkError, createValidationError, createBusinessError, createSystemError, createStructuredOutputError, } from "./error-factory.ts";
6
- export type { LLMErrorContext, StructuredOutputErrorContext } from "./error-factory.ts";
7
- export { wrapError, toError, parseAISDKError, parseNoObjectGeneratedError, extractErrorContext, getUserMessage, logError, } from "./error-utils.ts";
8
- export type { ErrorContext, NoObjectGeneratedErrorInfo } from "./error-utils.ts";
@@ -1,2 +0,0 @@
1
- export declare function setSuppressVerboseLogs(value: boolean): void;
2
- export declare function verboseLog(...args: unknown[]): void;
@@ -1,94 +0,0 @@
1
- import { z } from "zod";
2
- import type { AgeQualificationPolicy } from "../types/reply-policy.ts";
3
- import type { ZhipinData } from "../types/zhipin.ts";
4
- export declare const AGE_ELIGIBILITY_STATUSES: readonly ["pass", "fail", "unknown"];
5
- export type AgeEligibilityStatus = (typeof AGE_ELIGIBILITY_STATUSES)[number];
6
- export declare const AgeEvidenceSchema: z.ZodObject<{
7
- minAge: z.ZodNullable<z.ZodNumber>;
8
- maxAge: z.ZodNullable<z.ZodNumber>;
9
- }, "strip", z.ZodTypeAny, {
10
- minAge: number | null;
11
- maxAge: number | null;
12
- }, {
13
- minAge: number | null;
14
- maxAge: number | null;
15
- }>;
16
- export type AgeEvidence = z.infer<typeof AgeEvidenceSchema>;
17
- export declare const AgeEvidenceCollectionSchema: z.ZodObject<{
18
- evidence: z.ZodArray<z.ZodObject<{
19
- minAge: z.ZodNullable<z.ZodNumber>;
20
- maxAge: z.ZodNullable<z.ZodNumber>;
21
- }, "strip", z.ZodTypeAny, {
22
- minAge: number | null;
23
- maxAge: number | null;
24
- }, {
25
- minAge: number | null;
26
- maxAge: number | null;
27
- }>, "many">;
28
- matchedCount: z.ZodNumber;
29
- total: z.ZodNumber;
30
- isComplete: z.ZodBoolean;
31
- }, "strip", z.ZodTypeAny, {
32
- total: number;
33
- evidence: {
34
- minAge: number | null;
35
- maxAge: number | null;
36
- }[];
37
- matchedCount: number;
38
- isComplete: boolean;
39
- }, {
40
- total: number;
41
- evidence: {
42
- minAge: number | null;
43
- maxAge: number | null;
44
- }[];
45
- matchedCount: number;
46
- isComplete: boolean;
47
- }>;
48
- export type AgeEvidenceCollection = z.infer<typeof AgeEvidenceCollectionSchema>;
49
- export type AgeEvidenceSourceResult = AgeEvidence[] | AgeEvidenceCollection;
50
- export type AgeEligibilityQuery = {
51
- brandAlias?: string | null;
52
- cityName?: string | null;
53
- regionName?: string | null;
54
- };
55
- export interface AgeEligibilitySource {
56
- name: string;
57
- collect(query: AgeEligibilityQuery): Promise<AgeEvidenceSourceResult>;
58
- }
59
- export type AgeEligibilitySummary = {
60
- minAgeObserved: number | null;
61
- maxAgeObserved: number | null;
62
- matchedCount: number;
63
- total: number;
64
- };
65
- export type AgeEligibilityAppliedStrategy = AgeQualificationPolicy & {
66
- status: AgeEligibilityStatus;
67
- strategy: string;
68
- };
69
- export type AgeEligibilityResult = {
70
- status: AgeEligibilityStatus;
71
- summary: AgeEligibilitySummary;
72
- appliedStrategy: AgeEligibilityAppliedStrategy;
73
- };
74
- export declare function createConfigDataAgeSource(configData: ZhipinData): AgeEligibilitySource;
75
- export declare function createDulidayApiAgeSource({ token, jobListUrl, }: {
76
- token: string;
77
- jobListUrl: string;
78
- }): AgeEligibilitySource;
79
- export declare function createDefaultAgeEligibilitySources({ configData, token, jobListUrl, }: {
80
- configData: ZhipinData;
81
- token?: string | null | undefined;
82
- jobListUrl?: string | null | undefined;
83
- }): AgeEligibilitySource[];
84
- export declare function collectAgeEvidenceFromSources({ sources, ...query }: AgeEligibilityQuery & {
85
- sources?: AgeEligibilitySource[] | undefined;
86
- }): Promise<AgeEvidenceCollection>;
87
- export declare function evaluateAgeEligibility({ age, evidence, matchedCount, total, isComplete, strategy, }: {
88
- age?: number | null;
89
- evidence: AgeEvidence[];
90
- matchedCount?: number | undefined;
91
- total?: number | undefined;
92
- isComplete?: boolean | undefined;
93
- strategy?: AgeQualificationPolicy;
94
- }): AgeEligibilityResult;
@@ -1,8 +0,0 @@
1
- import type { CandidateInfo } from "../types/zhipin.ts";
2
- export interface KnownCandidateContext {
3
- /** 写入 user prompt 的已知事实文本,空字符串表示无已知信息 */
4
- factsText: string;
5
- /** 已知字段的中文标签列表,用于 system prompt 的"不得追问"约束 */
6
- knownFieldNames: string[];
7
- }
8
- export declare function buildKnownCandidateContext(candidateInfo?: CandidateInfo): KnownCandidateContext;
@@ -1,5 +0,0 @@
1
- import type { TurnPlan } from "../types/reply-policy.ts";
2
- import type { CandidateInfo } from "../types/zhipin.ts";
3
- export declare function parseAge(ageStr?: string): string | undefined;
4
- export declare function resolveCandidateAge(turnPlan: TurnPlan, candidateInfo?: CandidateInfo): number | undefined;
5
- export declare function resolveRegionName(turnPlan: TurnPlan, candidateInfo?: CandidateInfo): string | undefined;
@@ -1,13 +0,0 @@
1
- import type { TurnPlan, ReplyNeed, ReplyPolicyConfig } from "../types/reply-policy.ts";
2
- import type { ProviderConfigs, ClassificationOptions } from "../types/classification.ts";
3
- export declare function normalizeGeneratedTurnPlanOutput(value: unknown): unknown;
4
- export declare const PRIMARY_NEED_PRIORITY: readonly ["salary", "schedule", "location", "stores", "policy", "requirements", "availability", "interview", "wechat", "none"];
5
- export declare function detectRuleNeeds(message: string, history: string[]): Set<ReplyNeed>;
6
- export declare function selectContextNeeds(primaryNeed: ReplyNeed, availableNeedsInput: Iterable<ReplyNeed>, message: string, maxNeeds?: number): ReplyNeed[];
7
- export declare function selectPrimaryNeed(plannedPrimaryNeed: ReplyNeed | undefined, mergedNeedsInput: Iterable<ReplyNeed>, message: string): ReplyNeed;
8
- export declare function sanitizePlan(plan: TurnPlan, ruleNeeds: Set<ReplyNeed>, message: string): TurnPlan;
9
- export declare function planTurn(message: string, options: Omit<ClassificationOptions, "candidateMessage"> & {
10
- providerConfigs?: ProviderConfigs;
11
- replyPolicy?: Pick<ReplyPolicyConfig, "stageGoals">;
12
- knownCandidateFields?: string[];
13
- }): Promise<TurnPlan>;
@@ -1,21 +0,0 @@
1
- import type { ZhipinData, CandidateInfo } from "../types/zhipin.ts";
2
- import type { BrandPriorityStrategy } from "../types/config.ts";
3
- import type { BrandResolutionInput, BrandResolutionOutput } from "../types/brand-resolution.ts";
4
- import type { StoreWithDistance } from "../types/geocoding.ts";
5
- import type { TurnPlan, ReplyNeed, ReplyPolicyConfig, EffectiveDisclosureMode } from "../types/reply-policy.ts";
6
- interface PolicyContextDebugInfo {
7
- relevantStores: StoreWithDistance[];
8
- storeCount: number;
9
- detailLevel: EffectiveDisclosureMode;
10
- primaryNeed: ReplyNeed;
11
- turnPlan: TurnPlan;
12
- aliasLookupError?: string | undefined;
13
- }
14
- export type { PolicyContextDebugInfo };
15
- export declare function fuzzyMatchBrand(inputBrand: string, availableBrands: string[], aliasMap?: Map<string, string>): string | null;
16
- export declare function resolveBrandConflict(input: BrandResolutionInput): BrandResolutionOutput;
17
- export declare function buildContextInfoByNeeds(data: ZhipinData, turnPlan: TurnPlan, uiSelectedBrand?: string, toolBrand?: string, brandPriorityStrategy?: BrandPriorityStrategy, candidateInfo?: CandidateInfo, replyPolicy?: ReplyPolicyConfig, industryVoiceId?: string, turnIndex?: number, disclosureMode?: EffectiveDisclosureMode, factNeeds?: ReplyNeed[]): Promise<{
18
- contextInfo: string;
19
- resolvedBrand: string;
20
- debugInfo: PolicyContextDebugInfo;
21
- }>;