@wundam/orchex 1.0.0-rc.2 → 1.0.0-rc.21

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 (98) hide show
  1. package/README.md +59 -18
  2. package/dist/cloud-executor.d.ts +71 -0
  3. package/dist/cloud-executor.js +335 -0
  4. package/dist/cloud-sync.d.ts +8 -0
  5. package/dist/cloud-sync.js +52 -0
  6. package/dist/config.d.ts +30 -4
  7. package/dist/config.js +61 -2
  8. package/dist/context-builder.d.ts +2 -0
  9. package/dist/context-builder.js +11 -3
  10. package/dist/cost.js +1 -1
  11. package/dist/entitlements/jwt.d.ts +7 -0
  12. package/dist/entitlements/jwt.js +78 -0
  13. package/dist/entitlements/resolve.d.ts +17 -0
  14. package/dist/entitlements/resolve.js +49 -0
  15. package/dist/entitlements/types.d.ts +21 -0
  16. package/dist/entitlements/types.js +4 -0
  17. package/dist/executors/base.d.ts +1 -1
  18. package/dist/executors/bedrock-executor.d.ts +39 -0
  19. package/dist/executors/bedrock-executor.js +197 -0
  20. package/dist/executors/index.d.ts +1 -0
  21. package/dist/executors/index.js +24 -1
  22. package/dist/index.js +468 -23
  23. package/dist/intelligence/index.d.ts +44 -0
  24. package/dist/intelligence/index.js +160 -0
  25. package/dist/key-cache.d.ts +31 -0
  26. package/dist/key-cache.js +84 -0
  27. package/dist/login-helpers.d.ts +25 -0
  28. package/dist/login-helpers.js +54 -0
  29. package/dist/manifest.js +18 -1
  30. package/dist/mcp-instructions.d.ts +1 -0
  31. package/dist/mcp-instructions.js +84 -0
  32. package/dist/mcp-resources.d.ts +8 -0
  33. package/dist/mcp-resources.js +420 -0
  34. package/dist/model-cache.d.ts +18 -0
  35. package/dist/model-cache.js +62 -0
  36. package/dist/model-validator.d.ts +20 -0
  37. package/dist/model-validator.js +125 -0
  38. package/dist/orchestrator.d.ts +14 -0
  39. package/dist/orchestrator.js +191 -32
  40. package/dist/setup/ide-registry.d.ts +13 -0
  41. package/dist/setup/ide-registry.js +51 -0
  42. package/dist/setup/index.d.ts +1 -0
  43. package/dist/setup/index.js +111 -0
  44. package/dist/tier-gating.js +0 -16
  45. package/dist/tiers.d.ts +35 -5
  46. package/dist/tiers.js +39 -3
  47. package/dist/tools.d.ts +6 -1
  48. package/dist/tools.js +852 -95
  49. package/dist/types.d.ts +71 -60
  50. package/dist/types.js +3 -0
  51. package/dist/waves.d.ts +1 -1
  52. package/dist/waves.js +29 -2
  53. package/package.json +41 -5
  54. package/src/entitlements/public-key.pem +9 -0
  55. package/dist/intelligence/anti-pattern-detector.d.ts +0 -117
  56. package/dist/intelligence/anti-pattern-detector.js +0 -327
  57. package/dist/intelligence/budget-enforcer.d.ts +0 -119
  58. package/dist/intelligence/budget-enforcer.js +0 -226
  59. package/dist/intelligence/context-optimizer.d.ts +0 -111
  60. package/dist/intelligence/context-optimizer.js +0 -282
  61. package/dist/intelligence/cost-tracker.d.ts +0 -114
  62. package/dist/intelligence/cost-tracker.js +0 -183
  63. package/dist/intelligence/deliverable-extractor.d.ts +0 -134
  64. package/dist/intelligence/deliverable-extractor.js +0 -909
  65. package/dist/intelligence/dependency-inferrer.d.ts +0 -87
  66. package/dist/intelligence/dependency-inferrer.js +0 -403
  67. package/dist/intelligence/diagnostics.d.ts +0 -33
  68. package/dist/intelligence/diagnostics.js +0 -64
  69. package/dist/intelligence/error-analyzer.d.ts +0 -7
  70. package/dist/intelligence/error-analyzer.js +0 -76
  71. package/dist/intelligence/file-chunker.d.ts +0 -15
  72. package/dist/intelligence/file-chunker.js +0 -64
  73. package/dist/intelligence/fix-stream-manager.d.ts +0 -59
  74. package/dist/intelligence/fix-stream-manager.js +0 -212
  75. package/dist/intelligence/heuristics.d.ts +0 -23
  76. package/dist/intelligence/heuristics.js +0 -124
  77. package/dist/intelligence/learning-engine.d.ts +0 -157
  78. package/dist/intelligence/learning-engine.js +0 -433
  79. package/dist/intelligence/learning-feedback.d.ts +0 -96
  80. package/dist/intelligence/learning-feedback.js +0 -202
  81. package/dist/intelligence/pattern-analyzer.d.ts +0 -35
  82. package/dist/intelligence/pattern-analyzer.js +0 -189
  83. package/dist/intelligence/plan-parser.d.ts +0 -124
  84. package/dist/intelligence/plan-parser.js +0 -498
  85. package/dist/intelligence/planner.d.ts +0 -29
  86. package/dist/intelligence/planner.js +0 -86
  87. package/dist/intelligence/self-healer.d.ts +0 -16
  88. package/dist/intelligence/self-healer.js +0 -84
  89. package/dist/intelligence/slicing-metrics.d.ts +0 -62
  90. package/dist/intelligence/slicing-metrics.js +0 -202
  91. package/dist/intelligence/slicing-templates.d.ts +0 -81
  92. package/dist/intelligence/slicing-templates.js +0 -420
  93. package/dist/intelligence/split-suggester.d.ts +0 -69
  94. package/dist/intelligence/split-suggester.js +0 -176
  95. package/dist/intelligence/stream-generator.d.ts +0 -90
  96. package/dist/intelligence/stream-generator.js +0 -452
  97. package/dist/telemetry/telemetry-types.d.ts +0 -85
  98. package/dist/telemetry/telemetry-types.js +0 -1
