@noetaris/harness-types 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 +51 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# @noetaris/harness-types
|
|
2
|
+
|
|
3
|
+
Shared LLM type contract for the [@noetaris/harness](../core) ecosystem.
|
|
4
|
+
|
|
5
|
+
This package defines the common TypeScript interfaces that all LLM adapter packages implement. The core harness never imports these types — they are an ecosystem convention that lets adapters be structurally interchangeable.
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
`@noetaris/harness-types` is a types-only package with zero runtime code and zero dependencies. It provides the canonical definitions for messages, tools, and the `LLM` interface — the surface that all adapters (Anthropic, OpenAI, Gemini, etc.) must satisfy.
|
|
10
|
+
|
|
11
|
+
## Types
|
|
12
|
+
|
|
13
|
+
| Type | Description |
|
|
14
|
+
|------|-------------|
|
|
15
|
+
| `Message` | Discriminated union: `{ role: 'user'; content: string }` \| `{ role: 'assistant'; content?: string; toolCalls?: ToolCall[] }` \| `{ role: 'tool'; toolCallId: string; content: string }` |
|
|
16
|
+
| `Tool` | `{ name: string; description: string; inputSchema: Record<string, unknown> }` |
|
|
17
|
+
| `ToolCall` | `{ id: string; name: string; input: unknown }` |
|
|
18
|
+
| `LLMResponse` | `{ text: string; toolCalls: ToolCall[]; stopReason: 'end' \| 'tool_use' \| 'max_tokens' }` |
|
|
19
|
+
| `LLMUsageEvent` | `{ tokens: { input: number; output: number }; modelId: string; stopReason: LLMResponse['stopReason'] }` |
|
|
20
|
+
| `LLM` | `{ invoke(messages: Message[], options?: { tools?: Tool[] }): Promise<LLMResponse> }` |
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
pnpm add @noetaris/harness-types
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Requires Node.js ≥ 22.
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import type { LLM, Message, LLMResponse, Tool } from '@noetaris/harness-types'
|
|
34
|
+
|
|
35
|
+
class MyAdapter implements LLM {
|
|
36
|
+
async invoke(messages: Message[], options?: { tools?: Tool[] }): Promise<LLMResponse> {
|
|
37
|
+
// ...
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Related Packages
|
|
43
|
+
|
|
44
|
+
- [`@noetaris/harness`](https://github.com/noetaris-lab/harness) — core execution engine
|
|
45
|
+
- [`@noetaris/harness-anthropic`](https://github.com/noetaris-lab/harness-anthropic) — Anthropic Claude adapter
|
|
46
|
+
- [`@noetaris/harness-openai`](https://github.com/noetaris-lab/harness-openai) — OpenAI adapter
|
|
47
|
+
- [`@noetaris/harness-google`](https://github.com/noetaris-lab/harness-google) — Google Gemini adapter
|
|
48
|
+
|
|
49
|
+
## License
|
|
50
|
+
|
|
51
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared LLM protocol types used by all harness LLM adapters.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A single turn in a conversation.
|
|
8
|
+
*
|
|
9
|
+
* - `user` — text input from the human side.
|
|
10
|
+
* - `assistant` — model reply, optionally carrying tool-call requests.
|
|
11
|
+
* - `tool` — result returned to the model after a tool call.
|
|
12
|
+
*/
|
|
13
|
+
type Message = {
|
|
14
|
+
role: 'user';
|
|
15
|
+
content: string;
|
|
16
|
+
} | {
|
|
17
|
+
role: 'assistant';
|
|
18
|
+
content?: string;
|
|
19
|
+
toolCalls?: ToolCall[];
|
|
20
|
+
} | {
|
|
21
|
+
role: 'tool';
|
|
22
|
+
toolCallId: string;
|
|
23
|
+
content: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* A tool the LLM may invoke during a conversation turn.
|
|
27
|
+
*
|
|
28
|
+
* `inputSchema` must be a valid JSON Schema object describing the tool's
|
|
29
|
+
* input parameters (LLM adapters pass it to the provider as-is).
|
|
30
|
+
*/
|
|
31
|
+
interface Tool {
|
|
32
|
+
name: string;
|
|
33
|
+
description: string;
|
|
34
|
+
inputSchema: Record<string, unknown>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A single tool-call request emitted by the LLM in an assistant turn.
|
|
38
|
+
*
|
|
39
|
+
* `id` is provider-assigned and must be echoed back in the corresponding
|
|
40
|
+
* `role: 'tool'` message so the model can correlate results.
|
|
41
|
+
*/
|
|
42
|
+
interface ToolCall {
|
|
43
|
+
id: string;
|
|
44
|
+
name: string;
|
|
45
|
+
input: unknown;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Normalized response returned by every {@link LLM} adapter.
|
|
49
|
+
*
|
|
50
|
+
* `text` may be empty when `stopReason` is `'tool_use'`.
|
|
51
|
+
* `toolCalls` is empty when `stopReason` is `'end'` or `'max_tokens'`.
|
|
52
|
+
*/
|
|
53
|
+
interface LLMResponse {
|
|
54
|
+
text: string;
|
|
55
|
+
toolCalls: ToolCall[];
|
|
56
|
+
stopReason: 'end' | 'tool_use' | 'max_tokens';
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Token-usage payload emitted by LLM adapters as an `llm.response` observer event.
|
|
60
|
+
*
|
|
61
|
+
* Adapters that cannot report real token counts (e.g. mock adapters) emit `{ input: 0, output: 0 }`.
|
|
62
|
+
*/
|
|
63
|
+
interface LLMUsageEvent {
|
|
64
|
+
tokens: {
|
|
65
|
+
input: number;
|
|
66
|
+
output: number;
|
|
67
|
+
};
|
|
68
|
+
modelId: string;
|
|
69
|
+
stopReason: LLMResponse['stopReason'];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Core interface every LLM adapter must implement.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* const response = await llm.invoke(messages, { tools: [myTool] })
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
interface LLM {
|
|
80
|
+
/**
|
|
81
|
+
* Send a message list to the LLM and return a normalized response.
|
|
82
|
+
*
|
|
83
|
+
* @param messages - Conversation history, oldest first.
|
|
84
|
+
* @param options.tools - Optional tools the model may invoke.
|
|
85
|
+
*/
|
|
86
|
+
invoke(messages: Message[], options?: {
|
|
87
|
+
tools?: Tool[];
|
|
88
|
+
}): Promise<LLMResponse>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export type { LLM, LLMResponse, LLMUsageEvent, Message, Tool, ToolCall };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@noetaris/harness-types",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared LLM type contract for the @noetaris/harness ecosystem",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/noetaris-lab/harness-types.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/noetaris-lab/harness-types#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/noetaris-lab/harness-types/issues"
|
|
13
|
+
},
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=22"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup",
|
|
27
|
+
"typecheck": "tsc --noEmit",
|
|
28
|
+
"test": "vitest run",
|
|
29
|
+
"test:watch": "vitest",
|
|
30
|
+
"prepublishOnly": "pnpm build && pnpm test",
|
|
31
|
+
"publish:npm": "pnpm publish --access public --no-git-checks"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
36
|
+
"pnpm": {
|
|
37
|
+
"onlyBuiltDependencies": [
|
|
38
|
+
"esbuild"
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/node": "^25.8.0",
|
|
43
|
+
"tsup": "^8.5.1",
|
|
44
|
+
"typescript": "^6.0.3",
|
|
45
|
+
"vitest": "^4.1.6"
|
|
46
|
+
}
|
|
47
|
+
}
|