@primitivedotdev/sdk 1.2.1 → 1.4.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/README.md +44 -0
- package/dist/api/index.d.ts +4 -4
- package/dist/api/index.js +3 -3
- package/dist/{api-JvyzQsXn.js → api-DoB7DrgV.js} +364 -22
- package/dist/contract/index.d.ts +2 -2
- package/dist/contract/index.js +1 -1
- package/dist/{errors-7E9sW9eX.d.ts → errors-DyuAXctD.d.ts} +1 -1
- package/dist/{index-DdSffRr0.d.ts → index-BDjVGtc8.d.ts} +455 -7
- package/dist/{index-DR978rq5.d.ts → index-iZWfb98V.d.ts} +275 -4
- package/dist/index.d.ts +8 -6
- package/dist/index.js +7 -4
- package/dist/openapi/index.js +1 -1
- package/dist/{operations.generated-CvXrZUzc.js → operations.generated-XrEy5EtX.js} +636 -3
- package/dist/parser/index.d.ts +1 -1
- package/dist/{types-yNU-Oiea.d.ts → types-QT2ss9ho.d.ts} +207 -3
- package/dist/webhook/index.d.ts +4 -4
- package/dist/webhook/index.js +1 -1
- package/dist/{webhook-BAwK8EOG.js → webhook-CwjCyFv-.js} +2559 -224
- package/dist/x402/index.d.ts +263 -0
- package/dist/x402/index.js +320 -0
- package/package.json +10 -4
|
@@ -615,6 +615,8 @@ const client$1 = createClient(createConfig({ baseUrl: "https://api.primitive.dev
|
|
|
615
615
|
var sdk_gen_exports = /* @__PURE__ */ __exportAll({
|
|
616
616
|
addDomain: () => addDomain,
|
|
617
617
|
cliLogout: () => cliLogout,
|
|
618
|
+
createAgentAccount: () => createAgentAccount,
|
|
619
|
+
createAgentClaimLink: () => createAgentClaimLink,
|
|
618
620
|
createEndpoint: () => createEndpoint,
|
|
619
621
|
createFilter: () => createFilter,
|
|
620
622
|
createFunction: () => createFunction,
|
|
@@ -663,6 +665,7 @@ var sdk_gen_exports = /* @__PURE__ */ __exportAll({
|
|
|
663
665
|
sendEmail: () => sendEmail,
|
|
664
666
|
setFunctionRoute: () => setFunctionRoute,
|
|
665
667
|
setFunctionSecret: () => setFunctionSecret,
|
|
668
|
+
startAgentClaim: () => startAgentClaim,
|
|
666
669
|
startAgentSignup: () => startAgentSignup,
|
|
667
670
|
startCliLogin: () => startCliLogin,
|
|
668
671
|
startCliSignup: () => startCliSignup,
|
|
@@ -674,6 +677,7 @@ var sdk_gen_exports = /* @__PURE__ */ __exportAll({
|
|
|
674
677
|
updateEndpoint: () => updateEndpoint,
|
|
675
678
|
updateFilter: () => updateFilter,
|
|
676
679
|
updateFunction: () => updateFunction,
|
|
680
|
+
verifyAgentClaim: () => verifyAgentClaim,
|
|
677
681
|
verifyAgentSignup: () => verifyAgentSignup,
|
|
678
682
|
verifyCliSignup: () => verifyCliSignup,
|
|
679
683
|
verifyDomain: () => verifyDomain
|
|
@@ -818,6 +822,92 @@ const verifyAgentSignup = (options) => (options.client ?? client$1).post({
|
|
|
818
822
|
}
|
|
819
823
|
});
|
|
820
824
|
/**
|
|
825
|
+
* Create an emailless agent account
|
|
826
|
+
*
|
|
827
|
+
* Creates an emailless agent account without authentication and returns a
|
|
828
|
+
* one-time API key (prefixed `prim_`) plus a provisioned managed inbox.
|
|
829
|
+
* The account is on the `agent` plan: reply-only (it can send only to
|
|
830
|
+
* addresses that have already sent it authenticated mail) with tight send
|
|
831
|
+
* limits. Use the returned `api_key` as a Bearer token on later calls. The
|
|
832
|
+
* account can be upgraded to a full developer account by confirming an
|
|
833
|
+
* email through the claim flow. This endpoint does not require an API key.
|
|
834
|
+
*
|
|
835
|
+
*/
|
|
836
|
+
const createAgentAccount = (options) => (options.client ?? client$1).post({
|
|
837
|
+
url: "/agent/accounts",
|
|
838
|
+
...options,
|
|
839
|
+
headers: {
|
|
840
|
+
...options.body !== void 0 && { "Content-Type": "application/json" },
|
|
841
|
+
...options.headers
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
/**
|
|
845
|
+
* Start an agent account email claim
|
|
846
|
+
*
|
|
847
|
+
* Begins upgrading an emailless `agent` account into a full `developer`
|
|
848
|
+
* account by confirming an email address. Authenticated by the agent's own
|
|
849
|
+
* API key (the org is taken from the credential). Sends a verification
|
|
850
|
+
* code to the supplied email and returns the claim session id plus resend
|
|
851
|
+
* timing. Submit the code to `/agent/claim/verify` to complete the
|
|
852
|
+
* upgrade. Confirming an email that already belongs to a Primitive account
|
|
853
|
+
* is rejected.
|
|
854
|
+
*
|
|
855
|
+
*/
|
|
856
|
+
const startAgentClaim = (options) => (options.client ?? client$1).post({
|
|
857
|
+
security: [{
|
|
858
|
+
scheme: "bearer",
|
|
859
|
+
type: "http"
|
|
860
|
+
}],
|
|
861
|
+
url: "/agent/claim/start",
|
|
862
|
+
...options,
|
|
863
|
+
headers: {
|
|
864
|
+
...options.body !== void 0 && { "Content-Type": "application/json" },
|
|
865
|
+
...options.headers
|
|
866
|
+
}
|
|
867
|
+
});
|
|
868
|
+
/**
|
|
869
|
+
* Verify an agent account email claim
|
|
870
|
+
*
|
|
871
|
+
* Confirms the verification code emailed by `/agent/claim/start` and
|
|
872
|
+
* upgrades the account to the `developer` plan. The org id, API key, and
|
|
873
|
+
* managed inbox all carry over; the send cap lifts. Authenticated by the
|
|
874
|
+
* agent's own API key.
|
|
875
|
+
*
|
|
876
|
+
*/
|
|
877
|
+
const verifyAgentClaim = (options) => (options.client ?? client$1).post({
|
|
878
|
+
security: [{
|
|
879
|
+
scheme: "bearer",
|
|
880
|
+
type: "http"
|
|
881
|
+
}],
|
|
882
|
+
url: "/agent/claim/verify",
|
|
883
|
+
...options,
|
|
884
|
+
headers: {
|
|
885
|
+
...options.body !== void 0 && { "Content-Type": "application/json" },
|
|
886
|
+
...options.headers
|
|
887
|
+
}
|
|
888
|
+
});
|
|
889
|
+
/**
|
|
890
|
+
* Create a browser claim link
|
|
891
|
+
*
|
|
892
|
+
* Mints an opaque, single-use link an agent can hand to a human to
|
|
893
|
+
* complete the email-confirmation upgrade in a browser. Authenticated by
|
|
894
|
+
* the agent's own API key. `claim_url` is null when the API host cannot
|
|
895
|
+
* resolve a web origin to build the link.
|
|
896
|
+
*
|
|
897
|
+
*/
|
|
898
|
+
const createAgentClaimLink = (options) => (options?.client ?? client$1).post({
|
|
899
|
+
security: [{
|
|
900
|
+
scheme: "bearer",
|
|
901
|
+
type: "http"
|
|
902
|
+
}],
|
|
903
|
+
url: "/agent/claim/link",
|
|
904
|
+
...options,
|
|
905
|
+
headers: {
|
|
906
|
+
"Content-Type": "application/json",
|
|
907
|
+
...options?.headers
|
|
908
|
+
}
|
|
909
|
+
});
|
|
910
|
+
/**
|
|
821
911
|
* Revoke the current CLI OAuth session
|
|
822
912
|
*
|
|
823
913
|
* Revokes the OAuth grant used to authenticate the request. API-key
|
|
@@ -1693,10 +1783,12 @@ const listFunctions = (options) => (options?.client ?? client$1).get({
|
|
|
1693
1783
|
* each delivery and forwards the `Primitive-Signature` header to
|
|
1694
1784
|
* the handler. Verify the raw request body with
|
|
1695
1785
|
* `PRIMITIVE_WEBHOOK_SECRET` before parsing JSON; after verification
|
|
1696
|
-
* the request body parses to
|
|
1697
|
-
* `
|
|
1698
|
-
*
|
|
1699
|
-
*
|
|
1786
|
+
* the request body parses to a webhook event whose `event` field is
|
|
1787
|
+
* `email.received` for normal inbound mail, or a machine-mail type
|
|
1788
|
+
* (`email.bounced`, `email.tls_report`, `email.dmarc_report`,
|
|
1789
|
+
* `email.dmarc_failure`) for bounces and reports. Code is bundled
|
|
1790
|
+
* before being uploaded; ship a single self-contained file rather
|
|
1791
|
+
* than relying on external imports.
|
|
1700
1792
|
*
|
|
1701
1793
|
* **Code limits.** `code` is capped at 1 MiB UTF-8. `sourceMap`
|
|
1702
1794
|
* (optional) is capped at 5 MiB UTF-8, stored with each deployment
|
|
@@ -2126,7 +2218,7 @@ const DEFAULT_TOLERANCE_SECONDS = 300;
|
|
|
2126
2218
|
const FUTURE_TOLERANCE_SECONDS = 60;
|
|
2127
2219
|
const HEX_PATTERN = /^[0-9a-f]+$/i;
|
|
2128
2220
|
const HEX_LENGTH = 64;
|
|
2129
|
-
const UNIX_SECONDS_PATTERN = /^\d
|
|
2221
|
+
const UNIX_SECONDS_PATTERN = /^\d+$/;
|
|
2130
2222
|
function parseSignatureHeader(signatureHeader) {
|
|
2131
2223
|
if (!signatureHeader || typeof signatureHeader !== "string") return null;
|
|
2132
2224
|
const parts = signatureHeader.split(",");
|
|
@@ -2343,7 +2435,251 @@ function resolveRequestOptions(options) {
|
|
|
2343
2435
|
if (Object.keys(headers).length > 0) resolved.headers = headers;
|
|
2344
2436
|
return resolved;
|
|
2345
2437
|
}
|
|
2438
|
+
/**
|
|
2439
|
+
* Generic `{ success, data }` envelope unwrap for the simple
|
|
2440
|
+
* data-returning agent operations. Mirrors the error-mapping path of
|
|
2441
|
+
* `unwrapSendResult` so every agent call surfaces a `PrimitiveApiError`
|
|
2442
|
+
* with code / status / request id / retry-after, and re-throws abort and
|
|
2443
|
+
* timeout errors untouched. `label` names the resource in the
|
|
2444
|
+
* empty-body error message.
|
|
2445
|
+
*/
|
|
2446
|
+
function unwrapData(result, label) {
|
|
2447
|
+
const response = result.response;
|
|
2448
|
+
if (result.error) {
|
|
2449
|
+
if (isAbortLikeError(result.error)) throw result.error;
|
|
2450
|
+
const parsed = parseApiErrorPayload(result.error);
|
|
2451
|
+
throw new PrimitiveApiError(parsed.message, {
|
|
2452
|
+
payload: result.error,
|
|
2453
|
+
status: response?.status,
|
|
2454
|
+
code: parsed.code,
|
|
2455
|
+
gates: parsed.gates,
|
|
2456
|
+
requestId: parsed.requestId,
|
|
2457
|
+
retryAfter: parseRetryAfterHeader(response),
|
|
2458
|
+
details: parsed.details,
|
|
2459
|
+
cause: result.error instanceof Error ? result.error : void 0
|
|
2460
|
+
});
|
|
2461
|
+
}
|
|
2462
|
+
if (result.data?.data === void 0) throw new PrimitiveApiError(`Primitive API returned no ${label}`, {
|
|
2463
|
+
payload: result,
|
|
2464
|
+
status: response?.status
|
|
2465
|
+
});
|
|
2466
|
+
return result.data.data;
|
|
2467
|
+
}
|
|
2468
|
+
/**
|
|
2469
|
+
* Agent-account operations, grouped under `client.agent`.
|
|
2470
|
+
*
|
|
2471
|
+
* These cover the emailless agent lifecycle: create a zero-touch account
|
|
2472
|
+
* (no auth required), then later upgrade it to a full developer account by
|
|
2473
|
+
* confirming an email (the claim flow, authenticated by the agent's own
|
|
2474
|
+
* API key). Field shapes are the generated request/response types, matching
|
|
2475
|
+
* the documented API surface.
|
|
2476
|
+
*/
|
|
2477
|
+
var AgentResource = class {
|
|
2478
|
+
constructor(client) {
|
|
2479
|
+
this.client = client;
|
|
2480
|
+
}
|
|
2481
|
+
/**
|
|
2482
|
+
* Create an emailless agent account. Unauthenticated: call this on a
|
|
2483
|
+
* client constructed without an API key. Returns a one-time `api_key`
|
|
2484
|
+
* (prefixed `prim_`, shown once) plus a provisioned managed inbox. The
|
|
2485
|
+
* account is on the reply-only `agent` plan and can be upgraded later via
|
|
2486
|
+
* the claim flow.
|
|
2487
|
+
*/
|
|
2488
|
+
async createAccount(input, options) {
|
|
2489
|
+
return unwrapData(await createAgentAccount({
|
|
2490
|
+
body: input,
|
|
2491
|
+
...resolveRequestOptions(options),
|
|
2492
|
+
client: this.client,
|
|
2493
|
+
responseStyle: "fields"
|
|
2494
|
+
}), "agent account");
|
|
2495
|
+
}
|
|
2496
|
+
/**
|
|
2497
|
+
* Start the email-claim upgrade for the authenticated agent account.
|
|
2498
|
+
* Sends a verification code to `email` and returns the claim session id
|
|
2499
|
+
* plus resend timing. Authenticated by the agent's own API key.
|
|
2500
|
+
*/
|
|
2501
|
+
async claimStart(input, options) {
|
|
2502
|
+
return unwrapData(await startAgentClaim({
|
|
2503
|
+
body: input,
|
|
2504
|
+
...resolveRequestOptions(options),
|
|
2505
|
+
client: this.client,
|
|
2506
|
+
responseStyle: "fields"
|
|
2507
|
+
}), "claim start result");
|
|
2508
|
+
}
|
|
2509
|
+
/**
|
|
2510
|
+
* Confirm the claim verification code and upgrade the account to the
|
|
2511
|
+
* `developer` plan. The org id, API key, and managed inbox carry over;
|
|
2512
|
+
* the send cap lifts.
|
|
2513
|
+
*/
|
|
2514
|
+
async claimVerify(input, options) {
|
|
2515
|
+
return unwrapData(await verifyAgentClaim({
|
|
2516
|
+
body: input,
|
|
2517
|
+
...resolveRequestOptions(options),
|
|
2518
|
+
client: this.client,
|
|
2519
|
+
responseStyle: "fields"
|
|
2520
|
+
}), "claim result");
|
|
2521
|
+
}
|
|
2522
|
+
/**
|
|
2523
|
+
* Mint a browser claim link to hand to a human for the email-confirmation
|
|
2524
|
+
* upgrade. `claim_url` is null when the API host has no web origin to
|
|
2525
|
+
* build the link.
|
|
2526
|
+
*/
|
|
2527
|
+
async claimLink(input = {}, options) {
|
|
2528
|
+
return unwrapData(await createAgentClaimLink({
|
|
2529
|
+
body: input,
|
|
2530
|
+
...resolveRequestOptions(options),
|
|
2531
|
+
client: this.client,
|
|
2532
|
+
responseStyle: "fields"
|
|
2533
|
+
}), "claim link result");
|
|
2534
|
+
}
|
|
2535
|
+
};
|
|
2536
|
+
const INBOX_EPOCH_CURSOR = "1970-01-01T00:00:00.000000Z|00000000-0000-0000-0000-000000000000";
|
|
2537
|
+
const DEFAULT_WAIT_SECONDS = 30;
|
|
2538
|
+
function buildReplyBody(input) {
|
|
2539
|
+
const resolved = typeof input === "string" ? { text: input } : input;
|
|
2540
|
+
if ("subject" in resolved) throw new TypeError("reply does not support a subject override; the server prepends 'Re:' to the parent's subject for thread continuity");
|
|
2541
|
+
if (!resolved.text && !resolved.html) throw new TypeError("reply requires text or html");
|
|
2542
|
+
return {
|
|
2543
|
+
...resolved.text !== void 0 ? { body_text: resolved.text } : {},
|
|
2544
|
+
...resolved.html !== void 0 ? { body_html: resolved.html } : {},
|
|
2545
|
+
...resolved.from !== void 0 ? { from: resolved.from } : {},
|
|
2546
|
+
...resolved.attachments !== void 0 ? { attachments: resolved.attachments } : {},
|
|
2547
|
+
...resolved.wait !== void 0 ? { wait: resolved.wait } : {}
|
|
2548
|
+
};
|
|
2549
|
+
}
|
|
2550
|
+
async function replyById(client, id, input, options) {
|
|
2551
|
+
return unwrapSendResult(await replyToEmail({
|
|
2552
|
+
body: buildReplyBody(input),
|
|
2553
|
+
path: { id },
|
|
2554
|
+
...resolveRequestOptions(options),
|
|
2555
|
+
client,
|
|
2556
|
+
responseStyle: "fields"
|
|
2557
|
+
}));
|
|
2558
|
+
}
|
|
2559
|
+
function toInboundEmail(row, cursor, client) {
|
|
2560
|
+
return {
|
|
2561
|
+
id: row.id,
|
|
2562
|
+
messageId: row.message_id ?? null,
|
|
2563
|
+
from: row.sender,
|
|
2564
|
+
to: row.recipient,
|
|
2565
|
+
subject: row.subject ?? null,
|
|
2566
|
+
status: row.status,
|
|
2567
|
+
domain: row.domain,
|
|
2568
|
+
spamScore: row.spam_score ?? null,
|
|
2569
|
+
threadId: row.thread_id ?? null,
|
|
2570
|
+
createdAt: row.created_at,
|
|
2571
|
+
receivedAt: row.received_at,
|
|
2572
|
+
cursor,
|
|
2573
|
+
reply: (input, options) => replyById(client, row.id, input, options)
|
|
2574
|
+
};
|
|
2575
|
+
}
|
|
2576
|
+
/** Unwrap a `listEmails` page into rows + the next forward-tail cursor. */
|
|
2577
|
+
function unwrapInboxPage(result) {
|
|
2578
|
+
const response = result.response;
|
|
2579
|
+
if (result.error) {
|
|
2580
|
+
if (isAbortLikeError(result.error)) throw result.error;
|
|
2581
|
+
const parsed = parseApiErrorPayload(result.error);
|
|
2582
|
+
throw new PrimitiveApiError(parsed.message, {
|
|
2583
|
+
payload: result.error,
|
|
2584
|
+
status: response?.status,
|
|
2585
|
+
code: parsed.code,
|
|
2586
|
+
gates: parsed.gates,
|
|
2587
|
+
requestId: parsed.requestId,
|
|
2588
|
+
retryAfter: parseRetryAfterHeader(response),
|
|
2589
|
+
details: parsed.details,
|
|
2590
|
+
cause: result.error instanceof Error ? result.error : void 0
|
|
2591
|
+
});
|
|
2592
|
+
}
|
|
2593
|
+
return {
|
|
2594
|
+
emails: result.data?.data ?? [],
|
|
2595
|
+
cursor: result.data?.meta?.cursor ?? null
|
|
2596
|
+
};
|
|
2597
|
+
}
|
|
2598
|
+
/**
|
|
2599
|
+
* Inbound mail, grouped under `client.inbox`. Wraps the GET /v1/emails forward
|
|
2600
|
+
* tail (`?since` + `?wait` long-poll) so an agent's receive loop is a single
|
|
2601
|
+
* `for await`, with the cursor advanced for you.
|
|
2602
|
+
*/
|
|
2603
|
+
var InboxResource = class {
|
|
2604
|
+
constructor(client) {
|
|
2605
|
+
this.client = client;
|
|
2606
|
+
}
|
|
2607
|
+
/**
|
|
2608
|
+
* Stream inbound emails as they arrive. Long-polls the forward tail, yielding
|
|
2609
|
+
* one email at a time and advancing the cursor. Resumes from `since` (omit to
|
|
2610
|
+
* start oldest-first); stops when `signal` aborts.
|
|
2611
|
+
*
|
|
2612
|
+
* for await (const email of client.inbox.stream()) {
|
|
2613
|
+
* await email.reply("got it");
|
|
2614
|
+
* }
|
|
2615
|
+
*/
|
|
2616
|
+
async *stream(options = {}) {
|
|
2617
|
+
let since = options.since ?? INBOX_EPOCH_CURSOR;
|
|
2618
|
+
const wait = options.waitSeconds ?? DEFAULT_WAIT_SECONDS;
|
|
2619
|
+
while (!options.signal?.aborted) {
|
|
2620
|
+
const result = await listEmails({
|
|
2621
|
+
query: {
|
|
2622
|
+
since,
|
|
2623
|
+
wait,
|
|
2624
|
+
limit: 1
|
|
2625
|
+
},
|
|
2626
|
+
...resolveRequestOptions({ signal: options.signal }),
|
|
2627
|
+
client: this.client,
|
|
2628
|
+
responseStyle: "fields"
|
|
2629
|
+
});
|
|
2630
|
+
const { emails, cursor } = unwrapInboxPage(result);
|
|
2631
|
+
if (emails.length > 0 && cursor === null) throw new PrimitiveApiError("Forward tail returned emails without a continuation cursor; refusing to advance to avoid re-yielding the same mail.", { payload: result });
|
|
2632
|
+
for (const row of emails) yield toInboundEmail(row, cursor ?? since, this.client);
|
|
2633
|
+
if (cursor) since = cursor;
|
|
2634
|
+
}
|
|
2635
|
+
}
|
|
2636
|
+
/**
|
|
2637
|
+
* Resolve with the next inbound email after `since`, or null if none arrives
|
|
2638
|
+
* within the wait window. One-shot form of `stream`; pass your current cursor
|
|
2639
|
+
* as `since` to wait for genuinely new mail.
|
|
2640
|
+
*/
|
|
2641
|
+
async waitForNext(options = {}) {
|
|
2642
|
+
const result = await listEmails({
|
|
2643
|
+
query: {
|
|
2644
|
+
since: options.since ?? INBOX_EPOCH_CURSOR,
|
|
2645
|
+
wait: options.waitSeconds ?? DEFAULT_WAIT_SECONDS,
|
|
2646
|
+
limit: 1
|
|
2647
|
+
},
|
|
2648
|
+
...resolveRequestOptions({ signal: options.signal }),
|
|
2649
|
+
client: this.client,
|
|
2650
|
+
responseStyle: "fields"
|
|
2651
|
+
});
|
|
2652
|
+
const { emails, cursor } = unwrapInboxPage(result);
|
|
2653
|
+
if (emails.length === 0) return null;
|
|
2654
|
+
if (cursor === null) throw new PrimitiveApiError("Forward tail returned an email without a continuation cursor.", { payload: result });
|
|
2655
|
+
return toInboundEmail(emails[0], cursor, this.client);
|
|
2656
|
+
}
|
|
2657
|
+
};
|
|
2658
|
+
/** Account introspection, grouped under `client.account`. */
|
|
2659
|
+
var AccountResource = class {
|
|
2660
|
+
constructor(client) {
|
|
2661
|
+
this.client = client;
|
|
2662
|
+
}
|
|
2663
|
+
/**
|
|
2664
|
+
* The authenticated account: plan, limits, granted `entitlements` (e.g. an
|
|
2665
|
+
* emailless agent sees only reply-only keys), and `managed_inbox_address`
|
|
2666
|
+
* (the From address to reply as).
|
|
2667
|
+
*/
|
|
2668
|
+
async get(options) {
|
|
2669
|
+
return unwrapData(await getAccount({
|
|
2670
|
+
...resolveRequestOptions(options),
|
|
2671
|
+
client: this.client,
|
|
2672
|
+
responseStyle: "fields"
|
|
2673
|
+
}), "account");
|
|
2674
|
+
}
|
|
2675
|
+
};
|
|
2346
2676
|
var PrimitiveClient = class extends PrimitiveApiClient {
|
|
2677
|
+
/** Agent-account lifecycle operations (create, claim/upgrade). */
|
|
2678
|
+
agent = new AgentResource(this.client);
|
|
2679
|
+
/** Inbound mail: long-poll stream + waitForNext over the forward tail. */
|
|
2680
|
+
inbox = new InboxResource(this.client);
|
|
2681
|
+
/** Account introspection (plan, limits, entitlements, managed inbox). */
|
|
2682
|
+
account = new AccountResource(this.client);
|
|
2347
2683
|
async send(input, options) {
|
|
2348
2684
|
validateSendInput(input);
|
|
2349
2685
|
return unwrapSendResult(await sendEmail({
|
|
@@ -2397,22 +2733,7 @@ var PrimitiveClient = class extends PrimitiveApiClient {
|
|
|
2397
2733
|
* thread for half the recipient population.
|
|
2398
2734
|
*/
|
|
2399
2735
|
async reply(email, input, options) {
|
|
2400
|
-
|
|
2401
|
-
if ("subject" in resolved) throw new TypeError("reply does not support a subject override; the server prepends 'Re:' to the parent's subject for thread continuity");
|
|
2402
|
-
if (!resolved.text && !resolved.html) throw new TypeError("reply requires text or html");
|
|
2403
|
-
return unwrapSendResult(await replyToEmail({
|
|
2404
|
-
body: {
|
|
2405
|
-
...resolved.text !== void 0 ? { body_text: resolved.text } : {},
|
|
2406
|
-
...resolved.html !== void 0 ? { body_html: resolved.html } : {},
|
|
2407
|
-
...resolved.from !== void 0 ? { from: resolved.from } : {},
|
|
2408
|
-
...resolved.attachments !== void 0 ? { attachments: resolved.attachments } : {},
|
|
2409
|
-
...resolved.wait !== void 0 ? { wait: resolved.wait } : {}
|
|
2410
|
-
},
|
|
2411
|
-
path: { id: email.id },
|
|
2412
|
-
...resolveRequestOptions(options),
|
|
2413
|
-
client: this.client,
|
|
2414
|
-
responseStyle: "fields"
|
|
2415
|
-
}));
|
|
2736
|
+
return replyById(this.client, email.id, input, options);
|
|
2416
2737
|
}
|
|
2417
2738
|
async forward(email, input, options) {
|
|
2418
2739
|
validateForwardInput(input);
|
|
@@ -2469,6 +2790,7 @@ function mapSendResult(result) {
|
|
|
2469
2790
|
return {
|
|
2470
2791
|
id: result.id,
|
|
2471
2792
|
status: result.status,
|
|
2793
|
+
from: result.from,
|
|
2472
2794
|
queueId: result.queue_id,
|
|
2473
2795
|
accepted: result.accepted,
|
|
2474
2796
|
rejected: result.rejected,
|
|
@@ -2512,5 +2834,25 @@ function createPrimitiveClient(options = {}) {
|
|
|
2512
2834
|
function client(options = {}) {
|
|
2513
2835
|
return new PrimitiveClient(options);
|
|
2514
2836
|
}
|
|
2837
|
+
/**
|
|
2838
|
+
* Zero-to-receiving in one call: create an emailless agent account (no auth)
|
|
2839
|
+
* and return a PrimitiveClient already wired with its one-time API key, plus
|
|
2840
|
+
* the provisioned managed inbox. From here `result.client.inbox.stream()` and
|
|
2841
|
+
* `result.client.send(...)` work immediately.
|
|
2842
|
+
*
|
|
2843
|
+
* const { client, address } = await createAgent({ terms_accepted: true });
|
|
2844
|
+
*/
|
|
2845
|
+
async function createAgent(options) {
|
|
2846
|
+
const { client: clientOptions, ...input } = options;
|
|
2847
|
+
const account = await new PrimitiveClient(clientOptions).agent.createAccount(input);
|
|
2848
|
+
return {
|
|
2849
|
+
client: new PrimitiveClient({
|
|
2850
|
+
...clientOptions,
|
|
2851
|
+
apiKey: account.api_key
|
|
2852
|
+
}),
|
|
2853
|
+
address: account.address,
|
|
2854
|
+
account
|
|
2855
|
+
};
|
|
2856
|
+
}
|
|
2515
2857
|
//#endregion
|
|
2516
|
-
export {
|
|
2858
|
+
export { listSentEmails as $, downloadDomainZoneFile as A, createConfig as At, getSendPermissions as B, deleteEmail as C, updateFilter as Ct, deleteFunctionSecret as D, verifyCliSignup as Dt, deleteFunction as E, verifyAgentSignup as Et, getFunction as F, listDeliveries as G, getStorageStats as H, getFunctionRouting as I, listEndpoints as J, listDomains as K, getFunctionTestRunTrace as L, getAccount as M, getConversation as N, discardEmailContent as O, verifyDomain as Ot, getEmail as P, listFunctions as Q, getInboxStatus as R, deleteDomain as S, updateEndpoint as St, deleteFilter as T, verifyAgentClaim as Tt, getThread as U, getSentEmail as V, getWebhookSecret as W, listFunctionLogs as X, listFilters as Y, listFunctionSecrets as Z, createAgentClaimLink as _, testEndpoint as _t, client as a, resendCliSignupVerification as at, createFunction as b, updateAccount as bt, PRIMITIVE_SIGNATURE_HEADER as c, searchEmails as ct, PrimitiveApiClient as d, setFunctionRoute as dt, pollCliLogin as et, PrimitiveApiError as f, setFunctionSecret as ft, createAgentAccount as g, startCliSignup as gt, cliLogout as h, startCliLogin as ht, PrimitiveClient as i, resendAgentSignupVerification as it, downloadRawEmail as j, downloadAttachments as k, createClient as kt, verifyWebhookSignature as l, semanticSearch as lt, addDomain as m, startAgentSignup as mt, AgentResource as n, replayEmailWebhooks as nt, createAgent as o, rotateWebhookSecret as ot, createPrimitiveApiClient as p, startAgentClaim as pt, listEmails as q, InboxResource as r, replyToEmail as rt, createPrimitiveClient as s, sdk_gen_exports as st, AccountResource as t, replayDelivery as tt, DEFAULT_API_BASE_URL as u, sendEmail as ut, createEndpoint as v, testFunction as vt, deleteEndpoint as w, updateFunction as wt, createFunctionSecret as x, updateDomain as xt, createFilter as y, unsetFunctionRoute as yt, getOrgRoutingTopology as z };
|
package/dist/contract/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { C as signStandardWebhooksPayload, h as WEBHOOK_VERSION, j as signWebhookPayload, k as SignResult, x as StandardWebhooksSignResult } from "../index-
|
|
1
|
+
import { A as RawContentInline, E as ParsedError, F as WebhookAttachment, T as ParsedDataFailed, d as EmailAuth, f as EmailReceivedEvent, k as RawContentDownloadOnly, l as EmailAddress, u as EmailAnalysis, w as ParsedDataComplete } from "../types-QT2ss9ho.js";
|
|
2
|
+
import { C as signStandardWebhooksPayload, h as WEBHOOK_VERSION, j as signWebhookPayload, k as SignResult, x as StandardWebhooksSignResult } from "../index-iZWfb98V.js";
|
|
3
3
|
|
|
4
4
|
//#region src/contract/contract.d.ts
|
|
5
5
|
/** Maximum raw email size for inline inclusion (256 KB). */
|
package/dist/contract/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as signStandardWebhooksPayload, L as validateEmailReceivedEvent, M as signWebhookPayload, d as WEBHOOK_VERSION } from "../webhook-
|
|
1
|
+
import { E as signStandardWebhooksPayload, L as validateEmailReceivedEvent, M as signWebhookPayload, d as WEBHOOK_VERSION } from "../webhook-CwjCyFv-.js";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
//#region src/contract/contract.ts
|
|
4
4
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as WebhookAttachment, d as EmailAuth, f as EmailReceivedEvent, u as EmailAnalysis } from "./types-QT2ss9ho.js";
|
|
2
2
|
import { ErrorObject } from "ajv";
|
|
3
3
|
|
|
4
4
|
//#region src/webhook/received-email.d.ts
|