@itpay/cli 2.1.57 → 2.1.59
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/src/main.js +35 -18
- package/dist/src/state/config.js +1 -1
- package/package.json +2 -2
package/dist/src/main.js
CHANGED
|
@@ -16671,6 +16671,17 @@ function assertCheckoutCreation(checkout, cartID, sourceExecutionID) {
|
|
|
16671
16671
|
}
|
|
16672
16672
|
}
|
|
16673
16673
|
__name(assertCheckoutCreation, "assertCheckoutCreation");
|
|
16674
|
+
function assertAccountCheckout(checkout, cartID, sourceExecutionID) {
|
|
16675
|
+
const current = checkout.checkout;
|
|
16676
|
+
const expiry = Date.parse(current.expires_at ?? "");
|
|
16677
|
+
const entryExpiry = checkout.official_entry?.expires_at;
|
|
16678
|
+
const bound = entryExpiry === void 0 ? expiry : Date.parse(entryExpiry);
|
|
16679
|
+
const closed = !Number.isFinite(expiry) || !Number.isFinite(bound) || Math.min(expiry, bound) <= Date.now();
|
|
16680
|
+
if (!current.checkout_id || current.cart_id !== cartID || !payableStates.includes(current.status) || closed || bound > expiry) {
|
|
16681
|
+
throw checkoutNotPayable(current, cartID, sourceExecutionID, closed);
|
|
16682
|
+
}
|
|
16683
|
+
}
|
|
16684
|
+
__name(assertAccountCheckout, "assertAccountCheckout");
|
|
16674
16685
|
function assertCheckoutPayable(checkout, authoritative, cartID, sourceExecutionID) {
|
|
16675
16686
|
const current = authoritative?.checkout ?? checkout.checkout;
|
|
16676
16687
|
const deadlineClosed = authoritative?.payment_remaining_seconds === 0 || current.expires_at !== void 0 && (!authoritative?.server_now || Date.parse(current.expires_at) <= Date.parse(authoritative.server_now));
|
|
@@ -17599,6 +17610,12 @@ function railActionError(error, serviceExecutionID, actionType) {
|
|
|
17599
17610
|
__name(railActionError, "railActionError");
|
|
17600
17611
|
var railInputRecoveryInstruction = "Agent\u6309\u5F53\u524D\u6A21\u677F\u81EA\u884C\u4FEE\u6B63\u9519\u8BEF\u5B57\u6BB5\u548CJSON\u5C42\u7EA7\uFF0C\u4FDD\u7559\u5DF2\u6709\u6458\u8981\u7684\u7AEF\u70B9\u542B\u4E49\u53CA\u539F\u5730\u70B9/\u65E5\u671F/\u4EBA\u6570\uFF0C\u4E0D\u91CD\u590D\u7814\u7A76\u6216\u4E8B\u540E\u8865\u5199\u5192\u5145\u67E5\u8BE2\u524D\u6458\u8981\uFF1B\u4E0D\u8981\u5411\u7528\u6237\u8BE2\u95EE\u6280\u672F\u5B57\u6BB5\u3002\u53EA\u6709\u771F\u5B9E\u4E1A\u52A1\u6B67\u4E49\u624D\u95EE\u4EBA\uFF1B\u4F7F\u7528\u8FD4\u56DE\u7684\u6267\u884C\u8EAB\u4EFD\u6062\u590D\uFF0C\u672A\u521B\u5EFA\u65F6\u7528\u539F\u670D\u52A1\u3002";
|
|
17601
17612
|
|
|
17613
|
+
// src/services/shared/workflow-actor.ts
|
|
17614
|
+
function workflowSubmissionActor(action) {
|
|
17615
|
+
return action.submission_actor === "agent" ? "agent" : "human";
|
|
17616
|
+
}
|
|
17617
|
+
__name(workflowSubmissionActor, "workflowSubmissionActor");
|
|
17618
|
+
|
|
17602
17619
|
// src/services/rail/review.ts
|
|
17603
17620
|
function railWorkflowEnvelope(model) {
|
|
17604
17621
|
const execution = model.execution;
|
|
@@ -17744,7 +17761,7 @@ function railWorkflowEnvelope(model) {
|
|
|
17744
17761
|
...sides.some((side) => side.status !== "resolved" && !side.candidates?.length) ? {} : { interaction: {
|
|
17745
17762
|
schema_version: "itpay.interaction.v1",
|
|
17746
17763
|
stage: "location_confirmation_required",
|
|
17747
|
-
input_template: fileInputTemplate(`itpay services action ${id} --action ${action.action_type} --actor-type
|
|
17764
|
+
input_template: fileInputTemplate(`itpay services action ${id} --action ${action.action_type} --actor-type ${workflowSubmissionActor(action)} --status approved --input-json <\u5730\u70B9\u786E\u8BA4.json> --json`, { ...railInputTemplate(action.input_schema), ...requiredFields.includes("choices") ? { choices: Object.fromEntries(sides.filter((side) => side.candidates?.length).map((side) => [side.side, "<\u6240\u9009\u5019\u9009id>"])) } : {} }, requiredFields, { executionID: id, userAnswerRequired: true })
|
|
17748
17765
|
} },
|
|
17749
17766
|
recovery: []
|
|
17750
17767
|
};
|
|
@@ -17794,7 +17811,7 @@ function railWorkflowEnvelope(model) {
|
|
|
17794
17811
|
interaction: {
|
|
17795
17812
|
schema_version: "itpay.interaction.v1",
|
|
17796
17813
|
stage: "confirmation_required",
|
|
17797
|
-
input_template: fileInputTemplate(`itpay services action ${id} --action ${action.action_type} --actor-type
|
|
17814
|
+
input_template: fileInputTemplate(`itpay services action ${id} --action ${action.action_type} --actor-type ${workflowSubmissionActor(action)} --status approved --input-json <file> --json`, railInputTemplate(action.input_schema), requiredFields, { executionID: id, userAnswerRequired: true })
|
|
17798
17815
|
},
|
|
17799
17816
|
recovery: []
|
|
17800
17817
|
};
|
|
@@ -17837,7 +17854,7 @@ function railWorkflowEnvelope(model) {
|
|
|
17837
17854
|
stage: inputTemplate ? "input_required" : "payment",
|
|
17838
17855
|
...inputTemplate ? { input_template: inputTemplate } : {},
|
|
17839
17856
|
...state === "payment" && model.workflow?.human_action?.context?.review ? {
|
|
17840
|
-
revise_template: fileInputTemplate(`itpay services action ${id} --action ${model.workflow.human_action.action_type} --actor-type
|
|
17857
|
+
revise_template: fileInputTemplate(`itpay services action ${id} --action ${model.workflow.human_action.action_type} --actor-type ${workflowSubmissionActor(model.workflow.human_action)} --status approved --input-json <file> --json`, railInputTemplate(model.workflow.human_action.input_schema), requiredInputFields(model.workflow.human_action.input_schema), { executionID: id, userAnswerRequired: true })
|
|
17841
17858
|
} : {}
|
|
17842
17859
|
}
|
|
17843
17860
|
} : {},
|
|
@@ -19090,7 +19107,7 @@ function workflowEnvelope(model) {
|
|
|
19090
19107
|
instruction: "\u5C55\u793A\u672C\u6B21\u64CD\u4F5C\u7684\u5F85\u786E\u8BA4\u5185\u5BB9\uFF1B\u5DF2\u6709\u660E\u786E\u540C\u610F\u4E14\u76EE\u6807\u4E0E\u7248\u672C\u672A\u53D8\u65F6\u6CBF\u7528\uFF0C\u53EA\u8865\u7F3A\u5931\u7684\u771F\u5B9E\u540C\u610F\u3002\u6309\u5B8C\u6574\u6A21\u677F\u63D0\u4EA4\u540C\u4E00\u6267\u884C\uFF1B\u9009\u62E9\u5BF9\u8C61\u4E0D\u7B49\u4E8E\u8D2D\u4E70\u6279\u51C6\u3002",
|
|
19091
19108
|
next: null,
|
|
19092
19109
|
recovery: [],
|
|
19093
|
-
interaction: { schema_version: "itpay.interaction.v1", stage: "confirmation_required", input_template: fileInputTemplate(`itpay services action ${id} --action ${action.action_type} --actor-type
|
|
19110
|
+
interaction: { schema_version: "itpay.interaction.v1", stage: "confirmation_required", input_template: fileInputTemplate(`itpay services action ${id} --action ${action.action_type} --actor-type ${workflowSubmissionActor(action)} --status approved --input-json <file> --json`, serviceInputTemplate(action.input_schema), requiredInputFields(action.input_schema), { executionID: id, userAnswerRequired: true }) }
|
|
19094
19111
|
};
|
|
19095
19112
|
const inputRequired = state === "input_required";
|
|
19096
19113
|
const failed = ["failed", "recovery_required", "cancelled"].includes(state);
|
|
@@ -19363,17 +19380,6 @@ async function presentServiceCheckout(backend, config, serviceExecutionID, respo
|
|
|
19363
19380
|
const host = options.host ?? "terminal";
|
|
19364
19381
|
const currentModel = options.readModel;
|
|
19365
19382
|
const checkout = response.checkout;
|
|
19366
|
-
assertCheckoutCreation(checkout, response.cart.cart_id, serviceExecutionID);
|
|
19367
|
-
options.persistHandoff?.({
|
|
19368
|
-
serviceExecutionID,
|
|
19369
|
-
cartID: response.cart.cart_id,
|
|
19370
|
-
checkoutID: checkout.checkout.checkout_id,
|
|
19371
|
-
displayToken: checkout.display_token,
|
|
19372
|
-
checkoutURL: tokenizedCheckoutURL(checkout.checkout_url, checkout.display_token, checkout.qr_payload)
|
|
19373
|
-
});
|
|
19374
|
-
const authoritative = checkout.display_token ? await backend.getCheckoutPresentation(checkout.checkout.checkout_id, checkout.display_token, void 0, { deadline }) : void 0;
|
|
19375
|
-
assertCheckoutPayable(checkout, authoritative, response.cart.cart_id, serviceExecutionID);
|
|
19376
|
-
if (authoritative) response.cart.items = authoritative.items;
|
|
19377
19383
|
const checkoutID = checkout.checkout.checkout_id;
|
|
19378
19384
|
const agentType = options.agentType ?? config.agentType;
|
|
19379
19385
|
if (agentType === "dot" || agentType === "muse") {
|
|
@@ -19384,14 +19390,25 @@ async function presentServiceCheckout(backend, config, serviceExecutionID, respo
|
|
|
19384
19390
|
} catch {
|
|
19385
19391
|
}
|
|
19386
19392
|
const readOriginal = { command: `itpay --agent-type ${agentType} services get ${serviceExecutionID} --json`, reason: "\u7528\u6237\u5B8C\u6210\u9875\u9762\u64CD\u4F5C\u540E\u8BFB\u53D6\u539F\u4EFB\u52A1\u4E8B\u5B9E" };
|
|
19387
|
-
if (!entry || entry.access !== "account_session" || entry.url !== checkout.checkout_url || !url || !isPresentableURL(entry.url, config.baseURL) || url.protocol !== "https:" || url.username || url.password || url.search || url.hash || url.pathname !== `/checkout/${encodeURIComponent(checkoutID)}`) {
|
|
19393
|
+
if (!entry || entry.access !== "account_session" || entry.purpose !== "checkout" || entry.url !== checkout.checkout_url || !url || !isPresentableURL(entry.url, config.baseURL) || url.protocol !== "https:" || url.username || url.password || url.search || url.hash || url.pathname !== `/checkout/${encodeURIComponent(checkoutID)}`) {
|
|
19388
19394
|
throw new CommandContractError("secure_handoff_unavailable", "original purchase has no verified account-session entry", "\u4FDD\u7559\u539F\u8D2D\u4E70\uFF1B\u5F53\u524D\u8D26\u53F7\u5B89\u5168\u5165\u53E3\u4E0D\u53EF\u7528\uFF0C\u4E0D\u5C55\u793A\u6216\u62FC\u63A5 bearer \u94FE\u63A5\uFF0C\u4E0D\u6362\u8EAB\u4EFD\u6216\u91CD\u5EFA\u8D2D\u4E70\u3002", [readOriginal], void 0, { service_execution_id: serviceExecutionID, checkout_id: checkoutID });
|
|
19389
19395
|
}
|
|
19390
|
-
|
|
19396
|
+
assertAccountCheckout(checkout, response.cart.cart_id, serviceExecutionID);
|
|
19391
19397
|
const effects = { page_created: !response.handoff_reissued, page_reused: response.handoff_reissued === true, payment_requested: false, charged: false, human_page_action_required: true };
|
|
19392
|
-
writeCommandEnvelope2({ status: "human_checkout_required", result: { service_execution_id: serviceExecutionID, checkout_id: checkoutID, amount: formatMoney(checkout.checkout.amount_minor, checkout.checkout.currency), effects,
|
|
19398
|
+
writeCommandEnvelope2({ status: "human_checkout_required", result: { service_execution_id: serviceExecutionID, checkout_id: checkoutID, amount: formatMoney(checkout.checkout.amount_minor, checkout.checkout.currency), effects, agent_facts: presentAgent({ service_execution_id: serviceExecutionID, checkout_id: checkoutID, status: "human_checkout_required", checkout: { official_entry: entry }, effects }, { allowedOrigins: OFFICIAL_BACKEND_URLS }) }, handoff: { url: entry.url, purpose: entry.purpose, access: entry.access, ...entry.expires_at ? { expires_at: entry.expires_at } : {} }, instruction: "\u7ACB\u5373\u5C55\u793A\u5B98\u65B9\u94FE\u63A5\u53CA\u91D1\u989D\uFF1B\u7528\u6237\u767B\u5F55\u53D1\u8D77\u8FDE\u63A5\u7684\u8D26\u53F7\u5B8C\u6210\u5F53\u524D\u6B65\u9AA4\u3002\u4E8C\u7EF4\u7801\u4E0D\u662F\u524D\u7F6E\u6761\u4EF6\uFF0C\u6253\u5F00\u94FE\u63A5\u4E0D\u4EE3\u8868\u4ED8\u6B3E\u6216\u51FA\u7968\u3002\u7528\u6237\u8868\u793A\u5B8C\u6210\u540E\u8BFB\u53D6\u539F\u4EFB\u52A1\u4E8B\u5B9E\uFF0C\u4E0D\u91CD\u590D\u786E\u8BA4\u3001\u6362\u5355\u6216\u81EA\u52A8\u4ED8\u6B3E\u3002", next: readOriginal, recovery: [] }, { ...options.jsonOutput !== void 0 ? { jsonOutput: options.jsonOutput } : {}, ...options.output ? { output: options.output } : {} });
|
|
19393
19399
|
return;
|
|
19394
19400
|
}
|
|
19401
|
+
assertCheckoutCreation(checkout, response.cart.cart_id, serviceExecutionID);
|
|
19402
|
+
options.persistHandoff?.({
|
|
19403
|
+
serviceExecutionID,
|
|
19404
|
+
cartID: response.cart.cart_id,
|
|
19405
|
+
checkoutID: checkout.checkout.checkout_id,
|
|
19406
|
+
displayToken: checkout.display_token,
|
|
19407
|
+
checkoutURL: tokenizedCheckoutURL(checkout.checkout_url, checkout.display_token, checkout.qr_payload)
|
|
19408
|
+
});
|
|
19409
|
+
const authoritative = checkout.display_token ? await backend.getCheckoutPresentation(checkout.checkout.checkout_id, checkout.display_token, void 0, { deadline }) : void 0;
|
|
19410
|
+
assertCheckoutPayable(checkout, authoritative, response.cart.cart_id, serviceExecutionID);
|
|
19411
|
+
if (authoritative) response.cart.items = authoritative.items;
|
|
19395
19412
|
const displayToken = checkout.display_token;
|
|
19396
19413
|
const locale = normalizeCardLocale(options.locale);
|
|
19397
19414
|
const checkoutURL = tokenizedCheckoutURL(checkout.checkout_url, displayToken, checkout.qr_payload);
|
package/dist/src/state/config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itpay/cli",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.59",
|
|
4
4
|
"description": "The ItPay CLI for services, orders, and human-authorized purchased content.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -148,5 +148,5 @@
|
|
|
148
148
|
"services",
|
|
149
149
|
"api"
|
|
150
150
|
],
|
|
151
|
-
"gitHead": "
|
|
151
|
+
"gitHead": "59b0086e1133b9d10a26ee3703ce7591d3bee825"
|
|
152
152
|
}
|