@hyorman/copilot-proxy-core 1.0.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 (58) hide show
  1. package/out/assistants/index.d.ts +15 -0
  2. package/out/assistants/index.js +16 -0
  3. package/out/assistants/index.js.map +1 -0
  4. package/out/assistants/routes.d.ts +16 -0
  5. package/out/assistants/routes.js +597 -0
  6. package/out/assistants/routes.js.map +1 -0
  7. package/out/assistants/runner.d.ts +48 -0
  8. package/out/assistants/runner.js +851 -0
  9. package/out/assistants/runner.js.map +1 -0
  10. package/out/assistants/state.d.ts +81 -0
  11. package/out/assistants/state.js +351 -0
  12. package/out/assistants/state.js.map +1 -0
  13. package/out/assistants/tools.d.ts +4 -0
  14. package/out/assistants/tools.js +8 -0
  15. package/out/assistants/tools.js.map +1 -0
  16. package/out/assistants/types.d.ts +254 -0
  17. package/out/assistants/types.js +5 -0
  18. package/out/assistants/types.js.map +1 -0
  19. package/out/backend.d.ts +24 -0
  20. package/out/backend.js +12 -0
  21. package/out/backend.js.map +1 -0
  22. package/out/index.d.ts +13 -0
  23. package/out/index.js +21 -0
  24. package/out/index.js.map +1 -0
  25. package/out/server.d.ts +12 -0
  26. package/out/server.js +504 -0
  27. package/out/server.js.map +1 -0
  28. package/out/skills/index.d.ts +3 -0
  29. package/out/skills/index.js +4 -0
  30. package/out/skills/index.js.map +1 -0
  31. package/out/skills/manifest.d.ts +25 -0
  32. package/out/skills/manifest.js +96 -0
  33. package/out/skills/manifest.js.map +1 -0
  34. package/out/skills/resolver.d.ts +22 -0
  35. package/out/skills/resolver.js +66 -0
  36. package/out/skills/resolver.js.map +1 -0
  37. package/out/skills/routes.d.ts +3 -0
  38. package/out/skills/routes.js +191 -0
  39. package/out/skills/routes.js.map +1 -0
  40. package/out/skills/state.d.ts +35 -0
  41. package/out/skills/state.js +155 -0
  42. package/out/skills/state.js.map +1 -0
  43. package/out/skills/storage.d.ts +30 -0
  44. package/out/skills/storage.js +171 -0
  45. package/out/skills/storage.js.map +1 -0
  46. package/out/skills/types.d.ts +141 -0
  47. package/out/skills/types.js +8 -0
  48. package/out/skills/types.js.map +1 -0
  49. package/out/toolConvert.d.ts +24 -0
  50. package/out/toolConvert.js +56 -0
  51. package/out/toolConvert.js.map +1 -0
  52. package/out/types.d.ts +291 -0
  53. package/out/types.js +2 -0
  54. package/out/types.js.map +1 -0
  55. package/out/utils.d.ts +28 -0
  56. package/out/utils.js +81 -0
  57. package/out/utils.js.map +1 -0
  58. package/package.json +36 -0
