acp-ts 1.2.1 → 1.2.3

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/agentcp.js CHANGED
@@ -452,6 +452,9 @@ class AgentCP {
452
452
  onGroupEvent(groupId, evt) {
453
453
  console.log(`[Group][DefaultHandler] onGroupEvent: group=${groupId} event=${evt.event_type}`);
454
454
  },
455
+ onDutyDispatch(groupId, context) {
456
+ console.log(`[Group][DefaultHandler] onDutyDispatch: group=${groupId} original_msg_id=${context.original_msg_id} sender=${context.sender_id}`);
457
+ },
455
458
  };
456
459
  }
457
460
  /**
@@ -2,7 +2,7 @@
2
2
  * Group event handler interfaces and dispatch logic.
3
3
  * Mirrors Python SDK: agentcp/group/events.py
4
4
  */
5
- import { GroupNotify, GroupEvent, GroupMessageBatch } from './types';
5
+ import { GroupNotify, GroupEvent, GroupMessageBatch, DutyContext } from './types';
6
6
  /**
7
7
  * Abstract handler for ACP group notifications.
8
8
  */
@@ -15,6 +15,7 @@ export interface ACPGroupEventHandler {
15
15
  onJoinRequestReceived(groupId: string, agentId: string, message: string): void;
16
16
  onGroupMessageBatch(groupId: string, batch: GroupMessageBatch): void;
17
17
  onGroupEvent(groupId: string, evt: GroupEvent): void;
18
+ onDutyDispatch(groupId: string, context: DutyContext): void;
18
19
  }
19
20
  /**
20
21
  * Abstract handler for structured group events (from MSG/Session).
@@ -12,7 +12,7 @@ const types_1 = require("./types");
12
12
  * Returns true if dispatched, false if unrecognized or handler/notify is null.
13
13
  */
