@howone/sdk 0.3.12 → 0.3.15

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.d.mts CHANGED
@@ -875,16 +875,25 @@ declare function createClient(opts: {
875
875
  * @example
876
876
  * ```typescript
877
877
  * const result = await client.sse.request.post({
878
- * workflowId: 'workflow-id',
879
- * inputs: { prompt: 'Generate story' },
880
- * onNodeStart: (name) => console.log(`执行: ${name}`),
881
- * onStreamContent: (delta) => console.log(`内容: ${delta}`),
882
- * onCostUpdate: (stats) => console.log(`Token: ${stats.totalToken}`)
878
+ * workflowId: 'd27e7fbd-651a-4ff1-ae44-a220cb3b0522',
879
+ * inputs: {
880
+ * source_file_url: fileUrl,
881
+ * analysis_depth: 'standard',
882
+ * },
883
+ * onNodeStart: (name) => console.log(`执行节点: ${name}`),
884
+ * onStreamContent: (delta) => console.log(`内容片段: ${delta}`),
885
+ * onCostUpdate: (stats) => console.log(`累计 Token: ${stats.totalToken}`)
883
886
  * })
884
887
  *
885
888
  * // 也可以获取流式控制:
886
- * const session = client.sse.stream.post({ workflowId, inputs: {...} })
887
- * const events = client.sse.events.post({ workflowId, inputs: {...} })
889
+ * const session = client.sse.stream.post({
890
+ * workflowId: 'd27e7fbd-651a-4ff1-ae44-a220cb3b0522',
891
+ * inputs: { source_file_url: fileUrl, analysis_depth: 'standard' },
892
+ * })
893
+ * const events = client.sse.events.post({
894
+ * workflowId: 'd27e7fbd-651a-4ff1-ae44-a220cb3b0522',
895
+ * inputs: { source_file_url: fileUrl, analysis_depth: 'standard' },
896
+ * })
888
897
  * ```
889
898
  */
890
899
  sseRequest: LegacySSERequest;
package/dist/index.d.ts CHANGED
@@ -875,16 +875,25 @@ declare function createClient(opts: {
875
875
  * @example
876
876
  * ```typescript
877
877
  * const result = await client.sse.request.post({
878
- * workflowId: 'workflow-id',
879
- * inputs: { prompt: 'Generate story' },
880
- * onNodeStart: (name) => console.log(`执行: ${name}`),
881
- * onStreamContent: (delta) => console.log(`内容: ${delta}`),
882
- * onCostUpdate: (stats) => console.log(`Token: ${stats.totalToken}`)
878
+ * workflowId: 'd27e7fbd-651a-4ff1-ae44-a220cb3b0522',
879
+ * inputs: {
880
+ * source_file_url: fileUrl,
881
+ * analysis_depth: 'standard',
882
+ * },
883
+ * onNodeStart: (name) => console.log(`执行节点: ${name}`),
884
+ * onStreamContent: (delta) => console.log(`内容片段: ${delta}`),
885
+ * onCostUpdate: (stats) => console.log(`累计 Token: ${stats.totalToken}`)
883
886
  * })
884
887
  *
885
888
  * // 也可以获取流式控制:
886
- * const session = client.sse.stream.post({ workflowId, inputs: {...} })
887
- * const events = client.sse.events.post({ workflowId, inputs: {...} })
889
+ * const session = client.sse.stream.post({
890
+ * workflowId: 'd27e7fbd-651a-4ff1-ae44-a220cb3b0522',
891
+ * inputs: { source_file_url: fileUrl, analysis_depth: 'standard' },
892
+ * })
893
+ * const events = client.sse.events.post({
894
+ * workflowId: 'd27e7fbd-651a-4ff1-ae44-a220cb3b0522',
895
+ * inputs: { source_file_url: fileUrl, analysis_depth: 'standard' },
896
+ * })
888
897
  * ```
889
898
  */
890
899
  sseRequest: LegacySSERequest;
package/dist/index.js CHANGED
@@ -1352,6 +1352,23 @@ var injectRedirectOverlayStyles = () => {
1352
1352
  transform: scale(1.05);
1353
1353
  }
1354
1354
  }
1355
+
1356
+ [data-howone-auth-overlay-root] {
1357
+ position: fixed;
1358
+ inset: 0;
1359
+ z-index: 2147483646;
1360
+ display: flex;
1361
+ flex-direction: column;
1362
+ align-items: center;
1363
+ justify-content: center;
1364
+ width: 100vw;
1365
+ height: 100vh;
1366
+ color: #ffffff;
1367
+ background: rgba(0, 0, 0, 0.65);
1368
+ backdrop-filter: blur(6px);
1369
+ -webkit-backdrop-filter: blur(6px);
1370
+ text-align: center;
1371
+ }
1355
1372
  `;
1356
1373
  document.head.appendChild(style);
1357
1374
  redirectOverlayStylesInjected = true;
@@ -1418,14 +1435,32 @@ var HowOneProvider = ({
1418
1435
  }, [pendingRedirect]);
1419
1436
  const redirectToAuth = (0, import_react8.useCallback)(() => {
1420
1437
  if (!redirectOnUnauthenticated || typeof window === "undefined") return;
1438
+ const activeProjectId = projectId ?? getDefaultProjectId();
1439
+ const navigateToResolvedAuth = () => {
1440
+ setPendingRedirect(true);
1441
+ requestAnimationFrame(() => {
1442
+ if (activeProjectId) {
1443
+ try {
1444
+ const url = new URL(resolvedAuthUrl);
1445
+ url.searchParams.set("redirect_uri", window.location.href);
1446
+ url.searchParams.set("project_id", activeProjectId);
1447
+ window.location.href = url.toString();
1448
+ return;
1449
+ } catch (error) {
1450
+ console.error("[HowOneProvider] Failed to attach project_id to auth URL:", error);
1451
+ }
1452
+ }
1453
+ window.location.href = resolvedAuthUrl;
1454
+ });
1455
+ };
1421
1456
  try {
1422
1457
  const currentUrl = new URL(window.location.href);
1423
1458
  if (currentUrl.pathname.includes("/auth")) return;
1424
1459
  try {
1425
1460
  const authUrlObj = new URL(resolvedAuthUrl);
1426
1461
  authUrlObj.searchParams.set("redirect_uri", window.location.href);
1427
- if (projectId) {
1428
- authUrlObj.searchParams.set("project_id", projectId);
1462
+ if (activeProjectId) {
1463
+ authUrlObj.searchParams.set("project_id", activeProjectId);
1429
1464
  }
1430
1465
  setPendingRedirect(true);
1431
1466
  requestAnimationFrame(() => {
@@ -1435,15 +1470,9 @@ var HowOneProvider = ({
1435
1470
  } catch (error) {
1436
1471
  console.error("[HowOneProvider] Failed to build auth URL:", error);
1437
1472
  }
1438
- setPendingRedirect(true);
1439
- requestAnimationFrame(() => {
1440
- window.location.href = resolvedAuthUrl;
1441
- });
1473
+ navigateToResolvedAuth();
1442
1474
  } catch {
1443
- setPendingRedirect(true);
1444
- requestAnimationFrame(() => {
1445
- window.location.href = resolvedAuthUrl;
1446
- });
1475
+ navigateToResolvedAuth();
1447
1476
  }
1448
1477
  }, [redirectOnUnauthenticated, resolvedAuthUrl, projectId]);
1449
1478
  (0, import_react8.useEffect)(() => {
@@ -1478,24 +1507,31 @@ var HowOneProvider = ({
1478
1507
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ElementSelectorProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(HowoneContext.Provider, { value, children: [
1479
1508
  children,
1480
1509
  showFloatingButton && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FloatingButton, { onClick: () => window.open("https://howone.ai", "_blank") }),
1481
- pendingRedirect && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "fixed inset-0 z-[100000] h-full w-full flex flex-col items-center justify-center bg-black/65 backdrop-blur-sm text-white", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "relative mt-6 flex h-[220px] w-[220px] items-center justify-center", children: [
1482
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1483
- "div",
1484
- {
1485
- className: "absolute inset-0 rounded-full bg-white/20",
1486
- style: { animation: "howone-glow-ring 2.4s ease-in-out infinite" }
1487
- }
1488
- ),
1489
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "absolute inset-0 rounded-full bg-gradient-to-br from-white/10 via-white/25 to-white/10 blur-2xl" }),
1490
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1491
- "img",
1492
- {
1493
- style: { width: 250, animation: "howone-logo-pulse 2s ease-in-out infinite" },
1494
- src: "https://sxwxqoixnnklnpeutjrj.supabase.co/storage/v1/object/public/create-x/logo/logo.svg",
1495
- alt: "HowOne"
1496
- }
1497
- )
1498
- ] }) })
1510
+ pendingRedirect && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1511
+ "div",
1512
+ {
1513
+ "data-howone-auth-overlay-root": true,
1514
+ className: "fixed inset-0 z-[100000] h-full w-full flex flex-col items-center justify-center bg-black/65 backdrop-blur-sm text-white",
1515
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "relative mt-6 flex h-[220px] w-[220px] items-center justify-center", children: [
1516
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1517
+ "div",
1518
+ {
1519
+ className: "absolute inset-0 rounded-full bg-white/20",
1520
+ style: { animation: "howone-glow-ring 2.4s ease-in-out infinite" }
1521
+ }
1522
+ ),
1523
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "absolute inset-0 rounded-full bg-gradient-to-br from-white/10 via-white/25 to-white/10 blur-2xl" }),
1524
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1525
+ "img",
1526
+ {
1527
+ style: { width: 250, animation: "howone-logo-pulse 2s ease-in-out infinite" },
1528
+ src: "https://sxwxqoixnnklnpeutjrj.supabase.co/storage/v1/object/public/create-x/logo/logo.svg",
1529
+ alt: "HowOne"
1530
+ }
1531
+ )
1532
+ ] })
1533
+ }
1534
+ )
1499
1535
  ] }) }),
1500
1536
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(GlobalToastContainer, {})
1501
1537
  ]
@@ -2639,9 +2675,7 @@ function createAIClient(req, projectId) {
2639
2675
  signal
2640
2676
  });
2641
2677
  return {
2642
- imageUrl: response.imageUrl || response.url,
2643
- taskId: response.taskId || response.id,
2644
- metadata: response.metadata
2678
+ imageUrl: response.data.result.imageUrl
2645
2679
  };
2646
2680
  }
2647
2681
  };
@@ -3643,16 +3677,25 @@ function createClient(opts) {
3643
3677
  * @example
3644
3678
  * ```typescript
3645
3679
  * const result = await client.sse.request.post({
3646
- * workflowId: 'workflow-id',
3647
- * inputs: { prompt: 'Generate story' },
3648
- * onNodeStart: (name) => console.log(`执行: ${name}`),
3649
- * onStreamContent: (delta) => console.log(`内容: ${delta}`),
3650
- * onCostUpdate: (stats) => console.log(`Token: ${stats.totalToken}`)
3680
+ * workflowId: 'd27e7fbd-651a-4ff1-ae44-a220cb3b0522',
3681
+ * inputs: {
3682
+ * source_file_url: fileUrl,
3683
+ * analysis_depth: 'standard',
3684
+ * },
3685
+ * onNodeStart: (name) => console.log(`执行节点: ${name}`),
3686
+ * onStreamContent: (delta) => console.log(`内容片段: ${delta}`),
3687
+ * onCostUpdate: (stats) => console.log(`累计 Token: ${stats.totalToken}`)
3651
3688
  * })
3652
3689
  *
3653
3690
  * // 也可以获取流式控制:
3654
- * const session = client.sse.stream.post({ workflowId, inputs: {...} })
3655
- * const events = client.sse.events.post({ workflowId, inputs: {...} })
3691
+ * const session = client.sse.stream.post({
3692
+ * workflowId: 'd27e7fbd-651a-4ff1-ae44-a220cb3b0522',
3693
+ * inputs: { source_file_url: fileUrl, analysis_depth: 'standard' },
3694
+ * })
3695
+ * const events = client.sse.events.post({
3696
+ * workflowId: 'd27e7fbd-651a-4ff1-ae44-a220cb3b0522',
3697
+ * inputs: { source_file_url: fileUrl, analysis_depth: 'standard' },
3698
+ * })
3656
3699
  * ```
3657
3700
  */
3658
3701
  sseRequest: sseRequestWrapped,