@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.cjs CHANGED
@@ -4195,6 +4195,9 @@ function HustleChat({
4195
4195
  }
4196
4196
  return false;
4197
4197
  });
4198
+ const [paygStatus, setPaygStatus] = react.useState(null);
4199
+ const [paygLoading, setPaygLoading] = react.useState(false);
4200
+ const [paygError, setPaygError] = react.useState(null);
4198
4201
  react.useEffect(() => {
4199
4202
  if (typeof window !== "undefined") {
4200
4203
  localStorage.setItem(`hustle-stt-enabled-${instanceId}`, String(speechToTextEnabled));
@@ -4248,6 +4251,34 @@ function HustleChat({
4248
4251
  const removeAttachment = react.useCallback((index) => {
4249
4252
  setAttachments((prev) => prev.filter((_, i) => i !== index));
4250
4253
  }, []);
4254
+ const fetchPaygStatus = react.useCallback(async () => {
4255
+ if (!client) return;
4256
+ setPaygLoading(true);
4257
+ setPaygError(null);
4258
+ try {
4259
+ const status = await client.getPaygStatus();
4260
+ setPaygStatus(status);
4261
+ } catch (err) {
4262
+ setPaygError(err.message || "Failed to fetch PAYG status");
4263
+ } finally {
4264
+ setPaygLoading(false);
4265
+ }
4266
+ }, [client]);
4267
+ const configurePayg = react.useCallback(async (options) => {
4268
+ if (!client) return;
4269
+ setPaygError(null);
4270
+ try {
4271
+ await client.configurePayg(options);
4272
+ await fetchPaygStatus();
4273
+ } catch (err) {
4274
+ setPaygError(err.message || "Failed to configure PAYG");
4275
+ }
4276
+ }, [client, fetchPaygStatus]);
4277
+ react.useEffect(() => {
4278
+ if (showSettingsPanel && client) {
4279
+ fetchPaygStatus();
4280
+ }
4281
+ }, [showSettingsPanel, client, fetchPaygStatus]);
4251
4282
  const sendContinue = react.useCallback(async () => {
4252
4283
  if (isStreaming || !isReady) return;
4253
4284
  console.log("[AUTO_CONTINUE] Sending continue message...");
@@ -4702,6 +4733,84 @@ function HustleChat({
4702
4733
  /* @__PURE__ */ jsxRuntime.jsx("p", { style: styles.settingDescription, children: "Use your microphone to dictate messages" })
4703
4734
  ] }),
4704
4735
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles.settingDivider }),
4736
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles.settingGroup, children: [
4737
+ /* @__PURE__ */ jsxRuntime.jsx("label", { style: styles.settingLabel, children: "Pay-As-You-Go Billing" }),
4738
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: styles.settingDescription, children: "Manage your PAYG billing configuration" }),
4739
+ paygLoading && !paygStatus && /* @__PURE__ */ jsxRuntime.jsx("p", { style: { ...styles.settingDescription, fontStyle: "italic" }, children: "Loading billing status..." }),
4740
+ paygError && /* @__PURE__ */ jsxRuntime.jsx("p", { style: { ...styles.settingDescription, color: "#ef4444" }, children: paygError }),
4741
+ paygStatus && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4742
+ /* @__PURE__ */ jsxRuntime.jsxs(
4743
+ "div",
4744
+ {
4745
+ style: styles.toggleRow,
4746
+ onClick: () => configurePayg({ enabled: !paygStatus.enabled }),
4747
+ children: [
4748
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles.toggleLabel, children: paygStatus.enabled ? "PAYG Enabled" : "PAYG Disabled" }),
4749
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
4750
+ ...styles.toggleSwitch,
4751
+ ...paygStatus.enabled ? styles.toggleSwitchActive : {}
4752
+ }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
4753
+ ...styles.toggleKnob,
4754
+ ...paygStatus.enabled ? styles.toggleKnobActive : {}
4755
+ } }) })
4756
+ ]
4757
+ }
4758
+ ),
4759
+ paygStatus.enabled && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4760
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginTop: tokens.spacing.sm }, children: [
4761
+ /* @__PURE__ */ jsxRuntime.jsx("label", { style: { ...styles.settingDescription, display: "block", marginBottom: "4px" }, children: "Payment Token" }),
4762
+ /* @__PURE__ */ jsxRuntime.jsx(
4763
+ "select",
4764
+ {
4765
+ value: paygStatus.payment_token || "",
4766
+ onChange: (e) => configurePayg({ payment_token: e.target.value }),
4767
+ style: styles.settingSelect,
4768
+ children: (paygStatus.available_tokens || ["SOL", "SOL_USDC", "HUSTLE", "ETH", "ETH_USDC", "BASE_ETH", "BASE_USDC"]).map((token) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: token, children: token }, token))
4769
+ }
4770
+ )
4771
+ ] }),
4772
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginTop: tokens.spacing.sm }, children: [
4773
+ /* @__PURE__ */ jsxRuntime.jsx("label", { style: { ...styles.settingDescription, display: "block", marginBottom: "4px" }, children: "Payment Mode" }),
4774
+ /* @__PURE__ */ jsxRuntime.jsxs(
4775
+ "select",
4776
+ {
4777
+ value: paygStatus.mode || "pay_per_request",
4778
+ onChange: (e) => configurePayg({ mode: e.target.value }),
4779
+ style: styles.settingSelect,
4780
+ children: [
4781
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "pay_per_request", children: "Pay Per Request" }),
4782
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "debt_accumulation", children: "Debt Accumulation" })
4783
+ ]
4784
+ }
4785
+ )
4786
+ ] }),
4787
+ /* @__PURE__ */ jsxRuntime.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: [
4788
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4789
+ "Chain: ",
4790
+ paygStatus.payment_chain || "N/A"
4791
+ ] }),
4792
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4793
+ "Total Debt: $",
4794
+ (paygStatus.total_debt_usd || 0).toFixed(4)
4795
+ ] }),
4796
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4797
+ "Total Paid: $",
4798
+ (paygStatus.total_paid_usd || 0).toFixed(4)
4799
+ ] }),
4800
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4801
+ "Debt Ceiling: $",
4802
+ (paygStatus.debt_ceiling_usd || 0).toFixed(2)
4803
+ ] }),
4804
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4805
+ "Pending Charges: ",
4806
+ paygStatus.pending_charges || 0
4807
+ ] }),
4808
+ paygStatus.is_blocked && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { color: "#ef4444", fontWeight: "bold", marginTop: "4px" }, children: "Account is blocked" })
4809
+ ] })
4810
+ ] })
4811
+ ] })
4812
+ ] }),
4813
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles.settingDivider }),
4705
4814
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { ...styles.settingGroup, marginBottom: 0 }, children: [
4706
4815
  /* @__PURE__ */ jsxRuntime.jsx("label", { style: styles.settingLabel, children: "Plugins" }),
4707
4816
  /* @__PURE__ */ jsxRuntime.jsx("p", { style: styles.settingDescription, children: "Extend the AI with custom tools" }),