@yuaone/core 0.9.43 → 1.0.1
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-affordance.d.ts +37 -0
- package/dist/agent-affordance.d.ts.map +1 -0
- package/dist/agent-affordance.js +139 -0
- package/dist/agent-affordance.js.map +1 -0
- package/dist/agent-decision-types.d.ts +262 -0
- package/dist/agent-decision-types.d.ts.map +1 -0
- package/dist/agent-decision-types.js +19 -0
- package/dist/agent-decision-types.js.map +1 -0
- package/dist/agent-decision.d.ts +52 -0
- package/dist/agent-decision.d.ts.map +1 -0
- package/dist/agent-decision.js +767 -0
- package/dist/agent-decision.js.map +1 -0
- package/dist/agent-loop.d.ts +37 -79
- package/dist/agent-loop.d.ts.map +1 -1
- package/dist/agent-loop.js +730 -586
- package/dist/agent-loop.js.map +1 -1
- package/dist/agent-reasoning-engine.d.ts +48 -0
- package/dist/agent-reasoning-engine.d.ts.map +1 -0
- package/dist/agent-reasoning-engine.js +544 -0
- package/dist/agent-reasoning-engine.js.map +1 -0
- package/dist/codebase-context.d.ts +3 -0
- package/dist/codebase-context.d.ts.map +1 -1
- package/dist/codebase-context.js +15 -6
- package/dist/codebase-context.js.map +1 -1
- package/dist/command-plan-compiler.d.ts +43 -0
- package/dist/command-plan-compiler.d.ts.map +1 -0
- package/dist/command-plan-compiler.js +164 -0
- package/dist/command-plan-compiler.js.map +1 -0
- package/dist/dependency-guard.d.ts +18 -0
- package/dist/dependency-guard.d.ts.map +1 -0
- package/dist/dependency-guard.js +113 -0
- package/dist/dependency-guard.js.map +1 -0
- package/dist/execution-engine.d.ts +10 -1
- package/dist/execution-engine.d.ts.map +1 -1
- package/dist/execution-engine.js +162 -8
- package/dist/execution-engine.js.map +1 -1
- package/dist/execution-receipt.d.ts +62 -0
- package/dist/execution-receipt.d.ts.map +1 -0
- package/dist/execution-receipt.js +67 -0
- package/dist/execution-receipt.js.map +1 -0
- package/dist/failure-surface-writer.d.ts +13 -0
- package/dist/failure-surface-writer.d.ts.map +1 -0
- package/dist/failure-surface-writer.js +33 -0
- package/dist/failure-surface-writer.js.map +1 -0
- package/dist/file-chunker.d.ts +26 -0
- package/dist/file-chunker.d.ts.map +1 -0
- package/dist/file-chunker.js +103 -0
- package/dist/file-chunker.js.map +1 -0
- package/dist/image-observer.d.ts +22 -0
- package/dist/image-observer.d.ts.map +1 -0
- package/dist/image-observer.js +60 -0
- package/dist/image-observer.js.map +1 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -1
- package/dist/judgment-rules.d.ts +44 -0
- package/dist/judgment-rules.d.ts.map +1 -0
- package/dist/judgment-rules.js +185 -0
- package/dist/judgment-rules.js.map +1 -0
- package/dist/memory-decay.d.ts +41 -0
- package/dist/memory-decay.d.ts.map +1 -0
- package/dist/memory-decay.js +62 -0
- package/dist/memory-decay.js.map +1 -0
- package/dist/memory-manager.d.ts.map +1 -1
- package/dist/memory-manager.js +30 -0
- package/dist/memory-manager.js.map +1 -1
- package/dist/model-weakness-tracker.d.ts +42 -0
- package/dist/model-weakness-tracker.d.ts.map +1 -0
- package/dist/model-weakness-tracker.js +107 -0
- package/dist/model-weakness-tracker.js.map +1 -0
- package/dist/overhead-governor.d.ts +3 -1
- package/dist/overhead-governor.d.ts.map +1 -1
- package/dist/overhead-governor.js +5 -0
- package/dist/overhead-governor.js.map +1 -1
- package/dist/patch-scope-controller.d.ts +44 -0
- package/dist/patch-scope-controller.d.ts.map +1 -0
- package/dist/patch-scope-controller.js +107 -0
- package/dist/patch-scope-controller.js.map +1 -0
- package/dist/patch-transaction.d.ts +53 -0
- package/dist/patch-transaction.d.ts.map +1 -0
- package/dist/patch-transaction.js +119 -0
- package/dist/patch-transaction.js.map +1 -0
- package/dist/pre-write-validator.d.ts +29 -0
- package/dist/pre-write-validator.d.ts.map +1 -0
- package/dist/pre-write-validator.js +97 -0
- package/dist/pre-write-validator.js.map +1 -0
- package/dist/prompt-builder.d.ts +25 -0
- package/dist/prompt-builder.d.ts.map +1 -0
- package/dist/prompt-builder.js +93 -0
- package/dist/prompt-builder.js.map +1 -0
- package/dist/prompt-envelope.d.ts +40 -0
- package/dist/prompt-envelope.d.ts.map +1 -0
- package/dist/prompt-envelope.js +16 -0
- package/dist/prompt-envelope.js.map +1 -0
- package/dist/prompt-runtime.d.ts +66 -0
- package/dist/prompt-runtime.d.ts.map +1 -0
- package/dist/prompt-runtime.js +492 -0
- package/dist/prompt-runtime.js.map +1 -0
- package/dist/repo-capability-profile.d.ts +24 -0
- package/dist/repo-capability-profile.d.ts.map +1 -0
- package/dist/repo-capability-profile.js +113 -0
- package/dist/repo-capability-profile.js.map +1 -0
- package/dist/security-gate.d.ts +39 -0
- package/dist/security-gate.d.ts.map +1 -0
- package/dist/security-gate.js +121 -0
- package/dist/security-gate.js.map +1 -0
- package/dist/self-evaluation.d.ts +22 -0
- package/dist/self-evaluation.d.ts.map +1 -0
- package/dist/self-evaluation.js +43 -0
- package/dist/self-evaluation.js.map +1 -0
- package/dist/semantic-diff-reviewer.d.ts +28 -0
- package/dist/semantic-diff-reviewer.d.ts.map +1 -0
- package/dist/semantic-diff-reviewer.js +168 -0
- package/dist/semantic-diff-reviewer.js.map +1 -0
- package/dist/stall-detector.d.ts +26 -2
- package/dist/stall-detector.d.ts.map +1 -1
- package/dist/stall-detector.js +128 -3
- package/dist/stall-detector.js.map +1 -1
- package/dist/system-core.d.ts +27 -0
- package/dist/system-core.d.ts.map +1 -0
- package/dist/system-core.js +269 -0
- package/dist/system-core.js.map +1 -0
- package/dist/system-prompt.d.ts +4 -0
- package/dist/system-prompt.d.ts.map +1 -1
- package/dist/system-prompt.js +12 -218
- package/dist/system-prompt.js.map +1 -1
- package/dist/target-file-ranker.d.ts +38 -0
- package/dist/target-file-ranker.d.ts.map +1 -0
- package/dist/target-file-ranker.js +90 -0
- package/dist/target-file-ranker.js.map +1 -0
- package/dist/task-classifier.d.ts +6 -0
- package/dist/task-classifier.d.ts.map +1 -1
- package/dist/task-classifier.js +6 -0
- package/dist/task-classifier.js.map +1 -1
- package/dist/test-impact-planner.d.ts +16 -0
- package/dist/test-impact-planner.d.ts.map +1 -0
- package/dist/test-impact-planner.js +68 -0
- package/dist/test-impact-planner.js.map +1 -0
- package/dist/tool-outcome-cache.d.ts +41 -0
- package/dist/tool-outcome-cache.d.ts.map +1 -0
- package/dist/tool-outcome-cache.js +88 -0
- package/dist/tool-outcome-cache.js.map +1 -0
- package/dist/types.d.ts +39 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/verifier-rules.d.ts +15 -0
- package/dist/verifier-rules.d.ts.map +1 -0
- package/dist/verifier-rules.js +80 -0
- package/dist/verifier-rules.js.map +1 -0
- package/dist/workspace-mutation-policy.d.ts +28 -0
- package/dist/workspace-mutation-policy.d.ts.map +1 -0
- package/dist/workspace-mutation-policy.js +56 -0
- package/dist/workspace-mutation-policy.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module prompt-builder
|
|
3
|
+
* @description YUAN PromptBuilder -- dumb renderer.
|
|
4
|
+
*
|
|
5
|
+
* Rules:
|
|
6
|
+
* 1. PromptEnvelope -> string conversion only
|
|
7
|
+
* 2. No policy decisions (mode, budget, role interpretation forbidden)
|
|
8
|
+
* 3. Section order: core -> policy -> role -> context -> ephemeral -> reinforce
|
|
9
|
+
* 4. When token budget exceeded, droppable sections are removed first
|
|
10
|
+
*
|
|
11
|
+
* YUA reference: prompt-builder.ts (1436 lines) -- YUAN is much thinner
|
|
12
|
+
*/
|
|
13
|
+
/** Rough token estimation (1 token ~ 3.5 chars for mixed Korean/English) */
|
|
14
|
+
function estimateTokens(text) {
|
|
15
|
+
return Math.ceil(text.length / 3.5);
|
|
16
|
+
}
|
|
17
|
+
/** Section separator used between prompt sections */
|
|
18
|
+
const SECTION_SEP = "\n\n---\n\n";
|
|
19
|
+
function sortGroup(sections) {
|
|
20
|
+
return [...sections].sort((a, b) => a.priority - b.priority);
|
|
21
|
+
}
|
|
22
|
+
function orderedGroups(envelope) {
|
|
23
|
+
return [
|
|
24
|
+
sortGroup(envelope.systemCoreSections),
|
|
25
|
+
sortGroup(envelope.runtimePolicySections),
|
|
26
|
+
sortGroup(envelope.roleSections),
|
|
27
|
+
sortGroup(envelope.taskContextSections),
|
|
28
|
+
sortGroup(envelope.ephemeralSections),
|
|
29
|
+
sortGroup(envelope.reinforceSections),
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
function appendSection(current, next) {
|
|
33
|
+
if (!current.trim())
|
|
34
|
+
return next.trim();
|
|
35
|
+
return `${current}${SECTION_SEP}${next.trim()}`.trim();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* PromptEnvelope -> final system prompt string.
|
|
39
|
+
* No decisions. Just concatenation.
|
|
40
|
+
*
|
|
41
|
+
* @param envelope - The compiled prompt envelope from PromptRuntime
|
|
42
|
+
* @param maxTokens - Optional token budget. If set, droppable sections are
|
|
43
|
+
* removed (lowest priority first) until budget is met.
|
|
44
|
+
* Required sections (droppable=false) are never removed.
|
|
45
|
+
* @returns Final system prompt string ready for LLM consumption
|
|
46
|
+
*/
|
|
47
|
+
export function buildPrompt(envelope, maxTokens) {
|
|
48
|
+
// envelope.maxTokens가 있으면 우선 사용 (PromptRuntime이 예산 계산)
|
|
49
|
+
const effectiveMaxTokens = maxTokens ?? envelope.maxTokens;
|
|
50
|
+
const groups = orderedGroups(envelope);
|
|
51
|
+
const allSections = groups.flat();
|
|
52
|
+
// No token budget -> include everything
|
|
53
|
+
if (!effectiveMaxTokens) {
|
|
54
|
+
return joinSections(allSections);
|
|
55
|
+
}
|
|
56
|
+
// Preserve canonical zone order:
|
|
57
|
+
// core -> policy -> role -> context -> ephemeral -> reinforce
|
|
58
|
+
// Required sections are always kept; droppable sections are appended in-group
|
|
59
|
+
// until budget is exhausted.
|
|
60
|
+
let result = "";
|
|
61
|
+
let usedTokens = 0;
|
|
62
|
+
for (const group of groups) {
|
|
63
|
+
for (const s of group) {
|
|
64
|
+
if (!s.content.length || s.droppable)
|
|
65
|
+
continue;
|
|
66
|
+
const next = appendSection(result, s.content);
|
|
67
|
+
result = next;
|
|
68
|
+
usedTokens = estimateTokens(result);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
for (const group of groups) {
|
|
72
|
+
for (const s of group) {
|
|
73
|
+
if (!s.content.length || !s.droppable)
|
|
74
|
+
continue;
|
|
75
|
+
const candidate = appendSection(result, s.content);
|
|
76
|
+
const candidateTokens = estimateTokens(candidate);
|
|
77
|
+
if (candidateTokens <= effectiveMaxTokens) {
|
|
78
|
+
result = candidate;
|
|
79
|
+
usedTokens = candidateTokens;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return result.trim();
|
|
84
|
+
}
|
|
85
|
+
/** Join non-empty sections with separator */
|
|
86
|
+
function joinSections(sections) {
|
|
87
|
+
return sections
|
|
88
|
+
.filter(s => s.content.length > 0)
|
|
89
|
+
.map(s => s.content)
|
|
90
|
+
.join(SECTION_SEP)
|
|
91
|
+
.trim();
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=prompt-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-builder.js","sourceRoot":"","sources":["../src/prompt-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,4EAA4E;AAC5E,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC;AACtC,CAAC;AAED,qDAAqD;AACrD,MAAM,WAAW,GAAG,aAAa,CAAC;AAElC,SAAS,SAAS,CAAC,QAAyB;IAC1C,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,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AAI,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC,SAAS;gBAAE,SAAS;YAC/C,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;YAC9C,MAAM,GAAG,IAAI,CAAC;YACd,UAAU,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;YACtB,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,SAAS;gBAAE,SAAS;YAChD,MAAM,SAAS,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;YACnD,MAAM,eAAe,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;YAClD,IAAI,eAAe,IAAI,kBAAkB,EAAE,CAAC;gBAC1C,MAAM,GAAG,SAAS,CAAC;gBACnB,UAAU,GAAG,eAAe,CAAC;YAC/B,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;AACvB,CAAC;AAED,6CAA6C;AAC7C,SAAS,YAAY,CAAC,QAAyB;IAC7C,OAAO,QAAQ;SACZ,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;SACjC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;SACnB,IAAI,CAAC,WAAW,CAAC;SACjB,IAAI,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module prompt-envelope
|
|
3
|
+
* @description PromptRuntime → PromptBuilder 전달 계약.
|
|
4
|
+
* PromptBuilder는 이 타입만 받아서 string으로 렌더링.
|
|
5
|
+
* 정책 판단 불가, 필드 해석 불가 — 문자열 합치기만.
|
|
6
|
+
*/
|
|
7
|
+
/** 프롬프트 섹션 하나 */
|
|
8
|
+
export interface PromptSection {
|
|
9
|
+
/** 섹션 이름 (디버그/로깅용) */
|
|
10
|
+
name: string;
|
|
11
|
+
/** 섹션 내용 */
|
|
12
|
+
content: string;
|
|
13
|
+
/** 우선순위 (낮을수록 먼저, 같으면 삽입 순서) */
|
|
14
|
+
priority: number;
|
|
15
|
+
/** 토큰 예산 초과 시 삭제 가능 여부 */
|
|
16
|
+
droppable: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** PromptRuntime이 생성, PromptBuilder가 소비 */
|
|
19
|
+
export interface PromptEnvelope {
|
|
20
|
+
/** 불변 헌법 (정체성, safety, core rules) — 항상 첫 번째 */
|
|
21
|
+
systemCoreSections: PromptSection[];
|
|
22
|
+
/** Decision 기반 정책 (mode, role, budget hints, veto hints) */
|
|
23
|
+
runtimePolicySections: PromptSection[];
|
|
24
|
+
/** 역할 섹션 (planner/coder/verifier — Decision에서 결정) */
|
|
25
|
+
roleSections: PromptSection[];
|
|
26
|
+
/** 태스크 컨텍스트 (worldState, memory, skills, project) */
|
|
27
|
+
taskContextSections: PromptSection[];
|
|
28
|
+
/** 이번 iteration 전용 (반복당 힌트: QA, reflection, budget warning) */
|
|
29
|
+
ephemeralSections: PromptSection[];
|
|
30
|
+
/** 강화 섹션 (U-curve 두 번째 피크 — 마지막에 배치) */
|
|
31
|
+
reinforceSections: PromptSection[];
|
|
32
|
+
/** system prompt 토큰 예산 (PromptBuilder가 이 한도 내에서 droppable 관리) */
|
|
33
|
+
maxTokens?: number;
|
|
34
|
+
}
|
|
35
|
+
/** section 생성 헬퍼 */
|
|
36
|
+
export declare function section(name: string, content: string, opts?: {
|
|
37
|
+
priority?: number;
|
|
38
|
+
droppable?: boolean;
|
|
39
|
+
}): PromptSection;
|
|
40
|
+
//# sourceMappingURL=prompt-envelope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-envelope.d.ts","sourceRoot":"","sources":["../src/prompt-envelope.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,iBAAiB;AACjB,MAAM,WAAW,aAAa;IAC5B,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,2CAA2C;AAC3C,MAAM,WAAW,cAAc;IAC7B,gDAAgD;IAChD,kBAAkB,EAAE,aAAa,EAAE,CAAC;IACpC,4DAA4D;IAC5D,qBAAqB,EAAE,aAAa,EAAE,CAAC;IACvC,qDAAqD;IACrD,YAAY,EAAE,aAAa,EAAE,CAAC;IAC9B,qDAAqD;IACrD,mBAAmB,EAAE,aAAa,EAAE,CAAC;IACrC,+DAA+D;IAC/D,iBAAiB,EAAE,aAAa,EAAE,CAAC;IACnC,wCAAwC;IACxC,iBAAiB,EAAE,aAAa,EAAE,CAAC;IACnC,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,oBAAoB;AACpB,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,GAAG,aAAa,CAOhB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module prompt-envelope
|
|
3
|
+
* @description PromptRuntime → PromptBuilder 전달 계약.
|
|
4
|
+
* PromptBuilder는 이 타입만 받아서 string으로 렌더링.
|
|
5
|
+
* 정책 판단 불가, 필드 해석 불가 — 문자열 합치기만.
|
|
6
|
+
*/
|
|
7
|
+
/** section 생성 헬퍼 */
|
|
8
|
+
export function section(name, content, opts) {
|
|
9
|
+
return {
|
|
10
|
+
name,
|
|
11
|
+
content,
|
|
12
|
+
priority: opts?.priority ?? 50,
|
|
13
|
+
droppable: opts?.droppable ?? false,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=prompt-envelope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-envelope.js","sourceRoot":"","sources":["../src/prompt-envelope.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgCH,oBAAoB;AACpB,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,OAAe,EAAE,IAGtD;IACC,OAAO;QACL,IAAI;QACJ,OAAO;QACP,QAAQ,EAAE,IAAI,EAAE,QAAQ,IAAI,EAAE;QAC9B,SAAS,EAAE,IAAI,EAAE,SAAS,IAAI,KAAK;KACpC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module prompt-runtime
|
|
3
|
+
* @description YUAN PromptRuntime -- Decision policy compiler.
|
|
4
|
+
*
|
|
5
|
+
* Rules:
|
|
6
|
+
* 1. Consumes DecisionContext ONLY (no new decisions)
|
|
7
|
+
* 2. Produces PromptEnvelope -> delegates to PromptBuilder
|
|
8
|
+
* 3. agent-loop calls this instead of directly injecting system messages
|
|
9
|
+
*
|
|
10
|
+
* YUA reference: prompt-runtime.ts (876 lines)
|
|
11
|
+
* YUAN difference: coding agent specialized (tool budget hints, veto hints, plan context)
|
|
12
|
+
*/
|
|
13
|
+
import type { PromptEnvelope } from "./prompt-envelope.js";
|
|
14
|
+
import type { AgentDecisionContext } from "./agent-decision-types.js";
|
|
15
|
+
import type { SystemPromptOptions } from "./system-prompt.js";
|
|
16
|
+
/** PromptRuntime input -- provided by agent-loop */
|
|
17
|
+
/** Context window 토큰 예산 배분 */
|
|
18
|
+
export interface PromptTokenBudget {
|
|
19
|
+
/** 모델 전체 컨텍스트 윈도우 (토큰) */
|
|
20
|
+
contextWindow: number;
|
|
21
|
+
/** system prompt 최대 비율 (0~1, 기본 0.25) */
|
|
22
|
+
systemPromptRatio: number;
|
|
23
|
+
/** conversation 비율 (0~1, 기본 0.40) */
|
|
24
|
+
conversationRatio: number;
|
|
25
|
+
/** tool results 비율 (0~1, 기본 0.20) */
|
|
26
|
+
toolResultsRatio: number;
|
|
27
|
+
/** LLM 출력 여유 비율 (0~1, 기본 0.15) */
|
|
28
|
+
outputReserveRatio: number;
|
|
29
|
+
}
|
|
30
|
+
/** 모델별 기본 예산 */
|
|
31
|
+
export declare const DEFAULT_TOKEN_BUDGETS: Record<string, PromptTokenBudget>;
|
|
32
|
+
/** system prompt에 쓸 수 있는 최대 토큰 계산 */
|
|
33
|
+
export declare function getSystemPromptMaxTokens(budget: PromptTokenBudget): number;
|
|
34
|
+
export interface PromptRuntimeInput {
|
|
35
|
+
/** Decision Engine result (null = legacy fallback) */
|
|
36
|
+
decision: AgentDecisionContext | null;
|
|
37
|
+
/** Existing buildSystemPrompt options (backward compat) */
|
|
38
|
+
promptOptions: SystemPromptOptions;
|
|
39
|
+
/** Per-run context (memory, persona, reflexion, etc.) */
|
|
40
|
+
runContext?: {
|
|
41
|
+
memoryContext?: string;
|
|
42
|
+
personaSection?: string;
|
|
43
|
+
reflexionGuidance?: string;
|
|
44
|
+
taskMemory?: string;
|
|
45
|
+
ragContext?: string;
|
|
46
|
+
playbookHint?: string;
|
|
47
|
+
continuationPrompt?: string;
|
|
48
|
+
worldStateSection?: string;
|
|
49
|
+
weaknessContext?: string;
|
|
50
|
+
learnedSkills?: string;
|
|
51
|
+
pluginSkills?: string;
|
|
52
|
+
};
|
|
53
|
+
/** Per-iteration ephemeral hints (QA, reflection, budget, etc.) */
|
|
54
|
+
ephemeralHints?: string[];
|
|
55
|
+
/** 토큰 예산 (없으면 default 사용) */
|
|
56
|
+
tokenBudget?: PromptTokenBudget;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Decision + Context -> PromptEnvelope.
|
|
60
|
+
* This function is the SOLE place that decides "what goes into the prompt".
|
|
61
|
+
*
|
|
62
|
+
* PromptRuntime does NOT make new decisions -- only reads DecisionContext.
|
|
63
|
+
* PromptRuntime does NOT produce prompt strings -- only produces PromptEnvelope.
|
|
64
|
+
*/
|
|
65
|
+
export declare function compilePromptEnvelope(input: PromptRuntimeInput): PromptEnvelope;
|
|
66
|
+
//# sourceMappingURL=prompt-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-runtime.d.ts","sourceRoot":"","sources":["../src/prompt-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,sBAAsB,CAAC;AAG1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAI9D,oDAAoD;AACpD,8BAA8B;AAC9B,MAAM,WAAW,iBAAiB;IAChC,0BAA0B;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,yCAAyC;IACzC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qCAAqC;IACrC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qCAAqC;IACrC,gBAAgB,EAAE,MAAM,CAAC;IACzB,kCAAkC;IAClC,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,gBAAgB;AAChB,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CA6BnE,CAAC;AAEF,qCAAqC;AACrC,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAE1E;AAED,MAAM,WAAW,kBAAkB;IACjC,sDAAsD;IACtD,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAEtC,2DAA2D;IAC3D,aAAa,EAAE,mBAAmB,CAAC;IAEnC,yDAAyD;IACzD,UAAU,CAA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