agentfootprint 7.19.0 → 7.20.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 (97) hide show
  1. package/AGENTS.md +9 -6
  2. package/README.md +3 -3
  3. package/ai-instructions/claude-code/SKILL.md +9 -6
  4. package/ai-instructions/clinerules +1 -1
  5. package/ai-instructions/copilot-instructions.md +1 -1
  6. package/ai-instructions/cursor/agentfootprint.md +1 -1
  7. package/ai-instructions/kiro/agentfootprint.md +1 -1
  8. package/ai-instructions/windsurfrules +1 -1
  9. package/dist/core/agent/AgentBuilder.js +9 -0
  10. package/dist/core/agent/AgentBuilder.js.map +1 -1
  11. package/dist/core/agent/memoryRecallInjections.js +8 -0
  12. package/dist/core/agent/memoryRecallInjections.js.map +1 -1
  13. package/dist/core/slots/buildMessagesSlot.js +23 -4
  14. package/dist/core/slots/buildMessagesSlot.js.map +1 -1
  15. package/dist/esm/core/agent/AgentBuilder.d.ts +5 -0
  16. package/dist/esm/core/agent/AgentBuilder.js +9 -0
  17. package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
  18. package/dist/esm/core/agent/memoryRecallInjections.js +8 -0
  19. package/dist/esm/core/agent/memoryRecallInjections.js.map +1 -1
  20. package/dist/esm/core/slots/buildMessagesSlot.d.ts +16 -2
  21. package/dist/esm/core/slots/buildMessagesSlot.js +23 -4
  22. package/dist/esm/core/slots/buildMessagesSlot.js.map +1 -1
  23. package/dist/esm/lib/injection-engine/factories/defineFact.d.ts +7 -11
  24. package/dist/esm/lib/injection-engine/factories/defineFact.js +9 -7
  25. package/dist/esm/lib/injection-engine/factories/defineFact.js.map +1 -1
  26. package/dist/esm/lib/injection-engine/factories/defineInstruction.d.ts +10 -19
  27. package/dist/esm/lib/injection-engine/factories/defineInstruction.js +6 -4
  28. package/dist/esm/lib/injection-engine/factories/defineInstruction.js.map +1 -1
  29. package/dist/esm/lib/injection-engine/messagesSlotRefusal.d.ts +31 -0
  30. package/dist/esm/lib/injection-engine/messagesSlotRefusal.js +40 -0
  31. package/dist/esm/lib/injection-engine/messagesSlotRefusal.js.map +1 -0
  32. package/dist/esm/lib/injection-engine/types.d.ts +12 -1
  33. package/dist/esm/lib/injection-engine/types.js.map +1 -1
  34. package/dist/esm/lib/mcp/mcpServe.d.ts +8 -0
  35. package/dist/esm/lib/mcp/mcpServe.js +25 -0
  36. package/dist/esm/lib/mcp/mcpServe.js.map +1 -1
  37. package/dist/esm/lib/mcp/types.d.ts +26 -0
  38. package/dist/esm/lib/rag/defineRAG.d.ts +4 -19
  39. package/dist/esm/lib/rag/defineRAG.js +9 -4
  40. package/dist/esm/lib/rag/defineRAG.js.map +1 -1
  41. package/dist/esm/memory/asRoleRefusal.d.ts +43 -0
  42. package/dist/esm/memory/asRoleRefusal.js +55 -0
  43. package/dist/esm/memory/asRoleRefusal.js.map +1 -0
  44. package/dist/esm/memory/define.d.ts +2 -1
  45. package/dist/esm/memory/define.js +7 -20
  46. package/dist/esm/memory/define.js.map +1 -1
  47. package/dist/esm/memory/define.types.d.ts +3 -5
  48. package/dist/esm/memory/define.types.js +3 -1
  49. package/dist/esm/memory/define.types.js.map +1 -1
  50. package/dist/esm/memory/stages/formatDefault.js +17 -7
  51. package/dist/esm/memory/stages/formatDefault.js.map +1 -1
  52. package/dist/lib/injection-engine/factories/defineFact.js +9 -7
  53. package/dist/lib/injection-engine/factories/defineFact.js.map +1 -1
  54. package/dist/lib/injection-engine/factories/defineInstruction.js +6 -4
  55. package/dist/lib/injection-engine/factories/defineInstruction.js.map +1 -1
  56. package/dist/lib/injection-engine/messagesSlotRefusal.js +44 -0
  57. package/dist/lib/injection-engine/messagesSlotRefusal.js.map +1 -0
  58. package/dist/lib/injection-engine/types.js.map +1 -1
  59. package/dist/lib/mcp/mcpServe.js +25 -0
  60. package/dist/lib/mcp/mcpServe.js.map +1 -1
  61. package/dist/lib/rag/defineRAG.js +9 -4
  62. package/dist/lib/rag/defineRAG.js.map +1 -1
  63. package/dist/memory/asRoleRefusal.js +60 -0
  64. package/dist/memory/asRoleRefusal.js.map +1 -0
  65. package/dist/memory/define.js +7 -20
  66. package/dist/memory/define.js.map +1 -1
  67. package/dist/memory/define.types.js +3 -1
  68. package/dist/memory/define.types.js.map +1 -1
  69. package/dist/memory/stages/formatDefault.js +17 -7
  70. package/dist/memory/stages/formatDefault.js.map +1 -1
  71. package/dist/types/core/agent/AgentBuilder.d.ts +5 -0
  72. package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
  73. package/dist/types/core/agent/memoryRecallInjections.d.ts.map +1 -1
  74. package/dist/types/core/slots/buildMessagesSlot.d.ts +16 -2
  75. package/dist/types/core/slots/buildMessagesSlot.d.ts.map +1 -1
  76. package/dist/types/lib/injection-engine/factories/defineFact.d.ts +7 -11
  77. package/dist/types/lib/injection-engine/factories/defineFact.d.ts.map +1 -1
  78. package/dist/types/lib/injection-engine/factories/defineInstruction.d.ts +10 -19
  79. package/dist/types/lib/injection-engine/factories/defineInstruction.d.ts.map +1 -1
  80. package/dist/types/lib/injection-engine/messagesSlotRefusal.d.ts +32 -0
  81. package/dist/types/lib/injection-engine/messagesSlotRefusal.d.ts.map +1 -0
  82. package/dist/types/lib/injection-engine/types.d.ts +12 -1
  83. package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
  84. package/dist/types/lib/mcp/mcpServe.d.ts +8 -0
  85. package/dist/types/lib/mcp/mcpServe.d.ts.map +1 -1
  86. package/dist/types/lib/mcp/types.d.ts +26 -0
  87. package/dist/types/lib/mcp/types.d.ts.map +1 -1
  88. package/dist/types/lib/rag/defineRAG.d.ts +4 -19
  89. package/dist/types/lib/rag/defineRAG.d.ts.map +1 -1
  90. package/dist/types/memory/asRoleRefusal.d.ts +44 -0
  91. package/dist/types/memory/asRoleRefusal.d.ts.map +1 -0
  92. package/dist/types/memory/define.d.ts +2 -1
  93. package/dist/types/memory/define.d.ts.map +1 -1
  94. package/dist/types/memory/define.types.d.ts +3 -5
  95. package/dist/types/memory/define.types.d.ts.map +1 -1
  96. package/dist/types/memory/stages/formatDefault.d.ts.map +1 -1
  97. package/package.json +1 -1
