@wangmo-bit/ds-link 0.0.0-stage → 0.8.18

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 (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +134 -2
  3. package/TESTING.md +59 -0
  4. package/THIRD_PARTY_NOTICES.md +313 -0
  5. package/assets/icon.svg +7 -0
  6. package/cordis.patch.yml +3 -0
  7. package/dist/client.js +6012 -0
  8. package/package.json +102 -4
  9. package/src/core/constants.js +188 -0
  10. package/src/core/downgrade.js +80 -0
  11. package/src/core/engine.js +4669 -0
  12. package/src/core/errors.js +51 -0
  13. package/src/core/ledger.js +1174 -0
  14. package/src/core/migration.js +741 -0
  15. package/src/core/render.js +61 -0
  16. package/src/core/settings.js +147 -0
  17. package/src/core/validation.js +454 -0
  18. package/src/host/adapter.js +1152 -0
  19. package/src/host/connection.js +113 -0
  20. package/src/host/entry-0.2.0.js +13 -0
  21. package/src/host/entry-0.3.0.js +13 -0
  22. package/src/host/entry-0.4.0.js +13 -0
  23. package/src/host/entry-0.8.10.js +13 -0
  24. package/src/host/entry-0.8.11.js +13 -0
  25. package/src/host/entry-0.8.12.js +13 -0
  26. package/src/host/entry-0.8.13.js +13 -0
  27. package/src/host/entry-0.8.14.js +13 -0
  28. package/src/host/entry-0.8.15.js +13 -0
  29. package/src/host/entry-0.8.16-pre.1.js +13 -0
  30. package/src/host/entry-0.8.16-pre.2.js +13 -0
  31. package/src/host/entry-0.8.16-pre.3.js +13 -0
  32. package/src/host/entry-0.8.16-pre.4.js +13 -0
  33. package/src/host/entry-0.8.16-pre.5.js +13 -0
  34. package/src/host/entry-0.8.18.js +13 -0
  35. package/src/host/entry-0.8.5.js +13 -0
  36. package/src/host/entry-0.8.6.js +13 -0
  37. package/src/host/entry-0.8.7.js +13 -0
  38. package/src/host/entry-0.8.8.js +13 -0
  39. package/src/host/entry-0.8.9.js +13 -0
  40. package/src/host/index.js +74 -0
  41. package/src/host/plugin.js +403 -0
  42. package/src/host/prompt.js +22 -0
  43. package/src/host/tools.js +312 -0
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Stable, model- and UI-facing failures. Messages never contain message
3
+ * bodies, paths, or credentials: only identities, codes, and bounded counts.
4
+ */
5
+
6
+ export class SessionLinkError extends Error {
7
+ /**
8
+ * @param {string} code stable machine code
9
+ * @param {string} message bounded human description
10
+ * @param {Record<string, unknown>} [details] bounded structured detail
11
+ */
12
+ constructor(code, message, details) {
13
+ super(message)
14
+ this.name = 'SessionLinkError'
15
+ this.code = code
16
+ if (details !== undefined) this.details = details
17
+ }
18
+ }
19
+
20
+ /**
21
+ * @param {string} code
22
+ * @param {string} message
23
+ * @param {Record<string, unknown>} [details]
24
+ * @returns {SessionLinkError}
25
+ */
26
+ export function fail(code, message, details) {
27
+ return new SessionLinkError(code, message, details)
28
+ }
29
+
30
+ /**
31
+ * @param {unknown} error
32
+ * @returns {{ code: string, message: string, details?: Record<string, unknown> }}
33
+ */
34
+ export function errorPayload(error) {
35
+ if (error instanceof SessionLinkError) {
36
+ const payload = { code: error.code, message: error.message }
37
+ if (error.details !== undefined) payload.details = error.details
38
+ return payload
39
+ }
40
+ return { code: 'internal', message: 'internal session-link failure' }
41
+ }
42
+
43
+ /**
44
+ * @param {unknown} error
45
+ * @returns {string} stable code for logs without exposing content
46
+ */
47
+ export function errorCode(error) {
48
+ if (error instanceof SessionLinkError) return error.code
49
+ if (error && typeof error === 'object' && 'code' in error && typeof error.code === 'string') return error.code
50
+ return 'internal'
51
+ }