@getopencrawl/sdk 0.0.0-stage → 0.2.1
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 +598 -2
- package/dist/agentPlatform.d.ts +146 -0
- package/dist/agentPlatform.d.ts.map +1 -0
- package/dist/agentPlatform.js +48 -0
- package/dist/agentPlatform.js.map +1 -0
- package/dist/agents.d.ts +237 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +279 -0
- package/dist/agents.js.map +1 -0
- package/dist/answerContract.d.ts +85 -0
- package/dist/answerContract.d.ts.map +1 -0
- package/dist/answerContract.js +112 -0
- package/dist/answerContract.js.map +1 -0
- package/dist/answerView.d.ts +40 -0
- package/dist/answerView.d.ts.map +1 -0
- package/dist/answerView.js +118 -0
- package/dist/answerView.js.map +1 -0
- package/dist/configuration.d.ts +5 -0
- package/dist/configuration.d.ts.map +1 -0
- package/dist/configuration.js +29 -0
- package/dist/configuration.js.map +1 -0
- package/dist/customers.d.ts +176 -0
- package/dist/customers.d.ts.map +1 -0
- package/dist/customers.js +286 -0
- package/dist/customers.js.map +1 -0
- package/dist/errors.d.ts +35 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +58 -0
- package/dist/errors.js.map +1 -0
- package/dist/eventEvidence.d.ts +10 -0
- package/dist/eventEvidence.d.ts.map +1 -0
- package/dist/eventEvidence.js +52 -0
- package/dist/eventEvidence.js.map +1 -0
- package/dist/index.d.ts +98 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +139 -0
- package/dist/index.js.map +1 -0
- package/dist/productMonitors.d.ts +258 -0
- package/dist/productMonitors.d.ts.map +1 -0
- package/dist/productMonitors.js +68 -0
- package/dist/productMonitors.js.map +1 -0
- package/dist/researchAnswerContract.d.ts +8 -0
- package/dist/researchAnswerContract.d.ts.map +1 -0
- package/dist/researchAnswerContract.js +23 -0
- package/dist/researchAnswerContract.js.map +1 -0
- package/dist/researchAnswerView.d.ts +8 -0
- package/dist/researchAnswerView.d.ts.map +1 -0
- package/dist/researchAnswerView.js +27 -0
- package/dist/researchAnswerView.js.map +1 -0
- package/dist/researchCompletion.d.ts +114 -0
- package/dist/researchCompletion.d.ts.map +1 -0
- package/dist/researchCompletion.js +94 -0
- package/dist/researchCompletion.js.map +1 -0
- package/dist/serviceTenants.d.ts +15 -0
- package/dist/serviceTenants.d.ts.map +1 -0
- package/dist/serviceTenants.js +58 -0
- package/dist/serviceTenants.js.map +1 -0
- package/dist/tools.d.ts +59 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +60 -0
- package/dist/tools.js.map +1 -0
- package/dist/transport.d.ts +34 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +227 -0
- package/dist/transport.js.map +1 -0
- package/dist/types.d.ts +399 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/webhooks.d.ts +38 -0
- package/dist/webhooks.d.ts.map +1 -0
- package/dist/webhooks.js +73 -0
- package/dist/webhooks.js.map +1 -0
- package/examples/letter-customer-research-demo.mjs +54 -0
- package/examples/letter-customer-research-store.d.mts +38 -0
- package/examples/letter-customer-research-store.mjs +186 -0
- package/examples/letter-customer-research.d.mts +39 -0
- package/examples/letter-customer-research.mjs +194 -0
- package/examples/letter-event-receiver.d.mts +10 -0
- package/examples/letter-event-receiver.mjs +55 -0
- package/examples/letter-event-store.d.mts +35 -0
- package/examples/letter-event-store.mjs +84 -0
- package/examples/letter-seer.d.mts +31 -0
- package/examples/letter-seer.mjs +78 -0
- package/examples/letter-service-tenants.d.mts +12 -0
- package/examples/letter-service-tenants.mjs +49 -0
- package/examples/research-webhook-receiver.mjs +29 -0
- package/package.json +75 -4
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { OpenCrawlAPIError, OpenCrawlProtocolError, OpenCrawlTimeoutError, OpenCrawlValidationError } from './errors.js';
|
|
2
|
+
const CUSTOMER_ID = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;
|
|
3
|
+
const CADENCE = { hour: 60, day: 1440, week: 10080 };
|
|
4
|
+
const ACTIVE = new Set(['queued', 'running']);
|
|
5
|
+
const encoder = new TextEncoder();
|
|
6
|
+
/** Process-local key cache. Lost keys are recovered by rotation, so this is safe for
|
|
7
|
+
* a single process; with several processes use a shared KeyStore. */
|
|
8
|
+
export function memoryKeyStore() { const keys = new Map(); return { get: id => keys.get(id), set: (id, key) => { keys.set(id, key); } }; }
|
|
9
|
+
async function digest(value) { return Array.from(new Uint8Array(await crypto.subtle.digest('SHA-256', encoder.encode(value))), b => b.toString(16).padStart(2, '0')).join(''); }
|
|
10
|
+
function randomKey() { return crypto.randomUUID().replace(/-/g, ''); }
|
|
11
|
+
function clip(value, max) { const chars = Array.from(value.replace(/\s+/g, ' ').trim()); return chars.length > max ? chars.slice(0, max - 1).join('') + '…' : chars.join(''); }
|
|
12
|
+
function publicUrl(value) { if (typeof value !== 'string' || value.length > 2048)
|
|
13
|
+
return false; try {
|
|
14
|
+
const url = new URL(value);
|
|
15
|
+
return url.protocol === 'https:' || url.protocol === 'http:';
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return false;
|
|
19
|
+
} }
|
|
20
|
+
function unauthorized(error) { return error instanceof OpenCrawlAPIError && error.status === 401; }
|
|
21
|
+
function cadence(minutes) { return Object.keys(CADENCE).find(k => CADENCE[k] === minutes) ?? minutes; }
|
|
22
|
+
function cursorOf(signal) { return `${signal.observedAt}|${signal.id}`; }
|
|
23
|
+
function after(position, cursor) { if (!cursor)
|
|
24
|
+
return true; const [at, id = ''] = cursor.split('|'); return position.observed_at > at || position.observed_at === at && position.id > id; }
|
|
25
|
+
/** Deterministic description of one change for a feed or an agent. Prefers a
|
|
26
|
+
* server-generated headline when the observation carries one. */
|
|
27
|
+
export function signalHeadline(event) {
|
|
28
|
+
if (typeof event.change_summary?.headline === 'string' && event.change_summary.headline)
|
|
29
|
+
return event.change_summary.headline;
|
|
30
|
+
let host = event.url;
|
|
31
|
+
try {
|
|
32
|
+
host = new URL(event.url).host.replace(/^www\./, '');
|
|
33
|
+
}
|
|
34
|
+
catch { }
|
|
35
|
+
if (event.kind === 'unavailable')
|
|
36
|
+
return `${host}: page could not be checked`;
|
|
37
|
+
if (event.kind === 'recovered')
|
|
38
|
+
return `${host}: page available again`;
|
|
39
|
+
const hunk = (event.change_summary?.changes ?? []).find(h => !h.volatile);
|
|
40
|
+
if (hunk) {
|
|
41
|
+
const added = hunk.added[0], removed = hunk.removed[0];
|
|
42
|
+
if (added && removed)
|
|
43
|
+
return `${host}: “${clip(removed, 70)}” → “${clip(added, 70)}”`;
|
|
44
|
+
if (added)
|
|
45
|
+
return `${host}: new “${clip(added, 120)}”`;
|
|
46
|
+
if (removed)
|
|
47
|
+
return `${host}: removed “${clip(removed, 120)}”`;
|
|
48
|
+
}
|
|
49
|
+
const added = event.change_summary?.added?.[0];
|
|
50
|
+
return added ? `${host}: changed “${clip(added, 120)}”` : `${host}: page changed`;
|
|
51
|
+
}
|
|
52
|
+
function toSignal(event, watch) {
|
|
53
|
+
const summary = event.change_summary;
|
|
54
|
+
const hunks = summary.changes;
|
|
55
|
+
return { id: event.id, watchId: watch.id, watchName: watch.name, url: event.url, kind: event.kind, observedAt: event.observed_at, previousObservedAt: event.previous_observed_at,
|
|
56
|
+
headline: signalHeadline(event), relevance: summary.relevance ?? null, relevanceReason: summary.relevance_reason ?? null,
|
|
57
|
+
changes: hunks ? hunks.filter(h => !h.volatile).map(h => ({ removed: h.removed, added: h.added })) : [{ removed: summary.removed ?? [], added: summary.added ?? [] }],
|
|
58
|
+
truncated: Boolean(summary.changes_truncated ?? summary.truncated), gap: event.gap };
|
|
59
|
+
}
|
|
60
|
+
function toWatch(c) { return { id: c.id, name: c.name, urls: c.seed_urls, every: cadence(c.schedule_minutes), status: c.status, lastCheckedAt: c.last_checked_at, createdAt: c.created_at }; }
|
|
61
|
+
function encodeAnswerId(agentId, runId) { return `${agentId}.${runId}`; }
|
|
62
|
+
function decodeAnswerId(answerId) { const match = typeof answerId === 'string' ? /^(ragent_[0-9a-f]{32})\.(job_[0-9a-f]{32})$/.exec(answerId) : null; if (!match)
|
|
63
|
+
throw new OpenCrawlValidationError('Use an answerId returned by ask().'); return { agentId: match[1], runId: match[2] }; }
|
|
64
|
+
function toAnswer(agent, run) {
|
|
65
|
+
return { answerId: encodeAnswerId(agent.id, run.id), question: agent.goal, status: run.status, done: !ACTIVE.has(run.status),
|
|
66
|
+
findings: run.findings.map(f => ({ claim: f.claim, qualifiers: f.qualifiers, sources: f.citations.map(c => ({ url: c.url, title: c.title, quote: c.quote, publishedAt: c.published_at })) })),
|
|
67
|
+
gaps: run.gaps, startedAt: run.created_at, finishedAt: run.finished_at };
|
|
68
|
+
}
|
|
69
|
+
/** One Letter customer, isolated in its own OpenCrawl workspace. */
|
|
70
|
+
export class Customer {
|
|
71
|
+
id;
|
|
72
|
+
profile;
|
|
73
|
+
#client;
|
|
74
|
+
#refresh;
|
|
75
|
+
#key;
|
|
76
|
+
constructor(profile, client, key, refresh) { this.id = profile.id; this.profile = Object.freeze({ ...profile }); this.#client = client; this.#key = key; this.#refresh = refresh; }
|
|
77
|
+
/** The underlying customer-scoped client, for anything not covered here. */
|
|
78
|
+
get client() { return this.#client; }
|
|
79
|
+
async #call(work) {
|
|
80
|
+
try {
|
|
81
|
+
return await work(this.#client);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
if (!unauthorized(error))
|
|
85
|
+
throw error;
|
|
86
|
+
this.#client = await this.#refresh();
|
|
87
|
+
return work(this.#client);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/** Watch public pages for changes. Calling again with the same name, pages and
|
|
91
|
+
* cadence returns the same watch (resuming it if it was stopped). */
|
|
92
|
+
async watch(input, options = {}) {
|
|
93
|
+
if (!input || typeof input.name !== 'string' || !input.name.trim() || input.name.length > 200)
|
|
94
|
+
throw new OpenCrawlValidationError('Give the watch a name of at most 200 characters.');
|
|
95
|
+
const urls = [...new Set(input.urls ?? [])];
|
|
96
|
+
if (!urls.length || urls.length > 50 || !urls.every(publicUrl))
|
|
97
|
+
throw new OpenCrawlValidationError('Watch 1–50 public http(s) page URLs.');
|
|
98
|
+
const every = input.every ?? 'day';
|
|
99
|
+
if (!(every in CADENCE))
|
|
100
|
+
throw new OpenCrawlValidationError('every must be hour, day or week.');
|
|
101
|
+
// The brief tells OpenCrawl what matters when it rates each change's relevance.
|
|
102
|
+
const brief = input.brief ?? clip(`Competitor and market signals for ${this.profile.name} (${this.profile.website}).${this.profile.context ? ' ' + this.profile.context : ''}`, 4000);
|
|
103
|
+
if (typeof brief !== 'string' || brief.length > 4000)
|
|
104
|
+
throw new OpenCrawlValidationError('brief must be at most 4000 characters.');
|
|
105
|
+
const key = 'watch_' + (await digest(JSON.stringify([this.id, input.name.trim(), [...urls].sort(), every, brief]))).slice(0, 48);
|
|
106
|
+
return this.#call(async (client) => {
|
|
107
|
+
const receipt = await client.collections.create({ name: input.name.trim(), brief, seed_urls: urls, page_limit: urls.length, schedule_minutes: CADENCE[every], include_media: false }, { ...options, idempotencyKey: key });
|
|
108
|
+
// A replayed receipt is the original snapshot; read the watch's current state.
|
|
109
|
+
let collection = receipt.replayed ? await client.collections.get(receipt.collection.id, options) : receipt.collection;
|
|
110
|
+
if (collection.status === 'paused')
|
|
111
|
+
collection = await client.collections.update(collection.id, { expected_revision: collection.revision, status: 'active' }, options);
|
|
112
|
+
return toWatch(collection);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
async watches(options = {}) { return (await this.#collections(options)).map(toWatch); }
|
|
116
|
+
/** Stop checking a watch. History and earlier signals are kept. */
|
|
117
|
+
async unwatch(watchId, options = {}) {
|
|
118
|
+
return this.#call(async (client) => { const c = await client.collections.get(watchId, options); return toWatch(c.status === 'paused' ? c : await client.collections.update(c.id, { expected_revision: c.revision, status: 'paused' }, options)); });
|
|
119
|
+
}
|
|
120
|
+
async #collections(options) {
|
|
121
|
+
return this.#call(async (client) => { const all = []; let cursor; for (let page = 0; page < 20; page++) {
|
|
122
|
+
const result = await client.collections.list({ ...options, limit: 100, cursor });
|
|
123
|
+
all.push(...result.items);
|
|
124
|
+
if (!result.next_cursor)
|
|
125
|
+
break;
|
|
126
|
+
cursor = result.next_cursor;
|
|
127
|
+
} return all; });
|
|
128
|
+
}
|
|
129
|
+
/** Content changes, unavailable pages and recoveries after `since` (the cursor from the
|
|
130
|
+
* previous call), oldest first. Date-, clock- and age-only edits are left out. */
|
|
131
|
+
async signals(options = {}) {
|
|
132
|
+
const limit = options.limit ?? 50;
|
|
133
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 200)
|
|
134
|
+
throw new OpenCrawlValidationError('limit must be 1–200.');
|
|
135
|
+
const since = options.since ?? null;
|
|
136
|
+
if (since !== null && (typeof since !== 'string' || since.length > 300))
|
|
137
|
+
throw new OpenCrawlValidationError('since must be a cursor returned by signals().');
|
|
138
|
+
const watches = options.watchId ? [await this.#call(client => client.collections.get(options.watchId, options))] : await this.#collections(options);
|
|
139
|
+
const found = [];
|
|
140
|
+
let more = false;
|
|
141
|
+
for (const watch of watches) {
|
|
142
|
+
let cursor;
|
|
143
|
+
pages: for (let page = 0; page < 10; page++) {
|
|
144
|
+
const result = await this.#call(client => client.collections.events(watch.id, { signal: options.signal, timeoutMs: options.timeoutMs, limit: 100, cursor, includeVolatile: false }));
|
|
145
|
+
for (const event of result.items) {
|
|
146
|
+
if (!after(event, since))
|
|
147
|
+
break pages;
|
|
148
|
+
if (event.kind === 'baseline' || event.change_summary.substance === 'volatile_only')
|
|
149
|
+
continue;
|
|
150
|
+
found.push(toSignal(event, watch));
|
|
151
|
+
}
|
|
152
|
+
if (!result.next_cursor)
|
|
153
|
+
break;
|
|
154
|
+
cursor = result.next_cursor;
|
|
155
|
+
if (page === 9)
|
|
156
|
+
more = true;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
found.sort((a, b) => a.observedAt < b.observedAt ? -1 : a.observedAt > b.observedAt ? 1 : a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
|
|
160
|
+
if (found.length > limit) {
|
|
161
|
+
found.length = limit;
|
|
162
|
+
more = true;
|
|
163
|
+
}
|
|
164
|
+
return { signals: found, cursor: found.length ? cursorOf(found[found.length - 1]) : since, more };
|
|
165
|
+
}
|
|
166
|
+
/** Research a question on the public web (or on up to three named pages) and wait up
|
|
167
|
+
* to `waitMs` for cited findings. Asking the same question again reuses a recent answer. */
|
|
168
|
+
async ask(question, options = {}) {
|
|
169
|
+
if (typeof question !== 'string' || !question.trim())
|
|
170
|
+
throw new OpenCrawlValidationError('Ask a question.');
|
|
171
|
+
const urls = [...new Set(options.urls ?? [])];
|
|
172
|
+
if (urls.length > 3 || !urls.every(publicUrl))
|
|
173
|
+
throw new OpenCrawlValidationError('Name at most three public http(s) pages.');
|
|
174
|
+
const goal = urls.length ? `${question.trim()}\n\nRead these pages:\n${urls.join('\n')}\n` : question.trim();
|
|
175
|
+
if (goal.length > 4000)
|
|
176
|
+
throw new OpenCrawlValidationError('The question and pages must fit in 4000 characters.');
|
|
177
|
+
const reuse = options.reuseWithinMs ?? 6 * 3600000, waitMs = options.waitMs ?? 240000;
|
|
178
|
+
const customer = { name: this.profile.name.trim(), website: this.profile.website, context: this.profile.context ?? '' };
|
|
179
|
+
const key = 'ask_' + (await digest(JSON.stringify([this.id, goal, customer]))).slice(0, 48);
|
|
180
|
+
let { agent, run } = await this.#call(client => client.agents.create({ customer, goal, collection_ids: [] }, { signal: options.signal, timeoutMs: options.timeoutMs, idempotencyKey: key }));
|
|
181
|
+
if (agent.status === 'paused')
|
|
182
|
+
throw new OpenCrawlValidationError('This question was paused in OpenCrawl. Resume its agent to ask again.');
|
|
183
|
+
const latest = (await this.#call(client => client.agents.get(agent.id, options))).latest_run ?? run;
|
|
184
|
+
run = latest;
|
|
185
|
+
const stale = !ACTIVE.has(run.status) && (['failed', 'unknown', 'cancelled'].includes(run.status) || !run.finished_at || Date.now() - Date.parse(run.finished_at) > reuse);
|
|
186
|
+
if (stale)
|
|
187
|
+
({ run } = await this.#call(client => client.agents.runs.create(agent.id, { expected_revision: agent.revision }, { signal: options.signal, timeoutMs: options.timeoutMs, idempotencyKey: randomKey() })));
|
|
188
|
+
return this.#wait(agent, run, waitMs, options);
|
|
189
|
+
}
|
|
190
|
+
/** Read an answer started earlier, optionally waiting for it to finish. */
|
|
191
|
+
async answer(answerId, options = {}) {
|
|
192
|
+
const { agentId, runId } = decodeAnswerId(answerId);
|
|
193
|
+
const [agent, run] = await this.#call(client => Promise.all([client.agents.get(agentId, options), client.agents.runs.get(agentId, runId, options)]));
|
|
194
|
+
return this.#wait(agent, run, options.waitMs ?? 0, options);
|
|
195
|
+
}
|
|
196
|
+
async #wait(agent, run, waitMs, options) {
|
|
197
|
+
if (!ACTIVE.has(run.status) || waitMs <= 0)
|
|
198
|
+
return toAnswer(agent, run);
|
|
199
|
+
try {
|
|
200
|
+
run = await this.#call(client => client.agents.runs.wait(agent.id, run.id, { signal: options.signal, maxWaitMs: waitMs, pollIntervalMs: 3000 }));
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
if (!(error instanceof OpenCrawlTimeoutError))
|
|
204
|
+
throw error;
|
|
205
|
+
run = await this.#call(client => client.agents.runs.get(agent.id, run.id, options));
|
|
206
|
+
}
|
|
207
|
+
return toAnswer(agent, run);
|
|
208
|
+
}
|
|
209
|
+
/** Connection details for OpenCrawl's hosted MCP server, scoped to this customer. */
|
|
210
|
+
mcp() { return { url: this.#client.baseUrl.replace(/\/$/, '') + '/mcp', headers: { Authorization: `Bearer ${this.#key()}` } }; }
|
|
211
|
+
}
|
|
212
|
+
/** Customer isolation for a platform serving many end customers with one admin key. */
|
|
213
|
+
export class Customers {
|
|
214
|
+
#parent;
|
|
215
|
+
#keys;
|
|
216
|
+
#make;
|
|
217
|
+
#cache = new Map();
|
|
218
|
+
constructor(parent, keys, make) { this.#parent = parent; this.#keys = keys; this.#make = make; }
|
|
219
|
+
/** Load a customer, provisioning its isolated workspace on first use. */
|
|
220
|
+
get(profile, options = {}) {
|
|
221
|
+
if (!profile || typeof profile.id !== 'string' || !CUSTOMER_ID.test(profile.id))
|
|
222
|
+
throw new OpenCrawlValidationError('Customer id must be 1–128 letters, numbers, dots, colons, underscores or hyphens.');
|
|
223
|
+
if (typeof profile.name !== 'string' || !profile.name.trim() || Array.from(profile.name).length > 120 || /[\x00-\x1f\x7f]/.test(profile.name))
|
|
224
|
+
throw new OpenCrawlValidationError('Customer name must be 1–120 printable characters.');
|
|
225
|
+
if (!publicUrl(profile.website))
|
|
226
|
+
throw new OpenCrawlValidationError('Customer website must be a public http(s) URL.');
|
|
227
|
+
if (profile.context !== undefined && (typeof profile.context !== 'string' || profile.context.length > 4000))
|
|
228
|
+
throw new OpenCrawlValidationError('Customer context must be at most 4000 characters.');
|
|
229
|
+
const cached = this.#cache.get(profile.id);
|
|
230
|
+
if (cached)
|
|
231
|
+
return cached;
|
|
232
|
+
const loading = this.#load(profile, options).catch(error => { this.#cache.delete(profile.id); throw error; });
|
|
233
|
+
this.#cache.set(profile.id, loading);
|
|
234
|
+
return loading;
|
|
235
|
+
}
|
|
236
|
+
async #load(profile, options) {
|
|
237
|
+
let key = await this.#keys.get(profile.id) ?? await this.#provision(profile, options, null);
|
|
238
|
+
const refresh = async () => { const stored = await this.#keys.get(profile.id); key = stored && stored !== key ? stored : await this.#provision(profile, options, key); return this.#make(key); };
|
|
239
|
+
return new Customer(profile, this.#make(key), () => key, refresh);
|
|
240
|
+
}
|
|
241
|
+
async #provision(profile, options, stale) {
|
|
242
|
+
let tenant = await this.#find(profile.id, options);
|
|
243
|
+
if (!tenant) {
|
|
244
|
+
try {
|
|
245
|
+
const receipt = await this.#parent.createServiceTenant({ external_customer_id: profile.id, name: profile.name.trim() }, { ...options, idempotencyKey: randomKey() });
|
|
246
|
+
if (receipt.key) {
|
|
247
|
+
await this.#keys.set(profile.id, receipt.key);
|
|
248
|
+
return receipt.key;
|
|
249
|
+
}
|
|
250
|
+
tenant = receipt.tenant;
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
if (!(error instanceof OpenCrawlAPIError && error.status === 409))
|
|
254
|
+
throw error;
|
|
255
|
+
tenant = await this.#find(profile.id, options);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (!tenant)
|
|
259
|
+
throw new OpenCrawlProtocolError('The customer could not be found after provisioning.');
|
|
260
|
+
if (tenant.status !== 'active')
|
|
261
|
+
throw new OpenCrawlValidationError(`Customer ${profile.id} was removed from OpenCrawl and cannot be reused.`);
|
|
262
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
263
|
+
try {
|
|
264
|
+
const receipt = await this.#parent.rotateServiceTenantKey(tenant.id, { expected_revision: tenant.revision }, { ...options, idempotencyKey: randomKey() });
|
|
265
|
+
if (!receipt.key)
|
|
266
|
+
throw new OpenCrawlProtocolError('OpenCrawl did not return the new customer key.');
|
|
267
|
+
await this.#keys.set(profile.id, receipt.key);
|
|
268
|
+
return receipt.key;
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
271
|
+
if (!(error instanceof OpenCrawlAPIError && error.status === 409))
|
|
272
|
+
throw error;
|
|
273
|
+
// Another process rotated first; use the key it stored, or retry on the new revision.
|
|
274
|
+
const stored = await this.#keys.get(profile.id);
|
|
275
|
+
if (stored && stored !== stale)
|
|
276
|
+
return stored;
|
|
277
|
+
tenant = await this.#find(profile.id, options);
|
|
278
|
+
if (!tenant || tenant.status !== 'active')
|
|
279
|
+
throw error;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
throw new OpenCrawlProtocolError('The customer key changed repeatedly. Use a shared KeyStore across processes.');
|
|
283
|
+
}
|
|
284
|
+
async #find(id, options) { return (await this.#parent.listServiceTenants({ ...options, external_customer_id: id, limit: 1 })).items.find(t => t.external_customer_id === id); }
|
|
285
|
+
}
|
|
286
|
+
//# sourceMappingUR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AC,CAAC;IAClH,CAAC;IACD,KAAK,CAAC,KAAK,CAAC,EAAS,EAAC,OAAsB,IAAmC,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAC,GAAG,OAAO,EAAC,oBAAoB,EAAC,EAAE,EAAC,KAAK,EAAC,CAAC,EAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA,EAAE,CAAA,CAAC,CAAC,oBAAoB,KAAG,EAAE,CAAC,CAAA,CAAA,CAAC;CACvN"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Errors intentionally omit request headers, response bodies and transport causes. */
|
|
2
|
+
export declare class OpenCrawlError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class OpenCrawlValidationError extends OpenCrawlError {
|
|
6
|
+
}
|
|
7
|
+
export declare class OpenCrawlProtocolError extends OpenCrawlError {
|
|
8
|
+
readonly acceptanceUnknown: boolean;
|
|
9
|
+
readonly idempotencyKey?: string | undefined;
|
|
10
|
+
constructor(message: string, acceptanceUnknown?: boolean, idempotencyKey?: string | undefined);
|
|
11
|
+
}
|
|
12
|
+
export declare class OpenCrawlAbortError extends OpenCrawlError {
|
|
13
|
+
readonly acceptanceUnknown: boolean;
|
|
14
|
+
readonly idempotencyKey?: string | undefined;
|
|
15
|
+
constructor(message: string, acceptanceUnknown?: boolean, idempotencyKey?: string | undefined);
|
|
16
|
+
}
|
|
17
|
+
export declare class OpenCrawlTimeoutError extends OpenCrawlError {
|
|
18
|
+
readonly jobId?: string | undefined;
|
|
19
|
+
readonly acceptanceUnknown: boolean;
|
|
20
|
+
readonly idempotencyKey?: string | undefined;
|
|
21
|
+
constructor(message: string, jobId?: string | undefined, acceptanceUnknown?: boolean, idempotencyKey?: string | undefined);
|
|
22
|
+
}
|
|
23
|
+
export declare class OpenCrawlConnectionError extends OpenCrawlError {
|
|
24
|
+
readonly acceptanceUnknown: boolean;
|
|
25
|
+
readonly idempotencyKey?: string | undefined;
|
|
26
|
+
constructor(message: string, acceptanceUnknown: boolean, idempotencyKey?: string | undefined);
|
|
27
|
+
}
|
|
28
|
+
export declare class OpenCrawlAPIError extends OpenCrawlError {
|
|
29
|
+
readonly status: number;
|
|
30
|
+
readonly code?: string | undefined;
|
|
31
|
+
readonly requestId?: string | undefined;
|
|
32
|
+
readonly retryAfterMs?: number | undefined;
|
|
33
|
+
constructor(message: string, status: number, code?: string | undefined, requestId?: string | undefined, retryAfterMs?: number | undefined);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAC,MAAM;CAC3B;AACD,qBAAa,wBAAyB,SAAQ,cAAc;CAAG;AAC/D,qBAAa,sBAAuB,SAAQ,cAAc;IAC7B,QAAQ,CAAC,iBAAiB;IAAO,QAAQ,CAAC,cAAc,CAAC,EAAC,MAAM;gBAA/E,OAAO,EAAC,MAAM,EAAU,iBAAiB,UAAM,EAAU,cAAc,CAAC,EAAC,MAAM,YAAA;CAC5F;AACD,qBAAa,mBAAoB,SAAQ,cAAc;IAC1B,QAAQ,CAAC,iBAAiB;IAAO,QAAQ,CAAC,cAAc,CAAC,EAAC,MAAM;gBAA/E,OAAO,EAAC,MAAM,EAAU,iBAAiB,UAAM,EAAU,cAAc,CAAC,EAAC,MAAM,YAAA;CAC5F;AACD,qBAAa,qBAAsB,SAAQ,cAAc;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAC,MAAM;IAAC,QAAQ,CAAC,iBAAiB;IAAO,QAAQ,CAAC,cAAc,CAAC,EAAC,MAAM;gBAAtG,OAAO,EAAC,MAAM,EAAU,KAAK,CAAC,EAAC,MAAM,YAAA,EAAU,iBAAiB,UAAM,EAAU,cAAc,CAAC,EAAC,MAAM,YAAA;CACnH;AACD,qBAAa,wBAAyB,SAAQ,cAAc;IAC/B,QAAQ,CAAC,iBAAiB,EAAC,OAAO;IAAC,QAAQ,CAAC,cAAc,CAAC,EAAC,MAAM;gBAAjF,OAAO,EAAC,MAAM,EAAU,iBAAiB,EAAC,OAAO,EAAU,cAAc,CAAC,EAAC,MAAM,YAAA;CAC9F;AACD,qBAAa,iBAAkB,SAAQ,cAAc;IACxB,QAAQ,CAAC,MAAM,EAAC,MAAM;IAAC,QAAQ,CAAC,IAAI,CAAC,EAAC,MAAM;IAAC,QAAQ,CAAC,SAAS,CAAC,EAAC,MAAM;IAAC,QAAQ,CAAC,YAAY,CAAC,EAAC,MAAM;gBAApH,OAAO,EAAC,MAAM,EAAU,MAAM,EAAC,MAAM,EAAU,IAAI,CAAC,EAAC,MAAM,YAAA,EAAU,SAAS,CAAC,EAAC,MAAM,YAAA,EAAU,YAAY,CAAC,EAAC,MAAM,YAAA;CACjI"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** Errors intentionally omit request headers, response bodies and transport causes. */
|
|
2
|
+
export class OpenCrawlError extends Error {
|
|
3
|
+
constructor(message) { super(message); this.name = new.target.name; }
|
|
4
|
+
}
|
|
5
|
+
export class OpenCrawlValidationError extends OpenCrawlError {
|
|
6
|
+
}
|
|
7
|
+
export class OpenCrawlProtocolError extends OpenCrawlError {
|
|
8
|
+
acceptanceUnknown;
|
|
9
|
+
idempotencyKey;
|
|
10
|
+
constructor(message, acceptanceUnknown = false, idempotencyKey) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.acceptanceUnknown = acceptanceUnknown;
|
|
13
|
+
this.idempotencyKey = idempotencyKey;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export class OpenCrawlAbortError extends OpenCrawlError {
|
|
17
|
+
acceptanceUnknown;
|
|
18
|
+
idempotencyKey;
|
|
19
|
+
constructor(message, acceptanceUnknown = false, idempotencyKey) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.acceptanceUnknown = acceptanceUnknown;
|
|
22
|
+
this.idempotencyKey = idempotencyKey;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export class OpenCrawlTimeoutError extends OpenCrawlError {
|
|
26
|
+
jobId;
|
|
27
|
+
acceptanceUnknown;
|
|
28
|
+
idempotencyKey;
|
|
29
|
+
constructor(message, jobId, acceptanceUnknown = false, idempotencyKey) {
|
|
30
|
+
super(message);
|
|
31
|
+
this.jobId = jobId;
|
|
32
|
+
this.acceptanceUnknown = acceptanceUnknown;
|
|
33
|
+
this.idempotencyKey = idempotencyKey;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export class OpenCrawlConnectionError extends OpenCrawlError {
|
|
37
|
+
acceptanceUnknown;
|
|
38
|
+
idempotencyKey;
|
|
39
|
+
constructor(message, acceptanceUnknown, idempotencyKey) {
|
|
40
|
+
super(message);
|
|
41
|
+
this.acceptanceUnknown = acceptanceUnknown;
|
|
42
|
+
this.idempotencyKey = idempotencyKey;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export class OpenCrawlAPIError extends OpenCrawlError {
|
|
46
|
+
status;
|
|
47
|
+
code;
|
|
48
|
+
requestId;
|
|
49
|
+
retryAfterMs;
|
|
50
|
+
constructor(message, status, code, requestId, retryAfterMs) {
|
|
51
|
+
super(message);
|
|
52
|
+
this.status = status;
|
|
53
|
+
this.code = code;
|
|
54
|
+
this.requestId = requestId;
|
|
55
|
+
this.retryAfterMs = retryAfterMs;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAc,IAAE,KAAK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AAU,SAAiB,EAAU,YAAoB;QAAE,KAAK,CAAC,OAAO,CAAC,CAAA;QAA5G,WAAM,GAAN,MAAM,CAAO;QAAU,SAAI,GAAJ,IAAI,CAAQ;QAAU,cAAS,GAAT,SAAS,CAAQ;QAAU,iBAAY,GAAZ,YAAY,CAAQ;IAAgB,CAAC;CAClJ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Transport, type RequestOptions } from './transport.js';
|
|
2
|
+
import type { ResearchEventDetail } from './types.js';
|
|
3
|
+
export type EventReadOptions = RequestOptions & {
|
|
4
|
+
budget?: number;
|
|
5
|
+
beforeStart?: number;
|
|
6
|
+
afterStart?: number;
|
|
7
|
+
};
|
|
8
|
+
/** Reads one authorized immutable observation window; never follows continuation automatically. */
|
|
9
|
+
export declare function readEvent(transport: Transport, collectionId: string, eventId: string, options?: EventReadOptions): Promise<ResearchEventDetail>;
|
|
10
|
+
//# sourceMappingURL=eventEvidence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventEvidence.d.ts","sourceRoot":"","sources":["../src/eventEvidence.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,SAAS,EAAuB,KAAK,cAAc,EAAC,MAAM,gBAAgB,CAAC;AACnF,OAAO,KAAK,EAAC,mBAAmB,EAAqB,MAAM,YAAY,CAAC;AAExE,MAAM,MAAM,gBAAgB,GAAC,cAAc,GAAC;IAAC,MAAM,CAAC,EAAC,MAAM,CAAC;IAAA,WAAW,CAAC,EAAC,MAAM,CAAC;IAAA,UAAU,CAAC,EAAC,MAAM,CAAA;CAAC,CAAC;AAoBpG,mGAAmG;AACnG,wBAAsB,SAAS,CAAC,SAAS,EAAC,SAAS,EAAC,YAAY,EAAC,MAAM,EAAC,OAAO,EAAC,MAAM,EAAC,OAAO,GAAC,gBAAmB,GAAE,OAAO,CAAC,mBAAmB,CAAC,CAY/I"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { OpenCrawlProtocolError } from './errors.js';
|
|
2
|
+
import { boundedInteger, idPath } from './transport.js';
|
|
3
|
+
const integer = (value, min = 0, max = 2_000_000) => Number.isSafeInteger(value) && Number(value) >= min && Number(value) <= max;
|
|
4
|
+
const text = (value, max) => typeof value === 'string' && value.length <= max;
|
|
5
|
+
const hash = (value) => typeof value === 'string' && /^[a-f0-9]{64}$/.test(value);
|
|
6
|
+
const invalid = () => new OpenCrawlProtocolError('OpenCrawl returned invalid or out-of-scope retained event evidence.');
|
|
7
|
+
const bytes = (value) => new TextEncoder().encode(value).byteLength;
|
|
8
|
+
function validateWindow(value, offset, comparison) {
|
|
9
|
+
if (value === null) {
|
|
10
|
+
if (offset !== undefined)
|
|
11
|
+
throw invalid();
|
|
12
|
+
return 0;
|
|
13
|
+
}
|
|
14
|
+
if (!value || !text(value.version_id, 200) || !value.version_id || !hash(value.version_sha256) || !hash(value.body_sha256) || !text(value.title, 8192) || !text(value.url, 8192) || !(value.final_url === null || text(value.final_url, 65536)) || !(value.extraction_version === null || text(value.extraction_version, 65536)) || !text(value.version_observed_at, 200) || !value.version_observed_at || !text(value.text, 64000) || !integer(value.full_length) || !integer(value.start_char, 0, value.full_length) || !integer(value.end_char, value.start_char, value.full_length))
|
|
15
|
+
throw invalid();
|
|
16
|
+
const points = Array.from(value.text);
|
|
17
|
+
if (points.length !== value.end_char - value.start_char || points.some(point => point.length === 1 && /[\uD800-\uDFFF]/.test(point)) || value.next_start_char !== (value.end_char < value.full_length ? value.end_char : null) || value.omitted_before !== (value.start_char > 0) || value.omitted_after !== (value.end_char < value.full_length))
|
|
18
|
+
throw invalid();
|
|
19
|
+
if (offset !== undefined) {
|
|
20
|
+
if (value.window_origin !== 'explicit_offset' || value.start_char !== offset)
|
|
21
|
+
throw invalid();
|
|
22
|
+
}
|
|
23
|
+
else if (value.window_origin !== (comparison === 'contiguous_region' ? 'changed_region' : 'page_start') || (value.window_origin === 'page_start' && value.start_char !== 0))
|
|
24
|
+
throw invalid();
|
|
25
|
+
if (comparison === 'contiguous_region') {
|
|
26
|
+
if (!integer(value.changed_start_char, 0, value.full_length) || !integer(value.changed_end_char, value.changed_start_char, value.full_length))
|
|
27
|
+
throw invalid();
|
|
28
|
+
}
|
|
29
|
+
else if (value.changed_start_char !== null || value.changed_end_char !== null)
|
|
30
|
+
throw invalid();
|
|
31
|
+
return bytes(value.text);
|
|
32
|
+
}
|
|
33
|
+
/** Reads one authorized immutable observation window; never follows continuation automatically. */
|
|
34
|
+
export async function readEvent(transport, collectionId, eventId, options = {}) {
|
|
35
|
+
const collection = idPath(collectionId), event = idPath(eventId), budget = boundedInteger(options.budget ?? 16000, 'budget', 256, 32000);
|
|
36
|
+
const query = new URLSearchParams({ budget: String(budget) });
|
|
37
|
+
for (const [name, value] of [['before_start', options.beforeStart], ['after_start', options.afterStart]])
|
|
38
|
+
if (value !== undefined)
|
|
39
|
+
query.set(name, String(boundedInteger(value, name, 0, 2_000_000)));
|
|
40
|
+
const value = await transport.request(`/api/research/collections/${collection}/events/${event}?${query}`, { signal: options.signal, timeoutMs: options.timeoutMs });
|
|
41
|
+
if (!value || value.id !== eventId || value.collection_id !== collectionId || !text(value.url, 8192) || !['baseline', 'changed', 'unavailable', 'recovered'].includes(value.kind) || !text(value.observed_at, 200) || !value.observed_at || !(value.previous_observed_at === null || text(value.previous_observed_at, 200)) || typeof value.gap !== 'boolean' || !['contiguous_region', 'equal_body', 'single_observation', 'no_observation'].includes(value.comparison) || value.budget !== budget || !integer(value.text_bytes, 0, budget))
|
|
42
|
+
throw invalid();
|
|
43
|
+
const count = Number(value.before !== null) + Number(value.after !== null);
|
|
44
|
+
if (count !== (value.comparison === 'no_observation' ? 0 : value.comparison === 'single_observation' ? 1 : 2))
|
|
45
|
+
throw invalid();
|
|
46
|
+
const total = validateWindow(value.before, options.beforeStart, value.comparison) + validateWindow(value.after, options.afterStart, value.comparison);
|
|
47
|
+
if (total !== value.text_bytes || total > budget || (value.comparison === 'equal_body' && value.before?.body_sha256 !== value.after?.body_sha256) || (value.comparison === 'contiguous_region' && value.before?.body_sha256 === value.after?.body_sha256))
|
|
48
|
+
throw invalid();
|
|
49
|
+
// Full-body/version hashes identify retained observations. A partial window cannot verify them.
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=eventEvidence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventEvidence.js","sourceRoot":"","sources":["../src/eventEvidence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,aAAa,CAAC;AACnD,OAAO,EAAW,cAAc,EAAC,MAAM,EAAqB,MAAM,gBAAgB,CAAC;AAInF,MAAM,OAAO,GAAC,CAAC,KAAa,EAAC,GAAG,GAAC,CAAC,EAAC,GAAG,GAAC,SAAS,EAAiB,EAAE,CAAA,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAE,MAAM,CAAC,KAAK,CAAC,IAAE,GAAG,IAAE,MAAM,CAAC,KAAK,CAAC,IAAE,GAAG,CAAC;AACvI,MAAM,IAAI,GAAC,CAAC,KAAa,EAAC,GAAU,EAAiB,EAAE,CAAA,OAAO,KAAK,KAAG,QAAQ,IAAE,KAAK,CAAC,MAAM,IAAE,GAAG,CAAC;AAClG,MAAM,IAAI,GAAC,CAAC,KAAa,EAAC,EAAE,CAAA,OAAO,KAAK,KAAG,QAAQ,IAAE,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClF,MAAM,OAAO,GAAC,GAAE,EAAE,CAAA,IAAI,sBAAsB,CAAC,qEAAqE,CAAC,CAAC;AACpH,MAAM,KAAK,GAAC,CAAC,KAAY,EAAC,EAAE,CAAA,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC;AAEvE,SAAS,cAAc,CAAC,KAA8B,EAAC,MAAuB,EAAC,UAA4C;IAC1H,IAAG,KAAK,KAAG,IAAI,EAAC,CAAC;QAAA,IAAG,MAAM,KAAG,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KAAG,KAAK,CAAC,KAAK,EAAE,WAAW,CAAC,IAAE,CAAC,KAAK,CAAC,UAAU,KAAG,mBAAmB,IAAE,KAAK,CAAC,MAAM,EAAE,WAAW,KAAG,KAAK,CAAC,KAAK,EAAE,WAAW,CAAC;QAAC,MAAM,OAAO,EAAE,CAAC;IACnP,gGAAgG;IAChG,OAAO,KAAK,CAAC;AACd,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Customers, type KeyStore } from './customers.js';
|
|
2
|
+
import { AgentPlatform } from './agentPlatform.js';
|
|
3
|
+
import { Transport, type ClientOptions, type MutationOptions, type RequestOptions } from './transport.js';
|
|
4
|
+
import { ResearchWebhooks } from './webhooks.js';
|
|
5
|
+
import { ResearchAgents } from './agents.js';
|
|
6
|
+
import { ProductMonitors } from './productMonitors.js';
|
|
7
|
+
export * from './productMonitors.js';
|
|
8
|
+
export type { ResearchAgentFeedbackRating, ResearchAgentFeedbackInput, ResearchAgentFeedbackReceipt } from './agents.js';
|
|
9
|
+
export type { ResearchCustomer, ResearchPolicy, ResearchAgentInput, ResearchAgentRunInput, ResearchAgentWebPage, ResearchAgentCitation, ResearchAgentFinding, ResearchAgentRun, ResearchAgent, ResearchAgentReceipt, ResearchAgentPage, ResearchAgentRunPage, ResearchAgentSource, ResearchAgentSourceReceipt, ResearchAgentSchedule, ResearchAgentRepeat, ResearchAgentRepeats, AgentWaitOptions } from './agents.js';
|
|
10
|
+
import { type EventReadOptions } from './eventEvidence.js';
|
|
11
|
+
export type { EventReadOptions } from './eventEvidence.js';
|
|
12
|
+
import type { CollectionSettings, CollectionSettingsReceipt } from './types.js';
|
|
13
|
+
import type { Collection, CollectionUpdate, CollectionInput, CollectionReceipt, ContextInput, ContextResponse, CursorPage, PageOptions, RefreshInput, RefreshReceipt, ResearchEvent, ResearchJob, ResearchSearchInput, ResearchSearchResponse, ResearchPlanInput, ResearchPlanReceipt, ResearchPlannerStatus, ServiceTenant, ServiceTenantInput, ServiceTenantRevision, ServiceTenantReceipt, ServiceTenantOperation, ServiceTenantPage, ServiceTenantListOptions } from './types.js';
|
|
14
|
+
export * from './errors.js';
|
|
15
|
+
export * from './types.js';
|
|
16
|
+
export { verifyResearchWebhook, type WebhookSignatureInput } from './webhooks.js';
|
|
17
|
+
export { Customer, Customers, memoryKeyStore, signalHeadline, type KeyStore, type CustomerProfile, type Cadence, type WatchInput, type Watch, type Signal, type SignalsOptions, type SignalsResult, type Answer, type AnswerFinding, type AnswerSource, type AskOptions, type McpConnection } from './customers.js';
|
|
18
|
+
export { AgentPlatform, signupOrganization, pollOrganizationSignup, type AgentSignupInput, type AgentSignup, type AgentSignupPoll, type ProjectSpec, type ProjectHandoff, type AgentTurn } from './agentPlatform.js';
|
|
19
|
+
export { agentTools, type AgentTool, type AgentToolSet, type ToolOptions, type JsonSchema } from './tools.js';
|
|
20
|
+
export type { ClientOptions, RequestOptions, MutationOptions, Fetch } from './transport.js';
|
|
21
|
+
export type ListOptions = PageOptions & RequestOptions;
|
|
22
|
+
export type IterateOptions = ListOptions & {
|
|
23
|
+
maxPages?: number;
|
|
24
|
+
};
|
|
25
|
+
/** includeVolatile:false omits changes whose only differences are dates, clock times, relative ages or whitespace. */
|
|
26
|
+
export type EventListOptions = ListOptions & {
|
|
27
|
+
includeVolatile?: boolean;
|
|
28
|
+
};
|
|
29
|
+
export type WaitOptions = RequestOptions & {
|
|
30
|
+
maxWaitMs?: number;
|
|
31
|
+
pollIntervalMs?: number;
|
|
32
|
+
onProgress?: (job: ResearchJob) => void;
|
|
33
|
+
};
|
|
34
|
+
declare class Collections {
|
|
35
|
+
private readonly transport;
|
|
36
|
+
constructor(transport: Transport);
|
|
37
|
+
create(input: CollectionInput, options: MutationOptions): Promise<CollectionReceipt>;
|
|
38
|
+
list(options?: ListOptions): Promise<CursorPage<Collection>>;
|
|
39
|
+
get(id: string, options?: RequestOptions): Promise<Collection>;
|
|
40
|
+
update(id: string, input: CollectionUpdate, options?: RequestOptions): Promise<Collection>;
|
|
41
|
+
configure(id: string, input: CollectionSettings, options: MutationOptions): Promise<CollectionSettingsReceipt>;
|
|
42
|
+
refresh(id: string, input: RefreshInput, options: MutationOptions): Promise<RefreshReceipt>;
|
|
43
|
+
events(id: string, options?: EventListOptions): Promise<CursorPage<ResearchEvent>>;
|
|
44
|
+
event(collectionId: string, eventId: string, options?: EventReadOptions): Promise<import("./types.js").ResearchEventDetail>;
|
|
45
|
+
iterate(options?: IterateOptions): AsyncGenerator<Collection>;
|
|
46
|
+
iterateEvents(id: string, options?: IterateOptions & EventListOptions): AsyncGenerator<ResearchEvent>;
|
|
47
|
+
}
|
|
48
|
+
declare class Jobs {
|
|
49
|
+
private readonly transport;
|
|
50
|
+
constructor(transport: Transport);
|
|
51
|
+
get(id: string, options?: RequestOptions): Promise<ResearchJob>;
|
|
52
|
+
/** Waits for a terminal receipt. Failed/partial/cancelled jobs are returned, not disguised as success. */
|
|
53
|
+
wait(id: string, options?: WaitOptions): Promise<ResearchJob>;
|
|
54
|
+
}
|
|
55
|
+
declare class Plans {
|
|
56
|
+
private readonly transport;
|
|
57
|
+
constructor(transport: Transport);
|
|
58
|
+
status(options?: RequestOptions): Promise<ResearchPlannerStatus>;
|
|
59
|
+
/** Returns a proposal only. Source selection and collection creation remain explicit. */
|
|
60
|
+
create(input: ResearchPlanInput, options: MutationOptions): Promise<ResearchPlanReceipt>;
|
|
61
|
+
get(id: string, options?: RequestOptions): Promise<ResearchPlanReceipt>;
|
|
62
|
+
byKey(key: string, options?: RequestOptions): Promise<ResearchPlanReceipt>;
|
|
63
|
+
}
|
|
64
|
+
/** Server-only. Supply tenant-specific credentials explicitly; no environment or local config is read. */
|
|
65
|
+
export declare class OpenCrawl {
|
|
66
|
+
#private;
|
|
67
|
+
readonly productMonitors: ProductMonitors;
|
|
68
|
+
readonly agents: ResearchAgents;
|
|
69
|
+
readonly collections: Collections;
|
|
70
|
+
readonly jobs: Jobs;
|
|
71
|
+
readonly webhooks: ResearchWebhooks;
|
|
72
|
+
readonly plans: Plans;
|
|
73
|
+
readonly agent: AgentPlatform;
|
|
74
|
+
readonly baseUrl: string;
|
|
75
|
+
constructor(options: ClientOptions);
|
|
76
|
+
/** Your end customers, each isolated in its own workspace and provisioned on first use.
|
|
77
|
+
* Requires a parent administrator API key. Pass a shared KeyStore when several processes
|
|
78
|
+
* serve customers; keys lost from the store are recovered by rotation. */
|
|
79
|
+
customers(options?: {
|
|
80
|
+
keys?: KeyStore;
|
|
81
|
+
}): Customers;
|
|
82
|
+
/** Requires a parent administrator API key; these writes never retry automatically. */
|
|
83
|
+
createServiceTenant(input: ServiceTenantInput, options: MutationOptions): Promise<ServiceTenantReceipt>;
|
|
84
|
+
listServiceTenants(options?: ServiceTenantListOptions & RequestOptions): Promise<ServiceTenantPage>;
|
|
85
|
+
getServiceTenant(id: string, options?: RequestOptions): Promise<ServiceTenant>;
|
|
86
|
+
rotateServiceTenantKey(id: string, input: ServiceTenantRevision, options: MutationOptions): Promise<ServiceTenantReceipt>;
|
|
87
|
+
revokeServiceTenant(id: string, input: ServiceTenantRevision, options: MutationOptions): Promise<ServiceTenantReceipt>;
|
|
88
|
+
getServiceTenantReceipt(operation: ServiceTenantOperation, options: MutationOptions): Promise<ServiceTenantReceipt>;
|
|
89
|
+
search(input: ResearchSearchInput, options?: RequestOptions): Promise<ResearchSearchResponse>;
|
|
90
|
+
/** Existing source-scoped context API; explicit [] is retained, never broadened. */
|
|
91
|
+
context(input: ContextInput, options?: RequestOptions): Promise<ContextResponse>;
|
|
92
|
+
}
|
|
93
|
+
export default OpenCrawl;
|
|
94
|
+
export { readResearchAnswerContract, type AnswerSourceScope, type AnswerFactRef, type AnswerComponent, type AnswerContract, type AnswerContractMarker, type AnswerContractView } from './researchAnswerContract.js';
|
|
95
|
+
export { readResearchCompletion, readResearchPresentation, type ResearchPresentation, type ResearchCompletion, type ResearchCompletionNoticeCode, type ResearchCompletionView } from './researchCompletion.js';
|
|
96
|
+
export { readResearchAnswerView } from "./researchAnswerView.js";
|
|
97
|
+
export type { AnswerAssertion, AnswerOmissionReason, ResearchAnswerView, ResearchAnswerSection, ResearchAnswerViewResult } from "./answerView.js";
|
|
98
|
+
//# sourceMappingURL=index.d.ts.map
|