@rkat/sdk 0.3.4
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 +593 -0
- package/dist/capabilities.d.ts +24 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +36 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/client.d.ts +103 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +465 -0
- package/dist/client.js.map +1 -0
- package/dist/generated/errors.d.ts +25 -0
- package/dist/generated/errors.d.ts.map +1 -0
- package/dist/generated/errors.js +32 -0
- package/dist/generated/errors.js.map +1 -0
- package/dist/generated/index.d.ts +3 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +4 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/generated/types.d.ts +46 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/generated/types.js +4 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/skills.d.ts +41 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +57 -0
- package/dist/skills.js.map +1 -0
- package/dist/streaming.d.ts +26 -0
- package/dist/streaming.d.ts.map +1 -0
- package/dist/streaming.js +78 -0
- package/dist/streaming.js.map +1 -0
- package/package.json +26 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generated/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generated/index.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export declare const CONTRACT_VERSION = "0.3.3";
|
|
2
|
+
export interface WireUsage {
|
|
3
|
+
input_tokens: number;
|
|
4
|
+
output_tokens: number;
|
|
5
|
+
total_tokens: number;
|
|
6
|
+
cache_creation_tokens?: number;
|
|
7
|
+
cache_read_tokens?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface WireRunResult {
|
|
10
|
+
session_id: string;
|
|
11
|
+
session_ref?: string;
|
|
12
|
+
text: string;
|
|
13
|
+
turns: number;
|
|
14
|
+
tool_calls: number;
|
|
15
|
+
usage: WireUsage;
|
|
16
|
+
structured_output?: unknown;
|
|
17
|
+
schema_warnings?: Array<{
|
|
18
|
+
provider: string;
|
|
19
|
+
path: string;
|
|
20
|
+
message: string;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
export interface WireEvent {
|
|
24
|
+
session_id: string;
|
|
25
|
+
sequence: number;
|
|
26
|
+
event: Record<string, unknown>;
|
|
27
|
+
contract_version: string;
|
|
28
|
+
}
|
|
29
|
+
export interface CapabilityEntry {
|
|
30
|
+
id: string;
|
|
31
|
+
description: string;
|
|
32
|
+
status: string;
|
|
33
|
+
}
|
|
34
|
+
export interface CapabilitiesResponse {
|
|
35
|
+
contract_version: string;
|
|
36
|
+
capabilities: CapabilityEntry[];
|
|
37
|
+
}
|
|
38
|
+
export interface CommsParams {
|
|
39
|
+
host_mode: boolean;
|
|
40
|
+
comms_name?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface SkillsParams {
|
|
43
|
+
skills_enabled: boolean;
|
|
44
|
+
skill_references: string[];
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/generated/types.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,UAAU,CAAC;AAExC,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MA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uCAAuC;AACvC,0BAA0B;AAE1B,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Meerkat TypeScript SDK — communicate with the Meerkat agent runtime via JSON-RPC.
|
|
3
|
+
*/
|
|
4
|
+
export { MeerkatClient } from "./client.js";
|
|
5
|
+
export { CapabilityChecker } from "./capabilities.js";
|
|
6
|
+
export { EventStream } from "./streaming.js";
|
|
7
|
+
export { SkillHelper } from "./skills.js";
|
|
8
|
+
export { MeerkatError, CapabilityUnavailableError, SessionNotFoundError, SkillNotFoundError, } from "./generated/errors.js";
|
|
9
|
+
export type { WireUsage, WireRunResult, WireEvent, CapabilitiesResponse, CapabilityEntry, } from "./generated/types.js";
|
|
10
|
+
export { CONTRACT_VERSION } from "./generated/types.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EACL,YAAY,EACZ,0BAA0B,EAC1B,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,SAAS,EACT,aAAa,EACb,SAAS,EACT,oBAAoB,EACpB,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Meerkat TypeScript SDK — communicate with the Meerkat agent runtime via JSON-RPC.
|
|
3
|
+
*/
|
|
4
|
+
export { MeerkatClient } from "./client.js";
|
|
5
|
+
export { CapabilityChecker } from "./capabilities.js";
|
|
6
|
+
export { EventStream } from "./streaming.js";
|
|
7
|
+
export { SkillHelper } from "./skills.js";
|
|
8
|
+
export { MeerkatError, CapabilityUnavailableError, SessionNotFoundError, SkillNotFoundError, } from "./generated/errors.js";
|
|
9
|
+
export { CONTRACT_VERSION } from "./generated/types.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EACL,YAAY,EACZ,0BAA0B,EAC1B,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/skills.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill invocation helpers for the Meerkat SDK.
|
|
3
|
+
*/
|
|
4
|
+
import type { MeerkatClient } from "./client.js";
|
|
5
|
+
import type { WireRunResult } from "./generated/types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Helpers for working with Meerkat skills.
|
|
8
|
+
*
|
|
9
|
+
* Skills are loaded by the agent from filesystem and embedded sources.
|
|
10
|
+
* The agent's system prompt contains an inventory of available skills.
|
|
11
|
+
* To invoke a skill, include its reference (e.g. `/shell-patterns`)
|
|
12
|
+
* in the user prompt.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const helper = new SkillHelper(client);
|
|
17
|
+
* helper.requireSkills();
|
|
18
|
+
* const result = await helper.invoke(sessionId, "/shell-patterns", "How do I run a background job?");
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class SkillHelper {
|
|
22
|
+
private client;
|
|
23
|
+
constructor(client: MeerkatClient);
|
|
24
|
+
/** Check if the skills capability is available in this runtime. */
|
|
25
|
+
isAvailable(): boolean;
|
|
26
|
+
/** Throw if skills capability is not available. */
|
|
27
|
+
requireSkills(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Invoke a skill within an existing session.
|
|
30
|
+
*
|
|
31
|
+
* The skill reference (e.g. `/shell-patterns`) is prepended to the prompt.
|
|
32
|
+
* The agent's system prompt already contains the skill inventory, so it
|
|
33
|
+
* knows how to resolve the reference.
|
|
34
|
+
*/
|
|
35
|
+
invoke(sessionId: string, skillReference: string, prompt: string): Promise<WireRunResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Create a new session and invoke a skill in the first turn.
|
|
38
|
+
*/
|
|
39
|
+
invokeNewSession(skillReference: string, prompt: string, model?: string): Promise<WireRunResult>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=skills.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../src/skills.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D;;;;;;;;;;;;;;GAcG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAgB;gBAElB,MAAM,EAAE,aAAa;IAIjC,mEAAmE;IACnE,WAAW,IAAI,OAAO;IAItB,mDAAmD;IACnD,aAAa,IAAI,IAAI;IAUrB;;;;;;OAMG;IACG,MAAM,CACV,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,aAAa,CAAC;IAMzB;;OAEG;IACG,gBAAgB,CACpB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,aAAa,CAAC;CAK1B"}
|
package/dist/skills.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill invocation helpers for the Meerkat SDK.
|
|
3
|
+
*/
|
|
4
|
+
import { CapabilityUnavailableError } from "./generated/errors.js";
|
|
5
|
+
/**
|
|
6
|
+
* Helpers for working with Meerkat skills.
|
|
7
|
+
*
|
|
8
|
+
* Skills are loaded by the agent from filesystem and embedded sources.
|
|
9
|
+
* The agent's system prompt contains an inventory of available skills.
|
|
10
|
+
* To invoke a skill, include its reference (e.g. `/shell-patterns`)
|
|
11
|
+
* in the user prompt.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const helper = new SkillHelper(client);
|
|
16
|
+
* helper.requireSkills();
|
|
17
|
+
* const result = await helper.invoke(sessionId, "/shell-patterns", "How do I run a background job?");
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export class SkillHelper {
|
|
21
|
+
client;
|
|
22
|
+
constructor(client) {
|
|
23
|
+
this.client = client;
|
|
24
|
+
}
|
|
25
|
+
/** Check if the skills capability is available in this runtime. */
|
|
26
|
+
isAvailable() {
|
|
27
|
+
return this.client.hasCapability("skills");
|
|
28
|
+
}
|
|
29
|
+
/** Throw if skills capability is not available. */
|
|
30
|
+
requireSkills() {
|
|
31
|
+
if (!this.isAvailable()) {
|
|
32
|
+
throw new CapabilityUnavailableError("CAPABILITY_UNAVAILABLE", "Skills capability is not available in this runtime. " +
|
|
33
|
+
"Build with --features skills to enable.");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Invoke a skill within an existing session.
|
|
38
|
+
*
|
|
39
|
+
* The skill reference (e.g. `/shell-patterns`) is prepended to the prompt.
|
|
40
|
+
* The agent's system prompt already contains the skill inventory, so it
|
|
41
|
+
* knows how to resolve the reference.
|
|
42
|
+
*/
|
|
43
|
+
async invoke(sessionId, skillReference, prompt) {
|
|
44
|
+
this.requireSkills();
|
|
45
|
+
const fullPrompt = `${skillReference} ${prompt}`;
|
|
46
|
+
return this.client.startTurn(sessionId, fullPrompt);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Create a new session and invoke a skill in the first turn.
|
|
50
|
+
*/
|
|
51
|
+
async invokeNewSession(skillReference, prompt, model) {
|
|
52
|
+
this.requireSkills();
|
|
53
|
+
const fullPrompt = `${skillReference} ${prompt}`;
|
|
54
|
+
return this.client.createSession({ prompt: fullPrompt, model });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=skills.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.js","sourceRoot":"","sources":["../src/skills.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,WAAW;IACd,MAAM,CAAgB;IAE9B,YAAY,MAAqB;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,mEAAmE;IACnE,WAAW;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAED,mDAAmD;IACnD,aAAa;QACX,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,MAAM,IAAI,0BAA0B,CAClC,wBAAwB,EACxB,sDAAsD;gBACpD,yCAAyC,CAC5C,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,MAAM,CACV,SAAiB,EACjB,cAAsB,EACtB,MAAc;QAEd,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,MAAM,UAAU,GAAG,GAAG,cAAc,IAAI,MAAM,EAAE,CAAC;QACjD,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,gBAAgB,CACpB,cAAsB,EACtB,MAAc,EACd,KAAc;QAEd,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,MAAM,UAAU,GAAG,GAAG,cAAc,IAAI,MAAM,EAAE,CAAC;QACjD,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;IAClE,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async event stream over JSON-RPC notifications from rkat-rpc.
|
|
3
|
+
*/
|
|
4
|
+
import type { Interface as ReadlineInterface } from "node:readline";
|
|
5
|
+
import type { WireEvent } from "./generated/types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Async iterator that yields WireEvent objects from JSON-RPC notifications.
|
|
8
|
+
*
|
|
9
|
+
* Skips response messages (which have an `id` field) and only yields
|
|
10
|
+
* notification payloads parsed as WireEvent.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* for await (const event of new EventStream(readline)) {
|
|
15
|
+
* console.log(event.session_id, event.event);
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare class EventStream implements AsyncIterable<WireEvent> {
|
|
20
|
+
private buffer;
|
|
21
|
+
private waiters;
|
|
22
|
+
private closed;
|
|
23
|
+
constructor(rl: ReadlineInterface);
|
|
24
|
+
[Symbol.asyncIterator](): AsyncIterator<WireEvent>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=streaming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["../src/streaming.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;;;;;;;;;;GAYG;AACH,qBAAa,WAAY,YAAW,aAAa,CAAC,SAAS,CAAC;IAC1D,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,OAAO,CAAyD;IACxE,OAAO,CAAC,MAAM,CAAS;gBAEX,EAAE,EAAE,iBAAiB;IAoCjC,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,SAAS,CAAC;CAqBnD"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async event stream over JSON-RPC notifications from rkat-rpc.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Async iterator that yields WireEvent objects from JSON-RPC notifications.
|
|
6
|
+
*
|
|
7
|
+
* Skips response messages (which have an `id` field) and only yields
|
|
8
|
+
* notification payloads parsed as WireEvent.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* for await (const event of new EventStream(readline)) {
|
|
13
|
+
* console.log(event.session_id, event.event);
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export class EventStream {
|
|
18
|
+
buffer = [];
|
|
19
|
+
waiters = [];
|
|
20
|
+
closed = false;
|
|
21
|
+
constructor(rl) {
|
|
22
|
+
rl.on("line", (line) => {
|
|
23
|
+
try {
|
|
24
|
+
const data = JSON.parse(line);
|
|
25
|
+
// Skip responses (they have an "id" field)
|
|
26
|
+
if ("id" in data)
|
|
27
|
+
return;
|
|
28
|
+
const params = (data.params ?? {});
|
|
29
|
+
const event = {
|
|
30
|
+
session_id: String(params.session_id ?? ""),
|
|
31
|
+
sequence: Number(params.sequence ?? 0),
|
|
32
|
+
event: (params.event ?? {}),
|
|
33
|
+
contract_version: String(params.contract_version ?? ""),
|
|
34
|
+
};
|
|
35
|
+
if (this.waiters.length > 0) {
|
|
36
|
+
const waiter = this.waiters.shift();
|
|
37
|
+
waiter({ value: event, done: false });
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.buffer.push(event);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// Ignore non-JSON lines
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
rl.on("close", () => {
|
|
48
|
+
this.closed = true;
|
|
49
|
+
// Resolve any pending waiters with done
|
|
50
|
+
for (const waiter of this.waiters) {
|
|
51
|
+
waiter({ value: undefined, done: true });
|
|
52
|
+
}
|
|
53
|
+
this.waiters = [];
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
[Symbol.asyncIterator]() {
|
|
57
|
+
return {
|
|
58
|
+
next: () => {
|
|
59
|
+
if (this.buffer.length > 0) {
|
|
60
|
+
return Promise.resolve({
|
|
61
|
+
value: this.buffer.shift(),
|
|
62
|
+
done: false,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (this.closed) {
|
|
66
|
+
return Promise.resolve({
|
|
67
|
+
value: undefined,
|
|
68
|
+
done: true,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return new Promise((resolve) => {
|
|
72
|
+
this.waiters.push(resolve);
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=streaming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.js","sourceRoot":"","sources":["../src/streaming.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,WAAW;IACd,MAAM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AAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBAClC,MAAM,CAAC,EAAE,KAAK,EAAE,SAAiC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YACnE,CAAC;YACD,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QACpB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,CAAC,MAAM,CAAC,aAAa,CAAC;QACpB,OAAO;YACL,IAAI,EAAE,GAAuC,EAAE;gBAC7C,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC3B,OAAO,OAAO,CAAC,OAAO,CAAC;wBACrB,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAG;wBAC3B,IAAI,EAAE,KAAK;qBACZ,CAAC,CAAC;gBACL,CAAC;gBACD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;oBAChB,OAAO,OAAO,CAAC,OAAO,CAAC;wBACrB,KAAK,EAAE,SAAiC;wBACxC,IAAI,EAAE,IAAI;qBACX,CAAC,CAAC;gBACL,CAAC;gBACD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;oBAC7B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAC7B,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rkat/sdk",
|
|
3
|
+
"version": "0.3.4",
|
|
4
|
+
"description": "TypeScript SDK for Meerkat agent runtime",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.cjs",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"test": "node --test tests/"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT OR Apache-2.0",
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/node": "^22"
|
|
25
|
+
}
|
|
26
|
+
}
|