@clipwright/core 0.85.0 → 0.86.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/dist/api-failure.js +6 -5
- package/dist/errors.d.ts +4 -0
- package/dist/errors.js +8 -3
- package/dist/public-endpoints.d.ts +1 -0
- package/dist/public-endpoints.js +1 -0
- package/package.json +1 -1
package/dist/api-failure.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { accountNotAdmittedError, apiError, debtOutstandingError, editCeilingReachedError, editConflictError, editingDisabledError, editingNotPricedError, editInvalidError, insufficientCreditsError, maxCreditsExceededError, runNotEditableError, } from "./errors.js";
|
|
3
|
-
import { PUBLIC_APP_BASE_URL } from "./public-endpoints.js";
|
|
2
|
+
import { accountNotAdmittedError, apiError, creditsShort, debtOutstandingError, editCeilingReachedError, editConflictError, editingDisabledError, editingNotPricedError, editInvalidError, insufficientCreditsError, maxCreditsExceededError, runNotEditableError, } from "./errors.js";
|
|
3
|
+
import { PUBLIC_APP_BASE_URL, PUBLIC_BILLING_URL } from "./public-endpoints.js";
|
|
4
4
|
import { rateLimitedError } from "./rate-limit.js";
|
|
5
5
|
import { workflowCommandErrorRead } from "./contracts/v1/workflow-execution.js";
|
|
6
6
|
export function isRetryableFailure(failure) {
|
|
@@ -265,7 +265,8 @@ export const UNAUTHORIZED_NEXT_ACTION = "STOP. Clipwright did not accept this co
|
|
|
265
265
|
"CLIPWRIGHT_API_KEY, never in the chat, and restarts the host. With the hosted connector, the human reconnects it and " +
|
|
266
266
|
"signs in again. Then call get_account, which is free, to confirm.";
|
|
267
267
|
export const PURCHASE_NEEDED_NEXT_ACTION = "STOP. Do NOT retry: this call needs bought credits, and repeating it gives the same answer. Tell the user to buy a " +
|
|
268
|
-
`credit pack or pick a plan at ${
|
|
268
|
+
`credit pack or pick a plan at ${PUBLIC_BILLING_URL}, then call again. Nothing was charged and no run was created.`;
|
|
269
|
+
const shortBy = (need) => creditsShort(need) > 0 ? ` (${creditsShort(need)} short)` : "";
|
|
269
270
|
export function refusalNextAction(next) {
|
|
270
271
|
const fields = next.add.length ? ` Change ${next.add.join(", ")} first.` : "";
|
|
271
272
|
return `STOP. Do NOT retry unchanged: ${next.note}${fields} Then call ${next.action} (next has its route and arguments). ` +
|
|
@@ -298,8 +299,8 @@ export function agentFailureReport(failure) {
|
|
|
298
299
|
code: "insufficient_credits",
|
|
299
300
|
retryable: false,
|
|
300
301
|
next_action: `STOP. Do NOT retry: this account has ${failure.balanceCredits} credits and the call ` +
|
|
301
|
-
`needs ${failure.requiredCredits}. Retrying cannot change that. Tell the user to
|
|
302
|
-
|
|
302
|
+
`needs ${failure.requiredCredits}${shortBy(failure)}. Retrying cannot change that. Tell the user to buy a credit ` +
|
|
303
|
+
`pack or pick a plan at ${PUBLIC_BILLING_URL}, then call again. Nothing was charged and no run was created.`,
|
|
303
304
|
balance_credits: failure.balanceCredits,
|
|
304
305
|
required_credits: failure.requiredCredits,
|
|
305
306
|
};
|
package/dist/errors.d.ts
CHANGED
|
@@ -74,6 +74,10 @@ export declare function insufficientCreditsBody(args: {
|
|
|
74
74
|
requiredCredits: number;
|
|
75
75
|
note?: string | undefined;
|
|
76
76
|
}): InsufficientCreditsError;
|
|
77
|
+
export declare function creditsShort(args: {
|
|
78
|
+
balanceCredits: number;
|
|
79
|
+
requiredCredits: number;
|
|
80
|
+
}): number;
|
|
77
81
|
export declare function creditsNeededSentence(args: {
|
|
78
82
|
balanceCredits: number;
|
|
79
83
|
requiredCredits: number;
|
package/dist/errors.js
CHANGED
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { diyNext } from "./diy-next.js";
|
|
3
3
|
import { EDIT_ISSUE_CODES } from "./edit-validate.js";
|
|
4
4
|
import { workflowCommandError } from "./contracts/v1/workflow-execution.js";
|
|
5
|
+
import { PUBLIC_BILLING_URL } from "./public-endpoints.js";
|
|
5
6
|
import { actorCreationLimitedError, rateLimitedError } from "./rate-limit.js";
|
|
6
7
|
export const apiError = z.object({
|
|
7
8
|
error: z.object({
|
|
@@ -59,19 +60,23 @@ export function insufficientCreditsBody(args) {
|
|
|
59
60
|
error: {
|
|
60
61
|
code: "insufficient_credits",
|
|
61
62
|
message: `${creditsNeededSentence(args)} ` +
|
|
62
|
-
|
|
63
|
+
`Buy credits at ${PUBLIC_BILLING_URL} and retry; nothing was charged and no run was created.` +
|
|
64
|
+
(args.note === undefined ? "" : ` ${args.note}`),
|
|
63
65
|
balance_credits: args.balanceCredits,
|
|
64
66
|
required_credits: args.requiredCredits,
|
|
65
67
|
},
|
|
66
68
|
});
|
|
67
69
|
}
|
|
70
|
+
export function creditsShort(args) {
|
|
71
|
+
return Math.max(0, args.requiredCredits - args.balanceCredits);
|
|
72
|
+
}
|
|
68
73
|
export function creditsNeededSentence(args) {
|
|
69
|
-
const short = args
|
|
74
|
+
const short = creditsShort(args);
|
|
70
75
|
return (`This run needs ${args.requiredCredits} credits, the account has ${args.balanceCredits}` +
|
|
71
76
|
(short > 0 ? ` (${short} short).` : "."));
|
|
72
77
|
}
|
|
73
78
|
export function insufficientCreditsWarning(args) {
|
|
74
|
-
return (`${creditsNeededSentence(args)}
|
|
79
|
+
return (`${creditsNeededSentence(args)} Starting it will be refused with insufficient_credits ` +
|
|
75
80
|
"until the account buys credits.");
|
|
76
81
|
}
|
|
77
82
|
export function debtOutstandingWarning(args) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const PUBLIC_API_BASE_URL = "https://api.clipwright.io";
|
|
2
2
|
export declare const PUBLIC_APP_BASE_URL = "https://app.clipwright.io";
|
|
3
|
+
export declare const PUBLIC_BILLING_URL = "https://app.clipwright.io/billing";
|
|
3
4
|
export declare const PUBLIC_SITE_BASE_URL = "https://clipwright.io";
|
|
4
5
|
export declare const PUBLIC_MCP_URL = "https://mcp.clipwright.io/mcp";
|
|
5
6
|
export declare const MCP_SERVER_TITLE = "Clipwright.io";
|
package/dist/public-endpoints.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export const PUBLIC_API_BASE_URL = "https://api.clipwright.io";
|
|
2
2
|
export const PUBLIC_APP_BASE_URL = "https://app.clipwright.io";
|
|
3
|
+
export const PUBLIC_BILLING_URL = `${PUBLIC_APP_BASE_URL}/billing`;
|
|
3
4
|
export const PUBLIC_SITE_BASE_URL = "https://clipwright.io";
|
|
4
5
|
export const PUBLIC_MCP_URL = "https://mcp.clipwright.io/mcp";
|
|
5
6
|
export const MCP_SERVER_TITLE = "Clipwright.io";
|