@solidxai/core 0.1.22-beta.3 → 0.1.22-beta.4

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 (203) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/constants/error-messages.d.ts +1 -1
  3. package/dist/constants/error-messages.d.ts.map +1 -1
  4. package/dist/constants/error-messages.js +1 -1
  5. package/dist/constants/error-messages.js.map +1 -1
  6. package/dist/controllers/agent-registry.controller.d.ts +8 -0
  7. package/dist/controllers/agent-registry.controller.d.ts.map +1 -1
  8. package/dist/controllers/agent-registry.controller.js +14 -0
  9. package/dist/controllers/agent-registry.controller.js.map +1 -1
  10. package/dist/controllers/agent-session.controller.d.ts +8 -1
  11. package/dist/controllers/agent-session.controller.d.ts.map +1 -1
  12. package/dist/controllers/agent-session.controller.js +66 -2
  13. package/dist/controllers/agent-session.controller.js.map +1 -1
  14. package/dist/controllers/test-data.controller.d.ts +12 -0
  15. package/dist/controllers/test-data.controller.d.ts.map +1 -0
  16. package/dist/controllers/test-data.controller.js +66 -0
  17. package/dist/controllers/test-data.controller.js.map +1 -0
  18. package/dist/controllers/test-data.controller.spec.d.ts +2 -0
  19. package/dist/controllers/test-data.controller.spec.d.ts.map +1 -0
  20. package/dist/controllers/test-data.controller.spec.js +78 -0
  21. package/dist/controllers/test-data.controller.spec.js.map +1 -0
  22. package/dist/dtos/create-agent-job.dto.d.ts +1 -0
  23. package/dist/dtos/create-agent-job.dto.d.ts.map +1 -1
  24. package/dist/dtos/create-agent-job.dto.js +8 -1
  25. package/dist/dtos/create-agent-job.dto.js.map +1 -1
  26. package/dist/dtos/create-agent-process.dto.d.ts +5 -0
  27. package/dist/dtos/create-agent-process.dto.d.ts.map +1 -1
  28. package/dist/dtos/create-agent-process.dto.js +37 -1
  29. package/dist/dtos/create-agent-process.dto.js.map +1 -1
  30. package/dist/dtos/create-agent-registry.dto.d.ts +5 -0
  31. package/dist/dtos/create-agent-registry.dto.d.ts.map +1 -1
  32. package/dist/dtos/create-agent-registry.dto.js +39 -1
  33. package/dist/dtos/create-agent-registry.dto.js.map +1 -1
  34. package/dist/dtos/create-agent-session.dto.js +1 -1
  35. package/dist/dtos/create-agent-session.dto.js.map +1 -1
  36. package/dist/dtos/test-run-request.dto.d.ts +1 -0
  37. package/dist/dtos/test-run-request.dto.d.ts.map +1 -1
  38. package/dist/dtos/test-run-request.dto.js +7 -1
  39. package/dist/dtos/test-run-request.dto.js.map +1 -1
  40. package/dist/dtos/update-agent-deployment.dto.d.ts +8 -0
  41. package/dist/dtos/update-agent-deployment.dto.d.ts.map +1 -0
  42. package/dist/dtos/update-agent-deployment.dto.js +60 -0
  43. package/dist/dtos/update-agent-deployment.dto.js.map +1 -0
  44. package/dist/dtos/update-agent-job.dto.d.ts +1 -0
  45. package/dist/dtos/update-agent-job.dto.d.ts.map +1 -1
  46. package/dist/dtos/update-agent-job.dto.js +8 -1
  47. package/dist/dtos/update-agent-job.dto.js.map +1 -1
  48. package/dist/dtos/update-agent-process.dto.d.ts +5 -0
  49. package/dist/dtos/update-agent-process.dto.d.ts.map +1 -1
  50. package/dist/dtos/update-agent-process.dto.js +37 -1
  51. package/dist/dtos/update-agent-process.dto.js.map +1 -1
  52. package/dist/dtos/update-agent-registry.dto.d.ts +5 -0
  53. package/dist/dtos/update-agent-registry.dto.d.ts.map +1 -1
  54. package/dist/dtos/update-agent-registry.dto.js +39 -1
  55. package/dist/dtos/update-agent-registry.dto.js.map +1 -1
  56. package/dist/dtos/update-agent-session.dto.js +1 -1
  57. package/dist/dtos/update-agent-session.dto.js.map +1 -1
  58. package/dist/entities/agent-job.entity.d.ts +1 -0
  59. package/dist/entities/agent-job.entity.d.ts.map +1 -1
  60. package/dist/entities/agent-job.entity.js +7 -2
  61. package/dist/entities/agent-job.entity.js.map +1 -1
  62. package/dist/entities/agent-process.entity.d.ts +8 -0
  63. package/dist/entities/agent-process.entity.d.ts.map +1 -1
  64. package/dist/entities/agent-process.entity.js +38 -1
  65. package/dist/entities/agent-process.entity.js.map +1 -1
  66. package/dist/entities/agent-registry.entity.d.ts +5 -0
  67. package/dist/entities/agent-registry.entity.d.ts.map +1 -1
  68. package/dist/entities/agent-registry.entity.js +22 -1
  69. package/dist/entities/agent-registry.entity.js.map +1 -1
  70. package/dist/entities/agent-session.entity.d.ts.map +1 -1
  71. package/dist/entities/agent-session.entity.js +3 -1
  72. package/dist/entities/agent-session.entity.js.map +1 -1
  73. package/dist/helpers/agent-config-version-name.d.ts +2 -0
  74. package/dist/helpers/agent-config-version-name.d.ts.map +1 -0
  75. package/dist/helpers/agent-config-version-name.js +17 -0
  76. package/dist/helpers/agent-config-version-name.js.map +1 -0
  77. package/dist/helpers/agent-config-version-name.spec.d.ts +2 -0
  78. package/dist/helpers/agent-config-version-name.spec.d.ts.map +1 -0
  79. package/dist/helpers/agent-config-version-name.spec.js +31 -0
  80. package/dist/helpers/agent-config-version-name.spec.js.map +1 -0
  81. package/dist/index.d.ts +3 -0
  82. package/dist/index.d.ts.map +1 -1
  83. package/dist/index.js +2 -0
  84. package/dist/index.js.map +1 -1
  85. package/dist/jobs/database/test-run-queue-subscriber-database.service.d.ts.map +1 -1
  86. package/dist/jobs/database/test-run-queue-subscriber-database.service.js +8 -4
  87. package/dist/jobs/database/test-run-queue-subscriber-database.service.js.map +1 -1
  88. package/dist/resources/agent-embed/solid-agent-embed.js +243 -4
  89. package/dist/seeders/module-test-data.service.d.ts +19 -0
  90. package/dist/seeders/module-test-data.service.d.ts.map +1 -1
  91. package/dist/seeders/module-test-data.service.js +95 -15
  92. package/dist/seeders/module-test-data.service.js.map +1 -1
  93. package/dist/seeders/module-test-data.service.spec.d.ts +2 -0
  94. package/dist/seeders/module-test-data.service.spec.d.ts.map +1 -0
  95. package/dist/seeders/module-test-data.service.spec.js +158 -0
  96. package/dist/seeders/module-test-data.service.spec.js.map +1 -0
  97. package/dist/seeders/seed-data/solid-core-metadata.json +278 -11
  98. package/dist/services/agent-hub-process-manager.service.d.ts +4 -0
  99. package/dist/services/agent-hub-process-manager.service.d.ts.map +1 -1
  100. package/dist/services/agent-hub-process-manager.service.js +19 -3
  101. package/dist/services/agent-hub-process-manager.service.js.map +1 -1
  102. package/dist/services/agent-registry.service.d.ts +8 -0
  103. package/dist/services/agent-registry.service.d.ts.map +1 -1
  104. package/dist/services/agent-registry.service.js +32 -1
  105. package/dist/services/agent-registry.service.js.map +1 -1
  106. package/dist/services/crud.service.d.ts +1 -0
  107. package/dist/services/crud.service.d.ts.map +1 -1
  108. package/dist/services/crud.service.js +26 -2
  109. package/dist/services/crud.service.js.map +1 -1
  110. package/dist/services/settings/default-settings-provider.service.d.ts +12 -2
  111. package/dist/services/settings/default-settings-provider.service.d.ts.map +1 -1
  112. package/dist/services/settings/default-settings-provider.service.js +7 -1
  113. package/dist/services/settings/default-settings-provider.service.js.map +1 -1
  114. package/dist/solid-core.module.d.ts.map +1 -1
  115. package/dist/solid-core.module.js +3 -0
  116. package/dist/solid-core.module.js.map +1 -1
  117. package/dist/testing/adapters/ui/browser-provisioner.d.ts +11 -0
  118. package/dist/testing/adapters/ui/browser-provisioner.d.ts.map +1 -1
  119. package/dist/testing/adapters/ui/browser-provisioner.js +51 -1
  120. package/dist/testing/adapters/ui/browser-provisioner.js.map +1 -1
  121. package/dist/testing/adapters/ui/browser-provisioner.spec.d.ts +2 -0
  122. package/dist/testing/adapters/ui/browser-provisioner.spec.d.ts.map +1 -0
  123. package/dist/testing/adapters/ui/browser-provisioner.spec.js +137 -0
  124. package/dist/testing/adapters/ui/browser-provisioner.spec.js.map +1 -0
  125. package/dist/testing/adapters/ui/playwright-adapter.d.ts +7 -0
  126. package/dist/testing/adapters/ui/playwright-adapter.d.ts.map +1 -1
  127. package/dist/testing/adapters/ui/playwright-adapter.js +37 -8
  128. package/dist/testing/adapters/ui/playwright-adapter.js.map +1 -1
  129. package/dist/testing/adapters/ui/run-video.d.ts +40 -0
  130. package/dist/testing/adapters/ui/run-video.d.ts.map +1 -0
  131. package/dist/testing/adapters/ui/run-video.js +113 -0
  132. package/dist/testing/adapters/ui/run-video.js.map +1 -0
  133. package/dist/testing/adapters/ui/run-video.spec.d.ts +2 -0
  134. package/dist/testing/adapters/ui/run-video.spec.d.ts.map +1 -0
  135. package/dist/testing/adapters/ui/run-video.spec.js +62 -0
  136. package/dist/testing/adapters/ui/run-video.spec.js.map +1 -0
  137. package/dist/testing/contracts/testing-metadata.types.d.ts +1 -0
  138. package/dist/testing/contracts/testing-metadata.types.d.ts.map +1 -1
  139. package/dist/testing/contracts/testing-metadata.types.js.map +1 -1
  140. package/dist/testing/core/testing-engine.d.ts +1 -1
  141. package/dist/testing/core/testing-engine.d.ts.map +1 -1
  142. package/dist/testing/core/testing-engine.js +22 -4
  143. package/dist/testing/core/testing-engine.js.map +1 -1
  144. package/dist/testing/reporter/lifecycle-events.types.d.ts +1 -1
  145. package/dist/testing/reporter/lifecycle-events.types.d.ts.map +1 -1
  146. package/dist/testing/reporter/lifecycle-events.types.js.map +1 -1
  147. package/dist/testing/reporter/lifecycle-webhook-reporter.d.ts.map +1 -1
  148. package/dist/testing/reporter/lifecycle-webhook-reporter.js +2 -0
  149. package/dist/testing/reporter/lifecycle-webhook-reporter.js.map +1 -1
  150. package/dist/testing/runner/read-scenarios-file.d.ts +1 -0
  151. package/dist/testing/runner/read-scenarios-file.d.ts.map +1 -1
  152. package/dist/testing/runner/read-scenarios-file.js +20 -0
  153. package/dist/testing/runner/read-scenarios-file.js.map +1 -1
  154. package/dist/testing/runner/run-from-metadata.d.ts.map +1 -1
  155. package/dist/testing/runner/run-from-metadata.js +9 -1
  156. package/dist/testing/runner/run-from-metadata.js.map +1 -1
  157. package/dist/testing/runner/run-from-metadata.spec.js +12 -1
  158. package/dist/testing/runner/run-from-metadata.spec.js.map +1 -1
  159. package/package.json +1 -1
  160. package/resources/agent-embed/solid-agent-embed.js +243 -4
  161. package/src/constants/error-messages.ts +2 -1
  162. package/src/controllers/agent-registry.controller.ts +8 -1
  163. package/src/controllers/agent-session.controller.ts +37 -2
  164. package/src/controllers/test-data.controller.spec.ts +94 -0
  165. package/src/controllers/test-data.controller.ts +58 -0
  166. package/src/dtos/create-agent-job.dto.ts +6 -0
  167. package/src/dtos/create-agent-process.dto.ts +32 -1
  168. package/src/dtos/create-agent-registry.dto.ts +34 -1
  169. package/src/dtos/create-agent-session.dto.ts +1 -1
  170. package/src/dtos/test-run-request.dto.ts +6 -0
  171. package/src/dtos/update-agent-deployment.dto.ts +37 -0
  172. package/src/dtos/update-agent-job.dto.ts +6 -0
  173. package/src/dtos/update-agent-process.dto.ts +32 -1
  174. package/src/dtos/update-agent-registry.dto.ts +34 -1
  175. package/src/dtos/update-agent-session.dto.ts +1 -1
  176. package/src/entities/agent-job.entity.ts +5 -1
  177. package/src/entities/agent-process.entity.ts +28 -0
  178. package/src/entities/agent-registry.entity.ts +15 -0
  179. package/src/entities/agent-session.entity.ts +3 -0
  180. package/src/helpers/agent-config-version-name.spec.ts +35 -0
  181. package/src/helpers/agent-config-version-name.ts +16 -0
  182. package/src/index.ts +5 -0
  183. package/src/jobs/database/test-run-queue-subscriber-database.service.ts +10 -6
  184. package/src/seeders/module-test-data.service.spec.ts +184 -0
  185. package/src/seeders/module-test-data.service.ts +136 -20
  186. package/src/seeders/seed-data/solid-core-metadata.json +278 -11
  187. package/src/services/agent-hub-process-manager.service.ts +25 -4
  188. package/src/services/agent-registry.service.ts +35 -2
  189. package/src/services/crud.service.ts +30 -2
  190. package/src/services/settings/default-settings-provider.service.ts +11 -1
  191. package/src/solid-core.module.ts +3 -0
  192. package/src/testing/adapters/ui/browser-provisioner.spec.ts +131 -0
  193. package/src/testing/adapters/ui/browser-provisioner.ts +85 -2
  194. package/src/testing/adapters/ui/playwright-adapter.ts +48 -10
  195. package/src/testing/adapters/ui/run-video.spec.ts +72 -0
  196. package/src/testing/adapters/ui/run-video.ts +122 -0
  197. package/src/testing/contracts/testing-metadata.types.ts +5 -0
  198. package/src/testing/core/testing-engine.ts +28 -5
  199. package/src/testing/reporter/lifecycle-events.types.ts +2 -1
  200. package/src/testing/reporter/lifecycle-webhook-reporter.ts +1 -0
  201. package/src/testing/runner/read-scenarios-file.ts +24 -0
  202. package/src/testing/runner/run-from-metadata.spec.ts +15 -1
  203. package/src/testing/runner/run-from-metadata.ts +13 -5
