@hachej/boring-agent 0.4.62 → 0.4.64
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/conversations.js +8 -1
- package/dist/struggle.js +2 -1
- package/dist/target-block.d.ts +8 -0
- package/dist/target-block.js +25 -0
- package/package.json +3 -3
package/dist/conversations.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineDoc } from '@earendil-works/pi-durable';
|
|
2
2
|
import { RequestGuardError, hasJsonContentType, readJsonBody } from '@hachej/boring-files/request-guard';
|
|
3
3
|
import { MENTION_FILE_PREFIX } from './mentions.js';
|
|
4
|
+
import { withoutTarget } from './target-block.js';
|
|
4
5
|
/** The native document. `fork: 'initial'`: a fork made by `fork()` gets its own metadata in the creating commit; any other fork starts unmanaged. */
|
|
5
6
|
export const conversationMetadata = defineDoc({
|
|
6
7
|
kind: 'boring.conversation.metadata', checkpointWhen: () => false, version: 1, scope: 'conversation', history: 'latest', fork: 'initial',
|
|
@@ -9,7 +10,13 @@ export const conversationMetadata = defineDoc({
|
|
|
9
10
|
const managed = (meta, owner) => meta !== undefined && meta.owner !== '' && meta.deletedAt === null && (owner === undefined || meta.owner === owner);
|
|
10
11
|
/** What the person said: a leading `<target>{…}</target>` block (point-and-speak context) never becomes a title or a preview. */
|
|
11
12
|
const spoken = (text) => {
|
|
12
|
-
if (
|
|
13
|
+
if (text === undefined)
|
|
14
|
+
return undefined;
|
|
15
|
+
const said = withoutTarget(text);
|
|
16
|
+
if (said !== text)
|
|
17
|
+
return said.trim() || undefined;
|
|
18
|
+
// Metadata boundary: older or host-written text need not be canonical, so a `<target>` start that is not a valid block still never leaks.
|
|
19
|
+
if (!text.startsWith('<target>'))
|
|
13
20
|
return text;
|
|
14
21
|
const end = text.indexOf('</target>');
|
|
15
22
|
return end < 0 ? undefined : text.slice(end + 9).trim() || undefined;
|
package/dist/struggle.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { createHash } from 'node:crypto';
|
|
5
5
|
import { GenerationTask, ToolTask, defineExtension, hook } from '@earendil-works/pi-durable';
|
|
6
6
|
import { jsonSchemaTool } from './json-schema-tool.js';
|
|
7
|
+
import { withoutTarget } from './target-block.js';
|
|
7
8
|
export const REPORT_BUG_TOOL = 'report_bug';
|
|
8
9
|
export const BUG_CATEGORIES = ['tool_failed', 'impossible', 'person_says_wrong'];
|
|
9
10
|
/** Without a host sink an event is one structured log line, so nothing is lost before a host wires one. */
|
|
@@ -21,7 +22,7 @@ const userText = (message) => message.role !== 'user' ? '' : typeof message.cont
|
|
|
21
22
|
const asked = (message) => message?.role === 'assistant'
|
|
22
23
|
&& message.content.map(part => part.type === 'text' ? part.text : '').join('').trim().endsWith('?');
|
|
23
24
|
/** The person's words only: the block a point-and-speak message or a mention adds is not what they said. */
|
|
24
|
-
const words = (text) => new Set(text
|
|
25
|
+
const words = (text) => new Set(withoutTarget(text).replace(/<file[\s\S]*?<\/file>/g, '').toLowerCase().match(/[\p{L}\p{N}]+/gu) ?? []);
|
|
25
26
|
function rephrased(text, earlier) {
|
|
26
27
|
const said = words(text);
|
|
27
28
|
if (said.size < 3)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `<target>` block (point-and-speak) as the kit writes it: `<target>{JSON object, at most 1024 bytes}</target>`, a blank line, then what
|
|
3
|
+
* the person said. This is the one stripper packages/agent uses (conversation titles and previews, struggle detection). It repeats the kit's
|
|
4
|
+
* `withoutTarget` (`@hachej/boring-ui-kit/chat-view`) because this package has only a type edge to ui; `test/packages/target-grammar.test.mjs`
|
|
5
|
+
* runs one table through both. A block that is not valid by that rule is plain text.
|
|
6
|
+
*/
|
|
7
|
+
export declare function withoutTarget(text: string): string;
|
|
8
|
+
//# sourceMappingURL=target-block.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `<target>` block (point-and-speak) as the kit writes it: `<target>{JSON object, at most 1024 bytes}</target>`, a blank line, then what
|
|
3
|
+
* the person said. This is the one stripper packages/agent uses (conversation titles and previews, struggle detection). It repeats the kit's
|
|
4
|
+
* `withoutTarget` (`@hachej/boring-ui-kit/chat-view`) because this package has only a type edge to ui; `test/packages/target-grammar.test.mjs`
|
|
5
|
+
* runs one table through both. A block that is not valid by that rule is plain text.
|
|
6
|
+
*/
|
|
7
|
+
export function withoutTarget(text) {
|
|
8
|
+
if (!text.startsWith('<target>'))
|
|
9
|
+
return text;
|
|
10
|
+
const end = text.indexOf('</target>');
|
|
11
|
+
if (end < 0 || text.slice(end + 9, end + 11) !== '\n\n')
|
|
12
|
+
return text;
|
|
13
|
+
const json = text.slice(8, end);
|
|
14
|
+
if (new TextEncoder().encode(json).length > 1024)
|
|
15
|
+
return text;
|
|
16
|
+
try {
|
|
17
|
+
const target = JSON.parse(json);
|
|
18
|
+
if (target === null || typeof target !== 'object' || Array.isArray(target))
|
|
19
|
+
return text;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return text;
|
|
23
|
+
}
|
|
24
|
+
return text.slice(end + 11);
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hachej/boring-agent",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.64",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -188,8 +188,8 @@
|
|
|
188
188
|
"@earendil-works/pi-durable": "~1.4.0",
|
|
189
189
|
"@earendil-works/pi-ai": "~1.4.0",
|
|
190
190
|
"@earendil-works/chord": "~1.4.0",
|
|
191
|
-
"@hachej/boring-files": "^0.4.
|
|
192
|
-
"@hachej/boring-ui-kit": "^0.4.
|
|
191
|
+
"@hachej/boring-files": "^0.4.64",
|
|
192
|
+
"@hachej/boring-ui-kit": "^0.4.64",
|
|
193
193
|
"typebox": "1.3.27",
|
|
194
194
|
"xlsx": "^0.20.3"
|
|
195
195
|
},
|