@sowonai/crewx-sdk 0.1.0-dev.1 → 0.1.0-dev.10

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.
Files changed (49) hide show
  1. package/README.md +335 -6
  2. package/dist/config/yaml-loader.d.ts +8 -0
  3. package/dist/config/yaml-loader.js +137 -0
  4. package/dist/config/yaml-loader.js.map +1 -0
  5. package/dist/core/agent/agent-factory.d.ts +1 -1
  6. package/dist/core/agent/agent-factory.js +4 -6
  7. package/dist/core/agent/agent-factory.js.map +1 -1
  8. package/dist/core/agent/index.d.ts +1 -1
  9. package/dist/core/agent/index.js +2 -1
  10. package/dist/core/agent/index.js.map +1 -1
  11. package/dist/core/parallel/helpers.d.ts +27 -0
  12. package/dist/core/parallel/helpers.js +252 -0
  13. package/dist/core/parallel/helpers.js.map +1 -0
  14. package/dist/core/parallel/index.d.ts +2 -0
  15. package/dist/core/parallel/index.js +4 -1
  16. package/dist/core/parallel/index.js.map +1 -1
  17. package/dist/core/providers/base-ai.provider.js +6 -3
  18. package/dist/core/providers/base-ai.provider.js.map +1 -1
  19. package/dist/core/providers/dynamic-provider.factory.d.ts +64 -0
  20. package/dist/core/providers/dynamic-provider.factory.js +533 -0
  21. package/dist/core/providers/dynamic-provider.factory.js.map +1 -0
  22. package/dist/core/providers/index.d.ts +1 -0
  23. package/dist/core/providers/index.js +3 -1
  24. package/dist/core/providers/index.js.map +1 -1
  25. package/dist/index.d.ts +13 -5
  26. package/dist/index.js +16 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/services/index.d.ts +2 -0
  29. package/dist/services/index.js +19 -0
  30. package/dist/services/index.js.map +1 -0
  31. package/dist/services/layout-loader.service.d.ts +15 -0
  32. package/dist/services/layout-loader.service.js +185 -0
  33. package/dist/services/layout-loader.service.js.map +1 -0
  34. package/dist/services/layout-renderer.service.d.ts +24 -0
  35. package/dist/services/layout-renderer.service.js +158 -0
  36. package/dist/services/layout-renderer.service.js.map +1 -0
  37. package/dist/services/props-validator.service.d.ts +29 -0
  38. package/dist/services/props-validator.service.js +332 -0
  39. package/dist/services/props-validator.service.js.map +1 -0
  40. package/dist/types/agent.types.d.ts +6 -1
  41. package/dist/types/layout.types.d.ts +77 -0
  42. package/dist/types/layout.types.js +22 -0
  43. package/dist/types/layout.types.js.map +1 -0
  44. package/dist/types/structured-payload.types.d.ts +46 -0
  45. package/dist/types/structured-payload.types.js +65 -0
  46. package/dist/types/structured-payload.types.js.map +1 -0
  47. package/dist/utils/base-message-formatter.d.ts +1 -1
  48. package/dist/utils/base-message-formatter.js.map +1 -1
  49. 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
- Create platform-specific message formatters:
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 CustomFormatter extends BaseMessageFormatter {
557
+ class DiscordFormatter extends BaseMessageFormatter {
452
558
  formatMessage(msg: StructuredMessage, options: FormatterOptions): string {
453
- // Implement custom formatting
454
- return `[${msg.userId}] ${msg.text}`;
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 formatter = new CustomFormatter();
459
- const history = formatter.formatHistory(messages, {
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,MAAM,CAAC,CAAC;YAC7D,OAAO,CAAC,GAAG,CAAC,8BAA8B,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YAC5D,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;YAC5D,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,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Ae,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 declare function loadAgentConfigFromYaml(yamlString: string): CrewxAgentConfig;
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
- function loadAgentConfigFromYaml(yamlString) {
27
- return {
28
- defaultAgentId: 'crewx',
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":";;AAoFA,4CA6BC;AAMD,0DAMC;AAxHD,mDAAoE;AACpE,2CAAsD;AA8E/C,KAAK,UAAU,gBAAgB,CACpC,SAA2B,EAAE;IAG7B,MAAM,QAAQ,GAAG,IAAI,oBAAQ,EAAE,CAAC;IAGh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AAC;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';
@@ -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,iDAQyB;AAPvB,iHAAA,gBAAgB,OAAA;AAChB,wHAAA,uBAAuB,OAAA;AAQzB,iDAMyB;AALvB,6GAAA,YAAY,OAAA;AAOd,yCAKqB;AAJnB,qGAAA,QAAQ,OAAA"}
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[]>;