@nodaro/prompts 1.32.0 → 1.33.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/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/node-send-text.test.ts +9 -0
- package/src/node-send-text.ts +7 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nodaro/prompts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.33.0",
|
|
4
4
|
"description": "Nodaro's prompt-engineering layer — person/picker catalogs with prompt hints, identity-lock clauses, entity prompt builders, brand presets, and prompt/reference assembly shared by the Nodaro platform and SDK.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "FSL-1.1-Apache-2.0",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"test": "vitest run"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@nodaro/shared": "^3.
|
|
23
|
+
"@nodaro/shared": "^3.24.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"tsup": "^8.5.0",
|
|
@@ -64,6 +64,15 @@ describe("computeNodeSendText", () => {
|
|
|
64
64
|
expect(computeNodeSendText("collection-write", {}, { override: "row 3", wired: "the wire", refMap })).toBe("row 3")
|
|
65
65
|
})
|
|
66
66
|
|
|
67
|
+
it("collection-write: a typed field counts with its {Node} references resolved, as the engines send it (#1890)", () => {
|
|
68
|
+
const empty = new Map<string, string>()
|
|
69
|
+
// A feed with nothing new: an empty fallback is nothing to save, so the node skips.
|
|
70
|
+
expect(computeNodeSendText("collection-write", { title: "{Feed || }" }, { wired: "", refMap: empty })).toBe("")
|
|
71
|
+
expect(computeNodeSendText("collection-write", { title: "{Feed || untitled}" }, { wired: "", refMap: empty })).toBe("untitled")
|
|
72
|
+
expect(computeNodeSendText("collection-write", { title: "Breaking: {Feed}" }, { wired: "", refMap: new Map([["feed", "Telegram turns ten"]]) }))
|
|
73
|
+
.toBe("Breaking: Telegram turns ten")
|
|
74
|
+
})
|
|
75
|
+
|
|
67
76
|
it("prompt pre/post text never counts as something to send: an empty core with a prefix is nothing", () => {
|
|
68
77
|
const refMap = new Map<string, string>()
|
|
69
78
|
const affixed = { userInput: "", promptPrefix: "Write a news item about:", promptSuffix: "Keep it short." }
|
package/src/node-send-text.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SOCIAL_POST_NODE_TYPES } from "@nodaro/shared"
|
|
1
|
+
import { resolveNodeRefs, SOCIAL_POST_NODE_TYPES } from "@nodaro/shared"
|
|
2
2
|
import { computeLlmChatFields, computeNodePrompt, computeScriptTopic } from "./resolve-prompt.js"
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -111,7 +111,12 @@ export function computeNodeSendText(
|
|
|
111
111
|
// else a title, text or link typed on the node. A picture alone is a
|
|
112
112
|
// record too, but it never starves the node: only a wired TEXT input that
|
|
113
113
|
// produced nothing can (the skip rule's precondition).
|
|
114
|
-
|
|
114
|
+
// A typed field counts as the engines send it, its `{Node}` references
|
|
115
|
+
// resolved: `{Feed || }` over a feed with nothing new is empty, so the
|
|
116
|
+
// node skips instead of failing with an empty record (#1890).
|
|
117
|
+
const typed = [data.title, data.text, data.link]
|
|
118
|
+
.map((v) => (typeof v === "string" ? resolveNodeRefs(v, args.refMap) : v))
|
|
119
|
+
.find((v): v is string => present(v as string | undefined))
|
|
115
120
|
return [args.override, args.wired, typed].find(present) ?? ""
|
|
116
121
|
}
|
|
117
122
|
default:
|