@inkeep/agents-sdk 0.41.2 → 0.43.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/README.md +356 -2
- package/dist/agent.d.ts +84 -73
- package/dist/agent.js +42 -4
- package/dist/agentFullClient.d.ts +8 -8
- package/dist/agentFullClient.js +4 -4
- package/dist/artifact-component.d.ts +8 -8
- package/dist/artifact-component.js +2 -2
- package/dist/builderFunctions.d.ts +337 -248
- package/dist/builderFunctions.js +131 -2
- package/dist/builderFunctionsExperimental.d.ts +17 -17
- package/dist/builders.d.ts +48 -48
- package/dist/credential-provider.d.ts +93 -93
- package/dist/credential-provider.js +1 -1
- package/dist/credential-ref.d.ts +37 -37
- package/dist/data-component.d.ts +9 -9
- package/dist/data-component.js +2 -2
- package/dist/environment-settings.d.ts +4 -4
- package/dist/evaluationClient.d.ts +78 -0
- package/dist/evaluationClient.js +1202 -0
- package/dist/external-agent.d.ts +17 -17
- package/dist/external-agent.js +2 -2
- package/dist/index.d.ts +5 -3
- package/dist/index.js +4 -2
- package/dist/module-hosted-tool-manager.d.ts +1 -1
- package/dist/module-hosted-tool-manager.js +1 -1
- package/dist/project.d.ts +83 -83
- package/dist/project.js +23 -4
- package/dist/projectFullClient.d.ts +8 -8
- package/dist/projectFullClient.js +4 -4
- package/dist/runner.d.ts +15 -15
- package/dist/status-component.d.ts +3 -3
- package/dist/subAgent.d.ts +2 -2
- package/dist/subAgent.js +7 -7
- package/dist/telemetry-provider.d.ts +76 -76
- package/dist/tool.d.ts +16 -16
- package/dist/tool.js +23 -3
- package/dist/trigger.d.ts +46 -0
- package/dist/trigger.js +65 -0
- package/dist/types.d.ts +31 -22
- package/dist/utils/generateIdFromName.d.ts +4 -4
- package/dist/utils/tool-normalization.d.ts +10 -10
- package/dist/utils/validateFunction.d.ts +5 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ const token = await credentials.get('MY_TOKEN'); // Returns 'env-token'
|
|
|
58
58
|
| Type | Description | Requirements |
|
|
59
59
|
|------|-------------|--------------|
|
|
60
60
|
| `memory` | In-memory storage with env var fallback | None (default) |
|
|
61
|
-
| `keychain` | OS keychain storage | `
|
|
61
|
+
| `keychain` | OS keychain storage | `@napi-rs/keyring` package |
|
|
62
62
|
| `nango` | OAuth credential management | `@nangohq/node`, `@nangohq/types` |
|
|
63
63
|
| `custom` | Your own implementation | Implement `CredentialStore` interface |
|
|
64
64
|
|
|
@@ -117,6 +117,359 @@ tracer.startActiveSpan('my-operation', (span) => {
|
|
|
117
117
|
| `ConsoleTelemetryProvider` | Logs to console | None |
|
|
118
118
|
| Custom OpenTelemetry | Full observability | `@opentelemetry/*` packages |
|
|
119
119
|
|
|
120
|
+
## Webhook Triggers with Signature Verification
|
|
121
|
+
|
|
122
|
+
Webhook triggers allow your agents to be invoked by external services like GitHub, Slack, Stripe, and Zendesk. The SDK provides flexible HMAC signature verification to ensure webhook requests are authentic.
|
|
123
|
+
|
|
124
|
+
### Basic Webhook Trigger
|
|
125
|
+
|
|
126
|
+
Create a simple webhook trigger without signature verification:
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
import { trigger, credentialReference } from '@inkeep/agents-sdk';
|
|
130
|
+
|
|
131
|
+
export const myWebhook = trigger({
|
|
132
|
+
id: 'github-webhook',
|
|
133
|
+
name: 'GitHub Webhook',
|
|
134
|
+
description: 'Triggered by GitHub push events',
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Webhook Signature Verification
|
|
139
|
+
|
|
140
|
+
Different webhook providers use different signature patterns. The SDK supports all common patterns through flexible configuration.
|
|
141
|
+
|
|
142
|
+
#### Quick Examples
|
|
143
|
+
|
|
144
|
+
**GitHub Webhooks:**
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import { trigger, credentialReference } from '@inkeep/agents-sdk';
|
|
148
|
+
|
|
149
|
+
export const githubWebhook = trigger({
|
|
150
|
+
id: 'github-webhook',
|
|
151
|
+
name: 'GitHub Webhook',
|
|
152
|
+
description: 'Verified GitHub webhook',
|
|
153
|
+
signingSecretCredentialReference: credentialReference({
|
|
154
|
+
id: 'github-webhook-secret',
|
|
155
|
+
}),
|
|
156
|
+
signatureVerification: {
|
|
157
|
+
algorithm: 'sha256',
|
|
158
|
+
encoding: 'hex',
|
|
159
|
+
signature: {
|
|
160
|
+
source: 'header',
|
|
161
|
+
key: 'X-Hub-Signature-256',
|
|
162
|
+
prefix: 'sha256=',
|
|
163
|
+
},
|
|
164
|
+
signedComponents: [
|
|
165
|
+
{
|
|
166
|
+
source: 'body',
|
|
167
|
+
required: true,
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
componentJoin: {
|
|
171
|
+
strategy: 'concatenate',
|
|
172
|
+
separator: '',
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**Slack Webhooks:**
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
export const slackWebhook = trigger({
|
|
182
|
+
id: 'slack-webhook',
|
|
183
|
+
name: 'Slack Webhook',
|
|
184
|
+
description: 'Verified Slack webhook',
|
|
185
|
+
signingSecretCredentialReference: credentialReference({
|
|
186
|
+
id: 'slack-signing-secret',
|
|
187
|
+
}),
|
|
188
|
+
signatureVerification: {
|
|
189
|
+
algorithm: 'sha256',
|
|
190
|
+
encoding: 'hex',
|
|
191
|
+
signature: {
|
|
192
|
+
source: 'header',
|
|
193
|
+
key: 'X-Slack-Signature',
|
|
194
|
+
prefix: 'v0=',
|
|
195
|
+
},
|
|
196
|
+
signedComponents: [
|
|
197
|
+
{
|
|
198
|
+
source: 'literal',
|
|
199
|
+
value: 'v0',
|
|
200
|
+
required: true,
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
source: 'header',
|
|
204
|
+
key: 'X-Slack-Request-Timestamp',
|
|
205
|
+
required: true,
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
source: 'body',
|
|
209
|
+
required: true,
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
componentJoin: {
|
|
213
|
+
strategy: 'concatenate',
|
|
214
|
+
separator: ':',
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
**Zendesk Webhooks:**
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
export const zendeskWebhook = trigger({
|
|
224
|
+
id: 'zendesk-webhook',
|
|
225
|
+
name: 'Zendesk Webhook',
|
|
226
|
+
description: 'Verified Zendesk webhook',
|
|
227
|
+
signingSecretCredentialReference: credentialReference({
|
|
228
|
+
id: 'zendesk-signing-secret',
|
|
229
|
+
}),
|
|
230
|
+
signatureVerification: {
|
|
231
|
+
algorithm: 'sha256',
|
|
232
|
+
encoding: 'base64',
|
|
233
|
+
signature: {
|
|
234
|
+
source: 'header',
|
|
235
|
+
key: 'X-Zendesk-Webhook-Signature',
|
|
236
|
+
},
|
|
237
|
+
signedComponents: [
|
|
238
|
+
{
|
|
239
|
+
source: 'header',
|
|
240
|
+
key: 'X-Zendesk-Webhook-Signature-Timestamp',
|
|
241
|
+
required: true,
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
source: 'body',
|
|
245
|
+
required: true,
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
componentJoin: {
|
|
249
|
+
strategy: 'concatenate',
|
|
250
|
+
separator: '',
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
**Stripe Webhooks:**
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
export const stripeWebhook = trigger({
|
|
260
|
+
id: 'stripe-webhook',
|
|
261
|
+
name: 'Stripe Webhook',
|
|
262
|
+
description: 'Verified Stripe webhook',
|
|
263
|
+
signingSecretCredentialReference: credentialReference({
|
|
264
|
+
id: 'stripe-webhook-secret',
|
|
265
|
+
}),
|
|
266
|
+
signatureVerification: {
|
|
267
|
+
algorithm: 'sha256',
|
|
268
|
+
encoding: 'hex',
|
|
269
|
+
signature: {
|
|
270
|
+
source: 'header',
|
|
271
|
+
key: 'Stripe-Signature',
|
|
272
|
+
regex: 'v1=([a-f0-9]+)',
|
|
273
|
+
},
|
|
274
|
+
signedComponents: [
|
|
275
|
+
{
|
|
276
|
+
source: 'header',
|
|
277
|
+
key: 'Stripe-Signature',
|
|
278
|
+
regex: 't=([0-9]+)',
|
|
279
|
+
required: true,
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
source: 'body',
|
|
283
|
+
required: true,
|
|
284
|
+
},
|
|
285
|
+
],
|
|
286
|
+
componentJoin: {
|
|
287
|
+
strategy: 'concatenate',
|
|
288
|
+
separator: '.',
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
});
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Configuration Reference
|
|
295
|
+
|
|
296
|
+
#### SignatureVerificationConfig
|
|
297
|
+
|
|
298
|
+
The `signatureVerification` object configures how webhook signatures are verified.
|
|
299
|
+
|
|
300
|
+
**Fields:**
|
|
301
|
+
|
|
302
|
+
- `algorithm` - HMAC algorithm: `'sha256'` | `'sha512'` | `'sha384'` | `'sha1'` | `'md5'`
|
|
303
|
+
- **Recommended:** `'sha256'` (most secure and widely supported)
|
|
304
|
+
- **Warning:** `'sha1'` and `'md5'` are cryptographically weak and only supported for legacy systems
|
|
305
|
+
|
|
306
|
+
- `encoding` - Signature encoding: `'hex'` | `'base64'`
|
|
307
|
+
- **Default:** `'hex'` (used by most providers)
|
|
308
|
+
|
|
309
|
+
- `signature` - Where and how to extract the signature from the request
|
|
310
|
+
|
|
311
|
+
- `signedComponents` - Array of components that make up the signed data
|
|
312
|
+
|
|
313
|
+
- `componentJoin` - How to join multiple components before verification
|
|
314
|
+
|
|
315
|
+
- `validation` (optional) - Advanced validation options
|
|
316
|
+
|
|
317
|
+
#### Signature Source
|
|
318
|
+
|
|
319
|
+
The `signature` field specifies where to find the signature in the webhook request.
|
|
320
|
+
|
|
321
|
+
**Fields:**
|
|
322
|
+
|
|
323
|
+
- `source` - Location: `'header'` | `'query'` | `'body'`
|
|
324
|
+
- `'header'` - Extract from HTTP header (most common)
|
|
325
|
+
- `'query'` - Extract from URL query parameter
|
|
326
|
+
- `'body'` - Extract from request body using JMESPath
|
|
327
|
+
|
|
328
|
+
- `key` - Identifier for the signature:
|
|
329
|
+
- For headers: Header name (e.g., `'X-Hub-Signature-256'`)
|
|
330
|
+
- For query params: Parameter name (e.g., `'signature'`)
|
|
331
|
+
- For body: JMESPath expression (e.g., `'signature'` or `'headers."X-Signature"'`)
|
|
332
|
+
|
|
333
|
+
- `prefix` (optional) - Prefix to strip from signature (e.g., `'sha256='`, `'v0='`)
|
|
334
|
+
|
|
335
|
+
- `regex` (optional) - Regular expression with capture group for complex formats (e.g., `'v1=([a-f0-9]+)'`)
|
|
336
|
+
|
|
337
|
+
#### Signed Components
|
|
338
|
+
|
|
339
|
+
The `signedComponents` array specifies what data was signed by the webhook provider. Components are joined in order using the `componentJoin` configuration.
|
|
340
|
+
|
|
341
|
+
**Component Fields:**
|
|
342
|
+
|
|
343
|
+
- `source` - Component location: `'header'` | `'body'` | `'literal'`
|
|
344
|
+
- `'header'` - Extract from HTTP header
|
|
345
|
+
- `'body'` - Extract from request body (uses entire body as string)
|
|
346
|
+
- `'literal'` - Use a fixed string value
|
|
347
|
+
|
|
348
|
+
- `key` (optional) - Identifier:
|
|
349
|
+
- For headers: Header name (e.g., `'X-Slack-Request-Timestamp'`)
|
|
350
|
+
- For body: JMESPath expression (e.g., `'data.timestamp'`)
|
|
351
|
+
- Not used for literal components
|
|
352
|
+
|
|
353
|
+
- `value` (optional) - Static string value (only for `source: 'literal'`)
|
|
354
|
+
|
|
355
|
+
- `regex` (optional) - Regex with capture group to extract part of the value
|
|
356
|
+
|
|
357
|
+
- `required` - Whether component must be present (default: `true`)
|
|
358
|
+
- If `false`, missing components are treated as empty strings
|
|
359
|
+
|
|
360
|
+
#### Component Join
|
|
361
|
+
|
|
362
|
+
The `componentJoin` field specifies how to combine multiple signed components.
|
|
363
|
+
|
|
364
|
+
**Fields:**
|
|
365
|
+
|
|
366
|
+
- `strategy` - Join strategy: `'concatenate'` (only option currently)
|
|
367
|
+
|
|
368
|
+
- `separator` - String to insert between components:
|
|
369
|
+
- `''` (empty) - Direct concatenation (GitHub, Zendesk)
|
|
370
|
+
- `':'` - Colon separator (Slack)
|
|
371
|
+
- `'.'` - Dot separator (Stripe)
|
|
372
|
+
|
|
373
|
+
#### Advanced Validation Options
|
|
374
|
+
|
|
375
|
+
The optional `validation` field provides fine-grained control over verification behavior.
|
|
376
|
+
|
|
377
|
+
**Fields:**
|
|
378
|
+
|
|
379
|
+
- `headerCaseSensitive` (default: `false`) - Whether header names are case-sensitive
|
|
380
|
+
- `false` - Case-insensitive matching (HTTP standard, recommended)
|
|
381
|
+
- `true` - Exact case match required
|
|
382
|
+
|
|
383
|
+
- `allowEmptyBody` (default: `true`) - Whether to allow requests with empty bodies
|
|
384
|
+
- `true` - Empty bodies are valid (some webhooks send header-only verification requests)
|
|
385
|
+
- `false` - Reject requests with empty bodies
|
|
386
|
+
|
|
387
|
+
- `normalizeUnicode` (default: `false`) - Whether to normalize Unicode to NFC form
|
|
388
|
+
- `false` - Use raw body bytes
|
|
389
|
+
- `true` - Normalize to NFC before verification (handles different Unicode representations)
|
|
390
|
+
|
|
391
|
+
**Example with validation options:**
|
|
392
|
+
|
|
393
|
+
```typescript
|
|
394
|
+
signatureVerification: {
|
|
395
|
+
algorithm: 'sha256',
|
|
396
|
+
encoding: 'hex',
|
|
397
|
+
signature: {
|
|
398
|
+
source: 'header',
|
|
399
|
+
key: 'X-Signature',
|
|
400
|
+
},
|
|
401
|
+
signedComponents: [{ source: 'body', required: true }],
|
|
402
|
+
componentJoin: { strategy: 'concatenate', separator: '' },
|
|
403
|
+
validation: {
|
|
404
|
+
headerCaseSensitive: true,
|
|
405
|
+
allowEmptyBody: false,
|
|
406
|
+
normalizeUnicode: true,
|
|
407
|
+
},
|
|
408
|
+
},
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
### Migration from Legacy `signingSecret`
|
|
412
|
+
|
|
413
|
+
**Breaking Change:** The legacy `signingSecret` parameter has been removed. All triggers must use credential references and the new `signatureVerification` configuration.
|
|
414
|
+
|
|
415
|
+
**Before (deprecated):**
|
|
416
|
+
|
|
417
|
+
```typescript
|
|
418
|
+
export const webhook = trigger({
|
|
419
|
+
id: 'my-webhook',
|
|
420
|
+
signingSecret: 'my-secret-key', // ❌ No longer supported
|
|
421
|
+
});
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
**After (current):**
|
|
425
|
+
|
|
426
|
+
```typescript
|
|
427
|
+
export const webhook = trigger({
|
|
428
|
+
id: 'my-webhook',
|
|
429
|
+
signingSecretCredentialReference: credentialReference({
|
|
430
|
+
id: 'webhook-secret',
|
|
431
|
+
}),
|
|
432
|
+
signatureVerification: {
|
|
433
|
+
algorithm: 'sha256',
|
|
434
|
+
encoding: 'hex',
|
|
435
|
+
signature: {
|
|
436
|
+
source: 'header',
|
|
437
|
+
key: 'X-Hub-Signature-256',
|
|
438
|
+
prefix: 'sha256=',
|
|
439
|
+
},
|
|
440
|
+
signedComponents: [{ source: 'body', required: true }],
|
|
441
|
+
componentJoin: { strategy: 'concatenate', separator: '' },
|
|
442
|
+
},
|
|
443
|
+
});
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
### Security Best Practices
|
|
447
|
+
|
|
448
|
+
1. **Always use credential references** - Never hardcode signing secrets in your code
|
|
449
|
+
2. **Use strong algorithms** - Prefer `sha256` or stronger; avoid `sha1` and `md5`
|
|
450
|
+
3. **Validate all webhooks** - Always configure signature verification for production webhooks
|
|
451
|
+
4. **Use HTTPS** - Always receive webhooks over HTTPS to prevent man-in-the-middle attacks
|
|
452
|
+
5. **Rotate secrets regularly** - Update signing secrets periodically
|
|
453
|
+
6. **Monitor failed verifications** - Failed signature checks may indicate an attack
|
|
454
|
+
|
|
455
|
+
### Troubleshooting
|
|
456
|
+
|
|
457
|
+
**Signature verification always fails:**
|
|
458
|
+
|
|
459
|
+
1. Verify your signing secret is correct in the credential store
|
|
460
|
+
2. Check that the `algorithm` matches what the provider uses
|
|
461
|
+
3. Verify the `encoding` (hex vs base64)
|
|
462
|
+
4. Ensure `signedComponents` match what the provider actually signs
|
|
463
|
+
5. Check the `separator` in `componentJoin`
|
|
464
|
+
6. For body-based components, ensure you're not modifying the raw body
|
|
465
|
+
|
|
466
|
+
**Provider-specific tips:**
|
|
467
|
+
|
|
468
|
+
- **GitHub:** Requires `prefix: 'sha256='` and signs only the raw body
|
|
469
|
+
- **Slack:** Signs three components with colons: `v0:{timestamp}:{body}`
|
|
470
|
+
- **Stripe:** Uses regex extraction for both signature and timestamp from the same header
|
|
471
|
+
- **Zendesk:** Uses base64 encoding instead of hex
|
|
472
|
+
|
|
120
473
|
## API Reference
|
|
121
474
|
|
|
122
475
|
### Builders
|
|
@@ -124,6 +477,7 @@ tracer.startActiveSpan('my-operation', (span) => {
|
|
|
124
477
|
- `agent()` - Create an agent (top-level container with multiple sub-agents)
|
|
125
478
|
- `subAgent()` - Create a sub-agent configuration
|
|
126
479
|
- `tool()` - Create a tool configuration
|
|
480
|
+
- `trigger()` - Create a webhook trigger configuration
|
|
127
481
|
- `mcpServer()` - Create an MCP server configuration
|
|
128
482
|
- `mcpTool()` - Create an MCP tool
|
|
129
483
|
- `dataComponent()` - Create a data component
|
|
@@ -190,7 +544,7 @@ The SDK has minimal required dependencies. Advanced features require optional pa
|
|
|
190
544
|
| Feature | Required Packages |
|
|
191
545
|
|---------|------------------|
|
|
192
546
|
| Nango credentials | `@nangohq/node`, `@nangohq/types` |
|
|
193
|
-
| Keychain storage | `
|
|
547
|
+
| Keychain storage | `@napi-rs/keyring` |
|
|
194
548
|
| OpenTelemetry | `@opentelemetry/api`, `@opentelemetry/sdk-node` |
|
|
195
549
|
|
|
196
550
|
Install only what you need:
|
package/dist/agent.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Trigger, TriggerInterface } from "./trigger.js";
|
|
1
2
|
import { AgentConfig, AgentInterface, AllDelegateInputInterface, GenerateOptions, MessageInput, ModelSettings, RunResult, StreamResponse, SubAgentInterface, subAgentTeamAgentInterface } from "./types.js";
|
|
2
3
|
import { AgentStopWhen, FullAgentDefinition, StatusUpdateSettings } from "@inkeep/agents-core";
|
|
3
4
|
|
|
@@ -19,102 +20,112 @@ declare class Agent implements AgentInterface {
|
|
|
19
20
|
private statusUpdateSettings?;
|
|
20
21
|
private prompt?;
|
|
21
22
|
private stopWhen?;
|
|
23
|
+
private triggers;
|
|
24
|
+
private triggerMap;
|
|
22
25
|
constructor(config: AgentConfig);
|
|
23
26
|
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
* Set or update the configuration (tenantId, projectId and apiUrl)
|
|
28
|
+
* This is used by the CLI to inject configuration from inkeep.config.ts
|
|
29
|
+
*/
|
|
27
30
|
setConfig(tenantId: string, projectId: string, apiUrl: string): void;
|
|
28
31
|
/**
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
* Convert the Agent to FullAgentDefinition format for the new agent endpoint
|
|
33
|
+
*/
|
|
31
34
|
toFullAgentDefinition(): Promise<FullAgentDefinition>;
|
|
32
35
|
/**
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
* Initialize all tools in all agents (especially IPCTools that need MCP server URLs)
|
|
37
|
+
*/
|
|
35
38
|
private initializeAllTools;
|
|
36
39
|
/**
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
* Initialize the agent and all agents in the backend using the new agent endpoint
|
|
41
|
+
*/
|
|
39
42
|
init(): Promise<void>;
|
|
40
43
|
/**
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
* Generate a response using the default agent
|
|
45
|
+
*/
|
|
43
46
|
generate(input: MessageInput, options?: GenerateOptions): Promise<string>;
|
|
44
47
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
* Stream a response using the default agent
|
|
49
|
+
*/
|
|
47
50
|
stream(input: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
|
|
48
51
|
/**
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
* Alias for stream() method for consistency with naming patterns
|
|
53
|
+
*/
|
|
51
54
|
generateStream(input: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
|
|
52
55
|
/**
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
* Run with a specific agent from the agent
|
|
57
|
+
*/
|
|
55
58
|
runWith(subAgentId: string, input: MessageInput, options?: GenerateOptions): Promise<RunResult>;
|
|
56
59
|
/**
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
* Get an agent by name (unified method for all agent types)
|
|
61
|
+
*/
|
|
59
62
|
getSubAgent(name: string): SubAgentInterface | undefined;
|
|
60
63
|
/**
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
* Add an agent to the agent
|
|
65
|
+
*/
|
|
63
66
|
addSubAgent(agent: SubAgentInterface): void;
|
|
64
67
|
/**
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
* Remove an agent from the agent
|
|
69
|
+
*/
|
|
67
70
|
removeSubAgent(id: string): boolean;
|
|
68
71
|
/**
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
* Get all agents in the agent
|
|
73
|
+
*/
|
|
71
74
|
getSubAgents(): SubAgentInterface[];
|
|
72
75
|
/**
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
* Get all agent ids (unified method for all agent types)
|
|
77
|
+
*/
|
|
75
78
|
getSubAgentIds(): string[];
|
|
76
79
|
/**
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
* Set the default agent
|
|
81
|
+
*/
|
|
79
82
|
setDefaultSubAgent(agent: SubAgentInterface): void;
|
|
80
83
|
/**
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
* Get the default agent
|
|
85
|
+
*/
|
|
83
86
|
getDefaultSubAgent(): SubAgentInterface | undefined;
|
|
84
87
|
/**
|
|
85
|
-
|
|
86
|
-
|
|
88
|
+
* Get all triggers for this agent
|
|
89
|
+
*/
|
|
90
|
+
getTriggers(): Record<string, Trigger>;
|
|
91
|
+
/**
|
|
92
|
+
* Add one or more triggers to the agent at runtime
|
|
93
|
+
*/
|
|
94
|
+
addTrigger(...triggers: TriggerInterface[]): void;
|
|
95
|
+
/**
|
|
96
|
+
* Get the agent ID
|
|
97
|
+
*/
|
|
87
98
|
getId(): string;
|
|
88
99
|
getName(): string;
|
|
89
100
|
getDescription(): string | undefined;
|
|
90
101
|
getTenantId(): string;
|
|
91
102
|
/**
|
|
92
|
-
|
|
93
|
-
|
|
103
|
+
* Get the agent's model settingsuration
|
|
104
|
+
*/
|
|
94
105
|
getModels(): typeof this.models;
|
|
95
106
|
/**
|
|
96
|
-
|
|
97
|
-
|
|
107
|
+
* Set the agent's model settingsuration
|
|
108
|
+
*/
|
|
98
109
|
setModels(models: typeof this.models): void;
|
|
99
110
|
/**
|
|
100
|
-
|
|
101
|
-
|
|
111
|
+
* Get the agent's prompt configuration
|
|
112
|
+
*/
|
|
102
113
|
getPrompt(): string | undefined;
|
|
103
114
|
/**
|
|
104
|
-
|
|
105
|
-
|
|
115
|
+
* Get the agent's stopWhen configuration
|
|
116
|
+
*/
|
|
106
117
|
getStopWhen(): AgentStopWhen;
|
|
107
118
|
/**
|
|
108
|
-
|
|
109
|
-
|
|
119
|
+
* Get the agent's status updates configuration
|
|
120
|
+
*/
|
|
110
121
|
getStatusUpdateSettings(): StatusUpdateSettings | undefined;
|
|
111
122
|
/**
|
|
112
|
-
|
|
113
|
-
|
|
123
|
+
* Get the summarizer model from the agent's model settings
|
|
124
|
+
*/
|
|
114
125
|
getSummarizerModel(): ModelSettings | undefined;
|
|
115
126
|
/**
|
|
116
|
-
|
|
117
|
-
|
|
127
|
+
* Get agent statistics
|
|
128
|
+
*/
|
|
118
129
|
getStats(): {
|
|
119
130
|
agentCount: number;
|
|
120
131
|
defaultSubAgent: string | null;
|
|
@@ -126,61 +137,61 @@ declare class Agent implements AgentInterface {
|
|
|
126
137
|
headers?: Record<string, string>;
|
|
127
138
|
}): subAgentTeamAgentInterface;
|
|
128
139
|
/**
|
|
129
|
-
|
|
130
|
-
|
|
140
|
+
* Validate the agent configuration
|
|
141
|
+
*/
|
|
131
142
|
validate(): {
|
|
132
143
|
valid: boolean;
|
|
133
144
|
errors: string[];
|
|
134
145
|
};
|
|
135
146
|
private _init;
|
|
136
147
|
/**
|
|
137
|
-
|
|
138
|
-
|
|
148
|
+
* Type guard to check if an agent is an internal AgentInterface
|
|
149
|
+
*/
|
|
139
150
|
isInternalAgent(agent: AllDelegateInputInterface): agent is SubAgentInterface;
|
|
140
151
|
/**
|
|
141
|
-
|
|
142
|
-
|
|
152
|
+
* Get project-level model settingsuration defaults
|
|
153
|
+
*/
|
|
143
154
|
private getProjectModelDefaults;
|
|
144
155
|
/**
|
|
145
|
-
|
|
146
|
-
|
|
156
|
+
* Get project-level stopWhen configuration defaults
|
|
157
|
+
*/
|
|
147
158
|
private getProjectStopWhenDefaults;
|
|
148
159
|
/**
|
|
149
|
-
|
|
150
|
-
|
|
160
|
+
* Apply model inheritance hierarchy: Project -> Agent -> Agent
|
|
161
|
+
*/
|
|
151
162
|
private applyModelInheritance;
|
|
152
163
|
/**
|
|
153
|
-
|
|
154
|
-
|
|
164
|
+
* Apply stopWhen inheritance hierarchy: Project -> Agent -> Agent
|
|
165
|
+
*/
|
|
155
166
|
private applyStopWhenInheritance;
|
|
156
167
|
/**
|
|
157
|
-
|
|
158
|
-
|
|
168
|
+
* Propagate agent-level model settings to agents (supporting partial inheritance)
|
|
169
|
+
*/
|
|
159
170
|
private propagateModelSettingsToAgent;
|
|
160
171
|
/**
|
|
161
|
-
|
|
162
|
-
|
|
172
|
+
* Immediately propagate agent-level models to all agents during construction
|
|
173
|
+
*/
|
|
163
174
|
private propagateImmediateModelSettings;
|
|
164
175
|
/**
|
|
165
|
-
|
|
166
|
-
|
|
176
|
+
* Execute agent using the backend system instead of local runner
|
|
177
|
+
*/
|
|
167
178
|
private executeWithBackend;
|
|
168
179
|
/**
|
|
169
|
-
|
|
170
|
-
|
|
180
|
+
* Parse streaming response in SSE format
|
|
181
|
+
*/
|
|
171
182
|
private parseStreamingResponse;
|
|
172
183
|
/**
|
|
173
|
-
|
|
174
|
-
|
|
184
|
+
* Normalize input messages to the expected format
|
|
185
|
+
*/
|
|
175
186
|
private normalizeMessages;
|
|
176
187
|
}
|
|
177
188
|
/**
|
|
178
|
-
|
|
179
|
-
|
|
189
|
+
* Helper function to create agent - OpenAI style
|
|
190
|
+
*/
|
|
180
191
|
declare function agent(config: AgentConfig): Agent;
|
|
181
192
|
/**
|
|
182
|
-
|
|
183
|
-
|
|
193
|
+
* Factory function to create agent from configuration file
|
|
194
|
+
*/
|
|
184
195
|
declare function generateAgent(configPath: string): Promise<Agent>;
|
|
185
196
|
//#endregion
|
|
186
197
|
export { Agent, agent, generateAgent };
|