@kindgi/agents 0.0.0-bootstrap.0 → 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/LICENSE +201 -0
- package/README.md +131 -2
- package/dist/agent-turn-flow.d.ts +57 -0
- package/dist/agent-turn-flow.d.ts.map +1 -0
- package/dist/agent-turn-flow.js +172 -0
- package/dist/agent-turn-flow.js.map +1 -0
- package/dist/conversation-binding.d.ts +111 -0
- package/dist/conversation-binding.d.ts.map +1 -0
- package/dist/conversation-binding.js +4 -0
- package/dist/conversation-binding.js.map +1 -0
- package/dist/define.d.ts +180 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +361 -0
- package/dist/define.js.map +1 -0
- package/dist/errors.d.ts +62 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +4 -0
- package/dist/errors.js.map +1 -0
- package/dist/guardrails-gate.d.ts +169 -0
- package/dist/guardrails-gate.d.ts.map +1 -0
- package/dist/guardrails-gate.js +202 -0
- package/dist/guardrails-gate.js.map +1 -0
- package/dist/handlers/budget-check.d.ts +22 -0
- package/dist/handlers/budget-check.d.ts.map +1 -0
- package/dist/handlers/budget-check.js +109 -0
- package/dist/handlers/budget-check.js.map +1 -0
- package/dist/handlers/build-initial-messages.d.ts +17 -0
- package/dist/handlers/build-initial-messages.d.ts.map +1 -0
- package/dist/handlers/build-initial-messages.js +86 -0
- package/dist/handlers/build-initial-messages.js.map +1 -0
- package/dist/handlers/compose-result.d.ts +10 -0
- package/dist/handlers/compose-result.d.ts.map +1 -0
- package/dist/handlers/compose-result.js +79 -0
- package/dist/handlers/compose-result.js.map +1 -0
- package/dist/handlers/constants.d.ts +8 -0
- package/dist/handlers/constants.d.ts.map +1 -0
- package/dist/handlers/constants.js +10 -0
- package/dist/handlers/constants.js.map +1 -0
- package/dist/handlers/context.d.ts +210 -0
- package/dist/handlers/context.d.ts.map +1 -0
- package/dist/handlers/context.js +4 -0
- package/dist/handlers/context.js.map +1 -0
- package/dist/handlers/dispatch-tools.d.ts +15 -0
- package/dist/handlers/dispatch-tools.d.ts.map +1 -0
- package/dist/handlers/dispatch-tools.js +511 -0
- package/dist/handlers/dispatch-tools.js.map +1 -0
- package/dist/handlers/errors.d.ts +133 -0
- package/dist/handlers/errors.d.ts.map +1 -0
- package/dist/handlers/errors.js +134 -0
- package/dist/handlers/errors.js.map +1 -0
- package/dist/handlers/evaluate-guardrails.d.ts +14 -0
- package/dist/handlers/evaluate-guardrails.d.ts.map +1 -0
- package/dist/handlers/evaluate-guardrails.js +128 -0
- package/dist/handlers/evaluate-guardrails.js.map +1 -0
- package/dist/handlers/final-iteration.d.ts +7 -0
- package/dist/handlers/final-iteration.d.ts.map +1 -0
- package/dist/handlers/final-iteration.js +26 -0
- package/dist/handlers/final-iteration.js.map +1 -0
- package/dist/handlers/index.d.ts +5 -0
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +41 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/handlers/model-call.d.ts +13 -0
- package/dist/handlers/model-call.d.ts.map +1 -0
- package/dist/handlers/model-call.js +136 -0
- package/dist/handlers/model-call.js.map +1 -0
- package/dist/handlers/persist-final-message.d.ts +14 -0
- package/dist/handlers/persist-final-message.d.ts.map +1 -0
- package/dist/handlers/persist-final-message.js +54 -0
- package/dist/handlers/persist-final-message.js.map +1 -0
- package/dist/handlers/persist-provenance.d.ts +12 -0
- package/dist/handlers/persist-provenance.d.ts.map +1 -0
- package/dist/handlers/persist-provenance.js +34 -0
- package/dist/handlers/persist-provenance.js.map +1 -0
- package/dist/handlers/persist-user-message.d.ts +15 -0
- package/dist/handlers/persist-user-message.d.ts.map +1 -0
- package/dist/handlers/persist-user-message.js +59 -0
- package/dist/handlers/persist-user-message.js.map +1 -0
- package/dist/handlers/public-types.d.ts +201 -0
- package/dist/handlers/public-types.d.ts.map +1 -0
- package/dist/handlers/public-types.js +4 -0
- package/dist/handlers/public-types.js.map +1 -0
- package/dist/handlers/rehydrate.d.ts +8 -0
- package/dist/handlers/rehydrate.d.ts.map +1 -0
- package/dist/handlers/rehydrate.js +94 -0
- package/dist/handlers/rehydrate.js.map +1 -0
- package/dist/handlers/render-prompt.d.ts +12 -0
- package/dist/handlers/render-prompt.d.ts.map +1 -0
- package/dist/handlers/render-prompt.js +41 -0
- package/dist/handlers/render-prompt.js.map +1 -0
- package/dist/handlers/resolve-tools.d.ts +10 -0
- package/dist/handlers/resolve-tools.d.ts.map +1 -0
- package/dist/handlers/resolve-tools.js +55 -0
- package/dist/handlers/resolve-tools.js.map +1 -0
- package/dist/handlers/result-shape.d.ts +94 -0
- package/dist/handlers/result-shape.d.ts.map +1 -0
- package/dist/handlers/result-shape.js +19 -0
- package/dist/handlers/result-shape.js.map +1 -0
- package/dist/handlers/run-retrievals.d.ts +10 -0
- package/dist/handlers/run-retrievals.d.ts.map +1 -0
- package/dist/handlers/run-retrievals.js +64 -0
- package/dist/handlers/run-retrievals.js.map +1 -0
- package/dist/handlers/run-snapshot.d.ts +4 -0
- package/dist/handlers/run-snapshot.d.ts.map +1 -0
- package/dist/handlers/run-snapshot.js +26 -0
- package/dist/handlers/run-snapshot.js.map +1 -0
- package/dist/handlers/setup.d.ts +25 -0
- package/dist/handlers/setup.d.ts.map +1 -0
- package/dist/handlers/setup.js +231 -0
- package/dist/handlers/setup.js.map +1 -0
- package/dist/handlers/structured-output.d.ts +38 -0
- package/dist/handlers/structured-output.d.ts.map +1 -0
- package/dist/handlers/structured-output.js +89 -0
- package/dist/handlers/structured-output.js.map +1 -0
- package/dist/handlers/tool-errors.d.ts +56 -0
- package/dist/handlers/tool-errors.d.ts.map +1 -0
- package/dist/handlers/tool-errors.js +73 -0
- package/dist/handlers/tool-errors.js.map +1 -0
- package/dist/handlers/tool-hitl.d.ts +45 -0
- package/dist/handlers/tool-hitl.d.ts.map +1 -0
- package/dist/handlers/tool-hitl.js +81 -0
- package/dist/handlers/tool-hitl.js.map +1 -0
- package/dist/handlers/turn-environment.d.ts +26 -0
- package/dist/handlers/turn-environment.d.ts.map +1 -0
- package/dist/handlers/turn-environment.js +154 -0
- package/dist/handlers/turn-environment.js.map +1 -0
- package/dist/hitl-policy.d.ts +45 -0
- package/dist/hitl-policy.d.ts.map +1 -0
- package/dist/hitl-policy.js +74 -0
- package/dist/hitl-policy.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/invoke.d.ts +36 -0
- package/dist/invoke.d.ts.map +1 -0
- package/dist/invoke.js +228 -0
- package/dist/invoke.js.map +1 -0
- package/dist/migrations-dir.d.ts +11 -0
- package/dist/migrations-dir.d.ts.map +1 -0
- package/dist/migrations-dir.js +14 -0
- package/dist/migrations-dir.js.map +1 -0
- package/dist/project-run-result.d.ts +23 -0
- package/dist/project-run-result.d.ts.map +1 -0
- package/dist/project-run-result.js +116 -0
- package/dist/project-run-result.js.map +1 -0
- package/dist/prompt.d.ts +83 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +119 -0
- package/dist/prompt.js.map +1 -0
- package/dist/provenance-emit.d.ts +44 -0
- package/dist/provenance-emit.d.ts.map +1 -0
- package/dist/provenance-emit.js +51 -0
- package/dist/provenance-emit.js.map +1 -0
- package/dist/registry.d.ts +38 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +125 -0
- package/dist/registry.js.map +1 -0
- package/dist/retrieval.d.ts +47 -0
- package/dist/retrieval.d.ts.map +1 -0
- package/dist/retrieval.js +155 -0
- package/dist/retrieval.js.map +1 -0
- package/dist/run-snapshot-binding.d.ts +77 -0
- package/dist/run-snapshot-binding.d.ts.map +1 -0
- package/dist/run-snapshot-binding.js +4 -0
- package/dist/run-snapshot-binding.js.map +1 -0
- package/dist/schema.d.ts +497 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +133 -0
- package/dist/schema.js.map +1 -0
- package/dist/streaming.d.ts +118 -0
- package/dist/streaming.d.ts.map +1 -0
- package/dist/streaming.js +17 -0
- package/dist/streaming.js.map +1 -0
- package/dist/tenant-policy.d.ts +16 -0
- package/dist/tenant-policy.d.ts.map +1 -0
- package/dist/tenant-policy.js +77 -0
- package/dist/tenant-policy.js.map +1 -0
- package/dist/types.d.ts +435 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/versioning.d.ts +29 -0
- package/dist/versioning.d.ts.map +1 -0
- package/dist/versioning.js +58 -0
- package/dist/versioning.js.map +1 -0
- package/migrations/0000_sparkling_talkback.sql +18 -0
- package/migrations/0001_tired_warhawk.sql +16 -0
- package/migrations/0002_violet_ezekiel.sql +2 -0
- package/migrations/meta/0000_snapshot.json +172 -0
- package/migrations/meta/0001_snapshot.json +275 -0
- package/migrations/meta/0002_snapshot.json +287 -0
- package/migrations/meta/_journal.json +27 -0
- package/package.json +76 -4
- package/src/agent-turn-flow.ts +183 -0
- package/src/conversation-binding.ts +147 -0
- package/src/define.ts +572 -0
- package/src/errors.ts +80 -0
- package/src/guardrails-gate.ts +342 -0
- package/src/handlers/budget-check.ts +143 -0
- package/src/handlers/build-initial-messages.ts +103 -0
- package/src/handlers/compose-result.ts +90 -0
- package/src/handlers/constants.ts +10 -0
- package/src/handlers/context.ts +226 -0
- package/src/handlers/dispatch-tools.ts +633 -0
- package/src/handlers/errors.ts +282 -0
- package/src/handlers/evaluate-guardrails.ts +153 -0
- package/src/handlers/final-iteration.ts +30 -0
- package/src/handlers/index.ts +63 -0
- package/src/handlers/model-call.ts +151 -0
- package/src/handlers/persist-final-message.ts +67 -0
- package/src/handlers/persist-provenance.ts +39 -0
- package/src/handlers/persist-user-message.ts +70 -0
- package/src/handlers/public-types.ts +209 -0
- package/src/handlers/rehydrate.ts +161 -0
- package/src/handlers/render-prompt.ts +46 -0
- package/src/handlers/resolve-tools.ts +68 -0
- package/src/handlers/result-shape.ts +113 -0
- package/src/handlers/run-retrievals.ts +77 -0
- package/src/handlers/run-snapshot.ts +44 -0
- package/src/handlers/setup.ts +269 -0
- package/src/handlers/structured-output.ts +117 -0
- package/src/handlers/tool-errors.ts +122 -0
- package/src/handlers/tool-hitl.ts +126 -0
- package/src/handlers/turn-environment.ts +191 -0
- package/src/hitl-policy.ts +128 -0
- package/src/index.ts +154 -0
- package/src/invoke.ts +299 -0
- package/src/migrations-dir.ts +17 -0
- package/src/project-run-result.ts +131 -0
- package/src/prompt.ts +185 -0
- package/src/provenance-emit.ts +100 -0
- package/src/registry.ts +164 -0
- package/src/retrieval.ts +219 -0
- package/src/run-snapshot-binding.ts +87 -0
- package/src/schema.ts +154 -0
- package/src/streaming.ts +153 -0
- package/src/tenant-policy.ts +78 -0
- package/src/types.ts +453 -0
- package/src/versioning.ts +77 -0
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "2769ef0e-69b4-4a4d-ab47-044e2f11945e",
|
|
3
|
+
"prevId": "02977280-a54a-47a9-90e9-db22e06166f2",
|
|
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
|
+
"scope": {
|
|
49
|
+
"name": "scope",
|
|
50
|
+
"type": "jsonb",
|
|
51
|
+
"primaryKey": false,
|
|
52
|
+
"notNull": true
|
|
53
|
+
},
|
|
54
|
+
"opened_at": {
|
|
55
|
+
"name": "opened_at",
|
|
56
|
+
"type": "timestamp with time zone",
|
|
57
|
+
"primaryKey": false,
|
|
58
|
+
"notNull": true,
|
|
59
|
+
"default": "now()"
|
|
60
|
+
},
|
|
61
|
+
"closed_at": {
|
|
62
|
+
"name": "closed_at",
|
|
63
|
+
"type": "timestamp with time zone",
|
|
64
|
+
"primaryKey": false,
|
|
65
|
+
"notNull": false
|
|
66
|
+
},
|
|
67
|
+
"turn_count": {
|
|
68
|
+
"name": "turn_count",
|
|
69
|
+
"type": "integer",
|
|
70
|
+
"primaryKey": false,
|
|
71
|
+
"notNull": true,
|
|
72
|
+
"default": 0
|
|
73
|
+
},
|
|
74
|
+
"last_message_at": {
|
|
75
|
+
"name": "last_message_at",
|
|
76
|
+
"type": "timestamp with time zone",
|
|
77
|
+
"primaryKey": false,
|
|
78
|
+
"notNull": false
|
|
79
|
+
},
|
|
80
|
+
"metadata": {
|
|
81
|
+
"name": "metadata",
|
|
82
|
+
"type": "jsonb",
|
|
83
|
+
"primaryKey": false,
|
|
84
|
+
"notNull": false
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"indexes": {
|
|
88
|
+
"agent_conversations_tenant_agent_idx": {
|
|
89
|
+
"name": "agent_conversations_tenant_agent_idx",
|
|
90
|
+
"columns": [
|
|
91
|
+
{
|
|
92
|
+
"expression": "tenant_id",
|
|
93
|
+
"isExpression": false,
|
|
94
|
+
"asc": true,
|
|
95
|
+
"nulls": "last"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"expression": "agent_id",
|
|
99
|
+
"isExpression": false,
|
|
100
|
+
"asc": true,
|
|
101
|
+
"nulls": "last"
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
"isUnique": false,
|
|
105
|
+
"concurrently": false,
|
|
106
|
+
"method": "btree",
|
|
107
|
+
"with": {}
|
|
108
|
+
},
|
|
109
|
+
"agent_conversations_tenant_participant_idx": {
|
|
110
|
+
"name": "agent_conversations_tenant_participant_idx",
|
|
111
|
+
"columns": [
|
|
112
|
+
{
|
|
113
|
+
"expression": "tenant_id",
|
|
114
|
+
"isExpression": false,
|
|
115
|
+
"asc": true,
|
|
116
|
+
"nulls": "last"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"expression": "participant_id",
|
|
120
|
+
"isExpression": false,
|
|
121
|
+
"asc": true,
|
|
122
|
+
"nulls": "last"
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
"isUnique": false,
|
|
126
|
+
"concurrently": false,
|
|
127
|
+
"method": "btree",
|
|
128
|
+
"with": {}
|
|
129
|
+
},
|
|
130
|
+
"agent_conversations_open_recent_idx": {
|
|
131
|
+
"name": "agent_conversations_open_recent_idx",
|
|
132
|
+
"columns": [
|
|
133
|
+
{
|
|
134
|
+
"expression": "tenant_id",
|
|
135
|
+
"isExpression": false,
|
|
136
|
+
"asc": true,
|
|
137
|
+
"nulls": "last"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"expression": "last_message_at",
|
|
141
|
+
"isExpression": false,
|
|
142
|
+
"asc": false,
|
|
143
|
+
"nulls": "last"
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
"isUnique": false,
|
|
147
|
+
"where": "\"agent_conversations\".\"closed_at\" IS NULL",
|
|
148
|
+
"concurrently": false,
|
|
149
|
+
"method": "btree",
|
|
150
|
+
"with": {}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"foreignKeys": {},
|
|
154
|
+
"compositePrimaryKeys": {},
|
|
155
|
+
"uniqueConstraints": {},
|
|
156
|
+
"policies": {},
|
|
157
|
+
"checkConstraints": {},
|
|
158
|
+
"isRLSEnabled": false
|
|
159
|
+
},
|
|
160
|
+
"public.agent_run_snapshots": {
|
|
161
|
+
"name": "agent_run_snapshots",
|
|
162
|
+
"schema": "",
|
|
163
|
+
"columns": {
|
|
164
|
+
"id": {
|
|
165
|
+
"name": "id",
|
|
166
|
+
"type": "uuid",
|
|
167
|
+
"primaryKey": true,
|
|
168
|
+
"notNull": true
|
|
169
|
+
},
|
|
170
|
+
"tenant_id": {
|
|
171
|
+
"name": "tenant_id",
|
|
172
|
+
"type": "uuid",
|
|
173
|
+
"primaryKey": false,
|
|
174
|
+
"notNull": true
|
|
175
|
+
},
|
|
176
|
+
"project_id": {
|
|
177
|
+
"name": "project_id",
|
|
178
|
+
"type": "uuid",
|
|
179
|
+
"primaryKey": false,
|
|
180
|
+
"notNull": true
|
|
181
|
+
},
|
|
182
|
+
"agent_id": {
|
|
183
|
+
"name": "agent_id",
|
|
184
|
+
"type": "text",
|
|
185
|
+
"primaryKey": false,
|
|
186
|
+
"notNull": true
|
|
187
|
+
},
|
|
188
|
+
"agent_version": {
|
|
189
|
+
"name": "agent_version",
|
|
190
|
+
"type": "text",
|
|
191
|
+
"primaryKey": false,
|
|
192
|
+
"notNull": true
|
|
193
|
+
},
|
|
194
|
+
"conversation_id": {
|
|
195
|
+
"name": "conversation_id",
|
|
196
|
+
"type": "uuid",
|
|
197
|
+
"primaryKey": false,
|
|
198
|
+
"notNull": true
|
|
199
|
+
},
|
|
200
|
+
"user_message": {
|
|
201
|
+
"name": "user_message",
|
|
202
|
+
"type": "text",
|
|
203
|
+
"primaryKey": false,
|
|
204
|
+
"notNull": true
|
|
205
|
+
},
|
|
206
|
+
"parameters": {
|
|
207
|
+
"name": "parameters",
|
|
208
|
+
"type": "jsonb",
|
|
209
|
+
"primaryKey": false,
|
|
210
|
+
"notNull": false
|
|
211
|
+
},
|
|
212
|
+
"input": {
|
|
213
|
+
"name": "input",
|
|
214
|
+
"type": "jsonb",
|
|
215
|
+
"primaryKey": false,
|
|
216
|
+
"notNull": false
|
|
217
|
+
},
|
|
218
|
+
"participant_id": {
|
|
219
|
+
"name": "participant_id",
|
|
220
|
+
"type": "text",
|
|
221
|
+
"primaryKey": false,
|
|
222
|
+
"notNull": false
|
|
223
|
+
},
|
|
224
|
+
"dry_run": {
|
|
225
|
+
"name": "dry_run",
|
|
226
|
+
"type": "integer",
|
|
227
|
+
"primaryKey": false,
|
|
228
|
+
"notNull": true,
|
|
229
|
+
"default": 0
|
|
230
|
+
},
|
|
231
|
+
"principal": {
|
|
232
|
+
"name": "principal",
|
|
233
|
+
"type": "jsonb",
|
|
234
|
+
"primaryKey": false,
|
|
235
|
+
"notNull": false
|
|
236
|
+
},
|
|
237
|
+
"authz": {
|
|
238
|
+
"name": "authz",
|
|
239
|
+
"type": "jsonb",
|
|
240
|
+
"primaryKey": false,
|
|
241
|
+
"notNull": false
|
|
242
|
+
},
|
|
243
|
+
"created_at": {
|
|
244
|
+
"name": "created_at",
|
|
245
|
+
"type": "timestamp with time zone",
|
|
246
|
+
"primaryKey": false,
|
|
247
|
+
"notNull": true,
|
|
248
|
+
"default": "now()"
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
"indexes": {
|
|
252
|
+
"agent_run_snapshots_tenant_idx": {
|
|
253
|
+
"name": "agent_run_snapshots_tenant_idx",
|
|
254
|
+
"columns": [
|
|
255
|
+
{
|
|
256
|
+
"expression": "tenant_id",
|
|
257
|
+
"isExpression": false,
|
|
258
|
+
"asc": true,
|
|
259
|
+
"nulls": "last"
|
|
260
|
+
}
|
|
261
|
+
],
|
|
262
|
+
"isUnique": false,
|
|
263
|
+
"concurrently": false,
|
|
264
|
+
"method": "btree",
|
|
265
|
+
"with": {}
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
"foreignKeys": {},
|
|
269
|
+
"compositePrimaryKeys": {},
|
|
270
|
+
"uniqueConstraints": {},
|
|
271
|
+
"policies": {},
|
|
272
|
+
"checkConstraints": {},
|
|
273
|
+
"isRLSEnabled": false
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
"enums": {},
|
|
277
|
+
"schemas": {},
|
|
278
|
+
"sequences": {},
|
|
279
|
+
"roles": {},
|
|
280
|
+
"policies": {},
|
|
281
|
+
"views": {},
|
|
282
|
+
"_meta": {
|
|
283
|
+
"columns": {},
|
|
284
|
+
"schemas": {},
|
|
285
|
+
"tables": {}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "7",
|
|
3
|
+
"dialect": "postgresql",
|
|
4
|
+
"entries": [
|
|
5
|
+
{
|
|
6
|
+
"idx": 0,
|
|
7
|
+
"version": "7",
|
|
8
|
+
"when": 1789708941765,
|
|
9
|
+
"tag": "0000_sparkling_talkback",
|
|
10
|
+
"breakpoints": true
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"idx": 1,
|
|
14
|
+
"version": "7",
|
|
15
|
+
"when": 1790270079710,
|
|
16
|
+
"tag": "0001_tired_warhawk",
|
|
17
|
+
"breakpoints": true
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"idx": 2,
|
|
21
|
+
"version": "7",
|
|
22
|
+
"when": 1790813765675,
|
|
23
|
+
"tag": "0002_violet_ezekiel",
|
|
24
|
+
"breakpoints": true
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,79 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kindgi/agents",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.0",
|
|
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
|
-
"repository": {
|
|
7
|
-
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/kindgi/kindgi-sdk.git",
|
|
9
|
+
"directory": "packages/agents"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/kindgi/kindgi-sdk/tree/main/packages/agents#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/kindgi/kindgi-sdk/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"src",
|
|
27
|
+
"migrations",
|
|
28
|
+
"README.md",
|
|
29
|
+
"SPEC.md",
|
|
30
|
+
"type-manifest.json"
|
|
31
|
+
],
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@kindgi/authz": "0.1.0",
|
|
34
|
+
"@kindgi/capabilities": "0.1.0",
|
|
35
|
+
"@kindgi/compliance": "0.1.0",
|
|
36
|
+
"@kindgi/embedding": "0.1.0",
|
|
37
|
+
"@kindgi/flow": "0.1.0",
|
|
38
|
+
"@kindgi/handler": "0.1.0",
|
|
39
|
+
"@kindgi/guardrails": "0.1.0",
|
|
40
|
+
"@kindgi/memory": "0.1.0",
|
|
41
|
+
"@kindgi/policy-contract": "0.1.0",
|
|
42
|
+
"@kindgi/provenance": "0.1.0",
|
|
43
|
+
"@kindgi/runtime": "0.1.0",
|
|
44
|
+
"@kindgi/schema": "0.1.0",
|
|
45
|
+
"@kindgi/tools": "0.1.0",
|
|
46
|
+
"@kindgi/types": "0.1.0",
|
|
47
|
+
"drizzle-orm": "^0.36.4",
|
|
48
|
+
"liquidjs": "^10.29.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"zod": "^4.0.0"
|
|
52
|
+
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"zod": {
|
|
55
|
+
"optional": true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/node": "^22.10.5",
|
|
60
|
+
"drizzle-kit": "^0.30.1",
|
|
61
|
+
"typescript": "^5.7.3",
|
|
62
|
+
"vitest": "^2.1.8",
|
|
63
|
+
"zod": "^4.6.5"
|
|
64
|
+
},
|
|
65
|
+
"engines": {
|
|
66
|
+
"node": ">=22.0.0"
|
|
67
|
+
},
|
|
68
|
+
"publishConfig": {
|
|
69
|
+
"access": "public",
|
|
70
|
+
"provenance": true
|
|
71
|
+
},
|
|
72
|
+
"scripts": {
|
|
73
|
+
"build": "tsc -p tsconfig.build.json",
|
|
74
|
+
"typecheck": "tsc --noEmit",
|
|
75
|
+
"test": "vitest run",
|
|
76
|
+
"clean": "rm -rf dist *.tsbuildinfo",
|
|
77
|
+
"db:generate": "drizzle-kit generate"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
|
|
4
|
+
import type { Flow } from '@kindgi/flow';
|
|
5
|
+
import { loadFlow } from '@kindgi/flow';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The versioned agent-turn flow. Every agent turn — regardless of which
|
|
9
|
+
* concrete `Agent` is being invoked — executes as a run of this flow
|
|
10
|
+
* against handlers that close over the specific agent + bindings + input.
|
|
11
|
+
*
|
|
12
|
+
* Shape (uses the kernel loop primitive for the model↔tool cycle):
|
|
13
|
+
*
|
|
14
|
+
* ```
|
|
15
|
+
* $start → setup → render-prompt → persist-user-message → run-retrievals
|
|
16
|
+
* → build-initial-messages → agent-loop (kernel loop node)
|
|
17
|
+
* → evaluate-guardrails → persist-final-message → persist-provenance
|
|
18
|
+
* → compose-result → $end
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Guardrails run on the final response before it is stored: a response
|
|
22
|
+
* a blocking guardrail rejects never reaches the conversation.
|
|
23
|
+
*
|
|
24
|
+
* `agent-loop` is a `while+after` (do-while) loop; its body is
|
|
25
|
+
* `$loop-start → model-call → dispatch-tools → budget-check → $loop-end`.
|
|
26
|
+
* Exit condition: `iterationOutput.finishedTurn === true`.
|
|
27
|
+
* `collectAllIterations: true` so post-loop nodes can aggregate every
|
|
28
|
+
* iteration's per-iteration usage + appended messages.
|
|
29
|
+
*
|
|
30
|
+
* Version-locked so historical runs pin to this shape; any
|
|
31
|
+
* change to the node set or body sub-flow bumps the version and
|
|
32
|
+
* `resumeRun` refuses to resume old runs against a new flow.
|
|
33
|
+
*/
|
|
34
|
+
export const AGENT_TURN_FLOW_ID = 'agent.turn';
|
|
35
|
+
export const AGENT_TURN_FLOW_VERSION = '1.1.0';
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Safety cap for iterations. Per-agent `maxSteps` is enforced by the
|
|
39
|
+
* `budget-check` body node — this constant only bounds catastrophic
|
|
40
|
+
* runaway (model always requests a tool call, no budget-check, no
|
|
41
|
+
* agent config). Set high enough that no real agent will hit it.
|
|
42
|
+
*/
|
|
43
|
+
export const AGENT_TURN_LOOP_MAX_ITERATIONS = 32;
|
|
44
|
+
|
|
45
|
+
// Outer node ids.
|
|
46
|
+
export const SETUP_NODE = 'setup';
|
|
47
|
+
export const RENDER_PROMPT_NODE = 'render-prompt';
|
|
48
|
+
export const PERSIST_USER_MESSAGE_NODE = 'persist-user-message';
|
|
49
|
+
export const RUN_RETRIEVALS_NODE = 'run-retrievals';
|
|
50
|
+
export const BUILD_INITIAL_MESSAGES_NODE = 'build-initial-messages';
|
|
51
|
+
export const AGENT_LOOP_NODE = 'agent-loop';
|
|
52
|
+
export const PERSIST_FINAL_MESSAGE_NODE = 'persist-final-message';
|
|
53
|
+
export const EVALUATE_GUARDRAILS_NODE = 'evaluate-guardrails';
|
|
54
|
+
export const PERSIST_PROVENANCE_NODE = 'persist-provenance';
|
|
55
|
+
export const COMPOSE_RESULT_NODE = 'compose-result';
|
|
56
|
+
|
|
57
|
+
// Loop body node ids.
|
|
58
|
+
export const MODEL_CALL_NODE = 'model-call';
|
|
59
|
+
export const DISPATCH_TOOLS_NODE = 'dispatch-tools';
|
|
60
|
+
export const BUDGET_CHECK_NODE = 'budget-check';
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* JSON Schema (draft 2020-12) for each iteration's `$loop-end` output.
|
|
64
|
+
* See `AgentTurnIterationOutput` in the handlers module for the TS
|
|
65
|
+
* mirror.
|
|
66
|
+
*/
|
|
67
|
+
const iterationOutputSchema = {
|
|
68
|
+
type: 'object',
|
|
69
|
+
additionalProperties: false,
|
|
70
|
+
required: [
|
|
71
|
+
'finishReason',
|
|
72
|
+
'message',
|
|
73
|
+
'iterationAppended',
|
|
74
|
+
'iterationUsage',
|
|
75
|
+
'provider',
|
|
76
|
+
'finishedTurn',
|
|
77
|
+
'nextMessages',
|
|
78
|
+
],
|
|
79
|
+
properties: {
|
|
80
|
+
finishReason: {
|
|
81
|
+
type: 'string',
|
|
82
|
+
enum: ['stop', 'length', 'tool-use', 'content-filter', 'error'],
|
|
83
|
+
},
|
|
84
|
+
message: { type: 'object' },
|
|
85
|
+
iterationAppended: { type: 'array' },
|
|
86
|
+
iterationUsage: {
|
|
87
|
+
type: 'object',
|
|
88
|
+
additionalProperties: false,
|
|
89
|
+
required: ['promptTokens', 'completionTokens', 'costUsd'],
|
|
90
|
+
properties: {
|
|
91
|
+
promptTokens: { type: 'integer', minimum: 0 },
|
|
92
|
+
completionTokens: { type: 'integer', minimum: 0 },
|
|
93
|
+
costUsd: { type: 'number', minimum: 0 },
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
provider: {
|
|
97
|
+
type: 'object',
|
|
98
|
+
additionalProperties: false,
|
|
99
|
+
required: ['id', 'model'],
|
|
100
|
+
properties: {
|
|
101
|
+
id: { type: 'string' },
|
|
102
|
+
model: { type: 'string' },
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
finishedTurn: { type: 'boolean' },
|
|
106
|
+
nextMessages: { type: 'array' },
|
|
107
|
+
/** Populated when finishReason='error' from budget-check or dispatch failure. */
|
|
108
|
+
errorPayload: { type: 'object' },
|
|
109
|
+
},
|
|
110
|
+
} as const;
|
|
111
|
+
|
|
112
|
+
const rawGraph = {
|
|
113
|
+
id: AGENT_TURN_FLOW_ID,
|
|
114
|
+
version: AGENT_TURN_FLOW_VERSION,
|
|
115
|
+
name: 'Agent turn',
|
|
116
|
+
description:
|
|
117
|
+
'Framework-grade agent turn execution. One run per turn. Model↔tool cycle uses the kernel loop primitive.',
|
|
118
|
+
nodes: [
|
|
119
|
+
{ id: SETUP_NODE, kind: 'tool', ref: 'inline' },
|
|
120
|
+
{ id: RENDER_PROMPT_NODE, kind: 'tool', ref: 'inline' },
|
|
121
|
+
{ id: PERSIST_USER_MESSAGE_NODE, kind: 'tool', ref: 'inline' },
|
|
122
|
+
{ id: RUN_RETRIEVALS_NODE, kind: 'tool', ref: 'inline' },
|
|
123
|
+
{ id: BUILD_INITIAL_MESSAGES_NODE, kind: 'tool', ref: 'inline' },
|
|
124
|
+
{
|
|
125
|
+
id: AGENT_LOOP_NODE,
|
|
126
|
+
kind: 'loop',
|
|
127
|
+
loopKind: 'while',
|
|
128
|
+
evaluationTiming: 'after',
|
|
129
|
+
maxIterations: AGENT_TURN_LOOP_MAX_ITERATIONS,
|
|
130
|
+
exitCondition: {
|
|
131
|
+
op: 'truthy',
|
|
132
|
+
value: { path: 'iterationOutput.finishedTurn' },
|
|
133
|
+
},
|
|
134
|
+
outputSchema: iterationOutputSchema,
|
|
135
|
+
collectAllIterations: true,
|
|
136
|
+
body: {
|
|
137
|
+
nodes: [
|
|
138
|
+
{ id: MODEL_CALL_NODE, kind: 'tool', ref: 'inline' },
|
|
139
|
+
{ id: DISPATCH_TOOLS_NODE, kind: 'tool', ref: 'inline' },
|
|
140
|
+
{ id: BUDGET_CHECK_NODE, kind: 'tool', ref: 'inline' },
|
|
141
|
+
],
|
|
142
|
+
edges: [
|
|
143
|
+
{ id: 'body-e1', from: '$loop-start', to: MODEL_CALL_NODE },
|
|
144
|
+
{ id: 'body-e2', from: MODEL_CALL_NODE, to: DISPATCH_TOOLS_NODE },
|
|
145
|
+
{ id: 'body-e3', from: DISPATCH_TOOLS_NODE, to: BUDGET_CHECK_NODE },
|
|
146
|
+
{ id: 'body-e4', from: BUDGET_CHECK_NODE, to: '$loop-end' },
|
|
147
|
+
],
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
{ id: EVALUATE_GUARDRAILS_NODE, kind: 'tool', ref: 'inline' },
|
|
151
|
+
{ id: PERSIST_FINAL_MESSAGE_NODE, kind: 'tool', ref: 'inline' },
|
|
152
|
+
{ id: PERSIST_PROVENANCE_NODE, kind: 'tool', ref: 'inline' },
|
|
153
|
+
{ id: COMPOSE_RESULT_NODE, kind: 'tool', ref: 'inline' },
|
|
154
|
+
],
|
|
155
|
+
edges: [
|
|
156
|
+
{ id: 'e0', from: '$start', to: SETUP_NODE },
|
|
157
|
+
{ id: 'e1', from: SETUP_NODE, to: RENDER_PROMPT_NODE },
|
|
158
|
+
{ id: 'e2', from: RENDER_PROMPT_NODE, to: PERSIST_USER_MESSAGE_NODE },
|
|
159
|
+
{ id: 'e3', from: PERSIST_USER_MESSAGE_NODE, to: RUN_RETRIEVALS_NODE },
|
|
160
|
+
{ id: 'e4', from: RUN_RETRIEVALS_NODE, to: BUILD_INITIAL_MESSAGES_NODE },
|
|
161
|
+
{ id: 'e5', from: BUILD_INITIAL_MESSAGES_NODE, to: AGENT_LOOP_NODE },
|
|
162
|
+
{ id: 'e6', from: AGENT_LOOP_NODE, to: EVALUATE_GUARDRAILS_NODE },
|
|
163
|
+
{ id: 'e7', from: EVALUATE_GUARDRAILS_NODE, to: PERSIST_FINAL_MESSAGE_NODE },
|
|
164
|
+
{ id: 'e8', from: PERSIST_FINAL_MESSAGE_NODE, to: PERSIST_PROVENANCE_NODE },
|
|
165
|
+
{ id: 'e9', from: PERSIST_PROVENANCE_NODE, to: COMPOSE_RESULT_NODE },
|
|
166
|
+
{ id: 'e10', from: COMPOSE_RESULT_NODE, to: '$end' },
|
|
167
|
+
],
|
|
168
|
+
} as const;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* The compiled + validated flow. Cached — the loader is called once
|
|
172
|
+
* at module load. Throws on module load if the constant is malformed
|
|
173
|
+
* (should be caught by tests immediately).
|
|
174
|
+
*/
|
|
175
|
+
export const AGENT_TURN_FLOW: Flow = (() => {
|
|
176
|
+
const r = loadFlow(rawGraph);
|
|
177
|
+
if (r.kind === 'err') {
|
|
178
|
+
throw new Error(
|
|
179
|
+
`AGENT_TURN_FLOW failed to load — this is a bug in agent-turn-flow.ts: ${JSON.stringify(r.error)}`,
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
return r.value;
|
|
183
|
+
})();
|