@halo-sdk/core 1.0.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 +8 -0
- package/dist/halo-agent.d.ts +73 -0
- package/dist/halo-agent.d.ts.map +1 -0
- package/dist/halo-agent.js +95 -0
- package/dist/halo-agent.js.map +1 -0
- package/dist/halo-session.d.ts +60 -0
- package/dist/halo-session.d.ts.map +1 -0
- package/dist/halo-session.js +80 -0
- package/dist/halo-session.js.map +1 -0
- package/dist/halo.d.ts +20 -0
- package/dist/halo.d.ts.map +1 -0
- package/dist/halo.js +20 -0
- package/dist/halo.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/log.d.ts +22 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +41 -0
- package/dist/log.js.map +1 -0
- package/dist/model-adapter.d.ts +45 -0
- package/dist/model-adapter.d.ts.map +1 -0
- package/dist/model-adapter.js +2 -0
- package/dist/model-adapter.js.map +1 -0
- package/dist/prefix.d.ts +35 -0
- package/dist/prefix.d.ts.map +1 -0
- package/dist/prefix.js +84 -0
- package/dist/prefix.js.map +1 -0
- package/dist/session-impl.d.ts +62 -0
- package/dist/session-impl.d.ts.map +1 -0
- package/dist/session-impl.js +308 -0
- package/dist/session-impl.js.map +1 -0
- package/dist/session.d.ts +72 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +2 -0
- package/dist/session.js.map +1 -0
- package/dist/strategies.d.ts +26 -0
- package/dist/strategies.d.ts.map +1 -0
- package/dist/strategies.js +2 -0
- package/dist/strategies.js.map +1 -0
- package/dist/tool-utils.d.ts +14 -0
- package/dist/tool-utils.d.ts.map +1 -0
- package/dist/tool-utils.js +36 -0
- package/dist/tool-utils.js.map +1 -0
- package/dist/tool.d.ts +22 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +23 -0
- package/dist/tool.js.map +1 -0
- package/dist/types.d.ts +51 -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 +44 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-utils.js","sourceRoot":"","sources":["../src/tool-utils.ts"],"names":[],"mappings":"AAEA,oDAAoD;AACpD,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,GAAmB;IAChE,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE;YACR,IAAI;YACJ,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,UAAU,EAAE,GAAG,CAAC,UAAU;SAC3B;KACF,CAAC;AACJ,CAAC;AAQD;;;GAGG;AACH,MAAM,UAAU,cAAc;AAC5B,8DAA8D;AAC9D,KAAmE;IAEnE,MAAM,SAAS,GAAG,IAAI,GAAG,EAAuE,CAAC;IAEjG,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;IAEhD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IACzC,CAAC;IAED,MAAM,KAAK,GAAe,EAAE,CAAC;IAC7B,KAAK,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAChD,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;QACxC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YAChB,SAAS,CAAC,GAAG,CACX,IAAI;YACJ,8DAA8D;YAC9D,GAAG,CAAC,OAAsE,CAC3E,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AACzC,CAAC"}
|
package/dist/tool.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ToolDefinition } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Create a tool definition with an optional built-in execute function.
|
|
4
|
+
*
|
|
5
|
+
* This is a **type-level identity** — at runtime it returns the input unchanged.
|
|
6
|
+
* It exists purely for TypeScript generic inference on `TArgs`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const weatherTool = tool({
|
|
11
|
+
* description: "Get the weather for a city",
|
|
12
|
+
* parameters: {
|
|
13
|
+
* type: "object",
|
|
14
|
+
* properties: { city: { type: "string" } },
|
|
15
|
+
* required: ["city"],
|
|
16
|
+
* },
|
|
17
|
+
* execute: async ({ city }) => `Sunny, 22°C in ${city}`,
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function tool<TArgs = Record<string, unknown>>(def: ToolDefinition<TArgs>): ToolDefinition<TArgs>;
|
|
22
|
+
//# sourceMappingURL=tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClD,GAAG,EAAE,cAAc,CAAC,KAAK,CAAC,GACzB,cAAc,CAAC,KAAK,CAAC,CAEvB"}
|
package/dist/tool.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a tool definition with an optional built-in execute function.
|
|
3
|
+
*
|
|
4
|
+
* This is a **type-level identity** — at runtime it returns the input unchanged.
|
|
5
|
+
* It exists purely for TypeScript generic inference on `TArgs`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const weatherTool = tool({
|
|
10
|
+
* description: "Get the weather for a city",
|
|
11
|
+
* parameters: {
|
|
12
|
+
* type: "object",
|
|
13
|
+
* properties: { city: { type: "string" } },
|
|
14
|
+
* required: ["city"],
|
|
15
|
+
* },
|
|
16
|
+
* execute: async ({ city }) => `Sunny, 22°C in ${city}`,
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export function tool(def) {
|
|
21
|
+
return def;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=tool.js.map
|
package/dist/tool.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,IAAI,CAClB,GAA0B;IAE1B,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** Message roles in the OpenAI-compatible chat protocol. */
|
|
2
|
+
export type Role = "system" | "user" | "assistant" | "tool";
|
|
3
|
+
/** A single message in the chat protocol. */
|
|
4
|
+
export interface ChatMessage {
|
|
5
|
+
role: Role;
|
|
6
|
+
content: string;
|
|
7
|
+
tool_calls?: ToolCall[];
|
|
8
|
+
tool_call_id?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
}
|
|
11
|
+
/** A tool call requested by the model. */
|
|
12
|
+
export interface ToolCall {
|
|
13
|
+
id: string;
|
|
14
|
+
type: "function";
|
|
15
|
+
function: {
|
|
16
|
+
name: string;
|
|
17
|
+
arguments: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** A tool definition in OpenAI function-calling format. */
|
|
21
|
+
export interface ToolSpec {
|
|
22
|
+
type: "function";
|
|
23
|
+
function: {
|
|
24
|
+
name: string;
|
|
25
|
+
description: string;
|
|
26
|
+
parameters: Record<string, unknown>;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A tool definition with an optional built-in execute function.
|
|
31
|
+
* Pass `Record<string, ToolDefinition>` to `halo.session({ tools: {...} })`
|
|
32
|
+
* and `execute` will be called automatically — no `onToolCall` needed.
|
|
33
|
+
*/
|
|
34
|
+
export interface ToolDefinition<TArgs = Record<string, unknown>> {
|
|
35
|
+
description: string;
|
|
36
|
+
parameters: Record<string, unknown>;
|
|
37
|
+
/** If provided, run() calls this automatically when the model requests this tool. */
|
|
38
|
+
execute?: (args: TArgs) => string | Promise<string>;
|
|
39
|
+
}
|
|
40
|
+
/** Token usage for a single model call. */
|
|
41
|
+
export interface Usage {
|
|
42
|
+
promptTokens: number;
|
|
43
|
+
completionTokens: number;
|
|
44
|
+
/** Only present when the adapter supports prefix caching. */
|
|
45
|
+
caching?: {
|
|
46
|
+
hitTokens: number;
|
|
47
|
+
missTokens: number;
|
|
48
|
+
hitRate: number;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,MAAM,MAAM,IAAI,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;AAE5D,6CAA6C;AAC7C,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,0CAA0C;AAC1C,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,2DAA2D;AAC3D,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACrC,CAAC;CACH;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC7D,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,qFAAqF;IACrF,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACrD;AAED,2CAA2C;AAC3C,MAAM,WAAW,KAAK;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IAEzB,6DAA6D;IAC7D,OAAO,CAAC,EAAE;QACR,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@halo-sdk/core",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Core types, factory, and session management for Halo AI SDK — cache-aware agent with automatic tool-call loop",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"ai",
|
|
8
|
+
"llm",
|
|
9
|
+
"agent",
|
|
10
|
+
"cache-first",
|
|
11
|
+
"deepseek",
|
|
12
|
+
"tool-calling"
|
|
13
|
+
],
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/halo-sdk/halo-ai",
|
|
17
|
+
"directory": "packages/core"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"type": "module",
|
|
23
|
+
"main": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"typescript": "^5.8.0",
|
|
36
|
+
"vitest": "^3.0.0"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc",
|
|
40
|
+
"dev": "tsc --watch",
|
|
41
|
+
"test": "vitest run",
|
|
42
|
+
"test:watch": "vitest"
|
|
43
|
+
}
|
|
44
|
+
}
|