@simmalugnt-se/payload-editor-assistant 0.3.2 → 0.4.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/CHANGELOG.md +35 -0
- package/README.md +29 -5
- package/dist/components/EditorAssistantAside.js +127 -38
- package/dist/components/EditorAssistantProvider.js +1 -1
- package/dist/components/assistant-api.d.ts +20 -0
- package/dist/components/assistant-api.js +95 -11
- package/dist/components/assistant-context.d.ts +15 -3
- package/dist/components/assistant-context.js +32 -2
- package/dist/components/conversation-store.d.ts +18 -0
- package/dist/components/conversation-store.js +102 -0
- package/dist/components/copy.d.ts +24 -0
- package/dist/components/copy.js +24 -0
- package/dist/components/proposal-chain.d.ts +22 -0
- package/dist/components/proposal-chain.js +57 -0
- package/dist/endpoints/chat.d.ts +4 -0
- package/dist/endpoints/chat.js +69 -2
- package/dist/runtime/agent.d.ts +15 -0
- package/dist/runtime/agent.js +29 -5
- package/dist/runtime/propose-loop.js +2 -2
- package/dist/runtime/system-prompt.js +5 -2
- package/dist/runtime/tools.d.ts +4 -0
- package/dist/runtime/voice.d.ts +1 -0
- package/dist/runtime/voice.js +16 -1
- package/dist/types.d.ts +5 -1
- package/package.json +4 -4
package/dist/runtime/voice.d.ts
CHANGED
|
@@ -7,5 +7,6 @@ export declare function editorFacingText(input: {
|
|
|
7
7
|
expectedProposal?: boolean;
|
|
8
8
|
}): string;
|
|
9
9
|
export declare function stripInternalSpeech(text: string, locale: string): string;
|
|
10
|
+
export declare function withoutOverclaims(text: string): string;
|
|
10
11
|
export declare function approvalCopy(locale: string, capability: "form.propose" | "draft.create"): string;
|
|
11
12
|
export declare function couldNotStageCopy(locale: string): string;
|
package/dist/runtime/voice.js
CHANGED
|
@@ -3,7 +3,12 @@ const INTERNAL = /\b(form\.propose|form_propose|draft\.create|draft_create|schem
|
|
|
3
3
|
const ENGLISH_META = /\b(despite|therefore|however|the tool|I should|I've|has been issued|appropriate turn|proposed values)\b/i;
|
|
4
4
|
export function editorFacingText(input) {
|
|
5
5
|
if (input.pendingApproval) {
|
|
6
|
-
|
|
6
|
+
// A form change is in the form now, so the model's own words about it can stand, minus any
|
|
7
|
+
// claim the panel contradicts. A draft is not created until approved; that keeps fixed copy.
|
|
8
|
+
const own = input.pendingApproval.capability === "form.propose"
|
|
9
|
+
? withoutOverclaims(stripInternalSpeech(input.text, input.locale))
|
|
10
|
+
: "";
|
|
11
|
+
return own || approvalCopy(input.locale, input.pendingApproval.capability);
|
|
7
12
|
}
|
|
8
13
|
const cleaned = stripInternalSpeech(input.text, input.locale);
|
|
9
14
|
if (input.expectedProposal ||
|
|
@@ -26,6 +31,16 @@ export function stripInternalSpeech(text, locale) {
|
|
|
26
31
|
});
|
|
27
32
|
return kept.join(" ").replace(/\s+/g, " ").trim();
|
|
28
33
|
}
|
|
34
|
+
/** Keeping, saving and publishing are the editor's; a sentence that claims or asks for them goes. */
|
|
35
|
+
const OVERCLAIM = /godkänn|godkann|approve|spara|sparat|sparad|sparats|publicer|\bsaved?\b|publish|behåll|\bkeep\b|klicka|\bclick/i;
|
|
36
|
+
const MAX_OWN_TEXT = 600;
|
|
37
|
+
export function withoutOverclaims(text) {
|
|
38
|
+
const kept = splitSentences(text)
|
|
39
|
+
.filter((sentence) => !OVERCLAIM.test(sentence))
|
|
40
|
+
.join(" ")
|
|
41
|
+
.trim();
|
|
42
|
+
return kept.length <= MAX_OWN_TEXT ? kept : "";
|
|
43
|
+
}
|
|
29
44
|
export function approvalCopy(locale, capability) {
|
|
30
45
|
if (isSwedish(locale)) {
|
|
31
46
|
return capability === "draft.create"
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { EntityCapability } from "./capabilities.ts";
|
|
2
2
|
import type { AdminViewKind } from "./view.ts";
|
|
3
3
|
export type HostLanguageModel = object;
|
|
4
|
+
/**
|
|
5
|
+
* Returns the model for this request. Returning `null` or `undefined` (no API key set, say) keeps the
|
|
6
|
+
* plugin installed and tells the editor in the drawer that no model is set up.
|
|
7
|
+
*/
|
|
4
8
|
export type ModelResolver = (args: {
|
|
5
9
|
userId?: string | number;
|
|
6
|
-
}) => HostLanguageModel | Promise<HostLanguageModel>;
|
|
10
|
+
}) => HostLanguageModel | null | undefined | Promise<HostLanguageModel | null | undefined>;
|
|
7
11
|
export type FieldAllowlist = true | {
|
|
8
12
|
include: string[];
|
|
9
13
|
} | {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simmalugnt-se/payload-editor-assistant",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Context-aware editor assistant plugin for Payload Admin",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@payloadcms/ui": "3.
|
|
56
|
+
"@payloadcms/ui": "3.90.2",
|
|
57
57
|
"@types/node": "^22",
|
|
58
58
|
"@types/react": "^19.2.18",
|
|
59
59
|
"@types/react-dom": "^19.2.4",
|
|
60
|
-
"next": "16.3.
|
|
61
|
-
"payload": "3.
|
|
60
|
+
"next": "16.3.6",
|
|
61
|
+
"payload": "3.90.2",
|
|
62
62
|
"react": "19.2.8",
|
|
63
63
|
"react-dom": "19.2.8",
|
|
64
64
|
"tsx": "^4.21.0",
|