@@ -0,0 +1,254 @@
1
+ /**
2
+ * OpenAI Assistants API Types
3
+ */
4
+ import { ToolCall } from '../types.js';
5
+ import type { SkillAttachment } from '../skills/types.js';
6
+ export { ToolCall };
7
+ export interface OpenAIListResponse<T> {
8
+ object: 'list';
9
+ data: T[];
10
+ first_id: string | null;
11
+ last_id: string | null;
12
+ has_more: boolean;
13
+ }
14
+ export interface PaginationParams {
15
+ limit?: number;
16
+ order?: 'asc' | 'desc';
17
+ after?: string;
18
+ before?: string;
19
+ }
20
+ export type ToolType = 'code_interpreter' | 'file_search' | 'function';
21
+ export interface FunctionDefinition {
22
+ name: string;
23
+ description?: string;
24
+ parameters?: Record<string, unknown>;
25
+ strict?: boolean;
26
+ }
27
+ export interface AssistantTool {
28
+ type: ToolType;
29
+ function?: FunctionDefinition;
30
+ }
31
+ export interface ToolOutput {
32
+ tool_call_id: string;
33
+ output: string;
34
+ }
35
+ export interface Assistant {
36
+ id: string;
37
+ object: 'assistant';
38
+ created_at: number;
39
+ name: string | null;
40
+ description: string | null;
41
+ model: string;
42
+ instructions: string | null;
43
+ tools: AssistantTool[];
44
+ skills: SkillAttachment[];
45
+ metadata: Record<string, string>;
46
+ }
47
+ export interface CreateAssistantRequest {
48
+ model: string;
49
+ name?: string;
50
+ description?: string;
51
+ instructions?: string;
52
+ tools?: AssistantTool[];
53
+ skills?: SkillAttachment[];
54
+ metadata?: Record<string, string>;
55
+ }
56
+ export interface UpdateAssistantRequest {
57
+ model?: string;
58
+ name?: string | null;
59
+ description?: string | null;
60
+ instructions?: string | null;
61
+ tools?: AssistantTool[];
62
+ skills?: SkillAttachment[];
63
+ metadata?: Record<string, string>;
64
+ }
65
+ export interface Thread {
66
+ id: string;
67
+ object: 'thread';
68
+ created_at: number;
69
+ metadata: Record<string, string>;
70
+ }
71
+ export interface CreateThreadRequest {
72
+ messages?: CreateMessageRequest[];
73
+ metadata?: Record<string, string>;
74
+ }
75
+ export type MessageRole = 'user' | 'assistant';
76
+ export type MessageStatus = 'in_progress' | 'incomplete' | 'completed';
77
+ export interface TextContent {
78
+ type: 'text';
79
+ text: {
80
+ value: string;
81
+ annotations: TextAnnotation[];
82
+ };
83
+ }
84
+ export interface ImageFileContent {
85
+ type: 'image_file';
86
+ image_file: {
87
+ file_id: string;
88
+ detail?: 'auto' | 'low' | 'high';
89
+ };
90
+ }
91
+ export interface ImageUrlContent {
92
+ type: 'image_url';
93
+ image_url: {
94
+ url: string;
95
+ detail?: 'auto' | 'low' | 'high';
96
+ };
97
+ }
98
+ export interface TextAnnotation {
99
+ type: 'file_citation' | 'file_path';
100
+ text: string;
101
+ start_index: number;
102
+ end_index: number;
103
+ file_citation?: {
104
+ file_id: string;
105
+ quote?: string;
106
+ };
107
+ file_path?: {
108
+ file_id: string;
109
+ };
110
+ }
111
+ export type MessageContent = TextContent | ImageFileContent | ImageUrlContent;
112
+ export interface Message {
113
+ id: string;
114
+ object: 'thread.message';
115
+ created_at: number;
116
+ thread_id: string;
117
+ status: MessageStatus;
118
+ incomplete_details: {
119
+ reason: string;
120
+ } | null;
121
+ completed_at: number | null;
122
+ incomplete_at: number | null;
123
+ role: MessageRole;
124
+ content: MessageContent[];
125
+ assistant_id: string | null;
126
+ run_id: string | null;
127
+ attachments: MessageAttachment[];
128
+ metadata: Record<string, string>;
129
+ }
130
+ export interface MessageAttachment {
131
+ file_id: string;
132
+ tools: Array<{
133
+ type: ToolType;
134
+ }>;
135
+ }
136
+ export interface CreateMessageRequest {
137
+ role: 'user' | 'assistant';
138
+ content: string | MessageContent[];
139
+ attachments?: MessageAttachment[];
140
+ metadata?: Record<string, string>;
141
+ }
142
+ export type RunStatus = 'queued' | 'in_progress' | 'requires_action' | 'cancelling' | 'cancelled' | 'failed' | 'completed' | 'incomplete' | 'expired';
143
+ export interface RunError {
144
+ code: 'server_error' | 'rate_limit_exceeded' | 'invalid_prompt';
145
+ message: string;
146
+ }
147
+ export interface RunUsage {
148
+ prompt_tokens: number;
149
+ completion_tokens: number;
150
+ total_tokens: number;
151
+ }
152
+ export interface RequiredAction {
153
+ type: 'submit_tool_outputs';
154
+ submit_tool_outputs: {
155
+ tool_calls: ToolCall[];
156
+ };
157
+ }
158
+ export interface Run {
159
+ id: string;
160
+ object: 'thread.run';
161
+ created_at: number;
162
+ thread_id: string;
163
+ assistant_id: string;
164
+ status: RunStatus;
165
+ required_action: RequiredAction | null;
166
+ last_error: RunError | null;
167
+ expires_at: number | null;
168
+ started_at: number | null;
169
+ cancelled_at: number | null;
170
+ failed_at: number | null;
171
+ completed_at: number | null;
172
+ incomplete_details: {
173
+ reason: string;
174
+ } | null;
175
+ model: string;
176
+ instructions: string | null;
177
+ tools: AssistantTool[];
178
+ skills: SkillAttachment[];
179
+ metadata: Record<string, string>;
180
+ usage: RunUsage | null;
181
+ }
182
+ export interface CreateRunRequest {
183
+ assistant_id: string;
184
+ model?: string;
185
+ instructions?: string;
186
+ additional_instructions?: string;
187
+ additional_messages?: CreateMessageRequest[];
188
+ tools?: AssistantTool[];
189
+ skills?: SkillAttachment[];
190
+ metadata?: Record<string, string>;
191
+ stream?: boolean;
192
+ }
193
+ export interface CreateThreadAndRunRequest {
194
+ assistant_id: string;
195
+ thread?: CreateThreadRequest;
196
+ model?: string;
197
+ instructions?: string;
198
+ tools?: AssistantTool[];
199
+ skills?: SkillAttachment[];
200
+ metadata?: Record<string, string>;
201
+ stream?: boolean;
202
+ }
203
+ export interface SubmitToolOutputsRequest {
204
+ tool_outputs: ToolOutput[];
205
+ stream?: boolean;
206
+ }
207
+ export type RunStepType = 'message_creation' | 'tool_calls';
208
+ export type RunStepStatus = 'in_progress' | 'cancelled' | 'failed' | 'completed' | 'expired';
209
+ export interface RunStep {
210
+ id: string;
211
+ object: 'thread.run.step';
212
+ created_at: number;
213
+ run_id: string;
214
+ assistant_id: string;
215
+ thread_id: string;
216
+ type: RunStepType;
217
+ status: RunStepStatus;
218
+ cancelled_at: number | null;
219
+ completed_at: number | null;
220
+ expired_at: number | null;
221
+ failed_at: number | null;
222
+ last_error: RunError | null;
223
+ step_details: MessageCreationStepDetails | ToolCallsStepDetails;
224
+ usage: RunUsage | null;
225
+ }
226
+ export interface MessageCreationStepDetails {
227
+ type: 'message_creation';
228
+ message_creation: {
229
+ message_id: string;
230
+ };
231
+ }
232
+ export interface ToolCallsStepDetails {
233
+ type: 'tool_calls';
234
+ tool_calls: ToolCall[];
235
+ }
236
+ export type StreamEventType = 'thread.created' | 'thread.run.created' | 'thread.run.queued' | 'thread.run.in_progress' | 'thread.run.requires_action' | 'thread.run.completed' | 'thread.run.incomplete' | 'thread.run.failed' | 'thread.run.cancelling' | 'thread.run.cancelled' | 'thread.run.expired' | 'thread.run.step.created' | 'thread.run.step.in_progress' | 'thread.run.step.delta' | 'thread.run.step.completed' | 'thread.run.step.failed' | 'thread.run.step.cancelled' | 'thread.run.step.expired' | 'thread.message.created' | 'thread.message.in_progress' | 'thread.message.delta' | 'thread.message.completed' | 'thread.message.incomplete' | 'error' | 'done';
237
+ export interface StreamEvent {
238
+ event: StreamEventType;
239
+ data: unknown;
240
+ }
241
+ export interface MessageDelta {
242
+ id: string;
243
+ object: 'thread.message.delta';
244
+ delta: {
245
+ content: Array<{
246
+ index: number;
247
+ type: 'text';
248
+ text: {
249
+ value: string;
250
+ annotations?: unknown[];
251
+ };
252
+ }>;
253
+ };
254
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * OpenAI Assistants API Types
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/assistants/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Backend Abstraction
3
+ *
4
+ * Defines the ChatBackend interface that both VS Code and CLI
5
+ * implementations must satisfy. This is the core dependency-injection
6
+ * boundary that keeps platform-specific code out of the shared server.
7
+ */
8
+ import { ChatCompletionRequest, ChatCompletionChunk, ChatCompletionResponse, EmbeddingRequest, EmbeddingResponse } from './types.js';
9
+ export interface ModelInfo {
10
+ vendor: string;
11
+ family: string;
12
+ id?: string;
13
+ }
14
+ export interface Logger {
15
+ log(message: string): void;
16
+ error?(message: string): void;
17
+ }
18
+ export declare const consoleLogger: Logger;
19
+ export interface ChatBackend {
20
+ processChatRequest(request: ChatCompletionRequest): Promise<AsyncIterable<ChatCompletionChunk> | ChatCompletionResponse>;
21
+ getAvailableModels(): ModelInfo[] | Promise<ModelInfo[]>;
22
+ /** Optional: compute embeddings (VS Code only) */
23
+ processEmbeddingRequest?(request: EmbeddingRequest): Promise<EmbeddingResponse>;
24
+ }
package/out/backend.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Backend Abstraction
3
+ *
4
+ * Defines the ChatBackend interface that both VS Code and CLI
5
+ * implementations must satisfy. This is the core dependency-injection
6
+ * boundary that keeps platform-specific code out of the shared server.
7
+ */
8
+ export const consoleLogger = {
9
+ log: (msg) => console.log(msg),
10
+ error: (msg) => console.error(msg),
11
+ };
12
+ //# sourceMappingURL=backend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backend.js","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAqBH,MAAM,CAAC,MAAM,aAAa,GAAW;IACnC,GAAG,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IACtC,KAAK,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC;CAC3C,CAAC"}
package/out/index.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @hyorman/copilot-proxy-core
3
+ *
4
+ * Shared platform-independent logic for the Copilot Proxy.
5
+ * Exports server factory, types, state management, assistants, and skills modules.
6
+ */
7
+ export { ChatBackend, ModelInfo, Logger, consoleLogger } from './backend.js';
8
+ export { createApp, startServer } from './server.js';
9
+ export * from './types.js';
10
+ export { generateId, errorResponse, notFoundError, createMessage, generateApiToken, setApiTokens, addApiToken, removeApiToken, authMiddleware } from './utils.js';
11
+ export { assistantToolsToFunctionTools, responsesToolsToFunctionTools, toToolMode } from './toolConvert.js';
12
+ export * from './assistants/index.js';
13
+ export * from './skills/index.js';
package/out/index.js ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @hyorman/copilot-proxy-core
3
+ *
4
+ * Shared platform-independent logic for the Copilot Proxy.
5
+ * Exports server factory, types, state management, assistants, and skills modules.
6
+ */
7
+ // Backend abstraction
8
+ export { consoleLogger } from './backend.js';
9
+ // Server factory
10
+ export { createApp, startServer } from './server.js';
11
+ // Types
12
+ export * from './types.js';
13
+ // Utilities
14
+ export { generateId, errorResponse, notFoundError, createMessage, generateApiToken, setApiTokens, addApiToken, removeApiToken, authMiddleware } from './utils.js';
15
+ // Tool conversion (platform-independent)
16
+ export { assistantToolsToFunctionTools, responsesToolsToFunctionTools, toToolMode } from './toolConvert.js';
17
+ // Assistants module
18
+ export * from './assistants/index.js';
19
+ // Skills module
20
+ export * from './skills/index.js';
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,sBAAsB;AACtB,OAAO,EAAkC,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7E,iBAAiB;AACjB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAErD,QAAQ;AACR,cAAc,YAAY,CAAC;AAE3B,YAAY;AACZ,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAElK,yCAAyC;AACzC,OAAO,EAAE,6BAA6B,EAAE,6BAA6B,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE5G,oBAAoB;AACpB,cAAc,uBAAuB,CAAC;AAEtC,gBAAgB;AAChB,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Express Server Factory
3
+ *
4
+ * Creates a configured Express application using an injected ChatBackend.
5
+ * This factory pattern lets both VS Code and CLI platforms share the same
6
+ * server code while using different LLM backends.
7
+ */
8
+ import { ChatBackend, Logger } from './backend.js';
9
+ import { setApiTokens, addApiToken, removeApiToken } from './utils.js';
10
+ export { setApiTokens, addApiToken, removeApiToken };
11
+ export declare function createApp(backend: ChatBackend, logger: Logger): import("express-serve-static-core").Express;
12
+ export declare function startServer(backend: ChatBackend, logger: Logger, port?: number, tokens?: string[]): import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;