@anaralabs/sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +100 -0
- package/dist/agent-guide.d.ts +2 -0
- package/dist/agent-guide.d.ts.map +1 -0
- package/dist/agent-guide.js +29 -0
- package/dist/agent-guide.js.map +1 -0
- package/dist/client.d.ts +87 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +112 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +15 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +45 -0
- package/dist/errors.js.map +1 -0
- package/dist/http.d.ts +19 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +74 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/openapi.d.ts +38 -0
- package/dist/openapi.d.ts.map +1 -0
- package/dist/openapi.js +65 -0
- package/dist/openapi.js.map +1 -0
- package/dist/schemas.d.ts +693 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +469 -0
- package/dist/schemas.js.map +1 -0
- package/dist/types.d.ts +56 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Anara Labs, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# @anaralabs/sdk
|
|
2
|
+
|
|
3
|
+
Official TypeScript SDK for the [Anara](https://anara.com) API. It mirrors
|
|
4
|
+
Anara's in-product code-agent SDK — the full `anara.*` surface (library search,
|
|
5
|
+
research, entities, documents, spreadsheets, notes, images, RLM map/ask) — as a
|
|
6
|
+
typed HTTP client. Give a coding agent (Claude Code, Codex, …) the same tools
|
|
7
|
+
the Anara agent has, over a single API key.
|
|
8
|
+
|
|
9
|
+
Zero runtime dependencies. Works in Node 18+, Deno, Bun, edge runtimes, and the
|
|
10
|
+
browser (anywhere `fetch` exists).
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @anaralabs/sdk
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Authenticate
|
|
19
|
+
|
|
20
|
+
Mint an API key (Better Auth) from your signed-in browser session:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
curl -X POST https://anara.com/api/better-auth/api-key/create \
|
|
24
|
+
-H 'content-type: application/json' \
|
|
25
|
+
-H 'cookie: <signed-in-browser-cookie>' \
|
|
26
|
+
-d '{"name":"CLI","permissions":{"anara":["read","chat","write"]}}'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Keys look like `anara_…`. Reads need `anara:read`; library writes need
|
|
30
|
+
`anara:write`. Keep them secret; never commit them.
|
|
31
|
+
|
|
32
|
+
## Use
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { createAnaraClient } from '@anaralabs/sdk';
|
|
36
|
+
|
|
37
|
+
// `apiKey` defaults to the ANARA_API_KEY environment variable.
|
|
38
|
+
const anara = createAnaraClient();
|
|
39
|
+
|
|
40
|
+
// Retrieval — one call answers most questions, with citable passages.
|
|
41
|
+
const hits = await anara.search({ query: 'wooden pallet recycling drop-off' });
|
|
42
|
+
|
|
43
|
+
// Search + read the winners' pages in one shot.
|
|
44
|
+
const research = await anara.research({
|
|
45
|
+
query: ['revenue 2021', 'revenue 2022'],
|
|
46
|
+
readPages: 2,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Library entities (CRUD). Writes need an `anara:write` key.
|
|
50
|
+
const drafts = await anara.entities.query({
|
|
51
|
+
type: 'NOTE',
|
|
52
|
+
nameContains: 'draft',
|
|
53
|
+
});
|
|
54
|
+
const folder = await anara.entities.create({ type: 'GROUP', name: 'Drafts' });
|
|
55
|
+
for (const d of drafts) await anara.entities.move(d.id, folder.id);
|
|
56
|
+
|
|
57
|
+
// Fan a cheap sub-LM over big data (RLM).
|
|
58
|
+
const labels = await anara.map(reviews, 'Reply POSITIVE or NEGATIVE.');
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## How it works
|
|
62
|
+
|
|
63
|
+
The package is a thin client: every `anara.*` method is one HTTP call to the
|
|
64
|
+
Anara API (`POST /api/v1/sdk` with `{ method, args }`), dispatched server-side
|
|
65
|
+
against your authenticated workspace. `anara.me()` hits `GET /api/v1/me`. There
|
|
66
|
+
is no Anara logic in the package itself — just typed calls over your key.
|
|
67
|
+
|
|
68
|
+
## Surface
|
|
69
|
+
|
|
70
|
+
`entities.query/get/create/update/move/delete` · `search` · `research` ·
|
|
71
|
+
`retrieval.vectorSearch/keywordSearch/rerank` ·
|
|
72
|
+
`documents.getPages/expandContext/readToc/readMedia/extract` ·
|
|
73
|
+
`store.put/get` · `map` · `ask` · `askMany` ·
|
|
74
|
+
`spreadsheets.query/applyEdits` · `notes.read/edit` · `images.create` ·
|
|
75
|
+
`chats.search` · `workspace.queryDb` · `me`.
|
|
76
|
+
|
|
77
|
+
`invoke(method, args)` is the escape hatch for any method not yet wrapped.
|
|
78
|
+
|
|
79
|
+
Errors are thrown as `AnaraApiError` (`.status`, `.code`, `.details`);
|
|
80
|
+
`isAnaraApiError(e)` is a type guard.
|
|
81
|
+
|
|
82
|
+
### Drop-in agent guide
|
|
83
|
+
|
|
84
|
+
`ANARA_AGENT_GUIDE` is a ready-made system-prompt block teaching an agent when
|
|
85
|
+
and how to call the SDK:
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import { ANARA_AGENT_GUIDE } from '@anaralabs/sdk';
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Configuration
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
createAnaraClient({
|
|
95
|
+
apiKey: '…', // or ANARA_API_KEY
|
|
96
|
+
baseUrl: 'https://anara.com', // override for self-hosted / preview
|
|
97
|
+
fetch: customFetch, // override the fetch implementation
|
|
98
|
+
headers: { 'x-trace': '…' }, // extra headers on every request
|
|
99
|
+
});
|
|
100
|
+
```
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const ANARA_AGENT_GUIDE = "# Anara SDK \u2014 agent guide\n\nYou have an `anara` client (`@anaralabs/sdk`) authenticated to a research workspace.\nIt mirrors Anara's code-agent SDK: every call hits the Anara API over your key.\n\n## Retrieval (the common job)\n- `anara.search({ query, documentIds?, limit? })` \u2192 ranked, citable passages. ONE call answers most \"what does my library say about X\". STOP once you have a plausible answer \u2014 re-verifying is the #1 cost.\n- `anara.research({ query, readPages? })` \u2192 search + read the top winners' pages in one call. Pass an array of sub-questions (\u22646) to decompose.\n- `anara.retrieval.vectorSearch/keywordSearch({ queries })` then `anara.retrieval.rerank({ query, candidates, topK })` to compose custom recall. Gather wide, rerank, return narrow.\n- `anara.documents.getPages(documentId, [page])` to read full pages.\n\n## Library entities (CRUD)\n- `anara.entities.query({ type?, nameContains?, groupId?, limit? })`, `anara.entities.get(id, { withBody })`.\n- `anara.entities.create({ type: 'NOTE'|'GROUP'|'SPREADSHEET', ... })`, `update(id, { name })`, `move(id, groupId)`, `delete(ids, { dryRun })`.\n- Bulk delete? `delete(ids, { dryRun: true })` FIRST. Writes need an `anara:write` key.\n\n## Heavier tools\n- `anara.map(items, instruction, opts?)` and `anara.askMany(tasks, instruction?)` \u2014 fan a cheap sub-LM over big data when the per-item decision needs language judgment (NOT for string/regex/numeric tests \u2014 do those in plain code). `anara.ask(prompt, instruction?)` is the single-shot version.\n- `anara.store.put(value)` and `anara.store.get(handle)` \u2014 stash big intermediate data out of context (`store.put` needs an `anara:write` key).\n\n## How to use it well\n- Prefer `anara.search` over scraping; it already does retrieval + rerank.\n- One decisive call per step \u2014 round-trips are the cost.\n- Treat results as evidence to cite, not ground truth.\n";
|
|
2
|
+
//# sourceMappingURL=agent-guide.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-guide.d.ts","sourceRoot":"","sources":["../src/agent-guide.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,64DAwB7B,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// A drop-in system-prompt block teaching a coding agent (Claude Code, Codex, …)
|
|
2
|
+
// how to drive the Anara SDK — the same `anara.*` surface the in-product code
|
|
3
|
+
// agent uses, over an API key.
|
|
4
|
+
export const ANARA_AGENT_GUIDE = `# Anara SDK — agent guide
|
|
5
|
+
|
|
6
|
+
You have an \`anara\` client (\`@anaralabs/sdk\`) authenticated to a research workspace.
|
|
7
|
+
It mirrors Anara's code-agent SDK: every call hits the Anara API over your key.
|
|
8
|
+
|
|
9
|
+
## Retrieval (the common job)
|
|
10
|
+
- \`anara.search({ query, documentIds?, limit? })\` → ranked, citable passages. ONE call answers most "what does my library say about X". STOP once you have a plausible answer — re-verifying is the #1 cost.
|
|
11
|
+
- \`anara.research({ query, readPages? })\` → search + read the top winners' pages in one call. Pass an array of sub-questions (≤6) to decompose.
|
|
12
|
+
- \`anara.retrieval.vectorSearch/keywordSearch({ queries })\` then \`anara.retrieval.rerank({ query, candidates, topK })\` to compose custom recall. Gather wide, rerank, return narrow.
|
|
13
|
+
- \`anara.documents.getPages(documentId, [page])\` to read full pages.
|
|
14
|
+
|
|
15
|
+
## Library entities (CRUD)
|
|
16
|
+
- \`anara.entities.query({ type?, nameContains?, groupId?, limit? })\`, \`anara.entities.get(id, { withBody })\`.
|
|
17
|
+
- \`anara.entities.create({ type: 'NOTE'|'GROUP'|'SPREADSHEET', ... })\`, \`update(id, { name })\`, \`move(id, groupId)\`, \`delete(ids, { dryRun })\`.
|
|
18
|
+
- Bulk delete? \`delete(ids, { dryRun: true })\` FIRST. Writes need an \`anara:write\` key.
|
|
19
|
+
|
|
20
|
+
## Heavier tools
|
|
21
|
+
- \`anara.map(items, instruction, opts?)\` and \`anara.askMany(tasks, instruction?)\` — fan a cheap sub-LM over big data when the per-item decision needs language judgment (NOT for string/regex/numeric tests — do those in plain code). \`anara.ask(prompt, instruction?)\` is the single-shot version.
|
|
22
|
+
- \`anara.store.put(value)\` and \`anara.store.get(handle)\` — stash big intermediate data out of context (\`store.put\` needs an \`anara:write\` key).
|
|
23
|
+
|
|
24
|
+
## How to use it well
|
|
25
|
+
- Prefer \`anara.search\` over scraping; it already does retrieval + rerank.
|
|
26
|
+
- One decisive call per step — round-trips are the cost.
|
|
27
|
+
- Treat results as evidence to cite, not ground truth.
|
|
28
|
+
`;
|
|
29
|
+
//# sourceMappingURL=agent-guide.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-guide.js","sourceRoot":"","sources":["../src/agent-guide.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,8EAA8E;AAC9E,+BAA+B;AAC/B,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;CAwBhC,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { AnaraClientOptions, AnaraMe, AskTask, ChatsSearchInput, CreateEntityInput, DeleteEntitiesOptions, DeleteEntitiesResult, DocumentPages, EntityEnvelope, EntityQuery, ExpandContextInput, ExtractInput, GetEntityOptions, ImageCreateInput, MapOptions, MapResult, NoteEditInput, NoteReadInput, Passage, ReadMediaInput, ReadTocInput, RerankInput, ResearchInput, ResearchResult, RetrievalInput, SearchHit, SearchInput, SpreadsheetApplyEditsInput, SpreadsheetQueryInput, StorePutResult, UpdateEntityPatch, WorkspaceQueryInput } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Typed client for the Anara API. Mirrors the in-product `anara.*` SDK: every
|
|
4
|
+
* method is a `POST /api/v1/sdk/{method}` call whose JSON body is the method's
|
|
5
|
+
* arguments, dispatched server-side against your authenticated workspace.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const anara = createAnaraClient();
|
|
9
|
+
* const notes = await anara.entities.query({ type: 'NOTE', limit: 50 });
|
|
10
|
+
* const hits = await anara.search({ query: 'wooden pallet recycling' });
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare class AnaraClient {
|
|
14
|
+
private readonly config;
|
|
15
|
+
constructor(options?: AnaraClientOptions);
|
|
16
|
+
/** The user + active workspace the API key resolves to. */
|
|
17
|
+
me(): Promise<AnaraMe>;
|
|
18
|
+
/** Call a single `anara.*` method by name (escape hatch for the typed methods). */
|
|
19
|
+
invoke<T = unknown>(method: string, body?: Record<string, unknown>): Promise<T>;
|
|
20
|
+
readonly entities: {
|
|
21
|
+
query: (query?: EntityQuery) => Promise<EntityEnvelope[]>;
|
|
22
|
+
get: (id: string, options?: GetEntityOptions) => Promise<EntityEnvelope>;
|
|
23
|
+
create: (input: CreateEntityInput) => Promise<EntityEnvelope>;
|
|
24
|
+
update: (id: string, patch: UpdateEntityPatch) => Promise<EntityEnvelope>;
|
|
25
|
+
move: (id: string, groupId: string | null) => Promise<EntityEnvelope>;
|
|
26
|
+
delete: (ids: string | string[], options?: DeleteEntitiesOptions) => Promise<DeleteEntitiesResult>;
|
|
27
|
+
};
|
|
28
|
+
search(input: SearchInput): Promise<SearchHit[]>;
|
|
29
|
+
research(input: ResearchInput): Promise<ResearchResult | ResearchResult[]>;
|
|
30
|
+
readonly retrieval: {
|
|
31
|
+
vectorSearch: (input: RetrievalInput) => Promise<SearchHit[]>;
|
|
32
|
+
keywordSearch: (input: RetrievalInput) => Promise<SearchHit[]>;
|
|
33
|
+
rerank: (input: RerankInput) => Promise<SearchHit[]>;
|
|
34
|
+
};
|
|
35
|
+
readonly documents: {
|
|
36
|
+
getPages: (documentId: string, pages?: number[]) => Promise<DocumentPages>;
|
|
37
|
+
expandContext: (input: ExpandContextInput) => Promise<{
|
|
38
|
+
passages: Passage[];
|
|
39
|
+
}>;
|
|
40
|
+
readToc: (input: ReadTocInput) => Promise<{
|
|
41
|
+
toc: unknown;
|
|
42
|
+
}>;
|
|
43
|
+
readMedia: (input: ReadMediaInput) => Promise<{
|
|
44
|
+
passages: Array<{
|
|
45
|
+
passageId: string;
|
|
46
|
+
text: string;
|
|
47
|
+
}>;
|
|
48
|
+
}>;
|
|
49
|
+
extract: (input: ExtractInput) => Promise<{
|
|
50
|
+
items: Array<Record<string, unknown>>;
|
|
51
|
+
}>;
|
|
52
|
+
};
|
|
53
|
+
readonly spreadsheets: {
|
|
54
|
+
query: (input: SpreadsheetQueryInput) => Promise<unknown>;
|
|
55
|
+
applyEdits: (input: SpreadsheetApplyEditsInput) => Promise<unknown>;
|
|
56
|
+
};
|
|
57
|
+
readonly notes: {
|
|
58
|
+
read: (input: NoteReadInput) => Promise<{
|
|
59
|
+
success?: boolean;
|
|
60
|
+
content?: string;
|
|
61
|
+
message?: string;
|
|
62
|
+
}>;
|
|
63
|
+
edit: (input: NoteEditInput) => Promise<{
|
|
64
|
+
success: boolean;
|
|
65
|
+
}>;
|
|
66
|
+
};
|
|
67
|
+
readonly images: {
|
|
68
|
+
create: (input: ImageCreateInput) => Promise<{
|
|
69
|
+
url: string;
|
|
70
|
+
}>;
|
|
71
|
+
};
|
|
72
|
+
readonly workspace: {
|
|
73
|
+
queryDb: (input: WorkspaceQueryInput) => Promise<unknown>;
|
|
74
|
+
};
|
|
75
|
+
readonly chats: {
|
|
76
|
+
search: (input: ChatsSearchInput) => Promise<unknown>;
|
|
77
|
+
};
|
|
78
|
+
readonly store: {
|
|
79
|
+
put: (value: unknown) => Promise<StorePutResult>;
|
|
80
|
+
get: <T = unknown>(handle: string) => Promise<T>;
|
|
81
|
+
};
|
|
82
|
+
map(items: unknown[] | string, instruction: string, options?: MapOptions): Promise<MapResult[]>;
|
|
83
|
+
ask(prompt: string, instruction?: string): Promise<string>;
|
|
84
|
+
askMany(tasks: AskTask[], instruction?: string): Promise<MapResult[]>;
|
|
85
|
+
}
|
|
86
|
+
export declare function createAnaraClient(options?: AnaraClientOptions): AnaraClient;
|
|
87
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,kBAAkB,EAClB,OAAO,EACP,OAAO,EACP,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,aAAa,EACb,a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CAAC;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC;MAE3D;IAEF,QAAQ,CAAC,SAAS;QAChB,OAAO,UAAU,mBAAmB,KAAG,OAAO,CAAC,OAAO,CAAC;MAEvD;IAEF,QAAQ,CAAC,KAAK;QACZ,MAAM,UAAU,gBAAgB,KAAG,OAAO,CAAC,OAAO,CAAC;MAEnD;IAEF,QAAQ,CAAC,KAAK;QACZ,GAAG,UAAU,OAAO,KAAG,OAAO,CAAC,cAAc,CAAC;QAE9C,GAAG,GAAG,CAAC,GAAG,OAAO,UAAU,MAAM,KAAG,OAAO,CAAC,CAAC,CAAC;MAE9C;IAEF,GAAG,CACD,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,EACzB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,UAAU,GACnB,OAAO,CAAC,SAAS,EAAE,CAAC,CAEtB;IAED,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEzD;IAED,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAEpE;CACF;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE,kBAAuB,GAC/B,WAAW,CAEb"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { AnaraError } from './errors.js';
|
|
2
|
+
import { httpRequest, normalizeBaseUrl } from './http.js';
|
|
3
|
+
const DEFAULT_BASE_URL = 'https://anara.com';
|
|
4
|
+
function envApiKey() {
|
|
5
|
+
const env = globalThis.process?.env;
|
|
6
|
+
return env?.ANARA_API_KEY;
|
|
7
|
+
}
|
|
8
|
+
function compact(body) {
|
|
9
|
+
for (const key of Object.keys(body)) {
|
|
10
|
+
if (body[key] === undefined)
|
|
11
|
+
delete body[key];
|
|
12
|
+
}
|
|
13
|
+
return body;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Typed client for the Anara API. Mirrors the in-product `anara.*` SDK: every
|
|
17
|
+
* method is a `POST /api/v1/sdk/{method}` call whose JSON body is the method's
|
|
18
|
+
* arguments, dispatched server-side against your authenticated workspace.
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* const anara = createAnaraClient();
|
|
22
|
+
* const notes = await anara.entities.query({ type: 'NOTE', limit: 50 });
|
|
23
|
+
* const hits = await anara.search({ query: 'wooden pallet recycling' });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export class AnaraClient {
|
|
27
|
+
config;
|
|
28
|
+
constructor(options = {}) {
|
|
29
|
+
const apiKey = (options.apiKey ?? envApiKey())?.trim();
|
|
30
|
+
if (!apiKey) {
|
|
31
|
+
throw new AnaraError('AnaraClient requires an API key — pass `new AnaraClient({ apiKey })` or set the ANARA_API_KEY environment variable.');
|
|
32
|
+
}
|
|
33
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
34
|
+
if (typeof fetchImpl !== 'function') {
|
|
35
|
+
throw new AnaraError('No `fetch` implementation available — pass `options.fetch`.');
|
|
36
|
+
}
|
|
37
|
+
this.config = {
|
|
38
|
+
apiKey,
|
|
39
|
+
baseUrl: normalizeBaseUrl(options.baseUrl ?? DEFAULT_BASE_URL),
|
|
40
|
+
fetch: fetchImpl,
|
|
41
|
+
headers: options.headers ?? {},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** The user + active workspace the API key resolves to. */
|
|
45
|
+
me() {
|
|
46
|
+
return httpRequest(this.config, 'GET', '/api/v1/me');
|
|
47
|
+
}
|
|
48
|
+
/** Call a single `anara.*` method by name (escape hatch for the typed methods). */
|
|
49
|
+
invoke(method, body = {}) {
|
|
50
|
+
return httpRequest(this.config, 'POST', `/api/v1/sdk/${encodeURIComponent(method)}`, { body });
|
|
51
|
+
}
|
|
52
|
+
entities = {
|
|
53
|
+
query: (query = {}) => this.invoke('entities.query', { ...query }),
|
|
54
|
+
get: (id, options) => this.invoke('entities.get', compact({ id, ...options })),
|
|
55
|
+
create: (input) => this.invoke('entities.create', { ...input }),
|
|
56
|
+
update: (id, patch) => this.invoke('entities.update', compact({ id, ...patch })),
|
|
57
|
+
move: (id, groupId) => this.invoke('entities.move', { id, groupId }),
|
|
58
|
+
delete: (ids, options) => this.invoke('entities.delete', compact({ ids, ...options })),
|
|
59
|
+
};
|
|
60
|
+
search(input) {
|
|
61
|
+
return this.invoke('search', { ...input });
|
|
62
|
+
}
|
|
63
|
+
research(input) {
|
|
64
|
+
return this.invoke('research', { ...input });
|
|
65
|
+
}
|
|
66
|
+
retrieval = {
|
|
67
|
+
vectorSearch: (input) => this.invoke('retrieval.vectorSearch', { ...input }),
|
|
68
|
+
keywordSearch: (input) => this.invoke('retrieval.keywordSearch', { ...input }),
|
|
69
|
+
rerank: (input) => this.invoke('retrieval.rerank', { ...input }),
|
|
70
|
+
};
|
|
71
|
+
documents = {
|
|
72
|
+
getPages: (documentId, pages) => this.invoke('documents.getPages', compact({ documentId, pages })),
|
|
73
|
+
expandContext: (input) => this.invoke('documents.expandContext', { ...input }),
|
|
74
|
+
readToc: (input) => this.invoke('documents.readToc', { ...input }),
|
|
75
|
+
readMedia: (input) => this.invoke('documents.readMedia', { ...input }),
|
|
76
|
+
extract: (input) => this.invoke('documents.extract', { ...input }),
|
|
77
|
+
};
|
|
78
|
+
spreadsheets = {
|
|
79
|
+
query: (input) => this.invoke('spreadsheets.query', { ...input }),
|
|
80
|
+
applyEdits: (input) => this.invoke('spreadsheets.applyEdits', { ...input }),
|
|
81
|
+
};
|
|
82
|
+
notes = {
|
|
83
|
+
read: (input) => this.invoke('notes.read', { ...input }),
|
|
84
|
+
edit: (input) => this.invoke('notes.edit', { ...input }),
|
|
85
|
+
};
|
|
86
|
+
images = {
|
|
87
|
+
create: (input) => this.invoke('images.create', { ...input }),
|
|
88
|
+
};
|
|
89
|
+
workspace = {
|
|
90
|
+
queryDb: (input) => this.invoke('workspace.queryDb', { ...input }),
|
|
91
|
+
};
|
|
92
|
+
chats = {
|
|
93
|
+
search: (input) => this.invoke('chats.search', { ...input }),
|
|
94
|
+
};
|
|
95
|
+
store = {
|
|
96
|
+
put: (value) => this.invoke('store.put', { value }),
|
|
97
|
+
get: (handle) => this.invoke('store.get', { handle }),
|
|
98
|
+
};
|
|
99
|
+
map(items, instruction, options) {
|
|
100
|
+
return this.invoke('map', compact({ items, instruction, ...options }));
|
|
101
|
+
}
|
|
102
|
+
ask(prompt, instruction) {
|
|
103
|
+
return this.invoke('ask', compact({ prompt, instruction }));
|
|
104
|
+
}
|
|
105
|
+
askMany(tasks, instruction) {
|
|
106
|
+
return this.invoke('askMany', compact({ tasks, instruction }));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export function createAnaraClient(options = {}) {
|
|
110
|
+
return new AnaraClient(options);
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAmB,MAAM,WAAW,CAAC;AAoC3E,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AAE7C,SAAS,SAAS;IAChB,MAAM,GAAG,GACP,UACD,CAAC,OAAO,EAAE,GAAG,CAAC;IACf,OAAO,GAAG,EAAE,aAAa,CAAC;AAC5B,CAAC;AAED,SAAS,OAAO,CAAoC,IAAO;IACzD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;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AC;CACF;AAED,MAAM,UAAU,iBAAiB,CAC/B,OAAO,GAAuB,EAAE;IAEhC,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type AnaraErrorCode = 'bad_request' | 'unauthorized' | 'forbidden' | 'not_found' | 'rate_limited' | 'server_error' | 'unknown';
|
|
2
|
+
export declare class AnaraError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class AnaraApiError extends AnaraError {
|
|
6
|
+
readonly status: number;
|
|
7
|
+
/** The server's semantic code when present (e.g. `approval_required`,
|
|
8
|
+
* `guardrail`), otherwise derived from the HTTP status. */
|
|
9
|
+
readonly code: AnaraErrorCode | (string & {});
|
|
10
|
+
readonly details?: unknown;
|
|
11
|
+
constructor(status: number, message: string, details?: unknown, code?: string);
|
|
12
|
+
}
|
|
13
|
+
export declare function isAnaraError(value: unknown): value is AnaraError;
|
|
14
|
+
export declare function isAnaraApiError(value: unknown): value is AnaraApiError;
|
|
15
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GACtB,aAAa,GACb,cAAc,GACd,WAAW,GACX,WAAW,GACX,cAAc,GACd,cAAc,GACd,SAAS,CAAC;AAEd,qBAAa,UAAW,SAAQ,KAAK;IACnC,YAAY,OAAO,EAAE,MAAM,EAM1B;CACF;AAYD,qBAAa,aAAc,SAAQ,UAAU;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;+DAC2D;IAC3D,QAAQ,CAAC,IAAI,EAAE,cAAc,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAC9C,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAE3B,YACE,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,OAAO,EACjB,IAAI,CAAC,EAAE,MAAM,EAOd;CACF;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAEhE;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAEtE"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export class AnaraError extends Error {
|
|
2
|
+
constructor(message) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = 'AnaraError';
|
|
5
|
+
// Keep `instanceof` working when the class is downleveled or crosses a
|
|
6
|
+
// bundler/module boundary.
|
|
7
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function codeForStatus(status) {
|
|
11
|
+
if (status === 400 || status === 422)
|
|
12
|
+
return 'bad_request';
|
|
13
|
+
if (status === 401)
|
|
14
|
+
return 'unauthorized';
|
|
15
|
+
if (status === 403)
|
|
16
|
+
return 'forbidden';
|
|
17
|
+
if (status === 404)
|
|
18
|
+
return 'not_found';
|
|
19
|
+
if (status === 429)
|
|
20
|
+
return 'rate_limited';
|
|
21
|
+
if (status >= 500)
|
|
22
|
+
return 'server_error';
|
|
23
|
+
return 'unknown';
|
|
24
|
+
}
|
|
25
|
+
export class AnaraApiError extends AnaraError {
|
|
26
|
+
status;
|
|
27
|
+
/** The server's semantic code when present (e.g. `approval_required`,
|
|
28
|
+
* `guardrail`), otherwise derived from the HTTP status. */
|
|
29
|
+
code;
|
|
30
|
+
details;
|
|
31
|
+
constructor(status, message, details, code) {
|
|
32
|
+
super(message);
|
|
33
|
+
this.name = 'AnaraApiError';
|
|
34
|
+
this.status = status;
|
|
35
|
+
this.code = code ?? codeForStatus(status);
|
|
36
|
+
this.details = details;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export function isAnaraError(value) {
|
|
40
|
+
return value instanceof AnaraError;
|
|
41
|
+
}
|
|
42
|
+
export function isAnaraApiError(value) {
|
|
43
|
+
return value instanceof AnaraApiError;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AASA,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,uEAAuE;QACvE,2BAA2B;QAC3B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AAED,SAAS,aAAa,CAAC,MAAc;IACnC,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,aAAa,CAAC;IAC3D,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,cAAc,CAAC;IAC1C,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,WAAW,CAAC;IACvC,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,WAAW,CAAC;IACvC,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,cAAc,CAAC;IAC1C,IAAI,MAAM,IAAI,GAAG;QAAE,OAAO,cAAc,CAAC;IACzC,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,OAAO,aAAc,SAAQ,UAAU;IAClC,MAAM,CAAS;IACxB;+DAC2D;IAClD,IAAI,CAAiC;IACrC,OAAO,CAAW;IAE3B,YACE,MAAc,EACd,OAAe,EACf,OAAiB,EACjB,IAAa;QAEb,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;QAC1C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAED,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,KAAK,YAAY,UAAU,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,KAAK,YAAY,aAAa,CAAC;AACxC,CAAC"}
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AnaraApiError } from './errors.js';
|
|
2
|
+
export interface HttpConfig {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
apiKey: string;
|
|
5
|
+
fetch: typeof fetch;
|
|
6
|
+
headers: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
export type QueryParams = Record<string, string | number | undefined>;
|
|
9
|
+
export declare function normalizeBaseUrl(baseUrl: string): string;
|
|
10
|
+
export declare function buildUrl(baseUrl: string, path: string, query?: QueryParams): string;
|
|
11
|
+
export declare function errorFromResponse(response: Response): Promise<AnaraApiError>;
|
|
12
|
+
export interface RequestOptions {
|
|
13
|
+
query?: QueryParams;
|
|
14
|
+
body?: unknown;
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
}
|
|
17
|
+
export declare function requestHeaders(config: HttpConfig, extra?: Record<string, string>): Record<string, string>;
|
|
18
|
+
export declare function httpRequest<T>(config: HttpConfig, method: string, path: string, options?: RequestOptions): Promise<T>;
|
|
19
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;AAEtE,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAgB,QAAQ,CACtB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,WAAW,GAClB,MAAM,CAQR;AAiCD,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,aAAa,CAAC,CAUxB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,UAAU,EAClB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CASxB;AAED,wBAAsB,WAAW,CAAC,CAAC,EACjC,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,CAAC,CAAC,CAeZ"}
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { AnaraApiError } from './errors.js';
|
|
2
|
+
export function normalizeBaseUrl(baseUrl) {
|
|
3
|
+
return baseUrl.replace(/\/+$/, '');
|
|
4
|
+
}
|
|
5
|
+
export function buildUrl(baseUrl, path, query) {
|
|
6
|
+
const url = new URL(`${baseUrl}${path}`);
|
|
7
|
+
if (query) {
|
|
8
|
+
for (const [key, value] of Object.entries(query)) {
|
|
9
|
+
if (value !== undefined)
|
|
10
|
+
url.searchParams.set(key, String(value));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return url.toString();
|
|
14
|
+
}
|
|
15
|
+
function isRecord(value) {
|
|
16
|
+
return typeof value === 'object' && value !== null;
|
|
17
|
+
}
|
|
18
|
+
async function parseResponse(response) {
|
|
19
|
+
const raw = await response.text();
|
|
20
|
+
let data;
|
|
21
|
+
if (raw) {
|
|
22
|
+
try {
|
|
23
|
+
data = JSON.parse(raw);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
data = raw;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (!response.ok) {
|
|
30
|
+
const message = isRecord(data) && typeof data.error === 'string'
|
|
31
|
+
? data.error
|
|
32
|
+
: `Anara API request failed (${response.status})`;
|
|
33
|
+
const details = isRecord(data) ? data.details : data;
|
|
34
|
+
// Prefer the server's semantic code (approval_required, guardrail, …) over
|
|
35
|
+
// the status-derived fallback.
|
|
36
|
+
const code = isRecord(data) && typeof data.code === 'string' ? data.code : undefined;
|
|
37
|
+
throw new AnaraApiError(response.status, message, details, code);
|
|
38
|
+
}
|
|
39
|
+
return data;
|
|
40
|
+
}
|
|
41
|
+
export async function errorFromResponse(response) {
|
|
42
|
+
try {
|
|
43
|
+
await parseResponse(response);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (error instanceof AnaraApiError)
|
|
47
|
+
return error;
|
|
48
|
+
}
|
|
49
|
+
return new AnaraApiError(response.status, `Anara API request failed (${response.status})`);
|
|
50
|
+
}
|
|
51
|
+
export function requestHeaders(config, extra) {
|
|
52
|
+
// Caller headers first, then the SDK-managed ones — so a stray `x-api-key` in
|
|
53
|
+
// `config.headers` can never override the configured key.
|
|
54
|
+
return {
|
|
55
|
+
accept: 'application/json',
|
|
56
|
+
...config.headers,
|
|
57
|
+
...extra,
|
|
58
|
+
'x-api-key': config.apiKey,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export async function httpRequest(config, method, path, options = {}) {
|
|
62
|
+
const headers = requestHeaders(config);
|
|
63
|
+
let body;
|
|
64
|
+
if (options.body !== undefined) {
|
|
65
|
+
headers['content-type'] = 'application/json';
|
|
66
|
+
body = JSON.stringify(options.body);
|
|
67
|
+
}
|
|
68
|
+
const response = await config.fetch(buildUrl(config.baseUrl, path, options.query),
|
|
69
|
+
// `redirect: 'error'` so a cross-origin redirect can never re-send the
|
|
70
|
+
// x-api-key header to another host — it fails loudly instead.
|
|
71
|
+
{ method, headers, body, signal: options.signal, redirect: 'error' });
|
|
72
|
+
return parseResponse(response);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAW5C,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,QAAQ,CACtB,OAAe,EACf,IAAY,EACZ,KAAmB;IAEnB,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,OAAO,GAAG,IAAI,EAAE,CAAC,CAAC;IACzC,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACjD,IAAI,KAAK,KAAK,SAAS;gBAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAA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AAC;IACD,OAAO,IAAI,aAAa,CACtB,QAAQ,CAAC,MAAM,EACf,6BAA6B,QAAQ,CAAC,MAAM,GAAG,CAChD,CAAC;AACJ,CAAC;AAQD,MAAM,UAAU,cAAc,CAC5B,MAAkB,EAClB,KAA8B;IAE9B,8EAA8E;IAC9E,0DAA0D;IAC1D,OAAO;QACL,MAAM,EAAE,kBAAkB;QAC1B,GAAG,MAAM,CAAC,OAAO;QACjB,GAAG,KAAK;QACR,WAAW,EAAE,MAAM,CAAC,MAAM;KAC3B,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAkB,EAClB,MAAc,EACd,IAAY,EACZ,OAAO,GAAmB,EAAE;IAE5B,MAAM,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IACvC,IAAI,IAAwB,CAAC;IAC7B,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,CAAC,cAAc,CAAC,GAAG,kBAAkB,CAAC;QAC7C,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CACjC,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC;IAC7C,uEAAuE;IACvE,8DAA8D;IAC9D,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CACrE,CAAC;IACF,OAAO,aAAa,CAAI,QAAQ,CAAC,CAAC;AACpC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { AnaraClient, createAnaraClient } from './client.js';
|
|
2
|
+
export { AnaraError, AnaraApiError, isAnaraError, isAnaraApiError, type AnaraErrorCode, } from './errors.js';
|
|
3
|
+
export { ANARA_AGENT_GUIDE } from './agent-guide.js';
|
|
4
|
+
export { ANARA_METHODS, WRITE_METHODS, isAnaraMethod, entityEnvelope, type AnaraMethodName, type MethodSpec, } from './schemas.js';
|
|
5
|
+
export { buildOpenApiDocument, type OpenApiOptions } from './openapi.js';
|
|
6
|
+
export type { AnaraClientOptions, AnaraUser, AnaraMe, EntityEnvelope, EntityQuery, GetEntityOptions, CreateEntityInput, UpdateEntityPatch, DeleteEntitiesOptions, DeleteEntitiesResult, SearchInput, SearchHit, Passage, DocumentPages, ResearchInput, ResearchResult, RetrievalInput, RerankInput, StorePutResult, MapOptions, MapResult, AskTask, ExpandContextInput, ReadTocInput, ReadMediaInput, ExtractInput, SpreadsheetQueryInput, SpreadsheetApplyEditsInput, NoteReadInput, NoteEditInput, ImageCreateInput, WorkspaceQueryInput, ChatsSearchInput, } from './types.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EACL,UAAU,EACV,aAAa,EACb,YAAY,EACZ,eAAe,EACf,KAAK,cAAc,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EACL,aAAa,EACb,aAAa,EACb,aAAa,EACb,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,UAAU,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,oBAAoB,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AACzE,YAAY,EACV,kBAAkB,EAClB,SAAS,EACT,OAAO,EACP,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,EACX,SAAS,EACT,OAAO,EACP,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,WAAW,EACX,cAAc,EACd,UAAU,EACV,SAAS,EACT,OAAO,EACP,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,qBAAqB,EACrB,0BAA0B,EAC1B,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { AnaraClient, createAnaraClient } from './client.js';
|
|
2
|
+
export { AnaraError, AnaraApiError, isAnaraError, isAnaraApiError, } from './errors.js';
|
|
3
|
+
export { ANARA_AGENT_GUIDE } from './agent-guide.js';
|
|
4
|
+
export { ANARA_METHODS, WRITE_METHODS, isAnaraMethod, entityEnvelope, } from './schemas.js';
|
|
5
|
+
export { buildOpenApiDocument } from './openapi.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EACL,UAAU,EACV,aAAa,EACb,YAAY,EACZ,eAAe,GAEhB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EACL,aAAa,EACb,aAAa,EACb,aAAa,EACb,cAAc,GAGf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,oBAAoB,EAAuB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface OpenApiOptions {
|
|
2
|
+
title?: string;
|
|
3
|
+
version?: string;
|
|
4
|
+
/** Base server URL, e.g. `https://anara.com`. */
|
|
5
|
+
serverUrl?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Generates the OpenAPI 3.1 document for the anara.* surface straight from the
|
|
9
|
+
* zod method registry, so the spec is always in sync with the schemas the
|
|
10
|
+
* server validates with and the client is typed from. Each method is one POST
|
|
11
|
+
* operation at `/api/v1/sdk/{method}`; the request body is the method's
|
|
12
|
+
* positional args, the response is its return value.
|
|
13
|
+
*/
|
|
14
|
+
export declare function buildOpenApiDocument(options?: OpenApiOptions): {
|
|
15
|
+
openapi: string;
|
|
16
|
+
info: {
|
|
17
|
+
title: string;
|
|
18
|
+
version: string;
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
servers?: {
|
|
22
|
+
url: string;
|
|
23
|
+
}[] | undefined;
|
|
24
|
+
components: {
|
|
25
|
+
securitySchemes: {
|
|
26
|
+
ApiKeyAuth: {
|
|
27
|
+
type: string;
|
|
28
|
+
in: string;
|
|
29
|
+
name: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
security: {
|
|
34
|
+
ApiKeyAuth: never[];
|
|
35
|
+
}[];
|
|
36
|
+
paths: Record<string, unknown>;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=openapi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../src/openapi.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAMD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,cAAmB;;;QAwC3D,KAAK;QACL,OAAO;QACP,WAAW;;;;;;QAKX,eAAe;YACb,UAAU;gBAAI,IAAI;gBAAY,EAAE;gBAAY,IAAI;;;;;;;;EAMvD"}
|