You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(sdk): simplify and enhance loadLocalAgents API
- Remove confusing global loadedAgents export (was mutable state)
- Add proper typing with LoadedAgents and LoadedAgentDefinition types
- Add _sourceFilePath to each loaded agent for debugging
- Add validate option to automatically filter invalid agents
- Update README with comprehensive documentation
- All changes are backwards-compatible
console.log(`${agent.id} loaded from ${agent._sourceFilePath}`)
158
+
}
159
+
160
+
// Use the loaded agents with client.run()
161
+
const result =awaitclient.run({
162
+
agent: 'my-custom-agent',
163
+
agentDefinitions: Object.values(agents),
164
+
prompt: 'Hello',
165
+
})
166
+
```
167
+
168
+
#### Parameters
169
+
170
+
-**`agentsPath`** (string, optional): Path to a specific agents directory. If omitted, searches in `{cwd}/.agents`, `{cwd}/../.agents`, and `{homedir}/.agents`.
171
+
-**`verbose`** (boolean, optional): Whether to log errors during loading. Defaults to `false`.
172
+
-**`validate`** (boolean, optional): Whether to validate agents after loading. Invalid agents are filtered out. Defaults to `false`.
173
+
174
+
#### Returns
175
+
176
+
Returns a `Promise<LoadedAgents>` - a `Record<string, LoadedAgentDefinition>` of agent definitions keyed by their ID.
177
+
178
+
Each `LoadedAgentDefinition` extends `AgentDefinition` with:
179
+
-**`_sourceFilePath`** (string): The file path the agent was loaded from
0 commit comments