@intentic/sandbox-contract 1.415.1 → 1.416.1
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/contracts/runner.contract.d.ts +246 -246
- package/dist/contracts/system.contract.d.ts +18 -18
- package/dist/models/plan-pools.d.ts +2 -13
- package/dist/models/plan-pools.d.ts.map +1 -1
- package/dist/models/plan-pools.js +7 -41
- package/dist/models/plan-pools.js.map +1 -1
- package/dist/models/verdict/refusal-verdict.d.ts +2 -0
- package/dist/models/verdict/refusal-verdict.d.ts.map +1 -1
- package/dist/models/verdict/refusal-verdict.js +24 -2
- package/dist/models/verdict/refusal-verdict.js.map +1 -1
- package/dist/models/verdict/window-period.d.ts +13 -0
- package/dist/models/verdict/window-period.d.ts.map +1 -0
- package/dist/models/verdict/window-period.js +37 -0
- package/dist/models/verdict/window-period.js.map +1 -0
- package/dist/protocol/doors/webext-links.d.ts +1 -0
- package/dist/protocol/doors/webext-links.d.ts.map +1 -1
- package/dist/protocol/doors/webext-links.js +1 -0
- package/dist/protocol/doors/webext-links.js.map +1 -1
- package/package.json +5 -5
- package/src/models/plan-pools.test.ts +46 -3
- package/src/models/plan-pools.ts +11 -64
- package/src/models/verdict/refusal-verdict.ts +48 -3
- package/src/models/verdict/window-period.ts +57 -0
- package/src/protocol/doors/webext-links.ts +4 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// How long a pool's window runs, read off the provider's own key and whatever name it published. One implementation,
|
|
2
|
+
// because two things need it and must agree: a narrow column names the window by `short`, and a reading with no
|
|
3
|
+
// published reset instant may only be trusted for `seconds` past the moment it was taken.
|
|
4
|
+
|
|
5
|
+
export interface WindowPeriod {
|
|
6
|
+
readonly seconds: number;
|
|
7
|
+
// The token a narrow column names this window by, e.g. "5h", "wk".
|
|
8
|
+
readonly short: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const HOUR_SECONDS = 3_600;
|
|
12
|
+
const DAY_SECONDS = 86_400;
|
|
13
|
+
|
|
14
|
+
/** Kind and label as space-padded lowercase words, underscores split, so `\b` matches across both spellings. */
|
|
15
|
+
export const periodWords = (pool: { readonly kind: string; readonly label?: string | undefined }): string =>
|
|
16
|
+
` ${`${pool.kind} ${pool.label ?? ""}`
|
|
17
|
+
.toLowerCase()
|
|
18
|
+
.replaceAll(/[^a-z0-9]+/gu, " ")
|
|
19
|
+
.trim()} `;
|
|
20
|
+
|
|
21
|
+
// A count the words spell out, e.g. the 3 in "3 days".
|
|
22
|
+
const counted = (words: string, pattern: RegExp): number | undefined => {
|
|
23
|
+
const found = pattern.exec(words)?.[1];
|
|
24
|
+
return found === undefined ? undefined : Number(found);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// Day-scale and longer, where the named periods outrank a bare count: "7 days" is the week every plan sells, not a
|
|
28
|
+
// seven-day span of its own.
|
|
29
|
+
const dayPeriod = (words: string, days: number | undefined): WindowPeriod | undefined => {
|
|
30
|
+
if (days === 7 || /\bseven days?\b|\bweek(ly|s)?\b/u.test(words)) {
|
|
31
|
+
return { seconds: 7 * DAY_SECONDS, short: "wk" };
|
|
32
|
+
}
|
|
33
|
+
if (/\bmonth(ly|s)?\b/u.test(words)) {
|
|
34
|
+
return { seconds: 30 * DAY_SECONDS, short: "mo" };
|
|
35
|
+
}
|
|
36
|
+
if (days === 1 || /\bdaily\b/u.test(words)) {
|
|
37
|
+
return { seconds: DAY_SECONDS, short: "24h" };
|
|
38
|
+
}
|
|
39
|
+
return days === undefined ? undefined : { seconds: days * DAY_SECONDS, short: `${days}d` };
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/** Window length behind a pool; undefined when neither the key nor the name says how long it runs. */
|
|
43
|
+
export const windowPeriod = (pool: { readonly kind: string; readonly label?: string | undefined }): WindowPeriod | undefined => {
|
|
44
|
+
const words = periodWords(pool);
|
|
45
|
+
const hours = counted(words, /\b(\d+) hours?\b/u);
|
|
46
|
+
// Hours first: a pool named both ("5 hours, weekly cap") runs on the shorter clock.
|
|
47
|
+
if (hours !== undefined || /\bfive hours?\b/u.test(words)) {
|
|
48
|
+
const span = hours ?? 5;
|
|
49
|
+
return { seconds: span * HOUR_SECONDS, short: `${span}h` };
|
|
50
|
+
}
|
|
51
|
+
const day = dayPeriod(words, counted(words, /\b(\d+) days?\b/u));
|
|
52
|
+
if (day !== undefined) {
|
|
53
|
+
return day;
|
|
54
|
+
}
|
|
55
|
+
const minutes = counted(words, /\b(\d+) minutes?\b/u);
|
|
56
|
+
return minutes === undefined ? undefined : { seconds: minutes * 60, short: `${minutes}m` };
|
|
57
|
+
};
|
|
@@ -44,6 +44,10 @@ export const WEBEXT_MEDIA_SOURCE_HEADER = "x-intentic-source";
|
|
|
44
44
|
// browser and adds the ticket the file is collected with (the sandbox's webext/file-tickets.ts).
|
|
45
45
|
export const WEBEXT_UPLOAD_TOOL = "upload_file";
|
|
46
46
|
|
|
47
|
+
// The ChatGPT kit's send, whose `files` (sandbox paths) are ticketed the same way, one ticket per file, into its
|
|
48
|
+
// `tickets` in the same order.
|
|
49
|
+
export const WEBEXT_CHATGPT_SEND_TOOL = "chatgpt_send";
|
|
50
|
+
|
|
47
51
|
// How long a file ticket waits to be collected; the extension collects it before it asks the person anything.
|
|
48
52
|
export const WEBEXT_FILE_TICKET_TTL_MS = 60_000;
|
|
49
53
|
|