@prisflow/proactiveai-plugin-types 0.1.1 → 0.3.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/index.d.ts +28 -26
- package/package.json +4 -2
package/index.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ export interface ContextCompactionConfig {
|
|
|
71
71
|
summarySlot?: string
|
|
72
72
|
/** 摘要头部标签文本(如 【剧情史】)。 */
|
|
73
73
|
summaryLabel?: string
|
|
74
|
-
/** 触发压缩的 token
|
|
74
|
+
/** 触发压缩的 token 预算。已弃用——触发改为 provider 真实 usage > 窗口-输出上限,不再读取该字段。 */
|
|
75
75
|
tokenBudget?: number
|
|
76
76
|
/** 压缩后保留的最近消息估算 token 数(缺省 8000)。 */
|
|
77
77
|
keepTokens?: number
|
|
@@ -97,10 +97,10 @@ export interface ContextDefinition {
|
|
|
97
97
|
compaction?: ContextCompactionConfig
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
/** 工具调用上下文(调用方传入)。 */
|
|
100
|
+
/** 工具调用上下文(调用方传入)。conversationId/contextId 恒有值(工具都在会话+上下文内执行)。 */
|
|
101
101
|
export interface ToolCallMeta {
|
|
102
|
-
conversationId
|
|
103
|
-
contextId
|
|
102
|
+
conversationId: string
|
|
103
|
+
contextId: string
|
|
104
104
|
/** 触发本次工具调用的 LLM 轮次 runId(日志链路树)。 */
|
|
105
105
|
parentRunId?: string
|
|
106
106
|
}
|
|
@@ -125,6 +125,10 @@ export interface SilentToolDef {
|
|
|
125
125
|
run: (input: Record<string, unknown>, meta: ToolCallMeta) => ToolResult | Promise<ToolResult>
|
|
126
126
|
silent: true
|
|
127
127
|
transformPrompt?: undefined
|
|
128
|
+
/** 收轮引擎化:执行 + transformPrompt 完成后,引擎直接收轮(等同 host_yield),
|
|
129
|
+
* 不再以 instruction 回喂 LLM。剧情类工具专用——收轮由引擎保证,不依赖模型自觉。
|
|
130
|
+
* 需宿主 ≥ 0.6.3。 */
|
|
131
|
+
autoYield?: boolean
|
|
128
132
|
}
|
|
129
133
|
|
|
130
134
|
/** 非静默工具:执行后产生事件入总线,必须提供 transformPrompt。 */
|
|
@@ -135,16 +139,20 @@ export interface NonSilentToolDef {
|
|
|
135
139
|
run: (input: Record<string, unknown>, meta: ToolCallMeta) => ToolResult | Promise<ToolResult>
|
|
136
140
|
silent?: false
|
|
137
141
|
transformPrompt: (result: ToolResult) => ToolPromptResult
|
|
142
|
+
/** 收轮引擎化:执行 + transformPrompt 完成后,引擎直接收轮(等同 host_yield),
|
|
143
|
+
* 不再以 instruction 回喂 LLM。剧情类工具专用——收轮由引擎保证,不依赖模型自觉。
|
|
144
|
+
* 需宿主 ≥ 0.6.3。 */
|
|
145
|
+
autoYield?: boolean
|
|
138
146
|
}
|
|
139
147
|
|
|
140
148
|
/** 工具定义 —— 注册时需满足对应的 silent/transformPrompt 约束。 */
|
|
141
149
|
export type ToolDefinition = SilentToolDef | NonSilentToolDef
|
|
142
150
|
|
|
143
|
-
/** LLM API
|
|
151
|
+
/** LLM API 连接配置(与宿主对齐:baseURL 未配置为 null)。 */
|
|
144
152
|
export interface LlmConfig {
|
|
145
153
|
apiKey: string
|
|
146
154
|
model: string
|
|
147
|
-
baseURL
|
|
155
|
+
baseURL: string | null
|
|
148
156
|
}
|
|
149
157
|
|
|
150
158
|
/** LLM 消息(OpenAI Chat Completion 单条)。 */
|
|
@@ -198,6 +206,7 @@ export interface LlmNode {
|
|
|
198
206
|
system: string
|
|
199
207
|
input: (ctx: FlowCtx) => string
|
|
200
208
|
schema?: Record<string, unknown>
|
|
209
|
+
/** 结果存入 ctx.data 的键(缺省为 system 前 16 字符,无稳定语义,建议显式指定)。 */
|
|
201
210
|
assign?: string
|
|
202
211
|
maxTries?: number
|
|
203
212
|
maxTokens?: number
|
|
@@ -255,12 +264,17 @@ export interface PluginSetupAPI {
|
|
|
255
264
|
/** 整体覆盖写入插件持久化数据。 */
|
|
256
265
|
set(data: unknown): void
|
|
257
266
|
}
|
|
258
|
-
/**
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
267
|
+
/**
|
|
268
|
+
* 头部稳定层注入(三段式 system 稳定前缀)。
|
|
269
|
+
* 向当前会话+上下文的头部注入固定/慢变文本(如世界状态卡),
|
|
270
|
+
* 宿主组装 LLM 请求时自动读入稳定前缀(慢变 → 缓存恒命中)。
|
|
271
|
+
* 归属自动取自宿主执行上下文,插件无需传会话 ID。
|
|
272
|
+
*/
|
|
273
|
+
prompts: {
|
|
274
|
+
/** 注入/更新头部稳定层文本(覆盖该会话+上下文的注入位)。 */
|
|
275
|
+
set(text: string): void
|
|
276
|
+
/** 移除已注入的文本。 */
|
|
277
|
+
remove(text: string): void
|
|
264
278
|
}
|
|
265
279
|
/** 宿主 LLM 能力:结构化生成(schema 校验失败自动重试)。 */
|
|
266
280
|
llm: {
|
|
@@ -275,22 +289,10 @@ export interface PluginSetupAPI {
|
|
|
275
289
|
flow: {
|
|
276
290
|
/** 注册一张图(节点链)。 */
|
|
277
291
|
register(def: FlowDefinition): boolean
|
|
278
|
-
/** 执行一张图,渲染经 push
|
|
292
|
+
/** 执行一张图,渲染经 push 通道推送并落库。会话归属自动取自执行上下文。 */
|
|
279
293
|
run(
|
|
280
294
|
name: string,
|
|
281
|
-
input: unknown
|
|
282
|
-
opts?: { conversationId?: string; contextId?: string }
|
|
295
|
+
input: unknown
|
|
283
296
|
): Promise<FlowResult>
|
|
284
297
|
}
|
|
285
|
-
/** 三段式骨架提示词注入(优化缓存命中)。 */
|
|
286
|
-
prompts: {
|
|
287
|
-
/** inject(where, text):'prefix' 稳定前缀(system 内)|'suffix' 尾部指令前。 */
|
|
288
|
-
inject(where: 'prefix' | 'suffix', text: string, opts?: { contextId?: string }): void
|
|
289
|
-
/** 移除注入。 */
|
|
290
|
-
remove(where: 'prefix' | 'suffix', text: string, opts?: { contextId?: string }): void
|
|
291
|
-
}
|
|
292
|
-
/** 压缩层配置(覆盖 ContextDefinition.compaction 或全局默认)。 */
|
|
293
|
-
compaction: {
|
|
294
|
-
configure(cfg: Partial<ContextCompactionConfig>, opts?: { contextId?: string }): void
|
|
295
|
-
}
|
|
296
298
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisflow/proactiveai-plugin-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "ProactiveAI 宿主插件 API 的类型契约(纯类型,无运行时代码)。插件开发者通过该包获得类型提示与编译检查。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
7
7
|
"types": "index.d.ts",
|
|
8
|
-
"files": [
|
|
8
|
+
"files": [
|
|
9
|
+
"index.d.ts"
|
|
10
|
+
],
|
|
9
11
|
"scripts": {
|
|
10
12
|
"check": "tsc --noEmit"
|
|
11
13
|
},
|