@graph8/sdk 0.245.0 → 0.260.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.
Files changed (350) hide show
  1. package/README.md +19 -5
  2. package/dist/cli.js +216 -0
  3. package/dist/index.d.mts +283 -12
  4. package/dist/index.d.ts +283 -12
  5. package/dist/index.js +88 -2
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +88 -2
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/react.d.mts +274 -12
  10. package/dist/react.d.ts +274 -12
  11. package/dist/react.js +106 -10
  12. package/dist/react.js.map +1 -1
  13. package/dist/react.mjs +97 -11
  14. package/dist/react.mjs.map +1 -1
  15. package/dist/types/README.md +7 -0
  16. package/dist/types/agency.d.ts +20 -0
  17. package/dist/types/agentSetup.d.ts +57 -0
  18. package/dist/types/api.d.ts +127 -0
  19. package/dist/types/appClient.d.ts +99 -0
  20. package/dist/types/appPlatform.d.ts +269 -0
  21. package/dist/types/appTokens.d.ts +125 -0
  22. package/dist/types/apps.d.ts +130 -0
  23. package/dist/types/audiences.d.ts +88 -0
  24. package/dist/types/calendar.d.ts +55 -0
  25. package/dist/types/campaigns.d.ts +61 -0
  26. package/dist/types/chat.d.ts +35 -0
  27. package/dist/types/cli.d.ts +14 -0
  28. package/dist/types/companies.d.ts +123 -0
  29. package/dist/types/contacts.d.ts +200 -0
  30. package/dist/types/copilot.d.ts +31 -0
  31. package/dist/types/core.d.ts +1052 -0
  32. package/dist/types/deals.d.ts +215 -0
  33. package/dist/types/enrich.d.ts +51 -0
  34. package/dist/types/fields.d.ts +84 -0
  35. package/dist/types/forms.d.ts +16 -0
  36. package/dist/types/http.d.ts +141 -0
  37. package/dist/types/inbox.d.ts +123 -0
  38. package/dist/types/index.d.ts +63 -0
  39. package/dist/types/intent.d.ts +196 -0
  40. package/dist/types/lists.d.ts +44 -0
  41. package/dist/types/mailboxes.d.ts +240 -0
  42. package/dist/types/marketplace.d.ts +62 -0
  43. package/dist/types/meetings.d.ts +70 -0
  44. package/dist/types/newsletter.d.ts +212 -0
  45. package/dist/types/notes.d.ts +57 -0
  46. package/dist/types/objects.d.ts +281 -0
  47. package/dist/types/pipelines.d.ts +135 -0
  48. package/dist/types/quotes.d.ts +143 -0
  49. package/dist/types/react.d.ts +978 -0
  50. package/dist/types/search.d.ts +99 -0
  51. package/dist/types/sequences.d.ts +255 -0
  52. package/dist/types/signals.d.ts +28 -0
  53. package/dist/types/skills.d.ts +176 -0
  54. package/dist/types/snippet.d.ts +24 -0
  55. package/dist/types/studio.d.ts +161 -0
  56. package/dist/types/tasks.d.ts +101 -0
  57. package/dist/types/types.d.ts +45 -0
  58. package/dist/types/utils.d.ts +21 -0
  59. package/dist/types/version.d.ts +10 -0
  60. package/dist/types/visitors.d.ts +29 -0
  61. package/dist/types/voice.d.ts +304 -0
  62. package/dist/types/webhooks.d.ts +71 -0
  63. package/dist/types/workflows.d.ts +229 -0
  64. package/docs/agents.md +748 -0
  65. package/docs/api/README.md +165 -0
  66. package/docs/api/accounts.d.ts +396 -0
  67. package/docs/api/accounts.md +644 -0
  68. package/docs/api/adCampaigns.d.ts +707 -0
  69. package/docs/api/adCampaigns.md +1091 -0
  70. package/docs/api/adCreatives.d.ts +996 -0
  71. package/docs/api/adCreatives.md +1708 -0
  72. package/docs/api/agency.d.ts +556 -0
  73. package/docs/api/agency.md +845 -0
  74. package/docs/api/agent.d.ts +330 -0
  75. package/docs/api/agent.md +514 -0
  76. package/docs/api/agents.d.ts +1622 -0
  77. package/docs/api/agents.md +2860 -0
  78. package/docs/api/aiInbox.d.ts +1984 -0
  79. package/docs/api/aiInbox.md +3490 -0
  80. package/docs/api/analytics.d.ts +1273 -0
  81. package/docs/api/analytics.md +2095 -0
  82. package/docs/api/apiKeys.d.ts +252 -0
  83. package/docs/api/apiKeys.md +318 -0
  84. package/docs/api/appDeployments.d.ts +236 -0
  85. package/docs/api/appDeployments.md +471 -0
  86. package/docs/api/appDomains.d.ts +171 -0
  87. package/docs/api/appDomains.md +281 -0
  88. package/docs/api/appLogs.d.ts +120 -0
  89. package/docs/api/appLogs.md +159 -0
  90. package/docs/api/appObjects.d.ts +415 -0
  91. package/docs/api/appObjects.md +568 -0
  92. package/docs/api/appPages.d.ts +557 -0
  93. package/docs/api/appPages.md +796 -0
  94. package/docs/api/appPlatformTokens.d.ts +123 -0
  95. package/docs/api/appPlatformTokens.md +172 -0
  96. package/docs/api/appointments.d.ts +2361 -0
  97. package/docs/api/appointments.md +3917 -0
  98. package/docs/api/apps.d.ts +822 -0
  99. package/docs/api/apps.md +1342 -0
  100. package/docs/api/assertUpsert.d.ts +286 -0
  101. package/docs/api/assertUpsert.md +370 -0
  102. package/docs/api/audienceSyncs.d.ts +259 -0
  103. package/docs/api/audienceSyncs.md +395 -0
  104. package/docs/api/brandKit.d.ts +686 -0
  105. package/docs/api/brandKit.md +1133 -0
  106. package/docs/api/bugReports.d.ts +181 -0
  107. package/docs/api/bugReports.md +268 -0
  108. package/docs/api/by-path.md +3260 -0
  109. package/docs/api/calendarInvites.d.ts +117 -0
  110. package/docs/api/calendarInvites.md +148 -0
  111. package/docs/api/campaignWorkflows.d.ts +152 -0
  112. package/docs/api/campaignWorkflows.md +200 -0
  113. package/docs/api/campaigns.d.ts +721 -0
  114. package/docs/api/campaigns.md +1236 -0
  115. package/docs/api/channels.d.ts +171 -0
  116. package/docs/api/channels.md +235 -0
  117. package/docs/api/cliCampaigns.d.ts +205 -0
  118. package/docs/api/cliCampaigns.md +256 -0
  119. package/docs/api/cliPipelines.d.ts +324 -0
  120. package/docs/api/cliPipelines.md +562 -0
  121. package/docs/api/clickHouse.d.ts +115 -0
  122. package/docs/api/clickHouse.md +138 -0
  123. package/docs/api/companies.d.ts +1636 -0
  124. package/docs/api/companies.md +2211 -0
  125. package/docs/api/companyIntelligence.d.ts +299 -0
  126. package/docs/api/companyIntelligence.md +488 -0
  127. package/docs/api/contacts.d.ts +2173 -0
  128. package/docs/api/contacts.md +3143 -0
  129. package/docs/api/content.d.ts +968 -0
  130. package/docs/api/content.md +1667 -0
  131. package/docs/api/contentGridSkills.d.ts +177 -0
  132. package/docs/api/contentGridSkills.md +271 -0
  133. package/docs/api/copilot.d.ts +1017 -0
  134. package/docs/api/copilot.md +1765 -0
  135. package/docs/api/crmSyncs.d.ts +215 -0
  136. package/docs/api/crmSyncs.md +301 -0
  137. package/docs/api/customerSuccess.d.ts +491 -0
  138. package/docs/api/customerSuccess.md +776 -0
  139. package/docs/api/deals.d.ts +1696 -0
  140. package/docs/api/deals.md +2432 -0
  141. package/docs/api/deliverability.d.ts +418 -0
  142. package/docs/api/deliverability.md +677 -0
  143. package/docs/api/desk.d.ts +1765 -0
  144. package/docs/api/desk.md +3007 -0
  145. package/docs/api/dialer.d.ts +1185 -0
  146. package/docs/api/dialer.md +2166 -0
  147. package/docs/api/dialerAnalytics.d.ts +187 -0
  148. package/docs/api/dialerAnalytics.md +257 -0
  149. package/docs/api/documents.d.ts +895 -0
  150. package/docs/api/documents.md +1440 -0
  151. package/docs/api/duplicates.d.ts +195 -0
  152. package/docs/api/duplicates.md +315 -0
  153. package/docs/api/eSign.d.ts +38 -0
  154. package/docs/api/eSign.md +54 -0
  155. package/docs/api/eSignature.d.ts +242 -0
  156. package/docs/api/eSignature.md +341 -0
  157. package/docs/api/enrichment.d.ts +3207 -0
  158. package/docs/api/enrichment.md +5225 -0
  159. package/docs/api/events.d.ts +115 -0
  160. package/docs/api/events.md +105 -0
  161. package/docs/api/fields.d.ts +482 -0
  162. package/docs/api/fields.md +566 -0
  163. package/docs/api/forms.d.ts +1012 -0
  164. package/docs/api/forms.md +1542 -0
  165. package/docs/api/gtmCampaigns.d.ts +662 -0
  166. package/docs/api/gtmCampaigns.md +1044 -0
  167. package/docs/api/gtmContext.d.ts +1187 -0
  168. package/docs/api/gtmContext.md +2112 -0
  169. package/docs/api/gtmDeliverability.d.ts +60 -0
  170. package/docs/api/gtmDeliverability.md +63 -0
  171. package/docs/api/gtmKnowledgeBase.d.ts +76 -0
  172. package/docs/api/gtmKnowledgeBase.md +91 -0
  173. package/docs/api/gtmLaunchHelpers.d.ts +123 -0
  174. package/docs/api/gtmLaunchHelpers.md +148 -0
  175. package/docs/api/gtmLibrary.d.ts +448 -0
  176. package/docs/api/gtmLibrary.md +780 -0
  177. package/docs/api/health.d.ts +39 -0
  178. package/docs/api/health.md +58 -0
  179. package/docs/api/imageLibrary.d.ts +341 -0
  180. package/docs/api/imageLibrary.md +569 -0
  181. package/docs/api/imports.d.ts +157 -0
  182. package/docs/api/imports.md +174 -0
  183. package/docs/api/inbox.d.ts +709 -0
  184. package/docs/api/inbox.md +1067 -0
  185. package/docs/api/install.d.ts +213 -0
  186. package/docs/api/install.md +317 -0
  187. package/docs/api/installedApps.d.ts +131 -0
  188. package/docs/api/installedApps.md +241 -0
  189. package/docs/api/integrationStatus.d.ts +142 -0
  190. package/docs/api/integrationStatus.md +205 -0
  191. package/docs/api/integrations.d.ts +2327 -0
  192. package/docs/api/integrations.md +3791 -0
  193. package/docs/api/intent.d.ts +482 -0
  194. package/docs/api/intent.md +858 -0
  195. package/docs/api/knowledge.d.ts +501 -0
  196. package/docs/api/knowledge.md +843 -0
  197. package/docs/api/knowledgeBase.d.ts +84 -0
  198. package/docs/api/knowledgeBase.md +96 -0
  199. package/docs/api/landingPages.d.ts +1411 -0
  200. package/docs/api/landingPages.md +2488 -0
  201. package/docs/api/leads.d.ts +133 -0
  202. package/docs/api/leads.md +180 -0
  203. package/docs/api/library.d.ts +217 -0
  204. package/docs/api/library.md +338 -0
  205. package/docs/api/linkedIn.d.ts +227 -0
  206. package/docs/api/linkedIn.md +289 -0
  207. package/docs/api/linkedInOutreach.d.ts +727 -0
  208. package/docs/api/linkedInOutreach.md +990 -0
  209. package/docs/api/lists.d.ts +1106 -0
  210. package/docs/api/lists.md +1609 -0
  211. package/docs/api/logs.d.ts +71 -0
  212. package/docs/api/logs.md +70 -0
  213. package/docs/api/mailboxes.d.ts +1050 -0
  214. package/docs/api/mailboxes.md +1690 -0
  215. package/docs/api/marketingIntelligence.d.ts +256 -0
  216. package/docs/api/marketingIntelligence.md +454 -0
  217. package/docs/api/marketplace.d.ts +3173 -0
  218. package/docs/api/marketplace.md +5953 -0
  219. package/docs/api/mcp.d.ts +69 -0
  220. package/docs/api/mcp.md +69 -0
  221. package/docs/api/me.d.ts +54 -0
  222. package/docs/api/me.md +56 -0
  223. package/docs/api/meetings.d.ts +539 -0
  224. package/docs/api/meetings.md +747 -0
  225. package/docs/api/newsletter.d.ts +1613 -0
  226. package/docs/api/newsletter.md +2746 -0
  227. package/docs/api/notes.d.ts +517 -0
  228. package/docs/api/notes.md +888 -0
  229. package/docs/api/notifications.d.ts +94 -0
  230. package/docs/api/notifications.md +105 -0
  231. package/docs/api/objects.d.ts +621 -0
  232. package/docs/api/objects.md +1098 -0
  233. package/docs/api/openSearch.d.ts +234 -0
  234. package/docs/api/openSearch.md +297 -0
  235. package/docs/api/ops.d.ts +299 -0
  236. package/docs/api/ops.md +339 -0
  237. package/docs/api/orgGovernance.d.ts +393 -0
  238. package/docs/api/orgGovernance.md +623 -0
  239. package/docs/api/orgVideos.d.ts +184 -0
  240. package/docs/api/orgVideos.md +252 -0
  241. package/docs/api/organizationSettings.d.ts +626 -0
  242. package/docs/api/organizationSettings.md +911 -0
  243. package/docs/api/phoneNumbers.d.ts +484 -0
  244. package/docs/api/phoneNumbers.md +777 -0
  245. package/docs/api/profile.d.ts +329 -0
  246. package/docs/api/profile.md +540 -0
  247. package/docs/api/programmaticPages.d.ts +400 -0
  248. package/docs/api/programmaticPages.md +626 -0
  249. package/docs/api/providerDomains.d.ts +866 -0
  250. package/docs/api/providerDomains.md +1446 -0
  251. package/docs/api/providerUsage.d.ts +129 -0
  252. package/docs/api/providerUsage.md +186 -0
  253. package/docs/api/public.d.ts +69 -0
  254. package/docs/api/public.md +78 -0
  255. package/docs/api/publicCopilot.d.ts +67 -0
  256. package/docs/api/publicCopilot.md +80 -0
  257. package/docs/api/publicSignals.d.ts +66 -0
  258. package/docs/api/publicSignals.md +71 -0
  259. package/docs/api/publicVisitors.d.ts +97 -0
  260. package/docs/api/publicVisitors.md +118 -0
  261. package/docs/api/quotes.d.ts +1564 -0
  262. package/docs/api/quotes.md +2553 -0
  263. package/docs/api/radar.d.ts +808 -0
  264. package/docs/api/radar.md +1431 -0
  265. package/docs/api/radarReports.d.ts +208 -0
  266. package/docs/api/radarReports.md +306 -0
  267. package/docs/api/recordRoles.d.ts +143 -0
  268. package/docs/api/recordRoles.md +175 -0
  269. package/docs/api/repos.d.ts +146 -0
  270. package/docs/api/repos.md +211 -0
  271. package/docs/api/research.d.ts +295 -0
  272. package/docs/api/research.md +534 -0
  273. package/docs/api/revenue.d.ts +402 -0
  274. package/docs/api/revenue.md +608 -0
  275. package/docs/api/revenueAnalytics.d.ts +147 -0
  276. package/docs/api/revenueAnalytics.md +212 -0
  277. package/docs/api/revenueLifecycle.d.ts +207 -0
  278. package/docs/api/revenueLifecycle.md +274 -0
  279. package/docs/api/revenueRecords.d.ts +372 -0
  280. package/docs/api/revenueRecords.md +563 -0
  281. package/docs/api/roles.d.ts +431 -0
  282. package/docs/api/roles.md +812 -0
  283. package/docs/api/salesCoach.d.ts +877 -0
  284. package/docs/api/salesCoach.md +1540 -0
  285. package/docs/api/sandbox.d.ts +210 -0
  286. package/docs/api/sandbox.md +380 -0
  287. package/docs/api/scans.d.ts +104 -0
  288. package/docs/api/scans.md +136 -0
  289. package/docs/api/scheduleBuy.d.ts +293 -0
  290. package/docs/api/scheduleBuy.md +431 -0
  291. package/docs/api/scraping.d.ts +266 -0
  292. package/docs/api/scraping.md +383 -0
  293. package/docs/api/sdrAnalytics.d.ts +138 -0
  294. package/docs/api/sdrAnalytics.md +246 -0
  295. package/docs/api/search.d.ts +598 -0
  296. package/docs/api/search.md +866 -0
  297. package/docs/api/seo.d.ts +447 -0
  298. package/docs/api/seo.md +660 -0
  299. package/docs/api/sequenceLifecycle.d.ts +439 -0
  300. package/docs/api/sequenceLifecycle.md +513 -0
  301. package/docs/api/sequences.d.ts +1936 -0
  302. package/docs/api/sequences.md +3232 -0
  303. package/docs/api/settings.d.ts +448 -0
  304. package/docs/api/settings.md +731 -0
  305. package/docs/api/signals.d.ts +1441 -0
  306. package/docs/api/signals.md +2526 -0
  307. package/docs/api/signatures.d.ts +719 -0
  308. package/docs/api/signatures.md +1247 -0
  309. package/docs/api/skills.d.ts +230 -0
  310. package/docs/api/skills.md +466 -0
  311. package/docs/api/snippet.d.ts +85 -0
  312. package/docs/api/snippet.md +106 -0
  313. package/docs/api/socialPublishing.d.ts +824 -0
  314. package/docs/api/socialPublishing.md +1245 -0
  315. package/docs/api/studioDocuments.d.ts +244 -0
  316. package/docs/api/studioDocuments.md +348 -0
  317. package/docs/api/support.d.ts +90 -0
  318. package/docs/api/support.md +76 -0
  319. package/docs/api/suppressions.d.ts +241 -0
  320. package/docs/api/suppressions.md +343 -0
  321. package/docs/api/surveys.d.ts +847 -0
  322. package/docs/api/surveys.md +1223 -0
  323. package/docs/api/tasks.d.ts +813 -0
  324. package/docs/api/tasks.md +1344 -0
  325. package/docs/api/teamMembers.d.ts +668 -0
  326. package/docs/api/teamMembers.md +1040 -0
  327. package/docs/api/teams.d.ts +784 -0
  328. package/docs/api/teams.md +1395 -0
  329. package/docs/api/usage.d.ts +277 -0
  330. package/docs/api/usage.md +389 -0
  331. package/docs/api/visitors.d.ts +690 -0
  332. package/docs/api/visitors.md +1075 -0
  333. package/docs/api/voice.d.ts +4661 -0
  334. package/docs/api/voice.md +7905 -0
  335. package/docs/api/webAnalytics.d.ts +964 -0
  336. package/docs/api/webAnalytics.md +1452 -0
  337. package/docs/api/webChat.d.ts +1704 -0
  338. package/docs/api/webChat.md +2048 -0
  339. package/docs/api/webhooks.d.ts +251 -0
  340. package/docs/api/webhooks.md +386 -0
  341. package/docs/api/websiteEditor.d.ts +324 -0
  342. package/docs/api/websiteEditor.md +517 -0
  343. package/docs/api/work.d.ts +2298 -0
  344. package/docs/api/work.md +3096 -0
  345. package/docs/api/workbench.d.ts +2962 -0
  346. package/docs/api/workbench.md +4884 -0
  347. package/docs/api/workflows.d.ts +1218 -0
  348. package/docs/api/workflows.md +2302 -0
  349. package/docs/sdk-clients.md +4339 -0
  350. package/package.json +10 -3
