@theia/ai-core 1.61.0 → 1.62.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.
Files changed (69) hide show
  1. package/lib/browser/ai-core-frontend-module.js +2 -2
  2. package/lib/browser/ai-core-frontend-module.js.map +1 -1
  3. package/lib/browser/frontend-language-model-service.d.ts +1 -1
  4. package/lib/browser/frontend-language-model-service.d.ts.map +1 -1
  5. package/lib/browser/frontend-language-model-service.js.map +1 -1
  6. package/lib/browser/frontend-prompt-customization-service.d.ts +142 -48
  7. package/lib/browser/frontend-prompt-customization-service.d.ts.map +1 -1
  8. package/lib/browser/frontend-prompt-customization-service.js +452 -153
  9. package/lib/browser/frontend-prompt-customization-service.js.map +1 -1
  10. package/lib/browser/prompttemplate-contribution.d.ts +1 -2
  11. package/lib/browser/prompttemplate-contribution.d.ts.map +1 -1
  12. package/lib/browser/prompttemplate-contribution.js +5 -9
  13. package/lib/browser/prompttemplate-contribution.js.map +1 -1
  14. package/lib/common/agent-service.d.ts.map +1 -1
  15. package/lib/common/agent-service.js +14 -2
  16. package/lib/common/agent-service.js.map +1 -1
  17. package/lib/common/agent.d.ts +8 -3
  18. package/lib/common/agent.d.ts.map +1 -1
  19. package/lib/common/agent.js.map +1 -1
  20. package/lib/common/index.d.ts +0 -1
  21. package/lib/common/index.d.ts.map +1 -1
  22. package/lib/common/index.js +0 -1
  23. package/lib/common/index.js.map +1 -1
  24. package/lib/common/language-model-interaction-model.d.ts +74 -0
  25. package/lib/common/language-model-interaction-model.d.ts.map +1 -0
  26. package/lib/common/language-model-interaction-model.js +3 -0
  27. package/lib/common/language-model-interaction-model.js.map +1 -0
  28. package/lib/common/language-model-service.d.ts +26 -3
  29. package/lib/common/language-model-service.d.ts.map +1 -1
  30. package/lib/common/language-model-service.js +83 -6
  31. package/lib/common/language-model-service.js.map +1 -1
  32. package/lib/common/language-model-util.d.ts +3 -2
  33. package/lib/common/language-model-util.d.ts.map +1 -1
  34. package/lib/common/language-model-util.js +8 -0
  35. package/lib/common/language-model-util.js.map +1 -1
  36. package/lib/common/language-model.d.ts +25 -2
  37. package/lib/common/language-model.d.ts.map +1 -1
  38. package/lib/common/language-model.js +3 -1
  39. package/lib/common/language-model.js.map +1 -1
  40. package/lib/common/prompt-service.d.ts +332 -126
  41. package/lib/common/prompt-service.d.ts.map +1 -1
  42. package/lib/common/prompt-service.js +363 -102
  43. package/lib/common/prompt-service.js.map +1 -1
  44. package/lib/common/prompt-service.spec.js +104 -114
  45. package/lib/common/prompt-service.spec.js.map +1 -1
  46. package/lib/common/prompt-variable-contribution.d.ts +1 -2
  47. package/lib/common/prompt-variable-contribution.d.ts.map +1 -1
  48. package/lib/common/prompt-variable-contribution.js +17 -26
  49. package/lib/common/prompt-variable-contribution.js.map +1 -1
  50. package/package.json +10 -10
  51. package/src/browser/ai-core-frontend-module.ts +4 -4
  52. package/src/browser/frontend-language-model-service.ts +1 -1
  53. package/src/browser/frontend-prompt-customization-service.ts +574 -183
  54. package/src/browser/prompttemplate-contribution.ts +6 -9
  55. package/src/common/agent-service.ts +14 -4
  56. package/src/common/agent.ts +9 -3
  57. package/src/common/index.ts +0 -1
  58. package/src/common/language-model-interaction-model.ts +98 -0
  59. package/src/common/language-model-service.ts +115 -6
  60. package/src/common/language-model-util.ts +10 -2
  61. package/src/common/language-model.ts +28 -2
  62. package/src/common/prompt-service.spec.ts +108 -114
  63. package/src/common/prompt-service.ts +694 -221
  64. package/src/common/prompt-variable-contribution.ts +22 -27
  65. package/lib/common/communication-recording-service.d.ts +0 -30
  66. package/lib/common/communication-recording-service.d.ts.map +0 -1
  67. package/lib/common/communication-recording-service.js +0 -20
  68. package/lib/common/communication-recording-service.js.map +0 -1
  69. package/src/common/communication-recording-service.ts +0 -55
