@x12i/sdk 0.4.0 → 1.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.
Files changed (48) hide show
  1. package/README.md +62 -0
  2. package/dist/admin-import.d.ts +6 -0
  3. package/dist/admin-import.js +127 -0
  4. package/dist/admin-import.js.map +1 -0
  5. package/dist/admin-mcp.d.ts +3 -0
  6. package/dist/admin-mcp.js +95 -0
  7. package/dist/admin-mcp.js.map +1 -0
  8. package/dist/admin.d.ts +156 -0
  9. package/dist/admin.js +369 -0
  10. package/dist/admin.js.map +1 -0
  11. package/dist/cli.d.ts +2 -0
  12. package/dist/cli.js +68 -0
  13. package/dist/cli.js.map +1 -0
  14. package/dist/client.d.ts +74 -195
  15. package/dist/client.js +187 -695
  16. package/dist/client.js.map +1 -1
  17. package/dist/identity.d.ts +8 -0
  18. package/dist/identity.js +34 -0
  19. package/dist/identity.js.map +1 -0
  20. package/dist/index.d.ts +6 -22
  21. package/dist/index.js +6 -12
  22. package/dist/index.js.map +1 -1
  23. package/dist/init.d.ts +18 -0
  24. package/dist/init.js +147 -0
  25. package/dist/init.js.map +1 -0
  26. package/dist/maturity.d.ts +65 -0
  27. package/dist/maturity.js +138 -0
  28. package/dist/maturity.js.map +1 -0
  29. package/dist/mcp.d.ts +27 -0
  30. package/dist/mcp.js +168 -0
  31. package/dist/mcp.js.map +1 -0
  32. package/dist/protocol.d.ts +38 -0
  33. package/dist/protocol.js +168 -0
  34. package/dist/protocol.js.map +1 -0
  35. package/dist/rank.d.ts +19 -0
  36. package/dist/rank.js +82 -0
  37. package/dist/rank.js.map +1 -0
  38. package/dist/runner.d.ts +22 -0
  39. package/dist/runner.js +99 -0
  40. package/dist/runner.js.map +1 -0
  41. package/package.json +66 -61
  42. package/LICENSE +0 -21
  43. package/dist/client.d.ts.map +0 -1
  44. package/dist/index.d.ts.map +0 -1
  45. package/dist/registry.d.ts +0 -8
  46. package/dist/registry.d.ts.map +0 -1
  47. package/dist/registry.js +0 -21
  48. package/dist/registry.js.map +0 -1