14
14
  function dispatchAcpNotify(handler, notify) {
15
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
15
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
16
16
  if (handler == null || notify == null) {
17
17
  return false;
18
18
  }
@@ -41,6 +41,30 @@ function dispatchAcpNotify(handler, notify) {
41
41
  else if (event === types_1.NOTIFY_GROUP_EVENT) {
42
42
  handler.onGroupEvent(gid, data);
43
43
  }
44
+ else if (event === types_1.NOTIFY_DUTY_DISPATCH) {
45
+ const context = {
46
+ needs_dispatch: (_o = data.needs_dispatch) !== null && _o !== void 0 ? _o : false,
47
+ original_msg_id: (_p = data.original_msg_id) !== null && _p !== void 0 ? _p : 0,
48
+ sender_id: (_q = data.sender_id) !== null && _q !== void 0 ? _q : "",
49
+ sender_type: (_r = data.sender_type) !== null && _r !== void 0 ? _r : "",
50
+ group_member_count: (_s = data.group_member_count) !== null && _s !== void 0 ? _s : 0,
51
+ online_ai_members: ((_t = data.online_ai_members) !== null && _t !== void 0 ? _t : []).map((m) => {
52
+ var _a, _b;
53
+ return ({
54
+ agent_id: (_a = m.agent_id) !== null && _a !== void 0 ? _a : "",
55
+ agent_type: (_b = m.agent_type) !== null && _b !== void 0 ? _b : "",
56
+ });
57
+ }),
58
+ human_members: ((_u = data.human_members) !== null && _u !== void 0 ? _u : []).map((m) => {
59
+ var _a, _b;
60
+ return ({
61
+ agent_id: (_a = m.agent_id) !== null && _a !== void 0 ? _a : "",
62
+ agent_type: (_b = m.agent_type) !== null && _b !== void 0 ? _b : "",
63
+ });
64
+ }),
65
+ };
66
+ handler.onDutyDispatch(gid, context);
67
+ }
44
68
  else {
45
69
  return false;
46
70
  }
@@ -2,7 +2,7 @@
2
2
  * ACP Group Operations package.
3
3
  * Mirrors Python SDK: agentcp/group/__init__.py
4
4
  */
5
- export { GroupErrorCode, GroupError, GroupRequest, GroupResponse, GroupNotify, buildGroupRequest, groupRequestToJson, parseGroupResponse, parseGroupNotify, GroupMessage, GroupEvent, MsgCursor, EventCursor, CursorState, createMsgCursor, createEventCursor, CreateGroupResp, SendMessageResp, PullMessagesResp, PullEventsResp, GroupInfoResp, BanlistResp, BatchReviewResp, PendingRequestsResp, MembersResp, AdminsResp, RulesResp, AnnouncementResp, JoinRequirementsResp, MasterResp, InviteCodeResp, InviteCodeListResp, BroadcastLockResp, BroadcastPermissionResp, SyncStatusResp, SyncLogResp, ChecksumResp, PublicGroupInfoResp, SearchGroupsResp, DigestResp, MembershipInfo, ListMyGroupsResp, GetFileResp, GetSummaryResp, GetMetricsResp, NOTIFY_NEW_MESSAGE, NOTIFY_NEW_EVENT, NOTIFY_GROUP_INVITE, NOTIFY_JOIN_APPROVED, NOTIFY_JOIN_REJECTED, NOTIFY_JOIN_REQUEST_RECEIVED, NOTIFY_GROUP_EVENT, EVENT_MEMBER_JOINED, EVENT_MEMBER_REMOVED, EVENT_MEMBER_LEFT, EVENT_MEMBER_BANNED, EVENT_META_UPDATED, EVENT_RULES_UPDATED, EVENT_ANNOUNCEMENT_UPDATED, EVENT_GROUP_DISSOLVED, EVENT_MASTER_TRANSFERRED, EVENT_GROUP_SUSPENDED, EVENT_GROUP_RESUMED, EVENT_MEMBER_UNBANNED, EVENT_JOIN_REQUIREMENTS_UPDATED, EVENT_INVITE_CODE_CREATED, EVENT_INVITE_CODE_REVOKED, ACTION_MESSAGE_BATCH_PUSH, GroupMessageBatch, } from './types';
5
+ export { GroupErrorCode, GroupError, GroupRequest, GroupResponse, GroupNotify, buildGroupRequest, groupRequestToJson, parseGroupResponse, parseGroupNotify, GroupMessage, GroupEvent, MsgCursor, EventCursor, CursorState, createMsgCursor, createEventCursor, CreateGroupResp, SendMessageResp, PullMessagesResp, PullEventsResp, GroupInfoResp, BanlistResp, BatchReviewResp, PendingRequestsResp, RequestJoinResp, MembersResp, AdminsResp, RulesResp, AnnouncementResp, JoinRequirementsResp, MasterResp, InviteCodeResp, InviteCodeListResp, BroadcastLockResp, BroadcastPermissionResp, SyncStatusResp, SyncLogResp, ChecksumResp, PublicGroupInfoResp, SearchGroupsResp, DigestResp, MembershipInfo, ListMyGroupsResp, GetFileResp, GetSummaryResp, GetMetricsResp, NOTIFY_NEW_MESSAGE, NOTIFY_NEW_EVENT, NOTIFY_GROUP_INVITE, NOTIFY_JOIN_APPROVED, NOTIFY_JOIN_REJECTED, NOTIFY_JOIN_REQUEST_RECEIVED, NOTIFY_GROUP_EVENT, NOTIFY_DUTY_DISPATCH, EVENT_MEMBER_JOINED, EVENT_MEMBER_REMOVED, EVENT_MEMBER_LEFT, EVENT_MEMBER_BANNED, EVENT_META_UPDATED, EVENT_RULES_UPDATED, EVENT_ANNOUNCEMENT_UPDATED, EVENT_GROUP_DISSOLVED, EVENT_MASTER_TRANSFERRED, EVENT_GROUP_SUSPENDED, EVENT_GROUP_RESUMED, EVENT_MEMBER_UNBANNED, EVENT_JOIN_REQUIREMENTS_UPDATED, EVENT_INVITE_CODE_CREATED, EVENT_INVITE_CODE_REVOKED, ACTION_MESSAGE_BATCH_PUSH, GroupMessageBatch, DutyMemberInfo, DutyContext, DispatchDecisionParams, DispatchMetadata, DutyConfig, DutyState, DutyStatusResp, } from './types';
6
6
  export { ACPGroupClient, SendFunc } from './client';
7
7
  export { GroupOperations, SyncHandler } from './operations';
8
8
  export { ACPGroupEventHandler, EventProcessor, dispatchAcpNotify, dispatchEvent, } from './events';
@@ -4,7 +4,7 @@
4
4
  * Mirrors Python SDK: agentcp/group/__init__.py
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.GroupMessageStore = exports.LocalCursorStore = exports.dispatchAcpNotify = exports.GroupOperations = exports.ACPGroupClient = exports.ACTION_MESSAGE_BATCH_PUSH = exports.EVENT_INVITE_CODE_REVOKED = exports.EVENT_INVITE_CODE_CREATED = exports.EVENT_JOIN_REQUIREMENTS_UPDATED = exports.EVENT_MEMBER_UNBANNED = exports.EVENT_GROUP_RESUMED = exports.EVENT_GROUP_SUSPENDED = exports.EVENT_MASTER_TRANSFERRED = exports.EVENT_GROUP_DISSOLVED = exports.EVENT_ANNOUNCEMENT_UPDATED = exports.EVENT_RULES_UPDATED = exports.EVENT_META_UPDATED = exports.EVENT_MEMBER_BANNED = exports.EVENT_MEMBER_LEFT = exports.EVENT_MEMBER_REMOVED = exports.EVENT_MEMBER_JOINED = exports.NOTIFY_GROUP_EVENT = exports.NOTIFY_JOIN_REQUEST_RECEIVED = exports.NOTIFY_JOIN_REJECTED = exports.NOTIFY_JOIN_APPROVED = exports.NOTIFY_GROUP_INVITE = exports.NOTIFY_NEW_EVENT = exports.NOTIFY_NEW_MESSAGE = exports.createEventCursor = exports.createMsgCursor = exports.parseGroupNotify = exports.parseGroupResponse = exports.groupRequestToJson = exports.buildGroupRequest = exports.GroupError = exports.GroupErrorCode = void 0;
7
+ exports.GroupMessageStore = exports.LocalCursorStore = exports.dispatchAcpNotify = exports.GroupOperations = exports.ACPGroupClient = exports.ACTION_MESSAGE_BATCH_PUSH = exports.EVENT_INVITE_CODE_REVOKED = exports.EVENT_INVITE_CODE_CREATED = exports.EVENT_JOIN_REQUIREMENTS_UPDATED = exports.EVENT_MEMBER_UNBANNED = exports.EVENT_GROUP_RESUMED = exports.EVENT_GROUP_SUSPENDED = exports.EVENT_MASTER_TRANSFERRED = exports.EVENT_GROUP_DISSOLVED = exports.EVENT_ANNOUNCEMENT_UPDATED = exports.EVENT_RULES_UPDATED = exports.EVENT_META_UPDATED = exports.EVENT_MEMBER_BANNED = exports.EVENT_MEMBER_LEFT = exports.EVENT_MEMBER_REMOVED = exports.EVENT_MEMBER_JOINED = exports.NOTIFY_DUTY_DISPATCH = exports.NOTIFY_GROUP_EVENT = exports.NOTIFY_JOIN_REQUEST_RECEIVED = exports.NOTIFY_JOIN_REJECTED = exports.NOTIFY_JOIN_APPROVED = exports.NOTIFY_GROUP_INVITE = exports.NOTIFY_NEW_EVENT = exports.NOTIFY_NEW_MESSAGE = exports.createEventCursor = exports.createMsgCursor = exports.parseGroupNotify = exports.parseGroupResponse = exports.groupRequestToJson = exports.buildGroupRequest = exports.GroupError = exports.GroupErrorCode = void 0;
8
8
  // Types
9
9
  var types_1 = require("./types");
10
10
  Object.defineProperty(exports, "GroupErrorCode", { enumerable: true, get: function () { return types_1.GroupErrorCode; } });
@@ -23,6 +23,7 @@ Object.defineProperty(exports, "NOTIFY_JOIN_APPROVED", { enumerable: true, get:
23
23
  Object.defineProperty(exports, "NOTIFY_JOIN_REJECTED", { enumerable: true, get: function () { return types_1.NOTIFY_JOIN_REJECTED; } });
24
24
  Object.defineProperty(exports, "NOTIFY_JOIN_REQUEST_RECEIVED", { enumerable: true, get: function () { return types_1.NOTIFY_JOIN_REQUEST_RECEIVED; } });
25
25
  Object.defineProperty(exports, "NOTIFY_GROUP_EVENT", { enumerable: true, get: function () { return types_1.NOTIFY_GROUP_EVENT; } });
26
+ Object.defineProperty(exports, "NOTIFY_DUTY_DISPATCH", { enumerable: true, get: function () { return types_1.NOTIFY_DUTY_DISPATCH; } });
26
27
  // Group event type constants
27
28
  Object.defineProperty(exports, "EVENT_MEMBER_JOINED", { enumerable: true, get: function () { return types_1.EVENT_MEMBER_JOINED; } });
28
29
  Object.defineProperty(exports, "EVENT_MEMBER_REMOVED", { enumerable: true, get: function () { return types_1.EVENT_MEMBER_REMOVED; } });
@@ -3,7 +3,7 @@
3
3
  * Mirrors Python SDK: agentcp/group/operations.py
4
4
  */
5
5
  import { ACPGroupClient } from './client';
6
- import { CreateGroupResp, SendMessageResp, PullMessagesResp, PullEventsResp, CursorState, GroupInfoResp, BanlistResp, BatchReviewResp, PendingRequestsResp, MembersResp, AdminsResp, RulesResp, AnnouncementResp, JoinRequirementsResp, MasterResp, InviteCodeResp, InviteCodeListResp, BroadcastLockResp, BroadcastPermissionResp, SyncStatusResp, SyncLogResp, ChecksumResp, PublicGroupInfoResp, SearchGroupsResp, DigestResp, ListMyGroupsResp, GetFileResp, GetSummaryResp, GetMetricsResp } from './types';
6
+ import { CreateGroupResp, SendMessageResp, PullMessagesResp, PullEventsResp, CursorState, GroupInfoResp, BanlistResp, BatchReviewResp, PendingRequestsResp, RequestJoinResp, MembersResp, AdminsResp, RulesResp, AnnouncementResp, JoinRequirementsResp, MasterResp, InviteCodeResp, InviteCodeListResp, BroadcastLockResp, BroadcastPermissionResp, SyncStatusResp, SyncLogResp, ChecksumResp, PublicGroupInfoResp, SearchGroupsResp, DigestResp, ListMyGroupsResp, GetFileResp, GetSummaryResp, GetMetricsResp, DutyConfig, DutyStatusResp, DispatchDecisionParams } from './types';
7
7
  /**
8
8
  * Callback interface for syncGroup.
9
9
  */
@@ -30,18 +30,20 @@ export declare class GroupOperations {
30
30
  /**
31
31
  * 通过群聊链接加入群组。
32
32
  * - 提供 inviteCode 时:免审核,直接通过邀请码加入
33
- * - 不提供 inviteCode 时:提交加入申请,等待管理员审核
33
+ * - 不提供 inviteCode 时:
34
+ * - 公开群:直接加入,返回 status="joined"
35
+ * - 私密群:提交加入申请,返回 status="pending"
34
36
  *
35
37
  * @param groupUrl 群聊链接,如 "https://group.agentcp.io/<group_id>"
36
38
  * @param options 可选参数
37
39
  * @param options.inviteCode 邀请码(免审核加入)
38
- * @param options.message 申请消息(审核模式下使用)
39
- * @returns 审核模式返回 request_id,免审核模式返回空字符串
40
+ * @param options.message 申请消息(私密群审核模式下使用)
41
+ * @returns RequestJoinResp,包含 status 和 request_id
40
42
  */
41
43
  joinByUrl(groupUrl: string, options?: {
42
44
  inviteCode?: string;
43
45
  message?: string;
44
- }): Promise<string>;
46
+ }): Promise<RequestJoinResp>;
45
47
  /**
46
48
  * 注册上线,告知 group.ap 当前客户端在线,可以接收消息推送。
47
49
  * 客户端每次启动或重新连接时调用一次即可。
@@ -85,7 +87,7 @@ export declare class GroupOperations {
85
87
  banAgent(targetAid: string, groupId: string, agentId: string, reason?: string, expiresAt?: number): Promise<void>;
86
88
  unbanAgent(targetAid: string, groupId: string, agentId: string): Promise<void>;
87
89
  getBanlist(targetAid: string, groupId: string): Promise<BanlistResp>;
88
- requestJoin(targetAid: string, groupId: string, message?: string): Promise<string>;
90
+ requestJoin(targetAid: string, groupId: string, message?: string): Promise<RequestJoinResp>;
89
91
  reviewJoinRequest(targetAid: string, groupId: string, agentId: string, action: string, reason?: string): Promise<void>;
90
92
  batchReviewJoinRequests(targetAid: string, groupId: string, agentIds: string[], action: string, reason?: string): Promise<BatchReviewResp>;
91
93
  getPendingRequests(targetAid: string, groupId: string): Promise<PendingRequestsResp>;
@@ -132,4 +134,24 @@ export declare class GroupOperations {
132
134
  getFile(targetAid: string, groupId: string, file: string, offset?: number): Promise<GetFileResp>;
133
135
  getSummary(targetAid: string, groupId: string, date: string): Promise<GetSummaryResp>;
134
136
  getMetrics(targetAid: string): Promise<GetMetricsResp>;
137
+ /**
138
+ * 更新值班配置。权限要求:creator 或 admin。
139
+ */
140
+ updateDutyConfig(targetAid: string, groupId: string, config: Partial<DutyConfig>): Promise<void>;
141
+ /**
142
+ * 快捷设置固定值班 Agent 列表(自动切换为 fixed 模式)。
143
+ */
144
+ setFixedAgents(targetAid: string, groupId: string, agents: string[]): Promise<void>;
145
+ /**
146
+ * 获取值班状态,包含 config 和 state。
147
+ */
148
+ getDutyStatus(targetAid: string, groupId: string): Promise<DutyStatusResp>;
149
+ /**
150
+ * 值班 Agent 提交仲裁决策。
151
+ */
152
+ dispatchDecision(targetAid: string, groupId: string, params: DispatchDecisionParams): Promise<void>;
153
+ /**
154
+ * 重新获取所有成员的 agent.md 并更新 AgentType。
155
+ */
156
+ refreshMemberTypes(targetAid: string, groupId: string): Promise<void>;
135
157
  }
@@ -41,20 +41,22 @@ class GroupOperations {
41
41
  /**
42
42
  * 通过群聊链接加入群组。
43
43
  * - 提供 inviteCode 时:免审核,直接通过邀请码加入
44
- * - 不提供 inviteCode 时:提交加入申请,等待管理员审核
44
+ * - 不提供 inviteCode 时:
45
+ * - 公开群:直接加入,返回 status="joined"
46
+ * - 私密群:提交加入申请,返回 status="pending"
45
47
  *
46
48
  * @param groupUrl 群聊链接,如 "https://group.agentcp.io/<group_id>"
47
49
  * @param options 可选参数
48
50
  * @param options.inviteCode 邀请码(免审核加入)
49
- * @param options.message 申请消息(审核模式下使用)
50
- * @returns 审核模式返回 request_id,免审核模式返回空字符串
51
+ * @param options.message 申请消息(私密群审核模式下使用)
52
+ * @returns RequestJoinResp,包含 status 和 request_id
51
53
  */
52
54
  async joinByUrl(groupUrl, options) {
53
55
  var _a;
54
56
  const { targetAid, groupId } = GroupOperations.parseGroupUrl(groupUrl);
55
57
  if (options === null || options === void 0 ? void 0 : options.inviteCode) {
56
58
  await this.useInviteCode(targetAid, groupId, options.inviteCode);
57
- return '';
59
+ return { status: 'joined', request_id: '' };
58
60
  }
59
61
  return this.requestJoin(targetAid, groupId, (_a = options === null || options === void 0 ? void 0 : options.message) !== null && _a !== void 0 ? _a : '');
60
62
  }
@@ -268,14 +270,14 @@ class GroupOperations {
268
270
  return { banned: (_a = d.banned) !== null && _a !== void 0 ? _a : [] };
269
271
  }
270
272
  async requestJoin(targetAid, groupId, message = "") {
271
- var _a;
273
+ var _a, _b;
272
274
  const params = {};
273
275
  if (message)
274
276
  params.message = message;
275
277
  const resp = await this._client.sendRequest(targetAid, groupId, "request_join", Object.keys(params).length > 0 ? params : null);
276
278
  this._check(resp, "request_join");
277
279
  const d = resp.data || {};
278
- return (_a = d.request_id) !== null && _a !== void 0 ? _a : "";
280
+ return { status: (_a = d.status) !== null && _a !== void 0 ? _a : "pending", request_id: (_b = d.request_id) !== null && _b !== void 0 ? _b : "" };
279
281
  }
280
282
  async reviewJoinRequest(targetAid, groupId, agentId, action, reason = "") {
281
283
  const params = { agent_id: agentId, action };
@@ -616,5 +618,59 @@ class GroupOperations {
616
618
  sys_mb: (_c = d.sys_mb) !== null && _c !== void 0 ? _c : 0, gc_cycles: (_d = d.gc_cycles) !== null && _d !== void 0 ? _d : 0,
617
619
  };
618
620
  }
621
+ // ============================================================
622
+ // Duty (值班) Operations
623
+ // ============================================================
624
+ /**
625
+ * 更新值班配置。权限要求:creator 或 admin。
626
+ */
627
+ async updateDutyConfig(targetAid, groupId, config) {
628
+ const params = {};
629
+ if (config.mode != null)
630
+ params.mode = config.mode;
631
+ if (config.rotation_strategy != null)
632
+ params.rotation_strategy = config.rotation_strategy;
633
+ if (config.shift_duration_ms != null)
634
+ params.shift_duration_ms = config.shift_duration_ms;
635
+ if (config.max_messages_per_shift != null)
636
+ params.max_messages_per_shift = config.max_messages_per_shift;
637
+ if (config.dispatch_timeout_ms != null)
638
+ params.dispatch_timeout_ms = config.dispatch_timeout_ms;
639
+ if (config.timeout_fallback != null)
640
+ params.timeout_fallback = config.timeout_fallback;
641
+ const resp = await this._client.sendRequest(targetAid, groupId, "update_duty_config", params);
642
+ this._check(resp, "update_duty_config");
643
+ }
644
+ /**
645
+ * 快捷设置固定值班 Agent 列表(自动切换为 fixed 模式)。
646
+ */
647
+ async setFixedAgents(targetAid, groupId, agents) {
648
+ const resp = await this._client.sendRequest(targetAid, groupId, "set_fixed_agents", { agents });
649
+ this._check(resp, "set_fixed_agents");
650
+ }
651
+ /**
652
+ * 获取值班状态,包含 config 和 state。
653
+ */
654
+ async getDutyStatus(targetAid, groupId) {
655
+ var _a, _b;
656
+ const resp = await this._client.sendRequest(targetAid, groupId, "get_duty_status", null);
657
+ this._check(resp, "get_duty_status");
658
+ const d = resp.data || {};
659
+ return { config: (_a = d.config) !== null && _a !== void 0 ? _a : {}, state: (_b = d.state) !== null && _b !== void 0 ? _b : {} };
660
+ }
661
+ /**
662
+ * 值班 Agent 提交仲裁决策。
663
+ */
664
+ async dispatchDecision(targetAid, groupId, params) {
665
+ const resp = await this._client.sendRequest(targetAid, groupId, "dispatch_decision", params);
666
+ this._check(resp, "dispatch_decision");
667
+ }
668
+ /**
669
+ * 重新获取所有成员的 agent.md 并更新 AgentType。
670
+ */
671
+ async refreshMemberTypes(targetAid, groupId) {
672
+ const resp = await this._client.sendRequest(targetAid, groupId, "refresh_member_types", null);
673
+ this._check(resp, "refresh_member_types");
674
+ }
619
675
  }
620
676
  exports.GroupOperations = GroupOperations;
@@ -17,7 +17,13 @@ export declare enum GroupErrorCode {
17
17
  INVITE_CODE_INVALID = 1011,
18
18
  REQUEST_EXISTS = 1012,
19
19
  BROADCAST_CONFLICT = 1013,
20
- ACTION_NOT_IMPL = 1099
20
+ ACTION_NOT_IMPL = 1099,
21
+ DUTY_NOT_ENABLED = 1020,
22
+ NOT_DUTY_AGENT = 1021,
23
+ DISPATCH_NOT_FOUND = 1022,
24
+ INVALID_DECISION = 1023,
25
+ AGENT_MD_NOT_FOUND = 1024,
26
+ AGENT_MD_INVALID = 1025
21
27
  }
22
28
  export declare class GroupError extends Error {
23
29
  action: string;
@@ -120,6 +126,11 @@ export interface GroupInfoResp {
120
126
  export interface BanlistResp {
121
127
  banned: Record<string, any>[];
122
128
  }
129
+ export interface RequestJoinResp {
130
+ /** "joined" = 已直接加入(公开群), "pending" = 等待审核(私密群) */
131
+ status: string;
132
+ request_id: string;
133
+ }
123
134
  export interface BatchReviewResp {
124
135
  processed: number;
125
136
  total: number;
@@ -248,6 +259,7 @@ export declare const NOTIFY_JOIN_APPROVED = "join_approved";
248
259
  export declare const NOTIFY_JOIN_REJECTED = "join_rejected";
249
260
  export declare const NOTIFY_JOIN_REQUEST_RECEIVED = "join_request_received";
250
261
  export declare const NOTIFY_GROUP_EVENT = "group_event";
262
+ export declare const NOTIFY_DUTY_DISPATCH = "duty_dispatch";
251
263
  export declare const EVENT_MEMBER_JOINED = "member_joined";
252
264
  export declare const EVENT_MEMBER_REMOVED = "member_removed";
253
265
  export declare const EVENT_MEMBER_LEFT = "member_left";
@@ -263,6 +275,49 @@ export declare const EVENT_MEMBER_UNBANNED = "member_unbanned";
263
275
  export declare const EVENT_JOIN_REQUIREMENTS_UPDATED = "join_requirements_updated";
264
276
  export declare const EVENT_INVITE_CODE_CREATED = "invite_code_created";
265
277
  export declare const EVENT_INVITE_CODE_REVOKED = "invite_code_revoked";
278
+ export interface DutyMemberInfo {
279
+ agent_id: string;
280
+ agent_type: string;
281
+ }
282
+ export interface DutyContext {
283
+ needs_dispatch: boolean;
284
+ original_msg_id: number;
285
+ sender_id: string;
286
+ sender_type: string;
287
+ group_member_count: number;
288
+ online_ai_members: DutyMemberInfo[];
289
+ human_members: DutyMemberInfo[];
290
+ }
291
+ export interface DispatchDecisionParams {
292
+ original_msg_id: number;
293
+ type: "broadcast" | "selective" | "suppress";
294
+ hint?: string;
295
+ reply_mode?: string;
296
+ }
297
+ export interface DispatchMetadata {
298
+ type: string;
299
+ hint: string;
300
+ reply_mode: string;
301
+ }
302
+ export interface DutyConfig {
303
+ mode: "none" | "fixed" | "rotation";
304
+ rotation_strategy?: "round_robin" | "random";
305
+ shift_duration_ms?: number;
306
+ max_messages_per_shift?: number;
307
+ dispatch_timeout_ms?: number;
308
+ timeout_fallback?: "broadcast" | "next_duty";
309
+ agents?: string[];
310
+ }
311
+ export interface DutyState {
312
+ current_duty_agent?: string;
313
+ shift_start_time?: number;
314
+ messages_in_shift?: number;
315
+ [key: string]: any;
316
+ }
317
+ export interface DutyStatusResp {
318
+ config: DutyConfig;
319
+ state: DutyState;
320
+ }
266
321
  export declare const ACTION_MESSAGE_BATCH_PUSH = "message_batch_push";
267
322
  export interface GroupMessageBatch {
268
323
  messages: GroupMessage[];
@@ -4,7 +4,7 @@
4
4
  * Mirrors Python SDK: agentcp/group/types.py
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.ACTION_MESSAGE_BATCH_PUSH = exports.EVENT_INVITE_CODE_REVOKED = exports.EVENT_INVITE_CODE_CREATED = exports.EVENT_JOIN_REQUIREMENTS_UPDATED = exports.EVENT_MEMBER_UNBANNED = exports.EVENT_GROUP_RESUMED = exports.EVENT_GROUP_SUSPENDED = exports.EVENT_MASTER_TRANSFERRED = exports.EVENT_GROUP_DISSOLVED = exports.EVENT_ANNOUNCEMENT_UPDATED = exports.EVENT_RULES_UPDATED = exports.EVENT_META_UPDATED = exports.EVENT_MEMBER_BANNED = exports.EVENT_MEMBER_LEFT = exports.EVENT_MEMBER_REMOVED = exports.EVENT_MEMBER_JOINED = exports.NOTIFY_GROUP_EVENT = exports.NOTIFY_JOIN_REQUEST_RECEIVED = exports.NOTIFY_JOIN_REJECTED = exports.NOTIFY_JOIN_APPROVED = exports.NOTIFY_GROUP_INVITE = exports.NOTIFY_NEW_EVENT = exports.NOTIFY_NEW_MESSAGE = exports.GroupError = exports.GroupErrorCode = void 0;
7
+ exports.ACTION_MESSAGE_BATCH_PUSH = exports.EVENT_INVITE_CODE_REVOKED = exports.EVENT_INVITE_CODE_CREATED = exports.EVENT_JOIN_REQUIREMENTS_UPDATED = exports.EVENT_MEMBER_UNBANNED = exports.EVENT_GROUP_RESUMED = exports.EVENT_GROUP_SUSPENDED = exports.EVENT_MASTER_TRANSFERRED = exports.EVENT_GROUP_DISSOLVED = exports.EVENT_ANNOUNCEMENT_UPDATED = exports.EVENT_RULES_UPDATED = exports.EVENT_META_UPDATED = exports.EVENT_MEMBER_BANNED = exports.EVENT_MEMBER_LEFT = exports.EVENT_MEMBER_REMOVED = exports.EVENT_MEMBER_JOINED = exports.NOTIFY_DUTY_DISPATCH = exports.NOTIFY_GROUP_EVENT = exports.NOTIFY_JOIN_REQUEST_RECEIVED = exports.NOTIFY_JOIN_REJECTED = exports.NOTIFY_JOIN_APPROVED = exports.NOTIFY_GROUP_INVITE = exports.NOTIFY_NEW_EVENT = exports.NOTIFY_NEW_MESSAGE = exports.GroupError = exports.GroupErrorCode = void 0;
8
8
  exports.buildGroupRequest = buildGroupRequest;
9
9
  exports.groupRequestToJson = groupRequestToJson;
10
10
  exports.parseGroupResponse = parseGroupResponse;
@@ -31,6 +31,13 @@ var GroupErrorCode;
31
31
  GroupErrorCode[GroupErrorCode["REQUEST_EXISTS"] = 1012] = "REQUEST_EXISTS";
32
32
  GroupErrorCode[GroupErrorCode["BROADCAST_CONFLICT"] = 1013] = "BROADCAST_CONFLICT";
33
33
  GroupErrorCode[GroupErrorCode["ACTION_NOT_IMPL"] = 1099] = "ACTION_NOT_IMPL";
34
+ // Duty error codes
35
+ GroupErrorCode[GroupErrorCode["DUTY_NOT_ENABLED"] = 1020] = "DUTY_NOT_ENABLED";
36
+ GroupErrorCode[GroupErrorCode["NOT_DUTY_AGENT"] = 1021] = "NOT_DUTY_AGENT";
37
+ GroupErrorCode[GroupErrorCode["DISPATCH_NOT_FOUND"] = 1022] = "DISPATCH_NOT_FOUND";
38
+ GroupErrorCode[GroupErrorCode["INVALID_DECISION"] = 1023] = "INVALID_DECISION";
39
+ GroupErrorCode[GroupErrorCode["AGENT_MD_NOT_FOUND"] = 1024] = "AGENT_MD_NOT_FOUND";
40
+ GroupErrorCode[GroupErrorCode["AGENT_MD_INVALID"] = 1025] = "AGENT_MD_INVALID";
34
41
  })(GroupErrorCode || (exports.GroupErrorCode = GroupErrorCode = {}));
35
42
  const CODE_MESSAGES = {
36
43
  0: "success",
@@ -47,6 +54,12 @@ const CODE_MESSAGES = {
47
54
  1011: "invite code invalid",
48
55
  1012: "request exists",
49
56
  1013: "broadcast conflict",
57
+ 1020: "duty not enabled",
58
+ 1021: "not duty agent",
59
+ 1022: "dispatch not found",
60
+ 1023: "invalid decision",
61
+ 1024: "agent.md not found",
62
+ 1025: "agent.md invalid",
50
63
  1099: "action not implemented",
51
64
  };
52
65
  class GroupError extends Error {
@@ -121,6 +134,7 @@ exports.NOTIFY_JOIN_APPROVED = "join_approved";
121
134
  exports.NOTIFY_JOIN_REJECTED = "join_rejected";
122
135
  exports.NOTIFY_JOIN_REQUEST_RECEIVED = "join_request_received";
123
136
  exports.NOTIFY_GROUP_EVENT = "group_event";
137
+ exports.NOTIFY_DUTY_DISPATCH = "duty_dispatch";
124
138
  // Group Event Type Constants
125
139
  exports.EVENT_MEMBER_JOINED = "member_joined";
126
140
  exports.EVENT_MEMBER_REMOVED = "member_removed";