@pactor-app/skills 1.33.0 → 1.35.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/package.json +1 -1
- package/pactor-prd/SKILL.md +20 -23
- package/pactor-prd/references/acceptance-checklist.md +1 -1
- package/pactor-prd/references/data-api.md +35 -0
- package/pactor-prd/references/incremental-wireframe-delta.md +8 -9
- package/pactor-prd/references/page-inventory-and-files.md +2 -2
- package/pactor-prd/references/page-templates.md +59 -12
- package/pactor-prd/references/project-structure.md +1 -1
- package/pactor-prd/template/README.md +4 -4
- package/pactor-prd/template/app/api/d/[...parts]/route.ts +80 -0
- package/pactor-prd/template/app/layout.tsx +1 -3
- package/pactor-prd/template/next-env.d.ts +2 -2
- package/pactor-prd/template/next.config.js +2 -2
- package/pactor-prd/template/package.json +4 -4
- package/pactor-prd/template/pnpm-lock.yaml +97 -97
- package/pactor-prd/template/src/pactor/App.tsx +3 -2
- package/pactor-prd/template/src/pactor/actions.ts +5 -431
- package/pactor-prd/template/src/pactor/config.ts +12 -4
- package/pactor-prd/template/src/server/yaml/common/dashboard.yaml +1 -1
- package/pactor-prd/template/src/server/yaml/common/login.yaml +46 -75
- package/pactor-prd/template/src/server/yaml/models/data-list.yaml +344 -0
- package/pactor-prd/template/src/server/yaml/provider/provider-detail.yaml +2 -2
- package/pactor-prd/template/src/server/yaml/provider/provider-edit.yaml +1 -1
- package/pactor-prd/template/src/server/yaml/provider/provider-list.yaml +1 -1
- package/pactor-prd/template/src/server/yaml/route/route-detail.yaml +1 -1
- package/pactor-prd/template/src/server/yaml/route/route-edit.yaml +1 -1
- package/pactor-prd/template/src/server/yaml/route/route-list.yaml +1 -1
- package/pactor-prd/template/src/server/yaml/sitemap.yaml +23 -6
- package/pactor-prd/references/mock-data-routes.md +0 -66
- package/pactor-prd/template/app/api/data/[...parts]/route.ts +0 -118
- package/pactor-prd/template/app/login.css +0 -122
- package/pactor-prd/template/src/pactor/mocks/audit-mock.ts +0 -403
- package/pactor-prd/template/src/pactor/mocks/call-logs-mock.ts +0 -875
- package/pactor-prd/template/src/pactor/mocks/client-debug-mock.ts +0 -188
- package/pactor-prd/template/src/pactor/mocks/client-templates-mock.ts +0 -497
- package/pactor-prd/template/src/pactor/mocks/clients-mock.ts +0 -483
- package/pactor-prd/template/src/pactor/mocks/costs-mock.ts +0 -406
- package/pactor-prd/template/src/pactor/mocks/dashboard-mock.ts +0 -192
- package/pactor-prd/template/src/pactor/mocks/model-debug-mock.ts +0 -144
- package/pactor-prd/template/src/pactor/mocks/models-mock.ts +0 -799
- package/pactor-prd/template/src/pactor/mocks/ops-usage-mock.ts +0 -806
- package/pactor-prd/template/src/pactor/mocks/providers-mock.ts +0 -424
- package/pactor-prd/template/src/pactor/mocks/routes-mock.ts +0 -604
- package/pactor-prd/template/src/pactor/services.ts +0 -185
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 模型调试(调试台)演示数据与调用模拟(MVP mock,静态页面)。
|
|
3
|
-
* 对齐 PRD《调试台/02-模型调试》:直连供应商模型(Provider → Model,
|
|
4
|
-
* 不经过 AppKey / Route 业务链路),验证连通性与效果;
|
|
5
|
-
* 参数按 Model Capability 动态显示(reasoning_effort 仅推理模型,
|
|
6
|
-
* Streaming / Tools 按能力启用)。
|
|
7
|
-
* 供应商与模型选项复用模型资产 mock(providers-mock / models-mock);
|
|
8
|
-
* 接入真实后端后替换为直连调用,组件 props 契约不变。
|
|
9
|
-
* 安全约束:不展示 Provider Credential 明文(连接测试仅返回可达性结论)。
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { PROVIDER_CODES, getProvider } from "./providers-mock";
|
|
13
|
-
import { getModel } from "./models-mock";
|
|
14
|
-
|
|
15
|
-
/** 供应商选项:启用中的 Provider(直连调试不校验密钥状态,连接测试再探) */
|
|
16
|
-
export const DEBUG_PROVIDER_OPTIONS: { value: string; label: string }[] =
|
|
17
|
-
PROVIDER_CODES.map((code) => getProvider(code))
|
|
18
|
-
.filter((p) => p && p.status === "enabled")
|
|
19
|
-
.map((p) => ({ value: p!.code, label: p!.displayName || p!.name }));
|
|
20
|
-
|
|
21
|
-
/** 供应商下已接入(ONLINE)的模型选项;切换供应商时联动刷新 */
|
|
22
|
-
export function modelOptionsOf(providerCode: string) {
|
|
23
|
-
const p = getProvider(providerCode);
|
|
24
|
-
return (p?.models ?? [])
|
|
25
|
-
.filter((m) => m.status === "ONLINE")
|
|
26
|
-
.map((m) => ({ value: m.code, label: `${m.name}(${m.providerModelId})` }));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** 模型能力(来自 Model 默认参数 Tab 的 capabilities) */
|
|
30
|
-
export function capabilitiesOf(modelCode: string): string[] {
|
|
31
|
-
return getModel(modelCode)?.params.capabilities ?? [];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** 是否推理模型(reasoning_effort 参数按此显示;mock 以默认参数非「—」判定) */
|
|
35
|
-
export function supportsReasoning(modelCode: string): boolean {
|
|
36
|
-
const effort = getModel(modelCode)?.params.reasoningEffort;
|
|
37
|
-
return !!effort && effort !== "—";
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function numOrUndef(text: string | undefined): number | undefined {
|
|
41
|
-
const n = Number(text);
|
|
42
|
-
return text && text !== "—" && Number.isFinite(n) ? n : undefined;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** 模型默认参数(编辑页「默认参数」同源),切换模型后回填右侧参数区 */
|
|
46
|
-
export function paramDefaultsOf(modelCode: string): {
|
|
47
|
-
temperature?: number;
|
|
48
|
-
topP?: number;
|
|
49
|
-
maxTokens?: number;
|
|
50
|
-
reasoningEffort?: string;
|
|
51
|
-
} {
|
|
52
|
-
const params = getModel(modelCode)?.params;
|
|
53
|
-
return {
|
|
54
|
-
temperature: numOrUndef(params?.temperature),
|
|
55
|
-
topP: numOrUndef(params?.topP),
|
|
56
|
-
maxTokens: numOrUndef(params?.maxTokens),
|
|
57
|
-
reasoningEffort:
|
|
58
|
-
params?.reasoningEffort && params.reasoningEffort !== "—"
|
|
59
|
-
? params.reasoningEffort
|
|
60
|
-
: "medium",
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export const REASONING_EFFORT_OPTIONS = [
|
|
65
|
-
{ value: "low", label: "low" },
|
|
66
|
-
{ value: "medium", label: "medium" },
|
|
67
|
-
{ value: "high", label: "high" },
|
|
68
|
-
];
|
|
69
|
-
|
|
70
|
-
export interface ConnectionTestResult {
|
|
71
|
-
ok: boolean;
|
|
72
|
-
latencyMs: number;
|
|
73
|
-
detail: string;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/** 连接测试:不发对话,仅探测凭证与 Endpoint 可达性(mock 按密钥状态判定) */
|
|
77
|
-
export function testConnection(providerCode: string): ConnectionTestResult {
|
|
78
|
-
const p = getProvider(providerCode);
|
|
79
|
-
const latencyMs = 80 + Math.floor(Math.random() * 220);
|
|
80
|
-
if (!p) return { ok: false, latencyMs, detail: "供应商不存在" };
|
|
81
|
-
if (p.keyStatus !== "configured") {
|
|
82
|
-
return {
|
|
83
|
-
ok: false,
|
|
84
|
-
latencyMs,
|
|
85
|
-
detail: p.keyStatus === "pending" ? "API Key 待配置" : "未配置 API Key",
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
return { ok: true, latencyMs, detail: `${p.baseUrl} 可达` };
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export interface ModelDebugParams {
|
|
92
|
-
temperature?: number;
|
|
93
|
-
topP?: number;
|
|
94
|
-
maxTokens?: number;
|
|
95
|
-
reasoningEffort?: string;
|
|
96
|
-
streaming: boolean;
|
|
97
|
-
tools: boolean;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/** 一次直连调用的结果(回复全文 + assistant 消息下方紧凑摘要字段) */
|
|
101
|
-
export interface ModelDebugResult {
|
|
102
|
-
reply: string;
|
|
103
|
-
tokensIn: number;
|
|
104
|
-
tokensOut: number;
|
|
105
|
-
ttftMs: number;
|
|
106
|
-
latencyMs: number;
|
|
107
|
-
status: number;
|
|
108
|
-
requestId: string;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function roughTokens(text: string) {
|
|
112
|
-
return Math.max(8, Math.round(text.length / 2));
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/** 模拟直连上游生成(流式时由调用方按 reply 逐段渲染) */
|
|
116
|
-
export function simulateModelCall(
|
|
117
|
-
providerCode: string,
|
|
118
|
-
modelCode: string,
|
|
119
|
-
systemPrompt: string,
|
|
120
|
-
params: ModelDebugParams,
|
|
121
|
-
userText: string,
|
|
122
|
-
): ModelDebugResult {
|
|
123
|
-
const p = getProvider(providerCode);
|
|
124
|
-
const m = getModel(modelCode);
|
|
125
|
-
const reply = [
|
|
126
|
-
`我是 ${m?.name ?? modelCode}(由 ${p?.displayName ?? providerCode} 提供)。`,
|
|
127
|
-
"",
|
|
128
|
-
`你刚才说的是:「${userText.length > 40 ? `${userText.slice(0, 40)}…` : userText}」`,
|
|
129
|
-
"",
|
|
130
|
-
`本次调用参数:temperature=${params.temperature ?? "默认"},top_p=${params.topP ?? "默认"},max_tokens=${params.maxTokens ?? "默认"}${params.reasoningEffort ? `,reasoning_effort=${params.reasoningEffort}` : ""},stream=${params.streaming ? "true" : "false"}${params.tools ? ",已启用 Tools" : ""}${systemPrompt ? ",已应用 System Prompt" : ""}。`,
|
|
131
|
-
].join("\n");
|
|
132
|
-
const tokensIn = roughTokens(systemPrompt + userText) + 9;
|
|
133
|
-
const tokensOut = roughTokens(reply);
|
|
134
|
-
const ttftMs = 100 + Math.floor(Math.random() * 150);
|
|
135
|
-
return {
|
|
136
|
-
reply,
|
|
137
|
-
tokensIn,
|
|
138
|
-
tokensOut,
|
|
139
|
-
ttftMs,
|
|
140
|
-
latencyMs: ttftMs + 120 + Math.floor(Math.random() * 260),
|
|
141
|
-
status: 200,
|
|
142
|
-
requestId: `req-${Math.random().toString(16).slice(2, 10).padEnd(8, "0")}`,
|
|
143
|
-
};
|
|
144
|
-
}
|