@emblemvault/hustle-react 1.5.7 → 1.5.8

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.
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import { createContext, useState, useEffect, useCallback, useRef, useMemo, useContext } from 'react';
2
3
  import { HustleIncognitoClient } from 'hustle-incognito';
3
4
  import { useEmblemAuthOptional } from '@emblemvault/emblem-auth-react';
@@ -15324,6 +15325,9 @@ function HustleChat({
15324
15325
  }
15325
15326
  return false;
15326
15327
  });
15328
+ const [paygStatus, setPaygStatus] = useState(null);
15329
+ const [paygLoading, setPaygLoading] = useState(false);
15330
+ const [paygError, setPaygError] = useState(null);
15327
15331
  useEffect(() => {
15328
15332
  if (typeof window !== "undefined") {
15329
15333
  localStorage.setItem(`hustle-stt-enabled-${instanceId}`, String(speechToTextEnabled));
@@ -15377,6 +15381,34 @@ function HustleChat({
15377
15381
  const removeAttachment = useCallback((index) => {
15378
15382
  setAttachments((prev) => prev.filter((_2, i) => i !== index));
15379
15383
  }, []);
15384
+ const fetchPaygStatus = useCallback(async () => {
15385
+ if (!client) return;
15386
+ setPaygLoading(true);
15387
+ setPaygError(null);
15388
+ try {
15389
+ const status = await client.getPaygStatus();
15390
+ setPaygStatus(status);
15391
+ } catch (err) {
15392
+ setPaygError(err.message || "Failed to fetch PAYG status");
15393
+ } finally {
15394
+ setPaygLoading(false);
15395
+ }
15396
+ }, [client]);
15397
+ const configurePayg = useCallback(async (options) => {
15398
+ if (!client) return;
15399
+ setPaygError(null);
15400
+ try {
15401
+ await client.configurePayg(options);
15402
+ await fetchPaygStatus();
15403
+ } catch (err) {
15404
+ setPaygError(err.message || "Failed to configure PAYG");
15405
+ }
15406
+ }, [client, fetchPaygStatus]);
15407
+ useEffect(() => {
15408
+ if (showSettingsPanel && client) {
15409
+ fetchPaygStatus();
15410
+ }
15411
+ }, [showSettingsPanel, client, fetchPaygStatus]);
15380
15412
  const sendContinue = useCallback(async () => {
15381
15413
  if (isStreaming || !isReady) return;
15382
15414
  console.log("[AUTO_CONTINUE] Sending continue message...");
@@ -15831,6 +15863,84 @@ function HustleChat({
15831
15863
  /* @__PURE__ */ jsx("p", { style: styles.settingDescription, children: "Use your microphone to dictate messages" })
15832
15864
  ] }),
15833
15865
  /* @__PURE__ */ jsx("div", { style: styles.settingDivider }),
15866
+ /* @__PURE__ */ jsxs("div", { style: styles.settingGroup, children: [
15867
+ /* @__PURE__ */ jsx("label", { style: styles.settingLabel, children: "Pay-As-You-Go Billing" }),
15868
+ /* @__PURE__ */ jsx("p", { style: styles.settingDescription, children: "Manage your PAYG billing configuration" }),
15869
+ paygLoading && !paygStatus && /* @__PURE__ */ jsx("p", { style: { ...styles.settingDescription, fontStyle: "italic" }, children: "Loading billing status..." }),
15870
+ paygError && /* @__PURE__ */ jsx("p", { style: { ...styles.settingDescription, color: "#ef4444" }, children: paygError }),
15871
+ paygStatus && /* @__PURE__ */ jsxs(Fragment, { children: [
15872
+ /* @__PURE__ */ jsxs(
15873
+ "div",
15874
+ {
15875
+ style: styles.toggleRow,
15876
+ onClick: () => configurePayg({ enabled: !paygStatus.enabled }),
15877
+ children: [
15878
+ /* @__PURE__ */ jsx("span", { style: styles.toggleLabel, children: paygStatus.enabled ? "PAYG Enabled" : "PAYG Disabled" }),
15879
+ /* @__PURE__ */ jsx("div", { style: {
15880
+ ...styles.toggleSwitch,
15881
+ ...paygStatus.enabled ? styles.toggleSwitchActive : {}
15882
+ }, children: /* @__PURE__ */ jsx("div", { style: {
15883
+ ...styles.toggleKnob,
15884
+ ...paygStatus.enabled ? styles.toggleKnobActive : {}
15885
+ } }) })
15886
+ ]
15887
+ }
15888
+ ),
15889
+ paygStatus.enabled && /* @__PURE__ */ jsxs(Fragment, { children: [
15890
+ /* @__PURE__ */ jsxs("div", { style: { marginTop: tokens.spacing.sm }, children: [
15891
+ /* @__PURE__ */ jsx("label", { style: { ...styles.settingDescription, display: "block", marginBottom: "4px" }, children: "Payment Token" }),
15892
+ /* @__PURE__ */ jsx(
15893
+ "select",
15894
+ {
15895
+ value: paygStatus.payment_token || "",
15896
+ onChange: (e) => configurePayg({ payment_token: e.target.value }),
15897
+ style: styles.settingSelect,
15898
+ children: (paygStatus.available_tokens || ["SOL", "SOL_USDC", "HUSTLE", "ETH", "ETH_USDC", "BASE_ETH", "BASE_USDC"]).map((token) => /* @__PURE__ */ jsx("option", { value: token, children: token }, token))
15899
+ }
15900
+ )
15901
+ ] }),
15902
+ /* @__PURE__ */ jsxs("div", { style: { marginTop: tokens.spacing.sm }, children: [
15903
+ /* @__PURE__ */ jsx("label", { style: { ...styles.settingDescription, display: "block", marginBottom: "4px" }, children: "Payment Mode" }),
15904
+ /* @__PURE__ */ jsxs(
15905
+ "select",
15906
+ {
15907
+ value: paygStatus.mode || "pay_per_request",
15908
+ onChange: (e) => configurePayg({ mode: e.target.value }),
15909
+ style: styles.settingSelect,
15910
+ children: [
15911
+ /* @__PURE__ */ jsx("option", { value: "pay_per_request", children: "Pay Per Request" }),
15912
+ /* @__PURE__ */ jsx("option", { value: "debt_accumulation", children: "Debt Accumulation" })
15913
+ ]
15914
+ }
15915
+ )
15916
+ ] }),
15917
+ /* @__PURE__ */ jsxs("div", { style: { marginTop: tokens.spacing.md, padding: tokens.spacing.sm, background: "rgba(255,255,255,0.05)", borderRadius: tokens.radius.sm, fontSize: tokens.typography.fontSizeXs, color: tokens.colors.textSecondary }, children: [
15918
+ /* @__PURE__ */ jsxs("div", { children: [
15919
+ "Chain: ",
15920
+ paygStatus.payment_chain || "N/A"
15921
+ ] }),
15922
+ /* @__PURE__ */ jsxs("div", { children: [
15923
+ "Total Debt: $",
15924
+ (paygStatus.total_debt_usd || 0).toFixed(4)
15925
+ ] }),
15926
+ /* @__PURE__ */ jsxs("div", { children: [
15927
+ "Total Paid: $",
15928
+ (paygStatus.total_paid_usd || 0).toFixed(4)
15929
+ ] }),
15930
+ /* @__PURE__ */ jsxs("div", { children: [
15931
+ "Debt Ceiling: $",
15932
+ (paygStatus.debt_ceiling_usd || 0).toFixed(2)
15933
+ ] }),
15934
+ /* @__PURE__ */ jsxs("div", { children: [
15935
+ "Pending Charges: ",
15936
+ paygStatus.pending_charges || 0
15937
+ ] }),
15938
+ paygStatus.is_blocked && /* @__PURE__ */ jsx("div", { style: { color: "#ef4444", fontWeight: "bold", marginTop: "4px" }, children: "Account is blocked" })
15939
+ ] })
15940
+ ] })
15941
+ ] })
15942
+ ] }),
15943
+ /* @__PURE__ */ jsx("div", { style: styles.settingDivider }),
15834
15944
  /* @__PURE__ */ jsxs("div", { style: { ...styles.settingGroup, marginBottom: 0 }, children: [
15835
15945
  /* @__PURE__ */ jsx("label", { style: styles.settingLabel, children: "Plugins" }),
15836
15946
  /* @__PURE__ */ jsx("p", { style: styles.settingDescription, children: "Extend the AI with custom tools" }),