pairit 0.3.4 → 0.3.6
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 +2 -1
- package/dist/index.js +96 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -118,7 +118,8 @@ pairit --env staging admin activity # staging
|
|
|
118
118
|
survey-a r@example.com 1 (0/1) 0 9 40 html
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
-
- **Active**: sessions that have not finished
|
|
121
|
+
- **Active**: sessions that have not finished, changed in the last 15 minutes, and started in the last 12 hours. **Group** sessions have been matched into a group; **solo** ones have not.
|
|
122
|
+
- Older sessions that still change are listed under "Not counted". This is usually a browser tab left open on a page whose `html` component saves on a timer.
|
|
122
123
|
- **Waiting**: active sessions on a page with a `matchmaking` component that have not been matched yet.
|
|
123
124
|
- **Today**: sessions started in the last 24 hours. **Total**: all sessions of the config.
|
|
124
125
|
- **Flags**: `group` (the config has a matchmaking pool or component), then the features it uses: `chat`, `live-workspace`, `html`, `agents`.
|
package/dist/index.js
CHANGED
|
@@ -9567,7 +9567,12 @@ function formatActivity(report, options = {}) {
|
|
|
9567
9567
|
lines.push(row.live ? paint("1;31", `● ${text}`) : ` ${text}`);
|
|
9568
9568
|
}
|
|
9569
9569
|
lines.push("");
|
|
9570
|
-
|
|
9570
|
+
const stale = report.configs.filter((entry) => (entry.staleOpen ?? 0) > 0);
|
|
9571
|
+
if (stale.length > 0 && report.staleAfterHours) {
|
|
9572
|
+
lines.push(`Not counted: sessions that started over ${report.staleAfterHours} h ago but still change, usually a tab left open: ${stale.map((entry) => `${entry.configId} (${entry.staleOpen})`).join(", ")}.`);
|
|
9573
|
+
}
|
|
9574
|
+
const started = report.staleAfterHours ? `, changed in the last ${report.activeWindowMinutes} min, and started in the last ${report.staleAfterHours} h` : ` and changed in the last ${report.activeWindowMinutes} min`;
|
|
9575
|
+
lines.push(`Since ${report.since}. Active: not finished${started}. Today: started in the last 24 h.`);
|
|
9571
9576
|
return lines.join(`
|
|
9572
9577
|
`);
|
|
9573
9578
|
}
|
|
@@ -9803,6 +9808,94 @@ async function loadKeytar() {
|
|
|
9803
9808
|
}
|
|
9804
9809
|
}
|
|
9805
9810
|
|
|
9811
|
+
// src/group-lint.ts
|
|
9812
|
+
var GROUP_PATH = /^group(?:\.[A-Za-z0-9_]+)*/;
|
|
9813
|
+
var TEMPLATE = /\{\{\s*(group\.[A-Za-z0-9_.]+)\s*\}\}/g;
|
|
9814
|
+
function lintGroupView(config) {
|
|
9815
|
+
const errors = [];
|
|
9816
|
+
const shared = new Set;
|
|
9817
|
+
if (Array.isArray(config.matchmaking)) {
|
|
9818
|
+
config.matchmaking.forEach((pool, index) => {
|
|
9819
|
+
const share = pool?.share;
|
|
9820
|
+
if (share === undefined)
|
|
9821
|
+
return;
|
|
9822
|
+
if (!Array.isArray(share) || !share.every((key) => typeof key === "string" && /^\w+$/.test(key))) {
|
|
9823
|
+
errors.push(`matchmaking[${index}].share must be a list of session_state keys`);
|
|
9824
|
+
return;
|
|
9825
|
+
}
|
|
9826
|
+
for (const key of share)
|
|
9827
|
+
shared.add(key);
|
|
9828
|
+
});
|
|
9829
|
+
}
|
|
9830
|
+
const fields = new Map;
|
|
9831
|
+
for (const page of config.pages ?? []) {
|
|
9832
|
+
for (const component of page.components ?? []) {
|
|
9833
|
+
const c = component;
|
|
9834
|
+
if (c?.type !== "live-workspace" || c.props?.scope !== "group" || c.props?.mode !== "structured" || !Array.isArray(c.props.fields))
|
|
9835
|
+
continue;
|
|
9836
|
+
for (const field of c.props.fields) {
|
|
9837
|
+
const id = field?.id;
|
|
9838
|
+
if (typeof id !== "string")
|
|
9839
|
+
continue;
|
|
9840
|
+
const other = fields.get(id);
|
|
9841
|
+
if (other && other !== page.id) {
|
|
9842
|
+
errors.push(`group workspace field ${id} is on both ${other} and ${page.id}; group.ws needs unique field ids`);
|
|
9843
|
+
}
|
|
9844
|
+
fields.set(id, page.id ?? "");
|
|
9845
|
+
}
|
|
9846
|
+
}
|
|
9847
|
+
}
|
|
9848
|
+
const checkPath = (where, path2) => {
|
|
9849
|
+
const [, part, ...rest] = path2.split(".");
|
|
9850
|
+
if (part === "ws") {
|
|
9851
|
+
const field = rest[0];
|
|
9852
|
+
if (field && !fields.has(field)) {
|
|
9853
|
+
errors.push(`${where}: ${path2} is not a field of a structured group workspace`);
|
|
9854
|
+
}
|
|
9855
|
+
return;
|
|
9856
|
+
}
|
|
9857
|
+
if (part === "others") {
|
|
9858
|
+
const [index, key] = rest;
|
|
9859
|
+
if (index !== undefined && !/^\d+$/.test(index)) {
|
|
9860
|
+
errors.push(`${where}: ${path2} needs a member number, like group.others.0`);
|
|
9861
|
+
} else if (key && !shared.has(key)) {
|
|
9862
|
+
errors.push(`${where}: ${path2} reads ${key}, which no matchmaking pool lists in share`);
|
|
9863
|
+
}
|
|
9864
|
+
return;
|
|
9865
|
+
}
|
|
9866
|
+
errors.push(`${where}: ${path2} should start with group.ws or group.others`);
|
|
9867
|
+
};
|
|
9868
|
+
const walk = (where, value, key) => {
|
|
9869
|
+
if (typeof value === "string") {
|
|
9870
|
+
if (key === "when") {
|
|
9871
|
+
const path2 = value.trim().match(GROUP_PATH)?.[0];
|
|
9872
|
+
if (path2 && path2 !== "group")
|
|
9873
|
+
checkPath(where, path2);
|
|
9874
|
+
}
|
|
9875
|
+
for (const match of value.matchAll(TEMPLATE))
|
|
9876
|
+
checkPath(where, match[1]);
|
|
9877
|
+
return;
|
|
9878
|
+
}
|
|
9879
|
+
if (Array.isArray(value)) {
|
|
9880
|
+
for (const item of value)
|
|
9881
|
+
walk(where, item);
|
|
9882
|
+
return;
|
|
9883
|
+
}
|
|
9884
|
+
if (value && typeof value === "object") {
|
|
9885
|
+
for (const [k, v] of Object.entries(value))
|
|
9886
|
+
walk(where, v, k);
|
|
9887
|
+
}
|
|
9888
|
+
};
|
|
9889
|
+
config.pages?.forEach((page, index) => {
|
|
9890
|
+
walk(page.id ?? `pages[${index}]`, page);
|
|
9891
|
+
});
|
|
9892
|
+
config.agents?.forEach((agent, index) => {
|
|
9893
|
+
const id = agent?.id;
|
|
9894
|
+
walk(typeof id === "string" ? `agent ${id}` : `agents[${index}]`, agent);
|
|
9895
|
+
});
|
|
9896
|
+
return errors;
|
|
9897
|
+
}
|
|
9898
|
+
|
|
9806
9899
|
// src/html-assets.ts
|
|
9807
9900
|
import { readFile as readFile2, stat } from "node:fs/promises";
|
|
9808
9901
|
import path2 from "node:path";
|
|
@@ -10022,7 +10115,7 @@ function singleGroupSize(config) {
|
|
|
10022
10115
|
|
|
10023
10116
|
// src/index.ts
|
|
10024
10117
|
var program2 = new Command;
|
|
10025
|
-
program2.name("pairit").description("CLI for Pairit experiment configs").version("0.3.
|
|
10118
|
+
program2.name("pairit").description("CLI for Pairit experiment configs").version("0.3.6").option("--env <name>", "Target environment: staging or production", (value) => {
|
|
10026
10119
|
try {
|
|
10027
10120
|
return parseEnvName(value);
|
|
10028
10121
|
} catch (error) {
|
|
@@ -10341,6 +10434,7 @@ async function lintConfig(configPath) {
|
|
|
10341
10434
|
});
|
|
10342
10435
|
}
|
|
10343
10436
|
errors.push(...lintRandomization(config));
|
|
10437
|
+
errors.push(...lintGroupView(config));
|
|
10344
10438
|
if (errors.length) {
|
|
10345
10439
|
throw new Error(errors.join(", "));
|
|
10346
10440
|
}
|