@inline-chat/hermes-agent-adapter 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -11
- package/package.json +6 -6
- package/plugin/inline/adapter.py +746 -6
- package/plugin/inline/cli.py +1 -1
- package/plugin/inline/plugin.yaml +8 -1
- package/plugin/inline/sidecar/index.mjs +1844 -23
|
@@ -6795,6 +6795,8 @@ var Method;
|
|
|
6795
6795
|
Method[Method["GET_AGENT_ACCESS"] = 166] = "GET_AGENT_ACCESS";
|
|
6796
6796
|
Method[Method["GET_UNREAD_ACTIVITY"] = 167] = "GET_UNREAD_ACTIVITY";
|
|
6797
6797
|
Method[Method["READ_ACTIVITY"] = 168] = "READ_ACTIVITY";
|
|
6798
|
+
Method[Method["SET_FOCUS_STATUS"] = 169] = "SET_FOCUS_STATUS";
|
|
6799
|
+
Method[Method["GET_SPACES"] = 170] = "GET_SPACES";
|
|
6798
6800
|
})(Method || (Method = {}));
|
|
6799
6801
|
var GridTranscriptionState;
|
|
6800
6802
|
(function(GridTranscriptionState) {
|
|
@@ -6850,6 +6852,23 @@ var DeleteDialogFolderDisposition;
|
|
|
6850
6852
|
DeleteDialogFolderDisposition[DeleteDialogFolderDisposition["CLOSE_DIALOGS"] = 1] = "CLOSE_DIALOGS";
|
|
6851
6853
|
DeleteDialogFolderDisposition[DeleteDialogFolderDisposition["KEEP_DIALOGS"] = 2] = "KEEP_DIALOGS";
|
|
6852
6854
|
})(DeleteDialogFolderDisposition || (DeleteDialogFolderDisposition = {}));
|
|
6855
|
+
var ChatListScope;
|
|
6856
|
+
(function(ChatListScope) {
|
|
6857
|
+
ChatListScope[ChatListScope["DIALOGS"] = 0] = "DIALOGS";
|
|
6858
|
+
ChatListScope[ChatListScope["ACCESSIBLE"] = 1] = "ACCESSIBLE";
|
|
6859
|
+
})(ChatListScope || (ChatListScope = {}));
|
|
6860
|
+
var ChatListOrder;
|
|
6861
|
+
(function(ChatListOrder) {
|
|
6862
|
+
ChatListOrder[ChatListOrder["RECENT"] = 0] = "RECENT";
|
|
6863
|
+
ChatListOrder[ChatListOrder["ID"] = 1] = "ID";
|
|
6864
|
+
})(ChatListOrder || (ChatListOrder = {}));
|
|
6865
|
+
var ChatListKind;
|
|
6866
|
+
(function(ChatListKind) {
|
|
6867
|
+
ChatListKind[ChatListKind["UNSPECIFIED"] = 0] = "UNSPECIFIED";
|
|
6868
|
+
ChatListKind[ChatListKind["DM"] = 1] = "DM";
|
|
6869
|
+
ChatListKind[ChatListKind["SPACE_THREAD"] = 2] = "SPACE_THREAD";
|
|
6870
|
+
ChatListKind[ChatListKind["HOME_THREAD"] = 3] = "HOME_THREAD";
|
|
6871
|
+
})(ChatListKind || (ChatListKind = {}));
|
|
6853
6872
|
var GetChatHistoryMode;
|
|
6854
6873
|
(function(GetChatHistoryMode) {
|
|
6855
6874
|
GetChatHistoryMode[GetChatHistoryMode["HISTORY_MODE_UNSPECIFIED"] = 0] = "HISTORY_MODE_UNSPECIFIED";
|
|
@@ -18768,7 +18787,9 @@ class RpcCall$Type extends import_runtime4.MessageType {
|
|
|
18768
18787
|
{ no: 166, name: "getContacts", kind: "message", oneof: "input", T: () => GetContactsInput },
|
|
18769
18788
|
{ no: 167, name: "getAgentAccess", kind: "message", oneof: "input", T: () => GetAgentAccessInput },
|
|
18770
18789
|
{ no: 168, name: "getUnreadActivity", kind: "message", oneof: "input", T: () => GetUnreadActivityInput },
|
|
18771
|
-
{ no: 169, name: "readActivity", kind: "message", oneof: "input", T: () => ReadActivityInput }
|
|
18790
|
+
{ no: 169, name: "readActivity", kind: "message", oneof: "input", T: () => ReadActivityInput },
|
|
18791
|
+
{ no: 170, name: "setFocusStatus", kind: "message", oneof: "input", T: () => SetFocusStatusInput },
|
|
18792
|
+
{ no: 171, name: "getSpaces", kind: "message", oneof: "input", T: () => GetSpacesInput }
|
|
18772
18793
|
]);
|
|
18773
18794
|
}
|
|
18774
18795
|
create(value) {
|
|
@@ -19789,6 +19810,18 @@ class RpcCall$Type extends import_runtime4.MessageType {
|
|
|
19789
19810
|
readActivity: ReadActivityInput.internalBinaryRead(reader, reader.uint32(), options, message.input.readActivity)
|
|
19790
19811
|
};
|
|
19791
19812
|
break;
|
|
19813
|
+
case 170:
|
|
19814
|
+
message.input = {
|
|
19815
|
+
oneofKind: "setFocusStatus",
|
|
19816
|
+
setFocusStatus: SetFocusStatusInput.internalBinaryRead(reader, reader.uint32(), options, message.input.setFocusStatus)
|
|
19817
|
+
};
|
|
19818
|
+
break;
|
|
19819
|
+
case 171:
|
|
19820
|
+
message.input = {
|
|
19821
|
+
oneofKind: "getSpaces",
|
|
19822
|
+
getSpaces: GetSpacesInput.internalBinaryRead(reader, reader.uint32(), options, message.input.getSpaces)
|
|
19823
|
+
};
|
|
19824
|
+
break;
|
|
19792
19825
|
default:
|
|
19793
19826
|
let u = options.readUnknownField;
|
|
19794
19827
|
if (u === "throw")
|
|
@@ -20137,6 +20170,10 @@ class RpcCall$Type extends import_runtime4.MessageType {
|
|
|
20137
20170
|
GetUnreadActivityInput.internalBinaryWrite(message.input.getUnreadActivity, writer.tag(168, import_runtime.WireType.LengthDelimited).fork(), options).join();
|
|
20138
20171
|
if (message.input.oneofKind === "readActivity")
|
|
20139
20172
|
ReadActivityInput.internalBinaryWrite(message.input.readActivity, writer.tag(169, import_runtime.WireType.LengthDelimited).fork(), options).join();
|
|
20173
|
+
if (message.input.oneofKind === "setFocusStatus")
|
|
20174
|
+
SetFocusStatusInput.internalBinaryWrite(message.input.setFocusStatus, writer.tag(170, import_runtime.WireType.LengthDelimited).fork(), options).join();
|
|
20175
|
+
if (message.input.oneofKind === "getSpaces")
|
|
20176
|
+
GetSpacesInput.internalBinaryWrite(message.input.getSpaces, writer.tag(171, import_runtime.WireType.LengthDelimited).fork(), options).join();
|
|
20140
20177
|
let u = options.writeUnknownFields;
|
|
20141
20178
|
if (u !== false)
|
|
20142
20179
|
(u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
@@ -20315,7 +20352,9 @@ class RpcResult$Type extends import_runtime4.MessageType {
|
|
|
20315
20352
|
{ no: 166, name: "getContacts", kind: "message", oneof: "result", T: () => GetContactsResult },
|
|
20316
20353
|
{ no: 167, name: "getAgentAccess", kind: "message", oneof: "result", T: () => GetAgentAccessResult },
|
|
20317
20354
|
{ no: 168, name: "getUnreadActivity", kind: "message", oneof: "result", T: () => GetUnreadActivityResult },
|
|
20318
|
-
{ no: 169, name: "readActivity", kind: "message", oneof: "result", T: () => ReadActivityResult }
|
|
20355
|
+
{ no: 169, name: "readActivity", kind: "message", oneof: "result", T: () => ReadActivityResult },
|
|
20356
|
+
{ no: 170, name: "setFocusStatus", kind: "message", oneof: "result", T: () => SetFocusStatusResult },
|
|
20357
|
+
{ no: 171, name: "getSpaces", kind: "message", oneof: "result", T: () => GetSpacesResult }
|
|
20319
20358
|
]);
|
|
20320
20359
|
}
|
|
20321
20360
|
create(value) {
|
|
@@ -21336,6 +21375,18 @@ class RpcResult$Type extends import_runtime4.MessageType {
|
|
|
21336
21375
|
readActivity: ReadActivityResult.internalBinaryRead(reader, reader.uint32(), options, message.result.readActivity)
|
|
21337
21376
|
};
|
|
21338
21377
|
break;
|
|
21378
|
+
case 170:
|
|
21379
|
+
message.result = {
|
|
21380
|
+
oneofKind: "setFocusStatus",
|
|
21381
|
+
setFocusStatus: SetFocusStatusResult.internalBinaryRead(reader, reader.uint32(), options, message.result.setFocusStatus)
|
|
21382
|
+
};
|
|
21383
|
+
break;
|
|
21384
|
+
case 171:
|
|
21385
|
+
message.result = {
|
|
21386
|
+
oneofKind: "getSpaces",
|
|
21387
|
+
getSpaces: GetSpacesResult.internalBinaryRead(reader, reader.uint32(), options, message.result.getSpaces)
|
|
21388
|
+
};
|
|
21389
|
+
break;
|
|
21339
21390
|
default:
|
|
21340
21391
|
let u = options.readUnknownField;
|
|
21341
21392
|
if (u === "throw")
|
|
@@ -21684,6 +21735,10 @@ class RpcResult$Type extends import_runtime4.MessageType {
|
|
|
21684
21735
|
GetUnreadActivityResult.internalBinaryWrite(message.result.getUnreadActivity, writer.tag(168, import_runtime.WireType.LengthDelimited).fork(), options).join();
|
|
21685
21736
|
if (message.result.oneofKind === "readActivity")
|
|
21686
21737
|
ReadActivityResult.internalBinaryWrite(message.result.readActivity, writer.tag(169, import_runtime.WireType.LengthDelimited).fork(), options).join();
|
|
21738
|
+
if (message.result.oneofKind === "setFocusStatus")
|
|
21739
|
+
SetFocusStatusResult.internalBinaryWrite(message.result.setFocusStatus, writer.tag(170, import_runtime.WireType.LengthDelimited).fork(), options).join();
|
|
21740
|
+
if (message.result.oneofKind === "getSpaces")
|
|
21741
|
+
GetSpacesResult.internalBinaryWrite(message.result.getSpaces, writer.tag(171, import_runtime.WireType.LengthDelimited).fork(), options).join();
|
|
21687
21742
|
let u = options.writeUnknownFields;
|
|
21688
21743
|
if (u !== false)
|
|
21689
21744
|
(u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
@@ -26661,6 +26716,71 @@ class ReadActivityResult$Type extends import_runtime4.MessageType {
|
|
|
26661
26716
|
}
|
|
26662
26717
|
var ReadActivityResult = new ReadActivityResult$Type;
|
|
26663
26718
|
|
|
26719
|
+
class SetFocusStatusInput$Type extends import_runtime4.MessageType {
|
|
26720
|
+
constructor() {
|
|
26721
|
+
super("SetFocusStatusInput", [
|
|
26722
|
+
{ no: 1, name: "focused", kind: "scalar", T: 8 }
|
|
26723
|
+
]);
|
|
26724
|
+
}
|
|
26725
|
+
create(value) {
|
|
26726
|
+
const message = globalThis.Object.create(this.messagePrototype);
|
|
26727
|
+
message.focused = false;
|
|
26728
|
+
if (value !== undefined)
|
|
26729
|
+
import_runtime3.reflectionMergePartial(this, message, value);
|
|
26730
|
+
return message;
|
|
26731
|
+
}
|
|
26732
|
+
internalBinaryRead(reader, length, options, target) {
|
|
26733
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
26734
|
+
while (reader.pos < end) {
|
|
26735
|
+
let [fieldNo, wireType] = reader.tag();
|
|
26736
|
+
switch (fieldNo) {
|
|
26737
|
+
case 1:
|
|
26738
|
+
message.focused = reader.bool();
|
|
26739
|
+
break;
|
|
26740
|
+
default:
|
|
26741
|
+
let u = options.readUnknownField;
|
|
26742
|
+
if (u === "throw")
|
|
26743
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
26744
|
+
let d = reader.skip(wireType);
|
|
26745
|
+
if (u !== false)
|
|
26746
|
+
(u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
26747
|
+
}
|
|
26748
|
+
}
|
|
26749
|
+
return message;
|
|
26750
|
+
}
|
|
26751
|
+
internalBinaryWrite(message, writer, options) {
|
|
26752
|
+
if (message.focused !== false)
|
|
26753
|
+
writer.tag(1, import_runtime.WireType.Varint).bool(message.focused);
|
|
26754
|
+
let u = options.writeUnknownFields;
|
|
26755
|
+
if (u !== false)
|
|
26756
|
+
(u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
26757
|
+
return writer;
|
|
26758
|
+
}
|
|
26759
|
+
}
|
|
26760
|
+
var SetFocusStatusInput = new SetFocusStatusInput$Type;
|
|
26761
|
+
|
|
26762
|
+
class SetFocusStatusResult$Type extends import_runtime4.MessageType {
|
|
26763
|
+
constructor() {
|
|
26764
|
+
super("SetFocusStatusResult", []);
|
|
26765
|
+
}
|
|
26766
|
+
create(value) {
|
|
26767
|
+
const message = globalThis.Object.create(this.messagePrototype);
|
|
26768
|
+
if (value !== undefined)
|
|
26769
|
+
import_runtime3.reflectionMergePartial(this, message, value);
|
|
26770
|
+
return message;
|
|
26771
|
+
}
|
|
26772
|
+
internalBinaryRead(reader, length, options, target) {
|
|
26773
|
+
return target ?? this.create();
|
|
26774
|
+
}
|
|
26775
|
+
internalBinaryWrite(message, writer, options) {
|
|
26776
|
+
let u = options.writeUnknownFields;
|
|
26777
|
+
if (u !== false)
|
|
26778
|
+
(u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
26779
|
+
return writer;
|
|
26780
|
+
}
|
|
26781
|
+
}
|
|
26782
|
+
var SetFocusStatusResult = new SetFocusStatusResult$Type;
|
|
26783
|
+
|
|
26664
26784
|
class CreateBotInput$Type extends import_runtime4.MessageType {
|
|
26665
26785
|
constructor() {
|
|
26666
26786
|
super("CreateBotInput", [
|
|
@@ -30039,7 +30159,8 @@ class PrivacySettings$Type extends import_runtime4.MessageType {
|
|
|
30039
30159
|
super("PrivacySettings", [
|
|
30040
30160
|
{ no: 1, name: "share_time_zone", kind: "scalar", opt: true, T: 8 },
|
|
30041
30161
|
{ no: 2, name: "appear_in_global_search", kind: "scalar", opt: true, T: 8 },
|
|
30042
|
-
{ no: 3, name: "time_zone", kind: "message", T: () => PrivacyRule }
|
|
30162
|
+
{ no: 3, name: "time_zone", kind: "message", T: () => PrivacyRule },
|
|
30163
|
+
{ no: 4, name: "focus_status", kind: "message", T: () => PrivacyRule }
|
|
30043
30164
|
]);
|
|
30044
30165
|
}
|
|
30045
30166
|
create(value) {
|
|
@@ -30062,6 +30183,9 @@ class PrivacySettings$Type extends import_runtime4.MessageType {
|
|
|
30062
30183
|
case 3:
|
|
30063
30184
|
message.timeZone = PrivacyRule.internalBinaryRead(reader, reader.uint32(), options, message.timeZone);
|
|
30064
30185
|
break;
|
|
30186
|
+
case 4:
|
|
30187
|
+
message.focusStatus = PrivacyRule.internalBinaryRead(reader, reader.uint32(), options, message.focusStatus);
|
|
30188
|
+
break;
|
|
30065
30189
|
default:
|
|
30066
30190
|
let u = options.readUnknownField;
|
|
30067
30191
|
if (u === "throw")
|
|
@@ -30080,6 +30204,8 @@ class PrivacySettings$Type extends import_runtime4.MessageType {
|
|
|
30080
30204
|
writer.tag(2, import_runtime.WireType.Varint).bool(message.appearInGlobalSearch);
|
|
30081
30205
|
if (message.timeZone)
|
|
30082
30206
|
PrivacyRule.internalBinaryWrite(message.timeZone, writer.tag(3, import_runtime.WireType.LengthDelimited).fork(), options).join();
|
|
30207
|
+
if (message.focusStatus)
|
|
30208
|
+
PrivacyRule.internalBinaryWrite(message.focusStatus, writer.tag(4, import_runtime.WireType.LengthDelimited).fork(), options).join();
|
|
30083
30209
|
let u = options.writeUnknownFields;
|
|
30084
30210
|
if (u !== false)
|
|
30085
30211
|
(u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
@@ -31613,11 +31739,18 @@ var DeleteDialogFolderResult = new DeleteDialogFolderResult$Type;
|
|
|
31613
31739
|
class GetChatsInput$Type extends import_runtime4.MessageType {
|
|
31614
31740
|
constructor() {
|
|
31615
31741
|
super("GetChatsInput", [
|
|
31616
|
-
{ no: 1, name: "include_subthreads", kind: "scalar", opt: true, T: 8 }
|
|
31742
|
+
{ no: 1, name: "include_subthreads", kind: "scalar", opt: true, T: 8 },
|
|
31743
|
+
{ no: 2, name: "limit", kind: "scalar", opt: true, T: 5 },
|
|
31744
|
+
{ no: 3, name: "offset", kind: "message", T: () => ChatListOffset },
|
|
31745
|
+
{ no: 4, name: "order", kind: "enum", T: () => ["ChatListOrder", ChatListOrder, "CHAT_LIST_ORDER_"] },
|
|
31746
|
+
{ no: 5, name: "filter", kind: "message", T: () => ChatListFilter },
|
|
31747
|
+
{ no: 6, name: "scope", kind: "enum", T: () => ["ChatListScope", ChatListScope, "CHAT_LIST_SCOPE_"] }
|
|
31617
31748
|
]);
|
|
31618
31749
|
}
|
|
31619
31750
|
create(value) {
|
|
31620
31751
|
const message = globalThis.Object.create(this.messagePrototype);
|
|
31752
|
+
message.order = 0;
|
|
31753
|
+
message.scope = 0;
|
|
31621
31754
|
if (value !== undefined)
|
|
31622
31755
|
import_runtime3.reflectionMergePartial(this, message, value);
|
|
31623
31756
|
return message;
|
|
@@ -31630,6 +31763,21 @@ class GetChatsInput$Type extends import_runtime4.MessageType {
|
|
|
31630
31763
|
case 1:
|
|
31631
31764
|
message.includeSubthreads = reader.bool();
|
|
31632
31765
|
break;
|
|
31766
|
+
case 2:
|
|
31767
|
+
message.limit = reader.int32();
|
|
31768
|
+
break;
|
|
31769
|
+
case 3:
|
|
31770
|
+
message.offset = ChatListOffset.internalBinaryRead(reader, reader.uint32(), options, message.offset);
|
|
31771
|
+
break;
|
|
31772
|
+
case 4:
|
|
31773
|
+
message.order = reader.int32();
|
|
31774
|
+
break;
|
|
31775
|
+
case 5:
|
|
31776
|
+
message.filter = ChatListFilter.internalBinaryRead(reader, reader.uint32(), options, message.filter);
|
|
31777
|
+
break;
|
|
31778
|
+
case 6:
|
|
31779
|
+
message.scope = reader.int32();
|
|
31780
|
+
break;
|
|
31633
31781
|
default:
|
|
31634
31782
|
let u = options.readUnknownField;
|
|
31635
31783
|
if (u === "throw")
|
|
@@ -31644,6 +31792,16 @@ class GetChatsInput$Type extends import_runtime4.MessageType {
|
|
|
31644
31792
|
internalBinaryWrite(message, writer, options) {
|
|
31645
31793
|
if (message.includeSubthreads !== undefined)
|
|
31646
31794
|
writer.tag(1, import_runtime.WireType.Varint).bool(message.includeSubthreads);
|
|
31795
|
+
if (message.limit !== undefined)
|
|
31796
|
+
writer.tag(2, import_runtime.WireType.Varint).int32(message.limit);
|
|
31797
|
+
if (message.offset)
|
|
31798
|
+
ChatListOffset.internalBinaryWrite(message.offset, writer.tag(3, import_runtime.WireType.LengthDelimited).fork(), options).join();
|
|
31799
|
+
if (message.order !== 0)
|
|
31800
|
+
writer.tag(4, import_runtime.WireType.Varint).int32(message.order);
|
|
31801
|
+
if (message.filter)
|
|
31802
|
+
ChatListFilter.internalBinaryWrite(message.filter, writer.tag(5, import_runtime.WireType.LengthDelimited).fork(), options).join();
|
|
31803
|
+
if (message.scope !== 0)
|
|
31804
|
+
writer.tag(6, import_runtime.WireType.Varint).int32(message.scope);
|
|
31647
31805
|
let u = options.writeUnknownFields;
|
|
31648
31806
|
if (u !== false)
|
|
31649
31807
|
(u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
@@ -31652,6 +31810,157 @@ class GetChatsInput$Type extends import_runtime4.MessageType {
|
|
|
31652
31810
|
}
|
|
31653
31811
|
var GetChatsInput = new GetChatsInput$Type;
|
|
31654
31812
|
|
|
31813
|
+
class ChatListOffset$Type extends import_runtime4.MessageType {
|
|
31814
|
+
constructor() {
|
|
31815
|
+
super("ChatListOffset", [
|
|
31816
|
+
{ no: 1, name: "chat_id", kind: "scalar", T: 3, L: 0 },
|
|
31817
|
+
{ no: 2, name: "date", kind: "scalar", opt: true, T: 3, L: 0 }
|
|
31818
|
+
]);
|
|
31819
|
+
}
|
|
31820
|
+
create(value) {
|
|
31821
|
+
const message = globalThis.Object.create(this.messagePrototype);
|
|
31822
|
+
message.chatId = 0n;
|
|
31823
|
+
if (value !== undefined)
|
|
31824
|
+
import_runtime3.reflectionMergePartial(this, message, value);
|
|
31825
|
+
return message;
|
|
31826
|
+
}
|
|
31827
|
+
internalBinaryRead(reader, length, options, target) {
|
|
31828
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
31829
|
+
while (reader.pos < end) {
|
|
31830
|
+
let [fieldNo, wireType] = reader.tag();
|
|
31831
|
+
switch (fieldNo) {
|
|
31832
|
+
case 1:
|
|
31833
|
+
message.chatId = reader.int64().toBigInt();
|
|
31834
|
+
break;
|
|
31835
|
+
case 2:
|
|
31836
|
+
message.date = reader.int64().toBigInt();
|
|
31837
|
+
break;
|
|
31838
|
+
default:
|
|
31839
|
+
let u = options.readUnknownField;
|
|
31840
|
+
if (u === "throw")
|
|
31841
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
31842
|
+
let d = reader.skip(wireType);
|
|
31843
|
+
if (u !== false)
|
|
31844
|
+
(u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
31845
|
+
}
|
|
31846
|
+
}
|
|
31847
|
+
return message;
|
|
31848
|
+
}
|
|
31849
|
+
internalBinaryWrite(message, writer, options) {
|
|
31850
|
+
if (message.chatId !== 0n)
|
|
31851
|
+
writer.tag(1, import_runtime.WireType.Varint).int64(message.chatId);
|
|
31852
|
+
if (message.date !== undefined)
|
|
31853
|
+
writer.tag(2, import_runtime.WireType.Varint).int64(message.date);
|
|
31854
|
+
let u = options.writeUnknownFields;
|
|
31855
|
+
if (u !== false)
|
|
31856
|
+
(u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
31857
|
+
return writer;
|
|
31858
|
+
}
|
|
31859
|
+
}
|
|
31860
|
+
var ChatListOffset = new ChatListOffset$Type;
|
|
31861
|
+
|
|
31862
|
+
class ChatListFilter$Type extends import_runtime4.MessageType {
|
|
31863
|
+
constructor() {
|
|
31864
|
+
super("ChatListFilter", [
|
|
31865
|
+
{ no: 1, name: "kinds", kind: "enum", repeat: 1, T: () => ["ChatListKind", ChatListKind, "CHAT_LIST_KIND_"] },
|
|
31866
|
+
{ no: 2, name: "space_ids", kind: "scalar", repeat: 1, T: 3, L: 0 },
|
|
31867
|
+
{ no: 3, name: "unread", kind: "scalar", opt: true, T: 8 },
|
|
31868
|
+
{ no: 4, name: "archived", kind: "scalar", opt: true, T: 8 },
|
|
31869
|
+
{ no: 5, name: "open", kind: "scalar", opt: true, T: 8 },
|
|
31870
|
+
{ no: 6, name: "pinned", kind: "scalar", opt: true, T: 8 },
|
|
31871
|
+
{ no: 7, name: "folder_id", kind: "scalar", opt: true, T: 3, L: 0 },
|
|
31872
|
+
{ no: 8, name: "query", kind: "scalar", opt: true, T: 9 }
|
|
31873
|
+
]);
|
|
31874
|
+
}
|
|
31875
|
+
create(value) {
|
|
31876
|
+
const message = globalThis.Object.create(this.messagePrototype);
|
|
31877
|
+
message.kinds = [];
|
|
31878
|
+
message.spaceIds = [];
|
|
31879
|
+
if (value !== undefined)
|
|
31880
|
+
import_runtime3.reflectionMergePartial(this, message, value);
|
|
31881
|
+
return message;
|
|
31882
|
+
}
|
|
31883
|
+
internalBinaryRead(reader, length, options, target) {
|
|
31884
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
31885
|
+
while (reader.pos < end) {
|
|
31886
|
+
let [fieldNo, wireType] = reader.tag();
|
|
31887
|
+
switch (fieldNo) {
|
|
31888
|
+
case 1:
|
|
31889
|
+
if (wireType === import_runtime.WireType.LengthDelimited)
|
|
31890
|
+
for (let e = reader.int32() + reader.pos;reader.pos < e; )
|
|
31891
|
+
message.kinds.push(reader.int32());
|
|
31892
|
+
else
|
|
31893
|
+
message.kinds.push(reader.int32());
|
|
31894
|
+
break;
|
|
31895
|
+
case 2:
|
|
31896
|
+
if (wireType === import_runtime.WireType.LengthDelimited)
|
|
31897
|
+
for (let e = reader.int32() + reader.pos;reader.pos < e; )
|
|
31898
|
+
message.spaceIds.push(reader.int64().toBigInt());
|
|
31899
|
+
else
|
|
31900
|
+
message.spaceIds.push(reader.int64().toBigInt());
|
|
31901
|
+
break;
|
|
31902
|
+
case 3:
|
|
31903
|
+
message.unread = reader.bool();
|
|
31904
|
+
break;
|
|
31905
|
+
case 4:
|
|
31906
|
+
message.archived = reader.bool();
|
|
31907
|
+
break;
|
|
31908
|
+
case 5:
|
|
31909
|
+
message.open = reader.bool();
|
|
31910
|
+
break;
|
|
31911
|
+
case 6:
|
|
31912
|
+
message.pinned = reader.bool();
|
|
31913
|
+
break;
|
|
31914
|
+
case 7:
|
|
31915
|
+
message.folderId = reader.int64().toBigInt();
|
|
31916
|
+
break;
|
|
31917
|
+
case 8:
|
|
31918
|
+
message.query = reader.string();
|
|
31919
|
+
break;
|
|
31920
|
+
default:
|
|
31921
|
+
let u = options.readUnknownField;
|
|
31922
|
+
if (u === "throw")
|
|
31923
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
31924
|
+
let d = reader.skip(wireType);
|
|
31925
|
+
if (u !== false)
|
|
31926
|
+
(u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
31927
|
+
}
|
|
31928
|
+
}
|
|
31929
|
+
return message;
|
|
31930
|
+
}
|
|
31931
|
+
internalBinaryWrite(message, writer, options) {
|
|
31932
|
+
if (message.kinds.length) {
|
|
31933
|
+
writer.tag(1, import_runtime.WireType.LengthDelimited).fork();
|
|
31934
|
+
for (let i = 0;i < message.kinds.length; i++)
|
|
31935
|
+
writer.int32(message.kinds[i]);
|
|
31936
|
+
writer.join();
|
|
31937
|
+
}
|
|
31938
|
+
if (message.spaceIds.length) {
|
|
31939
|
+
writer.tag(2, import_runtime.WireType.LengthDelimited).fork();
|
|
31940
|
+
for (let i = 0;i < message.spaceIds.length; i++)
|
|
31941
|
+
writer.int64(message.spaceIds[i]);
|
|
31942
|
+
writer.join();
|
|
31943
|
+
}
|
|
31944
|
+
if (message.unread !== undefined)
|
|
31945
|
+
writer.tag(3, import_runtime.WireType.Varint).bool(message.unread);
|
|
31946
|
+
if (message.archived !== undefined)
|
|
31947
|
+
writer.tag(4, import_runtime.WireType.Varint).bool(message.archived);
|
|
31948
|
+
if (message.open !== undefined)
|
|
31949
|
+
writer.tag(5, import_runtime.WireType.Varint).bool(message.open);
|
|
31950
|
+
if (message.pinned !== undefined)
|
|
31951
|
+
writer.tag(6, import_runtime.WireType.Varint).bool(message.pinned);
|
|
31952
|
+
if (message.folderId !== undefined)
|
|
31953
|
+
writer.tag(7, import_runtime.WireType.Varint).int64(message.folderId);
|
|
31954
|
+
if (message.query !== undefined)
|
|
31955
|
+
writer.tag(8, import_runtime.WireType.LengthDelimited).string(message.query);
|
|
31956
|
+
let u = options.writeUnknownFields;
|
|
31957
|
+
if (u !== false)
|
|
31958
|
+
(u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
31959
|
+
return writer;
|
|
31960
|
+
}
|
|
31961
|
+
}
|
|
31962
|
+
var ChatListFilter = new ChatListFilter$Type;
|
|
31963
|
+
|
|
31655
31964
|
class GetChatsResult$Type extends import_runtime4.MessageType {
|
|
31656
31965
|
constructor() {
|
|
31657
31966
|
super("GetChatsResult", [
|
|
@@ -31660,7 +31969,8 @@ class GetChatsResult$Type extends import_runtime4.MessageType {
|
|
|
31660
31969
|
{ no: 3, name: "spaces", kind: "message", repeat: 1, T: () => Space },
|
|
31661
31970
|
{ no: 4, name: "users", kind: "message", repeat: 1, T: () => User },
|
|
31662
31971
|
{ no: 5, name: "messages", kind: "message", repeat: 1, T: () => Message },
|
|
31663
|
-
{ no: 6, name: "folders", kind: "message", repeat: 1, T: () => DialogFolder }
|
|
31972
|
+
{ no: 6, name: "folders", kind: "message", repeat: 1, T: () => DialogFolder },
|
|
31973
|
+
{ no: 7, name: "next_offset", kind: "message", T: () => ChatListOffset }
|
|
31664
31974
|
]);
|
|
31665
31975
|
}
|
|
31666
31976
|
create(value) {
|
|
@@ -31698,6 +32008,9 @@ class GetChatsResult$Type extends import_runtime4.MessageType {
|
|
|
31698
32008
|
case 6:
|
|
31699
32009
|
message.folders.push(DialogFolder.internalBinaryRead(reader, reader.uint32(), options));
|
|
31700
32010
|
break;
|
|
32011
|
+
case 7:
|
|
32012
|
+
message.nextOffset = ChatListOffset.internalBinaryRead(reader, reader.uint32(), options, message.nextOffset);
|
|
32013
|
+
break;
|
|
31701
32014
|
default:
|
|
31702
32015
|
let u = options.readUnknownField;
|
|
31703
32016
|
if (u === "throw")
|
|
@@ -31722,6 +32035,8 @@ class GetChatsResult$Type extends import_runtime4.MessageType {
|
|
|
31722
32035
|
Message.internalBinaryWrite(message.messages[i], writer.tag(5, import_runtime.WireType.LengthDelimited).fork(), options).join();
|
|
31723
32036
|
for (let i = 0;i < message.folders.length; i++)
|
|
31724
32037
|
DialogFolder.internalBinaryWrite(message.folders[i], writer.tag(6, import_runtime.WireType.LengthDelimited).fork(), options).join();
|
|
32038
|
+
if (message.nextOffset)
|
|
32039
|
+
ChatListOffset.internalBinaryWrite(message.nextOffset, writer.tag(7, import_runtime.WireType.LengthDelimited).fork(), options).join();
|
|
31725
32040
|
let u = options.writeUnknownFields;
|
|
31726
32041
|
if (u !== false)
|
|
31727
32042
|
(u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
@@ -31730,6 +32045,71 @@ class GetChatsResult$Type extends import_runtime4.MessageType {
|
|
|
31730
32045
|
}
|
|
31731
32046
|
var GetChatsResult = new GetChatsResult$Type;
|
|
31732
32047
|
|
|
32048
|
+
class GetSpacesInput$Type extends import_runtime4.MessageType {
|
|
32049
|
+
constructor() {
|
|
32050
|
+
super("GetSpacesInput", []);
|
|
32051
|
+
}
|
|
32052
|
+
create(value) {
|
|
32053
|
+
const message = globalThis.Object.create(this.messagePrototype);
|
|
32054
|
+
if (value !== undefined)
|
|
32055
|
+
import_runtime3.reflectionMergePartial(this, message, value);
|
|
32056
|
+
return message;
|
|
32057
|
+
}
|
|
32058
|
+
internalBinaryRead(reader, length, options, target) {
|
|
32059
|
+
return target ?? this.create();
|
|
32060
|
+
}
|
|
32061
|
+
internalBinaryWrite(message, writer, options) {
|
|
32062
|
+
let u = options.writeUnknownFields;
|
|
32063
|
+
if (u !== false)
|
|
32064
|
+
(u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
32065
|
+
return writer;
|
|
32066
|
+
}
|
|
32067
|
+
}
|
|
32068
|
+
var GetSpacesInput = new GetSpacesInput$Type;
|
|
32069
|
+
|
|
32070
|
+
class GetSpacesResult$Type extends import_runtime4.MessageType {
|
|
32071
|
+
constructor() {
|
|
32072
|
+
super("GetSpacesResult", [
|
|
32073
|
+
{ no: 1, name: "spaces", kind: "message", repeat: 1, T: () => Space }
|
|
32074
|
+
]);
|
|
32075
|
+
}
|
|
32076
|
+
create(value) {
|
|
32077
|
+
const message = globalThis.Object.create(this.messagePrototype);
|
|
32078
|
+
message.spaces = [];
|
|
32079
|
+
if (value !== undefined)
|
|
32080
|
+
import_runtime3.reflectionMergePartial(this, message, value);
|
|
32081
|
+
return message;
|
|
32082
|
+
}
|
|
32083
|
+
internalBinaryRead(reader, length, options, target) {
|
|
32084
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
32085
|
+
while (reader.pos < end) {
|
|
32086
|
+
let [fieldNo, wireType] = reader.tag();
|
|
32087
|
+
switch (fieldNo) {
|
|
32088
|
+
case 1:
|
|
32089
|
+
message.spaces.push(Space.internalBinaryRead(reader, reader.uint32(), options));
|
|
32090
|
+
break;
|
|
32091
|
+
default:
|
|
32092
|
+
let u = options.readUnknownField;
|
|
32093
|
+
if (u === "throw")
|
|
32094
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
32095
|
+
let d = reader.skip(wireType);
|
|
32096
|
+
if (u !== false)
|
|
32097
|
+
(u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
32098
|
+
}
|
|
32099
|
+
}
|
|
32100
|
+
return message;
|
|
32101
|
+
}
|
|
32102
|
+
internalBinaryWrite(message, writer, options) {
|
|
32103
|
+
for (let i = 0;i < message.spaces.length; i++)
|
|
32104
|
+
Space.internalBinaryWrite(message.spaces[i], writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
|
|
32105
|
+
let u = options.writeUnknownFields;
|
|
32106
|
+
if (u !== false)
|
|
32107
|
+
(u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
32108
|
+
return writer;
|
|
32109
|
+
}
|
|
32110
|
+
}
|
|
32111
|
+
var GetSpacesResult = new GetSpacesResult$Type;
|
|
32112
|
+
|
|
31733
32113
|
class TranslateMessagesInput$Type extends import_runtime4.MessageType {
|
|
31734
32114
|
constructor() {
|
|
31735
32115
|
super("TranslateMessagesInput", [
|
|
@@ -39853,7 +40233,8 @@ class UserStatus$Type extends import_runtime4.MessageType {
|
|
|
39853
40233
|
constructor() {
|
|
39854
40234
|
super("UserStatus", [
|
|
39855
40235
|
{ no: 1, name: "online", kind: "enum", T: () => ["UserStatus.Status", UserStatus_Status] },
|
|
39856
|
-
{ no: 2, name: "last_online", kind: "message", T: () => LastOnline }
|
|
40236
|
+
{ no: 2, name: "last_online", kind: "message", T: () => LastOnline },
|
|
40237
|
+
{ no: 3, name: "focus", kind: "message", T: () => FocusStatus }
|
|
39857
40238
|
]);
|
|
39858
40239
|
}
|
|
39859
40240
|
create(value) {
|
|
@@ -39874,6 +40255,9 @@ class UserStatus$Type extends import_runtime4.MessageType {
|
|
|
39874
40255
|
case 2:
|
|
39875
40256
|
message.lastOnline = LastOnline.internalBinaryRead(reader, reader.uint32(), options, message.lastOnline);
|
|
39876
40257
|
break;
|
|
40258
|
+
case 3:
|
|
40259
|
+
message.focus = FocusStatus.internalBinaryRead(reader, reader.uint32(), options, message.focus);
|
|
40260
|
+
break;
|
|
39877
40261
|
default:
|
|
39878
40262
|
let u = options.readUnknownField;
|
|
39879
40263
|
if (u === "throw")
|
|
@@ -39890,6 +40274,8 @@ class UserStatus$Type extends import_runtime4.MessageType {
|
|
|
39890
40274
|
writer.tag(1, import_runtime.WireType.Varint).int32(message.online);
|
|
39891
40275
|
if (message.lastOnline)
|
|
39892
40276
|
LastOnline.internalBinaryWrite(message.lastOnline, writer.tag(2, import_runtime.WireType.LengthDelimited).fork(), options).join();
|
|
40277
|
+
if (message.focus)
|
|
40278
|
+
FocusStatus.internalBinaryWrite(message.focus, writer.tag(3, import_runtime.WireType.LengthDelimited).fork(), options).join();
|
|
39893
40279
|
let u = options.writeUnknownFields;
|
|
39894
40280
|
if (u !== false)
|
|
39895
40281
|
(u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
@@ -39898,6 +40284,55 @@ class UserStatus$Type extends import_runtime4.MessageType {
|
|
|
39898
40284
|
}
|
|
39899
40285
|
var UserStatus = new UserStatus$Type;
|
|
39900
40286
|
|
|
40287
|
+
class FocusStatus$Type extends import_runtime4.MessageType {
|
|
40288
|
+
constructor() {
|
|
40289
|
+
super("FocusStatus", [
|
|
40290
|
+
{ no: 1, name: "focused", kind: "scalar", T: 8 },
|
|
40291
|
+
{ no: 2, name: "updated_at", kind: "scalar", opt: true, T: 3, L: 0 }
|
|
40292
|
+
]);
|
|
40293
|
+
}
|
|
40294
|
+
create(value) {
|
|
40295
|
+
const message = globalThis.Object.create(this.messagePrototype);
|
|
40296
|
+
message.focused = false;
|
|
40297
|
+
if (value !== undefined)
|
|
40298
|
+
import_runtime3.reflectionMergePartial(this, message, value);
|
|
40299
|
+
return message;
|
|
40300
|
+
}
|
|
40301
|
+
internalBinaryRead(reader, length, options, target) {
|
|
40302
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
40303
|
+
while (reader.pos < end) {
|
|
40304
|
+
let [fieldNo, wireType] = reader.tag();
|
|
40305
|
+
switch (fieldNo) {
|
|
40306
|
+
case 1:
|
|
40307
|
+
message.focused = reader.bool();
|
|
40308
|
+
break;
|
|
40309
|
+
case 2:
|
|
40310
|
+
message.updatedAt = reader.int64().toBigInt();
|
|
40311
|
+
break;
|
|
40312
|
+
default:
|
|
40313
|
+
let u = options.readUnknownField;
|
|
40314
|
+
if (u === "throw")
|
|
40315
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
40316
|
+
let d = reader.skip(wireType);
|
|
40317
|
+
if (u !== false)
|
|
40318
|
+
(u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
40319
|
+
}
|
|
40320
|
+
}
|
|
40321
|
+
return message;
|
|
40322
|
+
}
|
|
40323
|
+
internalBinaryWrite(message, writer, options) {
|
|
40324
|
+
if (message.focused !== false)
|
|
40325
|
+
writer.tag(1, import_runtime.WireType.Varint).bool(message.focused);
|
|
40326
|
+
if (message.updatedAt !== undefined)
|
|
40327
|
+
writer.tag(2, import_runtime.WireType.Varint).int64(message.updatedAt);
|
|
40328
|
+
let u = options.writeUnknownFields;
|
|
40329
|
+
if (u !== false)
|
|
40330
|
+
(u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
40331
|
+
return writer;
|
|
40332
|
+
}
|
|
40333
|
+
}
|
|
40334
|
+
var FocusStatus = new FocusStatus$Type;
|
|
40335
|
+
|
|
39901
40336
|
class LastOnline$Type extends import_runtime4.MessageType {
|
|
39902
40337
|
constructor() {
|
|
39903
40338
|
super("LastOnline", [
|
|
@@ -48129,6 +48564,9 @@ class PingPongService {
|
|
|
48129
48564
|
}
|
|
48130
48565
|
var isCrypto = (value) => typeof value === "object" && value !== null && ("getRandomValues" in value) && typeof value.getRandomValues === "function";
|
|
48131
48566
|
|
|
48567
|
+
// node_modules/@inline-chat/realtime-sdk/dist/realtime/rpc-input.js
|
|
48568
|
+
var normalizeRpcInput = (method, input) => RpcCall.create({ method, input }).input;
|
|
48569
|
+
|
|
48132
48570
|
// node_modules/@inline-chat/realtime-sdk/dist/realtime/transport.js
|
|
48133
48571
|
class TransportError extends Error {
|
|
48134
48572
|
code;
|
|
@@ -48277,7 +48715,7 @@ class ProtocolClient {
|
|
|
48277
48715
|
assertValidRpcMethod(method);
|
|
48278
48716
|
const message = this.wrapMessage({
|
|
48279
48717
|
oneofKind: "rpcCall",
|
|
48280
|
-
rpcCall: { method, input }
|
|
48718
|
+
rpcCall: { method, input: normalizeRpcInput(method, input) }
|
|
48281
48719
|
});
|
|
48282
48720
|
await this.transport.send(message);
|
|
48283
48721
|
return message.id;
|
|
@@ -48294,7 +48732,7 @@ class ProtocolClient {
|
|
|
48294
48732
|
}
|
|
48295
48733
|
const message = this.wrapMessage({
|
|
48296
48734
|
oneofKind: "rpcCall",
|
|
48297
|
-
rpcCall: { method, input }
|
|
48735
|
+
rpcCall: { method, input: normalizeRpcInput(method, input) }
|
|
48298
48736
|
});
|
|
48299
48737
|
return await new Promise((resolve, reject) => {
|
|
48300
48738
|
const pending = {
|
|
@@ -50885,7 +51323,8 @@ class InlineProtocolV3Connection {
|
|
|
50885
51323
|
throw new InlineProtocolV3Error("protocol", "Unexpected auth.complete response");
|
|
50886
51324
|
return response.body.authComplete;
|
|
50887
51325
|
}
|
|
50888
|
-
async callRpc(
|
|
51326
|
+
async callRpc(call, signal) {
|
|
51327
|
+
const rpc = { method: call.method, input: normalizeRpcInput(call.method, call.input) };
|
|
50889
51328
|
const request = { body: { oneofKind: "rpc", rpc } };
|
|
50890
51329
|
const response = readOnlyRpcMethods.has(rpc.method) ? await this.#invoke(request, undefined, signal) : await this.#invokeMutation(request, signal);
|
|
50891
51330
|
if (response.body.oneofKind === "rpcError")
|
|
@@ -52107,7 +52546,8 @@ var rpcInputKindByMethod = {
|
|
|
52107
52546
|
121: "cancelUpload",
|
|
52108
52547
|
127: "getSpace",
|
|
52109
52548
|
131: "updateBotAgent",
|
|
52110
|
-
132: "deleteBotAgent"
|
|
52549
|
+
132: "deleteBotAgent",
|
|
52550
|
+
170: "getSpaces"
|
|
52111
52551
|
};
|
|
52112
52552
|
var rpcResultKindByMethod = {
|
|
52113
52553
|
0: undefined,
|
|
@@ -52176,7 +52616,8 @@ var rpcResultKindByMethod = {
|
|
|
52176
52616
|
121: "cancelUpload",
|
|
52177
52617
|
127: "getSpace",
|
|
52178
52618
|
131: "updateBotAgent",
|
|
52179
|
-
132: "deleteBotAgent"
|
|
52619
|
+
132: "deleteBotAgent",
|
|
52620
|
+
170: "getSpaces"
|
|
52180
52621
|
};
|
|
52181
52622
|
|
|
52182
52623
|
// node_modules/@inline-chat/realtime-sdk/dist/sdk/logger.js
|
|
@@ -52260,6 +52701,7 @@ var replaySafeRpcMethods = new Set([
|
|
|
52260
52701
|
Method.GET_SPACE_MEMBERS,
|
|
52261
52702
|
Method.GET_CHAT_PARTICIPANTS,
|
|
52262
52703
|
Method.GET_CHATS,
|
|
52704
|
+
Method.GET_SPACES,
|
|
52263
52705
|
Method.GET_USER_SETTINGS,
|
|
52264
52706
|
Method.GET_UPDATES_STATE,
|
|
52265
52707
|
Method.GET_CHAT,
|
|
@@ -52370,6 +52812,7 @@ class InlineSdkClient {
|
|
|
52370
52812
|
});
|
|
52371
52813
|
started = false;
|
|
52372
52814
|
closed = false;
|
|
52815
|
+
syncUpdates;
|
|
52373
52816
|
bucketCatchUpsRunning = 0;
|
|
52374
52817
|
bucketCatchUpWaiters = [];
|
|
52375
52818
|
openPromise = null;
|
|
@@ -52388,6 +52831,9 @@ class InlineSdkClient {
|
|
|
52388
52831
|
catchUpRequestedBySpaceId = new Map;
|
|
52389
52832
|
userCatchUpInFlight = null;
|
|
52390
52833
|
userCatchUpRequested = null;
|
|
52834
|
+
userDemandAwaitingBaseline = false;
|
|
52835
|
+
userBaselineFloor;
|
|
52836
|
+
userBaselineFromHint = false;
|
|
52391
52837
|
peerResolutionInFlightByChatId = new Map;
|
|
52392
52838
|
peerResolutionRequestedByChatId = new Map;
|
|
52393
52839
|
recoveryReconnectInFlight = null;
|
|
@@ -52406,6 +52852,7 @@ class InlineSdkClient {
|
|
|
52406
52852
|
botCapabilitiesRegistrationInFlight = null;
|
|
52407
52853
|
constructor(options) {
|
|
52408
52854
|
this.options = options;
|
|
52855
|
+
this.syncUpdates = options.syncUpdates !== false;
|
|
52409
52856
|
this.log = options.logger ?? noopLogger;
|
|
52410
52857
|
this.httpBaseUrl = normalizeHttpBaseUrl(options.baseUrl ?? defaultApiBaseUrl);
|
|
52411
52858
|
this.fetchImpl = options.fetch ?? fetch;
|
|
@@ -53051,6 +53498,8 @@ class InlineSdkClient {
|
|
|
53051
53498
|
}
|
|
53052
53499
|
}
|
|
53053
53500
|
async initializeDateCursor() {
|
|
53501
|
+
if (!this.syncUpdates)
|
|
53502
|
+
return;
|
|
53054
53503
|
if (this.discoveryInFlight)
|
|
53055
53504
|
return this.discoveryInFlight;
|
|
53056
53505
|
if (this.discoveryCommitInFlight)
|
|
@@ -53080,6 +53529,7 @@ class InlineSdkClient {
|
|
|
53080
53529
|
getUpdatesState: GetUpdatesStateInput.create({ date })
|
|
53081
53530
|
}, { timeoutMs: 1500 });
|
|
53082
53531
|
const state = result.getUpdatesState;
|
|
53532
|
+
this.settleUserBaselineFromDiscovery(state.seq);
|
|
53083
53533
|
round.checkpoint = state.date;
|
|
53084
53534
|
round.updatesFound = state.updatesFound;
|
|
53085
53535
|
round.resultReceived = true;
|
|
@@ -53093,6 +53543,7 @@ class InlineSdkClient {
|
|
|
53093
53543
|
this.scheduleDiscoveryRetry(error.rpcCode === RpcError_Code.RATE_LIMIT || error.rpcCode === 429 ? "rate_limited" : "discovery_failed", retryAfterMsFromError(error));
|
|
53094
53544
|
} else {
|
|
53095
53545
|
this.log.error?.("Sync discovery unavailable", { reason: "request_rejected" });
|
|
53546
|
+
this.fallBackToHintedUserBaseline("discovery_rejected");
|
|
53096
53547
|
}
|
|
53097
53548
|
}
|
|
53098
53549
|
}
|
|
@@ -53359,6 +53810,7 @@ class InlineSdkClient {
|
|
|
53359
53810
|
case "userAddedToChat": {
|
|
53360
53811
|
if (options?.source === "live" && seq > 0) {
|
|
53361
53812
|
this.fenceLiveCursor({ kind: "user" });
|
|
53813
|
+
this.noteWithheldUserSeq(seq);
|
|
53362
53814
|
this.registerDiscoveryHint({ kind: "user" }, seq);
|
|
53363
53815
|
this.requestCatchUpUser(true, seq);
|
|
53364
53816
|
return Promise.resolve(true);
|
|
@@ -53557,6 +54009,8 @@ class InlineSdkClient {
|
|
|
53557
54009
|
}
|
|
53558
54010
|
}
|
|
53559
54011
|
prepareLiveEvent(event) {
|
|
54012
|
+
if (!this.syncUpdates)
|
|
54013
|
+
return true;
|
|
53560
54014
|
const bucket = this.sequencedBucketForEvent(event);
|
|
53561
54015
|
if (!bucket)
|
|
53562
54016
|
return true;
|
|
@@ -53621,6 +54075,8 @@ class InlineSdkClient {
|
|
|
53621
54075
|
const admittedSeq = this.liveAdmittedSeqByBucket.get(key);
|
|
53622
54076
|
const updateSeq = eventSeq != null ? Math.max(eventSeq, admittedSeq ?? 0) : admittedSeq;
|
|
53623
54077
|
this.fenceLiveCursor(bucket);
|
|
54078
|
+
if (bucket.kind === "user")
|
|
54079
|
+
this.noteWithheldUserSeq(eventSeq);
|
|
53624
54080
|
if (updateSeq != null)
|
|
53625
54081
|
this.registerDiscoveryHint(bucket, updateSeq);
|
|
53626
54082
|
this.requestCatchUpForLiveEvent(bucket, event, updateSeq);
|
|
@@ -53652,7 +54108,7 @@ class InlineSdkClient {
|
|
|
53652
54108
|
}
|
|
53653
54109
|
}
|
|
53654
54110
|
requestRecoveryReconnect(cause) {
|
|
53655
|
-
if (!this.started || this.recoveryReconnectInFlight)
|
|
54111
|
+
if (!this.syncUpdates || !this.started || this.recoveryReconnectInFlight)
|
|
53656
54112
|
return;
|
|
53657
54113
|
const reconnect = this.protocol.reconnect({ skipDelay: true, cause }).catch((error) => {
|
|
53658
54114
|
this.log.warn?.("Failed to reconnect after inbound event buffer overflow", error);
|
|
@@ -53677,6 +54133,7 @@ class InlineSdkClient {
|
|
|
53677
54133
|
this.requestCatchUpSpace({ spaceId: bucket.spaceId });
|
|
53678
54134
|
return;
|
|
53679
54135
|
case "user":
|
|
54136
|
+
this.noteWithheldUserSeq("seq" in event ? event.seq : undefined);
|
|
53680
54137
|
this.requestCatchUpUser(true);
|
|
53681
54138
|
return;
|
|
53682
54139
|
}
|
|
@@ -53725,6 +54182,7 @@ class InlineSdkClient {
|
|
|
53725
54182
|
this.requestCatchUpSpace({ spaceId: bucket.spaceId, ...updateSeq != null ? { updateSeq } : {} });
|
|
53726
54183
|
return;
|
|
53727
54184
|
case "user":
|
|
54185
|
+
this.noteWithheldUserSeq(updateSeq);
|
|
53728
54186
|
this.requestCatchUpUser(true, updateSeq);
|
|
53729
54187
|
return;
|
|
53730
54188
|
}
|
|
@@ -53945,13 +54403,85 @@ class InlineSdkClient {
|
|
|
53945
54403
|
this.satisfyDiscoveryThroughCursor({ kind: "user" }, seq);
|
|
53946
54404
|
}
|
|
53947
54405
|
requestCatchUpUser(forceFromStart = false, updateSeq) {
|
|
53948
|
-
|
|
53949
|
-
if (lastUserSeq == null && !this.options.catchUpUserFromStart && !forceFromStart) {
|
|
54406
|
+
if (!this.syncUpdates)
|
|
53950
54407
|
return null;
|
|
54408
|
+
if (this.awaitingUserBaseline()) {
|
|
54409
|
+
if (!forceFromStart)
|
|
54410
|
+
return null;
|
|
54411
|
+
const hintedBaseline = this.userBaselineFromHint ? updateSeq ?? this.userBaselineFloor : undefined;
|
|
54412
|
+
if (hintedBaseline == null) {
|
|
54413
|
+
this.recordUserCatchUpDemand(updateSeq);
|
|
54414
|
+
this.userDemandAwaitingBaseline = true;
|
|
54415
|
+
return null;
|
|
54416
|
+
}
|
|
54417
|
+
this.adoptUserBaseline(hintedBaseline, "hint");
|
|
54418
|
+
this.resumeUserCatchUpAfterBaseline();
|
|
53951
54419
|
}
|
|
53952
|
-
const cursor = lastUserSeq ?? 0;
|
|
54420
|
+
const cursor = this.state.lastUserSeq ?? 0;
|
|
53953
54421
|
if (updateSeq != null && updateSeq <= cursor)
|
|
53954
54422
|
return this.userCatchUpInFlight;
|
|
54423
|
+
this.recordUserCatchUpDemand(updateSeq);
|
|
54424
|
+
if (this.userCatchUpInFlight) {
|
|
54425
|
+
return this.userCatchUpInFlight;
|
|
54426
|
+
}
|
|
54427
|
+
if (this.recoveryRetries.get("user")?.timer)
|
|
54428
|
+
return null;
|
|
54429
|
+
this.fenceLiveCursor({ kind: "user" });
|
|
54430
|
+
return this.startUserCatchUp();
|
|
54431
|
+
}
|
|
54432
|
+
awaitingUserBaseline() {
|
|
54433
|
+
return this.syncUpdates && this.state.lastUserSeq == null && !this.options.catchUpUserFromStart;
|
|
54434
|
+
}
|
|
54435
|
+
noteWithheldUserSeq(seq) {
|
|
54436
|
+
if (seq == null || !Number.isSafeInteger(seq) || seq <= 0 || !this.awaitingUserBaseline())
|
|
54437
|
+
return;
|
|
54438
|
+
this.userBaselineFloor = Math.min(this.userBaselineFloor ?? seq, seq);
|
|
54439
|
+
}
|
|
54440
|
+
settleUserBaselineFromDiscovery(frontier) {
|
|
54441
|
+
if (this.awaitingUserBaseline()) {
|
|
54442
|
+
if (frontier == null || !Number.isSafeInteger(frontier) || frontier < 0) {
|
|
54443
|
+
this.fallBackToHintedUserBaseline("discovery_missing_seq");
|
|
54444
|
+
return;
|
|
54445
|
+
}
|
|
54446
|
+
this.adoptUserBaseline(frontier, "discovery");
|
|
54447
|
+
}
|
|
54448
|
+
this.resumeUserCatchUpAfterBaseline();
|
|
54449
|
+
}
|
|
54450
|
+
fallBackToHintedUserBaseline(reason) {
|
|
54451
|
+
if (!this.awaitingUserBaseline())
|
|
54452
|
+
return;
|
|
54453
|
+
const frontier = this.userCatchUpRequested?.endSeq ?? this.userBaselineFloor;
|
|
54454
|
+
this.log.warn?.("Sync discovery reported no user frontier; adopting the hinted frontier without replay", {
|
|
54455
|
+
reason,
|
|
54456
|
+
...frontier != null ? { frontier } : {}
|
|
54457
|
+
});
|
|
54458
|
+
if (frontier == null) {
|
|
54459
|
+
this.userBaselineFromHint = true;
|
|
54460
|
+
return;
|
|
54461
|
+
}
|
|
54462
|
+
this.adoptUserBaseline(frontier, "hint");
|
|
54463
|
+
this.resumeUserCatchUpAfterBaseline();
|
|
54464
|
+
}
|
|
54465
|
+
adoptUserBaseline(frontier, source) {
|
|
54466
|
+
const floor = this.userBaselineFloor;
|
|
54467
|
+
const baseline = Math.max(0, floor != null ? Math.min(frontier, floor - 1) : frontier);
|
|
54468
|
+
this.userBaselineFloor = undefined;
|
|
54469
|
+
this.userBaselineFromHint = false;
|
|
54470
|
+
this.state.lastUserSeq = baseline;
|
|
54471
|
+
this.scheduleStateSave();
|
|
54472
|
+
this.log.debug?.("Adopted user update baseline without replaying history", { source, baseline });
|
|
54473
|
+
this.satisfyDiscoveryThroughCursor({ kind: "user" }, baseline);
|
|
54474
|
+
}
|
|
54475
|
+
resumeUserCatchUpAfterBaseline() {
|
|
54476
|
+
if (!this.userDemandAwaitingBaseline)
|
|
54477
|
+
return;
|
|
54478
|
+
this.userDemandAwaitingBaseline = false;
|
|
54479
|
+
if (!this.userCatchUpRequested || this.userCatchUpInFlight || this.recoveryRetries.get("user")?.timer)
|
|
54480
|
+
return;
|
|
54481
|
+
this.fenceLiveCursor({ kind: "user" });
|
|
54482
|
+
this.startUserCatchUp();
|
|
54483
|
+
}
|
|
54484
|
+
recordUserCatchUpDemand(updateSeq) {
|
|
53955
54485
|
const previous = this.userCatchUpRequested;
|
|
53956
54486
|
const demandAlreadyCoversHint = updateSeq != null && (previous?.endSeq ?? 0) >= updateSeq;
|
|
53957
54487
|
if (!demandAlreadyCoversHint) {
|
|
@@ -53960,13 +54490,6 @@ class InlineSdkClient {
|
|
|
53960
54490
|
toLatest: previous?.toLatest === true || updateSeq == null
|
|
53961
54491
|
};
|
|
53962
54492
|
}
|
|
53963
|
-
if (this.userCatchUpInFlight) {
|
|
53964
|
-
return this.userCatchUpInFlight;
|
|
53965
|
-
}
|
|
53966
|
-
if (this.recoveryRetries.get("user")?.timer)
|
|
53967
|
-
return null;
|
|
53968
|
-
this.fenceLiveCursor({ kind: "user" });
|
|
53969
|
-
return this.startUserCatchUp();
|
|
53970
54493
|
}
|
|
53971
54494
|
startUserCatchUp() {
|
|
53972
54495
|
const initialDemand = this.userCatchUpRequested;
|
|
@@ -54100,6 +54623,8 @@ class InlineSdkClient {
|
|
|
54100
54623
|
return false;
|
|
54101
54624
|
}
|
|
54102
54625
|
requestCatchUpChat(params) {
|
|
54626
|
+
if (!this.syncUpdates)
|
|
54627
|
+
return Promise.resolve();
|
|
54103
54628
|
if (params.peer)
|
|
54104
54629
|
this.rememberChatPeer(params.chatId, params.peer);
|
|
54105
54630
|
this.fenceLiveCursor({ kind: "chat", chatId: params.chatId, peer: params.peer });
|
|
@@ -54266,6 +54791,8 @@ class InlineSdkClient {
|
|
|
54266
54791
|
return false;
|
|
54267
54792
|
}
|
|
54268
54793
|
requestCatchUpSpace(params) {
|
|
54794
|
+
if (!this.syncUpdates)
|
|
54795
|
+
return Promise.resolve();
|
|
54269
54796
|
this.fenceLiveCursor({ kind: "space", spaceId: params.spaceId });
|
|
54270
54797
|
const previous = this.catchUpRequestedBySpaceId.get(params.spaceId);
|
|
54271
54798
|
this.catchUpRequestedBySpaceId.set(params.spaceId, {
|
|
@@ -54415,6 +54942,8 @@ class InlineSdkClient {
|
|
|
54415
54942
|
return false;
|
|
54416
54943
|
}
|
|
54417
54944
|
resolvePersistedChatPeer(chatId, updateSeq) {
|
|
54945
|
+
if (!this.syncUpdates)
|
|
54946
|
+
return Promise.resolve();
|
|
54418
54947
|
const previous = this.peerResolutionRequestedByChatId.get(chatId);
|
|
54419
54948
|
this.peerResolutionRequestedByChatId.set(chatId, {
|
|
54420
54949
|
...updateSeq != null || previous?.endSeq != null ? { endSeq: Math.max(previous?.endSeq ?? 0, updateSeq ?? 0) } : {},
|
|
@@ -55367,6 +55896,1167 @@ function readUsers(result, kind) {
|
|
|
55367
55896
|
return Array.isArray(users) ? users : [];
|
|
55368
55897
|
}
|
|
55369
55898
|
|
|
55899
|
+
// src/vendor/agent-activity/protocol.ts
|
|
55900
|
+
var BlockStatusValue = {
|
|
55901
|
+
unspecified: 0,
|
|
55902
|
+
pending: 1,
|
|
55903
|
+
running: 2,
|
|
55904
|
+
waiting: 3,
|
|
55905
|
+
done: 4,
|
|
55906
|
+
failed: 5,
|
|
55907
|
+
cancelled: 6
|
|
55908
|
+
};
|
|
55909
|
+
var DisclosureKindValue = {
|
|
55910
|
+
default: 0,
|
|
55911
|
+
progress: 1
|
|
55912
|
+
};
|
|
55913
|
+
var ActivityKindValue = {
|
|
55914
|
+
unspecified: 0,
|
|
55915
|
+
reasoning: 1,
|
|
55916
|
+
explore: 2,
|
|
55917
|
+
read: 3,
|
|
55918
|
+
search: 4,
|
|
55919
|
+
edit: 5,
|
|
55920
|
+
delete: 6,
|
|
55921
|
+
move: 7,
|
|
55922
|
+
command: 8,
|
|
55923
|
+
web: 9,
|
|
55924
|
+
tool: 10,
|
|
55925
|
+
agent: 11
|
|
55926
|
+
};
|
|
55927
|
+
var DiffChangeValue = {
|
|
55928
|
+
unspecified: 0,
|
|
55929
|
+
added: 1,
|
|
55930
|
+
modified: 2,
|
|
55931
|
+
deleted: 3,
|
|
55932
|
+
renamed: 4
|
|
55933
|
+
};
|
|
55934
|
+
|
|
55935
|
+
// src/vendor/agent-activity/doc.ts
|
|
55936
|
+
var statusValue = (status) => status === "none" ? BlockStatusValue.unspecified : BlockStatusValue[status];
|
|
55937
|
+
|
|
55938
|
+
class DocBuilder {
|
|
55939
|
+
text = "";
|
|
55940
|
+
blocks = [];
|
|
55941
|
+
isEmpty() {
|
|
55942
|
+
return this.text.trim() === "";
|
|
55943
|
+
}
|
|
55944
|
+
finish() {
|
|
55945
|
+
return { text: this.text.replace(/\n+$/, ""), blockContent: { blocks: this.blocks } };
|
|
55946
|
+
}
|
|
55947
|
+
span(text) {
|
|
55948
|
+
const offset = this.text.length;
|
|
55949
|
+
this.text += `${text}
|
|
55950
|
+
`;
|
|
55951
|
+
return { offset: BigInt(offset), length: BigInt(text.length) };
|
|
55952
|
+
}
|
|
55953
|
+
raw(text) {
|
|
55954
|
+
this.text += text;
|
|
55955
|
+
}
|
|
55956
|
+
nested(build) {
|
|
55957
|
+
const inner = new DocBuilder;
|
|
55958
|
+
inner.text = this.text;
|
|
55959
|
+
build(inner);
|
|
55960
|
+
this.text = inner.text;
|
|
55961
|
+
return inner.blocks;
|
|
55962
|
+
}
|
|
55963
|
+
paragraph(text) {
|
|
55964
|
+
if (text.trim() === "")
|
|
55965
|
+
return;
|
|
55966
|
+
this.blocks.push({ kind: { oneofKind: "paragraph", paragraph: this.span(text.trimEnd()) } });
|
|
55967
|
+
}
|
|
55968
|
+
footer(text) {
|
|
55969
|
+
this.blocks.push({ kind: { oneofKind: "footer", footer: this.span(text) } });
|
|
55970
|
+
}
|
|
55971
|
+
code(text, language) {
|
|
55972
|
+
if (text === "")
|
|
55973
|
+
return;
|
|
55974
|
+
const range = this.span(text.replace(/\n+$/, ""));
|
|
55975
|
+
this.blocks.push({ kind: { oneofKind: "code", code: { text: range, ...language ? { language } : {} } } });
|
|
55976
|
+
}
|
|
55977
|
+
steps(steps) {
|
|
55978
|
+
if (steps.length === 0)
|
|
55979
|
+
return;
|
|
55980
|
+
const blocks = steps.map(({ text, status }) => {
|
|
55981
|
+
this.raw(status === "done" ? "[x] " : status === "running" ? "[>] " : "[ ] ");
|
|
55982
|
+
return { text: this.span(text), status: statusValue(status) };
|
|
55983
|
+
});
|
|
55984
|
+
this.blocks.push({ kind: { oneofKind: "steps", steps: { steps: blocks } } });
|
|
55985
|
+
}
|
|
55986
|
+
diff(path, change, diff, counts) {
|
|
55987
|
+
const added = counts?.additions ?? (diff ? diff.split(`
|
|
55988
|
+
`).filter((line) => line.startsWith("+") && !line.startsWith("+++")).length : undefined);
|
|
55989
|
+
const removed = counts?.deletions ?? (diff ? diff.split(`
|
|
55990
|
+
`).filter((line) => line.startsWith("-") && !line.startsWith("---")).length : undefined);
|
|
55991
|
+
const pathRange = this.span(path);
|
|
55992
|
+
const text = diff ? this.span(diff.trimEnd()) : undefined;
|
|
55993
|
+
this.blocks.push({
|
|
55994
|
+
kind: {
|
|
55995
|
+
oneofKind: "diff",
|
|
55996
|
+
diff: {
|
|
55997
|
+
path: pathRange,
|
|
55998
|
+
...text ? { text } : {},
|
|
55999
|
+
change: DiffChangeValue[change],
|
|
56000
|
+
...added !== undefined ? { additions: added } : {},
|
|
56001
|
+
...removed !== undefined ? { deletions: removed } : {}
|
|
56002
|
+
}
|
|
56003
|
+
}
|
|
56004
|
+
});
|
|
56005
|
+
}
|
|
56006
|
+
disclosure(summary, options, build) {
|
|
56007
|
+
const summaryRange = { offset: BigInt(this.text.length), length: BigInt(summary.length) };
|
|
56008
|
+
this.raw(summary);
|
|
56009
|
+
const meta = options.meta ? this.metaRange(options.meta) : undefined;
|
|
56010
|
+
this.raw(`
|
|
56011
|
+
`);
|
|
56012
|
+
const children = this.nested(build);
|
|
56013
|
+
this.blocks.push({
|
|
56014
|
+
kind: {
|
|
56015
|
+
oneofKind: "disclosure",
|
|
56016
|
+
disclosure: {
|
|
56017
|
+
summary: summaryRange,
|
|
56018
|
+
kind: DisclosureKindValue.default,
|
|
56019
|
+
children,
|
|
56020
|
+
activityKind: ActivityKindValue[options.activity ?? "unspecified"],
|
|
56021
|
+
status: statusValue(options.status ?? "none"),
|
|
56022
|
+
...meta ? { meta } : {}
|
|
56023
|
+
}
|
|
56024
|
+
}
|
|
56025
|
+
});
|
|
56026
|
+
}
|
|
56027
|
+
progress(summary, working, elapsed, build) {
|
|
56028
|
+
const summaryRange = { offset: BigInt(this.text.length), length: BigInt(summary.length) };
|
|
56029
|
+
this.raw(summary);
|
|
56030
|
+
const live = working ? elapsed : undefined;
|
|
56031
|
+
const meta = live ? this.metaRange(live.text) : undefined;
|
|
56032
|
+
this.raw(`
|
|
56033
|
+
`);
|
|
56034
|
+
const children = this.nested(build);
|
|
56035
|
+
this.blocks.push({
|
|
56036
|
+
kind: {
|
|
56037
|
+
oneofKind: "disclosure",
|
|
56038
|
+
disclosure: {
|
|
56039
|
+
summary: summaryRange,
|
|
56040
|
+
kind: working ? DisclosureKindValue.progress : DisclosureKindValue.default,
|
|
56041
|
+
initiallyOpen: working,
|
|
56042
|
+
children,
|
|
56043
|
+
activityKind: ActivityKindValue.unspecified,
|
|
56044
|
+
status: BlockStatusValue.unspecified,
|
|
56045
|
+
...meta ? { meta } : {},
|
|
56046
|
+
...live ? { startedAt: BigInt(Math.max(0, Math.floor(live.startedAtSeconds))) } : {}
|
|
56047
|
+
}
|
|
56048
|
+
}
|
|
56049
|
+
});
|
|
56050
|
+
}
|
|
56051
|
+
metaRange(meta) {
|
|
56052
|
+
this.raw(" · ");
|
|
56053
|
+
const range = { offset: BigInt(this.text.length), length: BigInt(meta.length) };
|
|
56054
|
+
this.raw(meta);
|
|
56055
|
+
return range;
|
|
56056
|
+
}
|
|
56057
|
+
}
|
|
56058
|
+
// src/vendor/agent-activity/limits.ts
|
|
56059
|
+
var MAX_TEXT_UTF16 = 1e5;
|
|
56060
|
+
var MAX_TEXT_BYTES = 400000;
|
|
56061
|
+
var MAX_BLOCKS = 1024;
|
|
56062
|
+
var MAX_DEPTH = 16;
|
|
56063
|
+
function docSize(doc) {
|
|
56064
|
+
const size = { utf16: doc.text.length, bytes: Buffer.byteLength(doc.text, "utf8"), blocks: 0, depth: 0 };
|
|
56065
|
+
const walk = (blocks, depth) => {
|
|
56066
|
+
if (blocks.length > 0)
|
|
56067
|
+
size.depth = Math.max(size.depth, depth);
|
|
56068
|
+
for (const block of blocks) {
|
|
56069
|
+
size.blocks += 1;
|
|
56070
|
+
switch (block.kind.oneofKind) {
|
|
56071
|
+
case "disclosure":
|
|
56072
|
+
walk(block.kind.disclosure.children, depth + 1);
|
|
56073
|
+
break;
|
|
56074
|
+
case "callout":
|
|
56075
|
+
walk(block.kind.callout.children, depth + 1);
|
|
56076
|
+
break;
|
|
56077
|
+
case "quote":
|
|
56078
|
+
walk(block.kind.quote.children, depth + 1);
|
|
56079
|
+
break;
|
|
56080
|
+
case "list":
|
|
56081
|
+
for (const item of block.kind.list.items)
|
|
56082
|
+
walk(item.children, depth + 1);
|
|
56083
|
+
break;
|
|
56084
|
+
default:
|
|
56085
|
+
break;
|
|
56086
|
+
}
|
|
56087
|
+
}
|
|
56088
|
+
};
|
|
56089
|
+
walk(doc.blockContent.blocks, 0);
|
|
56090
|
+
return size;
|
|
56091
|
+
}
|
|
56092
|
+
function docWithin(doc, share = 1) {
|
|
56093
|
+
const size = docSize(doc);
|
|
56094
|
+
return size.utf16 <= MAX_TEXT_UTF16 * share && size.bytes <= MAX_TEXT_BYTES * share && size.blocks <= MAX_BLOCKS * share && size.depth <= MAX_DEPTH;
|
|
56095
|
+
}
|
|
56096
|
+
function progressFits(doc) {
|
|
56097
|
+
return docWithin(doc, 0.8);
|
|
56098
|
+
}
|
|
56099
|
+
// src/vendor/agent-activity/text.ts
|
|
56100
|
+
var MAX_DETAIL_CHARS = 2000;
|
|
56101
|
+
var MAX_ROW_DIFF_CHARS = 8000;
|
|
56102
|
+
function elapsedText(ms) {
|
|
56103
|
+
const seconds = Math.floor(Math.max(0, Number.isFinite(ms) ? ms : 0) / 1000);
|
|
56104
|
+
if (seconds < 60)
|
|
56105
|
+
return `${Math.max(1, seconds)}s`;
|
|
56106
|
+
if (seconds < 3600)
|
|
56107
|
+
return `${Math.floor(seconds / 60)}m ${seconds % 60}s`;
|
|
56108
|
+
return `${Math.floor(seconds / 3600)}h ${Math.floor(seconds % 3600 / 60)}m`;
|
|
56109
|
+
}
|
|
56110
|
+
function firstLine(text, max) {
|
|
56111
|
+
const line = (text.split(`
|
|
56112
|
+
`).find((candidate) => candidate.trim() !== "") ?? "").trim().replace(/^\*+|\*+$/g, "").trim();
|
|
56113
|
+
const characters = Array.from(line);
|
|
56114
|
+
return characters.length > max ? `${characters.slice(0, max).join("")}…` : line;
|
|
56115
|
+
}
|
|
56116
|
+
function tail(text, max = MAX_DETAIL_CHARS) {
|
|
56117
|
+
const characters = Array.from(text);
|
|
56118
|
+
if (characters.length <= max)
|
|
56119
|
+
return text;
|
|
56120
|
+
const cutText = characters.slice(characters.length - max).join("");
|
|
56121
|
+
const cut = text.length - cutText.length;
|
|
56122
|
+
const newline = text.indexOf(`
|
|
56123
|
+
`, cut);
|
|
56124
|
+
const start = newline >= 0 && newline + 1 < text.length ? newline + 1 : cut;
|
|
56125
|
+
const hidden = Math.max(1, text.slice(0, start).split(`
|
|
56126
|
+
`).length - (text.slice(0, start).endsWith(`
|
|
56127
|
+
`) ? 1 : 0));
|
|
56128
|
+
return `… +${hidden} ${hidden === 1 ? "line" : "lines"}
|
|
56129
|
+
${text.slice(start)}`;
|
|
56130
|
+
}
|
|
56131
|
+
function head(text, max = MAX_DETAIL_CHARS) {
|
|
56132
|
+
const characters = Array.from(text);
|
|
56133
|
+
return characters.length <= max ? text : `${characters.slice(0, max).join("")}…`;
|
|
56134
|
+
}
|
|
56135
|
+
function relativePath(path, folder) {
|
|
56136
|
+
if (!folder)
|
|
56137
|
+
return path;
|
|
56138
|
+
const base = folder.endsWith("/") ? folder : `${folder}/`;
|
|
56139
|
+
return path.startsWith(base) && path.length > base.length ? path.slice(base.length) : path;
|
|
56140
|
+
}
|
|
56141
|
+
function baseName(path) {
|
|
56142
|
+
const trimmed = path.replace(/\/+$/, "");
|
|
56143
|
+
const index = trimmed.lastIndexOf("/");
|
|
56144
|
+
return index >= 0 ? trimmed.slice(index + 1) || trimmed : trimmed;
|
|
56145
|
+
}
|
|
56146
|
+
var SECRET_ASSIGNMENT = /\b([A-Za-z0-9_.-]*(?:api[_-]?key|access[_-]?key|secret|token|passw(?:or)?d|credential|auth)[A-Za-z0-9_.-]*)(\s*[=:]\s*)("[^"]*"|'[^']*'|[^\s"'&]+)/gi;
|
|
56147
|
+
var BEARER = /\b(bearer|basic)\s+[A-Za-z0-9._~+/-]{8,}=*/gi;
|
|
56148
|
+
var KNOWN_KEYS = /\b(?:sk-(?:ant-|proj-)?[A-Za-z0-9_-]{16,}|gh[pousr]_[A-Za-z0-9]{20,}|xox[abprs]-[A-Za-z0-9-]{10,}|AKIA[0-9A-Z]{16}|AIza[0-9A-Za-z_-]{30,})\b/g;
|
|
56149
|
+
var URL_CREDENTIALS = /\b([a-z][a-z0-9+.-]*:\/\/)[^\s/:@]+:[^\s/@]+@/gi;
|
|
56150
|
+
function redactSecrets(text) {
|
|
56151
|
+
return text.replace(BEARER, (_match, scheme) => `${scheme} •••`).replace(SECRET_ASSIGNMENT, (match, key, separator, value) => /^(bearer|basic)$/i.test(value) ? match : `${key}${separator}•••`).replace(/(--?(?:password|passwd|token|secret|api-key|apikey)\s+)(\S+)/gi, "$1•••").replace(KNOWN_KEYS, "•••").replace(URL_CREDENTIALS, "$1•••@");
|
|
56152
|
+
}
|
|
56153
|
+
|
|
56154
|
+
// src/vendor/agent-activity/renderer.ts
|
|
56155
|
+
var busy = (row) => row.state === "running" || row.state === "waiting";
|
|
56156
|
+
var status = (state) => state;
|
|
56157
|
+
var exploring = (body) => body?.kind === "read" || body?.kind === "search" || body?.kind === "list";
|
|
56158
|
+
|
|
56159
|
+
class ProgressRenderer {
|
|
56160
|
+
options;
|
|
56161
|
+
nextSlot = 1;
|
|
56162
|
+
slot;
|
|
56163
|
+
now = 0;
|
|
56164
|
+
notes = 0;
|
|
56165
|
+
constructor(options = {}) {
|
|
56166
|
+
this.options = options;
|
|
56167
|
+
}
|
|
56168
|
+
get isOpen() {
|
|
56169
|
+
return this.slot !== undefined;
|
|
56170
|
+
}
|
|
56171
|
+
apply(event, at = Date.now()) {
|
|
56172
|
+
this.now = at;
|
|
56173
|
+
const ops = [];
|
|
56174
|
+
switch (event.type) {
|
|
56175
|
+
case "turn.start":
|
|
56176
|
+
this.openSlot();
|
|
56177
|
+
this.pushProgress(ops, true);
|
|
56178
|
+
break;
|
|
56179
|
+
case "item":
|
|
56180
|
+
this.item(event);
|
|
56181
|
+
this.pushProgress(ops, event.state === "waiting" || event.state === "failed");
|
|
56182
|
+
break;
|
|
56183
|
+
case "commentary": {
|
|
56184
|
+
const text = event.text.trim();
|
|
56185
|
+
if (!text)
|
|
56186
|
+
break;
|
|
56187
|
+
this.openSlot();
|
|
56188
|
+
this.notes += 1;
|
|
56189
|
+
this.slot.rows.push({ id: `note:${this.notes}`, body: { kind: "note", text }, state: "done", startedAt: at });
|
|
56190
|
+
this.pushProgress(ops, false);
|
|
56191
|
+
break;
|
|
56192
|
+
}
|
|
56193
|
+
case "waiting":
|
|
56194
|
+
if (!this.slot)
|
|
56195
|
+
break;
|
|
56196
|
+
this.markWaiting(event.id, event.waiting);
|
|
56197
|
+
this.pushProgress(ops, true);
|
|
56198
|
+
break;
|
|
56199
|
+
case "split":
|
|
56200
|
+
this.split(ops);
|
|
56201
|
+
break;
|
|
56202
|
+
case "turn.end":
|
|
56203
|
+
this.endTurn(event.outcome, ops);
|
|
56204
|
+
break;
|
|
56205
|
+
}
|
|
56206
|
+
return ops;
|
|
56207
|
+
}
|
|
56208
|
+
openSlot() {
|
|
56209
|
+
if (!this.slot)
|
|
56210
|
+
this.slot = { id: this.nextSlot++, startedAt: this.now, rows: [] };
|
|
56211
|
+
}
|
|
56212
|
+
item(event) {
|
|
56213
|
+
this.openSlot();
|
|
56214
|
+
const slot = this.slot;
|
|
56215
|
+
let row = slot.rows.find((candidate) => candidate.id === event.id);
|
|
56216
|
+
if (!row) {
|
|
56217
|
+
row = { id: event.id, state: "running", startedAt: this.now };
|
|
56218
|
+
if (event.parent !== undefined)
|
|
56219
|
+
row.parent = event.parent;
|
|
56220
|
+
slot.rows.push(row);
|
|
56221
|
+
}
|
|
56222
|
+
if (event.body)
|
|
56223
|
+
row.body = mergeBody(row.body, event.body);
|
|
56224
|
+
if (event.state) {
|
|
56225
|
+
const ending = !busy({ ...row, state: event.state }) && busy(row);
|
|
56226
|
+
row.state = event.state;
|
|
56227
|
+
if (event.durationMs !== undefined)
|
|
56228
|
+
row.durationMs = event.durationMs;
|
|
56229
|
+
else if (ending && row.durationMs === undefined)
|
|
56230
|
+
row.durationMs = this.now - row.startedAt;
|
|
56231
|
+
} else if (event.durationMs !== undefined) {
|
|
56232
|
+
row.durationMs = event.durationMs;
|
|
56233
|
+
}
|
|
56234
|
+
}
|
|
56235
|
+
markWaiting(id, waiting) {
|
|
56236
|
+
const rows = this.slot?.rows ?? [];
|
|
56237
|
+
const target = id !== undefined ? rows.find((row) => row.id === id) : [...rows].reverse().find((row) => waiting ? row.state === "running" : row.state === "waiting");
|
|
56238
|
+
if (!target)
|
|
56239
|
+
return;
|
|
56240
|
+
if (waiting && target.state === "running")
|
|
56241
|
+
target.state = "waiting";
|
|
56242
|
+
else if (!waiting && target.state === "waiting")
|
|
56243
|
+
target.state = "running";
|
|
56244
|
+
}
|
|
56245
|
+
split(ops) {
|
|
56246
|
+
const slot = this.slot;
|
|
56247
|
+
if (!slot)
|
|
56248
|
+
return;
|
|
56249
|
+
const carried = slot.rows.filter(busy);
|
|
56250
|
+
const kept = { ...slot, rows: slot.rows.filter((row) => !busy(row)) };
|
|
56251
|
+
ops.push({ type: "end", slot: slot.id, doc: this.endedDoc(kept, `Worked for ${elapsedText(this.now - slot.startedAt)}`) });
|
|
56252
|
+
this.slot = undefined;
|
|
56253
|
+
if (carried.length > 0) {
|
|
56254
|
+
this.openSlot();
|
|
56255
|
+
this.slot.rows.push(...carried);
|
|
56256
|
+
this.pushProgress(ops, true);
|
|
56257
|
+
}
|
|
56258
|
+
}
|
|
56259
|
+
endTurn(outcome, ops) {
|
|
56260
|
+
const slot = this.slot;
|
|
56261
|
+
if (!slot)
|
|
56262
|
+
return;
|
|
56263
|
+
for (const row of slot.rows) {
|
|
56264
|
+
if (!busy(row))
|
|
56265
|
+
continue;
|
|
56266
|
+
row.state = outcome === "success" ? "done" : "cancelled";
|
|
56267
|
+
row.durationMs ??= this.now - row.startedAt;
|
|
56268
|
+
}
|
|
56269
|
+
const verb = outcome === "cancelled" ? "Stopped after" : outcome === "failure" ? "Failed after" : "Worked for";
|
|
56270
|
+
const failed = unresolvedFailures(slot.rows);
|
|
56271
|
+
const summary = `${verb} ${elapsedText(this.now - slot.startedAt)}${failed > 0 ? ` · ${failed} failed` : ""}`;
|
|
56272
|
+
ops.push({ type: "end", slot: slot.id, doc: this.endedDoc(slot, summary) });
|
|
56273
|
+
this.slot = undefined;
|
|
56274
|
+
}
|
|
56275
|
+
pushProgress(ops, urgent) {
|
|
56276
|
+
if (!this.slot)
|
|
56277
|
+
return;
|
|
56278
|
+
let doc = this.progressDoc(this.slot);
|
|
56279
|
+
if (!progressFits(doc) && this.splitForSize(ops))
|
|
56280
|
+
doc = this.progressDoc(this.slot);
|
|
56281
|
+
ops.push({ type: "progress", slot: this.slot.id, doc, urgent });
|
|
56282
|
+
}
|
|
56283
|
+
splitForSize(ops) {
|
|
56284
|
+
const slot = this.slot;
|
|
56285
|
+
const summary = `Worked for ${elapsedText(this.now - slot.startedAt)} · continued below`;
|
|
56286
|
+
const tops = slot.rows.filter((row) => topLevel(row, slot.rows));
|
|
56287
|
+
let finished = 0;
|
|
56288
|
+
while (finished < tops.length && !busy(tops[finished]))
|
|
56289
|
+
finished += 1;
|
|
56290
|
+
const fits = (count) => progressFits(this.endedDoc(subset(slot, tops.slice(0, count)), summary));
|
|
56291
|
+
let low = 0;
|
|
56292
|
+
let high = finished;
|
|
56293
|
+
while (low < high) {
|
|
56294
|
+
const middle = Math.ceil((low + high) / 2);
|
|
56295
|
+
if (fits(middle))
|
|
56296
|
+
low = middle;
|
|
56297
|
+
else
|
|
56298
|
+
high = middle - 1;
|
|
56299
|
+
}
|
|
56300
|
+
if (low === 0)
|
|
56301
|
+
return false;
|
|
56302
|
+
const kept = subset(slot, tops.slice(0, low));
|
|
56303
|
+
ops.push({ type: "end", slot: slot.id, doc: this.endedDoc(kept, summary) });
|
|
56304
|
+
this.slot = {
|
|
56305
|
+
id: this.nextSlot++,
|
|
56306
|
+
startedAt: this.now,
|
|
56307
|
+
rows: slot.rows.filter((row) => !kept.rows.includes(row))
|
|
56308
|
+
};
|
|
56309
|
+
return true;
|
|
56310
|
+
}
|
|
56311
|
+
progressDoc(slot) {
|
|
56312
|
+
const builder = new DocBuilder;
|
|
56313
|
+
builder.progress("Working", true, { startedAtSeconds: slot.startedAt / 1000, text: elapsedText(this.now - slot.startedAt) }, (inner) => this.writeSlot(inner, slot));
|
|
56314
|
+
return builder.finish();
|
|
56315
|
+
}
|
|
56316
|
+
endedDoc(slot, summary) {
|
|
56317
|
+
const builder = new DocBuilder;
|
|
56318
|
+
const rows = new DocBuilder;
|
|
56319
|
+
this.writeSlot(rows, slot);
|
|
56320
|
+
if (rows.isEmpty())
|
|
56321
|
+
builder.footer(summary);
|
|
56322
|
+
else
|
|
56323
|
+
builder.progress(summary, false, undefined, (inner) => this.writeSlot(inner, slot));
|
|
56324
|
+
return builder.finish();
|
|
56325
|
+
}
|
|
56326
|
+
writeSlot(builder, slot) {
|
|
56327
|
+
const rows = slot.rows.filter((row) => topLevel(row, slot.rows) && shows(row));
|
|
56328
|
+
let start = 0;
|
|
56329
|
+
while (start < rows.length) {
|
|
56330
|
+
let end = start + 1;
|
|
56331
|
+
while (end < rows.length && !startsPhase(rows[end]))
|
|
56332
|
+
end += 1;
|
|
56333
|
+
const first = rows[start];
|
|
56334
|
+
if (startsPhase(first) && end > start + 1)
|
|
56335
|
+
this.writePhase(builder, slot, first, rows.slice(start + 1, end));
|
|
56336
|
+
else if (startsPhase(first))
|
|
56337
|
+
this.writeRow(builder, slot, first);
|
|
56338
|
+
else
|
|
56339
|
+
this.writeRuns(builder, slot, rows.slice(start, end));
|
|
56340
|
+
start = end;
|
|
56341
|
+
}
|
|
56342
|
+
}
|
|
56343
|
+
writePhase(builder, slot, headRow, rows) {
|
|
56344
|
+
const text = headRow.body?.kind === "reasoning" ? headRow.body.summary : "";
|
|
56345
|
+
const title = firstLine(text, 80);
|
|
56346
|
+
const running = [headRow, ...rows].some(busy);
|
|
56347
|
+
builder.disclosure(title, { activity: "reasoning", status: running ? "running" : "done" }, (inner) => {
|
|
56348
|
+
if (text.trim() !== title)
|
|
56349
|
+
inner.paragraph(tail(text));
|
|
56350
|
+
this.writeRuns(inner, slot, rows);
|
|
56351
|
+
});
|
|
56352
|
+
}
|
|
56353
|
+
writeRuns(builder, slot, rows) {
|
|
56354
|
+
let index = 0;
|
|
56355
|
+
while (index < rows.length) {
|
|
56356
|
+
const fold = foldOf(rows[index]);
|
|
56357
|
+
let end = index + 1;
|
|
56358
|
+
if (fold !== "none")
|
|
56359
|
+
while (end < rows.length && foldOf(rows[end]) === fold)
|
|
56360
|
+
end += 1;
|
|
56361
|
+
const run = rows.slice(index, end);
|
|
56362
|
+
if (fold === "explore")
|
|
56363
|
+
this.writeExplore(builder, run);
|
|
56364
|
+
else if (fold === "command" && run.length > 1)
|
|
56365
|
+
this.writeCommands(builder, slot, run);
|
|
56366
|
+
else if (fold === "edit" && run.length > 1)
|
|
56367
|
+
this.writeEdits(builder, slot, run);
|
|
56368
|
+
else
|
|
56369
|
+
for (const row of run)
|
|
56370
|
+
this.writeRow(builder, slot, row);
|
|
56371
|
+
index = end;
|
|
56372
|
+
}
|
|
56373
|
+
}
|
|
56374
|
+
writeExplore(builder, run) {
|
|
56375
|
+
const running = run.some(busy);
|
|
56376
|
+
const failed = run.filter((row) => row.state === "failed").length;
|
|
56377
|
+
const lines = [];
|
|
56378
|
+
let reads = [];
|
|
56379
|
+
const flush = () => {
|
|
56380
|
+
if (reads.length > 0)
|
|
56381
|
+
lines.push(`Read ${reads.join(", ")}`);
|
|
56382
|
+
reads = [];
|
|
56383
|
+
};
|
|
56384
|
+
for (const row of run) {
|
|
56385
|
+
const body = row.body;
|
|
56386
|
+
const suffix = row.state === "failed" ? " (failed)" : "";
|
|
56387
|
+
if (body?.kind === "read") {
|
|
56388
|
+
if (row.state === "failed") {
|
|
56389
|
+
flush();
|
|
56390
|
+
lines.push(`Read ${this.path(body.path)}${suffix}`);
|
|
56391
|
+
} else {
|
|
56392
|
+
const name = baseName(body.path);
|
|
56393
|
+
if (!reads.includes(name))
|
|
56394
|
+
reads.push(name);
|
|
56395
|
+
}
|
|
56396
|
+
} else if (body?.kind === "search") {
|
|
56397
|
+
flush();
|
|
56398
|
+
const query = body.query ? redactSecrets(firstLine(body.query, 80)) : undefined;
|
|
56399
|
+
const where = body.path ? this.path(body.path) : undefined;
|
|
56400
|
+
lines.push(`${query && where ? `Search ${query} in ${where}` : query ? `Search ${query}` : where ? `Search in ${where}` : "Search"}${suffix}`);
|
|
56401
|
+
} else if (body?.kind === "list") {
|
|
56402
|
+
flush();
|
|
56403
|
+
lines.push(`List ${body.path ? this.path(body.path) : "."}${suffix}`);
|
|
56404
|
+
}
|
|
56405
|
+
}
|
|
56406
|
+
flush();
|
|
56407
|
+
builder.disclosure(running ? "Exploring" : "Explored", { activity: "explore", status: running ? "running" : "done", ...failed > 0 ? { meta: `${failed} failed` } : {} }, (inner) => {
|
|
56408
|
+
for (const line of lines)
|
|
56409
|
+
inner.paragraph(line);
|
|
56410
|
+
});
|
|
56411
|
+
}
|
|
56412
|
+
writeCommands(builder, slot, run) {
|
|
56413
|
+
const total = run.reduce((sum, row) => sum + (row.durationMs ?? 0), 0);
|
|
56414
|
+
builder.disclosure(`Ran ${run.length} commands`, { activity: "command", status: "done", ...total > 0 ? { meta: elapsedText(Math.max(total, 1000)) } : {} }, (inner) => {
|
|
56415
|
+
for (const row of run)
|
|
56416
|
+
this.writeRow(inner, slot, row);
|
|
56417
|
+
});
|
|
56418
|
+
}
|
|
56419
|
+
writeEdits(builder, slot, run) {
|
|
56420
|
+
const files = run.flatMap((row) => row.body?.kind === "edit" ? row.body.files : []);
|
|
56421
|
+
const { added, removed } = files.reduce((sum, file) => {
|
|
56422
|
+
const counts = lineCounts(file);
|
|
56423
|
+
return { added: sum.added + counts.added, removed: sum.removed + counts.removed };
|
|
56424
|
+
}, { added: 0, removed: 0 });
|
|
56425
|
+
const count = new Set(files.map((file) => file.path)).size;
|
|
56426
|
+
const meta = countsMeta(added, removed);
|
|
56427
|
+
builder.disclosure(count === 1 ? "Edited 1 file" : `Edited ${count} files`, { activity: "edit", status: "done", ...meta ? { meta } : {} }, (inner) => {
|
|
56428
|
+
for (const row of run)
|
|
56429
|
+
this.writeRow(inner, slot, row);
|
|
56430
|
+
});
|
|
56431
|
+
}
|
|
56432
|
+
writeRow(builder, slot, row) {
|
|
56433
|
+
const body = row.body;
|
|
56434
|
+
if (body?.kind === "note") {
|
|
56435
|
+
builder.paragraph(body.text);
|
|
56436
|
+
return;
|
|
56437
|
+
}
|
|
56438
|
+
const { title, meta, activity } = this.rowTitle(row);
|
|
56439
|
+
const children = body?.kind === "agent" ? slot.rows.filter((candidate) => candidate.parent === row.id && shows(candidate)) : [];
|
|
56440
|
+
builder.disclosure(title, { activity, status: status(row.state), ...meta ? { meta } : {} }, (inner) => {
|
|
56441
|
+
this.rowDetail(inner, row);
|
|
56442
|
+
if (children.length > 0)
|
|
56443
|
+
this.writeRuns(inner, slot, children);
|
|
56444
|
+
});
|
|
56445
|
+
}
|
|
56446
|
+
rowTitle(row) {
|
|
56447
|
+
const body = row.body;
|
|
56448
|
+
const running = busy(row);
|
|
56449
|
+
const time = !running && row.durationMs !== undefined ? elapsedText(Math.max(row.durationMs, 1000)) : undefined;
|
|
56450
|
+
switch (body?.kind) {
|
|
56451
|
+
case "command": {
|
|
56452
|
+
const code = body.exitCode !== undefined && body.exitCode !== 0 ? `exit ${body.exitCode}` : undefined;
|
|
56453
|
+
const meta = [code, time].filter(Boolean).join(" · ") || undefined;
|
|
56454
|
+
const command = firstLine(redactSecrets(body.command), 80);
|
|
56455
|
+
return { title: `${running ? "Running" : "Ran"} ${command}`.trim(), ...meta ? { meta } : {}, activity: "command" };
|
|
56456
|
+
}
|
|
56457
|
+
case "read":
|
|
56458
|
+
return { title: `Read ${this.path(body.path)}`, activity: "read" };
|
|
56459
|
+
case "search":
|
|
56460
|
+
return { title: body.query ? `Search ${redactSecrets(firstLine(body.query, 80))}` : "Search", activity: "search" };
|
|
56461
|
+
case "list":
|
|
56462
|
+
return { title: `List ${body.path ? this.path(body.path) : "."}`, activity: "explore" };
|
|
56463
|
+
case "edit": {
|
|
56464
|
+
const [only, ...rest] = body.files;
|
|
56465
|
+
const verb = (change) => change === "added" ? "Added" : change === "deleted" ? "Deleted" : change === "renamed" ? "Renamed" : "Edited";
|
|
56466
|
+
const title = only && rest.length === 0 ? `${verb(only.change)} ${this.path(only.path)}` : `Edited ${body.files.length} files`;
|
|
56467
|
+
const { added, removed } = body.files.reduce((sum, file) => {
|
|
56468
|
+
const counts = lineCounts(file);
|
|
56469
|
+
return { added: sum.added + counts.added, removed: sum.removed + counts.removed };
|
|
56470
|
+
}, { added: 0, removed: 0 });
|
|
56471
|
+
const meta = countsMeta(added, removed);
|
|
56472
|
+
const deletes = body.files.length > 0 && body.files.every((file) => file.change === "deleted");
|
|
56473
|
+
return { title, ...meta ? { meta } : {}, activity: deletes ? "delete" : "edit" };
|
|
56474
|
+
}
|
|
56475
|
+
case "web":
|
|
56476
|
+
if (body.query)
|
|
56477
|
+
return { title: `Searched the web for ${redactSecrets(firstLine(body.query, 80))}`, activity: "web" };
|
|
56478
|
+
return { title: body.url ? `Read ${redactSecrets(shortUrl(body.url))}` : "Browsed the web", activity: "web" };
|
|
56479
|
+
case "tool": {
|
|
56480
|
+
const title = firstLine(redactSecrets(body.title || body.name), 90);
|
|
56481
|
+
return { title, ...time ? { meta: time } : {}, activity: "tool" };
|
|
56482
|
+
}
|
|
56483
|
+
case "agent": {
|
|
56484
|
+
const title = body.title ? `Sub-agent: ${firstLine(redactSecrets(body.title), 70)}` : "Sub-agent";
|
|
56485
|
+
return { title, ...body.meta ? { meta: body.meta } : time ? { meta: time } : {}, activity: "agent" };
|
|
56486
|
+
}
|
|
56487
|
+
case "plan":
|
|
56488
|
+
return { title: "Updated plan", activity: "unspecified" };
|
|
56489
|
+
case "reasoning":
|
|
56490
|
+
return { title: firstLine(body.summary, 80) || "Thinking", activity: "reasoning" };
|
|
56491
|
+
case "compaction":
|
|
56492
|
+
return { title: running ? "Compacting the conversation" : "Compacted the conversation", activity: "tool" };
|
|
56493
|
+
default:
|
|
56494
|
+
return { title: "Working", activity: "unspecified" };
|
|
56495
|
+
}
|
|
56496
|
+
}
|
|
56497
|
+
rowDetail(builder, row) {
|
|
56498
|
+
const body = row.body;
|
|
56499
|
+
switch (body?.kind) {
|
|
56500
|
+
case "command":
|
|
56501
|
+
builder.code(`$ ${head(redactSecrets(body.command))}`, "sh");
|
|
56502
|
+
if (body.output)
|
|
56503
|
+
builder.code(tail(redactSecrets(body.output)));
|
|
56504
|
+
if (body.exitCode !== undefined && body.exitCode !== 0)
|
|
56505
|
+
builder.paragraph(`Exit code ${body.exitCode}`);
|
|
56506
|
+
break;
|
|
56507
|
+
case "edit": {
|
|
56508
|
+
let shown = 0;
|
|
56509
|
+
for (const file of body.files) {
|
|
56510
|
+
const diff = file.diff && shown < MAX_ROW_DIFF_CHARS ? tail(redactSecrets(file.diff)) : undefined;
|
|
56511
|
+
shown += diff?.length ?? 0;
|
|
56512
|
+
const counts = {
|
|
56513
|
+
...file.additions !== undefined ? { additions: file.additions } : {},
|
|
56514
|
+
...file.deletions !== undefined ? { deletions: file.deletions } : {}
|
|
56515
|
+
};
|
|
56516
|
+
builder.diff(this.path(file.path), file.change ?? "modified", diff, counts);
|
|
56517
|
+
}
|
|
56518
|
+
break;
|
|
56519
|
+
}
|
|
56520
|
+
case "tool":
|
|
56521
|
+
if (body.input)
|
|
56522
|
+
builder.code(tail(redactSecrets(body.input)));
|
|
56523
|
+
if (body.output)
|
|
56524
|
+
builder.code(tail(redactSecrets(body.output)));
|
|
56525
|
+
if (body.error)
|
|
56526
|
+
builder.paragraph(redactSecrets(firstLine(body.error, 500)));
|
|
56527
|
+
break;
|
|
56528
|
+
case "plan":
|
|
56529
|
+
if (body.explanation)
|
|
56530
|
+
builder.paragraph(body.explanation);
|
|
56531
|
+
builder.steps(body.steps.map((step) => ({
|
|
56532
|
+
text: step.text,
|
|
56533
|
+
status: step.status === "completed" ? "done" : step.status === "in_progress" ? "running" : "none"
|
|
56534
|
+
})));
|
|
56535
|
+
break;
|
|
56536
|
+
case "reasoning": {
|
|
56537
|
+
const title = firstLine(body.summary, 80);
|
|
56538
|
+
if (body.summary.trim() !== title)
|
|
56539
|
+
builder.paragraph(tail(body.summary));
|
|
56540
|
+
break;
|
|
56541
|
+
}
|
|
56542
|
+
default:
|
|
56543
|
+
break;
|
|
56544
|
+
}
|
|
56545
|
+
}
|
|
56546
|
+
path(path) {
|
|
56547
|
+
return relativePath(path, this.options.folder);
|
|
56548
|
+
}
|
|
56549
|
+
}
|
|
56550
|
+
function mergeBody(previous, next) {
|
|
56551
|
+
if (!previous || previous.kind !== next.kind)
|
|
56552
|
+
return next;
|
|
56553
|
+
const merged = { ...previous };
|
|
56554
|
+
for (const [key, value] of Object.entries(next))
|
|
56555
|
+
if (value !== undefined)
|
|
56556
|
+
merged[key] = value;
|
|
56557
|
+
return merged;
|
|
56558
|
+
}
|
|
56559
|
+
function topLevel(row, rows) {
|
|
56560
|
+
return row.parent === undefined || !rows.some((candidate) => candidate.id === row.parent && candidate.body?.kind === "agent");
|
|
56561
|
+
}
|
|
56562
|
+
function shows(row) {
|
|
56563
|
+
if (!row.body)
|
|
56564
|
+
return busy(row);
|
|
56565
|
+
return !(row.body.kind === "reasoning" && row.body.summary.trim() === "");
|
|
56566
|
+
}
|
|
56567
|
+
function startsPhase(row) {
|
|
56568
|
+
return row.body?.kind === "reasoning" && row.body.summary.trim() !== "";
|
|
56569
|
+
}
|
|
56570
|
+
function foldOf(row) {
|
|
56571
|
+
if (exploring(row.body))
|
|
56572
|
+
return "explore";
|
|
56573
|
+
if (row.body?.kind === "command" && row.state === "done" && (row.body.exitCode ?? 0) === 0)
|
|
56574
|
+
return "command";
|
|
56575
|
+
if (row.body?.kind === "edit" && row.state === "done")
|
|
56576
|
+
return "edit";
|
|
56577
|
+
return "none";
|
|
56578
|
+
}
|
|
56579
|
+
function unresolvedFailures(rows) {
|
|
56580
|
+
const keyed = rows.flatMap((row) => {
|
|
56581
|
+
const body = row.body;
|
|
56582
|
+
if (body?.kind === "command") {
|
|
56583
|
+
const failed = row.state === "failed" || body.exitCode !== undefined && body.exitCode !== 0;
|
|
56584
|
+
return [{ key: `command:${body.command}`, failed }];
|
|
56585
|
+
}
|
|
56586
|
+
if (body?.kind === "tool")
|
|
56587
|
+
return [{ key: `tool:${body.name}:${body.title ?? ""}`, failed: row.state === "failed" }];
|
|
56588
|
+
return [];
|
|
56589
|
+
});
|
|
56590
|
+
return keyed.filter((entry, index) => entry.failed && !keyed.slice(index + 1).some((later) => later.key === entry.key && !later.failed)).length;
|
|
56591
|
+
}
|
|
56592
|
+
function subset(slot, tops) {
|
|
56593
|
+
const keep = new Set(tops);
|
|
56594
|
+
const parents = tops.filter((row) => row.body?.kind === "agent").map((row) => row.id);
|
|
56595
|
+
while (parents.length > 0) {
|
|
56596
|
+
const parent = parents.pop();
|
|
56597
|
+
for (const row of slot.rows) {
|
|
56598
|
+
if (!keep.has(row) && row.parent === parent) {
|
|
56599
|
+
keep.add(row);
|
|
56600
|
+
if (row.body?.kind === "agent")
|
|
56601
|
+
parents.push(row.id);
|
|
56602
|
+
}
|
|
56603
|
+
}
|
|
56604
|
+
}
|
|
56605
|
+
return { ...slot, rows: slot.rows.filter((row) => keep.has(row)) };
|
|
56606
|
+
}
|
|
56607
|
+
function lineCounts(file) {
|
|
56608
|
+
if (file.additions !== undefined || file.deletions !== undefined) {
|
|
56609
|
+
return { added: file.additions ?? 0, removed: file.deletions ?? 0 };
|
|
56610
|
+
}
|
|
56611
|
+
if (!file.diff)
|
|
56612
|
+
return { added: 0, removed: 0 };
|
|
56613
|
+
const lines = file.diff.split(`
|
|
56614
|
+
`);
|
|
56615
|
+
const hunks = lines.some((line) => line.startsWith("@@"));
|
|
56616
|
+
if (file.change === "added" && !hunks)
|
|
56617
|
+
return { added: lines.length, removed: 0 };
|
|
56618
|
+
if (file.change === "deleted" && !hunks)
|
|
56619
|
+
return { added: 0, removed: lines.length };
|
|
56620
|
+
let added = 0;
|
|
56621
|
+
let removed = 0;
|
|
56622
|
+
for (const line of lines) {
|
|
56623
|
+
if (line.startsWith("+++") || line.startsWith("---"))
|
|
56624
|
+
continue;
|
|
56625
|
+
if (line.startsWith("+"))
|
|
56626
|
+
added += 1;
|
|
56627
|
+
else if (line.startsWith("-"))
|
|
56628
|
+
removed += 1;
|
|
56629
|
+
}
|
|
56630
|
+
return { added, removed };
|
|
56631
|
+
}
|
|
56632
|
+
function countsMeta(added, removed) {
|
|
56633
|
+
return added + removed > 0 ? `+${added} −${removed}` : undefined;
|
|
56634
|
+
}
|
|
56635
|
+
function shortUrl(url) {
|
|
56636
|
+
try {
|
|
56637
|
+
const parsed = new URL(url);
|
|
56638
|
+
const path = parsed.pathname === "/" ? "" : parsed.pathname;
|
|
56639
|
+
return firstLine(`${parsed.host}${path}`, 80);
|
|
56640
|
+
} catch {
|
|
56641
|
+
return firstLine(url, 80);
|
|
56642
|
+
}
|
|
56643
|
+
}
|
|
56644
|
+
// src/vendor/agent-activity/presenter.ts
|
|
56645
|
+
var EDIT_INTERVAL_MS = 1200;
|
|
56646
|
+
|
|
56647
|
+
class ProgressPresenter {
|
|
56648
|
+
transport;
|
|
56649
|
+
options;
|
|
56650
|
+
slots = new Map;
|
|
56651
|
+
chain = Promise.resolve();
|
|
56652
|
+
interval;
|
|
56653
|
+
now;
|
|
56654
|
+
setTimer;
|
|
56655
|
+
clearTimer;
|
|
56656
|
+
constructor(transport, options = {}) {
|
|
56657
|
+
this.transport = transport;
|
|
56658
|
+
this.options = options;
|
|
56659
|
+
this.interval = options.editIntervalMs ?? EDIT_INTERVAL_MS;
|
|
56660
|
+
this.now = options.now ?? Date.now;
|
|
56661
|
+
this.setTimer = options.setTimer ?? ((callback, ms) => setTimeout(callback, ms));
|
|
56662
|
+
this.clearTimer = options.clearTimer ?? ((timer) => clearTimeout(timer));
|
|
56663
|
+
}
|
|
56664
|
+
push(ops) {
|
|
56665
|
+
for (const op of ops) {
|
|
56666
|
+
const slot = this.slotState(op.slot);
|
|
56667
|
+
if (slot.ended || slot.failed)
|
|
56668
|
+
continue;
|
|
56669
|
+
slot.pending = op.doc;
|
|
56670
|
+
if (op.type === "end") {
|
|
56671
|
+
slot.ended = true;
|
|
56672
|
+
this.writeNow(op.slot, slot);
|
|
56673
|
+
} else if (slot.messageId === undefined && slot.lastFingerprint === undefined && slot.timer === undefined) {
|
|
56674
|
+
this.writeNow(op.slot, slot);
|
|
56675
|
+
} else if (op.urgent || this.now() - slot.lastWriteAt >= this.interval) {
|
|
56676
|
+
this.writeNow(op.slot, slot);
|
|
56677
|
+
} else if (slot.timer === undefined) {
|
|
56678
|
+
slot.timer = this.setTimer(() => {
|
|
56679
|
+
slot.timer = undefined;
|
|
56680
|
+
this.enqueue(op.slot, slot);
|
|
56681
|
+
}, Math.max(0, slot.lastWriteAt + this.interval - this.now()));
|
|
56682
|
+
}
|
|
56683
|
+
}
|
|
56684
|
+
}
|
|
56685
|
+
async flush() {
|
|
56686
|
+
for (const [id, slot] of this.slots)
|
|
56687
|
+
if (slot.pending && !slot.failed)
|
|
56688
|
+
this.writeNow(id, slot);
|
|
56689
|
+
await this.chain;
|
|
56690
|
+
}
|
|
56691
|
+
messageIds() {
|
|
56692
|
+
return [...this.slots.values()].flatMap((slot) => slot.messageId === undefined ? [] : [slot.messageId]);
|
|
56693
|
+
}
|
|
56694
|
+
slotState(id) {
|
|
56695
|
+
let slot = this.slots.get(id);
|
|
56696
|
+
if (!slot) {
|
|
56697
|
+
slot = { lastWriteAt: Number.NEGATIVE_INFINITY, ended: false, failed: false };
|
|
56698
|
+
this.slots.set(id, slot);
|
|
56699
|
+
}
|
|
56700
|
+
return slot;
|
|
56701
|
+
}
|
|
56702
|
+
writeNow(id, slot) {
|
|
56703
|
+
if (slot.timer !== undefined) {
|
|
56704
|
+
this.clearTimer(slot.timer);
|
|
56705
|
+
slot.timer = undefined;
|
|
56706
|
+
}
|
|
56707
|
+
this.enqueue(id, slot);
|
|
56708
|
+
}
|
|
56709
|
+
enqueue(id, slot) {
|
|
56710
|
+
slot.lastFingerprint ??= "";
|
|
56711
|
+
this.chain = this.chain.then(() => this.write(id, slot));
|
|
56712
|
+
}
|
|
56713
|
+
async write(_id, slot) {
|
|
56714
|
+
const doc = slot.pending;
|
|
56715
|
+
if (!doc || slot.failed)
|
|
56716
|
+
return;
|
|
56717
|
+
slot.pending = undefined;
|
|
56718
|
+
const fingerprint = fingerprintOf(doc);
|
|
56719
|
+
if (fingerprint === slot.lastFingerprint)
|
|
56720
|
+
return;
|
|
56721
|
+
const attempts = slot.ended && slot.messageId !== undefined ? 2 : 1;
|
|
56722
|
+
for (let attempt = 1;attempt <= attempts; attempt += 1) {
|
|
56723
|
+
try {
|
|
56724
|
+
if (slot.messageId === undefined) {
|
|
56725
|
+
slot.messageId = await this.transport.send(doc);
|
|
56726
|
+
} else {
|
|
56727
|
+
await this.transport.edit(slot.messageId, doc);
|
|
56728
|
+
}
|
|
56729
|
+
slot.lastFingerprint = fingerprint;
|
|
56730
|
+
slot.lastWriteAt = this.now();
|
|
56731
|
+
return;
|
|
56732
|
+
} catch (error) {
|
|
56733
|
+
if (attempt < attempts)
|
|
56734
|
+
continue;
|
|
56735
|
+
slot.failed = true;
|
|
56736
|
+
this.options.onError?.(error, slot.messageId === undefined ? "send" : "edit");
|
|
56737
|
+
}
|
|
56738
|
+
}
|
|
56739
|
+
}
|
|
56740
|
+
}
|
|
56741
|
+
function fingerprintOf(doc) {
|
|
56742
|
+
return JSON.stringify(doc, (_key, value) => typeof value === "bigint" ? value.toString() : value);
|
|
56743
|
+
}
|
|
56744
|
+
|
|
56745
|
+
class ProgressStream {
|
|
56746
|
+
renderer;
|
|
56747
|
+
presenter;
|
|
56748
|
+
constructor(transport, options = {}) {
|
|
56749
|
+
this.renderer = new ProgressRenderer(options);
|
|
56750
|
+
this.presenter = new ProgressPresenter(transport, options);
|
|
56751
|
+
}
|
|
56752
|
+
apply(event, at) {
|
|
56753
|
+
try {
|
|
56754
|
+
this.presenter.push(this.renderer.apply(event, at));
|
|
56755
|
+
} catch (error) {}
|
|
56756
|
+
}
|
|
56757
|
+
get isOpen() {
|
|
56758
|
+
return this.renderer.isOpen;
|
|
56759
|
+
}
|
|
56760
|
+
flush() {
|
|
56761
|
+
return this.presenter.flush();
|
|
56762
|
+
}
|
|
56763
|
+
}
|
|
56764
|
+
// src/vendor/agent-activity/mode.ts
|
|
56765
|
+
var DETAILED = 1;
|
|
56766
|
+
var FRIENDLY = 2;
|
|
56767
|
+
function resolveOutputMode(defaultMode, threadOverride) {
|
|
56768
|
+
const pick = (mode) => mode === DETAILED ? "detailed" : mode === FRIENDLY ? "friendly" : undefined;
|
|
56769
|
+
return pick(threadOverride) ?? pick(defaultMode) ?? "detailed";
|
|
56770
|
+
}
|
|
56771
|
+
// src/sidecar/activity.ts
|
|
56772
|
+
var MODE_CACHE_MS = 30000;
|
|
56773
|
+
var MODE_TIMEOUT_MS = 3000;
|
|
56774
|
+
var MAX_TURNS = 256;
|
|
56775
|
+
|
|
56776
|
+
class ActivityHub {
|
|
56777
|
+
options;
|
|
56778
|
+
turns = new Map;
|
|
56779
|
+
modes = new Map;
|
|
56780
|
+
now;
|
|
56781
|
+
modeCacheMs;
|
|
56782
|
+
modeTimeoutMs;
|
|
56783
|
+
maxTurns;
|
|
56784
|
+
constructor(options) {
|
|
56785
|
+
this.options = options;
|
|
56786
|
+
this.now = options.now ?? Date.now;
|
|
56787
|
+
this.modeCacheMs = options.modeCacheMs ?? MODE_CACHE_MS;
|
|
56788
|
+
this.modeTimeoutMs = options.modeTimeoutMs ?? MODE_TIMEOUT_MS;
|
|
56789
|
+
this.maxTurns = options.maxTurns ?? MAX_TURNS;
|
|
56790
|
+
}
|
|
56791
|
+
async apply(turnId, target, event, options = {}) {
|
|
56792
|
+
let state = this.turns.get(turnId);
|
|
56793
|
+
if (event.type === "turn.start") {
|
|
56794
|
+
if (!state)
|
|
56795
|
+
state = this.open(turnId, target);
|
|
56796
|
+
const mode = await state.ready;
|
|
56797
|
+
if (mode === "detailed" && !options.lazy && !state.ended)
|
|
56798
|
+
state.stream?.apply(event, options.at);
|
|
56799
|
+
return { mode };
|
|
56800
|
+
}
|
|
56801
|
+
if (!state || state.ended)
|
|
56802
|
+
return { ignored: true };
|
|
56803
|
+
const mode = await state.ready;
|
|
56804
|
+
state.touchedAt = this.now();
|
|
56805
|
+
if (mode !== "detailed" || !state.stream)
|
|
56806
|
+
return { mode };
|
|
56807
|
+
state.stream.apply(event, options.at);
|
|
56808
|
+
if (event.type === "turn.end")
|
|
56809
|
+
this.end(turnId, state);
|
|
56810
|
+
return { mode };
|
|
56811
|
+
}
|
|
56812
|
+
async flush(turnId) {
|
|
56813
|
+
const state = this.turns.get(turnId);
|
|
56814
|
+
if (!state)
|
|
56815
|
+
return;
|
|
56816
|
+
await state.ready;
|
|
56817
|
+
await state.stream?.flush();
|
|
56818
|
+
}
|
|
56819
|
+
get size() {
|
|
56820
|
+
return this.turns.size;
|
|
56821
|
+
}
|
|
56822
|
+
open(turnId, target) {
|
|
56823
|
+
this.prune();
|
|
56824
|
+
const state = { target, ended: false, touchedAt: this.now(), ready: Promise.resolve("detailed") };
|
|
56825
|
+
state.ready = this.modeFor(target).then((mode) => {
|
|
56826
|
+
state.mode = mode;
|
|
56827
|
+
if (mode === "detailed") {
|
|
56828
|
+
state.stream = new ProgressStream(this.options.transportFor(target), {
|
|
56829
|
+
onError: (error, op) => this.options.onError?.(error, op)
|
|
56830
|
+
});
|
|
56831
|
+
}
|
|
56832
|
+
return mode;
|
|
56833
|
+
});
|
|
56834
|
+
this.turns.set(turnId, state);
|
|
56835
|
+
return state;
|
|
56836
|
+
}
|
|
56837
|
+
end(turnId, state) {
|
|
56838
|
+
state.ended = true;
|
|
56839
|
+
const done = () => {
|
|
56840
|
+
if (this.turns.get(turnId) === state)
|
|
56841
|
+
this.turns.delete(turnId);
|
|
56842
|
+
};
|
|
56843
|
+
(state.stream?.flush() ?? Promise.resolve()).then(done, done);
|
|
56844
|
+
}
|
|
56845
|
+
prune() {
|
|
56846
|
+
if (this.turns.size < this.maxTurns)
|
|
56847
|
+
return;
|
|
56848
|
+
const byAge = [...this.turns.entries()].sort((left, right) => left[1].touchedAt - right[1].touchedAt);
|
|
56849
|
+
for (const [id] of byAge.slice(0, this.turns.size - this.maxTurns + 1))
|
|
56850
|
+
this.turns.delete(id);
|
|
56851
|
+
}
|
|
56852
|
+
async modeFor(target) {
|
|
56853
|
+
const key = targetKey(target);
|
|
56854
|
+
const cached = this.modes.get(key);
|
|
56855
|
+
if (cached && this.now() - cached.at < this.modeCacheMs)
|
|
56856
|
+
return cached.mode;
|
|
56857
|
+
try {
|
|
56858
|
+
let timer;
|
|
56859
|
+
const settings = await Promise.race([
|
|
56860
|
+
this.options.readMode(target),
|
|
56861
|
+
new Promise((_resolve, reject) => {
|
|
56862
|
+
timer = setTimeout(() => reject(new Error("output mode lookup timed out")), this.modeTimeoutMs);
|
|
56863
|
+
})
|
|
56864
|
+
]).finally(() => clearTimeout(timer));
|
|
56865
|
+
const mode = resolveOutputMode(settings.defaultMode, settings.override);
|
|
56866
|
+
this.modes.set(key, { mode, at: this.now() });
|
|
56867
|
+
if (this.modes.size > 1024)
|
|
56868
|
+
this.modes.delete(this.modes.keys().next().value);
|
|
56869
|
+
return mode;
|
|
56870
|
+
} catch (error) {
|
|
56871
|
+
this.options.onError?.(error, "mode");
|
|
56872
|
+
return cached?.mode ?? "detailed";
|
|
56873
|
+
}
|
|
56874
|
+
}
|
|
56875
|
+
}
|
|
56876
|
+
function targetKey(target) {
|
|
56877
|
+
return "chatId" in target ? `chat:${target.chatId.toString()}` : `user:${target.userId.toString()}`;
|
|
56878
|
+
}
|
|
56879
|
+
function randomMessageId2() {
|
|
56880
|
+
const bytes = new Uint8Array(8);
|
|
56881
|
+
globalThis.crypto.getRandomValues(bytes);
|
|
56882
|
+
const value = new DataView(bytes.buffer).getBigInt64(0, true);
|
|
56883
|
+
return value === 0n ? 1n : value;
|
|
56884
|
+
}
|
|
56885
|
+
function firstMessageId(result) {
|
|
56886
|
+
const record = asOptionalRecord(result);
|
|
56887
|
+
const send = asOptionalRecord(record?.sendMessage) ?? record;
|
|
56888
|
+
const updates = Array.isArray(send?.updates) ? send.updates : [];
|
|
56889
|
+
for (const raw of updates) {
|
|
56890
|
+
const update = asOptionalRecord(asOptionalRecord(raw)?.update);
|
|
56891
|
+
if (update?.oneofKind === "newMessage") {
|
|
56892
|
+
const id = asOptionalRecord(asOptionalRecord(update.newMessage)?.message)?.id;
|
|
56893
|
+
if (id != null)
|
|
56894
|
+
return BigInt(String(id));
|
|
56895
|
+
}
|
|
56896
|
+
if (update?.oneofKind === "updateMessageId") {
|
|
56897
|
+
const id = asOptionalRecord(update.updateMessageId)?.messageId;
|
|
56898
|
+
if (id != null)
|
|
56899
|
+
return BigInt(String(id));
|
|
56900
|
+
}
|
|
56901
|
+
}
|
|
56902
|
+
return null;
|
|
56903
|
+
}
|
|
56904
|
+
var ITEM_STATES = new Set(["running", "waiting", "done", "failed", "cancelled"]);
|
|
56905
|
+
var OUTCOMES = new Set(["success", "failure", "cancelled"]);
|
|
56906
|
+
var PLAN_STATUSES = new Set(["pending", "in_progress", "completed"]);
|
|
56907
|
+
var CHANGES = new Set(["added", "deleted", "modified", "renamed"]);
|
|
56908
|
+
function parseActivityEvent(value) {
|
|
56909
|
+
const record = asOptionalRecord(value);
|
|
56910
|
+
if (!record)
|
|
56911
|
+
throw new SidecarError("event must be an object", "bad_format");
|
|
56912
|
+
switch (record.type) {
|
|
56913
|
+
case "turn.start":
|
|
56914
|
+
return { type: "turn.start" };
|
|
56915
|
+
case "split":
|
|
56916
|
+
return { type: "split" };
|
|
56917
|
+
case "turn.end": {
|
|
56918
|
+
const outcome = record.outcome;
|
|
56919
|
+
if (typeof outcome !== "string" || !OUTCOMES.has(outcome)) {
|
|
56920
|
+
throw new SidecarError("turn.end requires outcome success, failure or cancelled", "bad_format");
|
|
56921
|
+
}
|
|
56922
|
+
return { type: "turn.end", outcome };
|
|
56923
|
+
}
|
|
56924
|
+
case "commentary":
|
|
56925
|
+
return { type: "commentary", text: requiredString(record, "text") };
|
|
56926
|
+
case "waiting": {
|
|
56927
|
+
if (typeof record.waiting !== "boolean")
|
|
56928
|
+
throw new SidecarError("waiting requires a boolean", "bad_format");
|
|
56929
|
+
const id = optionalString(record, "id");
|
|
56930
|
+
return { type: "waiting", waiting: record.waiting, ...id !== undefined ? { id } : {} };
|
|
56931
|
+
}
|
|
56932
|
+
case "item": {
|
|
56933
|
+
const id = requiredString(record, "id");
|
|
56934
|
+
const parent = optionalString(record, "parent");
|
|
56935
|
+
const state = record.state;
|
|
56936
|
+
if (state !== undefined && (typeof state !== "string" || !ITEM_STATES.has(state))) {
|
|
56937
|
+
throw new SidecarError("item state is not valid", "bad_format");
|
|
56938
|
+
}
|
|
56939
|
+
const durationMs = optionalNumber(record, "durationMs");
|
|
56940
|
+
const body = record.body === undefined ? undefined : parseBody(record.body);
|
|
56941
|
+
return {
|
|
56942
|
+
type: "item",
|
|
56943
|
+
id,
|
|
56944
|
+
...parent !== undefined ? { parent } : {},
|
|
56945
|
+
...body ? { body } : {},
|
|
56946
|
+
...state !== undefined ? { state } : {},
|
|
56947
|
+
...durationMs !== undefined ? { durationMs } : {}
|
|
56948
|
+
};
|
|
56949
|
+
}
|
|
56950
|
+
default:
|
|
56951
|
+
throw new SidecarError("unknown activity event type", "bad_format");
|
|
56952
|
+
}
|
|
56953
|
+
}
|
|
56954
|
+
function parseBody(value) {
|
|
56955
|
+
const body = asOptionalRecord(value);
|
|
56956
|
+
if (!body)
|
|
56957
|
+
throw new SidecarError("item body must be an object", "bad_format");
|
|
56958
|
+
const strings = (...keys) => {
|
|
56959
|
+
const out = {};
|
|
56960
|
+
for (const key of keys) {
|
|
56961
|
+
const text = optionalString(body, key);
|
|
56962
|
+
if (text !== undefined)
|
|
56963
|
+
out[key] = text;
|
|
56964
|
+
}
|
|
56965
|
+
return out;
|
|
56966
|
+
};
|
|
56967
|
+
switch (body.kind) {
|
|
56968
|
+
case "command": {
|
|
56969
|
+
const exitCode = optionalNumber(body, "exitCode");
|
|
56970
|
+
return {
|
|
56971
|
+
kind: "command",
|
|
56972
|
+
command: requiredString(body, "command"),
|
|
56973
|
+
...strings("output"),
|
|
56974
|
+
...exitCode !== undefined ? { exitCode: Math.trunc(exitCode) } : {}
|
|
56975
|
+
};
|
|
56976
|
+
}
|
|
56977
|
+
case "read":
|
|
56978
|
+
return { kind: "read", path: requiredString(body, "path") };
|
|
56979
|
+
case "search":
|
|
56980
|
+
return { kind: "search", ...strings("query", "path") };
|
|
56981
|
+
case "list":
|
|
56982
|
+
return { kind: "list", ...strings("path") };
|
|
56983
|
+
case "edit": {
|
|
56984
|
+
const files = Array.isArray(body.files) ? body.files : [];
|
|
56985
|
+
return { kind: "edit", files: files.map(parseFileChange) };
|
|
56986
|
+
}
|
|
56987
|
+
case "web":
|
|
56988
|
+
return { kind: "web", ...strings("query", "url") };
|
|
56989
|
+
case "tool":
|
|
56990
|
+
return { kind: "tool", name: requiredString(body, "name"), ...strings("title", "input", "output", "error") };
|
|
56991
|
+
case "agent":
|
|
56992
|
+
return { kind: "agent", ...strings("title", "meta") };
|
|
56993
|
+
case "plan": {
|
|
56994
|
+
const steps = Array.isArray(body.steps) ? body.steps : [];
|
|
56995
|
+
return {
|
|
56996
|
+
kind: "plan",
|
|
56997
|
+
steps: steps.map((raw) => {
|
|
56998
|
+
const step = asOptionalRecord(raw);
|
|
56999
|
+
const status = step?.status;
|
|
57000
|
+
if (!step || typeof status !== "string" || !PLAN_STATUSES.has(status)) {
|
|
57001
|
+
throw new SidecarError("plan step is not valid", "bad_format");
|
|
57002
|
+
}
|
|
57003
|
+
return { text: requiredString(step, "text"), status };
|
|
57004
|
+
}),
|
|
57005
|
+
...strings("explanation")
|
|
57006
|
+
};
|
|
57007
|
+
}
|
|
57008
|
+
case "reasoning":
|
|
57009
|
+
return { kind: "reasoning", summary: requiredString(body, "summary") };
|
|
57010
|
+
case "note":
|
|
57011
|
+
return { kind: "note", text: requiredString(body, "text") };
|
|
57012
|
+
case "compaction":
|
|
57013
|
+
return { kind: "compaction" };
|
|
57014
|
+
default:
|
|
57015
|
+
throw new SidecarError("unknown item body kind", "bad_format");
|
|
57016
|
+
}
|
|
57017
|
+
}
|
|
57018
|
+
function parseFileChange(value) {
|
|
57019
|
+
const file = asOptionalRecord(value);
|
|
57020
|
+
if (!file)
|
|
57021
|
+
throw new SidecarError("edit file must be an object", "bad_format");
|
|
57022
|
+
const change = file.change;
|
|
57023
|
+
if (change !== undefined && (typeof change !== "string" || !CHANGES.has(change))) {
|
|
57024
|
+
throw new SidecarError("edit file change is not valid", "bad_format");
|
|
57025
|
+
}
|
|
57026
|
+
const diff = optionalString(file, "diff");
|
|
57027
|
+
const additions = optionalNumber(file, "additions");
|
|
57028
|
+
const deletions = optionalNumber(file, "deletions");
|
|
57029
|
+
return {
|
|
57030
|
+
path: requiredString(file, "path"),
|
|
57031
|
+
...change !== undefined ? { change } : {},
|
|
57032
|
+
...diff !== undefined ? { diff } : {},
|
|
57033
|
+
...additions !== undefined ? { additions: Math.trunc(additions) } : {},
|
|
57034
|
+
...deletions !== undefined ? { deletions: Math.trunc(deletions) } : {}
|
|
57035
|
+
};
|
|
57036
|
+
}
|
|
57037
|
+
function requiredString(record, key) {
|
|
57038
|
+
const value = record[key];
|
|
57039
|
+
if (typeof value !== "string")
|
|
57040
|
+
throw new SidecarError(`${key} must be a string`, "bad_format");
|
|
57041
|
+
return value;
|
|
57042
|
+
}
|
|
57043
|
+
function optionalString(record, key) {
|
|
57044
|
+
const value = record[key];
|
|
57045
|
+
if (value === undefined || value === null)
|
|
57046
|
+
return;
|
|
57047
|
+
if (typeof value !== "string")
|
|
57048
|
+
throw new SidecarError(`${key} must be a string`, "bad_format");
|
|
57049
|
+
return value;
|
|
57050
|
+
}
|
|
57051
|
+
function optionalNumber(record, key) {
|
|
57052
|
+
const value = record[key];
|
|
57053
|
+
if (value === undefined || value === null)
|
|
57054
|
+
return;
|
|
57055
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
57056
|
+
throw new SidecarError(`${key} must be a number`, "bad_format");
|
|
57057
|
+
return value;
|
|
57058
|
+
}
|
|
57059
|
+
|
|
55370
57060
|
// src/sidecar/telemetry.ts
|
|
55371
57061
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
55372
57062
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
@@ -55606,7 +57296,10 @@ async function connectClientLoop() {
|
|
|
55606
57296
|
meUsername = normalizeOwnUsername(me.username);
|
|
55607
57297
|
registerBotCapabilitiesWithRetry({
|
|
55608
57298
|
register: () => client.setMyBotCapabilities({
|
|
55609
|
-
capabilities: [
|
|
57299
|
+
capabilities: [
|
|
57300
|
+
{ kind: BotCapability_Kind.CHAT_SETTINGS, version: 1 },
|
|
57301
|
+
{ kind: BotCapability_Kind.OUTPUT_MODE, version: 1 }
|
|
57302
|
+
]
|
|
55610
57303
|
}),
|
|
55611
57304
|
isCancelled: () => stopping,
|
|
55612
57305
|
onFailure: (error, willRetry) => {
|
|
@@ -55720,6 +57413,12 @@ async function handleRequest(req, res) {
|
|
|
55720
57413
|
case "/send":
|
|
55721
57414
|
await endpointSend(res, body);
|
|
55722
57415
|
return;
|
|
57416
|
+
case "/activity":
|
|
57417
|
+
await endpointActivity(res, body);
|
|
57418
|
+
return;
|
|
57419
|
+
case "/activity/flush":
|
|
57420
|
+
await endpointActivityFlush(res, body);
|
|
57421
|
+
return;
|
|
55723
57422
|
case "/edit":
|
|
55724
57423
|
await endpointEdit(res, body);
|
|
55725
57424
|
return;
|
|
@@ -55828,6 +57527,84 @@ async function endpointSend(res, body) {
|
|
|
55828
57527
|
const result = "chatId" in target ? await client.sendMessage({ chatId: target.chatId, ...params }) : await client.sendMessage({ userId: target.userId, ...params });
|
|
55829
57528
|
writeJson(res, 200, { ok: true, result: { messageId: result.messageId?.toString() ?? null } });
|
|
55830
57529
|
}
|
|
57530
|
+
async function endpointActivity(res, body) {
|
|
57531
|
+
const record = asRecord(body);
|
|
57532
|
+
const target = parseTarget(record);
|
|
57533
|
+
const event = parseActivityEvent(record.event);
|
|
57534
|
+
const turnId = readOptionalString(record, "turnId") || activityTargetKey(target);
|
|
57535
|
+
const at = readOptionalNumber(record, "at");
|
|
57536
|
+
const lazy = readOptionalBoolean(record, "lazy") ?? false;
|
|
57537
|
+
const result = await activityHub.apply(turnId, target, event, {
|
|
57538
|
+
...at !== undefined && Number.isFinite(at) ? { at } : {},
|
|
57539
|
+
lazy
|
|
57540
|
+
});
|
|
57541
|
+
writeJson(res, 200, { ok: true, result });
|
|
57542
|
+
}
|
|
57543
|
+
async function endpointActivityFlush(res, body) {
|
|
57544
|
+
const record = asRecord(body);
|
|
57545
|
+
const target = parseTarget(record);
|
|
57546
|
+
const turnId = readOptionalString(record, "turnId") || activityTargetKey(target);
|
|
57547
|
+
await activityHub.flush(turnId);
|
|
57548
|
+
writeJson(res, 200, { ok: true, result: {} });
|
|
57549
|
+
}
|
|
57550
|
+
function activityTargetKey(target) {
|
|
57551
|
+
return "chatId" in target ? `chat:${target.chatId.toString()}` : `user:${target.userId.toString()}`;
|
|
57552
|
+
}
|
|
57553
|
+
function progressTransport(target) {
|
|
57554
|
+
const peerId = inputPeerFromTarget(target);
|
|
57555
|
+
return {
|
|
57556
|
+
async send(doc) {
|
|
57557
|
+
const result = await client.invokeRaw(Method.SEND_MESSAGE, {
|
|
57558
|
+
oneofKind: "sendMessage",
|
|
57559
|
+
sendMessage: {
|
|
57560
|
+
peerId,
|
|
57561
|
+
randomId: randomMessageId2(),
|
|
57562
|
+
message: doc.text,
|
|
57563
|
+
blockContent: doc.blockContent,
|
|
57564
|
+
sendMode: MessageSendMode.MODE_SILENT
|
|
57565
|
+
}
|
|
57566
|
+
});
|
|
57567
|
+
const messageId = firstMessageId(result);
|
|
57568
|
+
if (messageId == null)
|
|
57569
|
+
throw new Error("sendMessage returned no message id");
|
|
57570
|
+
return messageId;
|
|
57571
|
+
},
|
|
57572
|
+
async edit(messageId, doc) {
|
|
57573
|
+
await client.invokeRaw(Method.EDIT_MESSAGE, {
|
|
57574
|
+
oneofKind: "editMessage",
|
|
57575
|
+
editMessage: { messageId, peerId, text: doc.text, blockContent: doc.blockContent }
|
|
57576
|
+
});
|
|
57577
|
+
}
|
|
57578
|
+
};
|
|
57579
|
+
}
|
|
57580
|
+
var AGENT_SETTINGS_CACHE_MS = 30000;
|
|
57581
|
+
var agentDefaultOutputMode;
|
|
57582
|
+
async function readOutputModeSettings(target) {
|
|
57583
|
+
const peerId = inputPeerFromTarget(target);
|
|
57584
|
+
const [defaultMode, participations] = await Promise.all([
|
|
57585
|
+
(async () => {
|
|
57586
|
+
if (agentDefaultOutputMode && Date.now() - agentDefaultOutputMode.at < AGENT_SETTINGS_CACHE_MS) {
|
|
57587
|
+
return agentDefaultOutputMode.value;
|
|
57588
|
+
}
|
|
57589
|
+
const result = asOptionalRecord(await client.invokeRaw(Method.GET_AGENT_SETTINGS, {
|
|
57590
|
+
oneofKind: "getAgentSettings",
|
|
57591
|
+
getAgentSettings: { botUserId: 0n }
|
|
57592
|
+
}));
|
|
57593
|
+
const settings = asOptionalRecord(asOptionalRecord(result?.getAgentSettings)?.settings);
|
|
57594
|
+
const value = typeof settings?.defaultOutputMode === "number" ? settings.defaultOutputMode : undefined;
|
|
57595
|
+
agentDefaultOutputMode = { value, at: Date.now() };
|
|
57596
|
+
return value;
|
|
57597
|
+
})(),
|
|
57598
|
+
client.invokeRaw(Method.GET_AGENT_PARTICIPATIONS, {
|
|
57599
|
+
oneofKind: "getAgentParticipations",
|
|
57600
|
+
getAgentParticipations: { peerId }
|
|
57601
|
+
})
|
|
57602
|
+
]);
|
|
57603
|
+
const list = asOptionalRecord(asOptionalRecord(participations)?.getAgentParticipations)?.participations;
|
|
57604
|
+
const mine = Array.isArray(list) && meId != null ? list.map(asOptionalRecord).find((entry) => entry != null && String(entry.botUserId) === meId) : undefined;
|
|
57605
|
+
const override = typeof mine?.outputMode === "number" ? mine.outputMode : undefined;
|
|
57606
|
+
return { defaultMode, override };
|
|
57607
|
+
}
|
|
55831
57608
|
async function endpointEdit(res, body) {
|
|
55832
57609
|
const record = asRecord(body);
|
|
55833
57610
|
const target = parseTarget(record);
|
|
@@ -56704,6 +58481,34 @@ class MockInlineClient {
|
|
|
56704
58481
|
}
|
|
56705
58482
|
return {};
|
|
56706
58483
|
}
|
|
58484
|
+
async invokeRaw(method, input) {
|
|
58485
|
+
this.record(`invokeRaw:${methodName(method)}`, input);
|
|
58486
|
+
if (method === Method.SEND_MESSAGE) {
|
|
58487
|
+
this.messageId += 1n;
|
|
58488
|
+
return {
|
|
58489
|
+
oneofKind: "sendMessage",
|
|
58490
|
+
sendMessage: { updates: [{ update: { oneofKind: "updateMessageId", updateMessageId: { messageId: this.messageId, randomId: 1n } } }] }
|
|
58491
|
+
};
|
|
58492
|
+
}
|
|
58493
|
+
if (method === Method.EDIT_MESSAGE)
|
|
58494
|
+
return { oneofKind: "editMessage", editMessage: { updates: [] } };
|
|
58495
|
+
if (method === Method.GET_AGENT_SETTINGS) {
|
|
58496
|
+
return {
|
|
58497
|
+
oneofKind: "getAgentSettings",
|
|
58498
|
+
getAgentSettings: { settings: { botUserId: 999n, defaultOutputMode: mockOutputMode("INLINE_SIDECAR_TEST_DEFAULT_OUTPUT_MODE"), revision: 0n } }
|
|
58499
|
+
};
|
|
58500
|
+
}
|
|
58501
|
+
if (method === Method.GET_AGENT_PARTICIPATIONS) {
|
|
58502
|
+
const override = mockOutputMode("INLINE_SIDECAR_TEST_OUTPUT_MODE_OVERRIDE");
|
|
58503
|
+
return {
|
|
58504
|
+
oneofKind: "getAgentParticipations",
|
|
58505
|
+
getAgentParticipations: {
|
|
58506
|
+
participations: override ? [{ botUserId: 999n, mode: 1, revision: 1n, date: 1n, outputMode: override }] : []
|
|
58507
|
+
}
|
|
58508
|
+
};
|
|
58509
|
+
}
|
|
58510
|
+
return { oneofKind: undefined };
|
|
58511
|
+
}
|
|
56707
58512
|
async invokeUncheckedRaw(method, input) {
|
|
56708
58513
|
this.record(`invokeUncheckedRaw:${methodName(method)}`, input);
|
|
56709
58514
|
if (method === Method.GET_CHAT_PARTICIPANTS) {
|
|
@@ -56824,7 +58629,23 @@ function chatIdFromInputPeer(peer) {
|
|
|
56824
58629
|
function methodName(method) {
|
|
56825
58630
|
return Method[method] ?? String(method);
|
|
56826
58631
|
}
|
|
58632
|
+
function mockOutputMode(name) {
|
|
58633
|
+
const value = readEnv(name);
|
|
58634
|
+
return value === "detailed" ? 1 : value === "friendly" ? 2 : 0;
|
|
58635
|
+
}
|
|
56827
58636
|
var client = createClient(clientOptions);
|
|
58637
|
+
var activityHub = new ActivityHub({
|
|
58638
|
+
transportFor: progressTransport,
|
|
58639
|
+
readMode: readOutputModeSettings,
|
|
58640
|
+
onError: (error, operation) => {
|
|
58641
|
+
if (operation === "mode") {
|
|
58642
|
+
console.error(`inline-sidecar: output mode lookup failed: ${redactError(error)}; using the last known mode`);
|
|
58643
|
+
return;
|
|
58644
|
+
}
|
|
58645
|
+
reportHermesPluginError(`activity.${operation}`, error);
|
|
58646
|
+
console.error(`inline-sidecar: progress ${operation} failed: ${redactError(error)}`);
|
|
58647
|
+
}
|
|
58648
|
+
});
|
|
56828
58649
|
var userDirectory = new InlineUserDirectory(client, {
|
|
56829
58650
|
onError: (operation, error) => {
|
|
56830
58651
|
reportHermesPluginError(`sender_directory.${operation}`, error);
|