@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.
@@ -3745,6 +3745,9 @@ function HustleChat({
3745
3745
  }
3746
3746
  return false;
3747
3747
  });
3748
+ const [paygStatus, setPaygStatus] = react.useState(null);
3749
+ const [paygLoading, setPaygLoading] = react.useState(false);
3750
+ const [paygError, setPaygError] = react.useState(null);
3748
3751
  react.useEffect(() => {
3749
3752
  if (typeof window !== "undefined") {
3750
3753
  localStorage.setItem(`hustle-stt-enabled-${instanceId}`, String(speechToTextEnabled));
@@ -3798,6 +3801,34 @@ function HustleChat({
3798
3801
  const removeAttachment = react.useCallback((index) => {
3799
3802
  setAttachments((prev) => prev.filter((_, i) => i !== index));
3800
3803
  }, []);
3804
+ const fetchPaygStatus = react.useCallback(async () => {
3805
+ if (!client) return;
3806
+ setPaygLoading(true);
3807
+ setPaygError(null);
3808
+ try {
3809
+ const status = await client.getPaygStatus();
3810
+ setPaygStatus(status);
3811
+ } catch (err) {
3812
+ setPaygError(err.message || "Failed to fetch PAYG status");
3813
+ } finally {
3814
+ setPaygLoading(false);
3815
+ }
3816
+ }, [client]);
3817
+ const configurePayg = react.useCallback(async (options) => {
3818
+ if (!client) return;
3819
+ setPaygError(null);
3820
+ try {
3821
+ await client.configurePayg(options);
3822
+ await fetchPaygStatus();
3823
+ } catch (err) {
3824
+ setPaygError(err.message || "Failed to configure PAYG");
3825
+ }
3826
+ }, [client, fetchPaygStatus]);
3827
+ react.useEffect(() => {
3828
+ if (showSettingsPanel && client) {
3829
+ fetchPaygStatus();
3830
+ }
3831
+ }, [showSettingsPanel, client, fetchPaygStatus]);
3801
3832
  const sendContinue = react.useCallback(async () => {
3802
3833
  if (isStreaming || !isReady) return;
3803
3834
  console.log("[AUTO_CONTINUE] Sending continue message...");
@@ -4252,6 +4283,84 @@ function HustleChat({
4252
4283
  /* @__PURE__ */ jsxRuntime.jsx("p", { style: styles.settingDescription, children: "Use your microphone to dictate messages" })
4253
4284
  ] }),
4254
4285
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles.settingDivider }),
4286
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles.settingGroup, children: [
4287
+ /* @__PURE__ */ jsxRuntime.jsx("label", { style: styles.settingLabel, children: "Pay-As-You-Go Billing" }),
4288
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: styles.settingDescription, children: "Manage your PAYG billing configuration" }),
4289
+ paygLoading && !paygStatus && /* @__PURE__ */ jsxRuntime.jsx("p", { style: { ...styles.settingDescription, fontStyle: "italic" }, children: "Loading billing status..." }),
4290
+ paygError && /* @__PURE__ */ jsxRuntime.jsx("p", { style: { ...styles.settingDescription, color: "#ef4444" }, children: paygError }),
4291
+ paygStatus && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4292
+ /* @__PURE__ */ jsxRuntime.jsxs(
4293
+ "div",
4294
+ {
4295
+ style: styles.toggleRow,
4296
+ onClick: () => configurePayg({ enabled: !paygStatus.enabled }),
4297
+ children: [
4298
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles.toggleLabel, children: paygStatus.enabled ? "PAYG Enabled" : "PAYG Disabled" }),
4299
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
4300
+ ...styles.toggleSwitch,
4301
+ ...paygStatus.enabled ? styles.toggleSwitchActive : {}
4302
+ }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
4303
+ ...styles.toggleKnob,
4304
+ ...paygStatus.enabled ? styles.toggleKnobActive : {}
4305
+ } }) })
4306
+ ]
4307
+ }
4308
+ ),
4309
+ paygStatus.enabled && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4310
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginTop: tokens.spacing.sm }, children: [
4311
+ /* @__PURE__ */ jsxRuntime.jsx("label", { style: { ...styles.settingDescription, display: "block", marginBottom: "4px" }, children: "Payment Token" }),
4312
+ /* @__PURE__ */ jsxRuntime.jsx(
4313
+ "select",
4314
+ {
4315
+ value: paygStatus.payment_token || "",
4316
+ onChange: (e) => configurePayg({ payment_token: e.target.value }),
4317
+ style: styles.settingSelect,
4318
+ 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))
4319
+ }
4320
+ )
4321
+ ] }),
4322
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginTop: tokens.spacing.sm }, children: [
4323
+ /* @__PURE__ */ jsxRuntime.jsx("label", { style: { ...styles.settingDescription, display: "block", marginBottom: "4px" }, children: "Payment Mode" }),
4324
+ /* @__PURE__ */ jsxRuntime.jsxs(
4325
+ "select",
4326
+ {
4327
+ value: paygStatus.mode || "pay_per_request",
4328
+ onChange: (e) => configurePayg({ mode: e.target.value }),
4329
+ style: styles.settingSelect,
4330
+ children: [
4331
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "pay_per_request", children: "Pay Per Request" }),
4332
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "debt_accumulation", children: "Debt Accumulation" })
4333
+ ]
4334
+ }
4335
+ )
4336
+ ] }),
4337
+ /* @__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: [
4338
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4339
+ "Chain: ",
4340
+ paygStatus.payment_chain || "N/A"
4341
+ ] }),
4342
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4343
+ "Total Debt: $",
4344
+ (paygStatus.total_debt_usd || 0).toFixed(4)
4345
+ ] }),
4346
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4347
+ "Total Paid: $",
4348
+ (paygStatus.total_paid_usd || 0).toFixed(4)
4349
+ ] }),
4350
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4351
+ "Debt Ceiling: $",
4352
+ (paygStatus.debt_ceiling_usd || 0).toFixed(2)
4353
+ ] }),
4354
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4355
+ "Pending Charges: ",
4356
+ paygStatus.pending_charges || 0
4357
+ ] }),
4358
+ paygStatus.is_blocked && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { color: "#ef4444", fontWeight: "bold", marginTop: "4px" }, children: "Account is blocked" })
4359
+ ] })
4360
+ ] })
4361
+ ] })
4362
+ ] }),
4363
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles.settingDivider }),
4255
4364
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { ...styles.settingGroup, marginBottom: 0 }, children: [
4256
4365
  /* @__PURE__ */ jsxRuntime.jsx("label", { style: styles.settingLabel, children: "Plugins" }),
4257
4366
  /* @__PURE__ */ jsxRuntime.jsx("p", { style: styles.settingDescription, children: "Extend the AI with custom tools" }),