@moxt-ai/mobius-sdk 0.0.82 → 0.0.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/resources.d.ts +1 -208
- package/dist/resources.d.ts.map +1 -1
- package/dist/resources.js +1 -518
- package/dist/resources.js.map +1 -1
- package/dist/service-client.d.ts +2 -30
- package/dist/service-client.d.ts.map +1 -1
- package/dist/service-client.js +3 -60
- package/dist/service-client.js.map +1 -1
- package/package.json +2 -2
package/dist/resources.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { decodeIdentifier, decodeTurn, isIdentifier, sessionCapabilitiesSchema, } from "@moxt-ai/mobius-protocol";
|
|
2
2
|
import { MobiusProtocolError, MobiusValidationError } from "./errors.js";
|
|
3
|
-
const MOBIUS_EVENT_FORMAT_VERSION = "2";
|
|
4
|
-
const MOBIUS_SESSION_EVENT_STREAM_EVENT = "session.event.v2";
|
|
5
|
-
const MOBIUS_SESSION_EVENT_STREAM_MEDIA_TYPE = "application/json";
|
|
6
|
-
const MOBIUS_SESSION_EVENT_STREAM_TRANSPORT = "websocket";
|
|
7
|
-
const MOBIUS_SESSION_EXPORT_FORMAT_VERSION = "1";
|
|
8
3
|
const SESSION_CAPABILITY_FIELDS = [
|
|
9
4
|
"additionalDirectories",
|
|
10
5
|
"audioPrompt",
|
|
@@ -60,16 +55,6 @@ function booleanField(value, field) {
|
|
|
60
55
|
}
|
|
61
56
|
return candidate;
|
|
62
57
|
}
|
|
63
|
-
function busyStatusField(value, field) {
|
|
64
|
-
const candidate = value[field];
|
|
65
|
-
if (candidate === undefined || candidate === null) {
|
|
66
|
-
return undefined;
|
|
67
|
-
}
|
|
68
|
-
if (candidate !== "working" && candidate !== "failed") {
|
|
69
|
-
throw invalidResponse(`The service returned an invalid ${field}`);
|
|
70
|
-
}
|
|
71
|
-
return candidate;
|
|
72
|
-
}
|
|
73
58
|
function arrayField(value, field, maximumLength = 10_000) {
|
|
74
59
|
const candidate = value[field];
|
|
75
60
|
if (!Array.isArray(candidate) || candidate.length > maximumLength) {
|
|
@@ -77,116 +62,12 @@ function arrayField(value, field, maximumLength = 10_000) {
|
|
|
77
62
|
}
|
|
78
63
|
return candidate;
|
|
79
64
|
}
|
|
80
|
-
function nullableCursor(value, field) {
|
|
81
|
-
const candidate = value[field];
|
|
82
|
-
if (candidate === null) {
|
|
83
|
-
return "";
|
|
84
|
-
}
|
|
85
|
-
if (typeof candidate !== "string" || candidate.length > 512) {
|
|
86
|
-
throw invalidResponse(`The service returned an invalid ${field}`);
|
|
87
|
-
}
|
|
88
|
-
return candidate;
|
|
89
|
-
}
|
|
90
65
|
function validateTimestamp(value, field) {
|
|
91
66
|
if (Number.isNaN(Date.parse(value))) {
|
|
92
67
|
throw invalidResponse(`The service returned an invalid ${field}`);
|
|
93
68
|
}
|
|
94
69
|
return value;
|
|
95
70
|
}
|
|
96
|
-
export class MobiusSessionEventCapabilities {
|
|
97
|
-
eventName;
|
|
98
|
-
formatVersion;
|
|
99
|
-
mediaType;
|
|
100
|
-
transport;
|
|
101
|
-
constructor(eventName, formatVersion, mediaType, transport) {
|
|
102
|
-
this.eventName = eventName;
|
|
103
|
-
this.formatVersion = formatVersion;
|
|
104
|
-
this.mediaType = mediaType;
|
|
105
|
-
this.transport = transport;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
export class MobiusAuthenticationCapabilities {
|
|
109
|
-
browserCredentials;
|
|
110
|
-
maximumBrowserCredentialLifetimeSeconds;
|
|
111
|
-
minimumBrowserCredentialLifetimeSeconds;
|
|
112
|
-
constructor(browserCredentials, maximumBrowserCredentialLifetimeSeconds, minimumBrowserCredentialLifetimeSeconds) {
|
|
113
|
-
this.browserCredentials = browserCredentials;
|
|
114
|
-
this.maximumBrowserCredentialLifetimeSeconds = maximumBrowserCredentialLifetimeSeconds;
|
|
115
|
-
this.minimumBrowserCredentialLifetimeSeconds = minimumBrowserCredentialLifetimeSeconds;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
export class MobiusPortabilityCapabilities {
|
|
119
|
-
exportFormatVersion;
|
|
120
|
-
nativeContextImport;
|
|
121
|
-
targetBindingRequired;
|
|
122
|
-
constructor(exportFormatVersion, nativeContextImport, targetBindingRequired) {
|
|
123
|
-
this.exportFormatVersion = exportFormatVersion;
|
|
124
|
-
this.nativeContextImport = nativeContextImport;
|
|
125
|
-
this.targetBindingRequired = targetBindingRequired;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
export class MobiusResourceCapabilities {
|
|
129
|
-
attempts;
|
|
130
|
-
browserCredentials;
|
|
131
|
-
events;
|
|
132
|
-
interactions;
|
|
133
|
-
messages;
|
|
134
|
-
portability;
|
|
135
|
-
runtimePairings;
|
|
136
|
-
runtimes;
|
|
137
|
-
sessions;
|
|
138
|
-
toolCalls;
|
|
139
|
-
turns;
|
|
140
|
-
constructor(resources) {
|
|
141
|
-
this.attempts = booleanField(resources, "attempts");
|
|
142
|
-
this.browserCredentials = booleanField(resources, "browserCredentials");
|
|
143
|
-
this.events = booleanField(resources, "events");
|
|
144
|
-
this.interactions = booleanField(resources, "interactions");
|
|
145
|
-
this.messages = booleanField(resources, "messages");
|
|
146
|
-
this.portability = booleanField(resources, "portability");
|
|
147
|
-
this.runtimePairings = booleanField(resources, "runtimePairings");
|
|
148
|
-
this.runtimes = booleanField(resources, "runtimes");
|
|
149
|
-
this.sessions = booleanField(resources, "sessions");
|
|
150
|
-
this.toolCalls = booleanField(resources, "toolCalls");
|
|
151
|
-
this.turns = booleanField(resources, "turns");
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
export class MobiusServiceCapabilities {
|
|
155
|
-
apiVersion;
|
|
156
|
-
authentication;
|
|
157
|
-
portability;
|
|
158
|
-
resources;
|
|
159
|
-
sessionEvents;
|
|
160
|
-
constructor(apiVersion, authentication, portability, resources, sessionEvents) {
|
|
161
|
-
this.apiVersion = apiVersion;
|
|
162
|
-
this.authentication = authentication;
|
|
163
|
-
this.portability = portability;
|
|
164
|
-
this.resources = resources;
|
|
165
|
-
this.sessionEvents = sessionEvents;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
export function decodeMobiusServiceCapabilities(value) {
|
|
169
|
-
const capabilities = record(value, "service capabilities");
|
|
170
|
-
const resources = record(capabilities["resources"], "resource capabilities");
|
|
171
|
-
const authentication = record(capabilities["authentication"], "authentication capabilities");
|
|
172
|
-
const portability = record(capabilities["portability"], "portability capabilities");
|
|
173
|
-
const sessionEvents = record(capabilities["sessionEvents"], "Session event capabilities");
|
|
174
|
-
const apiVersion = stringField(capabilities, "apiVersion", 32);
|
|
175
|
-
const eventName = stringField(sessionEvents, "eventName", 128);
|
|
176
|
-
const formatVersion = stringField(sessionEvents, "formatVersion", 32);
|
|
177
|
-
const mediaType = stringField(sessionEvents, "mediaType", 128);
|
|
178
|
-
const transport = stringField(sessionEvents, "transport", 32);
|
|
179
|
-
const exportFormatVersion = stringField(portability, "exportFormatVersion", 32);
|
|
180
|
-
if (apiVersion !== MOBIUS_API_VERSION ||
|
|
181
|
-
eventName !== MOBIUS_SESSION_EVENT_STREAM_EVENT ||
|
|
182
|
-
formatVersion !== MOBIUS_EVENT_FORMAT_VERSION ||
|
|
183
|
-
mediaType !== MOBIUS_SESSION_EVENT_STREAM_MEDIA_TYPE ||
|
|
184
|
-
transport !== MOBIUS_SESSION_EVENT_STREAM_TRANSPORT ||
|
|
185
|
-
exportFormatVersion !== MOBIUS_SESSION_EXPORT_FORMAT_VERSION) {
|
|
186
|
-
throw invalidResponse("The service returned unsupported Mobius API capabilities");
|
|
187
|
-
}
|
|
188
|
-
return new MobiusServiceCapabilities(apiVersion, new MobiusAuthenticationCapabilities(booleanField(authentication, "browserCredentials"), integerField(authentication, "maximumBrowserCredentialLifetimeSeconds"), integerField(authentication, "minimumBrowserCredentialLifetimeSeconds")), new MobiusPortabilityCapabilities(exportFormatVersion, booleanField(portability, "nativeContextImport"), booleanField(portability, "targetBindingRequired")), new MobiusResourceCapabilities(resources), new MobiusSessionEventCapabilities(eventName, formatVersion, mediaType, transport));
|
|
189
|
-
}
|
|
190
71
|
export class MobiusRecordingPolicy {
|
|
191
72
|
contentLimitBytes;
|
|
192
73
|
hotEventLimit;
|
|
@@ -652,18 +533,6 @@ export class MobiusElicitationResponseRequest extends MobiusInteractionResponseR
|
|
|
652
533
|
this.content = content;
|
|
653
534
|
}
|
|
654
535
|
}
|
|
655
|
-
export function decodeMobiusInteraction(value) {
|
|
656
|
-
try {
|
|
657
|
-
return decodeInteraction(value);
|
|
658
|
-
}
|
|
659
|
-
catch (cause) {
|
|
660
|
-
throw new MobiusProtocolError("The service returned an invalid Interaction", { cause });
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
export function decodeMobiusInteractionList(value) {
|
|
664
|
-
const response = record(value, "Interaction list");
|
|
665
|
-
return arrayField(response, "interactions", 100).map(decodeMobiusInteraction);
|
|
666
|
-
}
|
|
667
536
|
export class MobiusPageRequest {
|
|
668
537
|
cursor;
|
|
669
538
|
limit;
|
|
@@ -744,14 +613,6 @@ export class MobiusSession {
|
|
|
744
613
|
this.updatedAt = updatedAt;
|
|
745
614
|
}
|
|
746
615
|
}
|
|
747
|
-
/** A Session returned by the listing endpoint, including its latest turn status. */
|
|
748
|
-
export class MobiusSessionListing extends MobiusSession {
|
|
749
|
-
busyStatus;
|
|
750
|
-
constructor(session, busyStatus) {
|
|
751
|
-
super(session.agentId, session.createdAt, session.createdBy, session.defaultBinding, session.hasNativeHistory, session.lastCommittedSequence, session.policy, session.projectId, session.runtimeId, session.sessionId, session.state, session.title, session.updatedAt);
|
|
752
|
-
this.busyStatus = busyStatus;
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
616
|
export function decodeMobiusSessionState(value) {
|
|
756
617
|
const state = record(value, "Session lifecycle");
|
|
757
618
|
const kind = stringField(state, "kind", 32);
|
|
@@ -782,22 +643,6 @@ export function decodeMobiusSession(value) {
|
|
|
782
643
|
}
|
|
783
644
|
return new MobiusSession(identifierField(session, "agentId"), validateTimestamp(stringField(session, "createdAt", 128), "createdAt"), identifierField(session, "createdBy"), decodeBinding(session["defaultBinding"]), booleanField(session, "hasNativeHistory"), sequence, decodeRecordingPolicy(session["policy"]), identifierField(session, "projectId"), identifierField(session, "runtimeId"), identifierField(session, "sessionId"), decodeMobiusSessionState(session["lifecycle"]), stringField(session, "title", 500), validateTimestamp(stringField(session, "updatedAt", 128), "updatedAt"));
|
|
784
645
|
}
|
|
785
|
-
export function decodeMobiusSessionListing(value) {
|
|
786
|
-
const session = record(value, "Session");
|
|
787
|
-
return new MobiusSessionListing(decodeMobiusSession(session), busyStatusField(session, "busyStatus"));
|
|
788
|
-
}
|
|
789
|
-
export class MobiusSessionPage {
|
|
790
|
-
nextCursor;
|
|
791
|
-
sessions;
|
|
792
|
-
constructor(sessions, nextCursor) {
|
|
793
|
-
this.nextCursor = nextCursor;
|
|
794
|
-
this.sessions = sessions;
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
export function decodeMobiusSessionPage(value) {
|
|
798
|
-
const page = record(value, "Session page");
|
|
799
|
-
return new MobiusSessionPage(arrayField(page, "sessions", 100).map(decodeMobiusSessionListing), nullableCursor(page, "nextCursor"));
|
|
800
|
-
}
|
|
801
646
|
export class MobiusTurnState {
|
|
802
647
|
}
|
|
803
648
|
export class MobiusQueuedTurnState extends MobiusTurnState {
|
|
@@ -902,366 +747,4 @@ export function decodeMobiusTurn(value) {
|
|
|
902
747
|
}
|
|
903
748
|
return new MobiusTurn(turn.acceptedAt, turn.bindingId, turn.request.kind === "prompt" ? turn.request.content : "", turn.idempotencyKey, turn.sessionId, turn.request.kind === "prompt" ? turn.request.sessionConfigurations : [], state, turn.turnId, turn.request);
|
|
904
749
|
}
|
|
905
|
-
export function decodeMobiusAttempt(value) {
|
|
906
|
-
try {
|
|
907
|
-
return decodeAttempt(value);
|
|
908
|
-
}
|
|
909
|
-
catch (cause) {
|
|
910
|
-
throw new MobiusProtocolError("The service returned an invalid Attempt", {
|
|
911
|
-
cause,
|
|
912
|
-
});
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
export class MobiusAttemptSummary {
|
|
916
|
-
}
|
|
917
|
-
export class MobiusNoAttemptSummary extends MobiusAttemptSummary {
|
|
918
|
-
kind = "none";
|
|
919
|
-
}
|
|
920
|
-
export class MobiusPresentAttemptSummary extends MobiusAttemptSummary {
|
|
921
|
-
attemptId;
|
|
922
|
-
constructor(attemptId) {
|
|
923
|
-
super();
|
|
924
|
-
this.attemptId = attemptId;
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
export class MobiusDispatchingAttemptSummary extends MobiusPresentAttemptSummary {
|
|
928
|
-
dispatchedAt;
|
|
929
|
-
kind = "dispatching";
|
|
930
|
-
constructor(attemptId, dispatchedAt) {
|
|
931
|
-
super(attemptId);
|
|
932
|
-
this.dispatchedAt = dispatchedAt;
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
export class MobiusRunningAttemptSummary extends MobiusPresentAttemptSummary {
|
|
936
|
-
kind = "running";
|
|
937
|
-
startedAt;
|
|
938
|
-
constructor(attemptId, startedAt) {
|
|
939
|
-
super(attemptId);
|
|
940
|
-
this.startedAt = startedAt;
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
export class MobiusSucceededAttemptSummary extends MobiusPresentAttemptSummary {
|
|
944
|
-
completedAt;
|
|
945
|
-
kind = "succeeded";
|
|
946
|
-
startedAt;
|
|
947
|
-
stopReason;
|
|
948
|
-
constructor(attemptId, startedAt, completedAt, stopReason) {
|
|
949
|
-
super(attemptId);
|
|
950
|
-
this.completedAt = completedAt;
|
|
951
|
-
this.startedAt = startedAt;
|
|
952
|
-
this.stopReason = stopReason;
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
export class MobiusCancelledAttemptSummary extends MobiusPresentAttemptSummary {
|
|
956
|
-
cancelledAt;
|
|
957
|
-
kind = "cancelled";
|
|
958
|
-
startedAt;
|
|
959
|
-
constructor(attemptId, startedAt, cancelledAt) {
|
|
960
|
-
super(attemptId);
|
|
961
|
-
this.cancelledAt = cancelledAt;
|
|
962
|
-
this.startedAt = startedAt;
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
export class MobiusWaitingInputAttemptSummary extends MobiusPresentAttemptSummary {
|
|
966
|
-
interactionIds;
|
|
967
|
-
kind = "waiting_input";
|
|
968
|
-
startedAt;
|
|
969
|
-
constructor(attemptId, startedAt, interactionIds) {
|
|
970
|
-
super(attemptId);
|
|
971
|
-
this.interactionIds = interactionIds;
|
|
972
|
-
this.startedAt = startedAt;
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
export class MobiusFailedBeforeStartAttemptSummary extends MobiusAttemptSummary {
|
|
976
|
-
code;
|
|
977
|
-
failedAt;
|
|
978
|
-
kind = "failed";
|
|
979
|
-
message;
|
|
980
|
-
constructor(code, message, failedAt) {
|
|
981
|
-
super();
|
|
982
|
-
this.code = code;
|
|
983
|
-
this.failedAt = failedAt;
|
|
984
|
-
this.message = message;
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
export class MobiusFailedAttemptSummary extends MobiusPresentAttemptSummary {
|
|
988
|
-
code;
|
|
989
|
-
failedAt;
|
|
990
|
-
kind = "failed";
|
|
991
|
-
message;
|
|
992
|
-
startedAt;
|
|
993
|
-
constructor(attemptId, startedAt, code, message, failedAt) {
|
|
994
|
-
super(attemptId);
|
|
995
|
-
this.code = code;
|
|
996
|
-
this.failedAt = failedAt;
|
|
997
|
-
this.message = message;
|
|
998
|
-
this.startedAt = startedAt;
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
export class MobiusIndeterminateAttemptSummary extends MobiusPresentAttemptSummary {
|
|
1002
|
-
detectedAt;
|
|
1003
|
-
kind = "indeterminate";
|
|
1004
|
-
startedAt;
|
|
1005
|
-
constructor(attemptId, startedAt, detectedAt) {
|
|
1006
|
-
super(attemptId);
|
|
1007
|
-
this.detectedAt = detectedAt;
|
|
1008
|
-
this.startedAt = startedAt;
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
export function decodeMobiusAttemptSummary(value) {
|
|
1012
|
-
if (value === null) {
|
|
1013
|
-
return new MobiusNoAttemptSummary();
|
|
1014
|
-
}
|
|
1015
|
-
const attempt = record(value, "Attempt summary");
|
|
1016
|
-
const kind = stringField(attempt, "kind", 32);
|
|
1017
|
-
if (kind === "failed") {
|
|
1018
|
-
const attemptId = attempt["attemptId"];
|
|
1019
|
-
const startedAt = attempt["startedAt"];
|
|
1020
|
-
const code = identifierField(attempt, "code");
|
|
1021
|
-
const message = stringField(attempt, "message", 2_000);
|
|
1022
|
-
const failedAt = validateTimestamp(stringField(attempt, "failedAt", 128), "failedAt");
|
|
1023
|
-
if (attemptId === null && startedAt === null) {
|
|
1024
|
-
return new MobiusFailedBeforeStartAttemptSummary(code, message, failedAt);
|
|
1025
|
-
}
|
|
1026
|
-
if (typeof attemptId !== "string" || typeof startedAt !== "string") {
|
|
1027
|
-
throw invalidResponse("The service returned an invalid failed Attempt");
|
|
1028
|
-
}
|
|
1029
|
-
return new MobiusFailedAttemptSummary(attemptId, validateTimestamp(startedAt, "startedAt"), code, message, failedAt);
|
|
1030
|
-
}
|
|
1031
|
-
const attemptId = identifierField(attempt, "attemptId");
|
|
1032
|
-
if (kind === "dispatching") {
|
|
1033
|
-
return new MobiusDispatchingAttemptSummary(attemptId, validateTimestamp(stringField(attempt, "dispatchedAt", 128), "dispatchedAt"));
|
|
1034
|
-
}
|
|
1035
|
-
const startedAt = validateTimestamp(stringField(attempt, "startedAt", 128), "startedAt");
|
|
1036
|
-
if (kind === "running") {
|
|
1037
|
-
return new MobiusRunningAttemptSummary(attemptId, startedAt);
|
|
1038
|
-
}
|
|
1039
|
-
if (kind === "succeeded") {
|
|
1040
|
-
return new MobiusSucceededAttemptSummary(attemptId, startedAt, validateTimestamp(stringField(attempt, "completedAt", 128), "completedAt"), stringField(attempt, "stopReason", 128));
|
|
1041
|
-
}
|
|
1042
|
-
if (kind === "cancelled") {
|
|
1043
|
-
return new MobiusCancelledAttemptSummary(attemptId, startedAt, validateTimestamp(stringField(attempt, "cancelledAt", 128), "cancelledAt"));
|
|
1044
|
-
}
|
|
1045
|
-
if (kind === "waiting_input") {
|
|
1046
|
-
return new MobiusWaitingInputAttemptSummary(attemptId, startedAt, arrayField(attempt, "interactionIds", 100).map((interactionId) => {
|
|
1047
|
-
if (typeof interactionId !== "string") {
|
|
1048
|
-
throw invalidResponse("The service returned an invalid interaction identifier");
|
|
1049
|
-
}
|
|
1050
|
-
return identifierField({ interactionId }, "interactionId");
|
|
1051
|
-
}));
|
|
1052
|
-
}
|
|
1053
|
-
if (kind === "indeterminate") {
|
|
1054
|
-
return new MobiusIndeterminateAttemptSummary(attemptId, startedAt, validateTimestamp(stringField(attempt, "detectedAt", 128), "detectedAt"));
|
|
1055
|
-
}
|
|
1056
|
-
throw invalidResponse("The service returned an unsupported Attempt state");
|
|
1057
|
-
}
|
|
1058
|
-
export class MobiusActivitySummary {
|
|
1059
|
-
activityId;
|
|
1060
|
-
attemptId;
|
|
1061
|
-
activityType;
|
|
1062
|
-
detailAvailability;
|
|
1063
|
-
input;
|
|
1064
|
-
locations;
|
|
1065
|
-
name;
|
|
1066
|
-
output;
|
|
1067
|
-
sequence;
|
|
1068
|
-
status;
|
|
1069
|
-
title;
|
|
1070
|
-
toolCallId;
|
|
1071
|
-
toolKind;
|
|
1072
|
-
constructor(activityId, attemptId, activityType, detailAvailability, input, locations, name, output, sequence, status, title, toolCallId, toolKind) {
|
|
1073
|
-
this.activityId = activityId;
|
|
1074
|
-
this.attemptId = attemptId;
|
|
1075
|
-
this.activityType = activityType;
|
|
1076
|
-
this.detailAvailability = detailAvailability;
|
|
1077
|
-
this.input = input;
|
|
1078
|
-
this.locations = locations;
|
|
1079
|
-
this.name = name;
|
|
1080
|
-
this.output = output;
|
|
1081
|
-
this.sequence = sequence;
|
|
1082
|
-
this.status = status;
|
|
1083
|
-
this.title = title;
|
|
1084
|
-
this.toolCallId = toolCallId;
|
|
1085
|
-
this.toolKind = toolKind;
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
export function decodeMobiusActivitySummary(value) {
|
|
1089
|
-
const activity = record(value, "Activity summary");
|
|
1090
|
-
return new MobiusActivitySummary(identifierField(activity, "activityId"), identifierField(activity, "attemptId"), stringField(activity, "activityType", 128), stringField(activity, "detailAvailability", 32), stringField(activity, "input", AGENT_ACTIVITY_DETAIL_LIMIT), arrayField(activity, "locations", 100).map((location) => {
|
|
1091
|
-
if (typeof location !== "string" || location.length > 2_048) {
|
|
1092
|
-
throw invalidResponse("The service returned an invalid Activity location");
|
|
1093
|
-
}
|
|
1094
|
-
return location;
|
|
1095
|
-
}), stringField(activity, "name", 128), stringField(activity, "output", AGENT_ACTIVITY_DETAIL_LIMIT), integerField(activity, "sequence"), stringField(activity, "status", 64), stringField(activity, "title", 500), identifierField(activity, "toolCallId"), stringField(activity, "toolKind", 128));
|
|
1096
|
-
}
|
|
1097
|
-
/**
|
|
1098
|
-
* A stored step whose recorded shape a later protocol revision can no longer decode must cost only that
|
|
1099
|
-
* step. Failing the whole page would hide every other Turn in the Session, so an unreadable summary is
|
|
1100
|
-
* dropped from the restored conversation instead.
|
|
1101
|
-
*/
|
|
1102
|
-
function decodeMobiusActivitySummaries(values) {
|
|
1103
|
-
const activities = [];
|
|
1104
|
-
for (const value of values) {
|
|
1105
|
-
try {
|
|
1106
|
-
activities.push(decodeMobiusActivitySummary(value));
|
|
1107
|
-
}
|
|
1108
|
-
catch {
|
|
1109
|
-
// Skip the unreadable entry and keep the rest of the conversation.
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
return activities;
|
|
1113
|
-
}
|
|
1114
|
-
export class MobiusMessageContent {
|
|
1115
|
-
activities;
|
|
1116
|
-
additionalDirectoryIds;
|
|
1117
|
-
attempt;
|
|
1118
|
-
createdAt;
|
|
1119
|
-
disposition;
|
|
1120
|
-
images;
|
|
1121
|
-
messageId;
|
|
1122
|
-
prompt;
|
|
1123
|
-
resources;
|
|
1124
|
-
response;
|
|
1125
|
-
constructor(activities, additionalDirectoryIds, attempt, createdAt, disposition, images, messageId, prompt, resources, response) {
|
|
1126
|
-
this.activities = activities;
|
|
1127
|
-
this.additionalDirectoryIds = additionalDirectoryIds;
|
|
1128
|
-
this.attempt = attempt;
|
|
1129
|
-
this.createdAt = createdAt;
|
|
1130
|
-
this.disposition = disposition;
|
|
1131
|
-
this.images = images;
|
|
1132
|
-
this.messageId = messageId;
|
|
1133
|
-
this.prompt = prompt;
|
|
1134
|
-
this.resources = resources;
|
|
1135
|
-
this.response = response;
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
export class MobiusMessage extends MobiusMessageContent {
|
|
1139
|
-
agentId;
|
|
1140
|
-
commandId;
|
|
1141
|
-
contents;
|
|
1142
|
-
sessionId;
|
|
1143
|
-
targetCommandId;
|
|
1144
|
-
turnId;
|
|
1145
|
-
constructor(content, agentId, commandId, contents, sessionId, targetCommandId, turnId = "") {
|
|
1146
|
-
super(content.activities, content.additionalDirectoryIds, content.attempt, content.createdAt, content.disposition, content.images, content.messageId, content.prompt, content.resources, content.response);
|
|
1147
|
-
this.agentId = agentId;
|
|
1148
|
-
this.commandId = commandId;
|
|
1149
|
-
this.contents = contents;
|
|
1150
|
-
this.sessionId = sessionId;
|
|
1151
|
-
this.targetCommandId = targetCommandId;
|
|
1152
|
-
this.turnId = turnId;
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1155
|
-
export function decodeMobiusMessageContent(message) {
|
|
1156
|
-
return new MobiusMessageContent(decodeMobiusActivitySummaries(arrayField(message, "activities", 10_000)), arrayField(message, "additionalDirectoryIds", 100).map((directoryId) => {
|
|
1157
|
-
if (typeof directoryId !== "string") {
|
|
1158
|
-
throw invalidResponse("The service returned an invalid additional directory identifier");
|
|
1159
|
-
}
|
|
1160
|
-
return identifierField({ directoryId }, "directoryId");
|
|
1161
|
-
}), decodeMobiusAttemptSummary(message["attempt"]), validateTimestamp(stringField(message, "createdAt", 128), "createdAt"), stringField(message, "disposition", 16), decodePromptImagesValue(message["images"]), stringField(message, "messageId", 255), stringField(message, "prompt", 100_000), decodePromptResourcesValue(message["resources"]), stringField(message, "response", 8_500_000));
|
|
1162
|
-
}
|
|
1163
|
-
function decodeMobiusMessage(value) {
|
|
1164
|
-
const message = record(value, "Session message");
|
|
1165
|
-
return new MobiusMessage(decodeMobiusMessageContent(message), identifierField(message, "agentId"), identifierField(message, "commandId"), arrayField(message, "contents", 100).map(decodeAgentDisplayContentValue), identifierField(message, "sessionId"), stringField(message, "targetCommandId", 128), stringField(message, "turnId", 128));
|
|
1166
|
-
}
|
|
1167
|
-
export class MobiusMessagePage {
|
|
1168
|
-
lastCommittedSequence;
|
|
1169
|
-
messages;
|
|
1170
|
-
nextCursor;
|
|
1171
|
-
tailEventCursor;
|
|
1172
|
-
constructor(lastCommittedSequence, messages, nextCursor, tailEventCursor) {
|
|
1173
|
-
this.lastCommittedSequence = lastCommittedSequence;
|
|
1174
|
-
this.messages = messages;
|
|
1175
|
-
this.nextCursor = nextCursor;
|
|
1176
|
-
this.tailEventCursor = tailEventCursor;
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
export function decodeMobiusMessagePage(value) {
|
|
1180
|
-
const page = record(value, "Session message page");
|
|
1181
|
-
const sequence = stringField(page, "lastCommittedSeq", 40);
|
|
1182
|
-
if (!/^(?:0|[1-9][0-9]*)$/.test(sequence)) {
|
|
1183
|
-
throw invalidResponse("The service returned an invalid event sequence");
|
|
1184
|
-
}
|
|
1185
|
-
const tailEventCursor = page["tailEventCursor"];
|
|
1186
|
-
if (tailEventCursor !== undefined && (typeof tailEventCursor !== "string" || tailEventCursor.length > 512)) {
|
|
1187
|
-
throw invalidResponse("The service returned an invalid tailEventCursor");
|
|
1188
|
-
}
|
|
1189
|
-
return new MobiusMessagePage(sequence, arrayField(page, "messages", 100).map(decodeMobiusMessage), nullableCursor(page, "nextCursor"), tailEventCursor ?? "");
|
|
1190
|
-
}
|
|
1191
|
-
export class MobiusToolCallDetail {
|
|
1192
|
-
}
|
|
1193
|
-
export class MobiusAvailableToolCallDetail extends MobiusToolCallDetail {
|
|
1194
|
-
artifactId;
|
|
1195
|
-
content;
|
|
1196
|
-
input;
|
|
1197
|
-
kind = "available";
|
|
1198
|
-
output;
|
|
1199
|
-
storage;
|
|
1200
|
-
constructor(artifactId, content, input, output, storage) {
|
|
1201
|
-
super();
|
|
1202
|
-
this.artifactId = artifactId;
|
|
1203
|
-
this.content = content;
|
|
1204
|
-
this.input = input;
|
|
1205
|
-
this.output = output;
|
|
1206
|
-
this.storage = storage;
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
export class MobiusTruncatedToolCallDetail extends MobiusToolCallDetail {
|
|
1210
|
-
capturedBytes;
|
|
1211
|
-
kind = "truncated";
|
|
1212
|
-
originalBytes;
|
|
1213
|
-
constructor(capturedBytes, originalBytes) {
|
|
1214
|
-
super();
|
|
1215
|
-
this.capturedBytes = capturedBytes;
|
|
1216
|
-
this.originalBytes = originalBytes;
|
|
1217
|
-
}
|
|
1218
|
-
}
|
|
1219
|
-
export class MobiusUnrecordedToolCallDetail extends MobiusToolCallDetail {
|
|
1220
|
-
kind = "unrecorded";
|
|
1221
|
-
}
|
|
1222
|
-
export class MobiusDeletedToolCallDetail extends MobiusToolCallDetail {
|
|
1223
|
-
deletedAt;
|
|
1224
|
-
kind = "deleted";
|
|
1225
|
-
constructor(deletedAt) {
|
|
1226
|
-
super();
|
|
1227
|
-
this.deletedAt = deletedAt;
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
export function decodeMobiusToolCallDetail(value) {
|
|
1231
|
-
const detail = record(value, "ToolCall detail");
|
|
1232
|
-
const kind = stringField(detail, "kind", 32);
|
|
1233
|
-
if (kind === "available") {
|
|
1234
|
-
const storage = stringField(detail, "storage", 32);
|
|
1235
|
-
if (storage !== "archive" && storage !== "hot") {
|
|
1236
|
-
throw invalidResponse("The service returned an invalid ToolCall storage state");
|
|
1237
|
-
}
|
|
1238
|
-
return new MobiusAvailableToolCallDetail(identifierField(detail, "artifactId"), arrayField(detail, "content", 100_000), stringField(detail, "input"), stringField(detail, "output"), storage);
|
|
1239
|
-
}
|
|
1240
|
-
if (kind === "truncated") {
|
|
1241
|
-
return new MobiusTruncatedToolCallDetail(integerField(detail, "capturedBytes"), integerField(detail, "originalBytes"));
|
|
1242
|
-
}
|
|
1243
|
-
if (kind === "unrecorded") {
|
|
1244
|
-
return new MobiusUnrecordedToolCallDetail();
|
|
1245
|
-
}
|
|
1246
|
-
if (kind === "deleted") {
|
|
1247
|
-
return new MobiusDeletedToolCallDetail(validateTimestamp(stringField(detail, "deletedAt", 128), "deletedAt"));
|
|
1248
|
-
}
|
|
1249
|
-
throw invalidResponse("The service returned an invalid ToolCall detail");
|
|
1250
|
-
}
|
|
1251
|
-
export class MobiusSessionExport {
|
|
1252
|
-
formatVersion;
|
|
1253
|
-
session;
|
|
1254
|
-
constructor(formatVersion, session) {
|
|
1255
|
-
this.formatVersion = formatVersion;
|
|
1256
|
-
this.session = session;
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
export function decodeMobiusSessionExport(value) {
|
|
1260
|
-
const exported = record(value, "Session export");
|
|
1261
|
-
const formatVersion = stringField(exported, "formatVersion", 32);
|
|
1262
|
-
if (formatVersion !== MOBIUS_SESSION_EXPORT_FORMAT_VERSION) {
|
|
1263
|
-
throw invalidResponse("The service returned an unsupported Session export");
|
|
1264
|
-
}
|
|
1265
|
-
return new MobiusSessionExport(formatVersion, record(exported["session"], "Session export payload"));
|
|
1266
|
-
}
|
|
1267
750
|
//# sourceMappingURL=resources.js.map
|