@x-otto/interchange 0.1.0-alpha.14 → 0.1.0-alpha.17
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/context-fragment.d.ts +1 -1
- package/dist/index.d.ts +2 -35
- package/dist/index.js +1 -1
- package/dist/message.d.ts +11 -1
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* CODE-STYLE.md §6b)。片段内容被截断只损失尾部信息,不改变已注入部分的可读性。
|
|
14
14
|
*/
|
|
15
15
|
/** system prompt 注入片段的类型化 id(与 SYSTEM_PROMPT_SECTIONS 的字段一一对应)。 */
|
|
16
|
-
type ContextFragmentId = 'toolGuidance' | '
|
|
16
|
+
type ContextFragmentId = 'toolGuidance' | 'environment' | 'environmentVolatile' | 'agentKnowledge' | 'memoryIndex' | 'skillCatalog' | 'lesson' | 'lessonRelevantHints' | 'memoryDelta' | 'todoReminder' | 'docSyncReminder';
|
|
17
17
|
/** 有界上下文片段:id + 内容。预算声明在 SYSTEM_PROMPT_SECTIONS(runtime 包)。 */
|
|
18
18
|
interface ContextFragment {
|
|
19
19
|
id: ContextFragmentId;
|
package/dist/index.d.ts
CHANGED
|
@@ -279,7 +279,8 @@ declare function collectModelCapabilityFacts(model: Pick<Model, 'input'>): Model
|
|
|
279
279
|
* 注:本表是**排序权威**(方案 H:section 仍由各自 hook 自注册,priority 数字降级为对本表的引用);
|
|
280
280
|
* 不强行把 `SYSTEM_PROMPT_SECTIONS` 各 section 物理并入单一 registry(那超出外科尺度、非目标)。
|
|
281
281
|
* section 数量以该常量的字段数为准,不在本段注释里重复写死具体数字(history: 建表时 7 个,
|
|
282
|
-
* 后追加 docSyncReminder 成 8 个,又补 skillLoopGuidance 成 9
|
|
282
|
+
* 后追加 docSyncReminder 成 8 个,又补 skillLoopGuidance 成 9 个——写死数字会重犯本次发现的漂移;
|
|
283
|
+
* 09-07 技能回路/内化决策器完整下线,删 skillLoopGuidance/internalize 两项,回落 7 个)。
|
|
283
284
|
*/
|
|
284
285
|
type SystemPromptLane = 'stable' | 'volatile';
|
|
285
286
|
interface SystemPromptSectionSpec {
|
|
@@ -302,16 +303,6 @@ declare const SYSTEM_PROMPT_SECTIONS: {
|
|
|
302
303
|
readonly lane: "stable";
|
|
303
304
|
readonly budgetBytes: 20000;
|
|
304
305
|
};
|
|
305
|
-
/**
|
|
306
|
-
* RFC-318 D7:三分流判别(缺工具 / 流程重复 / 其余)。紧跟 toolGuidance——它是对
|
|
307
|
-
* "现有工具够不够用"的元判断,语义上属工具指引的延伸;内容恒定故走 stable lane。
|
|
308
|
-
*/
|
|
309
|
-
readonly skillLoopGuidance: {
|
|
310
|
-
readonly name: "skill-loop-guidance-injection";
|
|
311
|
-
readonly priority: 21;
|
|
312
|
-
readonly lane: "stable";
|
|
313
|
-
readonly budgetBytes: 2000;
|
|
314
|
-
};
|
|
315
306
|
readonly environment: {
|
|
316
307
|
readonly name: "runtime:environment";
|
|
317
308
|
readonly priority: 25;
|
|
@@ -348,30 +339,6 @@ declare const SYSTEM_PROMPT_SECTIONS: {
|
|
|
348
339
|
readonly lane: "volatile";
|
|
349
340
|
readonly budgetBytes: 4000;
|
|
350
341
|
};
|
|
351
|
-
/**
|
|
352
|
-
* RFC-383 M2(§9 修订 6):高频 skill 内化指令核心——引擎内部 hook
|
|
353
|
-
* `internalize-skill-injection` 的 volatile 尾段预算面。**必须注册**:不注册则
|
|
354
|
-
* applySectionBudget 原样放行、4KB 硬顶失效(决策器提炼不受控)。priority 42 排在
|
|
355
|
-
* lessonRelevantHints(41) 之后、memoryDelta(60) 之前。
|
|
356
|
-
*/
|
|
357
|
-
readonly internalize: {
|
|
358
|
-
readonly name: "internalize-skill-injection";
|
|
359
|
-
readonly priority: 42;
|
|
360
|
-
readonly lane: "volatile";
|
|
361
|
-
readonly budgetBytes: 4000;
|
|
362
|
-
};
|
|
363
|
-
/**
|
|
364
|
-
* RFC-445 M2(A7):插件失败候选——宿主 onLoadError 桥构造的结构化失败摘要,
|
|
365
|
-
* 经 volatile systemTail 受控注入(对齐 RFC-327 §9.1 放宽条款)。时效性强
|
|
366
|
-
* (失败当下就该被下一轮感知)故排在内化之后、memory-delta 之前。**必须注册**:
|
|
367
|
-
* 不注册则 applySectionBudget 原样放行、4KB 硬顶失效。
|
|
368
|
-
*/
|
|
369
|
-
readonly pluginFailures: {
|
|
370
|
-
readonly name: "plugin-failures-injection";
|
|
371
|
-
readonly priority: 55;
|
|
372
|
-
readonly lane: "volatile";
|
|
373
|
-
readonly budgetBytes: 4000;
|
|
374
|
-
};
|
|
375
342
|
readonly memoryDelta: {
|
|
376
343
|
readonly name: "memory-delta-injection";
|
|
377
344
|
readonly priority: 60;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{CONVERSATION_SUMMARY_PREFIX as e,getToolCallsByAssistantMessage as t,hasToolCalls as n}from"./message.js";import{boundFragment as r,contextFragmentBytes as i}from"./context-fragment.js";import{normalizeImageData as a,toAnthropicImageMime as o}from"./image.js";import{adjustDismissedSigil as s,applySigilCompletion as c,applySigilReplacement as l,evaluateSigilTrigger as u,extractSigilPrefix as d,isSigilDismissed as f,sigilOf as p}from"./input.js";function m(e){return!Array.isArray(e.input)||e.input.length===0?{state:`unknown`}:e.input.includes(`image`)?{state:`supported`,value:!0}:{state:`unsupported`}}function h(e){return m(e).state===`supported`}function g(e){return{vision:m(e)}}const _={toolGuidance:{name:`tool-guidance-injection`,priority:20,lane:`stable`,budgetBytes:2e4},
|
|
1
|
+
import{CONVERSATION_SUMMARY_PREFIX as e,getToolCallsByAssistantMessage as t,hasToolCalls as n}from"./message.js";import{boundFragment as r,contextFragmentBytes as i}from"./context-fragment.js";import{normalizeImageData as a,toAnthropicImageMime as o}from"./image.js";import{adjustDismissedSigil as s,applySigilCompletion as c,applySigilReplacement as l,evaluateSigilTrigger as u,extractSigilPrefix as d,isSigilDismissed as f,sigilOf as p}from"./input.js";function m(e){return!Array.isArray(e.input)||e.input.length===0?{state:`unknown`}:e.input.includes(`image`)?{state:`supported`,value:!0}:{state:`unsupported`}}function h(e){return m(e).state===`supported`}function g(e){return{vision:m(e)}}const _={toolGuidance:{name:`tool-guidance-injection`,priority:20,lane:`stable`,budgetBytes:2e4},environment:{name:`runtime:environment`,priority:25,lane:`stable`,budgetBytes:2e3},environmentVolatile:{name:`runtime:environment-volatile`,priority:26,lane:`volatile`,budgetBytes:4e3},agentKnowledge:{name:`agent-knowledge-injection`,priority:35,lane:`stable`,budgetBytes:28e3},skillCatalog:{name:`skill-catalog-injection`,priority:38,lane:`stable`,budgetBytes:12e3},lessonRelevantHints:{name:`lesson-relevant-hints`,priority:41,lane:`volatile`,budgetBytes:4e3},memoryDelta:{name:`memory-delta-injection`,priority:60,lane:`volatile`,budgetBytes:8e3},todoReminder:{name:`todo-reminder-injection`,priority:62,lane:`volatile`,budgetBytes:4e3},docSyncReminder:{name:`doc-sync-reminder-injection`,priority:64,lane:`volatile`,budgetBytes:4e3}},v=Object.values(_),y=new Set;function b(e,t){let n=v.find(t=>t.name===e);return n?(Buffer.byteLength(t,`utf8`)>n.budgetBytes&&!y.has(e)&&(y.add(e),console.warn(`[system-prompt] section "${e}" truncated to ${n.budgetBytes} bytes (content ${Buffer.byteLength(t,`utf8`)} bytes) — check SYSTEM_PROMPT_SECTIONS budget vs content size`)),r({id:x(e),content:t},n.budgetBytes).content):t}function x(e){let t={"tool-guidance-injection":`toolGuidance`,"runtime:environment":`environment`,"runtime:environment-volatile":`environmentVolatile`,"agent-knowledge-injection":`agentKnowledge`,"runtime:memory-index":`memoryIndex`,"skill-catalog-injection":`skillCatalog`,"lesson-injection":`lesson`,"lesson-relevant-hints":`lessonRelevantHints`,"memory-delta-injection":`memoryDelta`,"todo-reminder-injection":`todoReminder`,"doc-sync-reminder-injection":`docSyncReminder`}[e];if(t===void 0)throw Error(`applySectionBudget: unknown section name "${e}"`);return t}function S(e){return e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
2
2
|
`)}const C={"session.start":`durable`,"session.end":`durable`,"session.cleared":`durable`,"prompt.start":`durable`,"prompt.end":`durable`,"prompt.continued":`durable`,"turn.start":`durable`,"turn.end":`durable`,"tool.call.start":`durable`,"tool.call.end":`durable`,"messages.persist":`durable`,"compaction.start":`durable`,"compaction.end":`durable`,"memory.pruned":`durable`,error:`durable`,"stream.event":`live`,"streaming.start":`live`,"streaming.end":`live`,"agent.status":`live`,"steer.consumed":`live`,"run.paused":`live`,"run.resumed":`live`,"run.pause_requested":`live`,"run.pause_cancelled":`live`,"approval.required":`capability`,"approval.resolved":`capability`,"ask.user.required":`capability`,"ask.user.resolved":`capability`,"plan.approval.required":`capability`,"plan.approval.resolved":`capability`,"budget.notice":`capability`,"prompt.budget.notice":`capability`,"tool.call.mismatch.notice":`capability`,"image.degradation.notice":`capability`,"progress.stall.notice":`capability`,"compaction.reactive.notice":`capability`,"session.cost-budget-exceeded":`capability`,"session.crash-gap-detected":`capability`,"session.history-capped":`capability`,"session.write-lease-denied":`capability`,"session.write-lease-restored":`capability`};function w(e){return C[e]}export{e as CONVERSATION_SUMMARY_PREFIX,C as EVENT_DOMAIN,_ as SYSTEM_PROMPT_SECTIONS,v as SYSTEM_PROMPT_SECTION_ORDER,s as adjustDismissedSigil,b as applySectionBudget,c as applySigilCompletion,l as applySigilReplacement,r as boundFragment,g as collectModelCapabilityFacts,i as contextFragmentBytes,u as evaluateSigilTrigger,d as extractSigilPrefix,S as extractToolResultText,w as getEventDomain,t as getToolCallsByAssistantMessage,n as hasToolCalls,f as isSigilDismissed,m as modelImageCapability,h as modelSupportsImages,a as normalizeImageData,p as sigilOf,o as toAnthropicImageMime};
|
package/dist/message.d.ts
CHANGED
|
@@ -5,7 +5,17 @@ type KnownApi = 'openai-completions' | 'openai-responses' | 'azure-openai-respon
|
|
|
5
5
|
type Api = KnownApi | (string & {});
|
|
6
6
|
type KnownProvider = 'anthropic' | 'openai' | 'google' | 'amazon-bedrock' | 'github-copilot' | 'xai' | 'groq' | 'openrouter' | 'deepseek' | 'ollama' | 'moonshot' | 'custom';
|
|
7
7
|
type Provider = KnownProvider | (string & {});
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* RFC-421(新发现,会话 fe6bc77e 事故复盘):`'incomplete'` — SSE 流在未产出任何终止帧
|
|
10
|
+
* (`finish_reason` / `message_delta.stop_reason` / `response.completed|incomplete`)的
|
|
11
|
+
* 情况下就结束(`[DONE]` 或对端正常关闭连接,非网络异常,不触发 NetworkError 重试)。
|
|
12
|
+
* 常见根因:上游网关的输出侧内容审查在生成中途静默关流。此前各 wire 协议在这种情况下把
|
|
13
|
+
* `stopReason` 悄悄留在初始默认值 `'end_turn'`,与"模型自己决定说完了"完全不可区分——
|
|
14
|
+
* 残缺文本被当作正常完成上抛,用户看到的是"回复说到一半突然停了"且无任何诊断信号。
|
|
15
|
+
* 新增该值使 wire 层能诚实标注"流未正常终止",供 agent 层的 handleIncompleteStream
|
|
16
|
+
* 识别并注入续写引导(而非静默终止或误判为空转/空响应)。
|
|
17
|
+
*/
|
|
18
|
+
type StopReason = 'end_turn' | 'max_tokens' | 'tool_use' | 'stop_sequence' | 'refusal' | 'incomplete';
|
|
9
19
|
interface Usage {
|
|
10
20
|
inputTokens: number;
|
|
11
21
|
outputTokens: number;
|