agent-sh 0.14.6 → 0.14.7

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.
@@ -98,7 +98,9 @@ export class AgentLoop {
98
98
  this.conversation = new ConversationState(this.handlers, this.instanceId);
99
99
  this.activeMode = config.initialMode ?? { model: config.llmClient.model };
100
100
  // Tool protocol — controls how tools are presented to the LLM
101
- this.toolProtocol = createToolProtocol(getSettings().toolMode ?? "api", getSettings().coreTools ?? []);
101
+ const { names: fromExtensions } = this.bus.emitPipe("agent:core-tools:collect", { names: [] });
102
+ const coreTools = Array.from(new Set([...(getSettings().coreTools ?? []), ...fromExtensions]));
103
+ this.toolProtocol = createToolProtocol(getSettings().toolMode ?? "api", coreTools);
102
104
  // Register core tools
103
105
  this.registerCoreTools();
104
106
  // Register any protocol-provided tools (e.g. load_tool for deferred-lookup).
@@ -9,6 +9,10 @@ export interface AgentIdentity {
9
9
  }
10
10
  declare module "../core/event-bus.js" {
11
11
  interface BusEvents {
12
+ /** Sync pipe: extensions append core tool names; unioned with settings.coreTools. */
13
+ "agent:core-tools:collect": {
14
+ names: string[];
15
+ };
12
16
  "agent:providers": {
13
17
  providers: ProviderRegistration[];
14
18
  };
@@ -343,8 +343,12 @@ export default function agentBackend(ctx) {
343
343
  loadedExtensionNames = names;
344
344
  resolvedProviders = computeResolvedProviders();
345
345
  const settings = getSettings();
346
- const providerName = config.provider ?? settings.defaultProvider
347
- ?? (resolvedProviders.size > 0 ? resolvedProviders.keys().next().value : undefined);
346
+ // Built-ins register unconditionally so `auth list` can enumerate them;
347
+ // the fallback must skip keyless entries or it lands on openrouter and
348
+ // bails at the `!effectiveApiKey` guard below.
349
+ const providerName = config.provider
350
+ ?? settings.defaultProvider
351
+ ?? [...resolvedProviders].find(([, p]) => p.apiKey)?.[0];
348
352
  const activeProvider = providerName ? resolvedProviders.get(providerName) ?? null : null;
349
353
  // Persisted defaultModel wins over openrouter's hardcoded DEFAULT_MODELS[0].
350
354
  const effectiveApiKey = config.apiKey ?? activeProvider?.apiKey;
@@ -153,7 +153,7 @@ export async function loadExtensions(ctx, cliExtensions) {
153
153
  if (settings.extensions.length > 0) {
154
154
  specifiers.push(...settings.extensions);
155
155
  }
156
- const userSpecifiers = await discoverUserExtensions();
156
+ const userSpecifiers = await discoverUserExtensions(ctx);
157
157
  specifiers.push(...userSpecifiers);
158
158
  const seen = new Set();
159
159
  const unique = specifiers.filter((s) => {
@@ -165,19 +165,30 @@ export async function loadExtensions(ctx, cliExtensions) {
165
165
  const loaded = await loadSpecifiers(unique, ctx, false);
166
166
  return loaded;
167
167
  }
168
- async function discoverUserExtensions() {
168
+ async function discoverUserExtensions(ctx) {
169
169
  const specifiers = [];
170
170
  const disabled = new Set(getSettings().disabledExtensions ?? []);
171
+ let entries;
171
172
  try {
172
- const entries = await fs.readdir(EXT_DIR, { withFileTypes: true });
173
- for (const entry of entries) {
174
- // Disable check: directory name for dir-extensions, or basename sans
175
- // extension for file-extensions. Lets settings.json turn one off
176
- // without renaming it.
177
- const nameForDisable = entry.name.replace(/\.[^.]+$/, "");
178
- if (disabled.has(nameForDisable))
179
- continue;
180
- const fullPath = path.join(EXT_DIR, entry.name);
173
+ entries = await fs.readdir(EXT_DIR, { withFileTypes: true });
174
+ }
175
+ catch (err) {
176
+ if (err.code === "ENOENT")
177
+ return specifiers;
178
+ ctx.bus.emit("ui:error", {
179
+ message: `Failed to read extensions directory ${EXT_DIR}: ${err instanceof Error ? err.message : String(err)}`,
180
+ });
181
+ return specifiers;
182
+ }
183
+ for (const entry of entries) {
184
+ // Disable check: directory name for dir-extensions, or basename sans
185
+ // extension for file-extensions. Lets settings.json turn one off
186
+ // without renaming it.
187
+ const nameForDisable = entry.name.replace(/\.[^.]+$/, "");
188
+ if (disabled.has(nameForDisable))
189
+ continue;
190
+ const fullPath = path.join(EXT_DIR, entry.name);
191
+ try {
181
192
  const isDir = entry.isDirectory() ||
182
193
  (entry.isSymbolicLink() && (await fs.stat(fullPath)).isDirectory());
183
194
  if (isDir) {
@@ -189,9 +200,11 @@ async function discoverUserExtensions() {
189
200
  specifiers.push(fullPath);
190
201
  }
191
202
  }
192
- }
193
- catch {
194
- // Directory doesn't exist no user extensions
203
+ catch (err) {
204
+ ctx.bus.emit("ui:error", {
205
+ message: `Failed to inspect extension ${fullPath}: ${err instanceof Error ? err.message : String(err)}`,
206
+ });
207
+ }
195
208
  }
196
209
  return specifiers;
197
210
  }
@@ -240,7 +253,7 @@ async function loadSpecifiers(specifiers, ctx, bustCache) {
240
253
  * Tears down old registrations, busts the module cache, and re-activates.
241
254
  */
242
255
  export async function reloadExtensions(ctx) {
243
- const specifiers = await discoverUserExtensions();
256
+ const specifiers = await discoverUserExtensions(ctx);
244
257
  return loadSpecifiers(specifiers, ctx, true);
245
258
  }
246
259
  /**
@@ -2058,6 +2058,10 @@ export default function activate(ctx: AgentContext): void {
2058
2058
  for (const name of HIDDEN_IN_SCHEME_ONLY) {
2059
2059
  try { ctx.agent.unregisterTool(name); } catch { /* not registered — fine */ }
2060
2060
  }
2061
+ ctx.bus.onPipe("agent:core-tools:collect", (ev) => ({
2062
+ ...ev,
2063
+ names: [...ev.names, "scheme_eval"],
2064
+ }));
2061
2065
  }
2062
2066
 
2063
2067
  ctx.agent.registerTool({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-sh",
3
- "version": "0.14.6",
3
+ "version": "0.14.7",
4
4
  "description": "A shell-first terminal where AI is one keystroke away",
5
5
  "type": "module",
6
6
  "workspaces": [