@m6d/cortex-server 1.8.0 → 2.0.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.
- package/README.md +8 -3
- package/contracts/README.md +23 -0
- package/contracts/graph/embed.ts +50 -0
- package/{src/lib → contracts}/graph/helpers.ts +4 -10
- package/{src/lib → contracts}/graph/neo4j.ts +14 -27
- package/contracts/graph/schema.ts +65 -0
- package/{src/lib → contracts}/graph/types.ts +2 -29
- package/contracts/graph.ts +36 -0
- package/contracts/rich-text.ts +207 -0
- package/contracts/runtime.ts +243 -0
- package/contracts/wire.ts +143 -0
- package/dist/contracts/graph/embed.d.ts +22 -0
- package/dist/{src/lib → contracts}/graph/helpers.d.ts +16 -14
- package/dist/{src/lib → contracts}/graph/neo4j.d.ts +5 -5
- package/dist/contracts/graph/schema.d.ts +62 -0
- package/dist/{src/lib → contracts}/graph/types.d.ts +1 -1
- package/dist/contracts/graph.d.ts +14 -0
- package/dist/contracts/rich-text.d.ts +32 -0
- package/dist/contracts/runtime.d.ts +310 -0
- package/dist/contracts/wire.d.ts +120 -0
- package/dist/src/lib/adapters/database/index.d.ts +61 -0
- package/dist/src/lib/adapters/database/message-content.d.ts +30 -0
- package/dist/src/lib/adapters/database/mssql/attachments.d.ts +100 -0
- package/dist/src/lib/adapters/database/mssql/client.d.ts +8 -0
- package/dist/src/lib/adapters/database/mssql/index.d.ts +194 -0
- package/dist/src/lib/adapters/database/mssql/llm-requests.d.ts +17 -0
- package/dist/src/lib/adapters/database/mssql/messages.d.ts +37 -0
- package/dist/src/lib/adapters/database/mssql/threads.d.ts +50 -0
- package/dist/src/lib/adapters/database/postgres/attachments.d.ts +113 -0
- package/dist/src/lib/adapters/database/postgres/client.d.ts +8 -0
- package/dist/src/lib/adapters/database/postgres/index.d.ts +207 -0
- package/dist/src/lib/adapters/database/postgres/llm-requests.d.ts +17 -0
- package/dist/src/lib/adapters/database/postgres/messages.d.ts +37 -0
- package/dist/src/lib/adapters/database/postgres/threads.d.ts +50 -0
- package/{src/lib/adapters/storage.ts → dist/src/lib/adapters/storage/index.d.ts} +1 -1
- package/dist/src/lib/adapters/{minio.d.ts → storage/minio.d.ts} +1 -1
- package/dist/src/lib/ai/active-runs.d.ts +63 -0
- package/dist/src/lib/ai/attachments.d.ts +30 -0
- package/dist/src/lib/ai/backend-url.d.ts +16 -0
- package/dist/src/lib/ai/cc-runtime.d.ts +61 -0
- package/dist/src/lib/ai/commit-gate.d.ts +21 -0
- package/dist/src/lib/ai/context/builder.d.ts +6 -7
- package/dist/src/lib/ai/context/compression-middleware.d.ts +15 -0
- package/dist/src/lib/ai/context/compressor.d.ts +2 -13
- package/dist/src/lib/ai/context/intra-turn-compressor.d.ts +9 -9
- package/dist/src/lib/ai/context/optimize-thread-context.d.ts +9 -0
- package/dist/src/lib/ai/context/summarizer.d.ts +3 -3
- package/dist/src/lib/ai/context/token-estimator.d.ts +5 -8
- package/dist/src/lib/ai/fetch.d.ts +1 -1
- package/dist/src/lib/ai/finish-turn.d.ts +23 -0
- package/dist/src/lib/ai/helpers.d.ts +37 -4
- package/dist/src/lib/ai/index.d.ts +6 -3
- package/dist/src/lib/ai/inspector.d.ts +41 -0
- package/dist/src/lib/ai/interceptors/request-interceptor.d.ts +6 -5
- package/dist/src/lib/ai/prompt.d.ts +5 -4
- package/dist/src/lib/ai/redis-runs.d.ts +41 -0
- package/dist/src/lib/ai/redis-stream-log.d.ts +39 -0
- package/dist/src/lib/ai/tools/execute-code.tool.d.ts +18 -4
- package/dist/src/lib/ai/tools/query-graph.tool.d.ts +13 -5
- package/dist/src/lib/ai/tools/read-attachment.tool.d.ts +21 -0
- package/dist/src/lib/ai/tools/search-common.d.ts +17 -0
- package/dist/src/lib/ai/tools/search-knowledge.tool.d.ts +15 -0
- package/dist/src/lib/ai/tools/search-services.tool.d.ts +12 -0
- package/dist/src/lib/ai/tools/search-tools.tool.d.ts +12 -0
- package/dist/src/lib/ai/turn-tools.d.ts +39 -0
- package/dist/src/lib/ai/vision/rasterize-pdf.d.ts +26 -0
- package/dist/src/lib/ai/vision/rasterize-pdf.worker.d.ts +1 -0
- package/dist/src/lib/ai/vision/vision-reader.d.ts +45 -0
- package/dist/src/lib/cc/client.d.ts +183 -0
- package/dist/src/lib/cc/config-cache.d.ts +20 -0
- package/dist/src/lib/cc/format.d.ts +23 -0
- package/dist/src/lib/cc/registry.d.ts +34 -0
- package/dist/src/lib/cc/types.d.ts +27 -0
- package/dist/src/lib/config.d.ts +81 -64
- package/dist/src/lib/db/drizzle.config.mssql.d.ts +2 -0
- package/dist/src/lib/db/drizzle.config.pg.d.ts +2 -0
- package/dist/src/lib/db/migrate.d.ts +7 -1
- package/dist/src/lib/db/{schema.d.ts → schema.mssql.d.ts} +138 -29
- package/dist/src/lib/db/schema.pg.d.ts +546 -0
- package/dist/src/lib/factory.d.ts +2 -12
- package/dist/src/lib/graph/index.d.ts +10 -11
- package/dist/src/lib/graph/resolver.d.ts +2 -3
- package/dist/src/lib/index.d.ts +3 -3
- package/dist/src/lib/redis.d.ts +19 -0
- package/dist/src/lib/routes/chat.d.ts +1 -1
- package/dist/src/lib/routes/files.d.ts +1 -1
- package/dist/src/lib/routes/owned-thread.d.ts +17 -0
- package/dist/src/lib/routes/threads.d.ts +1 -1
- package/dist/src/lib/routes/ws.d.ts +1 -1
- package/dist/src/lib/types.d.ts +20 -37
- package/dist/src/lib/ws/connections.d.ts +2 -1
- package/package.json +33 -18
- package/src/lib/adapters/database/index.ts +78 -0
- package/src/lib/adapters/database/message-content.ts +39 -0
- package/src/lib/adapters/database/mssql/attachments.ts +90 -0
- package/src/lib/adapters/database/mssql/client.ts +11 -0
- package/src/lib/adapters/database/mssql/index.ts +23 -0
- package/src/lib/adapters/database/mssql/llm-requests.ts +43 -0
- package/src/lib/adapters/database/mssql/messages.ts +92 -0
- package/src/lib/adapters/database/mssql/threads.ts +83 -0
- package/src/lib/adapters/database/postgres/attachments.ts +88 -0
- package/src/lib/adapters/database/postgres/client.ts +11 -0
- package/src/lib/adapters/database/postgres/index.ts +23 -0
- package/src/lib/adapters/database/postgres/llm-requests.ts +45 -0
- package/src/lib/adapters/database/postgres/messages.ts +92 -0
- package/src/lib/adapters/database/postgres/threads.ts +84 -0
- package/{dist/src/lib/adapters/storage.d.ts → src/lib/adapters/storage/index.ts} +1 -1
- package/src/lib/adapters/{minio.ts → storage/minio.ts} +5 -5
- package/src/lib/ai/active-runs.ts +157 -0
- package/src/lib/ai/attachments.ts +144 -0
- package/src/lib/ai/backend-url.ts +27 -0
- package/src/lib/ai/cc-runtime.ts +63 -0
- package/src/lib/ai/commit-gate.ts +116 -0
- package/src/lib/ai/context/builder.ts +12 -14
- package/src/lib/ai/context/compression-middleware.ts +44 -0
- package/src/lib/ai/context/compressor.ts +67 -59
- package/src/lib/ai/context/intra-turn-compressor.ts +121 -204
- package/src/lib/ai/context/optimize-thread-context.ts +50 -0
- package/src/lib/ai/context/summarizer.ts +28 -30
- package/src/lib/ai/context/token-estimator.ts +35 -30
- package/src/lib/ai/fetch.ts +10 -5
- package/src/lib/ai/finish-turn.ts +75 -0
- package/src/lib/ai/helpers.ts +83 -15
- package/src/lib/ai/index.ts +366 -329
- package/src/lib/ai/inspector.ts +112 -0
- package/src/lib/ai/interceptors/request-interceptor.ts +70 -42
- package/src/lib/ai/prompt.ts +126 -125
- package/src/lib/ai/redis-runs.ts +167 -0
- package/src/lib/ai/redis-stream-log.ts +219 -0
- package/src/lib/ai/tools/execute-code.tool.ts +178 -67
- package/src/lib/ai/tools/query-graph.tool.ts +7 -8
- package/src/lib/ai/tools/read-attachment.tool.ts +59 -0
- package/src/lib/ai/tools/search-common.ts +15 -0
- package/src/lib/ai/tools/search-knowledge.tool.ts +33 -0
- package/src/lib/ai/tools/search-services.tool.ts +31 -0
- package/src/lib/ai/tools/search-tools.tool.ts +29 -0
- package/src/lib/ai/turn-tools.ts +154 -0
- package/src/lib/ai/vision/rasterize-pdf.ts +69 -0
- package/src/lib/ai/vision/rasterize-pdf.worker.ts +81 -0
- package/src/lib/ai/vision/vision-reader.ts +130 -0
- package/src/lib/auth/middleware.ts +5 -3
- package/src/lib/cc/client.ts +273 -0
- package/src/lib/cc/config-cache.ts +32 -0
- package/src/lib/cc/format.ts +92 -0
- package/src/lib/cc/registry.ts +62 -0
- package/src/lib/cc/types.ts +44 -0
- package/src/lib/config.ts +102 -71
- package/src/lib/db/drizzle.config.mssql.ts +9 -0
- package/src/lib/db/drizzle.config.pg.ts +9 -0
- package/src/lib/db/migrate.ts +45 -10
- package/src/lib/db/migrations/mssql/20260729092726_talented_wilson_fisk/migration.sql +20 -0
- package/src/lib/db/migrations/mssql/20260729092726_talented_wilson_fisk/snapshot.json +497 -0
- package/src/lib/db/migrations/mssql/20260801003652_perpetual_blue_shield/migration.sql +1 -0
- package/src/lib/db/migrations/mssql/20260801003652_perpetual_blue_shield/snapshot.json +516 -0
- package/src/lib/db/migrations/mssql/20260812174642_user_id_text/migration.sql +2 -0
- package/src/lib/db/migrations/mssql/20260812174642_user_id_text/snapshot.json +516 -0
- package/src/lib/db/migrations/pg/20260801084117_thick_ben_grimm/migration.sql +53 -0
- package/src/lib/db/migrations/pg/20260801084117_thick_ben_grimm/snapshot.json +584 -0
- package/src/lib/db/migrations/pg/20260812174622_user_id_text/migration.sql +2 -0
- package/src/lib/db/migrations/pg/20260812174622_user_id_text/snapshot.json +584 -0
- package/src/lib/db/{schema.ts → schema.mssql.ts} +29 -18
- package/src/lib/db/schema.pg.ts +95 -0
- package/src/lib/factory.ts +44 -89
- package/src/lib/graph/index.ts +12 -40
- package/src/lib/graph/resolver.ts +146 -116
- package/src/lib/index.ts +11 -4
- package/src/lib/redis.ts +44 -0
- package/src/lib/routes/chat.ts +91 -62
- package/src/lib/routes/files.ts +105 -83
- package/src/lib/routes/owned-thread.ts +17 -0
- package/src/lib/routes/threads.ts +14 -30
- package/src/lib/routes/ws.ts +9 -3
- package/src/lib/types.ts +37 -36
- package/src/lib/ws/connections.ts +9 -1
- package/tsconfig.json +48 -0
- package/dist/src/lib/adapters/database.d.ts +0 -45
- package/dist/src/lib/adapters/mssql.d.ts +0 -3
- package/dist/src/lib/ai/active-streams.d.ts +0 -14
- package/dist/src/lib/ai/context/index.d.ts +0 -16
- package/dist/src/lib/ai/tools/capture-files.tool.d.ts +0 -6
- package/dist/src/lib/cli/extract-endpoints.d.ts +0 -6
- package/dist/src/lib/graph/expand-domains.d.ts +0 -2
- package/dist/src/lib/graph/generate-cypher.d.ts +0 -22
- package/dist/src/lib/graph/seed.d.ts +0 -19
- package/dist/src/lib/graph/validate.d.ts +0 -2
- package/dist/src/lib/routes/index.d.ts +0 -4
- package/dist/src/lib/ws/events.d.ts +0 -39
- package/dist/src/lib/ws/index.d.ts +0 -3
- package/dist/src/lib/ws/notify.d.ts +0 -2
- package/src/lib/adapters/database.ts +0 -48
- package/src/lib/adapters/mssql.ts +0 -231
- package/src/lib/ai/active-streams.ts +0 -123
- package/src/lib/ai/context/index.ts +0 -80
- package/src/lib/ai/tools/capture-files.tool.ts +0 -20
- package/src/lib/cli/extract-endpoints.ts +0 -550
- package/src/lib/graph/expand-domains.ts +0 -276
- package/src/lib/graph/generate-cypher.ts +0 -192
- package/src/lib/graph/seed.ts +0 -162
- package/src/lib/graph/validate.ts +0 -78
- package/src/lib/routes/index.ts +0 -4
- package/src/lib/ws/events.ts +0 -39
- package/src/lib/ws/index.ts +0 -11
- package/src/lib/ws/notify.ts +0 -9
- package/src/sample/db/client.ts +0 -9
- package/src/sample/db/migrations/20260411023125_rich_purple_man/migration.sql +0 -5
- package/src/sample/db/migrations/20260411023125_rich_purple_man/snapshot.json +0 -50
- package/src/sample/db/schema.ts +0 -10
- package/src/sample/domains/account/concepts/session.concept.ts +0 -17
- package/src/sample/domains/account/endpoints/listCurrentSessions.endpoint.ts +0 -31
- package/src/sample/domains/account/endpoints/revokeAllOtherSessions.endpoint.ts +0 -22
- package/src/sample/domains/account/endpoints/revokeCurrentSession.endpoint.ts +0 -33
- package/src/sample/domains/account/index.ts +0 -18
- package/src/sample/domains/appraisals/concepts/appraisalCycle.concept.ts +0 -15
- package/src/sample/domains/appraisals/concepts/appraisalRecord.concept.ts +0 -20
- package/src/sample/domains/appraisals/concepts/appraisalRecordCompetency.concept.ts +0 -10
- package/src/sample/domains/appraisals/concepts/appraisalRecordFunctionalRequirement.concept.ts +0 -10
- package/src/sample/domains/appraisals/concepts/appraisalRecordGoal.concept.ts +0 -17
- package/src/sample/domains/appraisals/endpoints/getAppraisalRecordById.endpoint.ts +0 -321
- package/src/sample/domains/appraisals/endpoints/getAppraisalRecordCompetencies.endpoint.ts +0 -120
- package/src/sample/domains/appraisals/endpoints/getAppraisalRecordFunctionalRequirements.endpoint.ts +0 -126
- package/src/sample/domains/appraisals/endpoints/getAppraisalRecordGoals.endpoint.ts +0 -104
- package/src/sample/domains/appraisals/endpoints/getAppraisalRecordScore.endpoint.ts +0 -58
- package/src/sample/domains/appraisals/endpoints/listAppraisalCyclesSimple.endpoint.ts +0 -52
- package/src/sample/domains/appraisals/endpoints/listAppraisalRecords.endpoint.ts +0 -245
- package/src/sample/domains/appraisals/endpoints/listAppraisalTemplatesSimple.endpoint.ts +0 -52
- package/src/sample/domains/appraisals/index.ts +0 -40
- package/src/sample/domains/appraisals/rules/appraisalRecordScoping.rule.ts +0 -7
- package/src/sample/domains/attendance/concepts/attendancePermission.concept.ts +0 -17
- package/src/sample/domains/attendance/concepts/attendanceTransaction.concept.ts +0 -17
- package/src/sample/domains/attendance/concepts/publicHoliday.concept.ts +0 -10
- package/src/sample/domains/attendance/concepts/punch.concept.ts +0 -19
- package/src/sample/domains/attendance/endpoints/getAttendanceTransactionById.endpoint.ts +0 -444
- package/src/sample/domains/attendance/endpoints/getCurrentAttendanceProfile.endpoint.ts +0 -886
- package/src/sample/domains/attendance/endpoints/getCurrentAttendanceStatistics.endpoint.ts +0 -49
- package/src/sample/domains/attendance/endpoints/listAttendancePermissions.endpoint.ts +0 -176
- package/src/sample/domains/attendance/endpoints/listAttendanceTransactionStates.endpoint.ts +0 -26
- package/src/sample/domains/attendance/endpoints/listAttendanceTransactions.endpoint.ts +0 -373
- package/src/sample/domains/attendance/endpoints/listPublicHolidaysSimple.endpoint.ts +0 -52
- package/src/sample/domains/attendance/endpoints/listPunchTypes.endpoint.ts +0 -25
- package/src/sample/domains/attendance/endpoints/listPunches.endpoint.ts +0 -178
- package/src/sample/domains/attendance/index.ts +0 -41
- package/src/sample/domains/attendance/services/attendancePermissions.service.ts +0 -15
- package/src/sample/domains/employees/concepts/employee.concept.ts +0 -20
- package/src/sample/domains/employees/concepts/employeeBankAccount.concept.ts +0 -19
- package/src/sample/domains/employees/concepts/employeeChild.concept.ts +0 -19
- package/src/sample/domains/employees/concepts/employeeDocument.concept.ts +0 -21
- package/src/sample/domains/employees/concepts/employeeEvent.concept.ts +0 -21
- package/src/sample/domains/employees/concepts/employeeExperience.concept.ts +0 -18
- package/src/sample/domains/employees/concepts/employeeJobLevelChange.concept.ts +0 -21
- package/src/sample/domains/employees/concepts/employeeMedal.concept.ts +0 -20
- package/src/sample/domains/employees/concepts/employeeQualification.concept.ts +0 -20
- package/src/sample/domains/employees/concepts/employeeSpouse.concept.ts +0 -21
- package/src/sample/domains/employees/concepts/employeeViolation.concept.ts +0 -19
- package/src/sample/domains/employees/endpoints/getCurrentEmployee.endpoint.ts +0 -1651
- package/src/sample/domains/employees/endpoints/getCurrentIdentity.endpoint.ts +0 -197
- package/src/sample/domains/employees/endpoints/getCurrentManagers.endpoint.ts +0 -142
- package/src/sample/domains/employees/endpoints/getEmployeeById.endpoint.ts +0 -1659
- package/src/sample/domains/employees/endpoints/getEmployeeStatistics.endpoint.ts +0 -43
- package/src/sample/domains/employees/endpoints/listBankAccounts.endpoint.ts +0 -223
- package/src/sample/domains/employees/endpoints/listChildren.endpoint.ts +0 -211
- package/src/sample/domains/employees/endpoints/listDocuments.endpoint.ts +0 -222
- package/src/sample/domains/employees/endpoints/listEmployeesSimple.endpoint.ts +0 -156
- package/src/sample/domains/employees/endpoints/listEvents.endpoint.ts +0 -120
- package/src/sample/domains/employees/endpoints/listExperiences.endpoint.ts +0 -188
- package/src/sample/domains/employees/endpoints/listJobLevelChanges.endpoint.ts +0 -240
- package/src/sample/domains/employees/endpoints/listMedals.endpoint.ts +0 -266
- package/src/sample/domains/employees/endpoints/listQualifications.endpoint.ts +0 -265
- package/src/sample/domains/employees/endpoints/listSpouses.endpoint.ts +0 -278
- package/src/sample/domains/employees/endpoints/listViolations.endpoint.ts +0 -245
- package/src/sample/domains/employees/index.ts +0 -75
- package/src/sample/domains/employees/services/employees.service.ts +0 -181
- package/src/sample/domains/index.ts +0 -10
- package/src/sample/domains/leaves/concepts/leave.concept.ts +0 -21
- package/src/sample/domains/leaves/concepts/leaveBalance.concept.ts +0 -17
- package/src/sample/domains/leaves/concepts/leaveBalanceTransaction.concept.ts +0 -16
- package/src/sample/domains/leaves/concepts/leaveType.concept.ts +0 -13
- package/src/sample/domains/leaves/concepts/leaveTypes.concept.ts +0 -205
- package/src/sample/domains/leaves/endpoints/getBalance.endpoint.ts +0 -53
- package/src/sample/domains/leaves/endpoints/getLeaveById.endpoint.ts +0 -53
- package/src/sample/domains/leaves/endpoints/listBalanceTransactions.endpoint.ts +0 -196
- package/src/sample/domains/leaves/endpoints/listBalanceTypes.endpoint.ts +0 -26
- package/src/sample/domains/leaves/endpoints/listBalances.endpoint.ts +0 -201
- package/src/sample/domains/leaves/endpoints/listLeaveTypes.endpoint.ts +0 -28
- package/src/sample/domains/leaves/endpoints/listLeaves.endpoint.ts +0 -234
- package/src/sample/domains/leaves/index.ts +0 -38
- package/src/sample/domains/leaves/services/leaveRequests.service.ts +0 -232
- package/src/sample/domains/notifications/concepts/notification.concept.ts +0 -19
- package/src/sample/domains/notifications/endpoints/countMyNotifications.endpoint.ts +0 -21
- package/src/sample/domains/notifications/endpoints/getMyNotification.endpoint.ts +0 -57
- package/src/sample/domains/notifications/endpoints/listMyNotifications.endpoint.ts +0 -59
- package/src/sample/domains/notifications/endpoints/markMyNotificationAsRead.endpoint.ts +0 -32
- package/src/sample/domains/notifications/index.ts +0 -20
- package/src/sample/domains/payroll/concepts/payslip.concept.ts +0 -18
- package/src/sample/domains/payroll/concepts/salaryCertificate.concept.ts +0 -17
- package/src/sample/domains/payroll/concepts/salaryCertificateRequestingEntity.concept.ts +0 -8
- package/src/sample/domains/payroll/endpoints/getPayslipById.endpoint.ts +0 -238
- package/src/sample/domains/payroll/endpoints/listPayslips.endpoint.ts +0 -216
- package/src/sample/domains/payroll/endpoints/listSalaryCertificateLanguages.endpoint.ts +0 -25
- package/src/sample/domains/payroll/endpoints/listSalaryCertificateRequestingEntities.endpoint.ts +0 -62
- package/src/sample/domains/payroll/endpoints/listSalaryCertificateTypes.endpoint.ts +0 -24
- package/src/sample/domains/payroll/endpoints/listSalaryCertificates.endpoint.ts +0 -122
- package/src/sample/domains/payroll/endpoints/previewSalaryCertificate.endpoint.ts +0 -45
- package/src/sample/domains/payroll/index.ts +0 -32
- package/src/sample/domains/payroll/rules/payrollEmployeeContext.rule.ts +0 -7
- package/src/sample/domains/payroll/services/salaryCertificates.service.ts +0 -15
- package/src/sample/domains/servicing/concepts/service.concept.ts +0 -6
- package/src/sample/domains/servicing/concepts/serviceRequest.concept.ts +0 -12
- package/src/sample/domains/servicing/concepts/serviceRequestApproval.concept.ts +0 -9
- package/src/sample/domains/servicing/endpoints/cancelServiceRequest.endpoint.ts +0 -21
- package/src/sample/domains/servicing/endpoints/createServiceRequest.endpoint.ts +0 -511
- package/src/sample/domains/servicing/endpoints/getServiceRequest.endpoint.ts +0 -352
- package/src/sample/domains/servicing/endpoints/getServiceRequestFormItems.endpoint.ts +0 -219
- package/src/sample/domains/servicing/endpoints/getServiceRequestTransactionFormItems.endpoint.ts +0 -216
- package/src/sample/domains/servicing/endpoints/getServiceStates.endpoint.ts +0 -47
- package/src/sample/domains/servicing/endpoints/invokeServiceRequestAction.endpoint.ts +0 -139
- package/src/sample/domains/servicing/endpoints/listServiceRequests.endpoint.ts +0 -292
- package/src/sample/domains/servicing/endpoints/listServices.endpoint.ts +0 -108
- package/src/sample/domains/servicing/endpoints/updateServiceRequest.endpoint.ts +0 -355
- package/src/sample/domains/servicing/index.ts +0 -44
- package/src/sample/domains/servicing/rules/checkValidActions.rule.ts +0 -7
- package/src/sample/domains/servicing/rules/createServiceRequest.rule.ts +0 -7
- package/src/sample/domains/servicing/rules/filterServiceRequestsByState.rule.ts +0 -7
- package/src/sample/domains/servicing/rules/passingOptionFields.rule.ts +0 -7
- package/src/sample/domains/shared/rules/pagination.rule.ts +0 -7
- package/src/sample/domains/suggestions/concepts/suggestion.concept.ts +0 -19
- package/src/sample/domains/suggestions/concepts/suggestionCategory.concept.ts +0 -7
- package/src/sample/domains/suggestions/concepts/suggestionImpactLevel.concept.ts +0 -7
- package/src/sample/domains/suggestions/endpoints/createSuggestion.endpoint.ts +0 -705
- package/src/sample/domains/suggestions/endpoints/deleteSuggestion.endpoint.ts +0 -32
- package/src/sample/domains/suggestions/endpoints/getSuggestionById.endpoint.ts +0 -635
- package/src/sample/domains/suggestions/endpoints/listSuggestionCategories.endpoint.ts +0 -62
- package/src/sample/domains/suggestions/endpoints/listSuggestionImpactLevels.endpoint.ts +0 -62
- package/src/sample/domains/suggestions/endpoints/listSuggestionStates.endpoint.ts +0 -24
- package/src/sample/domains/suggestions/endpoints/listSuggestions.endpoint.ts +0 -132
- package/src/sample/domains/suggestions/endpoints/updateSuggestion.endpoint.ts +0 -690
- package/src/sample/domains/suggestions/endpoints/updateSuggestionState.endpoint.ts +0 -39
- package/src/sample/domains/suggestions/index.ts +0 -34
- package/src/sample/domains/suggestions/rules/suggestionScope.rule.ts +0 -7
- package/src/sample/domains/surveys/concepts/survey.concept.ts +0 -10
- package/src/sample/domains/surveys/concepts/surveyResponse.concept.ts +0 -14
- package/src/sample/domains/surveys/endpoints/getSurveyResponseById.endpoint.ts +0 -131
- package/src/sample/domains/surveys/endpoints/getTargetedSurvey.endpoint.ts +0 -129
- package/src/sample/domains/surveys/endpoints/listTargetedSurveys.endpoint.ts +0 -160
- package/src/sample/domains/surveys/endpoints/respondToSurvey.endpoint.ts +0 -144
- package/src/sample/domains/surveys/index.ts +0 -21
- package/src/sample/drizzle.config.ts +0 -11
- package/src/sample/index.bak.ts +0 -341
- package/src/sample/index.ts +0 -318
- package/src/sample/official-statements/defaults.ts +0 -57
- package/src/sample/official-statements/routes.ts +0 -137
- package/src/sample/official-statements/service.ts +0 -148
- package/src/sample/official-statements/types.ts +0 -23
- /package/src/lib/db/migrations/{20260326231647_nice_speedball → mssql/20260326231647_nice_speedball}/migration.sql +0 -0
- /package/src/lib/db/migrations/{20260326231647_nice_speedball → mssql/20260326231647_nice_speedball}/snapshot.json +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Redis } from "ioredis";
|
|
2
|
+
import type { StreamChunk } from "@tanstack/ai";
|
|
3
|
+
/**
|
|
4
|
+
* Whether a client-supplied resume offset belongs to `runId`. The offset names
|
|
5
|
+
* the log it replays, so an offset naming another run would replay that run's
|
|
6
|
+
* log to whoever presents it — matching the prefix this adapter encodes is what
|
|
7
|
+
* binds a resume to the thread the caller owns.
|
|
8
|
+
*/
|
|
9
|
+
export declare function offsetBelongsToRun(offset: string, runId: string): boolean;
|
|
10
|
+
type RedisStreamLogOptions = {
|
|
11
|
+
/** `null` builds a producer (appends flow into the log); an offset builds a reader. */
|
|
12
|
+
resumeOffset: string | null;
|
|
13
|
+
/** How long the log stays replayable after its last append or `close()`. */
|
|
14
|
+
streamTtlMs: number;
|
|
15
|
+
/** How long a reader waits for the run's first entry before failing. */
|
|
16
|
+
firstChunkDeadlineMs: number;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the run's producer is still alive. While it is, a caught-up
|
|
19
|
+
* reader parks indefinitely between chunks — the producer owns termination.
|
|
20
|
+
* Once it reports dead with the log still unclosed, the run was orphaned
|
|
21
|
+
* (producer crashed before `close()`), and the read fails so the joiner
|
|
22
|
+
* gets a terminal error instead of tailing forever.
|
|
23
|
+
*/
|
|
24
|
+
isLive?: () => Promise<boolean>;
|
|
25
|
+
};
|
|
26
|
+
export declare function redisStreamLog(redis: Redis, runId: string, options: RedisStreamLogOptions): {
|
|
27
|
+
resumeFrom: () => string | null;
|
|
28
|
+
append: (chunks: import("@tanstack/ai").AGUIEvent[]) => Promise<string[]>;
|
|
29
|
+
snapshot: () => Promise<{
|
|
30
|
+
offset: string;
|
|
31
|
+
chunk: StreamChunk;
|
|
32
|
+
}[]>;
|
|
33
|
+
close: () => Promise<void>;
|
|
34
|
+
read: (offset: string, signal?: AbortSignal) => AsyncGenerator<{
|
|
35
|
+
offset: string;
|
|
36
|
+
chunk: StreamChunk;
|
|
37
|
+
}, void, any>;
|
|
38
|
+
};
|
|
39
|
+
export {};
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import type { ResolvedCortexAgentConfig } from "../../config";
|
|
3
|
+
import type { CcRuntime } from "../../cc/registry";
|
|
4
|
+
export type ExecuteCodeToolOptions = {
|
|
5
|
+
backendFetch?: NonNullable<ResolvedCortexAgentConfig["backendFetch"]>;
|
|
6
|
+
attachmentSentinels?: boolean;
|
|
7
|
+
token: string;
|
|
8
|
+
cc?: CcRuntime;
|
|
9
|
+
};
|
|
10
|
+
export declare function createExecuteCodeTool(options: ExecuteCodeToolOptions): import("@tanstack/ai").ServerTool<z.ZodObject<{
|
|
11
|
+
code: z.ZodString;
|
|
12
|
+
}, z.core.$strip>, undefined, "executeCode", unknown, false, undefined> & {
|
|
13
|
+
inputSchema: z.ZodObject<{
|
|
14
|
+
code: z.ZodString;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
outputSchema: undefined;
|
|
17
|
+
approvalSchema: undefined;
|
|
18
|
+
};
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import type { Neo4jClient } from "../../../../contracts/graph";
|
|
3
|
+
export declare function createQueryGraphTool(neo4j: Neo4jClient): import("@tanstack/ai").ServerTool<z.ZodObject<{
|
|
4
|
+
query: z.ZodString;
|
|
5
|
+
parameters: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, z.core.$strip>, undefined, "queryGraph", unknown, false, undefined> & {
|
|
7
|
+
inputSchema: z.ZodObject<{
|
|
8
|
+
query: z.ZodString;
|
|
9
|
+
parameters: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
outputSchema: undefined;
|
|
12
|
+
approvalSchema: undefined;
|
|
13
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import type { ResolvedCortexAgentConfig } from "../../config";
|
|
3
|
+
type ReadAttachmentToolOptions = {
|
|
4
|
+
db: ResolvedCortexAgentConfig["db"];
|
|
5
|
+
storage: NonNullable<ResolvedCortexAgentConfig["storage"]>;
|
|
6
|
+
vision: NonNullable<ResolvedCortexAgentConfig["vision"]>;
|
|
7
|
+
threadId: string;
|
|
8
|
+
userId: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function createReadAttachmentTool(options: ReadAttachmentToolOptions): import("@tanstack/ai").ServerTool<z.ZodObject<{
|
|
11
|
+
attachmentId: z.ZodString;
|
|
12
|
+
query: z.ZodString;
|
|
13
|
+
}, z.core.$strip>, undefined, "readAttachment", unknown, false, undefined> & {
|
|
14
|
+
inputSchema: z.ZodObject<{
|
|
15
|
+
attachmentId: z.ZodString;
|
|
16
|
+
query: z.ZodString;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
outputSchema: undefined;
|
|
19
|
+
approvalSchema: undefined;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import type { CcRuntime } from "../../cc/registry";
|
|
3
|
+
/** The input shape all three catalog search tools share; only the query hint differs. */
|
|
4
|
+
export declare function searchInputSchema(queryDescription: string): z.ZodObject<{
|
|
5
|
+
query: z.ZodString;
|
|
6
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
/** The runtime search request those tools send: the model's input plus the turn's context. */
|
|
9
|
+
export declare function searchRequest(cc: CcRuntime, input: {
|
|
10
|
+
query: string;
|
|
11
|
+
limit?: number;
|
|
12
|
+
}): {
|
|
13
|
+
locale: "ar" | "en";
|
|
14
|
+
threadId: string;
|
|
15
|
+
query: string;
|
|
16
|
+
limit?: number;
|
|
17
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import type { CcRuntime } from "../../cc/registry";
|
|
3
|
+
export declare function createSearchKnowledgeTool(cc: CcRuntime): import("@tanstack/ai").ServerTool<z.ZodObject<{
|
|
4
|
+
query: z.ZodString;
|
|
5
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
service: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, z.core.$strip>, undefined, "searchKnowledge", unknown, false, undefined> & {
|
|
8
|
+
inputSchema: z.ZodObject<{
|
|
9
|
+
query: z.ZodString;
|
|
10
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
service: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
outputSchema: undefined;
|
|
14
|
+
approvalSchema: undefined;
|
|
15
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CcRuntime } from "../../cc/registry";
|
|
2
|
+
export declare function createSearchServicesTool(cc: CcRuntime): import("@tanstack/ai").ServerTool<import("zod").ZodObject<{
|
|
3
|
+
query: import("zod").ZodString;
|
|
4
|
+
limit: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
5
|
+
}, import("zod/v4/core").$strip>, undefined, "searchServices", unknown, false, undefined> & {
|
|
6
|
+
inputSchema: import("zod").ZodObject<{
|
|
7
|
+
query: import("zod").ZodString;
|
|
8
|
+
limit: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
9
|
+
}, import("zod/v4/core").$strip>;
|
|
10
|
+
outputSchema: undefined;
|
|
11
|
+
approvalSchema: undefined;
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CcRuntime } from "../../cc/registry";
|
|
2
|
+
export declare function createSearchToolsTool(cc: CcRuntime): import("@tanstack/ai").ServerTool<import("zod").ZodObject<{
|
|
3
|
+
query: import("zod").ZodString;
|
|
4
|
+
limit: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
5
|
+
}, import("zod/v4/core").$strip>, undefined, "searchTools", unknown, false, undefined> & {
|
|
6
|
+
inputSchema: import("zod").ZodObject<{
|
|
7
|
+
query: import("zod").ZodString;
|
|
8
|
+
limit: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
9
|
+
}, import("zod/v4/core").$strip>;
|
|
10
|
+
outputSchema: undefined;
|
|
11
|
+
approvalSchema: undefined;
|
|
12
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AnyServerTool } from "@tanstack/ai";
|
|
2
|
+
import type { ResolvedCortexAgentConfig } from "../config";
|
|
3
|
+
import type { Attachment, Thread } from "../types";
|
|
4
|
+
import type { CcRuntime } from "../cc/registry";
|
|
5
|
+
import type { Neo4jClient } from "../../../contracts/graph";
|
|
6
|
+
type TurnToolsOptions = {
|
|
7
|
+
config: ResolvedCortexAgentConfig;
|
|
8
|
+
cc: CcRuntime | undefined;
|
|
9
|
+
neo4j: Neo4jClient | undefined;
|
|
10
|
+
thread: Thread;
|
|
11
|
+
userId: string;
|
|
12
|
+
token: string;
|
|
13
|
+
session: Record<string, unknown> | null;
|
|
14
|
+
requestContext: Record<string, unknown>;
|
|
15
|
+
threadAttachments: Attachment[];
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Assembles the tool set for one turn: built-ins gated on what the agent has
|
|
19
|
+
* configured, then the agent's own tools.
|
|
20
|
+
*
|
|
21
|
+
* User tools are appended last and deliberately win on name collision — an agent
|
|
22
|
+
* must be able to replace a built-in it doesn't want.
|
|
23
|
+
*/
|
|
24
|
+
export declare function buildTurnTools(options: TurnToolsOptions): AnyServerTool[];
|
|
25
|
+
/**
|
|
26
|
+
* Instruments tool calls for the callbacks an agent configured. Returns
|
|
27
|
+
* `undefined` when nothing is listening, so the caller can skip the middleware
|
|
28
|
+
* entirely.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createToolInstrumentation(options: TurnToolsOptions & {
|
|
31
|
+
onToolStart: (toolName: string, toolCallId: string) => void;
|
|
32
|
+
onToolFinish: (toolName: string, toolCallId: string) => void;
|
|
33
|
+
}): {
|
|
34
|
+
name: string;
|
|
35
|
+
onBeforeToolCall(_ctx: import("@tanstack/ai").ChatMiddlewareContext<unknown>, { toolName, toolCallId, args }: import("@tanstack/ai").ToolCallHookContext): void;
|
|
36
|
+
onAfterToolCall(_ctx: import("@tanstack/ai").ChatMiddlewareContext<unknown>, { toolName, toolCallId }: import("@tanstack/ai").AfterToolCallInfo): void;
|
|
37
|
+
} | undefined;
|
|
38
|
+
export declare function hasDefaultAttachmentInterceptor(config: ResolvedCortexAgentConfig): boolean;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type RasterizedPdf = {
|
|
2
|
+
pages: {
|
|
3
|
+
data: Uint8Array;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}[];
|
|
7
|
+
totalPages: number;
|
|
8
|
+
truncatedBy?: "page-limit" | "payload-limit";
|
|
9
|
+
};
|
|
10
|
+
export type RasterizePdfWorkerRequest = {
|
|
11
|
+
bytes: Uint8Array;
|
|
12
|
+
maxPayloadBytes?: number;
|
|
13
|
+
};
|
|
14
|
+
export type RasterizePdfWorkerResponse = {
|
|
15
|
+
status: "success";
|
|
16
|
+
result: RasterizedPdf;
|
|
17
|
+
} | {
|
|
18
|
+
status: "error";
|
|
19
|
+
message: string;
|
|
20
|
+
};
|
|
21
|
+
type RasterizePdfOptions = {
|
|
22
|
+
abortSignal?: AbortSignal;
|
|
23
|
+
maxPayloadBytes?: number;
|
|
24
|
+
};
|
|
25
|
+
export declare function rasterizePdf(bytes: Uint8Array, options?: RasterizePdfOptions): Promise<RasterizedPdf>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ResolvedCortexAgentConfig } from "../../config";
|
|
2
|
+
type VisionConfig = NonNullable<ResolvedCortexAgentConfig["vision"]>;
|
|
3
|
+
export declare function describeAttachment(vision: VisionConfig, contentType: string, base64: string, abortSignal?: AbortSignal): Promise<{
|
|
4
|
+
status: "skipped";
|
|
5
|
+
error?: undefined;
|
|
6
|
+
text?: undefined;
|
|
7
|
+
note?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
status: "failed";
|
|
10
|
+
error: string;
|
|
11
|
+
text?: undefined;
|
|
12
|
+
note?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
status: "success";
|
|
15
|
+
text: string;
|
|
16
|
+
note: string;
|
|
17
|
+
error?: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
status: "failed";
|
|
20
|
+
error?: undefined;
|
|
21
|
+
text?: undefined;
|
|
22
|
+
note?: undefined;
|
|
23
|
+
}>;
|
|
24
|
+
export declare function answerQuestionAbout(vision: VisionConfig, contentType: string, base64: string, query: string, abortSignal?: AbortSignal): Promise<{
|
|
25
|
+
status: "skipped";
|
|
26
|
+
error?: undefined;
|
|
27
|
+
text?: undefined;
|
|
28
|
+
note?: undefined;
|
|
29
|
+
} | {
|
|
30
|
+
status: "failed";
|
|
31
|
+
error: string;
|
|
32
|
+
text?: undefined;
|
|
33
|
+
note?: undefined;
|
|
34
|
+
} | {
|
|
35
|
+
status: "success";
|
|
36
|
+
text: string;
|
|
37
|
+
note: string;
|
|
38
|
+
error?: undefined;
|
|
39
|
+
} | {
|
|
40
|
+
status: "failed";
|
|
41
|
+
error?: undefined;
|
|
42
|
+
text?: undefined;
|
|
43
|
+
note?: undefined;
|
|
44
|
+
}>;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import type { ControlCenterConfig } from "../config";
|
|
2
|
+
import type { ExecuteRequest, ResolveRequest, SearchRequest } from "./types";
|
|
3
|
+
type ControlCenterFetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
4
|
+
export type ExecuteOptions = {
|
|
5
|
+
readOnly: boolean;
|
|
6
|
+
endUserToken?: string;
|
|
7
|
+
threadId: string;
|
|
8
|
+
turnKey: string;
|
|
9
|
+
stepIndex: number;
|
|
10
|
+
callIndex: number;
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
abortSignal?: AbortSignal;
|
|
13
|
+
};
|
|
14
|
+
export declare class ControlCenterClient {
|
|
15
|
+
readonly url: string;
|
|
16
|
+
readonly cacheKey: string;
|
|
17
|
+
private readonly apiKey;
|
|
18
|
+
private readonly fetcher;
|
|
19
|
+
constructor(config: ControlCenterConfig, fetcher?: ControlCenterFetch);
|
|
20
|
+
getConfig(agentId: string, etag?: string, abortSignal?: AbortSignal): Promise<{
|
|
21
|
+
readonly status: "not-modified";
|
|
22
|
+
readonly config?: undefined;
|
|
23
|
+
readonly etag?: undefined;
|
|
24
|
+
} | {
|
|
25
|
+
readonly status: "not-found";
|
|
26
|
+
readonly config?: undefined;
|
|
27
|
+
readonly etag?: undefined;
|
|
28
|
+
} | {
|
|
29
|
+
readonly status: "modified";
|
|
30
|
+
readonly config: {
|
|
31
|
+
agentId: string;
|
|
32
|
+
systemPrompt: string;
|
|
33
|
+
promptVariables: ("userName" | "channel" | "locale" | "utcTime" | "timezone")[];
|
|
34
|
+
catalogBlurb: string;
|
|
35
|
+
defaultLocale: "ar" | "en";
|
|
36
|
+
metaTools: {
|
|
37
|
+
searchKnowledge: boolean;
|
|
38
|
+
searchTools: boolean;
|
|
39
|
+
searchServices: boolean;
|
|
40
|
+
};
|
|
41
|
+
limits: {
|
|
42
|
+
resolveTokenBudget: number;
|
|
43
|
+
executeTimeoutMs: number;
|
|
44
|
+
maxResponseBytes: number;
|
|
45
|
+
};
|
|
46
|
+
catalogVersion: string;
|
|
47
|
+
publishedAt: string;
|
|
48
|
+
};
|
|
49
|
+
readonly etag: string | null;
|
|
50
|
+
} | null>;
|
|
51
|
+
resolve(agentId: string, request: ResolveRequest, abortSignal?: AbortSignal): Promise<{
|
|
52
|
+
resolveId: string;
|
|
53
|
+
catalogVersion: string;
|
|
54
|
+
locale: "ar" | "en";
|
|
55
|
+
knowledge: {
|
|
56
|
+
chunkId: string;
|
|
57
|
+
text: string;
|
|
58
|
+
score: number;
|
|
59
|
+
citation: {
|
|
60
|
+
documentId: string;
|
|
61
|
+
documentTitle: string;
|
|
62
|
+
page: number | null;
|
|
63
|
+
section: string | null;
|
|
64
|
+
uri: string | null;
|
|
65
|
+
service: string | null;
|
|
66
|
+
};
|
|
67
|
+
}[];
|
|
68
|
+
tools: {
|
|
69
|
+
toolId: string;
|
|
70
|
+
name: string;
|
|
71
|
+
version: number;
|
|
72
|
+
readOnly: boolean;
|
|
73
|
+
tags: string[];
|
|
74
|
+
signature: string;
|
|
75
|
+
score: number | null;
|
|
76
|
+
pinned: boolean;
|
|
77
|
+
}[];
|
|
78
|
+
services: {
|
|
79
|
+
serviceId: string;
|
|
80
|
+
key: string;
|
|
81
|
+
name: string;
|
|
82
|
+
card: string;
|
|
83
|
+
score: number;
|
|
84
|
+
}[];
|
|
85
|
+
sharedShapes: {
|
|
86
|
+
ref: string;
|
|
87
|
+
shape: string;
|
|
88
|
+
}[];
|
|
89
|
+
budget: {
|
|
90
|
+
requested: number;
|
|
91
|
+
used: number;
|
|
92
|
+
truncated: boolean;
|
|
93
|
+
};
|
|
94
|
+
} | null>;
|
|
95
|
+
searchTools(agentId: string, request: SearchRequest, abortSignal?: AbortSignal): Promise<{
|
|
96
|
+
catalogVersion: string;
|
|
97
|
+
tools: {
|
|
98
|
+
toolId: string;
|
|
99
|
+
name: string;
|
|
100
|
+
version: number;
|
|
101
|
+
readOnly: boolean;
|
|
102
|
+
tags: string[];
|
|
103
|
+
signature: string;
|
|
104
|
+
score: number | null;
|
|
105
|
+
pinned: boolean;
|
|
106
|
+
}[];
|
|
107
|
+
sharedShapes: {
|
|
108
|
+
ref: string;
|
|
109
|
+
shape: string;
|
|
110
|
+
}[];
|
|
111
|
+
} | null>;
|
|
112
|
+
searchServices(agentId: string, request: SearchRequest, abortSignal?: AbortSignal): Promise<{
|
|
113
|
+
catalogVersion: string;
|
|
114
|
+
services: {
|
|
115
|
+
serviceId: string;
|
|
116
|
+
key: string;
|
|
117
|
+
name: string;
|
|
118
|
+
card: string;
|
|
119
|
+
score: number;
|
|
120
|
+
}[];
|
|
121
|
+
tools: {
|
|
122
|
+
toolId: string;
|
|
123
|
+
name: string;
|
|
124
|
+
version: number;
|
|
125
|
+
readOnly: boolean;
|
|
126
|
+
tags: string[];
|
|
127
|
+
signature: string;
|
|
128
|
+
score: number | null;
|
|
129
|
+
pinned: boolean;
|
|
130
|
+
}[];
|
|
131
|
+
sharedShapes: {
|
|
132
|
+
ref: string;
|
|
133
|
+
shape: string;
|
|
134
|
+
}[];
|
|
135
|
+
} | null>;
|
|
136
|
+
searchKnowledge(agentId: string, request: SearchRequest, abortSignal?: AbortSignal): Promise<{
|
|
137
|
+
catalogVersion: string;
|
|
138
|
+
knowledge: {
|
|
139
|
+
chunkId: string;
|
|
140
|
+
text: string;
|
|
141
|
+
score: number;
|
|
142
|
+
citation: {
|
|
143
|
+
documentId: string;
|
|
144
|
+
documentTitle: string;
|
|
145
|
+
page: number | null;
|
|
146
|
+
section: string | null;
|
|
147
|
+
uri: string | null;
|
|
148
|
+
service: string | null;
|
|
149
|
+
};
|
|
150
|
+
}[];
|
|
151
|
+
} | null>;
|
|
152
|
+
execute(agentId: string, toolId: string, request: ExecuteRequest, options: ExecuteOptions): Promise<{
|
|
153
|
+
error: {
|
|
154
|
+
kind: "timeout" | "upstream_4xx" | "upstream_5xx" | "schema_mismatch" | "rate_limited" | "not_found" | "unauthorized" | "invalid_request" | "egress_blocked" | "internal";
|
|
155
|
+
detail: string;
|
|
156
|
+
retryable: boolean;
|
|
157
|
+
retryAfterSeconds?: number | undefined;
|
|
158
|
+
upstreamStatus?: number | undefined;
|
|
159
|
+
};
|
|
160
|
+
} | {
|
|
161
|
+
toolId: string;
|
|
162
|
+
name: string;
|
|
163
|
+
version: number;
|
|
164
|
+
output: unknown;
|
|
165
|
+
meta: {
|
|
166
|
+
upstreamStatus: number;
|
|
167
|
+
durationMs: number;
|
|
168
|
+
replayed: boolean;
|
|
169
|
+
truncated: boolean;
|
|
170
|
+
truncatedPaths: string[];
|
|
171
|
+
drift: {
|
|
172
|
+
path: string;
|
|
173
|
+
kind: "missing" | "unexpected" | "type_mismatch";
|
|
174
|
+
}[];
|
|
175
|
+
};
|
|
176
|
+
} | null>;
|
|
177
|
+
private agentPath;
|
|
178
|
+
private post;
|
|
179
|
+
private postResponse;
|
|
180
|
+
private request;
|
|
181
|
+
private parse;
|
|
182
|
+
}
|
|
183
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ControlCenterClient } from "./client";
|
|
2
|
+
export declare function getControlCenterConfig(cc: ControlCenterClient, agentId: string, abortSignal?: AbortSignal): Promise<{
|
|
3
|
+
agentId: string;
|
|
4
|
+
systemPrompt: string;
|
|
5
|
+
promptVariables: ("userName" | "channel" | "locale" | "utcTime" | "timezone")[];
|
|
6
|
+
catalogBlurb: string;
|
|
7
|
+
defaultLocale: "ar" | "en";
|
|
8
|
+
metaTools: {
|
|
9
|
+
searchKnowledge: boolean;
|
|
10
|
+
searchTools: boolean;
|
|
11
|
+
searchServices: boolean;
|
|
12
|
+
};
|
|
13
|
+
limits: {
|
|
14
|
+
resolveTokenBudget: number;
|
|
15
|
+
executeTimeoutMs: number;
|
|
16
|
+
maxResponseBytes: number;
|
|
17
|
+
};
|
|
18
|
+
catalogVersion: string;
|
|
19
|
+
publishedAt: string;
|
|
20
|
+
} | null>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ResolveResponse, RuntimeAgentConfig } from "./types";
|
|
2
|
+
type SharedShape = ResolveResponse["sharedShapes"][number];
|
|
3
|
+
type ToolSignature = ResolveResponse["tools"][number];
|
|
4
|
+
type ServiceCard = ResolveResponse["services"][number];
|
|
5
|
+
type KnowledgeChunk = ResolveResponse["knowledge"][number];
|
|
6
|
+
/** Values for the published prompt's `{{variable}}` placeholders, read from session/request context. */
|
|
7
|
+
export declare function buildPromptVariables(promptVariables: RuntimeAgentConfig["promptVariables"], sources: Record<string, unknown>): Record<string, string>;
|
|
8
|
+
export declare function formatSharedShapes(shapes: SharedShape[]): string;
|
|
9
|
+
export declare function formatToolSignatures(tools: ToolSignature[]): string;
|
|
10
|
+
export declare function formatServiceCards(services: ServiceCard[]): string;
|
|
11
|
+
export declare function formatKnowledgeChunks(chunks: KnowledgeChunk[]): string;
|
|
12
|
+
export type CcPromptInput = {
|
|
13
|
+
config: RuntimeAgentConfig;
|
|
14
|
+
resolved: ResolveResponse | null;
|
|
15
|
+
variables: Record<string, string>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Dumb concatenator by contract: `signature`, `card`, and `shape` arrive
|
|
19
|
+
* pre-rendered from Control Center and are injected verbatim — never
|
|
20
|
+
* re-rendered from structured fields.
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildCcSection(cc: CcPromptInput): string;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ControlCenterClient } from "./client";
|
|
2
|
+
import type { RuntimeAgentConfig } from "./types";
|
|
3
|
+
export type CcToolBinding = {
|
|
4
|
+
toolId: string;
|
|
5
|
+
readOnly: boolean;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Turn-scoped and mutable: seeded from /resolve, extended by searchTools
|
|
9
|
+
* mid-turn so a tool discovered at step 3 is callable at step 4.
|
|
10
|
+
*/
|
|
11
|
+
export type CcToolRegistry = Map<string, CcToolBinding>;
|
|
12
|
+
export declare function registerCcTools(registry: CcToolRegistry, tools: {
|
|
13
|
+
name: string;
|
|
14
|
+
toolId: string;
|
|
15
|
+
readOnly: boolean;
|
|
16
|
+
}[]): void;
|
|
17
|
+
export declare function recordRecentCcTool(threadId: string, name: string): void;
|
|
18
|
+
export declare function getRecentCcTools(threadId: string): string[];
|
|
19
|
+
/** Everything a CC-aware tool needs for one turn. */
|
|
20
|
+
export type CcRuntime = {
|
|
21
|
+
client: ControlCenterClient;
|
|
22
|
+
agentId: string;
|
|
23
|
+
config: RuntimeAgentConfig;
|
|
24
|
+
registry: CcToolRegistry;
|
|
25
|
+
threadId: string;
|
|
26
|
+
turnKey: string;
|
|
27
|
+
userId: string;
|
|
28
|
+
locale: RuntimeAgentConfig["defaultLocale"];
|
|
29
|
+
endUserToken: string;
|
|
30
|
+
abortSignal?: AbortSignal;
|
|
31
|
+
getStepIndex: () => number;
|
|
32
|
+
nextCallIndex: (stepIndex: number) => number;
|
|
33
|
+
onToolProgress?: (toolName: string, toolCallId: string, status: "started" | "finished") => void;
|
|
34
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
export { AGENT_SLUG_PATTERN, executeResponseSchema, resolveResponseSchema, runtimeAgentConfigSchema, searchKnowledgeResponseSchema, searchServicesResponseSchema, searchToolsResponseSchema, type ExecuteRequest, type ResolveRequest, type ResolveResponse, type RuntimeAgentConfig, type SearchRequest, } from "../../../contracts/runtime";
|
|
3
|
+
/**
|
|
4
|
+
* The contract's error envelope, hardened for this consumer: a newer runtime may
|
|
5
|
+
* answer with an error kind this build has never heard of, which must degrade to a
|
|
6
|
+
* generic non-retryable `internal` rather than fail the parse.
|
|
7
|
+
*/
|
|
8
|
+
export declare const runtimeErrorSchema: z.ZodPreprocess<z.ZodObject<{
|
|
9
|
+
error: z.ZodObject<{
|
|
10
|
+
kind: z.ZodEnum<{
|
|
11
|
+
timeout: "timeout";
|
|
12
|
+
upstream_4xx: "upstream_4xx";
|
|
13
|
+
upstream_5xx: "upstream_5xx";
|
|
14
|
+
schema_mismatch: "schema_mismatch";
|
|
15
|
+
rate_limited: "rate_limited";
|
|
16
|
+
not_found: "not_found";
|
|
17
|
+
unauthorized: "unauthorized";
|
|
18
|
+
invalid_request: "invalid_request";
|
|
19
|
+
egress_blocked: "egress_blocked";
|
|
20
|
+
internal: "internal";
|
|
21
|
+
}>;
|
|
22
|
+
detail: z.ZodString;
|
|
23
|
+
retryable: z.ZodBoolean;
|
|
24
|
+
retryAfterSeconds: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
upstreamStatus: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
}, z.core.$strip>>;
|