@cadenya/cadenya 0.103.0 → 0.104.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.
@@ -170,6 +170,24 @@ export class Objectives extends APIResource {
170
170
  );
171
171
  }
172
172
 
173
+ /**
174
+ * Returns the context-usage breakdown measured for the objective's most recent
175
+ * iteration: character lengths per context component (system prompt, memory
176
+ * appendices, tool definitions, messages by role) alongside the iteration's input
177
+ * token counts.
178
+ */
179
+ retrieveDiagnostics(
180
+ objectiveID: string,
181
+ params: ObjectiveRetrieveDiagnosticsParams,
182
+ options?: RequestOptions,
183
+ ): APIPromise<ObjectiveRetrieveDiagnosticsResponse> {
184
+ const { workspaceId } = params;
185
+ return this._client.get(
186
+ path`/v1/workspaces/${workspaceId}/objectives/${objectiveID}/diagnostics`,
187
+ options,
188
+ );
189
+ }
190
+
173
191
  /**
174
192
  * Streams events for an objective in real-time using server-sent events (SSE)
175
193
  */
@@ -236,6 +254,59 @@ export interface CallableTool {
236
254
  tool?: Shared.ResourceMetadata;
237
255
  }
238
256
 
257
+ /**
258
+ * ContextLengths is the measured character length of each distinct component of an
259
+ * iteration's assembled context window. Values are raw character lengths of the
260
+ * component as assembled into the request — token estimates are derived by the
261
+ * client against input_tokens (component share = component length / sum of all
262
+ * lengths).
263
+ *
264
+ * New components are added as new fields — wire-compatible; absent components read
265
+ * as 0.
266
+ */
267
+ export interface ContextLengths {
268
+ /**
269
+ * Chat history messages with the assistant role.
270
+ */
271
+ assistantMessages: number;
272
+
273
+ /**
274
+ * The discoverable/available-tools appendix attached to the system prompt.
275
+ */
276
+ availableTools: number;
277
+
278
+ /**
279
+ * The episodic memory appendix attached to the system prompt.
280
+ */
281
+ episodicMemory: number;
282
+
283
+ /**
284
+ * The skills memory appendix attached to the system prompt.
285
+ */
286
+ skillsMemory: number;
287
+
288
+ /**
289
+ * The objective's base system prompt (rendered variation template).
290
+ */
291
+ systemPrompt: number;
292
+
293
+ /**
294
+ * Serialized tool definitions sent with the completion request (names,
295
+ * descriptions, and JSON-schema parameters).
296
+ */
297
+ toolDefinitions: number;
298
+
299
+ /**
300
+ * Tool results present in the chat history.
301
+ */
302
+ toolResults: number;
303
+
304
+ /**
305
+ * Chat history messages with the user role.
306
+ */
307
+ userMessages: number;
308
+ }
309
+
239
310
  export interface ContextWindowCompacted {
240
311
  /**
241
312
  * Number of messages that were compacted
@@ -515,6 +586,37 @@ export interface ObjectiveContextWindowData {
515
586
  sequence?: number;
516
587
  }
517
588
 
589
+ /**
590
+ * ObjectiveDiagnostics is the context-usage breakdown measured for a single
591
+ * iteration at request-assembly time. It reports how much of the context window
592
+ * each component occupies so tool parameters, memory cascades, and prompts can be
593
+ * tuned against real token usage.
594
+ */
595
+ export interface ObjectiveDiagnostics {
596
+ /**
597
+ * The portion of input_tokens served from the provider's prompt cache. Lets
598
+ * clients distinguish "big but cached" from "big and paid fresh every iteration".
599
+ */
600
+ cachedInputTokens: number;
601
+
602
+ /**
603
+ * ContextLengths is the measured character length of each distinct component of an
604
+ * iteration's assembled context window. Values are raw character lengths of the
605
+ * component as assembled into the request — token estimates are derived by the
606
+ * client against input_tokens (component share = component length / sum of all
607
+ * lengths).
608
+ *
609
+ * New components are added as new fields — wire-compatible; absent components read
610
+ * as 0.
611
+ */
612
+ contextLengths: ContextLengths;
613
+
614
+ /**
615
+ * Input tokens reported by the LLM provider for the iteration's completion.
616
+ */
617
+ inputTokens: number;
618
+ }
619
+
518
620
  export interface ObjectiveError {
519
621
  message?: string;
520
622
 
@@ -899,6 +1001,16 @@ export interface ObjectiveCompactResponse {
899
1001
  contextWindow?: ObjectiveContextWindowData;
900
1002
  }
901
1003
 
1004
+ export interface ObjectiveRetrieveDiagnosticsResponse {
1005
+ /**
1006
+ * ObjectiveDiagnostics is the context-usage breakdown measured for a single
1007
+ * iteration at request-assembly time. It reports how much of the context window
1008
+ * each component occupies so tool parameters, memory cascades, and prompts can be
1009
+ * tuned against real token usage.
1010
+ */
1011
+ diagnostics: ObjectiveDiagnostics;
1012
+ }
1013
+
902
1014
  export interface ObjectiveCreateParams {
903
1015
  agentId: string;
904
1016
 
@@ -1115,6 +1227,10 @@ export interface ObjectiveListEventsParams extends CursorPaginationParams {
1115
1227
  windowId?: string;
1116
1228
  }
1117
1229
 
1230
+ export interface ObjectiveRetrieveDiagnosticsParams {
1231
+ workspaceId: string;
1232
+ }
1233
+
1118
1234
  export interface ObjectiveStreamEventsParams {
1119
1235
  workspaceId: string;
1120
1236
  }
@@ -1129,6 +1245,7 @@ export declare namespace Objectives {
1129
1245
  type AssistantMessage as AssistantMessage,
1130
1246
  type AssistantToolCall as AssistantToolCall,
1131
1247
  type CallableTool as CallableTool,
1248
+ type ContextLengths as ContextLengths,
1132
1249
  type ContextWindowCompacted as ContextWindowCompacted,
1133
1250
  type MemoryRead as MemoryRead,
1134
1251
  type MemoryReference as MemoryReference,
@@ -1136,6 +1253,7 @@ export declare namespace Objectives {
1136
1253
  type ObjectiveConfigSnapshot as ObjectiveConfigSnapshot,
1137
1254
  type ObjectiveContextWindow as ObjectiveContextWindow,
1138
1255
  type ObjectiveContextWindowData as ObjectiveContextWindowData,
1256
+ type ObjectiveDiagnostics as ObjectiveDiagnostics,
1139
1257
  type ObjectiveError as ObjectiveError,
1140
1258
  type ObjectiveEvent as ObjectiveEvent,
1141
1259
  type ObjectiveEventData as ObjectiveEventData,
@@ -1153,6 +1271,7 @@ export declare namespace Objectives {
1153
1271
  type ToolResult as ToolResult,
1154
1272
  type UserMessage as UserMessage,
1155
1273
  type ObjectiveCompactResponse as ObjectiveCompactResponse,
1274
+ type ObjectiveRetrieveDiagnosticsResponse as ObjectiveRetrieveDiagnosticsResponse,
1156
1275
  type ObjectivesCursorPagination as ObjectivesCursorPagination,
1157
1276
  type ObjectiveContextWindowsCursorPagination as ObjectiveContextWindowsCursorPagination,
1158
1277
  type ObjectiveEventsCursorPagination as ObjectiveEventsCursorPagination,
@@ -1164,6 +1283,7 @@ export declare namespace Objectives {
1164
1283
  type ObjectiveContinueParams as ObjectiveContinueParams,
1165
1284
  type ObjectiveListContextWindowsParams as ObjectiveListContextWindowsParams,
1166
1285
  type ObjectiveListEventsParams as ObjectiveListEventsParams,
1286
+ type ObjectiveRetrieveDiagnosticsParams as ObjectiveRetrieveDiagnosticsParams,
1167
1287
  type ObjectiveStreamEventsParams as ObjectiveStreamEventsParams,
1168
1288
  };
1169
1289
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.103.0'; // x-release-please-version
1
+ export const VERSION = '0.104.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.103.0";
1
+ export declare const VERSION = "0.104.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.103.0";
1
+ export declare const VERSION = "0.104.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.103.0'; // x-release-please-version
4
+ exports.VERSION = '0.104.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.103.0'; // x-release-please-version
1
+ export const VERSION = '0.104.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map