@robota-sdk/agent-plugin 3.0.0-beta.64 → 3.0.0-beta.66
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 +92 -0
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +4 -2
- package/src/conversation-history/conversation-history-helpers.ts +2 -0
- package/src/conversation-history/conversation-history-plugin.ts +8 -6
- package/src/conversation-history/storages/database-storage.ts +2 -1
- package/src/conversation-history/storages/file-storage.ts +2 -1
- package/src/error-handling/error-handling-helpers.ts +1 -0
- package/src/error-handling/error-handling-plugin.ts +15 -14
- package/src/execution-analytics/execution-analytics-plugin.ts +18 -7
- package/src/limits/limits-helpers.ts +2 -1
- package/src/limits/limits-plugin.ts +10 -8
- package/src/limits/validation.ts +1 -0
- package/src/logging/logging-helpers.ts +2 -0
- package/src/logging/logging-plugin.ts +10 -9
- package/src/logging/storages/console-storage.ts +4 -2
- package/src/logging/storages/file-storage.ts +4 -2
- package/src/logging/storages/remote-storage.ts +4 -2
- package/src/performance/collectors/system-metrics-collector.ts +2 -1
- package/src/performance/performance-helpers.ts +2 -0
- package/src/performance/performance-plugin.ts +9 -7
- package/src/performance/storages/memory-storage.ts +5 -1
- package/src/usage/storages/file-storage.ts +3 -1
- package/src/usage/storages/memory-storage.ts +2 -1
- package/src/usage/storages/remote-storage.ts +3 -1
- package/src/usage/storages/silent-storage.ts +2 -1
- package/src/usage/usage-plugin-helpers.ts +1 -0
- package/src/usage/usage-plugin.ts +9 -7
- package/src/webhook/http-client.ts +1 -0
- package/src/webhook/transformer.ts +6 -6
- package/src/webhook/types.ts +7 -4
- package/src/webhook/webhook-helpers.ts +1 -0
- package/src/webhook/webhook-plugin.ts +2 -1
- package/src/webhook/webhook-queue.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@robota-sdk/agent-plugin",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.66",
|
|
4
4
|
"description": "Consolidated plugin implementations for Robota SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/node/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"jssha": "^3.3.1",
|
|
28
|
-
"@robota-sdk/agent-core": "3.0.0-beta.
|
|
28
|
+
"@robota-sdk/agent-core": "3.0.0-beta.66"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^22.14.0",
|
|
@@ -40,6 +40,8 @@
|
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "tsdown",
|
|
43
|
+
"build:js": "tsdown --no-dts",
|
|
44
|
+
"build:types": "tsdown --dts",
|
|
43
45
|
"typecheck": "tsc --noEmit",
|
|
44
46
|
"test": "vitest run",
|
|
45
47
|
"test:coverage": "vitest run --coverage",
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { ConfigurationError, PluginError, type ILogger } from '@robota-sdk/agent-core';
|
|
9
|
+
|
|
9
10
|
import { MemoryHistoryStorage, FileHistoryStorage, DatabaseHistoryStorage } from './storages/index';
|
|
11
|
+
|
|
10
12
|
import type {
|
|
11
13
|
IConversationHistoryPluginOptions,
|
|
12
14
|
IHistoryStorage,
|
|
@@ -10,12 +10,7 @@ import {
|
|
|
10
10
|
startPeriodicTask,
|
|
11
11
|
stopPeriodicTask,
|
|
12
12
|
} from '@robota-sdk/agent-core';
|
|
13
|
-
|
|
14
|
-
IConversationHistoryPluginOptions,
|
|
15
|
-
IConversationHistoryPluginStats,
|
|
16
|
-
IConversationHistoryEntry,
|
|
17
|
-
IHistoryStorage,
|
|
18
|
-
} from './types';
|
|
13
|
+
|
|
19
14
|
import {
|
|
20
15
|
validateConversationHistoryOptions,
|
|
21
16
|
createHistoryStorage,
|
|
@@ -23,6 +18,13 @@ import {
|
|
|
23
18
|
savePendingConversations,
|
|
24
19
|
} from './conversation-history-helpers';
|
|
25
20
|
|
|
21
|
+
import type {
|
|
22
|
+
IConversationHistoryPluginOptions,
|
|
23
|
+
IConversationHistoryPluginStats,
|
|
24
|
+
IConversationHistoryEntry,
|
|
25
|
+
IHistoryStorage,
|
|
26
|
+
} from './types';
|
|
27
|
+
|
|
26
28
|
const DEFAULT_MAX_CONVERSATIONS = 100;
|
|
27
29
|
const DEFAULT_MAX_MESSAGES = 1000;
|
|
28
30
|
const DEFAULT_SAVE_INTERVAL_MS = 30000;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { IHistoryStorage, IConversationHistoryEntry } from '../types';
|
|
2
1
|
import { createLogger, type ILogger, StorageError } from '@robota-sdk/agent-core';
|
|
3
2
|
|
|
3
|
+
import type { IHistoryStorage, IConversationHistoryEntry } from '../types';
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* Database storage implementation
|
|
6
7
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { IHistoryStorage, IConversationHistoryEntry } from '../types';
|
|
2
1
|
import { createLogger, type ILogger, StorageError } from '@robota-sdk/agent-core';
|
|
3
2
|
|
|
3
|
+
import type { IHistoryStorage, IConversationHistoryEntry } from '../types';
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* File storage implementation
|
|
6
7
|
*/
|
|
@@ -8,11 +8,6 @@ import {
|
|
|
8
8
|
} from '@robota-sdk/agent-core';
|
|
9
9
|
|
|
10
10
|
// Import from Facade pattern modules for type safety
|
|
11
|
-
import type {
|
|
12
|
-
IErrorHandlingContextData,
|
|
13
|
-
IErrorHandlingPluginOptions,
|
|
14
|
-
IErrorHandlingPluginStats,
|
|
15
|
-
} from './types';
|
|
16
11
|
import { toErrorContext, createPluginErrorContext } from './context-adapter';
|
|
17
12
|
import {
|
|
18
13
|
validateErrorHandlingOptions,
|
|
@@ -21,6 +16,12 @@ import {
|
|
|
21
16
|
sleep,
|
|
22
17
|
} from './error-handling-helpers';
|
|
23
18
|
|
|
19
|
+
import type {
|
|
20
|
+
IErrorHandlingContextData,
|
|
21
|
+
IErrorHandlingPluginOptions,
|
|
22
|
+
IErrorHandlingPluginStats,
|
|
23
|
+
} from './types';
|
|
24
|
+
|
|
24
25
|
const DEFAULT_MAX_RETRIES = 3;
|
|
25
26
|
const DEFAULT_RETRY_DELAY_MS = 1000;
|
|
26
27
|
const DEFAULT_FAILURE_THRESHOLD = 5;
|
|
@@ -106,7 +107,7 @@ export class ErrorHandlingPlugin extends AbstractPlugin<
|
|
|
106
107
|
this.logger.error('Error occurred', {
|
|
107
108
|
error: error.message,
|
|
108
109
|
stack: error.stack,
|
|
109
|
-
context
|
|
110
|
+
context,
|
|
110
111
|
});
|
|
111
112
|
}
|
|
112
113
|
|
|
@@ -180,8 +181,8 @@ export class ErrorHandlingPlugin extends AbstractPlugin<
|
|
|
180
181
|
this.failureCount = 0;
|
|
181
182
|
this.circuitBreakerOpen = false;
|
|
182
183
|
this.logger.info('Operation succeeded after retry', {
|
|
183
|
-
attempt
|
|
184
|
-
context
|
|
184
|
+
attempt,
|
|
185
|
+
context,
|
|
185
186
|
});
|
|
186
187
|
}
|
|
187
188
|
|
|
@@ -201,9 +202,9 @@ export class ErrorHandlingPlugin extends AbstractPlugin<
|
|
|
201
202
|
);
|
|
202
203
|
|
|
203
204
|
this.logger.debug('Retrying operation', {
|
|
204
|
-
attempt
|
|
205
|
-
delay
|
|
206
|
-
context
|
|
205
|
+
attempt,
|
|
206
|
+
delay,
|
|
207
|
+
context,
|
|
207
208
|
});
|
|
208
209
|
await sleep(delay);
|
|
209
210
|
} else {
|
|
@@ -258,7 +259,7 @@ export class ErrorHandlingPlugin extends AbstractPlugin<
|
|
|
258
259
|
// Simple logging - no additional logic
|
|
259
260
|
this.logger.debug('Simple error handling applied', {
|
|
260
261
|
error: error.message,
|
|
261
|
-
context
|
|
262
|
+
context,
|
|
262
263
|
});
|
|
263
264
|
}
|
|
264
265
|
|
|
@@ -274,7 +275,7 @@ export class ErrorHandlingPlugin extends AbstractPlugin<
|
|
|
274
275
|
this.logger.warn('Circuit breaker opened', {
|
|
275
276
|
failureCount: this.failureCount,
|
|
276
277
|
threshold: this.pluginOptions.failureThreshold,
|
|
277
|
-
context
|
|
278
|
+
context,
|
|
278
279
|
});
|
|
279
280
|
}
|
|
280
281
|
}
|
|
@@ -287,7 +288,7 @@ export class ErrorHandlingPlugin extends AbstractPlugin<
|
|
|
287
288
|
this.logger.debug('Exponential backoff error handling applied', {
|
|
288
289
|
error: _error.message,
|
|
289
290
|
failureCount: this.failureCount,
|
|
290
|
-
context
|
|
291
|
+
context,
|
|
291
292
|
});
|
|
292
293
|
}
|
|
293
294
|
}
|
|
@@ -11,12 +11,7 @@ import {
|
|
|
11
11
|
type TToolParameters,
|
|
12
12
|
type IToolExecutionResult,
|
|
13
13
|
} from '@robota-sdk/agent-core';
|
|
14
|
-
|
|
15
|
-
IExecutionStats,
|
|
16
|
-
IAggregatedExecutionStats,
|
|
17
|
-
IExecutionAnalyticsOptions,
|
|
18
|
-
IExecutionAnalyticsPluginStats,
|
|
19
|
-
} from './types';
|
|
14
|
+
|
|
20
15
|
import { aggregateExecutionStats } from './analytics-aggregation';
|
|
21
16
|
import {
|
|
22
17
|
validateExecutionAnalyticsOptions,
|
|
@@ -25,6 +20,13 @@ import {
|
|
|
25
20
|
buildErrorExecutionStats,
|
|
26
21
|
} from './execution-analytics-helpers';
|
|
27
22
|
|
|
23
|
+
import type {
|
|
24
|
+
IExecutionStats,
|
|
25
|
+
IAggregatedExecutionStats,
|
|
26
|
+
IExecutionAnalyticsOptions,
|
|
27
|
+
IExecutionAnalyticsPluginStats,
|
|
28
|
+
} from './types';
|
|
29
|
+
|
|
28
30
|
const DEFAULT_MAX_ENTRIES = 1000;
|
|
29
31
|
const DEFAULT_PERFORMANCE_THRESHOLD_MS = 5000;
|
|
30
32
|
const PREVIEW_LENGTH = 100;
|
|
@@ -279,7 +281,16 @@ export class ExecutionAnalyticsPlugin extends AbstractPlugin<
|
|
|
279
281
|
this.clearStats();
|
|
280
282
|
}
|
|
281
283
|
|
|
282
|
-
override getStatus() {
|
|
284
|
+
override getStatus(): {
|
|
285
|
+
name: string;
|
|
286
|
+
version: string;
|
|
287
|
+
enabled: boolean;
|
|
288
|
+
initialized: boolean;
|
|
289
|
+
category: PluginCategory;
|
|
290
|
+
priority: number;
|
|
291
|
+
subscribedEventsCount: number;
|
|
292
|
+
hasEventEmitter: boolean;
|
|
293
|
+
} {
|
|
283
294
|
return {
|
|
284
295
|
name: this.name,
|
|
285
296
|
version: this.version,
|
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { PluginError } from '@robota-sdk/agent-core';
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
import type { ILimitWindow, ITokenBucket } from './types';
|
|
11
|
+
import type { TUniversalMessage } from '@robota-sdk/agent-core';
|
|
11
12
|
|
|
12
13
|
const COST_DECIMAL_PLACES = 4;
|
|
13
14
|
const CHARS_PER_TOKEN = 4;
|
|
@@ -8,14 +8,7 @@ import {
|
|
|
8
8
|
type ILogger,
|
|
9
9
|
type TUniversalMessage,
|
|
10
10
|
} from '@robota-sdk/agent-core';
|
|
11
|
-
|
|
12
|
-
TLimitsStrategy,
|
|
13
|
-
ILimitsPluginOptions,
|
|
14
|
-
TPluginLimitsStatusData,
|
|
15
|
-
ILimitWindow,
|
|
16
|
-
ITokenBucket,
|
|
17
|
-
} from './types';
|
|
18
|
-
import { validateLimitsOptions } from './validation';
|
|
11
|
+
|
|
19
12
|
import {
|
|
20
13
|
defaultCostCalculator,
|
|
21
14
|
estimateTokensFromMessages,
|
|
@@ -23,6 +16,15 @@ import {
|
|
|
23
16
|
checkSlidingWindow,
|
|
24
17
|
checkFixedWindow,
|
|
25
18
|
} from './limits-helpers';
|
|
19
|
+
import { validateLimitsOptions } from './validation';
|
|
20
|
+
|
|
21
|
+
import type {
|
|
22
|
+
TLimitsStrategy,
|
|
23
|
+
ILimitsPluginOptions,
|
|
24
|
+
TPluginLimitsStatusData,
|
|
25
|
+
ILimitWindow,
|
|
26
|
+
ITokenBucket,
|
|
27
|
+
} from './types';
|
|
26
28
|
|
|
27
29
|
const DEFAULT_MAX_TOKENS = 100000;
|
|
28
30
|
const DEFAULT_MAX_REQUESTS = 1000;
|
package/src/limits/validation.ts
CHANGED
|
@@ -6,12 +6,14 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { ConfigurationError, EVENT_EMITTER_EVENTS } from '@robota-sdk/agent-core';
|
|
9
|
+
|
|
9
10
|
import {
|
|
10
11
|
ConsoleLogStorage,
|
|
11
12
|
FileLogStorage,
|
|
12
13
|
RemoteLogStorage,
|
|
13
14
|
SilentLogStorage,
|
|
14
15
|
} from './storages/index';
|
|
16
|
+
|
|
15
17
|
import type { ILoggingPluginOptions, ILogStorage, TLogLevel, ILogEntry } from './types';
|
|
16
18
|
|
|
17
19
|
/** Validate LoggingPlugin constructor options. @internal */
|
|
@@ -10,15 +10,6 @@ import {
|
|
|
10
10
|
type TEventName,
|
|
11
11
|
} from '@robota-sdk/agent-core';
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
TLogLevel,
|
|
15
|
-
ILogEntry,
|
|
16
|
-
ILoggingContextData,
|
|
17
|
-
ILoggingPluginOptions,
|
|
18
|
-
ILoggingPluginStats,
|
|
19
|
-
ILogStorage,
|
|
20
|
-
ILogFormatter,
|
|
21
|
-
} from './types';
|
|
22
13
|
import {
|
|
23
14
|
validateLoggingOptions,
|
|
24
15
|
createLoggingStorage,
|
|
@@ -29,6 +20,16 @@ import {
|
|
|
29
20
|
logToolExecutionHelper,
|
|
30
21
|
} from './logging-helpers';
|
|
31
22
|
|
|
23
|
+
import type {
|
|
24
|
+
TLogLevel,
|
|
25
|
+
ILogEntry,
|
|
26
|
+
ILoggingContextData,
|
|
27
|
+
ILoggingPluginOptions,
|
|
28
|
+
ILoggingPluginStats,
|
|
29
|
+
ILogStorage,
|
|
30
|
+
ILogFormatter,
|
|
31
|
+
} from './types';
|
|
32
|
+
|
|
32
33
|
export type { ILoggingContextData } from './types';
|
|
33
34
|
|
|
34
35
|
const DEFAULT_MAX_LOGS = 10000;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { ILogEntry, ILogStorage, ILogFormatter, TLogLevel } from '../types';
|
|
2
|
-
import { ConsoleLogFormatter } from '../formatters';
|
|
3
1
|
import { SilentLogger, type ILogger } from '@robota-sdk/agent-core';
|
|
4
2
|
|
|
3
|
+
import { ConsoleLogFormatter } from '../formatters';
|
|
4
|
+
|
|
5
|
+
import type { ILogEntry, ILogStorage, ILogFormatter, TLogLevel } from '../types';
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* Console log storage
|
|
7
9
|
*/
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { ILogEntry, ILogStorage, ILogFormatter } from '../types';
|
|
2
|
-
import { JsonLogFormatter } from '../formatters';
|
|
3
1
|
import { createLogger, type ILogger, PluginError } from '@robota-sdk/agent-core';
|
|
4
2
|
|
|
3
|
+
import { JsonLogFormatter } from '../formatters';
|
|
4
|
+
|
|
5
|
+
import type { ILogEntry, ILogStorage, ILogFormatter } from '../types';
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* File log storage (placeholder implementation)
|
|
7
9
|
*/
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { ILogEntry, ILogStorage, ILogFormatter } from '../types';
|
|
2
|
-
import { JsonLogFormatter } from '../formatters';
|
|
3
1
|
import {
|
|
4
2
|
createLogger,
|
|
5
3
|
type ILogger,
|
|
@@ -9,6 +7,10 @@ import {
|
|
|
9
7
|
stopPeriodicTask,
|
|
10
8
|
} from '@robota-sdk/agent-core';
|
|
11
9
|
|
|
10
|
+
import { JsonLogFormatter } from '../formatters';
|
|
11
|
+
|
|
12
|
+
import type { ILogEntry, ILogStorage, ILogFormatter } from '../types';
|
|
13
|
+
|
|
12
14
|
/**
|
|
13
15
|
* Remote log storage with batching
|
|
14
16
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { type ISystemMetricsCollector, type IPerformanceMetrics } from '../types';
|
|
2
1
|
import { createLogger, type ILogger } from '@robota-sdk/agent-core';
|
|
3
2
|
|
|
3
|
+
import { type ISystemMetricsCollector, type IPerformanceMetrics } from '../types';
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* Node.js system metrics collector
|
|
6
7
|
*/
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { ConfigurationError, EVENT_EMITTER_EVENTS } from '@robota-sdk/agent-core';
|
|
9
|
+
|
|
9
10
|
import { MemoryPerformanceStorage } from './storages/index';
|
|
11
|
+
|
|
10
12
|
import type { IPerformancePluginOptions, IPerformanceStorage } from './types';
|
|
11
13
|
|
|
12
14
|
/** Validate PerformancePlugin constructor options. @internal */
|
|
@@ -8,7 +8,16 @@ import {
|
|
|
8
8
|
type IEventEmitterEventData,
|
|
9
9
|
type TEventName,
|
|
10
10
|
} from '@robota-sdk/agent-core';
|
|
11
|
+
|
|
12
|
+
import { NodeSystemMetricsCollector } from './collectors/system-metrics-collector';
|
|
11
13
|
import {
|
|
14
|
+
validatePerformanceOptions,
|
|
15
|
+
createPerformanceStorage,
|
|
16
|
+
extractPerformanceModuleData,
|
|
17
|
+
PERFORMANCE_MODULE_EVENT_MAP,
|
|
18
|
+
} from './performance-helpers';
|
|
19
|
+
|
|
20
|
+
import type {
|
|
12
21
|
IPerformanceMetrics,
|
|
13
22
|
IAggregatedPerformanceStats,
|
|
14
23
|
IPerformancePluginOptions,
|
|
@@ -16,13 +25,6 @@ import {
|
|
|
16
25
|
IPerformanceStorage,
|
|
17
26
|
ISystemMetricsCollector,
|
|
18
27
|
} from './types';
|
|
19
|
-
import { NodeSystemMetricsCollector } from './collectors/system-metrics-collector';
|
|
20
|
-
import {
|
|
21
|
-
validatePerformanceOptions,
|
|
22
|
-
createPerformanceStorage,
|
|
23
|
-
extractPerformanceModuleData,
|
|
24
|
-
PERFORMANCE_MODULE_EVENT_MAP,
|
|
25
|
-
} from './performance-helpers';
|
|
26
28
|
|
|
27
29
|
const DEFAULT_MAX_ENTRIES = 5000;
|
|
28
30
|
const DEFAULT_BATCH_SIZE = 100;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
|
+
IPerformanceStorage,
|
|
3
|
+
IPerformanceMetrics,
|
|
4
|
+
IAggregatedPerformanceStats,
|
|
5
|
+
} from '../types';
|
|
2
6
|
|
|
3
7
|
export class MemoryPerformanceStorage implements IPerformanceStorage {
|
|
4
8
|
private entries: IPerformanceMetrics[] = [];
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { IUsageStorage, IUsageStats, IAggregatedUsageStats } from '../types';
|
|
2
1
|
import { createLogger, type ILogger, StorageError } from '@robota-sdk/agent-core';
|
|
2
|
+
|
|
3
3
|
import { aggregateUsageStats } from '../aggregate-usage-stats';
|
|
4
4
|
|
|
5
|
+
import type { IUsageStorage, IUsageStats, IAggregatedUsageStats } from '../types';
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* File storage implementation for usage statistics
|
|
7
9
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { IUsageStorage, IUsageStats, IAggregatedUsageStats } from '../types';
|
|
2
1
|
import { aggregateUsageStats } from '../aggregate-usage-stats';
|
|
3
2
|
|
|
3
|
+
import type { IUsageStorage, IUsageStats, IAggregatedUsageStats } from '../types';
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* Memory storage implementation for usage statistics
|
|
6
7
|
*/
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { IUsageStorage, IUsageStats, IAggregatedUsageStats } from '../types';
|
|
2
1
|
import {
|
|
3
2
|
createLogger,
|
|
4
3
|
type ILogger,
|
|
@@ -7,8 +6,11 @@ import {
|
|
|
7
6
|
startPeriodicTask,
|
|
8
7
|
stopPeriodicTask,
|
|
9
8
|
} from '@robota-sdk/agent-core';
|
|
9
|
+
|
|
10
10
|
import { aggregateUsageStats } from '../aggregate-usage-stats';
|
|
11
11
|
|
|
12
|
+
import type { IUsageStorage, IUsageStats, IAggregatedUsageStats } from '../types';
|
|
13
|
+
|
|
12
14
|
const SAMPLE_SIZE = 3;
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { IUsageStorage, IUsageStats, IAggregatedUsageStats } from '../types';
|
|
2
1
|
import { aggregateUsageStats } from '../aggregate-usage-stats';
|
|
3
2
|
|
|
3
|
+
import type { IUsageStorage, IUsageStats, IAggregatedUsageStats } from '../types';
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* Silent storage implementation for usage statistics (no-op)
|
|
6
7
|
*/
|
|
@@ -11,13 +11,7 @@ import {
|
|
|
11
11
|
type TTimerId,
|
|
12
12
|
startPeriodicTask,
|
|
13
13
|
} from '@robota-sdk/agent-core';
|
|
14
|
-
|
|
15
|
-
IUsageStats,
|
|
16
|
-
IAggregatedUsageStats,
|
|
17
|
-
IUsagePluginOptions,
|
|
18
|
-
IUsagePluginStats,
|
|
19
|
-
IUsageStorage,
|
|
20
|
-
} from './types';
|
|
14
|
+
|
|
21
15
|
import {
|
|
22
16
|
MemoryUsageStorage,
|
|
23
17
|
FileUsageStorage,
|
|
@@ -35,6 +29,14 @@ import {
|
|
|
35
29
|
resolveOperation,
|
|
36
30
|
} from './usage-plugin-helpers';
|
|
37
31
|
|
|
32
|
+
import type {
|
|
33
|
+
IUsageStats,
|
|
34
|
+
IAggregatedUsageStats,
|
|
35
|
+
IUsagePluginOptions,
|
|
36
|
+
IUsagePluginStats,
|
|
37
|
+
IUsageStorage,
|
|
38
|
+
} from './types';
|
|
39
|
+
|
|
38
40
|
const DEFAULT_REMOTE_TIMEOUT_MS = 30000;
|
|
39
41
|
|
|
40
42
|
/**
|
|
@@ -3,12 +3,6 @@
|
|
|
3
3
|
* Converts base plugin types to webhook-specific types safely
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type {
|
|
7
|
-
IPluginExecutionContext,
|
|
8
|
-
IPluginExecutionResult,
|
|
9
|
-
TLoggerData,
|
|
10
|
-
TUniversalValue,
|
|
11
|
-
} from '@robota-sdk/agent-core';
|
|
12
6
|
import type {
|
|
13
7
|
IWebhookExecutionContext,
|
|
14
8
|
IWebhookExecutionResult,
|
|
@@ -20,6 +14,12 @@ import type {
|
|
|
20
14
|
IWebhookToolCallData,
|
|
21
15
|
TWebhookEventName,
|
|
22
16
|
} from './types';
|
|
17
|
+
import type {
|
|
18
|
+
IPluginExecutionContext,
|
|
19
|
+
IPluginExecutionResult,
|
|
20
|
+
TLoggerData,
|
|
21
|
+
TUniversalValue,
|
|
22
|
+
} from '@robota-sdk/agent-core';
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Webhook data transformer utility class
|
package/src/webhook/types.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
IPluginExecutionResult,
|
|
3
|
+
IPluginOptions,
|
|
4
|
+
IPluginStats,
|
|
5
|
+
TExecutionEventName,
|
|
6
|
+
} from '@robota-sdk/agent-core';
|
|
2
7
|
|
|
3
8
|
/**
|
|
4
9
|
* Webhook plugin type definitions
|
|
@@ -109,7 +114,7 @@ export interface IWebhookExecutionResult {
|
|
|
109
114
|
success?: boolean | undefined;
|
|
110
115
|
usage?: { totalTokens?: number | undefined } | undefined;
|
|
111
116
|
// SSOT: reuse the canonical toolCalls shape from IPluginExecutionResult.
|
|
112
|
-
toolCalls?:
|
|
117
|
+
toolCalls?: IPluginExecutionResult['toolCalls'];
|
|
113
118
|
results?:
|
|
114
119
|
| Array<{
|
|
115
120
|
toolName?: string | undefined;
|
|
@@ -148,8 +153,6 @@ export interface IWebhookEndpoint {
|
|
|
148
153
|
secret?: string;
|
|
149
154
|
}
|
|
150
155
|
|
|
151
|
-
import type { IPluginOptions, IPluginStats } from '@robota-sdk/agent-core';
|
|
152
|
-
|
|
153
156
|
/**
|
|
154
157
|
* Webhook plugin configuration options
|
|
155
158
|
*/
|
|
@@ -15,8 +15,8 @@ import {
|
|
|
15
15
|
PluginError,
|
|
16
16
|
} from '@robota-sdk/agent-core';
|
|
17
17
|
|
|
18
|
-
import { WebhookTransformer } from './transformer';
|
|
19
18
|
import { WebhookHttpClient } from './http-client';
|
|
19
|
+
import { WebhookTransformer } from './transformer';
|
|
20
20
|
import {
|
|
21
21
|
validateWebhookEndpoints,
|
|
22
22
|
WEBHOOK_EXEC_EVENTS,
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
WEBHOOK_ERROR_EVENTS,
|
|
26
26
|
} from './webhook-helpers';
|
|
27
27
|
import { WebhookQueueManager } from './webhook-queue';
|
|
28
|
+
|
|
28
29
|
import type {
|
|
29
30
|
TWebhookEventName,
|
|
30
31
|
IWebhookEventData,
|
|
@@ -6,13 +6,14 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { type ILogger, type TTimerId } from '@robota-sdk/agent-core';
|
|
9
|
+
|
|
10
|
+
import type { WebhookHttpClient } from './http-client';
|
|
9
11
|
import type {
|
|
10
12
|
TWebhookEventName,
|
|
11
13
|
IWebhookPayload,
|
|
12
14
|
IWebhookEndpoint,
|
|
13
15
|
IWebhookRequest,
|
|
14
16
|
} from './types';
|
|
15
|
-
import { WebhookHttpClient } from './http-client';
|
|
16
17
|
|
|
17
18
|
/** Manages the async request queue, batch queue, and concurrency for WebhookPlugin. @internal */
|
|
18
19
|
export class WebhookQueueManager {
|