ai-worklens-agent 0.1.1 → 0.1.2

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/README.md CHANGED
@@ -36,7 +36,7 @@ npm run mcp
36
36
  如果管理员已经把员工端发布到 npm 或企业私有 npm 源,可以使用 `npx` 首次安装:
37
37
 
38
38
  ```bash
39
- npx -y -p ai-worklens-agent@0.1.0 worklens-agent-install \
39
+ NPM_CONFIG_UPDATE_NOTIFIER=false npx -y --loglevel=error -p ai-worklens-agent@0.1.2 worklens-agent-install \
40
40
  --server-url http://127.0.0.1:8797 \
41
41
  --tool codex \
42
42
  --employee-pinyin zhangsan
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-worklens-agent",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Employee-side collector agent for AI WorkLens.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/install.mjs CHANGED
@@ -580,6 +580,23 @@ function buildReadme(manifest) {
580
580
  ].join("\n") + "\n";
581
581
  }
582
582
 
583
+ function formatInstallSuccess(result, args) {
584
+ const tool = result.manifest?.selectedTool || args.tool || "codex";
585
+ const employeeAlias = args["employee-pinyin"] || args["employee-id"] || "未填写";
586
+ return [
587
+ "AI WorkLens 安装成功",
588
+ `工具: ${tool} / 注册名: ${employeeAlias}`,
589
+ `配置目录: ${result.targetDir}`
590
+ ].join("\n") + "\n";
591
+ }
592
+
593
+ function formatInstallFailure(error) {
594
+ return [
595
+ "AI WorkLens 安装失败",
596
+ `原因: ${error.message || "未知错误"}`
597
+ ].join("\n") + "\n";
598
+ }
599
+
583
600
  function isMainModule() {
584
601
  if (!process.argv[1]) return false;
585
602
  try {
@@ -591,21 +608,28 @@ function isMainModule() {
591
608
 
592
609
  if (isMainModule()) {
593
610
  const args = parseArgs(process.argv.slice(2));
594
- const result = installClient({
595
- targetDir: args["target-dir"],
596
- serverUrl: args["server-url"],
597
- collectorToken: args["collector-token"],
598
- employeeId: args["employee-id"],
599
- employeeName: args["employee-name"],
600
- employeePinyin: args["employee-pinyin"],
601
- department: args.department,
602
- role: args.role,
603
- clientId: args["client-id"],
604
- tool: args.tool,
605
- modelProvider: args["model-provider"],
606
- modelName: args["model-name"],
607
- modelVersion: args["model-version"],
608
- modelFamily: args["model-family"]
609
- });
610
- process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
611
+ try {
612
+ const result = installClient({
613
+ targetDir: args["target-dir"],
614
+ serverUrl: args["server-url"],
615
+ collectorToken: args["collector-token"],
616
+ employeeId: args["employee-id"],
617
+ employeeName: args["employee-name"],
618
+ employeePinyin: args["employee-pinyin"],
619
+ department: args.department,
620
+ role: args.role,
621
+ clientId: args["client-id"],
622
+ tool: args.tool,
623
+ modelProvider: args["model-provider"],
624
+ modelName: args["model-name"],
625
+ modelVersion: args["model-version"],
626
+ modelFamily: args["model-family"]
627
+ });
628
+ if (args.json) process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
629
+ else process.stdout.write(formatInstallSuccess(result, args));
630
+ } catch (error) {
631
+ if (args.json) process.stderr.write(`${JSON.stringify({ ok: false, error: error.message }, null, 2)}\n`);
632
+ else process.stderr.write(formatInstallFailure(error));
633
+ process.exitCode = 1;
634
+ }
611
635
  }