@@ -1 +1 @@
1
- {"version":3,"file":"test-run-queue-subscriber-database.service.js","sourceRoot":"","sources":["../../../src/jobs/database/test-run-queue-subscriber-database.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,yCAA4C;AAG5C,wGAAmE;AACnE,0EAAqE;AACrE,sFAAgF;AAEhF,mGAAqF;AACrF,kEAA4D;AAC5D,2EAAmF;AACnF,8EAAyE;AACzE,4EAAwG;AACxG,kFAA6E;AAC7E,kGAG2D;AAC3D,kGAA4F;AAC5F,uFAAwF;AACxF,mFAA0G;AAE1G,kEAA8D;AAavD,IAAM,8BAA8B,sCAApC,MAAM,8BAA+B,SAAQ,gDAAqC;IAGrF,YACa,gBAAkC,EAClC,qBAA4C,EAC5C,MAAqB,EACb,WAAwB,EACnB,WAA0C,EAC7B,WAAiD,EACnE,aAA4B;QAE7C,KAAK,CAAC,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,CAAC,CAAC;QAR9C,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,WAAM,GAAN,MAAM,CAAe;QACb,gBAAW,GAAX,WAAW,CAAa;QACF,gBAAW,GAAX,WAAW,CAAc;QACZ,gBAAW,GAAX,WAAW,CAAqB;QACnE,kBAAa,GAAb,aAAa,CAAe;QAThC,kBAAa,GAAG,IAAI,eAAM,CAAC,gCAA8B,CAAC,IAAI,CAAC,CAAC;IAYjF,CAAC;IAED,OAAO;QACH,OAAO;YACH,GAAG,yCAAkB;SACxB,CAAA;IACL,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAAwC;QACpD,MAAM,CAAC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a,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,KAAK,6BAA6B,aAAa,EAAE,CAAC,CAAC;QAC7F,CAAC;gBAAS,CAAC;YACP,IAAI,SAAS;gBAAE,IAAA,yCAAsB,EAAC,SAAS,CAAC,CAAC;YACjD,MAAM,QAAQ,CAAC,YAAY,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;QACzD,CAAC;QAED,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC;IACxC,CAAC;CACJ,CAAA;AAvGY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,mBAAU,GAAE;IASJ,WAAA,IAAA,eAAM,EAAC,qCAAY,CAAC,CAAA;IACpB,WAAA,IAAA,eAAM,EAAC,gDAAyB,CAAC,CAAA;qCALP,qCAAgB;QACX,gDAAqB;QACpC,8BAAa;QACA,mBAAW,kBAGT,8BAAa;GAVxC,8BAA8B,CAuG1C","sourcesContent":["import { Inject, Injectable, Logger } from '@nestjs/common';\nimport { HttpService } from '@nestjs/axios';\n\nimport { QueueMessage } from 'src/interfaces/mq';\nimport testRunQueueConfig from './test-run-queue-options-database';\nimport { MqMessageService } from '../../services/mq-message.service';\nimport { MqMessageQueueService } from '../../services/mq-message-queue.service';\nimport { QueuesModuleOptions } from \"../../interfaces\";\nimport { DatabaseSubscriber } from 'src/services/queues/database-subscriber.service';\nimport { PollerService } from 'src/services/poller.service';\nimport { toMobileAdapterOptions } from '../../testing/adapters/mobile/run-options';\nimport { runFromMetadata } from '../../testing/runner/run-from-metadata';\nimport { registerRunCancellation, releaseRunCancellation } from '../../testing/runner/run-cancellation';\nimport { readScenariosFile } from '../../testing/runner/read-scenarios-file';\nimport {\n LifecycleWebhookReporter,\n WebhookPostFn,\n} from '../../testing/reporter/lifecycle-webhook-reporter';\nimport { FileServiceArtifactSink } from '../../testing/reporter/file-service-artifact-sink';\nimport { FILE_SERVICE, IFileService } from '../../services/file/file-service.interface';\nimport { FILE_STORAGE_PATH_BUILDER, IStoragePathBuilder } from '../../services/file/storage-path-builder';\nimport { TestRunJobPayload } from '../../dtos/test-run-request.dto';\nimport { SecretService } from '../../services/secret.service';\n\n/**\n * Executes a queued test run on the worker tier (QUEUES_SERVICE_ROLE=subscriber).\n * Resolves scenarios from `scenariosPath` (read from disk here, at execution time —\n * the worker shares the filesystem with the caller) or from inline `scenarios`, then\n * runs them via {@link runFromMetadata} with a {@link LifecycleWebhookReporter} that\n * streams run.start → scenario.* → run.end to the caller's webhookUrl. A failing TEST\n * is NOT a failing JOB: failures (including an unreadable scenario file) are reported\n * over the webhook (run.end ok:false) and the job still completes, so the queue does\n * not retry a deterministically-failing test run.\n */\n@Injectable()\nexport class TestRunQueueSubscriberDatabase extends DatabaseSubscriber<TestRunJobPayload> {\n private readonly testRunLogger = new Logger(TestRunQueueSubscriberDatabase.name);\n\n constructor(\n readonly mqMessageService: MqMessageService,\n readonly mqMessageQueueService: MqMessageQueueService,\n readonly poller: PollerService,\n private readonly httpService: HttpService,\n @Inject(FILE_SERVICE) private readonly fileService: IFileService,\n @Inject(FILE_STORAGE_PATH_BUILDER) private readonly pathBuilder: IStoragePathBuilder,\n private readonly secretService: SecretService,\n ) {\n super(mqMessageService, mqMessageQueueService, poller);\n }\n\n options(): QueuesModuleOptions {\n return {\n ...testRunQueueConfig\n }\n }\n\n async subscribe(message: QueueMessage<TestRunJobPayload>) {\n const p = message.payload;\n this.testRunLogger.debug(`Starting test run ${p.runId} (externalRunId=${p.externalRunId})`);\n\n const post: WebhookPostFn = async (url, body, opts) => {\n const res = await this.httpService.axiosRef.post(url, body, {\n headers: { 'Content-Type': 'application/json', ...(opts.headers ?? {}) },\n timeout: opts.timeoutMs ?? 10_000,\n validateStatus: () => true,\n });\n return { ok: res.status >= 200 && res.status < 300, status: res.status };\n };\n\n // Persist binary artifacts (screenshots, whole-run video) to shared storage via the\n // core FILE_SERVICE (disk by default, S3 when DEFAULT_FILE_SERVICE=s3) instead of\n // shipping them inline / storing blobs in the DB. They go where SolidX keeps its media\n // (the path builder resolves the configured media folder or bucket), not into the working directory.\n const artifactSink = new FileServiceArtifactSink(this.fileService, { prefix: 'testing-hub', pathBuilder: this.pathBuilder });\n\n const reporter = new LifecycleWebhookReporter({\n webhookUrl: p.webhookUrl,\n runName: p.externalRunId ?? p.runId,\n externalRunId: p.externalRunId,\n runId: p.runId,\n post,\n artifactSink,\n });\n\n let scenarios = p.scenarios;\n let data = p.data;\n if (p.scenariosPath) {\n const read = readScenariosFile(p.scenariosPath);\n if (!read.ok) {\n const reason = `Scenario file unreadable: ${p.scenariosPath} (${read.error})`;\n this.testRunLogger.warn(`Test run ${p.runId} — ${reason}`);\n reporter.onRunStart({ total: 0, startedAt: new Date().toISOString(), scenarioIds: [] });\n await reporter.flushPending(1, reason);\n return { runId: p.runId, exitCode: 1 };\n }\n scenarios = read.scenarios;\n data = read.data ?? data;\n this.testRunLogger.debug(`Test run ${p.runId} loaded ${scenarios.length} scenario(s) from ${p.scenariosPath}`);\n }\n\n let exitCode = 0;\n // Why the run ended early, when it did. A failed scenario is reported by its own events, but a refusal before any\n // scenario starts (a device that is not ready, a scenario that cannot run on it) has no scenario to carry the\n // reason, so it goes out on run.end.\n let failureReason: string | undefined;\n // A caller that knows this run by its externalRunId can cancel it (POST /test-runs/cancel).\n const cancelKey = p.externalRunId ? String(p.externalRunId) : undefined;\n const signal = cancelKey ? registerRunCancellation(cancelKey) : undefined;\n try {\n await runFromMetadata({\n signal,\n scenarios,\n data,\n includeTags: p.includeTags,\n scenarioIds: p.scenarioIds,\n skipScenarioIds: p.skipScenarioIds,\n reporter,\n env: p.variables,\n api: { baseUrl: p.baseUrl },\n ui: { baseUrl: p.uiBaseUrl, headless: p.headless ?? true, capture: p.capture, recordVideo: p.recordVideo ?? true, healing: p.healing, viewport: p.viewport },\n mobile: p.mobile ? toMobileAdapterOptions(p.mobile, { recordVideo: p.recordVideo, capture: p.capture, healing: p.healing }) : undefined,\n options: { printApiLogs: p.printApiLogs ?? true },\n failFast: p.failFast,\n externalRunId: p.externalRunId,\n resolveSecrets: (keys) => this.secretService.resolveAvailable(keys),\n });\n } catch (err: any) {\n // A failed scenario is surfaced via the run.end webhook, not as a job failure.\n exitCode = 1;\n failureReason = String(err?.message ?? err);\n this.testRunLogger.warn(`Test run ${p.runId} completed with failures: ${failureReason}`);\n } finally {\n if (cancelKey) releaseRunCancellation(cancelKey);\n await reporter.flushPending(exitCode, failureReason);\n }\n\n return { runId: p.runId, exitCode };\n }\n}\n"]}
1
+ {"version":3,"file":"test-run-queue-subscriber-database.service.js","sourceRoot":"","sources":["../../../src/jobs/database/test-run-queue-subscriber-database.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,yCAA4C;AAG5C,wGAAmE;AACnE,0EAAqE;AACrE,sFAAgF;AAEhF,mGAAqF;AACrF,kEAA4D;AAC5D,2EAAmF;AACnF,8EAAyE;AACzE,4EAAwG;AACxG,kFAAgG;AAChG,kGAG2D;AAC3D,kGAA4F;AAC5F,uFAAwF;AACxF,mFAA0G;AAE1G,kEAA8D;AAavD,IAAM,8BAA8B,sCAApC,MAAM,8BAA+B,SAAQ,gDAAqC;IAGrF,YACa,gBAAkC,EAClC,qBAA4C,EAC5C,MAAqB,EACb,WAAwB,EACnB,WAA0C,EAC7B,WAAiD,EACnE,aAA4B;QAE7C,KAAK,CAAC,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,CAAC,CAAC;QAR9C,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,WAAM,GAAN,MAAM,CAAe;QACb,gBAAW,GAAX,WAAW,CAAa;QACF,gBAAW,GAAX,WAAW,CAAc;QACZ,gBAAW,GAAX,WAAW,CAAqB;QACnE,kBAAa,GAAb,aAAa,CAAe;QAThC,kBAAa,GAAG,IAAI,eAAM,CAAC,gCAA8B,CAAC,IAAI,CAAC,CAAC;IAYjF,CAAC;IAED,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ueMessage } from 'src/interfaces/mq';\nimport testRunQueueConfig from './test-run-queue-options-database';\nimport { MqMessageService } from '../../services/mq-message.service';\nimport { MqMessageQueueService } from '../../services/mq-message-queue.service';\nimport { QueuesModuleOptions } from \"../../interfaces\";\nimport { DatabaseSubscriber } from 'src/services/queues/database-subscriber.service';\nimport { PollerService } from 'src/services/poller.service';\nimport { toMobileAdapterOptions } from '../../testing/adapters/mobile/run-options';\nimport { runFromMetadata } from '../../testing/runner/run-from-metadata';\nimport { registerRunCancellation, releaseRunCancellation } from '../../testing/runner/run-cancellation';\nimport { readScenarioFiles, readScenariosFile } from '../../testing/runner/read-scenarios-file';\nimport {\n LifecycleWebhookReporter,\n WebhookPostFn,\n} from '../../testing/reporter/lifecycle-webhook-reporter';\nimport { FileServiceArtifactSink } from '../../testing/reporter/file-service-artifact-sink';\nimport { FILE_SERVICE, IFileService } from '../../services/file/file-service.interface';\nimport { FILE_STORAGE_PATH_BUILDER, IStoragePathBuilder } from '../../services/file/storage-path-builder';\nimport { TestRunJobPayload } from '../../dtos/test-run-request.dto';\nimport { SecretService } from '../../services/secret.service';\n\n/**\n * Executes a queued test run on the worker tier (QUEUES_SERVICE_ROLE=subscriber).\n * Resolves scenarios from `scenarioPaths` (one file per scenario) or `scenariosPath` (read from disk here, at execution time —\n * the worker shares the filesystem with the caller) or from inline `scenarios`, then\n * runs them via {@link runFromMetadata} with a {@link LifecycleWebhookReporter} that\n * streams run.start → scenario.* → run.end to the caller's webhookUrl. A failing TEST\n * is NOT a failing JOB: failures (including an unreadable scenario file) are reported\n * over the webhook (run.end ok:false) and the job still completes, so the queue does\n * not retry a deterministically-failing test run.\n */\n@Injectable()\nexport class TestRunQueueSubscriberDatabase extends DatabaseSubscriber<TestRunJobPayload> {\n private readonly testRunLogger = new Logger(TestRunQueueSubscriberDatabase.name);\n\n constructor(\n readonly mqMessageService: MqMessageService,\n readonly mqMessageQueueService: MqMessageQueueService,\n readonly poller: PollerService,\n private readonly httpService: HttpService,\n @Inject(FILE_SERVICE) private readonly fileService: IFileService,\n @Inject(FILE_STORAGE_PATH_BUILDER) private readonly pathBuilder: IStoragePathBuilder,\n private readonly secretService: SecretService,\n ) {\n super(mqMessageService, mqMessageQueueService, poller);\n }\n\n options(): QueuesModuleOptions {\n return {\n ...testRunQueueConfig\n }\n }\n\n async subscribe(message: QueueMessage<TestRunJobPayload>) {\n const p = message.payload;\n this.testRunLogger.debug(`Starting test run ${p.runId} (externalRunId=${p.externalRunId})`);\n\n const post: WebhookPostFn = async (url, body, opts) => {\n const res = await this.httpService.axiosRef.post(url, body, {\n headers: { 'Content-Type': 'application/json', ...(opts.headers ?? {}) },\n timeout: opts.timeoutMs ?? 10_000,\n validateStatus: () => true,\n });\n return { ok: res.status >= 200 && res.status < 300, status: res.status };\n };\n\n // Persist binary artifacts (screenshots, whole-run video) to shared storage via the\n // core FILE_SERVICE (disk by default, S3 when DEFAULT_FILE_SERVICE=s3) instead of\n // shipping them inline / storing blobs in the DB. They go where SolidX keeps its media\n // (the path builder resolves the configured media folder or bucket), not into the working directory.\n const artifactSink = new FileServiceArtifactSink(this.fileService, { prefix: 'testing-hub', pathBuilder: this.pathBuilder });\n\n const reporter = new LifecycleWebhookReporter({\n webhookUrl: p.webhookUrl,\n runName: p.externalRunId ?? p.runId,\n externalRunId: p.externalRunId,\n runId: p.runId,\n post,\n artifactSink,\n });\n\n let scenarios = p.scenarios;\n let data = p.data;\n const scenarioPaths = Array.isArray(p.scenarioPaths) && p.scenarioPaths.length ? p.scenarioPaths : null;\n if (scenarioPaths || p.scenariosPath) {\n const source = scenarioPaths ? `${scenarioPaths.length} scenario file(s)` : p.scenariosPath;\n const read = scenarioPaths ? readScenarioFiles(scenarioPaths) : readScenariosFile(p.scenariosPath);\n if (!read.ok) {\n const reason = scenarioPaths\n ? `Scenario file unreadable (${read.error})`\n : `Scenario file unreadable: ${p.scenariosPath} (${read.error})`;\n this.testRunLogger.warn(`Test run ${p.runId} — ${reason}`);\n reporter.onRunStart({ total: 0, startedAt: new Date().toISOString(), scenarioIds: [] });\n await reporter.flushPending(1, reason);\n return { runId: p.runId, exitCode: 1 };\n }\n scenarios = read.scenarios;\n data = read.data ?? data;\n this.testRunLogger.debug(`Test run ${p.runId} loaded ${scenarios.length} scenario(s) from ${source}`);\n }\n\n let exitCode = 0;\n // Why the run ended early, when it did. A failed scenario is reported by its own events, but a refusal before any\n // scenario starts (a device that is not ready, a scenario that cannot run on it) has no scenario to carry the\n // reason, so it goes out on run.end.\n let failureReason: string | undefined;\n // A caller that knows this run by its externalRunId can cancel it (POST /test-runs/cancel).\n const cancelKey = p.externalRunId ? String(p.externalRunId) : undefined;\n const signal = cancelKey ? registerRunCancellation(cancelKey) : undefined;\n try {\n await runFromMetadata({\n signal,\n scenarios,\n data,\n includeTags: p.includeTags,\n scenarioIds: p.scenarioIds,\n skipScenarioIds: p.skipScenarioIds,\n reporter,\n env: p.variables,\n api: { baseUrl: p.baseUrl },\n ui: { baseUrl: p.uiBaseUrl, headless: p.headless ?? true, capture: p.capture, recordVideo: p.recordVideo ?? true, healing: p.healing, viewport: p.viewport },\n mobile: p.mobile ? toMobileAdapterOptions(p.mobile, { recordVideo: p.recordVideo, capture: p.capture, healing: p.healing }) : undefined,\n options: { printApiLogs: p.printApiLogs ?? true },\n failFast: p.failFast,\n externalRunId: p.externalRunId,\n resolveSecrets: (keys) => this.secretService.resolveAvailable(keys),\n });\n } catch (err: any) {\n // A failed scenario is surfaced via the run.end webhook, not as a job failure.\n exitCode = 1;\n failureReason = String(err?.message ?? err);\n this.testRunLogger.warn(`Test run ${p.runId} completed with failures: ${failureReason}`);\n } finally {\n if (cancelKey) releaseRunCancellation(cancelKey);\n await reporter.flushPending(exitCode, failureReason);\n }\n\n return { runId: p.runId, exitCode };\n }\n}\n"]}
@@ -1,10 +1,11 @@
1
- /* SolidX AgentHub Embed SDK v5. No dependencies; credentials stay in memory.
1
+ /* SolidX AgentHub Embed SDK v7. No dependencies; credentials stay in memory.
2
2
  * mode: "popup" (default) owns its launcher and floating window.
3
3
  * mode: "inline" fills the supplied container; the host owns its layout.
4
+ * mountWorkspace owns the host layout around an inline chat.
4
5
  */
5
6
  (function (global) {
6
7
  "use strict";
7
- if (global.SolidAgentEmbed && global.SolidAgentEmbed.version >= 5) return;
8
+ if (global.SolidAgentEmbed && global.SolidAgentEmbed.version >= 7) return;
8
9
  var channel = "solidx-agent-embed";
9
10
  var publicProtocolVersion = 2;
10
11
  var maxContextBytes = 32 * 1024;
@@ -35,6 +36,7 @@
35
36
  embedUrl.searchParams.set("parentOrigin", location.origin);
36
37
  embedUrl.searchParams.set("instanceId", id);
37
38
  var inputs = JSON.parse(JSON.stringify(options.inputs || {}));
39
+ var workspaceState = options.workspace || null;
38
40
  var destroyed = false, initialized = false, locked = false, open = false, windowMode = "popup", ready = false, tokenFlight = null;
39
41
  var pending = new Map();
40
42
  var listeners = new Map(), beforeSendListeners = [], contextSnapshots = new Map(), listenerOrder = 0, eventSequence = 0;
@@ -292,11 +294,15 @@
292
294
  var missing = (options.requiredCapabilities || []).filter(function (name) { return !frameCapabilities.includes(name); });
293
295
  if (missing.length) { emitError(new Error("This hosted chat needs an upgrade. Missing capabilities: " + missing.join(", "))); return; }
294
296
  ready = true;
297
+ if (workspaceState) post("workspace_state", { workspace: workspaceState });
295
298
  clearTimeout(loadTimer);
296
299
  emit("onReady", { protocolVersion: publicProtocolVersion, instanceId: id, agentId: resolvedAgentId, capabilities: frameCapabilities });
297
300
  debug(id, "iframe ready", { protocolVersion: publicProtocolVersion, capabilities: frameCapabilities });
298
301
  }
299
302
  else if (data.type === "close") hide();
303
+ else if (data.type === "workspace_request" && inline && typeof data.action === "string") {
304
+ emit("onWorkspaceActionRequested", { action: data.action, agentName: data.agentName });
305
+ }
300
306
  else if (data.type === "before_send_request") runBeforeSend(data);
301
307
  else if (data.type === "public_event" && data.protocolVersion === publicProtocolVersion
302
308
  && typeof data.event === "string" && isPlainObject(data.payload) && payloadSize(data.payload) <= 64 * 1024) {
@@ -312,7 +318,7 @@
312
318
  bootstrapAuth = null;
313
319
  debug(id, "sending token bootstrap to iframe", { requestId: data.requestId, inputsCount: Object.keys(inputs).length });
314
320
  var agentName = hasAgentName ? options.agentName.trim() : (typeof auth.agentName === "string" ? auth.agentName.trim() : undefined);
315
- post("token", { requestId: data.requestId, auth: auth, inputs: inputs, agentName: agentName });
321
+ post("token", { requestId: data.requestId, auth: auth, inputs: inputs, agentName: agentName, workspace: workspaceState });
316
322
  })
317
323
  .catch(function (error) { post("token_error", { requestId: data.requestId, error: error.message }); emitError(error); });
318
324
  } else if (data.type === "authenticated") { emitRecovered(); emit("onAuthenticationStateChanged", { state: "authenticated" }); }
