@orthacms/copilot-server 0.0.0-reserve.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 (156) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -0
  3. package/dist/index.d.ts +24 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +48 -0
  6. package/dist/lib/chat/application/appliers-registrar.d.ts +16 -0
  7. package/dist/lib/chat/application/appliers-registrar.d.ts.map +1 -0
  8. package/dist/lib/chat/application/appliers-registrar.js +50 -0
  9. package/dist/lib/chat/application/capability-profile.service.d.ts +43 -0
  10. package/dist/lib/chat/application/capability-profile.service.d.ts.map +1 -0
  11. package/dist/lib/chat/application/capability-profile.service.js +75 -0
  12. package/dist/lib/chat/application/content-type-summary.service.d.ts +32 -0
  13. package/dist/lib/chat/application/content-type-summary.service.d.ts.map +1 -0
  14. package/dist/lib/chat/application/content-type-summary.service.js +64 -0
  15. package/dist/lib/chat/application/decide-proposal.service.d.ts +80 -0
  16. package/dist/lib/chat/application/decide-proposal.service.d.ts.map +1 -0
  17. package/dist/lib/chat/application/decide-proposal.service.js +112 -0
  18. package/dist/lib/chat/application/dto/create-run.dto.d.ts +138 -0
  19. package/dist/lib/chat/application/dto/create-run.dto.d.ts.map +1 -0
  20. package/dist/lib/chat/application/dto/create-run.dto.js +253 -0
  21. package/dist/lib/chat/application/dto/decide-tool-permission.dto.d.ts +20 -0
  22. package/dist/lib/chat/application/dto/decide-tool-permission.dto.d.ts.map +1 -0
  23. package/dist/lib/chat/application/dto/decide-tool-permission.dto.js +44 -0
  24. package/dist/lib/chat/application/dto/extend-tool-permission.dto.d.ts +18 -0
  25. package/dist/lib/chat/application/dto/extend-tool-permission.dto.d.ts.map +1 -0
  26. package/dist/lib/chat/application/dto/extend-tool-permission.dto.js +33 -0
  27. package/dist/lib/chat/application/dto/list-conversations-query.dto.d.ts +18 -0
  28. package/dist/lib/chat/application/dto/list-conversations-query.dto.d.ts.map +1 -0
  29. package/dist/lib/chat/application/dto/list-conversations-query.dto.js +39 -0
  30. package/dist/lib/chat/application/dto/list-proposals-query.dto.d.ts +15 -0
  31. package/dist/lib/chat/application/dto/list-proposals-query.dto.d.ts.map +1 -0
  32. package/dist/lib/chat/application/dto/list-proposals-query.dto.js +41 -0
  33. package/dist/lib/chat/application/dto/update-conversation.dto.d.ts +68 -0
  34. package/dist/lib/chat/application/dto/update-conversation.dto.d.ts.map +1 -0
  35. package/dist/lib/chat/application/dto/update-conversation.dto.js +115 -0
  36. package/dist/lib/chat/application/proposal-applier.registry.d.ts +27 -0
  37. package/dist/lib/chat/application/proposal-applier.registry.d.ts.map +1 -0
  38. package/dist/lib/chat/application/proposal-applier.registry.js +62 -0
  39. package/dist/lib/chat/application/run-engine.service.d.ts +243 -0
  40. package/dist/lib/chat/application/run-engine.service.d.ts.map +1 -0
  41. package/dist/lib/chat/application/run-engine.service.js +1058 -0
  42. package/dist/lib/chat/application/summarize-tool-output.d.ts +15 -0
  43. package/dist/lib/chat/application/summarize-tool-output.d.ts.map +1 -0
  44. package/dist/lib/chat/application/summarize-tool-output.js +61 -0
  45. package/dist/lib/chat/application/system-prompt.d.ts +81 -0
  46. package/dist/lib/chat/application/system-prompt.d.ts.map +1 -0
  47. package/dist/lib/chat/application/system-prompt.js +477 -0
  48. package/dist/lib/chat/application/tool-permission.broker.d.ts +118 -0
  49. package/dist/lib/chat/application/tool-permission.broker.d.ts.map +1 -0
  50. package/dist/lib/chat/application/tool-permission.broker.js +221 -0
  51. package/dist/lib/chat/http/controllers/create-run.controller.d.ts +30 -0
  52. package/dist/lib/chat/http/controllers/create-run.controller.d.ts.map +1 -0
  53. package/dist/lib/chat/http/controllers/create-run.controller.js +159 -0
  54. package/dist/lib/chat/http/controllers/get-conversation.controller.d.ts +22 -0
  55. package/dist/lib/chat/http/controllers/get-conversation.controller.d.ts.map +1 -0
  56. package/dist/lib/chat/http/controllers/get-conversation.controller.js +50 -0
  57. package/dist/lib/chat/http/controllers/list-conversations.controller.d.ts +20 -0
  58. package/dist/lib/chat/http/controllers/list-conversations.controller.d.ts.map +1 -0
  59. package/dist/lib/chat/http/controllers/list-conversations.controller.js +47 -0
  60. package/dist/lib/chat/http/controllers/list-models.controller.d.ts +35 -0
  61. package/dist/lib/chat/http/controllers/list-models.controller.d.ts.map +1 -0
  62. package/dist/lib/chat/http/controllers/list-models.controller.js +48 -0
  63. package/dist/lib/chat/http/controllers/proposals.controller.d.ts +43 -0
  64. package/dist/lib/chat/http/controllers/proposals.controller.d.ts.map +1 -0
  65. package/dist/lib/chat/http/controllers/proposals.controller.js +98 -0
  66. package/dist/lib/chat/http/controllers/tool-permission.controller.d.ts +57 -0
  67. package/dist/lib/chat/http/controllers/tool-permission.controller.d.ts.map +1 -0
  68. package/dist/lib/chat/http/controllers/tool-permission.controller.js +116 -0
  69. package/dist/lib/chat/http/controllers/update-conversation.controller.d.ts +37 -0
  70. package/dist/lib/chat/http/controllers/update-conversation.controller.d.ts.map +1 -0
  71. package/dist/lib/chat/http/controllers/update-conversation.controller.js +108 -0
  72. package/dist/lib/chat/http/sse-stream.d.ts +41 -0
  73. package/dist/lib/chat/http/sse-stream.d.ts.map +1 -0
  74. package/dist/lib/chat/http/sse-stream.js +95 -0
  75. package/dist/lib/chat/infrastructure/persistence/conversation.repository.d.ts +159 -0
  76. package/dist/lib/chat/infrastructure/persistence/conversation.repository.d.ts.map +1 -0
  77. package/dist/lib/chat/infrastructure/persistence/conversation.repository.js +249 -0
  78. package/dist/lib/chat/infrastructure/persistence/derive-title.d.ts +13 -0
  79. package/dist/lib/chat/infrastructure/persistence/derive-title.d.ts.map +1 -0
  80. package/dist/lib/chat/infrastructure/persistence/derive-title.js +35 -0
  81. package/dist/lib/chat/infrastructure/persistence/proposal.repository.d.ts +86 -0
  82. package/dist/lib/chat/infrastructure/persistence/proposal.repository.d.ts.map +1 -0
  83. package/dist/lib/chat/infrastructure/persistence/proposal.repository.js +152 -0
  84. package/dist/lib/chat/infrastructure/schema/conversations.d.ts +189 -0
  85. package/dist/lib/chat/infrastructure/schema/conversations.d.ts.map +1 -0
  86. package/dist/lib/chat/infrastructure/schema/conversations.js +100 -0
  87. package/dist/lib/chat/infrastructure/schema/external-refs.d.ts +67 -0
  88. package/dist/lib/chat/infrastructure/schema/external-refs.d.ts.map +1 -0
  89. package/dist/lib/chat/infrastructure/schema/external-refs.js +28 -0
  90. package/dist/lib/chat/infrastructure/schema/index.d.ts +5 -0
  91. package/dist/lib/chat/infrastructure/schema/index.d.ts.map +1 -0
  92. package/dist/lib/chat/infrastructure/schema/index.js +12 -0
  93. package/dist/lib/chat/infrastructure/schema/messages.d.ts +264 -0
  94. package/dist/lib/chat/infrastructure/schema/messages.d.ts.map +1 -0
  95. package/dist/lib/chat/infrastructure/schema/messages.js +96 -0
  96. package/dist/lib/chat/infrastructure/schema/proposals.d.ts +328 -0
  97. package/dist/lib/chat/infrastructure/schema/proposals.d.ts.map +1 -0
  98. package/dist/lib/chat/infrastructure/schema/proposals.js +87 -0
  99. package/dist/lib/chat/infrastructure/schema/tool-calls.d.ts +203 -0
  100. package/dist/lib/chat/infrastructure/schema/tool-calls.d.ts.map +1 -0
  101. package/dist/lib/chat/infrastructure/schema/tool-calls.js +50 -0
  102. package/dist/lib/copilot.module.d.ts +30 -0
  103. package/dist/lib/copilot.module.d.ts.map +1 -0
  104. package/dist/lib/copilot.module.js +146 -0
  105. package/dist/lib/copilot.tokens.d.ts +34 -0
  106. package/dist/lib/copilot.tokens.d.ts.map +1 -0
  107. package/dist/lib/copilot.tokens.js +38 -0
  108. package/dist/lib/infrastructure/model-registry.d.ts +22 -0
  109. package/dist/lib/infrastructure/model-registry.d.ts.map +1 -0
  110. package/dist/lib/infrastructure/model-registry.js +54 -0
  111. package/dist/lib/skills/application/dto/create-skill.dto.d.ts +36 -0
  112. package/dist/lib/skills/application/dto/create-skill.dto.d.ts.map +1 -0
  113. package/dist/lib/skills/application/dto/create-skill.dto.js +106 -0
  114. package/dist/lib/skills/application/dto/update-skill.dto.d.ts +28 -0
  115. package/dist/lib/skills/application/dto/update-skill.dto.d.ts.map +1 -0
  116. package/dist/lib/skills/application/dto/update-skill.dto.js +96 -0
  117. package/dist/lib/skills/application/skill-catalog.service.d.ts +97 -0
  118. package/dist/lib/skills/application/skill-catalog.service.d.ts.map +1 -0
  119. package/dist/lib/skills/application/skill-catalog.service.js +157 -0
  120. package/dist/lib/skills/http/controllers/list-skills.controller.d.ts +19 -0
  121. package/dist/lib/skills/http/controllers/list-skills.controller.d.ts.map +1 -0
  122. package/dist/lib/skills/http/controllers/list-skills.controller.js +50 -0
  123. package/dist/lib/skills/http/controllers/manage-skills.controller.d.ts +64 -0
  124. package/dist/lib/skills/http/controllers/manage-skills.controller.d.ts.map +1 -0
  125. package/dist/lib/skills/http/controllers/manage-skills.controller.js +182 -0
  126. package/dist/lib/skills/infrastructure/persistence/skill.repository.d.ts +78 -0
  127. package/dist/lib/skills/infrastructure/persistence/skill.repository.d.ts.map +1 -0
  128. package/dist/lib/skills/infrastructure/persistence/skill.repository.js +116 -0
  129. package/dist/lib/skills/infrastructure/schema/index.d.ts +2 -0
  130. package/dist/lib/skills/infrastructure/schema/index.d.ts.map +1 -0
  131. package/dist/lib/skills/infrastructure/schema/index.js +6 -0
  132. package/dist/lib/skills/infrastructure/schema/skills.d.ts +212 -0
  133. package/dist/lib/skills/infrastructure/schema/skills.d.ts.map +1 -0
  134. package/dist/lib/skills/infrastructure/schema/skills.js +78 -0
  135. package/dist/lib/types/copilot-config.d.ts +55 -0
  136. package/dist/lib/types/copilot-config.d.ts.map +1 -0
  137. package/dist/lib/types/copilot-config.js +2 -0
  138. package/dist/lib/utils/copilot-plugin.d.ts +66 -0
  139. package/dist/lib/utils/copilot-plugin.d.ts.map +1 -0
  140. package/dist/lib/utils/copilot-plugin.js +87 -0
  141. package/migrations/0000_copilot_chat.sql +48 -0
  142. package/migrations/0001_proposals.sql +34 -0
  143. package/migrations/0002_drop_workspace_policies.sql +1 -0
  144. package/migrations/0003_conversation_allowed_tools.sql +1 -0
  145. package/migrations/0004_message_attachments.sql +1 -0
  146. package/migrations/0005_skills.sql +19 -0
  147. package/migrations/0006_conversation_model_choice.sql +1 -0
  148. package/migrations/meta/0000_snapshot.json +390 -0
  149. package/migrations/meta/0001_snapshot.json +657 -0
  150. package/migrations/meta/0002_snapshot.json +610 -0
  151. package/migrations/meta/0003_snapshot.json +617 -0
  152. package/migrations/meta/0004_snapshot.json +623 -0
  153. package/migrations/meta/0005_snapshot.json +771 -0
  154. package/migrations/meta/0006_snapshot.json +777 -0
  155. package/migrations/meta/_journal.json +55 -0
  156. package/package.json +46 -0
