@elizaos/plugin-finances 2.0.3-beta.6 → 2.0.3-beta.7
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/actions/finances.d.ts +38 -0
- package/dist/actions/finances.d.ts.map +1 -0
- package/dist/actions/finances.js +368 -0
- package/dist/actions/finances.js.map +1 -0
- package/dist/components/finances/FinancesSpatialView.d.ts +80 -0
- package/dist/components/finances/FinancesSpatialView.d.ts.map +1 -0
- package/dist/components/finances/FinancesSpatialView.js +157 -0
- package/dist/components/finances/FinancesSpatialView.js.map +1 -0
- package/dist/components/finances/FinancesView.d.ts +97 -0
- package/dist/components/finances/FinancesView.d.ts.map +1 -0
- package/dist/components/finances/FinancesView.js +231 -0
- package/dist/components/finances/FinancesView.js.map +1 -0
- package/dist/components/finances/finances-view-bundle.d.ts +10 -0
- package/dist/components/finances/finances-view-bundle.d.ts.map +1 -0
- package/dist/components/finances/finances-view-bundle.js +5 -0
- package/dist/components/finances/finances-view-bundle.js.map +1 -0
- package/dist/db/finances-repository.d.ts +51 -0
- package/dist/db/finances-repository.d.ts.map +1 -0
- package/dist/db/finances-repository.js +521 -0
- package/dist/db/finances-repository.js.map +1 -0
- package/dist/db/index.d.ts +3 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +6 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/schema.d.ts +2615 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +133 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/db/sql.d.ts +65 -0
- package/dist/db/sql.d.ts.map +1 -0
- package/dist/db/sql.js +182 -0
- package/dist/db/sql.js.map +1 -0
- package/dist/finance-normalize.d.ts +24 -0
- package/dist/finance-normalize.d.ts.map +1 -0
- package/dist/finance-normalize.js +66 -0
- package/dist/finance-normalize.js.map +1 -0
- package/dist/finances-service.d.ts +179 -0
- package/dist/finances-service.d.ts.map +1 -0
- package/dist/finances-service.js +1122 -0
- package/dist/finances-service.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +109 -0
- package/dist/index.js.map +1 -0
- package/dist/payment-csv-import.d.ts +23 -0
- package/dist/payment-csv-import.d.ts.map +1 -0
- package/dist/payment-csv-import.js +271 -0
- package/dist/payment-csv-import.js.map +1 -0
- package/dist/payment-recurrence.d.ts +14 -0
- package/dist/payment-recurrence.d.ts.map +1 -0
- package/dist/payment-recurrence.js +190 -0
- package/dist/payment-recurrence.js.map +1 -0
- package/dist/payment-types.d.ts +158 -0
- package/dist/payment-types.d.ts.map +1 -0
- package/dist/payment-types.js +1 -0
- package/dist/payment-types.js.map +1 -0
- package/dist/plugin.d.ts +15 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +31 -0
- package/dist/plugin.js.map +1 -0
- package/dist/register-terminal-view.d.ts +15 -0
- package/dist/register-terminal-view.d.ts.map +1 -0
- package/dist/register-terminal-view.js +21 -0
- package/dist/register-terminal-view.js.map +1 -0
- package/dist/register.d.ts +9 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +5 -0
- package/dist/register.js.map +1 -0
- package/dist/services/browser-bridge-seam.d.ts +40 -0
- package/dist/services/browser-bridge-seam.d.ts.map +1 -0
- package/dist/services/browser-bridge-seam.js +39 -0
- package/dist/services/browser-bridge-seam.js.map +1 -0
- package/dist/services/gmail-seam.d.ts +40 -0
- package/dist/services/gmail-seam.d.ts.map +1 -0
- package/dist/services/gmail-seam.js +208 -0
- package/dist/services/gmail-seam.js.map +1 -0
- package/dist/services/migration.d.ts +65 -0
- package/dist/services/migration.d.ts.map +1 -0
- package/dist/services/migration.js +116 -0
- package/dist/services/migration.js.map +1 -0
- package/dist/services/subscriptions-service.d.ts +76 -0
- package/dist/services/subscriptions-service.d.ts.map +1 -0
- package/dist/services/subscriptions-service.js +1002 -0
- package/dist/services/subscriptions-service.js.map +1 -0
- package/dist/subscriptions-playbooks.d.ts +79 -0
- package/dist/subscriptions-playbooks.d.ts.map +1 -0
- package/dist/subscriptions-playbooks.js +871 -0
- package/dist/subscriptions-playbooks.js.map +1 -0
- package/dist/subscriptions-types.d.ts +80 -0
- package/dist/subscriptions-types.d.ts.map +1 -0
- package/dist/subscriptions-types.js +1 -0
- package/dist/subscriptions-types.js.map +1 -0
- package/dist/token-encryption.d.ts +42 -0
- package/dist/token-encryption.d.ts.map +1 -0
- package/dist/token-encryption.js +96 -0
- package/dist/token-encryption.js.map +1 -0
- package/dist/types.d.ts +55 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +18 -0
- package/dist/types.js.map +1 -0
- package/dist/views/bundle.js +411 -0
- package/dist/views/bundle.js.map +1 -0
- package/package.json +11 -11
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OWNER_FINANCES payments back-end for `@elizaos/plugin-finances`.
|
|
3
|
+
*
|
|
4
|
+
* Owns the payment-source / transaction / spending-summary / recurring-charge
|
|
5
|
+
* subactions and their parameter schema. The registered `OWNER_FINANCES`
|
|
6
|
+
* umbrella action lives in `@elizaos/plugin-personal-assistant` because it also
|
|
7
|
+
* dispatches the `subscription_*` verbs to the subscription back-end (which
|
|
8
|
+
* orchestrates the agent's Gmail + browser-bridge surfaces). PA imports
|
|
9
|
+
* {@link runPaymentsHandler} + the parameter constants from here, so the
|
|
10
|
+
* payments logic has a single home.
|
|
11
|
+
*/
|
|
12
|
+
import type { ActionResult, HandlerOptions, IAgentRuntime, Memory, State } from "@elizaos/core";
|
|
13
|
+
import { type FinancesServiceOptions } from "../finances-service.js";
|
|
14
|
+
/** Public similes for the OWNER_FINANCES umbrella. */
|
|
15
|
+
export declare const OWNER_FINANCE_SIMILES: readonly string[];
|
|
16
|
+
/**
|
|
17
|
+
* Parameter schema for the OWNER_FINANCES back-end — the registered umbrella
|
|
18
|
+
* surfaces this as its public param list (after renaming `subaction` →
|
|
19
|
+
* `action`).
|
|
20
|
+
*/
|
|
21
|
+
export declare const MONEY_PARAMETERS: readonly {
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
required: boolean;
|
|
25
|
+
schema: {
|
|
26
|
+
type: "string" | "number" | "boolean";
|
|
27
|
+
};
|
|
28
|
+
}[];
|
|
29
|
+
export declare const MONEY_TAGS: readonly string[];
|
|
30
|
+
export declare const MONEY_CONTEXTS: readonly string[];
|
|
31
|
+
/**
|
|
32
|
+
* Handler function backing OWNER_FINANCES payment-source and spending
|
|
33
|
+
* subactions. The umbrella in plugin-personal-assistant's `money.ts` is the
|
|
34
|
+
* only caller; no Action object is registered for this handler here.
|
|
35
|
+
*/
|
|
36
|
+
export declare function runPaymentsHandler(runtime: IAgentRuntime, message: Memory, state: State | undefined, options: HandlerOptions | undefined): Promise<ActionResult>;
|
|
37
|
+
export type { FinancesServiceOptions };
|
|
38
|
+
//# sourceMappingURL=finances.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finances.d.ts","sourceRoot":"","sources":["../../src/actions/finances.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,aAAa,EACb,MAAM,EACN,KAAK,EACN,MAAM,eAAe,CAAC;AAEvB,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,wBAAwB,CAAC;AAMhC,sDAAsD;AACtD,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAelD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE;QAAE,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAA;KAAE,CAAC;CACnD,EAsJA,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,SAAS,MAAM,EAWvC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAQ3C,CAAC;AA+MF;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,KAAK,GAAG,SAAS,EACxB,OAAO,EAAE,cAAc,GAAG,SAAS,GAClC,OAAO,CAAC,YAAY,CAAC,CAavB;AAED,YAAY,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { FinancesServiceError } from "../finance-normalize.js";
|
|
2
|
+
import {
|
|
3
|
+
FinancesService
|
|
4
|
+
} from "../finances-service.js";
|
|
5
|
+
const OWNER_FINANCE_SIMILES = [
|
|
6
|
+
"MONEY",
|
|
7
|
+
"PAYMENTS",
|
|
8
|
+
"SUBSCRIPTIONS",
|
|
9
|
+
"SPENDING",
|
|
10
|
+
"ROCKET_MONEY",
|
|
11
|
+
"BANK_TRANSACTIONS",
|
|
12
|
+
"RECURRING_CHARGES",
|
|
13
|
+
"BUDGET",
|
|
14
|
+
"EXPENSES",
|
|
15
|
+
"CANCEL_SUBSCRIPTION",
|
|
16
|
+
"AUDIT_SUBSCRIPTIONS",
|
|
17
|
+
"CANCEL_NETFLIX",
|
|
18
|
+
"CANCEL_HULU",
|
|
19
|
+
"MANAGE_SUBSCRIPTIONS"
|
|
20
|
+
];
|
|
21
|
+
const MONEY_PARAMETERS = [
|
|
22
|
+
{
|
|
23
|
+
name: "subaction",
|
|
24
|
+
description: "dashboard | list_sources | add_source | remove_source | import_csv | list_transactions | spending_summary | recurring_charges | subscription_audit | subscription_cancel | subscription_status. Defaults to dashboard for ambiguous intents.",
|
|
25
|
+
required: false,
|
|
26
|
+
schema: { type: "string" }
|
|
27
|
+
},
|
|
28
|
+
// Payments-side params.
|
|
29
|
+
{
|
|
30
|
+
name: "sourceId",
|
|
31
|
+
description: "Payment source UUID for scoped reads and CSV import.",
|
|
32
|
+
required: false,
|
|
33
|
+
schema: { type: "string" }
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "kind",
|
|
37
|
+
description: "add_source kind: csv | plaid | manual | paypal.",
|
|
38
|
+
required: false,
|
|
39
|
+
schema: { type: "string" }
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "label",
|
|
43
|
+
description: "Human label when adding a source.",
|
|
44
|
+
required: false,
|
|
45
|
+
schema: { type: "string" }
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "institution",
|
|
49
|
+
description: "Institution display name.",
|
|
50
|
+
required: false,
|
|
51
|
+
schema: { type: "string" }
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "accountMask",
|
|
55
|
+
description: "Last-four or mask string.",
|
|
56
|
+
required: false,
|
|
57
|
+
schema: { type: "string" }
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "csvText",
|
|
61
|
+
description: "Raw CSV payload for import_csv.",
|
|
62
|
+
required: false,
|
|
63
|
+
schema: { type: "string" }
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "dateColumn",
|
|
67
|
+
description: "CSV column hint for posting date.",
|
|
68
|
+
required: false,
|
|
69
|
+
schema: { type: "string" }
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "amountColumn",
|
|
73
|
+
description: "CSV column hint for amount.",
|
|
74
|
+
required: false,
|
|
75
|
+
schema: { type: "string" }
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "merchantColumn",
|
|
79
|
+
description: "CSV column hint for merchant.",
|
|
80
|
+
required: false,
|
|
81
|
+
schema: { type: "string" }
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "descriptionColumn",
|
|
85
|
+
description: "CSV column hint for description.",
|
|
86
|
+
required: false,
|
|
87
|
+
schema: { type: "string" }
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "categoryColumn",
|
|
91
|
+
description: "CSV column hint for category.",
|
|
92
|
+
required: false,
|
|
93
|
+
schema: { type: "string" }
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "windowDays",
|
|
97
|
+
description: "Rolling window for dashboard or spending summaries.",
|
|
98
|
+
required: false,
|
|
99
|
+
schema: { type: "number" }
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "sinceDays",
|
|
103
|
+
description: "History window for recurring charge detection.",
|
|
104
|
+
required: false,
|
|
105
|
+
schema: { type: "number" }
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: "limit",
|
|
109
|
+
description: "Transaction row cap for listings.",
|
|
110
|
+
required: false,
|
|
111
|
+
schema: { type: "number" }
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "merchantContains",
|
|
115
|
+
description: "Filter transactions by merchant substring.",
|
|
116
|
+
required: false,
|
|
117
|
+
schema: { type: "string" }
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "onlyDebits",
|
|
121
|
+
description: "Exclude credits when listing transactions.",
|
|
122
|
+
required: false,
|
|
123
|
+
schema: { type: "boolean" }
|
|
124
|
+
},
|
|
125
|
+
// Subscription-side params.
|
|
126
|
+
{
|
|
127
|
+
name: "serviceName",
|
|
128
|
+
description: "Display name of the subscription service.",
|
|
129
|
+
required: false,
|
|
130
|
+
schema: { type: "string" }
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: "serviceSlug",
|
|
134
|
+
description: "Normalized slug for routing.",
|
|
135
|
+
required: false,
|
|
136
|
+
schema: { type: "string" }
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: "candidateId",
|
|
140
|
+
description: "Internal audit candidate identifier.",
|
|
141
|
+
required: false,
|
|
142
|
+
schema: { type: "string" }
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: "cancellationId",
|
|
146
|
+
description: "Ongoing cancellation id for status lookups.",
|
|
147
|
+
required: false,
|
|
148
|
+
schema: { type: "string" }
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: "executor",
|
|
152
|
+
description: "Browser executor: user_browser | agent_browser | desktop_native.",
|
|
153
|
+
required: false,
|
|
154
|
+
schema: { type: "string" }
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: "queryWindowDays",
|
|
158
|
+
description: "Days of history for audit queries.",
|
|
159
|
+
required: false,
|
|
160
|
+
schema: { type: "number" }
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
name: "confirmed",
|
|
164
|
+
description: "User confirmed cancellation prerequisites.",
|
|
165
|
+
required: false,
|
|
166
|
+
schema: { type: "boolean" }
|
|
167
|
+
}
|
|
168
|
+
];
|
|
169
|
+
const MONEY_TAGS = [
|
|
170
|
+
"domain:finance",
|
|
171
|
+
"capability:read",
|
|
172
|
+
"capability:write",
|
|
173
|
+
"capability:update",
|
|
174
|
+
"capability:delete",
|
|
175
|
+
"capability:execute",
|
|
176
|
+
"surface:remote-api",
|
|
177
|
+
"surface:internal",
|
|
178
|
+
"risk:financial",
|
|
179
|
+
"cost:expensive"
|
|
180
|
+
];
|
|
181
|
+
const MONEY_CONTEXTS = [
|
|
182
|
+
"payments",
|
|
183
|
+
"finance",
|
|
184
|
+
"wallet",
|
|
185
|
+
"crypto",
|
|
186
|
+
"subscriptions",
|
|
187
|
+
"browser",
|
|
188
|
+
"automation"
|
|
189
|
+
];
|
|
190
|
+
function mergeParams(message, options) {
|
|
191
|
+
const params = {
|
|
192
|
+
...options?.parameters ?? {}
|
|
193
|
+
};
|
|
194
|
+
if (message.content && typeof message.content === "object") {
|
|
195
|
+
for (const [key, value] of Object.entries(
|
|
196
|
+
message.content
|
|
197
|
+
)) {
|
|
198
|
+
if (params[key] === void 0) {
|
|
199
|
+
params[key] = value;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return params;
|
|
204
|
+
}
|
|
205
|
+
function normalizeSubaction(value) {
|
|
206
|
+
if (typeof value !== "string") {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
const normalized = value.trim().toLowerCase().replace(/[- ]/g, "_");
|
|
210
|
+
const subactions = [
|
|
211
|
+
"dashboard",
|
|
212
|
+
"list_sources",
|
|
213
|
+
"add_source",
|
|
214
|
+
"remove_source",
|
|
215
|
+
"import_csv",
|
|
216
|
+
"list_transactions",
|
|
217
|
+
"spending_summary",
|
|
218
|
+
"recurring_charges"
|
|
219
|
+
];
|
|
220
|
+
return subactions.includes(normalized) ? normalized : null;
|
|
221
|
+
}
|
|
222
|
+
async function runPaymentsActionInner(runtime, message, state, options) {
|
|
223
|
+
void state;
|
|
224
|
+
const params = mergeParams(message, options);
|
|
225
|
+
const service = new FinancesService(runtime);
|
|
226
|
+
const subaction = normalizeSubaction(params.subaction) ?? "dashboard";
|
|
227
|
+
switch (subaction) {
|
|
228
|
+
case "dashboard": {
|
|
229
|
+
const dashboard = await service.getPaymentsDashboard({
|
|
230
|
+
windowDays: params.windowDays ?? null
|
|
231
|
+
});
|
|
232
|
+
return {
|
|
233
|
+
success: true,
|
|
234
|
+
text: service.summarizePaymentsDashboard(dashboard),
|
|
235
|
+
data: { dashboard }
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
case "list_sources": {
|
|
239
|
+
const sources = await service.listPaymentSources();
|
|
240
|
+
return {
|
|
241
|
+
success: true,
|
|
242
|
+
text: sources.length === 0 ? "No payment sources connected." : `${sources.length} payment source${sources.length === 1 ? "" : "s"} connected.`,
|
|
243
|
+
data: { sources }
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
case "add_source": {
|
|
247
|
+
if (!params.kind || !params.label) {
|
|
248
|
+
return {
|
|
249
|
+
success: false,
|
|
250
|
+
text: "Adding a payment source requires a kind (csv/plaid/manual/paypal) and a label.",
|
|
251
|
+
data: { error: "MISSING_SOURCE_FIELDS" }
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
const request = {
|
|
255
|
+
kind: params.kind,
|
|
256
|
+
label: params.label,
|
|
257
|
+
institution: params.institution ?? null,
|
|
258
|
+
accountMask: params.accountMask ?? null
|
|
259
|
+
};
|
|
260
|
+
const source = await service.addPaymentSource(request);
|
|
261
|
+
return {
|
|
262
|
+
success: true,
|
|
263
|
+
text: `Added ${source.kind} source "${source.label}".`,
|
|
264
|
+
data: { source }
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
case "remove_source": {
|
|
268
|
+
if (!params.sourceId) {
|
|
269
|
+
return {
|
|
270
|
+
success: false,
|
|
271
|
+
text: "Removing a payment source requires sourceId.",
|
|
272
|
+
data: { error: "MISSING_SOURCE_ID" }
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
await service.deletePaymentSource(params.sourceId);
|
|
276
|
+
return {
|
|
277
|
+
success: true,
|
|
278
|
+
text: "Payment source removed.",
|
|
279
|
+
data: { sourceId: params.sourceId }
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
case "import_csv": {
|
|
283
|
+
if (!params.sourceId || !params.csvText) {
|
|
284
|
+
return {
|
|
285
|
+
success: false,
|
|
286
|
+
text: "CSV import requires sourceId and csvText.",
|
|
287
|
+
data: { error: "MISSING_IMPORT_FIELDS" }
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
const result = await service.importTransactionsCsv({
|
|
291
|
+
sourceId: params.sourceId,
|
|
292
|
+
csvText: params.csvText,
|
|
293
|
+
dateColumn: params.dateColumn,
|
|
294
|
+
amountColumn: params.amountColumn,
|
|
295
|
+
merchantColumn: params.merchantColumn,
|
|
296
|
+
descriptionColumn: params.descriptionColumn,
|
|
297
|
+
categoryColumn: params.categoryColumn
|
|
298
|
+
});
|
|
299
|
+
const summary = `Imported ${result.inserted} transaction${result.inserted === 1 ? "" : "s"} (${result.skipped} already on file, ${result.errors.length} error${result.errors.length === 1 ? "" : "s"}).`;
|
|
300
|
+
return {
|
|
301
|
+
success: result.errors.length === 0 || result.inserted > 0,
|
|
302
|
+
text: summary,
|
|
303
|
+
data: { result }
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
case "list_transactions": {
|
|
307
|
+
const transactions = await service.listTransactions({
|
|
308
|
+
sourceId: params.sourceId ?? null,
|
|
309
|
+
limit: params.limit ?? null,
|
|
310
|
+
merchantContains: params.merchantContains ?? null,
|
|
311
|
+
onlyDebits: params.onlyDebits ?? null
|
|
312
|
+
});
|
|
313
|
+
return {
|
|
314
|
+
success: true,
|
|
315
|
+
text: `${transactions.length} transaction${transactions.length === 1 ? "" : "s"} returned.`,
|
|
316
|
+
data: { transactions }
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
case "spending_summary": {
|
|
320
|
+
const summary = await service.getSpendingSummary({
|
|
321
|
+
windowDays: params.windowDays ?? null,
|
|
322
|
+
sourceId: params.sourceId ?? null
|
|
323
|
+
});
|
|
324
|
+
return {
|
|
325
|
+
success: true,
|
|
326
|
+
text: `Spent $${summary.totalSpendUsd.toFixed(2)} in the last ${summary.windowDays} days across ${summary.transactionCount} transactions.`,
|
|
327
|
+
data: { summary }
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
case "recurring_charges": {
|
|
331
|
+
const charges = await service.getRecurringCharges({
|
|
332
|
+
sourceId: params.sourceId ?? null,
|
|
333
|
+
sinceDays: params.sinceDays ?? null
|
|
334
|
+
});
|
|
335
|
+
const annualized = charges.reduce(
|
|
336
|
+
(total, charge) => total + charge.annualizedCostUsd,
|
|
337
|
+
0
|
|
338
|
+
);
|
|
339
|
+
return {
|
|
340
|
+
success: true,
|
|
341
|
+
text: `Detected ${charges.length} recurring charge${charges.length === 1 ? "" : "s"} worth ~$${annualized.toFixed(2)}/yr.`,
|
|
342
|
+
data: { charges }
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
async function runPaymentsHandler(runtime, message, state, options) {
|
|
348
|
+
try {
|
|
349
|
+
return await runPaymentsActionInner(runtime, message, state, options);
|
|
350
|
+
} catch (error) {
|
|
351
|
+
if (error instanceof FinancesServiceError) {
|
|
352
|
+
return {
|
|
353
|
+
success: false,
|
|
354
|
+
text: error.message,
|
|
355
|
+
data: { status: error.status }
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
throw error;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
export {
|
|
362
|
+
MONEY_CONTEXTS,
|
|
363
|
+
MONEY_PARAMETERS,
|
|
364
|
+
MONEY_TAGS,
|
|
365
|
+
OWNER_FINANCE_SIMILES,
|
|
366
|
+
runPaymentsHandler
|
|
367
|
+
};
|
|
368
|
+
//# sourceMappingURL=finances.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/actions/finances.ts"],"sourcesContent":["/**\n * OWNER_FINANCES payments back-end for `@elizaos/plugin-finances`.\n *\n * Owns the payment-source / transaction / spending-summary / recurring-charge\n * subactions and their parameter schema. The registered `OWNER_FINANCES`\n * umbrella action lives in `@elizaos/plugin-personal-assistant` because it also\n * dispatches the `subscription_*` verbs to the subscription back-end (which\n * orchestrates the agent's Gmail + browser-bridge surfaces). PA imports\n * {@link runPaymentsHandler} + the parameter constants from here, so the\n * payments logic has a single home.\n */\n\nimport type {\n ActionResult,\n HandlerOptions,\n IAgentRuntime,\n Memory,\n State,\n} from \"@elizaos/core\";\nimport { FinancesServiceError } from \"../finance-normalize.js\";\nimport {\n FinancesService,\n type FinancesServiceOptions,\n} from \"../finances-service.js\";\nimport type {\n AddPaymentSourceRequest,\n LifeOpsPaymentSourceKind,\n} from \"../payment-types.js\";\n\n/** Public similes for the OWNER_FINANCES umbrella. */\nexport const OWNER_FINANCE_SIMILES: readonly string[] = [\n \"MONEY\",\n \"PAYMENTS\",\n \"SUBSCRIPTIONS\",\n \"SPENDING\",\n \"ROCKET_MONEY\",\n \"BANK_TRANSACTIONS\",\n \"RECURRING_CHARGES\",\n \"BUDGET\",\n \"EXPENSES\",\n \"CANCEL_SUBSCRIPTION\",\n \"AUDIT_SUBSCRIPTIONS\",\n \"CANCEL_NETFLIX\",\n \"CANCEL_HULU\",\n \"MANAGE_SUBSCRIPTIONS\",\n];\n\n/**\n * Parameter schema for the OWNER_FINANCES back-end — the registered umbrella\n * surfaces this as its public param list (after renaming `subaction` →\n * `action`).\n */\nexport const MONEY_PARAMETERS: readonly {\n name: string;\n description: string;\n required: boolean;\n schema: { type: \"string\" | \"number\" | \"boolean\" };\n}[] = [\n {\n name: \"subaction\",\n description:\n \"dashboard | list_sources | add_source | remove_source | import_csv | list_transactions | spending_summary | recurring_charges \" +\n \"| subscription_audit | subscription_cancel | subscription_status. Defaults to dashboard for ambiguous intents.\",\n required: false,\n schema: { type: \"string\" },\n },\n // Payments-side params.\n {\n name: \"sourceId\",\n description: \"Payment source UUID for scoped reads and CSV import.\",\n required: false,\n schema: { type: \"string\" },\n },\n {\n name: \"kind\",\n description: \"add_source kind: csv | plaid | manual | paypal.\",\n required: false,\n schema: { type: \"string\" },\n },\n {\n name: \"label\",\n description: \"Human label when adding a source.\",\n required: false,\n schema: { type: \"string\" },\n },\n {\n name: \"institution\",\n description: \"Institution display name.\",\n required: false,\n schema: { type: \"string\" },\n },\n {\n name: \"accountMask\",\n description: \"Last-four or mask string.\",\n required: false,\n schema: { type: \"string\" },\n },\n {\n name: \"csvText\",\n description: \"Raw CSV payload for import_csv.\",\n required: false,\n schema: { type: \"string\" },\n },\n {\n name: \"dateColumn\",\n description: \"CSV column hint for posting date.\",\n required: false,\n schema: { type: \"string\" },\n },\n {\n name: \"amountColumn\",\n description: \"CSV column hint for amount.\",\n required: false,\n schema: { type: \"string\" },\n },\n {\n name: \"merchantColumn\",\n description: \"CSV column hint for merchant.\",\n required: false,\n schema: { type: \"string\" },\n },\n {\n name: \"descriptionColumn\",\n description: \"CSV column hint for description.\",\n required: false,\n schema: { type: \"string\" },\n },\n {\n name: \"categoryColumn\",\n description: \"CSV column hint for category.\",\n required: false,\n schema: { type: \"string\" },\n },\n {\n name: \"windowDays\",\n description: \"Rolling window for dashboard or spending summaries.\",\n required: false,\n schema: { type: \"number\" },\n },\n {\n name: \"sinceDays\",\n description: \"History window for recurring charge detection.\",\n required: false,\n schema: { type: \"number\" },\n },\n {\n name: \"limit\",\n description: \"Transaction row cap for listings.\",\n required: false,\n schema: { type: \"number\" },\n },\n {\n name: \"merchantContains\",\n description: \"Filter transactions by merchant substring.\",\n required: false,\n schema: { type: \"string\" },\n },\n {\n name: \"onlyDebits\",\n description: \"Exclude credits when listing transactions.\",\n required: false,\n schema: { type: \"boolean\" },\n },\n // Subscription-side params.\n {\n name: \"serviceName\",\n description: \"Display name of the subscription service.\",\n required: false,\n schema: { type: \"string\" },\n },\n {\n name: \"serviceSlug\",\n description: \"Normalized slug for routing.\",\n required: false,\n schema: { type: \"string\" },\n },\n {\n name: \"candidateId\",\n description: \"Internal audit candidate identifier.\",\n required: false,\n schema: { type: \"string\" },\n },\n {\n name: \"cancellationId\",\n description: \"Ongoing cancellation id for status lookups.\",\n required: false,\n schema: { type: \"string\" },\n },\n {\n name: \"executor\",\n description:\n \"Browser executor: user_browser | agent_browser | desktop_native.\",\n required: false,\n schema: { type: \"string\" },\n },\n {\n name: \"queryWindowDays\",\n description: \"Days of history for audit queries.\",\n required: false,\n schema: { type: \"number\" },\n },\n {\n name: \"confirmed\",\n description: \"User confirmed cancellation prerequisites.\",\n required: false,\n schema: { type: \"boolean\" },\n },\n];\n\nexport const MONEY_TAGS: readonly string[] = [\n \"domain:finance\",\n \"capability:read\",\n \"capability:write\",\n \"capability:update\",\n \"capability:delete\",\n \"capability:execute\",\n \"surface:remote-api\",\n \"surface:internal\",\n \"risk:financial\",\n \"cost:expensive\",\n];\n\nexport const MONEY_CONTEXTS: readonly string[] = [\n \"payments\",\n \"finance\",\n \"wallet\",\n \"crypto\",\n \"subscriptions\",\n \"browser\",\n \"automation\",\n];\n\ntype PaymentsSubaction =\n | \"dashboard\"\n | \"list_sources\"\n | \"add_source\"\n | \"remove_source\"\n | \"import_csv\"\n | \"list_transactions\"\n | \"spending_summary\"\n | \"recurring_charges\";\n\ntype PaymentsActionParams = {\n subaction?: PaymentsSubaction;\n sourceId?: string;\n kind?: LifeOpsPaymentSourceKind;\n label?: string;\n institution?: string | null;\n accountMask?: string | null;\n csvText?: string;\n dateColumn?: string;\n amountColumn?: string;\n merchantColumn?: string;\n descriptionColumn?: string;\n categoryColumn?: string;\n windowDays?: number;\n sinceDays?: number;\n limit?: number;\n merchantContains?: string;\n onlyDebits?: boolean;\n};\n\nfunction mergeParams(\n message: Memory,\n options?: HandlerOptions,\n): PaymentsActionParams {\n const params = {\n ...(((options as Record<string, unknown> | undefined)?.parameters ??\n {}) as Record<string, unknown>),\n };\n if (message.content && typeof message.content === \"object\") {\n for (const [key, value] of Object.entries(\n message.content as Record<string, unknown>,\n )) {\n if (params[key] === undefined) {\n params[key] = value;\n }\n }\n }\n return params as PaymentsActionParams;\n}\n\nfunction normalizeSubaction(value: unknown): PaymentsSubaction | null {\n if (typeof value !== \"string\") {\n return null;\n }\n const normalized = value.trim().toLowerCase().replace(/[- ]/g, \"_\");\n const subactions: PaymentsSubaction[] = [\n \"dashboard\",\n \"list_sources\",\n \"add_source\",\n \"remove_source\",\n \"import_csv\",\n \"list_transactions\",\n \"spending_summary\",\n \"recurring_charges\",\n ];\n return (subactions as string[]).includes(normalized)\n ? (normalized as PaymentsSubaction)\n : null;\n}\n\nasync function runPaymentsActionInner(\n runtime: IAgentRuntime,\n message: Memory,\n state: State | undefined,\n options?: HandlerOptions,\n): Promise<ActionResult> {\n void state;\n const params = mergeParams(message, options);\n const service = new FinancesService(runtime);\n const subaction = normalizeSubaction(params.subaction) ?? \"dashboard\";\n\n switch (subaction) {\n case \"dashboard\": {\n const dashboard = await service.getPaymentsDashboard({\n windowDays: params.windowDays ?? null,\n });\n return {\n success: true,\n text: service.summarizePaymentsDashboard(dashboard),\n data: { dashboard },\n };\n }\n case \"list_sources\": {\n const sources = await service.listPaymentSources();\n return {\n success: true,\n text:\n sources.length === 0\n ? \"No payment sources connected.\"\n : `${sources.length} payment source${sources.length === 1 ? \"\" : \"s\"} connected.`,\n data: { sources },\n };\n }\n case \"add_source\": {\n if (!params.kind || !params.label) {\n return {\n success: false,\n text: \"Adding a payment source requires a kind (csv/plaid/manual/paypal) and a label.\",\n data: { error: \"MISSING_SOURCE_FIELDS\" },\n };\n }\n const request: AddPaymentSourceRequest = {\n kind: params.kind,\n label: params.label,\n institution: params.institution ?? null,\n accountMask: params.accountMask ?? null,\n };\n const source = await service.addPaymentSource(request);\n return {\n success: true,\n text: `Added ${source.kind} source \"${source.label}\".`,\n data: { source },\n };\n }\n case \"remove_source\": {\n if (!params.sourceId) {\n return {\n success: false,\n text: \"Removing a payment source requires sourceId.\",\n data: { error: \"MISSING_SOURCE_ID\" },\n };\n }\n await service.deletePaymentSource(params.sourceId);\n return {\n success: true,\n text: \"Payment source removed.\",\n data: { sourceId: params.sourceId },\n };\n }\n case \"import_csv\": {\n if (!params.sourceId || !params.csvText) {\n return {\n success: false,\n text: \"CSV import requires sourceId and csvText.\",\n data: { error: \"MISSING_IMPORT_FIELDS\" },\n };\n }\n const result = await service.importTransactionsCsv({\n sourceId: params.sourceId,\n csvText: params.csvText,\n dateColumn: params.dateColumn,\n amountColumn: params.amountColumn,\n merchantColumn: params.merchantColumn,\n descriptionColumn: params.descriptionColumn,\n categoryColumn: params.categoryColumn,\n });\n const summary = `Imported ${result.inserted} transaction${result.inserted === 1 ? \"\" : \"s\"} (${result.skipped} already on file, ${result.errors.length} error${result.errors.length === 1 ? \"\" : \"s\"}).`;\n return {\n success: result.errors.length === 0 || result.inserted > 0,\n text: summary,\n data: { result },\n };\n }\n case \"list_transactions\": {\n const transactions = await service.listTransactions({\n sourceId: params.sourceId ?? null,\n limit: params.limit ?? null,\n merchantContains: params.merchantContains ?? null,\n onlyDebits: params.onlyDebits ?? null,\n });\n return {\n success: true,\n text: `${transactions.length} transaction${transactions.length === 1 ? \"\" : \"s\"} returned.`,\n data: { transactions },\n };\n }\n case \"spending_summary\": {\n const summary = await service.getSpendingSummary({\n windowDays: params.windowDays ?? null,\n sourceId: params.sourceId ?? null,\n });\n return {\n success: true,\n text: `Spent $${summary.totalSpendUsd.toFixed(2)} in the last ${summary.windowDays} days across ${summary.transactionCount} transactions.`,\n data: { summary },\n };\n }\n case \"recurring_charges\": {\n const charges = await service.getRecurringCharges({\n sourceId: params.sourceId ?? null,\n sinceDays: params.sinceDays ?? null,\n });\n const annualized = charges.reduce(\n (total, charge) => total + charge.annualizedCostUsd,\n 0,\n );\n return {\n success: true,\n text: `Detected ${charges.length} recurring charge${charges.length === 1 ? \"\" : \"s\"} worth ~$${annualized.toFixed(2)}/yr.`,\n data: { charges },\n };\n }\n }\n}\n\n/**\n * Handler function backing OWNER_FINANCES payment-source and spending\n * subactions. The umbrella in plugin-personal-assistant's `money.ts` is the\n * only caller; no Action object is registered for this handler here.\n */\nexport async function runPaymentsHandler(\n runtime: IAgentRuntime,\n message: Memory,\n state: State | undefined,\n options: HandlerOptions | undefined,\n): Promise<ActionResult> {\n try {\n return await runPaymentsActionInner(runtime, message, state, options);\n } catch (error) {\n if (error instanceof FinancesServiceError) {\n return {\n success: false,\n text: error.message,\n data: { status: error.status },\n };\n }\n throw error;\n }\n}\n\nexport type { FinancesServiceOptions };\n"],"mappings":"AAmBA,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,OAEK;AAOA,MAAM,wBAA2C;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAOO,MAAM,mBAKP;AAAA,EACJ;AAAA,IACE,MAAM;AAAA,IACN,aACE;AAAA,IAEF,UAAU;AAAA,IACV,QAAQ,EAAE,MAAM,SAAS;AAAA,EAC3B;AAAA;AAAA,EAEA;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,UAAU;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Q,UAAU,gBAAgB,QAAQ,gBAAgB;AAAA,QAC1H,MAAM,EAAE,QAAQ;AAAA,MAClB;AAAA,IACF;AAAA,IACA,KAAK,qBAAqB;AACxB,YAAM,UAAU,MAAM,QAAQ,oBAAoB;AAAA,QAChD,UAAU,OAAO,YAAY;AAAA,QAC7B,WAAW,OAAO,aAAa;AAAA,MACjC,CAAC;AACD,YAAM,aAAa,QAAQ;AAAA,QACzB,CAAC,OAAO,WAAW,QAAQ,OAAO;AAAA,QAClC;AAAA,MACF;AACA,aAAO;AAAA,QACL,SAAS;AAAA,QACT,MAAM,YAAY,QAAQ,MAAM,oBAAoB,QAAQ,WAAW,IAAI,KAAK,GAAG,YAAY,WAAW,QAAQ,CAAC,CAAC;AAAA,QACpH,MAAM,EAAE,QAAQ;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AACF;AAOA,eAAsB,mBACpB,SACA,SACA,OACA,SACuB;AACvB,MAAI;AACF,WAAO,MAAM,uBAAuB,SAAS,SAAS,OAAO,OAAO;AAAA,EACtE,SAAS,OAAO;AACd,QAAI,iBAAiB,sBAAsB;AACzC,aAAO;AAAA,QACL,SAAS;AAAA,QACT,MAAM,MAAM;AAAA,QACZ,MAAM,EAAE,QAAQ,MAAM,OAAO;AAAA,MAC/B;AAAA,IACF;AACA,UAAM;AAAA,EACR;AACF;","names":[]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FinancesSpatialView — the owner finance dashboard authored once with the
|
|
3
|
+
* spatial vocabulary, so it renders correctly wherever it is displayed:
|
|
4
|
+
*
|
|
5
|
+
* - GUI / XR — mounted in `<SpatialSurface>` (DOM; XR scales up).
|
|
6
|
+
* - TUI — rendered to real terminal lines by the agent terminal, via
|
|
7
|
+
* `registerSpatialTerminalView` (see `register-terminal-view.tsx`).
|
|
8
|
+
*
|
|
9
|
+
* It is purely presentational (a snapshot + an action callback in, primitives
|
|
10
|
+
* out) and imports only the cross-modality primitives, so it is safe to render
|
|
11
|
+
* in the Node agent process where the terminal lives (no browser/client import).
|
|
12
|
+
*
|
|
13
|
+
* The balance, transactions, and recurring charges — including every currency
|
|
14
|
+
* amount — arrive ALREADY FORMATTED as display strings from the data wrapper
|
|
15
|
+
* ({@link ./FinancesView.tsx}); this component never fetches, computes a total,
|
|
16
|
+
* or runs financial math. It displays the snapshot and dispatches actions.
|
|
17
|
+
*/
|
|
18
|
+
/** Which render state the dashboard is in. */
|
|
19
|
+
export type FinancesViewState = "loading" | "error" | "empty" | "ready";
|
|
20
|
+
/** A balance summary row, already projected to display strings by the wrapper. */
|
|
21
|
+
export interface FinanceBalanceCard {
|
|
22
|
+
/** Pre-formatted net balance (e.g. "$2,765.50"). */
|
|
23
|
+
net: string;
|
|
24
|
+
/** True when the net balance is below zero (drives tone, no math here). */
|
|
25
|
+
negative: boolean;
|
|
26
|
+
/** Pre-formatted money in over the window (e.g. "$4,000.00"). */
|
|
27
|
+
income: string;
|
|
28
|
+
/** Pre-formatted money out over the window (e.g. "$1,234.50"). */
|
|
29
|
+
outflow: string;
|
|
30
|
+
/** Pre-formatted "as of" date label, or empty. */
|
|
31
|
+
asOf: string;
|
|
32
|
+
}
|
|
33
|
+
/** One transaction row, already projected to display strings by the wrapper. */
|
|
34
|
+
export interface FinanceTransactionCard {
|
|
35
|
+
id: string;
|
|
36
|
+
description: string;
|
|
37
|
+
/** Pre-formatted secondary line (date + optional category). */
|
|
38
|
+
meta: string;
|
|
39
|
+
/** Pre-formatted signed amount (e.g. "-$42.50"). */
|
|
40
|
+
amount: string;
|
|
41
|
+
/** True when the amount is an outflow (drives tone, no math here). */
|
|
42
|
+
outflow: boolean;
|
|
43
|
+
}
|
|
44
|
+
/** One recurring-charge row, already projected to display strings. */
|
|
45
|
+
export interface FinanceRecurringCard {
|
|
46
|
+
id: string;
|
|
47
|
+
label: string;
|
|
48
|
+
/** Pre-formatted secondary line (cadence + next-charge date). */
|
|
49
|
+
meta: string;
|
|
50
|
+
/** Pre-formatted amount (e.g. "$15.99"). */
|
|
51
|
+
amount: string;
|
|
52
|
+
}
|
|
53
|
+
export interface FinancesSnapshot {
|
|
54
|
+
/** The dashboard state machine. */
|
|
55
|
+
state: FinancesViewState;
|
|
56
|
+
/** Balance summary (only meaningful when state === "ready"). */
|
|
57
|
+
balance: FinanceBalanceCard;
|
|
58
|
+
/** Recent transactions (only meaningful when state === "ready"). */
|
|
59
|
+
transactions: FinanceTransactionCard[];
|
|
60
|
+
/** Recurring charges (only meaningful when state === "ready"). */
|
|
61
|
+
recurring: FinanceRecurringCard[];
|
|
62
|
+
/** One quiet proactive line, or empty when there is no genuine signal. */
|
|
63
|
+
note: string;
|
|
64
|
+
/** Error message when state === "error". */
|
|
65
|
+
error?: string;
|
|
66
|
+
}
|
|
67
|
+
export declare const EMPTY_FINANCES_SNAPSHOT: FinancesSnapshot;
|
|
68
|
+
export interface FinancesSpatialViewProps {
|
|
69
|
+
snapshot: FinancesSnapshot;
|
|
70
|
+
/**
|
|
71
|
+
* Dispatch by agent id:
|
|
72
|
+
* `retry` reload after an error,
|
|
73
|
+
* `connect` route a connect-a-source request to chat,
|
|
74
|
+
* `txn-<id>` open a transaction,
|
|
75
|
+
* `bill-<id>` open a recurring charge.
|
|
76
|
+
*/
|
|
77
|
+
onAction?: (action: string) => void;
|
|
78
|
+
}
|
|
79
|
+
export declare function FinancesSpatialView({ snapshot, onAction, }: FinancesSpatialViewProps): import("react/jsx-runtime").JSX.Element;
|
|
80
|
+
//# sourceMappingURL=FinancesSpatialView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FinancesSpatialView.d.ts","sourceRoot":"","sources":["../../../src/components/finances/FinancesSpatialView.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,8CAA8C;AAC9C,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAExE,kFAAkF;AAClF,MAAM,WAAW,kBAA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