@mitralab.io/sdk-core 0.3.6 → 0.3.8
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/CHANGELOG.md +52 -0
- package/README.md +29 -12
- package/contracts/README.md +9 -0
- package/contracts/manifest.json +11 -1
- package/contracts/v0.3.7/sdk-parity.json +2902 -0
- package/contracts/v0.3.8/sdk-parity.json +2902 -0
- package/dist/index.cjs +161 -236
- package/dist/index.d.cts +97 -161
- package/dist/index.d.ts +97 -161
- package/dist/index.js +160 -236
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,7 @@ __export(index_exports, {
|
|
|
30
30
|
createAgentTaskSessionManager: () => createAgentTaskSessionManager,
|
|
31
31
|
createAgentTasksModule: () => createAgentTasksModule,
|
|
32
32
|
createAgentsModule: () => createAgentsModule,
|
|
33
|
+
createAiProvidersModule: () => createAiProvidersModule,
|
|
33
34
|
createAppsModule: () => createAppsModule,
|
|
34
35
|
createAuthModule: () => createAuthModule,
|
|
35
36
|
createContextModule: () => createContextModule,
|
|
@@ -120,9 +121,6 @@ function isObject(value) {
|
|
|
120
121
|
function isNullableString(value) {
|
|
121
122
|
return value === null || typeof value === "string";
|
|
122
123
|
}
|
|
123
|
-
function isNonEmptyString(value) {
|
|
124
|
-
return typeof value === "string" && value.length > 0;
|
|
125
|
-
}
|
|
126
124
|
function isNullableBoolean(value) {
|
|
127
125
|
return value === null || typeof value === "boolean";
|
|
128
126
|
}
|
|
@@ -511,9 +509,6 @@ function expectAppFields(app, context, errors) {
|
|
|
511
509
|
if (!isNullableString(app.icon)) invalidField(context, "icon", errors);
|
|
512
510
|
if (!isNullableString(app.template)) invalidField(context, "template", errors);
|
|
513
511
|
if (typeof app.allowSignup !== "boolean") invalidField(context, "allowSignup", errors);
|
|
514
|
-
for (const field of ["emailLoginEnabled", "passwordLoginEnabled"]) {
|
|
515
|
-
if (field in app && typeof app[field] !== "boolean") invalidField(context, field, errors);
|
|
516
|
-
}
|
|
517
512
|
if (typeof app.externalAccessEnabled !== "boolean") {
|
|
518
513
|
invalidField(context, "externalAccessEnabled", errors);
|
|
519
514
|
}
|
|
@@ -756,83 +751,6 @@ function expectMessageAccepted(value, context, errors = defaultSdkCoreErrorFacto
|
|
|
756
751
|
if (typeof response.messageId !== "string") invalidField(context, "messageId", errors);
|
|
757
752
|
return response;
|
|
758
753
|
}
|
|
759
|
-
function expectEmailTemplate(value, context, errors = defaultSdkCoreErrorFactory) {
|
|
760
|
-
const template = expectObject(value, context, errors);
|
|
761
|
-
if (typeof template.id !== "string") invalidField(context, "id", errors);
|
|
762
|
-
if (!isNonEmptyString(template.type)) invalidField(context, "type", errors);
|
|
763
|
-
if (!isNullableString(template.senderIdentityId)) {
|
|
764
|
-
invalidField(context, "senderIdentityId", errors);
|
|
765
|
-
}
|
|
766
|
-
if (typeof template.subject !== "string") invalidField(context, "subject", errors);
|
|
767
|
-
if (typeof template.htmlBody !== "string") invalidField(context, "htmlBody", errors);
|
|
768
|
-
if (!isNullableString(template.textBody)) invalidField(context, "textBody", errors);
|
|
769
|
-
if (typeof template.platformDefault !== "boolean") {
|
|
770
|
-
invalidField(context, "platformDefault", errors);
|
|
771
|
-
}
|
|
772
|
-
if (typeof template.createdAt !== "string") invalidField(context, "createdAt", errors);
|
|
773
|
-
if (typeof template.updatedAt !== "string") invalidField(context, "updatedAt", errors);
|
|
774
|
-
return template;
|
|
775
|
-
}
|
|
776
|
-
function expectEmailTemplateTypeCatalog(value, context, errors = defaultSdkCoreErrorFactory) {
|
|
777
|
-
const catalog = expectObject(value, context, errors);
|
|
778
|
-
if (!isNonEmptyString(catalog.type)) invalidField(context, "type", errors);
|
|
779
|
-
expectObjectArray(catalog.variables, `${context} variables`, errors).forEach(
|
|
780
|
-
(variable, position) => {
|
|
781
|
-
const variableContext = `${context} variable ${position}`;
|
|
782
|
-
if (typeof variable.name !== "string") invalidField(variableContext, "name", errors);
|
|
783
|
-
if (typeof variable.required !== "boolean") {
|
|
784
|
-
invalidField(variableContext, "required", errors);
|
|
785
|
-
}
|
|
786
|
-
if (!isNullableString(variable.description)) {
|
|
787
|
-
invalidField(variableContext, "description", errors);
|
|
788
|
-
}
|
|
789
|
-
if (!isNullableString(variable.preview)) invalidField(variableContext, "preview", errors);
|
|
790
|
-
}
|
|
791
|
-
);
|
|
792
|
-
return catalog;
|
|
793
|
-
}
|
|
794
|
-
function expectEmailTemplatePreview(value, context, errors = defaultSdkCoreErrorFactory) {
|
|
795
|
-
const preview = expectObject(value, context, errors);
|
|
796
|
-
if (typeof preview.subject !== "string") invalidField(context, "subject", errors);
|
|
797
|
-
if (typeof preview.htmlBody !== "string") invalidField(context, "htmlBody", errors);
|
|
798
|
-
if (!isNullableString(preview.textBody)) invalidField(context, "textBody", errors);
|
|
799
|
-
return preview;
|
|
800
|
-
}
|
|
801
|
-
function expectEmailSender(value, context, errors = defaultSdkCoreErrorFactory) {
|
|
802
|
-
const sender = expectObject(value, context, errors);
|
|
803
|
-
if (typeof sender.id !== "string") invalidField(context, "id", errors);
|
|
804
|
-
if (typeof sender.email !== "string") invalidField(context, "email", errors);
|
|
805
|
-
if (typeof sender.displayName !== "string") invalidField(context, "displayName", errors);
|
|
806
|
-
if (!isNonEmptyString(sender.status)) invalidField(context, "status", errors);
|
|
807
|
-
if (typeof sender.sharedWithCurrentWorkspace !== "boolean") {
|
|
808
|
-
invalidField(context, "sharedWithCurrentWorkspace", errors);
|
|
809
|
-
}
|
|
810
|
-
if (typeof sender.ownerConfirmationPending !== "boolean") {
|
|
811
|
-
invalidField(context, "ownerConfirmationPending", errors);
|
|
812
|
-
}
|
|
813
|
-
if (typeof sender.createdAt !== "string") invalidField(context, "createdAt", errors);
|
|
814
|
-
if (typeof sender.updatedAt !== "string") invalidField(context, "updatedAt", errors);
|
|
815
|
-
return sender;
|
|
816
|
-
}
|
|
817
|
-
function expectEmailSettings(value, context, errors = defaultSdkCoreErrorFactory) {
|
|
818
|
-
const settings = expectObject(value, context, errors);
|
|
819
|
-
if (typeof settings.appId !== "string") invalidField(context, "appId", errors);
|
|
820
|
-
if (!isNullableString(settings.senderIdentityId)) {
|
|
821
|
-
invalidField(context, "senderIdentityId", errors);
|
|
822
|
-
}
|
|
823
|
-
if (!isNullableString(settings.displayName)) invalidField(context, "displayName", errors);
|
|
824
|
-
if (!isNullableString(settings.replyTo)) invalidField(context, "replyTo", errors);
|
|
825
|
-
if (typeof settings.ownTemplateSendsFromBrand !== "boolean") {
|
|
826
|
-
invalidField(context, "ownTemplateSendsFromBrand", errors);
|
|
827
|
-
}
|
|
828
|
-
const senderContext = `${context} effectiveSender`;
|
|
829
|
-
const sender = expectObject(settings.effectiveSender, senderContext, errors);
|
|
830
|
-
if (typeof sender.email !== "string") invalidField(senderContext, "email", errors);
|
|
831
|
-
if (!isNullableString(sender.displayName)) invalidField(senderContext, "displayName", errors);
|
|
832
|
-
if (!isNonEmptyString(sender.source)) invalidField(senderContext, "source", errors);
|
|
833
|
-
if (!isNullableString(sender.reason)) invalidField(senderContext, "reason", errors);
|
|
834
|
-
return settings;
|
|
835
|
-
}
|
|
836
754
|
function expectAgentDefinition(value, context, errors = defaultSdkCoreErrorFactory) {
|
|
837
755
|
const agent = expectObject(value, context, errors);
|
|
838
756
|
if (typeof agent.id !== "string") invalidField(context, "id", errors);
|
|
@@ -1181,6 +1099,78 @@ function expectAgentModel(value, context, errors = defaultSdkCoreErrorFactory) {
|
|
|
1181
1099
|
}
|
|
1182
1100
|
return model;
|
|
1183
1101
|
}
|
|
1102
|
+
function expectAiProviders(value, context, errors = defaultSdkCoreErrorFactory) {
|
|
1103
|
+
const providers = expectObject(value, context, errors);
|
|
1104
|
+
if (typeof providers.activeEngine !== "string") {
|
|
1105
|
+
invalidField(context, "activeEngine", errors);
|
|
1106
|
+
}
|
|
1107
|
+
if (typeof providers.includedAiAvailable !== "boolean") {
|
|
1108
|
+
invalidField(context, "includedAiAvailable", errors);
|
|
1109
|
+
}
|
|
1110
|
+
if (!isNullableString(providers.activeCustomProviderId)) {
|
|
1111
|
+
invalidField(context, "activeCustomProviderId", errors);
|
|
1112
|
+
}
|
|
1113
|
+
expectObjectArray(
|
|
1114
|
+
providers.customProviders,
|
|
1115
|
+
`${context} customProviders`,
|
|
1116
|
+
errors,
|
|
1117
|
+
expectAgentConnectionCustomProvider
|
|
1118
|
+
);
|
|
1119
|
+
if (providers.includedAiQuota !== null) {
|
|
1120
|
+
expectIncludedAiQuota(providers.includedAiQuota, `${context} includedAiQuota`, errors);
|
|
1121
|
+
}
|
|
1122
|
+
const opencode = expectObject(providers.opencode, `${context} opencode`, errors);
|
|
1123
|
+
if (typeof opencode.connected !== "boolean") invalidField(context, "opencode.connected", errors);
|
|
1124
|
+
for (const field of ["presetId", "presetName", "providerId", "baseUrl"]) {
|
|
1125
|
+
if (!isNullableString(opencode[field])) invalidField(context, `opencode.${field}`, errors);
|
|
1126
|
+
}
|
|
1127
|
+
if (!isNullableString(opencode.authMethod)) {
|
|
1128
|
+
invalidField(context, "opencode.authMethod", errors);
|
|
1129
|
+
}
|
|
1130
|
+
if (opencode.models !== null && !isStringArray(opencode.models)) {
|
|
1131
|
+
invalidField(context, "opencode.models", errors);
|
|
1132
|
+
}
|
|
1133
|
+
if (hasOwn(providers, "managedAiProfile") && providers.managedAiProfile !== null) {
|
|
1134
|
+
const profile = expectObject(
|
|
1135
|
+
providers.managedAiProfile,
|
|
1136
|
+
`${context} managedAiProfile`,
|
|
1137
|
+
errors
|
|
1138
|
+
);
|
|
1139
|
+
for (const field of [
|
|
1140
|
+
"profile",
|
|
1141
|
+
"agentType",
|
|
1142
|
+
"selectionMode",
|
|
1143
|
+
"model",
|
|
1144
|
+
"requiredScope"
|
|
1145
|
+
]) {
|
|
1146
|
+
if (typeof profile[field] !== "string") {
|
|
1147
|
+
invalidField(context, `managedAiProfile.${field}`, errors);
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
return providers;
|
|
1152
|
+
}
|
|
1153
|
+
function expectIncludedAiQuota(value, context, errors) {
|
|
1154
|
+
const quota = expectObject(value, context, errors);
|
|
1155
|
+
if (typeof quota.planCode !== "string") invalidField(context, "planCode", errors);
|
|
1156
|
+
if (hasOwn(quota, "blockingWindow") && typeof quota.blockingWindow !== "string") {
|
|
1157
|
+
invalidField(context, "blockingWindow", errors);
|
|
1158
|
+
}
|
|
1159
|
+
if (hasOwn(quota, "remainingTokens") && !isInteger(quota.remainingTokens)) {
|
|
1160
|
+
invalidField(context, "remainingTokens", errors);
|
|
1161
|
+
}
|
|
1162
|
+
const windows = expectObject(quota.windows, `${context} windows`, errors);
|
|
1163
|
+
for (const kind of ["day", "month"]) {
|
|
1164
|
+
if (!hasOwn(windows, kind)) continue;
|
|
1165
|
+
const window = expectObject(windows[kind], `${context} windows.${kind}`, errors);
|
|
1166
|
+
for (const field of ["limit", "left", "leftCenticredits"]) {
|
|
1167
|
+
if (!isInteger(window[field])) invalidField(context, `windows.${kind}.${field}`, errors);
|
|
1168
|
+
}
|
|
1169
|
+
if (typeof window.resetsAt !== "string") {
|
|
1170
|
+
invalidField(context, `windows.${kind}.resetsAt`, errors);
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1184
1174
|
function expectCredentialStatus(value, context, errors = defaultSdkCoreErrorFactory) {
|
|
1185
1175
|
const status = expectObject(value, context, errors);
|
|
1186
1176
|
if (typeof status.provider !== "string") invalidField(context, "provider", errors);
|
|
@@ -1791,6 +1781,7 @@ function createAgentTasksModule(transport, errors = defaultSdkCoreErrorFactory)
|
|
|
1791
1781
|
size: options.size,
|
|
1792
1782
|
sort: options.sort,
|
|
1793
1783
|
kinds: options.kinds,
|
|
1784
|
+
include: options.include,
|
|
1794
1785
|
before: options.before
|
|
1795
1786
|
}
|
|
1796
1787
|
}),
|
|
@@ -1814,6 +1805,19 @@ function createAgentTasksModule(transport, errors = defaultSdkCoreErrorFactory)
|
|
|
1814
1805
|
};
|
|
1815
1806
|
}
|
|
1816
1807
|
|
|
1808
|
+
// src/modules/aiProviders.ts
|
|
1809
|
+
function createAiProvidersModule(transport, errors = defaultSdkCoreErrorFactory) {
|
|
1810
|
+
return {
|
|
1811
|
+
async get() {
|
|
1812
|
+
return expectAiProviders(
|
|
1813
|
+
await transport.request("/api/v1/ai-providers", { method: "GET" }),
|
|
1814
|
+
"AI providers response",
|
|
1815
|
+
errors
|
|
1816
|
+
);
|
|
1817
|
+
}
|
|
1818
|
+
};
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1817
1821
|
// src/modules/apps.ts
|
|
1818
1822
|
function createAppsModule(transport, errors = defaultSdkCoreErrorFactory) {
|
|
1819
1823
|
const appPath = (appId) => `/api/v1/apps/${encodePathSegment(appId, "app id", errors)}`;
|
|
@@ -3030,23 +3034,7 @@ function createMembersModule(transport, errors = defaultSdkCoreErrorFactory) {
|
|
|
3030
3034
|
}
|
|
3031
3035
|
|
|
3032
3036
|
// src/modules/messenger.ts
|
|
3033
|
-
function createMessengerModule(transport, errors = defaultSdkCoreErrorFactory
|
|
3034
|
-
const templatePath = (type) => `/api/v1/email/templates/${encodePathSegment(type, "email template type", errors)}`;
|
|
3035
|
-
const senderPath = (senderId) => `/api/v1/email/identities/${encodePathSegment(senderId, "email sender id", errors)}`;
|
|
3036
|
-
const currentAppId = () => {
|
|
3037
|
-
const appId = getAppId?.();
|
|
3038
|
-
if (!appId) configurationError("An appId is required for app email calls", errors);
|
|
3039
|
-
return appId;
|
|
3040
|
-
};
|
|
3041
|
-
const settingsPath = () => `/api/v1/email/apps/${encodePathSegment(currentAppId(), "app id", errors)}/settings`;
|
|
3042
|
-
const preview = async (type, appId) => expectEmailTemplatePreview(
|
|
3043
|
-
await transport.request(`${templatePath(type)}/preview`, {
|
|
3044
|
-
method: "GET",
|
|
3045
|
-
params: { appId }
|
|
3046
|
-
}),
|
|
3047
|
-
"Email template preview response",
|
|
3048
|
-
errors
|
|
3049
|
-
);
|
|
3037
|
+
function createMessengerModule(transport, errors = defaultSdkCoreErrorFactory) {
|
|
3050
3038
|
return {
|
|
3051
3039
|
async notify(content) {
|
|
3052
3040
|
return expectMessageAccepted(
|
|
@@ -3067,120 +3055,6 @@ function createMessengerModule(transport, errors = defaultSdkCoreErrorFactory, g
|
|
|
3067
3055
|
"Send email response",
|
|
3068
3056
|
errors
|
|
3069
3057
|
);
|
|
3070
|
-
},
|
|
3071
|
-
async listEmailTemplates() {
|
|
3072
|
-
return expectObjectArray(
|
|
3073
|
-
await transport.request("/api/v1/email/templates", {
|
|
3074
|
-
method: "GET",
|
|
3075
|
-
params: { appId: currentAppId() }
|
|
3076
|
-
}),
|
|
3077
|
-
"Email template list response",
|
|
3078
|
-
errors,
|
|
3079
|
-
expectEmailTemplate
|
|
3080
|
-
);
|
|
3081
|
-
},
|
|
3082
|
-
async getEmailTemplateType(type) {
|
|
3083
|
-
return expectEmailTemplateTypeCatalog(
|
|
3084
|
-
await transport.request(
|
|
3085
|
-
`/api/v1/email/template-types/${encodePathSegment(type, "email template type", errors)}`,
|
|
3086
|
-
{ method: "GET" }
|
|
3087
|
-
),
|
|
3088
|
-
"Email template type response",
|
|
3089
|
-
errors
|
|
3090
|
-
);
|
|
3091
|
-
},
|
|
3092
|
-
async getEmailTemplate(type) {
|
|
3093
|
-
return expectEmailTemplate(
|
|
3094
|
-
await transport.request(templatePath(type), {
|
|
3095
|
-
method: "GET",
|
|
3096
|
-
params: { appId: currentAppId() }
|
|
3097
|
-
}),
|
|
3098
|
-
"Email template response",
|
|
3099
|
-
errors
|
|
3100
|
-
);
|
|
3101
|
-
},
|
|
3102
|
-
async upsertEmailTemplate(type, input) {
|
|
3103
|
-
const appId = currentAppId();
|
|
3104
|
-
const template = expectEmailTemplate(
|
|
3105
|
-
await transport.request(templatePath(type), {
|
|
3106
|
-
method: "PUT",
|
|
3107
|
-
body: templateBody(appId, input)
|
|
3108
|
-
}),
|
|
3109
|
-
"Upsert email template response",
|
|
3110
|
-
errors
|
|
3111
|
-
);
|
|
3112
|
-
try {
|
|
3113
|
-
return { template, preview: await preview(type, appId) };
|
|
3114
|
-
} catch (previewError) {
|
|
3115
|
-
return { template, preview: null, previewError };
|
|
3116
|
-
}
|
|
3117
|
-
},
|
|
3118
|
-
async previewEmailTemplate(type) {
|
|
3119
|
-
return preview(type, currentAppId());
|
|
3120
|
-
},
|
|
3121
|
-
async deleteEmailTemplate(type) {
|
|
3122
|
-
expectEmpty(
|
|
3123
|
-
await transport.request(templatePath(type), {
|
|
3124
|
-
method: "DELETE",
|
|
3125
|
-
params: { appId: currentAppId() }
|
|
3126
|
-
}),
|
|
3127
|
-
"Delete email template response",
|
|
3128
|
-
errors
|
|
3129
|
-
);
|
|
3130
|
-
},
|
|
3131
|
-
async listEmailSenders() {
|
|
3132
|
-
return expectObjectArray(
|
|
3133
|
-
await transport.request("/api/v1/email/identities/workspace", { method: "GET" }),
|
|
3134
|
-
"Email sender list response",
|
|
3135
|
-
errors,
|
|
3136
|
-
expectEmailSender
|
|
3137
|
-
);
|
|
3138
|
-
},
|
|
3139
|
-
async registerEmailSender(input) {
|
|
3140
|
-
return expectEmailSender(
|
|
3141
|
-
await transport.request("/api/v1/email/identities", {
|
|
3142
|
-
method: "POST",
|
|
3143
|
-
body: { email: input.email, displayName: input.displayName }
|
|
3144
|
-
}),
|
|
3145
|
-
"Register email sender response",
|
|
3146
|
-
errors
|
|
3147
|
-
);
|
|
3148
|
-
},
|
|
3149
|
-
async resendEmailSenderVerification(senderId) {
|
|
3150
|
-
return expectEmailSender(
|
|
3151
|
-
await transport.request(`${senderPath(senderId)}/resend-verification`, {
|
|
3152
|
-
method: "POST"
|
|
3153
|
-
}),
|
|
3154
|
-
"Resend email sender verification response",
|
|
3155
|
-
errors
|
|
3156
|
-
);
|
|
3157
|
-
},
|
|
3158
|
-
async confirmEmailSender(senderId, code) {
|
|
3159
|
-
return expectEmailSender(
|
|
3160
|
-
await transport.request(`${senderPath(senderId)}/confirm`, {
|
|
3161
|
-
method: "POST",
|
|
3162
|
-
body: { code }
|
|
3163
|
-
}),
|
|
3164
|
-
"Confirm email sender response",
|
|
3165
|
-
errors
|
|
3166
|
-
);
|
|
3167
|
-
},
|
|
3168
|
-
async getEmailSettings() {
|
|
3169
|
-
return expectEmailSettings(
|
|
3170
|
-
await transport.request(settingsPath(), { method: "GET" }),
|
|
3171
|
-
"Email settings response",
|
|
3172
|
-
errors
|
|
3173
|
-
);
|
|
3174
|
-
},
|
|
3175
|
-
async updateEmailSettings(input) {
|
|
3176
|
-
return expectEmailSettings(
|
|
3177
|
-
await transport.request(settingsPath(), {
|
|
3178
|
-
method: "PUT",
|
|
3179
|
-
body: settingsBody(input)
|
|
3180
|
-
}),
|
|
3181
|
-
"Update email settings response",
|
|
3182
|
-
errors
|
|
3183
|
-
);
|
|
3184
3058
|
}
|
|
3185
3059
|
};
|
|
3186
3060
|
}
|
|
@@ -3196,21 +3070,6 @@ function rawEmailPayload(input) {
|
|
|
3196
3070
|
...input.text === void 0 ? {} : { text: input.text }
|
|
3197
3071
|
};
|
|
3198
3072
|
}
|
|
3199
|
-
function templateBody(appId, input) {
|
|
3200
|
-
return {
|
|
3201
|
-
appId,
|
|
3202
|
-
subject: input.subject,
|
|
3203
|
-
htmlBody: input.htmlBody,
|
|
3204
|
-
...input.textBody === void 0 ? {} : { textBody: input.textBody }
|
|
3205
|
-
};
|
|
3206
|
-
}
|
|
3207
|
-
function settingsBody(input) {
|
|
3208
|
-
return {
|
|
3209
|
-
...input.senderIdentityId === void 0 ? {} : { senderIdentityId: input.senderIdentityId },
|
|
3210
|
-
...input.displayName === void 0 ? {} : { displayName: input.displayName },
|
|
3211
|
-
...input.replyTo === void 0 ? {} : { replyTo: input.replyTo }
|
|
3212
|
-
};
|
|
3213
|
-
}
|
|
3214
3073
|
|
|
3215
3074
|
// src/modules/publicFunctions.ts
|
|
3216
3075
|
function createPublicFunctionsModule(transport, errors = defaultSdkCoreErrorFactory) {
|
|
@@ -3503,6 +3362,7 @@ function createSdkCore(options) {
|
|
|
3503
3362
|
agentCredentials: createAgentCredentialsModule(copilot, errors),
|
|
3504
3363
|
agents,
|
|
3505
3364
|
agentTasks: createAgentTasksModule(copilot, errors),
|
|
3365
|
+
aiProviders: createAiProvidersModule(copilot, errors),
|
|
3506
3366
|
apps,
|
|
3507
3367
|
auth: createAuthModule(options.transports.auth, errors),
|
|
3508
3368
|
context: createContextModule(
|
|
@@ -3528,7 +3388,7 @@ function createSdkCore(options) {
|
|
|
3528
3388
|
integrationResources: createIntegrationResourcesModule(options.transports.integration, errors),
|
|
3529
3389
|
integrationTemplates: createIntegrationTemplatesModule(options.transports.integration, errors),
|
|
3530
3390
|
members,
|
|
3531
|
-
messenger: createMessengerModule(messengerTransport, errors
|
|
3391
|
+
messenger: createMessengerModule(messengerTransport, errors),
|
|
3532
3392
|
publicFunctions: createPublicFunctionsModule(options.transports.publicFunctions, errors),
|
|
3533
3393
|
queries: createQueriesModule(options.transports.dataManager, errors),
|
|
3534
3394
|
sql: createSqlModule(options.transports.dataManager, errors),
|
|
@@ -4500,12 +4360,22 @@ function isChatRow(message) {
|
|
|
4500
4360
|
var REQUEST_ROW_KINDS = {
|
|
4501
4361
|
APPROVAL: "approval",
|
|
4502
4362
|
USER_INPUT_REQUEST: "userInputRequest",
|
|
4503
|
-
NOTIFICATION: "notification"
|
|
4363
|
+
NOTIFICATION: "notification",
|
|
4364
|
+
PLAN: "plan"
|
|
4504
4365
|
};
|
|
4505
4366
|
function notificationFieldsOf(payload) {
|
|
4506
4367
|
const { source, outcome, summary, detail } = payload;
|
|
4507
4368
|
return { source, outcome, summary, ...detail !== void 0 ? { detail } : {} };
|
|
4508
4369
|
}
|
|
4370
|
+
function planFieldsOf(payload) {
|
|
4371
|
+
const { planId, steps, explanation, status } = payload;
|
|
4372
|
+
return {
|
|
4373
|
+
planId: planId ?? null,
|
|
4374
|
+
steps: Array.isArray(steps) ? steps : [],
|
|
4375
|
+
...explanation !== void 0 ? { explanation } : {},
|
|
4376
|
+
status: status ?? null
|
|
4377
|
+
};
|
|
4378
|
+
}
|
|
4509
4379
|
function parseJson(text) {
|
|
4510
4380
|
try {
|
|
4511
4381
|
return JSON.parse(text);
|
|
@@ -4535,7 +4405,10 @@ function toAgentTimelineItem(message) {
|
|
|
4535
4405
|
...timelineIdentityOf(message),
|
|
4536
4406
|
...parentToolIdOf(message.parentToolId)
|
|
4537
4407
|
};
|
|
4538
|
-
|
|
4408
|
+
if (requestKind === "notification") {
|
|
4409
|
+
return { ...item, kind: requestKind, ...notificationFieldsOf(payload) };
|
|
4410
|
+
}
|
|
4411
|
+
return requestKind === "plan" ? { ...item, kind: requestKind, ...planFieldsOf(payload) } : { ...item, kind: requestKind };
|
|
4539
4412
|
}
|
|
4540
4413
|
}
|
|
4541
4414
|
if (message.type === "TOOL_USE") {
|
|
@@ -4784,7 +4657,8 @@ var CoreAgentTaskSession = class {
|
|
|
4784
4657
|
const page = await this.dependencies.tasks.listMessages(this._taskId, {
|
|
4785
4658
|
...options.limit !== void 0 ? { size: options.limit } : {},
|
|
4786
4659
|
sort: "createdAt,desc",
|
|
4787
|
-
kinds: "all"
|
|
4660
|
+
kinds: "all",
|
|
4661
|
+
include: "plan"
|
|
4788
4662
|
});
|
|
4789
4663
|
this.historyLimit = options.limit;
|
|
4790
4664
|
this.replaceHistory(page);
|
|
@@ -4814,7 +4688,8 @@ var CoreAgentTaskSession = class {
|
|
|
4814
4688
|
before: oldest.id,
|
|
4815
4689
|
...this.historyLimit !== void 0 ? { size: this.historyLimit } : {},
|
|
4816
4690
|
sort: "createdAt,desc",
|
|
4817
|
-
kinds: "all"
|
|
4691
|
+
kinds: "all",
|
|
4692
|
+
include: "plan"
|
|
4818
4693
|
});
|
|
4819
4694
|
} catch (error) {
|
|
4820
4695
|
if (generation !== this.historyGeneration || this.isClosed()) return [];
|
|
@@ -5247,7 +5122,8 @@ var CoreAgentTaskSession = class {
|
|
|
5247
5122
|
const page = await this.dependencies.tasks.listMessages(this._taskId, {
|
|
5248
5123
|
size: 100,
|
|
5249
5124
|
sort: "createdAt,desc",
|
|
5250
|
-
kinds: "all"
|
|
5125
|
+
kinds: "all",
|
|
5126
|
+
include: "plan"
|
|
5251
5127
|
});
|
|
5252
5128
|
this.turnBaselineIds = new Set(page.content.map((message) => message.id));
|
|
5253
5129
|
}
|
|
@@ -5256,7 +5132,8 @@ var CoreAgentTaskSession = class {
|
|
|
5256
5132
|
const page = await this.dependencies.tasks.listMessages(this._taskId, {
|
|
5257
5133
|
size: 100,
|
|
5258
5134
|
sort: "createdAt,desc",
|
|
5259
|
-
kinds: "all"
|
|
5135
|
+
kinds: "all",
|
|
5136
|
+
include: "plan"
|
|
5260
5137
|
});
|
|
5261
5138
|
this.replaceHistory(page);
|
|
5262
5139
|
this.emit("historyLoaded", { history: this.history });
|
|
@@ -5507,6 +5384,15 @@ var CoreAgentTaskSession = class {
|
|
|
5507
5384
|
});
|
|
5508
5385
|
}
|
|
5509
5386
|
break;
|
|
5387
|
+
case "plan":
|
|
5388
|
+
if (payload && this.livePlan(event, payload)) {
|
|
5389
|
+
this.emit("plan", {
|
|
5390
|
+
...payload,
|
|
5391
|
+
...planFieldsOf(payload),
|
|
5392
|
+
...pieceIdentityOf(event, payload)
|
|
5393
|
+
});
|
|
5394
|
+
}
|
|
5395
|
+
break;
|
|
5510
5396
|
default:
|
|
5511
5397
|
break;
|
|
5512
5398
|
}
|
|
@@ -5784,6 +5670,44 @@ var CoreAgentTaskSession = class {
|
|
|
5784
5670
|
(item) => item
|
|
5785
5671
|
);
|
|
5786
5672
|
}
|
|
5673
|
+
// T3 sends the list whole on each update: the item takes the last one where it first came, as
|
|
5674
|
+
// the Copilot's row does. An update the item already holds (a replay after the history) leaves
|
|
5675
|
+
// it as it is and answers false.
|
|
5676
|
+
livePlan(event, payload) {
|
|
5677
|
+
const itemId = typeof payload.itemId === "string" ? payload.itemId : void 0;
|
|
5678
|
+
const sequence = typeof event.sequence === "number" ? event.sequence : void 0;
|
|
5679
|
+
if (itemId === void 0 && sequence === void 0) return true;
|
|
5680
|
+
let applied = true;
|
|
5681
|
+
this.livePiece(
|
|
5682
|
+
(item) => item.kind === "plan" && (itemId !== void 0 ? item.itemId === itemId : item.sequence === sequence),
|
|
5683
|
+
() => ({
|
|
5684
|
+
id: `live:plan:${itemId ?? sequence}`,
|
|
5685
|
+
kind: "plan",
|
|
5686
|
+
payload,
|
|
5687
|
+
...planFieldsOf(payload),
|
|
5688
|
+
at: liveAtOf(event),
|
|
5689
|
+
...sequence === void 0 ? {} : { sequence },
|
|
5690
|
+
...itemId === void 0 ? {} : { itemId }
|
|
5691
|
+
}),
|
|
5692
|
+
(item) => {
|
|
5693
|
+
const held = item.lastSequence ?? item.sequence;
|
|
5694
|
+
if (sequence !== void 0 && held !== void 0 && sequence <= held) {
|
|
5695
|
+
applied = false;
|
|
5696
|
+
return item;
|
|
5697
|
+
}
|
|
5698
|
+
const fields = planFieldsOf(payload);
|
|
5699
|
+
const next = {
|
|
5700
|
+
...item,
|
|
5701
|
+
payload,
|
|
5702
|
+
...fields,
|
|
5703
|
+
...sequence === void 0 ? {} : { lastSequence: sequence }
|
|
5704
|
+
};
|
|
5705
|
+
if (fields.explanation === void 0) delete next.explanation;
|
|
5706
|
+
return next;
|
|
5707
|
+
}
|
|
5708
|
+
);
|
|
5709
|
+
return applied;
|
|
5710
|
+
}
|
|
5787
5711
|
// A child thread's frames are the subagent's conversation: they open no turn and settle no
|
|
5788
5712
|
// message. Its text and tools still reach `delta`, `content` and `tool` as they did in 0.2.13,
|
|
5789
5713
|
// which knew no subagents, so an app that only bumps the version sees what it saw before.
|
|
@@ -6068,6 +5992,7 @@ async function resolveApiKeyToken(call, appId, apiKey, errors = defaultSdkCoreEr
|
|
|
6068
5992
|
createAgentTaskSessionManager,
|
|
6069
5993
|
createAgentTasksModule,
|
|
6070
5994
|
createAgentsModule,
|
|
5995
|
+
createAiProvidersModule,
|
|
6071
5996
|
createAppsModule,
|
|
6072
5997
|
createAuthModule,
|
|
6073
5998
|
createContextModule,
|