critiqs-react 0.3.0 → 0.5.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 (58) hide show
  1. package/AGENT_SETUP.md +198 -66
  2. package/README.md +214 -31
  3. package/bin/critiqs.mjs +3 -1
  4. package/dist/index.js +16877 -4770
  5. package/dist/server/index.d.ts +1 -87
  6. package/dist/server/index.js +1 -4889
  7. package/package.json +6 -5
  8. package/bin/cli.d.mts +0 -21
  9. package/bin/cli.mjs +0 -293
  10. package/bin/env.d.mts +0 -41
  11. package/bin/env.mjs +0 -384
  12. package/bin/init.d.mts +0 -126
  13. package/bin/init.mjs +0 -965
  14. package/bin/mcp.d.mts +0 -20
  15. package/bin/mcp.mjs +0 -314
  16. package/bin/setup.d.mts +0 -183
  17. package/bin/setup.mjs +0 -1054
  18. package/dist/backend/convex/_generated/api.d.ts +0 -95
  19. package/dist/backend/convex/_generated/api.js +0 -23
  20. package/dist/backend/convex/_generated/dataModel.d.ts +0 -60
  21. package/dist/backend/convex/_generated/server.d.ts +0 -162
  22. package/dist/backend/convex/_generated/server.js +0 -101
  23. package/dist/backend/convex/ai.ts +0 -93
  24. package/dist/backend/convex/aiSettings.ts +0 -43
  25. package/dist/backend/convex/auth.config.ts +0 -18
  26. package/dist/backend/convex/captureHttp.ts +0 -96
  27. package/dist/backend/convex/captures.ts +0 -167
  28. package/dist/backend/convex/crons.ts +0 -14
  29. package/dist/backend/convex/deviceSignIn.ts +0 -151
  30. package/dist/backend/convex/grouping.ts +0 -41
  31. package/dist/backend/convex/http.ts +0 -724
  32. package/dist/backend/convex/lib/ai.ts +0 -6
  33. package/dist/backend/convex/lib/links.ts +0 -12
  34. package/dist/backend/convex/lib/pages.ts +0 -207
  35. package/dist/backend/convex/lib/r2.ts +0 -75
  36. package/dist/backend/convex/lib/store.ts +0 -509
  37. package/dist/backend/convex/lib/tokens.ts +0 -101
  38. package/dist/backend/convex/lib/validators.ts +0 -73
  39. package/dist/backend/convex/lib/vendor/aws4fetch.js +0 -289
  40. package/dist/backend/convex/lib/vendor/critiqs_ai.js +0 -49081
  41. package/dist/backend/convex/lib/vendor/critiqs_core.js +0 -385
  42. package/dist/backend/convex/lib/vendor/critiqs_server.js +0 -3108
  43. package/dist/backend/convex/notificationEmails.ts +0 -61
  44. package/dist/backend/convex/notifications.ts +0 -182
  45. package/dist/backend/convex/plans.ts +0 -67
  46. package/dist/backend/convex/projects.ts +0 -46
  47. package/dist/backend/convex/schema.ts +0 -343
  48. package/dist/backend/convex/search.ts +0 -26
  49. package/dist/backend/convex/signIn.ts +0 -368
  50. package/dist/backend/convex/tags.ts +0 -68
  51. package/dist/backend/convex/threads.ts +0 -146
  52. package/dist/backend/convex/users.ts +0 -13
  53. package/dist/server/chunks/driver-n9zpr0k3.js +0 -21
  54. package/dist/server/chunks/index-9bg7tmnq.js +0 -522
  55. package/dist/server/chunks/index-askcfn7t.js +0 -148
  56. package/dist/server/chunks/providers-rv184xvj.js +0 -48444
  57. package/dist/server/chunks/token-kzddms7r.js +0 -63
  58. package/dist/server/chunks/token-util-k8bee1wc.js +0 -4
