@inkeep/agents-core 0.41.2 → 0.42.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/dist/api-client/base-client.d.ts +87 -8
- package/dist/api-client/base-client.js +174 -1
- package/dist/api-client/eval-api-client.d.ts +47 -0
- package/dist/api-client/eval-api-client.js +65 -0
- package/dist/api-client/index.d.ts +4 -0
- package/dist/api-client/index.js +5 -0
- package/dist/api-client/manage-api-client.d.ts +34 -0
- package/dist/api-client/manage-api-client.js +104 -0
- package/dist/auth/auth.d.ts +86 -20
- package/dist/auth/auth.js +55 -1
- package/dist/auth/authz/client.d.ts +81 -0
- package/dist/auth/authz/client.js +189 -0
- package/dist/auth/authz/config.d.ts +76 -0
- package/dist/auth/authz/config.js +76 -0
- package/dist/auth/authz/index.d.ts +5 -0
- package/dist/auth/authz/index.js +6 -0
- package/dist/auth/authz/permissions.d.ts +57 -0
- package/dist/auth/authz/permissions.js +83 -0
- package/dist/auth/authz/sync.d.ts +85 -0
- package/dist/auth/authz/sync.js +237 -0
- package/dist/auth/permissions.d.ts +13 -13
- package/dist/auth/permissions.js +2 -181
- package/dist/client-exports.d.ts +8 -3
- package/dist/client-exports.js +3 -2
- package/dist/constants/context-breakdown.d.ts +61 -0
- package/dist/constants/context-breakdown.js +124 -0
- package/dist/constants/otel-attributes.d.ts +4 -0
- package/dist/constants/otel-attributes.js +4 -0
- package/dist/context/ContextConfig.d.ts +2 -2
- package/dist/context/ContextConfig.js +3 -3
- package/dist/context/TemplateEngine.js +0 -1
- package/dist/context/index.d.ts +1 -5
- package/dist/context/index.js +1 -5
- package/dist/credential-stuffer/CredentialStuffer.d.ts +1 -1
- package/dist/data-access/index.d.ts +34 -26
- package/dist/data-access/index.js +34 -26
- package/dist/data-access/manage/agentFull.d.ts +36 -0
- package/dist/data-access/{agentFull.js → manage/agentFull.js} +205 -7
- package/dist/data-access/{agents.d.ts → manage/agents.d.ts} +23 -22
- package/dist/data-access/{agents.js → manage/agents.js} +52 -7
- package/dist/data-access/{artifactComponents.d.ts → manage/artifactComponents.d.ts} +21 -21
- package/dist/data-access/{artifactComponents.js → manage/artifactComponents.js} +5 -5
- package/dist/data-access/{contextConfigs.d.ts → manage/contextConfigs.d.ts} +14 -14
- package/dist/data-access/{contextConfigs.js → manage/contextConfigs.js} +3 -3
- package/dist/data-access/{credentialReferences.d.ts → manage/credentialReferences.d.ts} +17 -17
- package/dist/data-access/{credentialReferences.js → manage/credentialReferences.js} +2 -2
- package/dist/data-access/{dataComponents.d.ts → manage/dataComponents.d.ts} +20 -20
- package/dist/data-access/{dataComponents.js → manage/dataComponents.js} +7 -7
- package/dist/data-access/manage/evalConfig.d.ts +221 -0
- package/dist/data-access/manage/evalConfig.js +275 -0
- package/dist/data-access/{externalAgents.d.ts → manage/externalAgents.d.ts} +16 -16
- package/dist/data-access/{externalAgents.js → manage/externalAgents.js} +2 -2
- package/dist/data-access/{functionTools.d.ts → manage/functionTools.d.ts} +65 -15
- package/dist/data-access/{functionTools.js → manage/functionTools.js} +90 -8
- package/dist/data-access/{functions.d.ts → manage/functions.d.ts} +9 -9
- package/dist/data-access/{functions.js → manage/functions.js} +3 -3
- package/dist/data-access/manage/projectFull.d.ts +38 -0
- package/dist/data-access/{projectFull.js → manage/projectFull.js} +64 -65
- package/dist/data-access/manage/projectLifecycle.d.ts +119 -0
- package/dist/data-access/manage/projectLifecycle.js +234 -0
- package/dist/data-access/manage/projects.d.ts +75 -0
- package/dist/data-access/{projects.js → manage/projects.js} +15 -16
- package/dist/data-access/{subAgentExternalAgentRelations.d.ts → manage/subAgentExternalAgentRelations.d.ts} +19 -19
- package/dist/data-access/{subAgentExternalAgentRelations.js → manage/subAgentExternalAgentRelations.js} +2 -2
- package/dist/data-access/{subAgentRelations.d.ts → manage/subAgentRelations.d.ts} +29 -29
- package/dist/data-access/{subAgentRelations.js → manage/subAgentRelations.js} +3 -3
- package/dist/data-access/{subAgentTeamAgentRelations.d.ts → manage/subAgentTeamAgentRelations.d.ts} +19 -19
- package/dist/data-access/{subAgentTeamAgentRelations.js → manage/subAgentTeamAgentRelations.js} +2 -2
- package/dist/data-access/{subAgents.d.ts → manage/subAgents.d.ts} +13 -13
- package/dist/data-access/{subAgents.js → manage/subAgents.js} +4 -4
- package/dist/data-access/{tools.d.ts → manage/tools.d.ts} +26 -19
- package/dist/data-access/{tools.js → manage/tools.js} +57 -35
- package/dist/data-access/manage/triggers.d.ts +80 -0
- package/dist/data-access/manage/triggers.js +81 -0
- package/dist/data-access/{apiKeys.d.ts → runtime/apiKeys.d.ts} +17 -17
- package/dist/data-access/{apiKeys.js → runtime/apiKeys.js} +3 -3
- package/dist/data-access/runtime/cascade-delete.d.ts +77 -0
- package/dist/data-access/runtime/cascade-delete.js +111 -0
- package/dist/data-access/{contextCache.d.ts → runtime/contextCache.d.ts} +13 -13
- package/dist/data-access/{contextCache.js → runtime/contextCache.js} +5 -5
- package/dist/data-access/{conversations.d.ts → runtime/conversations.d.ts} +68 -19
- package/dist/data-access/{conversations.js → runtime/conversations.js} +13 -7
- package/dist/data-access/runtime/evalRuns.d.ts +120 -0
- package/dist/data-access/runtime/evalRuns.js +168 -0
- package/dist/data-access/{ledgerArtifacts.d.ts → runtime/ledgerArtifacts.d.ts} +13 -13
- package/dist/data-access/{ledgerArtifacts.js → runtime/ledgerArtifacts.js} +3 -3
- package/dist/data-access/{messages.d.ts → runtime/messages.d.ts} +15 -15
- package/dist/data-access/{messages.js → runtime/messages.js} +2 -2
- package/dist/data-access/{organizations.d.ts → runtime/organizations.d.ts} +16 -7
- package/dist/data-access/{organizations.js → runtime/organizations.js} +15 -3
- package/dist/data-access/runtime/projects.d.ts +62 -0
- package/dist/data-access/runtime/projects.js +90 -0
- package/dist/data-access/runtime/tasks.d.ts +55 -0
- package/dist/data-access/{tasks.js → runtime/tasks.js} +2 -2
- package/dist/data-access/runtime/triggerInvocations.d.ts +62 -0
- package/dist/data-access/runtime/triggerInvocations.js +54 -0
- package/dist/data-access/runtime/users.d.ts +19 -0
- package/dist/data-access/{users.js → runtime/users.js} +2 -2
- package/dist/data-access/validation.d.ts +4 -4
- package/dist/data-access/validation.js +1 -1
- package/dist/db/clean.d.ts +8 -4
- package/dist/db/clean.js +14 -105
- package/dist/db/delete.d.ts +1 -1
- package/dist/db/delete.js +7 -10
- package/dist/db/manage/dolt-cleanup.d.ts +51 -0
- package/dist/db/manage/dolt-cleanup.js +132 -0
- package/dist/db/manage/manage-client.d.ts +26 -0
- package/dist/db/manage/manage-client.js +68 -0
- package/dist/db/{schema.d.ts → manage/manage-schema.d.ts} +1459 -1285
- package/dist/db/{schema.js → manage/manage-schema.js} +433 -341
- package/dist/db/manage/test-manage-client.d.ts +27 -0
- package/dist/db/manage/test-manage-client.js +68 -0
- package/dist/db/runtime/runtime-client.d.ts +20 -0
- package/dist/db/runtime/runtime-client.js +30 -0
- package/dist/db/runtime/runtime-schema.d.ts +2834 -0
- package/dist/db/runtime/runtime-schema.js +483 -0
- package/dist/db/runtime/test-runtime-client.d.ts +27 -0
- package/dist/db/{test-client.js → runtime/test-runtime-client.js} +11 -25
- package/dist/dolt/branch.d.ts +62 -0
- package/dist/dolt/branch.js +82 -0
- package/dist/dolt/branches-api.d.ts +108 -0
- package/dist/dolt/branches-api.js +162 -0
- package/dist/dolt/commit.d.ts +94 -0
- package/dist/dolt/commit.js +103 -0
- package/dist/dolt/diff.d.ts +27 -0
- package/dist/dolt/diff.js +21 -0
- package/dist/dolt/index.d.ts +10 -0
- package/dist/dolt/index.js +11 -0
- package/dist/dolt/merge.d.ts +63 -0
- package/dist/dolt/merge.js +81 -0
- package/dist/dolt/migrate-all-branches.d.ts +4 -0
- package/dist/dolt/migrate-all-branches.js +78 -0
- package/dist/dolt/migrate-dolt.d.ts +1 -0
- package/dist/dolt/migrate-dolt.js +22 -0
- package/dist/dolt/ref-helpers.d.ts +19 -0
- package/dist/dolt/ref-helpers.js +65 -0
- package/dist/dolt/ref-middleware.d.ts +82 -0
- package/dist/dolt/ref-middleware.js +217 -0
- package/dist/dolt/ref-scope.d.ts +101 -0
- package/dist/dolt/ref-scope.js +231 -0
- package/dist/dolt/schema-sync.d.ts +134 -0
- package/dist/dolt/schema-sync.js +246 -0
- package/dist/env.d.ts +6 -4
- package/dist/env.js +3 -2
- package/dist/index.d.ts +71 -44
- package/dist/index.js +74 -47
- package/dist/types/entities.d.ts +81 -2
- package/dist/types/index.d.ts +3 -3
- package/dist/types/utility.d.ts +45 -4
- package/dist/utils/JsonTransformer.d.ts +44 -0
- package/dist/utils/JsonTransformer.js +112 -0
- package/dist/utils/apiKeys.d.ts +5 -1
- package/dist/utils/apiKeys.js +11 -1
- package/dist/utils/colors.d.ts +34 -0
- package/dist/utils/colors.js +49 -0
- package/dist/utils/credential-store-utils.d.ts +1 -1
- package/dist/utils/format-messages.d.ts +1 -1
- package/dist/utils/index.d.ts +7 -3
- package/dist/utils/index.js +7 -3
- package/dist/utils/internal-service-auth.d.ts +79 -0
- package/dist/utils/internal-service-auth.js +140 -0
- package/dist/utils/jwt-helpers.d.ts +56 -0
- package/dist/utils/jwt-helpers.js +90 -0
- package/dist/utils/service-token-auth.d.ts +9 -27
- package/dist/utils/service-token-auth.js +48 -96
- package/dist/utils/template-interpolation.d.ts +22 -0
- package/dist/utils/template-interpolation.js +62 -0
- package/dist/utils/third-party-mcp-servers/composio-client.js +23 -23
- package/dist/utils/trigger-auth.d.ts +62 -0
- package/dist/utils/trigger-auth.js +125 -0
- package/dist/validation/agentFull.js +2 -4
- package/dist/validation/dolt-schemas.d.ts +49 -0
- package/dist/validation/dolt-schemas.js +44 -0
- package/dist/validation/drizzle-schema-helpers.d.ts +4 -26
- package/dist/validation/drizzle-schema-helpers.js +5 -151
- package/dist/validation/index.d.ts +4 -3
- package/dist/validation/index.js +3 -2
- package/dist/validation/schemas.d.ts +17647 -4789
- package/dist/validation/schemas.js +328 -11
- package/drizzle/manage/0000_tearful_rhodey.sql +414 -0
- package/drizzle/manage/0001_broken_wendell_vaughn.sql +19 -0
- package/drizzle/manage/0002_bent_sunfire.sql +1 -0
- package/drizzle/manage/meta/0000_snapshot.json +2987 -0
- package/drizzle/manage/meta/0001_snapshot.json +3115 -0
- package/drizzle/manage/meta/0002_snapshot.json +3115 -0
- package/drizzle/manage/meta/_journal.json +27 -0
- package/drizzle/runtime/0008_silly_preak.sql +127 -0
- package/drizzle/runtime/0009_freezing_leo.sql +17 -0
- package/drizzle/runtime/meta/0008_snapshot.json +2263 -0
- package/drizzle/runtime/meta/0009_snapshot.json +2397 -0
- package/drizzle/{meta → runtime/meta}/_journal.json +14 -0
- package/package.json +48 -15
- package/dist/context/ContextFetcher.d.ts +0 -73
- package/dist/context/ContextFetcher.js +0 -291
- package/dist/context/ContextResolver.d.ts +0 -60
- package/dist/context/ContextResolver.js +0 -278
- package/dist/context/context.d.ts +0 -27
- package/dist/context/context.js +0 -128
- package/dist/context/contextCache.d.ts +0 -58
- package/dist/context/contextCache.js +0 -177
- package/dist/data-access/agentFull.d.ts +0 -33
- package/dist/data-access/projectFull.d.ts +0 -32
- package/dist/data-access/projects.d.ts +0 -71
- package/dist/data-access/tasks.d.ts +0 -45
- package/dist/data-access/users.d.ts +0 -19
- package/dist/db/client.d.ts +0 -20
- package/dist/db/client.js +0 -28
- package/dist/db/test-client.d.ts +0 -31
- package/dist/middleware/contextValidation.d.ts +0 -46
- package/dist/middleware/contextValidation.js +0 -280
- package/dist/middleware/index.d.ts +0 -2
- package/dist/middleware/index.js +0 -3
- package/dist/utils/execution.d.ts +0 -22
- package/dist/utils/execution.js +0 -25
- /package/drizzle/{0000_exotic_mysterio.sql → runtime/0000_exotic_mysterio.sql} +0 -0
- /package/drizzle/{0001_calm_sheva_callister.sql → runtime/0001_calm_sheva_callister.sql} +0 -0
- /package/drizzle/{0002_puzzling_goblin_queen.sql → runtime/0002_puzzling_goblin_queen.sql} +0 -0
- /package/drizzle/{0003_sweet_human_robot.sql → runtime/0003_sweet_human_robot.sql} +0 -0
- /package/drizzle/{0004_cuddly_shooting_star.sql → runtime/0004_cuddly_shooting_star.sql} +0 -0
- /package/drizzle/{0005_reflective_starfox.sql → runtime/0005_reflective_starfox.sql} +0 -0
- /package/drizzle/{0006_stale_thaddeus_ross.sql → runtime/0006_stale_thaddeus_ross.sql} +0 -0
- /package/drizzle/{0007_slim_karma.sql → runtime/0007_slim_karma.sql} +0 -0
- /package/drizzle/{meta → runtime/meta}/0000_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0001_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0003_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0005_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0006_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0007_snapshot.json +0 -0
package/dist/auth/permissions.js
CHANGED
|
@@ -10,138 +10,19 @@ const statement = {
|
|
|
10
10
|
"read",
|
|
11
11
|
"update",
|
|
12
12
|
"delete"
|
|
13
|
-
],
|
|
14
|
-
agent: [
|
|
15
|
-
"create",
|
|
16
|
-
"read",
|
|
17
|
-
"update",
|
|
18
|
-
"delete"
|
|
19
|
-
],
|
|
20
|
-
sub_agent: [
|
|
21
|
-
"create",
|
|
22
|
-
"read",
|
|
23
|
-
"update",
|
|
24
|
-
"delete"
|
|
25
|
-
],
|
|
26
|
-
tool: [
|
|
27
|
-
"create",
|
|
28
|
-
"read",
|
|
29
|
-
"update",
|
|
30
|
-
"delete"
|
|
31
|
-
],
|
|
32
|
-
api_key: [
|
|
33
|
-
"create",
|
|
34
|
-
"read",
|
|
35
|
-
"update",
|
|
36
|
-
"delete"
|
|
37
|
-
],
|
|
38
|
-
credential: [
|
|
39
|
-
"create",
|
|
40
|
-
"read",
|
|
41
|
-
"update",
|
|
42
|
-
"delete"
|
|
43
|
-
],
|
|
44
|
-
data_component: [
|
|
45
|
-
"create",
|
|
46
|
-
"read",
|
|
47
|
-
"update",
|
|
48
|
-
"delete"
|
|
49
|
-
],
|
|
50
|
-
artifact_component: [
|
|
51
|
-
"create",
|
|
52
|
-
"read",
|
|
53
|
-
"update",
|
|
54
|
-
"delete"
|
|
55
|
-
],
|
|
56
|
-
external_agent: [
|
|
57
|
-
"create",
|
|
58
|
-
"read",
|
|
59
|
-
"update",
|
|
60
|
-
"delete"
|
|
61
|
-
],
|
|
62
|
-
function: [
|
|
63
|
-
"create",
|
|
64
|
-
"read",
|
|
65
|
-
"update",
|
|
66
|
-
"delete"
|
|
67
|
-
],
|
|
68
|
-
context_config: [
|
|
69
|
-
"create",
|
|
70
|
-
"read",
|
|
71
|
-
"update",
|
|
72
|
-
"delete"
|
|
73
13
|
]
|
|
74
14
|
};
|
|
75
15
|
const ac = createAccessControl(statement);
|
|
76
16
|
const memberRole = ac.newRole({
|
|
77
17
|
project: ["read"],
|
|
78
|
-
agent: ["read"],
|
|
79
|
-
sub_agent: ["read"],
|
|
80
|
-
tool: ["read"],
|
|
81
|
-
api_key: ["read"],
|
|
82
|
-
credential: ["read"],
|
|
83
|
-
data_component: ["read"],
|
|
84
|
-
artifact_component: ["read"],
|
|
85
|
-
external_agent: ["read"],
|
|
86
|
-
function: ["read"],
|
|
87
|
-
context_config: ["read"],
|
|
88
18
|
...memberAc.statements
|
|
89
19
|
});
|
|
90
20
|
const adminRole = ac.newRole({
|
|
91
21
|
project: [
|
|
92
22
|
"create",
|
|
93
23
|
"read",
|
|
94
|
-
"update"
|
|
95
|
-
|
|
96
|
-
agent: [
|
|
97
|
-
"create",
|
|
98
|
-
"read",
|
|
99
|
-
"update"
|
|
100
|
-
],
|
|
101
|
-
sub_agent: [
|
|
102
|
-
"create",
|
|
103
|
-
"read",
|
|
104
|
-
"update"
|
|
105
|
-
],
|
|
106
|
-
tool: [
|
|
107
|
-
"create",
|
|
108
|
-
"read",
|
|
109
|
-
"update"
|
|
110
|
-
],
|
|
111
|
-
api_key: [
|
|
112
|
-
"create",
|
|
113
|
-
"read",
|
|
114
|
-
"update"
|
|
115
|
-
],
|
|
116
|
-
credential: [
|
|
117
|
-
"create",
|
|
118
|
-
"read",
|
|
119
|
-
"update"
|
|
120
|
-
],
|
|
121
|
-
data_component: [
|
|
122
|
-
"create",
|
|
123
|
-
"read",
|
|
124
|
-
"update"
|
|
125
|
-
],
|
|
126
|
-
artifact_component: [
|
|
127
|
-
"create",
|
|
128
|
-
"read",
|
|
129
|
-
"update"
|
|
130
|
-
],
|
|
131
|
-
external_agent: [
|
|
132
|
-
"create",
|
|
133
|
-
"read",
|
|
134
|
-
"update"
|
|
135
|
-
],
|
|
136
|
-
function: [
|
|
137
|
-
"create",
|
|
138
|
-
"read",
|
|
139
|
-
"update"
|
|
140
|
-
],
|
|
141
|
-
context_config: [
|
|
142
|
-
"create",
|
|
143
|
-
"read",
|
|
144
|
-
"update"
|
|
24
|
+
"update",
|
|
25
|
+
"delete"
|
|
145
26
|
],
|
|
146
27
|
...adminAc.statements
|
|
147
28
|
});
|
|
@@ -152,66 +33,6 @@ const ownerRole = ac.newRole({
|
|
|
152
33
|
"update",
|
|
153
34
|
"delete"
|
|
154
35
|
],
|
|
155
|
-
agent: [
|
|
156
|
-
"create",
|
|
157
|
-
"read",
|
|
158
|
-
"update",
|
|
159
|
-
"delete"
|
|
160
|
-
],
|
|
161
|
-
sub_agent: [
|
|
162
|
-
"create",
|
|
163
|
-
"read",
|
|
164
|
-
"update",
|
|
165
|
-
"delete"
|
|
166
|
-
],
|
|
167
|
-
tool: [
|
|
168
|
-
"create",
|
|
169
|
-
"read",
|
|
170
|
-
"update",
|
|
171
|
-
"delete"
|
|
172
|
-
],
|
|
173
|
-
api_key: [
|
|
174
|
-
"create",
|
|
175
|
-
"read",
|
|
176
|
-
"update",
|
|
177
|
-
"delete"
|
|
178
|
-
],
|
|
179
|
-
credential: [
|
|
180
|
-
"create",
|
|
181
|
-
"read",
|
|
182
|
-
"update",
|
|
183
|
-
"delete"
|
|
184
|
-
],
|
|
185
|
-
data_component: [
|
|
186
|
-
"create",
|
|
187
|
-
"read",
|
|
188
|
-
"update",
|
|
189
|
-
"delete"
|
|
190
|
-
],
|
|
191
|
-
artifact_component: [
|
|
192
|
-
"create",
|
|
193
|
-
"read",
|
|
194
|
-
"update",
|
|
195
|
-
"delete"
|
|
196
|
-
],
|
|
197
|
-
external_agent: [
|
|
198
|
-
"create",
|
|
199
|
-
"read",
|
|
200
|
-
"update",
|
|
201
|
-
"delete"
|
|
202
|
-
],
|
|
203
|
-
function: [
|
|
204
|
-
"create",
|
|
205
|
-
"read",
|
|
206
|
-
"update",
|
|
207
|
-
"delete"
|
|
208
|
-
],
|
|
209
|
-
context_config: [
|
|
210
|
-
"create",
|
|
211
|
-
"read",
|
|
212
|
-
"update",
|
|
213
|
-
"delete"
|
|
214
|
-
],
|
|
215
36
|
...ownerAc.statements
|
|
216
37
|
});
|
|
217
38
|
|
package/dist/client-exports.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { BreakdownComponentDef, CONTEXT_BREAKDOWN_TOTAL_SPAN_ATTRIBUTE, ContextBreakdown, V1_BREAKDOWN_SCHEMA, calculateBreakdownTotal, createEmptyBreakdown, parseContextBreakdownFromSpan } from "./constants/context-breakdown.js";
|
|
1
2
|
import { ACTIVITY_NAMES, ACTIVITY_STATUS, ACTIVITY_TYPES, AGENT_IDS, AI_OPERATIONS, AI_TOOL_TYPES, DELEGATION_FROM_SUB_AGENT_ID, DELEGATION_ID, DELEGATION_TO_SUB_AGENT_ID, SPAN_KEYS, SPAN_NAMES, TRANSFER_FROM_SUB_AGENT_ID, TRANSFER_TO_SUB_AGENT_ID, UNKNOWN_VALUE } from "./constants/otel-attributes.js";
|
|
2
3
|
import { AGGREGATE_OPERATORS, DATA_SOURCES, DATA_TYPES, FIELD_TYPES, OPERATORS, ORDER_DIRECTIONS, PANEL_TYPES, QUERY_DEFAULTS, QUERY_EXPRESSIONS, QUERY_FIELD_CONFIGS, QUERY_TYPES, REDUCE_OPERATIONS } from "./constants/signoz-queries.js";
|
|
3
|
-
import {
|
|
4
|
+
import { ConversationHistoryConfig, CredentialStoreType, MCPTransportType } from "./types/utility.js";
|
|
4
5
|
import "./types/index.js";
|
|
5
6
|
import { DEFAULT_NANGO_STORE_ID } from "./credential-stores/default-constants.js";
|
|
6
7
|
import { detectAuthenticationRequired } from "./utils/auth-detection.js";
|
|
7
8
|
import { validatePropsAsJsonSchema } from "./validation/props-validation.js";
|
|
8
9
|
import "./index.js";
|
|
9
|
-
import {
|
|
10
|
+
import { AgentStopWhen, AgentStopWhenSchema, ApiKeyApiUpdateSchema, FullAgentAgentInsertSchema, FunctionApiInsertSchema, FunctionApiSelectSchema, FunctionApiUpdateSchema, ModelSettings, ModelSettingsSchema, StopWhen, StopWhenSchema, SubAgentStopWhen, SubAgentStopWhenSchema, TriggerApiInsertSchema, TriggerApiSelectSchema, TriggerApiUpdateSchema, TriggerInvocationApiSelectSchema, TriggerInvocationListResponse, TriggerInvocationResponse, TriggerInvocationStatusEnum, TriggerListResponse, TriggerResponse } from "./validation/schemas.js";
|
|
10
11
|
import { z } from "@hono/zod-openapi";
|
|
11
12
|
|
|
12
13
|
//#region src/client-exports.d.ts
|
|
@@ -287,6 +288,10 @@ declare const FullAgentDefinitionSchema: z.ZodObject<{
|
|
|
287
288
|
type AgentApiInsert = z.infer<typeof AgentApiInsertSchema>;
|
|
288
289
|
type ToolApiInsert = z.infer<typeof ToolApiInsertSchema>;
|
|
289
290
|
type FunctionApiInsert = z.infer<typeof FunctionApiInsertSchema>;
|
|
291
|
+
type TriggerApiInsert = z.infer<typeof TriggerApiInsertSchema>;
|
|
292
|
+
type TriggerApiSelect = z.infer<typeof TriggerApiSelectSchema>;
|
|
293
|
+
type TriggerApiUpdate = z.infer<typeof TriggerApiUpdateSchema>;
|
|
294
|
+
type TriggerInvocationApiSelect = z.infer<typeof TriggerInvocationApiSelectSchema>;
|
|
290
295
|
type ApiKeyApiSelect = z.infer<typeof ApiKeyApiSelectSchema>;
|
|
291
296
|
type ApiKeyApiCreationResponse = z.infer<typeof ApiKeyApiCreationResponseSchema>;
|
|
292
297
|
type ApiKeyApiUpdateResponse = z.infer<typeof ApiKeyApiUpdateSchema>;
|
|
@@ -309,4 +314,4 @@ declare function generateIdFromName(name: string): string;
|
|
|
309
314
|
type ToolInsert = ToolApiInsert;
|
|
310
315
|
type AgentAgentInsert = AgentAgentApiInsert;
|
|
311
316
|
//#endregion
|
|
312
|
-
export { ACTIVITY_NAMES, ACTIVITY_STATUS, ACTIVITY_TYPES, AGENT_IDS, AGGREGATE_OPERATORS, AI_OPERATIONS, AI_TOOL_TYPES, AgentAgentApiInsert, AgentAgentApiInsertSchema, AgentAgentInsert, AgentApiInsert, AgentApiInsertSchema, type AgentStopWhen, AgentStopWhenSchema, ApiKeyApiCreationResponse, ApiKeyApiCreationResponseSchema, ApiKeyApiSelect, ApiKeyApiSelectSchema, ApiKeyApiUpdateResponse, ArtifactComponentApiInsert, ArtifactComponentApiInsertSchema, ContextConfigApiInsert, ContextConfigApiInsertSchema, CredentialReferenceApiInsert, CredentialReferenceApiInsertSchema, CredentialStoreType, DATA_SOURCES, DATA_TYPES, DEFAULT_NANGO_STORE_ID, DELEGATION_FROM_SUB_AGENT_ID, DELEGATION_ID, DELEGATION_TO_SUB_AGENT_ID, DataComponentApiInsert, DataComponentApiInsertSchema, ErrorResponse, ErrorResponseSchema, ExternalAgentApiInsert, ExternalAgentApiInsertSchema, ExternalAgentDefinition, FIELD_TYPES, FullAgentDefinition, FullAgentDefinitionSchema, FunctionApiInsert, FunctionApiInsertSchema, FunctionApiSelectSchema, FunctionApiUpdateSchema, IdParamsSchema, InternalAgentDefinition, ListResponseSchema, MAX_ID_LENGTH, MCPTransportType, MIN_ID_LENGTH, type ModelSettings, ModelSettingsSchema, OPERATORS, ORDER_DIRECTIONS, PANEL_TYPES, PaginationSchema, QUERY_DEFAULTS, QUERY_EXPRESSIONS, QUERY_FIELD_CONFIGS, QUERY_TYPES, REDUCE_OPERATIONS, SPAN_KEYS, SPAN_NAMES, SingleResponseSchema, type StopWhen, StopWhenSchema, type SubAgentStopWhen, SubAgentStopWhenSchema, TRANSFER_FROM_SUB_AGENT_ID, TRANSFER_TO_SUB_AGENT_ID, TenantParams, TenantParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsert, ToolApiInsertSchema, ToolInsert, UNKNOWN_VALUE, URL_SAFE_ID_PATTERN, detectAuthenticationRequired, generateIdFromName, resourceIdSchema, validatePropsAsJsonSchema };
|
|
317
|
+
export { ACTIVITY_NAMES, ACTIVITY_STATUS, ACTIVITY_TYPES, AGENT_IDS, AGGREGATE_OPERATORS, AI_OPERATIONS, AI_TOOL_TYPES, AgentAgentApiInsert, AgentAgentApiInsertSchema, AgentAgentInsert, AgentApiInsert, AgentApiInsertSchema, type AgentStopWhen, AgentStopWhenSchema, ApiKeyApiCreationResponse, ApiKeyApiCreationResponseSchema, ApiKeyApiSelect, ApiKeyApiSelectSchema, ApiKeyApiUpdateResponse, ArtifactComponentApiInsert, ArtifactComponentApiInsertSchema, BreakdownComponentDef, CONTEXT_BREAKDOWN_TOTAL_SPAN_ATTRIBUTE, ContextBreakdown, ContextConfigApiInsert, ContextConfigApiInsertSchema, CredentialReferenceApiInsert, CredentialReferenceApiInsertSchema, CredentialStoreType, DATA_SOURCES, DATA_TYPES, DEFAULT_NANGO_STORE_ID, DELEGATION_FROM_SUB_AGENT_ID, DELEGATION_ID, DELEGATION_TO_SUB_AGENT_ID, DataComponentApiInsert, DataComponentApiInsertSchema, ErrorResponse, ErrorResponseSchema, ExternalAgentApiInsert, ExternalAgentApiInsertSchema, ExternalAgentDefinition, FIELD_TYPES, FullAgentDefinition, FullAgentDefinitionSchema, FunctionApiInsert, FunctionApiInsertSchema, FunctionApiSelectSchema, FunctionApiUpdateSchema, IdParamsSchema, InternalAgentDefinition, ListResponseSchema, MAX_ID_LENGTH, MCPTransportType, MIN_ID_LENGTH, type ModelSettings, ModelSettingsSchema, OPERATORS, ORDER_DIRECTIONS, PANEL_TYPES, PaginationSchema, QUERY_DEFAULTS, QUERY_EXPRESSIONS, QUERY_FIELD_CONFIGS, QUERY_TYPES, REDUCE_OPERATIONS, SPAN_KEYS, SPAN_NAMES, SingleResponseSchema, type StopWhen, StopWhenSchema, type SubAgentStopWhen, SubAgentStopWhenSchema, TRANSFER_FROM_SUB_AGENT_ID, TRANSFER_TO_SUB_AGENT_ID, TenantParams, TenantParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsert, ToolApiInsertSchema, ToolInsert, TriggerApiInsert, TriggerApiInsertSchema, TriggerApiSelect, TriggerApiSelectSchema, TriggerApiUpdate, TriggerApiUpdateSchema, TriggerInvocationApiSelect, TriggerInvocationApiSelectSchema, TriggerInvocationListResponse, TriggerInvocationResponse, TriggerInvocationStatusEnum, TriggerListResponse, TriggerResponse, UNKNOWN_VALUE, URL_SAFE_ID_PATTERN, V1_BREAKDOWN_SCHEMA, calculateBreakdownTotal, createEmptyBreakdown, detectAuthenticationRequired, generateIdFromName, parseContextBreakdownFromSpan, resourceIdSchema, validatePropsAsJsonSchema };
|
package/dist/client-exports.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { schemaValidationDefaults } from "./constants/schema-validation/defaults.js";
|
|
2
2
|
import { CredentialStoreType, MCPTransportType } from "./types/utility.js";
|
|
3
|
-
import { AgentStopWhenSchema, ArtifactComponentApiInsertSchema as ArtifactComponentApiInsertSchema$1, FullAgentAgentInsertSchema, FunctionApiInsertSchema, FunctionApiSelectSchema, FunctionApiUpdateSchema, ModelSettingsSchema, StopWhenSchema, SubAgentStopWhenSchema } from "./validation/schemas.js";
|
|
3
|
+
import { AgentStopWhenSchema, ArtifactComponentApiInsertSchema as ArtifactComponentApiInsertSchema$1, FullAgentAgentInsertSchema, FunctionApiInsertSchema, FunctionApiSelectSchema, FunctionApiUpdateSchema, ModelSettingsSchema, StopWhenSchema, SubAgentStopWhenSchema, TriggerApiInsertSchema, TriggerApiSelectSchema, TriggerApiUpdateSchema, TriggerInvocationApiSelectSchema, TriggerInvocationListResponse, TriggerInvocationResponse, TriggerInvocationStatusEnum, TriggerListResponse, TriggerResponse } from "./validation/schemas.js";
|
|
4
4
|
import { DEFAULT_NANGO_STORE_ID } from "./credential-stores/default-constants.js";
|
|
5
5
|
import { validatePropsAsJsonSchema } from "./validation/props-validation.js";
|
|
6
|
+
import { CONTEXT_BREAKDOWN_TOTAL_SPAN_ATTRIBUTE, V1_BREAKDOWN_SCHEMA, calculateBreakdownTotal, createEmptyBreakdown, parseContextBreakdownFromSpan } from "./constants/context-breakdown.js";
|
|
6
7
|
import { ACTIVITY_NAMES, ACTIVITY_STATUS, ACTIVITY_TYPES, AGENT_IDS, AI_OPERATIONS, AI_TOOL_TYPES, DELEGATION_FROM_SUB_AGENT_ID, DELEGATION_ID, DELEGATION_TO_SUB_AGENT_ID, SPAN_KEYS, SPAN_NAMES, TRANSFER_FROM_SUB_AGENT_ID, TRANSFER_TO_SUB_AGENT_ID, UNKNOWN_VALUE } from "./constants/otel-attributes.js";
|
|
7
8
|
import { AGGREGATE_OPERATORS, DATA_SOURCES, DATA_TYPES, FIELD_TYPES, OPERATORS, ORDER_DIRECTIONS, PANEL_TYPES, QUERY_DEFAULTS, QUERY_EXPRESSIONS, QUERY_FIELD_CONFIGS, QUERY_TYPES, REDUCE_OPERATIONS } from "./constants/signoz-queries.js";
|
|
8
9
|
import { detectAuthenticationRequired } from "./utils/auth-detection.js";
|
|
@@ -167,4 +168,4 @@ function generateIdFromName(name) {
|
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
//#endregion
|
|
170
|
-
export { ACTIVITY_NAMES, ACTIVITY_STATUS, ACTIVITY_TYPES, AGENT_IDS, AGGREGATE_OPERATORS, AI_OPERATIONS, AI_TOOL_TYPES, AgentAgentApiInsertSchema, AgentApiInsertSchema, AgentStopWhenSchema, ApiKeyApiCreationResponseSchema, ApiKeyApiSelectSchema, ArtifactComponentApiInsertSchema, ContextConfigApiInsertSchema, CredentialReferenceApiInsertSchema, CredentialStoreType, DATA_SOURCES, DATA_TYPES, DEFAULT_NANGO_STORE_ID, DELEGATION_FROM_SUB_AGENT_ID, DELEGATION_ID, DELEGATION_TO_SUB_AGENT_ID, DataComponentApiInsertSchema, ErrorResponseSchema, ExternalAgentApiInsertSchema, FIELD_TYPES, FullAgentDefinitionSchema, FunctionApiInsertSchema, FunctionApiSelectSchema, FunctionApiUpdateSchema, IdParamsSchema, ListResponseSchema, MAX_ID_LENGTH, MCPTransportType, MIN_ID_LENGTH, ModelSettingsSchema, OPERATORS, ORDER_DIRECTIONS, PANEL_TYPES, PaginationSchema, QUERY_DEFAULTS, QUERY_EXPRESSIONS, QUERY_FIELD_CONFIGS, QUERY_TYPES, REDUCE_OPERATIONS, SPAN_KEYS, SPAN_NAMES, SingleResponseSchema, StopWhenSchema, SubAgentStopWhenSchema, TRANSFER_FROM_SUB_AGENT_ID, TRANSFER_TO_SUB_AGENT_ID, TenantParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsertSchema, UNKNOWN_VALUE, URL_SAFE_ID_PATTERN, detectAuthenticationRequired, generateIdFromName, resourceIdSchema, validatePropsAsJsonSchema };
|
|
171
|
+
export { ACTIVITY_NAMES, ACTIVITY_STATUS, ACTIVITY_TYPES, AGENT_IDS, AGGREGATE_OPERATORS, AI_OPERATIONS, AI_TOOL_TYPES, AgentAgentApiInsertSchema, AgentApiInsertSchema, AgentStopWhenSchema, ApiKeyApiCreationResponseSchema, ApiKeyApiSelectSchema, ArtifactComponentApiInsertSchema, CONTEXT_BREAKDOWN_TOTAL_SPAN_ATTRIBUTE, ContextConfigApiInsertSchema, CredentialReferenceApiInsertSchema, CredentialStoreType, DATA_SOURCES, DATA_TYPES, DEFAULT_NANGO_STORE_ID, DELEGATION_FROM_SUB_AGENT_ID, DELEGATION_ID, DELEGATION_TO_SUB_AGENT_ID, DataComponentApiInsertSchema, ErrorResponseSchema, ExternalAgentApiInsertSchema, FIELD_TYPES, FullAgentDefinitionSchema, FunctionApiInsertSchema, FunctionApiSelectSchema, FunctionApiUpdateSchema, IdParamsSchema, ListResponseSchema, MAX_ID_LENGTH, MCPTransportType, MIN_ID_LENGTH, ModelSettingsSchema, OPERATORS, ORDER_DIRECTIONS, PANEL_TYPES, PaginationSchema, QUERY_DEFAULTS, QUERY_EXPRESSIONS, QUERY_FIELD_CONFIGS, QUERY_TYPES, REDUCE_OPERATIONS, SPAN_KEYS, SPAN_NAMES, SingleResponseSchema, StopWhenSchema, SubAgentStopWhenSchema, TRANSFER_FROM_SUB_AGENT_ID, TRANSFER_TO_SUB_AGENT_ID, TenantParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsertSchema, TriggerApiInsertSchema, TriggerApiSelectSchema, TriggerApiUpdateSchema, TriggerInvocationApiSelectSchema, TriggerInvocationListResponse, TriggerInvocationResponse, TriggerInvocationStatusEnum, TriggerListResponse, TriggerResponse, UNKNOWN_VALUE, URL_SAFE_ID_PATTERN, V1_BREAKDOWN_SCHEMA, calculateBreakdownTotal, createEmptyBreakdown, detectAuthenticationRequired, generateIdFromName, parseContextBreakdownFromSpan, resourceIdSchema, validatePropsAsJsonSchema };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
//#region src/constants/context-breakdown.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Context breakdown schema definitions.
|
|
4
|
+
*
|
|
5
|
+
* This module defines the breakdown components tracked for each system prompt version.
|
|
6
|
+
* It serves as the single source of truth for:
|
|
7
|
+
* - Component keys and labels
|
|
8
|
+
* - OpenTelemetry span attribute keys
|
|
9
|
+
* - UI visualization colors (auto-generated)
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Defines a single breakdown component for a system prompt version.
|
|
13
|
+
* Each version can define its own set of components.
|
|
14
|
+
*/
|
|
15
|
+
interface BreakdownComponentDef {
|
|
16
|
+
/** Unique key for this component (used in breakdown.components map) */
|
|
17
|
+
key: string;
|
|
18
|
+
/** Human-readable label for UI display */
|
|
19
|
+
label: string;
|
|
20
|
+
/** OpenTelemetry span attribute key for this component */
|
|
21
|
+
spanAttribute: string;
|
|
22
|
+
/** Hex color for UI visualization (auto-generated) */
|
|
23
|
+
color: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* V1 Breakdown Schema - defines all context components tracked for V1 system prompts.
|
|
27
|
+
* Colors are automatically generated for visual distinction.
|
|
28
|
+
*/
|
|
29
|
+
declare const V1_BREAKDOWN_SCHEMA: BreakdownComponentDef[];
|
|
30
|
+
/** Span attribute key for total tokens */
|
|
31
|
+
declare const CONTEXT_BREAKDOWN_TOTAL_SPAN_ATTRIBUTE = "context.breakdown.total_tokens";
|
|
32
|
+
/**
|
|
33
|
+
* Dynamic context breakdown interface.
|
|
34
|
+
* Uses a components map to support different system prompt versions.
|
|
35
|
+
*/
|
|
36
|
+
interface ContextBreakdown {
|
|
37
|
+
/** Token counts by component key (version-specific) */
|
|
38
|
+
components: Record<string, number>;
|
|
39
|
+
/** Total estimated tokens */
|
|
40
|
+
total: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Creates an empty context breakdown from a schema definition.
|
|
44
|
+
* @param schema - Array of breakdown component definitions
|
|
45
|
+
*/
|
|
46
|
+
declare function createEmptyBreakdown(schema: BreakdownComponentDef[]): ContextBreakdown;
|
|
47
|
+
/**
|
|
48
|
+
* Calculates the total from all breakdown components and updates the total field.
|
|
49
|
+
* @param breakdown - The context breakdown to calculate total for
|
|
50
|
+
* @returns The breakdown with updated total
|
|
51
|
+
*/
|
|
52
|
+
declare function calculateBreakdownTotal(breakdown: ContextBreakdown): ContextBreakdown;
|
|
53
|
+
/**
|
|
54
|
+
* Parses a context breakdown from span attributes using a schema.
|
|
55
|
+
* @param data - Span attribute data record
|
|
56
|
+
* @param schema - Breakdown schema to use for parsing
|
|
57
|
+
* @returns Parsed context breakdown
|
|
58
|
+
*/
|
|
59
|
+
declare function parseContextBreakdownFromSpan(data: Record<string, unknown>, schema?: BreakdownComponentDef[]): ContextBreakdown;
|
|
60
|
+
//#endregion
|
|
61
|
+
export { BreakdownComponentDef, CONTEXT_BREAKDOWN_TOTAL_SPAN_ATTRIBUTE, ContextBreakdown, V1_BREAKDOWN_SCHEMA, calculateBreakdownTotal, createEmptyBreakdown, parseContextBreakdownFromSpan };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { generateDistinctColors } from "../utils/colors.js";
|
|
2
|
+
|
|
3
|
+
//#region src/constants/context-breakdown.ts
|
|
4
|
+
/**
|
|
5
|
+
* Context breakdown schema definitions.
|
|
6
|
+
*
|
|
7
|
+
* This module defines the breakdown components tracked for each system prompt version.
|
|
8
|
+
* It serves as the single source of truth for:
|
|
9
|
+
* - Component keys and labels
|
|
10
|
+
* - OpenTelemetry span attribute keys
|
|
11
|
+
* - UI visualization colors (auto-generated)
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Base schema without colors - colors are auto-generated based on index
|
|
15
|
+
*/
|
|
16
|
+
const V1_BREAKDOWN_SCHEMA_BASE = [
|
|
17
|
+
{
|
|
18
|
+
key: "systemPromptTemplate",
|
|
19
|
+
label: "System Prompt Template",
|
|
20
|
+
spanAttribute: "context.breakdown.system_template_tokens"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
key: "coreInstructions",
|
|
24
|
+
label: "Core Instructions",
|
|
25
|
+
spanAttribute: "context.breakdown.core_instructions_tokens"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
key: "agentPrompt",
|
|
29
|
+
label: "Agent Prompt",
|
|
30
|
+
spanAttribute: "context.breakdown.agent_prompt_tokens"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
key: "toolsSection",
|
|
34
|
+
label: "Tools (MCP/Function/Relation)",
|
|
35
|
+
spanAttribute: "context.breakdown.tools_tokens"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
key: "artifactsSection",
|
|
39
|
+
label: "Artifacts",
|
|
40
|
+
spanAttribute: "context.breakdown.artifacts_tokens"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
key: "dataComponents",
|
|
44
|
+
label: "Data Components",
|
|
45
|
+
spanAttribute: "context.breakdown.data_components_tokens"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
key: "artifactComponents",
|
|
49
|
+
label: "Artifact Components",
|
|
50
|
+
spanAttribute: "context.breakdown.artifact_components_tokens"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
key: "transferInstructions",
|
|
54
|
+
label: "Transfer Instructions",
|
|
55
|
+
spanAttribute: "context.breakdown.transfer_instructions_tokens"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
key: "delegationInstructions",
|
|
59
|
+
label: "Delegation Instructions",
|
|
60
|
+
spanAttribute: "context.breakdown.delegation_instructions_tokens"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
key: "thinkingPreparation",
|
|
64
|
+
label: "Thinking Preparation",
|
|
65
|
+
spanAttribute: "context.breakdown.thinking_preparation_tokens"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
key: "conversationHistory",
|
|
69
|
+
label: "Conversation History",
|
|
70
|
+
spanAttribute: "context.breakdown.conversation_history_tokens"
|
|
71
|
+
}
|
|
72
|
+
];
|
|
73
|
+
/** Pre-generated distinct colors for the schema */
|
|
74
|
+
const SCHEMA_COLORS = generateDistinctColors(V1_BREAKDOWN_SCHEMA_BASE.length);
|
|
75
|
+
/**
|
|
76
|
+
* V1 Breakdown Schema - defines all context components tracked for V1 system prompts.
|
|
77
|
+
* Colors are automatically generated for visual distinction.
|
|
78
|
+
*/
|
|
79
|
+
const V1_BREAKDOWN_SCHEMA = V1_BREAKDOWN_SCHEMA_BASE.map((def, index) => ({
|
|
80
|
+
...def,
|
|
81
|
+
color: SCHEMA_COLORS[index]
|
|
82
|
+
}));
|
|
83
|
+
/** Span attribute key for total tokens */
|
|
84
|
+
const CONTEXT_BREAKDOWN_TOTAL_SPAN_ATTRIBUTE = "context.breakdown.total_tokens";
|
|
85
|
+
/**
|
|
86
|
+
* Creates an empty context breakdown from a schema definition.
|
|
87
|
+
* @param schema - Array of breakdown component definitions
|
|
88
|
+
*/
|
|
89
|
+
function createEmptyBreakdown(schema) {
|
|
90
|
+
const components = {};
|
|
91
|
+
for (const def of schema) components[def.key] = 0;
|
|
92
|
+
return {
|
|
93
|
+
components,
|
|
94
|
+
total: 0
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Calculates the total from all breakdown components and updates the total field.
|
|
99
|
+
* @param breakdown - The context breakdown to calculate total for
|
|
100
|
+
* @returns The breakdown with updated total
|
|
101
|
+
*/
|
|
102
|
+
function calculateBreakdownTotal(breakdown) {
|
|
103
|
+
breakdown.total = Object.values(breakdown.components).reduce((sum, val) => sum + val, 0);
|
|
104
|
+
return breakdown;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Parses a context breakdown from span attributes using a schema.
|
|
108
|
+
* @param data - Span attribute data record
|
|
109
|
+
* @param schema - Breakdown schema to use for parsing
|
|
110
|
+
* @returns Parsed context breakdown
|
|
111
|
+
*/
|
|
112
|
+
function parseContextBreakdownFromSpan(data, schema = V1_BREAKDOWN_SCHEMA) {
|
|
113
|
+
const breakdown = createEmptyBreakdown(schema);
|
|
114
|
+
for (const def of schema) {
|
|
115
|
+
const value = data[def.spanAttribute];
|
|
116
|
+
breakdown.components[def.key] = typeof value === "number" ? value : Number(value) || 0;
|
|
117
|
+
}
|
|
118
|
+
const totalValue = data[CONTEXT_BREAKDOWN_TOTAL_SPAN_ATTRIBUTE];
|
|
119
|
+
breakdown.total = typeof totalValue === "number" ? totalValue : Number(totalValue) || 0;
|
|
120
|
+
return breakdown;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
//#endregion
|
|
124
|
+
export { CONTEXT_BREAKDOWN_TOTAL_SPAN_ATTRIBUTE, V1_BREAKDOWN_SCHEMA, calculateBreakdownTotal, createEmptyBreakdown, parseContextBreakdownFromSpan };
|
|
@@ -67,6 +67,7 @@ declare const SPAN_KEYS: {
|
|
|
67
67
|
readonly CONTEXT_AGENT_ID: "context.agent_id";
|
|
68
68
|
readonly CONTEXT_HEADERS_KEYS: "context.headers_keys";
|
|
69
69
|
readonly MESSAGE_CONTENT: "message.content";
|
|
70
|
+
readonly MESSAGE_PARTS: "message.parts";
|
|
70
71
|
readonly MESSAGE_TIMESTAMP: "message.timestamp";
|
|
71
72
|
readonly MCP_TOOL_DESCRIPTION: "mcp.tool.description";
|
|
72
73
|
readonly DELEGATION_FROM_SUB_AGENT_ID: "delegation.from_sub_agent_id";
|
|
@@ -80,6 +81,9 @@ declare const SPAN_KEYS: {
|
|
|
80
81
|
readonly NAME: "name";
|
|
81
82
|
readonly PARENT_SPAN_ID: "parentSpanID";
|
|
82
83
|
readonly CONVERSATION_ID: "conversation.id";
|
|
84
|
+
readonly INVOCATION_TYPE: "invocation.type";
|
|
85
|
+
readonly TRIGGER_ID: "trigger.id";
|
|
86
|
+
readonly TRIGGER_INVOCATION_ID: "trigger.invocation.id";
|
|
83
87
|
readonly ARTIFACT_ID: "artifact.id";
|
|
84
88
|
readonly ARTIFACT_TYPE: "artifact.type";
|
|
85
89
|
readonly ARTIFACT_TOOL_CALL_ID: "artifact.tool_call_id";
|
|
@@ -67,6 +67,7 @@ const SPAN_KEYS = {
|
|
|
67
67
|
CONTEXT_AGENT_ID: "context.agent_id",
|
|
68
68
|
CONTEXT_HEADERS_KEYS: "context.headers_keys",
|
|
69
69
|
MESSAGE_CONTENT: "message.content",
|
|
70
|
+
MESSAGE_PARTS: "message.parts",
|
|
70
71
|
MESSAGE_TIMESTAMP: "message.timestamp",
|
|
71
72
|
MCP_TOOL_DESCRIPTION: "mcp.tool.description",
|
|
72
73
|
DELEGATION_FROM_SUB_AGENT_ID,
|
|
@@ -80,6 +81,9 @@ const SPAN_KEYS = {
|
|
|
80
81
|
NAME: "name",
|
|
81
82
|
PARENT_SPAN_ID: "parentSpanID",
|
|
82
83
|
CONVERSATION_ID: "conversation.id",
|
|
84
|
+
INVOCATION_TYPE: "invocation.type",
|
|
85
|
+
TRIGGER_ID: "trigger.id",
|
|
86
|
+
TRIGGER_INVOCATION_ID: "trigger.invocation.id",
|
|
83
87
|
ARTIFACT_ID: "artifact.id",
|
|
84
88
|
ARTIFACT_TYPE: "artifact.type",
|
|
85
89
|
ARTIFACT_TOOL_CALL_ID: "artifact.tool_call_id",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContextFetchDefinition } from "../types/utility.js";
|
|
2
2
|
import "../types/index.js";
|
|
3
3
|
import { DotPaths } from "./validation-helpers.js";
|
|
4
|
-
import {
|
|
4
|
+
import { ContextConfigSelect, CredentialReferenceApiInsert } from "../types/entities.js";
|
|
5
5
|
import { z } from "@hono/zod-openapi";
|
|
6
6
|
|
|
7
7
|
//#region src/context/ContextConfig.d.ts
|
|
@@ -31,7 +31,7 @@ var ContextConfigBuilder = class {
|
|
|
31
31
|
this.tenantId = options.tenantId || "default";
|
|
32
32
|
this.projectId = options.projectId || "default";
|
|
33
33
|
this.agentId = options.agentId || "default";
|
|
34
|
-
this.baseURL = process.env.
|
|
34
|
+
this.baseURL = process.env.INKEEP_AGENTS_API_URL || "http://localhost:3002";
|
|
35
35
|
let headers$1;
|
|
36
36
|
if (options.headers) {
|
|
37
37
|
const actualSchema = options.headers instanceof HeadersSchemaBuilder ? options.headers.getSchema() : options.headers;
|
|
@@ -165,7 +165,7 @@ var ContextConfigBuilder = class {
|
|
|
165
165
|
contextVariables: this.getContextVariables()
|
|
166
166
|
};
|
|
167
167
|
try {
|
|
168
|
-
const updateResponse = await fetch(`${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/agent/${this.agentId}/context-configs/${this.getId()}`, {
|
|
168
|
+
const updateResponse = await fetch(`${this.baseURL}/manage/tenants/${this.tenantId}/projects/${this.projectId}/agent/${this.agentId}/context-configs/${this.getId()}`, {
|
|
169
169
|
method: "PUT",
|
|
170
170
|
headers: { "Content-Type": "application/json" },
|
|
171
171
|
body: JSON.stringify(configData)
|
|
@@ -176,7 +176,7 @@ var ContextConfigBuilder = class {
|
|
|
176
176
|
}
|
|
177
177
|
if (updateResponse.status === 404) {
|
|
178
178
|
logger.info({ contextConfigId: this.getId() }, "Context config not found, creating new config");
|
|
179
|
-
const createResponse = await fetch(`${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/agent/${this.agentId}/context-configs`, {
|
|
179
|
+
const createResponse = await fetch(`${this.baseURL}/manage/tenants/${this.tenantId}/projects/${this.projectId}/agent/${this.agentId}/context-configs`, {
|
|
180
180
|
method: "POST",
|
|
181
181
|
headers: { "Content-Type": "application/json" },
|
|
182
182
|
body: JSON.stringify(configData)
|
|
@@ -63,7 +63,6 @@ var TemplateEngine = class TemplateEngine {
|
|
|
63
63
|
variable: trimmedPath,
|
|
64
64
|
normalizedPath,
|
|
65
65
|
availableKeys: Object.keys(context),
|
|
66
|
-
contextStructure: JSON.stringify(context, null, 2),
|
|
67
66
|
headersContent: context.headers ? JSON.stringify(context.headers, null, 2) : "undefined"
|
|
68
67
|
}, "Headers template variable debugging");
|
|
69
68
|
else logger.warn({
|
package/dist/context/index.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { DotPaths } from "./validation-helpers.js";
|
|
2
2
|
import { ContextConfigBuilder, ContextConfigBuilderOptions, contextConfig, fetchDefinition, headers } from "./ContextConfig.js";
|
|
3
3
|
import { TemplateContext, TemplateEngine, TemplateRenderOptions } from "./TemplateEngine.js";
|
|
4
|
-
|
|
5
|
-
import { ContextResolutionOptions, ContextResolutionResult, ContextResolver, ResolvedContext } from "./ContextResolver.js";
|
|
6
|
-
import { determineContextTrigger, handleContextConfigChange, handleContextResolution } from "./context.js";
|
|
7
|
-
import { ContextCache } from "./contextCache.js";
|
|
8
|
-
export { ContextCache, ContextConfigBuilder, type ContextConfigBuilderOptions, ContextFetcher, type ContextResolutionOptions, type ContextResolutionResult, ContextResolver, type DotPaths, type FetchResult, MissingRequiredVariableError, type ResolvedContext, type TemplateContext, TemplateEngine, type TemplateRenderOptions, contextConfig, determineContextTrigger, fetchDefinition, handleContextConfigChange, handleContextResolution, headers };
|
|
4
|
+
export { ContextConfigBuilder, type ContextConfigBuilderOptions, type DotPaths, type TemplateContext, TemplateEngine, type TemplateRenderOptions, contextConfig, fetchDefinition, headers };
|
package/dist/context/index.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { ContextConfigBuilder, contextConfig, fetchDefinition, headers } from "./ContextConfig.js";
|
|
2
2
|
import { TemplateEngine } from "./TemplateEngine.js";
|
|
3
|
-
import { ContextCache } from "./contextCache.js";
|
|
4
|
-
import { ContextResolver } from "./ContextResolver.js";
|
|
5
|
-
import { ContextFetcher, MissingRequiredVariableError } from "./ContextFetcher.js";
|
|
6
|
-
import { determineContextTrigger, handleContextConfigChange, handleContextResolution } from "./context.js";
|
|
7
3
|
|
|
8
|
-
export {
|
|
4
|
+
export { ContextConfigBuilder, TemplateEngine, contextConfig, fetchDefinition, headers };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { MCPToolConfig } from "../types/entities.js";
|
|
2
1
|
import "../types/index.js";
|
|
3
2
|
import { CredentialStoreRegistry } from "../credential-stores/CredentialStoreRegistry.js";
|
|
4
3
|
import { PinoLogger } from "../utils/logger.js";
|
|
5
4
|
import { McpServerConfig } from "../utils/mcp-client.js";
|
|
5
|
+
import { MCPToolConfig } from "../types/entities.js";
|
|
6
6
|
|
|
7
7
|
//#region src/credential-stuffer/CredentialStuffer.d.ts
|
|
8
8
|
/**
|