warpmetal 0.3.0 → 0.4.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 +56 -7
- package/package.json +2 -2
- package/skills/warpmetal/SKILL.md +44 -22
- package/skills/warpmetal/agents/openai.yaml +2 -2
- package/skills/warpmetal/references/cli-reference.md +28 -4
- package/skills/warpmetal/references/payments.md +110 -0
- package/skills/warpmetal/references/safety.md +20 -7
- package/src/cli.js +134 -24
- package/src/payment.js +769 -0
- package/src/state.js +55 -1
package/src/state.js
CHANGED
|
@@ -145,7 +145,16 @@ export class StateStore {
|
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
async savePaymentChallenge(
|
|
148
|
+
async savePaymentChallenge(
|
|
149
|
+
taskId,
|
|
150
|
+
{
|
|
151
|
+
paymentRequired,
|
|
152
|
+
paymentAttemptId,
|
|
153
|
+
paymentRequestDigest,
|
|
154
|
+
paymentChallengeDigest,
|
|
155
|
+
paymentWorkflow,
|
|
156
|
+
},
|
|
157
|
+
) {
|
|
149
158
|
await this.update((state) => {
|
|
150
159
|
const order = state.orders[taskId];
|
|
151
160
|
if (!order)
|
|
@@ -154,10 +163,51 @@ export class StateStore {
|
|
|
154
163
|
});
|
|
155
164
|
order.paymentRequired = paymentRequired;
|
|
156
165
|
order.paymentAttemptId = paymentAttemptId;
|
|
166
|
+
order.paymentRequestDigest = paymentRequestDigest;
|
|
167
|
+
order.paymentChallengeDigest = paymentChallengeDigest;
|
|
168
|
+
order.paymentRequestEnvelopePath = paymentWorkflow?.requestEnvelopePath;
|
|
169
|
+
order.paymentArtifactPath = paymentWorkflow?.paymentArtifactPath;
|
|
157
170
|
order.paymentChallengeSavedAt = new Date().toISOString();
|
|
158
171
|
});
|
|
159
172
|
}
|
|
160
173
|
|
|
174
|
+
async saveWalletPaymentAttempt(
|
|
175
|
+
taskId,
|
|
176
|
+
{
|
|
177
|
+
attemptId,
|
|
178
|
+
requestDigest,
|
|
179
|
+
buyerPaymentIdentifier,
|
|
180
|
+
wallet,
|
|
181
|
+
payerAddress,
|
|
182
|
+
path,
|
|
183
|
+
expiresAt,
|
|
184
|
+
},
|
|
185
|
+
) {
|
|
186
|
+
await this.update((state) => {
|
|
187
|
+
const order = state.orders[taskId];
|
|
188
|
+
if (!order)
|
|
189
|
+
throw new CliError(`No local order state exists for ${taskId}.`, {
|
|
190
|
+
exitCode: 2,
|
|
191
|
+
});
|
|
192
|
+
if (
|
|
193
|
+
order.paymentRequestDigest &&
|
|
194
|
+
order.paymentRequestDigest !== requestDigest
|
|
195
|
+
) {
|
|
196
|
+
throw new CliError(
|
|
197
|
+
`The wallet payment attempt does not match the saved challenge for ${taskId}.`,
|
|
198
|
+
{ exitCode: 2 },
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
order.walletPaymentAttemptId = attemptId;
|
|
202
|
+
order.walletBuyerPaymentIdentifier = buyerPaymentIdentifier;
|
|
203
|
+
order.walletName = wallet;
|
|
204
|
+
order.walletPayerAddress = payerAddress;
|
|
205
|
+
order.paymentArtifactPath = path;
|
|
206
|
+
order.paymentArtifactExpiresAt = expiresAt;
|
|
207
|
+
order.paymentArtifactSavedAt = new Date().toISOString();
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
161
211
|
async saveAccessToken(serverId, accessToken, expiresAt) {
|
|
162
212
|
await this.update((state) => {
|
|
163
213
|
const server = state.servers[serverId] || { serverId };
|
|
@@ -284,6 +334,10 @@ export class StateStore {
|
|
|
284
334
|
serverId: order.serverId,
|
|
285
335
|
planId: order.planId,
|
|
286
336
|
paymentAttemptId: order.paymentAttemptId,
|
|
337
|
+
walletPaymentAttemptId: order.walletPaymentAttemptId,
|
|
338
|
+
walletName: order.walletName,
|
|
339
|
+
payerAddress: order.walletPayerAddress,
|
|
340
|
+
paymentArtifactExpiresAt: order.paymentArtifactExpiresAt,
|
|
287
341
|
credentialStored: Boolean(order.ownerToken),
|
|
288
342
|
})),
|
|
289
343
|
servers: Object.values(state.servers).map((server) => ({
|