@jini-ai/platform 0.6.23 → 0.7.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/CHANGELOG.md CHANGED
@@ -1,3 +1,30 @@
1
+ ## 0.7.0
2
+
3
+ ### Minor Changes
4
+
5
+ - c393010: Publish the A2 mail seams: platform exposes `toPluginHttpClient`, `fromPositionalMailer`,
6
+ `toPositionalMailer` and `createProviderMailer`; agent-plugins exposes
7
+ `createMailContributions`, `createMailCatalog`, `createMailConfiguration`,
8
+ `createMailSelection` and `createHostMailer`.
9
+
10
+ Hosts inject `parseSetup` and their credential-label policy. The legacy raw-only
11
+ `parseMailAdaptersFile({ raw }, optional)` call remains supported through a local
12
+ validation boundary, preserving declared setup validation and v1/v2 descriptors.
13
+ Provider-status and credential-save factories also require host wording and catalog
14
+ provenance so a second host supplies its own navigation without changing Tovu bytes.
15
+
16
+ ### Patch Changes
17
+
18
+ - 699b478: Expose six type-only contract areas in core and retain existing type exports. Reconcile card contracts with the complete UI presentation shapes so hosts can wire package objects without cross-package type imports.
19
+ - Updated dependencies [8fe045b]
20
+ - Updated dependencies [41ff2ff]
21
+ - Updated dependencies [a266ba8]
22
+ - Updated dependencies [27063ef]
23
+ - Updated dependencies [6ab1d81]
24
+ - Updated dependencies [699b478]
25
+ - Updated dependencies [39cf677]
26
+ - @jini-ai/core@0.7.0
27
+
1
28
  ## 0.6.23
2
29
 
3
30
  - Security hardening.
@@ -55,7 +55,6 @@
55
55
  * caller-supplied `init.signal` — is what ended the call, so a caller can tell "this took too long"
56
56
  * apart from "I cancelled it myself" without string-matching an error message. */
57
57
  export declare class FetchTimeoutError extends Error {
58
- readonly url: string;
59
58
  readonly timeoutMs: number;
60
59
  constructor(url: string, timeoutMs: number);
61
60
  }
@@ -55,12 +55,11 @@
55
55
  * caller-supplied `init.signal` — is what ended the call, so a caller can tell "this took too long"
56
56
  * apart from "I cancelled it myself" without string-matching an error message. */
57
57
  export class FetchTimeoutError extends Error {
58
- url;
59
58
  timeoutMs;
60
59
  constructor(url, timeoutMs) {
61
- super(`fetch timed out after ${timeoutMs}ms: ${url}`);
60
+ // Error objects reach logs; the origin is enough to identify the server.
61
+ super(`fetch timed out after ${timeoutMs}ms: ${URL.canParse(url) ? new URL(url).origin : "the requested server"}`);
62
62
  this.name = "FetchTimeoutError";
63
- this.url = url;
64
63
  this.timeoutMs = timeoutMs;
65
64
  }
66
65
  }
@@ -0,0 +1,8 @@
1
+ /** Preserve the original before a personal-config change; never replace the first backup.
2
+ * Call under the destination's write lock. Only an existing backup is ignored.
3
+ * @complexity O(file bytes) time, O(1) space; one exclusive filesystem copy.
4
+ */
5
+ export declare function backupOriginalOnce({ filePath }: {
6
+ filePath: string;
7
+ }, _options?: Record<string, never>): Promise<void>;
8
+ //# sourceMappingURL=backup-once.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { constants, promises as fs } from 'node:fs';
2
+ /** Preserve the original before a personal-config change; never replace the first backup.
3
+ * Call under the destination's write lock. Only an existing backup is ignored.
4
+ * @complexity O(file bytes) time, O(1) space; one exclusive filesystem copy.
5
+ */
6
+ export async function backupOriginalOnce({ filePath }, _options = {}) {
7
+ await fs.copyFile(filePath, `${filePath}.jini-backup`, constants.COPYFILE_EXCL)
8
+ .catch((error) => { if (error.code !== 'EEXIST')
9
+ throw error; });
10
+ }
11
+ //# sourceMappingURL=backup-once.js.map
@@ -13,4 +13,5 @@ export { DirectoryUserConfigRefusal, validateDirectoryUserConfig } from "./direc
13
13
  export * from "./workspace-directory.js";
