@kindgi/client 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/index.cjs CHANGED
@@ -480,6 +480,20 @@ function makeAgentsClient(transport) {
480
480
  };
481
481
  }
482
482
 
483
+ // src/scope-wire.ts
484
+ function scopeForBody(scope) {
485
+ if (scope.kind === "tenant") return { kind: "tenant" };
486
+ if (scope.kind === "org") return { kind: "org", orgId: scope.orgId };
487
+ return { kind: "project", projectId: scope.projectId };
488
+ }
489
+ function scopeToQuery(scope) {
490
+ if (scope.kind === "tenant") return { scopeKind: "tenant" };
491
+ if (scope.kind === "org") {
492
+ return { scopeKind: "org", scopeId: scope.orgId };
493
+ }
494
+ return { scopeKind: "project", scopeId: scope.projectId };
495
+ }
496
+
483
497
  // src/status-query.ts
484
498
  function singleStatusQuery(method, status) {
485
499
  if (status === void 0) return void 0;
@@ -506,6 +520,7 @@ function makeApprovalsClient(transport) {
506
520
  ...filter?.limit !== void 0 && { limit: filter.limit },
507
521
  ...filter?.cursor !== void 0 && { cursor: filter.cursor },
508
522
  ...statusParam !== void 0 && { status: statusParam },
523
+ ...filter?.scope !== void 0 && scopeToQuery(filter.scope),
509
524
  ...filter?.requiredRole !== void 0 && { requiredRole: filter.requiredRole },
510
525
  ...filter?.createdAfter !== void 0 && {
511
526
  createdAfter: filter.createdAfter
@@ -964,6 +979,7 @@ function makeConversationsClient(transport) {
964
979
  body: {
965
980
  agentId: input.agentId,
966
981
  agentVersion: input.agentVersion,
982
+ ...input.projectId !== void 0 && { projectId: input.projectId },
967
983
  ...input.title !== void 0 && { title: input.title },
968
984
  ...input.scope !== void 0 && { scope: input.scope },
969
985
  ...input.participantId !== void 0 && { participantId: input.participantId },
@@ -989,6 +1005,7 @@ function makeConversationsClient(transport) {
989
1005
  ...filter?.limit !== void 0 && { limit: filter.limit },
990
1006
  ...filter?.cursor !== void 0 && { cursor: filter.cursor },
991
1007
  ...statusParam !== void 0 && { status: statusParam },
1008
+ ...filter?.scope !== void 0 && scopeToQuery(filter.scope),
992
1009
  ...filter?.agent !== void 0 && { agentId: filter.agent }
993
1010
  }
994
1011
  });
@@ -1025,6 +1042,29 @@ function makeConversationsClient(transport) {
1025
1042
  }
1026
1043
 
1027
1044
  // src/resources/cost.ts
1045
+ function filterQuery(filter) {
1046
+ const scope = filter.scope !== void 0 ? scopeToQuery(filter.scope) : void 0;
1047
+ return {
1048
+ ...filter.runId !== void 0 && { runId: filter.runId },
1049
+ ...filter.includeDescendants === true && { includeDescendants: "true" },
1050
+ ...filter.rootRunId !== void 0 && { rootRunId: filter.rootRunId },
1051
+ ...filter.agentId !== void 0 && { agentId: filter.agentId },
1052
+ ...filter.conversationId !== void 0 && {
1053
+ conversationId: filter.conversationId
1054
+ },
1055
+ ...filter.category !== void 0 && { category: filter.category },
1056
+ ...filter.providerId !== void 0 && {
1057
+ providerId: filter.providerId
1058
+ },
1059
+ ...filter.model !== void 0 && { model: filter.model },
1060
+ ...filter.servedModel !== void 0 && { servedModel: filter.servedModel },
1061
+ ...scope !== void 0 && { scopeKind: scope.scopeKind },
1062
+ ...scope?.scopeId !== void 0 && { scopeId: scope.scopeId },
1063
+ ...filter.from !== void 0 && { from: filter.from },
1064
+ ...filter.to !== void 0 && { to: filter.to },
1065
+ ...filter.includeRawUsage === true && { include: "rawUsage" }
1066
+ };
1067
+ }
1028
1068
  function makeCostClient(transport) {
1029
1069
  return {
1030
1070
  usage: {
@@ -1035,17 +1075,7 @@ function makeCostClient(transport) {
1035
1075
  query: {
1036
1076
  ...filter?.limit !== void 0 && { limit: filter.limit },
1037
1077
  ...filter?.cursor !== void 0 && { cursor: filter.cursor },
1038
- ...filter?.runId !== void 0 && { runId: filter.runId },
1039
- ...filter?.agentId !== void 0 && { agentId: filter.agentId },
1040
- ...filter?.conversationId !== void 0 && {
1041
- conversationId: filter.conversationId
1042
- },
1043
- ...filter?.category !== void 0 && { category: filter.category },
1044
- ...filter?.providerId !== void 0 && {
1045
- providerId: filter.providerId
1046
- },
1047
- ...filter?.from !== void 0 && { from: filter.from },
1048
- ...filter?.to !== void 0 && { to: filter.to }
1078
+ ...filterQuery(filter ?? {})
1049
1079
  }
1050
1080
  });
1051
1081
  return {
@@ -1055,29 +1085,23 @@ function makeCostClient(transport) {
1055
1085
  }
1056
1086
  };
1057
1087
  },
1058
- async get(recordId) {
1088
+ async get(recordId, options) {
1059
1089
  return transport.request({
1060
1090
  method: "GET",
1061
- path: `/v1/cost/records/${encodeURIComponent(recordId)}`
1091
+ path: `/v1/cost/records/${encodeURIComponent(recordId)}`,
1092
+ ...options?.includeRawUsage === true && { query: { include: "rawUsage" } }
1062
1093
  });
1063
1094
  },
1064
1095
  async summary(input) {
1096
+ const { from, to, groupBy, ...filter } = input;
1065
1097
  return transport.request({
1066
1098
  method: "GET",
1067
1099
  path: "/v1/cost/aggregate",
1068
1100
  query: {
1069
- from: input.from,
1070
- to: input.to,
1071
- ...input.groupBy !== void 0 && { groupBy: input.groupBy.join(",") },
1072
- ...input.category !== void 0 && { category: input.category },
1073
- ...input.providerId !== void 0 && {
1074
- providerId: input.providerId
1075
- },
1076
- ...input.agentId !== void 0 && { agentId: input.agentId },
1077
- ...input.runId !== void 0 && { runId: input.runId },
1078
- ...input.conversationId !== void 0 && {
1079
- conversationId: input.conversationId
1080
- }
1101
+ ...filterQuery(filter),
1102
+ from,
1103
+ to,
1104
+ ...groupBy !== void 0 && { groupBy: groupBy.join(",") }
1081
1105
  }
1082
1106
  });
1083
1107
  }
@@ -1151,20 +1175,6 @@ function makeDeploymentsClient(transport) {
1151
1175
  };
1152
1176
  }
1153
1177
 
1154
- // src/scope-wire.ts
1155
- function scopeForBody(scope) {
1156
- if (scope.kind === "tenant") return { kind: "tenant" };
1157
- if (scope.kind === "org") return { kind: "org", orgId: scope.orgId };
1158
- return { kind: "project", projectId: scope.projectId };
1159
- }
1160
- function scopeToQuery(scope) {
1161
- if (scope.kind === "tenant") return { scopeKind: "tenant" };
1162
- if (scope.kind === "org") {
1163
- return { scopeKind: "org", scopeId: scope.orgId };
1164
- }
1165
- return { scopeKind: "project", scopeId: scope.projectId };
1166
- }
1167
-
1168
1178
  // src/resources/env.ts
1169
1179
  function makeEnvClient(transport) {
1170
1180
  return {
@@ -2327,6 +2337,7 @@ function makeProvenanceClient(transport) {
2327
2337
  query: {
2328
2338
  ...filter?.limit !== void 0 && { limit: filter.limit },
2329
2339
  ...filter?.cursor !== void 0 && { cursor: filter.cursor },
2340
+ ...filter?.scope !== void 0 && scopeToQuery(filter.scope),
2330
2341
  ...filter?.runId !== void 0 && { runId: filter.runId },
2331
2342
  ...filter?.agentId !== void 0 && {
2332
2343
  agentId: filter.agentId
@@ -2582,10 +2593,12 @@ function makeRunsClient(transport) {
2582
2593
  query: {
2583
2594
  ...filter?.limit !== void 0 && { limit: filter.limit },
2584
2595
  ...filter?.cursor !== void 0 && { cursor: filter.cursor },
2596
+ ...filter?.scope !== void 0 && scopeToQuery(filter.scope),
2585
2597
  ...filter?.parentRunId !== void 0 && {
2586
2598
  parentRunId: filter.parentRunId
2587
2599
  },
2588
2600
  ...filter?.topLevel !== void 0 && { topLevel: String(filter.topLevel) },
2601
+ ...filter?.agentId !== void 0 && { agentId: filter.agentId },
2589
2602
  ...filter?.includeOutput === true && { include: "output" }
2590
2603
  }
2591
2604
  });