@graph8/sdk 0.7.1 → 0.11.0

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
@@ -67,6 +67,21 @@ var createFormsClient = (writeKey, apiUrl) => {
67
67
 
68
68
  // src/utils.ts
69
69
  var isServer = typeof window === "undefined";
70
+ var resolveAppBaseUrl = (apiBaseUrl) => {
71
+ try {
72
+ const url = new URL(apiBaseUrl);
73
+ if (url.hostname === "localhost" || url.hostname === "127.0.0.1") {
74
+ url.port = "3000";
75
+ return url.origin;
76
+ }
77
+ if (url.hostname.endsWith("graph8.com")) {
78
+ url.hostname = url.hostname.replace(/^be\./, "app.");
79
+ return url.origin;
80
+ }
81
+ } catch {
82
+ }
83
+ return apiBaseUrl;
84
+ };
70
85
 
71
86
  // src/visitors.ts
72
87
  var DEFAULT_API2 = "https://be.graph8.com";
@@ -179,6 +194,7 @@ var createCopilotClient = (writeKey, apiUrl) => {
179
194
  var DEFAULT_API4 = "https://be.graph8.com";
180
195
  var createChatClient = (writeKey, apiUrl) => {
181
196
  const baseUrl = apiUrl || DEFAULT_API4;
197
+ const appUrl = resolveAppBaseUrl(baseUrl);
182
198
  const listeners = /* @__PURE__ */ new Map();
183
199
  let widgetEl = null;
184
200
  let ws = null;
@@ -193,7 +209,7 @@ var createChatClient = (writeKey, apiUrl) => {
193
209
  const position = config?.position || "bottom-right";
194
210
  const posStyle = position === "bottom-left" ? "left:16px;" : "right:16px;";
195
211
  const iframe = document.createElement("iframe");
196
- iframe.src = `${baseUrl}/webchat/embed?write_key=${writeKey}&theme=${config?.theme || "auto"}`;
212
+ iframe.src = `${appUrl}/webchat/embed?write_key=${writeKey}&theme=${config?.theme || "auto"}`;
197
213
  iframe.style.cssText = `position:fixed;bottom:16px;${posStyle}width:380px;height:560px;border:none;border-radius:12px;box-shadow:0 8px 32px rgba(0,0,0,0.15);z-index:99997;`;
198
214
  iframe.id = "g8-chat-widget";
199
215
  document.body.appendChild(iframe);
@@ -318,6 +334,19 @@ var G8Error = class _G8Error extends Error {
318
334
  function isRetryableStatus(status) {
319
335
  return status === 429 || status >= 500 && status <= 599;
320
336
  }
337
+ function isNonIdempotentMethod(method) {
338
+ const m = method.toUpperCase();
339
+ return m === "POST" || m === "PATCH";
340
+ }
341
+ function newIdempotencyKey() {
342
+ const c = globalThis.crypto;
343
+ if (c?.randomUUID) return c.randomUUID();
344
+ if (c?.getRandomValues) {
345
+ const bytes = c.getRandomValues(new Uint8Array(16));
346
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
347
+ }
348
+ return `g8-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
349
+ }
321
350
  function parseRetryAfter(header, nowMs = Date.now()) {
322
351
  if (!header) return null;
323
352
  const secs = Number(header);
@@ -384,7 +413,8 @@ async function request(baseUrl, path, apiKey, opts = {}) {
384
413
  Authorization: `Bearer ${apiKey}`,
385
414
  ...headers
386
415
  };
387
- if (idempotencyKey) finalHeaders["Idempotency-Key"] = idempotencyKey;
416
+ const effectiveIdempotencyKey = idempotencyKey ?? (maxRetries > 0 && isNonIdempotentMethod(method) ? newIdempotencyKey() : void 0);
417
+ if (effectiveIdempotencyKey) finalHeaders["Idempotency-Key"] = effectiveIdempotencyKey;
388
418
  let attempt = 0;
389
419
  for (; ; ) {
390
420
  let resp;
@@ -462,7 +492,7 @@ var createEnrichClient = (apiKey, apiUrl) => {
462
492
  });
463
493
  return resp.data ?? resp;
464
494
  },
465
- /** Search 300M+ contacts with filters. Credits charged per result. */
495
+ /** Search 700M+ contacts with filters. Credits charged per result. */
466
496
  async search(filters, page = 1, limit = 25) {
467
497
  const resp = await request(baseUrl, "/api/v1/search/contacts", apiKey, {
468
498
  method: "POST",
@@ -503,21 +533,30 @@ var createSequencesClient = (apiKey, apiUrl) => {
503
533
  query: params
504
534
  });
505
535
  },
506
- /** Add contacts to a sequence (V2 queuing). Live or drafted sequences only. */
507
- async add(config) {
536
+ /**
537
+ * Add contacts to a sequence (V2 queuing). Live or drafted sequences only.
538
+ * Pass `idempotencyKey` to make a retry safe — the same key returns the
539
+ * first result instead of re-enrolling on a 5xx-then-success (A6).
540
+ */
541
+ async add(config, idempotencyKey) {
508
542
  const resp = await request(
509
543
  baseUrl,
510
544
  `/api/v1/sequences/${config.sequenceId}/contacts`,
511
545
  apiKey,
512
- { method: "POST", body: { contact_ids: config.contactIds, list_id: config.listId } }
546
+ { method: "POST", body: { contact_ids: config.contactIds, list_id: config.listId }, idempotencyKey }
513
547
  );
514
548
  return resp.data ?? resp;
515
549
  },
516
- /** Create a new sequence with optional steps + channels. */
517
- async create(payload) {
550
+ /**
551
+ * Create a new sequence with optional steps + channels. Pass `idempotencyKey`
552
+ * to make a retry safe — the same key returns the first result instead of
553
+ * creating a duplicate sequence on a 5xx-then-success (A6).
554
+ */
555
+ async create(payload, idempotencyKey) {
518
556
  const resp = await request(baseUrl, "/api/v1/sequences", apiKey, {
519
557
  method: "POST",
520
- body: payload
558
+ body: payload,
559
+ idempotencyKey
521
560
  });
522
561
  return resp.data ?? resp;
523
562
  },
@@ -546,33 +585,43 @@ var createSequencesClient = (apiKey, apiUrl) => {
546
585
  });
547
586
  return resp.data ?? resp;
548
587
  },
549
- /** Run/start a DRAFTED sequence (V2 orchestration). */
550
- async run(sequenceId) {
588
+ /**
589
+ * Run/start a DRAFTED sequence (V2 orchestration). Pass `idempotencyKey` to
590
+ * make a retry safe — the same key won't re-trigger the run on a
591
+ * 5xx-then-success (A6).
592
+ */
593
+ async run(sequenceId, idempotencyKey) {
551
594
  const resp = await request(
552
595
  baseUrl,
553
596
  `/api/v1/sequences/${sequenceId}/run`,
554
597
  apiKey,
555
- { method: "POST" }
598
+ { method: "POST", idempotencyKey }
556
599
  );
557
600
  return resp.data ?? resp;
558
601
  },
559
- /** Pause a live sequence. */
560
- async pause(sequenceId) {
602
+ /**
603
+ * Pause a live sequence. Pass `idempotencyKey` to make a retry safe — the
604
+ * same key won't double-apply on a 5xx-then-success (A6).
605
+ */
606
+ async pause(sequenceId, idempotencyKey) {
561
607
  const resp = await request(
562
608
  baseUrl,
563
609
  `/api/v1/sequences/${sequenceId}/pause`,
564
610
  apiKey,
565
- { method: "POST" }
611
+ { method: "POST", idempotencyKey }
566
612
  );
567
613
  return resp.data ?? resp;
568
614
  },
569
- /** Resume a paused sequence. */
570
- async resume(sequenceId) {
615
+ /**
616
+ * Resume a paused sequence. Pass `idempotencyKey` to make a retry safe — the
617
+ * same key won't double-apply on a 5xx-then-success (A6).
618
+ */
619
+ async resume(sequenceId, idempotencyKey) {
571
620
  const resp = await request(
572
621
  baseUrl,
573
622
  `/api/v1/sequences/${sequenceId}/resume`,
574
623
  apiKey,
575
- { method: "POST" }
624
+ { method: "POST", idempotencyKey }
576
625
  );
577
626
  return resp.data ?? resp;
578
627
  },
@@ -616,45 +665,23 @@ var createCampaignsClient = (apiKey, apiUrl) => {
616
665
  return resp.data ?? resp;
617
666
  },
618
667
  async launch(campaignId) {
619
- await request(baseUrl, `/api/v1/campaigns/${campaignId}/launch`, apiKey, { method: "POST" });
620
- },
621
- async stats(campaignId) {
622
- const resp = await request(baseUrl, `/api/v1/campaigns/${campaignId}/stats`, apiKey);
623
- return resp.data ?? resp;
624
- }
625
- };
626
- };
627
-
628
- // src/integrations.ts
629
- var DEFAULT_API9 = "https://be.graph8.com";
630
- var createIntegrationsClient = (apiKey, apiUrl) => {
631
- const baseUrl = apiUrl || DEFAULT_API9;
632
- return {
633
- async list() {
634
- const resp = await request(baseUrl, "/api/v1/integrations", apiKey);
668
+ const resp = await request(
669
+ baseUrl,
670
+ `/api/v1/campaigns/${campaignId}/launch`,
671
+ apiKey,
672
+ { method: "POST" }
673
+ );
635
674
  return resp.data ?? resp;
636
- },
637
- async connect(provider, config) {
638
- await request(baseUrl, "/api/v1/integrations/connect", apiKey, {
639
- method: "POST",
640
- body: { provider, ...config }
641
- });
642
- },
643
- async sync(provider, config) {
644
- await request(baseUrl, "/api/v1/integrations/sync", apiKey, {
645
- method: "POST",
646
- body: { provider, ...config }
647
- });
648
675
  }
649
676
  };
650
677
  };
651
678
 
652
679
  // src/signals.ts
653
- var DEFAULT_API10 = "https://be.graph8.com";
680
+ var DEFAULT_API9 = "https://be.graph8.com";
654
681
  var createSignalsClient = (key, isApiKey, apiUrl) => {
655
- const baseUrl = apiUrl || DEFAULT_API10;
682
+ const baseUrl = apiUrl || DEFAULT_API9;
656
683
  const headers = () => isApiKey ? { "Content-Type": "application/json", "Authorization": `Bearer ${key}` } : { "Content-Type": "application/json", "X-Write-Key": key };
657
- const endpoint = isApiKey ? "/api/v1/signals/company" : "/api/v1/public/signals/company";
684
+ const endpoint = "/api/v1/public/signals/company";
658
685
  return {
659
686
  /** Get intent signals for a specific company domain. */
660
687
  async company(domain) {
@@ -679,24 +706,10 @@ var createSignalsClient = (key, isApiKey, apiUrl) => {
679
706
  };
680
707
  };
681
708
 
682
- // src/analytics.ts
683
- var DEFAULT_API11 = "https://be.graph8.com";
684
- var createAnalyticsClient = (apiKey, apiUrl) => {
685
- const baseUrl = apiUrl || DEFAULT_API11;
686
- return {
687
- async overview(config) {
688
- const resp = await request(baseUrl, "/api/v1/analytics/overview", apiKey, {
689
- query: { period: config?.period }
690
- });
691
- return resp.data ?? resp;
692
- }
693
- };
694
- };
695
-
696
709
  // src/voice.ts
697
- var DEFAULT_API12 = "https://be.graph8.com";
710
+ var DEFAULT_API10 = "https://be.graph8.com";
698
711
  var createVoiceClient = (apiKey, apiUrl) => {
699
- const baseUrl = apiUrl || DEFAULT_API12;
712
+ const baseUrl = apiUrl || DEFAULT_API10;
700
713
  const listeners = /* @__PURE__ */ new Map();
701
714
  const dialer = {
702
715
  /** List parallel-dialer sessions with filters + pagination. */
@@ -829,31 +842,6 @@ var createVoiceClient = (apiKey, apiUrl) => {
829
842
  }
830
843
  };
831
844
  return {
832
- /**
833
- * Start an AI voice session.
834
- * @deprecated Preview surface — for parallel-dialer flows use `voice.dialer.createSession()`.
835
- */
836
- async start(config) {
837
- const resp = await request(
838
- baseUrl,
839
- "/api/v1/voice/sessions",
840
- apiKey,
841
- { method: "POST", body: config }
842
- );
843
- return resp.data ?? resp;
844
- },
845
- /**
846
- * Get call analysis for a completed session.
847
- * @deprecated Preview surface — for dialer-call grading use `voice.dialer.callGrading(roomName)`.
848
- */
849
- async analysis(sessionId) {
850
- const resp = await request(
851
- baseUrl,
852
- `/api/v1/voice/sessions/${sessionId}/analysis`,
853
- apiKey
854
- );
855
- return resp.data ?? resp;
856
- },
857
845
  /** Listen for voice events. */
858
846
  on(event, callback) {
859
847
  if (!listeners.has(event)) listeners.set(event, []);
@@ -864,43 +852,9 @@ var createVoiceClient = (apiKey, apiUrl) => {
864
852
  };
865
853
  };
866
854
 
867
- // src/pages.ts
868
- var DEFAULT_API13 = "https://be.graph8.com";
869
- var createPagesClient = (apiKey, apiUrl) => {
870
- const baseUrl = apiUrl || DEFAULT_API13;
871
- return {
872
- /** Clone a landing page from any URL. */
873
- async clone(url) {
874
- const resp = await request(baseUrl, "/api/v1/landing-pages/clone-url", apiKey, {
875
- method: "POST",
876
- body: { url }
877
- });
878
- return resp.data ?? resp;
879
- },
880
- /** Create a landing page from a template. */
881
- async create(config) {
882
- const resp = await request(baseUrl, "/api/v1/landing-pages", apiKey, {
883
- method: "POST",
884
- body: config
885
- });
886
- return resp.data ?? resp;
887
- },
888
- /** Publish a landing page to CDN. */
889
- async publish(pageId) {
890
- const data = await request(
891
- baseUrl,
892
- `/api/v1/landing-pages/${pageId}/publish`,
893
- apiKey,
894
- { method: "POST" }
895
- );
896
- return { url: data.published_url || data.data?.published_url || "" };
897
- }
898
- };
899
- };
900
-
901
855
  // src/webhooks.ts
902
856
  var import_node_crypto = require("crypto");
903
- var DEFAULT_API14 = "https://be.graph8.com";
857
+ var DEFAULT_API11 = "https://be.graph8.com";
904
858
  var KNOWN_WEBHOOK_EVENTS = [
905
859
  "campaign.created",
906
860
  "campaign.updated",
@@ -918,7 +872,7 @@ var KNOWN_WEBHOOK_EVENTS = [
918
872
  "company_intelligence.completed",
919
873
  "audience.ready",
920
874
  "audience.failed",
921
- "sequence.deployed",
875
+ "sequence.draft_created",
922
876
  "sequence.started",
923
877
  "sequence.paused",
924
878
  "sequence.completed",
@@ -981,7 +935,7 @@ function constructEvent(payload, signature, timestamp, secret, opts = {}) {
981
935
  }
982
936
  }
983
937
  var createWebhooksClient = (_apiKey, apiUrl) => {
984
- const baseUrl = apiUrl || DEFAULT_API14;
938
+ const baseUrl = apiUrl || DEFAULT_API11;
985
939
  return {
986
940
  /** Base URL the webhook subscription API lives under. */
987
941
  baseUrl,
@@ -995,9 +949,9 @@ var createWebhooksClient = (_apiKey, apiUrl) => {
995
949
  };
996
950
 
997
951
  // src/contacts.ts
998
- var DEFAULT_API15 = "https://be.graph8.com";
952
+ var DEFAULT_API12 = "https://be.graph8.com";
999
953
  var createContactsClient = (apiKey, apiUrl) => {
1000
- const baseUrl = apiUrl || DEFAULT_API15;
954
+ const baseUrl = apiUrl || DEFAULT_API12;
1001
955
  return {
1002
956
  /** List contacts with optional filters. */
1003
957
  async list(params = {}) {
@@ -1056,9 +1010,9 @@ var createContactsClient = (apiKey, apiUrl) => {
1056
1010
  };
1057
1011
 
1058
1012
  // src/companies.ts
1059
- var DEFAULT_API16 = "https://be.graph8.com";
1013
+ var DEFAULT_API13 = "https://be.graph8.com";
1060
1014
  var createCompaniesClient = (apiKey, apiUrl) => {
1061
- const baseUrl = apiUrl || DEFAULT_API16;
1015
+ const baseUrl = apiUrl || DEFAULT_API13;
1062
1016
  return {
1063
1017
  /** List companies with optional filters. */
1064
1018
  async list(params = {}) {
@@ -1104,9 +1058,9 @@ var createCompaniesClient = (apiKey, apiUrl) => {
1104
1058
  };
1105
1059
 
1106
1060
  // src/lists.ts
1107
- var DEFAULT_API17 = "https://be.graph8.com";
1061
+ var DEFAULT_API14 = "https://be.graph8.com";
1108
1062
  var createListsClient = (apiKey, apiUrl) => {
1109
- const baseUrl = apiUrl || DEFAULT_API17;
1063
+ const baseUrl = apiUrl || DEFAULT_API14;
1110
1064
  return {
1111
1065
  /** List all lists. */
1112
1066
  async list(page = 1, limit = 50) {
@@ -1146,9 +1100,9 @@ var createListsClient = (apiKey, apiUrl) => {
1146
1100
  };
1147
1101
 
1148
1102
  // src/notes.ts
1149
- var DEFAULT_API18 = "https://be.graph8.com";
1103
+ var DEFAULT_API15 = "https://be.graph8.com";
1150
1104
  var createNotesClient = (apiKey, apiUrl) => {
1151
- const baseUrl = apiUrl || DEFAULT_API18;
1105
+ const baseUrl = apiUrl || DEFAULT_API15;
1152
1106
  return {
1153
1107
  /** List all notes on a contact. */
1154
1108
  async list(contactId) {
@@ -1178,9 +1132,9 @@ var createNotesClient = (apiKey, apiUrl) => {
1178
1132
  };
1179
1133
 
1180
1134
  // src/tasks.ts
1181
- var DEFAULT_API19 = "https://be.graph8.com";
1135
+ var DEFAULT_API16 = "https://be.graph8.com";
1182
1136
  var createTasksClient = (apiKey, apiUrl) => {
1183
- const baseUrl = apiUrl || DEFAULT_API19;
1137
+ const baseUrl = apiUrl || DEFAULT_API16;
1184
1138
  return {
1185
1139
  /** List tasks on a single contact. Optional status filter ("open" | "completed"). */
1186
1140
  async listForContact(contactId, status) {
@@ -1216,9 +1170,9 @@ var createTasksClient = (apiKey, apiUrl) => {
1216
1170
  };
1217
1171
 
1218
1172
  // src/fields.ts
1219
- var DEFAULT_API20 = "https://be.graph8.com";
1173
+ var DEFAULT_API17 = "https://be.graph8.com";
1220
1174
  var createFieldsClient = (apiKey, apiUrl) => {
1221
- const baseUrl = apiUrl || DEFAULT_API20;
1175
+ const baseUrl = apiUrl || DEFAULT_API17;
1222
1176
  return {
1223
1177
  /** List contact fields (base + custom). Pass listId to include list-specific custom fields. */
1224
1178
  async listContactFields(listId) {
@@ -1260,9 +1214,9 @@ var createFieldsClient = (apiKey, apiUrl) => {
1260
1214
  };
1261
1215
 
1262
1216
  // src/deals.ts
1263
- var DEFAULT_API21 = "https://be.graph8.com";
1217
+ var DEFAULT_API18 = "https://be.graph8.com";
1264
1218
  var createDealsClient = (apiKey, apiUrl) => {
1265
- const baseUrl = apiUrl || DEFAULT_API21;
1219
+ const baseUrl = apiUrl || DEFAULT_API18;
1266
1220
  return {
1267
1221
  /** List all deal pipelines and their stages. */
1268
1222
  async pipelines() {
@@ -1306,9 +1260,9 @@ var createDealsClient = (apiKey, apiUrl) => {
1306
1260
  };
1307
1261
 
1308
1262
  // src/inbox.ts
1309
- var DEFAULT_API22 = "https://be.graph8.com";
1263
+ var DEFAULT_API19 = "https://be.graph8.com";
1310
1264
  var createInboxClient = (apiKey, apiUrl) => {
1311
- const baseUrl = apiUrl || DEFAULT_API22;
1265
+ const baseUrl = apiUrl || DEFAULT_API19;
1312
1266
  return {
1313
1267
  /** List inbox threads across email, SMS, and LinkedIn. */
1314
1268
  async list(params = {}) {
@@ -1361,9 +1315,9 @@ var createInboxClient = (apiKey, apiUrl) => {
1361
1315
  };
1362
1316
 
1363
1317
  // src/quotes.ts
1364
- var DEFAULT_API23 = "https://be.graph8.com";
1318
+ var DEFAULT_API20 = "https://be.graph8.com";
1365
1319
  var createQuotesClient = (apiKey, apiUrl) => {
1366
- const baseUrl = apiUrl || DEFAULT_API23;
1320
+ const baseUrl = apiUrl || DEFAULT_API20;
1367
1321
  return {
1368
1322
  /** List quotes org-wide with optional filters and pagination. */
1369
1323
  async list(params = {}) {
@@ -1435,9 +1389,9 @@ var createQuotesClient = (apiKey, apiUrl) => {
1435
1389
  };
1436
1390
 
1437
1391
  // src/pipelines.ts
1438
- var DEFAULT_API24 = "https://be.graph8.com";
1392
+ var DEFAULT_API21 = "https://be.graph8.com";
1439
1393
  var createPipelinesClient = (apiKey, apiUrl) => {
1440
- const baseUrl = apiUrl || DEFAULT_API24;
1394
+ const baseUrl = apiUrl || DEFAULT_API21;
1441
1395
  return {
1442
1396
  /** List all stage-checklist pipelines with stages, evidence, scripts. */
1443
1397
  async list() {
@@ -1519,9 +1473,9 @@ var createPipelinesClient = (apiKey, apiUrl) => {
1519
1473
  };
1520
1474
 
1521
1475
  // src/workflows.ts
1522
- var DEFAULT_API25 = "https://be.graph8.com";
1476
+ var DEFAULT_API22 = "https://be.graph8.com";
1523
1477
  var createWorkflowsClient = (apiKey, apiUrl) => {
1524
- const baseUrl = apiUrl || DEFAULT_API25;
1478
+ const baseUrl = apiUrl || DEFAULT_API22;
1525
1479
  return {
1526
1480
  /** List workflows org-wide. */
1527
1481
  async list(params = {}) {
@@ -1637,9 +1591,9 @@ var createWorkflowsClient = (apiKey, apiUrl) => {
1637
1591
  };
1638
1592
 
1639
1593
  // src/skills.ts
1640
- var DEFAULT_API26 = "https://be.graph8.com";
1594
+ var DEFAULT_API23 = "https://be.graph8.com";
1641
1595
  var createSkillsClient = (apiKey, apiUrl) => {
1642
- const baseUrl = apiUrl || DEFAULT_API26;
1596
+ const baseUrl = apiUrl || DEFAULT_API23;
1643
1597
  return {
1644
1598
  /** List skills. */
1645
1599
  async list(params = {}) {
@@ -1726,9 +1680,9 @@ var createSkillsClient = (apiKey, apiUrl) => {
1726
1680
  };
1727
1681
 
1728
1682
  // src/intent.ts
1729
- var DEFAULT_API27 = "https://be.graph8.com";
1683
+ var DEFAULT_API24 = "https://be.graph8.com";
1730
1684
  var createIntentClient = (apiKey, apiUrl) => {
1731
- const baseUrl = apiUrl || DEFAULT_API27;
1685
+ const baseUrl = apiUrl || DEFAULT_API24;
1732
1686
  const get = (path) => request(baseUrl, `/api/v1${path}`, apiKey);
1733
1687
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1734
1688
  const del = (path) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "DELETE" });
@@ -1797,10 +1751,12 @@ var createIntentClient = (apiKey, apiUrl) => {
1797
1751
  };
1798
1752
 
1799
1753
  // src/studio.ts
1800
- var DEFAULT_API28 = "https://be.graph8.com";
1754
+ var DEFAULT_API25 = "https://be.graph8.com";
1801
1755
  var createStudioClient = (apiKey, apiUrl) => {
1802
- const baseUrl = apiUrl || DEFAULT_API28;
1756
+ const baseUrl = apiUrl || DEFAULT_API25;
1803
1757
  const get = (path, params = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { query: params });
1758
+ const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1759
+ const patch = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "PATCH", body });
1804
1760
  return {
1805
1761
  /** Org-level Studio documents (brand_brief, value_props, messaging_house, etc.).
1806
1762
  * `include_content` defaults to true server-side, so each document includes
@@ -1823,14 +1779,38 @@ var createStudioClient = (apiKey, apiUrl) => {
1823
1779
  /** AI research reports (buyer psychology, competitive teardown, GTM channel, etc.). */
1824
1780
  async researchReports(params = {}) {
1825
1781
  return get("/research-reports", params);
1782
+ },
1783
+ /** Create an ICP manually (no AI scoring). Requires name + website_url. */
1784
+ async createIcp(body) {
1785
+ return post("/icps", body);
1786
+ },
1787
+ /** Update an ICP (partial - send only fields to change). */
1788
+ async updateIcp(icpId, body) {
1789
+ return patch(`/icps/${icpId}`, body);
1790
+ },
1791
+ /** Archive an ICP (soft delete - sets status to "archived"). */
1792
+ async archiveIcp(icpId) {
1793
+ return post(`/icps/${icpId}/archive`);
1794
+ },
1795
+ /** Create a buyer persona manually (no AI generation). Requires title + website_url. */
1796
+ async createPersona(body) {
1797
+ return post("/personas", body);
1798
+ },
1799
+ /** Update a persona (partial). Passing status "archived" is equivalent to archivePersona. */
1800
+ async updatePersona(personaId, body) {
1801
+ return patch(`/personas/${personaId}`, body);
1802
+ },
1803
+ /** Archive a persona (soft delete - sets status to "archived"). */
1804
+ async archivePersona(personaId) {
1805
+ return post(`/personas/${personaId}/archive`);
1826
1806
  }
1827
1807
  };
1828
1808
  };
1829
1809
 
1830
1810
  // src/meetings.ts
1831
- var DEFAULT_API29 = "https://be.graph8.com";
1811
+ var DEFAULT_API26 = "https://be.graph8.com";
1832
1812
  var createMeetingsClient = (apiKey, apiUrl) => {
1833
- const baseUrl = apiUrl || DEFAULT_API29;
1813
+ const baseUrl = apiUrl || DEFAULT_API26;
1834
1814
  return {
1835
1815
  /** List meetings with optional filters. Returns summary rows without transcript / analysis. */
1836
1816
  async list(params = {}) {
@@ -1845,9 +1825,9 @@ var createMeetingsClient = (apiKey, apiUrl) => {
1845
1825
  };
1846
1826
 
1847
1827
  // src/audiences.ts
1848
- var DEFAULT_API30 = "https://be.graph8.com";
1828
+ var DEFAULT_API27 = "https://be.graph8.com";
1849
1829
  var createAudiencesClient = (apiKey, apiUrl) => {
1850
- const baseUrl = apiUrl || DEFAULT_API30;
1830
+ const baseUrl = apiUrl || DEFAULT_API27;
1851
1831
  const base = "/api/v1/audience-syncs";
1852
1832
  return {
1853
1833
  /** List all audience syncs for the organization. */
@@ -1895,9 +1875,9 @@ var createAudiencesClient = (apiKey, apiUrl) => {
1895
1875
  };
1896
1876
 
1897
1877
  // src/search.ts
1898
- var DEFAULT_API31 = "https://be.graph8.com";
1878
+ var DEFAULT_API28 = "https://be.graph8.com";
1899
1879
  var createSearchClient = (apiKey, apiUrl) => {
1900
- const baseUrl = apiUrl || DEFAULT_API31;
1880
+ const baseUrl = apiUrl || DEFAULT_API28;
1901
1881
  const body = (p) => ({ filters: [], page: 1, limit: 25, ...p });
1902
1882
  return {
1903
1883
  /** Search open-data contacts by filter. */
@@ -1928,9 +1908,9 @@ var createSearchClient = (apiKey, apiUrl) => {
1928
1908
  };
1929
1909
 
1930
1910
  // src/agency.ts
1931
- var DEFAULT_API32 = "https://be.graph8.com";
1911
+ var DEFAULT_API29 = "https://be.graph8.com";
1932
1912
  var createAgencyClient = (apiKey, apiUrl) => {
1933
- const baseUrl = apiUrl || DEFAULT_API32;
1913
+ const baseUrl = apiUrl || DEFAULT_API29;
1934
1914
  return {
1935
1915
  /** Describe the agency credential: agency org + authorized client count. */
1936
1916
  async me() {
@@ -1945,9 +1925,9 @@ var createAgencyClient = (apiKey, apiUrl) => {
1945
1925
  };
1946
1926
 
1947
1927
  // src/marketplace.ts
1948
- var DEFAULT_API33 = "https://be.graph8.com";
1928
+ var DEFAULT_API30 = "https://be.graph8.com";
1949
1929
  var createMarketplaceClient = (apiKey, apiUrl) => {
1950
- const baseUrl = apiUrl || DEFAULT_API33;
1930
+ const baseUrl = apiUrl || DEFAULT_API30;
1951
1931
  const base = "/api/v1/marketplace";
1952
1932
  return {
1953
1933
  /** Your own marketplace SDR profile. */
@@ -1997,9 +1977,9 @@ var createMarketplaceClient = (apiKey, apiUrl) => {
1997
1977
  };
1998
1978
 
1999
1979
  // src/snippet.ts
2000
- var DEFAULT_API34 = "https://be.graph8.com";
1980
+ var DEFAULT_API31 = "https://be.graph8.com";
2001
1981
  var createSnippetClient = (apiKey, apiUrl) => {
2002
- const baseUrl = apiUrl || DEFAULT_API34;
1982
+ const baseUrl = apiUrl || DEFAULT_API31;
2003
1983
  return {
2004
1984
  /** Get your org's tracking snippet (write key + React/script-tag embeds + config). */
2005
1985
  async get() {
@@ -2011,7 +1991,7 @@ var createSnippetClient = (apiKey, apiUrl) => {
2011
1991
 
2012
1992
  // src/core.ts
2013
1993
  var DEFAULT_HOST = "https://t.graph8.com";
2014
- var DEFAULT_API35 = "https://be.graph8.com";
1994
+ var DEFAULT_API32 = "https://be.graph8.com";
2015
1995
  var G8 = class {
2016
1996
  constructor() {
2017
1997
  /** @internal */
@@ -2035,16 +2015,10 @@ var G8 = class {
2035
2015
  /** @internal */
2036
2016
  this._campaigns = null;
2037
2017
  /** @internal */
2038
- this._integrations = null;
2039
- /** @internal */
2040
2018
  this._signals = null;
2041
2019
  /** @internal */
2042
- this._analytics = null;
2043
- /** @internal */
2044
2020
  this._voice = null;
2045
2021
  /** @internal */
2046
- this._pages = null;
2047
- /** @internal */
2048
2022
  this._webhooks = null;
2049
2023
  /** @internal */
2050
2024
  this._contacts = null;
@@ -2100,7 +2074,7 @@ var G8 = class {
2100
2074
  debug: config.debug
2101
2075
  });
2102
2076
  }
2103
- const apiUrl = config.apiUrl || DEFAULT_API35;
2077
+ const apiUrl = config.apiUrl || DEFAULT_API32;
2104
2078
  const writeKey = config.writeKey || "";
2105
2079
  const apiKey = config.apiKey || "";
2106
2080
  if (writeKey) {
@@ -2115,10 +2089,7 @@ var G8 = class {
2115
2089
  this._enrich = createEnrichClient(apiKey, apiUrl);
2116
2090
  this._sequences = createSequencesClient(apiKey, apiUrl);
2117
2091
  this._campaigns = createCampaignsClient(apiKey, apiUrl);
2118
- this._integrations = createIntegrationsClient(apiKey, apiUrl);
2119
- this._analytics = createAnalyticsClient(apiKey, apiUrl);
2120
2092
  this._voice = createVoiceClient(apiKey, apiUrl);
2121
- this._pages = createPagesClient(apiKey, apiUrl);
2122
2093
  this._webhooks = createWebhooksClient(apiKey, apiUrl);
2123
2094
  this._contacts = createContactsClient(apiKey, apiUrl);
2124
2095
  this._companies = createCompaniesClient(apiKey, apiUrl);
@@ -2201,31 +2172,16 @@ var G8 = class {
2201
2172
  this._assertKey("campaigns");
2202
2173
  return this._campaigns;
2203
2174
  }
2204
- /** CRM integrations (requires API key). */
2205
- get integrations() {
2206
- this._assertKey("integrations");
2207
- return this._integrations;
2208
- }
2209
2175
  /** Intent signals. */
2210
2176
  get signals() {
2211
2177
  this._assertInit();
2212
2178
  return this._signals;
2213
2179
  }
2214
- /** Analytics (requires API key). */
2215
- get analytics() {
2216
- this._assertKey("analytics");
2217
- return this._analytics;
2218
- }
2219
2180
  /** Voice AI (requires API key). */
2220
2181
  get voice() {
2221
2182
  this._assertKey("voice");
2222
2183
  return this._voice;
2223
2184
  }
2224
- /** Landing pages (requires API key). */
2225
- get pages() {
2226
- this._assertKey("pages");
2227
- return this._pages;
2228
- }
2229
2185
  /** Webhook event listeners (requires API key). */
2230
2186
  get webhooks() {
2231
2187
  this._assertKey("webhooks");