vana-cli 0.24.5 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/cli/index.d.ts +2 -0
  2. package/dist/cli/index.d.ts.map +1 -1
  3. package/dist/cli/index.js +91 -12
  4. package/dist/cli/index.js.map +1 -1
  5. package/dist/connectors/registry.d.ts +2 -0
  6. package/dist/connectors/registry.d.ts.map +1 -1
  7. package/dist/connectors/registry.js +18 -2
  8. package/dist/connectors/registry.js.map +1 -1
  9. package/dist/core/cli-types.d.ts +44 -0
  10. package/dist/core/cli-types.d.ts.map +1 -1
  11. package/dist/core/cli-types.js +14 -0
  12. package/dist/core/cli-types.js.map +1 -1
  13. package/dist/core/state-store.d.ts +6 -0
  14. package/dist/core/state-store.d.ts.map +1 -1
  15. package/dist/core/state-store.js.map +1 -1
  16. package/dist/pdpp/host.d.ts +66 -0
  17. package/dist/pdpp/host.d.ts.map +1 -0
  18. package/dist/pdpp/host.js +283 -0
  19. package/dist/pdpp/host.js.map +1 -0
  20. package/dist/pdpp/installer.d.ts +17 -0
  21. package/dist/pdpp/installer.d.ts.map +1 -0
  22. package/dist/pdpp/installer.js +117 -0
  23. package/dist/pdpp/installer.js.map +1 -0
  24. package/dist/pdpp/local.d.ts +14 -0
  25. package/dist/pdpp/local.d.ts.map +1 -0
  26. package/dist/pdpp/local.js +76 -0
  27. package/dist/pdpp/local.js.map +1 -0
  28. package/dist/pdpp/pins.d.ts +23 -0
  29. package/dist/pdpp/pins.d.ts.map +1 -0
  30. package/dist/pdpp/pins.js +18 -0
  31. package/dist/pdpp/pins.js.map +1 -0
  32. package/dist/pdpp/profile.d.ts +49 -0
  33. package/dist/pdpp/profile.d.ts.map +1 -0
  34. package/dist/pdpp/profile.js +17 -0
  35. package/dist/pdpp/profile.js.map +1 -0
  36. package/dist/pdpp/protocol.d.ts +79 -0
  37. package/dist/pdpp/protocol.d.ts.map +1 -0
  38. package/dist/pdpp/protocol.js +372 -0
  39. package/dist/pdpp/protocol.js.map +1 -0
  40. package/dist/pdpp/runtime.d.ts +43 -0
  41. package/dist/pdpp/runtime.d.ts.map +1 -0
  42. package/dist/pdpp/runtime.js +387 -0
  43. package/dist/pdpp/runtime.js.map +1 -0
  44. package/dist/pdpp/store.d.ts +43 -0
  45. package/dist/pdpp/store.d.ts.map +1 -0
  46. package/dist/pdpp/store.js +100 -0
  47. package/dist/pdpp/store.js.map +1 -0
  48. package/dist/runtime/core/contracts.d.ts +2 -0
  49. package/dist/runtime/core/contracts.d.ts.map +1 -1
  50. package/dist/runtime/managed-playwright.d.ts +7 -0
  51. package/dist/runtime/managed-playwright.d.ts.map +1 -1
  52. package/dist/runtime/managed-playwright.js +7 -0
  53. package/dist/runtime/managed-playwright.js.map +1 -1
  54. package/dist/vendor/pdpp-connector-manager/LICENSE +202 -0
  55. package/dist/vendor/pdpp-connector-manager/NOTICE +2 -0
  56. package/dist/vendor/pdpp-connector-manager/VENDOR.md +27 -0
  57. package/dist/vendor/pdpp-connector-manager/catalog-schema-data.mjs +168 -0
  58. package/dist/vendor/pdpp-connector-manager/catalog-schema.mjs +62 -0
  59. package/dist/vendor/pdpp-connector-manager/index.d.mts +49 -0
  60. package/dist/vendor/pdpp-connector-manager/index.mjs +1646 -0
  61. package/dist/vendor/pdpp-connector-manager/oci-catalog.mjs +93 -0
  62. package/dist/vendor/pdpp-connector-manager/oci-registry.mjs +1002 -0
  63. package/dist/vendor/pdpp-connector-manager/oci-verify.mjs +515 -0
  64. package/dist/vendor/pdpp-connector-manager/package.json +51 -0
  65. package/dist/vendor/pdpp-connector-manager/retry.mjs +142 -0
  66. package/dist/vendor/pdpp-connector-manager/tar-stream.mjs +685 -0
  67. package/package.json +7 -2
