@hopgoldy/agent-bridge 0.3.1 → 0.4.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/dist/index.d.ts CHANGED
@@ -11,6 +11,16 @@ type ClientOutputEvent = {
11
11
  } | {
12
12
  type: "command.session.stop";
13
13
  clientSessionId: string;
14
+ } | {
15
+ type: "command.session.status";
16
+ clientSessionId: string;
17
+ } | {
18
+ type: "command.session.model.list";
19
+ clientSessionId: string;
20
+ } | {
21
+ type: "command.session.model.set";
22
+ clientSessionId: string;
23
+ target: string;
14
24
  };
15
25
  type AgentInputEvent = {
16
26
  type: "user.message";
@@ -24,6 +34,22 @@ interface OutboundAttachment {
24
34
  fileName?: string;
25
35
  caption?: string;
26
36
  }
37
+ interface AgentSessionStatus {
38
+ sessionId: string;
39
+ provider?: string;
40
+ modelId?: string;
41
+ thinkingLevel?: string;
42
+ context?: {
43
+ tokens: number | null;
44
+ contextWindow: number | null;
45
+ percent: number | null;
46
+ };
47
+ }
48
+ interface AgentAvailableModel {
49
+ provider: string;
50
+ modelId: string;
51
+ isCurrent: boolean;
52
+ }
27
53
  type ToolProgressPayload = {
28
54
  toolName: string;
29
55
  toolCallId?: string;
@@ -38,6 +64,20 @@ type AgentOutputPayload = {
38
64
  } | {
39
65
  type: "assistant.thinking";
40
66
  text?: string;
67
+ } | {
68
+ type: "agent.status.info";
69
+ status: AgentSessionStatus;
70
+ } | {
71
+ type: "agent.model.list";
72
+ models: AgentAvailableModel[];
73
+ } | {
74
+ type: "agent.model.updated";
75
+ provider: string;
76
+ modelId: string;
77
+ } | {
78
+ type: "error";
79
+ kind: string;
80
+ detail?: string;
41
81
  } | ({
42
82
  type: "assistant.tool.running";
43
83
  } & ToolProgressPayload) | ({
@@ -70,6 +110,12 @@ interface AgentAdapter {
70
110
  start(onOutput: (event: AgentOutputEvent) => Promise<void> | void): Promise<void>;
71
111
  stop(): Promise<void>;
72
112
  abort?(): Promise<void>;
113
+ getStatus?(): Promise<AgentSessionStatus>;
114
+ getAvailableModels?(): Promise<AgentAvailableModel[]>;
115
+ setModel?(target: string): Promise<{
116
+ provider: string;
117
+ modelId: string;
118
+ }>;
73
119
  input(event: AgentInputEvent): Promise<void>;
74
120
  isBusy(): Promise<boolean>;
75
121
  }
@@ -94,22 +140,34 @@ interface ConfigAdapter<TConfig = unknown> {
94
140
  validate(config: TConfig): Promise<void> | void;
95
141
  summarize?(config: TConfig): string;
96
142
  }
143
+ type LocaleCode = "zh-CN" | "en-US";
144
+ interface ChannelCommonConfig {
145
+ language: LocaleCode;
146
+ }
147
+ interface ChannelCommonContext extends ChannelCommonConfig {
148
+ channelName: string;
149
+ }
97
150
  interface ClientModule<TConfig = unknown> {
98
151
  readonly type: string;
99
152
  createConfigCollector?: () => ConfigAdapter<TConfig>;
100
- createClientAdapter(config: TConfig): IMAdapter;
153
+ createClientAdapter(args: {
154
+ config: TConfig;
155
+ common: ChannelCommonContext;
156
+ }): IMAdapter;
101
157
  }
102
158
  interface AgentModule<TConfig = unknown> {
103
159
  readonly type: string;
104
160
  createConfigCollector?: () => ConfigAdapter<TConfig>;
105
161
  createAgentSession(args: {
106
162
  config: TConfig;
163
+ common: ChannelCommonContext;
107
164
  }): Promise<{
108
165
  agentSessionId: string;
109
166
  agentAdapter: AgentAdapter;
110
167
  }>;
111
168
  resumeAgentSession?(args: {
112
169
  config: TConfig;
170
+ common: ChannelCommonContext;
113
171
  agentSessionId: string;
114
172
  }): Promise<AgentAdapter>;
115
173
  }
@@ -154,6 +212,7 @@ type AgentConfig = {
154
212
  config: PiCodingAgentConfig;
155
213
  };
156
214
  interface ChannelConfig {
215
+ common: ChannelCommonConfig;
157
216
  client: ClientConfig;
158
217
  agent: AgentConfig;
159
218
  }
@@ -173,6 +232,7 @@ interface GatewayCoreOptions {
173
232
  agentConfig: AgentConfig["config"];
174
233
  agentIdleTimeoutMs: number;
175
234
  bindingStore?: SessionBindingStore;
235
+ common?: ChannelCommonContext;
176
236
  }
177
237
  interface SessionBindingStore {
178
238
  load(): Promise<Record<string, string>>;
@@ -208,4 +268,4 @@ interface WeixinInboundMessage {
208
268
  raw?: unknown;
209
269
  }
210
270
 
211
- export type { AgentAdapter, AgentConfig, AgentInputEvent, AgentModule, AgentOutputEvent, AppConfig, AppDefaults, ChannelConfig, ChannelRunner, ClientConfig, ClientInputEvent, ClientModule, ClientOutputEvent, ConfigAdapter, ConfigCollectContext, ConfigInputOptions, ConfigSelectOption, FeishuClientConfig, FeishuInboundMessage, GatewayCoreOptions, IMAdapter, LegacyAgentInputEvent, OutboundAttachment, PiCodingAgentConfig, RunChannelOptions, SessionBindingStore, WecomClientConfig, WecomInboundMessage, WeixinClientConfig, WeixinInboundMessage };
271
+ export type { AgentAdapter, AgentAvailableModel, AgentConfig, AgentInputEvent, AgentModule, AgentOutputEvent, AgentSessionStatus, AppConfig, AppDefaults, ChannelCommonConfig, ChannelCommonContext, ChannelConfig, ChannelRunner, ClientConfig, ClientInputEvent, ClientModule, ClientOutputEvent, ConfigAdapter, ConfigCollectContext, ConfigInputOptions, ConfigSelectOption, FeishuClientConfig, FeishuInboundMessage, GatewayCoreOptions, IMAdapter, LegacyAgentInputEvent, LocaleCode, OutboundAttachment, PiCodingAgentConfig, RunChannelOptions, SessionBindingStore, WecomClientConfig, WecomInboundMessage, WeixinClientConfig, WeixinInboundMessage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hopgoldy/agent-bridge",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "private": false,
5
5
  "description": "IM to Agent bridge with dual-adapter architecture",
6
6
  "packageManager": "pnpm@10.33.0",
@@ -44,6 +44,7 @@
44
44
  "@openilink/openilink-sdk-node": "^0.6.0",
45
45
  "@wecom/aibot-node-sdk": "^1.0.7",
46
46
  "commander": "^12.1.0",
47
+ "i18next": "^26.3.6",
47
48
  "qrcode-terminal": "^0.12.0"
48
49
  },
49
50
  "devDependencies": {