@@ -0,0 +1,390 @@
1
+ {
2
+ "id": "33508968-ba62-47b7-8bc0-047bf3dcc85e",
3
+ "prevId": "00000000-0000-0000-0000-000000000000",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "public.copilot_conversations": {
8
+ "name": "copilot_conversations",
9
+ "schema": "",
10
+ "columns": {
11
+ "id": {
12
+ "name": "id",
13
+ "type": "uuid",
14
+ "primaryKey": true,
15
+ "notNull": true,
16
+ "default": "gen_random_uuid()"
17
+ },
18
+ "user_id": {
19
+ "name": "user_id",
20
+ "type": "uuid",
21
+ "primaryKey": false,
22
+ "notNull": true
23
+ },
24
+ "workspace_id": {
25
+ "name": "workspace_id",
26
+ "type": "uuid",
27
+ "primaryKey": false,
28
+ "notNull": true
29
+ },
30
+ "title": {
31
+ "name": "title",
32
+ "type": "text",
33
+ "primaryKey": false,
34
+ "notNull": false
35
+ },
36
+ "surface": {
37
+ "name": "surface",
38
+ "type": "text",
39
+ "primaryKey": false,
40
+ "notNull": true,
41
+ "default": "'chat'"
42
+ },
43
+ "archived": {
44
+ "name": "archived",
45
+ "type": "boolean",
46
+ "primaryKey": false,
47
+ "notNull": true,
48
+ "default": false
49
+ },
50
+ "created_at": {
51
+ "name": "created_at",
52
+ "type": "timestamp with time zone",
53
+ "primaryKey": false,
54
+ "notNull": true,
55
+ "default": "now()"
56
+ },
57
+ "updated_at": {
58
+ "name": "updated_at",
59
+ "type": "timestamp with time zone",
60
+ "primaryKey": false,
61
+ "notNull": true,
62
+ "default": "now()"
63
+ }
64
+ },
65
+ "indexes": {
66
+ "copilot_conversations_owner_idx": {
67
+ "name": "copilot_conversations_owner_idx",
68
+ "columns": [
69
+ {
70
+ "expression": "user_id",
71
+ "isExpression": false,
72
+ "asc": true,
73
+ "nulls": "last"
74
+ },
75
+ {
76
+ "expression": "workspace_id",
77
+ "isExpression": false,
78
+ "asc": true,
79
+ "nulls": "last"
80
+ },
81
+ {
82
+ "expression": "updated_at",
83
+ "isExpression": false,
84
+ "asc": true,
85
+ "nulls": "last"
86
+ }
87
+ ],
88
+ "isUnique": false,
89
+ "concurrently": false,
90
+ "method": "btree",
91
+ "with": {}
92
+ }
93
+ },
94
+ "foreignKeys": {
95
+ "copilot_conversations_user_id_users_id_fk": {
96
+ "name": "copilot_conversations_user_id_users_id_fk",
97
+ "tableFrom": "copilot_conversations",
98
+ "tableTo": "users",
99
+ "columnsFrom": [
100
+ "user_id"
101
+ ],
102
+ "columnsTo": [
103
+ "id"
104
+ ],
105
+ "onDelete": "cascade",
106
+ "onUpdate": "no action"
107
+ },
108
+ "copilot_conversations_workspace_id_workspaces_id_fk": {
109
+ "name": "copilot_conversations_workspace_id_workspaces_id_fk",
110
+ "tableFrom": "copilot_conversations",
111
+ "tableTo": "workspaces",
112
+ "columnsFrom": [
113
+ "workspace_id"
114
+ ],
115
+ "columnsTo": [
116
+ "id"
117
+ ],
118
+ "onDelete": "cascade",
119
+ "onUpdate": "no action"
120
+ }
121
+ },
122
+ "compositePrimaryKeys": {},
123
+ "uniqueConstraints": {},
124
+ "policies": {},
125
+ "checkConstraints": {},
126
+ "isRLSEnabled": false
127
+ },
128
+ "public.copilot_messages": {
129
+ "name": "copilot_messages",
130
+ "schema": "",
131
+ "columns": {
132
+ "id": {
133
+ "name": "id",
134
+ "type": "uuid",
135
+ "primaryKey": true,
136
+ "notNull": true,
137
+ "default": "gen_random_uuid()"
138
+ },
139
+ "conversation_id": {
140
+ "name": "conversation_id",
141
+ "type": "uuid",
142
+ "primaryKey": false,
143
+ "notNull": true
144
+ },
145
+ "run_id": {
146
+ "name": "run_id",
147
+ "type": "uuid",
148
+ "primaryKey": false,
149
+ "notNull": true
150
+ },
151
+ "role": {
152
+ "name": "role",
153
+ "type": "copilot_message_role",
154
+ "typeSchema": "public",
155
+ "primaryKey": false,
156
+ "notNull": true
157
+ },
158
+ "content": {
159
+ "name": "content",
160
+ "type": "jsonb",
161
+ "primaryKey": false,
162
+ "notNull": true
163
+ },
164
+ "model": {
165
+ "name": "model",
166
+ "type": "text",
167
+ "primaryKey": false,
168
+ "notNull": false
169
+ },
170
+ "provider": {
171
+ "name": "provider",
172
+ "type": "text",
173
+ "primaryKey": false,
174
+ "notNull": false
175
+ },
176
+ "stop_reason": {
177
+ "name": "stop_reason",
178
+ "type": "text",
179
+ "primaryKey": false,
180
+ "notNull": false
181
+ },
182
+ "input_tokens": {
183
+ "name": "input_tokens",
184
+ "type": "integer",
185
+ "primaryKey": false,
186
+ "notNull": false
187
+ },
188
+ "output_tokens": {
189
+ "name": "output_tokens",
190
+ "type": "integer",
191
+ "primaryKey": false,
192
+ "notNull": false
193
+ },
194
+ "position": {
195
+ "name": "position",
196
+ "type": "integer",
197
+ "primaryKey": false,
198
+ "notNull": true
199
+ },
200
+ "created_at": {
201
+ "name": "created_at",
202
+ "type": "timestamp with time zone",
203
+ "primaryKey": false,
204
+ "notNull": true,
205
+ "default": "now()"
206
+ }
207
+ },
208
+ "indexes": {
209
+ "copilot_messages_thread_idx": {
210
+ "name": "copilot_messages_thread_idx",
211
+ "columns": [
212
+ {
213
+ "expression": "conversation_id",
214
+ "isExpression": false,
215
+ "asc": true,
216
+ "nulls": "last"
217
+ },
218
+ {
219
+ "expression": "position",
220
+ "isExpression": false,
221
+ "asc": true,
222
+ "nulls": "last"
223
+ }
224
+ ],
225
+ "isUnique": false,
226
+ "concurrently": false,
227
+ "method": "btree",
228
+ "with": {}
229
+ }
230
+ },
231
+ "foreignKeys": {
232
+ "copilot_messages_conversation_id_copilot_conversations_id_fk": {
233
+ "name": "copilot_messages_conversation_id_copilot_conversations_id_fk",
234
+ "tableFrom": "copilot_messages",
235
+ "tableTo": "copilot_conversations",
236
+ "columnsFrom": [
237
+ "conversation_id"
238
+ ],
239
+ "columnsTo": [
240
+ "id"
241
+ ],
242
+ "onDelete": "cascade",
243
+ "onUpdate": "no action"
244
+ }
245
+ },
246
+ "compositePrimaryKeys": {},
247
+ "uniqueConstraints": {},
248
+ "policies": {},
249
+ "checkConstraints": {},
250
+ "isRLSEnabled": false
251
+ },
252
+ "public.copilot_tool_calls": {
253
+ "name": "copilot_tool_calls",
254
+ "schema": "",
255
+ "columns": {
256
+ "id": {
257
+ "name": "id",
258
+ "type": "uuid",
259
+ "primaryKey": true,
260
+ "notNull": true,
261
+ "default": "gen_random_uuid()"
262
+ },
263
+ "conversation_id": {
264
+ "name": "conversation_id",
265
+ "type": "uuid",
266
+ "primaryKey": false,
267
+ "notNull": true
268
+ },
269
+ "run_id": {
270
+ "name": "run_id",
271
+ "type": "uuid",
272
+ "primaryKey": false,
273
+ "notNull": true
274
+ },
275
+ "call_id": {
276
+ "name": "call_id",
277
+ "type": "text",
278
+ "primaryKey": false,
279
+ "notNull": true
280
+ },
281
+ "name": {
282
+ "name": "name",
283
+ "type": "text",
284
+ "primaryKey": false,
285
+ "notNull": true
286
+ },
287
+ "input": {
288
+ "name": "input",
289
+ "type": "jsonb",
290
+ "primaryKey": false,
291
+ "notNull": false
292
+ },
293
+ "output_summary": {
294
+ "name": "output_summary",
295
+ "type": "text",
296
+ "primaryKey": false,
297
+ "notNull": false
298
+ },
299
+ "ok": {
300
+ "name": "ok",
301
+ "type": "boolean",
302
+ "primaryKey": false,
303
+ "notNull": true
304
+ },
305
+ "error": {
306
+ "name": "error",
307
+ "type": "text",
308
+ "primaryKey": false,
309
+ "notNull": false
310
+ },
311
+ "duration_ms": {
312
+ "name": "duration_ms",
313
+ "type": "integer",
314
+ "primaryKey": false,
315
+ "notNull": true
316
+ },
317
+ "created_at": {
318
+ "name": "created_at",
319
+ "type": "timestamp with time zone",
320
+ "primaryKey": false,
321
+ "notNull": true,
322
+ "default": "now()"
323
+ }
324
+ },
325
+ "indexes": {
326
+ "copilot_tool_calls_run_idx": {
327
+ "name": "copilot_tool_calls_run_idx",
328
+ "columns": [
329
+ {
330
+ "expression": "run_id",
331
+ "isExpression": false,
332
+ "asc": true,
333
+ "nulls": "last"
334
+ },
335
+ {
336
+ "expression": "created_at",
337
+ "isExpression": false,
338
+ "asc": true,
339
+ "nulls": "last"
340
+ }
341
+ ],
342
+ "isUnique": false,
343
+ "concurrently": false,
344
+ "method": "btree",
345
+ "with": {}
346
+ }
347
+ },
348
+ "foreignKeys": {
349
+ "copilot_tool_calls_conversation_id_copilot_conversations_id_fk": {
350
+ "name": "copilot_tool_calls_conversation_id_copilot_conversations_id_fk",
351
+ "tableFrom": "copilot_tool_calls",
352
+ "tableTo": "copilot_conversations",
353
+ "columnsFrom": [
354
+ "conversation_id"
355
+ ],
356
+ "columnsTo": [
357
+ "id"
358
+ ],
359
+ "onDelete": "cascade",
360
+ "onUpdate": "no action"
361
+ }
362
+ },
363
+ "compositePrimaryKeys": {},
364
+ "uniqueConstraints": {},
365
+ "policies": {},
366
+ "checkConstraints": {},
367
+ "isRLSEnabled": false
368
+ }
369
+ },
370
+ "enums": {
371
+ "public.copilot_message_role": {
372
+ "name": "copilot_message_role",
373
+ "schema": "public",
374
+ "values": [
375
+ "user",
376
+ "assistant"
377
+ ]
378
+ }
379
+ },
380
+ "schemas": {},
381
+ "sequences": {},
382
+ "roles": {},
383
+ "policies": {},
384
+ "views": {},
385
+ "_meta": {
386
+ "columns": {},
387
+ "schemas": {},
388
+ "tables": {}
389
+ }
390
+ }