@@ -0,0 +1,142 @@
1
+ // Copyright The PDP-Connect Contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export const DEFAULT_RETRY_ATTEMPTS = 6;
5
+ export const DEFAULT_RETRY_BASE_DELAY_MS = 1000;
6
+ export const DEFAULT_RETRY_MAX_DELAY_MS = 15_000;
7
+
8
+ const defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
9
+
10
+ export function isRetryableStatus(status) {
11
+ return status === 429 || (status >= 500 && status <= 599);
12
+ }
13
+
14
+ export function parseRetryAfter(value, now = Date.now()) {
15
+ if (typeof value !== "string") return null;
16
+
17
+ const seconds = Number(value.trim());
18
+ if (Number.isFinite(seconds) && seconds >= 0) {
19
+ return seconds * 1000;
20
+ }
21
+
22
+ const timestamp = Date.parse(value);
23
+ return Number.isFinite(timestamp) ? Math.max(0, timestamp - now) : null;
24
+ }
25
+
26
+ function getHeader(headers, name) {
27
+ if (headers?.get) return headers.get(name);
28
+ if (!headers || typeof headers !== "object") return null;
29
+ return headers[name] ?? headers[name.toLowerCase()] ?? null;
30
+ }
31
+
32
+ function retryDelay(attempt, { baseDelayMs, maxDelayMs, jitter, random }) {
33
+ const exponential = Math.min(maxDelayMs, baseDelayMs * 2 ** (attempt - 1));
34
+ if (!jitter || exponential === 0) return exponential;
35
+ return Math.min(maxDelayMs, exponential * (0.5 + random()));
36
+ }
37
+
38
+ function defaultOnRetry({ url, nextAttempt, attempts, delayMs, status, error }) {
39
+ const reason = status === null
40
+ ? `failed (${error instanceof Error ? error.message : String(error)})`
41
+ : `returned ${status}`;
42
+ console.warn(
43
+ `[connector-installer] fetch ${url} ${reason}; retrying in ${delayMs}ms ` +
44
+ `(attempt ${nextAttempt}/${attempts})`
45
+ );
46
+ }
47
+
48
+ /**
49
+ * Execute one fetch policy for release assets and registry requests.
50
+ *
51
+ * Only HTTP 429, HTTP 5xx, and rejected fetch promises are retried. A response
52
+ * with any other status is returned to the caller so it can preserve its own
53
+ * failure semantics, including the OCI present/absent/unknown distinction.
54
+ */
55
+ export async function fetchWithRetry(
56
+ url,
57
+ {
58
+ fetchImpl = fetch,
59
+ fetchOptions = {},
60
+ attempts = DEFAULT_RETRY_ATTEMPTS,
61
+ baseDelayMs = DEFAULT_RETRY_BASE_DELAY_MS,
62
+ maxDelayMs = DEFAULT_RETRY_MAX_DELAY_MS,
63
+ jitter = true,
64
+ random = Math.random,
65
+ sleep = defaultSleep,
66
+ now = Date.now,
67
+ onRetry = defaultOnRetry,
68
+ } = {}
69
+ ) {
70
+ const totalAttempts = Math.max(1, Math.floor(Number(attempts)) || 1);
71
+ const retryBaseDelayMs = Math.max(0, Number(baseDelayMs) || 0);
72
+ const retryMaxDelayMs = Math.max(retryBaseDelayMs, Number(maxDelayMs) || 0);
73
+
74
+ for (let attempt = 1; attempt <= totalAttempts; attempt += 1) {
75
+ let response;
76
+ try {
77
+ const options = typeof fetchOptions === "function"
78
+ ? fetchOptions(attempt)
79
+ : fetchOptions;
80
+ response = await fetchImpl(url, options);
81
+ } catch (error) {
82
+ if (attempt === totalAttempts) throw error;
83
+
84
+ const delayMs = retryDelay(attempt, {
85
+ baseDelayMs: retryBaseDelayMs,
86
+ maxDelayMs: retryMaxDelayMs,
87
+ jitter,
88
+ random,
89
+ });
90
+ await onRetry({
91
+ url,
92
+ attempt,
93
+ nextAttempt: attempt + 1,
94
+ attempts: totalAttempts,
95
+ delayMs,
96
+ status: null,
97
+ error,
98
+ retryAfterMs: null,
99
+ });
100
+ await sleep(delayMs);
101
+ continue;
102
+ }
103
+
104
+ if (!isRetryableStatus(response.status) || attempt === totalAttempts) {
105
+ return response;
106
+ }
107
+
108
+ const retryAfterMs = parseRetryAfter(
109
+ getHeader(response.headers, "retry-after"),
110
+ now()
111
+ );
112
+ const delayMs = Math.min(
113
+ retryMaxDelayMs,
114
+ Math.max(
115
+ retryDelay(attempt, {
116
+ baseDelayMs: retryBaseDelayMs,
117
+ maxDelayMs: retryMaxDelayMs,
118
+ jitter,
119
+ random,
120
+ }),
121
+ retryAfterMs ?? 0
122
+ )
123
+ );
124
+
125
+ try {
126
+ await response.body?.cancel?.();
127
+ } catch {
128
+ // A failed cleanup must not turn a retryable response into a terminal one.
129
+ }
130
+ await onRetry({
131
+ url,
132
+ attempt,
133
+ nextAttempt: attempt + 1,
134
+ attempts: totalAttempts,
135
+ delayMs,
136
+ status: response.status,
137
+ error: null,
138
+ retryAfterMs,
139
+ });
140
+ await sleep(delayMs);
141
+ }
142
+ }