14
14
  export * from "./verified-directory-move.js";
15
15
  export * from "./reviewed-file.js";
16
+ export { backupOriginalOnce } from './backup-once.js';
16
17
  //# sourceMappingURL=index.d.ts.map
package/dist/fs/index.js CHANGED
@@ -14,4 +14,5 @@ export { DirectoryUserConfigRefusal, validateDirectoryUserConfig } from "./direc
14
14
  export * from "./workspace-directory.js";
15
15
  export * from "./verified-directory-move.js";
16
16
  export * from "./reviewed-file.js";
17
+ export { backupOriginalOnce } from './backup-once.js';
17
18
  //# sourceMappingURL=index.js.map
@@ -101,8 +101,8 @@ function capBody(bodyText, maxBytes) {
101
101
  // so a complete binary body can have a decoded text representation that crosses the cap.
102
102
  // The byte-specific flag prevents falsely treating that complete file as corrupt; the coarse
103
103
  // bodyTruncated flag remains the OR for callers that consume text.
104
- function capResponse(response, maxBytes) {
105
- const bodyText = capBody(response.bodyText, maxBytes);
104
+ function capResponse({ response, maxBytes, bodyAs }) {
105
+ const bodyText = bodyAs === "bytes" ? "" : capBody(response.bodyText, maxBytes);
106
106
  const bytes = response.bodyBytes;
107
107
  const bytesOverCap = bytes !== undefined && bytes.byteLength > maxBytes;
108
108
  // A producer's coarse flag names no shape and counts against both unless its byte flag says
@@ -115,7 +115,7 @@ function capResponse(response, maxBytes) {
115
115
  ...(bytes !== undefined
116
116
  ? { bodyBytes: bytesOverCap ? bytes.subarray(0, maxBytes) : bytes, bodyBytesTruncated: bytesTruncated }
117
117
  : {}),
118
- bodyTruncated: bodyText !== response.bodyText || bytesOverCap || producerTruncated,
118
+ bodyTruncated: (bodyAs !== "bytes" && bodyText !== response.bodyText) || bytesOverCap || producerTruncated,
119
119
  };
120
120
  }
121
121
  const REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]);
