@lssm/lib.contracts 0.0.0-canary-20251217063201 → 0.0.0-canary-20251217073102
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/app-config/app-config.feature.js +53 -1
- package/dist/app-config/contracts.d.ts +50 -50
- package/dist/app-config/contracts.js +396 -1
- package/dist/app-config/docs/app-config.docblock.js +22 -220
- package/dist/app-config/events.d.ts +27 -27
- package/dist/app-config/events.js +168 -1
- package/dist/app-config/index.js +8 -1
- package/dist/app-config/lifecycle-contracts.d.ts +80 -80
- package/dist/app-config/lifecycle-contracts.js +441 -1
- package/dist/app-config/runtime.js +617 -1
- package/dist/app-config/spec.js +36 -1
- package/dist/app-config/validation.js +538 -1
- package/dist/capabilities/docs/capabilities.docblock.js +22 -1
- package/dist/capabilities/openbanking.js +92 -1
- package/dist/capabilities.js +50 -1
- package/dist/client/index.js +9 -1
- package/dist/client/react/drivers/rn-reusables.js +21 -1
- package/dist/client/react/drivers/shadcn.js +11 -1
- package/dist/client/react/feature-render.js +43 -1
- package/dist/client/react/form-render.js +298 -1
- package/dist/client/react/index.js +8 -1
- package/dist/contract-registry/index.js +3 -1
- package/dist/contract-registry/schemas.js +61 -1
- package/dist/contracts-adapter-hydration.js +41 -1
- package/dist/contracts-adapter-input.js +77 -1
- package/dist/data-views/docs/data-views.docblock.js +22 -1
- package/dist/data-views/query-generator.js +48 -1
- package/dist/data-views/runtime.js +39 -1
- package/dist/data-views.js +35 -1
- package/dist/docs/PUBLISHING.docblock.js +17 -76
- package/dist/docs/accessibility_wcag_compliance_specs.docblock.js +17 -350
- package/dist/docs/index.js +33 -1
- package/dist/docs/meta.docs.js +15 -2
- package/dist/docs/presentations.js +77 -1
- package/dist/docs/registry.js +51 -1
- package/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +17 -383
- package/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +17 -68
- package/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +17 -140
- package/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +17 -86
- package/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +17 -1
- package/dist/docs/tech/auth/better-auth-nextjs.docblock.js +25 -2
- package/dist/docs/tech/contracts/README.docblock.js +21 -1
- package/dist/docs/tech/contracts/create-subscription.docblock.js +21 -1
- package/dist/docs/tech/contracts/graphql-typed-outputs.docblock.js +21 -180
- package/dist/docs/tech/contracts/migrations.docblock.js +21 -1
- package/dist/docs/tech/contracts/openapi-export.docblock.js +22 -2
- package/dist/docs/tech/contracts/ops-to-presentation-linking.docblock.js +19 -60
- package/dist/docs/tech/contracts/overlays.docblock.js +21 -68
- package/dist/docs/tech/contracts/tests.docblock.js +21 -132
- package/dist/docs/tech/contracts/themes.docblock.js +21 -1
- package/dist/docs/tech/contracts/vertical-pocket-family-office.docblock.js +21 -106
- package/dist/docs/tech/lifecycle-stage-system.docblock.js +17 -213
- package/dist/docs/tech/llm/llm-integration.docblock.js +74 -5
- package/dist/docs/tech/mcp-endpoints.docblock.js +38 -1
- package/dist/docs/tech/presentation-runtime.docblock.js +17 -1
- package/dist/docs/tech/schema/README.docblock.js +21 -262
- package/dist/docs/tech/studio/learning-events.docblock.js +49 -1
- package/dist/docs/tech/studio/learning-journeys.docblock.js +25 -2
- package/dist/docs/tech/studio/platform-admin-panel.docblock.js +24 -2
- package/dist/docs/tech/studio/project-access-teams.docblock.js +26 -16
- package/dist/docs/tech/studio/project-routing.docblock.js +68 -1
- package/dist/docs/tech/studio/sandbox-unlogged.docblock.js +23 -2
- package/dist/docs/tech/studio/team-invitations.docblock.js +41 -36
- package/dist/docs/tech/studio/workspace-ops.docblock.js +48 -1
- package/dist/docs/tech/studio/workspaces.docblock.js +24 -2
- package/dist/docs/tech/telemetry-ingest.docblock.js +37 -3
- package/dist/docs/tech/templates/runtime.docblock.js +21 -1
- package/dist/docs/tech/vscode-extension.docblock.js +37 -3
- package/dist/docs/tech/workflows/overview.docblock.js +21 -1
- package/dist/docs/tech-contracts.docs.js +19 -2
- package/dist/events.js +12 -1
- package/dist/experiments/docs/experiments.docblock.js +22 -128
- package/dist/experiments/evaluator.js +101 -1
- package/dist/experiments/spec.js +33 -1
- package/dist/features.js +68 -1
- package/dist/forms/docs/forms.docblock.js +22 -1
- package/dist/forms.js +119 -1
- package/dist/index.js +107 -1
- package/dist/install.js +40 -1
- package/dist/integrations/contracts.d.ts +102 -102
- package/dist/integrations/contracts.js +388 -1
- package/dist/integrations/docs/integrations.docblock.js +95 -1
- package/dist/integrations/health.js +69 -1
- package/dist/integrations/index.js +23 -1
- package/dist/integrations/openbanking/contracts/accounts.d.ts +66 -66
- package/dist/integrations/openbanking/contracts/accounts.js +237 -1
- package/dist/integrations/openbanking/contracts/balances.d.ts +34 -34
- package/dist/integrations/openbanking/contracts/balances.js +167 -1
- package/dist/integrations/openbanking/contracts/index.js +12 -1
- package/dist/integrations/openbanking/contracts/transactions.d.ts +48 -48
- package/dist/integrations/openbanking/contracts/transactions.js +218 -1
- package/dist/integrations/openbanking/guards.js +32 -1
- package/dist/integrations/openbanking/models.d.ts +55 -55
- package/dist/integrations/openbanking/models.js +242 -1
- package/dist/integrations/openbanking/openbanking.feature.js +68 -1
- package/dist/integrations/openbanking/telemetry.js +39 -1
- package/dist/integrations/providers/elevenlabs.js +56 -1
- package/dist/integrations/providers/gcs-storage.js +79 -1
- package/dist/integrations/providers/gmail.js +91 -1
- package/dist/integrations/providers/google-calendar.js +70 -1
- package/dist/integrations/providers/impls/elevenlabs-voice.js +95 -1
- package/dist/integrations/providers/impls/gcs-storage.js +88 -1
- package/dist/integrations/providers/impls/gmail-inbound.js +200 -1
- package/dist/integrations/providers/impls/gmail-outbound.js +104 -5
- package/dist/integrations/providers/impls/google-calendar.js +154 -1
- package/dist/integrations/providers/impls/index.js +16 -1
- package/dist/integrations/providers/impls/mistral-embedding.js +41 -1
- package/dist/integrations/providers/impls/mistral-llm.js +247 -1
- package/dist/integrations/providers/impls/postmark-email.js +55 -1
- package/dist/integrations/providers/impls/powens-client.js +171 -1
- package/dist/integrations/providers/impls/powens-openbanking.js +218 -1
- package/dist/integrations/providers/impls/provider-factory.js +142 -1
- package/dist/integrations/providers/impls/qdrant-vector.js +69 -1
- package/dist/integrations/providers/impls/stripe-payments.js +202 -1
- package/dist/integrations/providers/impls/twilio-sms.js +58 -1
- package/dist/integrations/providers/index.js +13 -1
- package/dist/integrations/providers/mistral.js +72 -1
- package/dist/integrations/providers/postmark.js +72 -1
- package/dist/integrations/providers/powens.js +120 -1
- package/dist/integrations/providers/qdrant.js +77 -1
- package/dist/integrations/providers/registry.js +34 -1
- package/dist/integrations/providers/stripe.js +87 -1
- package/dist/integrations/providers/twilio-sms.js +65 -1
- package/dist/integrations/runtime.js +186 -1
- package/dist/integrations/secrets/aws-secret-manager.js +231 -1
- package/dist/integrations/secrets/env-secret-provider.js +81 -1
- package/dist/integrations/secrets/gcp-secret-manager.js +229 -1
- package/dist/integrations/secrets/index.js +8 -1
- package/dist/integrations/secrets/manager.js +103 -1
- package/dist/integrations/secrets/provider.js +58 -1
- package/dist/integrations/secrets/scaleway-secret-manager.js +247 -1
- package/dist/integrations/spec.js +39 -1
- package/dist/jobs/define-job.js +16 -1
- package/dist/jobs/gcp-cloud-tasks.js +53 -1
- package/dist/jobs/gcp-pubsub.js +39 -1
- package/dist/jobs/handlers/gmail-sync-handler.js +9 -1
- package/dist/jobs/handlers/index.js +12 -1
- package/dist/jobs/handlers/ping-handler.js +15 -1
- package/dist/jobs/handlers/storage-document-handler.js +14 -1
- package/dist/jobs/index.js +4 -1
- package/dist/jobs/memory-queue.js +71 -1
- package/dist/jobs/queue.js +33 -1
- package/dist/jobs/scaleway-sqs-queue.js +153 -1
- package/dist/jsonschema.d.ts +3 -3
- package/dist/jsonschema.js +32 -1
- package/dist/knowledge/contracts.d.ts +66 -66
- package/dist/knowledge/contracts.js +317 -1
- package/dist/knowledge/docs/knowledge.docblock.js +22 -138
- package/dist/knowledge/index.js +10 -1
- package/dist/knowledge/ingestion/document-processor.js +54 -1
- package/dist/knowledge/ingestion/embedding-service.js +25 -1
- package/dist/knowledge/ingestion/gmail-adapter.js +50 -5
- package/dist/knowledge/ingestion/index.js +7 -1
- package/dist/knowledge/ingestion/storage-adapter.js +26 -1
- package/dist/knowledge/ingestion/vector-indexer.js +32 -1
- package/dist/knowledge/query/index.js +3 -1
- package/dist/knowledge/query/service.js +64 -2
- package/dist/knowledge/runtime.js +49 -1
- package/dist/knowledge/spaces/email-threads.js +38 -1
- package/dist/knowledge/spaces/financial-docs.js +38 -1
- package/dist/knowledge/spaces/financial-overview.js +42 -1
- package/dist/knowledge/spaces/index.js +8 -1
- package/dist/knowledge/spaces/product-canon.js +38 -1
- package/dist/knowledge/spaces/support-faq.js +41 -1
- package/dist/knowledge/spaces/uploaded-docs.js +38 -1
- package/dist/knowledge/spec.js +39 -1
- package/dist/llm/exporters.js +541 -8
- package/dist/llm/index.js +4 -1
- package/dist/llm/prompts.js +246 -56
- package/dist/markdown.js +116 -3
- package/dist/migrations.js +33 -1
- package/dist/onboarding-base.d.ts +29 -29
- package/dist/onboarding-base.js +196 -1
- package/dist/openapi.js +75 -1
- package/dist/openbanking/docs/openbanking.docblock.js +22 -109
- package/dist/ownership.js +40 -1
- package/dist/policy/docs/policy.docblock.js +22 -1
- package/dist/policy/engine.js +223 -1
- package/dist/policy/opa-adapter.js +71 -1
- package/dist/policy/spec.js +33 -1
- package/dist/presentations/docs/presentations-conventions.docblock.js +21 -7
- package/dist/presentations.backcompat.js +47 -1
- package/dist/presentations.d.ts +3 -3
- package/dist/presentations.js +66 -1
- package/dist/presentations.v2.js +278 -6
- package/dist/prompt.js +10 -1
- package/dist/promptRegistry.js +34 -1
- package/dist/regenerator/docs/regenerator.docblock.js +22 -184
- package/dist/regenerator/executor.js +86 -1
- package/dist/regenerator/index.js +6 -1
- package/dist/regenerator/service.js +92 -1
- package/dist/regenerator/sinks.js +32 -1
- package/dist/regenerator/utils.js +51 -1
- package/dist/registry.js +208 -1
- package/dist/resources.js +47 -1
- package/dist/schema/dist/EnumType.js +2 -1
- package/dist/schema/dist/FieldType.js +49 -1
- package/dist/schema/dist/ScalarTypeEnum.js +236 -1
- package/dist/schema/dist/SchemaModel.js +39 -1
- package/dist/schema/dist/entity/defineEntity.js +1 -1
- package/dist/schema/dist/entity/index.js +2 -1
- package/dist/schema/dist/entity/types.js +1 -1
- package/dist/schema/dist/index.js +6 -1
- package/dist/schema-to-markdown.js +214 -10
- package/dist/server/graphql-pothos.js +128 -1
- package/dist/server/index.js +10 -1
- package/dist/server/mcp/createMcpServer.js +28 -1
- package/dist/server/mcp/registerPresentations.js +151 -1
- package/dist/server/mcp/registerPrompts.js +36 -2
- package/dist/server/mcp/registerResources.js +35 -1
- package/dist/server/mcp/registerTools.js +22 -1
- package/dist/server/provider-mcp.js +3 -1
- package/dist/server/rest-elysia.js +20 -1
- package/dist/server/rest-express.js +39 -1
- package/dist/server/rest-generic.js +125 -1
- package/dist/server/rest-next-app.js +38 -1
- package/dist/server/rest-next-mcp.js +45 -1
- package/dist/server/rest-next-pages.js +25 -1
- package/dist/spec.js +35 -1
- package/dist/telemetry/anomaly.js +48 -1
- package/dist/telemetry/docs/telemetry.docblock.js +22 -139
- package/dist/telemetry/index.js +5 -1
- package/dist/telemetry/spec.js +69 -1
- package/dist/telemetry/tracker.js +76 -1
- package/dist/tests/index.js +4 -1
- package/dist/tests/runner.js +150 -1
- package/dist/tests/spec.js +33 -1
- package/dist/themes.js +39 -1
- package/dist/workflow/adapters/db-adapter.js +83 -1
- package/dist/workflow/adapters/file-adapter.js +11 -1
- package/dist/workflow/adapters/index.js +5 -1
- package/dist/workflow/adapters/memory-store.js +58 -1
- package/dist/workflow/expression.js +98 -1
- package/dist/workflow/index.js +9 -1
- package/dist/workflow/runner.js +337 -1
- package/dist/workflow/sla-monitor.js +47 -1
- package/dist/workflow/spec.js +32 -1
- package/dist/workflow/validation.js +175 -1
- package/package.json +11 -4
|
@@ -1 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ElevenLabsVoiceProvider } from "./elevenlabs-voice.js";
|
|
2
|
+
import { GoogleCloudStorageProvider } from "./gcs-storage.js";
|
|
3
|
+
import { GmailInboundProvider } from "./gmail-inbound.js";
|
|
4
|
+
import { GmailOutboundProvider } from "./gmail-outbound.js";
|
|
5
|
+
import { GoogleCalendarProvider } from "./google-calendar.js";
|
|
6
|
+
import { MistralLLMProvider } from "./mistral-llm.js";
|
|
7
|
+
import { MistralEmbeddingProvider } from "./mistral-embedding.js";
|
|
8
|
+
import { QdrantVectorProvider } from "./qdrant-vector.js";
|
|
9
|
+
import { StripePaymentsProvider } from "./stripe-payments.js";
|
|
10
|
+
import { PostmarkEmailProvider } from "./postmark-email.js";
|
|
11
|
+
import { TwilioSmsProvider } from "./twilio-sms.js";
|
|
12
|
+
import { PowensClient, PowensClientError } from "./powens-client.js";
|
|
13
|
+
import { PowensOpenBankingProvider } from "./powens-openbanking.js";
|
|
14
|
+
import { IntegrationProviderFactory } from "./provider-factory.js";
|
|
15
|
+
|
|
16
|
+
export { ElevenLabsVoiceProvider, GmailInboundProvider, GmailOutboundProvider, GoogleCalendarProvider, GoogleCloudStorageProvider, IntegrationProviderFactory, MistralEmbeddingProvider, MistralLLMProvider, PostmarkEmailProvider, PowensClient, PowensClientError, PowensOpenBankingProvider, QdrantVectorProvider, StripePaymentsProvider, TwilioSmsProvider };
|
|
@@ -1 +1,41 @@
|
|
|
1
|
-
import{Mistral
|
|
1
|
+
import { Mistral } from "@mistralai/mistralai";
|
|
2
|
+
|
|
3
|
+
//#region src/integrations/providers/impls/mistral-embedding.ts
|
|
4
|
+
var MistralEmbeddingProvider = class {
|
|
5
|
+
client;
|
|
6
|
+
defaultModel;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
if (!options.apiKey) throw new Error("MistralEmbeddingProvider requires an apiKey");
|
|
9
|
+
this.client = options.client ?? new Mistral({
|
|
10
|
+
apiKey: options.apiKey,
|
|
11
|
+
serverURL: options.serverURL
|
|
12
|
+
});
|
|
13
|
+
this.defaultModel = options.defaultModel ?? "mistral-embed";
|
|
14
|
+
}
|
|
15
|
+
async embedDocuments(documents, options) {
|
|
16
|
+
if (documents.length === 0) return [];
|
|
17
|
+
const model = options?.model ?? this.defaultModel;
|
|
18
|
+
const response = await this.client.embeddings.create({
|
|
19
|
+
model,
|
|
20
|
+
inputs: documents.map((doc) => doc.text)
|
|
21
|
+
});
|
|
22
|
+
return response.data.map((item, index) => ({
|
|
23
|
+
id: documents[index]?.id ?? (item.index != null ? `embedding-${item.index}` : `embedding-${index}`),
|
|
24
|
+
vector: item.embedding ?? [],
|
|
25
|
+
dimensions: item.embedding?.length ?? 0,
|
|
26
|
+
model: response.model,
|
|
27
|
+
metadata: documents[index]?.metadata ? Object.fromEntries(Object.entries(documents[index]?.metadata ?? {}).map(([key, value]) => [key, String(value)])) : void 0
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
async embedQuery(query, options) {
|
|
31
|
+
const [result] = await this.embedDocuments([{
|
|
32
|
+
id: "query",
|
|
33
|
+
text: query
|
|
34
|
+
}], options);
|
|
35
|
+
if (!result) throw new Error("Failed to compute embedding for query");
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { MistralEmbeddingProvider };
|
|
@@ -1 +1,247 @@
|
|
|
1
|
-
import{Mistral
|
|
1
|
+
import { Mistral } from "@mistralai/mistralai";
|
|
2
|
+
|
|
3
|
+
//#region src/integrations/providers/impls/mistral-llm.ts
|
|
4
|
+
var MistralLLMProvider = class {
|
|
5
|
+
client;
|
|
6
|
+
defaultModel;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
if (!options.apiKey) throw new Error("MistralLLMProvider requires an apiKey");
|
|
9
|
+
this.client = options.client ?? new Mistral({
|
|
10
|
+
apiKey: options.apiKey,
|
|
11
|
+
serverURL: options.serverURL,
|
|
12
|
+
userAgent: options.userAgentSuffix ? `${options.userAgentSuffix}` : void 0
|
|
13
|
+
});
|
|
14
|
+
this.defaultModel = options.defaultModel ?? "mistral-large-latest";
|
|
15
|
+
}
|
|
16
|
+
async chat(messages, options = {}) {
|
|
17
|
+
const request = this.buildChatRequest(messages, options);
|
|
18
|
+
const response = await this.client.chat.complete(request);
|
|
19
|
+
return this.buildLLMResponse(response);
|
|
20
|
+
}
|
|
21
|
+
async *stream(messages, options = {}) {
|
|
22
|
+
const request = this.buildChatRequest(messages, options);
|
|
23
|
+
request.stream = true;
|
|
24
|
+
const stream = await this.client.chat.stream(request);
|
|
25
|
+
const aggregatedParts = [];
|
|
26
|
+
const aggregatedToolCalls = [];
|
|
27
|
+
let usage;
|
|
28
|
+
let finishReason;
|
|
29
|
+
for await (const event of stream) {
|
|
30
|
+
for (const choice of event.data.choices) {
|
|
31
|
+
const delta = choice.delta;
|
|
32
|
+
if (typeof delta.content === "string") {
|
|
33
|
+
if (delta.content.length > 0) {
|
|
34
|
+
aggregatedParts.push({
|
|
35
|
+
type: "text",
|
|
36
|
+
text: delta.content
|
|
37
|
+
});
|
|
38
|
+
yield {
|
|
39
|
+
type: "message_delta",
|
|
40
|
+
delta: {
|
|
41
|
+
type: "text",
|
|
42
|
+
text: delta.content
|
|
43
|
+
},
|
|
44
|
+
index: choice.index
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
} else if (Array.isArray(delta.content)) {
|
|
48
|
+
for (const chunk of delta.content) if (chunk.type === "text" && "text" in chunk) {
|
|
49
|
+
aggregatedParts.push({
|
|
50
|
+
type: "text",
|
|
51
|
+
text: chunk.text
|
|
52
|
+
});
|
|
53
|
+
yield {
|
|
54
|
+
type: "message_delta",
|
|
55
|
+
delta: {
|
|
56
|
+
type: "text",
|
|
57
|
+
text: chunk.text
|
|
58
|
+
},
|
|
59
|
+
index: choice.index
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (delta.toolCalls) {
|
|
64
|
+
let localIndex = 0;
|
|
65
|
+
for (const call of delta.toolCalls) {
|
|
66
|
+
const toolCall = this.fromMistralToolCall(call, localIndex);
|
|
67
|
+
aggregatedToolCalls.push(toolCall);
|
|
68
|
+
yield {
|
|
69
|
+
type: "tool_call",
|
|
70
|
+
call: toolCall,
|
|
71
|
+
index: choice.index
|
|
72
|
+
};
|
|
73
|
+
localIndex += 1;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (choice.finishReason && choice.finishReason !== "null") finishReason = choice.finishReason;
|
|
77
|
+
}
|
|
78
|
+
if (event.data.usage) {
|
|
79
|
+
const usageEntry = this.fromUsage(event.data.usage);
|
|
80
|
+
if (usageEntry) {
|
|
81
|
+
usage = usageEntry;
|
|
82
|
+
yield {
|
|
83
|
+
type: "usage",
|
|
84
|
+
usage: usageEntry
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const message = {
|
|
90
|
+
role: "assistant",
|
|
91
|
+
content: aggregatedParts.length ? aggregatedParts : [{
|
|
92
|
+
type: "text",
|
|
93
|
+
text: ""
|
|
94
|
+
}]
|
|
95
|
+
};
|
|
96
|
+
if (aggregatedToolCalls.length > 0) message.content = [...aggregatedToolCalls, ...aggregatedParts.length ? aggregatedParts : []];
|
|
97
|
+
yield {
|
|
98
|
+
type: "end",
|
|
99
|
+
response: {
|
|
100
|
+
message,
|
|
101
|
+
usage,
|
|
102
|
+
finishReason: mapFinishReason(finishReason)
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
async countTokens(messages) {
|
|
107
|
+
throw new Error("Mistral API does not currently support token counting");
|
|
108
|
+
}
|
|
109
|
+
buildChatRequest(messages, options) {
|
|
110
|
+
const request = {
|
|
111
|
+
model: options.model ?? this.defaultModel,
|
|
112
|
+
messages: messages.map((message) => this.toMistralMessage(message))
|
|
113
|
+
};
|
|
114
|
+
if (options.temperature != null) request.temperature = options.temperature;
|
|
115
|
+
if (options.topP != null) request.topP = options.topP;
|
|
116
|
+
if (options.maxOutputTokens != null) request.maxTokens = options.maxOutputTokens;
|
|
117
|
+
if (options.stopSequences?.length) request.stop = options.stopSequences.length === 1 ? options.stopSequences[0] : options.stopSequences;
|
|
118
|
+
if (options.tools?.length) request.tools = options.tools.map((tool) => ({
|
|
119
|
+
type: "function",
|
|
120
|
+
function: {
|
|
121
|
+
name: tool.name,
|
|
122
|
+
description: tool.description,
|
|
123
|
+
parameters: typeof tool.inputSchema === "object" && tool.inputSchema !== null ? tool.inputSchema : {}
|
|
124
|
+
}
|
|
125
|
+
}));
|
|
126
|
+
if (options.responseFormat === "json") request.responseFormat = { type: "json_object" };
|
|
127
|
+
return request;
|
|
128
|
+
}
|
|
129
|
+
buildLLMResponse(response) {
|
|
130
|
+
const firstChoice = response.choices[0];
|
|
131
|
+
if (!firstChoice) return {
|
|
132
|
+
message: {
|
|
133
|
+
role: "assistant",
|
|
134
|
+
content: [{
|
|
135
|
+
type: "text",
|
|
136
|
+
text: ""
|
|
137
|
+
}]
|
|
138
|
+
},
|
|
139
|
+
usage: this.fromUsage(response.usage),
|
|
140
|
+
raw: response
|
|
141
|
+
};
|
|
142
|
+
return {
|
|
143
|
+
message: this.fromAssistantMessage(firstChoice.message),
|
|
144
|
+
usage: this.fromUsage(response.usage),
|
|
145
|
+
finishReason: mapFinishReason(firstChoice.finishReason),
|
|
146
|
+
raw: response
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
fromUsage(usage) {
|
|
150
|
+
if (!usage) return void 0;
|
|
151
|
+
return {
|
|
152
|
+
promptTokens: usage.promptTokens ?? 0,
|
|
153
|
+
completionTokens: usage.completionTokens ?? 0,
|
|
154
|
+
totalTokens: usage.totalTokens ?? 0
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
fromAssistantMessage(message) {
|
|
158
|
+
const parts = [];
|
|
159
|
+
if (typeof message.content === "string") parts.push({
|
|
160
|
+
type: "text",
|
|
161
|
+
text: message.content
|
|
162
|
+
});
|
|
163
|
+
else if (Array.isArray(message.content)) message.content.forEach((chunk) => {
|
|
164
|
+
if (chunk.type === "text" && "text" in chunk) parts.push({
|
|
165
|
+
type: "text",
|
|
166
|
+
text: chunk.text
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
const toolCalls = message.toolCalls?.map((call, index) => this.fromMistralToolCall(call, index)) ?? [];
|
|
170
|
+
if (toolCalls.length > 0) parts.splice(0, 0, ...toolCalls);
|
|
171
|
+
if (parts.length === 0) parts.push({
|
|
172
|
+
type: "text",
|
|
173
|
+
text: ""
|
|
174
|
+
});
|
|
175
|
+
return {
|
|
176
|
+
role: "assistant",
|
|
177
|
+
content: parts
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
fromMistralToolCall(call, index) {
|
|
181
|
+
const args = typeof call.function.arguments === "string" ? call.function.arguments : JSON.stringify(call.function.arguments);
|
|
182
|
+
return {
|
|
183
|
+
type: "tool-call",
|
|
184
|
+
id: call.id ?? `tool-call-${index}`,
|
|
185
|
+
name: call.function.name,
|
|
186
|
+
arguments: args
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
toMistralMessage(message) {
|
|
190
|
+
const textContent = this.extractText(message.content);
|
|
191
|
+
const toolCalls = this.extractToolCalls(message);
|
|
192
|
+
switch (message.role) {
|
|
193
|
+
case "system": return {
|
|
194
|
+
role: "system",
|
|
195
|
+
content: textContent ?? ""
|
|
196
|
+
};
|
|
197
|
+
case "user": return {
|
|
198
|
+
role: "user",
|
|
199
|
+
content: textContent ?? ""
|
|
200
|
+
};
|
|
201
|
+
case "assistant": return {
|
|
202
|
+
role: "assistant",
|
|
203
|
+
content: toolCalls.length > 0 ? null : textContent ?? "",
|
|
204
|
+
toolCalls: toolCalls.length > 0 ? toolCalls : void 0
|
|
205
|
+
};
|
|
206
|
+
case "tool": return {
|
|
207
|
+
role: "tool",
|
|
208
|
+
content: textContent ?? "",
|
|
209
|
+
toolCallId: message.toolCallId ?? toolCalls[0]?.id
|
|
210
|
+
};
|
|
211
|
+
default: return {
|
|
212
|
+
role: "user",
|
|
213
|
+
content: textContent ?? ""
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
extractText(parts) {
|
|
218
|
+
const textParts = parts.filter((part) => part.type === "text").map((part) => part.text);
|
|
219
|
+
if (textParts.length === 0) return null;
|
|
220
|
+
return textParts.join("");
|
|
221
|
+
}
|
|
222
|
+
extractToolCalls(message) {
|
|
223
|
+
return message.content.filter((part) => part.type === "tool-call").map((call, index) => ({
|
|
224
|
+
id: call.id ?? `call_${index}`,
|
|
225
|
+
type: "function",
|
|
226
|
+
index,
|
|
227
|
+
function: {
|
|
228
|
+
name: call.name,
|
|
229
|
+
arguments: call.arguments
|
|
230
|
+
}
|
|
231
|
+
}));
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
function mapFinishReason(reason) {
|
|
235
|
+
if (!reason) return void 0;
|
|
236
|
+
switch (reason.toLowerCase()) {
|
|
237
|
+
case "stop": return "stop";
|
|
238
|
+
case "length": return "length";
|
|
239
|
+
case "tool_call":
|
|
240
|
+
case "tool_calls": return "tool_call";
|
|
241
|
+
case "content_filter": return "content_filter";
|
|
242
|
+
default: return;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
//#endregion
|
|
247
|
+
export { MistralLLMProvider };
|
|
@@ -1 +1,55 @@
|
|
|
1
|
-
import{ServerClient
|
|
1
|
+
import { ServerClient } from "postmark";
|
|
2
|
+
|
|
3
|
+
//#region src/integrations/providers/impls/postmark-email.ts
|
|
4
|
+
var PostmarkEmailProvider = class {
|
|
5
|
+
client;
|
|
6
|
+
defaultFromEmail;
|
|
7
|
+
messageStream;
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this.client = options.client ?? new ServerClient(options.serverToken, { useHttps: true });
|
|
10
|
+
this.defaultFromEmail = options.defaultFromEmail;
|
|
11
|
+
this.messageStream = options.messageStream;
|
|
12
|
+
}
|
|
13
|
+
async sendEmail(message) {
|
|
14
|
+
const request = {
|
|
15
|
+
From: formatAddress(message.from) ?? this.defaultFromEmail,
|
|
16
|
+
To: message.to.map((addr) => formatAddress(addr)).join(", "),
|
|
17
|
+
Cc: message.cc?.map((addr) => formatAddress(addr)).join(", ") || void 0,
|
|
18
|
+
Bcc: message.bcc?.map((addr) => formatAddress(addr)).join(", ") || void 0,
|
|
19
|
+
ReplyTo: message.replyTo ? formatAddress(message.replyTo) : void 0,
|
|
20
|
+
Subject: message.subject,
|
|
21
|
+
TextBody: message.textBody,
|
|
22
|
+
HtmlBody: message.htmlBody,
|
|
23
|
+
Headers: message.headers ? Object.entries(message.headers).map(([name, value]) => ({
|
|
24
|
+
Name: name,
|
|
25
|
+
Value: value
|
|
26
|
+
})) : void 0,
|
|
27
|
+
MessageStream: this.messageStream,
|
|
28
|
+
Attachments: buildAttachments(message)
|
|
29
|
+
};
|
|
30
|
+
const response = await this.client.sendEmail(request);
|
|
31
|
+
return {
|
|
32
|
+
id: response.MessageID,
|
|
33
|
+
providerMessageId: response.MessageID,
|
|
34
|
+
queuedAt: new Date(response.SubmittedAt ?? (/* @__PURE__ */ new Date()).toISOString())
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
function formatAddress(address) {
|
|
39
|
+
if (address.name) return `"${address.name}" <${address.email}>`;
|
|
40
|
+
return address.email;
|
|
41
|
+
}
|
|
42
|
+
function buildAttachments(message) {
|
|
43
|
+
if (!message.attachments?.length) return void 0;
|
|
44
|
+
return message.attachments.filter((attachment) => attachment.data).map((attachment) => ({
|
|
45
|
+
Name: attachment.filename,
|
|
46
|
+
Content: Buffer.from(attachment.data ?? new Uint8Array()).toString("base64"),
|
|
47
|
+
ContentType: attachment.contentType,
|
|
48
|
+
ContentID: null,
|
|
49
|
+
ContentLength: attachment.sizeBytes,
|
|
50
|
+
Disposition: "attachment"
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
export { PostmarkEmailProvider };
|
|
@@ -1 +1,171 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { URL } from "node:url";
|
|
2
|
+
|
|
3
|
+
//#region src/integrations/providers/impls/powens-client.ts
|
|
4
|
+
const POWENS_BASE_URL = {
|
|
5
|
+
sandbox: "https://api-sandbox.powens.com/v2",
|
|
6
|
+
production: "https://api.powens.com/v2"
|
|
7
|
+
};
|
|
8
|
+
var PowensClientError = class extends Error {
|
|
9
|
+
status;
|
|
10
|
+
code;
|
|
11
|
+
requestId;
|
|
12
|
+
response;
|
|
13
|
+
constructor(message, status, code, requestId, response) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = "PowensClientError";
|
|
16
|
+
this.status = status;
|
|
17
|
+
this.code = code;
|
|
18
|
+
this.requestId = requestId;
|
|
19
|
+
this.response = response;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var PowensClient = class {
|
|
23
|
+
clientId;
|
|
24
|
+
clientSecret;
|
|
25
|
+
apiKey;
|
|
26
|
+
fetchImpl;
|
|
27
|
+
logger;
|
|
28
|
+
defaultTimeoutMs;
|
|
29
|
+
token;
|
|
30
|
+
baseUrl;
|
|
31
|
+
constructor(options) {
|
|
32
|
+
this.clientId = options.clientId;
|
|
33
|
+
this.clientSecret = options.clientSecret;
|
|
34
|
+
this.apiKey = options.apiKey;
|
|
35
|
+
this.fetchImpl = options.fetchImpl ?? fetch;
|
|
36
|
+
this.logger = options.logger;
|
|
37
|
+
this.defaultTimeoutMs = options.defaultTimeoutMs ?? 15e3;
|
|
38
|
+
this.baseUrl = options.baseUrl ?? POWENS_BASE_URL[options.environment] ?? POWENS_BASE_URL.production;
|
|
39
|
+
}
|
|
40
|
+
async listAccounts(params) {
|
|
41
|
+
const searchParams = {
|
|
42
|
+
cursor: params.cursor,
|
|
43
|
+
limit: params.limit,
|
|
44
|
+
include_balances: params.includeBalances,
|
|
45
|
+
institution_uuid: params.institutionUuid
|
|
46
|
+
};
|
|
47
|
+
return await this.request({
|
|
48
|
+
method: "GET",
|
|
49
|
+
path: `/users/${encodeURIComponent(params.userUuid)}/accounts`,
|
|
50
|
+
searchParams
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async getAccount(accountUuid) {
|
|
54
|
+
return this.request({
|
|
55
|
+
method: "GET",
|
|
56
|
+
path: `/accounts/${encodeURIComponent(accountUuid)}`
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async listTransactions(params) {
|
|
60
|
+
const searchParams = {
|
|
61
|
+
cursor: params.cursor,
|
|
62
|
+
limit: params.limit,
|
|
63
|
+
from: params.from,
|
|
64
|
+
to: params.to,
|
|
65
|
+
include_pending: params.includePending
|
|
66
|
+
};
|
|
67
|
+
return this.request({
|
|
68
|
+
method: "GET",
|
|
69
|
+
path: `/accounts/${encodeURIComponent(params.accountUuid)}/transactions`,
|
|
70
|
+
searchParams
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
async getBalances(accountUuid) {
|
|
74
|
+
return this.request({
|
|
75
|
+
method: "GET",
|
|
76
|
+
path: `/accounts/${encodeURIComponent(accountUuid)}/balances`
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async getConnectionStatus(connectionUuid) {
|
|
80
|
+
return this.request({
|
|
81
|
+
method: "GET",
|
|
82
|
+
path: `/connections/${encodeURIComponent(connectionUuid)}`
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
async request(options) {
|
|
86
|
+
const url = new URL(options.path, this.baseUrl);
|
|
87
|
+
if (options.searchParams) for (const [key, value] of Object.entries(options.searchParams)) {
|
|
88
|
+
if (value === void 0 || value === null) continue;
|
|
89
|
+
url.searchParams.set(key, String(value));
|
|
90
|
+
}
|
|
91
|
+
const headers = {
|
|
92
|
+
Accept: "application/json",
|
|
93
|
+
"Content-Type": "application/json",
|
|
94
|
+
...options.headers
|
|
95
|
+
};
|
|
96
|
+
if (this.apiKey) headers["x-api-key"] = this.apiKey;
|
|
97
|
+
if (!options.skipAuth) headers.Authorization = `Bearer ${await this.ensureAccessToken()}`;
|
|
98
|
+
const controller = new AbortController();
|
|
99
|
+
const timeout = setTimeout(() => controller.abort(), options.timeoutMs ?? this.defaultTimeoutMs);
|
|
100
|
+
try {
|
|
101
|
+
const response = await this.fetchImpl(url, {
|
|
102
|
+
method: options.method,
|
|
103
|
+
headers,
|
|
104
|
+
body: options.body ? JSON.stringify(options.body) : void 0,
|
|
105
|
+
signal: controller.signal
|
|
106
|
+
});
|
|
107
|
+
const requestId = response.headers.get("x-request-id") ?? void 0;
|
|
108
|
+
if (!response.ok) {
|
|
109
|
+
let errorBody;
|
|
110
|
+
try {
|
|
111
|
+
errorBody = await response.json();
|
|
112
|
+
} catch {}
|
|
113
|
+
const errorObject = typeof errorBody === "object" && errorBody !== null ? errorBody : void 0;
|
|
114
|
+
const message = typeof errorObject?.message === "string" ? errorObject.message : `Powens API request failed with status ${response.status}`;
|
|
115
|
+
const code = typeof errorObject?.code === "string" ? errorObject.code : void 0;
|
|
116
|
+
throw new PowensClientError(message, response.status, code, requestId, errorBody);
|
|
117
|
+
}
|
|
118
|
+
if (response.status === 204) return;
|
|
119
|
+
try {
|
|
120
|
+
return await response.json();
|
|
121
|
+
} catch (error) {
|
|
122
|
+
this.logger?.error?.("[PowensClient] Failed to parse JSON response", error);
|
|
123
|
+
throw new PowensClientError("Failed to parse Powens response payload as JSON", response.status, void 0, requestId);
|
|
124
|
+
}
|
|
125
|
+
} catch (error) {
|
|
126
|
+
if (error instanceof PowensClientError) throw error;
|
|
127
|
+
if (error.name === "AbortError") throw new PowensClientError(`Powens API request timed out after ${options.timeoutMs ?? this.defaultTimeoutMs}ms`, 408);
|
|
128
|
+
this.logger?.error?.("[PowensClient] Request failed", error);
|
|
129
|
+
throw new PowensClientError(error.message ?? "Powens API request failed", 500);
|
|
130
|
+
} finally {
|
|
131
|
+
clearTimeout(timeout);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async ensureAccessToken() {
|
|
135
|
+
if (this.token && Date.now() < this.token.expiresAt - 5e3) return this.token.accessToken;
|
|
136
|
+
this.token = await this.fetchAccessToken();
|
|
137
|
+
return this.token.accessToken;
|
|
138
|
+
}
|
|
139
|
+
async fetchAccessToken() {
|
|
140
|
+
const url = new URL("/oauth/token", this.baseUrl);
|
|
141
|
+
const basicAuth = Buffer.from(`${this.clientId}:${this.clientSecret}`, "utf-8").toString("base64");
|
|
142
|
+
const response = await this.fetchImpl(url, {
|
|
143
|
+
method: "POST",
|
|
144
|
+
headers: {
|
|
145
|
+
Authorization: `Basic ${basicAuth}`,
|
|
146
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
147
|
+
Accept: "application/json"
|
|
148
|
+
},
|
|
149
|
+
body: new URLSearchParams({ grant_type: "client_credentials" }).toString()
|
|
150
|
+
});
|
|
151
|
+
if (!response.ok) {
|
|
152
|
+
let errorBody;
|
|
153
|
+
try {
|
|
154
|
+
errorBody = await response.json();
|
|
155
|
+
} catch {}
|
|
156
|
+
const errorObject = typeof errorBody === "object" && errorBody !== null ? errorBody : void 0;
|
|
157
|
+
throw new PowensClientError(typeof errorObject?.error_description === "string" ? errorObject.error_description : "Failed to obtain Powens access token", response.status, void 0, void 0, errorBody);
|
|
158
|
+
}
|
|
159
|
+
const payload = await response.json();
|
|
160
|
+
const expiresAt = Date.now() + payload.expires_in * 1e3;
|
|
161
|
+
this.logger?.debug?.("[PowensClient] Received access token", { expiresIn: payload.expires_in });
|
|
162
|
+
return {
|
|
163
|
+
accessToken: payload.access_token,
|
|
164
|
+
expiresAt,
|
|
165
|
+
scope: payload.scope
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
//#endregion
|
|
171
|
+
export { PowensClient, PowensClientError };
|