@x-otto/interchange 0.1.0-alpha.13 → 0.1.0-alpha.15

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.
@@ -13,7 +13,7 @@
13
13
  * CODE-STYLE.md §6b)。片段内容被截断只损失尾部信息,不改变已注入部分的可读性。
14
14
  */
15
15
  /** system prompt 注入片段的类型化 id(与 SYSTEM_PROMPT_SECTIONS 的字段一一对应)。 */
16
- type ContextFragmentId = 'toolGuidance' | 'skillLoopGuidance' | 'environment' | 'agentKnowledge' | 'memoryIndex' | 'skillCatalog' | 'lesson' | 'lessonRelevantHints' | 'memoryDelta' | 'todoReminder' | 'docSyncReminder' | 'internalize' | 'pluginFailures';
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,21 +303,23 @@ 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;
318
309
  readonly lane: "stable";
319
- readonly budgetBytes: 8000;
310
+ readonly budgetBytes: 2000;
311
+ };
312
+ /**
313
+ * date/gitBranch/gitStatus——真正逐轮可能变化的环境事实,volatile lane(priority 26,
314
+ * 紧跟 stable environment 之后):每轮重算、落在 prompt cache 断点之后,不冻结、
315
+ * 不击穿 stable 前缀。走 `defineHook` 直接推 `output.systemTail`(同 memory-delta/
316
+ * todo-reminder 既有模式),不经 `definePromptSection`(该便捷层只服务 stable lane)。
317
+ */
318
+ readonly environmentVolatile: {
319
+ readonly name: "runtime:environment-volatile";
320
+ readonly priority: 26;
321
+ readonly lane: "volatile";
322
+ readonly budgetBytes: 4000;
320
323
  };
321
324
  readonly agentKnowledge: {
322
325
  readonly name: "agent-knowledge-injection";
@@ -336,30 +339,6 @@ declare const SYSTEM_PROMPT_SECTIONS: {
336
339
  readonly lane: "volatile";
337
340
  readonly budgetBytes: 4000;
338
341
  };
339
- /**
340
- * RFC-383 M2(§9 修订 6):高频 skill 内化指令核心——引擎内部 hook
341
- * `internalize-skill-injection` 的 volatile 尾段预算面。**必须注册**:不注册则
342
- * applySectionBudget 原样放行、4KB 硬顶失效(决策器提炼不受控)。priority 42 排在
343
- * lessonRelevantHints(41) 之后、memoryDelta(60) 之前。
344
- */
345
- readonly internalize: {
346
- readonly name: "internalize-skill-injection";
347
- readonly priority: 42;
348
- readonly lane: "volatile";
349
- readonly budgetBytes: 4000;
350
- };
351
- /**
352
- * RFC-445 M2(A7):插件失败候选——宿主 onLoadError 桥构造的结构化失败摘要,
353
- * 经 volatile systemTail 受控注入(对齐 RFC-327 §9.1 放宽条款)。时效性强
354
- * (失败当下就该被下一轮感知)故排在内化之后、memory-delta 之前。**必须注册**:
355
- * 不注册则 applySectionBudget 原样放行、4KB 硬顶失效。
356
- */
357
- readonly pluginFailures: {
358
- readonly name: "plugin-failures-injection";
359
- readonly priority: 55;
360
- readonly lane: "volatile";
361
- readonly budgetBytes: 4000;
362
- };
363
342
  readonly memoryDelta: {
364
343
  readonly name: "memory-delta-injection";
365
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},skillLoopGuidance:{name:`skill-loop-guidance-injection`,priority:21,lane:`stable`,budgetBytes:2e3},environment:{name:`runtime:environment`,priority:25,lane:`stable`,budgetBytes:8e3},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},internalize:{name:`internalize-skill-injection`,priority:42,lane:`volatile`,budgetBytes:4e3},pluginFailures:{name:`plugin-failures-injection`,priority:55,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`,"skill-loop-guidance-injection":`skillLoopGuidance`,"runtime:environment":`environment`,"agent-knowledge-injection":`agentKnowledge`,"runtime:memory-index":`memoryIndex`,"skill-catalog-injection":`skillCatalog`,"lesson-injection":`lesson`,"lesson-relevant-hints":`lessonRelevantHints`,"internalize-skill-injection":`internalize`,"plugin-failures-injection":`pluginFailures`,"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(`
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@x-otto/interchange",
3
- "version": "0.1.0-alpha.13",
3
+ "version": "0.1.0-alpha.15",
4
4
  "files": [
5
5
  "dist"
6
6
  ],