@sowonai/crewx-sdk 0.1.0-dev.1 → 0.1.0-dev.3
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 +335 -6
- package/dist/config/yaml-loader.d.ts +8 -0
- package/dist/config/yaml-loader.js +137 -0
- package/dist/config/yaml-loader.js.map +1 -0
- package/dist/core/agent/agent-factory.d.ts +1 -1
- package/dist/core/agent/agent-factory.js +4 -6
- package/dist/core/agent/agent-factory.js.map +1 -1
- package/dist/core/agent/index.d.ts +1 -1
- package/dist/core/agent/index.js +2 -1
- package/dist/core/agent/index.js.map +1 -1
- package/dist/core/parallel/helpers.d.ts +27 -0
- package/dist/core/parallel/helpers.js +252 -0
- package/dist/core/parallel/helpers.js.map +1 -0
- package/dist/core/parallel/index.d.ts +2 -0
- package/dist/core/parallel/index.js +4 -1
- package/dist/core/parallel/index.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/types/structured-payload.types.d.ts +46 -0
- package/dist/types/structured-payload.types.js +65 -0
- package/dist/types/structured-payload.types.js.map +1 -0
- package/dist/utils/base-message-formatter.d.ts +1 -1
- package/dist/utils/base-message-formatter.js.map +1 -1
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -439,7 +439,113 @@ The SDK provides reusable components that were previously CLI-only. These abstra
|
|
|
439
439
|
|
|
440
440
|
### Message Formatting (Phase 1)
|
|
441
441
|
|
|
442
|
-
|
|
442
|
+
The SDK provides a flexible message formatting system that supports multiple platforms (Slack, Terminal, API, etc.) and allows custom formatters.
|
|
443
|
+
|
|
444
|
+
#### Platform-Specific Formatters
|
|
445
|
+
|
|
446
|
+
**Terminal Formatter (Built-in)**
|
|
447
|
+
|
|
448
|
+
```typescript
|
|
449
|
+
import { BaseMessageFormatter, type StructuredMessage } from '@sowonai/crewx-sdk';
|
|
450
|
+
|
|
451
|
+
const formatter = new BaseMessageFormatter();
|
|
452
|
+
|
|
453
|
+
// Format messages for terminal display
|
|
454
|
+
const history = formatter.formatHistory(messages, {
|
|
455
|
+
includeUserId: true,
|
|
456
|
+
includeTimestamp: true,
|
|
457
|
+
timestampFormat: 'iso', // 'iso' | 'relative' | 'unix'
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
console.log(history);
|
|
461
|
+
// Output:
|
|
462
|
+
// [2025-10-17T10:00:00Z] user123: Hello!
|
|
463
|
+
// [2025-10-17T10:00:05Z] assistant: How can I help?
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
**Slack Formatter (Built-in)**
|
|
467
|
+
|
|
468
|
+
For Slack bot integrations, use the Slack-specific formatter that handles threading, mentions, and rich formatting:
|
|
469
|
+
|
|
470
|
+
```typescript
|
|
471
|
+
import { SlackMessageFormatter } from '@sowonai/crewx-sdk';
|
|
472
|
+
|
|
473
|
+
const slackFormatter = new SlackMessageFormatter();
|
|
474
|
+
|
|
475
|
+
// Format for Slack with rich text support
|
|
476
|
+
const formatted = slackFormatter.formatForSlack(messages, {
|
|
477
|
+
includeTimestamp: true,
|
|
478
|
+
useThreading: true,
|
|
479
|
+
preserveMentions: true,
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
// Format agent response with Slack-specific blocks
|
|
483
|
+
const response = slackFormatter.formatAgentResponse({
|
|
484
|
+
content: 'Task completed successfully!',
|
|
485
|
+
agentId: 'backend',
|
|
486
|
+
metadata: { status: 'success' }
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
// Send to Slack
|
|
490
|
+
await slackClient.chat.postMessage({
|
|
491
|
+
channel: channelId,
|
|
492
|
+
blocks: response.blocks,
|
|
493
|
+
thread_ts: threadId,
|
|
494
|
+
});
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
**API/JSON Formatter**
|
|
498
|
+
|
|
499
|
+
For API responses or structured data:
|
|
500
|
+
|
|
501
|
+
```typescript
|
|
502
|
+
import {
|
|
503
|
+
BaseMessageFormatter,
|
|
504
|
+
type StructuredMessage,
|
|
505
|
+
type ConversationMetadata
|
|
506
|
+
} from '@sowonai/crewx-sdk';
|
|
507
|
+
|
|
508
|
+
class APIFormatter extends BaseMessageFormatter {
|
|
509
|
+
formatForAPI(messages: StructuredMessage[]): {
|
|
510
|
+
messages: Array<{
|
|
511
|
+
id: string;
|
|
512
|
+
author: { id: string; isBot: boolean };
|
|
513
|
+
content: string;
|
|
514
|
+
timestamp: string;
|
|
515
|
+
metadata?: Record<string, unknown>;
|
|
516
|
+
}>;
|
|
517
|
+
meta: ConversationMetadata;
|
|
518
|
+
} {
|
|
519
|
+
return {
|
|
520
|
+
messages: messages.map(msg => ({
|
|
521
|
+
id: msg.id,
|
|
522
|
+
author: {
|
|
523
|
+
id: msg.userId || 'unknown',
|
|
524
|
+
isBot: msg.isAssistant || false,
|
|
525
|
+
},
|
|
526
|
+
content: msg.text,
|
|
527
|
+
timestamp: msg.timestamp,
|
|
528
|
+
metadata: msg.metadata,
|
|
529
|
+
})),
|
|
530
|
+
meta: {
|
|
531
|
+
platform: 'api',
|
|
532
|
+
totalMessages: messages.length,
|
|
533
|
+
generatedAt: new Date().toISOString(),
|
|
534
|
+
},
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
const apiFormatter = new APIFormatter();
|
|
540
|
+
const response = apiFormatter.formatForAPI(messages);
|
|
541
|
+
|
|
542
|
+
// Return as JSON API response
|
|
543
|
+
res.json(response);
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
#### Custom Formatter Extension
|
|
547
|
+
|
|
548
|
+
Create your own formatter for custom platforms:
|
|
443
549
|
|
|
444
550
|
```typescript
|
|
445
551
|
import {
|
|
@@ -448,20 +554,243 @@ import {
|
|
|
448
554
|
FormatterOptions
|
|
449
555
|
} from '@sowonai/crewx-sdk';
|
|
450
556
|
|
|
451
|
-
class
|
|
557
|
+
class DiscordFormatter extends BaseMessageFormatter {
|
|
452
558
|
formatMessage(msg: StructuredMessage, options: FormatterOptions): string {
|
|
453
|
-
|
|
454
|
-
|
|
559
|
+
const timestamp = options.includeTimestamp
|
|
560
|
+
? `<t:${Math.floor(new Date(msg.timestamp).getTime() / 1000)}:R> `
|
|
561
|
+
: '';
|
|
562
|
+
|
|
563
|
+
const author = msg.isAssistant ? '🤖 **Bot**' : `👤 **${msg.userId}**`;
|
|
564
|
+
|
|
565
|
+
return `${timestamp}${author}: ${msg.text}`;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
formatForDiscordEmbed(
|
|
569
|
+
message: string,
|
|
570
|
+
options: { color?: number; title?: string }
|
|
571
|
+
) {
|
|
572
|
+
return {
|
|
573
|
+
embeds: [{
|
|
574
|
+
title: options.title || 'Agent Response',
|
|
575
|
+
description: message,
|
|
576
|
+
color: options.color || 0x5865F2,
|
|
577
|
+
timestamp: new Date().toISOString(),
|
|
578
|
+
}],
|
|
579
|
+
};
|
|
455
580
|
}
|
|
456
581
|
}
|
|
457
582
|
|
|
458
|
-
const
|
|
459
|
-
const
|
|
583
|
+
const discordFormatter = new DiscordFormatter();
|
|
584
|
+
const embed = discordFormatter.formatForDiscordEmbed(
|
|
585
|
+
'Analysis complete!',
|
|
586
|
+
{ title: 'Backend Agent', color: 0x00FF00 }
|
|
587
|
+
);
|
|
588
|
+
|
|
589
|
+
await discordChannel.send(embed);
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
#### Metadata Handling
|
|
593
|
+
|
|
594
|
+
The formatter system supports rich metadata for enhanced context:
|
|
595
|
+
|
|
596
|
+
```typescript
|
|
597
|
+
import {
|
|
598
|
+
BaseMessageFormatter,
|
|
599
|
+
type StructuredMessage,
|
|
600
|
+
type ConversationMetadata
|
|
601
|
+
} from '@sowonai/crewx-sdk';
|
|
602
|
+
|
|
603
|
+
const messages: StructuredMessage[] = [
|
|
604
|
+
{
|
|
605
|
+
id: 'msg-1',
|
|
606
|
+
userId: 'user123',
|
|
607
|
+
text: 'What is the status?',
|
|
608
|
+
timestamp: new Date().toISOString(),
|
|
609
|
+
isAssistant: false,
|
|
610
|
+
metadata: {
|
|
611
|
+
platform: 'slack',
|
|
612
|
+
channelId: 'C123456',
|
|
613
|
+
threadTs: '1234567890.123456',
|
|
614
|
+
userAgent: 'SlackBot/1.0',
|
|
615
|
+
},
|
|
616
|
+
},
|
|
617
|
+
{
|
|
618
|
+
id: 'msg-2',
|
|
619
|
+
userId: 'backend-agent',
|
|
620
|
+
text: 'All systems operational.',
|
|
621
|
+
timestamp: new Date().toISOString(),
|
|
622
|
+
isAssistant: true,
|
|
623
|
+
metadata: {
|
|
624
|
+
agentId: 'backend',
|
|
625
|
+
model: 'claude-3-5-sonnet',
|
|
626
|
+
processingTime: 1234,
|
|
627
|
+
tokenUsage: { input: 50, output: 100 },
|
|
628
|
+
},
|
|
629
|
+
},
|
|
630
|
+
];
|
|
631
|
+
|
|
632
|
+
const formatter = new BaseMessageFormatter();
|
|
633
|
+
|
|
634
|
+
// Format with metadata extraction
|
|
635
|
+
const formatted = formatter.formatHistory(messages, {
|
|
636
|
+
includeUserId: true,
|
|
637
|
+
includeTimestamp: true,
|
|
638
|
+
extractMetadata: true,
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
// Access metadata
|
|
642
|
+
messages.forEach(msg => {
|
|
643
|
+
if (msg.metadata?.tokenUsage) {
|
|
644
|
+
console.log(`Tokens used: ${msg.metadata.tokenUsage.input + msg.metadata.tokenUsage.output}`);
|
|
645
|
+
}
|
|
646
|
+
});
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
#### Migration Guide for Existing Formatter Users
|
|
650
|
+
|
|
651
|
+
If you're migrating from the CLI's internal formatter to the SDK formatter:
|
|
652
|
+
|
|
653
|
+
**Before (CLI internal)**
|
|
654
|
+
```typescript
|
|
655
|
+
// This was CLI-only code
|
|
656
|
+
import { MessageFormatter } from '../cli/src/utils/message-formatter';
|
|
657
|
+
|
|
658
|
+
const formatter = new MessageFormatter();
|
|
659
|
+
const result = formatter.format(messages);
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
**After (SDK)**
|
|
663
|
+
```typescript
|
|
664
|
+
// Now use SDK's BaseMessageFormatter
|
|
665
|
+
import { BaseMessageFormatter } from '@sowonai/crewx-sdk';
|
|
666
|
+
|
|
667
|
+
const formatter = new BaseMessageFormatter();
|
|
668
|
+
const result = formatter.formatHistory(messages, {
|
|
460
669
|
includeUserId: true,
|
|
461
670
|
includeTimestamp: true,
|
|
462
671
|
});
|
|
463
672
|
```
|
|
464
673
|
|
|
674
|
+
**Key Changes:**
|
|
675
|
+
1. Import from `@sowonai/crewx-sdk` instead of CLI internals
|
|
676
|
+
2. Use `formatHistory()` method instead of `format()`
|
|
677
|
+
3. Options are now explicitly passed as second parameter
|
|
678
|
+
4. Metadata handling is built-in with `extractMetadata` option
|
|
679
|
+
|
|
680
|
+
**Slack Migration**
|
|
681
|
+
```typescript
|
|
682
|
+
// Before (CLI)
|
|
683
|
+
import { SlackFormatter } from '../cli/src/slack/formatter';
|
|
684
|
+
|
|
685
|
+
// After (SDK)
|
|
686
|
+
import { SlackMessageFormatter } from '@sowonai/crewx-sdk';
|
|
687
|
+
|
|
688
|
+
const formatter = new SlackMessageFormatter();
|
|
689
|
+
// Same API, now available in SDK
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
#### CLI Developer Guide: Adding Slack Formatting
|
|
693
|
+
|
|
694
|
+
If you're building a CLI tool and want to add Slack formatting support:
|
|
695
|
+
|
|
696
|
+
**Step 1: Install SDK**
|
|
697
|
+
```bash
|
|
698
|
+
npm install @sowonai/crewx-sdk
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
**Step 2: Import Slack Formatter**
|
|
702
|
+
```typescript
|
|
703
|
+
import { SlackMessageFormatter } from '@sowonai/crewx-sdk';
|
|
704
|
+
import { WebClient } from '@slack/web-api';
|
|
705
|
+
|
|
706
|
+
const slackClient = new WebClient(process.env.SLACK_BOT_TOKEN);
|
|
707
|
+
const formatter = new SlackMessageFormatter();
|
|
708
|
+
```
|
|
709
|
+
|
|
710
|
+
**Step 3: Format Messages for Slack**
|
|
711
|
+
```typescript
|
|
712
|
+
async function sendToSlack(
|
|
713
|
+
channelId: string,
|
|
714
|
+
content: string,
|
|
715
|
+
threadTs?: string
|
|
716
|
+
) {
|
|
717
|
+
// Format using SDK formatter
|
|
718
|
+
const formatted = formatter.formatAgentResponse({
|
|
719
|
+
content,
|
|
720
|
+
agentId: 'my-cli-agent',
|
|
721
|
+
metadata: {
|
|
722
|
+
source: 'cli',
|
|
723
|
+
timestamp: new Date().toISOString(),
|
|
724
|
+
},
|
|
725
|
+
});
|
|
726
|
+
|
|
727
|
+
// Send to Slack
|
|
728
|
+
await slackClient.chat.postMessage({
|
|
729
|
+
channel: channelId,
|
|
730
|
+
text: content, // Fallback text
|
|
731
|
+
blocks: formatted.blocks,
|
|
732
|
+
thread_ts: threadTs,
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
**Step 4: Handle Conversation History**
|
|
738
|
+
```typescript
|
|
739
|
+
import {
|
|
740
|
+
SlackMessageFormatter,
|
|
741
|
+
type StructuredMessage
|
|
742
|
+
} from '@sowonai/crewx-sdk';
|
|
743
|
+
|
|
744
|
+
async function formatSlackThread(threadTs: string) {
|
|
745
|
+
// Fetch Slack thread
|
|
746
|
+
const thread = await slackClient.conversations.replies({
|
|
747
|
+
channel: channelId,
|
|
748
|
+
ts: threadTs,
|
|
749
|
+
});
|
|
750
|
+
|
|
751
|
+
// Convert to StructuredMessage format
|
|
752
|
+
const messages: StructuredMessage[] = thread.messages.map(msg => ({
|
|
753
|
+
id: msg.ts,
|
|
754
|
+
userId: msg.user || 'bot',
|
|
755
|
+
text: msg.text || '',
|
|
756
|
+
timestamp: new Date(parseFloat(msg.ts) * 1000).toISOString(),
|
|
757
|
+
isAssistant: !!msg.bot_id,
|
|
758
|
+
metadata: {
|
|
759
|
+
platform: 'slack',
|
|
760
|
+
threadTs: msg.thread_ts,
|
|
761
|
+
},
|
|
762
|
+
}));
|
|
763
|
+
|
|
764
|
+
// Format for display or processing
|
|
765
|
+
const formatter = new SlackMessageFormatter();
|
|
766
|
+
const formatted = formatter.formatHistory(messages, {
|
|
767
|
+
includeTimestamp: true,
|
|
768
|
+
useThreading: true,
|
|
769
|
+
});
|
|
770
|
+
|
|
771
|
+
return formatted;
|
|
772
|
+
}
|
|
773
|
+
```
|
|
774
|
+
|
|
775
|
+
**Step 5: Error Handling**
|
|
776
|
+
```typescript
|
|
777
|
+
try {
|
|
778
|
+
await sendToSlack(channelId, 'Task completed!', threadTs);
|
|
779
|
+
} catch (error) {
|
|
780
|
+
// Format error for Slack
|
|
781
|
+
const errorMessage = formatter.formatAgentResponse({
|
|
782
|
+
content: `❌ Error: ${error.message}`,
|
|
783
|
+
agentId: 'cli-agent',
|
|
784
|
+
metadata: { status: 'error' },
|
|
785
|
+
});
|
|
786
|
+
|
|
787
|
+
await slackClient.chat.postMessage({
|
|
788
|
+
channel: channelId,
|
|
789
|
+
blocks: errorMessage.blocks,
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
```
|
|
793
|
+
|
|
465
794
|
### AI Providers (Phase 2)
|
|
466
795
|
|
|
467
796
|
Use built-in providers or create custom ones:
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CrewxAgentConfig } from '../core/agent/agent-factory';
|
|
2
|
+
export declare class YamlConfigError extends Error {
|
|
3
|
+
readonly cause?: Error | undefined;
|
|
4
|
+
constructor(message: string, cause?: Error | undefined);
|
|
5
|
+
}
|
|
6
|
+
export declare function loadAgentConfigFromYaml(yamlString: string): CrewxAgentConfig;
|
|
7
|
+
export declare function loadAgentConfigFromFile(filePath: string): CrewxAgentConfig;
|
|
8
|
+
export declare function validateAgentConfig(config: CrewxAgentConfig): boolean;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.YamlConfigError = void 0;
|
|
4
|
+
exports.loadAgentConfigFromYaml = loadAgentConfigFromYaml;
|
|
5
|
+
exports.loadAgentConfigFromFile = loadAgentConfigFromFile;
|
|
6
|
+
exports.validateAgentConfig = validateAgentConfig;
|
|
7
|
+
const js_yaml_1 = require("js-yaml");
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
class YamlConfigError extends Error {
|
|
10
|
+
constructor(message, cause) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.cause = cause;
|
|
13
|
+
this.name = 'YamlConfigError';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.YamlConfigError = YamlConfigError;
|
|
17
|
+
function loadAgentConfigFromYaml(yamlString) {
|
|
18
|
+
if (!yamlString || typeof yamlString !== 'string') {
|
|
19
|
+
throw new YamlConfigError('YAML string is required and must be a non-empty string');
|
|
20
|
+
}
|
|
21
|
+
let parsed;
|
|
22
|
+
try {
|
|
23
|
+
const trimmed = yamlString.trim();
|
|
24
|
+
parsed = (0, js_yaml_1.load)(trimmed);
|
|
25
|
+
if (process.env.DEBUG_YAML === '1') {
|
|
26
|
+
console.log('[YAML DEBUG] Input length:', yamlString.length);
|
|
27
|
+
console.log('[YAML DEBUG] Trimmed length:', trimmed.length);
|
|
28
|
+
console.log('[YAML DEBUG] Parsed:', JSON.stringify(parsed));
|
|
29
|
+
console.log('[YAML DEBUG] Type:', typeof parsed);
|
|
30
|
+
console.log('[YAML DEBUG] Is null:', parsed === null);
|
|
31
|
+
console.log('[YAML DEBUG] Is array:', Array.isArray(parsed));
|
|
32
|
+
console.log('[YAML DEBUG] Truthy check:', !parsed);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
throw new YamlConfigError(`Failed to parse YAML: ${error instanceof Error ? error.message : 'Unknown error'}`, error instanceof Error ? error : undefined);
|
|
37
|
+
}
|
|
38
|
+
if (parsed === null || parsed === undefined || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
39
|
+
throw new YamlConfigError('YAML must contain a valid object structure');
|
|
40
|
+
}
|
|
41
|
+
return parseYamlConfig(parsed);
|
|
42
|
+
}
|
|
43
|
+
function loadAgentConfigFromFile(filePath) {
|
|
44
|
+
if (!filePath || typeof filePath !== 'string') {
|
|
45
|
+
throw new YamlConfigError('File path is required and must be a non-empty string');
|
|
46
|
+
}
|
|
47
|
+
let fileContent;
|
|
48
|
+
try {
|
|
49
|
+
fileContent = (0, fs_1.readFileSync)(filePath, 'utf-8');
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
throw new YamlConfigError(`Failed to read YAML file '${filePath}': ${error instanceof Error ? error.message : 'Unknown error'}`, error instanceof Error ? error : undefined);
|
|
53
|
+
}
|
|
54
|
+
return loadAgentConfigFromYaml(fileContent);
|
|
55
|
+
}
|
|
56
|
+
function parseYamlConfig(raw) {
|
|
57
|
+
const config = {};
|
|
58
|
+
if (raw.agents && typeof raw.agents === 'object') {
|
|
59
|
+
const agentIds = Object.keys(raw.agents);
|
|
60
|
+
if (agentIds.length > 0) {
|
|
61
|
+
const firstAgentId = agentIds[0];
|
|
62
|
+
const agentConfig = raw.agents[firstAgentId];
|
|
63
|
+
if (agentConfig) {
|
|
64
|
+
config.defaultAgentId = firstAgentId;
|
|
65
|
+
if (agentConfig.provider) {
|
|
66
|
+
config.provider = parseProvider(agentConfig.provider, agentConfig.inline);
|
|
67
|
+
}
|
|
68
|
+
if (agentConfig.knowledgeBase) {
|
|
69
|
+
config.knowledgeBase = parseKnowledgeBase(agentConfig.knowledgeBase);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (raw.defaults && typeof raw.defaults === 'object') {
|
|
75
|
+
if (raw.defaults.provider && !config.provider) {
|
|
76
|
+
config.provider = parseProvider(raw.defaults.provider);
|
|
77
|
+
}
|
|
78
|
+
if (raw.defaults.knowledgeBase && !config.knowledgeBase) {
|
|
79
|
+
config.knowledgeBase = parseKnowledgeBase(raw.defaults.knowledgeBase);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return config;
|
|
83
|
+
}
|
|
84
|
+
function parseProvider(providerString, inline) {
|
|
85
|
+
if (!providerString || typeof providerString !== 'string') {
|
|
86
|
+
throw new YamlConfigError('Provider must be a non-empty string');
|
|
87
|
+
}
|
|
88
|
+
const parts = providerString.split('/');
|
|
89
|
+
if (parts.length !== 2) {
|
|
90
|
+
throw new YamlConfigError(`Invalid provider format '${providerString}'. Expected format: 'namespace/id' (e.g., 'cli/claude')`);
|
|
91
|
+
}
|
|
92
|
+
const [namespace, id] = parts;
|
|
93
|
+
if (!namespace || !id) {
|
|
94
|
+
throw new YamlConfigError(`Provider namespace and id cannot be empty. Got: '${providerString}'`);
|
|
95
|
+
}
|
|
96
|
+
const config = {
|
|
97
|
+
namespace,
|
|
98
|
+
id,
|
|
99
|
+
};
|
|
100
|
+
if (inline && typeof inline === 'object') {
|
|
101
|
+
if (inline.model && typeof inline.model === 'string') {
|
|
102
|
+
config.model = inline.model;
|
|
103
|
+
}
|
|
104
|
+
if (inline.apiKey && typeof inline.apiKey === 'string') {
|
|
105
|
+
config.apiKey = inline.apiKey;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return config;
|
|
109
|
+
}
|
|
110
|
+
function parseKnowledgeBase(value) {
|
|
111
|
+
if (typeof value === 'string') {
|
|
112
|
+
return { path: value };
|
|
113
|
+
}
|
|
114
|
+
if (Array.isArray(value)) {
|
|
115
|
+
return { sources: value.filter((s) => typeof s === 'string') };
|
|
116
|
+
}
|
|
117
|
+
throw new YamlConfigError('Knowledge base must be a string (path) or array of strings (sources)');
|
|
118
|
+
}
|
|
119
|
+
function validateAgentConfig(config) {
|
|
120
|
+
if (!config || typeof config !== 'object') {
|
|
121
|
+
throw new YamlConfigError('Configuration must be a valid object');
|
|
122
|
+
}
|
|
123
|
+
if (config.provider) {
|
|
124
|
+
if (!config.provider.namespace || !config.provider.id) {
|
|
125
|
+
throw new YamlConfigError('Provider must have both namespace and id');
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (config.knowledgeBase) {
|
|
129
|
+
const hasPath = config.knowledgeBase.path && typeof config.knowledgeBase.path === 'string';
|
|
130
|
+
const hasSources = Array.isArray(config.knowledgeBase.sources) && config.knowledgeBase.sources.length > 0;
|
|
131
|
+
if (!hasPath && !hasSources) {
|
|
132
|
+
throw new YamlConfigError('Knowledge base must have either path or sources');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=yaml-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml-loader.js","sourceRoot":"","sources":["../../src/config/yaml-loader.ts"],"names":[],"mappings":";;;AAgEA,0DAiCC;AAcD,0DAiBC;AAkHD,kDAuBC;AAlQD,qCAA2C;AAC3C,2BAAkC;AAMlC,MAAa,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe,EAAkB,KAAa;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QAD4B,UAAK,GAAL,KAAK,CAAQ;QAExD,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AALD,0CAKC;AA6CD,SAAgB,uBAAuB,CAAC,UAAkB;IACxD,IAAI,CAAC,UAAU,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;QAClD,MAAM,IAAI,eAAe,CAAC,wDAAwD,CAAC,CAAC;IACtF,CAAC;IAED,IAAI,MAAW,CAAC;IAEhB,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC;QAClC,MAAM,GAAG,IAAA,cAAQ,EAAC,OAAO,CAAC,CAAC;QAG3B,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,KAAK,GAAG,EAAE,CAAC;YACnC,OAAO,CAAC,GAAG,CAAC,4BAA4B,EAAE,UAAU,CAAC,MA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C;QAC3F,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QAE1G,IAAI,CAAC,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;YAC5B,MAAM,IAAI,eAAe,CAAC,iDAAiD,CAAC,CAAC;QAC/E,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -27,4 +27,4 @@ export interface CrewxAgentResult {
|
|
|
27
27
|
eventBus: EventBus;
|
|
28
28
|
}
|
|
29
29
|
export declare function createCrewxAgent(config?: CrewxAgentConfig): Promise<CrewxAgentResult>;
|
|
30
|
-
export
|
|
30
|
+
export { loadAgentConfigFromYaml, loadAgentConfigFromFile } from '../../config/yaml-loader';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadAgentConfigFromFile = exports.loadAgentConfigFromYaml = void 0;
|
|
3
4
|
exports.createCrewxAgent = createCrewxAgent;
|
|
4
|
-
exports.loadAgentConfigFromYaml = loadAgentConfigFromYaml;
|
|
5
5
|
const agent_runtime_1 = require("./agent-runtime");
|
|
6
6
|
const event_bus_1 = require("./event-bus");
|
|
7
7
|
async function createCrewxAgent(config = {}) {
|
|
@@ -23,9 +23,7 @@ async function createCrewxAgent(config = {}) {
|
|
|
23
23
|
eventBus,
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
}
|
|
26
|
+
var yaml_loader_1 = require("../../config/yaml-loader");
|
|
27
|
+
Object.defineProperty(exports, "loadAgentConfigFromYaml", { enumerable: true, get: function () { return yaml_loader_1.loadAgentConfigFromYaml; } });
|
|
28
|
+
Object.defineProperty(exports, "loadAgentConfigFromFile", { enumerable: true, get: function () { return yaml_loader_1.loadAgentConfigFromFile; } });
|
|
31
29
|
//# sourceMappingURL=agent-factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-factory.js","sourceRoot":"","sources":["../../../src/core/agent/agent-factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agent-factory.js","sourceRoot":"","sources":["../../../src/core/agent/agent-factory.ts"],"names":[],"mappings":";;;AAoFA,4CA6BC;AA5GD,mDAAoE;AACpE,2CAAsD;AA8E/C,KAAK,UAAU,gBAAgB,CACpC,SAA2B,EAAE;IAG7B,MAAM,QAAQ,GAAG,IAAI,oBAAQ,EAAE,CAAC;IAGhC,MAAM,cAAc,GAAwB;QAC1C,QAAQ;QACR,eAAe,EAAE,MAAM,CAAC,eAAe,IAAI,KAAK;QAChD,cAAc,EAAE,MAAM,CAAC,cAAc,IAAI,OAAO;KACjD,CAAC;IAGF,MAAM,OAAO,GAAG,IAAI,4BAAY,CAAC,cAAc,CAAC,CAAC;IAGjD,MAAM,KAAK,GAAe;QACxB,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;QAClC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;QACtC,YAAY,EAAE,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC;KACjD,CAAC;IAGF,OAAO;QACL,KAAK;QACL,OAAO,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC;QAClE,QAAQ;KACT,CAAC;AACJ,CAAC;AAQD,wDAA4F;AAAnF,sHAAA,uBAAuB,OAAA;AAAE,sHAAA,uBAAuB,OAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { createCrewxAgent, loadAgentConfigFromYaml, type CrewxAgent, type CrewxAgentConfig, type CrewxAgentResult, type ProviderConfig, type KnowledgeBaseConfig, } from './agent-factory';
|
|
1
|
+
export { createCrewxAgent, loadAgentConfigFromYaml, loadAgentConfigFromFile, type CrewxAgent, type CrewxAgentConfig, type CrewxAgentResult, type ProviderConfig, type KnowledgeBaseConfig, } from './agent-factory';
|
|
2
2
|
export { AgentRuntime, type AgentQueryRequest, type AgentExecuteRequest, type AgentResult, type AgentRuntimeOptions, } from './agent-runtime';
|
|
3
3
|
export { EventBus, type EventListener, type CallStackFrame, type AgentEvent, } from './event-bus';
|
package/dist/core/agent/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EventBus = exports.AgentRuntime = exports.loadAgentConfigFromYaml = exports.createCrewxAgent = void 0;
|
|
3
|
+
exports.EventBus = exports.AgentRuntime = exports.loadAgentConfigFromFile = exports.loadAgentConfigFromYaml = exports.createCrewxAgent = void 0;
|
|
4
4
|
var agent_factory_1 = require("./agent-factory");
|
|
5
5
|
Object.defineProperty(exports, "createCrewxAgent", { enumerable: true, get: function () { return agent_factory_1.createCrewxAgent; } });
|
|
6
6
|
Object.defineProperty(exports, "loadAgentConfigFromYaml", { enumerable: true, get: function () { return agent_factory_1.loadAgentConfigFromYaml; } });
|
|
7
|
+
Object.defineProperty(exports, "loadAgentConfigFromFile", { enumerable: true, get: function () { return agent_factory_1.loadAgentConfigFromFile; } });
|
|
7
8
|
var agent_runtime_1 = require("./agent-runtime");
|
|
8
9
|
Object.defineProperty(exports, "AgentRuntime", { enumerable: true, get: function () { return agent_runtime_1.AgentRuntime; } });
|
|
9
10
|
var event_bus_1 = require("./event-bus");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/agent/index.ts"],"names":[],"mappings":";;;AAIA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/agent/index.ts"],"names":[],"mappings":";;;AAIA,iDASyB;AARvB,iHAAA,gBAAgB,OAAA;AAChB,wHAAA,uBAAuB,OAAA;AACvB,wHAAA,uBAAuB,OAAA;AAQzB,iDAMyB;AALvB,6GAAA,YAAY,OAAA;AAOd,yCAKqB;AAJnB,qGAAA,QAAQ,OAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ParallelRunnerMetrics } from './types';
|
|
2
|
+
import { type AgentQueryRequest, type AgentExecuteRequest, type AgentResult } from '../agent';
|
|
3
|
+
export interface RetryPolicy {
|
|
4
|
+
maxRetries: number;
|
|
5
|
+
retryDelay: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ParallelConfig {
|
|
8
|
+
concurrency?: number;
|
|
9
|
+
timeout?: number;
|
|
10
|
+
retryPolicy?: RetryPolicy;
|
|
11
|
+
onProgress?: (completed: number, total: number) => void;
|
|
12
|
+
onComplete?: (result: HelperResult<AgentResult>) => void;
|
|
13
|
+
}
|
|
14
|
+
export interface HelperResult<T = AgentResult> {
|
|
15
|
+
total: number;
|
|
16
|
+
completed: number;
|
|
17
|
+
successCount: number;
|
|
18
|
+
failureCount: number;
|
|
19
|
+
results: T[];
|
|
20
|
+
errors: Array<{
|
|
21
|
+
index: number;
|
|
22
|
+
error: Error;
|
|
23
|
+
}>;
|
|
24
|
+
metrics: ParallelRunnerMetrics;
|
|
25
|
+
}
|
|
26
|
+
export declare const runQueriesParallel: (queries: AgentQueryRequest[], config?: ParallelConfig) => Promise<AgentResult[]>;
|
|
27
|
+
export declare const runExecutesParallel: (requests: AgentExecuteRequest[], config?: ParallelConfig) => Promise<AgentResult[]>;
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runExecutesParallel = exports.runQueriesParallel = void 0;
|
|
4
|
+
const parallel_runner_1 = require("./parallel-runner");
|
|
5
|
+
const agent_1 = require("../agent");
|
|
6
|
+
const DEFAULT_CONCURRENCY = 3;
|
|
7
|
+
const DEFAULT_TIMEOUT_MS = 30000;
|
|
8
|
+
const DEFAULT_RETRY_DELAY_MS = 500;
|
|
9
|
+
const normalizeConcurrency = (value) => {
|
|
10
|
+
if (typeof value !== 'number' || Number.isNaN(value) || !Number.isFinite(value)) {
|
|
11
|
+
return DEFAULT_CONCURRENCY;
|
|
12
|
+
}
|
|
13
|
+
const normalized = Math.floor(value);
|
|
14
|
+
return normalized > 0 ? normalized : DEFAULT_CONCURRENCY;
|
|
15
|
+
};
|
|
16
|
+
const normalizeTimeout = (value) => {
|
|
17
|
+
if (value === undefined) {
|
|
18
|
+
return DEFAULT_TIMEOUT_MS;
|
|
19
|
+
}
|
|
20
|
+
if (typeof value !== 'number' || Number.isNaN(value) || value <= 0) {
|
|
21
|
+
return DEFAULT_TIMEOUT_MS;
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
};
|
|
25
|
+
const normalizeRetryPolicy = (policy) => {
|
|
26
|
+
if (!policy) {
|
|
27
|
+
return { maxRetries: 0, retryDelay: DEFAULT_RETRY_DELAY_MS };
|
|
28
|
+
}
|
|
29
|
+
const maxRetries = Number.isInteger(policy.maxRetries) && policy.maxRetries >= 0
|
|
30
|
+
? policy.maxRetries
|
|
31
|
+
: 0;
|
|
32
|
+
const retryDelay = typeof policy.retryDelay === 'number' && policy.retryDelay >= 0
|
|
33
|
+
? policy.retryDelay
|
|
34
|
+
: DEFAULT_RETRY_DELAY_MS;
|
|
35
|
+
return { maxRetries, retryDelay };
|
|
36
|
+
};
|
|
37
|
+
const createAbortError = (signal) => {
|
|
38
|
+
const reason = signal.reason;
|
|
39
|
+
if (reason instanceof Error) {
|
|
40
|
+
return reason;
|
|
41
|
+
}
|
|
42
|
+
if (typeof reason === 'string') {
|
|
43
|
+
return new Error(reason);
|
|
44
|
+
}
|
|
45
|
+
return new Error('Parallel operation aborted');
|
|
46
|
+
};
|
|
47
|
+
const waitForDelay = (delayMs, signal) => {
|
|
48
|
+
if (delayMs <= 0) {
|
|
49
|
+
return Promise.resolve();
|
|
50
|
+
}
|
|
51
|
+
return new Promise((resolve, reject) => {
|
|
52
|
+
const timer = setTimeout(() => {
|
|
53
|
+
signal.removeEventListener('abort', onAbort);
|
|
54
|
+
resolve();
|
|
55
|
+
}, delayMs);
|
|
56
|
+
const onAbort = () => {
|
|
57
|
+
clearTimeout(timer);
|
|
58
|
+
reject(createAbortError(signal));
|
|
59
|
+
};
|
|
60
|
+
if (signal.aborted) {
|
|
61
|
+
onAbort();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
const executeWithRetry = async (execute, retryPolicy, signal) => {
|
|
68
|
+
let lastFailureResult;
|
|
69
|
+
let lastError;
|
|
70
|
+
for (let attempt = 0; attempt <= retryPolicy.maxRetries; attempt += 1) {
|
|
71
|
+
if (signal.aborted) {
|
|
72
|
+
throw createAbortError(signal);
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const result = await execute();
|
|
76
|
+
lastFailureResult = result;
|
|
77
|
+
if (result.success || attempt === retryPolicy.maxRetries) {
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
lastError = error;
|
|
83
|
+
if (signal.aborted) {
|
|
84
|
+
throw createAbortError(signal);
|
|
85
|
+
}
|
|
86
|
+
if (attempt === retryPolicy.maxRetries) {
|
|
87
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
88
|
+
throw normalizedError;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (attempt < retryPolicy.maxRetries) {
|
|
92
|
+
await waitForDelay(retryPolicy.retryDelay, signal);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (lastFailureResult) {
|
|
96
|
+
return lastFailureResult;
|
|
97
|
+
}
|
|
98
|
+
if (lastError) {
|
|
99
|
+
throw lastError instanceof Error ? lastError : new Error(String(lastError));
|
|
100
|
+
}
|
|
101
|
+
throw new Error('Parallel helper encountered an unexpected state');
|
|
102
|
+
};
|
|
103
|
+
const recordProgress = (callbacks, state, wasSuccessful) => {
|
|
104
|
+
state.completed += 1;
|
|
105
|
+
if (wasSuccessful) {
|
|
106
|
+
state.success += 1;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
state.failure += 1;
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
callbacks.onProgress?.(state.completed, state.total);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
116
|
+
console.warn('Parallel helper onProgress callback threw an error:', error);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const mapResults = (taskResults) => {
|
|
121
|
+
return taskResults.map((taskResult) => ({
|
|
122
|
+
metadata: taskResult.metadata,
|
|
123
|
+
taskResult,
|
|
124
|
+
}));
|
|
125
|
+
};
|
|
126
|
+
const buildAgentResults = (decoratedResults) => {
|
|
127
|
+
const ordered = decoratedResults.slice().sort((a, b) => a.metadata.index - b.metadata.index);
|
|
128
|
+
return ordered.map(({ metadata, taskResult }) => {
|
|
129
|
+
if (taskResult.value) {
|
|
130
|
+
const baseResult = taskResult.value;
|
|
131
|
+
return {
|
|
132
|
+
...baseResult,
|
|
133
|
+
agentId: baseResult.agentId ?? metadata.request.agentId,
|
|
134
|
+
metadata: {
|
|
135
|
+
...baseResult.metadata,
|
|
136
|
+
requestIndex: metadata.index,
|
|
137
|
+
mode: metadata.mode,
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
const error = taskResult.error ?? new Error('Unknown error');
|
|
142
|
+
return {
|
|
143
|
+
agentId: metadata.request.agentId,
|
|
144
|
+
content: error.message,
|
|
145
|
+
success: false,
|
|
146
|
+
metadata: {
|
|
147
|
+
error: error.message,
|
|
148
|
+
aborted: taskResult.aborted ?? false,
|
|
149
|
+
requestIndex: metadata.index,
|
|
150
|
+
mode: metadata.mode,
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
const collectErrors = (decoratedResults) => {
|
|
156
|
+
return decoratedResults
|
|
157
|
+
.filter(({ taskResult }) => !taskResult.success)
|
|
158
|
+
.map(({ metadata, taskResult }) => {
|
|
159
|
+
if (taskResult.error instanceof Error) {
|
|
160
|
+
return { index: metadata.index, error: taskResult.error };
|
|
161
|
+
}
|
|
162
|
+
if (taskResult.value && !taskResult.value.success) {
|
|
163
|
+
const errorMessage = taskResult.value.metadata?.error
|
|
164
|
+
?? taskResult.value.content
|
|
165
|
+
?? 'Agent returned unsuccessful result';
|
|
166
|
+
return { index: metadata.index, error: new Error(errorMessage) };
|
|
167
|
+
}
|
|
168
|
+
return { index: metadata.index, error: new Error('Unknown failure') };
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
const createCallbacks = (progressState, config) => ({
|
|
172
|
+
onTaskComplete: async (result) => {
|
|
173
|
+
recordProgress(config, progressState, result.success);
|
|
174
|
+
},
|
|
175
|
+
onError: async () => {
|
|
176
|
+
recordProgress(config, progressState, false);
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
const runAgentOperations = async (requests, mode, config = {}) => {
|
|
180
|
+
if (!Array.isArray(requests)) {
|
|
181
|
+
throw new TypeError('Parallel helpers expect an array of requests');
|
|
182
|
+
}
|
|
183
|
+
if (requests.length === 0) {
|
|
184
|
+
const emptyMetrics = {
|
|
185
|
+
totalTasks: 0,
|
|
186
|
+
startedTasks: 0,
|
|
187
|
+
completedTasks: 0,
|
|
188
|
+
successCount: 0,
|
|
189
|
+
failureCount: 0,
|
|
190
|
+
totalDurationMs: 0,
|
|
191
|
+
averageDurationMs: 0,
|
|
192
|
+
throughput: 0,
|
|
193
|
+
};
|
|
194
|
+
const summary = {
|
|
195
|
+
total: 0,
|
|
196
|
+
completed: 0,
|
|
197
|
+
successCount: 0,
|
|
198
|
+
failureCount: 0,
|
|
199
|
+
results: [],
|
|
200
|
+
errors: [],
|
|
201
|
+
metrics: emptyMetrics,
|
|
202
|
+
};
|
|
203
|
+
config.onComplete?.(summary);
|
|
204
|
+
return [];
|
|
205
|
+
}
|
|
206
|
+
const concurrency = normalizeConcurrency(config.concurrency);
|
|
207
|
+
const timeout = normalizeTimeout(config.timeout);
|
|
208
|
+
const retryPolicy = normalizeRetryPolicy(config.retryPolicy);
|
|
209
|
+
const runner = new parallel_runner_1.ParallelRunner();
|
|
210
|
+
const runtime = new agent_1.AgentRuntime();
|
|
211
|
+
const runSingleOperation = (request) => (mode === 'query'
|
|
212
|
+
? runtime.query(request)
|
|
213
|
+
: runtime.execute(request));
|
|
214
|
+
const tasks = requests.map((request, index) => ({
|
|
215
|
+
id: `${mode}:${request.agentId ?? 'anonymous'}:${index}`,
|
|
216
|
+
metadata: { index, mode, request },
|
|
217
|
+
run: (context) => executeWithRetry(() => runSingleOperation(request), retryPolicy, context.signal),
|
|
218
|
+
}));
|
|
219
|
+
const progressState = {
|
|
220
|
+
completed: 0,
|
|
221
|
+
success: 0,
|
|
222
|
+
failure: 0,
|
|
223
|
+
total: requests.length,
|
|
224
|
+
};
|
|
225
|
+
const runnerOptions = {
|
|
226
|
+
maxConcurrency: concurrency,
|
|
227
|
+
timeoutMs: timeout,
|
|
228
|
+
evaluateTaskSuccess: (value) => value.success,
|
|
229
|
+
callbacks: createCallbacks(progressState, config),
|
|
230
|
+
};
|
|
231
|
+
const taskResults = await runner.run(tasks, runnerOptions);
|
|
232
|
+
const decoratedResults = mapResults(taskResults);
|
|
233
|
+
const agentResults = buildAgentResults(decoratedResults);
|
|
234
|
+
const errors = collectErrors(decoratedResults);
|
|
235
|
+
const metrics = runner.getMetrics();
|
|
236
|
+
const summary = {
|
|
237
|
+
total: requests.length,
|
|
238
|
+
completed: requests.length,
|
|
239
|
+
successCount: agentResults.filter((item) => item.success).length,
|
|
240
|
+
failureCount: agentResults.filter((item) => !item.success).length,
|
|
241
|
+
results: agentResults,
|
|
242
|
+
errors,
|
|
243
|
+
metrics,
|
|
244
|
+
};
|
|
245
|
+
config.onComplete?.(summary);
|
|
246
|
+
return agentResults;
|
|
247
|
+
};
|
|
248
|
+
const runQueriesParallel = (queries, config) => runAgentOperations(queries, 'query', config);
|
|
249
|
+
exports.runQueriesParallel = runQueriesParallel;
|
|
250
|
+
const runExecutesParallel = (requests, config) => runAgentOperations(requests, 'execute', config);
|
|
251
|
+
exports.runExecutesParallel = runExecutesParallel;
|
|
252
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/core/parallel/helpers.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AAOnD,oCAKkB;AAElB,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAC9B,MAAM,kBAAkB,GAAG,KAAM,CAAC;AAClC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAiCnC,MAAM,oBAAoB,GAAG,CAAC,KAAyB,EAAU,EAAE;IACjE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAChF,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrC,OAAO,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,mBAAmB,CAAC;AAC3D,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,KAAyB,EAAsB,EAAE;IACzE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,CA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;IACpD,MAAM,YAAY,GAAG,iBAAiB,CAAI,gBAAgB,CAAC,CAAC;IAC5D,MAAM,MAAM,GAAG,aAAa,CAAI,gBAAgB,CAAC,CAAC;IAClD,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;IAEpC,MAAM,OAAO,GAA8B;QACzC,KAAK,EAAE,QAAQ,CAAC,MAAM;QACtB,SAAS,EAAE,QAAQ,CAAC,MAAM;QAC1B,YAAY,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM;QAChE,YAAY,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM;QACjE,OAAO,EAAE,YAAY;QACrB,MAAM;QACN,OAAO;KACR,CAAC;IAEF,MAAM,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,CAAC;IAE7B,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEK,MAAM,kBAAkB,GAAG,CAChC,OAA4B,EAC5B,MAAuB,EACC,EAAE,CAAC,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AAH7D,QAAA,kBAAkB,sBAG2C;AAEnE,MAAM,mBAAmB,GAAG,CACjC,QAA+B,EAC/B,MAAuB,EACC,EAAE,CAAC,kBAAkB,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;AAHhE,QAAA,mBAAmB,uBAG6C"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { ParallelRunner, ParallelRunnerTimeoutError, createDefaultParallelRunner, } from './parallel-runner';
|
|
2
2
|
export type { ParallelRunnerMetrics, ParallelRunnerOptions, Task, TaskResult, TaskCallbacks, TaskExecutionContext, } from './types';
|
|
3
|
+
export { runQueriesParallel, runExecutesParallel, } from './helpers';
|
|
4
|
+
export type { ParallelConfig, HelperResult, RetryPolicy, } from './helpers';
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createDefaultParallelRunner = exports.ParallelRunnerTimeoutError = exports.ParallelRunner = void 0;
|
|
3
|
+
exports.runExecutesParallel = exports.runQueriesParallel = exports.createDefaultParallelRunner = exports.ParallelRunnerTimeoutError = exports.ParallelRunner = void 0;
|
|
4
4
|
var parallel_runner_1 = require("./parallel-runner");
|
|
5
5
|
Object.defineProperty(exports, "ParallelRunner", { enumerable: true, get: function () { return parallel_runner_1.ParallelRunner; } });
|
|
6
6
|
Object.defineProperty(exports, "ParallelRunnerTimeoutError", { enumerable: true, get: function () { return parallel_runner_1.ParallelRunnerTimeoutError; } });
|
|
7
7
|
Object.defineProperty(exports, "createDefaultParallelRunner", { enumerable: true, get: function () { return parallel_runner_1.createDefaultParallelRunner; } });
|
|
8
|
+
var helpers_1 = require("./helpers");
|
|
9
|
+
Object.defineProperty(exports, "runQueriesParallel", { enumerable: true, get: function () { return helpers_1.runQueriesParallel; } });
|
|
10
|
+
Object.defineProperty(exports, "runExecutesParallel", { enumerable: true, get: function () { return helpers_1.runExecutesParallel; } });
|
|
8
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/parallel/index.ts"],"names":[],"mappings":";;;AAAA,qDAI2B;AAHzB,iHAAA,cAAc,OAAA;AACd,6HAAA,0BAA0B,OAAA;AAC1B,8HAAA,2BAA2B,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/parallel/index.ts"],"names":[],"mappings":";;;AAAA,qDAI2B;AAHzB,iHAAA,cAAc,OAAA;AACd,6HAAA,0BAA0B,OAAA;AAC1B,8HAAA,2BAA2B,OAAA;AAU7B,qCAGmB;AAFjB,6GAAA,kBAAkB,OAAA;AAClB,8GAAA,mBAAmB,OAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,10 +15,12 @@ export type { AgentAction, AgentConfig, AgentsConfig, AgentInfo, AgentQueryOptio
|
|
|
15
15
|
export { ExecutionMode, SecurityLevel } from './types/agent.types';
|
|
16
16
|
export { getErrorMessage, getErrorStack, isError } from './utils/error-utils';
|
|
17
17
|
export { MentionParser, loadAvailableAgents, type MentionTask, type ParsedMentions, } from './utils/mention-parser';
|
|
18
|
-
export { BaseMessageFormatter, DefaultMessageFormatter, type StructuredMessage, type FormatterOptions, } from './utils/base-message-formatter';
|
|
19
|
-
export
|
|
18
|
+
export { BaseMessageFormatter, DefaultMessageFormatter, type StructuredMessage as FormatterStructuredMessage, type FormatterOptions, } from './utils/base-message-formatter';
|
|
19
|
+
export type { StructuredPayload, StructuredMessage, AgentInfo as StructuredAgentInfo, StructuredPayloadMetadata, } from './types/structured-payload.types';
|
|
20
|
+
export { isStructuredPayload, parseStructuredPayload, createStructuredPayload, } from './types/structured-payload.types';
|
|
21
|
+
export { createCrewxAgent, loadAgentConfigFromYaml, loadAgentConfigFromFile, type CrewxAgent, type CrewxAgentConfig, type CrewxAgentResult, type ProviderConfig as AgentProviderConfig, type KnowledgeBaseConfig, } from './core/agent';
|
|
20
22
|
export { type AgentQueryRequest, type AgentExecuteRequest, type AgentResult, type CallStackFrame, type EventListener, } from './core/agent';
|
|
21
23
|
export { RemoteAgentManager, FetchRemoteTransport, MockRemoteTransport, type RemoteAgentManagerOptions, } from './core/remote';
|
|
22
24
|
export type { RemoteAgentConfig, RemoteTransport, RemoteTransportRequestOptions, RemoteAgentQueryRequest, RemoteAgentExecuteRequest, RemoteAgentResponse, McpJsonRpcRequest, McpJsonRpcResponse, ToolNameMapping, RemoteAgentDescriptor, } from './core/remote';
|
|
23
|
-
export { ParallelRunner, ParallelRunnerTimeoutError, createDefaultParallelRunner, } from './core/parallel';
|
|
24
|
-
export type { ParallelRunnerMetrics, ParallelRunnerOptions, Task, TaskResult, TaskCallbacks, TaskExecutionContext, } from './core/parallel';
|
|
25
|
+
export { ParallelRunner, ParallelRunnerTimeoutError, createDefaultParallelRunner, runQueriesParallel, runExecutesParallel, } from './core/parallel';
|
|
26
|
+
export type { ParallelRunnerMetrics, ParallelRunnerOptions, Task, TaskResult, TaskCallbacks, TaskExecutionContext, ParallelConfig, HelperResult, RetryPolicy, } from './core/parallel';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createDefaultParallelRunner = exports.ParallelRunnerTimeoutError = exports.ParallelRunner = exports.MockRemoteTransport = exports.FetchRemoteTransport = exports.RemoteAgentManager = exports.loadAgentConfigFromYaml = exports.createCrewxAgent = exports.DefaultMessageFormatter = exports.BaseMessageFormatter = exports.loadAvailableAgents = exports.MentionParser = exports.isError = exports.getErrorStack = exports.getErrorMessage = exports.SecurityLevel = exports.ExecutionMode = exports.CodexProvider = exports.CopilotProvider = exports.GeminiProvider = exports.ClaudeProvider = exports.BaseAIProvider = exports.ProviderNotAvailableError = exports.BuiltInProviders = exports.ProviderNamespace = exports.DocumentManager = exports.getConversationConfig = exports.DEFAULT_CONVERSATION_CONFIG = exports.getDefaultTimeoutConfig = exports.getTimeoutConfig = exports.DEFAULT_MAX_FILES = exports.DEFAULT_MAX_FILE_SIZE = exports.PREFIX_TOOL_NAME = exports.SERVER_NAME = void 0;
|
|
3
|
+
exports.runExecutesParallel = exports.runQueriesParallel = exports.createDefaultParallelRunner = exports.ParallelRunnerTimeoutError = exports.ParallelRunner = exports.MockRemoteTransport = exports.FetchRemoteTransport = exports.RemoteAgentManager = exports.loadAgentConfigFromFile = exports.loadAgentConfigFromYaml = exports.createCrewxAgent = exports.createStructuredPayload = exports.parseStructuredPayload = exports.isStructuredPayload = exports.DefaultMessageFormatter = exports.BaseMessageFormatter = exports.loadAvailableAgents = exports.MentionParser = exports.isError = exports.getErrorStack = exports.getErrorMessage = exports.SecurityLevel = exports.ExecutionMode = exports.CodexProvider = exports.CopilotProvider = exports.GeminiProvider = exports.ClaudeProvider = exports.BaseAIProvider = exports.ProviderNotAvailableError = exports.BuiltInProviders = exports.ProviderNamespace = exports.DocumentManager = exports.getConversationConfig = exports.DEFAULT_CONVERSATION_CONFIG = exports.getDefaultTimeoutConfig = exports.getTimeoutConfig = exports.DEFAULT_MAX_FILES = exports.DEFAULT_MAX_FILE_SIZE = exports.PREFIX_TOOL_NAME = exports.SERVER_NAME = void 0;
|
|
4
4
|
var constants_1 = require("./constants");
|
|
5
5
|
Object.defineProperty(exports, "SERVER_NAME", { enumerable: true, get: function () { return constants_1.SERVER_NAME; } });
|
|
6
6
|
Object.defineProperty(exports, "PREFIX_TOOL_NAME", { enumerable: true, get: function () { return constants_1.PREFIX_TOOL_NAME; } });
|
|
@@ -38,9 +38,14 @@ Object.defineProperty(exports, "loadAvailableAgents", { enumerable: true, get: f
|
|
|
38
38
|
var base_message_formatter_1 = require("./utils/base-message-formatter");
|
|
39
39
|
Object.defineProperty(exports, "BaseMessageFormatter", { enumerable: true, get: function () { return base_message_formatter_1.BaseMessageFormatter; } });
|
|
40
40
|
Object.defineProperty(exports, "DefaultMessageFormatter", { enumerable: true, get: function () { return base_message_formatter_1.DefaultMessageFormatter; } });
|
|
41
|
+
var structured_payload_types_1 = require("./types/structured-payload.types");
|
|
42
|
+
Object.defineProperty(exports, "isStructuredPayload", { enumerable: true, get: function () { return structured_payload_types_1.isStructuredPayload; } });
|
|
43
|
+
Object.defineProperty(exports, "parseStructuredPayload", { enumerable: true, get: function () { return structured_payload_types_1.parseStructuredPayload; } });
|
|
44
|
+
Object.defineProperty(exports, "createStructuredPayload", { enumerable: true, get: function () { return structured_payload_types_1.createStructuredPayload; } });
|
|
41
45
|
var agent_1 = require("./core/agent");
|
|
42
46
|
Object.defineProperty(exports, "createCrewxAgent", { enumerable: true, get: function () { return agent_1.createCrewxAgent; } });
|
|
43
47
|
Object.defineProperty(exports, "loadAgentConfigFromYaml", { enumerable: true, get: function () { return agent_1.loadAgentConfigFromYaml; } });
|
|
48
|
+
Object.defineProperty(exports, "loadAgentConfigFromFile", { enumerable: true, get: function () { return agent_1.loadAgentConfigFromFile; } });
|
|
44
49
|
var remote_1 = require("./core/remote");
|
|
45
50
|
Object.defineProperty(exports, "RemoteAgentManager", { enumerable: true, get: function () { return remote_1.RemoteAgentManager; } });
|
|
46
51
|
Object.defineProperty(exports, "FetchRemoteTransport", { enumerable: true, get: function () { return remote_1.FetchRemoteTransport; } });
|
|
@@ -49,4 +54,6 @@ var parallel_1 = require("./core/parallel");
|
|
|
49
54
|
Object.defineProperty(exports, "ParallelRunner", { enumerable: true, get: function () { return parallel_1.ParallelRunner; } });
|
|
50
55
|
Object.defineProperty(exports, "ParallelRunnerTimeoutError", { enumerable: true, get: function () { return parallel_1.ParallelRunnerTimeoutError; } });
|
|
51
56
|
Object.defineProperty(exports, "createDefaultParallelRunner", { enumerable: true, get: function () { return parallel_1.createDefaultParallelRunner; } });
|
|
57
|
+
Object.defineProperty(exports, "runQueriesParallel", { enumerable: true, get: function () { return parallel_1.runQueriesParallel; } });
|
|
58
|
+
Object.defineProperty(exports, "runExecutesParallel", { enumerable: true, get: function () { return parallel_1.runExecutesParallel; } });
|
|
52
59
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAMA,yCAKqB;AAJnB,wGAAA,WAAW,OAAA;AACX,6GAAA,gBAAgB,OAAA;AAChB,kHAAA,qBAAqB,OAAA;AACrB,8GAAA,iBAAiB,OAAA;AAKnB,0DAAoF;AAA3E,kHAAA,gBAAgB,OAAA;AAAE,yHAAA,uBAAuB,OAAA;AAUlD,0EAG4C;AAF1C,kIAAA,2BAA2B,OAAA;AAC3B,4HAAA,qBAAqB,OAAA;AAIvB,+DAA8D;AAArD,k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D,4GAAA,aAAa,OAAA;AAAE,4GAAA,aAAa,OAAA;AAGrC,mDAA8E;AAArE,8GAAA,eAAe,OAAA;AAAE,4GAAA,aAAa,OAAA;AAAE,sGAAA,OAAO,OAAA;AAChD,yDAKgC;AAJ9B,+GAAA,aAAa,OAAA;AACb,qHAAA,mBAAmB,OAAA;AAIrB,yEAKwC;AAJtC,8HAAA,oBAAoB,OAAA;AACpB,iIAAA,uBAAuB,OAAA;AAYzB,6EAI0C;AAHxC,+HAAA,mBAAmB,OAAA;AACnB,kIAAA,sBAAsB,OAAA;AACtB,mIAAA,uBAAuB,OAAA;AAIzB,sCASsB;AARpB,yGAAA,gBAAgB,OAAA;AAChB,gHAAA,uBAAuB,OAAA;AACvB,gHAAA,uBAAuB,OAAA;AAgBzB,wCAKuB;AAJrB,4GAAA,kBAAkB,OAAA;AAClB,8GAAA,oBAAoB,OAAA;AACpB,6GAAA,mBAAmB,OAAA;AAiBrB,4CAMyB;AALvB,0GAAA,cAAc,OAAA;AACd,sHAAA,0BAA0B,OAAA;AAC1B,uHAAA,2BAA2B,OAAA;AAC3B,8GAAA,kBAAkB,OAAA;AAClB,+GAAA,mBAAmB,OAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { CallStackFrame } from '../core/agent/event-bus';
|
|
2
|
+
export interface StructuredMessage {
|
|
3
|
+
id: string;
|
|
4
|
+
userId?: string;
|
|
5
|
+
text: string;
|
|
6
|
+
timestamp: string;
|
|
7
|
+
isAssistant: boolean;
|
|
8
|
+
metadata?: Record<string, any>;
|
|
9
|
+
}
|
|
10
|
+
export interface AgentInfo {
|
|
11
|
+
id: string;
|
|
12
|
+
provider: string;
|
|
13
|
+
mode: 'query' | 'execute';
|
|
14
|
+
model?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface StructuredPayloadMetadata {
|
|
17
|
+
generatedAt: string;
|
|
18
|
+
messageCount: number;
|
|
19
|
+
originalContext?: string;
|
|
20
|
+
platform: string;
|
|
21
|
+
threadId?: string;
|
|
22
|
+
callStack?: CallStackFrame[];
|
|
23
|
+
formattedHistory?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface StructuredPayload {
|
|
26
|
+
version: string;
|
|
27
|
+
agent: AgentInfo;
|
|
28
|
+
prompt: string;
|
|
29
|
+
context?: string;
|
|
30
|
+
messages: StructuredMessage[];
|
|
31
|
+
metadata: StructuredPayloadMetadata;
|
|
32
|
+
}
|
|
33
|
+
export declare function isStructuredPayload(value: unknown): value is StructuredPayload;
|
|
34
|
+
export declare function parseStructuredPayload(input: string | null | undefined): StructuredPayload | null;
|
|
35
|
+
export declare function createStructuredPayload(params: {
|
|
36
|
+
agentId: string;
|
|
37
|
+
provider: string;
|
|
38
|
+
mode: 'query' | 'execute';
|
|
39
|
+
prompt: string;
|
|
40
|
+
context?: string;
|
|
41
|
+
messages?: StructuredMessage[];
|
|
42
|
+
model?: string;
|
|
43
|
+
platform?: string;
|
|
44
|
+
threadId?: string;
|
|
45
|
+
callStack?: CallStackFrame[];
|
|
46
|
+
}): StructuredPayload;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isStructuredPayload = isStructuredPayload;
|
|
4
|
+
exports.parseStructuredPayload = parseStructuredPayload;
|
|
5
|
+
exports.createStructuredPayload = createStructuredPayload;
|
|
6
|
+
function isStructuredPayload(value) {
|
|
7
|
+
if (!value || typeof value !== 'object') {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
const payload = value;
|
|
11
|
+
return (typeof payload.version === 'string' &&
|
|
12
|
+
typeof payload.prompt === 'string' &&
|
|
13
|
+
Array.isArray(payload.messages) &&
|
|
14
|
+
typeof payload.agent === 'object' &&
|
|
15
|
+
typeof payload.metadata === 'object' &&
|
|
16
|
+
typeof payload.agent.id === 'string' &&
|
|
17
|
+
typeof payload.agent.provider === 'string' &&
|
|
18
|
+
(payload.agent.mode === 'query' || payload.agent.mode === 'execute'));
|
|
19
|
+
}
|
|
20
|
+
function parseStructuredPayload(input) {
|
|
21
|
+
if (!input) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const trimmed = input.trim();
|
|
25
|
+
if (!trimmed.startsWith('{') || !trimmed.endsWith('}')) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const parsed = JSON.parse(trimmed);
|
|
30
|
+
if (isStructuredPayload(parsed)) {
|
|
31
|
+
if (!Array.isArray(parsed.messages)) {
|
|
32
|
+
parsed.messages = [];
|
|
33
|
+
}
|
|
34
|
+
return parsed;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
function createStructuredPayload(params) {
|
|
42
|
+
const now = new Date().toISOString();
|
|
43
|
+
const messages = params.messages || [];
|
|
44
|
+
return {
|
|
45
|
+
version: '1.0',
|
|
46
|
+
agent: {
|
|
47
|
+
id: params.agentId,
|
|
48
|
+
provider: params.provider,
|
|
49
|
+
mode: params.mode,
|
|
50
|
+
model: params.model,
|
|
51
|
+
},
|
|
52
|
+
prompt: params.prompt,
|
|
53
|
+
context: params.context,
|
|
54
|
+
messages,
|
|
55
|
+
metadata: {
|
|
56
|
+
generatedAt: now,
|
|
57
|
+
messageCount: messages.length,
|
|
58
|
+
originalContext: params.context,
|
|
59
|
+
platform: params.platform || 'cli',
|
|
60
|
+
threadId: params.threadId,
|
|
61
|
+
callStack: params.callStack,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=structured-payload.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structured-payload.types.js","sourceRoot":"","sources":["../../src/types/structured-payload.types.ts"],"names":[],"mappings":";;AA4IA,kDAiBC;AAOD,wDAyBC;AAKD,0DAmCC;AAzFD,SAAgB,mBAAmB,CA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CAAC;QAChB,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;IAEjB,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAKD,SAAgB,uBAAuB,CAAC,MAWvC;IACC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;IAEvC,OAAO;QACL,OAAO,EAAE,KAAK;QACd,KAAK,EAAE;YACL,EAAE,EAAE,MAAM,CAAC,OAAO;YAClB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB;QACD,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,QAAQ;QACR,QAAQ,EAAE;YACR,WAAW,EAAE,GAAG;YAChB,YAAY,EAAE,QAAQ,CAAC,MAAM;YAC7B,eAAe,EAAE,MAAM,CAAC,OAAO;YAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,KAAK;YAClC,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,SAAS,EAAE,MAAM,CAAC,SAAS;SAC5B;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -26,7 +26,7 @@ export declare abstract class BaseMessageFormatter {
|
|
|
26
26
|
protected sanitizeText(text: string, maxLength?: number): string;
|
|
27
27
|
protected truncateText(text: string, maxLength: number): string;
|
|
28
28
|
protected getDefaultOptions(options?: FormatterOptions): FormatterOptions;
|
|
29
|
-
|
|
29
|
+
protected resolveDisplayName(msg: StructuredMessage): string | undefined;
|
|
30
30
|
}
|
|
31
31
|
export declare class DefaultMessageFormatter extends BaseMessageFormatter {
|
|
32
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-message-formatter.js","sourceRoot":"","sources":["../../src/utils/base-message-format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AE,SAAS;YACrB,eAAe,EAAE,cAAc;YAC/B,GAAG,OAAO;SACX,CAAC;IACJ,CAAC;IAES,kBAAkB,CAAC,GAAsB;QACjD,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC;QACpC,OAAO,CACL,QAAQ,CAAC,QAAQ;YACjB,QAAQ,CAAC,WAAW;YACpB,QAAQ,CAAC,QAAQ;YACjB,QAAQ,CAAC,SAAS;YAClB,SAAS,CACV,CAAC;IACJ,CAAC;CACF;AArRD,oDAqRC;AAKD,MAAa,uBAAwB,SAAQ,oBAAoB;CAEhE;AAFD,0DAEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sowonai/crewx-sdk",
|
|
3
|
-
"version": "0.1.0-dev.
|
|
3
|
+
"version": "0.1.0-dev.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "SowonAI CrewX SDK",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -50,5 +50,8 @@
|
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@types/js-yaml": "^4.0.9"
|
|
53
56
|
}
|
|
54
57
|
}
|