@integrity-labs/agt-cli 0.28.317 → 0.28.319

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.
@@ -5067,7 +5067,12 @@ var INTEGRATION_REGISTRY = [
5067
5067
  },
5068
5068
  // ENG-5857 mints the real session id; default empty so the header
5069
5069
  // resolves cleanly (no profile bound → ephemeral session) until then.
5070
- envDefaults: { ANCHOR_BROWSER_SESSION_ID: "" }
5070
+ envDefaults: { ANCHOR_BROWSER_SESSION_ID: "" },
5071
+ // ENG-7748: route through the stdio remote-MCP proxy so the api-key and
5072
+ // the minted anchor-session-id headers are read LIVE per request. A
5073
+ // re-minted session id then takes effect with no agent respawn (a direct-
5074
+ // HTTP header would be frozen at spawn).
5075
+ liveHeaderRefresh: true
5071
5076
  }
5072
5077
  },
5073
5078
  {
@@ -5763,6 +5768,174 @@ var INSTALLABLE_NATIVE_INTEGRATION_IDS = INSTALLABLE_NATIVE_INTEGRATIONS.map((i)
5763
5768
  var MB2 = 1024 * 1024;
5764
5769
  var DIRECT_CHAT_UPLOAD_MAX_BYTES = 10 * MB2;
5765
5770
 
5771
+ // ../../packages/core/dist/anchor/types.js
5772
+ var ANCHOR_API_BASE_URL = "https://api.anchorbrowser.io/v1";
5773
+ var ANCHOR_API_KEY_HEADER = "anchor-api-key";
5774
+
5775
+ // ../../packages/core/dist/anchor/client.js
5776
+ var AnchorApiError = class extends Error {
5777
+ status;
5778
+ body;
5779
+ constructor(status, message, body) {
5780
+ super(message);
5781
+ this.name = "AnchorApiError";
5782
+ this.status = status;
5783
+ this.body = body;
5784
+ }
5785
+ };
5786
+ function buildCreateSessionBody(input) {
5787
+ const browser = {};
5788
+ if (input.profileName) {
5789
+ browser["profile"] = { name: input.profileName, persist: Boolean(input.persist) };
5790
+ }
5791
+ if (input.dedicatedStickyIp) {
5792
+ browser["dedicated_sticky_ip"] = true;
5793
+ }
5794
+ const timeout = {};
5795
+ if (typeof input.maxDurationMinutes === "number")
5796
+ timeout["max_duration"] = input.maxDurationMinutes;
5797
+ if (typeof input.idleTimeoutMinutes === "number")
5798
+ timeout["idle_timeout"] = input.idleTimeoutMinutes;
5799
+ const body = {};
5800
+ if (Object.keys(browser).length > 0)
5801
+ body["browser"] = browser;
5802
+ if (Object.keys(timeout).length > 0)
5803
+ body["session"] = { timeout };
5804
+ return body;
5805
+ }
5806
+ function extractSessionId(raw) {
5807
+ if (!raw || typeof raw !== "object")
5808
+ return null;
5809
+ const obj = raw;
5810
+ const data = obj["data"];
5811
+ const candidates = [
5812
+ data && typeof data === "object" ? data["id"] : void 0,
5813
+ data && typeof data === "object" ? data["session_id"] : void 0,
5814
+ obj["id"],
5815
+ obj["session_id"],
5816
+ obj["sessionId"]
5817
+ ];
5818
+ for (const c of candidates) {
5819
+ if (typeof c === "string" && c.length > 0)
5820
+ return c;
5821
+ }
5822
+ return null;
5823
+ }
5824
+ function extractLiveViewUrl(raw) {
5825
+ if (!raw || typeof raw !== "object")
5826
+ return null;
5827
+ const obj = raw;
5828
+ const data = obj["data"];
5829
+ const dataObj = data && typeof data === "object" ? data : void 0;
5830
+ const candidates = [
5831
+ dataObj?.["live_view_url"],
5832
+ dataObj?.["liveViewUrl"],
5833
+ obj["live_view_url"],
5834
+ obj["liveViewUrl"]
5835
+ ];
5836
+ for (const c of candidates) {
5837
+ if (typeof c === "string" && c.length > 0)
5838
+ return c;
5839
+ }
5840
+ return null;
5841
+ }
5842
+ var AnchorSessionClient = class {
5843
+ apiKey;
5844
+ baseUrl;
5845
+ timeoutMs;
5846
+ fetchImpl;
5847
+ constructor(opts) {
5848
+ if (!opts.apiKey) {
5849
+ throw new Error("AnchorSessionClient requires an apiKey");
5850
+ }
5851
+ this.apiKey = opts.apiKey;
5852
+ this.baseUrl = (opts.baseUrl ?? ANCHOR_API_BASE_URL).replace(/\/+$/, "");
5853
+ this.timeoutMs = opts.timeoutMs ?? 3e4;
5854
+ this.fetchImpl = opts.fetchImpl ?? fetch;
5855
+ }
5856
+ /**
5857
+ * Mint a session (`POST /sessions`). With a `profileName` the session resumes
5858
+ * that profile's authenticated state; without one it is a fresh stateless
5859
+ * browser. Throws {@link AnchorApiError} on a non-2xx, or a plain Error when
5860
+ * the response carries no locatable session id.
5861
+ */
5862
+ async createSession(input = {}) {
5863
+ const raw = await this.request("POST", "/sessions", buildCreateSessionBody(input));
5864
+ const sessionId = extractSessionId(raw);
5865
+ if (!sessionId) {
5866
+ throw new Error("Anchor createSession returned no locatable session id");
5867
+ }
5868
+ const liveViewUrl = extractLiveViewUrl(raw);
5869
+ return { sessionId, ...liveViewUrl ? { liveViewUrl } : {}, raw };
5870
+ }
5871
+ /**
5872
+ * Snapshot a running session's authenticated state into a named profile
5873
+ * (`POST /profiles` with `source: 'session'`). This is the explicit SAVE step
5874
+ * for onboarding - separating it from `endSession` means an aborted onboarding
5875
+ * can just end the session and persist NOTHING (a persist-on-end session would
5876
+ * flush partial/unauthenticated state and could clobber a good profile).
5877
+ * // anchor-verify: body shape from the ENG-5854 spike (verified live there).
5878
+ */
5879
+ async saveProfileFromSession(name, sessionId, opts = {}) {
5880
+ await this.request("POST", "/profiles", {
5881
+ name,
5882
+ source: "session",
5883
+ session_id: sessionId,
5884
+ ...opts.dedicatedStickyIp ? { dedicated_sticky_ip: true } : {}
5885
+ });
5886
+ }
5887
+ /**
5888
+ * End a session (`DELETE /sessions/:id`). Best-effort by contract: a 404 (the
5889
+ * session already expired) is treated as success - the goal state (no live
5890
+ * session) is reached either way.
5891
+ */
5892
+ async endSession(sessionId) {
5893
+ try {
5894
+ await this.request("DELETE", `/sessions/${encodeURIComponent(sessionId)}`);
5895
+ } catch (err) {
5896
+ if (err instanceof AnchorApiError && err.status === 404)
5897
+ return;
5898
+ throw err;
5899
+ }
5900
+ }
5901
+ // --- internals ----------------------------------------------------------
5902
+ async request(method, path, body) {
5903
+ const url = `${this.baseUrl}${path}`;
5904
+ const controller = new AbortController();
5905
+ const timer = setTimeout(() => controller.abort(), this.timeoutMs);
5906
+ let res;
5907
+ let text;
5908
+ try {
5909
+ res = await this.fetchImpl(url, {
5910
+ method,
5911
+ headers: {
5912
+ [ANCHOR_API_KEY_HEADER]: this.apiKey,
5913
+ ...body !== void 0 ? { "Content-Type": "application/json" } : {}
5914
+ },
5915
+ body: body !== void 0 ? JSON.stringify(body) : void 0,
5916
+ signal: controller.signal
5917
+ });
5918
+ text = await res.text();
5919
+ } catch (err) {
5920
+ const reason = err instanceof Error ? err.message : String(err);
5921
+ throw new AnchorApiError(0, `Anchor request failed: ${reason}`, void 0);
5922
+ } finally {
5923
+ clearTimeout(timer);
5924
+ }
5925
+ let parsed;
5926
+ try {
5927
+ parsed = text ? JSON.parse(text) : void 0;
5928
+ } catch {
5929
+ parsed = text;
5930
+ }
5931
+ if (!res.ok) {
5932
+ const detail = typeof parsed === "object" && parsed !== null && "error" in parsed ? String(parsed.error) : res.statusText;
5933
+ throw new AnchorApiError(res.status, `Anchor returned ${res.status}: ${detail}`, parsed);
5934
+ }
5935
+ return parsed;
5936
+ }
5937
+ };
5938
+
5766
5939
  // ../../packages/core/dist/onboarding/state-machine.js
5767
5940
  var AREA_ORDER = [
5768
5941
  "framing",
@@ -9760,6 +9933,7 @@ export {
9760
9933
  probeComposioAccount,
9761
9934
  probeComposioMcpToolCall,
9762
9935
  probeHttpProvider,
9936
+ AnchorSessionClient,
9763
9937
  isOnboardingArea,
9764
9938
  describeOnboardingChannel,
9765
9939
  coerceOnboardingState,
@@ -9845,4 +10019,4 @@ export {
9845
10019
  stopAllSessionsAndWait,
9846
10020
  getProjectDir
9847
10021
  };
9848
- //# sourceMappingURL=chunk-ORTMG5E3.js.map
10022
+ //# sourceMappingURL=chunk-ISHK77EM.js.map