@astratra/agent 1.0.0 → 1.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.fr.md +6 -0
- package/README.md +6 -0
- package/package.json +1 -1
- package/src/agent.js +2 -1
- package/src/index.d.ts +8 -1
package/README.fr.md
CHANGED
|
@@ -150,6 +150,12 @@ modèle ; les arguments sont sinon transmis comme le modèle les a écrits.
|
|
|
150
150
|
Pour les tests : `createMockGuards` et `createFakeModels` de
|
|
151
151
|
`@astratra/ai/guards/testing`.
|
|
152
152
|
|
|
153
|
+
### Montrer la réponse pendant qu'elle s'écrit
|
|
154
|
+
|
|
155
|
+
Avec des gardes, `turn` reçoit `unmask(texte)` : il rend les vrais mots d'un texte du modèle (masqué). Avec `onText`
|
|
156
|
+
de `@astratra/ai` (1.10.0), on montre ainsi la réponse en flux, sans ses repères (`#PERSON_0001`). La réponse finale
|
|
157
|
+
passe toujours par la garde de sortie (fuites, modération) ; ce qui part au modèle reste masqué.
|
|
158
|
+
|
|
153
159
|
## Tests
|
|
154
160
|
|
|
155
161
|
`npm test -w @astratra/agent`. Les tests PostgreSQL réels ne tournent qu'avec
|
package/README.md
CHANGED
|
@@ -318,6 +318,12 @@ tenant: scope it for tenant dashboards.
|
|
|
318
318
|
The interface parts are `FeedbackBar` in `@astratra/native-ui` (React Native)
|
|
319
319
|
and `@astratra/saas-kit-ui` (web).
|
|
320
320
|
|
|
321
|
+
### Showing the answer while it is written
|
|
322
|
+
|
|
323
|
+
With guards, `turn` receives `unmask(text)`: the real words of a (masked) model text. With `onText` from
|
|
324
|
+
`@astratra/ai` (1.10.0) you can show a streamed answer without its masking markers (`#PERSON_0001`). The final answer
|
|
325
|
+
still goes through the output guard (leaks, moderation); what is sent to the model stays masked.
|
|
326
|
+
|
|
321
327
|
## Tests
|
|
322
328
|
|
|
323
329
|
`npm test -w @astratra/agent` uses `node --test`; the guard tests run on
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astratra/agent",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Budgeted, verifiable and durable task execution with injected models and tools, plus user feedback (thumbs up/down) on runs that the agent learns from.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20"
|
package/src/agent.js
CHANGED
|
@@ -182,7 +182,8 @@ function createAgent(options = {}) {
|
|
|
182
182
|
if (!reserve && reason) throw new BudgetStop(reason);
|
|
183
183
|
task.turns += 1;
|
|
184
184
|
await save();
|
|
185
|
-
|
|
185
|
+
// `unmask` : de quoi montrer à la personne un texte du modèle pendant qu'il s'écrit (réponse en flux).
|
|
186
|
+
const response = await abortable(() => options.turn({ ...request, signal: activeSignal, phase, ...(guards && run ? { unmask: (text) => run.unmask(text) } : {}) }), activeSignal);
|
|
186
187
|
activeSignal.throwIfAborted();
|
|
187
188
|
const usage = usageOf(request, response, options.pricing);
|
|
188
189
|
for (const field of ['inputTokens', 'outputTokens', 'cost']) task.usage[field] += usage[field];
|
package/src/index.d.ts
CHANGED
|
@@ -29,7 +29,14 @@ export interface TaskStore {
|
|
|
29
29
|
save(task: Task, owner: string): Promise<Task>; release(id: string, owner: string): Promise<void>;
|
|
30
30
|
}
|
|
31
31
|
export interface Budget { maxMs?: number; maxTurns?: number; maxTokens?: number; maxCost?: number }
|
|
32
|
-
export interface TurnRequest {
|
|
32
|
+
export interface TurnRequest {
|
|
33
|
+
system: string; messages: Message[]; tools: Array<Record<string, unknown>>; signal: AbortSignal; phase: string;
|
|
34
|
+
/**
|
|
35
|
+
* Avec des gardes : rend les vrais mots d'un texte du modèle (masqué). Pour montrer une réponse pendant qu'elle
|
|
36
|
+
* s'écrit (`onText` de @astratra/ai) ; la réponse finale, elle, passe toujours par la garde de sortie.
|
|
37
|
+
*/
|
|
38
|
+
unmask?: (text: string) => string;
|
|
39
|
+
}
|
|
33
40
|
export interface TurnResponse { text?: string; toolCalls?: NativeToolCall[]; usage?: { inputTokens?: number; outputTokens?: number; prompt_tokens?: number; completion_tokens?: number; cost?: number } }
|
|
34
41
|
export interface Verification { complete: boolean; feedback?: string }
|
|
35
42
|
export interface SummaryInput { messages: Message[]; plan: PlanStep[]; signal: AbortSignal }
|