@townco/agent 0.1.79 → 0.1.81

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.
@@ -163,6 +163,7 @@ export class HookExecutor {
163
163
  currentPercentage: percentage,
164
164
  callback: hook.callback,
165
165
  triggeredAt,
166
+ toolCallId: toolResponse.toolCallId,
166
167
  }, notifications);
167
168
  try {
168
169
  // Load and execute callback
@@ -200,6 +201,7 @@ export class HookExecutor {
200
201
  callback: hook.callback,
201
202
  metadata: result.metadata,
202
203
  completedAt: Date.now(),
204
+ toolCallId: toolResponse.toolCallId,
203
205
  }, notifications);
204
206
  return response;
205
207
  }
@@ -210,6 +212,7 @@ export class HookExecutor {
210
212
  callback: hook.callback,
211
213
  metadata: { action: "no_action_needed" },
212
214
  completedAt: Date.now(),
215
+ toolCallId: toolResponse.toolCallId,
213
216
  }, notifications);
214
217
  return { notifications };
215
218
  }
@@ -221,6 +224,7 @@ export class HookExecutor {
221
224
  callback: hook.callback,
222
225
  error: error instanceof Error ? error.message : String(error),
223
226
  completedAt: Date.now(),
227
+ toolCallId: toolResponse.toolCallId,
224
228
  }, notifications);
225
229
  logger.error("Tool response hook execution failed", {
226
230
  callback: hook.callback,
@@ -56,7 +56,19 @@ export const toolResponseCompactor = async (ctx) => {
56
56
  }
57
57
  // Response would exceed threshold, need to compact or truncate
58
58
  // Determine target size: fit within available space, but cap at compactionLimit for truncation
59
- const targetSize = Math.min(availableSpace, compactionLimit);
59
+ // IMPORTANT: If context is already over threshold, availableSpace will be negative
60
+ // In that case, use a minimum reasonable target size (e.g., 10% of the output or 1000 tokens)
61
+ const minTargetSize = Math.max(Math.floor(outputTokens * 0.1), 1000);
62
+ const targetSize = availableSpace > 0
63
+ ? Math.min(availableSpace, compactionLimit)
64
+ : minTargetSize;
65
+ logger.info("Calculated target size for compaction", {
66
+ availableSpace,
67
+ compactionLimit,
68
+ minTargetSize,
69
+ targetSize,
70
+ contextAlreadyOverThreshold: availableSpace <= 0,
71
+ });
60
72
  // Case 2: Huge response, must truncate (too large for LLM compaction)
61
73
  if (outputTokens >= compactionLimit) {
62
74
  logger.warn("Tool response exceeds compaction capacity, truncating", {
@@ -168,16 +168,19 @@ export type HookNotification = {
168
168
  currentPercentage: number;
169
169
  callback: string;
170
170
  triggeredAt: number;
171
+ toolCallId?: string;
171
172
  } | {
172
173
  type: "hook_completed";
173
174
  hookType: HookType;
174
175
  callback: string;
175
176
  metadata?: HookResult["metadata"];
176
177
  completedAt: number;
178
+ toolCallId?: string;
177
179
  } | {
178
180
  type: "hook_error";
179
181
  hookType: HookType;
180
182
  callback: string;
181
183
  error: string;
182
184
  completedAt: number;
185
+ toolCallId?: string;
183
186
  };
@@ -1059,7 +1059,7 @@ const makeMcpToolsClient = (mcpConfigs) => {
1059
1059
  // Whether to throw on errors if a tool fails to load (optional, default: true)
1060
1060
  throwOnLoadError: true,
1061
1061
  // Whether to prefix tool names with the server name (optional, default: false)
1062
- prefixToolNameWithServerName: false,
1062
+ prefixToolNameWithServerName: true,
1063
1063
  // Optional additional prefix for tool names (optional, default: "")
1064
1064
  additionalToolNamePrefix: "",
1065
1065
  // Use standardized content block format in tool outputs
@@ -5,8 +5,8 @@ export declare function makeFilesystemTools(workingDirectory: string): readonly
5
5
  glob: z.ZodOptional<z.ZodString>;
6
6
  output_mode: z.ZodOptional<z.ZodEnum<{
7
7
  content: "content";
8
- files_with_matches: "files_with_matches";
9
8
  count: "count";
9
+ files_with_matches: "files_with_matches";
10
10
  }>>;
11
11
  "-B": z.ZodOptional<z.ZodNumber>;
12
12
  "-A": z.ZodOptional<z.ZodNumber>;
@@ -20,7 +20,7 @@ export declare function makeFilesystemTools(workingDirectory: string): readonly
20
20
  pattern: string;
21
21
  path?: string | undefined;
22
22
  glob?: string | undefined;
23
- output_mode?: "content" | "files_with_matches" | "count" | undefined;
23
+ output_mode?: "content" | "count" | "files_with_matches" | undefined;
24
24
  "-B"?: number | undefined;
25
25
  "-A"?: number | undefined;
26
26
  "-C"?: number | undefined;
@@ -33,7 +33,7 @@ export declare function makeFilesystemTools(workingDirectory: string): readonly
33
33
  pattern: string;
34
34
  path?: string | undefined;
35
35
  glob?: string | undefined;
36
- output_mode?: "content" | "files_with_matches" | "count" | undefined;
36
+ output_mode?: "content" | "count" | "files_with_matches" | undefined;
37
37
  "-B"?: number | undefined;
38
38
  "-A"?: number | undefined;
39
39
  "-C"?: number | undefined;