openteam 0.7.1 → 0.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openteam",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "Agent-centric team collaboration for OpenCode",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -17,6 +17,15 @@ function createTraceID() {
17
17
  return `msg-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
18
18
  }
19
19
 
20
+ /**
21
+ * 记录工具错误并返回错误字符串
22
+ * 基础设施错误(agent 识别失败、serve 不可用等)用 error 级别,始终写入日志文件
23
+ */
24
+ function toolError(toolName, message, data = {}) {
25
+ log.error(`${toolName}: ${message}`, data);
26
+ return `Error: ${message}`;
27
+ }
28
+
20
29
  export function createToolDefs() {
21
30
  return {
22
31
  msg: {
@@ -39,15 +48,15 @@ export function createToolDefs() {
39
48
  });
40
49
 
41
50
  const currentAgent = await getCurrentAgent(ctx.sessionID, 2000, { trace, reason: 'msg.execute' });
42
- if (!currentAgent) return 'Error: unable to identify current agent';
51
+ if (!currentAgent) return toolError('msg', 'unable to identify current agent', { trace, sessionID: ctx.sessionID });
43
52
 
44
53
  const teamConfig = loadTeamConfig(currentAgent.team);
45
- if (!teamConfig) return 'Error: team config not found';
54
+ if (!teamConfig) return toolError('msg', 'team config not found', { trace, team: currentAgent.team });
46
55
 
47
56
  const projectDir = currentAgent.projectDir;
48
- if (!projectDir) return 'Error: unable to determine project directory';
57
+ if (!projectDir) return toolError('msg', 'unable to determine project directory', { trace, agent: currentAgent.full });
49
58
  const serveUrl = getServeUrl(currentAgent.team, projectDir, { trace, reason: 'msg.execute' });
50
- if (!serveUrl) return 'Error: team serve is not running';
59
+ if (!serveUrl) return toolError('msg', 'team serve is not running', { trace, agent: currentAgent.full, team: currentAgent.team, projectDir });
51
60
 
52
61
  const isLeader = currentAgent.name === teamConfig.leader;
53
62
  const isBroadcast = !args.who || args.who === 'all';
@@ -95,20 +104,21 @@ export function createToolDefs() {
95
104
  alias: tool.schema.string().optional().describe('Instance alias'),
96
105
  },
97
106
  execute: async (args, ctx) => {
107
+ const trace = createTraceID();
98
108
  const currentAgent = await getCurrentAgent(ctx.sessionID);
99
- if (!currentAgent) return 'Error: unable to identify current agent';
109
+ if (!currentAgent) return toolError('command', 'unable to identify current agent', { trace, sessionID: ctx.sessionID });
100
110
 
101
111
  const teamConfig = loadTeamConfig(currentAgent.team);
102
- if (!teamConfig) return 'Error: team config not found';
112
+ if (!teamConfig) return toolError('command', 'team config not found', { trace, team: currentAgent.team });
103
113
 
104
114
  if (currentAgent.name !== teamConfig.leader) {
105
115
  return `Error: only ${teamConfig.leader} can use command`;
106
116
  }
107
117
 
108
118
  const projectDir = currentAgent.projectDir;
109
- if (!projectDir) return 'Error: unable to determine project directory';
110
- const serveUrl = getServeUrl(currentAgent.team, projectDir);
111
- if (!serveUrl) return 'Error: team serve is not running';
119
+ if (!projectDir) return toolError('command', 'unable to determine project directory', { trace, agent: currentAgent.full });
120
+ const serveUrl = getServeUrl(currentAgent.team, projectDir, { trace, reason: 'command.execute' });
121
+ if (!serveUrl) return toolError('command', 'team serve is not running', { trace, agent: currentAgent.full, team: currentAgent.team, projectDir });
112
122
 
113
123
  let who = args.who;
114
124
  let alias = args.alias;
@@ -159,15 +169,15 @@ export function createToolDefs() {
159
169
  execute: async (args, ctx) => {
160
170
  const trace = createTraceID();
161
171
  const currentAgent = await getCurrentAgent(ctx.sessionID, 2000, { trace, reason: 'task.execute' });
162
- if (!currentAgent) return 'Error: unable to identify current agent';
172
+ if (!currentAgent) return toolError('taskboard', 'unable to identify current agent', { trace, sessionID: ctx.sessionID });
163
173
 
164
174
  const teamConfig = loadTeamConfig(currentAgent.team);
165
- if (!teamConfig) return 'Error: team config not found';
175
+ if (!teamConfig) return toolError('taskboard', 'team config not found', { trace, team: currentAgent.team });
166
176
 
167
177
  const projectDir = currentAgent.projectDir;
168
- if (!projectDir) return 'Error: unable to determine project directory';
178
+ if (!projectDir) return toolError('taskboard', 'unable to determine project directory', { trace, agent: currentAgent.full });
169
179
  const serveUrl = getServeUrl(currentAgent.team, projectDir, { trace, reason: 'task.execute' });
170
- if (!serveUrl) return 'Error: team serve is not running';
180
+ if (!serveUrl) return toolError('taskboard', 'team serve is not running', { trace, agent: currentAgent.full, team: currentAgent.team, projectDir });
171
181
 
172
182
  // CREATE
173
183
  if (args.action === 'create') {