@@ -1,289 +0,0 @@
1
- // ../../node_modules/.bun/aws4fetch@1.0.20/node_modules/aws4fetch/dist/aws4fetch.esm.mjs
2
- var encoder = new TextEncoder;
3
- var HOST_SERVICES = {
4
- appstream2: "appstream",
5
- cloudhsmv2: "cloudhsm",
6
- email: "ses",
7
- marketplace: "aws-marketplace",
8
- mobile: "AWSMobileHubService",
9
- pinpoint: "mobiletargeting",
10
- queue: "sqs",
11
- "git-codecommit": "codecommit",
12
- "mturk-requester-sandbox": "mturk-requester",
13
- "personalize-runtime": "personalize"
14
- };
15
- var UNSIGNABLE_HEADERS = new Set([
16
- "authorization",
17
- "content-type",
18
- "content-length",
19
- "user-agent",
20
- "presigned-expires",
21
- "expect",
22
- "x-amzn-trace-id",
23
- "range",
24
- "connection"
25
- ]);
26
-
27
- class AwsClient {
28
- constructor({ accessKeyId, secretAccessKey, sessionToken, service, region, cache, retries, initRetryMs }) {
29
- if (accessKeyId == null)
30
- throw new TypeError("accessKeyId is a required option");
31
- if (secretAccessKey == null)
32
- throw new TypeError("secretAccessKey is a required option");
33
- this.accessKeyId = accessKeyId;
34
- this.secretAccessKey = secretAccessKey;
35
- this.sessionToken = sessionToken;
36
- this.service = service;
37
- this.region = region;
38
- this.cache = cache || new Map;
39
- this.retries = retries != null ? retries : 10;
40
- this.initRetryMs = initRetryMs || 50;
41
- }
42
- async sign(input, init) {
43
- if (input instanceof Request) {
44
- const { method, url, headers, body } = input;
45
- init = Object.assign({ method, url, headers }, init);
46
- if (init.body == null && headers.has("Content-Type")) {
47
- init.body = body != null && headers.has("X-Amz-Content-Sha256") ? body : await input.clone().arrayBuffer();
48
- }
49
- input = url;
50
- }
51
- const signer = new AwsV4Signer(Object.assign({ url: input.toString() }, init, this, init && init.aws));
52
- const signed = Object.assign({}, init, await signer.sign());
53
- delete signed.aws;
54
- try {
55
- return new Request(signed.url.toString(), signed);
56
- } catch (e) {
57
- if (e instanceof TypeError) {
58
- return new Request(signed.url.toString(), Object.assign({ duplex: "half" }, signed));
59
- }
60
- throw e;
61
- }
62
- }
63
- async fetch(input, init) {
64
- for (let i = 0;i <= this.retries; i++) {
65
- const fetched = fetch(await this.sign(input, init));
66
- if (i === this.retries) {
67
- return fetched;
68
- }
69
- const res = await fetched;
70
- if (res.status < 500 && res.status !== 429) {
71
- return res;
72
- }
73
- await new Promise((resolve) => setTimeout(resolve, Math.random() * this.initRetryMs * Math.pow(2, i)));
74
- }
75
- throw new Error("An unknown error occurred, ensure retries is not negative");
76
- }
77
- }
78
-
79
- class AwsV4Signer {
80
- constructor({ method, url, headers, body, accessKeyId, secretAccessKey, sessionToken, service, region, cache, datetime, signQuery, appendSessionToken, allHeaders, singleEncode }) {
81
- if (url == null)
82
- throw new TypeError("url is a required option");
83
- if (accessKeyId == null)
84
- throw new TypeError("accessKeyId is a required option");
85
- if (secretAccessKey == null)
86
- throw new TypeError("secretAccessKey is a required option");
87
- this.method = method || (body ? "POST" : "GET");
88
- this.url = new URL(url);
89
- this.headers = new Headers(headers || {});
90
- this.body = body;
91
- this.accessKeyId = accessKeyId;
92
- this.secretAccessKey = secretAccessKey;
93
- this.sessionToken = sessionToken;
94
- let guessedService, guessedRegion;
95
- if (!service || !region) {
96
- [guessedService, guessedRegion] = guessServiceRegion(this.url, this.headers);
97
- }
98
- this.service = service || guessedService || "";
99
- this.region = region || guessedRegion || "us-east-1";
100
- this.cache = cache || new Map;
101
- this.datetime = datetime || new Date().toISOString().replace(/[:-]|\.\d{3}/g, "");
102
- this.signQuery = signQuery;
103
- this.appendSessionToken = appendSessionToken || this.service === "iotdevicegateway";
104
- this.headers.delete("Host");
105
- if (this.service === "s3" && !this.signQuery && !this.headers.has("X-Amz-Content-Sha256")) {
106
- this.headers.set("X-Amz-Content-Sha256", "UNSIGNED-PAYLOAD");
107
- }
108
- const params = this.signQuery ? this.url.searchParams : this.headers;
109
- params.set("X-Amz-Date", this.datetime);
110
- if (this.sessionToken && !this.appendSessionToken) {
111
- params.set("X-Amz-Security-Token", this.sessionToken);
112
- }
113
- this.signableHeaders = ["host", ...this.headers.keys()].filter((header) => allHeaders || !UNSIGNABLE_HEADERS.has(header)).sort();
114
- this.signedHeaders = this.signableHeaders.join(";");
115
- this.canonicalHeaders = this.signableHeaders.map((header) => header + ":" + (header === "host" ? this.url.host : (this.headers.get(header) || "").replace(/\s+/g, " "))).join(`
116
- `);
117
- this.credentialString = [this.datetime.slice(0, 8), this.region, this.service, "aws4_request"].join("/");
118
- if (this.signQuery) {
119
- if (this.service === "s3" && !params.has("X-Amz-Expires")) {
120
- params.set("X-Amz-Expires", "86400");
121
- }
122
- params.set("X-Amz-Algorithm", "AWS4-HMAC-SHA256");
123
- params.set("X-Amz-Credential", this.accessKeyId + "/" + this.credentialString);
124
- params.set("X-Amz-SignedHeaders", this.signedHeaders);
125
- }
126
- if (this.service === "s3") {
127
- try {
128
- this.encodedPath = decodeURIComponent(this.url.pathname.replace(/\+/g, " "));
129
- } catch (e) {
130
- this.encodedPath = this.url.pathname;
131
- }
132
- } else {
133
- this.encodedPath = this.url.pathname.replace(/\/+/g, "/");
134
- }
135
- if (!singleEncode) {
136
- this.encodedPath = encodeURIComponent(this.encodedPath).replace(/%2F/g, "/");
137
- }
138
- this.encodedPath = encodeRfc3986(this.encodedPath);
139
- const seenKeys = new Set;
140
- this.encodedSearch = [...this.url.searchParams].filter(([k]) => {
141
- if (!k)
142
- return false;
143
- if (this.service === "s3") {
144
- if (seenKeys.has(k))
145
- return false;
146
- seenKeys.add(k);
147
- }
148
- return true;
149
- }).map((pair) => pair.map((p) => encodeRfc3986(encodeURIComponent(p)))).sort(([k1, v1], [k2, v2]) => k1 < k2 ? -1 : k1 > k2 ? 1 : v1 < v2 ? -1 : v1 > v2 ? 1 : 0).map((pair) => pair.join("=")).join("&");
150
- }
151
- async sign() {
152
- if (this.signQuery) {
153
- this.url.searchParams.set("X-Amz-Signature", await this.signature());
154
- if (this.sessionToken && this.appendSessionToken) {
155
- this.url.searchParams.set("X-Amz-Security-Token", this.sessionToken);
156
- }
157
- } else {
158
- this.headers.set("Authorization", await this.authHeader());
159
- }
160
- return {
161
- method: this.method,
162
- url: this.url,
163
- headers: this.headers,
164
- body: this.body
165
- };
166
- }
167
- async authHeader() {
168
- return [
169
- "AWS4-HMAC-SHA256 Credential=" + this.accessKeyId + "/" + this.credentialString,
170
- "SignedHeaders=" + this.signedHeaders,
171
- "Signature=" + await this.signature()
172
- ].join(", ");
173
- }
174
- async signature() {
175
- const date = this.datetime.slice(0, 8);
176
- const cacheKey = [this.secretAccessKey, date, this.region, this.service].join();
177
- let kCredentials = this.cache.get(cacheKey);
178
- if (!kCredentials) {
179
- const kDate = await hmac("AWS4" + this.secretAccessKey, date);
180
- const kRegion = await hmac(kDate, this.region);
181
- const kService = await hmac(kRegion, this.service);
182
- kCredentials = await hmac(kService, "aws4_request");
183
- this.cache.set(cacheKey, kCredentials);
184
- }
185
- return buf2hex(await hmac(kCredentials, await this.stringToSign()));
186
- }
187
- async stringToSign() {
188
- return [
189
- "AWS4-HMAC-SHA256",
190
- this.datetime,
191
- this.credentialString,
192
- buf2hex(await hash(await this.canonicalString()))
193
- ].join(`
194
- `);
195
- }
196
- async canonicalString() {
197
- return [
198
- this.method.toUpperCase(),
199
- this.encodedPath,
200
- this.encodedSearch,
201
- this.canonicalHeaders + `
202
- `,
203
- this.signedHeaders,
204
- await this.hexBodyHash()
205
- ].join(`
206
- `);
207
- }
208
- async hexBodyHash() {
209
- let hashHeader = this.headers.get("X-Amz-Content-Sha256") || (this.service === "s3" && this.signQuery ? "UNSIGNED-PAYLOAD" : null);
210
- if (hashHeader == null) {
211
- if (this.body && typeof this.body !== "string" && !("byteLength" in this.body)) {
212
- throw new Error("body must be a string, ArrayBuffer or ArrayBufferView, unless you include the X-Amz-Content-Sha256 header");
213
- }
214
- hashHeader = buf2hex(await hash(this.body || ""));
215
- }
216
- return hashHeader;
217
- }
218
- }
219
- async function hmac(key, string) {
220
- const cryptoKey = await crypto.subtle.importKey("raw", typeof key === "string" ? encoder.encode(key) : key, { name: "HMAC", hash: { name: "SHA-256" } }, false, ["sign"]);
221
- return crypto.subtle.sign("HMAC", cryptoKey, encoder.encode(string));
222
- }
223
- async function hash(content) {
224
- return crypto.subtle.digest("SHA-256", typeof content === "string" ? encoder.encode(content) : content);
225
- }
226
- var HEX_CHARS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
227
- function buf2hex(arrayBuffer) {
228
- const buffer = new Uint8Array(arrayBuffer);
229
- let out = "";
230
- for (let idx = 0;idx < buffer.length; idx++) {
231
- const n = buffer[idx];
232
- out += HEX_CHARS[n >>> 4 & 15];
233
- out += HEX_CHARS[n & 15];
234
- }
235
- return out;
236
- }
237
- function encodeRfc3986(urlEncodedStr) {
238
- return urlEncodedStr.replace(/[!'()*]/g, (c) => "%" + c.charCodeAt(0).toString(16).toUpperCase());
239
- }
240
- function guessServiceRegion(url, headers) {
241
- const { hostname, pathname } = url;
242
- if (hostname.endsWith(".on.aws")) {
243
- const match = hostname.match(/^[^.]{1,63}\.lambda-url\.([^.]{1,63})\.on\.aws$/);
244
- return match != null ? ["lambda", match[1] || ""] : ["", ""];
245
- }
246
- if (hostname.endsWith(".r2.cloudflarestorage.com")) {
247
- return ["s3", "auto"];
248
- }
249
- if (hostname.endsWith(".backblazeb2.com")) {
250
- const match = hostname.match(/^(?:[^.]{1,63}\.)?s3\.([^.]{1,63})\.backblazeb2\.com$/);
251
- return match != null ? ["s3", match[1] || ""] : ["", ""];
252
- }
253
- const match = hostname.replace("dualstack.", "").match(/([^.]{1,63})\.(?:([^.]{0,63})\.)?amazonaws\.com(?:\.cn)?$/);
254
- let service = match && match[1] || "";
255
- let region = match && match[2];
256
- if (region === "us-gov") {
257
- region = "us-gov-west-1";
258
- } else if (region === "s3" || region === "s3-accelerate") {
259
- region = "us-east-1";
260
- service = "s3";
261
- } else if (service === "iot") {
262
- if (hostname.startsWith("iot.")) {
263
- service = "execute-api";
264
- } else if (hostname.startsWith("data.jobs.iot.")) {
265
- service = "iot-jobs-data";
266
- } else {
267
- service = pathname === "/mqtt" ? "iotdevicegateway" : "iotdata";
268
- }
269
- } else if (service === "autoscaling") {
270
- const targetPrefix = (headers.get("X-Amz-Target") || "").split(".")[0];
271
- if (targetPrefix === "AnyScaleFrontendService") {
272
- service = "application-autoscaling";
273
- } else if (targetPrefix === "AnyScaleScalingPlannerFrontendService") {
274
- service = "autoscaling-plans";
275
- }
276
- } else if (region == null && service.startsWith("s3-")) {
277
- region = service.slice(3).replace(/^fips-|^external-1/, "");
278
- service = "s3";
279
- } else if (service.endsWith("-fips")) {
280
- service = service.slice(0, -5);
281
- } else if (region && /-\d$/.test(service) && !/-\d$/.test(region)) {
282
- [service, region] = [region, service];
283
- }
284
- return [HOST_SERVICES[service] || service, region || ""];
285
- }
286
- export {
287
- AwsClient,
288
- AwsV4Signer
289
- };