@emblemvault/hustle-react 1.5.7 → 1.5.9

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/index.js CHANGED
@@ -4169,6 +4169,9 @@ function HustleChat({
4169
4169
  }
4170
4170
  return false;
4171
4171
  });
4172
+ const [paygStatus, setPaygStatus] = useState(null);
4173
+ const [paygLoading, setPaygLoading] = useState(false);
4174
+ const [paygError, setPaygError] = useState(null);
4172
4175
  useEffect(() => {
4173
4176
  if (typeof window !== "undefined") {
4174
4177
  localStorage.setItem(`hustle-stt-enabled-${instanceId}`, String(speechToTextEnabled));
@@ -4222,6 +4225,34 @@ function HustleChat({
4222
4225
  const removeAttachment = useCallback((index) => {
4223
4226
  setAttachments((prev) => prev.filter((_, i) => i !== index));
4224
4227
  }, []);
4228
+ const fetchPaygStatus = useCallback(async () => {
4229
+ if (!client) return;
4230
+ setPaygLoading(true);
4231
+ setPaygError(null);
4232
+ try {
4233
+ const status = await client.getPaygStatus();
4234
+ setPaygStatus(status);
4235
+ } catch (err) {
4236
+ setPaygError(err.message || "Failed to fetch PAYG status");
4237
+ } finally {
4238
+ setPaygLoading(false);
4239
+ }
4240
+ }, [client]);
4241
+ const configurePayg = useCallback(async (options) => {
4242
+ if (!client) return;
4243
+ setPaygError(null);
4244
+ try {
4245
+ await client.configurePayg(options);
4246
+ await fetchPaygStatus();
4247
+ } catch (err) {
4248
+ setPaygError(err.message || "Failed to configure PAYG");
4249
+ }
4250
+ }, [client, fetchPaygStatus]);
4251
+ useEffect(() => {
4252
+ if (showSettingsPanel && client) {
4253
+ fetchPaygStatus();
4254
+ }
4255
+ }, [showSettingsPanel, client, fetchPaygStatus]);
4225
4256
  const sendContinue = useCallback(async () => {
4226
4257
  if (isStreaming || !isReady) return;
4227
4258
  console.log("[AUTO_CONTINUE] Sending continue message...");
@@ -4676,6 +4707,84 @@ function HustleChat({
4676
4707
  /* @__PURE__ */ jsx("p", { style: styles.settingDescription, children: "Use your microphone to dictate messages" })
4677
4708
  ] }),
4678
4709
  /* @__PURE__ */ jsx("div", { style: styles.settingDivider }),
4710
+ /* @__PURE__ */ jsxs("div", { style: styles.settingGroup, children: [
4711
+ /* @__PURE__ */ jsx("label", { style: styles.settingLabel, children: "Pay-As-You-Go Billing" }),
4712
+ /* @__PURE__ */ jsx("p", { style: styles.settingDescription, children: "Manage your PAYG billing configuration" }),
4713
+ paygLoading && !paygStatus && /* @__PURE__ */ jsx("p", { style: { ...styles.settingDescription, fontStyle: "italic" }, children: "Loading billing status..." }),
4714
+ paygError && /* @__PURE__ */ jsx("p", { style: { ...styles.settingDescription, color: "#ef4444" }, children: paygError }),
4715
+ paygStatus && /* @__PURE__ */ jsxs(Fragment, { children: [
4716
+ /* @__PURE__ */ jsxs(
4717
+ "div",
4718
+ {
4719
+ style: styles.toggleRow,
4720
+ onClick: () => configurePayg({ enabled: !paygStatus.enabled }),
4721
+ children: [
4722
+ /* @__PURE__ */ jsx("span", { style: styles.toggleLabel, children: paygStatus.enabled ? "PAYG Enabled" : "PAYG Disabled" }),
4723
+ /* @__PURE__ */ jsx("div", { style: {
4724
+ ...styles.toggleSwitch,
4725
+ ...paygStatus.enabled ? styles.toggleSwitchActive : {}
4726
+ }, children: /* @__PURE__ */ jsx("div", { style: {
4727
+ ...styles.toggleKnob,
4728
+ ...paygStatus.enabled ? styles.toggleKnobActive : {}
4729
+ } }) })
4730
+ ]
4731
+ }
4732
+ ),
4733
+ paygStatus.enabled && /* @__PURE__ */ jsxs(Fragment, { children: [
4734
+ /* @__PURE__ */ jsxs("div", { style: { marginTop: tokens.spacing.sm }, children: [
4735
+ /* @__PURE__ */ jsx("label", { style: { ...styles.settingDescription, display: "block", marginBottom: "4px" }, children: "Payment Token" }),
4736
+ /* @__PURE__ */ jsx(
4737
+ "select",
4738
+ {
4739
+ value: paygStatus.payment_token || "",
4740
+ onChange: (e) => configurePayg({ payment_token: e.target.value }),
4741
+ style: styles.settingSelect,
4742
+ 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))
4743
+ }
4744
+ )
4745
+ ] }),
4746
+ /* @__PURE__ */ jsxs("div", { style: { marginTop: tokens.spacing.sm }, children: [
4747
+ /* @__PURE__ */ jsx("label", { style: { ...styles.settingDescription, display: "block", marginBottom: "4px" }, children: "Payment Mode" }),
4748
+ /* @__PURE__ */ jsxs(
4749
+ "select",
4750
+ {
4751
+ value: paygStatus.mode || "pay_per_request",
4752
+ onChange: (e) => configurePayg({ mode: e.target.value }),
4753
+ style: styles.settingSelect,
4754
+ children: [
4755
+ /* @__PURE__ */ jsx("option", { value: "pay_per_request", children: "Pay Per Request" }),
4756
+ /* @__PURE__ */ jsx("option", { value: "debt_accumulation", children: "Debt Accumulation" })
4757
+ ]
4758
+ }
4759
+ )
4760
+ ] }),
4761
+ /* @__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: [
4762
+ /* @__PURE__ */ jsxs("div", { children: [
4763
+ "Chain: ",
4764
+ paygStatus.payment_chain || "N/A"
4765
+ ] }),
4766
+ /* @__PURE__ */ jsxs("div", { children: [
4767
+ "Total Debt: $",
4768
+ (paygStatus.total_debt_usd || 0).toFixed(4)
4769
+ ] }),
4770
+ /* @__PURE__ */ jsxs("div", { children: [
4771
+ "Total Paid: $",
4772
+ (paygStatus.total_paid_usd || 0).toFixed(4)
4773
+ ] }),
4774
+ /* @__PURE__ */ jsxs("div", { children: [
4775
+ "Debt Ceiling: $",
4776
+ (paygStatus.debt_ceiling_usd || 0).toFixed(2)
4777
+ ] }),
4778
+ /* @__PURE__ */ jsxs("div", { children: [
4779
+ "Pending Charges: ",
4780
+ paygStatus.pending_charges || 0
4781
+ ] }),
4782
+ paygStatus.is_blocked && /* @__PURE__ */ jsx("div", { style: { color: "#ef4444", fontWeight: "bold", marginTop: "4px" }, children: "Account is blocked" })
4783
+ ] })
4784
+ ] })
4785
+ ] })
4786
+ ] }),
4787
+ /* @__PURE__ */ jsx("div", { style: styles.settingDivider }),
4679
4788
  /* @__PURE__ */ jsxs("div", { style: { ...styles.settingGroup, marginBottom: 0 }, children: [
4680
4789
  /* @__PURE__ */ jsx("label", { style: styles.settingLabel, children: "Plugins" }),
4681
4790
  /* @__PURE__ */ jsx("p", { style: styles.settingDescription, children: "Extend the AI with custom tools" }),