@dsh-plus/notify-email 0.1.20 → 0.1.22

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/lib/index.js CHANGED
@@ -355,6 +355,17 @@ function extractErrorMessage(reason) {
355
355
  const message = error.message;
356
356
  return typeof message === "string" ? message : void 0;
357
357
  }
358
+ /**
359
+ * agent 是否仍留有已接收但未认领的工作。
360
+ * `hasPending` 未进 Inbox 契约面——它只是 dsh-agent-loop 的 ReactLoopInbox
361
+ * 实现 getter(官方唯一的 `agent.inbox` 赋值点),故按「实现面存在才读」
362
+ * 收窄:实现缺席即视为无待处理工作;存在时读到的正是该 getter,取值与
363
+ * 契约面的 nextTurn/nextStep 非空判定一致。
364
+ */
365
+ function hasPendingWork(inbox) {
366
+ if (!("hasPending" in inbox)) return false;
367
+ return inbox.hasPending === true;
368
+ }
358
369
  function installTurnEndWatcher(ctx, service, resolveConfig) {
359
370
  const watches = /* @__PURE__ */ new Map();
360
371
  const logger = ctx.logger("notify-email");
@@ -369,7 +380,7 @@ function installTurnEndWatcher(ctx, service, resolveConfig) {
369
380
  const fire = (session, turn, kind, errorMessage) => {
370
381
  const agent = ctx.agents.get(session.id);
371
382
  if (agent === void 0) return;
372
- if (agent.status !== "idle" || agent.inbox.hasPending) return;
383
+ if (agent.status !== "idle" || hasPendingWork(agent.inbox)) return;
373
384
  if (!ctx.agents.roots().includes(agent)) return;
374
385
  const watch = watchOf(session.id);
375
386
  const key = `${turn}:${kind}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsh-plus/notify-email",
3
- "version": "0.1.20",
3
+ "version": "0.1.22",
4
4
  "description": "dsh-plus service+ui plugin: 任务结束/等待决策/出错时向指定邮箱发送邮件通知",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -31,30 +31,30 @@
31
31
  }
32
32
  },
33
33
  "dependencies": {
34
- "@dsh-plus/shared": "0.1.13",
35
- "nodemailer": "9.0.6"
34
+ "nodemailer": "9.0.6",
35
+ "@dsh-plus/shared": "0.1.15"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@deepseek-ai/cordis": "^4.0.2",
39
- "@deepseek-ai/dsh-home-paths": "^0.1.5-alpha.2",
40
- "@deepseek-ai/dsh-settings": "^0.1.5-alpha.2",
39
+ "@deepseek-ai/dsh-home-paths": "^0.1.5-rc.1",
40
+ "@deepseek-ai/dsh-settings": "^0.1.5-rc.1",
41
41
  "@deepseek-ai/schemastery": "^3.18.2",
42
- "@deepseek-ai/dsh-credentials": "^0.1.5-alpha.2"
42
+ "@deepseek-ai/dsh-credentials": "^0.1.5-rc.1"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@deepseek-ai/cordis": "4.0.2",
46
- "@deepseek-ai/dsh-agent": "0.1.5-alpha.2",
47
- "@deepseek-ai/dsh-home-paths": "0.1.5-alpha.2",
48
- "@deepseek-ai/dsh-host-webserver": "0.1.5-alpha.2",
49
- "@deepseek-ai/dsh-llm": "0.1.5-alpha.2",
50
- "@deepseek-ai/dsh-session": "0.1.5-alpha.2",
51
- "@deepseek-ai/dsh-settings": "0.1.5-alpha.2",
52
- "@deepseek-ai/dsh-tools": "0.1.5-alpha.2",
46
+ "@deepseek-ai/dsh-agent": "0.1.5-rc.1",
47
+ "@deepseek-ai/dsh-home-paths": "0.1.5-rc.1",
48
+ "@deepseek-ai/dsh-host-webserver": "0.1.5-rc.1",
49
+ "@deepseek-ai/dsh-llm": "0.1.5-rc.1",
50
+ "@deepseek-ai/dsh-session": "0.1.5-rc.1",
51
+ "@deepseek-ai/dsh-settings": "0.1.5-rc.1",
52
+ "@deepseek-ai/dsh-tools": "0.1.5-rc.1",
53
53
  "@deepseek-ai/schemastery": "3.18.2",
54
54
  "@types/nodemailer": "8.0.1",
55
55
  "@types/react": "~18.3.31",
56
56
  "react": "^18.2.0",
57
- "@deepseek-ai/dsh-credentials": "0.1.5-alpha.2"
57
+ "@deepseek-ai/dsh-credentials": "0.1.5-rc.1"
58
58
  },
59
59
  "publishConfig": {
60
60
  "access": "public"
package/src/config-api.ts CHANGED
@@ -7,6 +7,8 @@
7
7
  import type { IncomingMessage, ServerResponse } from 'node:http'
8
8
 
9
9
  import type { Context } from '@deepseek-ai/cordis'
10
+ // 平台声明导入(无值消费):把 webServer 服务面合进 program,ctx.webServer 方可解析。
11
+ import type {} from '@deepseek-ai/dsh-host-webserver'
10
12
 
11
13
  import type { NotifyEmailService } from './service.ts'
12
14
 
@@ -5,6 +5,9 @@
5
5
  * @module notify-email/watchers/decision
6
6
  */
7
7
  import type { Context } from '@deepseek-ai/cordis'
8
+ // 平台声明导入(无值消费):把 dsh-tools 的 'tools/pre-execute' 事件与
9
+ // ToolExecution 参数/next 签名合进 program(事件名真名即此,非拼写错误)。
10
+ import type {} from '@deepseek-ai/dsh-tools'
8
11
 
9
12
  import type { NotifyEmailService } from '../service.ts'
10
13
 
@@ -7,6 +7,8 @@
7
7
  * @module notify-email/watchers/turn-end
8
8
  */
9
9
  import type { Context } from '@deepseek-ai/cordis'
10
+ // 平台声明导入:把 agent 服务面(ctx.agents)与 Inbox 契约合进 program。
11
+ import type { Inbox } from '@deepseek-ai/dsh-agent'
10
12
  import type { Session, TurnEndReason } from '@deepseek-ai/dsh-session'
11
13
 
12
14
  import type { NotifyEmailConfig } from '../config.ts'
@@ -44,6 +46,18 @@ function extractErrorMessage(reason: unknown): string | undefined {
44
46
  return typeof message === 'string' ? message : undefined
45
47
  }
46
48
 
49
+ /**
50
+ * agent 是否仍留有已接收但未认领的工作。
51
+ * `hasPending` 未进 Inbox 契约面——它只是 dsh-agent-loop 的 ReactLoopInbox
52
+ * 实现 getter(官方唯一的 `agent.inbox` 赋值点),故按「实现面存在才读」
53
+ * 收窄:实现缺席即视为无待处理工作;存在时读到的正是该 getter,取值与
54
+ * 契约面的 nextTurn/nextStep 非空判定一致。
55
+ */
56
+ function hasPendingWork(inbox: Inbox): boolean {
57
+ if (!('hasPending' in inbox)) return false
58
+ return inbox.hasPending === true
59
+ }
60
+
47
61
  export function installTurnEndWatcher(
48
62
  ctx: Context,
49
63
  service: NotifyEmailService,
@@ -64,7 +78,7 @@ export function installTurnEndWatcher(
64
78
  const fire = (session: Session, turn: number, kind: string, errorMessage?: string): void => {
65
79
  const agent = ctx.agents.get(session.id)
66
80
  if (agent === undefined) return
67
- if (agent.status !== 'idle' || agent.inbox.hasPending) return
81
+ if (agent.status !== 'idle' || hasPendingWork(agent.inbox)) return
68
82
  if (!ctx.agents.roots().includes(agent)) return
69
83
  const watch = watchOf(session.id)
70
84
  const key = `${turn}:${kind}`