@@ -431,6 +437,10 @@
431
437
  emit("onContextChanged", { protocolVersion: publicProtocolVersion, instanceId: id, agentId: resolvedAgentId, namespace: namespace, revision: revision, displaySummary: displaySummary });
432
438
  return sendCommand("setContext", { namespace: namespace, contribution: contribution });
433
439
  },
440
+ setWorkspaceState: function (next) {
441
+ workspaceState = next;
442
+ if (ready) post("workspace_state", { workspace: next });
443
+ },
434
444
  sendMessage: function (message) {
435
445
  if (!isPlainObject(message) || typeof message.text !== "string") return Promise.reject(new Error("sendMessage requires text."));
436
446
  return sendCommand("sendMessage", { text: message.text, source: message.source || "sdk" });
@@ -476,5 +486,234 @@
476
486
  }
477
487
  };
478
488
  }
479
- global.SolidAgentEmbed = { version: 5, mount: mount };
489
+ function mountWorkspace(options) {
490
+ var container = typeof options.container === "string" ? document.querySelector(options.container) : options.container;
491
+ var content = typeof options.content === "string" ? document.querySelector(options.content) : options.content;
492
+ if (!container || !content || content.parentElement !== container) throw new Error("Provide a workspace container and its content element.");
493
+ var agents = options.agents;
494
+ if (!Array.isArray(agents) || !agents.length || !agents.every(function (agent) {
495
+ return agent && typeof agent.name === "string" && agent.name.trim() && typeof agent.title === "string";
496
+ })) throw new Error("Provide at least one named agent.");
497
+ if (typeof options.tokenEndpoint !== "string" || !options.tokenEndpoint) throw new Error("Provide a token endpoint.");
498
+ var agentNames = agents.map(function (agent) { return agent.name; });
499
+ if (new Set(agentNames).size !== agentNames.length) throw new Error("Agent names must be unique.");
500
+ var defaultAgent = agentNames.includes(options.defaultAgentName) ? options.defaultAgentName : agents[0].name;
501
+ var key = typeof options.persistenceKey === "string" ? options.persistenceKey : "";
502
+ var state = { version: 1, open: false, mode: "docked", agentName: defaultAgent,
503
+ width: 420, floatingWidth: 440, floatingHeight: 720, x: 24, y: 80 };
504
+ try {
505
+ var stored = key && JSON.parse(localStorage.getItem(key) || "null");
506
+ if (stored && stored.version === 1) {
507
+ state.open = stored.open === true;
508
+ state.mode = ["docked", "floating", "fullscreen"].includes(stored.mode) ? stored.mode : "docked";
509
+ state.agentName = agentNames.includes(stored.agentName) ? stored.agentName : defaultAgent;
510
+ ["width", "floatingWidth", "floatingHeight", "x", "y"].forEach(function (field) {
511
+ if (Number.isFinite(stored[field])) state[field] = stored[field];
512
+ });
513
+ }
514
+ } catch (_) { /* Storage is optional. */ }
515
+
516
+ var previousContainerStyle = container.style.cssText;
517
+ var previousContentStyle = content.style.cssText;
518
+ var previousChatSpace = document.documentElement.style.getPropertyValue("--agent-chat-space");
519
+ var host = document.createElement("div");
520
+ var launcherHost = document.createElement("div");
521
+ container.appendChild(host);
522
+ document.body.appendChild(launcherHost);
523
+ var root = host.attachShadow({ mode: "open" });
524
+ var launcherRoot = launcherHost.attachShadow({ mode: "open" });
525
+ var css = document.createElement("style");
526
+ css.textContent = ":host{font:13px system-ui;color:#1e293b}*{box-sizing:border-box}button{font:inherit;cursor:pointer}button:focus-visible{outline:2px solid #3b82f6;outline-offset:2px}.panel{position:relative;display:flex;flex-direction:column;width:100%;height:100%;overflow:hidden;background:#fff;border-left:1px solid #d8dee8}.floating{border:1px solid #d8dee8;border-radius:12px;box-shadow:0 20px 60px #0004}.chat{flex:1;min-height:0}.drag{display:none;flex:0 0 22px;width:100%;border:0;border-bottom:1px solid #e2e8f0;background:#f8fafc;cursor:grab;touch-action:none}.floating .drag{display:block}.drag:active{cursor:grabbing}.drag:after{display:block;width:36px;height:4px;margin:auto;border-radius:3px;background:#94a3b8;content:''}.dock-resize{position:absolute;z-index:5;top:0;bottom:0;left:0;width:8px;cursor:col-resize;touch-action:none}.float-resize{position:absolute;z-index:5;right:0;bottom:0;width:28px;height:28px;border:0;background:transparent;cursor:nwse-resize;touch-action:none}.float-resize:after{position:absolute;right:6px;bottom:6px;width:10px;height:10px;border-right:2px solid #64748b;border-bottom:2px solid #64748b;content:''}.error{position:absolute;z-index:4;inset:0;overflow:auto;padding:44px 24px 24px;background:#fff}.floating .error{top:22px}.error-inner{max-width:420px;margin:auto}.error-icon{display:grid;width:36px;height:36px;place-items:center;border-radius:11px;background:#fff1ed;color:#c2412f;font-size:21px;font-weight:700}.eyebrow{margin-top:18px;color:#bd4c3d;font-size:11px;font-weight:700;letter-spacing:.06em;text-transform:uppercase}.error h2{margin:5px 0 8px;font-size:18px;line-height:1.3}.error p{margin:0;color:#64748b;overflow-wrap:anywhere}.recovery{margin-top:30px}.recovery-label{margin-bottom:8px;color:#475569;font-weight:700}.switch{display:flex;align-items:center;gap:10px;width:100%;min-height:40px;padding:0 12px;border:1px solid #d7e1ef;border-radius:10px;background:#fff;color:#23324b;text-align:left;font-weight:600}.switch:hover{background:#f4f7fc}.menu{margin-top:6px;padding:6px;border:1px solid #dce4ef;border-radius:12px;background:#fff;box-shadow:0 14px 40px #0f172a24}.menu-title{padding:7px 9px 9px;color:#64748b;font-size:11px;font-weight:700;letter-spacing:.05em;text-transform:uppercase}.option{display:flex;align-items:center;gap:10px;width:100%;min-height:42px;padding:6px 9px;border:0;border-radius:8px;background:transparent;color:#25344d;text-align:left;font-weight:600}.option:hover,.option.selected{background:#eff5ff}.avatar{display:grid;flex:0 0 26px;width:26px;height:26px;place-items:center;border-radius:8px;background:#e8f0ff;color:#2864c6}.option-title{flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.close{margin-top:20px;padding:0;border:0;background:none;color:#5277b1;font-weight:600}.close:hover{text-decoration:underline}";
527
+ var panel = document.createElement("div");
528
+ panel.className = "panel";
529
+ panel.setAttribute("role", "region");
530
+ panel.setAttribute("aria-label", "Agent chat");
531
+ var drag = document.createElement("button");
532
+ drag.type = "button"; drag.className = "drag"; drag.setAttribute("aria-label", "Move agent chat");
533
+ drag.title = "Drag or use arrow keys to move chat";
534
+ var chat = document.createElement("div"); chat.className = "chat";
535
+ var dockResize = document.createElement("div"); dockResize.className = "dock-resize";
536
+ dockResize.setAttribute("role", "separator"); dockResize.setAttribute("aria-label", "Resize agent chat");
537
+ var floatResize = document.createElement("button"); floatResize.type = "button";
538
+ floatResize.className = "float-resize"; floatResize.setAttribute("aria-label", "Resize floating agent chat");
539
+ panel.append(drag, chat, dockResize, floatResize); root.append(css, panel);
540
+ var launcherStyle = document.createElement("style");
541
+ launcherStyle.textContent = "button{position:fixed;z-index:2147483000;right:24px;bottom:72px;display:grid;width:56px;height:56px;place-items:center;border:0;border-radius:50%;background:#2563eb;color:#fff;box-shadow:0 10px 30px #2563eb6b;cursor:pointer;font-size:26px}button:focus-visible{outline:2px solid #2563eb;outline-offset:3px}";
542
+ var launcher = document.createElement("button"); launcher.type = "button";
543
+ launcher.setAttribute("aria-label", "Open agent chat"); launcher.textContent = "✧";
544
+ launcherRoot.append(launcherStyle, launcher);
545
+
546
+ var instance = null, disposed = false, error = "", restoreMode = "docked", context = null;
547
+ function clamp(value, min, max) { return Math.min(Math.max(value, min), Math.max(min, max)); }
548
+ function save() { if (key) try { localStorage.setItem(key, JSON.stringify(state)); } catch (_) { /* Storage is optional. */ } }
549
+ function workspaceState() { return { mode: state.mode, agents: agents, selectedAgentName: state.agentName }; }
550
+ function selectedAgent() { return agents.find(function (agent) { return agent.name === state.agentName; }); }
551
+ function showError(message) { error = message; render(); }
552
+ function clearError() { if (error) { error = ""; render(); } }
553
+ function setContext(namespace, snapshot, revision, displaySummary) {
554
+ context = { namespace: namespace, snapshot: snapshot, revision: revision, displaySummary: displaySummary };
555
+ return instance ? instance.setContext(namespace, snapshot, revision, displaySummary) : Promise.resolve();
556
+ }
557
+ function connect() {
558
+ if (disposed || instance) return;
559
+ var agent = selectedAgent();
560
+ instance = mount({ mode: "inline", container: chat, agentName: agent.name, title: agent.title,
561
+ tokenEndpoint: options.tokenEndpoint, getTokenHeaders: options.getTokenHeaders,
562
+ requiredCapabilities: ["inlinePanel", "asyncBeforeSend", "messageContextV1", "publicCommands", "workspaceControlsV1"],
563
+ requiredNamespaces: options.namespace ? [options.namespace] : undefined,
564
+ beforeSendTimeoutMs: 3000, workspace: workspaceState(),
565
+ onClose: function () { if (state.open) close(); },
566
+ onError: function (failure) { showError(failure.message || String(failure)); },
567
+ onRecovered: clearError });
568
+ if (options.namespace && typeof options.beforeSend === "function") instance.on("onBeforeUserMessageSend", options.beforeSend,
569
+ { namespace: options.namespace, priority: 0, timeoutMs: 3000 });
570
+ instance.on("onAgentNavigationRequested", function (event) { if (typeof options.onNavigationRequested === "function") options.onNavigationRequested(event); });
571
+ instance.on("onWorkspaceActionRequested", function (event) {
572
+ if (event.action === "close") close();
573
+ else if (event.action === "selectAgent") selectAgent(event.agentName);
574
+ else if (["dock", "float", "fullscreen", "restore"].includes(event.action)) changeMode(event.action);
575
+ });
576
+ if (context) instance.setContext(context.namespace, context.snapshot, context.revision, context.displaySummary).catch(function () {});
577
+ if (state.open) instance.open();
578
+ }
579
+ function selectAgent(name) {
580
+ if (!agentNames.includes(name) || name === state.agentName) return;
581
+ if (instance) { instance.destroy(); instance = null; }
582
+ chat.textContent = "";
583
+ state.agentName = name; error = ""; save(); render();
584
+ if (state.open) connect();
585
+ }
586
+ function changeMode(action) {
587
+ if (action === "fullscreen" && state.mode !== "fullscreen") restoreMode = state.mode;
588
+ state.mode = action === "float" ? "floating" : action === "fullscreen" ? "fullscreen"
589
+ : action === "restore" ? restoreMode : "docked";
590
+ save(); render();
591
+ if (instance) instance.setWorkspaceState(workspaceState());
592
+ }
593
+ function open() { state.open = true; save(); render(); connect(); if (instance) instance.open(); }
594
+ function close() { state.open = false; save(); if (instance) instance.close(); render(); }
595
+ function renderError() {
596
+ var previous = panel.querySelector(".error"); if (previous) previous.remove();
597
+ chat.style.visibility = error ? "hidden" : "visible";
598
+ if (!error) return;
599
+ var view = document.createElement("div"); view.className = "error";
600
+ var inner = document.createElement("div"); inner.className = "error-inner";
601
+ var icon = document.createElement("span"); icon.className = "error-icon"; icon.textContent = "!";
602
+ var eyebrow = document.createElement("div"); eyebrow.className = "eyebrow"; eyebrow.textContent = "Agent unavailable";
603
+ var title = document.createElement("h2"); title.textContent = "Couldn’t start " + selectedAgent().title;
604
+ var message = document.createElement("p"); message.setAttribute("role", "alert"); message.textContent = error;
605
+ inner.append(icon, eyebrow, title, message);
606
+ if (agents.length > 1) {
607
+ var recovery = document.createElement("div"); recovery.className = "recovery";
608
+ var label = document.createElement("div"); label.className = "recovery-label"; label.textContent = "Choose another agent";
609
+ var switcher = document.createElement("button"); switcher.type = "button"; switcher.className = "switch";
610
+ switcher.textContent = selectedAgent().title + " ⌄"; switcher.setAttribute("aria-label", "Switch agent");
611
+ switcher.setAttribute("aria-expanded", "false");
612
+ var menu = document.createElement("div"); menu.className = "menu"; menu.style.display = "none";
613
+ menu.setAttribute("role", "menu"); menu.setAttribute("aria-label", "Choose agent");
614
+ var menuTitle = document.createElement("div"); menuTitle.className = "menu-title"; menuTitle.textContent = "Choose an agent";
615
+ menu.appendChild(menuTitle);
616
+ agents.forEach(function (agent) {
617
+ var item = document.createElement("button"); item.type = "button"; item.className = "option";
618
+ if (agent.name === state.agentName) item.classList.add("selected");
619
+ item.setAttribute("role", "menuitemradio"); item.setAttribute("aria-checked", String(agent.name === state.agentName));
620
+ var avatar = document.createElement("span"); avatar.className = "avatar"; avatar.textContent = agent.title.trim().charAt(0).toUpperCase();
621
+ var itemTitle = document.createElement("span"); itemTitle.className = "option-title"; itemTitle.textContent = agent.title;
622
+ item.append(avatar, itemTitle); menu.appendChild(item);
623
+ item.addEventListener("click", function () { selectAgent(agent.name); });
624
+ });
625
+ switcher.addEventListener("click", function () {
626
+ var expanded = menu.style.display === "none";
627
+ menu.style.display = expanded ? "block" : "none"; switcher.setAttribute("aria-expanded", String(expanded));
628
+ });
629
+ recovery.append(label, switcher, menu); inner.appendChild(recovery);
630
+ }
631
+ var closeButton = document.createElement("button"); closeButton.type = "button"; closeButton.className = "close";
632
+ closeButton.textContent = "Close chat"; closeButton.addEventListener("click", close);
633
+ inner.appendChild(closeButton); view.appendChild(inner); panel.appendChild(view);
634
+ }
635
+ function render() {
636
+ if (disposed) return;
637
+ var floating = state.open && state.mode === "floating";
638
+ var fullscreen = state.open && state.mode === "fullscreen";
639
+ var width = clamp(state.width, 280, innerWidth - 320);
640
+ var floatWidth = clamp(state.floatingWidth, 280, innerWidth - 32);
641
+ var floatHeight = clamp(state.floatingHeight, 360, innerHeight - 32);
642
+ var dockWidth = state.open && !floating ? fullscreen ? "100%" : width + "px" : "0px";
643
+ container.style.display = "grid"; container.style.gridTemplateColumns = "minmax(0,1fr) " + dockWidth;
644
+ container.style.width = "100%"; container.style.height = "100dvh"; container.style.overflow = "hidden";
645
+ content.style.minWidth = "0"; content.style.height = "100%"; content.style.overflow = "auto";
646
+ content.style.visibility = fullscreen ? "hidden" : ""; content.style.pointerEvents = fullscreen ? "none" : "";
647
+ document.documentElement.style.setProperty("--agent-chat-space", dockWidth);
648
+ launcher.style.display = state.open ? "none" : "grid";
649
+ host.style.display = state.open ? "block" : "none";
650
+ host.style.width = floating ? floatWidth + "px" : "100%";
651
+ host.style.height = floating ? floatHeight + "px" : "100%";
652
+ host.style.position = floating ? "fixed" : "relative";
653
+ host.style.zIndex = floating ? "2147483000" : "300";
654
+ host.style.left = floating ? clamp(state.x, 0, innerWidth - floatWidth) + "px" : "";
655
+ host.style.top = floating ? clamp(state.y, 0, innerHeight - floatHeight) + "px" : "";
656
+ panel.classList.toggle("floating", floating);
657
+ drag.style.display = floating ? "block" : "none";
658
+ dockResize.style.display = state.open && !floating && !fullscreen ? "block" : "none";
659
+ floatResize.style.display = floating ? "block" : "none";
660
+ renderError();
661
+ }
662
+ function onDrag(event) {
663
+ if (!dragStart) return;
664
+ state.x = clamp(dragStart.x + event.clientX - dragStart.clientX, 0, innerWidth - host.offsetWidth);
665
+ state.y = clamp(dragStart.y + event.clientY - dragStart.clientY, 0, innerHeight - host.offsetHeight);
666
+ render();
667
+ }
668
+ function onResize(event) {
669
+ if (!resizeStart) return;
670
+ if (resizeStart.floating) {
671
+ state.floatingWidth = clamp(resizeStart.width + event.clientX - resizeStart.clientX, 280, innerWidth - state.x - 16);
672
+ state.floatingHeight = clamp(resizeStart.height + event.clientY - resizeStart.clientY, 360, innerHeight - state.y - 16);
673
+ } else state.width = clamp(resizeStart.width + resizeStart.clientX - event.clientX, 280, innerWidth - 320);
674
+ render();
675
+ }
676
+ var dragStart = null, resizeStart = null;
677
+ drag.addEventListener("pointerdown", function (event) {
678
+ dragStart = { clientX: event.clientX, clientY: event.clientY, x: state.x, y: state.y };
679
+ drag.setPointerCapture(event.pointerId);
680
+ });
681
+ drag.addEventListener("pointermove", onDrag);
682
+ drag.addEventListener("pointerup", function () { if (dragStart) save(); dragStart = null; });
683
+ drag.addEventListener("pointercancel", function () { dragStart = null; });
684
+ dockResize.addEventListener("pointerdown", function (event) {
685
+ resizeStart = { clientX: event.clientX, width: state.width, floating: false };
686
+ dockResize.setPointerCapture(event.pointerId);
687
+ });
688
+ floatResize.addEventListener("pointerdown", function (event) {
689
+ resizeStart = { clientX: event.clientX, clientY: event.clientY, width: state.floatingWidth,
690
+ height: state.floatingHeight, floating: true };
691
+ floatResize.setPointerCapture(event.pointerId);
692
+ });
693
+ dockResize.addEventListener("pointermove", onResize); floatResize.addEventListener("pointermove", onResize);
694
+ dockResize.addEventListener("pointerup", function () { if (resizeStart) save(); resizeStart = null; });
695
+ floatResize.addEventListener("pointerup", function () { if (resizeStart) save(); resizeStart = null; });
696
+ dockResize.addEventListener("pointercancel", function () { resizeStart = null; });
697
+ floatResize.addEventListener("pointercancel", function () { resizeStart = null; });
698
+ drag.addEventListener("keydown", function (event) {
699
+ var delta = { ArrowLeft: [-20, 0], ArrowRight: [20, 0], ArrowUp: [0, -20], ArrowDown: [0, 20] }[event.key];
700
+ if (!delta) return; event.preventDefault();
701
+ state.x = clamp(state.x + delta[0], 0, innerWidth - host.offsetWidth);
702
+ state.y = clamp(state.y + delta[1], 0, innerHeight - host.offsetHeight); save(); render();
703
+ });
704
+ launcher.addEventListener("click", open);
705
+ global.addEventListener("resize", render);
706
+ render(); if (state.open) connect();
707
+ return { open: open, close: close, setContext: setContext, destroy: function () {
708
+ if (disposed) return; disposed = true;
709
+ if (instance) instance.destroy();
710
+ global.removeEventListener("resize", render);
711
+ host.remove(); launcherHost.remove();
712
+ container.style.cssText = previousContainerStyle;
713
+ content.style.cssText = previousContentStyle;
714
+ if (previousChatSpace) document.documentElement.style.setProperty("--agent-chat-space", previousChatSpace);
715
+ else document.documentElement.style.removeProperty("--agent-chat-space");
716
+ } };
717
+ }
718
+ global.SolidAgentEmbed = { version: 7, mount: mount, mountWorkspace: mountWorkspace };
480
719
  })(window);
