@theia/ai-core 1.63.0-next.52 → 1.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/agent-completion-notification-service.d.ts +69 -0
- package/lib/browser/agent-completion-notification-service.d.ts.map +1 -0
- package/lib/browser/agent-completion-notification-service.js +187 -0
- package/lib/browser/agent-completion-notification-service.js.map +1 -0
- package/lib/browser/agent-preferences.d.ts.map +1 -1
- package/lib/browser/agent-preferences.js +11 -0
- package/lib/browser/agent-preferences.js.map +1 -1
- package/lib/browser/ai-core-frontend-module.d.ts.map +1 -1
- package/lib/browser/ai-core-frontend-module.js +7 -1
- package/lib/browser/ai-core-frontend-module.js.map +1 -1
- package/lib/browser/ai-core-preferences.d.ts +3 -0
- package/lib/browser/ai-core-preferences.d.ts.map +1 -1
- package/lib/browser/ai-core-preferences.js +14 -1
- package/lib/browser/ai-core-preferences.js.map +1 -1
- package/lib/browser/frontend-language-model-registry.d.ts +5 -5
- package/lib/browser/frontend-language-model-registry.d.ts.map +1 -1
- package/lib/browser/frontend-language-model-registry.js +12 -5
- package/lib/browser/frontend-language-model-registry.js.map +1 -1
- package/lib/browser/frontend-language-model-registry.spec.d.ts +2 -0
- package/lib/browser/frontend-language-model-registry.spec.d.ts.map +1 -0
- package/lib/browser/frontend-language-model-registry.spec.js +248 -0
- package/lib/browser/frontend-language-model-registry.spec.js.map +1 -0
- package/lib/browser/index.d.ts +4 -0
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +4 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/os-notification-service.d.ts +96 -0
- package/lib/browser/os-notification-service.d.ts.map +1 -0
- package/lib/browser/os-notification-service.js +222 -0
- package/lib/browser/os-notification-service.js.map +1 -0
- package/lib/browser/window-blink-service.d.ts +41 -0
- package/lib/browser/window-blink-service.d.ts.map +1 -0
- package/lib/browser/window-blink-service.js +174 -0
- package/lib/browser/window-blink-service.js.map +1 -0
- package/lib/common/configurable-in-memory-resources.d.ts +2 -0
- package/lib/common/configurable-in-memory-resources.d.ts.map +1 -1
- package/lib/common/configurable-in-memory-resources.js +7 -0
- package/lib/common/configurable-in-memory-resources.js.map +1 -1
- package/lib/common/index.d.ts +1 -0
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +1 -0
- package/lib/common/index.js.map +1 -1
- package/lib/common/language-model-delegate.d.ts +2 -2
- package/lib/common/language-model-delegate.d.ts.map +1 -1
- package/lib/common/language-model-delegate.js.map +1 -1
- package/lib/common/language-model.d.ts +24 -3
- package/lib/common/language-model.d.ts.map +1 -1
- package/lib/common/language-model.js +4 -0
- package/lib/common/language-model.js.map +1 -1
- package/lib/common/notification-types.d.ts +7 -0
- package/lib/common/notification-types.d.ts.map +1 -0
- package/lib/common/notification-types.js +29 -0
- package/lib/common/notification-types.js.map +1 -0
- package/lib/common/prompt-service.d.ts +14 -4
- package/lib/common/prompt-service.d.ts.map +1 -1
- package/lib/common/prompt-service.js +78 -9
- package/lib/common/prompt-service.js.map +1 -1
- package/lib/common/prompt-service.spec.js +3 -0
- package/lib/common/prompt-service.spec.js.map +1 -1
- package/lib/common/settings-service.d.ts +6 -0
- package/lib/common/settings-service.d.ts.map +1 -1
- package/lib/common/settings-service.js.map +1 -1
- package/package.json +10 -10
- package/src/browser/agent-completion-notification-service.ts +242 -0
- package/src/browser/agent-preferences.ts +14 -0
- package/src/browser/ai-core-frontend-module.ts +8 -0
- package/src/browser/ai-core-preferences.ts +20 -0
- package/src/browser/frontend-language-model-registry.spec.ts +298 -0
- package/src/browser/frontend-language-model-registry.ts +14 -8
- package/src/browser/index.ts +4 -0
- package/src/browser/os-notification-service.ts +271 -0
- package/src/browser/window-blink-service.ts +195 -0
- package/src/common/configurable-in-memory-resources.ts +8 -0
- package/src/common/index.ts +1 -0
- package/src/common/language-model-delegate.ts +5 -2
- package/src/common/language-model.ts +12 -3
- package/src/common/notification-types.ts +31 -0
- package/src/common/prompt-service.spec.ts +4 -1
- package/src/common/prompt-service.ts +101 -12
- package/src/common/settings-service.ts +6 -0
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import { Event, Emitter, URI } from '@theia/core';
|
|
17
|
+
import { Event, Emitter, URI, ILogger } from '@theia/core';
|
|
18
18
|
import { inject, injectable, optional, postConstruct } from '@theia/core/shared/inversify';
|
|
19
19
|
import { AIVariableArg, AIVariableContext, AIVariableService, createAIResolveVariableCache, ResolvedAIVariable } from './variable-service';
|
|
20
20
|
import { ToolInvocationRegistry } from './tool-invocation-registry';
|
|
@@ -363,12 +363,21 @@ export interface PromptService {
|
|
|
363
363
|
getVariantIds(promptVariantSetId: string): string[];
|
|
364
364
|
|
|
365
365
|
/**
|
|
366
|
-
* Gets the
|
|
366
|
+
* Gets the explicitly selected variant ID for a prompt fragment from settings.
|
|
367
|
+
* This returns only the variant that was explicitly selected in settings, not the default.
|
|
367
368
|
* @param promptVariantSetId The prompt variant set id
|
|
368
|
-
* @returns The selected variant ID
|
|
369
|
+
* @returns The selected variant ID from settings, or undefined if none is selected
|
|
369
370
|
*/
|
|
370
371
|
getSelectedVariantId(promptVariantSetId: string): Promise<string | undefined>;
|
|
371
372
|
|
|
373
|
+
/**
|
|
374
|
+
* Gets the effective variant ID that is guaranteed to be valid if one exists.
|
|
375
|
+
* This checks if the selected variant ID is valid, and falls back to the default variant if it isn't.
|
|
376
|
+
* @param promptVariantSetId The prompt variant set id
|
|
377
|
+
* @returns A valid variant ID if one exists, or undefined if no valid variant can be found
|
|
378
|
+
*/
|
|
379
|
+
getEffectiveVariantId(promptVariantSetId: string): Promise<string | undefined>;
|
|
380
|
+
|
|
372
381
|
/**
|
|
373
382
|
* Gets the default variant ID of the given set
|
|
374
383
|
* @param promptVariantSetId The prompt variant set id
|
|
@@ -408,6 +417,8 @@ export interface PromptService {
|
|
|
408
417
|
|
|
409
418
|
@injectable()
|
|
410
419
|
export class PromptServiceImpl implements PromptService {
|
|
420
|
+
@inject(ILogger)
|
|
421
|
+
protected readonly logger: ILogger;
|
|
411
422
|
@inject(AISettingsService) @optional()
|
|
412
423
|
protected readonly settingsService: AISettingsService | undefined;
|
|
413
424
|
|
|
@@ -505,17 +516,48 @@ export class PromptServiceImpl implements PromptService {
|
|
|
505
516
|
}
|
|
506
517
|
}
|
|
507
518
|
}
|
|
508
|
-
return
|
|
519
|
+
return undefined;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
async getEffectiveVariantId(fragmentId: string): Promise<string | undefined> {
|
|
523
|
+
const selectedVariantId = await this.getSelectedVariantId(fragmentId);
|
|
524
|
+
|
|
525
|
+
// Check if the selected variant actually exists
|
|
526
|
+
if (selectedVariantId) {
|
|
527
|
+
const variantIds = this.getVariantIds(fragmentId);
|
|
528
|
+
if (!variantIds.includes(selectedVariantId)) {
|
|
529
|
+
this.logger.warn(`Selected variant '${selectedVariantId}' for prompt set '${fragmentId}' does not exist. Falling back to default variant.`);
|
|
530
|
+
} else {
|
|
531
|
+
return selectedVariantId;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
// Fall back to default variant
|
|
536
|
+
const defaultVariantId = this.getDefaultVariantId(fragmentId);
|
|
537
|
+
if (defaultVariantId) {
|
|
538
|
+
const variantIds = this.getVariantIds(fragmentId);
|
|
539
|
+
if (!variantIds.includes(defaultVariantId)) {
|
|
540
|
+
this.logger.error(`Default variant '${defaultVariantId}' for prompt set '${fragmentId}' does not exist.`);
|
|
541
|
+
return undefined;
|
|
542
|
+
}
|
|
543
|
+
return defaultVariantId;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// No valid selected or default variant
|
|
547
|
+
if (this.getVariantIds(fragmentId).length > 0) {
|
|
548
|
+
this.logger.error(`No valid selected or default variant found for prompt set '${fragmentId}'.`);
|
|
549
|
+
}
|
|
550
|
+
return undefined;
|
|
509
551
|
}
|
|
510
552
|
|
|
511
553
|
protected async resolvePotentialSystemPrompt(promptFragmentId: string): Promise<PromptFragment | undefined> {
|
|
512
554
|
if (this._promptVariantSetsMap.has(promptFragmentId)) {
|
|
513
|
-
// This is a systemPrompt find the
|
|
514
|
-
const
|
|
515
|
-
if (
|
|
555
|
+
// This is a systemPrompt find the effective variant
|
|
556
|
+
const effectiveVariantId = await this.getEffectiveVariantId(promptFragmentId);
|
|
557
|
+
if (effectiveVariantId === undefined) {
|
|
516
558
|
return undefined;
|
|
517
559
|
}
|
|
518
|
-
return this.getPromptFragment(
|
|
560
|
+
return this.getPromptFragment(effectiveVariantId);
|
|
519
561
|
}
|
|
520
562
|
return this.getPromptFragment(promptFragmentId);
|
|
521
563
|
}
|
|
@@ -725,8 +767,29 @@ export class PromptServiceImpl implements PromptService {
|
|
|
725
767
|
this._onPromptsChangeEmitter.fire();
|
|
726
768
|
}
|
|
727
769
|
|
|
728
|
-
getVariantIds(
|
|
729
|
-
|
|
770
|
+
getVariantIds(variantSetId: string): string[] {
|
|
771
|
+
const builtInVariants = this._promptVariantSetsMap.get(variantSetId) || [];
|
|
772
|
+
|
|
773
|
+
// Check for custom variants from customization service
|
|
774
|
+
if (this.customizationService) {
|
|
775
|
+
const allCustomizedIds = this.customizationService.getCustomizedPromptFragmentIds();
|
|
776
|
+
// Find customizations that start with the variant set ID
|
|
777
|
+
// These are considered variants of this variant set
|
|
778
|
+
// Only include IDs that are not the variant set ID itself, start with the variant set ID,
|
|
779
|
+
// and are not customizations of existing variants in this set
|
|
780
|
+
const customVariants = allCustomizedIds.filter(id =>
|
|
781
|
+
id !== variantSetId &&
|
|
782
|
+
id.startsWith(variantSetId) &&
|
|
783
|
+
!builtInVariants.includes(id)
|
|
784
|
+
);
|
|
785
|
+
|
|
786
|
+
if (customVariants.length > 0) {
|
|
787
|
+
// Combine built-in variants with custom variants, without modifying the internal state
|
|
788
|
+
return [...builtInVariants, ...customVariants];
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
return builtInVariants;
|
|
730
793
|
}
|
|
731
794
|
|
|
732
795
|
getDefaultVariantId(promptVariantSetId: string): string | undefined {
|
|
@@ -734,7 +797,31 @@ export class PromptServiceImpl implements PromptService {
|
|
|
734
797
|
}
|
|
735
798
|
|
|
736
799
|
getPromptVariantSets(): Map<string, string[]> {
|
|
737
|
-
|
|
800
|
+
const result = new Map(this._promptVariantSetsMap);
|
|
801
|
+
|
|
802
|
+
// Check for custom variants from customization service
|
|
803
|
+
if (this.customizationService) {
|
|
804
|
+
const allCustomizedIds = this.customizationService.getCustomizedPromptFragmentIds();
|
|
805
|
+
|
|
806
|
+
// Add custom variants to existing variant sets
|
|
807
|
+
for (const [variantSetId, variants] of result.entries()) {
|
|
808
|
+
// Filter out customized fragments that are just customizations of existing variants
|
|
809
|
+
// so we don't treat them as separate variants themselves
|
|
810
|
+
// Only include IDs that are not the variant set ID itself, start with the variant set ID,
|
|
811
|
+
// and are not customizations of existing variants in this set
|
|
812
|
+
const customVariants = allCustomizedIds.filter(id =>
|
|
813
|
+
id !== variantSetId &&
|
|
814
|
+
id.startsWith(variantSetId) &&
|
|
815
|
+
!variants.includes(id)
|
|
816
|
+
);
|
|
817
|
+
|
|
818
|
+
if (customVariants.length > 0) {
|
|
819
|
+
// Create a new array without modifying the original
|
|
820
|
+
result.set(variantSetId, [...variants, ...customVariants]);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
return result;
|
|
738
825
|
}
|
|
739
826
|
|
|
740
827
|
addBuiltInPromptFragment(promptFragment: BasePromptFragment, promptVariantSetId?: string, isDefault: boolean = false): void {
|
|
@@ -861,7 +948,9 @@ export class PromptServiceImpl implements PromptService {
|
|
|
861
948
|
}
|
|
862
949
|
|
|
863
950
|
async resetToBuiltIn(fragmentId: string): Promise<void> {
|
|
864
|
-
|
|
951
|
+
const builtIn = this._builtInFragments.find(b => b.id === fragmentId);
|
|
952
|
+
// Only reset this if it has a built-in, otherwise a delete would be the correct operation
|
|
953
|
+
if (this.customizationService && builtIn) {
|
|
865
954
|
await this.customizationService.removeAllPromptFragmentCustomizations(fragmentId);
|
|
866
955
|
}
|
|
867
956
|
}
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
import { Event } from '@theia/core';
|
|
17
17
|
import { LanguageModelRequirement } from './language-model';
|
|
18
|
+
import { NotificationType } from './notification-types';
|
|
18
19
|
|
|
19
20
|
export const AISettingsService = Symbol('AISettingsService');
|
|
20
21
|
/**
|
|
@@ -35,4 +36,9 @@ export interface AgentSettings {
|
|
|
35
36
|
* If a main template is not present in this mapping, it means the main template is used.
|
|
36
37
|
*/
|
|
37
38
|
selectedVariants?: Record<string, string>;
|
|
39
|
+
/**
|
|
40
|
+
* Configuration for completion notifications when the agent finishes a task.
|
|
41
|
+
* If undefined, defaults to 'off'.
|
|
42
|
+
*/
|
|
43
|
+
completionNotification?: NotificationType;
|
|
38
44
|
}
|