@collective-intelligence/ai 0.9.1 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,7 +17,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
17
17
  readonly correlationId: Schema.String;
18
18
  readonly error: Schema.Struct<{
19
19
  readonly details: Schema.optionalKey<Schema.Struct<{
20
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
20
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
21
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
21
22
  }>>;
22
23
  } & {
23
24
  readonly code: Schema.Literal<"conflict">;
@@ -130,7 +131,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
130
131
  readonly correlationId: Schema.String;
131
132
  readonly error: Schema.Struct<{
132
133
  readonly details: Schema.optionalKey<Schema.Struct<{
133
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
134
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
135
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
134
136
  }>>;
135
137
  } & {
136
138
  readonly code: Schema.Literal<"conflict">;
@@ -206,6 +208,7 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
206
208
  }>>, never, never>, never, never>;
207
209
  readonly createConversation: import("effect/http-api/HttpApiClient").Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"createConversation", "POST", "/chat/conversations", never, never, Schema.toCodecJson<Schema.Struct<{
208
210
  readonly agentId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/AgentId">>;
211
+ readonly clientRequestId: Schema.optionalKey<Schema.String>;
209
212
  readonly projectId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/ProjectId">>;
210
213
  readonly title: Schema.optionalKey<Schema.String>;
211
214
  }>>, never, Schema.toCodecJson<Schema.Struct<{
@@ -229,7 +232,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
229
232
  readonly correlationId: Schema.String;
230
233
  readonly error: Schema.Struct<{
231
234
  readonly details: Schema.optionalKey<Schema.Struct<{
232
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
235
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
236
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
233
237
  }>>;
234
238
  } & {
235
239
  readonly code: Schema.Literal<"conflict">;
@@ -309,7 +313,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
309
313
  readonly correlationId: Schema.String;
310
314
  readonly error: Schema.Struct<{
311
315
  readonly details: Schema.optionalKey<Schema.Struct<{
312
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
316
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
317
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
313
318
  }>>;
314
319
  } & {
315
320
  readonly code: Schema.Literal<"conflict">;
@@ -402,7 +407,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
402
407
  readonly correlationId: Schema.String;
403
408
  readonly error: Schema.Struct<{
404
409
  readonly details: Schema.optionalKey<Schema.Struct<{
405
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
410
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
411
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
406
412
  }>>;
407
413
  } & {
408
414
  readonly code: Schema.Literal<"conflict">;
@@ -515,7 +521,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
515
521
  readonly correlationId: Schema.String;
516
522
  readonly error: Schema.Struct<{
517
523
  readonly details: Schema.optionalKey<Schema.Struct<{
518
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
524
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
525
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
519
526
  }>>;
520
527
  } & {
521
528
  readonly code: Schema.Literal<"conflict">;
@@ -612,7 +619,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
612
619
  readonly correlationId: Schema.String;
613
620
  readonly error: Schema.Struct<{
614
621
  readonly details: Schema.optionalKey<Schema.Struct<{
615
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
622
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
623
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
616
624
  }>>;
617
625
  } & {
618
626
  readonly code: Schema.Literal<"conflict">;
@@ -700,7 +708,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
700
708
  readonly correlationId: Schema.String;
701
709
  readonly error: Schema.Struct<{
702
710
  readonly details: Schema.optionalKey<Schema.Struct<{
703
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
711
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
712
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
704
713
  }>>;
705
714
  } & {
706
715
  readonly code: Schema.Literal<"conflict">;
@@ -1009,7 +1018,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
1009
1018
  readonly correlationId: Schema.String;
1010
1019
  readonly error: Schema.Struct<{
1011
1020
  readonly details: Schema.optionalKey<Schema.Struct<{
1012
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
1021
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
1022
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
1013
1023
  }>>;
1014
1024
  } & {
1015
1025
  readonly code: Schema.Literal<"conflict">;
@@ -1112,7 +1122,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
1112
1122
  readonly correlationId: Schema.String;
1113
1123
  readonly error: Schema.Struct<{
1114
1124
  readonly details: Schema.optionalKey<Schema.Struct<{
1115
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
1125
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
1126
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
1116
1127
  }>>;
1117
1128
  } & {
1118
1129
  readonly code: Schema.Literal<"conflict">;
@@ -1202,7 +1213,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
1202
1213
  readonly correlationId: Schema.String;
1203
1214
  readonly error: Schema.Struct<{
1204
1215
  readonly details: Schema.optionalKey<Schema.Struct<{
1205
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
1216
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
1217
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
1206
1218
  }>>;
1207
1219
  } & {
1208
1220
  readonly code: Schema.Literal<"conflict">;
@@ -1307,7 +1319,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
1307
1319
  readonly correlationId: Schema.String;
1308
1320
  readonly error: Schema.Struct<{
1309
1321
  readonly details: Schema.optionalKey<Schema.Struct<{
1310
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
1322
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
1323
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
1311
1324
  }>>;
1312
1325
  } & {
1313
1326
  readonly code: Schema.Literal<"conflict">;
@@ -1420,7 +1433,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
1420
1433
  readonly correlationId: Schema.String;
1421
1434
  readonly error: Schema.Struct<{
1422
1435
  readonly details: Schema.optionalKey<Schema.Struct<{
1423
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
1436
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
1437
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
1424
1438
  }>>;
1425
1439
  } & {
1426
1440
  readonly code: Schema.Literal<"conflict">;
@@ -1503,7 +1517,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
1503
1517
  readonly correlationId: Schema.String;
1504
1518
  readonly error: Schema.Struct<{
1505
1519
  readonly details: Schema.optionalKey<Schema.Struct<{
1506
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
1520
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
1521
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
1507
1522
  }>>;
1508
1523
  } & {
1509
1524
  readonly code: Schema.Literal<"conflict">;
@@ -1616,7 +1631,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
1616
1631
  readonly correlationId: Schema.String;
1617
1632
  readonly error: Schema.Struct<{
1618
1633
  readonly details: Schema.optionalKey<Schema.Struct<{
1619
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
1634
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
1635
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
1620
1636
  }>>;
1621
1637
  } & {
1622
1638
  readonly code: Schema.Literal<"conflict">;
@@ -1720,7 +1736,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
1720
1736
  readonly correlationId: Schema.String;
1721
1737
  readonly error: Schema.Struct<{
1722
1738
  readonly details: Schema.optionalKey<Schema.Struct<{
1723
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
1739
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
1740
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
1724
1741
  }>>;
1725
1742
  } & {
1726
1743
  readonly code: Schema.Literal<"conflict">;
@@ -1800,7 +1817,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
1800
1817
  readonly correlationId: Schema.String;
1801
1818
  readonly error: Schema.Struct<{
1802
1819
  readonly details: Schema.optionalKey<Schema.Struct<{
1803
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
1820
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
1821
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
1804
1822
  }>>;
1805
1823
  } & {
1806
1824
  readonly code: Schema.Literal<"conflict">;
@@ -1886,12 +1904,14 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
1886
1904
  readonly role: Schema.Literals<readonly ["system", "user", "assistant"]>;
1887
1905
  }>;
1888
1906
  readonly messageId: Schema.optionalKey<Schema.String>;
1907
+ readonly steering: Schema.optionalKey<Schema.Literals<readonly ["steer", "reject"]>>;
1889
1908
  readonly trigger: Schema.Literals<readonly ["submit-message", "regenerate-message"]>;
1890
1909
  }>>, never, Schema.toCodecJson<Schema.String>, Schema.toCodecJson<Schema.Struct<{
1891
1910
  readonly correlationId: Schema.String;
1892
1911
  readonly error: Schema.Struct<{
1893
1912
  readonly details: Schema.optionalKey<Schema.Struct<{
1894
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
1913
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
1914
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
1895
1915
  }>>;
1896
1916
  } & {
1897
1917
  readonly code: Schema.Literal<"conflict">;
@@ -1991,7 +2011,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
1991
2011
  readonly correlationId: Schema.String;
1992
2012
  readonly error: Schema.Struct<{
1993
2013
  readonly details: Schema.optionalKey<Schema.Struct<{
1994
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
2014
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
2015
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
1995
2016
  }>>;
1996
2017
  } & {
1997
2018
  readonly code: Schema.Literal<"conflict">;
@@ -2071,7 +2092,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
2071
2092
  readonly correlationId: Schema.String;
2072
2093
  readonly error: Schema.Struct<{
2073
2094
  readonly details: Schema.optionalKey<Schema.Struct<{
2074
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
2095
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
2096
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
2075
2097
  }>>;
2076
2098
  } & {
2077
2099
  readonly code: Schema.Literal<"conflict">;
@@ -2172,7 +2194,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
2172
2194
  readonly correlationId: Schema.String;
2173
2195
  readonly error: Schema.Struct<{
2174
2196
  readonly details: Schema.optionalKey<Schema.Struct<{
2175
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
2197
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
2198
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
2176
2199
  }>>;
2177
2200
  } & {
2178
2201
  readonly code: Schema.Literal<"conflict">;
@@ -2264,7 +2287,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
2264
2287
  readonly correlationId: Schema.String;
2265
2288
  readonly error: Schema.Struct<{
2266
2289
  readonly details: Schema.optionalKey<Schema.Struct<{
2267
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
2290
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
2291
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
2268
2292
  }>>;
2269
2293
  } & {
2270
2294
  readonly code: Schema.Literal<"conflict">;
@@ -2347,7 +2371,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
2347
2371
  readonly correlationId: Schema.String;
2348
2372
  readonly error: Schema.Struct<{
2349
2373
  readonly details: Schema.optionalKey<Schema.Struct<{
2350
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
2374
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
2375
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
2351
2376
  }>>;
2352
2377
  } & {
2353
2378
  readonly code: Schema.Literal<"conflict">;
@@ -2433,7 +2458,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
2433
2458
  readonly correlationId: Schema.String;
2434
2459
  readonly error: Schema.Struct<{
2435
2460
  readonly details: Schema.optionalKey<Schema.Struct<{
2436
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
2461
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
2462
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
2437
2463
  }>>;
2438
2464
  } & {
2439
2465
  readonly code: Schema.Literal<"conflict">;
@@ -2527,7 +2553,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
2527
2553
  readonly correlationId: Schema.String;
2528
2554
  readonly error: Schema.Struct<{
2529
2555
  readonly details: Schema.optionalKey<Schema.Struct<{
2530
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
2556
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
2557
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
2531
2558
  }>>;
2532
2559
  } & {
2533
2560
  readonly code: Schema.Literal<"conflict">;
@@ -2616,7 +2643,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
2616
2643
  readonly correlationId: Schema.String;
2617
2644
  readonly error: Schema.Struct<{
2618
2645
  readonly details: Schema.optionalKey<Schema.Struct<{
2619
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
2646
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
2647
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
2620
2648
  }>>;
2621
2649
  } & {
2622
2650
  readonly code: Schema.Literal<"conflict">;
@@ -2704,7 +2732,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
2704
2732
  readonly correlationId: Schema.String;
2705
2733
  readonly error: Schema.Struct<{
2706
2734
  readonly details: Schema.optionalKey<Schema.Struct<{
2707
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
2735
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
2736
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
2708
2737
  }>>;
2709
2738
  } & {
2710
2739
  readonly code: Schema.Literal<"conflict">;
@@ -2795,7 +2824,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
2795
2824
  readonly correlationId: Schema.String;
2796
2825
  readonly error: Schema.Struct<{
2797
2826
  readonly details: Schema.optionalKey<Schema.Struct<{
2798
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
2827
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
2828
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
2799
2829
  }>>;
2800
2830
  } & {
2801
2831
  readonly code: Schema.Literal<"conflict">;
@@ -2885,7 +2915,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
2885
2915
  readonly correlationId: Schema.String;
2886
2916
  readonly error: Schema.Struct<{
2887
2917
  readonly details: Schema.optionalKey<Schema.Struct<{
2888
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
2918
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
2919
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
2889
2920
  }>>;
2890
2921
  } & {
2891
2922
  readonly code: Schema.Literal<"conflict">;
@@ -2973,7 +3004,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
2973
3004
  readonly correlationId: Schema.String;
2974
3005
  readonly error: Schema.Struct<{
2975
3006
  readonly details: Schema.optionalKey<Schema.Struct<{
2976
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
3007
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
3008
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
2977
3009
  }>>;
2978
3010
  } & {
2979
3011
  readonly code: Schema.Literal<"conflict">;
@@ -3062,7 +3094,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
3062
3094
  readonly correlationId: Schema.String;
3063
3095
  readonly error: Schema.Struct<{
3064
3096
  readonly details: Schema.optionalKey<Schema.Struct<{
3065
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
3097
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
3098
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
3066
3099
  }>>;
3067
3100
  } & {
3068
3101
  readonly code: Schema.Literal<"conflict">;
@@ -3150,7 +3183,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
3150
3183
  readonly correlationId: Schema.String;
3151
3184
  readonly error: Schema.Struct<{
3152
3185
  readonly details: Schema.optionalKey<Schema.Struct<{
3153
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
3186
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
3187
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
3154
3188
  }>>;
3155
3189
  } & {
3156
3190
  readonly code: Schema.Literal<"conflict">;
@@ -3230,7 +3264,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
3230
3264
  readonly correlationId: Schema.String;
3231
3265
  readonly error: Schema.Struct<{
3232
3266
  readonly details: Schema.optionalKey<Schema.Struct<{
3233
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
3267
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
3268
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
3234
3269
  }>>;
3235
3270
  } & {
3236
3271
  readonly code: Schema.Literal<"conflict">;
@@ -3311,7 +3346,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
3311
3346
  readonly correlationId: Schema.String;
3312
3347
  readonly error: Schema.Struct<{
3313
3348
  readonly details: Schema.optionalKey<Schema.Struct<{
3314
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
3349
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
3350
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
3315
3351
  }>>;
3316
3352
  } & {
3317
3353
  readonly code: Schema.Literal<"conflict">;
@@ -3395,7 +3431,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
3395
3431
  readonly correlationId: Schema.String;
3396
3432
  readonly error: Schema.Struct<{
3397
3433
  readonly details: Schema.optionalKey<Schema.Struct<{
3398
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
3434
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
3435
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
3399
3436
  }>>;
3400
3437
  } & {
3401
3438
  readonly code: Schema.Literal<"conflict">;
@@ -3487,7 +3524,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
3487
3524
  readonly correlationId: Schema.String;
3488
3525
  readonly error: Schema.Struct<{
3489
3526
  readonly details: Schema.optionalKey<Schema.Struct<{
3490
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
3527
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
3528
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
3491
3529
  }>>;
3492
3530
  } & {
3493
3531
  readonly code: Schema.Literal<"conflict">;
@@ -3573,7 +3611,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
3573
3611
  readonly correlationId: Schema.String;
3574
3612
  readonly error: Schema.Struct<{
3575
3613
  readonly details: Schema.optionalKey<Schema.Struct<{
3576
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
3614
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
3615
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
3577
3616
  }>>;
3578
3617
  } & {
3579
3618
  readonly code: Schema.Literal<"conflict">;
@@ -3662,7 +3701,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
3662
3701
  readonly correlationId: Schema.String;
3663
3702
  readonly error: Schema.Struct<{
3664
3703
  readonly details: Schema.optionalKey<Schema.Struct<{
3665
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
3704
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
3705
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
3666
3706
  }>>;
3667
3707
  } & {
3668
3708
  readonly code: Schema.Literal<"conflict">;
@@ -3752,7 +3792,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
3752
3792
  readonly correlationId: Schema.String;
3753
3793
  readonly error: Schema.Struct<{
3754
3794
  readonly details: Schema.optionalKey<Schema.Struct<{
3755
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
3795
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
3796
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
3756
3797
  }>>;
3757
3798
  } & {
3758
3799
  readonly code: Schema.Literal<"conflict">;
@@ -3840,7 +3881,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
3840
3881
  readonly correlationId: Schema.String;
3841
3882
  readonly error: Schema.Struct<{
3842
3883
  readonly details: Schema.optionalKey<Schema.Struct<{
3843
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
3884
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
3885
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
3844
3886
  }>>;
3845
3887
  } & {
3846
3888
  readonly code: Schema.Literal<"conflict">;
@@ -3924,7 +3966,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
3924
3966
  readonly correlationId: Schema.String;
3925
3967
  readonly error: Schema.Struct<{
3926
3968
  readonly details: Schema.optionalKey<Schema.Struct<{
3927
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
3969
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
3970
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
3928
3971
  }>>;
3929
3972
  } & {
3930
3973
  readonly code: Schema.Literal<"conflict">;
@@ -4005,7 +4048,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
4005
4048
  readonly correlationId: Schema.String;
4006
4049
  readonly error: Schema.Struct<{
4007
4050
  readonly details: Schema.optionalKey<Schema.Struct<{
4008
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
4051
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
4052
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
4009
4053
  }>>;
4010
4054
  } & {
4011
4055
  readonly code: Schema.Literal<"conflict">;
@@ -4087,7 +4131,8 @@ declare const ChatSurface_base: Context.ServiceClass<ChatSurface, "@collective-i
4087
4131
  readonly correlationId: Schema.String;
4088
4132
  readonly error: Schema.Struct<{
4089
4133
  readonly details: Schema.optionalKey<Schema.Struct<{
4090
- readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent"]>;
4134
+ readonly reason: Schema.Literals<readonly ["turn_ended", "intent_turn_busy", "intent_turn_agent", "conversation_busy"]>;
4135
+ readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">>;
4091
4136
  }>>;
4092
4137
  } & {
4093
4138
  readonly code: Schema.Literal<"conflict">;
package/dist/headless.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{useIntentsScope2,useOptionalIntentsScope2,IntentsProvider2,IntentsRegistryScope2,useRegisterPiece2,usePieces2,useIntentResult2,chatBlockedKinds2,chatSurfaceLayer,callChatSurface,retryRead,chatFeatureFlags2,createBrowserFilePort2,openRunStates2,isOpenRunState2,trailBufferSize2,createTrailBuffer2,turnTrail2,useChatSession2,useCiChat2,ChatSessionProvider2,useIntentDispatch2,useIntents2,useLaunch2,useHasLaunchTarget2,submitChatLaunch2,useChatLaunchTarget2,ContextTrailProvider2,useTrailBuffer2,useTrailEntries2,useContextTrailEntries2,useRecordPageVisit2,useTrailMetadata2,useTrailEvent2,usePageJsonLd2}from"./domain-tg4azwc2.js";import"./domain-8rwbw2ah.js";import"./domain-5fpd4fte.js";import"./domain-50vzrrp9.js";import"./domain-54qeg701.js";var noVersion=Number.NEGATIVE_INFINITY;var accessCheckTargetLimit=200;var focusCount=0;var focusRechecks=new Set;var countingFocus=false;var onFocus=()=>{focusCount+=1;for(const recheck of focusRechecks){recheck()}};var countFocus=()=>{if(!countingFocus){countingFocus=true;window.addEventListener("focus",onFocus)}};var accessKey=(target)=>{switch(target.kind){case"capability":{return JSON.stringify([target.kind,target.code,target.mode])}case"entity_schema":{return JSON.stringify([target.kind,target.fqn,target.access])}case"dataset":{return JSON.stringify([target.kind,target.id])}default:{return JSON.stringify([target.kind,target.fqn])}}};var createAccessStore=(port)=>{let version=noVersion;const entries=new Map;const watchers=new Map;const askedAt=new Map;const inFlight=new Set;const queued=new Set;const askAgain=new Set;const batches=new Set;const notify=(keys)=>{for(const key of keys){for(const listener of watchers.get(key)?.listeners??[]){listener()}}};const outdated=(key)=>(entries.get(key)?.version??version)<version&&(askedAt.get(key)??noVersion)<version;const staleKeys=()=>[...watchers.keys()].filter(outdated);const needsAnswer=(key)=>{const entry=entries.get(key);return entry===undefined||entry.focus<focusCount||outdated(key)};const enqueue=(keys)=>{const idle=queued.size===0;for(const key of keys){if(!inFlight.has(key)){queued.add(key)}}return idle&&queued.size>0};const check=async(keys)=>{const targets=keys.flatMap((key)=>watchers.get(key)?.target??[]);const batch=new AbortController;const focus=focusCount;batches.add(batch);for(const key of keys){inFlight.add(key);askedAt.set(key,version)}const result=await port.check(targets,{signal:batch.signal}).catch(()=>null);batches.delete(batch);if(batch.signal.aborted){return[]}const response=result?.ok===true?result.value:undefined;for(const[index,key]of keys.entries()){inFlight.delete(key);const answer=response?.answers[index];entries.set(key,response===undefined||answer===undefined?{answer:"denied",focus,version:noVersion}:{answer,focus,version:response.accessVersion})}version=Math.max(version,response?.accessVersion??noVersion);notify(keys);const again=keys.filter((key)=>askAgain.delete(key));return[...staleKeys(),...again]};const send=async()=>{const keys=[...queued].filter((key)=>watchers.has(key));queued.clear();const chunks=Array.from({length:Math.ceil(keys.length/accessCheckTargetLimit)},(_,at)=>keys.slice(at*accessCheckTargetLimit,(at+1)*accessCheckTargetLimit));const again=await Promise.all(chunks.map((chunk)=>check(chunk)));if(enqueue(again.flat())){queueMicrotask(()=>{send()})}};const ask=(keys)=>{if(enqueue(keys)){queueMicrotask(()=>{send()})}};const askAll=()=>{for(const key of inFlight){askAgain.add(key)}ask(watchers.keys())};const stop=()=>{focusRechecks.delete(askAll);for(const batch of batches){batch.abort()}batches.clear();inFlight.clear();askAgain.clear()};return{recheck:askAll,visibility:(target)=>entries.get(accessKey(target))?.answer??"loading",watch:(target,onChange)=>{const key=accessKey(target);countFocus();focusRechecks.add(askAll);const watcher=watchers.get(key)??{listeners:new Set,target};watcher.listeners.add(onChange);watchers.set(key,watcher);if(needsAnswer(key)){ask([key])}return()=>{watcher.listeners.delete(onChange);if(watcher.listeners.size===0){watchers.delete(key)}if(watchers.size===0){stop()}}}}};var stores=new WeakMap;var accessStoreFor=(port,cacheScope)=>{const byCaller=stores.get(port)??new Map;stores.set(port,byCaller);const known=byCaller.get(cacheScope);if(known!==undefined){return known}const store=createAccessStore(port);byCaller.set(cacheScope,store);return store};var recheckAccess=(port)=>{for(const store of stores.get(port)?.values()??[]){store.recheck()}};import{useCallback,useMemo,useState,useSyncExternalStore}from"react";var stopNothing=()=>{};var useVisibility=(target)=>{const{access,cacheScope}=useIntentsScope2();const store=useMemo(()=>access===undefined?undefined:accessStoreFor(access,cacheScope),[access,cacheScope]);const[watched,setWatched]=useState(target);if(accessKey(watched)!==accessKey(target)){setWatched(target)}const subscribe=useCallback((onChange)=>store?.watch(watched,onChange)??stopNothing,[store,watched]);const snapshot=useCallback(()=>store?.visibility(watched)??"denied",[store,watched]);return useSyncExternalStore(subscribe,snapshot,snapshot)};var VisibilityGate=({children,fallback,target})=>{const visibility=useVisibility(target);if(visibility==="allowed"){return children}return visibility==="denied"?fallback:null};import{useEffect}from"react";var useReturnedIntentHandle=(returned)=>{const{registry}=useIntentsScope2();const fqn=returned?.fqn;const handle=returned?.handle;useEffect(()=>fqn===undefined||handle===undefined?undefined:registry.adopt({fqn,handle}),[fqn,handle,registry])};import*as Effect from"effect/Effect";var readTrailSwitches=(api,trail)=>Effect.runPromise(retryRead(callChatSurface((client)=>client.chat.getPlaceContext())).pipe(Effect.tap(({contextTrailEnabled})=>Effect.sync(()=>{trail.setRecording(contextTrailEnabled)})),Effect.ignore,Effect.provide(chatSurfaceLayer(api))));export{ChatSessionProvider2 as ChatSessionProvider,ContextTrailProvider2 as ContextTrailProvider,IntentsProvider2 as IntentsProvider,IntentsRegistryScope2 as IntentsRegistryScope,VisibilityGate,chatBlockedKinds2 as chatBlockedKinds,chatFeatureFlags2 as chatFeatureFlags,createBrowserFilePort2 as createBrowserFilePort,createTrailBuffer2 as createTrailBuffer,isOpenRunState2 as isOpenRunState,openRunStates2 as openRunStates,readTrailSwitches,recheckAccess,submitChatLaunch2 as submitChatLaunch,trailBufferSize2 as trailBufferSize,turnTrail2 as turnTrail,useChatLaunchTarget2 as useChatLaunchTarget,useChatSession2 as useChatSession,useCiChat2 as useCiChat,useContextTrailEntries2 as useContextTrailEntries,useHasLaunchTarget2 as useHasLaunchTarget,useIntentDispatch2 as useIntentDispatch,useIntentResult2 as useIntentResult,useIntents2 as useIntents,useIntentsScope2 as useIntentsScope,useLaunch2 as useLaunch,useOptionalIntentsScope2 as useOptionalIntentsScope,usePageJsonLd2 as usePageJsonLd,usePieces2 as usePieces,useRecordPageVisit2 as useRecordPageVisit,useRegisterPiece2 as useRegisterPiece,useReturnedIntentHandle,useTrailBuffer2 as useTrailBuffer,useTrailEntries2 as useTrailEntries,useTrailEvent2 as useTrailEvent,useTrailMetadata2 as useTrailMetadata,useVisibility};
2
+ import{useIntentsScope2,useOptionalIntentsScope2,IntentsProvider2,IntentsRegistryScope2,useRegisterPiece2,usePieces2,useIntentResult2,chatBlockedKinds2,chatSurfaceLayer,callChatSurface,retryRead,chatFeatureFlags2,createBrowserFilePort2,openRunStates2,isOpenRunState2,trailBufferSize2,createTrailBuffer2,turnTrail2,useChatSession2,useCiChat2,ChatSessionProvider2,useIntentDispatch2,useIntents2,useLaunch2,useHasLaunchTarget2,submitChatLaunch2,useChatLaunchTarget2,ContextTrailProvider2,useTrailBuffer2,useTrailEntries2,useContextTrailEntries2,useRecordPageVisit2,useTrailMetadata2,useTrailEvent2,usePageJsonLd2}from"./domain-4fej3j1a.js";import"./domain-6wbbkjz0.js";import"./domain-te8xf29h.js";import"./domain-s8r5t4nq.js";import"./domain-673qdd7n.js";var noVersion=Number.NEGATIVE_INFINITY;var accessCheckTargetLimit=200;var focusCount=0;var focusRechecks=new Set;var countingFocus=false;var onFocus=()=>{focusCount+=1;for(const recheck of focusRechecks){recheck()}};var countFocus=()=>{if(!countingFocus){countingFocus=true;window.addEventListener("focus",onFocus)}};var accessKey=(target)=>{switch(target.kind){case"capability":{return JSON.stringify([target.kind,target.code,target.mode])}case"entity_schema":{return JSON.stringify([target.kind,target.fqn,target.access])}case"dataset":{return JSON.stringify([target.kind,target.id])}default:{return JSON.stringify([target.kind,target.fqn])}}};var createAccessStore=(port)=>{let version=noVersion;const entries=new Map;const watchers=new Map;const askedAt=new Map;const inFlight=new Set;const queued=new Set;const askAgain=new Set;const batches=new Set;const notify=(keys)=>{for(const key of keys){for(const listener of watchers.get(key)?.listeners??[]){listener()}}};const outdated=(key)=>(entries.get(key)?.version??version)<version&&(askedAt.get(key)??noVersion)<version;const staleKeys=()=>[...watchers.keys()].filter(outdated);const needsAnswer=(key)=>{const entry=entries.get(key);return entry===undefined||entry.focus<focusCount||outdated(key)};const enqueue=(keys)=>{const idle=queued.size===0;for(const key of keys){if(!inFlight.has(key)){queued.add(key)}}return idle&&queued.size>0};const check=async(keys)=>{const targets=keys.flatMap((key)=>watchers.get(key)?.target??[]);const batch=new AbortController;const focus=focusCount;batches.add(batch);for(const key of keys){inFlight.add(key);askedAt.set(key,version)}const result=await port.check(targets,{signal:batch.signal}).catch(()=>null);batches.delete(batch);if(batch.signal.aborted){return[]}const response=result?.ok===true?result.value:undefined;for(const[index,key]of keys.entries()){inFlight.delete(key);const answer=response?.answers[index];entries.set(key,response===undefined||answer===undefined?{answer:"denied",focus,version:noVersion}:{answer,focus,version:response.accessVersion})}version=Math.max(version,response?.accessVersion??noVersion);notify(keys);const again=keys.filter((key)=>askAgain.delete(key));return[...staleKeys(),...again]};const send=async()=>{const keys=[...queued].filter((key)=>watchers.has(key));queued.clear();const chunks=Array.from({length:Math.ceil(keys.length/accessCheckTargetLimit)},(_,at)=>keys.slice(at*accessCheckTargetLimit,(at+1)*accessCheckTargetLimit));const again=await Promise.all(chunks.map((chunk)=>check(chunk)));if(enqueue(again.flat())){queueMicrotask(()=>{send()})}};const ask=(keys)=>{if(enqueue(keys)){queueMicrotask(()=>{send()})}};const askAll=()=>{for(const key of inFlight){askAgain.add(key)}ask(watchers.keys())};const stop=()=>{focusRechecks.delete(askAll);for(const batch of batches){batch.abort()}batches.clear();inFlight.clear();askAgain.clear()};return{recheck:askAll,visibility:(target)=>entries.get(accessKey(target))?.answer??"loading",watch:(target,onChange)=>{const key=accessKey(target);countFocus();focusRechecks.add(askAll);const watcher=watchers.get(key)??{listeners:new Set,target};watcher.listeners.add(onChange);watchers.set(key,watcher);if(needsAnswer(key)){ask([key])}return()=>{watcher.listeners.delete(onChange);if(watcher.listeners.size===0){watchers.delete(key)}if(watchers.size===0){stop()}}}}};var stores=new WeakMap;var accessStoreFor=(port,cacheScope)=>{const byCaller=stores.get(port)??new Map;stores.set(port,byCaller);const known=byCaller.get(cacheScope);if(known!==undefined){return known}const store=createAccessStore(port);byCaller.set(cacheScope,store);return store};var recheckAccess=(port)=>{for(const store of stores.get(port)?.values()??[]){store.recheck()}};import{useCallback,useMemo,useState,useSyncExternalStore}from"react";var stopNothing=()=>{};var useVisibility=(target)=>{const{access,cacheScope}=useIntentsScope2();const store=useMemo(()=>access===undefined?undefined:accessStoreFor(access,cacheScope),[access,cacheScope]);const[watched,setWatched]=useState(target);if(accessKey(watched)!==accessKey(target)){setWatched(target)}const subscribe=useCallback((onChange)=>store?.watch(watched,onChange)??stopNothing,[store,watched]);const snapshot=useCallback(()=>store?.visibility(watched)??"denied",[store,watched]);return useSyncExternalStore(subscribe,snapshot,snapshot)};var VisibilityGate=({children,fallback,target})=>{const visibility=useVisibility(target);if(visibility==="allowed"){return children}return visibility==="denied"?fallback:null};import{useEffect}from"react";var useReturnedIntentHandle=(returned)=>{const{registry}=useIntentsScope2();const fqn=returned?.fqn;const handle=returned?.handle;useEffect(()=>fqn===undefined||handle===undefined?undefined:registry.adopt({fqn,handle}),[fqn,handle,registry])};import*as Effect from"effect/Effect";var readTrailSwitches=(api,trail)=>Effect.runPromise(retryRead(callChatSurface((client)=>client.chat.getPlaceContext())).pipe(Effect.tap(({contextTrailEnabled})=>Effect.sync(()=>{trail.setRecording(contextTrailEnabled)})),Effect.ignore,Effect.provide(chatSurfaceLayer(api))));export{ChatSessionProvider2 as ChatSessionProvider,ContextTrailProvider2 as ContextTrailProvider,IntentsProvider2 as IntentsProvider,IntentsRegistryScope2 as IntentsRegistryScope,VisibilityGate,chatBlockedKinds2 as chatBlockedKinds,chatFeatureFlags2 as chatFeatureFlags,createBrowserFilePort2 as createBrowserFilePort,createTrailBuffer2 as createTrailBuffer,isOpenRunState2 as isOpenRunState,openRunStates2 as openRunStates,readTrailSwitches,recheckAccess,submitChatLaunch2 as submitChatLaunch,trailBufferSize2 as trailBufferSize,turnTrail2 as turnTrail,useChatLaunchTarget2 as useChatLaunchTarget,useChatSession2 as useChatSession,useCiChat2 as useCiChat,useContextTrailEntries2 as useContextTrailEntries,useHasLaunchTarget2 as useHasLaunchTarget,useIntentDispatch2 as useIntentDispatch,useIntentResult2 as useIntentResult,useIntents2 as useIntents,useIntentsScope2 as useIntentsScope,useLaunch2 as useLaunch,useOptionalIntentsScope2 as useOptionalIntentsScope,usePageJsonLd2 as usePageJsonLd,usePieces2 as usePieces,useRecordPageVisit2 as useRecordPageVisit,useRegisterPiece2 as useRegisterPiece,useReturnedIntentHandle,useTrailBuffer2 as useTrailBuffer,useTrailEntries2 as useTrailEntries,useTrailEvent2 as useTrailEvent,useTrailMetadata2 as useTrailMetadata,useVisibility};
@@ -1,6 +1,6 @@
1
1
  import * as Effect from "effect/Effect";
2
2
  import * as Stream from "effect/Stream";
3
- import type { ConversationId } from "../api/index.js";
3
+ import type { ChatSendSteering, ConversationId } from "../api/index.js";
4
4
  import type { CiUIMessage } from "../domain/index.js";
5
5
  import type { ChatTransportOptions } from "./chat-transport.js";
6
6
  import { AiFailureError } from "../domain/index.js";
@@ -9,6 +9,13 @@ export type ChatClientTurn = Readonly<{
9
9
  conversationId: ConversationId;
10
10
  /** The user's message, or the assistant message that carries an approval answer or a `ci_ask_user` output. */
11
11
  message: CiUIMessage;
12
+ /**
13
+ * What the send does while another turn of the Conversation runs:
14
+ * `steer` (the default) joins that turn as a Steering Message; `reject`
15
+ * refuses the send with an `AiFailureError` of code `conflict`, reason
16
+ * `conversation_busy` and the `runId` of that turn.
17
+ */
18
+ steering?: ChatSendSteering;
12
19
  }>;
13
20
  /** A chat without React, for server code (Q233). */
14
21
  export type ChatClient = Readonly<{
@@ -20,6 +27,7 @@ export type ChatClient = Readonly<{
20
27
  /**
21
28
  * The chat client of one mount (AC-309): it sends a turn through
22
29
  * {@link createChatTransport} and reads the answer with the AI SDK
23
- * `readUIMessageStream`. An `error` chunk in the answer fails it.
30
+ * `readUIMessageStream`. An `error` chunk in the answer fails it, and so
31
+ * does a `refused_turn` run status: the Agent turn ended before it started.
24
32
  */
25
33
  export declare const createChatClient: (options: ChatTransportOptions) => ChatClient;
@@ -51,7 +51,7 @@ export declare const runForChat: <A>(operation: Effect.Effect<A, Error>) => Prom
51
51
  * `DefaultChatTransport` that posts `POST /chat/:conversationId` with only
52
52
  * the last message and the trigger, and resumes with
53
53
  * `GET /chat/:conversationId/stream` (Q266). The AI SDK chat id is the
54
- * Conversation id. The send body is the chat contract alone: a `body`
55
- * given to the AI SDK send is not sent.
54
+ * Conversation id. The send body is the chat contract alone: of a `body`
55
+ * given to the AI SDK send, only `steering` is sent.
56
56
  */
57
57
  export declare const createChatTransport: (options: ChatTransportOptions) => CiChatTransport;
package/dist/transport.js CHANGED
@@ -1 +1 @@
1
- import{ConversationId2}from"./domain-5fpd4fte.js";import{aiErrorCodes2,AiFailureError2}from"./domain-9wzbv87n.js";import{readUIMessageStream}from"ai";import*as Effect2 from"effect/Effect";import*as Option2 from"effect/Option";import*as Stream from"effect/Stream";import{APICallError,DefaultChatTransport}from"ai";import*as Effect from"effect/Effect";import*as Option from"effect/Option";import*as Schema from"effect/Schema";var invalidRequest=(message)=>new AiFailureError2({code:"invalid_request",message,retryable:false});var decodeConversationId=Schema.decodeUnknownOption(ConversationId2);var conversationIdOf=(chatId)=>Effect.fromOption(decodeConversationId(chatId),()=>invalidRequest(`The chat id "${chatId}" is not a Conversation id.`));var lastMessage=(messages)=>Effect.fromOption(Option.fromUndefinedOr(messages.at(-1)),()=>invalidRequest("A chat send has no message."));var makeResumeEmptySignal=()=>{const listeners=new Set;return{emit:(event)=>{for(const listener of listeners){listener(event)}},subscribe:(listener)=>{listeners.add(listener);return()=>{listeners.delete(listener)}}}};var decodeFailureEnvelope=Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Struct({error:Schema.Struct({code:Schema.Literals(aiErrorCodes2),details:Schema.optionalKey(Schema.Struct({reason:Schema.optionalKey(Schema.String)})),message:Schema.String,retryable:Schema.Boolean})})));var codeOfStatus=(status)=>{switch(status){case 400:case 422:{return"invalid_request"}case 401:{return"unauthenticated"}case 403:{return"forbidden"}case 404:{return"not_found"}case 409:{return"conflict"}case 429:{return"rate_limited"}case 502:case 503:case 504:{return"unavailable"}default:{return"internal"}}};var toAiFailure=(cause)=>{if(cause instanceof AiFailureError2){return cause}if(APICallError.isInstance(cause)){return Option.match(decodeFailureEnvelope(cause.responseBody??""),{onNone:()=>{const code=codeOfStatus(cause.statusCode??500);return new AiFailureError2({code,message:cause.message,retryable:code==="rate_limited"||code==="unavailable"},{cause})},onSome:({error:failure})=>{const error={code:failure.code,message:failure.message,retryable:failure.retryable};const reason=failure.details?.reason;return new AiFailureError2(reason===undefined?error:{...error,reason},{cause})}})}if(cause instanceof TypeError){return new AiFailureError2({code:"unavailable",message:cause.message,retryable:true},{cause})}return new AiFailureError2({code:"internal",message:cause instanceof Error?cause.message:String(cause),retryable:false},{cause})};var sdkFetch=(fetch)=>Object.assign((input,init)=>fetch(input,init),{preconnect:()=>null});var runForChat=(operation)=>Effect.runPromise(operation);var isRequestAbort=(cause)=>cause instanceof Error&&cause.name==="AbortError";var requestFailure=(cause)=>isRequestAbort(cause)?cause:toAiFailure(cause);var createChatTransport=(options)=>{const base=String(options.baseUrl).replace(/\/+$/u,"");const chatUrl=(chatId)=>Effect.map(conversationIdOf(chatId),(id)=>`${base}/chat/${id}`);const resumeEmpty=makeResumeEmptySignal();const init={prepareReconnectToStreamRequest:({id})=>runForChat(Effect.map(chatUrl(id),(url)=>({api:`${url}/stream`}))),prepareSendMessagesRequest:({id,messageId,messages,trigger})=>runForChat(Effect.gen(function*sendRequest(){const body={message:yield*lastMessage(messages),trigger};return{api:yield*chatUrl(id),body:messageId===undefined?body:{...body,messageId}}}))};if(options.fetch!==undefined){init.fetch=sdkFetch(options.fetch)}if(options.headers!==undefined){init.headers=options.headers}const http=new DefaultChatTransport(init);return{onResumeEmpty:resumeEmpty.subscribe,reconnectToStream:(request)=>runForChat(Effect.gen(function*resume(){const stream=yield*Effect.tryPromise({catch:requestFailure,try:()=>http.reconnectToStream(request)});if(stream===null){const conversationId=yield*conversationIdOf(request.chatId);resumeEmpty.emit({conversationId})}return stream})),resumeStreamIsReplay:http.resumeStreamIsReplay,sendMessages:(request)=>runForChat(Effect.tryPromise({catch:requestFailure,try:()=>http.sendMessages(request)}))}};var endedWithoutAnswer=()=>new AiFailureError2({code:"internal",message:"The chat answer ended without a message.",retryable:true});var createChatClient=(options)=>{const transport=createChatTransport(options);const stream=({conversationId,message})=>Stream.unwrap(Effect2.tryPromise({catch:toAiFailure,try:(abortSignal)=>transport.sendMessages({abortSignal,chatId:conversationId,messageId:undefined,messages:[message],trigger:"submit-message"})}).pipe(Effect2.map((chunks)=>Stream.fromAsyncIterable(readUIMessageStream({stream:chunks,terminateOnError:true}),toAiFailure))));return{send:(turn)=>Stream.runLast(stream(turn)).pipe(Effect2.flatMap(Option2.match({onNone:()=>Effect2.fail(endedWithoutAnswer()),onSome:Effect2.succeed}))),stream}};import*as Duration from"effect/Duration";import*as Effect3 from"effect/Effect";import*as Schedule from"effect/Schedule";import*as Stream2 from"effect/Stream";var textChunks=(text)=>[{type:"start"},{id:"text-1",type:"text-start"},...text.split(/(?<=\s)/u).map((delta)=>({delta,id:"text-1",type:"text-delta"})),{id:"text-1",type:"text-end"},{type:"finish"}];var play=(answer,chunkDelayMs)=>{const chunks=Stream2.fromIterable("chunks"in answer?answer.chunks:textChunks(answer.text));return Stream2.toReadableStream(chunkDelayMs>0?chunks.pipe(Stream2.schedule(Schedule.spaced(Duration.millis(chunkDelayMs)))):chunks)};var createSimulatedChatTransport=(script)=>{const chunkDelayMs=script.chunkDelayMs??0;const resumeEmpty=makeResumeEmptySignal();return{onResumeEmpty:resumeEmpty.subscribe,reconnectToStream:({chatId})=>runForChat(Effect3.gen(function*resume(){const conversationId=yield*conversationIdOf(chatId);const running=script.resume?.(conversationId)??null;if(running===null){resumeEmpty.emit({conversationId});return null}return play(running,chunkDelayMs)})),resumeStreamIsReplay:true,sendMessages:({chatId,messageId,messages,trigger})=>runForChat(Effect3.gen(function*answer(){const conversationId=yield*conversationIdOf(chatId);const message=yield*lastMessage(messages);const turn=trigger==="regenerate-message"&&messageId!==undefined?{conversationId,message,messageId,trigger}:{conversationId,message,trigger:"submit-message"};return play(script.answer(turn),chunkDelayMs)}))}};export{createChatClient,createChatTransport,createSimulatedChatTransport};
1
+ import{ConversationId2}from"./domain-6wbbkjz0.js";import{aiErrorCodes2,AiFailureError2}from"./domain-9wzbv87n.js";import{readUIMessageStream}from"ai";import*as Effect2 from"effect/Effect";import*as Option2 from"effect/Option";import*as Stream from"effect/Stream";import{APICallError,DefaultChatTransport}from"ai";import*as Effect from"effect/Effect";import*as Option from"effect/Option";import*as Schema from"effect/Schema";var invalidRequest=(message)=>new AiFailureError2({code:"invalid_request",message,retryable:false});var decodeConversationId=Schema.decodeUnknownOption(ConversationId2);var conversationIdOf=(chatId)=>Effect.fromOption(decodeConversationId(chatId),()=>invalidRequest(`The chat id "${chatId}" is not a Conversation id.`));var lastMessage=(messages)=>Effect.fromOption(Option.fromUndefinedOr(messages.at(-1)),()=>invalidRequest("A chat send has no message."));var makeResumeEmptySignal=()=>{const listeners=new Set;return{emit:(event)=>{for(const listener of listeners){listener(event)}},subscribe:(listener)=>{listeners.add(listener);return()=>{listeners.delete(listener)}}}};var decodeFailureEnvelope=Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Struct({error:Schema.Struct({code:Schema.Literals(aiErrorCodes2),details:Schema.optionalKey(Schema.Struct({reason:Schema.optionalKey(Schema.String),runId:Schema.optionalKey(Schema.String)})),message:Schema.String,retryable:Schema.Boolean})})));var codeOfStatus=(status)=>{switch(status){case 400:case 422:{return"invalid_request"}case 401:{return"unauthenticated"}case 403:{return"forbidden"}case 404:{return"not_found"}case 409:{return"conflict"}case 429:{return"rate_limited"}case 502:case 503:case 504:{return"unavailable"}default:{return"internal"}}};var toAiFailure=(cause)=>{if(cause instanceof AiFailureError2){return cause}if(APICallError.isInstance(cause)){return Option.match(decodeFailureEnvelope(cause.responseBody??""),{onNone:()=>{const code=codeOfStatus(cause.statusCode??500);return new AiFailureError2({code,message:cause.message,retryable:code==="rate_limited"||code==="unavailable"},{cause})},onSome:({error:failure})=>{const error={code:failure.code,message:failure.message,retryable:failure.retryable};const reason=failure.details?.reason;const runId=failure.details?.runId;return new AiFailureError2({...error,...reason!==undefined&&{reason},...runId!==undefined&&{runId}},{cause})}})}if(cause instanceof TypeError){return new AiFailureError2({code:"unavailable",message:cause.message,retryable:true},{cause})}return new AiFailureError2({code:"internal",message:cause instanceof Error?cause.message:String(cause),retryable:false},{cause})};var steeringOf=(body)=>{const steering=body?.steering;return steering==="steer"||steering==="reject"?steering:undefined};var sdkFetch=(fetch)=>Object.assign((input,init)=>fetch(input,init),{preconnect:()=>null});var runForChat=(operation)=>Effect.runPromise(operation);var isRequestAbort=(cause)=>cause instanceof Error&&cause.name==="AbortError";var requestFailure=(cause)=>isRequestAbort(cause)?cause:toAiFailure(cause);var createChatTransport=(options)=>{const base=String(options.baseUrl).replace(/\/+$/u,"");const chatUrl=(chatId)=>Effect.map(conversationIdOf(chatId),(id)=>`${base}/chat/${id}`);const resumeEmpty=makeResumeEmptySignal();const init={prepareReconnectToStreamRequest:({id})=>runForChat(Effect.map(chatUrl(id),(url)=>({api:`${url}/stream`}))),prepareSendMessagesRequest:({body:sendBody,id,messageId,messages,trigger})=>runForChat(Effect.gen(function*sendRequest(){const steering=steeringOf(sendBody);const body={message:yield*lastMessage(messages),trigger,...steering!==undefined&&{steering}};return{api:yield*chatUrl(id),body:messageId===undefined?body:{...body,messageId}}}))};if(options.fetch!==undefined){init.fetch=sdkFetch(options.fetch)}if(options.headers!==undefined){init.headers=options.headers}const http=new DefaultChatTransport(init);return{onResumeEmpty:resumeEmpty.subscribe,reconnectToStream:(request)=>runForChat(Effect.gen(function*resume(){const stream=yield*Effect.tryPromise({catch:requestFailure,try:()=>http.reconnectToStream(request)});if(stream===null){const conversationId=yield*conversationIdOf(request.chatId);resumeEmpty.emit({conversationId})}return stream})),resumeStreamIsReplay:http.resumeStreamIsReplay,sendMessages:(request)=>runForChat(Effect.tryPromise({catch:requestFailure,try:()=>http.sendMessages(request)}))}};var endedWithoutAnswer=()=>new AiFailureError2({code:"internal",message:"The chat answer ended without a message.",retryable:true});var turnRefused=(refusal)=>new AiFailureError2({code:refusal.retryable?"unavailable":"forbidden",message:`The Agent turn was refused before it started (${[refusal.reason,refusal.errorCode].filter((part)=>part!==undefined&&part!==null).join(", ")}).`,reason:"turn_refused",retryable:refusal.retryable,turnRefusal:refusal});var failOnRefusal=()=>new TransformStream({transform:(chunk,controller)=>{if(chunk.type==="data-run-status"&&chunk.data.kind==="refused_turn"){controller.error(turnRefused(chunk.data));return}controller.enqueue(chunk)}});var createChatClient=(options)=>{const transport=createChatTransport(options);const stream=({conversationId,message,steering})=>Stream.unwrap(Effect2.tryPromise({catch:toAiFailure,try:(abortSignal)=>transport.sendMessages({abortSignal,...steering!==undefined&&{body:{steering}},chatId:conversationId,messageId:undefined,messages:[message],trigger:"submit-message"})}).pipe(Effect2.map((chunks)=>Stream.fromAsyncIterable(readUIMessageStream({stream:chunks.pipeThrough(failOnRefusal()),terminateOnError:true}),toAiFailure))));return{send:(turn)=>Stream.runLast(stream(turn)).pipe(Effect2.flatMap(Option2.match({onNone:()=>Effect2.fail(endedWithoutAnswer()),onSome:Effect2.succeed}))),stream}};import*as Duration from"effect/Duration";import*as Effect3 from"effect/Effect";import*as Schedule from"effect/Schedule";import*as Stream2 from"effect/Stream";var textChunks=(text)=>[{type:"start"},{id:"text-1",type:"text-start"},...text.split(/(?<=\s)/u).map((delta)=>({delta,id:"text-1",type:"text-delta"})),{id:"text-1",type:"text-end"},{type:"finish"}];var play=(answer,chunkDelayMs)=>{const chunks=Stream2.fromIterable("chunks"in answer?answer.chunks:textChunks(answer.text));return Stream2.toReadableStream(chunkDelayMs>0?chunks.pipe(Stream2.schedule(Schedule.spaced(Duration.millis(chunkDelayMs)))):chunks)};var createSimulatedChatTransport=(script)=>{const chunkDelayMs=script.chunkDelayMs??0;const resumeEmpty=makeResumeEmptySignal();return{onResumeEmpty:resumeEmpty.subscribe,reconnectToStream:({chatId})=>runForChat(Effect3.gen(function*resume(){const conversationId=yield*conversationIdOf(chatId);const running=script.resume?.(conversationId)??null;if(running===null){resumeEmpty.emit({conversationId});return null}return play(running,chunkDelayMs)})),resumeStreamIsReplay:true,sendMessages:({chatId,messageId,messages,trigger})=>runForChat(Effect3.gen(function*answer(){const conversationId=yield*conversationIdOf(chatId);const message=yield*lastMessage(messages);const turn=trigger==="regenerate-message"&&messageId!==undefined?{conversationId,message,messageId,trigger}:{conversationId,message,trigger:"submit-message"};return play(script.answer(turn),chunkDelayMs)}))}};export{createChatClient,createChatTransport,createSimulatedChatTransport};
@@ -39,7 +39,8 @@ export declare const readRunStream: (runId: InvocationId, update: (state: Partia
39
39
  readonly message: string;
40
40
  readonly retryable: boolean;
41
41
  readonly details?: {
42
- readonly reason: "intent_turn_agent" | "intent_turn_busy" | "turn_ended";
42
+ readonly reason: "conversation_busy" | "intent_turn_agent" | "intent_turn_busy" | "turn_ended";
43
+ readonly runId?: string & import("effect/Brand").Brand<"@collective-intelligence/ai/InvocationId">;
43
44
  };
44
45
  };
45
46
  readonly ok: false;