@ilana-ai/sdk 0.0.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/dist/client.d.ts +36 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +128 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +67 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +39 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ilana SDK Client
|
|
3
|
+
* Framework-agnostic client for the Ilana Runtime API
|
|
4
|
+
*/
|
|
5
|
+
import type { IlanaClientConfig, QueryInput, QueryResult, IlanaError, IlanaErrorCode } from './types.js';
|
|
6
|
+
export declare class IlanaClient {
|
|
7
|
+
private config;
|
|
8
|
+
constructor(config: IlanaClientConfig);
|
|
9
|
+
/**
|
|
10
|
+
* Send a query and receive a governed response
|
|
11
|
+
*/
|
|
12
|
+
query(queryInput: QueryInput): Promise<QueryResult>;
|
|
13
|
+
/**
|
|
14
|
+
* Internal request helper
|
|
15
|
+
*/
|
|
16
|
+
private request;
|
|
17
|
+
/**
|
|
18
|
+
* Parse API error response into IlanaError
|
|
19
|
+
*/
|
|
20
|
+
private parseError;
|
|
21
|
+
/**
|
|
22
|
+
* Handle network/fetch errors
|
|
23
|
+
*/
|
|
24
|
+
private handleNetworkError;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Error class for throwOnError mode
|
|
28
|
+
*/
|
|
29
|
+
export declare class IlanaSDKError extends Error {
|
|
30
|
+
readonly code: IlanaErrorCode;
|
|
31
|
+
readonly status?: number;
|
|
32
|
+
readonly requestId?: string;
|
|
33
|
+
readonly raw?: unknown;
|
|
34
|
+
constructor(error: IlanaError);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EAEV,WAAW,EACX,UAAU,EACV,cAAc,EACf,MAAM,YAAY,CAAC;AAgBpB,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CACsC;gBAExC,MAAM,EAAE,iBAAiB;IAgBrC;;OAEG;IACG,KAAK,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC;IAkCzD;;OAEG;YACW,OAAO;IA+BrB;;OAEG;IACH,OAAO,CAAC,UAAU;IAuBlB;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAQ3B;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;gBAEX,KAAK,EAAE,UAAU;CAQ9B"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ilana SDK Client
|
|
3
|
+
* Framework-agnostic client for the Ilana Runtime API
|
|
4
|
+
*/
|
|
5
|
+
export class IlanaClient {
|
|
6
|
+
constructor(config) {
|
|
7
|
+
if (!config.runtimeUrl) {
|
|
8
|
+
throw new Error('IlanaClient: runtimeUrl is required');
|
|
9
|
+
}
|
|
10
|
+
if (!config.token) {
|
|
11
|
+
throw new Error('IlanaClient: token is required');
|
|
12
|
+
}
|
|
13
|
+
this.config = {
|
|
14
|
+
runtimeUrl: config.runtimeUrl.replace(/\/$/, ''), // Remove trailing slash
|
|
15
|
+
token: config.token,
|
|
16
|
+
throwOnError: config.throwOnError ?? false,
|
|
17
|
+
fetch: config.fetch,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Send a query and receive a governed response
|
|
22
|
+
*/
|
|
23
|
+
async query(queryInput) {
|
|
24
|
+
const result = await this.request('/chat', {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
body: {
|
|
27
|
+
botId: queryInput.botId,
|
|
28
|
+
input: queryInput.input,
|
|
29
|
+
conversationId: queryInput.conversationId,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
if (!result.ok) {
|
|
33
|
+
if (this.config.throwOnError) {
|
|
34
|
+
throw new IlanaSDKError(result.error);
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
// API response shape now matches SDK output directly
|
|
39
|
+
const output = {
|
|
40
|
+
conversationId: result.data.conversationId,
|
|
41
|
+
response: result.data.response,
|
|
42
|
+
intentDetected: result.data.intentDetected,
|
|
43
|
+
metadata: {
|
|
44
|
+
capabilityAllowed: result.data.metadata.capabilityAllowed,
|
|
45
|
+
enforcementReason: result.data.metadata.enforcementReason,
|
|
46
|
+
schemaEnforced: result.data.metadata.schemaEnforced,
|
|
47
|
+
schemaFallbackUsed: result.data.metadata.schemaFallbackUsed,
|
|
48
|
+
schemaValidationError: result.data.metadata.schemaValidationError,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
return { ok: true, data: output };
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Internal request helper
|
|
55
|
+
*/
|
|
56
|
+
async request(path, options) {
|
|
57
|
+
const fetchFn = this.config.fetch ?? globalThis.fetch;
|
|
58
|
+
const url = `${this.config.runtimeUrl}${path}`;
|
|
59
|
+
try {
|
|
60
|
+
const response = await fetchFn(url, {
|
|
61
|
+
method: options.method,
|
|
62
|
+
headers: {
|
|
63
|
+
'Content-Type': 'application/json',
|
|
64
|
+
Authorization: `Bearer ${this.config.token}`,
|
|
65
|
+
},
|
|
66
|
+
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
67
|
+
});
|
|
68
|
+
const data = await response.json().catch(() => ({}));
|
|
69
|
+
if (!response.ok) {
|
|
70
|
+
const error = this.parseError(response.status, data);
|
|
71
|
+
return { ok: false, error };
|
|
72
|
+
}
|
|
73
|
+
return { ok: true, data: data };
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
const error = this.handleNetworkError(err);
|
|
77
|
+
return { ok: false, error };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Parse API error response into IlanaError
|
|
82
|
+
*/
|
|
83
|
+
parseError(status, data) {
|
|
84
|
+
const errorData = data;
|
|
85
|
+
const explicitCode = (errorData?.code || errorData?.error);
|
|
86
|
+
const codeMap = {
|
|
87
|
+
400: 'INVALID_REQUEST',
|
|
88
|
+
401: 'UNAUTHORIZED',
|
|
89
|
+
403: 'FORBIDDEN',
|
|
90
|
+
404: 'NOT_FOUND',
|
|
91
|
+
429: 'RATE_LIMITED',
|
|
92
|
+
500: 'INTERNAL_ERROR',
|
|
93
|
+
503: 'SERVICE_UNAVAILABLE',
|
|
94
|
+
};
|
|
95
|
+
return {
|
|
96
|
+
code: explicitCode ?? codeMap[status] ?? 'UNKNOWN_ERROR',
|
|
97
|
+
message: errorData?.error ?? `Request failed with status ${status}`,
|
|
98
|
+
status,
|
|
99
|
+
requestId: errorData?.requestId,
|
|
100
|
+
raw: data,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Handle network/fetch errors
|
|
105
|
+
*/
|
|
106
|
+
handleNetworkError(err) {
|
|
107
|
+
const message = err instanceof Error ? err.message : 'Network request failed';
|
|
108
|
+
return {
|
|
109
|
+
code: 'NETWORK_ERROR',
|
|
110
|
+
message,
|
|
111
|
+
raw: err,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Error class for throwOnError mode
|
|
117
|
+
*/
|
|
118
|
+
export class IlanaSDKError extends Error {
|
|
119
|
+
constructor(error) {
|
|
120
|
+
super(error.message);
|
|
121
|
+
this.name = 'IlanaSDKError';
|
|
122
|
+
this.code = error.code;
|
|
123
|
+
this.status = error.status;
|
|
124
|
+
this.requestId = error.requestId;
|
|
125
|
+
this.raw = error.raw;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAyBH,MAAM,OAAO,WAAW;IAItB,YAAY,MAAyB;QACnC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACpD,CAAC;QAED,IAAI,CAAC,MAAM,GAAG;YACZ,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,wBAAwB;YAC1E,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,KAAK;YAC1C,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK,CAAC,UAAsB;QAChC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAc,OAAO,EAAE;YACtD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,KAAK,EAAE,UAAU,CAAC,KAAK;gBACvB,KAAK,EAAE,UAAU,CAAC,KAAK;gBACvB,cAAc,EAAE,UAAU,CAAC,cAAc;aAC1C;SACF,CAAC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O;YACL,IAAI,EAAE,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,eAAe;YACxD,OAAO,EAAE,SAAS,EAAE,KAAK,IAAI,8BAA8B,MAAM,EAAE;YACnE,MAAM;YACN,SAAS,EAAE,SAAS,EAAE,SAAS;YAC/B,GAAG,EAAE,IAAI;SACV,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,kBAAkB,CAAC,GAAY;QACrC,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC;QAC9E,OAAO;YACL,IAAI,EAAE,eAAe;YACrB,OAAO;YACP,GAAG,EAAE,GAAG;SACT,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAMtC,YAAY,KAAiB;QAC3B,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;IACvB,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ilana SDK
|
|
3
|
+
* Framework-agnostic client for the Ilana Runtime API
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import { IlanaClient } from '@ilana/sdk';
|
|
8
|
+
*
|
|
9
|
+
* const client = new IlanaClient({
|
|
10
|
+
* runtimeUrl: 'https://api.getilana.ai',
|
|
11
|
+
* token: 'your-embed-token',
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* const result = await client.query({
|
|
15
|
+
* botId: 'your-bot-id',
|
|
16
|
+
* input: 'What features do you offer?',
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* if (result.ok) {
|
|
20
|
+
* console.log(result.data.response);
|
|
21
|
+
* console.log(result.data.metadata.capabilityAllowed);
|
|
22
|
+
* } else {
|
|
23
|
+
* console.error(result.error.code, result.error.message);
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export { IlanaClient, IlanaSDKError } from './client.js';
|
|
28
|
+
export type { IlanaClientConfig, QueryInput, QueryOutput, QueryResult, ResponseMetadata, EnforcementReason, IlanaError, IlanaErrorCode, Result, } from './types.js';
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEzD,YAAY,EACV,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,MAAM,GACP,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ilana SDK
|
|
3
|
+
* Framework-agnostic client for the Ilana Runtime API
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import { IlanaClient } from '@ilana/sdk';
|
|
8
|
+
*
|
|
9
|
+
* const client = new IlanaClient({
|
|
10
|
+
* runtimeUrl: 'https://api.getilana.ai',
|
|
11
|
+
* token: 'your-embed-token',
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* const result = await client.query({
|
|
15
|
+
* botId: 'your-bot-id',
|
|
16
|
+
* input: 'What features do you offer?',
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* if (result.ok) {
|
|
20
|
+
* console.log(result.data.response);
|
|
21
|
+
* console.log(result.data.metadata.capabilityAllowed);
|
|
22
|
+
* } else {
|
|
23
|
+
* console.error(result.error.code, result.error.message);
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export { IlanaClient, IlanaSDKError } from './client.js';
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ilana SDK Types
|
|
3
|
+
* Self-contained type definitions for the SDK
|
|
4
|
+
*/
|
|
5
|
+
export interface IlanaClientConfig {
|
|
6
|
+
/** Runtime API URL (e.g., https://api.getilana.ai) */
|
|
7
|
+
runtimeUrl: string;
|
|
8
|
+
/** Embed token for authentication */
|
|
9
|
+
token: string;
|
|
10
|
+
/** Throw errors instead of returning Result (default: false) */
|
|
11
|
+
throwOnError?: boolean;
|
|
12
|
+
/** Custom fetch implementation (for Node.js or testing) */
|
|
13
|
+
fetch?: typeof fetch;
|
|
14
|
+
}
|
|
15
|
+
export interface QueryInput {
|
|
16
|
+
/** Bot ID to query */
|
|
17
|
+
botId: string;
|
|
18
|
+
/** User input (question, search query, command, etc.) */
|
|
19
|
+
input: string;
|
|
20
|
+
/** Optional conversation ID for multi-turn interactions */
|
|
21
|
+
conversationId?: string;
|
|
22
|
+
}
|
|
23
|
+
export type EnforcementReason = 'DENY_LIST' | 'NOT_IN_ALLOW_LIST' | 'no_intent_match' | 'schema_fallback';
|
|
24
|
+
export interface ResponseMetadata {
|
|
25
|
+
/** Whether the detected intent was allowed by capability profile */
|
|
26
|
+
capabilityAllowed: boolean;
|
|
27
|
+
/** Reason for enforcement action, if any */
|
|
28
|
+
enforcementReason?: EnforcementReason;
|
|
29
|
+
/** Whether schema enforcement was applied */
|
|
30
|
+
schemaEnforced: boolean;
|
|
31
|
+
/** Whether fallback response was used due to schema validation failure */
|
|
32
|
+
schemaFallbackUsed: boolean;
|
|
33
|
+
/** Schema validation error message, if any */
|
|
34
|
+
schemaValidationError?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface QueryOutput {
|
|
37
|
+
/** Conversation ID (use for subsequent queries in multi-turn interactions) */
|
|
38
|
+
conversationId: string;
|
|
39
|
+
/** AI response */
|
|
40
|
+
response: string;
|
|
41
|
+
/** Detected intent, if any */
|
|
42
|
+
intentDetected?: string;
|
|
43
|
+
/** Governance and enforcement metadata */
|
|
44
|
+
metadata: ResponseMetadata;
|
|
45
|
+
}
|
|
46
|
+
export type IlanaErrorCode = 'UNAUTHORIZED' | 'FORBIDDEN' | 'NOT_FOUND' | 'RATE_LIMITED' | 'MESSAGE_CAP_EXCEEDED' | 'INVALID_REQUEST' | 'INTERNAL_ERROR' | 'SERVICE_UNAVAILABLE' | 'NETWORK_ERROR' | 'UNKNOWN_ERROR';
|
|
47
|
+
export interface IlanaError {
|
|
48
|
+
/** Error code for programmatic handling */
|
|
49
|
+
code: IlanaErrorCode;
|
|
50
|
+
/** Human-readable error message */
|
|
51
|
+
message: string;
|
|
52
|
+
/** HTTP status code, if applicable */
|
|
53
|
+
status?: number;
|
|
54
|
+
/** Request ID for debugging (from server) */
|
|
55
|
+
requestId?: string;
|
|
56
|
+
/** Raw error details for debugging */
|
|
57
|
+
raw?: unknown;
|
|
58
|
+
}
|
|
59
|
+
export type Result<T> = {
|
|
60
|
+
ok: true;
|
|
61
|
+
data: T;
|
|
62
|
+
} | {
|
|
63
|
+
ok: false;
|
|
64
|
+
error: IlanaError;
|
|
65
|
+
};
|
|
66
|
+
export type QueryResult = Result<QueryOutput>;
|
|
67
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,WAAW,iBAAiB;IAChC,sDAAsD;IACtD,UAAU,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,2DAA2D;IAC3D,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAMD,MAAM,WAAW,UAAU;IACzB,sBAAsB;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,2DAA2D;IAC3D,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,iBAAiB,GACzB,WAAW,GACX,mBAAmB,GACnB,iBAAiB,GACjB,iBAAiB,CAAC;AAEtB,MAAM,WAAW,gBAAgB;IAC/B,oEAAoE;IACpE,iBAAiB,EAAE,OAAO,CAAC;IAC3B,4CAA4C;IAC5C,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,6CAA6C;IAC7C,cAAc,EAAE,OAAO,CAAC;IACxB,0EAA0E;IAC1E,kBAAkB,EAAE,OAAO,CAAC;IAC5B,8CAA8C;IAC9C,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,WAAW;IAC1B,8EAA8E;IAC9E,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AAMD,MAAM,MAAM,cAAc,GACtB,cAAc,GACd,WAAW,GACX,WAAW,GACX,cAAc,GACd,sBAAsB,GACtB,iBAAiB,GACjB,gBAAgB,GAChB,qBAAqB,GACrB,eAAe,GACf,eAAe,CAAC;AAEpB,MAAM,WAAW,UAAU;IACzB,2CAA2C;IAC3C,IAAI,EAAE,cAAc,CAAC;IACrB,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sCAAsC;IACtC,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAMD,MAAM,MAAM,MAAM,CAAC,CAAC,IAChB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GACrB;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,CAAC;AAErC,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ilana-ai/sdk",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Ilana AI SDK - Framework-agnostic client for the Ilana Runtime API",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"check-types": "tsc --noEmit",
|
|
21
|
+
"clean": "rm -rf dist"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"typescript": "5.9.2"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"ilana",
|
|
30
|
+
"ai",
|
|
31
|
+
"sdk",
|
|
32
|
+
"chatbot",
|
|
33
|
+
"governance"
|
|
34
|
+
],
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
}
|
|
39
|
+
}
|