@@ -10,7 +10,7 @@
10
10
  * Produces an `Injection` with:
11
11
  * - flavor: `'fact'`
12
12
  * - trigger: configurable (default `'always'`)
13
- * - inject: targets `systemPrompt` OR `messages` (consumer chooses)
13
+ * - inject: `systemPrompt` — the slot that reaches the model
14
14
  *
15
15
  * @example
16
16
  * const userProfile = defineFact({
@@ -21,10 +21,9 @@
21
21
  * const turnTime = defineFact({
22
22
  * id: 'turn-time',
23
23
  * data: `Current time: ${new Date().toISOString()}`,
24
- * slot: 'messages',
25
- * role: 'system',
26
24
  * });
27
25
  */
26
+ import { messagesSlotRefusal } from '../messagesSlotRefusal.js';
28
27
  import { resolveCachePolicy } from '../../../cache/applyCachePolicy.js';
29
28
  export function defineFact(opts) {
30
29
  if (!opts.id || opts.id.trim().length === 0) {
@@ -33,13 +32,16 @@ export function defineFact(opts) {
33
32
  if (!opts.data || opts.data.length === 0) {
34
33
  throw new Error(`defineFact(${opts.id}): \`data\` is required.`);
35
34
  }
35
+ // The type already rules `'messages'` out for TypeScript callers; this
36
+ // catches the JavaScript ones and the `as never` casts, because a
37
+ // refusal that only exists at compile time is not a refusal.
38
+ if (opts.slot === 'messages') {
39
+ throw new Error(messagesSlotRefusal(`defineFact('${opts.id}')`));
40
+ }
36
41
  const trigger = opts.activeWhen
37
42
  ? { kind: 'rule', activeWhen: opts.activeWhen }
38
43
  : { kind: 'always' };
39
- const slot = opts.slot ?? 'system-prompt';
40
- const inject = slot === 'messages'
41
- ? { messages: [{ role: opts.role ?? 'system', content: opts.data }] }
42
- : { systemPrompt: opts.data };
44
+ const inject = { systemPrompt: opts.data };
43
45
  const cache = resolveCachePolicy('fact', opts.cache);
44
46
  // Two-stage cast (`as unknown as Injection`) is required because
45
47
  // `flavor: 'fact'` narrows tighter than `ContextSource`. Both stages
@@ -1 +1 @@
1
- {"version":3,"file":"defineFact.js","sourceRoot":"","sources":["../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AC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IACvB,MAAM,MAAM,GAAG,EAAE,YAAY,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;IAE3C,MAAM,KAAK,GAAG,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACrD,iEAAiE;IACjE,qEAAqE;IACrE,uEAAuE;IACvE,gEAAgE;IAChE,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;QAC1D,MAAM,EAAE,MAAe;QACvB,OAAO;QACP,MAAM;QACN,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;KACnC,CAAyB,CAAC;AAC7B,CAAC"}
@@ -27,7 +27,6 @@
27
27
  * prompt: 'PII has been redacted. Do not include emails or phone numbers.',
28
28
  * });
29
29
  */
30
- import type { ContextRole } from '../../../events/types.js';
31
30
  import type { Injection, InjectionContext } from '../types.js';
32
31
  import type { CachePolicy } from '../../../cache/types.js';
33
32
  export interface DefineInstructionOptions {
@@ -42,28 +41,20 @@ export interface DefineInstructionOptions {
42
41
  * `agentfootprint.context.evaluated`.
43
42
  */
44
43
  readonly activeWhen?: (ctx: InjectionContext) => boolean;
45
- /** Instruction text. Lands in the slot specified by `slot` (default system-prompt). */
44
+ /** Instruction text. Lands in the system-prompt slot. */
46
45
  readonly prompt: string;
47
46
  /**
48
- * Where the instruction lands.
47
+ * Where the instruction lands. `'system-prompt'` (the default) is the
48
+ * only slot an instruction can land in: it is the one every provider
49
+ * delivers.
49
50
  *
50
- * - `'system-prompt'` (default) — appended to the system prompt.
51
- * Lower attention than recent messages but always available.
52
- * - `'messages'` — appended as a recent message. **Higher attention
53
- * weight** — the LLM reads recent messages more carefully than
54
- * system-prompt text. Use this for guidance that MUST be salient
55
- * on this turn (post-tool-result reminders, urgent corrections).
56
- *
57
- * Same instruction object can target both slots in different agents
58
- * — the trigger semantics don't change.
59
- */
60
- readonly slot?: 'system-prompt' | 'messages';
61
- /**
62
- * When `slot: 'messages'`, the role to use. Default `'system'`.
63
- * `'user'` is also valid; `'assistant'` and `'tool'` work in
64
- * principle but rarely make pedagogical sense.
51
+ * `'messages'` is REFUSED — see {@link messagesSlotRefusal}. It was
52
+ * accepted before 7.19.1 and documented as the recency-first
53
+ * placement; it was recorded as injected and never sent. To make a
54
+ * rule salient at the moment it matters, return it from the tool whose
55
+ * result it is about — a tool result IS a recent message.
65
56
  */
66
- readonly role?: ContextRole;
57
+ readonly slot?: 'system-prompt';
67
58
  /**
68
59
  * Cache policy for this instruction. Defaults to `'never'` —
69
60
  * instructions are typically rule-based (volatile per-iter
@@ -27,6 +27,7 @@
27
27
  * prompt: 'PII has been redacted. Do not include emails or phone numbers.',
28
28
  * });
29
29
  */
30
+ import { messagesSlotRefusal } from '../messagesSlotRefusal.js';
30
31
  import { resolveCachePolicy } from '../../../cache/applyCachePolicy.js';
31
32
  export function defineInstruction(opts) {
32
33
  if (!opts.id || opts.id.trim().length === 0) {
@@ -35,13 +36,14 @@ export function defineInstruction(opts) {
35
36
  if (!opts.prompt || opts.prompt.length === 0) {
36
37
  throw new Error(`defineInstruction(${opts.id}): \`prompt\` is required.`);
37
38
  }
39
+ // Refused at run time as well as in the type — see defineFact for why.
40
+ if (opts.slot === 'messages') {
41
+ throw new Error(messagesSlotRefusal(`defineInstruction('${opts.id}')`));
42
+ }
38
43
  const trigger = opts.activeWhen
39
44
  ? { kind: 'rule', activeWhen: opts.activeWhen }
40
45
  : { kind: 'always' };
41
- const slot = opts.slot ?? 'system-prompt';
42
- const inject = slot === 'messages'
43
- ? { messages: [{ role: opts.role ?? 'system', content: opts.prompt }] }
44
- : { systemPrompt: opts.prompt };
46
+ const inject = { systemPrompt: opts.prompt };
45
47
  const cache = resolveCachePolicy('instruction', opts.cache);
46
48
  return Object.freeze({
47
49
  id: opts.id,
@@ -1 +1 @@
1
- {"version":3,"file":"defineInstruction.js","sourceRoot":"","sources":["../../../../../src/lib/injection-engine/factories/defineInstruction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAiDxE,MAAM,UAAU,iBAAiB,CAAC,IAA8B;IAC9D,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAChF,CAAC;IACD,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,CAAC,EAAE,4BAA4B,CAAC,CAAC;IAC5E,CAAC;IACD,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU;QAC7B,CAAC,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE;QACxD,CAAC,CAAC,EAAE,IAAI,EAAE,QAAiB,EAAE,CAAC;IAChC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,eAAe,CAAC;IAC1C,MAAM,MAAM,GACV,IAAI,KAAK,UAAU;QACjB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE;QACvE,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;IACpC,MAAM,KAAK,GAAG,kBAAkB,CAAC,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5D,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;QAC1D,MAAM,EAAE,cAAuB;QAC/B,OAAO;QACP,MAAM;QACN,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;KACnC,CAAyB,CAAC;AAC7B,CAAC"}
1
+ {"version":3,"file":"defineInstruction.js","sourceRoot":"","sources":["../../../../../src/lib/injection-engine/factories/defineInstruction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAyCxE,MAAM,UAAU,iBAAiB,CAAC,IAA8B;IAC9D,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAChF,CAAC;IACD,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,CAAC,EAAE,4BAA4B,CAAC,CAAC;IAC5E,CAAC;IACD,uEAAuE;IACvE,IAAK,IAAI,CAAC,IAA2B,KAAK,UAAU,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,sBAAsB,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;IAC1E,CAAC;IACD,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU;QAC7B,CAAC,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE;QACxD,CAAC,CAAC,EAAE,IAAI,EAAE,QAAiB,EAAE,CAAC;IAChC,MAAM,MAAM,GAAqB,EAAE,YAAY,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;IAC/D,MAAM,KAAK,GAAG,kBAAkB,CAAC,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5D,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;QAC1D,MAAM,EAAE,cAAuB;QAC/B,OAAO;QACP,MAAM;QACN,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;KACnC,CAAyB,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The messages-slot refusal — one sentence, said in every place the
3
+ * declaration can be made.
4
+ *
5
+ * WHY this exists at all: an Injection targeting the messages slot was
6
+ * RECORDED as injected — `context.injected` fired with its content, the
7
+ * slot composition counted it, the engine routed it — while the request
8
+ * assembled its message list from the conversation itself, so the model
9
+ * never saw it. The recording said one thing and the wire said another.
10
+ *
11
+ * Delivering it instead is not a one-line change, and doing it badly
12
+ * would be worse than the gap: the wire has no system role INSIDE the
13
+ * message list (the Anthropic and Bedrock adapters drop such a message —
14
+ * system is a separate top-level field — while the OpenAI adapters carry
15
+ * it), and `'system'` was the default role here. Wiring the slot up
16
+ * without a per-provider notion of what a provider can carry would
17
+ * replace one uniform gap with a provider-dependent one, and nothing in
18
+ * the recording would tell the two apart. Honest delivery needs a
19
+ * wire-carrying key out of the slot, that provider capability, and a
20
+ * message-sequence rule — a designed feature, not a patch.
21
+ *
22
+ * So until that exists, the declaration is refused where it is written.
23
+ * Absence beats a lie: nothing that worked stops working, and something
24
+ * that never worked stops pretending.
25
+ */
26
+ /**
27
+ * The refusal text, addressed from `site` (e.g. `defineFact('turn-time')`).
28
+ * Names the limitation and the three placements that DO reach the model,
29
+ * because a refusal that does not teach just moves the puzzle.
30
+ */
31
+ export declare function messagesSlotRefusal(site: string): string;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The messages-slot refusal — one sentence, said in every place the
3
+ * declaration can be made.
4
+ *
5
+ * WHY this exists at all: an Injection targeting the messages slot was
6
+ * RECORDED as injected — `context.injected` fired with its content, the
7
+ * slot composition counted it, the engine routed it — while the request
8
+ * assembled its message list from the conversation itself, so the model
9
+ * never saw it. The recording said one thing and the wire said another.
10
+ *
11
+ * Delivering it instead is not a one-line change, and doing it badly
12
+ * would be worse than the gap: the wire has no system role INSIDE the
13
+ * message list (the Anthropic and Bedrock adapters drop such a message —
14
+ * system is a separate top-level field — while the OpenAI adapters carry
15
+ * it), and `'system'` was the default role here. Wiring the slot up
16
+ * without a per-provider notion of what a provider can carry would
17
+ * replace one uniform gap with a provider-dependent one, and nothing in
18
+ * the recording would tell the two apart. Honest delivery needs a
19
+ * wire-carrying key out of the slot, that provider capability, and a
20
+ * message-sequence rule — a designed feature, not a patch.
21
+ *
22
+ * So until that exists, the declaration is refused where it is written.
23
+ * Absence beats a lie: nothing that worked stops working, and something
24
+ * that never worked stops pretending.
25
+ */
26
+ /**
27
+ * The refusal text, addressed from `site` (e.g. `defineFact('turn-time')`).
28
+ * Names the limitation and the three placements that DO reach the model,
29
+ * because a refusal that does not teach just moves the puzzle.
30
+ */
31
+ export function messagesSlotRefusal(site) {
32
+ return (`${site}: the messages slot does not reach the model, so this content would be ` +
33
+ `recorded as injected and never sent. The request's message list is assembled from ` +
34
+ `the conversation itself; the messages slot is the observability projection of it. ` +
35
+ `Three placements do reach the model: \`slot: 'system-prompt'\` (the default — ` +
36
+ `delivered by every provider), a tool's return value (tool results are real ` +
37
+ `messages, at the recency this option was reaching for), and the text passed to ` +
38
+ `\`agent.run({ message })\`.`);
39
+ }
40
+ //# sourceMappingURL=messagesSlotRefusal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messagesSlotRefusal.js","sourceRoot":"","sources":["../../../../src/lib/injection-engine/messagesSlotRefusal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,OAAO,CACL,GAAG,IAAI,yEAAyE;QAChF,oFAAoF;QACpF,oFAAoF;QACpF,gFAAgF;QAChF,6EAA6E;QAC7E,iFAAiF;QACjF,6BAA6B,CAC9B,CAAC;AACJ,CAAC"}
@@ -56,7 +56,18 @@ export type InjectionTrigger =
56
56
  export interface InjectionContent {
57
57
  /** Text appended to the system-prompt slot when active. */
58
58
  readonly systemPrompt?: string;
59
- /** Messages prepended to the messages slot when active. */
59
+ /**
60
+ * Messages appended to the messages slot when active.
61
+ *
62
+ * **Not delivered to the model, and refused where it can be declared**
63
+ * (`defineFact` / `defineInstruction` / `Agent.injection()`) since
64
+ * 7.19.1: the request's message list is assembled from the
65
+ * conversation, so content placed here was recorded as injected and
66
+ * never sent. The field stays on the type for the engine's internal
67
+ * memory-recall bridge and for the delivery feature that will make it
68
+ * true; nothing a consumer can declare reaches it. See
69
+ * `messagesSlotRefusal.ts` for the full reasoning.
70
+ */
60
71
  readonly messages?: ReadonlyArray<{
61
72
  readonly role: ContextRole;
62
73
  readonly content: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/lib/injection-engine/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAkOH,wEAAwE;AACxE,MAAM,UAAU,sBAAsB,CAAC,GAAc;IACnD,qEAAqE;IACrE,yEAAyE;IACzE,uEAAuE;IACvE,MAAM,IAAI,GAAG,GAAG,CAAC,QAAuE,CAAC;IACzF,MAAM,GAAG,GAAoB;QAC3B,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,MAAM,EAAE,GAAG,CAAC,M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AC3B,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,GAAG,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC;QACxD,GAAG,CAAC,IAAI,EAAE,WAAW,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,WAA6C,EAAE,CAAC;QAC7F,GAAG,CAAC,IAAI,EAAE,YAAY,IAAI;YACxB,YAAY,EAAE,IAAI,CAAC,YAA+C;SACnE,CAAC;QACF,MAAM,EAAE;YACN,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YACzE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;YACpF,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI;gBACtB,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;oBAClC,MAAM,EAAE,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE;oBACvB,WAAW,EAAE,GAAG,CAAC,EAAE;iBACpB,CAAC,CAAC;aACJ,CAAC;SACH;KACF,CAAC;IACF,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -9,6 +9,14 @@
9
9
  * // …later
10
10
  * await handle.close();
11
11
  *
12
+ * Over HTTP the handle also reports the socket it bound, so `port: 0`
13
+ * ("any free port") is usable from the outside:
14
+ *
15
+ * const handle = await mcpServe(tools, {
16
+ * transport: { transport: 'http', port: 0, host: '127.0.0.1' },
17
+ * });
18
+ * connect(`http://127.0.0.1:${handle.port}/mcp`);
19
+ *
12
20
  * `mcpClient` pulls someone else's tools in. This pushes yours out, so
13
21
  * the tool you already wrote, tested and governed can be called by any
14
22
  * MCP client — a desktop host, another team's agent, an IDE — without
@@ -9,6 +9,14 @@
9
9
  * // …later
10
10
  * await handle.close();
11
11
  *
12
+ * Over HTTP the handle also reports the socket it bound, so `port: 0`
13
+ * ("any free port") is usable from the outside:
14
+ *
15
+ * const handle = await mcpServe(tools, {
16
+ * transport: { transport: 'http', port: 0, host: '127.0.0.1' },
17
+ * });
18
+ * connect(`http://127.0.0.1:${handle.port}/mcp`);
19
+ *
12
20
  * `mcpClient` pulls someone else's tools in. This pushes yours out, so
13
21
  * the tool you already wrote, tested and governed can be called by any
14
22
  * MCP client — a desktop host, another team's agent, an IDE — without
@@ -158,6 +166,14 @@ export async function mcpServe(tools, opts = {}) {
158
166
  return {
159
167
  name,
160
168
  toolNames: listing.map((t) => t.name),
169
+ // Present only when a socket was bound (the http transport). Spread so
170
+ // a stdio handle has no `port` key at all, rather than one holding
171
+ // undefined — "there is no socket" and "the socket is unknown" are
172
+ // different claims.
173
+ ...(connection.bound !== undefined && {
174
+ port: connection.bound.port,
175
+ address: connection.bound.address,
176
+ }),
161
177
  async close() {
162
178
  if (closed)
163
179
  return;
@@ -398,7 +414,16 @@ async function connectHttp(transport, newServer) {
398
414
  else
399
415
  listener.listen(transport.port, resolve);
400
416
  });
417
+ // Read the socket AFTER listen resolves — before that, `port: 0` is still
418
+ // 0 and the address is null. A pipe/socket-path bind reports a string
419
+ // instead of an AddressInfo; there is no port to report then, so we report
420
+ // none rather than a made-up one.
421
+ const bound = listener.address();
401
422
  return {
423
+ ...(bound !== null &&
424
+ typeof bound === 'object' && {
425
+ bound: { port: bound.port, address: bound.address },
426
+ }),
402
427
  close: () => new Promise((resolve, reject) => {
403
428
  listener.close((err) => (err ? reject(err) : resolve()));
404
429
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"mcpServe.js","sourceRoot":"","sources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AQ,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC/B,IAAI,SAAS,CAAC,IAAI,KAAK,SAAS;YAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;;YACtF,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,0EAA0E;IAC1E,sEAAsE;IACtE,2EAA2E;IAC3E,kCAAkC;IAClC,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;IAEjC,OAAO;QACL,GAAG,CAAC,KAAK,KAAK,IAAI;YAChB,OAAO,KAAK,KAAK,QAAQ,IAAI;YAC3B,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE;SACpD,CAAC;QACJ,KAAK,EAAE,GAAG,EAAE,CACV,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACpC,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC3D,CAAC,CAAC;KACL,CAAC;AACJ,CAAC"}
@@ -274,6 +274,32 @@ export interface McpServeHandle {
274
274
  readonly name: string;
275
275
  /** Names of the tools being served, in the order clients will list them. */
276
276
  readonly toolNames: readonly string[];
277
+ /**
278
+ * The port the listener actually bound, for the `http` transport only —
279
+ * absent for `stdio`, which has no socket.
280
+ *
281
+ * It is here because `port: 0` means "any free port", and the caller who
282
+ * asked for one had no way to learn which one they got: the number the OS
283
+ * chose lived inside a listener nobody could see. Serving on `0` and
284
+ * reading this back is the supported way to run a server on an
285
+ * unpredictable port — a test suite, a dev tool, several replicas on one
286
+ * machine.
287
+ *
288
+ * With an explicit port this reports the same number back, so code can
289
+ * read it unconditionally rather than branching on how the port was set.
290
+ */
291
+ readonly port?: number;
292
+ /**
293
+ * The address the listener bound, for the `http` transport only — as the
294
+ * OS reports it, so `'127.0.0.1'` when a host was given and `'::'` (or
295
+ * `'0.0.0.0'`) when one was not.
296
+ *
297
+ * Reported rather than assembled into a URL on purpose: a wildcard bind is
298
+ * not an address a client can dial, and a handle that handed one out would
299
+ * be inventing reachability it cannot promise. Pair it with `port` and the
300
+ * host you know your callers can reach.
301
+ */
302
+ readonly address?: string;
277
303
  /**
278
304
  * Stop serving: closes the transport (and, for `http`, the listening
279
305
  * socket) and then the MCP server. Idempotent — calling it twice is
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * RAG is a context-engineering flavor: embed the user's question,
5
5
  * retrieve top-K semantically similar chunks from a vector store,
6
- * inject those chunks into the messages slot of the next LLM call.
6
+ * inject those chunks into the system-prompt slot of the next LLM call.
7
7
  * It's the same plumbing as `defineMemory({ type: SEMANTIC,
8
8
  * strategy: TOP_K })` — the rename is for intent + ergonomics.
9
9
  *
@@ -13,7 +13,7 @@
13
13
  * └─► CAUSAL (footprintjs decision snapshots)
14
14
  *
15
15
  * defineRAG ─► SEMANTIC + TOP_K with RAG-specific defaults
16
- * (asRole='user', threshold=0.7, no LLM-extract)
16
+ * (topK=3, threshold=0.7, no LLM-extract)
17
17
  *
18
18
  * Pattern: Composition over duplication — defineRAG returns a
19
19
  * MemoryDefinition produced by defineMemory. No new engine
@@ -27,10 +27,11 @@
27
27
  *
28
28
  * Emits: Indirectly — the underlying memory pipeline emits
29
29
  * `agentfootprint.context.injected` when retrieved chunks
30
- * land in the messages slot.
30
+ * land in the system-prompt slot.
31
31
  *
32
32
  * @see ./indexDocuments.ts for the seeding helper
33
33
  * @see ../../memory/define.ts for the underlying factory
34
+ * @see ../../memory/asRoleRefusal.ts for why `asRole` is refused, not honoured
34
35
  *
35
36
  * @example Basic usage
36
37
  * ```ts
@@ -61,7 +62,6 @@ import { mock } from 'agentfootprint/llm-providers';
61
62
  * .build();
62
63
  * ```
63
64
  */
64
- import type { ContextRole } from '../../events/types.js';
65
65
  import type { Embedder } from '../../memory/embedding/index.js';
66
66
  import type { MemoryStore } from '../../memory/store/index.js';
67
67
  import type { MemoryDefinition } from '../../memory/define.types.js';
@@ -112,21 +112,6 @@ export interface DefineRAGOptions {
112
112
  * sit comfortably with 0.7.
113
113
  */
114
114
  readonly threshold?: number;
115
- /**
116
- * Role to use when injecting retrieved chunks into the messages
117
- * slot. Default `'user'`.
118
- *
119
- * Why `'user'`: in tool-using ReAct loops, retrieved chunks
120
- * conceptually "augment what the user asked." Anthropic's tool-use
121
- * cookbook and OpenAI's RAG cookbook both show retrieved context
122
- * inside user-turn messages.
123
- *
124
- * Use `'system'` for authoritative reference docs that should
125
- * outweigh user instruction (policy / compliance / brand-voice
126
- * corpora). Use `'assistant'` only if you've persisted prior agent
127
- * turns as context — rare.
128
- */
129
- readonly asRole?: ContextRole;
130
115
  }
131
116
  /**
132
117
  * Build a RAG context-engineering definition. The returned
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * RAG is a context-engineering flavor: embed the user's question,
5
5
  * retrieve top-K semantically similar chunks from a vector store,
6
- * inject those chunks into the messages slot of the next LLM call.
6
+ * inject those chunks into the system-prompt slot of the next LLM call.
7
7
  * It's the same plumbing as `defineMemory({ type: SEMANTIC,
8
8
  * strategy: TOP_K })` — the rename is for intent + ergonomics.
9
9
  *
@@ -13,7 +13,7 @@
13
13
  * └─► CAUSAL (footprintjs decision snapshots)
14
14
  *
15
15
  * defineRAG ─► SEMANTIC + TOP_K with RAG-specific defaults
16
- * (asRole='user', threshold=0.7, no LLM-extract)
16
+ * (topK=3, threshold=0.7, no LLM-extract)
17
17
  *
18
18
  * Pattern: Composition over duplication — defineRAG returns a
19
19
  * MemoryDefinition produced by defineMemory. No new engine
@@ -27,10 +27,11 @@
27
27
  *
28
28
  * Emits: Indirectly — the underlying memory pipeline emits
29
29
  * `agentfootprint.context.injected` when retrieved chunks
30
- * land in the messages slot.
30
+ * land in the system-prompt slot.
31
31
  *
32
32
  * @see ./indexDocuments.ts for the seeding helper
33
33
  * @see ../../memory/define.ts for the underlying factory
34
+ * @see ../../memory/asRoleRefusal.ts for why `asRole` is refused, not honoured
34
35
  *
35
36
  * @example Basic usage
36
37
  * ```ts
@@ -63,6 +64,7 @@ import { mock } from 'agentfootprint/llm-providers';
63
64
  */
64
65
  import { MEMORY_TYPES, MEMORY_STRATEGIES } from '../../memory/define.types.js';
65
66
  import { defineMemory } from '../../memory/define.js';
67
+ import { refuseAsRole } from '../../memory/asRoleRefusal.js';
66
68
  /**
67
69
  * Build a RAG context-engineering definition. The returned
68
70
  * `MemoryDefinition` is registered on the Agent via `.rag(definition)`
@@ -75,6 +77,10 @@ export function defineRAG(opts) {
75
77
  if (!opts.id || opts.id.trim() === '') {
76
78
  throw new Error('defineRAG: `id` is required and must be non-empty.');
77
79
  }
80
+ // `asRole` no longer type-checks; this catches JavaScript callers and
81
+ // casts. Refused here rather than only inside `defineMemory` so the
82
+ // message names the factory the caller actually wrote.
83
+ refuseAsRole(opts, `defineRAG('${opts.id}')`);
78
84
  if (!opts.store) {
79
85
  throw new Error(`defineRAG[${opts.id}]: \`store\` is required.`);
80
86
  }
@@ -96,7 +102,6 @@ export function defineRAG(opts) {
96
102
  embedder: opts.embedder,
97
103
  },
98
104
  store: opts.store,
99
- asRole: opts.asRole ?? 'user',
100
105
  });
101
106
  }
102
107
  //# sourceMappingURL=defineRAG.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defineRAG.js","sourceRoot":"","sources":["../../../../src/lib/rag/defineRAG.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAMH,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,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AAC;QACxE,IAAI,EAAE,YAAY,CAAC,QAAQ;QAC3B,QAAQ,EAAE;YACR,IAAI,EAAE,iBAAiB,CAAC,KAAK;YAC7B,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC;YACpB,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,GAAG;YAChC,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB;QACD,KAAK,EAAE,IAAI,CAAC,KAAK;KAClB,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The `asRole` refusal — one sentence, said in every place the option
3
+ * could be declared.
4
+ *
5
+ * WHY this exists at all: `defineMemory({ asRole })` and
6
+ * `defineRAG({ asRole })` accepted a role, stored it on the returned
7
+ * `MemoryDefinition`, and NOTHING ever read it. Every formatter this
8
+ * library ships writes `role: 'system'` — `formatDefault`, `formatFacts`,
9
+ * `formatAsNarrative`, the causal `loadSnapshot`, and the auto pipeline —
10
+ * so recall has always been injected as system, whatever the option said.
11
+ * `defineRAG` even defaulted it to `'user'` and documented why, which made
12
+ * the lie legible: a reader could pick a role, read it back off the
13
+ * definition, and be told a role the run would never use.
14
+ *
15
+ * Delivering it instead is not a one-line change. Role-differentiated
16
+ * recall means putting non-system content into the message list, and the
17
+ * messages slot does not reach the model today (see
18
+ * `lib/injection-engine/messagesSlotRefusal.ts`): it is the observability
19
+ * projection of the conversation, not a wire. Honouring `asRole: 'user'`
20
+ * would have to route through that slot, which would trade a dead option
21
+ * for a recorded-and-dropped one — strictly worse, because the recording
22
+ * would then claim delivery.
23
+ *
24
+ * So the option is refused where it is written, and the refusal points at
25
+ * the feature that would make it real: role-differentiated recall arrives
26
+ * with messages delivery, if field evidence asks for it.
27
+ *
28
+ * A throw where there was a silent lie is a fix, not a break: nothing that
29
+ * worked stops working, and something that never worked stops pretending.
30
+ */
31
+ /**
32
+ * The refusal text, addressed from `site` (e.g. `defineRAG('product-docs')`).
33
+ * States the truth (never read; always system) and names what would change
34
+ * it, because a refusal that does not teach just moves the puzzle.
35
+ */
36
+ export declare function asRoleRefusal(site: string): string;
37
+ /**
38
+ * Throw the refusal when a caller passed `asRole`. Presence, not value —
39
+ * an explicit `asRole: 'system'` was just as unread as `asRole: 'user'`,
40
+ * and letting the "harmless" one through would teach that the option
41
+ * works.
42
+ */
43
+ export declare function refuseAsRole(options: object, site: string): void;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * The `asRole` refusal — one sentence, said in every place the option
3
+ * could be declared.
4
+ *
5
+ * WHY this exists at all: `defineMemory({ asRole })` and
6
+ * `defineRAG({ asRole })` accepted a role, stored it on the returned
7
+ * `MemoryDefinition`, and NOTHING ever read it. Every formatter this
8
+ * library ships writes `role: 'system'` — `formatDefault`, `formatFacts`,
9
+ * `formatAsNarrative`, the causal `loadSnapshot`, and the auto pipeline —
10
+ * so recall has always been injected as system, whatever the option said.
11
+ * `defineRAG` even defaulted it to `'user'` and documented why, which made
12
+ * the lie legible: a reader could pick a role, read it back off the
13
+ * definition, and be told a role the run would never use.
14
+ *
15
+ * Delivering it instead is not a one-line change. Role-differentiated
16
+ * recall means putting non-system content into the message list, and the
17
+ * messages slot does not reach the model today (see
18
+ * `lib/injection-engine/messagesSlotRefusal.ts`): it is the observability
19
+ * projection of the conversation, not a wire. Honouring `asRole: 'user'`
20
+ * would have to route through that slot, which would trade a dead option
21
+ * for a recorded-and-dropped one — strictly worse, because the recording
22
+ * would then claim delivery.
23
+ *
24
+ * So the option is refused where it is written, and the refusal points at
25
+ * the feature that would make it real: role-differentiated recall arrives
26
+ * with messages delivery, if field evidence asks for it.
27
+ *
28
+ * A throw where there was a silent lie is a fix, not a break: nothing that
29
+ * worked stops working, and something that never worked stops pretending.
30
+ */
31
+ /**
32
+ * The refusal text, addressed from `site` (e.g. `defineRAG('product-docs')`).
33
+ * States the truth (never read; always system) and names what would change
34
+ * it, because a refusal that does not teach just moves the puzzle.
35
+ */
36
+ export function asRoleRefusal(site) {
37
+ return (`${site}: \`asRole\` has never been read. Every formatter this library ships ` +
38
+ `writes \`role: 'system'\`, so recall is always injected as system — the option ` +
39
+ `was stored on the definition and ignored by the run. It is removed rather than ` +
40
+ `honoured, because honouring it means putting recall into the messages slot, ` +
41
+ `which does not reach the model. Role-differentiated recall arrives with the ` +
42
+ `messages-delivery feature, if field evidence asks for it. Drop the option: ` +
43
+ `the behaviour you already had does not change.`);
44
+ }
45
+ /**
46
+ * Throw the refusal when a caller passed `asRole`. Presence, not value —
47
+ * an explicit `asRole: 'system'` was just as unread as `asRole: 'user'`,
48
+ * and letting the "harmless" one through would teach that the option
49
+ * works.
50
+ */
51
+ export function refuseAsRole(options, site) {
52
+ if ('asRole' in options)
53
+ throw new Error(asRoleRefusal(site));
54
+ }
55
+ //# sourceMappingURL=asRoleRefusal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asRoleRefusal.js","sourceRoot":"","sources":["../../../src/memory/asRoleRefusal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,CACL,GAAG,IAAI,uEAAuE;QAC9E,iFAAiF;QACjF,iFAAiF;QACjF,8EAA8E;QAC9E,8EAA8E;QAC9E,6EAA6E;QAC7E,gDAAgD,CACjD,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,OAAe,EAAE,IAAY;IACxD,IAAI,QAAQ,IAAI,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;AAChE,CAAC"}