@xeroml/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/README.md +30 -0
- package/dist/client.d.ts +31 -0
- package/dist/client.js +96 -0
- package/dist/errors.d.ts +48 -0
- package/dist/errors.js +96 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/session.d.ts +28 -0
- package/dist/session.js +48 -0
- package/dist/types.d.ts +100 -0
- package/dist/types.js +2 -0
- package/package.json +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# @xeroml/sdk
|
|
2
|
+
|
|
3
|
+
Official TypeScript SDK for the XeroML API.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @xeroml/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { XeroML } from "@xeroml/sdk";
|
|
15
|
+
|
|
16
|
+
const client = new XeroML({ apiKey: "xml_..." });
|
|
17
|
+
|
|
18
|
+
const result = await client.classify({
|
|
19
|
+
text: "I want to cancel my subscription",
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Development
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pnpm install
|
|
27
|
+
pnpm build # compile
|
|
28
|
+
pnpm typecheck # type check
|
|
29
|
+
pnpm test # run tests
|
|
30
|
+
```
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Session } from "./session";
|
|
2
|
+
import type { IntentGraph, ParseOptions, SessionListItem, UsageInfo, XeroMLConfig } from "./types";
|
|
3
|
+
export declare class XeroML {
|
|
4
|
+
private readonly baseURL;
|
|
5
|
+
private readonly apiKey;
|
|
6
|
+
private readonly timeout;
|
|
7
|
+
constructor(config: XeroMLConfig);
|
|
8
|
+
/**
|
|
9
|
+
* One-shot parse — no session. Costs 1 credit.
|
|
10
|
+
*/
|
|
11
|
+
parse(message: string, options?: ParseOptions): Promise<IntentGraph>;
|
|
12
|
+
/**
|
|
13
|
+
* Create a new multi-turn session. Free.
|
|
14
|
+
*/
|
|
15
|
+
createSession(options?: {
|
|
16
|
+
sessionId?: string;
|
|
17
|
+
}): Promise<Session>;
|
|
18
|
+
/**
|
|
19
|
+
* List all sessions for the authenticated API key.
|
|
20
|
+
*/
|
|
21
|
+
listSessions(limit?: number): Promise<SessionListItem[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Get credit balance and usage stats. Free.
|
|
24
|
+
*/
|
|
25
|
+
getUsage(): Promise<UsageInfo>;
|
|
26
|
+
/**
|
|
27
|
+
* Internal HTTP helper. Exposed for Session to call.
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
request<T>(method: string, path: string, body: Record<string, unknown> | null): Promise<T>;
|
|
31
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// @xeroml/sdk — XeroML client class
|
|
2
|
+
import { mapError } from "./errors";
|
|
3
|
+
import { Session } from "./session";
|
|
4
|
+
const DEFAULT_BASE_URL = "https://api.xeroml.com";
|
|
5
|
+
const DEFAULT_TIMEOUT = 30_000;
|
|
6
|
+
export class XeroML {
|
|
7
|
+
baseURL;
|
|
8
|
+
apiKey;
|
|
9
|
+
timeout;
|
|
10
|
+
constructor(config) {
|
|
11
|
+
if (!config.apiKey) {
|
|
12
|
+
throw new Error("XeroML: apiKey is required.");
|
|
13
|
+
}
|
|
14
|
+
this.apiKey = config.apiKey;
|
|
15
|
+
this.baseURL = (config.baseURL ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
16
|
+
this.timeout = config.timeout ?? DEFAULT_TIMEOUT;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* One-shot parse — no session. Costs 1 credit.
|
|
20
|
+
*/
|
|
21
|
+
async parse(message, options) {
|
|
22
|
+
const body = { message };
|
|
23
|
+
if (options?.provider)
|
|
24
|
+
body.provider = options.provider;
|
|
25
|
+
const res = await this.request("POST", "/v1/parse", body);
|
|
26
|
+
return res.graph;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Create a new multi-turn session. Free.
|
|
30
|
+
*/
|
|
31
|
+
async createSession(options) {
|
|
32
|
+
const body = {};
|
|
33
|
+
if (options?.sessionId)
|
|
34
|
+
body.session_id = options.sessionId;
|
|
35
|
+
const res = await this.request("POST", "/v1/sessions", body);
|
|
36
|
+
return new Session(this, res.session_id);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* List all sessions for the authenticated API key.
|
|
40
|
+
*/
|
|
41
|
+
async listSessions(limit) {
|
|
42
|
+
const query = limit ? `?limit=${limit}` : "";
|
|
43
|
+
const res = await this.request("GET", `/v1/sessions${query}`, null);
|
|
44
|
+
return res.sessions;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get credit balance and usage stats. Free.
|
|
48
|
+
*/
|
|
49
|
+
async getUsage() {
|
|
50
|
+
return this.request("GET", "/v1/usage", null);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Internal HTTP helper. Exposed for Session to call.
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
async request(method, path, body) {
|
|
57
|
+
const url = `${this.baseURL}${path}`;
|
|
58
|
+
const headers = {
|
|
59
|
+
"X-API-Key": this.apiKey,
|
|
60
|
+
};
|
|
61
|
+
if (body !== null) {
|
|
62
|
+
headers["Content-Type"] = "application/json";
|
|
63
|
+
}
|
|
64
|
+
const controller = new AbortController();
|
|
65
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
66
|
+
try {
|
|
67
|
+
const res = await fetch(url, {
|
|
68
|
+
method,
|
|
69
|
+
headers,
|
|
70
|
+
body: body !== null ? JSON.stringify(body) : undefined,
|
|
71
|
+
signal: controller.signal,
|
|
72
|
+
});
|
|
73
|
+
if (!res.ok) {
|
|
74
|
+
let errorBody;
|
|
75
|
+
try {
|
|
76
|
+
errorBody = await res.json();
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
errorBody = { error: { message: res.statusText } };
|
|
80
|
+
}
|
|
81
|
+
const retryAfter = res.headers.get("Retry-After");
|
|
82
|
+
throw mapError(res.status, errorBody, retryAfter ? parseInt(retryAfter, 10) : undefined);
|
|
83
|
+
}
|
|
84
|
+
return (await res.json());
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
88
|
+
throw mapError(504, { error: { code: "timeout", message: "Request timed out." } });
|
|
89
|
+
}
|
|
90
|
+
throw err;
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
clearTimeout(timer);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface ErrorBody {
|
|
2
|
+
error?: {
|
|
3
|
+
code?: string;
|
|
4
|
+
message?: string;
|
|
5
|
+
status?: number;
|
|
6
|
+
request_id?: string;
|
|
7
|
+
details?: Record<string, unknown>;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare class XeroMLError extends Error {
|
|
11
|
+
code: string;
|
|
12
|
+
status: number;
|
|
13
|
+
requestId: string;
|
|
14
|
+
details?: Record<string, unknown>;
|
|
15
|
+
constructor(status: number, code: string, message: string, requestId?: string, details?: Record<string, unknown>);
|
|
16
|
+
}
|
|
17
|
+
export declare class XeroMLAuthError extends XeroMLError {
|
|
18
|
+
constructor(body: ErrorBody);
|
|
19
|
+
}
|
|
20
|
+
export declare class XeroMLCreditError extends XeroMLError {
|
|
21
|
+
constructor(body: ErrorBody);
|
|
22
|
+
}
|
|
23
|
+
export declare class XeroMLRateLimitError extends XeroMLError {
|
|
24
|
+
retryAfter: number;
|
|
25
|
+
constructor(body: ErrorBody, retryAfter?: number);
|
|
26
|
+
}
|
|
27
|
+
export declare class XeroMLValidationError extends XeroMLError {
|
|
28
|
+
constructor(body: ErrorBody);
|
|
29
|
+
}
|
|
30
|
+
export declare class XeroMLParseError extends XeroMLError {
|
|
31
|
+
constructor(body: ErrorBody);
|
|
32
|
+
}
|
|
33
|
+
export declare class XeroMLNotFoundError extends XeroMLError {
|
|
34
|
+
constructor(body: ErrorBody);
|
|
35
|
+
}
|
|
36
|
+
export declare class XeroMLSessionEndedError extends XeroMLError {
|
|
37
|
+
constructor(body: ErrorBody);
|
|
38
|
+
}
|
|
39
|
+
export declare class XeroMLTimeoutError extends XeroMLError {
|
|
40
|
+
constructor(body: ErrorBody);
|
|
41
|
+
}
|
|
42
|
+
export declare class XeroMLServerError extends XeroMLError {
|
|
43
|
+
constructor(body: ErrorBody);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Maps an HTTP error response to a typed XeroMLError.
|
|
47
|
+
*/
|
|
48
|
+
export declare function mapError(status: number, body: ErrorBody, retryAfter?: number): XeroMLError;
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// @xeroml/sdk — Error classes matching API error codes
|
|
2
|
+
export class XeroMLError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
status;
|
|
5
|
+
requestId;
|
|
6
|
+
details;
|
|
7
|
+
constructor(status, code, message, requestId, details) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = "XeroMLError";
|
|
10
|
+
this.status = status;
|
|
11
|
+
this.code = code;
|
|
12
|
+
this.requestId = requestId ?? "";
|
|
13
|
+
this.details = details;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export class XeroMLAuthError extends XeroMLError {
|
|
17
|
+
constructor(body) {
|
|
18
|
+
const err = body.error;
|
|
19
|
+
super(401, err?.code ?? "invalid_api_key", err?.message ?? "Invalid or revoked API key.", err?.request_id, err?.details);
|
|
20
|
+
this.name = "XeroMLAuthError";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export class XeroMLCreditError extends XeroMLError {
|
|
24
|
+
constructor(body) {
|
|
25
|
+
const err = body.error;
|
|
26
|
+
super(402, err?.code ?? "credits_exhausted", err?.message ?? "Credits exhausted.", err?.request_id, err?.details);
|
|
27
|
+
this.name = "XeroMLCreditError";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export class XeroMLRateLimitError extends XeroMLError {
|
|
31
|
+
retryAfter;
|
|
32
|
+
constructor(body, retryAfter) {
|
|
33
|
+
const err = body.error;
|
|
34
|
+
super(429, err?.code ?? "rate_limited", err?.message ?? "Rate limit exceeded.", err?.request_id, err?.details);
|
|
35
|
+
this.name = "XeroMLRateLimitError";
|
|
36
|
+
this.retryAfter = retryAfter ?? 60;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export class XeroMLValidationError extends XeroMLError {
|
|
40
|
+
constructor(body) {
|
|
41
|
+
const err = body.error;
|
|
42
|
+
super(400, err?.code ?? "invalid_input", err?.message ?? "Invalid input.", err?.request_id, err?.details);
|
|
43
|
+
this.name = "XeroMLValidationError";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export class XeroMLParseError extends XeroMLError {
|
|
47
|
+
constructor(body) {
|
|
48
|
+
const err = body.error;
|
|
49
|
+
super(422, err?.code ?? "parse_failed", err?.message ?? "Parse failed.", err?.request_id, err?.details);
|
|
50
|
+
this.name = "XeroMLParseError";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export class XeroMLNotFoundError extends XeroMLError {
|
|
54
|
+
constructor(body) {
|
|
55
|
+
const err = body.error;
|
|
56
|
+
super(404, err?.code ?? "session_not_found", err?.message ?? "Session not found.", err?.request_id, err?.details);
|
|
57
|
+
this.name = "XeroMLNotFoundError";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export class XeroMLSessionEndedError extends XeroMLError {
|
|
61
|
+
constructor(body) {
|
|
62
|
+
const err = body.error;
|
|
63
|
+
super(409, err?.code ?? "session_ended", err?.message ?? "Session already ended.", err?.request_id, err?.details);
|
|
64
|
+
this.name = "XeroMLSessionEndedError";
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export class XeroMLTimeoutError extends XeroMLError {
|
|
68
|
+
constructor(body) {
|
|
69
|
+
const err = body.error;
|
|
70
|
+
super(504, err?.code ?? "timeout", err?.message ?? "Request timed out.", err?.request_id, err?.details);
|
|
71
|
+
this.name = "XeroMLTimeoutError";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export class XeroMLServerError extends XeroMLError {
|
|
75
|
+
constructor(body) {
|
|
76
|
+
const err = body.error;
|
|
77
|
+
super(err?.status ?? 500, err?.code ?? "internal_error", err?.message ?? "Internal server error.", err?.request_id, err?.details);
|
|
78
|
+
this.name = "XeroMLServerError";
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Maps an HTTP error response to a typed XeroMLError.
|
|
83
|
+
*/
|
|
84
|
+
export function mapError(status, body, retryAfter) {
|
|
85
|
+
switch (status) {
|
|
86
|
+
case 401: return new XeroMLAuthError(body);
|
|
87
|
+
case 402: return new XeroMLCreditError(body);
|
|
88
|
+
case 429: return new XeroMLRateLimitError(body, retryAfter);
|
|
89
|
+
case 400: return new XeroMLValidationError(body);
|
|
90
|
+
case 422: return new XeroMLParseError(body);
|
|
91
|
+
case 404: return new XeroMLNotFoundError(body);
|
|
92
|
+
case 409: return new XeroMLSessionEndedError(body);
|
|
93
|
+
case 504: return new XeroMLTimeoutError(body);
|
|
94
|
+
default: return new XeroMLServerError(body);
|
|
95
|
+
}
|
|
96
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { XeroML } from "./client";
|
|
2
|
+
export { Session } from "./session";
|
|
3
|
+
export type { IntentGraph, SubGoal, IntentMeta, LatentStates, DriftReport, ParseResponse, SessionParseResponse, SessionInfo, SessionListItem, SessionGraphResponse, UsageInfo, UsageMonth, XeroMLConfig, ParseOptions, UpdateOptions, } from "./types";
|
|
4
|
+
export { XeroMLError, XeroMLAuthError, XeroMLCreditError, XeroMLRateLimitError, XeroMLValidationError, XeroMLParseError, XeroMLNotFoundError, XeroMLSessionEndedError, XeroMLTimeoutError, XeroMLServerError, mapError, } from "./errors";
|
|
5
|
+
export type { ErrorBody } from "./errors";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @xeroml/sdk — entry point
|
|
2
|
+
export { XeroML } from "./client";
|
|
3
|
+
export { Session } from "./session";
|
|
4
|
+
// Errors
|
|
5
|
+
export { XeroMLError, XeroMLAuthError, XeroMLCreditError, XeroMLRateLimitError, XeroMLValidationError, XeroMLParseError, XeroMLNotFoundError, XeroMLSessionEndedError, XeroMLTimeoutError, XeroMLServerError, mapError, } from "./errors";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { XeroML } from "./client";
|
|
2
|
+
import type { DriftReport, IntentGraph, ParseOptions, UpdateOptions } from "./types";
|
|
3
|
+
export declare class Session {
|
|
4
|
+
private client;
|
|
5
|
+
readonly sessionId: string;
|
|
6
|
+
/** @internal — use `xeroml.createSession()` instead. */
|
|
7
|
+
constructor(client: XeroML, sessionId: string);
|
|
8
|
+
/**
|
|
9
|
+
* Parse a user message within this session. Costs 1 credit.
|
|
10
|
+
*/
|
|
11
|
+
parse(message: string, options?: ParseOptions): Promise<IntentGraph>;
|
|
12
|
+
/**
|
|
13
|
+
* Feed an LLM response back into the session for drift tracking. Free.
|
|
14
|
+
*/
|
|
15
|
+
update(message: string, options?: UpdateOptions): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Check if intent drift has occurred. Free.
|
|
18
|
+
*/
|
|
19
|
+
checkDrift(): Promise<DriftReport>;
|
|
20
|
+
/**
|
|
21
|
+
* Get the current IntentGraph snapshot. Free.
|
|
22
|
+
*/
|
|
23
|
+
getGraph(): Promise<IntentGraph | null>;
|
|
24
|
+
/**
|
|
25
|
+
* End this session. Free.
|
|
26
|
+
*/
|
|
27
|
+
end(): Promise<void>;
|
|
28
|
+
}
|
package/dist/session.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// @xeroml/sdk — Session class for multi-turn conversations
|
|
2
|
+
export class Session {
|
|
3
|
+
client;
|
|
4
|
+
sessionId;
|
|
5
|
+
/** @internal — use `xeroml.createSession()` instead. */
|
|
6
|
+
constructor(client, sessionId) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
this.sessionId = sessionId;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Parse a user message within this session. Costs 1 credit.
|
|
12
|
+
*/
|
|
13
|
+
async parse(message, options) {
|
|
14
|
+
const body = { message };
|
|
15
|
+
if (options?.provider)
|
|
16
|
+
body.provider = options.provider;
|
|
17
|
+
const res = await this.client.request("POST", `/v1/sessions/${this.sessionId}/parse`, body);
|
|
18
|
+
return res.graph;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Feed an LLM response back into the session for drift tracking. Free.
|
|
22
|
+
*/
|
|
23
|
+
async update(message, options) {
|
|
24
|
+
const body = { message };
|
|
25
|
+
if (options?.role)
|
|
26
|
+
body.role = options.role;
|
|
27
|
+
await this.client.request("POST", `/v1/sessions/${this.sessionId}/update`, body);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Check if intent drift has occurred. Free.
|
|
31
|
+
*/
|
|
32
|
+
async checkDrift() {
|
|
33
|
+
return this.client.request("GET", `/v1/sessions/${this.sessionId}/drift`, null);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get the current IntentGraph snapshot. Free.
|
|
37
|
+
*/
|
|
38
|
+
async getGraph() {
|
|
39
|
+
const res = await this.client.request("GET", `/v1/sessions/${this.sessionId}/graph`, null);
|
|
40
|
+
return res.graph;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* End this session. Free.
|
|
44
|
+
*/
|
|
45
|
+
async end() {
|
|
46
|
+
await this.client.request("POST", `/v1/sessions/${this.sessionId}/end`, {});
|
|
47
|
+
}
|
|
48
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export interface LatentStates {
|
|
2
|
+
goal_intent: string;
|
|
3
|
+
action_readiness: "exploring" | "deciding" | "executing";
|
|
4
|
+
ambiguity_level: "clear" | "partial" | "conflicting";
|
|
5
|
+
risk_sensitivity: "low" | "medium" | "high";
|
|
6
|
+
intent_scope: "single" | "compound" | "multi_step";
|
|
7
|
+
}
|
|
8
|
+
export interface IntentMeta {
|
|
9
|
+
source: string;
|
|
10
|
+
confidence: number;
|
|
11
|
+
negotiation_history: string[];
|
|
12
|
+
latent_states: LatentStates;
|
|
13
|
+
}
|
|
14
|
+
export interface SubGoal {
|
|
15
|
+
id: string;
|
|
16
|
+
goal: string;
|
|
17
|
+
status: "pending" | "active" | "done" | "blocked" | "abandoned" | "background";
|
|
18
|
+
priority: number;
|
|
19
|
+
success_criteria: string[];
|
|
20
|
+
constraints: string[];
|
|
21
|
+
uncertainty: number;
|
|
22
|
+
context_requirements: string[];
|
|
23
|
+
modality: string;
|
|
24
|
+
dependencies: string[];
|
|
25
|
+
children: SubGoal[];
|
|
26
|
+
}
|
|
27
|
+
export interface IntentGraph {
|
|
28
|
+
schema_version: string;
|
|
29
|
+
root_goal: string;
|
|
30
|
+
sub_goals: SubGoal[];
|
|
31
|
+
meta: IntentMeta;
|
|
32
|
+
}
|
|
33
|
+
export interface DriftReport {
|
|
34
|
+
detected: boolean;
|
|
35
|
+
drift_type: string | null;
|
|
36
|
+
severity: number;
|
|
37
|
+
description: string;
|
|
38
|
+
previous_goal: string | null;
|
|
39
|
+
current_goal: string | null;
|
|
40
|
+
}
|
|
41
|
+
export interface ParseResponse {
|
|
42
|
+
graph: IntentGraph;
|
|
43
|
+
session_id?: string | null;
|
|
44
|
+
request_id: string;
|
|
45
|
+
latency_ms: number;
|
|
46
|
+
}
|
|
47
|
+
export interface SessionParseResponse {
|
|
48
|
+
graph: IntentGraph;
|
|
49
|
+
session_id: string;
|
|
50
|
+
turn_number: number;
|
|
51
|
+
request_id: string;
|
|
52
|
+
latency_ms: number;
|
|
53
|
+
}
|
|
54
|
+
export interface SessionInfo {
|
|
55
|
+
session_id: string;
|
|
56
|
+
status: string;
|
|
57
|
+
created_at: string;
|
|
58
|
+
}
|
|
59
|
+
export interface SessionListItem {
|
|
60
|
+
session_id: string;
|
|
61
|
+
status: string;
|
|
62
|
+
turn_count: number;
|
|
63
|
+
created_at: string;
|
|
64
|
+
updated_at: string;
|
|
65
|
+
}
|
|
66
|
+
export interface SessionListResponse {
|
|
67
|
+
sessions: SessionListItem[];
|
|
68
|
+
}
|
|
69
|
+
export interface SessionGraphResponse {
|
|
70
|
+
graph: IntentGraph | null;
|
|
71
|
+
session_id: string;
|
|
72
|
+
turn_count: number;
|
|
73
|
+
}
|
|
74
|
+
export interface UsageMonth {
|
|
75
|
+
month: string;
|
|
76
|
+
parse_calls: number;
|
|
77
|
+
drift_checks: number;
|
|
78
|
+
session_creates: number;
|
|
79
|
+
}
|
|
80
|
+
export interface UsageInfo {
|
|
81
|
+
credits: {
|
|
82
|
+
used: number;
|
|
83
|
+
total: number;
|
|
84
|
+
remaining: number;
|
|
85
|
+
};
|
|
86
|
+
tier: string;
|
|
87
|
+
rate_limit: number;
|
|
88
|
+
usage: UsageMonth[];
|
|
89
|
+
}
|
|
90
|
+
export interface XeroMLConfig {
|
|
91
|
+
apiKey: string;
|
|
92
|
+
baseURL?: string;
|
|
93
|
+
timeout?: number;
|
|
94
|
+
}
|
|
95
|
+
export interface ParseOptions {
|
|
96
|
+
provider?: string;
|
|
97
|
+
}
|
|
98
|
+
export interface UpdateOptions {
|
|
99
|
+
role?: string;
|
|
100
|
+
}
|
package/dist/types.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xeroml/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "XeroML TypeScript SDK — intent parsing and drift detection for AI apps",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": ["dist"],
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"lint": "echo 'no lint configured yet'",
|
|
11
|
+
"typecheck": "tsc --noEmit",
|
|
12
|
+
"test": "vitest run"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=18.0.0"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "^20.0.0",
|
|
19
|
+
"typescript": "^5.4.0",
|
|
20
|
+
"vitest": "^3.0.0"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/Intensee/xeroml-sdk-typescript"
|
|
26
|
+
}
|
|
27
|
+
}
|