@autorag/librarian 2.9.0 → 2.10.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/LICENSE +195 -21
- package/NOTICE +17 -21
- package/README.md +372 -143
- package/dist/agent/agent.d.ts +93 -22
- package/dist/agent/answer-citations.d.ts +22 -0
- package/dist/agent/answer-guidelines.d.ts +9 -9
- package/dist/agent/citations.d.ts +35 -23
- package/dist/agent/context-token-guard.d.ts +23 -0
- package/dist/agent/evidence-ledger.d.ts +7 -12
- package/dist/agent/index.d.ts +2 -2
- package/dist/agent/jev-extension.d.ts +5 -4
- package/dist/agent/jikji-find-tool.d.ts +1 -0
- package/dist/agent/pi-session.d.ts +35 -2
- package/dist/agent/request-limits.d.ts +20 -0
- package/dist/agent/{emit-results-tool.d.ts → results.d.ts} +5 -40
- package/dist/agent/search-all-tool.d.ts +1 -0
- package/dist/agent/search-documents.d.ts +14 -19
- package/dist/agent/search-single-datasource-tool.d.ts +1 -0
- package/dist/agent/self-config.d.ts +1 -1
- package/dist/cli/commands/report.d.ts +1 -1
- package/dist/cli/commands/tui.d.ts +3 -2
- package/dist/cli/config.d.ts +13 -11
- package/dist/cli/index.js +3939 -1684
- package/dist/cloud/authorize.d.ts +12 -0
- package/dist/cloud/callback-server.d.ts +33 -0
- package/dist/cloud/callback.d.ts +23 -0
- package/dist/cloud/config.d.ts +41 -0
- package/dist/cloud/errors.d.ts +46 -0
- package/dist/cloud/index.d.ts +12 -0
- package/dist/cloud/jev-backend.d.ts +90 -0
- package/dist/cloud/models.d.ts +32 -0
- package/dist/cloud/oauth-login.d.ts +22 -0
- package/dist/cloud/pkce.d.ts +20 -0
- package/dist/cloud/provider.d.ts +40 -0
- package/dist/cloud/token.d.ts +22 -0
- package/dist/core.d.ts +2 -5
- package/dist/core.js +3803 -1613
- package/dist/datasource/crawler-skill.d.ts +17 -0
- package/dist/datasource/sidecar/config.d.ts +26 -0
- package/dist/datasource/sidecar/descriptors.d.ts +67 -0
- package/dist/datasource/sidecar/fusion.d.ts +25 -0
- package/dist/datasource/sidecar/index.d.ts +131 -0
- package/dist/datasource/sidecar/methods.d.ts +27 -0
- package/dist/datasource/types.d.ts +3 -1
- package/dist/embedding-runtime/index.d.ts +6 -6
- package/dist/embedding-runtime/manifest.d.ts +0 -12
- package/dist/embedding-runtime/types.d.ts +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3982 -1676
- package/dist/mcp/index.js +3908 -1662
- package/dist/minsync/client.d.ts +3 -3
- package/dist/minsync/installer.d.ts +1 -1
- package/dist/minsync/process.d.ts +1 -0
- package/dist/minsync/types.d.ts +1 -1
- package/dist/observability/run-log.d.ts +1 -1
- package/dist/parser/defaults.d.ts +6 -4
- package/dist/parser/ocr-engines.d.ts +6 -0
- package/dist/retrieval/index.d.ts +2 -2
- package/dist/retrieval/rerank.d.ts +20 -3
- package/dist/retrieval/types.d.ts +0 -23
- package/licenses/embedding-assets.json +0 -35
- package/package.json +24 -27
- package/skills/autorag/SKILL.md +1 -1
- package/skills/autorag-doctor/SKILL.md +1 -1
- package/skills/autorag-lite-setup/SKILL.md +2 -2
- package/skills/autorag-setup/SKILL.md +3 -3
- package/dist/agent/fast-answer-tool.d.ts +0 -56
- package/licenses/gemma-notice.txt +0 -24
- package/licenses/gemma-section-3.2-flow-down.txt +0 -9
- package/licenses/gemma-terms-of-use.html +0 -4750
- package/licenses/gemma-terms-of-use.txt +0 -158
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface AuthorizeUrlParams {
|
|
2
|
+
/** Server root, e.g. `https://api.dazziapp.com`. */
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
/** Loopback redirect URI chosen by the login flow. */
|
|
5
|
+
redirectUri: string;
|
|
6
|
+
/** Random `state` echoed back on the redirect. */
|
|
7
|
+
state: string;
|
|
8
|
+
/** S256 code challenge derived from the PKCE verifier. */
|
|
9
|
+
codeChallenge: string;
|
|
10
|
+
}
|
|
11
|
+
/** Build the browser authorization URL for the PKCE authorization-code flow. */
|
|
12
|
+
export declare function buildAuthorizeUrl(params: AuthorizeUrlParams): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Path the browser is redirected to on the loopback listener. */
|
|
2
|
+
export declare const CALLBACK_PATH = "/callback";
|
|
3
|
+
/** Loopback listeners are ephemeral; abandon a login nobody completes. */
|
|
4
|
+
export declare const DEFAULT_LOGIN_TIMEOUT_MS: number;
|
|
5
|
+
export interface CallbackServer {
|
|
6
|
+
/** `http://127.0.0.1:<ephemeral port>/callback`. */
|
|
7
|
+
redirectUri: string;
|
|
8
|
+
/** Resolves with the first callback's query parameters. */
|
|
9
|
+
waitForCallback(): Promise<URLSearchParams>;
|
|
10
|
+
/** Stop listening and abandon any pending wait. */
|
|
11
|
+
close(): void;
|
|
12
|
+
}
|
|
13
|
+
export interface CallbackServerOptions {
|
|
14
|
+
/** Loopback interface to bind. Defaults to `127.0.0.1`. */
|
|
15
|
+
host?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Expected OAuth `state`. A browser callback is only accepted when it
|
|
18
|
+
* echoes this value, so a stray or forged request cannot win the race.
|
|
19
|
+
*/
|
|
20
|
+
state: string;
|
|
21
|
+
timeoutMs?: number;
|
|
22
|
+
signal?: AbortSignal;
|
|
23
|
+
onListening?: (redirectUri: string) => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Start a loopback HTTP listener for the OAuth redirect.
|
|
27
|
+
*
|
|
28
|
+
* The server closes itself as soon as the first valid callback — a request
|
|
29
|
+
* that echoes {@link CallbackServerOptions.state} and carries a `code` or
|
|
30
|
+
* `error` — arrives; malformed or forged requests get a `400` and are ignored.
|
|
31
|
+
* It also closes on abort and on timeout. Requests to other paths are ignored.
|
|
32
|
+
*/
|
|
33
|
+
export declare function startCallbackServer(options: CallbackServerOptions): Promise<CallbackServer>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Authorization response extracted from either the loopback server or a manual paste. */
|
|
2
|
+
export interface CallbackResult {
|
|
3
|
+
code?: string;
|
|
4
|
+
error?: string;
|
|
5
|
+
state?: string;
|
|
6
|
+
}
|
|
7
|
+
/** Read an authorization response out of query parameters. */
|
|
8
|
+
export declare function parseCallbackQuery(params: URLSearchParams): CallbackResult;
|
|
9
|
+
/**
|
|
10
|
+
* Parse what the user pasted when the browser could not reach the loopback
|
|
11
|
+
* server: a full redirect URL, a bare `code=...&state=...` query, or just the
|
|
12
|
+
* authorization code.
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseCallbackInput(input: string): CallbackResult;
|
|
15
|
+
/**
|
|
16
|
+
* Validate an authorization response against the expected `state` and return
|
|
17
|
+
* the authorization code. `state` is compared whenever the response carries
|
|
18
|
+
* one; a mismatch always aborts the login. A manual code paste carries no
|
|
19
|
+
* `state`, so there is nothing to compare there.
|
|
20
|
+
*/
|
|
21
|
+
export declare function requireAuthorizationCode(result: CallbackResult, expectedState: string): {
|
|
22
|
+
code: string;
|
|
23
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Provider identity and endpoint configuration for the hosted AutoRAG (Dazzi) plan. */
|
|
2
|
+
export declare const PROVIDER_ID = "autorag";
|
|
3
|
+
export declare const PROVIDER_NAME = "AutoRAG";
|
|
4
|
+
/** Server root, e.g. `https://api.dazziapp.com`. The API lives under `<root>/v1`. */
|
|
5
|
+
export declare const DEFAULT_BASE_URL = "https://api.dazziapp.com";
|
|
6
|
+
export declare const AUTORAG_BASE_URL_ENV = "AUTORAG_BASE_URL";
|
|
7
|
+
export declare const AUTORAG_API_KEY_ENV = "AUTORAG_API_KEY";
|
|
8
|
+
/** Server paths appended to the normalized server root. */
|
|
9
|
+
export declare const API_PATH = "/v1";
|
|
10
|
+
export declare const MODELS_PATH = "/v1/models";
|
|
11
|
+
export declare const AUTHORIZE_PATH = "/desktop/authorize";
|
|
12
|
+
export declare const TOKEN_PATH = "/api/desktop/token";
|
|
13
|
+
/**
|
|
14
|
+
* Request limits of the hosted API, declared on every `autorag` model.
|
|
15
|
+
*
|
|
16
|
+
* The API is served from Vercel, which rejects a request body above about
|
|
17
|
+
* 4.49 MB with HTTP 413 before it reaches the model (measured against
|
|
18
|
+
* `POST /v1/responses`). pi resends every image a tool returned on each later
|
|
19
|
+
* turn, so a search that reads a few photos crosses that line. The transcript
|
|
20
|
+
* cap leaves headroom for the tool declarations and request framing the
|
|
21
|
+
* transcript size does not count; the resize cap keeps one image well below it.
|
|
22
|
+
*/
|
|
23
|
+
export declare const AUTORAG_INPUT_LIMITS: {
|
|
24
|
+
readonly maxRequestBytes: 3500000;
|
|
25
|
+
readonly images: {
|
|
26
|
+
readonly resize: {
|
|
27
|
+
readonly maxBytes: 1000000;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
/** OAuth client identifier for the AutoRAG agent (Pi-compatible hosts use `pi`). */
|
|
32
|
+
export declare const OAUTH_CLIENT_ID = "agent";
|
|
33
|
+
/**
|
|
34
|
+
* Value used for `ProviderConfig.apiKey`. Pi resolves `$NAME` from the
|
|
35
|
+
* environment, so `AUTORAG_API_KEY` enables a headless, login-free setup.
|
|
36
|
+
*/
|
|
37
|
+
export declare const API_KEY_CONFIG_VALUE = "$AUTORAG_API_KEY";
|
|
38
|
+
/** Trim whitespace and trailing slashes so path concatenation is unambiguous. */
|
|
39
|
+
export declare function normalizeBaseUrl(value: string): string;
|
|
40
|
+
/** Server root from `AUTORAG_BASE_URL`, falling back to {@link DEFAULT_BASE_URL}. */
|
|
41
|
+
export declare function resolveBaseUrl(env: Record<string, string | undefined>): string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error types for the hosted AutoRAG (Dazzi) provider.
|
|
3
|
+
*
|
|
4
|
+
* Messages never contain credentials, authorization headers, or provider
|
|
5
|
+
* payloads; they are safe to surface in the CLI UI and in test assertions.
|
|
6
|
+
*/
|
|
7
|
+
/** Base class for every error raised by the AutoRAG provider. */
|
|
8
|
+
export declare class AutoragError extends Error {
|
|
9
|
+
constructor(message: string, options?: {
|
|
10
|
+
cause?: unknown;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
/** Raised for OAuth/PKCE/callback failures. */
|
|
14
|
+
export declare class AutoragOAuthError extends AutoragError {
|
|
15
|
+
constructor(message: string, options?: {
|
|
16
|
+
cause?: unknown;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Raised when an HTTP call to AutoRAG fails.
|
|
21
|
+
*
|
|
22
|
+
* `status` is the HTTP status code, `code`/`type` come from the OpenAI-shaped
|
|
23
|
+
* error body when the server supplies them.
|
|
24
|
+
*/
|
|
25
|
+
export declare class AutoragHttpError extends AutoragError {
|
|
26
|
+
readonly status: number;
|
|
27
|
+
readonly code?: string;
|
|
28
|
+
readonly type?: string;
|
|
29
|
+
constructor(message: string, options: {
|
|
30
|
+
status: number;
|
|
31
|
+
code?: string;
|
|
32
|
+
type?: string;
|
|
33
|
+
cause?: unknown;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export interface ErrorPayload {
|
|
37
|
+
message?: string;
|
|
38
|
+
code?: string;
|
|
39
|
+
type?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Extract `{ message, code, type }` from an OpenAI-shaped error body:
|
|
43
|
+
* `{ "error": { "message": ..., "type": ..., "code": ... } }`.
|
|
44
|
+
* Also tolerates `{ "error": "message" }` and a bare `{ "message": ... }`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function extractErrorPayload(body: unknown): ErrorPayload;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type { AuthorizeUrlParams } from "./authorize.js";
|
|
2
|
+
export { buildAuthorizeUrl } from "./authorize.js";
|
|
3
|
+
export type { CallbackResult } from "./callback.js";
|
|
4
|
+
export { parseCallbackInput, parseCallbackQuery, requireAuthorizationCode } from "./callback.js";
|
|
5
|
+
export { CALLBACK_PATH, type CallbackServer, type CallbackServerOptions, DEFAULT_LOGIN_TIMEOUT_MS, startCallbackServer, } from "./callback-server.js";
|
|
6
|
+
export { API_KEY_CONFIG_VALUE, API_PATH, AUTHORIZE_PATH, AUTORAG_API_KEY_ENV, AUTORAG_BASE_URL_ENV, DEFAULT_BASE_URL, MODELS_PATH, normalizeBaseUrl, OAUTH_CLIENT_ID, PROVIDER_ID, PROVIDER_NAME, resolveBaseUrl, TOKEN_PATH, } from "./config.js";
|
|
7
|
+
export { AutoragError, AutoragHttpError, AutoragOAuthError, type ErrorPayload, extractErrorPayload, } from "./errors.js";
|
|
8
|
+
export { buildStoreEntry, DEFAULT_CONTEXT_WINDOW, DEFAULT_MAX_TOKENS, type FetchModelsOptions, fetchModels, mapModelsError, mapServerModel, mapServerModels, modelsFromStore, resolveCredentialKey, } from "./models.js";
|
|
9
|
+
export { type LoginOptions, loginAutorag, refreshAutoragCredentials } from "./oauth-login.js";
|
|
10
|
+
export { base64UrlEncode, createCodeChallenge, createCodeVerifier, createPkcePair, createState, type PkcePair, } from "./pkce.js";
|
|
11
|
+
export { type AutoragEnv, createAutoRAGProviderConfig, refreshAutoragModels, registerAutoRAGProvider, } from "./provider.js";
|
|
12
|
+
export { type ExchangeCodeOptions, exchangeCodeForToken, mapTokenExchangeError, type TokenResponse } from "./token.js";
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jev backend for the hosted AutoRAG (Dazzi) plan.
|
|
3
|
+
*
|
|
4
|
+
* The server answers Jev's native dialect at `POST <root>/v1/jev` behind the
|
|
5
|
+
* account bearer key (`AUTORAG_API_KEY`), returning the same `answers` map the
|
|
6
|
+
* TypeSafe and OpenRouter backends do. `jev-use`'s package index does not
|
|
7
|
+
* export its native-dialect helpers, so the small mapping and the retrying JSON
|
|
8
|
+
* transport are reimplemented here against that documented dialect (covered by
|
|
9
|
+
* tests against a local HTTP server).
|
|
10
|
+
*
|
|
11
|
+
* Failures surface as `BackendError(name, "HTTP <status>: <message>", status)`
|
|
12
|
+
* so the engine degrades to an escalation with a readable hint instead of
|
|
13
|
+
* blocking the loop.
|
|
14
|
+
*/
|
|
15
|
+
import { type BackendRequest, type BackendResponse, type JevBackend, type Question, type RawAnswer, type State } from "jev-use";
|
|
16
|
+
/** API path appended to the normalized server root. */
|
|
17
|
+
export declare const JEV_PATH = "/v1/jev";
|
|
18
|
+
/** Live Jev model id on the hosted AutoRAG plan. */
|
|
19
|
+
export declare const AUTORAG_DEFAULT_JEV_MODEL = "jev-1.13";
|
|
20
|
+
/** Options for {@link AutoragJevBackend}. */
|
|
21
|
+
export interface AutoragJevBackendOptions {
|
|
22
|
+
/** Environment holding the bearer key and `AUTORAG_BASE_URL`. Default `process.env`. */
|
|
23
|
+
readonly env?: Record<string, string | undefined>;
|
|
24
|
+
/** Explicit bearer key; when omitted, read from `AUTORAG_API_KEY`. */
|
|
25
|
+
readonly apiKey?: string;
|
|
26
|
+
/** Override the server root (test seam); defaults to `resolveBaseUrl(env)`. */
|
|
27
|
+
readonly baseUrl?: string;
|
|
28
|
+
/** Model used when a call names none. @default AUTORAG_DEFAULT_JEV_MODEL */
|
|
29
|
+
readonly defaultModel?: string;
|
|
30
|
+
/** Abort one attempt after this long. @default 10_000 */
|
|
31
|
+
readonly timeoutMs?: number;
|
|
32
|
+
/** Retries on 408/429/5xx and network failures. @default 2 */
|
|
33
|
+
readonly maxRetries?: number;
|
|
34
|
+
/** Injection seam for tests. */
|
|
35
|
+
readonly fetchImpl?: typeof fetch;
|
|
36
|
+
}
|
|
37
|
+
type NativeWireQuestion = {
|
|
38
|
+
type: "noul";
|
|
39
|
+
instructions: string;
|
|
40
|
+
criteria?: {
|
|
41
|
+
true: string;
|
|
42
|
+
false: string;
|
|
43
|
+
};
|
|
44
|
+
} | {
|
|
45
|
+
type: "choice";
|
|
46
|
+
instructions: string;
|
|
47
|
+
criteria: Record<string, string>;
|
|
48
|
+
} | {
|
|
49
|
+
type: "score";
|
|
50
|
+
instructions: string;
|
|
51
|
+
criteria: string[];
|
|
52
|
+
};
|
|
53
|
+
interface NativeBody {
|
|
54
|
+
model: string;
|
|
55
|
+
state: string;
|
|
56
|
+
questions: Record<string, NativeWireQuestion>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Jev backend served by the hosted AutoRAG (Dazzi) plan.
|
|
60
|
+
*
|
|
61
|
+
* The constructor throws a named error when no account key is configured — a
|
|
62
|
+
* missing credential must be loud, never a silent fake judgment — and the retry
|
|
63
|
+
* policy mirrors `jev-use`'s own remote backends (408/429/5xx, `Retry-After`).
|
|
64
|
+
*/
|
|
65
|
+
export declare class AutoragJevBackend implements JevBackend {
|
|
66
|
+
readonly name = "autorag";
|
|
67
|
+
private readonly apiKey;
|
|
68
|
+
private readonly baseUrl;
|
|
69
|
+
private readonly defaultModel;
|
|
70
|
+
private readonly timeoutMs;
|
|
71
|
+
private readonly maxRetries;
|
|
72
|
+
private readonly fetchImpl;
|
|
73
|
+
constructor(options?: AutoragJevBackendOptions);
|
|
74
|
+
judge(request: BackendRequest): Promise<BackendResponse>;
|
|
75
|
+
/** POST JSON with a per-attempt timeout and jev-use's retry policy. */
|
|
76
|
+
private postJson;
|
|
77
|
+
}
|
|
78
|
+
/** Build the whole request body: model, a string state, and the questions by id. */
|
|
79
|
+
export declare function toNativeBody(state: State, questions: (Question & {
|
|
80
|
+
id: string;
|
|
81
|
+
})[], model: string): NativeBody;
|
|
82
|
+
/**
|
|
83
|
+
* Read the provider's answer map back into raw answers, in question order.
|
|
84
|
+
* Anything missing or mistyped is a `BackendError` — a silently dropped answer
|
|
85
|
+
* would read as a low-confidence judgment.
|
|
86
|
+
*/
|
|
87
|
+
export declare function parseNativeAnswers(backend: string, answers: unknown, questions: (Question & {
|
|
88
|
+
id: string;
|
|
89
|
+
})[]): RawAnswer[];
|
|
90
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Credential, ModelsStoreEntry } from "@earendil-works/pi-ai";
|
|
2
|
+
import type { ProviderModelConfig } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import { AutoragHttpError } from "./errors.js";
|
|
4
|
+
/** Used when the server omits `context_window` / `max_output_tokens`. */
|
|
5
|
+
export declare const DEFAULT_CONTEXT_WINDOW = 128000;
|
|
6
|
+
export declare const DEFAULT_MAX_TOKENS = 16384;
|
|
7
|
+
export interface FetchModelsOptions {
|
|
8
|
+
/** Server root, e.g. `https://api.dazziapp.com`. */
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
/** Bearer token resolved from OAuth credentials or `AUTORAG_API_KEY`. */
|
|
11
|
+
apiKey: string;
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
fetchImpl?: typeof fetch;
|
|
14
|
+
}
|
|
15
|
+
/** Pick the bearer token out of a stored Pi credential. */
|
|
16
|
+
export declare function resolveCredentialKey(credential: Credential | undefined): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* `GET <root>/v1/models` -> Pi chat model definitions.
|
|
19
|
+
*
|
|
20
|
+
* Pricing is USD per million tokens, matching Pi's cost model directly.
|
|
21
|
+
*/
|
|
22
|
+
export declare function fetchModels(options: FetchModelsOptions): Promise<ProviderModelConfig[]>;
|
|
23
|
+
/** Map a failed `/v1/models` response; 401 means the token is invalid or revoked. */
|
|
24
|
+
export declare function mapModelsError(status: number, body: unknown): AutoragHttpError;
|
|
25
|
+
/** Map an OpenAI-shaped `{ object: "list", data: [...] }` catalog body. */
|
|
26
|
+
export declare function mapServerModels(payload: unknown): ProviderModelConfig[];
|
|
27
|
+
/** Map a single AutoRAG model record; returns `undefined` when it has no usable id. */
|
|
28
|
+
export declare function mapServerModel(entry: Record<string, unknown>): ProviderModelConfig | undefined;
|
|
29
|
+
/** Snapshot the live catalog for offline startup. */
|
|
30
|
+
export declare function buildStoreEntry(models: readonly ProviderModelConfig[], providerId: string, baseUrl: string): ModelsStoreEntry;
|
|
31
|
+
/** Restore chat model definitions from a persisted catalog snapshot. */
|
|
32
|
+
export declare function modelsFromStore(stored: ModelsStoreEntry | undefined): ProviderModelConfig[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { OAuthCredentials, OAuthLoginCallbacks } from "@earendil-works/pi-ai";
|
|
2
|
+
export interface LoginOptions {
|
|
3
|
+
/** Server root, e.g. `https://api.dazziapp.com`. */
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
/** Loopback wait budget; defaults to {@link DEFAULT_LOGIN_TIMEOUT_MS}. */
|
|
6
|
+
timeoutMs?: number;
|
|
7
|
+
fetchImpl?: typeof fetch;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* AutoRAG tokens are long-lived revocable API keys: there is no refresh token
|
|
11
|
+
* and no expiry, so a refresh returns the stored credentials unchanged.
|
|
12
|
+
*/
|
|
13
|
+
export declare function refreshAutoragCredentials(credentials: OAuthCredentials): OAuthCredentials;
|
|
14
|
+
/**
|
|
15
|
+
* OAuth2 authorization-code + PKCE (S256) login for native apps.
|
|
16
|
+
*
|
|
17
|
+
* The browser is sent to `<root>/desktop/authorize` with a loopback redirect
|
|
18
|
+
* URI. When the browser cannot reach the loopback server, the user can paste
|
|
19
|
+
* the final redirect URL (or the bare code) into the prompt instead; both paths
|
|
20
|
+
* are raced and the first result wins.
|
|
21
|
+
*/
|
|
22
|
+
export declare function loginAutorag(callbacks: OAuthLoginCallbacks, options: LoginOptions): Promise<OAuthCredentials>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** RFC 7636 base64url encoding (unpadded, `-`/`_` alphabet). */
|
|
2
|
+
export declare function base64UrlEncode(bytes: Uint8Array): string;
|
|
3
|
+
/**
|
|
4
|
+
* `BASE64URL(SHA256(ASCII(code_verifier)))` — the S256 code challenge.
|
|
5
|
+
*
|
|
6
|
+
* RFC 7636 Appendix B reference vector: verifier
|
|
7
|
+
* `dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk` yields challenge
|
|
8
|
+
* `E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createCodeChallenge(verifier: string): string;
|
|
11
|
+
/** Random high-entropy PKCE code verifier (43 chars for the default 32 bytes). */
|
|
12
|
+
export declare function createCodeVerifier(byteLength?: number): string;
|
|
13
|
+
/** Random `state` value used to detect CSRF on the OAuth redirect. */
|
|
14
|
+
export declare function createState(byteLength?: number): string;
|
|
15
|
+
export interface PkcePair {
|
|
16
|
+
verifier: string;
|
|
17
|
+
challenge: string;
|
|
18
|
+
}
|
|
19
|
+
/** Generate a verifier and its matching S256 challenge in one step. */
|
|
20
|
+
export declare function createPkcePair(byteLength?: number): PkcePair;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hosted AutoRAG (Dazzi) plan as a first-class model provider named
|
|
3
|
+
* `autorag`.
|
|
4
|
+
*
|
|
5
|
+
* The server exposes an OpenAI Responses API surface under `<root>/v1`. Login
|
|
6
|
+
* is OAuth2 authorization-code + PKCE over a loopback redirect (or the headless
|
|
7
|
+
* `AUTORAG_API_KEY`), and the model catalog is discovered live from
|
|
8
|
+
* `GET <root>/v1/models` — no model id is ever hardcoded here. Streaming is
|
|
9
|
+
* delegated to Pi's built-in `openai-responses` API implementation.
|
|
10
|
+
*/
|
|
11
|
+
import type { RefreshModelsContext } from "@earendil-works/pi-ai";
|
|
12
|
+
import type { ModelRuntime, ProviderConfig, ProviderModelConfig } from "@earendil-works/pi-coding-agent";
|
|
13
|
+
/** Injection seam for tests and hosts that resolve configuration themselves. */
|
|
14
|
+
export type AutoragEnv = Record<string, string | undefined>;
|
|
15
|
+
interface Endpoints {
|
|
16
|
+
/** Server root, used for OAuth endpoints. */
|
|
17
|
+
baseUrl: string;
|
|
18
|
+
/** API base (`<root>/v1`), used as the provider `baseUrl` and for model listing. */
|
|
19
|
+
apiBaseUrl: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Resolve the provider's model list.
|
|
23
|
+
*
|
|
24
|
+
* Called by Pi with the credential it resolved for this provider. Without a
|
|
25
|
+
* credential (or without network access) the last persisted catalog, if any,
|
|
26
|
+
* is restored; a failed fetch keeps the previous list instead of blanking it.
|
|
27
|
+
*/
|
|
28
|
+
export declare function refreshAutoragModels(context: RefreshModelsContext, endpoints: Endpoints): Promise<ProviderModelConfig[]>;
|
|
29
|
+
/** Build the `ProviderConfig` handed to `ModelRuntime.registerProvider("autorag", ...)`. */
|
|
30
|
+
export declare function createAutoRAGProviderConfig(env?: AutoragEnv): ProviderConfig;
|
|
31
|
+
/**
|
|
32
|
+
* The single registration point: register `autorag` on a Pi `ModelRuntime`.
|
|
33
|
+
*
|
|
34
|
+
* Runs even when the user is not signed in, so `/login` lists AutoRAG. The
|
|
35
|
+
* awaited cache-only refresh loads the persisted catalog snapshot (offline and
|
|
36
|
+
* with `allowModelNetwork:false`); it makes no network call, so a signed-out
|
|
37
|
+
* provider contributes no models and nothing here reaches the network.
|
|
38
|
+
*/
|
|
39
|
+
export declare function registerAutoRAGProvider(runtime: ModelRuntime, env?: AutoragEnv): Promise<void>;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AutoragHttpError } from "./errors.js";
|
|
2
|
+
export interface TokenResponse {
|
|
3
|
+
accessToken: string;
|
|
4
|
+
email?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ExchangeCodeOptions {
|
|
7
|
+
/** Server root, e.g. `https://api.dazziapp.com`. */
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
code: string;
|
|
10
|
+
codeVerifier: string;
|
|
11
|
+
redirectUri: string;
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
fetchImpl?: typeof fetch;
|
|
14
|
+
}
|
|
15
|
+
/** Map a failed token-exchange response to an error carrying the HTTP status and server code. */
|
|
16
|
+
export declare function mapTokenExchangeError(status: number, body: unknown): AutoragHttpError;
|
|
17
|
+
/**
|
|
18
|
+
* Trade a PKCE authorization code for a long-lived API key.
|
|
19
|
+
*
|
|
20
|
+
* `POST <root>/api/desktop/token` with `{ code, code_verifier, redirect_uri }`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function exchangeCodeForToken(options: ExchangeCodeOptions): Promise<TokenResponse>;
|
package/dist/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AutoRAGJikjiPrepareResult, AutoRAGRefreshOptions, AutoRAGRefreshResult, AutoRAGRefreshStatus, AutoRAGWatchRefreshHandle, AutoRAGWatchRefreshOptions } from "./agent/agent.js";
|
|
2
|
-
import type { AutoRAGResultsDetails } from "./agent/
|
|
2
|
+
import type { AutoRAGResultsDetails } from "./agent/results.js";
|
|
3
3
|
import { type SearchDocumentsResponse } from "./agent/search-documents.js";
|
|
4
4
|
import { type CliConfig, type ResolveConfigInput } from "./cli/config.js";
|
|
5
5
|
import type { EverythingSearchRequest, EverythingSearchResult } from "./everything/index.js";
|
|
@@ -9,7 +9,7 @@ import type { MinSyncSyncResult } from "./minsync/types.js";
|
|
|
9
9
|
import type { ParsedMirrorSyncResult } from "./mirror/sync.js";
|
|
10
10
|
import type { RetrievalEngine } from "./retrieval/engine.js";
|
|
11
11
|
import type { DatasourceCatalogEntry, RetrievalSelection } from "./retrieval/selection.js";
|
|
12
|
-
import type {
|
|
12
|
+
import type { RetrievalDiagnostic, RetrievalOptions, RetrievalResult, RetrievalUnsearchedSurface } from "./retrieval/types.js";
|
|
13
13
|
/** Input accepted by {@link createAutoRAGLite}. Flags keep CLI precedence intact. */
|
|
14
14
|
export interface AutoRAGLiteOptions {
|
|
15
15
|
readonly flags?: ResolveConfigInput["flags"];
|
|
@@ -23,7 +23,6 @@ export declare class AutoRAGLite {
|
|
|
23
23
|
private readonly agent;
|
|
24
24
|
private readonly retrievalEngine;
|
|
25
25
|
private readonly memory;
|
|
26
|
-
private readonly sessions;
|
|
27
26
|
constructor(config: CliConfig);
|
|
28
27
|
/** Refresh parsed mirrors and configured indexes without constructing a model. */
|
|
29
28
|
refresh(force?: boolean, options?: AutoRAGRefreshOptions): Promise<AutoRAGRefreshResult>;
|
|
@@ -82,8 +81,6 @@ export declare class AutoRAGLite {
|
|
|
82
81
|
recordStructuredResultsSession(sessionId: string, query: string, details: AutoRAGResultsDetails): SearchDocumentsResponse;
|
|
83
82
|
/** Generate a session id and persist a typed structured report. */
|
|
84
83
|
recordReport(query: string, details: AutoRAGResultsDetails): SearchDocumentsResponse;
|
|
85
|
-
/** Return the opaque result registry associated with a persisted report. */
|
|
86
|
-
getResultRegistry(sessionId: string): ReadonlyMap<number, CuratedResult>;
|
|
87
84
|
/** Return a detached snapshot of persisted evidence state. */
|
|
88
85
|
getMemorySchema(): MemorySchema;
|
|
89
86
|
}
|