@theia/ai-core 1.63.0-next.52 → 1.63.1

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 (80) hide show
  1. package/lib/browser/agent-completion-notification-service.d.ts +69 -0
  2. package/lib/browser/agent-completion-notification-service.d.ts.map +1 -0
  3. package/lib/browser/agent-completion-notification-service.js +187 -0
  4. package/lib/browser/agent-completion-notification-service.js.map +1 -0
  5. package/lib/browser/agent-preferences.d.ts.map +1 -1
  6. package/lib/browser/agent-preferences.js +11 -0
  7. package/lib/browser/agent-preferences.js.map +1 -1
  8. package/lib/browser/ai-core-frontend-module.d.ts.map +1 -1
  9. package/lib/browser/ai-core-frontend-module.js +8 -1
  10. package/lib/browser/ai-core-frontend-module.js.map +1 -1
  11. package/lib/browser/ai-core-preferences.d.ts +3 -0
  12. package/lib/browser/ai-core-preferences.d.ts.map +1 -1
  13. package/lib/browser/ai-core-preferences.js +14 -1
  14. package/lib/browser/ai-core-preferences.js.map +1 -1
  15. package/lib/browser/frontend-language-model-registry.d.ts +5 -5
  16. package/lib/browser/frontend-language-model-registry.d.ts.map +1 -1
  17. package/lib/browser/frontend-language-model-registry.js +12 -5
  18. package/lib/browser/frontend-language-model-registry.js.map +1 -1
  19. package/lib/browser/frontend-language-model-registry.spec.d.ts +2 -0
  20. package/lib/browser/frontend-language-model-registry.spec.d.ts.map +1 -0
  21. package/lib/browser/frontend-language-model-registry.spec.js +248 -0
  22. package/lib/browser/frontend-language-model-registry.spec.js.map +1 -0
  23. package/lib/browser/index.d.ts +4 -0
  24. package/lib/browser/index.d.ts.map +1 -1
  25. package/lib/browser/index.js +4 -0
  26. package/lib/browser/index.js.map +1 -1
  27. package/lib/browser/os-notification-service.d.ts +96 -0
  28. package/lib/browser/os-notification-service.d.ts.map +1 -0
  29. package/lib/browser/os-notification-service.js +222 -0
  30. package/lib/browser/os-notification-service.js.map +1 -0
  31. package/lib/browser/window-blink-service.d.ts +41 -0
  32. package/lib/browser/window-blink-service.d.ts.map +1 -0
  33. package/lib/browser/window-blink-service.js +174 -0
  34. package/lib/browser/window-blink-service.js.map +1 -0
  35. package/lib/common/configurable-in-memory-resources.d.ts +2 -0
  36. package/lib/common/configurable-in-memory-resources.d.ts.map +1 -1
  37. package/lib/common/configurable-in-memory-resources.js +7 -0
  38. package/lib/common/configurable-in-memory-resources.js.map +1 -1
  39. package/lib/common/index.d.ts +1 -0
  40. package/lib/common/index.d.ts.map +1 -1
  41. package/lib/common/index.js +1 -0
  42. package/lib/common/index.js.map +1 -1
  43. package/lib/common/language-model-delegate.d.ts +2 -2
  44. package/lib/common/language-model-delegate.d.ts.map +1 -1
  45. package/lib/common/language-model-delegate.js.map +1 -1
  46. package/lib/common/language-model.d.ts +24 -3
  47. package/lib/common/language-model.d.ts.map +1 -1
  48. package/lib/common/language-model.js +4 -0
  49. package/lib/common/language-model.js.map +1 -1
  50. package/lib/common/notification-types.d.ts +7 -0
  51. package/lib/common/notification-types.d.ts.map +1 -0
  52. package/lib/common/notification-types.js +29 -0
  53. package/lib/common/notification-types.js.map +1 -0
  54. package/lib/common/prompt-service.d.ts +14 -4
  55. package/lib/common/prompt-service.d.ts.map +1 -1
  56. package/lib/common/prompt-service.js +78 -9
  57. package/lib/common/prompt-service.js.map +1 -1
  58. package/lib/common/prompt-service.spec.js +3 -0
  59. package/lib/common/prompt-service.spec.js.map +1 -1
  60. package/lib/common/settings-service.d.ts +6 -0
  61. package/lib/common/settings-service.d.ts.map +1 -1
  62. package/lib/common/settings-service.js.map +1 -1
  63. package/package.json +10 -10
  64. package/src/browser/agent-completion-notification-service.ts +242 -0
  65. package/src/browser/agent-preferences.ts +14 -0
  66. package/src/browser/ai-core-frontend-module.ts +11 -1
  67. package/src/browser/ai-core-preferences.ts +20 -0
  68. package/src/browser/frontend-language-model-registry.spec.ts +298 -0
  69. package/src/browser/frontend-language-model-registry.ts +14 -8
  70. package/src/browser/index.ts +4 -0
  71. package/src/browser/os-notification-service.ts +271 -0
  72. package/src/browser/window-blink-service.ts +195 -0
  73. package/src/common/configurable-in-memory-resources.ts +8 -0
  74. package/src/common/index.ts +1 -0
  75. package/src/common/language-model-delegate.ts +5 -2
  76. package/src/common/language-model.ts +12 -3
  77. package/src/common/notification-types.ts +31 -0
  78. package/src/common/prompt-service.spec.ts +4 -1
  79. package/src/common/prompt-service.ts +101 -12
  80. package/src/common/settings-service.ts +6 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontend-language-model-registry.spec.d.ts","sourceRoot":"","sources":["../../src/browser/frontend-language-model-registry.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,248 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2025 EclipseSource.
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
+ const jsdom_1 = require("@theia/core/lib/browser/test/jsdom");
19
+ let disableJSDOM = (0, jsdom_1.enableJSDOM)();
20
+ const frontend_application_config_provider_1 = require("@theia/core/lib/browser/frontend-application-config-provider");
21
+ frontend_application_config_provider_1.FrontendApplicationConfigProvider.set({});
22
+ const chai_1 = require("chai");
23
+ disableJSDOM();
24
+ function isErrorObject(obj) {
25
+ return !!obj && typeof obj === 'object' && 'error' in obj && 'message' in obj;
26
+ }
27
+ // This class provides a minimal implementation focused solely on testing the toolCall method.
28
+ // We cannot extend FrontendLanguageModelRegistryImpl directly due to issues in the test environment:
29
+ // - FrontendLanguageModelRegistryImpl imports dependencies that transitively depend on 'p-queue'
30
+ // - p-queue is an ESM-only module that cannot be loaded in the current test environment
31
+ class TestableLanguageModelRegistry {
32
+ constructor() {
33
+ this.requests = new Map();
34
+ }
35
+ async toolCall(id, toolId, arg_string) {
36
+ var _a;
37
+ if (!this.requests.has(id)) {
38
+ return { error: true, message: `No request found for ID '${id}'. The request may have been cancelled or completed.` };
39
+ }
40
+ const request = this.requests.get(id);
41
+ const tool = (_a = request.tools) === null || _a === void 0 ? void 0 : _a.find(t => t.id === toolId);
42
+ if (tool) {
43
+ try {
44
+ return await tool.handler(arg_string);
45
+ }
46
+ catch (error) {
47
+ const errorMessage = error instanceof Error ? error.message : String(error);
48
+ return { error: true, message: `Error executing tool '${toolId}': ${errorMessage}` };
49
+ }
50
+ ;
51
+ }
52
+ return { error: true, message: `Tool '${toolId}' not found in the available tools for this request.` };
53
+ }
54
+ // Test helper method
55
+ setRequest(id, request) {
56
+ this.requests.set(id, request);
57
+ }
58
+ }
59
+ describe('FrontendLanguageModelRegistryImpl toolCall functionality', () => {
60
+ let registry;
61
+ before(() => {
62
+ disableJSDOM = (0, jsdom_1.enableJSDOM)();
63
+ });
64
+ after(() => {
65
+ disableJSDOM();
66
+ });
67
+ beforeEach(() => {
68
+ registry = new TestableLanguageModelRegistry();
69
+ });
70
+ describe('toolCall', () => {
71
+ it('should return error object when request ID does not exist', async () => {
72
+ const result = await registry.toolCall('nonexistent-id', 'test-tool', '{}');
73
+ (0, chai_1.expect)(result).to.be.an('object');
74
+ (0, chai_1.expect)(isErrorObject(result)).to.be.true;
75
+ if (isErrorObject(result)) {
76
+ (0, chai_1.expect)(result.error).to.be.true;
77
+ (0, chai_1.expect)(result.message).to.include('No request found for ID \'nonexistent-id\'');
78
+ (0, chai_1.expect)(result.message).to.include('The request may have been cancelled or completed');
79
+ }
80
+ });
81
+ it('should return error object when tool is not found', async () => {
82
+ // Set up a request without the requested tool
83
+ const requestId = 'test-request-id';
84
+ const mockRequest = {
85
+ messages: [],
86
+ tools: [
87
+ {
88
+ id: 'different-tool',
89
+ name: 'Different Tool',
90
+ description: 'A different tool',
91
+ parameters: {
92
+ type: 'object',
93
+ properties: {}
94
+ },
95
+ handler: () => Promise.resolve('success')
96
+ }
97
+ ]
98
+ };
99
+ registry.setRequest(requestId, mockRequest);
100
+ const result = await registry.toolCall(requestId, 'nonexistent-tool', '{}');
101
+ (0, chai_1.expect)(result).to.be.an('object');
102
+ (0, chai_1.expect)(isErrorObject(result)).to.be.true;
103
+ if (isErrorObject(result)) {
104
+ (0, chai_1.expect)(result.error).to.be.true;
105
+ (0, chai_1.expect)(result.message).to.include('Tool \'nonexistent-tool\' not found in the available tools for this request');
106
+ }
107
+ });
108
+ it('should call tool handler successfully when tool exists', async () => {
109
+ const requestId = 'test-request-id';
110
+ const toolId = 'test-tool';
111
+ const expectedResult = 'tool execution result';
112
+ const mockTool = {
113
+ id: toolId,
114
+ name: 'Test Tool',
115
+ description: 'A test tool',
116
+ parameters: {
117
+ type: 'object',
118
+ properties: {}
119
+ },
120
+ handler: (args) => Promise.resolve(expectedResult)
121
+ };
122
+ const mockRequest = {
123
+ messages: [],
124
+ tools: [mockTool]
125
+ };
126
+ registry.setRequest(requestId, mockRequest);
127
+ const result = await registry.toolCall(requestId, toolId, '{}');
128
+ (0, chai_1.expect)(result).to.equal(expectedResult);
129
+ });
130
+ it('should handle synchronous tool handler errors gracefully', async () => {
131
+ const requestId = 'test-request-id';
132
+ const toolId = 'error-tool';
133
+ const errorMessage = 'Tool execution failed';
134
+ const mockTool = {
135
+ id: toolId,
136
+ name: 'Error Tool',
137
+ description: 'A tool that throws an error',
138
+ parameters: {
139
+ type: 'object',
140
+ properties: {}
141
+ },
142
+ handler: () => {
143
+ throw new Error(errorMessage);
144
+ }
145
+ };
146
+ const mockRequest = {
147
+ messages: [],
148
+ tools: [mockTool]
149
+ };
150
+ registry.setRequest(requestId, mockRequest);
151
+ const result = await registry.toolCall(requestId, toolId, '{}');
152
+ (0, chai_1.expect)(result).to.be.an('object');
153
+ (0, chai_1.expect)(isErrorObject(result)).to.be.true;
154
+ if (isErrorObject(result)) {
155
+ (0, chai_1.expect)(result.error).to.be.true;
156
+ (0, chai_1.expect)(result.message).to.include(`Error executing tool '${toolId}': ${errorMessage}`);
157
+ }
158
+ });
159
+ it('should handle non-Error exceptions gracefully', async () => {
160
+ const requestId = 'test-request-id';
161
+ const toolId = 'string-error-tool';
162
+ const errorMessage = 'String error';
163
+ const mockTool = {
164
+ id: toolId,
165
+ name: 'String Error Tool',
166
+ description: 'A tool that throws a string',
167
+ parameters: {
168
+ type: 'object',
169
+ properties: {}
170
+ },
171
+ handler: () => {
172
+ // eslint-disable-next-line no-throw-literal
173
+ throw errorMessage;
174
+ }
175
+ };
176
+ const mockRequest = {
177
+ messages: [],
178
+ tools: [mockTool]
179
+ };
180
+ registry.setRequest(requestId, mockRequest);
181
+ const result = await registry.toolCall(requestId, toolId, '{}');
182
+ (0, chai_1.expect)(result).to.be.an('object');
183
+ (0, chai_1.expect)(isErrorObject(result)).to.be.true;
184
+ if (isErrorObject(result)) {
185
+ (0, chai_1.expect)(result.error).to.be.true;
186
+ (0, chai_1.expect)(result.message).to.include(`Error executing tool '${toolId}': ${errorMessage}`);
187
+ }
188
+ });
189
+ it('should handle asynchronous tool handler errors gracefully', async () => {
190
+ const requestId = 'test-request-id';
191
+ const toolId = 'async-error-tool';
192
+ const errorMessage = 'Async tool execution failed';
193
+ const mockTool = {
194
+ id: toolId,
195
+ name: 'Async Error Tool',
196
+ description: 'A tool that returns a rejected promise',
197
+ parameters: {
198
+ type: 'object',
199
+ properties: {}
200
+ },
201
+ handler: () => Promise.reject(new Error(errorMessage))
202
+ };
203
+ const mockRequest = {
204
+ messages: [],
205
+ tools: [mockTool]
206
+ };
207
+ registry.setRequest(requestId, mockRequest);
208
+ const result = await registry.toolCall(requestId, toolId, '{}');
209
+ (0, chai_1.expect)(result).to.be.an('object');
210
+ (0, chai_1.expect)(isErrorObject(result)).to.be.true;
211
+ if (isErrorObject(result)) {
212
+ (0, chai_1.expect)(result.error).to.be.true;
213
+ (0, chai_1.expect)(result.message).to.include(`Error executing tool '${toolId}': ${errorMessage}`);
214
+ }
215
+ });
216
+ it('should handle tool handler with no tools array', async () => {
217
+ const requestId = 'test-request-id';
218
+ const mockRequest = {
219
+ messages: []
220
+ // No tools property
221
+ };
222
+ registry.setRequest(requestId, mockRequest);
223
+ const result = await registry.toolCall(requestId, 'any-tool', '{}');
224
+ (0, chai_1.expect)(result).to.be.an('object');
225
+ (0, chai_1.expect)(isErrorObject(result)).to.be.true;
226
+ if (isErrorObject(result)) {
227
+ (0, chai_1.expect)(result.error).to.be.true;
228
+ (0, chai_1.expect)(result.message).to.include('Tool \'any-tool\' not found in the available tools for this request');
229
+ }
230
+ });
231
+ it('should handle tool handler with empty tools array', async () => {
232
+ const requestId = 'test-request-id';
233
+ const mockRequest = {
234
+ messages: [],
235
+ tools: []
236
+ };
237
+ registry.setRequest(requestId, mockRequest);
238
+ const result = await registry.toolCall(requestId, 'any-tool', '{}');
239
+ (0, chai_1.expect)(result).to.be.an('object');
240
+ (0, chai_1.expect)(isErrorObject(result)).to.be.true;
241
+ if (isErrorObject(result)) {
242
+ (0, chai_1.expect)(result.error).to.be.true;
243
+ (0, chai_1.expect)(result.message).to.include('Tool \'any-tool\' not found in the available tools for this request');
244
+ }
245
+ });
246
+ });
247
+ });
248
+ //# sourceMappingURL=frontend-language-model-registry.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontend-language-model-registry.spec.js","sourceRoot":"","sources":["../../src/browser/frontend-language-model-registry.spec.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oCAAoC;AACpC,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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,CAAC,CAAC,CAAC"}
@@ -1,4 +1,8 @@
1
+ export * from './agent-completion-notification-service';
2
+ export * from './os-notification-service';
3
+ export * from './window-blink-service';
1
4
  export * from './ai-activation-service';