package/README.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  The most comprehensive GTM SDK. One `npm install`. Every graph8 capability.
4
4
 
5
+ > **AI coding agents (Claude Code, Codex, Cursor):** read
6
+ > [`docs/agents.md`](docs/agents.md) (`node_modules/@graph8/sdk/docs/agents.md`) first. It covers setup, the
7
+ > two client layers, safety tiers, errors and tested recipes, and links a per-area reference for every
8
+ > operation in [`docs/api/`](docs/api/README.md). It ships with the package, so it matches this version.
9
+ > Run `npx @graph8/sdk init-agent` to point Claude Code, Codex and Cursor in your project at it automatically.
10
+
5
11
  ## Install
6
12
 
7
13
  ```bash
@@ -53,7 +59,13 @@ import { g8 } from '@graph8/sdk';
53
59
 
54
60
  g8.init({ apiKey: 'YOUR_API_KEY' });
55
61
 
56
- // Contacts CRUD
62
+ // Contacts: create-or-update in one idempotent call (matches work_email, then linkedin_url).
63
+ // Use this when the contact may already exist; it is safe to retry.
64
+ const { action } = await g8.contacts.upsert({ list_id: 42, work_email: 'jane@acme.com', first_name: 'Jane' });
65
+ // action is "created" or "updated"
66
+
67
+ // Contacts CRUD. create() is create-only: a duplicate throws a 409 G8Error
68
+ // whose detail.hint / detail.upsert point back at upsert().
57
69
  const { data: contacts } = await g8.contacts.list({ company_name: 'Acme', limit: 10 });
58
70
  const contact = await g8.contacts.create({ work_email: 'jane@acme.com', first_name: 'Jane' });
59
71
  await g8.contacts.update(contact.id, { job_title: 'VP Sales' });
@@ -133,8 +145,9 @@ export const CTA = () => {
133
145
 
134
146
  The clients above are the ergonomic layer — hand-written, opinionated, and only
135
147
  as complete as someone made them. `g8.api` is the complete one: it is
136
- **generated from the published OpenAPI contract**, so it covers **every one of
137
- the 587 Developer API operations**, including surfaces with no hand-written
148
+ **generated from the published OpenAPI contract**, so it covers **every
149
+ Developer API operation** (the count and a per-area reference are in
150
+ [`docs/api/README.md`](docs/api/README.md)), including surfaces with no hand-written
138
151
  client (Appointments, Radar, App Objects, Ad Campaigns, Sandbox, Landing Pages,
139
152
  Agent, OpenSearch, ClickHouse and more).
140
153
 
@@ -225,9 +238,10 @@ Two things to know before reaching for it:
225
238
 
226
239
  | Method | Description |
227
240
  |--------|-------------|
241
+ | `g8.contacts.upsert(contact)` | **Create or update** a contact (`PUT /contacts/assert`). Matches `work_email`, then `linkedin_url`; needs `list_id`. Idempotent, the recommended way to write a contact |
228
242
  | `g8.contacts.list(params?)` | List contacts with filters |
229
243
  | `g8.contacts.get(id)` | Get contact by ID |
230
- | `g8.contacts.create(contact)` | Create a contact |
244
+ | `g8.contacts.create(contact)` | Create a contact. Create-only: a duplicate throws a 409 whose `detail.upsert` names `upsert()` |
231
245
  | `g8.contacts.update(id, fields)` | Update contact (partial) |
232
246
  | `g8.contacts.delete(id)` | Delete contact |
233
247
 
@@ -297,7 +311,7 @@ Two things to know before reaching for it:
297
311
 
298
312
  | Method | Description |
299
313
  |--------|-------------|
300
- | `g8.enrich.person(params)` | Look up a person (1 credit) |
314
+ | `g8.enrich.person(params)` | Look up a person (1 credit). REST: `POST /enrichment/lookup/person` (`POST /enrichment/person` is an alias) |
301
315
  | `g8.enrich.company(params)` | Look up a company (1 credit) |
302
316
  | `g8.enrich.verifyEmail(email)` | Verify email (1 credit) |
303
317
  | `g8.enrich.search(filters)` | Search 700M+ contacts |
package/dist/cli.js ADDED
@@ -0,0 +1,216 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/cli.ts
32
+ var cli_exports = {};
33
+ __export(cli_exports, {
34
+ runCli: () => runCli
35
+ });
36
+ module.exports = __toCommonJS(cli_exports);
37
+ var import_node_fs = __toESM(require("fs"));
38
+ var import_node_path = __toESM(require("path"));
39
+
40
+ // src/agentSetup.ts
41
+ var ALL_TARGETS = ["claude", "codex", "cursor"];
42
+ var MARKER_START = "<!-- graph8-sdk:start (managed by `npx @graph8/sdk init-agent`; edits inside are overwritten) -->";
43
+ var MARKER_END = "<!-- graph8-sdk:end -->";
44
+ function coreInstructions() {
45
+ return [
46
+ "This project uses the graph8 JavaScript SDK, `@graph8/sdk`.",
47
+ "",
48
+ "Before writing graph8 code, read `node_modules/@graph8/sdk/docs/agents.md`. It matches the installed version:",
49
+ "trust it over what you remember about graph8.",
50
+ "",
51
+ '- Server code: `import { g8 } from "@graph8/sdk"; g8.init({ apiKey: process.env.G8_API_KEY })`. Browser code: a',
52
+ " write key (`g8.init({ writeKey })`), never an API key.",
53
+ "- Prefer a hand-written client when one exists (`g8.contacts`, `g8.deals`, `g8.sequences`, ...):",
54
+ " `node_modules/@graph8/sdk/docs/sdk-clients.md`.",
55
+ "- Everything else is `g8.api.<namespace>.<member>(input)`, which covers every Developer API operation. Find it in",
56
+ " `node_modules/@graph8/sdk/docs/api/README.md` (by area) or `docs/api/by-path.md` (by REST path). Exact types:",
57
+ " `docs/api/<namespace>.d.ts`. `g8.api` returns the `{ data, ... }` envelope.",
58
+ "- Do not guess method names, fields or ids. If the docs do not list it, it does not exist: say so instead of",
59
+ " inventing it. (`g8.contacts.search`, `g8.sequences.enroll` and an `@graph8/cli` npm package do not exist.)",
60
+ "- Ask the user before any `external` (sends messages), `billable` (spends credits) or `destructive` operation.",
61
+ " The tier is in each reference entry and in `g8.api.operation(id).tier`.",
62
+ "- Errors are `G8Error`: log `err.detail`, not only `err.message`. The SDK already retries 429/5xx; do not add",
63
+ " another retry loop."
64
+ ].join("\n");
65
+ }
66
+ function claudeSkill() {
67
+ return [
68
+ "---",
69
+ "name: graph8-sdk",
70
+ "description: Use when writing or changing code that uses the graph8 JavaScript SDK (@graph8/sdk, `g8.` calls):",
71
+ " graph8 contacts, companies, lists, deals, sequences, campaigns, enrichment, inbox, webhooks or any graph8 API.",
72
+ "---",
73
+ "",
74
+ "# graph8 SDK",
75
+ "",
76
+ coreInstructions(),
77
+ "",
78
+ "_Generated by `npx @graph8/sdk init-agent`. Re-run it to update; edits here are overwritten._",
79
+ ""
80
+ ].join("\n");
81
+ }
82
+ function cursorRule() {
83
+ return [
84
+ "---",
85
+ "description: How to use the graph8 JavaScript SDK (@graph8/sdk) in this project",
86
+ "globs:",
87
+ "alwaysApply: false",
88
+ "---",
89
+ "",
90
+ coreInstructions(),
91
+ "",
92
+ "_Generated by `npx @graph8/sdk init-agent`. Re-run it to update; edits here are overwritten._",
93
+ ""
94
+ ].join("\n");
95
+ }
96
+ function agentsMdSection() {
97
+ return [MARKER_START, "## graph8 SDK", "", coreInstructions(), MARKER_END].join("\n");
98
+ }
99
+ function upsertAgentsMd(existing) {
100
+ const section = agentsMdSection();
101
+ if (existing === null || existing.trim() === "") return `${section}
102
+ `;
103
+ const start = existing.indexOf("<!-- graph8-sdk:start");
104
+ const end = existing.indexOf(MARKER_END);
105
+ if (start !== -1 && end !== -1 && end > start) {
106
+ return existing.slice(0, start) + section + existing.slice(end + MARKER_END.length);
107
+ }
108
+ if (start !== -1 || end !== -1) {
109
+ throw new Error("AGENTS.md has an unmatched graph8-sdk marker; fix or remove it, then re-run.");
110
+ }
111
+ return `${existing.replace(/\s*$/, "")}
112
+
113
+ ${section}
114
+ `;
115
+ }
116
+ function planAgentSetup(targets, read) {
117
+ const plans = [];
118
+ const add = (target, path2, next) => {
119
+ const current = read(path2);
120
+ plans.push({ target, path: path2, content: next, action: current === null ? "create" : current === next ? "unchanged" : "update" });
121
+ };
122
+ for (const target of targets) {
123
+ if (target === "claude") add(target, ".claude/skills/graph8-sdk/SKILL.md", claudeSkill());
124
+ else if (target === "codex") add(target, "AGENTS.md", upsertAgentsMd(read("AGENTS.md")));
125
+ else if (target === "cursor") add(target, ".cursor/rules/graph8-sdk.mdc", cursorRule());
126
+ }
127
+ return plans;
128
+ }
129
+ var INIT_AGENT_USAGE = `Usage: npx @graph8/sdk init-agent [--claude] [--codex] [--cursor] [--dry-run]
130
+
131
+ Point the coding agents in this project at the @graph8/sdk agent guide.
132
+ With no agent flag, sets up all three:
133
+ --claude .claude/skills/graph8-sdk/SKILL.md (Claude Code skill)
134
+ --codex AGENTS.md, managed section (Codex, Cursor, Copilot, ...)
135
+ --cursor .cursor/rules/graph8-sdk.mdc (Cursor rule)
136
+ --dry-run print what would change, write nothing
137
+ Re-running updates the files in place; your own AGENTS.md text is never touched.`;
138
+ function parseInitAgentArgs(argv) {
139
+ const targets = [];
140
+ let dryRun = false;
141
+ for (const arg of argv) {
142
+ if (arg === "--dry-run") dryRun = true;
143
+ else if (arg === "--claude" || arg === "--codex" || arg === "--cursor") targets.push(arg.slice(2));
144
+ else throw new Error(`unknown option ${arg}
145
+
146
+ ${INIT_AGENT_USAGE}`);
147
+ }
148
+ return { targets: targets.length ? [...new Set(targets)] : [...ALL_TARGETS], dryRun };
149
+ }
150
+
151
+ // src/cli.ts
152
+ var USAGE = `Usage: npx @graph8/sdk <command>
153
+
154
+ Commands:
155
+ init-agent point Claude Code, Codex and Cursor in this project at the SDK's agent guide
156
+
157
+ ${INIT_AGENT_USAGE}`;
158
+ function runCli(argv, io) {
159
+ const [command, ...rest] = argv;
160
+ if (!command || command === "--help" || command === "-h" || command === "help") {
161
+ io.out(USAGE);
162
+ return command ? 0 : 1;
163
+ }
164
+ if (command !== "init-agent") {
165
+ io.err(`unknown command ${command}
166
+
167
+ ${USAGE}`);
168
+ return 1;
169
+ }
170
+ if (rest.includes("--help") || rest.includes("-h")) {
171
+ io.out(INIT_AGENT_USAGE);
172
+ return 0;
173
+ }
174
+ let options;
175
+ try {
176
+ options = parseInitAgentArgs(rest);
177
+ } catch (e) {
178
+ io.err(e.message);
179
+ return 1;
180
+ }
181
+ const read = (rel) => {
182
+ const full = import_node_path.default.join(io.cwd, rel);
183
+ return import_node_fs.default.existsSync(full) ? import_node_fs.default.readFileSync(full, "utf8") : null;
184
+ };
185
+ let plans;
186
+ try {
187
+ plans = planAgentSetup(options.targets, read);
188
+ } catch (e) {
189
+ io.err(e.message);
190
+ return 1;
191
+ }
192
+ for (const plan of plans) {
193
+ if (!options.dryRun && plan.action !== "unchanged") {
194
+ const full = import_node_path.default.join(io.cwd, plan.path);
195
+ import_node_fs.default.mkdirSync(import_node_path.default.dirname(full), { recursive: true });
196
+ import_node_fs.default.writeFileSync(full, plan.content, "utf8");
197
+ }
198
+ io.out(`${options.dryRun ? "would " : ""}${plan.action === "unchanged" ? "keep" : plan.action} ${plan.path} (${plan.target})`);
199
+ }
200
+ if (!options.dryRun) io.out("\nDone. The full guide is node_modules/@graph8/sdk/docs/agents.md.");
201
+ return 0;
202
+ }
203
+ var invokedDirectly = typeof require !== "undefined" && typeof module !== "undefined" && require.main === module;
204
+ if (invokedDirectly) {
205
+ process.exitCode = runCli(process.argv.slice(2), {
206
+ cwd: process.cwd(),
207
+ out: (l) => process.stdout.write(`${l}
208
+ `),
209
+ err: (l) => process.stderr.write(`${l}
210
+ `)
211
+ });
212
+ }
213
+ // Annotate the CommonJS export names for ESM import in node:
214
+ 0 && (module.exports = {
215
+ runCli
216
+ });