@agimon-ai/po-log 0.0.0-alpha.44 → 0.0.0-alpha.46

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.
@@ -97,65 +97,89 @@ const apiContracts = (0, _agimon_ai_po_core_apiContracts.defineApiContract)({
97
97
  version: 1,
98
98
  sockets: [],
99
99
  dynamic: [],
100
- http: ["global", "workspace"].flatMap((scope) => [{
101
- id: "log.metrics",
102
- scope,
103
- basePath: "log",
104
- path: "/metrics",
105
- method: "GET",
106
- authentication: "owner",
107
- description: "Read usage metrics from the configured log sink.",
108
- parameters: [
109
- {
110
- name: "dimension",
111
- in: "query",
112
- required: false,
113
- schema: Dimension
100
+ http: ["global", "workspace"].flatMap((scope) => [
101
+ {
102
+ id: "log.metrics",
103
+ scope,
104
+ basePath: "log",
105
+ path: "/metrics",
106
+ method: "GET",
107
+ authentication: "owner",
108
+ description: "Read usage metrics from the configured log sink.",
109
+ parameters: [
110
+ {
111
+ name: "dimension",
112
+ in: "query",
113
+ required: false,
114
+ schema: Dimension
115
+ },
116
+ {
117
+ name: "period",
118
+ in: "query",
119
+ required: false,
120
+ schema: Period
121
+ },
122
+ {
123
+ name: "focus",
124
+ in: "query",
125
+ required: false,
126
+ schema: S
127
+ }
128
+ ],
129
+ responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(MetricsResponseSchema)
130
+ },
131
+ {
132
+ id: "log.issues",
133
+ scope,
134
+ basePath: "log",
135
+ path: "/issues",
136
+ method: "GET",
137
+ authentication: "owner",
138
+ description: "Read log issue details.",
139
+ parameters: [
140
+ {
141
+ name: "focus",
142
+ in: "query",
143
+ required: false,
144
+ schema: S
145
+ },
146
+ {
147
+ name: "startTime",
148
+ in: "query",
149
+ required: false,
150
+ schema: S
151
+ },
152
+ {
153
+ name: "endTime",
154
+ in: "query",
155
+ required: false,
156
+ schema: S
157
+ }
158
+ ],
159
+ responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(IssuesResponseSchema)
160
+ },
161
+ {
162
+ id: "log.ingestLogs",
163
+ scope,
164
+ basePath: "log",
165
+ path: "/v1/logs",
166
+ method: "POST",
167
+ authentication: "owner",
168
+ description: "Forward OTLP/JSON log records from a client to the configured log sink.",
169
+ body: {
170
+ required: true,
171
+ contentType: "application/json",
172
+ schema: typebox.Type.Object({ resourceLogs: typebox.Type.Array(typebox.Type.Unknown()) })
114
173
  },
115
- {
116
- name: "period",
117
- in: "query",
118
- required: false,
119
- schema: Period
120
- },
121
- {
122
- name: "focus",
123
- in: "query",
124
- required: false,
125
- schema: S
126
- }
127
- ],
128
- responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(MetricsResponseSchema)
129
- }, {
130
- id: "log.issues",
131
- scope,
132
- basePath: "log",
133
- path: "/issues",
134
- method: "GET",
135
- authentication: "owner",
136
- description: "Read log issue details.",
137
- parameters: [
138
- {
139
- name: "focus",
140
- in: "query",
141
- required: false,
142
- schema: S
143
- },
144
- {
145
- name: "startTime",
146
- in: "query",
147
- required: false,
148
- schema: S
149
- },
150
- {
151
- name: "endTime",
152
- in: "query",
153
- required: false,
154
- schema: S
174
+ responses: {
175
+ ...(0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(_agimon_ai_po_core_apiContracts.ApiOkSchema),
176
+ "413": {
177
+ description: "Log batch is too large",
178
+ schema: _agimon_ai_po_core_apiContracts.ApiErrorSchema
179
+ }
155
180
  }
156
- ],
157
- responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(IssuesResponseSchema)
158
- }])
181
+ }
182
+ ])
159
183
  });
160
184
  //#endregion
161
185
  exports.apiContracts = apiContracts;
@@ -1 +1 @@
1
- {"version":3,"file":"apiContracts.cjs","names":["Type","defineApiContract","jsonApiResponses"],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst S = Type.String();\nconst N = Type.Number();\nconst B = Type.Boolean();\nconst O = Type.Optional;\nconst literals = <T extends string>(values: T[]) => Type.Union(values.map((value) => Type.Literal(value)));\nconst Dimension = literals(['session', 'agent', 'model', 'provider']);\nconst Period = literals(['day', 'week', 'month', 'all']);\nconst Unavailable = Type.Object({ unavailable: literals(['no-sink', 'no-data', 'no-api', 'query-error']), detail: S });\nconst Tokens = { totalTokens: N, inputTokens: N, outputTokens: N };\nexport const MetricsResponseSchema = Type.Union([\n Unavailable,\n Type.Object({\n generatedAt: S,\n startTime: O(S),\n endTime: O(S),\n dimension: Dimension,\n period: Period,\n bucketUnit: S,\n focus: O(S),\n transport: O(literals(['http', 'worker'])),\n totals: Type.Object({\n usageEventCount: O(N),\n totalRecords: O(N),\n ...Tokens,\n cachedTokens: N,\n reasoningTokens: N,\n groupCount: N,\n failedGroups: N,\n issueCount: N,\n }),\n timeline: Type.Array(Type.Object({ label: S, ...Tokens })),\n groups: Type.Array(Type.Object({ key: S, ...Tokens, issueCount: N, failed: B })),\n tools: Type.Array(Type.Object({ name: S, calls: N, p90TotalTokens: N })),\n }),\n]);\nconst Nullable = Type.Union([S, Type.Null()]);\nexport const IssuesResponseSchema = Type.Union([\n Unavailable,\n Type.Object({\n totalIssues: N,\n uniqueIncidents: N,\n byCategory: Type.Record(S, N),\n byTool: Type.Record(S, N),\n byErrorType: Type.Record(S, N),\n samples: Type.Array(\n Type.Object({\n fingerprint: S,\n occurrenceCount: N,\n category: S,\n timestamp: S,\n level: S,\n message: S,\n detail: S,\n tool: Nullable,\n errorType: Nullable,\n agentName: Nullable,\n model: Nullable,\n statusCode: Nullable,\n }),\n ),\n }),\n]);\nexport const apiContracts = defineApiContract({\n version: 1,\n sockets: [],\n dynamic: [],\n http: (['global', 'workspace'] as const).flatMap((scope) => [\n {\n id: 'log.metrics',\n scope,\n basePath: 'log',\n path: '/metrics',\n method: 'GET',\n authentication: 'owner',\n description: 'Read usage metrics from the configured log sink.',\n parameters: [\n { name: 'dimension', in: 'query', required: false, schema: Dimension },\n { name: 'period', in: 'query', required: false, schema: Period },\n { name: 'focus', in: 'query', required: false, schema: S },\n ],\n responses: jsonApiResponses(MetricsResponseSchema),\n },\n {\n id: 'log.issues',\n scope,\n basePath: 'log',\n path: '/issues',\n method: 'GET',\n authentication: 'owner',\n description: 'Read log issue details.',\n parameters: [\n { name: 'focus', in: 'query', required: false, schema: S },\n { name: 'startTime', in: 'query', required: false, schema: S },\n { name: 'endTime', in: 'query', required: false, schema: S },\n ],\n responses: jsonApiResponses(IssuesResponseSchema),\n },\n ]),\n});\nexport default apiContracts;\n"],"mappings":";;;;;;;AAGA,MAAM,IAAIA,QAAAA,KAAK,OAAO;AACtB,MAAM,IAAIA,QAAAA,KAAK,OAAO;AACtB,MAAM,IAAIA,QAAAA,KAAK,QAAQ;AACvB,MAAM,IAAIA,QAAAA,KAAK;AACf,MAAM,YAA8B,WAAgBA,QAAAA,KAAK,MAAM,OAAO,KAAK,UAAUA,QAAAA,KAAK,QAAQ,KAAK,CAAC,CAAC;AACzG,MAAM,YAAY,SAAS;CAAC;CAAW;CAAS;CAAS;AAAU,CAAC;AACpE,MAAM,SAAS,SAAS;CAAC;CAAO;CAAQ;CAAS;AAAK,CAAC;AACvD,MAAM,cAAcA,QAAAA,KAAK,OAAO;CAAE,aAAa,SAAS;EAAC;EAAW;EAAW;EAAU;CAAa,CAAC;CAAG,QAAQ;AAAE,CAAC;AACrH,MAAM,SAAS;CAAE,aAAa;CAAG,aAAa;CAAG,cAAc;AAAE;AACjE,MAAa,wBAAwBA,QAAAA,KAAK,MAAM,CAC9C,aACAA,QAAAA,KAAK,OAAO;CACV,aAAa;CACb,WAAW,EAAE,CAAC;CACd,SAAS,EAAE,CAAC;CACZ,WAAW;CACX,QAAQ;CACR,YAAY;CACZ,OAAO,EAAE,CAAC;CACV,WAAW,EAAE,SAAS,CAAC,QAAQ,QAAQ,CAAC,CAAC;CACzC,QAAQA,QAAAA,KAAK,OAAO;EAClB,iBAAiB,EAAE,CAAC;EACpB,cA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;IAAE,MAAM;IAAa,IAAI;IAAS,UAAU;IAAO,QAAQ;GAAU;GACrE;IAAE,MAAM;IAAU,IAAI;IAAS,UAAU;IAAO,QAAQ;GAAO;GAC/D;IAAE,MAAM;IAAS,IAAI;IAAS,UAAU;IAAO,QAAQ;GAAE;EAC3D;EACA,YAAA,GAAWC,gCAAAA,iBAAAA,CAAiB,qBAAqB;CACnD,GACA;EACE,IAAI;EACJ;EACA,UAAU;EACV,MAAM;EACN,QAAQ;EACR,gBAAgB;EAChB,aAAa;EACb,YAAY;GACV;IAAE,MAAM;IAAS,IAAI;IAAS,UAAU;IAAO,QAAQ;GAAE;GACzD;IAAE,MAAM;IAAa,IAAI;IAAS,UAAU;IAAO,QAAQ;GAAE;GAC7D;IAAE,MAAM;IAAW,IAAI;IAAS,UAAU;IAAO,QAAQ;GAAE;EAC7D;EACA,YAAA,GAAWA,gCAAAA,iBAAAA,CAAiB,oBAAoB;CAClD,CACF,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"apiContracts.cjs","names":["Type","defineApiContract","jsonApiResponses","ApiOkSchema","ApiErrorSchema"],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { ApiErrorSchema, ApiOkSchema, defineApiContract, jsonApiResponses } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst S = Type.String();\nconst N = Type.Number();\nconst B = Type.Boolean();\nconst O = Type.Optional;\nconst literals = <T extends string>(values: T[]) => Type.Union(values.map((value) => Type.Literal(value)));\nconst Dimension = literals(['session', 'agent', 'model', 'provider']);\nconst Period = literals(['day', 'week', 'month', 'all']);\nconst Unavailable = Type.Object({ unavailable: literals(['no-sink', 'no-data', 'no-api', 'query-error']), detail: S });\nconst Tokens = { totalTokens: N, inputTokens: N, outputTokens: N };\nexport const MetricsResponseSchema = Type.Union([\n Unavailable,\n Type.Object({\n generatedAt: S,\n startTime: O(S),\n endTime: O(S),\n dimension: Dimension,\n period: Period,\n bucketUnit: S,\n focus: O(S),\n transport: O(literals(['http', 'worker'])),\n totals: Type.Object({\n usageEventCount: O(N),\n totalRecords: O(N),\n ...Tokens,\n cachedTokens: N,\n reasoningTokens: N,\n groupCount: N,\n failedGroups: N,\n issueCount: N,\n }),\n timeline: Type.Array(Type.Object({ label: S, ...Tokens })),\n groups: Type.Array(Type.Object({ key: S, ...Tokens, issueCount: N, failed: B })),\n tools: Type.Array(Type.Object({ name: S, calls: N, p90TotalTokens: N })),\n }),\n]);\nconst Nullable = Type.Union([S, Type.Null()]);\nexport const IssuesResponseSchema = Type.Union([\n Unavailable,\n Type.Object({\n totalIssues: N,\n uniqueIncidents: N,\n byCategory: Type.Record(S, N),\n byTool: Type.Record(S, N),\n byErrorType: Type.Record(S, N),\n samples: Type.Array(\n Type.Object({\n fingerprint: S,\n occurrenceCount: N,\n category: S,\n timestamp: S,\n level: S,\n message: S,\n detail: S,\n tool: Nullable,\n errorType: Nullable,\n agentName: Nullable,\n model: Nullable,\n statusCode: Nullable,\n }),\n ),\n }),\n]);\nexport const apiContracts = defineApiContract({\n version: 1,\n sockets: [],\n dynamic: [],\n http: (['global', 'workspace'] as const).flatMap((scope) => [\n {\n id: 'log.metrics',\n scope,\n basePath: 'log',\n path: '/metrics',\n method: 'GET',\n authentication: 'owner',\n description: 'Read usage metrics from the configured log sink.',\n parameters: [\n { name: 'dimension', in: 'query', required: false, schema: Dimension },\n { name: 'period', in: 'query', required: false, schema: Period },\n { name: 'focus', in: 'query', required: false, schema: S },\n ],\n responses: jsonApiResponses(MetricsResponseSchema),\n },\n {\n id: 'log.issues',\n scope,\n basePath: 'log',\n path: '/issues',\n method: 'GET',\n authentication: 'owner',\n description: 'Read log issue details.',\n parameters: [\n { name: 'focus', in: 'query', required: false, schema: S },\n { name: 'startTime', in: 'query', required: false, schema: S },\n { name: 'endTime', in: 'query', required: false, schema: S },\n ],\n responses: jsonApiResponses(IssuesResponseSchema),\n },\n {\n id: 'log.ingestLogs',\n scope,\n basePath: 'log',\n path: '/v1/logs',\n method: 'POST',\n authentication: 'owner',\n description: 'Forward OTLP/JSON log records from a client to the configured log sink.',\n body: {\n required: true,\n contentType: 'application/json',\n schema: Type.Object({ resourceLogs: Type.Array(Type.Unknown()) }),\n },\n responses: {\n ...jsonApiResponses(ApiOkSchema),\n '413': { description: 'Log batch is too large', schema: ApiErrorSchema },\n },\n },\n ]),\n});\nexport default apiContracts;\n"],"mappings":";;;;;;;AAGA,MAAM,IAAIA,QAAAA,KAAK,OAAO;AACtB,MAAM,IAAIA,QAAAA,KAAK,OAAO;AACtB,MAAM,IAAIA,QAAAA,KAAK,QAAQ;AACvB,MAAM,IAAIA,QAAAA,KAAK;AACf,MAAM,YAA8B,WAAgBA,QAAAA,KAAK,MAAM,OAAO,KAAK,UAAUA,QAAAA,KAAK,QAAQ,KAAK,CAAC,CAAC;AACzG,MAAM,YAAY,SAAS;CAAC;CAAW;CAAS;CAAS;AAAU,CAAC;AACpE,MAAM,SAAS,SAAS;CAAC;CAAO;CAAQ;CAAS;AAAK,CAAC;AACvD,MAAM,cAAcA,QAAAA,KAAK,OAAO;CAAE,aAAa,SAAS;EAAC;EAAW;EAAW;EAAU;CAAa,CAAC;CAAG,QAAQ;AAAE,CAAC;AACrH,MAAM,SAAS;CAAE,aAAa;CAAG,aAAa;CAAG,cAAc;AAAE;AACjE,MAAa,wBAAwBA,QAAAA,KAAK,MAAM,CAC9C,aACAA,QAAAA,KAAK,OAAO;CACV,aAAa;CACb,WAAW,EAAE,CAAC;CACd,SAAS,EAAE,CAAC;CACZ,WAAW;CACX,QAAQ;CACR,YAAY;CACZ,OAAO,EAAE,CAAC;CACV,WAAW,EAAE,SAAS,CAAC,QAAQ,QAAQ,CAAC,CAAC;CACzC,QAAQA,QAAAA,KAAK,OAAO;EAClB,iBAAiB,EAAE,CAAC;EACpB,cAAc,EAAE,CAAC;EACjB,GAAG;EACH,cAAc;EACd,iBAAiB;EACjB,YAAY;EACZ,cAAc;EACd,YAAY;CACd,CAAC;CACD,UAAUA,QAAAA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O;IAC/D;KAAE,MAAM;KAAS,IAAI;KAAS,UAAU;KAAO,QAAQ;IAAE;GAC3D;GACA,YAAA,GAAWC,gCAAAA,iBAAAA,CAAiB,qBAAqB;EACnD;EACA;GACE,IAAI;GACJ;GACA,UAAU;GACV,MAAM;GACN,QAAQ;GACR,gBAAgB;GAChB,aAAa;GACb,YAAY;IACV;KAAE,MAAM;KAAS,IAAI;KAAS,UAAU;KAAO,QAAQ;IAAE;IACzD;KAAE,MAAM;KAAa,IAAI;KAAS,UAAU;KAAO,QAAQ;IAAE;IAC7D;KAAE,MAAM;KAAW,IAAI;KAAS,UAAU;KAAO,QAAQ;IAAE;GAC7D;GACA,YAAA,GAAWA,gCAAAA,iBAAAA,CAAiB,oBAAoB;EAClD;EACA;GACE,IAAI;GACJ;GACA,UAAU;GACV,MAAM;GACN,QAAQ;GACR,gBAAgB;GAChB,aAAa;GACb,MAAM;IACJ,UAAU;IACV,aAAa;IACb,QAAQF,QAAAA,KAAK,OAAO,EAAE,cAAcA,QAAAA,KAAK,MAAMA,QAAAA,KAAK,QAAQ,CAAC,EAAE,CAAC;GAClE;GACA,WAAW;IACT,IAAA,GAAGE,gCAAAA,iBAAAA,CAAiBC,gCAAAA,WAAW;IAC/B,OAAO;KAAE,aAAa;KAA0B,QAAQC,gCAAAA;IAAe;GACzE;EACF;CACF,CAAC;AACH,CAAC"}
@@ -1,4 +1,4 @@
1
- import { defineApiContract, jsonApiResponses } from "@agimon-ai/po-core/apiContracts";
1
+ import { ApiErrorSchema, ApiOkSchema, defineApiContract, jsonApiResponses } from "@agimon-ai/po-core/apiContracts";
2
2
  import { Type } from "typebox";
3
3
  //#region src/schemas/apiContracts.ts
4
4
  const S = Type.String();
@@ -93,65 +93,89 @@ const apiContracts = defineApiContract({
93
93
  version: 1,
94
94
  sockets: [],
95
95
  dynamic: [],
96
- http: ["global", "workspace"].flatMap((scope) => [{
97
- id: "log.metrics",
98
- scope,
99
- basePath: "log",
100
- path: "/metrics",
101
- method: "GET",
102
- authentication: "owner",
103
- description: "Read usage metrics from the configured log sink.",
104
- parameters: [
105
- {
106
- name: "dimension",
107
- in: "query",
108
- required: false,
109
- schema: Dimension
96
+ http: ["global", "workspace"].flatMap((scope) => [
97
+ {
98
+ id: "log.metrics",
99
+ scope,
100
+ basePath: "log",
101
+ path: "/metrics",
102
+ method: "GET",
103
+ authentication: "owner",
104
+ description: "Read usage metrics from the configured log sink.",
105
+ parameters: [
106
+ {
107
+ name: "dimension",
108
+ in: "query",
109
+ required: false,
110
+ schema: Dimension
111
+ },
112
+ {
113
+ name: "period",
114
+ in: "query",
115
+ required: false,
116
+ schema: Period
117
+ },
118
+ {
119
+ name: "focus",
120
+ in: "query",
121
+ required: false,
122
+ schema: S
123
+ }
124
+ ],
125
+ responses: jsonApiResponses(MetricsResponseSchema)
126
+ },
127
+ {
128
+ id: "log.issues",
129
+ scope,
130
+ basePath: "log",
131
+ path: "/issues",
132
+ method: "GET",
133
+ authentication: "owner",
134
+ description: "Read log issue details.",
135
+ parameters: [
136
+ {
137
+ name: "focus",
138
+ in: "query",
139
+ required: false,
140
+ schema: S
141
+ },
142
+ {
143
+ name: "startTime",
144
+ in: "query",
145
+ required: false,
146
+ schema: S
147
+ },
148
+ {
149
+ name: "endTime",
150
+ in: "query",
151
+ required: false,
152
+ schema: S
153
+ }
154
+ ],
155
+ responses: jsonApiResponses(IssuesResponseSchema)
156
+ },
157
+ {
158
+ id: "log.ingestLogs",
159
+ scope,
160
+ basePath: "log",
161
+ path: "/v1/logs",
162
+ method: "POST",
163
+ authentication: "owner",
164
+ description: "Forward OTLP/JSON log records from a client to the configured log sink.",
165
+ body: {
166
+ required: true,
167
+ contentType: "application/json",
168
+ schema: Type.Object({ resourceLogs: Type.Array(Type.Unknown()) })
110
169
  },
111
- {
112
- name: "period",
113
- in: "query",
114
- required: false,
115
- schema: Period
116
- },
117
- {
118
- name: "focus",
119
- in: "query",
120
- required: false,
121
- schema: S
122
- }
123
- ],
124
- responses: jsonApiResponses(MetricsResponseSchema)
125
- }, {
126
- id: "log.issues",
127
- scope,
128
- basePath: "log",
129
- path: "/issues",
130
- method: "GET",
131
- authentication: "owner",
132
- description: "Read log issue details.",
133
- parameters: [
134
- {
135
- name: "focus",
136
- in: "query",
137
- required: false,
138
- schema: S
139
- },
140
- {
141
- name: "startTime",
142
- in: "query",
143
- required: false,
144
- schema: S
145
- },
146
- {
147
- name: "endTime",
148
- in: "query",
149
- required: false,
150
- schema: S
170
+ responses: {
171
+ ...jsonApiResponses(ApiOkSchema),
172
+ "413": {
173
+ description: "Log batch is too large",
174
+ schema: ApiErrorSchema
175
+ }
151
176
  }
152
- ],
153
- responses: jsonApiResponses(IssuesResponseSchema)
154
- }])
177
+ }
178
+ ])
155
179
  });
156
180
  //#endregion
157
181
  export { apiContracts, apiContracts as default };
@@ -1 +1 @@
1
- {"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst S = Type.String();\nconst N = Type.Number();\nconst B = Type.Boolean();\nconst O = Type.Optional;\nconst literals = <T extends string>(values: T[]) => Type.Union(values.map((value) => Type.Literal(value)));\nconst Dimension = literals(['session', 'agent', 'model', 'provider']);\nconst Period = literals(['day', 'week', 'month', 'all']);\nconst Unavailable = Type.Object({ unavailable: literals(['no-sink', 'no-data', 'no-api', 'query-error']), detail: S });\nconst Tokens = { totalTokens: N, inputTokens: N, outputTokens: N };\nexport const MetricsResponseSchema = Type.Union([\n Unavailable,\n Type.Object({\n generatedAt: S,\n startTime: O(S),\n endTime: O(S),\n dimension: Dimension,\n period: Period,\n bucketUnit: S,\n focus: O(S),\n transport: O(literals(['http', 'worker'])),\n totals: Type.Object({\n usageEventCount: O(N),\n totalRecords: O(N),\n ...Tokens,\n cachedTokens: N,\n reasoningTokens: N,\n groupCount: N,\n failedGroups: N,\n issueCount: N,\n }),\n timeline: Type.Array(Type.Object({ label: S, ...Tokens })),\n groups: Type.Array(Type.Object({ key: S, ...Tokens, issueCount: N, failed: B })),\n tools: Type.Array(Type.Object({ name: S, calls: N, p90TotalTokens: N })),\n }),\n]);\nconst Nullable = Type.Union([S, Type.Null()]);\nexport const IssuesResponseSchema = Type.Union([\n Unavailable,\n Type.Object({\n totalIssues: N,\n uniqueIncidents: N,\n byCategory: Type.Record(S, N),\n byTool: Type.Record(S, N),\n byErrorType: Type.Record(S, N),\n samples: Type.Array(\n Type.Object({\n fingerprint: S,\n occurrenceCount: N,\n category: S,\n timestamp: S,\n level: S,\n message: S,\n detail: S,\n tool: Nullable,\n errorType: Nullable,\n agentName: Nullable,\n model: Nullable,\n statusCode: Nullable,\n }),\n ),\n }),\n]);\nexport const apiContracts = defineApiContract({\n version: 1,\n sockets: [],\n dynamic: [],\n http: (['global', 'workspace'] as const).flatMap((scope) => [\n {\n id: 'log.metrics',\n scope,\n basePath: 'log',\n path: '/metrics',\n method: 'GET',\n authentication: 'owner',\n description: 'Read usage metrics from the configured log sink.',\n parameters: [\n { name: 'dimension', in: 'query', required: false, schema: Dimension },\n { name: 'period', in: 'query', required: false, schema: Period },\n { name: 'focus', in: 'query', required: false, schema: S },\n ],\n responses: jsonApiResponses(MetricsResponseSchema),\n },\n {\n id: 'log.issues',\n scope,\n basePath: 'log',\n path: '/issues',\n method: 'GET',\n authentication: 'owner',\n description: 'Read log issue details.',\n parameters: [\n { name: 'focus', in: 'query', required: false, schema: S },\n { name: 'startTime', in: 'query', required: false, schema: S },\n { name: 'endTime', in: 'query', required: false, schema: S },\n ],\n responses: jsonApiResponses(IssuesResponseSchema),\n },\n ]),\n});\nexport default apiContracts;\n"],"mappings":";;;AAGA,MAAM,IAAI,KAAK,OAAO;AACtB,MAAM,IAAI,KAAK,OAAO;AACtB,MAAM,IAAI,KAAK,QAAQ;AACvB,MAAM,IAAI,KAAK;AACf,MAAM,YAA8B,WAAgB,KAAK,MAAM,OAAO,KAAK,UAAU,KAAK,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a,KAAK,OAAO,GAAG,CAAC;CAC7B,SAAS,KAAK,MACZ,KAAK,OAAO;EACV,aAAa;EACb,iBAAiB;EACjB,UAAU;EACV,WAAW;EACX,OAAO;EACP,SAAS;EACT,QAAQ;EACR,MAAM;EACN,WAAW;EACX,WAAW;EACX,OAAO;EACP,YAAY;CACd,CAAC,CACH;AACF,CAAC,CACH,CAAC;AACD,MAAa,eAAe,kBAAkB;CAC5C,SAAS;CACT,SAAS,CAAC;CACV,SAAS,CAAC;CACV,MAAO,CAAC,UAAU,WAAW,CAAC,CAAW,SAAS,UAAU,CAC1D;EACE,IAAI;EACJ;EACA,UAAU;EACV,MAAM;EACN,QAAQ;EACR,gBAAgB;EAChB,aAAa;EACb,YAAY;GACV;IAAE,MAAM;IAAa,IAAI;IAAS,UAAU;IAAO,QAAQ;GAAU;GACrE;IAAE,MAAM;IAAU,IAAI;IAAS,UAAU;IAAO,QAAQ;GAAO;GAC/D;IAAE,MAAM;IAAS,IAAI;IAAS,UAAU;IAAO,QAAQ;GAAE;EAC3D;EACA,WAAW,iBAAiB,qBAAqB;CACnD,GACA;EACE,IAAI;EACJ;EACA,UAAU;EACV,MAAM;EACN,QAAQ;EACR,gBAAgB;EAChB,aAAa;EACb,YAAY;GACV;IAAE,MAAM;IAAS,IAAI;IAAS,UAAU;IAAO,QAAQ;GAAE;GACzD;IAAE,MAAM;IAAa,IAAI;IAAS,UAAU;IAAO,QAAQ;GAAE;GAC7D;IAAE,MAAM;IAAW,IAAI;IAAS,UAAU;IAAO,QAAQ;GAAE;EAC7D;EACA,WAAW,iBAAiB,oBAAoB;CAClD,CACF,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { ApiErrorSchema, ApiOkSchema, defineApiContract, jsonApiResponses } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst S = Type.String();\nconst N = Type.Number();\nconst B = Type.Boolean();\nconst O = Type.Optional;\nconst literals = <T extends string>(values: T[]) => Type.Union(values.map((value) => Type.Literal(value)));\nconst Dimension = literals(['session', 'agent', 'model', 'provider']);\nconst Period = literals(['day', 'week', 'month', 'all']);\nconst Unavailable = Type.Object({ unavailable: literals(['no-sink', 'no-data', 'no-api', 'query-error']), detail: S });\nconst Tokens = { totalTokens: N, inputTokens: N, outputTokens: N };\nexport const MetricsResponseSchema = Type.Union([\n Unavailable,\n Type.Object({\n generatedAt: S,\n startTime: O(S),\n endTime: O(S),\n dimension: Dimension,\n period: Period,\n bucketUnit: S,\n focus: O(S),\n transport: O(literals(['http', 'worker'])),\n totals: Type.Object({\n usageEventCount: O(N),\n totalRecords: O(N),\n ...Tokens,\n cachedTokens: N,\n reasoningTokens: N,\n groupCount: N,\n failedGroups: N,\n issueCount: N,\n }),\n timeline: Type.Array(Type.Object({ label: S, ...Tokens })),\n groups: Type.Array(Type.Object({ key: S, ...Tokens, issueCount: N, failed: B })),\n tools: Type.Array(Type.Object({ name: S, calls: N, p90TotalTokens: N })),\n }),\n]);\nconst Nullable = Type.Union([S, Type.Null()]);\nexport const IssuesResponseSchema = Type.Union([\n Unavailable,\n Type.Object({\n totalIssues: N,\n uniqueIncidents: N,\n byCategory: Type.Record(S, N),\n byTool: Type.Record(S, N),\n byErrorType: Type.Record(S, N),\n samples: Type.Array(\n Type.Object({\n fingerprint: S,\n occurrenceCount: N,\n category: S,\n timestamp: S,\n level: S,\n message: S,\n detail: S,\n tool: Nullable,\n errorType: Nullable,\n agentName: Nullable,\n model: Nullable,\n statusCode: Nullable,\n }),\n ),\n }),\n]);\nexport const apiContracts = defineApiContract({\n version: 1,\n sockets: [],\n dynamic: [],\n http: (['global', 'workspace'] as const).flatMap((scope) => [\n {\n id: 'log.metrics',\n scope,\n basePath: 'log',\n path: '/metrics',\n method: 'GET',\n authentication: 'owner',\n description: 'Read usage metrics from the configured log sink.',\n parameters: [\n { name: 'dimension', in: 'query', required: false, schema: Dimension },\n { name: 'period', in: 'query', required: false, schema: Period },\n { name: 'focus', in: 'query', required: false, schema: S },\n ],\n responses: jsonApiResponses(MetricsResponseSchema),\n },\n {\n id: 'log.issues',\n scope,\n basePath: 'log',\n path: '/issues',\n method: 'GET',\n authentication: 'owner',\n description: 'Read log issue details.',\n parameters: [\n { name: 'focus', in: 'query', required: false, schema: S },\n { name: 'startTime', in: 'query', required: false, schema: S },\n { name: 'endTime', in: 'query', required: false, schema: S },\n ],\n responses: jsonApiResponses(IssuesResponseSchema),\n },\n {\n id: 'log.ingestLogs',\n scope,\n basePath: 'log',\n path: '/v1/logs',\n method: 'POST',\n authentication: 'owner',\n description: 'Forward OTLP/JSON log records from a client to the configured log sink.',\n body: {\n required: true,\n contentType: 'application/json',\n schema: Type.Object({ resourceLogs: Type.Array(Type.Unknown()) }),\n },\n responses: {\n ...jsonApiResponses(ApiOkSchema),\n '413': { description: 'Log batch is too large', schema: ApiErrorSchema },\n },\n },\n ]),\n});\nexport default apiContracts;\n"],"mappings":";;;AAGA,MAAM,IAAI,KAAK,OAAO;AACtB,MAAM,IAAI,KAAK,OAAO;AACtB,MAAM,IAAI,KAAK,QAAQ;AACvB,MAAM,IAAI,KAAK;AACf,MAAM,YAA8B,WAAgB,KAAK,MAAM,OAAO,KAAK,UAAU,KAAK,QAAQ,KAAK,CAAC,CAAC;AACzG,MAAM,YAAY,SAAS;CAAC;CAAW;CAAS;CAAS;AAAU,CAAC;AACpE,MAAM,SAAS,SAAS;CAAC;CAAO;CAAQ;CAAS;AAAK,CAAC;AACvD,MAAM,cAAc,KAAK,OAAO;CAAE,aAAa,SAAS;EAAC;EAAW;EAAW;EAAU;CAAa,CAAC;CAAG,QAAQ;AAAE,CAAC;AACrH,MAAM,SAAS;CAAE,aAAa;CAAG,aAAa;CAAG,cAAc;AAAE;AACjE,MAAa,wBAAwB,KAAK,MAAM,CAC9C,aACA,KAAK,OAAO;CACV,aAAa;CACb,WAAW,EAAE,CAAC;CACd,SAAS,EAAE,CAAC;CACZ,WAAW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