@@ -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
  import { CommandService, ILogger, nls } from '@theia/core';
17
- import { injectable, inject, optional } from '@theia/core/shared/inversify';
17
+ import { injectable, inject } from '@theia/core/shared/inversify';
18
18
  import * as monaco from '@theia/monaco-editor-core';
19
19
  import {
20
20
  AIVariable,
@@ -26,7 +26,7 @@ import {
26
26
  AIVariableResolverWithVariableDependencies,
27
27
  AIVariableArg
28
28
  } from './variable-service';
29
- import { PromptCustomizationService, PromptService } from './prompt-service';
29
+ import { isCustomizedPromptFragment, PromptService } from './prompt-service';
30
30
  import { PromptText } from './prompt-text';
31
31
 
32
32
  export const PROMPT_VARIABLE: AIVariable = {
@@ -47,9 +47,6 @@ export class PromptVariableContribution implements AIVariableContribution, AIVar
47
47
  @inject(PromptService)
48
48
  protected readonly promptService: PromptService;
49
49
 
50
- @inject(PromptCustomizationService) @optional()
51
- protected readonly promptCustomizationService: PromptCustomizationService;
52
-
53
50
  @inject(ILogger)
54
51
  protected logger: ILogger;
55
52
 
@@ -74,7 +71,7 @@ export class PromptVariableContribution implements AIVariableContribution, AIVar
74
71
  if (request.variable.name === PROMPT_VARIABLE.name) {
75
72
  const promptId = request.arg?.trim();
76
73
  if (promptId) {
77
- const resolvedPrompt = await this.promptService.getPromptFragment(promptId, undefined, context, resolveDependency);
74
+ const resolvedPrompt = await this.promptService.getResolvedPromptFragmentWithoutFunctions(promptId, undefined, context, resolveDependency);
78
75
  if (resolvedPrompt) {
79
76
  return {
80
77
  variable: request.variable,
@@ -121,26 +118,24 @@ export class PromptVariableContribution implements AIVariableContribution, AIVar
121
118
 
122
119
  const range = new monaco.Range(position.lineNumber, triggerCharIndex + 2, position.lineNumber, position.column);
123
120
 
124
- const customPromptIds = this.promptCustomizationService?.getCustomPromptTemplateIDs() ?? [];
125
- const builtinPromptIds = Object.keys(this.promptService.getAllPrompts());
126
-
127
- const customPromptCompletions = customPromptIds.map(promptId => ({
128
- label: promptId,
129
- kind: monaco.languages.CompletionItemKind.Enum,
130
- insertText: promptId,
131
- range,
132
- detail: nls.localize('theia/ai/core/promptVariable/completions/detail/custom', 'Custom prompt template'),
133
- sortText: `AAA${promptId}` // Sort before everything else including all built-in prompts
134
- }));
135
- const builtinPromptCompletions = builtinPromptIds.map(promptId => ({
136
- label: promptId,
137
- kind: monaco.languages.CompletionItemKind.Variable,
138
- insertText: promptId,
139
- range,
140
- detail: nls.localize('theia/ai/core/promptVariable/completions/detail/builtin', 'Built-in prompt template'),
141
- sortText: `AAB${promptId}` // Sort after all custom prompts but before others
142
- }));
143
-
144
- return [...customPromptCompletions, ...builtinPromptCompletions];
121
+ const activePrompts = this.promptService.getActivePromptFragments();
122
+ let builtinPromptCompletions: monaco.languages.CompletionItem[] | undefined = undefined;
123
+
124
+ if (activePrompts.length > 0) {
125
+ builtinPromptCompletions = [];
126
+ activePrompts.forEach(prompt => (builtinPromptCompletions!.push(
127
+ {
128
+ label: prompt.id,
129
+ kind: isCustomizedPromptFragment(prompt) ? monaco.languages.CompletionItemKind.Enum : monaco.languages.CompletionItemKind.Variable,
130
+ insertText: prompt.id,
131
+ range,
132
+ detail: isCustomizedPromptFragment(prompt) ?
133
+ nls.localize('theia/ai/core/promptVariable/completions/detail/custom', 'Customized prompt fragment') :
134
+ nls.localize('theia/ai/core/promptVariable/completions/detail/builtin', 'Built-in prompt fragment'),
135
+ sortText: `${prompt.id}`
136
+ })));
137
+ }
138
+
139
+ return builtinPromptCompletions;
145
140
  }
146
141
  }
@@ -1,30 +0,0 @@
1
- import { Event } from '@theia/core';
2
- import { LanguageModelMessage } from './language-model';
3
- export type CommunicationHistory = CommunicationHistoryEntry[];
4
- export interface CommunicationHistoryEntryBase {
5
- agentId: string;
6
- sessionId: string;
7
- timestamp: number;
8
- requestId: string;
9
- }
10
- export interface CommunicationHistoryEntry extends CommunicationHistoryEntryBase {
11
- request?: LanguageModelMessage[];
12
- response?: LanguageModelMessage[];
13
- responseTime?: number;
14
- }
15
- export type CommunicationRequestEntry = Omit<CommunicationHistoryEntry, 'response' | 'responseTime'>;
16
- export type CommunicationResponseEntry = Omit<CommunicationHistoryEntry, 'request'>;
17
- export type CommunicationRequestEntryParam = Omit<CommunicationRequestEntry, 'timestamp'> & Partial<Pick<CommunicationRequestEntry, 'timestamp'>>;
18
- export type CommunicationResponseEntryParam = Omit<CommunicationResponseEntry, 'timestamp'> & Partial<Pick<CommunicationResponseEntry, 'timestamp'>>;
19
- export declare const CommunicationRecordingService: unique symbol;
20
- export interface CommunicationRecordingService {
21
- recordRequest(requestEntry: CommunicationRequestEntryParam): void;
22
- readonly onDidRecordRequest: Event<CommunicationRequestEntry>;
23
- recordResponse(responseEntry: CommunicationResponseEntryParam): void;
24
- readonly onDidRecordResponse: Event<CommunicationResponseEntry>;
25
- getHistory(agentId: string): CommunicationHistory;
26
- getSessionHistory(sessionId: string): CommunicationHistory;
27
- clearHistory(): void;
28
- readonly onStructuralChange: Event<void>;
29
- }
30
- //# sourceMappingURL=communication-recording-service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"communication-recording-service.d.ts","sourceRoot":"","sources":["../../src/common/communication-recording-service.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,MAAM,oBAAoB,GAAG,yBAAyB,EAAE,CAAC;AAE/D,MAAM,WAAW,6BAA6B;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,yBAA0B,SAAQ,6BAA6B;IAC5E,OAAO,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACjC,QAAQ,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC,yBAAyB,EAAE,UAAU,GAAG,cAAc,CAAC,CAAC;AACrG,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAAC,yBAAyB,EAAE,SAAS,CAAC,CAAC;AAEpF,MAAM,MAAM,8BAA8B,GAAG,IAAI,CAAC,yBAAyB,EAAE,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,yBAAyB,EAAE,WAAW,CAAC,CAAC,CAAC;AAClJ,MAAM,MAAM,+BAA+B,GAAG,IAAI,CAAC,0BAA0B,EAAE,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,0BAA0B,EAAE,WAAW,CAAC,CAAC,CAAC;AAErJ,eAAO,MAAM,6BAA6B,eAA0C,CAAC;AACrF,MAAM,WAAW,6BAA6B;IAC1C,aAAa,CAAC,YAAY,EAAE,8BAA8B,GAAG,IAAI,CAAC;IAClE,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAE9D,cAAc,CAAC,aAAa,EAAE,+BAA+B,GAAG,IAAI,CAAC;IACrE,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAEhE,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB,CAAC;IAElD,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,oBAAoB,CAAC;IAE3D,YAAY,IAAI,IAAI,CAAC;IACrB,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;CAC5C"}
@@ -1,20 +0,0 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2024 EclipseSource GmbH.
4
- //
5
- // This program and the accompanying materials are made available under the
6
- // terms of the Eclipse Public License v. 2.0 which is available at
7
- // http://www.eclipse.org/legal/epl-2.0.
8
- //
9
- // This Source Code may also be made available under the following Secondary
10
- // Licenses when the conditions for such availability set forth in the Eclipse
11
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
- // with the GNU Classpath Exception which is available at
13
- // https://www.gnu.org/software/classpath/license.html.
14
- //
15
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.CommunicationRecordingService = void 0;
19
- exports.CommunicationRecordingService = Symbol('CommunicationRecordingService');
20
- //# sourceMappingURL=communication-recording-service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"communication-recording-service.js","sourceRoot":"","sources":["../../src/common/communication-recording-service.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AA0BnE,QAAA,6BAA6B,GAAG,MAAM,CAAC,+BAA+B,CAAC,CAAC"}
@@ -1,55 +0,0 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2024 EclipseSource GmbH.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { Event } from '@theia/core';
18
- import { LanguageModelMessage } from './language-model';
19
-
20
- export type CommunicationHistory = CommunicationHistoryEntry[];
21
-
22
- export interface CommunicationHistoryEntryBase {
23
- agentId: string;
24
- sessionId: string;
25
- timestamp: number;
26
- requestId: string;
27
- }
28
-
29
- export interface CommunicationHistoryEntry extends CommunicationHistoryEntryBase {
30
- request?: LanguageModelMessage[];
31
- response?: LanguageModelMessage[];
32
- responseTime?: number;
33
- }
34
-
35
- export type CommunicationRequestEntry = Omit<CommunicationHistoryEntry, 'response' | 'responseTime'>;
36
- export type CommunicationResponseEntry = Omit<CommunicationHistoryEntry, 'request'>;
37
-
38
- export type CommunicationRequestEntryParam = Omit<CommunicationRequestEntry, 'timestamp'> & Partial<Pick<CommunicationRequestEntry, 'timestamp'>>;
39
- export type CommunicationResponseEntryParam = Omit<CommunicationResponseEntry, 'timestamp'> & Partial<Pick<CommunicationResponseEntry, 'timestamp'>>;
40
-
41
- export const CommunicationRecordingService = Symbol('CommunicationRecordingService');
42
- export interface CommunicationRecordingService {
43
- recordRequest(requestEntry: CommunicationRequestEntryParam): void;
44
- readonly onDidRecordRequest: Event<CommunicationRequestEntry>;
45
-
46
- recordResponse(responseEntry: CommunicationResponseEntryParam): void;
47
- readonly onDidRecordResponse: Event<CommunicationResponseEntry>;
48
-
49
- getHistory(agentId: string): CommunicationHistory;
50
-
51
- getSessionHistory(sessionId: string): CommunicationHistory;
52
-
53
- clearHistory(): void;
54
- readonly onStructuralChange: Event<void>;
55
- }