@modelprofile.com/flexharness 12.5.0 → 13.0.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_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/classes.flexharness.callbacks.js +10 -3
- package/dist_ts/classes.flexharness.core.js +4 -2
- package/dist_ts/classes.flexharness.permissions.js +11 -3
- package/dist_ts/classes.flexharness.prompts.js +11 -2
- package/dist_ts/classes.flexharness.reversions.js +21 -6
- package/dist_ts/classes.flexharness.runs.js +13 -7
- package/dist_ts/classes.flexharness.subagents.js +4 -5
- package/dist_ts/errors.d.ts +8 -2
- package/dist_ts/errors.js +13 -5
- package/dist_ts/interfaces.d.ts +27 -0
- package/dist_ts/interfaces.flexharness.d.ts +3 -1
- package/dist_ts/interfaces.js +7 -1
- package/dist_ts/utils.flexharness.d.ts +8 -2
- package/dist_ts/utils.flexharness.js +13 -3
- package/dist_ts/utils.json.js +9 -2
- package/dist_ts/utils.sessionpreview.d.ts +7 -0
- package/dist_ts/utils.sessionpreview.js +35 -0
- package/package.json +3 -3
- package/readme.md +8 -4
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.flexharness.callbacks.ts +9 -3
- package/ts/classes.flexharness.core.ts +2 -1
- package/ts/classes.flexharness.permissions.ts +8 -2
- package/ts/classes.flexharness.prompts.ts +9 -1
- package/ts/classes.flexharness.reversions.ts +21 -5
- package/ts/classes.flexharness.runs.ts +11 -4
- package/ts/classes.flexharness.subagents.ts +3 -3
- package/ts/errors.ts +13 -4
- package/ts/interfaces.flexharness.ts +3 -0
- package/ts/interfaces.ts +33 -0
- package/ts/readme.md +8 -4
- package/ts/utils.flexharness.ts +16 -2
- package/ts/utils.json.ts +12 -1
- package/ts/utils.sessionpreview.ts +32 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { FLEX_PROJECT_MANAGEMENT_LIMITS, type IFlexMessage } from './interfaces.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What a session is about before anyone titles it: the text of its first prompt that has any, as
|
|
5
|
+
* one line (every run of whitespace becomes one space), cut to the title bound at a character
|
|
6
|
+
* boundary. Undefined while no prompt carries text.
|
|
7
|
+
*/
|
|
8
|
+
export function sessionPreview(messagesArg: readonly IFlexMessage[]): string | undefined {
|
|
9
|
+
for (const message of messagesArg) {
|
|
10
|
+
if (message.role !== 'user') continue;
|
|
11
|
+
const text = message.parts
|
|
12
|
+
.map((part) => (part.type === 'text' ? part.text : ''))
|
|
13
|
+
.join(' ')
|
|
14
|
+
.replace(/\s+/gu, ' ')
|
|
15
|
+
.trim();
|
|
16
|
+
if (text) return utf8Prefix(text, FLEX_PROJECT_MANAGEMENT_LIMITS.maxTitleBytes);
|
|
17
|
+
}
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** The longest prefix of whole characters within `maxBytesArg` UTF-8 bytes. */
|
|
22
|
+
function utf8Prefix(valueArg: string, maxBytesArg: number): string {
|
|
23
|
+
if (Buffer.byteLength(valueArg, 'utf8') <= maxBytesArg) return valueArg;
|
|
24
|
+
let bytes = 0;
|
|
25
|
+
let end = 0;
|
|
26
|
+
for (const character of valueArg) {
|
|
27
|
+
bytes += Buffer.byteLength(character, 'utf8');
|
|
28
|
+
if (bytes > maxBytesArg) break;
|
|
29
|
+
end += character.length;
|
|
30
|
+
}
|
|
31
|
+
return valueArg.slice(0, end).trimEnd();
|
|
32
|
+
}
|