@kindgi/agents 0.1.1 → 0.1.3
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/dist/conversation-binding.d.ts +9 -1
- package/dist/conversation-binding.d.ts.map +1 -1
- package/dist/define.js +20 -0
- package/dist/define.js.map +1 -1
- package/dist/guardrails-gate.d.ts +7 -4
- package/dist/guardrails-gate.d.ts.map +1 -1
- package/dist/guardrails-gate.js +5 -2
- package/dist/guardrails-gate.js.map +1 -1
- package/dist/handlers/context.d.ts +14 -0
- package/dist/handlers/context.d.ts.map +1 -1
- package/dist/handlers/dispatch-tools.d.ts.map +1 -1
- package/dist/handlers/dispatch-tools.js +57 -60
- package/dist/handlers/dispatch-tools.js.map +1 -1
- package/dist/handlers/errors.d.ts +11 -1
- package/dist/handlers/errors.d.ts.map +1 -1
- package/dist/handlers/errors.js.map +1 -1
- package/dist/handlers/evaluate-guardrails.d.ts.map +1 -1
- package/dist/handlers/evaluate-guardrails.js +34 -1
- package/dist/handlers/evaluate-guardrails.js.map +1 -1
- package/dist/handlers/gate-decision.d.ts +62 -0
- package/dist/handlers/gate-decision.d.ts.map +1 -0
- package/dist/handlers/gate-decision.js +55 -0
- package/dist/handlers/gate-decision.js.map +1 -0
- package/dist/handlers/model-call.d.ts +10 -0
- package/dist/handlers/model-call.d.ts.map +1 -1
- package/dist/handlers/model-call.js +109 -34
- package/dist/handlers/model-call.js.map +1 -1
- package/dist/handlers/persist-provenance.d.ts.map +1 -1
- package/dist/handlers/persist-provenance.js +3 -1
- package/dist/handlers/persist-provenance.js.map +1 -1
- package/dist/handlers/persist-user-message.d.ts.map +1 -1
- package/dist/handlers/persist-user-message.js +5 -16
- package/dist/handlers/persist-user-message.js.map +1 -1
- package/dist/handlers/public-types.d.ts +16 -2
- package/dist/handlers/public-types.d.ts.map +1 -1
- package/dist/handlers/rehydrate.d.ts.map +1 -1
- package/dist/handlers/rehydrate.js +85 -0
- package/dist/handlers/rehydrate.js.map +1 -1
- package/dist/handlers/run-retrievals.d.ts.map +1 -1
- package/dist/handlers/run-retrievals.js +2 -19
- package/dist/handlers/run-retrievals.js.map +1 -1
- package/dist/handlers/setup.d.ts.map +1 -1
- package/dist/handlers/setup.js +44 -24
- package/dist/handlers/setup.js.map +1 -1
- package/dist/handlers/tool-hitl.d.ts +5 -9
- package/dist/handlers/tool-hitl.d.ts.map +1 -1
- package/dist/handlers/tool-hitl.js +5 -0
- package/dist/handlers/tool-hitl.js.map +1 -1
- package/dist/handlers/turn-provenance.d.ts +67 -0
- package/dist/handlers/turn-provenance.d.ts.map +1 -0
- package/dist/handlers/turn-provenance.js +160 -0
- package/dist/handlers/turn-provenance.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/invoke.d.ts +15 -2
- package/dist/invoke.d.ts.map +1 -1
- package/dist/invoke.js +38 -22
- package/dist/invoke.js.map +1 -1
- package/dist/provenance-emit.d.ts +4 -2
- package/dist/provenance-emit.d.ts.map +1 -1
- package/dist/provenance-emit.js +4 -2
- package/dist/provenance-emit.js.map +1 -1
- package/dist/schema.d.ts +17 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +11 -0
- package/dist/schema.js.map +1 -1
- package/dist/types.d.ts +15 -1
- package/dist/types.d.ts.map +1 -1
- package/migrations/0003_hesitant_captain_cross.sql +2 -0
- package/migrations/meta/0003_snapshot.json +321 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +19 -18
- package/src/conversation-binding.ts +9 -1
- package/src/define.ts +20 -0
- package/src/guardrails-gate.ts +17 -3
- package/src/handlers/context.ts +14 -0
- package/src/handlers/dispatch-tools.ts +76 -61
- package/src/handlers/errors.ts +13 -1
- package/src/handlers/evaluate-guardrails.ts +39 -1
- package/src/handlers/gate-decision.ts +101 -0
- package/src/handlers/model-call.ts +149 -33
- package/src/handlers/persist-provenance.ts +3 -1
- package/src/handlers/persist-user-message.ts +3 -16
- package/src/handlers/public-types.ts +16 -2
- package/src/handlers/rehydrate.ts +120 -3
- package/src/handlers/run-retrievals.ts +2 -19
- package/src/handlers/setup.ts +59 -33
- package/src/handlers/tool-hitl.ts +6 -10
- package/src/handlers/turn-provenance.ts +230 -0
- package/src/index.ts +8 -0
- package/src/invoke.ts +53 -25
- package/src/provenance-emit.ts +4 -1
- package/src/schema.ts +11 -0
- package/src/types.ts +15 -1
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "39c9de18-7608-4826-84f7-af1dda0ba078",
|
|
3
|
+
"prevId": "2769ef0e-69b4-4a4d-ab47-044e2f11945e",
|
|
4
|
+
"version": "7",
|
|
5
|
+
"dialect": "postgresql",
|
|
6
|
+
"tables": {
|
|
7
|
+
"public.agent_conversations": {
|
|
8
|
+
"name": "agent_conversations",
|
|
9
|
+
"schema": "",
|
|
10
|
+
"columns": {
|
|
11
|
+
"id": {
|
|
12
|
+
"name": "id",
|
|
13
|
+
"type": "uuid",
|
|
14
|
+
"primaryKey": true,
|
|
15
|
+
"notNull": true,
|
|
16
|
+
"default": "gen_random_uuid()"
|
|
17
|
+
},
|
|
18
|
+
"tenant_id": {
|
|
19
|
+
"name": "tenant_id",
|
|
20
|
+
"type": "uuid",
|
|
21
|
+
"primaryKey": false,
|
|
22
|
+
"notNull": true
|
|
23
|
+
},
|
|
24
|
+
"agent_id": {
|
|
25
|
+
"name": "agent_id",
|
|
26
|
+
"type": "text",
|
|
27
|
+
"primaryKey": false,
|
|
28
|
+
"notNull": true
|
|
29
|
+
},
|
|
30
|
+
"agent_version": {
|
|
31
|
+
"name": "agent_version",
|
|
32
|
+
"type": "text",
|
|
33
|
+
"primaryKey": false,
|
|
34
|
+
"notNull": true
|
|
35
|
+
},
|
|
36
|
+
"title": {
|
|
37
|
+
"name": "title",
|
|
38
|
+
"type": "text",
|
|
39
|
+
"primaryKey": false,
|
|
40
|
+
"notNull": true
|
|
41
|
+
},
|
|
42
|
+
"participant_id": {
|
|
43
|
+
"name": "participant_id",
|
|
44
|
+
"type": "text",
|
|
45
|
+
"primaryKey": false,
|
|
46
|
+
"notNull": false
|
|
47
|
+
},
|
|
48
|
+
"project_id": {
|
|
49
|
+
"name": "project_id",
|
|
50
|
+
"type": "uuid",
|
|
51
|
+
"primaryKey": false,
|
|
52
|
+
"notNull": false
|
|
53
|
+
},
|
|
54
|
+
"scope": {
|
|
55
|
+
"name": "scope",
|
|
56
|
+
"type": "jsonb",
|
|
57
|
+
"primaryKey": false,
|
|
58
|
+
"notNull": true
|
|
59
|
+
},
|
|
60
|
+
"opened_at": {
|
|
61
|
+
"name": "opened_at",
|
|
62
|
+
"type": "timestamp with time zone",
|
|
63
|
+
"primaryKey": false,
|
|
64
|
+
"notNull": true,
|
|
65
|
+
"default": "now()"
|
|
66
|
+
},
|
|
67
|
+
"closed_at": {
|
|
68
|
+
"name": "closed_at",
|
|
69
|
+
"type": "timestamp with time zone",
|
|
70
|
+
"primaryKey": false,
|
|
71
|
+
"notNull": false
|
|
72
|
+
},
|
|
73
|
+
"turn_count": {
|
|
74
|
+
"name": "turn_count",
|
|
75
|
+
"type": "integer",
|
|
76
|
+
"primaryKey": false,
|
|
77
|
+
"notNull": true,
|
|
78
|
+
"default": 0
|
|
79
|
+
},
|
|
80
|
+
"last_message_at": {
|
|
81
|
+
"name": "last_message_at",
|
|
82
|
+
"type": "timestamp with time zone",
|
|
83
|
+
"primaryKey": false,
|
|
84
|
+
"notNull": false
|
|
85
|
+
},
|
|
86
|
+
"metadata": {
|
|
87
|
+
"name": "metadata",
|
|
88
|
+
"type": "jsonb",
|
|
89
|
+
"primaryKey": false,
|
|
90
|
+
"notNull": false
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"indexes": {
|
|
94
|
+
"agent_conversations_tenant_agent_idx": {
|
|
95
|
+
"name": "agent_conversations_tenant_agent_idx",
|
|
96
|
+
"columns": [
|
|
97
|
+
{
|
|
98
|
+
"expression": "tenant_id",
|
|
99
|
+
"isExpression": false,
|
|
100
|
+
"asc": true,
|
|
101
|
+
"nulls": "last"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"expression": "agent_id",
|
|
105
|
+
"isExpression": false,
|
|
106
|
+
"asc": true,
|
|
107
|
+
"nulls": "last"
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"isUnique": false,
|
|
111
|
+
"concurrently": false,
|
|
112
|
+
"method": "btree",
|
|
113
|
+
"with": {}
|
|
114
|
+
},
|
|
115
|
+
"agent_conversations_tenant_participant_idx": {
|
|
116
|
+
"name": "agent_conversations_tenant_participant_idx",
|
|
117
|
+
"columns": [
|
|
118
|
+
{
|
|
119
|
+
"expression": "tenant_id",
|
|
120
|
+
"isExpression": false,
|
|
121
|
+
"asc": true,
|
|
122
|
+
"nulls": "last"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"expression": "participant_id",
|
|
126
|
+
"isExpression": false,
|
|
127
|
+
"asc": true,
|
|
128
|
+
"nulls": "last"
|
|
129
|
+
}
|
|
130
|
+
],
|
|
131
|
+
"isUnique": false,
|
|
132
|
+
"concurrently": false,
|
|
133
|
+
"method": "btree",
|
|
134
|
+
"with": {}
|
|
135
|
+
},
|
|
136
|
+
"agent_conversations_tenant_project_opened_idx": {
|
|
137
|
+
"name": "agent_conversations_tenant_project_opened_idx",
|
|
138
|
+
"columns": [
|
|
139
|
+
{
|
|
140
|
+
"expression": "tenant_id",
|
|
141
|
+
"isExpression": false,
|
|
142
|
+
"asc": true,
|
|
143
|
+
"nulls": "last"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"expression": "project_id",
|
|
147
|
+
"isExpression": false,
|
|
148
|
+
"asc": true,
|
|
149
|
+
"nulls": "last"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"expression": "opened_at",
|
|
153
|
+
"isExpression": false,
|
|
154
|
+
"asc": false,
|
|
155
|
+
"nulls": "last"
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
"isUnique": false,
|
|
159
|
+
"where": "\"agent_conversations\".\"project_id\" IS NOT NULL",
|
|
160
|
+
"concurrently": false,
|
|
161
|
+
"method": "btree",
|
|
162
|
+
"with": {}
|
|
163
|
+
},
|
|
164
|
+
"agent_conversations_open_recent_idx": {
|
|
165
|
+
"name": "agent_conversations_open_recent_idx",
|
|
166
|
+
"columns": [
|
|
167
|
+
{
|
|
168
|
+
"expression": "tenant_id",
|
|
169
|
+
"isExpression": false,
|
|
170
|
+
"asc": true,
|
|
171
|
+
"nulls": "last"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"expression": "last_message_at",
|
|
175
|
+
"isExpression": false,
|
|
176
|
+
"asc": false,
|
|
177
|
+
"nulls": "last"
|
|
178
|
+
}
|
|
179
|
+
],
|
|
180
|
+
"isUnique": false,
|
|
181
|
+
"where": "\"agent_conversations\".\"closed_at\" IS NULL",
|
|
182
|
+
"concurrently": false,
|
|
183
|
+
"method": "btree",
|
|
184
|
+
"with": {}
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
"foreignKeys": {},
|
|
188
|
+
"compositePrimaryKeys": {},
|
|
189
|
+
"uniqueConstraints": {},
|
|
190
|
+
"policies": {},
|
|
191
|
+
"checkConstraints": {},
|
|
192
|
+
"isRLSEnabled": false
|
|
193
|
+
},
|
|
194
|
+
"public.agent_run_snapshots": {
|
|
195
|
+
"name": "agent_run_snapshots",
|
|
196
|
+
"schema": "",
|
|
197
|
+
"columns": {
|
|
198
|
+
"id": {
|
|
199
|
+
"name": "id",
|
|
200
|
+
"type": "uuid",
|
|
201
|
+
"primaryKey": true,
|
|
202
|
+
"notNull": true
|
|
203
|
+
},
|
|
204
|
+
"tenant_id": {
|
|
205
|
+
"name": "tenant_id",
|
|
206
|
+
"type": "uuid",
|
|
207
|
+
"primaryKey": false,
|
|
208
|
+
"notNull": true
|
|
209
|
+
},
|
|
210
|
+
"project_id": {
|
|
211
|
+
"name": "project_id",
|
|
212
|
+
"type": "uuid",
|
|
213
|
+
"primaryKey": false,
|
|
214
|
+
"notNull": true
|
|
215
|
+
},
|
|
216
|
+
"agent_id": {
|
|
217
|
+
"name": "agent_id",
|
|
218
|
+
"type": "text",
|
|
219
|
+
"primaryKey": false,
|
|
220
|
+
"notNull": true
|
|
221
|
+
},
|
|
222
|
+
"agent_version": {
|
|
223
|
+
"name": "agent_version",
|
|
224
|
+
"type": "text",
|
|
225
|
+
"primaryKey": false,
|
|
226
|
+
"notNull": true
|
|
227
|
+
},
|
|
228
|
+
"conversation_id": {
|
|
229
|
+
"name": "conversation_id",
|
|
230
|
+
"type": "uuid",
|
|
231
|
+
"primaryKey": false,
|
|
232
|
+
"notNull": true
|
|
233
|
+
},
|
|
234
|
+
"user_message": {
|
|
235
|
+
"name": "user_message",
|
|
236
|
+
"type": "text",
|
|
237
|
+
"primaryKey": false,
|
|
238
|
+
"notNull": true
|
|
239
|
+
},
|
|
240
|
+
"parameters": {
|
|
241
|
+
"name": "parameters",
|
|
242
|
+
"type": "jsonb",
|
|
243
|
+
"primaryKey": false,
|
|
244
|
+
"notNull": false
|
|
245
|
+
},
|
|
246
|
+
"input": {
|
|
247
|
+
"name": "input",
|
|
248
|
+
"type": "jsonb",
|
|
249
|
+
"primaryKey": false,
|
|
250
|
+
"notNull": false
|
|
251
|
+
},
|
|
252
|
+
"participant_id": {
|
|
253
|
+
"name": "participant_id",
|
|
254
|
+
"type": "text",
|
|
255
|
+
"primaryKey": false,
|
|
256
|
+
"notNull": false
|
|
257
|
+
},
|
|
258
|
+
"dry_run": {
|
|
259
|
+
"name": "dry_run",
|
|
260
|
+
"type": "integer",
|
|
261
|
+
"primaryKey": false,
|
|
262
|
+
"notNull": true,
|
|
263
|
+
"default": 0
|
|
264
|
+
},
|
|
265
|
+
"principal": {
|
|
266
|
+
"name": "principal",
|
|
267
|
+
"type": "jsonb",
|
|
268
|
+
"primaryKey": false,
|
|
269
|
+
"notNull": false
|
|
270
|
+
},
|
|
271
|
+
"authz": {
|
|
272
|
+
"name": "authz",
|
|
273
|
+
"type": "jsonb",
|
|
274
|
+
"primaryKey": false,
|
|
275
|
+
"notNull": false
|
|
276
|
+
},
|
|
277
|
+
"created_at": {
|
|
278
|
+
"name": "created_at",
|
|
279
|
+
"type": "timestamp with time zone",
|
|
280
|
+
"primaryKey": false,
|
|
281
|
+
"notNull": true,
|
|
282
|
+
"default": "now()"
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
"indexes": {
|
|
286
|
+
"agent_run_snapshots_tenant_idx": {
|
|
287
|
+
"name": "agent_run_snapshots_tenant_idx",
|
|
288
|
+
"columns": [
|
|
289
|
+
{
|
|
290
|
+
"expression": "tenant_id",
|
|
291
|
+
"isExpression": false,
|
|
292
|
+
"asc": true,
|
|
293
|
+
"nulls": "last"
|
|
294
|
+
}
|
|
295
|
+
],
|
|
296
|
+
"isUnique": false,
|
|
297
|
+
"concurrently": false,
|
|
298
|
+
"method": "btree",
|
|
299
|
+
"with": {}
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
"foreignKeys": {},
|
|
303
|
+
"compositePrimaryKeys": {},
|
|
304
|
+
"uniqueConstraints": {},
|
|
305
|
+
"policies": {},
|
|
306
|
+
"checkConstraints": {},
|
|
307
|
+
"isRLSEnabled": false
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
"enums": {},
|
|
311
|
+
"schemas": {},
|
|
312
|
+
"sequences": {},
|
|
313
|
+
"roles": {},
|
|
314
|
+
"policies": {},
|
|
315
|
+
"views": {},
|
|
316
|
+
"_meta": {
|
|
317
|
+
"columns": {},
|
|
318
|
+
"schemas": {},
|
|
319
|
+
"tables": {}
|
|
320
|
+
}
|
|
321
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kindgi/agents",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Agent primitive for Kindgi. Composes capabilities (model routing), tools (execution), memory (facts + retrieval), guardrails (declarative guardrails), and provenance into a single declarative unit. Agents are data-as-code — a defineAgent() call produces a durable definition that runs on the kernel, with first-class multi-turn conversations, streaming output, and a provenance record per turn.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
20
20
|
"types": "./dist/index.d.ts",
|
|
21
|
-
"import": "./dist/index.js"
|
|
21
|
+
"import": "./dist/index.js",
|
|
22
|
+
"default": "./dist/index.js"
|
|
22
23
|
}
|
|
23
24
|
},
|
|
24
25
|
"files": [
|
|
@@ -30,21 +31,21 @@
|
|
|
30
31
|
"type-manifest.json"
|
|
31
32
|
],
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"@kindgi/authz": "0.1.
|
|
34
|
-
"@kindgi/capabilities": "0.1.
|
|
35
|
-
"@kindgi/compliance": "0.1.
|
|
36
|
-
"@kindgi/embedding": "0.1.
|
|
37
|
-
"@kindgi/flow": "0.1.
|
|
38
|
-
"@kindgi/handler": "0.1.
|
|
39
|
-
"@kindgi/guardrails": "0.1.
|
|
40
|
-
"@kindgi/memory": "0.1.
|
|
41
|
-
"@kindgi/policy-contract": "0.1.
|
|
42
|
-
"@kindgi/provenance": "0.1.
|
|
43
|
-
"@kindgi/runtime": "0.1.
|
|
44
|
-
"@kindgi/schema": "0.1.
|
|
45
|
-
"@kindgi/tools": "0.1.
|
|
46
|
-
"@kindgi/types": "0.1.
|
|
47
|
-
"drizzle-orm": "^0.
|
|
34
|
+
"@kindgi/authz": "0.1.3",
|
|
35
|
+
"@kindgi/capabilities": "0.1.3",
|
|
36
|
+
"@kindgi/compliance": "0.1.3",
|
|
37
|
+
"@kindgi/embedding": "0.1.3",
|
|
38
|
+
"@kindgi/flow": "0.1.3",
|
|
39
|
+
"@kindgi/handler": "0.1.3",
|
|
40
|
+
"@kindgi/guardrails": "0.1.3",
|
|
41
|
+
"@kindgi/memory": "0.1.3",
|
|
42
|
+
"@kindgi/policy-contract": "0.1.3",
|
|
43
|
+
"@kindgi/provenance": "0.1.3",
|
|
44
|
+
"@kindgi/runtime": "0.1.3",
|
|
45
|
+
"@kindgi/schema": "0.1.3",
|
|
46
|
+
"@kindgi/tools": "0.1.3",
|
|
47
|
+
"@kindgi/types": "0.1.3",
|
|
48
|
+
"drizzle-orm": "^0.45.3",
|
|
48
49
|
"liquidjs": "^10.29.0"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
@@ -63,7 +64,7 @@
|
|
|
63
64
|
"zod": "^4.6.5"
|
|
64
65
|
},
|
|
65
66
|
"engines": {
|
|
66
|
-
"node": ">=22.
|
|
67
|
+
"node": ">=22.12.0"
|
|
67
68
|
},
|
|
68
69
|
"publishConfig": {
|
|
69
70
|
"access": "public",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright (C) 2026 Kindgi Inc.
|
|
3
3
|
|
|
4
4
|
import type { RunBinding } from '@kindgi/runtime';
|
|
5
|
-
import type { Result, Semver, TenantId } from '@kindgi/types';
|
|
5
|
+
import type { ListScope, ProjectId, Result, Semver, TenantId } from '@kindgi/types';
|
|
6
6
|
|
|
7
7
|
import type { AgentError } from './errors.js';
|
|
8
8
|
import type {
|
|
@@ -21,6 +21,8 @@ export interface OpenConversationInput {
|
|
|
21
21
|
readonly agentVersion: Semver;
|
|
22
22
|
readonly title: string;
|
|
23
23
|
readonly participantId?: string;
|
|
24
|
+
/** The project the conversation is in: its turns' project. Lists filter by it. */
|
|
25
|
+
readonly projectId?: ProjectId;
|
|
24
26
|
readonly scope: Readonly<Record<string, unknown>>;
|
|
25
27
|
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
26
28
|
}
|
|
@@ -72,6 +74,12 @@ export interface ConversationPageCursor {
|
|
|
72
74
|
|
|
73
75
|
export interface ListConversationsPageInput {
|
|
74
76
|
readonly tenantId: TenantId;
|
|
77
|
+
/**
|
|
78
|
+
* Only one project's conversations, or every project's in an org.
|
|
79
|
+
* Absent: the tenant's. A conversation opened without a project is
|
|
80
|
+
* listed only without a scope.
|
|
81
|
+
*/
|
|
82
|
+
readonly scope?: ListScope;
|
|
75
83
|
readonly agentId?: AgentId;
|
|
76
84
|
/** When set, filter to open (no closedAt) or closed (closedAt set) rows only. */
|
|
77
85
|
readonly status?: 'open' | 'closed';
|
package/src/define.ts
CHANGED
|
@@ -448,6 +448,7 @@ function validateConversationPolicy(policy?: ConversationPolicy): Issue[] {
|
|
|
448
448
|
message: 'hitl.timeoutMs must be a positive integer (ms)',
|
|
449
449
|
});
|
|
450
450
|
}
|
|
451
|
+
out.push(...validateOnTimeout(h.onTimeout));
|
|
451
452
|
const ROLES: ReadonlySet<string> = new Set(['standard', 'senior', 'admin']);
|
|
452
453
|
if (
|
|
453
454
|
h.defaultReviewerRole !== undefined &&
|
|
@@ -490,6 +491,25 @@ function validateConversationPolicy(policy?: ConversationPolicy): Issue[] {
|
|
|
490
491
|
return out;
|
|
491
492
|
}
|
|
492
493
|
|
|
494
|
+
/**
|
|
495
|
+
* `hitl.onTimeout`: only `'escalate'`, what the runtime does when an
|
|
496
|
+
* approval's time runs out. `'auto-approve'` / `'auto-reject'` aren't
|
|
497
|
+
* implemented, so they're refused instead of accepted and ignored.
|
|
498
|
+
*/
|
|
499
|
+
function validateOnTimeout(onTimeout: unknown): Issue[] {
|
|
500
|
+
if (onTimeout === undefined || onTimeout === 'escalate') return [];
|
|
501
|
+
const path = '/conversationPolicy/hitl/onTimeout';
|
|
502
|
+
if (onTimeout === 'auto-approve' || onTimeout === 'auto-reject') {
|
|
503
|
+
return [
|
|
504
|
+
{
|
|
505
|
+
path,
|
|
506
|
+
message: `hitl.onTimeout '${onTimeout}' isn't supported: an approval that times out escalates one reviewer tier, and at admin it expires (the turn fails with hitl-cancelled). Use 'escalate', or leave it out.`,
|
|
507
|
+
},
|
|
508
|
+
];
|
|
509
|
+
}
|
|
510
|
+
return [{ path, message: "hitl.onTimeout must be 'escalate'" }];
|
|
511
|
+
}
|
|
512
|
+
|
|
493
513
|
type OutputOutcome =
|
|
494
514
|
| { readonly kind: 'none' }
|
|
495
515
|
| { readonly kind: 'ok'; readonly value: AgentOutputSpec }
|
package/src/guardrails-gate.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// Copyright (C) 2026 Kindgi Inc.
|
|
3
3
|
|
|
4
|
-
import type { ProviderRegistry, TenantPolicy } from '@kindgi/capabilities';
|
|
4
|
+
import type { ProviderRegistry, TenantPolicy, UsageSink } from '@kindgi/capabilities';
|
|
5
5
|
import type { ComplianceProvider } from '@kindgi/compliance';
|
|
6
6
|
import {
|
|
7
7
|
type CheckRegistry,
|
|
@@ -15,7 +15,15 @@ import {
|
|
|
15
15
|
type ToolResultRecord,
|
|
16
16
|
evaluateAll,
|
|
17
17
|
} from '@kindgi/guardrails';
|
|
18
|
-
import type {
|
|
18
|
+
import type {
|
|
19
|
+
AgentId,
|
|
20
|
+
GuardrailId,
|
|
21
|
+
OrgId,
|
|
22
|
+
ProjectId,
|
|
23
|
+
Result,
|
|
24
|
+
RunId,
|
|
25
|
+
TenantId,
|
|
26
|
+
} from '@kindgi/types';
|
|
19
27
|
|
|
20
28
|
import type { Agent, ConversationId, ConversationMessage } from './types.js';
|
|
21
29
|
|
|
@@ -66,6 +74,8 @@ export function buildRunTrace(input: {
|
|
|
66
74
|
readonly tenantId: TenantId;
|
|
67
75
|
/** Lets the engine record compliance evidence for a failed check. */
|
|
68
76
|
readonly projectId: ProjectId;
|
|
77
|
+
/** The project's org, when it has one. */
|
|
78
|
+
readonly orgId?: OrgId;
|
|
69
79
|
readonly conversationId: ConversationId;
|
|
70
80
|
/** 1-based number of this turn in the conversation. */
|
|
71
81
|
readonly turnNumber: number;
|
|
@@ -133,6 +143,7 @@ export function buildRunTrace(input: {
|
|
|
133
143
|
runId: input.runId,
|
|
134
144
|
tenantId: input.tenantId,
|
|
135
145
|
projectId: input.projectId,
|
|
146
|
+
...(input.orgId !== undefined && { orgId: input.orgId }),
|
|
136
147
|
agentId: input.agent.id as unknown as AgentId,
|
|
137
148
|
output,
|
|
138
149
|
toolCalls,
|
|
@@ -179,7 +190,8 @@ export function resolveGuardrails(
|
|
|
179
190
|
* doesn't halt on its own. `tenantPolicy` (the policy the turn was
|
|
180
191
|
* routed under) also governs which models llm-judge guardrails may use;
|
|
181
192
|
* `abortSignal` (the turn's) reaches every check, so a slow judge or
|
|
182
|
-
* pack check stops when the turn does.
|
|
193
|
+
* pack check stops when the turn does. `usage` (the turn's sink) records
|
|
194
|
+
* every llm-judge call, as the turn's own model calls are.
|
|
183
195
|
*/
|
|
184
196
|
export async function evaluateGate(
|
|
185
197
|
guardrails: readonly Guardrail[],
|
|
@@ -187,6 +199,7 @@ export async function evaluateGate(
|
|
|
187
199
|
bindings: GuardrailsBindings,
|
|
188
200
|
tenantPolicy?: TenantPolicy,
|
|
189
201
|
abortSignal?: AbortSignal,
|
|
202
|
+
usage?: UsageSink,
|
|
190
203
|
): Promise<readonly EvaluationOutcome[]> {
|
|
191
204
|
if (guardrails.length === 0 || bindings.checks === undefined) return [];
|
|
192
205
|
const evalBindings: EvaluationBindings = {
|
|
@@ -194,6 +207,7 @@ export async function evaluateGate(
|
|
|
194
207
|
...(bindings.compliance !== undefined && { compliance: bindings.compliance }),
|
|
195
208
|
...(tenantPolicy !== undefined && { tenantPolicy }),
|
|
196
209
|
...(abortSignal !== undefined && { abortSignal }),
|
|
210
|
+
...(usage !== undefined && { usage }),
|
|
197
211
|
};
|
|
198
212
|
return await evaluateAll(guardrails, bindings.checks, trace, evalBindings);
|
|
199
213
|
}
|
package/src/handlers/context.ts
CHANGED
|
@@ -143,6 +143,20 @@ export interface TurnContext {
|
|
|
143
143
|
* Present only when the builder was wired AND persistence succeeded.
|
|
144
144
|
*/
|
|
145
145
|
persistedProvenance?: import('@kindgi/provenance').Provenance;
|
|
146
|
+
/**
|
|
147
|
+
* This turn's tool results so far, by invocation id: a model call read
|
|
148
|
+
* them all (they're in its input), so its provenance node is
|
|
149
|
+
* `influenced-by` each. Filled by `dispatch-tools`, and by the rebuild
|
|
150
|
+
* of a resumed turn.
|
|
151
|
+
*/
|
|
152
|
+
toolResultIds?: string[];
|
|
153
|
+
/**
|
|
154
|
+
* The tool-call approvals this turn's journal shows decided, by
|
|
155
|
+
* invocation id: each call's provenance shows the approval it waited on.
|
|
156
|
+
* Populated by `rehydrateTurnContext` (a decision only reaches a turn
|
|
157
|
+
* that parked, and resumes).
|
|
158
|
+
*/
|
|
159
|
+
toolApprovals?: ReadonlyMap<string, import('./turn-provenance.js').ToolApproval>;
|
|
146
160
|
/**
|
|
147
161
|
* The tenant policy this turn's model was routed under (bound policy
|
|
148
162
|
* merged with the policy registry's). Populated by `setup`; guardrail
|