pcific 0.0.0-stage → 0.2.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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +50 -2
  3. package/dist/SKILL.md +127 -0
  4. package/dist/api/catalog.js +637 -0
  5. package/dist/api/run.js +960 -0
  6. package/dist/api/search.js +171 -0
  7. package/dist/api/shortcuts.js +799 -0
  8. package/dist/bin.js +648 -0
  9. package/dist/commands/auth.js +513 -0
  10. package/dist/commands/doctor.js +410 -0
  11. package/dist/commands/init.js +306 -0
  12. package/dist/commands/sync.js +214 -0
  13. package/dist/detect.js +214 -0
  14. package/dist/env.js +339 -0
  15. package/dist/goLive.js +629 -0
  16. package/dist/keyLink.js +305 -0
  17. package/dist/mcp/server.js +206 -0
  18. package/dist/mcp/tools.js +689 -0
  19. package/dist/python/template.js +793 -0
  20. package/dist/schema/discover.js +324 -0
  21. package/dist/schema/helpers.js +396 -0
  22. package/dist/schema/prismaToJsonSchema.js +197 -0
  23. package/dist/schema/push.js +570 -0
  24. package/dist/schema/tsToJsonSchema.js +405 -0
  25. package/dist/schema/zodToJsonSchema.js +442 -0
  26. package/dist/templates/openapi.json +1 -0
  27. package/dist/templates/sdk/auth.ts +139 -0
  28. package/dist/templates/sdk/client.ts +1059 -0
  29. package/dist/templates/sdk/errors.ts +76 -0
  30. package/dist/templates/sdk/generated-types.ts +5746 -0
  31. package/dist/templates/sdk/http.ts +359 -0
  32. package/dist/templates/sdk/index.ts +84 -0
  33. package/dist/templates/sdk/json.ts +24 -0
  34. package/dist/templates/sdk/kit.ts +516 -0
  35. package/dist/templates/sdk/multipart.ts +99 -0
  36. package/dist/templates/sdk/sse.ts +131 -0
  37. package/dist/templates/sdk/verify.ts +766 -0
  38. package/dist/templates/sdk-js/auth.d.ts +20 -0
  39. package/dist/templates/sdk-js/auth.js +85 -0
  40. package/dist/templates/sdk-js/client.d.ts +324 -0
  41. package/dist/templates/sdk-js/client.js +607 -0
  42. package/dist/templates/sdk-js/errors.d.ts +51 -0
  43. package/dist/templates/sdk-js/errors.js +48 -0
  44. package/dist/templates/sdk-js/generated-types.d.ts +5736 -0
  45. package/dist/templates/sdk-js/generated-types.js +5 -0
  46. package/dist/templates/sdk-js/http.d.ts +50 -0
  47. package/dist/templates/sdk-js/http.js +263 -0
  48. package/dist/templates/sdk-js/index.d.ts +9 -0
  49. package/dist/templates/sdk-js/index.js +7 -0
  50. package/dist/templates/sdk-js/json.d.ts +11 -0
  51. package/dist/templates/sdk-js/json.js +16 -0
  52. package/dist/templates/sdk-js/kit.d.ts +220 -0
  53. package/dist/templates/sdk-js/kit.js +208 -0
  54. package/dist/templates/sdk-js/multipart.d.ts +23 -0
  55. package/dist/templates/sdk-js/multipart.js +61 -0
  56. package/dist/templates/sdk-js/sse.d.ts +12 -0
  57. package/dist/templates/sdk-js/sse.js +99 -0
  58. package/dist/templates/sdk-js/verify.d.ts +114 -0
  59. package/dist/templates/sdk-js/verify.js +506 -0
  60. package/dist/templates.js +925 -0
  61. package/dist/ui.js +399 -0
  62. package/dist/webhooks/events.js +171 -0
  63. package/dist/webhooks/listen.js +772 -0
  64. package/package.json +32 -4
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Auto-generated from PCIFIC's OpenAPI 3.1 specification by scripts/generate-sdk-types.ts.
3
+ * Do not edit manually; run `npx tsx scripts/generate-sdk-types.ts` to regenerate.
4
+ */
5
+ export {};
@@ -0,0 +1,50 @@
1
+ import { type JsonValue } from "./json.js";
2
+ export interface RequestOptions {
3
+ marketplaceId?: string;
4
+ idempotencyKey?: string | false;
5
+ signal?: AbortSignal;
6
+ headers?: Record<string, string>;
7
+ testAiStub?: boolean;
8
+ }
9
+ export interface HttpClientConfig {
10
+ baseUrl: string;
11
+ apiKey: string;
12
+ signingSecret?: string;
13
+ marketplaceId?: string;
14
+ testAiStub?: boolean;
15
+ fetch: typeof globalThis.fetch;
16
+ maxRetries: number;
17
+ baseDelayMs: number;
18
+ maxDelayMs: number;
19
+ sleep: (ms: number) => Promise<void>;
20
+ now: () => number;
21
+ random: () => number;
22
+ }
23
+ interface InternalRequestParams extends RequestOptions {
24
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
25
+ path: string;
26
+ query?: Record<string, string | number | boolean | undefined | null>;
27
+ jsonBody?: JsonValue | object;
28
+ formData?: FormData;
29
+ binaryBody?: {
30
+ bytes: Uint8Array;
31
+ contentType: string;
32
+ };
33
+ accept?: string;
34
+ auth?: boolean;
35
+ }
36
+ export declare class PcificHttpClient {
37
+ readonly config: HttpClientConfig;
38
+ constructor(config: Partial<HttpClientConfig> & {
39
+ apiKey: string;
40
+ });
41
+ private buildUrl;
42
+ private computeBackoffMs;
43
+ private prepareBody;
44
+ send(params: InternalRequestParams): Promise<Response>;
45
+ requestJson<T>(params: InternalRequestParams): Promise<T>;
46
+ requestBinary(params: InternalRequestParams): Promise<Uint8Array>;
47
+ requestVoid(params: InternalRequestParams): Promise<void>;
48
+ requestStream(params: InternalRequestParams): Promise<ReadableStream<Uint8Array>>;
49
+ }
50
+ export {};
@@ -0,0 +1,263 @@
1
+ import { PcificApiError } from "./errors.js";
2
+ import { isBoolean, isJsonObject, isString, parseJsonValue } from "./json.js";
3
+ import { serializeFormData } from "./multipart.js";
4
+ import { signRequest } from "./verify.js";
5
+ const MUTATING_METHODS = new Set(["POST", "PUT", "PATCH", "DELETE"]);
6
+ const TEXT_ENCODER = new TextEncoder();
7
+ function isExplicitIdempotencyKey(value) {
8
+ return typeof value === "string";
9
+ }
10
+ function parseRetryAfterMs(headerValue, nowMs) {
11
+ if (!headerValue)
12
+ return null;
13
+ const trimmed = headerValue.trim();
14
+ if (/^\d+$/u.test(trimmed)) {
15
+ return Number(trimmed) * 1000;
16
+ }
17
+ const dateMs = Date.parse(trimmed);
18
+ if (!Number.isNaN(dateMs)) {
19
+ return Math.max(0, dateMs - nowMs);
20
+ }
21
+ return null;
22
+ }
23
+ function isRetryableStatus(status) {
24
+ return status === 408 || status === 429 || (status >= 500 && status <= 599);
25
+ }
26
+ function defaultSleep(ms) {
27
+ return new Promise((resolve) => {
28
+ setTimeout(resolve, ms);
29
+ });
30
+ }
31
+ function decodeProblems(value) {
32
+ if (!Array.isArray(value))
33
+ return [];
34
+ const problems = [];
35
+ for (const item of value) {
36
+ if (!isJsonObject(item))
37
+ continue;
38
+ const problem = {};
39
+ if (isString(item.path))
40
+ problem.path = item.path;
41
+ if (isString(item.where))
42
+ problem.where = item.where;
43
+ if (isString(item.problem))
44
+ problem.problem = item.problem;
45
+ if (isString(item.tryThis))
46
+ problem.tryThis = item.tryThis;
47
+ if (isString(item.category))
48
+ problem.category = item.category;
49
+ problems.push(problem);
50
+ }
51
+ return problems;
52
+ }
53
+ async function parseApiError(response) {
54
+ const requestIdFromHeader = response.headers.get("x-request-id") ?? undefined;
55
+ let rawBody;
56
+ try {
57
+ const text = await response.text();
58
+ if (text.length > 0) {
59
+ try {
60
+ rawBody = parseJsonValue(text);
61
+ }
62
+ catch {
63
+ rawBody = text;
64
+ }
65
+ }
66
+ }
67
+ catch {
68
+ rawBody = undefined;
69
+ }
70
+ if (isJsonObject(rawBody)) {
71
+ return new PcificApiError({
72
+ status: response.status,
73
+ code: isString(rawBody.code) ? rawBody.code : `HTTP_${response.status}`,
74
+ error: isString(rawBody.error)
75
+ ? rawBody.error
76
+ : `PCIFIC API request failed with HTTP ${response.status}.`,
77
+ tryThis: isString(rawBody.tryThis)
78
+ ? rawBody.tryThis
79
+ : "Inspect the response status and request parameters, then try again.",
80
+ where: isString(rawBody.where) ? rawBody.where : undefined,
81
+ retryable: isBoolean(rawBody.retryable) ? rawBody.retryable : isRetryableStatus(response.status),
82
+ problems: decodeProblems(rawBody.problems),
83
+ requestId: isString(rawBody.requestId) ? rawBody.requestId : requestIdFromHeader,
84
+ existingId: isString(rawBody.existingId) ? rawBody.existingId : undefined,
85
+ rawBody,
86
+ });
87
+ }
88
+ return new PcificApiError({
89
+ status: response.status,
90
+ code: `HTTP_${response.status}`,
91
+ error: `PCIFIC API request failed with HTTP ${response.status}.`,
92
+ tryThis: "Retry the request if it is a transient server error, or contact PCIFIC support with the requestId.",
93
+ retryable: isRetryableStatus(response.status),
94
+ requestId: requestIdFromHeader,
95
+ rawBody,
96
+ });
97
+ }
98
+ export class PcificHttpClient {
99
+ config;
100
+ constructor(config) {
101
+ this.config = {
102
+ baseUrl: (config.baseUrl ?? "https://business.pcific.ai").replace(/\/+$/u, ""),
103
+ apiKey: config.apiKey,
104
+ signingSecret: config.signingSecret,
105
+ marketplaceId: config.marketplaceId,
106
+ testAiStub: config.testAiStub,
107
+ fetch: config.fetch ?? globalThis.fetch,
108
+ maxRetries: config.maxRetries ?? 3,
109
+ baseDelayMs: config.baseDelayMs ?? 250,
110
+ maxDelayMs: config.maxDelayMs ?? 10_000,
111
+ sleep: config.sleep ?? defaultSleep,
112
+ now: config.now ?? (() => Date.now()),
113
+ random: config.random ?? (() => Math.random()),
114
+ };
115
+ }
116
+ buildUrl(path, query, marketplaceId) {
117
+ const url = new URL(`${this.config.baseUrl}${path}`);
118
+ const effectiveMarketplace = marketplaceId ?? this.config.marketplaceId;
119
+ if (effectiveMarketplace && (!query || query.marketplaceId === undefined)) {
120
+ url.searchParams.set("marketplaceId", effectiveMarketplace);
121
+ }
122
+ if (query) {
123
+ for (const [key, value] of Object.entries(query)) {
124
+ if (value !== undefined && value !== null) {
125
+ url.searchParams.set(key, String(value));
126
+ }
127
+ }
128
+ }
129
+ return url.toString();
130
+ }
131
+ computeBackoffMs(attempt, retryAfterHeader) {
132
+ const retryAfterMs = parseRetryAfterMs(retryAfterHeader, this.config.now());
133
+ if (retryAfterMs !== null) {
134
+ return Math.min(retryAfterMs, Math.max(this.config.maxDelayMs, retryAfterMs));
135
+ }
136
+ const exp = Math.min(this.config.maxDelayMs, this.config.baseDelayMs * 2 ** attempt);
137
+ const jitter = Math.floor(exp * 0.25 * this.config.random());
138
+ return Math.min(this.config.maxDelayMs, exp + jitter);
139
+ }
140
+ async prepareBody(params) {
141
+ if (params.formData) {
142
+ const serialized = await serializeFormData(params.formData);
143
+ return { bodyBytes: serialized.body, contentType: serialized.contentType };
144
+ }
145
+ if (params.binaryBody) {
146
+ return { bodyBytes: params.binaryBody.bytes, contentType: params.binaryBody.contentType };
147
+ }
148
+ if (params.jsonBody !== undefined) {
149
+ return {
150
+ bodyBytes: TEXT_ENCODER.encode(JSON.stringify(params.jsonBody)),
151
+ contentType: "application/json",
152
+ };
153
+ }
154
+ return { bodyBytes: undefined, contentType: undefined };
155
+ }
156
+ async send(params) {
157
+ const url = this.buildUrl(params.path, params.query, params.marketplaceId);
158
+ const { bodyBytes, contentType } = await this.prepareBody(params);
159
+ const isMutating = MUTATING_METHODS.has(params.method);
160
+ const idempotencyKey = params.idempotencyKey === false
161
+ ? undefined
162
+ : isExplicitIdempotencyKey(params.idempotencyKey)
163
+ ? params.idempotencyKey
164
+ : isMutating
165
+ ? crypto.randomUUID()
166
+ : undefined;
167
+ const useAuth = params.auth !== false;
168
+ const useStub = params.testAiStub ?? this.config.testAiStub;
169
+ let attempt = 0;
170
+ while (true) {
171
+ const headers = new Headers(params.headers);
172
+ if (useAuth) {
173
+ headers.set("Authorization", `Bearer ${this.config.apiKey}`);
174
+ }
175
+ if (contentType) {
176
+ headers.set("Content-Type", contentType);
177
+ }
178
+ if (params.accept) {
179
+ headers.set("Accept", params.accept);
180
+ }
181
+ else if (!headers.has("Accept")) {
182
+ headers.set("Accept", "application/json");
183
+ }
184
+ if (idempotencyKey) {
185
+ headers.set("Idempotency-Key", idempotencyKey);
186
+ }
187
+ if (useStub) {
188
+ headers.set("X-PCIFIC-Test-AI", "stub");
189
+ }
190
+ if (useAuth && this.config.signingSecret) {
191
+ const signature = await signRequest({
192
+ method: params.method,
193
+ url,
194
+ bodyBytes,
195
+ secret: this.config.signingSecret,
196
+ timestamp: Math.floor(this.config.now() / 1000),
197
+ });
198
+ headers.set("PCIFIC-Signature", signature);
199
+ }
200
+ let response;
201
+ try {
202
+ // SAFETY: Uint8Array is a valid Fetch BodyInit buffer view in standard Fetch APIs.
203
+ const bodyInit = bodyBytes;
204
+ response = await this.config.fetch(url, {
205
+ method: params.method,
206
+ headers,
207
+ body: bodyInit,
208
+ signal: params.signal,
209
+ });
210
+ }
211
+ catch (networkError) {
212
+ if (params.signal?.aborted || attempt >= this.config.maxRetries) {
213
+ throw networkError;
214
+ }
215
+ const delayMs = this.computeBackoffMs(attempt, null);
216
+ attempt += 1;
217
+ await this.config.sleep(delayMs);
218
+ continue;
219
+ }
220
+ if (response.ok) {
221
+ return response;
222
+ }
223
+ if (isRetryableStatus(response.status) && attempt < this.config.maxRetries && !params.signal?.aborted) {
224
+ const delayMs = this.computeBackoffMs(attempt, response.headers.get("retry-after"));
225
+ try {
226
+ await response.arrayBuffer();
227
+ }
228
+ catch {
229
+ // Ignore drain errors on retryable failures.
230
+ }
231
+ attempt += 1;
232
+ await this.config.sleep(delayMs);
233
+ continue;
234
+ }
235
+ throw await parseApiError(response);
236
+ }
237
+ }
238
+ async requestJson(params) {
239
+ const response = await this.send(params);
240
+ const text = await response.text();
241
+ // SAFETY: Caller requests the documented response type T for this endpoint; 204 endpoints use requestVoid.
242
+ return parseJsonValue(text);
243
+ }
244
+ async requestBinary(params) {
245
+ const response = await this.send(params);
246
+ return new Uint8Array(await response.arrayBuffer());
247
+ }
248
+ async requestVoid(params) {
249
+ await this.send(params);
250
+ }
251
+ async requestStream(params) {
252
+ const response = await this.send({ ...params, accept: "text/event-stream" });
253
+ if (!response.body) {
254
+ throw new PcificApiError({
255
+ status: response.status,
256
+ code: "EMPTY_STREAM",
257
+ error: "PCIFIC returned an empty response body for the event stream.",
258
+ tryThis: "Retry the request or fall back to polling GET.",
259
+ });
260
+ }
261
+ return response.body;
262
+ }
263
+ }
@@ -0,0 +1,9 @@
1
+ export { resolvePcificAuth, type PcificMode, type ResolvedPcificAuth, type ResolvePcificAuthOptions, } from "./auth.js";
2
+ export { createPcificClient, PcificClient, type AskPcificInput, type CreateListingInput, type CreateReviewInput, type DisputePackCreateDisputeInput, type DisputePackPushListingInput, type DisputePackRecordMessageInput, type DisputePackRecordSaleInput, type DisputePackRecordTrackingInput, type EmbedSessionInput, type GetAiNoticeOptions, type MessageCheckInput, type MessageCheckPresentInput, type MessageCheckSender, type MessageCheckVerifyOnlineInput, type MoneyMinorUnits, type PcificClientOptions, type WaitOptions, } from "./client.js";
3
+ export { PcificApiError, PcificConfigError, PcificStreamError, type PcificApiErrorInit, type PcificProblem, } from "./errors.js";
4
+ export { PcificHttpClient, type HttpClientConfig, type RequestOptions } from "./http.js";
5
+ export type { JsonObject, JsonValue } from "./json.js";
6
+ export { normalizeUpload, serializeFormData, type NormalizedUpload, type UploadFileDescriptor, type UploadInput, } from "./multipart.js";
7
+ export { parseSseStream, type SseFrame } from "./sse.js";
8
+ export { clearJwksCache, parseMessageCheckReceipt, signRequest, verifyMessageCheckReceipt, verifyPixelTraceManifest, verifyWebhookSignature, type Ed25519Jwk, type JsonWebKeySet, type ParsedMcr1Receipt, type SignRequestOptions, type VerifyMessageCheckReceiptOptions, type VerifyMessageCheckReceiptResult, type VerifyPixelTraceManifestOptions, type VerifyPixelTraceManifestResult, type VerifyWebhookSignatureOptions, type VerifyWebhookSignatureResult, } from "./verify.js";
9
+ export type { Error as PcificErrorResponse, OrbitCancelled, OrbitFailed, OrbitListing, OrbitQuestions, OrbitWorking, PcificPaths, SafeguardDone, SafeguardFailed, SafeguardWorking, ToolError, WebhookEvent, } from "./generated-types.js";
@@ -0,0 +1,7 @@
1
+ export { resolvePcificAuth, } from "./auth.js";
2
+ export { createPcificClient, PcificClient, } from "./client.js";
3
+ export { PcificApiError, PcificConfigError, PcificStreamError, } from "./errors.js";
4
+ export { PcificHttpClient } from "./http.js";
5
+ export { normalizeUpload, serializeFormData, } from "./multipart.js";
6
+ export { parseSseStream } from "./sse.js";
7
+ export { clearJwksCache, parseMessageCheckReceipt, signRequest, verifyMessageCheckReceipt, verifyPixelTraceManifest, verifyWebhookSignature, } from "./verify.js";
@@ -0,0 +1,11 @@
1
+ export type JsonValue = string | number | boolean | null | JsonValue[] | {
2
+ [key: string]: JsonValue;
3
+ };
4
+ export type JsonObject = {
5
+ [key: string]: JsonValue;
6
+ };
7
+ export declare function isString(value: JsonValue | undefined): value is string;
8
+ export declare function isNumber(value: JsonValue | undefined): value is number;
9
+ export declare function isBoolean(value: JsonValue | undefined): value is boolean;
10
+ export declare function isJsonObject(value: JsonValue | undefined): value is JsonObject;
11
+ export declare function parseJsonValue(text: string): JsonValue;
@@ -0,0 +1,16 @@
1
+ export function isString(value) {
2
+ return typeof value === "string";
3
+ }
4
+ export function isNumber(value) {
5
+ return typeof value === "number";
6
+ }
7
+ export function isBoolean(value) {
8
+ return typeof value === "boolean";
9
+ }
10
+ export function isJsonObject(value) {
11
+ return typeof value === "object" && value !== null && !Array.isArray(value);
12
+ }
13
+ export function parseJsonValue(text) {
14
+ // SAFETY: JSON.parse returns only JSON primitives, arrays, or plain objects matching JsonValue.
15
+ return JSON.parse(text);
16
+ }
@@ -0,0 +1,220 @@
1
+ export declare const DEFAULT_PCIFIC_KIT_BASE_URL = "https://business.pcific.ai";
2
+ export declare const PCIFIC_KIT_TOOLS: readonly ["orbit", "safeguard", "ask", "pixel-trace", "trust", "chat"];
3
+ export type PcificKitTool = (typeof PCIFIC_KIT_TOOLS)[number];
4
+ export type PcificKitTagName = `pcific-${PcificKitTool}`;
5
+ export type PcificKitLauncherCorner = "bottom-right" | "bottom-left" | "top-right" | "top-left";
6
+ export type PcificKitLauncher = PcificKitLauncherCorner | "inline";
7
+ export type PcificKitThemeMode = "auto" | "light" | "dark";
8
+ export type PcificKitOnOff = "on" | "off";
9
+ export declare const PCIFIC_KIT_FONTS: readonly ["business", "inherit", "Inter", "Work Sans", "Georgia", "Arial", "Verdana", "Times New Roman", "Courier New", "system-ui", "sans-serif", "serif", "monospace"];
10
+ export type PcificKitFont = (typeof PCIFIC_KIT_FONTS)[number];
11
+ export interface PcificKitTheme {
12
+ accent?: string;
13
+ background?: string;
14
+ surface?: string;
15
+ text?: string;
16
+ mutedText?: string;
17
+ border?: string;
18
+ mode?: PcificKitThemeMode;
19
+ radius?: number;
20
+ font?: PcificKitFont;
21
+ density?: "comfortable" | "compact";
22
+ launcher?: {
23
+ corner?: PcificKitLauncherCorner;
24
+ offset?: number;
25
+ label?: string;
26
+ };
27
+ }
28
+ export interface PcificChatMessage {
29
+ id: string;
30
+ text: string;
31
+ senderId: string;
32
+ senderName?: string;
33
+ createdAt?: string;
34
+ warn?: boolean;
35
+ label?: string | null;
36
+ }
37
+ export interface PcificChatSendPayload {
38
+ text: string;
39
+ maskedText: string;
40
+ verdict: string;
41
+ enforce: boolean;
42
+ checkId: string;
43
+ receipt: string | null;
44
+ }
45
+ export type PcificResultEventDetail = Record<string, string | string[]>;
46
+ export interface PcificStateEventDetail {
47
+ type: "pcific:state";
48
+ state: string;
49
+ label: string;
50
+ link?: string;
51
+ }
52
+ export interface PcificProblemEventDetail {
53
+ message: string;
54
+ }
55
+ export interface PcificCapabilitiesEventDetail {
56
+ type: "pcific:capabilities";
57
+ states: Array<{
58
+ id: string;
59
+ label: string;
60
+ }>;
61
+ acts: Array<{
62
+ id: string;
63
+ label: string;
64
+ }>;
65
+ }
66
+ export interface PcificMessageSentEventDetail extends PcificChatSendPayload {
67
+ message: PcificChatMessage | null;
68
+ }
69
+ export interface PcificMessageBlockedEventDetail {
70
+ verdict: string;
71
+ }
72
+ export interface PcificKitEventDetailMap {
73
+ "pcific:result": PcificResultEventDetail;
74
+ "pcific:state": PcificStateEventDetail;
75
+ "pcific:problem": PcificProblemEventDetail;
76
+ "pcific:capabilities": PcificCapabilitiesEventDetail;
77
+ "pcific:message-sent": PcificMessageSentEventDetail;
78
+ "pcific:message-blocked": PcificMessageBlockedEventDetail;
79
+ }
80
+ export type PcificKitEventMap = {
81
+ [K in keyof PcificKitEventDetailMap]: CustomEvent<PcificKitEventDetailMap[K]>;
82
+ };
83
+ export type PcificKitEventName = keyof PcificKitEventMap;
84
+ export interface PcificTagCommonAttributes {
85
+ session?: string;
86
+ read?: string;
87
+ fill?: string;
88
+ form?: string;
89
+ accent?: string;
90
+ mode?: PcificKitThemeMode;
91
+ radius?: number | string;
92
+ font?: PcificKitFont;
93
+ theme?: string;
94
+ logo?: string;
95
+ launcher?: PcificKitLauncher;
96
+ simulate?: boolean | "";
97
+ title?: string;
98
+ }
99
+ export interface PcificOrbitAttributes extends PcificTagCommonAttributes {
100
+ "pixel-trace"?: PcificKitOnOff;
101
+ safeguard?: PcificKitOnOff;
102
+ faq?: PcificKitOnOff;
103
+ price?: PcificKitOnOff;
104
+ "edit-chat"?: PcificKitOnOff;
105
+ }
106
+ export interface PcificSafeguardAttributes extends PcificTagCommonAttributes {
107
+ }
108
+ export interface PcificAskAttributes extends PcificTagCommonAttributes {
109
+ "item-id"?: string;
110
+ }
111
+ export interface PcificPixelTraceAttributes extends PcificTagCommonAttributes {
112
+ }
113
+ export interface PcificTrustAttributes extends PcificTagCommonAttributes {
114
+ }
115
+ export interface PcificChatAttributes extends PcificTagCommonAttributes {
116
+ "messages-url"?: string;
117
+ "send-url"?: string;
118
+ "session-url"?: string;
119
+ "poll-seconds"?: number | string;
120
+ }
121
+ export interface PcificTagAttributes extends PcificOrbitAttributes, PcificAskAttributes, PcificChatAttributes {
122
+ }
123
+ export interface PcificKitElement extends HTMLElement {
124
+ simulate(action: string): void;
125
+ }
126
+ export interface PcificChatElement extends PcificKitElement {
127
+ pushMessage(message: PcificChatMessage): void;
128
+ refresh(): void;
129
+ }
130
+ export interface PcificKitElementMap {
131
+ "pcific-orbit": PcificKitElement;
132
+ "pcific-safeguard": PcificKitElement;
133
+ "pcific-ask": PcificKitElement;
134
+ "pcific-pixel-trace": PcificKitElement;
135
+ "pcific-trust": PcificKitElement;
136
+ "pcific-chat": PcificChatElement;
137
+ }
138
+ export interface LoadPcificKitOptions {
139
+ /** Base origin serving `/static/templates/kit.js`. Defaults to `https://business.pcific.ai`. */
140
+ baseUrl?: string;
141
+ /** Maximum milliseconds to wait for the Kit script to load. Defaults to 15000. */
142
+ timeoutMs?: number;
143
+ /** When true, resolves as a no-op during SSR instead of throwing `PcificConfigError`. */
144
+ ignoreSsr?: boolean;
145
+ }
146
+ export interface PcificKitHandle {
147
+ readonly baseUrl: string;
148
+ readonly scriptUrl: string;
149
+ load(): Promise<void>;
150
+ onEvent: typeof onPcificEvent;
151
+ }
152
+ export interface KitScriptNode extends EventTarget {
153
+ type: string;
154
+ src: string;
155
+ getAttribute(name: string): string | null;
156
+ setAttribute(name: string, value: string): void;
157
+ }
158
+ export interface KitDocumentLike {
159
+ readonly head: {
160
+ appendChild(node: KitScriptNode): KitScriptNode;
161
+ } | null;
162
+ readonly documentElement: {
163
+ appendChild(node: KitScriptNode): KitScriptNode;
164
+ } | null;
165
+ createElement(tagName: "script"): KitScriptNode;
166
+ querySelectorAll(selector: string): ArrayLike<KitScriptNode>;
167
+ }
168
+ export interface KitCustomElementsLike {
169
+ get(name: string): CustomElementConstructor | undefined;
170
+ whenDefined?(name: string): Promise<CustomElementConstructor>;
171
+ }
172
+ export declare function getPcificKitScriptUrl(baseUrl?: string): string;
173
+ /**
174
+ * Idempotently loads the PCIFIC Kit web components script in browser environments.
175
+ * Safe against concurrent calls and duplicate script tags.
176
+ */
177
+ export declare function loadPcificKit(options?: LoadPcificKitOptions): Promise<void>;
178
+ /**
179
+ * Attaches a typed listener for any PCIFIC custom event (`pcific:result`, `pcific:state`,
180
+ * `pcific:problem`, etc.) and returns a cleanup function that removes it.
181
+ */
182
+ export declare function onPcificEvent<K extends PcificKitEventName>(element: EventTarget, eventName: K, handler: (detail: PcificKitEventDetailMap[K], event: CustomEvent<PcificKitEventDetailMap[K]>) => void, options?: AddEventListenerOptions | boolean): () => void;
183
+ /**
184
+ * Creates a reusable handle configured with a baseUrl for loading PCIFIC Kit
185
+ * and subscribing to typed web component events.
186
+ */
187
+ export declare function createPcificKit(options?: LoadPcificKitOptions): PcificKitHandle;
188
+ /** Clears internal in-flight script cache. Intended for test isolation. */
189
+ export declare function resetPcificKitLoader(): void;
190
+ export interface PcificIntrinsicElementBase {
191
+ id?: string;
192
+ class?: string;
193
+ className?: string;
194
+ style?: string | Record<string, string | number | undefined>;
195
+ slot?: string;
196
+ hidden?: boolean;
197
+ "aria-label"?: string;
198
+ children?: unknown;
199
+ ref?: unknown;
200
+ }
201
+ declare global {
202
+ interface HTMLElementTagNameMap {
203
+ "pcific-orbit": PcificKitElement;
204
+ "pcific-safeguard": PcificKitElement;
205
+ "pcific-ask": PcificKitElement;
206
+ "pcific-pixel-trace": PcificKitElement;
207
+ "pcific-trust": PcificKitElement;
208
+ "pcific-chat": PcificChatElement;
209
+ }
210
+ namespace JSX {
211
+ interface IntrinsicElements {
212
+ "pcific-orbit": PcificIntrinsicElementBase & PcificOrbitAttributes;
213
+ "pcific-safeguard": PcificIntrinsicElementBase & PcificSafeguardAttributes;
214
+ "pcific-ask": PcificIntrinsicElementBase & PcificAskAttributes;
215
+ "pcific-pixel-trace": PcificIntrinsicElementBase & PcificPixelTraceAttributes;
216
+ "pcific-trust": PcificIntrinsicElementBase & PcificTrustAttributes;
217
+ "pcific-chat": PcificIntrinsicElementBase & PcificChatAttributes;
218
+ }
219
+ }
220
+ }