@contractspec/lib.contracts 1.56.1 → 1.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/{rolldown_runtime.js → _rolldown/runtime.js} +3 -3
- package/dist/app-config/app-config.contracts.d.ts +50 -50
- package/dist/app-config/events.d.ts +27 -27
- package/dist/app-config/lifecycle-contracts.d.ts +54 -54
- package/dist/app-config/runtime.js +3 -3
- package/dist/app-config/validation.js +3 -3
- package/dist/capabilities/capabilities.js +20 -20
- package/dist/capabilities/context.d.ts +0 -1
- package/dist/capabilities/context.js +1 -1
- package/dist/capabilities/guards.d.ts +0 -1
- package/dist/capabilities/index.d.ts +2 -1
- package/dist/capabilities/index.js +2 -1
- package/dist/capabilities/meeting-recorder.d.ts +10 -0
- package/dist/capabilities/meeting-recorder.js +82 -0
- package/dist/capabilities/validation.d.ts +0 -1
- package/dist/client/react/drivers/rn-reusables.d.ts +0 -1
- package/dist/client/react/drivers/shadcn.d.ts +0 -1
- package/dist/client/react/form-render.js +3 -3
- package/dist/contract-registry/schemas.d.ts +2 -2
- package/dist/data-views/registry.d.ts +0 -1
- package/dist/data-views/spec.d.ts +0 -1
- package/dist/docs/commands/docsPublish.command.d.ts +13 -13
- package/dist/docs/contracts.d.ts +103 -103
- package/dist/docs/events/docsGenerated.event.d.ts +13 -13
- package/dist/docs/events/docsPublished.event.d.ts +15 -15
- package/dist/docs/forms/docsSearch.form.d.ts +4 -4
- package/dist/docs/queries/contractReference.query.d.ts +47 -47
- package/dist/docs/queries/docsIndex.query.d.ts +57 -57
- package/dist/docs/tech/llm/llm-integration.docblock.d.ts +0 -1
- package/dist/docs/tech/mcp-endpoints.docblock.js +5 -0
- package/dist/events.d.ts +0 -1
- package/dist/examples/index.d.ts +0 -1
- package/dist/examples/registry.d.ts +0 -1
- package/dist/examples/schema.d.ts +17 -17
- package/dist/experiments/spec.d.ts +2 -4
- package/dist/features/index.d.ts +0 -1
- package/dist/features/types.d.ts +2 -5
- package/dist/forms/forms.d.ts +1 -2
- package/dist/forms/forms.js +1 -2
- package/dist/index.d.ts +42 -1
- package/dist/index.js +36 -1
- package/dist/install.d.ts +2 -5
- package/dist/integrations/docs/integrations.docblock.js +19 -1
- package/dist/integrations/index.d.ts +26 -1
- package/dist/integrations/index.js +20 -1
- package/dist/integrations/meeting-recorder/contracts/index.d.ts +10 -0
- package/dist/integrations/meeting-recorder/contracts/index.js +12 -0
- package/dist/integrations/meeting-recorder/contracts/meetings.d.ts +458 -0
- package/dist/integrations/meeting-recorder/contracts/meetings.js +149 -0
- package/dist/integrations/meeting-recorder/contracts/transcripts.d.ts +173 -0
- package/dist/integrations/meeting-recorder/contracts/transcripts.js +156 -0
- package/dist/integrations/meeting-recorder/contracts/webhooks.d.ts +92 -0
- package/dist/integrations/meeting-recorder/contracts/webhooks.js +82 -0
- package/dist/integrations/meeting-recorder/meeting-recorder.capability.d.ts +7 -0
- package/dist/integrations/meeting-recorder/meeting-recorder.capability.js +21 -0
- package/dist/integrations/meeting-recorder/meeting-recorder.feature.d.ts +11 -0
- package/dist/integrations/meeting-recorder/meeting-recorder.feature.js +67 -0
- package/dist/integrations/meeting-recorder/models.d.ts +407 -0
- package/dist/integrations/meeting-recorder/models.js +295 -0
- package/dist/integrations/meeting-recorder/telemetry.d.ts +16 -0
- package/dist/integrations/meeting-recorder/telemetry.js +42 -0
- package/dist/integrations/openbanking/contracts/accounts.d.ts +66 -66
- package/dist/integrations/openbanking/contracts/balances.d.ts +34 -34
- package/dist/integrations/openbanking/contracts/transactions.d.ts +48 -48
- package/dist/integrations/openbanking/models.d.ts +55 -55
- package/dist/integrations/operations.d.ts +102 -102
- package/dist/integrations/providers/analytics-reader.d.ts +107 -0
- package/dist/integrations/providers/analytics-reader.js +0 -0
- package/dist/integrations/providers/analytics-writer.d.ts +10 -0
- package/dist/integrations/providers/analytics-writer.js +0 -0
- package/dist/integrations/providers/analytics.d.ts +49 -0
- package/dist/integrations/providers/analytics.js +0 -0
- package/dist/integrations/providers/database.d.ts +15 -0
- package/dist/integrations/providers/database.js +0 -0
- package/dist/integrations/providers/fal.d.ts +8 -0
- package/dist/integrations/providers/fal.js +94 -0
- package/dist/integrations/providers/fathom.d.ts +8 -0
- package/dist/integrations/providers/fathom.js +114 -0
- package/dist/integrations/providers/fireflies.d.ts +8 -0
- package/dist/integrations/providers/fireflies.js +98 -0
- package/dist/integrations/providers/gradium.d.ts +8 -0
- package/dist/integrations/providers/gradium.js +92 -0
- package/dist/integrations/providers/granola.d.ts +8 -0
- package/dist/integrations/providers/granola.js +71 -0
- package/dist/integrations/providers/index.d.ts +19 -1
- package/dist/integrations/providers/index.js +13 -1
- package/dist/integrations/providers/jira.d.ts +8 -0
- package/dist/integrations/providers/jira.js +90 -0
- package/dist/integrations/providers/linear.d.ts +8 -0
- package/dist/integrations/providers/linear.js +85 -0
- package/dist/integrations/providers/meeting-recorder.d.ts +132 -0
- package/dist/integrations/providers/meeting-recorder.js +0 -0
- package/dist/integrations/providers/notion.d.ts +8 -0
- package/dist/integrations/providers/notion.js +91 -0
- package/dist/integrations/providers/posthog.d.ts +8 -0
- package/dist/integrations/providers/posthog.js +107 -0
- package/dist/integrations/providers/project-management.d.ts +35 -0
- package/dist/integrations/providers/project-management.js +0 -0
- package/dist/integrations/providers/registry.d.ts +0 -1
- package/dist/integrations/providers/registry.js +24 -0
- package/dist/integrations/providers/supabase-postgres.d.ts +8 -0
- package/dist/integrations/providers/supabase-postgres.js +73 -0
- package/dist/integrations/providers/supabase-vector.d.ts +8 -0
- package/dist/integrations/providers/supabase-vector.js +93 -0
- package/dist/integrations/providers/tldv.d.ts +8 -0
- package/dist/integrations/providers/tldv.js +98 -0
- package/dist/integrations/runtime.js +0 -1
- package/dist/integrations/spec.d.ts +1 -1
- package/dist/jobs/queue.d.ts +0 -1
- package/dist/knowledge/binding.d.ts +1 -3
- package/dist/knowledge/operations.d.ts +66 -66
- package/dist/llm/exporters.d.ts +0 -1
- package/dist/llm/exporters.js +0 -1
- package/dist/llm/prompts.d.ts +0 -1
- package/dist/llm/types.d.ts +0 -1
- package/dist/onboarding-base.d.ts +29 -29
- package/dist/openapi.d.ts +0 -1
- package/dist/operations/operation.d.ts +19 -43
- package/dist/operations/registry.d.ts +0 -1
- package/dist/operations/registry.js +2 -2
- package/dist/operations/report/getContractVerificationStatus.d.ts +10 -10
- package/dist/ownership.d.ts +41 -88
- package/dist/policy/guards.d.ts +0 -1
- package/dist/policy/guards.js +3 -3
- package/dist/policy/index.d.ts +0 -1
- package/dist/policy/validation.d.ts +0 -1
- package/dist/product-intent/contract-patch-intent.d.ts +103 -0
- package/dist/product-intent/contract-patch-intent.js +33 -0
- package/dist/product-intent/contract-spec-patch.d.ts +89 -0
- package/dist/product-intent/contract-spec-patch.js +27 -0
- package/dist/product-intent/evidence.d.ts +17 -0
- package/dist/product-intent/evidence.js +13 -0
- package/dist/product-intent/findings.d.ts +60 -0
- package/dist/product-intent/findings.js +17 -0
- package/dist/product-intent/impact-report.d.ts +60 -0
- package/dist/product-intent/impact-report.js +27 -0
- package/dist/product-intent/index.d.ts +16 -0
- package/dist/product-intent/index.js +17 -0
- package/dist/product-intent/insights.d.ts +65 -0
- package/dist/product-intent/insights.js +23 -0
- package/dist/product-intent/opportunity-brief.d.ts +195 -0
- package/dist/product-intent/opportunity-brief.js +42 -0
- package/dist/product-intent/problems.d.ts +62 -0
- package/dist/product-intent/problems.js +22 -0
- package/dist/product-intent/registry.d.ts +32 -0
- package/dist/product-intent/registry.js +49 -0
- package/dist/product-intent/runtime.d.ts +103 -0
- package/dist/product-intent/runtime.js +101 -0
- package/dist/product-intent/spec.d.ts +676 -0
- package/dist/product-intent/spec.js +53 -0
- package/dist/product-intent/task-pack.d.ts +101 -0
- package/dist/product-intent/task-pack.js +34 -0
- package/dist/product-intent/tickets.d.ts +70 -0
- package/dist/product-intent/tickets.js +24 -0
- package/dist/product-intent/types.d.ts +12 -0
- package/dist/product-intent/types.js +13 -0
- package/dist/product-intent/ui-wireframe.d.ts +103 -0
- package/dist/product-intent/ui-wireframe.js +33 -0
- package/dist/registry-utils.d.ts +0 -1
- package/dist/registry-utils.js +3 -3
- package/dist/resources.js +1 -1
- package/dist/schema-to-markdown.d.ts +0 -1
- package/dist/server/contracts-adapter-input.js +2 -2
- package/dist/server/graphql-pothos.d.ts +0 -1
- package/dist/server/mcp/createMcpServer.d.ts +0 -1
- package/dist/server/rest-express.d.ts +0 -1
- package/dist/server/rest-generic.js +3 -3
- package/dist/server/rest-next-app.d.ts +0 -1
- package/dist/tests/spec.d.ts +0 -1
- package/dist/translations/registry.d.ts +0 -1
- package/dist/translations/spec.d.ts +0 -1
- package/dist/translations/validation.d.ts +0 -1
- package/dist/types.d.ts +5 -12
- package/dist/versioning/types.d.ts +0 -1
- package/dist/versioning/utils.d.ts +0 -1
- package/dist/workflow/adapters/memory-store.d.ts +0 -1
- package/dist/workflow/context.d.ts +0 -1
- package/dist/workflow/context.js +2 -2
- package/dist/workflow/runner.d.ts +1 -2
- package/dist/workspace-config/contractsrc-schema.d.ts +0 -1
- package/dist/workspace-config/contractsrc-types.d.ts +1 -3
- package/package.json +110 -32
- package/dist/integrations/providers/impls/elevenlabs-voice.d.ts +0 -20
- package/dist/integrations/providers/impls/elevenlabs-voice.js +0 -95
- package/dist/integrations/providers/impls/gcs-storage.d.ts +0 -24
- package/dist/integrations/providers/impls/gcs-storage.js +0 -88
- package/dist/integrations/providers/impls/gmail-inbound.d.ts +0 -26
- package/dist/integrations/providers/impls/gmail-inbound.js +0 -200
- package/dist/integrations/providers/impls/gmail-outbound.d.ts +0 -18
- package/dist/integrations/providers/impls/gmail-outbound.js +0 -105
- package/dist/integrations/providers/impls/google-calendar.d.ts +0 -23
- package/dist/integrations/providers/impls/google-calendar.js +0 -154
- package/dist/integrations/providers/impls/index.d.ts +0 -15
- package/dist/integrations/providers/impls/index.js +0 -16
- package/dist/integrations/providers/impls/mistral-embedding.d.ts +0 -23
- package/dist/integrations/providers/impls/mistral-embedding.js +0 -41
- package/dist/integrations/providers/impls/mistral-llm.d.ts +0 -31
- package/dist/integrations/providers/impls/mistral-llm.js +0 -247
- package/dist/integrations/providers/impls/postmark-email.d.ts +0 -19
- package/dist/integrations/providers/impls/postmark-email.js +0 -55
- package/dist/integrations/providers/impls/powens-client.d.ts +0 -124
- package/dist/integrations/providers/impls/powens-client.js +0 -171
- package/dist/integrations/providers/impls/powens-openbanking.d.ts +0 -27
- package/dist/integrations/providers/impls/powens-openbanking.js +0 -218
- package/dist/integrations/providers/impls/provider-factory.d.ts +0 -26
- package/dist/integrations/providers/impls/provider-factory.js +0 -146
- package/dist/integrations/providers/impls/qdrant-vector.d.ts +0 -24
- package/dist/integrations/providers/impls/qdrant-vector.js +0 -69
- package/dist/integrations/providers/impls/stripe-payments.d.ts +0 -28
- package/dist/integrations/providers/impls/stripe-payments.js +0 -202
- package/dist/integrations/providers/impls/twilio-sms.d.ts +0 -20
- package/dist/integrations/providers/impls/twilio-sms.js +0 -58
|
@@ -1,247 +0,0 @@
|
|
|
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,19 +0,0 @@
|
|
|
1
|
-
import { EmailOutboundMessage, EmailOutboundProvider, EmailOutboundResult } from "../email.js";
|
|
2
|
-
import { ServerClient } from "postmark";
|
|
3
|
-
|
|
4
|
-
//#region src/integrations/providers/impls/postmark-email.d.ts
|
|
5
|
-
interface PostmarkEmailProviderOptions {
|
|
6
|
-
serverToken: string;
|
|
7
|
-
defaultFromEmail?: string;
|
|
8
|
-
messageStream?: string;
|
|
9
|
-
client?: ServerClient;
|
|
10
|
-
}
|
|
11
|
-
declare class PostmarkEmailProvider implements EmailOutboundProvider {
|
|
12
|
-
private readonly client;
|
|
13
|
-
private readonly defaultFromEmail?;
|
|
14
|
-
private readonly messageStream?;
|
|
15
|
-
constructor(options: PostmarkEmailProviderOptions);
|
|
16
|
-
sendEmail(message: EmailOutboundMessage): Promise<EmailOutboundResult>;
|
|
17
|
-
}
|
|
18
|
-
//#endregion
|
|
19
|
-
export { PostmarkEmailProvider, PostmarkEmailProviderOptions };
|
|
@@ -1,55 +0,0 @@
|
|
|
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,124 +0,0 @@
|
|
|
1
|
-
//#region src/integrations/providers/impls/powens-client.d.ts
|
|
2
|
-
type PowensEnvironment = 'sandbox' | 'production';
|
|
3
|
-
interface PowensClientOptions {
|
|
4
|
-
clientId: string;
|
|
5
|
-
clientSecret: string;
|
|
6
|
-
apiKey?: string;
|
|
7
|
-
environment: PowensEnvironment;
|
|
8
|
-
baseUrl?: string;
|
|
9
|
-
fetchImpl?: typeof fetch;
|
|
10
|
-
defaultTimeoutMs?: number;
|
|
11
|
-
logger?: {
|
|
12
|
-
debug?: (...args: unknown[]) => void;
|
|
13
|
-
warn?: (...args: unknown[]) => void;
|
|
14
|
-
error?: (...args: unknown[]) => void;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
interface PowensAccount {
|
|
18
|
-
uuid: string;
|
|
19
|
-
reference: string;
|
|
20
|
-
userUuid: string;
|
|
21
|
-
institution: {
|
|
22
|
-
id: string;
|
|
23
|
-
name: string;
|
|
24
|
-
logoUrl?: string;
|
|
25
|
-
};
|
|
26
|
-
name: string;
|
|
27
|
-
iban?: string;
|
|
28
|
-
bic?: string;
|
|
29
|
-
currency?: string;
|
|
30
|
-
balance?: number;
|
|
31
|
-
availableBalance?: number;
|
|
32
|
-
type?: string;
|
|
33
|
-
status?: string;
|
|
34
|
-
metadata?: Record<string, unknown>;
|
|
35
|
-
}
|
|
36
|
-
interface PowensAccountListResponse {
|
|
37
|
-
accounts: PowensAccount[];
|
|
38
|
-
pagination?: {
|
|
39
|
-
nextCursor?: string;
|
|
40
|
-
hasMore?: boolean;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
interface PowensTransaction {
|
|
44
|
-
uuid: string;
|
|
45
|
-
accountUuid: string;
|
|
46
|
-
amount: number;
|
|
47
|
-
currency: string;
|
|
48
|
-
direction: 'credit' | 'debit';
|
|
49
|
-
description?: string;
|
|
50
|
-
category?: string;
|
|
51
|
-
rawLabel?: string;
|
|
52
|
-
bookingDate?: string;
|
|
53
|
-
valueDate?: string;
|
|
54
|
-
status?: string;
|
|
55
|
-
merchantName?: string;
|
|
56
|
-
merchantCategoryCode?: string;
|
|
57
|
-
counterpartyName?: string;
|
|
58
|
-
counterpartyAccount?: string;
|
|
59
|
-
metadata?: Record<string, unknown>;
|
|
60
|
-
}
|
|
61
|
-
interface PowensTransactionListResponse {
|
|
62
|
-
transactions: PowensTransaction[];
|
|
63
|
-
pagination?: {
|
|
64
|
-
nextCursor?: string;
|
|
65
|
-
hasMore?: boolean;
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
interface PowensBalance {
|
|
69
|
-
accountUuid: string;
|
|
70
|
-
type: string;
|
|
71
|
-
amount: number;
|
|
72
|
-
currency: string;
|
|
73
|
-
updatedAt: string;
|
|
74
|
-
metadata?: Record<string, unknown>;
|
|
75
|
-
}
|
|
76
|
-
interface PowensConnectionStatusResponse {
|
|
77
|
-
connectionUuid: string;
|
|
78
|
-
status: 'healthy' | 'error' | 'revoked' | 'pending';
|
|
79
|
-
lastAttemptAt?: string;
|
|
80
|
-
errorCode?: string;
|
|
81
|
-
errorMessage?: string;
|
|
82
|
-
metadata?: Record<string, unknown>;
|
|
83
|
-
}
|
|
84
|
-
declare class PowensClientError extends Error {
|
|
85
|
-
readonly status: number;
|
|
86
|
-
readonly code?: string;
|
|
87
|
-
readonly requestId?: string;
|
|
88
|
-
readonly response?: unknown;
|
|
89
|
-
constructor(message: string, status: number, code?: string, requestId?: string, response?: unknown);
|
|
90
|
-
}
|
|
91
|
-
declare class PowensClient {
|
|
92
|
-
private readonly clientId;
|
|
93
|
-
private readonly clientSecret;
|
|
94
|
-
private readonly apiKey?;
|
|
95
|
-
private readonly fetchImpl;
|
|
96
|
-
private readonly logger?;
|
|
97
|
-
private readonly defaultTimeoutMs;
|
|
98
|
-
private token?;
|
|
99
|
-
private readonly baseUrl;
|
|
100
|
-
constructor(options: PowensClientOptions);
|
|
101
|
-
listAccounts(params: {
|
|
102
|
-
userUuid: string;
|
|
103
|
-
cursor?: string;
|
|
104
|
-
limit?: number;
|
|
105
|
-
includeBalances?: boolean;
|
|
106
|
-
institutionUuid?: string;
|
|
107
|
-
}): Promise<PowensAccountListResponse>;
|
|
108
|
-
getAccount(accountUuid: string): Promise<PowensAccount>;
|
|
109
|
-
listTransactions(params: {
|
|
110
|
-
accountUuid: string;
|
|
111
|
-
cursor?: string;
|
|
112
|
-
limit?: number;
|
|
113
|
-
from?: string;
|
|
114
|
-
to?: string;
|
|
115
|
-
includePending?: boolean;
|
|
116
|
-
}): Promise<PowensTransactionListResponse>;
|
|
117
|
-
getBalances(accountUuid: string): Promise<PowensBalance[]>;
|
|
118
|
-
getConnectionStatus(connectionUuid: string): Promise<PowensConnectionStatusResponse>;
|
|
119
|
-
private request;
|
|
120
|
-
private ensureAccessToken;
|
|
121
|
-
private fetchAccessToken;
|
|
122
|
-
}
|
|
123
|
-
//#endregion
|
|
124
|
-
export { PowensAccount, PowensAccountListResponse, PowensBalance, PowensClient, PowensClientError, PowensClientOptions, PowensConnectionStatusResponse, PowensEnvironment, PowensTransaction, PowensTransactionListResponse };
|
|
@@ -1,171 +0,0 @@
|
|
|
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 };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { OpenBankingAccountBalance, OpenBankingAccountDetails, OpenBankingConnectionStatus, OpenBankingGetAccountDetailsParams, OpenBankingGetBalancesParams, OpenBankingGetConnectionStatusParams, OpenBankingListAccountsParams, OpenBankingListAccountsResult, OpenBankingListTransactionsParams, OpenBankingListTransactionsResult, OpenBankingProvider } from "../openbanking.js";
|
|
2
|
-
import { PowensClientOptions } from "./powens-client.js";
|
|
3
|
-
|
|
4
|
-
//#region src/integrations/providers/impls/powens-openbanking.d.ts
|
|
5
|
-
type PowensOpenBankingProviderOptions = PowensClientOptions;
|
|
6
|
-
declare class PowensOpenBankingProvider implements OpenBankingProvider {
|
|
7
|
-
private readonly client;
|
|
8
|
-
private readonly logger?;
|
|
9
|
-
constructor(options: PowensOpenBankingProviderOptions);
|
|
10
|
-
listAccounts(params: OpenBankingListAccountsParams): Promise<OpenBankingListAccountsResult>;
|
|
11
|
-
getAccountDetails(params: OpenBankingGetAccountDetailsParams): Promise<OpenBankingAccountDetails>;
|
|
12
|
-
listTransactions(params: OpenBankingListTransactionsParams): Promise<OpenBankingListTransactionsResult>;
|
|
13
|
-
getBalances(params: OpenBankingGetBalancesParams): Promise<OpenBankingAccountBalance[]>;
|
|
14
|
-
getConnectionStatus(params: OpenBankingGetConnectionStatusParams): Promise<OpenBankingConnectionStatus>;
|
|
15
|
-
private mapAccount;
|
|
16
|
-
private mapAccountDetails;
|
|
17
|
-
private mapTransaction;
|
|
18
|
-
private mapBalance;
|
|
19
|
-
private toContext;
|
|
20
|
-
private mapOwnership;
|
|
21
|
-
private mapAccountStatus;
|
|
22
|
-
private mapTransactionStatus;
|
|
23
|
-
private mapConnectionStatus;
|
|
24
|
-
private handleError;
|
|
25
|
-
}
|
|
26
|
-
//#endregion
|
|
27
|
-
export { PowensOpenBankingProvider, PowensOpenBankingProviderOptions };
|