@getcolter/sdk 0.1.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/LICENSE ADDED
@@ -0,0 +1,2 @@
1
+ See repository license at ../../LICENSE.
2
+
package/README.md ADDED
@@ -0,0 +1,149 @@
1
+ # @getcolter/sdk
2
+
3
+ Official Node.js SDK for Colter.
4
+
5
+ It supports:
6
+ - Hosted API client (`/api/v1/*`): `check`, `results`, `shares` (revocable share links + PDF).
7
+ - Local CLI runner wrapper: programmatic access to CLI-only features like `verify`, `replay`, `diff`, `export`.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @getcolter/sdk
13
+ ```
14
+
15
+ ## Quick start
16
+
17
+ ```typescript
18
+ import { ColterClient } from '@getcolter/sdk';
19
+
20
+ const client = new ColterClient();
21
+
22
+ const result = await client.check('example-store.com');
23
+
24
+ console.log(result.verdict); // "AGENT-READY" | "PARTIALLY AGENT-READY" | "NOT AGENT-READY"
25
+ console.log(result.agent_ready); // true if any protocol detected
26
+ console.log(result.protocols.ucp); // { detected: true, endpoint: "/.well-known/ucp", ... }
27
+ console.log(result.protocols.acp); // { detected: false, error: "...", ... }
28
+ ```
29
+
30
+ ## Share links (revocable + expiring)
31
+
32
+ ```ts
33
+ import { ColterClient } from "@getcolter/sdk";
34
+
35
+ const client = new ColterClient();
36
+
37
+ const share = await client.createShare({
38
+ result_id: "00000000-0000-0000-0000-000000000000",
39
+ brand: "Acme Agency",
40
+ whitelabel: true,
41
+ client_friendly: true,
42
+ expires_in_days: 30,
43
+ });
44
+
45
+ console.log(share.url); // https://agenticcom.ai/s/<token>
46
+ ```
47
+
48
+ ## Local CLI runner (feature parity)
49
+
50
+ ```ts
51
+ import { ColterCLI } from "@getcolter/sdk";
52
+
53
+ const cli = new ColterCLI(); // requires `colter` on PATH (or set COLTER_PATH)
54
+ const result = await cli.check("example.com");
55
+ const { pack } = await cli.verify("example.com", { throwOnFail: false });
56
+ ```
57
+
58
+ ## Configuration
59
+
60
+ ```typescript
61
+ // Custom base URL (for self-hosted or staging)
62
+ const client = new ColterClient({
63
+ baseUrl: 'https://staging.agenticcom.ai',
64
+ });
65
+ ```
66
+
67
+ ## API reference
68
+
69
+ ### `new ColterClient(options?)`
70
+
71
+ Creates a new Colter API client.
72
+
73
+ | Option | Type | Default | Description |
74
+ |--------|------|---------|-------------|
75
+ | `baseUrl` | `string` | `https://agenticcom.ai` | API base URL |
76
+
77
+ ### `client.check(url): Promise<CheckResult>`
78
+
79
+ Runs an agent-readiness check against the given store URL. The URL can be a bare domain (e.g. `"example.com"`) or include a scheme.
80
+
81
+ Throws `ColterError` for HTTP errors (400, 422, 429, 5xx).
82
+
83
+ ### `client.getResult(id): Promise<CheckResult>`
84
+
85
+ Fetch a stored result by id.
86
+
87
+ ### `client.getResultPdf(id, opts?): Promise<ArrayBuffer>`
88
+
89
+ Download a PDF for a stored result.
90
+
91
+ ### `client.createShare(req): Promise<ShareCreateResponse>`
92
+
93
+ Create a revocable share token for a result.
94
+
95
+ ### `client.resolveShare(token): Promise<ShareResolveResponse>`
96
+
97
+ Resolve a share token to the result plus share metadata.
98
+
99
+ ### `client.getSharePdf(token): Promise<ArrayBuffer>`
100
+
101
+ Download the branded PDF for a share token.
102
+
103
+ ### `client.revokeShare(token, revokeToken): Promise<{ ok: true; revoked: true }>`
104
+
105
+ Revoke a share token.
106
+
107
+ ### Error handling
108
+
109
+ ```typescript
110
+ import { ColterClient, ColterError } from '@getcolter/sdk';
111
+
112
+ try {
113
+ const result = await client.check('example.com');
114
+ } catch (err) {
115
+ if (err instanceof ColterError) {
116
+ console.error(`Status ${err.statusCode}: ${err.message}`);
117
+ if (err.retryAfter) {
118
+ console.error(`Retry in ${err.retryAfter}s`);
119
+ }
120
+ }
121
+ }
122
+ ```
123
+
124
+ ### Types
125
+
126
+ All response types are exported:
127
+
128
+ - `CheckResult` — full readiness check response
129
+ - `ProtocolStatus` — UCP, ACP, MCP detection results
130
+ - `ProtocolCheck` — single protocol detection
131
+ - `WebSignals` — JSON-LD, sitemap, robots.txt, OG tags
132
+ - `StoreStatus` — platform, product count, detectability
133
+ - `CoverageStatus` — Google and OpenAI ecosystem coverage
134
+ - `PlainLanguage` — merchant, agency, developer summaries
135
+ - `Verdict` — `"AGENT-READY" | "PARTIALLY AGENT-READY" | "NOT AGENT-READY"`
136
+ - `ShareCreateRequest`, `ShareCreateResponse`, `ShareResolveResponse`
137
+
138
+ ## Requirements
139
+
140
+ - Node.js >= 18.0.0 (uses native `fetch`)
141
+ - Zero runtime dependencies
142
+
143
+ ## Rate limits
144
+
145
+ The Colter API is rate limited to 5 requests per minute per IP. When rate limited, `check()` throws a `ColterError` with `statusCode: 429` and `retryAfter` set to the number of seconds to wait.
146
+
147
+ ## Docs
148
+
149
+ Full documentation at [agenticcom.ai/docs](https://agenticcom.ai/docs).
@@ -0,0 +1,103 @@
1
+ export type { CheckResult, ProtocolCheck, ProtocolStatus, StoreStatus, CoverageStatus, WebSignals, PlainLanguage, Verdict, ShareCreateRequest, ShareCreateResponse, ShareResolveResponse, } from './types.js';
2
+ import type { CheckResult, ShareCreateRequest, ShareCreateResponse, ShareResolveResponse } from './types.js';
3
+ /** SDK version sent in the User-Agent header. */
4
+ export declare const VERSION = "0.1.0";
5
+ /** Default Colter API base URL. */
6
+ export declare const DEFAULT_BASE_URL = "https://agenticcom.ai";
7
+ /** Options for creating a ColterClient. */
8
+ export interface ColterClientOptions {
9
+ /** API base URL (no trailing slash). Defaults to `https://agenticcom.ai`. */
10
+ baseUrl?: string;
11
+ }
12
+ /**
13
+ * Error returned when the Colter API responds with a non-2xx status.
14
+ */
15
+ export declare class ColterError extends Error {
16
+ /** HTTP status code from the API. */
17
+ readonly statusCode: number;
18
+ /** Seconds until the rate limit resets (only set for 429 responses). */
19
+ readonly retryAfter?: number;
20
+ constructor(statusCode: number, message: string, retryAfter?: number);
21
+ }
22
+ /**
23
+ * Client for the Colter public API.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const client = new ColterClient();
28
+ * const result = await client.check('example-store.com');
29
+ * console.log(result.verdict);
30
+ * ```
31
+ */
32
+ export declare class ColterClient {
33
+ private readonly baseUrl;
34
+ constructor(options?: ColterClientOptions);
35
+ /**
36
+ * Run an agent-readiness check against the given store URL.
37
+ *
38
+ * @param url - Store URL to check. Scheme is optional (defaults to `https://`).
39
+ * @returns Full readiness check result.
40
+ * @throws {ColterError} When the API returns a non-2xx response.
41
+ */
42
+ check(url: string): Promise<CheckResult>;
43
+ /** Fetch a stored readiness result by id. */
44
+ getResult(id: string): Promise<CheckResult>;
45
+ /** Download a PDF export for a stored readiness result. */
46
+ getResultPdf(id: string, opts?: {
47
+ brand?: string;
48
+ logo?: string;
49
+ whitelabel?: boolean;
50
+ client_friendly?: boolean;
51
+ }): Promise<ArrayBuffer>;
52
+ /** Create a revocable, expiring share link for a result id. */
53
+ createShare(req: ShareCreateRequest): Promise<ShareCreateResponse>;
54
+ /** Resolve a share token to a readiness result and share metadata. */
55
+ resolveShare(token: string): Promise<ShareResolveResponse>;
56
+ /** Download the branded PDF for a share token (branding comes from the share record). */
57
+ getSharePdf(token: string): Promise<ArrayBuffer>;
58
+ /** Revoke a share token using its revoke secret. */
59
+ revokeShare(token: string, revokeToken: string): Promise<{
60
+ ok: true;
61
+ revoked: true;
62
+ }>;
63
+ }
64
+ export declare class ColterCLIError extends Error {
65
+ readonly exitCode: number | null;
66
+ readonly stdout: string;
67
+ readonly stderr: string;
68
+ constructor(message: string, exitCode: number | null, stdout: string, stderr: string);
69
+ }
70
+ export interface ColterCLIOptions {
71
+ /** Path to the `colter` executable. If not set, uses COLTER_PATH or PATH lookup. */
72
+ colterPath?: string;
73
+ cwd?: string;
74
+ env?: NodeJS.ProcessEnv;
75
+ timeoutMs?: number;
76
+ }
77
+ export declare class ColterCLI {
78
+ private readonly colterPath;
79
+ private readonly cwd?;
80
+ private readonly env?;
81
+ private readonly timeoutMs?;
82
+ constructor(opts?: ColterCLIOptions);
83
+ private run;
84
+ check(url: string): Promise<CheckResult>;
85
+ verify(target: string, opts?: {
86
+ protocols?: string[];
87
+ out?: string;
88
+ tests?: string[];
89
+ schemaAcp?: string;
90
+ schemaUcp?: string;
91
+ throwOnFail?: boolean;
92
+ }): Promise<{
93
+ pack: unknown;
94
+ exitCode: number | null;
95
+ }>;
96
+ replay(packPath: string, opts?: {
97
+ live?: boolean;
98
+ }): Promise<unknown>;
99
+ diff(packA: string, packB: string): Promise<unknown>;
100
+ exportJson(packPath: string): Promise<unknown>;
101
+ version(): Promise<string>;
102
+ }
103
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,WAAW,EACX,aAAa,EACb,cAAc,EACd,WAAW,EACX,cAAc,EACd,UAAU,EACV,aAAa,EACb,OAAO,EACP,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAM7G,iDAAiD;AACjD,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B,mCAAmC;AACnC,eAAO,MAAM,gBAAgB,0BAA0B,CAAC;AAExD,2CAA2C;AAC3C,MAAM,WAAW,mBAAmB;IAClC,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,qCAAqC;IACrC,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,wEAAwE;IACxE,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;gBAExB,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAMrE;AAED;;;;;;;;;GASG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,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}
package/dist/index.js ADDED
@@ -0,0 +1,301 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { promisify } from 'node:util';
3
+ import { execFile } from 'node:child_process';
4
+ import { existsSync } from 'node:fs';
5
+ /** SDK version sent in the User-Agent header. */
6
+ export const VERSION = '0.1.0';
7
+ /** Default Colter API base URL. */
8
+ export const DEFAULT_BASE_URL = 'https://agenticcom.ai';
9
+ /**
10
+ * Error returned when the Colter API responds with a non-2xx status.
11
+ */
12
+ export class ColterError extends Error {
13
+ constructor(statusCode, message, retryAfter) {
14
+ super(message);
15
+ this.name = 'ColterError';
16
+ this.statusCode = statusCode;
17
+ this.retryAfter = retryAfter;
18
+ }
19
+ }
20
+ /**
21
+ * Client for the Colter public API.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const client = new ColterClient();
26
+ * const result = await client.check('example-store.com');
27
+ * console.log(result.verdict);
28
+ * ```
29
+ */
30
+ export class ColterClient {
31
+ constructor(options) {
32
+ this.baseUrl = options?.baseUrl ?? DEFAULT_BASE_URL;
33
+ }
34
+ /**
35
+ * Run an agent-readiness check against the given store URL.
36
+ *
37
+ * @param url - Store URL to check. Scheme is optional (defaults to `https://`).
38
+ * @returns Full readiness check result.
39
+ * @throws {ColterError} When the API returns a non-2xx response.
40
+ */
41
+ async check(url) {
42
+ const response = await fetch(`${this.baseUrl}/api/v1/check`, {
43
+ method: 'POST',
44
+ headers: {
45
+ 'Content-Type': 'application/json',
46
+ 'User-Agent': `colter-node/${VERSION}`,
47
+ Accept: 'application/json',
48
+ },
49
+ body: JSON.stringify({ url }),
50
+ });
51
+ if (!response.ok) {
52
+ const body = await response.json().catch(() => ({ error: 'Unknown error' }));
53
+ const message = typeof body.error === 'string' ? body.error : 'Request failed';
54
+ const retryAfter = typeof body.retryAfter === 'number' ? body.retryAfter : undefined;
55
+ throw new ColterError(response.status, message, retryAfter);
56
+ }
57
+ return response.json();
58
+ }
59
+ /** Fetch a stored readiness result by id. */
60
+ async getResult(id) {
61
+ const response = await fetch(`${this.baseUrl}/api/v1/results/${encodeURIComponent(id)}`, {
62
+ method: 'GET',
63
+ headers: {
64
+ 'User-Agent': `colter-node/${VERSION}`,
65
+ Accept: 'application/json',
66
+ },
67
+ });
68
+ if (!response.ok) {
69
+ const body = await response.json().catch(() => ({ error: 'Unknown error' }));
70
+ const message = typeof body.error === 'string' ? body.error : 'Request failed';
71
+ throw new ColterError(response.status, message);
72
+ }
73
+ return response.json();
74
+ }
75
+ /** Download a PDF export for a stored readiness result. */
76
+ async getResultPdf(id, opts) {
77
+ const qs = new URLSearchParams();
78
+ if (opts?.brand)
79
+ qs.set('brand', opts.brand);
80
+ if (opts?.logo)
81
+ qs.set('logo', opts.logo);
82
+ if (opts?.whitelabel)
83
+ qs.set('whitelabel', 'true');
84
+ if (opts?.client_friendly)
85
+ qs.set('client_friendly', 'true');
86
+ const url = `${this.baseUrl}/api/v1/results/${encodeURIComponent(id)}/pdf${qs.size ? `?${qs.toString()}` : ''}`;
87
+ const response = await fetch(url, {
88
+ method: 'GET',
89
+ headers: { 'User-Agent': `colter-node/${VERSION}`, Accept: 'application/pdf' },
90
+ });
91
+ if (!response.ok) {
92
+ const bodyText = await response.text().catch(() => '');
93
+ throw new ColterError(response.status, bodyText || 'Request failed');
94
+ }
95
+ return response.arrayBuffer();
96
+ }
97
+ /** Create a revocable, expiring share link for a result id. */
98
+ async createShare(req) {
99
+ const response = await fetch(`${this.baseUrl}/api/v1/shares`, {
100
+ method: 'POST',
101
+ headers: {
102
+ 'Content-Type': 'application/json',
103
+ 'User-Agent': `colter-node/${VERSION}`,
104
+ Accept: 'application/json',
105
+ },
106
+ body: JSON.stringify(req),
107
+ });
108
+ if (!response.ok) {
109
+ const body = await response.json().catch(() => ({ error: 'Unknown error' }));
110
+ const message = typeof body.error === 'string' ? body.error : 'Request failed';
111
+ throw new ColterError(response.status, message);
112
+ }
113
+ return response.json();
114
+ }
115
+ /** Resolve a share token to a readiness result and share metadata. */
116
+ async resolveShare(token) {
117
+ const response = await fetch(`${this.baseUrl}/api/v1/shares/${encodeURIComponent(token)}`, {
118
+ method: 'GET',
119
+ headers: { 'User-Agent': `colter-node/${VERSION}`, Accept: 'application/json' },
120
+ });
121
+ if (!response.ok) {
122
+ const body = await response.json().catch(() => ({ error: 'Unknown error' }));
123
+ const message = typeof body.error === 'string' ? body.error : 'Request failed';
124
+ throw new ColterError(response.status, message);
125
+ }
126
+ return response.json();
127
+ }
128
+ /** Download the branded PDF for a share token (branding comes from the share record). */
129
+ async getSharePdf(token) {
130
+ const response = await fetch(`${this.baseUrl}/api/v1/shares/${encodeURIComponent(token)}/pdf`, {
131
+ method: 'GET',
132
+ headers: { 'User-Agent': `colter-node/${VERSION}`, Accept: 'application/pdf' },
133
+ });
134
+ if (!response.ok) {
135
+ const bodyText = await response.text().catch(() => '');
136
+ throw new ColterError(response.status, bodyText || 'Request failed');
137
+ }
138
+ return response.arrayBuffer();
139
+ }
140
+ /** Revoke a share token using its revoke secret. */
141
+ async revokeShare(token, revokeToken) {
142
+ const response = await fetch(`${this.baseUrl}/api/v1/shares/${encodeURIComponent(token)}/revoke`, {
143
+ method: 'POST',
144
+ headers: {
145
+ 'Content-Type': 'application/json',
146
+ 'User-Agent': `colter-node/${VERSION}`,
147
+ Accept: 'application/json',
148
+ },
149
+ body: JSON.stringify({ revoke_token: revokeToken }),
150
+ });
151
+ if (!response.ok) {
152
+ const body = await response.json().catch(() => ({ error: 'Unknown error' }));
153
+ const message = typeof body.error === 'string' ? body.error : 'Request failed';
154
+ throw new ColterError(response.status, message);
155
+ }
156
+ return response.json();
157
+ }
158
+ }
159
+ export class ColterCLIError extends Error {
160
+ constructor(message, exitCode, stdout, stderr) {
161
+ super(message);
162
+ this.name = 'ColterCLIError';
163
+ this.exitCode = exitCode;
164
+ this.stdout = stdout;
165
+ this.stderr = stderr;
166
+ }
167
+ }
168
+ const execFileAsync = promisify(execFile);
169
+ async function whichColter() {
170
+ const cmd = process.platform === 'win32' ? 'where' : 'which';
171
+ try {
172
+ const { stdout } = await execFileAsync(cmd, ['colter'], { encoding: 'utf8' });
173
+ const p = stdout.trim().split(/\r?\n/)[0];
174
+ return p && existsSync(p) ? p : null;
175
+ }
176
+ catch {
177
+ return null;
178
+ }
179
+ }
180
+ export class ColterCLI {
181
+ constructor(opts) {
182
+ this.cwd = opts?.cwd;
183
+ this.env = opts?.env;
184
+ this.timeoutMs = opts?.timeoutMs;
185
+ const explicit = opts?.colterPath || process.env.COLTER_PATH;
186
+ this.colterPath = (async () => {
187
+ if (explicit)
188
+ return explicit;
189
+ const resolved = await whichColter();
190
+ if (resolved)
191
+ return resolved;
192
+ throw new ColterCLIError('colter binary not found (set COLTER_PATH or install @getcolter/cli)', null, '', '');
193
+ })();
194
+ }
195
+ async run(args) {
196
+ const bin = await this.colterPath;
197
+ return new Promise((resolve, reject) => {
198
+ const child = spawn(bin, args, {
199
+ cwd: this.cwd,
200
+ env: { ...process.env, ...this.env },
201
+ stdio: ['ignore', 'pipe', 'pipe'],
202
+ });
203
+ let stdout = '';
204
+ let stderr = '';
205
+ child.stdout.setEncoding('utf8');
206
+ child.stderr.setEncoding('utf8');
207
+ child.stdout.on('data', (d) => (stdout += d));
208
+ child.stderr.on('data', (d) => (stderr += d));
209
+ let timer;
210
+ if (this.timeoutMs && this.timeoutMs > 0) {
211
+ timer = setTimeout(() => {
212
+ child.kill('SIGKILL');
213
+ }, this.timeoutMs);
214
+ }
215
+ child.on('error', (err) => {
216
+ if (timer)
217
+ clearTimeout(timer);
218
+ reject(new ColterCLIError(String(err), null, stdout, stderr));
219
+ });
220
+ child.on('close', (code) => {
221
+ if (timer)
222
+ clearTimeout(timer);
223
+ resolve({ stdout, stderr, exitCode: code });
224
+ });
225
+ });
226
+ }
227
+ async check(url) {
228
+ const r = await this.run(['check', url, '--json']);
229
+ try {
230
+ return JSON.parse(r.stdout);
231
+ }
232
+ catch {
233
+ throw new ColterCLIError('failed to parse JSON output from colter check', r.exitCode, r.stdout, r.stderr);
234
+ }
235
+ }
236
+ async verify(target, opts) {
237
+ const args = ['verify', target, '--json'];
238
+ if (opts?.out)
239
+ args.push('--out', opts.out);
240
+ if (opts?.protocols?.length)
241
+ args.push('--protocols', opts.protocols.join(','));
242
+ if (opts?.schemaAcp)
243
+ args.push('--schema-acp', opts.schemaAcp);
244
+ if (opts?.schemaUcp)
245
+ args.push('--schema-ucp', opts.schemaUcp);
246
+ if (opts?.tests?.length) {
247
+ for (const t of opts.tests)
248
+ args.push('--tests', t);
249
+ }
250
+ const r = await this.run(args);
251
+ let pack;
252
+ try {
253
+ pack = JSON.parse(r.stdout);
254
+ }
255
+ catch {
256
+ throw new ColterCLIError('failed to parse JSON output from colter verify', r.exitCode, r.stdout, r.stderr);
257
+ }
258
+ if (opts?.throwOnFail && r.exitCode && r.exitCode !== 0) {
259
+ throw new ColterCLIError('colter verify failed', r.exitCode, r.stdout, r.stderr);
260
+ }
261
+ return { pack, exitCode: r.exitCode };
262
+ }
263
+ async replay(packPath, opts) {
264
+ const args = ['replay', packPath, '--json'];
265
+ if (opts?.live)
266
+ args.push('--live');
267
+ const r = await this.run(args);
268
+ try {
269
+ return JSON.parse(r.stdout);
270
+ }
271
+ catch {
272
+ throw new ColterCLIError('failed to parse JSON output from colter replay', r.exitCode, r.stdout, r.stderr);
273
+ }
274
+ }
275
+ async diff(packA, packB) {
276
+ const r = await this.run(['diff', packA, packB, '--json']);
277
+ try {
278
+ return JSON.parse(r.stdout);
279
+ }
280
+ catch {
281
+ throw new ColterCLIError('failed to parse JSON output from colter diff', r.exitCode, r.stdout, r.stderr);
282
+ }
283
+ }
284
+ async exportJson(packPath) {
285
+ const r = await this.run(['export', packPath, '--format', 'json']);
286
+ try {
287
+ return JSON.parse(r.stdout);
288
+ }
289
+ catch {
290
+ throw new ColterCLIError('failed to parse JSON output from colter export', r.exitCode, r.stdout, r.stderr);
291
+ }
292
+ }
293
+ async version() {
294
+ const r = await this.run(['version']);
295
+ if (r.exitCode && r.exitCode !== 0) {
296
+ throw new ColterCLIError('colter version failed', r.exitCode, r.stdout, r.stderr);
297
+ }
298
+ return r.stdout.trim();
299
+ }
300
+ }
301
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,iDAAiD;AACjD,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,mCAAmC;AACnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AAQxD;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IAMpC,YAAY,UAAkB,EAAE,OAAe,EAAE,UAAmB;QAClE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AAED;;;;;;;;;GASG;AACH,MAAM,OAAO,YAAY;IAGvB,YAAY,OAA6B;QACvC,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,gBAAgB,CAAC;IACtD,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,CAAC,GAAW;QACrB,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,eAAe,EAAE;YAC3D,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,YAAY,EAAE,eAAe,OAAO,EAAE;gBACtC,MAAM,EAAE,kBAAkB;aAC3B;YACD,IAAI,EAAE,IAAI,CA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E,CAAC;YACnC,MAAM,IAAI,cAAc,CAAC,uBAAuB,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;QACpF,CAAC;QACD,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;CACF"}
@@ -0,0 +1,125 @@
1
+ /** Detection result for a single protocol endpoint. */
2
+ export interface ProtocolCheck {
3
+ /** Whether the protocol endpoint was found and returned valid JSON. */
4
+ detected: boolean;
5
+ /** The well-known path probed (e.g. `/.well-known/ucp`). Empty if not found. */
6
+ endpoint: string;
7
+ /** Protocol version from the manifest, if available. */
8
+ version: string;
9
+ /** Error message if detection failed. Empty on success. */
10
+ error: string;
11
+ }
12
+ /** Detection results for all agent protocols. */
13
+ export interface ProtocolStatus {
14
+ ucp: ProtocolCheck;
15
+ acp: ProtocolCheck;
16
+ mcp: ProtocolCheck;
17
+ }
18
+ /** Detected e-commerce platform details. */
19
+ export interface StoreStatus {
20
+ /** Detected platform (e.g. `shopify`, `woocommerce`, or empty). */
21
+ platform: string;
22
+ /** Confidence score for platform detection (0..1). */
23
+ platform_confidence: number;
24
+ /** Number of products detected, or 0 if unknown. */
25
+ product_count: number;
26
+ /** Detected payment provider (if known). */
27
+ psp?: string;
28
+ /** Whether the store platform could be identified. */
29
+ detectable: boolean;
30
+ }
31
+ /** Which AI ecosystems are supported. */
32
+ export interface CoverageStatus {
33
+ /** True if UCP detected (Gemini, AI Mode, Copilot). */
34
+ google_ecosystem: boolean;
35
+ /** True if ACP detected (ChatGPT, Operator). */
36
+ openai_ecosystem: boolean;
37
+ }
38
+ /** Web discoverability signals found on the store. */
39
+ export interface WebSignals {
40
+ /** True if the page contains JSON-LD structured data. */
41
+ json_ld_found: boolean;
42
+ /** Schema.org types found (e.g. `["Product", "Organization"]`). */
43
+ json_ld_types: string[];
44
+ /** True if `/sitemap.xml` is accessible. */
45
+ sitemap_found: boolean;
46
+ /** True if `/robots.txt` exists and allows crawling. */
47
+ robots_txt_found: boolean;
48
+ /** True if Open Graph meta tags are present. */
49
+ og_tags_found: boolean;
50
+ }
51
+ /** Per-persona summaries of the check result. */
52
+ export interface PlainLanguage {
53
+ /** Business-focused summary for store owners. */
54
+ merchant: string;
55
+ /** Portfolio-focused summary for agencies managing multiple stores. */
56
+ agency: string;
57
+ /** Technical summary with protocol pass/fail details. */
58
+ developer: string;
59
+ }
60
+ /** A structured next-step suggestion (in addition to the free-form recommendation string). */
61
+ export interface NextStep {
62
+ kind: 'cli';
63
+ command: 'colter';
64
+ args: string[];
65
+ reason: string;
66
+ }
67
+ /** Overall readiness verdict. */
68
+ export type Verdict = 'AGENT-READY' | 'PARTIALLY AGENT-READY' | 'NOT AGENT-READY';
69
+ /** Full response from a Colter readiness check. */
70
+ export interface CheckResult {
71
+ /** Normalized hostname of the store that was checked. */
72
+ url: string;
73
+ /** True if at least one protocol (UCP or ACP) is detected. */
74
+ agent_ready: boolean;
75
+ /** True if both UCP and ACP are detected. */
76
+ fully_covered: boolean;
77
+ /** Protocol detection results. */
78
+ protocols: ProtocolStatus;
79
+ /** Web discoverability signals. */
80
+ web_signals: WebSignals;
81
+ /** Detected store platform details. */
82
+ store: StoreStatus;
83
+ /** AI ecosystem coverage. */
84
+ coverage: CoverageStatus;
85
+ /** Overall readiness verdict. */
86
+ verdict: Verdict;
87
+ /** Suggested next CLI command, or empty if fully ready. */
88
+ recommendation: string;
89
+ /** Structured next-step suggestion (optional). */
90
+ next_step?: NextStep;
91
+ /** Per-persona summaries. */
92
+ plain_language: PlainLanguage;
93
+ /** ISO 8601 timestamp of when the check was performed. */
94
+ checked_at: string;
95
+ /** Unique identifier for this check result. */
96
+ result_id?: string;
97
+ }
98
+ export interface ShareCreateRequest {
99
+ result_id: string;
100
+ brand?: string;
101
+ logo?: string;
102
+ whitelabel?: boolean;
103
+ client_friendly?: boolean;
104
+ expires_in_days?: number;
105
+ }
106
+ export interface ShareCreateResponse {
107
+ token: string;
108
+ url: string;
109
+ revoke_token: string;
110
+ expires_at: string;
111
+ }
112
+ export interface ShareResolved {
113
+ token: string;
114
+ result_id: string;
115
+ brand?: string | null;
116
+ logo?: string | null;
117
+ whitelabel: boolean;
118
+ client_friendly: boolean;
119
+ expires_at: string;
120
+ }
121
+ export interface ShareResolveResponse {
122
+ share: ShareResolved;
123
+ result: CheckResult;
124
+ }
125
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,uEAAuE;IACvE,QAAQ,EAAE,OAAO,CAAC;IAClB,gFAAgF;IAChF,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,KAAK,EAAE,MAAM,CAAC;CACf;AAED,iDAAiD;AACjD,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,aAAa,CAAC;IACnB,GAAG,EAAE,aAAa,CAAC;IACnB,GAAG,EAAE,aAAa,CAAC;CACpB;AAED,4CAA4C;AAC5C,MAAM,WAAW,WAAW;IAC1B,mEAAmE;IACnE,QAAQ,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oDAAoD;IACpD,aAAa,EAAE,MAAM,CAAC;IACtB,4CAA4C;IAC5C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,yCAAyC;AACzC,MAAM,WAAW,cAAc;IAC7B,uDAAuD;IACvD,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gDAAgD;IAChD,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED,sDAAsD;AACtD,MAAM,WAAW,UAAU;IACzB,yDAAyD;IACzD,aAAa,EAAE,OAAO,CAAC;IACvB,mEAAm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AAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,eAAe,EAAE,OAAO,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,EAAE,WAAW,CAAC;CACrB"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@getcolter/sdk",
3
+ "version": "0.1.0",
4
+ "description": "Official Colter SDK for Node.js — check if AI agents can shop your store",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "prepare": "npm run build",
22
+ "test": "npm run build && node --test test/*.test.mjs"
23
+ },
24
+ "keywords": [
25
+ "colter",
26
+ "agentic-commerce",
27
+ "ucp",
28
+ "acp",
29
+ "ai-agents",
30
+ "agent-ready",
31
+ "e-commerce"
32
+ ],
33
+ "author": "Colter <hello@agenticcom.ai>",
34
+ "license": "MIT",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/mfbahc/agentic-com.git"
38
+ },
39
+ "homepage": "https://agenticcom.ai/docs",
40
+ "engines": {
41
+ "node": ">=18.0.0"
42
+ },
43
+ "devDependencies": {
44
+ "@types/node": "^20.0.0",
45
+ "typescript": "^5.3.0"
46
+ }
47
+ }