@@ -0,0 +1,197 @@
1
+ /**
2
+ * AWS Bedrock Executor
3
+ *
4
+ * Supports Claude (via Bedrock), Llama, and Mistral models.
5
+ * Auth via AWS credentials (access key + secret key, or IAM role).
6
+ */
7
+ import { DEFAULT_EXECUTOR_CONFIG, RETRYABLE_STATUS_CODES, sleep, TimeoutError, withCircuitBreaker } from './base.js';
8
+ import { extractArtifactWithDiagnostics } from '../artifacts.js';
9
+ import { Semaphore } from '../semaphore.js';
10
+ // ============================================================================
11
+ // Model ID Mapping
12
+ // ============================================================================
13
+ const BEDROCK_MODEL_MAP = {
14
+ 'claude-3.5-sonnet': 'anthropic.claude-3-5-sonnet-20241022-v2:0',
15
+ 'claude-3-haiku': 'anthropic.claude-3-haiku-20240307-v1:0',
16
+ 'claude-sonnet-4-5': 'anthropic.claude-sonnet-4-5-v1:0',
17
+ 'llama-3.1-70b': 'meta.llama3-1-70b-instruct-v1:0',
18
+ 'mistral-large': 'mistral.mistral-large-2407-v1:0',
19
+ };
20
+ export function resolveBedrockModelId(model) {
21
+ return BEDROCK_MODEL_MAP[model] ?? model;
22
+ }
23
+ function isClaudeModel(modelId) {
24
+ return modelId.startsWith('anthropic.');
25
+ }
26
+ function isLlamaModel(modelId) {
27
+ return modelId.startsWith('meta.');
28
+ }
29
+ const DEFAULT_BEDROCK_CONFIG = {
30
+ ...DEFAULT_EXECUTOR_CONFIG,
31
+ region: process.env.AWS_REGION ?? process.env.AWS_DEFAULT_REGION ?? 'us-east-1',
32
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID,
33
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
34
+ };
35
+ // ============================================================================
36
+ // Executor
37
+ // ============================================================================
38
+ export class BedrockExecutor {
39
+ provider = 'bedrock';
40
+ config;
41
+ semaphore;
42
+ client;
43
+ constructor(config, client) {
44
+ this.config = { ...DEFAULT_BEDROCK_CONFIG, ...config };
45
+ this.semaphore = new Semaphore(this.config.maxConcurrency);
46
+ this.client = client;
47
+ }
48
+ async getClient() {
49
+ if (this.client)
50
+ return this.client;
51
+ // Dynamic import to avoid requiring @aws-sdk in non-Bedrock users
52
+ const { BedrockRuntimeClient, InvokeModelCommand } = await import('@aws-sdk/client-bedrock-runtime');
53
+ const awsClient = new BedrockRuntimeClient({
54
+ region: this.config.region,
55
+ ...(this.config.accessKeyId && this.config.secretAccessKey
56
+ ? {
57
+ credentials: {
58
+ accessKeyId: this.config.accessKeyId,
59
+ secretAccessKey: this.config.secretAccessKey,
60
+ },
61
+ }
62
+ : {}),
63
+ });
64
+ this.client = {
65
+ async invokeModel(params) {
66
+ const command = new InvokeModelCommand({
67
+ modelId: params.modelId,
68
+ contentType: params.contentType,
69
+ accept: params.accept,
70
+ body: new TextEncoder().encode(params.body),
71
+ });
72
+ const response = await awsClient.send(command);
73
+ return {
74
+ body: response.body ?? new Uint8Array(),
75
+ contentType: response.contentType,
76
+ };
77
+ },
78
+ };
79
+ return this.client;
80
+ }
81
+ async execute(request) {
82
+ const release = await this.semaphore.acquire();
83
+ try {
84
+ return await withCircuitBreaker(this.provider, request.model, () => this.executeWithRetry(request));
85
+ }
86
+ catch (err) {
87
+ return {
88
+ success: false,
89
+ rawResponse: '',
90
+ tokensUsed: { input: 0, output: 0 },
91
+ error: err?.message ?? String(err),
92
+ };
93
+ }
94
+ finally {
95
+ release();
96
+ }
97
+ }
98
+ async executeWithRetry(request) {
99
+ const modelId = resolveBedrockModelId(request.model);
100
+ for (let attempt = 0; attempt <= this.config.maxRetries; attempt++) {
101
+ try {
102
+ return await this.invokeWithTimeout(request, modelId);
103
+ }
104
+ catch (err) {
105
+ const statusCode = err?.statusCode ?? err?.$metadata?.httpStatusCode;
106
+ if (statusCode && RETRYABLE_STATUS_CODES.has(statusCode) && attempt < this.config.maxRetries) {
107
+ await sleep(this.config.retryDelayMs * Math.pow(2, attempt));
108
+ continue;
109
+ }
110
+ throw err;
111
+ }
112
+ }
113
+ throw new Error('Max retries exceeded');
114
+ }
115
+ async invokeWithTimeout(request, modelId) {
116
+ const timeoutMs = request.timeoutMs ?? this.config.timeoutMs;
117
+ const resultPromise = this.invokeModel(request, modelId);
118
+ const timeoutPromise = new Promise((_, reject) => setTimeout(() => reject(new TimeoutError(timeoutMs)), timeoutMs));
119
+ return Promise.race([resultPromise, timeoutPromise]);
120
+ }
121
+ async invokeModel(request, modelId) {
122
+ const client = await this.getClient();
123
+ const body = this.buildRequestBody(request, modelId);
124
+ const response = await client.invokeModel({
125
+ modelId,
126
+ contentType: 'application/json',
127
+ accept: 'application/json',
128
+ body: JSON.stringify(body),
129
+ });
130
+ const responseBody = typeof response.body === 'string'
131
+ ? JSON.parse(response.body)
132
+ : JSON.parse(new TextDecoder().decode(response.body));
133
+ return this.parseResponse(responseBody, modelId, request.streamId);
134
+ }
135
+ buildRequestBody(request, modelId) {
136
+ if (isClaudeModel(modelId)) {
137
+ return {
138
+ anthropic_version: 'bedrock-2023-05-31',
139
+ max_tokens: request.maxTokens,
140
+ messages: [{ role: 'user', content: request.prompt }],
141
+ };
142
+ }
143
+ if (isLlamaModel(modelId)) {
144
+ return {
145
+ prompt: request.prompt,
146
+ max_gen_len: request.maxTokens,
147
+ temperature: 0.1,
148
+ };
149
+ }
150
+ // Mistral and others
151
+ return {
152
+ prompt: `<s>[INST] ${request.prompt} [/INST]`,
153
+ max_tokens: request.maxTokens,
154
+ temperature: 0.1,
155
+ };
156
+ }
157
+ parseResponse(body, modelId, streamId) {
158
+ let rawText;
159
+ let tokensUsed = { input: 0, output: 0 };
160
+ if (isClaudeModel(modelId)) {
161
+ rawText = body.content?.[0]?.text ?? '';
162
+ tokensUsed = {
163
+ input: body.usage?.input_tokens ?? 0,
164
+ output: body.usage?.output_tokens ?? 0,
165
+ };
166
+ }
167
+ else if (isLlamaModel(modelId)) {
168
+ rawText = body.generation ?? '';
169
+ tokensUsed = {
170
+ input: body.prompt_token_count ?? 0,
171
+ output: body.generation_token_count ?? 0,
172
+ };
173
+ }
174
+ else {
175
+ // Mistral
176
+ rawText = body.outputs?.[0]?.text ?? '';
177
+ // Mistral on Bedrock doesn't always return token counts
178
+ tokensUsed = { input: 0, output: 0 };
179
+ }
180
+ let artifact;
181
+ try {
182
+ const extraction = extractArtifactWithDiagnostics(rawText);
183
+ if (extraction.artifact) {
184
+ artifact = extraction.artifact;
185
+ }
186
+ }
187
+ catch {
188
+ // Extraction failure — return raw response
189
+ }
190
+ return {
191
+ success: true,
192
+ rawResponse: rawText,
193
+ artifact,
194
+ tokensUsed,
195
+ };
196
+ }
197
+ }
@@ -11,6 +11,7 @@ export { OpenAIExecutor } from './openai-executor.js';
11
11
  export { GeminiExecutor } from './gemini-executor.js';
