@onco-foundry/agent-template 0.2.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/dist/agent_template.d.ts +16 -2
- package/dist/agent_template.js +19 -1
- package/package.json +6 -6
package/dist/agent_template.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { type AgentSpec, type ModelClient, type ToolDefinition } from 'agent-lat
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { type Capability } from '@onco-foundry/capability-registry';
|
|
4
4
|
import type { CapabilityDelegation } from '@onco-foundry/agent-runtime';
|
|
5
|
-
import { type VersionedResource } from '@onco-foundry/resource-versioning';
|
|
5
|
+
import { type VersionedResource, type VersionedResourceStore } from '@onco-foundry/resource-versioning';
|
|
6
6
|
import { type Tracer } from '@onco-foundry/trace-port';
|
|
7
7
|
/**
|
|
8
8
|
* 版本化 prompt 资源的 manifest 形状:结构版本号与内容版本号分开,
|
|
@@ -80,8 +80,14 @@ export type AgentTemplateDeclaration<I, O, C = undefined> = {
|
|
|
80
80
|
/**
|
|
81
81
|
* 版本化 prompt 资源根(含 current.json 指针):
|
|
82
82
|
* new URL('./resources/prompts/', import.meta.url)。生效版本解析归模板,编排方零感知。
|
|
83
|
+
* 与 promptStore 二选一。
|
|
83
84
|
*/
|
|
84
|
-
promptDir
|
|
85
|
+
promptDir?: URL;
|
|
86
|
+
/**
|
|
87
|
+
* prompt 资源存储后端:资源不在文件系统(如 MySQL)时注入,与 promptDir 二选一。
|
|
88
|
+
* 生效版本解析与 sha256 完整性校验不变,仍归模板。
|
|
89
|
+
*/
|
|
90
|
+
promptStore?: VersionedResourceStore;
|
|
85
91
|
/**
|
|
86
92
|
* 可选限额。缺省:maxTokens 16384、maxTurns 10、thinking 关闭;
|
|
87
93
|
* thinkingBudgetTokens 给了才开 thinking(按 clampThinkingBudgetTokens 钳制到 maxTokens 以内)。
|
|
@@ -104,6 +110,14 @@ export type CreateTemplateAgentOptions = {
|
|
|
104
110
|
tracer?: Tracer;
|
|
105
111
|
/** prompt 版本覆盖缝:指定版本目录名则跳过 current.json 指针,试跑/对照工具用。 */
|
|
106
112
|
promptVersion?: string;
|
|
113
|
+
/**
|
|
114
|
+
* submit_output 提交后是否结束运行(agent-lattice 0.25.0 的 submitOutputEndTurn,仅 outputSchema 形态有意义)。
|
|
115
|
+
* 缺省不传 = SDK 默认 true:提交即收尾,委派链路与直接 run 的有界交付不变。
|
|
116
|
+
* 仅 human-facing 调试会话(playground)显式传 false:模型交付后继续用人话总结收尾。
|
|
117
|
+
* false 形态下 generic run 照样取 response.structuredResult(SDK 保证最后一次提交进 structuredResult);
|
|
118
|
+
* 委派链路不该传 false——委派要的是有界交付,不是继续闲聊。
|
|
119
|
+
*/
|
|
120
|
+
readonly submitOutputEndTurn?: boolean;
|
|
107
121
|
};
|
|
108
122
|
export type AgentTemplate<I, O, C = undefined> = {
|
|
109
123
|
/** 能力名片:{ name: id, kind: 'agent', summary, input, output },无 version(版本归场景,ADR-10)。 */
|
package/dist/agent_template.js
CHANGED
|
@@ -48,6 +48,20 @@ export const defineAgentTemplate = (declaration) => {
|
|
|
48
48
|
throw new AppError(`模板 id 必须是 kebab-case(小写字母数字与连字符):${declaration.id}`);
|
|
49
49
|
}
|
|
50
50
|
const { id } = declaration;
|
|
51
|
+
/**
|
|
52
|
+
* prompt 来源在 loadPrompt 时才解析:声明对象允许在定义后补齐 promptDir/promptStore
|
|
53
|
+
* (测试夹具在 beforeAll 里指向临时资源就是这种用法),但同一时刻二者只能有一个。
|
|
54
|
+
*/
|
|
55
|
+
const resolvePromptSource = () => {
|
|
56
|
+
if (declaration.promptDir !== undefined && declaration.promptStore !== undefined) {
|
|
57
|
+
throw new AppError(`模板 ${id} 的 promptDir 与 promptStore 只能二选一`);
|
|
58
|
+
}
|
|
59
|
+
if (declaration.promptStore !== undefined)
|
|
60
|
+
return { store: declaration.promptStore };
|
|
61
|
+
if (declaration.promptDir !== undefined)
|
|
62
|
+
return { baseDir: declaration.promptDir };
|
|
63
|
+
throw new AppError(`模板 ${id} 必须声明 promptDir 或 promptStore 之一(prompt 资源在哪里,模板必须知道)`);
|
|
64
|
+
};
|
|
51
65
|
const card = {
|
|
52
66
|
name: id,
|
|
53
67
|
kind: 'agent',
|
|
@@ -70,7 +84,7 @@ export const defineAgentTemplate = (declaration) => {
|
|
|
70
84
|
const loadPrompt = async (loadOptions) => {
|
|
71
85
|
const adapter = declaration.promptManifest ?? defaultPromptManifest;
|
|
72
86
|
const promptResource = await loadActiveVersionedResource({
|
|
73
|
-
|
|
87
|
+
...resolvePromptSource(),
|
|
74
88
|
manifestSchema: adapter.manifestSchema,
|
|
75
89
|
...(loadOptions?.promptVersion !== undefined
|
|
76
90
|
? { versionOverride: loadOptions.promptVersion }
|
|
@@ -109,6 +123,10 @@ export const defineAgentTemplate = (declaration) => {
|
|
|
109
123
|
// 无领域校验要过,交付契约直接交给 SDK:声明 outputSchema 后 SDK 注入
|
|
110
124
|
// submit_output 工具,没提交就收尾会以 error_missing_output 失败。
|
|
111
125
|
outputSchema: declaration.output,
|
|
126
|
+
// submit_output 提交后是否结束运行:没给就不设该字段,SDK 默认 true(提交即收尾)。
|
|
127
|
+
...(options.submitOutputEndTurn === undefined
|
|
128
|
+
? {}
|
|
129
|
+
: { submitOutputEndTurn: options.submitOutputEndTurn }),
|
|
112
130
|
// 业务工具槽位:声明了才构建,依赖经 context 在创建时绑定;与 submit_output 并存。
|
|
113
131
|
...(declaration.tools === undefined ? {} : { tools: declaration.tools(context) }),
|
|
114
132
|
tracer,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onco-foundry/agent-template",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"agent-lattice": "0.
|
|
15
|
+
"agent-lattice": "0.25.0",
|
|
16
16
|
"zod": "^4.4.3",
|
|
17
|
-
"@onco-foundry/
|
|
17
|
+
"@onco-foundry/resource-versioning": "0.3.0",
|
|
18
|
+
"@onco-foundry/agent-runtime": "0.2.2",
|
|
19
|
+
"@onco-foundry/trace-port": "0.3.2",
|
|
18
20
|
"@onco-foundry/errors": "0.1.1",
|
|
19
|
-
"@onco-foundry/
|
|
20
|
-
"@onco-foundry/capability-registry": "0.1.1",
|
|
21
|
-
"@onco-foundry/trace-port": "0.3.1"
|
|
21
|
+
"@onco-foundry/capability-registry": "0.1.1"
|
|
22
22
|
},
|
|
23
23
|
"publishConfig": {
|
|
24
24
|
"access": "public"
|