5
+ export * from './ai-command-handler-factory';
2
6
  export * from './ai-core-frontend-application-contribution';
3
7
  export * from './ai-core-frontend-module';
4
8
  export * from './ai-core-preferences';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAgBA,cAAc,yBAAyB,CAAC;AACxC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sCAAsC,CAAC;AACrD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAgBA,cAAc,yCAAyC,CAAC;AACxD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6CAA6C,CAAC;AAC5D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sCAAsC,CAAC;AACrD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC"}
@@ -16,7 +16,11 @@
16
16
  // *****************************************************************************
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const tslib_1 = require("tslib");
19
+ tslib_1.__exportStar(require("./agent-completion-notification-service"), exports);
20
+ tslib_1.__exportStar(require("./os-notification-service"), exports);
21
+ tslib_1.__exportStar(require("./window-blink-service"), exports);
19
22
  tslib_1.__exportStar(require("./ai-activation-service"), exports);
23
+ tslib_1.__exportStar(require("./ai-command-handler-factory"), exports);
20
24
  tslib_1.__exportStar(require("./ai-core-frontend-application-contribution"), exports);
21
25
  tslib_1.__exportStar(require("./ai-core-frontend-module"), exports);
22
26
  tslib_1.__exportStar(require("./ai-core-preferences"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/browser/index.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;;;AAEhF,kEAAwC;AACxC,sFAA4D;AAC5D,oEAA0C;AAC1C,gEAAsC;AACtC,gEAAsC;AACtC,iEAAuC;AACvC,6EAAmD;AACnD,sEAA4C;AAC5C,wEAA8C;AAC9C,wEAA8C;AAC9C,+EAAqD;AACrD,sEAA4C;AAC5C,yEAA+C;AAC/C,2EAAiD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/browser/index.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;;;AAEhF,kFAAwD;AACxD,oEAA0C;AAC1C,iEAAuC;AACvC,kEAAwC;AACxC,uEAA6C;AAC7C,sFAA4D;AAC5D,oEAA0C;AAC1C,gEAAsC;AACtC,gEAAsC;AACtC,iEAAuC;AACvC,6EAAmD;AACnD,sEAA4C;AAC5C,wEAA8C;AAC9C,wEAA8C;AAC9C,+EAAqD;AACrD,sEAA4C;AAC5C,yEAA+C;AAC/C,2EAAiD"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Configuration options for OS notifications
3
+ */
4
+ export interface OSNotificationOptions {
5
+ /** The notification body text */
6
+ body?: string;
7
+ /** Icon to display with the notification */
8
+ icon?: string;
9
+ /** Whether the notification should be silent */
10
+ silent?: boolean;
11
+ /** Tag to group notifications */
12
+ tag?: string;
13
+ /** Whether the notification requires user interaction to dismiss */
14
+ requireInteraction?: boolean;
15
+ /** Custom data to associate with the notification */
16
+ data?: unknown;
17
+ }
18
+ /**
19
+ * Result of an OS notification attempt
20
+ */
21
+ export interface OSNotificationResult {
22
+ /** Whether the notification was successfully shown */
23
+ success: boolean;
24
+ /** Error message if the notification failed */
25
+ error?: string;
26
+ /** The created notification instance (if successful) */
27
+ notification?: Notification;
28
+ }
29
+ /**
30
+ * Service to handle OS-level notifications across different platforms
31
+ * Provides fallback mechanisms for environments where notifications are unavailable
32
+ */
33
+ export declare class OSNotificationService {
34
+ private isElectron;
35
+ constructor();
36
+ /**
37
+ * Show an OS-level notification with the given title and options
38
+ *
39
+ * @param title The notification title
40
+ * @param options Optional notification configuration
41
+ * @returns Promise resolving to the notification result
42
+ */
43
+ showNotification(title: string, options?: OSNotificationOptions): Promise<OSNotificationResult>;
44
+ /**
45
+ * Check if notification permission is granted
46
+ *
47
+ * @returns The current notification permission state
48
+ */
49
+ getPermissionStatus(): NotificationPermission;
50
+ /**
51
+ * Request notification permission from the user
52
+ *
53
+ * @returns Promise resolving to the permission state
54
+ */
55
+ requestPermission(): Promise<NotificationPermission>;
56
+ /**
57
+ * Check if OS notifications are supported in the current environment
58
+ *
59
+ * @returns true if notifications are supported, false otherwise
60
+ */
61
+ isNotificationSupported(): boolean;
62
+ /**
63
+ * Show a notification specifically for agent completion
64
+ * This is a convenience method with pre-configured options for agent notifications
65
+ *
66
+ * @param agentName The name of the agent that completed
67
+ * @param taskDescription Optional description of the completed task
68
+ * @returns Promise resolving to the notification result
69
+ */
70
+ showAgentCompletionNotification(agentName: string, taskDescription?: string): Promise<OSNotificationResult>;
71
+ /**
72
+ * Ensure notification permission is granted
73
+ *
74
+ * @returns Promise resolving to the permission state
75
+ */
76
+ private ensurePermission;
77
+ /**
78
+ * Create a native notification with the given title and options
79
+ *
80
+ * @param title The notification title
81
+ * @param options The notification options
82
+ * @returns Promise resolving to the created notification
83
+ */
84
+ private createNotification;
85
+ /**
86
+ * Attempt to focus the application window when notification is clicked
87
+ */
88
+ private focusApplicationWindow;
89
+ /**
90
+ * Get the icon URL for agent completion notifications
91
+ *
92
+ * @returns The icon URL or undefined if not available
93
+ */
94
+ private getAgentCompletionIcon;
95
+ }
96
+ //# sourceMappingURL=os-notification-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"os-notification-service.d.ts","sourceRoot":"","sources":["../../src/browser/os-notification-service.ts"],"names":[],"mappings":"AAoBA;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iCAAiC;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,qDAAqD;IACrD,IAAI,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,sDAAsD;IACtD,OAAO,EAAE,OAAO,CAAC;IACjB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,YAAY,CAAC,EAAE,YAAY,CAAC;CAC/B;AAED;;;GAGG;AACH,qBACa,qBAAqB;IAE9B,OAAO,CAAC,UAAU,CAAU;;IAM5B;;;;;;OAMG;IACG,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAgCzG;;;;OAIG;IACH,mBAAmB,IAAI,sBAAsB;IAO7C;;;;OAIG;IACG,iBAAiB,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAkB1D;;;;OAIG;IACH,uBAAuB,IAAI,OAAO;IAIlC;;;;;;;OAOG;IACG,+BAA+B,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAsBjH;;;;OAIG;YACW,gBAAgB;IAc9B;;;;;;OAMG;YACW,kBAAkB;IAyChC;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAc9B;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;CAKjC"}
@@ -0,0 +1,222 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2025 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.OSNotificationService = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const inversify_1 = require("@theia/core/shared/inversify");
21
+ const nls_1 = require("@theia/core/lib/common/nls");
22
+ const core_1 = require("@theia/core");
23
+ /**
24
+ * Service to handle OS-level notifications across different platforms
25
+ * Provides fallback mechanisms for environments where notifications are unavailable
26
+ */
27
+ let OSNotificationService = class OSNotificationService {
28
+ constructor() {
29
+ this.isElectron = core_1.environment.electron.is();
30
+ }
31
+ /**
32
+ * Show an OS-level notification with the given title and options
33
+ *
34
+ * @param title The notification title
35
+ * @param options Optional notification configuration
36
+ * @returns Promise resolving to the notification result
37
+ */
38
+ async showNotification(title, options = {}) {
39
+ try {
40
+ if (!this.isNotificationSupported()) {
41
+ return {
42
+ success: false,
43
+ error: 'Notifications are not supported in this environment'
44
+ };
45
+ }
46
+ const permission = await this.ensurePermission();
47
+ if (permission !== 'granted') {
48
+ return {
49
+ success: false,
50
+ error: `Notification permission ${permission}`
51
+ };
52
+ }
53
+ const notification = await this.createNotification(title, options);
54
+ return {
55
+ success: true,
56
+ notification
57
+ };
58
+ }
59
+ catch (error) {
60
+ console.error('Failed to show OS notification:', error);
61
+ return {
62
+ success: false,
63
+ error: error instanceof Error ? error.message : 'Unknown error occurred'
64
+ };
65
+ }
66
+ }
67
+ /**
68
+ * Check if notification permission is granted
69
+ *
70
+ * @returns The current notification permission state
71
+ */
72
+ getPermissionStatus() {
73
+ if (!this.isNotificationSupported()) {
74
+ return 'denied';
75
+ }
76
+ return Notification.permission;
77
+ }
78
+ /**
79
+ * Request notification permission from the user
80
+ *
81
+ * @returns Promise resolving to the permission state
82
+ */
83
+ async requestPermission() {
84
+ if (!this.isNotificationSupported()) {
85
+ return 'denied';
86
+ }
87
+ if (Notification.permission !== 'default') {
88
+ return Notification.permission;
89
+ }
90
+ try {
91
+ const permission = await Notification.requestPermission();
92
+ return permission;
93
+ }
94
+ catch (error) {
95
+ console.error('Failed to request notification permission:', error);
96
+ return 'denied';
97
+ }
98
+ }
99
+ /**
100
+ * Check if OS notifications are supported in the current environment
101
+ *
102
+ * @returns true if notifications are supported, false otherwise
103
+ */
104
+ isNotificationSupported() {
105
+ return typeof window !== 'undefined' && 'Notification' in window;
106
+ }
107
+ /**
108
+ * Show a notification specifically for agent completion
109
+ * This is a convenience method with pre-configured options for agent notifications
110
+ *
111
+ * @param agentName The name of the agent that completed
112
+ * @param taskDescription Optional description of the completed task
113
+ * @returns Promise resolving to the notification result
114
+ */
115
+ async showAgentCompletionNotification(agentName, taskDescription) {
116
+ const title = nls_1.nls.localize('theia/ai-core/agentCompletionTitle', 'Agent "{0}" Task Completed', agentName);
117
+ const body = taskDescription
118
+ ? nls_1.nls.localize('theia/ai-core/agentCompletionWithTask', 'Agent "{0}" has completed the task: {1}', agentName, taskDescription)
119
+ : nls_1.nls.localize('theia/ai-core/agentCompletionMessage', 'Agent "{0}" has completed its task.', agentName);
120
+ return this.showNotification(title, {
121
+ body,
122
+ icon: this.getAgentCompletionIcon(),
123
+ tag: `agent-completion-${agentName}`,
124
+ requireInteraction: false,
125
+ data: {
126
+ type: 'agent-completion',
127
+ agentName,
128
+ taskDescription,
129
+ timestamp: Date.now()
130
+ }
131
+ });
132
+ }
133
+ /**
134
+ * Ensure notification permission is granted
135
+ *
136
+ * @returns Promise resolving to the permission state
137
+ */
138
+ async ensurePermission() {
139
+ const currentPermission = this.getPermissionStatus();
140
+ if (currentPermission === 'granted') {
141
+ return currentPermission;
142
+ }
143
+ if (currentPermission === 'denied') {
144
+ return currentPermission;
145
+ }
146
+ return this.requestPermission();
147
+ }
148
+ /**
149
+ * Create a native notification with the given title and options
150
+ *
151
+ * @param title The notification title
152
+ * @param options The notification options
153
+ * @returns Promise resolving to the created notification
154
+ */
155
+ async createNotification(title, options) {
156
+ return new Promise((resolve, reject) => {
157
+ try {
158
+ const notificationOptions = {
159
+ body: options.body,
160
+ icon: options.icon,
161
+ silent: options.silent,
162
+ tag: options.tag,
163
+ requireInteraction: options.requireInteraction,
164
+ data: options.data
165
+ };
166
+ const notification = new Notification(title, notificationOptions);
167
+ notification.onshow = () => {
168
+ console.debug('OS notification shown:', title);
169
+ };
170
+ notification.onerror = error => {
171
+ console.error('OS notification error:', error);
172
+ reject(new Error('Failed to show notification'));
173
+ };
174
+ notification.onclick = () => {
175
+ console.debug('OS notification clicked:', title);
176
+ this.focusApplicationWindow();
177
+ notification.close();
178
+ };
179
+ notification.onclose = () => {
180
+ console.debug('OS notification closed:', title);
181
+ };
182
+ resolve(notification);
183
+ }
184
+ catch (error) {
185
+ reject(error);
186
+ }
187
+ });
188
+ }
189
+ /**
190
+ * Attempt to focus the application window when notification is clicked
191
+ */
192
+ focusApplicationWindow() {
193
+ var _a;
194
+ try {
195
+ if (typeof window !== 'undefined') {
196
+ window.focus();
197
+ if (this.isElectron && ((_a = window.electronTheiaCore) === null || _a === void 0 ? void 0 : _a.focusWindow)) {
198
+ window.electronTheiaCore.focusWindow();
199
+ }
200
+ }
201
+ }
202
+ catch (error) {
203
+ console.debug('Could not focus application window:', error);
204
+ }
205
+ }
206
+ /**
207
+ * Get the icon URL for agent completion notifications
208
+ *
209
+ * @returns The icon URL or undefined if not available
210
+ */
211
+ getAgentCompletionIcon() {
212
+ // This could return a path to an icon file
213
+ // For now, we'll return undefined to use the default system icon
214
+ return undefined;
215
+ }
216
+ };
217
+ exports.OSNotificationService = OSNotificationService;
218
+ exports.OSNotificationService = OSNotificationService = tslib_1.__decorate([
219
+ (0, inversify_1.injectable)(),
220
+ tslib_1.__metadata("design:paramtypes", [])
221
+ ], OSNotificationService);
222
+ //# sourceMappingURL=os-notification-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"os-notification-service.js","sourceRoot":"","sources":["../../src/browser/os-notification-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;A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