@contraagent/api 0.6.1 → 0.7.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/src/schema.ts CHANGED
@@ -162,6 +162,26 @@ export type paths = {
162
162
  patch?: never;
163
163
  trace?: never;
164
164
  };
165
+ "/api/runs/{run}/forecast": {
166
+ parameters: {
167
+ query?: never;
168
+ header?: never;
169
+ path?: never;
170
+ cookie?: never;
171
+ };
172
+ /**
173
+ * Api Forecast
174
+ * @description The tasks the run is expected to create and has not yet, from the run of the same flow that finished last before it started; a display only.
175
+ */
176
+ get: operations["api_forecast_api_runs__run__forecast_get"];
177
+ put?: never;
178
+ post?: never;
179
+ delete?: never;
180
+ options?: never;
181
+ head?: never;
182
+ patch?: never;
183
+ trace?: never;
184
+ };
165
185
  "/api/runs/{run}/definitions": {
166
186
  parameters: {
167
187
  query?: never;
@@ -609,14 +629,17 @@ export type components = {
609
629
  executor?: "agent" | "python";
610
630
  /**
611
631
  * Params
612
- * @description the task's params that are strings, numbers or booleans; an earlier task's output is one of `inputs`
632
+ * @description the task's params that are strings, numbers or booleans
613
633
  */
614
634
  params?: {
615
635
  [key: string]: string | number | boolean;
616
636
  };
617
637
  /** Outputs */
618
638
  outputs?: components["schemas"]["ContractSpec"][];
619
- /** Inputs */
639
+ /**
640
+ * Inputs
641
+ * @description its input contracts (`InputContract`, from a `TaskAdapter` of the engine), checked before it starts
642
+ */
620
643
  inputs?: components["schemas"]["ContractSpec"][];
621
644
  } & {
622
645
  [key: string]: unknown;
@@ -791,8 +814,8 @@ export type components = {
791
814
  * DeferralCause
792
815
  * @description Why a task was deferred, as data (`Deferral.cause`). `cause`: `deadline`,
793
816
  * `grace_window` (past the deadline's grace window), `cannot_finish` (`need_s`, `left_s`),
794
- * `dependency_not_queued`, `dependency_deferred` (a task whose output it reads was
795
- * deferred: `dependency`), `rest` (the credential of every hop it could take rests:
817
+ * `dependency_not_queued`, `dependency_deferred` (written by releases before 0.7: a task
818
+ * whose output it read was deferred, `dependency`), `rest` (the credential of every hop it could take rests:
796
819
  * `rests`), or a runner's own name. A field a cause does not have is left unset, and
797
820
  * `deferred.jsonl` records only the fields set.
798
821
  */
@@ -822,7 +845,7 @@ export type components = {
822
845
  rests?: components["schemas"]["SkippedHop"][];
823
846
  /**
824
847
  * Dependency
825
- * @description `dependency_deferred`: the key of the deferred task whose output it reads
848
+ * @description `dependency_deferred` (releases before 0.7): the key of the deferred task whose output it read
826
849
  */
827
850
  dependency?: string | null;
828
851
  };
@@ -840,7 +863,10 @@ export type components = {
840
863
  } & {
841
864
  [key: string]: unknown;
842
865
  };
843
- /** DownstreamTask */
866
+ /**
867
+ * DownstreamTask
868
+ * @description A later task: one given from this task, waiting for it, or created from it.
869
+ */
844
870
  DownstreamTask: {
845
871
  /** Key */
846
872
  key: string;
@@ -853,6 +879,11 @@ export type components = {
853
879
  * @enum {string}
854
880
  */
855
881
  executor: "agent" | "python";
882
+ /**
883
+ * Lineage
884
+ * @description how it is joined to this task, in the order `given_from`, `after`, `created_from`
885
+ */
886
+ lineage?: ("given_from" | "after" | "created_from")[];
856
887
  };
857
888
  /**
858
889
  * DroppedRoute
@@ -1020,8 +1051,129 @@ export type components = {
1020
1051
  * @description `<type>: <message>` of what it raised (or what cancelling it raised); else null
1021
1052
  */
1022
1053
  error?: string | null;
1054
+ /** @description for one that raised: where the exception left its own code (mostly the `await` that failed), its file as `flow` gives it; else null */
1055
+ raised_at?: components["schemas"]["Frame"] | null;
1056
+ /**
1057
+ * Raised By
1058
+ * @description for one that raised: the key of the failed task the exception is, the same in every flow call it passes through; null for an exception of flow code's own
1059
+ */
1060
+ raised_by?: string | null;
1023
1061
  /** @description its own deadline, for a flow call started through `time_box`; else null */
1024
1062
  time_box?: components["schemas"]["TimeBoxRecord"] | null;
1063
+ /**
1064
+ * Unawaited
1065
+ * @description for a top flow call that ended: the keys of the tasks created in it or in the flow calls it started that nothing awaited, waited for with `after=` or returned; they ran all the same
1066
+ */
1067
+ unawaited?: string[];
1068
+ };
1069
+ /**
1070
+ * Forecast
1071
+ * @description The tasks the run is expected to create and has not yet, with their wall time and
1072
+ * cost, from the run of the same flow that finished last before it started (`run.json`
1073
+ * `flow`). A display only: the schedule never reads it, and a run that creates fewer or
1074
+ * more tasks than the earlier run is no error.
1075
+ */
1076
+ Forecast: {
1077
+ /**
1078
+ * Flow
1079
+ * @description `module.qualname` of the run's top flow (`run.json` `flow`); empty for a run of an earlier release
1080
+ */
1081
+ flow: string;
1082
+ /**
1083
+ * Earlier Run
1084
+ * @description the run it reads; empty when no run of the same flow finished before this one started
1085
+ */
1086
+ earlier_run: string;
1087
+ /**
1088
+ * Earlier Finished At
1089
+ * @description when the earlier run finished, ISO 8601; empty when there is none
1090
+ */
1091
+ earlier_finished_at: string;
1092
+ /**
1093
+ * Entries
1094
+ * @description by tail key, in the order the earlier run created the first task of each
1095
+ */
1096
+ entries: components["schemas"]["ForecastEntry"][];
1097
+ /**
1098
+ * Remaining
1099
+ * @description the entries' `remaining`, summed
1100
+ */
1101
+ remaining: number;
1102
+ /**
1103
+ * Wall S
1104
+ * @description the entries' `wall_s`, summed
1105
+ */
1106
+ wall_s: number;
1107
+ /**
1108
+ * Cost Usd
1109
+ * @description the entries' `cost_usd`, summed; null when none has one
1110
+ */
1111
+ cost_usd: number | null;
1112
+ };
1113
+ /**
1114
+ * ForecastEntry
1115
+ * @description The tasks of one tail key in the earlier run the forecast reads, and how many of them
1116
+ * this run has created. A tail key is the flow path's function names, the kind, and the
1117
+ * passes of the loops around it, each capped at 3.
1118
+ */
1119
+ ForecastEntry: {
1120
+ /**
1121
+ * Kind
1122
+ * @description the kind of the earlier run's first task of it
1123
+ */
1124
+ kind: string;
1125
+ /**
1126
+ * Group
1127
+ * @description the group its kind is drawn in (`PlanGroup.id`)
1128
+ */
1129
+ group: string;
1130
+ /**
1131
+ * Flow
1132
+ * @description the function names of its flow path, outermost first
1133
+ */
1134
+ flow: string[];
1135
+ /**
1136
+ * Passes
1137
+ * @description the passes of the loops around it, outermost first, each capped at 3 (3: the third pass and later); null for a loop whose pass was not recorded
1138
+ */
1139
+ passes: (number | null)[];
1140
+ /**
1141
+ * Expected
1142
+ * @description the tasks of it the earlier run created
1143
+ */
1144
+ expected: number;
1145
+ /**
1146
+ * Created
1147
+ * @description the tasks of it this run has created
1148
+ */
1149
+ created: number;
1150
+ /**
1151
+ * Remaining
1152
+ * @description `expected` less `created`, never below 0
1153
+ */
1154
+ remaining: number;
1155
+ /**
1156
+ * Wall S
1157
+ * @description the wall time of the `remaining` tasks, at the earlier run's mean per task (every attempt counted)
1158
+ */
1159
+ wall_s: number;
1160
+ /**
1161
+ * Cost Usd
1162
+ * @description the cost of the `remaining` tasks in USD, at the earlier run's mean per task; null when the earlier run reported none
1163
+ */
1164
+ cost_usd: number | null;
1165
+ };
1166
+ /**
1167
+ * ForecastMessage
1168
+ * @description The forecast, sent when it changed: a task the run creates takes one off it.
1169
+ */
1170
+ ForecastMessage: {
1171
+ /**
1172
+ * Event
1173
+ * @constant
1174
+ */
1175
+ event: "forecast";
1176
+ data: components["schemas"]["Forecast"];
1025
1177
  };
1026
1178
  /**
1027
1179
  * Frame
@@ -1372,7 +1524,7 @@ export type components = {
1372
1524
  * Stop
1373
1525
  * @enum {string}
1374
1526
  */
1375
- stop: "completed" | "timeout" | "max_turns" | "budget" | "context_budget" | "stalled" | "auth_failed" | "api_error" | "rate_limited" | "refused" | "aborted" | "denied" | "error" | "no_output" | "launch_failed" | "invalid_output" | "invalid_input" | "credential_mismatch" | "skipped" | "partial";
1527
+ stop: "completed" | "timeout" | "max_turns" | "budget" | "context_budget" | "stalled" | "auth_failed" | "api_error" | "rate_limited" | "refused" | "aborted" | "denied" | "error" | "no_output" | "launch_failed" | "invalid_output" | "invalid_input" | "credential_mismatch" | "skipped" | "partial" | "cancelled";
1376
1528
  /** Ok */
1377
1529
  ok: boolean;
1378
1530
  /**
@@ -1410,6 +1562,12 @@ export type components = {
1410
1562
  unread_events?: {
1411
1563
  [key: string]: number;
1412
1564
  };
1565
+ /**
1566
+ * Usage Unknown
1567
+ * @default
1568
+ * @enum {string}
1569
+ */
1570
+ usage_unknown?: "" | "calls" | "tokens";
1413
1571
  changes?: components["schemas"]["Changes"] | null;
1414
1572
  /** Context Budget */
1415
1573
  context_budget?: number | null;
@@ -1423,6 +1581,10 @@ export type components = {
1423
1581
  * @default
1424
1582
  */
1425
1583
  fingerprint?: string;
1584
+ /** Fingerprint Parts */
1585
+ fingerprint_parts?: {
1586
+ [key: string]: string;
1587
+ };
1426
1588
  /**
1427
1589
  * Outside
1428
1590
  * @default
@@ -1433,6 +1595,11 @@ export type components = {
1433
1595
  * @default
1434
1596
  */
1435
1597
  rerun?: string;
1598
+ /**
1599
+ * Output Of After
1600
+ * @default
1601
+ */
1602
+ output_of_after?: string;
1436
1603
  /** Flow Call */
1437
1604
  flow_call?: string | null;
1438
1605
  /**
@@ -1897,6 +2064,11 @@ export type components = {
1897
2064
  skipped: number;
1898
2065
  /** Blocked */
1899
2066
  blocked: number;
2067
+ /**
2068
+ * Cancelled
2069
+ * @default 0
2070
+ */
2071
+ cancelled?: number;
1900
2072
  };
1901
2073
  /** PlanMessage */
1902
2074
  PlanMessage: {
@@ -1947,7 +2119,7 @@ export type components = {
1947
2119
  priority?: number;
1948
2120
  /**
1949
2121
  * Credential
1950
- * @description the credential its task call names (`credential=`), which every route of its kind ran it as; empty when it names none, or a run-wide override outranks it
2122
+ * @description the credential its call options name (`.options(credential=)`), which every route of its kind ran it as; empty when it names none, or a run-wide override outranks it
1951
2123
  * @default
1952
2124
  */
1953
2125
  credential?: string;
@@ -1964,7 +2136,7 @@ export type components = {
1964
2136
  flow?: components["schemas"]["Frame"][];
1965
2137
  /**
1966
2138
  * Created From
1967
- * @description keys whose results its flow call had received when it created it
2139
+ * @description keys of the results that reached its flow call between that flow call's previous resume and the one in which it created the task
1968
2140
  */
1969
2141
  created_from?: string[];
1970
2142
  /**
@@ -1972,6 +2144,18 @@ export type components = {
1972
2144
  * @description the id of the flow call that created it; null for a task with no origin
1973
2145
  */
1974
2146
  flow_call?: string | null;
2147
+ /**
2148
+ * Given From
2149
+ * @description keys of the tasks whose outputs it was given in its params: an output, or one item of an output that is a list, whose JSON is a value of its params; shown only, never part of its fingerprint
2150
+ */
2151
+ given_from?: string[];
2152
+ /**
2153
+ * Input Files
2154
+ * @description the input files among its params, as its task call hashed them: `param` (its place in the params, `notes/0`), `path` and `sha256`; absent when it has none
2155
+ */
2156
+ input_files?: {
2157
+ [key: string]: string;
2158
+ }[];
1975
2159
  /**
1976
2160
  * Base Kind
1977
2161
  * @description an implementation kind's base kind (`agent_task(implementations=)`), its group unless `groups` lists it; else empty
@@ -1982,7 +2166,7 @@ export type components = {
1982
2166
  * State
1983
2167
  * @enum {string}
1984
2168
  */
1985
- state: "pending" | "running" | "done" | "partial" | "failed" | "skipped" | "blocked";
2169
+ state: "pending" | "running" | "done" | "partial" | "failed" | "skipped" | "blocked" | "cancelled";
1986
2170
  /**
1987
2171
  * Level
1988
2172
  * @description depth in the dependency graph, 0 for a task that waits for nothing
@@ -2259,7 +2443,7 @@ export type components = {
2259
2443
  * RunEvent
2260
2444
  * @description One message of /events?run=
2261
2445
  */
2262
- RunEvent: components["schemas"]["JournalMessage"] | components["schemas"]["ProcsMessage"] | components["schemas"]["PlanMessage"] | components["schemas"]["OutputsMessage"] | components["schemas"]["CursorMessage"] | components["schemas"]["PanelMessage"] | components["schemas"]["ReadyMessage"];
2446
+ RunEvent: components["schemas"]["JournalMessage"] | components["schemas"]["ProcsMessage"] | components["schemas"]["PlanMessage"] | components["schemas"]["OutputsMessage"] | components["schemas"]["ForecastMessage"] | components["schemas"]["CursorMessage"] | components["schemas"]["PanelMessage"] | components["schemas"]["ReadyMessage"];
2263
2447
  /**
2264
2448
  * RunSummary
2265
2449
  * @description One run directory, as the run picker lists it.
@@ -2690,7 +2874,8 @@ export type components = {
2690
2874
  * @description A run's tasks (not attempts) by how they ended. `not_started`: refused for
2691
2875
  * an input, or waiting behind a task that failed; `running`: running now (in a
2692
2876
  * live run); `waiting`: queued in a live run; `not_run`: deferred, or queued in a
2693
- * run that is no longer live (it will not run).
2877
+ * run that is no longer live (it will not run); `cancelled`: cancelled once no flow
2878
+ * call waited for it (called with `.options(cancellable=True)`).
2694
2879
  */
2695
2880
  TaskCounts: {
2696
2881
  /** Total */
@@ -2721,6 +2906,11 @@ export type components = {
2721
2906
  not_run?: number;
2722
2907
  /** Skipped */
2723
2908
  skipped: number;
2909
+ /**
2910
+ * Cancelled
2911
+ * @default 0
2912
+ */
2913
+ cancelled?: number;
2724
2914
  };
2725
2915
  /**
2726
2916
  * TaskDefinition
@@ -2860,8 +3050,16 @@ export type components = {
2860
3050
  params: {
2861
3051
  [key: string]: unknown;
2862
3052
  };
2863
- /** Inputs */
3053
+ /**
3054
+ * Inputs
3055
+ * @description its input contracts (`ContractRecord.inputs`)
3056
+ */
2864
3057
  inputs: components["schemas"]["ContractSpec"][];
3058
+ /**
3059
+ * Input Files
3060
+ * @description the input files among its params
3061
+ */
3062
+ input_files?: components["schemas"]["TaskInputFile"][];
2865
3063
  /** Outputs */
2866
3064
  outputs: components["schemas"]["ContractSpec"][];
2867
3065
  /**
@@ -2874,6 +3072,42 @@ export type components = {
2874
3072
  /** Downstream */
2875
3073
  downstream: components["schemas"]["DownstreamTask"][];
2876
3074
  };
3075
+ /**
3076
+ * TaskInputFile
3077
+ * @description An input file among the task's params (`plan.jsonl` `input_files`): its place in the
3078
+ * params, its path and the SHA-256 of its content taken at the task call, the task whose
3079
+ * output file it is, and its check as the task was about to start.
3080
+ */
3081
+ TaskInputFile: {
3082
+ /**
3083
+ * Param
3084
+ * @description its place in the params: the param's name, then a list's index or a field's name (`notes/0`)
3085
+ */
3086
+ param: string;
3087
+ /**
3088
+ * Path
3089
+ * @description as the params hold it: relative to the run's working directory, or absolute for an output file outside it
3090
+ */
3091
+ path: string;
3092
+ /** Sha256 */
3093
+ sha256: string;
3094
+ /**
3095
+ * Writer
3096
+ * @description the key of the task it was given from whose output file it is; null for another file
3097
+ */
3098
+ writer?: string | null;
3099
+ /**
3100
+ * Check
3101
+ * @enum {string}
3102
+ */
3103
+ check: "passed" | "refused" | "not_checked";
3104
+ /**
3105
+ * Reason
3106
+ * @description for one `refused`: why, as the refusal names it; else empty
3107
+ * @default
3108
+ */
3109
+ reason?: string;
3110
+ };
2877
3111
  /**
2878
3112
  * TaskLaunch
2879
3113
  * @description A live launch of the task (a child process, or an in-process marker with empty plugin/model/role/cmd).
@@ -3606,7 +3840,10 @@ export type components = {
3606
3840
  /** Inflight */
3607
3841
  inflight: string[];
3608
3842
  };
3609
- /** UpstreamTask */
3843
+ /**
3844
+ * UpstreamTask
3845
+ * @description An earlier task: one this task was given from, waits for, or was created from.
3846
+ */
3610
3847
  UpstreamTask: {
3611
3848
  /** Key */
3612
3849
  key: string;
@@ -3621,6 +3858,11 @@ export type components = {
3621
3858
  executor: "agent" | "python";
3622
3859
  /** Outputs */
3623
3860
  outputs: components["schemas"]["ContractSpec"][];
3861
+ /**
3862
+ * Lineage
3863
+ * @description how this task is joined to it, in the order `given_from`, `after`, `created_from`
3864
+ */
3865
+ lineage?: ("given_from" | "after" | "created_from")[];
3624
3866
  };
3625
3867
  /** ValidationError */
3626
3868
  ValidationError: {
@@ -3898,6 +4140,37 @@ export interface operations {
3898
4140
  };
3899
4141
  };
3900
4142
  };
4143
+ api_forecast_api_runs__run__forecast_get: {
4144
+ parameters: {
4145
+ query?: never;
4146
+ header?: never;
4147
+ path: {
4148
+ run: string;
4149
+ };
4150
+ cookie?: never;
4151
+ };
4152
+ requestBody?: never;
4153
+ responses: {
4154
+ /** @description Successful Response */
4155
+ 200: {
4156
+ headers: {
4157
+ [name: string]: unknown;
4158
+ };
4159
+ content: {
4160
+ "application/json": components["schemas"]["Forecast"];
4161
+ };
4162
+ };
4163
+ /** @description Validation Error */
4164
+ 422: {
4165
+ headers: {
4166
+ [name: string]: unknown;
4167
+ };
4168
+ content: {
4169
+ "application/json": components["schemas"]["HTTPValidationError"];
4170
+ };
4171
+ };
4172
+ };
4173
+ };
3901
4174
  api_definitions_api_runs__run__definitions_get: {
3902
4175
  parameters: {
3903
4176
  query?: never;
package/src/types.ts CHANGED
@@ -62,6 +62,9 @@ export type Loop = S['Loop'];
62
62
  export type FlowCallNode = S['FlowCallNode'];
63
63
  export type FlowState = FlowCallNode['state'];
64
64
  export type TimeBoxRecord = S['TimeBoxRecord'];
65
+ /** The tasks a run is expected to create and has not yet, from an earlier run of its flow; a display only. */
66
+ export type Forecast = S['Forecast'];
67
+ export type ForecastEntry = S['ForecastEntry'];
65
68
 
66
69
  export type Outputs = S['Outputs'];
67
70
  export type OutputTally = S['OutputTally'];
@@ -87,6 +90,11 @@ export type TaskLaunch = S['TaskLaunch'];
87
90
  export type TaskIO = S['TaskIO'];
88
91
  export type UpstreamTask = S['UpstreamTask'];
89
92
  export type DownstreamTask = S['DownstreamTask'];
93
+ /** How a task is joined to an earlier one: given its output (`given_from`), waiting for it only (`after`), created after its result (`created_from`). */
94
+ export type Lineage = NonNullable<UpstreamTask['lineage']>[number];
95
+ /** An input file among a task's params, with the task whose output it is and its check at the start. */
96
+ export type TaskInputFile = S['TaskInputFile'];
97
+ export type InputFileCheck = TaskInputFile['check'];
90
98
 
91
99
  // --- transcripts -----------------------------------------------------------
92
100