@agent-assistant/traits 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 +202 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# `@agent-assistant/traits`
|
|
2
|
+
|
|
3
|
+
`@agent-assistant/traits` is a TypeScript-first leaf package for validated, immutable assistant trait data.
|
|
4
|
+
|
|
5
|
+
It defines how an assistant presents itself and which formatting hints it prefers. It does not own runtime config, persona prompts, routing, model choice, memory, or product behavior.
|
|
6
|
+
|
|
7
|
+
## API
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import {
|
|
11
|
+
createTraitsProvider,
|
|
12
|
+
TraitsValidationError,
|
|
13
|
+
} from '@agent-assistant/traits';
|
|
14
|
+
|
|
15
|
+
import type {
|
|
16
|
+
AssistantTraits,
|
|
17
|
+
SurfaceFormattingTraits,
|
|
18
|
+
TraitsProvider,
|
|
19
|
+
} from '@agent-assistant/traits';
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Data Model
|
|
23
|
+
|
|
24
|
+
### `AssistantTraits`
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
interface AssistantTraits {
|
|
28
|
+
voice: string;
|
|
29
|
+
formality: string;
|
|
30
|
+
proactivity: string;
|
|
31
|
+
riskPosture: string;
|
|
32
|
+
domain?: string;
|
|
33
|
+
vocabulary?: string[];
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Rules:
|
|
38
|
+
|
|
39
|
+
- `voice` must be a non-empty string. Known values are `concise`, `conversational`, `formal`, and `technical`.
|
|
40
|
+
- Unknown `voice` values are accepted with `console.warn` so products can extend the register without forking the package.
|
|
41
|
+
- `formality` must be `casual`, `professional`, or `academic`.
|
|
42
|
+
- `proactivity` must be `low`, `medium`, or `high`.
|
|
43
|
+
- `riskPosture` must be `cautious`, `moderate`, or `assertive`.
|
|
44
|
+
- `domain`, if present, must be a non-empty string.
|
|
45
|
+
- `vocabulary`, if present, must be a non-empty array of non-empty strings.
|
|
46
|
+
|
|
47
|
+
### `SurfaceFormattingTraits`
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
interface SurfaceFormattingTraits {
|
|
51
|
+
preferredResponseLength?: number;
|
|
52
|
+
preferRichBlocks?: boolean;
|
|
53
|
+
preferMarkdown?: boolean;
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Rules:
|
|
58
|
+
|
|
59
|
+
- `preferredResponseLength`, if present, must be a positive integer.
|
|
60
|
+
- `preferRichBlocks`, if present, must be a boolean.
|
|
61
|
+
- `preferMarkdown`, if present, must be a boolean.
|
|
62
|
+
|
|
63
|
+
These are hints for product-owned format hooks. They do not replace surface capability checks.
|
|
64
|
+
|
|
65
|
+
### `TraitsProvider`
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
interface TraitsProvider {
|
|
69
|
+
readonly traits: Readonly<AssistantTraits>;
|
|
70
|
+
readonly surfaceFormatting?: Readonly<SurfaceFormattingTraits>;
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Consumers should depend on the read-only provider contract, not mutate or rebuild the provider at runtime.
|
|
75
|
+
|
|
76
|
+
## Creating a Provider
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { createTraitsProvider } from '@agent-assistant/traits';
|
|
80
|
+
|
|
81
|
+
const traits = createTraitsProvider(
|
|
82
|
+
{
|
|
83
|
+
voice: 'concise',
|
|
84
|
+
formality: 'professional',
|
|
85
|
+
proactivity: 'medium',
|
|
86
|
+
riskPosture: 'moderate',
|
|
87
|
+
domain: 'knowledge-and-workspace',
|
|
88
|
+
vocabulary: ['digest', 'workspace', 'context'],
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
preferredResponseLength: 800,
|
|
92
|
+
preferRichBlocks: false,
|
|
93
|
+
preferMarkdown: true,
|
|
94
|
+
},
|
|
95
|
+
);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
`createTraitsProvider` validates inputs, copies them, freezes the returned provider, freezes the nested trait objects, and freezes the copied `vocabulary` array when present.
|
|
99
|
+
|
|
100
|
+
## Validation Errors
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
import { createTraitsProvider, TraitsValidationError } from '@agent-assistant/traits';
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
createTraitsProvider({
|
|
107
|
+
voice: 'concise',
|
|
108
|
+
formality: 'semi-formal',
|
|
109
|
+
proactivity: 'medium',
|
|
110
|
+
riskPosture: 'moderate',
|
|
111
|
+
});
|
|
112
|
+
} catch (error) {
|
|
113
|
+
if (error instanceof TraitsValidationError) {
|
|
114
|
+
console.error(error.field);
|
|
115
|
+
console.error(error.invalidValue);
|
|
116
|
+
console.error(error.message);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`TraitsValidationError` extends `Error` and exposes:
|
|
122
|
+
|
|
123
|
+
- `field`: the failing trait field name
|
|
124
|
+
- `invalidValue`: the rejected value
|
|
125
|
+
- `message`: a readable explanation
|
|
126
|
+
|
|
127
|
+
## Usage Boundaries
|
|
128
|
+
|
|
129
|
+
This package owns trait data only.
|
|
130
|
+
|
|
131
|
+
- No workforce persona ownership
|
|
132
|
+
- No prompt generation
|
|
133
|
+
- No product-specific logic
|
|
134
|
+
- No cloud or runtime service assumptions
|
|
135
|
+
- No dynamic learning or adaptation engine
|
|
136
|
+
- No imports from other Relay Assistant packages
|
|
137
|
+
|
|
138
|
+
Traits and workforce personas are intentionally separate. Products may compose trait values into persona prompts or synthesizer inputs, but that composition belongs outside this package.
|
|
139
|
+
|
|
140
|
+
## Adaptation Pattern
|
|
141
|
+
|
|
142
|
+
The v1 adaptation layer is read-only and product-owned: packages and products read a `TraitsProvider` and apply its values to their own formatting or synthesis logic.
|
|
143
|
+
|
|
144
|
+
Example formatting usage:
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
const traits = runtime.definition.traits;
|
|
148
|
+
|
|
149
|
+
const useMarkdown =
|
|
150
|
+
caps.supportsMarkdown && (traits?.surfaceFormatting?.preferMarkdown ?? true);
|
|
151
|
+
|
|
152
|
+
const responseVoice = traits?.traits.voice ?? 'concise';
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Example synthesis usage:
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
const traits = context.definition?.traits;
|
|
159
|
+
|
|
160
|
+
return assembleResponse(results, {
|
|
161
|
+
voice: traits?.traits.voice ?? 'concise',
|
|
162
|
+
formality: traits?.traits.formality ?? 'professional',
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
The package does not generate prompts, emit formatted output, or interpret domain vocabulary beyond validation.
|
|
167
|
+
|
|
168
|
+
## Core Integration
|
|
169
|
+
|
|
170
|
+
`@agent-assistant/core` can attach a provider on `AssistantDefinition`:
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
const assistant = createAssistant({
|
|
174
|
+
id: 'sage',
|
|
175
|
+
name: 'Sage',
|
|
176
|
+
traits: createTraitsProvider({
|
|
177
|
+
voice: 'concise',
|
|
178
|
+
formality: 'professional',
|
|
179
|
+
proactivity: 'medium',
|
|
180
|
+
riskPosture: 'moderate',
|
|
181
|
+
}),
|
|
182
|
+
capabilities: {
|
|
183
|
+
reply: () => undefined,
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
The field is optional. Assistants without traits continue to work unchanged.
|
|
189
|
+
|
|
190
|
+
## Local Development
|
|
191
|
+
|
|
192
|
+
From `packages/traits`:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
npm install
|
|
196
|
+
npm run build
|
|
197
|
+
npm test
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
This package is runnable in isolation and has zero runtime dependencies.
|
|
201
|
+
|
|
202
|
+
TRAITS_PACKAGE_IMPLEMENTED
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agent-assistant/traits",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Validated immutable assistant traits for Agent Assistant SDK",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc -p tsconfig.json",
|
|
19
|
+
"test": "vitest run",
|
|
20
|
+
"test:watch": "vitest",
|
|
21
|
+
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"typescript": "^5.9.3",
|
|
25
|
+
"vitest": "^3.2.4"
|
|
26
|
+
},
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/AgentWorkforce/agent-assistant"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
}
|
|
35
|
+
}
|