@hasura/promptql 2.0.0-alpha.16 → 2.0.0-alpha.18
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.d.mts +125 -5
- package/dist/index.d.ts +125 -5
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -3901,6 +3901,10 @@ type Project_Configuration_Bool_Exp = {
|
|
|
3901
3901
|
_not?: InputMaybe<Project_Configuration_Bool_Exp>;
|
|
3902
3902
|
_or?: InputMaybe<Array<Project_Configuration_Bool_Exp>>;
|
|
3903
3903
|
created_at?: InputMaybe<Timestamptz_Comparison_Exp>;
|
|
3904
|
+
data_studio?: InputMaybe<Boolean_Comparison_Exp>;
|
|
3905
|
+
default_onboarding_modal_visibility?: InputMaybe<Boolean_Comparison_Exp>;
|
|
3906
|
+
default_room?: InputMaybe<Uuid_Comparison_Exp>;
|
|
3907
|
+
default_room_info?: InputMaybe<Rooms_Bool_Exp>;
|
|
3904
3908
|
default_thread_visibility?: InputMaybe<Thread_Visibility_Enum_Enum_Comparison_Exp>;
|
|
3905
3909
|
enable_social_feed?: InputMaybe<Boolean_Comparison_Exp>;
|
|
3906
3910
|
project_id?: InputMaybe<Uuid_Comparison_Exp>;
|
|
@@ -3909,6 +3913,10 @@ type Project_Configuration_Bool_Exp = {
|
|
|
3909
3913
|
/** Ordering options when selecting data from "project_configuration". */
|
|
3910
3914
|
type Project_Configuration_Order_By = {
|
|
3911
3915
|
created_at?: InputMaybe<Order_By>;
|
|
3916
|
+
data_studio?: InputMaybe<Order_By>;
|
|
3917
|
+
default_onboarding_modal_visibility?: InputMaybe<Order_By>;
|
|
3918
|
+
default_room?: InputMaybe<Order_By>;
|
|
3919
|
+
default_room_info?: InputMaybe<Rooms_Order_By>;
|
|
3912
3920
|
default_thread_visibility?: InputMaybe<Order_By>;
|
|
3913
3921
|
enable_social_feed?: InputMaybe<Order_By>;
|
|
3914
3922
|
project_id?: InputMaybe<Order_By>;
|
|
@@ -3925,6 +3933,7 @@ type Promptql_Users_Bool_Exp = {
|
|
|
3925
3933
|
display_name?: InputMaybe<String_Comparison_Exp>;
|
|
3926
3934
|
email?: InputMaybe<Citext_Comparison_Exp>;
|
|
3927
3935
|
is_active?: InputMaybe<Boolean_Comparison_Exp>;
|
|
3936
|
+
is_app_admin?: InputMaybe<Boolean_Comparison_Exp>;
|
|
3928
3937
|
project_id?: InputMaybe<Uuid_Comparison_Exp>;
|
|
3929
3938
|
promptql_user_id?: InputMaybe<Uuid_Comparison_Exp>;
|
|
3930
3939
|
slack_info?: InputMaybe<Slack_Info_Bool_Exp>;
|
|
@@ -3942,6 +3951,7 @@ type Promptql_Users_Order_By = {
|
|
|
3942
3951
|
display_name?: InputMaybe<Order_By>;
|
|
3943
3952
|
email?: InputMaybe<Order_By>;
|
|
3944
3953
|
is_active?: InputMaybe<Order_By>;
|
|
3954
|
+
is_app_admin?: InputMaybe<Order_By>;
|
|
3945
3955
|
project_id?: InputMaybe<Order_By>;
|
|
3946
3956
|
promptql_user_id?: InputMaybe<Order_By>;
|
|
3947
3957
|
slack_info?: InputMaybe<Slack_Info_Order_By>;
|
|
@@ -4176,6 +4186,98 @@ type Slack_Integration_Min_Order_By = {
|
|
|
4176
4186
|
slack_app_name?: InputMaybe<Order_By>;
|
|
4177
4187
|
slack_workspace_id?: InputMaybe<Order_By>;
|
|
4178
4188
|
};
|
|
4189
|
+
/** order by aggregate values of table "social_feed_candidates" */
|
|
4190
|
+
type Social_Feed_Candidates_Aggregate_Order_By = {
|
|
4191
|
+
avg?: InputMaybe<Social_Feed_Candidates_Avg_Order_By>;
|
|
4192
|
+
count?: InputMaybe<Order_By>;
|
|
4193
|
+
max?: InputMaybe<Social_Feed_Candidates_Max_Order_By>;
|
|
4194
|
+
min?: InputMaybe<Social_Feed_Candidates_Min_Order_By>;
|
|
4195
|
+
stddev?: InputMaybe<Social_Feed_Candidates_Stddev_Order_By>;
|
|
4196
|
+
stddev_pop?: InputMaybe<Social_Feed_Candidates_Stddev_Pop_Order_By>;
|
|
4197
|
+
stddev_samp?: InputMaybe<Social_Feed_Candidates_Stddev_Samp_Order_By>;
|
|
4198
|
+
sum?: InputMaybe<Social_Feed_Candidates_Sum_Order_By>;
|
|
4199
|
+
var_pop?: InputMaybe<Social_Feed_Candidates_Var_Pop_Order_By>;
|
|
4200
|
+
var_samp?: InputMaybe<Social_Feed_Candidates_Var_Samp_Order_By>;
|
|
4201
|
+
variance?: InputMaybe<Social_Feed_Candidates_Variance_Order_By>;
|
|
4202
|
+
};
|
|
4203
|
+
/** order by avg() on columns of table "social_feed_candidates" */
|
|
4204
|
+
type Social_Feed_Candidates_Avg_Order_By = {
|
|
4205
|
+
thread_event_id?: InputMaybe<Order_By>;
|
|
4206
|
+
version?: InputMaybe<Order_By>;
|
|
4207
|
+
};
|
|
4208
|
+
/** Boolean expression to filter rows from the table "social_feed_candidates". All fields are combined with a logical 'AND'. */
|
|
4209
|
+
type Social_Feed_Candidates_Bool_Exp = {
|
|
4210
|
+
_and?: InputMaybe<Array<Social_Feed_Candidates_Bool_Exp>>;
|
|
4211
|
+
_not?: InputMaybe<Social_Feed_Candidates_Bool_Exp>;
|
|
4212
|
+
_or?: InputMaybe<Array<Social_Feed_Candidates_Bool_Exp>>;
|
|
4213
|
+
created_at?: InputMaybe<Timestamptz_Comparison_Exp>;
|
|
4214
|
+
id?: InputMaybe<Uuid_Comparison_Exp>;
|
|
4215
|
+
llm_output?: InputMaybe<Jsonb_Comparison_Exp>;
|
|
4216
|
+
summary?: InputMaybe<String_Comparison_Exp>;
|
|
4217
|
+
thread?: InputMaybe<Threads_V2_Bool_Exp>;
|
|
4218
|
+
thread_event_id?: InputMaybe<Bigint_Comparison_Exp>;
|
|
4219
|
+
thread_id?: InputMaybe<Uuid_Comparison_Exp>;
|
|
4220
|
+
title?: InputMaybe<String_Comparison_Exp>;
|
|
4221
|
+
updated_at?: InputMaybe<Timestamptz_Comparison_Exp>;
|
|
4222
|
+
version?: InputMaybe<Int_Comparison_Exp>;
|
|
4223
|
+
};
|
|
4224
|
+
/** order by max() on columns of table "social_feed_candidates" */
|
|
4225
|
+
type Social_Feed_Candidates_Max_Order_By = {
|
|
4226
|
+
created_at?: InputMaybe<Order_By>;
|
|
4227
|
+
id?: InputMaybe<Order_By>;
|
|
4228
|
+
summary?: InputMaybe<Order_By>;
|
|
4229
|
+
thread_event_id?: InputMaybe<Order_By>;
|
|
4230
|
+
thread_id?: InputMaybe<Order_By>;
|
|
4231
|
+
title?: InputMaybe<Order_By>;
|
|
4232
|
+
updated_at?: InputMaybe<Order_By>;
|
|
4233
|
+
version?: InputMaybe<Order_By>;
|
|
4234
|
+
};
|
|
4235
|
+
/** order by min() on columns of table "social_feed_candidates" */
|
|
4236
|
+
type Social_Feed_Candidates_Min_Order_By = {
|
|
4237
|
+
created_at?: InputMaybe<Order_By>;
|
|
4238
|
+
id?: InputMaybe<Order_By>;
|
|
4239
|
+
summary?: InputMaybe<Order_By>;
|
|
4240
|
+
thread_event_id?: InputMaybe<Order_By>;
|
|
4241
|
+
thread_id?: InputMaybe<Order_By>;
|
|
4242
|
+
title?: InputMaybe<Order_By>;
|
|
4243
|
+
updated_at?: InputMaybe<Order_By>;
|
|
4244
|
+
version?: InputMaybe<Order_By>;
|
|
4245
|
+
};
|
|
4246
|
+
/** order by stddev() on columns of table "social_feed_candidates" */
|
|
4247
|
+
type Social_Feed_Candidates_Stddev_Order_By = {
|
|
4248
|
+
thread_event_id?: InputMaybe<Order_By>;
|
|
4249
|
+
version?: InputMaybe<Order_By>;
|
|
4250
|
+
};
|
|
4251
|
+
/** order by stddev_pop() on columns of table "social_feed_candidates" */
|
|
4252
|
+
type Social_Feed_Candidates_Stddev_Pop_Order_By = {
|
|
4253
|
+
thread_event_id?: InputMaybe<Order_By>;
|
|
4254
|
+
version?: InputMaybe<Order_By>;
|
|
4255
|
+
};
|
|
4256
|
+
/** order by stddev_samp() on columns of table "social_feed_candidates" */
|
|
4257
|
+
type Social_Feed_Candidates_Stddev_Samp_Order_By = {
|
|
4258
|
+
thread_event_id?: InputMaybe<Order_By>;
|
|
4259
|
+
version?: InputMaybe<Order_By>;
|
|
4260
|
+
};
|
|
4261
|
+
/** order by sum() on columns of table "social_feed_candidates" */
|
|
4262
|
+
type Social_Feed_Candidates_Sum_Order_By = {
|
|
4263
|
+
thread_event_id?: InputMaybe<Order_By>;
|
|
4264
|
+
version?: InputMaybe<Order_By>;
|
|
4265
|
+
};
|
|
4266
|
+
/** order by var_pop() on columns of table "social_feed_candidates" */
|
|
4267
|
+
type Social_Feed_Candidates_Var_Pop_Order_By = {
|
|
4268
|
+
thread_event_id?: InputMaybe<Order_By>;
|
|
4269
|
+
version?: InputMaybe<Order_By>;
|
|
4270
|
+
};
|
|
4271
|
+
/** order by var_samp() on columns of table "social_feed_candidates" */
|
|
4272
|
+
type Social_Feed_Candidates_Var_Samp_Order_By = {
|
|
4273
|
+
thread_event_id?: InputMaybe<Order_By>;
|
|
4274
|
+
version?: InputMaybe<Order_By>;
|
|
4275
|
+
};
|
|
4276
|
+
/** order by variance() on columns of table "social_feed_candidates" */
|
|
4277
|
+
type Social_Feed_Candidates_Variance_Order_By = {
|
|
4278
|
+
thread_event_id?: InputMaybe<Order_By>;
|
|
4279
|
+
version?: InputMaybe<Order_By>;
|
|
4280
|
+
};
|
|
4179
4281
|
/** order by aggregate values of table "thread_artifacts" */
|
|
4180
4282
|
type Thread_Artifacts_Aggregate_Order_By = {
|
|
4181
4283
|
count?: InputMaybe<Order_By>;
|
|
@@ -4644,6 +4746,7 @@ type Threads_V2_Bool_Exp = {
|
|
|
4644
4746
|
created_at?: InputMaybe<Timestamptz_Comparison_Exp>;
|
|
4645
4747
|
custom_title?: InputMaybe<String_Comparison_Exp>;
|
|
4646
4748
|
deleted_at?: InputMaybe<Timestamptz_Comparison_Exp>;
|
|
4749
|
+
forked_from?: InputMaybe<Uuid_Comparison_Exp>;
|
|
4647
4750
|
learning_suggestion?: InputMaybe<String_Comparison_Exp>;
|
|
4648
4751
|
pinned_threads_v2s?: InputMaybe<Pinned_Threads_V2_Bool_Exp>;
|
|
4649
4752
|
project_config?: InputMaybe<Project_Configuration_Bool_Exp>;
|
|
@@ -4654,6 +4757,7 @@ type Threads_V2_Bool_Exp = {
|
|
|
4654
4757
|
room?: InputMaybe<Rooms_Bool_Exp>;
|
|
4655
4758
|
room_id?: InputMaybe<Uuid_Comparison_Exp>;
|
|
4656
4759
|
shared_threads?: InputMaybe<Shared_Threads_Bool_Exp>;
|
|
4760
|
+
social_feed_candidates?: InputMaybe<Social_Feed_Candidates_Bool_Exp>;
|
|
4657
4761
|
taught_by?: InputMaybe<Thread_Taught_By_Result_Bool_Exp>;
|
|
4658
4762
|
thread_artifacts?: InputMaybe<Thread_Artifacts_Bool_Exp>;
|
|
4659
4763
|
thread_events?: InputMaybe<Thread_Events_Bool_Exp>;
|
|
@@ -4674,6 +4778,7 @@ type Threads_V2_Max_Order_By = {
|
|
|
4674
4778
|
created_at?: InputMaybe<Order_By>;
|
|
4675
4779
|
custom_title?: InputMaybe<Order_By>;
|
|
4676
4780
|
deleted_at?: InputMaybe<Order_By>;
|
|
4781
|
+
forked_from?: InputMaybe<Order_By>;
|
|
4677
4782
|
project_id?: InputMaybe<Order_By>;
|
|
4678
4783
|
/** The room this thread belongs to. Every thread must belong to exactly one room. */
|
|
4679
4784
|
room_id?: InputMaybe<Order_By>;
|
|
@@ -4690,6 +4795,7 @@ type Threads_V2_Min_Order_By = {
|
|
|
4690
4795
|
created_at?: InputMaybe<Order_By>;
|
|
4691
4796
|
custom_title?: InputMaybe<Order_By>;
|
|
4692
4797
|
deleted_at?: InputMaybe<Order_By>;
|
|
4798
|
+
forked_from?: InputMaybe<Order_By>;
|
|
4693
4799
|
project_id?: InputMaybe<Order_By>;
|
|
4694
4800
|
/** The room this thread belongs to. Every thread must belong to exactly one room. */
|
|
4695
4801
|
room_id?: InputMaybe<Order_By>;
|
|
@@ -4706,6 +4812,7 @@ type Threads_V2_Order_By = {
|
|
|
4706
4812
|
created_at?: InputMaybe<Order_By>;
|
|
4707
4813
|
custom_title?: InputMaybe<Order_By>;
|
|
4708
4814
|
deleted_at?: InputMaybe<Order_By>;
|
|
4815
|
+
forked_from?: InputMaybe<Order_By>;
|
|
4709
4816
|
learning_suggestion?: InputMaybe<Order_By>;
|
|
4710
4817
|
pinned_threads_v2s_aggregate?: InputMaybe<Pinned_Threads_V2_Aggregate_Order_By>;
|
|
4711
4818
|
project_config?: InputMaybe<Project_Configuration_Order_By>;
|
|
@@ -4716,6 +4823,7 @@ type Threads_V2_Order_By = {
|
|
|
4716
4823
|
room?: InputMaybe<Rooms_Order_By>;
|
|
4717
4824
|
room_id?: InputMaybe<Order_By>;
|
|
4718
4825
|
shared_threads_aggregate?: InputMaybe<Shared_Threads_Aggregate_Order_By>;
|
|
4826
|
+
social_feed_candidates_aggregate?: InputMaybe<Social_Feed_Candidates_Aggregate_Order_By>;
|
|
4719
4827
|
taught_by_aggregate?: InputMaybe<Thread_Taught_By_Result_Aggregate_Order_By>;
|
|
4720
4828
|
thread_artifacts_aggregate?: InputMaybe<Thread_Artifacts_Aggregate_Order_By>;
|
|
4721
4829
|
thread_events_aggregate?: InputMaybe<Thread_Events_Aggregate_Order_By>;
|
|
@@ -4738,6 +4846,8 @@ type Threads_V2_Select_Column =
|
|
|
4738
4846
|
| 'custom_title'
|
|
4739
4847
|
/** column name */
|
|
4740
4848
|
| 'deleted_at'
|
|
4849
|
+
/** column name */
|
|
4850
|
+
| 'forked_from'
|
|
4741
4851
|
/** column name */
|
|
4742
4852
|
| 'project_id'
|
|
4743
4853
|
/** column name */
|
|
@@ -4832,6 +4942,7 @@ type User_Preferences_Bool_Exp = {
|
|
|
4832
4942
|
created_at?: InputMaybe<Timestamptz_Comparison_Exp>;
|
|
4833
4943
|
custom_instructions?: InputMaybe<String_Comparison_Exp>;
|
|
4834
4944
|
feature_flags?: InputMaybe<Jsonb_Comparison_Exp>;
|
|
4945
|
+
onboarding_popup_shown?: InputMaybe<Boolean_Comparison_Exp>;
|
|
4835
4946
|
promptql_user?: InputMaybe<Promptql_Users_Bool_Exp>;
|
|
4836
4947
|
promptql_user_id?: InputMaybe<Uuid_Comparison_Exp>;
|
|
4837
4948
|
updated_at?: InputMaybe<Timestamptz_Comparison_Exp>;
|
|
@@ -4841,6 +4952,7 @@ type User_Preferences_Order_By = {
|
|
|
4841
4952
|
created_at?: InputMaybe<Order_By>;
|
|
4842
4953
|
custom_instructions?: InputMaybe<Order_By>;
|
|
4843
4954
|
feature_flags?: InputMaybe<Order_By>;
|
|
4955
|
+
onboarding_popup_shown?: InputMaybe<Order_By>;
|
|
4844
4956
|
promptql_user?: InputMaybe<Promptql_Users_Order_By>;
|
|
4845
4957
|
promptql_user_id?: InputMaybe<Order_By>;
|
|
4846
4958
|
updated_at?: InputMaybe<Order_By>;
|
|
@@ -5123,11 +5235,7 @@ type GetThreadEventOptions = {
|
|
|
5123
5235
|
/**
|
|
5124
5236
|
* Filter events from this event ID.
|
|
5125
5237
|
*/
|
|
5126
|
-
|
|
5127
|
-
/**
|
|
5128
|
-
* Filter events to this event ID.
|
|
5129
|
-
*/
|
|
5130
|
-
toEventId?: string | null;
|
|
5238
|
+
eventId?: Bigint_Comparison_Exp;
|
|
5131
5239
|
/**
|
|
5132
5240
|
* Filter events by message ID.
|
|
5133
5241
|
*/
|
|
@@ -5136,6 +5244,10 @@ type GetThreadEventOptions = {
|
|
|
5136
5244
|
* Limit number of events
|
|
5137
5245
|
*/
|
|
5138
5246
|
limit?: number | null;
|
|
5247
|
+
/**
|
|
5248
|
+
* Limit number of events
|
|
5249
|
+
*/
|
|
5250
|
+
ordering?: Order_By | null;
|
|
5139
5251
|
};
|
|
5140
5252
|
/**
|
|
5141
5253
|
* Optional options for streaming thread events.
|
|
@@ -5153,6 +5265,14 @@ type StreamThreadEventOptions = {
|
|
|
5153
5265
|
* Stop right after the agent responds and skip post analysis events.
|
|
5154
5266
|
*/
|
|
5155
5267
|
skipAnalysis?: boolean;
|
|
5268
|
+
/**
|
|
5269
|
+
* Polling interval in seconds. Default is 5 seconds.
|
|
5270
|
+
*/
|
|
5271
|
+
pollingInterval?: number;
|
|
5272
|
+
/**
|
|
5273
|
+
* Maximum timeout in seconds.
|
|
5274
|
+
*/
|
|
5275
|
+
timeout?: number;
|
|
5156
5276
|
};
|
|
5157
5277
|
|
|
5158
5278
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -3901,6 +3901,10 @@ type Project_Configuration_Bool_Exp = {
|
|
|
3901
3901
|
_not?: InputMaybe<Project_Configuration_Bool_Exp>;
|
|
3902
3902
|
_or?: InputMaybe<Array<Project_Configuration_Bool_Exp>>;
|
|
3903
3903
|
created_at?: InputMaybe<Timestamptz_Comparison_Exp>;
|
|
3904
|
+
data_studio?: InputMaybe<Boolean_Comparison_Exp>;
|
|
3905
|
+
default_onboarding_modal_visibility?: InputMaybe<Boolean_Comparison_Exp>;
|
|
3906
|
+
default_room?: InputMaybe<Uuid_Comparison_Exp>;
|
|
3907
|
+
default_room_info?: InputMaybe<Rooms_Bool_Exp>;
|
|
3904
3908
|
default_thread_visibility?: InputMaybe<Thread_Visibility_Enum_Enum_Comparison_Exp>;
|
|
3905
3909
|
enable_social_feed?: InputMaybe<Boolean_Comparison_Exp>;
|
|
3906
3910
|
project_id?: InputMaybe<Uuid_Comparison_Exp>;
|
|
@@ -3909,6 +3913,10 @@ type Project_Configuration_Bool_Exp = {
|
|
|
3909
3913
|
/** Ordering options when selecting data from "project_configuration". */
|
|
3910
3914
|
type Project_Configuration_Order_By = {
|
|
3911
3915
|
created_at?: InputMaybe<Order_By>;
|
|
3916
|
+
data_studio?: InputMaybe<Order_By>;
|
|
3917
|
+
default_onboarding_modal_visibility?: InputMaybe<Order_By>;
|
|
3918
|
+
default_room?: InputMaybe<Order_By>;
|
|
3919
|
+
default_room_info?: InputMaybe<Rooms_Order_By>;
|
|
3912
3920
|
default_thread_visibility?: InputMaybe<Order_By>;
|
|
3913
3921
|
enable_social_feed?: InputMaybe<Order_By>;
|
|
3914
3922
|
project_id?: InputMaybe<Order_By>;
|
|
@@ -3925,6 +3933,7 @@ type Promptql_Users_Bool_Exp = {
|
|
|
3925
3933
|
display_name?: InputMaybe<String_Comparison_Exp>;
|
|
3926
3934
|
email?: InputMaybe<Citext_Comparison_Exp>;
|
|
3927
3935
|
is_active?: InputMaybe<Boolean_Comparison_Exp>;
|
|
3936
|
+
is_app_admin?: InputMaybe<Boolean_Comparison_Exp>;
|
|
3928
3937
|
project_id?: InputMaybe<Uuid_Comparison_Exp>;
|
|
3929
3938
|
promptql_user_id?: InputMaybe<Uuid_Comparison_Exp>;
|
|
3930
3939
|
slack_info?: InputMaybe<Slack_Info_Bool_Exp>;
|
|
@@ -3942,6 +3951,7 @@ type Promptql_Users_Order_By = {
|
|
|
3942
3951
|
display_name?: InputMaybe<Order_By>;
|
|
3943
3952
|
email?: InputMaybe<Order_By>;
|
|
3944
3953
|
is_active?: InputMaybe<Order_By>;
|
|
3954
|
+
is_app_admin?: InputMaybe<Order_By>;
|
|
3945
3955
|
project_id?: InputMaybe<Order_By>;
|
|
3946
3956
|
promptql_user_id?: InputMaybe<Order_By>;
|
|
3947
3957
|
slack_info?: InputMaybe<Slack_Info_Order_By>;
|
|
@@ -4176,6 +4186,98 @@ type Slack_Integration_Min_Order_By = {
|
|
|
4176
4186
|
slack_app_name?: InputMaybe<Order_By>;
|
|
4177
4187
|
slack_workspace_id?: InputMaybe<Order_By>;
|
|
4178
4188
|
};
|
|
4189
|
+
/** order by aggregate values of table "social_feed_candidates" */
|
|
4190
|
+
type Social_Feed_Candidates_Aggregate_Order_By = {
|
|
4191
|
+
avg?: InputMaybe<Social_Feed_Candidates_Avg_Order_By>;
|
|
4192
|
+
count?: InputMaybe<Order_By>;
|
|
4193
|
+
max?: InputMaybe<Social_Feed_Candidates_Max_Order_By>;
|
|
4194
|
+
min?: InputMaybe<Social_Feed_Candidates_Min_Order_By>;
|
|
4195
|
+
stddev?: InputMaybe<Social_Feed_Candidates_Stddev_Order_By>;
|
|
4196
|
+
stddev_pop?: InputMaybe<Social_Feed_Candidates_Stddev_Pop_Order_By>;
|
|
4197
|
+
stddev_samp?: InputMaybe<Social_Feed_Candidates_Stddev_Samp_Order_By>;
|
|
4198
|
+
sum?: InputMaybe<Social_Feed_Candidates_Sum_Order_By>;
|
|
4199
|
+
var_pop?: InputMaybe<Social_Feed_Candidates_Var_Pop_Order_By>;
|
|
4200
|
+
var_samp?: InputMaybe<Social_Feed_Candidates_Var_Samp_Order_By>;
|
|
4201
|
+
variance?: InputMaybe<Social_Feed_Candidates_Variance_Order_By>;
|
|
4202
|
+
};
|
|
4203
|
+
/** order by avg() on columns of table "social_feed_candidates" */
|
|
4204
|
+
type Social_Feed_Candidates_Avg_Order_By = {
|
|
4205
|
+
thread_event_id?: InputMaybe<Order_By>;
|
|
4206
|
+
version?: InputMaybe<Order_By>;
|
|
4207
|
+
};
|
|
4208
|
+
/** Boolean expression to filter rows from the table "social_feed_candidates". All fields are combined with a logical 'AND'. */
|
|
4209
|
+
type Social_Feed_Candidates_Bool_Exp = {
|
|
4210
|
+
_and?: InputMaybe<Array<Social_Feed_Candidates_Bool_Exp>>;
|
|
4211
|
+
_not?: InputMaybe<Social_Feed_Candidates_Bool_Exp>;
|
|
4212
|
+
_or?: InputMaybe<Array<Social_Feed_Candidates_Bool_Exp>>;
|
|
4213
|
+
created_at?: InputMaybe<Timestamptz_Comparison_Exp>;
|
|
4214
|
+
id?: InputMaybe<Uuid_Comparison_Exp>;
|
|
4215
|
+
llm_output?: InputMaybe<Jsonb_Comparison_Exp>;
|
|
4216
|
+
summary?: InputMaybe<String_Comparison_Exp>;
|
|
4217
|
+
thread?: InputMaybe<Threads_V2_Bool_Exp>;
|
|
4218
|
+
thread_event_id?: InputMaybe<Bigint_Comparison_Exp>;
|
|
4219
|
+
thread_id?: InputMaybe<Uuid_Comparison_Exp>;
|
|
4220
|
+
title?: InputMaybe<String_Comparison_Exp>;
|
|
4221
|
+
updated_at?: InputMaybe<Timestamptz_Comparison_Exp>;
|
|
4222
|
+
version?: InputMaybe<Int_Comparison_Exp>;
|
|
4223
|
+
};
|
|
4224
|
+
/** order by max() on columns of table "social_feed_candidates" */
|
|
4225
|
+
type Social_Feed_Candidates_Max_Order_By = {
|
|
4226
|
+
created_at?: InputMaybe<Order_By>;
|
|
4227
|
+
id?: InputMaybe<Order_By>;
|
|
4228
|
+
summary?: InputMaybe<Order_By>;
|
|
4229
|
+
thread_event_id?: InputMaybe<Order_By>;
|
|
4230
|
+
thread_id?: InputMaybe<Order_By>;
|
|
4231
|
+
title?: InputMaybe<Order_By>;
|
|
4232
|
+
updated_at?: InputMaybe<Order_By>;
|
|
4233
|
+
version?: InputMaybe<Order_By>;
|
|
4234
|
+
};
|
|
4235
|
+
/** order by min() on columns of table "social_feed_candidates" */
|
|
4236
|
+
type Social_Feed_Candidates_Min_Order_By = {
|
|
4237
|
+
created_at?: InputMaybe<Order_By>;
|
|
4238
|
+
id?: InputMaybe<Order_By>;
|
|
4239
|
+
summary?: InputMaybe<Order_By>;
|
|
4240
|
+
thread_event_id?: InputMaybe<Order_By>;
|
|
4241
|
+
thread_id?: InputMaybe<Order_By>;
|
|
4242
|
+
title?: InputMaybe<Order_By>;
|
|
4243
|
+
updated_at?: InputMaybe<Order_By>;
|
|
4244
|
+
version?: InputMaybe<Order_By>;
|
|
4245
|
+
};
|
|
4246
|
+
/** order by stddev() on columns of table "social_feed_candidates" */
|
|
4247
|
+
type Social_Feed_Candidates_Stddev_Order_By = {
|
|
4248
|
+
thread_event_id?: InputMaybe<Order_By>;
|
|
4249
|
+
version?: InputMaybe<Order_By>;
|
|
4250
|
+
};
|
|
4251
|
+
/** order by stddev_pop() on columns of table "social_feed_candidates" */
|
|
4252
|
+
type Social_Feed_Candidates_Stddev_Pop_Order_By = {
|
|
4253
|
+
thread_event_id?: InputMaybe<Order_By>;
|
|
4254
|
+
version?: InputMaybe<Order_By>;
|
|
4255
|
+
};
|
|
4256
|
+
/** order by stddev_samp() on columns of table "social_feed_candidates" */
|
|
4257
|
+
type Social_Feed_Candidates_Stddev_Samp_Order_By = {
|
|
4258
|
+
thread_event_id?: InputMaybe<Order_By>;
|
|
4259
|
+
version?: InputMaybe<Order_By>;
|
|
4260
|
+
};
|
|
4261
|
+
/** order by sum() on columns of table "social_feed_candidates" */
|
|
4262
|
+
type Social_Feed_Candidates_Sum_Order_By = {
|
|
4263
|
+
thread_event_id?: InputMaybe<Order_By>;
|
|
4264
|
+
version?: InputMaybe<Order_By>;
|
|
4265
|
+
};
|
|
4266
|
+
/** order by var_pop() on columns of table "social_feed_candidates" */
|
|
4267
|
+
type Social_Feed_Candidates_Var_Pop_Order_By = {
|
|
4268
|
+
thread_event_id?: InputMaybe<Order_By>;
|
|
4269
|
+
version?: InputMaybe<Order_By>;
|
|
4270
|
+
};
|
|
4271
|
+
/** order by var_samp() on columns of table "social_feed_candidates" */
|
|
4272
|
+
type Social_Feed_Candidates_Var_Samp_Order_By = {
|
|
4273
|
+
thread_event_id?: InputMaybe<Order_By>;
|
|
4274
|
+
version?: InputMaybe<Order_By>;
|
|
4275
|
+
};
|
|
4276
|
+
/** order by variance() on columns of table "social_feed_candidates" */
|
|
4277
|
+
type Social_Feed_Candidates_Variance_Order_By = {
|
|
4278
|
+
thread_event_id?: InputMaybe<Order_By>;
|
|
4279
|
+
version?: InputMaybe<Order_By>;
|
|
4280
|
+
};
|
|
4179
4281
|
/** order by aggregate values of table "thread_artifacts" */
|
|
4180
4282
|
type Thread_Artifacts_Aggregate_Order_By = {
|
|
4181
4283
|
count?: InputMaybe<Order_By>;
|
|
@@ -4644,6 +4746,7 @@ type Threads_V2_Bool_Exp = {
|
|
|
4644
4746
|
created_at?: InputMaybe<Timestamptz_Comparison_Exp>;
|
|
4645
4747
|
custom_title?: InputMaybe<String_Comparison_Exp>;
|
|
4646
4748
|
deleted_at?: InputMaybe<Timestamptz_Comparison_Exp>;
|
|
4749
|
+
forked_from?: InputMaybe<Uuid_Comparison_Exp>;
|
|
4647
4750
|
learning_suggestion?: InputMaybe<String_Comparison_Exp>;
|
|
4648
4751
|
pinned_threads_v2s?: InputMaybe<Pinned_Threads_V2_Bool_Exp>;
|
|
4649
4752
|
project_config?: InputMaybe<Project_Configuration_Bool_Exp>;
|
|
@@ -4654,6 +4757,7 @@ type Threads_V2_Bool_Exp = {
|
|
|
4654
4757
|
room?: InputMaybe<Rooms_Bool_Exp>;
|
|
4655
4758
|
room_id?: InputMaybe<Uuid_Comparison_Exp>;
|
|
4656
4759
|
shared_threads?: InputMaybe<Shared_Threads_Bool_Exp>;
|
|
4760
|
+
social_feed_candidates?: InputMaybe<Social_Feed_Candidates_Bool_Exp>;
|
|
4657
4761
|
taught_by?: InputMaybe<Thread_Taught_By_Result_Bool_Exp>;
|
|
4658
4762
|
thread_artifacts?: InputMaybe<Thread_Artifacts_Bool_Exp>;
|
|
4659
4763
|
thread_events?: InputMaybe<Thread_Events_Bool_Exp>;
|
|
@@ -4674,6 +4778,7 @@ type Threads_V2_Max_Order_By = {
|
|
|
4674
4778
|
created_at?: InputMaybe<Order_By>;
|
|
4675
4779
|
custom_title?: InputMaybe<Order_By>;
|
|
4676
4780
|
deleted_at?: InputMaybe<Order_By>;
|
|
4781
|
+
forked_from?: InputMaybe<Order_By>;
|
|
4677
4782
|
project_id?: InputMaybe<Order_By>;
|
|
4678
4783
|
/** The room this thread belongs to. Every thread must belong to exactly one room. */
|
|
4679
4784
|
room_id?: InputMaybe<Order_By>;
|
|
@@ -4690,6 +4795,7 @@ type Threads_V2_Min_Order_By = {
|
|
|
4690
4795
|
created_at?: InputMaybe<Order_By>;
|
|
4691
4796
|
custom_title?: InputMaybe<Order_By>;
|
|
4692
4797
|
deleted_at?: InputMaybe<Order_By>;
|
|
4798
|
+
forked_from?: InputMaybe<Order_By>;
|
|
4693
4799
|
project_id?: InputMaybe<Order_By>;
|
|
4694
4800
|
/** The room this thread belongs to. Every thread must belong to exactly one room. */
|
|
4695
4801
|
room_id?: InputMaybe<Order_By>;
|
|
@@ -4706,6 +4812,7 @@ type Threads_V2_Order_By = {
|
|
|
4706
4812
|
created_at?: InputMaybe<Order_By>;
|
|
4707
4813
|
custom_title?: InputMaybe<Order_By>;
|
|
4708
4814
|
deleted_at?: InputMaybe<Order_By>;
|
|
4815
|
+
forked_from?: InputMaybe<Order_By>;
|
|
4709
4816
|
learning_suggestion?: InputMaybe<Order_By>;
|
|
4710
4817
|
pinned_threads_v2s_aggregate?: InputMaybe<Pinned_Threads_V2_Aggregate_Order_By>;
|
|
4711
4818
|
project_config?: InputMaybe<Project_Configuration_Order_By>;
|
|
@@ -4716,6 +4823,7 @@ type Threads_V2_Order_By = {
|
|
|
4716
4823
|
room?: InputMaybe<Rooms_Order_By>;
|
|
4717
4824
|
room_id?: InputMaybe<Order_By>;
|
|
4718
4825
|
shared_threads_aggregate?: InputMaybe<Shared_Threads_Aggregate_Order_By>;
|
|
4826
|
+
social_feed_candidates_aggregate?: InputMaybe<Social_Feed_Candidates_Aggregate_Order_By>;
|
|
4719
4827
|
taught_by_aggregate?: InputMaybe<Thread_Taught_By_Result_Aggregate_Order_By>;
|
|
4720
4828
|
thread_artifacts_aggregate?: InputMaybe<Thread_Artifacts_Aggregate_Order_By>;
|
|
4721
4829
|
thread_events_aggregate?: InputMaybe<Thread_Events_Aggregate_Order_By>;
|
|
@@ -4738,6 +4846,8 @@ type Threads_V2_Select_Column =
|
|
|
4738
4846
|
| 'custom_title'
|
|
4739
4847
|
/** column name */
|
|
4740
4848
|
| 'deleted_at'
|
|
4849
|
+
/** column name */
|
|
4850
|
+
| 'forked_from'
|
|
4741
4851
|
/** column name */
|
|
4742
4852
|
| 'project_id'
|
|
4743
4853
|
/** column name */
|
|
@@ -4832,6 +4942,7 @@ type User_Preferences_Bool_Exp = {
|
|
|
4832
4942
|
created_at?: InputMaybe<Timestamptz_Comparison_Exp>;
|
|
4833
4943
|
custom_instructions?: InputMaybe<String_Comparison_Exp>;
|
|
4834
4944
|
feature_flags?: InputMaybe<Jsonb_Comparison_Exp>;
|
|
4945
|
+
onboarding_popup_shown?: InputMaybe<Boolean_Comparison_Exp>;
|
|
4835
4946
|
promptql_user?: InputMaybe<Promptql_Users_Bool_Exp>;
|
|
4836
4947
|
promptql_user_id?: InputMaybe<Uuid_Comparison_Exp>;
|
|
4837
4948
|
updated_at?: InputMaybe<Timestamptz_Comparison_Exp>;
|
|
@@ -4841,6 +4952,7 @@ type User_Preferences_Order_By = {
|
|
|
4841
4952
|
created_at?: InputMaybe<Order_By>;
|
|
4842
4953
|
custom_instructions?: InputMaybe<Order_By>;
|
|
4843
4954
|
feature_flags?: InputMaybe<Order_By>;
|
|
4955
|
+
onboarding_popup_shown?: InputMaybe<Order_By>;
|
|
4844
4956
|
promptql_user?: InputMaybe<Promptql_Users_Order_By>;
|
|
4845
4957
|
promptql_user_id?: InputMaybe<Order_By>;
|
|
4846
4958
|
updated_at?: InputMaybe<Order_By>;
|
|
@@ -5123,11 +5235,7 @@ type GetThreadEventOptions = {
|
|
|
5123
5235
|
/**
|
|
5124
5236
|
* Filter events from this event ID.
|
|
5125
5237
|
*/
|
|
5126
|
-
|
|
5127
|
-
/**
|
|
5128
|
-
* Filter events to this event ID.
|
|
5129
|
-
*/
|
|
5130
|
-
toEventId?: string | null;
|
|
5238
|
+
eventId?: Bigint_Comparison_Exp;
|
|
5131
5239
|
/**
|
|
5132
5240
|
* Filter events by message ID.
|
|
5133
5241
|
*/
|
|
@@ -5136,6 +5244,10 @@ type GetThreadEventOptions = {
|
|
|
5136
5244
|
* Limit number of events
|
|
5137
5245
|
*/
|
|
5138
5246
|
limit?: number | null;
|
|
5247
|
+
/**
|
|
5248
|
+
* Limit number of events
|
|
5249
|
+
*/
|
|
5250
|
+
ordering?: Order_By | null;
|
|
5139
5251
|
};
|
|
5140
5252
|
/**
|
|
5141
5253
|
* Optional options for streaming thread events.
|
|
@@ -5153,6 +5265,14 @@ type StreamThreadEventOptions = {
|
|
|
5153
5265
|
* Stop right after the agent responds and skip post analysis events.
|
|
5154
5266
|
*/
|
|
5155
5267
|
skipAnalysis?: boolean;
|
|
5268
|
+
/**
|
|
5269
|
+
* Polling interval in seconds. Default is 5 seconds.
|
|
5270
|
+
*/
|
|
5271
|
+
pollingInterval?: number;
|
|
5272
|
+
/**
|
|
5273
|
+
* Maximum timeout in seconds.
|
|
5274
|
+
*/
|
|
5275
|
+
timeout?: number;
|
|
5156
5276
|
};
|
|
5157
5277
|
|
|
5158
5278
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var x=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var re=Object.prototype.hasOwnProperty;var _e=(t,e)=>{for(var a in e)x(t,a,{get:e[a],enumerable:!0})},ne=(t,e,a,_)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ae(e))!re.call(t,r)&&r!==a&&x(t,r,{get:()=>e[r],enumerable:!(_=te(e,r))||_.enumerable});return t};var ie=t=>ne(x({},"__esModule",{value:!0}),t);var Ne={};_e(Ne,{PromptQLSdk:()=>U,cancelAgentMessage:()=>T,createApolloClient:()=>P,createPromptQLAuthTokenGenerator:()=>m,diffThreadEvents:()=>oe,getAgentGeneratedResponse:()=>ce,getAgentInteractionDecisionAcceptInteractionEvent:()=>me,getAgentInteractionDecisionDeclineInteractionEvent:()=>be,getAgentInteractionFinishedEvent:()=>We,getAgentMessageProcessingStartedEvent:()=>le,getAgentOrchestratorContextExplorerCompletedEvent:()=>fe,getAgentOrchestratorContextExplorerStartedEvent:()=>he,getAgentOrchestratorContextExplorerUpdateEvent:()=>u,getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent:()=>Ee,getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent:()=>Pe,getAgentOrchestratorSchemaExplorerCompletedEvent:()=>Oe,getAgentOrchestratorSchemaExplorerGeneratedCodeEvent:()=>Re,getAgentOrchestratorSchemaExplorerSchemaExploredEvent:()=>Ue,getAgentOrchestratorSchemaExplorerStartedEvent:()=>Te,getAgentOrchestratorSchemaExplorerUpdateEvent:()=>s,getAgentOrchestratorSchemaTasksGeneratedEvent:()=>ve,getAgentOrchestratorSchemaTasksGenerationCompletedEvent:()=>ke,getAgentOrchestratorSchemaTasksGenerationStartedEvent:()=>Ce,getAgentOrchestratorSchemaTasksGenerationUpdateEvent:()=>h,getAgentOrchestratorStepProgrammerEvent:()=>we,getAgentOrchestratorStepSavedProgramRunnerEvent:()=>Ve,getAgentOrchestratorStepUiProgrammerEvent:()=>Fe,getAgentOrchestratorStepUpdateEvent:()=>f,getAgentOrchestratorUpdateEvent:()=>g,getAgentOrchestratorWikiExplorerCompletedEvent:()=>Ae,getAgentOrchestratorWikiExplorerStartedEvent:()=>xe,getAgentOrchestratorWikiExplorerUpdateEvent:()=>S,getAgentOrchestratorWikiInfoGeneratedEvent:()=>Be,getAgentPlanGenerationStartedEvent:()=>de,getAgentPlanStepGeneratedEvent:()=>ye,getAgentPlanningDecisionCompletedEvent:()=>Me,getAgentPlanningDecisionPlanningRequiredEvent:()=>ge,getAgentPlanningDecisionStartedEvent:()=>Ie,getAgentPlanningDecisionUpdateEvent:()=>M,getAgentStartingOrchestratorEvent:()=>Se,getThread:()=>B,getThreadEvents:()=>k,getUserCancelEvent:()=>ue,getUserMessageEvent:()=>se,listThreads:()=>A,sendThreadMessage:()=>v,startThread:()=>C,streamThreadMessageEvents:()=>E,subscribeThreadEvents:()=>O,wasInteractionFinished:()=>Q});module.exports=ie(Ne);var l=require("rxjs");var F={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CancelAgentMessage"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"messageId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"cancel_agent_message"},arguments:[{kind:"Argument",name:{kind:"Name",value:"threadId"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}},{kind:"Argument",name:{kind:"Name",value:"agentMessageId"},value:{kind:"Variable",name:{kind:"Name",value:"messageId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},V={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"SendThreadMessage"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"uploads"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"UserUploadInput"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"send_thread_message"},arguments:[{kind:"Argument",name:{kind:"Name",value:"threadId"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}},{kind:"Argument",name:{kind:"Name",value:"uploads"},value:{kind:"Variable",name:{kind:"Name",value:"uploads"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},W={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"StartThread"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"projectId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildId"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"roomId"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"uploads"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"UserUploadInput"}}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"visibility"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"start_thread"},arguments:[{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"projectId"},value:{kind:"Variable",name:{kind:"Name",value:"projectId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"buildId"},value:{kind:"Variable",name:{kind:"Name",value:"buildId"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}},{kind:"Argument",name:{kind:"Name",value:"roomId"},value:{kind:"Variable",name:{kind:"Name",value:"roomId"}}},{kind:"Argument",name:{kind:"Name",value:"uploads"},value:{kind:"Variable",name:{kind:"Name",value:"uploads"}}},{kind:"Argument",name:{kind:"Name",value:"visibility"},value:{kind:"Variable",name:{kind:"Name",value:"visibility"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"thread_events"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"thread_event_id"}}]}}]}}]}}]},N={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetProjectInfo"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"get_project_info"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"projectId"}},{kind:"Field",name:{kind:"Name",value:"projectName"}},{kind:"Field",name:{kind:"Name",value:"promptqlConsoleUrl"}}]}}]}}]},j={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreads"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"offset"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_order_by"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"offset"},value:{kind:"Variable",name:{kind:"Name",value:"offset"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},q={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadById"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"uuid"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2_by_pk"},arguments:[{kind:"Argument",name:{kind:"Name",value:"thread_id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},z={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"thread_events_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_events"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_event_id"},value:{kind:"EnumValue",value:"asc"}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ThreadEvent"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ThreadEvent"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"thread_events"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"user_id"}}]}}]},G={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"subscription",name:{kind:"Name",value:"SubscribeThreadEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"thread_events_bool_exp"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_events"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_event_id"},value:{kind:"EnumValue",value:"asc"}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ThreadEvent"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ThreadEvent"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"thread_events"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"user_id"}}]}}]};function y(t){return t=t?t.trim():"",t?t[t.length-1]==="/"?t.slice(0,t.length-1):t:""}function c(t){if(t==null)return null;try{Number.parseInt(t)}catch{throw new Error("invalid threadEventId")}return t}function A(t,e){return t.query({query:j,variables:{...e,limit:e.limit&&e.limit>0?e.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2??[])}function B(t,e){if(!e)throw new Error("threadId is required");return t.query({query:q,variables:{id:e},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2_by_pk)}function C(t,e){if(!e.message.trim())throw new Error("message must not be empty");return t.mutate({mutation:W,variables:e}).then(a=>{if(!a.data?.start_thread)throw new Error(a.error?.message||"Failed to start thread");return a.data.start_thread})}function k(t,e,a){if(!e)throw new Error("threadId is required");let _={thread_id:{_eq:e}};if(a){let r=c(a.fromEventId),n=c(a.toEventId);r&&n?_.thread_event_id={_gte:a.fromEventId,_lte:a.toEventId}:r?_.thread_event_id={_gte:r}:n&&(_.thread_event_id={_lte:n}),a.messageId&&(_._or=K(a.messageId))}return t.query({query:z,variables:{where:_,limit:a?.limit},fetchPolicy:"no-cache"}).then(r=>r.data?.thread_events??[])}function v(t,e){if(!e.threadId)throw new Error("threadId is required");if(!e.message.trim())throw new Error("message must not be empty");return t.mutate({mutation:V,variables:e}).then(a=>{if(!a.data?.send_thread_message)throw new Error(a.error?.message||"Failed to send message to thread");return a.data.send_thread_message})}function T(t,e){if(!e.threadId)throw new Error("threadId is required");if(!e.messageId.trim())throw new Error("messageId is required");return t.mutate({mutation:F,variables:e}).then(a=>{if(!a.data?.cancel_agent_message)throw new Error(a.error?.message||"Failed to cancel thread");return a.data.cancel_agent_message})}function O(t,e,a){return D(t,e,{fromEventId:a})}function E(t,e,a){return D(t,e,a).pipe((0,l.takeWhile)(_=>Q(_,a?.skipAnalysis),!0))}function Q(t,e){for(let a=t.length-1;a>0;a--){let _=t[a];if(e&&"UserCancel"in _.event_data)return!1;if(!("AgentMessage"in _.event_data))return!0;let r=_.event_data.AgentMessage.update;if("content"in r&&"interaction_finished"in r.content||"InteractionFinished"in r||e&&"OrchestratorUpdate"in r&&"GeneratedResponse"in r.OrchestratorUpdate.update)return!1}return!0}function D(t,e,a){if(!e)throw new Error("threadId is required");let _={thread_id:{_eq:e}};return a&&(c(a.fromEventId)&&(_.thread_event_id={_gte:a.fromEventId}),a.messageId&&(_._or=K(a.messageId))),t.subscribe({query:G,variables:{where:_}}).pipe((0,l.map)(r=>{if(r.error)throw r.error;return r.data?.thread_events??[]}))}function K(t){return[{event_data:{_contains:{UserMessage:{message_id:t}}}},{event_data:{_contains:{AgentMessage:{message_id:t}}}},{event_data:{_contains:{UserCancel:{message_id:t}}}}]}function H(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="failure"}function L(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="success"&&"token"in t}function J(t){return t!=null&&typeof t=="object"&&("data"in t&&!!t.data&&typeof t.data=="object"&&"enrich_token"in t.data&&!!t.data.enrich_token&&typeof t.data.enrich_token=="object"&&"userDirectoryJWT"in t.data.enrich_token||"errors"in t&&Array.isArray(t.errors))}function m(t){let a=`${y(t.authHost)||"https://auth.pro.hasura.io"}/ddn/promptql/token`,_={token:"",expiry:new Date(0)},r=t.fetch||fetch,n=async()=>{let p=await r(a,{method:"POST",headers:t.headers});switch(p.status){case 200:{let i=await p.json();if(L(i))return i;throw new Error("malformed token response")}case 401:{let i=await p.json();throw H(i)?new Error(i?.error||p.statusText):new Error(p.statusText)}default:{let i=await p.text();throw new Error(i)}}};return async()=>{if(_.expiry.getTime()<=Date.now()-1e3){let p=await n(),i=await pe(t.promptqlGraphQLUrl,p.token,t.projectId,r);_.token=i;let d=new Date(p.expiry);if(Number.isNaN(d.getTime())){let w=new Date;w.setHours(1),_.expiry=w}else _.expiry=d}return _.token}}var pe=async(t,e,a,_=fetch)=>{let r=await _(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:"mutation EnrichToken($luxJWT: String!, $projectId: uuid) { enrich_token(luxJWT: $luxJWT, projectId: $projectId) { userDirectoryJWT }}",variables:{luxJWT:e,projectId:a},operationName:"EnrichToken"})});switch(r.status){case 200:{let n=await r.json();if(!J(n)||!n.data?.enrich_token?.userDirectoryJWT)throw new Error(`malformed promptql token response: ${JSON.stringify(n)}`);return n.data.enrich_token.userDirectoryJWT}default:{let n=await r.text();throw new Error(n)}}};function $(t){return{Authorization:`pat ${t}`}}var o=require("@apollo/client"),Z=require("@apollo/client/link/context"),X=require("@apollo/client/link/subscriptions"),Y=require("graphql"),ee=require("graphql-ws"),P=t=>{let e=new o.HttpLink({uri:t.url,fetch:t.fetch,headers:t.headers}),a=async i=>{let d=await t.getAuthToken();return{headers:{...i,Authorization:`Bearer ${d}`}}},_=(0,ee.createClient)({url:t.url,connectionParams:()=>a(t.headers)}),r=new X.GraphQLWsLink(_),n=new Z.SetContextLink(({headers:i})=>a(i)),p=o.ApolloLink.split(({operationType:i})=>i===Y.OperationTypeNode.SUBSCRIPTION,r,n.concat(e));return{client:new o.ApolloClient({link:p,cache:new o.InMemoryCache}),wsClient:_}};var b=class{_options;constructor(e){this._options=e}info(){return R(this._options.client)}};function R(t){return t.query({query:N,fetchPolicy:"cache-first"}).then(e=>{if(!e.data?.get_project_info)throw new Error(e.error?.message||"Project not found");return e.data.get_project_info})}var I=class{_options;constructor(e){this._options=e}list(e){return A(this._options.client,{...e,limit:e.limit&&e.limit>0?e.limit:10})}get(e){if(!e)throw new Error("threadId is required");return B(this._options.client,e)}async start(e){let a=await R(this._options.client);return C(this._options.client,{...e,projectId:a.projectId,buildId:e.buildId||this._options.buildId,timezone:e.timezone||this._options.defaultTimezone})}getEvents(e,a){return k(this._options.client,e,a)}sendMessage(e){return v(this._options.client,{...e,timezone:e.timezone||this._options.defaultTimezone})}cancelAgentMessage(e){return T(this._options.client,e)}subscribeEvents(e,a){return O(this._options.client,e,a)}streamMessageEvents(e,a){return E(this._options.client,e,a)}};var U=class{constructor(e){let a=y(e.promptqlBaseUrl)||"https://promptql.ddn.hasura.app";if(!e.serviceAccountToken)throw new Error("serviceAccountToken must not be empty. If you haven't created any service account token yet, check out Hasura docs https://hasura.io/docs/3.0/project-configuration/project-management/service-accounts/#how-to-create-service-account");let _=a.endsWith("/v1/graphql")?a:`${a}/playground-v2-hge/v1/graphql`;this._fetchToken=m({promptqlGraphQLUrl:_,authHost:e.authHost,headers:$(e.serviceAccountToken),fetch:e.fetch});let{client:r,wsClient:n}=P({getAuthToken:this._fetchToken,url:_,fetch:e.fetch,headers:e.headers});this._wsClient=n,this._options={client:r,buildId:e.buildId,defaultTimezone:e.timezone||Intl.DateTimeFormat().resolvedOptions().timeZone},this.thread=new I(this._options),this.project=new b(this._options)}_options;_wsClient;_fetchToken;thread;project;authenticated(){return this._fetchToken().then(()=>!0).catch(()=>!1)}close(){this._wsClient.dispose(),this._options.client.clearStore()}};function oe(t,e){if(!e.length)return[];if(!t.length)return e;let a=t[t.length-1];if(!a)return e;let _=BigInt(a.thread_event_id),r=e.length-1;for(;r>=0;r--){let n=e[r];if(BigInt(n?.thread_event_id)<=_)break}return e.slice(r+1)}function se(t){return"UserMessage"in t?t.UserMessage:null}function ue(t){return"UserCancel"in t?t.UserCancel:null}function de(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)||!("PlanGenerationStarted"in t.AgentMessage.update.OrchestratorUpdate.update)?null:t.AgentMessage.update.OrchestratorUpdate.update.PlanGenerationStarted}function ye(t){let e=g(t);return!e||!("PlanStepGenerated"in e)?null:e.PlanStepGenerated}function ce(t){return"AgentMessage"in t?"content"in t.AgentMessage.update&&"interaction_update"in t.AgentMessage.update.content&&"main_agent"in t.AgentMessage.update.content.interaction_update&&"completed"in t.AgentMessage.update.content.interaction_update.main_agent?{success:!0,message:t.AgentMessage.update.content.interaction_update.main_agent.completed.summary,modified_artifacts:[],generated_at:t.AgentMessage.update.timestamp}:!("OrchestratorUpdate"in t.AgentMessage.update)||!("GeneratedResponse"in t.AgentMessage.update.OrchestratorUpdate.update)?null:t.AgentMessage.update.OrchestratorUpdate.update.GeneratedResponse.response:null}function le(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("ProcessingStarted"in t.AgentMessage.update.MessageProcessingUpdate.update)?null:t.AgentMessage.update.MessageProcessingUpdate.update.ProcessingStarted}function me(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("InteractionDecision"in t.AgentMessage.update.MessageProcessingUpdate.update)||!("AcceptInteraction"in t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.AcceptInteraction}function be(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("InteractionDecision"in t.AgentMessage.update.MessageProcessingUpdate.update)||!("DeclineInteraction"in t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.DeclineInteraction}function M(t){return!("AgentMessage"in t)||!("PlanningDecisionUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.PlanningDecisionUpdate.update}function Ie(t){let e=M(t);return!e||!("Started"in e)?null:e.Started}function Me(t){let e=M(t);return!e||!("Completed"in e)?null:e.Completed}function ge(t){let e=M(t);return!e||!("PlanningRequired"in e)?null:e.PlanningRequired}function Se(t){return!("AgentMessage"in t)||!("StartingOrchestrator"in t.AgentMessage.update)?null:t.AgentMessage.update.StartingOrchestrator}function g(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.OrchestratorUpdate.update}function u(t){let e=g(t);return!e||!("ContextExplorerUpdate"in e)?null:e.ContextExplorerUpdate.update}function he(t){let e=u(t);return!e||!("Started"in e)?null:e.Started}function fe(t){let e=u(t);return!e||!("Completed"in e)?null:e.Completed}function S(t){let e=u(t);return!e||!("WikiExplorerUpdate"in e)?null:e.WikiExplorerUpdate.update}function xe(t){let e=S(t);return!e||!("Started"in e)?null:e.Started}function Ae(t){let e=S(t);return!e||!("Completed"in e)?null:e.Completed}function Be(t){let e=S(t);return!e||!("WikiInfoGenerated"in e)?null:e.WikiInfoGenerated}function h(t){let e=u(t);return!e||!("SchemaTasksGenerationUpdate"in e)?null:e.SchemaTasksGenerationUpdate.update}function Ce(t){let e=h(t);return!e||!("Started"in e)?null:e.Started}function ke(t){let e=h(t);return!e||!("Completed"in e)?null:e.Completed}function ve(t){let e=h(t);return!e||!("TasksGenerated"in e)?null:e.TasksGenerated}function s(t){let e=u(t);return!e||!("SchemaExplorerUpdate"in e)?null:e.SchemaExplorerUpdate.update}function Te(t){let e=s(t);return!e||!("Started"in e)?null:e.Started}function Oe(t){let e=s(t);return!e||!("Completed"in e)?null:e.Completed}function Ee(t){let e=s(t);return!e||!("CodeExecutionComplete"in e)?null:e.CodeExecutionComplete}function Pe(t){let e=s(t);return!e||!("CodeOutputAnalyzed"in e)?null:e.CodeOutputAnalyzed}function Re(t){let e=s(t);return!e||!("GeneratedCode"in e)?null:e.GeneratedCode}function Ue(t){let e=s(t);return!e||!("SchemaExplored"in e)?null:e.SchemaExplored}function f(t){let e=g(t);return!e||!("StepUpdate"in e)?null:e.StepUpdate}function we(t){let e=f(t);return!e||!("Programmer"in e.update)?null:e.update.Programmer}function Fe(t){let e=f(t);return!e||!("UiProgrammer"in e.update)?null:e.update.UiProgrammer}function Ve(t){let e=f(t);return!e||!("SavedProgramRunner"in e.update)?null:e.update.SavedProgramRunner}function We(t){if(!("AgentMessage"in t))return null;if("InteractionFinished"in t.AgentMessage.update){let e=t.AgentMessage.update.InteractionFinished.update;return"Completed"in e?{status:"completed",timestamp:e.Completed.completed_at,warnings:e.Completed.warnings}:"Errored"in e?{status:"errored",timestamp:e.Errored.errored_at,reason:typeof e.Errored.error=="string"?e.Errored.error:e.Errored.error.User.message}:"UserCancelled"in e?{status:"user_cancelled",timestamp:e.UserCancelled.cancelled_at}:"AgentDeclined"in e?{status:"agent_declined",timestamp:e.AgentDeclined.declined_at,reason:e.AgentDeclined.reason}:"ServerCancelled"in e?{status:"server_cancelled",timestamp:e.ServerCancelled.cancelled_at}:{status:"unknown"}}if("content"in t.AgentMessage.update&&"interaction_finished"in t.AgentMessage.update.content){let e=t.AgentMessage.update.content.interaction_finished.outcome;return"errored"in e?{status:"errored",reason:e.errored.user_facing_message||e.errored.raw_error,timestamp:t.AgentMessage.update.timestamp,warnings:e.errored.raw_error?[{message:e.errored.raw_error}]:[]}:"server_cancelled"in e?{status:"server_cancelled",timestamp:t.AgentMessage.update.timestamp}:"user_cancelled"in e?{status:"user_cancelled",timestamp:t.AgentMessage.update.timestamp}:"completed"in e?{status:"completed",timestamp:t.AgentMessage.update.timestamp,warnings:e.completed.warnings}:{status:"unknown"}}return null}0&&(module.exports={PromptQLSdk,cancelAgentMessage,createApolloClient,createPromptQLAuthTokenGenerator,diffThreadEvents,getAgentGeneratedResponse,getAgentInteractionDecisionAcceptInteractionEvent,getAgentInteractionDecisionDeclineInteractionEvent,getAgentInteractionFinishedEvent,getAgentMessageProcessingStartedEvent,getAgentOrchestratorContextExplorerCompletedEvent,getAgentOrchestratorContextExplorerStartedEvent,getAgentOrchestratorContextExplorerUpdateEvent,getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent,getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent,getAgentOrchestratorSchemaExplorerCompletedEvent,getAgentOrchestratorSchemaExplorerGeneratedCodeEvent,getAgentOrchestratorSchemaExplorerSchemaExploredEvent,getAgentOrchestratorSchemaExplorerStartedEvent,getAgentOrchestratorSchemaExplorerUpdateEvent,getAgentOrchestratorSchemaTasksGeneratedEvent,getAgentOrchestratorSchemaTasksGenerationCompletedEvent,getAgentOrchestratorSchemaTasksGenerationStartedEvent,getAgentOrchestratorSchemaTasksGenerationUpdateEvent,getAgentOrchestratorStepProgrammerEvent,getAgentOrchestratorStepSavedProgramRunnerEvent,getAgentOrchestratorStepUiProgrammerEvent,getAgentOrchestratorStepUpdateEvent,getAgentOrchestratorUpdateEvent,getAgentOrchestratorWikiExplorerCompletedEvent,getAgentOrchestratorWikiExplorerStartedEvent,getAgentOrchestratorWikiExplorerUpdateEvent,getAgentOrchestratorWikiInfoGeneratedEvent,getAgentPlanGenerationStartedEvent,getAgentPlanStepGeneratedEvent,getAgentPlanningDecisionCompletedEvent,getAgentPlanningDecisionPlanningRequiredEvent,getAgentPlanningDecisionStartedEvent,getAgentPlanningDecisionUpdateEvent,getAgentStartingOrchestratorEvent,getThread,getThreadEvents,getUserCancelEvent,getUserMessageEvent,listThreads,sendThreadMessage,startThread,streamThreadMessageEvents,subscribeThreadEvents,wasInteractionFinished});
|
|
1
|
+
"use strict";var x=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var ae=(t,e)=>{for(var a in e)x(t,a,{get:e[a],enumerable:!0})},re=(t,e,a,_)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ee(e))!te.call(t,r)&&r!==a&&x(t,r,{get:()=>e[r],enumerable:!(_=Y(e,r))||_.enumerable});return t};var _e=t=>re(x({},"__esModule",{value:!0}),t);var We={};ae(We,{PromptQLSdk:()=>U,cancelAgentMessage:()=>v,createApolloClient:()=>P,createPromptQLAuthTokenGenerator:()=>b,diffThreadEvents:()=>oe,getAgentGeneratedResponse:()=>ye,getAgentInteractionDecisionAcceptInteractionEvent:()=>le,getAgentInteractionDecisionDeclineInteractionEvent:()=>be,getAgentInteractionFinishedEvent:()=>Fe,getAgentMessageProcessingStartedEvent:()=>ce,getAgentOrchestratorContextExplorerCompletedEvent:()=>Ae,getAgentOrchestratorContextExplorerStartedEvent:()=>ge,getAgentOrchestratorContextExplorerUpdateEvent:()=>y,getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent:()=>Ee,getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent:()=>Te,getAgentOrchestratorSchemaExplorerCompletedEvent:()=>ve,getAgentOrchestratorSchemaExplorerGeneratedCodeEvent:()=>Pe,getAgentOrchestratorSchemaExplorerSchemaExploredEvent:()=>Re,getAgentOrchestratorSchemaExplorerStartedEvent:()=>Oe,getAgentOrchestratorSchemaExplorerUpdateEvent:()=>d,getAgentOrchestratorSchemaTasksGeneratedEvent:()=>ke,getAgentOrchestratorSchemaTasksGenerationCompletedEvent:()=>Be,getAgentOrchestratorSchemaTasksGenerationStartedEvent:()=>Ce,getAgentOrchestratorSchemaTasksGenerationUpdateEvent:()=>A,getAgentOrchestratorStepProgrammerEvent:()=>Ue,getAgentOrchestratorStepSavedProgramRunnerEvent:()=>je,getAgentOrchestratorStepUiProgrammerEvent:()=>we,getAgentOrchestratorStepUpdateEvent:()=>h,getAgentOrchestratorUpdateEvent:()=>S,getAgentOrchestratorWikiExplorerCompletedEvent:()=>xe,getAgentOrchestratorWikiExplorerStartedEvent:()=>he,getAgentOrchestratorWikiExplorerUpdateEvent:()=>g,getAgentOrchestratorWikiInfoGeneratedEvent:()=>fe,getAgentPlanGenerationStartedEvent:()=>se,getAgentPlanStepGeneratedEvent:()=>de,getAgentPlanningDecisionCompletedEvent:()=>Ie,getAgentPlanningDecisionPlanningRequiredEvent:()=>Me,getAgentPlanningDecisionStartedEvent:()=>me,getAgentPlanningDecisionUpdateEvent:()=>M,getAgentStartingOrchestratorEvent:()=>Se,getThread:()=>B,getThreadEvents:()=>l,getUserCancelEvent:()=>ue,getUserMessageEvent:()=>pe,listThreads:()=>C,sendThreadMessage:()=>O,startThread:()=>k,streamThreadMessageEvents:()=>T,subscribeThreadEvents:()=>E,wasInteractionFinished:()=>D});module.exports=_e(We);var u=require("rxjs");var j={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CancelAgentMessage"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"messageId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"cancel_agent_message"},arguments:[{kind:"Argument",name:{kind:"Name",value:"threadId"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}},{kind:"Argument",name:{kind:"Name",value:"agentMessageId"},value:{kind:"Variable",name:{kind:"Name",value:"messageId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},F={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"SendThreadMessage"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"uploads"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"UserUploadInput"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"send_thread_message"},arguments:[{kind:"Argument",name:{kind:"Name",value:"threadId"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}},{kind:"Argument",name:{kind:"Name",value:"uploads"},value:{kind:"Variable",name:{kind:"Name",value:"uploads"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},W={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"StartThread"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"projectId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildId"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"roomId"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"uploads"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"UserUploadInput"}}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"visibility"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"start_thread"},arguments:[{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"projectId"},value:{kind:"Variable",name:{kind:"Name",value:"projectId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"buildId"},value:{kind:"Variable",name:{kind:"Name",value:"buildId"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}},{kind:"Argument",name:{kind:"Name",value:"roomId"},value:{kind:"Variable",name:{kind:"Name",value:"roomId"}}},{kind:"Argument",name:{kind:"Name",value:"uploads"},value:{kind:"Variable",name:{kind:"Name",value:"uploads"}}},{kind:"Argument",name:{kind:"Name",value:"visibility"},value:{kind:"Variable",name:{kind:"Name",value:"visibility"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"thread_events"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"thread_event_id"}}]}}]}}]}}]},V={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetProjectInfo"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"get_project_info"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"projectId"}},{kind:"Field",name:{kind:"Name",value:"projectName"}},{kind:"Field",name:{kind:"Name",value:"promptqlConsoleUrl"}}]}}]}}]},N={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreads"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"offset"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_order_by"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"offset"},value:{kind:"Variable",name:{kind:"Name",value:"offset"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},z={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadById"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"uuid"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2_by_pk"},arguments:[{kind:"Argument",name:{kind:"Name",value:"thread_id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},q={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"thread_events_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"ordering"}},type:{kind:"NamedType",name:{kind:"Name",value:"order_by"}},defaultValue:{kind:"EnumValue",value:"asc"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_events"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_event_id"},value:{kind:"Variable",name:{kind:"Name",value:"ordering"}}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ThreadEvent"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ThreadEvent"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"thread_events"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"user_id"}}]}}]},G={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"subscription",name:{kind:"Name",value:"SubscribeThreadEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"thread_events_bool_exp"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_events"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_event_id"},value:{kind:"EnumValue",value:"asc"}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ThreadEvent"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ThreadEvent"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"thread_events"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"user_id"}}]}}]};function c(t){return t=t?t.trim():"",t?t[t.length-1]==="/"?t.slice(0,t.length-1):t:""}function f(t){if(t==null)return null;try{Number.parseInt(t)}catch{throw new Error("invalid threadEventId")}return t}function C(t,e){return t.query({query:N,variables:{...e,limit:e.limit&&e.limit>0?e.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2??[])}function B(t,e){if(!e)throw new Error("threadId is required");return t.query({query:z,variables:{id:e},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2_by_pk)}function k(t,e){if(!e.message.trim())throw new Error("message must not be empty");return t.mutate({mutation:W,variables:e}).then(a=>{if(!a.data?.start_thread)throw new Error(a.error?.message||"Failed to start thread");return a.data.start_thread})}function l(t,e,a){if(!e)throw new Error("threadId is required");let _={thread_id:{_eq:e}};return a&&(a.eventId&&(_.thread_event_id=a.eventId),a.messageId&&(_._or=ne(a.messageId))),t.query({query:q,variables:{where:_,limit:a?.limit,ordering:a?.ordering||"asc"},fetchPolicy:"no-cache"}).then(r=>r.data?.thread_events??[])}function O(t,e){if(!e.threadId)throw new Error("threadId is required");if(!e.message.trim())throw new Error("message must not be empty");return t.mutate({mutation:F,variables:e}).then(a=>{if(!a.data?.send_thread_message)throw new Error(a.error?.message||"Failed to send message to thread");return a.data.send_thread_message})}function v(t,e){if(!e.threadId)throw new Error("threadId is required");if(!e.messageId.trim())throw new Error("messageId is required");return t.mutate({mutation:j,variables:e}).then(a=>{if(!a.data?.cancel_agent_message)throw new Error(a.error?.message||"Failed to cancel thread");return a.data.cancel_agent_message})}function E(t,e,a){if(!e)throw new Error("threadId is required");f(a);let _={thread_id:{_eq:e}};return a&&(_.thread_event_id={_gte:a}),t.subscribe({query:G,variables:{where:_}}).pipe((0,u.map)(r=>{if(r.error)throw r.error;return r.data?.thread_events??[]}))}function T(t,e,a){if(!e)throw new Error("threadId is required");let _,r=f(a?.fromEventId),i={eventId:a?.fromEventId?{_gte:r}:void 0,messageId:a?.messageId},o=a?.pollingInterval&&a?.pollingInterval>0?a.pollingInterval:5;return(0,u.defer)(async()=>{let n=_?{messageId:a?.messageId,eventId:{_gt:_}}:i,p=await l(t,e,n);return p.length>0&&(_=p[p.length-1]?.thread_event_id),p}).pipe((0,u.repeat)({count:a?.timeout&&a.timeout>0?Math.ceil(a.timeout/o):void 0,delay:o*1e3}),(0,u.takeWhile)(n=>D(n,a?.skipAnalysis),!0))}function D(t,e){for(let a=t.length-1;a>0;a--){let _=t[a];if(e&&"UserCancel"in _.event_data)return!1;if(!("AgentMessage"in _.event_data))return!0;let r=_.event_data.AgentMessage.update;if("content"in r&&"interaction_finished"in r.content||"InteractionFinished"in r||e&&"OrchestratorUpdate"in r&&"GeneratedResponse"in r.OrchestratorUpdate.update)return!1}return!0}function ne(t){return[{event_data:{_contains:{UserMessage:{message_id:t}}}},{event_data:{_contains:{AgentMessage:{message_id:t}}}},{event_data:{_contains:{UserCancel:{message_id:t}}}}]}function Q(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="failure"}function J(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="success"&&"token"in t}function L(t){return t!=null&&typeof t=="object"&&("data"in t&&!!t.data&&typeof t.data=="object"&&"enrich_token"in t.data&&!!t.data.enrich_token&&typeof t.data.enrich_token=="object"&&"userDirectoryJWT"in t.data.enrich_token||"errors"in t&&Array.isArray(t.errors))}function b(t){let a=`${c(t.authHost)||"https://auth.pro.hasura.io"}/ddn/promptql/token`,_={token:"",expiry:new Date(0)},r=t.fetch||fetch,i=async()=>{let o=await r(a,{method:"POST",headers:t.headers});switch(o.status){case 200:{let n=await o.json();if(J(n))return n;throw new Error("malformed token response")}case 401:{let n=await o.json();throw Q(n)?new Error(n?.error||o.statusText):new Error(o.statusText)}default:{let n=await o.text();throw new Error(n)}}};return async()=>{if(_.expiry.getTime()<=Date.now()-1e3){let o=await i(),n=await ie(t.promptqlGraphQLUrl,o.token,t.projectId,r);_.token=n;let p=new Date(o.expiry);if(Number.isNaN(p.getTime())){let w=new Date;w.setHours(1),_.expiry=w}else _.expiry=p}return _.token}}var ie=async(t,e,a,_=fetch)=>{let r=await _(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:"mutation EnrichToken($luxJWT: String!, $projectId: uuid) { enrich_token(luxJWT: $luxJWT, projectId: $projectId) { userDirectoryJWT }}",variables:{luxJWT:e,projectId:a},operationName:"EnrichToken"})});switch(r.status){case 200:{let i=await r.json();if(!L(i)||!i.data?.enrich_token?.userDirectoryJWT)throw new Error(`malformed promptql token response: ${JSON.stringify(i)}`);return i.data.enrich_token.userDirectoryJWT}default:{let i=await r.text();throw new Error(i)}}};function K(t){return{Authorization:`pat ${t}`}}var s=require("@apollo/client"),H=require("@apollo/client/link/context"),$=require("@apollo/client/link/subscriptions"),Z=require("graphql"),X=require("graphql-ws"),P=t=>{let e=new s.HttpLink({uri:t.url,fetch:t.fetch,headers:t.headers}),a=async n=>{let p=await t.getAuthToken();return{headers:{...n,Authorization:`Bearer ${p}`}}},_=(0,X.createClient)({url:t.url,connectionParams:()=>a(t.headers),lazy:!0}),r=new $.GraphQLWsLink(_),i=new H.SetContextLink(({headers:n})=>a(n)),o=s.ApolloLink.split(({operationType:n})=>n===Z.OperationTypeNode.SUBSCRIPTION,r,i.concat(e));return{client:new s.ApolloClient({link:o,cache:new s.InMemoryCache}),wsClient:_}};var m=class{_options;constructor(e){this._options=e}info(){return R(this._options.client)}};function R(t){return t.query({query:V,fetchPolicy:"cache-first"}).then(e=>{if(!e.data?.get_project_info)throw new Error(e.error?.message||"Project not found");return e.data.get_project_info})}var I=class{_options;constructor(e){this._options=e}list(e){return C(this._options.client,{...e,limit:e.limit&&e.limit>0?e.limit:10})}get(e){if(!e)throw new Error("threadId is required");return B(this._options.client,e)}async start(e){let a=await R(this._options.client);return k(this._options.client,{...e,projectId:a.projectId,buildId:e.buildId||this._options.buildId,timezone:e.timezone||this._options.defaultTimezone})}getEvents(e,a){return l(this._options.client,e,a)}sendMessage(e){return O(this._options.client,{...e,timezone:e.timezone||this._options.defaultTimezone})}cancelAgentMessage(e){return v(this._options.client,e)}subscribeEvents(e,a){return E(this._options.client,e,a)}streamMessageEvents(e,a){return T(this._options.client,e,a)}};var U=class{constructor(e){let a=c(e.promptqlBaseUrl)||"https://promptql.ddn.hasura.app";if(!e.serviceAccountToken)throw new Error("serviceAccountToken must not be empty. If you haven't created any service account token yet, check out Hasura docs https://hasura.io/docs/3.0/project-configuration/project-management/service-accounts/#how-to-create-service-account");let _=a.endsWith("/v1/graphql")?a:`${a}/playground-v2-hge/v1/graphql`;this._fetchToken=b({promptqlGraphQLUrl:_,authHost:e.authHost,headers:K(e.serviceAccountToken),fetch:e.fetch});let{client:r,wsClient:i}=P({getAuthToken:this._fetchToken,url:_,fetch:e.fetch,headers:e.headers});this._wsClient=i,this._options={client:r,buildId:e.buildId,defaultTimezone:e.timezone||Intl.DateTimeFormat().resolvedOptions().timeZone},this.thread=new I(this._options),this.project=new m(this._options)}_options;_wsClient;_fetchToken;thread;project;authenticated(){return this._fetchToken().then(()=>!0).catch(()=>!1)}close(){this._wsClient.dispose(),this._options.client.clearStore()}};function oe(t,e){if(!e.length)return[];if(!t.length)return e;let a=t[t.length-1];if(!a)return e;let _=BigInt(a.thread_event_id),r=e.length-1;for(;r>=0;r--){let i=e[r];if(BigInt(i?.thread_event_id)<=_)break}return e.slice(r+1)}function pe(t){return"UserMessage"in t?t.UserMessage:null}function ue(t){return"UserCancel"in t?t.UserCancel:null}function se(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)||!("PlanGenerationStarted"in t.AgentMessage.update.OrchestratorUpdate.update)?null:t.AgentMessage.update.OrchestratorUpdate.update.PlanGenerationStarted}function de(t){let e=S(t);return!e||!("PlanStepGenerated"in e)?null:e.PlanStepGenerated}function ye(t){return"AgentMessage"in t?"content"in t.AgentMessage.update&&"interaction_update"in t.AgentMessage.update.content&&"main_agent"in t.AgentMessage.update.content.interaction_update&&"completed"in t.AgentMessage.update.content.interaction_update.main_agent?{success:!0,message:t.AgentMessage.update.content.interaction_update.main_agent.completed.summary,modified_artifacts:[],generated_at:t.AgentMessage.update.timestamp}:!("OrchestratorUpdate"in t.AgentMessage.update)||!("GeneratedResponse"in t.AgentMessage.update.OrchestratorUpdate.update)?null:t.AgentMessage.update.OrchestratorUpdate.update.GeneratedResponse.response:null}function ce(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("ProcessingStarted"in t.AgentMessage.update.MessageProcessingUpdate.update)?null:t.AgentMessage.update.MessageProcessingUpdate.update.ProcessingStarted}function le(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("InteractionDecision"in t.AgentMessage.update.MessageProcessingUpdate.update)||!("AcceptInteraction"in t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.AcceptInteraction}function be(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("InteractionDecision"in t.AgentMessage.update.MessageProcessingUpdate.update)||!("DeclineInteraction"in t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.DeclineInteraction}function M(t){return!("AgentMessage"in t)||!("PlanningDecisionUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.PlanningDecisionUpdate.update}function me(t){let e=M(t);return!e||!("Started"in e)?null:e.Started}function Ie(t){let e=M(t);return!e||!("Completed"in e)?null:e.Completed}function Me(t){let e=M(t);return!e||!("PlanningRequired"in e)?null:e.PlanningRequired}function Se(t){return!("AgentMessage"in t)||!("StartingOrchestrator"in t.AgentMessage.update)?null:t.AgentMessage.update.StartingOrchestrator}function S(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.OrchestratorUpdate.update}function y(t){let e=S(t);return!e||!("ContextExplorerUpdate"in e)?null:e.ContextExplorerUpdate.update}function ge(t){let e=y(t);return!e||!("Started"in e)?null:e.Started}function Ae(t){let e=y(t);return!e||!("Completed"in e)?null:e.Completed}function g(t){let e=y(t);return!e||!("WikiExplorerUpdate"in e)?null:e.WikiExplorerUpdate.update}function he(t){let e=g(t);return!e||!("Started"in e)?null:e.Started}function xe(t){let e=g(t);return!e||!("Completed"in e)?null:e.Completed}function fe(t){let e=g(t);return!e||!("WikiInfoGenerated"in e)?null:e.WikiInfoGenerated}function A(t){let e=y(t);return!e||!("SchemaTasksGenerationUpdate"in e)?null:e.SchemaTasksGenerationUpdate.update}function Ce(t){let e=A(t);return!e||!("Started"in e)?null:e.Started}function Be(t){let e=A(t);return!e||!("Completed"in e)?null:e.Completed}function ke(t){let e=A(t);return!e||!("TasksGenerated"in e)?null:e.TasksGenerated}function d(t){let e=y(t);return!e||!("SchemaExplorerUpdate"in e)?null:e.SchemaExplorerUpdate.update}function Oe(t){let e=d(t);return!e||!("Started"in e)?null:e.Started}function ve(t){let e=d(t);return!e||!("Completed"in e)?null:e.Completed}function Ee(t){let e=d(t);return!e||!("CodeExecutionComplete"in e)?null:e.CodeExecutionComplete}function Te(t){let e=d(t);return!e||!("CodeOutputAnalyzed"in e)?null:e.CodeOutputAnalyzed}function Pe(t){let e=d(t);return!e||!("GeneratedCode"in e)?null:e.GeneratedCode}function Re(t){let e=d(t);return!e||!("SchemaExplored"in e)?null:e.SchemaExplored}function h(t){let e=S(t);return!e||!("StepUpdate"in e)?null:e.StepUpdate}function Ue(t){let e=h(t);return!e||!("Programmer"in e.update)?null:e.update.Programmer}function we(t){let e=h(t);return!e||!("UiProgrammer"in e.update)?null:e.update.UiProgrammer}function je(t){let e=h(t);return!e||!("SavedProgramRunner"in e.update)?null:e.update.SavedProgramRunner}function Fe(t){if(!("AgentMessage"in t))return null;if("InteractionFinished"in t.AgentMessage.update){let e=t.AgentMessage.update.InteractionFinished.update;return"Completed"in e?{status:"completed",timestamp:e.Completed.completed_at,warnings:e.Completed.warnings}:"Errored"in e?{status:"errored",timestamp:e.Errored.errored_at,reason:typeof e.Errored.error=="string"?e.Errored.error:e.Errored.error.User.message}:"UserCancelled"in e?{status:"user_cancelled",timestamp:e.UserCancelled.cancelled_at}:"AgentDeclined"in e?{status:"agent_declined",timestamp:e.AgentDeclined.declined_at,reason:e.AgentDeclined.reason}:"ServerCancelled"in e?{status:"server_cancelled",timestamp:e.ServerCancelled.cancelled_at}:{status:"unknown"}}if("content"in t.AgentMessage.update&&"interaction_finished"in t.AgentMessage.update.content){let e=t.AgentMessage.update.content.interaction_finished.outcome;return"errored"in e?{status:"errored",reason:e.errored.user_facing_message||e.errored.raw_error,timestamp:t.AgentMessage.update.timestamp,warnings:e.errored.raw_error?[{message:e.errored.raw_error}]:[]}:"server_cancelled"in e?{status:"server_cancelled",timestamp:t.AgentMessage.update.timestamp}:"user_cancelled"in e?{status:"user_cancelled",timestamp:t.AgentMessage.update.timestamp}:"completed"in e?{status:"completed",timestamp:t.AgentMessage.update.timestamp,warnings:e.completed.warnings}:{status:"unknown"}}return null}0&&(module.exports={PromptQLSdk,cancelAgentMessage,createApolloClient,createPromptQLAuthTokenGenerator,diffThreadEvents,getAgentGeneratedResponse,getAgentInteractionDecisionAcceptInteractionEvent,getAgentInteractionDecisionDeclineInteractionEvent,getAgentInteractionFinishedEvent,getAgentMessageProcessingStartedEvent,getAgentOrchestratorContextExplorerCompletedEvent,getAgentOrchestratorContextExplorerStartedEvent,getAgentOrchestratorContextExplorerUpdateEvent,getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent,getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent,getAgentOrchestratorSchemaExplorerCompletedEvent,getAgentOrchestratorSchemaExplorerGeneratedCodeEvent,getAgentOrchestratorSchemaExplorerSchemaExploredEvent,getAgentOrchestratorSchemaExplorerStartedEvent,getAgentOrchestratorSchemaExplorerUpdateEvent,getAgentOrchestratorSchemaTasksGeneratedEvent,getAgentOrchestratorSchemaTasksGenerationCompletedEvent,getAgentOrchestratorSchemaTasksGenerationStartedEvent,getAgentOrchestratorSchemaTasksGenerationUpdateEvent,getAgentOrchestratorStepProgrammerEvent,getAgentOrchestratorStepSavedProgramRunnerEvent,getAgentOrchestratorStepUiProgrammerEvent,getAgentOrchestratorStepUpdateEvent,getAgentOrchestratorUpdateEvent,getAgentOrchestratorWikiExplorerCompletedEvent,getAgentOrchestratorWikiExplorerStartedEvent,getAgentOrchestratorWikiExplorerUpdateEvent,getAgentOrchestratorWikiInfoGeneratedEvent,getAgentPlanGenerationStartedEvent,getAgentPlanStepGeneratedEvent,getAgentPlanningDecisionCompletedEvent,getAgentPlanningDecisionPlanningRequiredEvent,getAgentPlanningDecisionStartedEvent,getAgentPlanningDecisionUpdateEvent,getAgentStartingOrchestratorEvent,getThread,getThreadEvents,getUserCancelEvent,getUserMessageEvent,listThreads,sendThreadMessage,startThread,streamThreadMessageEvents,subscribeThreadEvents,wasInteractionFinished});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{map as H,takeWhile as L}from"rxjs";var x={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CancelAgentMessage"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"messageId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"cancel_agent_message"},arguments:[{kind:"Argument",name:{kind:"Name",value:"threadId"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}},{kind:"Argument",name:{kind:"Name",value:"agentMessageId"},value:{kind:"Variable",name:{kind:"Name",value:"messageId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},A={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"SendThreadMessage"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"uploads"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"UserUploadInput"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"send_thread_message"},arguments:[{kind:"Argument",name:{kind:"Name",value:"threadId"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}},{kind:"Argument",name:{kind:"Name",value:"uploads"},value:{kind:"Variable",name:{kind:"Name",value:"uploads"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},B={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"StartThread"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"projectId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildId"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"roomId"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"uploads"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"UserUploadInput"}}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"visibility"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"start_thread"},arguments:[{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"projectId"},value:{kind:"Variable",name:{kind:"Name",value:"projectId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"buildId"},value:{kind:"Variable",name:{kind:"Name",value:"buildId"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}},{kind:"Argument",name:{kind:"Name",value:"roomId"},value:{kind:"Variable",name:{kind:"Name",value:"roomId"}}},{kind:"Argument",name:{kind:"Name",value:"uploads"},value:{kind:"Variable",name:{kind:"Name",value:"uploads"}}},{kind:"Argument",name:{kind:"Name",value:"visibility"},value:{kind:"Variable",name:{kind:"Name",value:"visibility"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"thread_events"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"thread_event_id"}}]}}]}}]}}]},C={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetProjectInfo"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"get_project_info"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"projectId"}},{kind:"Field",name:{kind:"Name",value:"projectName"}},{kind:"Field",name:{kind:"Name",value:"promptqlConsoleUrl"}}]}}]}}]},k={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreads"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"offset"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_order_by"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"offset"},value:{kind:"Variable",name:{kind:"Name",value:"offset"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},v={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadById"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"uuid"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2_by_pk"},arguments:[{kind:"Argument",name:{kind:"Name",value:"thread_id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},T={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"thread_events_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_events"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_event_id"},value:{kind:"EnumValue",value:"asc"}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ThreadEvent"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ThreadEvent"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"thread_events"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"user_id"}}]}}]},O={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"subscription",name:{kind:"Name",value:"SubscribeThreadEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"thread_events_bool_exp"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_events"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_event_id"},value:{kind:"EnumValue",value:"asc"}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ThreadEvent"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ThreadEvent"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"thread_events"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"user_id"}}]}}]};function d(t){return t=t?t.trim():"",t?t[t.length-1]==="/"?t.slice(0,t.length-1):t:""}function y(t){if(t==null)return null;try{Number.parseInt(t)}catch{throw new Error("invalid threadEventId")}return t}function E(t,e){return t.query({query:k,variables:{...e,limit:e.limit&&e.limit>0?e.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2??[])}function P(t,e){if(!e)throw new Error("threadId is required");return t.query({query:v,variables:{id:e},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2_by_pk)}function R(t,e){if(!e.message.trim())throw new Error("message must not be empty");return t.mutate({mutation:B,variables:e}).then(a=>{if(!a.data?.start_thread)throw new Error(a.error?.message||"Failed to start thread");return a.data.start_thread})}function U(t,e,a){if(!e)throw new Error("threadId is required");let _={thread_id:{_eq:e}};if(a){let r=y(a.fromEventId),n=y(a.toEventId);r&&n?_.thread_event_id={_gte:a.fromEventId,_lte:a.toEventId}:r?_.thread_event_id={_gte:r}:n&&(_.thread_event_id={_lte:n}),a.messageId&&(_._or=j(a.messageId))}return t.query({query:T,variables:{where:_,limit:a?.limit},fetchPolicy:"no-cache"}).then(r=>r.data?.thread_events??[])}function w(t,e){if(!e.threadId)throw new Error("threadId is required");if(!e.message.trim())throw new Error("message must not be empty");return t.mutate({mutation:A,variables:e}).then(a=>{if(!a.data?.send_thread_message)throw new Error(a.error?.message||"Failed to send message to thread");return a.data.send_thread_message})}function F(t,e){if(!e.threadId)throw new Error("threadId is required");if(!e.messageId.trim())throw new Error("messageId is required");return t.mutate({mutation:x,variables:e}).then(a=>{if(!a.data?.cancel_agent_message)throw new Error(a.error?.message||"Failed to cancel thread");return a.data.cancel_agent_message})}function V(t,e,a){return N(t,e,{fromEventId:a})}function W(t,e,a){return N(t,e,a).pipe(L(_=>J(_,a?.skipAnalysis),!0))}function J(t,e){for(let a=t.length-1;a>0;a--){let _=t[a];if(e&&"UserCancel"in _.event_data)return!1;if(!("AgentMessage"in _.event_data))return!0;let r=_.event_data.AgentMessage.update;if("content"in r&&"interaction_finished"in r.content||"InteractionFinished"in r||e&&"OrchestratorUpdate"in r&&"GeneratedResponse"in r.OrchestratorUpdate.update)return!1}return!0}function N(t,e,a){if(!e)throw new Error("threadId is required");let _={thread_id:{_eq:e}};return a&&(y(a.fromEventId)&&(_.thread_event_id={_gte:a.fromEventId}),a.messageId&&(_._or=j(a.messageId))),t.subscribe({query:O,variables:{where:_}}).pipe(H(r=>{if(r.error)throw r.error;return r.data?.thread_events??[]}))}function j(t){return[{event_data:{_contains:{UserMessage:{message_id:t}}}},{event_data:{_contains:{AgentMessage:{message_id:t}}}},{event_data:{_contains:{UserCancel:{message_id:t}}}}]}function q(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="failure"}function z(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="success"&&"token"in t}function G(t){return t!=null&&typeof t=="object"&&("data"in t&&!!t.data&&typeof t.data=="object"&&"enrich_token"in t.data&&!!t.data.enrich_token&&typeof t.data.enrich_token=="object"&&"userDirectoryJWT"in t.data.enrich_token||"errors"in t&&Array.isArray(t.errors))}function m(t){let a=`${d(t.authHost)||"https://auth.pro.hasura.io"}/ddn/promptql/token`,_={token:"",expiry:new Date(0)},r=t.fetch||fetch,n=async()=>{let p=await r(a,{method:"POST",headers:t.headers});switch(p.status){case 200:{let i=await p.json();if(z(i))return i;throw new Error("malformed token response")}case 401:{let i=await p.json();throw q(i)?new Error(i?.error||p.statusText):new Error(p.statusText)}default:{let i=await p.text();throw new Error(i)}}};return async()=>{if(_.expiry.getTime()<=Date.now()-1e3){let p=await n(),i=await $(t.promptqlGraphQLUrl,p.token,t.projectId,r);_.token=i;let u=new Date(p.expiry);if(Number.isNaN(u.getTime())){let f=new Date;f.setHours(1),_.expiry=f}else _.expiry=u}return _.token}}var $=async(t,e,a,_=fetch)=>{let r=await _(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:"mutation EnrichToken($luxJWT: String!, $projectId: uuid) { enrich_token(luxJWT: $luxJWT, projectId: $projectId) { userDirectoryJWT }}",variables:{luxJWT:e,projectId:a},operationName:"EnrichToken"})});switch(r.status){case 200:{let n=await r.json();if(!G(n)||!n.data?.enrich_token?.userDirectoryJWT)throw new Error(`malformed promptql token response: ${JSON.stringify(n)}`);return n.data.enrich_token.userDirectoryJWT}default:{let n=await r.text();throw new Error(n)}}};function Q(t){return{Authorization:`pat ${t}`}}import{ApolloClient as Z,ApolloLink as X,HttpLink as Y,InMemoryCache as ee}from"@apollo/client";import{SetContextLink as te}from"@apollo/client/link/context";import{GraphQLWsLink as ae}from"@apollo/client/link/subscriptions";import{OperationTypeNode as re}from"graphql";import{createClient as _e}from"graphql-ws";var D=t=>{let e=new Y({uri:t.url,fetch:t.fetch,headers:t.headers}),a=async i=>{let u=await t.getAuthToken();return{headers:{...i,Authorization:`Bearer ${u}`}}},_=_e({url:t.url,connectionParams:()=>a(t.headers)}),r=new ae(_),n=new te(({headers:i})=>a(i)),p=X.split(({operationType:i})=>i===re.SUBSCRIPTION,r,n.concat(e));return{client:new Z({link:p,cache:new ee}),wsClient:_}};var c=class{_options;constructor(e){this._options=e}info(){return b(this._options.client)}};function b(t){return t.query({query:C,fetchPolicy:"cache-first"}).then(e=>{if(!e.data?.get_project_info)throw new Error(e.error?.message||"Project not found");return e.data.get_project_info})}var l=class{_options;constructor(e){this._options=e}list(e){return E(this._options.client,{...e,limit:e.limit&&e.limit>0?e.limit:10})}get(e){if(!e)throw new Error("threadId is required");return P(this._options.client,e)}async start(e){let a=await b(this._options.client);return R(this._options.client,{...e,projectId:a.projectId,buildId:e.buildId||this._options.buildId,timezone:e.timezone||this._options.defaultTimezone})}getEvents(e,a){return U(this._options.client,e,a)}sendMessage(e){return w(this._options.client,{...e,timezone:e.timezone||this._options.defaultTimezone})}cancelAgentMessage(e){return F(this._options.client,e)}subscribeEvents(e,a){return V(this._options.client,e,a)}streamMessageEvents(e,a){return W(this._options.client,e,a)}};var K=class{constructor(e){let a=d(e.promptqlBaseUrl)||"https://promptql.ddn.hasura.app";if(!e.serviceAccountToken)throw new Error("serviceAccountToken must not be empty. If you haven't created any service account token yet, check out Hasura docs https://hasura.io/docs/3.0/project-configuration/project-management/service-accounts/#how-to-create-service-account");let _=a.endsWith("/v1/graphql")?a:`${a}/playground-v2-hge/v1/graphql`;this._fetchToken=m({promptqlGraphQLUrl:_,authHost:e.authHost,headers:Q(e.serviceAccountToken),fetch:e.fetch});let{client:r,wsClient:n}=D({getAuthToken:this._fetchToken,url:_,fetch:e.fetch,headers:e.headers});this._wsClient=n,this._options={client:r,buildId:e.buildId,defaultTimezone:e.timezone||Intl.DateTimeFormat().resolvedOptions().timeZone},this.thread=new l(this._options),this.project=new c(this._options)}_options;_wsClient;_fetchToken;thread;project;authenticated(){return this._fetchToken().then(()=>!0).catch(()=>!1)}close(){this._wsClient.dispose(),this._options.client.clearStore()}};function Qe(t,e){if(!e.length)return[];if(!t.length)return e;let a=t[t.length-1];if(!a)return e;let _=BigInt(a.thread_event_id),r=e.length-1;for(;r>=0;r--){let n=e[r];if(BigInt(n?.thread_event_id)<=_)break}return e.slice(r+1)}function De(t){return"UserMessage"in t?t.UserMessage:null}function Ke(t){return"UserCancel"in t?t.UserCancel:null}function He(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)||!("PlanGenerationStarted"in t.AgentMessage.update.OrchestratorUpdate.update)?null:t.AgentMessage.update.OrchestratorUpdate.update.PlanGenerationStarted}function Le(t){let e=M(t);return!e||!("PlanStepGenerated"in e)?null:e.PlanStepGenerated}function Je(t){return"AgentMessage"in t?"content"in t.AgentMessage.update&&"interaction_update"in t.AgentMessage.update.content&&"main_agent"in t.AgentMessage.update.content.interaction_update&&"completed"in t.AgentMessage.update.content.interaction_update.main_agent?{success:!0,message:t.AgentMessage.update.content.interaction_update.main_agent.completed.summary,modified_artifacts:[],generated_at:t.AgentMessage.update.timestamp}:!("OrchestratorUpdate"in t.AgentMessage.update)||!("GeneratedResponse"in t.AgentMessage.update.OrchestratorUpdate.update)?null:t.AgentMessage.update.OrchestratorUpdate.update.GeneratedResponse.response:null}function $e(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("ProcessingStarted"in t.AgentMessage.update.MessageProcessingUpdate.update)?null:t.AgentMessage.update.MessageProcessingUpdate.update.ProcessingStarted}function Ze(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("InteractionDecision"in t.AgentMessage.update.MessageProcessingUpdate.update)||!("AcceptInteraction"in t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.AcceptInteraction}function Xe(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("InteractionDecision"in t.AgentMessage.update.MessageProcessingUpdate.update)||!("DeclineInteraction"in t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.DeclineInteraction}function I(t){return!("AgentMessage"in t)||!("PlanningDecisionUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.PlanningDecisionUpdate.update}function Ye(t){let e=I(t);return!e||!("Started"in e)?null:e.Started}function et(t){let e=I(t);return!e||!("Completed"in e)?null:e.Completed}function tt(t){let e=I(t);return!e||!("PlanningRequired"in e)?null:e.PlanningRequired}function at(t){return!("AgentMessage"in t)||!("StartingOrchestrator"in t.AgentMessage.update)?null:t.AgentMessage.update.StartingOrchestrator}function M(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.OrchestratorUpdate.update}function s(t){let e=M(t);return!e||!("ContextExplorerUpdate"in e)?null:e.ContextExplorerUpdate.update}function rt(t){let e=s(t);return!e||!("Started"in e)?null:e.Started}function _t(t){let e=s(t);return!e||!("Completed"in e)?null:e.Completed}function g(t){let e=s(t);return!e||!("WikiExplorerUpdate"in e)?null:e.WikiExplorerUpdate.update}function nt(t){let e=g(t);return!e||!("Started"in e)?null:e.Started}function it(t){let e=g(t);return!e||!("Completed"in e)?null:e.Completed}function pt(t){let e=g(t);return!e||!("WikiInfoGenerated"in e)?null:e.WikiInfoGenerated}function S(t){let e=s(t);return!e||!("SchemaTasksGenerationUpdate"in e)?null:e.SchemaTasksGenerationUpdate.update}function ot(t){let e=S(t);return!e||!("Started"in e)?null:e.Started}function st(t){let e=S(t);return!e||!("Completed"in e)?null:e.Completed}function ut(t){let e=S(t);return!e||!("TasksGenerated"in e)?null:e.TasksGenerated}function o(t){let e=s(t);return!e||!("SchemaExplorerUpdate"in e)?null:e.SchemaExplorerUpdate.update}function dt(t){let e=o(t);return!e||!("Started"in e)?null:e.Started}function yt(t){let e=o(t);return!e||!("Completed"in e)?null:e.Completed}function ct(t){let e=o(t);return!e||!("CodeExecutionComplete"in e)?null:e.CodeExecutionComplete}function lt(t){let e=o(t);return!e||!("CodeOutputAnalyzed"in e)?null:e.CodeOutputAnalyzed}function mt(t){let e=o(t);return!e||!("GeneratedCode"in e)?null:e.GeneratedCode}function bt(t){let e=o(t);return!e||!("SchemaExplored"in e)?null:e.SchemaExplored}function h(t){let e=M(t);return!e||!("StepUpdate"in e)?null:e.StepUpdate}function It(t){let e=h(t);return!e||!("Programmer"in e.update)?null:e.update.Programmer}function Mt(t){let e=h(t);return!e||!("UiProgrammer"in e.update)?null:e.update.UiProgrammer}function gt(t){let e=h(t);return!e||!("SavedProgramRunner"in e.update)?null:e.update.SavedProgramRunner}function St(t){if(!("AgentMessage"in t))return null;if("InteractionFinished"in t.AgentMessage.update){let e=t.AgentMessage.update.InteractionFinished.update;return"Completed"in e?{status:"completed",timestamp:e.Completed.completed_at,warnings:e.Completed.warnings}:"Errored"in e?{status:"errored",timestamp:e.Errored.errored_at,reason:typeof e.Errored.error=="string"?e.Errored.error:e.Errored.error.User.message}:"UserCancelled"in e?{status:"user_cancelled",timestamp:e.UserCancelled.cancelled_at}:"AgentDeclined"in e?{status:"agent_declined",timestamp:e.AgentDeclined.declined_at,reason:e.AgentDeclined.reason}:"ServerCancelled"in e?{status:"server_cancelled",timestamp:e.ServerCancelled.cancelled_at}:{status:"unknown"}}if("content"in t.AgentMessage.update&&"interaction_finished"in t.AgentMessage.update.content){let e=t.AgentMessage.update.content.interaction_finished.outcome;return"errored"in e?{status:"errored",reason:e.errored.user_facing_message||e.errored.raw_error,timestamp:t.AgentMessage.update.timestamp,warnings:e.errored.raw_error?[{message:e.errored.raw_error}]:[]}:"server_cancelled"in e?{status:"server_cancelled",timestamp:t.AgentMessage.update.timestamp}:"user_cancelled"in e?{status:"user_cancelled",timestamp:t.AgentMessage.update.timestamp}:"completed"in e?{status:"completed",timestamp:t.AgentMessage.update.timestamp,warnings:e.completed.warnings}:{status:"unknown"}}return null}export{K as PromptQLSdk,F as cancelAgentMessage,D as createApolloClient,m as createPromptQLAuthTokenGenerator,Qe as diffThreadEvents,Je as getAgentGeneratedResponse,Ze as getAgentInteractionDecisionAcceptInteractionEvent,Xe as getAgentInteractionDecisionDeclineInteractionEvent,St as getAgentInteractionFinishedEvent,$e as getAgentMessageProcessingStartedEvent,_t as getAgentOrchestratorContextExplorerCompletedEvent,rt as getAgentOrchestratorContextExplorerStartedEvent,s as getAgentOrchestratorContextExplorerUpdateEvent,ct as getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent,lt as getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent,yt as getAgentOrchestratorSchemaExplorerCompletedEvent,mt as getAgentOrchestratorSchemaExplorerGeneratedCodeEvent,bt as getAgentOrchestratorSchemaExplorerSchemaExploredEvent,dt as getAgentOrchestratorSchemaExplorerStartedEvent,o as getAgentOrchestratorSchemaExplorerUpdateEvent,ut as getAgentOrchestratorSchemaTasksGeneratedEvent,st as getAgentOrchestratorSchemaTasksGenerationCompletedEvent,ot as getAgentOrchestratorSchemaTasksGenerationStartedEvent,S as getAgentOrchestratorSchemaTasksGenerationUpdateEvent,It as getAgentOrchestratorStepProgrammerEvent,gt as getAgentOrchestratorStepSavedProgramRunnerEvent,Mt as getAgentOrchestratorStepUiProgrammerEvent,h as getAgentOrchestratorStepUpdateEvent,M as getAgentOrchestratorUpdateEvent,it as getAgentOrchestratorWikiExplorerCompletedEvent,nt as getAgentOrchestratorWikiExplorerStartedEvent,g as getAgentOrchestratorWikiExplorerUpdateEvent,pt as getAgentOrchestratorWikiInfoGeneratedEvent,He as getAgentPlanGenerationStartedEvent,Le as getAgentPlanStepGeneratedEvent,et as getAgentPlanningDecisionCompletedEvent,tt as getAgentPlanningDecisionPlanningRequiredEvent,Ye as getAgentPlanningDecisionStartedEvent,I as getAgentPlanningDecisionUpdateEvent,at as getAgentStartingOrchestratorEvent,P as getThread,U as getThreadEvents,Ke as getUserCancelEvent,De as getUserMessageEvent,E as listThreads,w as sendThreadMessage,R as startThread,W as streamThreadMessageEvents,V as subscribeThreadEvents,J as wasInteractionFinished};
|
|
1
|
+
import{defer as Q,map as J,repeat as L,takeWhile as K}from"rxjs";var f={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CancelAgentMessage"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"messageId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"cancel_agent_message"},arguments:[{kind:"Argument",name:{kind:"Name",value:"threadId"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}},{kind:"Argument",name:{kind:"Name",value:"agentMessageId"},value:{kind:"Variable",name:{kind:"Name",value:"messageId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},C={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"SendThreadMessage"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"uploads"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"UserUploadInput"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"send_thread_message"},arguments:[{kind:"Argument",name:{kind:"Name",value:"threadId"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}},{kind:"Argument",name:{kind:"Name",value:"uploads"},value:{kind:"Variable",name:{kind:"Name",value:"uploads"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},B={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"StartThread"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"projectId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildId"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"roomId"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"uploads"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"UserUploadInput"}}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"visibility"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"start_thread"},arguments:[{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"projectId"},value:{kind:"Variable",name:{kind:"Name",value:"projectId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"buildId"},value:{kind:"Variable",name:{kind:"Name",value:"buildId"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}},{kind:"Argument",name:{kind:"Name",value:"roomId"},value:{kind:"Variable",name:{kind:"Name",value:"roomId"}}},{kind:"Argument",name:{kind:"Name",value:"uploads"},value:{kind:"Variable",name:{kind:"Name",value:"uploads"}}},{kind:"Argument",name:{kind:"Name",value:"visibility"},value:{kind:"Variable",name:{kind:"Name",value:"visibility"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"thread_events"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"thread_event_id"}}]}}]}}]}}]},k={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetProjectInfo"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"get_project_info"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"projectId"}},{kind:"Field",name:{kind:"Name",value:"projectName"}},{kind:"Field",name:{kind:"Name",value:"promptqlConsoleUrl"}}]}}]}}]},O={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreads"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"offset"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_order_by"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"offset"},value:{kind:"Variable",name:{kind:"Name",value:"offset"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},v={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadById"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"uuid"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2_by_pk"},arguments:[{kind:"Argument",name:{kind:"Name",value:"thread_id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},E={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"thread_events_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"ordering"}},type:{kind:"NamedType",name:{kind:"Name",value:"order_by"}},defaultValue:{kind:"EnumValue",value:"asc"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_events"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_event_id"},value:{kind:"Variable",name:{kind:"Name",value:"ordering"}}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ThreadEvent"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ThreadEvent"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"thread_events"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"user_id"}}]}}]},T={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"subscription",name:{kind:"Name",value:"SubscribeThreadEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"thread_events_bool_exp"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_events"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_event_id"},value:{kind:"EnumValue",value:"asc"}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ThreadEvent"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ThreadEvent"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"thread_events"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"user_id"}}]}}]};function d(t){return t=t?t.trim():"",t?t[t.length-1]==="/"?t.slice(0,t.length-1):t:""}function l(t){if(t==null)return null;try{Number.parseInt(t)}catch{throw new Error("invalid threadEventId")}return t}function P(t,e){return t.query({query:O,variables:{...e,limit:e.limit&&e.limit>0?e.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2??[])}function R(t,e){if(!e)throw new Error("threadId is required");return t.query({query:v,variables:{id:e},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2_by_pk)}function U(t,e){if(!e.message.trim())throw new Error("message must not be empty");return t.mutate({mutation:B,variables:e}).then(a=>{if(!a.data?.start_thread)throw new Error(a.error?.message||"Failed to start thread");return a.data.start_thread})}function b(t,e,a){if(!e)throw new Error("threadId is required");let r={thread_id:{_eq:e}};return a&&(a.eventId&&(r.thread_event_id=a.eventId),a.messageId&&(r._or=$(a.messageId))),t.query({query:E,variables:{where:r,limit:a?.limit,ordering:a?.ordering||"asc"},fetchPolicy:"no-cache"}).then(_=>_.data?.thread_events??[])}function w(t,e){if(!e.threadId)throw new Error("threadId is required");if(!e.message.trim())throw new Error("message must not be empty");return t.mutate({mutation:C,variables:e}).then(a=>{if(!a.data?.send_thread_message)throw new Error(a.error?.message||"Failed to send message to thread");return a.data.send_thread_message})}function j(t,e){if(!e.threadId)throw new Error("threadId is required");if(!e.messageId.trim())throw new Error("messageId is required");return t.mutate({mutation:f,variables:e}).then(a=>{if(!a.data?.cancel_agent_message)throw new Error(a.error?.message||"Failed to cancel thread");return a.data.cancel_agent_message})}function F(t,e,a){if(!e)throw new Error("threadId is required");l(a);let r={thread_id:{_eq:e}};return a&&(r.thread_event_id={_gte:a}),t.subscribe({query:T,variables:{where:r}}).pipe(J(_=>{if(_.error)throw _.error;return _.data?.thread_events??[]}))}function W(t,e,a){if(!e)throw new Error("threadId is required");let r,_=l(a?.fromEventId),i={eventId:a?.fromEventId?{_gte:_}:void 0,messageId:a?.messageId},o=a?.pollingInterval&&a?.pollingInterval>0?a.pollingInterval:5;return Q(async()=>{let n=r?{messageId:a?.messageId,eventId:{_gt:r}}:i,p=await b(t,e,n);return p.length>0&&(r=p[p.length-1]?.thread_event_id),p}).pipe(L({count:a?.timeout&&a.timeout>0?Math.ceil(a.timeout/o):void 0,delay:o*1e3}),K(n=>H(n,a?.skipAnalysis),!0))}function H(t,e){for(let a=t.length-1;a>0;a--){let r=t[a];if(e&&"UserCancel"in r.event_data)return!1;if(!("AgentMessage"in r.event_data))return!0;let _=r.event_data.AgentMessage.update;if("content"in _&&"interaction_finished"in _.content||"InteractionFinished"in _||e&&"OrchestratorUpdate"in _&&"GeneratedResponse"in _.OrchestratorUpdate.update)return!1}return!0}function $(t){return[{event_data:{_contains:{UserMessage:{message_id:t}}}},{event_data:{_contains:{AgentMessage:{message_id:t}}}},{event_data:{_contains:{UserCancel:{message_id:t}}}}]}function V(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="failure"}function N(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="success"&&"token"in t}function z(t){return t!=null&&typeof t=="object"&&("data"in t&&!!t.data&&typeof t.data=="object"&&"enrich_token"in t.data&&!!t.data.enrich_token&&typeof t.data.enrich_token=="object"&&"userDirectoryJWT"in t.data.enrich_token||"errors"in t&&Array.isArray(t.errors))}function m(t){let a=`${d(t.authHost)||"https://auth.pro.hasura.io"}/ddn/promptql/token`,r={token:"",expiry:new Date(0)},_=t.fetch||fetch,i=async()=>{let o=await _(a,{method:"POST",headers:t.headers});switch(o.status){case 200:{let n=await o.json();if(N(n))return n;throw new Error("malformed token response")}case 401:{let n=await o.json();throw V(n)?new Error(n?.error||o.statusText):new Error(o.statusText)}default:{let n=await o.text();throw new Error(n)}}};return async()=>{if(r.expiry.getTime()<=Date.now()-1e3){let o=await i(),n=await Z(t.promptqlGraphQLUrl,o.token,t.projectId,_);r.token=n;let p=new Date(o.expiry);if(Number.isNaN(p.getTime())){let x=new Date;x.setHours(1),r.expiry=x}else r.expiry=p}return r.token}}var Z=async(t,e,a,r=fetch)=>{let _=await r(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:"mutation EnrichToken($luxJWT: String!, $projectId: uuid) { enrich_token(luxJWT: $luxJWT, projectId: $projectId) { userDirectoryJWT }}",variables:{luxJWT:e,projectId:a},operationName:"EnrichToken"})});switch(_.status){case 200:{let i=await _.json();if(!z(i)||!i.data?.enrich_token?.userDirectoryJWT)throw new Error(`malformed promptql token response: ${JSON.stringify(i)}`);return i.data.enrich_token.userDirectoryJWT}default:{let i=await _.text();throw new Error(i)}}};function q(t){return{Authorization:`pat ${t}`}}import{ApolloClient as X,ApolloLink as Y,HttpLink as ee,InMemoryCache as te}from"@apollo/client";import{SetContextLink as ae}from"@apollo/client/link/context";import{GraphQLWsLink as re}from"@apollo/client/link/subscriptions";import{OperationTypeNode as _e}from"graphql";import{createClient as ne}from"graphql-ws";var G=t=>{let e=new ee({uri:t.url,fetch:t.fetch,headers:t.headers}),a=async n=>{let p=await t.getAuthToken();return{headers:{...n,Authorization:`Bearer ${p}`}}},r=ne({url:t.url,connectionParams:()=>a(t.headers),lazy:!0}),_=new re(r),i=new ae(({headers:n})=>a(n)),o=Y.split(({operationType:n})=>n===_e.SUBSCRIPTION,_,i.concat(e));return{client:new X({link:o,cache:new te}),wsClient:r}};var y=class{_options;constructor(e){this._options=e}info(){return I(this._options.client)}};function I(t){return t.query({query:k,fetchPolicy:"cache-first"}).then(e=>{if(!e.data?.get_project_info)throw new Error(e.error?.message||"Project not found");return e.data.get_project_info})}var c=class{_options;constructor(e){this._options=e}list(e){return P(this._options.client,{...e,limit:e.limit&&e.limit>0?e.limit:10})}get(e){if(!e)throw new Error("threadId is required");return R(this._options.client,e)}async start(e){let a=await I(this._options.client);return U(this._options.client,{...e,projectId:a.projectId,buildId:e.buildId||this._options.buildId,timezone:e.timezone||this._options.defaultTimezone})}getEvents(e,a){return b(this._options.client,e,a)}sendMessage(e){return w(this._options.client,{...e,timezone:e.timezone||this._options.defaultTimezone})}cancelAgentMessage(e){return j(this._options.client,e)}subscribeEvents(e,a){return F(this._options.client,e,a)}streamMessageEvents(e,a){return W(this._options.client,e,a)}};var D=class{constructor(e){let a=d(e.promptqlBaseUrl)||"https://promptql.ddn.hasura.app";if(!e.serviceAccountToken)throw new Error("serviceAccountToken must not be empty. If you haven't created any service account token yet, check out Hasura docs https://hasura.io/docs/3.0/project-configuration/project-management/service-accounts/#how-to-create-service-account");let r=a.endsWith("/v1/graphql")?a:`${a}/playground-v2-hge/v1/graphql`;this._fetchToken=m({promptqlGraphQLUrl:r,authHost:e.authHost,headers:q(e.serviceAccountToken),fetch:e.fetch});let{client:_,wsClient:i}=G({getAuthToken:this._fetchToken,url:r,fetch:e.fetch,headers:e.headers});this._wsClient=i,this._options={client:_,buildId:e.buildId,defaultTimezone:e.timezone||Intl.DateTimeFormat().resolvedOptions().timeZone},this.thread=new c(this._options),this.project=new y(this._options)}_options;_wsClient;_fetchToken;thread;project;authenticated(){return this._fetchToken().then(()=>!0).catch(()=>!1)}close(){this._wsClient.dispose(),this._options.client.clearStore()}};function Qe(t,e){if(!e.length)return[];if(!t.length)return e;let a=t[t.length-1];if(!a)return e;let r=BigInt(a.thread_event_id),_=e.length-1;for(;_>=0;_--){let i=e[_];if(BigInt(i?.thread_event_id)<=r)break}return e.slice(_+1)}function Je(t){return"UserMessage"in t?t.UserMessage:null}function Le(t){return"UserCancel"in t?t.UserCancel:null}function Ke(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)||!("PlanGenerationStarted"in t.AgentMessage.update.OrchestratorUpdate.update)?null:t.AgentMessage.update.OrchestratorUpdate.update.PlanGenerationStarted}function He(t){let e=S(t);return!e||!("PlanStepGenerated"in e)?null:e.PlanStepGenerated}function $e(t){return"AgentMessage"in t?"content"in t.AgentMessage.update&&"interaction_update"in t.AgentMessage.update.content&&"main_agent"in t.AgentMessage.update.content.interaction_update&&"completed"in t.AgentMessage.update.content.interaction_update.main_agent?{success:!0,message:t.AgentMessage.update.content.interaction_update.main_agent.completed.summary,modified_artifacts:[],generated_at:t.AgentMessage.update.timestamp}:!("OrchestratorUpdate"in t.AgentMessage.update)||!("GeneratedResponse"in t.AgentMessage.update.OrchestratorUpdate.update)?null:t.AgentMessage.update.OrchestratorUpdate.update.GeneratedResponse.response:null}function Ze(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("ProcessingStarted"in t.AgentMessage.update.MessageProcessingUpdate.update)?null:t.AgentMessage.update.MessageProcessingUpdate.update.ProcessingStarted}function Xe(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("InteractionDecision"in t.AgentMessage.update.MessageProcessingUpdate.update)||!("AcceptInteraction"in t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.AcceptInteraction}function Ye(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("InteractionDecision"in t.AgentMessage.update.MessageProcessingUpdate.update)||!("DeclineInteraction"in t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.DeclineInteraction}function M(t){return!("AgentMessage"in t)||!("PlanningDecisionUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.PlanningDecisionUpdate.update}function et(t){let e=M(t);return!e||!("Started"in e)?null:e.Started}function tt(t){let e=M(t);return!e||!("Completed"in e)?null:e.Completed}function at(t){let e=M(t);return!e||!("PlanningRequired"in e)?null:e.PlanningRequired}function rt(t){return!("AgentMessage"in t)||!("StartingOrchestrator"in t.AgentMessage.update)?null:t.AgentMessage.update.StartingOrchestrator}function S(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.OrchestratorUpdate.update}function s(t){let e=S(t);return!e||!("ContextExplorerUpdate"in e)?null:e.ContextExplorerUpdate.update}function _t(t){let e=s(t);return!e||!("Started"in e)?null:e.Started}function nt(t){let e=s(t);return!e||!("Completed"in e)?null:e.Completed}function g(t){let e=s(t);return!e||!("WikiExplorerUpdate"in e)?null:e.WikiExplorerUpdate.update}function it(t){let e=g(t);return!e||!("Started"in e)?null:e.Started}function ot(t){let e=g(t);return!e||!("Completed"in e)?null:e.Completed}function pt(t){let e=g(t);return!e||!("WikiInfoGenerated"in e)?null:e.WikiInfoGenerated}function A(t){let e=s(t);return!e||!("SchemaTasksGenerationUpdate"in e)?null:e.SchemaTasksGenerationUpdate.update}function ut(t){let e=A(t);return!e||!("Started"in e)?null:e.Started}function st(t){let e=A(t);return!e||!("Completed"in e)?null:e.Completed}function dt(t){let e=A(t);return!e||!("TasksGenerated"in e)?null:e.TasksGenerated}function u(t){let e=s(t);return!e||!("SchemaExplorerUpdate"in e)?null:e.SchemaExplorerUpdate.update}function yt(t){let e=u(t);return!e||!("Started"in e)?null:e.Started}function ct(t){let e=u(t);return!e||!("Completed"in e)?null:e.Completed}function lt(t){let e=u(t);return!e||!("CodeExecutionComplete"in e)?null:e.CodeExecutionComplete}function bt(t){let e=u(t);return!e||!("CodeOutputAnalyzed"in e)?null:e.CodeOutputAnalyzed}function mt(t){let e=u(t);return!e||!("GeneratedCode"in e)?null:e.GeneratedCode}function It(t){let e=u(t);return!e||!("SchemaExplored"in e)?null:e.SchemaExplored}function h(t){let e=S(t);return!e||!("StepUpdate"in e)?null:e.StepUpdate}function Mt(t){let e=h(t);return!e||!("Programmer"in e.update)?null:e.update.Programmer}function St(t){let e=h(t);return!e||!("UiProgrammer"in e.update)?null:e.update.UiProgrammer}function gt(t){let e=h(t);return!e||!("SavedProgramRunner"in e.update)?null:e.update.SavedProgramRunner}function At(t){if(!("AgentMessage"in t))return null;if("InteractionFinished"in t.AgentMessage.update){let e=t.AgentMessage.update.InteractionFinished.update;return"Completed"in e?{status:"completed",timestamp:e.Completed.completed_at,warnings:e.Completed.warnings}:"Errored"in e?{status:"errored",timestamp:e.Errored.errored_at,reason:typeof e.Errored.error=="string"?e.Errored.error:e.Errored.error.User.message}:"UserCancelled"in e?{status:"user_cancelled",timestamp:e.UserCancelled.cancelled_at}:"AgentDeclined"in e?{status:"agent_declined",timestamp:e.AgentDeclined.declined_at,reason:e.AgentDeclined.reason}:"ServerCancelled"in e?{status:"server_cancelled",timestamp:e.ServerCancelled.cancelled_at}:{status:"unknown"}}if("content"in t.AgentMessage.update&&"interaction_finished"in t.AgentMessage.update.content){let e=t.AgentMessage.update.content.interaction_finished.outcome;return"errored"in e?{status:"errored",reason:e.errored.user_facing_message||e.errored.raw_error,timestamp:t.AgentMessage.update.timestamp,warnings:e.errored.raw_error?[{message:e.errored.raw_error}]:[]}:"server_cancelled"in e?{status:"server_cancelled",timestamp:t.AgentMessage.update.timestamp}:"user_cancelled"in e?{status:"user_cancelled",timestamp:t.AgentMessage.update.timestamp}:"completed"in e?{status:"completed",timestamp:t.AgentMessage.update.timestamp,warnings:e.completed.warnings}:{status:"unknown"}}return null}export{D as PromptQLSdk,j as cancelAgentMessage,G as createApolloClient,m as createPromptQLAuthTokenGenerator,Qe as diffThreadEvents,$e as getAgentGeneratedResponse,Xe as getAgentInteractionDecisionAcceptInteractionEvent,Ye as getAgentInteractionDecisionDeclineInteractionEvent,At as getAgentInteractionFinishedEvent,Ze as getAgentMessageProcessingStartedEvent,nt as getAgentOrchestratorContextExplorerCompletedEvent,_t as getAgentOrchestratorContextExplorerStartedEvent,s as getAgentOrchestratorContextExplorerUpdateEvent,lt as getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent,bt as getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent,ct as getAgentOrchestratorSchemaExplorerCompletedEvent,mt as getAgentOrchestratorSchemaExplorerGeneratedCodeEvent,It as getAgentOrchestratorSchemaExplorerSchemaExploredEvent,yt as getAgentOrchestratorSchemaExplorerStartedEvent,u as getAgentOrchestratorSchemaExplorerUpdateEvent,dt as getAgentOrchestratorSchemaTasksGeneratedEvent,st as getAgentOrchestratorSchemaTasksGenerationCompletedEvent,ut as getAgentOrchestratorSchemaTasksGenerationStartedEvent,A as getAgentOrchestratorSchemaTasksGenerationUpdateEvent,Mt as getAgentOrchestratorStepProgrammerEvent,gt as getAgentOrchestratorStepSavedProgramRunnerEvent,St as getAgentOrchestratorStepUiProgrammerEvent,h as getAgentOrchestratorStepUpdateEvent,S as getAgentOrchestratorUpdateEvent,ot as getAgentOrchestratorWikiExplorerCompletedEvent,it as getAgentOrchestratorWikiExplorerStartedEvent,g as getAgentOrchestratorWikiExplorerUpdateEvent,pt as getAgentOrchestratorWikiInfoGeneratedEvent,Ke as getAgentPlanGenerationStartedEvent,He as getAgentPlanStepGeneratedEvent,tt as getAgentPlanningDecisionCompletedEvent,at as getAgentPlanningDecisionPlanningRequiredEvent,et as getAgentPlanningDecisionStartedEvent,M as getAgentPlanningDecisionUpdateEvent,rt as getAgentStartingOrchestratorEvent,R as getThread,b as getThreadEvents,Le as getUserCancelEvent,Je as getUserMessageEvent,P as listThreads,w as sendThreadMessage,U as startThread,W as streamThreadMessageEvents,F as subscribeThreadEvents,H as wasInteractionFinished};
|
package/package.json
CHANGED