@@ -1,6 +1,21 @@
1
1
  import { DiscoveryService, ModuleRef } from '@nestjs/core';
2
2
  import { SolidRegistry } from '../helpers/solid-registry';
3
3
  import { InternationalisationHelperService } from '../services/internationalisation-helper.service';
4
+ import { TestingDataRecord, TestingRoleSpec, TestingUserSpec } from '../testing/contracts/testing-metadata.types';
5
+ export interface TestDataSpec {
6
+ roles?: TestingRoleSpec[];
7
+ users?: TestingUserSpec[];
8
+ data?: TestingDataRecord[];
9
+ }
10
+ export interface TestDataLoadSummary {
11
+ rolesProcessed: number;
12
+ usersProcessed: number;
13
+ data: {
14
+ created: number;
15
+ updated: number;
16
+ skipped: number;
17
+ };
18
+ }
4
19
  export declare class ModuleTestDataService {
5
20
  private readonly moduleRef;
6
21
  private readonly discoveryService;
@@ -15,6 +30,10 @@ export declare class ModuleTestDataService {
15
30
  deleteTestDatasources(): Promise<void>;
16
31
  private get testDataFiles();
17
32
  private seedTestData;
33
+ loadTestData(testing: TestDataSpec): Promise<TestDataLoadSummary>;
34
+ private newLoadSummary;
35
+ private applyTestingSpec;
36
+ private loadModelDefinitions;
18
37
  private unlinkTestData;
19
38
  private seedTestRoles;
20
39
  private expandPermissionNames;
@@ -1 +1 @@
1
- {"version":3,"file":"module-test-data.service.d.ts","sourceRoot":"","sources":["../../src/seeders/module-test-data.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAa3D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,iCAAiC,EAAE,MAAM,kDAAkD,CAAC;AAUrG,qBACa,qBAAqB;IAK9B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,iCAAiC;IAPpD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0C;IACjE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,uBAAuB,CAAK;gBAGjC,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,aAAa,EAAE,aAAa,EAC5B,iCAAiC,EAAE,iCAAiC;IAGjF,aAAa,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBtD,cAAc,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBvD,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAqEtC,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAoD5C,OAAO,KAAK,aAAa,GAexB;YAEa,YAAY;YAqIZ,cAAc;YAqDd,aAAa;YAoCb,qBAAqB;YA6BrB,aAAa;YA0Bb,kB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kCAAkC;YAc5B,eAAe;CA4B9B"}
@@ -67,6 +67,7 @@ const model_metadata_service_1 = require("../services/model-metadata.service");
67
67
  const role_metadata_service_1 = require("../services/role-metadata.service");
68
68
  const user_service_1 = require("../services/user.service");
69
69
  const mediaStorageProviders_1 = require("../services/mediaStorageProviders");
70
+ const isBlank = (value) => value === undefined || value === null || value === '';
70
71
  let ModuleTestDataService = ModuleTestDataService_1 = class ModuleTestDataService {
71
72
  constructor(moduleRef, discoveryService, solidRegistry, internationalisationHelperService) {
72
73
  this.moduleRef = moduleRef;
@@ -224,20 +225,43 @@ let ModuleTestDataService = ModuleTestDataService_1 = class ModuleTestDataServic
224
225
  if (!moduleMetadata) {
225
226
  throw new Error('Module metadata missing from test data payload.');
226
227
  }
227
- const testingRoles = overallMetadata?.testing?.roles ?? [];
228
- const testingUsers = overallMetadata?.testing?.users ?? [];
229
- const testingData = overallMetadata?.testing?.data ?? [];
228
+ const modelsByName = new Map((moduleMetadata.models ?? []).map((m) => [m.singularName, m]));
229
+ await this.applyTestingSpec(overallMetadata?.testing ?? {}, modelsByName, this.newLoadSummary());
230
+ }
231
+ async loadTestData(testing) {
232
+ if (!testing || typeof testing !== 'object') {
233
+ throw new Error('testing must be an object with optional roles, users and data arrays.');
234
+ }
235
+ const testingData = testing.data ?? [];
236
+ for (const entry of testingData) {
237
+ if (!entry || typeof entry.modelUserKey !== 'string' || entry.modelUserKey.length === 0) {
238
+ throw new Error('Every testing.data entry needs a non-empty modelUserKey.');
239
+ }
240
+ }
241
+ const modelsByName = await this.loadModelDefinitions(testingData);
242
+ const summary = this.newLoadSummary();
243
+ await this.applyTestingSpec(testing, modelsByName, summary);
244
+ return summary;
245
+ }
246
+ newLoadSummary() {
247
+ return { rolesProcessed: 0, usersProcessed: 0, data: { created: 0, updated: 0, skipped: 0 } };
248
+ }
249
+ async applyTestingSpec(testing, modelsByName, summary) {
250
+ const testingRoles = testing?.roles ?? [];
251
+ const testingUsers = testing?.users ?? [];
252
+ const testingData = testing?.data ?? [];
230
253
  if (testingRoles.length > 0) {
231
254
  await this.seedTestRoles(testingRoles);
255
+ summary.rolesProcessed += testingRoles.length;
232
256
  }
233
257
  if (testingUsers.length > 0) {
234
258
  await this.seedTestUsers(testingUsers);
259
+ summary.usersProcessed += testingUsers.length;
235
260
  }
236
261
  if (testingData.length === 0) {
237
- this.logger.debug(`No test data found for ${moduleMetadata.name}`);
262
+ this.logger.debug('No test data records to load.');
238
263
  return;
239
264
  }
240
- const modelsByName = new Map((moduleMetadata.models ?? []).map((m) => [m.singularName, m]));
241
265
  for (const entry of testingData) {
242
266
  const modelUserKey = entry.modelUserKey;
243
267
  const modelDef = modelsByName.get(modelUserKey);
@@ -256,7 +280,7 @@ let ModuleTestDataService = ModuleTestDataService_1 = class ModuleTestDataServic
256
280
  continue;
257
281
  }
258
282
  const userKeyValue = payload[userKeyProp];
259
- if (userKeyValue === null || userKeyValue === undefined || userKeyValue === '') {
283
+ if (isBlank(userKeyValue)) {
260
284
  delete payload[userKeyProp];
261
285
  continue;
262
286
  }
@@ -300,27 +324,38 @@ let ModuleTestDataService = ModuleTestDataService_1 = class ModuleTestDataServic
300
324
  }
301
325
  delete payload[field.name];
302
326
  }
303
- let savedEntity;
304
327
  const userKeyField = modelDef.userKeyFieldUserKey;
305
- const recordUserKeyValue = entry.recUserKeyValue ?? payload[userKeyField];
306
- const recordLabel = `${modelUserKey}.${userKeyField}=${recordUserKeyValue}`;
307
- if (userKeyField && payload[userKeyField] !== undefined) {
328
+ let savedEntity;
329
+ let action;
330
+ if (!userKeyField) {
331
+ this.logger.warn(`Model ${modelUserKey} has no user key field; inserting test record without idempotency.`);
332
+ savedEntity = await entityRepo.save(entityRepo.create(payload));
333
+ action = 'created';
334
+ }
335
+ else {
336
+ if (isBlank(payload[userKeyField])) {
337
+ console.log(`Skipping test data record for ${modelUserKey}: data has no "${userKeyField}" value.`);
338
+ this.logger.warn(`Skipping test data record for ${modelUserKey}: data has no "${userKeyField}" value.`);
339
+ summary.data.skipped++;
340
+ continue;
341
+ }
342
+ const userKeyValue = payload[userKeyField];
343
+ const recordLabel = `${modelUserKey}.${userKeyField}=${userKeyValue}`;
308
344
  const existing = await entityRepo.findOne({
309
- where: { [userKeyField]: payload[userKeyField] },
345
+ where: { [userKeyField]: userKeyValue },
310
346
  });
311
347
  if (existing) {
312
348
  console.log(`Updating test data record: ${recordLabel}`);
313
349
  savedEntity = await entityRepo.save(entityRepo.merge(existing, payload));
350
+ action = 'updated';
314
351
  }
315
352
  else {
316
353
  console.log(`Creating test data record: ${recordLabel}`);
317
354
  savedEntity = await entityRepo.save(entityRepo.create(payload));
355
+ action = 'created';
318
356
  }
319
357
  }
320
- else {
321
- console.log(`Creating test data record without user key lookup: ${modelUserKey}`);
322
- savedEntity = await entityRepo.save(entityRepo.create(payload));
323
- }
358
+ summary.data[action]++;
324
359
  if (multiRelationPayload.length > 0) {
325
360
  await this.seedMultiRelations(savedEntity.id, modelUserKey, multiRelationPayload, modelsByName);
326
361
  }
@@ -329,6 +364,51 @@ let ModuleTestDataService = ModuleTestDataService_1 = class ModuleTestDataServic
329
364
  }
330
365
  }
331
366
  }
367
+ async loadModelDefinitions(entries) {
368
+ const usedKeysByModel = new Map();
369
+ for (const entry of entries) {
370
+ const used = usedKeysByModel.get(entry.modelUserKey) ?? new Set();
371
+ Object.keys(entry.data ?? {}).forEach((key) => used.add(key));
372
+ usedKeysByModel.set(entry.modelUserKey, used);
373
+ }
374
+ const defs = new Map();
375
+ const queue = [...usedKeysByModel.keys()];
376
+ const modelService = this.modelMetadataService;
377
+ while (queue.length > 0) {
378
+ const name = queue.shift();
379
+ if (defs.has(name))
380
+ continue;
381
+ let entity;
382
+ try {
383
+ entity = await modelService.findOneBySingularName(name, {
384
+ fields: { mediaStorageProvider: true },
385
+ userKeyField: true,
386
+ });
387
+ }
388
+ catch (error) {
389
+ if (error instanceof common_1.NotFoundException) {
390
+ throw new Error(`Test data modelUserKey not found in application metadata: ${name}`);
391
+ }
392
+ throw error;
393
+ }
394
+ const def = {
395
+ singularName: entity.singularName,
396
+ internationalisation: !!entity.internationalisation,
397
+ userKeyFieldUserKey: entity.userKeyField?.name,
398
+ fields: (entity.fields ?? []).map((f) => ({ ...f })),
399
+ };
400
+ defs.set(name, def);
401
+ const used = usedKeysByModel.get(name);
402
+ for (const field of def.fields) {
403
+ if (field.type !== 'relation' || !field.relationCoModelSingularName)
404
+ continue;
405
+ if (used?.has(`${field.name}UserKey`) || used?.has(`${field.name}UserKeys`)) {
406
+ queue.push(field.relationCoModelSingularName);
407
+ }
408
+ }
409
+ }
410
+ return defs;
411
+ }
332
412
  async unlinkTestData(overallMetadata) {
333
413
  const moduleMetadata = overallMetadata.moduleMetadata;
334
414
  if (!moduleMetadata) {