@prisflow/proactiveai-plugin-types 0.1.0 → 0.2.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.
Files changed (2) hide show
  1. package/index.d.ts +26 -28
  2. package/package.json +2 -2
package/index.d.ts CHANGED
@@ -1,8 +1,12 @@
1
1
  /**
2
2
  * @prisflow/proactiveai-plugin-types
3
3
  *
4
- * ProactiveAI 宿主插件 API 的类型契约(自包含,可独立发布 npm)。
5
- * 插件开发者安装本包后获得 setup(api) 的全部类型提示与编译检查。
4
+ * ProactiveAI 宿主插件 API 的类型契约。
5
+ * 本文件为自包含声明(不 import 宿主相对路径),可独立发布 npm。
6
+ *
7
+ * 发布:push 到 main 且 plugin-types/ 有变更时,
8
+ * 由 .github/workflows/publish-plugin-types.yml 触发;
9
+ * 仓库已在 npmjs 侧配置 trusted publishing(OIDC 自动认证,无需 NPM_TOKEN)。
6
10
  *
7
11
  * 使用:
8
12
  * npm i -D @prisflow/proactiveai-plugin-types
@@ -67,7 +71,7 @@ export interface ContextCompactionConfig {
67
71
  summarySlot?: string
68
72
  /** 摘要头部标签文本(如 【剧情史】)。 */
69
73
  summaryLabel?: string
70
- /** 触发压缩的 token 预算(缺省 60000)。 */
74
+ /** 触发压缩的 token 预算。已弃用——触发改为 provider 真实 usage > 窗口-输出上限,不再读取该字段。 */
71
75
  tokenBudget?: number
72
76
  /** 压缩后保留的最近消息估算 token 数(缺省 8000)。 */
73
77
  keepTokens?: number
@@ -93,10 +97,10 @@ export interface ContextDefinition {
93
97
  compaction?: ContextCompactionConfig
94
98
  }
95
99
 
96
- /** 工具调用上下文(调用方传入)。 */
100
+ /** 工具调用上下文(调用方传入)。conversationId/contextId 恒有值(工具都在会话+上下文内执行)。 */
97
101
  export interface ToolCallMeta {
98
- conversationId?: string
99
- contextId?: string
102
+ conversationId: string
103
+ contextId: string
100
104
  /** 触发本次工具调用的 LLM 轮次 runId(日志链路树)。 */
101
105
  parentRunId?: string
102
106
  }
@@ -136,11 +140,11 @@ export interface NonSilentToolDef {
136
140
  /** 工具定义 —— 注册时需满足对应的 silent/transformPrompt 约束。 */
137
141
  export type ToolDefinition = SilentToolDef | NonSilentToolDef
138
142
 
139
- /** LLM API 连接配置。 */
143
+ /** LLM API 连接配置(与宿主对齐:baseURL 未配置为 null)。 */
140
144
  export interface LlmConfig {
141
145
  apiKey: string
142
146
  model: string
143
- baseURL?: string
147
+ baseURL: string | null
144
148
  }
145
149
 
146
150
  /** LLM 消息(OpenAI Chat Completion 单条)。 */
@@ -194,6 +198,7 @@ export interface LlmNode {
194
198
  system: string
195
199
  input: (ctx: FlowCtx) => string
196
200
  schema?: Record<string, unknown>
201
+ /** 结果存入 ctx.data 的键(缺省为 system 前 16 字符,无稳定语义,建议显式指定)。 */
197
202
  assign?: string
198
203
  maxTries?: number
199
204
  maxTokens?: number
@@ -251,12 +256,17 @@ export interface PluginSetupAPI {
251
256
  /** 整体覆盖写入插件持久化数据。 */
252
257
  set(data: unknown): void
253
258
  }
254
- /** 宿主通用记忆层(host_memory 表,按会话+上下文隔离)。 */
255
- memory: {
256
- set(slot: string, data: string, opts?: { conversationId?: string; contextId?: string }): void
257
- get(slot: string, opts?: { conversationId?: string; contextId?: string }): string | null
258
- search(query: string, opts?: { conversationId?: string; contextId?: string }): Array<{ slot: string; data: string }>
259
- remove(slot: string, opts?: { conversationId?: string; contextId?: string }): boolean
259
+ /**
260
+ * 头部稳定层注入(三段式 system 稳定前缀)。
261
+ * 向当前会话+上下文的头部注入固定/慢变文本(如世界状态卡),
262
+ * 宿主组装 LLM 请求时自动读入稳定前缀(慢变 缓存恒命中)。
263
+ * 归属自动取自宿主执行上下文,插件无需传会话 ID。
264
+ */
265
+ prompts: {
266
+ /** 注入/更新头部稳定层文本(覆盖该会话+上下文的注入位)。 */
267
+ set(text: string): void
268
+ /** 移除已注入的文本。 */
269
+ remove(text: string): void
260
270
  }
261
271
  /** 宿主 LLM 能力:结构化生成(schema 校验失败自动重试)。 */
262
272
  llm: {
@@ -271,22 +281,10 @@ export interface PluginSetupAPI {
271
281
  flow: {
272
282
  /** 注册一张图(节点链)。 */
273
283
  register(def: FlowDefinition): boolean
274
- /** 执行一张图,渲染经 push 通道推送并落库。 */
284
+ /** 执行一张图,渲染经 push 通道推送并落库。会话归属自动取自执行上下文。 */
275
285
  run(
276
286
  name: string,
277
- input: unknown,
278
- opts?: { conversationId?: string; contextId?: string }
287
+ input: unknown
279
288
  ): Promise<FlowResult>
280
289
  }
281
- /** 三段式骨架提示词注入(优化缓存命中)。 */
282
- prompts: {
283
- /** inject(where, text):'prefix' 稳定前缀(system 内)|'suffix' 尾部指令前。 */
284
- inject(where: 'prefix' | 'suffix', text: string, opts?: { contextId?: string }): void
285
- /** 移除注入。 */
286
- remove(where: 'prefix' | 'suffix', text: string, opts?: { contextId?: string }): void
287
- }
288
- /** 压缩层配置(覆盖 ContextDefinition.compaction 或全局默认)。 */
289
- compaction: {
290
- configure(cfg: Partial<ContextCompactionConfig>, opts?: { contextId?: string }): void
291
- }
292
290
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
- {
1
+ {
2
2
  "name": "@prisflow/proactiveai-plugin-types",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "ProactiveAI 宿主插件 API 的类型契约(纯类型,无运行时代码)。插件开发者通过该包获得类型提示与编译检查。",
5
5
  "license": "MIT",
6
6
  "private": false,