12
12
  export { OllamaExecutor } from './ollama-executor.js';
13
13
  export { DeepseekExecutor } from './deepseek-executor.js';
14
+ export { BedrockExecutor } from './bedrock-executor.js';
14
15
  export * from './base.js';
15
16
  /**
16
17
  * Options for creating an executor.
@@ -10,12 +10,14 @@ import { OpenAIExecutor } from './openai-executor.js';
10
10
  import { GeminiExecutor } from './gemini-executor.js';
11
11
  import { OllamaExecutor } from './ollama-executor.js';
12
12
  import { DeepseekExecutor } from './deepseek-executor.js';
13
+ import { BedrockExecutor } from './bedrock-executor.js';
13
14
  // Re-export individual executors
14
15
  export { ClaudeExecutor } from '../claude-executor.js';
15
16
  export { OpenAIExecutor } from './openai-executor.js';
16
17
  export { GeminiExecutor } from './gemini-executor.js';
17
18
  export { OllamaExecutor } from './ollama-executor.js';
18
19
  export { DeepseekExecutor } from './deepseek-executor.js';
20
+ export { BedrockExecutor } from './bedrock-executor.js';
19
21
  // Re-export base utilities
20
22
  export * from './base.js';
21
23
  /**
@@ -88,8 +90,15 @@ export function createExecutor(options = {}) {
88
90
  timeoutMs: options.timeoutMs,
89
91
  maxConcurrency: options.maxConcurrency,
90
92
  }));
93
+ case 'bedrock':
94
+ return new BedrockExecutor(defined({
95
+ maxRetries: options.maxRetries,
96
+ retryDelayMs: options.retryDelayMs,
97
+ timeoutMs: options.timeoutMs,
98
+ maxConcurrency: options.maxConcurrency,
99
+ }));
91
100
  default:
92
- throw new Error(`Unknown provider: ${provider}. Supported: anthropic, openai, gemini, ollama, deepseek`);
101
+ throw new Error(`Unknown provider: ${provider}. Supported: anthropic, openai, gemini, ollama, deepseek, bedrock`);
93
102
  }
94
103
  }
95
104
  /**
@@ -106,6 +115,7 @@ export function getProviderStatus() {
106
115
  gemini: 'Google Gemini',
107
116
  ollama: 'Ollama (local)',
108
117
  deepseek: 'DeepSeek',
118
+ bedrock: 'AWS Bedrock',
109
119
  };
110
120
  if (provider === 'ollama') {
111
121
  return {
@@ -114,6 +124,16 @@ export function getProviderStatus() {
114
124
  message: `Provider: ${providerNames[provider]} at ${baseUrl}`,
115
125
  };
116
126
  }
127
+ if (provider === 'bedrock') {
128
+ const hasCredentials = !!(process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY);
129
+ return {
130
+ provider,
131
+ configured: hasCredentials,
132
+ message: hasCredentials
133
+ ? `Provider: ${providerNames[provider]} (${process.env.AWS_REGION ?? 'us-east-1'})`
134
+ : `Provider: ${providerNames[provider]} (not configured - missing AWS credentials)`,
135
+ };
136
+ }
117
137
  if (!apiKey) {
118
138
  return {
119
139
  provider,
@@ -142,6 +162,8 @@ export function listConfiguredProviders() {
142
162
  configured.push('gemini');
143
163
  if (process.env.DEEPSEEK_API_KEY)
144
164
  configured.push('deepseek');
165
+ if (process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY)
166
+ configured.push('bedrock');
145
167
  if (process.env.OLLAMA_BASE_URL || process.env.OLLAMA_HOST)
146
168
  configured.push('ollama');
147
169
  // Ollama is always available if running locally (default port)
@@ -166,6 +188,7 @@ export async function getFullStatus() {
166
188
  gemini: 'Google Gemini',
167
189
  ollama: 'Ollama (local)',
168
190
  deepseek: 'DeepSeek',
191
+ bedrock: 'AWS Bedrock',
169
192
  };
170
193
  if (provider === 'ollama') {
171
194
  return {