@sundaeswap/sprinkles 0.6.1 → 0.8.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/README.md +178 -181
- package/dist/cjs/Sprinkle/__tests__/action-integration.test.js +590 -0
- package/dist/cjs/Sprinkle/__tests__/action-integration.test.js.map +1 -0
- package/dist/cjs/Sprinkle/__tests__/action-registry.test.js +193 -0
- package/dist/cjs/Sprinkle/__tests__/action-registry.test.js.map +1 -0
- package/dist/cjs/Sprinkle/__tests__/action-runner.test.js +304 -0
- package/dist/cjs/Sprinkle/__tests__/action-runner.test.js.map +1 -0
- package/dist/cjs/Sprinkle/__tests__/builtin-actions.test.js +1110 -0
- package/dist/cjs/Sprinkle/__tests__/builtin-actions.test.js.map +1 -0
- package/dist/cjs/Sprinkle/__tests__/cli-adapter.test.js +744 -0
- package/dist/cjs/Sprinkle/__tests__/cli-adapter.test.js.map +1 -0
- package/dist/cjs/Sprinkle/__tests__/fill-in-struct.test.js +15 -1
- package/dist/cjs/Sprinkle/__tests__/fill-in-struct.test.js.map +1 -1
- package/dist/cjs/Sprinkle/__tests__/mcp-adapter.test.js +711 -0
- package/dist/cjs/Sprinkle/__tests__/mcp-adapter.test.js.map +1 -0
- package/dist/cjs/Sprinkle/__tests__/native-script.test.js +390 -0
- package/dist/cjs/Sprinkle/__tests__/native-script.test.js.map +1 -0
- package/dist/cjs/Sprinkle/__tests__/tui-helpers.test.js +334 -0
- package/dist/cjs/Sprinkle/__tests__/tui-helpers.test.js.map +1 -0
- package/dist/cjs/Sprinkle/__tests__/utility-actions.test.js +367 -0
- package/dist/cjs/Sprinkle/__tests__/utility-actions.test.js.map +1 -0
- package/dist/cjs/Sprinkle/__tests__/wallet-transaction-actions.test.js +749 -0
- package/dist/cjs/Sprinkle/__tests__/wallet-transaction-actions.test.js.map +1 -0
- package/dist/cjs/Sprinkle/actions/builtin/addressbook-actions.js +164 -0
- package/dist/cjs/Sprinkle/actions/builtin/addressbook-actions.js.map +1 -0
- package/dist/cjs/Sprinkle/actions/builtin/blaze-helper.js +61 -0
- package/dist/cjs/Sprinkle/actions/builtin/blaze-helper.js.map +1 -0
- package/dist/cjs/Sprinkle/actions/builtin/index.js +174 -0
- package/dist/cjs/Sprinkle/actions/builtin/index.js.map +1 -0
- package/dist/cjs/Sprinkle/actions/builtin/native-script.js +139 -0
- package/dist/cjs/Sprinkle/actions/builtin/native-script.js.map +1 -0
- package/dist/cjs/Sprinkle/actions/builtin/profile-actions.js +202 -0
- package/dist/cjs/Sprinkle/actions/builtin/profile-actions.js.map +1 -0
- package/dist/cjs/Sprinkle/actions/builtin/settings-actions.js +87 -0
- package/dist/cjs/Sprinkle/actions/builtin/settings-actions.js.map +1 -0
- package/dist/cjs/Sprinkle/actions/builtin/transaction-actions.js +345 -0
- package/dist/cjs/Sprinkle/actions/builtin/transaction-actions.js.map +1 -0
- package/dist/cjs/Sprinkle/actions/builtin/utility-actions.js +218 -0
- package/dist/cjs/Sprinkle/actions/builtin/utility-actions.js.map +1 -0
- package/dist/cjs/Sprinkle/actions/builtin/wallet-actions.js +212 -0
- package/dist/cjs/Sprinkle/actions/builtin/wallet-actions.js.map +1 -0
- package/dist/cjs/Sprinkle/actions/cli-adapter.js +390 -0
- package/dist/cjs/Sprinkle/actions/cli-adapter.js.map +1 -0
- package/dist/cjs/Sprinkle/actions/index.js +139 -0
- package/dist/cjs/Sprinkle/actions/index.js.map +1 -0
- package/dist/cjs/Sprinkle/actions/mcp-adapter.js +557 -0
- package/dist/cjs/Sprinkle/actions/mcp-adapter.js.map +1 -0
- package/dist/cjs/Sprinkle/actions/registry.js +92 -0
- package/dist/cjs/Sprinkle/actions/registry.js.map +1 -0
- package/dist/cjs/Sprinkle/actions/runner.js +190 -0
- package/dist/cjs/Sprinkle/actions/runner.js.map +1 -0
- package/dist/cjs/Sprinkle/actions/tui-helpers.js +96 -0
- package/dist/cjs/Sprinkle/actions/tui-helpers.js.map +1 -0
- package/dist/cjs/Sprinkle/actions/types.js +68 -0
- package/dist/cjs/Sprinkle/actions/types.js.map +1 -0
- package/dist/cjs/Sprinkle/index.js +678 -5
- package/dist/cjs/Sprinkle/index.js.map +1 -1
- package/dist/cjs/Sprinkle/prompts.js +12 -7
- package/dist/cjs/Sprinkle/prompts.js.map +1 -1
- package/dist/cjs/Sprinkle/schemas.js +17 -1
- package/dist/cjs/Sprinkle/schemas.js.map +1 -1
- package/dist/cjs/Sprinkle/type-guards.js +7 -1
- package/dist/cjs/Sprinkle/type-guards.js.map +1 -1
- package/dist/esm/Sprinkle/__tests__/action-integration.test.js +588 -0
- package/dist/esm/Sprinkle/__tests__/action-integration.test.js.map +1 -0
- package/dist/esm/Sprinkle/__tests__/action-registry.test.js +192 -0
- package/dist/esm/Sprinkle/__tests__/action-registry.test.js.map +1 -0
- package/dist/esm/Sprinkle/__tests__/action-runner.test.js +302 -0
- package/dist/esm/Sprinkle/__tests__/action-runner.test.js.map +1 -0
- package/dist/esm/Sprinkle/__tests__/builtin-actions.test.js +1107 -0
- package/dist/esm/Sprinkle/__tests__/builtin-actions.test.js.map +1 -0
- package/dist/esm/Sprinkle/__tests__/cli-adapter.test.js +742 -0
- package/dist/esm/Sprinkle/__tests__/cli-adapter.test.js.map +1 -0
- package/dist/esm/Sprinkle/__tests__/fill-in-struct.test.js +15 -1
- package/dist/esm/Sprinkle/__tests__/fill-in-struct.test.js.map +1 -1
- package/dist/esm/Sprinkle/__tests__/mcp-adapter.test.js +710 -0
- package/dist/esm/Sprinkle/__tests__/mcp-adapter.test.js.map +1 -0
- package/dist/esm/Sprinkle/__tests__/native-script.test.js +388 -0
- package/dist/esm/Sprinkle/__tests__/native-script.test.js.map +1 -0
- package/dist/esm/Sprinkle/__tests__/tui-helpers.test.js +332 -0
- package/dist/esm/Sprinkle/__tests__/tui-helpers.test.js.map +1 -0
- package/dist/esm/Sprinkle/__tests__/utility-actions.test.js +365 -0
- package/dist/esm/Sprinkle/__tests__/utility-actions.test.js.map +1 -0
- package/dist/esm/Sprinkle/__tests__/wallet-transaction-actions.test.js +747 -0
- package/dist/esm/Sprinkle/__tests__/wallet-transaction-actions.test.js.map +1 -0
- package/dist/esm/Sprinkle/actions/builtin/addressbook-actions.js +159 -0
- package/dist/esm/Sprinkle/actions/builtin/addressbook-actions.js.map +1 -0
- package/dist/esm/Sprinkle/actions/builtin/blaze-helper.js +55 -0
- package/dist/esm/Sprinkle/actions/builtin/blaze-helper.js.map +1 -0
- package/dist/esm/Sprinkle/actions/builtin/index.js +37 -0
- package/dist/esm/Sprinkle/actions/builtin/index.js.map +1 -0
- package/dist/esm/Sprinkle/actions/builtin/native-script.js +133 -0
- package/dist/esm/Sprinkle/actions/builtin/native-script.js.map +1 -0
- package/dist/esm/Sprinkle/actions/builtin/profile-actions.js +197 -0
- package/dist/esm/Sprinkle/actions/builtin/profile-actions.js.map +1 -0
- package/dist/esm/Sprinkle/actions/builtin/settings-actions.js +81 -0
- package/dist/esm/Sprinkle/actions/builtin/settings-actions.js.map +1 -0
- package/dist/esm/Sprinkle/actions/builtin/transaction-actions.js +340 -0
- package/dist/esm/Sprinkle/actions/builtin/transaction-actions.js.map +1 -0
- package/dist/esm/Sprinkle/actions/builtin/utility-actions.js +213 -0
- package/dist/esm/Sprinkle/actions/builtin/utility-actions.js.map +1 -0
- package/dist/esm/Sprinkle/actions/builtin/wallet-actions.js +207 -0
- package/dist/esm/Sprinkle/actions/builtin/wallet-actions.js.map +1 -0
- package/dist/esm/Sprinkle/actions/cli-adapter.js +379 -0
- package/dist/esm/Sprinkle/actions/cli-adapter.js.map +1 -0
- package/dist/esm/Sprinkle/actions/index.js +12 -0
- package/dist/esm/Sprinkle/actions/index.js.map +1 -0
- package/dist/esm/Sprinkle/actions/mcp-adapter.js +547 -0
- package/dist/esm/Sprinkle/actions/mcp-adapter.js.map +1 -0
- package/dist/esm/Sprinkle/actions/registry.js +85 -0
- package/dist/esm/Sprinkle/actions/registry.js.map +1 -0
- package/dist/esm/Sprinkle/actions/runner.js +182 -0
- package/dist/esm/Sprinkle/actions/runner.js.map +1 -0
- package/dist/esm/Sprinkle/actions/tui-helpers.js +91 -0
- package/dist/esm/Sprinkle/actions/tui-helpers.js.map +1 -0
- package/dist/esm/Sprinkle/actions/types.js +61 -0
- package/dist/esm/Sprinkle/actions/types.js.map +1 -0
- package/dist/esm/Sprinkle/index.js +517 -7
- package/dist/esm/Sprinkle/index.js.map +1 -1
- package/dist/esm/Sprinkle/prompts.js +12 -7
- package/dist/esm/Sprinkle/prompts.js.map +1 -1
- package/dist/esm/Sprinkle/schemas.js +16 -0
- package/dist/esm/Sprinkle/schemas.js.map +1 -1
- package/dist/esm/Sprinkle/type-guards.js +3 -0
- package/dist/esm/Sprinkle/type-guards.js.map +1 -1
- package/dist/types/Sprinkle/actions/builtin/addressbook-actions.d.ts +50 -0
- package/dist/types/Sprinkle/actions/builtin/addressbook-actions.d.ts.map +1 -0
- package/dist/types/Sprinkle/actions/builtin/blaze-helper.d.ts +39 -0
- package/dist/types/Sprinkle/actions/builtin/blaze-helper.d.ts.map +1 -0
- package/dist/types/Sprinkle/actions/builtin/index.d.ts +30 -0
- package/dist/types/Sprinkle/actions/builtin/index.d.ts.map +1 -0
- package/dist/types/Sprinkle/actions/builtin/native-script.d.ts +27 -0
- package/dist/types/Sprinkle/actions/builtin/native-script.d.ts.map +1 -0
- package/dist/types/Sprinkle/actions/builtin/profile-actions.d.ts +55 -0
- package/dist/types/Sprinkle/actions/builtin/profile-actions.d.ts.map +1 -0
- package/dist/types/Sprinkle/actions/builtin/settings-actions.d.ts +32 -0
- package/dist/types/Sprinkle/actions/builtin/settings-actions.d.ts.map +1 -0
- package/dist/types/Sprinkle/actions/builtin/transaction-actions.d.ts +70 -0
- package/dist/types/Sprinkle/actions/builtin/transaction-actions.d.ts.map +1 -0
- package/dist/types/Sprinkle/actions/builtin/utility-actions.d.ts +48 -0
- package/dist/types/Sprinkle/actions/builtin/utility-actions.d.ts.map +1 -0
- package/dist/types/Sprinkle/actions/builtin/wallet-actions.d.ts +50 -0
- package/dist/types/Sprinkle/actions/builtin/wallet-actions.d.ts.map +1 -0
- package/dist/types/Sprinkle/actions/cli-adapter.d.ts +104 -0
- package/dist/types/Sprinkle/actions/cli-adapter.d.ts.map +1 -0
- package/dist/types/Sprinkle/actions/index.d.ts +13 -0
- package/dist/types/Sprinkle/actions/index.d.ts.map +1 -0
- package/dist/types/Sprinkle/actions/mcp-adapter.d.ts +116 -0
- package/dist/types/Sprinkle/actions/mcp-adapter.d.ts.map +1 -0
- package/dist/types/Sprinkle/actions/registry.d.ts +42 -0
- package/dist/types/Sprinkle/actions/registry.d.ts.map +1 -0
- package/dist/types/Sprinkle/actions/runner.d.ts +45 -0
- package/dist/types/Sprinkle/actions/runner.d.ts.map +1 -0
- package/dist/types/Sprinkle/actions/tui-helpers.d.ts +53 -0
- package/dist/types/Sprinkle/actions/tui-helpers.d.ts.map +1 -0
- package/dist/types/Sprinkle/actions/types.d.ts +76 -0
- package/dist/types/Sprinkle/actions/types.d.ts.map +1 -0
- package/dist/types/Sprinkle/index.d.ts +84 -2
- package/dist/types/Sprinkle/index.d.ts.map +1 -1
- package/dist/types/Sprinkle/prompts.d.ts.map +1 -1
- package/dist/types/Sprinkle/schemas.d.ts +72 -0
- package/dist/types/Sprinkle/schemas.d.ts.map +1 -1
- package/dist/types/Sprinkle/type-guards.d.ts +4 -1
- package/dist/types/Sprinkle/type-guards.d.ts.map +1 -1
- package/dist/types/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +9 -2
- package/src/Sprinkle/__tests__/action-integration.test.ts +558 -0
- package/src/Sprinkle/__tests__/action-registry.test.ts +187 -0
- package/src/Sprinkle/__tests__/action-runner.test.ts +324 -0
- package/src/Sprinkle/__tests__/builtin-actions.test.ts +1022 -0
- package/src/Sprinkle/__tests__/cli-adapter.test.ts +736 -0
- package/src/Sprinkle/__tests__/fill-in-struct.test.ts +23 -1
- package/src/Sprinkle/__tests__/mcp-adapter.test.ts +720 -0
- package/src/Sprinkle/__tests__/native-script.test.ts +341 -0
- package/src/Sprinkle/__tests__/tui-helpers.test.ts +325 -0
- package/src/Sprinkle/__tests__/utility-actions.test.ts +348 -0
- package/src/Sprinkle/__tests__/wallet-transaction-actions.test.ts +695 -0
- package/src/Sprinkle/actions/builtin/addressbook-actions.ts +168 -0
- package/src/Sprinkle/actions/builtin/blaze-helper.ts +89 -0
- package/src/Sprinkle/actions/builtin/index.ts +125 -0
- package/src/Sprinkle/actions/builtin/native-script.ts +165 -0
- package/src/Sprinkle/actions/builtin/profile-actions.ts +229 -0
- package/src/Sprinkle/actions/builtin/settings-actions.ts +99 -0
- package/src/Sprinkle/actions/builtin/transaction-actions.ts +381 -0
- package/src/Sprinkle/actions/builtin/utility-actions.ts +285 -0
- package/src/Sprinkle/actions/builtin/wallet-actions.ts +233 -0
- package/src/Sprinkle/actions/cli-adapter.ts +446 -0
- package/src/Sprinkle/actions/index.ts +33 -0
- package/src/Sprinkle/actions/mcp-adapter.ts +638 -0
- package/src/Sprinkle/actions/registry.ts +97 -0
- package/src/Sprinkle/actions/runner.ts +200 -0
- package/src/Sprinkle/actions/tui-helpers.ts +114 -0
- package/src/Sprinkle/actions/types.ts +91 -0
- package/src/Sprinkle/index.ts +612 -3
- package/src/Sprinkle/prompts.ts +118 -72
- package/src/Sprinkle/schemas.ts +20 -0
- package/src/Sprinkle/type-guards.ts +9 -0
|
@@ -9,13 +9,18 @@ var _exportNames = {
|
|
|
9
9
|
NetworkSchema: true,
|
|
10
10
|
MultisigScriptModule: true,
|
|
11
11
|
MultisigScript: true,
|
|
12
|
+
NativeScriptInputSchema: true,
|
|
13
|
+
NativeScriptsParam: true,
|
|
12
14
|
ProviderSettingsSchema: true,
|
|
13
15
|
WalletSettingsSchema: true,
|
|
14
16
|
isOptional: true,
|
|
15
17
|
isImport: true,
|
|
16
18
|
isArray: true,
|
|
17
19
|
isBigInt: true,
|
|
20
|
+
isBoolean: true,
|
|
21
|
+
isInteger: true,
|
|
18
22
|
isLiteral: true,
|
|
23
|
+
isNumber: true,
|
|
19
24
|
isObject: true,
|
|
20
25
|
isRef: true,
|
|
21
26
|
isString: true,
|
|
@@ -30,8 +35,39 @@ var _exportNames = {
|
|
|
30
35
|
getDefault: true,
|
|
31
36
|
GetProvider: true,
|
|
32
37
|
GetWallet: true,
|
|
33
|
-
GetBlaze: true
|
|
38
|
+
GetBlaze: true,
|
|
39
|
+
ActionRegistry: true,
|
|
40
|
+
ActionError: true,
|
|
41
|
+
executeAction: true,
|
|
42
|
+
detectMode: true,
|
|
43
|
+
parseCliArgs: true,
|
|
44
|
+
generateActionHelp: true,
|
|
45
|
+
camelToKebab: true,
|
|
46
|
+
kebabToCamel: true,
|
|
47
|
+
coerceValue: true,
|
|
48
|
+
parseArgvWithSchema: true,
|
|
49
|
+
generateAppHelp: true,
|
|
50
|
+
runCli: true,
|
|
51
|
+
typeboxToJsonSchema: true,
|
|
52
|
+
coerceMcpInput: true,
|
|
53
|
+
getMcpSdk: true,
|
|
54
|
+
createMcpServer: true,
|
|
55
|
+
runMcp: true,
|
|
56
|
+
getBuiltinActions: true,
|
|
57
|
+
promptAndExecute: true
|
|
34
58
|
};
|
|
59
|
+
Object.defineProperty(exports, "ActionError", {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
get: function () {
|
|
62
|
+
return _index2.ActionError;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
Object.defineProperty(exports, "ActionRegistry", {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _index2.ActionRegistry;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
35
71
|
Object.defineProperty(exports, "GetBlaze", {
|
|
36
72
|
enumerable: true,
|
|
37
73
|
get: function () {
|
|
@@ -62,6 +98,18 @@ Object.defineProperty(exports, "MultisigScriptModule", {
|
|
|
62
98
|
return _schemas.MultisigScriptModule;
|
|
63
99
|
}
|
|
64
100
|
});
|
|
101
|
+
Object.defineProperty(exports, "NativeScriptInputSchema", {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
get: function () {
|
|
104
|
+
return _schemas.NativeScriptInputSchema;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(exports, "NativeScriptsParam", {
|
|
108
|
+
enumerable: true,
|
|
109
|
+
get: function () {
|
|
110
|
+
return _schemas.NativeScriptsParam;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
65
113
|
Object.defineProperty(exports, "NetworkSchema", {
|
|
66
114
|
enumerable: true,
|
|
67
115
|
get: function () {
|
|
@@ -87,12 +135,72 @@ Object.defineProperty(exports, "WalletSettingsSchema", {
|
|
|
87
135
|
return _schemas.WalletSettingsSchema;
|
|
88
136
|
}
|
|
89
137
|
});
|
|
138
|
+
Object.defineProperty(exports, "camelToKebab", {
|
|
139
|
+
enumerable: true,
|
|
140
|
+
get: function () {
|
|
141
|
+
return _index2.camelToKebab;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
Object.defineProperty(exports, "coerceMcpInput", {
|
|
145
|
+
enumerable: true,
|
|
146
|
+
get: function () {
|
|
147
|
+
return _index2.coerceMcpInput;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
Object.defineProperty(exports, "coerceValue", {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
get: function () {
|
|
153
|
+
return _index2.coerceValue;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
Object.defineProperty(exports, "createMcpServer", {
|
|
157
|
+
enumerable: true,
|
|
158
|
+
get: function () {
|
|
159
|
+
return _index2.createMcpServer;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
Object.defineProperty(exports, "detectMode", {
|
|
163
|
+
enumerable: true,
|
|
164
|
+
get: function () {
|
|
165
|
+
return _index2.detectMode;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
Object.defineProperty(exports, "executeAction", {
|
|
169
|
+
enumerable: true,
|
|
170
|
+
get: function () {
|
|
171
|
+
return _index2.executeAction;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
Object.defineProperty(exports, "generateActionHelp", {
|
|
175
|
+
enumerable: true,
|
|
176
|
+
get: function () {
|
|
177
|
+
return _index2.generateActionHelp;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
Object.defineProperty(exports, "generateAppHelp", {
|
|
181
|
+
enumerable: true,
|
|
182
|
+
get: function () {
|
|
183
|
+
return _index2.generateAppHelp;
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
Object.defineProperty(exports, "getBuiltinActions", {
|
|
187
|
+
enumerable: true,
|
|
188
|
+
get: function () {
|
|
189
|
+
return _index2.getBuiltinActions;
|
|
190
|
+
}
|
|
191
|
+
});
|
|
90
192
|
Object.defineProperty(exports, "getDefault", {
|
|
91
193
|
enumerable: true,
|
|
92
194
|
get: function () {
|
|
93
195
|
return _typeGuards.getDefault;
|
|
94
196
|
}
|
|
95
197
|
});
|
|
198
|
+
Object.defineProperty(exports, "getMcpSdk", {
|
|
199
|
+
enumerable: true,
|
|
200
|
+
get: function () {
|
|
201
|
+
return _index2.getMcpSdk;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
96
204
|
Object.defineProperty(exports, "hasDefault", {
|
|
97
205
|
enumerable: true,
|
|
98
206
|
get: function () {
|
|
@@ -111,12 +219,24 @@ Object.defineProperty(exports, "isBigInt", {
|
|
|
111
219
|
return _typeGuards.isBigInt;
|
|
112
220
|
}
|
|
113
221
|
});
|
|
222
|
+
Object.defineProperty(exports, "isBoolean", {
|
|
223
|
+
enumerable: true,
|
|
224
|
+
get: function () {
|
|
225
|
+
return _typeGuards.isBoolean;
|
|
226
|
+
}
|
|
227
|
+
});
|
|
114
228
|
Object.defineProperty(exports, "isImport", {
|
|
115
229
|
enumerable: true,
|
|
116
230
|
get: function () {
|
|
117
231
|
return _typeGuards.isImport;
|
|
118
232
|
}
|
|
119
233
|
});
|
|
234
|
+
Object.defineProperty(exports, "isInteger", {
|
|
235
|
+
enumerable: true,
|
|
236
|
+
get: function () {
|
|
237
|
+
return _typeGuards.isInteger;
|
|
238
|
+
}
|
|
239
|
+
});
|
|
120
240
|
Object.defineProperty(exports, "isLiteral", {
|
|
121
241
|
enumerable: true,
|
|
122
242
|
get: function () {
|
|
@@ -135,6 +255,12 @@ Object.defineProperty(exports, "isNullable", {
|
|
|
135
255
|
return _typeGuards.isNullable;
|
|
136
256
|
}
|
|
137
257
|
});
|
|
258
|
+
Object.defineProperty(exports, "isNumber", {
|
|
259
|
+
enumerable: true,
|
|
260
|
+
get: function () {
|
|
261
|
+
return _typeGuards.isNumber;
|
|
262
|
+
}
|
|
263
|
+
});
|
|
138
264
|
Object.defineProperty(exports, "isObject", {
|
|
139
265
|
enumerable: true,
|
|
140
266
|
get: function () {
|
|
@@ -183,6 +309,48 @@ Object.defineProperty(exports, "isUnion", {
|
|
|
183
309
|
return _typeGuards.isUnion;
|
|
184
310
|
}
|
|
185
311
|
});
|
|
312
|
+
Object.defineProperty(exports, "kebabToCamel", {
|
|
313
|
+
enumerable: true,
|
|
314
|
+
get: function () {
|
|
315
|
+
return _index2.kebabToCamel;
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
Object.defineProperty(exports, "parseArgvWithSchema", {
|
|
319
|
+
enumerable: true,
|
|
320
|
+
get: function () {
|
|
321
|
+
return _index2.parseArgvWithSchema;
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
Object.defineProperty(exports, "parseCliArgs", {
|
|
325
|
+
enumerable: true,
|
|
326
|
+
get: function () {
|
|
327
|
+
return _index2.parseCliArgs;
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
Object.defineProperty(exports, "promptAndExecute", {
|
|
331
|
+
enumerable: true,
|
|
332
|
+
get: function () {
|
|
333
|
+
return _index2.promptAndExecute;
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
Object.defineProperty(exports, "runCli", {
|
|
337
|
+
enumerable: true,
|
|
338
|
+
get: function () {
|
|
339
|
+
return _index2.runCli;
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
Object.defineProperty(exports, "runMcp", {
|
|
343
|
+
enumerable: true,
|
|
344
|
+
get: function () {
|
|
345
|
+
return _index2.runMcp;
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
Object.defineProperty(exports, "typeboxToJsonSchema", {
|
|
349
|
+
enumerable: true,
|
|
350
|
+
get: function () {
|
|
351
|
+
return _index2.typeboxToJsonSchema;
|
|
352
|
+
}
|
|
353
|
+
});
|
|
186
354
|
Object.defineProperty(exports, "unwrapNullable", {
|
|
187
355
|
enumerable: true,
|
|
188
356
|
get: function () {
|
|
@@ -216,6 +384,8 @@ var _encryption = require("./encryption.js");
|
|
|
216
384
|
var _txDialog = require("./tx-dialog.js");
|
|
217
385
|
var _index = require("./menus/index.js");
|
|
218
386
|
var _formatting = require("./utils/formatting.js");
|
|
387
|
+
var _index2 = require("./actions/index.js");
|
|
388
|
+
var _utilityActions = require("./actions/builtin/utility-actions.js");
|
|
219
389
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
220
390
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
221
391
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
@@ -228,12 +398,14 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
228
398
|
// Import encryption utilities
|
|
229
399
|
// Import tx-dialog utilities
|
|
230
400
|
// Import menu modules
|
|
401
|
+
// Import and re-export action system
|
|
231
402
|
class Sprinkle {
|
|
232
403
|
constructor(type, storagePath, options) {
|
|
233
404
|
_defineProperty(this, "storagePath", void 0);
|
|
234
405
|
_defineProperty(this, "settings", {});
|
|
235
406
|
_defineProperty(this, "type", void 0);
|
|
236
407
|
_defineProperty(this, "defaults", {});
|
|
408
|
+
_defineProperty(this, "addressbook", {});
|
|
237
409
|
_defineProperty(this, "options", void 0);
|
|
238
410
|
_defineProperty(this, "profileId", "");
|
|
239
411
|
_defineProperty(this, "profileMeta", {
|
|
@@ -241,9 +413,11 @@ class Sprinkle {
|
|
|
241
413
|
createdAt: "",
|
|
242
414
|
updatedAt: ""
|
|
243
415
|
});
|
|
416
|
+
_defineProperty(this, "actionRegistry", void 0);
|
|
244
417
|
this.type = type;
|
|
245
418
|
this.storagePath = storagePath;
|
|
246
419
|
this.options = options ?? {};
|
|
420
|
+
this.actionRegistry = new _index2.ActionRegistry();
|
|
247
421
|
}
|
|
248
422
|
|
|
249
423
|
// --- Current Profile Accessor ---
|
|
@@ -314,6 +488,7 @@ class Sprinkle {
|
|
|
314
488
|
this.profileMeta = parsed.meta;
|
|
315
489
|
this.settings = await this.decryptSettings(parsed.settings);
|
|
316
490
|
this.defaults = parsed.defaults ?? {};
|
|
491
|
+
this.addressbook = parsed.addressbook ?? {};
|
|
317
492
|
// Update active profile pointer
|
|
318
493
|
fs.writeFileSync(Sprinkle.activeProfilePath(this.storagePath), id, "utf-8");
|
|
319
494
|
}
|
|
@@ -333,7 +508,8 @@ class Sprinkle {
|
|
|
333
508
|
const jsonContent = JSON.stringify({
|
|
334
509
|
meta: this.profileMeta,
|
|
335
510
|
settings: settingsToSave,
|
|
336
|
-
defaults: this.defaults
|
|
511
|
+
defaults: this.defaults,
|
|
512
|
+
addressbook: this.addressbook
|
|
337
513
|
}, _encryption.bigIntReplacer, 2);
|
|
338
514
|
fs.writeFileSync(filePath, jsonContent, "utf-8");
|
|
339
515
|
}
|
|
@@ -410,7 +586,8 @@ class Sprinkle {
|
|
|
410
586
|
updatedAt: now
|
|
411
587
|
},
|
|
412
588
|
settings: parsed.settings,
|
|
413
|
-
defaults: parsed.defaults ?? {}
|
|
589
|
+
defaults: parsed.defaults ?? {},
|
|
590
|
+
addressbook: parsed.addressbook ?? {}
|
|
414
591
|
};
|
|
415
592
|
fs.mkdirSync(profilesDir, {
|
|
416
593
|
recursive: true
|
|
@@ -485,7 +662,8 @@ class Sprinkle {
|
|
|
485
662
|
updatedAt: now
|
|
486
663
|
},
|
|
487
664
|
settings: settingsToSave,
|
|
488
|
-
defaults: this.defaults
|
|
665
|
+
defaults: this.defaults,
|
|
666
|
+
addressbook: this.addressbook
|
|
489
667
|
}, _encryption.bigIntReplacer, 2);
|
|
490
668
|
fs.writeFileSync(path.join(profilesDir, `${id}.json`), jsonContent, "utf-8");
|
|
491
669
|
console.log(`Profile "${name}" created as a copy.`);
|
|
@@ -579,6 +757,10 @@ class Sprinkle {
|
|
|
579
757
|
value: -1
|
|
580
758
|
});
|
|
581
759
|
} else {
|
|
760
|
+
choices.push({
|
|
761
|
+
name: "Utilities",
|
|
762
|
+
value: -6
|
|
763
|
+
});
|
|
582
764
|
choices.push({
|
|
583
765
|
name: "Settings & Profiles",
|
|
584
766
|
value: -5
|
|
@@ -602,6 +784,58 @@ class Sprinkle {
|
|
|
602
784
|
return;
|
|
603
785
|
}
|
|
604
786
|
const selection = selectionResult;
|
|
787
|
+
if (selection === -6) {
|
|
788
|
+
const utilitiesMenu = {
|
|
789
|
+
title: "Utilities",
|
|
790
|
+
items: [{
|
|
791
|
+
title: "Mint Token",
|
|
792
|
+
action: async () => {
|
|
793
|
+
const result = await (0, _index2.promptAndExecute)(this, _utilityActions.mintToken);
|
|
794
|
+
if (!result.success) {
|
|
795
|
+
if (result.error.code === "USER_CANCELLED") return;
|
|
796
|
+
console.error(`\nError (${result.error.code}): ${result.error.message}\n`);
|
|
797
|
+
return;
|
|
798
|
+
}
|
|
799
|
+
const data = result.data;
|
|
800
|
+
console.log(`\nPolicy: ${data.policyId}\nToken: ${data.tokenName}\nAmount: ${data.amount}\n`);
|
|
801
|
+
const blaze = await Sprinkle.GetBlaze(this.settings.network, this.settings.provider, this.settings.wallet);
|
|
802
|
+
const tx = _sdk.Core.Transaction.fromCbor(_sdk.Core.TxCBOR(data.txCbor));
|
|
803
|
+
await this.TxDialog(blaze, tx);
|
|
804
|
+
}
|
|
805
|
+
}, {
|
|
806
|
+
title: "Simple Send",
|
|
807
|
+
action: async () => {
|
|
808
|
+
const result = await (0, _index2.promptAndExecute)(this, _utilityActions.simpleSend);
|
|
809
|
+
if (!result.success) {
|
|
810
|
+
if (result.error.code === "USER_CANCELLED") return;
|
|
811
|
+
console.error(`\nError (${result.error.code}): ${result.error.message}\n`);
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
const data = result.data;
|
|
815
|
+
const blaze = await Sprinkle.GetBlaze(this.settings.network, this.settings.provider, this.settings.wallet);
|
|
816
|
+
const tx = _sdk.Core.Transaction.fromCbor(_sdk.Core.TxCBOR(data.txCbor));
|
|
817
|
+
await this.TxDialog(blaze, tx);
|
|
818
|
+
}
|
|
819
|
+
}, {
|
|
820
|
+
title: "Register Stake Script",
|
|
821
|
+
action: async () => {
|
|
822
|
+
const result = await (0, _index2.promptAndExecute)(this, _utilityActions.registerStakeScript);
|
|
823
|
+
if (!result.success) {
|
|
824
|
+
if (result.error.code === "USER_CANCELLED") return;
|
|
825
|
+
console.error(`\nError (${result.error.code}): ${result.error.message}\n`);
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
const data = result.data;
|
|
829
|
+
const blaze = await Sprinkle.GetBlaze(this.settings.network, this.settings.provider, this.settings.wallet);
|
|
830
|
+
const tx = _sdk.Core.Transaction.fromCbor(_sdk.Core.TxCBOR(data.txCbor));
|
|
831
|
+
await this.TxDialog(blaze, tx);
|
|
832
|
+
}
|
|
833
|
+
}]
|
|
834
|
+
};
|
|
835
|
+
await this._showMenu(utilitiesMenu, false, [...path, "Utilities"], true);
|
|
836
|
+
await this._showMenu(menu, main, path, true);
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
605
839
|
if (selection === -5) {
|
|
606
840
|
const settingsMenu = {
|
|
607
841
|
title: "Settings & Profiles",
|
|
@@ -668,6 +902,113 @@ class Sprinkle {
|
|
|
668
902
|
action: async () => {
|
|
669
903
|
await this.deleteProfile();
|
|
670
904
|
}
|
|
905
|
+
}, {
|
|
906
|
+
title: "Addressbook",
|
|
907
|
+
items: [{
|
|
908
|
+
title: "View entries",
|
|
909
|
+
action: async () => {
|
|
910
|
+
const entries = Object.entries(this.addressbook);
|
|
911
|
+
if (entries.length === 0) {
|
|
912
|
+
console.log("Addressbook is empty.");
|
|
913
|
+
} else {
|
|
914
|
+
for (const [name, ms] of entries) {
|
|
915
|
+
const json = JSON.stringify(ms, _encryption.bigIntReplacer, 2);
|
|
916
|
+
let hashStr = "unknown";
|
|
917
|
+
try {
|
|
918
|
+
hashStr = (0, _index2.toNativeScript)(ms).hash();
|
|
919
|
+
} catch {/* skip */}
|
|
920
|
+
console.log(_yoctocolorsCjs.default.bold(name) + " " + _yoctocolorsCjs.default.dim(hashStr));
|
|
921
|
+
console.log(json);
|
|
922
|
+
console.log();
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
await (0, _prompts.selectWithClear)({
|
|
926
|
+
message: "Press Enter to continue...",
|
|
927
|
+
choices: [{
|
|
928
|
+
name: "Continue",
|
|
929
|
+
value: "continue"
|
|
930
|
+
}]
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
}, {
|
|
934
|
+
title: "Add entry",
|
|
935
|
+
action: async () => {
|
|
936
|
+
const name = await (0, _prompts.inputCancellable)({
|
|
937
|
+
message: "Entry name:",
|
|
938
|
+
validate: v => v.trim().length > 0 ? true : "Name cannot be empty"
|
|
939
|
+
});
|
|
940
|
+
if (name === null) return;
|
|
941
|
+
if (this.addressbook[name]) {
|
|
942
|
+
const overwrite = await (0, _prompts.confirmCancellable)({
|
|
943
|
+
message: `Entry "${name}" already exists. Overwrite?`,
|
|
944
|
+
default: false
|
|
945
|
+
});
|
|
946
|
+
if (!overwrite) return;
|
|
947
|
+
}
|
|
948
|
+
try {
|
|
949
|
+
const script = await this.FillInStruct(_schemas.MultisigScript);
|
|
950
|
+
this.addressbook[name] = script;
|
|
951
|
+
this.saveSettings();
|
|
952
|
+
console.log(`Added "${name}" to addressbook.`);
|
|
953
|
+
} catch (e) {
|
|
954
|
+
if (e instanceof _types.UserCancelledError) return;
|
|
955
|
+
throw e;
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
}, {
|
|
959
|
+
title: "Edit entry",
|
|
960
|
+
action: async () => {
|
|
961
|
+
const entries = Object.keys(this.addressbook);
|
|
962
|
+
if (entries.length === 0) {
|
|
963
|
+
console.log("Addressbook is empty.");
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
const selected = await (0, _prompts.selectCancellable)({
|
|
967
|
+
message: "Select entry to edit:",
|
|
968
|
+
choices: entries.map(n => ({
|
|
969
|
+
name: n,
|
|
970
|
+
value: n
|
|
971
|
+
}))
|
|
972
|
+
});
|
|
973
|
+
if (selected === null) return;
|
|
974
|
+
const editName = selected;
|
|
975
|
+
try {
|
|
976
|
+
const updated = await this.EditStruct(_schemas.MultisigScript, this.addressbook[editName]);
|
|
977
|
+
this.addressbook[editName] = updated;
|
|
978
|
+
this.saveSettings();
|
|
979
|
+
console.log(`Updated "${editName}".`);
|
|
980
|
+
} catch (e) {
|
|
981
|
+
if (e instanceof _types.UserCancelledError) return;
|
|
982
|
+
throw e;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
}, {
|
|
986
|
+
title: "Delete entry",
|
|
987
|
+
action: async () => {
|
|
988
|
+
const entries = Object.keys(this.addressbook);
|
|
989
|
+
if (entries.length === 0) {
|
|
990
|
+
console.log("Addressbook is empty.");
|
|
991
|
+
return;
|
|
992
|
+
}
|
|
993
|
+
const delSelected = await (0, _prompts.selectCancellable)({
|
|
994
|
+
message: "Select entry to delete:",
|
|
995
|
+
choices: entries.map(n => ({
|
|
996
|
+
name: n,
|
|
997
|
+
value: n
|
|
998
|
+
}))
|
|
999
|
+
});
|
|
1000
|
+
if (delSelected === null) return;
|
|
1001
|
+
const delName = delSelected;
|
|
1002
|
+
const confirmed = await (0, _prompts.confirmCancellable)({
|
|
1003
|
+
message: `Delete "${delName}"?`,
|
|
1004
|
+
default: false
|
|
1005
|
+
});
|
|
1006
|
+
if (!confirmed) return;
|
|
1007
|
+
delete this.addressbook[delName];
|
|
1008
|
+
this.saveSettings();
|
|
1009
|
+
console.log(`Deleted "${delName}".`);
|
|
1010
|
+
}
|
|
1011
|
+
}]
|
|
671
1012
|
}]
|
|
672
1013
|
};
|
|
673
1014
|
await this._showMenu(settingsMenu, false, [...path, "Settings & Profiles"], true);
|
|
@@ -761,6 +1102,88 @@ class Sprinkle {
|
|
|
761
1102
|
getDisplaySettings() {
|
|
762
1103
|
return (0, _encryption.maskSensitiveFields)(this.settings, this.type);
|
|
763
1104
|
}
|
|
1105
|
+
|
|
1106
|
+
// --- Non-interactive profile management (for CLI/MCP actions) ---
|
|
1107
|
+
|
|
1108
|
+
/**
|
|
1109
|
+
* Look up a profile entry by its ID without loading it.
|
|
1110
|
+
* Returns undefined if no profile with the given ID exists.
|
|
1111
|
+
*/
|
|
1112
|
+
getProfileById(id) {
|
|
1113
|
+
return this.scanProfiles().find(p => p.id === id);
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
/**
|
|
1117
|
+
* Create a new profile file without interactive prompts.
|
|
1118
|
+
* Does NOT switch the active profile.
|
|
1119
|
+
*
|
|
1120
|
+
* @throws ActionError with code DUPLICATE_PROFILE if a profile with the same name already exists.
|
|
1121
|
+
* @returns The created IProfileEntry
|
|
1122
|
+
*/
|
|
1123
|
+
async createProfileNonInteractive(name, description, initialSettings) {
|
|
1124
|
+
const profiles = this.scanProfiles();
|
|
1125
|
+
const nameLower = name.toLowerCase();
|
|
1126
|
+
const duplicate = profiles.find(p => p.meta.name.toLowerCase() === nameLower);
|
|
1127
|
+
if (duplicate) {
|
|
1128
|
+
throw new _index2.ActionError(`A profile named "${name}" already exists.`, "DUPLICATE_PROFILE", {
|
|
1129
|
+
existingId: duplicate.id
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
const profilesDir = Sprinkle.profilesDir(this.storagePath);
|
|
1133
|
+
if (!fs.existsSync(profilesDir)) {
|
|
1134
|
+
fs.mkdirSync(profilesDir, {
|
|
1135
|
+
recursive: true
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1138
|
+
const baseId = Sprinkle.sanitizeProfileId(name);
|
|
1139
|
+
const id = Sprinkle.findAvailableId(profilesDir, baseId);
|
|
1140
|
+
const now = new Date().toISOString();
|
|
1141
|
+
const meta = {
|
|
1142
|
+
name,
|
|
1143
|
+
description,
|
|
1144
|
+
createdAt: now,
|
|
1145
|
+
updatedAt: now
|
|
1146
|
+
};
|
|
1147
|
+
const profileData = {
|
|
1148
|
+
meta,
|
|
1149
|
+
settings: initialSettings ?? {},
|
|
1150
|
+
defaults: {},
|
|
1151
|
+
addressbook: {}
|
|
1152
|
+
};
|
|
1153
|
+
fs.writeFileSync(path.join(profilesDir, `${id}.json`), JSON.stringify(profileData, _encryption.bigIntReplacer, 2), "utf-8");
|
|
1154
|
+
return {
|
|
1155
|
+
id,
|
|
1156
|
+
meta
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
/**
|
|
1161
|
+
* Delete a profile file by ID.
|
|
1162
|
+
*
|
|
1163
|
+
* @throws ActionError with code PROFILE_NOT_FOUND if no profile with the given ID exists.
|
|
1164
|
+
* @throws ActionError with code CANNOT_DELETE_ONLY_PROFILE if this is the only profile.
|
|
1165
|
+
* @throws ActionError with code CANNOT_DELETE_ACTIVE_PROFILE if this is the currently active profile.
|
|
1166
|
+
*/
|
|
1167
|
+
deleteProfileById(id) {
|
|
1168
|
+
const profiles = this.scanProfiles();
|
|
1169
|
+
const profile = profiles.find(p => p.id === id);
|
|
1170
|
+
if (!profile) {
|
|
1171
|
+
throw new _index2.ActionError(`Profile "${id}" not found.`, "PROFILE_NOT_FOUND", {
|
|
1172
|
+
id
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
if (profiles.length === 1) {
|
|
1176
|
+
throw new _index2.ActionError("Cannot delete the only profile.", "CANNOT_DELETE_ONLY_PROFILE", {
|
|
1177
|
+
id
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
1180
|
+
if (id === this.profileId) {
|
|
1181
|
+
throw new _index2.ActionError("Cannot delete the active profile. Switch to a different profile first.", "CANNOT_DELETE_ACTIVE_PROFILE", {
|
|
1182
|
+
id
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
fs.unlinkSync(Sprinkle.profilePath(this.storagePath, id));
|
|
1186
|
+
}
|
|
764
1187
|
async TxDialog(blaze, tx, opts) {
|
|
765
1188
|
let currentTx = tx;
|
|
766
1189
|
let expanded = false;
|
|
@@ -1070,7 +1493,67 @@ class Sprinkle {
|
|
|
1070
1493
|
if (!resolvedType) {
|
|
1071
1494
|
throw new Error(`Could not resolve type ${type["$ref"]} at ${path.join(".")}`);
|
|
1072
1495
|
}
|
|
1073
|
-
|
|
1496
|
+
|
|
1497
|
+
// Addressbook integration for MultisigScript fields
|
|
1498
|
+
if (type["$ref"] === "MultisigScript" && Object.keys(this.addressbook).length > 0) {
|
|
1499
|
+
const sourceChoice = await (0, _prompts.selectWithClear)({
|
|
1500
|
+
message: "Select source for native script:",
|
|
1501
|
+
choices: [{
|
|
1502
|
+
name: "Enter manually",
|
|
1503
|
+
value: "manual"
|
|
1504
|
+
}, {
|
|
1505
|
+
name: "Select from addressbook",
|
|
1506
|
+
value: "addressbook"
|
|
1507
|
+
}]
|
|
1508
|
+
});
|
|
1509
|
+
if (sourceChoice === null) throw new _types.UserCancelledError();
|
|
1510
|
+
if (sourceChoice === "addressbook") {
|
|
1511
|
+
const entries = Object.entries(this.addressbook);
|
|
1512
|
+
const abChoices = entries.map(([name, ms]) => {
|
|
1513
|
+
let hashStr = "";
|
|
1514
|
+
try {
|
|
1515
|
+
hashStr = " " + _yoctocolorsCjs.default.dim((0, _index2.toNativeScript)(ms).hash());
|
|
1516
|
+
} catch {/* skip */}
|
|
1517
|
+
return {
|
|
1518
|
+
name: name + hashStr,
|
|
1519
|
+
value: name
|
|
1520
|
+
};
|
|
1521
|
+
});
|
|
1522
|
+
const selected = await (0, _prompts.selectWithClear)({
|
|
1523
|
+
message: "Select addressbook entry:",
|
|
1524
|
+
choices: abChoices
|
|
1525
|
+
});
|
|
1526
|
+
if (selected === null) throw new _types.UserCancelledError();
|
|
1527
|
+
return this.addressbook[selected];
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
const result = await this._fillInStruct(resolvedType, path, defs, def);
|
|
1531
|
+
|
|
1532
|
+
// Offer to save manually entered MultisigScript to addressbook
|
|
1533
|
+
if (type["$ref"] === "MultisigScript" && result !== undefined) {
|
|
1534
|
+
const shouldSave = await (0, _prompts.selectWithClear)({
|
|
1535
|
+
message: "Save this script to the addressbook?",
|
|
1536
|
+
choices: [{
|
|
1537
|
+
name: "No",
|
|
1538
|
+
value: false
|
|
1539
|
+
}, {
|
|
1540
|
+
name: "Yes",
|
|
1541
|
+
value: true
|
|
1542
|
+
}]
|
|
1543
|
+
});
|
|
1544
|
+
if (shouldSave) {
|
|
1545
|
+
const entryName = await (0, _prompts.inputCancellable)({
|
|
1546
|
+
message: "Addressbook entry name:",
|
|
1547
|
+
validate: v => v.trim().length > 0 ? true : "Name cannot be empty"
|
|
1548
|
+
});
|
|
1549
|
+
if (entryName !== null) {
|
|
1550
|
+
this.addressbook[entryName] = result;
|
|
1551
|
+
this.saveSettings();
|
|
1552
|
+
console.log(`Saved "${entryName}" to addressbook.`);
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
return result;
|
|
1074
1557
|
}
|
|
1075
1558
|
if ((0, _typeGuards.isOptional)(type)) {
|
|
1076
1559
|
const pathDisplay = (0, _formatting.formatPath)(path) || "value";
|
|
@@ -1215,6 +1698,24 @@ class Sprinkle {
|
|
|
1215
1698
|
}
|
|
1216
1699
|
return BigInt(answer);
|
|
1217
1700
|
}
|
|
1701
|
+
if ((0, _typeGuards.isBoolean)(type)) {
|
|
1702
|
+
const pathDisplay = (0, _formatting.formatPath)(path) || "value";
|
|
1703
|
+
const answer = await (0, _prompts.selectWithClear)({
|
|
1704
|
+
message: Sprinkle.ExtractMessage(type, `${pathDisplay}?`),
|
|
1705
|
+
choices: [{
|
|
1706
|
+
name: "Yes",
|
|
1707
|
+
value: true
|
|
1708
|
+
}, {
|
|
1709
|
+
name: "No",
|
|
1710
|
+
value: false
|
|
1711
|
+
}],
|
|
1712
|
+
default: def !== undefined ? def : (0, _typeGuards.hasDefault)(type) ? (0, _typeGuards.getDefault)(type) : undefined
|
|
1713
|
+
});
|
|
1714
|
+
if (answer === null) {
|
|
1715
|
+
throw new _types.UserCancelledError();
|
|
1716
|
+
}
|
|
1717
|
+
return answer;
|
|
1718
|
+
}
|
|
1218
1719
|
if ((0, _typeGuards.isLiteral)(type)) {
|
|
1219
1720
|
return type.const;
|
|
1220
1721
|
}
|
|
@@ -1303,6 +1804,178 @@ class Sprinkle {
|
|
|
1303
1804
|
}
|
|
1304
1805
|
return def;
|
|
1305
1806
|
}
|
|
1807
|
+
|
|
1808
|
+
// --- Action System ---
|
|
1809
|
+
|
|
1810
|
+
/**
|
|
1811
|
+
* Register an action on this Sprinkle instance.
|
|
1812
|
+
* Delegates to the internal ActionRegistry with name and schema validation.
|
|
1813
|
+
*/
|
|
1814
|
+
registerAction(action) {
|
|
1815
|
+
this.actionRegistry.register(action);
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
/**
|
|
1819
|
+
* Retrieve a registered action by name.
|
|
1820
|
+
* @returns The action, or undefined if not registered
|
|
1821
|
+
*/
|
|
1822
|
+
getAction(name) {
|
|
1823
|
+
return this.actionRegistry.get(name);
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
/**
|
|
1827
|
+
* List all registered actions.
|
|
1828
|
+
*/
|
|
1829
|
+
listActions() {
|
|
1830
|
+
return this.actionRegistry.list();
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
/**
|
|
1834
|
+
* List all registered actions grouped by category.
|
|
1835
|
+
* Uncategorized actions are grouped under "default".
|
|
1836
|
+
*/
|
|
1837
|
+
listActionsByCategory() {
|
|
1838
|
+
return this.actionRegistry.listByCategory();
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
/**
|
|
1842
|
+
* Execute a registered action by name with raw (unvalidated) input.
|
|
1843
|
+
* Input is validated against the action's inputSchema before execution.
|
|
1844
|
+
*
|
|
1845
|
+
* @throws Error if the action name is not registered
|
|
1846
|
+
*/
|
|
1847
|
+
async runAction(name, input) {
|
|
1848
|
+
const action = this.actionRegistry.get(name);
|
|
1849
|
+
if (!action) {
|
|
1850
|
+
throw new Error(`Action "${name}" is not registered. Available actions: ${this.actionRegistry.list().map(a => a.name).join(", ") || "(none)"}`);
|
|
1851
|
+
}
|
|
1852
|
+
const context = {
|
|
1853
|
+
sprinkle: this,
|
|
1854
|
+
settings: this.settings
|
|
1855
|
+
};
|
|
1856
|
+
return (0, _index2.executeAction)(action, input, context);
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
/**
|
|
1860
|
+
* Non-interactive profile initialization for CLI/MCP modes.
|
|
1861
|
+
* Resolves a profile without any user prompts.
|
|
1862
|
+
*
|
|
1863
|
+
* Resolution order:
|
|
1864
|
+
* 1. If profileName provided, load that profile directly
|
|
1865
|
+
* 2. If exactly one profile exists, auto-select it
|
|
1866
|
+
* 3. If multiple profiles exist and no name given, throw with available names
|
|
1867
|
+
* 4. If no profiles exist, throw instructing user to run in interactive mode
|
|
1868
|
+
*/
|
|
1869
|
+
async initNonInteractive(profileName) {
|
|
1870
|
+
await this.migrateIfNeeded();
|
|
1871
|
+
if (profileName) {
|
|
1872
|
+
await this.loadProfile(profileName);
|
|
1873
|
+
return;
|
|
1874
|
+
}
|
|
1875
|
+
const profiles = this.scanProfiles();
|
|
1876
|
+
if (profiles.length === 0) {
|
|
1877
|
+
throw new Error("No profiles found. Run in interactive mode to create one.");
|
|
1878
|
+
}
|
|
1879
|
+
if (profiles.length === 1) {
|
|
1880
|
+
await this.loadProfile(profiles[0].id);
|
|
1881
|
+
return;
|
|
1882
|
+
}
|
|
1883
|
+
|
|
1884
|
+
// Multiple profiles without a --profile flag
|
|
1885
|
+
const names = profiles.map(p => `"${p.id}" (${p.meta.name})`).join(", ");
|
|
1886
|
+
throw new Error(`Multiple profiles found. Specify one with --profile <id>. Available profiles: ${names}`);
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1889
|
+
/**
|
|
1890
|
+
* Static entry point that detects mode and runs accordingly.
|
|
1891
|
+
*
|
|
1892
|
+
* Modes:
|
|
1893
|
+
* - "tui" -- Interactive TUI menu (requires menu option)
|
|
1894
|
+
* - "cli" -- CLI action execution (parses argv for action name and args)
|
|
1895
|
+
* - "mcp" -- MCP protocol mode (not yet implemented)
|
|
1896
|
+
* - "help" -- Print available actions and exit
|
|
1897
|
+
*/
|
|
1898
|
+
static async run(opts) {
|
|
1899
|
+
const argv = opts.argv ?? process.argv.slice(2);
|
|
1900
|
+
const mode = (0, _index2.detectMode)(argv);
|
|
1901
|
+
if (mode === "tui") {
|
|
1902
|
+
if (!opts.menu) {
|
|
1903
|
+
throw new Error("TUI mode requires a menu. Provide a menu option or pass --help to see available actions.");
|
|
1904
|
+
}
|
|
1905
|
+
const sprinkle = await Sprinkle.New(opts.type, opts.storagePath, opts.options);
|
|
1906
|
+
// Register any provided actions
|
|
1907
|
+
for (const action of opts.actions ?? []) {
|
|
1908
|
+
sprinkle.registerAction(action);
|
|
1909
|
+
}
|
|
1910
|
+
await sprinkle.showMenu(opts.menu);
|
|
1911
|
+
return;
|
|
1912
|
+
}
|
|
1913
|
+
if (mode === "help") {
|
|
1914
|
+
const sprinkle = new Sprinkle(opts.type, opts.storagePath, opts.options);
|
|
1915
|
+
for (const action of opts.actions ?? []) {
|
|
1916
|
+
sprinkle.registerAction(action);
|
|
1917
|
+
}
|
|
1918
|
+
console.log((0, _index2.generateAppHelp)(sprinkle.listActions()));
|
|
1919
|
+
return;
|
|
1920
|
+
}
|
|
1921
|
+
if (mode === "cli") {
|
|
1922
|
+
const {
|
|
1923
|
+
actionName,
|
|
1924
|
+
args
|
|
1925
|
+
} = (0, _index2.parseCliArgs)(argv);
|
|
1926
|
+
|
|
1927
|
+
// Extract --profile flag from args if present
|
|
1928
|
+
const profileName = typeof args["profile"] === "string" ? args["profile"] : undefined;
|
|
1929
|
+
const sprinkle = new Sprinkle(opts.type, opts.storagePath, opts.options);
|
|
1930
|
+
for (const action of opts.actions ?? []) {
|
|
1931
|
+
sprinkle.registerAction(action);
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
// Handle action-specific --help BEFORE profile initialization
|
|
1935
|
+
// (help should work without a profile)
|
|
1936
|
+
if (args["help"] === true) {
|
|
1937
|
+
const action = sprinkle.getAction(actionName);
|
|
1938
|
+
if (action) {
|
|
1939
|
+
console.log((0, _index2.generateActionHelp)(action));
|
|
1940
|
+
} else {
|
|
1941
|
+
console.log(`Unknown action "${actionName}". Run --help to see available actions.`);
|
|
1942
|
+
}
|
|
1943
|
+
return;
|
|
1944
|
+
}
|
|
1945
|
+
await sprinkle.initNonInteractive(profileName);
|
|
1946
|
+
|
|
1947
|
+
// Remove internal flags from args before passing to action
|
|
1948
|
+
const actionArgs = {
|
|
1949
|
+
...args
|
|
1950
|
+
};
|
|
1951
|
+
delete actionArgs["profile"];
|
|
1952
|
+
delete actionArgs["help"];
|
|
1953
|
+
|
|
1954
|
+
// Build context and delegate to runCli for proper error routing
|
|
1955
|
+
const context = {
|
|
1956
|
+
sprinkle,
|
|
1957
|
+
settings: sprinkle.settings
|
|
1958
|
+
};
|
|
1959
|
+
await (0, _index2.runCli)(sprinkle, actionName, actionArgs, context);
|
|
1960
|
+
return;
|
|
1961
|
+
}
|
|
1962
|
+
if (mode === "mcp") {
|
|
1963
|
+
// Derive a server name from the storage path basename, falling back to a
|
|
1964
|
+
// sensible default.
|
|
1965
|
+
const serverName = path.basename(opts.storagePath) || "sprinkle-mcp";
|
|
1966
|
+
const sprinkle = new Sprinkle(opts.type, opts.storagePath, opts.options);
|
|
1967
|
+
for (const action of opts.actions ?? []) {
|
|
1968
|
+
sprinkle.registerAction(action);
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
// Read profile name from environment variable (MCP clients have no
|
|
1972
|
+
// interactive terminal to prompt for profile selection).
|
|
1973
|
+
const profileName = process.env["SPRINKLE_PROFILE"];
|
|
1974
|
+
await sprinkle.initNonInteractive(profileName);
|
|
1975
|
+
await (0, _index2.runMcp)(sprinkle, serverName);
|
|
1976
|
+
return;
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1306
1979
|
}
|
|
1307
1980
|
exports.Sprinkle = Sprinkle;
|
|
1308
1981
|
//# sourceMappingURL=index.js.map
|