@sourcegraph/amp 0.0.1749470495-ga92dad → 0.0.1749499297-gefb2d4

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/dist/amp.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import "./console-DjiPHC07.js";
3
- import "./main-C0YXppQM.js";
2
+ import "./console-DcPp_rUq.js";
3
+ import "./main-C94IoFQO.js";
4
4
  import "node:crypto";
5
5
  import "node:fs/promises";
6
6
  import "node:path";
7
7
  import "node:process";
8
- import "./client-B6fNYcnB.js";
8
+ import "./client-BWZPMP6j.js";
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env node
2
+ import { f as n, E as i, aV as c, s as p, p as w } from "./console-DcPp_rUq.js";
3
+ const m = !0;
4
+ function f() {
5
+ return new Proxy(
6
+ {},
7
+ {
8
+ get: (e, t) => async (...r) => {
9
+ const a = r.at(1), o = r.at(0), s = await h("/api/internal", {
10
+ method: "POST",
11
+ body: JSON.stringify({ method: t, params: o }),
12
+ signal: a?.signal
13
+ });
14
+ if (!s.ok)
15
+ throw new Error(`API request failed: ${s.status}`);
16
+ return await s.json();
17
+ }
18
+ }
19
+ );
20
+ }
21
+ const u = f(), y = i.pipe(
22
+ p(({ settings: e, secrets: t }) => w(async () => await t.getToken("apiKey", e.url) !== void 0))
23
+ );
24
+ async function h(e, t) {
25
+ const r = await n(i, t?.signal ?? void 0);
26
+ return d(r, e, t);
27
+ }
28
+ async function g(e, t) {
29
+ const r = await n(e.observe(t));
30
+ if (!r)
31
+ throw new Error(`Thread not found: ${t}`);
32
+ try {
33
+ const a = await u.shareThreadWithOperator({ threadData: r });
34
+ if (!a.ok)
35
+ throw new Error(`Failed to share thread: ${a.error.message}`);
36
+ } catch {
37
+ {
38
+ const o = await h("/api/internal/share-thread-with-operator", {
39
+ method: "POST",
40
+ headers: {
41
+ "Content-Type": "application/json"
42
+ },
43
+ body: JSON.stringify({ threadData: r })
44
+ });
45
+ if (!o.ok) {
46
+ const s = await o.text();
47
+ throw new Error(`Failed to share thread: ${o.status} ${s}`);
48
+ }
49
+ }
50
+ }
51
+ }
52
+ async function d(e, t, r) {
53
+ if (t.startsWith("http:") || t.startsWith("https:"))
54
+ throw new Error("input must be a path, not an absolute URL");
55
+ if (!t.startsWith("/"))
56
+ throw new Error("pathAndQuery must start with /");
57
+ const a = e.settings.url;
58
+ if (!a)
59
+ throw new Error("amp.url is not set");
60
+ const o = await e.secrets.getToken("apiKey", a);
61
+ if (!o || o.trim() === "") {
62
+ const s = new Error("Amp API key is not set");
63
+ throw s.name = "MissingApiKeyError", s;
64
+ }
65
+ return fetch(new URL(t, a), {
66
+ ...r,
67
+ headers: {
68
+ ...r?.headers,
69
+ ...c(),
70
+ "Content-Type": "application/json",
71
+ Authorization: `Bearer ${o}`
72
+ }
73
+ });
74
+ }
75
+ export {
76
+ m as F,
77
+ y as a,
78
+ h as f,
79
+ u as i,
80
+ g as s
81
+ };