@opentabs-dev/opentabs-plugin-ynab 0.0.74

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.
Files changed (77) hide show
  1. package/README.md +159 -0
  2. package/dist/adapter.iife.js +15312 -0
  3. package/dist/adapter.iife.js.map +7 -0
  4. package/dist/index.d.ts +14 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +62 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/tools/create-transaction.d.ts +46 -0
  9. package/dist/tools/create-transaction.d.ts.map +1 -0
  10. package/dist/tools/create-transaction.js +57 -0
  11. package/dist/tools/create-transaction.js.map +1 -0
  12. package/dist/tools/delete-transaction.d.ts +8 -0
  13. package/dist/tools/delete-transaction.d.ts.map +1 -0
  14. package/dist/tools/delete-transaction.js +32 -0
  15. package/dist/tools/delete-transaction.js.map +1 -0
  16. package/dist/tools/get-account.d.ts +18 -0
  17. package/dist/tools/get-account.d.ts.map +1 -0
  18. package/dist/tools/get-account.js +34 -0
  19. package/dist/tools/get-account.js.map +1 -0
  20. package/dist/tools/get-current-user.d.ts +9 -0
  21. package/dist/tools/get-current-user.d.ts.map +1 -0
  22. package/dist/tools/get-current-user.js +19 -0
  23. package/dist/tools/get-current-user.js.map +1 -0
  24. package/dist/tools/get-month.d.ts +33 -0
  25. package/dist/tools/get-month.d.ts.map +1 -0
  26. package/dist/tools/get-month.js +70 -0
  27. package/dist/tools/get-month.js.map +1 -0
  28. package/dist/tools/get-plan.d.ts +12 -0
  29. package/dist/tools/get-plan.d.ts.map +1 -0
  30. package/dist/tools/get-plan.js +22 -0
  31. package/dist/tools/get-plan.js.map +1 -0
  32. package/dist/tools/get-transaction.d.ts +39 -0
  33. package/dist/tools/get-transaction.d.ts.map +1 -0
  34. package/dist/tools/get-transaction.js +43 -0
  35. package/dist/tools/get-transaction.js.map +1 -0
  36. package/dist/tools/list-accounts.d.ts +18 -0
  37. package/dist/tools/list-accounts.d.ts.map +1 -0
  38. package/dist/tools/list-accounts.js +34 -0
  39. package/dist/tools/list-accounts.js.map +1 -0
  40. package/dist/tools/list-categories.d.ts +26 -0
  41. package/dist/tools/list-categories.d.ts.map +1 -0
  42. package/dist/tools/list-categories.js +62 -0
  43. package/dist/tools/list-categories.js.map +1 -0
  44. package/dist/tools/list-months.d.ts +16 -0
  45. package/dist/tools/list-months.d.ts.map +1 -0
  46. package/dist/tools/list-months.js +43 -0
  47. package/dist/tools/list-months.js.map +1 -0
  48. package/dist/tools/list-payees.d.ts +9 -0
  49. package/dist/tools/list-payees.d.ts.map +1 -0
  50. package/dist/tools/list-payees.js +29 -0
  51. package/dist/tools/list-payees.js.map +1 -0
  52. package/dist/tools/list-scheduled-transactions.d.ts +21 -0
  53. package/dist/tools/list-scheduled-transactions.d.ts.map +1 -0
  54. package/dist/tools/list-scheduled-transactions.js +32 -0
  55. package/dist/tools/list-scheduled-transactions.js.map +1 -0
  56. package/dist/tools/list-transactions.d.ts +27 -0
  57. package/dist/tools/list-transactions.d.ts.map +1 -0
  58. package/dist/tools/list-transactions.js +44 -0
  59. package/dist/tools/list-transactions.js.map +1 -0
  60. package/dist/tools/schemas.d.ts +347 -0
  61. package/dist/tools/schemas.d.ts.map +1 -0
  62. package/dist/tools/schemas.js +266 -0
  63. package/dist/tools/schemas.js.map +1 -0
  64. package/dist/tools/update-category-budget.d.ts +23 -0
  65. package/dist/tools/update-category-budget.d.ts.map +1 -0
  66. package/dist/tools/update-category-budget.js +50 -0
  67. package/dist/tools/update-category-budget.js.map +1 -0
  68. package/dist/tools/update-transaction.d.ts +47 -0
  69. package/dist/tools/update-transaction.d.ts.map +1 -0
  70. package/dist/tools/update-transaction.js +62 -0
  71. package/dist/tools/update-transaction.js.map +1 -0
  72. package/dist/tools.json +1684 -0
  73. package/dist/ynab-api.d.ts +19 -0
  74. package/dist/ynab-api.d.ts.map +1 -0
  75. package/dist/ynab-api.js +168 -0
  76. package/dist/ynab-api.js.map +1 -0
  77. package/package.json +55 -0