@@ -147,7 +147,7 @@ async function sendOneHop({ hop, request, url }, _options = {}) {
147
147
  const effectiveCap = Math.min(request.maxResponseBytes ?? Infinity, hop.policy.maxResponseBytes, hop.policy.maxDecompressedBytes);
148
148
  // Record the normalized URL actually resolved and pinned, not the caller's original spelling.
149
149
  // A followed redirect returns the deeper hop's response, including that hop's finalUrl.
150
- const cappedResponse = { ...capResponse(response, effectiveCap), finalUrl: url.href };
150
+ const cappedResponse = { ...capResponse({ response, maxBytes: effectiveCap, bodyAs: request.bodyAs }), finalUrl: url.href };
151
151
  // A refused redirect is a policy decision like a refused address, so it carries the same type.
152
152
  // The text names no Location target, which may be private, so both messages can share it.
153
153
  if (hop.redirect === "error" && REDIRECT_STATUSES.has(cappedResponse.status)) {
@@ -6,10 +6,10 @@ import { createBrotliDecompress, createGunzip, createInflate } from "node:zlib";
6
6
  * could change the destination between validation and connection. Preserve the original Host
7
7
  * authority and hostname TLS SNI for virtual hosting and certificate validation.
8
8
  * This raw transport belongs behind the guarded client, which validates each redirect hop.
9
- * Responses are buffered; the absolute ceiling bounds memory even without a caller byte limit.
9
+ * Responses are buffered; the default ceiling bounds memory when no caller byte limit is given.
10
10
  */
11
- /** Last-resort decoded-byte bound independent of any caller's response policy. */
12
- const ABSOLUTE_MAX_BYTES = 100 * 1024 * 1024;
11
+ /** Decoded-byte bound when the caller has not supplied its own response policy. */
12
+ const DEFAULT_MAX_BYTES = 100 * 1024 * 1024;
13
13
  export class FetchHttpTransportAdapter {
14
14
  optional;
15
15
  constructor(_required, optional = {}) {
@@ -47,15 +47,16 @@ export class FetchHttpTransportAdapter {
47
47
  // Concatenate once: text is a lossy UTF-8 view, while binary consumers retain the same
48
48
  // undecoded bytes. Buffer is a Uint8Array, so returning it needs no second byte copy.
49
49
  const body = Buffer.concat(chunks);
50
+ chunks.length = 0;
50
51
  resolve({
51
52
  status: res.statusCode ?? 0,
52
53
  headers: flattenHeaders(res.headers),
53
54
  setCookies: res.headers["set-cookie"] ?? [],
54
- bodyText: body.toString("utf8"), bodyBytes: body,
55
+ bodyText: req.bodyAs === "bytes" ? "" : body.toString("utf8"), bodyBytes: body,
55
56
  ...(truncated ? { bodyTruncated: true, bodyBytesTruncated: true } : {}),
56
57
  });
57
58
  };
58
- const cap = req.maxResponseBytes === undefined ? ABSOLUTE_MAX_BYTES : Math.min(req.maxResponseBytes, ABSOLUTE_MAX_BYTES);
59
+ const cap = req.maxResponseBytes ?? DEFAULT_MAX_BYTES;
59
60
  decoded.on("data", (chunk) => {
60
61
  if (settled)
61
62
  return;
@@ -1,22 +1,5 @@
1
- import type { HttpClientPort } from "@jini-ai/core/primitives";
2
- import type { MailerPort } from "./ports.js";
3
- export interface MailAdapterCredential {
4
- readonly token: string;
5
- readonly baseUrl?: string;
6
- readonly username?: string;
7
- }
8
- export interface MailAdapterKit {
9
- /** Provider requests must use the guarded outbound HTTP seam so its egress policy applies. */
10
- readonly httpClient: HttpClientPort;
11
- }
12
- export interface MailAdapterCreateContext {
13
- readonly credential: MailAdapterCredential;
14
- readonly kit: MailAdapterKit;
15
- /** Sample at the point of use. Hosts normalize this to the real clock when omitted. */
16
- readonly now?: () => Date;
17
- /** Per-install configuration; only the provider module owns its schema and validation. */
18
- readonly settings?: unknown;
19
- }
1
+ import type { MailAdapterCredential, MailAdapterKit, MailAdapterCreateContext } from '@jini-ai/core/contracts/mail';
2
+ export type { MailAdapterCredential, MailAdapterKit, MailAdapterCreateContext, MailAdapterModule } from '@jini-ai/core/contracts/mail';
20
3
  /**
21
4
  * Normalize a host's module context without inspecting settings or replacing its guarded ports.
22
5
  * The optional fields on {@link MailAdapterCreateContext} preserve legacy direct create calls;
@@ -31,14 +14,4 @@ export declare function createMailAdapterContext(required: {
31
14
  credential: MailAdapterCredential;
32
15
  kit: MailAdapterKit;
33
16
  }, { now, settings }?: Pick<MailAdapterCreateContext, "now" | "settings">): Required<MailAdapterCreateContext>;
34
- /** Provider modules return the ordinary mail port; the shared contract names no vendor. */
35
- export interface MailAdapterModule {
36
- /** Optional host-resolved account connection for domain reads only. The host validates the
37
- * HTTPS origin and plugin ownership; this credential must never replace the sending key. */
38
- readonly domainReadConnection?: {
39
- readonly serverId: string;
40
- readonly baseUrl: string;
41
- };
42
- create(context: MailAdapterCreateContext): MailerPort;
43
- }
44
17
  //# sourceMappingURL=adapter-module.d.ts.map
@@ -1,129 +1,2 @@
1
- import type { MailAdapterCredential } from "./adapter-module.js";
2
- import type { MailDomainState, MailProviderCapabilities, MailProviderRegistry, MailProviderSetting, MailStatus } from "./provider.js";
3
- /** Metadata only: the host reads these facts before decrypting a credential. */
4
- export interface MailCredentialFact {
5
- readonly id: string;
6
- readonly label: string;
7
- readonly vaultRevision?: number;
8
- readonly updatedAt: string;
9
- }
10
- /** Credential presence exposed in configuration reports; never a token or username. */
11
- export interface MailProviderCredentialFacts {
12
- readonly required: boolean;
13
- readonly saved: boolean;
14
- readonly label?: string;
15
- readonly credentialId?: string;
16
- readonly updatedAt?: string;
17
- }
18
- /** Declarative setup copy belongs to the host or plugin. */
19
- export interface MailProviderField {
20
- readonly key: string;
21
- readonly label: string;
22
- readonly type: "secret" | "text" | "url" | "email";
23
- readonly required: boolean;
24
- readonly defaultValue?: string;
25
- readonly placeholder?: string;
26
- readonly help?: string;
27
- readonly helpUrl?: string;
28
- }
29
- export interface MailProviderSetup {
30
- readonly fields: readonly MailProviderField[];
31
- readonly helpUrl?: string;
32
- }
33
- /** Safe host-supplied projection; configuration building and product copy stay in the host. */
34
- export interface MailProviderConfiguration {
35
- readonly pluginId?: string;
36
- readonly id: string;
37
- readonly label: string;
38
- readonly origin: "core" | "plugin";
39
- readonly hosted: boolean;
40
- readonly lanes: readonly ("transactional" | "bulk")[];
41
- readonly capabilities: Pick<MailProviderCapabilities, "feedback" | "domainVerification" | "rateLimit">;
42
- readonly credential: MailProviderCredentialFacts;
43
- readonly selectable: boolean;
44
- readonly refusal?: string;
45
- readonly setup: MailProviderSetup;
46
- }
47
- export interface MailProviderConfigurationReport {
48
- readonly setting: MailProviderSetting;
49
- readonly providers: readonly MailProviderConfiguration[];
50
- readonly refusals: readonly string[];
51
- }
52
- /** A provider failure safe for callers; contains neither credentials nor message bodies. */
53
- export interface MailProviderError {
54
- readonly at: string;
55
- readonly providerId: string | null;
56
- readonly source: "send" | "check";
57
- readonly code?: string;
58
- readonly message: string;
59
- }
60
- /** Alias the provider's existing verdict vocabulary instead of defining another taxonomy. */
61
- export type ProviderDomainState = MailDomainState;
62
- /** Provider verification is independent of DNS answers and credential presence. */
63
- export type SenderDomainVerification = {
64
- state: ProviderDomainState;
65
- domain: string;
66
- providerId: string;
67
- } | {
68
- state: "no_sender";
69
- providerId: string | null;
70
- } | {
71
- state: "no_provider";
72
- domain: string;
73
- providerId: string | null;
74
- } | {
75
- state: "unsupported";
76
- domain: string;
77
- providerId: string;
78
- } | {
79
- state: "unknown";
80
- domain?: string;
81
- providerId: string | null;
82
- reason: string;
83
- };
84
- export interface MailStatusReport extends MailStatus {
85
- readonly senderDomainVerification?: SenderDomainVerification;
86
- readonly providers: readonly MailProviderConfiguration[];
87
- readonly refusals: readonly string[];
88
- readonly checkedAt: string;
89
- readonly lastError?: MailProviderError;
90
- }
91
- export type MailProviderCheck = {
92
- ok: true;
93
- label: string;
94
- } | {
95
- ok: false;
96
- reason: string;
97
- };
98
- /** Host-built catalog: trusted loading, labels and setup copy remain outside the engine. */
99
- export interface MailProviderCatalog {
100
- readonly registry: MailProviderRegistry;
101
- readonly pluginIds: readonly string[];
102
- readonly refusals: readonly string[];
103
- credentialLabelFor(required: {
104
- id: string;
105
- }): string | undefined;
106
- setupFor(required: {
107
- id: string;
108
- }): MailProviderSetup;
109
- }
110
- /** Host settings adapter; reads do not infer provider selection from saved credentials. */
111
- export interface MailProviderSettingPort {
112
- read(required: Record<string, never>): Promise<MailProviderSetting | null>;
113
- write(required: {
114
- setting: MailProviderSetting;
115
- }): Promise<void>;
116
- }
117
- /** Host owns metadata lookup and decryption. Metadata may fail independently of key resolution. */
118
- export interface MailCredentialPort {
119
- readFact(required: {
120
- label: string;
121
- }): Promise<MailCredentialFact | undefined>;
122
- resolve(required: {
123
- catalog: MailProviderCatalog;
124
- id: string;
125
- }): Promise<MailAdapterCredential | null>;
126
- }
127
- /** Read-only provider verdict; implementations return unknown on lookup/provider failures. */
128
- export type SenderDomainVerificationPort = () => Promise<SenderDomainVerification>;
1
+ export type * from '@jini-ai/core/contracts/mail';
129
2
  //# sourceMappingURL=engine-contracts.d.ts.map
@@ -29,4 +29,7 @@ export type { ResolveMailerDeps, ResolveMailerOptions, ResolvedMailer } from "./
29
29
  export { createTtlCache, MAIL_STATUS_TTL_MS } from "./mail-status-cache.js";
30
30
  export type { TtlCache } from "./mail-status-cache.js";
31
31
  export * from "./senders.js";
32
+ export { defaultMailProviderSetup, parseMailProviderSetup, parseMailProviderSetupProperty } from "./provider-setup.js";
33
+ export * from "./plugin-abi.js";
34
+ export * from "./provider-mailer.js";
32
35
  //# sourceMappingURL=index.d.ts.map
@@ -14,4 +14,7 @@ export { createMailPolicyWrapper } from "./delivery-wrapper.js";
14
14
  export { createResolvedMailer } from "./resolve-mailer.js";
15
15
  export { createTtlCache, MAIL_STATUS_TTL_MS } from "./mail-status-cache.js";
16
16
  export * from "./senders.js";
17
+ export { defaultMailProviderSetup, parseMailProviderSetup, parseMailProviderSetupProperty } from "./provider-setup.js";
18
+ export * from "./plugin-abi.js";
19
+ export * from "./provider-mailer.js";
17
20
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,16 @@
1
+ import type { MailerPort, PositionalMailer, PluginMailHttpClient } from "@jini-ai/core/contracts/mail";
2
+ import type { HttpClientPort } from "@jini-ai/core/primitives";
3
+ export type { PositionalMailer, PluginMailHttpClient } from "@jini-ai/core/contracts/mail";
4
+ /** Preserve the guarded client while translating the plugin's positional request. @complexity O(1). */
5
+ export declare function toPluginHttpClient({ httpClient }: {
6
+ httpClient: HttpClientPort;
7
+ }, _optional?: Record<string, never>): PluginMailHttpClient;
8
+ /** Adapts required delivery fields and optional controls to a positional mailer. */
9
+ export declare function fromPositionalMailer({ mailer }: {
10
+ mailer: PositionalMailer;
11
+ }, _optional?: Record<string, never>): MailerPort;
12
+ /** Adapts an object-shaped mailer for positional consumers, preserving all delivery controls. */
13
+ export declare function toPositionalMailer({ mailer }: {
14
+ mailer: MailerPort;
15
+ }, _optional?: Record<string, never>): PositionalMailer;
16
+ //# sourceMappingURL=plugin-abi.d.ts.map
@@ -0,0 +1,21 @@
1
+ /** Preserve the guarded client while translating the plugin's positional request. @complexity O(1). */
2
+ export function toPluginHttpClient({ httpClient }, _optional = {}) {
3
+ return { send: (request, optional) => httpClient.send({ request }, optional) };
4
+ }
5
+ /** Adapts required delivery fields and optional controls to a positional mailer. */
6
+ export function fromPositionalMailer({ mailer }, _optional = {}) {
7
+ return {
8
+ capabilities: () => mailer.capabilities(),
9
+ send: ({ message, ...required }, optional = {}) => mailer.send(message, { ...required, ...optional }),
10
+ sendBatch: ({ messages, ...required }, optional = {}) => mailer.sendBatch(messages, { ...required, ...optional }),
11
+ };
12
+ }
13
+ /** Adapts an object-shaped mailer for positional consumers, preserving all delivery controls. */
14
+ export function toPositionalMailer({ mailer }, _optional = {}) {
15
+ return {
16
+ capabilities: () => mailer.capabilities({}),
17
+ send: (message, { idempotencyKey, workspaceId, sourceContext, ...optional }) => mailer.send({ message, idempotencyKey, workspaceId, sourceContext }, optional),
18
+ sendBatch: (messages, { idempotencyKey, workspaceId, sourceContext, ...optional }) => mailer.sendBatch({ messages, idempotencyKey, workspaceId, sourceContext }, optional),
19
+ };
20
+ }
21
+ //# sourceMappingURL=plugin-abi.js.map
@@ -1,92 +1,2 @@
1
- import type { UUID } from "@jini-ai/core/primitives";
2
- import type { MailerCapabilities, MailerSendResult, OutboundEmail, MailerSendRequired, MailerBatchRequired, MailerOptional } from "./types.js";
3
- export type { MailerCapabilities, MailerSendOptions, MailerSendResult, OutboundEmail } from "./types.js";
4
- export interface MailerPort {
5
- capabilities(_required: Record<string, never>): MailerCapabilities;
6
- send(required: MailerSendRequired, optional?: MailerOptional): Promise<MailerSendResult>;
7
- sendBatch(required: MailerBatchRequired, optional?: MailerOptional): Promise<readonly MailerSendResult[]>;
8
- }
9
- export type ConsoleMailerAdapter = MailerPort;
10
- export type InMemoryMailerAdapter = MailerPort;
11
- /** `all` blocks every send (hard bounce, manual); `bulk` blocks only bulk mail (complaints), so a
12
- * member who marked a newsletter as spam can still receive their own sign-in link. */
13
- export type MailSuppressionScope = "all" | "bulk";
14
- export interface MailSuppressionRepoPort {
15
- isSuppressed(required: {
16
- workspaceId: UUID;
17
- normalizedAddress: string;
18
- /** The lane being sent: `transactional` consults `all` only, `bulk` consults both scopes. */
19
- lane: MailDeliveryLane;
20
- }): Promise<boolean>;
21
- suppress(required: {
22
- workspaceId: UUID;
23
- normalizedAddress: string;
24
- scope: MailSuppressionScope;
25
- reason: "bounced" | "complained" | "manual";
26
- }): Promise<void>;
27
- }
28
- /** Hard delivery lanes. Distinct from `MailerSendOptions.lane` (interactive/notification readiness). */
29
- export type MailDeliveryLane = "transactional" | "bulk";
30
- export type MailLedgerOutcome = "reserved" | "sent" | "failed" | "unknown";
31
- export interface MailSendLedgerPort {
32
- /**
33
- * Atomically insert (workspaceId, idempotencyKey, recipient) as `reserved`. An existing row is
34
- * returned as-is, except `failed`, which the port flips back to `reserved` in the same statement
35
- * (a definitive failure means nothing was sent, so retrying under the same identity is safe).
36
- * With `optional.reclaimUnknown`, an `unknown` row with the SAME payloadHash is flipped to
37
- * `reserved` in that same statement too: the caller that wins the flip is the only one that
38
- * re-sends, and a concurrent retry sees `reserved` (an unknown outcome) instead of also re-sending.
39
- */
40
- reserve(required: {
41
- workspaceId: UUID;
42
- idempotencyKey: string;
43
- recipient: string;
44
- payloadHash: string;
45
- lane: MailDeliveryLane;
46
- providerId: string;
47
- }, optional?: {
48
- reclaimUnknown?: boolean;
49
- }): Promise<{
50
- status: "reserved";
51
- } | {
52
- status: "existing";
53
- outcome: Exclude<MailLedgerOutcome, "failed">;
54
- payloadHash: string;
55
- providerMessageId?: string;
56
- }>;
57
- mark(required: {
58
- workspaceId: UUID;
59
- idempotencyKey: string;
60
- recipient: string;
61
- outcome: Exclude<MailLedgerOutcome, "reserved">;
62
- providerMessageId?: string;
63
- errorCode?: string;
64
- }): Promise<void>;
65
- }
66
- /** @deprecated Racy check-then-send pair; use {@link MailSendLedgerPort}. Kept for type consumers. */
67
- export interface MailSendDedupRepoPort {
68
- wasSent(required: {
69
- workspaceId: UUID;
70
- idempotencyKey: string;
71
- }): Promise<boolean>;
72
- markSent(required: {
73
- workspaceId: UUID;
74
- idempotencyKey: string;
75
- }): Promise<void>;
76
- }
77
- /** Test/capture mode sink: messages are stored for the operator instead of leaving the process. */
78
- export interface MailCapturePort {
79
- capture(required: {
80
- message: OutboundEmail;
81
- lane: MailDeliveryLane;
82
- idempotencyKey: string;
83
- }): Promise<{
84
- id: string;
85
- }>;
86
- }
87
- export interface DeliveryReadinessPolicy {
88
- isReady(required: {
89
- capabilityName: string;
90
- }): boolean;
91
- }
1
+ export type * from '@jini-ai/core/contracts/mail';
92
2
  //# sourceMappingURL=ports.d.ts.map
@@ -0,0 +1,12 @@
1
+ import type { HttpClientPort } from "@jini-ai/core/primitives";
2
+ import type { MailAdapterCredential, MailProviderModule, MailerPort } from "@jini-ai/core/contracts/mail";
3
+ /**
4
+ * Builds a provider's mailer with credential scrubbing inside every policy wrapper.
5
+ * @complexity O(1).
6
+ */
7
+ export declare function createProviderMailer(required: {
8
+ httpClient: HttpClientPort;
9
+ provider: MailProviderModule;
10
+ credential: MailAdapterCredential;
11
+ }, _optional?: Record<string, never>): MailerPort;
12
+ //# sourceMappingURL=provider-mailer.d.ts.map
@@ -0,0 +1,31 @@
1
+ import { credentialSecrets, safeMailProviderText } from "./provider-error.js";
2
+ import { fromPositionalMailer, toPositionalMailer } from "./plugin-abi.js";
3
+ /**
4
+ * Builds a provider's mailer with credential scrubbing inside every policy wrapper.
5
+ * @complexity O(1).
6
+ */
7
+ export function createProviderMailer(required, _optional = {}) {
8
+ const { httpClient, provider, credential } = required;
9
+ const mailer = toPositionalMailer({ mailer: provider.create({ credential, kit: { httpClient } }) });
10
+ const secrets = credentialSecrets({ credential });
11
+ const safeResult = (result) => result.ok ? result : {
12
+ ...result,
13
+ errorCode: safeMailProviderText({ text: result.errorCode }, { secrets }),
14
+ message: safeMailProviderText({ text: result.message }, { secrets }),
15
+ };
16
+ // Policy turns throws into unknown outcomes; scrub here while the actual credential is in scope.
17
+ const safeCall = async (call) => {
18
+ try {
19
+ return await call();
20
+ }
21
+ catch (error) {
22
+ throw new Error(safeMailProviderText({ text: error instanceof Error ? error.message : String(error) }, { secrets }));
23
+ }
24
+ };
25
+ return fromPositionalMailer({ mailer: {
26
+ capabilities: () => mailer.capabilities(),
27
+ send: async (message, options) => safeResult(await safeCall(() => mailer.send(message, options))),
28
+ sendBatch: async (messages, options) => (await safeCall(() => mailer.sendBatch(messages, options))).map(safeResult),
29
+ } });
30
+ }
31
+ //# sourceMappingURL=provider-mailer.js.map
@@ -0,0 +1,33 @@
1
+ import type { MailProviderSetup } from "./engine-contracts.js";
2
+ /**
3
+ * Plain fields for each declared credential key, plus `baseUrl`: the credential store files every
4
+ * key under an origin, so the form always asks for one. An unknown key becomes a required text field.
5
+ * @complexity O(k) keys.
6
+ */
7
+ export declare function defaultMailProviderSetup(required: {
8
+ credentialKeys: readonly string[];
9
+ }, _optional?: Record<string, never>): MailProviderSetup;
10
+ /**
11
+ * Parses a descriptor's optional `setup`. Pure. `undefined` stays undefined (use the default).
12
+ * A field's `key` must be one of the provider's credential keys or `baseUrl` (always stored), and
13
+ * `token` must be a secret field, so a plugin cannot turn the key input into plain text.
14
+ * @returns The setup, or the reason it is invalid (the whole descriptor is then refused).
15
+ * @complexity O(f) fields.
16
+ */
17
+ export declare function parseMailProviderSetup(required: {
18
+ value: unknown;
19
+ at: string;
20
+ credentialKeys: readonly string[];
21
+ }, _optional?: Record<string, never>): MailProviderSetup | string | undefined;
22
+ /**
23
+ * The descriptor property form of {@link parseMailProviderSetup}: `{}` when absent, `{setup}` when
24
+ * valid, else the reason. @complexity O(f) fields.
25
+ */
26
+ export declare function parseMailProviderSetupProperty(required: {
27
+ value: unknown;
28
+ at: string;
29
+ credentialKeys: readonly string[];
30
+ }, _optional?: Record<string, never>): {
31
+ setup?: MailProviderSetup;
32
+ } | string;
33
+ //# sourceMappingURL=provider-setup.d.ts.map