@anchrd/colab-sdk 0.1.19 → 0.1.21
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/dist/crawls/crawls.d.ts +132 -0
- package/dist/crawls/crawls.js +138 -0
- package/dist/grammar/grammar.d.ts +1 -0
- package/dist/grammar/grammar.js +3 -0
- package/dist/sdk.d.ts +1 -0
- package/dist/sdk.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const CrawlId: z.ZodTemplateLiteral<`crawl_${string}`>;
|
|
3
|
+
export type CrawlId = z.infer<typeof CrawlId>;
|
|
4
|
+
export declare const maxCrawlPages = 1000;
|
|
5
|
+
export declare const defaultCrawlPages = 100;
|
|
6
|
+
export declare const maxCrawlPagesPerDay = 20000;
|
|
7
|
+
export declare const crawlDays = 14;
|
|
8
|
+
export declare const maxCrawlHits = 20;
|
|
9
|
+
export declare const maxCrawlReads = 10;
|
|
10
|
+
export declare const crawlPassageChars = 300;
|
|
11
|
+
export declare const CrawlCreateInput: z.ZodObject<{
|
|
12
|
+
url: z.ZodString;
|
|
13
|
+
includePatterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
14
|
+
excludePatterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
15
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
16
|
+
depth: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
render: z.ZodDefault<z.ZodBoolean>;
|
|
18
|
+
source: z.ZodDefault<z.ZodEnum<{
|
|
19
|
+
links: "links";
|
|
20
|
+
all: "all";
|
|
21
|
+
sitemaps: "sitemaps";
|
|
22
|
+
}>>;
|
|
23
|
+
modifiedSince: z.ZodOptional<z.ZodISODateTime>;
|
|
24
|
+
idempotencyKey: z.ZodString;
|
|
25
|
+
}, z.core.$strict>;
|
|
26
|
+
export type CrawlCreateInput = z.infer<typeof CrawlCreateInput>;
|
|
27
|
+
export declare const CrawlGetInput: z.ZodObject<{
|
|
28
|
+
crawlId: z.ZodTemplateLiteral<`crawl_${string}`>;
|
|
29
|
+
query: z.ZodOptional<z.ZodString>;
|
|
30
|
+
urls: z.ZodOptional<z.ZodPreprocess<z.ZodArray<z.ZodString>, unknown>>;
|
|
31
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
32
|
+
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
33
|
+
errors: z.ZodOptional<z.ZodPreprocess<z.ZodBoolean, unknown>>;
|
|
34
|
+
}, z.core.$strict>;
|
|
35
|
+
export type CrawlGetInput = z.infer<typeof CrawlGetInput>;
|
|
36
|
+
export declare const CrawlStatus: z.ZodEnum<{
|
|
37
|
+
done: "done";
|
|
38
|
+
failed: "failed";
|
|
39
|
+
expired: "expired";
|
|
40
|
+
running: "running";
|
|
41
|
+
starting: "starting";
|
|
42
|
+
reading: "reading";
|
|
43
|
+
}>;
|
|
44
|
+
export type CrawlStatus = z.infer<typeof CrawlStatus>;
|
|
45
|
+
export declare const Crawl: z.ZodObject<{
|
|
46
|
+
crawlId: z.ZodTemplateLiteral<`crawl_${string}`>;
|
|
47
|
+
url: z.ZodString;
|
|
48
|
+
status: z.ZodEnum<{
|
|
49
|
+
done: "done";
|
|
50
|
+
failed: "failed";
|
|
51
|
+
expired: "expired";
|
|
52
|
+
running: "running";
|
|
53
|
+
starting: "starting";
|
|
54
|
+
reading: "reading";
|
|
55
|
+
}>;
|
|
56
|
+
reason: z.ZodNullable<z.ZodString>;
|
|
57
|
+
limit: z.ZodNumber;
|
|
58
|
+
render: z.ZodBoolean;
|
|
59
|
+
total: z.ZodNullable<z.ZodNumber>;
|
|
60
|
+
finished: z.ZodNullable<z.ZodNumber>;
|
|
61
|
+
pages: z.ZodNumber;
|
|
62
|
+
createdAt: z.ZodISODateTime;
|
|
63
|
+
expiresAt: z.ZodISODateTime;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
export type Crawl = z.infer<typeof Crawl>;
|
|
66
|
+
export declare const CrawlPage: z.ZodObject<{
|
|
67
|
+
url: z.ZodString;
|
|
68
|
+
title: z.ZodString;
|
|
69
|
+
length: z.ZodNumber;
|
|
70
|
+
}, z.core.$strip>;
|
|
71
|
+
export type CrawlPage = z.infer<typeof CrawlPage>;
|
|
72
|
+
export declare const CrawlHit: z.ZodObject<{
|
|
73
|
+
url: z.ZodString;
|
|
74
|
+
title: z.ZodString;
|
|
75
|
+
passage: z.ZodString;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
export type CrawlHit = z.infer<typeof CrawlHit>;
|
|
78
|
+
export declare const CrawlRead: z.ZodObject<{
|
|
79
|
+
url: z.ZodString;
|
|
80
|
+
title: z.ZodString;
|
|
81
|
+
markdown: z.ZodString;
|
|
82
|
+
}, z.core.$strip>;
|
|
83
|
+
export type CrawlRead = z.infer<typeof CrawlRead>;
|
|
84
|
+
export declare const CrawlFailure: z.ZodObject<{
|
|
85
|
+
url: z.ZodString;
|
|
86
|
+
status: z.ZodString;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
export type CrawlFailure = z.infer<typeof CrawlFailure>;
|
|
89
|
+
export declare const CrawlDetail: z.ZodObject<{
|
|
90
|
+
crawl: z.ZodObject<{
|
|
91
|
+
crawlId: z.ZodTemplateLiteral<`crawl_${string}`>;
|
|
92
|
+
url: z.ZodString;
|
|
93
|
+
status: z.ZodEnum<{
|
|
94
|
+
done: "done";
|
|
95
|
+
failed: "failed";
|
|
96
|
+
expired: "expired";
|
|
97
|
+
running: "running";
|
|
98
|
+
starting: "starting";
|
|
99
|
+
reading: "reading";
|
|
100
|
+
}>;
|
|
101
|
+
reason: z.ZodNullable<z.ZodString>;
|
|
102
|
+
limit: z.ZodNumber;
|
|
103
|
+
render: z.ZodBoolean;
|
|
104
|
+
total: z.ZodNullable<z.ZodNumber>;
|
|
105
|
+
finished: z.ZodNullable<z.ZodNumber>;
|
|
106
|
+
pages: z.ZodNumber;
|
|
107
|
+
createdAt: z.ZodISODateTime;
|
|
108
|
+
expiresAt: z.ZodISODateTime;
|
|
109
|
+
}, z.core.$strip>;
|
|
110
|
+
items: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
111
|
+
url: z.ZodString;
|
|
112
|
+
title: z.ZodString;
|
|
113
|
+
length: z.ZodNumber;
|
|
114
|
+
}, z.core.$strip>>>;
|
|
115
|
+
nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
116
|
+
hits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
117
|
+
url: z.ZodString;
|
|
118
|
+
title: z.ZodString;
|
|
119
|
+
passage: z.ZodString;
|
|
120
|
+
}, z.core.$strip>>>;
|
|
121
|
+
reads: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
122
|
+
url: z.ZodString;
|
|
123
|
+
title: z.ZodString;
|
|
124
|
+
markdown: z.ZodString;
|
|
125
|
+
}, z.core.$strip>>>;
|
|
126
|
+
missing: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
127
|
+
failures: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
128
|
+
url: z.ZodString;
|
|
129
|
+
status: z.ZodString;
|
|
130
|
+
}, z.core.$strip>>>;
|
|
131
|
+
}, z.core.$strip>;
|
|
132
|
+
export type CrawlDetail = z.infer<typeof CrawlDetail>;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { idSchema } from "../ids/ids.js";
|
|
3
|
+
import { Flag, Limit as PageSize } from "../list-input.js";
|
|
4
|
+
import { IdempotencyKey } from "../primitives/primitives.js";
|
|
5
|
+
// Crawls (#785, E137, Funktionen › Crawl): the inputs of `intelligence_crawl_create` and
|
|
6
|
+
// `intelligence_crawl_get`, and their answers. Colab starts a crawl of a known website at Cloudflare
|
|
7
|
+
// Browser Rendering (`/crawl`), keeps its pages 14 days in a search table and stores none of them as
|
|
8
|
+
// a node: whoever wants to keep a page makes it a file with `intelligence_file_create`.
|
|
9
|
+
export const CrawlId = idSchema("crawl").describe("The crawl's id, `crawl_…`, as intelligence_crawl_create answered it.");
|
|
10
|
+
// The most pages one crawl may order, the default, and the most a Colab orders in one day (UTC).
|
|
11
|
+
export const maxCrawlPages = 1000;
|
|
12
|
+
export const defaultCrawlPages = 100;
|
|
13
|
+
export const maxCrawlPagesPerDay = 20_000;
|
|
14
|
+
// How long a crawl's pages stay searchable, like Cloudflare keeps them.
|
|
15
|
+
export const crawlDays = 14;
|
|
16
|
+
// The most hits a search answers, the most pages read whole in one call, and the length of a hit's
|
|
17
|
+
// passage.
|
|
18
|
+
export const maxCrawlHits = 20;
|
|
19
|
+
export const maxCrawlReads = 10;
|
|
20
|
+
export const crawlPassageChars = 300;
|
|
21
|
+
const Pattern = z.string().min(1).max(500);
|
|
22
|
+
export const CrawlCreateInput = z.strictObject({
|
|
23
|
+
url: z
|
|
24
|
+
.string()
|
|
25
|
+
.min(1)
|
|
26
|
+
.max(2000)
|
|
27
|
+
.describe("Where the crawl starts: a full https address of a public website, such as https://www.bitkom.org/Presse. Cloudflare follows its links and its sitemap from there."),
|
|
28
|
+
includePatterns: z
|
|
29
|
+
.array(Pattern)
|
|
30
|
+
.max(20)
|
|
31
|
+
.optional()
|
|
32
|
+
.describe("Only addresses matching one of these are crawled, such as https://www.bitkom.org/Presse/**. `*` matches anything but `/`, `**` anything. Leaving it out takes every address the crawl finds on the site."),
|
|
33
|
+
excludePatterns: z
|
|
34
|
+
.array(Pattern)
|
|
35
|
+
.max(20)
|
|
36
|
+
.optional()
|
|
37
|
+
.describe("Addresses matching one of these are left out; they win over includePatterns."),
|
|
38
|
+
limit: z
|
|
39
|
+
.number()
|
|
40
|
+
.int()
|
|
41
|
+
.min(1)
|
|
42
|
+
.max(maxCrawlPages, {
|
|
43
|
+
error: `A crawl orders at most ${maxCrawlPages} pages. Narrow the site with includePatterns or start below it.`,
|
|
44
|
+
})
|
|
45
|
+
.default(defaultCrawlPages)
|
|
46
|
+
.describe(`How many pages to crawl at most, 1 to ${maxCrawlPages}. Leaving it out gives ${defaultCrawlPages}. Start small, read the hits, and widen only when the area carries. A single page is a crawl with limit 1.`),
|
|
47
|
+
depth: z
|
|
48
|
+
.number()
|
|
49
|
+
.int()
|
|
50
|
+
.min(0)
|
|
51
|
+
.max(100_000)
|
|
52
|
+
.optional()
|
|
53
|
+
.describe("How many links deep from the start address, 0 for the start page alone. Leaving it out lets the limit decide."),
|
|
54
|
+
render: z
|
|
55
|
+
.boolean()
|
|
56
|
+
.default(false)
|
|
57
|
+
.describe("true runs a real browser and executes JavaScript, slower and billed by browser time; only for a page that stays empty without it. Leaving it out fetches the plain HTML."),
|
|
58
|
+
source: z
|
|
59
|
+
.enum(["all", "sitemaps", "links"])
|
|
60
|
+
.default("all")
|
|
61
|
+
.describe("Where the crawl finds pages: all (sitemap and links, the default), sitemaps or links only."),
|
|
62
|
+
modifiedSince: z.iso
|
|
63
|
+
.datetime()
|
|
64
|
+
.optional()
|
|
65
|
+
.describe("Only pages changed after this moment, ISO 8601. Set it to the last crawl of the same site for a recurring look, so only what is new comes back."),
|
|
66
|
+
idempotencyKey: IdempotencyKey,
|
|
67
|
+
});
|
|
68
|
+
export const CrawlGetInput = z.strictObject({
|
|
69
|
+
crawlId: CrawlId,
|
|
70
|
+
query: z
|
|
71
|
+
.string()
|
|
72
|
+
.min(2)
|
|
73
|
+
.max(200)
|
|
74
|
+
.optional()
|
|
75
|
+
.describe(`Search the crawl's pages instead of listing them: words to find in title and text, at least two characters; each word also finds longer words it begins. Answers the best ${maxCrawlHits} hits, each with one passage. Ask several times with other words instead of reading every page.`),
|
|
76
|
+
// Over REST one value, the addresses separated by spaces (`?urls=a%20b`): a query string carries
|
|
77
|
+
// text, and an address holds commas but never a bare space (#785, measured on colab.anchrd.sh).
|
|
78
|
+
urls: z
|
|
79
|
+
.preprocess((value) => (typeof value === "string" ? value.split(/\s+/).filter(Boolean) : value), z.array(z.string().min(1).max(2000)).min(1).max(maxCrawlReads))
|
|
80
|
+
.optional()
|
|
81
|
+
.describe(`Read these pages of the crawl whole, as Markdown, 1 to ${maxCrawlReads}, by the address the list or a hit named; over REST one value with the addresses separated by spaces. Not together with query.`),
|
|
82
|
+
cursor: z
|
|
83
|
+
.string()
|
|
84
|
+
.max(200)
|
|
85
|
+
.optional()
|
|
86
|
+
.describe("The nextCursor of the previous page of the list, unchanged."),
|
|
87
|
+
limit: PageSize.optional().describe("How many pages one page of the list holds, 1 to 100. Leaving it out gives 100."),
|
|
88
|
+
errors: Flag.optional().describe("true lists the addresses the crawl could not fetch or was not allowed to, with their reason, instead of the pages."),
|
|
89
|
+
});
|
|
90
|
+
// `starting` until Cloudflare took the job, `running` while it crawls, `reading` while Colab takes
|
|
91
|
+
// its pages, `done` when they are searchable, `failed` when the job ended without pages (`reason`
|
|
92
|
+
// says why), `expired` after `crawlDays`.
|
|
93
|
+
export const CrawlStatus = z.enum(["starting", "running", "reading", "done", "failed", "expired"]);
|
|
94
|
+
export const Crawl = z.object({
|
|
95
|
+
crawlId: CrawlId,
|
|
96
|
+
url: z.string(),
|
|
97
|
+
status: CrawlStatus,
|
|
98
|
+
reason: z.string().nullable(),
|
|
99
|
+
limit: z.number(),
|
|
100
|
+
render: z.boolean(),
|
|
101
|
+
// Pages Cloudflare found and finished so far, and the pages Colab holds once it is done.
|
|
102
|
+
total: z.number().nullable(),
|
|
103
|
+
finished: z.number().nullable(),
|
|
104
|
+
pages: z.number(),
|
|
105
|
+
createdAt: z.iso.datetime(),
|
|
106
|
+
expiresAt: z.iso.datetime(),
|
|
107
|
+
});
|
|
108
|
+
export const CrawlPage = z.object({
|
|
109
|
+
url: z.string(),
|
|
110
|
+
title: z.string(),
|
|
111
|
+
// Characters of the page's Markdown.
|
|
112
|
+
length: z.number(),
|
|
113
|
+
});
|
|
114
|
+
export const CrawlHit = z.object({
|
|
115
|
+
url: z.string(),
|
|
116
|
+
title: z.string(),
|
|
117
|
+
passage: z.string(),
|
|
118
|
+
});
|
|
119
|
+
export const CrawlRead = z.object({
|
|
120
|
+
url: z.string(),
|
|
121
|
+
title: z.string(),
|
|
122
|
+
markdown: z.string(),
|
|
123
|
+
});
|
|
124
|
+
export const CrawlFailure = z.object({
|
|
125
|
+
url: z.string(),
|
|
126
|
+
status: z.string(),
|
|
127
|
+
});
|
|
128
|
+
// One answer, with the part the call asked for: `items` (the list), `hits` (a search), `reads` (pages
|
|
129
|
+
// whole) or `failures`. While the crawl is not done, only `crawl` comes back.
|
|
130
|
+
export const CrawlDetail = z.object({
|
|
131
|
+
crawl: Crawl,
|
|
132
|
+
items: z.array(CrawlPage).optional(),
|
|
133
|
+
nextCursor: z.string().nullable().optional(),
|
|
134
|
+
hits: z.array(CrawlHit).optional(),
|
|
135
|
+
reads: z.array(CrawlRead).optional(),
|
|
136
|
+
missing: z.array(z.string()).optional(),
|
|
137
|
+
failures: z.array(CrawlFailure).optional(),
|
|
138
|
+
});
|
|
@@ -33,6 +33,7 @@ export declare const resources: {
|
|
|
33
33
|
readonly sso: "sso";
|
|
34
34
|
readonly secret: "secrets";
|
|
35
35
|
readonly step: "steps";
|
|
36
|
+
readonly crawl: "crawls";
|
|
36
37
|
};
|
|
37
38
|
export declare const actions: readonly ["list", "get", "create", "update", "archive", "restore", "purge"];
|
|
38
39
|
export declare const verbs: readonly ["invite", "resend", "disable", "enable", "rotate", "share", "move", "start", "complete", "test", "revoke", "remove", "unlock", "publish", "schedule", "unpublish", "cancel"];
|
package/dist/grammar/grammar.js
CHANGED
|
@@ -60,6 +60,9 @@ export const resources = {
|
|
|
60
60
|
// One step of an Operator run as its CLI's output showed it (E112), a sub-resource of the run:
|
|
61
61
|
// `operator_run_step_list`. Not `event`, the protocol's resource, and not `message`, a chat's.
|
|
62
62
|
step: "steps",
|
|
63
|
+
// A crawl of a known website at Cloudflare Browser Rendering (#785, E137): `intelligence_crawl_*`.
|
|
64
|
+
// Its pages are searched in Colab for 14 days and stored nowhere as a node.
|
|
65
|
+
crawl: "crawls",
|
|
63
66
|
};
|
|
64
67
|
// The closed list of actions with a route of their own shape.
|
|
65
68
|
export const actions = ["list", "get", "create", "update", "archive", "restore", "purge"];
|
package/dist/sdk.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { CardField, CardFieldId, CardFieldInput, CardFieldOption, CardFieldType,
|
|
|
9
9
|
export { ColumnId, ColumnType, columnTypes, TaskColumn } from "./columns/columns.js";
|
|
10
10
|
export { Connection, ConnectionCreateInput, ConnectionCredential, ConnectionDetail, ConnectionGetInput, ConnectionId, ConnectionList, ConnectionListInput, ConnectionRevokeInput, ConnectionState, ConnectionTested, ConnectionTestInput, ConnectionTestResult, ConnectionUpdateInput, } from "./connections/connections.js";
|
|
11
11
|
export { Call, CallId, CallList, CallListInput, CallSource, Connector, ConnectorField, ConnectorGetInput, ConnectorId, ConnectorList, ConnectorListInput, ConnectorTool, } from "./connectors/connectors.js";
|
|
12
|
+
export { Crawl, CrawlCreateInput, CrawlDetail, CrawlFailure, CrawlGetInput, CrawlHit, CrawlId, CrawlPage, CrawlRead, CrawlStatus, crawlDays, crawlPassageChars, defaultCrawlPages, maxCrawlHits, maxCrawlPages, maxCrawlPagesPerDay, maxCrawlReads, } from "./crawls/crawls.js";
|
|
12
13
|
export { DirectoryPrincipal, DirectorySearchInput } from "./directory/directory.js";
|
|
13
14
|
export { DocumentCreateInput, DocumentDetail, DocumentExcerpt, DocumentGetInput, DocumentUpdateInput, } from "./documents/documents.js";
|
|
14
15
|
export { ErrorCode, ErrorCurrent, ErrorIssue, ErrorResponse, errorCodes, invalidInput, Warning, } from "./error/error.js";
|
package/dist/sdk.js
CHANGED
|
@@ -12,6 +12,7 @@ export { CardField, CardFieldId, CardFieldInput, CardFieldOption, CardFieldType,
|
|
|
12
12
|
export { ColumnId, ColumnType, columnTypes, TaskColumn } from "./columns/columns.js";
|
|
13
13
|
export { Connection, ConnectionCreateInput, ConnectionCredential, ConnectionDetail, ConnectionGetInput, ConnectionId, ConnectionList, ConnectionListInput, ConnectionRevokeInput, ConnectionState, ConnectionTested, ConnectionTestInput, ConnectionTestResult, ConnectionUpdateInput, } from "./connections/connections.js";
|
|
14
14
|
export { Call, CallId, CallList, CallListInput, CallSource, Connector, ConnectorField, ConnectorGetInput, ConnectorId, ConnectorList, ConnectorListInput, ConnectorTool, } from "./connectors/connectors.js";
|
|
15
|
+
export { Crawl, CrawlCreateInput, CrawlDetail, CrawlFailure, CrawlGetInput, CrawlHit, CrawlId, CrawlPage, CrawlRead, CrawlStatus, crawlDays, crawlPassageChars, defaultCrawlPages, maxCrawlHits, maxCrawlPages, maxCrawlPagesPerDay, maxCrawlReads, } from "./crawls/crawls.js";
|
|
15
16
|
export { DirectoryPrincipal, DirectorySearchInput } from "./directory/directory.js";
|
|
16
17
|
export { DocumentCreateInput, DocumentDetail, DocumentExcerpt, DocumentGetInput, DocumentUpdateInput, } from "./documents/documents.js";
|
|
17
18
|
export { ErrorCode, ErrorCurrent, ErrorIssue, ErrorResponse, errorCodes, invalidInput, Warning, } from "./error/error.js";
|
package/package.json
CHANGED