@@ -0,0 +1,14 @@
1
+ import { OpenTabsPlugin } from '@opentabs-dev/plugin-sdk';
2
+ import type { ToolDefinition } from '@opentabs-dev/plugin-sdk';
3
+ declare class YnabPlugin extends OpenTabsPlugin {
4
+ readonly name = "ynab";
5
+ readonly description = "OpenTabs plugin for YNAB (You Need A Budget)";
6
+ readonly displayName = "YNAB";
7
+ readonly urlPatterns: string[];
8
+ readonly homepage = "https://app.ynab.com";
9
+ readonly tools: ToolDefinition[];
10
+ isReady(): Promise<boolean>;
11
+ }
12
+ declare const _default: YnabPlugin;
13
+ export default _default;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAgC/D,cAAM,UAAW,SAAQ,cAAc;IACrC,QAAQ,CAAC,IAAI,UAAU;IACvB,QAAQ,CAAC,WAAW,kDAAkD;IACtE,SAAkB,WAAW,UAAU;IACvC,QAAQ,CAAC,WAAW,WAA0B;IAC9C,SAAkB,QAAQ,0BAA0B;IACpD,QAAQ,CAAC,KAAK,EAAE,cAAc,EAAE,CAuB9B;IAEI,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;CAIlC;;AAED,wBAAgC"}
package/dist/index.js ADDED
@@ -0,0 +1,62 @@
1
+ import { OpenTabsPlugin } from '@opentabs-dev/plugin-sdk';
2
+ import { isAuthenticated, waitForAuth } from './ynab-api.js';
3
+ // Account
4
+ import { getCurrentUser } from './tools/get-current-user.js';
5
+ // Plans
6
+ import { getPlan } from './tools/get-plan.js';
7
+ // Accounts
8
+ import { listAccounts } from './tools/list-accounts.js';
9
+ import { getAccount } from './tools/get-account.js';
10
+ // Categories
11
+ import { listCategories } from './tools/list-categories.js';
12
+ import { updateCategoryBudget } from './tools/update-category-budget.js';
13
+ // Payees
14
+ import { listPayees } from './tools/list-payees.js';
15
+ // Transactions
16
+ import { listTransactions } from './tools/list-transactions.js';
17
+ import { getTransaction } from './tools/get-transaction.js';
18
+ import { createTransaction } from './tools/create-transaction.js';
19
+ import { updateTransaction } from './tools/update-transaction.js';
20
+ import { deleteTransaction } from './tools/delete-transaction.js';
21
+ import { listScheduledTransactions } from './tools/list-scheduled-transactions.js';
22
+ // Months
23
+ import { listMonths } from './tools/list-months.js';
24
+ import { getMonth } from './tools/get-month.js';
25
+ class YnabPlugin extends OpenTabsPlugin {
26
+ name = 'ynab';
27
+ description = 'OpenTabs plugin for YNAB (You Need A Budget)';
28
+ displayName = 'YNAB';
29
+ urlPatterns = ['*://app.ynab.com/*'];
30
+ homepage = 'https://app.ynab.com';
31
+ tools = [
32
+ // Account
33
+ getCurrentUser,
34
+ // Plans
35
+ getPlan,
36
+ // Accounts
37
+ listAccounts,
38
+ getAccount,
39
+ // Categories
40
+ listCategories,
41
+ updateCategoryBudget,
42
+ // Payees
43
+ listPayees,
44
+ // Transactions
45
+ listTransactions,
46
+ getTransaction,
47
+ createTransaction,
48
+ updateTransaction,
49
+ deleteTransaction,
50
+ listScheduledTransactions,
51
+ // Months
52
+ listMonths,
53
+ getMonth,
54
+ ];
55
+ async isReady() {
56
+ if (isAuthenticated())
57
+ return true;
58
+ return waitForAuth();
59
+ }
60
+ }
61
+ export default new YnabPlugin();
62
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE7D,UAAU;AACV,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,QAAQ;AACR,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,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EF,KAAK,CAAC,OAAO;QACX,IAAI,eAAe,EAAE;YAAE,OAAO,IAAI,CAAC;QACnC,OAAO,WAAW,EAAE,CAAC;IACvB,CAAC;CACF;AAED,eAAe,IAAI,UAAU,EAAE,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { z } from 'zod';
2
+ export declare const createTransaction: import("@opentabs-dev/plugin-sdk").ToolDefinition<z.ZodObject<{
3
+ account_id: z.ZodString;
4
+ date: z.ZodString;
5
+ amount: z.ZodNumber;
6
+ payee_name: z.ZodOptional<z.ZodString>;
7
+ payee_id: z.ZodOptional<z.ZodString>;
8
+ category_id: z.ZodOptional<z.ZodString>;
9
+ memo: z.ZodOptional<z.ZodString>;
10
+ cleared: z.ZodOptional<z.ZodEnum<{
11
+ cleared: "cleared";
12
+ uncleared: "uncleared";
13
+ reconciled: "reconciled";
14
+ }>>;
15
+ approved: z.ZodOptional<z.ZodBoolean>;
16
+ flag_color: z.ZodOptional<z.ZodEnum<{
17
+ red: "red";
18
+ orange: "orange";
19
+ yellow: "yellow";
20
+ green: "green";
21
+ blue: "blue";
22
+ purple: "purple";
23
+ }>>;
24
+ }, z.core.$strip>, z.ZodObject<{
25
+ transaction: z.ZodObject<{
26
+ id: z.ZodString;
27
+ date: z.ZodString;
28
+ amount: z.ZodString;
29
+ amount_milliunits: z.ZodNumber;
30
+ memo: z.ZodString;
31
+ cleared: z.ZodString;
32
+ approved: z.ZodBoolean;
33
+ flag_color: z.ZodString;
34
+ flag_name: z.ZodString;
35
+ account_id: z.ZodString;
36
+ account_name: z.ZodString;
37
+ payee_id: z.ZodString;
38
+ payee_name: z.ZodString;
39
+ category_id: z.ZodString;
40
+ category_name: z.ZodString;
41
+ transfer_account_id: z.ZodString;
42
+ import_id: z.ZodString;
43
+ deleted: z.ZodBoolean;
44
+ }, z.core.$strip>;
45
+ }, z.core.$strip>>;
46
+ //# sourceMappingURL=create-transaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-transaction.d.ts","sourceRoot":"","sources":["../../src/tools/create-transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA0D5B,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { defineTool, ToolError } from '@opentabs-dev/plugin-sdk';
2
+ import { z } from 'zod';
3
+ import { getPlanId, syncWrite } from '../ynab-api.js';
4
+ import { mapTransaction, transactionSchema } from './schemas.js';
5
+ export const createTransaction = defineTool({
6
+ name: 'create_transaction',
7
+ displayName: 'Create Transaction',
8
+ description: 'Create a new transaction in the active YNAB plan. Amount is in currency units (e.g. -42.50 for a $42.50 expense, 1500 for $1500 income). Negative amounts are outflows (expenses), positive amounts are inflows (income).',
9
+ summary: 'Create a new transaction',
10
+ icon: 'plus',
11
+ group: 'Transactions',
12
+ input: z.object({
13
+ account_id: z.string().min(1).describe('Account ID to create the transaction in'),
14
+ date: z.string().min(1).describe('Transaction date in YYYY-MM-DD format'),
15
+ amount: z
16
+ .number()
17
+ .describe('Amount in currency units (negative for expenses, positive for income). E.g. -42.50 for a $42.50 expense.'),
18
+ payee_name: z.string().optional().describe('Payee name (creates new payee if not found)'),
19
+ payee_id: z.string().optional().describe('Existing payee ID (takes precedence over payee_name)'),
20
+ category_id: z.string().optional().describe('Category ID to assign'),
21
+ memo: z.string().optional().describe('Transaction memo'),
22
+ cleared: z.enum(['cleared', 'uncleared', 'reconciled']).optional().describe('Cleared status (default uncleared)'),
23
+ approved: z.boolean().optional().describe('Whether the transaction is approved (default true)'),
24
+ flag_color: z.enum(['red', 'orange', 'yellow', 'green', 'blue', 'purple']).optional().describe('Flag color'),
25
+ }),
26
+ output: z.object({
27
+ transaction: transactionSchema,
28
+ }),
29
+ handle: async (params) => {
30
+ const planId = getPlanId();
31
+ const milliunits = Math.round(params.amount * 1000);
32
+ const txId = crypto.randomUUID();
33
+ const transaction = {
34
+ id: txId,
35
+ entities_account_id: params.account_id,
36
+ date: params.date,
37
+ amount: milliunits,
38
+ cleared: params.cleared ?? 'uncleared',
39
+ approved: params.approved ?? true,
40
+ memo: params.memo ?? null,
41
+ flag_color: params.flag_color ?? null,
42
+ entities_payee_id: params.payee_id ?? null,
43
+ payee_name: params.payee_name ?? null,
44
+ entities_subcategory_id: params.category_id ?? null,
45
+ is_tombstone: false,
46
+ };
47
+ const result = await syncWrite(planId, {
48
+ be_transactions: [transaction],
49
+ });
50
+ const saved = result.changed_entities?.be_transactions?.[0];
51
+ if (!saved) {
52
+ throw ToolError.internal('Transaction was created but no data was returned');
53
+ }
54
+ return { transaction: mapTransaction(saved) };
55
+ },
56
+ });
57
+ //# sourceMappingURL=create-transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-transaction.js","sourceRoot":"","sources":["../../src/tools/create-transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAQjE,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC;IAC1C,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,oBAAoB;IACjC,WAAW,EACT,2NAA2N;IAC7N,OAAO,EAAE,0BAA0B;IACnC,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,cAAc;IACrB,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,yCAAyC,CAAC;QACjF,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC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AAC;QAEjC,MAAM,WAAW,GAA4B;YAC3C,EAAE,EAAE,IAAI;YACR,mBAAmB,EAAE,MAAM,CAAC,UAAU;YACtC,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,WAAW;YACtC,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,IAAI;YACjC,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,IAAI;YACzB,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,IAAI;YACrC,iBAAiB,EAAE,MAAM,CAAC,QAAQ,IAAI,IAAI;YAC1C,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,IAAI;YACrC,uBAAuB,EAAE,MAAM,CAAC,WAAW,IAAI,IAAI;YACnD,YAAY,EAAE,KAAK;SACpB,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,MAAM,EAAE;YACrC,eAAe,EAAE,CAAC,WAAW,CAAC;SAC/B,CAAC,CAAC;QAEH,MAAM,KAAK,GAAI,MAAkC,CAAC,gBAAgB,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,CAAC;QACzF,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,SAAS,CAAC,QAAQ,CAAC,kDAAkD,CAAC,CAAC;QAC/E,CAAC;QAED,OAAO,EAAE,WAAW,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;IAChD,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod';
2
+ export declare const deleteTransaction: import("@opentabs-dev/plugin-sdk").ToolDefinition<z.ZodObject<{
3
+ transaction_id: z.ZodString;
4
+ account_id: z.ZodString;
5
+ }, z.core.$strip>, z.ZodObject<{
6
+ success: z.ZodBoolean;
7
+ }, z.core.$strip>>;
8
+ //# sourceMappingURL=delete-transaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete-transaction.d.ts","sourceRoot":"","sources":["../../src/tools/delete-transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,iBAAiB;;;;;kBA6B5B,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { defineTool } from '@opentabs-dev/plugin-sdk';
2
+ import { z } from 'zod';
3
+ import { getPlanId, syncWrite } from '../ynab-api.js';
4
+ export const deleteTransaction = defineTool({
5
+ name: 'delete_transaction',
6
+ displayName: 'Delete Transaction',
7
+ description: 'Delete a transaction from the active YNAB plan. This marks the transaction as deleted (soft delete).',
8
+ summary: 'Delete a transaction',
9
+ icon: 'trash-2',
10
+ group: 'Transactions',
11
+ input: z.object({
12
+ transaction_id: z.string().min(1).describe('Transaction ID to delete'),
13
+ account_id: z.string().min(1).describe('Account ID the transaction belongs to'),
14
+ }),
15
+ output: z.object({
16
+ success: z.boolean().describe('Whether the operation succeeded'),
17
+ }),
18
+ handle: async (params) => {
19
+ const planId = getPlanId();
20
+ await syncWrite(planId, {
21
+ be_transactions: [
22
+ {
23
+ id: params.transaction_id,
24
+ entities_account_id: params.account_id,
25
+ is_tombstone: true,
26
+ },
27
+ ],
28
+ });
29
+ return { success: true };
30
+ },
31
+ });
32
+ //# sourceMappingURL=delete-transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete-transaction.js","sourceRoot":"","sources":["../../src/tools/delete-transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC;IAC1C,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,oBAAoB;IACjC,WAAW,EAAE,sGAAsG;IACnH,OAAO,EAAE,sBAAsB;IAC/B,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,cAAc;IACrB,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,0BAA0B,CAAC;QACtE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,uCAAuC,CAAC;KAChF,CAAC;IACF,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;KACjE,CAAC;IACF,MAAM,EAAE,KAAK,EAAC,MAAM,EAAC,EAAE;QACrB,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAE3B,MAAM,SAAS,CAAC,MAAM,EAAE;YACtB,eAAe,EAAE;gBACf;oBACE,EAAE,EAAE,MAAM,CAAC,cAAc;oBACzB,mBAAmB,EAAE,MAAM,CAAC,UAAU;oBACtC,YAAY,EAAE,IAAI;iBACnB;aACF;SACF,CAAC,CAAC;QAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ export declare const getAccount: import("@opentabs-dev/plugin-sdk").ToolDefinition<z.ZodObject<{
3
+ account_id: z.ZodString;
4
+ }, z.core.$strip>, z.ZodObject<{
5
+ account: z.ZodObject<{
6
+ id: z.ZodString;
7
+ name: z.ZodString;
8
+ type: z.ZodString;
9
+ on_budget: z.ZodBoolean;
10
+ closed: z.ZodBoolean;
11
+ balance: z.ZodString;
12
+ balance_milliunits: z.ZodNumber;
13
+ cleared_balance: z.ZodString;
14
+ uncleared_balance: z.ZodString;
15
+ note: z.ZodString;
16
+ }, z.core.$strip>;
17
+ }, z.core.$strip>>;
18
+ //# sourceMappingURL=get-account.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-account.d.ts","sourceRoot":"","sources":["../../src/tools/get-account.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;kBAgCrB,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { defineTool, ToolError } from '@opentabs-dev/plugin-sdk';
2
+ import { z } from 'zod';
3
+ import { catalog, getPlanId } from '../ynab-api.js';
4
+ import { accountSchema, mapAccount } from './schemas.js';
5
+ export const getAccount = defineTool({
6
+ name: 'get_account',
7
+ displayName: 'Get Account',
8
+ description: 'Get details for a specific account in the active YNAB plan by its ID. Returns name, type, balances, and on-budget status.',
9
+ summary: 'Get account details by ID',
10
+ icon: 'landmark',
11
+ group: 'Accounts',
12
+ input: z.object({
13
+ account_id: z.string().min(1).describe('Account ID to retrieve'),
14
+ }),
15
+ output: z.object({
16
+ account: accountSchema,
17
+ }),
18
+ handle: async (params) => {
19
+ const planId = getPlanId();
20
+ const result = await catalog('syncBudgetData', {
21
+ budget_version_id: planId,
22
+ starting_device_knowledge: 0,
23
+ ending_device_knowledge: 0,
24
+ device_knowledge_of_server: 0,
25
+ });
26
+ const raw = result.changed_entities?.be_accounts ?? [];
27
+ const account = raw.find(a => a.id === params.account_id && !a.is_tombstone);
28
+ if (!account) {
29
+ throw ToolError.notFound(`Account not found: ${params.account_id}`);
30
+ }
31
+ return { account: mapAccount(account) };
32
+ },
33
+ });
34
+ //# sourceMappingURL=get-account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-account.js","sourceRoot":"","sources":["../../src/tools/get-account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEpD,O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1,9 @@
1
+ import { z } from 'zod';
2
+ export declare const getCurrentUser: import("@opentabs-dev/plugin-sdk").ToolDefinition<z.ZodObject<{}, z.core.$strip>, z.ZodObject<{
3
+ user: z.ZodObject<{
4
+ id: z.ZodString;
5
+ first_name: z.ZodString;
6
+ email: z.ZodString;
7
+ }, z.core.$strip>;
8
+ }, z.core.$strip>>;
9
+ //# sourceMappingURL=get-current-user.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-current-user.d.ts","sourceRoot":"","sources":["../../src/tools/get-current-user.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,cAAc;;;;;;kBAazB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { defineTool } from '@opentabs-dev/plugin-sdk';
2
+ import { z } from 'zod';
3
+ import { api } from '../ynab-api.js';
4
+ import { mapUser, userSchema } from './schemas.js';
5
+ export const getCurrentUser = defineTool({
6
+ name: 'get_current_user',
7
+ displayName: 'Get Current User',
8
+ description: 'Get the profile of the currently authenticated YNAB user including name and email.',
9
+ summary: 'Get your YNAB user profile',
10
+ icon: 'user',
11
+ group: 'Account',
12
+ input: z.object({}),
13
+ output: z.object({ user: userSchema }),
14
+ handle: async () => {
15
+ const data = await api('/user');
16
+ return { user: mapUser(data) };
17
+ },
18
+ });
19
+ //# sourceMappingURL=get-current-user.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-current-user.js","sourceRoot":"","sources":["../../src/tools/get-current-user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;IACvC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EAAE,oFAAoF;IACjG,OAAO,EAAE,4BAA4B;IACrC,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACnB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IACtC,MAAM,EAAE,KAAK,IAAI,EAAE;QACjB,MAAM,IAAI,GAAG,MAAM,GAAG,CAAU,OAAO,CAAC,CAAC;QACzC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;IACjC,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { z } from 'zod';
2
+ export declare const getMonth: import("@opentabs-dev/plugin-sdk").ToolDefinition<z.ZodObject<{
3
+ month: z.ZodString;
4
+ }, z.core.$strip>, z.ZodObject<{
5
+ month: z.ZodObject<{
6
+ month: z.ZodString;
7
+ income: z.ZodString;
8
+ budgeted: z.ZodString;
9
+ activity: z.ZodString;
10
+ to_be_budgeted: z.ZodString;
11
+ income_milliunits: z.ZodNumber;
12
+ budgeted_milliunits: z.ZodNumber;
13
+ activity_milliunits: z.ZodNumber;
14
+ to_be_budgeted_milliunits: z.ZodNumber;
15
+ age_of_money: z.ZodNumber;
16
+ }, z.core.$strip>;
17
+ categories: z.ZodArray<z.ZodObject<{
18
+ id: z.ZodString;
19
+ category_group_id: z.ZodString;
20
+ name: z.ZodString;
21
+ hidden: z.ZodBoolean;
22
+ budgeted: z.ZodString;
23
+ activity: z.ZodString;
24
+ balance: z.ZodString;
25
+ budgeted_milliunits: z.ZodNumber;
26
+ activity_milliunits: z.ZodNumber;
27
+ balance_milliunits: z.ZodNumber;
28
+ goal_type: z.ZodString;
29
+ goal_target: z.ZodString;
30
+ goal_percentage_complete: z.ZodNumber;
31
+ }, z.core.$strip>>;
32
+ }, z.core.$strip>>;
33
+ //# sourceMappingURL=get-month.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-month.d.ts","sourceRoot":"","sources":["../../src/tools/get-month.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAyEnB,CAAC"}
@@ -0,0 +1,70 @@
1
+ import { defineTool, ToolError } from '@opentabs-dev/plugin-sdk';
2
+ import { z } from 'zod';
3
+ import { catalog, getPlanId } from '../ynab-api.js';
4
+ import { categorySchema, mapCategory, mapMonth, monthSchema } from './schemas.js';
5
+ export const getMonth = defineTool({
6
+ name: 'get_month',
7
+ displayName: 'Get Month',
8
+ description: 'Get budget summary and category details for a specific month. Returns the month overview (income, budgeted, activity, Ready to Assign) plus per-category breakdowns. Month format is YYYY-MM-DD using the first of the month (e.g. 2026-03-01).',
9
+ summary: 'Get budget details for a month',
10
+ icon: 'calendar',
11
+ group: 'Months',
12
+ input: z.object({
13
+ month: z.string().min(1).describe('Month in YYYY-MM-DD format (first of month, e.g. 2026-03-01)'),
14
+ }),
15
+ output: z.object({
16
+ month: monthSchema,
17
+ categories: z.array(categorySchema).describe('Category budgets for this month'),
18
+ }),
19
+ handle: async (params) => {
20
+ const planId = getPlanId();
21
+ const result = await catalog('syncBudgetData', {
22
+ budget_version_id: planId,
23
+ starting_device_knowledge: 0,
24
+ ending_device_knowledge: 0,
25
+ device_knowledge_of_server: 0,
26
+ });
27
+ const entities = result.changed_entities;
28
+ const rawMonths = entities?.be_monthly_budgets ?? [];
29
+ const monthData = rawMonths.find(m => m.month === params.month && !m.is_tombstone);
30
+ if (!monthData) {
31
+ throw ToolError.notFound(`Month not found: ${params.month}`);
32
+ }
33
+ // Find the matching monthly budget calculation for aggregates
34
+ const monthlyCalcs = entities?.be_monthly_budget_calculations ?? [];
35
+ const monthCalc = monthlyCalcs.find(c => {
36
+ const budgetId = c.entities_monthly_budget_id;
37
+ return budgetId && budgetId.replace('mb/', '') === params.month;
38
+ });
39
+ const rawCategories = (entities?.be_subcategories ?? []).filter(c => !c.is_tombstone && c.is_hidden !== true);
40
+ // Map subcategory budget calculations by category ID
41
+ // entity_id format: mcbc/YYYY-MM/category-id
42
+ const subcatCalcs = entities?.be_monthly_subcategory_budget_calculations ?? [];
43
+ const calcMap = new Map();
44
+ for (const calc of subcatCalcs) {
45
+ const entityId = calc.entities_monthly_subcategory_budget_id;
46
+ if (entityId) {
47
+ const parts = entityId.split('/');
48
+ const categoryId = parts.length >= 3 ? parts.slice(2).join('/') : entityId;
49
+ calcMap.set(categoryId, calc);
50
+ }
51
+ }
52
+ const categories = rawCategories.map(c => {
53
+ const calc = calcMap.get(c.id ?? '');
54
+ return mapCategory({
55
+ ...c,
56
+ budgeted: calc?.budgeted ?? c.budgeted,
57
+ activity: calc?.activity ?? c.activity,
58
+ balance: calc?.balance ?? c.balance,
59
+ goal_type: calc?.goal_type ?? c.goal_type,
60
+ goal_target: calc?.goal_target ?? c.goal_target,
61
+ goal_percentage_complete: calc?.goal_percentage_complete ?? c.goal_percentage_complete,
62
+ });
63
+ });
64
+ return {
65
+ month: mapMonth(monthData, monthCalc),
66
+ categories,
67
+ };
68
+ },
69
+ });
70
+ //# sourceMappingURL=get-month.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-month.js","sourceRoot":"","sources":["../../src/tools/get-month.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AASlF,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC;IACjC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QAAQ,EAAE,IAAI,EAAE,QAAQ,IAAI,CAAC,CAAC,QAAQ;gBACtC,QAAQ,EAAE,IAAI,EAAE,QAAQ,IAAI,CAAC,CAAC,QAAQ;gBACtC,OAAO,EAAE,IAAI,EAAE,OAAO,IAAI,CAAC,CAAC,OAAO;gBACnC,SAAS,EAAE,IAAI,EAAE,SAAS,IAAI,CAAC,CAAC,SAAS;gBACzC,WAAW,EAAE,IAAI,EAAE,WAAW,IAAI,CAAC,CAAC,WAAW;gBAC/C,wBAAwB,EAAE,IAAI,EAAE,wBAAwB,IAAI,CAAC,CAAC,wBAAwB;aACvF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO;YACL,KAAK,EAAE,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;YACrC,UAAU;SACX,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { z } from 'zod';
2
+ export declare const getPlan: import("@opentabs-dev/plugin-sdk").ToolDefinition<z.ZodObject<{}, z.core.$strip>, z.ZodObject<{
3
+ plan: z.ZodObject<{
4
+ id: z.ZodString;
5
+ budget_id: z.ZodString;
6
+ name: z.ZodString;
7
+ date_format: z.ZodString;
8
+ currency_symbol: z.ZodString;
9
+ currency_iso_code: z.ZodString;
10
+ }, z.core.$strip>;
11
+ }, z.core.$strip>>;
12
+ //# sourceMappingURL=get-plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-plan.d.ts","sourceRoot":"","sources":["../../src/tools/get-plan.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,eAAO,MAAM,OAAO;;;;;;;;;kBAiBlB,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { defineTool } from '@opentabs-dev/plugin-sdk';
2
+ import { z } from 'zod';
3
+ import { catalog, getPlanId } from '../ynab-api.js';
4
+ import { mapPlan, planSchema } from './schemas.js';
5
+ export const getPlan = defineTool({
6
+ name: 'get_plan',
7
+ displayName: 'Get Plan',
8
+ description: 'Get details about the currently active YNAB plan (budget), including name, currency, and date format. The plan ID is extracted from the current URL.',
9
+ summary: 'Get the active plan details',
10
+ icon: 'wallet',
11
+ group: 'Plans',
12
+ input: z.object({}),
13
+ output: z.object({ plan: planSchema }),
14
+ handle: async () => {
15
+ const planId = getPlanId();
16
+ const result = await catalog('getInitialUserData', {
17
+ device_info: { id: planId, device_os: 'web' },
18
+ });
19
+ return { plan: mapPlan(result.budget_version) };
20
+ },
21
+ });
22
+ //# sourceMappingURL=get-plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-plan.js","sourceRoot":"","sources":["../../src/tools/get-plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAMnD,MAAM,CAAC,MAAM,OAAO,GAAG,UAAU,CAAC;IAChC,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,UAAU;IACvB,WAAW,EACT,sJAAsJ;IACxJ,OAAO,EAAE,6BAA6B;IACtC,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACnB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IACtC,MAAM,EAAE,KAAK,IAAI,EAAE;QACjB,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,MAAM,OAAO,CAAkB,oBAAoB,EAAE;YAClE,WAAW,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE;SAC9C,CAAC,CAAC;QACH,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,cAAyB,CAAC,EAAE,CAAC;IAC7D,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { z } from 'zod';
2
+ export declare const getTransaction: import("@opentabs-dev/plugin-sdk").ToolDefinition<z.ZodObject<{
3
+ transaction_id: z.ZodString;
4
+ }, z.core.$strip>, z.ZodObject<{
5
+ transaction: z.ZodObject<{
6
+ id: z.ZodString;
7
+ date: z.ZodString;
8
+ amount: z.ZodString;
9
+ amount_milliunits: z.ZodNumber;
10
+ memo: z.ZodString;
11
+ cleared: z.ZodString;
12
+ approved: z.ZodBoolean;
13
+ flag_color: z.ZodString;
14
+ flag_name: z.ZodString;
15
+ account_id: z.ZodString;
16
+ account_name: z.ZodString;
17
+ payee_id: z.ZodString;
18
+ payee_name: z.ZodString;
19
+ category_id: z.ZodString;
20
+ category_name: z.ZodString;
21
+ transfer_account_id: z.ZodString;
22
+ import_id: z.ZodString;
23
+ deleted: z.ZodBoolean;
24
+ }, z.core.$strip>;
25
+ subtransactions: z.ZodArray<z.ZodObject<{
26
+ id: z.ZodString;
27
+ transaction_id: z.ZodString;
28
+ amount: z.ZodString;
29
+ amount_milliunits: z.ZodNumber;
30
+ memo: z.ZodString;
31
+ payee_id: z.ZodString;
32
+ payee_name: z.ZodString;
33
+ category_id: z.ZodString;
34
+ category_name: z.ZodString;
35
+ transfer_account_id: z.ZodString;
36
+ deleted: z.ZodBoolean;
37
+ }, z.core.$strip>>;
38
+ }, z.core.$strip>>;
39
+ //# sourceMappingURL=get-transaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-transaction.d.ts","sourceRoot":"","sources":["../../src/tools/get-transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA0CzB,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { defineTool, ToolError } from '@opentabs-dev/plugin-sdk';
2
+ import { z } from 'zod';
3
+ import { catalog, getPlanId } from '../ynab-api.js';
4
+ import { mapSubtransaction, mapTransaction, subtransactionSchema, transactionSchema } from './schemas.js';
5
+ export const getTransaction = defineTool({
6
+ name: 'get_transaction',
7
+ displayName: 'Get Transaction',
8
+ description: 'Get details for a specific transaction by its ID. Returns full transaction data including any split subtransactions.',
9
+ summary: 'Get transaction details by ID',
10
+ icon: 'receipt',
11
+ group: 'Transactions',
12
+ input: z.object({
13
+ transaction_id: z.string().min(1).describe('Transaction ID to retrieve'),
14
+ }),
15
+ output: z.object({
16
+ transaction: transactionSchema,
17
+ subtransactions: z.array(subtransactionSchema).describe('Split subtransactions (empty if not a split)'),
18
+ }),
19
+ handle: async (params) => {
20
+ const planId = getPlanId();
21
+ const result = await catalog('syncBudgetData', {
22
+ budget_version_id: planId,
23
+ starting_device_knowledge: 0,
24
+ ending_device_knowledge: 0,
25
+ device_knowledge_of_server: 0,
26
+ });
27
+ const entities = result.changed_entities;
28
+ const raw = entities?.be_transactions ?? [];
29
+ const tx = raw.find(t => t.id === params.transaction_id && !t.is_tombstone);
30
+ if (!tx) {
31
+ throw ToolError.notFound(`Transaction not found: ${params.transaction_id}`);
32
+ }
33
+ const allSubs = entities?.be_subtransactions ?? [];
34
+ const subtransactions = allSubs
35
+ .filter(s => s.entities_transaction_id === params.transaction_id && !s.is_tombstone)
36
+ .map(mapSubtransaction);
37
+ return {
38
+ transaction: mapTransaction(tx),
39
+ subtransactions,
40
+ };
41
+ },
42
+ });
43
+ //# sourceMappingURL=get-transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-transaction.js","sourceRoot":"","sources":["../../src/tools/get-transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAA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AAI,CAAC,EAAE,EAAE,CAAC;YACR,MAAM,SAAS,CAAC,QAAQ,CAAC,0BAA0B,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;QAC9E,CAAC;QAED,MAAM,OAAO,GAAG,QAAQ,EAAE,kBAAkB,IAAI,EAAE,CAAC;QACnD,MAAM,eAAe,GAAG,OAAO;aAC5B,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,uBAAuB,KAAK,MAAM,CAAC,cAAc,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC;aACnF,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAE1B,OAAO;YACL,WAAW,EAAE,cAAc,CAAC,EAAE,CAAC;YAC/B,eAAe;SAChB,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ export declare const listAccounts: import("@opentabs-dev/plugin-sdk").ToolDefinition<z.ZodObject<{
3
+ include_closed: z.ZodOptional<z.ZodBoolean>;
4
+ }, z.core.$strip>, z.ZodObject<{
5
+ accounts: z.ZodArray<z.ZodObject<{
6
+ id: z.ZodString;
7
+ name: z.ZodString;
8
+ type: z.ZodString;
9
+ on_budget: z.ZodBoolean;
10
+ closed: z.ZodBoolean;
11
+ balance: z.ZodString;
12
+ balance_milliunits: z.ZodNumber;
13
+ cleared_balance: z.ZodString;
14
+ uncleared_balance: z.ZodString;
15
+ note: z.ZodString;
16
+ }, z.core.$strip>>;
17
+ }, z.core.$strip>>;
18
+ //# sourceMappingURL=list-accounts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-accounts.d.ts","sourceRoot":"","sources":["../../src/tools/list-accounts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;kBAgCvB,CAAC"}