package/dist/client.d.ts CHANGED
@@ -1,197 +1,76 @@
1
- import { ParserRegistry, type ClassifyCandidate, type FetchResult, type ParsedResult, type Parser } from "@x12i/core";
2
- import { type FetchOptions, type RetrieveOptions, type RetrieveBatchItem, type FetchCache, type SnapshotStore, type CachedRetrieveOptions, type ChangeCheckRequest, type ChangeCheckResult } from "@x12i/fetcher";
3
- import { type IngestOptions, type IngestResult } from "@x12i/ingest";
4
- import { type SearchConfig, type SearchProvider, type WebSearchRequest, type WebSearchResponse } from "@x12i/search";
5
- import { type CrawlRequest, type CrawlResult } from "@x12i/crawl";
6
- import { type ResearchPacket, type ResearchRequest } from "@x12i/research";
7
- import { type ExtractRequest, type ExtractResult, type ExtractionAdapter } from "@x12i/extract";
8
- import { type RunRecord, type RunStore, type ListItemsOptions, type ListItemsResult } from "@x12i/runs";
9
- import { type AnalyzeWebChangesRequest, type AnalyzeWebSourceRequest, type AnswerFromWebRequest, type AuditWebResearchRequest, type CompareWebSubjectsRequest, type FuncxExecutor, type WebFunctionBinding } from "@x12i/web-functions";
10
- export interface WebAgentClientOptions {
11
- registry?: ParserRegistry;
12
- fetchOptions?: FetchOptions;
13
- reuseBrowser?: boolean;
14
- search?: SearchProvider | SearchConfig | null;
15
- fetchCache?: FetchCache;
16
- snapshotStore?: SnapshotStore;
17
- runStore?: RunStore;
18
- extractionAdapter?: ExtractionAdapter;
19
- /** When true, client owns and closes default in-memory stores it created. */
20
- ownsDefaultStores?: boolean;
21
- /** Injected FuncX executor. When omitted, built from env (default mode: disabled). */
22
- funcxExecutor?: FuncxExecutor;
23
- /** Operator-approved web function bindings. */
24
- webFunctionBindings?: WebFunctionBinding[];
25
- aiProfiles?: {
26
- source?: "auto" | "remote" | "bundled";
27
- catalogLane?: "text";
28
- };
29
- /** When true, SDK owns and may close an executor it constructed. Injected executors are never closed. */
30
- ownsFuncxExecutor?: boolean;
1
+ import { type StoredIdentity } from "./identity.js";
2
+ import { type RankedPackage } from "./rank.js";
3
+ import { type UsageFields } from "./protocol.js";
4
+ export declare const SDK_VERSION: string;
5
+ /** Catalog service. Override with X12I_SDK_URL. */
6
+ export declare const DEFAULT_SERVICE_URL = "https://x12i-sdk.x12i.com";
7
+ export declare class SdkError extends Error {
8
+ readonly status: number;
9
+ readonly code: string;
10
+ constructor(message: string, status?: number, code?: string);
31
11
  }
32
- export interface FetchSearchResultsOptions {
33
- positions?: number[];
34
- urls?: string[];
35
- concurrency?: number;
36
- continueOnError?: boolean;
37
- fetchOptions?: FetchOptions;
38
- signal?: AbortSignal;
12
+ export type SearchResult = {
13
+ source: "service" | "registry";
14
+ ranked: boolean;
15
+ task: string;
16
+ results: RankedPackage[];
17
+ };
18
+ export type ReviewInput = {
19
+ package: string;
20
+ packageVersion: string;
21
+ agent: UsageFields["agent"];
22
+ outcome: UsageFields["outcome"];
23
+ rating: number;
24
+ worked?: string;
25
+ failed?: string;
26
+ needed?: string;
27
+ improve?: string;
28
+ };
29
+ export type ReportInput = Omit<ReviewInput, "rating">;
30
+ export type ClientOptions = {
31
+ baseUrl?: string;
32
+ fetch?: typeof fetch;
33
+ identityPath?: string;
34
+ };
35
+ export type ReadmeStatus = "missing" | "stale" | "fresh";
36
+ export type CachedPackage = {
37
+ readme: string;
38
+ readmeStatus: ReadmeStatus;
39
+ version: string | null;
40
+ description: string;
41
+ modifiedAt: string | null;
42
+ refreshedAt: string | null;
43
+ };
44
+ export type PackageView = {
45
+ name: string;
46
+ readme: string;
47
+ readmeStatus: ReadmeStatus;
48
+ version: string | null;
49
+ description: string;
50
+ modifiedAt: string | null;
51
+ refreshedAt: string | null;
52
+ updated: boolean;
53
+ source: "service" | "registry";
54
+ cached: CachedPackage;
55
+ detail: Record<string, unknown>;
56
+ refreshError?: string;
57
+ };
58
+ export declare class X12iClient {
59
+ readonly baseUrl: string;
60
+ readonly identityPath: string;
61
+ private readonly fetchImpl;
62
+ constructor(options?: ClientOptions);
63
+ search(task: string): Promise<SearchResult>;
64
+ catalog(cursor?: string, limit?: number): Promise<unknown>;
65
+ package(name: string): Promise<PackageView>;
66
+ readme(name: string): Promise<PackageView>;
67
+ reviews(name: string): Promise<unknown>;
68
+ report(input: ReportInput): Promise<unknown>;
69
+ review(input: ReviewInput): Promise<unknown>;
70
+ status(): Promise<unknown>;
71
+ ensureEnrolled(): Promise<StoredIdentity>;
72
+ private signedPost;
73
+ private readThrough;
74
+ private readmeFromRegistry;
75
+ private send;
39
76
  }
40
- export interface FetchedSearchPage {
41
- position?: number;
42
- url: string;
43
- title?: string;
44
- fetch?: FetchResult;
45
- error?: string;
46
- }
47
- export interface SearchAndFetchRequest extends WebSearchRequest {
48
- top?: number;
49
- positions?: number[];
50
- urls?: string[];
51
- concurrency?: number;
52
- continueOnError?: boolean;
53
- fetchOptions?: FetchOptions;
54
- signal?: AbortSignal;
55
- }
56
- export interface SearchAndFetchResult {
57
- search: WebSearchResponse;
58
- pages: FetchedSearchPage[];
59
- }
60
- /**
61
- * Canonical programmatic surface: fetch/retrieve/research/crawl/extract/runs.
62
- * CLI, REST, and MCP are thin adapters around this client.
63
- */
64
- export declare class WebAgentClient {
65
- readonly registry: ParserRegistry;
66
- private readonly defaultFetchOptions;
67
- private readonly reuseBrowser;
68
- private readonly searchProvider;
69
- private browserPromise;
70
- readonly fetchCache: FetchCache;
71
- readonly snapshotStore: SnapshotStore;
72
- readonly runStore: RunStore;
73
- private readonly extractionAdapter?;
74
- private readonly ownsCache;
75
- private readonly ownsSnapshots;
76
- private readonly ownsRuns;
77
- private readonly funcxExecutor;
78
- private readonly ownsFuncxExecutor;
79
- private webFunctionBindings;
80
- private readonly hostPolicy;
81
- private readonly aiProfilesSource;
82
- private readonly functionCheckpoints;
83
- private activeRunEventSink?;
84
- constructor(options?: WebAgentClientOptions);
85
- private loadBindingsFromEnv;
86
- private webFunctionsDeps;
87
- private buildResearchFunctionHooks;
88
- use<T>(parser: Parser<T>): this;
89
- /** Download a URL via Playwright (compatibility default: browser strategy). */
90
- fetch(url: string, options?: FetchOptions): Promise<FetchResult>;
91
- /** Strategy-aware multi-format retrieval (default strategy: auto). */
92
- retrieve(url: string, options?: RetrieveOptions): Promise<FetchResult>;
93
- fetchBatch(request: {
94
- urls: string[];
95
- concurrency?: number;
96
- continueOnError?: boolean;
97
- retrieveOptions?: RetrieveOptions;
98
- signal?: AbortSignal;
99
- }): Promise<RetrieveBatchItem[]>;
100
- retrieveCached(url: string, options?: CachedRetrieveOptions): Promise<FetchResult>;
101
- classify(url: string, options?: FetchOptions): Promise<ClassifyCandidate[]>;
102
- parse<T = unknown>(url: string, options?: FetchOptions): Promise<ParsedResult<T>>;
103
- parseAs<T = unknown>(type: string, url: string, options?: FetchOptions): Promise<ParsedResult<T>>;
104
- listParsers(): {
105
- type: string;
106
- description?: string;
107
- version?: string;
108
- }[];
109
- ingest(rootUrl: string, options?: IngestOptions): Promise<IngestResult>;
110
- search(request: WebSearchRequest, options?: {
111
- signal?: AbortSignal;
112
- }): Promise<WebSearchResponse>;
113
- searchConfigured(): boolean;
114
- fetchSearchResults(searchResult: WebSearchResponse, options?: FetchSearchResultsOptions): Promise<FetchedSearchPage[]>;
115
- searchAndFetch(request: SearchAndFetchRequest): Promise<SearchAndFetchResult>;
116
- research(request: ResearchRequest, options?: {
117
- signal?: AbortSignal;
118
- }): Promise<ResearchPacket>;
119
- startResearch(request: ResearchRequest, opts?: {
120
- idempotencyKey?: string;
121
- }): Promise<RunRecord>;
122
- private runResearchJob;
123
- crawl(request: CrawlRequest, options?: {
124
- signal?: AbortSignal;
125
- }): Promise<CrawlResult>;
126
- startCrawl(request: CrawlRequest, opts?: {
127
- idempotencyKey?: string;
128
- }): Promise<RunRecord>;
129
- private runCrawlJob;
130
- extract(request: ExtractRequest): Promise<ExtractResult>;
131
- checkChanges(request: ChangeCheckRequest & {
132
- url?: string;
133
- }): Promise<ChangeCheckResult>;
134
- analyze(request: AnalyzeWebSourceRequest, opts?: {
135
- signal?: AbortSignal;
136
- }): Promise<import("@x12i/web-functions").AnalyzeWebSourceResult>;
137
- answer(request: AnswerFromWebRequest, opts?: {
138
- signal?: AbortSignal;
139
- }): Promise<import("@x12i/web-functions").GroundedAnswer>;
140
- compare(request: CompareWebSubjectsRequest, opts?: {
141
- signal?: AbortSignal;
142
- }): Promise<import("@x12i/web-functions").WebComparison>;
143
- analyzeChanges(request: AnalyzeWebChangesRequest, opts?: {
144
- signal?: AbortSignal;
145
- }): Promise<import("@x12i/web-functions").AnalyzeWebChangesResult>;
146
- auditResearch(request: AuditWebResearchRequest, opts?: {
147
- signal?: AbortSignal;
148
- }): Promise<import("@x12i/web-functions").ResearchAuditResult>;
149
- listWebFunctions(options?: {
150
- role?: WebFunctionBinding["role"];
151
- }): Promise<{
152
- mode: import("@x12i/web-functions").FuncxExecutorMode;
153
- bindings: {
154
- status: "available" | "unavailable" | "incompatible" | "disabled";
155
- reasons: string[];
156
- warnings: string[];
157
- functionVersion?: string;
158
- catalogSource?: string;
159
- effectiveSlots?: import("@x12i/web-functions").WebFunctionModelConfig;
160
- binding: WebFunctionBinding;
161
- }[];
162
- }>;
163
- listWebAIProfiles(options?: {
164
- role?: string;
165
- }): Promise<{
166
- profiles: import("@x12i/ai-profiles").AIProfileSummary[];
167
- choices: import("@x12i/ai-profiles").AIProfileChoiceSummary[];
168
- catalogLane: "text";
169
- source: import("@x12i/ai-profiles").RegistrySourceMode;
170
- roleHint: string | undefined;
171
- }>;
172
- previewWebAIProfile(request: {
173
- profileChoice: string;
174
- bindingId?: string;
175
- }): Promise<{
176
- profileChoice: string;
177
- resolved: import("@x12i/ai-profiles").ResolvedAIProfile;
178
- note: string;
179
- bindingId: string | undefined;
180
- slots: import("@x12i/web-functions").WebFunctionModelConfig | undefined;
181
- }>;
182
- startAnswer(request: AnswerFromWebRequest, opts?: {
183
- idempotencyKey?: string;
184
- }): Promise<RunRecord>;
185
- private runAnswerJob;
186
- startCompare(request: CompareWebSubjectsRequest, opts?: {
187
- idempotencyKey?: string;
188
- }): Promise<RunRecord>;
189
- private runCompareJob;
190
- getRun(runId: string): Promise<RunRecord | undefined>;
191
- listRunItems(runId: string, options?: ListItemsOptions): Promise<ListItemsResult>;
192
- cancelRun(runId: string): Promise<RunRecord>;
193
- resumeRun(runId: string): Promise<RunRecord>;
194
- private getBrowser;
195
- close(): Promise<void>;
196
- }
197
- //# sourceMappingURL=client.d.ts.map